@mmmbuto/nexuscrew 0.8.14 → 0.8.16
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/README.md +27 -11
- package/frontend/dist/assets/index-B9RXe5E4.js +91 -0
- package/frontend/dist/assets/{index-CopPQTMk.css → index-C-JOkuIc.css} +1 -1
- package/frontend/dist/index.html +2 -2
- package/frontend/dist/version.json +1 -1
- package/lib/cli/commands.js +6 -0
- package/lib/nodes/peering.js +24 -7
- package/lib/nodes/tunnel-supervisor.js +74 -5
- package/lib/nodes/tunnel.js +58 -6
- package/lib/server.js +8 -0
- package/package.json +1 -1
- package/frontend/dist/assets/index-BR2Qfqi2.js +0 -91
|
@@ -0,0 +1,91 @@
|
|
|
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 l of o)if(l.type==="childList")for(const u of l.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&s(u)}).observe(document,{childList:!0,subtree:!0});function n(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function s(o){if(o.ep)return;o.ep=!0;const l=n(o);fetch(o.href,l)}})();function jh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Uc={exports:{}},Os={},Kc={exports:{}},Qe={};/**
|
|
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 Kp;function nw(){if(Kp)return Qe;Kp=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"),l=Symbol.for("react.provider"),u=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),w=Symbol.iterator;function y(D){return D===null||typeof D!="object"?null:(D=w&&D[w]||D["@@iterator"],typeof D=="function"?D:null)}var _={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b=Object.assign,C={};function k(D,U,Q){this.props=D,this.context=U,this.refs=C,this.updater=Q||_}k.prototype.isReactComponent={},k.prototype.setState=function(D,U){if(typeof D!="object"&&typeof D!="function"&&D!=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,D,U,"setState")},k.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function N(){}N.prototype=k.prototype;function M(D,U,Q){this.props=D,this.context=U,this.refs=C,this.updater=Q||_}var A=M.prototype=new N;A.constructor=M,b(A,k.prototype),A.isPureReactComponent=!0;var B=Array.isArray,ee=Object.prototype.hasOwnProperty,O={current:null},H={key:!0,ref:!0,__self:!0,__source:!0};function J(D,U,Q){var ae,se={},le=null,pe=null;if(U!=null)for(ae in U.ref!==void 0&&(pe=U.ref),U.key!==void 0&&(le=""+U.key),U)ee.call(U,ae)&&!H.hasOwnProperty(ae)&&(se[ae]=U[ae]);var ce=arguments.length-2;if(ce===1)se.children=Q;else if(1<ce){for(var ke=Array(ce),Oe=0;Oe<ce;Oe++)ke[Oe]=arguments[Oe+2];se.children=ke}if(D&&D.defaultProps)for(ae in ce=D.defaultProps,ce)se[ae]===void 0&&(se[ae]=ce[ae]);return{$$typeof:e,type:D,key:le,ref:pe,props:se,_owner:O.current}}function W(D,U){return{$$typeof:e,type:D.type,key:U,ref:D.ref,props:D.props,_owner:D._owner}}function X(D){return typeof D=="object"&&D!==null&&D.$$typeof===e}function G(D){var U={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(Q){return U[Q]})}var j=/\/+/g;function E(D,U){return typeof D=="object"&&D!==null&&D.key!=null?G(""+D.key):U.toString(36)}function P(D,U,Q,ae,se){var le=typeof D;(le==="undefined"||le==="boolean")&&(D=null);var pe=!1;if(D===null)pe=!0;else switch(le){case"string":case"number":pe=!0;break;case"object":switch(D.$$typeof){case e:case t:pe=!0}}if(pe)return pe=D,se=se(pe),D=ae===""?"."+E(pe,0):ae,B(se)?(Q="",D!=null&&(Q=D.replace(j,"$&/")+"/"),P(se,U,Q,"",function(Oe){return Oe})):se!=null&&(X(se)&&(se=W(se,Q+(!se.key||pe&&pe.key===se.key?"":(""+se.key).replace(j,"$&/")+"/")+D)),U.push(se)),1;if(pe=0,ae=ae===""?".":ae+":",B(D))for(var ce=0;ce<D.length;ce++){le=D[ce];var ke=ae+E(le,ce);pe+=P(le,U,Q,ke,se)}else if(ke=y(D),typeof ke=="function")for(D=ke.call(D),ce=0;!(le=D.next()).done;)le=le.value,ke=ae+E(le,ce++),pe+=P(le,U,Q,ke,se);else if(le==="object")throw U=String(D),Error("Objects are not valid as a React child (found: "+(U==="[object Object]"?"object with keys {"+Object.keys(D).join(", ")+"}":U)+"). If you meant to render a collection of children, use an array instead.");return pe}function z(D,U,Q){if(D==null)return D;var ae=[],se=0;return P(D,ae,"","",function(le){return U.call(Q,le,se++)}),ae}function R(D){if(D._status===-1){var U=D._result;U=U(),U.then(function(Q){(D._status===0||D._status===-1)&&(D._status=1,D._result=Q)},function(Q){(D._status===0||D._status===-1)&&(D._status=2,D._result=Q)}),D._status===-1&&(D._status=0,D._result=U)}if(D._status===1)return D._result.default;throw D._result}var F={current:null},I={transition:null},re={ReactCurrentDispatcher:F,ReactCurrentBatchConfig:I,ReactCurrentOwner:O};function q(){throw Error("act(...) is not supported in production builds of React.")}return Qe.Children={map:z,forEach:function(D,U,Q){z(D,function(){U.apply(this,arguments)},Q)},count:function(D){var U=0;return z(D,function(){U++}),U},toArray:function(D){return z(D,function(U){return U})||[]},only:function(D){if(!X(D))throw Error("React.Children.only expected to receive a single React element child.");return D}},Qe.Component=k,Qe.Fragment=n,Qe.Profiler=o,Qe.PureComponent=M,Qe.StrictMode=s,Qe.Suspense=p,Qe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=re,Qe.act=q,Qe.cloneElement=function(D,U,Q){if(D==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+D+".");var ae=b({},D.props),se=D.key,le=D.ref,pe=D._owner;if(U!=null){if(U.ref!==void 0&&(le=U.ref,pe=O.current),U.key!==void 0&&(se=""+U.key),D.type&&D.type.defaultProps)var ce=D.type.defaultProps;for(ke in U)ee.call(U,ke)&&!H.hasOwnProperty(ke)&&(ae[ke]=U[ke]===void 0&&ce!==void 0?ce[ke]:U[ke])}var ke=arguments.length-2;if(ke===1)ae.children=Q;else if(1<ke){ce=Array(ke);for(var Oe=0;Oe<ke;Oe++)ce[Oe]=arguments[Oe+2];ae.children=ce}return{$$typeof:e,type:D.type,key:se,ref:le,props:ae,_owner:pe}},Qe.createContext=function(D){return D={$$typeof:u,_currentValue:D,_currentValue2:D,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},D.Provider={$$typeof:l,_context:D},D.Consumer=D},Qe.createElement=J,Qe.createFactory=function(D){var U=J.bind(null,D);return U.type=D,U},Qe.createRef=function(){return{current:null}},Qe.forwardRef=function(D){return{$$typeof:d,render:D}},Qe.isValidElement=X,Qe.lazy=function(D){return{$$typeof:S,_payload:{_status:-1,_result:D},_init:R}},Qe.memo=function(D,U){return{$$typeof:m,type:D,compare:U===void 0?null:U}},Qe.startTransition=function(D){var U=I.transition;I.transition={};try{D()}finally{I.transition=U}},Qe.unstable_act=q,Qe.useCallback=function(D,U){return F.current.useCallback(D,U)},Qe.useContext=function(D){return F.current.useContext(D)},Qe.useDebugValue=function(){},Qe.useDeferredValue=function(D){return F.current.useDeferredValue(D)},Qe.useEffect=function(D,U){return F.current.useEffect(D,U)},Qe.useId=function(){return F.current.useId()},Qe.useImperativeHandle=function(D,U,Q){return F.current.useImperativeHandle(D,U,Q)},Qe.useInsertionEffect=function(D,U){return F.current.useInsertionEffect(D,U)},Qe.useLayoutEffect=function(D,U){return F.current.useLayoutEffect(D,U)},Qe.useMemo=function(D,U){return F.current.useMemo(D,U)},Qe.useReducer=function(D,U,Q){return F.current.useReducer(D,U,Q)},Qe.useRef=function(D){return F.current.useRef(D)},Qe.useState=function(D){return F.current.useState(D)},Qe.useSyncExternalStore=function(D,U,Q){return F.current.useSyncExternalStore(D,U,Q)},Qe.useTransition=function(){return F.current.useTransition()},Qe.version="18.3.1",Qe}var qp;function Th(){return qp||(qp=1,Kc.exports=nw()),Kc.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 Vp;function rw(){if(Vp)return Os;Vp=1;var e=Th(),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,l={key:!0,ref:!0,__self:!0,__source:!0};function u(d,p,m){var S,w={},y=null,_=null;m!==void 0&&(y=""+m),p.key!==void 0&&(y=""+p.key),p.ref!==void 0&&(_=p.ref);for(S in p)s.call(p,S)&&!l.hasOwnProperty(S)&&(w[S]=p[S]);if(d&&d.defaultProps)for(S in p=d.defaultProps,p)w[S]===void 0&&(w[S]=p[S]);return{$$typeof:t,type:d,key:y,ref:_,props:w,_owner:o.current}}return Os.Fragment=n,Os.jsx=u,Os.jsxs=u,Os}var Yp;function sw(){return Yp||(Yp=1,Uc.exports=rw()),Uc.exports}var h=sw(),L=Th();const ow=jh(L);var va={},qc={exports:{}},ai={},Vc={exports:{}},Yc={};/**
|
|
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 Xp;function aw(){return Xp||(Xp=1,(function(e){function t(I,re){var q=I.length;I.push(re);e:for(;0<q;){var D=q-1>>>1,U=I[D];if(0<o(U,re))I[D]=re,I[q]=U,q=D;else break e}}function n(I){return I.length===0?null:I[0]}function s(I){if(I.length===0)return null;var re=I[0],q=I.pop();if(q!==re){I[0]=q;e:for(var D=0,U=I.length,Q=U>>>1;D<Q;){var ae=2*(D+1)-1,se=I[ae],le=ae+1,pe=I[le];if(0>o(se,q))le<U&&0>o(pe,se)?(I[D]=pe,I[le]=q,D=le):(I[D]=se,I[ae]=q,D=ae);else if(le<U&&0>o(pe,q))I[D]=pe,I[le]=q,D=le;else break e}}return re}function o(I,re){var q=I.sortIndex-re.sortIndex;return q!==0?q:I.id-re.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var u=Date,d=u.now();e.unstable_now=function(){return u.now()-d}}var p=[],m=[],S=1,w=null,y=3,_=!1,b=!1,C=!1,k=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function A(I){for(var re=n(m);re!==null;){if(re.callback===null)s(m);else if(re.startTime<=I)s(m),re.sortIndex=re.expirationTime,t(p,re);else break;re=n(m)}}function B(I){if(C=!1,A(I),!b)if(n(p)!==null)b=!0,R(ee);else{var re=n(m);re!==null&&F(B,re.startTime-I)}}function ee(I,re){b=!1,C&&(C=!1,N(J),J=-1),_=!0;var q=y;try{for(A(re),w=n(p);w!==null&&(!(w.expirationTime>re)||I&&!G());){var D=w.callback;if(typeof D=="function"){w.callback=null,y=w.priorityLevel;var U=D(w.expirationTime<=re);re=e.unstable_now(),typeof U=="function"?w.callback=U:w===n(p)&&s(p),A(re)}else s(p);w=n(p)}if(w!==null)var Q=!0;else{var ae=n(m);ae!==null&&F(B,ae.startTime-re),Q=!1}return Q}finally{w=null,y=q,_=!1}}var O=!1,H=null,J=-1,W=5,X=-1;function G(){return!(e.unstable_now()-X<W)}function j(){if(H!==null){var I=e.unstable_now();X=I;var re=!0;try{re=H(!0,I)}finally{re?E():(O=!1,H=null)}}else O=!1}var E;if(typeof M=="function")E=function(){M(j)};else if(typeof MessageChannel<"u"){var P=new MessageChannel,z=P.port2;P.port1.onmessage=j,E=function(){z.postMessage(null)}}else E=function(){k(j,0)};function R(I){H=I,O||(O=!0,E())}function F(I,re){J=k(function(){I(e.unstable_now())},re)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(I){I.callback=null},e.unstable_continueExecution=function(){b||_||(b=!0,R(ee))},e.unstable_forceFrameRate=function(I){0>I||125<I?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):W=0<I?Math.floor(1e3/I):5},e.unstable_getCurrentPriorityLevel=function(){return y},e.unstable_getFirstCallbackNode=function(){return n(p)},e.unstable_next=function(I){switch(y){case 1:case 2:case 3:var re=3;break;default:re=y}var q=y;y=re;try{return I()}finally{y=q}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(I,re){switch(I){case 1:case 2:case 3:case 4:case 5:break;default:I=3}var q=y;y=I;try{return re()}finally{y=q}},e.unstable_scheduleCallback=function(I,re,q){var D=e.unstable_now();switch(typeof q=="object"&&q!==null?(q=q.delay,q=typeof q=="number"&&0<q?D+q:D):q=D,I){case 1:var U=-1;break;case 2:U=250;break;case 5:U=1073741823;break;case 4:U=1e4;break;default:U=5e3}return U=q+U,I={id:S++,callback:re,priorityLevel:I,startTime:q,expirationTime:U,sortIndex:-1},q>D?(I.sortIndex=q,t(m,I),n(p)===null&&I===n(m)&&(C?(N(J),J=-1):C=!0,F(B,q-D))):(I.sortIndex=U,t(p,I),b||_||(b=!0,R(ee))),I},e.unstable_shouldYield=G,e.unstable_wrapCallback=function(I){var re=y;return function(){var q=y;y=re;try{return I.apply(this,arguments)}finally{y=q}}}})(Yc)),Yc}var Gp;function lw(){return Gp||(Gp=1,Vc.exports=aw()),Vc.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 Qp;function cw(){if(Qp)return ai;Qp=1;var e=Th(),t=lw();function n(i){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+i,a=1;a<arguments.length;a++)r+="&args[]="+encodeURIComponent(arguments[a]);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 l(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 d=!(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]*$/,S={},w={};function y(i){return p.call(w,i)?!0:p.call(S,i)?!1:m.test(i)?w[i]=!0:(S[i]=!0,!1)}function _(i,r,a,c){if(a!==null&&a.type===0)return!1;switch(typeof r){case"function":case"symbol":return!0;case"boolean":return c?!1:a!==null?!a.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function b(i,r,a,c){if(r===null||typeof r>"u"||_(i,r,a,c))return!0;if(c)return!1;if(a!==null)switch(a.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 C(i,r,a,c,f,g,x){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=c,this.attributeNamespace=f,this.mustUseProperty=a,this.propertyName=i,this.type=r,this.sanitizeURL=g,this.removeEmptyString=x}var k={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){k[i]=new C(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var r=i[0];k[r]=new C(r,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){k[i]=new C(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){k[i]=new C(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){k[i]=new C(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){k[i]=new C(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){k[i]=new C(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){k[i]=new C(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){k[i]=new C(i,5,!1,i.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function M(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(N,M);k[r]=new C(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(N,M);k[r]=new C(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(N,M);k[r]=new C(r,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){k[i]=new C(i,1,!1,i.toLowerCase(),null,!1,!1)}),k.xlinkHref=new C("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){k[i]=new C(i,1,!1,i.toLowerCase(),null,!0,!0)});function A(i,r,a,c){var f=k.hasOwnProperty(r)?k[r]:null;(f!==null?f.type!==0:c||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(b(r,a,f,c)&&(a=null),c||f===null?y(r)&&(a===null?i.removeAttribute(r):i.setAttribute(r,""+a)):f.mustUseProperty?i[f.propertyName]=a===null?f.type===3?!1:"":a:(r=f.attributeName,c=f.attributeNamespace,a===null?i.removeAttribute(r):(f=f.type,a=f===3||f===4&&a===!0?"":""+a,c?i.setAttributeNS(c,r,a):i.setAttribute(r,a))))}var B=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,ee=Symbol.for("react.element"),O=Symbol.for("react.portal"),H=Symbol.for("react.fragment"),J=Symbol.for("react.strict_mode"),W=Symbol.for("react.profiler"),X=Symbol.for("react.provider"),G=Symbol.for("react.context"),j=Symbol.for("react.forward_ref"),E=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),z=Symbol.for("react.memo"),R=Symbol.for("react.lazy"),F=Symbol.for("react.offscreen"),I=Symbol.iterator;function re(i){return i===null||typeof i!="object"?null:(i=I&&i[I]||i["@@iterator"],typeof i=="function"?i:null)}var q=Object.assign,D;function U(i){if(D===void 0)try{throw Error()}catch(a){var r=a.stack.trim().match(/\n( *(at )?)/);D=r&&r[1]||""}return`
|
|
34
|
+
`+D+i}var Q=!1;function ae(i,r){if(!i||Q)return"";Q=!0;var a=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(oe){var c=oe}Reflect.construct(i,[],r)}else{try{r.call()}catch(oe){c=oe}i.call(r.prototype)}else{try{throw Error()}catch(oe){c=oe}i()}}catch(oe){if(oe&&c&&typeof oe.stack=="string"){for(var f=oe.stack.split(`
|
|
35
|
+
`),g=c.stack.split(`
|
|
36
|
+
`),x=f.length-1,T=g.length-1;1<=x&&0<=T&&f[x]!==g[T];)T--;for(;1<=x&&0<=T;x--,T--)if(f[x]!==g[T]){if(x!==1||T!==1)do if(x--,T--,0>T||f[x]!==g[T]){var $=`
|
|
37
|
+
`+f[x].replace(" at new "," at ");return i.displayName&&$.includes("<anonymous>")&&($=$.replace("<anonymous>",i.displayName)),$}while(1<=x&&0<=T);break}}}finally{Q=!1,Error.prepareStackTrace=a}return(i=i?i.displayName||i.name:"")?U(i):""}function se(i){switch(i.tag){case 5:return U(i.type);case 16:return U("Lazy");case 13:return U("Suspense");case 19:return U("SuspenseList");case 0:case 2:case 15:return i=ae(i.type,!1),i;case 11:return i=ae(i.type.render,!1),i;case 1:return i=ae(i.type,!0),i;default:return""}}function le(i){if(i==null)return null;if(typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case H:return"Fragment";case O:return"Portal";case W:return"Profiler";case J:return"StrictMode";case E:return"Suspense";case P:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case G:return(i.displayName||"Context")+".Consumer";case X:return(i._context.displayName||"Context")+".Provider";case j:var r=i.render;return i=i.displayName,i||(i=r.displayName||r.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case z:return r=i.displayName||null,r!==null?r:le(i.type)||"Memo";case R:r=i._payload,i=i._init;try{return le(i(r))}catch{}}return null}function pe(i){var r=i.type;switch(i.tag){case 24:return"Cache";case 9:return(r.displayName||"Context")+".Consumer";case 10:return(r._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return i=r.render,i=i.displayName||i.name||"",r.displayName||(i!==""?"ForwardRef("+i+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return le(r);case 8:return r===J?"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 ce(i){switch(typeof i){case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function ke(i){var r=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Oe(i){var r=ke(i)?"checked":"value",a=Object.getOwnPropertyDescriptor(i.constructor.prototype,r),c=""+i[r];if(!i.hasOwnProperty(r)&&typeof a<"u"&&typeof a.get=="function"&&typeof a.set=="function"){var f=a.get,g=a.set;return Object.defineProperty(i,r,{configurable:!0,get:function(){return f.call(this)},set:function(x){c=""+x,g.call(this,x)}}),Object.defineProperty(i,r,{enumerable:a.enumerable}),{getValue:function(){return c},setValue:function(x){c=""+x},stopTracking:function(){i._valueTracker=null,delete i[r]}}}}function te(i){i._valueTracker||(i._valueTracker=Oe(i))}function ie(i){if(!i)return!1;var r=i._valueTracker;if(!r)return!0;var a=r.getValue(),c="";return i&&(c=ke(i)?i.checked?"true":"false":i.value),i=c,i!==a?(r.setValue(i),!0):!1}function ye(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 Me(i,r){var a=r.checked;return q({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:a??i._wrapperState.initialChecked})}function je(i,r){var a=r.defaultValue==null?"":r.defaultValue,c=r.checked!=null?r.checked:r.defaultChecked;a=ce(r.value!=null?r.value:a),i._wrapperState={initialChecked:c,initialValue:a,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function Y(i,r){r=r.checked,r!=null&&A(i,"checked",r,!1)}function de(i,r){Y(i,r);var a=ce(r.value),c=r.type;if(a!=null)c==="number"?(a===0&&i.value===""||i.value!=a)&&(i.value=""+a):i.value!==""+a&&(i.value=""+a);else if(c==="submit"||c==="reset"){i.removeAttribute("value");return}r.hasOwnProperty("value")?K(i,r.type,a):r.hasOwnProperty("defaultValue")&&K(i,r.type,ce(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(i.defaultChecked=!!r.defaultChecked)}function we(i,r,a){if(r.hasOwnProperty("value")||r.hasOwnProperty("defaultValue")){var c=r.type;if(!(c!=="submit"&&c!=="reset"||r.value!==void 0&&r.value!==null))return;r=""+i._wrapperState.initialValue,a||r===i.value||(i.value=r),i.defaultValue=r}a=i.name,a!==""&&(i.name=""),i.defaultChecked=!!i._wrapperState.initialChecked,a!==""&&(i.name=a)}function K(i,r,a){(r!=="number"||ye(i.ownerDocument)!==i)&&(a==null?i.defaultValue=""+i._wrapperState.initialValue:i.defaultValue!==""+a&&(i.defaultValue=""+a))}var fe=Array.isArray;function Ce(i,r,a,c){if(i=i.options,r){r={};for(var f=0;f<a.length;f++)r["$"+a[f]]=!0;for(a=0;a<i.length;a++)f=r.hasOwnProperty("$"+i[a].value),i[a].selected!==f&&(i[a].selected=f),f&&c&&(i[a].defaultSelected=!0)}else{for(a=""+ce(a),r=null,f=0;f<i.length;f++){if(i[f].value===a){i[f].selected=!0,c&&(i[f].defaultSelected=!0);return}r!==null||i[f].disabled||(r=i[f])}r!==null&&(r.selected=!0)}}function Ne(i,r){if(r.dangerouslySetInnerHTML!=null)throw Error(n(91));return q({},r,{value:void 0,defaultValue:void 0,children:""+i._wrapperState.initialValue})}function Be(i,r){var a=r.value;if(a==null){if(a=r.children,r=r.defaultValue,a!=null){if(r!=null)throw Error(n(92));if(fe(a)){if(1<a.length)throw Error(n(93));a=a[0]}r=a}r==null&&(r=""),a=r}i._wrapperState={initialValue:ce(a)}}function mt(i,r){var a=ce(r.value),c=ce(r.defaultValue);a!=null&&(a=""+a,a!==i.value&&(i.value=a),r.defaultValue==null&&i.defaultValue!==a&&(i.defaultValue=a)),c!=null&&(i.defaultValue=""+c)}function rt(i){var r=i.textContent;r===i._wrapperState.initialValue&&r!==""&&r!==null&&(i.value=r)}function Ae(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 We(i,r){return i==null||i==="http://www.w3.org/1999/xhtml"?Ae(r):i==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":i}var Ie,bt=(function(i){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,a,c,f){MSApp.execUnsafeLocalFunction(function(){return i(r,a,c,f)})}:i})(function(i,r){if(i.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in i)i.innerHTML=r;else{for(Ie=Ie||document.createElement("div"),Ie.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=Ie.firstChild;i.firstChild;)i.removeChild(i.firstChild);for(;r.firstChild;)i.appendChild(r.firstChild)}});function Ge(i,r){if(r){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=r;return}}i.textContent=r}var ge={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},qe=["Webkit","ms","Moz","O"];Object.keys(ge).forEach(function(i){qe.forEach(function(r){r=r+i.charAt(0).toUpperCase()+i.substring(1),ge[r]=ge[i]})});function et(i,r,a){return r==null||typeof r=="boolean"||r===""?"":a||typeof r!="number"||r===0||ge.hasOwnProperty(i)&&ge[i]?(""+r).trim():r+"px"}function ue(i,r){i=i.style;for(var a in r)if(r.hasOwnProperty(a)){var c=a.indexOf("--")===0,f=et(a,r[a],c);a==="float"&&(a="cssFloat"),c?i.setProperty(a,f):i[a]=f}}var De=q({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 Ke(i,r){if(r){if(De[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 Lt(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 hi=null;function sl(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var ol=null,vr=null,_r=null;function ad(i){if(i=Cs(i)){if(typeof ol!="function")throw Error(n(280));var r=i.stateNode;r&&(r=Mo(r),ol(i.stateNode,i.type,r))}}function ld(i){vr?_r?_r.push(i):_r=[i]:vr=i}function cd(){if(vr){var i=vr,r=_r;if(_r=vr=null,ad(i),r)for(i=0;i<r.length;i++)ad(r[i])}}function ud(i,r){return i(r)}function hd(){}var al=!1;function dd(i,r,a){if(al)return i(r,a);al=!0;try{return ud(i,r,a)}finally{al=!1,(vr!==null||_r!==null)&&(hd(),cd())}}function is(i,r){var a=i.stateNode;if(a===null)return null;var c=Mo(a);if(c===null)return null;a=c[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":(c=!c.disabled)||(i=i.type,c=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!c;break e;default:i=!1}if(i)return null;if(a&&typeof a!="function")throw Error(n(231,r,typeof a));return a}var ll=!1;if(d)try{var ns={};Object.defineProperty(ns,"passive",{get:function(){ll=!0}}),window.addEventListener("test",ns,ns),window.removeEventListener("test",ns,ns)}catch{ll=!1}function cy(i,r,a,c,f,g,x,T,$){var oe=Array.prototype.slice.call(arguments,3);try{r.apply(a,oe)}catch(ve){this.onError(ve)}}var rs=!1,co=null,uo=!1,cl=null,uy={onError:function(i){rs=!0,co=i}};function hy(i,r,a,c,f,g,x,T,$){rs=!1,co=null,cy.apply(uy,arguments)}function dy(i,r,a,c,f,g,x,T,$){if(hy.apply(this,arguments),rs){if(rs){var oe=co;rs=!1,co=null}else throw Error(n(198));uo||(uo=!0,cl=oe)}}function Un(i){var r=i,a=i;if(i.alternate)for(;r.return;)r=r.return;else{i=r;do r=i,(r.flags&4098)!==0&&(a=r.return),i=r.return;while(i)}return r.tag===3?a:null}function fd(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 pd(i){if(Un(i)!==i)throw Error(n(188))}function fy(i){var r=i.alternate;if(!r){if(r=Un(i),r===null)throw Error(n(188));return r!==i?null:i}for(var a=i,c=r;;){var f=a.return;if(f===null)break;var g=f.alternate;if(g===null){if(c=f.return,c!==null){a=c;continue}break}if(f.child===g.child){for(g=f.child;g;){if(g===a)return pd(f),i;if(g===c)return pd(f),r;g=g.sibling}throw Error(n(188))}if(a.return!==c.return)a=f,c=g;else{for(var x=!1,T=f.child;T;){if(T===a){x=!0,a=f,c=g;break}if(T===c){x=!0,c=f,a=g;break}T=T.sibling}if(!x){for(T=g.child;T;){if(T===a){x=!0,a=g,c=f;break}if(T===c){x=!0,c=g,a=f;break}T=T.sibling}if(!x)throw Error(n(189))}}if(a.alternate!==c)throw Error(n(190))}if(a.tag!==3)throw Error(n(188));return a.stateNode.current===a?i:r}function md(i){return i=fy(i),i!==null?gd(i):null}function gd(i){if(i.tag===5||i.tag===6)return i;for(i=i.child;i!==null;){var r=gd(i);if(r!==null)return r;i=i.sibling}return null}var vd=t.unstable_scheduleCallback,_d=t.unstable_cancelCallback,py=t.unstable_shouldYield,my=t.unstable_requestPaint,yt=t.unstable_now,gy=t.unstable_getCurrentPriorityLevel,ul=t.unstable_ImmediatePriority,yd=t.unstable_UserBlockingPriority,ho=t.unstable_NormalPriority,vy=t.unstable_LowPriority,Sd=t.unstable_IdlePriority,fo=null,Fi=null;function _y(i){if(Fi&&typeof Fi.onCommitFiberRoot=="function")try{Fi.onCommitFiberRoot(fo,i,void 0,(i.current.flags&128)===128)}catch{}}var Mi=Math.clz32?Math.clz32:wy,yy=Math.log,Sy=Math.LN2;function wy(i){return i>>>=0,i===0?32:31-(yy(i)/Sy|0)|0}var po=64,mo=4194304;function ss(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 go(i,r){var a=i.pendingLanes;if(a===0)return 0;var c=0,f=i.suspendedLanes,g=i.pingedLanes,x=a&268435455;if(x!==0){var T=x&~f;T!==0?c=ss(T):(g&=x,g!==0&&(c=ss(g)))}else x=a&~f,x!==0?c=ss(x):g!==0&&(c=ss(g));if(c===0)return 0;if(r!==0&&r!==c&&(r&f)===0&&(f=c&-c,g=r&-r,f>=g||f===16&&(g&4194240)!==0))return r;if((c&4)!==0&&(c|=a&16),r=i.entangledLanes,r!==0)for(i=i.entanglements,r&=c;0<r;)a=31-Mi(r),f=1<<a,c|=i[a],r&=~f;return c}function by(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 Cy(i,r){for(var a=i.suspendedLanes,c=i.pingedLanes,f=i.expirationTimes,g=i.pendingLanes;0<g;){var x=31-Mi(g),T=1<<x,$=f[x];$===-1?((T&a)===0||(T&c)!==0)&&(f[x]=by(T,r)):$<=r&&(i.expiredLanes|=T),g&=~T}}function hl(i){return i=i.pendingLanes&-1073741825,i!==0?i:i&1073741824?1073741824:0}function wd(){var i=po;return po<<=1,(po&4194240)===0&&(po=64),i}function dl(i){for(var r=[],a=0;31>a;a++)r.push(i);return r}function os(i,r,a){i.pendingLanes|=r,r!==536870912&&(i.suspendedLanes=0,i.pingedLanes=0),i=i.eventTimes,r=31-Mi(r),i[r]=a}function ky(i,r){var a=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 c=i.eventTimes;for(i=i.expirationTimes;0<a;){var f=31-Mi(a),g=1<<f;r[f]=0,c[f]=-1,i[f]=-1,a&=~g}}function fl(i,r){var a=i.entangledLanes|=r;for(i=i.entanglements;a;){var c=31-Mi(a),f=1<<c;f&r|i[c]&r&&(i[c]|=r),a&=~f}}var it=0;function bd(i){return i&=-i,1<i?4<i?(i&268435455)!==0?16:536870912:4:1}var Cd,pl,kd,xd,Ed,ml=!1,vo=[],vn=null,_n=null,yn=null,as=new Map,ls=new Map,Sn=[],xy="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 Nd(i,r){switch(i){case"focusin":case"focusout":vn=null;break;case"dragenter":case"dragleave":_n=null;break;case"mouseover":case"mouseout":yn=null;break;case"pointerover":case"pointerout":as.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":ls.delete(r.pointerId)}}function cs(i,r,a,c,f,g){return i===null||i.nativeEvent!==g?(i={blockedOn:r,domEventName:a,eventSystemFlags:c,nativeEvent:g,targetContainers:[f]},r!==null&&(r=Cs(r),r!==null&&pl(r)),i):(i.eventSystemFlags|=c,r=i.targetContainers,f!==null&&r.indexOf(f)===-1&&r.push(f),i)}function Ey(i,r,a,c,f){switch(r){case"focusin":return vn=cs(vn,i,r,a,c,f),!0;case"dragenter":return _n=cs(_n,i,r,a,c,f),!0;case"mouseover":return yn=cs(yn,i,r,a,c,f),!0;case"pointerover":var g=f.pointerId;return as.set(g,cs(as.get(g)||null,i,r,a,c,f)),!0;case"gotpointercapture":return g=f.pointerId,ls.set(g,cs(ls.get(g)||null,i,r,a,c,f)),!0}return!1}function Rd(i){var r=Kn(i.target);if(r!==null){var a=Un(r);if(a!==null){if(r=a.tag,r===13){if(r=fd(a),r!==null){i.blockedOn=r,Ed(i.priority,function(){kd(a)});return}}else if(r===3&&a.stateNode.current.memoizedState.isDehydrated){i.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}i.blockedOn=null}function _o(i){if(i.blockedOn!==null)return!1;for(var r=i.targetContainers;0<r.length;){var a=vl(i.domEventName,i.eventSystemFlags,r[0],i.nativeEvent);if(a===null){a=i.nativeEvent;var c=new a.constructor(a.type,a);hi=c,a.target.dispatchEvent(c),hi=null}else return r=Cs(a),r!==null&&pl(r),i.blockedOn=a,!1;r.shift()}return!0}function Pd(i,r,a){_o(i)&&a.delete(r)}function Ny(){ml=!1,vn!==null&&_o(vn)&&(vn=null),_n!==null&&_o(_n)&&(_n=null),yn!==null&&_o(yn)&&(yn=null),as.forEach(Pd),ls.forEach(Pd)}function us(i,r){i.blockedOn===r&&(i.blockedOn=null,ml||(ml=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Ny)))}function hs(i){function r(f){return us(f,i)}if(0<vo.length){us(vo[0],i);for(var a=1;a<vo.length;a++){var c=vo[a];c.blockedOn===i&&(c.blockedOn=null)}}for(vn!==null&&us(vn,i),_n!==null&&us(_n,i),yn!==null&&us(yn,i),as.forEach(r),ls.forEach(r),a=0;a<Sn.length;a++)c=Sn[a],c.blockedOn===i&&(c.blockedOn=null);for(;0<Sn.length&&(a=Sn[0],a.blockedOn===null);)Rd(a),a.blockedOn===null&&Sn.shift()}var yr=B.ReactCurrentBatchConfig,yo=!0;function Ry(i,r,a,c){var f=it,g=yr.transition;yr.transition=null;try{it=1,gl(i,r,a,c)}finally{it=f,yr.transition=g}}function Py(i,r,a,c){var f=it,g=yr.transition;yr.transition=null;try{it=4,gl(i,r,a,c)}finally{it=f,yr.transition=g}}function gl(i,r,a,c){if(yo){var f=vl(i,r,a,c);if(f===null)Tl(i,r,c,So,a),Nd(i,c);else if(Ey(f,i,r,a,c))c.stopPropagation();else if(Nd(i,c),r&4&&-1<xy.indexOf(i)){for(;f!==null;){var g=Cs(f);if(g!==null&&Cd(g),g=vl(i,r,a,c),g===null&&Tl(i,r,c,So,a),g===f)break;f=g}f!==null&&c.stopPropagation()}else Tl(i,r,c,null,a)}}var So=null;function vl(i,r,a,c){if(So=null,i=sl(c),i=Kn(i),i!==null)if(r=Un(i),r===null)i=null;else if(a=r.tag,a===13){if(i=fd(r),i!==null)return i;i=null}else if(a===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;i=null}else r!==i&&(i=null);return So=i,null}function Dd(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(gy()){case ul:return 1;case yd:return 4;case ho:case vy:return 16;case Sd:return 536870912;default:return 16}default:return 16}}var wn=null,_l=null,wo=null;function Ld(){if(wo)return wo;var i,r=_l,a=r.length,c,f="value"in wn?wn.value:wn.textContent,g=f.length;for(i=0;i<a&&r[i]===f[i];i++);var x=a-i;for(c=1;c<=x&&r[a-c]===f[g-c];c++);return wo=f.slice(i,1<c?1-c:void 0)}function bo(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 Co(){return!0}function Md(){return!1}function di(i){function r(a,c,f,g,x){this._reactName=a,this._targetInst=f,this.type=c,this.nativeEvent=g,this.target=x,this.currentTarget=null;for(var T in i)i.hasOwnProperty(T)&&(a=i[T],this[T]=a?a(g):g[T]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?Co:Md,this.isPropagationStopped=Md,this}return q(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=Co)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Co)},persist:function(){},isPersistent:Co}),r}var Sr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},yl=di(Sr),ds=q({},Sr,{view:0,detail:0}),Dy=di(ds),Sl,wl,fs,ko=q({},ds,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Cl,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!==fs&&(fs&&i.type==="mousemove"?(Sl=i.screenX-fs.screenX,wl=i.screenY-fs.screenY):wl=Sl=0,fs=i),Sl)},movementY:function(i){return"movementY"in i?i.movementY:wl}}),jd=di(ko),Ly=q({},ko,{dataTransfer:0}),My=di(Ly),jy=q({},ds,{relatedTarget:0}),bl=di(jy),Ty=q({},Sr,{animationName:0,elapsedTime:0,pseudoElement:0}),Ay=di(Ty),By=q({},Sr,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),Iy=di(By),Oy=q({},Sr,{data:0}),Td=di(Oy),zy={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Fy={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"},Hy={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function $y(i){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(i):(i=Hy[i])?!!r[i]:!1}function Cl(){return $y}var Wy=q({},ds,{key:function(i){if(i.key){var r=zy[i.key]||i.key;if(r!=="Unidentified")return r}return i.type==="keypress"?(i=bo(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?Fy[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Cl,charCode:function(i){return i.type==="keypress"?bo(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?bo(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),Uy=di(Wy),Ky=q({},ko,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ad=di(Ky),qy=q({},ds,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Cl}),Vy=di(qy),Yy=q({},Sr,{propertyName:0,elapsedTime:0,pseudoElement:0}),Xy=di(Yy),Gy=q({},ko,{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}),Qy=di(Gy),Jy=[9,13,27,32],kl=d&&"CompositionEvent"in window,ps=null;d&&"documentMode"in document&&(ps=document.documentMode);var Zy=d&&"TextEvent"in window&&!ps,Bd=d&&(!kl||ps&&8<ps&&11>=ps),Id=" ",Od=!1;function zd(i,r){switch(i){case"keyup":return Jy.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Fd(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var wr=!1;function eS(i,r){switch(i){case"compositionend":return Fd(r);case"keypress":return r.which!==32?null:(Od=!0,Id);case"textInput":return i=r.data,i===Id&&Od?null:i;default:return null}}function tS(i,r){if(wr)return i==="compositionend"||!kl&&zd(i,r)?(i=Ld(),wo=_l=wn=null,wr=!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 Bd&&r.locale!=="ko"?null:r.data;default:return null}}var iS={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 Hd(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r==="input"?!!iS[i.type]:r==="textarea"}function $d(i,r,a,c){ld(c),r=Po(r,"onChange"),0<r.length&&(a=new yl("onChange","change",null,a,c),i.push({event:a,listeners:r}))}var ms=null,gs=null;function nS(i){af(i,0)}function xo(i){var r=Er(i);if(ie(r))return i}function rS(i,r){if(i==="change")return r}var Wd=!1;if(d){var xl;if(d){var El="oninput"in document;if(!El){var Ud=document.createElement("div");Ud.setAttribute("oninput","return;"),El=typeof Ud.oninput=="function"}xl=El}else xl=!1;Wd=xl&&(!document.documentMode||9<document.documentMode)}function Kd(){ms&&(ms.detachEvent("onpropertychange",qd),gs=ms=null)}function qd(i){if(i.propertyName==="value"&&xo(gs)){var r=[];$d(r,gs,i,sl(i)),dd(nS,r)}}function sS(i,r,a){i==="focusin"?(Kd(),ms=r,gs=a,ms.attachEvent("onpropertychange",qd)):i==="focusout"&&Kd()}function oS(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return xo(gs)}function aS(i,r){if(i==="click")return xo(r)}function lS(i,r){if(i==="input"||i==="change")return xo(r)}function cS(i,r){return i===r&&(i!==0||1/i===1/r)||i!==i&&r!==r}var ji=typeof Object.is=="function"?Object.is:cS;function vs(i,r){if(ji(i,r))return!0;if(typeof i!="object"||i===null||typeof r!="object"||r===null)return!1;var a=Object.keys(i),c=Object.keys(r);if(a.length!==c.length)return!1;for(c=0;c<a.length;c++){var f=a[c];if(!p.call(r,f)||!ji(i[f],r[f]))return!1}return!0}function Vd(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function Yd(i,r){var a=Vd(i);i=0;for(var c;a;){if(a.nodeType===3){if(c=i+a.textContent.length,i<=r&&c>=r)return{node:a,offset:r-i};i=c}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Vd(a)}}function Xd(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?Xd(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function Gd(){for(var i=window,r=ye();r instanceof i.HTMLIFrameElement;){try{var a=typeof r.contentWindow.location.href=="string"}catch{a=!1}if(a)i=r.contentWindow;else break;r=ye(i.document)}return r}function Nl(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 uS(i){var r=Gd(),a=i.focusedElem,c=i.selectionRange;if(r!==a&&a&&a.ownerDocument&&Xd(a.ownerDocument.documentElement,a)){if(c!==null&&Nl(a)){if(r=c.start,i=c.end,i===void 0&&(i=r),"selectionStart"in a)a.selectionStart=r,a.selectionEnd=Math.min(i,a.value.length);else if(i=(r=a.ownerDocument||document)&&r.defaultView||window,i.getSelection){i=i.getSelection();var f=a.textContent.length,g=Math.min(c.start,f);c=c.end===void 0?g:Math.min(c.end,f),!i.extend&&g>c&&(f=c,c=g,g=f),f=Yd(a,g);var x=Yd(a,c);f&&x&&(i.rangeCount!==1||i.anchorNode!==f.node||i.anchorOffset!==f.offset||i.focusNode!==x.node||i.focusOffset!==x.offset)&&(r=r.createRange(),r.setStart(f.node,f.offset),i.removeAllRanges(),g>c?(i.addRange(r),i.extend(x.node,x.offset)):(r.setEnd(x.node,x.offset),i.addRange(r)))}}for(r=[],i=a;i=i.parentNode;)i.nodeType===1&&r.push({element:i,left:i.scrollLeft,top:i.scrollTop});for(typeof a.focus=="function"&&a.focus(),a=0;a<r.length;a++)i=r[a],i.element.scrollLeft=i.left,i.element.scrollTop=i.top}}var hS=d&&"documentMode"in document&&11>=document.documentMode,br=null,Rl=null,_s=null,Pl=!1;function Qd(i,r,a){var c=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Pl||br==null||br!==ye(c)||(c=br,"selectionStart"in c&&Nl(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),_s&&vs(_s,c)||(_s=c,c=Po(Rl,"onSelect"),0<c.length&&(r=new yl("onSelect","select",null,r,a),i.push({event:r,listeners:c}),r.target=br)))}function Eo(i,r){var a={};return a[i.toLowerCase()]=r.toLowerCase(),a["Webkit"+i]="webkit"+r,a["Moz"+i]="moz"+r,a}var Cr={animationend:Eo("Animation","AnimationEnd"),animationiteration:Eo("Animation","AnimationIteration"),animationstart:Eo("Animation","AnimationStart"),transitionend:Eo("Transition","TransitionEnd")},Dl={},Jd={};d&&(Jd=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 No(i){if(Dl[i])return Dl[i];if(!Cr[i])return i;var r=Cr[i],a;for(a in r)if(r.hasOwnProperty(a)&&a in Jd)return Dl[i]=r[a];return i}var Zd=No("animationend"),ef=No("animationiteration"),tf=No("animationstart"),nf=No("transitionend"),rf=new Map,sf="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 bn(i,r){rf.set(i,r),l(r,[i])}for(var Ll=0;Ll<sf.length;Ll++){var Ml=sf[Ll],dS=Ml.toLowerCase(),fS=Ml[0].toUpperCase()+Ml.slice(1);bn(dS,"on"+fS)}bn(Zd,"onAnimationEnd"),bn(ef,"onAnimationIteration"),bn(tf,"onAnimationStart"),bn("dblclick","onDoubleClick"),bn("focusin","onFocus"),bn("focusout","onBlur"),bn(nf,"onTransitionEnd"),u("onMouseEnter",["mouseout","mouseover"]),u("onMouseLeave",["mouseout","mouseover"]),u("onPointerEnter",["pointerout","pointerover"]),u("onPointerLeave",["pointerout","pointerover"]),l("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),l("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),l("onBeforeInput",["compositionend","keypress","textInput","paste"]),l("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ys="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(" "),pS=new Set("cancel close invalid load scroll toggle".split(" ").concat(ys));function of(i,r,a){var c=i.type||"unknown-event";i.currentTarget=a,dy(c,r,void 0,i),i.currentTarget=null}function af(i,r){r=(r&4)!==0;for(var a=0;a<i.length;a++){var c=i[a],f=c.event;c=c.listeners;e:{var g=void 0;if(r)for(var x=c.length-1;0<=x;x--){var T=c[x],$=T.instance,oe=T.currentTarget;if(T=T.listener,$!==g&&f.isPropagationStopped())break e;of(f,T,oe),g=$}else for(x=0;x<c.length;x++){if(T=c[x],$=T.instance,oe=T.currentTarget,T=T.listener,$!==g&&f.isPropagationStopped())break e;of(f,T,oe),g=$}}}if(uo)throw i=cl,uo=!1,cl=null,i}function ot(i,r){var a=r[Fl];a===void 0&&(a=r[Fl]=new Set);var c=i+"__bubble";a.has(c)||(lf(r,i,2,!1),a.add(c))}function jl(i,r,a){var c=0;r&&(c|=4),lf(a,i,c,r)}var Ro="_reactListening"+Math.random().toString(36).slice(2);function Ss(i){if(!i[Ro]){i[Ro]=!0,s.forEach(function(a){a!=="selectionchange"&&(pS.has(a)||jl(a,!1,i),jl(a,!0,i))});var r=i.nodeType===9?i:i.ownerDocument;r===null||r[Ro]||(r[Ro]=!0,jl("selectionchange",!1,r))}}function lf(i,r,a,c){switch(Dd(r)){case 1:var f=Ry;break;case 4:f=Py;break;default:f=gl}a=f.bind(null,r,a,i),f=void 0,!ll||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(f=!0),c?f!==void 0?i.addEventListener(r,a,{capture:!0,passive:f}):i.addEventListener(r,a,!0):f!==void 0?i.addEventListener(r,a,{passive:f}):i.addEventListener(r,a,!1)}function Tl(i,r,a,c,f){var g=c;if((r&1)===0&&(r&2)===0&&c!==null)e:for(;;){if(c===null)return;var x=c.tag;if(x===3||x===4){var T=c.stateNode.containerInfo;if(T===f||T.nodeType===8&&T.parentNode===f)break;if(x===4)for(x=c.return;x!==null;){var $=x.tag;if(($===3||$===4)&&($=x.stateNode.containerInfo,$===f||$.nodeType===8&&$.parentNode===f))return;x=x.return}for(;T!==null;){if(x=Kn(T),x===null)return;if($=x.tag,$===5||$===6){c=g=x;continue e}T=T.parentNode}}c=c.return}dd(function(){var oe=g,ve=sl(a),_e=[];e:{var me=rf.get(i);if(me!==void 0){var Ee=yl,Pe=i;switch(i){case"keypress":if(bo(a)===0)break e;case"keydown":case"keyup":Ee=Uy;break;case"focusin":Pe="focus",Ee=bl;break;case"focusout":Pe="blur",Ee=bl;break;case"beforeblur":case"afterblur":Ee=bl;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ee=jd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ee=My;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ee=Vy;break;case Zd:case ef:case tf:Ee=Ay;break;case nf:Ee=Xy;break;case"scroll":Ee=Dy;break;case"wheel":Ee=Qy;break;case"copy":case"cut":case"paste":Ee=Iy;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ee=Ad}var Le=(r&4)!==0,St=!Le&&i==="scroll",Z=Le?me!==null?me+"Capture":null:me;Le=[];for(var V=oe,ne;V!==null;){ne=V;var Se=ne.stateNode;if(ne.tag===5&&Se!==null&&(ne=Se,Z!==null&&(Se=is(V,Z),Se!=null&&Le.push(ws(V,Se,ne)))),St)break;V=V.return}0<Le.length&&(me=new Ee(me,Pe,null,a,ve),_e.push({event:me,listeners:Le}))}}if((r&7)===0){e:{if(me=i==="mouseover"||i==="pointerover",Ee=i==="mouseout"||i==="pointerout",me&&a!==hi&&(Pe=a.relatedTarget||a.fromElement)&&(Kn(Pe)||Pe[tn]))break e;if((Ee||me)&&(me=ve.window===ve?ve:(me=ve.ownerDocument)?me.defaultView||me.parentWindow:window,Ee?(Pe=a.relatedTarget||a.toElement,Ee=oe,Pe=Pe?Kn(Pe):null,Pe!==null&&(St=Un(Pe),Pe!==St||Pe.tag!==5&&Pe.tag!==6)&&(Pe=null)):(Ee=null,Pe=oe),Ee!==Pe)){if(Le=jd,Se="onMouseLeave",Z="onMouseEnter",V="mouse",(i==="pointerout"||i==="pointerover")&&(Le=Ad,Se="onPointerLeave",Z="onPointerEnter",V="pointer"),St=Ee==null?me:Er(Ee),ne=Pe==null?me:Er(Pe),me=new Le(Se,V+"leave",Ee,a,ve),me.target=St,me.relatedTarget=ne,Se=null,Kn(ve)===oe&&(Le=new Le(Z,V+"enter",Pe,a,ve),Le.target=ne,Le.relatedTarget=St,Se=Le),St=Se,Ee&&Pe)t:{for(Le=Ee,Z=Pe,V=0,ne=Le;ne;ne=kr(ne))V++;for(ne=0,Se=Z;Se;Se=kr(Se))ne++;for(;0<V-ne;)Le=kr(Le),V--;for(;0<ne-V;)Z=kr(Z),ne--;for(;V--;){if(Le===Z||Z!==null&&Le===Z.alternate)break t;Le=kr(Le),Z=kr(Z)}Le=null}else Le=null;Ee!==null&&cf(_e,me,Ee,Le,!1),Pe!==null&&St!==null&&cf(_e,St,Pe,Le,!0)}}e:{if(me=oe?Er(oe):window,Ee=me.nodeName&&me.nodeName.toLowerCase(),Ee==="select"||Ee==="input"&&me.type==="file")var Te=rS;else if(Hd(me))if(Wd)Te=lS;else{Te=oS;var ze=sS}else(Ee=me.nodeName)&&Ee.toLowerCase()==="input"&&(me.type==="checkbox"||me.type==="radio")&&(Te=aS);if(Te&&(Te=Te(i,oe))){$d(_e,Te,a,ve);break e}ze&&ze(i,me,oe),i==="focusout"&&(ze=me._wrapperState)&&ze.controlled&&me.type==="number"&&K(me,"number",me.value)}switch(ze=oe?Er(oe):window,i){case"focusin":(Hd(ze)||ze.contentEditable==="true")&&(br=ze,Rl=oe,_s=null);break;case"focusout":_s=Rl=br=null;break;case"mousedown":Pl=!0;break;case"contextmenu":case"mouseup":case"dragend":Pl=!1,Qd(_e,a,ve);break;case"selectionchange":if(hS)break;case"keydown":case"keyup":Qd(_e,a,ve)}var Fe;if(kl)e:{switch(i){case"compositionstart":var He="onCompositionStart";break e;case"compositionend":He="onCompositionEnd";break e;case"compositionupdate":He="onCompositionUpdate";break e}He=void 0}else wr?zd(i,a)&&(He="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(He="onCompositionStart");He&&(Bd&&a.locale!=="ko"&&(wr||He!=="onCompositionStart"?He==="onCompositionEnd"&&wr&&(Fe=Ld()):(wn=ve,_l="value"in wn?wn.value:wn.textContent,wr=!0)),ze=Po(oe,He),0<ze.length&&(He=new Td(He,i,null,a,ve),_e.push({event:He,listeners:ze}),Fe?He.data=Fe:(Fe=Fd(a),Fe!==null&&(He.data=Fe)))),(Fe=Zy?eS(i,a):tS(i,a))&&(oe=Po(oe,"onBeforeInput"),0<oe.length&&(ve=new Td("onBeforeInput","beforeinput",null,a,ve),_e.push({event:ve,listeners:oe}),ve.data=Fe))}af(_e,r)})}function ws(i,r,a){return{instance:i,listener:r,currentTarget:a}}function Po(i,r){for(var a=r+"Capture",c=[];i!==null;){var f=i,g=f.stateNode;f.tag===5&&g!==null&&(f=g,g=is(i,a),g!=null&&c.unshift(ws(i,g,f)),g=is(i,r),g!=null&&c.push(ws(i,g,f))),i=i.return}return c}function kr(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5);return i||null}function cf(i,r,a,c,f){for(var g=r._reactName,x=[];a!==null&&a!==c;){var T=a,$=T.alternate,oe=T.stateNode;if($!==null&&$===c)break;T.tag===5&&oe!==null&&(T=oe,f?($=is(a,g),$!=null&&x.unshift(ws(a,$,T))):f||($=is(a,g),$!=null&&x.push(ws(a,$,T)))),a=a.return}x.length!==0&&i.push({event:r,listeners:x})}var mS=/\r\n?/g,gS=/\u0000|\uFFFD/g;function uf(i){return(typeof i=="string"?i:""+i).replace(mS,`
|
|
38
|
+
`).replace(gS,"")}function Do(i,r,a){if(r=uf(r),uf(i)!==r&&a)throw Error(n(425))}function Lo(){}var Al=null,Bl=null;function Il(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 Ol=typeof setTimeout=="function"?setTimeout:void 0,vS=typeof clearTimeout=="function"?clearTimeout:void 0,hf=typeof Promise=="function"?Promise:void 0,_S=typeof queueMicrotask=="function"?queueMicrotask:typeof hf<"u"?function(i){return hf.resolve(null).then(i).catch(yS)}:Ol;function yS(i){setTimeout(function(){throw i})}function zl(i,r){var a=r,c=0;do{var f=a.nextSibling;if(i.removeChild(a),f&&f.nodeType===8)if(a=f.data,a==="/$"){if(c===0){i.removeChild(f),hs(r);return}c--}else a!=="$"&&a!=="$?"&&a!=="$!"||c++;a=f}while(a);hs(r)}function Cn(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 df(i){i=i.previousSibling;for(var r=0;i;){if(i.nodeType===8){var a=i.data;if(a==="$"||a==="$!"||a==="$?"){if(r===0)return i;r--}else a==="/$"&&r++}i=i.previousSibling}return null}var xr=Math.random().toString(36).slice(2),Hi="__reactFiber$"+xr,bs="__reactProps$"+xr,tn="__reactContainer$"+xr,Fl="__reactEvents$"+xr,SS="__reactListeners$"+xr,wS="__reactHandles$"+xr;function Kn(i){var r=i[Hi];if(r)return r;for(var a=i.parentNode;a;){if(r=a[tn]||a[Hi]){if(a=r.alternate,r.child!==null||a!==null&&a.child!==null)for(i=df(i);i!==null;){if(a=i[Hi])return a;i=df(i)}return r}i=a,a=i.parentNode}return null}function Cs(i){return i=i[Hi]||i[tn],!i||i.tag!==5&&i.tag!==6&&i.tag!==13&&i.tag!==3?null:i}function Er(i){if(i.tag===5||i.tag===6)return i.stateNode;throw Error(n(33))}function Mo(i){return i[bs]||null}var Hl=[],Nr=-1;function kn(i){return{current:i}}function at(i){0>Nr||(i.current=Hl[Nr],Hl[Nr]=null,Nr--)}function st(i,r){Nr++,Hl[Nr]=i.current,i.current=r}var xn={},qt=kn(xn),ii=kn(!1),qn=xn;function Rr(i,r){var a=i.type.contextTypes;if(!a)return xn;var c=i.stateNode;if(c&&c.__reactInternalMemoizedUnmaskedChildContext===r)return c.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in a)f[g]=r[g];return c&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=r,i.__reactInternalMemoizedMaskedChildContext=f),f}function ni(i){return i=i.childContextTypes,i!=null}function jo(){at(ii),at(qt)}function ff(i,r,a){if(qt.current!==xn)throw Error(n(168));st(qt,r),st(ii,a)}function pf(i,r,a){var c=i.stateNode;if(r=r.childContextTypes,typeof c.getChildContext!="function")return a;c=c.getChildContext();for(var f in c)if(!(f in r))throw Error(n(108,pe(i)||"Unknown",f));return q({},a,c)}function To(i){return i=(i=i.stateNode)&&i.__reactInternalMemoizedMergedChildContext||xn,qn=qt.current,st(qt,i),st(ii,ii.current),!0}function mf(i,r,a){var c=i.stateNode;if(!c)throw Error(n(169));a?(i=pf(i,r,qn),c.__reactInternalMemoizedMergedChildContext=i,at(ii),at(qt),st(qt,i)):at(ii),st(ii,a)}var nn=null,Ao=!1,$l=!1;function gf(i){nn===null?nn=[i]:nn.push(i)}function bS(i){Ao=!0,gf(i)}function En(){if(!$l&&nn!==null){$l=!0;var i=0,r=it;try{var a=nn;for(it=1;i<a.length;i++){var c=a[i];do c=c(!0);while(c!==null)}nn=null,Ao=!1}catch(f){throw nn!==null&&(nn=nn.slice(i+1)),vd(ul,En),f}finally{it=r,$l=!1}}return null}var Pr=[],Dr=0,Bo=null,Io=0,wi=[],bi=0,Vn=null,rn=1,sn="";function Yn(i,r){Pr[Dr++]=Io,Pr[Dr++]=Bo,Bo=i,Io=r}function vf(i,r,a){wi[bi++]=rn,wi[bi++]=sn,wi[bi++]=Vn,Vn=i;var c=rn;i=sn;var f=32-Mi(c)-1;c&=~(1<<f),a+=1;var g=32-Mi(r)+f;if(30<g){var x=f-f%5;g=(c&(1<<x)-1).toString(32),c>>=x,f-=x,rn=1<<32-Mi(r)+f|a<<f|c,sn=g+i}else rn=1<<g|a<<f|c,sn=i}function Wl(i){i.return!==null&&(Yn(i,1),vf(i,1,0))}function Ul(i){for(;i===Bo;)Bo=Pr[--Dr],Pr[Dr]=null,Io=Pr[--Dr],Pr[Dr]=null;for(;i===Vn;)Vn=wi[--bi],wi[bi]=null,sn=wi[--bi],wi[bi]=null,rn=wi[--bi],wi[bi]=null}var fi=null,pi=null,ct=!1,Ti=null;function _f(i,r){var a=Ei(5,null,null,0);a.elementType="DELETED",a.stateNode=r,a.return=i,r=i.deletions,r===null?(i.deletions=[a],i.flags|=16):r.push(a)}function yf(i,r){switch(i.tag){case 5:var a=i.type;return r=r.nodeType!==1||a.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(i.stateNode=r,fi=i,pi=Cn(r.firstChild),!0):!1;case 6:return r=i.pendingProps===""||r.nodeType!==3?null:r,r!==null?(i.stateNode=r,fi=i,pi=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(a=Vn!==null?{id:rn,overflow:sn}:null,i.memoizedState={dehydrated:r,treeContext:a,retryLane:1073741824},a=Ei(18,null,null,0),a.stateNode=r,a.return=i,i.child=a,fi=i,pi=null,!0):!1;default:return!1}}function Kl(i){return(i.mode&1)!==0&&(i.flags&128)===0}function ql(i){if(ct){var r=pi;if(r){var a=r;if(!yf(i,r)){if(Kl(i))throw Error(n(418));r=Cn(a.nextSibling);var c=fi;r&&yf(i,r)?_f(c,a):(i.flags=i.flags&-4097|2,ct=!1,fi=i)}}else{if(Kl(i))throw Error(n(418));i.flags=i.flags&-4097|2,ct=!1,fi=i}}}function Sf(i){for(i=i.return;i!==null&&i.tag!==5&&i.tag!==3&&i.tag!==13;)i=i.return;fi=i}function Oo(i){if(i!==fi)return!1;if(!ct)return Sf(i),ct=!0,!1;var r;if((r=i.tag!==3)&&!(r=i.tag!==5)&&(r=i.type,r=r!=="head"&&r!=="body"&&!Il(i.type,i.memoizedProps)),r&&(r=pi)){if(Kl(i))throw wf(),Error(n(418));for(;r;)_f(i,r),r=Cn(r.nextSibling)}if(Sf(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 a=i.data;if(a==="/$"){if(r===0){pi=Cn(i.nextSibling);break e}r--}else a!=="$"&&a!=="$!"&&a!=="$?"||r++}i=i.nextSibling}pi=null}}else pi=fi?Cn(i.stateNode.nextSibling):null;return!0}function wf(){for(var i=pi;i;)i=Cn(i.nextSibling)}function Lr(){pi=fi=null,ct=!1}function Vl(i){Ti===null?Ti=[i]:Ti.push(i)}var CS=B.ReactCurrentBatchConfig;function ks(i,r,a){if(i=a.ref,i!==null&&typeof i!="function"&&typeof i!="object"){if(a._owner){if(a=a._owner,a){if(a.tag!==1)throw Error(n(309));var c=a.stateNode}if(!c)throw Error(n(147,i));var f=c,g=""+i;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===g?r.ref:(r=function(x){var T=f.refs;x===null?delete T[g]:T[g]=x},r._stringRef=g,r)}if(typeof i!="string")throw Error(n(284));if(!a._owner)throw Error(n(290,i))}return i}function zo(i,r){throw i=Object.prototype.toString.call(r),Error(n(31,i==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":i))}function bf(i){var r=i._init;return r(i._payload)}function Cf(i){function r(Z,V){if(i){var ne=Z.deletions;ne===null?(Z.deletions=[V],Z.flags|=16):ne.push(V)}}function a(Z,V){if(!i)return null;for(;V!==null;)r(Z,V),V=V.sibling;return null}function c(Z,V){for(Z=new Map;V!==null;)V.key!==null?Z.set(V.key,V):Z.set(V.index,V),V=V.sibling;return Z}function f(Z,V){return Z=Tn(Z,V),Z.index=0,Z.sibling=null,Z}function g(Z,V,ne){return Z.index=ne,i?(ne=Z.alternate,ne!==null?(ne=ne.index,ne<V?(Z.flags|=2,V):ne):(Z.flags|=2,V)):(Z.flags|=1048576,V)}function x(Z){return i&&Z.alternate===null&&(Z.flags|=2),Z}function T(Z,V,ne,Se){return V===null||V.tag!==6?(V=Oc(ne,Z.mode,Se),V.return=Z,V):(V=f(V,ne),V.return=Z,V)}function $(Z,V,ne,Se){var Te=ne.type;return Te===H?ve(Z,V,ne.props.children,Se,ne.key):V!==null&&(V.elementType===Te||typeof Te=="object"&&Te!==null&&Te.$$typeof===R&&bf(Te)===V.type)?(Se=f(V,ne.props),Se.ref=ks(Z,V,ne),Se.return=Z,Se):(Se=ca(ne.type,ne.key,ne.props,null,Z.mode,Se),Se.ref=ks(Z,V,ne),Se.return=Z,Se)}function oe(Z,V,ne,Se){return V===null||V.tag!==4||V.stateNode.containerInfo!==ne.containerInfo||V.stateNode.implementation!==ne.implementation?(V=zc(ne,Z.mode,Se),V.return=Z,V):(V=f(V,ne.children||[]),V.return=Z,V)}function ve(Z,V,ne,Se,Te){return V===null||V.tag!==7?(V=ir(ne,Z.mode,Se,Te),V.return=Z,V):(V=f(V,ne),V.return=Z,V)}function _e(Z,V,ne){if(typeof V=="string"&&V!==""||typeof V=="number")return V=Oc(""+V,Z.mode,ne),V.return=Z,V;if(typeof V=="object"&&V!==null){switch(V.$$typeof){case ee:return ne=ca(V.type,V.key,V.props,null,Z.mode,ne),ne.ref=ks(Z,null,V),ne.return=Z,ne;case O:return V=zc(V,Z.mode,ne),V.return=Z,V;case R:var Se=V._init;return _e(Z,Se(V._payload),ne)}if(fe(V)||re(V))return V=ir(V,Z.mode,ne,null),V.return=Z,V;zo(Z,V)}return null}function me(Z,V,ne,Se){var Te=V!==null?V.key:null;if(typeof ne=="string"&&ne!==""||typeof ne=="number")return Te!==null?null:T(Z,V,""+ne,Se);if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case ee:return ne.key===Te?$(Z,V,ne,Se):null;case O:return ne.key===Te?oe(Z,V,ne,Se):null;case R:return Te=ne._init,me(Z,V,Te(ne._payload),Se)}if(fe(ne)||re(ne))return Te!==null?null:ve(Z,V,ne,Se,null);zo(Z,ne)}return null}function Ee(Z,V,ne,Se,Te){if(typeof Se=="string"&&Se!==""||typeof Se=="number")return Z=Z.get(ne)||null,T(V,Z,""+Se,Te);if(typeof Se=="object"&&Se!==null){switch(Se.$$typeof){case ee:return Z=Z.get(Se.key===null?ne:Se.key)||null,$(V,Z,Se,Te);case O:return Z=Z.get(Se.key===null?ne:Se.key)||null,oe(V,Z,Se,Te);case R:var ze=Se._init;return Ee(Z,V,ne,ze(Se._payload),Te)}if(fe(Se)||re(Se))return Z=Z.get(ne)||null,ve(V,Z,Se,Te,null);zo(V,Se)}return null}function Pe(Z,V,ne,Se){for(var Te=null,ze=null,Fe=V,He=V=0,Tt=null;Fe!==null&&He<ne.length;He++){Fe.index>He?(Tt=Fe,Fe=null):Tt=Fe.sibling;var Ze=me(Z,Fe,ne[He],Se);if(Ze===null){Fe===null&&(Fe=Tt);break}i&&Fe&&Ze.alternate===null&&r(Z,Fe),V=g(Ze,V,He),ze===null?Te=Ze:ze.sibling=Ze,ze=Ze,Fe=Tt}if(He===ne.length)return a(Z,Fe),ct&&Yn(Z,He),Te;if(Fe===null){for(;He<ne.length;He++)Fe=_e(Z,ne[He],Se),Fe!==null&&(V=g(Fe,V,He),ze===null?Te=Fe:ze.sibling=Fe,ze=Fe);return ct&&Yn(Z,He),Te}for(Fe=c(Z,Fe);He<ne.length;He++)Tt=Ee(Fe,Z,He,ne[He],Se),Tt!==null&&(i&&Tt.alternate!==null&&Fe.delete(Tt.key===null?He:Tt.key),V=g(Tt,V,He),ze===null?Te=Tt:ze.sibling=Tt,ze=Tt);return i&&Fe.forEach(function(An){return r(Z,An)}),ct&&Yn(Z,He),Te}function Le(Z,V,ne,Se){var Te=re(ne);if(typeof Te!="function")throw Error(n(150));if(ne=Te.call(ne),ne==null)throw Error(n(151));for(var ze=Te=null,Fe=V,He=V=0,Tt=null,Ze=ne.next();Fe!==null&&!Ze.done;He++,Ze=ne.next()){Fe.index>He?(Tt=Fe,Fe=null):Tt=Fe.sibling;var An=me(Z,Fe,Ze.value,Se);if(An===null){Fe===null&&(Fe=Tt);break}i&&Fe&&An.alternate===null&&r(Z,Fe),V=g(An,V,He),ze===null?Te=An:ze.sibling=An,ze=An,Fe=Tt}if(Ze.done)return a(Z,Fe),ct&&Yn(Z,He),Te;if(Fe===null){for(;!Ze.done;He++,Ze=ne.next())Ze=_e(Z,Ze.value,Se),Ze!==null&&(V=g(Ze,V,He),ze===null?Te=Ze:ze.sibling=Ze,ze=Ze);return ct&&Yn(Z,He),Te}for(Fe=c(Z,Fe);!Ze.done;He++,Ze=ne.next())Ze=Ee(Fe,Z,He,Ze.value,Se),Ze!==null&&(i&&Ze.alternate!==null&&Fe.delete(Ze.key===null?He:Ze.key),V=g(Ze,V,He),ze===null?Te=Ze:ze.sibling=Ze,ze=Ze);return i&&Fe.forEach(function(iw){return r(Z,iw)}),ct&&Yn(Z,He),Te}function St(Z,V,ne,Se){if(typeof ne=="object"&&ne!==null&&ne.type===H&&ne.key===null&&(ne=ne.props.children),typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case ee:e:{for(var Te=ne.key,ze=V;ze!==null;){if(ze.key===Te){if(Te=ne.type,Te===H){if(ze.tag===7){a(Z,ze.sibling),V=f(ze,ne.props.children),V.return=Z,Z=V;break e}}else if(ze.elementType===Te||typeof Te=="object"&&Te!==null&&Te.$$typeof===R&&bf(Te)===ze.type){a(Z,ze.sibling),V=f(ze,ne.props),V.ref=ks(Z,ze,ne),V.return=Z,Z=V;break e}a(Z,ze);break}else r(Z,ze);ze=ze.sibling}ne.type===H?(V=ir(ne.props.children,Z.mode,Se,ne.key),V.return=Z,Z=V):(Se=ca(ne.type,ne.key,ne.props,null,Z.mode,Se),Se.ref=ks(Z,V,ne),Se.return=Z,Z=Se)}return x(Z);case O:e:{for(ze=ne.key;V!==null;){if(V.key===ze)if(V.tag===4&&V.stateNode.containerInfo===ne.containerInfo&&V.stateNode.implementation===ne.implementation){a(Z,V.sibling),V=f(V,ne.children||[]),V.return=Z,Z=V;break e}else{a(Z,V);break}else r(Z,V);V=V.sibling}V=zc(ne,Z.mode,Se),V.return=Z,Z=V}return x(Z);case R:return ze=ne._init,St(Z,V,ze(ne._payload),Se)}if(fe(ne))return Pe(Z,V,ne,Se);if(re(ne))return Le(Z,V,ne,Se);zo(Z,ne)}return typeof ne=="string"&&ne!==""||typeof ne=="number"?(ne=""+ne,V!==null&&V.tag===6?(a(Z,V.sibling),V=f(V,ne),V.return=Z,Z=V):(a(Z,V),V=Oc(ne,Z.mode,Se),V.return=Z,Z=V),x(Z)):a(Z,V)}return St}var Mr=Cf(!0),kf=Cf(!1),Fo=kn(null),Ho=null,jr=null,Yl=null;function Xl(){Yl=jr=Ho=null}function Gl(i){var r=Fo.current;at(Fo),i._currentValue=r}function Ql(i,r,a){for(;i!==null;){var c=i.alternate;if((i.childLanes&r)!==r?(i.childLanes|=r,c!==null&&(c.childLanes|=r)):c!==null&&(c.childLanes&r)!==r&&(c.childLanes|=r),i===a)break;i=i.return}}function Tr(i,r){Ho=i,Yl=jr=null,i=i.dependencies,i!==null&&i.firstContext!==null&&((i.lanes&r)!==0&&(ri=!0),i.firstContext=null)}function Ci(i){var r=i._currentValue;if(Yl!==i)if(i={context:i,memoizedValue:r,next:null},jr===null){if(Ho===null)throw Error(n(308));jr=i,Ho.dependencies={lanes:0,firstContext:i}}else jr=jr.next=i;return r}var Xn=null;function Jl(i){Xn===null?Xn=[i]:Xn.push(i)}function xf(i,r,a,c){var f=r.interleaved;return f===null?(a.next=a,Jl(r)):(a.next=f.next,f.next=a),r.interleaved=a,on(i,c)}function on(i,r){i.lanes|=r;var a=i.alternate;for(a!==null&&(a.lanes|=r),a=i,i=i.return;i!==null;)i.childLanes|=r,a=i.alternate,a!==null&&(a.childLanes|=r),a=i,i=i.return;return a.tag===3?a.stateNode:null}var Nn=!1;function Zl(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ef(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 an(i,r){return{eventTime:i,lane:r,tag:0,payload:null,callback:null,next:null}}function Rn(i,r,a){var c=i.updateQueue;if(c===null)return null;if(c=c.shared,(Je&2)!==0){var f=c.pending;return f===null?r.next=r:(r.next=f.next,f.next=r),c.pending=r,on(i,a)}return f=c.interleaved,f===null?(r.next=r,Jl(c)):(r.next=f.next,f.next=r),c.interleaved=r,on(i,a)}function $o(i,r,a){if(r=r.updateQueue,r!==null&&(r=r.shared,(a&4194240)!==0)){var c=r.lanes;c&=i.pendingLanes,a|=c,r.lanes=a,fl(i,a)}}function Nf(i,r){var a=i.updateQueue,c=i.alternate;if(c!==null&&(c=c.updateQueue,a===c)){var f=null,g=null;if(a=a.firstBaseUpdate,a!==null){do{var x={eventTime:a.eventTime,lane:a.lane,tag:a.tag,payload:a.payload,callback:a.callback,next:null};g===null?f=g=x:g=g.next=x,a=a.next}while(a!==null);g===null?f=g=r:g=g.next=r}else f=g=r;a={baseState:c.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:c.shared,effects:c.effects},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=r:i.next=r,a.lastBaseUpdate=r}function Wo(i,r,a,c){var f=i.updateQueue;Nn=!1;var g=f.firstBaseUpdate,x=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var $=T,oe=$.next;$.next=null,x===null?g=oe:x.next=oe,x=$;var ve=i.alternate;ve!==null&&(ve=ve.updateQueue,T=ve.lastBaseUpdate,T!==x&&(T===null?ve.firstBaseUpdate=oe:T.next=oe,ve.lastBaseUpdate=$))}if(g!==null){var _e=f.baseState;x=0,ve=oe=$=null,T=g;do{var me=T.lane,Ee=T.eventTime;if((c&me)===me){ve!==null&&(ve=ve.next={eventTime:Ee,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var Pe=i,Le=T;switch(me=r,Ee=a,Le.tag){case 1:if(Pe=Le.payload,typeof Pe=="function"){_e=Pe.call(Ee,_e,me);break e}_e=Pe;break e;case 3:Pe.flags=Pe.flags&-65537|128;case 0:if(Pe=Le.payload,me=typeof Pe=="function"?Pe.call(Ee,_e,me):Pe,me==null)break e;_e=q({},_e,me);break e;case 2:Nn=!0}}T.callback!==null&&T.lane!==0&&(i.flags|=64,me=f.effects,me===null?f.effects=[T]:me.push(T))}else Ee={eventTime:Ee,lane:me,tag:T.tag,payload:T.payload,callback:T.callback,next:null},ve===null?(oe=ve=Ee,$=_e):ve=ve.next=Ee,x|=me;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;me=T,T=me.next,me.next=null,f.lastBaseUpdate=me,f.shared.pending=null}}while(!0);if(ve===null&&($=_e),f.baseState=$,f.firstBaseUpdate=oe,f.lastBaseUpdate=ve,r=f.shared.interleaved,r!==null){f=r;do x|=f.lane,f=f.next;while(f!==r)}else g===null&&(f.shared.lanes=0);Jn|=x,i.lanes=x,i.memoizedState=_e}}function Rf(i,r,a){if(i=r.effects,r.effects=null,i!==null)for(r=0;r<i.length;r++){var c=i[r],f=c.callback;if(f!==null){if(c.callback=null,c=a,typeof f!="function")throw Error(n(191,f));f.call(c)}}}var xs={},$i=kn(xs),Es=kn(xs),Ns=kn(xs);function Gn(i){if(i===xs)throw Error(n(174));return i}function ec(i,r){switch(st(Ns,r),st(Es,i),st($i,xs),i=r.nodeType,i){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:We(null,"");break;default:i=i===8?r.parentNode:r,r=i.namespaceURI||null,i=i.tagName,r=We(r,i)}at($i),st($i,r)}function Ar(){at($i),at(Es),at(Ns)}function Pf(i){Gn(Ns.current);var r=Gn($i.current),a=We(r,i.type);r!==a&&(st(Es,i),st($i,a))}function tc(i){Es.current===i&&(at($i),at(Es))}var ht=kn(0);function Uo(i){for(var r=i;r!==null;){if(r.tag===13){var a=r.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||a.data==="$?"||a.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 ic=[];function nc(){for(var i=0;i<ic.length;i++)ic[i]._workInProgressVersionPrimary=null;ic.length=0}var Ko=B.ReactCurrentDispatcher,rc=B.ReactCurrentBatchConfig,Qn=0,dt=null,Et=null,Mt=null,qo=!1,Rs=!1,Ps=0,kS=0;function Vt(){throw Error(n(321))}function sc(i,r){if(r===null)return!1;for(var a=0;a<r.length&&a<i.length;a++)if(!ji(i[a],r[a]))return!1;return!0}function oc(i,r,a,c,f,g){if(Qn=g,dt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,Ko.current=i===null||i.memoizedState===null?RS:PS,i=a(c,f),Rs){g=0;do{if(Rs=!1,Ps=0,25<=g)throw Error(n(301));g+=1,Mt=Et=null,r.updateQueue=null,Ko.current=DS,i=a(c,f)}while(Rs)}if(Ko.current=Xo,r=Et!==null&&Et.next!==null,Qn=0,Mt=Et=dt=null,qo=!1,r)throw Error(n(300));return i}function ac(){var i=Ps!==0;return Ps=0,i}function Wi(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Mt===null?dt.memoizedState=Mt=i:Mt=Mt.next=i,Mt}function ki(){if(Et===null){var i=dt.alternate;i=i!==null?i.memoizedState:null}else i=Et.next;var r=Mt===null?dt.memoizedState:Mt.next;if(r!==null)Mt=r,Et=i;else{if(i===null)throw Error(n(310));Et=i,i={memoizedState:Et.memoizedState,baseState:Et.baseState,baseQueue:Et.baseQueue,queue:Et.queue,next:null},Mt===null?dt.memoizedState=Mt=i:Mt=Mt.next=i}return Mt}function Ds(i,r){return typeof r=="function"?r(i):r}function lc(i){var r=ki(),a=r.queue;if(a===null)throw Error(n(311));a.lastRenderedReducer=i;var c=Et,f=c.baseQueue,g=a.pending;if(g!==null){if(f!==null){var x=f.next;f.next=g.next,g.next=x}c.baseQueue=f=g,a.pending=null}if(f!==null){g=f.next,c=c.baseState;var T=x=null,$=null,oe=g;do{var ve=oe.lane;if((Qn&ve)===ve)$!==null&&($=$.next={lane:0,action:oe.action,hasEagerState:oe.hasEagerState,eagerState:oe.eagerState,next:null}),c=oe.hasEagerState?oe.eagerState:i(c,oe.action);else{var _e={lane:ve,action:oe.action,hasEagerState:oe.hasEagerState,eagerState:oe.eagerState,next:null};$===null?(T=$=_e,x=c):$=$.next=_e,dt.lanes|=ve,Jn|=ve}oe=oe.next}while(oe!==null&&oe!==g);$===null?x=c:$.next=T,ji(c,r.memoizedState)||(ri=!0),r.memoizedState=c,r.baseState=x,r.baseQueue=$,a.lastRenderedState=c}if(i=a.interleaved,i!==null){f=i;do g=f.lane,dt.lanes|=g,Jn|=g,f=f.next;while(f!==i)}else f===null&&(a.lanes=0);return[r.memoizedState,a.dispatch]}function cc(i){var r=ki(),a=r.queue;if(a===null)throw Error(n(311));a.lastRenderedReducer=i;var c=a.dispatch,f=a.pending,g=r.memoizedState;if(f!==null){a.pending=null;var x=f=f.next;do g=i(g,x.action),x=x.next;while(x!==f);ji(g,r.memoizedState)||(ri=!0),r.memoizedState=g,r.baseQueue===null&&(r.baseState=g),a.lastRenderedState=g}return[g,c]}function Df(){}function Lf(i,r){var a=dt,c=ki(),f=r(),g=!ji(c.memoizedState,f);if(g&&(c.memoizedState=f,ri=!0),c=c.queue,uc(Tf.bind(null,a,c,i),[i]),c.getSnapshot!==r||g||Mt!==null&&Mt.memoizedState.tag&1){if(a.flags|=2048,Ls(9,jf.bind(null,a,c,f,r),void 0,null),jt===null)throw Error(n(349));(Qn&30)!==0||Mf(a,r,f)}return f}function Mf(i,r,a){i.flags|=16384,i={getSnapshot:r,value:a},r=dt.updateQueue,r===null?(r={lastEffect:null,stores:null},dt.updateQueue=r,r.stores=[i]):(a=r.stores,a===null?r.stores=[i]:a.push(i))}function jf(i,r,a,c){r.value=a,r.getSnapshot=c,Af(r)&&Bf(i)}function Tf(i,r,a){return a(function(){Af(r)&&Bf(i)})}function Af(i){var r=i.getSnapshot;i=i.value;try{var a=r();return!ji(i,a)}catch{return!0}}function Bf(i){var r=on(i,1);r!==null&&Oi(r,i,1,-1)}function If(i){var r=Wi();return typeof i=="function"&&(i=i()),r.memoizedState=r.baseState=i,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ds,lastRenderedState:i},r.queue=i,i=i.dispatch=NS.bind(null,dt,i),[r.memoizedState,i]}function Ls(i,r,a,c){return i={tag:i,create:r,destroy:a,deps:c,next:null},r=dt.updateQueue,r===null?(r={lastEffect:null,stores:null},dt.updateQueue=r,r.lastEffect=i.next=i):(a=r.lastEffect,a===null?r.lastEffect=i.next=i:(c=a.next,a.next=i,i.next=c,r.lastEffect=i)),i}function Of(){return ki().memoizedState}function Vo(i,r,a,c){var f=Wi();dt.flags|=i,f.memoizedState=Ls(1|r,a,void 0,c===void 0?null:c)}function Yo(i,r,a,c){var f=ki();c=c===void 0?null:c;var g=void 0;if(Et!==null){var x=Et.memoizedState;if(g=x.destroy,c!==null&&sc(c,x.deps)){f.memoizedState=Ls(r,a,g,c);return}}dt.flags|=i,f.memoizedState=Ls(1|r,a,g,c)}function zf(i,r){return Vo(8390656,8,i,r)}function uc(i,r){return Yo(2048,8,i,r)}function Ff(i,r){return Yo(4,2,i,r)}function Hf(i,r){return Yo(4,4,i,r)}function $f(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 Wf(i,r,a){return a=a!=null?a.concat([i]):null,Yo(4,4,$f.bind(null,r,i),a)}function hc(){}function Uf(i,r){var a=ki();r=r===void 0?null:r;var c=a.memoizedState;return c!==null&&r!==null&&sc(r,c[1])?c[0]:(a.memoizedState=[i,r],i)}function Kf(i,r){var a=ki();r=r===void 0?null:r;var c=a.memoizedState;return c!==null&&r!==null&&sc(r,c[1])?c[0]:(i=i(),a.memoizedState=[i,r],i)}function qf(i,r,a){return(Qn&21)===0?(i.baseState&&(i.baseState=!1,ri=!0),i.memoizedState=a):(ji(a,r)||(a=wd(),dt.lanes|=a,Jn|=a,i.baseState=!0),r)}function xS(i,r){var a=it;it=a!==0&&4>a?a:4,i(!0);var c=rc.transition;rc.transition={};try{i(!1),r()}finally{it=a,rc.transition=c}}function Vf(){return ki().memoizedState}function ES(i,r,a){var c=Mn(i);if(a={lane:c,action:a,hasEagerState:!1,eagerState:null,next:null},Yf(i))Xf(r,a);else if(a=xf(i,r,a,c),a!==null){var f=Jt();Oi(a,i,c,f),Gf(a,r,c)}}function NS(i,r,a){var c=Mn(i),f={lane:c,action:a,hasEagerState:!1,eagerState:null,next:null};if(Yf(i))Xf(r,f);else{var g=i.alternate;if(i.lanes===0&&(g===null||g.lanes===0)&&(g=r.lastRenderedReducer,g!==null))try{var x=r.lastRenderedState,T=g(x,a);if(f.hasEagerState=!0,f.eagerState=T,ji(T,x)){var $=r.interleaved;$===null?(f.next=f,Jl(r)):(f.next=$.next,$.next=f),r.interleaved=f;return}}catch{}finally{}a=xf(i,r,f,c),a!==null&&(f=Jt(),Oi(a,i,c,f),Gf(a,r,c))}}function Yf(i){var r=i.alternate;return i===dt||r!==null&&r===dt}function Xf(i,r){Rs=qo=!0;var a=i.pending;a===null?r.next=r:(r.next=a.next,a.next=r),i.pending=r}function Gf(i,r,a){if((a&4194240)!==0){var c=r.lanes;c&=i.pendingLanes,a|=c,r.lanes=a,fl(i,a)}}var Xo={readContext:Ci,useCallback:Vt,useContext:Vt,useEffect:Vt,useImperativeHandle:Vt,useInsertionEffect:Vt,useLayoutEffect:Vt,useMemo:Vt,useReducer:Vt,useRef:Vt,useState:Vt,useDebugValue:Vt,useDeferredValue:Vt,useTransition:Vt,useMutableSource:Vt,useSyncExternalStore:Vt,useId:Vt,unstable_isNewReconciler:!1},RS={readContext:Ci,useCallback:function(i,r){return Wi().memoizedState=[i,r===void 0?null:r],i},useContext:Ci,useEffect:zf,useImperativeHandle:function(i,r,a){return a=a!=null?a.concat([i]):null,Vo(4194308,4,$f.bind(null,r,i),a)},useLayoutEffect:function(i,r){return Vo(4194308,4,i,r)},useInsertionEffect:function(i,r){return Vo(4,2,i,r)},useMemo:function(i,r){var a=Wi();return r=r===void 0?null:r,i=i(),a.memoizedState=[i,r],i},useReducer:function(i,r,a){var c=Wi();return r=a!==void 0?a(r):r,c.memoizedState=c.baseState=r,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:r},c.queue=i,i=i.dispatch=ES.bind(null,dt,i),[c.memoizedState,i]},useRef:function(i){var r=Wi();return i={current:i},r.memoizedState=i},useState:If,useDebugValue:hc,useDeferredValue:function(i){return Wi().memoizedState=i},useTransition:function(){var i=If(!1),r=i[0];return i=xS.bind(null,i[1]),Wi().memoizedState=i,[r,i]},useMutableSource:function(){},useSyncExternalStore:function(i,r,a){var c=dt,f=Wi();if(ct){if(a===void 0)throw Error(n(407));a=a()}else{if(a=r(),jt===null)throw Error(n(349));(Qn&30)!==0||Mf(c,r,a)}f.memoizedState=a;var g={value:a,getSnapshot:r};return f.queue=g,zf(Tf.bind(null,c,g,i),[i]),c.flags|=2048,Ls(9,jf.bind(null,c,g,a,r),void 0,null),a},useId:function(){var i=Wi(),r=jt.identifierPrefix;if(ct){var a=sn,c=rn;a=(c&~(1<<32-Mi(c)-1)).toString(32)+a,r=":"+r+"R"+a,a=Ps++,0<a&&(r+="H"+a.toString(32)),r+=":"}else a=kS++,r=":"+r+"r"+a.toString(32)+":";return i.memoizedState=r},unstable_isNewReconciler:!1},PS={readContext:Ci,useCallback:Uf,useContext:Ci,useEffect:uc,useImperativeHandle:Wf,useInsertionEffect:Ff,useLayoutEffect:Hf,useMemo:Kf,useReducer:lc,useRef:Of,useState:function(){return lc(Ds)},useDebugValue:hc,useDeferredValue:function(i){var r=ki();return qf(r,Et.memoizedState,i)},useTransition:function(){var i=lc(Ds)[0],r=ki().memoizedState;return[i,r]},useMutableSource:Df,useSyncExternalStore:Lf,useId:Vf,unstable_isNewReconciler:!1},DS={readContext:Ci,useCallback:Uf,useContext:Ci,useEffect:uc,useImperativeHandle:Wf,useInsertionEffect:Ff,useLayoutEffect:Hf,useMemo:Kf,useReducer:cc,useRef:Of,useState:function(){return cc(Ds)},useDebugValue:hc,useDeferredValue:function(i){var r=ki();return Et===null?r.memoizedState=i:qf(r,Et.memoizedState,i)},useTransition:function(){var i=cc(Ds)[0],r=ki().memoizedState;return[i,r]},useMutableSource:Df,useSyncExternalStore:Lf,useId:Vf,unstable_isNewReconciler:!1};function Ai(i,r){if(i&&i.defaultProps){r=q({},r),i=i.defaultProps;for(var a in i)r[a]===void 0&&(r[a]=i[a]);return r}return r}function dc(i,r,a,c){r=i.memoizedState,a=a(c,r),a=a==null?r:q({},r,a),i.memoizedState=a,i.lanes===0&&(i.updateQueue.baseState=a)}var Go={isMounted:function(i){return(i=i._reactInternals)?Un(i)===i:!1},enqueueSetState:function(i,r,a){i=i._reactInternals;var c=Jt(),f=Mn(i),g=an(c,f);g.payload=r,a!=null&&(g.callback=a),r=Rn(i,g,f),r!==null&&(Oi(r,i,f,c),$o(r,i,f))},enqueueReplaceState:function(i,r,a){i=i._reactInternals;var c=Jt(),f=Mn(i),g=an(c,f);g.tag=1,g.payload=r,a!=null&&(g.callback=a),r=Rn(i,g,f),r!==null&&(Oi(r,i,f,c),$o(r,i,f))},enqueueForceUpdate:function(i,r){i=i._reactInternals;var a=Jt(),c=Mn(i),f=an(a,c);f.tag=2,r!=null&&(f.callback=r),r=Rn(i,f,c),r!==null&&(Oi(r,i,c,a),$o(r,i,c))}};function Qf(i,r,a,c,f,g,x){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(c,g,x):r.prototype&&r.prototype.isPureReactComponent?!vs(a,c)||!vs(f,g):!0}function Jf(i,r,a){var c=!1,f=xn,g=r.contextType;return typeof g=="object"&&g!==null?g=Ci(g):(f=ni(r)?qn:qt.current,c=r.contextTypes,g=(c=c!=null)?Rr(i,f):xn),r=new r(a,g),i.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=Go,i.stateNode=r,r._reactInternals=i,c&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=f,i.__reactInternalMemoizedMaskedChildContext=g),r}function Zf(i,r,a,c){i=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(a,c),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(a,c),r.state!==i&&Go.enqueueReplaceState(r,r.state,null)}function fc(i,r,a,c){var f=i.stateNode;f.props=a,f.state=i.memoizedState,f.refs={},Zl(i);var g=r.contextType;typeof g=="object"&&g!==null?f.context=Ci(g):(g=ni(r)?qn:qt.current,f.context=Rr(i,g)),f.state=i.memoizedState,g=r.getDerivedStateFromProps,typeof g=="function"&&(dc(i,r,g,a),f.state=i.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof f.getSnapshotBeforeUpdate=="function"||typeof f.UNSAFE_componentWillMount!="function"&&typeof f.componentWillMount!="function"||(r=f.state,typeof f.componentWillMount=="function"&&f.componentWillMount(),typeof f.UNSAFE_componentWillMount=="function"&&f.UNSAFE_componentWillMount(),r!==f.state&&Go.enqueueReplaceState(f,f.state,null),Wo(i,a,f,c),f.state=i.memoizedState),typeof f.componentDidMount=="function"&&(i.flags|=4194308)}function Br(i,r){try{var a="",c=r;do a+=se(c),c=c.return;while(c);var f=a}catch(g){f=`
|
|
39
|
+
Error generating stack: `+g.message+`
|
|
40
|
+
`+g.stack}return{value:i,source:r,stack:f,digest:null}}function pc(i,r,a){return{value:i,source:null,stack:a??null,digest:r??null}}function mc(i,r){try{console.error(r.value)}catch(a){setTimeout(function(){throw a})}}var LS=typeof WeakMap=="function"?WeakMap:Map;function ep(i,r,a){a=an(-1,a),a.tag=3,a.payload={element:null};var c=r.value;return a.callback=function(){na||(na=!0,Dc=c),mc(i,r)},a}function tp(i,r,a){a=an(-1,a),a.tag=3;var c=i.type.getDerivedStateFromError;if(typeof c=="function"){var f=r.value;a.payload=function(){return c(f)},a.callback=function(){mc(i,r)}}var g=i.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(a.callback=function(){mc(i,r),typeof c!="function"&&(Dn===null?Dn=new Set([this]):Dn.add(this));var x=r.stack;this.componentDidCatch(r.value,{componentStack:x!==null?x:""})}),a}function ip(i,r,a){var c=i.pingCache;if(c===null){c=i.pingCache=new LS;var f=new Set;c.set(r,f)}else f=c.get(r),f===void 0&&(f=new Set,c.set(r,f));f.has(a)||(f.add(a),i=KS.bind(null,i,r,a),r.then(i,i))}function np(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 rp(i,r,a,c,f){return(i.mode&1)===0?(i===r?i.flags|=65536:(i.flags|=128,a.flags|=131072,a.flags&=-52805,a.tag===1&&(a.alternate===null?a.tag=17:(r=an(-1,1),r.tag=2,Rn(a,r,1))),a.lanes|=1),i):(i.flags|=65536,i.lanes=f,i)}var MS=B.ReactCurrentOwner,ri=!1;function Qt(i,r,a,c){r.child=i===null?kf(r,null,a,c):Mr(r,i.child,a,c)}function sp(i,r,a,c,f){a=a.render;var g=r.ref;return Tr(r,f),c=oc(i,r,a,c,g,f),a=ac(),i!==null&&!ri?(r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~f,ln(i,r,f)):(ct&&a&&Wl(r),r.flags|=1,Qt(i,r,c,f),r.child)}function op(i,r,a,c,f){if(i===null){var g=a.type;return typeof g=="function"&&!Ic(g)&&g.defaultProps===void 0&&a.compare===null&&a.defaultProps===void 0?(r.tag=15,r.type=g,ap(i,r,g,c,f)):(i=ca(a.type,null,c,r,r.mode,f),i.ref=r.ref,i.return=r,r.child=i)}if(g=i.child,(i.lanes&f)===0){var x=g.memoizedProps;if(a=a.compare,a=a!==null?a:vs,a(x,c)&&i.ref===r.ref)return ln(i,r,f)}return r.flags|=1,i=Tn(g,c),i.ref=r.ref,i.return=r,r.child=i}function ap(i,r,a,c,f){if(i!==null){var g=i.memoizedProps;if(vs(g,c)&&i.ref===r.ref)if(ri=!1,r.pendingProps=c=g,(i.lanes&f)!==0)(i.flags&131072)!==0&&(ri=!0);else return r.lanes=i.lanes,ln(i,r,f)}return gc(i,r,a,c,f)}function lp(i,r,a){var c=r.pendingProps,f=c.children,g=i!==null?i.memoizedState:null;if(c.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},st(Or,mi),mi|=a;else{if((a&1073741824)===0)return i=g!==null?g.baseLanes|a:a,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:i,cachePool:null,transitions:null},r.updateQueue=null,st(Or,mi),mi|=i,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},c=g!==null?g.baseLanes:a,st(Or,mi),mi|=c}else g!==null?(c=g.baseLanes|a,r.memoizedState=null):c=a,st(Or,mi),mi|=c;return Qt(i,r,f,a),r.child}function cp(i,r){var a=r.ref;(i===null&&a!==null||i!==null&&i.ref!==a)&&(r.flags|=512,r.flags|=2097152)}function gc(i,r,a,c,f){var g=ni(a)?qn:qt.current;return g=Rr(r,g),Tr(r,f),a=oc(i,r,a,c,g,f),c=ac(),i!==null&&!ri?(r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~f,ln(i,r,f)):(ct&&c&&Wl(r),r.flags|=1,Qt(i,r,a,f),r.child)}function up(i,r,a,c,f){if(ni(a)){var g=!0;To(r)}else g=!1;if(Tr(r,f),r.stateNode===null)Jo(i,r),Jf(r,a,c),fc(r,a,c,f),c=!0;else if(i===null){var x=r.stateNode,T=r.memoizedProps;x.props=T;var $=x.context,oe=a.contextType;typeof oe=="object"&&oe!==null?oe=Ci(oe):(oe=ni(a)?qn:qt.current,oe=Rr(r,oe));var ve=a.getDerivedStateFromProps,_e=typeof ve=="function"||typeof x.getSnapshotBeforeUpdate=="function";_e||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(T!==c||$!==oe)&&Zf(r,x,c,oe),Nn=!1;var me=r.memoizedState;x.state=me,Wo(r,c,x,f),$=r.memoizedState,T!==c||me!==$||ii.current||Nn?(typeof ve=="function"&&(dc(r,a,ve,c),$=r.memoizedState),(T=Nn||Qf(r,a,T,c,me,$,oe))?(_e||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount()),typeof x.componentDidMount=="function"&&(r.flags|=4194308)):(typeof x.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=c,r.memoizedState=$),x.props=c,x.state=$,x.context=oe,c=T):(typeof x.componentDidMount=="function"&&(r.flags|=4194308),c=!1)}else{x=r.stateNode,Ef(i,r),T=r.memoizedProps,oe=r.type===r.elementType?T:Ai(r.type,T),x.props=oe,_e=r.pendingProps,me=x.context,$=a.contextType,typeof $=="object"&&$!==null?$=Ci($):($=ni(a)?qn:qt.current,$=Rr(r,$));var Ee=a.getDerivedStateFromProps;(ve=typeof Ee=="function"||typeof x.getSnapshotBeforeUpdate=="function")||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(T!==_e||me!==$)&&Zf(r,x,c,$),Nn=!1,me=r.memoizedState,x.state=me,Wo(r,c,x,f);var Pe=r.memoizedState;T!==_e||me!==Pe||ii.current||Nn?(typeof Ee=="function"&&(dc(r,a,Ee,c),Pe=r.memoizedState),(oe=Nn||Qf(r,a,oe,c,me,Pe,$)||!1)?(ve||typeof x.UNSAFE_componentWillUpdate!="function"&&typeof x.componentWillUpdate!="function"||(typeof x.componentWillUpdate=="function"&&x.componentWillUpdate(c,Pe,$),typeof x.UNSAFE_componentWillUpdate=="function"&&x.UNSAFE_componentWillUpdate(c,Pe,$)),typeof x.componentDidUpdate=="function"&&(r.flags|=4),typeof x.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof x.componentDidUpdate!="function"||T===i.memoizedProps&&me===i.memoizedState||(r.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||T===i.memoizedProps&&me===i.memoizedState||(r.flags|=1024),r.memoizedProps=c,r.memoizedState=Pe),x.props=c,x.state=Pe,x.context=$,c=oe):(typeof x.componentDidUpdate!="function"||T===i.memoizedProps&&me===i.memoizedState||(r.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||T===i.memoizedProps&&me===i.memoizedState||(r.flags|=1024),c=!1)}return vc(i,r,a,c,g,f)}function vc(i,r,a,c,f,g){cp(i,r);var x=(r.flags&128)!==0;if(!c&&!x)return f&&mf(r,a,!1),ln(i,r,g);c=r.stateNode,MS.current=r;var T=x&&typeof a.getDerivedStateFromError!="function"?null:c.render();return r.flags|=1,i!==null&&x?(r.child=Mr(r,i.child,null,g),r.child=Mr(r,null,T,g)):Qt(i,r,T,g),r.memoizedState=c.state,f&&mf(r,a,!0),r.child}function hp(i){var r=i.stateNode;r.pendingContext?ff(i,r.pendingContext,r.pendingContext!==r.context):r.context&&ff(i,r.context,!1),ec(i,r.containerInfo)}function dp(i,r,a,c,f){return Lr(),Vl(f),r.flags|=256,Qt(i,r,a,c),r.child}var _c={dehydrated:null,treeContext:null,retryLane:0};function yc(i){return{baseLanes:i,cachePool:null,transitions:null}}function fp(i,r,a){var c=r.pendingProps,f=ht.current,g=!1,x=(r.flags&128)!==0,T;if((T=x)||(T=i!==null&&i.memoizedState===null?!1:(f&2)!==0),T?(g=!0,r.flags&=-129):(i===null||i.memoizedState!==null)&&(f|=1),st(ht,f&1),i===null)return ql(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):(x=c.children,i=c.fallback,g?(c=r.mode,g=r.child,x={mode:"hidden",children:x},(c&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=x):g=ua(x,c,0,null),i=ir(i,c,a,null),g.return=r,i.return=r,g.sibling=i,r.child=g,r.child.memoizedState=yc(a),r.memoizedState=_c,i):Sc(r,x));if(f=i.memoizedState,f!==null&&(T=f.dehydrated,T!==null))return jS(i,r,x,c,T,f,a);if(g){g=c.fallback,x=r.mode,f=i.child,T=f.sibling;var $={mode:"hidden",children:c.children};return(x&1)===0&&r.child!==f?(c=r.child,c.childLanes=0,c.pendingProps=$,r.deletions=null):(c=Tn(f,$),c.subtreeFlags=f.subtreeFlags&14680064),T!==null?g=Tn(T,g):(g=ir(g,x,a,null),g.flags|=2),g.return=r,c.return=r,c.sibling=g,r.child=c,c=g,g=r.child,x=i.child.memoizedState,x=x===null?yc(a):{baseLanes:x.baseLanes|a,cachePool:null,transitions:x.transitions},g.memoizedState=x,g.childLanes=i.childLanes&~a,r.memoizedState=_c,c}return g=i.child,i=g.sibling,c=Tn(g,{mode:"visible",children:c.children}),(r.mode&1)===0&&(c.lanes=a),c.return=r,c.sibling=null,i!==null&&(a=r.deletions,a===null?(r.deletions=[i],r.flags|=16):a.push(i)),r.child=c,r.memoizedState=null,c}function Sc(i,r){return r=ua({mode:"visible",children:r},i.mode,0,null),r.return=i,i.child=r}function Qo(i,r,a,c){return c!==null&&Vl(c),Mr(r,i.child,null,a),i=Sc(r,r.pendingProps.children),i.flags|=2,r.memoizedState=null,i}function jS(i,r,a,c,f,g,x){if(a)return r.flags&256?(r.flags&=-257,c=pc(Error(n(422))),Qo(i,r,x,c)):r.memoizedState!==null?(r.child=i.child,r.flags|=128,null):(g=c.fallback,f=r.mode,c=ua({mode:"visible",children:c.children},f,0,null),g=ir(g,f,x,null),g.flags|=2,c.return=r,g.return=r,c.sibling=g,r.child=c,(r.mode&1)!==0&&Mr(r,i.child,null,x),r.child.memoizedState=yc(x),r.memoizedState=_c,g);if((r.mode&1)===0)return Qo(i,r,x,null);if(f.data==="$!"){if(c=f.nextSibling&&f.nextSibling.dataset,c)var T=c.dgst;return c=T,g=Error(n(419)),c=pc(g,c,void 0),Qo(i,r,x,c)}if(T=(x&i.childLanes)!==0,ri||T){if(c=jt,c!==null){switch(x&-x){case 4:f=2;break;case 16:f=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:f=32;break;case 536870912:f=268435456;break;default:f=0}f=(f&(c.suspendedLanes|x))!==0?0:f,f!==0&&f!==g.retryLane&&(g.retryLane=f,on(i,f),Oi(c,i,f,-1))}return Bc(),c=pc(Error(n(421))),Qo(i,r,x,c)}return f.data==="$?"?(r.flags|=128,r.child=i.child,r=qS.bind(null,i),f._reactRetry=r,null):(i=g.treeContext,pi=Cn(f.nextSibling),fi=r,ct=!0,Ti=null,i!==null&&(wi[bi++]=rn,wi[bi++]=sn,wi[bi++]=Vn,rn=i.id,sn=i.overflow,Vn=r),r=Sc(r,c.children),r.flags|=4096,r)}function pp(i,r,a){i.lanes|=r;var c=i.alternate;c!==null&&(c.lanes|=r),Ql(i.return,r,a)}function wc(i,r,a,c,f){var g=i.memoizedState;g===null?i.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:c,tail:a,tailMode:f}:(g.isBackwards=r,g.rendering=null,g.renderingStartTime=0,g.last=c,g.tail=a,g.tailMode=f)}function mp(i,r,a){var c=r.pendingProps,f=c.revealOrder,g=c.tail;if(Qt(i,r,c.children,a),c=ht.current,(c&2)!==0)c=c&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&&pp(i,a,r);else if(i.tag===19)pp(i,a,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}c&=1}if(st(ht,c),(r.mode&1)===0)r.memoizedState=null;else switch(f){case"forwards":for(a=r.child,f=null;a!==null;)i=a.alternate,i!==null&&Uo(i)===null&&(f=a),a=a.sibling;a=f,a===null?(f=r.child,r.child=null):(f=a.sibling,a.sibling=null),wc(r,!1,f,a,g);break;case"backwards":for(a=null,f=r.child,r.child=null;f!==null;){if(i=f.alternate,i!==null&&Uo(i)===null){r.child=f;break}i=f.sibling,f.sibling=a,a=f,f=i}wc(r,!0,a,null,g);break;case"together":wc(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function Jo(i,r){(r.mode&1)===0&&i!==null&&(i.alternate=null,r.alternate=null,r.flags|=2)}function ln(i,r,a){if(i!==null&&(r.dependencies=i.dependencies),Jn|=r.lanes,(a&r.childLanes)===0)return null;if(i!==null&&r.child!==i.child)throw Error(n(153));if(r.child!==null){for(i=r.child,a=Tn(i,i.pendingProps),r.child=a,a.return=r;i.sibling!==null;)i=i.sibling,a=a.sibling=Tn(i,i.pendingProps),a.return=r;a.sibling=null}return r.child}function TS(i,r,a){switch(r.tag){case 3:hp(r),Lr();break;case 5:Pf(r);break;case 1:ni(r.type)&&To(r);break;case 4:ec(r,r.stateNode.containerInfo);break;case 10:var c=r.type._context,f=r.memoizedProps.value;st(Fo,c._currentValue),c._currentValue=f;break;case 13:if(c=r.memoizedState,c!==null)return c.dehydrated!==null?(st(ht,ht.current&1),r.flags|=128,null):(a&r.child.childLanes)!==0?fp(i,r,a):(st(ht,ht.current&1),i=ln(i,r,a),i!==null?i.sibling:null);st(ht,ht.current&1);break;case 19:if(c=(a&r.childLanes)!==0,(i.flags&128)!==0){if(c)return mp(i,r,a);r.flags|=128}if(f=r.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),st(ht,ht.current),c)break;return null;case 22:case 23:return r.lanes=0,lp(i,r,a)}return ln(i,r,a)}var gp,bc,vp,_p;gp=function(i,r){for(var a=r.child;a!==null;){if(a.tag===5||a.tag===6)i.appendChild(a.stateNode);else if(a.tag!==4&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===r)break;for(;a.sibling===null;){if(a.return===null||a.return===r)return;a=a.return}a.sibling.return=a.return,a=a.sibling}},bc=function(){},vp=function(i,r,a,c){var f=i.memoizedProps;if(f!==c){i=r.stateNode,Gn($i.current);var g=null;switch(a){case"input":f=Me(i,f),c=Me(i,c),g=[];break;case"select":f=q({},f,{value:void 0}),c=q({},c,{value:void 0}),g=[];break;case"textarea":f=Ne(i,f),c=Ne(i,c),g=[];break;default:typeof f.onClick!="function"&&typeof c.onClick=="function"&&(i.onclick=Lo)}Ke(a,c);var x;a=null;for(oe in f)if(!c.hasOwnProperty(oe)&&f.hasOwnProperty(oe)&&f[oe]!=null)if(oe==="style"){var T=f[oe];for(x in T)T.hasOwnProperty(x)&&(a||(a={}),a[x]="")}else oe!=="dangerouslySetInnerHTML"&&oe!=="children"&&oe!=="suppressContentEditableWarning"&&oe!=="suppressHydrationWarning"&&oe!=="autoFocus"&&(o.hasOwnProperty(oe)?g||(g=[]):(g=g||[]).push(oe,null));for(oe in c){var $=c[oe];if(T=f!=null?f[oe]:void 0,c.hasOwnProperty(oe)&&$!==T&&($!=null||T!=null))if(oe==="style")if(T){for(x in T)!T.hasOwnProperty(x)||$&&$.hasOwnProperty(x)||(a||(a={}),a[x]="");for(x in $)$.hasOwnProperty(x)&&T[x]!==$[x]&&(a||(a={}),a[x]=$[x])}else a||(g||(g=[]),g.push(oe,a)),a=$;else oe==="dangerouslySetInnerHTML"?($=$?$.__html:void 0,T=T?T.__html:void 0,$!=null&&T!==$&&(g=g||[]).push(oe,$)):oe==="children"?typeof $!="string"&&typeof $!="number"||(g=g||[]).push(oe,""+$):oe!=="suppressContentEditableWarning"&&oe!=="suppressHydrationWarning"&&(o.hasOwnProperty(oe)?($!=null&&oe==="onScroll"&&ot("scroll",i),g||T===$||(g=[])):(g=g||[]).push(oe,$))}a&&(g=g||[]).push("style",a);var oe=g;(r.updateQueue=oe)&&(r.flags|=4)}},_p=function(i,r,a,c){a!==c&&(r.flags|=4)};function Ms(i,r){if(!ct)switch(i.tailMode){case"hidden":r=i.tail;for(var a=null;r!==null;)r.alternate!==null&&(a=r),r=r.sibling;a===null?i.tail=null:a.sibling=null;break;case"collapsed":a=i.tail;for(var c=null;a!==null;)a.alternate!==null&&(c=a),a=a.sibling;c===null?r||i.tail===null?i.tail=null:i.tail.sibling=null:c.sibling=null}}function Yt(i){var r=i.alternate!==null&&i.alternate.child===i.child,a=0,c=0;if(r)for(var f=i.child;f!==null;)a|=f.lanes|f.childLanes,c|=f.subtreeFlags&14680064,c|=f.flags&14680064,f.return=i,f=f.sibling;else for(f=i.child;f!==null;)a|=f.lanes|f.childLanes,c|=f.subtreeFlags,c|=f.flags,f.return=i,f=f.sibling;return i.subtreeFlags|=c,i.childLanes=a,r}function AS(i,r,a){var c=r.pendingProps;switch(Ul(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Yt(r),null;case 1:return ni(r.type)&&jo(),Yt(r),null;case 3:return c=r.stateNode,Ar(),at(ii),at(qt),nc(),c.pendingContext&&(c.context=c.pendingContext,c.pendingContext=null),(i===null||i.child===null)&&(Oo(r)?r.flags|=4:i===null||i.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Ti!==null&&(jc(Ti),Ti=null))),bc(i,r),Yt(r),null;case 5:tc(r);var f=Gn(Ns.current);if(a=r.type,i!==null&&r.stateNode!=null)vp(i,r,a,c,f),i.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!c){if(r.stateNode===null)throw Error(n(166));return Yt(r),null}if(i=Gn($i.current),Oo(r)){c=r.stateNode,a=r.type;var g=r.memoizedProps;switch(c[Hi]=r,c[bs]=g,i=(r.mode&1)!==0,a){case"dialog":ot("cancel",c),ot("close",c);break;case"iframe":case"object":case"embed":ot("load",c);break;case"video":case"audio":for(f=0;f<ys.length;f++)ot(ys[f],c);break;case"source":ot("error",c);break;case"img":case"image":case"link":ot("error",c),ot("load",c);break;case"details":ot("toggle",c);break;case"input":je(c,g),ot("invalid",c);break;case"select":c._wrapperState={wasMultiple:!!g.multiple},ot("invalid",c);break;case"textarea":Be(c,g),ot("invalid",c)}Ke(a,g),f=null;for(var x in g)if(g.hasOwnProperty(x)){var T=g[x];x==="children"?typeof T=="string"?c.textContent!==T&&(g.suppressHydrationWarning!==!0&&Do(c.textContent,T,i),f=["children",T]):typeof T=="number"&&c.textContent!==""+T&&(g.suppressHydrationWarning!==!0&&Do(c.textContent,T,i),f=["children",""+T]):o.hasOwnProperty(x)&&T!=null&&x==="onScroll"&&ot("scroll",c)}switch(a){case"input":te(c),we(c,g,!0);break;case"textarea":te(c),rt(c);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(c.onclick=Lo)}c=f,r.updateQueue=c,c!==null&&(r.flags|=4)}else{x=f.nodeType===9?f:f.ownerDocument,i==="http://www.w3.org/1999/xhtml"&&(i=Ae(a)),i==="http://www.w3.org/1999/xhtml"?a==="script"?(i=x.createElement("div"),i.innerHTML="<script><\/script>",i=i.removeChild(i.firstChild)):typeof c.is=="string"?i=x.createElement(a,{is:c.is}):(i=x.createElement(a),a==="select"&&(x=i,c.multiple?x.multiple=!0:c.size&&(x.size=c.size))):i=x.createElementNS(i,a),i[Hi]=r,i[bs]=c,gp(i,r,!1,!1),r.stateNode=i;e:{switch(x=Lt(a,c),a){case"dialog":ot("cancel",i),ot("close",i),f=c;break;case"iframe":case"object":case"embed":ot("load",i),f=c;break;case"video":case"audio":for(f=0;f<ys.length;f++)ot(ys[f],i);f=c;break;case"source":ot("error",i),f=c;break;case"img":case"image":case"link":ot("error",i),ot("load",i),f=c;break;case"details":ot("toggle",i),f=c;break;case"input":je(i,c),f=Me(i,c),ot("invalid",i);break;case"option":f=c;break;case"select":i._wrapperState={wasMultiple:!!c.multiple},f=q({},c,{value:void 0}),ot("invalid",i);break;case"textarea":Be(i,c),f=Ne(i,c),ot("invalid",i);break;default:f=c}Ke(a,f),T=f;for(g in T)if(T.hasOwnProperty(g)){var $=T[g];g==="style"?ue(i,$):g==="dangerouslySetInnerHTML"?($=$?$.__html:void 0,$!=null&&bt(i,$)):g==="children"?typeof $=="string"?(a!=="textarea"||$!=="")&&Ge(i,$):typeof $=="number"&&Ge(i,""+$):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(o.hasOwnProperty(g)?$!=null&&g==="onScroll"&&ot("scroll",i):$!=null&&A(i,g,$,x))}switch(a){case"input":te(i),we(i,c,!1);break;case"textarea":te(i),rt(i);break;case"option":c.value!=null&&i.setAttribute("value",""+ce(c.value));break;case"select":i.multiple=!!c.multiple,g=c.value,g!=null?Ce(i,!!c.multiple,g,!1):c.defaultValue!=null&&Ce(i,!!c.multiple,c.defaultValue,!0);break;default:typeof f.onClick=="function"&&(i.onclick=Lo)}switch(a){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}}c&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return Yt(r),null;case 6:if(i&&r.stateNode!=null)_p(i,r,i.memoizedProps,c);else{if(typeof c!="string"&&r.stateNode===null)throw Error(n(166));if(a=Gn(Ns.current),Gn($i.current),Oo(r)){if(c=r.stateNode,a=r.memoizedProps,c[Hi]=r,(g=c.nodeValue!==a)&&(i=fi,i!==null))switch(i.tag){case 3:Do(c.nodeValue,a,(i.mode&1)!==0);break;case 5:i.memoizedProps.suppressHydrationWarning!==!0&&Do(c.nodeValue,a,(i.mode&1)!==0)}g&&(r.flags|=4)}else c=(a.nodeType===9?a:a.ownerDocument).createTextNode(c),c[Hi]=r,r.stateNode=c}return Yt(r),null;case 13:if(at(ht),c=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(ct&&pi!==null&&(r.mode&1)!==0&&(r.flags&128)===0)wf(),Lr(),r.flags|=98560,g=!1;else if(g=Oo(r),c!==null&&c.dehydrated!==null){if(i===null){if(!g)throw Error(n(318));if(g=r.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(n(317));g[Hi]=r}else Lr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Yt(r),g=!1}else Ti!==null&&(jc(Ti),Ti=null),g=!0;if(!g)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=a,r):(c=c!==null,c!==(i!==null&&i.memoizedState!==null)&&c&&(r.child.flags|=8192,(r.mode&1)!==0&&(i===null||(ht.current&1)!==0?Nt===0&&(Nt=3):Bc())),r.updateQueue!==null&&(r.flags|=4),Yt(r),null);case 4:return Ar(),bc(i,r),i===null&&Ss(r.stateNode.containerInfo),Yt(r),null;case 10:return Gl(r.type._context),Yt(r),null;case 17:return ni(r.type)&&jo(),Yt(r),null;case 19:if(at(ht),g=r.memoizedState,g===null)return Yt(r),null;if(c=(r.flags&128)!==0,x=g.rendering,x===null)if(c)Ms(g,!1);else{if(Nt!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(x=Uo(i),x!==null){for(r.flags|=128,Ms(g,!1),c=x.updateQueue,c!==null&&(r.updateQueue=c,r.flags|=4),r.subtreeFlags=0,c=a,a=r.child;a!==null;)g=a,i=c,g.flags&=14680066,x=g.alternate,x===null?(g.childLanes=0,g.lanes=i,g.child=null,g.subtreeFlags=0,g.memoizedProps=null,g.memoizedState=null,g.updateQueue=null,g.dependencies=null,g.stateNode=null):(g.childLanes=x.childLanes,g.lanes=x.lanes,g.child=x.child,g.subtreeFlags=0,g.deletions=null,g.memoizedProps=x.memoizedProps,g.memoizedState=x.memoizedState,g.updateQueue=x.updateQueue,g.type=x.type,i=x.dependencies,g.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),a=a.sibling;return st(ht,ht.current&1|2),r.child}i=i.sibling}g.tail!==null&&yt()>zr&&(r.flags|=128,c=!0,Ms(g,!1),r.lanes=4194304)}else{if(!c)if(i=Uo(x),i!==null){if(r.flags|=128,c=!0,a=i.updateQueue,a!==null&&(r.updateQueue=a,r.flags|=4),Ms(g,!0),g.tail===null&&g.tailMode==="hidden"&&!x.alternate&&!ct)return Yt(r),null}else 2*yt()-g.renderingStartTime>zr&&a!==1073741824&&(r.flags|=128,c=!0,Ms(g,!1),r.lanes=4194304);g.isBackwards?(x.sibling=r.child,r.child=x):(a=g.last,a!==null?a.sibling=x:r.child=x,g.last=x)}return g.tail!==null?(r=g.tail,g.rendering=r,g.tail=r.sibling,g.renderingStartTime=yt(),r.sibling=null,a=ht.current,st(ht,c?a&1|2:a&1),r):(Yt(r),null);case 22:case 23:return Ac(),c=r.memoizedState!==null,i!==null&&i.memoizedState!==null!==c&&(r.flags|=8192),c&&(r.mode&1)!==0?(mi&1073741824)!==0&&(Yt(r),r.subtreeFlags&6&&(r.flags|=8192)):Yt(r),null;case 24:return null;case 25:return null}throw Error(n(156,r.tag))}function BS(i,r){switch(Ul(r),r.tag){case 1:return ni(r.type)&&jo(),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return Ar(),at(ii),at(qt),nc(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 5:return tc(r),null;case 13:if(at(ht),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(n(340));Lr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return at(ht),null;case 4:return Ar(),null;case 10:return Gl(r.type._context),null;case 22:case 23:return Ac(),null;case 24:return null;default:return null}}var Zo=!1,Xt=!1,IS=typeof WeakSet=="function"?WeakSet:Set,Re=null;function Ir(i,r){var a=i.ref;if(a!==null)if(typeof a=="function")try{a(null)}catch(c){gt(i,r,c)}else a.current=null}function Cc(i,r,a){try{a()}catch(c){gt(i,r,c)}}var yp=!1;function OS(i,r){if(Al=yo,i=Gd(),Nl(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var c=a.getSelection&&a.getSelection();if(c&&c.rangeCount!==0){a=c.anchorNode;var f=c.anchorOffset,g=c.focusNode;c=c.focusOffset;try{a.nodeType,g.nodeType}catch{a=null;break e}var x=0,T=-1,$=-1,oe=0,ve=0,_e=i,me=null;t:for(;;){for(var Ee;_e!==a||f!==0&&_e.nodeType!==3||(T=x+f),_e!==g||c!==0&&_e.nodeType!==3||($=x+c),_e.nodeType===3&&(x+=_e.nodeValue.length),(Ee=_e.firstChild)!==null;)me=_e,_e=Ee;for(;;){if(_e===i)break t;if(me===a&&++oe===f&&(T=x),me===g&&++ve===c&&($=x),(Ee=_e.nextSibling)!==null)break;_e=me,me=_e.parentNode}_e=Ee}a=T===-1||$===-1?null:{start:T,end:$}}else a=null}a=a||{start:0,end:0}}else a=null;for(Bl={focusedElem:i,selectionRange:a},yo=!1,Re=r;Re!==null;)if(r=Re,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,Re=i;else for(;Re!==null;){r=Re;try{var Pe=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(Pe!==null){var Le=Pe.memoizedProps,St=Pe.memoizedState,Z=r.stateNode,V=Z.getSnapshotBeforeUpdate(r.elementType===r.type?Le:Ai(r.type,Le),St);Z.__reactInternalSnapshotBeforeUpdate=V}break;case 3:var ne=r.stateNode.containerInfo;ne.nodeType===1?ne.textContent="":ne.nodeType===9&&ne.documentElement&&ne.removeChild(ne.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Se){gt(r,r.return,Se)}if(i=r.sibling,i!==null){i.return=r.return,Re=i;break}Re=r.return}return Pe=yp,yp=!1,Pe}function js(i,r,a){var c=r.updateQueue;if(c=c!==null?c.lastEffect:null,c!==null){var f=c=c.next;do{if((f.tag&i)===i){var g=f.destroy;f.destroy=void 0,g!==void 0&&Cc(r,a,g)}f=f.next}while(f!==c)}}function ea(i,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var a=r=r.next;do{if((a.tag&i)===i){var c=a.create;a.destroy=c()}a=a.next}while(a!==r)}}function kc(i){var r=i.ref;if(r!==null){var a=i.stateNode;switch(i.tag){case 5:i=a;break;default:i=a}typeof r=="function"?r(i):r.current=i}}function Sp(i){var r=i.alternate;r!==null&&(i.alternate=null,Sp(r)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(r=i.stateNode,r!==null&&(delete r[Hi],delete r[bs],delete r[Fl],delete r[SS],delete r[wS])),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 wp(i){return i.tag===5||i.tag===3||i.tag===4}function bp(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||wp(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 xc(i,r,a){var c=i.tag;if(c===5||c===6)i=i.stateNode,r?a.nodeType===8?a.parentNode.insertBefore(i,r):a.insertBefore(i,r):(a.nodeType===8?(r=a.parentNode,r.insertBefore(i,a)):(r=a,r.appendChild(i)),a=a._reactRootContainer,a!=null||r.onclick!==null||(r.onclick=Lo));else if(c!==4&&(i=i.child,i!==null))for(xc(i,r,a),i=i.sibling;i!==null;)xc(i,r,a),i=i.sibling}function Ec(i,r,a){var c=i.tag;if(c===5||c===6)i=i.stateNode,r?a.insertBefore(i,r):a.appendChild(i);else if(c!==4&&(i=i.child,i!==null))for(Ec(i,r,a),i=i.sibling;i!==null;)Ec(i,r,a),i=i.sibling}var Ht=null,Bi=!1;function Pn(i,r,a){for(a=a.child;a!==null;)Cp(i,r,a),a=a.sibling}function Cp(i,r,a){if(Fi&&typeof Fi.onCommitFiberUnmount=="function")try{Fi.onCommitFiberUnmount(fo,a)}catch{}switch(a.tag){case 5:Xt||Ir(a,r);case 6:var c=Ht,f=Bi;Ht=null,Pn(i,r,a),Ht=c,Bi=f,Ht!==null&&(Bi?(i=Ht,a=a.stateNode,i.nodeType===8?i.parentNode.removeChild(a):i.removeChild(a)):Ht.removeChild(a.stateNode));break;case 18:Ht!==null&&(Bi?(i=Ht,a=a.stateNode,i.nodeType===8?zl(i.parentNode,a):i.nodeType===1&&zl(i,a),hs(i)):zl(Ht,a.stateNode));break;case 4:c=Ht,f=Bi,Ht=a.stateNode.containerInfo,Bi=!0,Pn(i,r,a),Ht=c,Bi=f;break;case 0:case 11:case 14:case 15:if(!Xt&&(c=a.updateQueue,c!==null&&(c=c.lastEffect,c!==null))){f=c=c.next;do{var g=f,x=g.destroy;g=g.tag,x!==void 0&&((g&2)!==0||(g&4)!==0)&&Cc(a,r,x),f=f.next}while(f!==c)}Pn(i,r,a);break;case 1:if(!Xt&&(Ir(a,r),c=a.stateNode,typeof c.componentWillUnmount=="function"))try{c.props=a.memoizedProps,c.state=a.memoizedState,c.componentWillUnmount()}catch(T){gt(a,r,T)}Pn(i,r,a);break;case 21:Pn(i,r,a);break;case 22:a.mode&1?(Xt=(c=Xt)||a.memoizedState!==null,Pn(i,r,a),Xt=c):Pn(i,r,a);break;default:Pn(i,r,a)}}function kp(i){var r=i.updateQueue;if(r!==null){i.updateQueue=null;var a=i.stateNode;a===null&&(a=i.stateNode=new IS),r.forEach(function(c){var f=VS.bind(null,i,c);a.has(c)||(a.add(c),c.then(f,f))})}}function Ii(i,r){var a=r.deletions;if(a!==null)for(var c=0;c<a.length;c++){var f=a[c];try{var g=i,x=r,T=x;e:for(;T!==null;){switch(T.tag){case 5:Ht=T.stateNode,Bi=!1;break e;case 3:Ht=T.stateNode.containerInfo,Bi=!0;break e;case 4:Ht=T.stateNode.containerInfo,Bi=!0;break e}T=T.return}if(Ht===null)throw Error(n(160));Cp(g,x,f),Ht=null,Bi=!1;var $=f.alternate;$!==null&&($.return=null),f.return=null}catch(oe){gt(f,r,oe)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)xp(r,i),r=r.sibling}function xp(i,r){var a=i.alternate,c=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:if(Ii(r,i),Ui(i),c&4){try{js(3,i,i.return),ea(3,i)}catch(Le){gt(i,i.return,Le)}try{js(5,i,i.return)}catch(Le){gt(i,i.return,Le)}}break;case 1:Ii(r,i),Ui(i),c&512&&a!==null&&Ir(a,a.return);break;case 5:if(Ii(r,i),Ui(i),c&512&&a!==null&&Ir(a,a.return),i.flags&32){var f=i.stateNode;try{Ge(f,"")}catch(Le){gt(i,i.return,Le)}}if(c&4&&(f=i.stateNode,f!=null)){var g=i.memoizedProps,x=a!==null?a.memoizedProps:g,T=i.type,$=i.updateQueue;if(i.updateQueue=null,$!==null)try{T==="input"&&g.type==="radio"&&g.name!=null&&Y(f,g),Lt(T,x);var oe=Lt(T,g);for(x=0;x<$.length;x+=2){var ve=$[x],_e=$[x+1];ve==="style"?ue(f,_e):ve==="dangerouslySetInnerHTML"?bt(f,_e):ve==="children"?Ge(f,_e):A(f,ve,_e,oe)}switch(T){case"input":de(f,g);break;case"textarea":mt(f,g);break;case"select":var me=f._wrapperState.wasMultiple;f._wrapperState.wasMultiple=!!g.multiple;var Ee=g.value;Ee!=null?Ce(f,!!g.multiple,Ee,!1):me!==!!g.multiple&&(g.defaultValue!=null?Ce(f,!!g.multiple,g.defaultValue,!0):Ce(f,!!g.multiple,g.multiple?[]:"",!1))}f[bs]=g}catch(Le){gt(i,i.return,Le)}}break;case 6:if(Ii(r,i),Ui(i),c&4){if(i.stateNode===null)throw Error(n(162));f=i.stateNode,g=i.memoizedProps;try{f.nodeValue=g}catch(Le){gt(i,i.return,Le)}}break;case 3:if(Ii(r,i),Ui(i),c&4&&a!==null&&a.memoizedState.isDehydrated)try{hs(r.containerInfo)}catch(Le){gt(i,i.return,Le)}break;case 4:Ii(r,i),Ui(i);break;case 13:Ii(r,i),Ui(i),f=i.child,f.flags&8192&&(g=f.memoizedState!==null,f.stateNode.isHidden=g,!g||f.alternate!==null&&f.alternate.memoizedState!==null||(Pc=yt())),c&4&&kp(i);break;case 22:if(ve=a!==null&&a.memoizedState!==null,i.mode&1?(Xt=(oe=Xt)||ve,Ii(r,i),Xt=oe):Ii(r,i),Ui(i),c&8192){if(oe=i.memoizedState!==null,(i.stateNode.isHidden=oe)&&!ve&&(i.mode&1)!==0)for(Re=i,ve=i.child;ve!==null;){for(_e=Re=ve;Re!==null;){switch(me=Re,Ee=me.child,me.tag){case 0:case 11:case 14:case 15:js(4,me,me.return);break;case 1:Ir(me,me.return);var Pe=me.stateNode;if(typeof Pe.componentWillUnmount=="function"){c=me,a=me.return;try{r=c,Pe.props=r.memoizedProps,Pe.state=r.memoizedState,Pe.componentWillUnmount()}catch(Le){gt(c,a,Le)}}break;case 5:Ir(me,me.return);break;case 22:if(me.memoizedState!==null){Rp(_e);continue}}Ee!==null?(Ee.return=me,Re=Ee):Rp(_e)}ve=ve.sibling}e:for(ve=null,_e=i;;){if(_e.tag===5){if(ve===null){ve=_e;try{f=_e.stateNode,oe?(g=f.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(T=_e.stateNode,$=_e.memoizedProps.style,x=$!=null&&$.hasOwnProperty("display")?$.display:null,T.style.display=et("display",x))}catch(Le){gt(i,i.return,Le)}}}else if(_e.tag===6){if(ve===null)try{_e.stateNode.nodeValue=oe?"":_e.memoizedProps}catch(Le){gt(i,i.return,Le)}}else if((_e.tag!==22&&_e.tag!==23||_e.memoizedState===null||_e===i)&&_e.child!==null){_e.child.return=_e,_e=_e.child;continue}if(_e===i)break e;for(;_e.sibling===null;){if(_e.return===null||_e.return===i)break e;ve===_e&&(ve=null),_e=_e.return}ve===_e&&(ve=null),_e.sibling.return=_e.return,_e=_e.sibling}}break;case 19:Ii(r,i),Ui(i),c&4&&kp(i);break;case 21:break;default:Ii(r,i),Ui(i)}}function Ui(i){var r=i.flags;if(r&2){try{e:{for(var a=i.return;a!==null;){if(wp(a)){var c=a;break e}a=a.return}throw Error(n(160))}switch(c.tag){case 5:var f=c.stateNode;c.flags&32&&(Ge(f,""),c.flags&=-33);var g=bp(i);Ec(i,g,f);break;case 3:case 4:var x=c.stateNode.containerInfo,T=bp(i);xc(i,T,x);break;default:throw Error(n(161))}}catch($){gt(i,i.return,$)}i.flags&=-3}r&4096&&(i.flags&=-4097)}function zS(i,r,a){Re=i,Ep(i)}function Ep(i,r,a){for(var c=(i.mode&1)!==0;Re!==null;){var f=Re,g=f.child;if(f.tag===22&&c){var x=f.memoizedState!==null||Zo;if(!x){var T=f.alternate,$=T!==null&&T.memoizedState!==null||Xt;T=Zo;var oe=Xt;if(Zo=x,(Xt=$)&&!oe)for(Re=f;Re!==null;)x=Re,$=x.child,x.tag===22&&x.memoizedState!==null?Pp(f):$!==null?($.return=x,Re=$):Pp(f);for(;g!==null;)Re=g,Ep(g),g=g.sibling;Re=f,Zo=T,Xt=oe}Np(i)}else(f.subtreeFlags&8772)!==0&&g!==null?(g.return=f,Re=g):Np(i)}}function Np(i){for(;Re!==null;){var r=Re;if((r.flags&8772)!==0){var a=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:Xt||ea(5,r);break;case 1:var c=r.stateNode;if(r.flags&4&&!Xt)if(a===null)c.componentDidMount();else{var f=r.elementType===r.type?a.memoizedProps:Ai(r.type,a.memoizedProps);c.componentDidUpdate(f,a.memoizedState,c.__reactInternalSnapshotBeforeUpdate)}var g=r.updateQueue;g!==null&&Rf(r,g,c);break;case 3:var x=r.updateQueue;if(x!==null){if(a=null,r.child!==null)switch(r.child.tag){case 5:a=r.child.stateNode;break;case 1:a=r.child.stateNode}Rf(r,x,a)}break;case 5:var T=r.stateNode;if(a===null&&r.flags&4){a=T;var $=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":$.autoFocus&&a.focus();break;case"img":$.src&&(a.src=$.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var oe=r.alternate;if(oe!==null){var ve=oe.memoizedState;if(ve!==null){var _e=ve.dehydrated;_e!==null&&hs(_e)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Xt||r.flags&512&&kc(r)}catch(me){gt(r,r.return,me)}}if(r===i){Re=null;break}if(a=r.sibling,a!==null){a.return=r.return,Re=a;break}Re=r.return}}function Rp(i){for(;Re!==null;){var r=Re;if(r===i){Re=null;break}var a=r.sibling;if(a!==null){a.return=r.return,Re=a;break}Re=r.return}}function Pp(i){for(;Re!==null;){var r=Re;try{switch(r.tag){case 0:case 11:case 15:var a=r.return;try{ea(4,r)}catch($){gt(r,a,$)}break;case 1:var c=r.stateNode;if(typeof c.componentDidMount=="function"){var f=r.return;try{c.componentDidMount()}catch($){gt(r,f,$)}}var g=r.return;try{kc(r)}catch($){gt(r,g,$)}break;case 5:var x=r.return;try{kc(r)}catch($){gt(r,x,$)}}}catch($){gt(r,r.return,$)}if(r===i){Re=null;break}var T=r.sibling;if(T!==null){T.return=r.return,Re=T;break}Re=r.return}}var FS=Math.ceil,ta=B.ReactCurrentDispatcher,Nc=B.ReactCurrentOwner,xi=B.ReactCurrentBatchConfig,Je=0,jt=null,Ct=null,$t=0,mi=0,Or=kn(0),Nt=0,Ts=null,Jn=0,ia=0,Rc=0,As=null,si=null,Pc=0,zr=1/0,cn=null,na=!1,Dc=null,Dn=null,ra=!1,Ln=null,sa=0,Bs=0,Lc=null,oa=-1,aa=0;function Jt(){return(Je&6)!==0?yt():oa!==-1?oa:oa=yt()}function Mn(i){return(i.mode&1)===0?1:(Je&2)!==0&&$t!==0?$t&-$t:CS.transition!==null?(aa===0&&(aa=wd()),aa):(i=it,i!==0||(i=window.event,i=i===void 0?16:Dd(i.type)),i)}function Oi(i,r,a,c){if(50<Bs)throw Bs=0,Lc=null,Error(n(185));os(i,a,c),((Je&2)===0||i!==jt)&&(i===jt&&((Je&2)===0&&(ia|=a),Nt===4&&jn(i,$t)),oi(i,c),a===1&&Je===0&&(r.mode&1)===0&&(zr=yt()+500,Ao&&En()))}function oi(i,r){var a=i.callbackNode;Cy(i,r);var c=go(i,i===jt?$t:0);if(c===0)a!==null&&_d(a),i.callbackNode=null,i.callbackPriority=0;else if(r=c&-c,i.callbackPriority!==r){if(a!=null&&_d(a),r===1)i.tag===0?bS(Lp.bind(null,i)):gf(Lp.bind(null,i)),_S(function(){(Je&6)===0&&En()}),a=null;else{switch(bd(c)){case 1:a=ul;break;case 4:a=yd;break;case 16:a=ho;break;case 536870912:a=Sd;break;default:a=ho}a=zp(a,Dp.bind(null,i))}i.callbackPriority=r,i.callbackNode=a}}function Dp(i,r){if(oa=-1,aa=0,(Je&6)!==0)throw Error(n(327));var a=i.callbackNode;if(Fr()&&i.callbackNode!==a)return null;var c=go(i,i===jt?$t:0);if(c===0)return null;if((c&30)!==0||(c&i.expiredLanes)!==0||r)r=la(i,c);else{r=c;var f=Je;Je|=2;var g=jp();(jt!==i||$t!==r)&&(cn=null,zr=yt()+500,er(i,r));do try{WS();break}catch(T){Mp(i,T)}while(!0);Xl(),ta.current=g,Je=f,Ct!==null?r=0:(jt=null,$t=0,r=Nt)}if(r!==0){if(r===2&&(f=hl(i),f!==0&&(c=f,r=Mc(i,f))),r===1)throw a=Ts,er(i,0),jn(i,c),oi(i,yt()),a;if(r===6)jn(i,c);else{if(f=i.current.alternate,(c&30)===0&&!HS(f)&&(r=la(i,c),r===2&&(g=hl(i),g!==0&&(c=g,r=Mc(i,g))),r===1))throw a=Ts,er(i,0),jn(i,c),oi(i,yt()),a;switch(i.finishedWork=f,i.finishedLanes=c,r){case 0:case 1:throw Error(n(345));case 2:tr(i,si,cn);break;case 3:if(jn(i,c),(c&130023424)===c&&(r=Pc+500-yt(),10<r)){if(go(i,0)!==0)break;if(f=i.suspendedLanes,(f&c)!==c){Jt(),i.pingedLanes|=i.suspendedLanes&f;break}i.timeoutHandle=Ol(tr.bind(null,i,si,cn),r);break}tr(i,si,cn);break;case 4:if(jn(i,c),(c&4194240)===c)break;for(r=i.eventTimes,f=-1;0<c;){var x=31-Mi(c);g=1<<x,x=r[x],x>f&&(f=x),c&=~g}if(c=f,c=yt()-c,c=(120>c?120:480>c?480:1080>c?1080:1920>c?1920:3e3>c?3e3:4320>c?4320:1960*FS(c/1960))-c,10<c){i.timeoutHandle=Ol(tr.bind(null,i,si,cn),c);break}tr(i,si,cn);break;case 5:tr(i,si,cn);break;default:throw Error(n(329))}}}return oi(i,yt()),i.callbackNode===a?Dp.bind(null,i):null}function Mc(i,r){var a=As;return i.current.memoizedState.isDehydrated&&(er(i,r).flags|=256),i=la(i,r),i!==2&&(r=si,si=a,r!==null&&jc(r)),i}function jc(i){si===null?si=i:si.push.apply(si,i)}function HS(i){for(var r=i;;){if(r.flags&16384){var a=r.updateQueue;if(a!==null&&(a=a.stores,a!==null))for(var c=0;c<a.length;c++){var f=a[c],g=f.getSnapshot;f=f.value;try{if(!ji(g(),f))return!1}catch{return!1}}}if(a=r.child,r.subtreeFlags&16384&&a!==null)a.return=r,r=a;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 jn(i,r){for(r&=~Rc,r&=~ia,i.suspendedLanes|=r,i.pingedLanes&=~r,i=i.expirationTimes;0<r;){var a=31-Mi(r),c=1<<a;i[a]=-1,r&=~c}}function Lp(i){if((Je&6)!==0)throw Error(n(327));Fr();var r=go(i,0);if((r&1)===0)return oi(i,yt()),null;var a=la(i,r);if(i.tag!==0&&a===2){var c=hl(i);c!==0&&(r=c,a=Mc(i,c))}if(a===1)throw a=Ts,er(i,0),jn(i,r),oi(i,yt()),a;if(a===6)throw Error(n(345));return i.finishedWork=i.current.alternate,i.finishedLanes=r,tr(i,si,cn),oi(i,yt()),null}function Tc(i,r){var a=Je;Je|=1;try{return i(r)}finally{Je=a,Je===0&&(zr=yt()+500,Ao&&En())}}function Zn(i){Ln!==null&&Ln.tag===0&&(Je&6)===0&&Fr();var r=Je;Je|=1;var a=xi.transition,c=it;try{if(xi.transition=null,it=1,i)return i()}finally{it=c,xi.transition=a,Je=r,(Je&6)===0&&En()}}function Ac(){mi=Or.current,at(Or)}function er(i,r){i.finishedWork=null,i.finishedLanes=0;var a=i.timeoutHandle;if(a!==-1&&(i.timeoutHandle=-1,vS(a)),Ct!==null)for(a=Ct.return;a!==null;){var c=a;switch(Ul(c),c.tag){case 1:c=c.type.childContextTypes,c!=null&&jo();break;case 3:Ar(),at(ii),at(qt),nc();break;case 5:tc(c);break;case 4:Ar();break;case 13:at(ht);break;case 19:at(ht);break;case 10:Gl(c.type._context);break;case 22:case 23:Ac()}a=a.return}if(jt=i,Ct=i=Tn(i.current,null),$t=mi=r,Nt=0,Ts=null,Rc=ia=Jn=0,si=As=null,Xn!==null){for(r=0;r<Xn.length;r++)if(a=Xn[r],c=a.interleaved,c!==null){a.interleaved=null;var f=c.next,g=a.pending;if(g!==null){var x=g.next;g.next=f,c.next=x}a.pending=c}Xn=null}return i}function Mp(i,r){do{var a=Ct;try{if(Xl(),Ko.current=Xo,qo){for(var c=dt.memoizedState;c!==null;){var f=c.queue;f!==null&&(f.pending=null),c=c.next}qo=!1}if(Qn=0,Mt=Et=dt=null,Rs=!1,Ps=0,Nc.current=null,a===null||a.return===null){Nt=1,Ts=r,Ct=null;break}e:{var g=i,x=a.return,T=a,$=r;if(r=$t,T.flags|=32768,$!==null&&typeof $=="object"&&typeof $.then=="function"){var oe=$,ve=T,_e=ve.tag;if((ve.mode&1)===0&&(_e===0||_e===11||_e===15)){var me=ve.alternate;me?(ve.updateQueue=me.updateQueue,ve.memoizedState=me.memoizedState,ve.lanes=me.lanes):(ve.updateQueue=null,ve.memoizedState=null)}var Ee=np(x);if(Ee!==null){Ee.flags&=-257,rp(Ee,x,T,g,r),Ee.mode&1&&ip(g,oe,r),r=Ee,$=oe;var Pe=r.updateQueue;if(Pe===null){var Le=new Set;Le.add($),r.updateQueue=Le}else Pe.add($);break e}else{if((r&1)===0){ip(g,oe,r),Bc();break e}$=Error(n(426))}}else if(ct&&T.mode&1){var St=np(x);if(St!==null){(St.flags&65536)===0&&(St.flags|=256),rp(St,x,T,g,r),Vl(Br($,T));break e}}g=$=Br($,T),Nt!==4&&(Nt=2),As===null?As=[g]:As.push(g),g=x;do{switch(g.tag){case 3:g.flags|=65536,r&=-r,g.lanes|=r;var Z=ep(g,$,r);Nf(g,Z);break e;case 1:T=$;var V=g.type,ne=g.stateNode;if((g.flags&128)===0&&(typeof V.getDerivedStateFromError=="function"||ne!==null&&typeof ne.componentDidCatch=="function"&&(Dn===null||!Dn.has(ne)))){g.flags|=65536,r&=-r,g.lanes|=r;var Se=tp(g,T,r);Nf(g,Se);break e}}g=g.return}while(g!==null)}Ap(a)}catch(Te){r=Te,Ct===a&&a!==null&&(Ct=a=a.return);continue}break}while(!0)}function jp(){var i=ta.current;return ta.current=Xo,i===null?Xo:i}function Bc(){(Nt===0||Nt===3||Nt===2)&&(Nt=4),jt===null||(Jn&268435455)===0&&(ia&268435455)===0||jn(jt,$t)}function la(i,r){var a=Je;Je|=2;var c=jp();(jt!==i||$t!==r)&&(cn=null,er(i,r));do try{$S();break}catch(f){Mp(i,f)}while(!0);if(Xl(),Je=a,ta.current=c,Ct!==null)throw Error(n(261));return jt=null,$t=0,Nt}function $S(){for(;Ct!==null;)Tp(Ct)}function WS(){for(;Ct!==null&&!py();)Tp(Ct)}function Tp(i){var r=Op(i.alternate,i,mi);i.memoizedProps=i.pendingProps,r===null?Ap(i):Ct=r,Nc.current=null}function Ap(i){var r=i;do{var a=r.alternate;if(i=r.return,(r.flags&32768)===0){if(a=AS(a,r,mi),a!==null){Ct=a;return}}else{if(a=BS(a,r),a!==null){a.flags&=32767,Ct=a;return}if(i!==null)i.flags|=32768,i.subtreeFlags=0,i.deletions=null;else{Nt=6,Ct=null;return}}if(r=r.sibling,r!==null){Ct=r;return}Ct=r=i}while(r!==null);Nt===0&&(Nt=5)}function tr(i,r,a){var c=it,f=xi.transition;try{xi.transition=null,it=1,US(i,r,a,c)}finally{xi.transition=f,it=c}return null}function US(i,r,a,c){do Fr();while(Ln!==null);if((Je&6)!==0)throw Error(n(327));a=i.finishedWork;var f=i.finishedLanes;if(a===null)return null;if(i.finishedWork=null,i.finishedLanes=0,a===i.current)throw Error(n(177));i.callbackNode=null,i.callbackPriority=0;var g=a.lanes|a.childLanes;if(ky(i,g),i===jt&&(Ct=jt=null,$t=0),(a.subtreeFlags&2064)===0&&(a.flags&2064)===0||ra||(ra=!0,zp(ho,function(){return Fr(),null})),g=(a.flags&15990)!==0,(a.subtreeFlags&15990)!==0||g){g=xi.transition,xi.transition=null;var x=it;it=1;var T=Je;Je|=4,Nc.current=null,OS(i,a),xp(a,i),uS(Bl),yo=!!Al,Bl=Al=null,i.current=a,zS(a),my(),Je=T,it=x,xi.transition=g}else i.current=a;if(ra&&(ra=!1,Ln=i,sa=f),g=i.pendingLanes,g===0&&(Dn=null),_y(a.stateNode),oi(i,yt()),r!==null)for(c=i.onRecoverableError,a=0;a<r.length;a++)f=r[a],c(f.value,{componentStack:f.stack,digest:f.digest});if(na)throw na=!1,i=Dc,Dc=null,i;return(sa&1)!==0&&i.tag!==0&&Fr(),g=i.pendingLanes,(g&1)!==0?i===Lc?Bs++:(Bs=0,Lc=i):Bs=0,En(),null}function Fr(){if(Ln!==null){var i=bd(sa),r=xi.transition,a=it;try{if(xi.transition=null,it=16>i?16:i,Ln===null)var c=!1;else{if(i=Ln,Ln=null,sa=0,(Je&6)!==0)throw Error(n(331));var f=Je;for(Je|=4,Re=i.current;Re!==null;){var g=Re,x=g.child;if((Re.flags&16)!==0){var T=g.deletions;if(T!==null){for(var $=0;$<T.length;$++){var oe=T[$];for(Re=oe;Re!==null;){var ve=Re;switch(ve.tag){case 0:case 11:case 15:js(8,ve,g)}var _e=ve.child;if(_e!==null)_e.return=ve,Re=_e;else for(;Re!==null;){ve=Re;var me=ve.sibling,Ee=ve.return;if(Sp(ve),ve===oe){Re=null;break}if(me!==null){me.return=Ee,Re=me;break}Re=Ee}}}var Pe=g.alternate;if(Pe!==null){var Le=Pe.child;if(Le!==null){Pe.child=null;do{var St=Le.sibling;Le.sibling=null,Le=St}while(Le!==null)}}Re=g}}if((g.subtreeFlags&2064)!==0&&x!==null)x.return=g,Re=x;else e:for(;Re!==null;){if(g=Re,(g.flags&2048)!==0)switch(g.tag){case 0:case 11:case 15:js(9,g,g.return)}var Z=g.sibling;if(Z!==null){Z.return=g.return,Re=Z;break e}Re=g.return}}var V=i.current;for(Re=V;Re!==null;){x=Re;var ne=x.child;if((x.subtreeFlags&2064)!==0&&ne!==null)ne.return=x,Re=ne;else e:for(x=V;Re!==null;){if(T=Re,(T.flags&2048)!==0)try{switch(T.tag){case 0:case 11:case 15:ea(9,T)}}catch(Te){gt(T,T.return,Te)}if(T===x){Re=null;break e}var Se=T.sibling;if(Se!==null){Se.return=T.return,Re=Se;break e}Re=T.return}}if(Je=f,En(),Fi&&typeof Fi.onPostCommitFiberRoot=="function")try{Fi.onPostCommitFiberRoot(fo,i)}catch{}c=!0}return c}finally{it=a,xi.transition=r}}return!1}function Bp(i,r,a){r=Br(a,r),r=ep(i,r,1),i=Rn(i,r,1),r=Jt(),i!==null&&(os(i,1,r),oi(i,r))}function gt(i,r,a){if(i.tag===3)Bp(i,i,a);else for(;r!==null;){if(r.tag===3){Bp(r,i,a);break}else if(r.tag===1){var c=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Dn===null||!Dn.has(c))){i=Br(a,i),i=tp(r,i,1),r=Rn(r,i,1),i=Jt(),r!==null&&(os(r,1,i),oi(r,i));break}}r=r.return}}function KS(i,r,a){var c=i.pingCache;c!==null&&c.delete(r),r=Jt(),i.pingedLanes|=i.suspendedLanes&a,jt===i&&($t&a)===a&&(Nt===4||Nt===3&&($t&130023424)===$t&&500>yt()-Pc?er(i,0):Rc|=a),oi(i,r)}function Ip(i,r){r===0&&((i.mode&1)===0?r=1:(r=mo,mo<<=1,(mo&130023424)===0&&(mo=4194304)));var a=Jt();i=on(i,r),i!==null&&(os(i,r,a),oi(i,a))}function qS(i){var r=i.memoizedState,a=0;r!==null&&(a=r.retryLane),Ip(i,a)}function VS(i,r){var a=0;switch(i.tag){case 13:var c=i.stateNode,f=i.memoizedState;f!==null&&(a=f.retryLane);break;case 19:c=i.stateNode;break;default:throw Error(n(314))}c!==null&&c.delete(r),Ip(i,a)}var Op;Op=function(i,r,a){if(i!==null)if(i.memoizedProps!==r.pendingProps||ii.current)ri=!0;else{if((i.lanes&a)===0&&(r.flags&128)===0)return ri=!1,TS(i,r,a);ri=(i.flags&131072)!==0}else ri=!1,ct&&(r.flags&1048576)!==0&&vf(r,Io,r.index);switch(r.lanes=0,r.tag){case 2:var c=r.type;Jo(i,r),i=r.pendingProps;var f=Rr(r,qt.current);Tr(r,a),f=oc(null,r,c,i,f,a);var g=ac();return r.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,ni(c)?(g=!0,To(r)):g=!1,r.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Zl(r),f.updater=Go,r.stateNode=f,f._reactInternals=r,fc(r,c,i,a),r=vc(null,r,c,!0,g,a)):(r.tag=0,ct&&g&&Wl(r),Qt(null,r,f,a),r=r.child),r;case 16:c=r.elementType;e:{switch(Jo(i,r),i=r.pendingProps,f=c._init,c=f(c._payload),r.type=c,f=r.tag=XS(c),i=Ai(c,i),f){case 0:r=gc(null,r,c,i,a);break e;case 1:r=up(null,r,c,i,a);break e;case 11:r=sp(null,r,c,i,a);break e;case 14:r=op(null,r,c,Ai(c.type,i),a);break e}throw Error(n(306,c,""))}return r;case 0:return c=r.type,f=r.pendingProps,f=r.elementType===c?f:Ai(c,f),gc(i,r,c,f,a);case 1:return c=r.type,f=r.pendingProps,f=r.elementType===c?f:Ai(c,f),up(i,r,c,f,a);case 3:e:{if(hp(r),i===null)throw Error(n(387));c=r.pendingProps,g=r.memoizedState,f=g.element,Ef(i,r),Wo(r,c,null,a);var x=r.memoizedState;if(c=x.element,g.isDehydrated)if(g={element:c,isDehydrated:!1,cache:x.cache,pendingSuspenseBoundaries:x.pendingSuspenseBoundaries,transitions:x.transitions},r.updateQueue.baseState=g,r.memoizedState=g,r.flags&256){f=Br(Error(n(423)),r),r=dp(i,r,c,a,f);break e}else if(c!==f){f=Br(Error(n(424)),r),r=dp(i,r,c,a,f);break e}else for(pi=Cn(r.stateNode.containerInfo.firstChild),fi=r,ct=!0,Ti=null,a=kf(r,null,c,a),r.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(Lr(),c===f){r=ln(i,r,a);break e}Qt(i,r,c,a)}r=r.child}return r;case 5:return Pf(r),i===null&&ql(r),c=r.type,f=r.pendingProps,g=i!==null?i.memoizedProps:null,x=f.children,Il(c,f)?x=null:g!==null&&Il(c,g)&&(r.flags|=32),cp(i,r),Qt(i,r,x,a),r.child;case 6:return i===null&&ql(r),null;case 13:return fp(i,r,a);case 4:return ec(r,r.stateNode.containerInfo),c=r.pendingProps,i===null?r.child=Mr(r,null,c,a):Qt(i,r,c,a),r.child;case 11:return c=r.type,f=r.pendingProps,f=r.elementType===c?f:Ai(c,f),sp(i,r,c,f,a);case 7:return Qt(i,r,r.pendingProps,a),r.child;case 8:return Qt(i,r,r.pendingProps.children,a),r.child;case 12:return Qt(i,r,r.pendingProps.children,a),r.child;case 10:e:{if(c=r.type._context,f=r.pendingProps,g=r.memoizedProps,x=f.value,st(Fo,c._currentValue),c._currentValue=x,g!==null)if(ji(g.value,x)){if(g.children===f.children&&!ii.current){r=ln(i,r,a);break e}}else for(g=r.child,g!==null&&(g.return=r);g!==null;){var T=g.dependencies;if(T!==null){x=g.child;for(var $=T.firstContext;$!==null;){if($.context===c){if(g.tag===1){$=an(-1,a&-a),$.tag=2;var oe=g.updateQueue;if(oe!==null){oe=oe.shared;var ve=oe.pending;ve===null?$.next=$:($.next=ve.next,ve.next=$),oe.pending=$}}g.lanes|=a,$=g.alternate,$!==null&&($.lanes|=a),Ql(g.return,a,r),T.lanes|=a;break}$=$.next}}else if(g.tag===10)x=g.type===r.type?null:g.child;else if(g.tag===18){if(x=g.return,x===null)throw Error(n(341));x.lanes|=a,T=x.alternate,T!==null&&(T.lanes|=a),Ql(x,a,r),x=g.sibling}else x=g.child;if(x!==null)x.return=g;else for(x=g;x!==null;){if(x===r){x=null;break}if(g=x.sibling,g!==null){g.return=x.return,x=g;break}x=x.return}g=x}Qt(i,r,f.children,a),r=r.child}return r;case 9:return f=r.type,c=r.pendingProps.children,Tr(r,a),f=Ci(f),c=c(f),r.flags|=1,Qt(i,r,c,a),r.child;case 14:return c=r.type,f=Ai(c,r.pendingProps),f=Ai(c.type,f),op(i,r,c,f,a);case 15:return ap(i,r,r.type,r.pendingProps,a);case 17:return c=r.type,f=r.pendingProps,f=r.elementType===c?f:Ai(c,f),Jo(i,r),r.tag=1,ni(c)?(i=!0,To(r)):i=!1,Tr(r,a),Jf(r,c,f),fc(r,c,f,a),vc(null,r,c,!0,i,a);case 19:return mp(i,r,a);case 22:return lp(i,r,a)}throw Error(n(156,r.tag))};function zp(i,r){return vd(i,r)}function YS(i,r,a,c){this.tag=i,this.key=a,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=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ei(i,r,a,c){return new YS(i,r,a,c)}function Ic(i){return i=i.prototype,!(!i||!i.isReactComponent)}function XS(i){if(typeof i=="function")return Ic(i)?1:0;if(i!=null){if(i=i.$$typeof,i===j)return 11;if(i===z)return 14}return 2}function Tn(i,r){var a=i.alternate;return a===null?(a=Ei(i.tag,r,i.key,i.mode),a.elementType=i.elementType,a.type=i.type,a.stateNode=i.stateNode,a.alternate=i,i.alternate=a):(a.pendingProps=r,a.type=i.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=i.flags&14680064,a.childLanes=i.childLanes,a.lanes=i.lanes,a.child=i.child,a.memoizedProps=i.memoizedProps,a.memoizedState=i.memoizedState,a.updateQueue=i.updateQueue,r=i.dependencies,a.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},a.sibling=i.sibling,a.index=i.index,a.ref=i.ref,a}function ca(i,r,a,c,f,g){var x=2;if(c=i,typeof i=="function")Ic(i)&&(x=1);else if(typeof i=="string")x=5;else e:switch(i){case H:return ir(a.children,f,g,r);case J:x=8,f|=8;break;case W:return i=Ei(12,a,r,f|2),i.elementType=W,i.lanes=g,i;case E:return i=Ei(13,a,r,f),i.elementType=E,i.lanes=g,i;case P:return i=Ei(19,a,r,f),i.elementType=P,i.lanes=g,i;case F:return ua(a,f,g,r);default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case X:x=10;break e;case G:x=9;break e;case j:x=11;break e;case z:x=14;break e;case R:x=16,c=null;break e}throw Error(n(130,i==null?i:typeof i,""))}return r=Ei(x,a,r,f),r.elementType=i,r.type=c,r.lanes=g,r}function ir(i,r,a,c){return i=Ei(7,i,c,r),i.lanes=a,i}function ua(i,r,a,c){return i=Ei(22,i,c,r),i.elementType=F,i.lanes=a,i.stateNode={isHidden:!1},i}function Oc(i,r,a){return i=Ei(6,i,null,r),i.lanes=a,i}function zc(i,r,a){return r=Ei(4,i.children!==null?i.children:[],i.key,r),r.lanes=a,r.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},r}function GS(i,r,a,c,f){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=dl(0),this.expirationTimes=dl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=dl(0),this.identifierPrefix=c,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function Fc(i,r,a,c,f,g,x,T,$){return i=new GS(i,r,a,T,$),r===1?(r=1,g===!0&&(r|=8)):r=0,g=Ei(3,null,null,r),i.current=g,g.stateNode=i,g.memoizedState={element:c,isDehydrated:a,cache:null,transitions:null,pendingSuspenseBoundaries:null},Zl(g),i}function QS(i,r,a){var c=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:O,key:c==null?null:""+c,children:i,containerInfo:r,implementation:a}}function Fp(i){if(!i)return xn;i=i._reactInternals;e:{if(Un(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(ni(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(n(171))}if(i.tag===1){var a=i.type;if(ni(a))return pf(i,a,r)}return r}function Hp(i,r,a,c,f,g,x,T,$){return i=Fc(a,c,!0,i,f,g,x,T,$),i.context=Fp(null),a=i.current,c=Jt(),f=Mn(a),g=an(c,f),g.callback=r??null,Rn(a,g,f),i.current.lanes=f,os(i,f,c),oi(i,c),i}function ha(i,r,a,c){var f=r.current,g=Jt(),x=Mn(f);return a=Fp(a),r.context===null?r.context=a:r.pendingContext=a,r=an(g,x),r.payload={element:i},c=c===void 0?null:c,c!==null&&(r.callback=c),i=Rn(f,r,x),i!==null&&(Oi(i,f,x,g),$o(i,f,x)),x}function da(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 $p(i,r){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<r?a:r}}function Hc(i,r){$p(i,r),(i=i.alternate)&&$p(i,r)}function JS(){return null}var Wp=typeof reportError=="function"?reportError:function(i){console.error(i)};function $c(i){this._internalRoot=i}fa.prototype.render=$c.prototype.render=function(i){var r=this._internalRoot;if(r===null)throw Error(n(409));ha(i,r,null,null)},fa.prototype.unmount=$c.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var r=i.containerInfo;Zn(function(){ha(null,i,null,null)}),r[tn]=null}};function fa(i){this._internalRoot=i}fa.prototype.unstable_scheduleHydration=function(i){if(i){var r=xd();i={blockedOn:null,target:i,priority:r};for(var a=0;a<Sn.length&&r!==0&&r<Sn[a].priority;a++);Sn.splice(a,0,i),a===0&&Rd(i)}};function Wc(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function pa(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11&&(i.nodeType!==8||i.nodeValue!==" react-mount-point-unstable "))}function Up(){}function ZS(i,r,a,c,f){if(f){if(typeof c=="function"){var g=c;c=function(){var oe=da(x);g.call(oe)}}var x=Hp(r,c,i,0,null,!1,!1,"",Up);return i._reactRootContainer=x,i[tn]=x.current,Ss(i.nodeType===8?i.parentNode:i),Zn(),x}for(;f=i.lastChild;)i.removeChild(f);if(typeof c=="function"){var T=c;c=function(){var oe=da($);T.call(oe)}}var $=Fc(i,0,!1,null,null,!1,!1,"",Up);return i._reactRootContainer=$,i[tn]=$.current,Ss(i.nodeType===8?i.parentNode:i),Zn(function(){ha(r,$,a,c)}),$}function ma(i,r,a,c,f){var g=a._reactRootContainer;if(g){var x=g;if(typeof f=="function"){var T=f;f=function(){var $=da(x);T.call($)}}ha(r,x,i,f)}else x=ZS(a,r,i,f,c);return da(x)}Cd=function(i){switch(i.tag){case 3:var r=i.stateNode;if(r.current.memoizedState.isDehydrated){var a=ss(r.pendingLanes);a!==0&&(fl(r,a|1),oi(r,yt()),(Je&6)===0&&(zr=yt()+500,En()))}break;case 13:Zn(function(){var c=on(i,1);if(c!==null){var f=Jt();Oi(c,i,1,f)}}),Hc(i,1)}},pl=function(i){if(i.tag===13){var r=on(i,134217728);if(r!==null){var a=Jt();Oi(r,i,134217728,a)}Hc(i,134217728)}},kd=function(i){if(i.tag===13){var r=Mn(i),a=on(i,r);if(a!==null){var c=Jt();Oi(a,i,r,c)}Hc(i,r)}},xd=function(){return it},Ed=function(i,r){var a=it;try{return it=i,r()}finally{it=a}},ol=function(i,r,a){switch(r){case"input":if(de(i,a),r=a.name,a.type==="radio"&&r!=null){for(a=i;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<a.length;r++){var c=a[r];if(c!==i&&c.form===i.form){var f=Mo(c);if(!f)throw Error(n(90));ie(c),de(c,f)}}}break;case"textarea":mt(i,a);break;case"select":r=a.value,r!=null&&Ce(i,!!a.multiple,r,!1)}},ud=Tc,hd=Zn;var ew={usingClientEntryPoint:!1,Events:[Cs,Er,Mo,ld,cd,Tc]},Is={findFiberByHostInstance:Kn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},tw={bundleType:Is.bundleType,version:Is.version,rendererPackageName:Is.rendererPackageName,rendererConfig:Is.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:B.ReactCurrentDispatcher,findHostInstanceByFiber:function(i){return i=md(i),i===null?null:i.stateNode},findFiberByHostInstance:Is.findFiberByHostInstance||JS,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 ga=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ga.isDisabled&&ga.supportsFiber)try{fo=ga.inject(tw),Fi=ga}catch{}}return ai.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ew,ai.createPortal=function(i,r){var a=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Wc(r))throw Error(n(200));return QS(i,r,null,a)},ai.createRoot=function(i,r){if(!Wc(i))throw Error(n(299));var a=!1,c="",f=Wp;return r!=null&&(r.unstable_strictMode===!0&&(a=!0),r.identifierPrefix!==void 0&&(c=r.identifierPrefix),r.onRecoverableError!==void 0&&(f=r.onRecoverableError)),r=Fc(i,1,!1,null,null,a,!1,c,f),i[tn]=r.current,Ss(i.nodeType===8?i.parentNode:i),new $c(r)},ai.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=md(r),i=i===null?null:i.stateNode,i},ai.flushSync=function(i){return Zn(i)},ai.hydrate=function(i,r,a){if(!pa(r))throw Error(n(200));return ma(null,i,r,!0,a)},ai.hydrateRoot=function(i,r,a){if(!Wc(i))throw Error(n(405));var c=a!=null&&a.hydratedSources||null,f=!1,g="",x=Wp;if(a!=null&&(a.unstable_strictMode===!0&&(f=!0),a.identifierPrefix!==void 0&&(g=a.identifierPrefix),a.onRecoverableError!==void 0&&(x=a.onRecoverableError)),r=Hp(r,null,i,1,a??null,f,!1,g,x),i[tn]=r.current,Ss(i),c)for(i=0;i<c.length;i++)a=c[i],f=a._getVersion,f=f(a._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[a,f]:r.mutableSourceEagerHydrationData.push(a,f);return new fa(r)},ai.render=function(i,r,a){if(!pa(r))throw Error(n(200));return ma(null,i,r,!1,a)},ai.unmountComponentAtNode=function(i){if(!pa(i))throw Error(n(40));return i._reactRootContainer?(Zn(function(){ma(null,null,i,!1,function(){i._reactRootContainer=null,i[tn]=null})}),!0):!1},ai.unstable_batchedUpdates=Tc,ai.unstable_renderSubtreeIntoContainer=function(i,r,a,c){if(!pa(a))throw Error(n(200));if(i==null||i._reactInternals===void 0)throw Error(n(38));return ma(i,r,a,!1,c)},ai.version="18.3.1-next-f1338f8080-20240426",ai}var Jp;function uw(){if(Jp)return qc.exports;Jp=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(),qc.exports=cw(),qc.exports}var Zp;function hw(){if(Zp)return va;Zp=1;var e=uw();return va.createRoot=e.createRoot,va.hydrateRoot=e.hydrateRoot,va}var dw=hw();const fw=jh(dw);function zt(e,t,n={}){return fetch(e,{...n,headers:{...n.headers||{},Authorization:`Bearer ${t}`}})}const Ia=e=>`nc_seen_${e}`;async function Ue(e,t,n={}){const s=await zt(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 l=new Error(o.error||`HTTP ${s.status}`);throw l.status=s.status,l.data=o,l}return o}const ui=e=>Array.isArray(e)&&e.length?`/api/route/${e.map(encodeURIComponent).join("/")}/_`:"/api",Kt=(e,t)=>`${ui(e)}/fleet/${t}`,fr=(e,t)=>Ue(Kt(t,"status"),e),Ah=(e,t,n)=>Ue(Kt(n,"up"),e,{method:"POST",body:t}),Oa=(e,t,n)=>Ue(Kt(n,"down"),e,{method:"POST",body:t}),Vs=(e,t,n)=>Ue(Kt(n,"restart"),e,{method:"POST",body:{cell:t}}),Bh=(e,t)=>Ue(Kt(t,"definitions"),e),pw=(e,t)=>Ue(Kt(t,"credentials/status"),e),mw=(e,t,n,s)=>Ue(Kt(s,"credentials/set"),e,{method:"POST",body:{envKey:t,value:n}}),gw=(e,t,n)=>Ue(Kt(n,"credentials/remove"),e,{method:"POST",body:{envKey:t}}),vw=(e,t,n)=>Ue(Kt(n,"define-engine"),e,{method:"POST",body:{def:t}}),_w=(e,t,n,s,o)=>Ue(Kt(o,"edit-engine"),e,{method:"POST",body:{id:t,patch:n,envChanges:s}}),yw=(e,t,n)=>Ue(Kt(n,"remove-engine"),e,{method:"POST",body:{id:t}}),Sw=(e,t,n)=>Ue(Kt(n,"define-cell"),e,{method:"POST",body:{def:t}}),ww=(e,t,n,s)=>Ue(Kt(s,"edit-cell"),e,{method:"POST",body:{id:t,patch:n}}),mv=(e,t,n=!1,s)=>Ue(Kt(s,"remove-cell"),e,{method:"POST",body:{id:t,stop:n}}),bw=(e,t,n)=>Ue(Kt(n,"import-cell"),e,{method:"POST",body:t}),Cw=(e,t,n)=>Ue(Kt(n,"restore-cells"),e,{method:"POST",body:{cells:t}}),kw=(e,t,n,s)=>Ue(Kt(s,"restore-engines"),e,{method:"POST",body:{engines:t,overwrite:!!n}}),Ih=(e,t,n)=>Ue(`${ui(n)}/sessions/${encodeURIComponent(t)}`,e,{method:"DELETE"}),gv=(e,t,n,s)=>Ue(`${ui(s)}/sessions/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{technical:!!n}}),vv=(e,t,n)=>Ue(`${ui(n)}/fs/dirs${t?`?path=${encodeURIComponent(t)}`:""}`,e),_v=e=>Ue("/api/settings",e),yv=e=>Ue("/api/nodes",e),xw=e=>Ue("/api/topology",e),Sv=(e,t)=>Ue(`${ui(t)}/sessions`,e),Oh=(e,t)=>Ue(`${ui(t)}/config`,e),em=(e,t)=>Ue(`${ui(t)}/topology`,e),wv=(e,t)=>Ue("/api/settings/config",e,{method:"POST",body:t}),Ew=e=>Ue("/api/settings/token/rotate",e,{method:"POST"}),Nw=(e,t)=>Ue("/api/settings/nodes/pair",e,{method:"POST",body:t}),tm=(e,t,n=[])=>Ue(`${ui(n)}/settings/peering/invite`,e,{method:"POST",body:t||{}}),Rw=(e,t,n)=>Ue(`/api/settings/nodes/${encodeURIComponent(t)}/label`,e,{method:"PATCH",body:{label:n}}),Pw=(e,t)=>Ue(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"DELETE"}),zh=(e,t,n)=>Ue(`/api/settings/nodes/${encodeURIComponent(t)}/${n}`,e,{method:"POST"}),Dw=(e,t,n)=>Ue(`/api/settings/nodes/${encodeURIComponent(t)}/share`,e,{method:"PATCH",body:{shared:n}}),im=(e,t,n,s=[])=>Ue(`/api/settings/nodes/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{visibility:n,selected:s}}),Lw=e=>Ue("/api/settings/service/regenerate",e,{method:"POST"}),Mw=e=>Ue("/api/settings/update/check",e,{method:"POST"}),jw=e=>Ue("/api/settings/update/apply",e,{method:"POST"}),Tw=(e,t=!0)=>Ue(`/api/asks${t?"?open=1":""}`,e),Aw=(e,t,n)=>Ue(`/api/asks/${encodeURIComponent(t)}/answer`,e,{method:"POST",body:{text:n}}),_a=(e,t=[])=>Ue(`${ui(t)}/decks`,e),nm=(e,t,n=[])=>Ue(`${ui(n)}/decks`,e,{method:"POST",body:{name:t}}),ya=(e,t,n,s,o=[])=>Ue(`${ui(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PUT",body:{layout:n,expectedRevision:s}}),Bw=(e,t,n,s,o=[])=>Ue(`${ui(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{name:n,expectedRevision:s}}),Iw=(e,t,n,s=[])=>Ue(`${ui(s)}/decks/${encodeURIComponent(t)}`,e,{method:"DELETE",body:{expectedRevision:n}}),Ow={power:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M12 3v8"}),h.jsx("path",{d:"M6.6 6.6a8 8 0 1 0 10.8 0"})]}),folder:h.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:h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:"3",y:"6",width:"18",height:"12",rx:"2"}),h.jsx("path",{d:"M7 10h.01M11 10h.01M15 10h.01M17 14h.01M7 14h7"})]}),mic:h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),h.jsx("path",{d:"M5 11a7 7 0 0 0 14 0"}),h.jsx("path",{d:"M12 18v3"})]}),enter:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M20 5v6a2 2 0 0 1-2 2H5"}),h.jsx("polyline",{points:"9 9 5 13 9 17"})]}),send:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M22 2 15 22 11 13 2 9Z"}),h.jsx("path",{d:"M22 2 11 13"})]}),trash:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M4 7h16"}),h.jsx("path",{d:"M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"}),h.jsx("path",{d:"M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"}),h.jsx("path",{d:"M10 11v6M14 11v6"})]}),x:h.jsx("path",{d:"M6 6l12 12M18 6 6 18"}),refresh:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M21 12a9 9 0 1 1-2.64-6.36L21 8"}),h.jsx("polyline",{points:"21 3 21 8 16 8"})]}),upload:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M12 16V5"}),h.jsx("polyline",{points:"8 9 12 5 16 9"}),h.jsx("path",{d:"M5 20h14"})]}),chevronLeft:h.jsx("polyline",{points:"14 6 8 12 14 18"}),attach:h.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:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),h.jsx("polyline",{points:"14 2 14 8 20 8"})]}),camera:h.jsxs(h.Fragment,{children:[h.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"}),h.jsx("circle",{cx:"12",cy:"13",r:"3.5"})]}),image:h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),h.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),h.jsx("path",{d:"M21 15l-5-5L5 21"})]}),zoomIn:h.jsxs(h.Fragment,{children:[h.jsx("circle",{cx:"11",cy:"11",r:"7"}),h.jsx("path",{d:"M21 21l-4.35-4.35"}),h.jsx("path",{d:"M8 11h6M11 8v6"})]}),zoomOut:h.jsxs(h.Fragment,{children:[h.jsx("circle",{cx:"11",cy:"11",r:"7"}),h.jsx("path",{d:"M21 21l-4.35-4.35"}),h.jsx("path",{d:"M8 11h6"})]}),gear:h.jsxs(h.Fragment,{children:[h.jsx("circle",{cx:"12",cy:"12",r:"3"}),h.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:h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),h.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})};function tt({name:e,size:t=20}){return h.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:Ow[e]||null})}const Fh="nc_pins";function bv(){try{const e=JSON.parse(localStorage.getItem(Fh));return Array.isArray(e)?e:[]}catch{return[]}}function Cv(e,t){const n=e.includes(t)?e.filter(s=>s!==t):[...e,t];try{localStorage.setItem(Fh,JSON.stringify(n))}catch{}return n}function kv(e,t,n){if(!e.includes(t)||!e.includes(n)||t===n)return e;const s=[...e],o=s.indexOf(t),l=s.indexOf(n);s.splice(o,1);const u=s.indexOf(n);s.splice(o<l?u+1:u,0,t);try{localStorage.setItem(Fh,JSON.stringify(s))}catch{}return s}function zw(e,t,n){const s=e.indexOf(t);return[s===-1?1e9:s,-(n||0)]}function Fw(e,t){return e[0]-t[0]||e[1]-t[1]}const rm=/^[a-z0-9-]{1,32}$/;function dn(e,t){const n=Array.isArray(e)?e:[];return n.length?`${n.map(encodeURIComponent).join("/")}:${t}`:String(t)}function Hw(e,t,n){const s={};for(const o of Array.isArray(t)?t:[]){const l=Array.isArray(o==null?void 0:o.route)?o.route:typeof(o==null?void 0:o.name)=="string"?[o.name]:[];if(!l.length)continue;const u=l.join("/"),d=o.status==="up"||o.tunnel&&o.tunnel.status==="up",p=o.status==="passive"||o.tunnel&&o.tunnel.status==="passive";!d&&!p&&(s[u]=e&&e[u]||n)}return s}function sm(e,t,n){return!e||!Array.isArray(e.cells)?[]:e.cells.map(s=>({...s,route:t,key:`${n}:${s.tmuxSession||s.cell}`}))}function om({nodes:e,topology:t,remote:n,down:s,fleet:o}={}){var p,m,S,w;const l=[],u=new Set,d=new Set;for(const y of Array.isArray(e)?e:[]){if(!y||typeof y.name!="string"||!rm.test(y.name)||y.direction==="inbound"&&y.shared!==!0)continue;const _=[y.name],b=y.name;u.add(b);const C=((p=y.tunnel)==null?void 0:p.status)||"unknown",k=C==="up",N={name:y.name,label:y.label||y.name,route:_,direct:!0,instanceId:y.nodeId||null,shared:y.shared===!0,tunnelStatus:C,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:y.health||null,direction:y.direction||"outbound",roles:y.roles||null,rolesKnown:y.rolesKnown===!0};if(y.nodeId&&d.add(y.nodeId),!y.nodeId&&y.paired===!1){l.push({...N,status:"needs-repair",downSince:s&&s[b]||null});continue}if(((m=y.health)==null?void 0:m.auth)==="failed"||C==="degraded"&&((S=y.health)==null?void 0:S.status)==="degraded"){l.push({...N,status:"needs-repair",downSince:s&&s[b]||null});continue}if(C==="passive"||((w=y.health)==null?void 0:w.status)==="passive"){l.push({...N,status:"passive",downSince:null});continue}if(!k){l.push({...N,status:"down",downSince:s&&s[b]||null});continue}const M=n&&(n[b]||n[y.name])||null;if(!M||M.error||!Array.isArray(M.sessions)){l.push({...N,status:"unreachable"});continue}const A=M.sessions.filter(H=>H&&typeof H.name=="string"&&H.name).map(H=>({...H,node:b,route:_,key:`${b}:${H.name}`})),B=o&&(o[b]||o[y.name]),ee=sm(B,_,b),O=new Set(ee.map(H=>H.tmuxSession).filter(Boolean));l.push({...N,status:"up",sessions:A,cells:ee,unmanaged:A.filter(H=>!O.has(H.name)),fleetAvailable:!!(B&&B.available),capabilities:B&&B.capabilities||[],engines:B&&B.engines||[],fleetProvider:B&&B.provider||null})}for(const y of Array.isArray(t)?t:[]){if(!y||!Array.isArray(y.route)||y.route.length<1||y.route.some(B=>!rm.test(B)))continue;const _=y.route.join("/");if(u.has(_)||y.instanceId&&d.has(y.instanceId))continue;y.instanceId&&d.add(y.instanceId);const b={name:y.name,label:y.label||y.route.join(" › "),route:[...y.route],direct:!1,instanceId:y.instanceId||null,shared:!0,tunnelStatus:null,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:y.health||null,lastSeen:y.lastSeen||null};if(y.stale){l.push({...b,status:"offline",downSince:s&&s[_]||y.lastSeen||null});continue}const C=n&&n[_]||null;if(!C||C.error||!Array.isArray(C.sessions)){l.push({...b,status:"unreachable",downSince:s&&s[_]||null});continue}const k=C.sessions.filter(B=>B&&typeof B.name=="string"&&B.name).map(B=>({...B,node:_,route:y.route,key:`${_}:${B.name}`})),N=o&&o[_],M=sm(N,y.route,_),A=new Set(M.map(B=>B.tmuxSession).filter(Boolean));l.push({...b,status:"up",sessions:k,cells:M,unmanaged:k.filter(B=>!A.has(B.name)),fleetAvailable:!!(N&&N.available),capabilities:N&&N.capabilities||[],engines:N&&N.engines||[],fleetProvider:N&&N.provider||null,lastSeen:y.lastSeen||null})}return l.sort((y,_)=>y.label.localeCompare(_.label))}const $w=["all","pinned","active","off","technical"],xv="nc_sidebar_views_v1",Ev="nc_sidebar_order_v1";function Nv(e){return $w.includes(e)?e:"all"}function Ww(e,t=[],n="all"){const s=Nv(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 Uw(e,t,n=[],s=[]){const o=n.indexOf(e.key),l=n.indexOf(t.key),u=o===-1?Number.MAX_SAFE_INTEGER:o,d=l===-1?Number.MAX_SAFE_INTEGER:l,p=s.indexOf(e.key),m=s.indexOf(t.key),S=p===-1?Number.MAX_SAFE_INTEGER:p,w=m===-1?Number.MAX_SAFE_INTEGER:m;return u-d||S-w||+!!t.live-+!!e.live||+!!t.fresh-+!!e.fresh||Number(t.activity||0)-Number(e.activity||0)||String(e.label||"").localeCompare(String(t.label||""))||String(e.key||"").localeCompare(String(t.key||""))}function Rv(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(Ev));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 l=[...new Set(o.filter(u=>typeof u=="string"&&u&&u.length<=256))].slice(0,128);l.length&&(n[s]=l)}return n}catch{return{}}}function Xi(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function Pv(e,t=globalThis.localStorage){try{t.setItem(Ev,JSON.stringify(e))}catch{}return e}function Dv(e,t,n,s,o=[]){if(typeof t!="string"||!t||n===s)return e;const l=[...new Set(o.filter(y=>typeof y=="string"&&y))];if(!l.includes(n)||!l.includes(s))return e;const u=Xi(e,t).filter(y=>l.includes(y)),d=[...u,...l.filter(y=>!u.includes(y))],p=d.indexOf(n),m=d.indexOf(s);d.splice(p,1);const S=d.indexOf(s),w=p<m?S+1:S;return d.splice(w,0,n),{...e,[t]:d}}function Lv(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(xv));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function za(e,t){var n,s;return{open:((n=e==null?void 0:e[t])==null?void 0:n.open)!==!1,filter:Nv((s=e==null?void 0:e[t])==null?void 0:s.filter)}}function Mv(e,t=globalThis.localStorage){try{t.setItem(xv,JSON.stringify(e))}catch{}return e}function am(e,t=""){const n=String(t||"").trim().toLocaleLowerCase();return n?[e.label,e.key,e.searchText].filter(Boolean).join(" ").toLocaleLowerCase().includes(n):!0}function fn(e=[],t=[],n="all",s=[]){return[...e].filter(o=>Ww(o,t,n)).sort((o,l)=>Uw(o,l,t,s))}const Hh=["it","en","es"];function Kw(){try{const e=typeof navigator<"u"&&navigator.language||"",t=String(e).slice(0,2).toLowerCase();return Hh.includes(t)?t:"en"}catch{return"en"}}const Da=Kw(),jv="nc_lang",zu="nc-lang";function Tv(){return typeof localStorage<"u"?localStorage:null}const Sa={it:{"update-available":"nuova versione {v} disponibile","install-version-mismatch":"installazione incompleta: frontend e server non coincidono (v{v})",reload:"ricarica","grid-empty":"trascina qui una sessione dalla sidebar, o doppio-clic per la vista singola","grid-full":"il deck può mostrare al massimo 9 sessioni",pin:"fissa in cima",reorder:"riordina","reorder-help":"trascina la maniglia; frecce su/giu da tastiera","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-degraded":"degradata: unit attiva, tmux morto","power-on":"accendi","power-off":"spegni","state-on":"accesa","state-off":"spenta",engine:"Engine",model:"Modello","model-default":"Modello predefinito del provider","model-remembered":"Ultimo modello usato con questo engine","boot-persist":"avvia al boot","remove-boot":"togli anche dal boot","power-config-in-settings":"Engine, provider, profilo, modello e permessi si modificano in Impostazioni → Flotta.","no-remote-control":"⚠ engine non-native: niente RC da app claude.ai (da qui la piloti comunque)",cancel:"annulla",name:"nome","name-invalid":"nome non valido: a-zA-Z0-9._- max 64, senza '-' iniziale",cwd:"cartella",browse:"sfoglia","fs-home":"home","fs-parent":".. su",preset:"preset","preset-2x2":"griglia 2×2","preset-columns":"colonne","preset-equalize":"equalizza",collapse:"comprimi",expand:"espandi",create:"crea","auth-prompt":"Incolla il token (stampato dal server):","remember-device":"ricorda su questo device","zoom-out":"testo più piccolo","zoom-in":"testo più grande",composer:"composer",windows:"{n} finestre","empty-files":"vuota",upload:"carica","no-sessions-short":"nessuna sessione","composer-placeholder":"scrivi o detta…",attach:"allega","attach-file":"File","attach-camera":"Fotocamera","attach-gallery":"Galleria","attach-uploading":"carico…","attach-upload-progress":"allegato {n}/{total}…","attach-uploaded":"{n} allegati caricati",voice:"voice",send:"invia","composer-send-failed":"connessione non pronta — testo conservato, riprova",close:"chiudi","lang-label":"lingua",decks:"deck","new-deck":"nuovo deck","deck-name":"nome deck","open-deck-window":"apri in una nuova finestra","detach-deck":"stacca in una nuova finestra","deck-current":"questo deck (finestra corrente)","deck-owner-unavailable":"nodo owner non condiviso o non raggiungibile","rename-deck":"rinomina deck","delete-deck":"elimina deck","delete-deck-confirm":'Eliminare il deck "{name}"?',"send-to-deck":"manda al deck…","deck-autosave":"salvataggio automatico",saving:"salvataggio…",saved:"salvato","popup-blocked":"popup bloccato: apri qui","select-drag":"trascina per selezionare","copy-manual":"seleziona e copia manualmente","toggle-sidebar":"mostra/nascondi la barra laterale",settings:"impostazioni","tab-roles":"ruoli","tab-nodes":"nodi",local:"Locale",location:"Dove","pairing-link":"link di pairing","pairing-required":"nome, alias SSH e link di pairing sono obbligatori","pairing-connect-help":"Per collegare un nodo servono: nome, Host SSH già funzionante e link/QR creato sull’altra installazione NexusCrew.","pairing-localhost-hint":"127.0.0.1 nel link è corretto: non aprirlo qui. NexusCrew usa invito e porta attraverso l’Host SSH.","scan-qr":"scansiona QR","pairing-qr-invalid":"QR di pairing non valido","invite-node":"invita un nodo","create-pairing-link":"crea link / QR","visibility-network":"tutta la rete","visibility-relay":"solo relay","visibility-selected":"nodi selezionati","hydra-simple":"locale + nodi, una sola rete","local-ready":"Questo dispositivo è pronto. Puoi usarlo da solo o collegarlo a un nodo.","local-only":"solo locale","add-node":"aggiungi nodo",connect:"collega","node-connected":"Nodo collegato. La rete verrà sincronizzata automaticamente.","tab-system":"sistema","tab-fleet":"flotta","fleet-editor-unavailable":"Editor disponibile solo con il provider fleet builtin.","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-credential-title":"API key su questo dispositivo","fleet-credential-help":"La key resta solo sul nodo selezionato, non viene mostrata, esportata o condivisa con la rete.","fleet-credential-set":"imposta key","fleet-credential-change":"cambia key","fleet-credential-forget":"dimentica","fleet-credential-saved":"Key salvata localmente.","fleet-credential-removed":"Key locale rimossa.","fleet-credential-remove-confirm":"Rimuovere la key locale {key}?","fleet-credential-source-environment":"ambiente","fleet-credential-source-local":"store locale","fleet-credential-source-compatibility":"config compatibile","fleet-credential-source-missing":"mancante","fleet-model-default":"modello predefinito (opzionale)","fleet-model-required":"modello (obbligatorio)","fleet-standard-permissions":"permessi standard","fleet-unsafe-permissions":"non sicuro · ignora approvazioni/sandbox","fleet-unsafe-warning":"Modalità non sicura esplicita: il worker può agire senza le normali approvazioni o protezioni sandbox.","fleet-provider-display":"nome visualizzato del provider","fleet-custom-provider-default":"Provider personalizzato","fleet-api-key-env":"NOME_VARIABILE_API_KEY","fleet-provider-id":"id-provider","fleet-custom-secret-help":"NexusCrew salva solo il nome della variabile d’ambiente, mai il suo valore.","fleet-model-override":"modello alternativo","fleet-ready":"pronto","fleet-not-ready":"non configurato","fleet-engines":"Engine","fleet-cells":"Celle / sessioni cloud","fleet-backup":"backup / ripristino","fleet-backup-help":"Esporta o ripristina selettivamente engine, celle e system prompt. Token, API key e segreti provider non entrano mai nel file.","fleet-backup-export":"esporta","fleet-backup-import":"importa","fleet-backup-download":"scarica backup","fleet-backup-restore":"ripristina selezionate","fleet-backup-import-help":"Scegli un backup JSON, controlla le celle e seleziona l’engine di destinazione prima del ripristino.","fleet-backup-overwrite":"sovrascrive la cella esistente","fleet-backup-new":"nuova cella","fleet-backup-engine-missing":"scegli un engine disponibile","fleet-backup-restore-unavailable":"Il nodo selezionato supporta solo l’esportazione; aggiornalo per ripristinare backup.","fleet-backup-restored":"{n} celle ripristinate","fleet-backup-confirm-overwrite":"Sovrascrivere queste celle? {cells}","fleet-backup-needs-restart":"riavvio necessario: {cells}","fleet-backup-empty":"nessuna cella da esportare","fleet-backup-select-one":"seleziona almeno una cella","fleet-backup-too-large":"backup troppo grande (massimo 1 MB)","fleet-backup-invalid-json":"il file non contiene JSON valido","fleet-backup-invalid-format":"formato o versione del backup non supportati","fleet-backup-invalid-cell":"il backup contiene una cella non valida","fleet-backup-duplicate-cell":"il backup contiene ID cella duplicati","fleet-backup-invalid-engine":"il backup contiene un engine non valido","fleet-backup-duplicate-engine":"il backup contiene ID engine duplicati","fleet-backup-confirm-engine-overwrite":"Sovrascrivere questi engine? I valori ambiente già configurati sul target restano invariati. {engines}","fleet-backup-env-names":"nomi ambiente","fleet-backup-env-values-required":"i valori ambiente vanno configurati sul dispositivo","fleet-system-prompt":"system prompt",characters:"caratteri","select-all":"seleziona tutte","select-none":"nessuna",edit:"modifica",save:"salva",label:"etichetta","command-path":"path assoluto del comando","args-lines":"argomenti, uno per riga","env-write-only":"I valori env sono write-only: vuoto mantiene il valore esistente.","fleet-new-engine":"Nuovo engine","fleet-new-cell":"Nuova cella","fleet-saved":"Definizione salvata.","fleet-restart-confirm":"Modifica salvata. Riavviare ora: {cells}?","fleet-remove-engine":'Eliminare l’engine "{id}"?',"fleet-remove-cell":'Eliminare la cella "{id}"? Se è attiva verrà prima fermata.',"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-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-private":"Privato: solo questo dispositivo può usare il collegamento all’hub.","share-node-off-desc":"Privato: resta collegato al nodo hub, ma gli altri client non possono raggiungerlo.","share-node-on-desc":"Condiviso: il nodo hub può mostrarlo e smistare celle e deck autorizzati.","peer-shared":"Nodo client condiviso nella rete Hydra","peer-private":"Nodo client privato: collegato, non pubblicato nella rete Hydra","node-connected-client":"client collegato","transport-used":"in uso","tunnel-up":"tunnel su","tunnel-down":"tunnel giù","authorized-keys-hint":"incolla questa riga in ~/.ssh/authorized_keys sull'host remoto:",copy:"copia",copied:"copiato","token-rotate":"ruota token","token-rotate-explain":"Il nuovo token NON verrà mostrato: recuperalo con `nexuscrew show token`. La sessione corrente verrà invalidata.","service-regenerate":"rigenera service","npm-auto-update":"aggiornamenti automatici da npm","npm-auto-update-help":"Controlla periodicamente latest e installa solo versioni più recenti. Mai downgrade.","npm-update-current":"installata","npm-update-latest":"npm latest","npm-update-check":"controlla ora","npm-update-install":"aggiorna ora","npm-update-restarting":"Aggiornamento avviato; NexusCrew si riaprirà dopo il riavvio del servizio.","npm-update-idle":"aggiornato","npm-update-checking":"controllo in corso","npm-update-available":"aggiornamento disponibile","npm-update-installing":"installazione in corso","npm-update-installed":"installato, riavvio in corso","npm-update-error":"controllo fallito","npm-update-unsupported":"disponibile solo con installazione npm globale","service-installed":"service installato","service-missing":"service non installato","service-active":"attivo","service-inactive":"non attivo",confirm:"conferma",add:"aggiungi",enable:"attiva","wizard-title":"benvenuto in NexusCrew","wizard-skip":"configura dopo dai settings","wizard-step-roles":"ruoli di questa installazione","wizard-step-node":"primo nodo remoto (opzionale)","wizard-done":"tutto pronto","wizard-done-desc":"setup completato — puoi cambiare tutto dai settings",next:"continua",back:"indietro",skip:"salta",finish:"fine","err-node-name":"nome non valido (a-z, 0-9, -, max 32)","err-ssh":"ssh non valido (atteso user@host o alias)","err-port":"porta non valida (1–65535)","err-ssh-port":"porta SSH non valida (1–65535)","err-node-port":"porta NexusCrew non valida (1–65535)","node-sessions":"{n} sessioni","tunnel-down-since":"tunnel giù da {t}","node-unreachable":"nodo non raggiungibile","node-passive":"client offline · stato normale","node-offline":"nodo offline","node-offline-seen":"offline · visto {t} fa","node-needs-repair":"legacy · ripeti il pairing","asks-title":"domande dalle celle","ask-reply-ph":"scrivi la risposta…","push-enable":"attiva notifiche push","push-disable":"disattiva notifiche push","push-on":"push attive su questo device","push-off":"push non attive","push-denied":"permesso notifiche negato dal browser","push-unsupported":"push non supportate in questo browser","node-display-label":"Nome (etichetta)","node-slug-hint":"routing su slug: {slug}","device-name-label":"Nome dispositivo","device-name-hint":"come ti vedono i peer (modificabile)","err-label":"etichetta non valida (max 64 char, niente a capo)","fleet-inventory":"Celle e sessioni","fleet-inventory-help":"tutte le posizioni (Locale + route Hydra)","fleet-manage-location":"Gestisci posizione","fleet-network-overview":"Panoramica rete","fleet-manage-help":"crea e configura celle nella posizione selezionata","fleet-overview-help":"stato operativo di tutte le posizioni, senza duplicare l’editor","fleet-inventory-empty":"nessuna cella o sessione","fleet-not-available":"fleet non disponibile su questa posizione",start:"avvia",stop:"ferma",restart:"riavvia",delete:"elimina","copy-manual":"copia non riuscita — seleziona e Cmd+C, o copia a mano","copy-empty":"niente selezione: trascina con Shift per selezionare","save-and-start":"salva e avvia",permissions:"Permessi","power-on-hint":"Spegni la cella; puoi anche toglierla dal boot.","launch-engine-help":"Provider, credenziali e nuovi engine si creano in Impostazioni → Flotta. Modello e permessi sono per questa cella.","launch-external-hint":"Provider esterno: engine/modello si configurano nel fleet esterno.","import-as-cell":"Importa come cella","import-help":"Riconcilia una sessione tmux esistente in una cella gestita. Scegli un engine già dichiarato: nessun engine viene inventato.","import-engine-required":"scegli un engine (obbligatorio)","test-and-connect":"testa e collega","pairing-v2-hint":"Incolla o scansiona UN solo link: precompila nome, Host SSH ed etichetta quando il link li include (v2).","invite-v2-hint":"Crea un invito monouso completo. Se sei già collegato a un hub, viene usato automaticamente; altrimenti serve solo il suo indirizzo SSH raggiungibile.","invite-network-hint":"Crea un invito per la rete a cui sei già collegato. Il nuovo dispositivo entrerà attraverso l’hub, non si collegherà direttamente a questo dispositivo.","invite-network-label":"Rete di destinazione","invite-network-via":"Hub","invite-network-route":"Un solo collegamento verso l’hub; nodi, celle e deck vengono smistati internamente.","invite-endpoint-label":"Indirizzo SSH di questo hub visto dagli altri dispositivi","invite-endpoint-auto":"Endpoint già configurato","invite-endpoint-needed":"Inserisci user@host o un alias SSH condiviso. Non è 127.0.0.1 e non è l’URL HTTP NexusCrew.","invite-ssh-hint":"Il target SSH con cui L’ALTRO dispositivo raggiunge QUESTA installazione (user@host o alias). Obbligatorio: viene incluso nel link.","invite-next-steps":"copia questo link, apri NexusCrew sull’altro dispositivo e incollalo in Impostazioni → Nodi (o scansiona il QR): al resto pensa NexusCrew","pair-card-title":"collega con un solo link","pair-card-help":"Incolla il link di pairing generato sull’altro dispositivo (o scansiona il suo QR): NexusCrew decodifica, prova la connessione SSH e collega da solo.","pair-paste-ph":"incolla qui il link di pairing","pair-paste-btn":"incolla","pair-advanced":"avanzate / modifica","pair-progress":"collegamento in corso: SSH → invito → conferma → verifica…","pair-retry":"riprova","pair-invalid-link":"questo non è un link di pairing valido","pair-invalid-hint":"serve il link completo (http://…#pair=…) generato dall’altro NexusCrew: non aprirlo, incollalo qui","pair-missing-ssh":"il link non include il target SSH (formato v1): indica in “avanzate” come questo dispositivo raggiunge l’altro via SSH — non viene mai inventato","pair-missing-name":"manca il nome del nodo: completalo in “avanzate”","pair-clipboard-denied":"lettura degli appunti non consentita: incolla manualmente nel campo","pair-clipboard-empty":"appunti vuoti: copia prima il link di pairing","pair-stage-validation":"dati non validi","pair-stage-conflict":"nome già in uso","pair-stage-ssh-start":"avvio del tunnel SSH fallito","pair-stage-ssh-ready":"peer non raggiungibile via SSH","pair-stage-join":"scambio dell’invito fallito","pair-stage-tunnel-final":"tunnel negoziato fallito","pair-stage-confirm":"conferma del pairing fallita","pair-stage-health":"verifica finale della federazione fallita","pair-stage-internal":"errore interno","pair-stage-generic":"connessione fallita","qr-no-camera":"nessuna camera disponibile su questo dispositivo: usa una foto del QR","qr-permission":"permesso camera negato: consentilo nel browser o usa una foto del QR","qr-unsupported":"scanner live non supportato qui: carica una foto del QR","qr-upload":"usa una foto"},en:{"update-available":"new version {v} available","install-version-mismatch":"incomplete installation: frontend and server do not match (v{v})",reload:"reload","grid-empty":"drag a session here from the sidebar, or double-click for single view","grid-full":"a deck can show at most 9 sessions",pin:"pin to top",reorder:"reorder","reorder-help":"drag the handle; keyboard up/down arrows","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-degraded":"degraded: unit active, tmux dead","power-on":"power on","power-off":"power off","state-on":"running","state-off":"stopped",engine:"Engine",model:"Model","model-default":"Provider default model","model-remembered":"Last model used with this engine","boot-persist":"start at boot","remove-boot":"also remove from boot","power-config-in-settings":"Edit engine, provider, profile, model and permissions in Settings → Fleet.","no-remote-control":"⚠ non-native engine: no claude.ai app RC (you can still drive it from here)",cancel:"cancel",name:"name","name-invalid":"invalid name: a-zA-Z0-9._- max 64, no leading '-'",cwd:"folder",browse:"browse","fs-home":"home","fs-parent":".. up",preset:"preset","preset-2x2":"2×2 grid","preset-columns":"columns","preset-equalize":"equalize",collapse:"collapse",expand:"expand",create:"create","auth-prompt":"Paste the token (printed by the server):","remember-device":"remember on this device","zoom-out":"smaller text","zoom-in":"bigger text",composer:"composer",windows:"{n} windows","empty-files":"empty",upload:"upload","no-sessions-short":"no sessions","composer-placeholder":"type or dictate…",attach:"attach","attach-file":"File","attach-camera":"Camera","attach-gallery":"Gallery","attach-uploading":"uploading…","attach-upload-progress":"attachment {n}/{total}…","attach-uploaded":"{n} attachments uploaded",voice:"voice",send:"send","composer-send-failed":"connection not ready — text kept, try again",close:"close","lang-label":"language",decks:"decks","new-deck":"new deck","deck-name":"deck name","open-deck-window":"open in a new window","detach-deck":"detach into a new window","deck-current":"this deck (current window)","deck-owner-unavailable":"owner node is not shared or reachable","rename-deck":"rename deck","delete-deck":"delete deck","delete-deck-confirm":'Delete deck "{name}"?',"send-to-deck":"send to deck…","deck-autosave":"autosave",saving:"saving…",saved:"saved","popup-blocked":"popup blocked: open here","select-drag":"drag to select","copy-manual":"select and copy manually","toggle-sidebar":"show/hide the sidebar",settings:"settings","tab-roles":"roles","tab-nodes":"nodes",local:"Local",location:"Location","pairing-link":"pairing link","pairing-required":"name, SSH alias and pairing link are required","pairing-connect-help":"Connecting a node requires a name, a working SSH Host, and a link/QR created by the other NexusCrew installation.","pairing-localhost-hint":"127.0.0.1 in the link is correct: do not open it here. NexusCrew carries the invite and port through the SSH Host.","scan-qr":"scan QR","pairing-qr-invalid":"invalid pairing QR","invite-node":"invite a node","create-pairing-link":"create link / QR","visibility-network":"whole network","visibility-relay":"relay only","visibility-selected":"selected nodes","hydra-simple":"local + nodes, one network","local-ready":"This device is ready. Use it alone or connect it to a node.","local-only":"local only","add-node":"add node",connect:"connect","node-connected":"Node connected. The network will synchronize automatically.","tab-system":"system","tab-fleet":"fleet","fleet-editor-unavailable":"The editor is available only with the builtin fleet provider.","fleet-managed":"managed by NexusCrew","fleet-custom":"custom command","fleet-managed-help":"Client, provider and launch are managed internally; secrets are never displayed.","fleet-credential-title":"API key on this device","fleet-credential-help":"The key stays only on the selected node and is never displayed, exported or shared with the network.","fleet-credential-set":"set key","fleet-credential-change":"change key","fleet-credential-forget":"forget","fleet-credential-saved":"Key saved locally.","fleet-credential-removed":"Local key removed.","fleet-credential-remove-confirm":"Remove the local {key} key?","fleet-credential-source-environment":"environment","fleet-credential-source-local":"local store","fleet-credential-source-compatibility":"compatible config","fleet-credential-source-missing":"missing","fleet-model-default":"default model (optional)","fleet-model-required":"model (required)","fleet-standard-permissions":"standard permissions","fleet-unsafe-permissions":"unsafe · bypass approvals/sandbox","fleet-unsafe-warning":"Explicit unsafe mode: the worker can act without normal approval or sandbox gates.","fleet-provider-display":"provider display name","fleet-custom-provider-default":"Custom provider","fleet-api-key-env":"API_KEY_ENV_NAME","fleet-provider-id":"provider-id","fleet-custom-secret-help":"NexusCrew stores only the environment-variable name, never its value.","fleet-model-override":"model override","fleet-ready":"ready","fleet-not-ready":"not configured","fleet-engines":"Engines","fleet-cells":"Cells / cloud sessions","fleet-backup":"backup / restore","fleet-backup-help":"Selectively export or restore engines, cells, and system prompts. Tokens, API keys, and provider secrets never enter the file.","fleet-backup-export":"export","fleet-backup-import":"import","fleet-backup-download":"download backup","fleet-backup-restore":"restore selected","fleet-backup-import-help":"Choose a JSON backup, review the cells and select a destination engine before restoring.","fleet-backup-overwrite":"overwrites existing cell","fleet-backup-new":"new cell","fleet-backup-engine-missing":"choose an available engine","fleet-backup-restore-unavailable":"The selected node supports export only; update it to restore backups.","fleet-backup-restored":"{n} cells restored","fleet-backup-confirm-overwrite":"Overwrite these cells? {cells}","fleet-backup-needs-restart":"restart required: {cells}","fleet-backup-empty":"no cells to export","fleet-backup-select-one":"select at least one cell","fleet-backup-too-large":"backup is too large (1 MB maximum)","fleet-backup-invalid-json":"the file does not contain valid JSON","fleet-backup-invalid-format":"unsupported backup format or version","fleet-backup-invalid-cell":"the backup contains an invalid cell","fleet-backup-duplicate-cell":"the backup contains duplicate cell IDs","fleet-backup-invalid-engine":"the backup contains an invalid engine","fleet-backup-duplicate-engine":"the backup contains duplicate engine IDs","fleet-backup-confirm-engine-overwrite":"Overwrite these engines? Environment values already configured on the target stay unchanged. {engines}","fleet-backup-env-names":"environment names","fleet-backup-env-values-required":"environment values must be configured on this device","fleet-system-prompt":"system prompt",characters:"characters","select-all":"select all","select-none":"select none",edit:"edit",save:"save",label:"label","command-path":"absolute command path","args-lines":"arguments, one per line","env-write-only":"Environment values are write-only: blank keeps the existing value.","fleet-new-engine":"New engine","fleet-new-cell":"New cell","fleet-saved":"Definition saved.","fleet-restart-confirm":"Change saved. Restart now: {cells}?","fleet-remove-engine":'Delete engine "{id}"?',"fleet-remove-cell":'Delete cell "{id}"? If active it will be stopped first.',"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-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-private":"Private: only this device can use its hub connection.","share-node-off-desc":"Private: it stays connected to the hub, but other clients cannot reach it.","share-node-on-desc":"Shared: the hub may advertise it and route authorized cells and decks.","peer-shared":"Client node shared on the Hydra network","peer-private":"Private client node: connected, not published on Hydra","node-connected-client":"connected client","transport-used":"in use","tunnel-up":"tunnel up","tunnel-down":"tunnel down","authorized-keys-hint":"paste this line into ~/.ssh/authorized_keys on the remote host:",copy:"copy",copied:"copied","token-rotate":"rotate token","token-rotate-explain":"The new token will NOT be shown: retrieve it with `nexuscrew show token`. The current session will be invalidated.","service-regenerate":"regenerate service","npm-auto-update":"automatic updates from npm","npm-auto-update-help":"Periodically checks latest and installs only newer versions. Never downgrades.","npm-update-current":"installed","npm-update-latest":"npm latest","npm-update-check":"check now","npm-update-install":"update now","npm-update-restarting":"Update started; NexusCrew will return after the service restarts.","npm-update-idle":"up to date","npm-update-checking":"checking","npm-update-available":"update available","npm-update-installing":"installing","npm-update-installed":"installed, restarting","npm-update-error":"check failed","npm-update-unsupported":"available only for global npm installations","service-installed":"service installed","service-missing":"service not installed","service-active":"active","service-inactive":"not active",confirm:"confirm",add:"add",enable:"enable","wizard-title":"welcome to NexusCrew","wizard-skip":"configure later from settings","wizard-step-roles":"roles of this install","wizard-step-node":"first remote node (optional)","wizard-done":"all set","wizard-done-desc":"setup complete — you can change everything from settings",next:"continue",back:"back",skip:"skip",finish:"finish","err-node-name":"invalid name (a-z, 0-9, -, max 32)","err-ssh":"invalid ssh (expected user@host or alias)","err-port":"invalid port (1–65535)","err-ssh-port":"invalid SSH port (1–65535)","err-node-port":"invalid NexusCrew port (1–65535)","node-sessions":"{n} sessions","tunnel-down-since":"tunnel down for {t}","node-unreachable":"node unreachable","node-passive":"client offline · expected","node-offline":"node offline","node-offline-seen":"offline · seen {t} ago","node-needs-repair":"legacy · pair again","asks-title":"questions from the cells","ask-reply-ph":"type your answer…","push-enable":"enable push notifications","push-disable":"disable push notifications","push-on":"push active on this device","push-off":"push not active","push-denied":"notification permission denied by the browser","push-unsupported":"push not supported in this browser","node-display-label":"Name (label)","node-slug-hint":"routing on slug: {slug}","device-name-label":"Device name","device-name-hint":"how peers see you (editable)","err-label":"invalid label (max 64 chars, no line breaks)","fleet-inventory":"Cells and sessions","fleet-inventory-help":"all positions (Local + Hydra routes)","fleet-manage-location":"Manage location","fleet-network-overview":"Network overview","fleet-manage-help":"create and configure cells at the selected location","fleet-overview-help":"operational state of every location, separate from the editor","fleet-inventory-empty":"no cells or sessions","fleet-not-available":"fleet not available on this position",start:"start",stop:"stop",restart:"restart",delete:"delete","copy-manual":"copy failed — select and press Cmd+C, or copy manually","copy-empty":"nothing selected: drag with Shift to select","save-and-start":"save and start",permissions:"Permissions","power-on-hint":"Stop the cell; you can also remove it from boot.","launch-engine-help":"Providers, credentials and new engines are created in Settings → Fleet. Model and permissions are per cell.","launch-external-hint":"External provider: engine/model are configured in the external fleet.","import-as-cell":"Import as cell","import-help":"Reconcile an existing tmux session into a managed cell. Pick an already-declared engine: no engine is invented.","import-engine-required":"pick an engine (required)","test-and-connect":"test and connect","pairing-v2-hint":"Paste or scan ONE link: it prefills name, SSH host and label when the link carries them (v2).","invite-v2-hint":"Create one complete one-time invitation. If this device already joined a hub, that hub is used automatically; otherwise only its reachable SSH address is required.","invite-network-hint":"Create an invitation for the network you already joined. The new device enters through the hub instead of connecting directly to this device.","invite-network-label":"Destination network","invite-network-via":"Hub","invite-network-route":"One connection to the hub; nodes, cells and decks are routed internally.","invite-endpoint-label":"This hub’s SSH address as seen by other devices","invite-endpoint-auto":"Configured endpoint","invite-endpoint-needed":"Enter user@host or a shared SSH alias. This is not 127.0.0.1 and not the NexusCrew HTTP URL.","invite-ssh-hint":"The SSH target the OTHER device uses to reach THIS installation (user@host or alias). Required: it is included in the link.","invite-next-steps":"copy this link, open NexusCrew on the other device and paste it in Settings → Nodes (or scan the QR): NexusCrew does the rest","pair-card-title":"connect with one link","pair-card-help":"Paste the pairing link generated on the other device (or scan its QR): NexusCrew decodes it, tests the SSH connection and connects on its own.","pair-paste-ph":"paste the pairing link here","pair-paste-btn":"paste","pair-advanced":"advanced / edit","pair-progress":"connecting: SSH → invite → confirm → verify…","pair-retry":"retry","pair-invalid-link":"this is not a valid pairing link","pair-invalid-hint":"you need the full link (http://…#pair=…) generated by the other NexusCrew: don’t open it, paste it here","pair-missing-ssh":"the link carries no SSH target (v1 format): set in “advanced” how this device reaches the other one over SSH — it is never invented","pair-missing-name":"the node name is missing: fill it in “advanced”","pair-clipboard-denied":"clipboard read not allowed: paste manually into the field","pair-clipboard-empty":"clipboard is empty: copy the pairing link first","pair-stage-validation":"invalid data","pair-stage-conflict":"name already in use","pair-stage-ssh-start":"SSH tunnel start failed","pair-stage-ssh-ready":"peer unreachable over SSH","pair-stage-join":"invite exchange failed","pair-stage-tunnel-final":"negotiated tunnel failed","pair-stage-confirm":"pairing confirmation failed","pair-stage-health":"final federation check failed","pair-stage-internal":"internal error","pair-stage-generic":"connection failed","qr-no-camera":"no camera available on this device: use a photo of the QR","qr-permission":"camera permission denied: allow it in the browser or use a photo of the QR","qr-unsupported":"live scanner not supported here: upload a photo of the QR","qr-upload":"use a photo"},es:{"update-available":"nueva versión {v} disponible","install-version-mismatch":"instalación incompleta: frontend y servidor no coinciden (v{v})",reload:"recargar","grid-empty":"arrastra aquí una sesión desde la barra lateral, o doble clic para vista única","grid-full":"un deck puede mostrar como máximo 9 sesiones",pin:"fijar arriba",reorder:"reordenar","reorder-help":"arrastra el control; flechas arriba/abajo","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-degraded":"degradada: unit activa, tmux muerto","power-on":"encender","power-off":"apagar","state-on":"encendida","state-off":"apagada",engine:"Motor",model:"Modelo","model-default":"Modelo predeterminado del proveedor","model-remembered":"Último modelo usado con este motor","boot-persist":"iniciar en el boot","remove-boot":"quitar también del boot","power-config-in-settings":"Modifica motor, proveedor, perfil, modelo y permisos en Ajustes → Flota.","no-remote-control":"⚠ motor no nativo: sin RC de la app claude.ai (aquí puedes pilotarla igual)",cancel:"cancelar",name:"nombre","name-invalid":"nombre inválido: a-zA-Z0-9._- máx 64, sin '-' inicial",cwd:"carpeta",browse:"explorar","fs-home":"home","fs-parent":".. arriba",preset:"preset","preset-2x2":"cuadrícula 2×2","preset-columns":"columnas","preset-equalize":"igualar",collapse:"contraer",expand:"expandir",create:"crear","auth-prompt":"Pega el token (impreso por el servidor):","remember-device":"recordar en este dispositivo","zoom-out":"texto más pequeño","zoom-in":"texto más grande",composer:"composer",windows:"{n} ventanas","empty-files":"vacía",upload:"subir","no-sessions-short":"sin sesiones","composer-placeholder":"escribe o dicta…",attach:"adjuntar","attach-file":"Archivo","attach-camera":"Cámara","attach-gallery":"Galería","attach-uploading":"subiendo…","attach-upload-progress":"adjunto {n}/{total}…","attach-uploaded":"{n} adjuntos subidos",voice:"voz",send:"enviar","composer-send-failed":"conexión no disponible — texto conservado, inténtalo de nuevo",close:"cerrar","lang-label":"idioma",decks:"decks","new-deck":"nuevo deck","deck-name":"nombre del deck","open-deck-window":"abrir en una ventana nueva","detach-deck":"separar en una ventana nueva","deck-current":"este deck (ventana actual)","deck-owner-unavailable":"el nodo propietario no está compartido o accesible","rename-deck":"renombrar deck","delete-deck":"eliminar deck","delete-deck-confirm":"¿Eliminar el deck «{name}»?","send-to-deck":"enviar al deck…","deck-autosave":"guardado automático",saving:"guardando…",saved:"guardado","popup-blocked":"ventana bloqueada: abrir aquí","select-drag":"arrastra para seleccionar","copy-manual":"selecciona y copia manualmente","toggle-sidebar":"mostrar/ocultar la barra lateral",settings:"ajustes","tab-roles":"roles","tab-nodes":"nodos",local:"Local",location:"Ubicación","pairing-link":"enlace de emparejamiento","pairing-required":"nombre, alias SSH y enlace son obligatorios","pairing-connect-help":"Para conectar un nodo necesitas un nombre, un Host SSH funcional y el enlace/QR creado por la otra instalación NexusCrew.","pairing-localhost-hint":"127.0.0.1 en el enlace es correcto: no lo abras aquí. NexusCrew usa la invitación y el puerto mediante el Host SSH.","scan-qr":"escanear QR","pairing-qr-invalid":"QR de emparejamiento no válido","invite-node":"invitar un nodo","create-pairing-link":"crear enlace / QR","visibility-network":"toda la red","visibility-relay":"solo relay","visibility-selected":"nodos seleccionados","hydra-simple":"local + nodos, una red","local-ready":"Este dispositivo está listo. Úsalo solo o conéctalo a un nodo.","local-only":"solo local","add-node":"añadir nodo",connect:"conectar","node-connected":"Nodo conectado. La red se sincronizará automáticamente.","tab-system":"sistema","tab-fleet":"flota","fleet-editor-unavailable":"El editor solo está disponible con el proveedor builtin.","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-credential-title":"Clave API en este dispositivo","fleet-credential-help":"La clave permanece solo en el nodo seleccionado y nunca se muestra, exporta ni comparte con la red.","fleet-credential-set":"poner clave","fleet-credential-change":"cambiar clave","fleet-credential-forget":"olvidar","fleet-credential-saved":"Clave guardada localmente.","fleet-credential-removed":"Clave local eliminada.","fleet-credential-remove-confirm":"¿Eliminar la clave local {key}?","fleet-credential-source-environment":"entorno","fleet-credential-source-local":"almacén local","fleet-credential-source-compatibility":"config compatible","fleet-credential-source-missing":"ausente","fleet-model-default":"modelo predeterminado (opcional)","fleet-model-required":"modelo (obligatorio)","fleet-standard-permissions":"permisos estándar","fleet-unsafe-permissions":"inseguro · omitir aprobaciones/sandbox","fleet-unsafe-warning":"Modo inseguro explícito: el worker puede actuar sin las aprobaciones normales ni las protecciones del sandbox.","fleet-provider-display":"nombre visible del proveedor","fleet-custom-provider-default":"Proveedor personalizado","fleet-api-key-env":"NOMBRE_VARIABLE_API_KEY","fleet-provider-id":"id-proveedor","fleet-custom-secret-help":"NexusCrew guarda solo el nombre de la variable de entorno, nunca su valor.","fleet-model-override":"modelo alternativo","fleet-ready":"listo","fleet-not-ready":"no configurado","fleet-engines":"Motores","fleet-cells":"Celdas / sesiones cloud","fleet-backup":"copia / restauración","fleet-backup-help":"Exporta o restaura selectivamente motores, celdas y system prompts. Tokens, claves API y secretos del proveedor nunca entran en el archivo.","fleet-backup-export":"exportar","fleet-backup-import":"importar","fleet-backup-download":"descargar copia","fleet-backup-restore":"restaurar seleccionadas","fleet-backup-import-help":"Elige una copia JSON, revisa las celdas y selecciona un motor de destino antes de restaurar.","fleet-backup-overwrite":"sobrescribe la celda existente","fleet-backup-new":"celda nueva","fleet-backup-engine-missing":"elige un motor disponible","fleet-backup-restore-unavailable":"El nodo seleccionado solo admite exportación; actualízalo para restaurar copias.","fleet-backup-restored":"{n} celdas restauradas","fleet-backup-confirm-overwrite":"¿Sobrescribir estas celdas? {cells}","fleet-backup-needs-restart":"reinicio necesario: {cells}","fleet-backup-empty":"no hay celdas para exportar","fleet-backup-select-one":"selecciona al menos una celda","fleet-backup-too-large":"copia demasiado grande (máximo 1 MB)","fleet-backup-invalid-json":"el archivo no contiene JSON válido","fleet-backup-invalid-format":"formato o versión de copia no compatible","fleet-backup-invalid-cell":"la copia contiene una celda no válida","fleet-backup-duplicate-cell":"la copia contiene IDs de celda duplicados","fleet-backup-invalid-engine":"la copia contiene un motor no válido","fleet-backup-duplicate-engine":"la copia contiene IDs de motor duplicados","fleet-backup-confirm-engine-overwrite":"¿Sobrescribir estos motores? Los valores de entorno ya configurados en el destino no cambian. {engines}","fleet-backup-env-names":"nombres de entorno","fleet-backup-env-values-required":"los valores de entorno deben configurarse en este dispositivo","fleet-system-prompt":"system prompt",characters:"caracteres","select-all":"seleccionar todas","select-none":"ninguna",edit:"editar",save:"guardar",label:"etiqueta","command-path":"ruta absoluta del comando","args-lines":"argumentos, uno por línea","env-write-only":"Los valores env son de solo escritura: vacío conserva el valor existente.","fleet-new-engine":"Nuevo motor","fleet-new-cell":"Nueva celda","fleet-saved":"Definición guardada.","fleet-restart-confirm":"Cambio guardado. ¿Reiniciar ahora: {cells}?","fleet-remove-engine":'¿Eliminar el motor "{id}"?',"fleet-remove-cell":'¿Eliminar la celda "{id}"? Si está activa se detendrá primero.',"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-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-private":"Privado: solo este dispositivo puede usar la conexión al hub.","share-node-off-desc":"Privado: sigue conectado al hub, pero otros clientes no pueden alcanzarlo.","share-node-on-desc":"Compartido: el hub puede anunciarlo y enrutar celdas y decks autorizados.","peer-shared":"Nodo cliente compartido en la red Hydra","peer-private":"Nodo cliente privado: conectado, no publicado en Hydra","node-connected-client":"cliente conectado","transport-used":"en uso","tunnel-up":"túnel activo","tunnel-down":"túnel caído","authorized-keys-hint":"pega esta línea en ~/.ssh/authorized_keys del host remoto:",copy:"copiar",copied:"copiado","token-rotate":"rotar token","token-rotate-explain":"El nuevo token NO se mostrará: recupéralo con `nexuscrew show token`. La sesión actual quedará invalidada.","service-regenerate":"regenerar service","npm-auto-update":"actualizaciones automáticas desde npm","npm-auto-update-help":"Comprueba latest periódicamente e instala solo versiones más recientes. Nunca baja de versión.","npm-update-current":"instalada","npm-update-latest":"npm latest","npm-update-check":"comprobar ahora","npm-update-install":"actualizar ahora","npm-update-restarting":"Actualización iniciada; NexusCrew volverá después de reiniciar el servicio.","npm-update-idle":"actualizado","npm-update-checking":"comprobando","npm-update-available":"actualización disponible","npm-update-installing":"instalando","npm-update-installed":"instalada, reiniciando","npm-update-error":"comprobación fallida","npm-update-unsupported":"disponible solo con instalación npm global","service-installed":"service instalado","service-missing":"service no instalado","service-active":"activo","service-inactive":"no activo",confirm:"confirmar",add:"añadir",enable:"activar","wizard-title":"bienvenido a NexusCrew","wizard-skip":"configura después desde ajustes","wizard-step-roles":"roles de esta instalación","wizard-step-node":"primer nodo remoto (opcional)","wizard-done":"todo listo","wizard-done-desc":"configuración completa — puedes cambiarlo todo desde ajustes",next:"continuar",back:"atrás",skip:"omitir",finish:"terminar","err-node-name":"nombre inválido (a-z, 0-9, -, máx 32)","err-ssh":"ssh inválido (se espera user@host o alias)","err-port":"puerto inválido (1–65535)","err-ssh-port":"puerto SSH inválido (1–65535)","err-node-port":"puerto NexusCrew inválido (1–65535)","node-sessions":"{n} sesiones","tunnel-down-since":"túnel caído desde hace {t}","node-unreachable":"nodo inalcanzable","node-passive":"cliente desconectado · estado normal","node-offline":"nodo desconectado","node-offline-seen":"sin conexión · visto hace {t}","node-needs-repair":"legacy · vuelve a enlazar","asks-title":"preguntas de las celdas","ask-reply-ph":"escribe la respuesta…","push-enable":"activar notificaciones push","push-disable":"desactivar notificaciones push","push-on":"push activas en este dispositivo","push-off":"push no activas","push-denied":"permiso de notificaciones denegado por el navegador","push-unsupported":"push no soportadas en este navegador","node-display-label":"Nombre (etiqueta)","node-slug-hint":"enrutado por slug: {slug}","device-name-label":"Nombre del dispositivo","device-name-hint":"cómo te ven los pares (editable)","err-label":"etiqueta no válida (máx 64 caracteres, sin saltos de línea)","fleet-inventory":"Celdas y sesiones","fleet-inventory-help":"todas las posiciones (Local + rutas Hydra)","fleet-manage-location":"Gestionar ubicación","fleet-network-overview":"Vista de red","fleet-manage-help":"crea y configura celdas en la ubicación seleccionada","fleet-overview-help":"estado operativo de todas las ubicaciones, separado del editor","fleet-inventory-empty":"sin celdas ni sesiones","fleet-not-available":"fleet no disponible en esta posición",start:"iniciar",stop:"detener",restart:"reiniciar",delete:"eliminar","copy-manual":"copia fallida — selecciona y pulsa Cmd+C, o copia a mano","copy-empty":"nada seleccionado: arrastra con Shift para seleccionar","save-and-start":"guardar e iniciar",permissions:"Permisos","power-on-hint":"Detén la celda; también puedes quitarla del boot.","launch-engine-help":"Proveedores, credenciales y nuevos motores se crean en Ajustes → Flota. Modelo y permisos son por celda.","launch-external-hint":"Proveedor externo: motor/modelo se configuran en el fleet externo.","import-as-cell":"Importar como celda","import-help":"Reconcilia una sesión tmux existente en una celda gestionada. Elige un motor ya declarado: no se inventa ninguno.","import-engine-required":"elige un motor (obligatorio)","test-and-connect":"probar y conectar","pairing-v2-hint":"Pega o escanea UN solo enlace: rellena nombre, Host SSH y etiqueta cuando los incluye (v2).","invite-v2-hint":"Crea una invitación completa de un solo uso. Si este dispositivo ya está unido a un hub, se usa automáticamente; si no, solo hace falta su dirección SSH alcanzable.","invite-network-hint":"Crea una invitación para la red a la que ya estás conectado. El nuevo dispositivo entra por el hub y no se conecta directamente a este dispositivo.","invite-network-label":"Red de destino","invite-network-via":"Hub","invite-network-route":"Una sola conexión al hub; nodos, celdas y decks se enrutan internamente.","invite-endpoint-label":"Dirección SSH de este hub vista por los otros dispositivos","invite-endpoint-auto":"Endpoint ya configurado","invite-endpoint-needed":"Introduce usuario@host o un alias SSH compartido. No es 127.0.0.1 ni la URL HTTP de NexusCrew.","invite-ssh-hint":"El destino SSH con el que el OTRO dispositivo alcanza ESTA instalación (usuario@host o alias). Obligatorio: se incluye en el enlace.","invite-next-steps":"copia este enlace, abre NexusCrew en el otro dispositivo y pégalo en Ajustes → Nodos (o escanea el QR): NexusCrew hace el resto","pair-card-title":"conectar con un solo enlace","pair-card-help":"Pega el enlace de emparejamiento generado en el otro dispositivo (o escanea su QR): NexusCrew lo decodifica, prueba la conexión SSH y conecta solo.","pair-paste-ph":"pega aquí el enlace de emparejamiento","pair-paste-btn":"pegar","pair-advanced":"avanzado / editar","pair-progress":"conectando: SSH → invitación → confirmación → verificación…","pair-retry":"reintentar","pair-invalid-link":"esto no es un enlace de emparejamiento válido","pair-invalid-hint":"se necesita el enlace completo (http://…#pair=…) generado por el otro NexusCrew: no lo abras, pégalo aquí","pair-missing-ssh":"el enlace no incluye el destino SSH (formato v1): indica en “avanzado” cómo este dispositivo alcanza al otro por SSH — nunca se inventa","pair-missing-name":"falta el nombre del nodo: complétalo en “avanzado”","pair-clipboard-denied":"lectura del portapapeles no permitida: pega manualmente en el campo","pair-clipboard-empty":"portapapeles vacío: copia primero el enlace","pair-stage-validation":"datos no válidos","pair-stage-conflict":"nombre ya en uso","pair-stage-ssh-start":"fallo al iniciar el túnel SSH","pair-stage-ssh-ready":"peer inaccesible por SSH","pair-stage-join":"intercambio de invitación fallido","pair-stage-tunnel-final":"túnel negociado fallido","pair-stage-confirm":"confirmación de emparejamiento fallida","pair-stage-health":"verificación final de la federación fallida","pair-stage-internal":"error interno","pair-stage-generic":"conexión fallida","qr-no-camera":"no hay cámara disponible en este dispositivo: usa una foto del QR","qr-permission":"permiso de cámara denegado: permítelo en el navegador o usa una foto del QR","qr-unsupported":"escáner en vivo no soportado aquí: sube una foto del QR","qr-upload":"usar una foto"}};function Fu(){const e=Tv(),t=e?e.getItem(jv):null;return Hh.includes(t)?t:Da}function qw(e){const t=Tv();if(t)try{t.setItem(jv,e)}catch{}typeof window<"u"&&window.dispatchEvent(new Event(zu))}function v(e){const t=Fu(),n=Sa[t]||Sa[Da];return Object.prototype.hasOwnProperty.call(n,e)?n[e]:Object.prototype.hasOwnProperty.call(Sa[Da],e)?Sa[Da][e]:e}function Vw(e){return typeof window>"u"?()=>{}:(window.addEventListener(zu,e),()=>window.removeEventListener(zu,e))}const Av=Hh;function Si(){return[L.useSyncExternalStore(Vw,Fu,Fu),qw]}function Fa({cell:e,token:t,route:n=[],onConfirm:s,onClose:o}){var z,R;Si();const l=!!(e&&e.active),u=Array.isArray(n)?n.join("/"):"",[d,p]=L.useState([]),[m,S]=L.useState(!1);L.useEffect(()=>{let F=!0;return(async()=>{if(t)try{const I=await fr(t,u?u.split("/"):[]);if(!F)return;if(S(I.provider==="builtin"&&(I.capabilities||[]).includes("edit")),I.provider==="builtin"&&(I.capabilities||[]).includes("definitions")){const re=await Bh(t,u?u.split("/"):[]);if(!F)return;const q=new Map((I.engines||[]).map(D=>[D.id,D]));p((re.engines||[]).map(D=>{var U,Q,ae,se,le,pe,ce;return{id:D.id,label:D.label||D.id,client:((U=D.managed)==null?void 0:U.client)||"",models:[...new Set([...((Q=q.get(D.id))==null?void 0:Q.models)||[],...((ae=D.managedInfo)==null?void 0:ae.models)||[]])].filter(Boolean),defaultModel:((se=D.managed)==null?void 0:se.model)||((le=D.managedInfo)==null?void 0:le.defaultModel)||"",policyDefault:((pe=D.managed)==null?void 0:pe.permissionPolicy)||((ce=D.managed)!=null&&ce.client&&D.managed.client==="claude"?"unsafe":"standard")}}))}}catch{}})(),()=>{F=!1}},[t,u]);const w=(e==null?void 0:e.engine)||((z=d[0])==null?void 0:z.id)||"",y=F=>(e==null?void 0:e.models)&&e.models[F]||"",_=F=>{const I=(e==null?void 0:e.permissionPolicies)&&e.permissionPolicies[F];if(I==="standard"||I==="unsafe")return I;const re=d.find(q=>q.id===F);return re?re.policyDefault:"standard"},[b,C]=L.useState(w),[k,N]=L.useState((e==null?void 0:e.model)||""),M=(e==null?void 0:e.permissionPolicy)==="standard"||(e==null?void 0:e.permissionPolicy)==="unsafe"?e.permissionPolicy:((R=e==null?void 0:e.permissionPolicies)==null?void 0:R[e==null?void 0:e.engine])||"",[A,B]=L.useState(M),[ee,O]=L.useState((e==null?void 0:e.boot)??!0),[H,J]=L.useState(!1),[W,X]=L.useState(null);L.useEffect(()=>{d.length&&(C(F=>F||w),N(F=>F||y((e==null?void 0:e.engine)||w)||""),B(F=>F==="standard"||F==="unsafe"?F:_((e==null?void 0:e.engine)||w)))},[d.length]);const G=L.useMemo(()=>d.find(F=>F.id===b)||null,[d,b]),j=!!(G&&["claude","codex","codex-vl"].includes(G.client));function E(F){C(F);const I=d.find(re=>re.id===F);N(y(F)||(I==null?void 0:I.defaultModel)||""),B(_(F))}async function P(F){F.preventDefault(),J(!0),X(null);try{if(l)await s({action:"down",boot:ee});else{const I=A==="standard"||A==="unsafe"?A:(G==null?void 0:G.policyDefault)||"standard";await s({action:"up",...m?{engine:b,model:k||"",...j?{permissionPolicy:I}:(G==null?void 0:G.client)==="pi"?{permissionPolicy:"standard"}:{}}:{},boot:ee})}o()}catch(I){X(String(I&&I.message||I)),J(!1)}}return h.jsx("div",{className:"nc-sheet-overlay nc-launch-overlay",onClick:o,children:h.jsxs("form",{className:"nc-sheet nc-power-sheet nc-launch-sheet",onClick:F=>F.stopPropagation(),onSubmit:P,children:[h.jsxs("div",{className:"nc-sheet-head",children:[h.jsx("b",{children:e==null?void 0:e.cell}),h.jsx("span",{className:"nc-sheet-state",children:v(l?"state-on":"state-off")})]}),l?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"nc-power-config",children:[h.jsx("span",{children:v("engine")}),h.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&h.jsxs("small",{children:[v("model"),": ",e.model]}),h.jsx("small",{children:v("power-on-hint")})]}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:ee,onChange:F=>O(F.target.checked)}),v("remove-boot")]})]}):h.jsxs(h.Fragment,{children:[m&&d.length>0?h.jsxs("div",{className:"nc-launch-fields",children:[h.jsxs("label",{className:"nc-field",children:[v("engine"),h.jsx("select",{value:b,onChange:F=>E(F.target.value),children:d.map(F=>h.jsx("option",{value:F.id,children:F.label},F.id))})]}),h.jsxs("label",{className:"nc-field",children:[v("model"),h.jsx("input",{value:k,list:"nc-launch-models",placeholder:v("model-default"),onChange:F=>N(F.target.value)}),h.jsx("datalist",{id:"nc-launch-models",children:((G==null?void 0:G.models)||[]).map(F=>h.jsx("option",{value:F},F))})]}),j?h.jsxs("label",{className:"nc-field",children:[v("permissions"),h.jsxs("select",{value:A,onChange:F=>B(F.target.value),children:[h.jsx("option",{value:"standard",children:v("fleet-standard-permissions")}),h.jsx("option",{value:"unsafe",children:v("fleet-unsafe-permissions")})]})]}):h.jsx("small",{className:"nc-note",children:v("fleet-standard-permissions")}),j&&A==="unsafe"&&h.jsx("small",{className:"nc-err",children:v("fleet-unsafe-warning")}),h.jsx("small",{className:"nc-note",children:v("launch-engine-help")})]}):h.jsxs("div",{className:"nc-power-config",children:[h.jsx("span",{children:v("engine")}),h.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&h.jsxs("small",{children:[v("model"),": ",e.model]}),h.jsx("small",{children:v("launch-external-hint")})]}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:ee,onChange:F=>O(F.target.checked)}),v("boot-persist")]})]}),W&&h.jsx("div",{className:"nc-err",children:W}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:o,disabled:H,children:v("cancel")}),h.jsx("button",{type:"submit",className:"nc-btn primary",disabled:H,children:v(l?"power-off":"save-and-start")})]})]})})}const Yw=4e3;function $h(e,t=!0){const[n,s]=L.useState([]),o=L.useRef({});return L.useEffect(()=>{if(!t||!e){s([]);return}let l=!0;async function u(){var C;let p=[],m=[];if(await Promise.all([yv(e).then(k=>{p=Array.isArray(k.nodes)?k.nodes:[]}).catch(()=>{}),xw(e).then(k=>{m=Array.isArray(k.nodes)?k.nodes:[]}).catch(()=>{})]),!l)return;const S={},w={},y=new Set(p.map(k=>k.name)),_=[];for(const k of p)((C=k.tunnel)==null?void 0:C.status)==="up"&&(k.nodeId||k.paired!==!1)&&(k.direction!=="inbound"||k.shared===!0)&&_.push([k.name]);for(const k of m)!k.stale&&Array.isArray(k.route)&&!(k.route.length===1&&y.has(k.route[0]))&&_.push(k.route);if(await Promise.all(_.map(async k=>{const N=k.join("/");try{S[N]=await Sv(e,k)}catch{S[N]={error:"unreachable"}}try{w[N]=await fr(e,k)}catch{w[N]={available:!1}}})),!l)return;const b=om({nodes:p,topology:m,remote:S,fleet:w,down:o.current});o.current=Hw(o.current,b,Math.floor(Date.now()/1e3)),s(om({nodes:p,topology:m,remote:S,fleet:w,down:o.current}))}u();const d=setInterval(u,Yw);return()=>{l=!1,clearInterval(d)}},[e,t]),n}const lm=52,cm=14;function Kr({position:e,itemKey:t,label:n,onMove:s,onStep:o,canMove:l=()=>!0}){const u=L.useRef(null),d=L.useRef(0),[p,m]=L.useState(!1),S=()=>{var k,N,M,A;const C=u.current;(N=(k=C==null?void 0:C.over)==null?void 0:k.classList)==null||N.remove("nc-roster-over"),(A=(M=C==null?void 0:C.source)==null?void 0:M.classList)==null||A.remove("nc-roster-dragging"),d.current&&cancelAnimationFrame(d.current),d.current=0},w=(C=!1)=>{const k=u.current;if(!k)return;const N=k.target;S(),u.current=null,m(!1);try{k.handle.releasePointerCapture(k.pointerId)}catch{}C&&N&&N!==t&&l(t,N)&&s(t,N)},y=(C,k)=>{var ee,O,H,J,W,X,G,j;const N=u.current;if(!N)return;N.x=C,N.y=k;const M=(O=(ee=document.elementFromPoint(C,k))==null?void 0:ee.closest)==null?void 0:O.call(ee,"[data-roster-key][data-position]"),A=(H=M==null?void 0:M.dataset)==null?void 0:H.rosterKey,B=((J=M==null?void 0:M.dataset)==null?void 0:J.position)===e&&A&&A!==t&&l(t,A);N.over!==(B?M:null)&&((X=(W=N.over)==null?void 0:W.classList)==null||X.remove("nc-roster-over"),N.over=B?M:null,(j=(G=N.over)==null?void 0:G.classList)==null||j.add("nc-roster-over")),N.target=B?A:null},_=()=>{const C=u.current;if(!C){d.current=0;return}const k=C.container;if(k){const N=k.getBoundingClientRect(),M=C.y<N.top+lm?-cm:C.y>N.bottom-lm?cm:0;M&&(k.scrollTop+=M,y(C.x,C.y))}d.current=requestAnimationFrame(_)};L.useEffect(()=>{const C=N=>{N.key==="Escape"&&u.current&&(N.preventDefault(),w(!1))},k=()=>w(!1);return window.addEventListener("keydown",C),window.addEventListener("blur",k),()=>{window.removeEventListener("keydown",C),window.removeEventListener("blur",k),S(),u.current=null}},[t,e]);const b=C=>{var M;if(C.pointerType==="mouse"&&C.button!==0)return;C.preventDefault(),C.stopPropagation(),C.currentTarget.focus({preventScroll:!0});const k=C.currentTarget.closest("[data-roster-key][data-position]"),N=C.currentTarget.closest(".nc-side-scroll, .nc-home-scroll");u.current={pointerId:C.pointerId,handle:C.currentTarget,source:k,container:N,target:null,over:null,x:C.clientX,y:C.clientY},(M=k==null?void 0:k.classList)==null||M.add("nc-roster-dragging");try{C.currentTarget.setPointerCapture(C.pointerId)}catch{}m(!0),d.current=requestAnimationFrame(_)};return h.jsx("button",{type:"button",className:`nc-roster-handle${p?" active":""}`,"aria-label":`${v("reorder")} ${n}`,"aria-keyshortcuts":"ArrowUp ArrowDown",title:v("reorder-help"),onClick:C=>{C.preventDefault(),C.stopPropagation()},onDragStart:C=>C.preventDefault(),onKeyDown:C=>{C.key!=="ArrowUp"&&C.key!=="ArrowDown"||(C.preventDefault(),C.stopPropagation(),o(C.key==="ArrowUp"?-1:1))},onPointerDown:b,onPointerMove:C=>{!u.current||C.pointerId!==u.current.pointerId||(C.preventDefault(),C.stopPropagation(),y(C.clientX,C.clientY))},onPointerUp:C=>{!u.current||C.pointerId!==u.current.pointerId||(C.preventDefault(),C.stopPropagation(),w(!0))},onPointerCancel:()=>w(!1),onLostPointerCapture:()=>{u.current&&w(!1)},children:"↕"})}function Ha(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 Xc(e){return e.status==="passive"?v("node-passive"):e.status==="down"?e.downSince?v("tunnel-down-since").replace("{t}",Ha(e.downSince)):v("tunnel-down"):e.status==="unreachable"?v("node-unreachable"):e.status==="offline"?e.lastSeen?v("node-offline-seen").replace("{t}",Ha(e.lastSeen)):v("node-offline"):e.status==="needs-repair"?v("node-needs-repair"):""}function Xw(e){return e?e.status==="healthy"?"on":"warn":null}function um(e){return e&&(e.detail||e.status)||""}function Gw({onPick:e,token:t,onSettings:n}){const[s,o]=Si(),l=$h(t),[u,d]=L.useState(null),[p,m]=L.useState(null),[S,w]=L.useState(""),[y,_]=L.useState(""),[b,C]=L.useState({bind:"127.0.0.1",port:""}),[k,N]=L.useState([]),[M,A]=L.useState(null),[B,ee]=L.useState(null),[O,H]=L.useState(bv),[J,W]=L.useState(Lv),[X,G]=L.useState(Rv);async function j(){try{const de=await(await zt("/api/sessions",t)).json();de.error?(m(de.error),d([])):(m(null),d(de.sessions||[]))}catch(Y){m(String(Y)),d([])}try{const Y=await fr(t);N(Y.available?Y.cells||[]:[])}catch{N([])}}L.useEffect(()=>{j(),zt("/api/config",t).then(de=>de.json()).then(de=>{_(de.version||""),C({bind:de.bind||"127.0.0.1",port:de.port||""})}).catch(()=>{});const Y=setInterval(j,4e3);return()=>clearInterval(Y)},[]);async function E(){if(!b.port)return;const Y=`http://${b.bind}:${b.port}/#token=${t}`;try{await navigator.clipboard.writeText(Y)}catch{}}async function P(Y){if(!M)return;const{cell:de}=M,we=Array.isArray(M.route)?M.route:[];Y.action==="up"?await Ah(t,{cell:de,boot:!!Y.boot,...Y.engine?{engine:Y.engine}:{},...Y.model!==void 0?{model:Y.model}:{},...Y.permissionPolicy?{permissionPolicy:Y.permissionPolicy}:{}},we):await Oa(t,{cell:de,boot:!!Y.boot},we),j()}async function z(Y,de=[]){try{await Ih(t,Y,de)}catch{return}j()}async function R(Y,de,we=[]){try{await gv(t,Y,de,we)}catch{return}j()}async function F(Y){if(!(!(Y!=null&&Y.direct)||B)){ee(Y.name);try{await zh(t,Y.name,Y.tunnelStatus==="up"?"down":"up")}catch{}ee(null)}}const I=Y=>H(de=>Cv(de,Y)),re=Y=>za(J,Y),q=(Y,de)=>W(we=>{const K={...we,[Y]:{...za(we,Y),...de}};return Mv(K)}),D=L.useMemo(()=>(u||[]).map(Y=>{const de=Number(localStorage.getItem(Ia(Y.name))||0),we=!!(Y.outbox&&Y.outbox.count>0&&Y.outbox.latest>de);return{...Y,fresh:we}}),[u]),U=L.useMemo(()=>new Map(D.map(Y=>[Y.name,Y])),[D]),Q=L.useMemo(()=>new Set(k.map(Y=>Y.tmuxSession)),[k]),ae=L.useMemo(()=>D.filter(Y=>!Q.has(Y.name)),[D,Q]),se=L.useMemo(()=>[...k.map(Y=>{const de=U.get(Y.tmuxSession)||{};return{type:"cell",value:Y,key:dn([],Y.tmuxSession),label:Y.cell,live:!!Y.tmux,fresh:!!de.fresh,activity:de.activity||0,searchText:`${Y.engine||""} ${Y.key||""} ${de.preview||""}`}}),...ae.map(Y=>({type:"session",value:Y,key:dn([],Y.name),label:Y.name,live:!0,technical:Y.technical===!0,fresh:!!Y.fresh,activity:Y.activity||0,searchText:`${Y.preview||""} ${Y.cmd||""}`}))],[k,ae,U]),le=re("local"),pe=L.useMemo(()=>fn(se,O,le.filter,Xi(X,"local")).filter(Y=>am(Y,S)),[se,O,le.filter,S,X]),ce=l.reduce((Y,de)=>Y+(de.cells||[]).length+(de.unmanaged||[]).filter(we=>!we.technical).length,0),ke=fn(se,O,"all",Xi(X,"local")).length+ce,Oe=u?u.length:0,te=(u||[]).filter(Y=>Y.attached).length,ie=b.port?`${b.bind}:${b.port}`:b.bind;function ye(Y,de,we,K){const fe=O.includes(de),Ce=O.includes(we);if(fe===Ce){if(fe){H(Ne=>kv(Ne,de,we));return}G(Ne=>{var rt;const Be=((rt=K.find(Ae=>Ae.key===de))==null?void 0:rt.technical)===!0,mt=fn(K,O,Be?"technical":"all",Xi(Ne,Y)).map(Ae=>Ae.key);return Pv(Dv(Ne,Y,de,we,mt))})}}function Me(Y,de,we,K){var rt;const fe=((rt=K.find(Ae=>Ae.key===de))==null?void 0:rt.technical)===!0,Ce=O.includes(de),Ne=fn(K,O,fe?"technical":"all",Xi(X,Y)).map(Ae=>Ae.key).filter(Ae=>O.includes(Ae)===Ce),Be=Ne.indexOf(de),mt=Ne[Be+we];Be>=0&&mt&&ye(Y,de,mt,K)}function je(Y,de=null,we=se){var mt,rt;const K=Array.isArray(de==null?void 0:de.route)?de.route:[],fe=K.join("/"),Ce=fe||"local",Ne=(Ae,We)=>O.includes(Ae)===O.includes(We);if(Y.type==="cell"){const Ae=Y.value,We=K.length?((de==null?void 0:de.sessions)||[]).find(ge=>ge.name===Ae.tmuxSession):U.get(Ae.tmuxSession),Ie=(We==null?void 0:We.preview)||Ae.preview||"",bt=[`${Ae.engine}${Ae.key?`·${Ae.key}`:""}`,Ie,Ae.active?"":v("cell-off")].filter(Boolean).join(" · "),Ge=K.length===0||((de==null?void 0:de.capabilities)||[]).includes(Ae.active?"down":"up");return h.jsxs("div",{className:"nc-mcard","data-roster-key":Y.key,"data-position":Ce,children:[h.jsx(Kr,{position:Ce,itemKey:Y.key,label:Ae.cell,canMove:Ne,onMove:(ge,qe)=>ye(Ce,ge,qe,we),onStep:ge=>Me(Ce,Y.key,ge,we)}),h.jsxs("button",{className:"nc-mcard-main",onClick:()=>Ae.tmux&&e(K.length?{session:Ae.tmuxSession,node:fe}:Ae.tmuxSession),title:Ae.degraded?v("cell-degraded"):Ae.tmux?v("cell-on"):v("cell-off"),children:[h.jsx("span",{className:`dot ${Ae.degraded?"warn":Ae.tmux?"on":""}`}),h.jsxs("span",{className:"nc-mcard-text",children:[h.jsx("b",{children:Ae.cell}),h.jsx("small",{children:bt})]})]}),Y.activity?h.jsx("span",{className:"nc-rel",children:Ha(Y.activity)}):null,Y.fresh&&((mt=We==null?void 0:We.outbox)==null?void 0:mt.count)>0&&h.jsx("span",{className:"nc-badge",title:v("new-files-outbox"),children:We.outbox.count}),h.jsx("button",{className:`nc-act pin${O.includes(Y.key)?" on":""}`,"aria-label":`${v("pin")} ${Ae.cell}`,title:v("pin"),onClick:()=>I(Y.key),children:O.includes(Y.key)?"★":"☆"}),Ge&&h.jsx("button",{className:`nc-act power${Ae.tmux?" on":""}${Ae.degraded?" warn":""}`,onClick:()=>A(K.length?{...Ae,route:K,availableEngines:(de==null?void 0:de.engines)||[]}:Ae),title:Ae.active?v("power-off"):v("power-on"),"aria-label":`${Ae.active?v("power-off"):v("power-on")} ${Ae.cell}`,children:h.jsx(tt,{name:"power",size:16})})]},Y.key)}const Be=Y.value;return h.jsxs("div",{className:"nc-mcard","data-roster-key":Y.key,"data-position":Ce,children:[h.jsx(Kr,{position:Ce,itemKey:Y.key,label:Be.name,canMove:Ne,onMove:(Ae,We)=>ye(Ce,Ae,We,we),onStep:Ae=>Me(Ce,Y.key,Ae,we)}),h.jsxs("button",{className:"nc-mcard-main",onClick:()=>e(K.length?{session:Be.name,node:fe}:Be.name),children:[h.jsx("span",{className:Be.attached?"dot on":"dot"}),h.jsxs("span",{className:"nc-mcard-text",children:[h.jsx("b",{children:Be.name}),h.jsx("small",{children:Be.preview?Be.preview:Be.cmd?Be.cmd:v("windows").replace("{n}",String(Be.windows||0))})]})]}),Y.activity?h.jsx("span",{className:"nc-rel",children:Ha(Y.activity)}):null,Y.fresh&&((rt=Be.outbox)==null?void 0:rt.count)>0&&h.jsx("span",{className:"nc-badge",title:v("new-files-outbox"),children:Be.outbox.count}),h.jsx("button",{className:`nc-act pin${O.includes(Y.key)?" on":""}`,"aria-label":`${v("pin")} ${Be.name}`,title:v("pin"),onClick:()=>I(Y.key),children:O.includes(Y.key)?"★":"☆"}),h.jsx("button",{className:`nc-act technical${Be.technical?" on":""}`,title:Be.technical?v("mark-normal"):v("mark-technical"),"aria-label":`${Be.technical?v("mark-normal"):v("mark-technical")} ${Be.name}`,onClick:()=>R(Be.name,!Be.technical,K),children:"T"}),h.jsx("button",{className:"nc-menu",title:v("terminate"),"aria-label":`${v("terminate")} ${Be.name}`,onClick:()=>{window.confirm(v("terminate-confirm").replace("{name}",Be.name))&&z(Be.name,K)},children:"⋯"})]},Y.key)}return h.jsxs("div",{className:"nc-home",children:[h.jsxs("header",{className:"nc-home-head",children:[h.jsxs("div",{className:"nc-wordmark",children:["NexusCrew",h.jsx("span",{className:"nc-cursor"})]}),h.jsxs("div",{className:"nc-home-sub",children:[v("fleet-tmux")," · ",Oe," ",v("sessions"),te>0&&` · ${te} attached`]}),h.jsxs("span",{className:"nc-head-actions",children:[h.jsx("button",{className:"nc-refresh",onClick:()=>n("nodes",!1),title:v("settings"),children:h.jsx(tt,{name:"gear",size:18})}),h.jsx("button",{className:"nc-refresh",onClick:j,title:v("refresh"),children:h.jsx(tt,{name:"refresh",size:18})})]})]}),h.jsxs("main",{className:"nc-home-scroll",children:[ke>8&&h.jsx("input",{className:"nc-filter",type:"search",placeholder:v("filter-placeholder"),"aria-label":v("filter-placeholder"),value:S,onChange:Y=>w(Y.target.value)}),p&&h.jsx("div",{className:"nc-err",children:p}),h.jsxs("section",{className:"nc-group","data-position":"local",children:[h.jsx(hm,{label:v("position-local"),count:pe.length,state:le,dotClass:"on",onToggle:()=>q("local",{open:!le.open}),onFilter:Y=>q("local",{filter:Y})}),le.open&&pe.map(Y=>je(Y,null,se)),le.open&&u===null&&h.jsx("div",{className:"nc-empty",children:v("loading-fleet")}),le.open&&u!==null&&pe.length===0&&!p&&h.jsx("div",{className:"nc-empty",children:S?v("no-match").replace("{q}",S):v("no-sessions-short")})]}),l.map(Y=>{const we=Xw(Y.health)||(Y.status==="up"?"on":Y.status==="passive"?"":"warn"),K=Y.health?um(Y.health):Y.status==="up"?"":Xc(Y),fe=Y.route||[Y.name],Ce=fe.join("/"),Ne=re(Ce),Be=new Map((Y.sessions||[]).map(Ie=>[Ie.name,Ie])),mt=Ie=>{const bt=Number(localStorage.getItem(Ia(dn(fe,Ie.name)))||0);return!!(Ie.outbox&&Ie.outbox.count>0&&Ie.outbox.latest>bt)},rt=[...(Y.cells||[]).map(Ie=>{const bt=Be.get(Ie.tmuxSession)||{};return{type:"cell",value:Ie,key:dn(fe,Ie.tmuxSession||Ie.cell),label:Ie.cell,live:!!Ie.tmux,fresh:mt({...bt,name:Ie.tmuxSession||Ie.cell}),activity:bt.activity||Ie.activity||0,searchText:`${Ie.engine||""} ${Ie.key||""} ${bt.preview||Ie.preview||""}`}}),...(Y.unmanaged||[]).map(Ie=>({type:"session",value:Ie,key:dn(fe,Ie.name),label:Ie.name,live:!0,technical:Ie.technical===!0,fresh:mt(Ie),activity:Ie.activity||0,searchText:`${Ie.preview||""} ${Ie.cmd||""}`}))],Ae=fn(rt,O,Ne.filter,Xi(X,Ce)).filter(Ie=>am(Ie,S)),We=Y.direct&&Y.health&&Y.health.managed!==!1?h.jsx("button",{type:"button",className:`nc-act power${Y.tunnelStatus==="up"?" on":""}`,disabled:B===Y.name,title:Y.tunnelStatus==="up"?v("power-off"):v("power-on"),"aria-label":`${Y.tunnelStatus==="up"?v("power-off"):v("power-on")} ${Y.label||Y.name}`,onClick:()=>F(Y),children:h.jsx(tt,{name:"power",size:15})}):null;return h.jsxs("section",{className:"nc-group","data-position":Ce,children:[h.jsx(hm,{label:Y.label||Y.name,count:Ae.length,state:Ne,dotClass:we,dotTitle:K,detail:Y.status==="up"?"":Y.health&&um(Y.health)||Xc(Y),onToggle:()=>q(Ce,{open:!Ne.open}),onFilter:Ie=>q(Ce,{filter:Ie}),action:We}),Y.status==="up"&&Ne.open&&Ae.map(Ie=>je(Ie,Y,rt)),Y.status==="up"&&Ne.open&&Ae.length===0&&h.jsx("div",{className:"nc-empty",children:S?v("no-match").replace("{q}",S):v("no-sessions-short")})]},`nodo-${Ce}`)}),h.jsxs("footer",{className:"nc-home-foot",onClick:E,title:v("copy-url"),children:[h.jsxs("span",{className:"nc-home-meta",children:[y&&h.jsxs("span",{className:"nc-home-version",children:["v",y]}),h.jsxs("span",{className:"nc-home-endpoint",children:[ie," · ",v("ssh-only")]})]}),h.jsx("span",{className:"nc-lang",onClick:Y=>Y.stopPropagation(),children:Av.map((Y,de)=>h.jsxs("span",{children:[de>0&&" · ",h.jsx("button",{className:`nc-lang-btn${s===Y?" on":""}`,onClick:()=>o(Y),title:Y,children:Y.toUpperCase()})]},Y))})]})]}),h.jsx("button",{className:"nc-fab",onClick:()=>n("fleet",!0),title:v("fleet-new-cell"),"aria-label":v("fleet-new-cell"),children:"+"}),M&&h.jsx(Fa,{cell:M,token:t,route:Array.isArray(M.route)?M.route:[],onConfirm:P,onClose:()=>A(null)})]})}function hm({label:e,count:t,state:n,dotClass:s="",dotTitle:o="",detail:l="",onToggle:u,onFilter:d,action:p=null}){return h.jsxs("div",{className:"nc-mobile-position-head",children:[h.jsxs("button",{type:"button",className:"nc-mobile-position-toggle",onClick:u,"aria-expanded":n.open,"aria-label":`${e} · ${v("node-sessions").replace("{n}",String(t))}`,children:[h.jsx("span",{className:"nc-mobile-chevron","aria-hidden":"true",children:n.open?"⌄":"›"}),h.jsx("span",{className:`dot ${s}`,title:o}),h.jsxs("span",{className:"nc-mobile-position-copy",children:[h.jsx("b",{children:e}),h.jsx("small",{children:l||v("node-sessions").replace("{n}",String(t))})]})]}),h.jsxs("select",{className:"nc-mobile-position-filter",value:n.filter,"aria-label":`${e} · ${v("filter-placeholder")}`,title:v(`view-${n.filter}`),onChange:m=>d(m.target.value),children:[h.jsx("option",{value:"all",children:v("view-all")}),h.jsx("option",{value:"pinned",children:v("view-pinned")}),h.jsx("option",{value:"active",children:v("view-active")}),h.jsx("option",{value:"off",children:v("view-off")}),h.jsx("option",{value:"technical",children:v("view-technical")})]}),p]})}/**
|
|
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 Bv=Object.defineProperty,Qw=Object.getOwnPropertyDescriptor,Jw=(e,t)=>{for(var n in t)Bv(e,n,{get:t[n],enumerable:!0})},_t=(e,t,n,s)=>{for(var o=s>1?void 0:s?Qw(t,n):t,l=e.length-1,u;l>=0;l--)(u=e[l])&&(o=(s?u(t,n,o):u(o))||o);return s&&o&&Bv(t,n,o),o},xe=(e,t)=>(n,s)=>t(n,s,e),dm="Terminal input",Hu={get:()=>dm,set:e=>dm=e},fm="Too much output to announce, navigate to rows manually to read",$u={get:()=>fm,set:e=>fm=e};function Zw(e){return e.replace(/\r?\n/g,"\r")}function e0(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function t0(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function i0(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");Iv(o,t,n,s)}}function Iv(e,t,n,s){e=Zw(e),e=e0(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function Ov(e,t,n){let s=n.getBoundingClientRect(),o=e.clientX-s.left-10,l=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${l}px`,t.style.zIndex="1000",t.focus()}function pm(e,t,n,s,o){Ov(e,t,n),o&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Fn(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Ja(e,t=0,n=e.length){let s="";for(let o=t;o<n;++o){let l=e[o];l>65535?(l-=65536,s+=String.fromCharCode((l>>10)+55296)+String.fromCharCode(l%1024+56320)):s+=String.fromCharCode(l)}return s}var n0=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 l=e.charCodeAt(o++);56320<=l&&l<=57343?t[s++]=(this._interim-55296)*1024+l-56320+65536:(t[s++]=this._interim,t[s++]=l),this._interim=0}for(let l=o;l<n;++l){let u=e.charCodeAt(l);if(55296<=u&&u<=56319){if(++l>=n)return this._interim=u,s;let d=e.charCodeAt(l);56320<=d&&d<=57343?t[s++]=(u-55296)*1024+d-56320+65536:(t[s++]=u,t[s++]=d);continue}u!==65279&&(t[s++]=u)}return s}},r0=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,l,u,d,p=0,m=0;if(this.interim[0]){let y=!1,_=this.interim[0];_&=(_&224)===192?31:(_&240)===224?15:7;let b=0,C;for(;(C=this.interim[++b]&63)&&b<4;)_<<=6,_|=C;let k=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,N=k-b;for(;m<N;){if(m>=n)return 0;if(C=e[m++],(C&192)!==128){m--,y=!0;break}else this.interim[b++]=C,_<<=6,_|=C&63}y||(k===2?_<128?m--:t[s++]=_:k===3?_<2048||_>=55296&&_<=57343||_===65279||(t[s++]=_):_<65536||_>1114111||(t[s++]=_)),this.interim.fill(0)}let S=n-4,w=m;for(;w<n;){for(;w<S&&!((o=e[w])&128)&&!((l=e[w+1])&128)&&!((u=e[w+2])&128)&&!((d=e[w+3])&128);)t[s++]=o,t[s++]=l,t[s++]=u,t[s++]=d,w+=4;if(o=e[w++],o<128)t[s++]=o;else if((o&224)===192){if(w>=n)return this.interim[0]=o,s;if(l=e[w++],(l&192)!==128){w--;continue}if(p=(o&31)<<6|l&63,p<128){w--;continue}t[s++]=p}else if((o&240)===224){if(w>=n)return this.interim[0]=o,s;if(l=e[w++],(l&192)!==128){w--;continue}if(w>=n)return this.interim[0]=o,this.interim[1]=l,s;if(u=e[w++],(u&192)!==128){w--;continue}if(p=(o&15)<<12|(l&63)<<6|u&63,p<2048||p>=55296&&p<=57343||p===65279)continue;t[s++]=p}else if((o&248)===240){if(w>=n)return this.interim[0]=o,s;if(l=e[w++],(l&192)!==128){w--;continue}if(w>=n)return this.interim[0]=o,this.interim[1]=l,s;if(u=e[w++],(u&192)!==128){w--;continue}if(w>=n)return this.interim[0]=o,this.interim[1]=l,this.interim[2]=u,s;if(d=e[w++],(d&192)!==128){w--;continue}if(p=(o&7)<<18|(l&63)<<12|(u&63)<<6|d&63,p<65536||p>1114111)continue;t[s++]=p}}return s}},zv="",Hn=" ",no=class Fv{constructor(){this.fg=0,this.bg=0,this.extended=new $a}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 Fv;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}},$a=class Hv{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 Hv(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Di=class $v extends no{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new $a,this.combinedData=""}static fromCharData(t){let n=new $v;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?Fn(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()]}},mm="di$target",Wu="di$dependencies",Gc=new Map;function s0(e){return e[Wu]||[]}function Ft(e){if(Gc.has(e))return Gc.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");o0(t,n,o)};return t._id=e,Gc.set(e,t),t}function o0(e,t,n){t[mm]===t?t[Wu].push({id:e,index:n}):(t[Wu]=[{id:e,index:n}],t[mm]=t)}var ei=Ft("BufferService"),Wv=Ft("CoreMouseService"),pr=Ft("CoreService"),a0=Ft("CharsetService"),Wh=Ft("InstantiationService"),Uv=Ft("LogService"),ti=Ft("OptionsService"),Kv=Ft("OscLinkService"),l0=Ft("UnicodeService"),ro=Ft("DecorationService"),Uu=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){var S;let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let s=[],o=this._optionsService.rawOptions.linkHandler,l=new Di,u=n.getTrimmedLength(),d=-1,p=-1,m=!1;for(let w=0;w<u;w++)if(!(p===-1&&!n.hasContent(w))){if(n.loadCell(w,l),l.hasExtendedAttrs()&&l.extended.urlId)if(p===-1){p=w,d=l.extended.urlId;continue}else m=l.extended.urlId!==d;else p!==-1&&(m=!0);if(m||p!==-1&&w===u-1){let y=(S=this._oscLinkService.getLinkData(d))==null?void 0:S.uri;if(y){let _={start:{x:p+1,y:e},end:{x:w+(!m&&w===u-1?1:0),y:e}},b=!1;if(!(o!=null&&o.allowNonHttpProtocols))try{let C=new URL(y);["http:","https:"].includes(C.protocol)||(b=!0)}catch{b=!0}b||s.push({text:y,range:_,activate:(C,k)=>o?o.activate(C,k,_):c0(C,k),hover:(C,k)=>{var N;return(N=o==null?void 0:o.hover)==null?void 0:N.call(o,C,k,_)},leave:(C,k)=>{var N;return(N=o==null?void 0:o.leave)==null?void 0:N.call(o,C,k,_)}})}m=!1,l.hasExtendedAttrs()&&l.extended.urlId?(p=w,d=l.extended.urlId):(p=-1,d=-1)}}t(s)}};Uu=_t([xe(0,ei),xe(1,ti),xe(2,Kv)],Uu);function c0(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 Za=Ft("CharSizeService"),mn=Ft("CoreBrowserService"),Uh=Ft("MouseService"),gn=Ft("RenderService"),u0=Ft("SelectionService"),qv=Ft("CharacterJoinerService"),Jr=Ft("ThemeService"),Vv=Ft("LinkProviderService"),h0=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?gm.isErrorNoTelemetry(e)?new gm(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)}},d0=new h0;function La(e){f0(e)||d0.onUnexpectedError(e)}var Ku="Canceled";function f0(e){return e instanceof p0?!0:e instanceof Error&&e.name===Ku&&e.message===Ku}var p0=class extends Error{constructor(){super(Ku),this.name=this.message}};function m0(e){return new Error(`Illegal argument: ${e}`)}var gm=class qu extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof qu)return t;let n=new qu;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Vu=class Yv extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Yv.prototype)}};function gi(e,t=0){return e[e.length-(1+t)]}var g0;(e=>{function t(l){return l<0}e.isLessThan=t;function n(l){return l<=0}e.isLessThanOrEqual=n;function s(l){return l>0}e.isGreaterThan=s;function o(l){return l===0}e.isNeitherLessOrGreaterThan=o,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(g0||(g0={}));function v0(e,t){let n=this,s=!1,o;return function(){return s||(s=!0,t||(o=e.apply(n,arguments))),o}}var Xv;(e=>{function t(B){return B&&typeof B=="object"&&typeof B[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*o(B){yield B}e.single=o;function l(B){return t(B)?B:o(B)}e.wrap=l;function u(B){return B||n}e.from=u;function*d(B){for(let ee=B.length-1;ee>=0;ee--)yield B[ee]}e.reverse=d;function p(B){return!B||B[Symbol.iterator]().next().done===!0}e.isEmpty=p;function m(B){return B[Symbol.iterator]().next().value}e.first=m;function S(B,ee){let O=0;for(let H of B)if(ee(H,O++))return!0;return!1}e.some=S;function w(B,ee){for(let O of B)if(ee(O))return O}e.find=w;function*y(B,ee){for(let O of B)ee(O)&&(yield O)}e.filter=y;function*_(B,ee){let O=0;for(let H of B)yield ee(H,O++)}e.map=_;function*b(B,ee){let O=0;for(let H of B)yield*ee(H,O++)}e.flatMap=b;function*C(...B){for(let ee of B)yield*ee}e.concat=C;function k(B,ee,O){let H=O;for(let J of B)H=ee(H,J);return H}e.reduce=k;function*N(B,ee,O=B.length){for(ee<0&&(ee+=B.length),O<0?O+=B.length:O>B.length&&(O=B.length);ee<O;ee++)yield B[ee]}e.slice=N;function M(B,ee=Number.POSITIVE_INFINITY){let O=[];if(ee===0)return[O,B];let H=B[Symbol.iterator]();for(let J=0;J<ee;J++){let W=H.next();if(W.done)return[O,e.empty()];O.push(W.value)}return[O,{[Symbol.iterator](){return H}}]}e.consume=M;async function A(B){let ee=[];for await(let O of B)ee.push(O);return Promise.resolve(ee)}e.asyncToArray=A})(Xv||(Xv={}));function hr(e){if(Xv.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 _0(...e){return ut(()=>hr(e))}function ut(e){return{dispose:v0(()=>{e()})}}var Gv=class Qv{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{hr(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?Qv.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)}};Gv.DISABLE_DISPOSED_WARNING=!1;var $n=Gv,Xe=class{constructor(){this._store=new $n,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)}};Xe.None=Object.freeze({dispose(){}});var Gr=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}},pn=typeof window=="object"?window:globalThis,Yu=class Xu{constructor(t){this.element=t,this.next=Xu.Undefined,this.prev=Xu.Undefined}};Yu.Undefined=new Yu(void 0);var ft=Yu,vm=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}},y0=globalThis.performance&&typeof globalThis.performance.now=="function",S0=class Jv{static create(t){return new Jv(t)}constructor(t){this._now=y0&&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}},Ut;(e=>{e.None=()=>Xe.None;function t(j,E){return w(j,()=>{},0,void 0,!0,void 0,E)}e.defer=t;function n(j){return(E,P=null,z)=>{let R=!1,F;return F=j(I=>{if(!R)return F?F.dispose():R=!0,E.call(P,I)},null,z),R&&F.dispose(),F}}e.once=n;function s(j,E,P){return m((z,R=null,F)=>j(I=>z.call(R,E(I)),null,F),P)}e.map=s;function o(j,E,P){return m((z,R=null,F)=>j(I=>{E(I),z.call(R,I)},null,F),P)}e.forEach=o;function l(j,E,P){return m((z,R=null,F)=>j(I=>E(I)&&z.call(R,I),null,F),P)}e.filter=l;function u(j){return j}e.signal=u;function d(...j){return(E,P=null,z)=>{let R=_0(...j.map(F=>F(I=>E.call(P,I))));return S(R,z)}}e.any=d;function p(j,E,P,z){let R=P;return s(j,F=>(R=E(R,F),R),z)}e.reduce=p;function m(j,E){let P,z={onWillAddFirstListener(){P=j(R.fire,R)},onDidRemoveLastListener(){P==null||P.dispose()}},R=new be(z);return E==null||E.add(R),R.event}function S(j,E){return E instanceof Array?E.push(j):E&&E.add(j),j}function w(j,E,P=100,z=!1,R=!1,F,I){let re,q,D,U=0,Q,ae={leakWarningThreshold:F,onWillAddFirstListener(){re=j(le=>{U++,q=E(q,le),z&&!D&&(se.fire(q),q=void 0),Q=()=>{let pe=q;q=void 0,D=void 0,(!z||U>1)&&se.fire(pe),U=0},typeof P=="number"?(clearTimeout(D),D=setTimeout(Q,P)):D===void 0&&(D=0,queueMicrotask(Q))})},onWillRemoveListener(){R&&U>0&&(Q==null||Q())},onDidRemoveLastListener(){Q=void 0,re.dispose()}},se=new be(ae);return I==null||I.add(se),se.event}e.debounce=w;function y(j,E=0,P){return e.debounce(j,(z,R)=>z?(z.push(R),z):[R],E,void 0,!0,void 0,P)}e.accumulate=y;function _(j,E=(z,R)=>z===R,P){let z=!0,R;return l(j,F=>{let I=z||!E(F,R);return z=!1,R=F,I},P)}e.latch=_;function b(j,E,P){return[e.filter(j,E,P),e.filter(j,z=>!E(z),P)]}e.split=b;function C(j,E=!1,P=[],z){let R=P.slice(),F=j(q=>{R?R.push(q):re.fire(q)});z&&z.add(F);let I=()=>{R==null||R.forEach(q=>re.fire(q)),R=null},re=new be({onWillAddFirstListener(){F||(F=j(q=>re.fire(q)),z&&z.add(F))},onDidAddFirstListener(){R&&(E?setTimeout(I):I())},onDidRemoveLastListener(){F&&F.dispose(),F=null}});return z&&z.add(re),re.event}e.buffer=C;function k(j,E){return(P,z,R)=>{let F=E(new M);return j(function(I){let re=F.evaluate(I);re!==N&&P.call(z,re)},void 0,R)}}e.chain=k;let N=Symbol("HaltChainable");class M{constructor(){this.steps=[]}map(E){return this.steps.push(E),this}forEach(E){return this.steps.push(P=>(E(P),P)),this}filter(E){return this.steps.push(P=>E(P)?P:N),this}reduce(E,P){let z=P;return this.steps.push(R=>(z=E(z,R),z)),this}latch(E=(P,z)=>P===z){let P=!0,z;return this.steps.push(R=>{let F=P||!E(R,z);return P=!1,z=R,F?R:N}),this}evaluate(E){for(let P of this.steps)if(E=P(E),E===N)break;return E}}function A(j,E,P=z=>z){let z=(...re)=>I.fire(P(...re)),R=()=>j.on(E,z),F=()=>j.removeListener(E,z),I=new be({onWillAddFirstListener:R,onDidRemoveLastListener:F});return I.event}e.fromNodeEventEmitter=A;function B(j,E,P=z=>z){let z=(...re)=>I.fire(P(...re)),R=()=>j.addEventListener(E,z),F=()=>j.removeEventListener(E,z),I=new be({onWillAddFirstListener:R,onDidRemoveLastListener:F});return I.event}e.fromDOMEventEmitter=B;function ee(j){return new Promise(E=>n(j)(E))}e.toPromise=ee;function O(j){let E=new be;return j.then(P=>{E.fire(P)},()=>{E.fire(void 0)}).finally(()=>{E.dispose()}),E.event}e.fromPromise=O;function H(j,E){return j(P=>E.fire(P))}e.forward=H;function J(j,E,P){return E(P),j(z=>E(z))}e.runAndSubscribe=J;class W{constructor(E,P){this._observable=E,this._counter=0,this._hasChanged=!1;let z={onWillAddFirstListener:()=>{E.addObserver(this)},onDidRemoveLastListener:()=>{E.removeObserver(this)}};this.emitter=new be(z),P&&P.add(this.emitter)}beginUpdate(E){this._counter++}handlePossibleChange(E){}handleChange(E,P){this._hasChanged=!0}endUpdate(E){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function X(j,E){return new W(j,E).emitter.event}e.fromObservable=X;function G(j){return(E,P,z)=>{let R=0,F=!1,I={beginUpdate(){R++},endUpdate(){R--,R===0&&(j.reportChanges(),F&&(F=!1,E.call(P)))},handlePossibleChange(){},handleChange(){F=!0}};j.addObserver(I),j.reportChanges();let re={dispose(){j.removeObserver(I)}};return z instanceof $n?z.add(re):Array.isArray(z)&&z.push(re),re}}e.fromObservableLight=G})(Ut||(Ut={}));var Gu=class Qu{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Qu._idPool++}`,Qu.all.add(this)}start(t){this._stopWatch=new S0,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}}};Gu.all=new Set,Gu._idPool=0;var w0=Gu,b0=-1,Zv=class e_{constructor(t,n,s=(e_._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[l,u]=this.getMostFrequentStack(),d=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${u}):`;console.warn(d),console.warn(l);let p=new x0(d,l);this._errorHandler(p)}return()=>{let l=this._stacks.get(t.value)||0;this._stacks.set(t.value,l-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}};Zv._idPool=1;var C0=Zv,k0=class t_{constructor(t){this.value=t}static create(){let t=new Error;return new t_(t.stack??"")}print(){console.warn(this.value.split(`
|
|
58
|
+
`).slice(2).join(`
|
|
59
|
+
`))}},x0=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},E0=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},N0=0,Qc=class{constructor(e){this.value=e,this.id=N0++}},R0=2,P0,be=class{constructor(e){var t,n,s,o;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new C0((e==null?void 0:e.onListenerError)??La,((n=this._options)==null?void 0:n.leakWarningThreshold)??b0):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new w0(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,d,p,m,S;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let w=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(w);let y=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],_=new E0(`${w}. HINT: Stack shows most frequent listener (${y[1]}-times)`,y[0]);return(((u=this._options)==null?void 0:u.onListenerError)||La)(_),Xe.None}if(this._disposed)return Xe.None;t&&(e=e.bind(t));let s=new Qc(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=k0.create(),o=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof Qc?(this._deliveryQueue??(this._deliveryQueue=new D0),this._listeners=[this._listeners,s]):this._listeners.push(s):((p=(d=this._options)==null?void 0:d.onWillAddFirstListener)==null||p.call(d,this),this._listeners=s,(S=(m=this._options)==null?void 0:m.onDidAddFirstListener)==null||S.call(m,this)),this._size++;let l=ut(()=>{o==null||o(),this._removeListener(s)});return n instanceof $n?n.add(l):Array.isArray(n)&&n.push(l),l}),this._event}_removeListener(e){var o,l,u,d;if((l=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||l.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(d=(u=this._options)==null?void 0:u.onDidRemoveLastListener)==null||d.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*R0<=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)||La;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 Qc)this._deliver(this._listeners,e);else{let l=this._deliveryQueue;l.enqueue(this,e,this._listeners.length),this._deliverQueue(l)}(o=this._perfMon)==null||o.stop()}hasListeners(){return this._size>0}},D0=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}},Ju=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new be,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new be,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}};Ju.INSTANCE=new Ju;var Kh=Ju;function L0(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}Kh.INSTANCE.onDidChangeZoomLevel;function M0(e){return Kh.INSTANCE.getZoomFactor(e)}Kh.INSTANCE.onDidChangeFullscreen;var Zr=typeof navigator=="object"?navigator.userAgent:"",Zu=Zr.indexOf("Firefox")>=0,j0=Zr.indexOf("AppleWebKit")>=0,qh=Zr.indexOf("Chrome")>=0,T0=!qh&&Zr.indexOf("Safari")>=0;Zr.indexOf("Electron/")>=0;Zr.indexOf("Android")>=0;var Jc=!1;if(typeof pn.matchMedia=="function"){let e=pn.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=pn.matchMedia("(display-mode: fullscreen)");Jc=e.matches,L0(pn,e,({matches:n})=>{Jc&&t.matches||(Jc=n)})}var qr="en",eh=!1,th=!1,Ma=!1,i_=!1,wa,ja=qr,_m=qr,A0,zi,cr=globalThis,Wt,dv;typeof cr.vscode<"u"&&typeof cr.vscode.process<"u"?Wt=cr.vscode.process:typeof process<"u"&&typeof((dv=process==null?void 0:process.versions)==null?void 0:dv.node)=="string"&&(Wt=process);var fv,B0=typeof((fv=Wt==null?void 0:Wt.versions)==null?void 0:fv.electron)=="string",I0=B0&&(Wt==null?void 0:Wt.type)==="renderer",pv;if(typeof Wt=="object"){eh=Wt.platform==="win32",th=Wt.platform==="darwin",Ma=Wt.platform==="linux",Ma&&Wt.env.SNAP&&Wt.env.SNAP_REVISION,Wt.env.CI||Wt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,wa=qr,ja=qr;let e=Wt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);wa=t.userLocale,_m=t.osLocale,ja=t.resolvedLanguage||qr,A0=(pv=t.languagePack)==null?void 0:pv.translationsConfigFile}catch{}i_=!0}else typeof navigator=="object"&&!I0?(zi=navigator.userAgent,eh=zi.indexOf("Windows")>=0,th=zi.indexOf("Macintosh")>=0,(zi.indexOf("Macintosh")>=0||zi.indexOf("iPad")>=0||zi.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Ma=zi.indexOf("Linux")>=0,(zi==null?void 0:zi.indexOf("Mobi"))>=0,ja=globalThis._VSCODE_NLS_LANGUAGE||qr,wa=navigator.language.toLowerCase(),_m=wa):console.error("Unable to resolve platform.");var n_=eh,Qi=th,O0=Ma,ym=i_,en=zi,Bn=ja,z0;(e=>{function t(){return Bn}e.value=t;function n(){return Bn.length===2?Bn==="en":Bn.length>=3?Bn[0]==="e"&&Bn[1]==="n"&&Bn[2]==="-":!1}e.isDefaultVariant=n;function s(){return Bn==="en"}e.isDefault=s})(z0||(z0={}));var F0=typeof cr.postMessage=="function"&&!cr.importScripts;(()=>{if(F0){let e=[];cr.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let s=0,o=e.length;s<o;s++){let l=e[s];if(l.id===n.data.vscodeScheduleAsyncWork){e.splice(s,1),l.callback();return}}});let t=0;return n=>{let s=++t;e.push({id:s,callback:n}),cr.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var H0=!!(en&&en.indexOf("Chrome")>=0);en&&en.indexOf("Firefox")>=0;!H0&&en&&en.indexOf("Safari")>=0;en&&en.indexOf("Edg/")>=0;en&&en.indexOf("Android")>=0;var Hr=typeof navigator=="object"?navigator:{};ym||document.queryCommandSupported&&document.queryCommandSupported("copy")||Hr&&Hr.clipboard&&Hr.clipboard.writeText,ym||Hr&&Hr.clipboard&&Hr.clipboard.readText;var Vh=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}},Zc=new Vh,Sm=new Vh,wm=new Vh,$0=new Array(230),r_;(e=>{function t(d){return Zc.keyCodeToStr(d)}e.toString=t;function n(d){return Zc.strToKeyCode(d)}e.fromString=n;function s(d){return Sm.keyCodeToStr(d)}e.toUserSettingsUS=s;function o(d){return wm.keyCodeToStr(d)}e.toUserSettingsGeneral=o;function l(d){return Sm.strToKeyCode(d)||wm.strToKeyCode(d)}e.fromUserSettings=l;function u(d){if(d>=98&&d<=113)return null;switch(d){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Zc.keyCodeToStr(d)}e.toElectronAccelerator=u})(r_||(r_={}));var W0=class s_{constructor(t,n,s,o,l){this.ctrlKey=t,this.shiftKey=n,this.altKey=s,this.metaKey=o,this.keyCode=l}equals(t){return t instanceof s_&&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 U0([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},U0=class{constructor(e){if(e.length===0)throw m0("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 K0(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return r_.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(Zu)switch(t){case 59:return 85;case 60:if(O0)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Qi)return 57;break}else if(j0&&(Qi&&t===93||!Qi&&t===92))return 57;return $0[t]||0}var q0=Qi?256:2048,V0=512,Y0=1024,X0=Qi?2048:256,bm=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=K0(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|=q0),this.altKey&&(t|=V0),this.shiftKey&&(t|=Y0),this.metaKey&&(t|=X0),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new W0(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Cm=new WeakMap;function G0(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 Q0=class{static getSameOriginWindowChain(e){let t=Cm.get(e);if(!t){t=[],Cm.set(e,t);let n=e,s;do s=G0(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 l of o){let u=l.window.deref();if(n+=(u==null?void 0:u.scrollY)??0,s+=(u==null?void 0:u.scrollX)??0,u===t||!l.iframeElement)break;let d=l.iframeElement.getBoundingClientRect();n+=d.top,s+=d.left}return{top:n,left:s}}},ba=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=Q0.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},km=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(qh){let l=navigator.userAgent.match(/Chrome\/(\d+)/);s=(l?parseInt(l[1]):123)<=122}if(e){let l=e,u=e,d=((o=e.view)==null?void 0:o.devicePixelRatio)||1;if(typeof l.wheelDeltaY<"u")s?this.deltaY=l.wheelDeltaY/(120*d):this.deltaY=l.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?Zu&&!Qi?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof l.wheelDeltaX<"u")T0&&n_?this.deltaX=-(l.wheelDeltaX/120):s?this.deltaX=l.wheelDeltaX/(120*d):this.deltaX=l.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?Zu&&!Qi?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*d):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},o_=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),J0;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof Z0?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ut.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:o_})})(J0||(J0={}));var Z0=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?o_:(this._emitter||(this._emitter=new be),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Yh=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 Vu("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Vu("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},eb=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 Vu("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=ut(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},tb;(e=>{async function t(s){let o,l=await Promise.all(s.map(u=>u.then(d=>d,d=>{o||(o=d)})));if(typeof o<"u")throw o;return l}e.settled=t;function n(s){return new Promise(async(o,l)=>{try{await s(o,l)}catch(u){l(u)}})}e.withAsyncBody=n})(tb||(tb={}));var xm=class Ri{static fromArray(t){return new Ri(n=>{n.emitMany(t)})}static fromPromise(t){return new Ri(async n=>{n.emitMany(await t)})}static fromPromises(t){return new Ri(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new Ri(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 be,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 Ut.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 Ri(async s=>{for await(let o of t)s.emitOne(n(o))})}map(t){return Ri.map(this,t)}static filter(t,n){return new Ri(async s=>{for await(let o of t)n(o)&&s.emitOne(o)})}filter(t){return Ri.filter(this,t)}static coalesce(t){return Ri.filter(t,n=>!!n)}coalesce(){return Ri.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return Ri.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())}};xm.EMPTY=xm.fromArray([]);var{getWindow:Gi,getWindowId:ib,onDidRegisterWindow:nb}=(function(){let e=new Map,t={window:pn,disposables:new $n};e.set(pn.vscodeWindowId,t);let n=new be,s=new be,o=new be;function l(u,d){return(typeof u=="number"?e.get(u):void 0)??(d?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:s.event,registerWindow(u){if(e.has(u.vscodeWindowId))return Xe.None;let d=new $n,p={window:u,disposables:d.add(new $n)};return e.set(u.vscodeWindowId,p),d.add(ut(()=>{e.delete(u.vscodeWindowId),s.fire(u)})),d.add($e(u,At.BEFORE_UNLOAD,()=>{o.fire(u)})),n.fire(p),d},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(u){return u.vscodeWindowId},hasWindow(u){return e.has(u)},getWindowById:l,getWindow(u){var m;let d=u;if((m=d==null?void 0:d.ownerDocument)!=null&&m.defaultView)return d.ownerDocument.defaultView.window;let p=u;return p!=null&&p.view?p.view.window:pn},getDocument(u){return Gi(u).document}}})(),rb=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 $e(e,t,n,s){return new rb(e,t,n,s)}var Em=function(e,t,n,s){return $e(e,t,n,s)},Xh,sb=class extends eb{constructor(e){super(),this.defaultTarget=e&&Gi(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},Nm=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){La(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=l=>{n.set(l,!1);let u=e.get(l)??[];for(t.set(l,u),e.set(l,[]),s.set(l,!0);u.length>0;)u.sort(Nm.sort),u.shift().execute();s.set(l,!1)};Xh=(l,u,d=0)=>{let p=ib(l),m=new Nm(u,d),S=e.get(p);return S||(S=[],e.set(p,S)),S.push(m),n.get(p)||(n.set(p,!0),l.requestAnimationFrame(()=>o(p))),m}})();function ob(e){let t=e.getBoundingClientRect(),n=Gi(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var At={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"},ab=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=li(t);this._maxWidth!==n&&(this._maxWidth=n,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let n=li(t);this._width!==n&&(this._width=n,this.domNode.style.width=this._width)}setHeight(t){let n=li(t);this._height!==n&&(this._height=n,this.domNode.style.height=this._height)}setTop(t){let n=li(t);this._top!==n&&(this._top=n,this.domNode.style.top=this._top)}setLeft(t){let n=li(t);this._left!==n&&(this._left=n,this.domNode.style.left=this._left)}setBottom(t){let n=li(t);this._bottom!==n&&(this._bottom=n,this.domNode.style.bottom=this._bottom)}setRight(t){let n=li(t);this._right!==n&&(this._right=n,this.domNode.style.right=this._right)}setPaddingTop(t){let n=li(t);this._paddingTop!==n&&(this._paddingTop=n,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let n=li(t);this._paddingLeft!==n&&(this._paddingLeft=n,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let n=li(t);this._paddingBottom!==n&&(this._paddingBottom=n,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let n=li(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=li(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=li(t);this._lineHeight!==n&&(this._lineHeight=n,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let n=li(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 li(e){return typeof e=="number"?`${e}px`:e}function Zs(e){return new ab(e)}var a_=class{constructor(){this._hooks=new $n,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 l=e;try{e.setPointerCapture(t),this._hooks.add(ut(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{l=Gi(e)}this._hooks.add($e(l,At.POINTER_MOVE,u=>{if(u.buttons!==n){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add($e(l,At.POINTER_UP,u=>this.stopMonitoring(!0)))}};function lb(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 l=`$memoize$${t}`;n[s]=function(...u){return this.hasOwnProperty(l)||Object.defineProperty(this,l,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,u)}),this[l]}}var Yi;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Yi||(Yi={}));var Ys=class Gt extends Xe{constructor(){super(),this.dispatched=!1,this.targets=new vm,this.ignoreTargets=new vm,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ut.runAndSubscribe(nb,({window:t,disposables:n})=>{n.add($e(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add($e(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add($e(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:pn,disposables:this._store}))}static addTarget(t){if(!Gt.isTouchDevice())return Xe.None;Gt.INSTANCE||(Gt.INSTANCE=new Gt);let n=Gt.INSTANCE.targets.push(t);return ut(n)}static ignoreTarget(t){if(!Gt.isTouchDevice())return Xe.None;Gt.INSTANCE||(Gt.INSTANCE=new Gt);let n=Gt.INSTANCE.ignoreTargets.push(t);return ut(n)}static isTouchDevice(){return"ontouchstart"in pn||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 l=t.targetTouches.item(s);this.activeTouches[l.identifier]={id:l.identifier,initialTarget:l.target,initialTimeStamp:n,initialPageX:l.pageX,initialPageY:l.pageY,rollingTimestamps:[n],rollingPageX:[l.pageX],rollingPageY:[l.pageY]};let u=this.newGestureEvent(Yi.Start,l.target);u.pageX=l.pageX,u.pageY=l.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 l=0,u=n.changedTouches.length;l<u;l++){let d=n.changedTouches.item(l);if(!this.activeTouches.hasOwnProperty(String(d.identifier))){console.warn("move of an UNKNOWN touch",d);continue}let p=this.activeTouches[d.identifier],m=Date.now()-p.initialTimeStamp;if(m<Gt.HOLD_DELAY&&Math.abs(p.initialPageX-gi(p.rollingPageX))<30&&Math.abs(p.initialPageY-gi(p.rollingPageY))<30){let S=this.newGestureEvent(Yi.Tap,p.initialTarget);S.pageX=gi(p.rollingPageX),S.pageY=gi(p.rollingPageY),this.dispatchEvent(S)}else if(m>=Gt.HOLD_DELAY&&Math.abs(p.initialPageX-gi(p.rollingPageX))<30&&Math.abs(p.initialPageY-gi(p.rollingPageY))<30){let S=this.newGestureEvent(Yi.Contextmenu,p.initialTarget);S.pageX=gi(p.rollingPageX),S.pageY=gi(p.rollingPageY),this.dispatchEvent(S)}else if(o===1){let S=gi(p.rollingPageX),w=gi(p.rollingPageY),y=gi(p.rollingTimestamps)-p.rollingTimestamps[0],_=S-p.rollingPageX[0],b=w-p.rollingPageY[0],C=[...this.targets].filter(k=>p.initialTarget instanceof Node&&k.contains(p.initialTarget));this.inertia(t,C,s,Math.abs(_)/y,_>0?1:-1,S,Math.abs(b)/y,b>0?1:-1,w)}this.dispatchEvent(this.newGestureEvent(Yi.End,p.initialTarget)),delete this.activeTouches[d.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===Yi.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>Gt.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===Yi.Change||t.type===Yi.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,l=t.initialTarget;for(;l&&l!==s;)o++,l=l.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,l,u,d,p,m){this.handle=Xh(t,()=>{let S=Date.now(),w=S-s,y=0,_=0,b=!0;o+=Gt.SCROLL_FRICTION*w,d+=Gt.SCROLL_FRICTION*w,o>0&&(b=!1,y=l*o*w),d>0&&(b=!1,_=p*d*w);let C=this.newGestureEvent(Yi.Change);C.translationX=y,C.translationY=_,n.forEach(k=>k.dispatchEvent(C)),b||this.inertia(t,n,S,o,l,u+y,d,p,m+_)})}onTouchMove(t){let n=Date.now();for(let s=0,o=t.changedTouches.length;s<o;s++){let l=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("end of an UNKNOWN touch",l);continue}let u=this.activeTouches[l.identifier],d=this.newGestureEvent(Yi.Change,u.initialTarget);d.translationX=l.pageX-gi(u.rollingPageX),d.translationY=l.pageY-gi(u.rollingPageY),d.pageX=l.pageX,d.pageY=l.pageY,this.dispatchEvent(d),u.rollingPageX.length>3&&(u.rollingPageX.shift(),u.rollingPageY.shift(),u.rollingTimestamps.shift()),u.rollingPageX.push(l.pageX),u.rollingPageY.push(l.pageY),u.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Ys.SCROLL_FRICTION=-.005,Ys.HOLD_DELAY=700,Ys.CLEAR_TAP_COUNT_TIME=400,_t([lb],Ys,"isTouchDevice",1);var cb=Ys,Gh=class extends Xe{onclick(e,t){this._register($e(e,At.CLICK,n=>t(new ba(Gi(e),n))))}onmousedown(e,t){this._register($e(e,At.MOUSE_DOWN,n=>t(new ba(Gi(e),n))))}onmouseover(e,t){this._register($e(e,At.MOUSE_OVER,n=>t(new ba(Gi(e),n))))}onmouseleave(e,t){this._register($e(e,At.MOUSE_LEAVE,n=>t(new ba(Gi(e),n))))}onkeydown(e,t){this._register($e(e,At.KEY_DOWN,n=>t(new bm(n))))}onkeyup(e,t){this._register($e(e,At.KEY_UP,n=>t(new bm(n))))}oninput(e,t){this._register($e(e,At.INPUT,t))}onblur(e,t){this._register($e(e,At.BLUR,t))}onfocus(e,t){this._register($e(e,At.FOCUS,t))}onchange(e,t){this._register($e(e,At.CHANGE,t))}ignoreGesture(e){return cb.ignoreTarget(e)}},Rm=11,ub=class extends Gh{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=Rm+"px",this.domNode.style.height=Rm+"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 a_),this._register(Em(this.bgDomNode,At.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Em(this.domNode,At.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new sb),this._pointerdownScheduleRepeatTimer=this._register(new Yh)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Gi(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()}},hb=class ih{constructor(t,n,s,o,l,u,d){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,o=o|0,l=l|0,u=u|0,d=d|0),this.rawScrollLeft=o,this.rawScrollTop=d,n<0&&(n=0),o+n>s&&(o=s-n),o<0&&(o=0),l<0&&(l=0),d+l>u&&(d=u-l),d<0&&(d=0),this.width=n,this.scrollWidth=s,this.scrollLeft=o,this.height=l,this.scrollHeight=u,this.scrollTop=d}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 ih(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 ih(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,l=this.scrollLeft!==t.scrollLeft,u=this.height!==t.height,d=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:l,heightChanged:u,scrollHeightChanged:d,scrollTopChanged:p}}},db=class extends Xe{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new be),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new hb(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 Dm(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=Dm.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)))}},Pm=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function eu(e,t){let n=t-e;return function(s){return e+n*mb(s)}}function fb(e,t,n){return function(s){return s<n?e(s/n):t((s-n)/(1-n))}}var Dm=class nh{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,l;return t<n?(o=t+.75*s,l=n-.75*s):(o=t-.75*s,l=n+.75*s),fb(eu(t,o),eu(l,n),.33)}return eu(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 Pm(s,o,!1)}return new Pm(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,s){return nh.start(t,n,s)}static start(t,n,s){s=s+10;let o=Date.now()-10;return new nh(t,n,o,s)}};function pb(e){return Math.pow(e,3)}function mb(e){return 1-pb(1-e)}var gb=class extends Xe{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 Yh)}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":"")))}},vb=140,l_=class extends Gh{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 gb(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new a_),this._shouldRender=!0,this.domNode=Zs(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($e(this.domNode.domNode,At.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new ub(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=Zs(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($e(this.slider.domNode,At.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=ob(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 l=this._sliderOrthogonalPointerPosition(o),u=Math.abs(l-n);if(n_&&u>vb){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let d=this._sliderPointerPosition(o)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(d))},()=>{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()}},c_=class rh{constructor(t,n,s,o,l,u){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=l,this._scrollPosition=u,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new rh(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,l){let u=Math.max(0,s-t),d=Math.max(0,u-2*n),p=o>0&&o>s;if(!p)return{computedAvailableSize:Math.round(u),computedIsNeeded:p,computedSliderSize:Math.round(d),computedSliderRatio:0,computedSliderPosition:0};let m=Math.round(Math.max(20,Math.floor(s*d/o))),S=(d-m)/(o-s),w=l*S;return{computedAvailableSize:Math.round(u),computedIsNeeded:p,computedSliderSize:Math.round(m),computedSliderRatio:S,computedSliderPosition:Math.round(w)}}_refreshComputedValues(){let t=rh._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)}},_b=class extends l_{constructor(e,t,n){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new c_(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}},yb=class extends l_{constructor(e,t,n){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new c_(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}},Sb=500,Lm=50,wb=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},sh=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 l=o===this._front?t:Math.pow(2,-s);if(t-=l,n+=this._memory[o].score*l,o===this._front)break;o=(this._capacity+o-1)%this._capacity,s++}while(!0);return n<=.5}acceptStandardWheelEvent(t){if(qh){let n=Gi(t.browserEvent),s=M0(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,l=new wb(t,n,s);this._front===-1&&this._rear===-1?(this._memory[0]=l,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]=l),l.score=this._computeScore(l,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),l=Math.abs(t.deltaY),u=Math.abs(n.deltaX),d=Math.abs(n.deltaY),p=Math.max(Math.min(o,u),1),m=Math.max(Math.min(l,d),1),S=Math.max(o,u),w=Math.max(l,d);S%p===0&&w%m===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};sh.INSTANCE=new sh;var bb=sh,Cb=class extends Gh{constructor(e,t,n){super(),this._onScroll=this._register(new be),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new be),this.onWillScroll=this._onWillScroll.event,this._options=xb(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 yb(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new _b(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=Zs(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Zs(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Zs(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 Yh),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=hr(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,Qi&&(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 km(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=hr(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new km(n))};this._mouseWheelToDispose.push($e(this._listenOnDomNode,At.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var o;if((o=e.browserEvent)!=null&&o.defaultPrevented)return;let t=bb.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let l=e.deltaY*this._options.mouseWheelScrollSensitivity,u=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&u+l===0?u=l=0:Math.abs(l)>=Math.abs(u)?u=0:l=0),this._options.flipAxes&&([l,u]=[u,l]);let d=!Qi&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||d)&&!u&&(u=l,l=0),e.browserEvent&&e.browserEvent.altKey&&(u=u*this._options.fastScrollSensitivity,l=l*this._options.fastScrollSensitivity);let p=this._scrollable.getFutureScrollPosition(),m={};if(l){let S=Lm*l,w=p.scrollTop-(S<0?Math.floor(S):Math.ceil(S));this._verticalScrollbar.writeScrollPosition(m,w)}if(u){let S=Lm*u,w=p.scrollLeft-(S<0?Math.floor(S):Math.ceil(S));this._horizontalScrollbar.writeScrollPosition(m,w)}m=this._scrollable.validateScrollPosition(m),(p.scrollLeft!==m.scrollLeft||p.scrollTop!==m.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(m):this._scrollable.setScrollPositionNow(m),n=!0)}let s=n;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,s=n?" left":"",o=t?" top":"",l=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${o}`),this._topLeftShadowDomNode.setClassName(`shadow${l}${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(),Sb)}},kb=class extends Cb{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 xb(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,Qi&&(t.className+=" mac"),t}var oh=class extends Xe{constructor(e,t,n,s,o,l,u,d){super(),this._bufferService=n,this._optionsService=u,this._renderService=d,this._onRequestScrollLines=this._register(new be),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let p=this._register(new db({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:m=>Xh(s.window,m)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{p.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new kb(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(Ut.runAndSubscribe(l.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=l.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ut(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(ut(()=>this._styleElement.remove())),this._register(Ut.runAndSubscribe(l.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${l.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${l.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${l.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}};oh=_t([xe(2,ei),xe(3,mn),xe(4,Wv),xe(5,Jr),xe(6,ti),xe(7,gn)],oh);var ah=class extends Xe{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(l=>this._removeDecoration(l))),this._register(ut(()=>{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()}};ah=_t([xe(1,ei),xe(2,mn),xe(3,ro),xe(4,gn)],ah);var Eb=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)}},Ki={full:0,left:0,center:0,right:0},In={full:0,left:0,center:0,right:0},zs={full:0,left:0,center:0,right:0},Wa=class extends Xe{constructor(e,t,n,s,o,l,u,d){var m;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=s,this._renderService=o,this._optionsService=l,this._themeService=u,this._coreBrowserService=d,this._colorZoneStore=new Eb,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(ut(()=>{var S;return(S=this._canvas)==null?void 0:S.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);In.full=this._canvas.width,In.left=e,In.center=t,In.right=e,this._refreshDrawHeightConstants(),zs.full=1,zs.left=1,zs.center=1+In.left,zs.right=1+In.left+In.center}_refreshDrawHeightConstants(){Ki.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);Ki.left=t,Ki.center=t,Ki.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.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(zs[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Ki[e.position||"full"]/2),In[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Ki[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}))}};Wa=_t([xe(2,ei),xe(3,ro),xe(4,gn),xe(5,ti),xe(6,Jr),xe(7,mn)],Wa);var he;(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=""))(he||(he={}));var Ta;(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=""))(Ta||(Ta={}));var u_;(e=>e.ST=`${he.ESC}\\`)(u_||(u_={}));var lh=class{constructor(e,t,n,s,o,l){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=s,this._coreService=o,this._renderService=l,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(`${he.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 l=this._compositionView.getBoundingClientRect();this._textarea.style.left=o+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(l.width,1)+"px",this._textarea.style.height=Math.max(l.height,1)+"px",this._textarea.style.lineHeight=l.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};lh=_t([xe(2,ei),xe(3,ti),xe(4,pr),xe(5,gn)],lh);var Bt=0,It=0,Ot=0,vt=0,Mm={css:"#00000000",rgba:0},xt;(e=>{function t(o,l,u,d){return d!==void 0?`#${nr(o)}${nr(l)}${nr(u)}${nr(d)}`:`#${nr(o)}${nr(l)}${nr(u)}`}e.toCss=t;function n(o,l,u,d=255){return(o<<24|l<<16|u<<8|d)>>>0}e.toRgba=n;function s(o,l,u,d){return{css:e.toCss(o,l,u,d),rgba:e.toRgba(o,l,u,d)}}e.toColor=s})(xt||(xt={}));var lt;(e=>{function t(p,m){if(vt=(m.rgba&255)/255,vt===1)return{css:m.css,rgba:m.rgba};let S=m.rgba>>24&255,w=m.rgba>>16&255,y=m.rgba>>8&255,_=p.rgba>>24&255,b=p.rgba>>16&255,C=p.rgba>>8&255;Bt=_+Math.round((S-_)*vt),It=b+Math.round((w-b)*vt),Ot=C+Math.round((y-C)*vt);let k=xt.toCss(Bt,It,Ot),N=xt.toRgba(Bt,It,Ot);return{css:k,rgba:N}}e.blend=t;function n(p){return(p.rgba&255)===255}e.isOpaque=n;function s(p,m,S){let w=Aa.ensureContrastRatio(p.rgba,m.rgba,S);if(w)return xt.toColor(w>>24&255,w>>16&255,w>>8&255)}e.ensureContrastRatio=s;function o(p){let m=(p.rgba|255)>>>0;return[Bt,It,Ot]=Aa.toChannels(m),{css:xt.toCss(Bt,It,Ot),rgba:m}}e.opaque=o;function l(p,m){return vt=Math.round(m*255),[Bt,It,Ot]=Aa.toChannels(p.rgba),{css:xt.toCss(Bt,It,Ot,vt),rgba:xt.toRgba(Bt,It,Ot,vt)}}e.opacity=l;function u(p,m){return vt=p.rgba&255,l(p,vt*m/255)}e.multiplyOpacity=u;function d(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=d})(lt||(lt={}));var pt;(e=>{let t,n;try{let o=document.createElement("canvas");o.width=1,o.height=1;let l=o.getContext("2d",{willReadFrequently:!0});l&&(t=l,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 Bt=parseInt(o.slice(1,2).repeat(2),16),It=parseInt(o.slice(2,3).repeat(2),16),Ot=parseInt(o.slice(3,4).repeat(2),16),xt.toColor(Bt,It,Ot);case 5:return Bt=parseInt(o.slice(1,2).repeat(2),16),It=parseInt(o.slice(2,3).repeat(2),16),Ot=parseInt(o.slice(3,4).repeat(2),16),vt=parseInt(o.slice(4,5).repeat(2),16),xt.toColor(Bt,It,Ot,vt);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 l=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(l)return Bt=parseInt(l[1]),It=parseInt(l[2]),Ot=parseInt(l[3]),vt=Math.round((l[5]===void 0?1:parseFloat(l[5]))*255),xt.toColor(Bt,It,Ot,vt);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),[Bt,It,Ot,vt]=t.getImageData(0,0,1,1).data,vt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:xt.toRgba(Bt,It,Ot,vt),css:o}}e.toColor=s})(pt||(pt={}));var Zt;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,o,l){let u=s/255,d=o/255,p=l/255,m=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4),S=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),w=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return m*.2126+S*.7152+w*.0722}e.relativeLuminance2=n})(Zt||(Zt={}));var Aa;(e=>{function t(u,d){if(vt=(d&255)/255,vt===1)return d;let p=d>>24&255,m=d>>16&255,S=d>>8&255,w=u>>24&255,y=u>>16&255,_=u>>8&255;return Bt=w+Math.round((p-w)*vt),It=y+Math.round((m-y)*vt),Ot=_+Math.round((S-_)*vt),xt.toRgba(Bt,It,Ot)}e.blend=t;function n(u,d,p){let m=Zt.relativeLuminance(u>>8),S=Zt.relativeLuminance(d>>8);if(un(m,S)<p){if(S<m){let _=s(u,d,p),b=un(m,Zt.relativeLuminance(_>>8));if(b<p){let C=o(u,d,p),k=un(m,Zt.relativeLuminance(C>>8));return b>k?_:C}return _}let w=o(u,d,p),y=un(m,Zt.relativeLuminance(w>>8));if(y<p){let _=s(u,d,p),b=un(m,Zt.relativeLuminance(_>>8));return y>b?w:_}return w}}e.ensureContrastRatio=n;function s(u,d,p){let m=u>>24&255,S=u>>16&255,w=u>>8&255,y=d>>24&255,_=d>>16&255,b=d>>8&255,C=un(Zt.relativeLuminance2(y,_,b),Zt.relativeLuminance2(m,S,w));for(;C<p&&(y>0||_>0||b>0);)y-=Math.max(0,Math.ceil(y*.1)),_-=Math.max(0,Math.ceil(_*.1)),b-=Math.max(0,Math.ceil(b*.1)),C=un(Zt.relativeLuminance2(y,_,b),Zt.relativeLuminance2(m,S,w));return(y<<24|_<<16|b<<8|255)>>>0}e.reduceLuminance=s;function o(u,d,p){let m=u>>24&255,S=u>>16&255,w=u>>8&255,y=d>>24&255,_=d>>16&255,b=d>>8&255,C=un(Zt.relativeLuminance2(y,_,b),Zt.relativeLuminance2(m,S,w));for(;C<p&&(y<255||_<255||b<255);)y=Math.min(255,y+Math.ceil((255-y)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),b=Math.min(255,b+Math.ceil((255-b)*.1)),C=un(Zt.relativeLuminance2(y,_,b),Zt.relativeLuminance2(m,S,w));return(y<<24|_<<16|b<<8|255)>>>0}e.increaseLuminance=o;function l(u){return[u>>24&255,u>>16&255,u>>8&255,u&255]}e.toChannels=l})(Aa||(Aa={}));function nr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function un(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var Nb=class extends no{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()]}},Ua=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,l=0,u=0,d=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!==d||this._workCell.bg!==p){if(m-o>1){let S=this._getJoinedRanges(s,u,l,t,o);for(let w=0;w<S.length;w++)n.push(S[w])}o=m,u=l,d=this._workCell.fg,p=this._workCell.bg}l+=this._workCell.getChars().length||Hn.length}if(this._bufferService.cols-o>1){let m=this._getJoinedRanges(s,u,l,t,o);for(let S=0;S<m.length;S++)n.push(m[S])}return n}_getJoinedRanges(e,t,n,s,o){let l=e.substring(t,n),u=[];try{u=this._characterJoiners[0].handler(l)}catch(d){console.error(d)}for(let d=1;d<this._characterJoiners.length;d++)try{let p=this._characterJoiners[d].handler(l);for(let m=0;m<p.length;m++)Ua._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,l=0,u=e[s];if(u){for(let d=n;d<this._bufferService.cols;d++){let p=t.getWidth(d),m=t.getString(d).length||Hn.length;if(p!==0){if(!o&&u[0]<=l&&(u[0]=d,o=!0),u[1]<=l){if(u[1]=d,u=e[++s],!u)break;u[0]<=l?(u[0]=d,o=!0):o=!1}l+=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}};Ua=_t([xe(0,ei)],Ua);function Rb(e){return 57508<=e&&e<=57558}function Pb(e){return 9472<=e&&e<=9631}function Db(e){return Rb(e)||Pb(e)}function Lb(){return{css:{canvas:Ca(),cell:Ca()},device:{canvas:Ca(),cell:Ca(),char:{width:0,height:0,left:0,top:0}}}}function Ca(){return{width:0,height:0}}var ch=class{constructor(e,t,n,s,o,l,u){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=s,this._coreService=o,this._decorationService=l,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,l,u,d,p,m,S){let w=[],y=this._characterJoinerService.getJoinedCharacters(t),_=this._themeService.colors,b=e.getNoBgTrimmedLength();n&&b<l+1&&(b=l+1);let C,k=0,N="",M=0,A=0,B=0,ee=0,O=!1,H=0,J=!1,W=0,X=0,G=[],j=m!==-1&&S!==-1;for(let E=0;E<b;E++){e.loadCell(E,this._workCell);let P=this._workCell.getWidth();if(P===0)continue;let z=!1,R=E>=X,F=E,I=this._workCell;if(y.length>0&&E===y[0][0]&&R){let ye=y.shift(),Me=this._isCellInSelection(ye[0],t);for(M=ye[0]+1;M<ye[1];M++)R&&(R=Me===this._isCellInSelection(M,t));R&&(R=!n||l<ye[0]||l>=ye[1]),R?(z=!0,I=new Nb(this._workCell,e.translateToString(!0,ye[0],ye[1]),ye[1]-ye[0]),F=ye[1]-1,P=I.getWidth()):X=ye[1]}let re=this._isCellInSelection(E,t),q=n&&E===l,D=j&&E>=m&&E<=S,U=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,ye=>{U=!0});let Q=I.getChars()||Hn;if(Q===" "&&(I.isUnderline()||I.isOverline())&&(Q=" "),W=P*d-p.get(Q,I.isBold(),I.isItalic()),!C)C=this._document.createElement("span");else if(k&&(re&&J||!re&&!J&&I.bg===A)&&(re&&J&&_.selectionForeground||I.fg===B)&&I.extended.ext===ee&&D===O&&W===H&&!q&&!z&&!U&&R){I.isInvisible()?N+=Hn:N+=Q,k++;continue}else k&&(C.textContent=N),C=this._document.createElement("span"),k=0,N="";if(A=I.bg,B=I.fg,ee=I.extended.ext,O=D,H=W,J=re,z&&l>=E&&l<=F&&(l=E),!this._coreService.isCursorHidden&&q&&this._coreService.isCursorInitialized){if(G.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&G.push("xterm-cursor-blink"),G.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":G.push("xterm-cursor-outline");break;case"block":G.push("xterm-cursor-block");break;case"bar":G.push("xterm-cursor-bar");break;case"underline":G.push("xterm-cursor-underline");break}}if(I.isBold()&&G.push("xterm-bold"),I.isItalic()&&G.push("xterm-italic"),I.isDim()&&G.push("xterm-dim"),I.isInvisible()?N=Hn:N=I.getChars()||Hn,I.isUnderline()&&(G.push(`xterm-underline-${I.extended.underlineStyle}`),N===" "&&(N=" "),!I.isUnderlineColorDefault()))if(I.isUnderlineColorRGB())C.style.textDecorationColor=`rgb(${no.toColorRGB(I.getUnderlineColor()).join(",")})`;else{let ye=I.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&I.isBold()&&ye<8&&(ye+=8),C.style.textDecorationColor=_.ansi[ye].css}I.isOverline()&&(G.push("xterm-overline"),N===" "&&(N=" ")),I.isStrikethrough()&&G.push("xterm-strikethrough"),D&&(C.style.textDecoration="underline");let ae=I.getFgColor(),se=I.getFgColorMode(),le=I.getBgColor(),pe=I.getBgColorMode(),ce=!!I.isInverse();if(ce){let ye=ae;ae=le,le=ye;let Me=se;se=pe,pe=Me}let ke,Oe,te=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,ye=>{ye.options.layer!=="top"&&te||(ye.backgroundColorRGB&&(pe=50331648,le=ye.backgroundColorRGB.rgba>>8&16777215,ke=ye.backgroundColorRGB),ye.foregroundColorRGB&&(se=50331648,ae=ye.foregroundColorRGB.rgba>>8&16777215,Oe=ye.foregroundColorRGB),te=ye.options.layer==="top")}),!te&&re&&(ke=this._coreBrowserService.isFocused?_.selectionBackgroundOpaque:_.selectionInactiveBackgroundOpaque,le=ke.rgba>>8&16777215,pe=50331648,te=!0,_.selectionForeground&&(se=50331648,ae=_.selectionForeground.rgba>>8&16777215,Oe=_.selectionForeground)),te&&G.push("xterm-decoration-top");let ie;switch(pe){case 16777216:case 33554432:ie=_.ansi[le],G.push(`xterm-bg-${le}`);break;case 50331648:ie=xt.toColor(le>>16,le>>8&255,le&255),this._addStyle(C,`background-color:#${jm((le>>>0).toString(16),"0",6)}`);break;case 0:default:ce?(ie=_.foreground,G.push("xterm-bg-257")):ie=_.background}switch(ke||I.isDim()&&(ke=lt.multiplyOpacity(ie,.5)),se){case 16777216:case 33554432:I.isBold()&&ae<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ae+=8),this._applyMinimumContrast(C,ie,_.ansi[ae],I,ke,void 0)||G.push(`xterm-fg-${ae}`);break;case 50331648:let ye=xt.toColor(ae>>16&255,ae>>8&255,ae&255);this._applyMinimumContrast(C,ie,ye,I,ke,Oe)||this._addStyle(C,`color:#${jm(ae.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(C,ie,_.foreground,I,ke,Oe)||ce&&G.push("xterm-fg-257")}G.length&&(C.className=G.join(" "),G.length=0),!q&&!z&&!U&&R?k++:C.textContent=N,W!==this.defaultSpacing&&(C.style.letterSpacing=`${W}px`),w.push(C),E=F}return C&&k&&(C.textContent=N),w}_applyMinimumContrast(e,t,n,s,o,l){if(this._optionsService.rawOptions.minimumContrastRatio===1||Db(s.getCode()))return!1;let u=this._getContrastCache(s),d;if(!o&&!l&&(d=u.getColor(t.rgba,n.rgba)),d===void 0){let p=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);d=lt.ensureContrastRatio(o||t,l||n,p),u.setColor((o||t).rgba,(l||n).rgba,d??null)}return d?(this._addStyle(e,`color:${d.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,s=this._selectionEnd;return!n||!s?!1:this._columnSelectMode?n[0]<=s[0]?e>=n[0]&&t>=n[1]&&e<s[0]&&t<=s[1]:e<n[0]&&t>=n[1]&&e>=s[0]&&t<=s[1]:t>n[1]&&t<s[1]||n[1]===s[1]&&t===n[1]&&e>=n[0]&&e<s[0]||n[1]<s[1]&&t===s[1]&&e<s[0]||n[1]<s[1]&&t===n[1]&&e>=n[0]}};ch=_t([xe(1,qv),xe(2,ti),xe(3,mn),xe(4,pr),xe(5,ro),xe(6,Jr)],ch);function jm(e,t,n){for(;e.length<n;)e=t+e;return e}var Mb=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 l=e.createElement("span");l.classList.add("xterm-char-measure-element"),l.style.fontWeight="bold",l.style.fontStyle="italic",this._measureElements=[n,s,o,l],this._container.appendChild(n),this._container.appendChild(s),this._container.appendChild(o),this._container.appendChild(l),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 l=this._holey.get(o);if(l===void 0){let u=0;t&&(u|=1),n&&(u|=2),l=this._measure(e,u),l>0&&this._holey.set(o,l)}return l}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},jb=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,l=t[1]-o,u=n[1]-o,d=Math.max(l,0),p=Math.min(u,e.rows-1);if(d>=e.rows||p<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=l,this.viewportEndRow=u,this.viewportCappedStartRow=d,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 Tb(){return new jb}var tu="xterm-dom-renderer-owner-",Ni="xterm-rows",ka="xterm-fg-",Tm="xterm-bg-",Fs="xterm-focus",xa="xterm-selection",Ab=1,uh=class extends Xe{constructor(e,t,n,s,o,l,u,d,p,m,S,w,y,_){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=s,this._viewportElement=o,this._helperContainer=l,this._linkifier2=u,this._charSizeService=p,this._optionsService=m,this._bufferService=S,this._coreService=w,this._coreBrowserService=y,this._themeService=_,this._terminalClass=Ab++,this._rowElements=[],this._selectionRenderModel=Tb(),this.onRequestRedraw=this._register(new be).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Ni),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(xa),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=Lb(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(b=>this._injectCss(b))),this._injectCss(this._themeService.colors),this._rowFactory=d.createInstance(ch,document),this._element.classList.add(tu+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(b=>this._handleLinkHover(b))),this._register(this._linkifier2.onHideLinkUnderline(b=>this._handleLinkLeave(b))),this._register(ut(()=>{this._element.classList.remove(tu+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Mb(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} .${Ni} 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} .${Ni} { 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} .${Ni} .xterm-dim { color: ${lt.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} .${Ni}.${Fs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Ni}.${Fs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Ni}.${Fs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${xa} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${xa} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${xa} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[l,u]of e.ansi.entries())t+=`${this._terminalSelector} .${ka}${l} { color: ${u.css}; }${this._terminalSelector} .${ka}${l}.xterm-dim { color: ${lt.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${Tm}${l} { background-color: ${u.css}; }`;t+=`${this._terminalSelector} .${ka}257 { color: ${lt.opaque(e.background).css}; }${this._terminalSelector} .${ka}257.xterm-dim { color: ${lt.multiplyOpacity(lt.opaque(e.background),.5).css}; }${this._terminalSelector} .${Tm}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(Fs),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Fs),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,l=this._selectionRenderModel.viewportCappedStartRow,u=this._selectionRenderModel.viewportCappedEndRow,d=this._document.createDocumentFragment();if(n){let p=e[0]>t[0];d.appendChild(this._createSelectionElement(l,p?t[0]:e[0],p?e[0]:t[0],u-l+1))}else{let p=s===l?e[0]:0,m=l===o?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(l,p,m));let S=u-l-1;if(d.appendChild(this._createSelectionElement(l+1,0,this._bufferService.cols,S)),l!==u){let w=o===u?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(u,0,w))}}this._selectionContainer.appendChild(d)}_createSelectionElement(e,t,n,s=1){let o=this._document.createElement("div"),l=t*this.dimensions.css.cell.width,u=this.dimensions.css.cell.width*(n-t);return l+u>this.dimensions.css.canvas.width&&(u=this.dimensions.css.canvas.width-l),o.style.height=`${s*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${l}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),l=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,u=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,d=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=e;p<=t;p++){let m=p+n.ydisp,S=this._rowElements[p],w=n.lines.get(m);if(!S||!w)break;S.replaceChildren(...this._rowFactory.createRow(w,m,m===s,u,d,o,l,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${tu}${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,l){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 d=this._bufferService.buffer,p=d.ybase+d.y,m=Math.min(d.x,o-1),S=this._optionsService.rawOptions.cursorBlink,w=this._optionsService.rawOptions.cursorStyle,y=this._optionsService.rawOptions.cursorInactiveStyle;for(let _=n;_<=s;++_){let b=_+d.ydisp,C=this._rowElements[_],k=d.lines.get(b);if(!C||!k)break;C.replaceChildren(...this._rowFactory.createRow(k,b,b===p,w,y,m,S,this.dimensions.css.cell.width,this._widthCache,l?_===n?e:0:-1,l?(_===s?t:o)-1:-1))}}};uh=_t([xe(7,Wh),xe(8,Za),xe(9,ti),xe(10,ei),xe(11,pr),xe(12,mn),xe(13,Jr)],uh);var hh=class extends Xe{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new be),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Ib(this._optionsService))}catch{this._measureStrategy=this._register(new Bb(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())}};hh=_t([xe(2,ti)],hh);var h_=class extends Xe{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)}},Bb=class extends h_{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}},Ib=class extends h_{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}},Ob=class extends Xe{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 zb(this._window)),this._onDprChange=this._register(new be),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new be),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Ut.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register($e(this._textarea,"focus",()=>this._isFocused=!0)),this._register($e(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}},zb=class extends Xe{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Gr),this._onDprChange=this._register(new be),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ut(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=$e(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)}},Fb=class extends Xe{constructor(){super(),this.linkProviders=[],this._register(ut(()=>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 Qh(e,t,n){let s=n.getBoundingClientRect(),o=e.getComputedStyle(n),l=parseInt(o.getPropertyValue("padding-left")),u=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-s.left-l,t.clientY-s.top-u]}function Hb(e,t,n,s,o,l,u,d,p){if(!l)return;let m=Qh(e,t,n);if(m)return m[0]=Math.ceil((m[0]+(p?u/2:0))/u),m[1]=Math.ceil(m[1]/d),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 dh=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,o){return Hb(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=Qh(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])}}};dh=_t([xe(0,gn),xe(1,Za)],dh);var $b=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=[]}},d_={};Jw(d_,{getSafariVersion:()=>Ub,isChromeOS:()=>g_,isFirefox:()=>f_,isIpad:()=>Kb,isIphone:()=>qb,isLegacyEdge:()=>Wb,isLinux:()=>Jh,isMac:()=>Ka,isNode:()=>el,isSafari:()=>p_,isWindows:()=>m_});var el=typeof process<"u"&&"title"in process,so=el?"node":navigator.userAgent,oo=el?"node":navigator.platform,f_=so.includes("Firefox"),Wb=so.includes("Edge"),p_=/^((?!chrome|android).)*safari/i.test(so);function Ub(){if(!p_)return 0;let e=so.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Ka=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(oo),Kb=oo==="iPad",qb=oo==="iPhone",m_=["Windows","Win16","Win32","WinCE"].includes(oo),Jh=oo.indexOf("Linux")>=0,g_=/\bCrOS\b/.test(so),v_=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()}},Vb=class extends v_{_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())}}},Yb=class extends v_{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},qa=!el&&"requestIdleCallback"in window?Yb:Vb,Xb=class{constructor(){this._queue=new qa}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},fh=class extends Xe{constructor(e,t,n,s,o,l,u,d,p){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=o,this._coreBrowserService=d,this._renderer=this._register(new Gr),this._pausedResizeTask=new Xb,this._observerDisposable=this._register(new Gr),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 be),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new be),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new be),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new be),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new $b((m,S)=>this._renderRows(m,S),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Gb(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ut(()=>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(l.onDecorationRegistered(()=>this._fullRefresh())),this._register(l.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=ut(()=>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()}};fh=_t([xe(2,ti),xe(3,Za),xe(4,pr),xe(5,ro),xe(6,ei),xe(7,mn),xe(8,Jr)],fh);var Gb=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 Qb(e,t,n,s){let o=n.buffer.x,l=n.buffer.y;if(!n.buffer.hasScrollback)return e1(o,l,e,t,n,s)+tl(l,t,n,s)+t1(o,l,e,t,n,s);let u;if(l===t)return u=o>e?"D":"C",to(Math.abs(o-e),eo(u,s));u=l>t?"D":"C";let d=Math.abs(l-t),p=Zb(l>t?e:o,n)+(d-1)*n.cols+1+Jb(l>t?o:e);return to(p,eo(u,s))}function Jb(e,t){return e-1}function Zb(e,t){return t.cols-e}function e1(e,t,n,s,o,l){return tl(t,s,o,l).length===0?"":to(y_(e,t,e,t-dr(t,o),!1,o).length,eo("D",l))}function tl(e,t,n,s){let o=e-dr(e,n),l=t-dr(t,n),u=Math.abs(o-l)-i1(e,t,n);return to(u,eo(__(e,t),s))}function t1(e,t,n,s,o,l){let u;tl(t,s,o,l).length>0?u=s-dr(s,o):u=t;let d=s,p=n1(e,t,n,s,o,l);return to(y_(e,u,n,d,p==="C",o).length,eo(p,l))}function i1(e,t,n){var u;let s=0,o=e-dr(e,n),l=t-dr(t,n);for(let d=0;d<Math.abs(o-l);d++){let p=__(e,t)==="A"?-1:1;(u=n.buffer.lines.get(o+p*d))!=null&&u.isWrapped&&s++}return s}function dr(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 n1(e,t,n,s,o,l){let u;return tl(n,s,o,l).length>0?u=s-dr(s,o):u=t,e<n&&u<=s||e>=n&&u<s?"C":"D"}function __(e,t){return e>t?"A":"B"}function y_(e,t,n,s,o,l){let u=e,d=t,p="";for(;(u!==n||d!==s)&&d>=0&&d<l.buffer.lines.length;)u+=o?1:-1,o&&u>l.cols-1?(p+=l.buffer.translateBufferLineToString(d,!1,e,u),u=0,e=0,d++):!o&&u<0&&(p+=l.buffer.translateBufferLineToString(d,!1,0,e+1),u=l.cols-1,e=u,d--);return p+l.buffer.translateBufferLineToString(d,!1,e,u)}function eo(e,t){let n=t?"O":"[";return he.ESC+n+e}function to(e,t){e=Math.floor(e);let n="";for(let s=0;s<e;s++)n+=t;return n}var r1=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 Am(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 iu=50,s1=15,o1=50,a1=500,l1=" ",c1=new RegExp(l1,"g"),ph=class extends Xe{constructor(e,t,n,s,o,l,u,d,p){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=s,this._coreService=o,this._mouseService=l,this._optionsService=u,this._renderService=d,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 be),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new be),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new be),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new be),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 r1(this._bufferService),this._activeSelectionMode=0,this._register(ut(()=>{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],l=e[0]<t[0]?t[0]:e[0];for(let u=e[1];u<=t[1];u++){let d=n.translateBufferLineToString(u,!0,o,l);s.push(d)}}else{let o=e[1]===t[1]?t[0]:void 0;s.push(n.translateBufferLineToString(e[1],!0,e[0],o));for(let l=e[1]+1;l<=t[1]-1;l++){let u=n.lines.get(l),d=n.translateBufferLineToString(l,!0);u!=null&&u.isWrapped?s[s.length-1]+=d:s.push(d)}if(e[1]!==t[1]){let l=n.lines.get(t[1]),u=n.translateBufferLineToString(t[1],!0,0,t[0]);l&&l.isWrapped?s[s.length-1]+=u:s.push(u)}}return s.map(o=>o.replace(c1," ")).join(m_?`\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())),Jh&&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,l;let n=(l=(o=this._linkifier.currentLink)==null?void 0:o.link)==null?void 0:l.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=Am(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=Qh(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,-iu),iu),t/=iu,t/Math.abs(t)+Math.round(t*(s1-1)))}shouldForceSelection(e){return Ka?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(),o1)}_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&&!(Ka&&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<a1&&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=Qb(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,l=o.lines.get(e[1]);if(!l)return;let u=o.translateBufferLineToString(e[1],!1),d=this._convertViewportColToCharacterIndex(l,e[0]),p=d,m=e[0]-d,S=0,w=0,y=0,_=0;if(u.charAt(d)===" "){for(;d>0&&u.charAt(d-1)===" ";)d--;for(;p<u.length&&u.charAt(p+1)===" ";)p++}else{let k=e[0],N=e[0];l.getWidth(k)===0&&(S++,k--),l.getWidth(N)===2&&(w++,N++);let M=l.getString(N).length;for(M>1&&(_+=M-1,p+=M-1);k>0&&d>0&&!this._isCharWordSeparator(l.loadCell(k-1,this._workCell));){l.loadCell(k-1,this._workCell);let A=this._workCell.getChars().length;this._workCell.getWidth()===0?(S++,k--):A>1&&(y+=A-1,d-=A-1),d--,k--}for(;N<l.length&&p+1<u.length&&!this._isCharWordSeparator(l.loadCell(N+1,this._workCell));){l.loadCell(N+1,this._workCell);let A=this._workCell.getChars().length;this._workCell.getWidth()===2?(w++,N++):A>1&&(_+=A-1,p+=A-1),p++,N++}}p++;let b=d+m-S+y,C=Math.min(this._bufferService.cols,p-d+S+w-y-_);if(!(!t&&u.slice(d,p).trim()==="")){if(n&&b===0&&l.getCodePoint(0)!==32){let k=o.lines.get(e[1]-1);if(k&&l.isWrapped&&k.getCodePoint(this._bufferService.cols-1)!==32){let N=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(N){let M=this._bufferService.cols-N.start;b-=M,C+=M}}}if(s&&b+C===this._bufferService.cols&&l.getCodePoint(this._bufferService.cols-1)!==32){let k=o.lines.get(e[1]+1);if(k!=null&&k.isWrapped&&k.getCodePoint(0)!==32){let N=this._getWordAt([0,e[1]+1],!1,!1,!0);N&&(C+=N.length)}}return{start:b,length:C}}}_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=Am(n,this._bufferService.cols)}};ph=_t([xe(3,ei),xe(4,pr),xe(5,Uh),xe(6,ti),xe(7,gn),xe(8,mn)],ph);var Bm=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={}}},Im=class{constructor(){this._color=new Bm,this._css=new Bm}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()}},Rt=Object.freeze((()=>{let e=[pt.toColor("#2e3436"),pt.toColor("#cc0000"),pt.toColor("#4e9a06"),pt.toColor("#c4a000"),pt.toColor("#3465a4"),pt.toColor("#75507b"),pt.toColor("#06989a"),pt.toColor("#d3d7cf"),pt.toColor("#555753"),pt.toColor("#ef2929"),pt.toColor("#8ae234"),pt.toColor("#fce94f"),pt.toColor("#729fcf"),pt.toColor("#ad7fa8"),pt.toColor("#34e2e2"),pt.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],l=t[n%6];e.push({css:xt.toCss(s,o,l),rgba:xt.toRgba(s,o,l)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:xt.toCss(s,s,s),rgba:xt.toRgba(s,s,s)})}return e})()),sr=pt.toColor("#ffffff"),Xs=pt.toColor("#000000"),Om=pt.toColor("#ffffff"),zm=Xs,Hs={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},u1=sr,mh=class extends Xe{constructor(e){super(),this._optionsService=e,this._contrastCache=new Im,this._halfContrastCache=new Im,this._onChangeColors=this._register(new be),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:sr,background:Xs,cursor:Om,cursorAccent:zm,selectionForeground:void 0,selectionBackgroundTransparent:Hs,selectionBackgroundOpaque:lt.blend(Xs,Hs),selectionInactiveBackgroundTransparent:Hs,selectionInactiveBackgroundOpaque:lt.blend(Xs,Hs),scrollbarSliderBackground:lt.opacity(sr,.2),scrollbarSliderHoverBackground:lt.opacity(sr,.4),scrollbarSliderActiveBackground:lt.opacity(sr,.5),overviewRulerBorder:sr,ansi:Rt.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=nt(e.foreground,sr),t.background=nt(e.background,Xs),t.cursor=lt.blend(t.background,nt(e.cursor,Om)),t.cursorAccent=lt.blend(t.background,nt(e.cursorAccent,zm)),t.selectionBackgroundTransparent=nt(e.selectionBackground,Hs),t.selectionBackgroundOpaque=lt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=nt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=lt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?nt(e.selectionForeground,Mm):void 0,t.selectionForeground===Mm&&(t.selectionForeground=void 0),lt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=lt.opacity(t.selectionBackgroundTransparent,.3)),lt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=lt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=nt(e.scrollbarSliderBackground,lt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=nt(e.scrollbarSliderHoverBackground,lt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=nt(e.scrollbarSliderActiveBackground,lt.opacity(t.foreground,.5)),t.overviewRulerBorder=nt(e.overviewRulerBorder,u1),t.ansi=Rt.slice(),t.ansi[0]=nt(e.black,Rt[0]),t.ansi[1]=nt(e.red,Rt[1]),t.ansi[2]=nt(e.green,Rt[2]),t.ansi[3]=nt(e.yellow,Rt[3]),t.ansi[4]=nt(e.blue,Rt[4]),t.ansi[5]=nt(e.magenta,Rt[5]),t.ansi[6]=nt(e.cyan,Rt[6]),t.ansi[7]=nt(e.white,Rt[7]),t.ansi[8]=nt(e.brightBlack,Rt[8]),t.ansi[9]=nt(e.brightRed,Rt[9]),t.ansi[10]=nt(e.brightGreen,Rt[10]),t.ansi[11]=nt(e.brightYellow,Rt[11]),t.ansi[12]=nt(e.brightBlue,Rt[12]),t.ansi[13]=nt(e.brightMagenta,Rt[13]),t.ansi[14]=nt(e.brightCyan,Rt[14]),t.ansi[15]=nt(e.brightWhite,Rt[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]=nt(e.extendedAnsi[s],Rt[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()}}};mh=_t([xe(0,ti)],mh);function nt(e,t){if(e!==void 0)try{return pt.toColor(e)}catch{}return t}var h1=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)}},d1=class{constructor(){this._services=new h1,this._services.set(Wh,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=s0(e).sort((l,u)=>l.index-u.index),s=[];for(let l of n){let u=this._services.get(l.id);if(!u)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${l.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)}},f1={trace:0,debug:1,info:2,warn:3,error:4,off:5},p1="xterm.js: ",gh=class extends Xe{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=f1[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?"":p1)+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)}};gh=_t([xe(0,ti)],gh);var Fm=class extends Xe{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new be),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new be),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new be),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}},Ye=3,kt=Object.freeze(new no),Ea=0,nu=2,Gs=class S_{constructor(t,n,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Ye);let o=n||Di.fromCharData([0,zv,1,0]);for(let l=0;l<t;++l)this.setCell(l,o);this.length=t}get(t){let n=this._data[t*Ye+0],s=n&2097151;return[this._data[t*Ye+1],n&2097152?this._combined[t]:s?Fn(s):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,n){this._data[t*Ye+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*Ye+0]=t|2097152|n[2]<<22):this._data[t*Ye+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*Ye+0]>>22}hasWidth(t){return this._data[t*Ye+0]&12582912}getFg(t){return this._data[t*Ye+1]}getBg(t){return this._data[t*Ye+2]}hasContent(t){return this._data[t*Ye+0]&4194303}getCodePoint(t){let n=this._data[t*Ye+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*Ye+0]&2097152}getString(t){let n=this._data[t*Ye+0];return n&2097152?this._combined[t]:n&2097151?Fn(n&2097151):""}isProtected(t){return this._data[t*Ye+2]&536870912}loadCell(t,n){return Ea=t*Ye,n.content=this._data[Ea+0],n.fg=this._data[Ea+1],n.bg=this._data[Ea+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*Ye+0]=n.content,this._data[t*Ye+1]=n.fg,this._data[t*Ye+2]=n.bg}setCellFromCodepoint(t,n,s,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*Ye+0]=n|s<<22,this._data[t*Ye+1]=o.fg,this._data[t*Ye+2]=o.bg}addCodepointToCell(t,n,s){let o=this._data[t*Ye+0];o&2097152?this._combined[t]+=Fn(n):o&2097151?(this._combined[t]=Fn(o&2097151)+Fn(n),o&=-2097152,o|=2097152):o=n|1<<22,s&&(o&=-12582913,o|=s<<22),this._data[t*Ye+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 l=this.length-t-n-1;l>=0;--l)this.setCell(t+n+l,this.loadCell(t+l,o));for(let l=0;l<n;++l)this.setCell(t+l,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 l=0;l<this.length-t-n;++l)this.setCell(t+l,this.loadCell(t+n+l,o));for(let l=this.length-n;l<this.length;++l)this.setCell(l,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*nu<this._data.buffer.byteLength;let s=t*Ye;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 d=parseInt(o[u],10);d>=t&&delete this._combined[d]}let l=Object.keys(this._extendedAttrs);for(let u=0;u<l.length;u++){let d=parseInt(l[u],10);d>=t&&delete this._extendedAttrs[d]}}return this.length=t,s*4*nu<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*nu<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 S_(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*Ye+0]&4194303)return t+(this._data[t*Ye+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Ye+0]&4194303||this._data[t*Ye+2]&50331648)return t+(this._data[t*Ye+0]>>22);return 0}copyCellsFrom(t,n,s,o,l){let u=t._data;if(l)for(let p=o-1;p>=0;p--){for(let m=0;m<Ye;m++)this._data[(s+p)*Ye+m]=u[(n+p)*Ye+m];u[(n+p)*Ye+2]&268435456&&(this._extendedAttrs[s+p]=t._extendedAttrs[n+p])}else for(let p=0;p<o;p++){for(let m=0;m<Ye;m++)this._data[(s+p)*Ye+m]=u[(n+p)*Ye+m];u[(n+p)*Ye+2]&268435456&&(this._extendedAttrs[s+p]=t._extendedAttrs[n+p])}let d=Object.keys(t._combined);for(let p=0;p<d.length;p++){let m=parseInt(d[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 l="";for(;n<s;){let u=this._data[n*Ye+0],d=u&2097151,p=u&2097152?this._combined[n]:d?Fn(d):Hn;if(l+=p,o)for(let m=0;m<p.length;++m)o.push(n);n+=u>>22||1}return o&&o.push(n),l}};function m1(e,t,n,s,o,l){let u=[];for(let d=0;d<e.length-1;d++){let p=d,m=e.get(++p);if(!m.isWrapped)continue;let S=[e.get(d)];for(;p<e.length&&m.isWrapped;)S.push(m),m=e.get(++p);if(!l&&s>=d&&s<p){d+=S.length-1;continue}let w=0,y=io(S,w,t),_=1,b=0;for(;_<S.length;){let k=io(S,_,t),N=k-b,M=n-y,A=Math.min(N,M);S[w].copyCellsFrom(S[_],b,y,A,!1),y+=A,y===n&&(w++,y=0),b+=A,b===k&&(_++,b=0),y===0&&w!==0&&S[w-1].getWidth(n-1)===2&&(S[w].copyCellsFrom(S[w-1],n-1,y++,1,!1),S[w-1].setCell(n-1,o))}S[w].replaceCells(y,n,o);let C=0;for(let k=S.length-1;k>0&&(k>w||S[k].getTrimmedLength()===0);k--)C++;C>0&&(u.push(d+S.length-C),u.push(C)),d+=S.length-1}return u}function g1(e,t){let n=[],s=0,o=t[s],l=0;for(let u=0;u<e.length;u++)if(o===u){let d=t[++s];e.onDeleteEmitter.fire({index:u-l,amount:d}),u+=d-1,l+=d,o=t[++s]}else n.push(u);return{layout:n,countRemoved:l}}function v1(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 _1(e,t,n){let s=[],o=e.map((p,m)=>io(e,m,t)).reduce((p,m)=>p+m),l=0,u=0,d=0;for(;d<o;){if(o-d<n){s.push(o-d);break}l+=n;let p=io(e,u,t);l>p&&(l-=p,u++);let m=e[u].getWidth(l-1)===2;m&&l--;let S=m?n-1:n;s.push(S),d+=S}return s}function io(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 b_{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=b_._nextId++,this._onDispose=this.register(new be),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),hr(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};w_._nextId=1;var y1=w_,Dt={},or=Dt.B;Dt[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Dt.A={"#":"£"};Dt.B=void 0;Dt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Dt.C=Dt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Dt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Dt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Dt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Dt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Dt.E=Dt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Dt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Dt.H=Dt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Dt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Hm=4294967295,$m=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=kt.clone(),this.savedCharset=or,this.markers=[],this._nullCell=Di.fromCharData([0,zv,1,0]),this._whitespaceCell=Di.fromCharData([0,Hn,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new qa,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Fm(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 $a),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 $a),this._whitespaceCell}getBlankLine(e,t){return new Gs(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>Hm?Hm:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=kt);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 Fm(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(kt),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 l=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 Gs(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+l+1?(this.ybase--,l++,this.ydisp>0&&this.ydisp--):this.lines.push(new Gs(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),l&&(this.y+=l),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 l=0;l<this.lines.length;l++)s+=+this.lines.get(l).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=m1(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(kt),n);if(s.length>0){let o=g1(this.lines,s);v1(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=this.getNullCell(kt),o=n;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Gs(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(kt),o=[],l=0;for(let u=this.lines.length-1;u>=0;u--){let d=this.lines.get(u);if(!d||!d.isWrapped&&d.getTrimmedLength()<=e)continue;let p=[d];for(;d.isWrapped&&u>0;)d=this.lines.get(--u),p.unshift(d);if(!n){let A=this.ybase+this.y;if(A>=u&&A<u+p.length)continue}let m=p[p.length-1].getTrimmedLength(),S=_1(p,this._cols,e),w=S.length-p.length,y;this.ybase===0&&this.y!==this.lines.length-1?y=Math.max(0,this.y-this.lines.maxLength+w):y=Math.max(0,this.lines.length-this.lines.maxLength+w);let _=[];for(let A=0;A<w;A++){let B=this.getBlankLine(kt,!0);_.push(B)}_.length>0&&(o.push({start:u+p.length+l,newLines:_}),l+=_.length),p.push(..._);let b=S.length-1,C=S[b];C===0&&(b--,C=S[b]);let k=p.length-w-1,N=m;for(;k>=0;){let A=Math.min(N,C);if(p[b]===void 0)break;if(p[b].copyCellsFrom(p[k],N-A,C-A,A,!0),C-=A,C===0&&(b--,C=S[b]),N-=A,N===0){k--;let B=Math.max(k,0);N=io(p,B,this._cols)}}for(let A=0;A<p.length;A++)S[A]<e&&p[A].setCell(S[A],s);let M=w-y;for(;M-- >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+l)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+w,this.ybase+t-1)}if(o.length>0){let u=[],d=[];for(let C=0;C<this.lines.length;C++)d.push(this.lines.get(C));let p=this.lines.length,m=p-1,S=0,w=o[S];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+l);let y=0;for(let C=Math.min(this.lines.maxLength-1,p+l-1);C>=0;C--)if(w&&w.start>m+y){for(let k=w.newLines.length-1;k>=0;k--)this.lines.set(C--,w.newLines[k]);C++,u.push({index:m+1,amount:w.newLines.length}),y+=w.newLines.length,w=o[++S]}else this.lines.set(C,d[m--]);let _=0;for(let C=u.length-1;C>=0;C--)u[C].index+=_,this.lines.onInsertEmitter.fire(u[C]),_+=u[C].amount;let b=Math.max(0,p+l-this.lines.maxLength);b>0&&this.lines.onTrimEmitter.fire(b)}}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 y1(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)}},S1=class extends Xe{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new be),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 $m(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new $m(!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)}},C_=2,k_=1,vh=class extends Xe{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new be),this.onResize=this._onResize.event,this._onScroll=this._register(new be),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,C_),this.rows=Math.max(e.rawOptions.rows||0,k_),this.buffers=this._register(new S1(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,l=n.ybase+n.scrollBottom;if(n.scrollTop===0){let u=n.lines.isFull;l===n.lines.length-1?u?n.lines.recycle().copyFrom(s):n.lines.push(s.clone()):n.lines.splice(l+1,0,s.clone()),u?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let u=l-o+1;n.lines.shiftElements(o+1,u-1,-1),n.lines.set(l,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))}};vh=_t([xe(0,ti)],vh);var $r={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:Ka,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},w1=["normal","bold","100","200","300","400","500","600","700","800","900"],b1=class extends Xe{constructor(e){super(),this._onOptionChange=this._register(new be),this.onOptionChange=this._onOptionChange.event;let t={...$r};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(ut(()=>{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 $r))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,s)=>{if(!(n in $r))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=$r[e]),!C1(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=$r[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=w1.includes(t)?t:$r[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 C1(e){return e==="block"||e==="underline"||e==="bar"}function Qs(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]&&Qs(e[s],t-1);return n}var Wm=Object.freeze({insertMode:!1}),Um=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),_h=class extends Xe{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 be),this.onData=this._onData.event,this._onUserInput=this._register(new be),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new be),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new be),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Qs(Wm),this.decPrivateModes=Qs(Um)}reset(){this.modes=Qs(Wm),this.decPrivateModes=Qs(Um)}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))}};_h=_t([xe(0,ei),xe(1,Uv),xe(2,ti)],_h);var Km={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 ru(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 su=String.fromCharCode,qm={DEFAULT:e=>{let t=[ru(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${su(t[0])}${su(t[1])}${su(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${ru(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${ru(e,!0)};${e.x};${e.y}${t}`}},yh=class extends Xe{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 be),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Km))this.addProtocol(s,Km[s]);for(let s of Object.keys(qm))this.addEncoding(s,qm[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)}};yh=_t([xe(0,ei),xe(1,pr),xe(2,ti)],yh);var ou=[[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]],k1=[[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]],Pt;function x1(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 E1=class{constructor(){if(this.version="6",!Pt){Pt=new Uint8Array(65536),Pt.fill(1),Pt[0]=0,Pt.fill(0,1,32),Pt.fill(0,127,160),Pt.fill(2,4352,4448),Pt[9001]=2,Pt[9002]=2,Pt.fill(2,11904,42192),Pt[12351]=1,Pt.fill(2,44032,55204),Pt.fill(2,63744,64256),Pt.fill(2,65040,65050),Pt.fill(2,65072,65136),Pt.fill(2,65280,65377),Pt.fill(2,65504,65511);for(let e=0;e<ou.length;++e)Pt.fill(0,ou[e][0],ou[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Pt[e]:x1(e,k1)?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=lr.extractWidth(t);o===0?s=!1:o>n&&(n=o)}return lr.createPropertyValue(0,n,s)}},lr=class Ba{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new be,this.onChange=this._onChange.event;let t=new E1;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 l=0;l<o;++l){let u=t.charCodeAt(l);if(55296<=u&&u<=56319){if(++l>=o)return n+this.wcwidth(u);let m=t.charCodeAt(l);56320<=m&&m<=57343?u=(u-55296)*1024+m-56320+65536:n+=this.wcwidth(m)}let d=this.charProperties(u,s),p=Ba.extractWidth(d);Ba.extractShouldJoin(d)&&(p-=Ba.extractWidth(s)),n+=p,s=d}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},N1=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 Vm(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 $s=2147483647,R1=256,x_=class Sh{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>R1)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 Sh;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 l=0;l<o.length;++l)n.addSubParam(o[l]);else n.addParam(o)}return n}clone(){let t=new Sh(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>$s?$s: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>$s?$s: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,$s):t}},Ws=[],P1=class{constructor(){this._state=0,this._active=Ws,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=Ws}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=Ws,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Ws,!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",Ja(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=Ws,this._id=-1,this._state=0}}},vi=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+=Ja(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}},Us=[],D1=class{constructor(){this._handlers=Object.create(null),this._active=Us,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Us}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=Us,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Us,!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",Ja(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=Us,this._ident=0}},Js=new x_;Js.addParam(0);var Ym=class{constructor(e){this._handler=e,this._data="",this._params=Js,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Js,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Ja(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=Js,this._data="",this._hitLimit=!1,n));return this._params=Js,this._data="",this._hitLimit=!1,t}},L1=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,s){this.table[t<<8|e]=n<<4|s}addMany(e,t,n,s){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=n<<4|s}},Pi=160,M1=(function(){let e=new L1(4095),t=Array.apply(null,Array(256)).map((d,p)=>p),n=(d,p)=>t.slice(d,p),s=n(32,127),o=n(0,24);o.push(25),o.push.apply(o,n(28,32));let l=n(0,14),u;e.setDefault(1,0),e.addMany(s,0,2,0);for(u in l)e.addMany([24,26,153,154],u,3,0),e.addMany(n(128,144),u,3,0),e.addMany(n(144,152),u,3,0),e.add(156,u,0,0),e.add(27,u,11,1),e.add(157,u,4,8),e.addMany([152,158,159],u,0,7),e.add(155,u,11,3),e.add(144,u,11,9);return e.addMany(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(o,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(o,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(o,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Pi,0,2,0),e.add(Pi,8,5,8),e.add(Pi,6,0,6),e.add(Pi,11,0,11),e.add(Pi,13,13,13),e})(),j1=class extends Xe{constructor(e=M1){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new x_,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(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(ut(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new P1),this._dcsParser=this._register(new D1),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 l=e.intermediates.charCodeAt(o);if(32>l||l>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=l}}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,l=0,u;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,l=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 d=this._parseStack.handlers,p=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&p>-1){for(;p>=0&&(u=d[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=d[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,l=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let d=l;d<t;++d){switch(s=e[d],o=this._transitions.table[this.currentState<<8|(s<160?s:Pi)],o>>4){case 2:for(let y=d+1;;++y){if(y>=t||(s=e[y])<32||s>126&&s<Pi){this._printHandler(e,d,y),d=y-1;break}if(++y>=t||(s=e[y])<32||s>126&&s<Pi){this._printHandler(e,d,y),d=y-1;break}if(++y>=t||(s=e[y])<32||s>126&&s<Pi){this._printHandler(e,d,y),d=y-1;break}if(++y>=t||(s=e[y])<32||s>126&&s<Pi){this._printHandler(e,d,y),d=y-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:d,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,d),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(++d<t&&(s=e[d])>47&&s<60);d--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let S=this._escHandlers[this._collect<<8|s],w=S?S.length-1:-1;for(;w>=0&&(u=S[w](),u!==!0);w--)if(u instanceof Promise)return this._preserveStack(4,S,w,o,d),u;w<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let y=d+1;;++y)if(y>=t||(s=e[y])===24||s===26||s===27||s>127&&s<Pi){this._dcsParser.put(e,d,y),d=y-1;break}break;case 14:if(u=this._dcsParser.unhook(s!==24&&s!==26),u)return this._preserveStack(6,[],0,o,d),u;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let y=d+1;;y++)if(y>=t||(s=e[y])<32||s>127&&s<Pi){this._oscParser.put(e,d,y),d=y-1;break}break;case 6:if(u=this._oscParser.end(s!==24&&s!==26),u)return this._preserveStack(5,[],0,o,d),u;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},T1=/^([\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})$/,A1=/^[\da-f]+$/;function Xm(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=T1.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),A1.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 l=parseInt(t.slice(n*o,n*o+n),16);s[o]=n===1?l<<4:n===2?l:n===3?l>>4:l>>8}return s}}function au(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 B1(e,t=16){let[n,s,o]=e;return`rgb:${au(n,t)}/${au(s,t)}/${au(o,t)}`}var I1={"(":0,")":1,"*":2,"+":3,"-":1,".":2},On=131072,Gm=10;function Qm(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 Jm=5e3,Zm=0,O1=class extends Xe{constructor(e,t,n,s,o,l,u,d,p=new j1){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=s,this._optionsService=o,this._oscLinkService=l,this._coreMouseService=u,this._unicodeService=d,this._parser=p,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new n0,this._utf8Decoder=new r0,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=kt.clone(),this._eraseAttrDataInternal=kt.clone(),this._onRequestBell=this._register(new be),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new be),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new be),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new be),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new be),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new be),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new be),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new be),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new be),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new be),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new be),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new be),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new be),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 wh(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(m=>this._activeBuffer=m.activeBuffer)),this._parser.setCsiHandlerFallback((m,S)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(m),params:S.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,S,w)=>{this._logService.debug("Unknown OSC code: ",{identifier:m,action:S,data:w})}),this._parser.setDcsHandlerFallback((m,S,w)=>{S==="HOOK"&&(w=w.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(m),action:S,payload:w})}),this._parser.setPrintHandler((m,S,w)=>this.print(m,S,w)),this._parser.registerCsiHandler({final:"@"},m=>this.insertChars(m)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},m=>this.scrollLeft(m)),this._parser.registerCsiHandler({final:"A"},m=>this.cursorUp(m)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},m=>this.scrollRight(m)),this._parser.registerCsiHandler({final:"B"},m=>this.cursorDown(m)),this._parser.registerCsiHandler({final:"C"},m=>this.cursorForward(m)),this._parser.registerCsiHandler({final:"D"},m=>this.cursorBackward(m)),this._parser.registerCsiHandler({final:"E"},m=>this.cursorNextLine(m)),this._parser.registerCsiHandler({final:"F"},m=>this.cursorPrecedingLine(m)),this._parser.registerCsiHandler({final:"G"},m=>this.cursorCharAbsolute(m)),this._parser.registerCsiHandler({final:"H"},m=>this.cursorPosition(m)),this._parser.registerCsiHandler({final:"I"},m=>this.cursorForwardTab(m)),this._parser.registerCsiHandler({final:"J"},m=>this.eraseInDisplay(m,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},m=>this.eraseInDisplay(m,!0)),this._parser.registerCsiHandler({final:"K"},m=>this.eraseInLine(m,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},m=>this.eraseInLine(m,!0)),this._parser.registerCsiHandler({final:"L"},m=>this.insertLines(m)),this._parser.registerCsiHandler({final:"M"},m=>this.deleteLines(m)),this._parser.registerCsiHandler({final:"P"},m=>this.deleteChars(m)),this._parser.registerCsiHandler({final:"S"},m=>this.scrollUp(m)),this._parser.registerCsiHandler({final:"T"},m=>this.scrollDown(m)),this._parser.registerCsiHandler({final:"X"},m=>this.eraseChars(m)),this._parser.registerCsiHandler({final:"Z"},m=>this.cursorBackwardTab(m)),this._parser.registerCsiHandler({final:"`"},m=>this.charPosAbsolute(m)),this._parser.registerCsiHandler({final:"a"},m=>this.hPositionRelative(m)),this._parser.registerCsiHandler({final:"b"},m=>this.repeatPrecedingCharacter(m)),this._parser.registerCsiHandler({final:"c"},m=>this.sendDeviceAttributesPrimary(m)),this._parser.registerCsiHandler({prefix:">",final:"c"},m=>this.sendDeviceAttributesSecondary(m)),this._parser.registerCsiHandler({final:"d"},m=>this.linePosAbsolute(m)),this._parser.registerCsiHandler({final:"e"},m=>this.vPositionRelative(m)),this._parser.registerCsiHandler({final:"f"},m=>this.hVPosition(m)),this._parser.registerCsiHandler({final:"g"},m=>this.tabClear(m)),this._parser.registerCsiHandler({final:"h"},m=>this.setMode(m)),this._parser.registerCsiHandler({prefix:"?",final:"h"},m=>this.setModePrivate(m)),this._parser.registerCsiHandler({final:"l"},m=>this.resetMode(m)),this._parser.registerCsiHandler({prefix:"?",final:"l"},m=>this.resetModePrivate(m)),this._parser.registerCsiHandler({final:"m"},m=>this.charAttributes(m)),this._parser.registerCsiHandler({final:"n"},m=>this.deviceStatus(m)),this._parser.registerCsiHandler({prefix:"?",final:"n"},m=>this.deviceStatusPrivate(m)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},m=>this.softReset(m)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},m=>this.setCursorStyle(m)),this._parser.registerCsiHandler({final:"r"},m=>this.setScrollRegion(m)),this._parser.registerCsiHandler({final:"s"},m=>this.saveCursor(m)),this._parser.registerCsiHandler({final:"t"},m=>this.windowOptions(m)),this._parser.registerCsiHandler({final:"u"},m=>this.restoreCursor(m)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},m=>this.insertColumns(m)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},m=>this.deleteColumns(m)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},m=>this.selectProtected(m)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},m=>this.requestMode(m,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},m=>this.requestMode(m,!1)),this._parser.setExecuteHandler(he.BEL,()=>this.bell()),this._parser.setExecuteHandler(he.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(he.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(he.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(he.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(he.BS,()=>this.backspace()),this._parser.setExecuteHandler(he.HT,()=>this.tab()),this._parser.setExecuteHandler(he.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(he.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Ta.IND,()=>this.index()),this._parser.setExecuteHandler(Ta.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Ta.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new vi(m=>(this.setTitle(m),this.setIconName(m),!0))),this._parser.registerOscHandler(1,new vi(m=>this.setIconName(m))),this._parser.registerOscHandler(2,new vi(m=>this.setTitle(m))),this._parser.registerOscHandler(4,new vi(m=>this.setOrReportIndexedColor(m))),this._parser.registerOscHandler(8,new vi(m=>this.setHyperlink(m))),this._parser.registerOscHandler(10,new vi(m=>this.setOrReportFgColor(m))),this._parser.registerOscHandler(11,new vi(m=>this.setOrReportBgColor(m))),this._parser.registerOscHandler(12,new vi(m=>this.setOrReportCursorColor(m))),this._parser.registerOscHandler(104,new vi(m=>this.restoreIndexedColor(m))),this._parser.registerOscHandler(110,new vi(m=>this.restoreFgColor(m))),this._parser.registerOscHandler(111,new vi(m=>this.restoreBgColor(m))),this._parser.registerOscHandler(112,new vi(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 Dt)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 Ym((m,S)=>this.requestStatusString(m,S)))}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"),Jm))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Jm} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,s=this._activeBuffer.x,o=this._activeBuffer.y,l=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>On&&(l=this._parseStack.position+On)}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<On&&(this._parseBuffer=new Uint32Array(Math.min(e.length,On))),u||this._dirtyRowTracker.clearRange(),e.length>On)for(let m=l;m<e.length;m+=On){let S=m+On<e.length?m+On:e.length,w=typeof e=="string"?this._stringDecoder.decode(e.substring(m,S),this._parseBuffer):this._utf8Decoder.decode(e.subarray(m,S),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,w))return this._preserveStack(s,o,w,m),this._logSlowResolvingAsync(n),n}else if(!u){let m=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,m))return this._preserveStack(s,o,m,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==s||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let d=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(d,this._bufferService.rows-1)})}print(e,t,n){let s,o,l=this._charsetService.charset,u=this._optionsService.rawOptions.screenReaderMode,d=this._bufferService.cols,p=this._coreService.decPrivateModes.wraparound,m=this._coreService.modes.insertMode,S=this._curAttrData,w=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&w.getWidth(this._activeBuffer.x-1)===2&&w.setCellFromCodepoint(this._activeBuffer.x-1,0,1,S);let y=this._parser.precedingJoinState;for(let _=t;_<n;++_){if(s=e[_],s<127&&l){let N=l[String.fromCharCode(s)];N&&(s=N.charCodeAt(0))}let b=this._unicodeService.charProperties(s,y);o=lr.extractWidth(b);let C=lr.extractShouldJoin(b),k=C?lr.extractWidth(y):0;if(y=b,u&&this._onA11yChar.fire(Fn(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-k>d){if(p){let N=w,M=this._activeBuffer.x-k;for(this._activeBuffer.x=k,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),w=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),k>0&&w instanceof Gs&&w.copyCellsFrom(N,M,0,k,!1);M<d;)N.setCellFromCodepoint(M++,0,1,S)}else if(this._activeBuffer.x=d-1,o===2)continue}if(C&&this._activeBuffer.x){let N=w.getWidth(this._activeBuffer.x-1)?1:2;w.addCodepointToCell(this._activeBuffer.x-N,s,o);for(let M=o-k;--M>=0;)w.setCellFromCodepoint(this._activeBuffer.x++,0,0,S);continue}if(m&&(w.insertCells(this._activeBuffer.x,o-k,this._activeBuffer.getNullCell(S)),w.getWidth(d-1)===2&&w.setCellFromCodepoint(d-1,0,1,S)),w.setCellFromCodepoint(this._activeBuffer.x++,s,o,S),o>0)for(;--o;)w.setCellFromCodepoint(this._activeBuffer.x++,0,0,S)}this._parser.precedingJoinState=y,this._activeBuffer.x<d&&n-t>0&&w.getWidth(this._activeBuffer.x)===0&&!w.hasContent(this._activeBuffer.x)&&w.setCellFromCodepoint(this._activeBuffer.x,0,1,S),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>Qm(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Ym(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new vi(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 l=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);l.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),o),s&&(l.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(kt));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=lr.extractWidth(t),o=this._activeBuffer.x-s,l=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),u=new Uint32Array(l.length*n),d=0;for(let m=0;m<l.length;){let S=l.codePointAt(m)||0;u[d++]=S,m+=S>65535?2:1}let p=d;for(let m=1;m<n;++m)u.copyWithin(p,0,d),p+=d;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(he.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(he.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(he.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(he.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(he.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,or),this._charsetService.setgCharset(1,or),this._charsetService.setgCharset(2,or),this._charsetService.setgCharset(3,or);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){(C=>(C[C.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",C[C.SET=1]="SET",C[C.RESET=2]="RESET",C[C.PERMANENTLY_SET=3]="PERMANENTLY_SET",C[C.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let s=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:l}=this._coreMouseService,u=this._coreService,{buffers:d,cols:p}=this._bufferService,{active:m,alt:S}=d,w=this._optionsService.rawOptions,y=(C,k)=>(u.triggerDataEvent(`${he.ESC}[${t?"":"?"}${C};${k}$y`),!0),_=C=>C?1:2,b=e.params[0];return t?b===2?y(b,4):b===4?y(b,_(u.modes.insertMode)):b===12?y(b,3):b===20?y(b,_(w.convertEol)):y(b,0):b===1?y(b,_(s.applicationCursorKeys)):b===3?y(b,w.windowOptions.setWinLines?p===80?2:p===132?1:0:0):b===6?y(b,_(s.origin)):b===7?y(b,_(s.wraparound)):b===8?y(b,3):b===9?y(b,_(o==="X10")):b===12?y(b,_(w.cursorBlink)):b===25?y(b,_(!u.isCursorHidden)):b===45?y(b,_(s.reverseWraparound)):b===66?y(b,_(s.applicationKeypad)):b===67?y(b,4):b===1e3?y(b,_(o==="VT200")):b===1002?y(b,_(o==="DRAG")):b===1003?y(b,_(o==="ANY")):b===1004?y(b,_(s.sendFocus)):b===1005?y(b,4):b===1006?y(b,_(l==="SGR")):b===1015?y(b,4):b===1016?y(b,_(l==="SGR_PIXELS")):b===1048?y(b,1):b===47||b===1047||b===1049?y(b,_(m===S)):b===2004?y(b,_(s.bracketedPasteMode)):b===2026?y(b,_(s.synchronizedOutput)):y(b,0)}_updateAttrColor(e,t,n,s,o){return t===2?(e|=50331648,e&=-16777216,e|=no.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,l=0;do{if(s[l+o]=e.params[t+l],e.hasSubParams(t+l)){let u=e.getSubParams(t+l),d=0;do s[1]===5&&(o=1),s[l+d+1+o]=u[d];while(++d<u.length&&d+l+1+o<s.length);break}if(s[1]===5&&l+o>=2||s[1]===2&&l+o>=5)break;s[1]&&(o=1)}while(++l+t<e.length&&l+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 l}_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=kt.fg,e.bg=kt.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|=kt.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=kt.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|=kt.fg&16777215,s.bg&=-67108864,s.bg|=kt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${he.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${he.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(`${he.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=kt.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(!Qm(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(`${he.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Gm&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Gm&&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 l=parseInt(s);if(eg(l))if(o==="?")t.push({type:0,index:l});else{let u=Xm(o);u&&t.push({type:1,index:l,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(l=>l.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=Xm(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]);eg(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,or),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(I1[e[0]],Dt[e[1]]||or),!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=kt.clone(),this._eraseAttrDataInternal=kt.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(`${he.ESC}${u}${he.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)}},wh=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&&(Zm=e,e=t,t=Zm),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};wh=_t([xe(0,ei)],wh);function eg(e){return 0<=e&&e<256}var z1=5e7,tg=12,F1=50,H1=class extends Xe{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 be),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>z1)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=d=>performance.now()-n>=tg?setTimeout(()=>this._innerWrite(0,d)):this._innerWrite(n,d);o.catch(d=>(queueMicrotask(()=>{throw d}),Promise.resolve(!1))).then(u);return}let l=this._callbacks[this._bufferOffset];if(l&&l(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-n>=tg)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>F1&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},bh=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let d=t.addMarker(t.ybase+t.y),p={data:e,id:this._nextId++,lines:[d]};return d.onDispose(()=>this._removeMarkerFromLink(p,d)),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 l=t.addMarker(t.ybase+t.y),u={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(u,l)),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);n.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(n,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};bh=_t([xe(0,ei)],bh);var ig=!1,$1=class extends Xe{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Gr),this._onBinary=this._register(new be),this.onBinary=this._onBinary.event,this._onData=this._register(new be),this.onData=this._onData.event,this._onLineFeed=this._register(new be),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new be),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new be),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new be),this._instantiationService=new d1,this.optionsService=this._register(new b1(e)),this._instantiationService.setService(ti,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(vh)),this._instantiationService.setService(ei,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(gh)),this._instantiationService.setService(Uv,this._logService),this.coreService=this._register(this._instantiationService.createInstance(_h)),this._instantiationService.setService(pr,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(yh)),this._instantiationService.setService(Wv,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(lr)),this._instantiationService.setService(l0,this.unicodeService),this._charsetService=this._instantiationService.createInstance(N1),this._instantiationService.setService(a0,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(bh),this._instantiationService.setService(Kv,this._oscLinkService),this._inputHandler=this._register(new O1(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ut.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ut.forward(this._bufferService.onResize,this._onResize)),this._register(Ut.forward(this.coreService.onData,this._onData)),this._register(Ut.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 H1((t,n)=>this._inputHandler.parse(t,n))),this._register(Ut.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new be),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&&!ig&&(this._logService.warn("writeSync is unreliable and will be removed soon."),ig=!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,C_),t=Math.max(t,k_),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(Vm.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Vm(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ut(()=>{for(let t of e)t.dispose()})}}},W1={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 U1(e,t,n,s){var u;let o={type:0,cancel:!1,key:void 0},l=(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=he.ESC+"OA":o.key=he.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=he.ESC+"OD":o.key=he.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=he.ESC+"OC":o.key=he.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=he.ESC+"OB":o.key=he.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":he.DEL,e.altKey&&(o.key=he.ESC+o.key);break;case 9:if(e.shiftKey){o.key=he.ESC+"[Z";break}o.key=he.HT,o.cancel=!0;break;case 13:o.key=e.altKey?he.ESC+he.CR:he.CR,o.cancel=!0;break;case 27:o.key=he.ESC,e.altKey&&(o.key=he.ESC+he.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;l?o.key=he.ESC+"[1;"+(l+1)+"D":t?o.key=he.ESC+"OD":o.key=he.ESC+"[D";break;case 39:if(e.metaKey)break;l?o.key=he.ESC+"[1;"+(l+1)+"C":t?o.key=he.ESC+"OC":o.key=he.ESC+"[C";break;case 38:if(e.metaKey)break;l?o.key=he.ESC+"[1;"+(l+1)+"A":t?o.key=he.ESC+"OA":o.key=he.ESC+"[A";break;case 40:if(e.metaKey)break;l?o.key=he.ESC+"[1;"+(l+1)+"B":t?o.key=he.ESC+"OB":o.key=he.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=he.ESC+"[2~");break;case 46:l?o.key=he.ESC+"[3;"+(l+1)+"~":o.key=he.ESC+"[3~";break;case 36:l?o.key=he.ESC+"[1;"+(l+1)+"H":t?o.key=he.ESC+"OH":o.key=he.ESC+"[H";break;case 35:l?o.key=he.ESC+"[1;"+(l+1)+"F":t?o.key=he.ESC+"OF":o.key=he.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=he.ESC+"[5;"+(l+1)+"~":o.key=he.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=he.ESC+"[6;"+(l+1)+"~":o.key=he.ESC+"[6~";break;case 112:l?o.key=he.ESC+"[1;"+(l+1)+"P":o.key=he.ESC+"OP";break;case 113:l?o.key=he.ESC+"[1;"+(l+1)+"Q":o.key=he.ESC+"OQ";break;case 114:l?o.key=he.ESC+"[1;"+(l+1)+"R":o.key=he.ESC+"OR";break;case 115:l?o.key=he.ESC+"[1;"+(l+1)+"S":o.key=he.ESC+"OS";break;case 116:l?o.key=he.ESC+"[15;"+(l+1)+"~":o.key=he.ESC+"[15~";break;case 117:l?o.key=he.ESC+"[17;"+(l+1)+"~":o.key=he.ESC+"[17~";break;case 118:l?o.key=he.ESC+"[18;"+(l+1)+"~":o.key=he.ESC+"[18~";break;case 119:l?o.key=he.ESC+"[19;"+(l+1)+"~":o.key=he.ESC+"[19~";break;case 120:l?o.key=he.ESC+"[20;"+(l+1)+"~":o.key=he.ESC+"[20~";break;case 121:l?o.key=he.ESC+"[21;"+(l+1)+"~":o.key=he.ESC+"[21~";break;case 122:l?o.key=he.ESC+"[23;"+(l+1)+"~":o.key=he.ESC+"[23~";break;case 123:l?o.key=he.ESC+"[24;"+(l+1)+"~":o.key=he.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=he.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=he.DEL:e.keyCode===219?o.key=he.ESC:e.keyCode===220?o.key=he.FS:e.keyCode===221&&(o.key=he.GS);else if((!n||s)&&e.altKey&&!e.metaKey){let d=(u=W1[e.keyCode])==null?void 0:u[e.shiftKey?1:0];if(d)o.key=he.ESC+d;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=he.ESC+m}else if(e.keyCode===32)o.key=he.ESC+(e.ctrlKey?he.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let p=e.code.slice(3,4);e.shiftKey||(p=p.toLowerCase()),o.key=he.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=he.US),e.key==="@"&&(o.key=he.NUL));break}return o}var wt=0,K1=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new qa,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new qa,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,l)=>this._getKey(o)-this._getKey(l)),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||(wt=this._search(t),wt===-1)||this._getKey(this._array[wt])!==t)return!1;do if(this._array[wt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(wt),!0;while(++wt<this._array.length&&this._getKey(this._array[wt])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,l)=>o-l),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&&(wt=this._search(e),!(wt<0||wt>=this._array.length)&&this._getKey(this._array[wt])===e))do yield this._array[wt];while(++wt<this._array.length&&this._getKey(this._array[wt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(wt=this._search(e),!(wt<0||wt>=this._array.length)&&this._getKey(this._array[wt])===e))do t(this._array[wt]);while(++wt<this._array.length&&this._getKey(this._array[wt])===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}},lu=0,ng=0,q1=class extends Xe{constructor(){super(),this._decorations=new K1(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new be),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new be),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ut(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new V1(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 l of this._decorations.getKeyIterator(t))s=l.options.x??0,o=s+(l.options.width??1),e>=s&&e<o&&(!n||(l.options.layer??"bottom")===n)&&(yield l)}forEachDecorationAtCell(e,t,n,s){this._decorations.forEachByKey(t,o=>{lu=o.options.x??0,ng=lu+(o.options.width??1),e>=lu&&e<ng&&(!n||(o.options.layer??"bottom")===n)&&s(o)})}},V1=class extends $n{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new be),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new be),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=pt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=pt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},Y1=1e3,X1=class{constructor(e,t=Y1){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,l=this._debounceThresholdMS-o;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},l)}}_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)}},rg=20,Va=class extends Xe{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 l=0;l<this._terminal.rows;l++)this._rowElements[l]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[l]);if(this._topBoundaryFocusListener=l=>this._handleBoundaryFocus(l,0),this._bottomBoundaryFocusListener=l=>this._handleBoundaryFocus(l,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 X1(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(l=>this._handleResize(l.rows))),this._register(this._terminal.onRender(l=>this._refreshRows(l.start,l.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(l=>this._handleChar(l))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
64
|
+
`))),this._register(this._terminal.onA11yTab(l=>this._handleTab(l))),this._register(this._terminal.onKey(l=>this._handleKey(l.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register($e(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(ut(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<rg+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
65
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===rg+1&&(this._liveRegion.textContent+=$u.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 l=n.lines.get(n.ydisp+o),u=[],d=(l==null?void 0:l.translateToString(!0,void 0,void 0,u))||"",p=(n.ydisp+o+1).toString(),m=this._rowElements[o];m&&(d.length===0?(m.textContent=" ",this._rowColumns.set(m,[0,1])):(m.textContent=d,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"),l=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===l||e.relatedTarget!==s)return;let u,d;if(t===0?(u=n,d=this._rowElements.pop(),this._rowContainer.removeChild(d)):(u=this._rowElements.shift(),d=n,this._rowContainer.removeChild(u)),u.removeEventListener("focus",this._topBoundaryFocusListener),d.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 d;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:((d=s.textContent)==null?void 0:d.length)??0}),!this._rowContainer.contains(n.node))return;let o=({node:p,offset:m})=>{let S=p instanceof Text?p.parentNode:p,w=parseInt(S==null?void 0:S.getAttribute("aria-posinset"),10)-1;if(isNaN(w))return console.warn("row is invalid. Race condition?"),null;let y=this._rowColumns.get(S);if(!y)return console.warn("columns is null. Race condition?"),null;let _=m<y.length?y[m]:y.slice(-1)[0]+1;return _>=this._terminal.cols&&(++w,_=0),{row:w,column:_}},l=o(t),u=o(n);if(!(!l||!u)){if(l.row>u.row||l.row===u.row&&l.column>=u.column)throw new Error("invalid range");this._terminal.select(l.column,l.row,(u.row-l.row)*this._terminal.cols-l.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,l;e.style.transform="";let t=e.getBoundingClientRect().width,n=(l=(o=this._rowColumns.get(e))==null?void 0:o.slice(-1))==null?void 0:l[0];if(!n)return;let s=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};Va=_t([xe(1,Wh),xe(2,mn),xe(3,gn)],Va);var Ch=class extends Xe{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 be),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new be),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ut(()=>{var l;hr(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(l=this._activeProviderReplies)==null||l.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register($e(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register($e(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register($e(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register($e(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(l=>{l==null||l.forEach(u=>{u.link.dispose&&u.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[l,u]of this._linkProviderService.linkProviders.entries())t?(o=this._activeProviderReplies)!=null&&o.get(l)&&(n=this._checkLinkProviderResult(l,e,n)):u.provideLinks(e.y,d=>{var m,S;if(this._isMouseOut)return;let p=d==null?void 0:d.map(w=>({link:w}));(m=this._activeProviderReplies)==null||m.set(l,p),n=this._checkLinkProviderResult(l,e,n),((S=this._activeProviderReplies)==null?void 0:S.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 l=0;l<o.length;l++){let u=o[l],d=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=d;m<=p;m++){if(n.has(m)){o.splice(l--,1);break}n.add(m)}}}}_checkLinkProviderResult(e,t,n){var l;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(d=>this._linkAtPosition(d.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 d=(l=this._activeProviderReplies.get(u))==null?void 0:l.find(p=>this._linkAtPosition(p.link,t));if(d){n=!0,this._handleNewLink(d);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&&G1(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,hr(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,l;(s=this._currentLink)!=null&&s.state&&((l=(o=this._currentLink)==null?void 0:o.state)==null?void 0:l.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 l=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);l&&this._askForLink(l,!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}}};Ch=_t([xe(1,Uh),xe(2,gn),xe(3,ei),xe(4,Vv)],Ch);function G1(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 Q1=class extends $1{constructor(e={}){super(e),this._linkifier=this._register(new Gr),this.browser=d_,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Gr),this._onCursorMove=this._register(new be),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new be),this.onKey=this._onKey.event,this._onRender=this._register(new be),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new be),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new be),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new be),this.onBell=this._onBell.event,this._onFocus=this._register(new be),this._onBlur=this._register(new be),this._onA11yCharEmitter=this._register(new be),this._onA11yTabEmitter=this._register(new be),this._onWillOpen=this._register(new be),this._setup(),this._decorationService=this._instantiationService.createInstance(q1),this._instantiationService.setService(ro,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Fb),this._instantiationService.setService(Vv,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Uu)),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(Ut.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ut.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ut.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ut.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(ut(()=>{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=lt.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${he.ESC}]${s};${B1(o)}${u_.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(l=>l.ansi[t.index]=xt.toColor(...t.color));else{let l=n;this._themeService.modifyColors(u=>u[l]=xt.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(Va,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(he.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(he.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),l=this._renderService.dimensions.css.cell.width*o,u=this.buffer.y*this._renderService.dimensions.css.cell.height,d=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=d+"px",this.textarea.style.top=u+"px",this.textarea.style.width=l+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register($e(this.element,"copy",t=>{this.hasSelection()&&t0(t,this._selectionService)}));let e=t=>i0(t,this.textarea,this.coreService,this.optionsService);this._register($e(this.textarea,"paste",e)),this._register($e(this.element,"paste",e)),f_?this._register($e(this.element,"mousedown",t=>{t.button===2&&pm(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register($e(this.element,"contextmenu",t=>{pm(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Jh&&this._register($e(this.element,"auxclick",t=>{t.button===1&&Ov(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register($e(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register($e(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register($e(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register($e(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register($e(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register($e(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register($e(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($e(this.screenElement,"mousemove",l=>this.updateCursorStyle(l))),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",Hu.get()),g_||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Ob,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(mn,this._coreBrowserService),this._register($e(this.textarea,"focus",l=>this._handleTextAreaFocus(l))),this._register($e(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(hh,this._document,this._helperContainer),this._instantiationService.setService(Za,this._charSizeService),this._themeService=this._instantiationService.createInstance(mh),this._instantiationService.setService(Jr,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Ua),this._instantiationService.setService(qv,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(fh,this.rows,this.screenElement)),this._instantiationService.setService(gn,this._renderService),this._register(this._renderService.onRenderedViewportChange(l=>this._onRender.fire(l))),this.onResize(l=>this._renderService.resize(l.cols,l.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(lh,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(dh),this._instantiationService.setService(Uh,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Ch,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(oh,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(l=>{super.scrollLines(l,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(ph,this.element,this.screenElement,s)),this._instantiationService.setService(u0,this._selectionService),this._register(this._selectionService.onRequestScrollLines(l=>this.scrollLines(l.amount,l.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(l=>this._renderService.handleSelectionChanged(l.start,l.end,l.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(l=>{this.textarea.value=l,this.textarea.focus(),this.textarea.select()})),this._register(Ut.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var l;this._selectionService.refresh(),(l=this._viewport)==null||l.queueSync()})),this._register(this._instantiationService.createInstance(ah,this.screenElement)),this._register($e(this.element,"mousedown",l=>this._selectionService.handleMouseDown(l))),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(Va,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",l=>this._handleScreenReaderModeOptionChange(l))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Wa,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",l=>{!this._overviewRulerRenderer&&l&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Wa,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(uh,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(l){var m,S,w,y,_;let u=e._mouseService.getMouseReportCoords(l,e.screenElement);if(!u)return!1;let d,p;switch(l.overrideType||l.type){case"mousemove":p=32,l.buttons===void 0?(d=3,l.button!==void 0&&(d=l.button<3?l.button:3)):d=l.buttons&1?0:l.buttons&4?1:l.buttons&2?2:3;break;case"mouseup":p=0,d=l.button<3?l.button:3;break;case"mousedown":p=1,d=l.button<3?l.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(l)===!1)return!1;let b=l.deltaY;if(b===0||e.coreMouseService.consumeWheelEvent(l,(y=(w=(S=(m=e._renderService)==null?void 0:m.dimensions)==null?void 0:S.device)==null?void 0:w.cell)==null?void 0:y.height,(_=e._coreBrowserService)==null?void 0:_.dpr)===0)return!1;p=b<0?0:1,d=4;break;default:return!1}return p===void 0||d===void 0||d>4?!1:e.coreMouseService.triggerMouseEvent({col:u.col,row:u.row,x:u.x,y:u.y,button:d,action:p,ctrl:l.ctrlKey,alt:l.altKey,shift:l.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:l=>(n(l),l.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(l)),wheel:l=>(n(l),this.cancel(l,!0)),mousedrag:l=>{l.buttons&&n(l)},mousemove:l=>{l.buttons||n(l)}};this._register(this.coreMouseService.onProtocolChange(l=>{l?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(l)),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()),l&8?s.mousemove||(t.addEventListener("mousemove",o.mousemove),s.mousemove=o.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),l&16?s.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),s.wheel=o.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),l&2?s.mouseup||(s.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),l&4?s.mousedrag||(s.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register($e(t,"mousedown",l=>{if(l.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(l)))return n(l),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(l)})),this._register($e(t,"wheel",l=>{var u,d,p,m,S;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(l)===!1)return!1;if(!this.buffer.hasScrollback){if(l.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(l,(m=(p=(d=(u=e._renderService)==null?void 0:u.dimensions)==null?void 0:d.device)==null?void 0:p.cell)==null?void 0:m.height,(S=e._coreBrowserService)==null?void 0:S.dpr)===0)return this.cancel(l,!0);let w=he.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(l.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(w,!0),this.cancel(l,!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){Iv(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=U1(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===he.ETX||n.key===he.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)&&(J1(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(kt));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(he.ESC+"[I"):this.coreService.triggerDataEvent(he.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(`${he.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(`${he.ESC}[6;${o};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function J1(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var Z1=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)}},eC=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)}},sg=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 eC(t)}getNullCell(){return new Di}},tC=class extends Xe{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new be),this.onBufferChange=this._onBufferChange.event,this._normal=new sg(this._core.buffers.normal,"normal"),this._alternate=new sg(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)}},iC=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)}},nC=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}},rC=["cols","rows"],qi=0,sC=class extends Xe{constructor(e){super(),this._core=this._register(new Q1(e)),this._addonManager=this._register(new Z1),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(rC.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 iC(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new nC(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 tC(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 Hu.get()},set promptLabel(e){Hu.set(e)},get tooMuchOutput(){return $u.get()},set tooMuchOutput(e){$u.set(e)}}}_verifyIntegers(...e){for(qi of e)if(qi===1/0||isNaN(qi)||qi%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(qi of e)if(qi&&(qi===1/0||isNaN(qi)||qi%1!==0||qi<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 oC=2,aC=1,lC=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var w;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((w=this._terminal.options.overviewRuler)==null?void 0:w.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(n.getPropertyValue("height")),o=Math.max(0,parseInt(n.getPropertyValue("width"))),l=window.getComputedStyle(this._terminal.element),u={top:parseInt(l.getPropertyValue("padding-top")),bottom:parseInt(l.getPropertyValue("padding-bottom")),right:parseInt(l.getPropertyValue("padding-right")),left:parseInt(l.getPropertyValue("padding-left"))},d=u.top+u.bottom,p=u.right+u.left,m=s-d,S=o-p-t;return{cols:Math.max(oC,Math.floor(S/e.css.cell.width)),rows:Math.max(aC,Math.floor(m/e.css.cell.height))}}};function cC(e,t){return e?`/api/route/${String(e).split("/").map(encodeURIComponent).join("/")}/_/ws?token=${encodeURIComponent(t||"")}`:"/ws"}function uC({session:e,node:t,token:n,cols:s,rows:o,readonly:l=!1,takeSize:u,focused:d,onData:p,onExit:m,onFiles:S,retryBaseMs:w=250}){const y=["localhost","127.0.0.1","::1","[::1]"].includes(location.hostname);if(location.protocol!=="https:"&&!y)throw new Error("nexuscrew: ws:// rifiutato su origine non-locale e non-TLS (apri via tunnel su localhost o servi in HTTPS)");const b=`${location.protocol==="https:"?"wss":"ws"}://${location.host}${cC(t,n)}`;let C=null,k=!1,N=!1,M=null,A=0,B=d;const ee=()=>{if(k||N||M)return;const H=Math.min(5e3,Math.max(0,w)*2**Math.min(A++,5));M=setTimeout(()=>{M=null,O()},H)},O=()=>{if(k||N)return;const H=new WebSocket(b);C=H,H.binaryType="arraybuffer",H.onopen=()=>{if(C!==H||k)return;A=0;const J={type:"attach",session:e,token:n,cols:s,rows:o,readonly:l};u!==void 0&&(J.takeSize=u),H.send(JSON.stringify(J)),B!==void 0&&H.send(JSON.stringify({type:"focus",on:!!B}))},H.onmessage=J=>{if(!(C!==H||k))if(typeof J.data=="string"){let W;try{W=JSON.parse(J.data)}catch{return}W.type==="exit"&&(N=!0,m&&m(W.code)),W.type==="files"&&S&&S(W)}else p&&p(new Uint8Array(J.data))},H.onerror=()=>{if(C===H)try{H.close()}catch{}},H.onclose=J=>{C!==H||k||N||[1e3,1002,4401,4404].includes(J==null?void 0:J.code)||ee()}};return O(),{sendInput:H=>{if(!C||C.readyState!==1)return!1;try{return C.send(typeof H=="string"?new TextEncoder().encode(H):H),!0}catch{try{C.close()}catch{}return!1}},isReady:()=>!!C&&C.readyState===1,resize:(H,J)=>{s=H,o=J,(C==null?void 0:C.readyState)===1&&C.send(JSON.stringify({type:"resize",cols:H,rows:J}))},action:H=>{(C==null?void 0:C.readyState)===1&&C.send(JSON.stringify({type:"action",name:H}))},focus:H=>{B=H,(C==null?void 0:C.readyState)===1&&C.send(JSON.stringify({type:"focus",on:!!H}))},close:()=>{if(k=!0,M&&clearTimeout(M),M=null,C)try{C.close()}catch{}},get raw(){return C}}}async function og(e){const t=String(e||"");if(!t)return!1;try{if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")return await navigator.clipboard.writeText(t),!0}catch{}try{const 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 hC="\r";function dC(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 fC({isReady:e,paste:t,send:n}){return s=>{if(!s||!e())return!1;try{return t(s)===!1||!e()?!1:n(hC)!==!1}catch{return!1}}}function pC(e){return!e||typeof e!="object"?!1:!!e.shiftKey}function mC(e){return!e||typeof e!="object"||String(e.key||"").toLowerCase()!=="c"?!1:!!(e.metaKey||e.ctrlKey&&e.shiftKey)}const gC=450,ag=8;function vC(e,t,n,s){return Math.abs(Number(n)-Number(e))>ag||Math.abs(Number(s)-Number(t))>ag}const _C=new Map([["image/png","png"],["image/jpeg","jpg"],["image/gif","gif"],["image/webp","webp"],["application/pdf","pdf"],["text/plain","txt"]]);function cu(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 lg(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 yC(e,t=0,n=Date.now()){const s=String((e==null?void 0:e.name)||"").trim();if(s)return s;const o=_C.get(String((e==null?void 0:e.type)||"").toLowerCase())||"bin";return`clipboard-${n}-${t+1}.${o}`}async function E_({files:e,token:t,session:n,node:s="",paste:o=!0,fetchImpl:l=zt,onProgress:u=()=>{},now:d=Date.now()}={}){const p=Array.from(e||[]).filter(Boolean),m=[],S=[];if(!n||!p.length)return{paths:m,errors:S};const w=ui(s?String(s).split("/"):[]);for(let y=0;y<p.length;y+=1){const _=p[y],b=yC(_,y,d);u({index:y,total:p.length,name:b,state:"uploading"});try{const C=new FormData;C.append("session",n),C.append("paste",o?"true":"false"),C.append("file",_,b);const k=await l(`${w}/files/upload`,t,{method:"POST",body:C}),N=await k.json().catch(()=>({}));if(!k.ok||N.error)throw new Error(N.error||`HTTP ${k.status}`);m.push(N.path),u({index:y,total:p.length,name:b,state:"done",path:N.path})}catch(C){const k=String((C==null?void 0:C.message)||C);S.push({name:b,message:k}),u({index:y,total:p.length,name:b,state:"error",error:k})}}return{paths:m,errors:S}}function N_({session:e,node:t,token:n,readonly:s,takeSize:o,focused:l,sendRef:u,composerRef:d,actionRef:p,ctrlRef:m,setCtrlArmed:S,onFiles:w,fontSize:y=13,selectionMode:_=!1,onSelectionModeChange:b}){const C=L.useRef(null),k=L.useRef(null),N=L.useRef(y);N.current=y;const M=L.useRef(l);M.current=l;const A=L.useRef(_);A.current=_;const[B,ee]=L.useState(""),[O,H]=L.useState(""),[J,W]=L.useState(null),X=async()=>{var P,z,R,F;const j=((z=(P=k.current)==null?void 0:P.term)==null?void 0:z.getSelection())||B;if(!j){H(v("copy-empty")),setTimeout(()=>H(""),1500);return}const E=await og(j);H(v(E?"copied":"copy-manual")),E&&((F=(R=k.current)==null?void 0:R.term)==null||F.clearSelection(),b==null||b(!1)),setTimeout(()=>H(""),1800)},G=L.useRef(X);return G.current=X,L.useEffect(()=>{const j=k.current;j&&j.sock&&j.sock.focus&&j.sock.focus(!!l)},[l]),L.useEffect(()=>{const j=k.current;j&&(j.term.options.fontSize=y,j.fit.fit(),j.sock.resize(j.term.cols,j.term.rows))},[y]),L.useEffect(()=>{const j=new sC({cursorBlink:!0,fontSize:N.current,scrollback:1e3,theme:{background:"#0a0e0a"}}),E=new lC;j.loadAddon(E),j.open(C.current),E.fit();const P=new TextDecoder;let z;try{z=uC({session:e,node:t,token:n,readonly:s,takeSize:o,focused:M.current,onFiles:w,cols:j.cols,rows:j.rows,onData:ge=>j.write(P.decode(ge)),onExit:()=>j.write(`\r
|
|
78
|
+
\x1B[33m[sessione finita]\x1B[0m\r
|
|
79
|
+
`)})}catch(ge){return j.write(`\r
|
|
80
|
+
\x1B[31m${ge.message}\x1B[0m\r
|
|
81
|
+
`),()=>j.dispose()}k.current={term:j,fit:E,sock:z};let R=null;const F=j.onData(ge=>{if(s){R&&(R.ok=!1);return}if(!R&&m&&m.current&&ge.length===1){const et=ge.charCodeAt(0);let ue=et;et>=97&&et<=122?ue=et-96:et>=64&&et<=95?ue=et-64:et===32&&(ue=0),ge=String.fromCharCode(ue),m.current=!1,S&&S(!1)}const qe=z.sendInput(ge);R&&(R.seen=!0,R.ok=R.ok&&qe)});u&&(u.current=ge=>z.sendInput(ge)),p&&(p.current=ge=>z.action(ge)),d&&(d.current=fC({isReady:()=>!s&&z.isReady(),paste:ge=>{const qe={seen:!1,ok:!0};R=qe;try{j.paste(ge)}catch{qe.ok=!1}finally{R=null}return qe.seen&&qe.ok},send:ge=>z.sendInput(ge)}));const I=j.onSelectionChange(()=>ee(j.getSelection()));j.attachCustomKeyEventHandler(ge=>(ge.ctrlKey||ge.metaKey)&&ge.key.toLowerCase()==="c"&&j.getSelection()?(ge.type==="keydown"&&og(j.getSelection()),!1):!0);const re=C.current;let q=!1;const D=async ge=>{if(!ge.length||q)return;if(s){W({error:v("settings-readonly")});return}q=!0,W({current:0,total:ge.length,name:""});const qe=await E_({files:ge,token:n,session:e,node:t,paste:!0,onProgress:({index:et,total:ue,name:De,state:Ke,error:Lt})=>W({current:et+1,total:ue,name:De,...Ke==="error"?{error:Lt}:{}})});q=!1,qe.errors.length?W({error:qe.errors.map(et=>`${et.name}: ${et.message}`).join(" · ")}):(W({done:!0,total:qe.paths.length}),setTimeout(()=>W(null),1600))},U=ge=>{const qe=ge.clipboardData;if(!cu(qe))return;const et=lg(qe);et.length&&(ge.preventDefault(),ge.stopPropagation(),D(et))},Q=ge=>{cu(ge.dataTransfer)&&(ge.preventDefault(),ge.stopPropagation())},ae=ge=>{cu(ge.dataTransfer)&&(ge.preventDefault(),ge.stopPropagation(),D(lg(ge.dataTransfer)))};re.addEventListener("paste",U,!0),re.addEventListener("dragenter",Q,!0),re.addEventListener("dragover",Q,!0),re.addEventListener("drop",ae,!0);const se=24;let le=null,pe=null,ce=0,ke=null,Oe=null,te=null,ie=!1;const ye=()=>{te&&clearTimeout(te),te=null},Me=(ge,qe)=>{const ue=(re.querySelector(".xterm-screen")||re).getBoundingClientRect(),De=Math.max(0,Math.min(j.cols-1,Math.floor((ge-ue.left)/Math.max(1,ue.width)*j.cols))),Ke=Math.max(0,Math.min(j.rows-1,Math.floor((qe-ue.top)/Math.max(1,ue.height)*j.rows)));return{col:De,row:j.buffer.active.viewportY+Ke}},je=ge=>Me(ge.clientX,ge.clientY),Y=ge=>{if(ye(),ie=!1,ge.touches.length!==1){le=null;return}if(A.current){ge.preventDefault(),ge.stopPropagation(),Oe=je(ge.touches[0]),j.clearSelection();return}le=ge.touches[0].clientY,pe=ge.touches[0].clientX,ce=0,ke=null;const qe={x:pe,y:le};te=setTimeout(()=>{te=null,ie=!0,A.current=!0,b==null||b(!0),Oe=Me(qe.x,qe.y),j.clearSelection(),j.select(Oe.col,Oe.row,1),le=null,pe=null,ke=null,ce=0},gC)},de=ge=>{if((A.current||ie)&&Oe&&ge.touches.length===1){ge.preventDefault(),ge.stopPropagation();const et=je(ge.touches[0]),ue=Oe.row*j.cols+Oe.col,De=et.row*j.cols+et.col,Ke=ue<=De?Oe:et;j.select(Ke.col,Ke.row,Math.abs(De-ue)+1);return}if(le===null||ge.touches.length!==1)return;ge.preventDefault(),ge.stopPropagation();const qe=ge.touches[0];if(te&&vC(pe,le,qe.clientX,qe.clientY)&&ye(),ke===null&&(Math.abs(qe.clientY-le)>8||Math.abs(qe.clientX-pe)>8)&&(ke=Math.abs(qe.clientY-le)>Math.abs(qe.clientX-pe)),!!ke){for(ce+=qe.clientY-le,le=qe.clientY;ce>=se;)z.action("scroll-up"),ce-=se;for(;ce<=-se;)z.action("scroll-down"),ce+=se}},we=()=>{ye(),le=null,pe=null,Oe=null,ie=!1};let K=0;const fe=ge=>{for(ge.preventDefault(),ge.stopPropagation(),K+=ge.deltaY;K<=-se;)z.action("scroll-up"),K+=se;for(;K>=se;)z.action("scroll-down"),K-=se};re.addEventListener("touchstart",Y,{passive:!1}),re.addEventListener("touchmove",de,{passive:!1,capture:!0}),re.addEventListener("touchend",we,{passive:!0}),re.addEventListener("touchcancel",we,{passive:!0});const Ce=ge=>{(A.current||ie)&&(ge.preventDefault(),ge.stopPropagation())};re.addEventListener("contextmenu",Ce,!0),re.addEventListener("wheel",fe,{passive:!1,capture:!0});let Ne=null;const Be=ge=>{pC(ge)&&(ge.preventDefault(),ge.stopPropagation(),Ne=Me(ge.clientX,ge.clientY),j.clearSelection())},mt=ge=>{if(!Ne)return;ge.preventDefault(),ge.stopPropagation();const qe=Me(ge.clientX,ge.clientY),et=Ne.row*j.cols+Ne.col,ue=qe.row*j.cols+qe.col,De=et<=ue?Ne:qe;j.select(De.col,De.row,Math.abs(ue-et)+1)},rt=ge=>{Ne&&(ge.stopPropagation(),Ne=null)};re.addEventListener("mousedown",Be,!0),re.addEventListener("mousemove",mt,!0),re.addEventListener("mouseup",rt,!0);const Ae=ge=>{!mC(ge)||!(k.current&&k.current.term&&k.current.term.getSelection())||(ge.preventDefault(),ge.stopPropagation(),G.current&&G.current())};re.addEventListener("keydown",Ae,!0);const We=()=>{E.fit(),z.resize(j.cols,j.rows)};window.addEventListener("resize",We);const Ie=window.visualViewport;Ie&&(Ie.addEventListener("resize",We),Ie.addEventListener("scroll",We));let bt=null,Ge=0;return typeof ResizeObserver<"u"&&(bt=new ResizeObserver(()=>{Ge&&cancelAnimationFrame(Ge),Ge=requestAnimationFrame(We)}),bt.observe(re)),()=>{k.current=null,u&&(u.current=()=>!1),d&&(d.current=()=>!1),p&&(p.current=()=>!1),F.dispose(),I.dispose(),re.removeEventListener("touchstart",Y),re.removeEventListener("touchmove",de,{capture:!0}),re.removeEventListener("touchend",we),re.removeEventListener("touchcancel",we),re.removeEventListener("contextmenu",Ce,!0),ye(),re.removeEventListener("wheel",fe,{capture:!0}),re.removeEventListener("mousedown",Be,!0),re.removeEventListener("mousemove",mt,!0),re.removeEventListener("mouseup",rt,!0),re.removeEventListener("keydown",Ae,!0),re.removeEventListener("paste",U,!0),re.removeEventListener("dragenter",Q,!0),re.removeEventListener("dragover",Q,!0),re.removeEventListener("drop",ae,!0),window.removeEventListener("resize",We),Ie&&(Ie.removeEventListener("resize",We),Ie.removeEventListener("scroll",We)),bt&&bt.disconnect(),Ge&&cancelAnimationFrame(Ge),z.close(),j.dispose()}},[e,t,n,s,o,u,d,p,m,S,w]),h.jsxs("div",{className:`nc-terminal${_?" selecting":""}`,children:[h.jsx("div",{className:"nc-terminal-host",ref:C}),J&&h.jsx("div",{className:`nc-upload-state${J.error?" error":""}`,role:"status",children:J.error?J.error:J.done?v("attach-uploaded").replace("{n}",String(J.total||0)):v("attach-upload-progress").replace("{n}",String(J.current||0)).replace("{total}",String(J.total||0))}),(B||_)&&h.jsxs("div",{className:"nc-selection-tools",children:[B?h.jsx("button",{type:"button",onClick:X,children:O||v("copy")}):h.jsx("span",{children:v("select-drag")}),h.jsx("button",{type:"button",onClick:()=>{var j,E;(E=(j=k.current)==null?void 0:j.term)==null||E.clearSelection(),ee(""),b==null||b(!1)},children:v("cancel")}),O===v("copy-manual")&&h.jsx("textarea",{readOnly:!0,value:B,onFocus:j=>j.target.select()})]})]})}const cg="",ci="\x1B",SC=[{label:"↑",seq:ci+"[A"},{label:"↓",seq:ci+"[B"},{label:"PGUP",seq:ci+"[5~"},{label:"PGDN",seq:ci+"[6~"}];function wC({send:e,action:t,ctrlArmed:n=!1,onCtrl:s,onKeyboard:o,selectionMode:l=!1,onSelectionMode:u}){const[d,p]=L.useState(!1),[m,S]=L.useState(!1),[w,y]=L.useState(!1),_=k=>{w?(e(ci+k),y(!1)):e(k)},b=(k,N,M)=>h.jsx("button",{onMouseDown:A=>{A.preventDefault(),_(N),M&&M()},children:k},k),C=(k,N)=>h.jsx("button",{onMouseDown:M=>{M.preventDefault(),t(N),S(!1)},children:k},k);return d?h.jsxs("div",{className:"nc-keybar copy",children:[h.jsx("span",{className:"tag",children:"copy-mode"}),SC.map(k=>b(k.label,k.seq)),b("ESCI (q)","q",()=>p(!1))]}):h.jsxs("div",{className:"nc-keybar termux",children:[m&&h.jsxs("div",{className:"nc-keymenu",children:[C("←WIN","prev-window"),C("WIN→","next-window"),C("⬅PANE","pane-left"),C("PANE➡","pane-right"),b("SCROLL",cg+"[",()=>{p(!0),S(!1)}),h.jsx("button",{className:l?"armed":"",onMouseDown:k=>{k.preventDefault(),u==null||u(!l),S(!1)},children:"SELECT"}),b("⌃C","",()=>S(!1)),b("DETACH",cg+"d",()=>S(!1))]}),h.jsxs("div",{className:"row",children:[b("ESC",ci),h.jsx("button",{className:m?"armed":"",onMouseDown:k=>{k.preventDefault(),S(N=>!N)},children:"☰"},"menu"),b("/","/"),b("—","-"),b("HOME",ci+"[H"),b("↑",ci+"[A"),b("END",ci+"[F"),b("PGUP",ci+"[5~")]}),h.jsxs("div",{className:"row",children:[b("⇥"," "),h.jsx("button",{onMouseDown:k=>{k.preventDefault(),o&&o()},children:"⌨"},"kbd"),h.jsx("button",{className:n?"armed":"",onMouseDown:k=>{k.preventDefault(),s&&s()},children:"CTRL"},"ctrl"),h.jsx("button",{className:w?"armed":"",onMouseDown:k=>{k.preventDefault(),y(N=>!N)},children:"ALT"},"alt"),b("←",ci+"[D"),b("↓",ci+"[B"),b("→",ci+"[C"),b("PGDN",ci+"[6~")]})]})}const bC=e=>e>1048576?`${(e/1048576).toFixed(1)}M`:e>1024?`${(e/1024).toFixed(0)}K`:`${e}B`;function R_({session:e,node:t,token:n,filesEvent:s,onClose:o}){Si();const l=t?`/api/route/${String(t).split("/").map(encodeURIComponent).join("/")}/_`:"/api",u=t?`${t}:${e}`:e,[d,p]=L.useState("outbox"),[m,S]=L.useState({inbox:[],outbox:[]}),[w,y]=L.useState(""),_=L.useRef(null);async function b(){try{const A=await(await zt(`${l}/files?session=${encodeURIComponent(e)}`,n)).json();if(A.error){y(A.error);return}S(A);const B=A.outbox[0]?A.outbox[0].mtime:0;localStorage.setItem(Ia(u),String(B))}catch(M){y(String(M))}}L.useEffect(()=>{b()},[e,t]),L.useEffect(()=>{s&&s.session===e&&b()},[s]);async function C(M){for(const A of M){y(`carico ${A.name}…`);const B=new FormData;B.append("session",e),B.append("file",A);try{const O=await(await zt(`${l}/files/upload`,n,{method:"POST",body:B})).json();y(O.error?`errore: ${O.error}`:"")}catch(ee){y(String(ee))}}b()}async function k(M){const A=await zt(`${l}/files/download?session=${encodeURIComponent(e)}&box=${d}&name=${encodeURIComponent(M)}`,n);if(!A.ok){y("errore download");return}const B=await A.blob(),ee=URL.createObjectURL(B),O=document.createElement("a");O.href=ee,O.download=M,O.click(),URL.revokeObjectURL(ee)}async function N(M){await zt(`${l}/files?session=${encodeURIComponent(e)}&box=${d}&name=${encodeURIComponent(M)}`,n,{method:"DELETE"}),b()}return h.jsxs("div",{className:"nc-files",children:[h.jsxs("header",{children:[h.jsx("b",{children:t?`${t}:${e}`:e}),h.jsx("button",{onClick:o,title:v("close"),children:h.jsx(tt,{name:"x",size:20})})]}),h.jsxs("nav",{children:[h.jsx("button",{className:d==="outbox"?"on":"",onClick:()=>p("outbox"),children:"outbox"}),h.jsx("button",{className:d==="inbox"?"on":"",onClick:()=>p("inbox"),children:"inbox"}),h.jsxs("button",{className:"up",onClick:()=>_.current&&_.current.click(),children:[h.jsx(tt,{name:"upload",size:18})," ",v("upload")]}),h.jsx("input",{type:"file",multiple:!0,ref:_,style:{display:"none"},onChange:M=>{C(Array.from(M.target.files||[])),M.target.value=""}})]}),w&&h.jsx("div",{className:"nc-busy",children:w}),h.jsxs("ul",{children:[m[d].map(M=>h.jsxs("li",{children:[h.jsx("span",{className:"name",onClick:()=>k(M.name),children:M.name}),h.jsx("small",{children:bC(M.size)}),h.jsx("button",{onClick:()=>N(M.name),title:"elimina",children:h.jsx(tt,{name:"trash",size:18})})]},M.name)),m[d].length===0&&h.jsx("li",{className:"empty",children:v("empty-files")})]})]})}function P_({submitText:e,token:t,session:n,node:s}){Si();const o=s?`/api/route/${String(s).split("/").map(encodeURIComponent).join("/")}/_`:"/api",[l,u]=L.useState(""),[d,p]=L.useState(!1),[m,S]=L.useState(""),[w,y]=L.useState(!1),_=L.useRef(null),b=L.useRef(null),C=L.useRef(null),[k,N]=L.useState(!1),[M,A]=L.useState({left:0,bottom:0}),[B,ee]=L.useState(!1),[O,H]=L.useState(!1),J=L.useRef(null),W=L.useRef(null),X=L.useRef(null),G=L.useRef(null),j=L.useRef(null),E=L.useRef(`nc-attach-${Math.random().toString(36).slice(2,8)}`);L.useEffect(()=>{let Q=!1;if(s){y(!1);return}return zt(`${o}/voice/status`,t).then(ae=>ae.json()).then(ae=>{Q||y(!!ae.serverSttConfigured)}).catch(()=>{Q||y(!1)}),()=>{Q=!0}},[t,o]);const z=!!(typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition)||w);async function R(){const Q=l,ae=dC(Q);if(!ae||O)return;H(!0),S("");let se=!1;try{se=!!await e(ae)}catch{se=!1}se?u(le=>le===Q?"":le):S(v("composer-send-failed")),H(!1),requestAnimationFrame(()=>{var le;return(le=C.current)==null?void 0:le.focus({preventScroll:!0})})}function F(){const Q=J.current&&J.current.getBoundingClientRect();Q&&A({left:Math.max(6,Math.min(Q.left,window.innerWidth-186)),bottom:window.innerHeight-Q.top+6}),N(!0)}function I(Q){N(!1),Q&&J.current&&J.current.focus()}L.useEffect(()=>{if(!k)return;const Q=se=>{se.key==="Escape"&&I(!0)},ae=se=>{const le=W.current&&W.current.contains(se.target),pe=J.current&&J.current.contains(se.target);!le&&!pe&&I(!1)};return document.addEventListener("keydown",Q),document.addEventListener("pointerdown",ae),()=>{document.removeEventListener("keydown",Q),document.removeEventListener("pointerdown",ae)}},[k]);function re(Q){I(!1),Q.current&&Q.current.click()}async function q(Q){if(!Q.length||!n)return;ee(!0),S("");const{paths:ae,errors:se}=await E_({files:Q,token:t,session:n,node:s,paste:!1});se.length&&S(se.map(le=>`${le.name}: ${le.message}`).join(" · ")),ae.length&&u(le=>le+(le&&!le.endsWith(" ")?" ":"")+ae.join(" ")),ee(!1)}function D(){_.current&&_.current.stop(),b.current&&b.current.stop(),p(!1)}async function U(){S("");const Q=window.SpeechRecognition||window.webkitSpeechRecognition;if(Q){const ae=new Q;ae.lang="it-IT",ae.continuous=!1,ae.interimResults=!0;const se=l?`${l} `:"";ae.onresult=le=>{const pe=Array.from(le.results).map(ce=>ce[0].transcript).join("");u(se+pe)},ae.onend=()=>p(!1),ae.onerror=le=>{S(`voice: ${le.error||"errore"}`),p(!1)},_.current=ae,ae.start(),p(!0);return}try{const ae=await navigator.mediaDevices.getUserMedia({audio:!0}),se=new MediaRecorder(ae),le=[];se.ondataavailable=pe=>le.push(pe.data),se.onstop=async()=>{ae.getTracks().forEach(pe=>pe.stop()),p(!1),S("trascrivo…");try{const pe=new Blob(le,{type:se.mimeType||"audio/webm"}),ke=await(await zt(`${o}/voice/transcribe`,t,{method:"POST",headers:{"content-type":"application/octet-stream"},body:pe})).json();ke.error?S(ke.error):(S(""),u(Oe=>Oe+(Oe?" ":"")+(ke.text||"")))}catch(pe){S(String(pe))}},b.current={stop:()=>se.state!=="inactive"&&se.stop()},se.start(),p(!0)}catch{S("microfono non disponibile"),p(!1)}}return h.jsxs("div",{className:"nc-composer",children:[m&&h.jsx("div",{className:"nc-composer-err",children:m}),h.jsxs("div",{className:"nc-composer-row",children:[n&&h.jsx("button",{ref:J,className:B?"attach busy":"attach",disabled:B,onClick:()=>k?I(!1):F(),title:v(B?"attach-uploading":"attach"),"aria-label":v("attach"),"aria-haspopup":"menu","aria-expanded":k,"aria-controls":E.current,children:h.jsx(tt,{name:"attach",size:22})}),k&&h.jsxs("div",{ref:W,id:E.current,role:"menu",className:"nc-attach-menu",style:{left:M.left,bottom:M.bottom},children:[h.jsxs("button",{role:"menuitem",onClick:()=>re(X),children:[h.jsx(tt,{name:"file",size:18})," ",v("attach-file")]}),h.jsxs("button",{role:"menuitem",onClick:()=>re(G),children:[h.jsx(tt,{name:"camera",size:18})," ",v("attach-camera")]}),h.jsxs("button",{role:"menuitem",onClick:()=>re(j),children:[h.jsx(tt,{name:"image",size:18})," ",v("attach-gallery")]})]}),h.jsx("input",{ref:X,type:"file",multiple:!0,hidden:!0,onChange:Q=>{q(Array.from(Q.target.files||[])),Q.target.value=""}}),h.jsx("input",{ref:G,type:"file",accept:"image/*",capture:"environment",hidden:!0,onChange:Q=>{q(Array.from(Q.target.files||[])),Q.target.value=""}}),h.jsx("input",{ref:j,type:"file",accept:"image/*,video/*",multiple:!0,hidden:!0,onChange:Q=>{q(Array.from(Q.target.files||[])),Q.target.value=""}}),h.jsx("textarea",{ref:C,rows:2,value:l,placeholder:v("composer-placeholder"),onChange:Q=>u(Q.target.value)}),z&&h.jsx("button",{className:d?"mic on":"mic",onClick:d?D:U,title:v("voice"),children:h.jsx(tt,{name:"mic",size:22})}),h.jsx("button",{type:"button",className:"go",disabled:O,onPointerDown:Q=>Q.preventDefault(),onClick:R,title:v("send"),children:h.jsx(tt,{name:"enter",size:22})})]})]})}function Ya(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 ug(e){return String(e||"?").replace(/^[^a-zA-Z0-9]+/,"").charAt(0).toUpperCase()||"?"}function Na(e,t){if(!(e!=null&&e.outbox)||e.outbox.count<1)return!1;const n=Number(localStorage.getItem(Ia(t))||0);return e.outbox.latest>n}const CC=180,kC=480;function uu(e){return e.status==="passive"?v("node-passive"):e.status==="down"?e.downSince?v("tunnel-down-since").replace("{t}",Ya(e.downSince)):v("tunnel-down"):e.status==="unreachable"?v("node-unreachable"):e.status==="offline"?e.lastSeen?v("node-offline-seen").replace("{t}",Ya(e.lastSeen)):v("node-offline"):e.status==="needs-repair"?v("node-needs-repair"):""}function xC(e){return!e||e.status==="passive"?null:e.status==="healthy"?"on":"warn"}function hg(e){return e&&(e.detail||e.status)||""}function EC({sessions:e=[],cells:t=[],activeSessions:n=[],nodeGroups:s=[],onPick:o,onAddTile:l,onPower:u,onNodePower:d,onKill:p,onVisibility:m,onNew:S,onSettings:w,width:y=240,collapsed:_=!1,onResize:b,onToggleCollapse:C}){const[k,N]=Si(),[M,A]=L.useState(bv),[B,ee]=L.useState(Lv),[O,H]=L.useState(Rv),J=te=>A(ie=>Cv(ie,te)),W=new Set((t||[]).map(te=>te.tmuxSession)),X=new Map((e||[]).map(te=>[te.name,te])),G=(te,ie)=>zw(M,te,ie),j=Fw,E=[...t||[]].sort((te,ie)=>j(G(te.tmuxSession,(X.get(te.tmuxSession)||{}).activity),G(ie.tmuxSession,(X.get(ie.tmuxSession)||{}).activity))),P=(e||[]).filter(te=>!W.has(te.name)).sort((te,ie)=>j(G(te.name,te.activity),G(ie.name,ie.activity))||te.name.localeCompare(ie.name)),z=new Set(n||[]),R=te=>za(B,te),F=(te,ie)=>ee(ye=>{const Me={...ye,[te]:{...za(ye,te),...ie}};return Mv(Me)}),I=[...E.map(te=>{const ie=X.get(te.tmuxSession)||{},ye=dn([],te.tmuxSession);return{type:"cell",value:te,key:ye,label:te.cell,live:!!te.tmux,fresh:Na(ie,ye),activity:ie.activity||0}}),...P.map(te=>{const ie=dn([],te.name);return{type:"session",value:te,key:ie,label:te.name,live:!0,technical:te.technical===!0,fresh:Na(te,ie),activity:te.activity||0}})],re=fn(I,M,R("local").filter,Xi(O,"local")),q=(s||[]).map(te=>{const ie=(te.route||[te.name]).join("/"),ye=R(ie),Me=new Map((te.sessions||[]).map(de=>[de.name,de])),je=[...(te.cells||[]).map(de=>{const we=Me.get(de.tmuxSession)||{},K=dn(te.route,de.tmuxSession||de.cell);return{type:"cell",value:de,key:K,label:de.cell,live:!!de.tmux,fresh:Na(we,K),activity:we.activity||de.activity||0}}),...(te.unmanaged||[]).map(de=>{const we=dn(te.route,de.name);return{type:"session",value:de,key:we,label:de.name,live:!0,technical:de.technical===!0,fresh:Na(de,we),activity:de.activity||0}})],Y=fn(je,M,ye.filter,Xi(O,ie));return{g:te,nodeRoute:ie,groupView:ye,rawItems:je,items:Y}});function D(te,ie,ye,Me){const je=M.includes(ie),Y=M.includes(ye);if(je===Y){if(je){A(de=>kv(de,ie,ye));return}H(de=>{var fe;const we=((fe=Me.find(Ce=>Ce.key===ie))==null?void 0:fe.technical)===!0,K=fn(Me,M,we?"technical":"all",Xi(de,te)).map(Ce=>Ce.key);return Pv(Dv(de,te,ie,ye,K))})}}function U(te,ie,ye,Me){var fe;const je=((fe=Me.find(Ce=>Ce.key===ie))==null?void 0:fe.technical)===!0,Y=M.includes(ie),de=fn(Me,M,je?"technical":"all",Xi(O,te)).map(Ce=>Ce.key).filter(Ce=>M.includes(Ce)===Y),we=de.indexOf(ie),K=de[we+ye];we>=0&&K&&D(te,ie,K,Me)}const Q=(te,ie)=>M.includes(te)===M.includes(ie),[ae,se]=L.useState(null),le=(te,ie)=>{const ye=te.currentTarget.getBoundingClientRect();se({text:ie,y:ye.top+ye.height/2})},pe=()=>se(null),ce=L.useRef(null);L.useEffect(()=>()=>{ce.current&&ce.current()},[]);function ke(te){te.preventDefault(),te.stopPropagation();const ie=te.clientX,ye=y,Me=Y=>{const de=Math.max(CC,Math.min(kC,ye+(Y.clientX-ie)));b&&b(de)},je=()=>{window.removeEventListener("pointermove",Me),window.removeEventListener("pointerup",je),window.removeEventListener("pointercancel",je),window.removeEventListener("blur",je),ce.current=null};window.addEventListener("pointermove",Me),window.addEventListener("pointerup",je),window.addEventListener("pointercancel",je),window.addEventListener("blur",je),ce.current=je}const Oe=_?{width:48,flex:"0 0 48px"}:{width:y,flex:`0 0 ${y}px`};return _?h.jsxs("aside",{className:"nc-sidebar mini",style:Oe,children:[h.jsx("div",{className:"nc-side-head mini",children:h.jsx("button",{className:"nc-collapse-btn",onClick:C,title:v("expand"),children:"⟩"})}),h.jsx("button",{className:"nc-side-gear mini",onClick:()=>w&&w("nodes",!1),title:v("settings"),onMouseEnter:te=>le(te,v("settings")),onMouseLeave:pe,children:h.jsx(tt,{name:"gear",size:16})}),h.jsx("div",{className:"nc-side-scroll mini",children:h.jsxs("div",{className:"nc-side-group mini",children:[R("local").open&&re.map(te=>te.type==="cell"?(()=>{const ie=te.value,ye=ie.degraded?"warn":ie.tmux?"on":"",Me=!!ie.tmux;return h.jsx("button",{type:"button",className:`nc-mini-dot${z.has(ie.tmuxSession)?" active":""}`,onMouseEnter:je=>le(je,ie.cell),onMouseLeave:pe,draggable:Me,onDragStart:Me?je=>je.dataTransfer.setData("text/nc-session",ie.tmuxSession):void 0,onClick:Me?()=>l&&l(ie.tmuxSession):()=>u&&u(ie),onDoubleClick:Me?()=>o&&o(ie.tmuxSession):void 0,children:h.jsx("span",{className:`nc-dot ${ye}`})},te.key)})():(()=>{const ie=te.value;return h.jsx("button",{type:"button",className:`nc-mini-init${z.has(ie.name)?" active":""}`,onMouseEnter:ye=>le(ye,ie.name),onMouseLeave:pe,draggable:!0,onDragStart:ye=>ye.dataTransfer.setData("text/nc-session",ie.name),onClick:()=>l&&l(ie.name),onDoubleClick:()=>o&&o(ie.name),children:ug(ie.name)},te.key)})()),q.flatMap(({g:te,nodeRoute:ie,groupView:ye,items:Me})=>te.status==="up"?ye.open?Me.map(je=>je.type==="cell"?(()=>{const Y=je.value,de=!!Y.tmux;return h.jsx("button",{type:"button",className:`nc-mini-dot${z.has(je.key)?" active":""}`,onMouseEnter:we=>le(we,`${te.label||ie}: ${Y.cell}`),onMouseLeave:pe,draggable:de,onDragStart:de?we=>we.dataTransfer.setData("text/nc-session",je.key):void 0,onClick:de?()=>l&&l(je.key):()=>u&&u({...Y,route:te.route,availableEngines:te.engines||[]}),onDoubleClick:de?()=>o&&o({session:Y.tmuxSession,node:ie}):void 0,children:h.jsx("span",{className:`nc-dot ${Y.degraded?"warn":de?"on":""}`})},je.key)})():(()=>{const Y=je.value;return h.jsx("button",{type:"button",className:`nc-mini-init${z.has(je.key)?" active":""}`,onMouseEnter:de=>le(de,`${te.label||ie}: ${Y.name}`),onMouseLeave:pe,draggable:!0,onDragStart:de=>de.dataTransfer.setData("text/nc-session",je.key),onClick:()=>l&&l(je.key),onDoubleClick:()=>o&&o({session:Y.name,node:ie}),children:ug(Y.name)},je.key)})()):[]:[h.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:je=>le(je,`${te.label||(te.route||[te.name]).join(" › ")}: ${uu(te)}`),onMouseLeave:pe,children:h.jsx("span",{className:`nc-dot${te.status==="passive"?"":" warn"}`})},`nodo-${(te.route||[te.name]).join("/")}`)])]})}),ae&&h.jsx("div",{className:"nc-mini-tip",style:{top:ae.y},children:ae.text})]}):h.jsxs("aside",{className:"nc-sidebar",style:Oe,children:[h.jsxs("div",{className:"nc-side-head",children:[h.jsx("button",{className:"nc-collapse-btn",onClick:C,title:v("collapse"),children:"⟨"}),h.jsx("span",{className:"nc-side-title",children:v("fleet")}),h.jsxs("button",{className:"nc-new-btn",onClick:S,title:v("fleet-new-cell"),children:["+ ",v("new")]})]}),h.jsxs("button",{className:"nc-side-gear",onClick:()=>w&&w("nodes",!1),title:v("settings"),children:[h.jsx(tt,{name:"gear",size:15})," ",v("settings")]}),h.jsxs("div",{className:"nc-side-scroll",children:[h.jsx(NC,{label:v("position-local"),count:re.length,state:R("local"),onToggle:()=>F("local",{open:!R("local").open}),onFilter:te=>F("local",{filter:te})}),R("local").open&&h.jsxs("div",{className:"nc-side-group",children:[re.map(te=>te.type==="cell"?(()=>{const ie=te.value,ye=ie.degraded?"warn":ie.tmux?"on":"",Me=ie.degraded?v("cell-degraded"):ie.tmux?v("cell-on"):v("cell-off"),je=!!ie.tmux;return h.jsxs("div",{"data-roster-key":te.key,"data-position":"local",className:`nc-cell${je?" live":""}${z.has(ie.tmuxSession)?" active":""}`,title:`${ie.cell} · ${ie.engine}${ie.key?`·${ie.key}`:""} · ${Me}`,"aria-label":`${ie.cell}, ${ie.engine}${ie.key?` ${ie.key}`:""}, ${Me}`,draggable:je,onDragStart:je?Y=>Y.dataTransfer.setData("text/nc-session",ie.tmuxSession):void 0,onClick:je?()=>l&&l(ie.tmuxSession):void 0,onDoubleClick:je?()=>o&&o(ie.tmuxSession):void 0,children:[h.jsx(Kr,{position:"local",itemKey:te.key,label:ie.cell,canMove:Q,onMove:(Y,de)=>D("local",Y,de,I),onStep:Y=>U("local",te.key,Y,I)}),h.jsx("span",{className:`nc-dot ${ye}`}),h.jsxs("span",{className:"nc-cell-main",children:[h.jsx("b",{title:ie.cell,children:ie.cell}),h.jsxs("small",{title:`${ie.engine}${ie.key?`·${ie.key}`:""}`,children:[ie.engine,ie.key?`·${ie.key}`:""]})]}),h.jsx("button",{className:`nc-pin${M.includes(te.key)?" on":""}`,title:v("pin"),onClick:Y=>{Y.stopPropagation(),J(te.key)},children:M.includes(te.key)?"★":"☆"}),h.jsx("button",{className:`nc-power${ie.tmux?" on":""}${ie.degraded?" warn":""}`,onClick:Y=>{Y.stopPropagation(),u&&u(ie)},title:ie.active?v("power-off"):v("power-on"),children:h.jsx(tt,{name:"power",size:14})})]},te.key)})():(()=>{var ye;const ie=te.value;return h.jsxs("div",{"data-roster-key":te.key,"data-position":"local",className:`nc-side-card${z.has(ie.name)?" active":""}`,draggable:!0,onDragStart:Me=>Me.dataTransfer.setData("text/nc-session",ie.name),onClick:()=>l&&l(ie.name),onDoubleClick:()=>o&&o(ie.name),children:[h.jsx(Kr,{position:"local",itemKey:te.key,label:ie.name,canMove:Q,onMove:(Me,je)=>D("local",Me,je,I),onStep:Me=>U("local",te.key,Me,I)}),h.jsx("span",{className:ie.attached?"nc-dot on":"nc-dot"}),h.jsxs("span",{className:"nc-card-main",children:[h.jsx("b",{children:ie.name}),h.jsxs("small",{children:[ie.preview||ie.cmd||v("windows").replace("{n}",String(ie.windows||0)),((ye=ie.outbox)==null?void 0:ye.count)>0?` · 📦${ie.outbox.count}`:""]})]}),ie.activity?h.jsx("span",{className:"nc-rel",children:Ya(ie.activity)}):null,h.jsx("button",{className:`nc-pin${M.includes(te.key)?" on":""}`,title:v("pin"),onClick:Me=>{Me.stopPropagation(),J(te.key)},children:M.includes(te.key)?"★":"☆"}),h.jsx("button",{className:`nc-technical${ie.technical?" on":""}`,title:ie.technical?v("mark-normal"):v("mark-technical"),"aria-label":`${ie.technical?v("mark-normal"):v("mark-technical")} ${ie.name}`,onClick:Me=>{Me.stopPropagation(),m&&m(ie.name,!ie.technical,[])},children:"T"}),h.jsx("button",{className:"nc-menu",title:v("terminate"),onClick:Me=>{Me.stopPropagation(),window.confirm(v("terminate-confirm").replace("{name}",ie.name))&&p&&p(ie.name)},children:"⋯"})]},te.key)})()),re.length===0&&h.jsx("div",{className:"nc-empty",children:v("no-sessions-short")})]}),q.map(({g:te,nodeRoute:ie,groupView:ye,rawItems:Me,items:je})=>{const de=xC(te.health)||(te.status==="up"?"on":te.status==="passive"?"":"warn");return h.jsxs("div",{children:[h.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:()=>F(ie,{open:!ye.open}),onKeyDown:we=>{(we.key==="Enter"||we.key===" ")&&(we.preventDefault(),F(ie,{open:!ye.open}))},children:[h.jsx("span",{className:"nc-node-chevron",children:ye.open?"⌄":"›"}),h.jsx("span",{className:`nc-dot ${de}`,title:te.health?hg(te.health):""}),h.jsx("b",{children:te.label||te.name}),h.jsxs("small",{children:[" · ",te.status==="up"?v("node-sessions").replace("{n}",String(je.length)):te.health&&hg(te.health)||uu(te)]}),h.jsxs("select",{className:"nc-node-filter",value:ye.filter,title:v(`view-${ye.filter}`),onClick:we=>we.stopPropagation(),onChange:we=>F(ie,{filter:we.target.value}),children:[h.jsx("option",{value:"all",children:v("view-all")}),h.jsx("option",{value:"pinned",children:v("view-pinned")}),h.jsx("option",{value:"active",children:v("view-active")}),h.jsx("option",{value:"off",children:v("view-off")}),h.jsx("option",{value:"technical",children:v("view-technical")})]}),te.direct&&te.health&&te.health.managed!==!1&&h.jsx("button",{type:"button",className:`nc-power${te.tunnelStatus==="up"?" on":""}`,title:te.tunnelStatus==="up"?v("power-off"):v("power-on"),onClick:we=>{we.stopPropagation(),d&&d(te)},children:h.jsx(tt,{name:"power",size:14})})]}),te.status==="up"&&ye.open&&h.jsxs("div",{className:"nc-side-group",children:[je.map(we=>we.type==="cell"?(()=>{const K=we.value,fe=!!K.tmux,Ce=K.degraded?"warn":K.tmux?"on":"";return h.jsxs("div",{"data-roster-key":we.key,"data-position":ie,className:`nc-side-card nc-cell${fe?" live":""}${z.has(K.key)?" active":""}`,title:K.active?v("cell-on"):v("cell-off"),draggable:fe,onDragStart:fe?Ne=>Ne.dataTransfer.setData("text/nc-session",K.key):void 0,onClick:fe?()=>l&&l(K.key):void 0,onDoubleClick:fe?()=>o&&o({session:K.tmuxSession,node:ie}):void 0,children:[h.jsx(Kr,{position:ie,itemKey:we.key,label:K.cell,canMove:Q,onMove:(Ne,Be)=>D(ie,Ne,Be,Me),onStep:Ne=>U(ie,we.key,Ne,Me)}),h.jsx("span",{className:`nc-dot ${Ce}`}),h.jsxs("span",{className:"nc-card-main",children:[h.jsx("b",{children:K.cell}),h.jsxs("small",{children:[K.engine,K.key?`·${K.key}`:"",K.active?"":` · ${v("cell-off")}`]})]}),h.jsx("button",{className:`nc-pin${M.includes(we.key)?" on":""}`,title:v("pin"),onClick:Ne=>{Ne.stopPropagation(),J(we.key)},children:M.includes(we.key)?"★":"☆"}),(te.capabilities||[]).includes(K.active?"down":"up")&&h.jsx("button",{className:`nc-power${K.active?" on":""}${K.degraded?" warn":""}`,onClick:Ne=>{Ne.stopPropagation(),u&&u({...K,route:te.route,availableEngines:te.engines||[]})},title:K.active?v("power-off"):v("power-on"),children:h.jsx(tt,{name:"power",size:14})})]},we.key)})():(()=>{const K=we.value;return h.jsxs("div",{"data-roster-key":we.key,"data-position":ie,className:`nc-side-card${z.has(K.key)?" active":""}`,draggable:!0,onDragStart:fe=>fe.dataTransfer.setData("text/nc-session",K.key),onClick:()=>l&&l(K.key),onDoubleClick:()=>o&&o({session:K.name,node:K.node}),children:[h.jsx(Kr,{position:ie,itemKey:we.key,label:K.name,canMove:Q,onMove:(fe,Ce)=>D(ie,fe,Ce,Me),onStep:fe=>U(ie,we.key,fe,Me)}),h.jsx("span",{className:K.attached?"nc-dot on":"nc-dot"}),h.jsxs("span",{className:"nc-card-main",children:[h.jsx("b",{children:K.name}),h.jsx("small",{children:K.preview?K.preview:K.cmd?K.cmd:v("windows").replace("{n}",String(K.windows||0))})]}),K.activity?h.jsx("span",{className:"nc-rel",children:Ya(K.activity)}):null,h.jsx("button",{className:`nc-pin${M.includes(we.key)?" on":""}`,title:v("pin"),onClick:fe=>{fe.stopPropagation(),J(we.key)},children:M.includes(we.key)?"★":"☆"}),h.jsx("button",{className:`nc-technical${K.technical?" on":""}`,title:K.technical?v("mark-normal"):v("mark-technical"),"aria-label":`${K.technical?v("mark-normal"):v("mark-technical")} ${K.name}`,onClick:fe=>{fe.stopPropagation(),m&&m(K.name,!K.technical,te.route||[])},children:"T"}),h.jsx("button",{className:"nc-menu",title:v("terminate"),onClick:fe=>{fe.stopPropagation(),window.confirm(v("terminate-confirm").replace("{name}",K.name))&&p&&p(K.name,te.route)},children:"⋯"})]},we.key)})()),je.length===0&&h.jsx("div",{className:"nc-empty",children:v("no-sessions-short")})]})]},`nodo-${(te.route||[te.name]).join("/")}`)})]}),h.jsx("div",{className:"nc-side-lang",children:Av.map((te,ie)=>h.jsxs("span",{children:[ie>0&&" · ",h.jsx("button",{className:`nc-lang-btn${k===te?" on":""}`,onClick:()=>N(te),title:te,children:te.toUpperCase()})]},te))}),h.jsx("div",{className:"nc-side-resize",onPointerDown:ke,title:""})]})}function NC({label:e,count:t,state:n,onToggle:s,onFilter:o}){return h.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:s,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),s())},children:[h.jsx("span",{className:"nc-node-chevron",children:n.open?"⌄":"›"}),h.jsx("span",{className:"nc-dot on"}),h.jsx("b",{children:e}),h.jsxs("small",{children:[" · ",v("node-sessions").replace("{n}",String(t))]}),h.jsxs("select",{className:"nc-node-filter",value:n.filter,title:v(`view-${n.filter}`),onClick:l=>l.stopPropagation(),onChange:l=>o(l.target.value),children:[h.jsx("option",{value:"all",children:v("view-all")}),h.jsx("option",{value:"pinned",children:v("view-pinned")}),h.jsx("option",{value:"active",children:v("view-active")}),h.jsx("option",{value:"off",children:v("view-off")}),h.jsx("option",{value:"technical",children:v("view-technical")})]})]})}const Zh=9,Xa=.2,RC=/^[a-z0-9-]{1,32}(?:\/[a-z0-9-]{1,32}){0,3}$/,D_=/^[a-f0-9]{16,64}$/,kh=e=>RC.test(e)&&new Set(e.split("/")).size===e.split("/").length;function Wn(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!kh(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"&&D_.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"&&kh(e.node)?{session:e.session,node:e.node,...t?{ownerId:t}:{}}:null}return null}function _i(e){const t=Wn(e);return t?t.node?`${t.node}:${t.session}`:t.session:""}const L_=9,M_=24,ao=11,PC=e=>{const t=Number(e);return t>=L_&&t<=M_?t:ao};function Vr(){return{columns:[]}}function Ji(e){return e.columns.flatMap(t=>t.tiles.map(n=>_i(n)))}function DC(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(_i(o.tiles[s]));return t}const es=e=>({columns:e.columns.map(t=>({width:t.width,tiles:t.tiles.map(n=>({...n}))}))});function ed(e,t,n,s){const o=Wn(t);if(!o||Ji(e).includes(_i(o))||Ji(e).length>=Zh)return e;const l=es(e),u={session:o.session,height:1,fontSize:ao,...s||{}};if(o.node&&(u.node=o.node),o.ownerId&&(u.ownerId=o.ownerId),n==="end")return l.columns.push({width:1,tiles:[u]}),l;if(n&&typeof n.col=="number"&&typeof n.row=="number"&&l.columns[n.col])return l.columns[n.col].tiles.splice(n.row,0,u),l;if(n&&typeof n.col=="number"){const d=Math.max(0,Math.min(l.columns.length,n.col));return l.columns.splice(d,0,{width:1,tiles:[u]}),l}return l.columns.push({width:1,tiles:[u]}),l}function j_(e,t){const n=_i(t);if(!n||Ji(e).includes(n)||Ji(e).length>=Zh)return e;const s=Ji(e).length+1,o=Math.ceil(Math.sqrt(s));if(e.columns.length>=o){let S=0;for(let w=1;w<e.columns.length;w+=1)e.columns[w].tiles.length<e.columns[S].tiles.length&&(S=w);return ed(e,t,{col:S,row:e.columns[S].tiles.length})}const l=[...DC(e),n],u=new Map(e.columns.flatMap(S=>S.tiles.map(w=>[_i(w),w]))),d=Wn(t),p=e.columns.length?e.columns.reduce((S,w)=>S+(Number(w.width)||1),0)/e.columns.length:1,m=Array.from({length:o},(S,w)=>{var y;return{width:((y=e.columns[w])==null?void 0:y.width)||p,tiles:[]}});return l.forEach((S,w)=>{const y=Wn(S);if(!y)return;const _=u.get(S)||(S===n?d:{})||{},b={session:y.session,height:_.height||1,fontSize:_.fontSize||ao};y.node&&(b.node=y.node),_.ownerId&&(b.ownerId=_.ownerId),_.unavailable===!0&&(b.unavailable=!0),m[w%o].tiles.push(b)}),{columns:m.filter(S=>S.tiles.length)}}function Ga(e,t){const n=_i(t),s=es(e);for(const o of s.columns)o.tiles=o.tiles.filter(l=>_i(l)!==n);return s.columns=s.columns.filter(o=>o.tiles.length>0),s}function LC(e,t,n){const s=_i(t);if(!Ji(e).includes(s))return e;const o=e.columns.flatMap(l=>l.tiles).find(l=>_i(l)===s);return ed(Ga(e,s),s,n,{fontSize:o.fontSize,height:o.height,...o.ownerId?{ownerId:o.ownerId}:{},...o.unavailable===!0?{unavailable:!0}:{}})}function MC(e,t){if(!(t instanceof Map)||t.size===0)return e;let n=!1;const s=es(e);for(const o of s.columns)for(const l of o.tiles){const u=t.get(_i(l));if(!u)continue;const d=Wn(u);d&&(l.session=d.session,d.node?l.node=d.node:delete l.node,d.ownerId&&(l.ownerId=d.ownerId),n=!0)}return n?ur(s):e}function jC(e,t,n){const s=es(e);return s.columns[t]&&(s.columns[t].width=Math.max(Xa,Number(n)||1)),s}function TC(e,t,n,s){const o=es(e),l=o.columns[t]&&o.columns[t].tiles[n];return l&&(l.height=Math.max(Xa,Number(s)||1)),o}function AC(e,t,n,s){if(!(e.columns[t]&&e.columns[t].tiles[n]))return e;const l=es(e),u=l.columns[t].tiles[n],d=Number(u.fontSize)||ao;return u.fontSize=Math.max(L_,Math.min(M_,d+(Number(s)||0))),l}function BC(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 dg(e){for(const t of[.25,.5,.75])if(Math.abs(e-t)<=.03)return t;return e}function ur(e){if(!e||!Array.isArray(e.columns))return Vr();const t=e.columns.map(s=>({width:Math.max(Xa,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"&&kh(o.node)).filter(o=>o.ownerId==null||typeof o.ownerId=="string"&&D_.test(o.ownerId)).map(o=>{const l={session:o.session,height:Math.max(Xa,Number(o.height)||1),fontSize:PC(o.fontSize)};return o.node!=null&&(l.node=o.node),o.ownerId!=null&&(l.ownerId=o.ownerId),o.unavailable===!0&&(l.unavailable=!0),l})})).filter(s=>s.tiles.length>0),n=new Set;for(const s of t)s.tiles=s.tiles.filter(o=>!n.has(_i(o))&&n.add(_i(o))&&n.size<=Zh);return{columns:t.filter(s=>s.tiles.length>0)}}function IC(e,t,n){return!e&&t?n+1:n}function OC({session:e,node:t,token:n,readonly:s=!1,focused:o,onFocus:l,onClose:u,onOpenSingle:d,alive:p=!0,available:m=!0,fontSize:S=ao,onZoom:w,decks:y=[],currentDeck:_,onSendToDeck:b}){const C=L.useRef(()=>{}),k=L.useRef(()=>!1),N=L.useRef(()=>{}),M=L.useRef(!1),[A,B]=L.useState(!1),[ee,O]=L.useState(!1),[H,J]=L.useState(!1),[W,X]=L.useState(null),[G,j]=L.useState(0),E=L.useRef(p),P=t?`${t}:${e}`:e,z=y.filter(R=>R.id!==_&&R.available!==!1);return L.useEffect(()=>{const R=E.current;!R&&p&&j(F=>IC(R,p,F)),E.current=p},[p]),h.jsxs("div",{className:`nc-tile${o?" focused":""}`,onMouseDown:()=>l&&l(P),children:[h.jsxs("div",{className:"nc-tile-head",draggable:!0,onDragStart:R=>{R.dataTransfer.setData("text/nc-session",P),R.dataTransfer.effectAllowed="move"},children:[h.jsxs("button",{className:"nc-tile-name",onClick:()=>l&&l(P),children:[h.jsx("span",{className:p?"nc-dot on":"nc-dot"}),h.jsx("b",{children:e}),t&&h.jsxs("small",{className:"nc-tile-node",children:["@",t]})]}),h.jsxs("span",{className:"nc-tile-actions",children:[w&&h.jsx("button",{onClick:()=>w(-1),title:v("zoom-out"),children:h.jsx(tt,{name:"zoomOut",size:14})}),w&&h.jsx("button",{onClick:()=>w(1),title:v("zoom-in"),children:h.jsx(tt,{name:"zoomIn",size:14})}),b&&z.length>0&&h.jsxs("select",{className:"nc-tile-deck",title:v("send-to-deck"),value:"",onMouseDown:R=>R.stopPropagation(),onChange:R=>{const F=R.target.value;F&&b(P,F),R.target.value=""},children:[h.jsx("option",{value:"",children:v("send-to-deck")}),z.map(R=>h.jsxs("option",{value:R.id,children:[R.ownerLabel," · ",R.name]},R.id))]}),h.jsx("button",{onClick:()=>O(R=>!R),title:"composer",children:"⌨"}),h.jsx("button",{onClick:()=>J(R=>!R),title:"file",children:"📁"}),d&&h.jsx("button",{onClick:()=>d({session:e,node:t}),title:"vista singola",children:"↗"}),u&&h.jsx("button",{className:"nc-tile-close",onClick:()=>u(P),title:"chiudi",children:"✕"})]})]}),h.jsxs("div",{className:"nc-tile-body",children:[m?h.jsx(N_,{session:e,node:t,token:n,readonly:s,takeSize:!1,focused:o,sendRef:C,composerRef:k,actionRef:N,ctrlRef:M,setCtrlArmed:B,onFiles:X,fontSize:S},`${P}:${G}`):h.jsx("div",{className:"nc-tile-unavailable",children:v("deck-owner-unavailable")}),m&&H&&h.jsx("div",{className:"nc-tile-files",onMouseDown:R=>R.stopPropagation(),children:h.jsx(R_,{session:e,node:t,token:n,filesEvent:W,onClose:()=>J(!1)})})]}),m&&ee&&h.jsx("div",{className:"nc-tile-composer",onMouseDown:R=>R.stopPropagation(),children:h.jsx(P_,{submitText:R=>k.current(R),token:n,session:e,node:t})})]})}const fg=.2,pg=.28,T_=(e,t)=>Array.from((e==null?void 0:e.types)||[]).includes(t),hu=e=>T_(e,"text/nc-session"),mg=e=>{var t;return T_(e,"Files")||(((t=e==null?void 0:e.files)==null?void 0:t.length)||0)>0};function zC(e,t,n){const s=(e-n.left)/(n.width||1),o=(t-n.top)/(n.height||1);return s<pg?"left":s>1-pg?"right":o<.5?"top":"bottom"}function FC({layout:e,onLayoutChange:t,token:n,readonly:s=!1,sessionsAlive:o,focusSession:l,onFocus:u,onOpenSingle:d,decks:p=[],currentDeck:m,onSendToDeck:S}){Si();const[w,y]=L.useState(null),_=L.useRef(null),b=L.useRef([]),C=L.useRef(null);function k(W,X){const G=()=>{window.removeEventListener("pointermove",W),window.removeEventListener("pointerup",G),window.removeEventListener("pointercancel",G),window.removeEventListener("blur",G),C.current=null};window.addEventListener("pointermove",W),window.addEventListener("pointerup",G),window.addEventListener("pointercancel",G),window.addEventListener("blur",G),C.current=G}L.useEffect(()=>()=>{C.current&&C.current()},[]),L.useEffect(()=>{const W=()=>y(null);return window.addEventListener("dragend",W),window.addEventListener("drop",W),()=>{window.removeEventListener("dragend",W),window.removeEventListener("drop",W)}},[]);const N=e.columns.length,M=W=>w&&w.col===W&&w.row===void 0,A=!!w&&w.col===N,B=(W,X)=>w&&w.col===W&&w.row===X&&w.quadrant?` drop-${w.quadrant}`:"";function ee(W){if(W.preventDefault(),mg(W.dataTransfer)){y(null);return}const X=W.dataTransfer.getData("text/nc-session"),G=w;if(y(null),!X||!G)return;let j;if(G.quadrant){if(j=BC(e,G.col,G.row,G.quadrant),!j)return}else j={col:G.col};t(Ji(e).includes(X)?LC(e,X,j):ed(e,X,j))}function O(W,X){W.preventDefault(),W.stopPropagation();const G=W.clientX,j=e.columns[X].width,E=_.current&&_.current.clientWidth||1,P=e.columns[X+1];k(R=>{let F=Math.max(fg,j+(R.clientX-G)/E);if(P){const I=dg(F/(F+P.width));F=I/(1-I)*P.width}t(jC(e,X,F))})}function H(W,X,G){W.preventDefault(),W.stopPropagation();const j=W.clientY,E=e.columns[X].tiles[G].height,P=b.current[X],z=P&&P.clientHeight||1,R=e.columns[X].tiles[G+1];k(I=>{let re=Math.max(fg,E+(I.clientY-j)/z);if(R){const q=dg(re/(re+R.height));re=q/(1-q)*R.height}t(TC(e,X,G,re))})}function J(W){t(Ga(e,W))}return h.jsxs("div",{className:"nc-grid",ref:_,onDragOver:W=>{if(mg(W.dataTransfer)){W.preventDefault(),y(null);return}hu(W.dataTransfer)&&(W.preventDefault(),w&&w.col===N||y({col:N}))},onDrop:ee,onDragLeave:W=>{const X=W.relatedTarget;(!X||!(_.current&&_.current.contains(X)))&&y(null)},children:[e.columns.flatMap((W,X)=>{const G=[];return G.push(h.jsx("div",{className:`nc-col${M(X)?" drop-newcol":""}`,ref:j=>{b.current[X]=j},style:{flexGrow:W.width,flexBasis:0},onDragOver:j=>{hu(j.dataTransfer)&&(j.preventDefault(),j.stopPropagation(),w&&w.col===X&&w.row===void 0||y({col:X}))},children:W.tiles.flatMap((j,E)=>{const P=[],z=_i(j);return P.push(h.jsx("div",{className:`nc-tile-slot${B(X,E)}`,style:{flexGrow:j.height,flexBasis:0},onDragOver:R=>{if(!hu(R.dataTransfer))return;R.preventDefault(),R.stopPropagation();const F=zC(R.clientX,R.clientY,R.currentTarget.getBoundingClientRect());w&&w.col===X&&w.row===E&&w.quadrant===F||y({col:X,row:E,quadrant:F})},children:h.jsx(OC,{session:j.session,node:j.node,token:n,readonly:s,focused:l===z,onFocus:u,onClose:J,onOpenSingle:d,available:j.unavailable!==!0,alive:j.unavailable!==!0&&(!o||o.has(z)),fontSize:j.fontSize,onZoom:R=>t(AC(e,X,E,R)),decks:p,currentDeck:m,onSendToDeck:S})},z)),E<W.tiles.length-1&&P.push(h.jsx("div",{className:"nc-divider-h",onPointerDown:R=>H(R,X,E)},`h${E}`)),P})},`c${X}`)),X<N-1&&G.push(h.jsx("div",{className:"nc-divider-v",onPointerDown:j=>O(j,X)},`v${X}`)),G}),A&&h.jsx("div",{className:"nc-drop-line-v nc-drop-line-end"}),N===0&&h.jsx("div",{className:"nc-grid-empty",children:v("grid-empty")})]})}const hn="local",Li=/^[a-f0-9]{16,64}$/;function Yr(e,t){return`${e&&Li.test(e)?e:hn}:${t}`}function td(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!==hn&&!Li.test(s)||!/^[a-z0-9-]{1,32}$/.test(o)?null:{ownerId:s===hn?null:s,name:o}}function il(e){return Array.isArray(e)&&e.length?e.join("/"):""}function id(e){return{columns:ur(e).columns.map(t=>({width:t.width,tiles:t.tiles.map(n=>({...n}))}))}}function HC(e){const t=new Map;for(const n of Array.isArray(e)?e:[])n&&Li.test(String(n.instanceId||""))&&Array.isArray(n.route)&&t.set(il(n.route),n.instanceId);return t}function $C(e){const t=new Map;for(const n of Array.isArray(e)?e:[])n&&Li.test(String(n.instanceId||""))&&Array.isArray(n.route)&&t.set(n.instanceId,[...n.route]);return t}function xh(e,t,n=[]){const s=id(e),o=HC(n);for(const l of s.columns)for(const u of l.tiles)u.ownerId||(!u.node&&Li.test(String(t||""))?u.ownerId=t:u.node&&o.has(u.node)&&(u.ownerId=o.get(u.node)));return s}function Eh(e,t,n=[]){const s=id(e),o=new Map;for(const l of n)l&&Li.test(String(l.instanceId||""))&&Array.isArray(l.route)&&o.set(l.instanceId,[...l.route]);for(const l of s.columns)for(const u of l.tiles)u.ownerId&&(u.ownerId===t?(delete u.node,delete u.unavailable):o.has(u.ownerId)?(u.node=il(o.get(u.ownerId)),delete u.unavailable):u.unavailable=!0);return s}function gg(e,t,n=[]){const s=id(e),o=$C(n);for(const l of s.columns)for(const u of l.tiles)delete u.unavailable,u.ownerId&&(u.ownerId===t?delete u.node:o.has(u.ownerId)&&(u.node=il(o.get(u.ownerId))));return s}function A_(e,t,n=[]){const s=Wn(e);if(!s)return null;if(s.ownerId)return s;if(!s.node)return{...s,...Li.test(String(t||""))?{ownerId:t}:{}};const o=n.find(l=>il(l&&l.route)===s.node);return{...s,...o&&Li.test(String(o.instanceId||""))?{ownerId:o.instanceId}:{}}}const WC=/^[a-z0-9-]{1,32}$/,yi="main",B_="nc_decks",I_="nc_deck_order_v1",O_=24;function vg(e){return typeof e!="string"?"":e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,32).replace(/-+$/,"")}function Qr(e){return typeof e=="string"&&WC.test(e)}function UC(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/?$/);if(t){let n;try{n=decodeURIComponent(t[1])}catch{n=t[1]}return Qr(n)?n:yi}return yi}function KC(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/([^/]+)\/?$/);if(t){let s,o;try{s=decodeURIComponent(t[1]),o=decodeURIComponent(t[2])}catch{return{id:Yr(null,yi),ownerId:null,name:yi}}if(Li.test(s)&&Qr(o))return{id:Yr(s,o),ownerId:s,name:o}}const n=UC(e);return{id:Yr(null,n),ownerId:null,name:n}}function du(e,t){const n=typeof e=="object"&&e?{ownerId:e.ownerId||null,name:e.name}:td(e)||{ownerId:null,name:e},s=Qr(n.name)?n.name:yi,o=n.ownerId?`/deck/${encodeURIComponent(n.ownerId)}/${encodeURIComponent(s)}`:s===yi?"/":`/deck/${encodeURIComponent(s)}`;return t?`${o}#token=${encodeURIComponent(t)}`:o}function z_(e){return e===yi?"nc_grid_v1":`nc_grid_v1__${e}`}function F_(e){const t=[yi];if(Array.isArray(e)){for(const n of e)if(Qr(n)&&n!==yi&&!t.includes(n)&&t.push(n),t.length>=O_)break}return t}function ts(){return typeof localStorage<"u"?localStorage:null}function qC(){const e=ts();if(!e)return[yi];try{return F_(JSON.parse(e.getItem(B_)||"null"))}catch{return[yi]}}function VC(e){const t=ts();if(t)try{t.setItem(B_,JSON.stringify(F_(e)))}catch{}}function lo(e){return e==="local"||Li.test(String(e||""))}function nl(e,t){const n=td(e);return!!n&&(n.ownerId||"local")===t}function Zi(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,s]of Object.entries(e).slice(0,64)){if(!lo(n)||!Array.isArray(s))continue;const o=[...new Set(s.filter(l=>typeof l=="string"&&l.length<=100&&nl(l,n)))].slice(0,O_);o.length&&(t[n]=o)}return t}function Ra(e=ts()){if(!e)return{};try{return Zi(JSON.parse(e.getItem(I_)||"null"))}catch{return{}}}function fu(e,t=ts()){const n=Zi(e);if(t)try{t.setItem(I_,JSON.stringify(n))}catch{}return n}function rl(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function YC(e,t,n,s,o=[]){if(!lo(t)||n===s)return Zi(e);const l=[...new Set(o.filter(w=>nl(w,t)))];if(!l.includes(n)||!l.includes(s))return Zi(e);const u=rl(e,t).filter(w=>l.includes(w)),d=[...u,...l.filter(w=>!u.includes(w))],p=d.indexOf(n),m=d.indexOf(s);d.splice(p,1);const S=d.indexOf(s);return d.splice(p<m?S+1:S,0,n),Zi({...e,[t]:d})}function XC(e,t,n,s){if(!lo(t)||!nl(s,t))return Zi(e);const o=rl(e,t);return o.includes(n)?Zi({...e,[t]:o.map(l=>l===n?s:l)}):Zi(e)}function GC(e,t,n){return lo(t)?Zi({...e,[t]:rl(e,t).filter(s=>s!==n)}):Zi(e)}function _g(e,t={}){const n=new Map;for(const o of Array.isArray(e)?e:[]){const l=o!=null&&o.local?"local":String((o==null?void 0:o.ownerId)||"");!lo(l)||!nl(o==null?void 0:o.id,l)||(n.has(l)||n.set(l,[]),n.get(l).push(o))}const s=[];for(const[,o]of n){const l=o[0].local?"local":o[0].ownerId,u=rl(t,l),d=new Map(u.map((p,m)=>[p,m]));o.sort((p,m)=>{const S=d.has(p.id)?d.get(p.id):Number.MAX_SAFE_INTEGER,w=d.has(m.id)?d.get(m.id):Number.MAX_SAFE_INTEGER;return S-w}),s.push(...o)}return s}function Nh(e){const t=ts();if(!t)return null;try{return JSON.parse(t.getItem(z_(e))||"null")}catch{return null}}function QC(e,t){const n=ts();if(n)try{n.setItem(z_(e),JSON.stringify(t))}catch{}}const yg=52,Sg=18;function JC({ownerKey:e,deckId:t,label:n,onMove:s,onStep:o}){const l=L.useRef(null),u=L.useRef(0),[d,p]=L.useState(!1),m=()=>{var C,k,N,M;const b=l.current;(k=(C=b==null?void 0:b.over)==null?void 0:C.classList)==null||k.remove("nc-deck-over"),(M=(N=b==null?void 0:b.source)==null?void 0:N.classList)==null||M.remove("nc-deck-dragging"),u.current&&cancelAnimationFrame(u.current),u.current=0},S=(b=!1)=>{const C=l.current;if(!C)return;const k=C.target;m(),l.current=null,p(!1);try{C.handle.releasePointerCapture(C.pointerId)}catch{}b&&k&&k!==t&&s(t,k)},w=(b,C)=>{var B,ee,O,H,J,W,X,G;const k=l.current;if(!k)return;k.x=b,k.y=C;const N=(ee=(B=document.elementFromPoint(b,C))==null?void 0:B.closest)==null?void 0:ee.call(B,"[data-deck-id][data-owner-key]"),M=(O=N==null?void 0:N.dataset)==null?void 0:O.deckId,A=((H=N==null?void 0:N.dataset)==null?void 0:H.ownerKey)===e&&M&&M!==t;k.over!==(A?N:null)&&((W=(J=k.over)==null?void 0:J.classList)==null||W.remove("nc-deck-over"),k.over=A?N:null,(G=(X=k.over)==null?void 0:X.classList)==null||G.add("nc-deck-over")),k.target=A?M:null},y=()=>{var k,N;const b=l.current;if(!b){u.current=0;return}const C=(N=(k=b.container)==null?void 0:k.getBoundingClientRect)==null?void 0:N.call(k);if(C){const M=b.x<C.left+yg?-Sg:b.x>C.right-yg?Sg:0;M&&(b.container.scrollLeft+=M,w(b.x,b.y))}u.current=requestAnimationFrame(y)};L.useEffect(()=>{const b=k=>{k.key==="Escape"&&l.current&&(k.preventDefault(),S(!1))},C=()=>S(!1);return window.addEventListener("keydown",b),window.addEventListener("blur",C),()=>{window.removeEventListener("keydown",b),window.removeEventListener("blur",C),m(),l.current=null}},[t,e]);const _=b=>{var N;if(b.pointerType==="mouse"&&b.button!==0)return;b.preventDefault(),b.stopPropagation(),b.currentTarget.focus({preventScroll:!0});const C=b.currentTarget.closest("[data-deck-id][data-owner-key]"),k=b.currentTarget.closest(".nc-deckbar");l.current={pointerId:b.pointerId,handle:b.currentTarget,source:C,container:k,target:null,over:null,x:b.clientX,y:b.clientY},(N=C==null?void 0:C.classList)==null||N.add("nc-deck-dragging");try{b.currentTarget.setPointerCapture(b.pointerId)}catch{}p(!0),u.current=requestAnimationFrame(y)};return h.jsx("button",{type:"button",className:`nc-deck-handle${d?" active":""}`,"aria-label":`${v("reorder")} ${n}`,"aria-keyshortcuts":"ArrowLeft ArrowRight",title:v("reorder-deck-help"),onClick:b=>{b.preventDefault(),b.stopPropagation()},onDragStart:b=>b.preventDefault(),onKeyDown:b=>{b.key!=="ArrowLeft"&&b.key!=="ArrowRight"||(b.preventDefault(),b.stopPropagation(),o(b.key==="ArrowLeft"?-1:1))},onPointerDown:_,onPointerMove:b=>{!l.current||b.pointerId!==l.current.pointerId||(b.preventDefault(),b.stopPropagation(),w(b.clientX,b.clientY))},onPointerUp:b=>{!l.current||b.pointerId!==l.current.pointerId||(b.preventDefault(),b.stopPropagation(),S(!0))},onPointerCancel:()=>S(!1),onLostPointerCapture:()=>{l.current&&S(!1)},children:"↔"})}function ZC({decks:e=[],currentDeck:t="local:main",onCreate:n,onRename:s,onDelete:o,onReorder:l,onOpenWindow:u,onNavigate:d,saveState:p="idle",error:m="",sidebarVisible:S,onToggleSidebar:w}){Si();const[y,_]=L.useState(null),[b,C]=L.useState(""),[k,N]=L.useState(!1),[M,A]=L.useState(""),[B,ee]=L.useState(""),O=vg(b),H=Qr(O),J=[];for(const E of e){const P=E.local?"local":E.ownerId;let z=J.find(R=>R.key===P);z||(z={key:P,label:E.ownerLabel||(E.local?"Local":P),local:!!E.local,decks:[]},J.push(z)),z.decks.push(E)}const W=async()=>{if(H){N(!0),A("");try{n&&await n(O,y),C(""),_(null)}catch(E){A(String(E.message||E))}N(!1)}},X=E=>{ee(""),u&&u(E.id)||ee(E.id)},G=async E=>{if(!(E.id===t||!d||k||E.available===!1)){N(!0),A("");try{await d(E.id)}catch(P){A(String((P==null?void 0:P.message)||P))}N(!1)}},j=(E,P,z)=>{const R=E.decks.findIndex(I=>I.id===P.id),F=E.decks[R+z];R>=0&&F&&l&&!k&&l(P.id,F.id)};return h.jsxs("div",{className:"nc-deckbar",children:[w&&h.jsx("button",{className:"nc-deck-sidebar-toggle",title:v("toggle-sidebar"),onClick:w,children:S?"◀":"☰"}),h.jsx("span",{className:"nc-deckbar-label",children:v("decks")}),h.jsx("div",{className:"nc-deck-chips",children:J.map(E=>h.jsxs("span",{className:"nc-deck-owner-group",children:[h.jsx("span",{className:"nc-deck-owner",children:E.local?"Local":E.label}),E.decks.map(P=>h.jsxs("span",{"data-deck-id":P.id,"data-owner-key":E.key,className:`nc-deck-chip${P.id===t?" current":""}${P.available===!1?" offline":""}`,children:[h.jsx(JC,{ownerKey:E.key,deckId:P.id,label:`${E.label} · ${P.name}`,onMove:(z,R)=>{l&&!k&&l(z,R)},onStep:z=>j(E,P,z)}),h.jsxs("button",{className:"nc-deck-open",title:P.available===!1?`${P.ownerLabel} offline`:P.id===t?v("deck-current"):`${P.ownerLabel} · ${P.name}`,disabled:k||P.available===!1,onClick:()=>G(P),children:[P.name,P.id===t?" •":""]}),h.jsx("button",{className:"nc-deck-mini",disabled:P.available===!1,title:v("detach-deck"),onClick:()=>X(P),children:"↗"}),P.name!==yi&&h.jsxs(h.Fragment,{children:[h.jsx("button",{className:"nc-deck-mini",disabled:P.available===!1,title:v("rename-deck"),onClick:()=>{const z=(typeof window<"u"?window.prompt(v("rename-deck"),P.name):"")||"",R=vg(z);Qr(R)&&R!==P.name&&s&&s(P.id,R).catch(F=>A(String(F.message||F)))},children:"✎"}),h.jsx("button",{className:"nc-deck-mini nc-deck-del",disabled:P.available===!1,title:v("delete-deck"),onClick:()=>{(typeof window>"u"||window.confirm(v("delete-deck-confirm").replace("{name}",`${P.ownerLabel} · ${P.name}`)))&&o&&o(P.id).catch(z=>A(String(z.message||z)))},children:"✕"})]})]},P.id)),y===E.key?h.jsxs("span",{className:"nc-deck-add",children:[h.jsx("input",{autoFocus:!0,className:H||!b?"":"invalid",placeholder:v("deck-name"),value:b,onChange:P=>C(P.target.value),onKeyDown:P=>{P.key==="Enter"&&W(),P.key==="Escape"&&(C(""),_(null))}}),b&&H&&O!==b&&h.jsxs("span",{className:"nc-deck-slug",children:["→ ",O]}),h.jsx("button",{className:"nc-deck-ok",disabled:!H||k,onClick:W,children:v("create")}),h.jsx("button",{className:"nc-deck-cancel",onClick:()=>{C(""),_(null)},children:v("cancel")})]}):h.jsxs("button",{className:"nc-deck-newbtn",disabled:k||E.decks.every(P=>P.available===!1),title:`${v("new-deck")} · ${E.label}`,onClick:()=>{C(""),_(E.key)},children:["+ ",v("new")]})]},E.key))}),h.jsx("span",{className:`nc-deck-state ${p}`,title:v("deck-autosave"),children:v(p==="saving"?"saving":p==="saved"?"saved":"deck-autosave")}),(M||m)&&h.jsx("span",{className:"nc-deck-error",children:M||m}),B&&h.jsx("button",{className:"nc-deck-fallback",onClick:()=>u&&u(B),children:v("popup-blocked")})]})}var Wr={},pu,wg;function ek(){return wg||(wg=1,pu=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),pu}var mu={},zn={},bg;function mr(){if(bg)return zn;bg=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 zn.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},zn.getSymbolTotalCodewords=function(s){return t[s]},zn.getBCHDigit=function(n){let s=0;for(;n!==0;)s++,n>>>=1;return s},zn.setToSJISFunction=function(s){if(typeof s!="function")throw new Error('"toSJISFunc" is not a valid function.');e=s},zn.isKanjiModeEnabled=function(){return typeof e<"u"},zn.toSJIS=function(s){return e(s)},zn}var gu={},Cg;function nd(){return Cg||(Cg=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}}})(gu)),gu}var vu,kg;function tk(){if(kg)return vu;kg=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++}},vu=e,vu}var _u,xg;function ik(){if(xg)return _u;xg=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 l=t*this.size+n;this.data[l]=s,o&&(this.reservedBit[l]=!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]},_u=e,_u}var yu={},Eg;function nk(){return Eg||(Eg=1,(function(e){const t=mr().getSymbolSize;e.getRowColCoords=function(s){if(s===1)return[];const o=Math.floor(s/7)+2,l=t(s),u=l===145?26:Math.ceil((l-13)/(2*o-2))*2,d=[l-7];for(let p=1;p<o-1;p++)d[p]=d[p-1]-u;return d.push(6),d.reverse()},e.getPositions=function(s){const o=[],l=e.getRowColCoords(s),u=l.length;for(let d=0;d<u;d++)for(let p=0;p<u;p++)d===0&&p===0||d===0&&p===u-1||d===u-1&&p===0||o.push([l[d],l[p]]);return o}})(yu)),yu}var Su={},Ng;function rk(){if(Ng)return Su;Ng=1;const e=mr().getSymbolSize,t=7;return Su.getPositions=function(s){const o=e(s);return[[0,0],[o-t,0],[0,o-t]]},Su}var wu={},Rg;function sk(){return Rg||(Rg=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 l=o.size;let u=0,d=0,p=0,m=null,S=null;for(let w=0;w<l;w++){d=p=0,m=S=null;for(let y=0;y<l;y++){let _=o.get(w,y);_===m?d++:(d>=5&&(u+=t.N1+(d-5)),m=_,d=1),_=o.get(y,w),_===S?p++:(p>=5&&(u+=t.N1+(p-5)),S=_,p=1)}d>=5&&(u+=t.N1+(d-5)),p>=5&&(u+=t.N1+(p-5))}return u},e.getPenaltyN2=function(o){const l=o.size;let u=0;for(let d=0;d<l-1;d++)for(let p=0;p<l-1;p++){const m=o.get(d,p)+o.get(d,p+1)+o.get(d+1,p)+o.get(d+1,p+1);(m===4||m===0)&&u++}return u*t.N2},e.getPenaltyN3=function(o){const l=o.size;let u=0,d=0,p=0;for(let m=0;m<l;m++){d=p=0;for(let S=0;S<l;S++)d=d<<1&2047|o.get(m,S),S>=10&&(d===1488||d===93)&&u++,p=p<<1&2047|o.get(S,m),S>=10&&(p===1488||p===93)&&u++}return u*t.N3},e.getPenaltyN4=function(o){let l=0;const u=o.data.length;for(let p=0;p<u;p++)l+=o.data[p];return Math.abs(Math.ceil(l*100/u/5)-10)*t.N4};function n(s,o,l){switch(s){case e.Patterns.PATTERN000:return(o+l)%2===0;case e.Patterns.PATTERN001:return o%2===0;case e.Patterns.PATTERN010:return l%3===0;case e.Patterns.PATTERN011:return(o+l)%3===0;case e.Patterns.PATTERN100:return(Math.floor(o/2)+Math.floor(l/3))%2===0;case e.Patterns.PATTERN101:return o*l%2+o*l%3===0;case e.Patterns.PATTERN110:return(o*l%2+o*l%3)%2===0;case e.Patterns.PATTERN111:return(o*l%3+(o+l)%2)%2===0;default:throw new Error("bad maskPattern:"+s)}}e.applyMask=function(o,l){const u=l.size;for(let d=0;d<u;d++)for(let p=0;p<u;p++)l.isReserved(p,d)||l.xor(p,d,n(o,p,d))},e.getBestMask=function(o,l){const u=Object.keys(e.Patterns).length;let d=0,p=1/0;for(let m=0;m<u;m++){l(m),e.applyMask(m,o);const S=e.getPenaltyN1(o)+e.getPenaltyN2(o)+e.getPenaltyN3(o)+e.getPenaltyN4(o);e.applyMask(m,o),S<p&&(p=S,d=m)}return d}})(wu)),wu}var Pa={},Pg;function H_(){if(Pg)return Pa;Pg=1;const e=nd(),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 Pa.getBlocksCount=function(o,l){switch(l){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}},Pa.getTotalCodewordsCount=function(o,l){switch(l){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}},Pa}var bu={},Ks={},Dg;function ok(){if(Dg)return Ks;Dg=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]})(),Ks.log=function(s){if(s<1)throw new Error("log("+s+")");return t[s]},Ks.exp=function(s){return e[s]},Ks.mul=function(s,o){return s===0||o===0?0:e[t[s]+t[o]]},Ks}var Lg;function ak(){return Lg||(Lg=1,(function(e){const t=ok();e.mul=function(s,o){const l=new Uint8Array(s.length+o.length-1);for(let u=0;u<s.length;u++)for(let d=0;d<o.length;d++)l[u+d]^=t.mul(s[u],o[d]);return l},e.mod=function(s,o){let l=new Uint8Array(s);for(;l.length-o.length>=0;){const u=l[0];for(let p=0;p<o.length;p++)l[p]^=t.mul(o[p],u);let d=0;for(;d<l.length&&l[d]===0;)d++;l=l.slice(d)}return l},e.generateECPolynomial=function(s){let o=new Uint8Array([1]);for(let l=0;l<s;l++)o=e.mul(o,new Uint8Array([1,t.exp(l)]));return o}})(bu)),bu}var Cu,Mg;function lk(){if(Mg)return Cu;Mg=1;const e=ak();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 l=e.mod(o,this.genPoly),u=this.degree-l.length;if(u>0){const d=new Uint8Array(this.degree);return d.set(l,u),d}return l},Cu=t,Cu}var ku={},xu={},Eu={},jg;function $_(){return jg||(jg=1,Eu.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),Eu}var Vi={},Tg;function W_(){if(Tg)return Vi;Tg=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
|
+
]))+`;Vi.KANJI=new RegExp(n,"g"),Vi.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Vi.BYTE=new RegExp(s,"g"),Vi.NUMERIC=new RegExp(e,"g"),Vi.ALPHANUMERIC=new RegExp(t,"g");const o=new RegExp("^"+n+"$"),l=new RegExp("^"+e+"$"),u=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Vi.testKanji=function(p){return o.test(p)},Vi.testNumeric=function(p){return l.test(p)},Vi.testAlphanumeric=function(p){return u.test(p)},Vi}var Ag;function gr(){return Ag||(Ag=1,(function(e){const t=$_(),n=W_();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(l,u){if(!l.ccBits)throw new Error("Invalid mode: "+l);if(!t.isValid(u))throw new Error("Invalid version: "+u);return u>=1&&u<10?l.ccBits[0]:u<27?l.ccBits[1]:l.ccBits[2]},e.getBestModeForData=function(l){return n.testNumeric(l)?e.NUMERIC:n.testAlphanumeric(l)?e.ALPHANUMERIC:n.testKanji(l)?e.KANJI:e.BYTE},e.toString=function(l){if(l&&l.id)return l.id;throw new Error("Invalid mode")},e.isValid=function(l){return l&&l.bit&&l.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(l,u){if(e.isValid(l))return l;try{return s(l)}catch{return u}}})(xu)),xu}var Bg;function ck(){return Bg||(Bg=1,(function(e){const t=mr(),n=H_(),s=nd(),o=gr(),l=$_(),u=7973,d=t.getBCHDigit(u);function p(y,_,b){for(let C=1;C<=40;C++)if(_<=e.getCapacity(C,b,y))return C}function m(y,_){return o.getCharCountIndicator(y,_)+4}function S(y,_){let b=0;return y.forEach(function(C){const k=m(C.mode,_);b+=k+C.getBitsLength()}),b}function w(y,_){for(let b=1;b<=40;b++)if(S(y,b)<=e.getCapacity(b,_,o.MIXED))return b}e.from=function(_,b){return l.isValid(_)?parseInt(_,10):b},e.getCapacity=function(_,b,C){if(!l.isValid(_))throw new Error("Invalid QR Code version");typeof C>"u"&&(C=o.BYTE);const k=t.getSymbolTotalCodewords(_),N=n.getTotalCodewordsCount(_,b),M=(k-N)*8;if(C===o.MIXED)return M;const A=M-m(C,_);switch(C){case o.NUMERIC:return Math.floor(A/10*3);case o.ALPHANUMERIC:return Math.floor(A/11*2);case o.KANJI:return Math.floor(A/13);case o.BYTE:default:return Math.floor(A/8)}},e.getBestVersionForData=function(_,b){let C;const k=s.from(b,s.M);if(Array.isArray(_)){if(_.length>1)return w(_,k);if(_.length===0)return 1;C=_[0]}else C=_;return p(C.mode,C.getLength(),k)},e.getEncodedBits=function(_){if(!l.isValid(_)||_<7)throw new Error("Invalid QR Code version");let b=_<<12;for(;t.getBCHDigit(b)-d>=0;)b^=u<<t.getBCHDigit(b)-d;return _<<12|b}})(ku)),ku}var Nu={},Ig;function uk(){if(Ig)return Nu;Ig=1;const e=mr(),t=1335,n=21522,s=e.getBCHDigit(t);return Nu.getEncodedBits=function(l,u){const d=l.bit<<3|u;let p=d<<10;for(;e.getBCHDigit(p)-s>=0;)p^=t<<e.getBCHDigit(p)-s;return(d<<10|p)^n},Nu}var Ru={},Pu,Og;function hk(){if(Og)return Pu;Og=1;const e=gr();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,l,u;for(o=0;o+3<=this.data.length;o+=3)l=this.data.substr(o,3),u=parseInt(l,10),s.put(u,10);const d=this.data.length-o;d>0&&(l=this.data.substr(o),u=parseInt(l,10),s.put(u,d*3+1))},Pu=t,Pu}var Du,zg;function dk(){if(zg)return Du;zg=1;const e=gr(),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 l;for(l=0;l+2<=this.data.length;l+=2){let u=t.indexOf(this.data[l])*45;u+=t.indexOf(this.data[l+1]),o.put(u,11)}this.data.length%2&&o.put(t.indexOf(this.data[l]),6)},Du=n,Du}var Lu,Fg;function fk(){if(Fg)return Lu;Fg=1;const e=gr();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)},Lu=t,Lu}var Mu,Hg;function pk(){if(Hg)return Mu;Hg=1;const e=gr(),t=mr();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 l=t.toSJIS(this.data[o]);if(l>=33088&&l<=40956)l-=33088;else if(l>=57408&&l<=60351)l-=49472;else throw new Error("Invalid SJIS character: "+this.data[o]+`
|
|
83
|
+
Make sure your charset is UTF-8`);l=(l>>>8&255)*192+(l&255),s.put(l,13)}},Mu=n,Mu}var ju={exports:{}},$g;function mk(){return $g||($g=1,(function(e){var t={single_source_shortest_paths:function(n,s,o){var l={},u={};u[s]=0;var d=t.PriorityQueue.make();d.push(s,0);for(var p,m,S,w,y,_,b,C,k;!d.empty();){p=d.pop(),m=p.value,w=p.cost,y=n[m]||{};for(S in y)y.hasOwnProperty(S)&&(_=y[S],b=w+_,C=u[S],k=typeof u[S]>"u",(k||C>b)&&(u[S]=b,d.push(S,b),l[S]=m))}if(typeof o<"u"&&typeof u[o]>"u"){var N=["Could not find a path from ",s," to ",o,"."].join("");throw new Error(N)}return l},extract_shortest_path_from_predecessor_list:function(n,s){for(var o=[],l=s;l;)o.push(l),n[l],l=n[l];return o.reverse(),o},find_path:function(n,s,o){var l=t.single_source_shortest_paths(n,s,o);return t.extract_shortest_path_from_predecessor_list(l,o)},PriorityQueue:{make:function(n){var s=t.PriorityQueue,o={},l;n=n||{};for(l in s)s.hasOwnProperty(l)&&(o[l]=s[l]);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})(ju)),ju.exports}var Wg;function gk(){return Wg||(Wg=1,(function(e){const t=gr(),n=hk(),s=dk(),o=fk(),l=pk(),u=W_(),d=mr(),p=mk();function m(N){return unescape(encodeURIComponent(N)).length}function S(N,M,A){const B=[];let ee;for(;(ee=N.exec(A))!==null;)B.push({data:ee[0],index:ee.index,mode:M,length:ee[0].length});return B}function w(N){const M=S(u.NUMERIC,t.NUMERIC,N),A=S(u.ALPHANUMERIC,t.ALPHANUMERIC,N);let B,ee;return d.isKanjiModeEnabled()?(B=S(u.BYTE,t.BYTE,N),ee=S(u.KANJI,t.KANJI,N)):(B=S(u.BYTE_KANJI,t.BYTE,N),ee=[]),M.concat(A,B,ee).sort(function(H,J){return H.index-J.index}).map(function(H){return{data:H.data,mode:H.mode,length:H.length}})}function y(N,M){switch(M){case t.NUMERIC:return n.getBitsLength(N);case t.ALPHANUMERIC:return s.getBitsLength(N);case t.KANJI:return l.getBitsLength(N);case t.BYTE:return o.getBitsLength(N)}}function _(N){return N.reduce(function(M,A){const B=M.length-1>=0?M[M.length-1]:null;return B&&B.mode===A.mode?(M[M.length-1].data+=A.data,M):(M.push(A),M)},[])}function b(N){const M=[];for(let A=0;A<N.length;A++){const B=N[A];switch(B.mode){case t.NUMERIC:M.push([B,{data:B.data,mode:t.ALPHANUMERIC,length:B.length},{data:B.data,mode:t.BYTE,length:B.length}]);break;case t.ALPHANUMERIC:M.push([B,{data:B.data,mode:t.BYTE,length:B.length}]);break;case t.KANJI:M.push([B,{data:B.data,mode:t.BYTE,length:m(B.data)}]);break;case t.BYTE:M.push([{data:B.data,mode:t.BYTE,length:m(B.data)}])}}return M}function C(N,M){const A={},B={start:{}};let ee=["start"];for(let O=0;O<N.length;O++){const H=N[O],J=[];for(let W=0;W<H.length;W++){const X=H[W],G=""+O+W;J.push(G),A[G]={node:X,lastCount:0},B[G]={};for(let j=0;j<ee.length;j++){const E=ee[j];A[E]&&A[E].node.mode===X.mode?(B[E][G]=y(A[E].lastCount+X.length,X.mode)-y(A[E].lastCount,X.mode),A[E].lastCount+=X.length):(A[E]&&(A[E].lastCount=X.length),B[E][G]=y(X.length,X.mode)+4+t.getCharCountIndicator(X.mode,M))}}ee=J}for(let O=0;O<ee.length;O++)B[ee[O]].end=0;return{map:B,table:A}}function k(N,M){let A;const B=t.getBestModeForData(N);if(A=t.from(M,B),A!==t.BYTE&&A.bit<B.bit)throw new Error('"'+N+'" cannot be encoded with mode '+t.toString(A)+`.
|
|
84
|
+
Suggested mode is: `+t.toString(B));switch(A===t.KANJI&&!d.isKanjiModeEnabled()&&(A=t.BYTE),A){case t.NUMERIC:return new n(N);case t.ALPHANUMERIC:return new s(N);case t.KANJI:return new l(N);case t.BYTE:return new o(N)}}e.fromArray=function(M){return M.reduce(function(A,B){return typeof B=="string"?A.push(k(B,null)):B.data&&A.push(k(B.data,B.mode)),A},[])},e.fromString=function(M,A){const B=w(M,d.isKanjiModeEnabled()),ee=b(B),O=C(ee,A),H=p.find_path(O.map,"start","end"),J=[];for(let W=1;W<H.length-1;W++)J.push(O.table[H[W]].node);return e.fromArray(_(J))},e.rawSplit=function(M){return e.fromArray(w(M,d.isKanjiModeEnabled()))}})(Ru)),Ru}var Ug;function vk(){if(Ug)return mu;Ug=1;const e=mr(),t=nd(),n=tk(),s=ik(),o=nk(),l=rk(),u=sk(),d=H_(),p=lk(),m=ck(),S=uk(),w=gr(),y=gk();function _(O,H){const J=O.size,W=l.getPositions(H);for(let X=0;X<W.length;X++){const G=W[X][0],j=W[X][1];for(let E=-1;E<=7;E++)if(!(G+E<=-1||J<=G+E))for(let P=-1;P<=7;P++)j+P<=-1||J<=j+P||(E>=0&&E<=6&&(P===0||P===6)||P>=0&&P<=6&&(E===0||E===6)||E>=2&&E<=4&&P>=2&&P<=4?O.set(G+E,j+P,!0,!0):O.set(G+E,j+P,!1,!0))}}function b(O){const H=O.size;for(let J=8;J<H-8;J++){const W=J%2===0;O.set(J,6,W,!0),O.set(6,J,W,!0)}}function C(O,H){const J=o.getPositions(H);for(let W=0;W<J.length;W++){const X=J[W][0],G=J[W][1];for(let j=-2;j<=2;j++)for(let E=-2;E<=2;E++)j===-2||j===2||E===-2||E===2||j===0&&E===0?O.set(X+j,G+E,!0,!0):O.set(X+j,G+E,!1,!0)}}function k(O,H){const J=O.size,W=m.getEncodedBits(H);let X,G,j;for(let E=0;E<18;E++)X=Math.floor(E/3),G=E%3+J-8-3,j=(W>>E&1)===1,O.set(X,G,j,!0),O.set(G,X,j,!0)}function N(O,H,J){const W=O.size,X=S.getEncodedBits(H,J);let G,j;for(G=0;G<15;G++)j=(X>>G&1)===1,G<6?O.set(G,8,j,!0):G<8?O.set(G+1,8,j,!0):O.set(W-15+G,8,j,!0),G<8?O.set(8,W-G-1,j,!0):G<9?O.set(8,15-G-1+1,j,!0):O.set(8,15-G-1,j,!0);O.set(W-8,8,1,!0)}function M(O,H){const J=O.size;let W=-1,X=J-1,G=7,j=0;for(let E=J-1;E>0;E-=2)for(E===6&&E--;;){for(let P=0;P<2;P++)if(!O.isReserved(X,E-P)){let z=!1;j<H.length&&(z=(H[j]>>>G&1)===1),O.set(X,E-P,z),G--,G===-1&&(j++,G=7)}if(X+=W,X<0||J<=X){X-=W,W=-W;break}}}function A(O,H,J){const W=new n;J.forEach(function(P){W.put(P.mode.bit,4),W.put(P.getLength(),w.getCharCountIndicator(P.mode,O)),P.write(W)});const X=e.getSymbolTotalCodewords(O),G=d.getTotalCodewordsCount(O,H),j=(X-G)*8;for(W.getLengthInBits()+4<=j&&W.put(0,4);W.getLengthInBits()%8!==0;)W.putBit(0);const E=(j-W.getLengthInBits())/8;for(let P=0;P<E;P++)W.put(P%2?17:236,8);return B(W,O,H)}function B(O,H,J){const W=e.getSymbolTotalCodewords(H),X=d.getTotalCodewordsCount(H,J),G=W-X,j=d.getBlocksCount(H,J),E=W%j,P=j-E,z=Math.floor(W/j),R=Math.floor(G/j),F=R+1,I=z-R,re=new p(I);let q=0;const D=new Array(j),U=new Array(j);let Q=0;const ae=new Uint8Array(O.buffer);for(let ke=0;ke<j;ke++){const Oe=ke<P?R:F;D[ke]=ae.slice(q,q+Oe),U[ke]=re.encode(D[ke]),q+=Oe,Q=Math.max(Q,Oe)}const se=new Uint8Array(W);let le=0,pe,ce;for(pe=0;pe<Q;pe++)for(ce=0;ce<j;ce++)pe<D[ce].length&&(se[le++]=D[ce][pe]);for(pe=0;pe<I;pe++)for(ce=0;ce<j;ce++)se[le++]=U[ce][pe];return se}function ee(O,H,J,W){let X;if(Array.isArray(O))X=y.fromArray(O);else if(typeof O=="string"){let z=H;if(!z){const R=y.rawSplit(O);z=m.getBestVersionForData(R,J)}X=y.fromString(O,z||40)}else throw new Error("Invalid data");const G=m.getBestVersionForData(X,J);if(!G)throw new Error("The amount of data is too big to be stored in a QR Code");if(!H)H=G;else if(H<G)throw new Error(`
|
|
85
|
+
The chosen QR Code version cannot contain this amount of data.
|
|
86
|
+
Minimum version required to store current data is: `+G+`.
|
|
87
|
+
`);const j=A(H,J,X),E=e.getSymbolSize(H),P=new s(E);return _(P,H),b(P),C(P,H),N(P,J,0),H>=7&&k(P,H),M(P,j),isNaN(W)&&(W=u.getBestMask(P,N.bind(null,P,J))),u.applyMask(W,P),N(P,J,W),{modules:P,version:H,errorCorrectionLevel:J,maskPattern:W,segments:X}}return mu.create=function(H,J){if(typeof H>"u"||H==="")throw new Error("No input text");let W=t.M,X,G;return typeof J<"u"&&(W=t.from(J.errorCorrectionLevel,t.M),X=m.from(J.version),G=u.from(J.maskPattern),J.toSJISFunc&&e.setToSJISFunction(J.toSJISFunc)),ee(H,X,W,G)},mu}var Tu={},Au={},Kg;function U_(){return Kg||(Kg=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(l){return[l,l]}))),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,l=s.width&&s.width>=21?s.width:void 0,u=s.scale||4;return{width:l,scale:l?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 l=e.getScale(s,o);return Math.floor((s+o.margin*2)*l)},e.qrToImageData=function(s,o,l){const u=o.modules.size,d=o.modules.data,p=e.getScale(u,l),m=Math.floor((u+l.margin*2)*p),S=l.margin*p,w=[l.color.light,l.color.dark];for(let y=0;y<m;y++)for(let _=0;_<m;_++){let b=(y*m+_)*4,C=l.color.light;if(y>=S&&_>=S&&y<m-S&&_<m-S){const k=Math.floor((y-S)/p),N=Math.floor((_-S)/p);C=w[d[k*u+N]?1:0]}s[b++]=C.r,s[b++]=C.g,s[b++]=C.b,s[b]=C.a}}})(Au)),Au}var qg;function _k(){return qg||(qg=1,(function(e){const t=U_();function n(o,l,u){o.clearRect(0,0,l.width,l.height),l.style||(l.style={}),l.height=u,l.width=u,l.style.height=u+"px",l.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(l,u,d){let p=d,m=u;typeof p>"u"&&(!u||!u.getContext)&&(p=u,u=void 0),u||(m=s()),p=t.getOptions(p);const S=t.getImageWidth(l.modules.size,p),w=m.getContext("2d"),y=w.createImageData(S,S);return t.qrToImageData(y.data,l,p),n(w,m,S),w.putImageData(y,0,0),m},e.renderToDataURL=function(l,u,d){let p=d;typeof p>"u"&&(!u||!u.getContext)&&(p=u,u=void 0),p||(p={});const m=e.render(l,u,p),S=p.type||"image/png",w=p.rendererOpts||{};return m.toDataURL(S,w.quality)}})(Tu)),Tu}var Bu={},Vg;function yk(){if(Vg)return Bu;Vg=1;const e=U_();function t(o,l){const u=o.a/255,d=l+'="'+o.hex+'"';return u<1?d+" "+l+'-opacity="'+u.toFixed(2).slice(1)+'"':d}function n(o,l,u){let d=o+l;return typeof u<"u"&&(d+=" "+u),d}function s(o,l,u){let d="",p=0,m=!1,S=0;for(let w=0;w<o.length;w++){const y=Math.floor(w%l),_=Math.floor(w/l);!y&&!m&&(m=!0),o[w]?(S++,w>0&&y>0&&o[w-1]||(d+=m?n("M",y+u,.5+_+u):n("m",p,0),p=0,m=!1),y+1<l&&o[w+1]||(d+=n("h",S),S=0)):p++}return d}return Bu.render=function(l,u,d){const p=e.getOptions(u),m=l.modules.size,S=l.modules.data,w=m+p.margin*2,y=p.color.light.a?"<path "+t(p.color.light,"fill")+' d="M0 0h'+w+"v"+w+'H0z"/>':"",_="<path "+t(p.color.dark,"stroke")+' d="'+s(S,m,p.margin)+'"/>',b='viewBox="0 0 '+w+" "+w+'"',k='<svg xmlns="http://www.w3.org/2000/svg" '+(p.width?'width="'+p.width+'" height="'+p.width+'" ':"")+b+' shape-rendering="crispEdges">'+y+_+`</svg>
|
|
88
|
+
`;return typeof d=="function"&&d(null,k),k},Bu}var Yg;function Sk(){if(Yg)return Wr;Yg=1;const e=ek(),t=vk(),n=_k(),s=yk();function o(l,u,d,p,m){const S=[].slice.call(arguments,1),w=S.length,y=typeof S[w-1]=="function";if(!y&&!e())throw new Error("Callback required as last argument");if(y){if(w<2)throw new Error("Too few arguments provided");w===2?(m=d,d=u,u=p=void 0):w===3&&(u.getContext&&typeof m>"u"?(m=p,p=void 0):(m=p,p=d,d=u,u=void 0))}else{if(w<1)throw new Error("Too few arguments provided");return w===1?(d=u,u=p=void 0):w===2&&!u.getContext&&(p=d,d=u,u=void 0),new Promise(function(_,b){try{const C=t.create(d,p);_(l(C,u,p))}catch(C){b(C)}})}try{const _=t.create(d,p);m(null,l(_,u,p))}catch(_){m(_)}}return Wr.create=t.create,Wr.toCanvas=o.bind(null,n.render),Wr.toDataURL=o.bind(null,n.renderToDataURL),Wr.toString=o.bind(null,function(l,u,d){return s.render(l,d)}),Wr}var wk=Sk();const bk=jh(wk),K_=/^[a-z0-9-]{1,32}$/,Ck=/^[A-Za-z0-9._-]{1,32}$/,kk=/^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/,xk=320;function Ek(e){return typeof e=="string"&&K_.test(e)}const Nk=64;function Rh(e){if(typeof e!="string")return!1;const t=e.trim();return t.length>0&&t.length<=Nk&&!/[\x00-\x1f\x7f]/.test(t)}function Xr(e){return String(e??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32).replace(/-+$/g,"")||"node"}function q_(e){if(typeof e!="string"||!e||e.length>xk||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:Ck.test(e.slice(0,t))&&kk.test(e.slice(t+1))}function Xg(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 Gg({name:e,ssh:t,sshPort:n,remotePort:s}={}){const o=typeof e=="string"?e.trim():e,l=typeof t=="string"?t.trim():t;if(!Ek(o))return{ok:!1,error:"err-node-name"};if(!q_(l))return{ok:!1,error:"err-ssh"};const u=Xg(n);if(u===void 0)return{ok:!1,error:"err-ssh-port"};const d=Xg(s);if(d===void 0)return{ok:!1,error:"err-node-port"};const p={name:o,ssh:l};return u!==null&&(p.sshPort=u),d!==null&&(p.remotePort=d),{ok:!0,value:p}}function Rk(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 Qg(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?Rk(e.since,t):null}}const Pk=new Set(["v","instanceId","port","label","invite"]),Dk=new Set(["v","instanceId","port","label","invite","name","ssh","sshPort"]);function Lk(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,l=>l.charCodeAt(0));return typeof TextDecoder<"u"?new TextDecoder().decode(o):Buffer.from(o).toString("utf8")}function Mk(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(Lk(t))}catch{return{ok:!1}}if(!n||typeof n!="object"||Array.isArray(n))return{ok:!1};const s=n.v===1?Pk:n.v===2?Dk: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 l={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"||!K_.test(n.name))return{ok:!1};l.name=n.name}if(n.ssh!==void 0){if(!q_(n.ssh))return{ok:!1};l.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};l.sshPort=u}}return l}function jk(e,t,n=new Set){if(!t||!t.ok)return e;const s={...e},o=(l,u)=>{u==null||u===""||n.has(l)||(s[l]=u)};return o("label",t.label),t.version===2&&(o("name",t.name||(t.ssh?Xr(t.label):"")),o("ssh",t.ssh),t.sshPort!==void 0&&o("sshPort",String(t.sshPort))),s}function Jg(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.data=="string"?e.data.trim():""}function Tk(e){const t=String(e||"").trim();if(!t)return{kind:"empty"};const n=Mk(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 Ak(e,t,n=new Set,s=!1){if(!t||!t.ok)return e;const o=jk(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 Zg(e,t,n=new Set,s=!1){const o=String(t||"").trim(),l=Tk(o);let u={...e,pairingUrl:o};return(l.kind==="complete"||l.kind==="partial")&&(u={...Ak(u,l.decoded,n,s),pairingUrl:o}),{classification:l,form:u}}function Bk(e,{deviceDefault:t=""}={}){const n={name:e.name,ssh:e.ssh,pairingUrl:e.pairingUrl,...e.label?{label:e.label}:{},...e.sshPort?{sshPort:Number(e.sshPort)}:{}},s=e.localLabel||t;return s&&(n.localLabel=s),n}function Ik(){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 Ok=["validation","conflict","ssh-start","ssh-ready","join","tunnel-final","confirm","health"];function zk(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:"",retryable:typeof t.retryable=="boolean"?t.retryable:!n,message:s||String(e&&e.message||e)}}const Fk="modulepreload",Hk=function(e){return"/"+e},ev={},$k=function(t,n,s){let o=Promise.resolve();if(n&&n.length>0){let u=function(m){return Promise.all(m.map(S=>Promise.resolve(S).then(w=>({status:"fulfilled",value:w}),w=>({status:"rejected",reason:w}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),p=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));o=u(n.map(m=>{if(m=Hk(m),m in ev)return;ev[m]=!0;const S=m.endsWith(".css"),w=S?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${w}`))return;const y=document.createElement("link");if(y.rel=S?"stylesheet":Fk,S||(y.as="script"),y.crossOrigin="",y.href=m,p&&y.setAttribute("nonce",p),document.head.appendChild(y),S)return new Promise((_,b)=>{y.addEventListener("load",_),y.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${m}`)))})}))}function l(u){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=u,window.dispatchEvent(d),!d.defaultPrevented)throw u}return o.then(u=>{for(const d of u||[])d.status==="rejected"&&l(d.reason);return t().catch(l)})};class Ve{constructor(t,n,s,o,l){this._legacyCanvasSize=Ve.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||l?"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||l||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"),l=this.$overlay.style,l.position="absolute",l.display="none",l.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 d=window.getComputedStyle(t);d.display==="none"&&(t.style.setProperty("display","block","important"),u=!0),d.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=Ve.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 Ve.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,l)=>({id:o.deviceId,label:o.label||(l===0?"Default Camera":`Camera ${l+1}`)}))}finally{s&&(console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"),Ve._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"),Ve._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(),Ve._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?Ve._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&&(Ve._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,l=!1,u=!1){let d,p=!1;n&&("scanRegion"in n||"qrEngine"in n||"canvas"in n||"disallowCanvasResizing"in n||"alsoTryWithoutScanRegion"in n||"returnDetailedScanResult"in n)?(d=n.scanRegion,s=n.qrEngine,o=n.canvas,l=n.disallowCanvasResizing||!1,u=n.alsoTryWithoutScanRegion||!1,p=!0):console.warn(n||s||o||l||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,S;[s,m]=await Promise.all([s||Ve.createQrEngine(),Ve._loadImage(t)]),[o,S]=Ve._drawToCanvas(m,d,o,l);let w;if(s instanceof Worker){let y=s;n||Ve._postWorkerMessageSync(y,"inversionMode","both"),w=await new Promise((_,b)=>{let C,k,N,M=-1;k=B=>{B.data.id===M&&(y.removeEventListener("message",k),y.removeEventListener("error",N),clearTimeout(C),B.data.data!==null?_({data:B.data.data,cornerPoints:Ve._convertPoints(B.data.cornerPoints,d)}):b(Ve.NO_QR_CODE_FOUND))},N=B=>{y.removeEventListener("message",k),y.removeEventListener("error",N),clearTimeout(C),b("Scanner error: "+(B?B.message||B:"Unknown Error"))},y.addEventListener("message",k),y.addEventListener("error",N),C=setTimeout(()=>N("timeout"),1e4);let A=S.getImageData(0,0,o.width,o.height);M=Ve._postWorkerMessageSync(y,"decode",A,[A.data.buffer])})}else w=await Promise.race([new Promise((y,_)=>window.setTimeout(()=>_("Scanner error: timeout"),1e4)),(async()=>{try{var[y]=await s.detect(o);if(!y)throw Ve.NO_QR_CODE_FOUND;return{data:y.rawValue,cornerPoints:Ve._convertPoints(y.cornerPoints,d)}}catch(_){if(y=_.message||_,/not implemented|service unavailable/.test(y))return Ve._disableBarcodeDetector=!0,Ve.scanImage(t,{scanRegion:d,canvas:o,disallowCanvasResizing:l,alsoTryWithoutScanRegion:u});throw`Scanner error: ${y}`}})()]);return p?w:w.data}catch(m){if(!d||!u)throw m;let S=await Ve.scanImage(t,{qrEngine:s,canvas:o,disallowCanvasResizing:l});return p?S:S.data}finally{n||Ve._postWorkerMessage(s,"close")}}setGrayscaleWeights(t,n,s,o=!0){Ve._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:t,green:n,blue:s,useIntegerApproximation:o})}setInversionMode(t){Ve._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=()=>$k(()=>import("./qr-scanner-worker.min-D85Z9gVD.js"),[]).then(s=>s.createWorker()),!(!Ve._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,l=t.offsetHeight,u=t.offsetLeft,d=t.offsetTop,p=window.getComputedStyle(t),m=p.objectFit,S=n/s,w=o/l;switch(m){case"none":var y=n,_=s;break;case"fill":y=o,_=l;break;default:(m==="cover"?S>w:S<w)?(_=l,y=_*S):(y=o,_=y/S),m==="scale-down"&&(y=Math.min(y,n),_=Math.min(_,s))}var[b,C]=p.objectPosition.split(" ").map((N,M)=>{const A=parseFloat(N);return N.endsWith("%")?(M?l-_:o-y)*A/100:A});p=this._scanRegion.width||n,w=this._scanRegion.height||s,m=this._scanRegion.x||0;var k=this._scanRegion.y||0;S=this.$overlay.style,S.width=`${p/n*y}px`,S.height=`${w/s*_}px`,S.top=`${d+C+k/s*_}px`,s=/scaleX\(-1\)/.test(t.style.transform),S.left=`${u+(s?o-b-y:b)+(s?n-m-p:m)/n*y}px`,S.transform=t.style.transform}})}static _convertPoints(t,n){if(!n)return t;let s=n.x||0,o=n.y||0,l=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*l+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 Ve.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(o){if(!this._active)return;this._onDecodeError(o)}!Ve._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=Ve.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:l})=>`${o},${l}`).join(" ")),this.$codeOutlineHighlight.style.display="")):this.$codeOutlineHighlight&&!this._codeOutlineHighlightRemovalTimeout&&(this._codeOutlineHighlightRemovalTimeout=setTimeout(()=>this.$codeOutlineHighlight.style.display="none",100))}this._scanFrame()})}_onDecodeError(t){t!==Ve.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 l=await navigator.mediaDevices.getUserMedia({video:o,audio:!1}),u=this._getFacingMode(l)||(o.facingMode?this._preferredCamera:this._preferredCamera==="environment"?"user":"environment");return{stream:l,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 l=n&&n.x?n.x:0,u=n&&n.y?n.y:0,d=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:d,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,l,u,d,p,0,0,s.width,s.height),[s,n]}static async _loadImage(t){if(t instanceof Image)return await Ve._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 Ve._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=l=>{t.removeEventListener("load",o),t.removeEventListener("error",o),l instanceof ErrorEvent?s("Image load error"):n()};t.addEventListener("load",o),t.addEventListener("error",o)})}static async _postWorkerMessage(t,n,s,o){return Ve._postWorkerMessageSync(await t,n,s,o)}static _postWorkerMessageSync(t,n,s,o){if(!(t instanceof Worker))return-1;let l=Ve._workerMessageId++;return t.postMessage({id:l,type:n,data:s},o),l}}Ve.DEFAULT_CANVAS_SIZE=400;Ve.NO_QR_CODE_FOUND="No QR code found";Ve._disableBarcodeDetector=!1;Ve._workerMessageId=0;function Wk({onResult:e,onClose:t}){const n=L.useRef(null),s=L.useRef(null),o=L.useRef(!1),[l,u]=L.useState("");L.useEffect(()=>{let p=!1;const m=n.current,S=w=>{p||o.current||(o.current=!0,e(w))};return(async()=>{if(typeof navigator>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!="function"){u(v("qr-unsupported"));return}let w=!1;try{w=await Ve.hasCamera()}catch{w=!1}if(!w){u(v("qr-no-camera"));return}if(p||!m)return;const y=new Ve(m,_=>{const b=Jg(_);b&&S(b)},{returnDetailedScanResult:!0,preferredCamera:"environment",calculateScanRegion:_=>{const b=_.videoWidth||640,C=_.videoHeight||480,k=Math.max(1,Math.round(Math.min(b,C)*.92));return{x:Math.round((b-k)/2),y:Math.round((C-k)/2),width:k,height:k,downScaledWidth:600,downScaledHeight:600}},highlightScanRegion:!0,highlightCodeOutline:!0});s.current=y;try{await y.start()}catch(_){if(p)return;const b=_&&_.name||"";u(v(b==="NotAllowedError"||b==="SecurityError"?"qr-permission":b==="NotFoundError"||b==="OverconstrainedError"||b==="NotReadableError"?"qr-no-camera":"qr-unsupported"))}})(),()=>{p=!0;const w=s.current;if(w){try{w.stop()}catch{}try{w.destroy()}catch{}s.current=null}const y=m,_=y&&y.srcObject;if(_&&typeof _.getTracks=="function"){for(const b of _.getTracks())try{b.stop()}catch{}try{y.srcObject=null}catch{}}}},[]);const d=async p=>{const m=p.target.files&&p.target.files[0];if(p.target.value="",!!m)try{const S=await Ve.scanImage(m,{returnDetailedScanResult:!0}),w=Jg(S);if(!w)throw new Error("empty");o.current||(o.current=!0,e(w))}catch{u(v("pairing-qr-invalid"))}};return h.jsx("div",{className:"nc-sheet-overlay nc-qr-overlay",onClick:t,children:h.jsxs("div",{className:"nc-sheet nc-qr-modal",onClick:p=>p.stopPropagation(),children:[h.jsx("div",{className:"nc-sheet-head",children:h.jsx("b",{children:v("scan-qr")})}),h.jsx("video",{ref:n,className:"nc-qr-video",playsInline:!0,muted:!0}),l&&h.jsx("div",{className:"nc-err",role:"alert",children:l}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsxs("label",{className:"nc-btn ghost nc-qr-upload",children:[v("qr-upload"),h.jsx("input",{type:"file",accept:"image/*",hidden:!0,onChange:d})]}),h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:t,children:v("cancel")})]})]})})}const tv=()=>({name:"",label:"",ssh:"",sshPort:"",pairingUrl:"",localLabel:""});function V_({token:e,initial:t="",autoStart:n=!1,deviceDefault:s="",readonly:o=!1,onSuccess:l,onBusyChange:u}){const[d,p]=L.useState(tv),[m,S]=L.useState(!1),[w,y]=L.useState(!1),[_,b]=L.useState("idle"),[C,k]=L.useState(null),[N,M]=L.useState(""),[A,B]=L.useState(!1),ee=L.useRef(Ik()),O=L.useRef(new Set),H=_==="busy";L.useEffect(()=>(u&&u(H),()=>{u&&u(!1)}),[H,u]);const J=async P=>{const z=String(P.pairingUrl||"").trim();if(ee.current.start(z)){b("busy"),k(null),M("");try{await Nw(e,Bk(P,{deviceDefault:s})),b("ok"),S(!1),p(tv()),O.current=new Set,B(!1),ee.current.finish(),l&&await l()}catch(R){const F=zk(R);k(F),b("idle"),ee.current.finish(),(F.stage==="validation"||F.stage==="conflict"||F.stage==="ssh-start"||F.stage==="ssh-ready"||String(F.code||"").startsWith("ssh-"))&&S(!0)}}},W=(P,z=!0)=>{const{classification:R,form:F}=Zg(d,P,O.current,A),I=F.pairingUrl;if(k(null),M(""),_==="ok"&&b("idle"),p(F),R.kind==="invalid"){k({stage:"validation",code:"bad-link",message:v("pair-invalid-link"),hint:v("pair-invalid-hint"),retryable:!0});return}if(R.kind==="partial"){S(!0),M(R.missing.includes("ssh")?v("pair-missing-ssh"):v("pair-missing-name"));return}R.kind==="complete"&&z&&!o&&ee.current.canAuto(I)&&J(F)};L.useEffect(()=>{t&&W(t,n)},[]);const X=()=>{const P=String(d.pairingUrl||"").trim(),{classification:z,form:R}=Zg(d,P,O.current,A);if(p(R),M(""),k(null),z.kind==="empty"){k({stage:"validation",message:v("pairing-required"),retryable:!0});return}if(z.kind==="invalid"){k({stage:"validation",code:"bad-link",message:v("pair-invalid-link"),hint:v("pair-invalid-hint"),retryable:!0});return}if(!R.ssh||!R.name){S(!0),M(R.ssh?v("pair-missing-name"):v("pair-missing-ssh"));return}if(R.label&&!Rh(R.label)){k({stage:"validation",message:v("err-label"),retryable:!0});return}if(R.localLabel&&!Rh(R.localLabel)){k({stage:"validation",message:v("err-label"),retryable:!0});return}ee.current.reset(P),J(R)},G=async()=>{try{if(!navigator.clipboard||typeof navigator.clipboard.readText!="function")throw new Error("unsupported");const P=await navigator.clipboard.readText();P&&P.trim()?W(P):M(v("pair-clipboard-empty"))}catch{M(v("pair-clipboard-denied"))}},j=(P,z)=>{O.current.add(P),p(R=>({...R,[P]:z}))},E=C&&C.stage&&(Ok.includes(C.stage)||C.stage==="internal")?v(`pair-stage-${C.stage}`):v("pair-stage-generic");return h.jsxs("div",{className:"nc-set-form nc-pair-card",children:[h.jsx("div",{className:"nc-sheet-label",children:v("pair-card-title")}),h.jsx("div",{className:"nc-set-info",children:v("pair-card-help")}),h.jsx("input",{className:"nc-pair-input",placeholder:v("pair-paste-ph"),value:d.pairingUrl,disabled:o||H,onChange:P=>{p({...d,pairingUrl:P.target.value}),k(null),M("")},onPaste:P=>{const z=P.clipboardData&&P.clipboardData.getData("text")||"";z.trim()&&(P.preventDefault(),W(z))},onKeyDown:P=>{P.key==="Enter"&&(P.preventDefault(),X())}}),h.jsxs("div",{className:"nc-pair-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||H,onClick:G,children:v("pair-paste-btn")}),h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||H,onClick:()=>y(!0),children:v("scan-qr")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:o||H,title:o?v("settings-readonly"):"",onClick:X,children:v("test-and-connect")})]}),h.jsxs("div",{className:"nc-pair-status","aria-live":"polite",children:[H&&h.jsx("div",{className:"nc-pair-progress",children:v("pair-progress")}),_==="ok"&&h.jsx("div",{className:"nc-set-test ok",children:v("node-connected")}),N&&h.jsx("div",{className:"nc-set-hint nc-pair-notice",children:N}),C&&h.jsxs("div",{className:"nc-err",role:"alert",children:[h.jsx("b",{children:E})," — ",C.message,C.hint&&h.jsx("div",{className:"nc-pair-hint",children:C.hint}),C.retryable&&h.jsx("div",{children:h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||H,onClick:X,children:v("pair-retry")})})]})]}),h.jsxs("button",{type:"button",className:"nc-btn ghost nc-pair-advanced-toggle",disabled:H,onClick:()=>S(P=>!P),children:[m?"▾":"▸"," ",v("pair-advanced")]}),m&&h.jsxs("div",{className:"nc-pair-advanced",children:[h.jsxs("label",{className:"nc-field",children:[v("node-display-label"),h.jsx("input",{placeholder:"Home Relay",value:d.label,disabled:o||H,onChange:P=>{O.current.add("label"),p(z=>({...z,label:P.target.value,name:A?z.name:Xr(P.target.value)}))}})]}),h.jsxs("label",{className:"nc-field",children:[v("node-name-label"),h.jsx("input",{placeholder:v("node-name-ph"),value:d.name,disabled:o||H,onChange:P=>{B(!0),O.current.add("name"),p(z=>({...z,name:P.target.value?Xr(P.target.value):""}))}})]}),h.jsx("small",{className:"nc-set-hint",children:v("node-slug-hint").replace("{slug}",d.name||"home-relay")}),h.jsxs("label",{className:"nc-field",children:[v("pair-ssh-local-label"),h.jsx("input",{placeholder:"my-relay",value:d.ssh,disabled:o||H,onChange:P=>{O.current.add("ssh"),j("ssh",P.target.value)}}),h.jsx("small",{className:"nc-set-hint",children:v("node-ssh-local-help")})]}),h.jsxs("label",{className:"nc-field",children:[v("node-ssh-port-label"),h.jsx("input",{inputMode:"numeric",placeholder:v("node-ssh-port-help"),value:d.sshPort,disabled:o||H,onChange:P=>j("sshPort",P.target.value.replace(/[^0-9]/g,"").slice(0,5))})]}),h.jsxs("label",{className:"nc-field",children:[v("device-name-label"),h.jsx("input",{placeholder:s||"NexusCrew",value:d.localLabel,disabled:o||H,onChange:P=>j("localLabel",P.target.value)}),h.jsx("small",{className:"nc-set-hint",children:v("device-name-hint")})]})]}),w&&h.jsx(Wk,{onResult:P=>{y(!1),W(P)},onClose:()=>y(!1)})]})}function rd(){return typeof navigator<"u"&&"serviceWorker"in navigator&&typeof window<"u"&&"PushManager"in window&&typeof Notification<"u"}function Uk(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 l=0;l<s.length;l+=1)o[l]=s.charCodeAt(l);return o}async function Kk(){if(!rd())return"unsupported";if(Notification.permission==="denied")return"denied";try{return await(await navigator.serviceWorker.ready).pushManager.getSubscription()?"subscribed":"idle"}catch{return"idle"}}async function qk(e){if(!rd())throw new Error("push-unsupported");if(await Notification.requestPermission()!=="granted")throw new Error("push-denied");const n=await zt("/api/push/vapid",e),{publicKey:s}=await n.json();if(!s)throw new Error("vapid non disponibile");const l=await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Uk(s)}),u=await zt("/api/push/subscribe",e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({subscription:l.toJSON()})});if(!u.ok){try{await l.unsubscribe()}catch{}const d=await u.json().catch(()=>({}));throw new Error(d.error||`HTTP ${u.status}`)}return!0}async function Vk(e){if(!rd())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 zt("/api/push/subscribe",e,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:s})})}catch{}return!0}const Y_="nexuscrew.fleet",X_=2,Yk="nexuscrew.cells",Xk=/^[A-Za-z0-9._-]{1,32}$/,sd=/^[a-z0-9._-]{1,32}$/,G_=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,Gk=new Set(["standard","unsafe"]),Qk=4096,iv=256,Jk=8192,Zk=32,ex=24,tx=new Set(["format","version","exportedAt","cells","engines"]),ix=new Set(["id","cwd","engine","boot","model","models","permissionPolicies","systemPrompt","prompt"]),nx=new Set(["id","label","rc","managed","command","args","envKeys","model","promptMode","promptFlag"]),rx=new Set(["client","provider","credentialProfile","model","permissionPolicy","displayName","protocol","baseUrl","envKey","providerId"]);function ar(e,t){return typeof e=="string"&&e.length<=t&&!/[\x00-\x1f\x7f]/.test(e)}function Q_(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 nv(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,l]of n){if(!sd.test(o)||!t(l))return null;s[o]=l}return s}function J_(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(l=>!ix.has(l))||!Xk.test(String(e.id||""))||typeof e.cwd!="string"||!e.cwd||e.cwd.length>Qk||!sd.test(String(e.engine||""))||e.boot!==void 0&&typeof e.boot!="boolean"||e.model!==void 0&&(typeof e.model!="string"||e.model.length>iv)||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>Jk)return null;const n=nv(e.models,l=>typeof l=="string"&&!!l&&l.length<=iv),s=nv(e.permissionPolicies,l=>Gk.has(l));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 sx(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(n=>!rx.has(n)))return null;const t={};for(const[n,s]of Object.entries(e)){if(typeof s!="string"||!ar(s,n==="baseUrl"?512:128)||Q_(s))return null;t[n]=s}return!t.client||!t.provider||t.envKey&&!G_.test(t.envKey)?null:t}function Z_(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(s=>!nx.has(s))||!sd.test(String(e.id||""))||!ar(e.label||e.id,64)||e.rc!==void 0&&typeof e.rc!="boolean")return null;const t={id:e.id,label:e.label||e.id,rc:e.rc===!0};if(e.managed!==void 0){const s=sx(e.managed);return!s||["command","args","envKeys","model","promptMode","promptFlag"].some(o=>e[o]!==void 0)?null:(t.managed=s,t)}if(!ar(e.command,512)||!e.command.startsWith("/")||!Array.isArray(e.args)||e.args.length>32||e.args.some(s=>!ar(s,1024)||Q_(s))||e.promptMode!=="flag"&&e.promptMode!=="send-keys"||e.promptMode==="flag"&&(!ar(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")||!ar(e.model.flag,32)||/\s/.test(e.model.flag)||!ar(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=>!G_.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 ey(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.managed?{id:e.id,label:e.label,rc:e.rc,managed:e.managed}:{id:e.id,label:e.label,rc:e.rc,command:e.command,args:e.args,envKeys:e.envKeys,model:e.model,promptMode:e.promptMode,promptFlag:e.promptFlag},n=Z_(t);return n||null}function ox(e,t,n=[],s=[],o=new Date){n instanceof Date&&(o=n,n=[],s=[]);const l=t instanceof Set?t:new Set(t||[]),u=s instanceof Set?s:new Set(s||[]),d=[];for(const m of Array.isArray(e)?e:[]){if(!l.has(m.id))continue;const S=J_({id:m.id,cwd:m.cwd,engine:m.engine,boot:m.boot===!0,...m.model?{model:m.model}:{},...m.models?{models:m.models}:{},...m.permissionPolicies?{permissionPolicies:m.permissionPolicies}:{},systemPrompt:m.prompt||""});S&&d.push(S)}const p=[];for(const m of Array.isArray(n)?n:[]){if(!u.has(m.id))continue;const S=ey(m);S&&p.push(S)}return{format:Y_,version:X_,exportedAt:o.toISOString(),cells:d,engines:p}}function ax(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)===Yk&&(t==null?void 0:t.version)===1;if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(d=>!tx.has(d))||!n&&(t.format!==Y_||t.version!==X_)||!Array.isArray(t.cells)||t.cells.length>Zk||!n&&(!Array.isArray(t.engines)||t.engines.length>ex))return{ok:!1,error:"invalid-format",cells:[],engines:[]};const s=[],o=new Set;for(const d of t.cells){const p=J_(d);if(!p)return{ok:!1,error:"invalid-cell",cells:[],engines:[]};if(o.has(p.id))return{ok:!1,error:"duplicate-cell",cells:[],engines:[]};o.add(p.id),s.push(p)}const l=[],u=new Set;for(const d of n?[]:t.engines){const p=Z_(d);if(!p)return{ok:!1,error:"invalid-engine",cells:[],engines:[]};if(u.has(p.id))return{ok:!1,error:"duplicate-engine",cells:[],engines:[]};u.add(p.id),l.push(p)}return{ok:!0,cells:s,engines:l,legacy:n,exportedAt:typeof t.exportedAt=="string"?t.exportedAt:""}}function lx(e,t,n){const s=new Set(n||[]);if(!s.has(t))return null;const o=p=>Object.fromEntries(Object.entries(p||{}).filter(([m])=>s.has(m))),l={id:e.id,cwd:e.cwd,engine:t,boot:e.boot===!0,prompt:e.systemPrompt||""};t===e.engine&&e.model?l.model=e.model:e.models&&e.models[t]&&(l.model=e.models[t]);const u=o(e.models),d=o(e.permissionPolicies);return Object.keys(u).length&&(l.models=u),Object.keys(d).length&&(l.permissionPolicies=d),l}const cx=()=>({kind:"managed",id:"claude.native",label:"",client:"claude",provider:"native",credentialProfile:"",managedModel:"",permissionPolicy:"unsafe",displayName:"",protocol:"anthropic_messages",baseUrl:"",envKey:"",providerId:"nexuscrew-custom",command:"",argsText:"",rc:!0,promptMode:"send-keys",promptFlag:"",modelFlag:"",modelValue:"",envRows:[]}),rv=(e="")=>({id:"",cwd:"",engine:e,boot:!1,model:"",prompt:""}),ty=e=>e==="claude"?"unsafe":"standard",Qa=(e,t)=>e.find(n=>n.client===t.client&&n.provider===t.provider&&(n.credentialProfile||"")===(t.credentialProfile||"")),ux=(e,t)=>{var n;return((n=Qa(e,t))==null?void 0:n.label)||`${t.client} · ${t.provider}`};function hx(e){var t,n,s,o,l,u,d,p,m,S,w,y,_,b;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:((l=e.managed)==null?void 0:l.permissionPolicy)||ty((u=e.managed)==null?void 0:u.client),displayName:((d=e.managed)==null?void 0:d.displayName)||"",protocol:((p=e.managed)==null?void 0:p.protocol)||"",baseUrl:((m=e.managed)==null?void 0:m.baseUrl)||"",envKey:((S=e.managed)==null?void 0:S.envKey)||"",providerId:((w=e.managed)==null?void 0:w.providerId)||"nexuscrew-custom",modelOptions:e.availableModels||((y=e.managedInfo)==null?void 0:y.models)||[],promptMode:e.promptMode||"send-keys",promptFlag:e.promptFlag||"",modelFlag:((_=e.model)==null?void 0:_.flag)||"",modelValue:((b=e.model)==null?void 0:b.value)||"",envRows:(e.envKeys||[]).map(C=>({key:C,value:"",configured:!0,remove:!1}))}}function dx(e,t,n=[]){if(e.kind==="managed"){const o={client:e.client,provider:e.provider,model:e.managedModel||"",permissionPolicy:e.permissionPolicy||ty(e.client)};e.credentialProfile&&(o.credentialProfile=e.credentialProfile);const l=Qa(n,e);return l!=null&&l.credentialEnv&&(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||ux(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 Ur({children:e,onClose:t,label:n,error:s=""}){const o=L.useRef(null),l=L.useRef(null),u=L.useRef(t);return u.current=t,L.useEffect(()=>{const d=document.activeElement,p=o.current,m=()=>Array.from((p==null?void 0:p.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [href], [tabindex]:not([tabindex="-1"])'))||[]).filter(y=>y.offsetParent!==null),S=requestAnimationFrame(()=>{var y;return(y=m()[0]||p)==null?void 0:y.focus({preventScroll:!0})}),w=y=>{var k;if(y.key==="Escape"){y.preventDefault(),(k=u.current)==null||k.call(u);return}if(y.key!=="Tab")return;const _=m();if(!_.length){y.preventDefault(),p==null||p.focus();return}const b=_[0],C=_[_.length-1];y.shiftKey&&document.activeElement===b?(y.preventDefault(),C.focus()):!y.shiftKey&&document.activeElement===C&&(y.preventDefault(),b.focus())};return document.addEventListener("keydown",w),()=>{cancelAnimationFrame(S),document.removeEventListener("keydown",w),d&&d.isConnected&&typeof d.focus=="function"&&d.focus({preventScroll:!0})}},[]),L.useEffect(()=>{s&&requestAnimationFrame(()=>{var d;return(d=l.current)==null?void 0:d.scrollIntoView({block:"nearest"})})},[s]),h.jsx("div",{className:"nc-fleet-modal",role:"presentation",onMouseDown:d=>{d.target===d.currentTarget&&t()},children:h.jsxs("div",{ref:o,className:"nc-fleet-modal-dialog",role:"dialog","aria-modal":"true","aria-label":n||v("settings"),tabIndex:-1,children:[e,s&&h.jsx("div",{ref:l,className:"nc-err nc-fleet-modal-error",role:"alert","aria-live":"assertive",children:s})]})})}function fx({token:e,readonly:t,targets:n=[],startNewCell:s=!1,initialLocation:o=""}){const[l,u]=L.useState({engines:[],cells:[],managedCatalog:[]}),[d,p]=L.useState({available:!1,capabilities:[]}),[m,S]=L.useState(null),[w,y]=L.useState(null),[_,b]=L.useState(!1),[C,k]=L.useState(""),[N,M]=L.useState(""),[A,B]=L.useState(o),[ee,O]=L.useState(!1),[H,J]=L.useState(null),[W,X]=L.useState(null),[G,j]=L.useState(!1),[E,P]=L.useState([]),[z,R]=L.useState(null),[F,I]=L.useState("manage"),re=L.useRef(!1),q=A?A.split("/"):[],D=L.useCallback(async()=>{try{const K=await fr(e,q);p(K);try{const fe=await Oh(e,q);O(!!fe.readonlyDefault)}catch{O(!1)}if(K.provider==="builtin"&&(K.capabilities||[]).includes("definitions")){const fe=await Bh(e,q),Ce=new Map((K.engines||[]).map(Ne=>[Ne.id,Ne]));if(fe.engines=(fe.engines||[]).map(Ne=>{var Be;return{...Ne,availableModels:((Be=Ce.get(Ne.id))==null?void 0:Be.models)||[]}}),u(fe),(K.capabilities||[]).includes("credentials"))try{P((await pw(e,q)).credentials||[])}catch{P([])}else P([])}}catch(K){k(String(K.message||K))}},[e,A]);L.useEffect(()=>{D();const K=setInterval(D,5e3);return()=>clearInterval(K)},[D]);const U=new Set((d.cells||[]).filter(K=>K.active).map(K=>K.cell)),Q=d.provider==="builtin"&&(d.capabilities||[]).includes("edit"),ae=(d.capabilities||[]).includes("restore");L.useEffect(()=>{!s||re.current||!Q||!l.engines.length||(re.current=!0,y({mode:"new",form:rv(l.engines[0].id)}))},[s,Q,l.engines]);const se=async K=>{b(!0),k(""),M("");try{await K(),await D()}catch(fe){k(String(fe.message||fe))}b(!1)},le=()=>se(async()=>{const K=m.mode==="new",fe=dx(m.form,K,l.managedCatalog||[]);!K&&m.form.kind==="custom"&&!m.form.modelFlag&&(fe.model=null),!K&&m.form.kind==="custom"&&m.form.promptMode!=="flag"&&(fe.promptFlag=null);let Ce;if(K)Ce=await vw(e,fe,q);else{const Be=m.original,mt=new Set(m.form.envRows.filter(We=>!We.remove).map(We=>We.key)),rt=(Be.envKeys||[]).filter(We=>!mt.has(We)),Ae=Object.fromEntries(m.form.envRows.filter(We=>!We.remove&&We.key&&(!We.configured||We.value!=="")).map(We=>[We.key,We.value]));Ce=await _w(e,Be.id,fe,m.form.kind==="custom"?{set:Ae,remove:rt}:void 0,q)}S(null),M(v("fleet-saved"));const Ne=(Ce==null?void 0:Ce.activeCells)||[];if(Ne.length&&window.confirm(v("fleet-restart-confirm").replace("{cells}",Ne.join(", "))))for(const Be of Ne)await Vs(e,Be,q)}),pe=()=>se(async()=>{const K=w.mode==="new",fe=w.form,Ce={...K?{id:fe.id}:{},cwd:fe.cwd,engine:fe.engine,boot:!!fe.boot};K?(fe.model&&(Ce.model=fe.model),fe.prompt&&(Ce.prompt=fe.prompt)):(Ce.model=fe.model||null,Ce.prompt=fe.prompt||null);const Ne=K?await Sw(e,Ce,q):await ww(e,w.original.id,Ce,q),Be=K?fe.id:w.original.id;y(null),M(v("fleet-saved")),!K&&(Ne!=null&&Ne.active)&&window.confirm(v("fleet-restart-confirm").replace("{cells}",Be))&&await Vs(e,Be,q)}),ce=t||ee,ke=K=>E.find(fe=>{var Ce;return(Ce=fe.engines)==null?void 0:Ce.includes(K.id)})||null,Oe=()=>se(async()=>{var Ce;const K=await mw(e,z.envKey,z.value,q);P(K.credentials||[]),R(null),M(v("fleet-credential-saved"));const fe=((Ce=(K.credentials||[]).find(Ne=>Ne.envKey===z.envKey))==null?void 0:Ce.activeCells)||[];if(fe.length&&window.confirm(v("fleet-restart-confirm").replace("{cells}",fe.join(", "))))for(const Ne of fe)await Vs(e,Ne,q)}),te=K=>se(async()=>{if(!window.confirm(v("fleet-credential-remove-confirm").replace("{key}",K.envKey)))return;const fe=await gw(e,K.envKey,q);P(fe.credentials||[]),M(v("fleet-credential-removed"))}),ie=K=>J({...K,route:Array.isArray(K==null?void 0:K.route)?K.route:q}),ye=async K=>{if(!H)return;const fe=H.cell||H.id,Ce=Array.isArray(H.route)?H.route:q;K.action==="up"?await Ah(e,{cell:fe,boot:!!K.boot,...K.engine?{engine:K.engine}:{},...K.model!==void 0?{model:K.model}:{},...K.permissionPolicy?{permissionPolicy:K.permissionPolicy}:{}},Ce):await Oa(e,{cell:fe,boot:!!K.boot},Ce)},Me=(K,fe)=>{k(""),X({mode:"new",route:Array.isArray(fe)?fe:q,form:{tmuxSession:K.name,id:"",engine:"",cwd:"",boot:!1},err:""})},je=()=>se(async()=>{const K=W.form;if(!K.engine){X({...W,err:v("import-engine-required")});return}await bw(e,{tmuxSession:K.tmuxSession,id:K.id||void 0,engine:K.engine,cwd:K.cwd||void 0,boot:!!K.boot},K.route||q),X(null),M(v("fleet-saved"))}),Y=({engineRows:K=[],cellRows:fe=[]})=>se(async()=>{const Ce=K.filter(Ge=>Ge.selected),Ne=Ce.map(Ge=>ey(Ge.engine));if(Ne.some(Ge=>!Ge))throw new Error(v("fleet-backup-invalid-engine"));const Be=Ce.filter(Ge=>Ge.exists).map(Ge=>Ge.engine.id);if(Be.length&&!window.confirm(v("fleet-backup-confirm-engine-overwrite").replace("{engines}",Be.join(", "))))return;const mt=[...new Set([...l.engines.map(Ge=>Ge.id),...Ne.map(Ge=>Ge.id)])],rt=[];for(const Ge of fe.filter(ge=>ge.selected)){const ge=lx(Ge.cell,Ge.engine,mt);if(!ge)throw new Error(`${Ge.cell.id}: ${v("fleet-backup-engine-missing")}`);rt.push(ge)}const Ae=fe.filter(Ge=>Ge.selected&&Ge.exists).map(Ge=>Ge.cell.id);if(Ae.length&&!window.confirm(v("fleet-backup-confirm-overwrite").replace("{cells}",Ae.join(", "))))return;const We=Ne.length?await kw(e,Ne,Be.length>0,q):{needsRestart:[]},Ie=rt.length?await Cw(e,rt,q):{needsRestart:[]},bt=[...new Set([...We.needsRestart||[],...Ie.needsRestart||[]])];j(!1),M(`${v("fleet-backup-restored").replace("{n}",String(rt.length))}${Ne.length?` · ${Ne.length} ${v("fleet-engines").toLowerCase()}`:""}${bt.length?` · ${v("fleet-backup-needs-restart").replace("{cells}",bt.join(", "))}`:""}`)}),de=h.jsxs("label",{className:"nc-field",children:[v("location"),h.jsxs("select",{value:A,onChange:K=>{B(K.target.value),S(null),y(null),k(""),M(""),O(!1),p({available:!1,capabilities:[]}),u({engines:[],cells:[],managedCatalog:[]}),P([]),R(null)},children:[h.jsx("option",{value:"",children:v("local")}),n.map(K=>h.jsxs("option",{value:K.route.join("/"),disabled:K.status&&K.status!=="up",children:[K.label,K.status&&K.status!=="up"?` · ${v("node-offline")}`:""]},K.route.join("/")))]})]}),we=h.jsxs("div",{className:"nc-fleet-view-tabs",role:"tablist","aria-label":v("tab-fleet"),children:[h.jsx("button",{type:"button",role:"tab","aria-selected":F==="manage",className:`nc-set-tabbtn${F==="manage"?" on":""}`,onClick:()=>I("manage"),children:v("fleet-manage-location")}),h.jsx("button",{type:"button",role:"tab","aria-selected":F==="overview",className:`nc-set-tabbtn${F==="overview"?" on":""}`,onClick:()=>I("overview"),children:v("fleet-network-overview")})]});return Q?h.jsxs("div",{className:"nc-set-tab nc-fleet-editor",children:[we,F==="overview"?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"nc-set-info",children:v("fleet-overview-help")}),h.jsx(sv,{token:e,targets:n,readonly:t,onPower:ie,onImport:Me})]}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"nc-set-info",children:v("fleet-manage-help")}),de,h.jsxs("div",{className:"nc-set-row nc-fleet-backup-actions",children:[h.jsx("button",{className:"nc-btn ghost",disabled:ce||_,onClick:()=>{k(""),j(!0)},children:v("fleet-backup")}),h.jsx("small",{children:v("fleet-backup-help")})]}),h.jsxs("div",{className:"nc-fleet-section-head",children:[h.jsx("b",{children:v("fleet-cells")}),h.jsx("span",{className:"nc-fleet-head-actions",children:h.jsxs("button",{className:"nc-btn primary",disabled:ce||_||!l.engines.length,onClick:()=>{var K;k(""),y({mode:"new",form:rv((K=l.engines[0])==null?void 0:K.id)})},children:["+ ",v("add")]})})]}),l.cells.map(K=>{const fe=U.has(K.id),Ce=d.capabilities||[];return h.jsxs("div",{className:"nc-fleet-item",children:[h.jsxs("span",{children:[h.jsx("b",{children:K.id}),h.jsxs("small",{children:[K.engine," · ",K.cwd,fe?` · ${v("service-active")}`:` · ${v("cell-off")}`]})]}),h.jsxs("span",{children:[fe&&Ce.includes("down")&&h.jsx("button",{className:"nc-btn ghost",disabled:ce||_,onClick:()=>se(()=>Oa(e,{cell:K.id},q)),children:v("stop")}),!fe&&Ce.includes("up")&&h.jsx("button",{className:"nc-btn primary",disabled:ce||_,onClick:()=>ie({cell:K.id,id:K.id,engine:K.engine,model:K.model,models:K.models,permissionPolicies:K.permissionPolicies,active:!1,boot:K.boot}),children:v("start")}),fe&&Ce.includes("restart")&&h.jsx("button",{className:"nc-btn ghost",disabled:ce||_,onClick:()=>se(()=>Vs(e,K.id,q)),children:v("restart")}),h.jsx("button",{className:"nc-btn ghost",disabled:ce||_,onClick:()=>{k(""),y({mode:"edit",original:K,form:{...K}})},children:v("edit")}),h.jsx("button",{className:"nc-btn danger",disabled:ce||_,onClick:()=>se(async()=>{window.confirm(v("fleet-remove-cell").replace("{id}",K.id))&&await mv(e,K.id,!0,q)}),children:"×"})]})]},K.id)}),h.jsxs("div",{className:"nc-fleet-section-head",children:[h.jsx("b",{children:v("fleet-engines")}),h.jsxs("button",{className:"nc-btn primary",disabled:ce||_,onClick:()=>{k(""),S({mode:"new",form:cx()})},children:["+ ",v("add")]})]}),l.engines.map(K=>{var Ce,Ne;const fe=ke(K);return h.jsxs("div",{className:"nc-fleet-item",children:[h.jsxs("span",{children:[h.jsx("b",{children:K.label}),h.jsx("small",{children:K.managed?`${K.id} · ${K.managed.client} / ${K.managed.provider} · ${(Ce=K.managedInfo)!=null&&Ce.configured?v("fleet-ready"):((Ne=K.managedInfo)==null?void 0:Ne.reason)||v("fleet-not-ready")}`:`${K.id} · ${K.command}`}),fe&&h.jsxs("small",{children:[fe.envKey," · ",v(`fleet-credential-source-${fe.source||"missing"}`)]})]}),h.jsxs("span",{children:[fe&&h.jsx("button",{className:"nc-btn ghost",disabled:ce||_,onClick:()=>{k(""),R({envKey:fe.envKey,value:""})},children:fe.configured?v("fleet-credential-change"):v("fleet-credential-set")}),(fe==null?void 0:fe.source)==="local"&&h.jsx("button",{className:"nc-btn danger",disabled:ce||_,onClick:()=>te(fe),children:v("fleet-credential-forget")}),h.jsx("button",{className:"nc-btn ghost",disabled:ce||_,onClick:()=>{k(""),S({mode:"edit",original:K,form:hx(K)})},children:v("edit")}),h.jsx("button",{className:"nc-btn danger",disabled:ce||_,onClick:()=>se(async()=>{window.confirm(v("fleet-remove-engine").replace("{id}",K.id))&&await yw(e,K.id,q)}),children:"×"})]})]},K.id)})]}),m&&h.jsx(Ur,{onClose:()=>S(null),label:v("fleet-new-engine"),error:C,children:h.jsx(mx,{state:m,setState:S,busy:_,onSave:le,catalog:l.managedCatalog||[]})}),w&&h.jsx(Ur,{onClose:()=>y(null),label:v("fleet-new-cell"),error:C,children:h.jsx(gx,{token:e,route:q,targets:n,location:A,setLocation:B,state:w,setState:y,engines:l.engines,busy:_,onSave:pe})}),N&&h.jsx("div",{className:"nc-set-note",children:N}),C&&h.jsx("div",{className:"nc-err",children:C}),G&&h.jsx(Ur,{onClose:()=>j(!1),label:v("fleet-backup"),error:C,children:h.jsx(px,{cells:l.cells,engines:l.engines,busy:_,canRestore:ae,onRestore:Y,onClose:()=>j(!1)})}),z&&h.jsx(Ur,{onClose:()=>R(null),label:v("fleet-credential-title"),error:C,children:h.jsxs("div",{className:"nc-fleet-form nc-credential-form",children:[h.jsx("b",{children:v("fleet-credential-title")}),h.jsx("small",{children:v("fleet-credential-help")}),h.jsxs("label",{className:"nc-field",children:[z.envKey,h.jsx("input",{type:"password",autoComplete:"off",spellCheck:"false",autoCapitalize:"none",value:z.value,onChange:K=>R({...z,value:K.target.value})})]}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>R(null),children:v("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:_||!z.value,onClick:Oe,children:v("save")})]})]})}),W&&h.jsx(Ur,{onClose:()=>X(null),label:v("import-as-cell"),error:C,children:h.jsx(ov,{token:e,route:W.route||q,state:W,setState:X,busy:_,onSave:je})}),H&&h.jsx(Fa,{cell:H,token:e,route:Array.isArray(H.route)?H.route:q,onConfirm:async K=>{try{await ye(K)}finally{await D()}},onClose:()=>J(null)})]}):h.jsxs("div",{className:"nc-set-tab",children:[we,F==="overview"?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"nc-set-info",children:v("fleet-overview-help")}),h.jsx(sv,{token:e,targets:n,readonly:t,onPower:ie,onImport:Me})]}):h.jsxs(h.Fragment,{children:[de,h.jsx("div",{className:"nc-set-info",children:v("fleet-editor-unavailable")})]}),C&&h.jsx("div",{className:"nc-err",children:C}),W&&h.jsx(Ur,{onClose:()=>X(null),label:v("import-as-cell"),error:C,children:h.jsx(ov,{token:e,route:W.route||q,state:W,setState:X,busy:_,onSave:je})}),H&&h.jsx(Fa,{cell:H,token:e,route:Array.isArray(H.route)?H.route:q,onConfirm:async K=>{try{await ye(K)}finally{await D()}},onClose:()=>J(null)})]})}function sv({token:e,targets:t=[],readonly:n=!1,onPower:s,onImport:o}){const[l,u]=L.useState([]),[d,p]=L.useState(0);L.useEffect(()=>{let k=!0;async function N(){const A=[{route:[],label:v("local")}].concat((t||[]).map(ee=>({route:Array.isArray(ee.route)?ee.route:[],label:ee.label||(ee.route||[]).join(" › ")}))),B=await Promise.all(A.map(async ee=>{const O={...ee,available:!1,readonly:!1,capabilities:[],provider:null,cells:[],unmanaged:[],err:""};try{const H=await fr(e,ee.route);O.available=!!H.available,O.capabilities=H.capabilities||[],O.provider=H.provider||null,O.cells=(H.cells||[]).map(J=>({...J,route:ee.route}));try{O.readonly=!!(await Oh(e,ee.route)).readonlyDefault}catch{}try{const J=await Sv(e,ee.route),W=new Set(O.cells.map(X=>X.tmuxSession).filter(Boolean));O.unmanaged=(J.sessions||[]).filter(X=>X&&!W.has(X.name))}catch{}}catch(H){O.err=String(H&&H.message||H)}return O}));k&&u(B)}N();const M=setInterval(N,6e3);return()=>{k=!1,clearInterval(M)}},[e,t,d]);const m=(k,N)=>Array.isArray(k.capabilities)&&k.capabilities.includes(N)&&!n&&!k.readonly,S=()=>p(k=>k+1),w=(k,N)=>{s&&s({...k,route:N})},y=(k,N)=>{s&&s({...k,route:N})},_=async(k,N)=>{try{await Vs(e,k.cell,N)}catch{}S()},b=async(k,N)=>{if(window.confirm(v("fleet-remove-cell").replace("{id}",k.cell))){try{await mv(e,k.cell,!0,N)}catch{}S()}},C=async(k,N)=>{if(window.confirm(v("terminate-confirm").replace("{name}",k.name))){try{await Ih(e,k.name,N)}catch{}S()}};return h.jsxs("div",{className:"nc-fleet-inventory",children:[h.jsxs("div",{className:"nc-fleet-section-head",children:[h.jsx("b",{children:v("fleet-inventory")}),h.jsx("small",{children:v("fleet-inventory-help")})]}),l.map(k=>{const N=k.route.length?k.route.join("/"):"local";return h.jsxs("div",{className:"nc-fleet-pos",children:[h.jsxs("div",{className:"nc-fleet-pos-title",children:[h.jsx("span",{className:`dot ${k.available?"on":"warn"}`}),h.jsx("b",{children:k.label}),h.jsx("small",{children:k.available?`${k.cells.length} ${v("fleet-cells")} · ${k.unmanaged.length} ${v("fleet-tmux")}`:k.err||v("fleet-not-available")})]}),k.cells.map(M=>h.jsxs("div",{className:"nc-fleet-item nc-fleet-cell",children:[h.jsxs("span",{children:[h.jsx("b",{children:M.cell}),h.jsx("small",{children:`${M.engine||""}${M.key?`·${M.key}`:""}${M.active?"":` · ${v("cell-off")}`}`})]}),h.jsxs("span",{className:"nc-fleet-cell-actions",children:[M.active&&m(k,"down")&&h.jsx("button",{className:"nc-btn ghost",title:v("power-off"),onClick:()=>y(M,k.route),children:v("stop")}),!M.active&&m(k,"up")&&h.jsx("button",{className:"nc-btn ghost",title:v("power-on"),onClick:()=>w(M,k.route),children:v("start")}),m(k,"restart")&&M.active&&h.jsx("button",{className:"nc-btn ghost",title:v("restart"),onClick:()=>_(M,k.route),children:v("restart")}),m(k,"remove")&&h.jsx("button",{className:"nc-btn danger",title:v("delete"),onClick:()=>b(M,k.route),children:"×"})]})]},`${N}:${M.cell}`)),k.unmanaged.map(M=>h.jsxs("div",{className:"nc-fleet-item nc-fleet-unmanaged",children:[h.jsxs("span",{children:[h.jsx("b",{children:M.name}),h.jsx("small",{children:v("fleet-tmux")})]}),h.jsxs("span",{className:"nc-fleet-cell-actions",children:[m(k,"import")&&o&&h.jsx("button",{className:"nc-btn ghost",title:v("import-as-cell"),onClick:()=>o(M,k.route),children:v("import-as-cell")}),h.jsx("button",{className:"nc-btn danger",title:v("terminate"),onClick:()=>C(M,k.route),children:"×"})]})]},`${N}:u:${M.name}`)),k.available&&k.cells.length===0&&k.unmanaged.length===0&&h.jsx("div",{className:"nc-empty",children:v("fleet-inventory-empty")})]},N)})]})}function px({cells:e=[],engines:t=[],busy:n,canRestore:s=!1,onRestore:o,onClose:l}){const[u,d]=L.useState("export"),[p,m]=L.useState(()=>new Set(e.map(E=>E.id))),[S,w]=L.useState(()=>new Set(t.map(E=>E.id))),[y,_]=L.useState([]),[b,C]=L.useState([]),[k,N]=L.useState(""),M=new Set(t.map(E=>E.id)),A=new Set(e.map(E=>E.id)),B=(E,P)=>E(z=>{const R=new Set(z);return R.has(P)?R.delete(P):R.add(P),R}),ee=()=>{const E=ox(e,p,t,S),P=t.filter(I=>S.has(I.id)).length;if(E.engines.length!==P){N(v("fleet-backup-invalid-engine"));return}if(!E.cells.length&&!E.engines.length){N(v("fleet-backup-select-one"));return}const z=new Blob([`${JSON.stringify(E,null,2)}
|
|
91
|
+
`],{type:"application/json"}),R=URL.createObjectURL(z),F=document.createElement("a");F.href=R,F.download=`nexuscrew-fleet-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(F),F.click(),F.remove(),setTimeout(()=>URL.revokeObjectURL(R),0),N("")},O=async E=>{if(N(""),_([]),C([]),!!E){if(E.size>1024*1024){N(v("fleet-backup-too-large"));return}try{const P=ax(await E.text());if(!P.ok){N(v(`fleet-backup-${P.error}`));return}const z=new Set(P.engines.map(R=>R.id));C(P.engines.map(R=>({engine:R,exists:M.has(R.id),selected:!M.has(R.id)}))),_(P.cells.map(R=>{const F=M.has(R.engine)||z.has(R.engine),I=A.has(R.id);return{cell:R,engine:F?R.engine:"",selected:F&&!I,exists:I}}))}catch(P){N(String(P.message||P))}}},H=(E,P)=>_(z=>z.map((R,F)=>F===E?{...R,...P}:R)),J=(E,P)=>C(z=>z.map((R,F)=>F===E?{...R,...P}:R)),W=new Set([...M,...b.filter(E=>E.selected).map(E=>E.engine.id)]),X=y.filter(E=>E.selected&&E.engine&&W.has(E.engine)),G=b.filter(E=>E.selected),j=[...new Map([...t.map(E=>[E.id,E.label||E.id]),...b.filter(E=>E.selected).map(E=>[E.engine.id,E.engine.label||E.engine.id])]).entries()];return h.jsxs("div",{className:"nc-set-form nc-fleet-form nc-backup-dialog",children:[h.jsx("b",{children:v("fleet-backup")}),h.jsx("small",{children:v("fleet-backup-help")}),h.jsxs("div",{className:"nc-set-tabs nc-backup-tabs",children:[h.jsx("button",{type:"button",className:`nc-set-tabbtn${u==="export"?" on":""}`,onClick:()=>{d("export"),N("")},children:v("fleet-backup-export")}),h.jsx("button",{type:"button",className:`nc-set-tabbtn${u==="import"?" on":""}`,disabled:!s,title:s?"":v("fleet-backup-restore-unavailable"),onClick:()=>{d("import"),N("")},children:v("fleet-backup-import")})]}),u==="export"?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{m(new Set(e.map(E=>E.id))),w(new Set(t.map(E=>E.id)))},children:v("select-all")}),h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{m(new Set),w(new Set)},children:v("select-none")})]}),h.jsxs("div",{className:"nc-backup-list",children:[h.jsx("b",{children:v("fleet-engines")}),t.map(E=>{var P;return h.jsxs("label",{className:"nc-check nc-backup-row",children:[h.jsx("input",{type:"checkbox",checked:S.has(E.id),onChange:()=>B(w,E.id)}),h.jsxs("span",{children:[h.jsx("b",{children:E.label||E.id}),h.jsxs("small",{children:[E.id,(P=E.envKeys)!=null&&P.length?` · ${E.envKeys.length} ${v("fleet-backup-env-names")}`:""]})]})]},E.id)}),h.jsx("b",{children:v("fleet-cells")}),e.map(E=>h.jsxs("label",{className:"nc-check nc-backup-row",children:[h.jsx("input",{type:"checkbox",checked:p.has(E.id),onChange:()=>B(m,E.id)}),h.jsxs("span",{children:[h.jsx("b",{children:E.id}),h.jsxs("small",{children:[E.engine," · ",v("fleet-system-prompt")," ",(E.prompt||"").length," ",v("characters")]})]})]},E.id)),!e.length&&!t.length&&h.jsx("div",{className:"nc-empty",children:v("fleet-backup-empty")})]}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:l,children:v("cancel")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:!p.size&&!S.size,onClick:ee,children:v("fleet-backup-download")})]})]}):h.jsxs(h.Fragment,{children:[h.jsx("input",{type:"file",accept:"application/json,.json",disabled:n,onChange:E=>O(E.target.files&&E.target.files[0])}),h.jsx("small",{children:v("fleet-backup-import-help")}),!!(y.length||b.length)&&h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{C(E=>E.map(P=>({...P,selected:!0}))),_(E=>E.map(P=>({...P,selected:!!P.engine})))},children:v("select-all")}),h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{C(E=>E.map(P=>({...P,selected:!1}))),_(E=>E.map(P=>({...P,selected:!1})))},children:v("select-none")})]}),h.jsxs("div",{className:"nc-backup-list",children:[!!b.length&&h.jsx("b",{children:v("fleet-engines")}),b.map((E,P)=>{var z;return h.jsx("div",{className:"nc-backup-import-row",children:h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:E.selected,onChange:R=>J(P,{selected:R.target.checked})}),h.jsxs("span",{children:[h.jsx("b",{children:E.engine.label||E.engine.id}),h.jsxs("small",{children:[E.engine.id," · ",E.exists?v("fleet-backup-overwrite"):v("fleet-backup-new"),(z=E.engine.envKeys)!=null&&z.length?` · ${v("fleet-backup-env-values-required")}`:""]})]})]})},E.engine.id)}),!!y.length&&h.jsx("b",{children:v("fleet-cells")}),y.map((E,P)=>h.jsxs("div",{className:"nc-backup-import-row",children:[h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:E.selected,disabled:!E.engine||!W.has(E.engine),onChange:z=>H(P,{selected:z.target.checked})}),h.jsxs("span",{children:[h.jsx("b",{children:E.cell.id}),h.jsxs("small",{children:[E.exists?v("fleet-backup-overwrite"):v("fleet-backup-new")," · ",v("fleet-system-prompt")," ",E.cell.systemPrompt.length," ",v("characters")]})]})]}),h.jsxs("select",{value:E.engine,onChange:z=>H(P,{engine:z.target.value,selected:!!z.target.value}),children:[h.jsx("option",{value:"",children:v("fleet-backup-engine-missing")}),j.map(([z,R])=>h.jsx("option",{value:z,children:R},z))]})]},E.cell.id))]}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:l,children:v("cancel")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||!X.length&&!G.length,onClick:()=>o({engineRows:b,cellRows:y}),children:v("fleet-backup-restore")})]})]}),k&&h.jsx("div",{className:"nc-err",children:k})]})}function mx({state:e,setState:t,busy:n,onSave:s,catalog:o}){var y;const l=e.form,u=_=>t({...e,form:{...l,..._}}),d=l.envRows||[],p=[...new Map(o.map(_=>[_.client,_.clientLabel||_.client])).entries()],m=o.filter(_=>_.client===l.client),S=Qa(o,l),w=_=>{_&&u({client:_.client,provider:_.provider,credentialProfile:_.credentialProfile||"",managedModel:_.model||"",protocol:_.protocol||"",permissionPolicy:_.permissionPolicyDefault||"standard",rc:!!_.rc,displayName:_.custom?v("fleet-custom-provider-default"):"",baseUrl:_.custom?"":_.endpoint||"",envKey:_.defaultEnvKey||"",providerId:"nexuscrew-custom",...e.mode==="new"?{id:_.id,label:""}:{}})};return h.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[h.jsx("b",{children:e.mode==="new"?v("fleet-new-engine"):`${v("edit")} ${l.id}`}),h.jsx("input",{value:l.id,disabled:e.mode!=="new",placeholder:"id",onChange:_=>u({id:_.target.value})}),h.jsx("input",{value:l.label,placeholder:v("label"),onChange:_=>u({label:_.target.value})}),h.jsxs("select",{value:l.kind,disabled:e.mode!=="new",onChange:_=>u({kind:_.target.value}),children:[h.jsx("option",{value:"managed",children:v("fleet-managed")}),h.jsx("option",{value:"custom",children:v("fleet-custom")})]}),l.kind==="managed"?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("select",{value:l.client,disabled:e.mode!=="new",onChange:_=>w(o.find(b=>b.client===_.target.value&&b.default)||o.find(b=>b.client===_.target.value)),children:p.map(([_,b])=>h.jsx("option",{value:_,children:b},_))}),h.jsx("select",{value:((y=Qa(o,l))==null?void 0:y.id)||"",disabled:e.mode!=="new",onChange:_=>w(o.find(b=>b.id===_.target.value)),children:m.map(_=>h.jsx("option",{value:_.id,children:_.label},_.id))})]}),h.jsx("input",{value:l.managedModel,list:"nc-managed-models",placeholder:v(S!=null&&S.requiresModel?"fleet-model-required":"fleet-model-default"),onChange:_=>u({managedModel:_.target.value})}),h.jsx("datalist",{id:"nc-managed-models",children:[...(S==null?void 0:S.models)||[],...l.modelOptions||[]].filter((_,b,C)=>_&&C.indexOf(_)===b).map(_=>h.jsx("option",{value:_},_))}),S!=null&&S.supportsUnsafe?h.jsxs("select",{value:l.permissionPolicy,onChange:_=>u({permissionPolicy:_.target.value}),children:[h.jsx("option",{value:"standard",children:v("fleet-standard-permissions")}),h.jsx("option",{value:"unsafe",children:v("fleet-unsafe-permissions")})]}):h.jsx("small",{children:v("fleet-standard-permissions")}),(S==null?void 0:S.supportsUnsafe)&&l.permissionPolicy==="unsafe"&&h.jsx("small",{className:"nc-err",children:v("fleet-unsafe-warning")}),(S==null?void 0:S.credentialEnv)&&h.jsxs(h.Fragment,{children:[h.jsx("input",{value:l.envKey,placeholder:v("fleet-api-key-env"),onChange:_=>u({envKey:_.target.value})}),h.jsx("small",{children:v("fleet-custom-secret-help")})]}),l.provider==="custom"&&h.jsxs(h.Fragment,{children:[h.jsx("input",{value:l.displayName,placeholder:v("fleet-provider-display"),onChange:_=>u({displayName:_.target.value})}),h.jsx("input",{value:l.baseUrl,placeholder:"https://api.example.com/v1",onChange:_=>u({baseUrl:_.target.value})}),((S==null?void 0:S.protocols)||[]).length>1&&h.jsx("select",{value:l.protocol,onChange:_=>u({protocol:_.target.value}),children:S.protocols.map(_=>h.jsx("option",{value:_,children:_},_))}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:l.envKey,placeholder:v("fleet-api-key-env"),onChange:_=>u({envKey:_.target.value})}),h.jsx("input",{value:l.providerId,placeholder:v("fleet-provider-id"),onChange:_=>u({providerId:_.target.value})})]}),h.jsxs("small",{children:[l.protocol," · ",v("fleet-custom-secret-help")]})]}),h.jsx("small",{children:v("fleet-managed-help")})]}):h.jsxs(h.Fragment,{children:[h.jsx("input",{value:l.command,placeholder:v("command-path"),onChange:_=>u({command:_.target.value})}),h.jsx("textarea",{value:l.argsText,placeholder:v("args-lines"),onChange:_=>u({argsText:_.target.value})}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:l.rc,onChange:_=>u({rc:_.target.checked})})," remote control"]}),h.jsxs("select",{value:l.promptMode,onChange:_=>u({promptMode:_.target.value}),children:[h.jsx("option",{value:"send-keys",children:"send-keys"}),h.jsx("option",{value:"flag",children:"flag"})]}),l.promptMode==="flag"&&h.jsx("input",{value:l.promptFlag,placeholder:"prompt flag",onChange:_=>u({promptFlag:_.target.value})}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:l.modelFlag,placeholder:"model flag",onChange:_=>u({modelFlag:_.target.value})}),h.jsx("input",{value:l.modelValue,placeholder:"model default",onChange:_=>u({modelValue:_.target.value})})]}),h.jsx("small",{children:v("env-write-only")}),d.map((_,b)=>h.jsxs("div",{className:"nc-fleet-env",children:[h.jsx("input",{value:_.key,disabled:_.configured,placeholder:"ENV_KEY",onChange:C=>{const k=d.slice();k[b]={..._,key:C.target.value},u({envRows:k})}}),h.jsx("input",{type:"password",value:_.value,placeholder:_.configured?"•••••• (unchanged)":"value",onChange:C=>{const k=d.slice();k[b]={..._,value:C.target.value},u({envRows:k})}}),h.jsx("button",{className:"nc-btn danger",onClick:()=>u({envRows:d.filter((C,k)=>k!==b)}),children:"×"})]},`${_.key}-${b}`)),h.jsx("button",{className:"nc-btn ghost",onClick:()=>u({envRows:[...d,{key:"",value:"",configured:!1}]}),children:"+ env"})]}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>t(null),children:v("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:n||!l.id||l.kind==="custom"&&!l.command||l.kind==="managed"&&(S==null?void 0:S.requiresModel)&&!l.managedModel||l.kind==="managed"&&(S==null?void 0:S.credentialEnv)&&!l.envKey||l.kind==="managed"&&l.provider==="custom"&&(!l.displayName||!l.baseUrl||!l.envKey||!l.providerId),onClick:s,children:v("save")})]})]})}function gx({token:e,route:t,targets:n=[],location:s,setLocation:o,state:l,setState:u,engines:d,busy:p,onSave:m}){const[S,w]=L.useState(null),[y,_]=L.useState(""),b=l.form,C=A=>u({...l,form:{...b,...A}}),k=d.find(A=>A.id===b.engine),N=A=>{var ee,O,H;const B=d.find(J=>J.id===A);C({engine:A,model:((ee=b.models)==null?void 0:ee[A])||((O=B==null?void 0:B.managed)==null?void 0:O.model)||((H=B==null?void 0:B.model)==null?void 0:H.value)||""})},M=async A=>{try{const B=await vv(e,A,t);w(B),C({cwd:B.path}),_("")}catch(B){_(String(B.message||B))}};return h.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[h.jsx("b",{children:l.mode==="new"?v("fleet-new-cell"):`${v("edit")} ${b.id}`}),l.mode==="new"&&h.jsxs("label",{className:"nc-field",children:[v("location"),h.jsx("span",{className:"nc-req",children:" *"}),h.jsxs("select",{value:s,onChange:A=>{o(A.target.value),C({engine:""})},children:[h.jsx("option",{value:"",children:v("local")}),n.map(A=>h.jsxs("option",{value:A.route.join("/"),disabled:A.status&&A.status!=="up",children:[A.label,A.status&&A.status!=="up"?` · ${v("node-offline")}`:""]},A.route.join("/")))]})]}),h.jsx("input",{value:b.id,disabled:l.mode!=="new",placeholder:"id",onChange:A=>C({id:A.target.value})}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:b.cwd,placeholder:v("cwd"),onChange:A=>C({cwd:A.target.value})}),h.jsx("button",{className:"nc-btn ghost",onClick:()=>S?w(null):M(b.cwd),children:v("browse")})]}),S&&h.jsxs("div",{className:"nc-fs",children:[h.jsx("div",{className:"nc-fs-path",children:S.path}),h.jsxs("div",{className:"nc-fs-list",children:[S.parent&&h.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>M(S.parent),children:["↑ ",v("fs-parent")]}),(S.dirs||[]).map(A=>h.jsxs("button",{className:"nc-fs-item",onClick:()=>M(`${S.path.replace(/\/$/,"")}/${A}`),children:["📁 ",A]},A))]})]}),y&&h.jsx("div",{className:"nc-err",children:y}),h.jsx("select",{value:b.engine,onChange:A=>N(A.target.value),children:d.map(A=>h.jsx("option",{value:A.id,children:A.label},A.id))}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:!!b.boot,onChange:A=>C({boot:A.target.checked})})," boot"]}),h.jsx("input",{value:b.model||"",list:"nc-cell-models",placeholder:v("fleet-model-override"),onChange:A=>C({model:A.target.value})}),h.jsx("datalist",{id:"nc-cell-models",children:((k==null?void 0:k.availableModels)||[]).map(A=>h.jsx("option",{value:A},A))}),h.jsx("textarea",{value:b.prompt||"",placeholder:"prompt",onChange:A=>C({prompt:A.target.value})}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>u(null),children:v("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:p||!b.id||!b.cwd||!b.engine,onClick:m,children:v("save")})]})]})}function ov({token:e,route:t=[],state:n,setState:s,busy:o,onSave:l}){const[u,d]=L.useState(null),[p,m]=L.useState([]),[S,w]=L.useState(""),y=Array.isArray(t)?t.join("/"):"";L.useEffect(()=>{let N=!0;return Bh(e,y?y.split("/"):[]).then(M=>{N&&(m(M.engines||[]),w(""))}).catch(M=>{N&&(m([]),w(String(M.message||M)))}),()=>{N=!1}},[e,y]);const _=n.form,b=N=>s({...n,form:{..._,...N}}),C=async N=>{try{const M=await vv(e,N,t);d(M),b({cwd:M.path})}catch{}},k=!_.id&&_.tmuxSession?_.tmuxSession.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32):_.id;return h.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[h.jsxs("b",{children:[v("import-as-cell")," · ",_.tmuxSession]}),h.jsx("small",{children:v("import-help")}),h.jsx("input",{value:_.tmuxSession,disabled:!0,placeholder:"tmux session",readOnly:!0}),h.jsx("input",{value:_.id,placeholder:v("name"),onChange:N=>b({id:N.target.value})}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:_.cwd,placeholder:v("cwd"),onChange:N=>b({cwd:N.target.value})}),h.jsx("button",{className:"nc-btn ghost",type:"button",onClick:()=>u?d(null):C(_.cwd),children:v("browse")})]}),u&&h.jsxs("div",{className:"nc-fs",children:[h.jsx("div",{className:"nc-fs-path",children:u.path}),h.jsxs("div",{className:"nc-fs-list",children:[u.parent&&h.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>C(u.parent),children:["↑ ",v("fs-parent")]}),(u.dirs||[]).map(N=>h.jsxs("button",{className:"nc-fs-item",onClick:()=>C(`${u.path.replace(/\/$/,"")}/${N}`),children:["📁 ",N]},N))]})]}),h.jsxs("select",{value:_.engine,onChange:N=>b({engine:N.target.value}),children:[h.jsx("option",{value:"",children:v("import-engine-required")}),p.map(N=>h.jsx("option",{value:N.id,children:N.label},N.id))]}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:!!_.boot,onChange:N=>b({boot:N.target.checked})})," boot"]}),(n.err||S)&&h.jsx("div",{className:"nc-err",children:n.err||S}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>s(null),children:v("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:o||!_.tmuxSession||!_.engine||!p.length,onClick:l,children:v(k?"import-as-cell":"save")})]})]})}function vx({text:e}){const[t,n]=L.useState(!1),s=async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{}};return h.jsxs("div",{className:"nc-set-copyline",children:[h.jsx("code",{children:e}),h.jsxs("button",{type:"button",className:"nc-btn ghost",onClick:s,children:[h.jsx(tt,{name:"copy",size:14})," ",v(t?"copied":"copy")]})]})}function _x({value:e}){const[t,n]=L.useState("");return L.useEffect(()=>{let s=!0;return bk.toDataURL(e,{margin:1,width:220}).then(o=>{s&&n(o)}).catch(()=>{}),()=>{s=!1}},[e]),t?h.jsx("img",{src:t,width:"220",height:"220",alt:"NexusCrew pairing QR"}):null}function yx({token:e,nodes:t,settings:n,readonly:s,refresh:o}){const[l,u]=L.useState(null),[d,p]=L.useState(null),[m,S]=L.useState({}),[w,y]=L.useState(null),[_,b]=L.useState({ssh:"",sshPort:"",name:""}),[C,k]=L.useState(""),[N,M]=L.useState(""),[A,B]=L.useState(""),[ee,O]=L.useState(!1),H=Date.now(),J=n&&n.deviceName||"",W=(t||[]).filter(R=>R&&R.direction==="outbound"&&R.name&&R.ssh),X=W.find(R=>R.name===C)||W[0]||null,G=W.find(R=>R.name===N)||W[0]||null,j=G?Qg(G.tunnel,H):null,E=async(R,F)=>{u(null),p(`${R}:${F}`);try{const I=await zh(e,R,F);F==="test"&&S(re=>({...re,[R]:I})),await o()}catch(I){u(`${R}: ${String(I.message||I)}`)}p(null)},P=async R=>{if(window.confirm(v("node-remove-confirm").replace("{name}",R))){u(null),p(`${R}:remove`);try{await Pw(e,R),await o()}catch(F){u(`${R}: ${String(F.message||F)}`)}p(null)}},z=async()=>{if(u(null),X){const I=Gg({name:X.name,ssh:X.ssh,sshPort:X.sshPort||""});if(!I.ok){u(v(I.error));return}p("invite");try{y(await tm(e,{ssh:I.value.ssh,...I.value.sshPort?{sshPort:I.value.sshPort}:{}},[X.name]))}catch(re){u(String(re.message||re))}p(null);return}const R=Xr(_.name||A||J||"NexusCrew"),F=Gg({name:R,ssh:_.ssh,sshPort:_.sshPort});if(!F.ok){u(v(F.error));return}p("invite");try{y(await tm(e,{...A||J?{label:A||J}:{},name:R,ssh:F.value.ssh,...F.value.sshPort?{sshPort:F.value.sshPort}:{}}))}catch(I){u(String(I.message||I))}p(null)};return h.jsxs("div",{className:"nc-set-tab",children:[h.jsx(V_,{token:e,deviceDefault:J,readonly:s,onSuccess:o}),G&&h.jsxs("div",{className:"nc-set-form nc-local-share",children:[h.jsx("div",{className:"nc-sheet-label",children:v("share-local-heading")}),W.length>1&&h.jsxs("label",{className:"nc-field",children:[v("share-local-hub"),h.jsx("select",{value:G.name,disabled:s||!!d,onChange:R=>M(R.target.value),children:W.map(R=>h.jsx("option",{value:R.name,children:R.label||R.name},R.name))})]}),h.jsxs("label",{className:"nc-check nc-node-share",children:[h.jsx("input",{type:"checkbox",checked:G.shared===!0,disabled:s||!!d||!(j!=null&&j.up)&&!G.shared,onChange:async R=>{u(null),p(`${G.name}:share`);try{await Dw(e,G.name,R.target.checked),await o()}catch(F){u(`${G.name}: ${String(F.message||F)}`)}p(null)}}),h.jsxs("span",{children:[h.jsx("b",{children:v("share-local-through").replace("{device}",J||v("local")).replace("{hub}",G.label||G.name)}),h.jsx("small",{children:v(G.shared?"share-node-on-desc":"share-node-off-desc")})]})]}),h.jsx("div",{className:`nc-set-test${G.shared&&(j!=null&&j.up)?" ok":""}`,children:G.shared?v("share-local-active"):v("share-local-private")})]}),(t||[]).length===0&&h.jsx("div",{className:"nc-empty",children:v("no-nodes")}),(t||[]).map(R=>{var re,q,D,U,Q;const F=Qg(R.tunnel,H),I=m[R.name];return h.jsxs("div",{className:"nc-set-node",children:[h.jsxs("div",{className:"nc-set-node-head",children:[h.jsx("span",{className:`nc-dot ${F.up?"on":""}`}),h.jsx("b",{children:R.label||R.name}),h.jsxs("small",{children:[R.name,R.direction==="outbound"?` · SSH ${R.ssh||""}`:` · ${v("node-connected-client")}`,(re=R.tunnel)!=null&&re.transport?` · ${R.tunnel.transport} ${v("transport-used")}`:""]}),h.jsxs("span",{className:`nc-set-tunnel${F.up?" up":""}`,children:[v(F.label),F.since?` · ${F.since}`:""]})]}),R.direction==="inbound"&&h.jsx("div",{className:"nc-set-info",children:v(R.shared?"peer-shared":"peer-private")}),R.direction==="inbound"&&R.shared&&h.jsxs(h.Fragment,{children:[h.jsxs("select",{value:R.visibility||"network",disabled:s||!!d,onChange:async ae=>{p(`${R.name}:visibility`);try{await im(e,R.name,ae.target.value),await o()}catch(se){u(String(se.message||se))}p(null)},children:[h.jsx("option",{value:"network",children:v("visibility-network")}),h.jsx("option",{value:"relay-only",children:v("visibility-relay")}),h.jsx("option",{value:"selected",children:v("visibility-selected")})]}),R.visibility==="selected"&&h.jsx("div",{className:"nc-set-row",children:(t||[]).filter(ae=>ae.name!==R.name&&ae.nodeId).map(ae=>{const se=(R.selected||[]).includes(ae.nodeId);return h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:se,disabled:s||!!d,onChange:async le=>{const pe=le.target.checked?[...R.selected||[],ae.nodeId]:(R.selected||[]).filter(ce=>ce!==ae.nodeId);p(`${R.name}:visibility`);try{await im(e,R.name,"selected",pe),await o()}catch(ce){u(String(ce.message||ce))}p(null)}})," ",ae.label||ae.name]},ae.nodeId)})})]}),h.jsxs("div",{className:"nc-set-node-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!d,onClick:async()=>{const ae=window.prompt(v("node-display-label"),R.label||R.name);if(ae!=null){if(!Rh(ae)){u(v("err-label"));return}p(`${R.name}:label`);try{await Rw(e,R.name,ae),await o()}catch(se){u(String(se.message||se))}p(null)}},children:v("edit")}),((q=R.health)==null?void 0:q.managed)!==!1&&h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>E(R.name,"test"),children:v("node-test")}),((D=R.health)==null?void 0:D.managed)!==!1&&(F.up?h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>E(R.name,"down"),children:v("tunnel-stop")}):h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>E(R.name,"up"),children:v("tunnel-start")})),((U=R.health)==null?void 0:U.managed)!==!1&&h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>E(R.name,"restart"),children:v("tunnel-restart")}),h.jsx("button",{type:"button",className:"nc-btn danger",disabled:s||!!d,title:v(s?"settings-readonly":"terminate"),onClick:()=>P(R.name),children:h.jsx(tt,{name:"trash",size:14})})]}),((Q=R.health)==null?void 0:Q.detail)&&h.jsx("div",{className:`nc-set-test${R.health.status==="healthy"?" ok":R.health.status==="passive"?"":" ko"}`,children:R.health.detail}),I&&h.jsxs("div",{className:`nc-set-test${I.ok?" ok":" ko"}`,children:[I.result,I.detail?` — ${I.detail}`:""]})]},R.name)}),h.jsxs("div",{className:"nc-set-form",children:[h.jsx("div",{className:"nc-sheet-label",children:v("invite-node")}),h.jsx("small",{className:"nc-set-hint",children:v(X?"invite-network-hint":"invite-v2-hint")}),X?h.jsxs(h.Fragment,{children:[W.length>1&&h.jsxs("label",{className:"nc-field",children:[v("invite-network-label"),h.jsx("select",{value:X.name,disabled:s||!!d,onChange:R=>{k(R.target.value),y(null)},children:W.map(R=>h.jsx("option",{value:R.name,children:R.label||R.name},R.name))})]}),h.jsxs("div",{className:"nc-set-info nc-invite-endpoint",children:[v("invite-network-via"),": ",h.jsx("b",{children:X.label||X.name})," · ",X.ssh,X.sshPort?`:${X.sshPort}`:""]}),h.jsx("small",{className:"nc-set-hint",children:v("invite-network-route")})]}):h.jsxs("label",{className:"nc-field",children:[v("invite-endpoint-label"),h.jsx("input",{placeholder:"user@host",value:_.ssh,disabled:s,onChange:R=>b({..._,ssh:R.target.value})}),h.jsx("small",{className:"nc-set-hint",children:v("invite-endpoint-needed")})]}),!X&&ee&&h.jsxs("div",{className:"nc-invite-advanced",children:[h.jsxs("label",{className:"nc-field",children:[v("node-ssh-port-label"),h.jsx("input",{inputMode:"numeric",placeholder:"22",value:_.sshPort,disabled:s,onChange:R=>b({..._,sshPort:R.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),h.jsxs("label",{className:"nc-field",children:[v("device-name-label"),h.jsx("input",{placeholder:J||"NexusCrew",value:A,disabled:s,onChange:R=>B(R.target.value)}),h.jsx("small",{className:"nc-set-hint",children:v("device-name-hint")})]}),h.jsxs("label",{className:"nc-field",children:[v("node-name-label"),h.jsx("input",{placeholder:Xr(A||J||v("node-name-ph")),value:_.name,disabled:s,onChange:R=>b({..._,name:R.target.value?Xr(R.target.value):""})})]})]}),h.jsxs("div",{className:"nc-set-row nc-invite-actions",children:[h.jsx("button",{type:"button",className:"nc-btn primary",disabled:s||!!d||!X&&!_.ssh.trim(),onClick:z,children:v("create-pairing-link")}),!X&&h.jsxs("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>O(R=>!R),children:[ee?"▾":"▸"," ",v("pair-advanced")]})]}),w&&h.jsxs(h.Fragment,{children:[h.jsx(_x,{value:w.pairingUrl}),h.jsx(vx,{text:w.pairingUrl}),h.jsx("div",{className:"nc-set-info",children:v("invite-next-steps")})]})]}),l&&h.jsx("div",{className:"nc-err",children:l})]})}function Sx({token:e,readonly:t}){const[n,s]=L.useState("idle"),[o,l]=L.useState(!1),[u,d]=L.useState(null);L.useEffect(()=>{let m=!1;return Kk().then(S=>{m||s(S)}),()=>{m=!0}},[]);const p=async()=>{d(null),l(!0);try{n==="subscribed"?(await Vk(e),s("idle")):(await qk(e),s("subscribed"))}catch(m){const S=String(m.message||m);S==="push-denied"?(s("denied"),d(v("push-denied"))):S==="push-unsupported"?(s("unsupported"),d(v("push-unsupported"))):d(S)}l(!1)};return n==="unsupported"?h.jsx("div",{className:"nc-set-info",children:v("push-unsupported")}):h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||o||n==="denied",title:t?v("settings-readonly"):"",onClick:p,children:v(n==="subscribed"?"push-disable":"push-enable")}),h.jsx("span",{className:"nc-set-info",children:v(n==="subscribed"?"push-on":n==="denied"?"push-denied":"push-off")})]}),u&&h.jsx("div",{className:"nc-err",children:u})]})}function wx({token:e,settings:t,readonly:n,refresh:s}){const[o,l]=L.useState(null),[u,d]=L.useState(null),[p,m]=L.useState(!1),[S,w]=L.useState(!1),[y,_]=L.useState(null),[b,C]=L.useState(!0);L.useEffect(()=>{_(t&&t.update||null),C(!t||t.autoUpdate!==!1)},[t]);const k=async()=>{l(null),d(null),w(!0);try{const O=await Ew(e);d(O.note||"ok"),m(!1)}catch(O){l(String(O.message||O))}w(!1)},N=async()=>{l(null),d(null),w(!0);try{const O=await Lw(e);d(`${O.note||"ok"}${O.target?` (${O.target})`:""}`)}catch(O){l(String(O.message||O))}w(!1)},M=async O=>{l(null),d(null),w(!0);try{await wv(e,{autoUpdate:O}),C(O),s&&await s()}catch(H){l(String(H.message||H))}w(!1)},A=async()=>{l(null),d(null),w(!0);try{_(await Mw(e))}catch(O){l(String(O.message||O))}w(!1)},B=async()=>{l(null),d(null),w(!0);try{const O=await jw(e);_(O),d(v("npm-update-restarting"))}catch(O){l(String(O.message||O))}w(!1)},ee=t&&t.service;return h.jsxs("div",{className:"nc-set-tab",children:[t&&h.jsxs("div",{className:"nc-set-info",children:["v",t.version," · ",t.platform," · :",t.port,h.jsx("br",{}),ee&&ee.installed?v("service-installed"):v("service-missing"),ee&&ee.installed?` · ${ee.active?v("service-active"):v("service-inactive")}`:"",ee?` · boot ${ee.boot?"on":"off"}`:""]}),h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||S,title:n?v("settings-readonly"):"",onClick:()=>{l(null),d(null),m(!0)},children:v("token-rotate")}),h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||S,title:n?v("settings-readonly"):"",onClick:N,children:v("service-regenerate")})]}),h.jsxs("div",{className:"nc-set-form nc-update-settings",children:[h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:b,disabled:n||S||y&&!y.supported,onChange:O=>M(O.target.checked)}),h.jsxs("span",{children:[h.jsx("b",{children:v("npm-auto-update")}),h.jsx("small",{children:v("npm-auto-update-help")})]})]}),y&&h.jsxs("div",{className:"nc-set-info",children:[v("npm-update-current")," v",y.current,y.latest?` · ${v("npm-update-latest")} v${y.latest}`:""," · ",v(`npm-update-${y.supported?y.phase:"unsupported"}`)]}),h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||S||!y||!y.supported,onClick:A,children:v("npm-update-check")}),y&&y.available&&h.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||S||y.phase==="installing",onClick:B,children:v("npm-update-install")})]}),y&&y.lastError&&h.jsx("div",{className:"nc-err",children:y.lastError})]}),h.jsx(Sx,{token:e,readonly:n}),p&&h.jsxs("div",{className:"nc-set-confirm",children:[h.jsx("div",{children:v("token-rotate-explain")}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:S,onClick:()=>m(!1),children:v("cancel")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:S,onClick:k,children:v("confirm")})]})]}),u&&h.jsx("div",{className:"nc-set-note",children:u}),o&&h.jsx("div",{className:"nc-err",children:o})]})}function bx({token:e,onClose:t,initialTab:n="nodes",initialLocation:s="",startNewCell:o=!1}){Si();const[l,u]=L.useState(n),[d,p]=L.useState(null),[m,S]=L.useState([]),[w,y]=L.useState(!1),[_,b]=L.useState(null),C=$h(e),k=L.useCallback(async()=>{try{const N=await _v(e);p(N),b(null)}catch(N){b(String(N.message||N))}try{const N=await yv(e);S(N.nodes||[])}catch(N){b(String(N.message||N))}},[e]);return L.useEffect(()=>{k();const N=setInterval(k,5e3);return()=>clearInterval(N)},[k]),L.useEffect(()=>{let N=!1;return zt("/api/config",e).then(M=>M.json()).then(M=>{N||y(!!M.readonlyDefault)}).catch(()=>{}),()=>{N=!0}},[e]),h.jsx("div",{className:"nc-set-overlay",onClick:t,children:h.jsxs("div",{className:"nc-set-panel",onClick:N=>N.stopPropagation(),children:[h.jsxs("div",{className:"nc-set-head",children:[h.jsx(tt,{name:"gear",size:18}),h.jsx("b",{children:v("settings")}),h.jsx("button",{type:"button",className:"nc-set-close",onClick:t,title:v("close"),children:h.jsx(tt,{name:"x",size:18})})]}),w&&h.jsx("div",{className:"nc-set-readonly",children:v("settings-readonly")}),_&&h.jsx("div",{className:"nc-err",children:_}),h.jsx("div",{className:"nc-set-tabs",children:["nodes","fleet","system"].map(N=>h.jsx("button",{type:"button",className:`nc-set-tabbtn${l===N?" on":""}`,onClick:()=>u(N),children:v(`tab-${N}`)},N))}),h.jsxs("div",{className:"nc-set-body",children:[l==="nodes"&&h.jsx(yx,{token:e,nodes:m,settings:d,readonly:w,refresh:k}),l==="fleet"&&h.jsx(fx,{token:e,readonly:w,startNewCell:o,initialLocation:s,targets:C.map(N=>({route:N.route,label:N.label||N.name,status:N.status}))}),l==="system"&&h.jsx(wx,{token:e,settings:d,readonly:w,refresh:k})]})]})})}function Cx({token:e,initialPair:t,onPairDone:n,onDone:s}){Si();const[o,l]=L.useState(t?"pair":"welcome"),[u,d]=L.useState(!1),[p,m]=L.useState(null),S=async()=>{d(!0),m(null);try{await wv(e,{wizardDone:!0}),n&&n(),s()}catch(w){m(String(w.message||w)),d(!1)}};return h.jsx("div",{className:"nc-wiz-overlay",children:h.jsxs("div",{className:"nc-wiz",children:[h.jsxs("div",{className:"nc-wiz-head",children:[h.jsx("b",{children:v("wizard-title")}),h.jsx("small",{children:v("hydra-simple")})]}),o==="welcome"&&h.jsxs("div",{className:"nc-wiz-body",children:[h.jsx("div",{className:"nc-wiz-done",children:v("local-ready")}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",disabled:u,onClick:S,children:v("local-only")}),h.jsx("button",{className:"nc-btn primary",disabled:u,onClick:()=>l("pair"),children:v("add-node")})]})]}),o==="pair"&&h.jsxs("div",{className:"nc-wiz-body",children:[h.jsx(V_,{token:e,initial:t||"",autoStart:!!t,onBusyChange:d,onSuccess:async()=>{n&&n(),l("done")}}),h.jsx("div",{className:"nc-sheet-actions",children:h.jsx("button",{className:"nc-btn ghost",disabled:u,onClick:()=>{n&&n(),l("welcome")},children:v("back")})})]}),o==="done"&&h.jsxs("div",{className:"nc-wiz-body",children:[h.jsx("div",{className:"nc-wiz-done",children:v("node-connected")}),h.jsx("div",{className:"nc-sheet-actions",children:h.jsx("button",{className:"nc-btn primary",disabled:u,onClick:S,children:v("finish")})})]}),p&&h.jsx("div",{className:"nc-err",children:p})]})})}function kx(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 xx=6e3,Ex=12e3;function Nx({n:e,onClose:t}){return h.jsxs("div",{className:`nc-ntf-toast${e.urgency==="high"?" high":""}`,role:"status","aria-live":"polite",children:[h.jsxs("div",{className:"nc-ntf-toast-txt",children:[h.jsx("b",{children:e.title}),e.body&&h.jsx("small",{children:e.body}),e.session&&h.jsx("span",{className:"nc-ntf-from",children:e.session})]}),h.jsx("button",{type:"button",className:"nc-ntf-x",onClick:t,title:v("close"),children:h.jsx(tt,{name:"x",size:14})})]})}function Rx({ask:e,token:t,onAnswered:n}){const[s,o]=L.useState(""),[l,u]=L.useState(!1),[d,p]=L.useState(null),m=async S=>{const w=String(S||"").trim();if(!(!w||l)){p(null),u(!0);try{await Aw(t,e.id,w),n(e.id)}catch(y){p(String(y.message||y))}u(!1)}};return h.jsxs("div",{className:"nc-ask-card",children:[h.jsxs("div",{className:"nc-ask-head",children:[h.jsx("span",{className:"nc-ntf-from",children:e.session}),h.jsxs("code",{className:"nc-ask-id",children:["#",e.id]})]}),h.jsx("div",{className:"nc-ask-q",children:e.question}),Array.isArray(e.options)&&e.options.length>0&&h.jsx("div",{className:"nc-ask-opts",children:e.options.map(S=>h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:l,onClick:()=>m(S),children:S},S))}),h.jsxs("div",{className:"nc-ask-reply",children:[h.jsx("textarea",{rows:2,placeholder:v("ask-reply-ph"),value:s,disabled:l,onChange:S=>o(S.target.value)}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:l||!s.trim(),onClick:()=>m(s),children:v("send")})]}),d&&h.jsx("div",{className:"nc-err",children:d})]})}function Px({token:e}){Si();const[t,n]=L.useState([]),[s,o]=L.useState([]),[l,u]=L.useState(()=>{try{return/(?:^|[#&])ask=/.test(location.hash)}catch{return!1}}),d=L.useRef(0),p=L.useCallback(w=>{n(y=>y.filter(_=>_.key!==w))},[]),m=L.useCallback(w=>{const y=`t${d.current+=1}`;n(_=>[..._.slice(-3),{...w,key:y}]),setTimeout(()=>p(y),w.urgency==="high"?Ex:xx)},[p]);L.useEffect(()=>{if(!e)return;let w=!1;Tw(e).then(_=>{w||o(_.asks||[])}).catch(()=>{});const y=kx(e,_=>{_.type==="notify"?m(_):_.type==="ask"&&_.ask&&_.ask.id?o(b=>b.some(C=>C.id===_.ask.id)?b:[...b,_.ask]):_.type==="ask-answered"&&_.id&&o(b=>b.filter(C=>C.id!==_.id))});return()=>{w=!0,y()}},[e,m]);const S=w=>o(y=>y.filter(_=>_.id!==w));return h.jsxs(h.Fragment,{children:[t.length>0&&h.jsx("div",{className:"nc-ntf-toasts",children:t.map(w=>h.jsx(Nx,{n:w,onClose:()=>p(w.key)},w.key))}),s.length>0&&!l&&h.jsxs("button",{type:"button",className:"nc-ask-badge",onClick:()=>u(!0),title:v("asks-title"),children:["? ",h.jsx("span",{className:"nc-ask-count",children:s.length})]}),s.length>0&&l&&h.jsxs("div",{className:"nc-ask-panel",children:[h.jsxs("div",{className:"nc-ask-panel-head",children:[h.jsx("b",{children:v("asks-title")}),h.jsx("span",{className:"nc-ask-count",children:s.length}),h.jsx("button",{type:"button",className:"nc-ntf-x",onClick:()=>u(!1),title:v("close"),children:h.jsx(tt,{name:"x",size:16})})]}),h.jsx("div",{className:"nc-ask-panel-body",children:s.map(w=>h.jsx(Rx,{ask:w,token:e,onAnswered:S},w.id))})]})]})}const Iu=e=>Ji(ur(e)).length===0,Ou=e=>Array.isArray(e)?e.join("/"):"";function Dx(e){const t=new Set,n=[];for(const s of Array.isArray(e)?e:[])!s||!Li.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 qs(e){return{instanceId:e.ownerId,route:e.ownerRoute||[],label:e.ownerLabel,status:e.available===!1?"offline":"up"}}function rr(e,t,n,s=!1,o=!0){const l=t.instanceId;return{...e,id:Yr(s?null:l,e.name),ownerId:l,ownerRoute:s?[]:[...t.route],ownerLabel:s?"Local":t.label,local:s,available:o,ownerTopology:Array.isArray(n)?n:[],layout:xh(e.layout,l,n)}}function Lx(e,t,n,s,o=[]){const[l,u]=L.useState([]),[d,p]=L.useState(!1),[m,S]=L.useState("idle"),[w,y]=L.useState(""),[_,b]=L.useState(""),C=L.useRef([]),k=L.useRef([]),N=L.useRef(""),M=L.useRef(t),A=L.useRef(n),B=L.useRef(!1),ee=L.useRef(!0),O=L.useRef(""),H=L.useMemo(()=>Dx(o),[o]),J=H.map(q=>`${q.instanceId}:${Ou(q.route)}:${q.status}:${q.label}`).join("|");k.current=H,A.current=n,M.current=t,C.current=l;const W=L.useCallback(q=>Eh(q.layout,N.current,k.current),[]),X=L.useCallback((q,D=!0,U=M.current)=>{const Q=_g(q,Ra()),ae=C.current.some(le=>le.id===U);C.current=Q,u(Q);const se=Q.find(le=>le.id===U);if(D&&se){ee.current=!0;const le=W(se);s(le),se.local&&QC(se.name,le)}else ae&&!se&&(ee.current=!0,s(Vr()),y("deck non più condiviso dal nodo owner"));VC(Q.filter(le=>le.local).map(le=>le.name))},[s,W]),G=L.useCallback(async q=>{let D=await _a(e);const U=D.decks.find(Q=>Q.name==="main");if(D.decks.length===1&&U&&U.revision===0&&Iu(U.layout)){const Q=qC(),ae=ur(Nh("main")||Vr());if(!Iu(ae)){const se=xh(ae,q,[]);D.decks[0]=await ya(e,"main",se,0,[])}for(const se of Q.filter(le=>le!=="main"))try{let le=await nm(e,se,[]);const pe=ur(Nh(se)||Vr());Iu(pe)||(le=await ya(e,se,xh(pe,q,[]),le.revision,[]))}catch{}D=await _a(e)}return D},[e]),j=L.useCallback(async({migrate:q=!1}={})=>{const D=await Oh(e,[]),U=Li.test(String(D.instanceId||""))?D.instanceId:"";if(!U)throw new Error("instanceId locale non disponibile");N.current=U,b(U);const[Q,ae]=await Promise.all([q?G(U):_a(e),em(e,[]).catch(()=>({nodes:[]}))]),se={instanceId:U,route:[],label:"Local"},le=Q.decks.map(ce=>rr(ce,se,ae.nodes,!0,!0)),pe=C.current;return await Promise.all(k.current.map(async ce=>{if(ce.status!=="up"){le.push(...pe.filter(ke=>!ke.local&&ke.ownerId===ce.instanceId).map(ke=>({...ke,ownerRoute:[...ce.route],ownerLabel:ce.label,available:!1})));return}try{const[ke,Oe]=await Promise.all([_a(e,ce.route),em(e,ce.route).catch(()=>({nodes:[]}))]);le.push(...ke.decks.map(te=>rr(te,ce,Oe.nodes,!1,!0)))}catch{le.push(...pe.filter(Oe=>!Oe.local&&Oe.ownerId===ce.instanceId).map(Oe=>({...Oe,ownerRoute:[...ce.route],ownerLabel:ce.label,available:!1})))}})),le.sort((ce,ke)=>ce.local===ke.local?ce.ownerLabel.localeCompare(ke.ownerLabel)||(ce.name==="main"?-1:ke.name==="main"?1:ce.name.localeCompare(ke.name)):ce.local?-1:1),le},[e,G,J]);L.useEffect(()=>{if(!e)return;let q=!1;const D=O.current!==e;return O.current=e,j({migrate:D}).then(U=>{if(q)return;const Q=C.current.find(le=>le.id===M.current),ae=U.find(le=>le.id===M.current),se=ae&&(!Q||ae.revision>Q.revision||Q.available!==ae.available||Ou(Q.ownerRoute)!==Ou(ae.ownerRoute));X(U,D||!!se&&!B.current),p(!0),ae&&y("")}).catch(U=>{q||(p(!0),y(String(U.message||U)))}),()=>{q=!0}},[X,j,J,e]);const E=L.useCallback(async(q=M.current)=>{if(!d||!B.current)return!0;const D=C.current.find(U=>U.id===q);if(!D)return y(`deck inesistente: ${q}`),!1;if(D.available===!1)return y(`nodo owner offline: ${D.ownerLabel}`),!1;S("saving");try{const U=gg(ur(A.current),D.ownerId,D.ownerTopology),Q=await ya(e,D.name,U,D.revision,D.ownerRoute),ae=rr(Q,qs(D),D.ownerTopology,D.local,!0);return X(C.current.map(se=>se.id===q?ae:se),!1),B.current=!1,S("saved"),y(""),setTimeout(()=>S("idle"),1500),!0}catch(U){if(S("error"),y(String(U.message||U)),U.status===409&&U.data&&U.data.current){const Q=C.current.find(se=>se.id===q),ae=rr(U.data.current,qs(Q),Q.ownerTopology,Q.local,!0);X(C.current.map(se=>se.id===q?ae:se),!1)}return!1}},[d,e,X]);return L.useEffect(()=>{if(!d)return;if(ee.current){ee.current=!1;return}B.current=!0,S("saving");const q=setTimeout(E,650);return()=>clearTimeout(q)},[n,d,E]),L.useEffect(()=>{if(!d)return;const q=setInterval(async()=>{try{const D=await j(),U=C.current.find(se=>se.id===M.current),Q=D.find(se=>se.id===M.current),ae=Q&&(!U||Q.revision>U.revision||U.available!==Q.available);X(D,ae&&!B.current)}catch{}},5e3);return()=>clearInterval(q)},[d,j,X]),{decks:l,records:l,localNodeId:_,ready:d,saveState:m,error:w,setError:y,saveNow:E,select:async q=>{if(B.current&&!await E(M.current))throw new Error("salvataggio del deck corrente fallito: cambio annullato");const D=C.current.find(U=>U.id===q);if(!D)throw new Error(`deck inesistente: ${q}`);return B.current=!1,ee.current=!0,W(D)},add:async(q,D=null)=>{const U=D===hn?C.current.find(se=>se.local):D?C.current.find(se=>se.ownerId===D):null;if(!U||U.available===!1)throw new Error("nodo owner non disponibile");const Q=await nm(e,q,U.ownerRoute),ae=rr(Q,qs(U),U.ownerTopology,U.local,!0);return X([...C.current,ae],!1),ae},rename:async(q,D)=>{const U=C.current.find(pe=>pe.id===q);if(!U)throw new Error("deck inesistente");if(q===M.current&&B.current&&!await E(q))throw new Error(`salvataggio di "${U.name}" fallito: rinomina annullata`);const Q=C.current.find(pe=>pe.id===q);if(!Q)throw new Error("deck inesistente");const ae=await Bw(e,Q.name,D,Q.revision,Q.ownerRoute),se=rr(ae,qs(Q),Q.ownerTopology,Q.local,!0),le=Q.local?hn:Q.ownerId;return fu(XC(Ra(),le,q,se.id)),X(C.current.map(pe=>pe.id===q?se:pe),!1),se},remove:async q=>{const D=C.current.find(Q=>Q.id===q);if(!D)throw new Error("deck inesistente");q===M.current&&(B.current=!1),await Iw(e,D.name,D.revision,D.ownerRoute);const U=D.local?hn:D.ownerId;fu(GC(Ra(),U,q)),X(C.current.filter(Q=>Q.id!==q),!1)},reorder:(q,D)=>{const U=C.current.find(ce=>ce.id===q),Q=C.current.find(ce=>ce.id===D);if(!U||!Q)return!1;const ae=U.local?hn:U.ownerId,se=Q.local?hn:Q.ownerId;if(ae!==se)return!1;const le=C.current.filter(ce=>(ce.local?hn:ce.ownerId)===ae).map(ce=>ce.id),pe=fu(YC(Ra(),ae,q,D,le));return X(_g(C.current,pe),!1),!0},addTileTo:async(q,D)=>{const U=C.current.find(ce=>ce.id===q);if(!U)throw new Error("deck inesistente");if(U.available===!1)throw new Error(`nodo owner offline: ${U.ownerLabel}`);const Q=A_(D,N.current,k.current);if(!Q)throw new Error("riferimento sessione non valido");const ae=W(U),se=gg(j_(ae,Q),U.ownerId,U.ownerTopology),le=await ya(e,U.name,se,U.revision,U.ownerRoute),pe=rr(le,qs(U),U.ownerTopology,U.local,!0);return X(C.current.map(ce=>ce.id===q?pe:ce),!1),pe},localMainId:Yr(null,"main"),parseDeckId:td}}const Mx="/sw.js",Ph="nc-sw-update";let Dh=null,Lh=!1,Mh=null,iy=Object.freeze({needed:!1,kind:null,version:""}),ny=!1;function ry(){typeof window<"u"&&window.dispatchEvent(new Event(Ph))}function sy(){const e=Mh||(Lh?{kind:"reload",version:""}:null);iy=Object.freeze({needed:!!e,kind:(e==null?void 0:e.kind)||null,version:(e==null?void 0:e.version)||""})}function av(){return iy}function jx(e){return typeof window>"u"?()=>{}:(window.addEventListener(Ph,e),()=>window.removeEventListener(Ph,e))}function od(e){Lh!==e&&(Lh=e,sy(),ry())}function Tx(e,t,n){let s=null;e&&t&&e!==t?s={kind:"install",version:e}:t&&n&&t!==n&&(s={kind:"reload",version:t});const o=JSON.stringify(s)===JSON.stringify(Mh);Mh=s,sy(),o||ry()}function Ax(e){e.addEventListener("statechange",()=>{e.state==="installed"&&navigator.serviceWorker.controller&&od(!0)})}function Bx(){typeof navigator>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{ny&&location.reload()}),navigator.serviceWorker.register(Mx).then(e=>{Dh=e,e.waiting&&od(!0),e.addEventListener("updatefound",()=>{const t=e.installing;t&&Ax(t)}),setInterval(()=>{e.update().catch(()=>{})},3600*1e3)}).catch(()=>{}))}function Ix(){ny=!0,od(!1);const e=Dh&&Dh.waiting;e?(e.postMessage({type:"SKIP_WAITING"}),setTimeout(()=>location.reload(),4e3)):location.reload()}function Ox({hash:e="",origin:t="",pathname:n="",search:s=""}={}){const o=String(e||"").replace(/^#/,""),l=`${n||""}${s||""}`;if(!o)return{token:"",pair:"",nextUrl:l};const u=new URLSearchParams(o),d=u.get("token")||"",p=u.get("pair")||"",m=p?`${t||""}${n||""}#pair=${p}`:"";return{token:d,pair:m,nextUrl:l}}const oy=9,ay=24,ly="nc_side_w",lv="nc_side_min",zx=240,cv="(min-width:1024px) and (pointer:fine)";function Fx(){const e=Number(localStorage.getItem(ly));return e>=180&&e<=480?e:zx}function Hx(){const e=Number(localStorage.getItem("nc_fontsize"));return e>=oy&&e<=ay?e:13}function $x(){const e={token:"",pair:""};try{const{token:t,pair:n,nextUrl:s}=Ox({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 Wx(e){try{return ur(Nh(e))}catch{return Vr()}}function uv(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 Ux(){const[e,t]=L.useState(()=>window.matchMedia(cv).matches);return L.useEffect(()=>{const n=window.matchMedia(cv),s=o=>t(o.matches);return n.addEventListener("change",s),()=>n.removeEventListener("change",s)},[]),e}function hv({session:e,node:t,token:n,readonly:s=!1,onBack:o}){Si();const[l,u]=L.useState(!1),[d,p]=L.useState(()=>window.matchMedia("(pointer: coarse)").matches),[m,S]=L.useState(null),[w,y]=L.useState(Hx),[_,b]=L.useState(""),C=W=>y(X=>{const G=Math.max(oy,Math.min(ay,X+W));return localStorage.setItem("nc_fontsize",String(G)),G}),k=L.useRef(()=>{}),N=L.useRef(()=>!1),M=L.useRef(()=>{}),A=L.useRef(!1),[B,ee]=L.useState(!1),[O,H]=L.useState(!1),J=()=>{A.current=!A.current,ee(A.current)};return L.useEffect(()=>{let W=!0;const X=t?t.split("/"):[],G=t?`/api/route/${t.split("/").map(encodeURIComponent).join("/")}/_`:"/api";async function j(){let P=null,z=null;try{const I=await(await zt(`${G}/sessions`,n)).json();Array.isArray(I.sessions)&&(P=I.sessions.find(re=>re.name===e))}catch{}try{const F=await fr(n,X);F.available&&Array.isArray(F.cells)&&(z=F.cells.find(I=>I.tmuxSession===e))}catch{}if(!W)return;let R="";z?R=`${z.engine}${z.key?`·${z.key}`:""}`:P&&(R=P.attached?`attached · ${uv(P.activity)}`:P.activity?uv(P.activity):""),b(R)}j();const E=setInterval(j,4e3);return()=>{W=!1,clearInterval(E)}},[e,t,n]),h.jsxs("div",{className:"nc-app",children:[h.jsxs("header",{className:"nc-bar nc-bar-single",children:[h.jsxs("button",{onClick:o,title:v("sessions"),children:[h.jsx(tt,{name:"chevronLeft",size:18}),h.jsx("span",{className:"nc-bar-label",children:v("sessions")})]}),h.jsxs("span",{className:"nc-bar-center",children:[h.jsx("b",{children:t?`${t}:${e}`:e}),_&&h.jsx("small",{className:"nc-bar-sub",children:_})]}),h.jsxs("span",{className:"nc-bar-right",children:[h.jsx("button",{onClick:()=>C(-1),title:v("zoom-out"),children:h.jsx(tt,{name:"zoomOut",size:18})}),h.jsx("button",{onClick:()=>C(1),title:v("zoom-in"),children:h.jsx(tt,{name:"zoomIn",size:18})}),h.jsx("button",{onClick:()=>p(W=>!W),title:v("composer"),children:h.jsx(tt,{name:"keyboard",size:20})}),h.jsx("button",{onClick:()=>u(W=>!W),title:v("files"),children:h.jsx(tt,{name:"folder",size:20})})]})]}),h.jsx("div",{className:"nc-termwrap",children:h.jsx(N_,{session:e,node:t,token:n,readonly:s,takeSize:!0,sendRef:k,composerRef:N,actionRef:M,ctrlRef:A,setCtrlArmed:ee,onFiles:S,fontSize:w,selectionMode:O,onSelectionModeChange:H})}),h.jsx(wC,{onKeyboard:()=>p(W=>!W),send:W=>k.current(W),action:W=>M.current(W),ctrlArmed:B,onCtrl:J,selectionMode:O,onSelectionMode:H}),d&&h.jsx(P_,{submitText:W=>N.current(W),token:n,session:e,node:t}),l&&h.jsx(R_,{session:e,node:t,token:n,filesEvent:m,onClose:()=>u(!1)})]})}function Kx(){Si();const[e]=L.useState($x),[t,n]=L.useState(e.token),[s,o]=L.useState(e.pair||""),l=L.useCallback(()=>{o("");try{sessionStorage.removeItem("nc_pair")}catch{}},[]),[u,d]=L.useState(!1),p=Ux(),[m]=L.useState(()=>KC(typeof location<"u"?location.pathname:"/")),[S,w]=L.useState(m.id),y=S===Yr(null,yi),[_,b]=L.useState(null),C=ue=>b(Wn(ue)),[k,N]=L.useState([]),[M,A]=L.useState([]),[B,ee]=L.useState(()=>m.ownerId?Vr():Wx(m.name)),[O,H]=L.useState(null),[J,W]=L.useState(null),X=ue=>W(Wn(ue)),G=$h(t,p),j=L.useMemo(()=>(G||[]).filter(ue=>ue.instanceId).map(ue=>({instanceId:ue.instanceId,route:ue.route,label:ue.label,status:ue.status})),[G]),E=Lx(t,S,B,ee,j),P=E.decks;L.useEffect(()=>{const ue=new Map;for(const De of G||[]){const Ke=(De.route||[De.name]).join("/"),Lt=new Set((De.sessions||[]).map(hi=>hi.name));for(const hi of De.cells||[])!hi.cell||!hi.tmuxSession||hi.cell===hi.tmuxSession||Lt.has(hi.cell)||ue.set(`${Ke}:${hi.cell}`,`${Ke}:${hi.tmuxSession}`)}ee(De=>MC(De,ue))},[G]),L.useEffect(()=>{E.localNodeId&&ee(ue=>{const De=Eh(ue,E.localNodeId,j);return JSON.stringify(De)===JSON.stringify(ue)?ue:De})},[j,E.localNodeId]);const[z,R]=L.useState(null),[F,I]=L.useState(!1),[re,q]=L.useState(Fx),[D,U]=L.useState(!y),[Q,ae]=L.useState(()=>y?localStorage.getItem(lv)==="1":!0),[se,le]=L.useState(!1),[pe,ce]=L.useState("nodes"),[ke,Oe]=L.useState(!1),[te,ie]=L.useState(""),ye=(ue="nodes",De=!1,Ke="")=>{ce(ue),Oe(De),ie(Ke),le(!0)},[Me,je]=L.useState(!1),[Y,de]=L.useState(!1);L.useEffect(()=>{try{localStorage.setItem(ly,String(re))}catch{}},[re]),L.useEffect(()=>{try{localStorage.setItem(lv,Q?"1":"")}catch{}},[Q]),L.useEffect(()=>{if(!t)return;let ue=!1;return Promise.all([_v(t),zt("/api/config",t).then(De=>De.json())]).then(([De,Ke])=>{ue||(de(!!Ke.readonlyDefault),(De.firstRun===!0&&!Ke.readonlyDefault||s)&&je(!0))}).catch(()=>{}),()=>{ue=!0}},[t,s]);const we=L.useCallback(async()=>{try{const De=await(await zt("/api/sessions",t)).json();De.error||N(De.sessions||[])}catch{}try{const ue=await fr(t);A(ue.available?ue.cells||[]:[])}catch{A([])}},[t]);L.useEffect(()=>{if(!p)return;we();const ue=setInterval(we,4e3);return()=>clearInterval(ue)},[p,we]),L.useEffect(()=>{let ue=!1;return zt("/api/config",t).then(De=>De.json()).then(De=>{ue||Tx(De.version,De.uiVersion,"0.8.16")}).catch(()=>{}),()=>{ue=!0}},[t]);const K=new Set([...k.map(ue=>ue.name),...G.flatMap(ue=>ue.sessions.map(De=>De.key))]),fe=Ji(B),Ce=ue=>ee(De=>{const Ke=A_(ue,E.localNodeId,j)||ue,Lt=j_(De,Ke);return Lt===De&&Ji(De).length>=9&&E.setError(v("grid-full")),Lt}),Ne=async(ue,De=[])=>{try{await Ih(t,ue,De)}catch{return}const Ke=De.length?`${De.join("/")}:${ue}`:ue;ee(Lt=>Ga(Lt,Ke)),we()},Be=async(ue,De,Ke=[])=>{try{await gv(t,ue,De,Ke)}catch{return}we()},mt=async ue=>{if(!z)return;const{cell:De}=z,Ke=Array.isArray(z.route)?z.route:[];ue.action==="up"?await Ah(t,{cell:De,boot:!!ue.boot,...ue.engine?{engine:ue.engine}:{},...ue.model!==void 0?{model:ue.model}:{},...ue.permissionPolicy?{permissionPolicy:ue.permissionPolicy}:{}},Ke):await Oa(t,{cell:De,boot:!!ue.boot},Ke),we()},rt=async ue=>{if(!(!(ue!=null&&ue.direct)||F)){I(!0);try{await zh(t,ue.name,ue.tunnelStatus==="up"?"down":"up")}finally{I(!1)}}},Ae=ue=>{const De=P.find(Ke=>Ke.id===ue);if(!De)return!1;try{const Ke=window.open(du(De,t),"_blank");return Ke&&(Ke.opener=null),!!Ke}catch{return!1}},We=async ue=>{if(!ue||ue===S)return;const De=await E.select(ue),Ke=E.records.find(Lt=>Lt.id===ue);w(ue),ee(De),H(null),W(null);try{history.replaceState(null,"",du(Ke||ue,null))}catch{}},Ie=async(ue,De)=>{const Ke=await E.add(ue,De);await We(Ke.id)},bt=async(ue,De)=>{const Ke=await E.rename(ue,De);if(ue===S){w(Ke.id),ee(Eh(Ke.layout,E.localNodeId,j)),H(null),W(null);try{history.replaceState(null,"",du(Ke,null))}catch{}}},Ge=async ue=>{await E.remove(ue),ue===S&&await We(E.localMainId)},ge=async(ue,De)=>{!De||De===S||(await E.addTileTo(De,ue),ee(Ke=>Ga(Ke,ue)))};if(!t)return h.jsxs("div",{className:"nc-auth",children:[h.jsx("p",{children:v("auth-prompt")}),h.jsx("input",{onChange:ue=>n(ue.target.value.trim()),placeholder:"token"}),h.jsxs("label",{children:[h.jsx("input",{type:"checkbox",checked:u,onChange:ue=>d(ue.target.checked)})," ",v("remember-device")]}),h.jsx("button",{onClick:()=>{(u?localStorage:sessionStorage).setItem("nc_token",t)},children:"ok"})]});const qe=h.jsxs(h.Fragment,{children:[se&&h.jsx(bx,{token:t,initialTab:pe,initialLocation:te,startNewCell:ke,onClose:()=>{le(!1),Oe(!1),ie("")}}),Me&&h.jsx(Cx,{token:t,initialPair:s,onPairDone:l,onDone:()=>je(!1)}),h.jsx(Px,{token:t})]});if(!p)return _?h.jsxs(h.Fragment,{children:[h.jsx(hv,{session:_.session,node:_.node,token:t,readonly:Y,onBack:()=>b(null)}),qe]}):h.jsxs(h.Fragment,{children:[h.jsx(Gw,{onPick:C,token:t,onSettings:ye}),qe]});const et=y||!D;return h.jsxs("div",{className:"nc-workspace",children:[et&&h.jsx(EC,{sessions:k,cells:M,activeSessions:fe,nodeGroups:G,onPick:X,onAddTile:Ce,onPower:R,onNodePower:rt,onKill:Ne,onVisibility:Be,onNew:()=>ye("fleet",!0),onSettings:ye,width:re,collapsed:Q,onResize:q,onToggleCollapse:()=>ae(ue=>!ue)}),h.jsxs("div",{className:"nc-workspace-main",children:[h.jsx(ZC,{decks:P,currentDeck:S,onCreate:Ie,onRename:bt,onDelete:Ge,onReorder:E.reorder,onOpenWindow:Ae,onNavigate:We,saveState:E.saveState,error:E.error,sidebarVisible:et,onToggleSidebar:y?null:()=>U(ue=>!ue)}),h.jsx(FC,{layout:B,onLayoutChange:ee,token:t,readonly:Y,sessionsAlive:K,focusSession:O,onFocus:H,onOpenSingle:X,decks:P,currentDeck:S,onSendToDeck:ge})]}),J&&h.jsx("div",{className:"nc-single-overlay",children:h.jsx(hv,{session:J.session,node:J.node,token:t,readonly:Y,onBack:()=>W(null)})}),z&&h.jsx(Fa,{cell:z,token:t,route:Array.isArray(z.route)?z.route:[],onConfirm:mt,onClose:()=>R(null)}),qe]})}function qx(){Si();const e=L.useSyncExternalStore(jx,av,av);if(!e.needed)return null;const t=e.kind==="install"?v("install-version-mismatch").replace("{v}",e.version):v("update-available").replace("{v}",e.version).replace(" "," ").trim();return h.jsxs("div",{className:"nc-update",role:"status","aria-live":"polite",children:[h.jsx("span",{className:"nc-update-msg",children:t}),e.kind==="reload"&&h.jsx("button",{className:"nc-update-btn",onClick:Ix,children:v("reload")})]})}Bx();fw.createRoot(document.getElementById("root")).render(h.jsxs(ow.StrictMode,{children:[h.jsx(Kx,{}),h.jsx(qx,{})]}));
|