@mmmbuto/nexuscrew 0.9.0 → 0.9.2
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 +91 -0
- package/README.md +22 -4
- package/frontend/dist/assets/index-uRh_hSop.js +93 -0
- package/frontend/dist/index.html +1 -1
- package/frontend/dist/version.json +1 -1
- package/lib/cli/commands.js +14 -0
- package/lib/config.js +9 -0
- package/lib/fleet/builtin.js +57 -2
- package/lib/live-host/routes.js +9 -3
- package/lib/nodes/commands.js +15 -4
- package/lib/nodes/store.js +43 -0
- package/lib/nodes/tunnel.js +19 -0
- package/lib/proxy/federation.js +25 -1
- package/lib/proxy/panel-auth.js +63 -33
- package/lib/proxy/panel-proxy.js +41 -10
- package/lib/server.js +128 -6
- package/lib/settings/pairing-coordinator.js +32 -0
- package/lib/settings/public-peering-routes.js +13 -1
- package/package.json +1 -1
- package/skills/aidesktop/SKILL.md +201 -0
- package/skills/aidesktop/docker/Dockerfile +21 -0
- package/skills/aidesktop/docker/custom-cont-init.d/10-cdp-relay.sh +20 -0
- package/skills/aidesktop/docker/docker-compose.example.yml +75 -0
- package/skills/live/SKILL.md +90 -0
- package/skills/nexuscrew/SKILL.md +113 -0
- package/frontend/dist/assets/index-zjL6kZ7J.js +0 -93
- package/skills/alibaba-token-media/SKILL.md +0 -152
- package/skills/alibaba-token-media/agents/openai.yaml +0 -4
- package/skills/alibaba-token-media/references/api-contract.md +0 -97
- package/skills/alibaba-token-media/scripts/alibaba_token_media.py +0 -550
- package/skills/fill-forms/SKILL.md +0 -177
- package/skills/fill-forms/agents/openai.yaml +0 -4
- package/skills/fill-forms/references/overlay-technique.md +0 -99
- package/skills/fill-forms/requirements.txt +0 -4
- package/skills/fill-forms/scripts/dump_docx.py +0 -70
- package/skills/fill-forms/scripts/fill_docx.py +0 -207
- package/skills/fill-forms/scripts/fill_pdf.py +0 -424
- package/skills/fill-forms/scripts/inspect_pdf.py +0 -188
- package/skills/fill-forms/scripts/prepare_signature.py +0 -171
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))s(o);new MutationObserver(o=>{for(const a of o)if(a.type==="childList")for(const u of a.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&s(u)}).observe(document,{childList:!0,subtree:!0});function n(o){const a={};return o.integrity&&(a.integrity=o.integrity),o.referrerPolicy&&(a.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?a.credentials="include":o.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function s(o){if(o.ep)return;o.ep=!0;const a=n(o);fetch(o.href,a)}})();function Gh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ku={exports:{}},Ao={},qu={exports:{}},ct={};/**
|
|
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 fg;function m0(){if(fg)return ct;fg=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),u=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),y=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=y&&T[y]||T["@@iterator"],typeof T=="function"?T:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,N={};function S(T,H,Y){this.props=T,this.context=H,this.refs=N,this.updater=Y||b}S.prototype.isReactComponent={},S.prototype.setState=function(T,H){if(typeof T!="object"&&typeof T!="function"&&T!=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,T,H,"setState")},S.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function j(){}j.prototype=S.prototype;function C(T,H,Y){this.props=T,this.context=H,this.refs=N,this.updater=Y||b}var $=C.prototype=new j;$.constructor=C,k($,S.prototype),$.isPureReactComponent=!0;var O=Array.isArray,U=Object.prototype.hasOwnProperty,V={current:null},K={key:!0,ref:!0,__self:!0,__source:!0};function Z(T,H,Y){var de,ue={},fe=null,ve=null;if(H!=null)for(de in H.ref!==void 0&&(ve=H.ref),H.key!==void 0&&(fe=""+H.key),H)U.call(H,de)&&!K.hasOwnProperty(de)&&(ue[de]=H[de]);var ie=arguments.length-2;if(ie===1)ue.children=Y;else if(1<ie){for(var ye=Array(ie),Ue=0;Ue<ie;Ue++)ye[Ue]=arguments[Ue+2];ue.children=ye}if(T&&T.defaultProps)for(de in ie=T.defaultProps,ie)ue[de]===void 0&&(ue[de]=ie[de]);return{$$typeof:e,type:T,key:fe,ref:ve,props:ue,_owner:V.current}}function G(T,H){return{$$typeof:e,type:T.type,key:H,ref:T.ref,props:T.props,_owner:T._owner}}function Q(T){return typeof T=="object"&&T!==null&&T.$$typeof===e}function F(T){var H={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(Y){return H[Y]})}var B=/\/+/g;function A(T,H){return typeof T=="object"&&T!==null&&T.key!=null?F(""+T.key):H.toString(36)}function z(T,H,Y,de,ue){var fe=typeof T;(fe==="undefined"||fe==="boolean")&&(T=null);var ve=!1;if(T===null)ve=!0;else switch(fe){case"string":case"number":ve=!0;break;case"object":switch(T.$$typeof){case e:case t:ve=!0}}if(ve)return ve=T,ue=ue(ve),T=de===""?"."+A(ve,0):de,O(ue)?(Y="",T!=null&&(Y=T.replace(B,"$&/")+"/"),z(ue,H,Y,"",function(Ue){return Ue})):ue!=null&&(Q(ue)&&(ue=G(ue,Y+(!ue.key||ve&&ve.key===ue.key?"":(""+ue.key).replace(B,"$&/")+"/")+T)),H.push(ue)),1;if(ve=0,de=de===""?".":de+":",O(T))for(var ie=0;ie<T.length;ie++){fe=T[ie];var ye=de+A(fe,ie);ve+=z(fe,H,Y,ye,ue)}else if(ye=w(T),typeof ye=="function")for(T=ye.call(T),ie=0;!(fe=T.next()).done;)fe=fe.value,ye=de+A(fe,ie++),ve+=z(fe,H,Y,ye,ue);else if(fe==="object")throw H=String(T),Error("Objects are not valid as a React child (found: "+(H==="[object Object]"?"object with keys {"+Object.keys(T).join(", ")+"}":H)+"). If you meant to render a collection of children, use an array instead.");return ve}function I(T,H,Y){if(T==null)return T;var de=[],ue=0;return z(T,de,"","",function(fe){return H.call(Y,fe,ue++)}),de}function D(T){if(T._status===-1){var H=T._result;H=H(),H.then(function(Y){(T._status===0||T._status===-1)&&(T._status=1,T._result=Y)},function(Y){(T._status===0||T._status===-1)&&(T._status=2,T._result=Y)}),T._status===-1&&(T._status=0,T._result=H)}if(T._status===1)return T._result.default;throw T._result}var P={current:null},x={transition:null},M={ReactCurrentDispatcher:P,ReactCurrentBatchConfig:x,ReactCurrentOwner:V};function L(){throw Error("act(...) is not supported in production builds of React.")}return ct.Children={map:I,forEach:function(T,H,Y){I(T,function(){H.apply(this,arguments)},Y)},count:function(T){var H=0;return I(T,function(){H++}),H},toArray:function(T){return I(T,function(H){return H})||[]},only:function(T){if(!Q(T))throw Error("React.Children.only expected to receive a single React element child.");return T}},ct.Component=S,ct.Fragment=n,ct.Profiler=o,ct.PureComponent=C,ct.StrictMode=s,ct.Suspense=p,ct.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=M,ct.act=L,ct.cloneElement=function(T,H,Y){if(T==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+T+".");var de=k({},T.props),ue=T.key,fe=T.ref,ve=T._owner;if(H!=null){if(H.ref!==void 0&&(fe=H.ref,ve=V.current),H.key!==void 0&&(ue=""+H.key),T.type&&T.type.defaultProps)var ie=T.type.defaultProps;for(ye in H)U.call(H,ye)&&!K.hasOwnProperty(ye)&&(de[ye]=H[ye]===void 0&&ie!==void 0?ie[ye]:H[ye])}var ye=arguments.length-2;if(ye===1)de.children=Y;else if(1<ye){ie=Array(ye);for(var Ue=0;Ue<ye;Ue++)ie[Ue]=arguments[Ue+2];de.children=ie}return{$$typeof:e,type:T.type,key:ue,ref:fe,props:de,_owner:ve}},ct.createContext=function(T){return T={$$typeof:u,_currentValue:T,_currentValue2:T,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},T.Provider={$$typeof:a,_context:T},T.Consumer=T},ct.createElement=Z,ct.createFactory=function(T){var H=Z.bind(null,T);return H.type=T,H},ct.createRef=function(){return{current:null}},ct.forwardRef=function(T){return{$$typeof:h,render:T}},ct.isValidElement=Q,ct.lazy=function(T){return{$$typeof:v,_payload:{_status:-1,_result:T},_init:D}},ct.memo=function(T,H){return{$$typeof:m,type:T,compare:H===void 0?null:H}},ct.startTransition=function(T){var H=x.transition;x.transition={};try{T()}finally{x.transition=H}},ct.unstable_act=L,ct.useCallback=function(T,H){return P.current.useCallback(T,H)},ct.useContext=function(T){return P.current.useContext(T)},ct.useDebugValue=function(){},ct.useDeferredValue=function(T){return P.current.useDeferredValue(T)},ct.useEffect=function(T,H){return P.current.useEffect(T,H)},ct.useId=function(){return P.current.useId()},ct.useImperativeHandle=function(T,H,Y){return P.current.useImperativeHandle(T,H,Y)},ct.useInsertionEffect=function(T,H){return P.current.useInsertionEffect(T,H)},ct.useLayoutEffect=function(T,H){return P.current.useLayoutEffect(T,H)},ct.useMemo=function(T,H){return P.current.useMemo(T,H)},ct.useReducer=function(T,H,Y){return P.current.useReducer(T,H,Y)},ct.useRef=function(T){return P.current.useRef(T)},ct.useState=function(T){return P.current.useState(T)},ct.useSyncExternalStore=function(T,H,Y){return P.current.useSyncExternalStore(T,H,Y)},ct.useTransition=function(){return P.current.useTransition()},ct.version="18.3.1",ct}var pg;function Xh(){return pg||(pg=1,qu.exports=m0()),qu.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 mg;function g0(){if(mg)return Ao;mg=1;var e=Xh(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function u(h,p,m){var v,y={},w=null,b=null;m!==void 0&&(w=""+m),p.key!==void 0&&(w=""+p.key),p.ref!==void 0&&(b=p.ref);for(v in p)s.call(p,v)&&!a.hasOwnProperty(v)&&(y[v]=p[v]);if(h&&h.defaultProps)for(v in p=h.defaultProps,p)y[v]===void 0&&(y[v]=p[v]);return{$$typeof:t,type:h,key:w,ref:b,props:y,_owner:o.current}}return Ao.Fragment=n,Ao.jsx=u,Ao.jsxs=u,Ao}var gg;function v0(){return gg||(gg=1,Ku.exports=g0()),Ku.exports}var l=v0(),E=Xh();const _0=Gh(E);var fl={},Vu={exports:{}},Wn={},Yu={exports:{}},Gu={};/**
|
|
18
|
-
* @license React
|
|
19
|
-
* scheduler.production.min.js
|
|
20
|
-
*
|
|
21
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
22
|
-
*
|
|
23
|
-
* This source code is licensed under the MIT license found in the
|
|
24
|
-
* LICENSE file in the root directory of this source tree.
|
|
25
|
-
*/var vg;function y0(){return vg||(vg=1,(function(e){function t(x,M){var L=x.length;x.push(M);e:for(;0<L;){var T=L-1>>>1,H=x[T];if(0<o(H,M))x[T]=M,x[L]=H,L=T;else break e}}function n(x){return x.length===0?null:x[0]}function s(x){if(x.length===0)return null;var M=x[0],L=x.pop();if(L!==M){x[0]=L;e:for(var T=0,H=x.length,Y=H>>>1;T<Y;){var de=2*(T+1)-1,ue=x[de],fe=de+1,ve=x[fe];if(0>o(ue,L))fe<H&&0>o(ve,ue)?(x[T]=ve,x[fe]=L,T=fe):(x[T]=ue,x[de]=L,T=de);else if(fe<H&&0>o(ve,L))x[T]=ve,x[fe]=L,T=fe;else break e}}return M}function o(x,M){var L=x.sortIndex-M.sortIndex;return L!==0?L:x.id-M.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var u=Date,h=u.now();e.unstable_now=function(){return u.now()-h}}var p=[],m=[],v=1,y=null,w=3,b=!1,k=!1,N=!1,S=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function $(x){for(var M=n(m);M!==null;){if(M.callback===null)s(m);else if(M.startTime<=x)s(m),M.sortIndex=M.expirationTime,t(p,M);else break;M=n(m)}}function O(x){if(N=!1,$(x),!k)if(n(p)!==null)k=!0,D(U);else{var M=n(m);M!==null&&P(O,M.startTime-x)}}function U(x,M){k=!1,N&&(N=!1,j(Z),Z=-1),b=!0;var L=w;try{for($(M),y=n(p);y!==null&&(!(y.expirationTime>M)||x&&!F());){var T=y.callback;if(typeof T=="function"){y.callback=null,w=y.priorityLevel;var H=T(y.expirationTime<=M);M=e.unstable_now(),typeof H=="function"?y.callback=H:y===n(p)&&s(p),$(M)}else s(p);y=n(p)}if(y!==null)var Y=!0;else{var de=n(m);de!==null&&P(O,de.startTime-M),Y=!1}return Y}finally{y=null,w=L,b=!1}}var V=!1,K=null,Z=-1,G=5,Q=-1;function F(){return!(e.unstable_now()-Q<G)}function B(){if(K!==null){var x=e.unstable_now();Q=x;var M=!0;try{M=K(!0,x)}finally{M?A():(V=!1,K=null)}}else V=!1}var A;if(typeof C=="function")A=function(){C(B)};else if(typeof MessageChannel<"u"){var z=new MessageChannel,I=z.port2;z.port1.onmessage=B,A=function(){I.postMessage(null)}}else A=function(){S(B,0)};function D(x){K=x,V||(V=!0,A())}function P(x,M){Z=S(function(){x(e.unstable_now())},M)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(x){x.callback=null},e.unstable_continueExecution=function(){k||b||(k=!0,D(U))},e.unstable_forceFrameRate=function(x){0>x||125<x?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):G=0<x?Math.floor(1e3/x):5},e.unstable_getCurrentPriorityLevel=function(){return w},e.unstable_getFirstCallbackNode=function(){return n(p)},e.unstable_next=function(x){switch(w){case 1:case 2:case 3:var M=3;break;default:M=w}var L=w;w=M;try{return x()}finally{w=L}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(x,M){switch(x){case 1:case 2:case 3:case 4:case 5:break;default:x=3}var L=w;w=x;try{return M()}finally{w=L}},e.unstable_scheduleCallback=function(x,M,L){var T=e.unstable_now();switch(typeof L=="object"&&L!==null?(L=L.delay,L=typeof L=="number"&&0<L?T+L:T):L=T,x){case 1:var H=-1;break;case 2:H=250;break;case 5:H=1073741823;break;case 4:H=1e4;break;default:H=5e3}return H=L+H,x={id:v++,callback:M,priorityLevel:x,startTime:L,expirationTime:H,sortIndex:-1},L>T?(x.sortIndex=L,t(m,x),n(p)===null&&x===n(m)&&(N?(j(Z),Z=-1):N=!0,P(O,L-T))):(x.sortIndex=H,t(p,x),k||b||(k=!0,D(U))),x},e.unstable_shouldYield=F,e.unstable_wrapCallback=function(x){var M=w;return function(){var L=w;w=M;try{return x.apply(this,arguments)}finally{w=L}}}})(Gu)),Gu}var _g;function w0(){return _g||(_g=1,Yu.exports=y0()),Yu.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 yg;function b0(){if(yg)return Wn;yg=1;var e=Xh(),t=w0();function n(i){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+i,c=1;c<arguments.length;c++)r+="&args[]="+encodeURIComponent(arguments[c]);return"Minified React error #"+i+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var s=new Set,o={};function a(i,r){u(i,r),u(i+"Capture",r)}function u(i,r){for(o[i]=r,i=0;i<r.length;i++)s.add(r[i])}var h=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,m=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,v={},y={};function w(i){return p.call(y,i)?!0:p.call(v,i)?!1:m.test(i)?y[i]=!0:(v[i]=!0,!1)}function b(i,r,c,d){if(c!==null&&c.type===0)return!1;switch(typeof r){case"function":case"symbol":return!0;case"boolean":return d?!1:c!==null?!c.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function k(i,r,c,d){if(r===null||typeof r>"u"||b(i,r,c,d))return!0;if(d)return!1;if(c!==null)switch(c.type){case 3:return!r;case 4:return r===!1;case 5:return isNaN(r);case 6:return isNaN(r)||1>r}return!1}function N(i,r,c,d,g,_,R){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=d,this.attributeNamespace=g,this.mustUseProperty=c,this.propertyName=i,this.type=r,this.sanitizeURL=_,this.removeEmptyString=R}var S={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){S[i]=new N(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var r=i[0];S[r]=new N(r,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){S[i]=new N(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){S[i]=new N(i,2,!1,i,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(i){S[i]=new N(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){S[i]=new N(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){S[i]=new N(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){S[i]=new N(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){S[i]=new N(i,5,!1,i.toLowerCase(),null,!1,!1)});var j=/[\-:]([a-z])/g;function C(i){return i[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(i){var r=i.replace(j,C);S[r]=new N(r,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var r=i.replace(j,C);S[r]=new N(r,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var r=i.replace(j,C);S[r]=new N(r,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){S[i]=new N(i,1,!1,i.toLowerCase(),null,!1,!1)}),S.xlinkHref=new N("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){S[i]=new N(i,1,!1,i.toLowerCase(),null,!0,!0)});function $(i,r,c,d){var g=S.hasOwnProperty(r)?S[r]:null;(g!==null?g.type!==0:d||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(k(r,c,g,d)&&(c=null),d||g===null?w(r)&&(c===null?i.removeAttribute(r):i.setAttribute(r,""+c)):g.mustUseProperty?i[g.propertyName]=c===null?g.type===3?!1:"":c:(r=g.attributeName,d=g.attributeNamespace,c===null?i.removeAttribute(r):(g=g.type,c=g===3||g===4&&c===!0?"":""+c,d?i.setAttributeNS(d,r,c):i.setAttribute(r,c))))}var O=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,U=Symbol.for("react.element"),V=Symbol.for("react.portal"),K=Symbol.for("react.fragment"),Z=Symbol.for("react.strict_mode"),G=Symbol.for("react.profiler"),Q=Symbol.for("react.provider"),F=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),A=Symbol.for("react.suspense"),z=Symbol.for("react.suspense_list"),I=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),P=Symbol.for("react.offscreen"),x=Symbol.iterator;function M(i){return i===null||typeof i!="object"?null:(i=x&&i[x]||i["@@iterator"],typeof i=="function"?i:null)}var L=Object.assign,T;function H(i){if(T===void 0)try{throw Error()}catch(c){var r=c.stack.trim().match(/\n( *(at )?)/);T=r&&r[1]||""}return`
|
|
34
|
-
`+T+i}var Y=!1;function de(i,r){if(!i||Y)return"";Y=!0;var c=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(r)if(r=function(){throw Error()},Object.defineProperty(r.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(r,[])}catch(ae){var d=ae}Reflect.construct(i,[],r)}else{try{r.call()}catch(ae){d=ae}i.call(r.prototype)}else{try{throw Error()}catch(ae){d=ae}i()}}catch(ae){if(ae&&d&&typeof ae.stack=="string"){for(var g=ae.stack.split(`
|
|
35
|
-
`),_=d.stack.split(`
|
|
36
|
-
`),R=g.length-1,q=_.length-1;1<=R&&0<=q&&g[R]!==_[q];)q--;for(;1<=R&&0<=q;R--,q--)if(g[R]!==_[q]){if(R!==1||q!==1)do if(R--,q--,0>q||g[R]!==_[q]){var J=`
|
|
37
|
-
`+g[R].replace(" at new "," at ");return i.displayName&&J.includes("<anonymous>")&&(J=J.replace("<anonymous>",i.displayName)),J}while(1<=R&&0<=q);break}}}finally{Y=!1,Error.prepareStackTrace=c}return(i=i?i.displayName||i.name:"")?H(i):""}function ue(i){switch(i.tag){case 5:return H(i.type);case 16:return H("Lazy");case 13:return H("Suspense");case 19:return H("SuspenseList");case 0:case 2:case 15:return i=de(i.type,!1),i;case 11:return i=de(i.type.render,!1),i;case 1:return i=de(i.type,!0),i;default:return""}}function fe(i){if(i==null)return null;if(typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case K:return"Fragment";case V:return"Portal";case G:return"Profiler";case Z:return"StrictMode";case A:return"Suspense";case z:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case F:return(i.displayName||"Context")+".Consumer";case Q:return(i._context.displayName||"Context")+".Provider";case B:var r=i.render;return i=i.displayName,i||(i=r.displayName||r.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case I:return r=i.displayName||null,r!==null?r:fe(i.type)||"Memo";case D:r=i._payload,i=i._init;try{return fe(i(r))}catch{}}return null}function ve(i){var r=i.type;switch(i.tag){case 24:return"Cache";case 9:return(r.displayName||"Context")+".Consumer";case 10:return(r._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return i=r.render,i=i.displayName||i.name||"",r.displayName||(i!==""?"ForwardRef("+i+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return fe(r);case 8:return r===Z?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r}return null}function ie(i){switch(typeof i){case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function ye(i){var r=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Ue(i){var r=ye(i)?"checked":"value",c=Object.getOwnPropertyDescriptor(i.constructor.prototype,r),d=""+i[r];if(!i.hasOwnProperty(r)&&typeof c<"u"&&typeof c.get=="function"&&typeof c.set=="function"){var g=c.get,_=c.set;return Object.defineProperty(i,r,{configurable:!0,get:function(){return g.call(this)},set:function(R){d=""+R,_.call(this,R)}}),Object.defineProperty(i,r,{enumerable:c.enumerable}),{getValue:function(){return d},setValue:function(R){d=""+R},stopTracking:function(){i._valueTracker=null,delete i[r]}}}}function ut(i){i._valueTracker||(i._valueTracker=Ue(i))}function rt(i){if(!i)return!1;var r=i._valueTracker;if(!r)return!0;var c=r.getValue(),d="";return i&&(d=ye(i)?i.checked?"true":"false":i.value),i=d,i!==c?(r.setValue(i),!0):!1}function Ae(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}function Dt(i,r){var c=r.checked;return L({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:c??i._wrapperState.initialChecked})}function Qt(i,r){var c=r.defaultValue==null?"":r.defaultValue,d=r.checked!=null?r.checked:r.defaultChecked;c=ie(r.value!=null?r.value:c),i._wrapperState={initialChecked:d,initialValue:c,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function $e(i,r){r=r.checked,r!=null&&$(i,"checked",r,!1)}function dt(i,r){$e(i,r);var c=ie(r.value),d=r.type;if(c!=null)d==="number"?(c===0&&i.value===""||i.value!=c)&&(i.value=""+c):i.value!==""+c&&(i.value=""+c);else if(d==="submit"||d==="reset"){i.removeAttribute("value");return}r.hasOwnProperty("value")?wt(i,r.type,c):r.hasOwnProperty("defaultValue")&&wt(i,r.type,ie(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(i.defaultChecked=!!r.defaultChecked)}function it(i,r,c){if(r.hasOwnProperty("value")||r.hasOwnProperty("defaultValue")){var d=r.type;if(!(d!=="submit"&&d!=="reset"||r.value!==void 0&&r.value!==null))return;r=""+i._wrapperState.initialValue,c||r===i.value||(i.value=r),i.defaultValue=r}c=i.name,c!==""&&(i.name=""),i.defaultChecked=!!i._wrapperState.initialChecked,c!==""&&(i.name=c)}function wt(i,r,c){(r!=="number"||Ae(i.ownerDocument)!==i)&&(c==null?i.defaultValue=""+i._wrapperState.initialValue:i.defaultValue!==""+c&&(i.defaultValue=""+c))}var bt=Array.isArray;function mt(i,r,c,d){if(i=i.options,r){r={};for(var g=0;g<c.length;g++)r["$"+c[g]]=!0;for(c=0;c<i.length;c++)g=r.hasOwnProperty("$"+i[c].value),i[c].selected!==g&&(i[c].selected=g),g&&d&&(i[c].defaultSelected=!0)}else{for(c=""+ie(c),r=null,g=0;g<i.length;g++){if(i[g].value===c){i[g].selected=!0,d&&(i[g].defaultSelected=!0);return}r!==null||i[g].disabled||(r=i[g])}r!==null&&(r.selected=!0)}}function gt(i,r){if(r.dangerouslySetInnerHTML!=null)throw Error(n(91));return L({},r,{value:void 0,defaultValue:void 0,children:""+i._wrapperState.initialValue})}function pt(i,r){var c=r.value;if(c==null){if(c=r.children,r=r.defaultValue,c!=null){if(r!=null)throw Error(n(92));if(bt(c)){if(1<c.length)throw Error(n(93));c=c[0]}r=c}r==null&&(r=""),c=r}i._wrapperState={initialValue:ie(c)}}function Pt(i,r){var c=ie(r.value),d=ie(r.defaultValue);c!=null&&(c=""+c,c!==i.value&&(i.value=c),r.defaultValue==null&&i.defaultValue!==c&&(i.defaultValue=c)),d!=null&&(i.defaultValue=""+d)}function vt(i){var r=i.textContent;r===i._wrapperState.initialValue&&r!==""&&r!==null&&(i.value=r)}function xt(i){switch(i){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Se(i,r){return i==null||i==="http://www.w3.org/1999/xhtml"?xt(r):i==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":i}var le,Pe=(function(i){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,c,d,g){MSApp.execUnsafeLocalFunction(function(){return i(r,c,d,g)})}:i})(function(i,r){if(i.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in i)i.innerHTML=r;else{for(le=le||document.createElement("div"),le.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=le.firstChild;i.firstChild;)i.removeChild(i.firstChild);for(;r.firstChild;)i.appendChild(r.firstChild)}});function We(i,r){if(r){var c=i.firstChild;if(c&&c===i.lastChild&&c.nodeType===3){c.nodeValue=r;return}}i.textContent=r}var te={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},we=["Webkit","ms","Moz","O"];Object.keys(te).forEach(function(i){we.forEach(function(r){r=r+i.charAt(0).toUpperCase()+i.substring(1),te[r]=te[i]})});function Ne(i,r,c){return r==null||typeof r=="boolean"||r===""?"":c||typeof r!="number"||r===0||te.hasOwnProperty(i)&&te[i]?(""+r).trim():r+"px"}function De(i,r){i=i.style;for(var c in r)if(r.hasOwnProperty(c)){var d=c.indexOf("--")===0,g=Ne(c,r[c],d);c==="float"&&(c="cssFloat"),d?i.setProperty(c,g):i[c]=g}}var Oe=L({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 _t(i,r){if(r){if(Oe[i]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(n(137,i));if(r.dangerouslySetInnerHTML!=null){if(r.children!=null)throw Error(n(60));if(typeof r.dangerouslySetInnerHTML!="object"||!("__html"in r.dangerouslySetInnerHTML))throw Error(n(61))}if(r.style!=null&&typeof r.style!="object")throw Error(n(62))}}function yt(i,r){if(i.indexOf("-")===-1)return typeof r.is=="string";switch(i){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var X=null;function se(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var W=null,oe=null,pe=null;function _e(i){if(i=go(i)){if(typeof W!="function")throw Error(n(280));var r=i.stateNode;r&&(r=ja(r),W(i.stateNode,i.type,r))}}function Be(i){oe?pe?pe.push(i):pe=[i]:oe=i}function me(){if(oe){var i=oe,r=pe;if(pe=oe=null,_e(i),r)for(i=0;i<r.length;i++)_e(r[i])}}function Ce(i,r){return i(r)}function Ge(){}var rn=!1;function tt(i,r,c){if(rn)return i(r,c);rn=!0;try{return Ce(i,r,c)}finally{rn=!1,(oe!==null||pe!==null)&&(Ge(),me())}}function bn(i,r){var c=i.stateNode;if(c===null)return null;var d=ja(c);if(d===null)return null;c=d[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(d=!d.disabled)||(i=i.type,d=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!d;break e;default:i=!1}if(i)return null;if(c&&typeof c!="function")throw Error(n(231,r,typeof c));return c}var Ct=!1;if(h)try{var Xe={};Object.defineProperty(Xe,"passive",{get:function(){Ct=!0}}),window.addEventListener("test",Xe,Xe),window.removeEventListener("test",Xe,Xe)}catch{Ct=!1}function Jt(i,r,c,d,g,_,R,q,J){var ae=Array.prototype.slice.call(arguments,3);try{r.apply(c,ae)}catch(xe){this.onError(xe)}}var dn=!1,qn=null,ce=!1,je=null,qe={onError:function(i){dn=!0,qn=i}};function ot(i,r,c,d,g,_,R,q,J){dn=!1,qn=null,Jt.apply(qe,arguments)}function Vt(i,r,c,d,g,_,R,q,J){if(ot.apply(this,arguments),dn){if(dn){var ae=qn;dn=!1,qn=null}else throw Error(n(198));ce||(ce=!0,je=ae)}}function Nt(i){var r=i,c=i;if(i.alternate)for(;r.return;)r=r.return;else{i=r;do r=i,(r.flags&4098)!==0&&(c=r.return),i=r.return;while(i)}return r.tag===3?c:null}function Qi(i){if(i.tag===13){var r=i.memoizedState;if(r===null&&(i=i.alternate,i!==null&&(r=i.memoizedState)),r!==null)return r.dehydrated}return null}function An(i){if(Nt(i)!==i)throw Error(n(188))}function Di(i){var r=i.alternate;if(!r){if(r=Nt(i),r===null)throw Error(n(188));return r!==i?null:i}for(var c=i,d=r;;){var g=c.return;if(g===null)break;var _=g.alternate;if(_===null){if(d=g.return,d!==null){c=d;continue}break}if(g.child===_.child){for(_=g.child;_;){if(_===c)return An(g),i;if(_===d)return An(g),r;_=_.sibling}throw Error(n(188))}if(c.return!==d.return)c=g,d=_;else{for(var R=!1,q=g.child;q;){if(q===c){R=!0,c=g,d=_;break}if(q===d){R=!0,d=g,c=_;break}q=q.sibling}if(!R){for(q=_.child;q;){if(q===c){R=!0,c=_,d=g;break}if(q===d){R=!0,d=_,c=g;break}q=q.sibling}if(!R)throw Error(n(189))}}if(c.alternate!==d)throw Error(n(190))}if(c.tag!==3)throw Error(n(188));return c.stateNode.current===c?i:r}function Ps(i){return i=Di(i),i!==null?Yr(i):null}function Yr(i){if(i.tag===5||i.tag===6)return i;for(i=i.child;i!==null;){var r=Yr(i);if(r!==null)return r;i=i.sibling}return null}var As=t.unstable_scheduleCallback,Gr=t.unstable_cancelCallback,sr=t.unstable_shouldYield,ca=t.unstable_requestPaint,It=t.unstable_now,he=t.unstable_getCurrentPriorityLevel,Ke=t.unstable_ImmediatePriority,Je=t.unstable_UserBlockingPriority,Qe=t.unstable_NormalPriority,Et=t.unstable_LowPriority,At=t.unstable_IdlePriority,Zt=null,hn=null;function dc(i){if(hn&&typeof hn.onCommitFiberRoot=="function")try{hn.onCommitFiberRoot(Zt,i,void 0,(i.current.flags&128)===128)}catch{}}var Bn=Math.clz32?Math.clz32:Tb,Xr=Math.log,Lb=Math.LN2;function Tb(i){return i>>>=0,i===0?32:31-(Xr(i)/Lb|0)|0}var ua=64,da=4194304;function Qr(i){switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return i&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return i}}function ha(i,r){var c=i.pendingLanes;if(c===0)return 0;var d=0,g=i.suspendedLanes,_=i.pingedLanes,R=c&268435455;if(R!==0){var q=R&~g;q!==0?d=Qr(q):(_&=R,_!==0&&(d=Qr(_)))}else R=c&~g,R!==0?d=Qr(R):_!==0&&(d=Qr(_));if(d===0)return 0;if(r!==0&&r!==d&&(r&g)===0&&(g=d&-d,_=r&-r,g>=_||g===16&&(_&4194240)!==0))return r;if((d&4)!==0&&(d|=c&16),r=i.entangledLanes,r!==0)for(i=i.entanglements,r&=d;0<r;)c=31-Bn(r),g=1<<c,d|=i[c],r&=~g;return d}function Mb(i,r){switch(i){case 1:case 2:case 4:return r+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Db(i,r){for(var c=i.suspendedLanes,d=i.pingedLanes,g=i.expirationTimes,_=i.pendingLanes;0<_;){var R=31-Bn(_),q=1<<R,J=g[R];J===-1?((q&c)===0||(q&d)!==0)&&(g[R]=Mb(q,r)):J<=r&&(i.expiredLanes|=q),_&=~q}}function hc(i){return i=i.pendingLanes&-1073741825,i!==0?i:i&1073741824?1073741824:0}function Wf(){var i=ua;return ua<<=1,(ua&4194240)===0&&(ua=64),i}function fc(i){for(var r=[],c=0;31>c;c++)r.push(i);return r}function Jr(i,r,c){i.pendingLanes|=r,r!==536870912&&(i.suspendedLanes=0,i.pingedLanes=0),i=i.eventTimes,r=31-Bn(r),i[r]=c}function Ib(i,r){var c=i.pendingLanes&~r;i.pendingLanes=r,i.suspendedLanes=0,i.pingedLanes=0,i.expiredLanes&=r,i.mutableReadLanes&=r,i.entangledLanes&=r,r=i.entanglements;var d=i.eventTimes;for(i=i.expirationTimes;0<c;){var g=31-Bn(c),_=1<<g;r[g]=0,d[g]=-1,i[g]=-1,c&=~_}}function pc(i,r){var c=i.entangledLanes|=r;for(i=i.entanglements;c;){var d=31-Bn(c),g=1<<d;g&r|i[d]&r&&(i[d]|=r),c&=~g}}var St=0;function Kf(i){return i&=-i,1<i?4<i?(i&268435455)!==0?16:536870912:4:1}var qf,mc,Vf,Yf,Gf,gc=!1,fa=[],Ji=null,Zi=null,es=null,Zr=new Map,eo=new Map,ts=[],Ob="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 Xf(i,r){switch(i){case"focusin":case"focusout":Ji=null;break;case"dragenter":case"dragleave":Zi=null;break;case"mouseover":case"mouseout":es=null;break;case"pointerover":case"pointerout":Zr.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":eo.delete(r.pointerId)}}function to(i,r,c,d,g,_){return i===null||i.nativeEvent!==_?(i={blockedOn:r,domEventName:c,eventSystemFlags:d,nativeEvent:_,targetContainers:[g]},r!==null&&(r=go(r),r!==null&&mc(r)),i):(i.eventSystemFlags|=d,r=i.targetContainers,g!==null&&r.indexOf(g)===-1&&r.push(g),i)}function Bb(i,r,c,d,g){switch(r){case"focusin":return Ji=to(Ji,i,r,c,d,g),!0;case"dragenter":return Zi=to(Zi,i,r,c,d,g),!0;case"mouseover":return es=to(es,i,r,c,d,g),!0;case"pointerover":var _=g.pointerId;return Zr.set(_,to(Zr.get(_)||null,i,r,c,d,g)),!0;case"gotpointercapture":return _=g.pointerId,eo.set(_,to(eo.get(_)||null,i,r,c,d,g)),!0}return!1}function Qf(i){var r=Ls(i.target);if(r!==null){var c=Nt(r);if(c!==null){if(r=c.tag,r===13){if(r=Qi(c),r!==null){i.blockedOn=r,Gf(i.priority,function(){Vf(c)});return}}else if(r===3&&c.stateNode.current.memoizedState.isDehydrated){i.blockedOn=c.tag===3?c.stateNode.containerInfo:null;return}}}i.blockedOn=null}function pa(i){if(i.blockedOn!==null)return!1;for(var r=i.targetContainers;0<r.length;){var c=_c(i.domEventName,i.eventSystemFlags,r[0],i.nativeEvent);if(c===null){c=i.nativeEvent;var d=new c.constructor(c.type,c);X=d,c.target.dispatchEvent(d),X=null}else return r=go(c),r!==null&&mc(r),i.blockedOn=c,!1;r.shift()}return!0}function Jf(i,r,c){pa(i)&&c.delete(r)}function zb(){gc=!1,Ji!==null&&pa(Ji)&&(Ji=null),Zi!==null&&pa(Zi)&&(Zi=null),es!==null&&pa(es)&&(es=null),Zr.forEach(Jf),eo.forEach(Jf)}function no(i,r){i.blockedOn===r&&(i.blockedOn=null,gc||(gc=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,zb)))}function io(i){function r(g){return no(g,i)}if(0<fa.length){no(fa[0],i);for(var c=1;c<fa.length;c++){var d=fa[c];d.blockedOn===i&&(d.blockedOn=null)}}for(Ji!==null&&no(Ji,i),Zi!==null&&no(Zi,i),es!==null&&no(es,i),Zr.forEach(r),eo.forEach(r),c=0;c<ts.length;c++)d=ts[c],d.blockedOn===i&&(d.blockedOn=null);for(;0<ts.length&&(c=ts[0],c.blockedOn===null);)Qf(c),c.blockedOn===null&&ts.shift()}var rr=O.ReactCurrentBatchConfig,ma=!0;function $b(i,r,c,d){var g=St,_=rr.transition;rr.transition=null;try{St=1,vc(i,r,c,d)}finally{St=g,rr.transition=_}}function Fb(i,r,c,d){var g=St,_=rr.transition;rr.transition=null;try{St=4,vc(i,r,c,d)}finally{St=g,rr.transition=_}}function vc(i,r,c,d){if(ma){var g=_c(i,r,c,d);if(g===null)Dc(i,r,d,ga,c),Xf(i,d);else if(Bb(g,i,r,c,d))d.stopPropagation();else if(Xf(i,d),r&4&&-1<Ob.indexOf(i)){for(;g!==null;){var _=go(g);if(_!==null&&qf(_),_=_c(i,r,c,d),_===null&&Dc(i,r,d,ga,c),_===g)break;g=_}g!==null&&d.stopPropagation()}else Dc(i,r,d,null,c)}}var ga=null;function _c(i,r,c,d){if(ga=null,i=se(d),i=Ls(i),i!==null)if(r=Nt(i),r===null)i=null;else if(c=r.tag,c===13){if(i=Qi(r),i!==null)return i;i=null}else if(c===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;i=null}else r!==i&&(i=null);return ga=i,null}function Zf(i){switch(i){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(he()){case Ke:return 1;case Je:return 4;case Qe:case Et:return 16;case At:return 536870912;default:return 16}default:return 16}}var ns=null,yc=null,va=null;function ep(){if(va)return va;var i,r=yc,c=r.length,d,g="value"in ns?ns.value:ns.textContent,_=g.length;for(i=0;i<c&&r[i]===g[i];i++);var R=c-i;for(d=1;d<=R&&r[c-d]===g[_-d];d++);return va=g.slice(i,1<d?1-d:void 0)}function _a(i){var r=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&r===13&&(i=13)):i=r,i===10&&(i=13),32<=i||i===13?i:0}function ya(){return!0}function tp(){return!1}function Vn(i){function r(c,d,g,_,R){this._reactName=c,this._targetInst=g,this.type=d,this.nativeEvent=_,this.target=R,this.currentTarget=null;for(var q in i)i.hasOwnProperty(q)&&(c=i[q],this[q]=c?c(_):_[q]);return this.isDefaultPrevented=(_.defaultPrevented!=null?_.defaultPrevented:_.returnValue===!1)?ya:tp,this.isPropagationStopped=tp,this}return L(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var c=this.nativeEvent;c&&(c.preventDefault?c.preventDefault():typeof c.returnValue!="unknown"&&(c.returnValue=!1),this.isDefaultPrevented=ya)},stopPropagation:function(){var c=this.nativeEvent;c&&(c.stopPropagation?c.stopPropagation():typeof c.cancelBubble!="unknown"&&(c.cancelBubble=!0),this.isPropagationStopped=ya)},persist:function(){},isPersistent:ya}),r}var or={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},wc=Vn(or),so=L({},or,{view:0,detail:0}),Hb=Vn(so),bc,Sc,ro,wa=L({},so,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:kc,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==ro&&(ro&&i.type==="mousemove"?(bc=i.screenX-ro.screenX,Sc=i.screenY-ro.screenY):Sc=bc=0,ro=i),bc)},movementY:function(i){return"movementY"in i?i.movementY:Sc}}),np=Vn(wa),Ub=L({},wa,{dataTransfer:0}),Wb=Vn(Ub),Kb=L({},so,{relatedTarget:0}),xc=Vn(Kb),qb=L({},or,{animationName:0,elapsedTime:0,pseudoElement:0}),Vb=Vn(qb),Yb=L({},or,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),Gb=Vn(Yb),Xb=L({},or,{data:0}),ip=Vn(Xb),Qb={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Jb={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"},Zb={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function eS(i){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(i):(i=Zb[i])?!!r[i]:!1}function kc(){return eS}var tS=L({},so,{key:function(i){if(i.key){var r=Qb[i.key]||i.key;if(r!=="Unidentified")return r}return i.type==="keypress"?(i=_a(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?Jb[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:kc,charCode:function(i){return i.type==="keypress"?_a(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?_a(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),nS=Vn(tS),iS=L({},wa,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),sp=Vn(iS),sS=L({},so,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:kc}),rS=Vn(sS),oS=L({},or,{propertyName:0,elapsedTime:0,pseudoElement:0}),aS=Vn(oS),lS=L({},wa,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),cS=Vn(lS),uS=[9,13,27,32],Cc=h&&"CompositionEvent"in window,oo=null;h&&"documentMode"in document&&(oo=document.documentMode);var dS=h&&"TextEvent"in window&&!oo,rp=h&&(!Cc||oo&&8<oo&&11>=oo),op=" ",ap=!1;function lp(i,r){switch(i){case"keyup":return uS.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function cp(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var ar=!1;function hS(i,r){switch(i){case"compositionend":return cp(r);case"keypress":return r.which!==32?null:(ap=!0,op);case"textInput":return i=r.data,i===op&&ap?null:i;default:return null}}function fS(i,r){if(ar)return i==="compositionend"||!Cc&&lp(i,r)?(i=ep(),va=yc=ns=null,ar=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return rp&&r.locale!=="ko"?null:r.data;default:return null}}var pS={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 up(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r==="input"?!!pS[i.type]:r==="textarea"}function dp(i,r,c,d){Be(d),r=Ca(r,"onChange"),0<r.length&&(c=new wc("onChange","change",null,c,d),i.push({event:c,listeners:r}))}var ao=null,lo=null;function mS(i){Rp(i,0)}function ba(i){var r=hr(i);if(rt(r))return i}function gS(i,r){if(i==="change")return r}var hp=!1;if(h){var Ec;if(h){var Nc="oninput"in document;if(!Nc){var fp=document.createElement("div");fp.setAttribute("oninput","return;"),Nc=typeof fp.oninput=="function"}Ec=Nc}else Ec=!1;hp=Ec&&(!document.documentMode||9<document.documentMode)}function pp(){ao&&(ao.detachEvent("onpropertychange",mp),lo=ao=null)}function mp(i){if(i.propertyName==="value"&&ba(lo)){var r=[];dp(r,lo,i,se(i)),tt(mS,r)}}function vS(i,r,c){i==="focusin"?(pp(),ao=r,lo=c,ao.attachEvent("onpropertychange",mp)):i==="focusout"&&pp()}function _S(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return ba(lo)}function yS(i,r){if(i==="click")return ba(r)}function wS(i,r){if(i==="input"||i==="change")return ba(r)}function bS(i,r){return i===r&&(i!==0||1/i===1/r)||i!==i&&r!==r}var hi=typeof Object.is=="function"?Object.is:bS;function co(i,r){if(hi(i,r))return!0;if(typeof i!="object"||i===null||typeof r!="object"||r===null)return!1;var c=Object.keys(i),d=Object.keys(r);if(c.length!==d.length)return!1;for(d=0;d<c.length;d++){var g=c[d];if(!p.call(r,g)||!hi(i[g],r[g]))return!1}return!0}function gp(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function vp(i,r){var c=gp(i);i=0;for(var d;c;){if(c.nodeType===3){if(d=i+c.textContent.length,i<=r&&d>=r)return{node:c,offset:r-i};i=d}e:{for(;c;){if(c.nextSibling){c=c.nextSibling;break e}c=c.parentNode}c=void 0}c=gp(c)}}function _p(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?_p(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function yp(){for(var i=window,r=Ae();r instanceof i.HTMLIFrameElement;){try{var c=typeof r.contentWindow.location.href=="string"}catch{c=!1}if(c)i=r.contentWindow;else break;r=Ae(i.document)}return r}function jc(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r&&(r==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||r==="textarea"||i.contentEditable==="true")}function SS(i){var r=yp(),c=i.focusedElem,d=i.selectionRange;if(r!==c&&c&&c.ownerDocument&&_p(c.ownerDocument.documentElement,c)){if(d!==null&&jc(c)){if(r=d.start,i=d.end,i===void 0&&(i=r),"selectionStart"in c)c.selectionStart=r,c.selectionEnd=Math.min(i,c.value.length);else if(i=(r=c.ownerDocument||document)&&r.defaultView||window,i.getSelection){i=i.getSelection();var g=c.textContent.length,_=Math.min(d.start,g);d=d.end===void 0?_:Math.min(d.end,g),!i.extend&&_>d&&(g=d,d=_,_=g),g=vp(c,_);var R=vp(c,d);g&&R&&(i.rangeCount!==1||i.anchorNode!==g.node||i.anchorOffset!==g.offset||i.focusNode!==R.node||i.focusOffset!==R.offset)&&(r=r.createRange(),r.setStart(g.node,g.offset),i.removeAllRanges(),_>d?(i.addRange(r),i.extend(R.node,R.offset)):(r.setEnd(R.node,R.offset),i.addRange(r)))}}for(r=[],i=c;i=i.parentNode;)i.nodeType===1&&r.push({element:i,left:i.scrollLeft,top:i.scrollTop});for(typeof c.focus=="function"&&c.focus(),c=0;c<r.length;c++)i=r[c],i.element.scrollLeft=i.left,i.element.scrollTop=i.top}}var xS=h&&"documentMode"in document&&11>=document.documentMode,lr=null,Rc=null,uo=null,Pc=!1;function wp(i,r,c){var d=c.window===c?c.document:c.nodeType===9?c:c.ownerDocument;Pc||lr==null||lr!==Ae(d)||(d=lr,"selectionStart"in d&&jc(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),uo&&co(uo,d)||(uo=d,d=Ca(Rc,"onSelect"),0<d.length&&(r=new wc("onSelect","select",null,r,c),i.push({event:r,listeners:d}),r.target=lr)))}function Sa(i,r){var c={};return c[i.toLowerCase()]=r.toLowerCase(),c["Webkit"+i]="webkit"+r,c["Moz"+i]="moz"+r,c}var cr={animationend:Sa("Animation","AnimationEnd"),animationiteration:Sa("Animation","AnimationIteration"),animationstart:Sa("Animation","AnimationStart"),transitionend:Sa("Transition","TransitionEnd")},Ac={},bp={};h&&(bp=document.createElement("div").style,"AnimationEvent"in window||(delete cr.animationend.animation,delete cr.animationiteration.animation,delete cr.animationstart.animation),"TransitionEvent"in window||delete cr.transitionend.transition);function xa(i){if(Ac[i])return Ac[i];if(!cr[i])return i;var r=cr[i],c;for(c in r)if(r.hasOwnProperty(c)&&c in bp)return Ac[i]=r[c];return i}var Sp=xa("animationend"),xp=xa("animationiteration"),kp=xa("animationstart"),Cp=xa("transitionend"),Ep=new Map,Np="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 is(i,r){Ep.set(i,r),a(r,[i])}for(var Lc=0;Lc<Np.length;Lc++){var Tc=Np[Lc],kS=Tc.toLowerCase(),CS=Tc[0].toUpperCase()+Tc.slice(1);is(kS,"on"+CS)}is(Sp,"onAnimationEnd"),is(xp,"onAnimationIteration"),is(kp,"onAnimationStart"),is("dblclick","onDoubleClick"),is("focusin","onFocus"),is("focusout","onBlur"),is(Cp,"onTransitionEnd"),u("onMouseEnter",["mouseout","mouseover"]),u("onMouseLeave",["mouseout","mouseover"]),u("onPointerEnter",["pointerout","pointerover"]),u("onPointerLeave",["pointerout","pointerover"]),a("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),a("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),a("onBeforeInput",["compositionend","keypress","textInput","paste"]),a("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ho="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),ES=new Set("cancel close invalid load scroll toggle".split(" ").concat(ho));function jp(i,r,c){var d=i.type||"unknown-event";i.currentTarget=c,Vt(d,r,void 0,i),i.currentTarget=null}function Rp(i,r){r=(r&4)!==0;for(var c=0;c<i.length;c++){var d=i[c],g=d.event;d=d.listeners;e:{var _=void 0;if(r)for(var R=d.length-1;0<=R;R--){var q=d[R],J=q.instance,ae=q.currentTarget;if(q=q.listener,J!==_&&g.isPropagationStopped())break e;jp(g,q,ae),_=J}else for(R=0;R<d.length;R++){if(q=d[R],J=q.instance,ae=q.currentTarget,q=q.listener,J!==_&&g.isPropagationStopped())break e;jp(g,q,ae),_=J}}}if(ce)throw i=je,ce=!1,je=null,i}function Lt(i,r){var c=r[Fc];c===void 0&&(c=r[Fc]=new Set);var d=i+"__bubble";c.has(d)||(Pp(r,i,2,!1),c.add(d))}function Mc(i,r,c){var d=0;r&&(d|=4),Pp(c,i,d,r)}var ka="_reactListening"+Math.random().toString(36).slice(2);function fo(i){if(!i[ka]){i[ka]=!0,s.forEach(function(c){c!=="selectionchange"&&(ES.has(c)||Mc(c,!1,i),Mc(c,!0,i))});var r=i.nodeType===9?i:i.ownerDocument;r===null||r[ka]||(r[ka]=!0,Mc("selectionchange",!1,r))}}function Pp(i,r,c,d){switch(Zf(r)){case 1:var g=$b;break;case 4:g=Fb;break;default:g=vc}c=g.bind(null,r,c,i),g=void 0,!Ct||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(g=!0),d?g!==void 0?i.addEventListener(r,c,{capture:!0,passive:g}):i.addEventListener(r,c,!0):g!==void 0?i.addEventListener(r,c,{passive:g}):i.addEventListener(r,c,!1)}function Dc(i,r,c,d,g){var _=d;if((r&1)===0&&(r&2)===0&&d!==null)e:for(;;){if(d===null)return;var R=d.tag;if(R===3||R===4){var q=d.stateNode.containerInfo;if(q===g||q.nodeType===8&&q.parentNode===g)break;if(R===4)for(R=d.return;R!==null;){var J=R.tag;if((J===3||J===4)&&(J=R.stateNode.containerInfo,J===g||J.nodeType===8&&J.parentNode===g))return;R=R.return}for(;q!==null;){if(R=Ls(q),R===null)return;if(J=R.tag,J===5||J===6){d=_=R;continue e}q=q.parentNode}}d=d.return}tt(function(){var ae=_,xe=se(c),ke=[];e:{var be=Ep.get(i);if(be!==void 0){var Me=wc,ze=i;switch(i){case"keypress":if(_a(c)===0)break e;case"keydown":case"keyup":Me=nS;break;case"focusin":ze="focus",Me=xc;break;case"focusout":ze="blur",Me=xc;break;case"beforeblur":case"afterblur":Me=xc;break;case"click":if(c.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Me=np;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Me=Wb;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Me=rS;break;case Sp:case xp:case kp:Me=Vb;break;case Cp:Me=aS;break;case"scroll":Me=Hb;break;case"wheel":Me=cS;break;case"copy":case"cut":case"paste":Me=Gb;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Me=sp}var Fe=(r&4)!==0,Yt=!Fe&&i==="scroll",ne=Fe?be!==null?be+"Capture":null:be;Fe=[];for(var ee=ae,re;ee!==null;){re=ee;var Ee=re.stateNode;if(re.tag===5&&Ee!==null&&(re=Ee,ne!==null&&(Ee=bn(ee,ne),Ee!=null&&Fe.push(po(ee,Ee,re)))),Yt)break;ee=ee.return}0<Fe.length&&(be=new Me(be,ze,null,c,xe),ke.push({event:be,listeners:Fe}))}}if((r&7)===0){e:{if(be=i==="mouseover"||i==="pointerover",Me=i==="mouseout"||i==="pointerout",be&&c!==X&&(ze=c.relatedTarget||c.fromElement)&&(Ls(ze)||ze[Ii]))break e;if((Me||be)&&(be=xe.window===xe?xe:(be=xe.ownerDocument)?be.defaultView||be.parentWindow:window,Me?(ze=c.relatedTarget||c.toElement,Me=ae,ze=ze?Ls(ze):null,ze!==null&&(Yt=Nt(ze),ze!==Yt||ze.tag!==5&&ze.tag!==6)&&(ze=null)):(Me=null,ze=ae),Me!==ze)){if(Fe=np,Ee="onMouseLeave",ne="onMouseEnter",ee="mouse",(i==="pointerout"||i==="pointerover")&&(Fe=sp,Ee="onPointerLeave",ne="onPointerEnter",ee="pointer"),Yt=Me==null?be:hr(Me),re=ze==null?be:hr(ze),be=new Fe(Ee,ee+"leave",Me,c,xe),be.target=Yt,be.relatedTarget=re,Ee=null,Ls(xe)===ae&&(Fe=new Fe(ne,ee+"enter",ze,c,xe),Fe.target=re,Fe.relatedTarget=Yt,Ee=Fe),Yt=Ee,Me&&ze)t:{for(Fe=Me,ne=ze,ee=0,re=Fe;re;re=ur(re))ee++;for(re=0,Ee=ne;Ee;Ee=ur(Ee))re++;for(;0<ee-re;)Fe=ur(Fe),ee--;for(;0<re-ee;)ne=ur(ne),re--;for(;ee--;){if(Fe===ne||ne!==null&&Fe===ne.alternate)break t;Fe=ur(Fe),ne=ur(ne)}Fe=null}else Fe=null;Me!==null&&Ap(ke,be,Me,Fe,!1),ze!==null&&Yt!==null&&Ap(ke,Yt,ze,Fe,!0)}}e:{if(be=ae?hr(ae):window,Me=be.nodeName&&be.nodeName.toLowerCase(),Me==="select"||Me==="input"&&be.type==="file")var He=gS;else if(up(be))if(hp)He=wS;else{He=_S;var Ve=vS}else(Me=be.nodeName)&&Me.toLowerCase()==="input"&&(be.type==="checkbox"||be.type==="radio")&&(He=yS);if(He&&(He=He(i,ae))){dp(ke,He,c,xe);break e}Ve&&Ve(i,be,ae),i==="focusout"&&(Ve=be._wrapperState)&&Ve.controlled&&be.type==="number"&&wt(be,"number",be.value)}switch(Ve=ae?hr(ae):window,i){case"focusin":(up(Ve)||Ve.contentEditable==="true")&&(lr=Ve,Rc=ae,uo=null);break;case"focusout":uo=Rc=lr=null;break;case"mousedown":Pc=!0;break;case"contextmenu":case"mouseup":case"dragend":Pc=!1,wp(ke,c,xe);break;case"selectionchange":if(xS)break;case"keydown":case"keyup":wp(ke,c,xe)}var Ye;if(Cc)e:{switch(i){case"compositionstart":var Ze="onCompositionStart";break e;case"compositionend":Ze="onCompositionEnd";break e;case"compositionupdate":Ze="onCompositionUpdate";break e}Ze=void 0}else ar?lp(i,c)&&(Ze="onCompositionEnd"):i==="keydown"&&c.keyCode===229&&(Ze="onCompositionStart");Ze&&(rp&&c.locale!=="ko"&&(ar||Ze!=="onCompositionStart"?Ze==="onCompositionEnd"&&ar&&(Ye=ep()):(ns=xe,yc="value"in ns?ns.value:ns.textContent,ar=!0)),Ve=Ca(ae,Ze),0<Ve.length&&(Ze=new ip(Ze,i,null,c,xe),ke.push({event:Ze,listeners:Ve}),Ye?Ze.data=Ye:(Ye=cp(c),Ye!==null&&(Ze.data=Ye)))),(Ye=dS?hS(i,c):fS(i,c))&&(ae=Ca(ae,"onBeforeInput"),0<ae.length&&(xe=new ip("onBeforeInput","beforeinput",null,c,xe),ke.push({event:xe,listeners:ae}),xe.data=Ye))}Rp(ke,r)})}function po(i,r,c){return{instance:i,listener:r,currentTarget:c}}function Ca(i,r){for(var c=r+"Capture",d=[];i!==null;){var g=i,_=g.stateNode;g.tag===5&&_!==null&&(g=_,_=bn(i,c),_!=null&&d.unshift(po(i,_,g)),_=bn(i,r),_!=null&&d.push(po(i,_,g))),i=i.return}return d}function ur(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5);return i||null}function Ap(i,r,c,d,g){for(var _=r._reactName,R=[];c!==null&&c!==d;){var q=c,J=q.alternate,ae=q.stateNode;if(J!==null&&J===d)break;q.tag===5&&ae!==null&&(q=ae,g?(J=bn(c,_),J!=null&&R.unshift(po(c,J,q))):g||(J=bn(c,_),J!=null&&R.push(po(c,J,q)))),c=c.return}R.length!==0&&i.push({event:r,listeners:R})}var NS=/\r\n?/g,jS=/\u0000|\uFFFD/g;function Lp(i){return(typeof i=="string"?i:""+i).replace(NS,`
|
|
38
|
-
`).replace(jS,"")}function Ea(i,r,c){if(r=Lp(r),Lp(i)!==r&&c)throw Error(n(425))}function Na(){}var Ic=null,Oc=null;function Bc(i,r){return i==="textarea"||i==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var zc=typeof setTimeout=="function"?setTimeout:void 0,RS=typeof clearTimeout=="function"?clearTimeout:void 0,Tp=typeof Promise=="function"?Promise:void 0,PS=typeof queueMicrotask=="function"?queueMicrotask:typeof Tp<"u"?function(i){return Tp.resolve(null).then(i).catch(AS)}:zc;function AS(i){setTimeout(function(){throw i})}function $c(i,r){var c=r,d=0;do{var g=c.nextSibling;if(i.removeChild(c),g&&g.nodeType===8)if(c=g.data,c==="/$"){if(d===0){i.removeChild(g),io(r);return}d--}else c!=="$"&&c!=="$?"&&c!=="$!"||d++;c=g}while(c);io(r)}function ss(i){for(;i!=null;i=i.nextSibling){var r=i.nodeType;if(r===1||r===3)break;if(r===8){if(r=i.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return i}function Mp(i){i=i.previousSibling;for(var r=0;i;){if(i.nodeType===8){var c=i.data;if(c==="$"||c==="$!"||c==="$?"){if(r===0)return i;r--}else c==="/$"&&r++}i=i.previousSibling}return null}var dr=Math.random().toString(36).slice(2),yi="__reactFiber$"+dr,mo="__reactProps$"+dr,Ii="__reactContainer$"+dr,Fc="__reactEvents$"+dr,LS="__reactListeners$"+dr,TS="__reactHandles$"+dr;function Ls(i){var r=i[yi];if(r)return r;for(var c=i.parentNode;c;){if(r=c[Ii]||c[yi]){if(c=r.alternate,r.child!==null||c!==null&&c.child!==null)for(i=Mp(i);i!==null;){if(c=i[yi])return c;i=Mp(i)}return r}i=c,c=i.parentNode}return null}function go(i){return i=i[yi]||i[Ii],!i||i.tag!==5&&i.tag!==6&&i.tag!==13&&i.tag!==3?null:i}function hr(i){if(i.tag===5||i.tag===6)return i.stateNode;throw Error(n(33))}function ja(i){return i[mo]||null}var Hc=[],fr=-1;function rs(i){return{current:i}}function Tt(i){0>fr||(i.current=Hc[fr],Hc[fr]=null,fr--)}function jt(i,r){fr++,Hc[fr]=i.current,i.current=r}var os={},En=rs(os),zn=rs(!1),Ts=os;function pr(i,r){var c=i.type.contextTypes;if(!c)return os;var d=i.stateNode;if(d&&d.__reactInternalMemoizedUnmaskedChildContext===r)return d.__reactInternalMemoizedMaskedChildContext;var g={},_;for(_ in c)g[_]=r[_];return d&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=r,i.__reactInternalMemoizedMaskedChildContext=g),g}function $n(i){return i=i.childContextTypes,i!=null}function Ra(){Tt(zn),Tt(En)}function Dp(i,r,c){if(En.current!==os)throw Error(n(168));jt(En,r),jt(zn,c)}function Ip(i,r,c){var d=i.stateNode;if(r=r.childContextTypes,typeof d.getChildContext!="function")return c;d=d.getChildContext();for(var g in d)if(!(g in r))throw Error(n(108,ve(i)||"Unknown",g));return L({},c,d)}function Pa(i){return i=(i=i.stateNode)&&i.__reactInternalMemoizedMergedChildContext||os,Ts=En.current,jt(En,i),jt(zn,zn.current),!0}function Op(i,r,c){var d=i.stateNode;if(!d)throw Error(n(169));c?(i=Ip(i,r,Ts),d.__reactInternalMemoizedMergedChildContext=i,Tt(zn),Tt(En),jt(En,i)):Tt(zn),jt(zn,c)}var Oi=null,Aa=!1,Uc=!1;function Bp(i){Oi===null?Oi=[i]:Oi.push(i)}function MS(i){Aa=!0,Bp(i)}function as(){if(!Uc&&Oi!==null){Uc=!0;var i=0,r=St;try{var c=Oi;for(St=1;i<c.length;i++){var d=c[i];do d=d(!0);while(d!==null)}Oi=null,Aa=!1}catch(g){throw Oi!==null&&(Oi=Oi.slice(i+1)),As(Ke,as),g}finally{St=r,Uc=!1}}return null}var mr=[],gr=0,La=null,Ta=0,ni=[],ii=0,Ms=null,Bi=1,zi="";function Ds(i,r){mr[gr++]=Ta,mr[gr++]=La,La=i,Ta=r}function zp(i,r,c){ni[ii++]=Bi,ni[ii++]=zi,ni[ii++]=Ms,Ms=i;var d=Bi;i=zi;var g=32-Bn(d)-1;d&=~(1<<g),c+=1;var _=32-Bn(r)+g;if(30<_){var R=g-g%5;_=(d&(1<<R)-1).toString(32),d>>=R,g-=R,Bi=1<<32-Bn(r)+g|c<<g|d,zi=_+i}else Bi=1<<_|c<<g|d,zi=i}function Wc(i){i.return!==null&&(Ds(i,1),zp(i,1,0))}function Kc(i){for(;i===La;)La=mr[--gr],mr[gr]=null,Ta=mr[--gr],mr[gr]=null;for(;i===Ms;)Ms=ni[--ii],ni[ii]=null,zi=ni[--ii],ni[ii]=null,Bi=ni[--ii],ni[ii]=null}var Yn=null,Gn=null,Ot=!1,fi=null;function $p(i,r){var c=ai(5,null,null,0);c.elementType="DELETED",c.stateNode=r,c.return=i,r=i.deletions,r===null?(i.deletions=[c],i.flags|=16):r.push(c)}function Fp(i,r){switch(i.tag){case 5:var c=i.type;return r=r.nodeType!==1||c.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(i.stateNode=r,Yn=i,Gn=ss(r.firstChild),!0):!1;case 6:return r=i.pendingProps===""||r.nodeType!==3?null:r,r!==null?(i.stateNode=r,Yn=i,Gn=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(c=Ms!==null?{id:Bi,overflow:zi}:null,i.memoizedState={dehydrated:r,treeContext:c,retryLane:1073741824},c=ai(18,null,null,0),c.stateNode=r,c.return=i,i.child=c,Yn=i,Gn=null,!0):!1;default:return!1}}function qc(i){return(i.mode&1)!==0&&(i.flags&128)===0}function Vc(i){if(Ot){var r=Gn;if(r){var c=r;if(!Fp(i,r)){if(qc(i))throw Error(n(418));r=ss(c.nextSibling);var d=Yn;r&&Fp(i,r)?$p(d,c):(i.flags=i.flags&-4097|2,Ot=!1,Yn=i)}}else{if(qc(i))throw Error(n(418));i.flags=i.flags&-4097|2,Ot=!1,Yn=i}}}function Hp(i){for(i=i.return;i!==null&&i.tag!==5&&i.tag!==3&&i.tag!==13;)i=i.return;Yn=i}function Ma(i){if(i!==Yn)return!1;if(!Ot)return Hp(i),Ot=!0,!1;var r;if((r=i.tag!==3)&&!(r=i.tag!==5)&&(r=i.type,r=r!=="head"&&r!=="body"&&!Bc(i.type,i.memoizedProps)),r&&(r=Gn)){if(qc(i))throw Up(),Error(n(418));for(;r;)$p(i,r),r=ss(r.nextSibling)}if(Hp(i),i.tag===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(n(317));e:{for(i=i.nextSibling,r=0;i;){if(i.nodeType===8){var c=i.data;if(c==="/$"){if(r===0){Gn=ss(i.nextSibling);break e}r--}else c!=="$"&&c!=="$!"&&c!=="$?"||r++}i=i.nextSibling}Gn=null}}else Gn=Yn?ss(i.stateNode.nextSibling):null;return!0}function Up(){for(var i=Gn;i;)i=ss(i.nextSibling)}function vr(){Gn=Yn=null,Ot=!1}function Yc(i){fi===null?fi=[i]:fi.push(i)}var DS=O.ReactCurrentBatchConfig;function vo(i,r,c){if(i=c.ref,i!==null&&typeof i!="function"&&typeof i!="object"){if(c._owner){if(c=c._owner,c){if(c.tag!==1)throw Error(n(309));var d=c.stateNode}if(!d)throw Error(n(147,i));var g=d,_=""+i;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===_?r.ref:(r=function(R){var q=g.refs;R===null?delete q[_]:q[_]=R},r._stringRef=_,r)}if(typeof i!="string")throw Error(n(284));if(!c._owner)throw Error(n(290,i))}return i}function Da(i,r){throw i=Object.prototype.toString.call(r),Error(n(31,i==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":i))}function Wp(i){var r=i._init;return r(i._payload)}function Kp(i){function r(ne,ee){if(i){var re=ne.deletions;re===null?(ne.deletions=[ee],ne.flags|=16):re.push(ee)}}function c(ne,ee){if(!i)return null;for(;ee!==null;)r(ne,ee),ee=ee.sibling;return null}function d(ne,ee){for(ne=new Map;ee!==null;)ee.key!==null?ne.set(ee.key,ee):ne.set(ee.index,ee),ee=ee.sibling;return ne}function g(ne,ee){return ne=ms(ne,ee),ne.index=0,ne.sibling=null,ne}function _(ne,ee,re){return ne.index=re,i?(re=ne.alternate,re!==null?(re=re.index,re<ee?(ne.flags|=2,ee):re):(ne.flags|=2,ee)):(ne.flags|=1048576,ee)}function R(ne){return i&&ne.alternate===null&&(ne.flags|=2),ne}function q(ne,ee,re,Ee){return ee===null||ee.tag!==6?(ee=zu(re,ne.mode,Ee),ee.return=ne,ee):(ee=g(ee,re),ee.return=ne,ee)}function J(ne,ee,re,Ee){var He=re.type;return He===K?xe(ne,ee,re.props.children,Ee,re.key):ee!==null&&(ee.elementType===He||typeof He=="object"&&He!==null&&He.$$typeof===D&&Wp(He)===ee.type)?(Ee=g(ee,re.props),Ee.ref=vo(ne,ee,re),Ee.return=ne,Ee):(Ee=rl(re.type,re.key,re.props,null,ne.mode,Ee),Ee.ref=vo(ne,ee,re),Ee.return=ne,Ee)}function ae(ne,ee,re,Ee){return ee===null||ee.tag!==4||ee.stateNode.containerInfo!==re.containerInfo||ee.stateNode.implementation!==re.implementation?(ee=$u(re,ne.mode,Ee),ee.return=ne,ee):(ee=g(ee,re.children||[]),ee.return=ne,ee)}function xe(ne,ee,re,Ee,He){return ee===null||ee.tag!==7?(ee=Us(re,ne.mode,Ee,He),ee.return=ne,ee):(ee=g(ee,re),ee.return=ne,ee)}function ke(ne,ee,re){if(typeof ee=="string"&&ee!==""||typeof ee=="number")return ee=zu(""+ee,ne.mode,re),ee.return=ne,ee;if(typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case U:return re=rl(ee.type,ee.key,ee.props,null,ne.mode,re),re.ref=vo(ne,null,ee),re.return=ne,re;case V:return ee=$u(ee,ne.mode,re),ee.return=ne,ee;case D:var Ee=ee._init;return ke(ne,Ee(ee._payload),re)}if(bt(ee)||M(ee))return ee=Us(ee,ne.mode,re,null),ee.return=ne,ee;Da(ne,ee)}return null}function be(ne,ee,re,Ee){var He=ee!==null?ee.key:null;if(typeof re=="string"&&re!==""||typeof re=="number")return He!==null?null:q(ne,ee,""+re,Ee);if(typeof re=="object"&&re!==null){switch(re.$$typeof){case U:return re.key===He?J(ne,ee,re,Ee):null;case V:return re.key===He?ae(ne,ee,re,Ee):null;case D:return He=re._init,be(ne,ee,He(re._payload),Ee)}if(bt(re)||M(re))return He!==null?null:xe(ne,ee,re,Ee,null);Da(ne,re)}return null}function Me(ne,ee,re,Ee,He){if(typeof Ee=="string"&&Ee!==""||typeof Ee=="number")return ne=ne.get(re)||null,q(ee,ne,""+Ee,He);if(typeof Ee=="object"&&Ee!==null){switch(Ee.$$typeof){case U:return ne=ne.get(Ee.key===null?re:Ee.key)||null,J(ee,ne,Ee,He);case V:return ne=ne.get(Ee.key===null?re:Ee.key)||null,ae(ee,ne,Ee,He);case D:var Ve=Ee._init;return Me(ne,ee,re,Ve(Ee._payload),He)}if(bt(Ee)||M(Ee))return ne=ne.get(re)||null,xe(ee,ne,Ee,He,null);Da(ee,Ee)}return null}function ze(ne,ee,re,Ee){for(var He=null,Ve=null,Ye=ee,Ze=ee=0,mn=null;Ye!==null&&Ze<re.length;Ze++){Ye.index>Ze?(mn=Ye,Ye=null):mn=Ye.sibling;var ft=be(ne,Ye,re[Ze],Ee);if(ft===null){Ye===null&&(Ye=mn);break}i&&Ye&&ft.alternate===null&&r(ne,Ye),ee=_(ft,ee,Ze),Ve===null?He=ft:Ve.sibling=ft,Ve=ft,Ye=mn}if(Ze===re.length)return c(ne,Ye),Ot&&Ds(ne,Ze),He;if(Ye===null){for(;Ze<re.length;Ze++)Ye=ke(ne,re[Ze],Ee),Ye!==null&&(ee=_(Ye,ee,Ze),Ve===null?He=Ye:Ve.sibling=Ye,Ve=Ye);return Ot&&Ds(ne,Ze),He}for(Ye=d(ne,Ye);Ze<re.length;Ze++)mn=Me(Ye,ne,Ze,re[Ze],Ee),mn!==null&&(i&&mn.alternate!==null&&Ye.delete(mn.key===null?Ze:mn.key),ee=_(mn,ee,Ze),Ve===null?He=mn:Ve.sibling=mn,Ve=mn);return i&&Ye.forEach(function(gs){return r(ne,gs)}),Ot&&Ds(ne,Ze),He}function Fe(ne,ee,re,Ee){var He=M(re);if(typeof He!="function")throw Error(n(150));if(re=He.call(re),re==null)throw Error(n(151));for(var Ve=He=null,Ye=ee,Ze=ee=0,mn=null,ft=re.next();Ye!==null&&!ft.done;Ze++,ft=re.next()){Ye.index>Ze?(mn=Ye,Ye=null):mn=Ye.sibling;var gs=be(ne,Ye,ft.value,Ee);if(gs===null){Ye===null&&(Ye=mn);break}i&&Ye&&gs.alternate===null&&r(ne,Ye),ee=_(gs,ee,Ze),Ve===null?He=gs:Ve.sibling=gs,Ve=gs,Ye=mn}if(ft.done)return c(ne,Ye),Ot&&Ds(ne,Ze),He;if(Ye===null){for(;!ft.done;Ze++,ft=re.next())ft=ke(ne,ft.value,Ee),ft!==null&&(ee=_(ft,ee,Ze),Ve===null?He=ft:Ve.sibling=ft,Ve=ft);return Ot&&Ds(ne,Ze),He}for(Ye=d(ne,Ye);!ft.done;Ze++,ft=re.next())ft=Me(Ye,ne,Ze,ft.value,Ee),ft!==null&&(i&&ft.alternate!==null&&Ye.delete(ft.key===null?Ze:ft.key),ee=_(ft,ee,Ze),Ve===null?He=ft:Ve.sibling=ft,Ve=ft);return i&&Ye.forEach(function(p0){return r(ne,p0)}),Ot&&Ds(ne,Ze),He}function Yt(ne,ee,re,Ee){if(typeof re=="object"&&re!==null&&re.type===K&&re.key===null&&(re=re.props.children),typeof re=="object"&&re!==null){switch(re.$$typeof){case U:e:{for(var He=re.key,Ve=ee;Ve!==null;){if(Ve.key===He){if(He=re.type,He===K){if(Ve.tag===7){c(ne,Ve.sibling),ee=g(Ve,re.props.children),ee.return=ne,ne=ee;break e}}else if(Ve.elementType===He||typeof He=="object"&&He!==null&&He.$$typeof===D&&Wp(He)===Ve.type){c(ne,Ve.sibling),ee=g(Ve,re.props),ee.ref=vo(ne,Ve,re),ee.return=ne,ne=ee;break e}c(ne,Ve);break}else r(ne,Ve);Ve=Ve.sibling}re.type===K?(ee=Us(re.props.children,ne.mode,Ee,re.key),ee.return=ne,ne=ee):(Ee=rl(re.type,re.key,re.props,null,ne.mode,Ee),Ee.ref=vo(ne,ee,re),Ee.return=ne,ne=Ee)}return R(ne);case V:e:{for(Ve=re.key;ee!==null;){if(ee.key===Ve)if(ee.tag===4&&ee.stateNode.containerInfo===re.containerInfo&&ee.stateNode.implementation===re.implementation){c(ne,ee.sibling),ee=g(ee,re.children||[]),ee.return=ne,ne=ee;break e}else{c(ne,ee);break}else r(ne,ee);ee=ee.sibling}ee=$u(re,ne.mode,Ee),ee.return=ne,ne=ee}return R(ne);case D:return Ve=re._init,Yt(ne,ee,Ve(re._payload),Ee)}if(bt(re))return ze(ne,ee,re,Ee);if(M(re))return Fe(ne,ee,re,Ee);Da(ne,re)}return typeof re=="string"&&re!==""||typeof re=="number"?(re=""+re,ee!==null&&ee.tag===6?(c(ne,ee.sibling),ee=g(ee,re),ee.return=ne,ne=ee):(c(ne,ee),ee=zu(re,ne.mode,Ee),ee.return=ne,ne=ee),R(ne)):c(ne,ee)}return Yt}var _r=Kp(!0),qp=Kp(!1),Ia=rs(null),Oa=null,yr=null,Gc=null;function Xc(){Gc=yr=Oa=null}function Qc(i){var r=Ia.current;Tt(Ia),i._currentValue=r}function Jc(i,r,c){for(;i!==null;){var d=i.alternate;if((i.childLanes&r)!==r?(i.childLanes|=r,d!==null&&(d.childLanes|=r)):d!==null&&(d.childLanes&r)!==r&&(d.childLanes|=r),i===c)break;i=i.return}}function wr(i,r){Oa=i,Gc=yr=null,i=i.dependencies,i!==null&&i.firstContext!==null&&((i.lanes&r)!==0&&(Fn=!0),i.firstContext=null)}function si(i){var r=i._currentValue;if(Gc!==i)if(i={context:i,memoizedValue:r,next:null},yr===null){if(Oa===null)throw Error(n(308));yr=i,Oa.dependencies={lanes:0,firstContext:i}}else yr=yr.next=i;return r}var Is=null;function Zc(i){Is===null?Is=[i]:Is.push(i)}function Vp(i,r,c,d){var g=r.interleaved;return g===null?(c.next=c,Zc(r)):(c.next=g.next,g.next=c),r.interleaved=c,$i(i,d)}function $i(i,r){i.lanes|=r;var c=i.alternate;for(c!==null&&(c.lanes|=r),c=i,i=i.return;i!==null;)i.childLanes|=r,c=i.alternate,c!==null&&(c.childLanes|=r),c=i,i=i.return;return c.tag===3?c.stateNode:null}var ls=!1;function eu(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Yp(i,r){i=i.updateQueue,r.updateQueue===i&&(r.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,effects:i.effects})}function Fi(i,r){return{eventTime:i,lane:r,tag:0,payload:null,callback:null,next:null}}function cs(i,r,c){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(ht&2)!==0){var g=d.pending;return g===null?r.next=r:(r.next=g.next,g.next=r),d.pending=r,$i(i,c)}return g=d.interleaved,g===null?(r.next=r,Zc(d)):(r.next=g.next,g.next=r),d.interleaved=r,$i(i,c)}function Ba(i,r,c){if(r=r.updateQueue,r!==null&&(r=r.shared,(c&4194240)!==0)){var d=r.lanes;d&=i.pendingLanes,c|=d,r.lanes=c,pc(i,c)}}function Gp(i,r){var c=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,c===d)){var g=null,_=null;if(c=c.firstBaseUpdate,c!==null){do{var R={eventTime:c.eventTime,lane:c.lane,tag:c.tag,payload:c.payload,callback:c.callback,next:null};_===null?g=_=R:_=_.next=R,c=c.next}while(c!==null);_===null?g=_=r:_=_.next=r}else g=_=r;c={baseState:d.baseState,firstBaseUpdate:g,lastBaseUpdate:_,shared:d.shared,effects:d.effects},i.updateQueue=c;return}i=c.lastBaseUpdate,i===null?c.firstBaseUpdate=r:i.next=r,c.lastBaseUpdate=r}function za(i,r,c,d){var g=i.updateQueue;ls=!1;var _=g.firstBaseUpdate,R=g.lastBaseUpdate,q=g.shared.pending;if(q!==null){g.shared.pending=null;var J=q,ae=J.next;J.next=null,R===null?_=ae:R.next=ae,R=J;var xe=i.alternate;xe!==null&&(xe=xe.updateQueue,q=xe.lastBaseUpdate,q!==R&&(q===null?xe.firstBaseUpdate=ae:q.next=ae,xe.lastBaseUpdate=J))}if(_!==null){var ke=g.baseState;R=0,xe=ae=J=null,q=_;do{var be=q.lane,Me=q.eventTime;if((d&be)===be){xe!==null&&(xe=xe.next={eventTime:Me,lane:0,tag:q.tag,payload:q.payload,callback:q.callback,next:null});e:{var ze=i,Fe=q;switch(be=r,Me=c,Fe.tag){case 1:if(ze=Fe.payload,typeof ze=="function"){ke=ze.call(Me,ke,be);break e}ke=ze;break e;case 3:ze.flags=ze.flags&-65537|128;case 0:if(ze=Fe.payload,be=typeof ze=="function"?ze.call(Me,ke,be):ze,be==null)break e;ke=L({},ke,be);break e;case 2:ls=!0}}q.callback!==null&&q.lane!==0&&(i.flags|=64,be=g.effects,be===null?g.effects=[q]:be.push(q))}else Me={eventTime:Me,lane:be,tag:q.tag,payload:q.payload,callback:q.callback,next:null},xe===null?(ae=xe=Me,J=ke):xe=xe.next=Me,R|=be;if(q=q.next,q===null){if(q=g.shared.pending,q===null)break;be=q,q=be.next,be.next=null,g.lastBaseUpdate=be,g.shared.pending=null}}while(!0);if(xe===null&&(J=ke),g.baseState=J,g.firstBaseUpdate=ae,g.lastBaseUpdate=xe,r=g.shared.interleaved,r!==null){g=r;do R|=g.lane,g=g.next;while(g!==r)}else _===null&&(g.shared.lanes=0);zs|=R,i.lanes=R,i.memoizedState=ke}}function Xp(i,r,c){if(i=r.effects,r.effects=null,i!==null)for(r=0;r<i.length;r++){var d=i[r],g=d.callback;if(g!==null){if(d.callback=null,d=c,typeof g!="function")throw Error(n(191,g));g.call(d)}}}var _o={},wi=rs(_o),yo=rs(_o),wo=rs(_o);function Os(i){if(i===_o)throw Error(n(174));return i}function tu(i,r){switch(jt(wo,r),jt(yo,i),jt(wi,_o),i=r.nodeType,i){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:Se(null,"");break;default:i=i===8?r.parentNode:r,r=i.namespaceURI||null,i=i.tagName,r=Se(r,i)}Tt(wi),jt(wi,r)}function br(){Tt(wi),Tt(yo),Tt(wo)}function Qp(i){Os(wo.current);var r=Os(wi.current),c=Se(r,i.type);r!==c&&(jt(yo,i),jt(wi,c))}function nu(i){yo.current===i&&(Tt(wi),Tt(yo))}var zt=rs(0);function $a(i){for(var r=i;r!==null;){if(r.tag===13){var c=r.memoizedState;if(c!==null&&(c=c.dehydrated,c===null||c.data==="$?"||c.data==="$!"))return r}else if(r.tag===19&&r.memoizedProps.revealOrder!==void 0){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var iu=[];function su(){for(var i=0;i<iu.length;i++)iu[i]._workInProgressVersionPrimary=null;iu.length=0}var Fa=O.ReactCurrentDispatcher,ru=O.ReactCurrentBatchConfig,Bs=0,$t=null,on=null,fn=null,Ha=!1,bo=!1,So=0,IS=0;function Nn(){throw Error(n(321))}function ou(i,r){if(r===null)return!1;for(var c=0;c<r.length&&c<i.length;c++)if(!hi(i[c],r[c]))return!1;return!0}function au(i,r,c,d,g,_){if(Bs=_,$t=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,Fa.current=i===null||i.memoizedState===null?$S:FS,i=c(d,g),bo){_=0;do{if(bo=!1,So=0,25<=_)throw Error(n(301));_+=1,fn=on=null,r.updateQueue=null,Fa.current=HS,i=c(d,g)}while(bo)}if(Fa.current=Ka,r=on!==null&&on.next!==null,Bs=0,fn=on=$t=null,Ha=!1,r)throw Error(n(300));return i}function lu(){var i=So!==0;return So=0,i}function bi(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return fn===null?$t.memoizedState=fn=i:fn=fn.next=i,fn}function ri(){if(on===null){var i=$t.alternate;i=i!==null?i.memoizedState:null}else i=on.next;var r=fn===null?$t.memoizedState:fn.next;if(r!==null)fn=r,on=i;else{if(i===null)throw Error(n(310));on=i,i={memoizedState:on.memoizedState,baseState:on.baseState,baseQueue:on.baseQueue,queue:on.queue,next:null},fn===null?$t.memoizedState=fn=i:fn=fn.next=i}return fn}function xo(i,r){return typeof r=="function"?r(i):r}function cu(i){var r=ri(),c=r.queue;if(c===null)throw Error(n(311));c.lastRenderedReducer=i;var d=on,g=d.baseQueue,_=c.pending;if(_!==null){if(g!==null){var R=g.next;g.next=_.next,_.next=R}d.baseQueue=g=_,c.pending=null}if(g!==null){_=g.next,d=d.baseState;var q=R=null,J=null,ae=_;do{var xe=ae.lane;if((Bs&xe)===xe)J!==null&&(J=J.next={lane:0,action:ae.action,hasEagerState:ae.hasEagerState,eagerState:ae.eagerState,next:null}),d=ae.hasEagerState?ae.eagerState:i(d,ae.action);else{var ke={lane:xe,action:ae.action,hasEagerState:ae.hasEagerState,eagerState:ae.eagerState,next:null};J===null?(q=J=ke,R=d):J=J.next=ke,$t.lanes|=xe,zs|=xe}ae=ae.next}while(ae!==null&&ae!==_);J===null?R=d:J.next=q,hi(d,r.memoizedState)||(Fn=!0),r.memoizedState=d,r.baseState=R,r.baseQueue=J,c.lastRenderedState=d}if(i=c.interleaved,i!==null){g=i;do _=g.lane,$t.lanes|=_,zs|=_,g=g.next;while(g!==i)}else g===null&&(c.lanes=0);return[r.memoizedState,c.dispatch]}function uu(i){var r=ri(),c=r.queue;if(c===null)throw Error(n(311));c.lastRenderedReducer=i;var d=c.dispatch,g=c.pending,_=r.memoizedState;if(g!==null){c.pending=null;var R=g=g.next;do _=i(_,R.action),R=R.next;while(R!==g);hi(_,r.memoizedState)||(Fn=!0),r.memoizedState=_,r.baseQueue===null&&(r.baseState=_),c.lastRenderedState=_}return[_,d]}function Jp(){}function Zp(i,r){var c=$t,d=ri(),g=r(),_=!hi(d.memoizedState,g);if(_&&(d.memoizedState=g,Fn=!0),d=d.queue,du(nm.bind(null,c,d,i),[i]),d.getSnapshot!==r||_||fn!==null&&fn.memoizedState.tag&1){if(c.flags|=2048,ko(9,tm.bind(null,c,d,g,r),void 0,null),pn===null)throw Error(n(349));(Bs&30)!==0||em(c,r,g)}return g}function em(i,r,c){i.flags|=16384,i={getSnapshot:r,value:c},r=$t.updateQueue,r===null?(r={lastEffect:null,stores:null},$t.updateQueue=r,r.stores=[i]):(c=r.stores,c===null?r.stores=[i]:c.push(i))}function tm(i,r,c,d){r.value=c,r.getSnapshot=d,im(r)&&sm(i)}function nm(i,r,c){return c(function(){im(r)&&sm(i)})}function im(i){var r=i.getSnapshot;i=i.value;try{var c=r();return!hi(i,c)}catch{return!0}}function sm(i){var r=$i(i,1);r!==null&&vi(r,i,1,-1)}function rm(i){var r=bi();return typeof i=="function"&&(i=i()),r.memoizedState=r.baseState=i,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:xo,lastRenderedState:i},r.queue=i,i=i.dispatch=zS.bind(null,$t,i),[r.memoizedState,i]}function ko(i,r,c,d){return i={tag:i,create:r,destroy:c,deps:d,next:null},r=$t.updateQueue,r===null?(r={lastEffect:null,stores:null},$t.updateQueue=r,r.lastEffect=i.next=i):(c=r.lastEffect,c===null?r.lastEffect=i.next=i:(d=c.next,c.next=i,i.next=d,r.lastEffect=i)),i}function om(){return ri().memoizedState}function Ua(i,r,c,d){var g=bi();$t.flags|=i,g.memoizedState=ko(1|r,c,void 0,d===void 0?null:d)}function Wa(i,r,c,d){var g=ri();d=d===void 0?null:d;var _=void 0;if(on!==null){var R=on.memoizedState;if(_=R.destroy,d!==null&&ou(d,R.deps)){g.memoizedState=ko(r,c,_,d);return}}$t.flags|=i,g.memoizedState=ko(1|r,c,_,d)}function am(i,r){return Ua(8390656,8,i,r)}function du(i,r){return Wa(2048,8,i,r)}function lm(i,r){return Wa(4,2,i,r)}function cm(i,r){return Wa(4,4,i,r)}function um(i,r){if(typeof r=="function")return i=i(),r(i),function(){r(null)};if(r!=null)return i=i(),r.current=i,function(){r.current=null}}function dm(i,r,c){return c=c!=null?c.concat([i]):null,Wa(4,4,um.bind(null,r,i),c)}function hu(){}function hm(i,r){var c=ri();r=r===void 0?null:r;var d=c.memoizedState;return d!==null&&r!==null&&ou(r,d[1])?d[0]:(c.memoizedState=[i,r],i)}function fm(i,r){var c=ri();r=r===void 0?null:r;var d=c.memoizedState;return d!==null&&r!==null&&ou(r,d[1])?d[0]:(i=i(),c.memoizedState=[i,r],i)}function pm(i,r,c){return(Bs&21)===0?(i.baseState&&(i.baseState=!1,Fn=!0),i.memoizedState=c):(hi(c,r)||(c=Wf(),$t.lanes|=c,zs|=c,i.baseState=!0),r)}function OS(i,r){var c=St;St=c!==0&&4>c?c:4,i(!0);var d=ru.transition;ru.transition={};try{i(!1),r()}finally{St=c,ru.transition=d}}function mm(){return ri().memoizedState}function BS(i,r,c){var d=fs(i);if(c={lane:d,action:c,hasEagerState:!1,eagerState:null,next:null},gm(i))vm(r,c);else if(c=Vp(i,r,c,d),c!==null){var g=Tn();vi(c,i,d,g),_m(c,r,d)}}function zS(i,r,c){var d=fs(i),g={lane:d,action:c,hasEagerState:!1,eagerState:null,next:null};if(gm(i))vm(r,g);else{var _=i.alternate;if(i.lanes===0&&(_===null||_.lanes===0)&&(_=r.lastRenderedReducer,_!==null))try{var R=r.lastRenderedState,q=_(R,c);if(g.hasEagerState=!0,g.eagerState=q,hi(q,R)){var J=r.interleaved;J===null?(g.next=g,Zc(r)):(g.next=J.next,J.next=g),r.interleaved=g;return}}catch{}finally{}c=Vp(i,r,g,d),c!==null&&(g=Tn(),vi(c,i,d,g),_m(c,r,d))}}function gm(i){var r=i.alternate;return i===$t||r!==null&&r===$t}function vm(i,r){bo=Ha=!0;var c=i.pending;c===null?r.next=r:(r.next=c.next,c.next=r),i.pending=r}function _m(i,r,c){if((c&4194240)!==0){var d=r.lanes;d&=i.pendingLanes,c|=d,r.lanes=c,pc(i,c)}}var Ka={readContext:si,useCallback:Nn,useContext:Nn,useEffect:Nn,useImperativeHandle:Nn,useInsertionEffect:Nn,useLayoutEffect:Nn,useMemo:Nn,useReducer:Nn,useRef:Nn,useState:Nn,useDebugValue:Nn,useDeferredValue:Nn,useTransition:Nn,useMutableSource:Nn,useSyncExternalStore:Nn,useId:Nn,unstable_isNewReconciler:!1},$S={readContext:si,useCallback:function(i,r){return bi().memoizedState=[i,r===void 0?null:r],i},useContext:si,useEffect:am,useImperativeHandle:function(i,r,c){return c=c!=null?c.concat([i]):null,Ua(4194308,4,um.bind(null,r,i),c)},useLayoutEffect:function(i,r){return Ua(4194308,4,i,r)},useInsertionEffect:function(i,r){return Ua(4,2,i,r)},useMemo:function(i,r){var c=bi();return r=r===void 0?null:r,i=i(),c.memoizedState=[i,r],i},useReducer:function(i,r,c){var d=bi();return r=c!==void 0?c(r):r,d.memoizedState=d.baseState=r,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:r},d.queue=i,i=i.dispatch=BS.bind(null,$t,i),[d.memoizedState,i]},useRef:function(i){var r=bi();return i={current:i},r.memoizedState=i},useState:rm,useDebugValue:hu,useDeferredValue:function(i){return bi().memoizedState=i},useTransition:function(){var i=rm(!1),r=i[0];return i=OS.bind(null,i[1]),bi().memoizedState=i,[r,i]},useMutableSource:function(){},useSyncExternalStore:function(i,r,c){var d=$t,g=bi();if(Ot){if(c===void 0)throw Error(n(407));c=c()}else{if(c=r(),pn===null)throw Error(n(349));(Bs&30)!==0||em(d,r,c)}g.memoizedState=c;var _={value:c,getSnapshot:r};return g.queue=_,am(nm.bind(null,d,_,i),[i]),d.flags|=2048,ko(9,tm.bind(null,d,_,c,r),void 0,null),c},useId:function(){var i=bi(),r=pn.identifierPrefix;if(Ot){var c=zi,d=Bi;c=(d&~(1<<32-Bn(d)-1)).toString(32)+c,r=":"+r+"R"+c,c=So++,0<c&&(r+="H"+c.toString(32)),r+=":"}else c=IS++,r=":"+r+"r"+c.toString(32)+":";return i.memoizedState=r},unstable_isNewReconciler:!1},FS={readContext:si,useCallback:hm,useContext:si,useEffect:du,useImperativeHandle:dm,useInsertionEffect:lm,useLayoutEffect:cm,useMemo:fm,useReducer:cu,useRef:om,useState:function(){return cu(xo)},useDebugValue:hu,useDeferredValue:function(i){var r=ri();return pm(r,on.memoizedState,i)},useTransition:function(){var i=cu(xo)[0],r=ri().memoizedState;return[i,r]},useMutableSource:Jp,useSyncExternalStore:Zp,useId:mm,unstable_isNewReconciler:!1},HS={readContext:si,useCallback:hm,useContext:si,useEffect:du,useImperativeHandle:dm,useInsertionEffect:lm,useLayoutEffect:cm,useMemo:fm,useReducer:uu,useRef:om,useState:function(){return uu(xo)},useDebugValue:hu,useDeferredValue:function(i){var r=ri();return on===null?r.memoizedState=i:pm(r,on.memoizedState,i)},useTransition:function(){var i=uu(xo)[0],r=ri().memoizedState;return[i,r]},useMutableSource:Jp,useSyncExternalStore:Zp,useId:mm,unstable_isNewReconciler:!1};function pi(i,r){if(i&&i.defaultProps){r=L({},r),i=i.defaultProps;for(var c in i)r[c]===void 0&&(r[c]=i[c]);return r}return r}function fu(i,r,c,d){r=i.memoizedState,c=c(d,r),c=c==null?r:L({},r,c),i.memoizedState=c,i.lanes===0&&(i.updateQueue.baseState=c)}var qa={isMounted:function(i){return(i=i._reactInternals)?Nt(i)===i:!1},enqueueSetState:function(i,r,c){i=i._reactInternals;var d=Tn(),g=fs(i),_=Fi(d,g);_.payload=r,c!=null&&(_.callback=c),r=cs(i,_,g),r!==null&&(vi(r,i,g,d),Ba(r,i,g))},enqueueReplaceState:function(i,r,c){i=i._reactInternals;var d=Tn(),g=fs(i),_=Fi(d,g);_.tag=1,_.payload=r,c!=null&&(_.callback=c),r=cs(i,_,g),r!==null&&(vi(r,i,g,d),Ba(r,i,g))},enqueueForceUpdate:function(i,r){i=i._reactInternals;var c=Tn(),d=fs(i),g=Fi(c,d);g.tag=2,r!=null&&(g.callback=r),r=cs(i,g,d),r!==null&&(vi(r,i,d,c),Ba(r,i,d))}};function ym(i,r,c,d,g,_,R){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(d,_,R):r.prototype&&r.prototype.isPureReactComponent?!co(c,d)||!co(g,_):!0}function wm(i,r,c){var d=!1,g=os,_=r.contextType;return typeof _=="object"&&_!==null?_=si(_):(g=$n(r)?Ts:En.current,d=r.contextTypes,_=(d=d!=null)?pr(i,g):os),r=new r(c,_),i.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=qa,i.stateNode=r,r._reactInternals=i,d&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=g,i.__reactInternalMemoizedMaskedChildContext=_),r}function bm(i,r,c,d){i=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(c,d),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(c,d),r.state!==i&&qa.enqueueReplaceState(r,r.state,null)}function pu(i,r,c,d){var g=i.stateNode;g.props=c,g.state=i.memoizedState,g.refs={},eu(i);var _=r.contextType;typeof _=="object"&&_!==null?g.context=si(_):(_=$n(r)?Ts:En.current,g.context=pr(i,_)),g.state=i.memoizedState,_=r.getDerivedStateFromProps,typeof _=="function"&&(fu(i,r,_,c),g.state=i.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof g.getSnapshotBeforeUpdate=="function"||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(r=g.state,typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount(),r!==g.state&&qa.enqueueReplaceState(g,g.state,null),za(i,c,g,d),g.state=i.memoizedState),typeof g.componentDidMount=="function"&&(i.flags|=4194308)}function Sr(i,r){try{var c="",d=r;do c+=ue(d),d=d.return;while(d);var g=c}catch(_){g=`
|
|
39
|
-
Error generating stack: `+_.message+`
|
|
40
|
-
`+_.stack}return{value:i,source:r,stack:g,digest:null}}function mu(i,r,c){return{value:i,source:null,stack:c??null,digest:r??null}}function gu(i,r){try{console.error(r.value)}catch(c){setTimeout(function(){throw c})}}var US=typeof WeakMap=="function"?WeakMap:Map;function Sm(i,r,c){c=Fi(-1,c),c.tag=3,c.payload={element:null};var d=r.value;return c.callback=function(){Za||(Za=!0,Au=d),gu(i,r)},c}function xm(i,r,c){c=Fi(-1,c),c.tag=3;var d=i.type.getDerivedStateFromError;if(typeof d=="function"){var g=r.value;c.payload=function(){return d(g)},c.callback=function(){gu(i,r)}}var _=i.stateNode;return _!==null&&typeof _.componentDidCatch=="function"&&(c.callback=function(){gu(i,r),typeof d!="function"&&(ds===null?ds=new Set([this]):ds.add(this));var R=r.stack;this.componentDidCatch(r.value,{componentStack:R!==null?R:""})}),c}function km(i,r,c){var d=i.pingCache;if(d===null){d=i.pingCache=new US;var g=new Set;d.set(r,g)}else g=d.get(r),g===void 0&&(g=new Set,d.set(r,g));g.has(c)||(g.add(c),i=i0.bind(null,i,r,c),r.then(i,i))}function Cm(i){do{var r;if((r=i.tag===13)&&(r=i.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return i;i=i.return}while(i!==null);return null}function Em(i,r,c,d,g){return(i.mode&1)===0?(i===r?i.flags|=65536:(i.flags|=128,c.flags|=131072,c.flags&=-52805,c.tag===1&&(c.alternate===null?c.tag=17:(r=Fi(-1,1),r.tag=2,cs(c,r,1))),c.lanes|=1),i):(i.flags|=65536,i.lanes=g,i)}var WS=O.ReactCurrentOwner,Fn=!1;function Ln(i,r,c,d){r.child=i===null?qp(r,null,c,d):_r(r,i.child,c,d)}function Nm(i,r,c,d,g){c=c.render;var _=r.ref;return wr(r,g),d=au(i,r,c,d,_,g),c=lu(),i!==null&&!Fn?(r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~g,Hi(i,r,g)):(Ot&&c&&Wc(r),r.flags|=1,Ln(i,r,d,g),r.child)}function jm(i,r,c,d,g){if(i===null){var _=c.type;return typeof _=="function"&&!Bu(_)&&_.defaultProps===void 0&&c.compare===null&&c.defaultProps===void 0?(r.tag=15,r.type=_,Rm(i,r,_,d,g)):(i=rl(c.type,null,d,r,r.mode,g),i.ref=r.ref,i.return=r,r.child=i)}if(_=i.child,(i.lanes&g)===0){var R=_.memoizedProps;if(c=c.compare,c=c!==null?c:co,c(R,d)&&i.ref===r.ref)return Hi(i,r,g)}return r.flags|=1,i=ms(_,d),i.ref=r.ref,i.return=r,r.child=i}function Rm(i,r,c,d,g){if(i!==null){var _=i.memoizedProps;if(co(_,d)&&i.ref===r.ref)if(Fn=!1,r.pendingProps=d=_,(i.lanes&g)!==0)(i.flags&131072)!==0&&(Fn=!0);else return r.lanes=i.lanes,Hi(i,r,g)}return vu(i,r,c,d,g)}function Pm(i,r,c){var d=r.pendingProps,g=d.children,_=i!==null?i.memoizedState:null;if(d.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},jt(kr,Xn),Xn|=c;else{if((c&1073741824)===0)return i=_!==null?_.baseLanes|c:c,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:i,cachePool:null,transitions:null},r.updateQueue=null,jt(kr,Xn),Xn|=i,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},d=_!==null?_.baseLanes:c,jt(kr,Xn),Xn|=d}else _!==null?(d=_.baseLanes|c,r.memoizedState=null):d=c,jt(kr,Xn),Xn|=d;return Ln(i,r,g,c),r.child}function Am(i,r){var c=r.ref;(i===null&&c!==null||i!==null&&i.ref!==c)&&(r.flags|=512,r.flags|=2097152)}function vu(i,r,c,d,g){var _=$n(c)?Ts:En.current;return _=pr(r,_),wr(r,g),c=au(i,r,c,d,_,g),d=lu(),i!==null&&!Fn?(r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~g,Hi(i,r,g)):(Ot&&d&&Wc(r),r.flags|=1,Ln(i,r,c,g),r.child)}function Lm(i,r,c,d,g){if($n(c)){var _=!0;Pa(r)}else _=!1;if(wr(r,g),r.stateNode===null)Ya(i,r),wm(r,c,d),pu(r,c,d,g),d=!0;else if(i===null){var R=r.stateNode,q=r.memoizedProps;R.props=q;var J=R.context,ae=c.contextType;typeof ae=="object"&&ae!==null?ae=si(ae):(ae=$n(c)?Ts:En.current,ae=pr(r,ae));var xe=c.getDerivedStateFromProps,ke=typeof xe=="function"||typeof R.getSnapshotBeforeUpdate=="function";ke||typeof R.UNSAFE_componentWillReceiveProps!="function"&&typeof R.componentWillReceiveProps!="function"||(q!==d||J!==ae)&&bm(r,R,d,ae),ls=!1;var be=r.memoizedState;R.state=be,za(r,d,R,g),J=r.memoizedState,q!==d||be!==J||zn.current||ls?(typeof xe=="function"&&(fu(r,c,xe,d),J=r.memoizedState),(q=ls||ym(r,c,q,d,be,J,ae))?(ke||typeof R.UNSAFE_componentWillMount!="function"&&typeof R.componentWillMount!="function"||(typeof R.componentWillMount=="function"&&R.componentWillMount(),typeof R.UNSAFE_componentWillMount=="function"&&R.UNSAFE_componentWillMount()),typeof R.componentDidMount=="function"&&(r.flags|=4194308)):(typeof R.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=d,r.memoizedState=J),R.props=d,R.state=J,R.context=ae,d=q):(typeof R.componentDidMount=="function"&&(r.flags|=4194308),d=!1)}else{R=r.stateNode,Yp(i,r),q=r.memoizedProps,ae=r.type===r.elementType?q:pi(r.type,q),R.props=ae,ke=r.pendingProps,be=R.context,J=c.contextType,typeof J=="object"&&J!==null?J=si(J):(J=$n(c)?Ts:En.current,J=pr(r,J));var Me=c.getDerivedStateFromProps;(xe=typeof Me=="function"||typeof R.getSnapshotBeforeUpdate=="function")||typeof R.UNSAFE_componentWillReceiveProps!="function"&&typeof R.componentWillReceiveProps!="function"||(q!==ke||be!==J)&&bm(r,R,d,J),ls=!1,be=r.memoizedState,R.state=be,za(r,d,R,g);var ze=r.memoizedState;q!==ke||be!==ze||zn.current||ls?(typeof Me=="function"&&(fu(r,c,Me,d),ze=r.memoizedState),(ae=ls||ym(r,c,ae,d,be,ze,J)||!1)?(xe||typeof R.UNSAFE_componentWillUpdate!="function"&&typeof R.componentWillUpdate!="function"||(typeof R.componentWillUpdate=="function"&&R.componentWillUpdate(d,ze,J),typeof R.UNSAFE_componentWillUpdate=="function"&&R.UNSAFE_componentWillUpdate(d,ze,J)),typeof R.componentDidUpdate=="function"&&(r.flags|=4),typeof R.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof R.componentDidUpdate!="function"||q===i.memoizedProps&&be===i.memoizedState||(r.flags|=4),typeof R.getSnapshotBeforeUpdate!="function"||q===i.memoizedProps&&be===i.memoizedState||(r.flags|=1024),r.memoizedProps=d,r.memoizedState=ze),R.props=d,R.state=ze,R.context=J,d=ae):(typeof R.componentDidUpdate!="function"||q===i.memoizedProps&&be===i.memoizedState||(r.flags|=4),typeof R.getSnapshotBeforeUpdate!="function"||q===i.memoizedProps&&be===i.memoizedState||(r.flags|=1024),d=!1)}return _u(i,r,c,d,_,g)}function _u(i,r,c,d,g,_){Am(i,r);var R=(r.flags&128)!==0;if(!d&&!R)return g&&Op(r,c,!1),Hi(i,r,_);d=r.stateNode,WS.current=r;var q=R&&typeof c.getDerivedStateFromError!="function"?null:d.render();return r.flags|=1,i!==null&&R?(r.child=_r(r,i.child,null,_),r.child=_r(r,null,q,_)):Ln(i,r,q,_),r.memoizedState=d.state,g&&Op(r,c,!0),r.child}function Tm(i){var r=i.stateNode;r.pendingContext?Dp(i,r.pendingContext,r.pendingContext!==r.context):r.context&&Dp(i,r.context,!1),tu(i,r.containerInfo)}function Mm(i,r,c,d,g){return vr(),Yc(g),r.flags|=256,Ln(i,r,c,d),r.child}var yu={dehydrated:null,treeContext:null,retryLane:0};function wu(i){return{baseLanes:i,cachePool:null,transitions:null}}function Dm(i,r,c){var d=r.pendingProps,g=zt.current,_=!1,R=(r.flags&128)!==0,q;if((q=R)||(q=i!==null&&i.memoizedState===null?!1:(g&2)!==0),q?(_=!0,r.flags&=-129):(i===null||i.memoizedState!==null)&&(g|=1),jt(zt,g&1),i===null)return Vc(r),i=r.memoizedState,i!==null&&(i=i.dehydrated,i!==null)?((r.mode&1)===0?r.lanes=1:i.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(R=d.children,i=d.fallback,_?(d=r.mode,_=r.child,R={mode:"hidden",children:R},(d&1)===0&&_!==null?(_.childLanes=0,_.pendingProps=R):_=ol(R,d,0,null),i=Us(i,d,c,null),_.return=r,i.return=r,_.sibling=i,r.child=_,r.child.memoizedState=wu(c),r.memoizedState=yu,i):bu(r,R));if(g=i.memoizedState,g!==null&&(q=g.dehydrated,q!==null))return KS(i,r,R,d,q,g,c);if(_){_=d.fallback,R=r.mode,g=i.child,q=g.sibling;var J={mode:"hidden",children:d.children};return(R&1)===0&&r.child!==g?(d=r.child,d.childLanes=0,d.pendingProps=J,r.deletions=null):(d=ms(g,J),d.subtreeFlags=g.subtreeFlags&14680064),q!==null?_=ms(q,_):(_=Us(_,R,c,null),_.flags|=2),_.return=r,d.return=r,d.sibling=_,r.child=d,d=_,_=r.child,R=i.child.memoizedState,R=R===null?wu(c):{baseLanes:R.baseLanes|c,cachePool:null,transitions:R.transitions},_.memoizedState=R,_.childLanes=i.childLanes&~c,r.memoizedState=yu,d}return _=i.child,i=_.sibling,d=ms(_,{mode:"visible",children:d.children}),(r.mode&1)===0&&(d.lanes=c),d.return=r,d.sibling=null,i!==null&&(c=r.deletions,c===null?(r.deletions=[i],r.flags|=16):c.push(i)),r.child=d,r.memoizedState=null,d}function bu(i,r){return r=ol({mode:"visible",children:r},i.mode,0,null),r.return=i,i.child=r}function Va(i,r,c,d){return d!==null&&Yc(d),_r(r,i.child,null,c),i=bu(r,r.pendingProps.children),i.flags|=2,r.memoizedState=null,i}function KS(i,r,c,d,g,_,R){if(c)return r.flags&256?(r.flags&=-257,d=mu(Error(n(422))),Va(i,r,R,d)):r.memoizedState!==null?(r.child=i.child,r.flags|=128,null):(_=d.fallback,g=r.mode,d=ol({mode:"visible",children:d.children},g,0,null),_=Us(_,g,R,null),_.flags|=2,d.return=r,_.return=r,d.sibling=_,r.child=d,(r.mode&1)!==0&&_r(r,i.child,null,R),r.child.memoizedState=wu(R),r.memoizedState=yu,_);if((r.mode&1)===0)return Va(i,r,R,null);if(g.data==="$!"){if(d=g.nextSibling&&g.nextSibling.dataset,d)var q=d.dgst;return d=q,_=Error(n(419)),d=mu(_,d,void 0),Va(i,r,R,d)}if(q=(R&i.childLanes)!==0,Fn||q){if(d=pn,d!==null){switch(R&-R){case 4:g=2;break;case 16:g=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:g=32;break;case 536870912:g=268435456;break;default:g=0}g=(g&(d.suspendedLanes|R))!==0?0:g,g!==0&&g!==_.retryLane&&(_.retryLane=g,$i(i,g),vi(d,i,g,-1))}return Ou(),d=mu(Error(n(421))),Va(i,r,R,d)}return g.data==="$?"?(r.flags|=128,r.child=i.child,r=s0.bind(null,i),g._reactRetry=r,null):(i=_.treeContext,Gn=ss(g.nextSibling),Yn=r,Ot=!0,fi=null,i!==null&&(ni[ii++]=Bi,ni[ii++]=zi,ni[ii++]=Ms,Bi=i.id,zi=i.overflow,Ms=r),r=bu(r,d.children),r.flags|=4096,r)}function Im(i,r,c){i.lanes|=r;var d=i.alternate;d!==null&&(d.lanes|=r),Jc(i.return,r,c)}function Su(i,r,c,d,g){var _=i.memoizedState;_===null?i.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:d,tail:c,tailMode:g}:(_.isBackwards=r,_.rendering=null,_.renderingStartTime=0,_.last=d,_.tail=c,_.tailMode=g)}function Om(i,r,c){var d=r.pendingProps,g=d.revealOrder,_=d.tail;if(Ln(i,r,d.children,c),d=zt.current,(d&2)!==0)d=d&1|2,r.flags|=128;else{if(i!==null&&(i.flags&128)!==0)e:for(i=r.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&Im(i,c,r);else if(i.tag===19)Im(i,c,r);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break e;for(;i.sibling===null;){if(i.return===null||i.return===r)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}d&=1}if(jt(zt,d),(r.mode&1)===0)r.memoizedState=null;else switch(g){case"forwards":for(c=r.child,g=null;c!==null;)i=c.alternate,i!==null&&$a(i)===null&&(g=c),c=c.sibling;c=g,c===null?(g=r.child,r.child=null):(g=c.sibling,c.sibling=null),Su(r,!1,g,c,_);break;case"backwards":for(c=null,g=r.child,r.child=null;g!==null;){if(i=g.alternate,i!==null&&$a(i)===null){r.child=g;break}i=g.sibling,g.sibling=c,c=g,g=i}Su(r,!0,c,null,_);break;case"together":Su(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function Ya(i,r){(r.mode&1)===0&&i!==null&&(i.alternate=null,r.alternate=null,r.flags|=2)}function Hi(i,r,c){if(i!==null&&(r.dependencies=i.dependencies),zs|=r.lanes,(c&r.childLanes)===0)return null;if(i!==null&&r.child!==i.child)throw Error(n(153));if(r.child!==null){for(i=r.child,c=ms(i,i.pendingProps),r.child=c,c.return=r;i.sibling!==null;)i=i.sibling,c=c.sibling=ms(i,i.pendingProps),c.return=r;c.sibling=null}return r.child}function qS(i,r,c){switch(r.tag){case 3:Tm(r),vr();break;case 5:Qp(r);break;case 1:$n(r.type)&&Pa(r);break;case 4:tu(r,r.stateNode.containerInfo);break;case 10:var d=r.type._context,g=r.memoizedProps.value;jt(Ia,d._currentValue),d._currentValue=g;break;case 13:if(d=r.memoizedState,d!==null)return d.dehydrated!==null?(jt(zt,zt.current&1),r.flags|=128,null):(c&r.child.childLanes)!==0?Dm(i,r,c):(jt(zt,zt.current&1),i=Hi(i,r,c),i!==null?i.sibling:null);jt(zt,zt.current&1);break;case 19:if(d=(c&r.childLanes)!==0,(i.flags&128)!==0){if(d)return Om(i,r,c);r.flags|=128}if(g=r.memoizedState,g!==null&&(g.rendering=null,g.tail=null,g.lastEffect=null),jt(zt,zt.current),d)break;return null;case 22:case 23:return r.lanes=0,Pm(i,r,c)}return Hi(i,r,c)}var Bm,xu,zm,$m;Bm=function(i,r){for(var c=r.child;c!==null;){if(c.tag===5||c.tag===6)i.appendChild(c.stateNode);else if(c.tag!==4&&c.child!==null){c.child.return=c,c=c.child;continue}if(c===r)break;for(;c.sibling===null;){if(c.return===null||c.return===r)return;c=c.return}c.sibling.return=c.return,c=c.sibling}},xu=function(){},zm=function(i,r,c,d){var g=i.memoizedProps;if(g!==d){i=r.stateNode,Os(wi.current);var _=null;switch(c){case"input":g=Dt(i,g),d=Dt(i,d),_=[];break;case"select":g=L({},g,{value:void 0}),d=L({},d,{value:void 0}),_=[];break;case"textarea":g=gt(i,g),d=gt(i,d),_=[];break;default:typeof g.onClick!="function"&&typeof d.onClick=="function"&&(i.onclick=Na)}_t(c,d);var R;c=null;for(ae in g)if(!d.hasOwnProperty(ae)&&g.hasOwnProperty(ae)&&g[ae]!=null)if(ae==="style"){var q=g[ae];for(R in q)q.hasOwnProperty(R)&&(c||(c={}),c[R]="")}else ae!=="dangerouslySetInnerHTML"&&ae!=="children"&&ae!=="suppressContentEditableWarning"&&ae!=="suppressHydrationWarning"&&ae!=="autoFocus"&&(o.hasOwnProperty(ae)?_||(_=[]):(_=_||[]).push(ae,null));for(ae in d){var J=d[ae];if(q=g!=null?g[ae]:void 0,d.hasOwnProperty(ae)&&J!==q&&(J!=null||q!=null))if(ae==="style")if(q){for(R in q)!q.hasOwnProperty(R)||J&&J.hasOwnProperty(R)||(c||(c={}),c[R]="");for(R in J)J.hasOwnProperty(R)&&q[R]!==J[R]&&(c||(c={}),c[R]=J[R])}else c||(_||(_=[]),_.push(ae,c)),c=J;else ae==="dangerouslySetInnerHTML"?(J=J?J.__html:void 0,q=q?q.__html:void 0,J!=null&&q!==J&&(_=_||[]).push(ae,J)):ae==="children"?typeof J!="string"&&typeof J!="number"||(_=_||[]).push(ae,""+J):ae!=="suppressContentEditableWarning"&&ae!=="suppressHydrationWarning"&&(o.hasOwnProperty(ae)?(J!=null&&ae==="onScroll"&&Lt("scroll",i),_||q===J||(_=[])):(_=_||[]).push(ae,J))}c&&(_=_||[]).push("style",c);var ae=_;(r.updateQueue=ae)&&(r.flags|=4)}},$m=function(i,r,c,d){c!==d&&(r.flags|=4)};function Co(i,r){if(!Ot)switch(i.tailMode){case"hidden":r=i.tail;for(var c=null;r!==null;)r.alternate!==null&&(c=r),r=r.sibling;c===null?i.tail=null:c.sibling=null;break;case"collapsed":c=i.tail;for(var d=null;c!==null;)c.alternate!==null&&(d=c),c=c.sibling;d===null?r||i.tail===null?i.tail=null:i.tail.sibling=null:d.sibling=null}}function jn(i){var r=i.alternate!==null&&i.alternate.child===i.child,c=0,d=0;if(r)for(var g=i.child;g!==null;)c|=g.lanes|g.childLanes,d|=g.subtreeFlags&14680064,d|=g.flags&14680064,g.return=i,g=g.sibling;else for(g=i.child;g!==null;)c|=g.lanes|g.childLanes,d|=g.subtreeFlags,d|=g.flags,g.return=i,g=g.sibling;return i.subtreeFlags|=d,i.childLanes=c,r}function VS(i,r,c){var d=r.pendingProps;switch(Kc(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return jn(r),null;case 1:return $n(r.type)&&Ra(),jn(r),null;case 3:return d=r.stateNode,br(),Tt(zn),Tt(En),su(),d.pendingContext&&(d.context=d.pendingContext,d.pendingContext=null),(i===null||i.child===null)&&(Ma(r)?r.flags|=4:i===null||i.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,fi!==null&&(Mu(fi),fi=null))),xu(i,r),jn(r),null;case 5:nu(r);var g=Os(wo.current);if(c=r.type,i!==null&&r.stateNode!=null)zm(i,r,c,d,g),i.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!d){if(r.stateNode===null)throw Error(n(166));return jn(r),null}if(i=Os(wi.current),Ma(r)){d=r.stateNode,c=r.type;var _=r.memoizedProps;switch(d[yi]=r,d[mo]=_,i=(r.mode&1)!==0,c){case"dialog":Lt("cancel",d),Lt("close",d);break;case"iframe":case"object":case"embed":Lt("load",d);break;case"video":case"audio":for(g=0;g<ho.length;g++)Lt(ho[g],d);break;case"source":Lt("error",d);break;case"img":case"image":case"link":Lt("error",d),Lt("load",d);break;case"details":Lt("toggle",d);break;case"input":Qt(d,_),Lt("invalid",d);break;case"select":d._wrapperState={wasMultiple:!!_.multiple},Lt("invalid",d);break;case"textarea":pt(d,_),Lt("invalid",d)}_t(c,_),g=null;for(var R in _)if(_.hasOwnProperty(R)){var q=_[R];R==="children"?typeof q=="string"?d.textContent!==q&&(_.suppressHydrationWarning!==!0&&Ea(d.textContent,q,i),g=["children",q]):typeof q=="number"&&d.textContent!==""+q&&(_.suppressHydrationWarning!==!0&&Ea(d.textContent,q,i),g=["children",""+q]):o.hasOwnProperty(R)&&q!=null&&R==="onScroll"&&Lt("scroll",d)}switch(c){case"input":ut(d),it(d,_,!0);break;case"textarea":ut(d),vt(d);break;case"select":case"option":break;default:typeof _.onClick=="function"&&(d.onclick=Na)}d=g,r.updateQueue=d,d!==null&&(r.flags|=4)}else{R=g.nodeType===9?g:g.ownerDocument,i==="http://www.w3.org/1999/xhtml"&&(i=xt(c)),i==="http://www.w3.org/1999/xhtml"?c==="script"?(i=R.createElement("div"),i.innerHTML="<script><\/script>",i=i.removeChild(i.firstChild)):typeof d.is=="string"?i=R.createElement(c,{is:d.is}):(i=R.createElement(c),c==="select"&&(R=i,d.multiple?R.multiple=!0:d.size&&(R.size=d.size))):i=R.createElementNS(i,c),i[yi]=r,i[mo]=d,Bm(i,r,!1,!1),r.stateNode=i;e:{switch(R=yt(c,d),c){case"dialog":Lt("cancel",i),Lt("close",i),g=d;break;case"iframe":case"object":case"embed":Lt("load",i),g=d;break;case"video":case"audio":for(g=0;g<ho.length;g++)Lt(ho[g],i);g=d;break;case"source":Lt("error",i),g=d;break;case"img":case"image":case"link":Lt("error",i),Lt("load",i),g=d;break;case"details":Lt("toggle",i),g=d;break;case"input":Qt(i,d),g=Dt(i,d),Lt("invalid",i);break;case"option":g=d;break;case"select":i._wrapperState={wasMultiple:!!d.multiple},g=L({},d,{value:void 0}),Lt("invalid",i);break;case"textarea":pt(i,d),g=gt(i,d),Lt("invalid",i);break;default:g=d}_t(c,g),q=g;for(_ in q)if(q.hasOwnProperty(_)){var J=q[_];_==="style"?De(i,J):_==="dangerouslySetInnerHTML"?(J=J?J.__html:void 0,J!=null&&Pe(i,J)):_==="children"?typeof J=="string"?(c!=="textarea"||J!=="")&&We(i,J):typeof J=="number"&&We(i,""+J):_!=="suppressContentEditableWarning"&&_!=="suppressHydrationWarning"&&_!=="autoFocus"&&(o.hasOwnProperty(_)?J!=null&&_==="onScroll"&&Lt("scroll",i):J!=null&&$(i,_,J,R))}switch(c){case"input":ut(i),it(i,d,!1);break;case"textarea":ut(i),vt(i);break;case"option":d.value!=null&&i.setAttribute("value",""+ie(d.value));break;case"select":i.multiple=!!d.multiple,_=d.value,_!=null?mt(i,!!d.multiple,_,!1):d.defaultValue!=null&&mt(i,!!d.multiple,d.defaultValue,!0);break;default:typeof g.onClick=="function"&&(i.onclick=Na)}switch(c){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}}d&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return jn(r),null;case 6:if(i&&r.stateNode!=null)$m(i,r,i.memoizedProps,d);else{if(typeof d!="string"&&r.stateNode===null)throw Error(n(166));if(c=Os(wo.current),Os(wi.current),Ma(r)){if(d=r.stateNode,c=r.memoizedProps,d[yi]=r,(_=d.nodeValue!==c)&&(i=Yn,i!==null))switch(i.tag){case 3:Ea(d.nodeValue,c,(i.mode&1)!==0);break;case 5:i.memoizedProps.suppressHydrationWarning!==!0&&Ea(d.nodeValue,c,(i.mode&1)!==0)}_&&(r.flags|=4)}else d=(c.nodeType===9?c:c.ownerDocument).createTextNode(d),d[yi]=r,r.stateNode=d}return jn(r),null;case 13:if(Tt(zt),d=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(Ot&&Gn!==null&&(r.mode&1)!==0&&(r.flags&128)===0)Up(),vr(),r.flags|=98560,_=!1;else if(_=Ma(r),d!==null&&d.dehydrated!==null){if(i===null){if(!_)throw Error(n(318));if(_=r.memoizedState,_=_!==null?_.dehydrated:null,!_)throw Error(n(317));_[yi]=r}else vr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;jn(r),_=!1}else fi!==null&&(Mu(fi),fi=null),_=!0;if(!_)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=c,r):(d=d!==null,d!==(i!==null&&i.memoizedState!==null)&&d&&(r.child.flags|=8192,(r.mode&1)!==0&&(i===null||(zt.current&1)!==0?an===0&&(an=3):Ou())),r.updateQueue!==null&&(r.flags|=4),jn(r),null);case 4:return br(),xu(i,r),i===null&&fo(r.stateNode.containerInfo),jn(r),null;case 10:return Qc(r.type._context),jn(r),null;case 17:return $n(r.type)&&Ra(),jn(r),null;case 19:if(Tt(zt),_=r.memoizedState,_===null)return jn(r),null;if(d=(r.flags&128)!==0,R=_.rendering,R===null)if(d)Co(_,!1);else{if(an!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(R=$a(i),R!==null){for(r.flags|=128,Co(_,!1),d=R.updateQueue,d!==null&&(r.updateQueue=d,r.flags|=4),r.subtreeFlags=0,d=c,c=r.child;c!==null;)_=c,i=d,_.flags&=14680066,R=_.alternate,R===null?(_.childLanes=0,_.lanes=i,_.child=null,_.subtreeFlags=0,_.memoizedProps=null,_.memoizedState=null,_.updateQueue=null,_.dependencies=null,_.stateNode=null):(_.childLanes=R.childLanes,_.lanes=R.lanes,_.child=R.child,_.subtreeFlags=0,_.deletions=null,_.memoizedProps=R.memoizedProps,_.memoizedState=R.memoizedState,_.updateQueue=R.updateQueue,_.type=R.type,i=R.dependencies,_.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),c=c.sibling;return jt(zt,zt.current&1|2),r.child}i=i.sibling}_.tail!==null&&It()>Cr&&(r.flags|=128,d=!0,Co(_,!1),r.lanes=4194304)}else{if(!d)if(i=$a(R),i!==null){if(r.flags|=128,d=!0,c=i.updateQueue,c!==null&&(r.updateQueue=c,r.flags|=4),Co(_,!0),_.tail===null&&_.tailMode==="hidden"&&!R.alternate&&!Ot)return jn(r),null}else 2*It()-_.renderingStartTime>Cr&&c!==1073741824&&(r.flags|=128,d=!0,Co(_,!1),r.lanes=4194304);_.isBackwards?(R.sibling=r.child,r.child=R):(c=_.last,c!==null?c.sibling=R:r.child=R,_.last=R)}return _.tail!==null?(r=_.tail,_.rendering=r,_.tail=r.sibling,_.renderingStartTime=It(),r.sibling=null,c=zt.current,jt(zt,d?c&1|2:c&1),r):(jn(r),null);case 22:case 23:return Iu(),d=r.memoizedState!==null,i!==null&&i.memoizedState!==null!==d&&(r.flags|=8192),d&&(r.mode&1)!==0?(Xn&1073741824)!==0&&(jn(r),r.subtreeFlags&6&&(r.flags|=8192)):jn(r),null;case 24:return null;case 25:return null}throw Error(n(156,r.tag))}function YS(i,r){switch(Kc(r),r.tag){case 1:return $n(r.type)&&Ra(),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return br(),Tt(zn),Tt(En),su(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 5:return nu(r),null;case 13:if(Tt(zt),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(n(340));vr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return Tt(zt),null;case 4:return br(),null;case 10:return Qc(r.type._context),null;case 22:case 23:return Iu(),null;case 24:return null;default:return null}}var Ga=!1,Rn=!1,GS=typeof WeakSet=="function"?WeakSet:Set,Ie=null;function xr(i,r){var c=i.ref;if(c!==null)if(typeof c=="function")try{c(null)}catch(d){Ut(i,r,d)}else c.current=null}function ku(i,r,c){try{c()}catch(d){Ut(i,r,d)}}var Fm=!1;function XS(i,r){if(Ic=ma,i=yp(),jc(i)){if("selectionStart"in i)var c={start:i.selectionStart,end:i.selectionEnd};else e:{c=(c=i.ownerDocument)&&c.defaultView||window;var d=c.getSelection&&c.getSelection();if(d&&d.rangeCount!==0){c=d.anchorNode;var g=d.anchorOffset,_=d.focusNode;d=d.focusOffset;try{c.nodeType,_.nodeType}catch{c=null;break e}var R=0,q=-1,J=-1,ae=0,xe=0,ke=i,be=null;t:for(;;){for(var Me;ke!==c||g!==0&&ke.nodeType!==3||(q=R+g),ke!==_||d!==0&&ke.nodeType!==3||(J=R+d),ke.nodeType===3&&(R+=ke.nodeValue.length),(Me=ke.firstChild)!==null;)be=ke,ke=Me;for(;;){if(ke===i)break t;if(be===c&&++ae===g&&(q=R),be===_&&++xe===d&&(J=R),(Me=ke.nextSibling)!==null)break;ke=be,be=ke.parentNode}ke=Me}c=q===-1||J===-1?null:{start:q,end:J}}else c=null}c=c||{start:0,end:0}}else c=null;for(Oc={focusedElem:i,selectionRange:c},ma=!1,Ie=r;Ie!==null;)if(r=Ie,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,Ie=i;else for(;Ie!==null;){r=Ie;try{var ze=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(ze!==null){var Fe=ze.memoizedProps,Yt=ze.memoizedState,ne=r.stateNode,ee=ne.getSnapshotBeforeUpdate(r.elementType===r.type?Fe:pi(r.type,Fe),Yt);ne.__reactInternalSnapshotBeforeUpdate=ee}break;case 3:var re=r.stateNode.containerInfo;re.nodeType===1?re.textContent="":re.nodeType===9&&re.documentElement&&re.removeChild(re.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Ee){Ut(r,r.return,Ee)}if(i=r.sibling,i!==null){i.return=r.return,Ie=i;break}Ie=r.return}return ze=Fm,Fm=!1,ze}function Eo(i,r,c){var d=r.updateQueue;if(d=d!==null?d.lastEffect:null,d!==null){var g=d=d.next;do{if((g.tag&i)===i){var _=g.destroy;g.destroy=void 0,_!==void 0&&ku(r,c,_)}g=g.next}while(g!==d)}}function Xa(i,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var c=r=r.next;do{if((c.tag&i)===i){var d=c.create;c.destroy=d()}c=c.next}while(c!==r)}}function Cu(i){var r=i.ref;if(r!==null){var c=i.stateNode;switch(i.tag){case 5:i=c;break;default:i=c}typeof r=="function"?r(i):r.current=i}}function Hm(i){var r=i.alternate;r!==null&&(i.alternate=null,Hm(r)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(r=i.stateNode,r!==null&&(delete r[yi],delete r[mo],delete r[Fc],delete r[LS],delete r[TS])),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}function Um(i){return i.tag===5||i.tag===3||i.tag===4}function Wm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||Um(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function Eu(i,r,c){var d=i.tag;if(d===5||d===6)i=i.stateNode,r?c.nodeType===8?c.parentNode.insertBefore(i,r):c.insertBefore(i,r):(c.nodeType===8?(r=c.parentNode,r.insertBefore(i,c)):(r=c,r.appendChild(i)),c=c._reactRootContainer,c!=null||r.onclick!==null||(r.onclick=Na));else if(d!==4&&(i=i.child,i!==null))for(Eu(i,r,c),i=i.sibling;i!==null;)Eu(i,r,c),i=i.sibling}function Nu(i,r,c){var d=i.tag;if(d===5||d===6)i=i.stateNode,r?c.insertBefore(i,r):c.appendChild(i);else if(d!==4&&(i=i.child,i!==null))for(Nu(i,r,c),i=i.sibling;i!==null;)Nu(i,r,c),i=i.sibling}var Sn=null,mi=!1;function us(i,r,c){for(c=c.child;c!==null;)Km(i,r,c),c=c.sibling}function Km(i,r,c){if(hn&&typeof hn.onCommitFiberUnmount=="function")try{hn.onCommitFiberUnmount(Zt,c)}catch{}switch(c.tag){case 5:Rn||xr(c,r);case 6:var d=Sn,g=mi;Sn=null,us(i,r,c),Sn=d,mi=g,Sn!==null&&(mi?(i=Sn,c=c.stateNode,i.nodeType===8?i.parentNode.removeChild(c):i.removeChild(c)):Sn.removeChild(c.stateNode));break;case 18:Sn!==null&&(mi?(i=Sn,c=c.stateNode,i.nodeType===8?$c(i.parentNode,c):i.nodeType===1&&$c(i,c),io(i)):$c(Sn,c.stateNode));break;case 4:d=Sn,g=mi,Sn=c.stateNode.containerInfo,mi=!0,us(i,r,c),Sn=d,mi=g;break;case 0:case 11:case 14:case 15:if(!Rn&&(d=c.updateQueue,d!==null&&(d=d.lastEffect,d!==null))){g=d=d.next;do{var _=g,R=_.destroy;_=_.tag,R!==void 0&&((_&2)!==0||(_&4)!==0)&&ku(c,r,R),g=g.next}while(g!==d)}us(i,r,c);break;case 1:if(!Rn&&(xr(c,r),d=c.stateNode,typeof d.componentWillUnmount=="function"))try{d.props=c.memoizedProps,d.state=c.memoizedState,d.componentWillUnmount()}catch(q){Ut(c,r,q)}us(i,r,c);break;case 21:us(i,r,c);break;case 22:c.mode&1?(Rn=(d=Rn)||c.memoizedState!==null,us(i,r,c),Rn=d):us(i,r,c);break;default:us(i,r,c)}}function qm(i){var r=i.updateQueue;if(r!==null){i.updateQueue=null;var c=i.stateNode;c===null&&(c=i.stateNode=new GS),r.forEach(function(d){var g=r0.bind(null,i,d);c.has(d)||(c.add(d),d.then(g,g))})}}function gi(i,r){var c=r.deletions;if(c!==null)for(var d=0;d<c.length;d++){var g=c[d];try{var _=i,R=r,q=R;e:for(;q!==null;){switch(q.tag){case 5:Sn=q.stateNode,mi=!1;break e;case 3:Sn=q.stateNode.containerInfo,mi=!0;break e;case 4:Sn=q.stateNode.containerInfo,mi=!0;break e}q=q.return}if(Sn===null)throw Error(n(160));Km(_,R,g),Sn=null,mi=!1;var J=g.alternate;J!==null&&(J.return=null),g.return=null}catch(ae){Ut(g,r,ae)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)Vm(r,i),r=r.sibling}function Vm(i,r){var c=i.alternate,d=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:if(gi(r,i),Si(i),d&4){try{Eo(3,i,i.return),Xa(3,i)}catch(Fe){Ut(i,i.return,Fe)}try{Eo(5,i,i.return)}catch(Fe){Ut(i,i.return,Fe)}}break;case 1:gi(r,i),Si(i),d&512&&c!==null&&xr(c,c.return);break;case 5:if(gi(r,i),Si(i),d&512&&c!==null&&xr(c,c.return),i.flags&32){var g=i.stateNode;try{We(g,"")}catch(Fe){Ut(i,i.return,Fe)}}if(d&4&&(g=i.stateNode,g!=null)){var _=i.memoizedProps,R=c!==null?c.memoizedProps:_,q=i.type,J=i.updateQueue;if(i.updateQueue=null,J!==null)try{q==="input"&&_.type==="radio"&&_.name!=null&&$e(g,_),yt(q,R);var ae=yt(q,_);for(R=0;R<J.length;R+=2){var xe=J[R],ke=J[R+1];xe==="style"?De(g,ke):xe==="dangerouslySetInnerHTML"?Pe(g,ke):xe==="children"?We(g,ke):$(g,xe,ke,ae)}switch(q){case"input":dt(g,_);break;case"textarea":Pt(g,_);break;case"select":var be=g._wrapperState.wasMultiple;g._wrapperState.wasMultiple=!!_.multiple;var Me=_.value;Me!=null?mt(g,!!_.multiple,Me,!1):be!==!!_.multiple&&(_.defaultValue!=null?mt(g,!!_.multiple,_.defaultValue,!0):mt(g,!!_.multiple,_.multiple?[]:"",!1))}g[mo]=_}catch(Fe){Ut(i,i.return,Fe)}}break;case 6:if(gi(r,i),Si(i),d&4){if(i.stateNode===null)throw Error(n(162));g=i.stateNode,_=i.memoizedProps;try{g.nodeValue=_}catch(Fe){Ut(i,i.return,Fe)}}break;case 3:if(gi(r,i),Si(i),d&4&&c!==null&&c.memoizedState.isDehydrated)try{io(r.containerInfo)}catch(Fe){Ut(i,i.return,Fe)}break;case 4:gi(r,i),Si(i);break;case 13:gi(r,i),Si(i),g=i.child,g.flags&8192&&(_=g.memoizedState!==null,g.stateNode.isHidden=_,!_||g.alternate!==null&&g.alternate.memoizedState!==null||(Pu=It())),d&4&&qm(i);break;case 22:if(xe=c!==null&&c.memoizedState!==null,i.mode&1?(Rn=(ae=Rn)||xe,gi(r,i),Rn=ae):gi(r,i),Si(i),d&8192){if(ae=i.memoizedState!==null,(i.stateNode.isHidden=ae)&&!xe&&(i.mode&1)!==0)for(Ie=i,xe=i.child;xe!==null;){for(ke=Ie=xe;Ie!==null;){switch(be=Ie,Me=be.child,be.tag){case 0:case 11:case 14:case 15:Eo(4,be,be.return);break;case 1:xr(be,be.return);var ze=be.stateNode;if(typeof ze.componentWillUnmount=="function"){d=be,c=be.return;try{r=d,ze.props=r.memoizedProps,ze.state=r.memoizedState,ze.componentWillUnmount()}catch(Fe){Ut(d,c,Fe)}}break;case 5:xr(be,be.return);break;case 22:if(be.memoizedState!==null){Xm(ke);continue}}Me!==null?(Me.return=be,Ie=Me):Xm(ke)}xe=xe.sibling}e:for(xe=null,ke=i;;){if(ke.tag===5){if(xe===null){xe=ke;try{g=ke.stateNode,ae?(_=g.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none"):(q=ke.stateNode,J=ke.memoizedProps.style,R=J!=null&&J.hasOwnProperty("display")?J.display:null,q.style.display=Ne("display",R))}catch(Fe){Ut(i,i.return,Fe)}}}else if(ke.tag===6){if(xe===null)try{ke.stateNode.nodeValue=ae?"":ke.memoizedProps}catch(Fe){Ut(i,i.return,Fe)}}else if((ke.tag!==22&&ke.tag!==23||ke.memoizedState===null||ke===i)&&ke.child!==null){ke.child.return=ke,ke=ke.child;continue}if(ke===i)break e;for(;ke.sibling===null;){if(ke.return===null||ke.return===i)break e;xe===ke&&(xe=null),ke=ke.return}xe===ke&&(xe=null),ke.sibling.return=ke.return,ke=ke.sibling}}break;case 19:gi(r,i),Si(i),d&4&&qm(i);break;case 21:break;default:gi(r,i),Si(i)}}function Si(i){var r=i.flags;if(r&2){try{e:{for(var c=i.return;c!==null;){if(Um(c)){var d=c;break e}c=c.return}throw Error(n(160))}switch(d.tag){case 5:var g=d.stateNode;d.flags&32&&(We(g,""),d.flags&=-33);var _=Wm(i);Nu(i,_,g);break;case 3:case 4:var R=d.stateNode.containerInfo,q=Wm(i);Eu(i,q,R);break;default:throw Error(n(161))}}catch(J){Ut(i,i.return,J)}i.flags&=-3}r&4096&&(i.flags&=-4097)}function QS(i,r,c){Ie=i,Ym(i)}function Ym(i,r,c){for(var d=(i.mode&1)!==0;Ie!==null;){var g=Ie,_=g.child;if(g.tag===22&&d){var R=g.memoizedState!==null||Ga;if(!R){var q=g.alternate,J=q!==null&&q.memoizedState!==null||Rn;q=Ga;var ae=Rn;if(Ga=R,(Rn=J)&&!ae)for(Ie=g;Ie!==null;)R=Ie,J=R.child,R.tag===22&&R.memoizedState!==null?Qm(g):J!==null?(J.return=R,Ie=J):Qm(g);for(;_!==null;)Ie=_,Ym(_),_=_.sibling;Ie=g,Ga=q,Rn=ae}Gm(i)}else(g.subtreeFlags&8772)!==0&&_!==null?(_.return=g,Ie=_):Gm(i)}}function Gm(i){for(;Ie!==null;){var r=Ie;if((r.flags&8772)!==0){var c=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:Rn||Xa(5,r);break;case 1:var d=r.stateNode;if(r.flags&4&&!Rn)if(c===null)d.componentDidMount();else{var g=r.elementType===r.type?c.memoizedProps:pi(r.type,c.memoizedProps);d.componentDidUpdate(g,c.memoizedState,d.__reactInternalSnapshotBeforeUpdate)}var _=r.updateQueue;_!==null&&Xp(r,_,d);break;case 3:var R=r.updateQueue;if(R!==null){if(c=null,r.child!==null)switch(r.child.tag){case 5:c=r.child.stateNode;break;case 1:c=r.child.stateNode}Xp(r,R,c)}break;case 5:var q=r.stateNode;if(c===null&&r.flags&4){c=q;var J=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":J.autoFocus&&c.focus();break;case"img":J.src&&(c.src=J.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var ae=r.alternate;if(ae!==null){var xe=ae.memoizedState;if(xe!==null){var ke=xe.dehydrated;ke!==null&&io(ke)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Rn||r.flags&512&&Cu(r)}catch(be){Ut(r,r.return,be)}}if(r===i){Ie=null;break}if(c=r.sibling,c!==null){c.return=r.return,Ie=c;break}Ie=r.return}}function Xm(i){for(;Ie!==null;){var r=Ie;if(r===i){Ie=null;break}var c=r.sibling;if(c!==null){c.return=r.return,Ie=c;break}Ie=r.return}}function Qm(i){for(;Ie!==null;){var r=Ie;try{switch(r.tag){case 0:case 11:case 15:var c=r.return;try{Xa(4,r)}catch(J){Ut(r,c,J)}break;case 1:var d=r.stateNode;if(typeof d.componentDidMount=="function"){var g=r.return;try{d.componentDidMount()}catch(J){Ut(r,g,J)}}var _=r.return;try{Cu(r)}catch(J){Ut(r,_,J)}break;case 5:var R=r.return;try{Cu(r)}catch(J){Ut(r,R,J)}}}catch(J){Ut(r,r.return,J)}if(r===i){Ie=null;break}var q=r.sibling;if(q!==null){q.return=r.return,Ie=q;break}Ie=r.return}}var JS=Math.ceil,Qa=O.ReactCurrentDispatcher,ju=O.ReactCurrentOwner,oi=O.ReactCurrentBatchConfig,ht=0,pn=null,en=null,xn=0,Xn=0,kr=rs(0),an=0,No=null,zs=0,Ja=0,Ru=0,jo=null,Hn=null,Pu=0,Cr=1/0,Ui=null,Za=!1,Au=null,ds=null,el=!1,hs=null,tl=0,Ro=0,Lu=null,nl=-1,il=0;function Tn(){return(ht&6)!==0?It():nl!==-1?nl:nl=It()}function fs(i){return(i.mode&1)===0?1:(ht&2)!==0&&xn!==0?xn&-xn:DS.transition!==null?(il===0&&(il=Wf()),il):(i=St,i!==0||(i=window.event,i=i===void 0?16:Zf(i.type)),i)}function vi(i,r,c,d){if(50<Ro)throw Ro=0,Lu=null,Error(n(185));Jr(i,c,d),((ht&2)===0||i!==pn)&&(i===pn&&((ht&2)===0&&(Ja|=c),an===4&&ps(i,xn)),Un(i,d),c===1&&ht===0&&(r.mode&1)===0&&(Cr=It()+500,Aa&&as()))}function Un(i,r){var c=i.callbackNode;Db(i,r);var d=ha(i,i===pn?xn:0);if(d===0)c!==null&&Gr(c),i.callbackNode=null,i.callbackPriority=0;else if(r=d&-d,i.callbackPriority!==r){if(c!=null&&Gr(c),r===1)i.tag===0?MS(Zm.bind(null,i)):Bp(Zm.bind(null,i)),PS(function(){(ht&6)===0&&as()}),c=null;else{switch(Kf(d)){case 1:c=Ke;break;case 4:c=Je;break;case 16:c=Qe;break;case 536870912:c=At;break;default:c=Qe}c=ag(c,Jm.bind(null,i))}i.callbackPriority=r,i.callbackNode=c}}function Jm(i,r){if(nl=-1,il=0,(ht&6)!==0)throw Error(n(327));var c=i.callbackNode;if(Er()&&i.callbackNode!==c)return null;var d=ha(i,i===pn?xn:0);if(d===0)return null;if((d&30)!==0||(d&i.expiredLanes)!==0||r)r=sl(i,d);else{r=d;var g=ht;ht|=2;var _=tg();(pn!==i||xn!==r)&&(Ui=null,Cr=It()+500,Fs(i,r));do try{t0();break}catch(q){eg(i,q)}while(!0);Xc(),Qa.current=_,ht=g,en!==null?r=0:(pn=null,xn=0,r=an)}if(r!==0){if(r===2&&(g=hc(i),g!==0&&(d=g,r=Tu(i,g))),r===1)throw c=No,Fs(i,0),ps(i,d),Un(i,It()),c;if(r===6)ps(i,d);else{if(g=i.current.alternate,(d&30)===0&&!ZS(g)&&(r=sl(i,d),r===2&&(_=hc(i),_!==0&&(d=_,r=Tu(i,_))),r===1))throw c=No,Fs(i,0),ps(i,d),Un(i,It()),c;switch(i.finishedWork=g,i.finishedLanes=d,r){case 0:case 1:throw Error(n(345));case 2:Hs(i,Hn,Ui);break;case 3:if(ps(i,d),(d&130023424)===d&&(r=Pu+500-It(),10<r)){if(ha(i,0)!==0)break;if(g=i.suspendedLanes,(g&d)!==d){Tn(),i.pingedLanes|=i.suspendedLanes&g;break}i.timeoutHandle=zc(Hs.bind(null,i,Hn,Ui),r);break}Hs(i,Hn,Ui);break;case 4:if(ps(i,d),(d&4194240)===d)break;for(r=i.eventTimes,g=-1;0<d;){var R=31-Bn(d);_=1<<R,R=r[R],R>g&&(g=R),d&=~_}if(d=g,d=It()-d,d=(120>d?120:480>d?480:1080>d?1080:1920>d?1920:3e3>d?3e3:4320>d?4320:1960*JS(d/1960))-d,10<d){i.timeoutHandle=zc(Hs.bind(null,i,Hn,Ui),d);break}Hs(i,Hn,Ui);break;case 5:Hs(i,Hn,Ui);break;default:throw Error(n(329))}}}return Un(i,It()),i.callbackNode===c?Jm.bind(null,i):null}function Tu(i,r){var c=jo;return i.current.memoizedState.isDehydrated&&(Fs(i,r).flags|=256),i=sl(i,r),i!==2&&(r=Hn,Hn=c,r!==null&&Mu(r)),i}function Mu(i){Hn===null?Hn=i:Hn.push.apply(Hn,i)}function ZS(i){for(var r=i;;){if(r.flags&16384){var c=r.updateQueue;if(c!==null&&(c=c.stores,c!==null))for(var d=0;d<c.length;d++){var g=c[d],_=g.getSnapshot;g=g.value;try{if(!hi(_(),g))return!1}catch{return!1}}}if(c=r.child,r.subtreeFlags&16384&&c!==null)c.return=r,r=c;else{if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function ps(i,r){for(r&=~Ru,r&=~Ja,i.suspendedLanes|=r,i.pingedLanes&=~r,i=i.expirationTimes;0<r;){var c=31-Bn(r),d=1<<c;i[c]=-1,r&=~d}}function Zm(i){if((ht&6)!==0)throw Error(n(327));Er();var r=ha(i,0);if((r&1)===0)return Un(i,It()),null;var c=sl(i,r);if(i.tag!==0&&c===2){var d=hc(i);d!==0&&(r=d,c=Tu(i,d))}if(c===1)throw c=No,Fs(i,0),ps(i,r),Un(i,It()),c;if(c===6)throw Error(n(345));return i.finishedWork=i.current.alternate,i.finishedLanes=r,Hs(i,Hn,Ui),Un(i,It()),null}function Du(i,r){var c=ht;ht|=1;try{return i(r)}finally{ht=c,ht===0&&(Cr=It()+500,Aa&&as())}}function $s(i){hs!==null&&hs.tag===0&&(ht&6)===0&&Er();var r=ht;ht|=1;var c=oi.transition,d=St;try{if(oi.transition=null,St=1,i)return i()}finally{St=d,oi.transition=c,ht=r,(ht&6)===0&&as()}}function Iu(){Xn=kr.current,Tt(kr)}function Fs(i,r){i.finishedWork=null,i.finishedLanes=0;var c=i.timeoutHandle;if(c!==-1&&(i.timeoutHandle=-1,RS(c)),en!==null)for(c=en.return;c!==null;){var d=c;switch(Kc(d),d.tag){case 1:d=d.type.childContextTypes,d!=null&&Ra();break;case 3:br(),Tt(zn),Tt(En),su();break;case 5:nu(d);break;case 4:br();break;case 13:Tt(zt);break;case 19:Tt(zt);break;case 10:Qc(d.type._context);break;case 22:case 23:Iu()}c=c.return}if(pn=i,en=i=ms(i.current,null),xn=Xn=r,an=0,No=null,Ru=Ja=zs=0,Hn=jo=null,Is!==null){for(r=0;r<Is.length;r++)if(c=Is[r],d=c.interleaved,d!==null){c.interleaved=null;var g=d.next,_=c.pending;if(_!==null){var R=_.next;_.next=g,d.next=R}c.pending=d}Is=null}return i}function eg(i,r){do{var c=en;try{if(Xc(),Fa.current=Ka,Ha){for(var d=$t.memoizedState;d!==null;){var g=d.queue;g!==null&&(g.pending=null),d=d.next}Ha=!1}if(Bs=0,fn=on=$t=null,bo=!1,So=0,ju.current=null,c===null||c.return===null){an=1,No=r,en=null;break}e:{var _=i,R=c.return,q=c,J=r;if(r=xn,q.flags|=32768,J!==null&&typeof J=="object"&&typeof J.then=="function"){var ae=J,xe=q,ke=xe.tag;if((xe.mode&1)===0&&(ke===0||ke===11||ke===15)){var be=xe.alternate;be?(xe.updateQueue=be.updateQueue,xe.memoizedState=be.memoizedState,xe.lanes=be.lanes):(xe.updateQueue=null,xe.memoizedState=null)}var Me=Cm(R);if(Me!==null){Me.flags&=-257,Em(Me,R,q,_,r),Me.mode&1&&km(_,ae,r),r=Me,J=ae;var ze=r.updateQueue;if(ze===null){var Fe=new Set;Fe.add(J),r.updateQueue=Fe}else ze.add(J);break e}else{if((r&1)===0){km(_,ae,r),Ou();break e}J=Error(n(426))}}else if(Ot&&q.mode&1){var Yt=Cm(R);if(Yt!==null){(Yt.flags&65536)===0&&(Yt.flags|=256),Em(Yt,R,q,_,r),Yc(Sr(J,q));break e}}_=J=Sr(J,q),an!==4&&(an=2),jo===null?jo=[_]:jo.push(_),_=R;do{switch(_.tag){case 3:_.flags|=65536,r&=-r,_.lanes|=r;var ne=Sm(_,J,r);Gp(_,ne);break e;case 1:q=J;var ee=_.type,re=_.stateNode;if((_.flags&128)===0&&(typeof ee.getDerivedStateFromError=="function"||re!==null&&typeof re.componentDidCatch=="function"&&(ds===null||!ds.has(re)))){_.flags|=65536,r&=-r,_.lanes|=r;var Ee=xm(_,q,r);Gp(_,Ee);break e}}_=_.return}while(_!==null)}ig(c)}catch(He){r=He,en===c&&c!==null&&(en=c=c.return);continue}break}while(!0)}function tg(){var i=Qa.current;return Qa.current=Ka,i===null?Ka:i}function Ou(){(an===0||an===3||an===2)&&(an=4),pn===null||(zs&268435455)===0&&(Ja&268435455)===0||ps(pn,xn)}function sl(i,r){var c=ht;ht|=2;var d=tg();(pn!==i||xn!==r)&&(Ui=null,Fs(i,r));do try{e0();break}catch(g){eg(i,g)}while(!0);if(Xc(),ht=c,Qa.current=d,en!==null)throw Error(n(261));return pn=null,xn=0,an}function e0(){for(;en!==null;)ng(en)}function t0(){for(;en!==null&&!sr();)ng(en)}function ng(i){var r=og(i.alternate,i,Xn);i.memoizedProps=i.pendingProps,r===null?ig(i):en=r,ju.current=null}function ig(i){var r=i;do{var c=r.alternate;if(i=r.return,(r.flags&32768)===0){if(c=VS(c,r,Xn),c!==null){en=c;return}}else{if(c=YS(c,r),c!==null){c.flags&=32767,en=c;return}if(i!==null)i.flags|=32768,i.subtreeFlags=0,i.deletions=null;else{an=6,en=null;return}}if(r=r.sibling,r!==null){en=r;return}en=r=i}while(r!==null);an===0&&(an=5)}function Hs(i,r,c){var d=St,g=oi.transition;try{oi.transition=null,St=1,n0(i,r,c,d)}finally{oi.transition=g,St=d}return null}function n0(i,r,c,d){do Er();while(hs!==null);if((ht&6)!==0)throw Error(n(327));c=i.finishedWork;var g=i.finishedLanes;if(c===null)return null;if(i.finishedWork=null,i.finishedLanes=0,c===i.current)throw Error(n(177));i.callbackNode=null,i.callbackPriority=0;var _=c.lanes|c.childLanes;if(Ib(i,_),i===pn&&(en=pn=null,xn=0),(c.subtreeFlags&2064)===0&&(c.flags&2064)===0||el||(el=!0,ag(Qe,function(){return Er(),null})),_=(c.flags&15990)!==0,(c.subtreeFlags&15990)!==0||_){_=oi.transition,oi.transition=null;var R=St;St=1;var q=ht;ht|=4,ju.current=null,XS(i,c),Vm(c,i),SS(Oc),ma=!!Ic,Oc=Ic=null,i.current=c,QS(c),ca(),ht=q,St=R,oi.transition=_}else i.current=c;if(el&&(el=!1,hs=i,tl=g),_=i.pendingLanes,_===0&&(ds=null),dc(c.stateNode),Un(i,It()),r!==null)for(d=i.onRecoverableError,c=0;c<r.length;c++)g=r[c],d(g.value,{componentStack:g.stack,digest:g.digest});if(Za)throw Za=!1,i=Au,Au=null,i;return(tl&1)!==0&&i.tag!==0&&Er(),_=i.pendingLanes,(_&1)!==0?i===Lu?Ro++:(Ro=0,Lu=i):Ro=0,as(),null}function Er(){if(hs!==null){var i=Kf(tl),r=oi.transition,c=St;try{if(oi.transition=null,St=16>i?16:i,hs===null)var d=!1;else{if(i=hs,hs=null,tl=0,(ht&6)!==0)throw Error(n(331));var g=ht;for(ht|=4,Ie=i.current;Ie!==null;){var _=Ie,R=_.child;if((Ie.flags&16)!==0){var q=_.deletions;if(q!==null){for(var J=0;J<q.length;J++){var ae=q[J];for(Ie=ae;Ie!==null;){var xe=Ie;switch(xe.tag){case 0:case 11:case 15:Eo(8,xe,_)}var ke=xe.child;if(ke!==null)ke.return=xe,Ie=ke;else for(;Ie!==null;){xe=Ie;var be=xe.sibling,Me=xe.return;if(Hm(xe),xe===ae){Ie=null;break}if(be!==null){be.return=Me,Ie=be;break}Ie=Me}}}var ze=_.alternate;if(ze!==null){var Fe=ze.child;if(Fe!==null){ze.child=null;do{var Yt=Fe.sibling;Fe.sibling=null,Fe=Yt}while(Fe!==null)}}Ie=_}}if((_.subtreeFlags&2064)!==0&&R!==null)R.return=_,Ie=R;else e:for(;Ie!==null;){if(_=Ie,(_.flags&2048)!==0)switch(_.tag){case 0:case 11:case 15:Eo(9,_,_.return)}var ne=_.sibling;if(ne!==null){ne.return=_.return,Ie=ne;break e}Ie=_.return}}var ee=i.current;for(Ie=ee;Ie!==null;){R=Ie;var re=R.child;if((R.subtreeFlags&2064)!==0&&re!==null)re.return=R,Ie=re;else e:for(R=ee;Ie!==null;){if(q=Ie,(q.flags&2048)!==0)try{switch(q.tag){case 0:case 11:case 15:Xa(9,q)}}catch(He){Ut(q,q.return,He)}if(q===R){Ie=null;break e}var Ee=q.sibling;if(Ee!==null){Ee.return=q.return,Ie=Ee;break e}Ie=q.return}}if(ht=g,as(),hn&&typeof hn.onPostCommitFiberRoot=="function")try{hn.onPostCommitFiberRoot(Zt,i)}catch{}d=!0}return d}finally{St=c,oi.transition=r}}return!1}function sg(i,r,c){r=Sr(c,r),r=Sm(i,r,1),i=cs(i,r,1),r=Tn(),i!==null&&(Jr(i,1,r),Un(i,r))}function Ut(i,r,c){if(i.tag===3)sg(i,i,c);else for(;r!==null;){if(r.tag===3){sg(r,i,c);break}else if(r.tag===1){var d=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(ds===null||!ds.has(d))){i=Sr(c,i),i=xm(r,i,1),r=cs(r,i,1),i=Tn(),r!==null&&(Jr(r,1,i),Un(r,i));break}}r=r.return}}function i0(i,r,c){var d=i.pingCache;d!==null&&d.delete(r),r=Tn(),i.pingedLanes|=i.suspendedLanes&c,pn===i&&(xn&c)===c&&(an===4||an===3&&(xn&130023424)===xn&&500>It()-Pu?Fs(i,0):Ru|=c),Un(i,r)}function rg(i,r){r===0&&((i.mode&1)===0?r=1:(r=da,da<<=1,(da&130023424)===0&&(da=4194304)));var c=Tn();i=$i(i,r),i!==null&&(Jr(i,r,c),Un(i,c))}function s0(i){var r=i.memoizedState,c=0;r!==null&&(c=r.retryLane),rg(i,c)}function r0(i,r){var c=0;switch(i.tag){case 13:var d=i.stateNode,g=i.memoizedState;g!==null&&(c=g.retryLane);break;case 19:d=i.stateNode;break;default:throw Error(n(314))}d!==null&&d.delete(r),rg(i,c)}var og;og=function(i,r,c){if(i!==null)if(i.memoizedProps!==r.pendingProps||zn.current)Fn=!0;else{if((i.lanes&c)===0&&(r.flags&128)===0)return Fn=!1,qS(i,r,c);Fn=(i.flags&131072)!==0}else Fn=!1,Ot&&(r.flags&1048576)!==0&&zp(r,Ta,r.index);switch(r.lanes=0,r.tag){case 2:var d=r.type;Ya(i,r),i=r.pendingProps;var g=pr(r,En.current);wr(r,c),g=au(null,r,d,i,g,c);var _=lu();return r.flags|=1,typeof g=="object"&&g!==null&&typeof g.render=="function"&&g.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,$n(d)?(_=!0,Pa(r)):_=!1,r.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,eu(r),g.updater=qa,r.stateNode=g,g._reactInternals=r,pu(r,d,i,c),r=_u(null,r,d,!0,_,c)):(r.tag=0,Ot&&_&&Wc(r),Ln(null,r,g,c),r=r.child),r;case 16:d=r.elementType;e:{switch(Ya(i,r),i=r.pendingProps,g=d._init,d=g(d._payload),r.type=d,g=r.tag=a0(d),i=pi(d,i),g){case 0:r=vu(null,r,d,i,c);break e;case 1:r=Lm(null,r,d,i,c);break e;case 11:r=Nm(null,r,d,i,c);break e;case 14:r=jm(null,r,d,pi(d.type,i),c);break e}throw Error(n(306,d,""))}return r;case 0:return d=r.type,g=r.pendingProps,g=r.elementType===d?g:pi(d,g),vu(i,r,d,g,c);case 1:return d=r.type,g=r.pendingProps,g=r.elementType===d?g:pi(d,g),Lm(i,r,d,g,c);case 3:e:{if(Tm(r),i===null)throw Error(n(387));d=r.pendingProps,_=r.memoizedState,g=_.element,Yp(i,r),za(r,d,null,c);var R=r.memoizedState;if(d=R.element,_.isDehydrated)if(_={element:d,isDehydrated:!1,cache:R.cache,pendingSuspenseBoundaries:R.pendingSuspenseBoundaries,transitions:R.transitions},r.updateQueue.baseState=_,r.memoizedState=_,r.flags&256){g=Sr(Error(n(423)),r),r=Mm(i,r,d,c,g);break e}else if(d!==g){g=Sr(Error(n(424)),r),r=Mm(i,r,d,c,g);break e}else for(Gn=ss(r.stateNode.containerInfo.firstChild),Yn=r,Ot=!0,fi=null,c=qp(r,null,d,c),r.child=c;c;)c.flags=c.flags&-3|4096,c=c.sibling;else{if(vr(),d===g){r=Hi(i,r,c);break e}Ln(i,r,d,c)}r=r.child}return r;case 5:return Qp(r),i===null&&Vc(r),d=r.type,g=r.pendingProps,_=i!==null?i.memoizedProps:null,R=g.children,Bc(d,g)?R=null:_!==null&&Bc(d,_)&&(r.flags|=32),Am(i,r),Ln(i,r,R,c),r.child;case 6:return i===null&&Vc(r),null;case 13:return Dm(i,r,c);case 4:return tu(r,r.stateNode.containerInfo),d=r.pendingProps,i===null?r.child=_r(r,null,d,c):Ln(i,r,d,c),r.child;case 11:return d=r.type,g=r.pendingProps,g=r.elementType===d?g:pi(d,g),Nm(i,r,d,g,c);case 7:return Ln(i,r,r.pendingProps,c),r.child;case 8:return Ln(i,r,r.pendingProps.children,c),r.child;case 12:return Ln(i,r,r.pendingProps.children,c),r.child;case 10:e:{if(d=r.type._context,g=r.pendingProps,_=r.memoizedProps,R=g.value,jt(Ia,d._currentValue),d._currentValue=R,_!==null)if(hi(_.value,R)){if(_.children===g.children&&!zn.current){r=Hi(i,r,c);break e}}else for(_=r.child,_!==null&&(_.return=r);_!==null;){var q=_.dependencies;if(q!==null){R=_.child;for(var J=q.firstContext;J!==null;){if(J.context===d){if(_.tag===1){J=Fi(-1,c&-c),J.tag=2;var ae=_.updateQueue;if(ae!==null){ae=ae.shared;var xe=ae.pending;xe===null?J.next=J:(J.next=xe.next,xe.next=J),ae.pending=J}}_.lanes|=c,J=_.alternate,J!==null&&(J.lanes|=c),Jc(_.return,c,r),q.lanes|=c;break}J=J.next}}else if(_.tag===10)R=_.type===r.type?null:_.child;else if(_.tag===18){if(R=_.return,R===null)throw Error(n(341));R.lanes|=c,q=R.alternate,q!==null&&(q.lanes|=c),Jc(R,c,r),R=_.sibling}else R=_.child;if(R!==null)R.return=_;else for(R=_;R!==null;){if(R===r){R=null;break}if(_=R.sibling,_!==null){_.return=R.return,R=_;break}R=R.return}_=R}Ln(i,r,g.children,c),r=r.child}return r;case 9:return g=r.type,d=r.pendingProps.children,wr(r,c),g=si(g),d=d(g),r.flags|=1,Ln(i,r,d,c),r.child;case 14:return d=r.type,g=pi(d,r.pendingProps),g=pi(d.type,g),jm(i,r,d,g,c);case 15:return Rm(i,r,r.type,r.pendingProps,c);case 17:return d=r.type,g=r.pendingProps,g=r.elementType===d?g:pi(d,g),Ya(i,r),r.tag=1,$n(d)?(i=!0,Pa(r)):i=!1,wr(r,c),wm(r,d,g),pu(r,d,g,c),_u(null,r,d,!0,i,c);case 19:return Om(i,r,c);case 22:return Pm(i,r,c)}throw Error(n(156,r.tag))};function ag(i,r){return As(i,r)}function o0(i,r,c,d){this.tag=i,this.key=c,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=d,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ai(i,r,c,d){return new o0(i,r,c,d)}function Bu(i){return i=i.prototype,!(!i||!i.isReactComponent)}function a0(i){if(typeof i=="function")return Bu(i)?1:0;if(i!=null){if(i=i.$$typeof,i===B)return 11;if(i===I)return 14}return 2}function ms(i,r){var c=i.alternate;return c===null?(c=ai(i.tag,r,i.key,i.mode),c.elementType=i.elementType,c.type=i.type,c.stateNode=i.stateNode,c.alternate=i,i.alternate=c):(c.pendingProps=r,c.type=i.type,c.flags=0,c.subtreeFlags=0,c.deletions=null),c.flags=i.flags&14680064,c.childLanes=i.childLanes,c.lanes=i.lanes,c.child=i.child,c.memoizedProps=i.memoizedProps,c.memoizedState=i.memoizedState,c.updateQueue=i.updateQueue,r=i.dependencies,c.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},c.sibling=i.sibling,c.index=i.index,c.ref=i.ref,c}function rl(i,r,c,d,g,_){var R=2;if(d=i,typeof i=="function")Bu(i)&&(R=1);else if(typeof i=="string")R=5;else e:switch(i){case K:return Us(c.children,g,_,r);case Z:R=8,g|=8;break;case G:return i=ai(12,c,r,g|2),i.elementType=G,i.lanes=_,i;case A:return i=ai(13,c,r,g),i.elementType=A,i.lanes=_,i;case z:return i=ai(19,c,r,g),i.elementType=z,i.lanes=_,i;case P:return ol(c,g,_,r);default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case Q:R=10;break e;case F:R=9;break e;case B:R=11;break e;case I:R=14;break e;case D:R=16,d=null;break e}throw Error(n(130,i==null?i:typeof i,""))}return r=ai(R,c,r,g),r.elementType=i,r.type=d,r.lanes=_,r}function Us(i,r,c,d){return i=ai(7,i,d,r),i.lanes=c,i}function ol(i,r,c,d){return i=ai(22,i,d,r),i.elementType=P,i.lanes=c,i.stateNode={isHidden:!1},i}function zu(i,r,c){return i=ai(6,i,null,r),i.lanes=c,i}function $u(i,r,c){return r=ai(4,i.children!==null?i.children:[],i.key,r),r.lanes=c,r.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},r}function l0(i,r,c,d,g){this.tag=r,this.containerInfo=i,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=fc(0),this.expirationTimes=fc(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=fc(0),this.identifierPrefix=d,this.onRecoverableError=g,this.mutableSourceEagerHydrationData=null}function Fu(i,r,c,d,g,_,R,q,J){return i=new l0(i,r,c,q,J),r===1?(r=1,_===!0&&(r|=8)):r=0,_=ai(3,null,null,r),i.current=_,_.stateNode=i,_.memoizedState={element:d,isDehydrated:c,cache:null,transitions:null,pendingSuspenseBoundaries:null},eu(_),i}function c0(i,r,c){var d=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:V,key:d==null?null:""+d,children:i,containerInfo:r,implementation:c}}function lg(i){if(!i)return os;i=i._reactInternals;e:{if(Nt(i)!==i||i.tag!==1)throw Error(n(170));var r=i;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if($n(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(n(171))}if(i.tag===1){var c=i.type;if($n(c))return Ip(i,c,r)}return r}function cg(i,r,c,d,g,_,R,q,J){return i=Fu(c,d,!0,i,g,_,R,q,J),i.context=lg(null),c=i.current,d=Tn(),g=fs(c),_=Fi(d,g),_.callback=r??null,cs(c,_,g),i.current.lanes=g,Jr(i,g,d),Un(i,d),i}function al(i,r,c,d){var g=r.current,_=Tn(),R=fs(g);return c=lg(c),r.context===null?r.context=c:r.pendingContext=c,r=Fi(_,R),r.payload={element:i},d=d===void 0?null:d,d!==null&&(r.callback=d),i=cs(g,r,R),i!==null&&(vi(i,g,R,_),Ba(i,g,R)),R}function ll(i){if(i=i.current,!i.child)return null;switch(i.child.tag){case 5:return i.child.stateNode;default:return i.child.stateNode}}function ug(i,r){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var c=i.retryLane;i.retryLane=c!==0&&c<r?c:r}}function Hu(i,r){ug(i,r),(i=i.alternate)&&ug(i,r)}function u0(){return null}var dg=typeof reportError=="function"?reportError:function(i){console.error(i)};function Uu(i){this._internalRoot=i}cl.prototype.render=Uu.prototype.render=function(i){var r=this._internalRoot;if(r===null)throw Error(n(409));al(i,r,null,null)},cl.prototype.unmount=Uu.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var r=i.containerInfo;$s(function(){al(null,i,null,null)}),r[Ii]=null}};function cl(i){this._internalRoot=i}cl.prototype.unstable_scheduleHydration=function(i){if(i){var r=Yf();i={blockedOn:null,target:i,priority:r};for(var c=0;c<ts.length&&r!==0&&r<ts[c].priority;c++);ts.splice(c,0,i),c===0&&Qf(i)}};function Wu(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function ul(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11&&(i.nodeType!==8||i.nodeValue!==" react-mount-point-unstable "))}function hg(){}function d0(i,r,c,d,g){if(g){if(typeof d=="function"){var _=d;d=function(){var ae=ll(R);_.call(ae)}}var R=cg(r,d,i,0,null,!1,!1,"",hg);return i._reactRootContainer=R,i[Ii]=R.current,fo(i.nodeType===8?i.parentNode:i),$s(),R}for(;g=i.lastChild;)i.removeChild(g);if(typeof d=="function"){var q=d;d=function(){var ae=ll(J);q.call(ae)}}var J=Fu(i,0,!1,null,null,!1,!1,"",hg);return i._reactRootContainer=J,i[Ii]=J.current,fo(i.nodeType===8?i.parentNode:i),$s(function(){al(r,J,c,d)}),J}function dl(i,r,c,d,g){var _=c._reactRootContainer;if(_){var R=_;if(typeof g=="function"){var q=g;g=function(){var J=ll(R);q.call(J)}}al(r,R,i,g)}else R=d0(c,r,i,g,d);return ll(R)}qf=function(i){switch(i.tag){case 3:var r=i.stateNode;if(r.current.memoizedState.isDehydrated){var c=Qr(r.pendingLanes);c!==0&&(pc(r,c|1),Un(r,It()),(ht&6)===0&&(Cr=It()+500,as()))}break;case 13:$s(function(){var d=$i(i,1);if(d!==null){var g=Tn();vi(d,i,1,g)}}),Hu(i,1)}},mc=function(i){if(i.tag===13){var r=$i(i,134217728);if(r!==null){var c=Tn();vi(r,i,134217728,c)}Hu(i,134217728)}},Vf=function(i){if(i.tag===13){var r=fs(i),c=$i(i,r);if(c!==null){var d=Tn();vi(c,i,r,d)}Hu(i,r)}},Yf=function(){return St},Gf=function(i,r){var c=St;try{return St=i,r()}finally{St=c}},W=function(i,r,c){switch(r){case"input":if(dt(i,c),r=c.name,c.type==="radio"&&r!=null){for(c=i;c.parentNode;)c=c.parentNode;for(c=c.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<c.length;r++){var d=c[r];if(d!==i&&d.form===i.form){var g=ja(d);if(!g)throw Error(n(90));rt(d),dt(d,g)}}}break;case"textarea":Pt(i,c);break;case"select":r=c.value,r!=null&&mt(i,!!c.multiple,r,!1)}},Ce=Du,Ge=$s;var h0={usingClientEntryPoint:!1,Events:[go,hr,ja,Be,me,Du]},Po={findFiberByHostInstance:Ls,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},f0={bundleType:Po.bundleType,version:Po.version,rendererPackageName:Po.rendererPackageName,rendererConfig:Po.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:O.ReactCurrentDispatcher,findHostInstanceByFiber:function(i){return i=Ps(i),i===null?null:i.stateNode},findFiberByHostInstance:Po.findFiberByHostInstance||u0,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 hl=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!hl.isDisabled&&hl.supportsFiber)try{Zt=hl.inject(f0),hn=hl}catch{}}return Wn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=h0,Wn.createPortal=function(i,r){var c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Wu(r))throw Error(n(200));return c0(i,r,null,c)},Wn.createRoot=function(i,r){if(!Wu(i))throw Error(n(299));var c=!1,d="",g=dg;return r!=null&&(r.unstable_strictMode===!0&&(c=!0),r.identifierPrefix!==void 0&&(d=r.identifierPrefix),r.onRecoverableError!==void 0&&(g=r.onRecoverableError)),r=Fu(i,1,!1,null,null,c,!1,d,g),i[Ii]=r.current,fo(i.nodeType===8?i.parentNode:i),new Uu(r)},Wn.findDOMNode=function(i){if(i==null)return null;if(i.nodeType===1)return i;var r=i._reactInternals;if(r===void 0)throw typeof i.render=="function"?Error(n(188)):(i=Object.keys(i).join(","),Error(n(268,i)));return i=Ps(r),i=i===null?null:i.stateNode,i},Wn.flushSync=function(i){return $s(i)},Wn.hydrate=function(i,r,c){if(!ul(r))throw Error(n(200));return dl(null,i,r,!0,c)},Wn.hydrateRoot=function(i,r,c){if(!Wu(i))throw Error(n(405));var d=c!=null&&c.hydratedSources||null,g=!1,_="",R=dg;if(c!=null&&(c.unstable_strictMode===!0&&(g=!0),c.identifierPrefix!==void 0&&(_=c.identifierPrefix),c.onRecoverableError!==void 0&&(R=c.onRecoverableError)),r=cg(r,null,i,1,c??null,g,!1,_,R),i[Ii]=r.current,fo(i),d)for(i=0;i<d.length;i++)c=d[i],g=c._getVersion,g=g(c._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[c,g]:r.mutableSourceEagerHydrationData.push(c,g);return new cl(r)},Wn.render=function(i,r,c){if(!ul(r))throw Error(n(200));return dl(null,i,r,!1,c)},Wn.unmountComponentAtNode=function(i){if(!ul(i))throw Error(n(40));return i._reactRootContainer?($s(function(){dl(null,null,i,!1,function(){i._reactRootContainer=null,i[Ii]=null})}),!0):!1},Wn.unstable_batchedUpdates=Du,Wn.unstable_renderSubtreeIntoContainer=function(i,r,c,d){if(!ul(c))throw Error(n(200));if(i==null||i._reactInternals===void 0)throw Error(n(38));return dl(i,r,c,!1,d)},Wn.version="18.3.1-next-f1338f8080-20240426",Wn}var wg;function S0(){if(wg)return Vu.exports;wg=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Vu.exports=b0(),Vu.exports}var bg;function x0(){if(bg)return fl;bg=1;var e=S0();return fl.createRoot=e.createRoot,fl.hydrateRoot=e.hydrateRoot,fl}var k0=x0();const C0=Gh(k0);function Kt(e,t,n={}){return fetch(e,{...n,headers:{...n.headers||{},Authorization:`Bearer ${t}`}})}const ey=e=>`nc_seen_${e}`;async function Le(e,t,n={}){const s=await Kt(e,t,{method:n.method||"GET",headers:{"content-type":"application/json"},body:n.body?JSON.stringify(n.body):void 0}),o=await s.json().catch(()=>({}));if(!s.ok){const a=new Error(o.error||`HTTP ${s.status}`);throw a.status=s.status,a.data=o,a}return o}const sn=e=>Array.isArray(e)&&e.length?`/api/route/${e.map(encodeURIComponent).join("/")}/_`:"/api",Xt=(e,t)=>`${sn(e)}/fleet/${t}`;async function E0(e,t,n,{signal:s}={}){const o=await Kt(`${sn(t)}/panel/${encodeURIComponent(n)}/ticket`,e,{method:"POST",signal:s}),a=await o.json().catch(()=>({}));return o.status===200&&a&&typeof a.ticket=="string"?{ok:!0,ticket:a.ticket}:o.status===403&&a&&a.reason==="panel-not-granted"?{ok:!1,cause:"not-granted"}:o.status===404?{ok:!1,cause:"no-panel"}:o.status===401?{ok:!1,cause:"unauthorized"}:{ok:!1,cause:"denied"}}const Rs=(e,t)=>Le(Xt(t,"status"),e),Qh=(e,t,n)=>Le(Xt(n,"up"),e,{method:"POST",body:t}),Il=(e,t,n)=>Le(Xt(n,"down"),e,{method:"POST",body:t}),ty=(e,t,n)=>Le(Xt(n,"boot"),e,{method:"POST",body:t}),Fo=(e,t,n)=>Le(Xt(n,"restart"),e,{method:"POST",body:{cell:t}}),Jl=(e,t)=>Le(Xt(t,"definitions"),e),N0=(e,t)=>Le(Xt(t,"credentials/status"),e),Sg=(e,t,n,s)=>Le(Xt(s,"credentials/set"),e,{method:"POST",body:{envKey:t,value:n}}),j0=(e,t,n)=>Le(Xt(n,"credentials/remove"),e,{method:"POST",body:{envKey:t}}),R0=(e,t,n)=>Le(Xt(n,"define-engine"),e,{method:"POST",body:{def:t}}),P0=(e,t,n,s,o)=>Le(Xt(o,"edit-engine"),e,{method:"POST",body:{id:t,patch:n,envChanges:s}}),A0=(e,t,n)=>Le(Xt(n,"remove-engine"),e,{method:"POST",body:{id:t}}),L0=(e,t,n)=>Le(Xt(n,"define-model"),e,{method:"POST",body:{def:t}}),T0=(e,t,n,s)=>Le(Xt(s,"remove-model"),e,{method:"POST",body:{id:t,engine:n}}),M0=(e,t,n,s)=>Le(Xt(s,"model-test"),e,{method:"POST",body:{engine:t,model:n}}),D0=(e,t,n)=>Le(Xt(n,"define-cell"),e,{method:"POST",body:{def:t}}),ny=(e,t,n,s)=>Le(Xt(s,"edit-cell"),e,{method:"POST",body:{id:t,patch:n}}),iy=(e,t,n=!1,s)=>Le(Xt(s,"remove-cell"),e,{method:"POST",body:{id:t,stop:n}}),I0=(e,t,n)=>Le(Xt(n,"import-cell"),e,{method:"POST",body:t}),O0=(e,t,n)=>Le(Xt(n,"restore-cells"),e,{method:"POST",body:{cells:t}}),B0=(e,t,n,s,o)=>Le(Xt(s,"restore-engines"),e,{method:"POST",body:{engines:t,overwrite:!!n,...Array.isArray(o)&&o.length?{models:o}:{}}}),Jh=(e,t,n)=>Le(`${sn(n)}/sessions/${encodeURIComponent(t)}`,e,{method:"DELETE"}),sy=(e,t,n,s)=>Le(`${sn(s)}/sessions/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{technical:!!n}}),Zh=(e,t,n)=>Le(`${sn(n)}/fs/dirs${t?`?path=${encodeURIComponent(t)}`:""}`,e),ry=e=>Le("/api/settings",e),z0=e=>Le("/api/nodes",e),$0=e=>Le("/api/peers",e),oy=(e,t=[])=>Le(`${sn(t)}/vl-nodes`,e),xg=(e,t,n,s={},o=[])=>Le(`${sn(o)}/vl-nodes/${encodeURIComponent(t)}/commands`,e,{method:"POST",body:{kind:n,args:s}}),F0=(e,t,n=0,s=[])=>Le(`${sn(s)}/vl-nodes/${encodeURIComponent(t)}/events${n?`?after=${encodeURIComponent(n)}`:""}`,e),ay=e=>Le("/api/topology",e),ef=(e,t)=>Le(`${sn(t)}/sessions`,e),tf=(e,t)=>Le(`${sn(t)}/config`,e),kg=(e,t)=>Le(`${sn(t)}/topology`,e),qd=(e,t)=>Le("/api/settings/config",e,{method:"POST",body:t}),H0=e=>Le("/api/settings/token/rotate",e,{method:"POST"}),U0=(e,t)=>Le("/api/settings/nodes/pair",e,{method:"POST",body:t}),W0=(e,t,n=[])=>Le(`${sn(n)}/settings/peering/invite`,e,{method:"POST",body:t||{}}),ly=(e,t,n)=>Le(`/api/settings/nodes/${encodeURIComponent(t)}/label`,e,{method:"PATCH",body:{label:n}}),K0=e=>Le("/api/settings/node-aliases",e),q0=(e,t,n)=>Le(`/api/settings/node-aliases/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{alias:n}}),Cg=(e,t)=>Le(`/api/settings/node-aliases/${encodeURIComponent(t)}`,e,{method:"DELETE"}),Eg=(e,t,n)=>Le(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"PATCH",body:n}),V0=(e,t)=>Le(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"DELETE"}),nf=(e,t,n)=>Le(`/api/settings/nodes/${encodeURIComponent(t)}/${n}`,e,{method:"POST"}),Y0=(e,t,n)=>Le(`/api/settings/nodes/${encodeURIComponent(t)}/share`,e,{method:"PATCH",body:{shared:n}}),G0=(e,t,n,s=[])=>Le(`/api/settings/nodes/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{visibility:n,selected:s}}),X0=e=>Le("/api/settings/audio",e),Q0=(e,t)=>Le("/api/settings/audio/consent",e,{method:"PATCH",body:{consent:t}}),J0=e=>Le("/api/settings/audio/test",e,{method:"POST",body:{}}),Z0=e=>Le("/api/settings/audio/stop",e,{method:"POST",body:{}}),ex=e=>Le("/api/settings/audio/groups",e),tx=(e,t,n)=>Le(`/api/settings/audio/groups/${encodeURIComponent(t)}`,e,{method:"PUT",body:n}),nx=(e,t)=>Le(`/api/settings/audio/groups/${encodeURIComponent(t)}`,e,{method:"DELETE"}),ix=e=>Le("/api/settings/service/regenerate",e,{method:"POST"}),sx=e=>Le("/api/settings/update/check",e,{method:"POST"}),rx=e=>Le("/api/settings/update/apply",e,{method:"POST"}),Zl=(e,t)=>`${sn(e)}/diagnostics/${t}`,ox=(e,t=[])=>Le(Zl(t,"status"),e),ax=(e,{after:t=0,limit:n=200}={},s=[])=>Le(`${Zl(s,"logs")}?after=${encodeURIComponent(t)}&limit=${encodeURIComponent(n)}`,e),Ng=(e,t,n,s=[])=>Le(Zl(s,"verbose"),e,{method:"PATCH",body:{enabled:t,durationSeconds:n}}),lx=(e,t=[])=>Le(Zl(t,"logs"),e,{method:"DELETE"}),cx=(e,t=!0)=>Le(`/api/asks${t?"?open=1":""}`,e),ux=(e,t,n)=>Le(`/api/asks/${encodeURIComponent(t)}/answer`,e,{method:"POST",body:{text:n}}),dx=(e,t)=>Le(`/api/asks/${encodeURIComponent(t)}`,e,{method:"DELETE"}),pl=(e,t=[])=>Le(`${sn(t)}/decks`,e),jg=(e,t,n=[])=>Le(`${sn(n)}/decks`,e,{method:"POST",body:{name:t}}),ml=(e,t,n,s,o=[])=>Le(`${sn(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PUT",body:{layout:n,expectedRevision:s}}),hx=(e,t,n,s,o=[])=>Le(`${sn(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{name:n,expectedRevision:s}}),fx=(e,t,n,s=[])=>Le(`${sn(s)}/decks/${encodeURIComponent(t)}`,e,{method:"DELETE",body:{expectedRevision:n}}),px=e=>Le("/api/live-host",e),mx=(e,t,n)=>Le("/api/live-host/designate",e,{method:"POST",body:{cellId:t,expectedRevision:n}}),gx=(e,t)=>Le("/api/live-host/clear",e,{method:"POST",body:{expectedRevision:t}}),vx={power:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M12 3v8"}),l.jsx("path",{d:"M6.6 6.6a8 8 0 1 0 10.8 0"})]}),folder:l.jsx("path",{d:"M4 6a2 2 0 0 1 2-2h3.6a2 2 0 0 1 1.4.6L12.4 6H18a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z"}),keyboard:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"3",y:"6",width:"18",height:"12",rx:"2"}),l.jsx("path",{d:"M7 10h.01M11 10h.01M15 10h.01M17 14h.01M7 14h7"})]}),mic:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),l.jsx("path",{d:"M5 11a7 7 0 0 0 14 0"}),l.jsx("path",{d:"M12 18v3"})]}),enter:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M20 5v6a2 2 0 0 1-2 2H5"}),l.jsx("polyline",{points:"9 9 5 13 9 17"})]}),send:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M22 2 15 22 11 13 2 9Z"}),l.jsx("path",{d:"M22 2 11 13"})]}),trash:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M4 7h16"}),l.jsx("path",{d:"M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"}),l.jsx("path",{d:"M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"}),l.jsx("path",{d:"M10 11v6M14 11v6"})]}),x:l.jsx("path",{d:"M6 6l12 12M18 6 6 18"}),monitor:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"3",y:"4",width:"18",height:"12",rx:"2"}),l.jsx("path",{d:"M8 20h8M12 16v4"})]}),refresh:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M21 12a9 9 0 1 1-2.64-6.36L21 8"}),l.jsx("polyline",{points:"21 3 21 8 16 8"})]}),boot:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"3",y:"4",width:"18",height:"13",rx:"2"}),l.jsx("path",{d:"M8 21h8M12 17v4M12 12V7"}),l.jsx("polyline",{points:"9 10 12 7 15 10"})]}),upload:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M12 16V5"}),l.jsx("polyline",{points:"8 9 12 5 16 9"}),l.jsx("path",{d:"M5 20h14"})]}),chevronLeft:l.jsx("polyline",{points:"14 6 8 12 14 18"}),chevronUp:l.jsx("polyline",{points:"6 14 12 8 18 14"}),chevronDown:l.jsx("polyline",{points:"6 10 12 16 18 10"}),history:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M3 12a9 9 0 1 0 3-6.7L3 8"}),l.jsx("polyline",{points:"3 3 3 8 8 8"}),l.jsx("path",{d:"M12 7v5l3 2"})]}),attach:l.jsx("path",{d:"M21.44 11.05 12.25 20.24a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"}),file:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),l.jsx("polyline",{points:"14 2 14 8 20 8"})]}),camera:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M14.5 4h-5L7.5 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3.5z"}),l.jsx("circle",{cx:"12",cy:"13",r:"3.5"})]}),image:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),l.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),l.jsx("path",{d:"M21 15l-5-5L5 21"})]}),zoomIn:l.jsxs(l.Fragment,{children:[l.jsx("circle",{cx:"11",cy:"11",r:"7"}),l.jsx("path",{d:"M21 21l-4.35-4.35"}),l.jsx("path",{d:"M8 11h6M11 8v6"})]}),zoomOut:l.jsxs(l.Fragment,{children:[l.jsx("circle",{cx:"11",cy:"11",r:"7"}),l.jsx("path",{d:"M21 21l-4.35-4.35"}),l.jsx("path",{d:"M8 11h6"})]}),gear:l.jsxs(l.Fragment,{children:[l.jsx("circle",{cx:"12",cy:"12",r:"3"}),l.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),copy:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),l.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})};function nt({name:e,size:t=20}){return l.jsx("svg",{className:"nc-icon",width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:vx[e]||null})}const _x=["all","pinned","active","off","technical"],cy="nc_sidebar_views_v1",uy="nc_sidebar_order_v1";function dy(e){return _x.includes(e)?e:"all"}function yx(e,t=[],n="all"){const s=dy(n);return s==="technical"?e.technical===!0:e.technical===!0?!1:s==="pinned"?t.includes(e.key):s==="active"?!!e.live:s==="off"?!e.live:!0}function wx(e,t,n=[],s=[]){const o=n.indexOf(e.key),a=n.indexOf(t.key),u=o===-1?Number.MAX_SAFE_INTEGER:o,h=a===-1?Number.MAX_SAFE_INTEGER:a,p=s.indexOf(e.key),m=s.indexOf(t.key),v=p===-1?Number.MAX_SAFE_INTEGER:p,y=m===-1?Number.MAX_SAFE_INTEGER:m;return u-h||v-y||+!!t.live-+!!e.live||+!!t.fresh-+!!e.fresh||Number(t.activity||0)-Number(e.activity||0)||String(e.label||"").localeCompare(String(t.label||""))||String(e.key||"").localeCompare(String(t.key||""))}function bx(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(uy));if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[s,o]of Object.entries(t).slice(0,64)){if(typeof s!="string"||!s||s.length>160||!Array.isArray(o))continue;const a=[...new Set(o.filter(u=>typeof u=="string"&&u&&u.length<=256))].slice(0,128);a.length&&(n[s]=a)}return n}catch{return{}}}function Yi(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function Sx(e,t=globalThis.localStorage){try{t.setItem(uy,JSON.stringify(e))}catch{}return e}function xx(e,t,n,s,o=[]){if(typeof t!="string"||!t||n===s)return e;const a=[...new Set(o.filter(w=>typeof w=="string"&&w))];if(!a.includes(n)||!a.includes(s))return e;const u=Yi(e,t).filter(w=>a.includes(w)),h=[...u,...a.filter(w=>!u.includes(w))],p=h.indexOf(n),m=h.indexOf(s);h.splice(p,1);const v=h.indexOf(s),y=p<m?v+1:v;return h.splice(y,0,n),{...e,[t]:h}}function kx(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(cy));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function Rg(e,t){var n,s;return{open:((n=e==null?void 0:e[t])==null?void 0:n.open)!==!1,filter:dy((s=e==null?void 0:e[t])==null?void 0:s.filter)}}function Cx(e,t=globalThis.localStorage){try{t.setItem(cy,JSON.stringify(e))}catch{}return e}function Pg(e,t=""){const n=String(t||"").trim().toLocaleLowerCase();return n?[e.label,e.key,e.searchText].filter(Boolean).join(" ").toLocaleLowerCase().includes(n):!0}function Cs(e=[],t=[],n="all",s=[]){return[...e].filter(o=>yx(o,t,n)).sort((o,a)=>wx(o,a,t,s))}const sf=["it","en","es"];function Ex(){try{const e=typeof navigator<"u"&&navigator.language||"",t=String(e).slice(0,2).toLowerCase();return sf.includes(t)?t:"en"}catch{return"en"}}const jl=Ex(),hy="nc_lang",Vd="nc-lang";function fy(){return typeof localStorage<"u"?localStorage:null}const gl={it:{"update-available":"nuova versione {v} disponibile","install-version-mismatch":"installazione incompleta: frontend e server non coincidono (v{v})",reload:"ricarica","grid-empty":"trascina qui una sessione dalla sidebar, o doppio-clic per la vista singola","grid-full":"il deck può mostrare al massimo 9 sessioni",pin:"fissa in cima",reorder:"riordina","host-lease-live":"host live: supervisione attiva","host-lease-grace":"host live: supervisione in recupero (grace)","host-lease-expired":"host live: supervisione scaduta","host-lease-none":"host live: mai supervisionata","host-lease-unavailable":"host live: garanzia di supervisione non disponibile su questo nodo","reorder-help":"trascina la maniglia; frecce su/giu da tastiera","rename-node":"rinomina nodo","rename-node-prompt":"Nuovo nome del nodo in NexusCrew","rename-node-invalid":"Nome non valido: massimo 64 caratteri, senza a capo.","reorder-deck-help":"trascina il deck; frecce sinistra/destra da tastiera",sessions:"sessioni","new-session":"nuova sessione",new:"nuova",fleet:"Flotta","fleet-tmux":"flotta tmux","other-sessions":"Altre sessioni","view-all":"tutte","view-pinned":"fissate","view-active":"attive","view-off":"spente","view-technical":"tecniche","mark-technical":"nascondi come sessione tecnica","mark-normal":"mostra come sessione normale","position-local":"Locale",files:"file",refresh:"aggiorna","filter-placeholder":"filtra sessioni…","loading-fleet":"carico la flotta…","no-sessions":"nessuna sessione tmux viva — la flotta parte al boot (systemd)","no-match":'nessuna sessione contiene "{q}"',"copy-url":"clicca per copiare l'URL","ssh-only":"solo tunnel SSH/VPN","new-files-outbox":"nuovi file in outbox",terminate:"termina","terminate-confirm":'Terminare la sessione "{name}"?',"cell-on":"tmux vivo","cell-off":"spenta","cell-working":"al lavoro","cell-idle":"in attesa","cell-degraded":"degradata: unit attiva, tmux morto","power-on":"accendi","power-off":"spegni","boot-enable":"attiva al boot","boot-disable":"disattiva al boot","state-on":"accesa","state-off":"spenta",engine:"Engine",model:"Modello","model-default":"Modello predefinito del provider","model-remembered":"Ultimo modello usato con questo engine","boot-persist":"avvia al boot","remove-boot":"togli anche dal boot","power-config-in-settings":"Engine, provider, profilo, modello e permessi si modificano in Impostazioni → Flotta.","no-remote-control":"⚠ engine non-native: niente RC da app claude.ai (da qui la piloti comunque)",cancel:"annulla",name:"nome","name-invalid":"nome non valido: a-zA-Z0-9._- max 64, senza '-' iniziale",cwd:"cartella",browse:"sfoglia","fs-home":"home","fs-parent":".. su",preset:"preset","preset-2x2":"griglia 2×2","preset-columns":"colonne","preset-equalize":"equalizza",collapse:"comprimi",expand:"espandi",create:"crea","auth-prompt":"Incolla il token (stampato dal server):","remember-device":"ricorda su questo device","zoom-out":"testo più piccolo","zoom-in":"testo più grande",composer:"composer",panel:"pannello","panel-none":"Nessun pannello configurato per questa cella.","panel-checking":"Apertura del pannello…","panel-not-granted":"Questo nodo non concede il pannello a chi lo chiede: l'accesso va concesso sul nodo che possiede la cella, non riprovando qui.","panel-denied":"Ingresso al pannello rifiutato: il biglietto non è più valido. Riprova: verrà chiesto un biglietto nuovo.","panel-unreachable":"Il pannello non è raggiungibile attraverso questo nodo: riprova tra poco.","panel-timeout":"Il pannello non ha risposto in tempo: servizio lento a partire o sovraccarico. Riprova tra poco.","panel-retry":"Riprova",windows:"{n} finestre","empty-files":"vuota",upload:"carica","no-sessions-short":"nessuna sessione","composer-placeholder":"scrivi o detta…","composer-history-tools":"cronologia e dimensione input","composer-history":"cronologia della cella","composer-history-empty":"nessun input inviato","composer-history-clear":"cancella cronologia di questa cella","composer-expand":"espandi input","composer-collapse":"riduci input","composer-clear-data":"cancella bozze e cronologia","composer-clear-data-help":"Rimuove da questo browser tutte le bozze e la cronologia input delle celle.","composer-clear-confirm":"Cancellare tutte le bozze e la cronologia input salvate in questo browser?","composer-clear-done":"Bozze e cronologia cancellate.","composer-clear-failed":"Impossibile cancellare i dati del composer in questo browser.",attach:"allega","attach-file":"File","attach-camera":"Fotocamera","attach-gallery":"Galleria","attach-uploading":"carico…","attach-upload-progress":"allegato {n}/{total}…","attach-uploaded":"{n} allegati caricati",voice:"voice",send:"invia","composer-send-failed":"connessione non pronta — testo conservato, riprova",close:"chiudi","lang-label":"lingua",decks:"deck","new-deck":"nuovo deck","deck-name":"nome deck","open-deck-window":"apri in una nuova finestra","detach-deck":"stacca in una nuova finestra","deck-current":"questo deck (finestra corrente)","deck-owner-unavailable":"nodo owner non condiviso o non raggiungibile","rename-deck":"rinomina deck","delete-deck":"elimina deck","delete-deck-confirm":'Eliminare il deck "{name}"?',"send-to-deck":"manda al deck…","deck-autosave":"salvataggio automatico",saving:"salvataggio…",saved:"salvato","popup-blocked":"popup bloccato: apri qui","expand-owner":"espandi i deck di {owner}","collapse-owner":"comprimi i deck di {owner}","owner-deck-count-one":"{count} deck","owner-deck-count-many":"{count} deck","dot-working":"in uso (finestra attiva)","dot-on":"aperta in background","dot-neutral":"non aperta","dot-warn":"nodo offline","select-drag":"trascina per selezionare","copy-manual":"seleziona e copia manualmente","toggle-sidebar":"mostra/nascondi la barra laterale",settings:"impostazioni","tab-roles":"ruoli","tab-nodes":"nodi",local:"Locale",location:"Dove","pairing-link":"link di pairing","pairing-required":"nome, alias SSH e link di pairing sono obbligatori","pairing-connect-help":"Per collegare un nodo servono: nome, Host SSH già funzionante e link/QR creato sull’altra installazione NexusCrew.","pairing-localhost-hint":"127.0.0.1 nel link è corretto: non aprirlo qui. NexusCrew usa invito e porta attraverso l’Host SSH.","scan-qr":"scansiona QR","pairing-qr-invalid":"QR di pairing non valido","invite-node":"invita un nodo","create-pairing-link":"crea link / QR","visibility-network":"tutta la rete","visibility-relay":"solo relay","visibility-selected":"nodi selezionati","hydra-simple":"locale + nodi, una sola rete","local-ready":"Questo dispositivo è pronto. Puoi usarlo da solo o collegarlo a un nodo.","local-only":"solo locale","add-node":"aggiungi nodo",connect:"collega","node-connected":"Nodo collegato. La rete verrà sincronizzata automaticamente.","tab-system":"sistema","tab-fleet":"flotta","tab-audio":"audio","system-general":"generale","system-diagnostics":"diagnostica","system-this-node":"questo nodo","system-updates":"aggiornamenti","system-security":"sicurezza","system-local-data":"dati locali del browser","system-terminal":"terminale","alternate-screen":"schermo alternato","alternate-screen-help":"Mantiene il comportamento tmux standard per le nuove sessioni NexusCrew. Un’applicazione che segue il mouse scorre da sé; le altre fanno scorrere la storia di tmux. Non modifica le celle già attive.","tab-input":"input","tab-diagnostics":"diagnostica","input-settings-local":"Preferenze locali di questo browser. Si applicano subito a vista singola e deck, senza modificare il nodo remoto.","terminal-keyboard-gesture":"Apertura tastiera virtuale dal terminale","terminal-keyboard-double-tap":"Doppio tap (predefinito)","terminal-keyboard-single-tap":"Tap singolo","terminal-keyboard-never":"Mai dal terminale","terminal-keyboard-gesture-help":"Il tastierino e STT seguono i controlli separati sotto. Mouse e tastiera fisica restano utilizzabili.","keybar-ime-lock":"Tastierino: mantieni chiusa la tastiera virtuale","keybar-ime-lock-help":"ESC, frecce, PgUp/PgDn, Enter e menu inviano direttamente al PTY senza dare focus a un campo di testo.","voice-ime-lock":"Microfono STT: mantieni chiusa la tastiera virtuale","voice-ime-lock-help":"Il tap sul microfono avvia o ferma la voce senza focalizzare il composer.","keybar-enter-show":"Mostra Enter verticale nel tastierino","keybar-enter-show-help":"Enter resta a destra di PgUp/PgDn ed è alto quanto entrambe le righe.","keybar-layout":"Layout tastierino","keybar-layout-full":"Esteso (predefinito)","keybar-layout-compact":"Compatto","keybar-layout-help":"Compatto: una riga con expand ⊞ per accedere al set completo senza cambiare la preferenza.","input-settings-reset":"ripristina predefiniti input","diagnostics-local":"Questo nodo","diagnostics-target":"Nodo da diagnosticare","diagnostics-verbose":"Log verbosi temporanei","diagnostics-duration":"Durata verbose","diagnostics-expires":"Verbose attivo fino alle {time}","diagnostics-off":"Verbose spento; warning ed errori operativi restano disponibili.","diagnostics-level":"Livello","diagnostics-all-levels":"tutti i livelli","diagnostics-component":"componente","diagnostics-pause":"pausa","diagnostics-autoscroll":"scorrimento automatico","diagnostics-log":"Log diagnostico sanitizzato","diagnostics-empty":"Nessun evento diagnostico.","diagnostics-export":"esporta JSON","diagnostics-export-failed":"Esportazione non disponibile in questo browser.","diagnostics-clear":"svuota","diagnostics-clear-confirm":"Svuotare il buffer diagnostico di questo nodo?","diagnostics-unsupported":"Questo peer è offline o non supporta la diagnostica strutturata.","fleet-editor-loading":"Caricamento dell'editor Fleet…","fleet-editor-load-error":"Impossibile caricare l'editor Fleet.","fleet-editor-unavailable":"Editor Fleet non disponibile in questa posizione.","fleet-managed":"gestito da NexusCrew","fleet-custom":"comando personalizzato","fleet-managed-help":"Client, provider e avvio sono gestiti internamente; i segreti non vengono mostrati.","fleet-shell-engine-help":"Shell locale risolta sul dispositivo al momento dell’avvio; nessun percorso viene salvato nel backup.","fleet-shell-command-placeholder":"comando opzionale, es. npm test","fleet-shell-command-help":"Esecuzione tramite shell login interattiva (-lic), con PATH e alias utente. La cella si ferma quando il comando termina; gli errori immediati vengono segnalati.","fleet-shell-command-metachar":"Pipe, redirect, variabili e altri metacaratteri vengono interpretati dalla shell del dispositivo.","fleet-shell-interactive":"Vuoto: apre una shell interattiva locale e mantiene la cella attiva.","fleet-shell-launch-help":"Il comando Shell si configura nella cella da Impostazioni → Flotta.","fleet-credential-title":"API key su questo dispositivo","fleet-credential-help":"La key resta solo sul nodo selezionato e non viene mai mostrata né esportata. Se il nodo è remoto, il valore viaggia fino a lui sul canale accoppiato.","fleet-credential-set":"imposta key","fleet-credential-change":"cambia key","fleet-credential-forget":"dimentica","fleet-credential-saved":"Key salvata localmente.","fleet-credential-removed":"Key locale rimossa.","fleet-credential-remove-confirm":"Rimuovere la key locale {key}?","fleet-credential-source-environment":"ambiente","fleet-credential-source-local":"store locale","fleet-credential-source-compatibility":"config compatibile","fleet-credential-source-missing":"mancante","fleet-credential-source-nexuscrew-store":"store NexusCrew","fleet-credential-source-unreadable":"non verificabile","fleet-credential-source-login":"login del client","fleet-credential-source-none":"nessuna","fleet-credential-source-policy":"origine credenziale","fleet-credential-source-policy-auto":"auto (precedenza legacy)","fleet-credential-source-policy-nexuscrew-store":"solo store NexusCrew","fleet-credential-source-policy-environment":"solo ambiente","fleet-key-section":"KEY","fleet-key-variable":"Variabile","fleet-key-value":"Valore per {key}","fleet-key-used-by":"Usata da: {engines}","fleet-key-used-by-none":"Non ancora usata da engine configurati su questo nodo.","fleet-key-shared-impact":"Sostituire o rimuovere {key} interessa tutti gli engine elencati: {engines}.","fleet-key-enter":"inserisci la key","fleet-key-blank-keeps":"vuoto = mantieni la fonte attuale","fleet-key-reveal":"mostra","fleet-key-hide":"nascondi","fleet-key-local-help":"Il valore resta write-only sul nodo selezionato: non viene mai riletto dalla rete e non entra in engine o backup. Se il nodo selezionato è remoto, il valore lo raggiunge attraverso il canale accoppiato.","fleet-key-create-missing":"Crea esplicitamente l’engine senza key (resterà “key richiesta”).","fleet-key-partial-create":"Engine creato; la key non è stata salvata. Puoi riprovare senza creare duplicati.","fleet-key-partial-edit":"Engine aggiornato; la key non è stata salvata. Le modifiche all’engine restano applicate.","fleet-provider-notice-claude-openrouter":"Claude Code è ottimizzato per modelli Anthropic: altri provider potrebbero non funzionare correttamente. Fast mode richiede il provider Anthropic first-party.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses è beta e stateless; Codex-VL non usa fallback Chat Completions.","fleet-provider-notice-claude-kimi-code":"Kimi Code usa una configurazione Claude isolata con onboarding e fast mode dedicati; la configurazione Claude nativa non viene modificata, ma i suoi strumenti MCP vengono ereditati.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal usa solo ALIBABA_CODE_API_KEY dal credential layer locale; qwen3.8-max è il modello predefinito e non viene usato alcun fallback OpenAI/PAYG.","fleet-provider-notice-kimi-native":'Kimi Code CLI nativo usa il login del CLI (device-code) e la propria configurazione: NexusCrew non legge né copia credenziali. Distinto dal provider "Kimi Code" di Claude Code, che resta il percorso K3 gestito.',"fleet-model-default":"modello predefinito (opzionale)","fleet-model-required":"modello (obbligatorio)","fleet-standard-permissions":"permessi standard","fleet-unsafe-permissions":"non sicuro · ignora approvazioni/sandbox","fleet-unsafe-warning":"Modalità non sicura esplicita: il worker può agire senza le normali approvazioni o protezioni sandbox.","fleet-provider-display":"nome visualizzato del provider","fleet-custom-provider-default":"Provider personalizzato","fleet-api-key-env":"NOME_VARIABILE_API_KEY","fleet-provider-id":"id-provider","fleet-custom-secret-help":"NexusCrew salva solo il nome della variabile d’ambiente, mai il suo valore.","cell-prompt":"Prompt di avvio della cella","cell-prompt-help":"Inviato alla cella quando parte: e’ il suo incarico permanente. Vuoto = nessun prompt, la cella parte e basta.","fleet-boot":"avvio automatico","fleet-remote-control":"controllo remoto","cell-mcp":"Strumenti MCP","cell-mcp-all":"tutti","cell-mcp-none":"nessuno","cell-mcp-some":"scelti","cell-mcp-inert":"Per questo client gli strumenti MCP li registra il client nel proprio config, non NexusCrew: la selezione qui non ha effetto.","cell-mcp-help":"«Tutti» è il comportamento di sempre. «Nessuno» è l’unica esclusione CERTA: toglie ogni strumento e non dipende da dove i server sono definiti — è ciò che serve per una cella di cui non ci si fida. Con «scelti» si concede per nome, ma l’elenco copre solo i server che questo nodo sa enumerare: plugin e connettori non compaiono e resterebbero disponibili.","fleet-model-override":"modello alternativo","fleet-ready":"pronto","fleet-not-ready":"non configurato","fleet-engines":"Engine","fleet-cells":"Celle / sessioni cloud","fleet-models":"Modelli dichiarati","fleet-no-models":"Nessun modello dichiarato: si usano quelli del catalogo.","model-editor-engine":"Profilo","model-editor-id":"Id del modello","model-editor-id-help":"L’id esatto che il fornitore si aspetta. Profilo e id non si cambiano dopo: si ritira e si ridichiara.","model-editor-context":"Finestra di contesto (token)","model-editor-max-tokens":"Massimo di token in uscita","model-editor-reasoning":"Supporta il ragionamento esteso","model-test":"Prova sull’API","model-test-running":"Provo…","model-test-ok":"risponde","model-test-unknown-model":"il fornitore non conosce questo id","model-test-auth":"credenziale mancante o rifiutata","model-test-unreachable":"endpoint non raggiungibile","model-test-unverified":"non verificato","model-test-unverified-help":"Non significa che non funzioni: questo fornitore non espone l’elenco dei modelli, quindi la prova non ha potuto dire né sì né no.","model-remove":"Ritira","model-in-use":"in uso","fleet-backup":"backup / ripristino","fleet-backup-help":"Esporta o ripristina selettivamente engine, celle, modelli dichiarati e system prompt. Token, API key e segreti provider non entrano mai nel file.","fleet-backup-export":"esporta","fleet-backup-import":"importa","fleet-backup-download":"scarica backup","fleet-backup-restore":"ripristina selezionate","fleet-backup-import-help":"Scegli un backup JSON, controlla le celle e seleziona l’engine di destinazione prima del ripristino.","fleet-backup-overwrite":"sovrascrive la cella esistente","fleet-backup-new":"nuova cella","fleet-backup-engine-missing":"scegli un engine disponibile","fleet-backup-restore-unavailable":"Il nodo selezionato supporta solo l’esportazione; aggiornalo per ripristinare backup.","fleet-backup-restored":"{n} celle ripristinate","fleet-backup-confirm-overwrite":"Sovrascrivere queste celle? {cells}","fleet-backup-needs-restart":"riavvio necessario: {cells}","fleet-backup-empty":"nessuna cella da esportare","fleet-backup-select-one":"seleziona almeno una cella","fleet-backup-too-large":"backup troppo grande (massimo 1 MB)","fleet-backup-invalid-json":"il file non contiene JSON valido","fleet-backup-invalid-format":"formato o versione del backup non supportati","fleet-backup-invalid-cell":"il backup contiene una cella non valida","fleet-backup-duplicate-cell":"il backup contiene ID cella duplicati","fleet-backup-invalid-engine":"il backup contiene un engine non valido","fleet-backup-duplicate-engine":"il backup contiene ID engine duplicati","fleet-backup-invalid-model":"il backup contiene un modello non valido","fleet-backup-duplicate-model":"il backup contiene modelli duplicati","fleet-backup-confirm-engine-overwrite":"Sovrascrivere questi engine? I valori ambiente già configurati sul target restano invariati. {engines}","fleet-backup-env-names":"nomi ambiente","fleet-backup-env-values-required":"i valori ambiente vanno configurati sul dispositivo","fleet-system-prompt":"system prompt",characters:"caratteri","select-all":"seleziona tutte","select-none":"nessuna",edit:"modifica",save:"salva",label:"etichetta","command-path":"path assoluto del comando","args-lines":"argomenti, uno per riga","env-write-only":"I valori env sono write-only: vuoto mantiene il valore esistente.","fleet-new-engine":"Nuovo engine","fleet-new-cell":"Nuova cella","fleet-saved":"Definizione salvata.","fleet-restart-confirm":"Modifica salvata. Riavviare ora: {cells}?","fleet-remove-engine":'Eliminare l’engine "{id}"?',"fleet-remove-cell":'Eliminare la cella "{id}"? Se è attiva verrà prima fermata.',"fleet-cwd-needs-repair":"cartella da riparare","fleet-cwd-repair":"ripara","fleet-cwd-repair-title":"Ripara cartella cella {id}","fleet-cwd-repair-help":"La cartella attuale non è portabile su questo dispositivo: appartiene a un altro dispositivo o non esiste sotto la home. Scegli una cartella home-relative (~) sul dispositivo target; il backend ricalcolerà il percorso assoluto.","fleet-cwd-repair-no-source-path":"Il percorso originale non viene mostrato: è specifico del dispositivo di origine.","fleet-cwd-repair-placeholder":"es. Dev","fleet-cwd-repair-preview":"Nuova cartella: {path}","fleet-cwd-repair-browse":"sfoglia sotto ~","fleet-cwd-repair-fs-empty":"nessuna sottocartella","fleet-cwd-repair-use-current":"usa questa cartella","fleet-cwd-repair-invalid":'percorso non valido: niente assoluto, "..", barra rovesciata o lettera disco',"fleet-cwd-repair-confirm":"Impostare la cartella della cella {id} su {path}? Verrà ricalcolata sul dispositivo target.","fleet-cwd-repair-unportable":"Il percorso scelto non è portabile su questo dispositivo: deve esistere sotto la home.","fleet-cwd-repair-suggestion":"Suggerimento dal dispositivo:","fleet-cwd-repair-use-suggestion":"usa {path}","fleet-cwd-repaired":"Cartella della cella riparata.","fleet-recovery-kimi-code-consent-yes":"Kimi Code: conferma la custom API key (Yes) nel terminale della cella, poi riavvia la cella.","fleet-recovery-kimi-code-config-custom-api-key":'Kimi Code: nel terminale della cella apri /config e abilita "Use custom API key", poi riavvia la cella. Se la chiave è cambiata, aggiorna la credenziale e riprova.',"fleet-recovery-kimi-cli-login":"Kimi Code CLI: nel terminale della cella esegui /login (device-code Kimi) oppure /provider, poi riavvia la cella.","fleet-recovery-client-terminal-dialog":"Completa il dialogo mostrato nel terminale della cella, poi riavvia la cella.","settings-readonly":"READONLY attivo: le modifiche sono bloccate dal server (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"questa macchina guarda altri nodi via tunnel SSH","role-node":"nodo (raggiungibile)","published-port":"porta pubblicata (opzionale)","no-nodes":"nessun nodo remoto configurato","node-add":"collega installazione NexusCrew","node-connect-help":"La porta SSH serve a raggiungere il server SSH. La porta NexusCrew è invece la porta locale mostrata da `nexuscrew status` sul nodo remoto.","node-name-label":"Nome del nodo","node-ssh-label":"Host SSH","pair-ssh-local-label":"Host o alias SSH su questo dispositivo","node-ssh-local-help":"Puoi sostituire l’indirizzo del link con lo stesso alias che funziona usando ssh su questo dispositivo. Alias, agent e chiavi restano locali e non viaggiano nel link.","node-ssh-port-label":"Porta SSH","node-ssh-port-help":"Di solito 22; usa la porta pubblica del server SSH.","node-app-port-label":"Porta NexusCrew sul nodo","node-app-port-help":"È la porta mostrata da `nexuscrew status` sul nodo remoto.","node-name-ph":"nome (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"porta remota (opz.)","node-remove-confirm":'Rimuovere il nodo "{name}"?',"node-remove-warning":"Elimina associazione, credenziali e tunnel locale. Non spegne il dispositivo remoto.","peer-inventory-title":"Nodi collegati al hub","peer-group-hubs":"Hub diretti","peer-group-clients":"Client collegati","peer-group-routed":"Nodi raggiungibili tramite la rete","peer-group-vl":"Nodi VL","vl-owners-unavailable":"Owner VL non raggiunti","peer-routed":"instradato","peer-routed-stale":"instradato, non raggiungibile","peer-visibility":"Visibilità nella rete","node-test":"test","tunnel-start":"avvia tunnel","tunnel-stop":"ferma tunnel","tunnel-restart":"riavvia tunnel","share-node":"Condividi questo nodo","share-local-heading":"Condivisione di questo dispositivo","share-local-hub":"Hub di condivisione","share-local-through":"Condividi {device} tramite {hub}","share-local-active":"Condiviso e raggiungibile dalla rete collegata all’hub.","share-local-pending":"Condivisione richiesta, ma il tunnel è giù: questo dispositivo non è ancora raggiungibile.","share-local-private":"Privato: solo questo dispositivo può usare il collegamento all’hub.","share-local-private-down":"Privato, ma il collegamento all’hub è giù. Riconnetti per applicare e verificare la modalità privata.","share-local-reconnect":"Riconnetti e riconcilia","share-off-hub-reconcile-pending":"Stato privato salvato; la revoca sull’hub è ancora in attesa.","fleet-cell-label":"nome leggibile (facoltativo)","share-off-local-reconcile-pending":"Revoca confermata dall’hub; il tunnel locale deve ancora riconciliarsi.","share-reverse-pool-pending":"Il canale reverse non risulta spento in modo dimostrabile: resta in quarantena, non chiuso.","share-node-off-desc":"Privato: resta collegato al nodo hub, ma gli altri client non possono raggiungerlo.","share-node-on-desc":"Condiviso: il nodo hub può mostrarlo e smistare celle e deck autorizzati.","peer-shared":"Nodo client condiviso nella rete Hydra","peer-private":"Nodo client privato: collegato, non pubblicato nella rete Hydra","peer-vl-federated":"Nodo VL: federato","row-vl-federated":"federato","node-connected-client":"client collegato","transport-used":"in uso","tunnel-up":"tunnel su","tunnel-down":"tunnel giù","vl-poll-online":"online (poll)","vl-poll-offline":"non risponde","authorized-keys-hint":"incolla questa riga in ~/.ssh/authorized_keys sull'host remoto:",copy:"copia",copied:"copiato","token-rotate":"ruota token","token-rotate-explain":"Il nuovo token NON verrà mostrato: recuperalo con `nexuscrew show token`. La sessione corrente verrà invalidata.","service-regenerate":"rigenera service","npm-auto-update":"aggiornamenti automatici da npm","npm-auto-update-help":"Controlla periodicamente latest e installa solo versioni più recenti. Mai downgrade.","npm-update-current":"installata","npm-update-latest":"npm latest","npm-update-check":"controlla ora","npm-update-install":"aggiorna ora","npm-update-restarting":"Aggiornamento avviato; NexusCrew si riaprirà dopo il riavvio del servizio.","npm-update-idle":"aggiornato","npm-update-checking":"controllo in corso","npm-update-available":"aggiornamento disponibile","npm-update-installing":"installazione in corso","npm-update-installed":"installato, riavvio in corso","npm-update-error":"controllo fallito","npm-update-unsupported":"disponibile solo con installazione npm globale","service-installed":"service installato","service-missing":"service non installato","service-active":"attivo","service-inactive":"non attivo",confirm:"conferma",add:"aggiungi",enable:"attiva","wizard-title":"benvenuto in NexusCrew","wizard-skip":"configura dopo dai settings","wizard-step-roles":"ruoli di questa installazione","wizard-step-node":"primo nodo remoto (opzionale)","wizard-done":"tutto pronto","wizard-done-desc":"setup completato — puoi cambiare tutto dai settings",next:"continua",back:"indietro",skip:"salta",finish:"fine","err-node-name":"nome non valido (a-z, 0-9, -, max 32)","err-local-name":"nome locale non valido: usa uno slug univoco, non “localhost”","err-ssh":"ssh non valido (atteso user@host o alias)","err-port":"porta non valida (1–65535)","err-ssh-port":"porta SSH non valida (1–65535)","err-node-port":"porta NexusCrew non valida (1–65535)","node-sessions":"{n} sessioni","tunnel-down-since":"tunnel giù da {t}","node-unreachable":"nodo non raggiungibile","node-passive":"client offline · stato normale","node-offline":"nodo offline","node-offline-seen":"offline · visto {t} fa","node-needs-repair":"legacy · ripeti il pairing","asks-title":"domande dalle celle","ask-dismiss":"Scarta la domanda","ask-reply-ph":"scrivi la risposta…","push-enable":"attiva notifiche push","push-disable":"disattiva notifiche push","push-on":"push attive su questo device","push-off":"push non attive","push-denied":"permesso notifiche negato dal browser","push-unsupported":"push non supportate in questo browser","notification-speech-enable":"leggi le notifiche ad alta voce","notification-speech-help":"Usa la voce del browser solo per nuove notifiche mentre questa PWA è visibile e in primo piano. Con l’app chiusa resta la notifica di sistema.","notification-speech-test":"prova voce","notification-speech-testing":"prova in corso…","notification-speech-preview":"NexusCrew. Notifiche vocali attive.","notification-speech-preview-ok":"Prova vocale completata.","notification-speech-preview-failed":"Il browser non ha avviato la prova vocale. Interagisci con la pagina e riprova.","notification-speech-needs-test":"Per questa sessione dell’app, premi “prova voce” prima di ricevere annunci vocali.","notification-speech-unsupported":"Sintesi vocale non supportata in questo browser.","audio-title":"Audio nativo del nodo","audio-help":"Consenso e controlli valgono solo per questo dispositivo. Share e visibilità non autorizzano suoni.","audio-consent":"consenti TTS su questo nodo","audio-consent-help":"Permette a celle autorizzate, locali o remote, di consegnare un comando vocale. Puoi revocarlo in ogni momento.","audio-capability":"Capability locale","audio-loading":"leggo lo stato audio locale…","audio-adapter":"adapter","audio-adapter-none":"nessuno","audio-installed":"installato","audio-installed-yes":"sì","audio-installed-no":"no","audio-liveness":"disponibilità","audio-liveness-ready":"pronto ad accettare","audio-liveness-unavailable":"non disponibile","audio-languages":"lingue dichiarate","audio-limits":"limiti","audio-test":"prova audio locale","audio-testing":"prova in corso…","audio-stop":"ferma audio locale","audio-stopping":"stop in corso…","audio-test-needs-consent":"Attiva il consenso locale prima di provare la voce.","audio-unavailable":"Nessun adapter TTS nativo disponibile su questo nodo.","audio-test-accepted":"Il nodo ha accettato la prova. Non dimostra che qualcuno l’abbia udita.","audio-test-refused":"Il nodo ha rifiutato la prova.","audio-test-unknown":"Esito della prova sconosciuto: il nodo non può confermare l’avvio.","audio-stop-stopped":"Audio locale fermato.","audio-stop-idle":"Nessun enunciato locale da fermare.","audio-groups-title":"Gruppi audio condivisi","audio-groups-help":"Decide su quali dispositivi si sente la voce quando una cella parla. Il gruppo è una preferenza locale di consegna, non un consenso. Ogni nodo conserva consenso, ACL, disponibilità e Stop locale.","audio-groups-empty":"Nessun gruppo: la voce esce solo su questo nodo.","audio-group-name":"nome gruppo","audio-group-mode":"modalità consegna","audio-group-primary":"primo disponibile (in ordine)","audio-group-fanout":"tutti i nodi elencati","audio-group-targets":"nodi target esatti","audio-group-local":"questo nodo","audio-group-unavailable-target":"non rilevato ora","audio-group-no-targets":"Nessun nodo con instanceId disponibile. Il gruppo non può usare nomi, wildcard o “tutti”.","audio-group-new":"nuovo gruppo","audio-group-edit":"modifica","audio-group-delete":"elimina","audio-group-save":"salva gruppo","audio-group-cancel":"annulla","audio-group-invalid":"Il gruppo richiede un nome valido e almeno un nodeId esatto.","audio-group-save-failed":"Salvataggio gruppo audio non riuscito.","node-display-label":"Nome (etichetta)","routed-node-aliases":"Alias nodi instradati","routed-node-aliases-help":"Visibili solo su questo dispositivo; route e nome remoto non cambiano.","node-local-alias":"Alias su questo dispositivo","alias-on-device":"Alias su questo dispositivo","reset-alias":"Ripristina nome remoto","node-slug-hint":"routing su slug: {slug}","device-name-label":"Nome dispositivo","device-name-hint":"come ti vedono i peer (modificabile)","local-route-name-label":"Nome locale / route","local-route-name-hint":"handle tecnico stabile: label leggibile + suffisso del nodeId; modificabile prima della connessione","err-label":"etichetta non valida (max 64 char, niente a capo)","fleet-inventory":"Celle e sessioni","fleet-inventory-help":"tutte le posizioni (Locale + route Hydra)","fleet-manage-location":"Gestisci posizione","fleet-network-overview":"Panoramica rete","fleet-manage-help":"crea e configura celle nella posizione selezionata","fleet-overview-help":"stato operativo di tutte le posizioni, senza duplicare l’editor","fleet-inventory-empty":"nessuna cella o sessione","cell-switcher-refreshing":"aggiorno le celle…","cell-switcher-empty-active":"nessuna cella attiva verificata","cell-switcher-not-confirmed":"stato non confermato","cell-switcher-not-active":"questa cella non è più attiva","cell-switcher-select":"seleziona una cella","cell-switcher-open":"apri cella","cell-switcher-show-all":"tutte","cell-switcher-show-active":"attive","cell-switcher-close":"chiudi selettore celle","fleet-not-available":"fleet non disponibile su questa posizione",start:"avvia",stop:"ferma",restart:"riavvia",delete:"elimina","copy-manual":"copia non riuscita — seleziona e Cmd+C, o copia a mano","copy-empty":"niente selezione: trascina con Shift per selezionare","selection-held":"evidenziazione persa, testo ancora in mano","invite-hub-only":"Un invito si conia sull’hub. Ammettere un nodo nuovo è la sola cosa che un nodo collegato non può chiedere per conto di un altro: apri NexusCrew sull’hub e crea l’invito da lì.","row-private":"privato","node-detail-open":"apri il dettaglio","node-detail-reach":"Raggiungibilità","node-detail-route":"percorso","node-detail-ssh":"SSH","node-detail-transport":"trasporto","node-detail-owner":"owner","node-detail-authority":"Cosa può fare questo nodo","authority-owner-equivalent":"Autorità pari alla tua: un nodo accoppiato può fare su questa macchina tutto quello che puoi fare tu.","authority-routed":"Non è accoppiato con questa macchina: la sua autorità vive presso l’hub che lo instrada.","authority-no-grants":"L’unico potere per-nodo che esiste è la scelta delle celle, qui sotto. Dentro quelle celle l’autorità resta piena.","authority-no-grants-elsewhere":"L’unico potere per-nodo che esiste è la scelta delle celle, e si imposta sull’installazione che le possiede — non da qui.","node-detail-network-view":"Cosa vede di questa rete","node-detail-command":"Comando","vl-no-commands":"Il device non dichiara comandi disponibili.","vl-events-title":"Sessione","vl-events-empty":"Nessun evento in memoria: la sessione non ha ancora parlato, oppure quello che ha detto è uscito dal buffer. La storia resta sul device.","vl-events-gap":"eventi non ricevuti:","vl-events-truncated":"contenuto troncato dal device","vl-events-turn-end":"— fine turno —","vl-events-done":"— fine risposta —","vl-events-writer-epoch":"— cambio scrittore —","vl-events-tool":"strumento","vl-events-tool-ok":"concluso","vl-events-tool-failed":"fallito","vl-events-usage":"consumo aggiornato","vl-events-stale":"Aggiornamento non riuscito: quello che vedi potrebbe non essere l’ultimo.","vl-cmd-phase-submitted":"inviato, in attesa di conferma","vl-cmd-phase-inflight":"in corso","vl-cmd-phase-done-ok":"completato","vl-cmd-phase-done-error":"fallito","vl-cmd-status":"stato","vl-cmd-health":"salute","vl-cmd-start":"avvia","vl-cmd-stop":"ferma","vl-cmd-restart":"riavvia","vl-cmd-version":"versione","vl-cmd-capabilities":"capacità","vl-cmd-logs":"log","vl-cmd-prompt":"prompt","vl-prompt-placeholder":"scrivi il prompt per la sessione del device…","vl-prompt-send":"invia prompt","vl-cmd-unpair":"disaccoppia","node-grant-none":"Nessun nodo scelto: condiviso, ma verso nessuno.","node-grant-unknown":"non più in inventario","node-grant-remove":"togli","node-grant-add":"Aggiungi un nodo","node-grant-search":"Cerca fra i nodi","node-grant-no-candidates":"Nessun nodo corrisponde.","cell-scope":"Celle visibili a questo nodo","cell-scope-help":"Vale su cio’ che questo nodo elenca e su cio’ che può toccare, terminale compreso. Dentro le celle concesse resta un nodo accoppiato a pieno titolo: non è una sandbox.","cell-scope-all":"tutte le celle","cell-scope-none":"nessuna cella","cell-scope-selected":"celle selezionate","cell-scope-none-granted":"Nessuna cella scelta: questo nodo non ne vede nessuna.","cell-scope-unknown":"cella non più esistente","cell-scope-add":"Aggiungi una cella","cell-scope-search":"Cerca fra le celle","cell-scope-no-candidates":"Nessuna cella corrisponde.","cell-scope-reset-warning":"Cambiando modo l’elenco viene azzerato: tornando a «celle selezionate» andrà rifatto.","cell-scope-list-unavailable":"Elenco delle celle non disponibile ora: le concessioni qui sotto restano valide, ma non si può dire se esistono ancora.","single-view":"vista singola",retract:"riduci","keybar-expand":"espandi la barra tasti","keybar-retract":"riduci la barra tasti","save-and-start":"salva e avvia",permissions:"Permessi","power-on-hint":"Spegni la cella; puoi anche toglierla dal boot.","launch-engine-help":"Provider, credenziali e nuovi engine si creano in Impostazioni → Flotta. Modello e permessi sono per questa cella.","launch-unavailable-hint":"Configurazione engine non disponibile su questo nodo.","import-as-cell":"Importa come cella","import-help":"Riconcilia una sessione tmux esistente in una cella gestita. Scegli un engine già dichiarato: nessun engine viene inventato.","import-engine-required":"scegli un engine (obbligatorio)","test-and-connect":"testa e collega","pairing-v2-hint":"Incolla o scansiona UN solo link: precompila nome, Host SSH ed etichetta quando il link li include (v2).","invite-v2-hint":"Crea un invito monouso. Serve l’indirizzo SSH di questo dispositivo, raggiungibile da chi lo userà.","invite-target-local":"Il nuovo dispositivo entrerà in","invite-target-this":"questo dispositivo","invite-endpoint-label":"Indirizzo SSH di questo hub visto dagli altri dispositivi","invite-endpoint-auto":"Endpoint già configurato","invite-endpoint-needed":"Inserisci user@host o un alias SSH condiviso. Non è 127.0.0.1 e non è l’URL HTTP NexusCrew.","invite-ssh-hint":"Il target SSH con cui L’ALTRO dispositivo raggiunge QUESTA installazione (user@host o alias). Obbligatorio: viene incluso nel link.","invite-next-steps":"copia questo link, apri NexusCrew sull’altro dispositivo e incollalo in Impostazioni → Nodi (o scansiona il QR): al resto pensa NexusCrew","pair-card-title":"collega con un solo link","pair-card-help":"Incolla il link di pairing generato sull’altro dispositivo (o scansiona il suo QR): NexusCrew decodifica, prova la connessione SSH e collega da solo.","pair-paste-ph":"incolla qui il link di pairing","pair-paste-btn":"incolla","pair-advanced":"avanzate / modifica","pair-progress":"collegamento in corso: SSH → invito → conferma → verifica…","pair-retry":"riprova","pair-invalid-link":"questo non è un link di pairing valido","pair-invalid-hint":"serve il link completo (http://…#pair=…) generato dall’altro NexusCrew: non aprirlo, incollalo qui","pair-missing-ssh":"il link non include il target SSH (formato v1): indica in “avanzate” come questo dispositivo raggiunge l’altro via SSH — non viene mai inventato","pair-missing-name":"manca il nome del nodo: completalo in “avanzate”","pair-clipboard-denied":"lettura degli appunti non consentita: incolla manualmente nel campo","pair-clipboard-empty":"appunti vuoti: copia prima il link di pairing","pair-stage-validation":"dati non validi","pair-stage-conflict":"nome già in uso","pair-stage-ssh-start":"avvio del tunnel SSH fallito","pair-stage-ssh-ready":"peer non raggiungibile via SSH","pair-stage-join":"scambio dell’invito fallito","pair-stage-tunnel-final":"tunnel negoziato fallito","pair-stage-confirm":"conferma del pairing fallita","pair-stage-health":"verifica finale della federazione fallita","pair-stage-internal":"errore interno","pair-stage-generic":"connessione fallita","qr-no-camera":"nessuna camera disponibile su questo dispositivo: usa una foto del QR","qr-permission":"permesso camera negato: consentilo nel browser o usa una foto del QR","qr-unsupported":"scanner live non supportato qui: carica una foto del QR","qr-upload":"usa una foto"},en:{"update-available":"new version {v} available","install-version-mismatch":"incomplete installation: frontend and server do not match (v{v})",reload:"reload","grid-empty":"drag a session here from the sidebar, or double-click for single view","grid-full":"a deck can show at most 9 sessions",pin:"pin to top",reorder:"reorder","host-lease-live":"live host: supervision active","host-lease-grace":"live host: supervision recovering (grace)","host-lease-expired":"live host: supervision expired","host-lease-none":"live host: never supervised","host-lease-unavailable":"live host: supervision guarantee not available on this node","reorder-help":"drag the handle; keyboard up/down arrows","rename-node":"rename node","rename-node-prompt":"New node name in NexusCrew","rename-node-invalid":"Invalid name: maximum 64 characters, no line breaks.","reorder-deck-help":"drag the deck; keyboard left/right arrows",sessions:"sessions","new-session":"new session",new:"new",fleet:"Fleet","fleet-tmux":"tmux fleet","other-sessions":"Other sessions","view-all":"all","view-pinned":"pinned","view-active":"active","view-off":"off","view-technical":"technical","mark-technical":"hide as technical session","mark-normal":"show as normal session","position-local":"Local",files:"files",refresh:"refresh","filter-placeholder":"filter sessions…","loading-fleet":"loading fleet…","no-sessions":"no live tmux sessions — the fleet starts at boot (systemd)","no-match":'no session matches "{q}"',"copy-url":"click to copy URL","ssh-only":"SSH/VPN tunnel only","new-files-outbox":"new files in outbox",terminate:"terminate","terminate-confirm":'Terminate session "{name}"?',"cell-on":"tmux alive","cell-off":"off","cell-working":"working","cell-idle":"idle","cell-degraded":"degraded: unit active, tmux dead","power-on":"power on","power-off":"power off","boot-enable":"enable at boot","boot-disable":"disable at boot","state-on":"running","state-off":"stopped",engine:"Engine",model:"Model","model-default":"Provider default model","model-remembered":"Last model used with this engine","boot-persist":"start at boot","remove-boot":"also remove from boot","power-config-in-settings":"Edit engine, provider, profile, model and permissions in Settings → Fleet.","no-remote-control":"⚠ non-native engine: no claude.ai app RC (you can still drive it from here)",cancel:"cancel",name:"name","name-invalid":"invalid name: a-zA-Z0-9._- max 64, no leading '-'",cwd:"folder",browse:"browse","fs-home":"home","fs-parent":".. up",preset:"preset","preset-2x2":"2×2 grid","preset-columns":"columns","preset-equalize":"equalize",collapse:"collapse",expand:"expand",create:"create","auth-prompt":"Paste the token (printed by the server):","remember-device":"remember on this device","zoom-out":"smaller text","zoom-in":"bigger text",composer:"composer",panel:"panel","panel-none":"No panel configured for this cell.","panel-checking":"Opening panel…","panel-not-granted":"This node does not grant the panel to the requester: access must be granted on the node that owns the cell, not by retrying here.","panel-denied":"Panel entry refused: the ticket is no longer valid. Retry: a new ticket will be requested.","panel-unreachable":"The panel is not reachable through this node: retry in a little while.","panel-timeout":"The panel did not answer in time: service slow to start or overloaded. Retry in a little while.","panel-retry":"Retry",windows:"{n} windows","empty-files":"empty",upload:"upload","no-sessions-short":"no sessions","composer-placeholder":"type or dictate…","composer-history-tools":"input history and size","composer-history":"cell history","composer-history-empty":"no submitted input","composer-history-clear":"clear this cell history","composer-expand":"expand input","composer-collapse":"collapse input","composer-clear-data":"clear drafts and history","composer-clear-data-help":"Removes every saved cell draft and input-history entry from this browser.","composer-clear-confirm":"Clear every saved draft and input-history entry from this browser?","composer-clear-done":"Drafts and history cleared.","composer-clear-failed":"Could not clear composer data in this browser.",attach:"attach","attach-file":"File","attach-camera":"Camera","attach-gallery":"Gallery","attach-uploading":"uploading…","attach-upload-progress":"attachment {n}/{total}…","attach-uploaded":"{n} attachments uploaded",voice:"voice",send:"send","composer-send-failed":"connection not ready — text kept, try again",close:"close","lang-label":"language",decks:"decks","new-deck":"new deck","deck-name":"deck name","open-deck-window":"open in a new window","detach-deck":"detach into a new window","deck-current":"this deck (current window)","deck-owner-unavailable":"owner node is not shared or reachable","rename-deck":"rename deck","delete-deck":"delete deck","delete-deck-confirm":'Delete deck "{name}"?',"send-to-deck":"send to deck…","deck-autosave":"autosave",saving:"saving…",saved:"saved","popup-blocked":"popup blocked: open here","expand-owner":"expand {owner} decks","collapse-owner":"collapse {owner} decks","owner-deck-count-one":"{count} deck","owner-deck-count-many":"{count} decks","dot-working":"in use (active window)","dot-on":"open in background","dot-neutral":"not open","dot-warn":"owner offline","select-drag":"drag to select","copy-manual":"select and copy manually","toggle-sidebar":"show/hide the sidebar",settings:"settings","tab-roles":"roles","tab-nodes":"nodes",local:"Local",location:"Location","pairing-link":"pairing link","pairing-required":"name, SSH alias and pairing link are required","pairing-connect-help":"Connecting a node requires a name, a working SSH Host, and a link/QR created by the other NexusCrew installation.","pairing-localhost-hint":"127.0.0.1 in the link is correct: do not open it here. NexusCrew carries the invite and port through the SSH Host.","scan-qr":"scan QR","pairing-qr-invalid":"invalid pairing QR","invite-node":"invite a node","create-pairing-link":"create link / QR","visibility-network":"whole network","visibility-relay":"relay only","visibility-selected":"selected nodes","hydra-simple":"local + nodes, one network","local-ready":"This device is ready. Use it alone or connect it to a node.","local-only":"local only","add-node":"add node",connect:"connect","node-connected":"Node connected. The network will synchronize automatically.","tab-system":"system","tab-fleet":"fleet","tab-audio":"audio","system-general":"general","system-diagnostics":"diagnostics","system-this-node":"this node","system-updates":"updates","system-security":"security","system-local-data":"local browser data","system-terminal":"terminal","alternate-screen":"alternate screen","alternate-screen-help":"Keeps standard tmux behaviour for new NexusCrew sessions. An application that tracks the mouse scrolls on its own; the others browse the tmux scrollback. It does not change cells already running.","tab-input":"input","tab-diagnostics":"diagnostics","input-settings-local":"Local preferences for this browser. They apply immediately to single view and decks without changing the remote node.","terminal-keyboard-gesture":"Open the virtual keyboard from the terminal","terminal-keyboard-double-tap":"Double tap (default)","terminal-keyboard-single-tap":"Single tap","terminal-keyboard-never":"Never from terminal","terminal-keyboard-gesture-help":"The keypad and STT use the separate controls below. Mouse and physical keyboard remain available.","keybar-ime-lock":"Keypad: keep the virtual keyboard closed","keybar-ime-lock-help":"ESC, arrows, PgUp/PgDn, Enter and menu send directly to the PTY without focusing a text field.","voice-ime-lock":"STT microphone: keep the virtual keyboard closed","voice-ime-lock-help":"Tapping the microphone starts or stops voice without focusing the composer.","keybar-enter-show":"Show the tall Enter keypad key","keybar-enter-show-help":"Enter stays to the right of PgUp/PgDn and spans both rows.","keybar-layout":"Keypad layout","keybar-layout-full":"Full (default)","keybar-layout-compact":"Compact","keybar-layout-help":"Compact: one row with an expand toggle that reaches the full key set without changing the preference.","input-settings-reset":"restore input defaults","diagnostics-local":"This node","diagnostics-target":"Node to diagnose","diagnostics-verbose":"Temporary verbose logs","diagnostics-duration":"Verbose duration","diagnostics-expires":"Verbose enabled until {time}","diagnostics-off":"Verbose is off; operational warnings and errors remain available.","diagnostics-level":"Level","diagnostics-all-levels":"all levels","diagnostics-component":"component","diagnostics-pause":"pause","diagnostics-autoscroll":"autoscroll","diagnostics-log":"Sanitized diagnostic log","diagnostics-empty":"No diagnostic events.","diagnostics-export":"export JSON","diagnostics-export-failed":"Export is not available in this browser.","diagnostics-clear":"clear","diagnostics-clear-confirm":"Clear this node diagnostic buffer?","diagnostics-unsupported":"This peer is offline or does not support structured diagnostics.","fleet-editor-loading":"Loading the Fleet editor…","fleet-editor-load-error":"Unable to load the Fleet editor.","fleet-editor-unavailable":"The Fleet editor is unavailable at this location.","fleet-managed":"managed by NexusCrew","fleet-custom":"custom command","fleet-managed-help":"Client, provider and launch are managed internally; secrets are never displayed.","fleet-shell-engine-help":"The local shell is resolved on the device at launch time; no executable path is stored in backups.","fleet-shell-command-placeholder":"optional command, e.g. npm test","fleet-shell-command-help":"Runs through an interactive login shell (-lic), with the user PATH and aliases. The cell stops when the command finishes; immediate failures are reported.","fleet-shell-command-metachar":"Pipes, redirects, variables, and other metacharacters are interpreted by the device shell.","fleet-shell-interactive":"Empty: opens a local interactive shell and keeps the cell active.","fleet-shell-launch-help":"Configure the Shell command on the cell in Settings → Fleet.","fleet-credential-title":"API key on this device","fleet-credential-help":"The key stays only on the selected node and is never displayed or exported. If the node is remote, the value travels to it over the paired channel.","fleet-credential-set":"set key","fleet-credential-change":"change key","fleet-credential-forget":"forget","fleet-credential-saved":"Key saved locally.","fleet-credential-removed":"Local key removed.","fleet-credential-remove-confirm":"Remove the local {key} key?","fleet-credential-source-environment":"environment","fleet-credential-source-local":"local store","fleet-credential-source-compatibility":"compatible config","fleet-credential-source-missing":"missing","fleet-credential-source-nexuscrew-store":"NexusCrew store","fleet-credential-source-unreadable":"unreadable","fleet-credential-source-login":"client login","fleet-credential-source-none":"none","fleet-credential-source-policy":"credential source","fleet-credential-source-policy-auto":"auto (legacy precedence)","fleet-credential-source-policy-nexuscrew-store":"NexusCrew store only","fleet-credential-source-policy-environment":"environment only","fleet-key-section":"KEY","fleet-key-variable":"Variable","fleet-key-value":"Value for {key}","fleet-key-used-by":"Used by: {engines}","fleet-key-used-by-none":"Not yet used by configured engines on this node.","fleet-key-shared-impact":"Replacing or removing {key} affects every listed engine: {engines}.","fleet-key-enter":"enter the key","fleet-key-blank-keeps":"blank = keep the current source","fleet-key-reveal":"reveal","fleet-key-hide":"hide","fleet-key-local-help":"The value stays write-only on the selected node: it is never read back over the network and never enters engines or backups. If the selected node is remote, the value reaches it over the paired channel.","fleet-key-create-missing":"Explicitly create the engine without a key (it will remain “key required”).","fleet-key-partial-create":"Engine created; the key was not saved. Retry without creating a duplicate.","fleet-key-partial-edit":"Engine updated; the key was not saved. The engine changes remain applied.","fleet-provider-notice-claude-openrouter":"Claude Code is optimized for Anthropic models; other providers may not work correctly. Fast mode requires the first-party Anthropic provider.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses is beta and stateless; Codex-VL has no Chat Completions fallback.","fleet-provider-notice-claude-kimi-code":"Kimi Code uses isolated Claude configuration with dedicated onboarding and fast-mode flags; native Claude configuration is not modified, but its MCP tools are inherited.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal uses only ALIBABA_CODE_API_KEY from the local credential layer; qwen3.8-max is the default and no OpenAI/PAYG fallback is used.","fleet-provider-notice-kimi-native":'Native Kimi Code CLI uses the CLI login (device code) and its own configuration: NexusCrew never reads or copies credentials. Distinct from the Claude Code "Kimi Code" provider, which remains the managed K3 path.',"fleet-model-default":"default model (optional)","fleet-model-required":"model (required)","fleet-standard-permissions":"standard permissions","fleet-unsafe-permissions":"unsafe · bypass approvals/sandbox","fleet-unsafe-warning":"Explicit unsafe mode: the worker can act without normal approval or sandbox gates.","fleet-provider-display":"provider display name","fleet-custom-provider-default":"Custom provider","fleet-api-key-env":"API_KEY_ENV_NAME","fleet-provider-id":"provider-id","fleet-custom-secret-help":"NexusCrew stores only the environment-variable name, never its value.","cell-prompt":"Cell start-up prompt","cell-prompt-help":"Sent to the cell when it starts: this is its standing brief. Empty means no prompt — the cell just starts.","fleet-boot":"start at boot","fleet-remote-control":"remote control","cell-mcp":"MCP tools","cell-mcp-all":"all","cell-mcp-none":"none","cell-mcp-some":"chosen","cell-mcp-inert":"For this client, MCP tools are registered by the client in its own config, not NexusCrew: the selection here has no effect.","cell-mcp-help":"“All” is the long-standing behaviour. “None” is the only CERTAIN exclusion: it removes every tool and does not depend on where the servers are defined — that is what you want for a cell you do not trust. “Chosen” grants by name, but the list only covers servers this node can enumerate: plugins and connectors do not appear and would stay available.","fleet-model-override":"model override","fleet-ready":"ready","fleet-not-ready":"not configured","fleet-engines":"Engines","fleet-cells":"Cells / cloud sessions","fleet-models":"Declared models","fleet-no-models":"No declared model: the built-in catalog is used.","model-editor-engine":"Profile","model-editor-id":"Model id","model-editor-id-help":"The exact id the provider expects. Profile and id cannot be changed later: withdraw and declare again.","model-editor-context":"Context window (tokens)","model-editor-max-tokens":"Max output tokens","model-editor-reasoning":"Supports extended reasoning","model-test":"Test against the API","model-test-running":"Testing…","model-test-ok":"responds","model-test-unknown-model":"the provider does not know this id","model-test-auth":"credential missing or refused","model-test-unreachable":"endpoint unreachable","model-test-unverified":"not verified","model-test-unverified-help":"This does not mean it fails: this provider does not expose a model list, so the test could say neither yes nor no.","model-remove":"Withdraw","model-in-use":"in use","fleet-backup":"backup / restore","fleet-backup-help":"Selectively export or restore engines, cells, declared models, and system prompts. Tokens, API keys, and provider secrets never enter the file.","fleet-backup-export":"export","fleet-backup-import":"import","fleet-backup-download":"download backup","fleet-backup-restore":"restore selected","fleet-backup-import-help":"Choose a JSON backup, review the cells and select a destination engine before restoring.","fleet-backup-overwrite":"overwrites existing cell","fleet-backup-new":"new cell","fleet-backup-engine-missing":"choose an available engine","fleet-backup-restore-unavailable":"The selected node supports export only; update it to restore backups.","fleet-backup-restored":"{n} cells restored","fleet-backup-confirm-overwrite":"Overwrite these cells? {cells}","fleet-backup-needs-restart":"restart required: {cells}","fleet-backup-empty":"no cells to export","fleet-backup-select-one":"select at least one cell","fleet-backup-too-large":"backup is too large (1 MB maximum)","fleet-backup-invalid-json":"the file does not contain valid JSON","fleet-backup-invalid-format":"unsupported backup format or version","fleet-backup-invalid-cell":"the backup contains an invalid cell","fleet-backup-duplicate-cell":"the backup contains duplicate cell IDs","fleet-backup-invalid-engine":"the backup contains an invalid engine","fleet-backup-duplicate-engine":"the backup contains duplicate engine IDs","fleet-backup-invalid-model":"the backup contains an invalid model","fleet-backup-duplicate-model":"the backup contains duplicate models","fleet-backup-confirm-engine-overwrite":"Overwrite these engines? Environment values already configured on the target stay unchanged. {engines}","fleet-backup-env-names":"environment names","fleet-backup-env-values-required":"environment values must be configured on this device","fleet-system-prompt":"system prompt",characters:"characters","select-all":"select all","select-none":"select none",edit:"edit",save:"save",label:"label","command-path":"absolute command path","args-lines":"arguments, one per line","env-write-only":"Environment values are write-only: blank keeps the existing value.","fleet-new-engine":"New engine","fleet-new-cell":"New cell","fleet-saved":"Definition saved.","fleet-restart-confirm":"Change saved. Restart now: {cells}?","fleet-remove-engine":'Delete engine "{id}"?',"fleet-remove-cell":'Delete cell "{id}"? If active it will be stopped first.',"fleet-cwd-needs-repair":"folder needs repair","fleet-cwd-repair":"repair","fleet-cwd-repair-title":"Repair cell folder {id}","fleet-cwd-repair-help":"The current folder is not portable on this device: it belongs to another device or does not exist under the home directory. Choose a home-relative (~) folder on the target device; the backend will recompute the absolute path.","fleet-cwd-repair-no-source-path":"The original path is not shown: it is specific to the source device.","fleet-cwd-repair-placeholder":"e.g. Dev","fleet-cwd-repair-preview":"New folder: {path}","fleet-cwd-repair-browse":"browse under ~","fleet-cwd-repair-fs-empty":"no subfolders","fleet-cwd-repair-use-current":"use this folder","fleet-cwd-repair-invalid":'invalid path: no absolute path, "..", backslash or drive letter',"fleet-cwd-repair-confirm":"Set the folder of cell {id} to {path}? It will be recomputed on the target device.","fleet-cwd-repair-unportable":"The chosen path is not portable on this device: it must exist under the home directory.","fleet-cwd-repair-suggestion":"Suggestion from device:","fleet-cwd-repair-use-suggestion":"use {path}","fleet-cwd-repaired":"Cell folder repaired.","fleet-recovery-kimi-code-consent-yes":"Kimi Code: confirm the custom API key (Yes) in the cell terminal, then restart the cell.","fleet-recovery-kimi-code-config-custom-api-key":'Kimi Code: in the cell terminal open /config and enable "Use custom API key", then restart the cell. If the key changed, update the credential and retry.',"fleet-recovery-kimi-cli-login":"Kimi Code CLI: in the cell terminal run /login (Kimi device code) or /provider, then restart the cell.","fleet-recovery-client-terminal-dialog":"Complete the dialog shown in the cell terminal, then restart the cell.","settings-readonly":"READONLY active: changes are blocked by the server (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"this machine watches other nodes via SSH tunnels","role-node":"node (reachable)","published-port":"published port (optional)","no-nodes":"no remote nodes configured","node-add":"connect a NexusCrew installation","node-connect-help":"The SSH port reaches the SSH server. The NexusCrew port is the local port reported by `nexuscrew status` on the remote node.","node-name-label":"Node name","node-ssh-label":"SSH host","pair-ssh-local-label":"SSH host or alias on this device","node-ssh-local-help":"You may replace the link address with the same alias that works with ssh on this device. Aliases, agents and private keys stay local and are never carried in the link.","node-ssh-port-label":"SSH port","node-ssh-port-help":"Usually 22; use the SSH server public port.","node-app-port-label":"NexusCrew port on node","node-app-port-help":"The port reported by `nexuscrew status` on the remote node.","node-name-ph":"name (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"remote port (opt.)","node-remove-confirm":'Remove node "{name}"?',"node-remove-warning":"Deletes the pairing, credentials and local tunnel. It does not power off the remote device.","peer-inventory-title":"Nodes connected to the hub","peer-group-hubs":"Direct hubs","peer-group-clients":"Connected clients","peer-group-routed":"Nodes reachable through the network","peer-group-vl":"VL nodes","vl-owners-unavailable":"VL owners unreachable","peer-routed":"routed","peer-routed-stale":"routed, unreachable","peer-visibility":"Network visibility","node-test":"test","tunnel-start":"start tunnel","tunnel-stop":"stop tunnel","tunnel-restart":"restart tunnel","share-node":"Share this node","share-local-heading":"Share this device","share-local-hub":"Sharing hub","share-local-through":"Share {device} through {hub}","share-local-active":"Shared and reachable by the network connected to the hub.","share-local-pending":"Sharing is requested, but the tunnel is down: this device is not reachable yet.","share-local-private":"Private: only this device can use its hub connection.","share-local-private-down":"Private, but the hub connection is down. Reconnect to apply and verify private mode.","share-local-reconnect":"Reconnect and reconcile","share-off-hub-reconcile-pending":"Private state saved; hub revocation is still pending.","fleet-cell-label":"readable name (optional)","share-off-local-reconcile-pending":"Hub revocation confirmed; the local tunnel still needs reconciliation.","share-reverse-pool-pending":"The reverse channel was not demonstrably shut down: it is quarantined, not closed.","share-node-off-desc":"Private: it stays connected to the hub, but other clients cannot reach it.","share-node-on-desc":"Shared: the hub may advertise it and route authorized cells and decks.","peer-shared":"Client node shared on the Hydra network","peer-private":"Private client node: connected, not published on Hydra","peer-vl-federated":"VL node: federated","row-vl-federated":"federated","node-connected-client":"connected client","transport-used":"in use","tunnel-up":"tunnel up","tunnel-down":"tunnel down","vl-poll-online":"online (poll)","vl-poll-offline":"not responding","authorized-keys-hint":"paste this line into ~/.ssh/authorized_keys on the remote host:",copy:"copy",copied:"copied","token-rotate":"rotate token","token-rotate-explain":"The new token will NOT be shown: retrieve it with `nexuscrew show token`. The current session will be invalidated.","service-regenerate":"regenerate service","npm-auto-update":"automatic updates from npm","npm-auto-update-help":"Periodically checks latest and installs only newer versions. Never downgrades.","npm-update-current":"installed","npm-update-latest":"npm latest","npm-update-check":"check now","npm-update-install":"update now","npm-update-restarting":"Update started; NexusCrew will return after the service restarts.","npm-update-idle":"up to date","npm-update-checking":"checking","npm-update-available":"update available","npm-update-installing":"installing","npm-update-installed":"installed, restarting","npm-update-error":"check failed","npm-update-unsupported":"available only for global npm installations","service-installed":"service installed","service-missing":"service not installed","service-active":"active","service-inactive":"not active",confirm:"confirm",add:"add",enable:"enable","wizard-title":"welcome to NexusCrew","wizard-skip":"configure later from settings","wizard-step-roles":"roles of this install","wizard-step-node":"first remote node (optional)","wizard-done":"all set","wizard-done-desc":"setup complete — you can change everything from settings",next:"continue",back:"back",skip:"skip",finish:"finish","err-node-name":"invalid name (a-z, 0-9, -, max 32)","err-local-name":"invalid local name: use a unique slug, not “localhost”","err-ssh":"invalid ssh (expected user@host or alias)","err-port":"invalid port (1–65535)","err-ssh-port":"invalid SSH port (1–65535)","err-node-port":"invalid NexusCrew port (1–65535)","node-sessions":"{n} sessions","tunnel-down-since":"tunnel down for {t}","node-unreachable":"node unreachable","node-passive":"client offline · expected","node-offline":"node offline","node-offline-seen":"offline · seen {t} ago","node-needs-repair":"legacy · pair again","asks-title":"questions from the cells","ask-dismiss":"Dismiss question","ask-reply-ph":"type your answer…","push-enable":"enable push notifications","push-disable":"disable push notifications","push-on":"push active on this device","push-off":"push not active","push-denied":"notification permission denied by the browser","push-unsupported":"push not supported in this browser","notification-speech-enable":"read notifications aloud","notification-speech-help":"Uses the browser voice only for new notifications while this PWA is visible and in the foreground. When the app is closed, the system notification remains available.","notification-speech-test":"test voice","notification-speech-testing":"testing voice…","notification-speech-preview":"NexusCrew. Spoken notifications are active.","notification-speech-preview-ok":"Voice test completed.","notification-speech-preview-failed":"The browser did not start the voice test. Interact with the page and try again.","notification-speech-needs-test":"For this app session, select “test voice” before spoken alerts can play.","notification-speech-unsupported":"Speech synthesis is not supported in this browser.","audio-title":"Native node audio","audio-help":"Consent and controls apply only to this device. Share and visibility do not authorize sounds.","audio-consent":"allow TTS on this node","audio-consent-help":"Allows authorized local or remote cells to deliver a voice command. You can revoke it at any time.","audio-capability":"Local capability","audio-loading":"reading local audio state…","audio-adapter":"adapter","audio-adapter-none":"none","audio-installed":"installed","audio-installed-yes":"yes","audio-installed-no":"no","audio-liveness":"availability","audio-liveness-ready":"ready to accept","audio-liveness-unavailable":"unavailable","audio-languages":"declared languages","audio-limits":"limits","audio-test":"test local audio","audio-testing":"testing audio…","audio-stop":"stop local audio","audio-stopping":"stopping audio…","audio-test-needs-consent":"Enable local consent before testing the voice.","audio-unavailable":"No native TTS adapter is available on this node.","audio-test-accepted":"The node accepted the test. It does not prove that anyone heard it.","audio-test-refused":"The node refused the test.","audio-test-unknown":"Test outcome unknown: the node could not confirm startup.","audio-stop-stopped":"Local audio stopped.","audio-stop-idle":"No local utterance to stop.","audio-groups-title":"Shared audio groups","audio-groups-help":"Chooses which devices play the voice when a cell speaks. A group is a local delivery preference, not consent. Each node keeps its own consent, ACL, availability and local Stop.","audio-groups-empty":"No group: voice plays only on this node.","audio-group-name":"group name","audio-group-mode":"delivery mode","audio-group-primary":"first available (in order)","audio-group-fanout":"all listed nodes","audio-group-targets":"exact target nodes","audio-group-local":"this node","audio-group-unavailable-target":"not currently discovered","audio-group-no-targets":"No node with an available instanceId. A group cannot use names, wildcards, or “all”.","audio-group-new":"new group","audio-group-edit":"edit","audio-group-delete":"delete","audio-group-save":"save group","audio-group-cancel":"cancel","audio-group-invalid":"A group needs a valid name and at least one exact nodeId.","audio-group-save-failed":"Could not save audio group.","node-display-label":"Name (label)","routed-node-aliases":"Routed node aliases","routed-node-aliases-help":"Visible only on this device; the route and remote name do not change.","node-local-alias":"Alias on this device","alias-on-device":"Alias on this device","reset-alias":"Reset remote name","node-slug-hint":"routing on slug: {slug}","device-name-label":"Device name","device-name-hint":"how peers see you (editable)","local-route-name-label":"Local / route name","local-route-name-hint":"stable technical handle: readable label + nodeId suffix; editable before connecting","err-label":"invalid label (max 64 chars, no line breaks)","fleet-inventory":"Cells and sessions","fleet-inventory-help":"all positions (Local + Hydra routes)","fleet-manage-location":"Manage location","fleet-network-overview":"Network overview","fleet-manage-help":"create and configure cells at the selected location","fleet-overview-help":"operational state of every location, separate from the editor","fleet-inventory-empty":"no cells or sessions","cell-switcher-refreshing":"refreshing cells…","cell-switcher-empty-active":"no verified active cells","cell-switcher-not-confirmed":"status not confirmed","cell-switcher-not-active":"this cell is no longer active","cell-switcher-select":"select a cell","cell-switcher-open":"open cell","cell-switcher-show-all":"all","cell-switcher-show-active":"active","cell-switcher-close":"close cell switcher","fleet-not-available":"fleet not available on this position",start:"start",stop:"stop",restart:"restart",delete:"delete","copy-manual":"copy failed — select and press Cmd+C, or copy manually","copy-empty":"nothing selected: drag with Shift to select","selection-held":"highlight gone, text still held","invite-hub-only":"An invite is minted on the hub. Admitting a new node is the one thing a connected node cannot ask on another’s behalf: open NexusCrew on the hub and create the invite there.","row-private":"private","node-detail-open":"open details","node-detail-reach":"Reachability","node-detail-route":"path","node-detail-ssh":"SSH","node-detail-transport":"transport","node-detail-owner":"owner","node-detail-authority":"What this node can do","authority-owner-equivalent":"Authority equal to yours: a paired node can do on this machine everything you can do.","authority-routed":"Not paired with this machine: its authority lives on the hub that routes it.","authority-no-grants":"The only per-node power that exists is the choice of cells, below. Within those cells the authority stays full.","authority-no-grants-elsewhere":"The only per-node power that exists is the choice of cells, and it is set on the installation that owns them — not here.","node-detail-network-view":"What it sees of this network","node-detail-command":"Command","vl-no-commands":"The device declares no commands available.","vl-events-title":"Session","vl-events-empty":"No events in memory: the session has not spoken yet, or what it said has left the buffer. The history stays on the device.","vl-events-gap":"events not received:","vl-events-truncated":"content truncated by the device","vl-events-turn-end":"— end of turn —","vl-events-done":"— turn complete —","vl-events-writer-epoch":"— writer changed —","vl-events-tool":"tool","vl-events-tool-ok":"finished","vl-events-tool-failed":"failed","vl-events-usage":"usage updated","vl-events-stale":"Refresh failed: what you see may not be the latest.","vl-cmd-phase-submitted":"sent, awaiting confirmation","vl-cmd-phase-inflight":"in progress","vl-cmd-phase-done-ok":"completed","vl-cmd-phase-done-error":"failed","vl-cmd-status":"status","vl-cmd-health":"health","vl-cmd-start":"start","vl-cmd-stop":"stop","vl-cmd-restart":"restart","vl-cmd-version":"version","vl-cmd-capabilities":"capabilities","vl-cmd-logs":"logs","vl-cmd-prompt":"prompt","vl-prompt-placeholder":"write the prompt for the device session…","vl-prompt-send":"send prompt","vl-cmd-unpair":"unpair","node-grant-none":"No node chosen: shared, but towards nobody.","node-grant-unknown":"no longer in the inventory","node-grant-remove":"remove","node-grant-add":"Add a node","node-grant-search":"Search the nodes","node-grant-no-candidates":"No node matches.","cell-scope":"Cells this node can see","cell-scope-help":"Applies to what this node lists and to what it can act on, terminal included. Within the granted cells it remains a fully paired node: this is not a sandbox.","cell-scope-all":"every cell","cell-scope-none":"no cell","cell-scope-selected":"selected cells","cell-scope-none-granted":"No cell chosen: this node sees none of them.","cell-scope-unknown":"cell no longer exists","cell-scope-add":"Add a cell","cell-scope-search":"Search the cells","cell-scope-no-candidates":"No cell matches.","cell-scope-reset-warning":"Switching mode clears the list: coming back to “selected cells” means choosing them again.","cell-scope-list-unavailable":"Cell list unavailable right now: the grants below still hold, but we cannot tell whether they still exist.","single-view":"single view",retract:"retract","keybar-expand":"expand the key bar","keybar-retract":"retract the key bar","save-and-start":"save and start",permissions:"Permissions","power-on-hint":"Stop the cell; you can also remove it from boot.","launch-engine-help":"Providers, credentials and new engines are created in Settings → Fleet. Model and permissions are per cell.","launch-unavailable-hint":"Engine configuration is unavailable on this node.","import-as-cell":"Import as cell","import-help":"Reconcile an existing tmux session into a managed cell. Pick an already-declared engine: no engine is invented.","import-engine-required":"pick an engine (required)","test-and-connect":"test and connect","pairing-v2-hint":"Paste or scan ONE link: it prefills name, SSH host and label when the link carries them (v2).","invite-v2-hint":"Create one one-time invitation. It needs this device’s SSH address, reachable by whoever will use it.","invite-target-local":"The new device will join","invite-target-this":"this device","invite-endpoint-label":"This hub’s SSH address as seen by other devices","invite-endpoint-auto":"Configured endpoint","invite-endpoint-needed":"Enter user@host or a shared SSH alias. This is not 127.0.0.1 and not the NexusCrew HTTP URL.","invite-ssh-hint":"The SSH target the OTHER device uses to reach THIS installation (user@host or alias). Required: it is included in the link.","invite-next-steps":"copy this link, open NexusCrew on the other device and paste it in Settings → Nodes (or scan the QR): NexusCrew does the rest","pair-card-title":"connect with one link","pair-card-help":"Paste the pairing link generated on the other device (or scan its QR): NexusCrew decodes it, tests the SSH connection and connects on its own.","pair-paste-ph":"paste the pairing link here","pair-paste-btn":"paste","pair-advanced":"advanced / edit","pair-progress":"connecting: SSH → invite → confirm → verify…","pair-retry":"retry","pair-invalid-link":"this is not a valid pairing link","pair-invalid-hint":"you need the full link (http://…#pair=…) generated by the other NexusCrew: don’t open it, paste it here","pair-missing-ssh":"the link carries no SSH target (v1 format): set in “advanced” how this device reaches the other one over SSH — it is never invented","pair-missing-name":"the node name is missing: fill it in “advanced”","pair-clipboard-denied":"clipboard read not allowed: paste manually into the field","pair-clipboard-empty":"clipboard is empty: copy the pairing link first","pair-stage-validation":"invalid data","pair-stage-conflict":"name already in use","pair-stage-ssh-start":"SSH tunnel start failed","pair-stage-ssh-ready":"peer unreachable over SSH","pair-stage-join":"invite exchange failed","pair-stage-tunnel-final":"negotiated tunnel failed","pair-stage-confirm":"pairing confirmation failed","pair-stage-health":"final federation check failed","pair-stage-internal":"internal error","pair-stage-generic":"connection failed","qr-no-camera":"no camera available on this device: use a photo of the QR","qr-permission":"camera permission denied: allow it in the browser or use a photo of the QR","qr-unsupported":"live scanner not supported here: upload a photo of the QR","qr-upload":"use a photo"},es:{"update-available":"nueva versión {v} disponible","install-version-mismatch":"instalación incompleta: frontend y servidor no coinciden (v{v})",reload:"recargar","grid-empty":"arrastra aquí una sesión desde la barra lateral, o doble clic para vista única","grid-full":"un deck puede mostrar como máximo 9 sesiones",pin:"fijar arriba",reorder:"reordenar","host-lease-live":"host live: supervisión activa","host-lease-grace":"host live: supervisión en recuperación (grace)","host-lease-expired":"host live: supervisión caducada","host-lease-none":"host live: nunca supervisada","host-lease-unavailable":"host live: garantía de supervisión no disponible en este nodo","reorder-help":"arrastra el control; flechas arriba/abajo","rename-node":"renombrar nodo","rename-node-prompt":"Nuevo nombre del nodo en NexusCrew","rename-node-invalid":"Nombre no válido: máximo 64 caracteres, sin saltos de línea.","reorder-deck-help":"arrastra el deck; flechas izquierda/derecha",sessions:"sesiones","new-session":"nueva sesión",new:"nueva",fleet:"Flota","fleet-tmux":"flota tmux","other-sessions":"Otras sesiones","view-all":"todas","view-pinned":"fijadas","view-active":"activas","view-off":"apagadas","view-technical":"técnicas","mark-technical":"ocultar como sesión técnica","mark-normal":"mostrar como sesión normal","position-local":"Local",files:"archivos",refresh:"actualizar","filter-placeholder":"filtrar sesiones…","loading-fleet":"cargando flota…","no-sessions":"sin sesiones tmux vivas — la flota arranca en el boot (systemd)","no-match":"ninguna sesión coincide con «{q}»","copy-url":"clic para copiar la URL","ssh-only":"solo túnel SSH/VPN","new-files-outbox":"archivos nuevos en outbox",terminate:"terminar","terminate-confirm":"¿Terminar la sesión «{name}»?","cell-on":"tmux activo","cell-off":"apagada","cell-working":"trabajando","cell-idle":"en espera","cell-degraded":"degradada: unit activa, tmux muerto","power-on":"encender","power-off":"apagar","boot-enable":"activar al iniciar","boot-disable":"desactivar al iniciar","state-on":"encendida","state-off":"apagada",engine:"Motor",model:"Modelo","model-default":"Modelo predeterminado del proveedor","model-remembered":"Último modelo usado con este motor","boot-persist":"iniciar en el boot","remove-boot":"quitar también del boot","power-config-in-settings":"Modifica motor, proveedor, perfil, modelo y permisos en Ajustes → Flota.","no-remote-control":"⚠ motor no nativo: sin RC de la app claude.ai (aquí puedes pilotarla igual)",cancel:"cancelar",name:"nombre","name-invalid":"nombre inválido: a-zA-Z0-9._- máx 64, sin '-' inicial",cwd:"carpeta",browse:"explorar","fs-home":"home","fs-parent":".. arriba",preset:"preset","preset-2x2":"cuadrícula 2×2","preset-columns":"columnas","preset-equalize":"igualar",collapse:"contraer",expand:"expandir",create:"crear","auth-prompt":"Pega el token (impreso por el servidor):","remember-device":"recordar en este dispositivo","zoom-out":"texto más pequeño","zoom-in":"texto más grande",composer:"composer",panel:"panel","panel-none":"Ningún panel configurado para esta celda.","panel-checking":"Abriendo el panel…","panel-not-granted":"Este nodo no concede el panel a quien lo pide: el acceso se concede en el nodo que posee la celda, no reintentando aquí.","panel-denied":"Entrada al panel rechazada: el billete ya no es válido. Reintenta: se pedirá un billete nuevo.","panel-unreachable":"El panel no es accesible a través de este nodo: reintenta en un momento.","panel-timeout":"El panel no respondió a tiempo: servicio lento en arrancar o sobrecargado. Reintenta en un momento.","panel-retry":"Reintentar",windows:"{n} ventanas","empty-files":"vacía",upload:"subir","no-sessions-short":"sin sesiones","composer-placeholder":"escribe o dicta…","composer-history-tools":"historial y tamaño de entrada","composer-history":"historial de la celda","composer-history-empty":"ninguna entrada enviada","composer-history-clear":"borrar historial de esta celda","composer-expand":"ampliar entrada","composer-collapse":"reducir entrada","composer-clear-data":"borrar borradores e historial","composer-clear-data-help":"Elimina de este navegador todos los borradores y el historial de entrada de las celdas.","composer-clear-confirm":"¿Borrar todos los borradores y el historial de entrada guardados en este navegador?","composer-clear-done":"Borradores e historial eliminados.","composer-clear-failed":"No se pudieron borrar los datos del composer en este navegador.",attach:"adjuntar","attach-file":"Archivo","attach-camera":"Cámara","attach-gallery":"Galería","attach-uploading":"subiendo…","attach-upload-progress":"adjunto {n}/{total}…","attach-uploaded":"{n} adjuntos subidos",voice:"voz",send:"enviar","composer-send-failed":"conexión no disponible — texto conservado, inténtalo de nuevo",close:"cerrar","lang-label":"idioma",decks:"decks","new-deck":"nuevo deck","deck-name":"nombre del deck","open-deck-window":"abrir en una ventana nueva","detach-deck":"separar en una ventana nueva","deck-current":"este deck (ventana actual)","deck-owner-unavailable":"el nodo propietario no está compartido o accesible","rename-deck":"renombrar deck","delete-deck":"eliminar deck","delete-deck-confirm":"¿Eliminar el deck «{name}»?","send-to-deck":"enviar al deck…","deck-autosave":"guardado automático",saving:"guardando…",saved:"guardado","popup-blocked":"ventana bloqueada: abrir aquí","expand-owner":"expandir decks de {owner}","collapse-owner":"comprimir decks de {owner}","owner-deck-count-one":"{count} deck","owner-deck-count-many":"{count} decks","dot-working":"en uso (ventana activa)","dot-on":"abierta en segundo plano","dot-neutral":"no abierta","dot-warn":"nodo sin conexión","select-drag":"arrastra para seleccionar","copy-manual":"selecciona y copia manualmente","toggle-sidebar":"mostrar/ocultar la barra lateral",settings:"ajustes","tab-roles":"roles","tab-nodes":"nodos",local:"Local",location:"Ubicación","pairing-link":"enlace de emparejamiento","pairing-required":"nombre, alias SSH y enlace son obligatorios","pairing-connect-help":"Para conectar un nodo necesitas un nombre, un Host SSH funcional y el enlace/QR creado por la otra instalación NexusCrew.","pairing-localhost-hint":"127.0.0.1 en el enlace es correcto: no lo abras aquí. NexusCrew usa la invitación y el puerto mediante el Host SSH.","scan-qr":"escanear QR","pairing-qr-invalid":"QR de emparejamiento no válido","invite-node":"invitar un nodo","create-pairing-link":"crear enlace / QR","visibility-network":"toda la red","visibility-relay":"solo relay","visibility-selected":"nodos seleccionados","hydra-simple":"local + nodos, una red","local-ready":"Este dispositivo está listo. Úsalo solo o conéctalo a un nodo.","local-only":"solo local","add-node":"añadir nodo",connect:"conectar","node-connected":"Nodo conectado. La red se sincronizará automáticamente.","tab-system":"sistema","tab-fleet":"flota","tab-audio":"audio","system-general":"general","system-diagnostics":"diagnóstico","system-this-node":"este nodo","system-updates":"actualizaciones","system-security":"seguridad","system-local-data":"datos locales del navegador","system-terminal":"terminal","alternate-screen":"pantalla alternativa","alternate-screen-help":"Mantiene el comportamiento estándar de tmux para las nuevas sesiones NexusCrew. Una aplicación que sigue el ratón se desplaza sola; las demás recorren el historial de tmux. No modifica las celdas ya activas.","tab-input":"entrada","tab-diagnostics":"diagnóstico","input-settings-local":"Preferencias locales de este navegador. Se aplican de inmediato a la vista única y a los decks sin cambiar el nodo remoto.","terminal-keyboard-gesture":"Abrir el teclado virtual desde el terminal","terminal-keyboard-double-tap":"Doble toque (predeterminado)","terminal-keyboard-single-tap":"Toque único","terminal-keyboard-never":"Nunca desde el terminal","terminal-keyboard-gesture-help":"El teclado auxiliar y STT usan los controles separados de abajo. El ratón y el teclado físico siguen disponibles.","keybar-ime-lock":"Teclado auxiliar: mantener cerrado el teclado virtual","keybar-ime-lock-help":"ESC, flechas, PgUp/PgDn, Enter y menú envían directamente al PTY sin enfocar un campo de texto.","voice-ime-lock":"Micrófono STT: mantener cerrado el teclado virtual","voice-ime-lock-help":"Tocar el micrófono inicia o detiene la voz sin enfocar el compositor.","keybar-enter-show":"Mostrar Enter vertical en el teclado auxiliar","keybar-enter-show-help":"Enter queda a la derecha de PgUp/PgDn y ocupa las dos filas.","keybar-layout":"Distribución del teclado auxiliar","keybar-layout-full":"Completo (predeterminado)","keybar-layout-compact":"Compacto","keybar-layout-help":"Compacto: una fila con un botón expandir que alcanza el conjunto completo sin cambiar la preferencia.","input-settings-reset":"restaurar valores de entrada","diagnostics-local":"Este nodo","diagnostics-target":"Nodo a diagnosticar","diagnostics-verbose":"Logs detallados temporales","diagnostics-duration":"Duración detallada","diagnostics-expires":"Log detallado activo hasta las {time}","diagnostics-off":"El log detallado está apagado; los avisos y errores operativos siguen disponibles.","diagnostics-level":"Nivel","diagnostics-all-levels":"todos los niveles","diagnostics-component":"componente","diagnostics-pause":"pausa","diagnostics-autoscroll":"desplazamiento automático","diagnostics-log":"Log de diagnóstico sanitizado","diagnostics-empty":"No hay eventos de diagnóstico.","diagnostics-export":"exportar JSON","diagnostics-export-failed":"La exportación no está disponible en este navegador.","diagnostics-clear":"vaciar","diagnostics-clear-confirm":"¿Vaciar el búfer de diagnóstico de este nodo?","diagnostics-unsupported":"Este par está desconectado o no admite diagnósticos estructurados.","fleet-editor-loading":"Cargando el editor de Fleet…","fleet-editor-load-error":"No se puede cargar el editor de Fleet.","fleet-editor-unavailable":"El editor de Fleet no está disponible en esta ubicación.","fleet-managed":"gestionado por NexusCrew","fleet-custom":"comando personalizado","fleet-managed-help":"Cliente, proveedor e inicio se gestionan internamente; los secretos nunca se muestran.","fleet-shell-engine-help":"La shell local se resuelve en el dispositivo al iniciar; no se guarda ninguna ruta ejecutable en las copias.","fleet-shell-command-placeholder":"comando opcional, p. ej. npm test","fleet-shell-command-help":"Se ejecuta mediante una shell de inicio interactiva (-lic), con PATH y alias del usuario. La celda se detiene al terminar; los fallos inmediatos se notifican.","fleet-shell-command-metachar":"Pipes, redirecciones, variables y otros metacaracteres son interpretados por la shell del dispositivo.","fleet-shell-interactive":"Vacío: abre una shell local interactiva y mantiene la celda activa.","fleet-shell-launch-help":"Configura el comando Shell de la celda en Ajustes → Flota.","fleet-credential-title":"Clave API en este dispositivo","fleet-credential-help":"La clave permanece solo en el nodo seleccionado y nunca se muestra ni se exporta. Si el nodo es remoto, el valor viaja hasta él por el canal emparejado.","fleet-credential-set":"poner clave","fleet-credential-change":"cambiar clave","fleet-credential-forget":"olvidar","fleet-credential-saved":"Clave guardada localmente.","fleet-credential-removed":"Clave local eliminada.","fleet-credential-remove-confirm":"¿Eliminar la clave local {key}?","fleet-credential-source-environment":"entorno","fleet-credential-source-local":"almacén local","fleet-credential-source-compatibility":"config compatible","fleet-credential-source-missing":"ausente","fleet-credential-source-nexuscrew-store":"almacén NexusCrew","fleet-credential-source-unreadable":"no verificable","fleet-credential-source-login":"login del cliente","fleet-credential-source-none":"ninguna","fleet-credential-source-policy":"origen de credencial","fleet-credential-source-policy-auto":"auto (precedencia legacy)","fleet-credential-source-policy-nexuscrew-store":"solo almacén NexusCrew","fleet-credential-source-policy-environment":"solo entorno","fleet-key-section":"KEY","fleet-key-variable":"Variable","fleet-key-value":"Valor para {key}","fleet-key-used-by":"Usada por: {engines}","fleet-key-used-by-none":"Aún no la usa ningún motor configurado en este nodo.","fleet-key-shared-impact":"Sustituir o eliminar {key} afecta a todos los motores listados: {engines}.","fleet-key-enter":"introduce la clave","fleet-key-blank-keeps":"vacío = mantener la fuente actual","fleet-key-reveal":"mostrar","fleet-key-hide":"ocultar","fleet-key-local-help":"El valor permanece write-only en el nodo seleccionado: nunca se vuelve a leer desde la red ni entra en motores o copias. Si el nodo seleccionado es remoto, el valor llega a él por el canal emparejado.","fleet-key-create-missing":"Crear explícitamente el motor sin clave (seguirá como “clave requerida”).","fleet-key-partial-create":"Motor creado; la clave no se guardó. Puedes reintentar sin crear un duplicado.","fleet-key-partial-edit":"Motor actualizado; la clave no se guardó. Los cambios del motor siguen aplicados.","fleet-provider-notice-claude-openrouter":"Claude Code está optimizado para modelos Anthropic; otros proveedores podrían no funcionar correctamente. Fast mode requiere el proveedor Anthropic first-party.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses es beta y stateless; Codex-VL no usa fallback de Chat Completions.","fleet-provider-notice-claude-kimi-code":"Kimi Code usa una configuración Claude aislada con onboarding y fast mode dedicados; la configuración Claude nativa no se modifica, pero sus herramientas MCP se heredan.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal usa solo ALIBABA_CODE_API_KEY de la capa local de credenciales; qwen3.8-max es el modelo predeterminado y no se usa fallback OpenAI/PAYG.","fleet-provider-notice-kimi-native":'Kimi Code CLI nativo usa el login del CLI (device-code) y su propia configuración: NexusCrew no lee ni copia credenciales. Distinto del proveedor "Kimi Code" de Claude Code, que sigue siendo la ruta K3 gestionada.',"fleet-model-default":"modelo predeterminado (opcional)","fleet-model-required":"modelo (obligatorio)","fleet-standard-permissions":"permisos estándar","fleet-unsafe-permissions":"inseguro · omitir aprobaciones/sandbox","fleet-unsafe-warning":"Modo inseguro explícito: el worker puede actuar sin las aprobaciones normales ni las protecciones del sandbox.","fleet-provider-display":"nombre visible del proveedor","fleet-custom-provider-default":"Proveedor personalizado","fleet-api-key-env":"NOMBRE_VARIABLE_API_KEY","fleet-provider-id":"id-proveedor","fleet-custom-secret-help":"NexusCrew guarda solo el nombre de la variable de entorno, nunca su valor.","cell-prompt":"Prompt de arranque de la celda","cell-prompt-help":"Se envía a la celda al arrancar: es su encargo permanente. Vacío = sin prompt, la celda solo arranca.","fleet-boot":"inicio automático","fleet-remote-control":"control remoto","cell-mcp":"Herramientas MCP","cell-mcp-all":"todas","cell-mcp-none":"ninguna","cell-mcp-some":"elegidas","cell-mcp-inert":"Para este cliente, las herramientas MCP las registra el cliente en su propia config, no NexusCrew: la selección aquí no tiene efecto.","cell-mcp-help":"«Todas» es el comportamiento de siempre. «Ninguna» es la única exclusión CIERTA: quita toda herramienta y no depende de dónde estén definidos los servidores — es lo que hace falta para una celda en la que no se confía. Con «elegidas» se concede por nombre, pero la lista solo cubre los servidores que este nodo puede enumerar: los plugins y conectores no aparecen y seguirían disponibles.","fleet-model-override":"modelo alternativo","fleet-ready":"listo","fleet-not-ready":"no configurado","fleet-engines":"Motores","fleet-cells":"Celdas / sesiones cloud","fleet-models":"Modelos declarados","fleet-no-models":"Ningún modelo declarado: se usa el catálogo interno.","model-editor-engine":"Perfil","model-editor-id":"Id del modelo","model-editor-id-help":"El id exacto que espera el proveedor. Perfil e id no se cambian después: se retira y se vuelve a declarar.","model-editor-context":"Ventana de contexto (tokens)","model-editor-max-tokens":"Máximo de tokens de salida","model-editor-reasoning":"Admite razonamiento extendido","model-test":"Probar contra la API","model-test-running":"Probando…","model-test-ok":"responde","model-test-unknown-model":"el proveedor no conoce este id","model-test-auth":"credencial ausente o rechazada","model-test-unreachable":"endpoint inalcanzable","model-test-unverified":"no verificado","model-test-unverified-help":"No significa que falle: este proveedor no expone la lista de modelos, así que la prueba no pudo decir ni sí ni no.","model-remove":"Retirar","model-in-use":"en uso","fleet-backup":"copia / restauración","fleet-backup-help":"Exporta o restaura selectivamente motores, celdas, modelos declarados y system prompts. Tokens, claves API y secretos del proveedor nunca entran en el archivo.","fleet-backup-export":"exportar","fleet-backup-import":"importar","fleet-backup-download":"descargar copia","fleet-backup-restore":"restaurar seleccionadas","fleet-backup-import-help":"Elige una copia JSON, revisa las celdas y selecciona un motor de destino antes de restaurar.","fleet-backup-overwrite":"sobrescribe la celda existente","fleet-backup-new":"celda nueva","fleet-backup-engine-missing":"elige un motor disponible","fleet-backup-restore-unavailable":"El nodo seleccionado solo admite exportación; actualízalo para restaurar copias.","fleet-backup-restored":"{n} celdas restauradas","fleet-backup-confirm-overwrite":"¿Sobrescribir estas celdas? {cells}","fleet-backup-needs-restart":"reinicio necesario: {cells}","fleet-backup-empty":"no hay celdas para exportar","fleet-backup-select-one":"selecciona al menos una celda","fleet-backup-too-large":"copia demasiado grande (máximo 1 MB)","fleet-backup-invalid-json":"el archivo no contiene JSON válido","fleet-backup-invalid-format":"formato o versión de copia no compatible","fleet-backup-invalid-cell":"la copia contiene una celda no válida","fleet-backup-duplicate-cell":"la copia contiene IDs de celda duplicados","fleet-backup-invalid-engine":"la copia contiene un motor no válido","fleet-backup-duplicate-engine":"la copia contiene IDs de motor duplicados","fleet-backup-invalid-model":"la copia contiene un modelo no válido","fleet-backup-duplicate-model":"la copia contiene modelos duplicados","fleet-backup-confirm-engine-overwrite":"¿Sobrescribir estos motores? Los valores de entorno ya configurados en el destino no cambian. {engines}","fleet-backup-env-names":"nombres de entorno","fleet-backup-env-values-required":"los valores de entorno deben configurarse en este dispositivo","fleet-system-prompt":"system prompt",characters:"caracteres","select-all":"seleccionar todas","select-none":"ninguna",edit:"editar",save:"guardar",label:"etiqueta","command-path":"ruta absoluta del comando","args-lines":"argumentos, uno por línea","env-write-only":"Los valores env son de solo escritura: vacío conserva el valor existente.","fleet-new-engine":"Nuevo motor","fleet-new-cell":"Nueva celda","fleet-saved":"Definición guardada.","fleet-restart-confirm":"Cambio guardado. ¿Reiniciar ahora: {cells}?","fleet-remove-engine":'¿Eliminar el motor "{id}"?',"fleet-remove-cell":'¿Eliminar la celda "{id}"? Si está activa se detendrá primero.',"fleet-cwd-needs-repair":"carpeta a reparar","fleet-cwd-repair":"reparar","fleet-cwd-repair-title":"Reparar carpeta de celda {id}","fleet-cwd-repair-help":"La carpeta actual no es portátil en este dispositivo: pertenece a otro dispositivo o no existe bajo el directorio home. Elige una carpeta relativa a home (~) en el dispositivo destino; el backend recalculará la ruta absoluta.","fleet-cwd-repair-no-source-path":"La ruta original no se muestra: es específica del dispositivo de origen.","fleet-cwd-repair-placeholder":"p. ej. Dev","fleet-cwd-repair-preview":"Nueva carpeta: {path}","fleet-cwd-repair-browse":"examinar bajo ~","fleet-cwd-repair-fs-empty":"sin subcarpetas","fleet-cwd-repair-use-current":"usar esta carpeta","fleet-cwd-repair-invalid":'ruta no válida: nada de ruta absoluta, "..", barra invertida ni letra de unidad',"fleet-cwd-repair-confirm":"¿Establecer la carpeta de la celda {id} a {path}? Se recalculará en el dispositivo destino.","fleet-cwd-repair-unportable":"La ruta elegida no es portátil en este dispositivo: debe existir bajo el directorio home.","fleet-cwd-repair-suggestion":"Sugerencia del dispositivo:","fleet-cwd-repair-use-suggestion":"usar {path}","fleet-cwd-repaired":"Carpeta de la celda reparada.","fleet-recovery-kimi-code-consent-yes":"Kimi Code: confirma la clave API personalizada (Yes) en el terminal de la celda, luego reinicia la celda.","fleet-recovery-kimi-code-config-custom-api-key":'Kimi Code: en el terminal de la celda abre /config y activa "Use custom API key", luego reinicia la celda. Si la clave cambió, actualiza la credencial y reintenta.',"fleet-recovery-kimi-cli-login":"Kimi Code CLI: en el terminal de la celda ejecuta /login (código de dispositivo Kimi) o /provider, luego reinicia la celda.","fleet-recovery-client-terminal-dialog":"Completa el diálogo mostrado en el terminal de la celda, luego reinicia la celda.","settings-readonly":"READONLY activo: los cambios están bloqueados por el servidor (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"esta máquina observa otros nodos vía túneles SSH","role-node":"nodo (alcanzable)","published-port":"puerto publicado (opcional)","no-nodes":"sin nodos remotos configurados","node-add":"conectar una instalación NexusCrew","node-connect-help":"El puerto SSH conecta con el servidor SSH. El puerto NexusCrew es el puerto local indicado por `nexuscrew status` en el nodo remoto.","node-name-label":"Nombre del nodo","node-ssh-label":"Host SSH","pair-ssh-local-label":"Host o alias SSH en este dispositivo","node-ssh-local-help":"Puedes sustituir la dirección del enlace por el mismo alias que funciona con ssh en este dispositivo. Los alias, agentes y claves permanecen locales y nunca viajan en el enlace.","node-ssh-port-label":"Puerto SSH","node-ssh-port-help":"Normalmente 22; usa el puerto público del servidor SSH.","node-app-port-label":"Puerto NexusCrew del nodo","node-app-port-help":"El puerto indicado por `nexuscrew status` en el nodo remoto.","node-name-ph":"nombre (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"puerto remoto (opc.)","node-remove-confirm":"¿Eliminar el nodo «{name}»?","node-remove-warning":"Elimina el emparejamiento, las credenciales y el túnel local. No apaga el dispositivo remoto.","peer-inventory-title":"Nodos conectados al hub","peer-group-hubs":"Hubs directos","peer-group-clients":"Clientes conectados","peer-group-routed":"Nodos accesibles a través de la red","peer-group-vl":"Nodos VL","vl-owners-unavailable":"Owners VL no alcanzados","peer-routed":"enrutado","peer-routed-stale":"enrutado, no accesible","peer-visibility":"Visibilidad en la red","node-test":"test","tunnel-start":"iniciar túnel","tunnel-stop":"detener túnel","tunnel-restart":"reiniciar túnel","share-node":"Compartir este nodo","share-local-heading":"Compartir este dispositivo","share-local-hub":"Hub para compartir","share-local-through":"Compartir {device} mediante {hub}","share-local-active":"Compartido y accesible para la red conectada al hub.","share-local-pending":"Se solicitó compartir, pero el túnel está caído: este dispositivo aún no es accesible.","share-local-private":"Privado: solo este dispositivo puede usar la conexión al hub.","share-local-private-down":"Privado, pero la conexión al hub está caída. Reconecta para aplicar y verificar el modo privado.","share-local-reconnect":"Reconectar y reconciliar","share-off-hub-reconcile-pending":"Estado privado guardado; la revocación en el hub sigue pendiente.","fleet-cell-label":"nombre legible (opcional)","share-off-local-reconcile-pending":"Revocación confirmada por el hub; el túnel local aún debe reconciliarse.","share-reverse-pool-pending":"El canal inverso no se apagó de forma demostrable: queda en cuarentena, no cerrado.","share-node-off-desc":"Privado: sigue conectado al hub, pero otros clientes no pueden alcanzarlo.","share-node-on-desc":"Compartido: el hub puede anunciarlo y enrutar celdas y decks autorizados.","peer-shared":"Nodo cliente compartido en la red Hydra","peer-private":"Nodo cliente privado: conectado, no publicado en Hydra","peer-vl-federated":"Nodo VL: federado","row-vl-federated":"federado","node-connected-client":"cliente conectado","transport-used":"en uso","tunnel-up":"túnel activo","tunnel-down":"túnel caído","vl-poll-online":"en línea (poll)","vl-poll-offline":"sin respuesta","authorized-keys-hint":"pega esta línea en ~/.ssh/authorized_keys del host remoto:",copy:"copiar",copied:"copiado","token-rotate":"rotar token","token-rotate-explain":"El nuevo token NO se mostrará: recupéralo con `nexuscrew show token`. La sesión actual quedará invalidada.","service-regenerate":"regenerar service","npm-auto-update":"actualizaciones automáticas desde npm","npm-auto-update-help":"Comprueba latest periódicamente e instala solo versiones más recientes. Nunca baja de versión.","npm-update-current":"instalada","npm-update-latest":"npm latest","npm-update-check":"comprobar ahora","npm-update-install":"actualizar ahora","npm-update-restarting":"Actualización iniciada; NexusCrew volverá después de reiniciar el servicio.","npm-update-idle":"actualizado","npm-update-checking":"comprobando","npm-update-available":"actualización disponible","npm-update-installing":"instalando","npm-update-installed":"instalada, reiniciando","npm-update-error":"comprobación fallida","npm-update-unsupported":"disponible solo con instalación npm global","service-installed":"service instalado","service-missing":"service no instalado","service-active":"activo","service-inactive":"no activo",confirm:"confirmar",add:"añadir",enable:"activar","wizard-title":"bienvenido a NexusCrew","wizard-skip":"configura después desde ajustes","wizard-step-roles":"roles de esta instalación","wizard-step-node":"primer nodo remoto (opcional)","wizard-done":"todo listo","wizard-done-desc":"configuración completa — puedes cambiarlo todo desde ajustes",next:"continuar",back:"atrás",skip:"omitir",finish:"terminar","err-node-name":"nombre inválido (a-z, 0-9, -, máx 32)","err-local-name":"nombre local inválido: usa un slug único, no “localhost”","err-ssh":"ssh inválido (se espera user@host o alias)","err-port":"puerto inválido (1–65535)","err-ssh-port":"puerto SSH inválido (1–65535)","err-node-port":"puerto NexusCrew inválido (1–65535)","node-sessions":"{n} sesiones","tunnel-down-since":"túnel caído desde hace {t}","node-unreachable":"nodo inalcanzable","node-passive":"cliente desconectado · estado normal","node-offline":"nodo desconectado","node-offline-seen":"sin conexión · visto hace {t}","node-needs-repair":"legacy · vuelve a enlazar","asks-title":"preguntas de las celdas","ask-dismiss":"Descartar la pregunta","ask-reply-ph":"escribe la respuesta…","push-enable":"activar notificaciones push","push-disable":"desactivar notificaciones push","push-on":"push activas en este dispositivo","push-off":"push no activas","push-denied":"permiso de notificaciones denegado por el navegador","push-unsupported":"push no soportadas en este navegador","notification-speech-enable":"leer las notificaciones en voz alta","notification-speech-help":"Usa la voz del navegador solo para notificaciones nuevas mientras esta PWA está visible y en primer plano. Con la aplicación cerrada permanece la notificación del sistema.","notification-speech-test":"probar voz","notification-speech-testing":"probando voz…","notification-speech-preview":"NexusCrew. Las notificaciones por voz están activas.","notification-speech-preview-ok":"Prueba de voz completada.","notification-speech-preview-failed":"El navegador no inició la prueba de voz. Interactúa con la página y vuelve a intentarlo.","notification-speech-needs-test":"Para esta sesión de la aplicación, pulsa “probar voz” antes de recibir avisos hablados.","notification-speech-unsupported":"La síntesis de voz no está disponible en este navegador.","audio-title":"Audio nativo del nodo","audio-help":"El consentimiento y los controles valen solo para este dispositivo. Compartir y visibilidad no autorizan sonidos.","audio-consent":"permitir TTS en este nodo","audio-consent-help":"Permite que celdas autorizadas, locales o remotas, entreguen un comando de voz. Puedes revocarlo en cualquier momento.","audio-capability":"Capacidad local","audio-loading":"leyendo el estado de audio local…","audio-adapter":"adaptador","audio-adapter-none":"ninguno","audio-installed":"instalado","audio-installed-yes":"sí","audio-installed-no":"no","audio-liveness":"disponibilidad","audio-liveness-ready":"listo para aceptar","audio-liveness-unavailable":"no disponible","audio-languages":"idiomas declarados","audio-limits":"límites","audio-test":"probar audio local","audio-testing":"probando audio…","audio-stop":"detener audio local","audio-stopping":"deteniendo audio…","audio-test-needs-consent":"Activa el consentimiento local antes de probar la voz.","audio-unavailable":"No hay un adaptador TTS nativo disponible en este nodo.","audio-test-accepted":"El nodo aceptó la prueba. No demuestra que alguien la haya oído.","audio-test-refused":"El nodo rechazó la prueba.","audio-test-unknown":"Resultado de prueba desconocido: el nodo no pudo confirmar el inicio.","audio-stop-stopped":"Audio local detenido.","audio-stop-idle":"No hay enunciado local que detener.","audio-groups-title":"Grupos de audio compartido","audio-groups-help":"Decide en qué dispositivos se oye la voz cuando habla una celda. Un grupo es una preferencia local de entrega, no un consentimiento. Cada nodo conserva su consentimiento, ACL, disponibilidad y Stop local.","audio-groups-empty":"Sin grupos: la voz sale solo por este nodo.","audio-group-name":"nombre del grupo","audio-group-mode":"modo de entrega","audio-group-primary":"primero disponible (en orden)","audio-group-fanout":"todos los nodos enumerados","audio-group-targets":"nodos destino exactos","audio-group-local":"este nodo","audio-group-unavailable-target":"no detectado ahora","audio-group-no-targets":"No hay ningún nodo con instanceId disponible. Un grupo no puede usar nombres, comodines ni “todos”.","audio-group-new":"nuevo grupo","audio-group-edit":"editar","audio-group-delete":"eliminar","audio-group-save":"guardar grupo","audio-group-cancel":"cancelar","audio-group-invalid":"El grupo necesita un nombre válido y al menos un nodeId exacto.","audio-group-save-failed":"No se pudo guardar el grupo de audio.","node-display-label":"Nombre (etiqueta)","routed-node-aliases":"Alias de nodos enrutados","routed-node-aliases-help":"Visibles solo en este dispositivo; la ruta y el nombre remoto no cambian.","node-local-alias":"Alias en este dispositivo","alias-on-device":"Alias en este dispositivo","reset-alias":"Restablecer nombre remoto","node-slug-hint":"enrutado por slug: {slug}","device-name-label":"Nombre del dispositivo","device-name-hint":"cómo te ven los pares (editable)","local-route-name-label":"Nombre local / ruta","local-route-name-hint":"identificador técnico estable: etiqueta legible + sufijo del nodeId; editable antes de conectar","err-label":"etiqueta no válida (máx 64 caracteres, sin saltos de línea)","fleet-inventory":"Celdas y sesiones","fleet-inventory-help":"todas las posiciones (Local + rutas Hydra)","fleet-manage-location":"Gestionar ubicación","fleet-network-overview":"Vista de red","fleet-manage-help":"crea y configura celdas en la ubicación seleccionada","fleet-overview-help":"estado operativo de todas las ubicaciones, separado del editor","fleet-inventory-empty":"sin celdas ni sesiones","cell-switcher-refreshing":"actualizando celdas…","cell-switcher-empty-active":"no hay celdas activas verificadas","cell-switcher-not-confirmed":"estado sin confirmar","cell-switcher-not-active":"esta celda ya no está activa","cell-switcher-select":"selecciona una celda","cell-switcher-open":"abrir celda","cell-switcher-show-all":"todas","cell-switcher-show-active":"activas","cell-switcher-close":"cerrar selector de celdas","fleet-not-available":"fleet no disponible en esta posición",start:"iniciar",stop:"detener",restart:"reiniciar",delete:"eliminar","copy-manual":"copia fallida — selecciona y pulsa Cmd+C, o copia a mano","copy-empty":"nada seleccionado: arrastra con Shift para seleccionar","selection-held":"resaltado perdido, texto aún retenido","invite-hub-only":"Una invitación se acuña en el hub. Admitir un nodo nuevo es lo único que un nodo conectado no puede pedir en nombre de otro: abre NexusCrew en el hub y créala allí.","row-private":"privado","node-detail-open":"abrir el detalle","node-detail-reach":"Alcanzabilidad","node-detail-route":"ruta","node-detail-ssh":"SSH","node-detail-transport":"transporte","node-detail-owner":"propietario","node-detail-authority":"Qué puede hacer este nodo","authority-owner-equivalent":"Autoridad igual a la tuya: un nodo emparejado puede hacer en esta máquina todo lo que puedes hacer tú.","authority-routed":"No está emparejado con esta máquina: su autoridad vive en el hub que lo enruta.","authority-no-grants":"El único poder por nodo que existe es la elección de celdas, más abajo. Dentro de esas celdas la autoridad sigue siendo plena.","authority-no-grants-elsewhere":"El único poder por nodo que existe es la elección de celdas, y se configura en la instalación que las posee — no aquí.","node-detail-network-view":"Qué ve de esta red","node-detail-command":"Comando","vl-no-commands":"El dispositivo no declara comandos disponibles.","vl-events-title":"Sesión","vl-events-empty":"Ningún evento en memoria: la sesión aún no ha hablado, o lo que dijo ha salido del búfer. El historial queda en el dispositivo.","vl-events-gap":"eventos no recibidos:","vl-events-truncated":"contenido truncado por el dispositivo","vl-events-turn-end":"— fin del turno —","vl-events-done":"— fin de la respuesta —","vl-events-writer-epoch":"— cambio de escritor —","vl-events-tool":"herramienta","vl-events-tool-ok":"terminada","vl-events-tool-failed":"fallida","vl-events-usage":"consumo actualizado","vl-events-stale":"Actualización fallida: puede que no estés viendo lo último.","vl-cmd-phase-submitted":"enviado, a la espera de confirmación","vl-cmd-phase-inflight":"en curso","vl-cmd-phase-done-ok":"completado","vl-cmd-phase-done-error":"fallido","vl-cmd-status":"estado","vl-cmd-health":"salud","vl-cmd-start":"iniciar","vl-cmd-stop":"detener","vl-cmd-restart":"reiniciar","vl-cmd-version":"versión","vl-cmd-capabilities":"capacidades","vl-cmd-logs":"logs","vl-cmd-prompt":"prompt","vl-prompt-placeholder":"escribe el prompt para la sesión del dispositivo…","vl-prompt-send":"enviar prompt","vl-cmd-unpair":"desemparejar","node-grant-none":"Ningún nodo elegido: compartido, pero hacia nadie.","node-grant-unknown":"ya no está en el inventario","node-grant-remove":"quitar","node-grant-add":"Añadir un nodo","node-grant-search":"Buscar entre los nodos","node-grant-no-candidates":"Ningún nodo coincide.","cell-scope":"Celdas visibles para este nodo","cell-scope-help":"Se aplica a lo que este nodo lista y a lo que puede tocar, incluido el terminal. Dentro de las celdas concedidas sigue siendo un nodo emparejado por completo: no es un sandbox.","cell-scope-all":"todas las celdas","cell-scope-none":"ninguna celda","cell-scope-selected":"celdas seleccionadas","cell-scope-none-granted":"Ninguna celda elegida: este nodo no ve ninguna.","cell-scope-unknown":"la celda ya no existe","cell-scope-add":"Añadir una celda","cell-scope-search":"Buscar entre las celdas","cell-scope-no-candidates":"Ninguna celda coincide.","cell-scope-reset-warning":"Al cambiar de modo la lista se borra: volver a «celdas seleccionadas» obliga a elegirlas de nuevo.","cell-scope-list-unavailable":"Lista de celdas no disponible ahora: las concesiones de abajo siguen vigentes, pero no se puede saber si aún existen.","single-view":"vista única",retract:"reducir","keybar-expand":"ampliar la barra de teclas","keybar-retract":"reducir la barra de teclas","save-and-start":"guardar e iniciar",permissions:"Permisos","power-on-hint":"Detén la celda; también puedes quitarla del boot.","launch-engine-help":"Proveedores, credenciales y nuevos motores se crean en Ajustes → Flota. Modelo y permisos son por celda.","launch-unavailable-hint":"La configuración del motor no está disponible en este nodo.","import-as-cell":"Importar como celda","import-help":"Reconcilia una sesión tmux existente en una celda gestionada. Elige un motor ya declarado: no se inventa ninguno.","import-engine-required":"elige un motor (obligatorio)","test-and-connect":"probar y conectar","pairing-v2-hint":"Pega o escanea UN solo enlace: rellena nombre, Host SSH y etiqueta cuando los incluye (v2).","invite-v2-hint":"Crea una invitación de un solo uso. Hace falta la dirección SSH de este dispositivo, alcanzable por quien la use.","invite-target-local":"El nuevo dispositivo entrará en","invite-target-this":"este dispositivo","invite-endpoint-label":"Dirección SSH de este hub vista por los otros dispositivos","invite-endpoint-auto":"Endpoint ya configurado","invite-endpoint-needed":"Introduce usuario@host o un alias SSH compartido. No es 127.0.0.1 ni la URL HTTP de NexusCrew.","invite-ssh-hint":"El destino SSH con el que el OTRO dispositivo alcanza ESTA instalación (usuario@host o alias). Obligatorio: se incluye en el enlace.","invite-next-steps":"copia este enlace, abre NexusCrew en el otro dispositivo y pégalo en Ajustes → Nodos (o escanea el QR): NexusCrew hace el resto","pair-card-title":"conectar con un solo enlace","pair-card-help":"Pega el enlace de emparejamiento generado en el otro dispositivo (o escanea su QR): NexusCrew lo decodifica, prueba la conexión SSH y conecta solo.","pair-paste-ph":"pega aquí el enlace de emparejamiento","pair-paste-btn":"pegar","pair-advanced":"avanzado / editar","pair-progress":"conectando: SSH → invitación → confirmación → verificación…","pair-retry":"reintentar","pair-invalid-link":"esto no es un enlace de emparejamiento válido","pair-invalid-hint":"se necesita el enlace completo (http://…#pair=…) generado por el otro NexusCrew: no lo abras, pégalo aquí","pair-missing-ssh":"el enlace no incluye el destino SSH (formato v1): indica en “avanzado” cómo este dispositivo alcanza al otro por SSH — nunca se inventa","pair-missing-name":"falta el nombre del nodo: complétalo en “avanzado”","pair-clipboard-denied":"lectura del portapapeles no permitida: pega manualmente en el campo","pair-clipboard-empty":"portapapeles vacío: copia primero el enlace","pair-stage-validation":"datos no válidos","pair-stage-conflict":"nombre ya en uso","pair-stage-ssh-start":"fallo al iniciar el túnel SSH","pair-stage-ssh-ready":"peer inaccesible por SSH","pair-stage-join":"intercambio de invitación fallido","pair-stage-tunnel-final":"túnel negociado fallido","pair-stage-confirm":"confirmación de emparejamiento fallida","pair-stage-health":"verificación final de la federación fallida","pair-stage-internal":"error interno","pair-stage-generic":"conexión fallida","qr-no-camera":"no hay cámara disponible en este dispositivo: usa una foto del QR","qr-permission":"permiso de cámara denegado: permítelo en el navegador o usa una foto del QR","qr-unsupported":"escáner en vivo no soportado aquí: sube una foto del QR","qr-upload":"usar una foto"}};function Ol(){const e=fy(),t=e?e.getItem(hy):null;return sf.includes(t)?t:jl}function Nx(e){const t=fy();if(t)try{t.setItem(hy,e)}catch{}typeof window<"u"&&window.dispatchEvent(new Event(Vd))}function f(e){const t=Ol(),n=gl[t]||gl[jl];return Object.prototype.hasOwnProperty.call(n,e)?n[e]:Object.prototype.hasOwnProperty.call(gl[jl],e)?gl[jl][e]:e}function jx(e){return typeof window>"u"?()=>{}:(window.addEventListener(Vd,e),()=>window.removeEventListener(Vd,e))}const py=sf;function Dn(){return[E.useSyncExternalStore(jx,Ol,Ol),Nx]}function Bl({cell:e,token:t,route:n=[],onConfirm:s,onClose:o}){var D,P;Dn();const a=!!(e&&e.active),u=Array.isArray(n)?n.join("/"):"",[h,p]=E.useState([]),[m,v]=E.useState(!1);E.useEffect(()=>{let x=!0;return(async()=>{if(t)try{const M=await Rs(t,u?u.split("/"):[]);if(!x)return;if(v(M.provider==="builtin"&&(M.capabilities||[]).includes("edit")),M.provider==="builtin"&&(M.capabilities||[]).includes("definitions")){const L=await Jl(t,u?u.split("/"):[]);if(!x)return;const T=new Map((M.engines||[]).map(H=>[H.id,H]));p((L.engines||[]).map(H=>{var Y,de,ue,fe,ve,ie,ye;return{id:H.id,label:H.label||H.id,client:((Y=H.managed)==null?void 0:Y.client)||"",models:[...new Set([...((de=T.get(H.id))==null?void 0:de.models)||[],...((ue=H.managedInfo)==null?void 0:ue.models)||[]])].filter(Boolean),defaultModel:((fe=H.managed)==null?void 0:fe.model)||((ve=H.managedInfo)==null?void 0:ve.defaultModel)||"",policyDefault:((ie=H.managed)==null?void 0:ie.permissionPolicy)||((ye=H.managed)!=null&&ye.client&&H.managed.client==="claude"?"unsafe":"standard")}}))}}catch{}})(),()=>{x=!1}},[t,u]);const y=(e==null?void 0:e.engine)||((D=h[0])==null?void 0:D.id)||"",w=x=>(e==null?void 0:e.models)&&e.models[x]||"",b=x=>{const M=(e==null?void 0:e.permissionPolicies)&&e.permissionPolicies[x];if(M==="standard"||M==="unsafe")return M;const L=h.find(T=>T.id===x);return L?L.policyDefault:"standard"},[k,N]=E.useState(y),[S,j]=E.useState((e==null?void 0:e.model)||""),C=(e==null?void 0:e.permissionPolicy)==="standard"||(e==null?void 0:e.permissionPolicy)==="unsafe"?e.permissionPolicy:((P=e==null?void 0:e.permissionPolicies)==null?void 0:P[e==null?void 0:e.engine])||"",[$,O]=E.useState(C),[U,V]=E.useState((e==null?void 0:e.boot)??!0),[K,Z]=E.useState(!1),[G,Q]=E.useState(null);E.useEffect(()=>{h.length&&(N(x=>x||y),j(x=>x||w((e==null?void 0:e.engine)||y)||""),O(x=>x==="standard"||x==="unsafe"?x:b((e==null?void 0:e.engine)||y)))},[h.length]);const F=E.useMemo(()=>h.find(x=>x.id===k)||null,[h,k]),B=!!(F&&["claude","codex","codex-vl","agy","kimi"].includes(F.client)),A=(F==null?void 0:F.client)==="shell";function z(x){N(x);const M=h.find(L=>L.id===x);j(w(x)||(M==null?void 0:M.defaultModel)||""),O(b(x))}async function I(x){x.preventDefault(),Z(!0),Q(null);try{if(a)await s({action:"down",boot:U});else{const M=$==="standard"||$==="unsafe"?$:(F==null?void 0:F.policyDefault)||"standard";await s({action:"up",...m?{engine:k,model:S||"",...B?{permissionPolicy:M}:(F==null?void 0:F.client)==="pi"?{permissionPolicy:"standard"}:{}}:{},boot:U})}o()}catch(M){Q(String(M&&M.message||M)),Z(!1)}}return l.jsx("div",{className:"nc-sheet-overlay nc-launch-overlay",onClick:o,children:l.jsxs("form",{className:"nc-sheet nc-power-sheet nc-launch-sheet",onClick:x=>x.stopPropagation(),onSubmit:I,children:[l.jsxs("div",{className:"nc-sheet-head",children:[l.jsx("b",{children:e==null?void 0:e.cell}),l.jsx("span",{className:"nc-sheet-state",children:f(a?"state-on":"state-off")})]}),a?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"nc-power-config",children:[l.jsx("span",{children:f("engine")}),l.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&l.jsxs("small",{children:[f("model"),": ",e.model]}),l.jsx("small",{children:f("power-on-hint")})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:U,onChange:x=>V(x.target.checked)}),f("remove-boot")]})]}):l.jsxs(l.Fragment,{children:[m&&h.length>0?l.jsxs("div",{className:"nc-launch-fields",children:[l.jsxs("label",{className:"nc-field",children:[f("engine"),l.jsx("select",{value:k,onChange:x=>z(x.target.value),children:h.map(x=>l.jsx("option",{value:x.id,children:x.label},x.id))})]}),!A&&l.jsxs("label",{className:"nc-field",children:[f("model"),l.jsx("input",{value:S,list:"nc-launch-models",placeholder:f("model-default"),onChange:x=>j(x.target.value)}),l.jsx("datalist",{id:"nc-launch-models",children:((F==null?void 0:F.models)||[]).map(x=>l.jsx("option",{value:x},x))})]}),B?l.jsxs("label",{className:"nc-field",children:[f("permissions"),l.jsxs("select",{value:$,onChange:x=>O(x.target.value),children:[l.jsx("option",{value:"standard",children:f("fleet-standard-permissions")}),l.jsx("option",{value:"unsafe",children:f("fleet-unsafe-permissions")})]})]}):l.jsx("small",{className:"nc-note",children:f("fleet-standard-permissions")}),B&&$==="unsafe"&&l.jsx("small",{className:"nc-err",children:f("fleet-unsafe-warning")}),l.jsx("small",{className:"nc-note",children:f(A?"fleet-shell-launch-help":"launch-engine-help")})]}):l.jsxs("div",{className:"nc-power-config",children:[l.jsx("span",{children:f("engine")}),l.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&l.jsxs("small",{children:[f("model"),": ",e.model]}),l.jsx("small",{children:f("launch-unavailable-hint")})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:U,onChange:x=>V(x.target.checked)}),f("boot-persist")]})]}),G&&l.jsx("div",{className:"nc-err",children:G}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:o,disabled:K,children:f("cancel")}),l.jsx("button",{type:"submit",className:"nc-btn primary",disabled:K,children:f(a?"power-off":"save-and-start")})]})]})})}const Ag=/^[a-z0-9-]{1,32}$/;function Xo(e,t){const n=Array.isArray(e)?e:[];return n.length?`${n.map(encodeURIComponent).join("/")}:${t}`:String(t)}function Rx(e,t,n){const s={};for(const o of Array.isArray(t)?t:[]){const a=Array.isArray(o==null?void 0:o.route)?o.route:typeof(o==null?void 0:o.name)=="string"?[o.name]:[];if(!a.length)continue;const u=a.join("/"),h=o.status==="up"||o.tunnel&&o.tunnel.status==="up",p=o.status==="passive"||o.tunnel&&o.tunnel.status==="passive";!h&&!p&&(s[u]=e&&e[u]||n)}return s}function Lg(e,t,n){return!e||!Array.isArray(e.cells)?[]:e.cells.map(s=>({...s,route:t,key:`${n}:${s.tmuxSession||s.cell}`}))}function Tg({nodes:e,topology:t,remote:n,down:s,fleet:o,aliases:a}={}){var m,v,y,w;const u=[],h=new Set,p=new Set;for(const b of Array.isArray(e)?e:[]){if(!b||typeof b.name!="string"||!Ag.test(b.name)||b.direction==="inbound"&&b.shared!==!0)continue;const k=[b.name],N=b.name;h.add(N);const S=((m=b.tunnel)==null?void 0:m.status)||"unknown",j=S==="up",C={name:b.name,label:b.label||b.name,originalLabel:b.label||b.name,alias:null,route:k,direct:!0,instanceId:b.nodeId||null,shared:b.shared===!0,tunnelStatus:S,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:b.health||null,direction:b.direction||"outbound",roles:b.roles||null,rolesKnown:b.rolesKnown===!0};if(b.nodeId&&p.add(b.nodeId),!b.nodeId&&b.paired===!1){u.push({...C,status:"needs-repair",downSince:s&&s[N]||null});continue}if(((v=b.health)==null?void 0:v.auth)==="failed"||S==="degraded"&&((y=b.health)==null?void 0:y.status)==="degraded"){u.push({...C,status:"needs-repair",downSince:s&&s[N]||null});continue}if(S==="passive"||((w=b.health)==null?void 0:w.status)==="passive"){u.push({...C,status:"passive",downSince:null});continue}if(!j){u.push({...C,status:"down",downSince:s&&s[N]||null});continue}const $=n&&(n[N]||n[b.name])||null,O=o&&(o[N]||o[b.name]),U=!!($&&!$.error&&Array.isArray($.sessions)),V=!!(O&&O.available===!0&&Array.isArray(O.cells));if(!U&&!V){u.push({...C,status:"unreachable"});continue}const K=(U?$.sessions:[]).filter(Q=>Q&&typeof Q.name=="string"&&Q.name).map(Q=>({...Q,node:N,route:k,key:`${N}:${Q.name}`})),Z=Lg(O,k,N),G=new Set(Z.map(Q=>Q.tmuxSession).filter(Boolean));u.push({...C,status:"up",sessions:K,cells:Z,unmanaged:K.filter(Q=>!G.has(Q.name)),fleetAvailable:!!(O&&O.available),capabilities:O&&O.capabilities||[],engines:O&&O.engines||[],fleetProvider:O&&O.provider||null,sessionsAvailable:U,inventoryPartial:!U})}for(const b of Array.isArray(t)?t:[]){if(!b||!Array.isArray(b.route)||b.route.length<1||b.route.some(G=>!Ag.test(G)))continue;const k=b.route.join("/");if(h.has(k)||b.instanceId&&p.has(b.instanceId))continue;b.instanceId&&p.add(b.instanceId);const N=b.label||b.route.join(" › "),S=b.instanceId&&a&&typeof a[b.instanceId]=="string"?a[b.instanceId]:null,j={name:b.name,label:S||N,originalLabel:N,alias:S,route:[...b.route],direct:!1,instanceId:b.instanceId||null,shared:!0,tunnelStatus:null,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:b.health||null,lastSeen:b.lastSeen||null};if(b.stale){u.push({...j,status:"offline",downSince:s&&s[k]||b.lastSeen||null});continue}const C=n&&n[k]||null,$=o&&o[k],O=!!(C&&!C.error&&Array.isArray(C.sessions)),U=!!($&&$.available===!0&&Array.isArray($.cells));if(!O&&!U){u.push({...j,status:"unreachable",downSince:s&&s[k]||null});continue}const V=(O?C.sessions:[]).filter(G=>G&&typeof G.name=="string"&&G.name).map(G=>({...G,node:k,route:b.route,key:`${k}:${G.name}`})),K=Lg($,b.route,k),Z=new Set(K.map(G=>G.tmuxSession).filter(Boolean));u.push({...j,status:"up",sessions:V,cells:K,unmanaged:V.filter(G=>!Z.has(G.name)),fleetAvailable:!!($&&$.available),capabilities:$&&$.capabilities||[],engines:$&&$.engines||[],fleetProvider:$&&$.provider||null,lastSeen:b.lastSeen||null,sessionsAvailable:O,inventoryPartial:!O})}return u.sort((b,k)=>b.label.localeCompare(k.label))}function my(e,t={}){if(!e||typeof e!="object")return null;const n=typeof e.nodeId=="string"?e.nodeId:"";if(!n)return null;const s=typeof e.label=="string"&&e.label.trim()||typeof e.cell=="string"&&e.cell.trim()||n,o=Array.isArray(t.route)?[...t.route]:[];return{kind:"vl",nodeId:n,name:n,label:s,cell:e.cell??null,paired:!!e.pairedAt,online:!!e.online,lastSeen:e.lastSeen??null,generation:e.generation??null,version:e.version??null,health:e.health??null,session:e.session??null,capabilities:Array.isArray(e.capabilities)?e.capabilities:[],inflight:e.inflight??null,lastAck:e.lastAck??null,canManage:!!e.canManage,route:o,isLocal:o.length===0,ownerInstanceId:typeof t.instanceId=="string"?t.instanceId:null,ownerLabel:typeof t.label=="string"&&t.label?t.label:null}}function Px(e){var n;const t=[];for(const s of Array.isArray(e)?e:[]){if(!s||s.kind!=="vl"||!s.nodeId)continue;const o=s.online===!0,a=o&&((n=s.session)==null?void 0:n.attached)===!0,u=s.ownerInstanceId||"local";t.push({kind:"vl",name:`vl-${s.nodeId.slice(0,8)}`,label:s.label,route:Array.isArray(s.route)?[...s.route]:[],instanceId:null,direct:!1,status:o?"up":"offline",downSince:o?null:s.lastSeen??null,sessions:a?[{key:`vl:${u}:${s.nodeId}`,name:s.session.profile,attached:!0}]:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:s.health??null,peer:s})}return t}function gy(e,t){const n=e&&Array.isArray(e.nodes)?e.nodes:[],s=new Set([t]),o=[];for(const a of n){const u=a&&typeof a.instanceId=="string"?a.instanceId:"";if(!u||s.has(u)||a.stale===!0||!Array.isArray(a.route)||a.route.length===0)continue;s.add(u);const h=typeof a.label=="string"&&a.label||typeof a.name=="string"&&a.name||a.route.join(" › ");o.push({instanceId:u,route:[...a.route],label:h})}return o}const Ax=4e3;function rf(e,t=!0,n=0){const[s,o]=E.useState([]),a=E.useRef({});return E.useEffect(()=>{if(!t||!e){o([]);return}let u=!0;async function h(){var O;let m=[],v=[],y={},w="";if(await Promise.all([z0(e).then(U=>{m=Array.isArray(U.nodes)?U.nodes:[]}).catch(()=>{}),ay(e).then(U=>{v=Array.isArray(U.nodes)?U.nodes:[]}).catch(()=>{}),K0(e).then(U=>{y=U&&typeof U.aliasesByInstanceId=="object"?U.aliasesByInstanceId:{}}).catch(()=>{}),Kt("/api/config",e).then(U=>U.json()).then(U=>{w=U&&typeof U.instanceId=="string"?U.instanceId:""}).catch(()=>{})]),!u)return;const b=[{instanceId:w||null,route:[],label:null},...gy({nodes:v},w)],k=[];if(await Promise.all(b.map(async U=>{try{const V=await oy(e,U.route);for(const K of V.nodes||[]){const Z=my(K,U);Z&&k.push(Z)}}catch{}})),!u)return;const N={},S={},j=new Set(m.map(U=>U.name)),C=[];for(const U of m)((O=U.tunnel)==null?void 0:O.status)==="up"&&(U.nodeId||U.paired!==!1)&&(U.direction!=="inbound"||U.shared===!0)&&C.push([U.name]);for(const U of v)!U.stale&&Array.isArray(U.route)&&U.route.length>0&&!(U.route.length===1&&j.has(U.route[0]))&&C.push(U.route);if(await Promise.all(C.map(async U=>{const V=U.join("/");try{N[V]=await ef(e,U)}catch{N[V]={error:"unreachable"}}try{S[V]=await Rs(e,U)}catch{S[V]={available:!1}}})),!u)return;const $=Tg({nodes:m,topology:v,remote:N,fleet:S,aliases:y,down:a.current});a.current=Rx(a.current,$,Math.floor(Date.now()/1e3)),o([...Tg({nodes:m,topology:v,remote:N,fleet:S,aliases:y,down:a.current}),...Px(k)])}h();const p=setInterval(h,Ax);return()=>{u=!1,clearInterval(p)}},[e,t,n]),s}const Mg=52,Dg=14;function ji({position:e,itemKey:t,label:n,onMove:s,onStep:o,canMove:a=()=>!0,scope:u="roster"}){const h=E.useRef(null),p=E.useRef(0),[m,v]=E.useState(!1),y=()=>{var j,C,$,O;const S=h.current;(C=(j=S==null?void 0:S.over)==null?void 0:j.classList)==null||C.remove("nc-roster-over"),(O=($=S==null?void 0:S.source)==null?void 0:$.classList)==null||O.remove("nc-roster-dragging"),p.current&&cancelAnimationFrame(p.current),p.current=0},w=(S=!1)=>{const j=h.current;if(!j)return;const C=j.target;y(),h.current=null,v(!1);try{j.handle.releasePointerCapture(j.pointerId)}catch{}S&&C&&C!==t&&a(t,C)&&s(t,C)},b=(S,j)=>{var Z,G,Q,F,B,A,z,I,D;const C=h.current;if(!C)return;C.x=S,C.y=j;const $=u==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",O=(G=(Z=document.elementFromPoint(S,j))==null?void 0:Z.closest)==null?void 0:G.call(Z,$),U=u==="node"?(Q=O==null?void 0:O.dataset)==null?void 0:Q.nodeOrderKey:(F=O==null?void 0:O.dataset)==null?void 0:F.rosterKey,K=(u==="node"||((B=O==null?void 0:O.dataset)==null?void 0:B.position)===e)&&U&&U!==t&&a(t,U);C.over!==(K?O:null)&&((z=(A=C.over)==null?void 0:A.classList)==null||z.remove("nc-roster-over"),C.over=K?O:null,(D=(I=C.over)==null?void 0:I.classList)==null||D.add("nc-roster-over")),C.target=K?U:null},k=()=>{const S=h.current;if(!S){p.current=0;return}const j=S.container;if(j){const C=j.getBoundingClientRect(),$=S.y<C.top+Mg?-Dg:S.y>C.bottom-Mg?Dg:0;$&&(j.scrollTop+=$,b(S.x,S.y))}p.current=requestAnimationFrame(k)};E.useEffect(()=>{const S=C=>{C.key==="Escape"&&h.current&&(C.preventDefault(),w(!1))},j=()=>w(!1);return window.addEventListener("keydown",S),window.addEventListener("blur",j),()=>{window.removeEventListener("keydown",S),window.removeEventListener("blur",j),y(),h.current=null}},[t,e,u]);const N=S=>{var O;if(S.pointerType==="mouse"&&S.button!==0)return;S.preventDefault(),S.stopPropagation(),S.currentTarget.focus({preventScroll:!0});const j=u==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",C=S.currentTarget.closest(j),$=S.currentTarget.closest(".nc-side-scroll, .nc-home-scroll, .nc-cell-switcher-list");h.current={pointerId:S.pointerId,handle:S.currentTarget,source:C,container:$,target:null,over:null,x:S.clientX,y:S.clientY},(O=C==null?void 0:C.classList)==null||O.add("nc-roster-dragging");try{S.currentTarget.setPointerCapture(S.pointerId)}catch{}v(!0),p.current=requestAnimationFrame(k)};return l.jsx("button",{type:"button",className:`nc-roster-handle${m?" active":""}`,"aria-label":`${f("reorder")} ${n}`,"aria-keyshortcuts":"ArrowUp ArrowDown",title:f("reorder-help"),onClick:S=>{S.preventDefault(),S.stopPropagation()},onDragStart:S=>S.preventDefault(),onKeyDown:S=>{S.key!=="ArrowUp"&&S.key!=="ArrowDown"||(S.preventDefault(),S.stopPropagation(),o(S.key==="ArrowUp"?-1:1))},onPointerDown:N,onPointerMove:S=>{!h.current||S.pointerId!==h.current.pointerId||(S.preventDefault(),S.stopPropagation(),b(S.clientX,S.clientY))},onPointerUp:S=>{!h.current||S.pointerId!==h.current.pointerId||(S.preventDefault(),S.stopPropagation(),w(!0))},onPointerCancel:()=>w(!1),onLostPointerCapture:()=>{h.current&&w(!1)},children:"↕"})}const of="nc_pins";function Xu(){try{const e=JSON.parse(localStorage.getItem(of));return Array.isArray(e)?e:[]}catch{return[]}}function vy(e){try{return localStorage.setItem(of,JSON.stringify(e)),null}catch(t){return t instanceof Error?t:new Error(String(t))}}function Lx(e,t){const n=e.includes(t)?e.filter(s=>s!==t):[...e,t];return{next:n,error:vy(n)}}function Ig(e,t){if(!Array.isArray(e)||!e.includes(t))return{next:Array.isArray(e)?e:[],error:null};const n=e.filter(s=>s!==t);return{next:n,error:vy(n)}}function Tx(e,t,n){if(!e.includes(t)||!e.includes(n)||t===n)return e;const s=[...e],o=s.indexOf(t),a=s.indexOf(n);s.splice(o,1);const u=s.indexOf(n);s.splice(o<a?u+1:u,0,t);try{localStorage.setItem(of,JSON.stringify(s))}catch{}return s}function Mx(e,t,n){const s=e.indexOf(t);return[s===-1?1e9:s,-(n||0)]}function Dx(e,t){return e[0]-t[0]||e[1]-t[1]}function af(){const[e,t]=E.useState(Xu),[n,s]=E.useState(kx),[o,a]=E.useState(bx),[u,h]=E.useState(null),p=j=>t(C=>Lx(C,j).next),m=j=>{const C=Ig(Xu(),j);return t(C.next),h(C.error?{key:j,message:C.error.message||String(C.error)}:null),C.error},v=()=>{if(!u)return;const j=Ig(Xu(),u.key);t(j.next),h(j.error?{...u,message:j.error.message||String(j.error)}:null)},y=()=>h(null),w=j=>Rg(n,j),b=(j,C)=>s($=>{const O={...$,[j]:{...Rg($,j),...C}};return Cx(O)}),k=(j,C)=>e.includes(j)===e.includes(C);function N(j,C,$,O){const U=e.includes(C),V=e.includes($);if(U===V){if(U){t(K=>Tx(K,C,$));return}a(K=>{var Q;const Z=((Q=O.find(F=>F.key===C))==null?void 0:Q.technical)===!0,G=Cs(O,e,Z?"technical":"all",Yi(K,j)).map(F=>F.key);return Sx(xx(K,j,C,$,G))})}}function S(j,C,$,O){var Q;const U=((Q=O.find(F=>F.key===C))==null?void 0:Q.technical)===!0,V=e.includes(C),K=Cs(O,e,U?"technical":"all",Yi(o,j)).map(F=>F.key).filter(F=>e.includes(F)===V),Z=K.indexOf(C),G=K[Z+$];Z>=0&&G&&N(j,C,G,O)}return{pins:e,views:n,orders:o,togglePin:p,removePin:m,pinError:u,retryPinPersist:v,clearPinError:y,viewFor:w,updateView:b,canMoveRoster:k,moveRoster:N,stepRoster:S}}const _y="nc_node_order_v1",Ix=/^[a-f0-9]{16,64}$/;function Gs(e){if(Ix.test(String((e==null?void 0:e.instanceId)||"")))return`id:${e.instanceId}`;const t=Array.isArray(e==null?void 0:e.route)?e.route.filter(n=>typeof n=="string"&&n):[];return t.length?`route:${t.map(encodeURIComponent).join("/")}`:typeof(e==null?void 0:e.name)=="string"&&e.name?`name:${encodeURIComponent(e.name)}`:""}function Og(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(_y));return Array.isArray(t)?[...new Set(t.filter(n=>typeof n=="string"&&n&&n.length<=192))].slice(0,128):[]}catch{return[]}}function Ox(e,t=globalThis.localStorage){try{t.setItem(_y,JSON.stringify(e))}catch{}return e}function Bg(e=[],t=[]){const n=new Map(t.map((s,o)=>[s,o]));return e.map((s,o)=>({group:s,index:o})).sort((s,o)=>{const a=n.has(Gs(s.group))?n.get(Gs(s.group)):Number.MAX_SAFE_INTEGER,u=n.has(Gs(o.group))?n.get(Gs(o.group)):Number.MAX_SAFE_INTEGER;return a-u||s.index-o.index}).map(({group:s})=>s)}function Bx(e,t,n,s=[]){if(!t||!n||t===n)return e;const o=s.map(Gs).filter(Boolean);if(!o.includes(t)||!o.includes(n))return e;const a=[...e.filter(m=>o.includes(m)),...o.filter(m=>!e.includes(m))],u=a.indexOf(t),h=a.indexOf(n);a.splice(u,1);const p=a.indexOf(n);return a.splice(u<h?p+1:p,0,t),a}const Yd="nexuscrew-node-preferences";function zx(){try{window.dispatchEvent(new Event(Yd))}catch{}}function yy(){const[e,t]=E.useState(Og);E.useEffect(()=>{const a=()=>t(Og());return window.addEventListener("storage",a),window.addEventListener(Yd,a),()=>{window.removeEventListener("storage",a),window.removeEventListener(Yd,a)}},[]);const n=a=>Bg(a,e),s=(a,u,h)=>t(p=>{const m=Bx(p,a,u,h);return Ox(m),zx(),m});return{order:e,groupsFor:n,moveNode:s,stepNode:(a,u,h)=>{const p=Bg(h,e).map(Gs),m=p.indexOf(a),v=p[m+u];m>=0&&v&&s(a,v,h)},nodeKey:Gs}}const $x="none",wy="favorite",lf="live";function by({hostCell:e,pins:t=[],item:n}){const s=n&&n.value&&typeof n.value.cell=="string"?n.value.cell:null;return s!=null&&e===s?lf:Array.isArray(t)&&n&&t.includes(n.key)?wy:$x}function Sy(e){return e===lf?"clearAndUnpin":e===wy?"designate":"addPin"}const Fx=Object.freeze(["live","grace","expired","none","unavailable"]);function xy(e,t){return e!==lf||!Fx.includes(t)?null:`host-lease-${t}`}function ky({pinError:e,onRetry:t,onDismiss:n}){return e?l.jsxs("div",{className:"nc-pin-error",role:"alert",children:[l.jsx("span",{className:"nc-pin-error-text",children:"★ preferenza non salvata"}),l.jsx("button",{type:"button",className:"nc-pin-error-retry",onClick:t,children:"riprova"}),l.jsx("button",{type:"button",className:"nc-pin-error-close",onClick:n,"aria-label":"chiudi avviso",children:"×"})]}):null}function Or(e,t=Math.floor(Date.now()/1e3)){if(!e)return"";const n=t-e;return n<0||n<60?"ora":n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}g`}function qi(e){return e.status==="passive"?f("node-passive"):e.status==="down"?e.downSince?f("tunnel-down-since").replace("{t}",Or(e.downSince)):f("tunnel-down"):e.status==="unreachable"?f("node-unreachable"):e.status==="offline"?e.lastSeen?f("node-offline-seen").replace("{t}",Or(e.lastSeen)):f("node-offline"):e.status==="needs-repair"?f("node-needs-repair"):""}function Cy(e,{passive:t=null}={}){return e?e.status==="passive"?t:e.status==="healthy"?"on":"warn":null}function Vo(e){return e&&(e.detail||e.status)||""}function zl(e,t,n=globalThis.localStorage){if(!(e!=null&&e.outbox)||e.outbox.count<1)return!1;const s=Number(n.getItem(ey(t))||0);return e.outbox.latest>s}function cf(e,t={}){const n=e||{};if(!n.tmux){const s=`${n.engine||""}${n.key?`·${n.key}`:""}`,o=[s,n.model&&n.model!==s?n.model:""].filter(Boolean).join(" · ");return{working:!1,subtitle:String(o||f("cell-off")).trim()}}if(t.working===!0){const s=f("cell-working"),o=String(t.status||"").trim();return{working:!0,subtitle:!o||/^working(?:\.{3}|…)?$/i.test(o)?s:`${s} · ${o}`}}return t.working===!1?{working:!1,subtitle:f("cell-idle")}:{working:!1,subtitle:String(t.preview||n.preview||f("cell-on")).trim()}}function Ey(e,t){return[...new Set([e.engine,e.model,e.key,t.preview,e.preview,t.status].filter(Boolean).map(String))].join(" ")}function uf(e,t,n,s=globalThis.localStorage){return[...(Array.isArray(e)?e:[]).map(o=>{const a=n.get(o.tmuxSession)||{},u=Xo([],o.tmuxSession),h=cf(o,a);return{type:"cell",value:o,key:u,label:o.cell,live:!!o.tmux,fresh:zl(a,u,s),activity:a.activity||0,working:h.working,subtitle:h.subtitle,searchText:Ey(o,a)}}),...(Array.isArray(t)?t:[]).map(o=>{const a=Xo([],o.name);return{type:"session",value:o,key:a,label:o.name,live:!0,technical:o.technical===!0,fresh:zl(o,a,s),activity:o.activity||0,searchText:`${o.preview||""} ${o.cmd||""}`}})]}function $l(e,t=globalThis.localStorage){const n=e||{},s=Array.isArray(n.route)?n.route:[],o=new Map((n.sessions||[]).map(u=>[u.name,u])),a=[...(n.cells||[]).map(u=>{const h=o.get(u.tmuxSession)||{},p=Xo(s,u.tmuxSession||u.cell),m=cf(u,h);return{type:"cell",value:u,key:p,label:u.cell,live:!!u.tmux,fresh:zl(h,p,t),activity:h.activity||u.activity||0,working:m.working,subtitle:m.subtitle,searchText:Ey(u,h)}}),...(n.unmanaged||[]).map(u=>{const h=Xo(s,u.name);return{type:"session",value:u,key:h,label:u.name,live:!0,technical:u.technical===!0,fresh:zl(u,h,t),activity:u.activity||0,searchText:`${u.preview||""} ${u.cmd||""}`}})];return{route:s,rawItems:a}}const df=9,Fl=.2,Hx=/^[a-z0-9-]{1,32}(?:\/[a-z0-9-]{1,32}){0,3}$/,Br=/^[a-f0-9]{16,64}$/,Gd=e=>Hx.test(e)&&new Set(e.split("/")).size===e.split("/").length;function js(e){if(typeof e=="string"&&e){const t=e.indexOf(":");if(t<0)return{session:e};const n=e.slice(0,t),s=e.slice(t+1);return!Gd(n)||!s?null:{session:s,node:n}}if(e&&typeof e=="object"&&typeof e.session=="string"&&e.session){const t=e.ownerId===void 0?void 0:typeof e.ownerId=="string"&&Br.test(e.ownerId)?e.ownerId:null;return t===null?null:e.node===void 0||e.node===null||e.node===""?{session:e.session,...t?{ownerId:t}:{}}:typeof e.node=="string"&&Gd(e.node)?{session:e.session,node:e.node,...t?{ownerId:t}:{}}:null}return null}function Zn(e){const t=js(e);return t?t.node?`${t.node}:${t.session}`:t.session:""}const Ny=9,jy=24,na=11,Ux=e=>{const t=Number(e);return t>=Ny&&t<=jy?t:na};function Mr(){return{columns:[]}}function Ai(e){return e.columns.flatMap(t=>t.tiles.map(n=>Zn(n)))}function Wx(e){const t=[],n=Math.max(0,...e.columns.map(s=>s.tiles.length));for(let s=0;s<n;s+=1)for(const o of e.columns)o.tiles[s]&&t.push(Zn(o.tiles[s]));return t}const Ur=e=>({columns:e.columns.map(t=>({width:t.width,tiles:t.tiles.map(n=>({...n}))}))});function hf(e,t,n,s){const o=js(t);if(!o||Ai(e).includes(Zn(o))||Ai(e).length>=df)return e;const a=Ur(e),u={session:o.session,height:1,fontSize:na,...s||{}};if(o.node&&(u.node=o.node),o.ownerId&&(u.ownerId=o.ownerId),n==="end")return a.columns.push({width:1,tiles:[u]}),a;if(n&&typeof n.col=="number"&&typeof n.row=="number"&&a.columns[n.col])return a.columns[n.col].tiles.splice(n.row,0,u),a;if(n&&typeof n.col=="number"){const h=Math.max(0,Math.min(a.columns.length,n.col));return a.columns.splice(h,0,{width:1,tiles:[u]}),a}return a.columns.push({width:1,tiles:[u]}),a}function Ry(e,t){const n=Zn(t);if(!n||Ai(e).includes(n)||Ai(e).length>=df)return e;const s=Ai(e).length+1,o=Math.ceil(Math.sqrt(s));if(e.columns.length>=o){let v=0;for(let y=1;y<e.columns.length;y+=1)e.columns[y].tiles.length<e.columns[v].tiles.length&&(v=y);return hf(e,t,{col:v,row:e.columns[v].tiles.length})}const a=[...Wx(e),n],u=new Map(e.columns.flatMap(v=>v.tiles.map(y=>[Zn(y),y]))),h=js(t),p=e.columns.length?e.columns.reduce((v,y)=>v+(Number(y.width)||1),0)/e.columns.length:1,m=Array.from({length:o},(v,y)=>{var w;return{width:((w=e.columns[y])==null?void 0:w.width)||p,tiles:[]}});return a.forEach((v,y)=>{const w=js(v);if(!w)return;const b=u.get(v)||(v===n?h:{})||{},k={session:w.session,height:b.height||1,fontSize:b.fontSize||na};w.node&&(k.node=w.node),b.ownerId&&(k.ownerId=b.ownerId),b.unavailable===!0&&(k.unavailable=!0),m[y%o].tiles.push(k)}),{columns:m.filter(v=>v.tiles.length)}}function Hl(e,t){const n=Zn(t),s=Ur(e);for(const o of s.columns)o.tiles=o.tiles.filter(a=>Zn(a)!==n);return s.columns=s.columns.filter(o=>o.tiles.length>0),s}function Kx(e,t,n){const s=Zn(t);if(!Ai(e).includes(s))return e;const o=e.columns.flatMap(a=>a.tiles).find(a=>Zn(a)===s);return hf(Hl(e,s),s,n,{fontSize:o.fontSize,height:o.height,...o.ownerId?{ownerId:o.ownerId}:{},...o.unavailable===!0?{unavailable:!0}:{}})}function qx(e,t){if(!(t instanceof Map)||t.size===0)return e;let n=!1;const s=Ur(e);for(const o of s.columns)for(const a of o.tiles){const u=t.get(Zn(a));if(!u)continue;const h=js(u);h&&(a.session=h.session,h.node?a.node=h.node:delete a.node,h.ownerId&&(a.ownerId=h.ownerId),n=!0)}return n?Qs(s):e}function Vx(e,t,n){const s=Ur(e);return s.columns[t]&&(s.columns[t].width=Math.max(Fl,Number(n)||1)),s}function Yx(e,t,n,s){const o=Ur(e),a=o.columns[t]&&o.columns[t].tiles[n];return a&&(a.height=Math.max(Fl,Number(s)||1)),o}function Gx(e,t,n,s){if(!(e.columns[t]&&e.columns[t].tiles[n]))return e;const a=Ur(e),u=a.columns[t].tiles[n],h=Number(u.fontSize)||na;return u.fontSize=Math.max(Ny,Math.min(jy,h+(Number(s)||0))),a}function Xx(e,t,n,s){const o=e.columns[t];if(!o||!o.tiles[n])return null;switch(s){case"left":return{col:t};case"right":return{col:t+1};case"top":return{col:t,row:n};case"bottom":return{col:t,row:n+1};default:return null}}function zg(e){for(const t of[.25,.5,.75])if(Math.abs(e-t)<=.03)return t;return e}function Qs(e){if(!e||!Array.isArray(e.columns))return Mr();const t=e.columns.map(s=>({width:Math.max(Fl,Number(s&&s.width)||1),tiles:(Array.isArray(s&&s.tiles)?s.tiles:[]).filter(o=>o&&typeof o.session=="string"&&o.session).filter(o=>o.node==null||typeof o.node=="string"&&Gd(o.node)).filter(o=>o.ownerId==null||typeof o.ownerId=="string"&&Br.test(o.ownerId)).map(o=>{const a={session:o.session,height:Math.max(Fl,Number(o.height)||1),fontSize:Ux(o.fontSize)};return o.node!=null&&(a.node=o.node),o.ownerId!=null&&(a.ownerId=o.ownerId),o.unavailable===!0&&(a.unavailable=!0),a})})).filter(s=>s.tiles.length>0),n=new Set;for(const s of t)s.tiles=s.tiles.filter(o=>!n.has(Zn(o))&&n.add(Zn(o))&&n.size<=df);return{columns:t.filter(s=>s.tiles.length>0)}}const Py=/^[a-z0-9-]{1,32}$/,Qx=/^[A-Za-z0-9._-]{1,32}$/,Jx=/^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/,Zx=320;function Xd(e){return typeof e=="string"&&Py.test(e)}const ek=64;function zr(e){if(typeof e!="string")return!1;const t=e.trim();return t.length>0&&t.length<=ek&&!/[\x00-\x1f\x7f]/.test(t)}function Es(e){return String(e??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32).replace(/-+$/g,"")||"node"}function Ay(e){if(typeof e!="string"||!e||e.length>Zx||e.startsWith("-")||/[\0-\x20\x7f]/.test(e))return!1;if(!e.includes("@"))return/^[A-Za-z0-9][A-Za-z0-9._:-]{0,254}$/.test(e);const t=e.indexOf("@");return t<=0||t!==e.lastIndexOf("@")?!1:Qx.test(e.slice(0,t))&&Jx.test(e.slice(t+1))}function $g(e){if(e===""||e===null||e===void 0)return null;const t=String(e).trim();if(!/^[0-9]{1,5}$/.test(t))return;const n=Number(t);return Number.isInteger(n)&&n>=1&&n<=65535?n:void 0}function tk({name:e,ssh:t,sshPort:n,remotePort:s}={}){const o=typeof e=="string"?e.trim():e,a=typeof t=="string"?t.trim():t;if(!Xd(o))return{ok:!1,error:"err-node-name"};if(!Ay(a))return{ok:!1,error:"err-ssh"};const u=$g(n);if(u===void 0)return{ok:!1,error:"err-ssh-port"};const h=$g(s);if(h===void 0)return{ok:!1,error:"err-node-port"};const p={name:o,ssh:a};return u!==null&&(p.sshPort=u),h!==null&&(p.remotePort=h),{ok:!0,value:p}}function nk(e,t){if(!e||!t||t<e)return null;const n=Math.floor((t-e)/1e3);return n<60?"ora":n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}g`}function Qd(e,t){const n=!!(e&&e.status==="up"),s=!!(e&&e.status==="passive");return{up:n,...s?{passive:!0}:{},label:n?"tunnel-up":s?"node-passive":"tunnel-down",since:n?nk(e.since,t):null}}const ik=new Set(["v","instanceId","port","label","invite"]),sk=new Set(["v","instanceId","port","label","invite","name","ssh","sshPort"]);function rk(e){const t=String(e).replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),s=typeof atob=="function"?atob(n):Buffer.from(n,"base64").toString("binary"),o=Uint8Array.from(s,a=>a.charCodeAt(0));return typeof TextDecoder<"u"?new TextDecoder().decode(o):Buffer.from(o).toString("utf8")}function ok(e){let t="";try{const u=new URL(String(e));t=new URLSearchParams(u.hash.replace(/^#/,"")).get("pair")||""}catch{return{ok:!1}}if(!t)return{ok:!1};let n;try{n=JSON.parse(rk(t))}catch{return{ok:!1}}if(!n||typeof n!="object"||Array.isArray(n))return{ok:!1};const s=n.v===1?ik:n.v===2?sk:null;if(!s)return{ok:!1};for(const u of Object.keys(n))if(!s.has(u))return{ok:!1};if(!/^[a-f0-9]{16,64}$/.test(String(n.instanceId)))return{ok:!1};const o=Number(n.port);if(!Number.isInteger(o)||o<1||o>65535)return{ok:!1};if(typeof n.label!="string")return{ok:!1};if(typeof n.invite!="string"||!n.invite)return{ok:!1};const a={ok:!0,version:n.v,label:n.label,invite:n.invite,instanceId:n.instanceId,port:o};if(n.v===2){if(n.name!==void 0){if(typeof n.name!="string"||!Py.test(n.name))return{ok:!1};a.name=n.name}if(n.ssh!==void 0){if(!Ay(n.ssh))return{ok:!1};a.ssh=String(n.ssh).trim()}if(n.sshPort!==void 0){const u=Number(n.sshPort);if(!Number.isInteger(u)||u<1||u>65535)return{ok:!1};a.sshPort=u}}return a}function ak(e,t,n=new Set){if(!t||!t.ok)return e;const s={...e},o=(a,u)=>{u==null||u===""||n.has(a)||(s[a]=u)};return o("label",t.label),t.version===2&&(o("name",t.name||(t.ssh?Es(t.label):"")),o("ssh",t.ssh),t.sshPort!==void 0&&o("sshPort",String(t.sshPort))),s}const lk=["KIMI_AUTH_ACTION_REQUIRED","CLIENT_INTERACTION_REQUIRED"],ck=["kimi-code-consent-yes","kimi-code-config-custom-api-key","kimi-cli-login","client-terminal-dialog"];function ff(e){const t=e&&typeof e=="object"?e.actionRequired:null;return!t||typeof t!="object"||!lk.includes(t.code)||!ck.includes(t.recovery)?null:{code:t.code,recovery:t.recovery,text:f(`fleet-recovery-${t.recovery}`)}}let Jd={sessions:[],cells:[],nodeGroups:[],localNodeId:"",localFresh:!1,refreshedAt:0};function Fg(){return Jd}function Ly(e={}){return Jd={sessions:Array.isArray(e.sessions)?e.sessions:[],cells:Array.isArray(e.cells)?e.cells:[],nodeGroups:Array.isArray(e.nodeGroups)?e.nodeGroups:[],localNodeId:typeof e.localNodeId=="string"?e.localNodeId:"",localFresh:e.localFresh===!0,refreshedAt:Number.isFinite(e.refreshedAt)?e.refreshedAt:0},Jd}const Nr=(e,t=[])=>`${t.length?t.join("/"):"local"}:${e}`;function uk({onPick:e,token:t,onSettings:n,onOpenVlSession:s,hostCell:o=null,hostLease:a=null,onDesignateCell:u,onClearHostCell:h}){const[p,m]=Dn(),v=rf(t),[y,w]=E.useState(null),[b,k]=E.useState(null),[N,S]=E.useState(""),[j,C]=E.useState(""),[$,O]=E.useState({bind:"127.0.0.1",port:""}),[U,V]=E.useState(""),[K,Z]=E.useState([]),[G,Q]=E.useState([]),[F,B]=E.useState({}),[A,z]=E.useState(new Set),[I,D]=E.useState(null),[P,x]=E.useState(null),{pins:M,orders:L,togglePin:T,removePin:H,pinError:Y,retryPinPersist:de,clearPinError:ue,viewFor:fe,updateView:ve,canMoveRoster:ie,moveRoster:ye,stepRoster:Ue}=af();function ut(W,oe,pe,_e){if(_e!=="local"){T(W.key);return}const Be=Sy(pe);if(Be==="addPin"){T(W.key);return}if(Be==="designate"){u&&u(oe.cell);return}if(Be==="clearAndUnpin"){if(!h)return;Promise.resolve(h()).then(me=>{me&&H(W.key)})}}const{groupsFor:rt,moveNode:Ae,stepNode:Dt,nodeKey:Qt}=yy(),$e=rt(v);E.useEffect(()=>{Ly({sessions:y||[],cells:K,nodeGroups:v,localNodeId:U})},[y,K,v,U]),E.useEffect(()=>{const W=new Map;for(const oe of K)W.set(Nr(oe.cell),!!oe.boot);for(const oe of v){const pe=oe.route||[oe.name];for(const _e of oe.cells||[])W.set(Nr(_e.cell,pe),!!_e.boot)}B(oe=>{let pe=!1;const _e={...oe};for(const[Be,me]of Object.entries(oe))W.has(Be)&&W.get(Be)===me&&(delete _e[Be],pe=!0);return pe?_e:oe})},[K,v]);async function dt(){try{const oe=await(await Kt("/api/sessions",t)).json();oe.error?(k(oe.error),w([])):(k(null),w(oe.sessions||[]))}catch(W){k(String(W)),w([])}try{const W=await Rs(t);Z(W.available?W.cells||[]:[]),Q(W.available?W.capabilities||[]:[])}catch{Z([]),Q([])}}E.useEffect(()=>{dt(),Kt("/api/config",t).then(oe=>oe.json()).then(oe=>{C(oe.version||""),O({bind:oe.bind||"127.0.0.1",port:oe.port||""}),V(Br.test(String(oe.instanceId||""))?oe.instanceId:"")}).catch(()=>{});const W=setInterval(dt,4e3);return()=>clearInterval(W)},[]);async function it(){if(!$.port)return;const W=`http://${$.bind}:${$.port}/#token=${t}`;try{await navigator.clipboard.writeText(W)}catch{}}function wt(W,oe,pe){const _e=Nr(W,oe);B(Be=>({...Be,[_e]:!!pe}))}function bt(W,oe=[]){const pe=Nr(W.cell,oe);return Object.prototype.hasOwnProperty.call(F,pe)?F[pe]:!!W.boot}async function mt(W,oe,pe=[]){W.stopPropagation();const _e=Nr(oe.cell,pe),Be=!bt(oe,pe);wt(oe.cell,pe,Be),z(me=>new Set(me).add(_e));try{await ty(t,{cell:oe.cell,enabled:Be},pe),pe.length||Z(me=>me.map(Ce=>Ce.cell===oe.cell?{...Ce,boot:Be}:Ce))}catch(me){B(Ce=>{const Ge={...Ce};return delete Ge[_e],Ge}),k(String((me==null?void 0:me.message)||me))}finally{z(me=>{const Ce=new Set(me);return Ce.delete(_e),Ce})}}async function gt(W){if(!I)return;const{cell:oe}=I,pe=Array.isArray(I.route)?I.route:[];if(W.action==="up"){const _e=await Qh(t,{cell:oe,boot:!!W.boot,...W.engine?{engine:W.engine}:{},...W.model!==void 0?{model:W.model}:{},...W.permissionPolicy?{permissionPolicy:W.permissionPolicy}:{}},pe),Be=ff(_e);Be&&k(Be.text),wt(oe,pe,!!W.boot)}else await Il(t,{cell:oe,boot:!!W.boot},pe),W.boot&&wt(oe,pe,!1);dt()}async function pt(W,oe=[]){try{await Jh(t,W,oe)}catch{return}dt()}async function Pt(W,oe,pe=[]){try{await sy(t,W,oe,pe)}catch{return}dt()}async function vt(W){if(!(!(W!=null&&W.direct)||P)){x(W.name);try{await nf(t,W.name,W.tunnelStatus==="up"?"down":"up")}catch{}x(null)}}async function xt(W){if(!(W!=null&&W.direct))return;const oe=window.prompt(f("rename-node-prompt"),W.label||W.name);if(oe===null)return;const pe=String(oe).trim();if(!zr(pe)){window.alert(f("rename-node-invalid"));return}try{await ly(t,W.name,pe)}catch(_e){window.alert(String((_e==null?void 0:_e.message)||_e))}}const Se=E.useMemo(()=>new Map((y||[]).map(W=>[W.name,W])),[y]),le=E.useMemo(()=>new Set(K.map(W=>W.tmuxSession)),[K]),Pe=E.useMemo(()=>(y||[]).filter(W=>!le.has(W.name)),[y,le]),We=E.useMemo(()=>uf(K,Pe,Se),[K,Pe,Se]),te=fe("local"),we=E.useMemo(()=>Cs(We,M,te.filter,Yi(L,"local")).filter(W=>Pg(W,N)),[We,M,te.filter,N,L]),Ne=$e.reduce((W,oe)=>W+(oe.cells||[]).length+(oe.unmanaged||[]).filter(pe=>!pe.technical).length,0),De=Cs(We,M,"all",Yi(L,"local")).length+Ne,Oe=We.filter(W=>W.live).length+$e.reduce((W,oe)=>W+$l(oe).rawItems.filter(pe=>pe.live).length,0),_t=(y||[]).filter(W=>W.attached).length+$e.reduce((W,oe)=>W+(oe.sessions||[]).filter(pe=>pe.attached).length,0),yt=Math.min(_t,Oe),X=$.port?`${$.bind}:${$.port}`:$.bind;function se(W,oe=null,pe=We){var bn,Ct;const _e=Array.isArray(oe==null?void 0:oe.route)?oe.route:[],Be=_e.join("/"),me=Be||"local",Ce=_e.length?oe==null?void 0:oe.instanceId:U,Ge=(Xe,Jt)=>e({session:Xe,...Be?{node:Be}:{},...Br.test(String(Ce||""))?{ownerId:Ce}:{},...typeof Jt=="string"&&Jt?{cellName:Jt}:{}}),rn=ie;if(W.type==="cell"){const Xe=W.value,Jt=me==="local"?by({hostCell:o,pins:M,item:W}):M.includes(W.key)?"favorite":"none",dn=_e.length?((oe==null?void 0:oe.sessions)||[]).find(An=>An.name===Xe.tmuxSession):Se.get(Xe.tmuxSession),qn=me==="local"?xy(Jt,a):null,ce=Xe.degraded?f("cell-degraded"):W.working?W.subtitle:Xe.tmux?f("cell-idle"):f("cell-off"),je=qn?`${ce} · ${f(qn)}`:ce,qe=_e.length===0||((oe==null?void 0:oe.capabilities)||[]).includes(Xe.active?"down":"up"),ot=_e.length===0?G.includes("boot"):((oe==null?void 0:oe.capabilities)||[]).includes("boot"),Vt=bt(Xe,_e),Nt=Nr(Xe.cell,_e),Qi=`${f(Vt?"boot-disable":"boot-enable")} ${Xe.cell}`;return l.jsxs("div",{className:"nc-mcard","data-roster-key":W.key,"data-position":me,children:[l.jsx(ji,{position:me,itemKey:W.key,label:Xe.cell,canMove:rn,onMove:(An,Di)=>ye(me,An,Di,pe),onStep:An=>Ue(me,W.key,An,pe)}),l.jsxs("button",{className:"nc-mcard-main",onClick:()=>Xe.tmux&&Ge(Xe.tmuxSession,Xe.cell),title:je,"aria-label":`${Xe.cell}, ${je}`,children:[l.jsx("span",{className:`dot ${Xe.degraded?"warn":Xe.tmux?`on${W.working?" working":""}`:""}`}),l.jsxs("span",{className:"nc-mcard-text",children:[l.jsx("b",{children:Xe.cell}),l.jsx("small",{title:W.subtitle,children:W.subtitle})]})]}),W.activity?l.jsx("span",{className:"nc-rel",children:Or(W.activity)}):null,W.fresh&&((bn=dn==null?void 0:dn.outbox)==null?void 0:bn.count)>0&&l.jsx("span",{className:"nc-badge",title:f("new-files-outbox"),children:dn.outbox.count}),l.jsx("button",{className:`nc-act pin${Jt==="live"?" live":Jt==="favorite"?" on":""}`,"aria-label":`${Jt==="live"?"live host":f("pin")} ${Xe.cell}`,title:Jt==="live"?"live host":f("pin"),onClick:()=>ut(W,Xe,Jt,me),children:Jt==="none"?"☆":"★"}),ot&&l.jsx("button",{className:`nc-act boot${Vt?" on":""}`,disabled:A.has(Nt),onClick:An=>mt(An,Xe,_e),title:Qi,"aria-label":Qi,children:l.jsx(nt,{name:"boot",size:16})}),qe&&l.jsx("button",{className:`nc-act power${Xe.tmux?" on":""}${Xe.degraded?" warn":""}`,onClick:()=>D(_e.length?{...Xe,boot:Vt,route:_e,availableEngines:(oe==null?void 0:oe.engines)||[]}:{...Xe,boot:Vt}),title:Xe.active?f("power-off"):f("power-on"),"aria-label":`${Xe.active?f("power-off"):f("power-on")} ${Xe.cell}`,children:l.jsx(nt,{name:"power",size:16})})]},W.key)}const tt=W.value;return l.jsxs("div",{className:"nc-mcard","data-roster-key":W.key,"data-position":me,children:[l.jsx(ji,{position:me,itemKey:W.key,label:tt.name,canMove:rn,onMove:(Xe,Jt)=>ye(me,Xe,Jt,pe),onStep:Xe=>Ue(me,W.key,Xe,pe)}),l.jsxs("button",{className:"nc-mcard-main",onClick:()=>Ge(tt.name),children:[l.jsx("span",{className:tt.attached?"dot on":"dot"}),l.jsxs("span",{className:"nc-mcard-text",children:[l.jsx("b",{children:tt.name}),l.jsx("small",{children:tt.preview?tt.preview:tt.cmd?tt.cmd:f("windows").replace("{n}",String(tt.windows||0))})]})]}),W.activity?l.jsx("span",{className:"nc-rel",children:Or(W.activity)}):null,W.fresh&&((Ct=tt.outbox)==null?void 0:Ct.count)>0&&l.jsx("span",{className:"nc-badge",title:f("new-files-outbox"),children:tt.outbox.count}),l.jsx("button",{className:`nc-act pin${M.includes(W.key)?" on":""}`,"aria-label":`${f("pin")} ${tt.name}`,title:f("pin"),onClick:()=>T(W.key),children:M.includes(W.key)?"★":"☆"}),l.jsx("button",{className:`nc-act technical${tt.technical?" on":""}`,title:tt.technical?f("mark-normal"):f("mark-technical"),"aria-label":`${tt.technical?f("mark-normal"):f("mark-technical")} ${tt.name}`,onClick:()=>Pt(tt.name,!tt.technical,_e),children:"T"}),l.jsx("button",{className:"nc-menu",title:f("terminate"),"aria-label":`${f("terminate")} ${tt.name}`,onClick:()=>{window.confirm(f("terminate-confirm").replace("{name}",tt.name))&&pt(tt.name,_e)},children:"⋯"})]},W.key)}return l.jsxs("div",{className:"nc-home",children:[l.jsxs("header",{className:"nc-home-head",children:[l.jsxs("div",{className:"nc-wordmark",children:["NexusCrew",l.jsx("span",{className:"nc-cursor"})]}),l.jsxs("div",{className:"nc-home-sub",children:[f("fleet-tmux")," · ",Oe," ",f("sessions"),yt>0&&` · ${yt} attached`]}),l.jsxs("span",{className:"nc-head-actions",children:[l.jsx("button",{className:"nc-refresh",onClick:()=>n("nodes",!1),title:f("settings"),children:l.jsx(nt,{name:"gear",size:18})}),l.jsx("button",{className:"nc-refresh",onClick:dt,title:f("refresh"),children:l.jsx(nt,{name:"refresh",size:18})})]})]}),l.jsxs("main",{className:"nc-home-scroll",children:[l.jsx(ky,{pinError:Y,onRetry:de,onDismiss:ue}),De>8&&l.jsx("input",{className:"nc-filter",type:"search",placeholder:f("filter-placeholder"),"aria-label":f("filter-placeholder"),value:N,onChange:W=>S(W.target.value)}),b&&l.jsx("div",{className:"nc-err",children:b}),l.jsxs("section",{className:"nc-group","data-position":"local",children:[l.jsx(Qu,{label:f("position-local"),count:we.length,state:te,dotClass:"on",onToggle:()=>ve("local",{open:!te.open}),onFilter:W=>ve("local",{filter:W})}),te.open&&we.map(W=>se(W,null,We)),te.open&&y===null&&l.jsx("div",{className:"nc-empty",children:f("loading-fleet")}),te.open&&y!==null&&we.length===0&&!b&&l.jsx("div",{className:"nc-empty",children:N?f("no-match").replace("{q}",N):f("no-sessions-short")})]}),$e.map(W=>{const pe=Cy(W.health,{passive:"warn"})||(W.status==="up"?"on":W.status==="passive"?"":"warn"),_e=W.health?Vo(W.health):W.status==="up"?"":qi(W),me=(W.route&&W.route.length?W.route:[W.name]).join("/"),Ce=fe(me);if(W.kind==="vl")return l.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":me,"data-node-order-key":Qt(W),children:[l.jsx(Qu,{label:W.label||W.name,count:W.sessions.length,state:Ce,dotClass:pe,dotTitle:_e,detail:W.status==="up"?"":qi(W),onToggle:()=>ve(me,{open:!Ce.open}),onFilter:Ct=>ve(me,{filter:Ct})}),W.status==="up"&&Ce.open&&W.sessions.map(Ct=>l.jsx("div",{className:"nc-mcard nc-vl-session-row",children:l.jsxs("button",{className:"nc-mcard-main",onClick:()=>s&&s(W.peer),"aria-label":`${W.label||W.name}: ${Ct.name}`,children:[l.jsx("span",{className:"dot on"}),l.jsxs("span",{className:"nc-mcard-text",children:[l.jsx("b",{children:Ct.name}),l.jsx("small",{children:f("vl-events-title")})]})]})},Ct.key)),W.status==="up"&&Ce.open&&W.sessions.length===0&&l.jsx("div",{className:"nc-empty",children:f("no-sessions-short")})]},`nodo-vl-${me}-${W.name}`);const{rawItems:Ge}=$l(W),rn=Cs(Ge,M,Ce.filter,Yi(L,me)).filter(Ct=>Pg(Ct,N)),tt=W.direct&&W.health&&W.health.managed!==!1?l.jsx("button",{type:"button",className:`nc-act power${W.tunnelStatus==="up"?" on":""}`,disabled:P===W.name,title:W.tunnelStatus==="up"?f("power-off"):f("power-on"),"aria-label":`${W.tunnelStatus==="up"?f("power-off"):f("power-on")} ${W.label||W.name}`,onClick:()=>vt(W),children:l.jsx(nt,{name:"power",size:15})}):null,bn=l.jsxs("span",{className:"nc-node-actions",children:[l.jsx(ji,{scope:"node",position:"nodes",itemKey:Qt(W),label:W.label||W.name,onMove:(Ct,Xe)=>Ae(Ct,Xe,v),onStep:Ct=>Dt(Qt(W),Ct,v)}),W.direct&&l.jsx("button",{type:"button",className:"nc-node-rename",title:f("rename-node"),"aria-label":`${f("rename-node")} ${W.label||W.name}`,onClick:()=>xt(W),children:"✎"}),tt]});return l.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":me,"data-node-order-key":Qt(W),children:[l.jsx(Qu,{label:W.label||W.name,count:rn.length,state:Ce,dotClass:pe,dotTitle:_e,detail:W.status==="up"?"":W.health&&Vo(W.health)||qi(W),onToggle:()=>ve(me,{open:!Ce.open}),onFilter:Ct=>ve(me,{filter:Ct}),onRename:W.direct?()=>xt(W):null,action:bn}),W.status==="up"&&Ce.open&&rn.map(Ct=>se(Ct,W,Ge)),W.status==="up"&&Ce.open&&rn.length===0&&l.jsx("div",{className:"nc-empty",children:N?f("no-match").replace("{q}",N):f("no-sessions-short")})]},`nodo-${me}`)}),l.jsxs("footer",{className:"nc-home-foot",onClick:it,title:f("copy-url"),children:[l.jsxs("span",{className:"nc-home-meta",children:[j&&l.jsxs("span",{className:"nc-home-version",children:["v",j]}),l.jsxs("span",{className:"nc-home-endpoint",children:[X," · ",f("ssh-only")]})]}),l.jsx("span",{className:"nc-lang",onClick:W=>W.stopPropagation(),children:py.map((W,oe)=>l.jsxs("span",{children:[oe>0&&" · ",l.jsx("button",{className:`nc-lang-btn${p===W?" on":""}`,onClick:()=>m(W),title:W,children:W.toUpperCase()})]},W))})]})]}),l.jsx("button",{className:"nc-fab",onClick:()=>n("fleet",!0),title:f("fleet-new-cell"),"aria-label":f("fleet-new-cell"),children:"+"}),I&&l.jsx(Bl,{cell:I,token:t,route:Array.isArray(I.route)?I.route:[],onConfirm:gt,onClose:()=>D(null)})]})}function Qu({label:e,count:t,state:n,dotClass:s="",dotTitle:o="",detail:a="",onToggle:u,onFilter:h,onRename:p=null,action:m=null}){return l.jsxs("div",{className:"nc-mobile-position-head",onContextMenu:p?v=>{v.preventDefault(),p()}:void 0,children:[l.jsxs("button",{type:"button",className:"nc-mobile-position-toggle",onClick:u,"aria-expanded":n.open,"aria-label":`${e} · ${f("node-sessions").replace("{n}",String(t))}`,children:[l.jsx("span",{className:"nc-mobile-chevron","aria-hidden":"true",children:n.open?"⌄":"›"}),l.jsx("span",{className:`dot ${s}`,title:o}),l.jsxs("span",{className:"nc-mobile-position-copy",children:[l.jsx("b",{children:e}),l.jsx("small",{children:a||f("node-sessions").replace("{n}",String(t))})]})]}),l.jsxs("select",{className:"nc-mobile-position-filter",value:n.filter,"aria-label":`${e} · ${f("filter-placeholder")}`,title:f(`view-${n.filter}`),onChange:v=>h(v.target.value),children:[l.jsx("option",{value:"all",children:f("view-all")}),l.jsx("option",{value:"pinned",children:f("view-pinned")}),l.jsx("option",{value:"active",children:f("view-active")}),l.jsx("option",{value:"off",children:f("view-off")}),l.jsx("option",{value:"technical",children:f("view-technical")})]}),m]})}/**
|
|
41
|
-
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
42
|
-
* @license MIT
|
|
43
|
-
*
|
|
44
|
-
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
|
45
|
-
* @license MIT
|
|
46
|
-
*
|
|
47
|
-
* Originally forked from (with the author's permission):
|
|
48
|
-
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
49
|
-
* http://bellard.org/jslinux/
|
|
50
|
-
* Copyright (c) 2011 Fabrice Bellard
|
|
51
|
-
*/var Ty=Object.defineProperty,dk=Object.getOwnPropertyDescriptor,hk=(e,t)=>{for(var n in t)Ty(e,n,{get:t[n],enumerable:!0})},qt=(e,t,n,s)=>{for(var o=s>1?void 0:s?dk(t,n):t,a=e.length-1,u;a>=0;a--)(u=e[a])&&(o=(s?u(t,n,o):u(o))||o);return s&&o&&Ty(t,n,o),o},Te=(e,t)=>(n,s)=>t(n,s,e),Hg="Terminal input",Zd={get:()=>Hg,set:e=>Hg=e},Ug="Too much output to announce, navigate to rows manually to read",eh={get:()=>Ug,set:e=>Ug=e};function fk(e){return e.replace(/\r?\n/g,"\r")}function pk(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function mk(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function gk(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");My(o,t,n,s)}}function My(e,t,n,s){e=fk(e),e=pk(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function Dy(e,t,n){let s=n.getBoundingClientRect(),o=e.clientX-s.left-10,a=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${a}px`,t.style.zIndex="1000",t.focus()}function Wg(e,t,n,s,o){Dy(e,t,n),o&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Ss(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function ec(e,t=0,n=e.length){let s="";for(let o=t;o<n;++o){let a=e[o];a>65535?(a-=65536,s+=String.fromCharCode((a>>10)+55296)+String.fromCharCode(a%1024+56320)):s+=String.fromCharCode(a)}return s}var vk=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let s=0,o=0;if(this._interim){let a=e.charCodeAt(o++);56320<=a&&a<=57343?t[s++]=(this._interim-55296)*1024+a-56320+65536:(t[s++]=this._interim,t[s++]=a),this._interim=0}for(let a=o;a<n;++a){let u=e.charCodeAt(a);if(55296<=u&&u<=56319){if(++a>=n)return this._interim=u,s;let h=e.charCodeAt(a);56320<=h&&h<=57343?t[s++]=(u-55296)*1024+h-56320+65536:(t[s++]=u,t[s++]=h);continue}u!==65279&&(t[s++]=u)}return s}},_k=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let s=0,o,a,u,h,p=0,m=0;if(this.interim[0]){let w=!1,b=this.interim[0];b&=(b&224)===192?31:(b&240)===224?15:7;let k=0,N;for(;(N=this.interim[++k]&63)&&k<4;)b<<=6,b|=N;let S=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,j=S-k;for(;m<j;){if(m>=n)return 0;if(N=e[m++],(N&192)!==128){m--,w=!0;break}else this.interim[k++]=N,b<<=6,b|=N&63}w||(S===2?b<128?m--:t[s++]=b:S===3?b<2048||b>=55296&&b<=57343||b===65279||(t[s++]=b):b<65536||b>1114111||(t[s++]=b)),this.interim.fill(0)}let v=n-4,y=m;for(;y<n;){for(;y<v&&!((o=e[y])&128)&&!((a=e[y+1])&128)&&!((u=e[y+2])&128)&&!((h=e[y+3])&128);)t[s++]=o,t[s++]=a,t[s++]=u,t[s++]=h,y+=4;if(o=e[y++],o<128)t[s++]=o;else if((o&224)===192){if(y>=n)return this.interim[0]=o,s;if(a=e[y++],(a&192)!==128){y--;continue}if(p=(o&31)<<6|a&63,p<128){y--;continue}t[s++]=p}else if((o&240)===224){if(y>=n)return this.interim[0]=o,s;if(a=e[y++],(a&192)!==128){y--;continue}if(y>=n)return this.interim[0]=o,this.interim[1]=a,s;if(u=e[y++],(u&192)!==128){y--;continue}if(p=(o&15)<<12|(a&63)<<6|u&63,p<2048||p>=55296&&p<=57343||p===65279)continue;t[s++]=p}else if((o&248)===240){if(y>=n)return this.interim[0]=o,s;if(a=e[y++],(a&192)!==128){y--;continue}if(y>=n)return this.interim[0]=o,this.interim[1]=a,s;if(u=e[y++],(u&192)!==128){y--;continue}if(y>=n)return this.interim[0]=o,this.interim[1]=a,this.interim[2]=u,s;if(h=e[y++],(h&192)!==128){y--;continue}if(p=(o&7)<<18|(a&63)<<12|(u&63)<<6|h&63,p<65536||p>1114111)continue;t[s++]=p}}return s}},Iy="",ks=" ",ia=class Oy{constructor(){this.fg=0,this.bg=0,this.extended=new Ul}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new Oy;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Ul=class By{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new By(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},di=class zy extends ia{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Ul,this.combinedData=""}static fromCharData(t){let n=new zy;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Ss(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(s-55296)*1024+o-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Kg="di$target",th="di$dependencies",Ju=new Map;function yk(e){return e[th]||[]}function wn(e){if(Ju.has(e))return Ju.get(e);let t=function(n,s,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");wk(t,n,o)};return t._id=e,Ju.set(e,t),t}function wk(e,t,n){t[Kg]===t?t[th].push({id:e,index:n}):(t[th]=[{id:e,index:n}],t[Kg]=t)}var In=wn("BufferService"),$y=wn("CoreMouseService"),tr=wn("CoreService"),bk=wn("CharsetService"),pf=wn("InstantiationService"),Fy=wn("LogService"),On=wn("OptionsService"),Hy=wn("OscLinkService"),Sk=wn("UnicodeService"),sa=wn("DecorationService"),nh=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){var v;let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let s=[],o=this._optionsService.rawOptions.linkHandler,a=new di,u=n.getTrimmedLength(),h=-1,p=-1,m=!1;for(let y=0;y<u;y++)if(!(p===-1&&!n.hasContent(y))){if(n.loadCell(y,a),a.hasExtendedAttrs()&&a.extended.urlId)if(p===-1){p=y,h=a.extended.urlId;continue}else m=a.extended.urlId!==h;else p!==-1&&(m=!0);if(m||p!==-1&&y===u-1){let w=(v=this._oscLinkService.getLinkData(h))==null?void 0:v.uri;if(w){let b={start:{x:p+1,y:e},end:{x:y+(!m&&y===u-1?1:0),y:e}},k=!1;if(!(o!=null&&o.allowNonHttpProtocols))try{let N=new URL(w);["http:","https:"].includes(N.protocol)||(k=!0)}catch{k=!0}k||s.push({text:w,range:b,activate:(N,S)=>o?o.activate(N,S,b):xk(N,S),hover:(N,S)=>{var j;return(j=o==null?void 0:o.hover)==null?void 0:j.call(o,N,S,b)},leave:(N,S)=>{var j;return(j=o==null?void 0:o.leave)==null?void 0:j.call(o,N,S,b)}})}m=!1,a.hasExtendedAttrs()&&a.extended.urlId?(p=y,h=a.extended.urlId):(p=-1,h=-1)}}t(s)}};nh=qt([Te(0,In),Te(1,On),Te(2,Hy)],nh);function xk(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
52
|
-
|
|
53
|
-
WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var tc=wn("CharSizeService"),Gi=wn("CoreBrowserService"),mf=wn("MouseService"),Xi=wn("RenderService"),kk=wn("SelectionService"),Uy=wn("CharacterJoinerService"),Wr=wn("ThemeService"),Wy=wn("LinkProviderService"),Ck=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?qg.isErrorNoTelemetry(e)?new qg(e.message+`
|
|
54
|
-
|
|
55
|
-
`+e.stack):new Error(e.message+`
|
|
56
|
-
|
|
57
|
-
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},Ek=new Ck;function Rl(e){Nk(e)||Ek.onUnexpectedError(e)}var ih="Canceled";function Nk(e){return e instanceof jk?!0:e instanceof Error&&e.name===ih&&e.message===ih}var jk=class extends Error{constructor(){super(ih),this.name=this.message}};function Rk(e){return new Error(`Illegal argument: ${e}`)}var qg=class sh extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof sh)return t;let n=new sh;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},rh=class Ky extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Ky.prototype)}};function Qn(e,t=0){return e[e.length-(1+t)]}var Pk;(e=>{function t(a){return a<0}e.isLessThan=t;function n(a){return a<=0}e.isLessThanOrEqual=n;function s(a){return a>0}e.isGreaterThan=s;function o(a){return a===0}e.isNeitherLessOrGreaterThan=o,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Pk||(Pk={}));function Ak(e,t){let n=this,s=!1,o;return function(){return s||(s=!0,t||(o=e.apply(n,arguments))),o}}var qy;(e=>{function t(O){return O&&typeof O=="object"&&typeof O[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*o(O){yield O}e.single=o;function a(O){return t(O)?O:o(O)}e.wrap=a;function u(O){return O||n}e.from=u;function*h(O){for(let U=O.length-1;U>=0;U--)yield O[U]}e.reverse=h;function p(O){return!O||O[Symbol.iterator]().next().done===!0}e.isEmpty=p;function m(O){return O[Symbol.iterator]().next().value}e.first=m;function v(O,U){let V=0;for(let K of O)if(U(K,V++))return!0;return!1}e.some=v;function y(O,U){for(let V of O)if(U(V))return V}e.find=y;function*w(O,U){for(let V of O)U(V)&&(yield V)}e.filter=w;function*b(O,U){let V=0;for(let K of O)yield U(K,V++)}e.map=b;function*k(O,U){let V=0;for(let K of O)yield*U(K,V++)}e.flatMap=k;function*N(...O){for(let U of O)yield*U}e.concat=N;function S(O,U,V){let K=V;for(let Z of O)K=U(K,Z);return K}e.reduce=S;function*j(O,U,V=O.length){for(U<0&&(U+=O.length),V<0?V+=O.length:V>O.length&&(V=O.length);U<V;U++)yield O[U]}e.slice=j;function C(O,U=Number.POSITIVE_INFINITY){let V=[];if(U===0)return[V,O];let K=O[Symbol.iterator]();for(let Z=0;Z<U;Z++){let G=K.next();if(G.done)return[V,e.empty()];V.push(G.value)}return[V,{[Symbol.iterator](){return K}}]}e.consume=C;async function $(O){let U=[];for await(let V of O)U.push(V);return Promise.resolve(U)}e.asyncToArray=$})(qy||(qy={}));function Zs(e){if(qy.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Lk(...e){return Bt(()=>Zs(e))}function Bt(e){return{dispose:Ak(()=>{e()})}}var Vy=class Yy{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{Zs(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Yy.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};Vy.DISABLE_DISPOSED_WARNING=!1;var Ns=Vy,lt=class{constructor(){this._store=new Ns,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)}};lt.None=Object.freeze({dispose(){}});var $r=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Vi=typeof window=="object"?window:globalThis,oh=class ah{constructor(t){this.element=t,this.next=ah.Undefined,this.prev=ah.Undefined}};oh.Undefined=new oh(void 0);var Ft=oh,Vg=class{constructor(){this._first=Ft.Undefined,this._last=Ft.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Ft.Undefined}clear(){let e=this._first;for(;e!==Ft.Undefined;){let t=e.next;e.prev=Ft.Undefined,e.next=Ft.Undefined,e=t}this._first=Ft.Undefined,this._last=Ft.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new Ft(e);if(this._first===Ft.Undefined)this._first=n,this._last=n;else if(t){let o=this._last;this._last=n,n.prev=o,o.next=n}else{let o=this._first;this._first=n,n.next=o,o.prev=n}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(n))}}shift(){if(this._first!==Ft.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Ft.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Ft.Undefined&&e.next!==Ft.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Ft.Undefined&&e.next===Ft.Undefined?(this._first=Ft.Undefined,this._last=Ft.Undefined):e.next===Ft.Undefined?(this._last=this._last.prev,this._last.next=Ft.Undefined):e.prev===Ft.Undefined&&(this._first=this._first.next,this._first.prev=Ft.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Ft.Undefined;)yield e.element,e=e.next}},Tk=globalThis.performance&&typeof globalThis.performance.now=="function",Mk=class Gy{static create(t){return new Gy(t)}constructor(t){this._now=Tk&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Cn;(e=>{e.None=()=>lt.None;function t(B,A){return y(B,()=>{},0,void 0,!0,void 0,A)}e.defer=t;function n(B){return(A,z=null,I)=>{let D=!1,P;return P=B(x=>{if(!D)return P?P.dispose():D=!0,A.call(z,x)},null,I),D&&P.dispose(),P}}e.once=n;function s(B,A,z){return m((I,D=null,P)=>B(x=>I.call(D,A(x)),null,P),z)}e.map=s;function o(B,A,z){return m((I,D=null,P)=>B(x=>{A(x),I.call(D,x)},null,P),z)}e.forEach=o;function a(B,A,z){return m((I,D=null,P)=>B(x=>A(x)&&I.call(D,x),null,P),z)}e.filter=a;function u(B){return B}e.signal=u;function h(...B){return(A,z=null,I)=>{let D=Lk(...B.map(P=>P(x=>A.call(z,x))));return v(D,I)}}e.any=h;function p(B,A,z,I){let D=z;return s(B,P=>(D=A(D,P),D),I)}e.reduce=p;function m(B,A){let z,I={onWillAddFirstListener(){z=B(D.fire,D)},onDidRemoveLastListener(){z==null||z.dispose()}},D=new Re(I);return A==null||A.add(D),D.event}function v(B,A){return A instanceof Array?A.push(B):A&&A.add(B),B}function y(B,A,z=100,I=!1,D=!1,P,x){let M,L,T,H=0,Y,de={leakWarningThreshold:P,onWillAddFirstListener(){M=B(fe=>{H++,L=A(L,fe),I&&!T&&(ue.fire(L),L=void 0),Y=()=>{let ve=L;L=void 0,T=void 0,(!I||H>1)&&ue.fire(ve),H=0},typeof z=="number"?(clearTimeout(T),T=setTimeout(Y,z)):T===void 0&&(T=0,queueMicrotask(Y))})},onWillRemoveListener(){D&&H>0&&(Y==null||Y())},onDidRemoveLastListener(){Y=void 0,M.dispose()}},ue=new Re(de);return x==null||x.add(ue),ue.event}e.debounce=y;function w(B,A=0,z){return e.debounce(B,(I,D)=>I?(I.push(D),I):[D],A,void 0,!0,void 0,z)}e.accumulate=w;function b(B,A=(I,D)=>I===D,z){let I=!0,D;return a(B,P=>{let x=I||!A(P,D);return I=!1,D=P,x},z)}e.latch=b;function k(B,A,z){return[e.filter(B,A,z),e.filter(B,I=>!A(I),z)]}e.split=k;function N(B,A=!1,z=[],I){let D=z.slice(),P=B(L=>{D?D.push(L):M.fire(L)});I&&I.add(P);let x=()=>{D==null||D.forEach(L=>M.fire(L)),D=null},M=new Re({onWillAddFirstListener(){P||(P=B(L=>M.fire(L)),I&&I.add(P))},onDidAddFirstListener(){D&&(A?setTimeout(x):x())},onDidRemoveLastListener(){P&&P.dispose(),P=null}});return I&&I.add(M),M.event}e.buffer=N;function S(B,A){return(z,I,D)=>{let P=A(new C);return B(function(x){let M=P.evaluate(x);M!==j&&z.call(I,M)},void 0,D)}}e.chain=S;let j=Symbol("HaltChainable");class C{constructor(){this.steps=[]}map(A){return this.steps.push(A),this}forEach(A){return this.steps.push(z=>(A(z),z)),this}filter(A){return this.steps.push(z=>A(z)?z:j),this}reduce(A,z){let I=z;return this.steps.push(D=>(I=A(I,D),I)),this}latch(A=(z,I)=>z===I){let z=!0,I;return this.steps.push(D=>{let P=z||!A(D,I);return z=!1,I=D,P?D:j}),this}evaluate(A){for(let z of this.steps)if(A=z(A),A===j)break;return A}}function $(B,A,z=I=>I){let I=(...M)=>x.fire(z(...M)),D=()=>B.on(A,I),P=()=>B.removeListener(A,I),x=new Re({onWillAddFirstListener:D,onDidRemoveLastListener:P});return x.event}e.fromNodeEventEmitter=$;function O(B,A,z=I=>I){let I=(...M)=>x.fire(z(...M)),D=()=>B.addEventListener(A,I),P=()=>B.removeEventListener(A,I),x=new Re({onWillAddFirstListener:D,onDidRemoveLastListener:P});return x.event}e.fromDOMEventEmitter=O;function U(B){return new Promise(A=>n(B)(A))}e.toPromise=U;function V(B){let A=new Re;return B.then(z=>{A.fire(z)},()=>{A.fire(void 0)}).finally(()=>{A.dispose()}),A.event}e.fromPromise=V;function K(B,A){return B(z=>A.fire(z))}e.forward=K;function Z(B,A,z){return A(z),B(I=>A(I))}e.runAndSubscribe=Z;class G{constructor(A,z){this._observable=A,this._counter=0,this._hasChanged=!1;let I={onWillAddFirstListener:()=>{A.addObserver(this)},onDidRemoveLastListener:()=>{A.removeObserver(this)}};this.emitter=new Re(I),z&&z.add(this.emitter)}beginUpdate(A){this._counter++}handlePossibleChange(A){}handleChange(A,z){this._hasChanged=!0}endUpdate(A){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function Q(B,A){return new G(B,A).emitter.event}e.fromObservable=Q;function F(B){return(A,z,I)=>{let D=0,P=!1,x={beginUpdate(){D++},endUpdate(){D--,D===0&&(B.reportChanges(),P&&(P=!1,A.call(z)))},handlePossibleChange(){},handleChange(){P=!0}};B.addObserver(x),B.reportChanges();let M={dispose(){B.removeObserver(x)}};return I instanceof Ns?I.add(M):Array.isArray(I)&&I.push(M),M}}e.fromObservableLight=F})(Cn||(Cn={}));var lh=class ch{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${ch._idPool++}`,ch.all.add(this)}start(t){this._stopWatch=new Mk,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};lh.all=new Set,lh._idPool=0;var Dk=lh,Ik=-1,Xy=class Qy{constructor(t,n,s=(Qy._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,n){let s=this.threshold;if(s<=0||n<s)return;this._stacks||(this._stacks=new Map);let o=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,o+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[a,u]=this.getMostFrequentStack(),h=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${u}):`;console.warn(h),console.warn(a);let p=new zk(h,a);this._errorHandler(p)}return()=>{let a=this._stacks.get(t.value)||0;this._stacks.set(t.value,a-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[s,o]of this._stacks)(!t||n<o)&&(t=[s,o],n=o);return t}};Xy._idPool=1;var Ok=Xy,Bk=class Jy{constructor(t){this.value=t}static create(){let t=new Error;return new Jy(t.stack??"")}print(){console.warn(this.value.split(`
|
|
58
|
-
`).slice(2).join(`
|
|
59
|
-
`))}},zk=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},$k=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Fk=0,Zu=class{constructor(e){this.value=e,this.id=Fk++}},Hk=2,Uk,Re=class{constructor(e){var t,n,s,o;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new Ok((e==null?void 0:e.onListenerError)??Rl,((n=this._options)==null?void 0:n.leakWarningThreshold)??Ik):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new Dk(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var e,t,n,s;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(n=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||n.call(t),(s=this._leakageMon)==null||s.dispose())}get event(){return this._event??(this._event=(e,t,n)=>{var u,h,p,m,v;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let y=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(y);let w=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],b=new $k(`${y}. HINT: Stack shows most frequent listener (${w[1]}-times)`,w[0]);return(((u=this._options)==null?void 0:u.onListenerError)||Rl)(b),lt.None}if(this._disposed)return lt.None;t&&(e=e.bind(t));let s=new Zu(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=Bk.create(),o=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof Zu?(this._deliveryQueue??(this._deliveryQueue=new Wk),this._listeners=[this._listeners,s]):this._listeners.push(s):((p=(h=this._options)==null?void 0:h.onWillAddFirstListener)==null||p.call(h,this),this._listeners=s,(v=(m=this._options)==null?void 0:m.onDidAddFirstListener)==null||v.call(m,this)),this._size++;let a=Bt(()=>{o==null||o(),this._removeListener(s)});return n instanceof Ns?n.add(a):Array.isArray(n)&&n.push(a),a}),this._event}_removeListener(e){var o,a,u,h;if((a=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||a.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(h=(u=this._options)==null?void 0:u.onDidRemoveLastListener)==null||h.call(u,this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[n]=void 0;let s=this._deliveryQueue.current===this;if(this._size*Hk<=t.length){let p=0;for(let m=0;m<t.length;m++)t[m]?t[p++]=t[m]:s&&(this._deliveryQueue.end--,p<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=p}}_deliver(e,t){var s;if(!e)return;let n=((s=this._options)==null?void 0:s.onListenerError)||Rl;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,n,s,o;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(n=this._perfMon)==null||n.stop()),(s=this._perfMon)==null||s.start(this._size),this._listeners)if(this._listeners instanceof Zu)this._deliver(this._listeners,e);else{let a=this._deliveryQueue;a.enqueue(this,e,this._listeners.length),this._deliverQueue(a)}(o=this._perfMon)==null||o.stop()}hasListeners(){return this._size>0}},Wk=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},uh=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Re,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Re,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};uh.INSTANCE=new uh;var gf=uh;function Kk(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}gf.INSTANCE.onDidChangeZoomLevel;function qk(e){return gf.INSTANCE.getZoomFactor(e)}gf.INSTANCE.onDidChangeFullscreen;var Kr=typeof navigator=="object"?navigator.userAgent:"",dh=Kr.indexOf("Firefox")>=0,Vk=Kr.indexOf("AppleWebKit")>=0,vf=Kr.indexOf("Chrome")>=0,Yk=!vf&&Kr.indexOf("Safari")>=0;Kr.indexOf("Electron/")>=0;Kr.indexOf("Android")>=0;var ed=!1;if(typeof Vi.matchMedia=="function"){let e=Vi.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Vi.matchMedia("(display-mode: fullscreen)");ed=e.matches,Kk(Vi,e,({matches:n})=>{ed&&t.matches||(ed=n)})}var Tr="en",hh=!1,fh=!1,Pl=!1,Zy=!1,vl,Al=Tr,Yg=Tr,Gk,_i,Js=globalThis,kn,Q_;typeof Js.vscode<"u"&&typeof Js.vscode.process<"u"?kn=Js.vscode.process:typeof process<"u"&&typeof((Q_=process==null?void 0:process.versions)==null?void 0:Q_.node)=="string"&&(kn=process);var J_,Xk=typeof((J_=kn==null?void 0:kn.versions)==null?void 0:J_.electron)=="string",Qk=Xk&&(kn==null?void 0:kn.type)==="renderer",Z_;if(typeof kn=="object"){hh=kn.platform==="win32",fh=kn.platform==="darwin",Pl=kn.platform==="linux",Pl&&kn.env.SNAP&&kn.env.SNAP_REVISION,kn.env.CI||kn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,vl=Tr,Al=Tr;let e=kn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);vl=t.userLocale,Yg=t.osLocale,Al=t.resolvedLanguage||Tr,Gk=(Z_=t.languagePack)==null?void 0:Z_.translationsConfigFile}catch{}Zy=!0}else typeof navigator=="object"&&!Qk?(_i=navigator.userAgent,hh=_i.indexOf("Windows")>=0,fh=_i.indexOf("Macintosh")>=0,(_i.indexOf("Macintosh")>=0||_i.indexOf("iPad")>=0||_i.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Pl=_i.indexOf("Linux")>=0,(_i==null?void 0:_i.indexOf("Mobi"))>=0,Al=globalThis._VSCODE_NLS_LANGUAGE||Tr,vl=navigator.language.toLowerCase(),Yg=vl):console.error("Unable to resolve platform.");var ew=hh,Li=fh,Jk=Pl,Gg=Zy,Mi=_i,vs=Al,Zk;(e=>{function t(){return vs}e.value=t;function n(){return vs.length===2?vs==="en":vs.length>=3?vs[0]==="e"&&vs[1]==="n"&&vs[2]==="-":!1}e.isDefaultVariant=n;function s(){return vs==="en"}e.isDefault=s})(Zk||(Zk={}));var e1=typeof Js.postMessage=="function"&&!Js.importScripts;(()=>{if(e1){let e=[];Js.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let s=0,o=e.length;s<o;s++){let a=e[s];if(a.id===n.data.vscodeScheduleAsyncWork){e.splice(s,1),a.callback();return}}});let t=0;return n=>{let s=++t;e.push({id:s,callback:n}),Js.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var t1=!!(Mi&&Mi.indexOf("Chrome")>=0);Mi&&Mi.indexOf("Firefox")>=0;!t1&&Mi&&Mi.indexOf("Safari")>=0;Mi&&Mi.indexOf("Edg/")>=0;Mi&&Mi.indexOf("Android")>=0;var jr=typeof navigator=="object"?navigator:{};Gg||document.queryCommandSupported&&document.queryCommandSupported("copy")||jr&&jr.clipboard&&jr.clipboard.writeText,Gg||jr&&jr.clipboard&&jr.clipboard.readText;var _f=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},td=new _f,Xg=new _f,Qg=new _f,n1=new Array(230),tw;(e=>{function t(h){return td.keyCodeToStr(h)}e.toString=t;function n(h){return td.strToKeyCode(h)}e.fromString=n;function s(h){return Xg.keyCodeToStr(h)}e.toUserSettingsUS=s;function o(h){return Qg.keyCodeToStr(h)}e.toUserSettingsGeneral=o;function a(h){return Xg.strToKeyCode(h)||Qg.strToKeyCode(h)}e.fromUserSettings=a;function u(h){if(h>=98&&h<=113)return null;switch(h){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return td.keyCodeToStr(h)}e.toElectronAccelerator=u})(tw||(tw={}));var i1=class nw{constructor(t,n,s,o,a){this.ctrlKey=t,this.shiftKey=n,this.altKey=s,this.metaKey=o,this.keyCode=a}equals(t){return t instanceof nw&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",n=this.shiftKey?"1":"0",s=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${n}${s}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new s1([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},s1=class{constructor(e){if(e.length===0)throw Rk("chords");this.chords=e}getHashCode(){let e="";for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function r1(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return tw.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(dh)switch(t){case 59:return 85;case 60:if(Jk)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Li)return 57;break}else if(Vk&&(Li&&t===93||!Li&&t===92))return 57;return n1[t]||0}var o1=Li?256:2048,a1=512,l1=1024,c1=Li?2048:256,Jg=class{constructor(e){var n;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(n=t.getModifierState)==null?void 0:n.call(t,"AltGraph"),this.keyCode=r1(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=o1),this.altKey&&(t|=a1),this.shiftKey&&(t|=l1),this.metaKey&&(t|=c1),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new i1(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Zg=new WeakMap;function u1(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!=="null"&&n.origin!=="null"&&t.origin!==n.origin)return null}catch{return null}return e.parent}var d1=class{static getSameOriginWindowChain(e){let t=Zg.get(e);if(!t){t=[],Zg.set(e,t);let n=e,s;do s=u1(n),s?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=s;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,s=0,o=this.getSameOriginWindowChain(e);for(let a of o){let u=a.window.deref();if(n+=(u==null?void 0:u.scrollY)??0,s+=(u==null?void 0:u.scrollX)??0,u===t||!a.iframeElement)break;let h=a.iframeElement.getBoundingClientRect();n+=h.top,s+=h.left}return{top:n,left:s}}},_l=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=d1.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},ev=class{constructor(e,t=0,n=0){var o;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let s=!1;if(vf){let a=navigator.userAgent.match(/Chrome\/(\d+)/);s=(a?parseInt(a[1]):123)<=122}if(e){let a=e,u=e,h=((o=e.view)==null?void 0:o.devicePixelRatio)||1;if(typeof a.wheelDeltaY<"u")s?this.deltaY=a.wheelDeltaY/(120*h):this.deltaY=a.wheelDeltaY/120;else if(typeof u.VERTICAL_AXIS<"u"&&u.axis===u.VERTICAL_AXIS)this.deltaY=-u.detail/3;else if(e.type==="wheel"){let p=e;p.deltaMode===p.DOM_DELTA_LINE?dh&&!Li?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof a.wheelDeltaX<"u")Yk&&ew?this.deltaX=-(a.wheelDeltaX/120):s?this.deltaX=a.wheelDeltaX/(120*h):this.deltaX=a.wheelDeltaX/120;else if(typeof u.HORIZONTAL_AXIS<"u"&&u.axis===u.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let p=e;p.deltaMode===p.DOM_DELTA_LINE?dh&&!Li?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*h):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},iw=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),h1;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof f1?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Cn.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:iw})})(h1||(h1={}));var f1=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?iw:(this._emitter||(this._emitter=new Re),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},yf=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new rh("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new rh("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},p1=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new rh("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=Bt(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},m1;(e=>{async function t(s){let o,a=await Promise.all(s.map(u=>u.then(h=>h,h=>{o||(o=h)})));if(typeof o<"u")throw o;return a}e.settled=t;function n(s){return new Promise(async(o,a)=>{try{await s(o,a)}catch(u){a(u)}})}e.withAsyncBody=n})(m1||(m1={}));var tv=class ci{static fromArray(t){return new ci(n=>{n.emitMany(t)})}static fromPromise(t){return new ci(async n=>{n.emitMany(await t)})}static fromPromises(t){return new ci(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new ci(async n=>{await Promise.all(t.map(async s=>{for await(let o of s)n.emitOne(o)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new Re,queueMicrotask(async()=>{let s={emitOne:o=>this.emitOne(o),emitMany:o=>this.emitMany(o),reject:o=>this.reject(o)};try{await Promise.resolve(t(s)),this.resolve()}catch(o){this.reject(o)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Cn.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var n;return(n=this._onReturn)==null||n.call(this),{done:!0,value:void 0}}}}static map(t,n){return new ci(async s=>{for await(let o of t)s.emitOne(n(o))})}map(t){return ci.map(this,t)}static filter(t,n){return new ci(async s=>{for await(let o of t)n(o)&&s.emitOne(o)})}filter(t){return ci.filter(this,t)}static coalesce(t){return ci.filter(t,n=>!!n)}coalesce(){return ci.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return ci.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};tv.EMPTY=tv.fromArray([]);var{getWindow:Pi,getWindowId:g1,onDidRegisterWindow:v1}=(function(){let e=new Map,t={window:Vi,disposables:new Ns};e.set(Vi.vscodeWindowId,t);let n=new Re,s=new Re,o=new Re;function a(u,h){return(typeof u=="number"?e.get(u):void 0)??(h?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:s.event,registerWindow(u){if(e.has(u.vscodeWindowId))return lt.None;let h=new Ns,p={window:u,disposables:h.add(new Ns)};return e.set(u.vscodeWindowId,p),h.add(Bt(()=>{e.delete(u.vscodeWindowId),s.fire(u)})),h.add(et(u,gn.BEFORE_UNLOAD,()=>{o.fire(u)})),n.fire(p),h},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(u){return u.vscodeWindowId},hasWindow(u){return e.has(u)},getWindowById:a,getWindow(u){var m;let h=u;if((m=h==null?void 0:h.ownerDocument)!=null&&m.defaultView)return h.ownerDocument.defaultView.window;let p=u;return p!=null&&p.view?p.view.window:Vi},getDocument(u){return Pi(u).document}}})(),_1=class{constructor(e,t,n,s){this._node=e,this._type=t,this._handler=n,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function et(e,t,n,s){return new _1(e,t,n,s)}var nv=function(e,t,n,s){return et(e,t,n,s)},wf,y1=class extends p1{constructor(e){super(),this.defaultTarget=e&&Pi(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},iv=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){Rl(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,s=new Map,o=a=>{n.set(a,!1);let u=e.get(a)??[];for(t.set(a,u),e.set(a,[]),s.set(a,!0);u.length>0;)u.sort(iv.sort),u.shift().execute();s.set(a,!1)};wf=(a,u,h=0)=>{let p=g1(a),m=new iv(u,h),v=e.get(p);return v||(v=[],e.set(p,v)),v.push(m),n.get(p)||(n.set(p,!0),a.requestAnimationFrame(()=>o(p))),m}})();function w1(e){let t=e.getBoundingClientRect(),n=Pi(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var gn={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"},b1=class{constructor(t){this.domNode=t,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(t){let n=Kn(t);this._maxWidth!==n&&(this._maxWidth=n,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let n=Kn(t);this._width!==n&&(this._width=n,this.domNode.style.width=this._width)}setHeight(t){let n=Kn(t);this._height!==n&&(this._height=n,this.domNode.style.height=this._height)}setTop(t){let n=Kn(t);this._top!==n&&(this._top=n,this.domNode.style.top=this._top)}setLeft(t){let n=Kn(t);this._left!==n&&(this._left=n,this.domNode.style.left=this._left)}setBottom(t){let n=Kn(t);this._bottom!==n&&(this._bottom=n,this.domNode.style.bottom=this._bottom)}setRight(t){let n=Kn(t);this._right!==n&&(this._right=n,this.domNode.style.right=this._right)}setPaddingTop(t){let n=Kn(t);this._paddingTop!==n&&(this._paddingTop=n,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let n=Kn(t);this._paddingLeft!==n&&(this._paddingLeft=n,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let n=Kn(t);this._paddingBottom!==n&&(this._paddingBottom=n,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let n=Kn(t);this._paddingRight!==n&&(this._paddingRight=n,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(t){let n=Kn(t);this._fontSize!==n&&(this._fontSize=n,this.domNode.style.fontSize=this._fontSize)}setFontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(t){this._fontFeatureSettings!==t&&(this._fontFeatureSettings=t,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(t){this._fontVariationSettings!==t&&(this._fontVariationSettings=t,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(t){this._textDecoration!==t&&(this._textDecoration=t,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(t){let n=Kn(t);this._lineHeight!==n&&(this._lineHeight=n,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let n=Kn(t);this._letterSpacing!==n&&(this._letterSpacing=n,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,n){this.domNode.classList.toggle(t,n),this._className=this.domNode.className}setDisplay(t){this._display!==t&&(this._display=t,this.domNode.style.display=this._display)}setPosition(t){this._position!==t&&(this._position=t,this.domNode.style.position=this._position)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this.domNode.style.visibility=this._visibility)}setColor(t){this._color!==t&&(this._color=t,this.domNode.style.color=this._color)}setBackgroundColor(t){this._backgroundColor!==t&&(this._backgroundColor=t,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(t){this._layerHint!==t&&(this._layerHint=t,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(t){this._boxShadow!==t&&(this._boxShadow=t,this.domNode.style.boxShadow=t)}setContain(t){this._contain!==t&&(this._contain=t,this.domNode.style.contain=this._contain)}setAttribute(t,n){this.domNode.setAttribute(t,n)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function Kn(e){return typeof e=="number"?`${e}px`:e}function Yo(e){return new b1(e)}var sw=class{constructor(){this._hooks=new Ns,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,s,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=o;let a=e;try{e.setPointerCapture(t),this._hooks.add(Bt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=Pi(e)}this._hooks.add(et(a,gn.POINTER_MOVE,u=>{if(u.buttons!==n){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add(et(a,gn.POINTER_UP,u=>this.stopMonitoring(!0)))}};function S1(e,t,n){let s=null,o=null;if(typeof n.value=="function"?(s="value",o=n.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(s="get",o=n.get),!o)throw new Error("not supported");let a=`$memoize$${t}`;n[s]=function(...u){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,u)}),this[a]}}var Ei;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Ei||(Ei={}));var Ho=class Pn extends lt{constructor(){super(),this.dispatched=!1,this.targets=new Vg,this.ignoreTargets=new Vg,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Cn.runAndSubscribe(v1,({window:t,disposables:n})=>{n.add(et(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(et(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add(et(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:Vi,disposables:this._store}))}static addTarget(t){if(!Pn.isTouchDevice())return lt.None;Pn.INSTANCE||(Pn.INSTANCE=new Pn);let n=Pn.INSTANCE.targets.push(t);return Bt(n)}static ignoreTarget(t){if(!Pn.isTouchDevice())return lt.None;Pn.INSTANCE||(Pn.INSTANCE=new Pn);let n=Pn.INSTANCE.ignoreTargets.push(t);return Bt(n)}static isTouchDevice(){return"ontouchstart"in Vi||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,o=t.targetTouches.length;s<o;s++){let a=t.targetTouches.item(s);this.activeTouches[a.identifier]={id:a.identifier,initialTarget:a.target,initialTimeStamp:n,initialPageX:a.pageX,initialPageY:a.pageY,rollingTimestamps:[n],rollingPageX:[a.pageX],rollingPageY:[a.pageY]};let u=this.newGestureEvent(Ei.Start,a.target);u.pageX=a.pageX,u.pageY=a.pageY,this.dispatchEvent(u)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,n){let s=Date.now(),o=Object.keys(this.activeTouches).length;for(let a=0,u=n.changedTouches.length;a<u;a++){let h=n.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(h.identifier))){console.warn("move of an UNKNOWN touch",h);continue}let p=this.activeTouches[h.identifier],m=Date.now()-p.initialTimeStamp;if(m<Pn.HOLD_DELAY&&Math.abs(p.initialPageX-Qn(p.rollingPageX))<30&&Math.abs(p.initialPageY-Qn(p.rollingPageY))<30){let v=this.newGestureEvent(Ei.Tap,p.initialTarget);v.pageX=Qn(p.rollingPageX),v.pageY=Qn(p.rollingPageY),this.dispatchEvent(v)}else if(m>=Pn.HOLD_DELAY&&Math.abs(p.initialPageX-Qn(p.rollingPageX))<30&&Math.abs(p.initialPageY-Qn(p.rollingPageY))<30){let v=this.newGestureEvent(Ei.Contextmenu,p.initialTarget);v.pageX=Qn(p.rollingPageX),v.pageY=Qn(p.rollingPageY),this.dispatchEvent(v)}else if(o===1){let v=Qn(p.rollingPageX),y=Qn(p.rollingPageY),w=Qn(p.rollingTimestamps)-p.rollingTimestamps[0],b=v-p.rollingPageX[0],k=y-p.rollingPageY[0],N=[...this.targets].filter(S=>p.initialTarget instanceof Node&&S.contains(p.initialTarget));this.inertia(t,N,s,Math.abs(b)/w,b>0?1:-1,v,Math.abs(k)/w,k>0?1:-1,y)}this.dispatchEvent(this.newGestureEvent(Ei.End,p.initialTarget)),delete this.activeTouches[h.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=n,s.tapCount=0,s}dispatchEvent(t){if(t.type===Ei.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>Pn.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===Ei.Change||t.type===Ei.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let n=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let o=0,a=t.initialTarget;for(;a&&a!==s;)o++,a=a.parentElement;n.push([o,s])}n.sort((s,o)=>s[0]-o[0]);for(let[s,o]of n)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,s,o,a,u,h,p,m){this.handle=wf(t,()=>{let v=Date.now(),y=v-s,w=0,b=0,k=!0;o+=Pn.SCROLL_FRICTION*y,h+=Pn.SCROLL_FRICTION*y,o>0&&(k=!1,w=a*o*y),h>0&&(k=!1,b=p*h*y);let N=this.newGestureEvent(Ei.Change);N.translationX=w,N.translationY=b,n.forEach(S=>S.dispatchEvent(N)),k||this.inertia(t,n,v,o,a,u+w,h,p,m+b)})}onTouchMove(t){let n=Date.now();for(let s=0,o=t.changedTouches.length;s<o;s++){let a=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("end of an UNKNOWN touch",a);continue}let u=this.activeTouches[a.identifier],h=this.newGestureEvent(Ei.Change,u.initialTarget);h.translationX=a.pageX-Qn(u.rollingPageX),h.translationY=a.pageY-Qn(u.rollingPageY),h.pageX=a.pageX,h.pageY=a.pageY,this.dispatchEvent(h),u.rollingPageX.length>3&&(u.rollingPageX.shift(),u.rollingPageY.shift(),u.rollingTimestamps.shift()),u.rollingPageX.push(a.pageX),u.rollingPageY.push(a.pageY),u.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Ho.SCROLL_FRICTION=-.005,Ho.HOLD_DELAY=700,Ho.CLEAR_TAP_COUNT_TIME=400,qt([S1],Ho,"isTouchDevice",1);var x1=Ho,bf=class extends lt{onclick(e,t){this._register(et(e,gn.CLICK,n=>t(new _l(Pi(e),n))))}onmousedown(e,t){this._register(et(e,gn.MOUSE_DOWN,n=>t(new _l(Pi(e),n))))}onmouseover(e,t){this._register(et(e,gn.MOUSE_OVER,n=>t(new _l(Pi(e),n))))}onmouseleave(e,t){this._register(et(e,gn.MOUSE_LEAVE,n=>t(new _l(Pi(e),n))))}onkeydown(e,t){this._register(et(e,gn.KEY_DOWN,n=>t(new Jg(n))))}onkeyup(e,t){this._register(et(e,gn.KEY_UP,n=>t(new Jg(n))))}oninput(e,t){this._register(et(e,gn.INPUT,t))}onblur(e,t){this._register(et(e,gn.BLUR,t))}onfocus(e,t){this._register(et(e,gn.FOCUS,t))}onchange(e,t){this._register(et(e,gn.CHANGE,t))}ignoreGesture(e){return x1.ignoreTarget(e)}},sv=11,k1=class extends bf{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=sv+"px",this.domNode.style.height=sv+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new sw),this._register(nv(this.bgDomNode,gn.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(nv(this.domNode,gn.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new y1),this._pointerdownScheduleRepeatTimer=this._register(new yf)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Pi(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},C1=class ph{constructor(t,n,s,o,a,u,h){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,o=o|0,a=a|0,u=u|0,h=h|0),this.rawScrollLeft=o,this.rawScrollTop=h,n<0&&(n=0),o+n>s&&(o=s-n),o<0&&(o=0),a<0&&(a=0),h+a>u&&(h=u-a),h<0&&(h=0),this.width=n,this.scrollWidth=s,this.scrollLeft=o,this.height=a,this.scrollHeight=u,this.scrollTop=h}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,n){return new ph(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new ph(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,n){let s=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,a=this.scrollLeft!==t.scrollLeft,u=this.height!==t.height,h=this.scrollHeight!==t.scrollHeight,p=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:n,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:o,scrollLeftChanged:a,heightChanged:u,scrollHeightChanged:h,scrollTopChanged:p}}},E1=class extends lt{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Re),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new C1(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var s;let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let s;t?s=new ov(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=ov.start(this._state,n,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},rv=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function nd(e,t){let n=t-e;return function(s){return e+n*R1(s)}}function N1(e,t,n){return function(s){return s<n?e(s/n):t((s-n)/(1-n))}}var ov=class mh{constructor(t,n,s,o){this.from=t,this.to=n,this.duration=o,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,n,s){if(Math.abs(t-n)>2.5*s){let o,a;return t<n?(o=t+.75*s,a=n-.75*s):(o=t-.75*s,a=n+.75*s),N1(nd(t,o),nd(a,n),.33)}return nd(t,n)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let n=(t-this.startTime)/this.duration;if(n<1){let s=this.scrollLeft(n),o=this.scrollTop(n);return new rv(s,o,!1)}return new rv(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,s){return mh.start(t,n,s)}static start(t,n,s){s=s+10;let o=Date.now()-10;return new mh(t,n,o,s)}};function j1(e){return Math.pow(e,3)}function R1(e){return 1-j1(1-e)}var P1=class extends lt{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new yf)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},A1=140,rw=class extends bf{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 P1(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new sw),this._shouldRender=!0,this.domNode=Yo(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(et(this.domNode.domNode,gn.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new k1(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=Yo(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(et(this.slider.domNode,gn.POINTER_DOWN,o=>{o.button===0&&(o.preventDefault(),this._sliderPointerDown(o))})),this.onclick(this.slider.domNode,o=>{o.leftButton&&o.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);n<=o&&o<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let o=w1(this.domNode.domNode);t=e.pageX-o.left,n=e.pageY-o.top}let s=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let a=this._sliderOrthogonalPointerPosition(o),u=Math.abs(a-n);if(ew&&u>A1){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let h=this._sliderPointerPosition(o)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(h))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},ow=class gh{constructor(t,n,s,o,a,u){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=a,this._scrollPosition=u,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new gh(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,s,o,a){let u=Math.max(0,s-t),h=Math.max(0,u-2*n),p=o>0&&o>s;if(!p)return{computedAvailableSize:Math.round(u),computedIsNeeded:p,computedSliderSize:Math.round(h),computedSliderRatio:0,computedSliderPosition:0};let m=Math.round(Math.max(20,Math.floor(s*h/o))),v=(h-m)/(o-s),y=a*v;return{computedAvailableSize:Math.round(u),computedIsNeeded:p,computedSliderSize:Math.round(m),computedSliderRatio:v,computedSliderPosition:Math.round(y)}}_refreshComputedValues(){let t=gh._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,s=this._scrollPosition;return n<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let n=this._computedSliderPosition+t;return Math.round(n/this._computedSliderRatio)}},L1=class extends rw{constructor(e,t,n){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new ow(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.scrollWidth,o.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},T1=class extends rw{constructor(e,t,n){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new ow(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,o.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},M1=500,av=50,D1=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},vh=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,n=0,s=1,o=this._rear;do{let a=o===this._front?t:Math.pow(2,-s);if(t-=a,n+=this._memory[o].score*a,o===this._front)break;o=(this._capacity+o-1)%this._capacity,s++}while(!0);return n<=.5}acceptStandardWheelEvent(t){if(vf){let n=Pi(t.browserEvent),s=qk(n);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,n,s){let o=null,a=new D1(t,n,s);this._front===-1&&this._rear===-1?(this._memory[0]=a,this._front=0,this._rear=0):(o=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=a),a.score=this._computeScore(a,o)}_computeScore(t,n){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),n){let o=Math.abs(t.deltaX),a=Math.abs(t.deltaY),u=Math.abs(n.deltaX),h=Math.abs(n.deltaY),p=Math.max(Math.min(o,u),1),m=Math.max(Math.min(a,h),1),v=Math.max(o,u),y=Math.max(a,h);v%p===0&&y%m===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};vh.INSTANCE=new vh;var I1=vh,O1=class extends bf{constructor(e,t,n){super(),this._onScroll=this._register(new Re),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Re),this.onWillScroll=this._onWillScroll.event,this._options=z1(t),this._scrollable=n,this._register(this._scrollable.onScroll(o=>{this._onWillScroll.fire(o),this._onDidScroll(o),this._onScroll.fire(o)}));let s={onMouseWheel:o=>this._onMouseWheel(o),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new T1(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new L1(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Yo(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Yo(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Yo(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,o=>this._onMouseOver(o)),this.onmouseleave(this._listenOnDomNode,o=>this._onMouseLeave(o)),this._hideTimeout=this._register(new yf),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Zs(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,Li&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new ev(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Zs(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new ev(n))};this._mouseWheelToDispose.push(et(this._listenOnDomNode,gn.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var o;if((o=e.browserEvent)!=null&&o.defaultPrevented)return;let t=I1.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let a=e.deltaY*this._options.mouseWheelScrollSensitivity,u=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&u+a===0?u=a=0:Math.abs(a)>=Math.abs(u)?u=0:a=0),this._options.flipAxes&&([a,u]=[u,a]);let h=!Li&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||h)&&!u&&(u=a,a=0),e.browserEvent&&e.browserEvent.altKey&&(u=u*this._options.fastScrollSensitivity,a=a*this._options.fastScrollSensitivity);let p=this._scrollable.getFutureScrollPosition(),m={};if(a){let v=av*a,y=p.scrollTop-(v<0?Math.floor(v):Math.ceil(v));this._verticalScrollbar.writeScrollPosition(m,y)}if(u){let v=av*u,y=p.scrollLeft-(v<0?Math.floor(v):Math.ceil(v));this._horizontalScrollbar.writeScrollPosition(m,y)}m=this._scrollable.validateScrollPosition(m),(p.scrollLeft!==m.scrollLeft||p.scrollTop!==m.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(m):this._scrollable.setScrollPositionNow(m),n=!0)}let s=n;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,s=n?" left":"",o=t?" top":"",a=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${o}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${o}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),M1)}},B1=class extends O1{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function z1(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,Li&&(t.className+=" mac"),t}var _h=class extends lt{constructor(e,t,n,s,o,a,u,h){super(),this._bufferService=n,this._optionsService=u,this._renderService=h,this._onRequestScrollLines=this._register(new Re),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let p=this._register(new E1({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:m=>wf(s.window,m)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{p.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new B1(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},p)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(o.onProtocolChange(m=>{this._scrollableElement.updateOptions({handleMouseWheel:!(m&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Cn.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Bt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Bt(()=>this._styleElement.remove())),this._register(Cn.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${a.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${a.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${a.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
60
|
-
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(m=>this._handleScroll(m)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};_h=qt([Te(2,In),Te(3,Gi),Te(4,$y),Te(5,Wr),Te(6,On),Te(7,Xi)],_h);var yh=class extends lt{constructor(e,t,n,s,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=s,this._renderService=o,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(a=>this._removeDecoration(a))),this._register(Bt(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};yh=qt([Te(1,In),Te(2,Gi),Te(3,sa),Te(4,Xi)],yh);var $1=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||"full"]&&t<=e.endBufferLine+this._linePadding[n||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},xi={full:0,left:0,center:0,right:0},_s={full:0,left:0,center:0,right:0},Lo={full:0,left:0,center:0,right:0},Wl=class extends lt{constructor(e,t,n,s,o,a,u,h){var m;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=s,this._renderService=o,this._optionsService=a,this._themeService=u,this._coreBrowserService=h,this._colorZoneStore=new $1,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(m=this._viewportElement.parentElement)==null||m.insertBefore(this._canvas,this._viewportElement),this._register(Bt(()=>{var v;return(v=this._canvas)==null?void 0:v.remove()}));let p=this._canvas.getContext("2d");if(p)this._ctx=p;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);_s.full=this._canvas.width,_s.left=e,_s.center=t,_s.right=e,this._refreshDrawHeightConstants(),Lo.full=1,Lo.left=1,Lo.center=1+_s.left,Lo.right=1+_s.left+_s.center}_refreshDrawHeightConstants(){xi.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);xi.left=t,xi.center=t,xi.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*xi.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*xi.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*xi.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*xi.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(Lo[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-xi[e.position||"full"]/2),_s[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+xi[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Wl=qt([Te(2,In),Te(3,sa),Te(4,Xi),Te(5,On),Te(6,Wr),Te(7,Gi)],Wl);var ge;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
|
|
61
|
-
`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(ge||(ge={}));var Ll;(e=>(e.PAD="",e.HOP="",e.BPH="",e.NBH="",e.IND="",e.NEL="
",e.SSA="",e.ESA="",e.HTS="",e.HTJ="",e.VTS="",e.PLD="",e.PLU="",e.RI="",e.SS2="",e.SS3="",e.DCS="",e.PU1="",e.PU2="",e.STS="",e.CCH="",e.MW="",e.SPA="",e.EPA="",e.SOS="",e.SGCI="",e.SCI="",e.CSI="",e.ST="",e.OSC="",e.PM="",e.APC=""))(Ll||(Ll={}));var aw;(e=>e.ST=`${ge.ESC}\\`)(aw||(aw={}));var wh=class{constructor(e,t,n,s,o,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=s,this._coreService=o,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${ge.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),n=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,o=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=o+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=n+"px",this._compositionView.style.lineHeight=n+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let a=this._compositionView.getBoundingClientRect();this._textarea.style.left=o+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(a.width,1)+"px",this._textarea.style.height=Math.max(a.height,1)+"px",this._textarea.style.lineHeight=a.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};wh=qt([Te(2,In),Te(3,On),Te(4,tr),Te(5,Xi)],wh);var vn=0,_n=0,yn=0,Wt=0,lv={css:"#00000000",rgba:0},nn;(e=>{function t(o,a,u,h){return h!==void 0?`#${Ws(o)}${Ws(a)}${Ws(u)}${Ws(h)}`:`#${Ws(o)}${Ws(a)}${Ws(u)}`}e.toCss=t;function n(o,a,u,h=255){return(o<<24|a<<16|u<<8|h)>>>0}e.toRgba=n;function s(o,a,u,h){return{css:e.toCss(o,a,u,h),rgba:e.toRgba(o,a,u,h)}}e.toColor=s})(nn||(nn={}));var Mt;(e=>{function t(p,m){if(Wt=(m.rgba&255)/255,Wt===1)return{css:m.css,rgba:m.rgba};let v=m.rgba>>24&255,y=m.rgba>>16&255,w=m.rgba>>8&255,b=p.rgba>>24&255,k=p.rgba>>16&255,N=p.rgba>>8&255;vn=b+Math.round((v-b)*Wt),_n=k+Math.round((y-k)*Wt),yn=N+Math.round((w-N)*Wt);let S=nn.toCss(vn,_n,yn),j=nn.toRgba(vn,_n,yn);return{css:S,rgba:j}}e.blend=t;function n(p){return(p.rgba&255)===255}e.isOpaque=n;function s(p,m,v){let y=Tl.ensureContrastRatio(p.rgba,m.rgba,v);if(y)return nn.toColor(y>>24&255,y>>16&255,y>>8&255)}e.ensureContrastRatio=s;function o(p){let m=(p.rgba|255)>>>0;return[vn,_n,yn]=Tl.toChannels(m),{css:nn.toCss(vn,_n,yn),rgba:m}}e.opaque=o;function a(p,m){return Wt=Math.round(m*255),[vn,_n,yn]=Tl.toChannels(p.rgba),{css:nn.toCss(vn,_n,yn,Wt),rgba:nn.toRgba(vn,_n,yn,Wt)}}e.opacity=a;function u(p,m){return Wt=p.rgba&255,a(p,Wt*m/255)}e.multiplyOpacity=u;function h(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=h})(Mt||(Mt={}));var Ht;(e=>{let t,n;try{let o=document.createElement("canvas");o.width=1,o.height=1;let a=o.getContext("2d",{willReadFrequently:!0});a&&(t=a,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function s(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return vn=parseInt(o.slice(1,2).repeat(2),16),_n=parseInt(o.slice(2,3).repeat(2),16),yn=parseInt(o.slice(3,4).repeat(2),16),nn.toColor(vn,_n,yn);case 5:return vn=parseInt(o.slice(1,2).repeat(2),16),_n=parseInt(o.slice(2,3).repeat(2),16),yn=parseInt(o.slice(3,4).repeat(2),16),Wt=parseInt(o.slice(4,5).repeat(2),16),nn.toColor(vn,_n,yn,Wt);case 7:return{css:o,rgba:(parseInt(o.slice(1),16)<<8|255)>>>0};case 9:return{css:o,rgba:parseInt(o.slice(1),16)>>>0}}let a=o.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(a)return vn=parseInt(a[1]),_n=parseInt(a[2]),yn=parseInt(a[3]),Wt=Math.round((a[5]===void 0?1:parseFloat(a[5]))*255),nn.toColor(vn,_n,yn,Wt);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[vn,_n,yn,Wt]=t.getImageData(0,0,1,1).data,Wt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:nn.toRgba(vn,_n,yn,Wt),css:o}}e.toColor=s})(Ht||(Ht={}));var Mn;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,o,a){let u=s/255,h=o/255,p=a/255,m=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4),v=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),y=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return m*.2126+v*.7152+y*.0722}e.relativeLuminance2=n})(Mn||(Mn={}));var Tl;(e=>{function t(u,h){if(Wt=(h&255)/255,Wt===1)return h;let p=h>>24&255,m=h>>16&255,v=h>>8&255,y=u>>24&255,w=u>>16&255,b=u>>8&255;return vn=y+Math.round((p-y)*Wt),_n=w+Math.round((m-w)*Wt),yn=b+Math.round((v-b)*Wt),nn.toRgba(vn,_n,yn)}e.blend=t;function n(u,h,p){let m=Mn.relativeLuminance(u>>8),v=Mn.relativeLuminance(h>>8);if(Wi(m,v)<p){if(v<m){let b=s(u,h,p),k=Wi(m,Mn.relativeLuminance(b>>8));if(k<p){let N=o(u,h,p),S=Wi(m,Mn.relativeLuminance(N>>8));return k>S?b:N}return b}let y=o(u,h,p),w=Wi(m,Mn.relativeLuminance(y>>8));if(w<p){let b=s(u,h,p),k=Wi(m,Mn.relativeLuminance(b>>8));return w>k?y:b}return y}}e.ensureContrastRatio=n;function s(u,h,p){let m=u>>24&255,v=u>>16&255,y=u>>8&255,w=h>>24&255,b=h>>16&255,k=h>>8&255,N=Wi(Mn.relativeLuminance2(w,b,k),Mn.relativeLuminance2(m,v,y));for(;N<p&&(w>0||b>0||k>0);)w-=Math.max(0,Math.ceil(w*.1)),b-=Math.max(0,Math.ceil(b*.1)),k-=Math.max(0,Math.ceil(k*.1)),N=Wi(Mn.relativeLuminance2(w,b,k),Mn.relativeLuminance2(m,v,y));return(w<<24|b<<16|k<<8|255)>>>0}e.reduceLuminance=s;function o(u,h,p){let m=u>>24&255,v=u>>16&255,y=u>>8&255,w=h>>24&255,b=h>>16&255,k=h>>8&255,N=Wi(Mn.relativeLuminance2(w,b,k),Mn.relativeLuminance2(m,v,y));for(;N<p&&(w<255||b<255||k<255);)w=Math.min(255,w+Math.ceil((255-w)*.1)),b=Math.min(255,b+Math.ceil((255-b)*.1)),k=Math.min(255,k+Math.ceil((255-k)*.1)),N=Wi(Mn.relativeLuminance2(w,b,k),Mn.relativeLuminance2(m,v,y));return(w<<24|b<<16|k<<8|255)>>>0}e.increaseLuminance=o;function a(u){return[u>>24&255,u>>16&255,u>>8&255,u&255]}e.toChannels=a})(Tl||(Tl={}));function Ws(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Wi(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var F1=class extends ia{constructor(e,t,n){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Kl=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new di}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],s=t.translateToString(!0),o=0,a=0,u=0,h=t.getFg(0),p=t.getBg(0);for(let m=0;m<t.getTrimmedLength();m++)if(t.loadCell(m,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==h||this._workCell.bg!==p){if(m-o>1){let v=this._getJoinedRanges(s,u,a,t,o);for(let y=0;y<v.length;y++)n.push(v[y])}o=m,u=a,h=this._workCell.fg,p=this._workCell.bg}a+=this._workCell.getChars().length||ks.length}if(this._bufferService.cols-o>1){let m=this._getJoinedRanges(s,u,a,t,o);for(let v=0;v<m.length;v++)n.push(m[v])}return n}_getJoinedRanges(e,t,n,s,o){let a=e.substring(t,n),u=[];try{u=this._characterJoiners[0].handler(a)}catch(h){console.error(h)}for(let h=1;h<this._characterJoiners.length;h++)try{let p=this._characterJoiners[h].handler(a);for(let m=0;m<p.length;m++)Kl._mergeRanges(u,p[m])}catch(p){console.error(p)}return this._stringRangesToCellRanges(u,s,o),u}_stringRangesToCellRanges(e,t,n){let s=0,o=!1,a=0,u=e[s];if(u){for(let h=n;h<this._bufferService.cols;h++){let p=t.getWidth(h),m=t.getString(h).length||ks.length;if(p!==0){if(!o&&u[0]<=a&&(u[0]=h,o=!0),u[1]<=a){if(u[1]=h,u=e[++s],!u)break;u[0]<=a?(u[0]=h,o=!0):o=!1}a+=m}}u&&(u[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let s=0;s<e.length;s++){let o=e[s];if(n){if(t[1]<=o[0])return e[s-1][1]=t[1],e;if(t[1]<=o[1])return e[s-1][1]=Math.max(t[1],o[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=o[0])return e.splice(s,0,t),e;if(t[1]<=o[1])return o[0]=Math.min(t[0],o[0]),e;t[0]<o[1]&&(o[0]=Math.min(t[0],o[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};Kl=qt([Te(0,In)],Kl);function H1(e){return 57508<=e&&e<=57558}function U1(e){return 9472<=e&&e<=9631}function W1(e){return H1(e)||U1(e)}function K1(){return{css:{canvas:yl(),cell:yl()},device:{canvas:yl(),cell:yl(),char:{width:0,height:0,left:0,top:0}}}}function yl(){return{width:0,height:0}}var bh=class{constructor(e,t,n,s,o,a,u){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=s,this._coreService=o,this._decorationService=a,this._themeService=u,this._workCell=new di,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,s,o,a,u,h,p,m,v){let y=[],w=this._characterJoinerService.getJoinedCharacters(t),b=this._themeService.colors,k=e.getNoBgTrimmedLength();n&&k<a+1&&(k=a+1);let N,S=0,j="",C=0,$=0,O=0,U=0,V=!1,K=0,Z=!1,G=0,Q=0,F=[],B=m!==-1&&v!==-1;for(let A=0;A<k;A++){e.loadCell(A,this._workCell);let z=this._workCell.getWidth();if(z===0)continue;let I=!1,D=A>=Q,P=A,x=this._workCell;if(w.length>0&&A===w[0][0]&&D){let Ae=w.shift(),Dt=this._isCellInSelection(Ae[0],t);for(C=Ae[0]+1;C<Ae[1];C++)D&&(D=Dt===this._isCellInSelection(C,t));D&&(D=!n||a<Ae[0]||a>=Ae[1]),D?(I=!0,x=new F1(this._workCell,e.translateToString(!0,Ae[0],Ae[1]),Ae[1]-Ae[0]),P=Ae[1]-1,z=x.getWidth()):Q=Ae[1]}let M=this._isCellInSelection(A,t),L=n&&A===a,T=B&&A>=m&&A<=v,H=!1;this._decorationService.forEachDecorationAtCell(A,t,void 0,Ae=>{H=!0});let Y=x.getChars()||ks;if(Y===" "&&(x.isUnderline()||x.isOverline())&&(Y=" "),G=z*h-p.get(Y,x.isBold(),x.isItalic()),!N)N=this._document.createElement("span");else if(S&&(M&&Z||!M&&!Z&&x.bg===$)&&(M&&Z&&b.selectionForeground||x.fg===O)&&x.extended.ext===U&&T===V&&G===K&&!L&&!I&&!H&&D){x.isInvisible()?j+=ks:j+=Y,S++;continue}else S&&(N.textContent=j),N=this._document.createElement("span"),S=0,j="";if($=x.bg,O=x.fg,U=x.extended.ext,V=T,K=G,Z=M,I&&a>=A&&a<=P&&(a=A),!this._coreService.isCursorHidden&&L&&this._coreService.isCursorInitialized){if(F.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&F.push("xterm-cursor-blink"),F.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":F.push("xterm-cursor-outline");break;case"block":F.push("xterm-cursor-block");break;case"bar":F.push("xterm-cursor-bar");break;case"underline":F.push("xterm-cursor-underline");break}}if(x.isBold()&&F.push("xterm-bold"),x.isItalic()&&F.push("xterm-italic"),x.isDim()&&F.push("xterm-dim"),x.isInvisible()?j=ks:j=x.getChars()||ks,x.isUnderline()&&(F.push(`xterm-underline-${x.extended.underlineStyle}`),j===" "&&(j=" "),!x.isUnderlineColorDefault()))if(x.isUnderlineColorRGB())N.style.textDecorationColor=`rgb(${ia.toColorRGB(x.getUnderlineColor()).join(",")})`;else{let Ae=x.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&x.isBold()&&Ae<8&&(Ae+=8),N.style.textDecorationColor=b.ansi[Ae].css}x.isOverline()&&(F.push("xterm-overline"),j===" "&&(j=" ")),x.isStrikethrough()&&F.push("xterm-strikethrough"),T&&(N.style.textDecoration="underline");let de=x.getFgColor(),ue=x.getFgColorMode(),fe=x.getBgColor(),ve=x.getBgColorMode(),ie=!!x.isInverse();if(ie){let Ae=de;de=fe,fe=Ae;let Dt=ue;ue=ve,ve=Dt}let ye,Ue,ut=!1;this._decorationService.forEachDecorationAtCell(A,t,void 0,Ae=>{Ae.options.layer!=="top"&&ut||(Ae.backgroundColorRGB&&(ve=50331648,fe=Ae.backgroundColorRGB.rgba>>8&16777215,ye=Ae.backgroundColorRGB),Ae.foregroundColorRGB&&(ue=50331648,de=Ae.foregroundColorRGB.rgba>>8&16777215,Ue=Ae.foregroundColorRGB),ut=Ae.options.layer==="top")}),!ut&&M&&(ye=this._coreBrowserService.isFocused?b.selectionBackgroundOpaque:b.selectionInactiveBackgroundOpaque,fe=ye.rgba>>8&16777215,ve=50331648,ut=!0,b.selectionForeground&&(ue=50331648,de=b.selectionForeground.rgba>>8&16777215,Ue=b.selectionForeground)),ut&&F.push("xterm-decoration-top");let rt;switch(ve){case 16777216:case 33554432:rt=b.ansi[fe],F.push(`xterm-bg-${fe}`);break;case 50331648:rt=nn.toColor(fe>>16,fe>>8&255,fe&255),this._addStyle(N,`background-color:#${cv((fe>>>0).toString(16),"0",6)}`);break;case 0:default:ie?(rt=b.foreground,F.push("xterm-bg-257")):rt=b.background}switch(ye||x.isDim()&&(ye=Mt.multiplyOpacity(rt,.5)),ue){case 16777216:case 33554432:x.isBold()&&de<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(de+=8),this._applyMinimumContrast(N,rt,b.ansi[de],x,ye,void 0)||F.push(`xterm-fg-${de}`);break;case 50331648:let Ae=nn.toColor(de>>16&255,de>>8&255,de&255);this._applyMinimumContrast(N,rt,Ae,x,ye,Ue)||this._addStyle(N,`color:#${cv(de.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(N,rt,b.foreground,x,ye,Ue)||ie&&F.push("xterm-fg-257")}F.length&&(N.className=F.join(" "),F.length=0),!L&&!I&&!H&&D?S++:N.textContent=j,G!==this.defaultSpacing&&(N.style.letterSpacing=`${G}px`),y.push(N),A=P}return N&&S&&(N.textContent=j),y}_applyMinimumContrast(e,t,n,s,o,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||W1(s.getCode()))return!1;let u=this._getContrastCache(s),h;if(!o&&!a&&(h=u.getColor(t.rgba,n.rgba)),h===void 0){let p=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);h=Mt.ensureContrastRatio(o||t,a||n,p),u.setColor((o||t).rgba,(a||n).rgba,h??null)}return h?(this._addStyle(e,`color:${h.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,s=this._selectionEnd;return!n||!s?!1:this._columnSelectMode?n[0]<=s[0]?e>=n[0]&&t>=n[1]&&e<s[0]&&t<=s[1]:e<n[0]&&t>=n[1]&&e>=s[0]&&t<=s[1]:t>n[1]&&t<s[1]||n[1]===s[1]&&t===n[1]&&e>=n[0]&&e<s[0]||n[1]<s[1]&&t===s[1]&&e<s[0]||n[1]<s[1]&&t===n[1]&&e>=n[0]}};bh=qt([Te(1,Uy),Te(2,On),Te(3,Gi),Te(4,tr),Te(5,sa),Te(6,Wr)],bh);function cv(e,t,n){for(;e.length<n;)e=t+e;return e}var q1=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let n=e.createElement("span");n.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontStyle="italic";let a=e.createElement("span");a.classList.add("xterm-char-measure-element"),a.style.fontWeight="bold",a.style.fontStyle="italic",this._measureElements=[n,s,o,a],this._container.appendChild(n),this._container.appendChild(s),this._container.appendChild(o),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,s){e===this._font&&t===this._fontSize&&n===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,n){let s=0;if(!t&&!n&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let u=this._measure(e,0);return u>0&&(this._flat[s]=u),u}let o=e;t&&(o+="B"),n&&(o+="I");let a=this._holey.get(o);if(a===void 0){let u=0;t&&(u|=1),n&&(u|=2),a=this._measure(e,u),a>0&&this._holey.set(o,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},V1=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,s=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let o=e.buffers.active.ydisp,a=t[1]-o,u=n[1]-o,h=Math.max(a,0),p=Math.min(u,e.rows-1);if(h>=e.rows||p<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=a,this.viewportEndRow=u,this.viewportCappedStartRow=h,this.viewportCappedEndRow=p,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function Y1(){return new V1}var id="xterm-dom-renderer-owner-",li="xterm-rows",wl="xterm-fg-",uv="xterm-bg-",To="xterm-focus",bl="xterm-selection",G1=1,Sh=class extends lt{constructor(e,t,n,s,o,a,u,h,p,m,v,y,w,b){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=s,this._viewportElement=o,this._helperContainer=a,this._linkifier2=u,this._charSizeService=p,this._optionsService=m,this._bufferService=v,this._coreService=y,this._coreBrowserService=w,this._themeService=b,this._terminalClass=G1++,this._rowElements=[],this._selectionRenderModel=Y1(),this.onRequestRedraw=this._register(new Re).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(li),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(bl),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=K1(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(k=>this._injectCss(k))),this._injectCss(this._themeService.colors),this._rowFactory=h.createInstance(bh,document),this._element.classList.add(id+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(k=>this._handleLinkHover(k))),this._register(this._linkifier2.onHideLinkUnderline(k=>this._handleLinkLeave(k))),this._register(Bt(()=>{this._element.classList.remove(id+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new q1(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${li} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${li} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${li} .xterm-dim { color: ${Mt.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${o} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${li}.${To} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${li}.${To} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${li}.${To} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${li} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${li} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${li} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${li} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${li} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${bl} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${bl} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${bl} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[a,u]of e.ansi.entries())t+=`${this._terminalSelector} .${wl}${a} { color: ${u.css}; }${this._terminalSelector} .${wl}${a}.xterm-dim { color: ${Mt.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${uv}${a} { background-color: ${u.css}; }`;t+=`${this._terminalSelector} .${wl}257 { color: ${Mt.opaque(e.background).css}; }${this._terminalSelector} .${wl}257.xterm-dim { color: ${Mt.multiplyOpacity(Mt.opaque(e.background),.5).css}; }${this._terminalSelector} .${uv}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let n=this._rowElements.length;n<=t;n++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(To),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(To),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,u=this._selectionRenderModel.viewportCappedEndRow,h=this._document.createDocumentFragment();if(n){let p=e[0]>t[0];h.appendChild(this._createSelectionElement(a,p?t[0]:e[0],p?e[0]:t[0],u-a+1))}else{let p=s===a?e[0]:0,m=a===o?t[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(a,p,m));let v=u-a-1;if(h.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,v)),a!==u){let y=o===u?t[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(u,0,y))}}this._selectionContainer.appendChild(h)}_createSelectionElement(e,t,n,s=1){let o=this._document.createElement("div"),a=t*this.dimensions.css.cell.width,u=this.dimensions.css.cell.width*(n-t);return a+u>this.dimensions.css.canvas.width&&(u=this.dimensions.css.canvas.width-a),o.style.height=`${s*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${a}px`,o.style.width=`${u}px`,o}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,s=n.ybase+n.y,o=Math.min(n.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,u=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,h=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=e;p<=t;p++){let m=p+n.ydisp,v=this._rowElements[p],y=n.lines.get(m);if(!v||!y)break;v.replaceChildren(...this._rowFactory.createRow(y,m,m===s,u,h,o,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${id}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,s,o,a){n<0&&(e=0),s<0&&(t=0);let u=this._bufferService.rows-1;n=Math.max(Math.min(n,u),0),s=Math.max(Math.min(s,u),0),o=Math.min(o,this._bufferService.cols);let h=this._bufferService.buffer,p=h.ybase+h.y,m=Math.min(h.x,o-1),v=this._optionsService.rawOptions.cursorBlink,y=this._optionsService.rawOptions.cursorStyle,w=this._optionsService.rawOptions.cursorInactiveStyle;for(let b=n;b<=s;++b){let k=b+h.ydisp,N=this._rowElements[b],S=h.lines.get(k);if(!N||!S)break;N.replaceChildren(...this._rowFactory.createRow(S,k,k===p,y,w,m,v,this.dimensions.css.cell.width,this._widthCache,a?b===n?e:0:-1,a?(b===s?t:o)-1:-1))}}};Sh=qt([Te(7,pf),Te(8,tc),Te(9,On),Te(10,In),Te(11,tr),Te(12,Gi),Te(13,Wr)],Sh);var xh=class extends lt{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Re),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Q1(this._optionsService))}catch{this._measureStrategy=this._register(new X1(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};xh=qt([Te(2,On)],xh);var lw=class extends lt{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},X1=class extends lw{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},Q1=class extends lw{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},J1=class extends lt{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new Z1(this._window)),this._onDprChange=this._register(new Re),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Re),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Cn.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(et(this._textarea,"focus",()=>this._isFocused=!0)),this._register(et(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}},Z1=class extends lt{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new $r),this._onDprChange=this._register(new Re),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Bt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=et(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)}},eC=class extends lt{constructor(){super(),this.linkProviders=[],this._register(Bt(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function Sf(e,t,n){let s=n.getBoundingClientRect(),o=e.getComputedStyle(n),a=parseInt(o.getPropertyValue("padding-left")),u=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-s.left-a,t.clientY-s.top-u]}function tC(e,t,n,s,o,a,u,h,p){if(!a)return;let m=Sf(e,t,n);if(m)return m[0]=Math.ceil((m[0]+(p?u/2:0))/u),m[1]=Math.ceil(m[1]/h),m[0]=Math.min(Math.max(m[0],1),s+(p?1:0)),m[1]=Math.min(Math.max(m[1],1),o),m}var kh=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,o){return tC(window,e,t,n,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let n=Sf(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};kh=qt([Te(0,Xi),Te(1,tc)],kh);var nC=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},cw={};hk(cw,{getSafariVersion:()=>sC,isChromeOS:()=>fw,isFirefox:()=>uw,isIpad:()=>rC,isIphone:()=>oC,isLegacyEdge:()=>iC,isLinux:()=>xf,isMac:()=>ql,isNode:()=>nc,isSafari:()=>dw,isWindows:()=>hw});var nc=typeof process<"u"&&"title"in process,ra=nc?"node":navigator.userAgent,oa=nc?"node":navigator.platform,uw=ra.includes("Firefox"),iC=ra.includes("Edge"),dw=/^((?!chrome|android).)*safari/i.test(ra);function sC(){if(!dw)return 0;let e=ra.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var ql=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(oa),rC=oa==="iPad",oC=oa==="iPhone",hw=["Windows","Win16","Win32","WinCE"].includes(oa),xf=oa.indexOf("Linux")>=0,fw=/\bCrOS\b/.test(ra),pw=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,n=0,s=e.timeRemaining(),o=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),o=e.timeRemaining(),n*1.5>o){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=o}this.clear()}},aC=class extends pw{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},lC=class extends pw{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Vl=!nc&&"requestIdleCallback"in window?lC:aC,cC=class{constructor(){this._queue=new Vl}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Ch=class extends lt{constructor(e,t,n,s,o,a,u,h,p){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=o,this._coreBrowserService=h,this._renderer=this._register(new $r),this._pausedResizeTask=new cC,this._observerDisposable=this._register(new $r),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new Re),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Re),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Re),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Re),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new nC((m,v)=>this._renderRows(m,v),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new uC(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Bt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(u.onResize(()=>this._fullRefresh())),this._register(u.buffers.onBufferActivate(()=>{var m;return(m=this._renderer.value)==null?void 0:m.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(u.cols,u.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(u.buffer.y,u.buffer.y,!0))),this._register(p.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(m=>this._registerIntersectionObserver(m,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=Bt(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var n;return(n=this._renderer.value)==null?void 0:n.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,n){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,n)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Ch=qt([Te(2,On),Te(3,tc),Te(4,tr),Te(5,sa),Te(6,In),Te(7,Gi),Te(8,Wr)],Ch);var uC=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function dC(e,t,n,s){let o=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return pC(o,a,e,t,n,s)+ic(a,t,n,s)+mC(o,a,e,t,n,s);let u;if(a===t)return u=o>e?"D":"C",Jo(Math.abs(o-e),Qo(u,s));u=a>t?"D":"C";let h=Math.abs(a-t),p=fC(a>t?e:o,n)+(h-1)*n.cols+1+hC(a>t?o:e);return Jo(p,Qo(u,s))}function hC(e,t){return e-1}function fC(e,t){return t.cols-e}function pC(e,t,n,s,o,a){return ic(t,s,o,a).length===0?"":Jo(gw(e,t,e,t-er(t,o),!1,o).length,Qo("D",a))}function ic(e,t,n,s){let o=e-er(e,n),a=t-er(t,n),u=Math.abs(o-a)-gC(e,t,n);return Jo(u,Qo(mw(e,t),s))}function mC(e,t,n,s,o,a){let u;ic(t,s,o,a).length>0?u=s-er(s,o):u=t;let h=s,p=vC(e,t,n,s,o,a);return Jo(gw(e,u,n,h,p==="C",o).length,Qo(p,a))}function gC(e,t,n){var u;let s=0,o=e-er(e,n),a=t-er(t,n);for(let h=0;h<Math.abs(o-a);h++){let p=mw(e,t)==="A"?-1:1;(u=n.buffer.lines.get(o+p*h))!=null&&u.isWrapped&&s++}return s}function er(e,t){let n=0,s=t.buffer.lines.get(e),o=s==null?void 0:s.isWrapped;for(;o&&e>=0&&e<t.rows;)n++,s=t.buffer.lines.get(--e),o=s==null?void 0:s.isWrapped;return n}function vC(e,t,n,s,o,a){let u;return ic(n,s,o,a).length>0?u=s-er(s,o):u=t,e<n&&u<=s||e>=n&&u<s?"C":"D"}function mw(e,t){return e>t?"A":"B"}function gw(e,t,n,s,o,a){let u=e,h=t,p="";for(;(u!==n||h!==s)&&h>=0&&h<a.buffer.lines.length;)u+=o?1:-1,o&&u>a.cols-1?(p+=a.buffer.translateBufferLineToString(h,!1,e,u),u=0,e=0,h++):!o&&u<0&&(p+=a.buffer.translateBufferLineToString(h,!1,0,e+1),u=a.cols-1,e=u,h--);return p+a.buffer.translateBufferLineToString(h,!1,e,u)}function Qo(e,t){let n=t?"O":"[";return ge.ESC+n+e}function Jo(e,t){e=Math.floor(e);let n="";for(let s=0;s<e;s++)n+=t;return n}var _C=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function dv(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var sd=50,yC=15,wC=50,bC=500,SC=" ",xC=new RegExp(SC,"g"),Eh=class extends lt{constructor(e,t,n,s,o,a,u,h,p){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=s,this._coreService=o,this._mouseService=a,this._optionsService=u,this._renderService=h,this._coreBrowserService=p,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new di,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Re),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Re),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Re),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Re),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=m=>this._handleMouseMove(m),this._mouseUpListener=m=>this._handleMouseUp(m),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(m=>this._handleTrim(m)),this._register(this._bufferService.buffers.onBufferActivate(m=>this._handleBufferActivate(m))),this.enable(),this._model=new _C(this._bufferService),this._activeSelectionMode=0,this._register(Bt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(m=>{m.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let u=e[1];u<=t[1];u++){let h=n.translateBufferLineToString(u,!0,o,a);s.push(h)}}else{let o=e[1]===t[1]?t[0]:void 0;s.push(n.translateBufferLineToString(e[1],!0,e[0],o));for(let a=e[1]+1;a<=t[1]-1;a++){let u=n.lines.get(a),h=n.translateBufferLineToString(a,!0);u!=null&&u.isWrapped?s[s.length-1]+=h:s.push(h)}if(e[1]!==t[1]){let a=n.lines.get(t[1]),u=n.translateBufferLineToString(t[1],!0,0,t[0]);a&&a.isWrapped?s[s.length-1]+=u:s.push(u)}}return s.map(o=>o.replace(xC," ")).join(hw?`\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())),xf&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s||!t?!1:this._areCoordsInSelection(t,n,s)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s?!1:this._areCoordsInSelection([e,t],n,s)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var o,a;let n=(a=(o=this._linkifier.currentLink)==null?void 0:o.link)==null?void 0:a.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=dv(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Sf(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-sd),sd),t/=sd,t/Math.abs(t)+Math.round(t*(yC-1)))}shouldForceSelection(e){return ql?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(),wC)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(ql&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let s=n.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<bC&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let n=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(n&&n[0]!==void 0&&n[1]!==void 0){let s=dC(n[0]-1,n[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let s=0;t>=s;s++){let o=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:o>1&&t!==s&&(n+=o-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,a=o.lines.get(e[1]);if(!a)return;let u=o.translateBufferLineToString(e[1],!1),h=this._convertViewportColToCharacterIndex(a,e[0]),p=h,m=e[0]-h,v=0,y=0,w=0,b=0;if(u.charAt(h)===" "){for(;h>0&&u.charAt(h-1)===" ";)h--;for(;p<u.length&&u.charAt(p+1)===" ";)p++}else{let S=e[0],j=e[0];a.getWidth(S)===0&&(v++,S--),a.getWidth(j)===2&&(y++,j++);let C=a.getString(j).length;for(C>1&&(b+=C-1,p+=C-1);S>0&&h>0&&!this._isCharWordSeparator(a.loadCell(S-1,this._workCell));){a.loadCell(S-1,this._workCell);let $=this._workCell.getChars().length;this._workCell.getWidth()===0?(v++,S--):$>1&&(w+=$-1,h-=$-1),h--,S--}for(;j<a.length&&p+1<u.length&&!this._isCharWordSeparator(a.loadCell(j+1,this._workCell));){a.loadCell(j+1,this._workCell);let $=this._workCell.getChars().length;this._workCell.getWidth()===2?(y++,j++):$>1&&(b+=$-1,p+=$-1),p++,j++}}p++;let k=h+m-v+w,N=Math.min(this._bufferService.cols,p-h+v+y-w-b);if(!(!t&&u.slice(h,p).trim()==="")){if(n&&k===0&&a.getCodePoint(0)!==32){let S=o.lines.get(e[1]-1);if(S&&a.isWrapped&&S.getCodePoint(this._bufferService.cols-1)!==32){let j=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(j){let C=this._bufferService.cols-j.start;k-=C,N+=C}}}if(s&&k+N===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let S=o.lines.get(e[1]+1);if(S!=null&&S.isWrapped&&S.getCodePoint(0)!==32){let j=this._getWordAt([0,e[1]+1],!1,!1,!0);j&&(N+=j.length)}}return{start:k,length:N}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=dv(n,this._bufferService.cols)}};Eh=qt([Te(3,In),Te(4,tr),Te(5,mf),Te(6,On),Te(7,Xi),Te(8,Gi)],Eh);var hv=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},fv=class{constructor(){this._color=new hv,this._css=new hv}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},ln=Object.freeze((()=>{let e=[Ht.toColor("#2e3436"),Ht.toColor("#cc0000"),Ht.toColor("#4e9a06"),Ht.toColor("#c4a000"),Ht.toColor("#3465a4"),Ht.toColor("#75507b"),Ht.toColor("#06989a"),Ht.toColor("#d3d7cf"),Ht.toColor("#555753"),Ht.toColor("#ef2929"),Ht.toColor("#8ae234"),Ht.toColor("#fce94f"),Ht.toColor("#729fcf"),Ht.toColor("#ad7fa8"),Ht.toColor("#34e2e2"),Ht.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],o=t[n/6%6|0],a=t[n%6];e.push({css:nn.toCss(s,o,a),rgba:nn.toRgba(s,o,a)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:nn.toCss(s,s,s),rgba:nn.toRgba(s,s,s)})}return e})()),qs=Ht.toColor("#ffffff"),Uo=Ht.toColor("#000000"),pv=Ht.toColor("#ffffff"),mv=Uo,Mo={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},kC=qs,Nh=class extends lt{constructor(e){super(),this._optionsService=e,this._contrastCache=new fv,this._halfContrastCache=new fv,this._onChangeColors=this._register(new Re),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:qs,background:Uo,cursor:pv,cursorAccent:mv,selectionForeground:void 0,selectionBackgroundTransparent:Mo,selectionBackgroundOpaque:Mt.blend(Uo,Mo),selectionInactiveBackgroundTransparent:Mo,selectionInactiveBackgroundOpaque:Mt.blend(Uo,Mo),scrollbarSliderBackground:Mt.opacity(qs,.2),scrollbarSliderHoverBackground:Mt.opacity(qs,.4),scrollbarSliderActiveBackground:Mt.opacity(qs,.5),overviewRulerBorder:qs,ansi:ln.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=kt(e.foreground,qs),t.background=kt(e.background,Uo),t.cursor=Mt.blend(t.background,kt(e.cursor,pv)),t.cursorAccent=Mt.blend(t.background,kt(e.cursorAccent,mv)),t.selectionBackgroundTransparent=kt(e.selectionBackground,Mo),t.selectionBackgroundOpaque=Mt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=kt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Mt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?kt(e.selectionForeground,lv):void 0,t.selectionForeground===lv&&(t.selectionForeground=void 0),Mt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Mt.opacity(t.selectionBackgroundTransparent,.3)),Mt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Mt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=kt(e.scrollbarSliderBackground,Mt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=kt(e.scrollbarSliderHoverBackground,Mt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=kt(e.scrollbarSliderActiveBackground,Mt.opacity(t.foreground,.5)),t.overviewRulerBorder=kt(e.overviewRulerBorder,kC),t.ansi=ln.slice(),t.ansi[0]=kt(e.black,ln[0]),t.ansi[1]=kt(e.red,ln[1]),t.ansi[2]=kt(e.green,ln[2]),t.ansi[3]=kt(e.yellow,ln[3]),t.ansi[4]=kt(e.blue,ln[4]),t.ansi[5]=kt(e.magenta,ln[5]),t.ansi[6]=kt(e.cyan,ln[6]),t.ansi[7]=kt(e.white,ln[7]),t.ansi[8]=kt(e.brightBlack,ln[8]),t.ansi[9]=kt(e.brightRed,ln[9]),t.ansi[10]=kt(e.brightGreen,ln[10]),t.ansi[11]=kt(e.brightYellow,ln[11]),t.ansi[12]=kt(e.brightBlue,ln[12]),t.ansi[13]=kt(e.brightMagenta,ln[13]),t.ansi[14]=kt(e.brightCyan,ln[14]),t.ansi[15]=kt(e.brightWhite,ln[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<n;s++)t.ansi[s+16]=kt(e.extendedAnsi[s],ln[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};Nh=qt([Te(0,On)],Nh);function kt(e,t){if(e!==void 0)try{return Ht.toColor(e)}catch{}return t}var CC=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},EC=class{constructor(){this._services=new CC,this._services.set(pf,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=yk(e).sort((a,u)=>a.index-u.index),s=[];for(let a of n){let u=this._services.get(a.id);if(!u)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${a.id._id}.`);s.push(u)}let o=n.length>0?n[0].index:t.length;if(t.length!==o)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${o+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},NC={trace:0,debug:1,info:2,warn:3,error:4,off:5},jC="xterm.js: ",jh=class extends lt{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=NC[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?"":jC)+t,...n)}trace(e,...t){var n;this._logLevel<=0&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var n;this._logLevel<=1&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var n;this._logLevel<=2&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var n;this._logLevel<=3&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var n;this._logLevel<=4&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.error.bind(this._optionsService.options.logger))??console.error,e,t)}};jh=qt([Te(0,On)],jh);var gv=class extends lt{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Re),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Re),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Re),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+n.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<n.length;s++)this._array[this._getCyclicIndex(e+s)]=n[s];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let s=this._length+n.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let o=t-1;o>=0;o--)this.set(e+o+n,this.get(e+o));let s=e+t+n-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+n,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},at=3,tn=Object.freeze(new ia),Sl=0,rd=2,Wo=class vw{constructor(t,n,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*at);let o=n||di.fromCharData([0,Iy,1,0]);for(let a=0;a<t;++a)this.setCell(a,o);this.length=t}get(t){let n=this._data[t*at+0],s=n&2097151;return[this._data[t*at+1],n&2097152?this._combined[t]:s?Ss(s):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,n){this._data[t*at+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*at+0]=t|2097152|n[2]<<22):this._data[t*at+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*at+0]>>22}hasWidth(t){return this._data[t*at+0]&12582912}getFg(t){return this._data[t*at+1]}getBg(t){return this._data[t*at+2]}hasContent(t){return this._data[t*at+0]&4194303}getCodePoint(t){let n=this._data[t*at+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*at+0]&2097152}getString(t){let n=this._data[t*at+0];return n&2097152?this._combined[t]:n&2097151?Ss(n&2097151):""}isProtected(t){return this._data[t*at+2]&536870912}loadCell(t,n){return Sl=t*at,n.content=this._data[Sl+0],n.fg=this._data[Sl+1],n.bg=this._data[Sl+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*at+0]=n.content,this._data[t*at+1]=n.fg,this._data[t*at+2]=n.bg}setCellFromCodepoint(t,n,s,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*at+0]=n|s<<22,this._data[t*at+1]=o.fg,this._data[t*at+2]=o.bg}addCodepointToCell(t,n,s){let o=this._data[t*at+0];o&2097152?this._combined[t]+=Ss(n):o&2097151?(this._combined[t]=Ss(o&2097151)+Ss(n),o&=-2097152,o|=2097152):o=n|1<<22,s&&(o&=-12582913,o|=s<<22),this._data[t*at+0]=o}insertCells(t,n,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length-t){let o=new di;for(let a=this.length-t-n-1;a>=0;--a)this.setCell(t+n+a,this.loadCell(t+a,o));for(let a=0;a<n;++a)this.setCell(t+a,s)}else for(let o=t;o<this.length;++o)this.setCell(o,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,n,s){if(t%=this.length,n<this.length-t){let o=new di;for(let a=0;a<this.length-t-n;++a)this.setCell(t+a,this.loadCell(t+n+a,o));for(let a=this.length-n;a<this.length;++a)this.setCell(a,s)}else for(let o=t;o<this.length;++o)this.setCell(o,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,n,s,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,s);t<n&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,s);t<n&&t<this.length;)this.setCell(t++,s)}resize(t,n){if(t===this.length)return this._data.length*4*rd<this._data.buffer.byteLength;let s=t*at;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let o=new Uint32Array(s);o.set(this._data),this._data=o}for(let o=this.length;o<t;++o)this.setCell(o,n)}else{this._data=this._data.subarray(0,s);let o=Object.keys(this._combined);for(let u=0;u<o.length;u++){let h=parseInt(o[u],10);h>=t&&delete this._combined[h]}let a=Object.keys(this._extendedAttrs);for(let u=0;u<a.length;u++){let h=parseInt(a[u],10);h>=t&&delete this._extendedAttrs[h]}}return this.length=t,s*4*rd<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*rd<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,n=!1){if(n){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let n in t._combined)this._combined[n]=t._combined[n];this._extendedAttrs={};for(let n in t._extendedAttrs)this._extendedAttrs[n]=t._extendedAttrs[n];this.isWrapped=t.isWrapped}clone(){let t=new vw(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let n in this._combined)t._combined[n]=this._combined[n];for(let n in this._extendedAttrs)t._extendedAttrs[n]=this._extendedAttrs[n];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*at+0]&4194303)return t+(this._data[t*at+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*at+0]&4194303||this._data[t*at+2]&50331648)return t+(this._data[t*at+0]>>22);return 0}copyCellsFrom(t,n,s,o,a){let u=t._data;if(a)for(let p=o-1;p>=0;p--){for(let m=0;m<at;m++)this._data[(s+p)*at+m]=u[(n+p)*at+m];u[(n+p)*at+2]&268435456&&(this._extendedAttrs[s+p]=t._extendedAttrs[n+p])}else for(let p=0;p<o;p++){for(let m=0;m<at;m++)this._data[(s+p)*at+m]=u[(n+p)*at+m];u[(n+p)*at+2]&268435456&&(this._extendedAttrs[s+p]=t._extendedAttrs[n+p])}let h=Object.keys(t._combined);for(let p=0;p<h.length;p++){let m=parseInt(h[p],10);m>=n&&(this._combined[m-n+s]=t._combined[m])}}translateToString(t,n,s,o){n=n??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),o&&(o.length=0);let a="";for(;n<s;){let u=this._data[n*at+0],h=u&2097151,p=u&2097152?this._combined[n]:h?Ss(h):ks;if(a+=p,o)for(let m=0;m<p.length;++m)o.push(n);n+=u>>22||1}return o&&o.push(n),a}};function RC(e,t,n,s,o,a){let u=[];for(let h=0;h<e.length-1;h++){let p=h,m=e.get(++p);if(!m.isWrapped)continue;let v=[e.get(h)];for(;p<e.length&&m.isWrapped;)v.push(m),m=e.get(++p);if(!a&&s>=h&&s<p){h+=v.length-1;continue}let y=0,w=Zo(v,y,t),b=1,k=0;for(;b<v.length;){let S=Zo(v,b,t),j=S-k,C=n-w,$=Math.min(j,C);v[y].copyCellsFrom(v[b],k,w,$,!1),w+=$,w===n&&(y++,w=0),k+=$,k===S&&(b++,k=0),w===0&&y!==0&&v[y-1].getWidth(n-1)===2&&(v[y].copyCellsFrom(v[y-1],n-1,w++,1,!1),v[y-1].setCell(n-1,o))}v[y].replaceCells(w,n,o);let N=0;for(let S=v.length-1;S>0&&(S>y||v[S].getTrimmedLength()===0);S--)N++;N>0&&(u.push(h+v.length-N),u.push(N)),h+=v.length-1}return u}function PC(e,t){let n=[],s=0,o=t[s],a=0;for(let u=0;u<e.length;u++)if(o===u){let h=t[++s];e.onDeleteEmitter.fire({index:u-a,amount:h}),u+=h-1,a+=h,o=t[++s]}else n.push(u);return{layout:n,countRemoved:a}}function AC(e,t){let n=[];for(let s=0;s<t.length;s++)n.push(e.get(t[s]));for(let s=0;s<n.length;s++)e.set(s,n[s]);e.length=t.length}function LC(e,t,n){let s=[],o=e.map((p,m)=>Zo(e,m,t)).reduce((p,m)=>p+m),a=0,u=0,h=0;for(;h<o;){if(o-h<n){s.push(o-h);break}a+=n;let p=Zo(e,u,t);a>p&&(a-=p,u++);let m=e[u].getWidth(a-1)===2;m&&a--;let v=m?n-1:n;s.push(v),h+=v}return s}function Zo(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,o=e[t+1].getWidth(0)===2;return s&&o?n-1:n}var _w=class yw{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=yw._nextId++,this._onDispose=this.register(new Re),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Zs(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};_w._nextId=1;var TC=_w,un={},Vs=un.B;un[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:"≥","{":"π","|":"≠","}":"£","~":"·"};un.A={"#":"£"};un.B=void 0;un[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};un.C=un[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};un.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};un.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};un.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};un.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};un.E=un[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};un.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};un.H=un[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};un["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var vv=4294967295,_v=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=tn.clone(),this.savedCharset=Vs,this.markers=[],this._nullCell=di.fromCharData([0,Iy,1,0]),this._whitespaceCell=di.fromCharData([0,ks,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Vl,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new gv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new Ul),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new Ul),this._whitespaceCell}getBlankLine(e,t){return new Wo(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>vv?vv:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=tn);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new gv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(tn),s=0,o=this._getCorrectBufferLength(t);if(o>this.lines.maxLength&&(this.lines.maxLength=o),this.lines.length>0){if(this._cols<e)for(let u=0;u<this.lines.length;u++)s+=+this.lines.get(u).resize(e,n);let a=0;if(this._rows<t)for(let u=this._rows;u<t;u++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Wo(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new Wo(e,n)));else for(let u=this._rows;u>t;u--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(o<this.lines.maxLength){let u=this.lines.length-o;u>0&&(this.lines.trimStart(u),this.ybase=Math.max(this.ybase-u,0),this.ydisp=Math.max(this.ydisp-u,0),this.savedY=Math.max(this.savedY-u,0)),this.lines.maxLength=o}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let a=0;a<this.lines.length;a++)s+=+this.lines.get(a).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=RC(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(tn),n);if(s.length>0){let o=PC(this.lines,s);AC(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=this.getNullCell(tn),o=n;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Wo(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(tn),o=[],a=0;for(let u=this.lines.length-1;u>=0;u--){let h=this.lines.get(u);if(!h||!h.isWrapped&&h.getTrimmedLength()<=e)continue;let p=[h];for(;h.isWrapped&&u>0;)h=this.lines.get(--u),p.unshift(h);if(!n){let $=this.ybase+this.y;if($>=u&&$<u+p.length)continue}let m=p[p.length-1].getTrimmedLength(),v=LC(p,this._cols,e),y=v.length-p.length,w;this.ybase===0&&this.y!==this.lines.length-1?w=Math.max(0,this.y-this.lines.maxLength+y):w=Math.max(0,this.lines.length-this.lines.maxLength+y);let b=[];for(let $=0;$<y;$++){let O=this.getBlankLine(tn,!0);b.push(O)}b.length>0&&(o.push({start:u+p.length+a,newLines:b}),a+=b.length),p.push(...b);let k=v.length-1,N=v[k];N===0&&(k--,N=v[k]);let S=p.length-y-1,j=m;for(;S>=0;){let $=Math.min(j,N);if(p[k]===void 0)break;if(p[k].copyCellsFrom(p[S],j-$,N-$,$,!0),N-=$,N===0&&(k--,N=v[k]),j-=$,j===0){S--;let O=Math.max(S,0);j=Zo(p,O,this._cols)}}for(let $=0;$<p.length;$++)v[$]<e&&p[$].setCell(v[$],s);let C=y-w;for(;C-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+y,this.ybase+t-1)}if(o.length>0){let u=[],h=[];for(let N=0;N<this.lines.length;N++)h.push(this.lines.get(N));let p=this.lines.length,m=p-1,v=0,y=o[v];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let w=0;for(let N=Math.min(this.lines.maxLength-1,p+a-1);N>=0;N--)if(y&&y.start>m+w){for(let S=y.newLines.length-1;S>=0;S--)this.lines.set(N--,y.newLines[S]);N++,u.push({index:m+1,amount:y.newLines.length}),w+=y.newLines.length,y=o[++v]}else this.lines.set(N,h[m--]);let b=0;for(let N=u.length-1;N>=0;N--)u[N].index+=b,this.lines.onInsertEmitter.fire(u[N]),b+=u[N].amount;let k=Math.max(0,p+a-this.lines.maxLength);k>0&&this.lines.onTrimEmitter.fire(k)}}translateBufferLineToString(e,t,n=0,s){let o=this.lines.get(e);return o?o.translateToString(t,n,s):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new TC(e);return this.markers.push(t),t.register(this.lines.onTrim(n=>{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.line<n.index+n.amount&&t.dispose(),t.line>n.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},MC=class extends lt{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Re),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new _v(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new _v(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},ww=2,bw=1,Rh=class extends lt{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Re),this.onResize=this._onResize.event,this._onScroll=this._register(new Re),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,ww),this.rows=Math.max(e.rawOptions.rows||0,bw),this.buffers=this._register(new MC(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=n.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let o=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let u=n.lines.isFull;a===n.lines.length-1?u?n.lines.recycle().copyFrom(s):n.lines.push(s.clone()):n.lines.splice(a+1,0,s.clone()),u?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let u=a-o+1;n.lines.shiftElements(o+1,u-1,-1),n.lines.set(a,s.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let s=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),s!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};Rh=qt([Te(0,On)],Rh);var Rr={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:ql,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},DC=["normal","bold","100","200","300","400","500","600","700","800","900"],IC=class extends lt{constructor(e){super(),this._onOptionChange=this._register(new Re),this.onOptionChange=this._onOptionChange.event;let t={...Rr};for(let n in e)if(n in t)try{let s=e[n];t[n]=this._sanitizeAndValidateOption(n,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Bt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=n=>{if(!(n in Rr))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,s)=>{if(!(n in Rr))throw new Error(`No option with key "${n}"`);s=this._sanitizeAndValidateOption(n,s),this.rawOptions[n]!==s&&(this.rawOptions[n]=s,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let s={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Rr[e]),!OC(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Rr[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=DC.includes(t)?t:Rr[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function OC(e){return e==="block"||e==="underline"||e==="bar"}function Ko(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let s in e)n[s]=t<=1?e[s]:e[s]&&Ko(e[s],t-1);return n}var yv=Object.freeze({insertMode:!1}),wv=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Ph=class extends lt{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Re),this.onData=this._onData.event,this._onUserInput=this._register(new Re),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Re),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Re),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Ko(yv),this.decPrivateModes=Ko(wv)}reset(){this.modes=Ko(yv),this.decPrivateModes=Ko(wv)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Ph=qt([Te(0,In),Te(1,Fy),Te(2,On)],Ph);var bv={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function od(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var ad=String.fromCharCode,Sv={DEFAULT:e=>{let t=[od(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${ad(t[0])}${ad(t[1])}${ad(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${od(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${od(e,!0)};${e.x};${e.y}${t}`}},Ah=class extends lt{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Re),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(bv))this.addProtocol(s,bv[s]);for(let s of Object.keys(Sv))this.addEncoding(s,Sv[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let s=t/n,o=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(o/=s+0,Math.abs(e.deltaY)<50&&(o*=.3),this._wheelPartialScroll+=o,o=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(o*=this._bufferService.rows),o}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Ah=qt([Te(0,In),Te(1,tr),Te(2,On)],Ah);var ld=[[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]],BC=[[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]],cn;function zC(e,t){let n=0,s=t.length-1,o;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=n;)if(o=n+s>>1,e>t[o][1])n=o+1;else if(e<t[o][0])s=o-1;else return!0;return!1}var $C=class{constructor(){if(this.version="6",!cn){cn=new Uint8Array(65536),cn.fill(1),cn[0]=0,cn.fill(0,1,32),cn.fill(0,127,160),cn.fill(2,4352,4448),cn[9001]=2,cn[9002]=2,cn.fill(2,11904,42192),cn[12351]=1,cn.fill(2,44032,55204),cn.fill(2,63744,64256),cn.fill(2,65040,65050),cn.fill(2,65072,65136),cn.fill(2,65280,65377),cn.fill(2,65504,65511);for(let e=0;e<ld.length;++e)cn.fill(0,ld[e][0],ld[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?cn[e]:zC(e,BC)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),s=n===0&&t!==0;if(s){let o=Xs.extractWidth(t);o===0?s=!1:o>n&&(n=o)}return Xs.createPropertyValue(0,n,s)}},Xs=class Ml{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Re,this.onChange=this._onChange.event;let t=new $C;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,s=!1){return(t&16777215)<<3|(n&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,s=0,o=t.length;for(let a=0;a<o;++a){let u=t.charCodeAt(a);if(55296<=u&&u<=56319){if(++a>=o)return n+this.wcwidth(u);let m=t.charCodeAt(a);56320<=m&&m<=57343?u=(u-55296)*1024+m-56320+65536:n+=this.wcwidth(m)}let h=this.charProperties(u,s),p=Ml.extractWidth(h);Ml.extractShouldJoin(h)&&(p-=Ml.extractWidth(s)),n+=p,s=h}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},FC=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function xv(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var Do=2147483647,HC=256,Sw=class Lh{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>HC)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new Lh;if(!t.length)return n;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let o=t[s];if(Array.isArray(o))for(let a=0;a<o.length;++a)n.addSubParam(o[a]);else n.addParam(o)}return n}clone(){let t=new Lh(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let n=0;n<this.length;++n){t.push(this.params[n]);let s=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,o))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Do?Do:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>Do?Do:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-n>0?this._subParams.subarray(n,s):null}getSubParamsAll(){let t={};for(let n=0;n<this.length;++n){let s=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-s>0&&(t[n]=this._subParams.slice(s,o))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,o=s[n-1];s[n-1]=~o?Math.min(o*10+t,Do):t}},Io=[],UC=class{constructor(){this._state=0,this._active=Io,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Io}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=Io,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Io,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,"PUT",ec(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;s>=0&&(n=this._active[s].end(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=Io,this._id=-1,this._state=0}}},Jn=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=ec(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},Oo=[],WC=class{constructor(){this._handlers=Object.create(null),this._active=Oo,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Oo}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Oo,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Oo,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",ec(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;s>=0&&(n=this._active[s].unhook(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=Oo,this._ident=0}},qo=new Sw;qo.addParam(0);var kv=class{constructor(e){this._handler=e,this._data="",this._params=qo,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():qo,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=ec(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(n=>(this._params=qo,this._data="",this._hitLimit=!1,n));return this._params=qo,this._data="",this._hitLimit=!1,t}},KC=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,s){this.table[t<<8|e]=n<<4|s}addMany(e,t,n,s){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=n<<4|s}},ui=160,qC=(function(){let e=new KC(4095),t=Array.apply(null,Array(256)).map((h,p)=>p),n=(h,p)=>t.slice(h,p),s=n(32,127),o=n(0,24);o.push(25),o.push.apply(o,n(28,32));let a=n(0,14),u;e.setDefault(1,0),e.addMany(s,0,2,0);for(u in a)e.addMany([24,26,153,154],u,3,0),e.addMany(n(128,144),u,3,0),e.addMany(n(144,152),u,3,0),e.add(156,u,0,0),e.add(27,u,11,1),e.add(157,u,4,8),e.addMany([152,158,159],u,0,7),e.add(155,u,11,3),e.add(144,u,11,9);return e.addMany(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(o,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(o,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(o,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(ui,0,2,0),e.add(ui,8,5,8),e.add(ui,6,0,6),e.add(ui,11,0,11),e.add(ui,13,13,13),e})(),VC=class extends lt{constructor(e=qC){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 Sw,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(Bt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new UC),this._dcsParser=this._register(new WC),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let o=0;o<e.intermediates.length;++o){let a=e.intermediates.charCodeAt(o);if(32>a||a>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=a}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=s,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let s=this._escHandlers[n];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let s=this._csiHandlers[n];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,s,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=s,this._parseStack.chunkPos=o}parse(e,t,n){let s=0,o=0,a=0,u;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let h=this._parseStack.handlers,p=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&p>-1){for(;p>=0&&(u=h[p](this._params),u!==!0);p--)if(u instanceof Promise)return this._parseStack.handlerPos=p,u}this._parseStack.handlers=[];break;case 4:if(n===!1&&p>-1){for(;p>=0&&(u=h[p](),u!==!0);p--)if(u instanceof Promise)return this._parseStack.handlerPos=p,u}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],u=this._dcsParser.unhook(s!==24&&s!==26,n),u)return u;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],u=this._oscParser.end(s!==24&&s!==26,n),u)return u;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let h=a;h<t;++h){switch(s=e[h],o=this._transitions.table[this.currentState<<8|(s<160?s:ui)],o>>4){case 2:for(let w=h+1;;++w){if(w>=t||(s=e[w])<32||s>126&&s<ui){this._printHandler(e,h,w),h=w-1;break}if(++w>=t||(s=e[w])<32||s>126&&s<ui){this._printHandler(e,h,w),h=w-1;break}if(++w>=t||(s=e[w])<32||s>126&&s<ui){this._printHandler(e,h,w),h=w-1;break}if(++w>=t||(s=e[w])<32||s>126&&s<ui){this._printHandler(e,h,w),h=w-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:h,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let p=this._csiHandlers[this._collect<<8|s],m=p?p.length-1:-1;for(;m>=0&&(u=p[m](this._params),u!==!0);m--)if(u instanceof Promise)return this._preserveStack(3,p,m,o,h),u;m<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++h<t&&(s=e[h])>47&&s<60);h--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let v=this._escHandlers[this._collect<<8|s],y=v?v.length-1:-1;for(;y>=0&&(u=v[y](),u!==!0);y--)if(u instanceof Promise)return this._preserveStack(4,v,y,o,h),u;y<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let w=h+1;;++w)if(w>=t||(s=e[w])===24||s===26||s===27||s>127&&s<ui){this._dcsParser.put(e,h,w),h=w-1;break}break;case 14:if(u=this._dcsParser.unhook(s!==24&&s!==26),u)return this._preserveStack(6,[],0,o,h),u;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let w=h+1;;w++)if(w>=t||(s=e[w])<32||s>127&&s<ui){this._oscParser.put(e,h,w),h=w-1;break}break;case 6:if(u=this._oscParser.end(s!==24&&s!==26),u)return this._preserveStack(5,[],0,o,h),u;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},YC=/^([\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})$/,GC=/^[\da-f]+$/;function Cv(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=YC.exec(t);if(n){let s=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/s*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/s*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),GC.exec(t)&&[3,6,9,12].includes(t.length))){let n=t.length/3,s=[0,0,0];for(let o=0;o<3;++o){let a=parseInt(t.slice(n*o,n*o+n),16);s[o]=n===1?a<<4:n===2?a:n===3?a>>4:a>>8}return s}}function cd(e,t){let n=e.toString(16),s=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function XC(e,t=16){let[n,s,o]=e;return`rgb:${cd(n,t)}/${cd(s,t)}/${cd(o,t)}`}var QC={"(":0,")":1,"*":2,"+":3,"-":1,".":2},ys=131072,Ev=10;function Nv(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var jv=5e3,Rv=0,JC=class extends lt{constructor(e,t,n,s,o,a,u,h,p=new VC){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=s,this._optionsService=o,this._oscLinkService=a,this._coreMouseService=u,this._unicodeService=h,this._parser=p,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new vk,this._utf8Decoder=new _k,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=tn.clone(),this._eraseAttrDataInternal=tn.clone(),this._onRequestBell=this._register(new Re),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Re),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Re),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Re),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Re),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Re),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Re),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Re),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Re),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Re),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Re),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Re),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Re),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new Th(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(m=>this._activeBuffer=m.activeBuffer)),this._parser.setCsiHandlerFallback((m,v)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(m),params:v.toArray()})}),this._parser.setEscHandlerFallback(m=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(m)})}),this._parser.setExecuteHandlerFallback(m=>{this._logService.debug("Unknown EXECUTE code: ",{code:m})}),this._parser.setOscHandlerFallback((m,v,y)=>{this._logService.debug("Unknown OSC code: ",{identifier:m,action:v,data:y})}),this._parser.setDcsHandlerFallback((m,v,y)=>{v==="HOOK"&&(y=y.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(m),action:v,payload:y})}),this._parser.setPrintHandler((m,v,y)=>this.print(m,v,y)),this._parser.registerCsiHandler({final:"@"},m=>this.insertChars(m)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},m=>this.scrollLeft(m)),this._parser.registerCsiHandler({final:"A"},m=>this.cursorUp(m)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},m=>this.scrollRight(m)),this._parser.registerCsiHandler({final:"B"},m=>this.cursorDown(m)),this._parser.registerCsiHandler({final:"C"},m=>this.cursorForward(m)),this._parser.registerCsiHandler({final:"D"},m=>this.cursorBackward(m)),this._parser.registerCsiHandler({final:"E"},m=>this.cursorNextLine(m)),this._parser.registerCsiHandler({final:"F"},m=>this.cursorPrecedingLine(m)),this._parser.registerCsiHandler({final:"G"},m=>this.cursorCharAbsolute(m)),this._parser.registerCsiHandler({final:"H"},m=>this.cursorPosition(m)),this._parser.registerCsiHandler({final:"I"},m=>this.cursorForwardTab(m)),this._parser.registerCsiHandler({final:"J"},m=>this.eraseInDisplay(m,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},m=>this.eraseInDisplay(m,!0)),this._parser.registerCsiHandler({final:"K"},m=>this.eraseInLine(m,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},m=>this.eraseInLine(m,!0)),this._parser.registerCsiHandler({final:"L"},m=>this.insertLines(m)),this._parser.registerCsiHandler({final:"M"},m=>this.deleteLines(m)),this._parser.registerCsiHandler({final:"P"},m=>this.deleteChars(m)),this._parser.registerCsiHandler({final:"S"},m=>this.scrollUp(m)),this._parser.registerCsiHandler({final:"T"},m=>this.scrollDown(m)),this._parser.registerCsiHandler({final:"X"},m=>this.eraseChars(m)),this._parser.registerCsiHandler({final:"Z"},m=>this.cursorBackwardTab(m)),this._parser.registerCsiHandler({final:"`"},m=>this.charPosAbsolute(m)),this._parser.registerCsiHandler({final:"a"},m=>this.hPositionRelative(m)),this._parser.registerCsiHandler({final:"b"},m=>this.repeatPrecedingCharacter(m)),this._parser.registerCsiHandler({final:"c"},m=>this.sendDeviceAttributesPrimary(m)),this._parser.registerCsiHandler({prefix:">",final:"c"},m=>this.sendDeviceAttributesSecondary(m)),this._parser.registerCsiHandler({final:"d"},m=>this.linePosAbsolute(m)),this._parser.registerCsiHandler({final:"e"},m=>this.vPositionRelative(m)),this._parser.registerCsiHandler({final:"f"},m=>this.hVPosition(m)),this._parser.registerCsiHandler({final:"g"},m=>this.tabClear(m)),this._parser.registerCsiHandler({final:"h"},m=>this.setMode(m)),this._parser.registerCsiHandler({prefix:"?",final:"h"},m=>this.setModePrivate(m)),this._parser.registerCsiHandler({final:"l"},m=>this.resetMode(m)),this._parser.registerCsiHandler({prefix:"?",final:"l"},m=>this.resetModePrivate(m)),this._parser.registerCsiHandler({final:"m"},m=>this.charAttributes(m)),this._parser.registerCsiHandler({final:"n"},m=>this.deviceStatus(m)),this._parser.registerCsiHandler({prefix:"?",final:"n"},m=>this.deviceStatusPrivate(m)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},m=>this.softReset(m)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},m=>this.setCursorStyle(m)),this._parser.registerCsiHandler({final:"r"},m=>this.setScrollRegion(m)),this._parser.registerCsiHandler({final:"s"},m=>this.saveCursor(m)),this._parser.registerCsiHandler({final:"t"},m=>this.windowOptions(m)),this._parser.registerCsiHandler({final:"u"},m=>this.restoreCursor(m)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},m=>this.insertColumns(m)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},m=>this.deleteColumns(m)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},m=>this.selectProtected(m)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},m=>this.requestMode(m,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},m=>this.requestMode(m,!1)),this._parser.setExecuteHandler(ge.BEL,()=>this.bell()),this._parser.setExecuteHandler(ge.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(ge.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(ge.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(ge.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(ge.BS,()=>this.backspace()),this._parser.setExecuteHandler(ge.HT,()=>this.tab()),this._parser.setExecuteHandler(ge.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(ge.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Ll.IND,()=>this.index()),this._parser.setExecuteHandler(Ll.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Ll.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Jn(m=>(this.setTitle(m),this.setIconName(m),!0))),this._parser.registerOscHandler(1,new Jn(m=>this.setIconName(m))),this._parser.registerOscHandler(2,new Jn(m=>this.setTitle(m))),this._parser.registerOscHandler(4,new Jn(m=>this.setOrReportIndexedColor(m))),this._parser.registerOscHandler(8,new Jn(m=>this.setHyperlink(m))),this._parser.registerOscHandler(10,new Jn(m=>this.setOrReportFgColor(m))),this._parser.registerOscHandler(11,new Jn(m=>this.setOrReportBgColor(m))),this._parser.registerOscHandler(12,new Jn(m=>this.setOrReportCursorColor(m))),this._parser.registerOscHandler(104,new Jn(m=>this.restoreIndexedColor(m))),this._parser.registerOscHandler(110,new Jn(m=>this.restoreFgColor(m))),this._parser.registerOscHandler(111,new Jn(m=>this.restoreBgColor(m))),this._parser.registerOscHandler(112,new Jn(m=>this.restoreCursorColor(m))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let m in un)this._parser.registerEscHandler({intermediates:"(",final:m},()=>this.selectCharset("("+m)),this._parser.registerEscHandler({intermediates:")",final:m},()=>this.selectCharset(")"+m)),this._parser.registerEscHandler({intermediates:"*",final:m},()=>this.selectCharset("*"+m)),this._parser.registerEscHandler({intermediates:"+",final:m},()=>this.selectCharset("+"+m)),this._parser.registerEscHandler({intermediates:"-",final:m},()=>this.selectCharset("-"+m)),this._parser.registerEscHandler({intermediates:".",final:m},()=>this.selectCharset("."+m)),this._parser.registerEscHandler({intermediates:"/",final:m},()=>this.selectCharset("/"+m));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(m=>(this._logService.error("Parsing error: ",m),m)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new kv((m,v)=>this.requestStatusString(m,v)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),jv))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${jv} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,s=this._activeBuffer.x,o=this._activeBuffer.y,a=0,u=this._parseStack.paused;if(u){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;s=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>ys&&(a=this._parseStack.position+ys)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,m=>String.fromCharCode(m)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(m=>m.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<ys&&(this._parseBuffer=new Uint32Array(Math.min(e.length,ys))),u||this._dirtyRowTracker.clearRange(),e.length>ys)for(let m=a;m<e.length;m+=ys){let v=m+ys<e.length?m+ys:e.length,y=typeof e=="string"?this._stringDecoder.decode(e.substring(m,v),this._parseBuffer):this._utf8Decoder.decode(e.subarray(m,v),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,y))return this._preserveStack(s,o,y,m),this._logSlowResolvingAsync(n),n}else if(!u){let m=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,m))return this._preserveStack(s,o,m,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==s||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let h=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),p=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);p<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(p,this._bufferService.rows-1),end:Math.min(h,this._bufferService.rows-1)})}print(e,t,n){let s,o,a=this._charsetService.charset,u=this._optionsService.rawOptions.screenReaderMode,h=this._bufferService.cols,p=this._coreService.decPrivateModes.wraparound,m=this._coreService.modes.insertMode,v=this._curAttrData,y=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&y.getWidth(this._activeBuffer.x-1)===2&&y.setCellFromCodepoint(this._activeBuffer.x-1,0,1,v);let w=this._parser.precedingJoinState;for(let b=t;b<n;++b){if(s=e[b],s<127&&a){let j=a[String.fromCharCode(s)];j&&(s=j.charCodeAt(0))}let k=this._unicodeService.charProperties(s,w);o=Xs.extractWidth(k);let N=Xs.extractShouldJoin(k),S=N?Xs.extractWidth(w):0;if(w=k,u&&this._onA11yChar.fire(Ss(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-S>h){if(p){let j=y,C=this._activeBuffer.x-S;for(this._activeBuffer.x=S,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),y=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),S>0&&y instanceof Wo&&y.copyCellsFrom(j,C,0,S,!1);C<h;)j.setCellFromCodepoint(C++,0,1,v)}else if(this._activeBuffer.x=h-1,o===2)continue}if(N&&this._activeBuffer.x){let j=y.getWidth(this._activeBuffer.x-1)?1:2;y.addCodepointToCell(this._activeBuffer.x-j,s,o);for(let C=o-S;--C>=0;)y.setCellFromCodepoint(this._activeBuffer.x++,0,0,v);continue}if(m&&(y.insertCells(this._activeBuffer.x,o-S,this._activeBuffer.getNullCell(v)),y.getWidth(h-1)===2&&y.setCellFromCodepoint(h-1,0,1,v)),y.setCellFromCodepoint(this._activeBuffer.x++,s,o,v),o>0)for(;--o;)y.setCellFromCodepoint(this._activeBuffer.x++,0,0,v)}this._parser.precedingJoinState=w,this._activeBuffer.x<h&&n-t>0&&y.getWidth(this._activeBuffer.x)===0&&!y.hasContent(this._activeBuffer.x)&&y.setCellFromCodepoint(this._activeBuffer.x,0,1,v),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>Nv(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new kv(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Jn(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,s=!1,o=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),o),s&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n))!=null&&s.getTrimmedLength()););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let o=this._activeBuffer.lines.length-this._bufferService.rows;o>0&&(this._activeBuffer.lines.trimStart(o),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-o,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-o,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(o-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(tn));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,s=Xs.extractWidth(t),o=this._activeBuffer.x-s,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),u=new Uint32Array(a.length*n),h=0;for(let m=0;m<a.length;){let v=a.codePointAt(m)||0;u[h++]=v,m+=v>65535?2:1}let p=h;for(let m=1;m<n;++m)u.copyWithin(p,0,h),p+=h;return this.print(u,0,p),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(ge.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(ge.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(ge.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(ge.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(ge.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Vs),this._charsetService.setgCharset(1,Vs),this._charsetService.setgCharset(2,Vs),this._charsetService.setgCharset(3,Vs);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(N=>(N[N.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",N[N.SET=1]="SET",N[N.RESET=2]="RESET",N[N.PERMANENTLY_SET=3]="PERMANENTLY_SET",N[N.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let s=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:a}=this._coreMouseService,u=this._coreService,{buffers:h,cols:p}=this._bufferService,{active:m,alt:v}=h,y=this._optionsService.rawOptions,w=(N,S)=>(u.triggerDataEvent(`${ge.ESC}[${t?"":"?"}${N};${S}$y`),!0),b=N=>N?1:2,k=e.params[0];return t?k===2?w(k,4):k===4?w(k,b(u.modes.insertMode)):k===12?w(k,3):k===20?w(k,b(y.convertEol)):w(k,0):k===1?w(k,b(s.applicationCursorKeys)):k===3?w(k,y.windowOptions.setWinLines?p===80?2:p===132?1:0:0):k===6?w(k,b(s.origin)):k===7?w(k,b(s.wraparound)):k===8?w(k,3):k===9?w(k,b(o==="X10")):k===12?w(k,b(y.cursorBlink)):k===25?w(k,b(!u.isCursorHidden)):k===45?w(k,b(s.reverseWraparound)):k===66?w(k,b(s.applicationKeypad)):k===67?w(k,4):k===1e3?w(k,b(o==="VT200")):k===1002?w(k,b(o==="DRAG")):k===1003?w(k,b(o==="ANY")):k===1004?w(k,b(s.sendFocus)):k===1005?w(k,4):k===1006?w(k,b(a==="SGR")):k===1015?w(k,4):k===1016?w(k,b(a==="SGR_PIXELS")):k===1048?w(k,1):k===47||k===1047||k===1049?w(k,b(m===v)):k===2004?w(k,b(s.bracketedPasteMode)):k===2026?w(k,b(s.synchronizedOutput)):w(k,0)}_updateAttrColor(e,t,n,s,o){return t===2?(e|=50331648,e&=-16777216,e|=ia.fromColorRGB([n,s,o])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let s=[0,0,-1,0,0,0],o=0,a=0;do{if(s[a+o]=e.params[t+a],e.hasSubParams(t+a)){let u=e.getSubParams(t+a),h=0;do s[1]===5&&(o=1),s[a+h+1+o]=u[h];while(++h<u.length&&h+a+1+o<s.length);break}if(s[1]===5&&a+o>=2||s[1]===2&&a+o>=5)break;s[1]&&(o=1)}while(++a+t<e.length&&a+o<s.length);for(let u=2;u<s.length;++u)s[u]===-1&&(s[u]=0);switch(s[0]){case 38:n.fg=this._updateAttrColor(n.fg,s[1],s[3],s[4],s[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,s[1],s[3],s[4],s[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,s[1],s[3],s[4],s[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=tn.fg,e.bg=tn.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,s=this._curAttrData;for(let o=0;o<t;o++)n=e.params[o],n>=30&&n<=37?(s.fg&=-50331904,s.fg|=16777216|n-30):n>=40&&n<=47?(s.bg&=-50331904,s.bg|=16777216|n-40):n>=90&&n<=97?(s.fg&=-50331904,s.fg|=16777216|n-90|8):n>=100&&n<=107?(s.bg&=-50331904,s.bg|=16777216|n-100|8):n===0?this._processSGR0(s):n===1?s.fg|=134217728:n===3?s.bg|=67108864:n===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,s)):n===5?s.fg|=536870912:n===7?s.fg|=67108864:n===8?s.fg|=1073741824:n===9?s.fg|=2147483648:n===2?s.bg|=134217728:n===21?this._processUnderline(2,s):n===22?(s.fg&=-134217729,s.bg&=-134217729):n===23?s.bg&=-67108865:n===24?(s.fg&=-268435457,this._processUnderline(0,s)):n===25?s.fg&=-536870913:n===27?s.fg&=-67108865:n===28?s.fg&=-1073741825:n===29?s.fg&=2147483647:n===39?(s.fg&=-67108864,s.fg|=tn.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=tn.bg&16777215):n===38||n===48||n===58?o+=this._extractColor(e,o,s):n===53?s.bg|=1073741824:n===55?s.bg&=-1073741825:n===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):n===100?(s.fg&=-67108864,s.fg|=tn.fg&16777215,s.bg&=-67108864,s.bg|=tn.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${ge.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${ge.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${ge.ESC}[?${t};${n}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=tn.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Nv(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${ge.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Ev&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Ev&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(";");for(;n.length>1;){let s=n.shift(),o=n.shift();if(/^\d+$/.exec(s)){let a=parseInt(s);if(Pv(a))if(o==="?")t.push({type:0,index:a});else{let u=Cv(o);u&&t.push({type:1,index:a,color:u})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(n,s):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),s,o=n.findIndex(a=>a.startsWith("id="));return o!==-1&&(s=n[o].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(";");for(let s=0;s<n.length&&!(t>=this._specialColors.length);++s,++t)if(n[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=Cv(n[s]);o&&this._onColor.fire([{type:1,index:this._specialColors[t],color:o}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(";");for(let s=0;s<n.length;++s)if(/^\d+$/.exec(n[s])){let o=parseInt(n[s]);Pv(o)&&t.push({type:2,index:o})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,Vs),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(QC[e[0]],un[e[1]]||Vs),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=tn.clone(),this._eraseAttrDataInternal=tn.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new di;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(n);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=u=>(this._coreService.triggerDataEvent(`${ge.ESC}${u}${ge.ESC}\\`),!0),s=this._bufferService.buffer,o=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[o.cursorStyle]-(o.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Th=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(Rv=e,e=t,t=Rv),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Th=qt([Te(0,In)],Th);function Pv(e){return 0<=e&&e<256}var ZC=5e7,Av=12,eE=50,tE=class extends lt{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new Re),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>ZC)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],o=this._action(s,t);if(o){let u=h=>performance.now()-n>=Av?setTimeout(()=>this._innerWrite(0,h)):this._innerWrite(n,h);o.catch(h=>(queueMicrotask(()=>{throw h}),Promise.resolve(!1))).then(u);return}let a=this._callbacks[this._bufferOffset];if(a&&a(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-n>=Av)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>eE&&(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()}},Mh=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let h=t.addMarker(t.ybase+t.y),p={data:e,id:this._nextId++,lines:[h]};return h.onDispose(()=>this._removeMarkerFromLink(p,h)),this._dataByLinkId.set(p.id,p),p.id}let n=e,s=this._getEntryIdKey(n),o=this._entriesWithId.get(s);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let a=t.addMarker(t.ybase+t.y),u={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(u,a)),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);n.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(n,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Mh=qt([Te(0,In)],Mh);var Lv=!1,nE=class extends lt{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new $r),this._onBinary=this._register(new Re),this.onBinary=this._onBinary.event,this._onData=this._register(new Re),this.onData=this._onData.event,this._onLineFeed=this._register(new Re),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Re),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Re),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Re),this._instantiationService=new EC,this.optionsService=this._register(new IC(e)),this._instantiationService.setService(On,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Rh)),this._instantiationService.setService(In,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(jh)),this._instantiationService.setService(Fy,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Ph)),this._instantiationService.setService(tr,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Ah)),this._instantiationService.setService($y,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Xs)),this._instantiationService.setService(Sk,this.unicodeService),this._charsetService=this._instantiationService.createInstance(FC),this._instantiationService.setService(bk,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Mh),this._instantiationService.setService(Hy,this._oscLinkService),this._inputHandler=this._register(new JC(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Cn.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Cn.forward(this._bufferService.onResize,this._onResize)),this._register(Cn.forward(this.coreService.onData,this._onData)),this._register(Cn.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 tE((t,n)=>this._inputHandler.parse(t,n))),this._register(Cn.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Re),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!Lv&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Lv=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,ww),t=Math.max(t,bw),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(xv.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(xv(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Bt(()=>{for(let t of e)t.dispose()})}}},iE={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 sE(e,t,n,s){var u;let o={type:0,cancel:!1,key:void 0},a=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?o.key=ge.ESC+"OA":o.key=ge.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=ge.ESC+"OD":o.key=ge.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=ge.ESC+"OC":o.key=ge.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=ge.ESC+"OB":o.key=ge.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":ge.DEL,e.altKey&&(o.key=ge.ESC+o.key);break;case 9:if(e.shiftKey){o.key=ge.ESC+"[Z";break}o.key=ge.HT,o.cancel=!0;break;case 13:o.key=e.altKey?ge.ESC+ge.CR:ge.CR,o.cancel=!0;break;case 27:o.key=ge.ESC,e.altKey&&(o.key=ge.ESC+ge.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;a?o.key=ge.ESC+"[1;"+(a+1)+"D":t?o.key=ge.ESC+"OD":o.key=ge.ESC+"[D";break;case 39:if(e.metaKey)break;a?o.key=ge.ESC+"[1;"+(a+1)+"C":t?o.key=ge.ESC+"OC":o.key=ge.ESC+"[C";break;case 38:if(e.metaKey)break;a?o.key=ge.ESC+"[1;"+(a+1)+"A":t?o.key=ge.ESC+"OA":o.key=ge.ESC+"[A";break;case 40:if(e.metaKey)break;a?o.key=ge.ESC+"[1;"+(a+1)+"B":t?o.key=ge.ESC+"OB":o.key=ge.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=ge.ESC+"[2~");break;case 46:a?o.key=ge.ESC+"[3;"+(a+1)+"~":o.key=ge.ESC+"[3~";break;case 36:a?o.key=ge.ESC+"[1;"+(a+1)+"H":t?o.key=ge.ESC+"OH":o.key=ge.ESC+"[H";break;case 35:a?o.key=ge.ESC+"[1;"+(a+1)+"F":t?o.key=ge.ESC+"OF":o.key=ge.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=ge.ESC+"[5;"+(a+1)+"~":o.key=ge.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=ge.ESC+"[6;"+(a+1)+"~":o.key=ge.ESC+"[6~";break;case 112:a?o.key=ge.ESC+"[1;"+(a+1)+"P":o.key=ge.ESC+"OP";break;case 113:a?o.key=ge.ESC+"[1;"+(a+1)+"Q":o.key=ge.ESC+"OQ";break;case 114:a?o.key=ge.ESC+"[1;"+(a+1)+"R":o.key=ge.ESC+"OR";break;case 115:a?o.key=ge.ESC+"[1;"+(a+1)+"S":o.key=ge.ESC+"OS";break;case 116:a?o.key=ge.ESC+"[15;"+(a+1)+"~":o.key=ge.ESC+"[15~";break;case 117:a?o.key=ge.ESC+"[17;"+(a+1)+"~":o.key=ge.ESC+"[17~";break;case 118:a?o.key=ge.ESC+"[18;"+(a+1)+"~":o.key=ge.ESC+"[18~";break;case 119:a?o.key=ge.ESC+"[19;"+(a+1)+"~":o.key=ge.ESC+"[19~";break;case 120:a?o.key=ge.ESC+"[20;"+(a+1)+"~":o.key=ge.ESC+"[20~";break;case 121:a?o.key=ge.ESC+"[21;"+(a+1)+"~":o.key=ge.ESC+"[21~";break;case 122:a?o.key=ge.ESC+"[23;"+(a+1)+"~":o.key=ge.ESC+"[23~";break;case 123:a?o.key=ge.ESC+"[24;"+(a+1)+"~":o.key=ge.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?o.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?o.key=ge.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=ge.DEL:e.keyCode===219?o.key=ge.ESC:e.keyCode===220?o.key=ge.FS:e.keyCode===221&&(o.key=ge.GS);else if((!n||s)&&e.altKey&&!e.metaKey){let h=(u=iE[e.keyCode])==null?void 0:u[e.shiftKey?1:0];if(h)o.key=ge.ESC+h;else if(e.keyCode>=65&&e.keyCode<=90){let p=e.ctrlKey?e.keyCode-64:e.keyCode+32,m=String.fromCharCode(p);e.shiftKey&&(m=m.toUpperCase()),o.key=ge.ESC+m}else if(e.keyCode===32)o.key=ge.ESC+(e.ctrlKey?ge.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let p=e.code.slice(3,4);e.shiftKey||(p=p.toLowerCase()),o.key=ge.ESC+p,o.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(o.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?o.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(o.key=ge.US),e.key==="@"&&(o.key=ge.NUL));break}return o}var Gt=0,rE=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Vl,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Vl,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((o,a)=>this._getKey(o)-this._getKey(a)),t=0,n=0,s=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<s.length;o++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(s[o]=e[t],t++):s[o]=this._array[n++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(Gt=this._search(t),Gt===-1)||this._getKey(this._array[Gt])!==t)return!1;do if(this._array[Gt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Gt),!0;while(++Gt<this._array.length&&this._getKey(this._array[Gt])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,a)=>o-a),t=0,n=new Array(this._array.length-e.length),s=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:n[s++]=this._array[o];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Gt=this._search(e),!(Gt<0||Gt>=this._array.length)&&this._getKey(this._array[Gt])===e))do yield this._array[Gt];while(++Gt<this._array.length&&this._getKey(this._array[Gt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Gt=this._search(e),!(Gt<0||Gt>=this._array.length)&&this._getKey(this._array[Gt])===e))do t(this._array[Gt]);while(++Gt<this._array.length&&this._getKey(this._array[Gt])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let s=t+n>>1,o=this._getKey(this._array[s]);if(o>e)n=s-1;else if(o<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},ud=0,Tv=0,oE=class extends lt{constructor(){super(),this._decorations=new rE(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new Re),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Re),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Bt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new aE(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let s=0,o=0;for(let a of this._decorations.getKeyIterator(t))s=a.options.x??0,o=s+(a.options.width??1),e>=s&&e<o&&(!n||(a.options.layer??"bottom")===n)&&(yield a)}forEachDecorationAtCell(e,t,n,s){this._decorations.forEachByKey(t,o=>{ud=o.options.x??0,Tv=ud+(o.options.width??1),e>=ud&&e<Tv&&(!n||(o.options.layer??"bottom")===n)&&s(o)})}},aE=class extends Ns{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Re),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Re),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=Ht.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Ht.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},lE=1e3,cE=class{constructor(e,t=lE){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let o=s-this._lastRefreshMs,a=this._debounceThresholdMS-o;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},a)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Mv=20,Yl=class extends lt{constructor(e,t,n,s){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let o=this._coreBrowserService.mainDocument;this._accessibilityContainer=o.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=o.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let a=0;a<this._terminal.rows;a++)this._rowElements[a]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[a]);if(this._topBoundaryFocusListener=a=>this._handleBoundaryFocus(a,0),this._bottomBoundaryFocusListener=a=>this._handleBoundaryFocus(a,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=o.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new cE(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(et(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Bt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Mv+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
65
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Mv+1&&(this._liveRegion.textContent+=eh.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,s=n.lines.length.toString();for(let o=e;o<=t;o++){let a=n.lines.get(n.ydisp+o),u=[],h=(a==null?void 0:a.translateToString(!0,void 0,void 0,u))||"",p=(n.ydisp+o+1).toString(),m=this._rowElements[o];m&&(h.length===0?(m.textContent=" ",this._rowColumns.set(m,[0,1])):(m.textContent=h,this._rowColumns.set(m,u)),m.setAttribute("aria-posinset",p),m.setAttribute("aria-setsize",s),this._alignRowWidth(m))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],o=n.getAttribute("aria-posinset"),a=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===a||e.relatedTarget!==s)return;let u,h;if(t===0?(u=n,h=this._rowElements.pop(),this._rowContainer.removeChild(h)):(u=this._rowElements.shift(),h=n,this._rowContainer.removeChild(u)),u.removeEventListener("focus",this._topBoundaryFocusListener),h.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let p=this._createAccessibilityTreeNode();this._rowElements.unshift(p),this._rowContainer.insertAdjacentElement("afterbegin",p)}else{let p=this._createAccessibilityTreeNode();this._rowElements.push(p),this._rowContainer.appendChild(p)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var h;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:s,offset:((h=s.textContent)==null?void 0:h.length)??0}),!this._rowContainer.contains(n.node))return;let o=({node:p,offset:m})=>{let v=p instanceof Text?p.parentNode:p,y=parseInt(v==null?void 0:v.getAttribute("aria-posinset"),10)-1;if(isNaN(y))return console.warn("row is invalid. Race condition?"),null;let w=this._rowColumns.get(v);if(!w)return console.warn("columns is null. Race condition?"),null;let b=m<w.length?w[m]:w.slice(-1)[0]+1;return b>=this._terminal.cols&&(++y,b=0),{row:y,column:b}},a=o(t),u=o(n);if(!(!a||!u)){if(a.row>u.row||a.row===u.row&&a.column>=u.column)throw new Error("invalid range");this._terminal.select(a.column,a.row,(u.row-a.row)*this._terminal.cols-a.column+u.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var o,a;e.style.transform="";let t=e.getBoundingClientRect().width,n=(a=(o=this._rowColumns.get(e))==null?void 0:o.slice(-1))==null?void 0:a[0];if(!n)return;let s=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};Yl=qt([Te(1,pf),Te(2,Gi),Te(3,Xi)],Yl);var Dh=class extends lt{constructor(e,t,n,s,o){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=s,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Re),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Re),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Bt(()=>{var a;Zs(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(et(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(et(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(et(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(et(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let s=0;s<n.length;s++){let o=n[s];if(o.classList.contains("xterm"))break;if(o.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var s,o;(!this._activeProviderReplies||!t)&&((s=this._activeProviderReplies)==null||s.forEach(a=>{a==null||a.forEach(u=>{u.link.dispose&&u.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[a,u]of this._linkProviderService.linkProviders.entries())t?(o=this._activeProviderReplies)!=null&&o.get(a)&&(n=this._checkLinkProviderResult(a,e,n)):u.provideLinks(e.y,h=>{var m,v;if(this._isMouseOut)return;let p=h==null?void 0:h.map(y=>({link:y}));(m=this._activeProviderReplies)==null||m.set(a,p),n=this._checkLinkProviderResult(a,e,n),((v=this._activeProviderReplies)==null?void 0:v.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let s=0;s<t.size;s++){let o=t.get(s);if(o)for(let a=0;a<o.length;a++){let u=o[a],h=u.link.range.start.y<e?0:u.link.range.start.x,p=u.link.range.end.y>e?this._bufferService.cols:u.link.range.end.x;for(let m=h;m<=p;m++){if(n.has(m)){o.splice(a--,1);break}n.add(m)}}}}_checkLinkProviderResult(e,t,n){var a;if(!this._activeProviderReplies)return n;let s=this._activeProviderReplies.get(e),o=!1;for(let u=0;u<e;u++)(!this._activeProviderReplies.has(u)||this._activeProviderReplies.get(u))&&(o=!0);if(!o&&s){let u=s.find(h=>this._linkAtPosition(h.link,t));u&&(n=!0,this._handleNewLink(u))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let u=0;u<this._activeProviderReplies.size;u++){let h=(a=this._activeProviderReplies.get(u))==null?void 0:a.find(p=>this._linkAtPosition(p.link,t));if(h){n=!0,this._handleNewLink(h);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&uE(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Zs(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.pointerCursor},set:n=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>{var n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.underline},set:n=>{var s,o,a;(s=this._currentLink)!=null&&s.state&&((a=(o=this._currentLink)==null?void 0:o.state)==null?void 0:a.decorations.underline)!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let s=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(s,o),this._lastMouseEvent)){let a=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);a&&this._askForLink(a,!1)}})))}_linkHover(e,t,n){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,s=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-s-1,n.end.x,n.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,n){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,o=t.y*this._bufferService.cols+t.x;return n<=o&&o<=s}_positionFromMouseEvent(e,t,n){let s=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,s,o){return{x1:e,y1:t,x2:n,y2:s,cols:this._bufferService.cols,fg:o}}};Dh=qt([Te(1,mf),Te(2,Xi),Te(3,In),Te(4,Wy)],Dh);function uE(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var dE=class extends nE{constructor(e={}){super(e),this._linkifier=this._register(new $r),this.browser=cw,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new $r),this._onCursorMove=this._register(new Re),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Re),this.onKey=this._onKey.event,this._onRender=this._register(new Re),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Re),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Re),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Re),this.onBell=this._onBell.event,this._onFocus=this._register(new Re),this._onBlur=this._register(new Re),this._onA11yCharEmitter=this._register(new Re),this._onA11yTabEmitter=this._register(new Re),this._onWillOpen=this._register(new Re),this._setup(),this._decorationService=this._instantiationService.createInstance(oE),this._instantiationService.setService(sa,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(eC),this._instantiationService.setService(Wy,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(nh)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Cn.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Cn.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Cn.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Cn.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Bt(()=>{var t,n;this._customKeyEventHandler=void 0,(n=(t=this.element)==null?void 0:t.parentNode)==null||n.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let n,s="";switch(t.index){case 256:n="foreground",s="10";break;case 257:n="background",s="11";break;case 258:n="cursor",s="12";break;default:n="ansi",s="4;"+t.index}switch(t.type){case 0:let o=Mt.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${ge.ESC}]${s};${XC(o)}${aw.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(a=>a.ansi[t.index]=nn.toColor(...t.color));else{let a=n;this._themeService.modifyColors(u=>u[a]=nn.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Yl,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(ge.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(ge.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,o=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*o,u=this.buffer.y*this._renderService.dimensions.css.cell.height,h=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=h+"px",this.textarea.style.top=u+"px",this.textarea.style.width=a+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(et(this.element,"copy",t=>{this.hasSelection()&&mk(t,this._selectionService)}));let e=t=>gk(t,this.textarea,this.coreService,this.optionsService);this._register(et(this.textarea,"paste",e)),this._register(et(this.element,"paste",e)),uw?this._register(et(this.element,"mousedown",t=>{t.button===2&&Wg(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(et(this.element,"contextmenu",t=>{Wg(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),xf&&this._register(et(this.element,"auxclick",t=>{t.button===1&&Dy(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(et(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(et(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(et(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(et(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(et(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(et(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(et(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var o;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((o=this.element)==null?void 0:o.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(et(this.screenElement,"mousemove",a=>this.updateCursorStyle(a))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Zd.get()),fw||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(J1,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Gi,this._coreBrowserService),this._register(et(this.textarea,"focus",a=>this._handleTextAreaFocus(a))),this._register(et(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(xh,this._document,this._helperContainer),this._instantiationService.setService(tc,this._charSizeService),this._themeService=this._instantiationService.createInstance(Nh),this._instantiationService.setService(Wr,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Kl),this._instantiationService.setService(Uy,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Ch,this.rows,this.screenElement)),this._instantiationService.setService(Xi,this._renderService),this._register(this._renderService.onRenderedViewportChange(a=>this._onRender.fire(a))),this.onResize(a=>this._renderService.resize(a.cols,a.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(wh,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(kh),this._instantiationService.setService(mf,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Dh,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(_h,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(a=>{super.scrollLines(a,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Eh,this.element,this.screenElement,s)),this._instantiationService.setService(kk,this._selectionService),this._register(this._selectionService.onRequestScrollLines(a=>this.scrollLines(a.amount,a.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(a=>this._renderService.handleSelectionChanged(a.start,a.end,a.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(a=>{this.textarea.value=a,this.textarea.focus(),this.textarea.select()})),this._register(Cn.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var a;this._selectionService.refresh(),(a=this._viewport)==null||a.queueSync()})),this._register(this._instantiationService.createInstance(yh,this.screenElement)),this._register(et(this.element,"mousedown",a=>this._selectionService.handleMouseDown(a))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Yl,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",a=>this._handleScreenReaderModeOptionChange(a))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Wl,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",a=>{!this._overviewRulerRenderer&&a&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Wl,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Sh,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(a){var m,v,y,w,b;let u=e._mouseService.getMouseReportCoords(a,e.screenElement);if(!u)return!1;let h,p;switch(a.overrideType||a.type){case"mousemove":p=32,a.buttons===void 0?(h=3,a.button!==void 0&&(h=a.button<3?a.button:3)):h=a.buttons&1?0:a.buttons&4?1:a.buttons&2?2:3;break;case"mouseup":p=0,h=a.button<3?a.button:3;break;case"mousedown":p=1,h=a.button<3?a.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(a)===!1)return!1;let k=a.deltaY;if(k===0||e.coreMouseService.consumeWheelEvent(a,(w=(y=(v=(m=e._renderService)==null?void 0:m.dimensions)==null?void 0:v.device)==null?void 0:y.cell)==null?void 0:w.height,(b=e._coreBrowserService)==null?void 0:b.dpr)===0)return!1;p=k<0?0:1,h=4;break;default:return!1}return p===void 0||h===void 0||h>4?!1:e.coreMouseService.triggerMouseEvent({col:u.col,row:u.row,x:u.x,y:u.y,button:h,action:p,ctrl:a.ctrlKey,alt:a.altKey,shift:a.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:a=>(n(a),a.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(a)),wheel:a=>(n(a),this.cancel(a,!0)),mousedrag:a=>{a.buttons&&n(a)},mousemove:a=>{a.buttons||n(a)}};this._register(this.coreMouseService.onProtocolChange(a=>{a?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(a)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),a&8?s.mousemove||(t.addEventListener("mousemove",o.mousemove),s.mousemove=o.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),a&16?s.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),s.wheel=o.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),a&2?s.mouseup||(s.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),a&4?s.mousedrag||(s.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(et(t,"mousedown",a=>{if(a.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(a)))return n(a),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(a)})),this._register(et(t,"wheel",a=>{var u,h,p,m,v;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(a)===!1)return!1;if(!this.buffer.hasScrollback){if(a.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(a,(m=(p=(h=(u=e._renderService)==null?void 0:u.dimensions)==null?void 0:h.device)==null?void 0:p.cell)==null?void 0:m.height,(v=e._coreBrowserService)==null?void 0:v.dpr)===0)return this.cancel(a,!0);let y=ge.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(a.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(y,!0),this.cancel(a,!0)}}},{passive:!1}))}refresh(e,t){var n;(n=this._renderService)==null||n.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){My(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var n;(n=this._selectionService)==null||n.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let n=sE(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let s=this.rows-1;return this.scrollLines(n.type===2?-s:s),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===ge.ETX||n.key===ge.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(hE(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var n;(n=this._charSizeService)==null||n.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(tn));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(ge.ESC+"[I"):this.coreService.triggerDataEvent(ge.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),n=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${ge.ESC}[4;${n};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${ge.ESC}[6;${o};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function hE(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var fE=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},pE=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new di)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Dv=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new pE(t)}getNullCell(){return new di}},mE=class extends lt{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Re),this.onBufferChange=this._onBufferChange.event,this._normal=new Dv(this._core.buffers.normal,"normal"),this._alternate=new Dv(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)}},gE=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,s)=>t(n,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},vE=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}},_E=["cols","rows"],ki=0,yE=class extends lt{constructor(e){super(),this._core=this._register(new dE(e)),this._addonManager=this._register(new fE),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],n=(s,o)=>{this._checkReadonlyOptions(s),this._core.options[s]=o};for(let s in this._core.options){let o={get:t.bind(this,s),set:n.bind(this,s)};Object.defineProperty(this._publicOptions,s,o)}}_checkReadonlyOptions(e){if(_E.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new gE(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new vE(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 mE(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
66
|
-
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Zd.get()},set promptLabel(e){Zd.set(e)},get tooMuchOutput(){return eh.get()},set tooMuchOutput(e){eh.set(e)}}}_verifyIntegers(...e){for(ki of e)if(ki===1/0||isNaN(ki)||ki%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(ki of e)if(ki&&(ki===1/0||isNaN(ki)||ki%1!==0||ki<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 wE=2,bE=1,SE=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var y;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((y=this._terminal.options.overviewRuler)==null?void 0:y.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(n.getPropertyValue("height")),o=Math.max(0,parseInt(n.getPropertyValue("width"))),a=window.getComputedStyle(this._terminal.element),u={top:parseInt(a.getPropertyValue("padding-top")),bottom:parseInt(a.getPropertyValue("padding-bottom")),right:parseInt(a.getPropertyValue("padding-right")),left:parseInt(a.getPropertyValue("padding-left"))},h=u.top+u.bottom,p=u.right+u.left,m=s-h,v=o-p-t;return{cols:Math.max(wE,Math.floor(v/e.css.cell.width)),rows:Math.max(bE,Math.floor(m/e.css.cell.height))}}};function xE(e,t){return e?`/api/route/${String(e).split("/").map(encodeURIComponent).join("/")}/_/ws?token=${encodeURIComponent(t||"")}`:"/ws"}function kE({session:e,node:t,token:n,cols:s,rows:o,readonly:a=!1,takeSize:u,focused:h,onData:p,onExit:m,onFiles:v,retryBaseMs:y=250}){const w=["localhost","127.0.0.1","::1","[::1]"].includes(location.hostname);if(location.protocol!=="https:"&&!w)throw new Error("nexuscrew: ws:// rifiutato su origine non-locale e non-TLS (apri via tunnel su localhost o servi in HTTPS)");const k=`${location.protocol==="https:"?"wss":"ws"}://${location.host}${xE(t,n)}`;let N=null,S=!1,j=!1,C=null,$=0,O=h;const U=()=>{if(S||j||C)return;const K=Math.min(5e3,Math.max(0,y)*2**Math.min($++,5));C=setTimeout(()=>{C=null,V()},K)},V=()=>{if(S||j)return;const K=new WebSocket(k);N=K,K.binaryType="arraybuffer",K.onopen=()=>{if(N!==K||S)return;$=0;const Z={type:"attach",session:e,token:n,cols:s,rows:o,readonly:a};u!==void 0&&(Z.takeSize=u),K.send(JSON.stringify(Z)),O!==void 0&&K.send(JSON.stringify({type:"focus",on:!!O}))},K.onmessage=Z=>{if(!(N!==K||S))if(typeof Z.data=="string"){let G;try{G=JSON.parse(Z.data)}catch{return}G.type==="exit"&&(j=!0,m&&m(G.code)),G.type==="files"&&v&&v(G)}else p&&p(new Uint8Array(Z.data))},K.onerror=()=>{if(N===K)try{K.close()}catch{}},K.onclose=Z=>{N!==K||S||j||[1e3,1002,4401,4404].includes(Z==null?void 0:Z.code)||U()}};return V(),{sendInput:K=>{if(!N||N.readyState!==1)return!1;try{return N.send(typeof K=="string"?new TextEncoder().encode(K):K),!0}catch{try{N.close()}catch{}return!1}},isReady:()=>!!N&&N.readyState===1,resize:(K,Z)=>{s=K,o=Z,(N==null?void 0:N.readyState)===1&&N.send(JSON.stringify({type:"resize",cols:K,rows:Z}))},action:K=>{(N==null?void 0:N.readyState)===1&&N.send(JSON.stringify({type:"action",name:K}))},focus:K=>{O=K,(N==null?void 0:N.readyState)===1&&N.send(JSON.stringify({type:"focus",on:!!K}))},close:()=>{if(S=!0,C&&clearTimeout(C),C=null,N)try{N.close()}catch{}},get raw(){return N}}}async function Iv(e){const t=String(e||"");if(!t)return!1;try{if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")return await navigator.clipboard.writeText(t),!0}catch{}try{const n=document.createElement("textarea");n.value=t,n.readOnly=!0,n.style.position="fixed",n.style.opacity="0",n.style.pointerEvents="none",document.body.appendChild(n),n.select();const s=document.execCommand&&document.execCommand("copy");if(n.remove(),s)return!0}catch{}return!1}const CE="\r";function EE(e){const t=String(e||"");let n=t.length;for(;n>0;){const s=t.charCodeAt(n-1);if(s===10||s===13)n-=1;else break}return t.slice(0,n)}function NE({isReady:e,paste:t,send:n}){return s=>{if(!s||!e())return!1;try{return t(s)===!1||!e()?!1:n(CE)!==!1}catch{return!1}}}function jE(e){return!e||typeof e!="object"?!1:!!e.shiftKey}function RE(e){return!e||typeof e!="object"||String(e.key||"").toLowerCase()!=="c"?!1:!!(e.metaKey||e.ctrlKey&&e.shiftKey)}const PE=450,Ov=8;function AE(e,t,n,s){return Math.abs(Number(n)-Number(e))>Ov||Math.abs(Number(s)-Number(t))>Ov}const LE=new Map([["image/png","png"],["image/jpeg","jpg"],["image/gif","gif"],["image/webp","webp"],["application/pdf","pdf"],["text/plain","txt"]]);function dd(e){return e?e.files&&e.files.length>0||Array.from(e.items||[]).some(t=>t&&t.kind==="file")?!0:Array.from(e.types||[]).includes("Files"):!1}function Bv(e){if(!e)return[];const t=Array.from(e.files||[]).filter(Boolean);return t.length?t:Array.from(e.items||[]).filter(n=>n&&n.kind==="file"&&typeof n.getAsFile=="function").map(n=>n.getAsFile()).filter(Boolean)}function TE(e,t=0,n=Date.now()){const s=String((e==null?void 0:e.name)||"").trim();if(s)return s;const o=LE.get(String((e==null?void 0:e.type)||"").toLowerCase())||"bin";return`clipboard-${n}-${t+1}.${o}`}async function xw({files:e,token:t,session:n,node:s="",paste:o=!0,fetchImpl:a=Kt,onProgress:u=()=>{},now:h=Date.now()}={}){const p=Array.from(e||[]).filter(Boolean),m=[],v=[];if(!n||!p.length)return{paths:m,errors:v};const y=sn(s?String(s).split("/"):[]);for(let w=0;w<p.length;w+=1){const b=p[w],k=TE(b,w,h);u({index:w,total:p.length,name:k,state:"uploading"});try{const N=new FormData;N.append("session",n),N.append("paste",o?"true":"false"),N.append("file",b,k);const S=await a(`${y}/files/upload`,t,{method:"POST",body:N}),j=await S.json().catch(()=>({}));if(!S.ok||j.error)throw new Error(j.error||`HTTP ${S.status}`);m.push(j.path),u({index:w,total:p.length,name:k,state:"done",path:j.path})}catch(N){const S=String((N==null?void 0:N.message)||N);v.push({name:k,message:S}),u({index:w,total:p.length,name:k,state:"error",error:S})}}return{paths:m,errors:v}}const ME=420,DE=32;function IE(e){if(!e||typeof e!="object")return!1;const t=String(e.tagName||"").toLowerCase();return t==="textarea"||t==="input"||e.isContentEditable===!0}function Ih({documentRef:e,navigatorRef:t}={}){const n=e||(typeof document<"u"?document:null),s=t||(typeof navigator<"u"?navigator:null);let o=!1;try{s!=null&&s.virtualKeyboard&&typeof s.virtualKeyboard.hide=="function"&&(s.virtualKeyboard.hide(),o=!0)}catch{}const a=n&&n.activeElement;let u=!1;if(IE(a)&&typeof a.blur=="function")try{a.blur(),u=!0}catch{}return{blurred:u,apiRequested:o}}function kw(e,t,n=!1){const s=e&&e.textarea;if(!s)return null;const a=t==="single-tap"||t==="double-tap"&&n?"text":"none";return s.inputMode=a,s.setAttribute("inputmode",a),a}function OE(e,t){if(!e||!e.textarea)return!1;kw(e,"double-tap",!0);try{e.focus()}catch{return!1}const n=typeof navigator<"u"?navigator:null;try{n!=null&&n.virtualKeyboard&&typeof n.virtualKeyboard.show=="function"&&n.virtualKeyboard.show()}catch{}return!0}function BE(e,t,n){return e==="never"?{open:!1,next:null}:e==="single-tap"?{open:!0,next:null}:!n||!Number.isFinite(n.at)||!Number.isFinite(n.x)||!Number.isFinite(n.y)?{open:!1,next:null}:t&&n.at>=t.at&&n.at-t.at<=ME&&Math.hypot(n.x-t.x,n.y-t.y)<=DE?{open:!0,next:null}:{open:!1,next:n}}const zE=24,zv=80,Cw=8,$E="\x1B[5~",FE="\x1B[6~",HE=64,UE=65;function WE(e,t,n){const s=e==="up"?HE:UE,o=a=>Math.max(1,Math.min(9999,Number.isFinite(a)?Math.round(a):1));return`\x1B[<${s};${o(t)};${o(n)}M`}function KE({alternateScreen:e=!1,readonly:t=!1,mouseTracking:n=!1}={}){return t?"scroll":n?"mouse":e?"page":"scroll"}function qE(e,t){return e==="page"?Number.isFinite(t)&&t>0?Math.max(zv,t):zv:Number.isFinite(t)&&t>0?t:zE}function VE({mode:e="scroll",accumulated:t=0,threshold:n=0}={}){const s=qE(e,n);if(!Number.isFinite(t))return{mode:e,up:0,down:0,remainder:0};const o=Math.abs(t);if(o<s)return{mode:e,up:0,down:0,remainder:t};const a=Math.floor(o/s),u=Math.min(a,Cw),h=(t>=0?1:-1)*(o%s);return{mode:e,up:t>0?u:0,down:t<0?u:0,remainder:h}}function YE(e,t=null){const n=[],s=t&&Number.isFinite(t.col)?t.col:1,o=t&&Number.isFinite(t.row)?t.row:1,a=h=>Math.min(Cw,Number.isFinite(h)?Math.max(0,Math.floor(h)):0),u=h=>e.mode==="mouse"?{kind:"input",seq:WE(h,s,o)}:e.mode==="page"?{kind:"input",seq:h==="up"?$E:FE}:{kind:"action",name:h==="up"?"scroll-up":"scroll-down"};for(let h=0;h<a(e.up);h+=1)n.push(u("up"));for(let h=0;h<a(e.down);h+=1)n.push(u("down"));return n}function Ew({session:e,node:t,token:n,readonly:s,takeSize:o,focused:a,sendRef:u,composerRef:h,actionRef:p,ctrlRef:m,setCtrlArmed:v,onFiles:y,fontSize:w=13,selectionMode:b=!1,onSelectionModeChange:k,keyboardGesture:N="double-tap"}){const S=E.useRef(null),j=E.useRef(null),C=E.useRef(w);C.current=w;const $=E.useRef(a);$.current=a;const O=E.useRef(b);O.current=b;const U=E.useRef(N);U.current=N;const[V,K]=E.useState(""),[Z,G]=E.useState(""),[Q,F]=E.useState(null),[B,A]=E.useState(null),[z,I]=E.useState(!1),D=async()=>{var L,T,H,Y;const x=((T=(L=j.current)==null?void 0:L.term)==null?void 0:T.getSelection())||V;if(!x){G(f("copy-empty")),setTimeout(()=>G(""),1500);return}const M=await Iv(x);G(f(M?"copied":"copy-manual")),M&&((Y=(H=j.current)==null?void 0:H.term)==null||Y.clearSelection(),K(""),I(!1),k==null||k(!1)),setTimeout(()=>G(""),1800)},P=E.useRef(D);return P.current=D,E.useEffect(()=>{const x=j.current;x&&x.sock&&x.sock.focus&&x.sock.focus(!!a)},[a]),E.useEffect(()=>{const x=j.current;x&&(x.term.options.fontSize=w,x.fit.fit(),x.sock.resize(x.term.cols,x.term.rows))},[w]),E.useEffect(()=>{var x,M;(M=(x=j.current)==null?void 0:x.setKeyboardGesture)==null||M.call(x,N)},[N]),E.useEffect(()=>{var Ps,Yr,As,Gr,sr,ca,It;const x=new yE({cursorBlink:!0,fontSize:C.current,scrollback:1e3,theme:{background:"#0a0e0a"}}),M=new SE;x.loadAddon(M),x.open(S.current),M.fit();let L=!1,T=!1;const H=he=>Ke=>{for(const Je of Ke){const Qe=Array.isArray(Je)?Je[0]:Je;Qe===1006&&(L=he),Qe===1016&&(T=he)}return!1};(Yr=(Ps=x.parser)==null?void 0:Ps.registerCsiHandler)==null||Yr.call(Ps,{prefix:"?",final:"h"},H(!0)),(Gr=(As=x.parser)==null?void 0:As.registerCsiHandler)==null||Gr.call(As,{prefix:"?",final:"l"},H(!1)),(ca=(sr=x.parser)==null?void 0:sr.registerEscHandler)==null||ca.call(sr,{final:"c"},()=>(L=!1,T=!1,!1));const Y=()=>{const he=L&&!T&&(x.modes&&x.modes.mouseTrackingMode||"none")!=="none",Ke=S.current;return Ke&&(Ke.dataset.mouseTracking=he?"on":"off"),he},de=new TextDecoder;let ue=U.current==="single-tap",fe=null;const ve=()=>{ue=U.current==="single-tap",kw(x,U.current,ue)},ie=he=>{U.current=he,fe=null,ve()},ye=()=>U.current==="never"?!1:(ue=!0,OE(x));ve();const Ue=x.textarea,ut=()=>{U.current==="double-tap"&&ve()};Ue==null||Ue.addEventListener("blur",ut);let rt;try{rt=kE({session:e,node:t,token:n,readonly:s,takeSize:o,focused:$.current,onFiles:y,cols:x.cols,rows:x.rows,onData:he=>x.write(de.decode(he)),onExit:()=>x.write(`\r
|
|
78
|
-
\x1B[33m[sessione finita]\x1B[0m\r
|
|
79
|
-
`)})}catch(he){return x.write(`\r
|
|
80
|
-
\x1B[31m${he.message}\x1B[0m\r
|
|
81
|
-
`),()=>x.dispose()}j.current={term:x,fit:M,sock:rt,setKeyboardGesture:ie};let Ae=null;const Dt=x.onData(he=>{if(s){Ae&&(Ae.ok=!1);return}if(!Ae&&m&&m.current&&he.length===1){const Je=he.charCodeAt(0);let Qe=Je;Je>=97&&Je<=122?Qe=Je-96:Je>=64&&Je<=95?Qe=Je-64:Je===32&&(Qe=0),he=String.fromCharCode(Qe),m.current=!1,v&&v(!1)}const Ke=rt.sendInput(he);Ae&&(Ae.seen=!0,Ae.ok=Ae.ok&&Ke)});u&&(u.current=he=>rt.sendInput(he)),p&&(p.current=he=>rt.action(he)),h&&(h.current=NE({isReady:()=>!s&&rt.isReady(),paste:he=>{const Ke={seen:!1,ok:!0};Ae=Ke;try{x.paste(he)}catch{Ke.ok=!1}finally{Ae=null}return Ke.seen&&Ke.ok},send:he=>rt.sendInput(he)}));const Qt=x.onSelectionChange(()=>{const he=x.getSelection();he?(K(he),I(!1)):I(!0)});x.attachCustomKeyEventHandler(he=>(he.ctrlKey||he.metaKey)&&he.key.toLowerCase()==="c"&&x.getSelection()?(he.type==="keydown"&&Iv(x.getSelection()),!1):!0);const $e=S.current;let dt=!1;const it=async he=>{if(!he.length||dt)return;if(s){F({error:f("settings-readonly")});return}dt=!0,F({current:0,total:he.length,name:""});const Ke=await xw({files:he,token:n,session:e,node:t,paste:!0,onProgress:({index:Je,total:Qe,name:Et,state:At,error:Zt})=>F({current:Je+1,total:Qe,name:Et,...At==="error"?{error:Zt}:{}})});dt=!1,Ke.errors.length?F({error:Ke.errors.map(Je=>`${Je.name}: ${Je.message}`).join(" · ")}):(F({done:!0,total:Ke.paths.length}),setTimeout(()=>F(null),1600))},wt=he=>{const Ke=he.clipboardData;if(!dd(Ke))return;const Je=Bv(Ke);Je.length&&(he.preventDefault(),he.stopPropagation(),it(Je))},bt=he=>{dd(he.dataTransfer)&&(he.preventDefault(),he.stopPropagation())},mt=he=>{dd(he.dataTransfer)&&(he.preventDefault(),he.stopPropagation(),it(Bv(he.dataTransfer)))};$e.addEventListener("paste",wt,!0),$e.addEventListener("dragenter",bt,!0),$e.addEventListener("dragover",bt,!0),$e.addEventListener("drop",mt,!0);const gt=24,pt=(he,Ke)=>{const Qe=($e.querySelector(".xterm-screen")||$e).getBoundingClientRect(),Et=Math.floor((he-Qe.left)/Math.max(1,Qe.width)*x.cols)+1,At=Math.floor((Ke-Qe.top)/Math.max(1,Qe.height)*x.rows)+1;return{col:Math.max(1,Math.min(x.cols,Et)),row:Math.max(1,Math.min(x.rows,At))}},Pt=(he,Ke={mode:null,remainder:0},Je=null,Qe=null)=>{const Et=S.current,At=Et?Et.getBoundingClientRect().height:gt,Zt=KE({alternateScreen:x.buffer.active.type==="alternate",readonly:s,mouseTracking:Y()}),hn=Zt==="mouse"?"mouse":Je||Zt,dc=Ke.mode===hn?Ke.remainder+he:he,Bn=VE({mode:hn,accumulated:dc,threshold:hn==="page"?At:gt});for(const Xr of YE(Bn,Qe))Xr.kind==="input"?rt.sendInput(Xr.seq):rt.action(Xr.name);return{mode:hn,remainder:Bn.remainder}};let vt=null,xt=null,Se=null,le=null,Pe=!1,We=!1,te={mode:null,remainder:0},we=null,Ne=null,De=null,Oe=!1,_t=0;const yt=()=>{De&&clearTimeout(De),De=null},X=(he,Ke)=>{const Qe=($e.querySelector(".xterm-screen")||$e).getBoundingClientRect(),Et=Math.max(0,Math.min(x.cols-1,Math.floor((he-Qe.left)/Math.max(1,Qe.width)*x.cols))),At=Math.max(0,Math.min(x.rows-1,Math.floor((Ke-Qe.top)/Math.max(1,Qe.height)*x.rows)));return{col:Et,row:x.buffer.active.viewportY+At}},se=2,W=he=>{const Je=($e.querySelector(".xterm-screen")||$e).getBoundingClientRect();return Math.max(0,Math.min(x.rows-1,Math.floor((he-Je.top)/Math.max(1,Je.height)*x.rows)))<se?se:-se},oe=(he,Ke)=>{const Et=($e.querySelector(".xterm-screen")||$e).getBoundingClientRect().height/Math.max(1,x.rows);return X(he.clientX,he.clientY+Ke*Et)},pe=he=>{const Je=($e.querySelector(".xterm-screen")||$e).getBoundingClientRect(),Qe=$e.getBoundingClientRect(),Et=Je.width/Math.max(1,x.cols),At=Je.height/Math.max(1,x.rows),Zt=Number(x.buffer.active.viewportY)||0,hn=Math.max(0,Math.min(x.rows-1,he.row-Zt));A({left:`${Je.left-Qe.left+he.col*Et}px`,top:`${Je.top-Qe.top+hn*At}px`,width:`${Et}px`,height:`${At}px`})},_e=he=>{if(yt(),Oe=!1,Pe=!1,We||he.touches.length!==1){We=!0,Pe=!0,fe=null,A(null),_t=0,vt=null,xt=null,Se=null,le=null;return}if(O.current){he.preventDefault(),he.stopPropagation(),_t=W(he.touches[0].clientY),Ne=oe(he.touches[0],_t),x.clearSelection(),pe(Ne);return}vt=he.touches[0].clientY,xt=he.touches[0].clientX,Se=xt,le=vt,te={mode:null,remainder:0},we=null;const Ke={x:xt,y:vt};De=setTimeout(()=>{var Zt;De=null,Oe=!0,Pe=!0,fe=null,O.current=!0,k==null||k(!0),Ne=X(Ke.x,Ke.y),_t=W(Ke.y);const Je=oe({clientX:Ke.x,clientY:Ke.y},_t);x.clearSelection();const Qe=Ne.row*x.cols+Ne.col,Et=Je.row*x.cols+Je.col,At=Qe<=Et?Ne:Je;x.select(At.col,At.row,Math.abs(Et-Qe)+1),pe(Je);try{(Zt=navigator.vibrate)==null||Zt.call(navigator,10)}catch{}vt=null,xt=null,we=null,te={mode:null,remainder:0}},PE)},Be=he=>{if(Oe&&Ne&&he.touches.length===1){he.preventDefault(),he.stopPropagation();const Qe=oe(he.touches[0],_t),Et=Ne.row*x.cols+Ne.col,At=Qe.row*x.cols+Qe.col,Zt=Et<=At?Ne:Qe;x.select(Zt.col,Zt.row,Math.abs(At-Et)+1),pe(Qe);return}if(O.current&&Ne&&he.touches.length===1){he.preventDefault(),he.stopPropagation();const Qe=oe(he.touches[0],_t),Et=Ne.row*x.cols+Ne.col,At=Qe.row*x.cols+Qe.col,Zt=Et<=At?Ne:Qe;x.select(Zt.col,Zt.row,Math.abs(At-Et)+1),pe(Qe);return}if(vt===null||he.touches.length!==1)return;he.preventDefault(),he.stopPropagation();const Ke=he.touches[0];if(AE(Se,le,Ke.clientX,Ke.clientY)&&(Pe=!0,fe=null,De&&yt()),we===null&&(Math.abs(Ke.clientY-vt)>8||Math.abs(Ke.clientX-xt)>8)&&(we=Math.abs(Ke.clientY-vt)>Math.abs(Ke.clientX-xt)),!we)return;const Je=Ke.clientY-vt;vt=Ke.clientY,te=Pt(Je,te,"scroll",pt(Ke.clientX,Ke.clientY))},me=()=>{yt(),vt=null,xt=null,Se=null,le=null,Ne=null,Oe=!1,Pe=!1,We=!1,_t=0,A(null),te={mode:null,remainder:0}},Ce=he=>{if(We){fe=null,yt(),(!he.touches||he.touches.length===0)&&me();return}const Ke=he.changedTouches&&he.changedTouches[0];if(!Pe&&!Oe&&!O.current&&Ke){const Je={at:Date.now(),x:Ke.clientX,y:Ke.clientY},Qe=BE(U.current,fe,Je);fe=Qe.next,Qe.open&&ye()}me()},Ge=()=>{fe=null,me()};let rn={mode:null,remainder:0};const tt=he=>{he.preventDefault(),he.stopPropagation(),rn=Pt(-he.deltaY,rn,"scroll",pt(he.clientX,he.clientY))};$e.addEventListener("touchstart",_e,{passive:!1}),$e.addEventListener("touchmove",Be,{passive:!1,capture:!0}),$e.addEventListener("touchend",Ce,{passive:!0}),$e.addEventListener("touchcancel",Ge,{passive:!0});const bn=()=>{!O.current&&U.current==="double-tap"&&ye()};$e.addEventListener("dblclick",bn);const Ct=he=>{(O.current||Oe)&&(he.preventDefault(),he.stopPropagation())};$e.addEventListener("contextmenu",Ct,!0),$e.addEventListener("wheel",tt,{passive:!1,capture:!0});let Xe=null;const Jt=he=>{jE(he)&&(he.preventDefault(),he.stopPropagation(),Xe=X(he.clientX,he.clientY),x.clearSelection())},dn=he=>{var At;if(!Xe){(At=x.hasSelection)!=null&&At.call(x)&&Y()&&(he.preventDefault(),he.stopPropagation());return}he.preventDefault(),he.stopPropagation();const Ke=X(he.clientX,he.clientY),Je=Xe.row*x.cols+Xe.col,Qe=Ke.row*x.cols+Ke.col,Et=Je<=Qe?Xe:Ke;x.select(Et.col,Et.row,Math.abs(Qe-Je)+1)},qn=he=>{Xe&&(he.stopPropagation(),Xe=null)};$e.addEventListener("mousedown",Jt,!0),$e.addEventListener("mousemove",dn,!0),$e.addEventListener("mouseup",qn,!0);const ce=he=>{!RE(he)||!(j.current&&j.current.term&&j.current.term.getSelection())||(he.preventDefault(),he.stopPropagation(),P.current&&P.current())};$e.addEventListener("keydown",ce,!0);const je=()=>{M.fit(),rt.resize(x.cols,x.rows)};window.addEventListener("resize",je);const qe=window.visualViewport;let ot=qe&&Number(qe.height);const Vt=()=>{const he=qe&&Number(qe.height);ue&&U.current==="double-tap"&&Number.isFinite(ot)&&Number.isFinite(he)&&he>ot+80&&ve(),ot=he,je()};qe&&(qe.addEventListener("resize",Vt),qe.addEventListener("scroll",je));const Nt=typeof navigator<"u"?navigator.virtualKeyboard:null,Qi=()=>{var he;ue&&U.current==="double-tap"&&Number(((he=Nt==null?void 0:Nt.boundingRect)==null?void 0:he.height)||0)===0&&ve()};(It=Nt==null?void 0:Nt.addEventListener)==null||It.call(Nt,"geometrychange",Qi);let An=null,Di=0;return typeof ResizeObserver<"u"&&(An=new ResizeObserver(()=>{Di&&cancelAnimationFrame(Di),Di=requestAnimationFrame(je)}),An.observe($e)),()=>{var he;j.current=null,u&&(u.current=()=>!1),h&&(h.current=()=>!1),p&&(p.current=()=>!1),Dt.dispose(),Qt.dispose(),$e.removeEventListener("touchstart",_e),$e.removeEventListener("touchmove",Be,{capture:!0}),$e.removeEventListener("touchend",Ce),$e.removeEventListener("touchcancel",Ge),$e.removeEventListener("dblclick",bn),$e.removeEventListener("contextmenu",Ct,!0),yt(),$e.removeEventListener("wheel",tt,{capture:!0}),$e.removeEventListener("mousedown",Jt,!0),$e.removeEventListener("mousemove",dn,!0),$e.removeEventListener("mouseup",qn,!0),$e.removeEventListener("keydown",ce,!0),$e.removeEventListener("paste",wt,!0),$e.removeEventListener("dragenter",bt,!0),$e.removeEventListener("dragover",bt,!0),$e.removeEventListener("drop",mt,!0),window.removeEventListener("resize",je),qe&&(qe.removeEventListener("resize",Vt),qe.removeEventListener("scroll",je)),(he=Nt==null?void 0:Nt.removeEventListener)==null||he.call(Nt,"geometrychange",Qi),Ue==null||Ue.removeEventListener("blur",ut),An&&An.disconnect(),Di&&cancelAnimationFrame(Di),rt.close(),x.dispose()}},[e,t,n,s,o,u,h,p,m,v,y]),l.jsxs("div",{className:`nc-terminal${b?" selecting":""}`,children:[l.jsx("div",{className:"nc-terminal-host",ref:S}),B&&l.jsx("div",{className:"nc-touch-selection-caret",style:B,"aria-hidden":"true"}),Q&&l.jsx("div",{className:`nc-upload-state${Q.error?" error":""}`,role:"status",children:Q.error?Q.error:Q.done?f("attach-uploaded").replace("{n}",String(Q.total||0)):f("attach-upload-progress").replace("{n}",String(Q.current||0)).replace("{total}",String(Q.total||0))}),(V||b)&&l.jsxs("div",{className:"nc-selection-tools",children:[V?l.jsx("button",{type:"button",onClick:D,children:Z||f("copy")}):l.jsx("span",{children:f("select-drag")}),V&&z&&l.jsx("span",{className:"nc-selection-held",children:f("selection-held")}),l.jsx("button",{type:"button",onClick:()=>{var x,M;(M=(x=j.current)==null?void 0:x.term)==null||M.clearSelection(),K(""),I(!1),k==null||k(!1)},children:f("cancel")}),Z===f("copy-manual")&&l.jsx("textarea",{readOnly:!0,value:V,onFocus:x=>x.target.select()})]})]})}const $v="",Rt="\x1B",GE=[{label:"↑",seq:Rt+"[A"},{label:"↓",seq:Rt+"[B"},{label:"PGUP",seq:Rt+"[5~"},{label:"PGDN",seq:Rt+"[6~"}],XE=new Set([Rt+"[A",Rt+"[B",Rt+"[C",Rt+"[D",Rt+"[5~",Rt+"[6~"]),QE=350,JE=55;function ZE({send:e,action:t,ctrlArmed:n=!1,onCtrl:s,onKeyboard:o,selectionMode:a=!1,onSelectionMode:u,onCellSwitcher:h,cellSwitcherOpen:p=!1,keepKeyboardClosed:m=!0,showEnter:v=!0,keybarLayout:y="full"}){const[w,b]=E.useState(!1),[k,N]=E.useState(!1),[S,j]=E.useState(!1),[C,$]=E.useState(!1),O=y==="compact"&&!C,U=E.useRef({delay:null,interval:null}),V=E.useRef(()=>{}),K=()=>{const M=U.current;M.delay!==null&&clearTimeout(M.delay),M.interval!==null&&clearInterval(M.interval),M.delay=null,M.interval=null};V.current=K,E.useEffect(()=>{const M=()=>{document.visibilityState==="hidden"&&V.current()},L=()=>V.current();return window.addEventListener("blur",L),document.addEventListener("visibilitychange",M),()=>{window.removeEventListener("blur",L),document.removeEventListener("visibilitychange",M),V.current()}},[]),E.useEffect(()=>{y!=="compact"&&$(!1)},[y]);const Z=M=>{S?(e(Rt+M),j(!1)):e(M)},G=M=>{m&&Ih(),M()},Q=M=>({onPointerDown:L=>{L.preventDefault(),G(M)},onClick:L=>{L.detail===0&&G(M)}}),F=M=>({onPointerDown:L=>{L.preventDefault(),K(),G(M),!S&&(U.current.delay=setTimeout(()=>{U.current.delay=null,M(),U.current.interval=setInterval(M,JE)},QE))},onPointerUp:K,onPointerLeave:K,onPointerCancel:K,onLostPointerCapture:K,onTouchCancel:K,onClick:L=>{L.detail===0&&G(M)}}),B=(M,L,T)=>l.jsx("button",{type:"button",...XE.has(L)&&!T?F(()=>Z(L)):Q(()=>{Z(L),T&&T()}),children:M},M),A=(M,L)=>l.jsx("button",{type:"button",...Q(()=>{t(L),N(!1)}),children:M},M),z=h?l.jsx("button",{type:"button","aria-label":f("fleet-cells"),title:f("fleet-cells"),"aria-expanded":p,...Q(h),children:"◫"},"cells"):l.jsx("button",{type:"button",...Q(()=>{o&&o()}),children:"⌨"},"kbd"),I=v&&l.jsx("button",{type:"button",className:"nc-enter-key","aria-label":"ENTER",title:"ENTER",...Q(()=>Z("\r")),children:l.jsx(nt,{name:"enter",size:24})}),D=k&&l.jsxs("div",{className:"nc-keymenu",children:[A("←WIN","prev-window"),A("WIN→","next-window"),A("⬅PANE","pane-left"),A("PANE➡","pane-right"),B("SCROLL",$v+"[",()=>{b(!0),N(!1)}),l.jsx("button",{type:"button",className:a?"armed":"",...Q(()=>{u==null||u(!a),N(!1)}),children:"SELECT"}),B("⌃C","",()=>N(!1)),B("DETACH",$v+"d",()=>N(!1))]});if(w)return l.jsxs("div",{className:"nc-keybar copy",children:[l.jsx("span",{className:"tag",children:"copy-mode"}),GE.map(M=>B(M.label,M.seq)),B("ESCI (q)","q",()=>b(!1))]});if(O)return l.jsxs("div",{className:"nc-keybar termux",children:[D,l.jsxs("div",{className:`nc-keygrid compact${v?"":" no-enter"}`,children:[l.jsx("div",{className:"nc-keyrows",children:l.jsxs("div",{className:"row",children:[l.jsx("button",{type:"button","aria-label":f("keybar-expand"),title:f("expand"),...Q(()=>$(!0)),children:l.jsx(nt,{name:"chevronUp",size:20})},"expand"),z,l.jsx("button",{type:"button",className:k?"armed":"",...Q(()=>N(M=>!M)),children:"☰"},"menu"),B("↑",Rt+"[A"),B("↓",Rt+"[B"),B("←",Rt+"[D"),B("→",Rt+"[C"),B("PGUP",Rt+"[5~"),B("PGDN",Rt+"[6~")]})}),I]})]});const P=y==="compact"&&C,x=P&&l.jsx("button",{type:"button",className:"nc-retract-key","aria-label":f("keybar-retract"),title:f("retract"),...Q(()=>$(!1)),children:l.jsx(nt,{name:"chevronDown",size:20})});return l.jsxs("div",{className:`nc-keybar termux${P?" expanded":""}`,children:[D,l.jsxs("div",{className:`nc-keygrid${v?"":" no-enter"}${P?" expanded":""}`,children:[x,l.jsxs("div",{className:"nc-keyrows",children:[l.jsxs("div",{className:"row",children:[B("ESC",Rt),l.jsx("button",{type:"button",className:k?"armed":"",...Q(()=>N(M=>!M)),children:"☰"},"menu"),B("/","/"),B("—","-"),B("HOME",Rt+"[H"),B("↑",Rt+"[A"),B("END",Rt+"[F"),B("PGUP",Rt+"[5~")]}),l.jsxs("div",{className:"row",children:[B("⇥"," "),z,l.jsx("button",{type:"button",className:n?"armed":"",...Q(()=>{s&&s()}),children:"CTRL"},"ctrl"),l.jsx("button",{type:"button",className:S?"armed":"",...Q(()=>j(M=>!M)),children:"ALT"},"alt"),B("←",Rt+"[D"),B("↓",Rt+"[B"),B("→",Rt+"[C"),B("PGDN",Rt+"[6~")]})]}),I]})]})}const eN=e=>e>1048576?`${(e/1048576).toFixed(1)}M`:e>1024?`${(e/1024).toFixed(0)}K`:`${e}B`;function Nw({session:e,node:t,token:n,filesEvent:s,onClose:o}){Dn();const a=t?`/api/route/${String(t).split("/").map(encodeURIComponent).join("/")}/_`:"/api",u=t?`${t}:${e}`:e,[h,p]=E.useState("outbox"),[m,v]=E.useState({inbox:[],outbox:[]}),[y,w]=E.useState(""),b=E.useRef(null);async function k(){try{const $=await(await Kt(`${a}/files?session=${encodeURIComponent(e)}`,n)).json();if($.error){w($.error);return}v($);const O=$.outbox[0]?$.outbox[0].mtime:0;localStorage.setItem(ey(u),String(O))}catch(C){w(String(C))}}E.useEffect(()=>{k()},[e,t]),E.useEffect(()=>{s&&s.session===e&&k()},[s]);async function N(C){for(const $ of C){w(`carico ${$.name}…`);const O=new FormData;O.append("session",e),O.append("file",$);try{const V=await(await Kt(`${a}/files/upload`,n,{method:"POST",body:O})).json();w(V.error?`errore: ${V.error}`:"")}catch(U){w(String(U))}}k()}async function S(C){const $=await Kt(`${a}/files/download?session=${encodeURIComponent(e)}&box=${h}&name=${encodeURIComponent(C)}`,n);if(!$.ok){w("errore download");return}const O=await $.blob(),U=URL.createObjectURL(O),V=document.createElement("a");V.href=U,V.download=C,V.click(),URL.revokeObjectURL(U)}async function j(C){await Kt(`${a}/files?session=${encodeURIComponent(e)}&box=${h}&name=${encodeURIComponent(C)}`,n,{method:"DELETE"}),k()}return l.jsxs("div",{className:"nc-files",children:[l.jsxs("header",{children:[l.jsx("b",{children:t?`${t}:${e}`:e}),l.jsx("button",{onClick:o,title:f("close"),children:l.jsx(nt,{name:"x",size:20})})]}),l.jsxs("nav",{children:[l.jsx("button",{className:h==="outbox"?"on":"",onClick:()=>p("outbox"),children:"outbox"}),l.jsx("button",{className:h==="inbox"?"on":"",onClick:()=>p("inbox"),children:"inbox"}),l.jsxs("button",{className:"up",onClick:()=>b.current&&b.current.click(),children:[l.jsx(nt,{name:"upload",size:18})," ",f("upload")]}),l.jsx("input",{type:"file",multiple:!0,ref:b,style:{display:"none"},onChange:C=>{N(Array.from(C.target.files||[])),C.target.value=""}})]}),y&&l.jsx("div",{className:"nc-busy",children:y}),l.jsxs("ul",{children:[m[h].map(C=>l.jsxs("li",{children:[l.jsx("span",{className:"name",onClick:()=>S(C.name),children:C.name}),l.jsx("small",{children:eN(C.size)}),l.jsx("button",{onClick:()=>j(C.name),title:f("delete"),children:l.jsx(nt,{name:"trash",size:18})})]},C.name)),m[h].length===0&&l.jsx("li",{className:"empty",children:f("empty-files")})]})]})}const sc="nc_composer_v1",Oh="nc-composer-reset",tN=50,jw=256*1024,Rw=512*1024,nN=768*1024,Fv=2*1024*1024,Pw=720*60*60*1e3,Bh=1;function Aw(e){const t=Number(e);return Number.isFinite(t)&&t>0?t:0}function kf(e){if(e!==void 0)return e;try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function Gl(){return{version:Bh,cells:{}}}function Lw(e){const t=[];for(const s of Array.isArray(e)?e:[]){const o=typeof s=="string"?s:s&&s.text,a=Aw(typeof s=="string"?0:s&&s.at);if(!(typeof o!="string"||!o||o.length>jw)&&!(t.length&&t[t.length-1].text===o)&&(t.push({text:o,at:a}),t.length>=tN))break}let n=0;return t.filter(s=>n+s.text.length>nN?!1:(n+=s.text.length,!0))}function Xl(e){if(!e||typeof e!="object")return null;const t=typeof e.draft=="string"&&e.draft.length<=Rw?e.draft:"",n=Lw(e.history),s=Aw(e.updatedAt),o=e.expanded===!0;return!t&&!n.length&&!o?null:{draft:t,history:n,expanded:o,updatedAt:s}}function iN(e){let t;try{t=typeof e=="string"?JSON.parse(e):e}catch{return Gl()}if(!t||typeof t!="object"||t.version!==Bh||!t.cells||typeof t.cells!="object")return Gl();const n=Object.create(null);for(const[s,o]of Object.entries(t.cells)){if(!s||typeof s!="string"||s.length>512||s==="__proto__"||s==="constructor"||s==="prototype")continue;const a=Xl(o);a&&(n[s]=a)}return{version:Bh,cells:n}}function Tw(e){const t=kf(e);if(!t)return Gl();try{return iN(t.getItem(sc))}catch{return Gl()}}function Hv(e){try{return JSON.stringify(e).length}catch{return 1/0}}function sN(e,t,n){for(const[s,o]of Object.entries(e.cells))s!==n&&o.updatedAt>0&&t-o.updatedAt>Pw&&delete e.cells[s]}function Mw(e,t){return Object.entries(e.cells).filter(([n])=>n!==t).sort((n,s)=>n[1].updatedAt-s[1].updatedAt).map(([n])=>n)}function rN(e,t){for(;Hv(e)>Fv;){const n=Object.entries(e.cells).filter(([,s])=>s.history.length).sort((s,o)=>s[1].updatedAt-o[1].updatedAt);if(!n.length)break;n[0][1].history.pop()}for(const n of Mw(e,t)){if(Hv(e)<=Fv)break;delete e.cells[n]}}function Dw(e,t,n){const s=kf(e);if(!s)return!1;rN(t,n);const o=()=>(s.setItem(sc,JSON.stringify(t)),!0);try{return o()}catch{for(const u of Mw(t,n)){delete t.cells[u];try{return o()}catch{}}return!1}}function aa(e,t,n,s){const o=Tw(t);sN(o,n,e);const a=Xl(o.cells[e])||{draft:"",history:[],expanded:!1,updatedAt:0},u=s({...a,history:[...a.history]}),h=Xl(u);return h?o.cells[e]={...h,updatedAt:n}:delete o.cells[e],{ok:Dw(t,o,e),cell:o.cells[e]||{draft:"",history:[],expanded:!1,updatedAt:n}}}function oN({ownerId:e,node:t,session:n}){const s=String(n||"");if(!s)return"";const o=Br.test(String(e||""))?String(e):t?`route:${String(t)}`:"local";return`${encodeURIComponent(o)}:${encodeURIComponent(s)}`}function Bo(e,t,n=Date.now()){if(!e)return{draft:"",history:[],expanded:!1,updatedAt:0};const s=Tw(t),o=Xl(s.cells[e]);return!o||o.updatedAt>0&&n-o.updatedAt>Pw?(s.cells[e]&&(delete s.cells[e],Dw(t,s,"")),{draft:"",history:[],expanded:!1,updatedAt:0}):{...o,history:[...o.history]}}function Uv(e,t,n,s=Date.now()){const o=String(t||"");return!e||o.length>Rw?!1:aa(e,n,s,a=>({...a,draft:o})).ok}function Wv(e,t,n=Date.now()){return e?aa(e,t,n,s=>({...s,draft:""})).ok:!1}function aN(e,t,n,s=Date.now()){return e?aa(e,n,s,o=>({...o,expanded:!!t})).ok:!1}function lN(e,t,n,s=Date.now()){const o=String(t||"");return!e||!o||o.length>jw?!1:aa(e,n,s,a=>{const u=a.history.filter(h=>h.text!==o);return u.unshift({text:o,at:s}),{...a,history:Lw(u)}}).ok}function cN(e,t,n=Date.now()){return e?aa(e,t,n,s=>({...s,history:[]})).ok:!1}function uN(e){const t=kf(e);if(!t)return!1;try{return t.removeItem(sc),!0}catch{return!1}}const dN=300;function hN(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function fN({ownerId:e,node:t,session:n,storage:s=hN()}){const o=E.useMemo(()=>oN({ownerId:e,node:t,session:n}),[e,t,n]),a=E.useMemo(()=>Bo(o,s),[]),[u,h]=E.useState(a.draft),[p,m]=E.useState(a.expanded),[v,y]=E.useState(a.history),[w,b]=E.useState(-1),k=E.useRef(o),N=E.useRef(a.draft),S=E.useRef(null),j=E.useRef(a.updatedAt||0),C=E.useRef(a.draft),$=E.useCallback(()=>{S.current&&clearTimeout(S.current),S.current=null},[]),O=E.useCallback(()=>{$(),Uv(k.current,N.current,s)},[$,s]),U=E.useCallback(()=>{$(),S.current=setTimeout(()=>{S.current=null,Uv(k.current,N.current,s)},dN)},[$,s]),V=E.useCallback(z=>{const I=String(typeof z=="function"?z(N.current):z||"");N.current=I,j.current=Date.now(),C.current=I,b(-1),h(I),U()},[U]),K=E.useCallback((z,I)=>{$(),N.current=z,j.current=Date.now(),h(z),b(I),U()},[$,U]),Z=E.useCallback(()=>{if(!v.length)return!1;const z=Math.min(w+1,v.length-1);return w<0&&(C.current=N.current),K(v[z].text,z),!0},[K,v,w]),G=E.useCallback(()=>{if(w<0)return!1;const z=w-1;return K(z<0?C.current:v[z].text,z),!0},[K,v,w]),Q=E.useCallback(z=>{C.current=N.current;const I=v.findIndex(D=>D.text===z);K(String(z||""),I)},[K,v]),F=E.useCallback(()=>{m(z=>{const I=!z;return aN(k.current,I,s),I})},[s]),B=E.useCallback((z,I,D)=>{if(!z)return;if(lN(z,D,s),!(k.current===z)){Bo(z,s).draft===I&&Wv(z,s);return}y(Bo(z,s).history),C.current="",b(-1),N.current===I?($(),N.current="",j.current=Date.now(),h(""),Wv(z,s)):U()},[$,U,s]),A=E.useCallback(()=>{cN(k.current,s),y([]),b(-1),C.current=N.current},[s]);return E.useEffect(()=>{if(k.current===o)return;O(),k.current=o;const z=Bo(o,s);N.current=z.draft,j.current=z.updatedAt||0,C.current=z.draft,h(z.draft),m(z.expanded),y(z.history),b(-1)},[o,O,s]),E.useEffect(()=>{const z=()=>O(),I=()=>{document.visibilityState==="hidden"&&O()};return window.addEventListener("pagehide",z),document.addEventListener("visibilitychange",I),()=>{window.removeEventListener("pagehide",z),document.removeEventListener("visibilitychange",I),O()}},[O]),E.useEffect(()=>{const z=()=>{$(),N.current="",j.current=0,C.current="",h(""),m(!1),y([]),b(-1)},I=P=>{if(P.key!==sc)return;if(P.newValue==null){z();return}const x=Bo(k.current,s);x.updatedAt<j.current||($(),N.current=x.draft,j.current=x.updatedAt,C.current=x.draft,h(x.draft),m(x.expanded),y(x.history),b(-1))},D=()=>z();return window.addEventListener("storage",I),window.addEventListener(Oh,D),()=>{window.removeEventListener("storage",I),window.removeEventListener(Oh,D)}},[$,s]),{cellKey:o,text:u,setText:V,expanded:p,toggleExpanded:F,history:v,historyCursor:w,recallPrevious:Z,recallNext:G,selectHistory:Q,confirmSubmitted:B,clearHistory:A,flush:O}}function Iw({submitText:e,token:t,session:n,node:s,ownerId:o,keepKeyboardClosedOnVoice:a=!0}){Dn();const u=s?`/api/route/${String(s).split("/").map(encodeURIComponent).join("/")}/_`:"/api",{cellKey:h,text:p,setText:m,expanded:v,toggleExpanded:y,history:w,historyCursor:b,recallPrevious:k,recallNext:N,selectHistory:S,confirmSubmitted:j,clearHistory:C,flush:$}=fN({ownerId:o,node:s,session:n}),[O,U]=E.useState(!1),[V,K]=E.useState(""),[Z,G]=E.useState(!1),Q=E.useRef(null),F=E.useRef(null),B=E.useRef(null),[A,z]=E.useState(!1),[I,D]=E.useState({left:0,bottom:0}),[P,x]=E.useState(!1),[M,L]=E.useState(!1),T=E.useRef(null),H=E.useRef(null),Y=E.useRef(null),de=E.useRef(null),ue=E.useRef(null),fe=E.useRef(null),ve=E.useRef(null),ie=E.useRef(!1),[ye,Ue]=E.useState(!1),[ut,rt]=E.useState({left:0,bottom:0,width:320}),Ae=E.useRef(`nc-attach-${Math.random().toString(36).slice(2,8)}`);E.useEffect(()=>{let Se=!1;if(s){G(!1);return}return Kt(`${u}/voice/status`,t).then(le=>le.json()).then(le=>{Se||G(!!le.serverSttConfigured)}).catch(()=>{Se||G(!1)}),()=>{Se=!0}},[t,u]);const Qt=!!(typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition)||Z);async function $e(){const Se=B.current&&typeof B.current.value=="string"?B.current.value:p;Ih(),Se!==p&&m(Se);const le=Se,Pe=EE(le);if(!Pe||M)return;L(!0),K("");let We=!1;try{We=!!await e(Pe)}catch{We=!1}We?j(h,le,Pe):K(f("composer-send-failed")),L(!1)}function dt(){const Se=T.current&&T.current.getBoundingClientRect();Se&&D({left:Math.max(6,Math.min(Se.left,window.innerWidth-186)),bottom:window.innerHeight-Se.top+6}),z(!0)}function it(Se){z(!1),Se&&T.current&&T.current.focus()}function wt(){const Se=Y.current&&Y.current.getBoundingClientRect();if(Se){const le=Math.max(220,Math.min(360,window.innerWidth-12));rt({left:Math.max(6,Math.min(Se.right-le,window.innerWidth-le-6)),bottom:window.innerHeight-Se.top+6,width:le})}Ue(!0)}function bt(Se){Ue(!1),Se&&Y.current&&Y.current.focus()}E.useEffect(()=>{if(!A)return;const Se=Pe=>{Pe.key==="Escape"&&it(!0)},le=Pe=>{const We=H.current&&H.current.contains(Pe.target),te=T.current&&T.current.contains(Pe.target);!We&&!te&&it(!1)};return document.addEventListener("keydown",Se),document.addEventListener("pointerdown",le),()=>{document.removeEventListener("keydown",Se),document.removeEventListener("pointerdown",le)}},[A]),E.useEffect(()=>{if(!ye)return;const Se=Pe=>{Pe.key==="Escape"&&bt(!0)},le=Pe=>{const We=de.current&&de.current.contains(Pe.target),te=Y.current&&Y.current.contains(Pe.target);!We&&!te&&bt(!1)};return document.addEventListener("keydown",Se),document.addEventListener("pointerdown",le),()=>{document.removeEventListener("keydown",Se),document.removeEventListener("pointerdown",le)}},[ye]);function mt(Se){if(!(Se.isComposing||ie.current||Se.altKey||Se.ctrlKey||Se.metaKey)){if(Se.key==="ArrowUp"&&Se.currentTarget.selectionStart===0&&Se.currentTarget.selectionEnd===0){k()&&Se.preventDefault();return}Se.key==="ArrowDown"&&b>=0&&Se.currentTarget.selectionStart===p.length&&Se.currentTarget.selectionEnd===p.length&&N()&&Se.preventDefault()}}function gt(Se){it(!1),Se.current&&Se.current.click()}async function pt(Se){if(!Se.length||!n)return;x(!0),K("");const{paths:le,errors:Pe}=await xw({files:Se,token:t,session:n,node:s,paste:!1});Pe.length&&K(Pe.map(We=>`${We.name}: ${We.message}`).join(" · ")),le.length&&m(We=>We+(We&&!We.endsWith(" ")?" ":"")+le.join(" ")),x(!1)}function Pt(){Q.current&&Q.current.stop(),F.current&&F.current.stop(),U(!1)}async function vt(){K("");const Se=window.SpeechRecognition||window.webkitSpeechRecognition;if(Se){const le=new Se;le.lang="it-IT",le.continuous=!1,le.interimResults=!0;const Pe=p?`${p} `:"";le.onresult=We=>{const te=Array.from(We.results).map(we=>we[0].transcript).join("");m(Pe+te)},le.onend=()=>U(!1),le.onerror=We=>{K(`voice: ${We.error||"errore"}`),U(!1)},Q.current=le,le.start(),U(!0);return}try{const le=await navigator.mediaDevices.getUserMedia({audio:!0}),Pe=new MediaRecorder(le),We=[];Pe.ondataavailable=te=>We.push(te.data),Pe.onstop=async()=>{le.getTracks().forEach(te=>te.stop()),U(!1),K("trascrivo…");try{const te=new Blob(We,{type:Pe.mimeType||"audio/webm"}),Ne=await(await Kt(`${u}/voice/transcribe`,t,{method:"POST",headers:{"content-type":"application/octet-stream"},body:te})).json();Ne.error?K(Ne.error):(K(""),m(De=>De+(De?" ":"")+(Ne.text||"")))}catch(te){K(String(te))}},F.current={stop:()=>Pe.state!=="inactive"&&Pe.stop()},Pe.start(),U(!0)}catch{K("microfono non disponibile"),U(!1)}}function xt(){a&&Ih(),O?Pt():vt()}return l.jsxs("div",{className:"nc-composer",children:[V&&l.jsx("div",{className:"nc-composer-err",children:V}),l.jsxs("div",{className:"nc-composer-row",children:[n&&l.jsx("button",{ref:T,className:P?"attach busy":"attach",disabled:P,onClick:()=>A?it(!1):dt(),title:f(P?"attach-uploading":"attach"),"aria-label":f("attach"),"aria-haspopup":"menu","aria-expanded":A,"aria-controls":Ae.current,children:l.jsx(nt,{name:"attach",size:22})}),A&&l.jsxs("div",{ref:H,id:Ae.current,role:"menu",className:"nc-attach-menu",style:{left:I.left,bottom:I.bottom},children:[l.jsxs("button",{role:"menuitem",onClick:()=>gt(ue),children:[l.jsx(nt,{name:"file",size:18})," ",f("attach-file")]}),l.jsxs("button",{role:"menuitem",onClick:()=>gt(fe),children:[l.jsx(nt,{name:"camera",size:18})," ",f("attach-camera")]}),l.jsxs("button",{role:"menuitem",onClick:()=>gt(ve),children:[l.jsx(nt,{name:"image",size:18})," ",f("attach-gallery")]})]}),l.jsx("button",{ref:Y,type:"button",className:"history",onPointerDown:Se=>Se.preventDefault(),onClick:()=>ye?bt(!1):wt(),title:f("composer-history-tools"),"aria-label":f("composer-history-tools"),"aria-haspopup":"menu","aria-expanded":ye,children:l.jsx(nt,{name:"history",size:21})}),ye&&l.jsxs("div",{ref:de,role:"menu",className:"nc-composer-history-menu",style:{left:ut.left,bottom:ut.bottom,width:ut.width},children:[l.jsxs("button",{role:"menuitem",className:"nc-composer-history-action",onPointerDown:Se=>Se.preventDefault(),onClick:()=>{y(),bt(!1)},children:[l.jsx(nt,{name:v?"chevronDown":"chevronUp",size:18}),f(v?"composer-collapse":"composer-expand")]}),l.jsx("div",{className:"nc-composer-history-title",children:f("composer-history")}),w.length===0&&l.jsx("div",{className:"nc-composer-history-empty",children:f("composer-history-empty")}),w.map((Se,le)=>l.jsxs("button",{type:"button",role:"menuitem",className:"nc-composer-history-entry",onPointerDown:Pe=>Pe.preventDefault(),onClick:()=>{S(Se.text),bt(!1)},children:[l.jsx("span",{children:Se.text.replace(/\s+/g," ").slice(0,180)}),Se.at>0&&l.jsx("small",{children:new Date(Se.at).toLocaleString()})]},`${Se.at}:${le}`)),w.length>0&&l.jsx("button",{type:"button",role:"menuitem",className:"nc-composer-history-clear",onPointerDown:Se=>Se.preventDefault(),onClick:()=>{C(),bt(!1)},children:f("composer-history-clear")})]}),l.jsx("input",{ref:ue,type:"file",multiple:!0,hidden:!0,onChange:Se=>{pt(Array.from(Se.target.files||[])),Se.target.value=""}}),l.jsx("input",{ref:fe,type:"file",accept:"image/*",capture:"environment",hidden:!0,onChange:Se=>{pt(Array.from(Se.target.files||[])),Se.target.value=""}}),l.jsx("input",{ref:ve,type:"file",accept:"image/*,video/*",multiple:!0,hidden:!0,onChange:Se=>{pt(Array.from(Se.target.files||[])),Se.target.value=""}}),l.jsx("textarea",{ref:B,className:v?"expanded":"",rows:v?8:2,value:p,placeholder:f("composer-placeholder"),onChange:Se=>m(Se.target.value),onKeyDown:mt,onCompositionStart:()=>{ie.current=!0},onCompositionEnd:()=>{ie.current=!1},onBlur:$}),Qt&&l.jsx("button",{type:"button",className:O?"mic on":"mic",title:f("voice"),"aria-label":f("voice"),onPointerDown:Se=>{Se.preventDefault(),xt()},onClick:Se=>{Se.detail===0&&xt()},children:l.jsx(nt,{name:"mic",size:22})}),l.jsx("button",{type:"button",className:"go",disabled:M,onPointerDown:Se=>Se.preventDefault(),onClick:$e,title:f("send"),children:l.jsx(nt,{name:"enter",size:22})})]})]})}function hd(e){return String(e||"?").replace(/^[^a-zA-Z0-9]+/,"").charAt(0).toUpperCase()||"?"}const pN=180,mN=480,Pr=(e,t=[])=>`${t.length?t.join("/"):"local"}:${e}`;function gN({sessions:e=[],cells:t=[],activeSessions:n=[],nodeGroups:s=[],onPick:o,onAddTile:a,onPower:u,onBoot:h,onNodePower:p,onKill:m,onVisibility:v,onNew:y,onNodeRename:w,onSettings:b,onBootError:k,localNodeId:N,fleetCapabilities:S=[],bootSettlement:j=null,hostCell:C=null,hostLease:$=null,onDesignateCell:O,onClearHostCell:U,onBootSettlementApplied:V,onOpenVlSession:K,width:Z=240,collapsed:G=!1,onResize:Q,onToggleCollapse:F}){const[B,A]=Dn(),{pins:z,orders:I,togglePin:D,removePin:P,pinError:x,retryPinPersist:M,clearPinError:L,viewFor:T,updateView:H,canMoveRoster:Y,moveRoster:de,stepRoster:ue}=af(),{groupsFor:fe,moveNode:ve,stepNode:ie,nodeKey:ye}=yy();function Ue(X,se,W){const oe=Sy(W);if(oe==="addPin"){D(X.key);return}if(oe==="designate"){O&&O(se.cell);return}if(oe==="clearAndUnpin"){if(!U)return;Promise.resolve(U()).then(pe=>{pe&&P(X.key)})}}const ut=new Set((t||[]).map(X=>X.tmuxSession)),rt=new Map((e||[]).map(X=>[X.name,X])),Ae=(X,se)=>Mx(z,X,se),Dt=Dx,Qt=[...t||[]].sort((X,se)=>Dt(Ae(X.tmuxSession,(rt.get(X.tmuxSession)||{}).activity),Ae(se.tmuxSession,(rt.get(se.tmuxSession)||{}).activity))),$e=(e||[]).filter(X=>!ut.has(X.name)).sort((X,se)=>Dt(Ae(X.name,X.activity),Ae(se.name,se.activity))||X.name.localeCompare(se.name)),dt=new Set(n||[]),it=uf(Qt,$e,rt),wt=Cs(it,z,T("local").filter,Yi(I,"local")),mt=fe(s||[]).map(X=>{const se=(X.route&&X.route.length?X.route:[X.name]).join("/"),W=T(se);if(X.kind==="vl")return{g:X,nodeRoute:se,groupView:W,rawItems:[],items:[]};const{rawItems:oe}=$l(X),pe=Cs(oe,z,W.filter,Yi(I,se));return{g:X,nodeRoute:se,groupView:W,rawItems:oe,items:pe}}),gt=(X,se,W)=>o&&o({session:X,...se?{node:se}:{},...Br.test(String(W||""))?{ownerId:W}:{}}),pt=async X=>{if(!(X!=null&&X.direct)||!w)return;const se=window.prompt(f("rename-node-prompt"),X.label||X.name);if(se!==null)try{await w(X,se)||window.alert(f("rename-node-invalid"))}catch(W){window.alert(String((W==null?void 0:W.message)||W))}},[Pt,vt]=E.useState({}),[xt,Se]=E.useState(new Set);E.useEffect(()=>{const X=new Map;for(const se of t||[])X.set(Pr(se.cell),!!se.boot);for(const se of s||[]){const W=se.route||[se.name];for(const oe of se.cells||[])X.set(Pr(oe.cell,W),!!oe.boot)}vt(se=>{let W=!1;const oe={...se};for(const[pe,_e]of Object.entries(se))X.has(pe)&&X.get(pe)===_e&&(delete oe[pe],W=!0);return W?oe:se})},[t,s]),E.useEffect(()=>{if(!(j!=null&&j.cell))return;const X=Array.isArray(j.route)?j.route:[],se=Pr(j.cell,X);vt(W=>({...W,[se]:!!j.enabled})),V&&V(j.id)},[j,V]);const le=(X,se=[])=>{const W=Pr(X.cell,se);return Object.prototype.hasOwnProperty.call(Pt,W)?Pt[W]:!!X.boot},Pe=async(X,se,W=[])=>{if(X.stopPropagation(),!h)return;const oe=Pr(se.cell,W),pe=!le(se,W);vt(_e=>({..._e,[oe]:pe})),Se(_e=>new Set(_e).add(oe));try{await h(se.cell,pe,W)}catch(_e){vt(Be=>{const me={...Be};return delete me[oe],me}),k&&k(_e)}finally{Se(_e=>{const Be=new Set(_e);return Be.delete(oe),Be})}},We=(X,se=[])=>{const W=Pr(X.cell,se),oe=le(X,se),pe=`${f(oe?"boot-disable":"boot-enable")} ${X.cell}`;return l.jsx("button",{className:`nc-boot${oe?" on":""}`,disabled:xt.has(W),onClick:_e=>Pe(_e,X,se),title:pe,"aria-label":pe,children:l.jsx(nt,{name:"boot",size:14})})},[te,we]=E.useState(null),Ne=(X,se)=>{const W=X.currentTarget.getBoundingClientRect();we({text:se,y:W.top+W.height/2})},De=()=>we(null),Oe=E.useRef(null);E.useEffect(()=>()=>{Oe.current&&Oe.current()},[]);function _t(X){X.preventDefault(),X.stopPropagation();const se=X.clientX,W=Z,oe=_e=>{const Be=Math.max(pN,Math.min(mN,W+(_e.clientX-se)));Q&&Q(Be)},pe=()=>{window.removeEventListener("pointermove",oe),window.removeEventListener("pointerup",pe),window.removeEventListener("pointercancel",pe),window.removeEventListener("blur",pe),Oe.current=null};window.addEventListener("pointermove",oe),window.addEventListener("pointerup",pe),window.addEventListener("pointercancel",pe),window.addEventListener("blur",pe),Oe.current=pe}const yt=G?{width:48,flex:"0 0 48px"}:{width:Z,flex:`0 0 ${Z}px`};return G?l.jsxs("aside",{className:"nc-sidebar mini",style:yt,children:[l.jsx("div",{className:"nc-side-head mini",children:l.jsx("button",{className:"nc-collapse-btn",onClick:F,title:f("expand"),children:"⟩"})}),l.jsx("button",{className:"nc-side-gear mini",onClick:()=>b&&b("nodes",!1),title:f("settings"),onMouseEnter:X=>Ne(X,f("settings")),onMouseLeave:De,children:l.jsx(nt,{name:"gear",size:16})}),l.jsx("div",{className:"nc-side-scroll mini",children:l.jsxs("div",{className:"nc-side-group mini",children:[T("local").open&&wt.map(X=>X.type==="cell"?(()=>{const se=X.value,W=se.degraded?"warn":se.tmux?"on":"",oe=!!se.tmux;return l.jsx("button",{type:"button",className:`nc-mini-dot${dt.has(se.tmuxSession)?" active":""}`,onMouseEnter:pe=>Ne(pe,`${se.cell}: ${X.subtitle}`),onMouseLeave:De,draggable:oe,onDragStart:oe?pe=>pe.dataTransfer.setData("text/nc-session",se.tmuxSession):void 0,onClick:oe?()=>a&&a(se.tmuxSession):()=>u&&u(se),onDoubleClick:oe?()=>gt(se.tmuxSession,"",N):void 0,children:l.jsx("span",{className:`nc-dot ${W}${X.working?" working":""}`})},X.key)})():(()=>{const se=X.value;return l.jsx("button",{type:"button",className:`nc-mini-init${dt.has(se.name)?" active":""}`,onMouseEnter:W=>Ne(W,se.name),onMouseLeave:De,draggable:!0,onDragStart:W=>W.dataTransfer.setData("text/nc-session",se.name),onClick:()=>a&&a(se.name),onDoubleClick:()=>gt(se.name,"",N),children:hd(se.name)},X.key)})()),mt.flatMap(({g:X,nodeRoute:se,groupView:W,items:oe})=>X.kind==="vl"?X.status==="up"&&X.sessions.length?X.sessions.map(pe=>l.jsx("button",{type:"button",className:"nc-mini-init",onMouseEnter:_e=>Ne(_e,`${X.label||se}: ${pe.name}`),onMouseLeave:De,onClick:()=>K&&K(X.peer),children:hd(pe.name)},pe.key)):[l.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:pe=>Ne(pe,`${X.label||X.name}: ${X.status==="up"?f("no-sessions-short"):qi(X)}`),onMouseLeave:De,children:l.jsx("span",{className:`nc-dot${X.status==="up"?" on":" warn"}`})},`nodo-vl-${se}-${X.name}`)]:X.status==="up"?W.open?oe.map(pe=>pe.type==="cell"?(()=>{const _e=pe.value,Be=!!_e.tmux;return l.jsx("button",{type:"button",className:`nc-mini-dot${dt.has(pe.key)?" active":""}`,onMouseEnter:me=>Ne(me,`${X.label||se}: ${_e.cell} · ${pe.subtitle}`),onMouseLeave:De,draggable:Be,onDragStart:Be?me=>me.dataTransfer.setData("text/nc-session",pe.key):void 0,onClick:Be?()=>a&&a(pe.key):()=>u&&u({..._e,route:X.route,availableEngines:X.engines||[]}),onDoubleClick:Be?()=>gt(_e.tmuxSession,se,X.instanceId):void 0,children:l.jsx("span",{className:`nc-dot ${_e.degraded?"warn":Be?`on${pe.working?" working":""}`:""}`})},pe.key)})():(()=>{const _e=pe.value;return l.jsx("button",{type:"button",className:`nc-mini-init${dt.has(pe.key)?" active":""}`,onMouseEnter:Be=>Ne(Be,`${X.label||se}: ${_e.name}`),onMouseLeave:De,draggable:!0,onDragStart:Be=>Be.dataTransfer.setData("text/nc-session",pe.key),onClick:()=>a&&a(pe.key),onDoubleClick:()=>gt(_e.name,se,X.instanceId),children:hd(_e.name)},pe.key)})()):[]:[l.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:pe=>Ne(pe,`${X.label||(X.route||[X.name]).join(" › ")}: ${qi(X)}`),onMouseLeave:De,children:l.jsx("span",{className:`nc-dot${X.status==="passive"?"":" warn"}`})},`nodo-${(X.route||[X.name]).join("/")}`)])]})}),te&&l.jsx("div",{className:"nc-mini-tip",style:{top:te.y},children:te.text})]}):l.jsxs("aside",{className:"nc-sidebar",style:yt,children:[l.jsxs("div",{className:"nc-side-head",children:[l.jsx("button",{className:"nc-collapse-btn",onClick:F,title:f("collapse"),children:"⟨"}),l.jsx("span",{className:"nc-side-title",children:f("fleet")}),l.jsxs("button",{className:"nc-new-btn",onClick:y,title:f("fleet-new-cell"),children:["+ ",f("new")]})]}),l.jsxs("button",{className:"nc-side-gear",onClick:()=>b&&b("nodes",!1),title:f("settings"),children:[l.jsx(nt,{name:"gear",size:15})," ",f("settings")]}),l.jsx(ky,{pinError:x,onRetry:M,onDismiss:L}),l.jsxs("div",{className:"nc-side-scroll",children:[l.jsx(vN,{label:f("position-local"),count:wt.length,state:T("local"),onToggle:()=>H("local",{open:!T("local").open}),onFilter:X=>H("local",{filter:X})}),T("local").open&&l.jsxs("div",{className:"nc-side-group",children:[wt.map(X=>X.type==="cell"?(()=>{const se=X.value,W=by({hostCell:C,pins:z,item:X}),oe=se.degraded?"warn":se.tmux?"on":"",pe=xy(W,$),_e=se.degraded?f("cell-degraded"):X.working?X.subtitle:se.tmux?f("cell-idle"):f("cell-off"),Be=pe?`${_e} · ${f(pe)}`:_e,me=!!se.tmux;return l.jsxs("div",{"data-roster-key":X.key,"data-position":"local",className:`nc-cell${me?" live":""}${dt.has(se.tmuxSession)?" active":""}`,title:`${se.cell} · ${X.subtitle}${Be===X.subtitle?"":` · ${Be}`}`,"aria-label":`${se.cell}, ${X.subtitle}${Be===X.subtitle?"":`, ${Be}`}`,draggable:me,onDragStart:me?Ce=>Ce.dataTransfer.setData("text/nc-session",se.tmuxSession):void 0,onClick:me?()=>a&&a(se.tmuxSession):void 0,onDoubleClick:me?()=>gt(se.tmuxSession,"",N):void 0,children:[l.jsx(ji,{position:"local",itemKey:X.key,label:se.cell,canMove:Y,onMove:(Ce,Ge)=>de("local",Ce,Ge,it),onStep:Ce=>ue("local",X.key,Ce,it)}),l.jsx("span",{className:`nc-dot ${oe}${X.working?" working":""}`}),l.jsxs("span",{className:"nc-cell-main",children:[l.jsx("b",{title:se.cell,children:se.cell}),l.jsx("small",{title:X.subtitle,children:X.subtitle})]}),l.jsx("button",{className:`nc-pin${W==="live"?" live":W==="favorite"?" on":""}`,title:W==="live"?"live host":f("pin"),onClick:Ce=>{Ce.stopPropagation(),Ue(X,se,W)},children:W==="none"?"☆":"★"}),h&&S.includes("boot")&&We(se),l.jsx("button",{className:`nc-power${se.tmux?" on":""}${se.degraded?" warn":""}`,onClick:Ce=>{Ce.stopPropagation(),u&&u({...se,boot:le(se)})},title:se.active?f("power-off"):f("power-on"),children:l.jsx(nt,{name:"power",size:14})})]},X.key)})():(()=>{var W;const se=X.value;return l.jsxs("div",{"data-roster-key":X.key,"data-position":"local",className:`nc-side-card${dt.has(se.name)?" active":""}`,draggable:!0,onDragStart:oe=>oe.dataTransfer.setData("text/nc-session",se.name),onClick:()=>a&&a(se.name),onDoubleClick:()=>gt(se.name,"",N),children:[l.jsx(ji,{position:"local",itemKey:X.key,label:se.name,canMove:Y,onMove:(oe,pe)=>de("local",oe,pe,it),onStep:oe=>ue("local",X.key,oe,it)}),l.jsx("span",{className:se.attached?"nc-dot on":"nc-dot"}),l.jsxs("span",{className:"nc-card-main",children:[l.jsx("b",{children:se.name}),l.jsxs("small",{children:[se.preview||se.cmd||f("windows").replace("{n}",String(se.windows||0)),((W=se.outbox)==null?void 0:W.count)>0?` · 📦${se.outbox.count}`:""]})]}),se.activity?l.jsx("span",{className:"nc-rel",children:Or(se.activity)}):null,l.jsx("button",{className:`nc-pin${z.includes(X.key)?" on":""}`,title:f("pin"),onClick:oe=>{oe.stopPropagation(),D(X.key)},children:z.includes(X.key)?"★":"☆"}),l.jsx("button",{className:`nc-technical${se.technical?" on":""}`,title:se.technical?f("mark-normal"):f("mark-technical"),"aria-label":`${se.technical?f("mark-normal"):f("mark-technical")} ${se.name}`,onClick:oe=>{oe.stopPropagation(),v&&v(se.name,!se.technical,[])},children:"T"}),l.jsx("button",{className:"nc-menu",title:f("terminate"),onClick:oe=>{oe.stopPropagation(),window.confirm(f("terminate-confirm").replace("{name}",se.name))&&m&&m(se.name)},children:"⋯"})]},X.key)})()),wt.length===0&&l.jsx("div",{className:"nc-empty",children:f("no-sessions-short")})]}),mt.map(({g:X,nodeRoute:se,groupView:W,rawItems:oe,items:pe})=>{const Be=Cy(X.health)||(X.status==="up"?"on":X.status==="passive"?"":"warn");return X.kind==="vl"?l.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":ye(X),children:[l.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:()=>H(se,{open:!W.open}),onKeyDown:me=>{(me.key==="Enter"||me.key===" ")&&(me.preventDefault(),H(se,{open:!W.open}))},children:[l.jsx(ji,{scope:"node",position:"nodes",itemKey:ye(X),label:X.label||X.name,onMove:(me,Ce)=>ve(me,Ce,s||[]),onStep:me=>ie(ye(X),me,s||[])}),l.jsx("span",{className:"nc-node-chevron",children:W.open?"⌄":"›"}),l.jsx("span",{className:`nc-dot ${Be}`,title:X.health?Vo(X.health):""}),l.jsx("b",{children:X.label||X.name}),l.jsxs("small",{children:[" · ",X.status==="up"?f("node-sessions").replace("{n}",String(X.sessions.length)):qi(X)]})]}),X.status==="up"&&W.open&&l.jsxs("div",{className:"nc-side-group",children:[X.sessions.map(me=>l.jsxs("div",{className:"nc-side-card nc-vl-session-row",role:"button",tabIndex:0,onClick:()=>K&&K(X.peer),onKeyDown:Ce=>{(Ce.key==="Enter"||Ce.key===" ")&&(Ce.preventDefault(),K&&K(X.peer))},children:[l.jsx("span",{className:"nc-dot on"}),l.jsxs("span",{className:"nc-card-main",children:[l.jsx("b",{children:me.name}),l.jsx("small",{children:f("vl-events-title")})]})]},me.key)),X.sessions.length===0&&l.jsx("div",{className:"nc-empty",children:f("no-sessions-short")})]})]},`nodo-vl-${se}-${X.name}`):l.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":ye(X),children:[l.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onContextMenu:X.direct&&w?me=>{me.preventDefault(),pt(X)}:void 0,onClick:()=>H(se,{open:!W.open}),onKeyDown:me=>{(me.key==="Enter"||me.key===" ")&&(me.preventDefault(),H(se,{open:!W.open}))},children:[l.jsx(ji,{scope:"node",position:"nodes",itemKey:ye(X),label:X.label||X.name,onMove:(me,Ce)=>ve(me,Ce,s||[]),onStep:me=>ie(ye(X),me,s||[])}),l.jsx("span",{className:"nc-node-chevron",children:W.open?"⌄":"›"}),l.jsx("span",{className:`nc-dot ${Be}`,title:X.health?Vo(X.health):""}),l.jsx("b",{children:X.label||X.name}),l.jsxs("small",{children:[" · ",X.status==="up"?f("node-sessions").replace("{n}",String(pe.length)):X.health&&Vo(X.health)||qi(X)]}),l.jsxs("select",{className:"nc-node-filter",value:W.filter,title:f(`view-${W.filter}`),onClick:me=>me.stopPropagation(),onChange:me=>H(se,{filter:me.target.value}),children:[l.jsx("option",{value:"all",children:f("view-all")}),l.jsx("option",{value:"pinned",children:f("view-pinned")}),l.jsx("option",{value:"active",children:f("view-active")}),l.jsx("option",{value:"off",children:f("view-off")}),l.jsx("option",{value:"technical",children:f("view-technical")})]}),X.direct&&w&&l.jsx("button",{type:"button",className:"nc-node-rename",title:f("rename-node"),"aria-label":`${f("rename-node")} ${X.label||X.name}`,onClick:me=>{me.stopPropagation(),pt(X)},children:"✎"}),X.direct&&X.health&&X.health.managed!==!1&&l.jsx("button",{type:"button",className:`nc-power${X.tunnelStatus==="up"?" on":""}`,title:X.tunnelStatus==="up"?f("power-off"):f("power-on"),onClick:me=>{me.stopPropagation(),p&&p(X)},children:l.jsx(nt,{name:"power",size:14})})]}),X.status==="up"&&W.open&&l.jsxs("div",{className:"nc-side-group",children:[pe.map(me=>me.type==="cell"?(()=>{const Ce=me.value,Ge=!!Ce.tmux,rn=Ce.degraded?"warn":Ce.tmux?"on":"";return l.jsxs("div",{"data-roster-key":me.key,"data-position":se,className:`nc-side-card nc-cell${Ge?" live":""}${dt.has(Ce.key)?" active":""}`,title:me.working?me.subtitle:Ce.tmux?f("cell-idle"):f("cell-off"),draggable:Ge,onDragStart:Ge?tt=>tt.dataTransfer.setData("text/nc-session",Ce.key):void 0,onClick:Ge?()=>a&&a(Ce.key):void 0,onDoubleClick:Ge?()=>gt(Ce.tmuxSession,se,X.instanceId):void 0,children:[l.jsx(ji,{position:se,itemKey:me.key,label:Ce.cell,canMove:Y,onMove:(tt,bn)=>de(se,tt,bn,oe),onStep:tt=>ue(se,me.key,tt,oe)}),l.jsx("span",{className:`nc-dot ${rn}${me.working?" working":""}`}),l.jsxs("span",{className:"nc-card-main",children:[l.jsx("b",{children:Ce.cell}),l.jsx("small",{title:me.subtitle,children:me.subtitle})]}),l.jsx("button",{className:`nc-pin${z.includes(me.key)?" on":""}`,title:f("pin"),onClick:tt=>{tt.stopPropagation(),D(me.key)},children:z.includes(me.key)?"★":"☆"}),h&&(X.capabilities||[]).includes("boot")&&We(Ce,X.route||[]),(X.capabilities||[]).includes(Ce.active?"down":"up")&&l.jsx("button",{className:`nc-power${Ce.active?" on":""}${Ce.degraded?" warn":""}`,onClick:tt=>{tt.stopPropagation(),u&&u({...Ce,boot:le(Ce,X.route||[]),route:X.route,availableEngines:X.engines||[]})},title:Ce.active?f("power-off"):f("power-on"),children:l.jsx(nt,{name:"power",size:14})})]},me.key)})():(()=>{const Ce=me.value;return l.jsxs("div",{"data-roster-key":me.key,"data-position":se,className:`nc-side-card${dt.has(Ce.key)?" active":""}`,draggable:!0,onDragStart:Ge=>Ge.dataTransfer.setData("text/nc-session",Ce.key),onClick:()=>a&&a(Ce.key),onDoubleClick:()=>gt(Ce.name,Ce.node||se,X.instanceId),children:[l.jsx(ji,{position:se,itemKey:me.key,label:Ce.name,canMove:Y,onMove:(Ge,rn)=>de(se,Ge,rn,oe),onStep:Ge=>ue(se,me.key,Ge,oe)}),l.jsx("span",{className:Ce.attached?"nc-dot on":"nc-dot"}),l.jsxs("span",{className:"nc-card-main",children:[l.jsx("b",{children:Ce.name}),l.jsx("small",{children:Ce.preview?Ce.preview:Ce.cmd?Ce.cmd:f("windows").replace("{n}",String(Ce.windows||0))})]}),Ce.activity?l.jsx("span",{className:"nc-rel",children:Or(Ce.activity)}):null,l.jsx("button",{className:`nc-pin${z.includes(me.key)?" on":""}`,title:f("pin"),onClick:Ge=>{Ge.stopPropagation(),D(me.key)},children:z.includes(me.key)?"★":"☆"}),l.jsx("button",{className:`nc-technical${Ce.technical?" on":""}`,title:Ce.technical?f("mark-normal"):f("mark-technical"),"aria-label":`${Ce.technical?f("mark-normal"):f("mark-technical")} ${Ce.name}`,onClick:Ge=>{Ge.stopPropagation(),v&&v(Ce.name,!Ce.technical,X.route||[])},children:"T"}),l.jsx("button",{className:"nc-menu",title:f("terminate"),onClick:Ge=>{Ge.stopPropagation(),window.confirm(f("terminate-confirm").replace("{name}",Ce.name))&&m&&m(Ce.name,X.route)},children:"⋯"})]},me.key)})()),pe.length===0&&l.jsx("div",{className:"nc-empty",children:f("no-sessions-short")})]})]},`nodo-${(X.route||[X.name]).join("/")}`)})]}),l.jsx("div",{className:"nc-side-lang",children:py.map((X,se)=>l.jsxs("span",{children:[se>0&&" · ",l.jsx("button",{className:`nc-lang-btn${B===X?" on":""}`,onClick:()=>A(X),title:X,children:X.toUpperCase()})]},X))}),l.jsx("div",{className:"nc-side-resize",onPointerDown:_t,title:""})]})}function vN({label:e,count:t,state:n,onToggle:s,onFilter:o}){return l.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:s,onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),s())},children:[l.jsx("span",{className:"nc-node-chevron",children:n.open?"⌄":"›"}),l.jsx("span",{className:"nc-dot on"}),l.jsx("b",{children:e}),l.jsxs("small",{children:[" · ",f("node-sessions").replace("{n}",String(t))]}),l.jsxs("select",{className:"nc-node-filter",value:n.filter,title:f(`view-${n.filter}`),onClick:a=>a.stopPropagation(),onChange:a=>o(a.target.value),children:[l.jsx("option",{value:"all",children:f("view-all")}),l.jsx("option",{value:"pinned",children:f("view-pinned")}),l.jsx("option",{value:"active",children:f("view-active")}),l.jsx("option",{value:"off",children:f("view-off")}),l.jsx("option",{value:"technical",children:f("view-technical")})]})]})}function _N(e,t,n){return!e&&t?n+1:n}const Cf="nc_input_preferences_v1",fd="nc-input-preferences",Ow=Object.freeze(["double-tap","single-tap","never"]),Bw=Object.freeze(["full","compact"]),xs=Object.freeze({terminalKeyboardGesture:"double-tap",keybarKeepsKeyboardClosed:!0,voiceKeepsKeyboardClosed:!0,showKeybarEnter:!0,keybarLayout:"full"});function Ef(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{};return{terminalKeyboardGesture:Ow.includes(t.terminalKeyboardGesture)?t.terminalKeyboardGesture:xs.terminalKeyboardGesture,keybarKeepsKeyboardClosed:typeof t.keybarKeepsKeyboardClosed=="boolean"?t.keybarKeepsKeyboardClosed:xs.keybarKeepsKeyboardClosed,voiceKeepsKeyboardClosed:typeof t.voiceKeepsKeyboardClosed=="boolean"?t.voiceKeepsKeyboardClosed:xs.voiceKeepsKeyboardClosed,showKeybarEnter:typeof t.showKeybarEnter=="boolean"?t.showKeybarEnter:xs.showKeybarEnter,keybarLayout:Bw.includes(t.keybarLayout)?t.keybarLayout:xs.keybarLayout}}function zw(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function Kv(e=zw()){if(!e)return{...xs};try{return Ef(JSON.parse(e.getItem(Cf)||"null"))}catch{return{...xs}}}function yN(e,t=zw()){const n=Ef(e);if(t)try{t.setItem(Cf,JSON.stringify(n))}catch{}return n}function Nf(){const[e,t]=E.useState(Kv);E.useEffect(()=>{const s=o=>{if((o==null?void 0:o.type)==="storage"&&o.key!==Cf&&o.key!==null)return;const a=o!=null&&o.detail?Ef(o.detail):Kv();t(a)};return window.addEventListener(fd,s),window.addEventListener("storage",s),()=>{window.removeEventListener(fd,s),window.removeEventListener("storage",s)}},[]);const n=E.useCallback(s=>{t(o=>{const a=yN({...o,...s||{}});return window.dispatchEvent(new CustomEvent(fd,{detail:a})),a})},[]);return[e,n]}function wN({session:e,node:t,ownerId:n,cellName:s,token:o,readonly:a=!1,focused:u,onFocus:h,onClose:p,onOpenSingle:m,alive:v=!0,available:y=!0,fontSize:w=na,onZoom:b,decks:k=[],currentDeck:N,onSendToDeck:S}){const[j]=Nf(),C=s||e,$=E.useRef(()=>{}),O=E.useRef(()=>!1),U=E.useRef(()=>{}),V=E.useRef(!1),[K,Z]=E.useState(!1),[G,Q]=E.useState(!1),[F,B]=E.useState(!1),[A,z]=E.useState(null),[I,D]=E.useState(0),P=E.useRef(v),x=t?`${t}:${e}`:e,M=k.filter(L=>L.id!==N&&L.available!==!1);return E.useEffect(()=>{const L=P.current;!L&&v&&D(T=>_N(L,v,T)),P.current=v},[v]),l.jsxs("div",{className:`nc-tile${u?" focused":""}`,onMouseDown:()=>h&&h(x),children:[l.jsxs("div",{className:"nc-tile-head",draggable:!0,onDragStart:L=>{L.dataTransfer.setData("text/nc-session",x),L.dataTransfer.effectAllowed="move"},children:[l.jsxs("button",{className:"nc-tile-name",onClick:()=>h&&h(x),title:t?`${C} · ${t}`:C,children:[l.jsx("span",{className:v?"nc-dot on":"nc-dot"}),l.jsx("b",{children:C})]}),l.jsxs("span",{className:"nc-tile-actions",children:[b&&l.jsx("button",{onClick:()=>b(-1),title:f("zoom-out"),children:l.jsx(nt,{name:"zoomOut",size:14})}),b&&l.jsx("button",{onClick:()=>b(1),title:f("zoom-in"),children:l.jsx(nt,{name:"zoomIn",size:14})}),S&&M.length>0&&l.jsxs("select",{className:"nc-tile-deck",title:f("send-to-deck"),value:"",onMouseDown:L=>L.stopPropagation(),onChange:L=>{const T=L.target.value;T&&S(x,T),L.target.value=""},children:[l.jsx("option",{value:"",children:f("send-to-deck")}),M.map(L=>l.jsxs("option",{value:L.id,children:[L.ownerLabel," · ",L.name]},L.id))]}),l.jsx("button",{onClick:()=>Q(L=>!L),title:f("composer"),children:"⌨"}),l.jsx("button",{onClick:()=>B(L=>!L),title:f("files"),children:"📁"}),m&&l.jsx("button",{onClick:()=>m({session:e,node:t,ownerId:n}),title:f("single-view"),children:"↗"}),p&&l.jsx("button",{className:"nc-tile-close",onClick:()=>p(x),title:f("close"),children:"✕"})]})]}),l.jsxs("div",{className:"nc-tile-body",children:[y?l.jsx(Ew,{session:e,node:t,token:o,readonly:a,takeSize:!1,focused:u,sendRef:$,composerRef:O,actionRef:U,ctrlRef:V,setCtrlArmed:Z,onFiles:z,fontSize:w,keyboardGesture:j.terminalKeyboardGesture},`${x}:${I}`):l.jsx("div",{className:"nc-tile-unavailable",children:f("deck-owner-unavailable")}),y&&F&&l.jsx("div",{className:"nc-tile-files",onMouseDown:L=>L.stopPropagation(),children:l.jsx(Nw,{session:e,node:t,token:o,filesEvent:A,onClose:()=>B(!1)})})]}),y&&G&&l.jsx("div",{className:"nc-tile-composer",onMouseDown:L=>L.stopPropagation(),children:l.jsx(Iw,{submitText:L=>O.current(L),token:o,session:e,node:t,ownerId:n,keepKeyboardClosedOnVoice:j.voiceKeepsKeyboardClosed})})]})}function bN({session:e,node:t,ownerId:n,cells:s,nodeGroups:o}={}){const a=typeof e=="string"?e:"";if(!a)return null;if(t){const h=Array.isArray(o)?o:[];for(const p of h){if(!p||(Array.isArray(p.route)?p.route:[]).join("/")!==t||n&&p.instanceId&&String(n)!==String(p.instanceId))continue;const v=(Array.isArray(p.cells)?p.cells:[]).find(y=>y&&y.tmuxSession===a);if(v)return v}return null}return(Array.isArray(s)?s:[]).find(h=>h&&h.tmuxSession===a)||null}function jf({session:e,cell:t,node:n,ownerId:s,cells:o,nodeGroups:a}={}){const u=typeof e=="string"?e:"";if(t&&typeof t.cell=="string"&&t.cell)return t.cell;const h=bN({session:u,node:n,ownerId:s,cells:o,nodeGroups:a});return h&&h.cell?h.cell:u}const qv=.2,Vv=.28,$w=(e,t)=>Array.from((e==null?void 0:e.types)||[]).includes(t),pd=e=>$w(e,"text/nc-session"),Yv=e=>{var t;return $w(e,"Files")||(((t=e==null?void 0:e.files)==null?void 0:t.length)||0)>0};function SN(e,t,n){const s=(e-n.left)/(n.width||1),o=(t-n.top)/(n.height||1);return s<Vv?"left":s>1-Vv?"right":o<.5?"top":"bottom"}function xN({layout:e,onLayoutChange:t,token:n,readonly:s=!1,sessionsAlive:o,focusSession:a,onFocus:u,onOpenSingle:h,decks:p=[],currentDeck:m,onSendToDeck:v,cells:y=[],nodeGroups:w=[]}){Dn();const[b,k]=E.useState(null),N=E.useRef(null),S=E.useRef([]),j=E.useRef(null);function C(F,B){const A=()=>{window.removeEventListener("pointermove",F),window.removeEventListener("pointerup",A),window.removeEventListener("pointercancel",A),window.removeEventListener("blur",A),j.current=null};window.addEventListener("pointermove",F),window.addEventListener("pointerup",A),window.addEventListener("pointercancel",A),window.addEventListener("blur",A),j.current=A}E.useEffect(()=>()=>{j.current&&j.current()},[]),E.useEffect(()=>{const F=()=>k(null);return window.addEventListener("dragend",F),window.addEventListener("drop",F),()=>{window.removeEventListener("dragend",F),window.removeEventListener("drop",F)}},[]);const $=e.columns.length,O=F=>b&&b.col===F&&b.row===void 0,U=!!b&&b.col===$,V=(F,B)=>b&&b.col===F&&b.row===B&&b.quadrant?` drop-${b.quadrant}`:"";function K(F){if(F.preventDefault(),Yv(F.dataTransfer)){k(null);return}const B=F.dataTransfer.getData("text/nc-session"),A=b;if(k(null),!B||!A)return;let z;if(A.quadrant){if(z=Xx(e,A.col,A.row,A.quadrant),!z)return}else z={col:A.col};t(Ai(e).includes(B)?Kx(e,B,z):hf(e,B,z))}function Z(F,B){F.preventDefault(),F.stopPropagation();const A=F.clientX,z=e.columns[B].width,I=N.current&&N.current.clientWidth||1,D=e.columns[B+1];C(x=>{let M=Math.max(qv,z+(x.clientX-A)/I);if(D){const L=zg(M/(M+D.width));M=L/(1-L)*D.width}t(Vx(e,B,M))})}function G(F,B,A){F.preventDefault(),F.stopPropagation();const z=F.clientY,I=e.columns[B].tiles[A].height,D=S.current[B],P=D&&D.clientHeight||1,x=e.columns[B].tiles[A+1];C(L=>{let T=Math.max(qv,I+(L.clientY-z)/P);if(x){const H=zg(T/(T+x.height));T=H/(1-H)*x.height}t(Yx(e,B,A,T))})}function Q(F){t(Hl(e,F))}return l.jsxs("div",{className:"nc-grid",ref:N,onDragOver:F=>{if(Yv(F.dataTransfer)){F.preventDefault(),k(null);return}pd(F.dataTransfer)&&(F.preventDefault(),b&&b.col===$||k({col:$}))},onDrop:K,onDragLeave:F=>{const B=F.relatedTarget;(!B||!(N.current&&N.current.contains(B)))&&k(null)},children:[e.columns.flatMap((F,B)=>{const A=[];return A.push(l.jsx("div",{className:`nc-col${O(B)?" drop-newcol":""}`,ref:z=>{S.current[B]=z},style:{flexGrow:F.width,flexBasis:0},onDragOver:z=>{pd(z.dataTransfer)&&(z.preventDefault(),z.stopPropagation(),b&&b.col===B&&b.row===void 0||k({col:B}))},children:F.tiles.flatMap((z,I)=>{const D=[],P=Zn(z),x=jf({session:z.session,node:z.node,ownerId:z.ownerId,cells:y,nodeGroups:w});return D.push(l.jsx("div",{className:`nc-tile-slot${V(B,I)}`,style:{flexGrow:z.height,flexBasis:0},onDragOver:M=>{if(!pd(M.dataTransfer))return;M.preventDefault(),M.stopPropagation();const L=SN(M.clientX,M.clientY,M.currentTarget.getBoundingClientRect());b&&b.col===B&&b.row===I&&b.quadrant===L||k({col:B,row:I,quadrant:L})},children:l.jsx(wN,{session:z.session,node:z.node,ownerId:z.ownerId,cellName:x,token:n,readonly:s,focused:a===P,onFocus:u,onClose:Q,onOpenSingle:h,available:z.unavailable!==!0,alive:z.unavailable!==!0&&(!o||o.has(P)),fontSize:z.fontSize,onZoom:M=>t(Gx(e,B,I,M)),decks:p,currentDeck:m,onSendToDeck:v})},P)),I<F.tiles.length-1&&D.push(l.jsx("div",{className:"nc-divider-h",onPointerDown:M=>G(M,B,I)},`h${I}`)),D})},`c${B}`)),B<$-1&&A.push(l.jsx("div",{className:"nc-divider-v",onPointerDown:z=>Z(z,B)},`v${B}`)),A}),U&&l.jsx("div",{className:"nc-drop-line-v nc-drop-line-end"}),$===0&&l.jsx("div",{className:"nc-grid-empty",children:f("grid-empty")})]})}const Ri="local",ei=/^[a-f0-9]{16,64}$/;function Dr(e,t){return`${e&&ei.test(e)?e:Ri}:${t}`}function rc(e){const t=String(e||""),n=t.indexOf(":");if(n<1)return null;const s=t.slice(0,n),o=t.slice(n+1);return s!==Ri&&!ei.test(s)||!/^[a-z0-9-]{1,32}$/.test(o)?null:{ownerId:s===Ri?null:s,name:o}}function oc(e){return Array.isArray(e)&&e.length?e.join("/"):""}function Rf(e){return{columns:Qs(e).columns.map(t=>({width:t.width,tiles:t.tiles.map(n=>({...n}))}))}}function kN(e){const t=new Map;for(const n of Array.isArray(e)?e:[])n&&ei.test(String(n.instanceId||""))&&Array.isArray(n.route)&&t.set(oc(n.route),n.instanceId);return t}function CN(e){const t=new Map;for(const n of Array.isArray(e)?e:[])n&&ei.test(String(n.instanceId||""))&&Array.isArray(n.route)&&t.set(n.instanceId,[...n.route]);return t}function zh(e,t,n=[]){const s=Rf(e),o=kN(n);for(const a of s.columns)for(const u of a.tiles)u.ownerId||(!u.node&&ei.test(String(t||""))?u.ownerId=t:u.node&&o.has(u.node)&&(u.ownerId=o.get(u.node)));return s}function $h(e,t,n=[]){const s=Rf(e),o=new Map;for(const a of n)a&&ei.test(String(a.instanceId||""))&&Array.isArray(a.route)&&o.set(a.instanceId,[...a.route]);for(const a of s.columns)for(const u of a.tiles)u.ownerId&&(u.ownerId===t?(delete u.node,delete u.unavailable):o.has(u.ownerId)?(u.node=oc(o.get(u.ownerId)),delete u.unavailable):u.unavailable=!0);return s}function Gv(e,t,n=[]){const s=Rf(e),o=CN(n);for(const a of s.columns)for(const u of a.tiles)delete u.unavailable,u.ownerId&&(u.ownerId===t?delete u.node:o.has(u.ownerId)&&(u.node=oc(o.get(u.ownerId))));return s}function Fw(e,t,n=[]){const s=js(e);if(!s)return null;if(s.ownerId)return s;if(!s.node)return{...s,...ei.test(String(t||""))?{ownerId:t}:{}};const o=n.find(a=>oc(a&&a.route)===s.node);return{...s,...o&&ei.test(String(o.instanceId||""))?{ownerId:o.instanceId}:{}}}const EN=/^[a-z0-9-]{1,32}$/,ti="main",Hw="nc_decks",Uw="nc_deck_order_v1",Ww=24;function Xv(e){return typeof e!="string"?"":e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,32).replace(/-+$/,"")}function Fr(e){return typeof e=="string"&&EN.test(e)}function NN(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/?$/);if(t){let n;try{n=decodeURIComponent(t[1])}catch{n=t[1]}return Fr(n)?n:ti}return ti}function jN(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/([^/]+)\/?$/);if(t){let s,o;try{s=decodeURIComponent(t[1]),o=decodeURIComponent(t[2])}catch{return{id:Dr(null,ti),ownerId:null,name:ti}}if(ei.test(s)&&Fr(o))return{id:Dr(s,o),ownerId:s,name:o}}const n=NN(e);return{id:Dr(null,n),ownerId:null,name:n}}function md(e,t){const n=typeof e=="object"&&e?{ownerId:e.ownerId||null,name:e.name}:rc(e)||{ownerId:null,name:e},s=Fr(n.name)?n.name:ti,o=n.ownerId?`/deck/${encodeURIComponent(n.ownerId)}/${encodeURIComponent(s)}`:s===ti?"/":`/deck/${encodeURIComponent(s)}`;return t?`${o}#token=${encodeURIComponent(t)}`:o}function Kw(e){return e===ti?"nc_grid_v1":`nc_grid_v1__${e}`}function qw(e){const t=[ti];if(Array.isArray(e)){for(const n of e)if(Fr(n)&&n!==ti&&!t.includes(n)&&t.push(n),t.length>=Ww)break}return t}function qr(){return typeof localStorage<"u"?localStorage:null}function RN(){const e=qr();if(!e)return[ti];try{return qw(JSON.parse(e.getItem(Hw)||"null"))}catch{return[ti]}}function PN(e){const t=qr();if(t)try{t.setItem(Hw,JSON.stringify(qw(e)))}catch{}}function la(e){return e==="local"||ei.test(String(e||""))}function ac(e,t){const n=rc(e);return!!n&&(n.ownerId||"local")===t}function Ti(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,s]of Object.entries(e).slice(0,64)){if(!la(n)||!Array.isArray(s))continue;const o=[...new Set(s.filter(a=>typeof a=="string"&&a.length<=100&&ac(a,n)))].slice(0,Ww);o.length&&(t[n]=o)}return t}function xl(e=qr()){if(!e)return{};try{return Ti(JSON.parse(e.getItem(Uw)||"null"))}catch{return{}}}function gd(e,t=qr()){const n=Ti(e);if(t)try{t.setItem(Uw,JSON.stringify(n))}catch{}return n}function lc(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function AN(e,t,n,s,o=[]){if(!la(t)||n===s)return Ti(e);const a=[...new Set(o.filter(y=>ac(y,t)))];if(!a.includes(n)||!a.includes(s))return Ti(e);const u=lc(e,t).filter(y=>a.includes(y)),h=[...u,...a.filter(y=>!u.includes(y))],p=h.indexOf(n),m=h.indexOf(s);h.splice(p,1);const v=h.indexOf(s);return h.splice(p<m?v+1:v,0,n),Ti({...e,[t]:h})}function LN(e,t,n,s){if(!la(t)||!ac(s,t))return Ti(e);const o=lc(e,t);return o.includes(n)?Ti({...e,[t]:o.map(a=>a===n?s:a)}):Ti(e)}function TN(e,t,n){return la(t)?Ti({...e,[t]:lc(e,t).filter(s=>s!==n)}):Ti(e)}function Qv(e,t={}){const n=new Map;for(const o of Array.isArray(e)?e:[]){const a=o!=null&&o.local?"local":String((o==null?void 0:o.ownerId)||"");!la(a)||!ac(o==null?void 0:o.id,a)||(n.has(a)||n.set(a,[]),n.get(a).push(o))}const s=[];for(const[,o]of n){const a=o[0].local?"local":o[0].ownerId,u=lc(t,a),h=new Map(u.map((p,m)=>[p,m]));o.sort((p,m)=>{const v=h.has(p.id)?h.get(p.id):Number.MAX_SAFE_INTEGER,y=h.has(m.id)?h.get(m.id):Number.MAX_SAFE_INTEGER;return v-y}),s.push(...o)}return s}function Fh(e){const t=qr();if(!t)return null;try{return JSON.parse(t.getItem(Kw(e))||"null")}catch{return null}}function MN(e,t){const n=qr();if(n)try{n.setItem(Kw(e),JSON.stringify(t))}catch{}}const Pf="nc_deckbar_collapsed_v1",Vw=64;function Af(e){return e===Ri||ei.test(String(e||""))}function Lf(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};let n=0;for(const[s,o]of Object.entries(e)){if(n>=Vw)break;if(Af(s)){if(o===!0)t[s]=!0;else if(o===!1)t[s]=!1;else continue;n+=1}}return t}function Yw(e,t){return Af(t)&&Object.prototype.hasOwnProperty.call(e||{},t)?e[t]===!0:!0}function DN(e,t){const n=Lf(e);return Af(t)&&(!Object.prototype.hasOwnProperty.call(n,t)&&Object.keys(n).length>=Vw&&delete n[Object.keys(n)[0]],n[t]=!Yw(n,t)),n}function Gw(){return typeof localStorage<"u"?localStorage:null}function Jv(e=Gw()){if(!e)return{};try{return Lf(JSON.parse(e.getItem(Pf)||"null"))}catch{return{}}}function IN(e,t=Gw()){const n=Lf(e);if(t)try{t.setItem(Pf,JSON.stringify(n))}catch{}return n}function ON(){const[e,t]=E.useState(Jv);E.useEffect(()=>{const o=a=>{(a.key===Pf||a.key===null)&&t(Jv())};return window.addEventListener("storage",o),()=>window.removeEventListener("storage",o)},[]);const n=E.useCallback(o=>Yw(e,o),[e]),s=E.useCallback(o=>{t(a=>IN(DN(a,o)))},[]);return{collapsed:e,isCollapsed:n,toggle:s}}const Tf="nc_deck_presence_v1",Zv=3e4,BN=18e4,Xw=1e4,Qw=32,zN=/^[A-Za-z0-9_-]{1,64}$/,$N=new Set([...Object.getOwnPropertyNames(Object.prototype),"prototype"]),e_="working",FN="on",HN="neutral",UN="warn";function Mf(e){return typeof e=="string"&&zN.test(e)&&!$N.has(e)}function Jw(e){return typeof e=="string"&&rc(e)!==null}function Df(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function Hr(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};let n=0;for(const[s,o]of Object.entries(e)){if(n>=Qw)break;Mf(s)&&(!o||typeof o!="object"||Jw(o.deckId)&&Df(o.ts)&&(t[s]={deckId:o.deckId,ts:o.ts,focus:o.focus===!0,visible:o.visible===!0},n+=1))}return t}function Zw(e,t){const n=Hr(e);if(!Df(t))return n;const s={};for(const[o,a]of Object.entries(n)){const u=a.visible?Zv:BN,h=t-u;a.ts>=h&&a.ts<=t+Zv&&(s[o]=a)}return s}function t_(e,t,n,s){if(!Mf(t)||!Df(s))return Hr(e);const o=Zw(e,s);if(!Jw(n==null?void 0:n.deckId))return o;if(!Object.prototype.hasOwnProperty.call(o,t)&&Object.keys(o).length>=Qw){let a="",u=1/0;for(const[h,p]of Object.entries(o))p.ts<u&&(a=h,u=p.ts);a&&delete o[a]}return o[t]={deckId:n.deckId,ts:s,focus:(n==null?void 0:n.focus)===!0,visible:(n==null?void 0:n.visible)===!0},Hr(o)}function WN(e,t){const n=Hr(e);if(!Mf(t))return n;const s={...n};return delete s[t],s}function KN(e,t){const n=Zw(e,t),s={};for(const o of Object.values(n)){const a=o.focus&&o.visible?e_:FN;s[o.deckId]!==e_&&(s[o.deckId]=a)}return s}function eb(){return typeof localStorage<"u"?localStorage:null}function kl(e=eb()){if(!e)return{};try{return Hr(JSON.parse(e.getItem(Tf)||"null"))}catch{return{}}}function vd(e,t=eb()){const n=Hr(e);if(t)try{t.setItem(Tf,JSON.stringify(n))}catch{}return n}const qN=Math.min(Xw,5e3);function VN(){var e,t;try{const n=(t=(e=globalThis.crypto)==null?void 0:e.randomUUID)==null?void 0:t.call(e);if(n)return`w${n.replaceAll("-","")}`}catch{}return`w${Date.now().toString(36)}${Math.random().toString(36).slice(2,14)}`}const YN=VN();function n_(){const e=typeof document<"u"&&typeof document.hasFocus=="function"?document.hasFocus():!0,t=typeof document<"u"&&typeof document.visibilityState=="string"?document.visibilityState!=="hidden":!0;return{focus:e,visible:t}}function GN(e,t=!0){const s=E.useRef(YN).current,o=E.useRef(e);o.current=e;const[a,u]=E.useState(()=>({map:{},now:Date.now()})),h=E.useCallback(()=>{u({map:kl(),now:Date.now()})},[]);E.useEffect(()=>{if(!t)return;const v=()=>{const S=Date.now(),j=t_(kl(),s,{deckId:o.current,...n_()},S);return vd(j),{map:j,now:S}},y=()=>u(v());y();const w=setInterval(v,Xw),b=setInterval(h,qN),k=y,N=S=>{(S.key===Tf||S.key===null)&&h()};return window.addEventListener("focus",k),window.addEventListener("blur",k),typeof document<"u"&&document.addEventListener("visibilitychange",k),window.addEventListener("storage",N),()=>{clearInterval(w),clearInterval(b),window.removeEventListener("focus",k),window.removeEventListener("blur",k),typeof document<"u"&&document.removeEventListener("visibilitychange",k),window.removeEventListener("storage",N);try{vd(WN(kl(),s))}catch{}}},[t,s,h]),E.useEffect(()=>{if(!t)return;const v=Date.now(),y=t_(kl(),s,{deckId:e,...n_()},v);vd(y),u({map:y,now:v})},[e,t,s]);const p=E.useMemo(()=>t?KN(a.map,a.now):{},[t,a]);return{dotFor:E.useCallback((v,y=!1)=>t?y?UN:p[v]||HN:null,[p,t]),windowId:s}}const i_=52,s_=18;function XN({ownerKey:e,deckId:t,label:n,onMove:s,onStep:o}){const a=E.useRef(null),u=E.useRef(0),[h,p]=E.useState(!1),m=()=>{var N,S,j,C;const k=a.current;(S=(N=k==null?void 0:k.over)==null?void 0:N.classList)==null||S.remove("nc-deck-over"),(C=(j=k==null?void 0:k.source)==null?void 0:j.classList)==null||C.remove("nc-deck-dragging"),u.current&&cancelAnimationFrame(u.current),u.current=0},v=(k=!1)=>{const N=a.current;if(!N)return;const S=N.target;m(),a.current=null,p(!1);try{N.handle.releasePointerCapture(N.pointerId)}catch{}k&&S&&S!==t&&s(t,S)},y=(k,N)=>{var O,U,V,K,Z,G,Q,F;const S=a.current;if(!S)return;S.x=k,S.y=N;const j=(U=(O=document.elementFromPoint(k,N))==null?void 0:O.closest)==null?void 0:U.call(O,"[data-deck-id][data-owner-key]"),C=(V=j==null?void 0:j.dataset)==null?void 0:V.deckId,$=((K=j==null?void 0:j.dataset)==null?void 0:K.ownerKey)===e&&C&&C!==t;S.over!==($?j:null)&&((G=(Z=S.over)==null?void 0:Z.classList)==null||G.remove("nc-deck-over"),S.over=$?j:null,(F=(Q=S.over)==null?void 0:Q.classList)==null||F.add("nc-deck-over")),S.target=$?C:null},w=()=>{var S,j;const k=a.current;if(!k){u.current=0;return}const N=(j=(S=k.container)==null?void 0:S.getBoundingClientRect)==null?void 0:j.call(S);if(N){const C=k.x<N.left+i_?-s_:k.x>N.right-i_?s_:0;C&&(k.container.scrollLeft+=C,y(k.x,k.y))}u.current=requestAnimationFrame(w)};E.useEffect(()=>{const k=S=>{S.key==="Escape"&&a.current&&(S.preventDefault(),v(!1))},N=()=>v(!1);return window.addEventListener("keydown",k),window.addEventListener("blur",N),()=>{window.removeEventListener("keydown",k),window.removeEventListener("blur",N),m(),a.current=null}},[t,e]);const b=k=>{var j;if(k.pointerType==="mouse"&&k.button!==0)return;k.preventDefault(),k.stopPropagation(),k.currentTarget.focus({preventScroll:!0});const N=k.currentTarget.closest("[data-deck-id][data-owner-key]"),S=k.currentTarget.closest(".nc-deckbar");a.current={pointerId:k.pointerId,handle:k.currentTarget,source:N,container:S,target:null,over:null,x:k.clientX,y:k.clientY},(j=N==null?void 0:N.classList)==null||j.add("nc-deck-dragging");try{k.currentTarget.setPointerCapture(k.pointerId)}catch{}p(!0),u.current=requestAnimationFrame(w)};return l.jsx("button",{type:"button",className:`nc-deck-handle${h?" active":""}`,"aria-label":`${f("reorder")} ${n}`,"aria-keyshortcuts":"ArrowLeft ArrowRight",title:f("reorder-deck-help"),onClick:k=>{k.preventDefault(),k.stopPropagation()},onDragStart:k=>k.preventDefault(),onKeyDown:k=>{k.key!=="ArrowLeft"&&k.key!=="ArrowRight"||(k.preventDefault(),k.stopPropagation(),o(k.key==="ArrowLeft"?-1:1))},onPointerDown:b,onPointerMove:k=>{!a.current||k.pointerId!==a.current.pointerId||(k.preventDefault(),k.stopPropagation(),y(k.clientX,k.clientY))},onPointerUp:k=>{!a.current||k.pointerId!==a.current.pointerId||(k.preventDefault(),k.stopPropagation(),v(!0))},onPointerCancel:()=>v(!1),onLostPointerCapture:()=>{a.current&&v(!1)},children:"↔"})}function QN({decks:e=[],currentDeck:t="local:main",onCreate:n,onRename:s,onDelete:o,onReorder:a,onOpenWindow:u,onNavigate:h,saveState:p="idle",error:m="",sidebarVisible:v,onToggleSidebar:y}){Dn();const{isCollapsed:w,toggle:b}=ON(),{dotFor:k}=GN(t),[N,S]=E.useState(null),[j,C]=E.useState(""),[$,O]=E.useState(!1),[U,V]=E.useState(""),[K,Z]=E.useState(""),G=Xv(j),Q=Fr(G),F=[];for(const D of e){const P=D.local?"local":D.ownerId;let x=F.find(M=>M.key===P);x||(x={key:P,label:D.ownerLabel||(D.local?"Local":P),local:!!D.local,decks:[]},F.push(x)),x.decks.push(D)}const B=async()=>{if(Q){O(!0),V("");try{n&&await n(G,N),C(""),S(null)}catch(D){V(String(D.message||D))}O(!1)}},A=D=>{Z(""),u&&u(D.id)||Z(D.id)},z=async D=>{if(!(D.id===t||!h||$||D.available===!1)){O(!0),V("");try{await h(D.id)}catch(P){V(String((P==null?void 0:P.message)||P))}O(!1)}},I=(D,P,x)=>{const M=D.decks.findIndex(T=>T.id===P.id),L=D.decks[M+x];M>=0&&L&&a&&!$&&a(P.id,L.id)};return l.jsxs("div",{className:"nc-deckbar",children:[y&&l.jsx("button",{className:"nc-deck-sidebar-toggle",title:f("toggle-sidebar"),onClick:y,children:v?"◀":"☰"}),l.jsx("span",{className:"nc-deckbar-label",children:f("decks")}),l.jsx("div",{className:"nc-deck-chips",children:F.map(D=>{const P=w(D.key),x=`nc-deck-content-${D.key}`,M=D.local?"Local":D.label,L=D.decks.some(Y=>Y.id===t),T=(D.decks.find(Y=>Y.id===t)||{}).name,H=f(D.decks.length===1?"owner-deck-count-one":"owner-deck-count-many").replace("{count}",D.decks.length);return l.jsxs("span",{className:`nc-deck-owner-group${P?" collapsed":""}`,"data-owner-key":D.key,"data-collapsed":P?"1":"0",children:[l.jsxs("button",{type:"button",className:"nc-deck-owner-toggle","aria-expanded":!P,"aria-controls":x,title:f(P?"expand-owner":"collapse-owner").replace("{owner}",M),onClick:()=>{!P&&N===D.key&&(C(""),S(null)),b(D.key)},children:[l.jsx("span",{className:"nc-deck-owner-caret","aria-hidden":"true",children:P?"▸":"▾"}),l.jsx("span",{className:"nc-deck-owner",children:M})]}),P&&l.jsxs("span",{className:"nc-deck-summary",title:H,children:[l.jsx("span",{className:"nc-deck-summary-count",children:D.decks.length}),L&&l.jsxs("span",{className:"nc-deck-summary-current",children:["• ",T]})]}),l.jsxs("span",{id:x,className:"nc-deck-owner-content",hidden:P,children:[D.decks.map(Y=>{const de=k(Y.id,Y.available===!1);return l.jsxs("span",{"data-deck-id":Y.id,"data-owner-key":D.key,className:`nc-deck-chip${Y.id===t?" current":""}${Y.available===!1?" offline":""}`,children:[de&&l.jsx(JN,{state:de}),l.jsx(XN,{ownerKey:D.key,deckId:Y.id,label:`${D.label} · ${Y.name}`,onMove:(ue,fe)=>{a&&!$&&a(ue,fe)},onStep:ue=>I(D,Y,ue)}),l.jsxs("button",{className:"nc-deck-open",title:Y.available===!1?`${Y.ownerLabel} offline`:Y.id===t?f("deck-current"):`${Y.ownerLabel} · ${Y.name}`,disabled:$||Y.available===!1,onClick:()=>z(Y),children:[Y.name,Y.id===t?" •":""]}),l.jsx("button",{className:"nc-deck-mini",disabled:Y.available===!1,title:f("detach-deck"),onClick:()=>A(Y),children:"↗"}),Y.name!==ti&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"nc-deck-mini",disabled:Y.available===!1,title:f("rename-deck"),onClick:()=>{const ue=(typeof window<"u"?window.prompt(f("rename-deck"),Y.name):"")||"",fe=Xv(ue);Fr(fe)&&fe!==Y.name&&s&&s(Y.id,fe).catch(ve=>V(String(ve.message||ve)))},children:"✎"}),l.jsx("button",{className:"nc-deck-mini nc-deck-del",disabled:Y.available===!1,title:f("delete-deck"),onClick:()=>{(typeof window>"u"||window.confirm(f("delete-deck-confirm").replace("{name}",`${Y.ownerLabel} · ${Y.name}`)))&&o&&o(Y.id).catch(ue=>V(String(ue.message||ue)))},children:"✕"})]})]},Y.id)}),N===D.key?l.jsxs("span",{className:"nc-deck-add",children:[l.jsx("input",{autoFocus:!0,className:Q||!j?"":"invalid",placeholder:f("deck-name"),value:j,onChange:Y=>C(Y.target.value),onKeyDown:Y=>{Y.key==="Enter"&&B(),Y.key==="Escape"&&(C(""),S(null))}}),j&&Q&&G!==j&&l.jsxs("span",{className:"nc-deck-slug",children:["→ ",G]}),l.jsx("button",{className:"nc-deck-ok",disabled:!Q||$,onClick:B,children:f("create")}),l.jsx("button",{className:"nc-deck-cancel",onClick:()=>{C(""),S(null)},children:f("cancel")})]}):l.jsxs("button",{className:"nc-deck-newbtn",disabled:$||D.decks.every(Y=>Y.available===!1),title:`${f("new-deck")} · ${D.label}`,onClick:()=>{C(""),S(D.key)},children:["+ ",f("new")]})]})]},D.key)})}),l.jsx("span",{className:`nc-deck-state ${p}`,title:f("deck-autosave"),children:f(p==="saving"?"saving":p==="saved"?"saved":"deck-autosave")}),(U||m)&&l.jsx("span",{className:"nc-deck-error",children:U||m}),K&&l.jsx("button",{className:"nc-deck-fallback",onClick:()=>u&&u(K),children:f("popup-blocked")})]})}function JN({state:e}){if(!e)return null;const t=f(`dot-${e}`);return l.jsx("span",{className:`nc-deck-dot ${e}`,role:"img","aria-label":t,title:t})}var Ar={},_d,r_;function ZN(){return r_||(r_=1,_d=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),_d}var yd={},ws={},o_;function nr(){if(o_)return ws;o_=1;let e;const t=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return ws.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},ws.getSymbolTotalCodewords=function(s){return t[s]},ws.getBCHDigit=function(n){let s=0;for(;n!==0;)s++,n>>>=1;return s},ws.setToSJISFunction=function(s){if(typeof s!="function")throw new Error('"toSJISFunc" is not a valid function.');e=s},ws.isKanjiModeEnabled=function(){return typeof e<"u"},ws.toSJIS=function(s){return e(s)},ws}var wd={},a_;function If(){return a_||(a_=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+n)}}e.isValid=function(s){return s&&typeof s.bit<"u"&&s.bit>=0&&s.bit<4},e.from=function(s,o){if(e.isValid(s))return s;try{return t(s)}catch{return o}}})(wd)),wd}var bd,l_;function e2(){if(l_)return bd;l_=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(t){const n=Math.floor(t/8);return(this.buffer[n]>>>7-t%8&1)===1},put:function(t,n){for(let s=0;s<n;s++)this.putBit((t>>>n-s-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},bd=e,bd}var Sd,c_;function t2(){if(c_)return Sd;c_=1;function e(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return e.prototype.set=function(t,n,s,o){const a=t*this.size+n;this.data[a]=s,o&&(this.reservedBit[a]=!0)},e.prototype.get=function(t,n){return this.data[t*this.size+n]},e.prototype.xor=function(t,n,s){this.data[t*this.size+n]^=s},e.prototype.isReserved=function(t,n){return this.reservedBit[t*this.size+n]},Sd=e,Sd}var xd={},u_;function n2(){return u_||(u_=1,(function(e){const t=nr().getSymbolSize;e.getRowColCoords=function(s){if(s===1)return[];const o=Math.floor(s/7)+2,a=t(s),u=a===145?26:Math.ceil((a-13)/(2*o-2))*2,h=[a-7];for(let p=1;p<o-1;p++)h[p]=h[p-1]-u;return h.push(6),h.reverse()},e.getPositions=function(s){const o=[],a=e.getRowColCoords(s),u=a.length;for(let h=0;h<u;h++)for(let p=0;p<u;p++)h===0&&p===0||h===0&&p===u-1||h===u-1&&p===0||o.push([a[h],a[p]]);return o}})(xd)),xd}var kd={},d_;function i2(){if(d_)return kd;d_=1;const e=nr().getSymbolSize,t=7;return kd.getPositions=function(s){const o=e(s);return[[0,0],[o-t,0],[0,o-t]]},kd}var Cd={},h_;function s2(){return h_||(h_=1,(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(o){return o!=null&&o!==""&&!isNaN(o)&&o>=0&&o<=7},e.from=function(o){return e.isValid(o)?parseInt(o,10):void 0},e.getPenaltyN1=function(o){const a=o.size;let u=0,h=0,p=0,m=null,v=null;for(let y=0;y<a;y++){h=p=0,m=v=null;for(let w=0;w<a;w++){let b=o.get(y,w);b===m?h++:(h>=5&&(u+=t.N1+(h-5)),m=b,h=1),b=o.get(w,y),b===v?p++:(p>=5&&(u+=t.N1+(p-5)),v=b,p=1)}h>=5&&(u+=t.N1+(h-5)),p>=5&&(u+=t.N1+(p-5))}return u},e.getPenaltyN2=function(o){const a=o.size;let u=0;for(let h=0;h<a-1;h++)for(let p=0;p<a-1;p++){const m=o.get(h,p)+o.get(h,p+1)+o.get(h+1,p)+o.get(h+1,p+1);(m===4||m===0)&&u++}return u*t.N2},e.getPenaltyN3=function(o){const a=o.size;let u=0,h=0,p=0;for(let m=0;m<a;m++){h=p=0;for(let v=0;v<a;v++)h=h<<1&2047|o.get(m,v),v>=10&&(h===1488||h===93)&&u++,p=p<<1&2047|o.get(v,m),v>=10&&(p===1488||p===93)&&u++}return u*t.N3},e.getPenaltyN4=function(o){let a=0;const u=o.data.length;for(let p=0;p<u;p++)a+=o.data[p];return Math.abs(Math.ceil(a*100/u/5)-10)*t.N4};function n(s,o,a){switch(s){case e.Patterns.PATTERN000:return(o+a)%2===0;case e.Patterns.PATTERN001:return o%2===0;case e.Patterns.PATTERN010:return a%3===0;case e.Patterns.PATTERN011:return(o+a)%3===0;case e.Patterns.PATTERN100:return(Math.floor(o/2)+Math.floor(a/3))%2===0;case e.Patterns.PATTERN101:return o*a%2+o*a%3===0;case e.Patterns.PATTERN110:return(o*a%2+o*a%3)%2===0;case e.Patterns.PATTERN111:return(o*a%3+(o+a)%2)%2===0;default:throw new Error("bad maskPattern:"+s)}}e.applyMask=function(o,a){const u=a.size;for(let h=0;h<u;h++)for(let p=0;p<u;p++)a.isReserved(p,h)||a.xor(p,h,n(o,p,h))},e.getBestMask=function(o,a){const u=Object.keys(e.Patterns).length;let h=0,p=1/0;for(let m=0;m<u;m++){a(m),e.applyMask(m,o);const v=e.getPenaltyN1(o)+e.getPenaltyN2(o)+e.getPenaltyN3(o)+e.getPenaltyN4(o);e.applyMask(m,o),v<p&&(p=v,h=m)}return h}})(Cd)),Cd}var Cl={},f_;function tb(){if(f_)return Cl;f_=1;const e=If(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],n=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return Cl.getBlocksCount=function(o,a){switch(a){case e.L:return t[(o-1)*4+0];case e.M:return t[(o-1)*4+1];case e.Q:return t[(o-1)*4+2];case e.H:return t[(o-1)*4+3];default:return}},Cl.getTotalCodewordsCount=function(o,a){switch(a){case e.L:return n[(o-1)*4+0];case e.M:return n[(o-1)*4+1];case e.Q:return n[(o-1)*4+2];case e.H:return n[(o-1)*4+3];default:return}},Cl}var Ed={},zo={},p_;function r2(){if(p_)return zo;p_=1;const e=new Uint8Array(512),t=new Uint8Array(256);return(function(){let s=1;for(let o=0;o<255;o++)e[o]=s,t[s]=o,s<<=1,s&256&&(s^=285);for(let o=255;o<512;o++)e[o]=e[o-255]})(),zo.log=function(s){if(s<1)throw new Error("log("+s+")");return t[s]},zo.exp=function(s){return e[s]},zo.mul=function(s,o){return s===0||o===0?0:e[t[s]+t[o]]},zo}var m_;function o2(){return m_||(m_=1,(function(e){const t=r2();e.mul=function(s,o){const a=new Uint8Array(s.length+o.length-1);for(let u=0;u<s.length;u++)for(let h=0;h<o.length;h++)a[u+h]^=t.mul(s[u],o[h]);return a},e.mod=function(s,o){let a=new Uint8Array(s);for(;a.length-o.length>=0;){const u=a[0];for(let p=0;p<o.length;p++)a[p]^=t.mul(o[p],u);let h=0;for(;h<a.length&&a[h]===0;)h++;a=a.slice(h)}return a},e.generateECPolynomial=function(s){let o=new Uint8Array([1]);for(let a=0;a<s;a++)o=e.mul(o,new Uint8Array([1,t.exp(a)]));return o}})(Ed)),Ed}var Nd,g_;function a2(){if(g_)return Nd;g_=1;const e=o2();function t(n){this.genPoly=void 0,this.degree=n,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(s){this.degree=s,this.genPoly=e.generateECPolynomial(this.degree)},t.prototype.encode=function(s){if(!this.genPoly)throw new Error("Encoder not initialized");const o=new Uint8Array(s.length+this.degree);o.set(s);const a=e.mod(o,this.genPoly),u=this.degree-a.length;if(u>0){const h=new Uint8Array(this.degree);return h.set(a,u),h}return a},Nd=t,Nd}var jd={},Rd={},Pd={},v_;function nb(){return v_||(v_=1,Pd.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),Pd}var Ci={},__;function ib(){if(__)return Ci;__=1;const e="[0-9]+",t="[A-Z $%*+\\-./:]+";let n="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";n=n.replace(/u/g,"\\u");const s="(?:(?![A-Z0-9 $%*+\\-./:]|"+n+`)(?:.|[\r
|
|
82
|
-
]))+`;Ci.KANJI=new RegExp(n,"g"),Ci.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Ci.BYTE=new RegExp(s,"g"),Ci.NUMERIC=new RegExp(e,"g"),Ci.ALPHANUMERIC=new RegExp(t,"g");const o=new RegExp("^"+n+"$"),a=new RegExp("^"+e+"$"),u=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Ci.testKanji=function(p){return o.test(p)},Ci.testNumeric=function(p){return a.test(p)},Ci.testAlphanumeric=function(p){return u.test(p)},Ci}var y_;function ir(){return y_||(y_=1,(function(e){const t=nb(),n=ib();e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(a,u){if(!a.ccBits)throw new Error("Invalid mode: "+a);if(!t.isValid(u))throw new Error("Invalid version: "+u);return u>=1&&u<10?a.ccBits[0]:u<27?a.ccBits[1]:a.ccBits[2]},e.getBestModeForData=function(a){return n.testNumeric(a)?e.NUMERIC:n.testAlphanumeric(a)?e.ALPHANUMERIC:n.testKanji(a)?e.KANJI:e.BYTE},e.toString=function(a){if(a&&a.id)return a.id;throw new Error("Invalid mode")},e.isValid=function(a){return a&&a.bit&&a.ccBits};function s(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+o)}}e.from=function(a,u){if(e.isValid(a))return a;try{return s(a)}catch{return u}}})(Rd)),Rd}var w_;function l2(){return w_||(w_=1,(function(e){const t=nr(),n=tb(),s=If(),o=ir(),a=nb(),u=7973,h=t.getBCHDigit(u);function p(w,b,k){for(let N=1;N<=40;N++)if(b<=e.getCapacity(N,k,w))return N}function m(w,b){return o.getCharCountIndicator(w,b)+4}function v(w,b){let k=0;return w.forEach(function(N){const S=m(N.mode,b);k+=S+N.getBitsLength()}),k}function y(w,b){for(let k=1;k<=40;k++)if(v(w,k)<=e.getCapacity(k,b,o.MIXED))return k}e.from=function(b,k){return a.isValid(b)?parseInt(b,10):k},e.getCapacity=function(b,k,N){if(!a.isValid(b))throw new Error("Invalid QR Code version");typeof N>"u"&&(N=o.BYTE);const S=t.getSymbolTotalCodewords(b),j=n.getTotalCodewordsCount(b,k),C=(S-j)*8;if(N===o.MIXED)return C;const $=C-m(N,b);switch(N){case o.NUMERIC:return Math.floor($/10*3);case o.ALPHANUMERIC:return Math.floor($/11*2);case o.KANJI:return Math.floor($/13);case o.BYTE:default:return Math.floor($/8)}},e.getBestVersionForData=function(b,k){let N;const S=s.from(k,s.M);if(Array.isArray(b)){if(b.length>1)return y(b,S);if(b.length===0)return 1;N=b[0]}else N=b;return p(N.mode,N.getLength(),S)},e.getEncodedBits=function(b){if(!a.isValid(b)||b<7)throw new Error("Invalid QR Code version");let k=b<<12;for(;t.getBCHDigit(k)-h>=0;)k^=u<<t.getBCHDigit(k)-h;return b<<12|k}})(jd)),jd}var Ad={},b_;function c2(){if(b_)return Ad;b_=1;const e=nr(),t=1335,n=21522,s=e.getBCHDigit(t);return Ad.getEncodedBits=function(a,u){const h=a.bit<<3|u;let p=h<<10;for(;e.getBCHDigit(p)-s>=0;)p^=t<<e.getBCHDigit(p)-s;return(h<<10|p)^n},Ad}var Ld={},Td,S_;function u2(){if(S_)return Td;S_=1;const e=ir();function t(n){this.mode=e.NUMERIC,this.data=n.toString()}return t.getBitsLength=function(s){return 10*Math.floor(s/3)+(s%3?s%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(s){let o,a,u;for(o=0;o+3<=this.data.length;o+=3)a=this.data.substr(o,3),u=parseInt(a,10),s.put(u,10);const h=this.data.length-o;h>0&&(a=this.data.substr(o),u=parseInt(a,10),s.put(u,h*3+1))},Td=t,Td}var Md,x_;function d2(){if(x_)return Md;x_=1;const e=ir(),t=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function n(s){this.mode=e.ALPHANUMERIC,this.data=s}return n.getBitsLength=function(o){return 11*Math.floor(o/2)+6*(o%2)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(o){let a;for(a=0;a+2<=this.data.length;a+=2){let u=t.indexOf(this.data[a])*45;u+=t.indexOf(this.data[a+1]),o.put(u,11)}this.data.length%2&&o.put(t.indexOf(this.data[a]),6)},Md=n,Md}var Dd,k_;function h2(){if(k_)return Dd;k_=1;const e=ir();function t(n){this.mode=e.BYTE,typeof n=="string"?this.data=new TextEncoder().encode(n):this.data=new Uint8Array(n)}return t.getBitsLength=function(s){return s*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(n){for(let s=0,o=this.data.length;s<o;s++)n.put(this.data[s],8)},Dd=t,Dd}var Id,C_;function f2(){if(C_)return Id;C_=1;const e=ir(),t=nr();function n(s){this.mode=e.KANJI,this.data=s}return n.getBitsLength=function(o){return o*13},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(s){let o;for(o=0;o<this.data.length;o++){let a=t.toSJIS(this.data[o]);if(a>=33088&&a<=40956)a-=33088;else if(a>=57408&&a<=60351)a-=49472;else throw new Error("Invalid SJIS character: "+this.data[o]+`
|
|
83
|
-
Make sure your charset is UTF-8`);a=(a>>>8&255)*192+(a&255),s.put(a,13)}},Id=n,Id}var Od={exports:{}},E_;function p2(){return E_||(E_=1,(function(e){var t={single_source_shortest_paths:function(n,s,o){var a={},u={};u[s]=0;var h=t.PriorityQueue.make();h.push(s,0);for(var p,m,v,y,w,b,k,N,S;!h.empty();){p=h.pop(),m=p.value,y=p.cost,w=n[m]||{};for(v in w)w.hasOwnProperty(v)&&(b=w[v],k=y+b,N=u[v],S=typeof u[v]>"u",(S||N>k)&&(u[v]=k,h.push(v,k),a[v]=m))}if(typeof o<"u"&&typeof u[o]>"u"){var j=["Could not find a path from ",s," to ",o,"."].join("");throw new Error(j)}return a},extract_shortest_path_from_predecessor_list:function(n,s){for(var o=[],a=s;a;)o.push(a),n[a],a=n[a];return o.reverse(),o},find_path:function(n,s,o){var a=t.single_source_shortest_paths(n,s,o);return t.extract_shortest_path_from_predecessor_list(a,o)},PriorityQueue:{make:function(n){var s=t.PriorityQueue,o={},a;n=n||{};for(a in s)s.hasOwnProperty(a)&&(o[a]=s[a]);return o.queue=[],o.sorter=n.sorter||s.default_sorter,o},default_sorter:function(n,s){return n.cost-s.cost},push:function(n,s){var o={value:n,cost:s};this.queue.push(o),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(Od)),Od.exports}var N_;function m2(){return N_||(N_=1,(function(e){const t=ir(),n=u2(),s=d2(),o=h2(),a=f2(),u=ib(),h=nr(),p=p2();function m(j){return unescape(encodeURIComponent(j)).length}function v(j,C,$){const O=[];let U;for(;(U=j.exec($))!==null;)O.push({data:U[0],index:U.index,mode:C,length:U[0].length});return O}function y(j){const C=v(u.NUMERIC,t.NUMERIC,j),$=v(u.ALPHANUMERIC,t.ALPHANUMERIC,j);let O,U;return h.isKanjiModeEnabled()?(O=v(u.BYTE,t.BYTE,j),U=v(u.KANJI,t.KANJI,j)):(O=v(u.BYTE_KANJI,t.BYTE,j),U=[]),C.concat($,O,U).sort(function(K,Z){return K.index-Z.index}).map(function(K){return{data:K.data,mode:K.mode,length:K.length}})}function w(j,C){switch(C){case t.NUMERIC:return n.getBitsLength(j);case t.ALPHANUMERIC:return s.getBitsLength(j);case t.KANJI:return a.getBitsLength(j);case t.BYTE:return o.getBitsLength(j)}}function b(j){return j.reduce(function(C,$){const O=C.length-1>=0?C[C.length-1]:null;return O&&O.mode===$.mode?(C[C.length-1].data+=$.data,C):(C.push($),C)},[])}function k(j){const C=[];for(let $=0;$<j.length;$++){const O=j[$];switch(O.mode){case t.NUMERIC:C.push([O,{data:O.data,mode:t.ALPHANUMERIC,length:O.length},{data:O.data,mode:t.BYTE,length:O.length}]);break;case t.ALPHANUMERIC:C.push([O,{data:O.data,mode:t.BYTE,length:O.length}]);break;case t.KANJI:C.push([O,{data:O.data,mode:t.BYTE,length:m(O.data)}]);break;case t.BYTE:C.push([{data:O.data,mode:t.BYTE,length:m(O.data)}])}}return C}function N(j,C){const $={},O={start:{}};let U=["start"];for(let V=0;V<j.length;V++){const K=j[V],Z=[];for(let G=0;G<K.length;G++){const Q=K[G],F=""+V+G;Z.push(F),$[F]={node:Q,lastCount:0},O[F]={};for(let B=0;B<U.length;B++){const A=U[B];$[A]&&$[A].node.mode===Q.mode?(O[A][F]=w($[A].lastCount+Q.length,Q.mode)-w($[A].lastCount,Q.mode),$[A].lastCount+=Q.length):($[A]&&($[A].lastCount=Q.length),O[A][F]=w(Q.length,Q.mode)+4+t.getCharCountIndicator(Q.mode,C))}}U=Z}for(let V=0;V<U.length;V++)O[U[V]].end=0;return{map:O,table:$}}function S(j,C){let $;const O=t.getBestModeForData(j);if($=t.from(C,O),$!==t.BYTE&&$.bit<O.bit)throw new Error('"'+j+'" cannot be encoded with mode '+t.toString($)+`.
|
|
84
|
-
Suggested mode is: `+t.toString(O));switch($===t.KANJI&&!h.isKanjiModeEnabled()&&($=t.BYTE),$){case t.NUMERIC:return new n(j);case t.ALPHANUMERIC:return new s(j);case t.KANJI:return new a(j);case t.BYTE:return new o(j)}}e.fromArray=function(C){return C.reduce(function($,O){return typeof O=="string"?$.push(S(O,null)):O.data&&$.push(S(O.data,O.mode)),$},[])},e.fromString=function(C,$){const O=y(C,h.isKanjiModeEnabled()),U=k(O),V=N(U,$),K=p.find_path(V.map,"start","end"),Z=[];for(let G=1;G<K.length-1;G++)Z.push(V.table[K[G]].node);return e.fromArray(b(Z))},e.rawSplit=function(C){return e.fromArray(y(C,h.isKanjiModeEnabled()))}})(Ld)),Ld}var j_;function g2(){if(j_)return yd;j_=1;const e=nr(),t=If(),n=e2(),s=t2(),o=n2(),a=i2(),u=s2(),h=tb(),p=a2(),m=l2(),v=c2(),y=ir(),w=m2();function b(V,K){const Z=V.size,G=a.getPositions(K);for(let Q=0;Q<G.length;Q++){const F=G[Q][0],B=G[Q][1];for(let A=-1;A<=7;A++)if(!(F+A<=-1||Z<=F+A))for(let z=-1;z<=7;z++)B+z<=-1||Z<=B+z||(A>=0&&A<=6&&(z===0||z===6)||z>=0&&z<=6&&(A===0||A===6)||A>=2&&A<=4&&z>=2&&z<=4?V.set(F+A,B+z,!0,!0):V.set(F+A,B+z,!1,!0))}}function k(V){const K=V.size;for(let Z=8;Z<K-8;Z++){const G=Z%2===0;V.set(Z,6,G,!0),V.set(6,Z,G,!0)}}function N(V,K){const Z=o.getPositions(K);for(let G=0;G<Z.length;G++){const Q=Z[G][0],F=Z[G][1];for(let B=-2;B<=2;B++)for(let A=-2;A<=2;A++)B===-2||B===2||A===-2||A===2||B===0&&A===0?V.set(Q+B,F+A,!0,!0):V.set(Q+B,F+A,!1,!0)}}function S(V,K){const Z=V.size,G=m.getEncodedBits(K);let Q,F,B;for(let A=0;A<18;A++)Q=Math.floor(A/3),F=A%3+Z-8-3,B=(G>>A&1)===1,V.set(Q,F,B,!0),V.set(F,Q,B,!0)}function j(V,K,Z){const G=V.size,Q=v.getEncodedBits(K,Z);let F,B;for(F=0;F<15;F++)B=(Q>>F&1)===1,F<6?V.set(F,8,B,!0):F<8?V.set(F+1,8,B,!0):V.set(G-15+F,8,B,!0),F<8?V.set(8,G-F-1,B,!0):F<9?V.set(8,15-F-1+1,B,!0):V.set(8,15-F-1,B,!0);V.set(G-8,8,1,!0)}function C(V,K){const Z=V.size;let G=-1,Q=Z-1,F=7,B=0;for(let A=Z-1;A>0;A-=2)for(A===6&&A--;;){for(let z=0;z<2;z++)if(!V.isReserved(Q,A-z)){let I=!1;B<K.length&&(I=(K[B]>>>F&1)===1),V.set(Q,A-z,I),F--,F===-1&&(B++,F=7)}if(Q+=G,Q<0||Z<=Q){Q-=G,G=-G;break}}}function $(V,K,Z){const G=new n;Z.forEach(function(z){G.put(z.mode.bit,4),G.put(z.getLength(),y.getCharCountIndicator(z.mode,V)),z.write(G)});const Q=e.getSymbolTotalCodewords(V),F=h.getTotalCodewordsCount(V,K),B=(Q-F)*8;for(G.getLengthInBits()+4<=B&&G.put(0,4);G.getLengthInBits()%8!==0;)G.putBit(0);const A=(B-G.getLengthInBits())/8;for(let z=0;z<A;z++)G.put(z%2?17:236,8);return O(G,V,K)}function O(V,K,Z){const G=e.getSymbolTotalCodewords(K),Q=h.getTotalCodewordsCount(K,Z),F=G-Q,B=h.getBlocksCount(K,Z),A=G%B,z=B-A,I=Math.floor(G/B),D=Math.floor(F/B),P=D+1,x=I-D,M=new p(x);let L=0;const T=new Array(B),H=new Array(B);let Y=0;const de=new Uint8Array(V.buffer);for(let ye=0;ye<B;ye++){const Ue=ye<z?D:P;T[ye]=de.slice(L,L+Ue),H[ye]=M.encode(T[ye]),L+=Ue,Y=Math.max(Y,Ue)}const ue=new Uint8Array(G);let fe=0,ve,ie;for(ve=0;ve<Y;ve++)for(ie=0;ie<B;ie++)ve<T[ie].length&&(ue[fe++]=T[ie][ve]);for(ve=0;ve<x;ve++)for(ie=0;ie<B;ie++)ue[fe++]=H[ie][ve];return ue}function U(V,K,Z,G){let Q;if(Array.isArray(V))Q=w.fromArray(V);else if(typeof V=="string"){let I=K;if(!I){const D=w.rawSplit(V);I=m.getBestVersionForData(D,Z)}Q=w.fromString(V,I||40)}else throw new Error("Invalid data");const F=m.getBestVersionForData(Q,Z);if(!F)throw new Error("The amount of data is too big to be stored in a QR Code");if(!K)K=F;else if(K<F)throw new Error(`
|
|
85
|
-
The chosen QR Code version cannot contain this amount of data.
|
|
86
|
-
Minimum version required to store current data is: `+F+`.
|
|
87
|
-
`);const B=$(K,Z,Q),A=e.getSymbolSize(K),z=new s(A);return b(z,K),k(z),N(z,K),j(z,Z,0),K>=7&&S(z,K),C(z,B),isNaN(G)&&(G=u.getBestMask(z,j.bind(null,z,Z))),u.applyMask(G,z),j(z,Z,G),{modules:z,version:K,errorCorrectionLevel:Z,maskPattern:G,segments:Q}}return yd.create=function(K,Z){if(typeof K>"u"||K==="")throw new Error("No input text");let G=t.M,Q,F;return typeof Z<"u"&&(G=t.from(Z.errorCorrectionLevel,t.M),Q=m.from(Z.version),F=u.from(Z.maskPattern),Z.toSJISFunc&&e.setToSJISFunction(Z.toSJISFunc)),U(K,Q,G,F)},yd}var Bd={},zd={},R_;function sb(){return R_||(R_=1,(function(e){function t(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let s=n.slice().replace("#","").split("");if(s.length<3||s.length===5||s.length>8)throw new Error("Invalid hex color: "+n);(s.length===3||s.length===4)&&(s=Array.prototype.concat.apply([],s.map(function(a){return[a,a]}))),s.length===6&&s.push("F","F");const o=parseInt(s.join(""),16);return{r:o>>24&255,g:o>>16&255,b:o>>8&255,a:o&255,hex:"#"+s.slice(0,6).join("")}}e.getOptions=function(s){s||(s={}),s.color||(s.color={});const o=typeof s.margin>"u"||s.margin===null||s.margin<0?4:s.margin,a=s.width&&s.width>=21?s.width:void 0,u=s.scale||4;return{width:a,scale:a?4:u,margin:o,color:{dark:t(s.color.dark||"#000000ff"),light:t(s.color.light||"#ffffffff")},type:s.type,rendererOpts:s.rendererOpts||{}}},e.getScale=function(s,o){return o.width&&o.width>=s+o.margin*2?o.width/(s+o.margin*2):o.scale},e.getImageWidth=function(s,o){const a=e.getScale(s,o);return Math.floor((s+o.margin*2)*a)},e.qrToImageData=function(s,o,a){const u=o.modules.size,h=o.modules.data,p=e.getScale(u,a),m=Math.floor((u+a.margin*2)*p),v=a.margin*p,y=[a.color.light,a.color.dark];for(let w=0;w<m;w++)for(let b=0;b<m;b++){let k=(w*m+b)*4,N=a.color.light;if(w>=v&&b>=v&&w<m-v&&b<m-v){const S=Math.floor((w-v)/p),j=Math.floor((b-v)/p);N=y[h[S*u+j]?1:0]}s[k++]=N.r,s[k++]=N.g,s[k++]=N.b,s[k]=N.a}}})(zd)),zd}var P_;function v2(){return P_||(P_=1,(function(e){const t=sb();function n(o,a,u){o.clearRect(0,0,a.width,a.height),a.style||(a.style={}),a.height=u,a.width=u,a.style.height=u+"px",a.style.width=u+"px"}function s(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(a,u,h){let p=h,m=u;typeof p>"u"&&(!u||!u.getContext)&&(p=u,u=void 0),u||(m=s()),p=t.getOptions(p);const v=t.getImageWidth(a.modules.size,p),y=m.getContext("2d"),w=y.createImageData(v,v);return t.qrToImageData(w.data,a,p),n(y,m,v),y.putImageData(w,0,0),m},e.renderToDataURL=function(a,u,h){let p=h;typeof p>"u"&&(!u||!u.getContext)&&(p=u,u=void 0),p||(p={});const m=e.render(a,u,p),v=p.type||"image/png",y=p.rendererOpts||{};return m.toDataURL(v,y.quality)}})(Bd)),Bd}var $d={},A_;function _2(){if(A_)return $d;A_=1;const e=sb();function t(o,a){const u=o.a/255,h=a+'="'+o.hex+'"';return u<1?h+" "+a+'-opacity="'+u.toFixed(2).slice(1)+'"':h}function n(o,a,u){let h=o+a;return typeof u<"u"&&(h+=" "+u),h}function s(o,a,u){let h="",p=0,m=!1,v=0;for(let y=0;y<o.length;y++){const w=Math.floor(y%a),b=Math.floor(y/a);!w&&!m&&(m=!0),o[y]?(v++,y>0&&w>0&&o[y-1]||(h+=m?n("M",w+u,.5+b+u):n("m",p,0),p=0,m=!1),w+1<a&&o[y+1]||(h+=n("h",v),v=0)):p++}return h}return $d.render=function(a,u,h){const p=e.getOptions(u),m=a.modules.size,v=a.modules.data,y=m+p.margin*2,w=p.color.light.a?"<path "+t(p.color.light,"fill")+' d="M0 0h'+y+"v"+y+'H0z"/>':"",b="<path "+t(p.color.dark,"stroke")+' d="'+s(v,m,p.margin)+'"/>',k='viewBox="0 0 '+y+" "+y+'"',S='<svg xmlns="http://www.w3.org/2000/svg" '+(p.width?'width="'+p.width+'" height="'+p.width+'" ':"")+k+' shape-rendering="crispEdges">'+w+b+`</svg>
|
|
88
|
-
`;return typeof h=="function"&&h(null,S),S},$d}var L_;function y2(){if(L_)return Ar;L_=1;const e=ZN(),t=g2(),n=v2(),s=_2();function o(a,u,h,p,m){const v=[].slice.call(arguments,1),y=v.length,w=typeof v[y-1]=="function";if(!w&&!e())throw new Error("Callback required as last argument");if(w){if(y<2)throw new Error("Too few arguments provided");y===2?(m=h,h=u,u=p=void 0):y===3&&(u.getContext&&typeof m>"u"?(m=p,p=void 0):(m=p,p=h,h=u,u=void 0))}else{if(y<1)throw new Error("Too few arguments provided");return y===1?(h=u,u=p=void 0):y===2&&!u.getContext&&(p=h,h=u,u=void 0),new Promise(function(b,k){try{const N=t.create(h,p);b(a(N,u,p))}catch(N){k(N)}})}try{const b=t.create(h,p);m(null,a(b,u,p))}catch(b){m(b)}}return Ar.create=t.create,Ar.toCanvas=o.bind(null,n.render),Ar.toDataURL=o.bind(null,n.renderToDataURL),Ar.toString=o.bind(null,function(a,u,h){return s.render(a,h)}),Ar}var w2=y2();const b2=Gh(w2);function T_(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.data=="string"?e.data.trim():""}function S2(e){const t=String(e||"").trim();if(!t)return{kind:"empty"};const n=ok(t);if(!n||!n.ok)return{kind:"invalid"};const s=[];return n.ssh||s.push("ssh"),n.name||s.push("name"),s.length?{kind:"partial",decoded:n,missing:s}:{kind:"complete",decoded:n}}function x2(e,t,n=new Set,s=!1){if(!t||!t.ok)return e;const o=ak(e,t,n);return t.version===2&&t.name&&!n.has("name")&&!s&&(o.name=t.name),!n.has("label")&&!o.label&&t.label&&(o.label=t.label),o}function M_(e,t,n=new Set,s=!1){const o=String(t||"").trim(),a=S2(o);let u={...e,pairingUrl:o};return(a.kind==="complete"||a.kind==="partial")&&(u={...x2(u,a.decoded,n,s),pairingUrl:o}),{classification:a,form:u}}function Dl(e,t){const n=String(t||"").toLowerCase();if(!/^[a-f0-9]{16,64}$/.test(n))return"";const s=String(e||"NexusCrew").replace(/([a-z0-9])([A-Z])/g,"$1 $2");let o=Es(s);(o==="localhost"||o==="node")&&(o="nexuscrew");const a=n.slice(0,4),u=Math.max(1,32-a.length-1);return`${o.slice(0,u).replace(/-+$/g,"")||"n"}-${a}`}function k2(e,{deviceDefault:t="",localNodeId:n="",localNameDefault:s=""}={}){const o={name:e.name,ssh:e.ssh,pairingUrl:e.pairingUrl,...e.label?{label:e.label}:{},...e.sshPort?{sshPort:Number(e.sshPort)}:{}},a=e.localLabel||t;a&&(o.localLabel=a);const u=String(e.localName||Dl(a,n)||s||"").trim();return u&&(o.localName=u),o}function C2(){const e=new Set;let t=!1;return{canAuto(n){return!t&&!e.has(String(n||""))},start(n){return t?!1:(t=!0,e.add(String(n||"")),!0)},finish(){t=!1},reset(n){e.delete(String(n||""))},isBusy(){return t}}}const E2=["validation","conflict","ssh-start","ssh-ready","join","tunnel-final","confirm","health"];function N2(e){const t=e&&e.data||{},n=typeof t.stage=="string"&&t.stage?t.stage:"",s=typeof t.detail=="string"&&t.detail?t.detail:"";return{stage:n,code:typeof t.code=="string"?t.code:"",detail:s,hint:typeof t.hint=="string"?t.hint:"",suggestedName:typeof t.suggestedName=="string"?t.suggestedName:"",retryable:typeof t.retryable=="boolean"?t.retryable:!n,message:s||String(e&&e.message||e)}}const j2="modulepreload",R2=function(e){return"/"+e},D_={},P2=function(t,n,s){let o=Promise.resolve();if(n&&n.length>0){let u=function(m){return Promise.all(m.map(v=>Promise.resolve(v).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),p=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));o=u(n.map(m=>{if(m=R2(m),m in D_)return;D_[m]=!0;const v=m.endsWith(".css"),y=v?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${y}`))return;const w=document.createElement("link");if(w.rel=v?"stylesheet":j2,v||(w.as="script"),w.crossOrigin="",w.href=m,p&&w.setAttribute("nonce",p),document.head.appendChild(w),v)return new Promise((b,k)=>{w.addEventListener("load",b),w.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${m}`)))})}))}function a(u){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=u,window.dispatchEvent(h),!h.defaultPrevented)throw u}return o.then(u=>{for(const h of u||[])h.status==="rejected"&&a(h.reason);return t().catch(a)})};class st{constructor(t,n,s,o,a){this._legacyCanvasSize=st.DEFAULT_CANVAS_SIZE,this._preferredCamera="environment",this._maxScansPerSecond=25,this._lastScanTimestamp=-1,this._destroyed=this._flashOn=this._paused=this._active=!1,this.$video=t,this.$canvas=document.createElement("canvas"),s&&typeof s=="object"?this._onDecode=n:(console.warn(s||o||a?"You're using a deprecated version of the QrScanner constructor which will be removed in the future":"Note that the type of the scan result passed to onDecode will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),this._legacyOnDecode=n),n=typeof s=="object"?s:{},this._onDecodeError=n.onDecodeError||(typeof s=="function"?s:this._onDecodeError),this._calculateScanRegion=n.calculateScanRegion||(typeof o=="function"?o:this._calculateScanRegion),this._preferredCamera=n.preferredCamera||a||this._preferredCamera,this._legacyCanvasSize=typeof s=="number"?s:typeof o=="number"?o:this._legacyCanvasSize,this._maxScansPerSecond=n.maxScansPerSecond||this._maxScansPerSecond,this._onPlay=this._onPlay.bind(this),this._onLoadedMetaData=this._onLoadedMetaData.bind(this),this._onVisibilityChange=this._onVisibilityChange.bind(this),this._updateOverlay=this._updateOverlay.bind(this),t.disablePictureInPicture=!0,t.playsInline=!0,t.muted=!0;let u=!1;if(t.hidden&&(t.hidden=!1,u=!0),document.body.contains(t)||(document.body.appendChild(t),u=!0),s=t.parentElement,n.highlightScanRegion||n.highlightCodeOutline){if(o=!!n.overlay,this.$overlay=n.overlay||document.createElement("div"),a=this.$overlay.style,a.position="absolute",a.display="none",a.pointerEvents="none",this.$overlay.classList.add("scan-region-highlight"),!o&&n.highlightScanRegion){this.$overlay.innerHTML='<svg class="scan-region-highlight-svg" viewBox="0 0 238 238" preserveAspectRatio="none" style="position:absolute;width:100%;height:100%;left:0;top:0;fill:none;stroke:#e9b213;stroke-width:4;stroke-linecap:round;stroke-linejoin:round"><path d="M31 2H10a8 8 0 0 0-8 8v21M207 2h21a8 8 0 0 1 8 8v21m0 176v21a8 8 0 0 1-8 8h-21m-176 0H10a8 8 0 0 1-8-8v-21"/></svg>';try{this.$overlay.firstElementChild.animate({transform:["scale(.98)","scale(1.01)"]},{duration:400,iterations:1/0,direction:"alternate",easing:"ease-in-out"})}catch{}s.insertBefore(this.$overlay,this.$video.nextSibling)}n.highlightCodeOutline&&(this.$overlay.insertAdjacentHTML("beforeend",'<svg class="code-outline-highlight" preserveAspectRatio="none" style="display:none;width:100%;height:100%;fill:none;stroke:#e9b213;stroke-width:5;stroke-dasharray:25;stroke-linecap:round;stroke-linejoin:round"><polygon/></svg>'),this.$codeOutlineHighlight=this.$overlay.lastElementChild)}this._scanRegion=this._calculateScanRegion(t),requestAnimationFrame(()=>{let h=window.getComputedStyle(t);h.display==="none"&&(t.style.setProperty("display","block","important"),u=!0),h.visibility!=="visible"&&(t.style.setProperty("visibility","visible","important"),u=!0),u&&(console.warn("QrScanner has overwritten the video hiding style to avoid Safari stopping the playback."),t.style.opacity="0",t.style.width="0",t.style.height="0",this.$overlay&&this.$overlay.parentElement&&this.$overlay.parentElement.removeChild(this.$overlay),delete this.$overlay,delete this.$codeOutlineHighlight),this.$overlay&&this._updateOverlay()}),t.addEventListener("play",this._onPlay),t.addEventListener("loadedmetadata",this._onLoadedMetaData),document.addEventListener("visibilitychange",this._onVisibilityChange),window.addEventListener("resize",this._updateOverlay),this._qrEnginePromise=st.createQrEngine()}static set WORKER_PATH(t){console.warn("Setting QrScanner.WORKER_PATH is not required and not supported anymore. Have a look at the README for new setup instructions.")}static async hasCamera(){try{return!!(await st.listCameras(!1)).length}catch{return!1}}static async listCameras(t=!1){if(!navigator.mediaDevices)return[];let n=async()=>(await navigator.mediaDevices.enumerateDevices()).filter(o=>o.kind==="videoinput"),s;try{t&&(await n()).every(o=>!o.label)&&(s=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch{}try{return(await n()).map((o,a)=>({id:o.deviceId,label:o.label||(a===0?"Default Camera":`Camera ${a+1}`)}))}finally{s&&(console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"),st._stopVideoStream(s))}}async hasFlash(){let t;try{if(this.$video.srcObject){if(!(this.$video.srcObject instanceof MediaStream))return!1;t=this.$video.srcObject}else t=(await this._getCameraStream()).stream;return"torch"in t.getVideoTracks()[0].getSettings()}catch{return!1}finally{t&&t!==this.$video.srcObject&&(console.warn("Call hasFlash after successfully starting the scanner to avoid creating a temporary video stream"),st._stopVideoStream(t))}}isFlashOn(){return this._flashOn}async toggleFlash(){this._flashOn?await this.turnFlashOff():await this.turnFlashOn()}async turnFlashOn(){if(!this._flashOn&&!this._destroyed&&(this._flashOn=!0,this._active&&!this._paused))try{if(!await this.hasFlash())throw"No flash available";await this.$video.srcObject.getVideoTracks()[0].applyConstraints({advanced:[{torch:!0}]})}catch(t){throw this._flashOn=!1,t}}async turnFlashOff(){this._flashOn&&(this._flashOn=!1,await this._restartVideoStream())}destroy(){this.$video.removeEventListener("loadedmetadata",this._onLoadedMetaData),this.$video.removeEventListener("play",this._onPlay),document.removeEventListener("visibilitychange",this._onVisibilityChange),window.removeEventListener("resize",this._updateOverlay),this._destroyed=!0,this._flashOn=!1,this.stop(),st._postWorkerMessage(this._qrEnginePromise,"close")}async start(){if(this._destroyed)throw Error("The QR scanner can not be started as it had been destroyed.");if((!this._active||this._paused)&&(window.location.protocol!=="https:"&&console.warn("The camera stream is only accessible if the page is transferred via https."),this._active=!0,!document.hidden))if(this._paused=!1,this.$video.srcObject)await this.$video.play();else try{let{stream:t,facingMode:n}=await this._getCameraStream();!this._active||this._paused?st._stopVideoStream(t):(this._setVideoMirror(n),this.$video.srcObject=t,await this.$video.play(),this._flashOn&&(this._flashOn=!1,this.turnFlashOn().catch(()=>{})))}catch(t){if(!this._paused)throw this._active=!1,t}}stop(){this.pause(),this._active=!1}async pause(t=!1){if(this._paused=!0,!this._active)return!0;this.$video.pause(),this.$overlay&&(this.$overlay.style.display="none");let n=()=>{this.$video.srcObject instanceof MediaStream&&(st._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return t?(n(),!0):(await new Promise(s=>setTimeout(s,300)),this._paused?(n(),!0):!1)}async setCamera(t){t!==this._preferredCamera&&(this._preferredCamera=t,await this._restartVideoStream())}static async scanImage(t,n,s,o,a=!1,u=!1){let h,p=!1;n&&("scanRegion"in n||"qrEngine"in n||"canvas"in n||"disallowCanvasResizing"in n||"alsoTryWithoutScanRegion"in n||"returnDetailedScanResult"in n)?(h=n.scanRegion,s=n.qrEngine,o=n.canvas,a=n.disallowCanvasResizing||!1,u=n.alsoTryWithoutScanRegion||!1,p=!0):console.warn(n||s||o||a||u?"You're using a deprecated api for scanImage which will be removed in the future.":"Note that the return type of scanImage will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),n=!!s;try{let m,v;[s,m]=await Promise.all([s||st.createQrEngine(),st._loadImage(t)]),[o,v]=st._drawToCanvas(m,h,o,a);let y;if(s instanceof Worker){let w=s;n||st._postWorkerMessageSync(w,"inversionMode","both"),y=await new Promise((b,k)=>{let N,S,j,C=-1;S=O=>{O.data.id===C&&(w.removeEventListener("message",S),w.removeEventListener("error",j),clearTimeout(N),O.data.data!==null?b({data:O.data.data,cornerPoints:st._convertPoints(O.data.cornerPoints,h)}):k(st.NO_QR_CODE_FOUND))},j=O=>{w.removeEventListener("message",S),w.removeEventListener("error",j),clearTimeout(N),k("Scanner error: "+(O?O.message||O:"Unknown Error"))},w.addEventListener("message",S),w.addEventListener("error",j),N=setTimeout(()=>j("timeout"),1e4);let $=v.getImageData(0,0,o.width,o.height);C=st._postWorkerMessageSync(w,"decode",$,[$.data.buffer])})}else y=await Promise.race([new Promise((w,b)=>window.setTimeout(()=>b("Scanner error: timeout"),1e4)),(async()=>{try{var[w]=await s.detect(o);if(!w)throw st.NO_QR_CODE_FOUND;return{data:w.rawValue,cornerPoints:st._convertPoints(w.cornerPoints,h)}}catch(b){if(w=b.message||b,/not implemented|service unavailable/.test(w))return st._disableBarcodeDetector=!0,st.scanImage(t,{scanRegion:h,canvas:o,disallowCanvasResizing:a,alsoTryWithoutScanRegion:u});throw`Scanner error: ${w}`}})()]);return p?y:y.data}catch(m){if(!h||!u)throw m;let v=await st.scanImage(t,{qrEngine:s,canvas:o,disallowCanvasResizing:a});return p?v:v.data}finally{n||st._postWorkerMessage(s,"close")}}setGrayscaleWeights(t,n,s,o=!0){st._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:t,green:n,blue:s,useIntegerApproximation:o})}setInversionMode(t){st._postWorkerMessage(this._qrEnginePromise,"inversionMode",t)}static async createQrEngine(t){if(t&&console.warn("Specifying a worker path is not required and not supported anymore."),t=()=>P2(()=>import("./qr-scanner-worker.min-D85Z9gVD.js"),[]).then(s=>s.createWorker()),!(!st._disableBarcodeDetector&&"BarcodeDetector"in window&&BarcodeDetector.getSupportedFormats&&(await BarcodeDetector.getSupportedFormats()).includes("qr_code")))return t();let n=navigator.userAgentData;return n&&n.brands.some(({brand:s})=>/Chromium/i.test(s))&&/mac ?OS/i.test(n.platform)&&await n.getHighEntropyValues(["architecture","platformVersion"]).then(({architecture:s,platformVersion:o})=>/arm/i.test(s||"arm")&&13<=parseInt(o||"13")).catch(()=>!0)?t():new BarcodeDetector({formats:["qr_code"]})}_onPlay(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay(),this.$overlay&&(this.$overlay.style.display=""),this._scanFrame()}_onLoadedMetaData(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay()}_onVisibilityChange(){document.hidden?this.pause():this._active&&this.start()}_calculateScanRegion(t){let n=Math.round(.6666666666666666*Math.min(t.videoWidth,t.videoHeight));return{x:Math.round((t.videoWidth-n)/2),y:Math.round((t.videoHeight-n)/2),width:n,height:n,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame(()=>{if(this.$overlay){var t=this.$video,n=t.videoWidth,s=t.videoHeight,o=t.offsetWidth,a=t.offsetHeight,u=t.offsetLeft,h=t.offsetTop,p=window.getComputedStyle(t),m=p.objectFit,v=n/s,y=o/a;switch(m){case"none":var w=n,b=s;break;case"fill":w=o,b=a;break;default:(m==="cover"?v>y:v<y)?(b=a,w=b*v):(w=o,b=w/v),m==="scale-down"&&(w=Math.min(w,n),b=Math.min(b,s))}var[k,N]=p.objectPosition.split(" ").map((j,C)=>{const $=parseFloat(j);return j.endsWith("%")?(C?a-b:o-w)*$/100:$});p=this._scanRegion.width||n,y=this._scanRegion.height||s,m=this._scanRegion.x||0;var S=this._scanRegion.y||0;v=this.$overlay.style,v.width=`${p/n*w}px`,v.height=`${y/s*b}px`,v.top=`${h+N+S/s*b}px`,s=/scaleX\(-1\)/.test(t.style.transform),v.left=`${u+(s?o-k-w:k)+(s?n-m-p:m)/n*w}px`,v.transform=t.style.transform}})}static _convertPoints(t,n){if(!n)return t;let s=n.x||0,o=n.y||0,a=n.width&&n.downScaledWidth?n.width/n.downScaledWidth:1;n=n.height&&n.downScaledHeight?n.height/n.downScaledHeight:1;for(let u of t)u.x=u.x*a+s,u.y=u.y*n+o;return t}_scanFrame(){!this._active||this.$video.paused||this.$video.ended||("requestVideoFrameCallback"in this.$video?this.$video.requestVideoFrameCallback.bind(this.$video):requestAnimationFrame)(async()=>{if(!(1>=this.$video.readyState)){var t=Date.now()-this._lastScanTimestamp,n=1e3/this._maxScansPerSecond;t<n&&await new Promise(o=>setTimeout(o,n-t)),this._lastScanTimestamp=Date.now();try{var s=await st.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(o){if(!this._active)return;this._onDecodeError(o)}!st._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=st.createQrEngine()),s?(this._onDecode?this._onDecode(s):this._legacyOnDecode&&this._legacyOnDecode(s.data),this.$codeOutlineHighlight&&(clearTimeout(this._codeOutlineHighlightRemovalTimeout),this._codeOutlineHighlightRemovalTimeout=void 0,this.$codeOutlineHighlight.setAttribute("viewBox",`${this._scanRegion.x||0} ${this._scanRegion.y||0} ${this._scanRegion.width||this.$video.videoWidth} ${this._scanRegion.height||this.$video.videoHeight}`),this.$codeOutlineHighlight.firstElementChild.setAttribute("points",s.cornerPoints.map(({x:o,y:a})=>`${o},${a}`).join(" ")),this.$codeOutlineHighlight.style.display="")):this.$codeOutlineHighlight&&!this._codeOutlineHighlightRemovalTimeout&&(this._codeOutlineHighlightRemovalTimeout=setTimeout(()=>this.$codeOutlineHighlight.style.display="none",100))}this._scanFrame()})}_onDecodeError(t){t!==st.NO_QR_CODE_FOUND&&console.log(t)}async _getCameraStream(){if(!navigator.mediaDevices)throw"Camera not found.";let t=/^(environment|user)$/.test(this._preferredCamera)?"facingMode":"deviceId",n=[{width:{min:1024}},{width:{min:768}},{}],s=n.map(o=>Object.assign({},o,{[t]:{exact:this._preferredCamera}}));for(let o of[...s,...n])try{let a=await navigator.mediaDevices.getUserMedia({video:o,audio:!1}),u=this._getFacingMode(a)||(o.facingMode?this._preferredCamera:this._preferredCamera==="environment"?"user":"environment");return{stream:a,facingMode:u}}catch{}throw"Camera not found."}async _restartVideoStream(){let t=this._paused;await this.pause(!0)&&!t&&this._active&&await this.start()}static _stopVideoStream(t){for(let n of t.getTracks())n.stop(),t.removeTrack(n)}_setVideoMirror(t){this.$video.style.transform="scaleX("+(t==="user"?-1:1)+")"}_getFacingMode(t){return(t=t.getVideoTracks()[0])?/rear|back|environment/i.test(t.label)?"environment":/front|user|face/i.test(t.label)?"user":null:null}static _drawToCanvas(t,n,s,o=!1){s=s||document.createElement("canvas");let a=n&&n.x?n.x:0,u=n&&n.y?n.y:0,h=n&&n.width?n.width:t.videoWidth||t.width,p=n&&n.height?n.height:t.videoHeight||t.height;return o||(o=n&&n.downScaledWidth?n.downScaledWidth:h,n=n&&n.downScaledHeight?n.downScaledHeight:p,s.width!==o&&(s.width=o),s.height!==n&&(s.height=n)),n=s.getContext("2d",{alpha:!1}),n.imageSmoothingEnabled=!1,n.drawImage(t,a,u,h,p,0,0,s.width,s.height),[s,n]}static async _loadImage(t){if(t instanceof Image)return await st._awaitImageLoad(t),t;if(t instanceof HTMLVideoElement||t instanceof HTMLCanvasElement||t instanceof SVGImageElement||"OffscreenCanvas"in window&&t instanceof OffscreenCanvas||"ImageBitmap"in window&&t instanceof ImageBitmap)return t;if(t instanceof File||t instanceof Blob||t instanceof URL||typeof t=="string"){let n=new Image;n.src=t instanceof File||t instanceof Blob?URL.createObjectURL(t):t.toString();try{return await st._awaitImageLoad(n),n}finally{(t instanceof File||t instanceof Blob)&&URL.revokeObjectURL(n.src)}}else throw"Unsupported image type."}static async _awaitImageLoad(t){t.complete&&t.naturalWidth!==0||await new Promise((n,s)=>{let o=a=>{t.removeEventListener("load",o),t.removeEventListener("error",o),a instanceof ErrorEvent?s("Image load error"):n()};t.addEventListener("load",o),t.addEventListener("error",o)})}static async _postWorkerMessage(t,n,s,o){return st._postWorkerMessageSync(await t,n,s,o)}static _postWorkerMessageSync(t,n,s,o){if(!(t instanceof Worker))return-1;let a=st._workerMessageId++;return t.postMessage({id:a,type:n,data:s},o),a}}st.DEFAULT_CANVAS_SIZE=400;st.NO_QR_CODE_FOUND="No QR code found";st._disableBarcodeDetector=!1;st._workerMessageId=0;function A2({onResult:e,onClose:t}){const n=E.useRef(null),s=E.useRef(null),o=E.useRef(!1),[a,u]=E.useState("");E.useEffect(()=>{let p=!1;const m=n.current,v=y=>{p||o.current||(o.current=!0,e(y))};return(async()=>{if(typeof navigator>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!="function"){u(f("qr-unsupported"));return}let y=!1;try{y=await st.hasCamera()}catch{y=!1}if(!y){u(f("qr-no-camera"));return}if(p||!m)return;const w=new st(m,b=>{const k=T_(b);k&&v(k)},{returnDetailedScanResult:!0,preferredCamera:"environment",calculateScanRegion:b=>{const k=b.videoWidth||640,N=b.videoHeight||480,S=Math.max(1,Math.round(Math.min(k,N)*.92));return{x:Math.round((k-S)/2),y:Math.round((N-S)/2),width:S,height:S,downScaledWidth:600,downScaledHeight:600}},highlightScanRegion:!0,highlightCodeOutline:!0});s.current=w;try{await w.start()}catch(b){if(p)return;const k=b&&b.name||"";u(f(k==="NotAllowedError"||k==="SecurityError"?"qr-permission":k==="NotFoundError"||k==="OverconstrainedError"||k==="NotReadableError"?"qr-no-camera":"qr-unsupported"))}})(),()=>{p=!0;const y=s.current;if(y){try{y.stop()}catch{}try{y.destroy()}catch{}s.current=null}const w=m,b=w&&w.srcObject;if(b&&typeof b.getTracks=="function"){for(const k of b.getTracks())try{k.stop()}catch{}try{w.srcObject=null}catch{}}}},[]);const h=async p=>{const m=p.target.files&&p.target.files[0];if(p.target.value="",!!m)try{const v=await st.scanImage(m,{returnDetailedScanResult:!0}),y=T_(v);if(!y)throw new Error("empty");o.current||(o.current=!0,e(y))}catch{u(f("pairing-qr-invalid"))}};return l.jsx("div",{className:"nc-sheet-overlay nc-qr-overlay",onClick:t,children:l.jsxs("div",{className:"nc-sheet nc-qr-modal",onClick:p=>p.stopPropagation(),children:[l.jsx("div",{className:"nc-sheet-head",children:l.jsx("b",{children:f("scan-qr")})}),l.jsx("video",{ref:n,className:"nc-qr-video",playsInline:!0,muted:!0}),a&&l.jsx("div",{className:"nc-err",role:"alert",children:a}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsxs("label",{className:"nc-btn ghost nc-qr-upload",children:[f("qr-upload"),l.jsx("input",{type:"file",accept:"image/*",hidden:!0,onChange:h})]}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:t,children:f("cancel")})]})]})})}const I_=()=>({name:"",label:"",ssh:"",sshPort:"",pairingUrl:"",localLabel:"",localName:""});function rb({token:e,initial:t="",autoStart:n=!1,deviceDefault:s="",localNodeId:o="",localNameDefault:a="",readonly:u=!1,onSuccess:h,onBusyChange:p}){const[m,v]=E.useState(I_),[y,w]=E.useState(!1),[b,k]=E.useState(!1),[N,S]=E.useState("idle"),[j,C]=E.useState(null),[$,O]=E.useState(""),[U,V]=E.useState(!1),[K,Z]=E.useState(!1),G=E.useRef(C2()),Q=E.useRef(new Set),F=N==="busy",B=Dl(m.localLabel||s,o)||a,A=K?m.localName:B;E.useEffect(()=>(p&&p(F),()=>{p&&p(!1)}),[F,p]);const z=async L=>{const T=String(L.pairingUrl||"").trim();if(G.current.start(T)){S("busy"),C(null),O("");try{await U0(e,k2({...L,localName:K?L.localName:Dl(L.localLabel||s,o)||a},{deviceDefault:s,localNodeId:o,localNameDefault:a})),S("ok"),w(!1),v(I_()),Q.current=new Set,V(!1),Z(!1),G.current.finish(),h&&await h()}catch(H){const Y=N2(H);C(Y),S("idle"),G.current.finish(),Y.code==="peer-name-conflict"&&Xd(Y.suggestedName)&&(Z(!0),Q.current.add("localName"),v(de=>({...de,localName:Y.suggestedName}))),(Y.stage==="validation"||Y.stage==="conflict"||Y.stage==="ssh-start"||Y.stage==="ssh-ready"||String(Y.code||"").startsWith("ssh-"))&&w(!0)}}},I=(L,T=!0)=>{const{classification:H,form:Y}=M_(m,L,Q.current,U),de=Y.pairingUrl;if(C(null),O(""),N==="ok"&&S("idle"),v(Y),H.kind==="invalid"){C({stage:"validation",code:"bad-link",message:f("pair-invalid-link"),hint:f("pair-invalid-hint"),retryable:!0});return}if(H.kind==="partial"){w(!0),O(H.missing.includes("ssh")?f("pair-missing-ssh"):f("pair-missing-name"));return}H.kind==="complete"&&T&&!u&&G.current.canAuto(de)&&z(Y)};E.useEffect(()=>{t&&I(t,n)},[]);const D=()=>{const L=String(m.pairingUrl||"").trim(),{classification:T,form:H}=M_(m,L,Q.current,U);if(v(H),O(""),C(null),T.kind==="empty"){C({stage:"validation",message:f("pairing-required"),retryable:!0});return}if(T.kind==="invalid"){C({stage:"validation",code:"bad-link",message:f("pair-invalid-link"),hint:f("pair-invalid-hint"),retryable:!0});return}if(!H.ssh||!H.name){w(!0),O(H.ssh?f("pair-missing-name"):f("pair-missing-ssh"));return}if(H.label&&!zr(H.label)){C({stage:"validation",message:f("err-label"),retryable:!0});return}if(H.localLabel&&!zr(H.localLabel)){C({stage:"validation",message:f("err-label"),retryable:!0});return}const Y=K?H.localName:Dl(H.localLabel||s,o)||a;if(!Xd(Y)||Y==="localhost"){w(!0),C({stage:"validation",code:"bad-local-name",message:f("err-local-name"),retryable:!0});return}G.current.reset(L),z(H)},P=async()=>{try{if(!navigator.clipboard||typeof navigator.clipboard.readText!="function")throw new Error("unsupported");const L=await navigator.clipboard.readText();L&&L.trim()?I(L):O(f("pair-clipboard-empty"))}catch{O(f("pair-clipboard-denied"))}},x=(L,T)=>{Q.current.add(L),v(H=>({...H,[L]:T}))},M=j&&j.stage&&(E2.includes(j.stage)||j.stage==="internal")?f(`pair-stage-${j.stage}`):f("pair-stage-generic");return l.jsxs("div",{className:"nc-set-form nc-pair-card",children:[l.jsx("div",{className:"nc-sheet-label",children:f("pair-card-title")}),l.jsx("div",{className:"nc-set-info",children:f("pair-card-help")}),l.jsx("input",{className:"nc-pair-input",placeholder:f("pair-paste-ph"),value:m.pairingUrl,disabled:u||F,onChange:L=>{v({...m,pairingUrl:L.target.value}),C(null),O("")},onPaste:L=>{const T=L.clipboardData&&L.clipboardData.getData("text")||"";T.trim()&&(L.preventDefault(),I(T))},onKeyDown:L=>{L.key==="Enter"&&(L.preventDefault(),D())}}),l.jsxs("div",{className:"nc-pair-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u||F,onClick:P,children:f("pair-paste-btn")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u||F,onClick:()=>k(!0),children:f("scan-qr")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:u||F,title:u?f("settings-readonly"):"",onClick:D,children:f("test-and-connect")})]}),l.jsxs("div",{className:"nc-pair-status","aria-live":"polite",children:[F&&l.jsx("div",{className:"nc-pair-progress",children:f("pair-progress")}),N==="ok"&&l.jsx("div",{className:"nc-set-test ok",children:f("node-connected")}),$&&l.jsx("div",{className:"nc-set-hint nc-pair-notice",children:$}),j&&l.jsxs("div",{className:"nc-err",role:"alert",children:[l.jsx("b",{children:M})," — ",j.message,j.hint&&l.jsx("div",{className:"nc-pair-hint",children:j.hint}),j.retryable&&l.jsx("div",{children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u||F,onClick:D,children:f("pair-retry")})})]})]}),l.jsxs("button",{type:"button",className:"nc-btn ghost nc-pair-advanced-toggle",disabled:F,onClick:()=>w(L=>!L),children:[y?"▾":"▸"," ",f("pair-advanced")]}),y&&l.jsxs("div",{className:"nc-pair-advanced",children:[l.jsxs("label",{className:"nc-field",children:[f("node-display-label"),l.jsx("input",{placeholder:"Home Relay",value:m.label,disabled:u||F,onChange:L=>{Q.current.add("label"),v(T=>({...T,label:L.target.value,name:U?T.name:Es(L.target.value)}))}})]}),l.jsxs("label",{className:"nc-field",children:[f("node-name-label"),l.jsx("input",{placeholder:f("node-name-ph"),value:m.name,disabled:u||F,onChange:L=>{V(!0),Q.current.add("name"),v(T=>({...T,name:L.target.value?Es(L.target.value):""}))}})]}),l.jsx("small",{className:"nc-set-hint",children:f("node-slug-hint").replace("{slug}",m.name||"home-relay")}),l.jsxs("label",{className:"nc-field",children:[f("pair-ssh-local-label"),l.jsx("input",{placeholder:"my-relay",value:m.ssh,disabled:u||F,onChange:L=>{Q.current.add("ssh"),x("ssh",L.target.value)}}),l.jsx("small",{className:"nc-set-hint",children:f("node-ssh-local-help")})]}),l.jsxs("label",{className:"nc-field",children:[f("node-ssh-port-label"),l.jsx("input",{inputMode:"numeric",placeholder:f("node-ssh-port-help"),value:m.sshPort,disabled:u||F,onChange:L=>x("sshPort",L.target.value.replace(/[^0-9]/g,"").slice(0,5))})]}),l.jsxs("label",{className:"nc-field",children:[f("device-name-label"),l.jsx("input",{placeholder:s||"NexusCrew",value:m.localLabel,disabled:u||F,onChange:L=>x("localLabel",L.target.value)}),l.jsx("small",{className:"nc-set-hint",children:f("device-name-hint")})]}),l.jsxs("label",{className:"nc-field",children:[f("local-route-name-label"),l.jsx("input",{placeholder:B||"nexuscrew-5bd6",value:A,disabled:u||F,onChange:L=>{Z(!0),Q.current.add("localName"),v(T=>({...T,localName:L.target.value?Es(L.target.value):""}))}}),l.jsx("small",{className:"nc-set-hint",children:f("local-route-name-hint")})]})]}),b&&l.jsx(A2,{onResult:L=>{k(!1),I(L)},onClose:()=>k(!1)})]})}const Ni={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 Of(e){if(!e||typeof e!="object")return{key:Ni.down,up:!1};if(e.kind==="vl")return e.online?{key:Ni.vlOnline,up:!0}:{key:Ni.vlOffline,up:!1};if(e.kind==="transitive"){const n=e.stale===!0;return{key:n?Ni.routedStale:Ni.routed,up:!n,routed:!0}}const t=e.tunnel&&e.tunnel.status;return t==="up"?{key:Ni.up,up:!0}:t==="passive"?{key:Ni.passive,up:!1,passive:!0}:{key:Ni.down,up:!1}}function ob(e){if(!e||typeof e!="object")return{key:"peer-private",shortKey:"row-private",shared:!1};if(e.kind==="vl")return{key:"peer-vl-federated",shortKey:"row-vl-federated",shared:!0};if(e.shared!==!0)return{key:"peer-private",shortKey:"row-private",shared:!1};const t=e.visibility||"network";if(t==="relay-only")return{key:"visibility-relay",shortKey:"visibility-relay",shared:!0,visibility:t};if(t==="selected"){const n=Array.isArray(e.selected)?e.selected.length:0;return{key:"visibility-selected",shortKey:"visibility-selected",shared:!0,visibility:t,count:n}}return{key:"visibility-network",shortKey:"visibility-network",shared:!0,visibility:t}}function L2(e){const n=e.health&&typeof e.health.detail=="string"&&e.health.detail.trim()||f(e.online?Ni.vlOnline:Ni.vlOffline);return e.ownerLabel?`${e.ownerLabel} · ${n}`:n}function T2(e){if(!e||typeof e!="object")return null;const t=typeof e.name=="string"?e.name:"";if(!t)return null;const n=e.kind==="transitive";return{name:t,title:typeof e.label=="string"&&e.label.trim()||t,subtitle:e.kind==="vl"?L2(e):t,reach:Of(e),exposure:ob(e),routed:n,routeLabel:n&&Array.isArray(e.route)?e.route.join(" › "):null}}function M2(e){if(!e||typeof e!="object"||typeof e.name!="string"||!e.name)return null;const t=e.kind==="transitive";return{name:e.name,title:typeof e.label=="string"&&e.label.trim()||e.name,routed:t,route:t&&Array.isArray(e.route)?[...e.route]:null,ssh:!t&&e.direction==="outbound"&&e.ssh?String(e.ssh):null,inbound:!t&&e.direction==="inbound",transport:e.tunnel&&typeof e.tunnel.transport=="string"&&e.tunnel.transport||null}}function D2(e){return!e||typeof e!="object"?null:e.kind==="transitive"?{key:"authority-routed",ownerEquivalent:!1,grants:[],model:"none"}:{key:"authority-owner-equivalent",ownerEquivalent:!0,grants:[],model:"none"}}function I2(e,t){if(!e||e.visibility!=="selected")return[];const n=[...new Set(Array.isArray(e.selected)?e.selected:[])],s=new Map;for(const o of Array.isArray(t)?t:[])o&&o.nodeId&&!s.has(o.nodeId)&&s.set(o.nodeId,o);return n.map(o=>{const a=s.get(o);return{id:o,label:a?typeof a.label=="string"&&a.label.trim()||a.name:o,known:!!a}})}function O2(e,t,n=""){if(!e)return[];const s=new Set(Array.isArray(e.selected)?e.selected:[]),o=String(n||"").trim().toLowerCase(),a=new Set,u=[],h=p=>e.nodeId?p.nodeId===e.nodeId:p.name===e.name;for(const p of Array.isArray(t)?t:[]){if(!p||!p.nodeId||h(p)||s.has(p.nodeId)||a.has(p.nodeId))continue;const m=typeof p.label=="string"&&p.label.trim()||p.name;o&&!`${m} ${p.name}`.toLowerCase().includes(o)||(a.add(p.nodeId),u.push({id:p.nodeId,label:m,name:p.name}))}return u.sort((p,m)=>p.label.localeCompare(m.label))}function B2(e,{readonly:t=!1,busy:n=!1}={}){if(!e||typeof e!="object")return[];const s=e.actions&&typeof e.actions=="object"?e.actions:{},o=Of(e).up,a=[],u=(h,p,{mutating:m=!0,danger:v=!1}={})=>{a.push({key:h,action:p,danger:v,disabled:n||m&&t})};return s.edit&&u("edit","edit"),s.test&&u("node-test","test",{mutating:!1}),s.disconnect&&o&&u("tunnel-stop","down"),s.connect&&!o&&u("tunnel-start","up"),s.restart&&u("tunnel-restart","restart"),s.remove&&u("delete","remove",{danger:!0}),a}function ab(e){const t=e&&typeof e.cellVisibility=="string"?e.cellVisibility:"all";return["all","none","selected"].includes(t)?t:"all"}function z2(e,t){if(ab(e)!=="selected")return[];const n=[...new Set(Array.isArray(e.cells)?e.cells:[])];if(!Array.isArray(t))return n.map(o=>({id:o,label:o,known:!0}));const s=new Set(t.map(o=>typeof o=="string"?o:o&&(o.cell||o.id)).filter(Boolean));return n.map(o=>({id:o,label:o,known:s.has(o)}))}function $2(e,t,n=""){const s=new Set(Array.isArray(e&&e.cells)?e.cells:[]),o=String(n||"").trim().toLowerCase(),a=new Set,u=[];for(const h of Array.isArray(t)?t:[]){const p=typeof h=="string"?h:h&&(h.cell||h.id);!p||s.has(p)||a.has(p)||o&&!p.toLowerCase().includes(o)||(a.add(p),u.push({id:p,label:p}))}return u.sort((h,p)=>h.label.localeCompare(p.label))}function F2(e,t,{readonly:n=!1,busy:s=!1}={}){const o=M2(e);return o?{identity:o,reach:Of(e),authority:D2(e),exposure:ob(e),grants:I2(e,t),cellScope:ab(e),actions:B2(e,{readonly:n,busy:s}),canEditVisibility:!!(e.actions&&e.actions.visibility)&&e.shared===!0&&e.kind!=="transitive",canEditCellScope:!!(e.actions&&e.actions.edit)&&e.kind!=="transitive"}:null}const H2=new Set(["update_candidate"]),O_=4096,U2=new Set(["prompt"]),B_={logs:{limit:50}};function W2(e){if(!e||e.kind!=="vl")return[];const t=Array.isArray(e.capabilities)?e.capabilities:[],n=new Set,s=[];for(const o of t)typeof o!="string"||!o||H2.has(o)||U2.has(o)||n.has(o)||(n.add(o),s.push(o));return s}function z_(e){return!!(e&&e.kind==="vl"&&Array.isArray(e.capabilities)&&e.capabilities.includes("prompt"))}function K2(e){return B_[e]?{...B_[e]}:{}}function q2(e,t){return e?e.inflight&&typeof e.inflight=="object"?{phase:"inflight",kind:e.inflight.kind}:t?e.lastAck&&e.lastAck.id===t.id?{phase:"done",kind:t.kind,status:e.lastAck.status,result:e.lastAck.result,at:e.lastAck.at}:{phase:"submitted",kind:t.kind}:e.lastAck&&typeof e.lastAck=="object"?{phase:"done",kind:null,status:e.lastAck.status,result:e.lastAck.result,at:e.lastAck.at}:null:null}function V2({title:e,subtitle:t,status:n,footer:s,onClose:o,plain:a=!1,children:u}){const h=E.useRef(null),p=E.useRef(null);return E.useEffect(()=>(p.current=document.activeElement,h.current&&h.current.focus(),()=>{const m=p.current;m&&typeof m.focus=="function"&&document.contains(m)&&m.focus()}),[]),E.useEffect(()=>{const m=v=>{v.key==="Escape"&&(v.stopPropagation(),o&&o())};return document.addEventListener("keydown",m,!0),()=>document.removeEventListener("keydown",m,!0)},[o]),l.jsx("div",{className:"nc-detail-overlay",onMouseDown:m=>{m.target===m.currentTarget&&o&&o()},children:l.jsxs("div",{className:"nc-detail-sheet",ref:h,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":typeof e=="string"?e:void 0,children:[l.jsxs("div",{className:"nc-detail-head",children:[l.jsxs("div",{className:"nc-detail-title",children:[l.jsx("b",{children:e}),t&&l.jsx("small",{children:t})]}),n,l.jsx("button",{type:"button",className:"nc-btn ghost nc-detail-close",onClick:o,"aria-label":f("close"),children:l.jsx(nt,{name:"x",size:14})})]}),l.jsx("div",{className:`nc-detail-body${a?" plain":""}`,children:u}),s&&l.jsx("div",{className:"nc-detail-foot",children:s})]})})}function Lr({title:e,hint:t,children:n}){return n==null||n===!1?null:l.jsxs("section",{className:"nc-detail-section",children:[e&&l.jsx("div",{className:"nc-sheet-label",children:e}),t&&l.jsx("small",{className:"nc-set-hint",children:t}),n]})}function Y2({node:e,nodes:t,token:n,readonly:s,refresh:o,onClose:a}){var xt,Se;Dn();const[u,h]=E.useState(null),[p,m]=E.useState(null),[v,y]=E.useState(null),[w,b]=E.useState(null),[k,N]=E.useState(!1),[S,j]=E.useState(""),[C,$]=E.useState(!1),[O,U]=E.useState(null),[V,K]=E.useState(!1),[Z,G]=E.useState(""),[Q,F]=E.useState(!1),[B,A]=E.useState(null),[z,I]=E.useState(!1),[D,P]=E.useState(""),x=E.useMemo(()=>F2(e,t,{readonly:s,busy:!!u}),[e,t,s,u]);if(!x)return null;const{identity:M,reach:L,authority:T,exposure:H,grants:Y,actions:de,canEditVisibility:ue,canEditCellScope:fe,cellScope:ve}=x,ie=M.routed?{up:L.up,since:null}:Qd(e.tunnel,Date.now()),ye=async(le,Pe)=>{m(null),h(le);try{await Pe()}catch(We){m(String(We&&We.message||We))}h(null)},Ue=le=>{if(le==="edit"){b({label:e.label||e.name,ssh:e.ssh||"",sshPort:e.sshPort?String(e.sshPort):"",autostart:e.autostart===!0,visibility:e.visibility||"network"});return}if(le==="remove"){N(!0);return}ye(`${e.name}:${le}`,async()=>{const Pe=await nf(n,e.name,le);le==="test"&&y(Pe),await o()})},ut=(le,Pe=K2(le))=>ye(`${e.nodeId}:${le}`,async()=>{const We=await xg(n,e.nodeId,le,Pe,e.route||[]);A({id:We.id,kind:le,submittedAt:Date.now()}),await o()}),rt=()=>{const le=D.trim().slice(0,O_);le&&ye(`${e.nodeId}:prompt`,async()=>{const Pe=await xg(n,e.nodeId,"prompt",{text:le},e.route||[]);A({id:Pe.id,kind:"prompt",submittedAt:Date.now()}),P(""),I(!1),await o()})},Ae=()=>{if(!zr(w.label)){m(f("err-label"));return}const le=M.inbound?{label:w.label,visibility:w.visibility,selected:w.visibility==="selected"?[...e.selected||[]]:[]}:{label:w.label,ssh:w.ssh,autostart:w.autostart,...w.sshPort?{sshPort:Number(w.sshPort)}:{}};return ye(`${e.name}:edit`,async()=>{await Eg(n,e.name,le),b(null),await o()})},Dt=(le,Pe)=>ye(`${e.name}:visibility`,async()=>{await G0(n,e.name,le,Pe),await o()}),Qt=ue&&e.visibility==="selected"?O2(e,t,S):[],$e=(le,Pe)=>ye(`${e.name}:cell-scope`,async()=>{await Eg(n,e.name,le==="selected"?{cellVisibility:le,cells:Array.isArray(Pe)?Pe:e.cells||[]}:{cellVisibility:le}),await o()}),dt=async({retry:le=!1}={})=>{if(le&&V)K(!1);else if(O!==null||V)return;try{const Pe=await Jl(n);U(Array.isArray(Pe&&Pe.cells)?Pe.cells:[])}catch{K(!0)}};E.useEffect(()=>{fe&&ve==="selected"&&O===null&&dt()},[fe,ve,O]);const it=z2(e,O),wt=ve==="selected"?$2(e,O,Z):[],bt=l.jsxs("span",{className:`nc-set-tunnel${L.up?" up":""}`,children:[f(L.key),ie.since?` · ${ie.since}`:""]}),mt=e.kind==="vl",gt=mt?W2(e):[],pt=mt?q2(e,B):null,Pt=le=>{const Pe=`vl-cmd-${le}`,We=f(Pe);return We===Pe?le:We},vt=mt?[...gt.map(le=>l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u||s,title:s?f("settings-readonly"):void 0,onClick:()=>ut(le),children:Pt(le)},le)),...z_(e)?[l.jsx("button",{type:"button",className:`nc-btn ghost${z?" on":""}`,disabled:!!u||s,title:s?f("settings-readonly"):void 0,onClick:()=>I(le=>!le),children:Pt("prompt")},"prompt")]:[]]:de.map(le=>l.jsx("button",{type:"button",className:`nc-btn ${le.danger?"danger":"ghost"}`,disabled:le.disabled,title:le.disabled&&s?f("settings-readonly"):void 0,onClick:()=>Ue(le.action),children:le.action==="remove"?l.jsxs(l.Fragment,{children:[l.jsx(nt,{name:"trash",size:14})," ",f(le.key)]}):f(le.key)},le.action));return l.jsxs(V2,{title:M.title,subtitle:M.name,status:bt,footer:vt,onClose:a,children:[l.jsxs(Lr,{title:f("node-detail-reach"),children:[l.jsxs("dl",{className:"nc-detail-facts",children:[M.route&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:f("node-detail-route")}),l.jsx("dd",{children:M.route.join(" › ")})]}),M.ssh&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:f("node-detail-ssh")}),l.jsxs("dd",{children:[M.ssh,e.sshPort?`:${e.sshPort}`:""]})]}),M.transport&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:f("node-detail-transport")}),l.jsx("dd",{children:M.transport})]}),mt&&e.ownerLabel&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:f("node-detail-owner")}),l.jsx("dd",{children:e.ownerLabel})]})]}),((xt=e.health)==null?void 0:xt.detail)&&l.jsx("div",{className:`nc-set-test${mt?e.health.state==="running"?" ok":e.health.state==="starting"?"":" ko":e.health.status==="healthy"?" ok":e.health.status==="passive"?"":" ko"}`,children:e.health.detail}),v&&l.jsxs("div",{className:`nc-set-test${v.ok?" ok":" ko"}`,children:[v.result,v.detail?` — ${v.detail}`:""]})]}),mt&&l.jsxs(Lr,{title:f("node-detail-command"),children:[gt.length===0&&!z_(e)&&l.jsx("small",{className:"nc-set-hint",children:f("vl-no-commands")}),z&&l.jsxs("div",{className:"nc-vl-prompt",children:[l.jsx("textarea",{value:D,maxLength:O_,placeholder:f("vl-prompt-placeholder"),"aria-label":f("vl-prompt-placeholder"),disabled:!!u||s,onChange:le=>P(le.target.value)}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:!!u||s||!D.trim(),onClick:rt,children:f("vl-prompt-send")})]}),pt&&l.jsxs("div",{className:`nc-set-test${pt.phase==="done"?pt.status==="ok"?" ok":" ko":""}`,children:[pt.kind&&`${Pt(pt.kind)}: `,pt.phase==="submitted"&&f("vl-cmd-phase-submitted"),pt.phase==="inflight"&&f("vl-cmd-phase-inflight"),pt.phase==="done"&&f(pt.status==="ok"?"vl-cmd-phase-done-ok":"vl-cmd-phase-done-error"),pt.phase==="done"&&((Se=pt.result)!=null&&Se.detail)?` — ${pt.result.detail}`:""]})]}),l.jsxs(Lr,{title:f("node-detail-authority"),children:[l.jsx("div",{className:"nc-set-info",children:f(T.key)}),T.grants.length===0&&l.jsx("small",{className:"nc-set-hint",children:f(fe?"authority-no-grants":"authority-no-grants-elsewhere")})]}),l.jsxs(Lr,{title:f("node-detail-network-view"),children:[l.jsx("div",{className:"nc-set-info",children:f(mt?H.key:H.shared?"peer-shared":"peer-private")}),ue&&l.jsxs(l.Fragment,{children:[l.jsxs("label",{className:"nc-field",children:[f("peer-visibility"),l.jsxs("select",{value:e.visibility||"network",disabled:s||!!u,onChange:le=>Dt(le.target.value),children:[l.jsx("option",{value:"network",children:f("visibility-network")}),l.jsx("option",{value:"relay-only",children:f("visibility-relay")}),l.jsx("option",{value:"selected",children:f("visibility-selected")})]})]}),e.visibility==="selected"&&l.jsxs("div",{className:"nc-detail-grants",children:[Y.length===0&&l.jsx("small",{className:"nc-set-hint",children:f("node-grant-none")}),Y.map(le=>l.jsxs("div",{className:`nc-detail-grant${le.known?"":" unknown"}`,children:[l.jsxs("span",{children:[le.label,le.known?"":` — ${f("node-grant-unknown")}`]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:()=>Dt("selected",(e.selected||[]).filter(Pe=>Pe!==le.id)),children:f("node-grant-remove")})]},le.id)),!C&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:()=>{$(!0),j("")},children:f("node-grant-add")}),C&&l.jsxs("div",{className:"nc-detail-picker",children:[l.jsx("input",{value:S,placeholder:f("node-grant-search"),disabled:s||!!u,onChange:le=>j(le.target.value)}),l.jsxs("div",{className:"nc-detail-picker-list",children:[Qt.length===0&&l.jsx("small",{className:"nc-set-hint",children:f("node-grant-no-candidates")}),Qt.map(le=>l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:async()=>{await Dt("selected",[...e.selected||[],le.id]),$(!1),j("")},children:le.label},le.id))]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>{$(!1),j("")},children:f("cancel")})]})]})]})]}),fe&&l.jsxs(Lr,{title:f("cell-scope"),children:[l.jsx("small",{className:"nc-set-hint",children:f("cell-scope-help")}),l.jsx("label",{className:"nc-field",children:l.jsxs("select",{value:ve,"aria-label":f("cell-scope"),disabled:s||!!u,onChange:le=>{le.target.value==="selected"&&dt(),$e(le.target.value)},children:[l.jsx("option",{value:"all",children:f("cell-scope-all")}),l.jsx("option",{value:"none",children:f("cell-scope-none")}),l.jsx("option",{value:"selected",children:f("cell-scope-selected")})]})}),ve==="selected"&&it.length>0&&l.jsx("small",{className:"nc-set-hint",children:f("cell-scope-reset-warning")}),V&&l.jsx("small",{className:"nc-set-hint",children:f("cell-scope-list-unavailable")}),ve==="selected"&&l.jsxs("div",{className:"nc-detail-grants",children:[it.length===0&&l.jsx("small",{className:"nc-set-hint",children:f("cell-scope-none-granted")}),it.map(le=>l.jsxs("div",{className:`nc-detail-grant${le.known?"":" unknown"}`,children:[l.jsxs("span",{children:[le.label,le.known?"":` — ${f("cell-scope-unknown")}`]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:()=>$e("selected",(e.cells||[]).filter(Pe=>Pe!==le.id)),children:f("node-grant-remove")})]},le.id)),!Q&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:async()=>{await dt({retry:!0}),F(!0),G("")},children:f("cell-scope-add")}),Q&&l.jsxs("div",{className:"nc-detail-picker",children:[l.jsx("input",{value:Z,placeholder:f("cell-scope-search"),disabled:s||!!u,onChange:le=>G(le.target.value)}),l.jsxs("div",{className:"nc-detail-picker-list",children:[wt.length===0&&l.jsx("small",{className:"nc-set-hint",children:f("cell-scope-no-candidates")}),wt.map(le=>l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:async()=>{await $e("selected",[...e.cells||[],le.id]),F(!1),G("")},children:le.label},le.id))]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>{F(!1),G("")},children:f("cancel")})]})]})]}),w&&l.jsxs(Lr,{title:f("edit"),children:[l.jsxs("label",{className:"nc-field",children:[f("node-display-label"),l.jsx("input",{value:w.label,disabled:!!u,onChange:le=>b({...w,label:le.target.value})})]}),M.inbound?l.jsxs("label",{className:"nc-field",children:[f("peer-visibility"),l.jsxs("select",{value:w.visibility,disabled:!!u,onChange:le=>b({...w,visibility:le.target.value}),children:[l.jsx("option",{value:"network",children:f("visibility-network")}),l.jsx("option",{value:"relay-only",children:f("visibility-relay")}),l.jsx("option",{value:"selected",children:f("visibility-selected")})]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("label",{className:"nc-field",children:[f("node-ssh-label"),l.jsx("input",{value:w.ssh,disabled:!!u,onChange:le=>b({...w,ssh:le.target.value})})]}),l.jsxs("label",{className:"nc-field",children:[f("node-ssh-port-label"),l.jsx("input",{inputMode:"numeric",value:w.sshPort,disabled:!!u,onChange:le=>b({...w,sshPort:le.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:w.autostart,disabled:!!u,onChange:le=>b({...w,autostart:le.target.checked})})," ",f("boot-persist")]})]}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn primary",disabled:!!u,onClick:Ae,children:f("save")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>b(null),children:f("cancel")})]})]}),k&&l.jsxs("div",{className:"nc-set-confirm",children:[l.jsx("b",{children:f("node-remove-confirm").replace("{name}",M.title)}),l.jsx("small",{children:f("node-remove-warning")}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn danger",disabled:!!u,onClick:()=>ye(`${e.name}:remove`,async()=>{await V0(n,e.name),N(!1),await o(),a&&a()}),children:f("delete")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>N(!1),children:f("cancel")})]})]}),p&&l.jsx("div",{className:"nc-err",children:p})]})}function Bf(){return typeof navigator<"u"&&"serviceWorker"in navigator&&typeof window<"u"&&"PushManager"in window&&typeof Notification<"u"}function G2(e){const t="=".repeat((4-e.length%4)%4),n=(e+t).replace(/-/g,"+").replace(/_/g,"/"),s=atob(n),o=new Uint8Array(s.length);for(let a=0;a<s.length;a+=1)o[a]=s.charCodeAt(a);return o}async function X2(){if(!Bf())return"unsupported";if(Notification.permission==="denied")return"denied";try{return await(await navigator.serviceWorker.ready).pushManager.getSubscription()?"subscribed":"idle"}catch{return"idle"}}async function Q2(e){if(!Bf())throw new Error("push-unsupported");if(await Notification.requestPermission()!=="granted")throw new Error("push-denied");const n=await Kt("/api/push/vapid",e),{publicKey:s}=await n.json();if(!s)throw new Error("vapid non disponibile");const a=await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:G2(s)}),u=await Kt("/api/push/subscribe",e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({subscription:a.toJSON()})});if(!u.ok){try{await a.unsubscribe()}catch{}const h=await u.json().catch(()=>({}));throw new Error(h.error||`HTTP ${u.status}`)}return!0}async function J2(e){if(!Bf())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 Kt("/api/push/subscribe",e,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:s})})}catch{}return!0}const Hh="nexuscrew.fleet",lb=3,Z2="nexuscrew.cells",cb=/^[A-Za-z0-9._-]{1,32}$/,cc=/^[a-z0-9._-]{1,32}$/,ub=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,db=new Set(["standard","unsafe"]),ej=4096,tj=4096,Ql=256,hb=8192,nj=4096,ij=32,sj=64,rj=24,oj=new Set(["format","version","exportedAt","cells","engines","models"]),aj=new Set(["id","cwdRel","engine","boot","model","models","permissionPolicies","commands","systemPrompt","prompt","label","mcp"]),lj=new Set(["id","cwd","engine","boot","model","models","permissionPolicies","systemPrompt","prompt"]);function Ys(e){if(typeof e!="string"||e.length>tj)return null;for(let n=0;n<e.length;n+=1){const s=e.charCodeAt(n);if(s<=31||s===127||s===92)return null}if(e==="")return"";if(e.charAt(0)==="/"||/^[A-Za-z]:/.test(e))return null;const t=[];for(const n of e.split("/"))if(!(n===""||n===".")){if(n==="..")return null;t.push(n)}return t.join("/")}const cj=new Set(["id","label","rc","managed","command","args","envKeys","model","promptMode","promptFlag","panelUrl"]),uj=new Set(["client","provider","credentialProfile","model","permissionPolicy","displayName","protocol","baseUrl","envKey","providerId"]),dj=new Set(["127.0.0.1","localhost","[::1]"]);function hj(e){if(typeof e!="string"||!e||e.length>512||/[\x00-\x1f\x7f]|\s/.test(e))return!1;let t;try{t=new URL(e)}catch{return!1}return!(t.protocol!=="http:"&&t.protocol!=="https:"||!dj.has(t.hostname))}function Ki(e,t){return typeof e=="string"&&e.length<=t&&!/[\x00-\x1f\x7f]/.test(e)}function zf(e){const t=String(e||"");return/(?:bearer\s+|authorization\s*[:=]|(?:api[_-]?key|secret|token)\s*[:=])/i.test(t)||/^-{1,2}(?:api[-_]?key|access[-_]?key|auth(?:orization)?[-_]?token|token|secret|password|credential)(?:$|=)/i.test(t)||/\b(?:sk|fw|fpk|hf|zai)[-_][A-Za-z0-9._-]{8,}\b/i.test(t)||/https?:\/\/[^\s/@:]+:[^\s/@]+@/i.test(t)}function Go(e,t){if(e===void 0)return{};if(!e||typeof e!="object"||Array.isArray(e))return null;const n=Object.entries(e);if(n.length>128)return null;const s={};for(const[o,a]of n){if(!cc.test(o)||!t(a))return null;s[o]=a}return s}function fb(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(h=>!aj.has(h))||!cb.test(String(e.id||""))||typeof e.cwdRel!="string")return null;const t=Ys(e.cwdRel);if(t===null||!cc.test(String(e.engine||""))||e.boot!==void 0&&typeof e.boot!="boolean"||e.model!==void 0&&(typeof e.model!="string"||e.model.length>Ql)||e.systemPrompt!==void 0&&e.prompt!==void 0&&e.systemPrompt!==e.prompt)return null;const n=e.systemPrompt===void 0?e.prompt===void 0?"":e.prompt:e.systemPrompt;if(typeof n!="string"||n.length>hb)return null;const s=Go(e.models,h=>typeof h=="string"&&!!h&&h.length<=Ql),o=Go(e.permissionPolicies,h=>db.has(h)),a=Go(e.commands,h=>Ki(h,nj)&&!zf(h));if(s===null||o===null||a===null)return null;const u={id:e.id,cwdRel:t,engine:e.engine,boot:e.boot===!0,systemPrompt:n};if(e.model&&(u.model=e.model),e.label!==void 0){if(!Ki(e.label,sj)||!String(e.label).trim())return null;u.label=String(e.label).trim()}return Object.keys(s).length&&(u.models=s),Object.keys(o).length&&(u.permissionPolicies=o),Object.keys(a).length&&(u.commands=a),u}function fj(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(a=>!lj.has(a))||!cb.test(String(e.id||""))||typeof e.cwd!="string"||!e.cwd||e.cwd.length>ej||!cc.test(String(e.engine||""))||e.boot!==void 0&&typeof e.boot!="boolean"||e.model!==void 0&&(typeof e.model!="string"||e.model.length>Ql)||e.systemPrompt!==void 0&&e.prompt!==void 0&&e.systemPrompt!==e.prompt)return null;const t=e.systemPrompt===void 0?e.prompt===void 0?"":e.prompt:e.systemPrompt;if(typeof t!="string"||t.length>hb)return null;const n=Go(e.models,a=>typeof a=="string"&&!!a&&a.length<=Ql),s=Go(e.permissionPolicies,a=>db.has(a));if(n===null||s===null)return null;const o={id:e.id,cwd:e.cwd,engine:e.engine,boot:e.boot===!0,systemPrompt:t};return e.model&&(o.model=e.model),Object.keys(n).length&&(o.models=n),Object.keys(s).length&&(o.permissionPolicies=s),o}function pj(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(n=>!uj.has(n)))return null;const t={};for(const[n,s]of Object.entries(e)){if(typeof s!="string"||!Ki(s,n==="baseUrl"?512:128)||zf(s))return null;t[n]=s}return!t.client||!t.provider||t.envKey&&!ub.test(t.envKey)?null:t}function pb(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(s=>!cj.has(s))||!cc.test(String(e.id||""))||!Ki(e.label||e.id,64)||e.rc!==void 0&&typeof e.rc!="boolean"||e.panelUrl!==void 0&&!hj(e.panelUrl))return null;const t={id:e.id,label:e.label||e.id,rc:e.rc===!0};if(e.panelUrl!==void 0&&(t.panelUrl=e.panelUrl),e.managed!==void 0){const s=pj(e.managed);return!s||["command","args","envKeys","model","promptMode","promptFlag"].some(o=>e[o]!==void 0)?null:(t.managed=s,t)}if(!Ki(e.command,512)||!e.command.startsWith("/")||!Array.isArray(e.args)||e.args.length>32||e.args.some(s=>!Ki(s,1024)||zf(s))||e.promptMode!=="flag"&&e.promptMode!=="send-keys"||e.promptMode==="flag"&&(!Ki(e.promptFlag,32)||/\s/.test(e.promptFlag)))return null;if(e.model!==void 0){if(!e.model||typeof e.model!="object"||Array.isArray(e.model)||Object.keys(e.model).some(s=>s!=="flag"&&s!=="value")||!Ki(e.model.flag,32)||/\s/.test(e.model.flag)||!Ki(e.model.value||"",128))return null;t.model={flag:e.model.flag,value:e.model.value||""}}const n=e.envKeys===void 0?[]:e.envKeys;return!Array.isArray(n)||n.length>32||n.some(s=>!ub.test(s))?null:(Object.assign(t,{command:e.command,args:[...e.args],envKeys:[...new Set(n)].sort(),promptMode:e.promptMode}),e.promptMode==="flag"&&(t.promptFlag=e.promptFlag),t)}function mb(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.managed?{id:e.id,label:e.label,rc:e.rc,managed:e.managed,...e.panelUrl!==void 0?{panelUrl:e.panelUrl}:{}}:{id:e.id,label:e.label,rc:e.rc,command:e.command,args:e.args,envKeys:e.envKeys,model:e.model,promptMode:e.promptMode,promptFlag:e.promptFlag,...e.panelUrl!==void 0?{panelUrl:e.panelUrl}:{}},n=pb(t);return n||null}function mj(e,t,n){const s=new Set;for(const o of Array.isArray(t)?t:[]){if(!n.has(o.id)||!o.managed)continue;const{client:a,provider:u,credentialProfile:h}=o.managed;s.add(h?`${a}.${u}-${h}`:`${a}.${u}`),s.add(`${a}.${u}`)}return(Array.isArray(e)?e:[]).filter(o=>o&&s.has(o.engine))}function gj(e,t,n=[],s=[],o=new Date,a=[]){n instanceof Date&&(o=n,n=[],s=[]);const u=t instanceof Set?t:new Set(t||[]),h=s instanceof Set?s:new Set(s||[]),p=[];for(const y of Array.isArray(e)?e:[]){if(!u.has(y.id))continue;const w=fb({id:y.id,cwdRel:y.cwdRel,engine:y.engine,boot:y.boot===!0,...y.label?{label:y.label}:{},...y.model?{model:y.model}:{},...y.models?{models:y.models}:{},...y.permissionPolicies?{permissionPolicies:y.permissionPolicies}:{},systemPrompt:y.prompt||"",...y.commands?{commands:y.commands}:{}});if(!w)return{ok:!1,error:"invalid-cell",invalidCellIds:[y.id]};p.push(w)}const m=[];for(const y of Array.isArray(n)?n:[]){if(!h.has(y.id))continue;const w=mb(y);w&&m.push(w)}const v=mj(a,n,h);return{format:Hh,version:lb,exportedAt:o.toISOString(),cells:p,engines:m,...v.length?{models:v}:{}}}function vj(e){let t;try{t=JSON.parse(String(e||""))}catch{return{ok:!1,error:"invalid-json",cells:[],engines:[]}}const n=(t==null?void 0:t.format)===Z2&&(t==null?void 0:t.version)===1,s=(t==null?void 0:t.format)===Hh&&(t==null?void 0:t.version)===2,o=(t==null?void 0:t.format)===Hh&&(t==null?void 0:t.version)===lb,a=n||s,u=s||o;if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(w=>!oj.has(w))||!n&&!s&&!o||!Array.isArray(t.cells)||t.cells.length>ij||u&&(!Array.isArray(t.engines)||t.engines.length>rj))return{ok:!1,error:"invalid-format",cells:[],engines:[]};const h=[],p=new Set;for(const w of t.cells){const b=a?fj(w):fb(w);if(!b)return{ok:!1,error:"invalid-cell",cells:[],engines:[]};if(p.has(b.id))return{ok:!1,error:"duplicate-cell",cells:[],engines:[]};p.add(b.id),h.push(b)}const m=[],v=new Set;for(const w of u?t.engines:[]){const b=pb(w);if(!b)return{ok:!1,error:"invalid-engine",cells:[],engines:[]};if(v.has(b.id))return{ok:!1,error:"duplicate-engine",cells:[],engines:[]};v.add(b.id),m.push(b)}const y=[];if(t.models!==void 0){if(!Array.isArray(t.models)||t.models.length>64)return{ok:!1,error:"invalid-model",cells:[],engines:[]};const w=new Set;for(const b of t.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(C=>!k.has(C)))return{ok:!1,error:"invalid-model",cells:[],engines:[]};const N=typeof b.id=="string"?b.id.trim():"",S=typeof b.engine=="string"?b.engine.trim():"";if(!N||!S)return{ok:!1,error:"invalid-model",cells:[],engines:[]};const j=`${S}::${N}`;if(w.has(j))return{ok:!1,error:"duplicate-model",cells:[],engines:[]};w.add(j),y.push({...b,id:N,engine:S})}}return{ok:!0,cells:h,engines:m,models:y,legacy:a,exportedAt:typeof t.exportedAt=="string"?t.exportedAt:""}}function _j(e,t,n){const s=new Set(n||[]);if(!s.has(t))return null;const o=m=>Object.fromEntries(Object.entries(m||{}).filter(([v])=>s.has(v))),a={id:e.id,engine:t,boot:e.boot===!0,prompt:e.systemPrompt||""};typeof e.label=="string"&&e.label&&(a.label=e.label),typeof e.cwdRel=="string"?a.cwdRel=e.cwdRel:typeof e.cwd=="string"&&e.cwd&&(a.cwd=e.cwd),t===e.engine&&e.model?a.model=e.model:e.models&&e.models[t]&&(a.model=e.models[t]);const u=o(e.models),h=o(e.permissionPolicies),p=o(e.commands);return Object.keys(u).length&&(a.models=u),Object.keys(h).length&&(a.permissionPolicies=h),Object.keys(p).length&&(a.commands=p),a}const yj=()=>({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}),$_=(e="")=>({id:"",cwd:"",engine:e,boot:!1,label:"",model:"",prompt:"",commands:{},command:""}),gb=e=>e==="claude"?"unsafe":"standard",ea=(e,t)=>e.find(n=>n.client===t.client&&n.provider===t.provider&&(n.credentialProfile||"")===(t.credentialProfile||"")),wj=(e,t)=>{var n;return((n=ea(e,t))==null?void 0:n.label)||`${t.client} · ${t.provider}`};function bj(e){var t,n,s,o,a,u,h,p,m,v,y,w,b,k,N;return{kind:e.managed?"managed":"custom",id:e.id,label:e.label||"",command:e.command||"",argsText:(e.args||[]).join(`
|
|
89
|
-
`),rc:!!e.rc,client:((t=e.managed)==null?void 0:t.client)||"claude",provider:((n=e.managed)==null?void 0:n.provider)||"native",credentialProfile:((s=e.managed)==null?void 0:s.credentialProfile)||"",managedModel:((o=e.managed)==null?void 0:o.model)||"",permissionPolicy:((a=e.managed)==null?void 0:a.permissionPolicy)||gb((u=e.managed)==null?void 0:u.client),credentialSourcePolicy:((h=e.managed)==null?void 0:h.credentialSourcePolicy)||"auto",displayName:((p=e.managed)==null?void 0:p.displayName)||"",protocol:((m=e.managed)==null?void 0:m.protocol)||"",baseUrl:((v=e.managed)==null?void 0:v.baseUrl)||"",envKey:((y=e.managed)==null?void 0:y.envKey)||"",providerId:((w=e.managed)==null?void 0:w.providerId)||"nexuscrew-custom",modelOptions:e.availableModels||((b=e.managedInfo)==null?void 0:b.models)||[],promptMode:e.promptMode||"send-keys",promptFlag:e.promptFlag||"",modelFlag:((k=e.model)==null?void 0:k.flag)||"",modelValue:((N=e.model)==null?void 0:N.value)||"",envRows:(e.envKeys||[]).map(S=>({key:S,value:"",configured:!0,remove:!1})),credentialValue:"",credentialReveal:!1,allowMissingCredential:!1}}function Sj(e,t,n=[]){if(e.kind==="managed"){const o={client:e.client,provider:e.provider,model:e.client==="shell"?"":e.managedModel||"",permissionPolicy:e.client==="shell"?"standard":e.permissionPolicy||gb(e.client)};e.credentialProfile&&(o.credentialProfile=e.credentialProfile),e.credentialSourcePolicy&&e.credentialSourcePolicy!=="auto"&&(o.credentialSourcePolicy=e.credentialSourcePolicy);const a=ea(n,e);return(a==null?void 0:a.credentialEnv)===!0&&(o.envKey=e.envKey),e.provider==="custom"&&Object.assign(o,{displayName:e.displayName,protocol:e.protocol,baseUrl:e.baseUrl,envKey:e.envKey,providerId:e.providerId}),{...t?{id:e.id}:{},label:e.label||wj(n,e),rc:!!e.rc,managed:o}}const s={...t?{id:e.id}:{},label:e.label||e.id,rc:!!e.rc,command:e.command,args:e.argsText.split(`
|
|
90
|
-
`).filter(o=>o!==""),promptMode:e.promptMode};return e.modelFlag&&(s.model={flag:e.modelFlag,value:e.modelValue||""}),e.promptMode==="flag"&&(s.promptFlag=e.promptFlag),t&&(s.env=Object.fromEntries(e.envRows.filter(o=>!o.remove&&o.key).map(o=>[o.key,o.value]))),s}function bs({children:e,onClose:t,label:n,error:s=""}){const o=E.useRef(null),a=E.useRef(null),u=E.useRef(t);return u.current=t,E.useEffect(()=>{const h=document.activeElement,p=o.current,m=()=>Array.from((p==null?void 0:p.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [href], [tabindex]:not([tabindex="-1"])'))||[]).filter(w=>w.offsetParent!==null),v=requestAnimationFrame(()=>{var w;return(w=m()[0]||p)==null?void 0:w.focus({preventScroll:!0})}),y=w=>{var S;if(w.key==="Escape"){w.preventDefault(),(S=u.current)==null||S.call(u);return}if(w.key!=="Tab")return;const b=m();if(!b.length){w.preventDefault(),p==null||p.focus();return}const k=b[0],N=b[b.length-1];w.shiftKey&&document.activeElement===k?(w.preventDefault(),N.focus()):!w.shiftKey&&document.activeElement===N&&(w.preventDefault(),k.focus())};return document.addEventListener("keydown",y),()=>{cancelAnimationFrame(v),document.removeEventListener("keydown",y),h&&h.isConnected&&typeof h.focus=="function"&&h.focus({preventScroll:!0})}},[]),E.useEffect(()=>{s&&requestAnimationFrame(()=>{var h;return(h=a.current)==null?void 0:h.scrollIntoView({block:"nearest"})})},[s]),l.jsx("div",{className:"nc-fleet-modal",role:"presentation",onMouseDown:h=>{h.target===h.currentTarget&&t()},children:l.jsxs("div",{ref:o,className:"nc-fleet-modal-dialog",role:"dialog","aria-modal":"true","aria-label":n||f("settings"),tabIndex:-1,children:[e,s&&l.jsx("div",{ref:a,className:"nc-err nc-fleet-modal-error",role:"alert","aria-live":"assertive",children:s})]})})}function Fd({token:e,targets:t=[],readonly:n=!1,onPower:s,onImport:o}){const[a,u]=E.useState([]),[h,p]=E.useState(0);E.useEffect(()=>{let S=!0;async function j(){const $=[{route:[],label:f("local")}].concat((t||[]).map(U=>({route:Array.isArray(U.route)?U.route:[],label:U.label||(U.route||[]).join(" › ")}))),O=await Promise.all($.map(async U=>{const V={...U,available:!1,readonly:!1,capabilities:[],provider:null,cells:[],unmanaged:[],err:""};try{const K=await Rs(e,U.route);V.available=!!K.available,V.capabilities=K.capabilities||[],V.provider=K.provider||null,V.cells=(K.cells||[]).map(Z=>({...Z,route:U.route}));try{V.readonly=!!(await tf(e,U.route)).readonlyDefault}catch{}try{const Z=await ef(e,U.route),G=new Set(V.cells.map(Q=>Q.tmuxSession).filter(Boolean));V.unmanaged=(Z.sessions||[]).filter(Q=>Q&&!G.has(Q.name))}catch{}}catch(K){V.err=String(K&&K.message||K)}return V}));S&&u(O)}j();const C=setInterval(j,6e3);return()=>{S=!1,clearInterval(C)}},[e,t,h]);const m=(S,j)=>Array.isArray(S.capabilities)&&S.capabilities.includes(j)&&!n&&!S.readonly,v=()=>p(S=>S+1),y=(S,j)=>{s&&s({...S,route:j})},w=(S,j)=>{s&&s({...S,route:j})},b=async(S,j)=>{try{await Fo(e,S.cell,j)}catch{}v()},k=async(S,j)=>{if(window.confirm(f("fleet-remove-cell").replace("{id}",S.cell))){try{await iy(e,S.cell,!0,j)}catch{}v()}},N=async(S,j)=>{if(window.confirm(f("terminate-confirm").replace("{name}",S.name))){try{await Jh(e,S.name,j)}catch{}v()}};return l.jsxs("div",{className:"nc-fleet-inventory",children:[l.jsxs("div",{className:"nc-fleet-section-head",children:[l.jsx("b",{children:f("fleet-inventory")}),l.jsx("small",{children:f("fleet-inventory-help")})]}),a.map(S=>{const j=S.route.length?S.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 ${S.available?"on":"warn"}`}),l.jsx("b",{children:S.label}),l.jsx("small",{children:S.available?`${S.cells.length} ${f("fleet-cells")} · ${S.unmanaged.length} ${f("fleet-tmux")}`:S.err||f("fleet-not-available")})]}),S.cells.map(C=>l.jsxs("div",{className:"nc-fleet-item nc-fleet-cell",children:[l.jsxs("span",{children:[l.jsx("b",{children:C.cell}),l.jsx("small",{children:`${C.engine||""}${C.key?`·${C.key}`:""}${C.active?"":` · ${f("cell-off")}`}`})]}),l.jsxs("span",{className:"nc-fleet-cell-actions",children:[C.active&&m(S,"down")&&l.jsx("button",{className:"nc-btn ghost",title:f("power-off"),onClick:()=>w(C,S.route),children:f("stop")}),!C.active&&m(S,"up")&&l.jsx("button",{className:"nc-btn ghost",title:f("power-on"),onClick:()=>y(C,S.route),children:f("start")}),m(S,"restart")&&C.active&&l.jsx("button",{className:"nc-btn ghost",title:f("restart"),onClick:()=>b(C,S.route),children:f("restart")}),m(S,"remove")&&l.jsx("button",{className:"nc-btn danger",title:f("delete"),onClick:()=>k(C,S.route),children:"×"})]})]},`${j}:${C.cell}`)),S.unmanaged.map(C=>l.jsxs("div",{className:"nc-fleet-item nc-fleet-unmanaged",children:[l.jsxs("span",{children:[l.jsx("b",{children:C.name}),l.jsx("small",{children:f("fleet-tmux")})]}),l.jsxs("span",{className:"nc-fleet-cell-actions",children:[m(S,"import")&&o&&l.jsx("button",{className:"nc-btn ghost",title:f("import-as-cell"),onClick:()=>o(C,S.route),children:f("import-as-cell")}),l.jsx("button",{className:"nc-btn danger",title:f("terminate"),onClick:()=>N(C,S.route),children:"×"})]})]},`${j}:u:${C.name}`)),S.available&&S.cells.length===0&&S.unmanaged.length===0&&l.jsx("div",{className:"nc-empty",children:f("fleet-inventory-empty")})]},j)})]})}function xj({cells:e=[],engines:t=[],models:n=[],busy:s,canRestore:o=!1,onRestore:a,onClose:u}){const[h,p]=E.useState("export"),[m,v]=E.useState([]),[y,w]=E.useState(()=>new Set(e.map(D=>D.id))),[b,k]=E.useState(()=>new Set(t.map(D=>D.id))),[N,S]=E.useState([]),[j,C]=E.useState([]),[$,O]=E.useState(""),U=new Set(t.map(D=>D.id)),V=new Set(e.map(D=>D.id)),K=(D,P)=>D(x=>{const M=new Set(x);return M.has(P)?M.delete(P):M.add(P),M}),Z=()=>{const D=gj(e,y,t,b,new Date,n);if(D.ok===!1){O(f(`fleet-backup-${D.error}`));return}const P=e.filter(H=>y.has(H.id)).length,x=t.filter(H=>b.has(H.id)).length;if(D.cells.length!==P){O(f("fleet-backup-invalid-cell"));return}if(D.engines.length!==x){O(f("fleet-backup-invalid-engine"));return}if(!D.cells.length&&!D.engines.length){O(f("fleet-backup-select-one"));return}const M=new Blob([`${JSON.stringify(D,null,2)}
|
|
91
|
-
`],{type:"application/json"}),L=URL.createObjectURL(M),T=document.createElement("a");T.href=L,T.download=`nexuscrew-fleet-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(T),T.click(),T.remove(),setTimeout(()=>URL.revokeObjectURL(L),0),O("")},G=async D=>{if(O(""),S([]),C([]),!!D){if(D.size>1024*1024){O(f("fleet-backup-too-large"));return}try{const P=vj(await D.text());if(!P.ok){O(f(`fleet-backup-${P.error}`));return}v(Array.isArray(P.models)?P.models:[]);const x=new Set(P.engines.map(M=>M.id));C(P.engines.map(M=>({engine:M,exists:U.has(M.id),selected:!U.has(M.id)}))),S(P.cells.map(M=>{const L=U.has(M.engine)||x.has(M.engine),T=V.has(M.id);return{cell:M,engine:L?M.engine:"",selected:L&&!T,exists:T}}))}catch(P){O(String(P.message||P))}}},Q=(D,P)=>S(x=>x.map((M,L)=>L===D?{...M,...P}:M)),F=(D,P)=>C(x=>x.map((M,L)=>L===D?{...M,...P}:M)),B=new Set([...U,...j.filter(D=>D.selected).map(D=>D.engine.id)]),A=N.filter(D=>D.selected&&D.engine&&B.has(D.engine)),z=j.filter(D=>D.selected),I=[...new Map([...t.map(D=>[D.id,D.label||D.id]),...j.filter(D=>D.selected).map(D=>[D.engine.id,D.engine.label||D.engine.id])]).entries()];return l.jsxs("div",{className:"nc-set-form nc-fleet-form nc-backup-dialog",children:[l.jsx("b",{children:f("fleet-backup")}),l.jsx("small",{children:f("fleet-backup-help")}),l.jsxs("div",{className:"nc-set-tabs nc-backup-tabs",children:[l.jsx("button",{type:"button",className:`nc-set-tabbtn${h==="export"?" on":""}`,onClick:()=>{p("export"),O("")},children:f("fleet-backup-export")}),l.jsx("button",{type:"button",className:`nc-set-tabbtn${h==="import"?" on":""}`,disabled:!o,title:o?"":f("fleet-backup-restore-unavailable"),onClick:()=>{p("import"),O("")},children:f("fleet-backup-import")})]}),h==="export"?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{w(new Set(e.map(D=>D.id))),k(new Set(t.map(D=>D.id)))},children:f("select-all")}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{w(new Set),k(new Set)},children:f("select-none")})]}),l.jsxs("div",{className:"nc-backup-list",children:[l.jsx("b",{children:f("fleet-engines")}),t.map(D=>{var P;return l.jsxs("label",{className:"nc-check nc-backup-row",children:[l.jsx("input",{type:"checkbox",checked:b.has(D.id),onChange:()=>K(k,D.id)}),l.jsxs("span",{children:[l.jsx("b",{children:D.label||D.id}),l.jsxs("small",{children:[D.id,(P=D.envKeys)!=null&&P.length?` · ${D.envKeys.length} ${f("fleet-backup-env-names")}`:""]})]})]},D.id)}),l.jsx("b",{children:f("fleet-cells")}),e.map(D=>l.jsxs("label",{className:"nc-check nc-backup-row",children:[l.jsx("input",{type:"checkbox",checked:y.has(D.id),onChange:()=>K(w,D.id)}),l.jsxs("span",{children:[l.jsx("b",{children:D.id}),l.jsxs("small",{children:[D.engine," · ",f("fleet-system-prompt")," ",(D.prompt||"").length," ",f("characters")]})]})]},D.id)),!e.length&&!t.length&&l.jsx("div",{className:"nc-empty",children:f("fleet-backup-empty")})]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:u,children:f("cancel")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:!y.size&&!b.size,onClick:Z,children:f("fleet-backup-download")})]})]}):l.jsxs(l.Fragment,{children:[l.jsx("input",{type:"file",accept:"application/json,.json",disabled:s,onChange:D=>G(D.target.files&&D.target.files[0])}),l.jsx("small",{children:f("fleet-backup-import-help")}),!!(N.length||j.length)&&l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{C(D=>D.map(P=>({...P,selected:!0}))),S(D=>D.map(P=>({...P,selected:!!P.engine})))},children:f("select-all")}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{C(D=>D.map(P=>({...P,selected:!1}))),S(D=>D.map(P=>({...P,selected:!1})))},children:f("select-none")})]}),l.jsxs("div",{className:"nc-backup-list",children:[!!j.length&&l.jsx("b",{children:f("fleet-engines")}),j.map((D,P)=>{var x;return l.jsx("div",{className:"nc-backup-import-row",children:l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:D.selected,onChange:M=>F(P,{selected:M.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:D.engine.label||D.engine.id}),l.jsxs("small",{children:[D.engine.id," · ",D.exists?f("fleet-backup-overwrite"):f("fleet-backup-new"),(x=D.engine.envKeys)!=null&&x.length?` · ${f("fleet-backup-env-values-required")}`:""]})]})]})},D.engine.id)}),!!N.length&&l.jsx("b",{children:f("fleet-cells")}),N.map((D,P)=>l.jsxs("div",{className:"nc-backup-import-row",children:[l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:D.selected,disabled:!D.engine||!B.has(D.engine),onChange:x=>Q(P,{selected:x.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:D.cell.id}),l.jsxs("small",{children:[D.exists?f("fleet-backup-overwrite"):f("fleet-backup-new")," · ",f("fleet-system-prompt")," ",D.cell.systemPrompt.length," ",f("characters")]})]})]}),l.jsxs("select",{value:D.engine,onChange:x=>Q(P,{engine:x.target.value,selected:!!x.target.value}),children:[l.jsx("option",{value:"",children:f("fleet-backup-engine-missing")}),I.map(([x,M])=>l.jsx("option",{value:x,children:M},x))]})]},D.cell.id))]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:u,children:f("cancel")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:s||!A.length&&!z.length,onClick:()=>a({engineRows:j,cellRows:N,models:m}),children:f("fleet-backup-restore")})]})]}),$&&l.jsx("div",{className:"nc-err",children:$})]})}function kj({state:e,setState:t,busy:n,onSave:s,catalog:o}){var j;const a=e.form,u=C=>t({...e,form:{...a,...C}}),h=a.envRows||[],p=[...new Map(o.map(C=>[C.client,C.clientLabel||C.client])).entries()],m=o.filter(C=>C.client===a.client),v=ea(o,a),y=typeof(v==null?void 0:v.credentialEnv)=="string"?v.credentialEnv:"",w=Array.isArray(v==null?void 0:v.credentialUsedBy)?v.credentialUsedBy:[],b=(v==null?void 0:v.credentialSource)||"missing",k=!!(v!=null&&v.credentialEnv)||a.credentialProfile==="a"||a.credentialProfile==="p",N=!!y&&e.mode==="new"&&(v==null?void 0:v.authConfigured)!==!0&&!a.credentialValue&&!a.allowMissingCredential,S=C=>{C&&u({client:C.client,provider:C.provider,credentialProfile:C.credentialProfile||"",managedModel:C.model||"",protocol:C.protocol||"",permissionPolicy:C.permissionPolicyDefault||"standard",credentialSourcePolicy:"auto",rc:!!C.rc,displayName:C.custom?f("fleet-custom-provider-default"):"",baseUrl:C.custom?"":C.endpoint||"",envKey:C.defaultEnvKey||"",providerId:"nexuscrew-custom",credentialValue:"",credentialReveal:!1,allowMissingCredential:!1,...e.mode==="new"?{id:C.id,label:""}:{}})};return l.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[l.jsx("b",{children:e.mode==="new"?f("fleet-new-engine"):`${f("edit")} ${a.id}`}),l.jsx("input",{value:a.id,disabled:e.mode!=="new",placeholder:"id",onChange:C=>u({id:C.target.value})}),l.jsx("input",{value:a.label,placeholder:f("label"),onChange:C=>u({label:C.target.value})}),l.jsxs("select",{value:a.kind,disabled:e.mode!=="new",onChange:C=>u({kind:C.target.value}),children:[l.jsx("option",{value:"managed",children:f("fleet-managed")}),l.jsx("option",{value:"custom",children:f("fleet-custom")})]}),a.kind==="managed"?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"nc-fleet-pair",children:[l.jsx("select",{value:a.client,disabled:e.mode!=="new",onChange:C=>S(o.find($=>$.client===C.target.value&&$.default)||o.find($=>$.client===C.target.value)),children:p.map(([C,$])=>l.jsx("option",{value:C,children:$},C))}),l.jsx("select",{value:((j=ea(o,a))==null?void 0:j.id)||"",disabled:e.mode!=="new",onChange:C=>S(o.find($=>$.id===C.target.value)),children:m.map(C=>l.jsx("option",{value:C.id,children:C.label},C.id))})]}),a.client!=="shell"&&l.jsxs(l.Fragment,{children:[l.jsx("input",{value:a.managedModel,list:"nc-managed-models",placeholder:f(v!=null&&v.requiresModel?"fleet-model-required":"fleet-model-default"),onChange:C=>u({managedModel:C.target.value})}),l.jsx("datalist",{id:"nc-managed-models",children:[...(v==null?void 0:v.models)||[],...a.modelOptions||[]].filter((C,$,O)=>C&&O.indexOf(C)===$).map(C=>l.jsx("option",{value:C},C))})]}),v!=null&&v.supportsUnsafe?l.jsxs("select",{value:a.permissionPolicy,onChange:C=>u({permissionPolicy:C.target.value}),children:[l.jsx("option",{value:"standard",children:f("fleet-standard-permissions")}),l.jsx("option",{value:"unsafe",children:f("fleet-unsafe-permissions")})]}):l.jsx("small",{children:f("fleet-standard-permissions")}),(v==null?void 0:v.supportsUnsafe)&&a.permissionPolicy==="unsafe"&&l.jsx("small",{className:"nc-err",children:f("fleet-unsafe-warning")}),k&&l.jsxs("select",{"aria-label":f("fleet-credential-source-policy"),value:a.credentialSourcePolicy||"auto",onChange:C=>u({credentialSourcePolicy:C.target.value}),children:[l.jsx("option",{value:"auto",children:f("fleet-credential-source-policy-auto")}),l.jsx("option",{value:"nexuscrew-store",children:f("fleet-credential-source-policy-nexuscrew-store")}),l.jsx("option",{value:"environment",children:f("fleet-credential-source-policy-environment")})]}),(v==null?void 0:v.credentialEnv)===!0&&l.jsxs(l.Fragment,{children:[l.jsx("input",{value:a.envKey,placeholder:f("fleet-api-key-env"),onChange:C=>u({envKey:C.target.value})}),l.jsx("small",{children:f("fleet-custom-secret-help")})]}),y&&l.jsxs("section",{className:"nc-fleet-key","aria-label":f("fleet-key-section"),children:[l.jsxs("div",{className:"nc-fleet-key-head",children:[l.jsx("b",{children:f("fleet-key-section")}),l.jsx("span",{children:f(`fleet-credential-source-${b}`)})]}),l.jsxs("label",{className:"nc-field",children:[f("fleet-key-variable"),l.jsx("input",{value:y,readOnly:!0,"aria-label":f("fleet-key-variable")})]}),l.jsx("small",{children:w.length?f("fleet-key-used-by").replace("{engines}",w.join(", ")):f("fleet-key-used-by-none")}),w.length>0&&l.jsx("small",{children:f("fleet-key-shared-impact").replace("{key}",y).replace("{engines}",w.join(", "))}),l.jsxs("div",{className:"nc-fleet-key-input",children:[l.jsx("input",{type:a.credentialReveal?"text":"password",value:a.credentialValue||"","aria-label":f("fleet-key-value").replace("{key}",y),autoComplete:"new-password",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",placeholder:v!=null&&v.authConfigured||e.mode==="edit"?f("fleet-key-blank-keeps"):f("fleet-key-enter"),onChange:C=>u({credentialValue:C.target.value,allowMissingCredential:C.target.value?!1:a.allowMissingCredential})}),l.jsx("button",{type:"button",className:"nc-btn ghost","aria-label":f(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal"),onClick:()=>u({credentialReveal:!a.credentialReveal}),children:f(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal")})]}),l.jsx("small",{children:f("fleet-key-local-help")}),e.mode==="new"&&(v==null?void 0:v.authConfigured)!==!0&&!a.credentialValue&&l.jsxs("label",{className:"nc-check nc-fleet-key-missing",children:[l.jsx("input",{type:"checkbox",checked:!!a.allowMissingCredential,onChange:C=>u({allowMissingCredential:C.target.checked})}),f("fleet-key-create-missing")]}),(v==null?void 0:v.notice)&&l.jsx("small",{className:"nc-fleet-provider-notice",children:f(`fleet-provider-notice-${v.notice}`)})]}),(v==null?void 0:v.notice)&&!y&&l.jsx("small",{className:"nc-fleet-provider-notice",children:f(`fleet-provider-notice-${v.notice}`)}),a.provider==="custom"&&l.jsxs(l.Fragment,{children:[l.jsx("input",{value:a.displayName,placeholder:f("fleet-provider-display"),onChange:C=>u({displayName:C.target.value})}),l.jsx("input",{value:a.baseUrl,placeholder:"https://api.example.com/v1",onChange:C=>u({baseUrl:C.target.value})}),((v==null?void 0:v.protocols)||[]).length>1&&l.jsx("select",{value:a.protocol,onChange:C=>u({protocol:C.target.value}),children:v.protocols.map(C=>l.jsx("option",{value:C,children:C},C))}),l.jsxs("div",{className:"nc-fleet-pair",children:[l.jsx("input",{value:a.envKey,placeholder:f("fleet-api-key-env"),onChange:C=>u({envKey:C.target.value})}),l.jsx("input",{value:a.providerId,placeholder:f("fleet-provider-id"),onChange:C=>u({providerId:C.target.value})})]}),l.jsxs("small",{children:[a.protocol," · ",f("fleet-custom-secret-help")]})]}),l.jsx("small",{children:f(a.client==="shell"?"fleet-shell-engine-help":"fleet-managed-help")})]}):l.jsxs(l.Fragment,{children:[l.jsx("input",{value:a.command,placeholder:f("command-path"),onChange:C=>u({command:C.target.value})}),l.jsx("textarea",{value:a.argsText,placeholder:f("args-lines"),onChange:C=>u({argsText:C.target.value})}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:a.rc,onChange:C=>u({rc:C.target.checked})})," ",f("fleet-remote-control")]}),l.jsxs("select",{value:a.promptMode,onChange:C=>u({promptMode:C.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:C=>u({promptFlag:C.target.value})}),l.jsxs("div",{className:"nc-fleet-pair",children:[l.jsx("input",{value:a.modelFlag,placeholder:"model flag",onChange:C=>u({modelFlag:C.target.value})}),l.jsx("input",{value:a.modelValue,placeholder:"model default",onChange:C=>u({modelValue:C.target.value})})]}),l.jsx("small",{children:f("env-write-only")}),h.map((C,$)=>l.jsxs("div",{className:"nc-fleet-env",children:[l.jsx("input",{value:C.key,disabled:C.configured,placeholder:"ENV_KEY",onChange:O=>{const U=h.slice();U[$]={...C,key:O.target.value},u({envRows:U})}}),l.jsx("input",{type:"password",value:C.value,placeholder:C.configured?"•••••• (unchanged)":"value",onChange:O=>{const U=h.slice();U[$]={...C,value:O.target.value},u({envRows:U})}}),l.jsx("button",{className:"nc-btn danger",onClick:()=>u({envRows:h.filter((O,U)=>U!==$)}),children:"×"})]},`${C.key}-${$}`)),l.jsx("button",{className:"nc-btn ghost",onClick:()=>u({envRows:[...h,{key:"",value:"",configured:!1}]}),children:"+ env"})]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{className:"nc-btn ghost",onClick:()=>t(null),children:f("cancel")}),l.jsx("button",{className:"nc-btn primary",disabled:n||!a.id||N||a.kind==="custom"&&!a.command||a.kind==="managed"&&(v==null?void 0:v.requiresModel)&&!a.managedModel||a.kind==="managed"&&(v==null?void 0:v.credentialEnv)===!0&&!a.envKey||a.kind==="managed"&&a.provider==="custom"&&(!a.displayName||!a.baseUrl||!a.envKey||!a.providerId),onClick:s,children:f("save")})]})]})}function Cj({state:e,setState:t,busy:n,onSave:s,onTest:o,profiles:a=[],canTest:u=!0}){const[h,p]=E.useState(null),[m,v]=E.useState(!1),y=e.form,w=S=>t({...e,form:{...y,...S}}),b=/^[^\x00-\x1f\x7f]{1,128}$/.test(y.id||""),k=!!(y.id||"").trim()&&!!(y.engine||"").trim()&&b,N=async()=>{p(null),v(!0);try{p(await o(y.engine,y.id))}catch(S){p({outcome:"unverified",detail:String(S&&S.message||S)})}v(!1)};return l.jsxs("div",{className:"nc-fleet-form",children:[l.jsxs("label",{className:"nc-field",children:[f("model-editor-engine"),l.jsxs("select",{value:y.engine||"",disabled:n||e.mode==="edit",onChange:S=>{p(null),w({engine:S.target.value})},children:[l.jsx("option",{value:"",children:"—"}),a.map(S=>l.jsx("option",{value:S.id,children:S.label?`${S.id} · ${S.label}`:S.id},S.id))]})]}),l.jsxs("label",{className:"nc-field",children:[f("model-editor-id"),l.jsx("input",{value:y.id||"",disabled:n||e.mode==="edit",placeholder:"qwen3.9-max",onChange:S=>{p(null),w({id:S.target.value})}})]}),l.jsx("small",{className:"nc-set-hint",children:f("model-editor-id-help")}),l.jsxs("label",{className:"nc-field",children:[f("model-editor-context"),l.jsx("input",{inputMode:"numeric",value:y.contextWindow||"",disabled:n,onChange:S=>w({contextWindow:S.target.value.replace(/[^0-9]/g,"").slice(0,9)})})]}),l.jsxs("label",{className:"nc-field",children:[f("model-editor-max-tokens"),l.jsx("input",{inputMode:"numeric",value:y.maxTokens||"",disabled:n,onChange:S=>w({maxTokens:S.target.value.replace(/[^0-9]/g,"").slice(0,9)})})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:y.reasoning===!0,disabled:n,onChange:S=>w({reasoning:S.target.checked})})," ",f("model-editor-reasoning")]}),l.jsxs("div",{className:"nc-set-row",children:[u&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||m||!k,onClick:N,children:f(m?"model-test-running":"model-test")}),h&&l.jsxs("span",{className:`nc-model-test ${h.outcome}`,children:[f(`model-test-${h.outcome}`),h.outcome==="ok"&&Number.isInteger(h.latencyMs)?` · ${h.latencyMs}ms`:""]})]}),h&&h.detail&&l.jsx("small",{className:"nc-set-hint",children:h.detail}),h&&h.outcome==="unverified"&&l.jsx("small",{className:"nc-set-hint",children:f("model-test-unverified-help")}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>t(null),children:f("cancel")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||!k,onClick:()=>s(y),children:f("save")})]})]})}function Ej({token:e,route:t,targets:n=[],location:s,setLocation:o,state:a,setState:u,engines:h,mcpServers:p=[],managedCatalog:m=[],busy:v,onSave:y}){var z,I,D;const[w,b]=E.useState(null),[k,N]=E.useState(""),S=a.form,j=P=>u({...a,form:{...S,...P}}),C=h.find(P=>P.id===S.engine),$=((z=C==null?void 0:C.managed)==null?void 0:z.client)==="shell",O=((I=C==null?void 0:C.managed)==null?void 0:I.client)||"",U=((D=m.find(P=>P.client===O))==null?void 0:D.mcpManaged)!==!1,V=P=>{var L,T,H,Y;const x=h.find(de=>de.id===P),M={...S.commands||{}};((L=C==null?void 0:C.managed)==null?void 0:L.client)==="shell"&&(S.command?M[S.engine]=S.command:delete M[S.engine]),j({engine:P,model:((T=S.models)==null?void 0:T[P])||((H=x==null?void 0:x.managed)==null?void 0:H.model)||((Y=x==null?void 0:x.model)==null?void 0:Y.value)||"",commands:M,command:M[P]||""})},K=P=>{const x={...S.commands||{}};P?x[S.engine]=P:delete x[S.engine],j({command:P,commands:x})},Z=$&&/[|&;<>()`$*?{}\[\]~]/.test(S.command||""),G=[...new Set([...p||[],...Array.isArray(S.mcp)?S.mcp:[]])].sort(),Q=Array.isArray(S.mcp)?S.mcp.length?"some":"none":"all",F=P=>{var x;return j({mcp:P==="all"?void 0:P==="none"?[]:(x=S.mcp)!=null&&x.length?S.mcp:[...G]})},B=P=>{const x=Array.isArray(S.mcp)?S.mcp:[];j({mcp:x.includes(P)?x.filter(M=>M!==P):[...x,P].sort()})},A=async P=>{try{const x=await Zh(e,P,t);b(x),j({cwd:x.path}),N("")}catch(x){N(String(x.message||x))}};return l.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[l.jsx("b",{children:a.mode==="new"?f("fleet-new-cell"):`${f("edit")} ${S.id}`}),a.mode==="new"&&l.jsxs("label",{className:"nc-field",children:[f("location"),l.jsx("span",{className:"nc-req",children:" *"}),l.jsxs("select",{value:s,onChange:P=>{o(P.target.value),j({engine:""})},children:[l.jsx("option",{value:"",children:f("local")}),n.map(P=>l.jsxs("option",{value:P.route.join("/"),disabled:P.status&&P.status!=="up",children:[P.label,P.status&&P.status!=="up"?` · ${f("node-offline")}`:""]},P.route.join("/")))]})]}),l.jsx("input",{value:S.id,disabled:a.mode!=="new",placeholder:"id",onChange:P=>j({id:P.target.value})}),l.jsx("input",{value:S.label||"",maxLength:64,placeholder:f("fleet-cell-label"),onChange:P=>j({label:P.target.value})}),l.jsxs("div",{className:"nc-fleet-pair",children:[l.jsx("input",{value:S.cwd,placeholder:f("cwd"),onChange:P=>j({cwd:P.target.value})}),l.jsx("button",{className:"nc-btn ghost",onClick:()=>w?b(null):A(S.cwd),children:f("browse")})]}),w&&l.jsxs("div",{className:"nc-fs",children:[l.jsx("div",{className:"nc-fs-path",children:w.path}),l.jsxs("div",{className:"nc-fs-list",children:[w.parent&&l.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>A(w.parent),children:["↑ ",f("fs-parent")]}),(w.dirs||[]).map(P=>l.jsxs("button",{className:"nc-fs-item",onClick:()=>A(`${w.path.replace(/\/$/,"")}/${P}`),children:["📁 ",P]},P))]})]}),k&&l.jsx("div",{className:"nc-err",children:k}),l.jsx("select",{value:S.engine,onChange:P=>V(P.target.value),children:h.map(P=>l.jsx("option",{value:P.id,children:P.label},P.id))}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:!!S.boot,onChange:P=>j({boot:P.target.checked})})," ",f("fleet-boot")]}),$?l.jsxs(l.Fragment,{children:[l.jsx("input",{value:S.command||"",maxLength:4096,placeholder:f("fleet-shell-command-placeholder"),onChange:P=>K(P.target.value)}),l.jsx("small",{children:S.command?f("fleet-shell-command-help"):f("fleet-shell-interactive")}),Z&&l.jsx("small",{className:"nc-note",children:f("fleet-shell-command-metachar")})]}):l.jsxs(l.Fragment,{children:[l.jsx("input",{value:S.model||"",list:"nc-cell-models",placeholder:f("fleet-model-override"),onChange:P=>j({model:P.target.value})}),l.jsx("datalist",{id:"nc-cell-models",children:((C==null?void 0:C.availableModels)||[]).map(P=>l.jsx("option",{value:P},P))}),l.jsx("textarea",{value:S.prompt||"",placeholder:f("cell-prompt"),onChange:P=>j({prompt:P.target.value})}),l.jsx("small",{children:f("cell-prompt-help")}),l.jsxs("label",{className:"nc-field",children:[f("cell-mcp"),l.jsxs("select",{value:Q,onChange:P=>F(P.target.value),children:[l.jsx("option",{value:"all",children:f("cell-mcp-all")}),l.jsx("option",{value:"none",children:f("cell-mcp-none")}),l.jsx("option",{value:"some",children:f("cell-mcp-some")})]})]}),!U&&l.jsx("small",{className:"nc-note",children:f("cell-mcp-inert")}),Q==="some"&&l.jsx("div",{className:"nc-fleet-mcp-list",children:G.map(P=>l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:(S.mcp||[]).includes(P),onChange:()=>B(P)})," ",P]},P))}),l.jsx("small",{children:f("cell-mcp-help")})]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{className:"nc-btn ghost",onClick:()=>u(null),children:f("cancel")}),l.jsx("button",{className:"nc-btn primary",disabled:v||!S.id||!S.cwd||!S.engine,onClick:y,children:f("save")})]})]})}function F_({token:e,route:t=[],state:n,setState:s,busy:o,onSave:a}){const[u,h]=E.useState(null),[p,m]=E.useState([]),[v,y]=E.useState(""),w=Array.isArray(t)?t.join("/"):"";E.useEffect(()=>{let j=!0;return Jl(e,w?w.split("/"):[]).then(C=>{j&&(m(C.engines||[]),y(""))}).catch(C=>{j&&(m([]),y(String(C.message||C)))}),()=>{j=!1}},[e,w]);const b=n.form,k=j=>s({...n,form:{...b,...j}}),N=async j=>{try{const C=await Zh(e,j,t);h(C),k({cwd:C.path})}catch{}},S=!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:[f("import-as-cell")," · ",b.tmuxSession]}),l.jsx("small",{children:f("import-help")}),l.jsx("input",{value:b.tmuxSession,disabled:!0,placeholder:"tmux session",readOnly:!0}),l.jsx("input",{value:b.id,placeholder:f("name"),onChange:j=>k({id:j.target.value})}),l.jsxs("div",{className:"nc-fleet-pair",children:[l.jsx("input",{value:b.cwd,placeholder:f("cwd"),onChange:j=>k({cwd:j.target.value})}),l.jsx("button",{className:"nc-btn ghost",type:"button",onClick:()=>u?h(null):N(b.cwd),children:f("browse")})]}),u&&l.jsxs("div",{className:"nc-fs",children:[l.jsx("div",{className:"nc-fs-path",children:u.path}),l.jsxs("div",{className:"nc-fs-list",children:[u.parent&&l.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>N(u.parent),children:["↑ ",f("fs-parent")]}),(u.dirs||[]).map(j=>l.jsxs("button",{className:"nc-fs-item",onClick:()=>N(`${u.path.replace(/\/$/,"")}/${j}`),children:["📁 ",j]},j))]})]}),l.jsxs("select",{value:b.engine,onChange:j=>k({engine:j.target.value}),children:[l.jsx("option",{value:"",children:f("import-engine-required")}),p.map(j=>l.jsx("option",{value:j.id,children:j.label},j.id))]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:!!b.boot,onChange:j=>k({boot:j.target.checked})})," ",f("fleet-boot")]}),(n.err||v)&&l.jsx("div",{className:"nc-err",children:n.err||v}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{className:"nc-btn ghost",onClick:()=>s(null),children:f("cancel")}),l.jsx("button",{className:"nc-btn primary",disabled:o||!b.tmuxSession||!b.engine||!p.length,onClick:a,children:f(S?"import-as-cell":"save")})]})]})}function El(e){const t=Ys(e);return t===null?`~/${e}`:t?`~/${t}`:"~"}function Nj(e){if(!e||typeof e.path!="string"||typeof e.home!="string")return"";const{path:t,home:n}=e;return!n||t===n||!t.startsWith(n+"/")?"":t.slice(n.length+1).replace(/\/+$/,"")}function jj({token:e,route:t,cell:n,busy:s=!1,onSaved:o,onClose:a}){const[u,h]=E.useState(""),[p,m]=E.useState(null),[v,y]=E.useState(!1),[w,b]=E.useState(""),k=typeof(n==null?void 0:n.cwdSuggestion)=="string"&&Ys(n.cwdSuggestion)!==null?Ys(n.cwdSuggestion):null,[N,S]=E.useState(k),j=n==null?void 0:n.id,C=s||v,$=async G=>{const Q=Ys(G);if(Q===null){m({rel:"",dirs:[],loading:!1,err:f("fleet-cwd-repair-invalid")});return}m({rel:Q,dirs:[],loading:!0,err:""});try{const F=await Zh(e,Q,t),B=Nj(F);m({rel:B,dirs:Array.isArray(F.dirs)?F.dirs:[],loading:!1,err:""})}catch(F){m({rel:Q,dirs:[],loading:!1,err:String(F&&F.message||F)})}},O=G=>{if(!p)return;const Q=p.rel?`${p.rel}/${G}`:G;$(Q)},U=()=>{p!=null&&p.rel&&$(p.rel.split("/").slice(0,-1).join("/"))},V=()=>{p&&(h(p.rel||""),m(null),b(""),S(null))},K=()=>{N!==null&&(h(N),S(null),b(""))},Z=async()=>{if(C)return;const G=Ys(u);if(G===null){b(f("fleet-cwd-repair-invalid"));return}const Q=El(G);let F=!0;try{F=window.confirm(f("fleet-cwd-repair-confirm").replace("{id}",String(j||"")).replace("{path}",Q))}catch{F=!1}if(F){y(!0),b(""),S(null);try{const B=await ny(e,j,{cwdRel:G},t);o==null||o(B)}catch(B){const A=B&&B.data||{};if(A.code==="unportable-cwd"){b(f("fleet-cwd-repair-unportable"));const z=Array.isArray(A.cells)?A.cells.find(D=>D&&D.id===j):null,I=z&&typeof z.suggestion=="string"?z.suggestion:null;I!==null&&Ys(I)!==null&&S(I)}else b(String(B&&B.message||B))}finally{y(!1)}}};return l.jsxs("div",{className:"nc-set-form nc-fleet-form nc-cwd-repair",children:[l.jsx("b",{children:f("fleet-cwd-repair-title").replace("{id}",String(j||""))}),l.jsx("small",{className:"nc-set-info",children:f("fleet-cwd-repair-help")}),l.jsx("small",{className:"nc-cwd-no-source",children:f("fleet-cwd-repair-no-source-path")}),l.jsxs("label",{className:"nc-field",children:[f("cwd"),l.jsxs("div",{className:"nc-cwd-rel-row",children:[l.jsx("span",{className:"nc-cwd-rel-prefix",children:"~/"}),l.jsx("input",{value:u,placeholder:f("fleet-cwd-repair-placeholder"),autoComplete:"off",spellCheck:"false",autoCapitalize:"none",onChange:G=>h(G.target.value)}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:C,onClick:()=>p?m(null):$(""),children:f(p?"close":"fleet-cwd-repair-browse")})]})]}),l.jsx("div",{className:"nc-cwd-preview",children:f("fleet-cwd-repair-preview").replace("{path}",El(u))}),p&&l.jsxs("div",{className:"nc-fs",children:[l.jsx("div",{className:"nc-fs-path",children:El(p.rel)}),l.jsxs("div",{className:"nc-fs-list",children:[p.rel&&l.jsxs("button",{type:"button",className:"nc-fs-item nc-fs-nav",onClick:U,children:["↑ ",f("fs-parent")]}),p.loading&&l.jsx("div",{className:"nc-fs-empty",children:"…"}),!p.loading&&p.dirs.length===0&&l.jsx("div",{className:"nc-fs-empty",children:f("fleet-cwd-repair-fs-empty")}),!p.loading&&p.dirs.map(G=>l.jsxs("button",{type:"button",className:"nc-fs-item",onClick:()=>O(G),children:["📁 ",G]},G))]}),p.err&&l.jsx("div",{className:"nc-err",children:p.err}),l.jsx("div",{className:"nc-sheet-actions",children:l.jsx("button",{type:"button",className:"nc-btn primary",disabled:C||p.loading||!!p.err,onClick:V,children:f("fleet-cwd-repair-use-current")})})]}),w&&l.jsx("div",{className:"nc-err",role:"alert",children:w}),N!==null&&l.jsxs("div",{className:"nc-cwd-suggestion",role:"status",children:[l.jsx("span",{children:f("fleet-cwd-repair-suggestion")}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:K,children:f("fleet-cwd-repair-use-suggestion").replace("{path}",El(N))})]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:v,onClick:a,children:f("cancel")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:C,onClick:Z,children:v?"…":f("save")})]})]})}function Rj({token:e,readonly:t,targets:n=[],startNewCell:s=!1,initialLocation:o=""}){const[a,u]=E.useState({engines:[],cells:[],managedCatalog:[]}),[h,p]=E.useState({available:!1,capabilities:[]}),[m,v]=E.useState(!1),[y,w]=E.useState(null),[b,k]=E.useState(null),[N,S]=E.useState({}),[j,C]=E.useState(null),[$,O]=E.useState(!1),[U,V]=E.useState(""),[K,Z]=E.useState(""),[G,Q]=E.useState(o),[F,B]=E.useState(!1),[A,z]=E.useState(null),[I,D]=E.useState(null),[P,x]=E.useState(null),[M,L]=E.useState(!1),[T,H]=E.useState([]),[Y,de]=E.useState(null),[ue,fe]=E.useState("manage"),ve=E.useRef(!1),ie=G?G.split("/"):[],ye=E.useCallback(async()=>{try{const te=await Rs(e,ie);p(te);try{const we=await tf(e,ie);B(!!we.readonlyDefault)}catch{B(!1)}if(te.provider==="builtin"&&(te.capabilities||[]).includes("definitions")){const we=await Jl(e,ie),Ne=new Map((te.engines||[]).map(De=>[De.id,De]));if(we.engines=(we.engines||[]).map(De=>{var Oe;return{...De,availableModels:((Oe=Ne.get(De.id))==null?void 0:Oe.models)||[]}}),u(we),(te.capabilities||[]).includes("credentials"))try{H((await N0(e,ie)).credentials||[])}catch{H([])}else H([])}V("")}catch(te){V(String(te.message||te))}finally{v(!0)}},[e,G]);E.useEffect(()=>{ye();const te=setInterval(ye,5e3);return()=>clearInterval(te)},[ye]);const Ue=new Set((h.cells||[]).filter(te=>te.active).map(te=>te.cell)),ut=h.provider==="builtin"&&(h.capabilities||[]).includes("edit"),rt=(h.capabilities||[]).includes("restore");E.useEffect(()=>{!s||ve.current||!ut||!a.engines.length||(ve.current=!0,C({mode:"new",form:$_(a.engines[0].id)}))},[s,ut,a.engines]);const Ae=async te=>{O(!0),V(""),Z("");try{await te(),await ye()}catch(we){V(String(we.message||we))}O(!1)},Dt=async(te,we)=>{const Ne=await M0(e,te,we,ie);return S(De=>({...De,[`${te}::${we}`]:Ne})),Ne},Qt=te=>Ae(async()=>{const we={id:String(te.id||"").trim(),engine:String(te.engine||"").trim()};for(const Ne of["contextWindow","maxTokens"]){const De=String(te[Ne]||"").trim();De&&(we[Ne]=Number(De))}te.reasoning===!0&&(we.reasoning=!0),await L0(e,we,ie),k(null),await ye()}),$e=()=>Ae(async()=>{var pe;const te=y.mode==="new",we=y.form,Ne=a.managedCatalog||[],De=we.kind==="managed"?ea(Ne,we):null,Oe=typeof(De==null?void 0:De.credentialEnv)=="string"?De.credentialEnv:"",_t=Oe&&we.credentialValue||"",yt=Sj(we,te,Ne);!te&&y.form.kind==="custom"&&!y.form.modelFlag&&(yt.model=null),!te&&y.form.kind==="custom"&&y.form.promptMode!=="flag"&&(yt.promptFlag=null);let X;if(te)X=await R0(e,yt,ie);else{const _e=y.original,Be=new Set(y.form.envRows.filter(Ge=>!Ge.remove).map(Ge=>Ge.key)),me=(_e.envKeys||[]).filter(Ge=>!Be.has(Ge)),Ce=Object.fromEntries(y.form.envRows.filter(Ge=>!Ge.remove&&Ge.key&&(!Ge.configured||Ge.value!=="")).map(Ge=>[Ge.key,Ge.value]));X=await P0(e,_e.id,yt,y.form.kind==="custom"?{set:Ce,remove:me}:void 0,ie)}let se=null;if(Oe&&_t)try{se=await Sg(e,Oe,_t,ie),H(se.credentials||[])}catch{throw await ye(),te&&w({mode:"edit",original:{...yt,id:we.id},form:{...we,credentialReveal:!1}}),new Error(f(te?"fleet-key-partial-create":"fleet-key-partial-edit"))}await ye(),w(null),Z(f("fleet-saved"));const W=((pe=((se==null?void 0:se.credentials)||[]).find(_e=>_e.envKey===Oe))==null?void 0:pe.activeCells)||[],oe=[...new Set([...(X==null?void 0:X.activeCells)||[],...W])];if(oe.length&&window.confirm(f("fleet-restart-confirm").replace("{cells}",oe.join(", "))))for(const _e of oe)await Fo(e,_e,ie)}),dt=()=>Ae(async()=>{var se,W,oe,pe,_e,Be;const te=j.mode==="new",we=j.form,Ne={...te?{id:we.id}:{},cwd:we.cwd,engine:we.engine,boot:!!we.boot},De={...we.commands||{}},Oe=a.engines.find(me=>me.id===we.engine);((se=Oe==null?void 0:Oe.managed)==null?void 0:se.client)==="shell"&&typeof we.command=="string"&&we.command.length?De[we.engine]=we.command:((W=Oe==null?void 0:Oe.managed)==null?void 0:W.client)==="shell"&&delete De[we.engine],(Object.keys(De).length||!te)&&(Ne.commands=De);const _t=(we.label||"").trim();te?_t&&(Ne.label=_t):Ne.label=_t||null,te?Array.isArray(we.mcp)&&(Ne.mcp=we.mcp):Ne.mcp=Array.isArray(we.mcp)?we.mcp:null,te?(((oe=Oe==null?void 0:Oe.managed)==null?void 0:oe.client)!=="shell"&&we.model&&(Ne.model=we.model),((pe=Oe==null?void 0:Oe.managed)==null?void 0:pe.client)!=="shell"&&we.prompt&&(Ne.prompt=we.prompt)):(Ne.model=((_e=Oe==null?void 0:Oe.managed)==null?void 0:_e.client)==="shell"?null:we.model||null,((Be=Oe==null?void 0:Oe.managed)==null?void 0:Be.client)!=="shell"&&(Ne.prompt=we.prompt||null));const yt=te?await D0(e,Ne,ie):await ny(e,j.original.id,Ne,ie),X=te?we.id:j.original.id;C(null),Z(f("fleet-saved")),!te&&(yt!=null&&yt.active)&&window.confirm(f("fleet-restart-confirm").replace("{cells}",X))&&await Fo(e,X,ie)}),it=t||F,wt=h.capabilities||[],bt=ie.length>0&&it,mt=te=>T.find(we=>{var Ne;return(Ne=we.engines)==null?void 0:Ne.includes(te.id)})||null,gt=()=>Ae(async()=>{var Ne;const te=await Sg(e,Y.envKey,Y.value,ie);H(te.credentials||[]),de(null),Z(f("fleet-credential-saved"));const we=((Ne=(te.credentials||[]).find(De=>De.envKey===Y.envKey))==null?void 0:Ne.activeCells)||[];if(we.length&&window.confirm(f("fleet-restart-confirm").replace("{cells}",we.join(", "))))for(const De of we)await Fo(e,De,ie)}),pt=te=>Ae(async()=>{if(!window.confirm(f("fleet-credential-remove-confirm").replace("{key}",te.envKey)))return;const we=await j0(e,te.envKey,ie);H(we.credentials||[]),Z(f("fleet-credential-removed"))}),Pt=te=>z({...te,route:Array.isArray(te==null?void 0:te.route)?te.route:ie}),vt=async te=>{if(!A)return;const we=A.cell||A.id,Ne=Array.isArray(A.route)?A.route:ie;if(te.action==="up"){const De=await Qh(e,{cell:we,boot:!!te.boot,...te.engine?{engine:te.engine}:{},...te.model!==void 0?{model:te.model}:{},...te.permissionPolicy?{permissionPolicy:te.permissionPolicy}:{}},Ne),Oe=ff(De);Oe&&Z(Oe.text)}else await Il(e,{cell:we,boot:!!te.boot},Ne)},xt=(te,we)=>{V(""),D({mode:"new",route:Array.isArray(we)?we:ie,form:{tmuxSession:te.name,id:"",engine:"",cwd:"",boot:!1},err:""})},Se=()=>Ae(async()=>{const te=I.form;if(!te.engine){D({...I,err:f("import-engine-required")});return}await I0(e,{tmuxSession:te.tmuxSession,id:te.id||void 0,engine:te.engine,cwd:te.cwd||void 0,boot:!!te.boot},te.route||ie),D(null),Z(f("fleet-saved"))}),le=({engineRows:te=[],cellRows:we=[],models:Ne=[]})=>Ae(async()=>{const De=te.filter(_e=>_e.selected),Oe=De.map(_e=>mb(_e.engine));if(Oe.some(_e=>!_e))throw new Error(f("fleet-backup-invalid-engine"));const _t=De.filter(_e=>_e.exists).map(_e=>_e.engine.id);if(_t.length&&!window.confirm(f("fleet-backup-confirm-engine-overwrite").replace("{engines}",_t.join(", "))))return;const yt=[...new Set([...a.engines.map(_e=>_e.id),...Oe.map(_e=>_e.id)])],X=[];for(const _e of we.filter(Be=>Be.selected)){const Be=_j(_e.cell,_e.engine,yt);if(!Be)throw new Error(`${_e.cell.id}: ${f("fleet-backup-engine-missing")}`);X.push(Be)}const se=we.filter(_e=>_e.selected&&_e.exists).map(_e=>_e.cell.id);if(se.length&&!window.confirm(f("fleet-backup-confirm-overwrite").replace("{cells}",se.join(", "))))return;const W=Oe.length?await B0(e,Oe,_t.length>0,ie,Ne):{needsRestart:[]},oe=X.length?await O0(e,X,ie):{needsRestart:[]},pe=[...new Set([...W.needsRestart||[],...oe.needsRestart||[]])];L(!1),Z(`${f("fleet-backup-restored").replace("{n}",String(X.length))}${Oe.length?` · ${Oe.length} ${f("fleet-engines").toLowerCase()}`:""}${pe.length?` · ${f("fleet-backup-needs-restart").replace("{cells}",pe.join(", "))}`:""}`)}),Pe=l.jsxs("label",{className:"nc-field",children:[f("location"),l.jsxs("select",{value:G,onChange:te=>{Q(te.target.value),w(null),C(null),V(""),Z(""),B(!1),v(!1),p({available:!1,capabilities:[]}),u({engines:[],cells:[],managedCatalog:[]}),H([]),de(null)},children:[l.jsx("option",{value:"",children:f("local")}),n.map(te=>l.jsxs("option",{value:te.route.join("/"),disabled:te.status&&te.status!=="up",children:[te.label,te.status&&te.status!=="up"?` · ${f("node-offline")}`:""]},te.route.join("/")))]})]}),We=l.jsxs("div",{className:"nc-fleet-view-tabs",role:"tablist","aria-label":f("tab-fleet"),children:[l.jsx("button",{type:"button",role:"tab","aria-selected":ue==="manage",className:`nc-set-tabbtn${ue==="manage"?" on":""}`,onClick:()=>fe("manage"),children:f("fleet-manage-location")}),l.jsx("button",{type:"button",role:"tab","aria-selected":ue==="overview",className:`nc-set-tabbtn${ue==="overview"?" on":""}`,onClick:()=>fe("overview"),children:f("fleet-network-overview")})]});return m?ut?l.jsxs("div",{className:"nc-set-tab nc-fleet-editor",children:[We,ue==="overview"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-set-info",children:f("fleet-overview-help")}),l.jsx(Fd,{token:e,targets:n,readonly:t,onPower:Pt,onImport:xt})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-set-info",children:f("fleet-manage-help")}),Pe,l.jsxs("div",{className:"nc-set-row nc-fleet-backup-actions",children:[l.jsx("button",{className:"nc-btn ghost",disabled:it||$,onClick:()=>{V(""),L(!0)},children:f("fleet-backup")}),l.jsx("small",{children:f("fleet-backup-help")})]}),l.jsxs("div",{className:"nc-fleet-section-head",children:[l.jsx("b",{children:f("fleet-cells")}),l.jsx("span",{className:"nc-fleet-head-actions",children:l.jsxs("button",{className:"nc-btn primary",disabled:it||$||!a.engines.length,onClick:()=>{var te;V(""),C({mode:"new",form:$_((te=a.engines[0])==null?void 0:te.id)})},children:["+ ",f("add")]})})]}),a.cells.map(te=>{const we=Ue.has(te.id),Ne=te.needsRepair===!0;return l.jsxs("div",{className:"nc-fleet-item",children:[l.jsxs("span",{children:[l.jsx("b",{children:te.id}),te.label?l.jsxs("small",{className:"nc-fleet-label",children:[" ",te.label]}):null,l.jsxs("small",{children:[te.engine," · ",Ne?l.jsx("span",{className:"nc-fleet-tag nc-fleet-tag-warn",children:f("fleet-cwd-needs-repair")}):te.cwd,we?` · ${f("service-active")}`:` · ${f("cell-off")}`]})]}),l.jsxs("span",{children:[we&&wt.includes("down")&&l.jsx("button",{className:"nc-btn ghost",disabled:it||$,onClick:()=>Ae(()=>Il(e,{cell:te.id},ie)),children:f("stop")}),!we&&wt.includes("up")&&l.jsx("button",{className:"nc-btn primary",disabled:it||$,onClick:()=>Pt({cell:te.id,id:te.id,engine:te.engine,model:te.model,models:te.models,permissionPolicies:te.permissionPolicies,active:!1,boot:te.boot}),children:f("start")}),we&&wt.includes("restart")&&l.jsx("button",{className:"nc-btn ghost",disabled:it||$,onClick:()=>Ae(()=>Fo(e,te.id,ie)),children:f("restart")}),Ne?l.jsx("button",{className:"nc-btn ghost",disabled:it||$,onClick:()=>{V(""),x(te)},children:f("fleet-cwd-repair")}):l.jsx("button",{className:"nc-btn ghost",disabled:it||$,onClick:()=>{var De;V(""),C({mode:"edit",original:te,form:{...te,commands:{...te.commands||{}},command:((De=te.commands)==null?void 0:De[te.engine])||""}})},children:f("edit")}),l.jsx("button",{className:"nc-btn danger",disabled:it||$,onClick:()=>Ae(async()=>{window.confirm(f("fleet-remove-cell").replace("{id}",te.id))&&await iy(e,te.id,!0,ie)}),children:"×"})]})]},te.id)}),l.jsxs("div",{className:"nc-fleet-section-head",children:[l.jsx("b",{children:f("fleet-engines")}),l.jsxs("button",{className:"nc-btn primary",disabled:it||$,onClick:()=>{V(""),w({mode:"new",form:yj()})},children:["+ ",f("add")]})]}),a.engines.map(te=>{var Ne,De;const we=mt(te);return l.jsxs("div",{className:"nc-fleet-item",children:[l.jsxs("span",{children:[l.jsx("b",{children:te.label}),l.jsx("small",{children:te.managed?`${te.id} · ${te.managed.client} / ${te.managed.provider} · ${(Ne=te.managedInfo)!=null&&Ne.configured?f("fleet-ready"):((De=te.managedInfo)==null?void 0:De.reason)||f("fleet-not-ready")}`:`${te.id} · ${te.command}`}),we&&l.jsxs("small",{children:[we.envKey," · ",f(`fleet-credential-source-${we.source||"missing"}`)]})]}),l.jsxs("span",{children:[we&&l.jsx("button",{className:"nc-btn ghost",disabled:it||$,onClick:()=>{V(""),de({envKey:we.envKey,value:""})},children:we.configured?f("fleet-credential-change"):f("fleet-credential-set")}),(we==null?void 0:we.source)==="local"&&l.jsx("button",{className:"nc-btn danger",disabled:it||$,onClick:()=>pt(we),children:f("fleet-credential-forget")}),l.jsx("button",{className:"nc-btn ghost",disabled:it||$,onClick:()=>{V(""),w({mode:"edit",original:te,form:bj(te)})},children:f("edit")}),l.jsx("button",{className:"nc-btn danger",disabled:it||$,onClick:()=>Ae(async()=>{window.confirm(f("fleet-remove-engine").replace("{id}",te.id))&&await A0(e,te.id,ie)}),children:"×"})]})]},te.id)}),l.jsxs("div",{className:"nc-fleet-section-head",children:[l.jsx("b",{children:f("fleet-models")}),l.jsxs("button",{className:"nc-btn primary",disabled:it||$,onClick:()=>{V(""),k({mode:"new",form:{id:"",engine:""}})},children:["+ ",f("add")]})]}),!(a.models||[]).length&&l.jsx("small",{className:"nc-set-hint",children:f("fleet-no-models")}),(a.models||[]).map(te=>{const we=`${te.engine}::${te.id}`,Ne=N[we],De=(a.engines||[]).some(Oe=>Oe.managed&&Oe.managed.model===te.id);return l.jsxs("div",{className:"nc-fleet-item",children:[l.jsxs("span",{children:[l.jsx("b",{children:te.id}),l.jsxs("small",{children:[te.engine,te.contextWindow?` · ${te.contextWindow}`:"",De?` · ${f("model-in-use")}`:""]}),Ne&&l.jsxs("small",{className:`nc-model-test ${Ne.outcome}`,children:[f(`model-test-${Ne.outcome}`),Ne.outcome==="ok"&&Number.isInteger(Ne.latencyMs)?` · ${Ne.latencyMs}ms`:""]})]}),l.jsxs("span",{children:[wt.includes("model-test")&&l.jsx("button",{className:"nc-btn ghost",disabled:$||bt,onClick:()=>Ae(()=>Dt(te.engine,te.id)),children:f("model-test")}),l.jsx("button",{className:"nc-btn danger",disabled:it||$,onClick:()=>Ae(()=>T0(e,te.id,te.engine,ie)),children:"×"})]})]},we)})]}),b&&l.jsx(bs,{onClose:()=>k(null),label:f("fleet-models"),error:U,children:l.jsx(Cj,{state:b,setState:k,busy:$,onSave:Qt,onTest:Dt,profiles:a.managedCatalog||[],canTest:wt.includes("model-test")&&!bt})}),y&&l.jsx(bs,{onClose:()=>w(null),label:f("fleet-new-engine"),error:U,children:l.jsx(kj,{state:y,setState:w,busy:$,onSave:$e,catalog:a.managedCatalog||[]})}),j&&l.jsx(bs,{onClose:()=>C(null),label:f("fleet-new-cell"),error:U,children:l.jsx(Ej,{token:e,route:ie,targets:n,location:G,setLocation:Q,state:j,setState:C,engines:a.engines,mcpServers:a.mcpServers||[],managedCatalog:a.managedCatalog||[],busy:$,onSave:dt})}),P&&l.jsx(bs,{onClose:()=>x(null),label:f("fleet-cwd-repair-title").replace("{id}",P.id),error:"",children:l.jsx(jj,{token:e,route:ie,cell:P,busy:$,onSaved:async()=>{x(null),Z(f("fleet-cwd-repaired")),await ye()},onClose:()=>x(null)})}),K&&l.jsx("div",{className:"nc-set-note",children:K}),U&&l.jsx("div",{className:"nc-err",children:U}),M&&l.jsx(bs,{onClose:()=>L(!1),label:f("fleet-backup"),error:U,children:l.jsx(xj,{cells:a.cells,engines:a.engines,models:a.models||[],busy:$,canRestore:rt,onRestore:le,onClose:()=>L(!1)})}),Y&&l.jsx(bs,{onClose:()=>de(null),label:f("fleet-credential-title"),error:U,children:l.jsxs("div",{className:"nc-fleet-form nc-credential-form",children:[l.jsx("b",{children:f("fleet-credential-title")}),l.jsx("small",{children:f("fleet-credential-help")}),l.jsxs("label",{className:"nc-field",children:[Y.envKey,l.jsx("input",{type:"password",autoComplete:"off",spellCheck:"false",autoCapitalize:"none",value:Y.value,onChange:te=>de({...Y,value:te.target.value})})]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{className:"nc-btn ghost",onClick:()=>de(null),children:f("cancel")}),l.jsx("button",{className:"nc-btn primary",disabled:$||!Y.value,onClick:gt,children:f("save")})]})]})}),I&&l.jsx(bs,{onClose:()=>D(null),label:f("import-as-cell"),error:U,children:l.jsx(F_,{token:e,route:I.route||ie,state:I,setState:D,busy:$,onSave:Se})}),A&&l.jsx(Bl,{cell:A,token:e,route:Array.isArray(A.route)?A.route:ie,onConfirm:async te=>{try{await vt(te)}finally{await ye()}},onClose:()=>z(null)})]}):l.jsxs("div",{className:"nc-set-tab",children:[We,ue==="overview"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-set-info",children:f("fleet-overview-help")}),l.jsx(Fd,{token:e,targets:n,readonly:t,onPower:Pt,onImport:xt})]}):l.jsxs(l.Fragment,{children:[Pe,l.jsxs("div",{className:"nc-set-info",children:[f(U?"fleet-editor-load-error":"fleet-editor-unavailable"),!U&&h.reason?` ${h.reason}`:""]})]}),U&&l.jsx("div",{className:"nc-err",children:U}),I&&l.jsx(bs,{onClose:()=>D(null),label:f("import-as-cell"),error:U,children:l.jsx(F_,{token:e,route:I.route||ie,state:I,setState:D,busy:$,onSave:Se})}),A&&l.jsx(Bl,{cell:A,token:e,route:Array.isArray(A.route)?A.route:ie,onConfirm:async te=>{try{await vt(te)}finally{await ye()}},onClose:()=>z(null)})]}):l.jsxs("div",{className:"nc-set-tab",children:[We,ue==="overview"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-set-info",children:f("fleet-overview-help")}),l.jsx(Fd,{token:e,targets:n,readonly:t,onPower:Pt,onImport:xt})]}):l.jsxs(l.Fragment,{children:[Pe,l.jsx("div",{className:"nc-set-info",children:f("fleet-editor-loading")})]})]})}const $f="nc_notification_speech_v1",Nl="nc-notification-speech",Uh="nc-notification-speech-preview",Pj=320,Aj=2,Lj=3e4,Tj=1e4,Mj=6e4,Dj=64,H_=Object.freeze({enabled:!1}),Ij=Object.freeze({it:"it-IT",en:"en-US",es:"es-ES"}),Oj=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"])}),Ff=new WeakSet;function Hf(e){return{enabled:(e&&typeof e=="object"&&!Array.isArray(e)?e:{}).enabled===!0}}function vb(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function U_(e=vb()){if(!e)return{...H_};try{return Hf(JSON.parse(e.getItem($f)||"null"))}catch{return{...H_}}}function Bj(e,t=vb()){const n=Hf(e);if(t)try{t.setItem($f,JSON.stringify(n))}catch{}return n}function Vr(){try{return typeof window<"u"?window:null}catch{return null}}function ta(e=Vr()){try{return!!(e&&e.speechSynthesis&&typeof e.speechSynthesis.speak=="function"&&typeof e.SpeechSynthesisUtterance=="function")}catch{return!1}}function _b(e=Vr()){return!!(e&&(typeof e=="object"||typeof e=="function")&&Ff.has(e))}function Wh(e=Vr()){e&&(typeof e=="object"||typeof e=="function")&&Ff.delete(e)}function Ir(e){const t=String(e||"").trim().toLowerCase().split("-")[0];return Ij[t]||""}function uc(e){return String(e||"").normalize("NFC").replace(/[\p{Cc}\p{Cf}]+/gu," ").replace(/\s+/g," ").trim()}function zj(e){const t=uc(e).normalize("NFD").replace(new RegExp("\\p{M}+","gu"),"").toLowerCase(),n=new Set(t.match(new RegExp("\\p{L}+","gu"))||[]);if(n.size<4)return"";const s=Object.entries(Oj).map(([o,a])=>({lang:o,score:[...n].reduce((u,h)=>u+(a.has(h)?1:0),0)})).sort((o,a)=>a.score-o.score);return s[0].score>=3&&s[0].score-s[1].score>=2?s[0].lang:""}function $j(e,t){const n=Ir(e&&e.lang);return n||Ir(zj(e&&e.body))||Ir(t)}function yb(e){try{const t=e&&e.speechSynthesis&&e.speechSynthesis.getVoices;return typeof t=="function"?Array.from(t.call(e.speechSynthesis)||[]).filter(Boolean):[]}catch{return[]}}function wb(e,t){const n=Ir(t);if(!n)return null;const s=Array.from(e||[]).filter(h=>h&&typeof h.lang=="string"&&h.lang.trim()),o=s.filter(h=>h.lang.trim().toLowerCase()===n.toLowerCase()),a=n.slice(0,2).toLowerCase(),u=s.filter(h=>h.lang.trim().toLowerCase().split("-")[0]===a);return o.find(h=>h.default===!0)||o[0]||u.find(h=>h.default===!0)||u[0]||null}function W_(e){return uc(e).replace(/\bBearer\s+\S+/gi,"Bearer [redacted]").replace(/\b(?:sk|hf|zai|xox[baprs]|gh[pousr]|npm)[_-][A-Za-z0-9._-]{8,}\b/gi,"[redacted]").replace(/\b(?:token|password|secret|credential|api[_-]?key)\s*[=:]\s*(?:"[^"]*"|'[^']*'|\S+)/gi,"[redacted]").replace(/\b[A-Z][A-Z0-9_]{2,}\s*=\s*(?:"[^"]*"|'[^']*'|\S+)/g,"[redacted]").replace(/(?:\/home\/[^/\s]+|\/Users\/[^/\s]+|\/data\/(?:data|user\/\d+)\/[^/\s]+)(?:\/[^\s]*)?/g,"[private path]").replace(/\b[A-Za-z]:\\Users\\[^\\\s]+(?:\\[^\s]*)?/g,"[private path]")}function Fj(e,t=Pj){const n=W_(e&&e.title),s=W_(e&&e.body),o=[n,s&&s!==n?s:""].filter(Boolean).join(". "),a=Array.from(o);return a.length<=t?o:`${a.slice(0,Math.max(0,t-1)).join("").trimEnd()}…`}function Hj(e){try{return!!(e&&e.visibilityState==="visible"&&typeof e.hasFocus=="function"&&e.hasFocus())}catch{return!1}}function bb(e=Vr()){if(!ta(e))return!1;try{return e.speechSynthesis.cancel(),!0}catch{return!1}}function Uj(e){try{e&&typeof e.dispatchEvent=="function"&&typeof e.Event=="function"&&e.dispatchEvent(new e.Event(Uh))}catch{}}function Wj(e,t,n=Vr(),s={}){var m;if(Wh(n),!ta(n))return Promise.resolve(!1);const o=uc(e);if(!o||(m=s.signal)!=null&&m.aborted)return Promise.resolve(!1);const a=Number.isFinite(s.timeoutMs)&&s.timeoutMs>0?s.timeoutMs:Tj,u=s.setTimer||((v,y)=>setTimeout(v,y)),h=s.clearTimer||(v=>clearTimeout(v)),p=s.signal;return Uj(n),new Promise(v=>{let y=!1,w=!1,b=null,k=null;const N=S=>{if(!y){if(y=!0,p&&k&&p.removeEventListener("abort",k),b!==null&&h(b),S)Ff.add(n);else try{n.speechSynthesis.cancel()}catch{}v(S)}};k=()=>N(!1),p&&p.addEventListener("abort",k,{once:!0});try{n.speechSynthesis.cancel();const S=new n.SpeechSynthesisUtterance(o);S.lang=Ir(t);const j=wb(yb(n),S.lang);j&&(S.voice=j),S.onstart=()=>{w=!0},S.onend=()=>N(w),S.onerror=()=>N(!1),b=u(()=>N(!1),a),n.speechSynthesis.speak(S)}catch{N(!1)}})}function Kj(e={}){const t=e.scope||Vr(),n=e.document||t&&t.document,s=Number.isInteger(e.maxPending)&&e.maxPending>=0?e.maxPending:Aj,o=Number.isFinite(e.watchdogMs)&&e.watchdogMs>0?e.watchdogMs:Lj,a=Number.isFinite(e.dedupWindowMs)&&e.dedupWindowMs>0?e.dedupWindowMs:Mj,u=Number.isInteger(e.maxDedup)&&e.maxDedup>0?e.maxDedup:Dj,h=e.now||Date.now,p=e.setTimer||((F,B)=>setTimeout(F,B)),m=e.clearTimer||(F=>clearTimeout(F)),v=e.isPrimed||(()=>_b(t)),y=t&&t.speechSynthesis;let w=null,b=null,k=[],N=[],S=()=>{};const j=new Map,C=()=>{N=yb(t)};if(C(),y&&typeof y.addEventListener=="function")y.addEventListener("voiceschanged",C),S=()=>y.removeEventListener("voiceschanged",C);else if(y&&"onvoiceschanged"in y){const F=y.onvoiceschanged,B=(...A)=>{C(),typeof F=="function"&&F.apply(y,A)};y.onvoiceschanged=B,S=()=>{y.onvoiceschanged===B&&(y.onvoiceschanged=F)}}const $=F=>{if(F&&typeof F.id=="string"&&F.id)return`id:${F.id}`;const B=Number(F&&F.ts),A=uc(F&&F.title);return Number.isFinite(B)&&A?`frame:${B}:${A}`:""},O=F=>{if(!F)return!0;const B=h();for(const[A,z]of j)B-z>=a&&j.delete(A);if(j.has(F))return!1;for(j.set(F,B);j.size>u;)j.delete(j.keys().next().value);return!0},U=()=>{b!==null&&m(b),b=null},V=()=>{U(),w&&(w.onend=null,w.onerror=null,w=null),bb(t)},K=F=>{if(!ta(t))return k=[],"unsupported";let B;try{B=new t.SpeechSynthesisUtterance(F.text),B.lang=Ir(F.lang);const z=wb(N,B.lang);z&&(B.voice=z)}catch{return k=[],"error"}w=B;const A=()=>{if(w!==B)return;U(),w=null,B.onend=null,B.onerror=null;const z=k.shift();z&&K(z)};B.onend=A,B.onerror=A;try{return b=p(()=>{if(w!==B)return;w=null,B.onend=null,B.onerror=null;try{t.speechSynthesis.cancel()}catch{}U();const z=k.shift();z&&K(z)},o),t.speechSynthesis.speak(B),"speaking"}catch{return A(),"error"}},Z=(F,B)=>{if(!ta(t))return"unsupported";const A=Fj(F);if(!A)return"empty";if(!O($(F)))return"duplicate";if(!Hj(n))return"inactive";if(!v())return"unprimed";const z={text:A,lang:B};return F&&F.urgency==="high"?(k=[],V(),K(z)):w?s===0?"dropped":(k.length>=s&&k.shift(),k.push(z),"queued"):K(z)},G=()=>{k=[],V()};return{enqueue:Z,stop:G,dispose:()=>{G(),S(),S=()=>{}}}}function Sb(){const[e,t]=E.useState(U_);E.useEffect(()=>{const s=o=>{if((o==null?void 0:o.type)==="storage"&&o.key!==$f&&o.key!==null)return;const a=(o==null?void 0:o.type)===Nl?Hf(o.detail):U_();t(a)};return window.addEventListener(Nl,s),window.addEventListener("storage",s),()=>{window.removeEventListener(Nl,s),window.removeEventListener("storage",s)}},[]);const n=E.useCallback(s=>{const o=Bj({enabled:s===!0});return t(o),window.dispatchEvent(new CustomEvent(Nl,{detail:o})),o.enabled},[]);return[e.enabled,n]}function qj({text:e}){const[t,n]=E.useState(!1),s=async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{}};return l.jsxs("div",{className:"nc-set-copyline",children:[l.jsx("code",{children:e}),l.jsxs("button",{type:"button",className:"nc-btn ghost",onClick:s,children:[l.jsx(nt,{name:"copy",size:14})," ",f(t?"copied":"copy")]})]})}function Vj({value:e}){const[t,n]=E.useState("");return E.useEffect(()=>{let s=!0;return b2.toDataURL(e,{margin:1,width:220}).then(o=>{s&&n(o)}).catch(()=>{}),()=>{s=!1}},[e]),t?l.jsx("img",{src:t,width:"220",height:"220",alt:"NexusCrew pairing QR"}):null}function Yj({token:e,nodes:t,roster:n,settings:s,readonly:o,refresh:a,refreshAliases:u,vlUnavailable:h=[]}){const[p,m]=E.useState(null),[v,y]=E.useState(null),[w,b]=E.useState(null),[k,N]=E.useState({ssh:"",sshPort:"",name:""}),[S,j]=E.useState(""),[C,$]=E.useState(""),[O,U]=E.useState(!1),[V,K]=E.useState(null),Z=Date.now(),G=s&&s.deviceName||"",Q=(t||[]).filter(x=>x&&x.direction==="outbound"&&x.name&&x.ssh),F=Q.find(x=>x.name===S)||Q[0]||null,B=F?Qd(F.tunnel,Z):null,A=F!=null&&F.shared?B!=null&&B.up?"share-local-active":"share-local-pending":B!=null&&B.up?"share-local-private":"share-local-private-down",z=[{key:"peer-group-hubs",rows:(t||[]).filter(x=>x.kind!=="transitive"&&x.kind!=="vl"&&x.relation!=="client")},{key:"peer-group-clients",rows:(t||[]).filter(x=>x.kind!=="transitive"&&x.kind!=="vl"&&x.relation==="client")},{key:"peer-group-routed",rows:(t||[]).filter(x=>x.kind==="transitive")},{key:"peer-group-vl",rows:(t||[]).filter(x=>x.kind==="vl")}],I=V&&(t||[]).find(x=>`${x.kind||"direct"}:${x.nodeId||x.name}`===V)||null,D=async x=>{if(F){m(null),y(`${F.name}:share`);try{const M=await Y0(e,F.name,x);await a(),M&&M.reversePoolPending===!0&&m(`${F.name}: ${f("share-reverse-pool-pending")}`)}catch(M){const L=M!=null&&M.data&&M.data.shared===!1?M.data:null;if(L)try{await a()}catch{}const T=M!=null&&M.data&&typeof M.data.hint=="string"?M.data.hint:"",H=(L==null?void 0:L.revoked)===!0&&(L==null?void 0:L.localReconcilePending)===!0?f("share-off-local-reconcile-pending"):(L==null?void 0:L.revoked)===!1&&(L==null?void 0:L.reconcilePending)===!0?f("share-off-hub-reconcile-pending"):"",Y=M!=null&&M.data&&M.data.reversePoolPending===!0?f("share-reverse-pool-pending"):"",de=M!=null&&M.data&&typeof M.data.code=="string"?M.data.code:"",ue=M!=null&&M.data&&typeof M.data.detail=="string"?M.data.detail.trim():"",fe=ue&&ue!==String(M.message||"")?ue:"";m(`${F.name}: ${String(M.message||M)}${de?` [${de}]`:""}${fe?` — ${fe}`:""}${T?` — ${T}`:""}${H?` — ${H}`:""}${Y?` — ${Y}`:""}`)}y(null)}},P=async()=>{m(null);const x=Es(k.name||C||G||"NexusCrew"),M=tk({name:x,ssh:k.ssh,sshPort:k.sshPort});if(!M.ok){m(f(M.error));return}y("invite");try{b(await W0(e,{...C||G?{label:C||G}:{},name:x,ssh:M.value.ssh,...M.value.sshPort?{sshPort:M.value.sshPort}:{}}))}catch(L){m(String(L.message||L))}y(null)};return l.jsxs("div",{className:"nc-set-tab",children:[l.jsx("div",{className:"nc-sheet-label",children:f("peer-inventory-title")}),(t||[]).length===0&&l.jsx("div",{className:"nc-empty",children:f("no-nodes")}),z.map(x=>x.rows.length>0&&l.jsxs("div",{className:"nc-peer-group",children:[l.jsxs("div",{className:"nc-peer-group-title",children:[f(x.key)," ",l.jsx("span",{children:x.rows.length})]}),x.rows.map(M=>{const L=T2(M);if(!L)return null;const T=`${M.kind||"direct"}:${M.nodeId||M.name}`,H=L.routed?{up:L.reach.up,since:null}:Qd(M.tunnel,Z);return l.jsxs("button",{type:"button",className:`nc-set-node nc-node-row${L.routed?" routed":""}`,"aria-label":`${L.title} — ${f("node-detail-open")}`,onClick:()=>K(T),children:[l.jsx("span",{className:`nc-dot ${L.reach.up?"on":""}`}),l.jsxs("span",{className:"nc-node-row-text",children:[l.jsx("b",{children:L.title}),l.jsxs("small",{children:[L.routed?L.routeLabel:`${L.subtitle} · ${f(L.exposure.shortKey)}`,!L.routed&&L.exposure.shortKey==="visibility-selected"?` (${L.exposure.count})`:""]})]}),l.jsxs("span",{className:`nc-set-tunnel${L.reach.up?" up":""}`,children:[f(L.reach.key),H.since?` · ${H.since}`:""]}),l.jsx("span",{className:"nc-node-row-more",children:l.jsx(nt,{name:"chevronDown",size:14})})]},T)})]},x.key)),h.length>0&&l.jsxs("div",{className:"nc-err",children:[f("vl-owners-unavailable"),": ",h.map(x=>x.label||x.route.join("/")).join(", ")]}),I&&l.jsx(Y2,{node:I,nodes:t||[],token:e,readonly:o,refresh:a,onClose:()=>K(null)}),(n||[]).some(x=>!x.direct&&x.instanceId)&&l.jsxs("div",{className:"nc-set-form",children:[l.jsx("div",{className:"nc-sheet-label",children:f("routed-node-aliases")}),l.jsx("small",{className:"nc-set-hint",children:f("routed-node-aliases-help")}),(n||[]).filter(x=>!x.direct&&x.instanceId).map(x=>l.jsxs("div",{className:"nc-set-node",children:[l.jsxs("div",{className:"nc-set-node-head",children:[l.jsx("span",{className:`nc-dot ${x.status==="up"?"on":""}`}),l.jsx("b",{children:x.label||x.name}),l.jsx("small",{children:(x.route||[]).join(" › ")})]}),l.jsxs("div",{className:"nc-set-node-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!v,onClick:async()=>{const M=window.prompt(f("node-local-alias"),x.alias||"");if(M!=null){if(M.trim()&&!zr(M.normalize("NFC"))){m(f("err-label"));return}y(`${x.instanceId}:alias`),m(null);try{M.trim()?await q0(e,x.instanceId,M):await Cg(e,x.instanceId),u()}catch(L){m(String(L.message||L))}y(null)}},children:f("alias-on-device")}),x.alias&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!v,onClick:async()=>{y(`${x.instanceId}:alias-reset`),m(null);try{await Cg(e,x.instanceId),u()}catch(M){m(String(M.message||M))}y(null)},children:f("reset-alias")})]})]},x.instanceId))]}),F&&l.jsxs("div",{className:"nc-set-form nc-local-share",children:[l.jsx("div",{className:"nc-sheet-label",children:f("share-local-heading")}),Q.length>1&&l.jsxs("label",{className:"nc-field",children:[f("share-local-hub"),l.jsx("select",{value:F.name,disabled:o||!!v,onChange:x=>j(x.target.value),children:Q.map(x=>l.jsx("option",{value:x.name,children:x.label||x.name},x.name))})]}),l.jsxs("label",{className:"nc-check nc-node-share",children:[l.jsx("input",{type:"checkbox",checked:F.shared===!0,disabled:o||!!v,onChange:x=>D(x.target.checked)}),l.jsxs("span",{children:[l.jsx("b",{children:f("share-local-through").replace("{device}",G||f("local")).replace("{hub}",F.label||F.name)}),l.jsx("small",{children:f(F.shared?"share-node-on-desc":"share-node-off-desc")})]})]}),l.jsx("div",{className:`nc-set-test${F.shared&&(B!=null&&B.up)?" ok":B!=null&&B.up?"":" ko"}`,children:f(A)}),!(B!=null&&B.up)&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!v,onClick:()=>D(F.shared===!0),children:f("share-local-reconnect")})]}),l.jsx(rb,{token:e,deviceDefault:G,localNodeId:s&&s.nodeId||"",localNameDefault:s&&s.localName||"",readonly:o,onSuccess:a}),l.jsxs("div",{className:"nc-set-form",children:[l.jsx("div",{className:"nc-sheet-label",children:f("invite-node")}),l.jsx("small",{className:"nc-set-hint",children:f("invite-v2-hint")}),l.jsxs("div",{className:"nc-set-info nc-invite-endpoint",children:[f("invite-target-local"),": ",l.jsx("b",{children:G||f("invite-target-this")})]}),l.jsxs("label",{className:"nc-field",children:[f("invite-endpoint-label"),l.jsx("input",{placeholder:"user@host",value:k.ssh,disabled:o,onChange:x=>N({...k,ssh:x.target.value})}),l.jsx("small",{className:"nc-set-hint",children:f("invite-endpoint-needed")})]}),Q.length>0&&l.jsx("small",{className:"nc-set-hint nc-invite-hub-hint",children:f("invite-hub-only")}),O&&l.jsxs("div",{className:"nc-invite-advanced",children:[l.jsxs("label",{className:"nc-field",children:[f("node-ssh-port-label"),l.jsx("input",{inputMode:"numeric",placeholder:"22",value:k.sshPort,disabled:o,onChange:x=>N({...k,sshPort:x.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),l.jsxs("label",{className:"nc-field",children:[f("device-name-label"),l.jsx("input",{placeholder:G||"NexusCrew",value:C,disabled:o,onChange:x=>$(x.target.value)}),l.jsx("small",{className:"nc-set-hint",children:f("device-name-hint")})]}),l.jsxs("label",{className:"nc-field",children:[f("node-name-label"),l.jsx("input",{placeholder:Es(C||G||f("node-name-ph")),value:k.name,disabled:o,onChange:x=>N({...k,name:x.target.value?Es(x.target.value):""})})]})]}),l.jsxs("div",{className:"nc-set-row nc-invite-actions",children:[l.jsx("button",{type:"button",className:"nc-btn primary",disabled:o||!!v||!k.ssh.trim(),onClick:P,children:f("create-pairing-link")}),l.jsxs("button",{type:"button",className:"nc-btn ghost",disabled:!!v,onClick:()=>U(x=>!x),children:[O?"▾":"▸"," ",f("pair-advanced")]})]}),w&&l.jsxs(l.Fragment,{children:[l.jsx(Vj,{value:w.pairingUrl}),l.jsx(qj,{text:w.pairingUrl}),l.jsx("div",{className:"nc-set-info",children:f("invite-next-steps")})]})]}),p&&l.jsx("div",{className:"nc-err",children:p})]})}function Gj({token:e,readonly:t}){const[n,s]=E.useState("idle"),[o,a]=E.useState(!1),[u,h]=E.useState(null);E.useEffect(()=>{let m=!1;return X2().then(v=>{m||s(v)}),()=>{m=!0}},[]);const p=async()=>{h(null),a(!0);try{n==="subscribed"?(await J2(e),s("idle")):(await Q2(e),s("subscribed"))}catch(m){const v=String(m.message||m);v==="push-denied"?(s("denied"),h(f("push-denied"))):v==="push-unsupported"?(s("unsupported"),h(f("push-unsupported"))):h(v)}a(!1)};return n==="unsupported"?l.jsx("div",{className:"nc-set-info",children:f("push-unsupported")}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||o||n==="denied",title:t?f("settings-readonly"):"",onClick:p,children:f(n==="subscribed"?"push-disable":"push-enable")}),l.jsx("span",{className:"nc-set-info",children:f(n==="subscribed"?"push-on":n==="denied"?"push-denied":"push-off")})]}),u&&l.jsx("div",{className:"nc-err",children:u})]})}function Xj(){const[e,t]=Sb(),[n,s]=E.useState(""),[o,a]=E.useState(""),[u,h]=E.useState(!1),[p,m]=E.useState(_b),v=E.useRef(0),y=E.useRef(!1),w=E.useRef(null),b=ta();E.useEffect(()=>()=>{var S;v.current+=1,y.current&&((S=w.current)==null||S.abort(),w.current=null,y.current=!1,Wh())},[]);const k=async()=>{const S=v.current+=1,j=typeof AbortController=="function"?new AbortController:null;s(""),a(""),h(!0),m(!1),y.current=!0,w.current=j;const C=await Wj(f("notification-speech-preview"),Ol(),void 0,j?{signal:j.signal}:{});return S!==v.current||(w.current=null,y.current=!1,h(!1),m(C),C?a(f("notification-speech-preview-ok")):s(f("notification-speech-preview-failed"))),C},N=S=>{var j;if(t(S),s(""),a(""),S)k();else{v.current+=1;const C=y.current;(j=w.current)==null||j.abort(),w.current=null,y.current=!1,h(!1),m(!1),Wh(),C||bb()}};return l.jsxs("div",{className:"nc-set-form",children:[l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox","aria-label":f("notification-speech-enable"),checked:e,disabled:!b,onChange:S=>N(S.target.checked)}),l.jsxs("span",{children:[l.jsx("b",{children:f("notification-speech-enable")}),l.jsx("small",{children:f("notification-speech-help")})]})]}),b?l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!e||u,onClick:()=>{k()},children:f(u?"notification-speech-testing":"notification-speech-test")})}):l.jsx("div",{className:"nc-set-info",children:f("notification-speech-unsupported")}),e&&!p&&!u&&!n&&l.jsx("div",{className:"nc-set-info",children:f("notification-speech-needs-test")}),o&&l.jsx("div",{className:"nc-set-info",role:"status",children:o}),n&&l.jsx("div",{className:"nc-err",children:n})]})}function Qj({token:e,readonly:t,nodes:n=[],settings:s=null}){const[o,a]=E.useState(null),[u,h]=E.useState([]),[p,m]=E.useState({name:"",mode:"primary-failover",targets:[]}),[v,y]=E.useState(null),[w,b]=E.useState(!1),[k,N]=E.useState(null),[S,j]=E.useState(""),C=E.useCallback(async()=>{try{const[P,x]=await Promise.all([X0(e),ex(e)]);a(P),h(Array.isArray(x==null?void 0:x.groups)?x.groups:[]),j("")}catch(P){j(String(P.message||P))}},[e]);E.useEffect(()=>{C()},[C]);const $=async P=>{b(!0),N(null),j("");try{a(await Q0(e,P))}catch(x){j(String(x.message||x))}b(!1)},O=async()=>{b(!0),N(null),j("");try{N({kind:"test",...await J0(e)})}catch(P){j(String(P.message||P))}b(!1)},U=async()=>{b(!0),N(null),j("");try{N({kind:"stop",...await Z0(e)})}catch(P){j(String(P.message||P))}b(!1)},V=[],K=new Set,Z=(P,x)=>{const M=typeof P=="string"?P.toLowerCase():"";!/^[a-f0-9]{32}$/.test(M)||K.has(M)||(K.add(M),V.push({id:M,label:x||M}))};Z(s==null?void 0:s.nodeId,f("audio-group-local"));for(const P of n||[])Z((P==null?void 0:P.nodeId)||(P==null?void 0:P.instanceId),(P==null?void 0:P.label)||(P==null?void 0:P.name)||(P==null?void 0:P.nodeId));for(const P of p.targets)Z(P,`${P} (${f("audio-group-unavailable-target")})`);const G=(P=null)=>{j(""),P?(y(P.name),m({name:P.name,mode:P.mode,targets:[...P.targets||[]]})):(y(null),m({name:"",mode:"primary-failover",targets:[]}))},Q=(P,x)=>m(M=>({...M,targets:x?[...new Set([...M.targets,P])]:M.targets.filter(L=>L!==P)})),F=async()=>{const P=p.name.trim().toLowerCase();if(!/^[a-z0-9][a-z0-9-]{0,31}$/.test(P)||p.targets.length<1){j(f("audio-group-invalid"));return}b(!0),j("");try{const x=await tx(e,P,{targets:p.targets,mode:p.mode}),M=x==null?void 0:x.group;if(!M||!M.name)throw new Error(f("audio-group-save-failed"));h(L=>[...L.filter(T=>T.name!==M.name),M].sort((T,H)=>T.name.localeCompare(H.name))),G(null)}catch(x){j(String(x.message||x))}b(!1)},B=async P=>{b(!0),j("");try{await nx(e,P),h(x=>x.filter(M=>M.name!==P)),v===P&&G(null)}catch(x){j(String(x.message||x))}b(!1)},A=(o==null?void 0:o.installed)===!0,z=(o==null?void 0:o.liveness)==="ready",I=(o==null?void 0:o.consent)===!0&&A&&z,D=k?k.kind==="stop"?f(k.stopped?"audio-stop-stopped":"audio-stop-idle"):k.status==="accepted"||k.status==="spoken"?f("audio-test-accepted"):k.status==="unknown"?f("audio-test-unknown"):`${f("audio-test-refused")}${k.reason?` (${k.reason})`:""}`:"";return l.jsxs("div",{className:"nc-set-tab nc-audio-settings",children:[l.jsxs("div",{className:"nc-set-info",children:[l.jsx("b",{children:f("audio-title")}),l.jsx("br",{}),f("audio-help")]}),o?l.jsxs(l.Fragment,{children:[l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox","aria-label":f("audio-consent"),checked:o.consent===!0,disabled:t||w,onChange:P=>{$(P.target.checked)}}),l.jsxs("span",{children:[l.jsx("b",{children:f("audio-consent")}),l.jsx("small",{children:f("audio-consent-help")})]})]}),l.jsxs("div",{className:"nc-set-form",children:[l.jsx("div",{className:"nc-sheet-label",children:f("audio-capability")}),l.jsxs("div",{className:"nc-set-info",children:[f("audio-adapter"),": ",o.adapter||f("audio-adapter-none"),l.jsx("br",{}),f("audio-installed"),": ",f(A?"audio-installed-yes":"audio-installed-no"),l.jsx("br",{}),f("audio-liveness"),": ",f(z?"audio-liveness-ready":"audio-liveness-unavailable"),Array.isArray(o.languages)&&o.languages.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("br",{}),f("audio-languages"),": ",o.languages.join(", ")]})]}),o.limits&&l.jsxs("small",{className:"nc-set-hint",children:[f("audio-limits"),": ",o.limits]})]}),!o.consent&&l.jsx("div",{className:"nc-set-info",children:f("audio-test-needs-consent")}),!A&&l.jsx("div",{className:"nc-set-info",children:f("audio-unavailable")}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn primary",disabled:t||w||!I,title:t?f("settings-readonly"):"",onClick:()=>{O()},children:f(w?"audio-testing":"audio-test")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:w,onClick:()=>{U()},children:f(w?"audio-stopping":"audio-stop")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:w,onClick:()=>{C()},children:f("refresh")})]}),l.jsxs("div",{className:"nc-set-form",children:[l.jsx("div",{className:"nc-sheet-label",children:f("audio-groups-title")}),l.jsx("small",{className:"nc-set-hint",children:f("audio-groups-help")}),u.length===0&&l.jsx("div",{className:"nc-set-info",children:f("audio-groups-empty")}),u.map(P=>{var x;return l.jsxs("div",{className:"nc-set-row",children:[l.jsxs("span",{children:[l.jsx("b",{children:P.name})," ",l.jsxs("small",{children:["· ",P.mode==="fanout"?f("audio-group-fanout"):f("audio-group-primary")," · ",((x=P.targets)==null?void 0:x.length)||0]})]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||w,onClick:()=>G(P),children:f("audio-group-edit")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||w,onClick:()=>{B(P.name)},children:f("audio-group-delete")})]},P.name)}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||w,onClick:()=>G(null),children:f("audio-group-new")})}),l.jsxs("label",{className:"nc-field",children:[f("audio-group-name"),l.jsx("input",{"aria-label":f("audio-group-name"),value:p.name,maxLength:"32",disabled:t||w,onChange:P=>m(x=>({...x,name:P.target.value}))})]}),l.jsxs("label",{className:"nc-field",children:[f("audio-group-mode"),l.jsxs("select",{"aria-label":f("audio-group-mode"),value:p.mode,disabled:t||w,onChange:P=>m(x=>({...x,mode:P.target.value})),children:[l.jsx("option",{value:"primary-failover",children:f("audio-group-primary")}),l.jsx("option",{value:"fanout",children:f("audio-group-fanout")})]})]}),l.jsx("div",{className:"nc-set-info",children:f("audio-group-targets")}),V.length===0?l.jsx("small",{className:"nc-set-hint",children:f("audio-group-no-targets")}):V.map(P=>l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:p.targets.includes(P.id),disabled:t||w,onChange:x=>Q(P.id,x.target.checked)}),l.jsxs("span",{children:[P.label,l.jsx("small",{children:P.id})]})]},P.id)),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn primary",disabled:t||w,onClick:()=>{F()},children:f("audio-group-save")}),v&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:w,onClick:()=>G(null),children:f("audio-group-cancel")})]})]})]}):l.jsx("div",{className:"nc-set-info",children:f("audio-loading")}),D&&l.jsx("div",{className:"nc-set-note",role:"status",children:D}),S&&l.jsx("div",{className:"nc-err",children:S})]})}function Jj(){const[e,t]=Nf();return l.jsxs("div",{className:"nc-set-tab nc-input-settings",children:[l.jsx("div",{className:"nc-set-info",children:f("input-settings-local")}),l.jsxs("div",{className:"nc-set-form",children:[l.jsxs("label",{className:"nc-field",children:[f("terminal-keyboard-gesture"),l.jsx("select",{"aria-label":f("terminal-keyboard-gesture"),value:e.terminalKeyboardGesture,onChange:n=>t({terminalKeyboardGesture:n.target.value}),children:Ow.map(n=>l.jsx("option",{value:n,children:f(`terminal-keyboard-${n}`)},n))}),l.jsx("small",{children:f("terminal-keyboard-gesture-help")})]}),l.jsxs("label",{className:"nc-field",children:[f("keybar-layout"),l.jsx("select",{"aria-label":f("keybar-layout"),value:e.keybarLayout,onChange:n=>t({keybarLayout:n.target.value}),children:Bw.map(n=>l.jsx("option",{value:n,children:f(`keybar-layout-${n}`)},n))}),l.jsx("small",{children:f("keybar-layout-help")})]})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:e.keybarKeepsKeyboardClosed,onChange:n=>t({keybarKeepsKeyboardClosed:n.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:f("keybar-ime-lock")}),l.jsx("small",{children:f("keybar-ime-lock-help")})]})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:e.voiceKeepsKeyboardClosed,onChange:n=>t({voiceKeepsKeyboardClosed:n.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:f("voice-ime-lock")}),l.jsx("small",{children:f("voice-ime-lock-help")})]})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:e.showKeybarEnter,onChange:n=>t({showKeybarEnter:n.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:f("keybar-enter-show")}),l.jsx("small",{children:f("keybar-enter-show-help")})]})]}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>t(xs),children:f("input-settings-reset")})})]})}function Zj({token:e,roster:t=[],readonly:n}){const s=[{key:"local",route:[],label:f("diagnostics-local"),status:"up"},...t.filter(I=>Array.isArray(I.route)&&I.route.length).map(I=>({key:I.route.join("/"),route:I.route,label:I.label||I.name,status:I.status}))],[o,a]=E.useState("local"),u=s.find(I=>I.key===o)||s[0],[h,p]=E.useState(null),[m,v]=E.useState([]),[y,w]=E.useState(""),[b,k]=E.useState(!1),[N,S]=E.useState(!0),[j,C]=E.useState(900),[$,O]=E.useState("all"),[U,V]=E.useState(""),K=E.useRef(0),Z=E.useRef(null),G=E.useCallback(async()=>{try{const I=await ox(e,u.route);if(p(I),w(""),!b){const D=await ax(e,{after:K.current,limit:200},u.route);Array.isArray(D.records)&&D.records.length&&(K.current=D.cursor,v(P=>[...P,...D.records].slice(-500)))}}catch(I){w(I&&I.status===404?f("diagnostics-unsupported"):String(I.message||I))}},[e,u.key,b]);E.useEffect(()=>{K.current=0,v([]),p(null),w("")},[u.key]),E.useEffect(()=>{let I=null,D=!0;const P=()=>{!D||document.visibilityState==="hidden"||G()},x=()=>{I&&clearInterval(I),I=document.visibilityState==="hidden"?null:setInterval(P,2e3),document.visibilityState!=="hidden"&&P()};return document.addEventListener("visibilitychange",x),x(),()=>{D=!1,I&&clearInterval(I),document.removeEventListener("visibilitychange",x)}},[G]),E.useEffect(()=>{N&&Z.current&&(Z.current.scrollTop=Z.current.scrollHeight)},[m,N]);const Q=m.filter(I=>($==="all"||I.level===$)&&(!U||String(I.component||"").toLowerCase().includes(U.toLowerCase()))),F=Q.map(I=>`${I.ts} ${I.level.toUpperCase()} ${I.component} ${I.code} ${I.message}${Object.keys(I.meta||{}).length?` ${JSON.stringify(I.meta)}`:""}`).join(`
|
|
92
|
-
`),B=async I=>{w("");try{const D=await I();p(D),await G()}catch(D){w(String(D.message||D))}},A=async()=>{try{await navigator.clipboard.writeText(F)}catch{w(f("copy-manual"))}},z=()=>{try{const I=new Blob([`${JSON.stringify(Q,null,2)}
|
|
93
|
-
`],{type:"application/json"}),D=URL.createObjectURL(I),P=document.createElement("a");P.href=D,P.download="nexuscrew-diagnostics.json",P.click(),URL.revokeObjectURL(D)}catch{w(f("diagnostics-export-failed"))}};return l.jsxs("div",{className:"nc-set-tab nc-diagnostics",children:[l.jsxs("label",{className:"nc-field",children:[f("diagnostics-target"),l.jsx("select",{value:u.key,onChange:I=>a(I.target.value),children:s.map(I=>l.jsxs("option",{value:I.key,children:[I.label,I.status!=="up"?` · ${I.status}`:""]},I.key))})]}),l.jsxs("div",{className:"nc-set-form nc-diag-controls",children:[l.jsx("div",{className:"nc-sheet-label",children:f("diagnostics-verbose")}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("select",{"aria-label":f("diagnostics-duration"),value:j,onChange:I=>C(Number(I.target.value)),disabled:n,children:[300,900,1800,3600].map(I=>l.jsxs("option",{value:I,children:[I/60," min"]},I))}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||(h==null?void 0:h.verbose)===!0,onClick:()=>B(()=>Ng(e,!0,j,u.route)),children:f("enable")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||(h==null?void 0:h.verbose)!==!0,onClick:()=>B(()=>Ng(e,!1,j,u.route)),children:f("stop")})]}),l.jsx("small",{className:"nc-set-hint",children:h!=null&&h.verbose?f("diagnostics-expires").replace("{time}",new Date(h.expiresAt).toLocaleTimeString()):f("diagnostics-off")})]}),l.jsxs("div",{className:"nc-diag-filters",children:[l.jsxs("select",{"aria-label":f("diagnostics-level"),value:$,onChange:I=>O(I.target.value),children:[l.jsx("option",{value:"all",children:f("diagnostics-all-levels")}),["debug","info","warn","error"].map(I=>l.jsx("option",{value:I,children:I},I))]}),l.jsx("input",{"aria-label":f("diagnostics-component"),placeholder:f("diagnostics-component"),value:U,onChange:I=>V(I.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:I=>k(I.target.checked)})," ",f("diagnostics-pause")]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:N,onChange:I=>S(I.target.checked)})," ",f("diagnostics-autoscroll")]})]}),l.jsx("pre",{ref:Z,className:"nc-diag-log","aria-label":f("diagnostics-log"),children:F||f("diagnostics-empty")}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:A,children:f("copy")}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:z,children:f("diagnostics-export")}),l.jsx("button",{type:"button",className:"nc-btn danger",disabled:n,onClick:()=>{window.confirm(f("diagnostics-clear-confirm"))&&B(async()=>{const I=await lx(e,u.route);return K.current=0,v([]),I})},children:f("diagnostics-clear")})]}),y&&l.jsx("div",{className:"nc-err",children:y})]})}function eR({token:e,settings:t,readonly:n,refresh:s,roster:o,section:a,setSection:u}){const[h,p]=E.useState(null),[m,v]=E.useState(null),[y,w]=E.useState(!1),[b,k]=E.useState(!1),[N,S]=E.useState(null),[j,C]=E.useState(!0),[$,O]=E.useState(!1);E.useEffect(()=>{S(t&&t.update||null),C(!t||t.autoUpdate!==!1),O(!!(t&&t.alternateScreen))},[t]);const U=async()=>{p(null),v(null),k(!0);try{const A=await H0(e);v(A.note||"ok"),w(!1)}catch(A){p(String(A.message||A))}k(!1)},V=async()=>{p(null),v(null),k(!0);try{const A=await ix(e);v(`${A.note||"ok"}${A.target?` (${A.target})`:""}`)}catch(A){p(String(A.message||A))}k(!1)},K=async A=>{p(null),v(null),k(!0);try{await qd(e,{autoUpdate:A}),C(A),s&&await s()}catch(z){p(String(z.message||z))}k(!1)},Z=async A=>{p(null),v(null),k(!0);try{await qd(e,{alternateScreen:A}),O(A),s&&await s()}catch(z){p(String(z.message||z))}k(!1)},G=async()=>{p(null),v(null),k(!0);try{S(await sx(e))}catch(A){p(String(A.message||A))}k(!1)},Q=async()=>{p(null),v(null),k(!0);try{const A=await rx(e);S(A),v(f("npm-update-restarting"))}catch(A){p(String(A.message||A))}k(!1)},F=()=>{window.confirm(f("composer-clear-confirm"))&&(p(null),uN()?(window.dispatchEvent(new Event(Oh)),v(f("composer-clear-done"))):p(f("composer-clear-failed")))},B=t&&t.service;return l.jsxs("div",{className:"nc-set-tab",children:[l.jsx("div",{className:"nc-system-tabs",role:"tablist","aria-label":f("tab-system"),children:["general","diagnostics"].map(A=>l.jsx("button",{type:"button",role:"tab","aria-selected":a===A,className:`nc-set-tabbtn${a===A?" on":""}`,onClick:()=>u(A),children:f(`system-${A}`)},A))}),a==="general"&&l.jsxs(l.Fragment,{children:[l.jsxs("section",{className:"nc-system-group",children:[l.jsx("h3",{children:f("system-this-node")}),t&&l.jsxs("div",{className:"nc-set-info",children:["v",t.version," · ",t.platform," · :",t.port,l.jsx("br",{}),B&&B.installed?f("service-installed"):f("service-missing"),B&&B.installed?` · ${B.active?f("service-active"):f("service-inactive")}`:"",B?` · boot ${B.boot?"on":"off"}`:""]}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||b,title:n?f("settings-readonly"):"",onClick:V,children:f("service-regenerate")})}),l.jsx(Gj,{token:e,readonly:n}),l.jsx(Xj,{})]}),l.jsxs("section",{className:"nc-system-group",children:[l.jsx("h3",{children:f("system-updates")}),l.jsxs("div",{className:"nc-set-form nc-update-settings",children:[l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:j,disabled:n||b||N&&!N.supported,onChange:A=>K(A.target.checked)}),l.jsxs("span",{children:[l.jsx("b",{children:f("npm-auto-update")}),l.jsx("small",{children:f("npm-auto-update-help")})]})]}),N&&l.jsxs("div",{className:"nc-set-info",children:[f("npm-update-current")," v",N.current,N.latest?` · ${f("npm-update-latest")} v${N.latest}`:""," · ",f(`npm-update-${N.supported?N.phase:"unsupported"}`)]}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||b||!N||!N.supported,onClick:G,children:f("npm-update-check")}),N&&N.available&&l.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||b||N.phase==="installing",onClick:Q,children:f("npm-update-install")})]}),N&&N.lastError&&l.jsx("div",{className:"nc-err",children:N.lastError})]})]}),l.jsxs("section",{className:"nc-system-group",children:[l.jsx("h3",{children:f("system-security")}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||b,title:n?f("settings-readonly"):"",onClick:()=>{p(null),v(null),w(!0)},children:f("token-rotate")})})]}),l.jsxs("section",{className:"nc-system-group",children:[l.jsx("h3",{children:f("system-local-data")}),l.jsxs("div",{className:"nc-set-form",children:[l.jsx("div",{className:"nc-sheet-label",children:f("composer-clear-data")}),l.jsx("small",{className:"nc-set-hint",children:f("composer-clear-data-help")}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:F,children:f("composer-clear-data")})})]})]})]}),a==="diagnostics"&&l.jsxs("section",{className:"nc-system-group nc-system-diagnostics",children:[l.jsx("h3",{children:f("system-diagnostics")}),l.jsxs("div",{className:"nc-set-form nc-alternate-screen-settings",children:[l.jsx("div",{className:"nc-sheet-label",children:f("system-terminal")}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox","aria-label":f("alternate-screen"),checked:$,disabled:n||b,onChange:A=>Z(A.target.checked)}),l.jsxs("span",{children:[l.jsx("b",{children:f("alternate-screen")}),l.jsx("small",{children:f("alternate-screen-help")})]})]})]}),l.jsx(Zj,{token:e,roster:o,readonly:n})]}),y&&l.jsxs("div",{className:"nc-set-confirm",children:[l.jsx("div",{children:f("token-rotate-explain")}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:b,onClick:()=>w(!1),children:f("cancel")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:b,onClick:U,children:f("confirm")})]})]}),m&&l.jsx("div",{className:"nc-set-note",children:m}),h&&l.jsx("div",{className:"nc-err",children:h})]})}function tR({token:e,onClose:t,initialTab:n="nodes",initialLocation:s="",startNewCell:o=!1}){Dn();const a=n==="diagnostics"?"diagnostics":"general",[u,h]=E.useState(n==="diagnostics"?"system":n),p=E.useRef(null),m=E.useRef(null),[v,y]=E.useState({start:!1,end:!1}),[w,b]=E.useState(a),[k,N]=E.useState(null),[S,j]=E.useState([]),[C,$]=E.useState([]),[O,U]=E.useState(!1),[V,K]=E.useState(null),[Z,G]=E.useState(0),Q=rf(e,!0,Z),F=E.useCallback(()=>{const A=p.current;if(!A)return;const z=A.scrollWidth>A.clientWidth+1,I={start:z&&A.scrollLeft>1,end:z&&A.scrollLeft+A.clientWidth<A.scrollWidth-1};y(D=>D.start===I.start&&D.end===I.end?D:I)},[]);E.useEffect(()=>{const A=p.current;if(!A)return;const z=typeof ResizeObserver=="function"?new ResizeObserver(F):null;return z==null||z.observe(A),window.addEventListener("resize",F),F(),()=>{z==null||z.disconnect(),window.removeEventListener("resize",F)}},[F]),E.useEffect(()=>{var z,I;(I=(z=m.current)==null?void 0:z.scrollIntoView)==null||I.call(z,{behavior:"smooth",block:"nearest",inline:"nearest"});const A=window.requestAnimationFrame?window.requestAnimationFrame(F):setTimeout(F,0);return()=>{window.cancelAnimationFrame?window.cancelAnimationFrame(A):clearTimeout(A)}},[u,F]);const B=E.useCallback(async()=>{var A;try{const z=await ry(e);N(z),K(null)}catch(z){K(String(z.message||z))}try{const I=(await $0(e)).peers||[];let D=[],P=[];try{const[x,M]=await Promise.all([Kt("/api/config",e).then(Y=>Y.json()).catch(()=>null),ay(e).catch(()=>null)]),L=x&&typeof x.instanceId=="string"?x.instanceId:"",T=[{instanceId:L||null,route:[],label:null},...gy(M,L)],H=await Promise.all(T.map(async Y=>{try{return{ok:!0,peers:((await oy(e,Y.route)).nodes||[]).map(fe=>my(fe,Y)).filter(Boolean)}}catch(de){return{ok:!1,owner:Y,error:de}}}));for(const Y of H){if(Y.ok){D.push(...Y.peers);continue}Y.owner.route.length!==0&&P.push({instanceId:Y.owner.instanceId,label:Y.owner.label,route:Y.owner.route,failure:/timeout/i.test(String(((A=Y.error)==null?void 0:A.message)||Y.error))?"timeout":"unreachable"})}}catch{}$(P),j([...I,...D])}catch(z){K(String(z.message||z))}},[e]);return E.useEffect(()=>{B();const A=setInterval(B,5e3);return()=>clearInterval(A)},[B]),E.useEffect(()=>{let A=!1;return Kt("/api/config",e).then(z=>z.json()).then(z=>{A||U(!!z.readonlyDefault)}).catch(()=>{}),()=>{A=!0}},[e]),l.jsx("div",{className:"nc-set-overlay",onClick:t,children:l.jsxs("div",{className:"nc-set-panel",onClick:A=>A.stopPropagation(),children:[l.jsxs("div",{className:"nc-set-head",children:[l.jsx(nt,{name:"gear",size:18}),l.jsx("b",{children:f("settings")}),l.jsx("button",{type:"button",className:"nc-set-close",onClick:t,title:f("close"),children:l.jsx(nt,{name:"x",size:18})})]}),O&&l.jsx("div",{className:"nc-set-readonly",children:f("settings-readonly")}),V&&l.jsx("div",{className:"nc-err",children:V}),l.jsx("div",{className:`nc-set-tabs-wrap${v.start?" has-start-overflow":""}${v.end?" has-end-overflow":""}`,children:l.jsx("div",{className:"nc-set-tabs",ref:p,onScroll:F,children:["nodes","fleet","audio","input","system"].map(A=>l.jsx("button",{ref:u===A?m:null,type:"button",className:`nc-set-tabbtn${u===A?" on":""}`,onClick:()=>h(A),children:f(`tab-${A}`)},A))})}),l.jsxs("div",{className:"nc-set-body",children:[u==="nodes"&&l.jsx(Yj,{token:e,nodes:S,roster:Q,settings:k,readonly:O,vlUnavailable:C,refresh:B,refreshAliases:()=>G(A=>A+1)}),u==="fleet"&&l.jsx(Rj,{token:e,readonly:O,startNewCell:o,initialLocation:s,targets:Q.map(A=>({route:A.route,label:A.label||A.name,status:A.status}))}),u==="audio"&&l.jsx(Qj,{token:e,readonly:O,nodes:S,settings:k}),u==="input"&&l.jsx(Jj,{}),u==="system"&&l.jsx(eR,{token:e,settings:k,readonly:O,refresh:B,roster:Q,section:w,setSection:b})]})]})})}function nR({token:e,initialPair:t,deviceDefault:n="",localNodeId:s="",localNameDefault:o="",onPairDone:a,onDone:u}){Dn();const[h,p]=E.useState(t?"pair":"welcome"),[m,v]=E.useState(!1),[y,w]=E.useState(null),b=async()=>{v(!0),w(null);try{await qd(e,{wizardDone:!0}),a&&a(),u()}catch(k){w(String(k.message||k)),v(!1)}};return l.jsx("div",{className:"nc-wiz-overlay",children:l.jsxs("div",{className:"nc-wiz",children:[l.jsxs("div",{className:"nc-wiz-head",children:[l.jsx("b",{children:f("wizard-title")}),l.jsx("small",{children:f("hydra-simple")})]}),h==="welcome"&&l.jsxs("div",{className:"nc-wiz-body",children:[l.jsx("div",{className:"nc-wiz-done",children:f("local-ready")}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{className:"nc-btn ghost",disabled:m,onClick:b,children:f("local-only")}),l.jsx("button",{className:"nc-btn primary",disabled:m,onClick:()=>p("pair"),children:f("add-node")})]})]}),h==="pair"&&l.jsxs("div",{className:"nc-wiz-body",children:[l.jsx(rb,{token:e,initial:t||"",autoStart:!!t,deviceDefault:n,localNodeId:s,localNameDefault:o,onBusyChange:v,onSuccess:async()=>{a&&a(),p("done")}}),l.jsx("div",{className:"nc-sheet-actions",children:l.jsx("button",{className:"nc-btn ghost",disabled:m,onClick:()=>{a&&a(),p("welcome")},children:f("back")})})]}),h==="done"&&l.jsxs("div",{className:"nc-wiz-body",children:[l.jsx("div",{className:"nc-wiz-done",children:f("node-connected")}),l.jsx("div",{className:"nc-sheet-actions",children:l.jsx("button",{className:"nc-btn primary",disabled:m,onClick:b,children:f("finish")})})]}),y&&l.jsx("div",{className:"nc-err",children:y})]})})}function iR(e,t){if(typeof EventSource>"u"||!e)return()=>{};const n=new EventSource(`/api/events?token=${encodeURIComponent(e)}`);return n.onmessage=s=>{try{const o=JSON.parse(s.data);o&&typeof o=="object"&&typeof o.type=="string"&&t(o)}catch{}},()=>{try{n.close()}catch{}}}const sR=6e3,rR=12e3;function oR({n:e,onClose:t}){return l.jsxs("div",{className:`nc-ntf-toast${e.urgency==="high"?" high":""}`,role:"status","aria-live":"polite",children:[l.jsxs("div",{className:"nc-ntf-toast-txt",children:[l.jsx("b",{children:e.title}),e.body&&l.jsx("small",{children:e.body}),e.session&&l.jsx("span",{className:"nc-ntf-from",children:e.session})]}),l.jsx("button",{type:"button",className:"nc-ntf-x",onClick:t,title:f("close"),children:l.jsx(nt,{name:"x",size:14})})]})}function aR({ask:e,token:t,onAnswered:n,onDismiss:s}){const[o,a]=E.useState(""),[u,h]=E.useState(!1),[p,m]=E.useState(null),[v,y]=E.useState(!1),w=async k=>{const N=String(k||"").trim();if(!(!N||u)){m(null),h(!0);try{await ux(t,e.id,N),n(e.id)}catch(S){m(String(S.message||S))}h(!1)}},b=async()=>{if(!v){y(!0);try{await dx(t,e.id),s(e.id)}catch{y(!1)}}};return l.jsxs("div",{className:"nc-ask-card",children:[l.jsxs("div",{className:"nc-ask-head",children:[l.jsx("span",{className:"nc-ntf-from",children:e.session}),l.jsxs("code",{className:"nc-ask-id",children:["#",e.id]}),l.jsx("button",{type:"button",className:"nc-ask-dismiss",title:f("ask-dismiss"),"aria-label":f("ask-dismiss"),disabled:v,onClick:b,children:l.jsx(nt,{name:"x",size:14})})]}),l.jsx("div",{className:"nc-ask-q",children:e.question}),Array.isArray(e.options)&&e.options.length>0&&l.jsx("div",{className:"nc-ask-opts",children:e.options.map(k=>l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u,onClick:()=>w(k),children:k},k))}),l.jsxs("div",{className:"nc-ask-reply",children:[l.jsx("textarea",{rows:2,placeholder:f("ask-reply-ph"),value:o,disabled:u,onChange:k=>a(k.target.value)}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:u||!o.trim(),onClick:()=>w(o),children:f("send")})]}),p&&l.jsx("div",{className:"nc-err",children:p})]})}function lR({token:e}){const[t]=Dn(),[n]=Sb(),[s,o]=E.useState([]),[a,u]=E.useState([]),[h,p]=E.useState(()=>{try{return/(?:^|[#&])ask=/.test(location.hash)}catch{return!1}}),m=E.useRef(0),v=E.useRef(null);v.current||(v.current=Kj());const y=E.useRef({enabled:n,lang:t});y.current={enabled:n,lang:t};const w=E.useCallback(S=>{o(j=>j.filter(C=>C.key!==S))},[]),b=E.useCallback(S=>{const j=`t${m.current+=1}`;o($=>[...$.slice(-3),{...S,key:j}]),setTimeout(()=>w(j),S.urgency==="high"?rR:sR);const C=y.current;if(C.enabled)try{v.current.enqueue(S,$j(S,C.lang))}catch{}},[w]);E.useEffect(()=>{n||v.current.stop()},[n]),E.useEffect(()=>{const S=()=>{(document.visibilityState!=="visible"||!document.hasFocus())&&v.current.stop()},j=()=>v.current.stop();return document.addEventListener("visibilitychange",S),window.addEventListener("blur",S),window.addEventListener(Uh,j),()=>{document.removeEventListener("visibilitychange",S),window.removeEventListener("blur",S),window.removeEventListener(Uh,j),typeof v.current.dispose=="function"?v.current.dispose():v.current.stop()}},[]),E.useEffect(()=>{if(!e)return;let S=!1;cx(e).then(C=>{S||u(C.asks||[])}).catch(()=>{});const j=iR(e,C=>{C.type==="notify"?b(C):C.type==="ask"&&C.ask&&C.ask.id?u($=>$.some(O=>O.id===C.ask.id)?$:[...$,C.ask]):C.type==="ask-answered"&&C.id?u($=>$.filter(O=>O.id!==C.id)):C.type==="ask-dismissed"&&C.id&&u($=>$.filter(O=>O.id!==C.id))});return()=>{S=!0,j()}},[e,b]);const k=S=>u(j=>j.filter(C=>C.id!==S)),N=S=>u(j=>j.filter(C=>C.id!==S));return l.jsxs(l.Fragment,{children:[s.length>0&&l.jsx("div",{className:"nc-ntf-toasts",children:s.map(S=>l.jsx(oR,{n:S,onClose:()=>w(S.key)},S.key))}),a.length>0&&!h&&l.jsxs("button",{type:"button",className:"nc-ask-badge",onClick:()=>p(!0),title:f("asks-title"),children:["? ",l.jsx("span",{className:"nc-ask-count",children:a.length})]}),a.length>0&&h&&l.jsxs("div",{className:"nc-ask-panel",children:[l.jsxs("div",{className:"nc-ask-panel-head",children:[l.jsx("b",{children:f("asks-title")}),l.jsx("span",{className:"nc-ask-count",children:a.length}),l.jsx("button",{type:"button",className:"nc-ntf-x",onClick:()=>p(!1),title:f("close"),children:l.jsx(nt,{name:"x",size:16})})]}),l.jsx("div",{className:"nc-ask-panel-body",children:a.map(S=>l.jsx(aR,{ask:S,token:e,onAnswered:k,onDismiss:N},S.id))})]})]})}const cR=4e3;async function uR(e){const t=await Kt("/api/sessions",e);if((t==null?void 0:t.ok)===!1)throw new Error(`HTTP ${t.status}`);const n=await t.json();if(!Array.isArray(n==null?void 0:n.sessions))throw new Error("invalid sessions payload");return n.sessions}async function Hd(e,t=[]){var h;const[n,s]=await Promise.allSettled([t.length?ef(e,t):uR(e),Rs(e,t)]),o=n.status==="fulfilled"&&Array.isArray((h=n.value)==null?void 0:h.sessions)?n.value.sessions:Array.isArray(n.value)?n.value:null,a=s.status==="fulfilled"?s.value:null,u=(a==null?void 0:a.available)===!0&&Array.isArray(a.cells)?a.cells:null;return{sessions:o,cells:u,fresh:Array.isArray(o)&&Array.isArray(u)}}function xb(e,t,n){return n===!0&&(e==null?void 0:e.degraded)!==!0&&(e==null?void 0:e.active)===!0&&e.tmux!==!1&&!!e.tmuxSession&&(t||[]).some(s=>(s==null?void 0:s.name)===e.tmuxSession)}function dR(e){const t=new Map((e.sessions||[]).map(o=>[o.name,o])),n=[],s=(o,a,u,h=[],p="")=>{const m=new Map((a||[]).map(v=>[v.name,v]));for(const v of o||[]){const y=m.get(v.tmuxSession)||{},w=cf(v,y),b=xb(v,a,u);n.push({key:Xo(h,v.tmuxSession||v.cell),session:v.tmuxSession,route:h,cellName:v.cell,label:v.cell,node:h.length?h.join("/"):"",nodeLabel:p,live:b,selectable:b,verified:u===!0,working:w.working,degraded:!!v.degraded,active:v.active===!0,activity:y.activity||v.activity||0,subtitle:w.subtitle})}};s(e.cells,[...t.values()],e.localFresh===!0);for(const o of e.nodeGroups||[]){const a=Array.isArray(o.route)?o.route:[];o.kind==="vl"||!a.length||s(o.cells,o.sessions,o.switcherFresh===!0,a,o.label||o.name||"")}return n}function hR(e){const t=new Map,n=Array.isArray(e.sessions)?e.sessions:[],s=Array.isArray(e.cells)?e.cells:[],o=new Map(n.map(u=>[u.name,u])),a=new Set(s.map(u=>u.tmuxSession).filter(Boolean));t.set("local",uf(s,n.filter(u=>!a.has(u.name)),o));for(const u of e.nodeGroups||[]){const h=Array.isArray(u.route)?u.route:[];if(u.kind==="vl"||!h.length)continue;const p=Array.isArray(u.cells)?u.cells:[],m=Array.isArray(u.sessions)?u.sessions:[],v=new Set(p.map(y=>y.tmuxSession).filter(Boolean));t.set(h.join("/"),$l({...u,route:h,cells:p,sessions:m,unmanaged:m.filter(y=>!v.has(y.name))}).rawItems)}return t}function fR(e,t,n,s){return[...new Set(e.map(a=>a.node||"local"))].flatMap(a=>{const u=e.filter(v=>(v.node||"local")===a),h=new Map((t.get(a)||[]).map(v=>[v.key,v])),p=new Map(u.map(v=>[v.key,v])),m=u.map(v=>{const y=h.get(v.key);return{...v,label:(y==null?void 0:y.label)||v.label,live:(y==null?void 0:y.live)??v.live,fresh:(y==null?void 0:y.fresh)===!0,activity:(y==null?void 0:y.activity)??v.activity}});return Cs(m,n,"all",Yi(s,a)).map(v=>p.get(v.key))})}function pR({token:e,current:t,onPick:n,onClose:s}){const[o,a]=E.useState(Fg),[u,h]=E.useState(!1),[p,m]=E.useState(!1),[v,y]=E.useState(""),[w,b]=E.useState(""),[k,N]=E.useState(""),S=E.useRef(null),j=E.useRef(null),C=E.useMemo(()=>dR(o),[o]),$=E.useMemo(()=>hR(o),[o]),{pins:O,orders:U,canMoveRoster:V,moveRoster:K,stepRoster:Z}=af(),G=E.useMemo(()=>fR(C,$,O,U),[C,$,O,U]),Q=E.useMemo(()=>u?G:G.filter(I=>I.selectable||I.degraded&&I.active),[G,u]),F=E.useMemo(()=>C.find(I=>I.key===w&&I.selectable),[C,w]);E.useEffect(()=>{var P;const I=document.activeElement;(P=j.current)==null||P.focus();const D=x=>{x.key==="Escape"&&s()};return document.addEventListener("keydown",D),()=>{var x;document.removeEventListener("keydown",D),(x=I==null?void 0:I.focus)==null||x.call(I)}},[s]),E.useEffect(()=>{let I=!0,D=!1;const P=async()=>{if(D)return;D=!0;const M=Fg(),L=Array.isArray(M.nodeGroups)?M.nodeGroups:[],T=Hd(e),H=ie=>ie.kind!=="vl"&&Array.isArray(ie.route)&&ie.route.length>0,Y=await Promise.all(L.filter(H).map(async ie=>({group:ie,result:await Hd(e,ie.route)}))),de=await T;if(!I)return;const ue=new Map(Y.map(({group:ie,result:ye})=>[JSON.stringify(ie.route||[]),ye])),fe=L.map(ie=>{if(!H(ie))return{...ie,switcherFresh:!1};const ye=ue.get(JSON.stringify(ie.route||[]));return ye?{...ie,sessions:ye.sessions||ie.sessions||[],cells:ye.cells||ie.cells||[],switcherFresh:ye.fresh}:{...ie,switcherFresh:!1}}),ve=Ly({...M,sessions:de.sessions||M.sessions||[],cells:de.cells||M.cells||[],localFresh:de.fresh,nodeGroups:fe,refreshedAt:Date.now()});a(ve),m(!0),D=!1};P();const x=setInterval(P,cR);return()=>{I=!1,clearInterval(x)}},[e]);const B=I=>I.degraded?f("cell-degraded"):I.verified?I.selectable?I.working?f("cell-working"):f("cell-idle"):f("cell-off"):f("cell-switcher-not-confirmed"),A=I=>{if(y(""),!I.selectable){y(f("cell-switcher-not-active"));return}b(I.key)},z=async()=>{const I=F;if(!I){y(f("cell-switcher-select"));return}y(""),N(I.key);try{const D=await Hd(e,I.route),P=(D.cells||[]).find(x=>(x==null?void 0:x.cell)===I.cellName&&(x==null?void 0:x.tmuxSession)===I.session);if(!xb(P,D.sessions,D.fresh)){y(f("cell-switcher-not-active"));return}n({session:I.session,...I.node?{node:I.node}:{},cellName:I.cellName}),s()}catch{y(f("cell-switcher-not-active"))}finally{N("")}};return l.jsx("div",{className:"nc-cell-switcher-backdrop",onClick:s,children:l.jsxs("aside",{ref:S,className:"nc-cell-switcher",role:"dialog","aria-label":f("fleet-cells"),tabIndex:-1,onClick:I=>I.stopPropagation(),children:[l.jsxs("div",{className:"nc-cell-switcher-list",children:[!p&&l.jsx("div",{className:"nc-empty",role:"status",children:f("cell-switcher-refreshing")}),p&&Q.length===0&&l.jsx("div",{className:"nc-empty",role:"status",children:f("cell-switcher-empty-active")}),Q.map(I=>{const D=(t==null?void 0:t.session)===I.session&&((t==null?void 0:t.node)||"")===I.node,P=w===I.key,x=B(I),M=I.node||"local",L=$.get(M)||C.filter(T=>(T.node||"local")===M);return l.jsxs("div",{className:`nc-cell-switcher-row${D?" current":""}${P?" selected":""}${I.selectable?"":" off"}`,"data-roster-key":I.key,"data-position":M,children:[l.jsx(ji,{position:M,itemKey:I.key,label:I.cellName,canMove:V,onMove:(T,H)=>K(M,T,H,L),onStep:T=>Z(M,I.key,T,L)}),l.jsxs("button",{type:"button",className:"nc-cell-switcher-row-select","aria-current":D?"true":void 0,"aria-pressed":P,"aria-disabled":!I.selectable,disabled:k===I.key,onClick:()=>A(I),children:[l.jsx("span",{className:`nc-cell-switcher-dot${I.degraded?" warn":I.live?` on${I.working?" working":""}`:""}`}),l.jsxs("span",{className:"nc-cell-switcher-copy",children:[l.jsx("b",{children:I.cellName}),l.jsx("small",{className:"nc-cell-switcher-state",children:x}),l.jsx("small",{children:[I.nodeLabel,I.subtitle].filter(Boolean).join(" · ")})]})]})]},I.key)})]}),v&&l.jsx("div",{className:"nc-cell-switcher-notice",role:"status",children:v}),l.jsx("div",{className:"nc-cell-switcher-actions",children:l.jsx("button",{type:"button",className:"nc-cell-switcher-open",disabled:!F||!!k,onClick:z,children:F?`${f("cell-switcher-open")}: ${F.cellName}`:f("cell-switcher-select")})}),l.jsxs("div",{className:"nc-cell-switcher-controls",children:[l.jsx("b",{children:f("fleet-cells")}),l.jsx("button",{type:"button",className:"nc-cell-switcher-filter","aria-pressed":u,onClick:()=>{y(""),h(I=>!I)},children:f(u?"cell-switcher-show-active":"cell-switcher-show-all")}),l.jsx("button",{ref:j,type:"button",className:"nc-cell-switcher-close","aria-label":f("cell-switcher-close"),title:f("cell-switcher-close"),onClick:s,children:"×"})]})]})})}const mR=2e3;function gR(e){if(e.kind==="gap")return`${f("vl-events-gap")} ${e.count||"?"}`;if(e.kind==="truncate")return f("vl-events-truncated");if(e.kind==="turn_end")return f("vl-events-turn-end");if(e.kind==="done")return f("vl-events-done");if(e.kind==="writer_epoch")return f("vl-events-writer-epoch");if(e.kind==="tool_start")return`${f("vl-events-tool")} ${e.name||""}`.trim();if(e.kind==="tool_end"){const t=e.isError?f("vl-events-tool-failed"):f("vl-events-tool-ok");return`${f("vl-events-tool")} ${e.name||""} — ${t}`.trim()}return e.kind==="usage"?e.text||f("vl-events-usage"):e.text||""}function vR({token:e,nodeId:t,route:n=[]}){const[s,o]=E.useState([]),[a,u]=E.useState(!1),h=E.useRef(0),p=E.useRef(!1);return E.useEffect(()=>{let m=!0;h.current=0,p.current=!1,o([]);const v=async()=>{if(!p.current){p.current=!0;try{const b=await F0(e,t,h.current,n);if(!m)return;u(!1);const N=(Array.isArray(b==null?void 0:b.events)?b.events:[]).filter(S=>Number.isSafeInteger(S==null?void 0:S.seq)&&S.seq>h.current);N.length&&(o(S=>S.concat(N).slice(-500)),h.current=N[N.length-1].seq),Number.isSafeInteger(b==null?void 0:b.cursor)&&b.cursor>h.current&&(h.current=b.cursor)}catch{m&&u(!0)}finally{p.current=!1}}},y=()=>{v().catch(()=>{})};y();const w=setInterval(y,mR);return()=>{m=!1,clearInterval(w)}},[e,t,JSON.stringify(n)]),l.jsxs("div",{className:"nc-vl-events",children:[a&&l.jsx("div",{className:"nc-set-hint nc-vl-events-stale",children:f("vl-events-stale")}),s.length===0&&!a&&l.jsx("small",{className:"nc-set-hint","data-testid":"vl-events-empty",children:f("vl-events-empty")}),s.length>0&&l.jsx("ol",{className:"nc-vl-events-list",children:s.map(m=>l.jsx("li",{"data-testid":`vl-ev-${m.seq}`,className:`nc-vl-ev nc-vl-ev-${m.kind}${m.isError?" error":""}${m.kind==="gap"?" gap":""}`,children:gR(m)},`${m.seq}-${m.kind}`))})]})}function K_({peer:e,token:t,onBack:n}){var s;return Dn(),e?l.jsxs("section",{className:"nc-vl-session-view",children:[l.jsxs("header",{className:"nc-bar nc-bar-single",children:[l.jsxs("button",{onClick:n,title:f("back"),children:[l.jsx(nt,{name:"chevronLeft",size:18}),l.jsx("span",{className:"nc-bar-label",children:f("back")})]}),l.jsxs("span",{className:"nc-bar-center",children:[l.jsx("b",{title:e.label,children:e.label}),((s=e.session)==null?void 0:s.profile)&&l.jsxs("small",{className:"nc-bar-sub",children:[e.session.profile," · ",f("vl-events-title")]})]}),l.jsx("span",{className:"nc-bar-right"})]}),l.jsx("div",{className:"nc-vl-session-body",children:l.jsx(vR,{token:t,nodeId:e.nodeId,route:e.route||[]})})]}):null}function _R({cellId:e,panelUrl:t,route:n=[],token:s,title:o,requestTimeoutMs:a=4e3}){const[u,h]=E.useState(e&&s?"requesting":"none"),[p,m]=E.useState(""),v=E.useRef(0),y=E.useCallback(async()=>{if(!e||!s||!t){h("none");return}const b=v.current+=1;h("requesting");const k=new AbortController,N=setTimeout(()=>k.abort(),a);try{const S=await E0(s,n,e,{signal:k.signal});if(clearTimeout(N),b!==v.current)return;if(S.ok){let j="/";try{j=new URL(t).pathname||"/"}catch{}m(`${sn(n)}/panel/${encodeURIComponent(e)}${j}?ticket=${encodeURIComponent(S.ticket)}`),h("ready")}else h(S.cause)}catch(S){if(clearTimeout(N),b!==v.current)return;h(S&&S.name==="AbortError"?"timeout":"unreachable")}},[e,t,n,s,a]);E.useEffect(()=>{y()},[y]);const w=(b,k=!0)=>l.jsxs("div",{className:"nc-cellpanel nc-cellpanel-msg",role:"status",children:[l.jsx("span",{children:f(b)}),k&&l.jsx("span",{className:"nc-cellpanel-actions",children:l.jsx("button",{type:"button",title:f("panel-retry"),onClick:()=>y(),children:f("panel-retry")})})]});return u==="none"||u==="no-panel"?w("panel-none",!1):u==="requesting"?l.jsx("div",{className:"nc-cellpanel nc-cellpanel-msg",role:"status",children:l.jsx("span",{children:f("panel-checking")})}):u==="not-granted"?w("panel-not-granted"):u==="denied"||u==="unauthorized"?w("panel-denied"):u==="timeout"?w("panel-timeout"):u==="unreachable"?w("panel-unreachable"):l.jsx("iframe",{className:"nc-cellpanel nc-cellpanel-frame",src:p,title:o||f("panel"),allowFullScreen:!0})}const Ud=e=>Ai(Qs(e)).length===0,Wd=e=>Array.isArray(e)?e.join("/"):"";function yR(e){const t=new Set,n=[];for(const s of Array.isArray(e)?e:[])!s||!ei.test(String(s.instanceId||""))||!Array.isArray(s.route)||!s.route.length||t.has(s.instanceId)||(t.add(s.instanceId),n.push({instanceId:s.instanceId,route:[...s.route],label:String(s.label||s.name||s.route.join(" › ")),status:s.status||"offline"}));return n.sort((s,o)=>s.label.localeCompare(o.label))}function $o(e){return{instanceId:e.ownerId,route:e.ownerRoute||[],label:e.ownerLabel,status:e.available===!1?"offline":"up"}}function Ks(e,t,n,s=!1,o=!0){const a=t.instanceId;return{...e,id:Dr(s?null:a,e.name),ownerId:a,ownerRoute:s?[]:[...t.route],ownerLabel:s?"Local":t.label,local:s,available:o,ownerTopology:Array.isArray(n)?n:[],layout:zh(e.layout,a,n)}}function wR(e,t,n,s,o=[]){const[a,u]=E.useState([]),[h,p]=E.useState(!1),[m,v]=E.useState("idle"),[y,w]=E.useState(""),[b,k]=E.useState(""),N=E.useRef([]),S=E.useRef([]),j=E.useRef(""),C=E.useRef(t),$=E.useRef(n),O=E.useRef(!1),U=E.useRef(!0),V=E.useRef(""),K=E.useMemo(()=>yR(o),[o]),Z=K.map(L=>`${L.instanceId}:${Wd(L.route)}:${L.status}:${L.label}`).join("|");S.current=K,$.current=n,C.current=t,N.current=a;const G=E.useCallback(L=>$h(L.layout,j.current,S.current),[]),Q=E.useCallback((L,T=!0,H=C.current)=>{const Y=Qv(L,xl()),de=N.current.some(fe=>fe.id===H);N.current=Y,u(Y);const ue=Y.find(fe=>fe.id===H);if(T&&ue){U.current=!0;const fe=G(ue);s(fe),ue.local&&MN(ue.name,fe)}else de&&!ue&&(U.current=!0,s(Mr()),w("deck non più condiviso dal nodo owner"));PN(Y.filter(fe=>fe.local).map(fe=>fe.name))},[s,G]),F=E.useCallback(async L=>{let T=await pl(e);const H=T.decks.find(Y=>Y.name==="main");if(T.decks.length===1&&H&&H.revision===0&&Ud(H.layout)){const Y=RN(),de=Qs(Fh("main")||Mr());if(!Ud(de)){const ue=zh(de,L,[]);T.decks[0]=await ml(e,"main",ue,0,[])}for(const ue of Y.filter(fe=>fe!=="main"))try{let fe=await jg(e,ue,[]);const ve=Qs(Fh(ue)||Mr());Ud(ve)||(fe=await ml(e,ue,zh(ve,L,[]),fe.revision,[]))}catch{}T=await pl(e)}return T},[e]),B=E.useCallback(async({migrate:L=!1}={})=>{const T=await tf(e,[]),H=ei.test(String(T.instanceId||""))?T.instanceId:"";if(!H)throw new Error("instanceId locale non disponibile");j.current=H,k(H);const[Y,de]=await Promise.all([L?F(H):pl(e),kg(e,[]).catch(()=>({nodes:[]}))]),ue={instanceId:H,route:[],label:"Local"},fe=Y.decks.map(ie=>Ks(ie,ue,de.nodes,!0,!0)),ve=N.current;return await Promise.all(S.current.map(async ie=>{if(ie.status!=="up"){fe.push(...ve.filter(ye=>!ye.local&&ye.ownerId===ie.instanceId).map(ye=>({...ye,ownerRoute:[...ie.route],ownerLabel:ie.label,available:!1})));return}try{const[ye,Ue]=await Promise.all([pl(e,ie.route),kg(e,ie.route).catch(()=>({nodes:[]}))]);fe.push(...ye.decks.map(ut=>Ks(ut,ie,Ue.nodes,!1,!0)))}catch{fe.push(...ve.filter(Ue=>!Ue.local&&Ue.ownerId===ie.instanceId).map(Ue=>({...Ue,ownerRoute:[...ie.route],ownerLabel:ie.label,available:!1})))}})),fe.sort((ie,ye)=>ie.local===ye.local?ie.ownerLabel.localeCompare(ye.ownerLabel)||(ie.name==="main"?-1:ye.name==="main"?1:ie.name.localeCompare(ye.name)):ie.local?-1:1),fe},[e,F,Z]);E.useEffect(()=>{if(!e)return;let L=!1;const T=V.current!==e;return V.current=e,B({migrate:T}).then(H=>{if(L)return;const Y=N.current.find(fe=>fe.id===C.current),de=H.find(fe=>fe.id===C.current),ue=de&&(!Y||de.revision>Y.revision||Y.available!==de.available||Wd(Y.ownerRoute)!==Wd(de.ownerRoute));Q(H,T||!!ue&&!O.current),p(!0),de&&w("")}).catch(H=>{L||(p(!0),w(String(H.message||H)))}),()=>{L=!0}},[Q,B,Z,e]);const A=E.useCallback(async(L=C.current)=>{if(!h||!O.current)return!0;const T=N.current.find(H=>H.id===L);if(!T)return w(`deck inesistente: ${L}`),!1;if(T.available===!1)return w(`nodo owner offline: ${T.ownerLabel}`),!1;v("saving");try{const H=Gv(Qs($.current),T.ownerId,T.ownerTopology),Y=await ml(e,T.name,H,T.revision,T.ownerRoute),de=Ks(Y,$o(T),T.ownerTopology,T.local,!0);return Q(N.current.map(ue=>ue.id===L?de:ue),!1),O.current=!1,v("saved"),w(""),setTimeout(()=>v("idle"),1500),!0}catch(H){if(v("error"),w(String(H.message||H)),H.status===409&&H.data&&H.data.current){const Y=N.current.find(ue=>ue.id===L),de=Ks(H.data.current,$o(Y),Y.ownerTopology,Y.local,!0);Q(N.current.map(ue=>ue.id===L?de:ue),!1)}return!1}},[h,e,Q]);return E.useEffect(()=>{if(!h)return;if(U.current){U.current=!1;return}O.current=!0,v("saving");const L=setTimeout(A,650);return()=>clearTimeout(L)},[n,h,A]),E.useEffect(()=>{if(!h)return;const L=setInterval(async()=>{try{const T=await B(),H=N.current.find(ue=>ue.id===C.current),Y=T.find(ue=>ue.id===C.current),de=Y&&(!H||Y.revision>H.revision||H.available!==Y.available);Q(T,de&&!O.current)}catch{}},5e3);return()=>clearInterval(L)},[h,B,Q]),{decks:a,records:a,localNodeId:b,ready:h,saveState:m,error:y,setError:w,saveNow:A,select:async L=>{if(O.current&&!await A(C.current))throw new Error("salvataggio del deck corrente fallito: cambio annullato");const T=N.current.find(H=>H.id===L);if(!T)throw new Error(`deck inesistente: ${L}`);return O.current=!1,U.current=!0,G(T)},add:async(L,T=null)=>{const H=T===Ri?N.current.find(ue=>ue.local):T?N.current.find(ue=>ue.ownerId===T):null;if(!H||H.available===!1)throw new Error("nodo owner non disponibile");const Y=await jg(e,L,H.ownerRoute),de=Ks(Y,$o(H),H.ownerTopology,H.local,!0);return Q([...N.current,de],!1),de},rename:async(L,T)=>{const H=N.current.find(ve=>ve.id===L);if(!H)throw new Error("deck inesistente");if(L===C.current&&O.current&&!await A(L))throw new Error(`salvataggio di "${H.name}" fallito: rinomina annullata`);const Y=N.current.find(ve=>ve.id===L);if(!Y)throw new Error("deck inesistente");const de=await hx(e,Y.name,T,Y.revision,Y.ownerRoute),ue=Ks(de,$o(Y),Y.ownerTopology,Y.local,!0),fe=Y.local?Ri:Y.ownerId;return gd(LN(xl(),fe,L,ue.id)),Q(N.current.map(ve=>ve.id===L?ue:ve),!1),ue},remove:async L=>{const T=N.current.find(Y=>Y.id===L);if(!T)throw new Error("deck inesistente");L===C.current&&(O.current=!1),await fx(e,T.name,T.revision,T.ownerRoute);const H=T.local?Ri:T.ownerId;gd(TN(xl(),H,L)),Q(N.current.filter(Y=>Y.id!==L),!1)},reorder:(L,T)=>{const H=N.current.find(ie=>ie.id===L),Y=N.current.find(ie=>ie.id===T);if(!H||!Y)return!1;const de=H.local?Ri:H.ownerId,ue=Y.local?Ri:Y.ownerId;if(de!==ue)return!1;const fe=N.current.filter(ie=>(ie.local?Ri:ie.ownerId)===de).map(ie=>ie.id),ve=gd(AN(xl(),de,L,T,fe));return Q(Qv(N.current,ve),!1),!0},addTileTo:async(L,T)=>{const H=N.current.find(ie=>ie.id===L);if(!H)throw new Error("deck inesistente");if(H.available===!1)throw new Error(`nodo owner offline: ${H.ownerLabel}`);const Y=Fw(T,j.current,S.current);if(!Y)throw new Error("riferimento sessione non valido");const de=G(H),ue=Gv(Ry(de,Y),H.ownerId,H.ownerTopology),fe=await ml(e,H.name,ue,H.revision,H.ownerRoute),ve=Ks(fe,$o(H),H.ownerTopology,H.local,!0);return Q(N.current.map(ie=>ie.id===L?ve:ie),!1),ve},localMainId:Dr(null,"main"),parseDeckId:rc}}const bR="/sw.js",Kh="nc-sw-update";let qh=null,Vh=!1,Yh=null,kb=Object.freeze({needed:!1,kind:null,version:""}),Cb=!1;function Eb(){typeof window<"u"&&window.dispatchEvent(new Event(Kh))}function Nb(){const e=Yh||(Vh?{kind:"reload",version:""}:null);kb=Object.freeze({needed:!!e,kind:(e==null?void 0:e.kind)||null,version:(e==null?void 0:e.version)||""})}function q_(){return kb}function SR(e){return typeof window>"u"?()=>{}:(window.addEventListener(Kh,e),()=>window.removeEventListener(Kh,e))}function Uf(e){Vh!==e&&(Vh=e,Nb(),Eb())}const Kd="nc-auto-reload";function xR(){try{return typeof sessionStorage<"u"?sessionStorage:null}catch{return null}}function kR(e,t,n,s={}){let o=null;e&&t&&e!==t?o={kind:"install",version:e}:t&&n&&t!==n&&(o={kind:"reload",version:t});const a=JSON.stringify(o)===JSON.stringify(Yh);Yh=o,Nb(),a||Eb();const u=s.storage===void 0?xR():s.storage;if(!o){try{u&&u.removeItem(Kd)}catch{}return}if(o.kind!=="reload"||!u)return;const h=`${t}|${n}`;try{if(u.getItem(Kd)===h)return;u.setItem(Kd,h)}catch{return}(s.applyImpl||jb)()}function CR(e){e.addEventListener("statechange",()=>{e.state==="installed"&&navigator.serviceWorker.controller&&Uf(!0)})}function ER(){typeof navigator>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{Cb&&location.reload()}),navigator.serviceWorker.register(bR).then(e=>{qh=e,e.waiting&&Uf(!0),e.addEventListener("updatefound",()=>{const t=e.installing;t&&CR(t)}),setInterval(()=>{e.update().catch(()=>{})},3600*1e3)}).catch(()=>{}))}function jb(){Cb=!0,Uf(!1);const e=qh&&qh.waiting;e?(e.postMessage({type:"SKIP_WAITING"}),setTimeout(()=>location.reload(),4e3)):location.reload()}function NR({hash:e="",origin:t="",pathname:n="",search:s=""}={}){const o=String(e||"").replace(/^#/,""),a=`${n||""}${s||""}`;if(!o)return{token:"",pair:"",nextUrl:a};const u=new URLSearchParams(o),h=u.get("token")||"",p=u.get("pair")||"",m=p?`${t||""}${n||""}#pair=${p}`:"";return{token:h,pair:m,nextUrl:a}}const Rb=9,Pb=24,Ab="nc_side_w",V_="nc_side_min",jR=240,Y_="(min-width:1024px) and (pointer:fine)";function RR(){const e=Number(localStorage.getItem(Ab));return e>=180&&e<=480?e:jR}function PR(){const e=Number(localStorage.getItem("nc_fontsize"));return e>=Rb&&e<=Pb?e:13}function AR(){const e={token:"",pair:""};try{const{token:t,pair:n,nextUrl:s}=NR({hash:location.hash,origin:location.origin,pathname:location.pathname,search:location.search});if(t){e.token=t;try{localStorage.setItem("nc_token",t)}catch{}}if(n){e.pair=n;try{sessionStorage.setItem("nc_pair",n)}catch{}}if(location.hash)try{history.replaceState(null,"",s)}catch{}}catch{}if(e.token||(e.token=sessionStorage.getItem("nc_token")||localStorage.getItem("nc_token")||""),!e.pair){const t=sessionStorage.getItem("nc_pair");t&&(e.pair=t)}return e}function LR(e){try{return Qs(Fh(e))}catch{return Mr()}}function G_(e){if(!e)return"";const t=Math.floor(Date.now()/1e3)-e;return t<0||t<60?"ora":t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:`${Math.floor(t/86400)}g`}function TR(){const[e,t]=E.useState(()=>window.matchMedia(Y_).matches);return E.useEffect(()=>{const n=window.matchMedia(Y_),s=o=>t(o.matches);return n.addEventListener("change",s),()=>n.removeEventListener("change",s)},[]),e}function X_({session:e,node:t,ownerId:n,cellName:s,token:o,readonly:a=!1,onBack:u,onCellSwitcher:h,cellSwitcherOpen:p=!1}){Dn();const[m]=Nf(),[v,y]=E.useState(!1),[w,b]=E.useState(()=>window.matchMedia("(pointer: coarse)").matches),[k,N]=E.useState(null),[S,j]=E.useState(PR),[C,$]=E.useState(s||e),[O,U]=E.useState(""),[V,K]=E.useState(""),[Z,G]=E.useState(""),[Q,F]=E.useState(!1),B=H=>j(Y=>{const de=Math.max(Rb,Math.min(Pb,Y+H));return localStorage.setItem("nc_fontsize",String(de)),de}),A=E.useRef(()=>{}),z=E.useRef(()=>!1),I=E.useRef(()=>{}),D=E.useRef(!1),[P,x]=E.useState(!1),[M,L]=E.useState(!1),T=()=>{D.current=!D.current,x(D.current)};return E.useEffect(()=>{$(s||e),F(!1)},[s,e]),E.useEffect(()=>{let H=!0;const Y=t?t.split("/"):[],de=t?`/api/route/${t.split("/").map(encodeURIComponent).join("/")}/_`:"/api";async function ue(){let ve=null,ie=null;try{const ut=await(await Kt(`${de}/sessions`,o)).json();Array.isArray(ut.sessions)&&(ve=ut.sessions.find(rt=>rt.name===e))}catch{}try{const Ue=await Rs(o,Y);Ue.available&&Array.isArray(Ue.cells)&&(ie=Ue.cells.find(ut=>ut.tmuxSession===e))}catch{}if(!H)return;$(jf({session:e,cell:ie||(s?{cell:s}:null)})),K(typeof(ie==null?void 0:ie.panelUrl)=="string"?ie.panelUrl.trim():""),G(typeof(ie==null?void 0:ie.cell)=="string"?ie.cell:"");let ye="";ie?ye=`${ie.engine}${ie.key?`·${ie.key}`:""}`:ve&&(ye=ve.attached?`attached · ${G_(ve.activity)}`:ve.activity?G_(ve.activity):""),U(ye)}ue();const fe=setInterval(ue,4e3);return()=>{H=!1,clearInterval(fe)}},[e,t,o]),l.jsxs("div",{className:"nc-app",children:[l.jsxs("header",{className:"nc-bar nc-bar-single",children:[l.jsxs("button",{onClick:u,title:f("sessions"),children:[l.jsx(nt,{name:"chevronLeft",size:18}),l.jsx("span",{className:"nc-bar-label",children:f("sessions")})]}),l.jsxs("span",{className:"nc-bar-center",children:[l.jsx("b",{title:t?`${C} · ${t}`:C,children:C}),O&&l.jsx("small",{className:"nc-bar-sub",children:O})]}),l.jsxs("span",{className:"nc-bar-right",children:[l.jsx("button",{onClick:()=>B(-1),title:f("zoom-out"),children:l.jsx(nt,{name:"zoomOut",size:18})}),l.jsx("button",{onClick:()=>B(1),title:f("zoom-in"),children:l.jsx(nt,{name:"zoomIn",size:18})}),l.jsx("button",{onClick:()=>b(H=>!H),title:f("composer"),children:l.jsx(nt,{name:"keyboard",size:20})}),l.jsx("button",{onClick:()=>y(H=>!H),title:f("files"),children:l.jsx(nt,{name:"folder",size:20})}),V&&l.jsx("button",{onClick:()=>F(H=>!H),title:f("panel"),"aria-pressed":Q,children:l.jsx(nt,{name:"monitor",size:20})})]})]}),l.jsxs("div",{className:"nc-termwrap",children:[l.jsx(Ew,{session:e,node:t,token:o,readonly:a,takeSize:!0,sendRef:A,composerRef:z,actionRef:I,ctrlRef:D,setCtrlArmed:x,onFiles:N,fontSize:S,selectionMode:M,onSelectionModeChange:L,keyboardGesture:m.terminalKeyboardGesture}),Q&&V&&Z&&l.jsx(_R,{cellId:Z,panelUrl:V,route:t?t.split("/"):[],token:o,title:C})]}),l.jsx(ZE,{onKeyboard:()=>b(H=>!H),onCellSwitcher:h,cellSwitcherOpen:p,send:H=>A.current(H),action:H=>I.current(H),ctrlArmed:P,onCtrl:T,selectionMode:M,onSelectionMode:L,keepKeyboardClosed:m.keybarKeepsKeyboardClosed,showEnter:m.showKeybarEnter,keybarLayout:m.keybarLayout}),w&&l.jsx(Iw,{submitText:H=>z.current(H),token:o,session:e,node:t,ownerId:n,keepKeyboardClosedOnVoice:m.voiceKeepsKeyboardClosed}),v&&l.jsx(Nw,{session:e,node:t,token:o,filesEvent:k,onClose:()=>y(!1)})]})}function MR(){Dn();const[e]=E.useState(AR),[t,n]=E.useState(e.token),[s,o]=E.useState(e.pair||""),a=E.useCallback(()=>{o("");try{sessionStorage.removeItem("nc_pair")}catch{}},[]),[u,h]=E.useState(!1),p=TR(),[m]=E.useState(()=>jN(typeof location<"u"?location.pathname:"/")),[v,y]=E.useState(m.id),w=v===Dr(null,ti),[b,k]=E.useState(null),N=ce=>{const je=js(ce);k(je?{...je,...typeof(ce==null?void 0:ce.cellName)=="string"&&ce.cellName?{cellName:ce.cellName}:{}}:null)},[S,j]=E.useState([]),[C,$]=E.useState([]),[O,U]=E.useState([]),[V,K]=E.useState(()=>m.ownerId?Mr():LR(m.name)),[Z,G]=E.useState(null),[Q,F]=E.useState(null),B=ce=>F(js(ce)),[A,z]=E.useState(null),I=rf(t,p),D=E.useMemo(()=>(I||[]).filter(ce=>ce.instanceId).map(ce=>({instanceId:ce.instanceId,route:ce.route,label:ce.label,status:ce.status})),[I]),P=wR(t,v,V,K,D),x=P.decks;E.useEffect(()=>{const ce=new Map;for(const je of I||[]){const qe=(je.route||[je.name]).join("/"),ot=new Set((je.sessions||[]).map(Vt=>Vt.name));for(const Vt of je.cells||[])!Vt.cell||!Vt.tmuxSession||Vt.cell===Vt.tmuxSession||ot.has(Vt.cell)||ce.set(`${qe}:${Vt.cell}`,`${qe}:${Vt.tmuxSession}`)}K(je=>qx(je,ce))},[I]),E.useEffect(()=>{P.localNodeId&&K(ce=>{const je=$h(ce,P.localNodeId,D);return JSON.stringify(je)===JSON.stringify(ce)?ce:je})},[D,P.localNodeId]);const[M,L]=E.useState(null),[T,H]=E.useState(null),Y=E.useRef(0),[de,ue]=E.useState(!1),[fe,ve]=E.useState(RR),[ie,ye]=E.useState(!w),[Ue,ut]=E.useState(()=>w?localStorage.getItem(V_)==="1":!0),[rt,Ae]=E.useState(!1),[Dt,Qt]=E.useState("nodes"),[$e,dt]=E.useState(!1),[it,wt]=E.useState(""),[bt,mt]=E.useState(!1),gt=(ce="nodes",je=!1,qe="")=>{Qt(ce),dt(je),wt(qe),Ae(!0)},[pt,Pt]=E.useState(!1),[vt,xt]=E.useState({deviceDefault:"",localNodeId:"",localNameDefault:""}),[Se,le]=E.useState(!1);E.useEffect(()=>{try{localStorage.setItem(Ab,String(fe))}catch{}},[fe]),E.useEffect(()=>{try{localStorage.setItem(V_,Ue?"1":"")}catch{}},[Ue]),E.useEffect(()=>{if(!t)return;let ce=!1;return Promise.all([ry(t),Kt("/api/config",t).then(je=>je.json())]).then(([je,qe])=>{ce||(xt({deviceDefault:je.deviceName||"",localNodeId:je.nodeId||"",localNameDefault:je.localName||""}),le(!!qe.readonlyDefault),(je.firstRun===!0&&!qe.readonlyDefault||s)&&Pt(!0))}).catch(()=>{}),()=>{ce=!0}},[t,s]);const[Pe,We]=E.useState(null),[te,we]=E.useState(null),[Ne,De]=E.useState(0),Oe=E.useCallback(async()=>{try{const je=await(await Kt("/api/sessions",t)).json();je.error||j(je.sessions||[])}catch{}try{const ce=await Rs(t);$(ce.available?ce.cells||[]:[]),U(ce.available?ce.capabilities||[]:[])}catch{$([]),U([])}},[t]);E.useEffect(()=>{let ce=!1;const je=async()=>{try{const ot=await px(t);if(ce)return;We(ot&&typeof ot.hostCell=="string"?ot.hostCell:null),we(ot&&ot.host&&typeof ot.host.lease=="string"?ot.host.lease:null),De(Number.isInteger(ot&&ot.revision)?ot.revision:0)}catch{}};je();const qe=setInterval(je,4e3);return()=>{ce=!0,clearInterval(qe)}},[t]),E.useEffect(()=>{if(!p)return;Oe();const ce=setInterval(Oe,4e3);return()=>clearInterval(ce)},[p,Oe]);const _t=E.useCallback(async ce=>{try{const je=await mx(t,ce,Ne);We(je.hostCell||null),De(Number.isInteger(je.revision)?je.revision:Ne)}catch{}},[t,Ne]),yt=E.useCallback(async()=>{try{const ce=await gx(t,Ne);return We(ce.hostCell||null),De(Number.isInteger(ce.revision)?ce.revision:Ne),!0}catch{return!1}},[t,Ne]);E.useEffect(()=>{let ce=!1;const je=()=>{Kt("/api/config",t).then(ot=>ot.json()).then(ot=>{ce||kR(ot.version,ot.uiVersion,"0.9.0")}).catch(()=>{})};je();const qe=setInterval(je,6e4);return()=>{ce=!0,clearInterval(qe)}},[t]);const X=new Set([...S.map(ce=>ce.name),...I.flatMap(ce=>ce.sessions.map(je=>je.key))]),se=Ai(V),W=ce=>K(je=>{const qe=Fw(ce,P.localNodeId,D)||ce,ot=Ry(je,qe);return ot===je&&Ai(je).length>=9&&P.setError(f("grid-full")),ot}),oe=async(ce,je=[])=>{try{await Jh(t,ce,je)}catch{return}const qe=je.length?`${je.join("/")}:${ce}`:ce;K(ot=>Hl(ot,qe)),Oe()},pe=async(ce,je,qe=[])=>{try{await sy(t,ce,je,qe)}catch{return}Oe()},_e=async(ce,je,qe=[])=>{await ty(t,{cell:ce,enabled:!!je},qe),Oe()},Be=async ce=>{if(!M)return;const{cell:je}=M,qe=Array.isArray(M.route)?M.route:[];if(ce.action==="up"){const Vt=await Qh(t,{cell:je,boot:!!ce.boot,...ce.engine?{engine:ce.engine}:{},...ce.model!==void 0?{model:ce.model}:{},...ce.permissionPolicy?{permissionPolicy:ce.permissionPolicy}:{}},qe),Nt=ff(Vt);Nt&&P.setError(Nt.text)}else await Il(t,{cell:je,boot:!!ce.boot},qe);const ot=ce.action==="up"?!!ce.boot:ce.boot?!1:!!M.boot;H({id:++Y.current,cell:je,route:qe,enabled:ot}),Oe()},me=E.useCallback(ce=>{H(je=>(je==null?void 0:je.id)===ce?null:je)},[]),Ce=async ce=>{if(!(!(ce!=null&&ce.direct)||de)){ue(!0);try{await nf(t,ce.name,ce.tunnelStatus==="up"?"down":"up")}finally{ue(!1)}}},Ge=async(ce,je)=>{const qe=String(je||"").trim();return!(ce!=null&&ce.direct)||!zr(qe)?!1:(await ly(t,ce.name,qe),!0)},rn=ce=>{const je=x.find(qe=>qe.id===ce);if(!je)return!1;try{const qe=window.open(md(je,t),"_blank");return qe&&(qe.opener=null),!!qe}catch{return!1}},tt=async ce=>{if(!ce||ce===v)return;const je=await P.select(ce),qe=P.records.find(ot=>ot.id===ce);y(ce),K(je),G(null),F(null);try{history.replaceState(null,"",md(qe||ce,null))}catch{}},bn=async(ce,je)=>{const qe=await P.add(ce,je);await tt(qe.id)},Ct=async(ce,je)=>{const qe=await P.rename(ce,je);if(ce===v){y(qe.id),K($h(qe.layout,P.localNodeId,D)),G(null),F(null);try{history.replaceState(null,"",md(qe,null))}catch{}}},Xe=async ce=>{await P.remove(ce),ce===v&&await tt(P.localMainId)},Jt=async(ce,je)=>{!je||je===v||(await P.addTileTo(je,ce),K(qe=>Hl(qe,ce)))};if(!t)return l.jsxs("div",{className:"nc-auth",children:[l.jsx("p",{children:f("auth-prompt")}),l.jsx("input",{onChange:ce=>n(ce.target.value.trim()),placeholder:"token"}),l.jsxs("label",{children:[l.jsx("input",{type:"checkbox",checked:u,onChange:ce=>h(ce.target.checked)})," ",f("remember-device")]}),l.jsx("button",{onClick:()=>{(u?localStorage:sessionStorage).setItem("nc_token",t)},children:"ok"})]});const dn=l.jsxs(l.Fragment,{children:[rt&&l.jsx(tR,{token:t,initialTab:Dt,initialLocation:it,startNewCell:$e,onClose:()=>{Ae(!1),dt(!1),wt("")}}),pt&&l.jsx(nR,{token:t,initialPair:s,...vt,onPairDone:a,onDone:()=>Pt(!1)}),l.jsx(lR,{token:t})]});if(!p)return A?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-single-overlay",children:l.jsx(K_,{peer:A,token:t,onBack:()=>z(null)})}),dn]}):b?l.jsxs(l.Fragment,{children:[l.jsx(X_,{session:b.session,node:b.node,ownerId:b.ownerId,cellName:b.cellName,token:t,readonly:Se,onBack:()=>k(null),onCellSwitcher:()=>mt(!0),cellSwitcherOpen:bt}),bt&&l.jsx(pR,{token:t,current:b,onPick:ce=>{N(ce),mt(!1)},onClose:()=>mt(!1)}),dn]}):l.jsxs(l.Fragment,{children:[l.jsx(uk,{onPick:N,token:t,onSettings:gt,onOpenVlSession:z,hostCell:Pe,hostLease:te,onDesignateCell:_t,onClearHostCell:yt}),dn]});const qn=w||!ie;return l.jsxs("div",{className:"nc-workspace",children:[qn&&l.jsx(gN,{sessions:S,cells:C,activeSessions:se,nodeGroups:I,fleetCapabilities:O,bootSettlement:T,onBootSettlementApplied:me,localNodeId:P.localNodeId,hostCell:Pe,hostLease:te,onDesignateCell:_t,onClearHostCell:yt,onPick:B,onAddTile:W,onPower:L,onBoot:_e,onBootError:ce=>P.setError(String((ce==null?void 0:ce.message)||ce)),onNodePower:Ce,onNodeRename:Ge,onKill:oe,onVisibility:pe,onNew:()=>gt("fleet",!0),onSettings:gt,onOpenVlSession:z,width:fe,collapsed:Ue,onResize:ve,onToggleCollapse:()=>ut(ce=>!ce)}),l.jsxs("div",{className:"nc-workspace-main",children:[l.jsx(QN,{decks:x,currentDeck:v,onCreate:bn,onRename:Ct,onDelete:Xe,onReorder:P.reorder,onOpenWindow:rn,onNavigate:tt,saveState:P.saveState,error:P.error,sidebarVisible:qn,onToggleSidebar:w?null:()=>ye(ce=>!ce)}),l.jsx(xN,{layout:V,onLayoutChange:K,token:t,readonly:Se,sessionsAlive:X,focusSession:Z,onFocus:G,onOpenSingle:B,decks:x,currentDeck:v,onSendToDeck:Jt,cells:C,nodeGroups:I})]}),A&&l.jsx("div",{className:"nc-single-overlay",children:l.jsx(K_,{peer:A,token:t,onBack:()=>z(null)})}),Q&&l.jsx("div",{className:"nc-single-overlay",children:l.jsx(X_,{session:Q.session,node:Q.node,ownerId:Q.ownerId,cellName:jf({session:Q.session,node:Q.node,ownerId:Q.ownerId,cells:C,nodeGroups:I}),token:t,readonly:Se,onBack:()=>F(null)})}),M&&l.jsx(Bl,{cell:M,token:t,route:Array.isArray(M.route)?M.route:[],onConfirm:Be,onClose:()=>L(null)}),dn]})}function DR(){Dn();const e=E.useSyncExternalStore(SR,q_,q_);if(!e.needed)return null;const t=e.kind==="install"?f("install-version-mismatch").replace("{v}",e.version):f("update-available").replace("{v}",e.version).replace(" "," ").trim();return l.jsxs("div",{className:"nc-update",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"nc-update-msg",children:t}),e.kind==="reload"&&l.jsx("button",{className:"nc-update-btn",onClick:jb,children:f("reload")})]})}ER();C0.createRoot(document.getElementById("root")).render(l.jsxs(_0.StrictMode,{children:[l.jsx(MR,{}),l.jsx(DR,{})]}));
|