@mmmbuto/nexuscrew 0.9.28 → 0.9.30

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.
Files changed (81) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/docs/LIVE_PROMPT.md +1 -1
  3. package/docs/NOTIFICATIONS.md +37 -0
  4. package/docs/OPERATIONS.md +20 -0
  5. package/frontend/dist/assets/index-BbcjoZS0.js +167 -0
  6. package/frontend/dist/assets/index-DqCfZFGi.css +32 -0
  7. package/frontend/dist/index.html +2 -2
  8. package/frontend/dist/sw.js +91 -10
  9. package/frontend/dist/version.json +1 -1
  10. package/lib/audio/groups.js +1 -1
  11. package/lib/auth/token.js +4 -4
  12. package/lib/cli/commands.js +70 -15
  13. package/lib/cli/doctor.js +5 -5
  14. package/lib/cli/fleet-service.js +7 -7
  15. package/lib/cli/init.js +55 -31
  16. package/lib/cli/pidfile.js +1 -1
  17. package/lib/cli/service.js +124 -8
  18. package/lib/cli/stable-alias.js +4 -4
  19. package/lib/cli/url.js +1 -1
  20. package/lib/config.js +36 -6
  21. package/lib/files/routes.js +1 -1
  22. package/lib/fleet/boot.js +2 -2
  23. package/lib/fleet/builtin.js +15 -15
  24. package/lib/fleet/causes.js +1 -1
  25. package/lib/fleet/cell-exec.js +23 -23
  26. package/lib/fleet/cell-hold.js +6 -6
  27. package/lib/fleet/cell-lease-server.js +106 -106
  28. package/lib/fleet/cell-lease.js +21 -21
  29. package/lib/fleet/definitions.js +10 -10
  30. package/lib/fleet/identity-authority.js +1 -1
  31. package/lib/fleet/launch-broker.js +13 -13
  32. package/lib/fleet/launch.js +15 -15
  33. package/lib/fleet/lease-client.js +23 -23
  34. package/lib/fleet/lease-routes.js +3 -3
  35. package/lib/fleet/lease-verifier.js +22 -22
  36. package/lib/fleet/managed.js +35 -35
  37. package/lib/fleet/prompt-delivery.js +13 -13
  38. package/lib/fleet/routes.js +15 -10
  39. package/lib/fleet/runtime.js +24 -24
  40. package/lib/live-host/bridge.js +53 -43
  41. package/lib/live-host/federation.js +97 -0
  42. package/lib/live-host/routes.js +166 -8
  43. package/lib/live-host/store.js +44 -6
  44. package/lib/mcp/server.js +14 -14
  45. package/lib/mcp/tools.js +5 -5
  46. package/lib/nodes/access-presets.js +258 -0
  47. package/lib/nodes/commands.js +198 -4
  48. package/lib/nodes/store.js +152 -9
  49. package/lib/nodes/tunnel.js +7 -7
  50. package/lib/notify/ask-answer-service.js +184 -0
  51. package/lib/notify/ask-receipts.js +197 -0
  52. package/lib/notify/ask-relay.js +152 -0
  53. package/lib/notify/asks.js +28 -3
  54. package/lib/notify/event-feed-acl.js +95 -0
  55. package/lib/notify/event-feed-asks-routes.js +144 -0
  56. package/lib/notify/event-feed-client.js +434 -0
  57. package/lib/notify/event-feed-history.js +115 -0
  58. package/lib/notify/event-feed-producers.js +175 -0
  59. package/lib/notify/event-feed-routes.js +254 -0
  60. package/lib/notify/event-feed.js +328 -0
  61. package/lib/notify/events.js +1 -1
  62. package/lib/notify/notifier.js +3 -3
  63. package/lib/notify/push-relay.js +240 -0
  64. package/lib/notify/push.js +8 -8
  65. package/lib/notify/routes.js +62 -23
  66. package/lib/proxy/federation.js +132 -12
  67. package/lib/proxy/node-proxy.js +13 -13
  68. package/lib/proxy/panel-auth.js +4 -4
  69. package/lib/proxy/panel-proxy.js +2 -2
  70. package/lib/proxy/resource-acl.js +145 -0
  71. package/lib/server.js +396 -40
  72. package/lib/settings/pairing-coordinator.js +1 -1
  73. package/lib/settings/routes.js +45 -32
  74. package/lib/update/manager.js +1 -1
  75. package/lib/update/runner.js +1 -1
  76. package/lib/voice/transcribe.js +1 -1
  77. package/lib/ws/bridge.js +3 -3
  78. package/package.json +1 -1
  79. package/skills/live/SKILL.md +12 -0
  80. package/frontend/dist/assets/index-CWra6B79.js +0 -167
  81. package/frontend/dist/assets/index-D6CIfCjv.css +0 -32
@@ -1,167 +0,0 @@
1
- (function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&i(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function i(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();function am(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ah={exports:{}},Xa={},jh={exports:{}},bt={};/**
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 N_;function qC(){if(N_)return bt;N_=1;var t=Symbol.for("react.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),l=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),y=Symbol.iterator;function _(z){return z===null||typeof z!="object"?null:(z=y&&z[y]||z["@@iterator"],typeof z=="function"?z:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b=Object.assign,N={};function x(z,F,K){this.props=z,this.context=F,this.refs=N,this.updater=K||w}x.prototype.isReactComponent={},x.prototype.setState=function(z,F){if(typeof z!="object"&&typeof z!="function"&&z!=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,z,F,"setState")},x.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function E(){}E.prototype=x.prototype;function C(z,F,K){this.props=z,this.context=F,this.refs=N,this.updater=K||w}var I=C.prototype=new E;I.constructor=C,b(I,x.prototype),I.isPureReactComponent=!0;var T=Array.isArray,W=Object.prototype.hasOwnProperty,U={current:null},Q={key:!0,ref:!0,__self:!0,__source:!0};function ee(z,F,K){var ne,re={},Y=null,de=null;if(F!=null)for(ne in F.ref!==void 0&&(de=F.ref),F.key!==void 0&&(Y=""+F.key),F)W.call(F,ne)&&!Q.hasOwnProperty(ne)&&(re[ne]=F[ne]);var oe=arguments.length-2;if(oe===1)re.children=K;else if(1<oe){for(var pe=Array(oe),xe=0;xe<oe;xe++)pe[xe]=arguments[xe+2];re.children=pe}if(z&&z.defaultProps)for(ne in oe=z.defaultProps,oe)re[ne]===void 0&&(re[ne]=oe[ne]);return{$$typeof:t,type:z,key:Y,ref:de,props:re,_owner:U.current}}function q(z,F){return{$$typeof:t,type:z.type,key:F,ref:z.ref,props:z.props,_owner:z._owner}}function J(z){return typeof z=="object"&&z!==null&&z.$$typeof===t}function $(z){var F={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(K){return F[K]})}var M=/\/+/g;function L(z,F){return typeof z=="object"&&z!==null&&z.key!=null?$(""+z.key):F.toString(36)}function j(z,F,K,ne,re){var Y=typeof z;(Y==="undefined"||Y==="boolean")&&(z=null);var de=!1;if(z===null)de=!0;else switch(Y){case"string":case"number":de=!0;break;case"object":switch(z.$$typeof){case t:case e:de=!0}}if(de)return de=z,re=re(de),z=ne===""?"."+L(de,0):ne,T(re)?(K="",z!=null&&(K=z.replace(M,"$&/")+"/"),j(re,F,K,"",function(xe){return xe})):re!=null&&(J(re)&&(re=q(re,K+(!re.key||de&&de.key===re.key?"":(""+re.key).replace(M,"$&/")+"/")+z)),F.push(re)),1;if(de=0,ne=ne===""?".":ne+":",T(z))for(var oe=0;oe<z.length;oe++){Y=z[oe];var pe=ne+L(Y,oe);de+=j(Y,F,K,pe,re)}else if(pe=_(z),typeof pe=="function")for(z=pe.call(z),oe=0;!(Y=z.next()).done;)Y=Y.value,pe=ne+L(Y,oe++),de+=j(Y,F,K,pe,re);else if(Y==="object")throw F=String(z),Error("Objects are not valid as a React child (found: "+(F==="[object Object]"?"object with keys {"+Object.keys(z).join(", ")+"}":F)+"). If you meant to render a collection of children, use an array instead.");return de}function O(z,F,K){if(z==null)return z;var ne=[],re=0;return j(z,ne,"","",function(Y){return F.call(K,Y,re++)}),ne}function P(z){if(z._status===-1){var F=z._result;F=F(),F.then(function(K){(z._status===0||z._status===-1)&&(z._status=1,z._result=K)},function(K){(z._status===0||z._status===-1)&&(z._status=2,z._result=K)}),z._status===-1&&(z._status=0,z._result=F)}if(z._status===1)return z._result.default;throw z._result}var A={current:null},R={transition:null},D={ReactCurrentDispatcher:A,ReactCurrentBatchConfig:R,ReactCurrentOwner:U};function H(){throw Error("act(...) is not supported in production builds of React.")}return bt.Children={map:O,forEach:function(z,F,K){O(z,function(){F.apply(this,arguments)},K)},count:function(z){var F=0;return O(z,function(){F++}),F},toArray:function(z){return O(z,function(F){return F})||[]},only:function(z){if(!J(z))throw Error("React.Children.only expected to receive a single React element child.");return z}},bt.Component=x,bt.Fragment=n,bt.Profiler=s,bt.PureComponent=C,bt.StrictMode=i,bt.Suspense=h,bt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=D,bt.act=H,bt.cloneElement=function(z,F,K){if(z==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+z+".");var ne=b({},z.props),re=z.key,Y=z.ref,de=z._owner;if(F!=null){if(F.ref!==void 0&&(Y=F.ref,de=U.current),F.key!==void 0&&(re=""+F.key),z.type&&z.type.defaultProps)var oe=z.type.defaultProps;for(pe in F)W.call(F,pe)&&!Q.hasOwnProperty(pe)&&(ne[pe]=F[pe]===void 0&&oe!==void 0?oe[pe]:F[pe])}var pe=arguments.length-2;if(pe===1)ne.children=K;else if(1<pe){oe=Array(pe);for(var xe=0;xe<pe;xe++)oe[xe]=arguments[xe+2];ne.children=oe}return{$$typeof:t,type:z.type,key:re,ref:Y,props:ne,_owner:de}},bt.createContext=function(z){return z={$$typeof:l,_currentValue:z,_currentValue2:z,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},z.Provider={$$typeof:a,_context:z},z.Consumer=z},bt.createElement=ee,bt.createFactory=function(z){var F=ee.bind(null,z);return F.type=z,F},bt.createRef=function(){return{current:null}},bt.forwardRef=function(z){return{$$typeof:d,render:z}},bt.isValidElement=J,bt.lazy=function(z){return{$$typeof:g,_payload:{_status:-1,_result:z},_init:P}},bt.memo=function(z,F){return{$$typeof:f,type:z,compare:F===void 0?null:F}},bt.startTransition=function(z){var F=R.transition;R.transition={};try{z()}finally{R.transition=F}},bt.unstable_act=H,bt.useCallback=function(z,F){return A.current.useCallback(z,F)},bt.useContext=function(z){return A.current.useContext(z)},bt.useDebugValue=function(){},bt.useDeferredValue=function(z){return A.current.useDeferredValue(z)},bt.useEffect=function(z,F){return A.current.useEffect(z,F)},bt.useId=function(){return A.current.useId()},bt.useImperativeHandle=function(z,F,K){return A.current.useImperativeHandle(z,F,K)},bt.useInsertionEffect=function(z,F){return A.current.useInsertionEffect(z,F)},bt.useLayoutEffect=function(z,F){return A.current.useLayoutEffect(z,F)},bt.useMemo=function(z,F){return A.current.useMemo(z,F)},bt.useReducer=function(z,F,K){return A.current.useReducer(z,F,K)},bt.useRef=function(z){return A.current.useRef(z)},bt.useState=function(z){return A.current.useState(z)},bt.useSyncExternalStore=function(z,F,K){return A.current.useSyncExternalStore(z,F,K)},bt.useTransition=function(){return A.current.useTransition()},bt.version="18.3.1",bt}var L_;function lm(){return L_||(L_=1,jh.exports=qC()),jh.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 R_;function KC(){if(R_)return Xa;R_=1;var t=lm(),e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,s=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function l(d,h,f){var g,y={},_=null,w=null;f!==void 0&&(_=""+f),h.key!==void 0&&(_=""+h.key),h.ref!==void 0&&(w=h.ref);for(g in h)i.call(h,g)&&!a.hasOwnProperty(g)&&(y[g]=h[g]);if(d&&d.defaultProps)for(g in h=d.defaultProps,h)y[g]===void 0&&(y[g]=h[g]);return{$$typeof:e,type:d,key:_,ref:w,props:y,_owner:s.current}}return Xa.Fragment=n,Xa.jsx=l,Xa.jsxs=l,Xa}var M_;function VC(){return M_||(M_=1,Ah.exports=KC()),Ah.exports}var c=VC(),k=lm();const YC=am(k);var Hc={},Ph={exports:{}},wi={},Th={exports:{}},Dh={};/**
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 A_;function GC(){return A_||(A_=1,(function(t){function e(R,D){var H=R.length;R.push(D);e:for(;0<H;){var z=H-1>>>1,F=R[z];if(0<s(F,D))R[z]=D,R[H]=F,H=z;else break e}}function n(R){return R.length===0?null:R[0]}function i(R){if(R.length===0)return null;var D=R[0],H=R.pop();if(H!==D){R[0]=H;e:for(var z=0,F=R.length,K=F>>>1;z<K;){var ne=2*(z+1)-1,re=R[ne],Y=ne+1,de=R[Y];if(0>s(re,H))Y<F&&0>s(de,re)?(R[z]=de,R[Y]=H,z=Y):(R[z]=re,R[ne]=H,z=ne);else if(Y<F&&0>s(de,H))R[z]=de,R[Y]=H,z=Y;else break e}}return D}function s(R,D){var H=R.sortIndex-D.sortIndex;return H!==0?H:R.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var l=Date,d=l.now();t.unstable_now=function(){return l.now()-d}}var h=[],f=[],g=1,y=null,_=3,w=!1,b=!1,N=!1,x=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function I(R){for(var D=n(f);D!==null;){if(D.callback===null)i(f);else if(D.startTime<=R)i(f),D.sortIndex=D.expirationTime,e(h,D);else break;D=n(f)}}function T(R){if(N=!1,I(R),!b)if(n(h)!==null)b=!0,P(W);else{var D=n(f);D!==null&&A(T,D.startTime-R)}}function W(R,D){b=!1,N&&(N=!1,E(ee),ee=-1),w=!0;var H=_;try{for(I(D),y=n(h);y!==null&&(!(y.expirationTime>D)||R&&!$());){var z=y.callback;if(typeof z=="function"){y.callback=null,_=y.priorityLevel;var F=z(y.expirationTime<=D);D=t.unstable_now(),typeof F=="function"?y.callback=F:y===n(h)&&i(h),I(D)}else i(h);y=n(h)}if(y!==null)var K=!0;else{var ne=n(f);ne!==null&&A(T,ne.startTime-D),K=!1}return K}finally{y=null,_=H,w=!1}}var U=!1,Q=null,ee=-1,q=5,J=-1;function $(){return!(t.unstable_now()-J<q)}function M(){if(Q!==null){var R=t.unstable_now();J=R;var D=!0;try{D=Q(!0,R)}finally{D?L():(U=!1,Q=null)}}else U=!1}var L;if(typeof C=="function")L=function(){C(M)};else if(typeof MessageChannel<"u"){var j=new MessageChannel,O=j.port2;j.port1.onmessage=M,L=function(){O.postMessage(null)}}else L=function(){x(M,0)};function P(R){Q=R,U||(U=!0,L())}function A(R,D){ee=x(function(){R(t.unstable_now())},D)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(R){R.callback=null},t.unstable_continueExecution=function(){b||w||(b=!0,P(W))},t.unstable_forceFrameRate=function(R){0>R||125<R?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):q=0<R?Math.floor(1e3/R):5},t.unstable_getCurrentPriorityLevel=function(){return _},t.unstable_getFirstCallbackNode=function(){return n(h)},t.unstable_next=function(R){switch(_){case 1:case 2:case 3:var D=3;break;default:D=_}var H=_;_=D;try{return R()}finally{_=H}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(R,D){switch(R){case 1:case 2:case 3:case 4:case 5:break;default:R=3}var H=_;_=R;try{return D()}finally{_=H}},t.unstable_scheduleCallback=function(R,D,H){var z=t.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?z+H:z):H=z,R){case 1:var F=-1;break;case 2:F=250;break;case 5:F=1073741823;break;case 4:F=1e4;break;default:F=5e3}return F=H+F,R={id:g++,callback:D,priorityLevel:R,startTime:H,expirationTime:F,sortIndex:-1},H>z?(R.sortIndex=H,e(f,R),n(h)===null&&R===n(f)&&(N?(E(ee),ee=-1):N=!0,A(T,H-z))):(R.sortIndex=F,e(h,R),b||w||(b=!0,P(W))),R},t.unstable_shouldYield=$,t.unstable_wrapCallback=function(R){var D=_;return function(){var H=_;_=D;try{return R.apply(this,arguments)}finally{_=H}}}})(Dh)),Dh}var j_;function XC(){return j_||(j_=1,Th.exports=GC()),Th.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 P_;function QC(){if(P_)return wi;P_=1;var t=lm(),e=XC();function n(r){for(var o="https://reactjs.org/docs/error-decoder.html?invariant="+r,u=1;u<arguments.length;u++)o+="&args[]="+encodeURIComponent(arguments[u]);return"Minified React error #"+r+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var i=new Set,s={};function a(r,o){l(r,o),l(r+"Capture",o)}function l(r,o){for(s[r]=o,r=0;r<o.length;r++)i.add(o[r])}var d=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),h=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,g={},y={};function _(r){return h.call(y,r)?!0:h.call(g,r)?!1:f.test(r)?y[r]=!0:(g[r]=!0,!1)}function w(r,o,u,p){if(u!==null&&u.type===0)return!1;switch(typeof o){case"function":case"symbol":return!0;case"boolean":return p?!1:u!==null?!u.acceptsBooleans:(r=r.toLowerCase().slice(0,5),r!=="data-"&&r!=="aria-");default:return!1}}function b(r,o,u,p){if(o===null||typeof o>"u"||w(r,o,u,p))return!0;if(p)return!1;if(u!==null)switch(u.type){case 3:return!o;case 4:return o===!1;case 5:return isNaN(o);case 6:return isNaN(o)||1>o}return!1}function N(r,o,u,p,v,S,B){this.acceptsBooleans=o===2||o===3||o===4,this.attributeName=p,this.attributeNamespace=v,this.mustUseProperty=u,this.propertyName=r,this.type=o,this.sanitizeURL=S,this.removeEmptyString=B}var x={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){x[r]=new N(r,0,!1,r,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(r){var o=r[0];x[o]=new N(o,1,!1,r[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(r){x[r]=new N(r,2,!1,r.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){x[r]=new N(r,2,!1,r,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(r){x[r]=new N(r,3,!1,r.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(r){x[r]=new N(r,3,!0,r,null,!1,!1)}),["capture","download"].forEach(function(r){x[r]=new N(r,4,!1,r,null,!1,!1)}),["cols","rows","size","span"].forEach(function(r){x[r]=new N(r,6,!1,r,null,!1,!1)}),["rowSpan","start"].forEach(function(r){x[r]=new N(r,5,!1,r.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function C(r){return r[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(r){var o=r.replace(E,C);x[o]=new N(o,1,!1,r,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(r){var o=r.replace(E,C);x[o]=new N(o,1,!1,r,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(r){var o=r.replace(E,C);x[o]=new N(o,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(r){x[r]=new N(r,1,!1,r.toLowerCase(),null,!1,!1)}),x.xlinkHref=new N("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(r){x[r]=new N(r,1,!1,r.toLowerCase(),null,!0,!0)});function I(r,o,u,p){var v=x.hasOwnProperty(o)?x[o]:null;(v!==null?v.type!==0:p||!(2<o.length)||o[0]!=="o"&&o[0]!=="O"||o[1]!=="n"&&o[1]!=="N")&&(b(o,u,v,p)&&(u=null),p||v===null?_(o)&&(u===null?r.removeAttribute(o):r.setAttribute(o,""+u)):v.mustUseProperty?r[v.propertyName]=u===null?v.type===3?!1:"":u:(o=v.attributeName,p=v.attributeNamespace,u===null?r.removeAttribute(o):(v=v.type,u=v===3||v===4&&u===!0?"":""+u,p?r.setAttributeNS(p,o,u):r.setAttribute(o,u))))}var T=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,W=Symbol.for("react.element"),U=Symbol.for("react.portal"),Q=Symbol.for("react.fragment"),ee=Symbol.for("react.strict_mode"),q=Symbol.for("react.profiler"),J=Symbol.for("react.provider"),$=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),L=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),A=Symbol.for("react.offscreen"),R=Symbol.iterator;function D(r){return r===null||typeof r!="object"?null:(r=R&&r[R]||r["@@iterator"],typeof r=="function"?r:null)}var H=Object.assign,z;function F(r){if(z===void 0)try{throw Error()}catch(u){var o=u.stack.trim().match(/\n( *(at )?)/);z=o&&o[1]||""}return`
34
- `+z+r}var K=!1;function ne(r,o){if(!r||K)return"";K=!0;var u=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(o)if(o=function(){throw Error()},Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(o,[])}catch(fe){var p=fe}Reflect.construct(r,[],o)}else{try{o.call()}catch(fe){p=fe}r.call(o.prototype)}else{try{throw Error()}catch(fe){p=fe}r()}}catch(fe){if(fe&&p&&typeof fe.stack=="string"){for(var v=fe.stack.split(`
35
- `),S=p.stack.split(`
36
- `),B=v.length-1,G=S.length-1;1<=B&&0<=G&&v[B]!==S[G];)G--;for(;1<=B&&0<=G;B--,G--)if(v[B]!==S[G]){if(B!==1||G!==1)do if(B--,G--,0>G||v[B]!==S[G]){var te=`
37
- `+v[B].replace(" at new "," at ");return r.displayName&&te.includes("<anonymous>")&&(te=te.replace("<anonymous>",r.displayName)),te}while(1<=B&&0<=G);break}}}finally{K=!1,Error.prepareStackTrace=u}return(r=r?r.displayName||r.name:"")?F(r):""}function re(r){switch(r.tag){case 5:return F(r.type);case 16:return F("Lazy");case 13:return F("Suspense");case 19:return F("SuspenseList");case 0:case 2:case 15:return r=ne(r.type,!1),r;case 11:return r=ne(r.type.render,!1),r;case 1:return r=ne(r.type,!0),r;default:return""}}function Y(r){if(r==null)return null;if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case Q:return"Fragment";case U:return"Portal";case q:return"Profiler";case ee:return"StrictMode";case L:return"Suspense";case j:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case $:return(r.displayName||"Context")+".Consumer";case J:return(r._context.displayName||"Context")+".Provider";case M:var o=r.render;return r=r.displayName,r||(r=o.displayName||o.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case O:return o=r.displayName||null,o!==null?o:Y(r.type)||"Memo";case P:o=r._payload,r=r._init;try{return Y(r(o))}catch{}}return null}function de(r){var o=r.type;switch(r.tag){case 24:return"Cache";case 9:return(o.displayName||"Context")+".Consumer";case 10:return(o._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return r=o.render,r=r.displayName||r.name||"",o.displayName||(r!==""?"ForwardRef("+r+")":"ForwardRef");case 7:return"Fragment";case 5:return o;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Y(o);case 8:return o===ee?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof o=="function")return o.displayName||o.name||null;if(typeof o=="string")return o}return null}function oe(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function pe(r){var o=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(o==="checkbox"||o==="radio")}function xe(r){var o=pe(r)?"checked":"value",u=Object.getOwnPropertyDescriptor(r.constructor.prototype,o),p=""+r[o];if(!r.hasOwnProperty(o)&&typeof u<"u"&&typeof u.get=="function"&&typeof u.set=="function"){var v=u.get,S=u.set;return Object.defineProperty(r,o,{configurable:!0,get:function(){return v.call(this)},set:function(B){p=""+B,S.call(this,B)}}),Object.defineProperty(r,o,{enumerable:u.enumerable}),{getValue:function(){return p},setValue:function(B){p=""+B},stopTracking:function(){r._valueTracker=null,delete r[o]}}}}function Qe(r){r._valueTracker||(r._valueTracker=xe(r))}function ot(r){if(!r)return!1;var o=r._valueTracker;if(!o)return!0;var u=o.getValue(),p="";return r&&(p=pe(r)?r.checked?"true":"false":r.value),r=p,r!==u?(o.setValue(r),!0):!1}function De(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function je(r,o){var u=o.checked;return H({},o,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:u??r._wrapperState.initialChecked})}function tt(r,o){var u=o.defaultValue==null?"":o.defaultValue,p=o.checked!=null?o.checked:o.defaultChecked;u=oe(o.value!=null?o.value:u),r._wrapperState={initialChecked:p,initialValue:u,controlled:o.type==="checkbox"||o.type==="radio"?o.checked!=null:o.value!=null}}function Nt(r,o){o=o.checked,o!=null&&I(r,"checked",o,!1)}function Ct(r,o){Nt(r,o);var u=oe(o.value),p=o.type;if(u!=null)p==="number"?(u===0&&r.value===""||r.value!=u)&&(r.value=""+u):r.value!==""+u&&(r.value=""+u);else if(p==="submit"||p==="reset"){r.removeAttribute("value");return}o.hasOwnProperty("value")?ht(r,o.type,u):o.hasOwnProperty("defaultValue")&&ht(r,o.type,oe(o.defaultValue)),o.checked==null&&o.defaultChecked!=null&&(r.defaultChecked=!!o.defaultChecked)}function ft(r,o,u){if(o.hasOwnProperty("value")||o.hasOwnProperty("defaultValue")){var p=o.type;if(!(p!=="submit"&&p!=="reset"||o.value!==void 0&&o.value!==null))return;o=""+r._wrapperState.initialValue,u||o===r.value||(r.value=o),r.defaultValue=o}u=r.name,u!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,u!==""&&(r.name=u)}function ht(r,o,u){(o!=="number"||De(r.ownerDocument)!==r)&&(u==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+u&&(r.defaultValue=""+u))}var kt=Array.isArray;function St(r,o,u,p){if(r=r.options,o){o={};for(var v=0;v<u.length;v++)o["$"+u[v]]=!0;for(u=0;u<r.length;u++)v=o.hasOwnProperty("$"+r[u].value),r[u].selected!==v&&(r[u].selected=v),v&&p&&(r[u].defaultSelected=!0)}else{for(u=""+oe(u),o=null,v=0;v<r.length;v++){if(r[v].value===u){r[v].selected=!0,p&&(r[v].defaultSelected=!0);return}o!==null||r[v].disabled||(o=r[v])}o!==null&&(o.selected=!0)}}function Ut(r,o){if(o.dangerouslySetInnerHTML!=null)throw Error(n(91));return H({},o,{value:void 0,defaultValue:void 0,children:""+r._wrapperState.initialValue})}function Mt(r,o){var u=o.value;if(u==null){if(u=o.children,o=o.defaultValue,u!=null){if(o!=null)throw Error(n(92));if(kt(u)){if(1<u.length)throw Error(n(93));u=u[0]}o=u}o==null&&(o=""),u=o}r._wrapperState={initialValue:oe(u)}}function It(r,o){var u=oe(o.value),p=oe(o.defaultValue);u!=null&&(u=""+u,u!==r.value&&(r.value=u),o.defaultValue==null&&r.defaultValue!==u&&(r.defaultValue=u)),p!=null&&(r.defaultValue=""+p)}function tn(r){var o=r.textContent;o===r._wrapperState.initialValue&&o!==""&&o!==null&&(r.value=o)}function Ft(r){switch(r){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function ln(r,o){return r==null||r==="http://www.w3.org/1999/xhtml"?Ft(o):r==="http://www.w3.org/2000/svg"&&o==="foreignObject"?"http://www.w3.org/1999/xhtml":r}var V,Te=(function(r){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(o,u,p,v){MSApp.execUnsafeLocalFunction(function(){return r(o,u,p,v)})}:r})(function(r,o){if(r.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in r)r.innerHTML=o;else{for(V=V||document.createElement("div"),V.innerHTML="<svg>"+o.valueOf().toString()+"</svg>",o=V.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;o.firstChild;)r.appendChild(o.firstChild)}});function gt(r,o){if(o){var u=r.firstChild;if(u&&u===r.lastChild&&u.nodeType===3){u.nodeValue=o;return}}r.textContent=o}var le={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},ae=["Webkit","ms","Moz","O"];Object.keys(le).forEach(function(r){ae.forEach(function(o){o=o+r.charAt(0).toUpperCase()+r.substring(1),le[o]=le[r]})});function ge(r,o,u){return o==null||typeof o=="boolean"||o===""?"":u||typeof o!="number"||o===0||le.hasOwnProperty(r)&&le[r]?(""+o).trim():o+"px"}function Ce(r,o){r=r.style;for(var u in o)if(o.hasOwnProperty(u)){var p=u.indexOf("--")===0,v=ge(u,o[u],p);u==="float"&&(u="cssFloat"),p?r.setProperty(u,v):r[u]=v}}var Me=H({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 nt(r,o){if(o){if(Me[r]&&(o.children!=null||o.dangerouslySetInnerHTML!=null))throw Error(n(137,r));if(o.dangerouslySetInnerHTML!=null){if(o.children!=null)throw Error(n(60));if(typeof o.dangerouslySetInnerHTML!="object"||!("__html"in o.dangerouslySetInnerHTML))throw Error(n(61))}if(o.style!=null&&typeof o.style!="object")throw Error(n(62))}}function ct(r,o){if(r.indexOf("-")===-1)return typeof o.is=="string";switch(r){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var pt=null;function Lt(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var Dt=null,Et=null,Bt=null;function Z(r){if(r=Da(r)){if(typeof Dt!="function")throw Error(n(280));var o=r.stateNode;o&&(o=ic(o),Dt(r.stateNode,r.type,o))}}function ye(r){Et?Bt?Bt.push(r):Bt=[r]:Et=r}function Ue(){if(Et){var r=Et,o=Bt;if(Bt=Et=null,Z(r),o)for(r=0;r<o.length;r++)Z(o[r])}}function We(r,o){return r(o)}function Ge(){}var jt=!1;function Pt(r,o,u){if(jt)return r(o,u);jt=!0;try{return We(r,o,u)}finally{jt=!1,(Et!==null||Bt!==null)&&(Ge(),Ue())}}function X(r,o){var u=r.stateNode;if(u===null)return null;var p=ic(u);if(p===null)return null;u=p[o];e:switch(o){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(p=!p.disabled)||(r=r.type,p=!(r==="button"||r==="input"||r==="select"||r==="textarea")),r=!p;break e;default:r=!1}if(r)return null;if(u&&typeof u!="function")throw Error(n(231,o,typeof u));return u}var ie=!1;if(d)try{var _e={};Object.defineProperty(_e,"passive",{get:function(){ie=!0}}),window.addEventListener("test",_e,_e),window.removeEventListener("test",_e,_e)}catch{ie=!1}function Ke(r,o,u,p,v,S,B,G,te){var fe=Array.prototype.slice.call(arguments,3);try{o.apply(u,fe)}catch(be){this.onError(be)}}var Ie=!1,Ee=null,et=!1,Ot=null,gn={onError:function(r){Ie=!0,Ee=r}};function Fe(r,o,u,p,v,S,B,G,te){Ie=!1,Ee=null,Ke.apply(gn,arguments)}function Be(r,o,u,p,v,S,B,G,te){if(Fe.apply(this,arguments),Ie){if(Ie){var fe=Ee;Ie=!1,Ee=null}else throw Error(n(198));et||(et=!0,Ot=fe)}}function vt(r){var o=r,u=r;if(r.alternate)for(;o.return;)o=o.return;else{r=o;do o=r,(o.flags&4098)!==0&&(u=o.return),r=o.return;while(r)}return o.tag===3?u:null}function Mn(r){if(r.tag===13){var o=r.memoizedState;if(o===null&&(r=r.alternate,r!==null&&(o=r.memoizedState)),o!==null)return o.dehydrated}return null}function me(r){if(vt(r)!==r)throw Error(n(188))}function Se(r){var o=r.alternate;if(!o){if(o=vt(r),o===null)throw Error(n(188));return o!==r?null:r}for(var u=r,p=o;;){var v=u.return;if(v===null)break;var S=v.alternate;if(S===null){if(p=v.return,p!==null){u=p;continue}break}if(v.child===S.child){for(S=v.child;S;){if(S===u)return me(v),r;if(S===p)return me(v),o;S=S.sibling}throw Error(n(188))}if(u.return!==p.return)u=v,p=S;else{for(var B=!1,G=v.child;G;){if(G===u){B=!0,u=v,p=S;break}if(G===p){B=!0,p=v,u=S;break}G=G.sibling}if(!B){for(G=S.child;G;){if(G===u){B=!0,u=S,p=v;break}if(G===p){B=!0,p=S,u=v;break}G=G.sibling}if(!B)throw Error(n(189))}}if(u.alternate!==p)throw Error(n(190))}if(u.tag!==3)throw Error(n(188));return u.stateNode.current===u?r:o}function Ae(r){return r=Se(r),r!==null?it(r):null}function it(r){if(r.tag===5||r.tag===6)return r;for(r=r.child;r!==null;){var o=it(r);if(o!==null)return o;r=r.sibling}return null}var st=e.unstable_scheduleCallback,wt=e.unstable_cancelCallback,cn=e.unstable_shouldYield,$t=e.unstable_requestPaint,Wt=e.unstable_now,Xs=e.unstable_getCurrentPriorityLevel,Di=e.unstable_ImmediatePriority,Gi=e.unstable_UserBlockingPriority,go=e.unstable_NormalPriority,id=e.unstable_LowPriority,jr=e.unstable_IdlePriority,Pr=null,xi=null;function va(r){if(xi&&typeof xi.onCommitFiberRoot=="function")try{xi.onCommitFiberRoot(Pr,r,void 0,(r.current.flags&128)===128)}catch{}}var di=Math.clz32?Math.clz32:Hl,zl=Math.log,Fl=Math.LN2;function Hl(r){return r>>>=0,r===0?32:31-(zl(r)/Fl|0)|0}var Tr=64,Dr=4194304;function Gn(r){switch(r&-r){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function Ir(r,o){var u=r.pendingLanes;if(u===0)return 0;var p=0,v=r.suspendedLanes,S=r.pingedLanes,B=u&268435455;if(B!==0){var G=B&~v;G!==0?p=Gn(G):(S&=B,S!==0&&(p=Gn(S)))}else B=u&~v,B!==0?p=Gn(B):S!==0&&(p=Gn(S));if(p===0)return 0;if(o!==0&&o!==p&&(o&v)===0&&(v=p&-p,S=o&-o,v>=S||v===16&&(S&4194240)!==0))return o;if((p&4)!==0&&(p|=u&16),o=r.entangledLanes,o!==0)for(r=r.entanglements,o&=p;0<o;)u=31-di(o),v=1<<u,p|=r[u],o&=~v;return p}function Ul(r,o){switch(r){case 1:case 2:case 4:return o+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return o+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Wl(r,o){for(var u=r.suspendedLanes,p=r.pingedLanes,v=r.expirationTimes,S=r.pendingLanes;0<S;){var B=31-di(S),G=1<<B,te=v[B];te===-1?((G&u)===0||(G&p)!==0)&&(v[B]=Ul(G,o)):te<=o&&(r.expiredLanes|=G),S&=~G}}function Qs(r){return r=r.pendingLanes&-1073741825,r!==0?r:r&1073741824?1073741824:0}function os(){var r=Tr;return Tr<<=1,(Tr&4194240)===0&&(Tr=64),r}function Js(r){for(var o=[],u=0;31>u;u++)o.push(r);return o}function Zs(r,o,u){r.pendingLanes|=o,o!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,o=31-di(o),r[o]=u}function _a(r,o){var u=r.pendingLanes&~o;r.pendingLanes=o,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=o,r.mutableReadLanes&=o,r.entangledLanes&=o,o=r.entanglements;var p=r.eventTimes;for(r=r.expirationTimes;0<u;){var v=31-di(u),S=1<<v;o[v]=0,p[v]=-1,r[v]=-1,u&=~S}}function vo(r,o){var u=r.entangledLanes|=o;for(r=r.entanglements;u;){var p=31-di(u),v=1<<p;v&o|r[p]&o&&(r[p]|=o),u&=~v}}var xt=0;function ya(r){return r&=-r,1<r?4<r?(r&268435455)!==0?16:536870912:4:1}var Ls,hi,_o,wa,Xn,yo=!1,Rs=[],fi=null,Ci=null,Xi=null,as=new Map,er=new Map,ki=[],ql="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 ba(r,o){switch(r){case"focusin":case"focusout":fi=null;break;case"dragenter":case"dragleave":Ci=null;break;case"mouseover":case"mouseout":Xi=null;break;case"pointerover":case"pointerout":as.delete(o.pointerId);break;case"gotpointercapture":case"lostpointercapture":er.delete(o.pointerId)}}function ce(r,o,u,p,v,S){return r===null||r.nativeEvent!==S?(r={blockedOn:o,domEventName:u,eventSystemFlags:p,nativeEvent:S,targetContainers:[v]},o!==null&&(o=Da(o),o!==null&&hi(o)),r):(r.eventSystemFlags|=p,o=r.targetContainers,v!==null&&o.indexOf(v)===-1&&o.push(v),r)}function Pe(r,o,u,p,v){switch(o){case"focusin":return fi=ce(fi,r,o,u,p,v),!0;case"dragenter":return Ci=ce(Ci,r,o,u,p,v),!0;case"mouseover":return Xi=ce(Xi,r,o,u,p,v),!0;case"pointerover":var S=v.pointerId;return as.set(S,ce(as.get(S)||null,r,o,u,p,v)),!0;case"gotpointercapture":return S=v.pointerId,er.set(S,ce(er.get(S)||null,r,o,u,p,v)),!0}return!1}function Re(r){var o=Br(r.target);if(o!==null){var u=vt(o);if(u!==null){if(o=u.tag,o===13){if(o=Mn(u),o!==null){r.blockedOn=o,Xn(r.priority,function(){_o(u)});return}}else if(o===3&&u.stateNode.current.memoizedState.isDehydrated){r.blockedOn=u.tag===3?u.stateNode.containerInfo:null;return}}}r.blockedOn=null}function $e(r){if(r.blockedOn!==null)return!1;for(var o=r.targetContainers;0<o.length;){var u=sd(r.domEventName,r.eventSystemFlags,o[0],r.nativeEvent);if(u===null){u=r.nativeEvent;var p=new u.constructor(u.type,u);pt=p,u.target.dispatchEvent(p),pt=null}else return o=Da(u),o!==null&&hi(o),r.blockedOn=u,!1;o.shift()}return!0}function rt(r,o,u){$e(r)&&u.delete(o)}function ut(){yo=!1,fi!==null&&$e(fi)&&(fi=null),Ci!==null&&$e(Ci)&&(Ci=null),Xi!==null&&$e(Xi)&&(Xi=null),as.forEach(rt),er.forEach(rt)}function Rt(r,o){r.blockedOn===o&&(r.blockedOn=null,yo||(yo=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,ut)))}function Ht(r){function o(v){return Rt(v,r)}if(0<Rs.length){Rt(Rs[0],r);for(var u=1;u<Rs.length;u++){var p=Rs[u];p.blockedOn===r&&(p.blockedOn=null)}}for(fi!==null&&Rt(fi,r),Ci!==null&&Rt(Ci,r),Xi!==null&&Rt(Xi,r),as.forEach(o),er.forEach(o),u=0;u<ki.length;u++)p=ki[u],p.blockedOn===r&&(p.blockedOn=null);for(;0<ki.length&&(u=ki[0],u.blockedOn===null);)Re(u),u.blockedOn===null&&ki.shift()}var vn=T.ReactCurrentBatchConfig,Jt=!0;function pi(r,o,u,p){var v=xt,S=vn.transition;vn.transition=null;try{xt=1,Sa(r,o,u,p)}finally{xt=v,vn.transition=S}}function ls(r,o,u,p){var v=xt,S=vn.transition;vn.transition=null;try{xt=4,Sa(r,o,u,p)}finally{xt=v,vn.transition=S}}function Sa(r,o,u,p){if(Jt){var v=sd(r,o,u,p);if(v===null)bd(r,o,p,xa,u),ba(r,p);else if(Pe(v,r,o,u,p))p.stopPropagation();else if(ba(r,p),o&4&&-1<ql.indexOf(r)){for(;v!==null;){var S=Da(v);if(S!==null&&Ls(S),S=sd(r,o,u,p),S===null&&bd(r,o,p,xa,u),S===v)break;v=S}v!==null&&p.stopPropagation()}else bd(r,o,p,null,u)}}var xa=null;function sd(r,o,u,p){if(xa=null,r=Lt(p),r=Br(r),r!==null)if(o=vt(r),o===null)r=null;else if(u=o.tag,u===13){if(r=Mn(o),r!==null)return r;r=null}else if(u===3){if(o.stateNode.current.memoizedState.isDehydrated)return o.tag===3?o.stateNode.containerInfo:null;r=null}else o!==r&&(r=null);return xa=r,null}function fg(r){switch(r){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Xs()){case Di:return 1;case Gi:return 4;case go:case id:return 16;case jr:return 536870912;default:return 16}default:return 16}}var tr=null,rd=null,Kl=null;function pg(){if(Kl)return Kl;var r,o=rd,u=o.length,p,v="value"in tr?tr.value:tr.textContent,S=v.length;for(r=0;r<u&&o[r]===v[r];r++);var B=u-r;for(p=1;p<=B&&o[u-p]===v[S-p];p++);return Kl=v.slice(r,1<p?1-p:void 0)}function Vl(r){var o=r.keyCode;return"charCode"in r?(r=r.charCode,r===0&&o===13&&(r=13)):r=o,r===10&&(r=13),32<=r||r===13?r:0}function Yl(){return!0}function mg(){return!1}function Ei(r){function o(u,p,v,S,B){this._reactName=u,this._targetInst=v,this.type=p,this.nativeEvent=S,this.target=B,this.currentTarget=null;for(var G in r)r.hasOwnProperty(G)&&(u=r[G],this[G]=u?u(S):S[G]);return this.isDefaultPrevented=(S.defaultPrevented!=null?S.defaultPrevented:S.returnValue===!1)?Yl:mg,this.isPropagationStopped=mg,this}return H(o.prototype,{preventDefault:function(){this.defaultPrevented=!0;var u=this.nativeEvent;u&&(u.preventDefault?u.preventDefault():typeof u.returnValue!="unknown"&&(u.returnValue=!1),this.isDefaultPrevented=Yl)},stopPropagation:function(){var u=this.nativeEvent;u&&(u.stopPropagation?u.stopPropagation():typeof u.cancelBubble!="unknown"&&(u.cancelBubble=!0),this.isPropagationStopped=Yl)},persist:function(){},isPersistent:Yl}),o}var wo={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},od=Ei(wo),Ca=H({},wo,{view:0,detail:0}),_x=Ei(Ca),ad,ld,ka,Gl=H({},Ca,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ud,button:0,buttons:0,relatedTarget:function(r){return r.relatedTarget===void 0?r.fromElement===r.srcElement?r.toElement:r.fromElement:r.relatedTarget},movementX:function(r){return"movementX"in r?r.movementX:(r!==ka&&(ka&&r.type==="mousemove"?(ad=r.screenX-ka.screenX,ld=r.screenY-ka.screenY):ld=ad=0,ka=r),ad)},movementY:function(r){return"movementY"in r?r.movementY:ld}}),gg=Ei(Gl),yx=H({},Gl,{dataTransfer:0}),wx=Ei(yx),bx=H({},Ca,{relatedTarget:0}),cd=Ei(bx),Sx=H({},wo,{animationName:0,elapsedTime:0,pseudoElement:0}),xx=Ei(Sx),Cx=H({},wo,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),kx=Ei(Cx),Ex=H({},wo,{data:0}),vg=Ei(Ex),Nx={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Lx={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"},Rx={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Mx(r){var o=this.nativeEvent;return o.getModifierState?o.getModifierState(r):(r=Rx[r])?!!o[r]:!1}function ud(){return Mx}var Ax=H({},Ca,{key:function(r){if(r.key){var o=Nx[r.key]||r.key;if(o!=="Unidentified")return o}return r.type==="keypress"?(r=Vl(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?Lx[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ud,charCode:function(r){return r.type==="keypress"?Vl(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?Vl(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),jx=Ei(Ax),Px=H({},Gl,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),_g=Ei(Px),Tx=H({},Ca,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ud}),Dx=Ei(Tx),Ix=H({},wo,{propertyName:0,elapsedTime:0,pseudoElement:0}),Bx=Ei(Ix),Ox=H({},Gl,{deltaX:function(r){return"deltaX"in r?r.deltaX:"wheelDeltaX"in r?-r.wheelDeltaX:0},deltaY:function(r){return"deltaY"in r?r.deltaY:"wheelDeltaY"in r?-r.wheelDeltaY:"wheelDelta"in r?-r.wheelDelta:0},deltaZ:0,deltaMode:0}),$x=Ei(Ox),zx=[9,13,27,32],dd=d&&"CompositionEvent"in window,Ea=null;d&&"documentMode"in document&&(Ea=document.documentMode);var Fx=d&&"TextEvent"in window&&!Ea,yg=d&&(!dd||Ea&&8<Ea&&11>=Ea),wg=" ",bg=!1;function Sg(r,o){switch(r){case"keyup":return zx.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function xg(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var bo=!1;function Hx(r,o){switch(r){case"compositionend":return xg(o);case"keypress":return o.which!==32?null:(bg=!0,wg);case"textInput":return r=o.data,r===wg&&bg?null:r;default:return null}}function Ux(r,o){if(bo)return r==="compositionend"||!dd&&Sg(r,o)?(r=pg(),Kl=rd=tr=null,bo=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(o.ctrlKey||o.altKey||o.metaKey)||o.ctrlKey&&o.altKey){if(o.char&&1<o.char.length)return o.char;if(o.which)return String.fromCharCode(o.which)}return null;case"compositionend":return yg&&o.locale!=="ko"?null:o.data;default:return null}}var Wx={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 Cg(r){var o=r&&r.nodeName&&r.nodeName.toLowerCase();return o==="input"?!!Wx[r.type]:o==="textarea"}function kg(r,o,u,p){ye(p),o=ec(o,"onChange"),0<o.length&&(u=new od("onChange","change",null,u,p),r.push({event:u,listeners:o}))}var Na=null,La=null;function qx(r){Ug(r,0)}function Xl(r){var o=Eo(r);if(ot(o))return r}function Kx(r,o){if(r==="change")return o}var Eg=!1;if(d){var hd;if(d){var fd="oninput"in document;if(!fd){var Ng=document.createElement("div");Ng.setAttribute("oninput","return;"),fd=typeof Ng.oninput=="function"}hd=fd}else hd=!1;Eg=hd&&(!document.documentMode||9<document.documentMode)}function Lg(){Na&&(Na.detachEvent("onpropertychange",Rg),La=Na=null)}function Rg(r){if(r.propertyName==="value"&&Xl(La)){var o=[];kg(o,La,r,Lt(r)),Pt(qx,o)}}function Vx(r,o,u){r==="focusin"?(Lg(),Na=o,La=u,Na.attachEvent("onpropertychange",Rg)):r==="focusout"&&Lg()}function Yx(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return Xl(La)}function Gx(r,o){if(r==="click")return Xl(o)}function Xx(r,o){if(r==="input"||r==="change")return Xl(o)}function Qx(r,o){return r===o&&(r!==0||1/r===1/o)||r!==r&&o!==o}var Qi=typeof Object.is=="function"?Object.is:Qx;function Ra(r,o){if(Qi(r,o))return!0;if(typeof r!="object"||r===null||typeof o!="object"||o===null)return!1;var u=Object.keys(r),p=Object.keys(o);if(u.length!==p.length)return!1;for(p=0;p<u.length;p++){var v=u[p];if(!h.call(o,v)||!Qi(r[v],o[v]))return!1}return!0}function Mg(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function Ag(r,o){var u=Mg(r);r=0;for(var p;u;){if(u.nodeType===3){if(p=r+u.textContent.length,r<=o&&p>=o)return{node:u,offset:o-r};r=p}e:{for(;u;){if(u.nextSibling){u=u.nextSibling;break e}u=u.parentNode}u=void 0}u=Mg(u)}}function jg(r,o){return r&&o?r===o?!0:r&&r.nodeType===3?!1:o&&o.nodeType===3?jg(r,o.parentNode):"contains"in r?r.contains(o):r.compareDocumentPosition?!!(r.compareDocumentPosition(o)&16):!1:!1}function Pg(){for(var r=window,o=De();o instanceof r.HTMLIFrameElement;){try{var u=typeof o.contentWindow.location.href=="string"}catch{u=!1}if(u)r=o.contentWindow;else break;o=De(r.document)}return o}function pd(r){var o=r&&r.nodeName&&r.nodeName.toLowerCase();return o&&(o==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||o==="textarea"||r.contentEditable==="true")}function Jx(r){var o=Pg(),u=r.focusedElem,p=r.selectionRange;if(o!==u&&u&&u.ownerDocument&&jg(u.ownerDocument.documentElement,u)){if(p!==null&&pd(u)){if(o=p.start,r=p.end,r===void 0&&(r=o),"selectionStart"in u)u.selectionStart=o,u.selectionEnd=Math.min(r,u.value.length);else if(r=(o=u.ownerDocument||document)&&o.defaultView||window,r.getSelection){r=r.getSelection();var v=u.textContent.length,S=Math.min(p.start,v);p=p.end===void 0?S:Math.min(p.end,v),!r.extend&&S>p&&(v=p,p=S,S=v),v=Ag(u,S);var B=Ag(u,p);v&&B&&(r.rangeCount!==1||r.anchorNode!==v.node||r.anchorOffset!==v.offset||r.focusNode!==B.node||r.focusOffset!==B.offset)&&(o=o.createRange(),o.setStart(v.node,v.offset),r.removeAllRanges(),S>p?(r.addRange(o),r.extend(B.node,B.offset)):(o.setEnd(B.node,B.offset),r.addRange(o)))}}for(o=[],r=u;r=r.parentNode;)r.nodeType===1&&o.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof u.focus=="function"&&u.focus(),u=0;u<o.length;u++)r=o[u],r.element.scrollLeft=r.left,r.element.scrollTop=r.top}}var Zx=d&&"documentMode"in document&&11>=document.documentMode,So=null,md=null,Ma=null,gd=!1;function Tg(r,o,u){var p=u.window===u?u.document:u.nodeType===9?u:u.ownerDocument;gd||So==null||So!==De(p)||(p=So,"selectionStart"in p&&pd(p)?p={start:p.selectionStart,end:p.selectionEnd}:(p=(p.ownerDocument&&p.ownerDocument.defaultView||window).getSelection(),p={anchorNode:p.anchorNode,anchorOffset:p.anchorOffset,focusNode:p.focusNode,focusOffset:p.focusOffset}),Ma&&Ra(Ma,p)||(Ma=p,p=ec(md,"onSelect"),0<p.length&&(o=new od("onSelect","select",null,o,u),r.push({event:o,listeners:p}),o.target=So)))}function Ql(r,o){var u={};return u[r.toLowerCase()]=o.toLowerCase(),u["Webkit"+r]="webkit"+o,u["Moz"+r]="moz"+o,u}var xo={animationend:Ql("Animation","AnimationEnd"),animationiteration:Ql("Animation","AnimationIteration"),animationstart:Ql("Animation","AnimationStart"),transitionend:Ql("Transition","TransitionEnd")},vd={},Dg={};d&&(Dg=document.createElement("div").style,"AnimationEvent"in window||(delete xo.animationend.animation,delete xo.animationiteration.animation,delete xo.animationstart.animation),"TransitionEvent"in window||delete xo.transitionend.transition);function Jl(r){if(vd[r])return vd[r];if(!xo[r])return r;var o=xo[r],u;for(u in o)if(o.hasOwnProperty(u)&&u in Dg)return vd[r]=o[u];return r}var Ig=Jl("animationend"),Bg=Jl("animationiteration"),Og=Jl("animationstart"),$g=Jl("transitionend"),zg=new Map,Fg="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 nr(r,o){zg.set(r,o),a(o,[r])}for(var _d=0;_d<Fg.length;_d++){var yd=Fg[_d],eC=yd.toLowerCase(),tC=yd[0].toUpperCase()+yd.slice(1);nr(eC,"on"+tC)}nr(Ig,"onAnimationEnd"),nr(Bg,"onAnimationIteration"),nr(Og,"onAnimationStart"),nr("dblclick","onDoubleClick"),nr("focusin","onFocus"),nr("focusout","onBlur"),nr($g,"onTransitionEnd"),l("onMouseEnter",["mouseout","mouseover"]),l("onMouseLeave",["mouseout","mouseover"]),l("onPointerEnter",["pointerout","pointerover"]),l("onPointerLeave",["pointerout","pointerover"]),a("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),a("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),a("onBeforeInput",["compositionend","keypress","textInput","paste"]),a("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Aa="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(" "),nC=new Set("cancel close invalid load scroll toggle".split(" ").concat(Aa));function Hg(r,o,u){var p=r.type||"unknown-event";r.currentTarget=u,Be(p,o,void 0,r),r.currentTarget=null}function Ug(r,o){o=(o&4)!==0;for(var u=0;u<r.length;u++){var p=r[u],v=p.event;p=p.listeners;e:{var S=void 0;if(o)for(var B=p.length-1;0<=B;B--){var G=p[B],te=G.instance,fe=G.currentTarget;if(G=G.listener,te!==S&&v.isPropagationStopped())break e;Hg(v,G,fe),S=te}else for(B=0;B<p.length;B++){if(G=p[B],te=G.instance,fe=G.currentTarget,G=G.listener,te!==S&&v.isPropagationStopped())break e;Hg(v,G,fe),S=te}}}if(et)throw r=Ot,et=!1,Ot=null,r}function Vt(r,o){var u=o[Nd];u===void 0&&(u=o[Nd]=new Set);var p=r+"__bubble";u.has(p)||(Wg(o,r,2,!1),u.add(p))}function wd(r,o,u){var p=0;o&&(p|=4),Wg(u,r,p,o)}var Zl="_reactListening"+Math.random().toString(36).slice(2);function ja(r){if(!r[Zl]){r[Zl]=!0,i.forEach(function(u){u!=="selectionchange"&&(nC.has(u)||wd(u,!1,r),wd(u,!0,r))});var o=r.nodeType===9?r:r.ownerDocument;o===null||o[Zl]||(o[Zl]=!0,wd("selectionchange",!1,o))}}function Wg(r,o,u,p){switch(fg(o)){case 1:var v=pi;break;case 4:v=ls;break;default:v=Sa}u=v.bind(null,o,u,r),v=void 0,!ie||o!=="touchstart"&&o!=="touchmove"&&o!=="wheel"||(v=!0),p?v!==void 0?r.addEventListener(o,u,{capture:!0,passive:v}):r.addEventListener(o,u,!0):v!==void 0?r.addEventListener(o,u,{passive:v}):r.addEventListener(o,u,!1)}function bd(r,o,u,p,v){var S=p;if((o&1)===0&&(o&2)===0&&p!==null)e:for(;;){if(p===null)return;var B=p.tag;if(B===3||B===4){var G=p.stateNode.containerInfo;if(G===v||G.nodeType===8&&G.parentNode===v)break;if(B===4)for(B=p.return;B!==null;){var te=B.tag;if((te===3||te===4)&&(te=B.stateNode.containerInfo,te===v||te.nodeType===8&&te.parentNode===v))return;B=B.return}for(;G!==null;){if(B=Br(G),B===null)return;if(te=B.tag,te===5||te===6){p=S=B;continue e}G=G.parentNode}}p=p.return}Pt(function(){var fe=S,be=Lt(u),ke=[];e:{var we=zg.get(r);if(we!==void 0){var He=od,Ve=r;switch(r){case"keypress":if(Vl(u)===0)break e;case"keydown":case"keyup":He=jx;break;case"focusin":Ve="focus",He=cd;break;case"focusout":Ve="blur",He=cd;break;case"beforeblur":case"afterblur":He=cd;break;case"click":if(u.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":He=gg;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":He=wx;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":He=Dx;break;case Ig:case Bg:case Og:He=xx;break;case $g:He=Bx;break;case"scroll":He=_x;break;case"wheel":He=$x;break;case"copy":case"cut":case"paste":He=kx;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":He=_g}var Ye=(o&4)!==0,_n=!Ye&&r==="scroll",ue=Ye?we!==null?we+"Capture":null:we;Ye=[];for(var se=fe,he;se!==null;){he=se;var Ne=he.stateNode;if(he.tag===5&&Ne!==null&&(he=Ne,ue!==null&&(Ne=X(se,ue),Ne!=null&&Ye.push(Pa(se,Ne,he)))),_n)break;se=se.return}0<Ye.length&&(we=new He(we,Ve,null,u,be),ke.push({event:we,listeners:Ye}))}}if((o&7)===0){e:{if(we=r==="mouseover"||r==="pointerover",He=r==="mouseout"||r==="pointerout",we&&u!==pt&&(Ve=u.relatedTarget||u.fromElement)&&(Br(Ve)||Ve[Ms]))break e;if((He||we)&&(we=be.window===be?be:(we=be.ownerDocument)?we.defaultView||we.parentWindow:window,He?(Ve=u.relatedTarget||u.toElement,He=fe,Ve=Ve?Br(Ve):null,Ve!==null&&(_n=vt(Ve),Ve!==_n||Ve.tag!==5&&Ve.tag!==6)&&(Ve=null)):(He=null,Ve=fe),He!==Ve)){if(Ye=gg,Ne="onMouseLeave",ue="onMouseEnter",se="mouse",(r==="pointerout"||r==="pointerover")&&(Ye=_g,Ne="onPointerLeave",ue="onPointerEnter",se="pointer"),_n=He==null?we:Eo(He),he=Ve==null?we:Eo(Ve),we=new Ye(Ne,se+"leave",He,u,be),we.target=_n,we.relatedTarget=he,Ne=null,Br(be)===fe&&(Ye=new Ye(ue,se+"enter",Ve,u,be),Ye.target=he,Ye.relatedTarget=_n,Ne=Ye),_n=Ne,He&&Ve)t:{for(Ye=He,ue=Ve,se=0,he=Ye;he;he=Co(he))se++;for(he=0,Ne=ue;Ne;Ne=Co(Ne))he++;for(;0<se-he;)Ye=Co(Ye),se--;for(;0<he-se;)ue=Co(ue),he--;for(;se--;){if(Ye===ue||ue!==null&&Ye===ue.alternate)break t;Ye=Co(Ye),ue=Co(ue)}Ye=null}else Ye=null;He!==null&&qg(ke,we,He,Ye,!1),Ve!==null&&_n!==null&&qg(ke,_n,Ve,Ye,!0)}}e:{if(we=fe?Eo(fe):window,He=we.nodeName&&we.nodeName.toLowerCase(),He==="select"||He==="input"&&we.type==="file")var Xe=Kx;else if(Cg(we))if(Eg)Xe=Xx;else{Xe=Yx;var Je=Vx}else(He=we.nodeName)&&He.toLowerCase()==="input"&&(we.type==="checkbox"||we.type==="radio")&&(Xe=Gx);if(Xe&&(Xe=Xe(r,fe))){kg(ke,Xe,u,be);break e}Je&&Je(r,we,fe),r==="focusout"&&(Je=we._wrapperState)&&Je.controlled&&we.type==="number"&&ht(we,"number",we.value)}switch(Je=fe?Eo(fe):window,r){case"focusin":(Cg(Je)||Je.contentEditable==="true")&&(So=Je,md=fe,Ma=null);break;case"focusout":Ma=md=So=null;break;case"mousedown":gd=!0;break;case"contextmenu":case"mouseup":case"dragend":gd=!1,Tg(ke,u,be);break;case"selectionchange":if(Zx)break;case"keydown":case"keyup":Tg(ke,u,be)}var Ze;if(dd)e:{switch(r){case"compositionstart":var at="onCompositionStart";break e;case"compositionend":at="onCompositionEnd";break e;case"compositionupdate":at="onCompositionUpdate";break e}at=void 0}else bo?Sg(r,u)&&(at="onCompositionEnd"):r==="keydown"&&u.keyCode===229&&(at="onCompositionStart");at&&(yg&&u.locale!=="ko"&&(bo||at!=="onCompositionStart"?at==="onCompositionEnd"&&bo&&(Ze=pg()):(tr=be,rd="value"in tr?tr.value:tr.textContent,bo=!0)),Je=ec(fe,at),0<Je.length&&(at=new vg(at,r,null,u,be),ke.push({event:at,listeners:Je}),Ze?at.data=Ze:(Ze=xg(u),Ze!==null&&(at.data=Ze)))),(Ze=Fx?Hx(r,u):Ux(r,u))&&(fe=ec(fe,"onBeforeInput"),0<fe.length&&(be=new vg("onBeforeInput","beforeinput",null,u,be),ke.push({event:be,listeners:fe}),be.data=Ze))}Ug(ke,o)})}function Pa(r,o,u){return{instance:r,listener:o,currentTarget:u}}function ec(r,o){for(var u=o+"Capture",p=[];r!==null;){var v=r,S=v.stateNode;v.tag===5&&S!==null&&(v=S,S=X(r,u),S!=null&&p.unshift(Pa(r,S,v)),S=X(r,o),S!=null&&p.push(Pa(r,S,v))),r=r.return}return p}function Co(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5);return r||null}function qg(r,o,u,p,v){for(var S=o._reactName,B=[];u!==null&&u!==p;){var G=u,te=G.alternate,fe=G.stateNode;if(te!==null&&te===p)break;G.tag===5&&fe!==null&&(G=fe,v?(te=X(u,S),te!=null&&B.unshift(Pa(u,te,G))):v||(te=X(u,S),te!=null&&B.push(Pa(u,te,G)))),u=u.return}B.length!==0&&r.push({event:o,listeners:B})}var iC=/\r\n?/g,sC=/\u0000|\uFFFD/g;function Kg(r){return(typeof r=="string"?r:""+r).replace(iC,`
38
- `).replace(sC,"")}function tc(r,o,u){if(o=Kg(o),Kg(r)!==o&&u)throw Error(n(425))}function nc(){}var Sd=null,xd=null;function Cd(r,o){return r==="textarea"||r==="noscript"||typeof o.children=="string"||typeof o.children=="number"||typeof o.dangerouslySetInnerHTML=="object"&&o.dangerouslySetInnerHTML!==null&&o.dangerouslySetInnerHTML.__html!=null}var kd=typeof setTimeout=="function"?setTimeout:void 0,rC=typeof clearTimeout=="function"?clearTimeout:void 0,Vg=typeof Promise=="function"?Promise:void 0,oC=typeof queueMicrotask=="function"?queueMicrotask:typeof Vg<"u"?function(r){return Vg.resolve(null).then(r).catch(aC)}:kd;function aC(r){setTimeout(function(){throw r})}function Ed(r,o){var u=o,p=0;do{var v=u.nextSibling;if(r.removeChild(u),v&&v.nodeType===8)if(u=v.data,u==="/$"){if(p===0){r.removeChild(v),Ht(o);return}p--}else u!=="$"&&u!=="$?"&&u!=="$!"||p++;u=v}while(u);Ht(o)}function ir(r){for(;r!=null;r=r.nextSibling){var o=r.nodeType;if(o===1||o===3)break;if(o===8){if(o=r.data,o==="$"||o==="$!"||o==="$?")break;if(o==="/$")return null}}return r}function Yg(r){r=r.previousSibling;for(var o=0;r;){if(r.nodeType===8){var u=r.data;if(u==="$"||u==="$!"||u==="$?"){if(o===0)return r;o--}else u==="/$"&&o++}r=r.previousSibling}return null}var ko=Math.random().toString(36).slice(2),cs="__reactFiber$"+ko,Ta="__reactProps$"+ko,Ms="__reactContainer$"+ko,Nd="__reactEvents$"+ko,lC="__reactListeners$"+ko,cC="__reactHandles$"+ko;function Br(r){var o=r[cs];if(o)return o;for(var u=r.parentNode;u;){if(o=u[Ms]||u[cs]){if(u=o.alternate,o.child!==null||u!==null&&u.child!==null)for(r=Yg(r);r!==null;){if(u=r[cs])return u;r=Yg(r)}return o}r=u,u=r.parentNode}return null}function Da(r){return r=r[cs]||r[Ms],!r||r.tag!==5&&r.tag!==6&&r.tag!==13&&r.tag!==3?null:r}function Eo(r){if(r.tag===5||r.tag===6)return r.stateNode;throw Error(n(33))}function ic(r){return r[Ta]||null}var Ld=[],No=-1;function sr(r){return{current:r}}function Yt(r){0>No||(r.current=Ld[No],Ld[No]=null,No--)}function qt(r,o){No++,Ld[No]=r.current,r.current=o}var rr={},Qn=sr(rr),mi=sr(!1),Or=rr;function Lo(r,o){var u=r.type.contextTypes;if(!u)return rr;var p=r.stateNode;if(p&&p.__reactInternalMemoizedUnmaskedChildContext===o)return p.__reactInternalMemoizedMaskedChildContext;var v={},S;for(S in u)v[S]=o[S];return p&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=o,r.__reactInternalMemoizedMaskedChildContext=v),v}function gi(r){return r=r.childContextTypes,r!=null}function sc(){Yt(mi),Yt(Qn)}function Gg(r,o,u){if(Qn.current!==rr)throw Error(n(168));qt(Qn,o),qt(mi,u)}function Xg(r,o,u){var p=r.stateNode;if(o=o.childContextTypes,typeof p.getChildContext!="function")return u;p=p.getChildContext();for(var v in p)if(!(v in o))throw Error(n(108,de(r)||"Unknown",v));return H({},u,p)}function rc(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||rr,Or=Qn.current,qt(Qn,r),qt(mi,mi.current),!0}function Qg(r,o,u){var p=r.stateNode;if(!p)throw Error(n(169));u?(r=Xg(r,o,Or),p.__reactInternalMemoizedMergedChildContext=r,Yt(mi),Yt(Qn),qt(Qn,r)):Yt(mi),qt(mi,u)}var As=null,oc=!1,Rd=!1;function Jg(r){As===null?As=[r]:As.push(r)}function uC(r){oc=!0,Jg(r)}function or(){if(!Rd&&As!==null){Rd=!0;var r=0,o=xt;try{var u=As;for(xt=1;r<u.length;r++){var p=u[r];do p=p(!0);while(p!==null)}As=null,oc=!1}catch(v){throw As!==null&&(As=As.slice(r+1)),st(Di,or),v}finally{xt=o,Rd=!1}}return null}var Ro=[],Mo=0,ac=null,lc=0,Ii=[],Bi=0,$r=null,js=1,Ps="";function zr(r,o){Ro[Mo++]=lc,Ro[Mo++]=ac,ac=r,lc=o}function Zg(r,o,u){Ii[Bi++]=js,Ii[Bi++]=Ps,Ii[Bi++]=$r,$r=r;var p=js;r=Ps;var v=32-di(p)-1;p&=~(1<<v),u+=1;var S=32-di(o)+v;if(30<S){var B=v-v%5;S=(p&(1<<B)-1).toString(32),p>>=B,v-=B,js=1<<32-di(o)+v|u<<v|p,Ps=S+r}else js=1<<S|u<<v|p,Ps=r}function Md(r){r.return!==null&&(zr(r,1),Zg(r,1,0))}function Ad(r){for(;r===ac;)ac=Ro[--Mo],Ro[Mo]=null,lc=Ro[--Mo],Ro[Mo]=null;for(;r===$r;)$r=Ii[--Bi],Ii[Bi]=null,Ps=Ii[--Bi],Ii[Bi]=null,js=Ii[--Bi],Ii[Bi]=null}var Ni=null,Li=null,Zt=!1,Ji=null;function ev(r,o){var u=Fi(5,null,null,0);u.elementType="DELETED",u.stateNode=o,u.return=r,o=r.deletions,o===null?(r.deletions=[u],r.flags|=16):o.push(u)}function tv(r,o){switch(r.tag){case 5:var u=r.type;return o=o.nodeType!==1||u.toLowerCase()!==o.nodeName.toLowerCase()?null:o,o!==null?(r.stateNode=o,Ni=r,Li=ir(o.firstChild),!0):!1;case 6:return o=r.pendingProps===""||o.nodeType!==3?null:o,o!==null?(r.stateNode=o,Ni=r,Li=null,!0):!1;case 13:return o=o.nodeType!==8?null:o,o!==null?(u=$r!==null?{id:js,overflow:Ps}:null,r.memoizedState={dehydrated:o,treeContext:u,retryLane:1073741824},u=Fi(18,null,null,0),u.stateNode=o,u.return=r,r.child=u,Ni=r,Li=null,!0):!1;default:return!1}}function jd(r){return(r.mode&1)!==0&&(r.flags&128)===0}function Pd(r){if(Zt){var o=Li;if(o){var u=o;if(!tv(r,o)){if(jd(r))throw Error(n(418));o=ir(u.nextSibling);var p=Ni;o&&tv(r,o)?ev(p,u):(r.flags=r.flags&-4097|2,Zt=!1,Ni=r)}}else{if(jd(r))throw Error(n(418));r.flags=r.flags&-4097|2,Zt=!1,Ni=r}}}function nv(r){for(r=r.return;r!==null&&r.tag!==5&&r.tag!==3&&r.tag!==13;)r=r.return;Ni=r}function cc(r){if(r!==Ni)return!1;if(!Zt)return nv(r),Zt=!0,!1;var o;if((o=r.tag!==3)&&!(o=r.tag!==5)&&(o=r.type,o=o!=="head"&&o!=="body"&&!Cd(r.type,r.memoizedProps)),o&&(o=Li)){if(jd(r))throw iv(),Error(n(418));for(;o;)ev(r,o),o=ir(o.nextSibling)}if(nv(r),r.tag===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(n(317));e:{for(r=r.nextSibling,o=0;r;){if(r.nodeType===8){var u=r.data;if(u==="/$"){if(o===0){Li=ir(r.nextSibling);break e}o--}else u!=="$"&&u!=="$!"&&u!=="$?"||o++}r=r.nextSibling}Li=null}}else Li=Ni?ir(r.stateNode.nextSibling):null;return!0}function iv(){for(var r=Li;r;)r=ir(r.nextSibling)}function Ao(){Li=Ni=null,Zt=!1}function Td(r){Ji===null?Ji=[r]:Ji.push(r)}var dC=T.ReactCurrentBatchConfig;function Ia(r,o,u){if(r=u.ref,r!==null&&typeof r!="function"&&typeof r!="object"){if(u._owner){if(u=u._owner,u){if(u.tag!==1)throw Error(n(309));var p=u.stateNode}if(!p)throw Error(n(147,r));var v=p,S=""+r;return o!==null&&o.ref!==null&&typeof o.ref=="function"&&o.ref._stringRef===S?o.ref:(o=function(B){var G=v.refs;B===null?delete G[S]:G[S]=B},o._stringRef=S,o)}if(typeof r!="string")throw Error(n(284));if(!u._owner)throw Error(n(290,r))}return r}function uc(r,o){throw r=Object.prototype.toString.call(o),Error(n(31,r==="[object Object]"?"object with keys {"+Object.keys(o).join(", ")+"}":r))}function sv(r){var o=r._init;return o(r._payload)}function rv(r){function o(ue,se){if(r){var he=ue.deletions;he===null?(ue.deletions=[se],ue.flags|=16):he.push(se)}}function u(ue,se){if(!r)return null;for(;se!==null;)o(ue,se),se=se.sibling;return null}function p(ue,se){for(ue=new Map;se!==null;)se.key!==null?ue.set(se.key,se):ue.set(se.index,se),se=se.sibling;return ue}function v(ue,se){return ue=pr(ue,se),ue.index=0,ue.sibling=null,ue}function S(ue,se,he){return ue.index=he,r?(he=ue.alternate,he!==null?(he=he.index,he<se?(ue.flags|=2,se):he):(ue.flags|=2,se)):(ue.flags|=1048576,se)}function B(ue){return r&&ue.alternate===null&&(ue.flags|=2),ue}function G(ue,se,he,Ne){return se===null||se.tag!==6?(se=kh(he,ue.mode,Ne),se.return=ue,se):(se=v(se,he),se.return=ue,se)}function te(ue,se,he,Ne){var Xe=he.type;return Xe===Q?be(ue,se,he.props.children,Ne,he.key):se!==null&&(se.elementType===Xe||typeof Xe=="object"&&Xe!==null&&Xe.$$typeof===P&&sv(Xe)===se.type)?(Ne=v(se,he.props),Ne.ref=Ia(ue,se,he),Ne.return=ue,Ne):(Ne=Tc(he.type,he.key,he.props,null,ue.mode,Ne),Ne.ref=Ia(ue,se,he),Ne.return=ue,Ne)}function fe(ue,se,he,Ne){return se===null||se.tag!==4||se.stateNode.containerInfo!==he.containerInfo||se.stateNode.implementation!==he.implementation?(se=Eh(he,ue.mode,Ne),se.return=ue,se):(se=v(se,he.children||[]),se.return=ue,se)}function be(ue,se,he,Ne,Xe){return se===null||se.tag!==7?(se=Yr(he,ue.mode,Ne,Xe),se.return=ue,se):(se=v(se,he),se.return=ue,se)}function ke(ue,se,he){if(typeof se=="string"&&se!==""||typeof se=="number")return se=kh(""+se,ue.mode,he),se.return=ue,se;if(typeof se=="object"&&se!==null){switch(se.$$typeof){case W:return he=Tc(se.type,se.key,se.props,null,ue.mode,he),he.ref=Ia(ue,null,se),he.return=ue,he;case U:return se=Eh(se,ue.mode,he),se.return=ue,se;case P:var Ne=se._init;return ke(ue,Ne(se._payload),he)}if(kt(se)||D(se))return se=Yr(se,ue.mode,he,null),se.return=ue,se;uc(ue,se)}return null}function we(ue,se,he,Ne){var Xe=se!==null?se.key:null;if(typeof he=="string"&&he!==""||typeof he=="number")return Xe!==null?null:G(ue,se,""+he,Ne);if(typeof he=="object"&&he!==null){switch(he.$$typeof){case W:return he.key===Xe?te(ue,se,he,Ne):null;case U:return he.key===Xe?fe(ue,se,he,Ne):null;case P:return Xe=he._init,we(ue,se,Xe(he._payload),Ne)}if(kt(he)||D(he))return Xe!==null?null:be(ue,se,he,Ne,null);uc(ue,he)}return null}function He(ue,se,he,Ne,Xe){if(typeof Ne=="string"&&Ne!==""||typeof Ne=="number")return ue=ue.get(he)||null,G(se,ue,""+Ne,Xe);if(typeof Ne=="object"&&Ne!==null){switch(Ne.$$typeof){case W:return ue=ue.get(Ne.key===null?he:Ne.key)||null,te(se,ue,Ne,Xe);case U:return ue=ue.get(Ne.key===null?he:Ne.key)||null,fe(se,ue,Ne,Xe);case P:var Je=Ne._init;return He(ue,se,he,Je(Ne._payload),Xe)}if(kt(Ne)||D(Ne))return ue=ue.get(he)||null,be(se,ue,Ne,Xe,null);uc(se,Ne)}return null}function Ve(ue,se,he,Ne){for(var Xe=null,Je=null,Ze=se,at=se=0,Pn=null;Ze!==null&&at<he.length;at++){Ze.index>at?(Pn=Ze,Ze=null):Pn=Ze.sibling;var Tt=we(ue,Ze,he[at],Ne);if(Tt===null){Ze===null&&(Ze=Pn);break}r&&Ze&&Tt.alternate===null&&o(ue,Ze),se=S(Tt,se,at),Je===null?Xe=Tt:Je.sibling=Tt,Je=Tt,Ze=Pn}if(at===he.length)return u(ue,Ze),Zt&&zr(ue,at),Xe;if(Ze===null){for(;at<he.length;at++)Ze=ke(ue,he[at],Ne),Ze!==null&&(se=S(Ze,se,at),Je===null?Xe=Ze:Je.sibling=Ze,Je=Ze);return Zt&&zr(ue,at),Xe}for(Ze=p(ue,Ze);at<he.length;at++)Pn=He(Ze,ue,at,he[at],Ne),Pn!==null&&(r&&Pn.alternate!==null&&Ze.delete(Pn.key===null?at:Pn.key),se=S(Pn,se,at),Je===null?Xe=Pn:Je.sibling=Pn,Je=Pn);return r&&Ze.forEach(function(mr){return o(ue,mr)}),Zt&&zr(ue,at),Xe}function Ye(ue,se,he,Ne){var Xe=D(he);if(typeof Xe!="function")throw Error(n(150));if(he=Xe.call(he),he==null)throw Error(n(151));for(var Je=Xe=null,Ze=se,at=se=0,Pn=null,Tt=he.next();Ze!==null&&!Tt.done;at++,Tt=he.next()){Ze.index>at?(Pn=Ze,Ze=null):Pn=Ze.sibling;var mr=we(ue,Ze,Tt.value,Ne);if(mr===null){Ze===null&&(Ze=Pn);break}r&&Ze&&mr.alternate===null&&o(ue,Ze),se=S(mr,se,at),Je===null?Xe=mr:Je.sibling=mr,Je=mr,Ze=Pn}if(Tt.done)return u(ue,Ze),Zt&&zr(ue,at),Xe;if(Ze===null){for(;!Tt.done;at++,Tt=he.next())Tt=ke(ue,Tt.value,Ne),Tt!==null&&(se=S(Tt,se,at),Je===null?Xe=Tt:Je.sibling=Tt,Je=Tt);return Zt&&zr(ue,at),Xe}for(Ze=p(ue,Ze);!Tt.done;at++,Tt=he.next())Tt=He(Ze,ue,at,Tt.value,Ne),Tt!==null&&(r&&Tt.alternate!==null&&Ze.delete(Tt.key===null?at:Tt.key),se=S(Tt,se,at),Je===null?Xe=Tt:Je.sibling=Tt,Je=Tt);return r&&Ze.forEach(function(WC){return o(ue,WC)}),Zt&&zr(ue,at),Xe}function _n(ue,se,he,Ne){if(typeof he=="object"&&he!==null&&he.type===Q&&he.key===null&&(he=he.props.children),typeof he=="object"&&he!==null){switch(he.$$typeof){case W:e:{for(var Xe=he.key,Je=se;Je!==null;){if(Je.key===Xe){if(Xe=he.type,Xe===Q){if(Je.tag===7){u(ue,Je.sibling),se=v(Je,he.props.children),se.return=ue,ue=se;break e}}else if(Je.elementType===Xe||typeof Xe=="object"&&Xe!==null&&Xe.$$typeof===P&&sv(Xe)===Je.type){u(ue,Je.sibling),se=v(Je,he.props),se.ref=Ia(ue,Je,he),se.return=ue,ue=se;break e}u(ue,Je);break}else o(ue,Je);Je=Je.sibling}he.type===Q?(se=Yr(he.props.children,ue.mode,Ne,he.key),se.return=ue,ue=se):(Ne=Tc(he.type,he.key,he.props,null,ue.mode,Ne),Ne.ref=Ia(ue,se,he),Ne.return=ue,ue=Ne)}return B(ue);case U:e:{for(Je=he.key;se!==null;){if(se.key===Je)if(se.tag===4&&se.stateNode.containerInfo===he.containerInfo&&se.stateNode.implementation===he.implementation){u(ue,se.sibling),se=v(se,he.children||[]),se.return=ue,ue=se;break e}else{u(ue,se);break}else o(ue,se);se=se.sibling}se=Eh(he,ue.mode,Ne),se.return=ue,ue=se}return B(ue);case P:return Je=he._init,_n(ue,se,Je(he._payload),Ne)}if(kt(he))return Ve(ue,se,he,Ne);if(D(he))return Ye(ue,se,he,Ne);uc(ue,he)}return typeof he=="string"&&he!==""||typeof he=="number"?(he=""+he,se!==null&&se.tag===6?(u(ue,se.sibling),se=v(se,he),se.return=ue,ue=se):(u(ue,se),se=kh(he,ue.mode,Ne),se.return=ue,ue=se),B(ue)):u(ue,se)}return _n}var jo=rv(!0),ov=rv(!1),dc=sr(null),hc=null,Po=null,Dd=null;function Id(){Dd=Po=hc=null}function Bd(r){var o=dc.current;Yt(dc),r._currentValue=o}function Od(r,o,u){for(;r!==null;){var p=r.alternate;if((r.childLanes&o)!==o?(r.childLanes|=o,p!==null&&(p.childLanes|=o)):p!==null&&(p.childLanes&o)!==o&&(p.childLanes|=o),r===u)break;r=r.return}}function To(r,o){hc=r,Dd=Po=null,r=r.dependencies,r!==null&&r.firstContext!==null&&((r.lanes&o)!==0&&(vi=!0),r.firstContext=null)}function Oi(r){var o=r._currentValue;if(Dd!==r)if(r={context:r,memoizedValue:o,next:null},Po===null){if(hc===null)throw Error(n(308));Po=r,hc.dependencies={lanes:0,firstContext:r}}else Po=Po.next=r;return o}var Fr=null;function $d(r){Fr===null?Fr=[r]:Fr.push(r)}function av(r,o,u,p){var v=o.interleaved;return v===null?(u.next=u,$d(o)):(u.next=v.next,v.next=u),o.interleaved=u,Ts(r,p)}function Ts(r,o){r.lanes|=o;var u=r.alternate;for(u!==null&&(u.lanes|=o),u=r,r=r.return;r!==null;)r.childLanes|=o,u=r.alternate,u!==null&&(u.childLanes|=o),u=r,r=r.return;return u.tag===3?u.stateNode:null}var ar=!1;function zd(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function lv(r,o){r=r.updateQueue,o.updateQueue===r&&(o.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,effects:r.effects})}function Ds(r,o){return{eventTime:r,lane:o,tag:0,payload:null,callback:null,next:null}}function lr(r,o,u){var p=r.updateQueue;if(p===null)return null;if(p=p.shared,(At&2)!==0){var v=p.pending;return v===null?o.next=o:(o.next=v.next,v.next=o),p.pending=o,Ts(r,u)}return v=p.interleaved,v===null?(o.next=o,$d(p)):(o.next=v.next,v.next=o),p.interleaved=o,Ts(r,u)}function fc(r,o,u){if(o=o.updateQueue,o!==null&&(o=o.shared,(u&4194240)!==0)){var p=o.lanes;p&=r.pendingLanes,u|=p,o.lanes=u,vo(r,u)}}function cv(r,o){var u=r.updateQueue,p=r.alternate;if(p!==null&&(p=p.updateQueue,u===p)){var v=null,S=null;if(u=u.firstBaseUpdate,u!==null){do{var B={eventTime:u.eventTime,lane:u.lane,tag:u.tag,payload:u.payload,callback:u.callback,next:null};S===null?v=S=B:S=S.next=B,u=u.next}while(u!==null);S===null?v=S=o:S=S.next=o}else v=S=o;u={baseState:p.baseState,firstBaseUpdate:v,lastBaseUpdate:S,shared:p.shared,effects:p.effects},r.updateQueue=u;return}r=u.lastBaseUpdate,r===null?u.firstBaseUpdate=o:r.next=o,u.lastBaseUpdate=o}function pc(r,o,u,p){var v=r.updateQueue;ar=!1;var S=v.firstBaseUpdate,B=v.lastBaseUpdate,G=v.shared.pending;if(G!==null){v.shared.pending=null;var te=G,fe=te.next;te.next=null,B===null?S=fe:B.next=fe,B=te;var be=r.alternate;be!==null&&(be=be.updateQueue,G=be.lastBaseUpdate,G!==B&&(G===null?be.firstBaseUpdate=fe:G.next=fe,be.lastBaseUpdate=te))}if(S!==null){var ke=v.baseState;B=0,be=fe=te=null,G=S;do{var we=G.lane,He=G.eventTime;if((p&we)===we){be!==null&&(be=be.next={eventTime:He,lane:0,tag:G.tag,payload:G.payload,callback:G.callback,next:null});e:{var Ve=r,Ye=G;switch(we=o,He=u,Ye.tag){case 1:if(Ve=Ye.payload,typeof Ve=="function"){ke=Ve.call(He,ke,we);break e}ke=Ve;break e;case 3:Ve.flags=Ve.flags&-65537|128;case 0:if(Ve=Ye.payload,we=typeof Ve=="function"?Ve.call(He,ke,we):Ve,we==null)break e;ke=H({},ke,we);break e;case 2:ar=!0}}G.callback!==null&&G.lane!==0&&(r.flags|=64,we=v.effects,we===null?v.effects=[G]:we.push(G))}else He={eventTime:He,lane:we,tag:G.tag,payload:G.payload,callback:G.callback,next:null},be===null?(fe=be=He,te=ke):be=be.next=He,B|=we;if(G=G.next,G===null){if(G=v.shared.pending,G===null)break;we=G,G=we.next,we.next=null,v.lastBaseUpdate=we,v.shared.pending=null}}while(!0);if(be===null&&(te=ke),v.baseState=te,v.firstBaseUpdate=fe,v.lastBaseUpdate=be,o=v.shared.interleaved,o!==null){v=o;do B|=v.lane,v=v.next;while(v!==o)}else S===null&&(v.shared.lanes=0);Wr|=B,r.lanes=B,r.memoizedState=ke}}function uv(r,o,u){if(r=o.effects,o.effects=null,r!==null)for(o=0;o<r.length;o++){var p=r[o],v=p.callback;if(v!==null){if(p.callback=null,p=u,typeof v!="function")throw Error(n(191,v));v.call(p)}}}var Ba={},us=sr(Ba),Oa=sr(Ba),$a=sr(Ba);function Hr(r){if(r===Ba)throw Error(n(174));return r}function Fd(r,o){switch(qt($a,o),qt(Oa,r),qt(us,Ba),r=o.nodeType,r){case 9:case 11:o=(o=o.documentElement)?o.namespaceURI:ln(null,"");break;default:r=r===8?o.parentNode:o,o=r.namespaceURI||null,r=r.tagName,o=ln(o,r)}Yt(us),qt(us,o)}function Do(){Yt(us),Yt(Oa),Yt($a)}function dv(r){Hr($a.current);var o=Hr(us.current),u=ln(o,r.type);o!==u&&(qt(Oa,r),qt(us,u))}function Hd(r){Oa.current===r&&(Yt(us),Yt(Oa))}var nn=sr(0);function mc(r){for(var o=r;o!==null;){if(o.tag===13){var u=o.memoizedState;if(u!==null&&(u=u.dehydrated,u===null||u.data==="$?"||u.data==="$!"))return o}else if(o.tag===19&&o.memoizedProps.revealOrder!==void 0){if((o.flags&128)!==0)return o}else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===r)break;for(;o.sibling===null;){if(o.return===null||o.return===r)return null;o=o.return}o.sibling.return=o.return,o=o.sibling}return null}var Ud=[];function Wd(){for(var r=0;r<Ud.length;r++)Ud[r]._workInProgressVersionPrimary=null;Ud.length=0}var gc=T.ReactCurrentDispatcher,qd=T.ReactCurrentBatchConfig,Ur=0,sn=null,kn=null,An=null,vc=!1,za=!1,Fa=0,hC=0;function Jn(){throw Error(n(321))}function Kd(r,o){if(o===null)return!1;for(var u=0;u<o.length&&u<r.length;u++)if(!Qi(r[u],o[u]))return!1;return!0}function Vd(r,o,u,p,v,S){if(Ur=S,sn=o,o.memoizedState=null,o.updateQueue=null,o.lanes=0,gc.current=r===null||r.memoizedState===null?gC:vC,r=u(p,v),za){S=0;do{if(za=!1,Fa=0,25<=S)throw Error(n(301));S+=1,An=kn=null,o.updateQueue=null,gc.current=_C,r=u(p,v)}while(za)}if(gc.current=wc,o=kn!==null&&kn.next!==null,Ur=0,An=kn=sn=null,vc=!1,o)throw Error(n(300));return r}function Yd(){var r=Fa!==0;return Fa=0,r}function ds(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return An===null?sn.memoizedState=An=r:An=An.next=r,An}function $i(){if(kn===null){var r=sn.alternate;r=r!==null?r.memoizedState:null}else r=kn.next;var o=An===null?sn.memoizedState:An.next;if(o!==null)An=o,kn=r;else{if(r===null)throw Error(n(310));kn=r,r={memoizedState:kn.memoizedState,baseState:kn.baseState,baseQueue:kn.baseQueue,queue:kn.queue,next:null},An===null?sn.memoizedState=An=r:An=An.next=r}return An}function Ha(r,o){return typeof o=="function"?o(r):o}function Gd(r){var o=$i(),u=o.queue;if(u===null)throw Error(n(311));u.lastRenderedReducer=r;var p=kn,v=p.baseQueue,S=u.pending;if(S!==null){if(v!==null){var B=v.next;v.next=S.next,S.next=B}p.baseQueue=v=S,u.pending=null}if(v!==null){S=v.next,p=p.baseState;var G=B=null,te=null,fe=S;do{var be=fe.lane;if((Ur&be)===be)te!==null&&(te=te.next={lane:0,action:fe.action,hasEagerState:fe.hasEagerState,eagerState:fe.eagerState,next:null}),p=fe.hasEagerState?fe.eagerState:r(p,fe.action);else{var ke={lane:be,action:fe.action,hasEagerState:fe.hasEagerState,eagerState:fe.eagerState,next:null};te===null?(G=te=ke,B=p):te=te.next=ke,sn.lanes|=be,Wr|=be}fe=fe.next}while(fe!==null&&fe!==S);te===null?B=p:te.next=G,Qi(p,o.memoizedState)||(vi=!0),o.memoizedState=p,o.baseState=B,o.baseQueue=te,u.lastRenderedState=p}if(r=u.interleaved,r!==null){v=r;do S=v.lane,sn.lanes|=S,Wr|=S,v=v.next;while(v!==r)}else v===null&&(u.lanes=0);return[o.memoizedState,u.dispatch]}function Xd(r){var o=$i(),u=o.queue;if(u===null)throw Error(n(311));u.lastRenderedReducer=r;var p=u.dispatch,v=u.pending,S=o.memoizedState;if(v!==null){u.pending=null;var B=v=v.next;do S=r(S,B.action),B=B.next;while(B!==v);Qi(S,o.memoizedState)||(vi=!0),o.memoizedState=S,o.baseQueue===null&&(o.baseState=S),u.lastRenderedState=S}return[S,p]}function hv(){}function fv(r,o){var u=sn,p=$i(),v=o(),S=!Qi(p.memoizedState,v);if(S&&(p.memoizedState=v,vi=!0),p=p.queue,Qd(gv.bind(null,u,p,r),[r]),p.getSnapshot!==o||S||An!==null&&An.memoizedState.tag&1){if(u.flags|=2048,Ua(9,mv.bind(null,u,p,v,o),void 0,null),jn===null)throw Error(n(349));(Ur&30)!==0||pv(u,o,v)}return v}function pv(r,o,u){r.flags|=16384,r={getSnapshot:o,value:u},o=sn.updateQueue,o===null?(o={lastEffect:null,stores:null},sn.updateQueue=o,o.stores=[r]):(u=o.stores,u===null?o.stores=[r]:u.push(r))}function mv(r,o,u,p){o.value=u,o.getSnapshot=p,vv(o)&&_v(r)}function gv(r,o,u){return u(function(){vv(o)&&_v(r)})}function vv(r){var o=r.getSnapshot;r=r.value;try{var u=o();return!Qi(r,u)}catch{return!0}}function _v(r){var o=Ts(r,1);o!==null&&ns(o,r,1,-1)}function yv(r){var o=ds();return typeof r=="function"&&(r=r()),o.memoizedState=o.baseState=r,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ha,lastRenderedState:r},o.queue=r,r=r.dispatch=mC.bind(null,sn,r),[o.memoizedState,r]}function Ua(r,o,u,p){return r={tag:r,create:o,destroy:u,deps:p,next:null},o=sn.updateQueue,o===null?(o={lastEffect:null,stores:null},sn.updateQueue=o,o.lastEffect=r.next=r):(u=o.lastEffect,u===null?o.lastEffect=r.next=r:(p=u.next,u.next=r,r.next=p,o.lastEffect=r)),r}function wv(){return $i().memoizedState}function _c(r,o,u,p){var v=ds();sn.flags|=r,v.memoizedState=Ua(1|o,u,void 0,p===void 0?null:p)}function yc(r,o,u,p){var v=$i();p=p===void 0?null:p;var S=void 0;if(kn!==null){var B=kn.memoizedState;if(S=B.destroy,p!==null&&Kd(p,B.deps)){v.memoizedState=Ua(o,u,S,p);return}}sn.flags|=r,v.memoizedState=Ua(1|o,u,S,p)}function bv(r,o){return _c(8390656,8,r,o)}function Qd(r,o){return yc(2048,8,r,o)}function Sv(r,o){return yc(4,2,r,o)}function xv(r,o){return yc(4,4,r,o)}function Cv(r,o){if(typeof o=="function")return r=r(),o(r),function(){o(null)};if(o!=null)return r=r(),o.current=r,function(){o.current=null}}function kv(r,o,u){return u=u!=null?u.concat([r]):null,yc(4,4,Cv.bind(null,o,r),u)}function Jd(){}function Ev(r,o){var u=$i();o=o===void 0?null:o;var p=u.memoizedState;return p!==null&&o!==null&&Kd(o,p[1])?p[0]:(u.memoizedState=[r,o],r)}function Nv(r,o){var u=$i();o=o===void 0?null:o;var p=u.memoizedState;return p!==null&&o!==null&&Kd(o,p[1])?p[0]:(r=r(),u.memoizedState=[r,o],r)}function Lv(r,o,u){return(Ur&21)===0?(r.baseState&&(r.baseState=!1,vi=!0),r.memoizedState=u):(Qi(u,o)||(u=os(),sn.lanes|=u,Wr|=u,r.baseState=!0),o)}function fC(r,o){var u=xt;xt=u!==0&&4>u?u:4,r(!0);var p=qd.transition;qd.transition={};try{r(!1),o()}finally{xt=u,qd.transition=p}}function Rv(){return $i().memoizedState}function pC(r,o,u){var p=hr(r);if(u={lane:p,action:u,hasEagerState:!1,eagerState:null,next:null},Mv(r))Av(o,u);else if(u=av(r,o,u,p),u!==null){var v=si();ns(u,r,p,v),jv(u,o,p)}}function mC(r,o,u){var p=hr(r),v={lane:p,action:u,hasEagerState:!1,eagerState:null,next:null};if(Mv(r))Av(o,v);else{var S=r.alternate;if(r.lanes===0&&(S===null||S.lanes===0)&&(S=o.lastRenderedReducer,S!==null))try{var B=o.lastRenderedState,G=S(B,u);if(v.hasEagerState=!0,v.eagerState=G,Qi(G,B)){var te=o.interleaved;te===null?(v.next=v,$d(o)):(v.next=te.next,te.next=v),o.interleaved=v;return}}catch{}finally{}u=av(r,o,v,p),u!==null&&(v=si(),ns(u,r,p,v),jv(u,o,p))}}function Mv(r){var o=r.alternate;return r===sn||o!==null&&o===sn}function Av(r,o){za=vc=!0;var u=r.pending;u===null?o.next=o:(o.next=u.next,u.next=o),r.pending=o}function jv(r,o,u){if((u&4194240)!==0){var p=o.lanes;p&=r.pendingLanes,u|=p,o.lanes=u,vo(r,u)}}var wc={readContext:Oi,useCallback:Jn,useContext:Jn,useEffect:Jn,useImperativeHandle:Jn,useInsertionEffect:Jn,useLayoutEffect:Jn,useMemo:Jn,useReducer:Jn,useRef:Jn,useState:Jn,useDebugValue:Jn,useDeferredValue:Jn,useTransition:Jn,useMutableSource:Jn,useSyncExternalStore:Jn,useId:Jn,unstable_isNewReconciler:!1},gC={readContext:Oi,useCallback:function(r,o){return ds().memoizedState=[r,o===void 0?null:o],r},useContext:Oi,useEffect:bv,useImperativeHandle:function(r,o,u){return u=u!=null?u.concat([r]):null,_c(4194308,4,Cv.bind(null,o,r),u)},useLayoutEffect:function(r,o){return _c(4194308,4,r,o)},useInsertionEffect:function(r,o){return _c(4,2,r,o)},useMemo:function(r,o){var u=ds();return o=o===void 0?null:o,r=r(),u.memoizedState=[r,o],r},useReducer:function(r,o,u){var p=ds();return o=u!==void 0?u(o):o,p.memoizedState=p.baseState=o,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:o},p.queue=r,r=r.dispatch=pC.bind(null,sn,r),[p.memoizedState,r]},useRef:function(r){var o=ds();return r={current:r},o.memoizedState=r},useState:yv,useDebugValue:Jd,useDeferredValue:function(r){return ds().memoizedState=r},useTransition:function(){var r=yv(!1),o=r[0];return r=fC.bind(null,r[1]),ds().memoizedState=r,[o,r]},useMutableSource:function(){},useSyncExternalStore:function(r,o,u){var p=sn,v=ds();if(Zt){if(u===void 0)throw Error(n(407));u=u()}else{if(u=o(),jn===null)throw Error(n(349));(Ur&30)!==0||pv(p,o,u)}v.memoizedState=u;var S={value:u,getSnapshot:o};return v.queue=S,bv(gv.bind(null,p,S,r),[r]),p.flags|=2048,Ua(9,mv.bind(null,p,S,u,o),void 0,null),u},useId:function(){var r=ds(),o=jn.identifierPrefix;if(Zt){var u=Ps,p=js;u=(p&~(1<<32-di(p)-1)).toString(32)+u,o=":"+o+"R"+u,u=Fa++,0<u&&(o+="H"+u.toString(32)),o+=":"}else u=hC++,o=":"+o+"r"+u.toString(32)+":";return r.memoizedState=o},unstable_isNewReconciler:!1},vC={readContext:Oi,useCallback:Ev,useContext:Oi,useEffect:Qd,useImperativeHandle:kv,useInsertionEffect:Sv,useLayoutEffect:xv,useMemo:Nv,useReducer:Gd,useRef:wv,useState:function(){return Gd(Ha)},useDebugValue:Jd,useDeferredValue:function(r){var o=$i();return Lv(o,kn.memoizedState,r)},useTransition:function(){var r=Gd(Ha)[0],o=$i().memoizedState;return[r,o]},useMutableSource:hv,useSyncExternalStore:fv,useId:Rv,unstable_isNewReconciler:!1},_C={readContext:Oi,useCallback:Ev,useContext:Oi,useEffect:Qd,useImperativeHandle:kv,useInsertionEffect:Sv,useLayoutEffect:xv,useMemo:Nv,useReducer:Xd,useRef:wv,useState:function(){return Xd(Ha)},useDebugValue:Jd,useDeferredValue:function(r){var o=$i();return kn===null?o.memoizedState=r:Lv(o,kn.memoizedState,r)},useTransition:function(){var r=Xd(Ha)[0],o=$i().memoizedState;return[r,o]},useMutableSource:hv,useSyncExternalStore:fv,useId:Rv,unstable_isNewReconciler:!1};function Zi(r,o){if(r&&r.defaultProps){o=H({},o),r=r.defaultProps;for(var u in r)o[u]===void 0&&(o[u]=r[u]);return o}return o}function Zd(r,o,u,p){o=r.memoizedState,u=u(p,o),u=u==null?o:H({},o,u),r.memoizedState=u,r.lanes===0&&(r.updateQueue.baseState=u)}var bc={isMounted:function(r){return(r=r._reactInternals)?vt(r)===r:!1},enqueueSetState:function(r,o,u){r=r._reactInternals;var p=si(),v=hr(r),S=Ds(p,v);S.payload=o,u!=null&&(S.callback=u),o=lr(r,S,v),o!==null&&(ns(o,r,v,p),fc(o,r,v))},enqueueReplaceState:function(r,o,u){r=r._reactInternals;var p=si(),v=hr(r),S=Ds(p,v);S.tag=1,S.payload=o,u!=null&&(S.callback=u),o=lr(r,S,v),o!==null&&(ns(o,r,v,p),fc(o,r,v))},enqueueForceUpdate:function(r,o){r=r._reactInternals;var u=si(),p=hr(r),v=Ds(u,p);v.tag=2,o!=null&&(v.callback=o),o=lr(r,v,p),o!==null&&(ns(o,r,p,u),fc(o,r,p))}};function Pv(r,o,u,p,v,S,B){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(p,S,B):o.prototype&&o.prototype.isPureReactComponent?!Ra(u,p)||!Ra(v,S):!0}function Tv(r,o,u){var p=!1,v=rr,S=o.contextType;return typeof S=="object"&&S!==null?S=Oi(S):(v=gi(o)?Or:Qn.current,p=o.contextTypes,S=(p=p!=null)?Lo(r,v):rr),o=new o(u,S),r.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,o.updater=bc,r.stateNode=o,o._reactInternals=r,p&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=v,r.__reactInternalMemoizedMaskedChildContext=S),o}function Dv(r,o,u,p){r=o.state,typeof o.componentWillReceiveProps=="function"&&o.componentWillReceiveProps(u,p),typeof o.UNSAFE_componentWillReceiveProps=="function"&&o.UNSAFE_componentWillReceiveProps(u,p),o.state!==r&&bc.enqueueReplaceState(o,o.state,null)}function eh(r,o,u,p){var v=r.stateNode;v.props=u,v.state=r.memoizedState,v.refs={},zd(r);var S=o.contextType;typeof S=="object"&&S!==null?v.context=Oi(S):(S=gi(o)?Or:Qn.current,v.context=Lo(r,S)),v.state=r.memoizedState,S=o.getDerivedStateFromProps,typeof S=="function"&&(Zd(r,o,S,u),v.state=r.memoizedState),typeof o.getDerivedStateFromProps=="function"||typeof v.getSnapshotBeforeUpdate=="function"||typeof v.UNSAFE_componentWillMount!="function"&&typeof v.componentWillMount!="function"||(o=v.state,typeof v.componentWillMount=="function"&&v.componentWillMount(),typeof v.UNSAFE_componentWillMount=="function"&&v.UNSAFE_componentWillMount(),o!==v.state&&bc.enqueueReplaceState(v,v.state,null),pc(r,u,v,p),v.state=r.memoizedState),typeof v.componentDidMount=="function"&&(r.flags|=4194308)}function Io(r,o){try{var u="",p=o;do u+=re(p),p=p.return;while(p);var v=u}catch(S){v=`
39
- Error generating stack: `+S.message+`
40
- `+S.stack}return{value:r,source:o,stack:v,digest:null}}function th(r,o,u){return{value:r,source:null,stack:u??null,digest:o??null}}function nh(r,o){try{console.error(o.value)}catch(u){setTimeout(function(){throw u})}}var yC=typeof WeakMap=="function"?WeakMap:Map;function Iv(r,o,u){u=Ds(-1,u),u.tag=3,u.payload={element:null};var p=o.value;return u.callback=function(){Lc||(Lc=!0,vh=p),nh(r,o)},u}function Bv(r,o,u){u=Ds(-1,u),u.tag=3;var p=r.type.getDerivedStateFromError;if(typeof p=="function"){var v=o.value;u.payload=function(){return p(v)},u.callback=function(){nh(r,o)}}var S=r.stateNode;return S!==null&&typeof S.componentDidCatch=="function"&&(u.callback=function(){nh(r,o),typeof p!="function"&&(ur===null?ur=new Set([this]):ur.add(this));var B=o.stack;this.componentDidCatch(o.value,{componentStack:B!==null?B:""})}),u}function Ov(r,o,u){var p=r.pingCache;if(p===null){p=r.pingCache=new yC;var v=new Set;p.set(o,v)}else v=p.get(o),v===void 0&&(v=new Set,p.set(o,v));v.has(u)||(v.add(u),r=PC.bind(null,r,o,u),o.then(r,r))}function $v(r){do{var o;if((o=r.tag===13)&&(o=r.memoizedState,o=o!==null?o.dehydrated!==null:!0),o)return r;r=r.return}while(r!==null);return null}function zv(r,o,u,p,v){return(r.mode&1)===0?(r===o?r.flags|=65536:(r.flags|=128,u.flags|=131072,u.flags&=-52805,u.tag===1&&(u.alternate===null?u.tag=17:(o=Ds(-1,1),o.tag=2,lr(u,o,1))),u.lanes|=1),r):(r.flags|=65536,r.lanes=v,r)}var wC=T.ReactCurrentOwner,vi=!1;function ii(r,o,u,p){o.child=r===null?ov(o,null,u,p):jo(o,r.child,u,p)}function Fv(r,o,u,p,v){u=u.render;var S=o.ref;return To(o,v),p=Vd(r,o,u,p,S,v),u=Yd(),r!==null&&!vi?(o.updateQueue=r.updateQueue,o.flags&=-2053,r.lanes&=~v,Is(r,o,v)):(Zt&&u&&Md(o),o.flags|=1,ii(r,o,p,v),o.child)}function Hv(r,o,u,p,v){if(r===null){var S=u.type;return typeof S=="function"&&!Ch(S)&&S.defaultProps===void 0&&u.compare===null&&u.defaultProps===void 0?(o.tag=15,o.type=S,Uv(r,o,S,p,v)):(r=Tc(u.type,null,p,o,o.mode,v),r.ref=o.ref,r.return=o,o.child=r)}if(S=r.child,(r.lanes&v)===0){var B=S.memoizedProps;if(u=u.compare,u=u!==null?u:Ra,u(B,p)&&r.ref===o.ref)return Is(r,o,v)}return o.flags|=1,r=pr(S,p),r.ref=o.ref,r.return=o,o.child=r}function Uv(r,o,u,p,v){if(r!==null){var S=r.memoizedProps;if(Ra(S,p)&&r.ref===o.ref)if(vi=!1,o.pendingProps=p=S,(r.lanes&v)!==0)(r.flags&131072)!==0&&(vi=!0);else return o.lanes=r.lanes,Is(r,o,v)}return ih(r,o,u,p,v)}function Wv(r,o,u){var p=o.pendingProps,v=p.children,S=r!==null?r.memoizedState:null;if(p.mode==="hidden")if((o.mode&1)===0)o.memoizedState={baseLanes:0,cachePool:null,transitions:null},qt(Oo,Ri),Ri|=u;else{if((u&1073741824)===0)return r=S!==null?S.baseLanes|u:u,o.lanes=o.childLanes=1073741824,o.memoizedState={baseLanes:r,cachePool:null,transitions:null},o.updateQueue=null,qt(Oo,Ri),Ri|=r,null;o.memoizedState={baseLanes:0,cachePool:null,transitions:null},p=S!==null?S.baseLanes:u,qt(Oo,Ri),Ri|=p}else S!==null?(p=S.baseLanes|u,o.memoizedState=null):p=u,qt(Oo,Ri),Ri|=p;return ii(r,o,v,u),o.child}function qv(r,o){var u=o.ref;(r===null&&u!==null||r!==null&&r.ref!==u)&&(o.flags|=512,o.flags|=2097152)}function ih(r,o,u,p,v){var S=gi(u)?Or:Qn.current;return S=Lo(o,S),To(o,v),u=Vd(r,o,u,p,S,v),p=Yd(),r!==null&&!vi?(o.updateQueue=r.updateQueue,o.flags&=-2053,r.lanes&=~v,Is(r,o,v)):(Zt&&p&&Md(o),o.flags|=1,ii(r,o,u,v),o.child)}function Kv(r,o,u,p,v){if(gi(u)){var S=!0;rc(o)}else S=!1;if(To(o,v),o.stateNode===null)xc(r,o),Tv(o,u,p),eh(o,u,p,v),p=!0;else if(r===null){var B=o.stateNode,G=o.memoizedProps;B.props=G;var te=B.context,fe=u.contextType;typeof fe=="object"&&fe!==null?fe=Oi(fe):(fe=gi(u)?Or:Qn.current,fe=Lo(o,fe));var be=u.getDerivedStateFromProps,ke=typeof be=="function"||typeof B.getSnapshotBeforeUpdate=="function";ke||typeof B.UNSAFE_componentWillReceiveProps!="function"&&typeof B.componentWillReceiveProps!="function"||(G!==p||te!==fe)&&Dv(o,B,p,fe),ar=!1;var we=o.memoizedState;B.state=we,pc(o,p,B,v),te=o.memoizedState,G!==p||we!==te||mi.current||ar?(typeof be=="function"&&(Zd(o,u,be,p),te=o.memoizedState),(G=ar||Pv(o,u,G,p,we,te,fe))?(ke||typeof B.UNSAFE_componentWillMount!="function"&&typeof B.componentWillMount!="function"||(typeof B.componentWillMount=="function"&&B.componentWillMount(),typeof B.UNSAFE_componentWillMount=="function"&&B.UNSAFE_componentWillMount()),typeof B.componentDidMount=="function"&&(o.flags|=4194308)):(typeof B.componentDidMount=="function"&&(o.flags|=4194308),o.memoizedProps=p,o.memoizedState=te),B.props=p,B.state=te,B.context=fe,p=G):(typeof B.componentDidMount=="function"&&(o.flags|=4194308),p=!1)}else{B=o.stateNode,lv(r,o),G=o.memoizedProps,fe=o.type===o.elementType?G:Zi(o.type,G),B.props=fe,ke=o.pendingProps,we=B.context,te=u.contextType,typeof te=="object"&&te!==null?te=Oi(te):(te=gi(u)?Or:Qn.current,te=Lo(o,te));var He=u.getDerivedStateFromProps;(be=typeof He=="function"||typeof B.getSnapshotBeforeUpdate=="function")||typeof B.UNSAFE_componentWillReceiveProps!="function"&&typeof B.componentWillReceiveProps!="function"||(G!==ke||we!==te)&&Dv(o,B,p,te),ar=!1,we=o.memoizedState,B.state=we,pc(o,p,B,v);var Ve=o.memoizedState;G!==ke||we!==Ve||mi.current||ar?(typeof He=="function"&&(Zd(o,u,He,p),Ve=o.memoizedState),(fe=ar||Pv(o,u,fe,p,we,Ve,te)||!1)?(be||typeof B.UNSAFE_componentWillUpdate!="function"&&typeof B.componentWillUpdate!="function"||(typeof B.componentWillUpdate=="function"&&B.componentWillUpdate(p,Ve,te),typeof B.UNSAFE_componentWillUpdate=="function"&&B.UNSAFE_componentWillUpdate(p,Ve,te)),typeof B.componentDidUpdate=="function"&&(o.flags|=4),typeof B.getSnapshotBeforeUpdate=="function"&&(o.flags|=1024)):(typeof B.componentDidUpdate!="function"||G===r.memoizedProps&&we===r.memoizedState||(o.flags|=4),typeof B.getSnapshotBeforeUpdate!="function"||G===r.memoizedProps&&we===r.memoizedState||(o.flags|=1024),o.memoizedProps=p,o.memoizedState=Ve),B.props=p,B.state=Ve,B.context=te,p=fe):(typeof B.componentDidUpdate!="function"||G===r.memoizedProps&&we===r.memoizedState||(o.flags|=4),typeof B.getSnapshotBeforeUpdate!="function"||G===r.memoizedProps&&we===r.memoizedState||(o.flags|=1024),p=!1)}return sh(r,o,u,p,S,v)}function sh(r,o,u,p,v,S){qv(r,o);var B=(o.flags&128)!==0;if(!p&&!B)return v&&Qg(o,u,!1),Is(r,o,S);p=o.stateNode,wC.current=o;var G=B&&typeof u.getDerivedStateFromError!="function"?null:p.render();return o.flags|=1,r!==null&&B?(o.child=jo(o,r.child,null,S),o.child=jo(o,null,G,S)):ii(r,o,G,S),o.memoizedState=p.state,v&&Qg(o,u,!0),o.child}function Vv(r){var o=r.stateNode;o.pendingContext?Gg(r,o.pendingContext,o.pendingContext!==o.context):o.context&&Gg(r,o.context,!1),Fd(r,o.containerInfo)}function Yv(r,o,u,p,v){return Ao(),Td(v),o.flags|=256,ii(r,o,u,p),o.child}var rh={dehydrated:null,treeContext:null,retryLane:0};function oh(r){return{baseLanes:r,cachePool:null,transitions:null}}function Gv(r,o,u){var p=o.pendingProps,v=nn.current,S=!1,B=(o.flags&128)!==0,G;if((G=B)||(G=r!==null&&r.memoizedState===null?!1:(v&2)!==0),G?(S=!0,o.flags&=-129):(r===null||r.memoizedState!==null)&&(v|=1),qt(nn,v&1),r===null)return Pd(o),r=o.memoizedState,r!==null&&(r=r.dehydrated,r!==null)?((o.mode&1)===0?o.lanes=1:r.data==="$!"?o.lanes=8:o.lanes=1073741824,null):(B=p.children,r=p.fallback,S?(p=o.mode,S=o.child,B={mode:"hidden",children:B},(p&1)===0&&S!==null?(S.childLanes=0,S.pendingProps=B):S=Dc(B,p,0,null),r=Yr(r,p,u,null),S.return=o,r.return=o,S.sibling=r,o.child=S,o.child.memoizedState=oh(u),o.memoizedState=rh,r):ah(o,B));if(v=r.memoizedState,v!==null&&(G=v.dehydrated,G!==null))return bC(r,o,B,p,G,v,u);if(S){S=p.fallback,B=o.mode,v=r.child,G=v.sibling;var te={mode:"hidden",children:p.children};return(B&1)===0&&o.child!==v?(p=o.child,p.childLanes=0,p.pendingProps=te,o.deletions=null):(p=pr(v,te),p.subtreeFlags=v.subtreeFlags&14680064),G!==null?S=pr(G,S):(S=Yr(S,B,u,null),S.flags|=2),S.return=o,p.return=o,p.sibling=S,o.child=p,p=S,S=o.child,B=r.child.memoizedState,B=B===null?oh(u):{baseLanes:B.baseLanes|u,cachePool:null,transitions:B.transitions},S.memoizedState=B,S.childLanes=r.childLanes&~u,o.memoizedState=rh,p}return S=r.child,r=S.sibling,p=pr(S,{mode:"visible",children:p.children}),(o.mode&1)===0&&(p.lanes=u),p.return=o,p.sibling=null,r!==null&&(u=o.deletions,u===null?(o.deletions=[r],o.flags|=16):u.push(r)),o.child=p,o.memoizedState=null,p}function ah(r,o){return o=Dc({mode:"visible",children:o},r.mode,0,null),o.return=r,r.child=o}function Sc(r,o,u,p){return p!==null&&Td(p),jo(o,r.child,null,u),r=ah(o,o.pendingProps.children),r.flags|=2,o.memoizedState=null,r}function bC(r,o,u,p,v,S,B){if(u)return o.flags&256?(o.flags&=-257,p=th(Error(n(422))),Sc(r,o,B,p)):o.memoizedState!==null?(o.child=r.child,o.flags|=128,null):(S=p.fallback,v=o.mode,p=Dc({mode:"visible",children:p.children},v,0,null),S=Yr(S,v,B,null),S.flags|=2,p.return=o,S.return=o,p.sibling=S,o.child=p,(o.mode&1)!==0&&jo(o,r.child,null,B),o.child.memoizedState=oh(B),o.memoizedState=rh,S);if((o.mode&1)===0)return Sc(r,o,B,null);if(v.data==="$!"){if(p=v.nextSibling&&v.nextSibling.dataset,p)var G=p.dgst;return p=G,S=Error(n(419)),p=th(S,p,void 0),Sc(r,o,B,p)}if(G=(B&r.childLanes)!==0,vi||G){if(p=jn,p!==null){switch(B&-B){case 4:v=2;break;case 16:v=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:v=32;break;case 536870912:v=268435456;break;default:v=0}v=(v&(p.suspendedLanes|B))!==0?0:v,v!==0&&v!==S.retryLane&&(S.retryLane=v,Ts(r,v),ns(p,r,v,-1))}return xh(),p=th(Error(n(421))),Sc(r,o,B,p)}return v.data==="$?"?(o.flags|=128,o.child=r.child,o=TC.bind(null,r),v._reactRetry=o,null):(r=S.treeContext,Li=ir(v.nextSibling),Ni=o,Zt=!0,Ji=null,r!==null&&(Ii[Bi++]=js,Ii[Bi++]=Ps,Ii[Bi++]=$r,js=r.id,Ps=r.overflow,$r=o),o=ah(o,p.children),o.flags|=4096,o)}function Xv(r,o,u){r.lanes|=o;var p=r.alternate;p!==null&&(p.lanes|=o),Od(r.return,o,u)}function lh(r,o,u,p,v){var S=r.memoizedState;S===null?r.memoizedState={isBackwards:o,rendering:null,renderingStartTime:0,last:p,tail:u,tailMode:v}:(S.isBackwards=o,S.rendering=null,S.renderingStartTime=0,S.last=p,S.tail=u,S.tailMode=v)}function Qv(r,o,u){var p=o.pendingProps,v=p.revealOrder,S=p.tail;if(ii(r,o,p.children,u),p=nn.current,(p&2)!==0)p=p&1|2,o.flags|=128;else{if(r!==null&&(r.flags&128)!==0)e:for(r=o.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&Xv(r,u,o);else if(r.tag===19)Xv(r,u,o);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===o)break e;for(;r.sibling===null;){if(r.return===null||r.return===o)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}p&=1}if(qt(nn,p),(o.mode&1)===0)o.memoizedState=null;else switch(v){case"forwards":for(u=o.child,v=null;u!==null;)r=u.alternate,r!==null&&mc(r)===null&&(v=u),u=u.sibling;u=v,u===null?(v=o.child,o.child=null):(v=u.sibling,u.sibling=null),lh(o,!1,v,u,S);break;case"backwards":for(u=null,v=o.child,o.child=null;v!==null;){if(r=v.alternate,r!==null&&mc(r)===null){o.child=v;break}r=v.sibling,v.sibling=u,u=v,v=r}lh(o,!0,u,null,S);break;case"together":lh(o,!1,null,null,void 0);break;default:o.memoizedState=null}return o.child}function xc(r,o){(o.mode&1)===0&&r!==null&&(r.alternate=null,o.alternate=null,o.flags|=2)}function Is(r,o,u){if(r!==null&&(o.dependencies=r.dependencies),Wr|=o.lanes,(u&o.childLanes)===0)return null;if(r!==null&&o.child!==r.child)throw Error(n(153));if(o.child!==null){for(r=o.child,u=pr(r,r.pendingProps),o.child=u,u.return=o;r.sibling!==null;)r=r.sibling,u=u.sibling=pr(r,r.pendingProps),u.return=o;u.sibling=null}return o.child}function SC(r,o,u){switch(o.tag){case 3:Vv(o),Ao();break;case 5:dv(o);break;case 1:gi(o.type)&&rc(o);break;case 4:Fd(o,o.stateNode.containerInfo);break;case 10:var p=o.type._context,v=o.memoizedProps.value;qt(dc,p._currentValue),p._currentValue=v;break;case 13:if(p=o.memoizedState,p!==null)return p.dehydrated!==null?(qt(nn,nn.current&1),o.flags|=128,null):(u&o.child.childLanes)!==0?Gv(r,o,u):(qt(nn,nn.current&1),r=Is(r,o,u),r!==null?r.sibling:null);qt(nn,nn.current&1);break;case 19:if(p=(u&o.childLanes)!==0,(r.flags&128)!==0){if(p)return Qv(r,o,u);o.flags|=128}if(v=o.memoizedState,v!==null&&(v.rendering=null,v.tail=null,v.lastEffect=null),qt(nn,nn.current),p)break;return null;case 22:case 23:return o.lanes=0,Wv(r,o,u)}return Is(r,o,u)}var Jv,ch,Zv,e_;Jv=function(r,o){for(var u=o.child;u!==null;){if(u.tag===5||u.tag===6)r.appendChild(u.stateNode);else if(u.tag!==4&&u.child!==null){u.child.return=u,u=u.child;continue}if(u===o)break;for(;u.sibling===null;){if(u.return===null||u.return===o)return;u=u.return}u.sibling.return=u.return,u=u.sibling}},ch=function(){},Zv=function(r,o,u,p){var v=r.memoizedProps;if(v!==p){r=o.stateNode,Hr(us.current);var S=null;switch(u){case"input":v=je(r,v),p=je(r,p),S=[];break;case"select":v=H({},v,{value:void 0}),p=H({},p,{value:void 0}),S=[];break;case"textarea":v=Ut(r,v),p=Ut(r,p),S=[];break;default:typeof v.onClick!="function"&&typeof p.onClick=="function"&&(r.onclick=nc)}nt(u,p);var B;u=null;for(fe in v)if(!p.hasOwnProperty(fe)&&v.hasOwnProperty(fe)&&v[fe]!=null)if(fe==="style"){var G=v[fe];for(B in G)G.hasOwnProperty(B)&&(u||(u={}),u[B]="")}else fe!=="dangerouslySetInnerHTML"&&fe!=="children"&&fe!=="suppressContentEditableWarning"&&fe!=="suppressHydrationWarning"&&fe!=="autoFocus"&&(s.hasOwnProperty(fe)?S||(S=[]):(S=S||[]).push(fe,null));for(fe in p){var te=p[fe];if(G=v!=null?v[fe]:void 0,p.hasOwnProperty(fe)&&te!==G&&(te!=null||G!=null))if(fe==="style")if(G){for(B in G)!G.hasOwnProperty(B)||te&&te.hasOwnProperty(B)||(u||(u={}),u[B]="");for(B in te)te.hasOwnProperty(B)&&G[B]!==te[B]&&(u||(u={}),u[B]=te[B])}else u||(S||(S=[]),S.push(fe,u)),u=te;else fe==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,G=G?G.__html:void 0,te!=null&&G!==te&&(S=S||[]).push(fe,te)):fe==="children"?typeof te!="string"&&typeof te!="number"||(S=S||[]).push(fe,""+te):fe!=="suppressContentEditableWarning"&&fe!=="suppressHydrationWarning"&&(s.hasOwnProperty(fe)?(te!=null&&fe==="onScroll"&&Vt("scroll",r),S||G===te||(S=[])):(S=S||[]).push(fe,te))}u&&(S=S||[]).push("style",u);var fe=S;(o.updateQueue=fe)&&(o.flags|=4)}},e_=function(r,o,u,p){u!==p&&(o.flags|=4)};function Wa(r,o){if(!Zt)switch(r.tailMode){case"hidden":o=r.tail;for(var u=null;o!==null;)o.alternate!==null&&(u=o),o=o.sibling;u===null?r.tail=null:u.sibling=null;break;case"collapsed":u=r.tail;for(var p=null;u!==null;)u.alternate!==null&&(p=u),u=u.sibling;p===null?o||r.tail===null?r.tail=null:r.tail.sibling=null:p.sibling=null}}function Zn(r){var o=r.alternate!==null&&r.alternate.child===r.child,u=0,p=0;if(o)for(var v=r.child;v!==null;)u|=v.lanes|v.childLanes,p|=v.subtreeFlags&14680064,p|=v.flags&14680064,v.return=r,v=v.sibling;else for(v=r.child;v!==null;)u|=v.lanes|v.childLanes,p|=v.subtreeFlags,p|=v.flags,v.return=r,v=v.sibling;return r.subtreeFlags|=p,r.childLanes=u,o}function xC(r,o,u){var p=o.pendingProps;switch(Ad(o),o.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Zn(o),null;case 1:return gi(o.type)&&sc(),Zn(o),null;case 3:return p=o.stateNode,Do(),Yt(mi),Yt(Qn),Wd(),p.pendingContext&&(p.context=p.pendingContext,p.pendingContext=null),(r===null||r.child===null)&&(cc(o)?o.flags|=4:r===null||r.memoizedState.isDehydrated&&(o.flags&256)===0||(o.flags|=1024,Ji!==null&&(wh(Ji),Ji=null))),ch(r,o),Zn(o),null;case 5:Hd(o);var v=Hr($a.current);if(u=o.type,r!==null&&o.stateNode!=null)Zv(r,o,u,p,v),r.ref!==o.ref&&(o.flags|=512,o.flags|=2097152);else{if(!p){if(o.stateNode===null)throw Error(n(166));return Zn(o),null}if(r=Hr(us.current),cc(o)){p=o.stateNode,u=o.type;var S=o.memoizedProps;switch(p[cs]=o,p[Ta]=S,r=(o.mode&1)!==0,u){case"dialog":Vt("cancel",p),Vt("close",p);break;case"iframe":case"object":case"embed":Vt("load",p);break;case"video":case"audio":for(v=0;v<Aa.length;v++)Vt(Aa[v],p);break;case"source":Vt("error",p);break;case"img":case"image":case"link":Vt("error",p),Vt("load",p);break;case"details":Vt("toggle",p);break;case"input":tt(p,S),Vt("invalid",p);break;case"select":p._wrapperState={wasMultiple:!!S.multiple},Vt("invalid",p);break;case"textarea":Mt(p,S),Vt("invalid",p)}nt(u,S),v=null;for(var B in S)if(S.hasOwnProperty(B)){var G=S[B];B==="children"?typeof G=="string"?p.textContent!==G&&(S.suppressHydrationWarning!==!0&&tc(p.textContent,G,r),v=["children",G]):typeof G=="number"&&p.textContent!==""+G&&(S.suppressHydrationWarning!==!0&&tc(p.textContent,G,r),v=["children",""+G]):s.hasOwnProperty(B)&&G!=null&&B==="onScroll"&&Vt("scroll",p)}switch(u){case"input":Qe(p),ft(p,S,!0);break;case"textarea":Qe(p),tn(p);break;case"select":case"option":break;default:typeof S.onClick=="function"&&(p.onclick=nc)}p=v,o.updateQueue=p,p!==null&&(o.flags|=4)}else{B=v.nodeType===9?v:v.ownerDocument,r==="http://www.w3.org/1999/xhtml"&&(r=Ft(u)),r==="http://www.w3.org/1999/xhtml"?u==="script"?(r=B.createElement("div"),r.innerHTML="<script><\/script>",r=r.removeChild(r.firstChild)):typeof p.is=="string"?r=B.createElement(u,{is:p.is}):(r=B.createElement(u),u==="select"&&(B=r,p.multiple?B.multiple=!0:p.size&&(B.size=p.size))):r=B.createElementNS(r,u),r[cs]=o,r[Ta]=p,Jv(r,o,!1,!1),o.stateNode=r;e:{switch(B=ct(u,p),u){case"dialog":Vt("cancel",r),Vt("close",r),v=p;break;case"iframe":case"object":case"embed":Vt("load",r),v=p;break;case"video":case"audio":for(v=0;v<Aa.length;v++)Vt(Aa[v],r);v=p;break;case"source":Vt("error",r),v=p;break;case"img":case"image":case"link":Vt("error",r),Vt("load",r),v=p;break;case"details":Vt("toggle",r),v=p;break;case"input":tt(r,p),v=je(r,p),Vt("invalid",r);break;case"option":v=p;break;case"select":r._wrapperState={wasMultiple:!!p.multiple},v=H({},p,{value:void 0}),Vt("invalid",r);break;case"textarea":Mt(r,p),v=Ut(r,p),Vt("invalid",r);break;default:v=p}nt(u,v),G=v;for(S in G)if(G.hasOwnProperty(S)){var te=G[S];S==="style"?Ce(r,te):S==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,te!=null&&Te(r,te)):S==="children"?typeof te=="string"?(u!=="textarea"||te!=="")&&gt(r,te):typeof te=="number"&&gt(r,""+te):S!=="suppressContentEditableWarning"&&S!=="suppressHydrationWarning"&&S!=="autoFocus"&&(s.hasOwnProperty(S)?te!=null&&S==="onScroll"&&Vt("scroll",r):te!=null&&I(r,S,te,B))}switch(u){case"input":Qe(r),ft(r,p,!1);break;case"textarea":Qe(r),tn(r);break;case"option":p.value!=null&&r.setAttribute("value",""+oe(p.value));break;case"select":r.multiple=!!p.multiple,S=p.value,S!=null?St(r,!!p.multiple,S,!1):p.defaultValue!=null&&St(r,!!p.multiple,p.defaultValue,!0);break;default:typeof v.onClick=="function"&&(r.onclick=nc)}switch(u){case"button":case"input":case"select":case"textarea":p=!!p.autoFocus;break e;case"img":p=!0;break e;default:p=!1}}p&&(o.flags|=4)}o.ref!==null&&(o.flags|=512,o.flags|=2097152)}return Zn(o),null;case 6:if(r&&o.stateNode!=null)e_(r,o,r.memoizedProps,p);else{if(typeof p!="string"&&o.stateNode===null)throw Error(n(166));if(u=Hr($a.current),Hr(us.current),cc(o)){if(p=o.stateNode,u=o.memoizedProps,p[cs]=o,(S=p.nodeValue!==u)&&(r=Ni,r!==null))switch(r.tag){case 3:tc(p.nodeValue,u,(r.mode&1)!==0);break;case 5:r.memoizedProps.suppressHydrationWarning!==!0&&tc(p.nodeValue,u,(r.mode&1)!==0)}S&&(o.flags|=4)}else p=(u.nodeType===9?u:u.ownerDocument).createTextNode(p),p[cs]=o,o.stateNode=p}return Zn(o),null;case 13:if(Yt(nn),p=o.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(Zt&&Li!==null&&(o.mode&1)!==0&&(o.flags&128)===0)iv(),Ao(),o.flags|=98560,S=!1;else if(S=cc(o),p!==null&&p.dehydrated!==null){if(r===null){if(!S)throw Error(n(318));if(S=o.memoizedState,S=S!==null?S.dehydrated:null,!S)throw Error(n(317));S[cs]=o}else Ao(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;Zn(o),S=!1}else Ji!==null&&(wh(Ji),Ji=null),S=!0;if(!S)return o.flags&65536?o:null}return(o.flags&128)!==0?(o.lanes=u,o):(p=p!==null,p!==(r!==null&&r.memoizedState!==null)&&p&&(o.child.flags|=8192,(o.mode&1)!==0&&(r===null||(nn.current&1)!==0?En===0&&(En=3):xh())),o.updateQueue!==null&&(o.flags|=4),Zn(o),null);case 4:return Do(),ch(r,o),r===null&&ja(o.stateNode.containerInfo),Zn(o),null;case 10:return Bd(o.type._context),Zn(o),null;case 17:return gi(o.type)&&sc(),Zn(o),null;case 19:if(Yt(nn),S=o.memoizedState,S===null)return Zn(o),null;if(p=(o.flags&128)!==0,B=S.rendering,B===null)if(p)Wa(S,!1);else{if(En!==0||r!==null&&(r.flags&128)!==0)for(r=o.child;r!==null;){if(B=mc(r),B!==null){for(o.flags|=128,Wa(S,!1),p=B.updateQueue,p!==null&&(o.updateQueue=p,o.flags|=4),o.subtreeFlags=0,p=u,u=o.child;u!==null;)S=u,r=p,S.flags&=14680066,B=S.alternate,B===null?(S.childLanes=0,S.lanes=r,S.child=null,S.subtreeFlags=0,S.memoizedProps=null,S.memoizedState=null,S.updateQueue=null,S.dependencies=null,S.stateNode=null):(S.childLanes=B.childLanes,S.lanes=B.lanes,S.child=B.child,S.subtreeFlags=0,S.deletions=null,S.memoizedProps=B.memoizedProps,S.memoizedState=B.memoizedState,S.updateQueue=B.updateQueue,S.type=B.type,r=B.dependencies,S.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),u=u.sibling;return qt(nn,nn.current&1|2),o.child}r=r.sibling}S.tail!==null&&Wt()>$o&&(o.flags|=128,p=!0,Wa(S,!1),o.lanes=4194304)}else{if(!p)if(r=mc(B),r!==null){if(o.flags|=128,p=!0,u=r.updateQueue,u!==null&&(o.updateQueue=u,o.flags|=4),Wa(S,!0),S.tail===null&&S.tailMode==="hidden"&&!B.alternate&&!Zt)return Zn(o),null}else 2*Wt()-S.renderingStartTime>$o&&u!==1073741824&&(o.flags|=128,p=!0,Wa(S,!1),o.lanes=4194304);S.isBackwards?(B.sibling=o.child,o.child=B):(u=S.last,u!==null?u.sibling=B:o.child=B,S.last=B)}return S.tail!==null?(o=S.tail,S.rendering=o,S.tail=o.sibling,S.renderingStartTime=Wt(),o.sibling=null,u=nn.current,qt(nn,p?u&1|2:u&1),o):(Zn(o),null);case 22:case 23:return Sh(),p=o.memoizedState!==null,r!==null&&r.memoizedState!==null!==p&&(o.flags|=8192),p&&(o.mode&1)!==0?(Ri&1073741824)!==0&&(Zn(o),o.subtreeFlags&6&&(o.flags|=8192)):Zn(o),null;case 24:return null;case 25:return null}throw Error(n(156,o.tag))}function CC(r,o){switch(Ad(o),o.tag){case 1:return gi(o.type)&&sc(),r=o.flags,r&65536?(o.flags=r&-65537|128,o):null;case 3:return Do(),Yt(mi),Yt(Qn),Wd(),r=o.flags,(r&65536)!==0&&(r&128)===0?(o.flags=r&-65537|128,o):null;case 5:return Hd(o),null;case 13:if(Yt(nn),r=o.memoizedState,r!==null&&r.dehydrated!==null){if(o.alternate===null)throw Error(n(340));Ao()}return r=o.flags,r&65536?(o.flags=r&-65537|128,o):null;case 19:return Yt(nn),null;case 4:return Do(),null;case 10:return Bd(o.type._context),null;case 22:case 23:return Sh(),null;case 24:return null;default:return null}}var Cc=!1,ei=!1,kC=typeof WeakSet=="function"?WeakSet:Set,qe=null;function Bo(r,o){var u=r.ref;if(u!==null)if(typeof u=="function")try{u(null)}catch(p){un(r,o,p)}else u.current=null}function uh(r,o,u){try{u()}catch(p){un(r,o,p)}}var t_=!1;function EC(r,o){if(Sd=Jt,r=Pg(),pd(r)){if("selectionStart"in r)var u={start:r.selectionStart,end:r.selectionEnd};else e:{u=(u=r.ownerDocument)&&u.defaultView||window;var p=u.getSelection&&u.getSelection();if(p&&p.rangeCount!==0){u=p.anchorNode;var v=p.anchorOffset,S=p.focusNode;p=p.focusOffset;try{u.nodeType,S.nodeType}catch{u=null;break e}var B=0,G=-1,te=-1,fe=0,be=0,ke=r,we=null;t:for(;;){for(var He;ke!==u||v!==0&&ke.nodeType!==3||(G=B+v),ke!==S||p!==0&&ke.nodeType!==3||(te=B+p),ke.nodeType===3&&(B+=ke.nodeValue.length),(He=ke.firstChild)!==null;)we=ke,ke=He;for(;;){if(ke===r)break t;if(we===u&&++fe===v&&(G=B),we===S&&++be===p&&(te=B),(He=ke.nextSibling)!==null)break;ke=we,we=ke.parentNode}ke=He}u=G===-1||te===-1?null:{start:G,end:te}}else u=null}u=u||{start:0,end:0}}else u=null;for(xd={focusedElem:r,selectionRange:u},Jt=!1,qe=o;qe!==null;)if(o=qe,r=o.child,(o.subtreeFlags&1028)!==0&&r!==null)r.return=o,qe=r;else for(;qe!==null;){o=qe;try{var Ve=o.alternate;if((o.flags&1024)!==0)switch(o.tag){case 0:case 11:case 15:break;case 1:if(Ve!==null){var Ye=Ve.memoizedProps,_n=Ve.memoizedState,ue=o.stateNode,se=ue.getSnapshotBeforeUpdate(o.elementType===o.type?Ye:Zi(o.type,Ye),_n);ue.__reactInternalSnapshotBeforeUpdate=se}break;case 3:var he=o.stateNode.containerInfo;he.nodeType===1?he.textContent="":he.nodeType===9&&he.documentElement&&he.removeChild(he.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Ne){un(o,o.return,Ne)}if(r=o.sibling,r!==null){r.return=o.return,qe=r;break}qe=o.return}return Ve=t_,t_=!1,Ve}function qa(r,o,u){var p=o.updateQueue;if(p=p!==null?p.lastEffect:null,p!==null){var v=p=p.next;do{if((v.tag&r)===r){var S=v.destroy;v.destroy=void 0,S!==void 0&&uh(o,u,S)}v=v.next}while(v!==p)}}function kc(r,o){if(o=o.updateQueue,o=o!==null?o.lastEffect:null,o!==null){var u=o=o.next;do{if((u.tag&r)===r){var p=u.create;u.destroy=p()}u=u.next}while(u!==o)}}function dh(r){var o=r.ref;if(o!==null){var u=r.stateNode;switch(r.tag){case 5:r=u;break;default:r=u}typeof o=="function"?o(r):o.current=r}}function n_(r){var o=r.alternate;o!==null&&(r.alternate=null,n_(o)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(o=r.stateNode,o!==null&&(delete o[cs],delete o[Ta],delete o[Nd],delete o[lC],delete o[cC])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function i_(r){return r.tag===5||r.tag===3||r.tag===4}function s_(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||i_(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function hh(r,o,u){var p=r.tag;if(p===5||p===6)r=r.stateNode,o?u.nodeType===8?u.parentNode.insertBefore(r,o):u.insertBefore(r,o):(u.nodeType===8?(o=u.parentNode,o.insertBefore(r,u)):(o=u,o.appendChild(r)),u=u._reactRootContainer,u!=null||o.onclick!==null||(o.onclick=nc));else if(p!==4&&(r=r.child,r!==null))for(hh(r,o,u),r=r.sibling;r!==null;)hh(r,o,u),r=r.sibling}function fh(r,o,u){var p=r.tag;if(p===5||p===6)r=r.stateNode,o?u.insertBefore(r,o):u.appendChild(r);else if(p!==4&&(r=r.child,r!==null))for(fh(r,o,u),r=r.sibling;r!==null;)fh(r,o,u),r=r.sibling}var Un=null,es=!1;function cr(r,o,u){for(u=u.child;u!==null;)r_(r,o,u),u=u.sibling}function r_(r,o,u){if(xi&&typeof xi.onCommitFiberUnmount=="function")try{xi.onCommitFiberUnmount(Pr,u)}catch{}switch(u.tag){case 5:ei||Bo(u,o);case 6:var p=Un,v=es;Un=null,cr(r,o,u),Un=p,es=v,Un!==null&&(es?(r=Un,u=u.stateNode,r.nodeType===8?r.parentNode.removeChild(u):r.removeChild(u)):Un.removeChild(u.stateNode));break;case 18:Un!==null&&(es?(r=Un,u=u.stateNode,r.nodeType===8?Ed(r.parentNode,u):r.nodeType===1&&Ed(r,u),Ht(r)):Ed(Un,u.stateNode));break;case 4:p=Un,v=es,Un=u.stateNode.containerInfo,es=!0,cr(r,o,u),Un=p,es=v;break;case 0:case 11:case 14:case 15:if(!ei&&(p=u.updateQueue,p!==null&&(p=p.lastEffect,p!==null))){v=p=p.next;do{var S=v,B=S.destroy;S=S.tag,B!==void 0&&((S&2)!==0||(S&4)!==0)&&uh(u,o,B),v=v.next}while(v!==p)}cr(r,o,u);break;case 1:if(!ei&&(Bo(u,o),p=u.stateNode,typeof p.componentWillUnmount=="function"))try{p.props=u.memoizedProps,p.state=u.memoizedState,p.componentWillUnmount()}catch(G){un(u,o,G)}cr(r,o,u);break;case 21:cr(r,o,u);break;case 22:u.mode&1?(ei=(p=ei)||u.memoizedState!==null,cr(r,o,u),ei=p):cr(r,o,u);break;default:cr(r,o,u)}}function o_(r){var o=r.updateQueue;if(o!==null){r.updateQueue=null;var u=r.stateNode;u===null&&(u=r.stateNode=new kC),o.forEach(function(p){var v=DC.bind(null,r,p);u.has(p)||(u.add(p),p.then(v,v))})}}function ts(r,o){var u=o.deletions;if(u!==null)for(var p=0;p<u.length;p++){var v=u[p];try{var S=r,B=o,G=B;e:for(;G!==null;){switch(G.tag){case 5:Un=G.stateNode,es=!1;break e;case 3:Un=G.stateNode.containerInfo,es=!0;break e;case 4:Un=G.stateNode.containerInfo,es=!0;break e}G=G.return}if(Un===null)throw Error(n(160));r_(S,B,v),Un=null,es=!1;var te=v.alternate;te!==null&&(te.return=null),v.return=null}catch(fe){un(v,o,fe)}}if(o.subtreeFlags&12854)for(o=o.child;o!==null;)a_(o,r),o=o.sibling}function a_(r,o){var u=r.alternate,p=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:if(ts(o,r),hs(r),p&4){try{qa(3,r,r.return),kc(3,r)}catch(Ye){un(r,r.return,Ye)}try{qa(5,r,r.return)}catch(Ye){un(r,r.return,Ye)}}break;case 1:ts(o,r),hs(r),p&512&&u!==null&&Bo(u,u.return);break;case 5:if(ts(o,r),hs(r),p&512&&u!==null&&Bo(u,u.return),r.flags&32){var v=r.stateNode;try{gt(v,"")}catch(Ye){un(r,r.return,Ye)}}if(p&4&&(v=r.stateNode,v!=null)){var S=r.memoizedProps,B=u!==null?u.memoizedProps:S,G=r.type,te=r.updateQueue;if(r.updateQueue=null,te!==null)try{G==="input"&&S.type==="radio"&&S.name!=null&&Nt(v,S),ct(G,B);var fe=ct(G,S);for(B=0;B<te.length;B+=2){var be=te[B],ke=te[B+1];be==="style"?Ce(v,ke):be==="dangerouslySetInnerHTML"?Te(v,ke):be==="children"?gt(v,ke):I(v,be,ke,fe)}switch(G){case"input":Ct(v,S);break;case"textarea":It(v,S);break;case"select":var we=v._wrapperState.wasMultiple;v._wrapperState.wasMultiple=!!S.multiple;var He=S.value;He!=null?St(v,!!S.multiple,He,!1):we!==!!S.multiple&&(S.defaultValue!=null?St(v,!!S.multiple,S.defaultValue,!0):St(v,!!S.multiple,S.multiple?[]:"",!1))}v[Ta]=S}catch(Ye){un(r,r.return,Ye)}}break;case 6:if(ts(o,r),hs(r),p&4){if(r.stateNode===null)throw Error(n(162));v=r.stateNode,S=r.memoizedProps;try{v.nodeValue=S}catch(Ye){un(r,r.return,Ye)}}break;case 3:if(ts(o,r),hs(r),p&4&&u!==null&&u.memoizedState.isDehydrated)try{Ht(o.containerInfo)}catch(Ye){un(r,r.return,Ye)}break;case 4:ts(o,r),hs(r);break;case 13:ts(o,r),hs(r),v=r.child,v.flags&8192&&(S=v.memoizedState!==null,v.stateNode.isHidden=S,!S||v.alternate!==null&&v.alternate.memoizedState!==null||(gh=Wt())),p&4&&o_(r);break;case 22:if(be=u!==null&&u.memoizedState!==null,r.mode&1?(ei=(fe=ei)||be,ts(o,r),ei=fe):ts(o,r),hs(r),p&8192){if(fe=r.memoizedState!==null,(r.stateNode.isHidden=fe)&&!be&&(r.mode&1)!==0)for(qe=r,be=r.child;be!==null;){for(ke=qe=be;qe!==null;){switch(we=qe,He=we.child,we.tag){case 0:case 11:case 14:case 15:qa(4,we,we.return);break;case 1:Bo(we,we.return);var Ve=we.stateNode;if(typeof Ve.componentWillUnmount=="function"){p=we,u=we.return;try{o=p,Ve.props=o.memoizedProps,Ve.state=o.memoizedState,Ve.componentWillUnmount()}catch(Ye){un(p,u,Ye)}}break;case 5:Bo(we,we.return);break;case 22:if(we.memoizedState!==null){u_(ke);continue}}He!==null?(He.return=we,qe=He):u_(ke)}be=be.sibling}e:for(be=null,ke=r;;){if(ke.tag===5){if(be===null){be=ke;try{v=ke.stateNode,fe?(S=v.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none"):(G=ke.stateNode,te=ke.memoizedProps.style,B=te!=null&&te.hasOwnProperty("display")?te.display:null,G.style.display=ge("display",B))}catch(Ye){un(r,r.return,Ye)}}}else if(ke.tag===6){if(be===null)try{ke.stateNode.nodeValue=fe?"":ke.memoizedProps}catch(Ye){un(r,r.return,Ye)}}else if((ke.tag!==22&&ke.tag!==23||ke.memoizedState===null||ke===r)&&ke.child!==null){ke.child.return=ke,ke=ke.child;continue}if(ke===r)break e;for(;ke.sibling===null;){if(ke.return===null||ke.return===r)break e;be===ke&&(be=null),ke=ke.return}be===ke&&(be=null),ke.sibling.return=ke.return,ke=ke.sibling}}break;case 19:ts(o,r),hs(r),p&4&&o_(r);break;case 21:break;default:ts(o,r),hs(r)}}function hs(r){var o=r.flags;if(o&2){try{e:{for(var u=r.return;u!==null;){if(i_(u)){var p=u;break e}u=u.return}throw Error(n(160))}switch(p.tag){case 5:var v=p.stateNode;p.flags&32&&(gt(v,""),p.flags&=-33);var S=s_(r);fh(r,S,v);break;case 3:case 4:var B=p.stateNode.containerInfo,G=s_(r);hh(r,G,B);break;default:throw Error(n(161))}}catch(te){un(r,r.return,te)}r.flags&=-3}o&4096&&(r.flags&=-4097)}function NC(r,o,u){qe=r,l_(r)}function l_(r,o,u){for(var p=(r.mode&1)!==0;qe!==null;){var v=qe,S=v.child;if(v.tag===22&&p){var B=v.memoizedState!==null||Cc;if(!B){var G=v.alternate,te=G!==null&&G.memoizedState!==null||ei;G=Cc;var fe=ei;if(Cc=B,(ei=te)&&!fe)for(qe=v;qe!==null;)B=qe,te=B.child,B.tag===22&&B.memoizedState!==null?d_(v):te!==null?(te.return=B,qe=te):d_(v);for(;S!==null;)qe=S,l_(S),S=S.sibling;qe=v,Cc=G,ei=fe}c_(r)}else(v.subtreeFlags&8772)!==0&&S!==null?(S.return=v,qe=S):c_(r)}}function c_(r){for(;qe!==null;){var o=qe;if((o.flags&8772)!==0){var u=o.alternate;try{if((o.flags&8772)!==0)switch(o.tag){case 0:case 11:case 15:ei||kc(5,o);break;case 1:var p=o.stateNode;if(o.flags&4&&!ei)if(u===null)p.componentDidMount();else{var v=o.elementType===o.type?u.memoizedProps:Zi(o.type,u.memoizedProps);p.componentDidUpdate(v,u.memoizedState,p.__reactInternalSnapshotBeforeUpdate)}var S=o.updateQueue;S!==null&&uv(o,S,p);break;case 3:var B=o.updateQueue;if(B!==null){if(u=null,o.child!==null)switch(o.child.tag){case 5:u=o.child.stateNode;break;case 1:u=o.child.stateNode}uv(o,B,u)}break;case 5:var G=o.stateNode;if(u===null&&o.flags&4){u=G;var te=o.memoizedProps;switch(o.type){case"button":case"input":case"select":case"textarea":te.autoFocus&&u.focus();break;case"img":te.src&&(u.src=te.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(o.memoizedState===null){var fe=o.alternate;if(fe!==null){var be=fe.memoizedState;if(be!==null){var ke=be.dehydrated;ke!==null&&Ht(ke)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}ei||o.flags&512&&dh(o)}catch(we){un(o,o.return,we)}}if(o===r){qe=null;break}if(u=o.sibling,u!==null){u.return=o.return,qe=u;break}qe=o.return}}function u_(r){for(;qe!==null;){var o=qe;if(o===r){qe=null;break}var u=o.sibling;if(u!==null){u.return=o.return,qe=u;break}qe=o.return}}function d_(r){for(;qe!==null;){var o=qe;try{switch(o.tag){case 0:case 11:case 15:var u=o.return;try{kc(4,o)}catch(te){un(o,u,te)}break;case 1:var p=o.stateNode;if(typeof p.componentDidMount=="function"){var v=o.return;try{p.componentDidMount()}catch(te){un(o,v,te)}}var S=o.return;try{dh(o)}catch(te){un(o,S,te)}break;case 5:var B=o.return;try{dh(o)}catch(te){un(o,B,te)}}}catch(te){un(o,o.return,te)}if(o===r){qe=null;break}var G=o.sibling;if(G!==null){G.return=o.return,qe=G;break}qe=o.return}}var LC=Math.ceil,Ec=T.ReactCurrentDispatcher,ph=T.ReactCurrentOwner,zi=T.ReactCurrentBatchConfig,At=0,jn=null,bn=null,Wn=0,Ri=0,Oo=sr(0),En=0,Ka=null,Wr=0,Nc=0,mh=0,Va=null,_i=null,gh=0,$o=1/0,Bs=null,Lc=!1,vh=null,ur=null,Rc=!1,dr=null,Mc=0,Ya=0,_h=null,Ac=-1,jc=0;function si(){return(At&6)!==0?Wt():Ac!==-1?Ac:Ac=Wt()}function hr(r){return(r.mode&1)===0?1:(At&2)!==0&&Wn!==0?Wn&-Wn:dC.transition!==null?(jc===0&&(jc=os()),jc):(r=xt,r!==0||(r=window.event,r=r===void 0?16:fg(r.type)),r)}function ns(r,o,u,p){if(50<Ya)throw Ya=0,_h=null,Error(n(185));Zs(r,u,p),((At&2)===0||r!==jn)&&(r===jn&&((At&2)===0&&(Nc|=u),En===4&&fr(r,Wn)),yi(r,p),u===1&&At===0&&(o.mode&1)===0&&($o=Wt()+500,oc&&or()))}function yi(r,o){var u=r.callbackNode;Wl(r,o);var p=Ir(r,r===jn?Wn:0);if(p===0)u!==null&&wt(u),r.callbackNode=null,r.callbackPriority=0;else if(o=p&-p,r.callbackPriority!==o){if(u!=null&&wt(u),o===1)r.tag===0?uC(f_.bind(null,r)):Jg(f_.bind(null,r)),oC(function(){(At&6)===0&&or()}),u=null;else{switch(ya(p)){case 1:u=Di;break;case 4:u=Gi;break;case 16:u=go;break;case 536870912:u=jr;break;default:u=go}u=b_(u,h_.bind(null,r))}r.callbackPriority=o,r.callbackNode=u}}function h_(r,o){if(Ac=-1,jc=0,(At&6)!==0)throw Error(n(327));var u=r.callbackNode;if(zo()&&r.callbackNode!==u)return null;var p=Ir(r,r===jn?Wn:0);if(p===0)return null;if((p&30)!==0||(p&r.expiredLanes)!==0||o)o=Pc(r,p);else{o=p;var v=At;At|=2;var S=m_();(jn!==r||Wn!==o)&&(Bs=null,$o=Wt()+500,Kr(r,o));do try{AC();break}catch(G){p_(r,G)}while(!0);Id(),Ec.current=S,At=v,bn!==null?o=0:(jn=null,Wn=0,o=En)}if(o!==0){if(o===2&&(v=Qs(r),v!==0&&(p=v,o=yh(r,v))),o===1)throw u=Ka,Kr(r,0),fr(r,p),yi(r,Wt()),u;if(o===6)fr(r,p);else{if(v=r.current.alternate,(p&30)===0&&!RC(v)&&(o=Pc(r,p),o===2&&(S=Qs(r),S!==0&&(p=S,o=yh(r,S))),o===1))throw u=Ka,Kr(r,0),fr(r,p),yi(r,Wt()),u;switch(r.finishedWork=v,r.finishedLanes=p,o){case 0:case 1:throw Error(n(345));case 2:Vr(r,_i,Bs);break;case 3:if(fr(r,p),(p&130023424)===p&&(o=gh+500-Wt(),10<o)){if(Ir(r,0)!==0)break;if(v=r.suspendedLanes,(v&p)!==p){si(),r.pingedLanes|=r.suspendedLanes&v;break}r.timeoutHandle=kd(Vr.bind(null,r,_i,Bs),o);break}Vr(r,_i,Bs);break;case 4:if(fr(r,p),(p&4194240)===p)break;for(o=r.eventTimes,v=-1;0<p;){var B=31-di(p);S=1<<B,B=o[B],B>v&&(v=B),p&=~S}if(p=v,p=Wt()-p,p=(120>p?120:480>p?480:1080>p?1080:1920>p?1920:3e3>p?3e3:4320>p?4320:1960*LC(p/1960))-p,10<p){r.timeoutHandle=kd(Vr.bind(null,r,_i,Bs),p);break}Vr(r,_i,Bs);break;case 5:Vr(r,_i,Bs);break;default:throw Error(n(329))}}}return yi(r,Wt()),r.callbackNode===u?h_.bind(null,r):null}function yh(r,o){var u=Va;return r.current.memoizedState.isDehydrated&&(Kr(r,o).flags|=256),r=Pc(r,o),r!==2&&(o=_i,_i=u,o!==null&&wh(o)),r}function wh(r){_i===null?_i=r:_i.push.apply(_i,r)}function RC(r){for(var o=r;;){if(o.flags&16384){var u=o.updateQueue;if(u!==null&&(u=u.stores,u!==null))for(var p=0;p<u.length;p++){var v=u[p],S=v.getSnapshot;v=v.value;try{if(!Qi(S(),v))return!1}catch{return!1}}}if(u=o.child,o.subtreeFlags&16384&&u!==null)u.return=o,o=u;else{if(o===r)break;for(;o.sibling===null;){if(o.return===null||o.return===r)return!0;o=o.return}o.sibling.return=o.return,o=o.sibling}}return!0}function fr(r,o){for(o&=~mh,o&=~Nc,r.suspendedLanes|=o,r.pingedLanes&=~o,r=r.expirationTimes;0<o;){var u=31-di(o),p=1<<u;r[u]=-1,o&=~p}}function f_(r){if((At&6)!==0)throw Error(n(327));zo();var o=Ir(r,0);if((o&1)===0)return yi(r,Wt()),null;var u=Pc(r,o);if(r.tag!==0&&u===2){var p=Qs(r);p!==0&&(o=p,u=yh(r,p))}if(u===1)throw u=Ka,Kr(r,0),fr(r,o),yi(r,Wt()),u;if(u===6)throw Error(n(345));return r.finishedWork=r.current.alternate,r.finishedLanes=o,Vr(r,_i,Bs),yi(r,Wt()),null}function bh(r,o){var u=At;At|=1;try{return r(o)}finally{At=u,At===0&&($o=Wt()+500,oc&&or())}}function qr(r){dr!==null&&dr.tag===0&&(At&6)===0&&zo();var o=At;At|=1;var u=zi.transition,p=xt;try{if(zi.transition=null,xt=1,r)return r()}finally{xt=p,zi.transition=u,At=o,(At&6)===0&&or()}}function Sh(){Ri=Oo.current,Yt(Oo)}function Kr(r,o){r.finishedWork=null,r.finishedLanes=0;var u=r.timeoutHandle;if(u!==-1&&(r.timeoutHandle=-1,rC(u)),bn!==null)for(u=bn.return;u!==null;){var p=u;switch(Ad(p),p.tag){case 1:p=p.type.childContextTypes,p!=null&&sc();break;case 3:Do(),Yt(mi),Yt(Qn),Wd();break;case 5:Hd(p);break;case 4:Do();break;case 13:Yt(nn);break;case 19:Yt(nn);break;case 10:Bd(p.type._context);break;case 22:case 23:Sh()}u=u.return}if(jn=r,bn=r=pr(r.current,null),Wn=Ri=o,En=0,Ka=null,mh=Nc=Wr=0,_i=Va=null,Fr!==null){for(o=0;o<Fr.length;o++)if(u=Fr[o],p=u.interleaved,p!==null){u.interleaved=null;var v=p.next,S=u.pending;if(S!==null){var B=S.next;S.next=v,p.next=B}u.pending=p}Fr=null}return r}function p_(r,o){do{var u=bn;try{if(Id(),gc.current=wc,vc){for(var p=sn.memoizedState;p!==null;){var v=p.queue;v!==null&&(v.pending=null),p=p.next}vc=!1}if(Ur=0,An=kn=sn=null,za=!1,Fa=0,ph.current=null,u===null||u.return===null){En=1,Ka=o,bn=null;break}e:{var S=r,B=u.return,G=u,te=o;if(o=Wn,G.flags|=32768,te!==null&&typeof te=="object"&&typeof te.then=="function"){var fe=te,be=G,ke=be.tag;if((be.mode&1)===0&&(ke===0||ke===11||ke===15)){var we=be.alternate;we?(be.updateQueue=we.updateQueue,be.memoizedState=we.memoizedState,be.lanes=we.lanes):(be.updateQueue=null,be.memoizedState=null)}var He=$v(B);if(He!==null){He.flags&=-257,zv(He,B,G,S,o),He.mode&1&&Ov(S,fe,o),o=He,te=fe;var Ve=o.updateQueue;if(Ve===null){var Ye=new Set;Ye.add(te),o.updateQueue=Ye}else Ve.add(te);break e}else{if((o&1)===0){Ov(S,fe,o),xh();break e}te=Error(n(426))}}else if(Zt&&G.mode&1){var _n=$v(B);if(_n!==null){(_n.flags&65536)===0&&(_n.flags|=256),zv(_n,B,G,S,o),Td(Io(te,G));break e}}S=te=Io(te,G),En!==4&&(En=2),Va===null?Va=[S]:Va.push(S),S=B;do{switch(S.tag){case 3:S.flags|=65536,o&=-o,S.lanes|=o;var ue=Iv(S,te,o);cv(S,ue);break e;case 1:G=te;var se=S.type,he=S.stateNode;if((S.flags&128)===0&&(typeof se.getDerivedStateFromError=="function"||he!==null&&typeof he.componentDidCatch=="function"&&(ur===null||!ur.has(he)))){S.flags|=65536,o&=-o,S.lanes|=o;var Ne=Bv(S,G,o);cv(S,Ne);break e}}S=S.return}while(S!==null)}v_(u)}catch(Xe){o=Xe,bn===u&&u!==null&&(bn=u=u.return);continue}break}while(!0)}function m_(){var r=Ec.current;return Ec.current=wc,r===null?wc:r}function xh(){(En===0||En===3||En===2)&&(En=4),jn===null||(Wr&268435455)===0&&(Nc&268435455)===0||fr(jn,Wn)}function Pc(r,o){var u=At;At|=2;var p=m_();(jn!==r||Wn!==o)&&(Bs=null,Kr(r,o));do try{MC();break}catch(v){p_(r,v)}while(!0);if(Id(),At=u,Ec.current=p,bn!==null)throw Error(n(261));return jn=null,Wn=0,En}function MC(){for(;bn!==null;)g_(bn)}function AC(){for(;bn!==null&&!cn();)g_(bn)}function g_(r){var o=w_(r.alternate,r,Ri);r.memoizedProps=r.pendingProps,o===null?v_(r):bn=o,ph.current=null}function v_(r){var o=r;do{var u=o.alternate;if(r=o.return,(o.flags&32768)===0){if(u=xC(u,o,Ri),u!==null){bn=u;return}}else{if(u=CC(u,o),u!==null){u.flags&=32767,bn=u;return}if(r!==null)r.flags|=32768,r.subtreeFlags=0,r.deletions=null;else{En=6,bn=null;return}}if(o=o.sibling,o!==null){bn=o;return}bn=o=r}while(o!==null);En===0&&(En=5)}function Vr(r,o,u){var p=xt,v=zi.transition;try{zi.transition=null,xt=1,jC(r,o,u,p)}finally{zi.transition=v,xt=p}return null}function jC(r,o,u,p){do zo();while(dr!==null);if((At&6)!==0)throw Error(n(327));u=r.finishedWork;var v=r.finishedLanes;if(u===null)return null;if(r.finishedWork=null,r.finishedLanes=0,u===r.current)throw Error(n(177));r.callbackNode=null,r.callbackPriority=0;var S=u.lanes|u.childLanes;if(_a(r,S),r===jn&&(bn=jn=null,Wn=0),(u.subtreeFlags&2064)===0&&(u.flags&2064)===0||Rc||(Rc=!0,b_(go,function(){return zo(),null})),S=(u.flags&15990)!==0,(u.subtreeFlags&15990)!==0||S){S=zi.transition,zi.transition=null;var B=xt;xt=1;var G=At;At|=4,ph.current=null,EC(r,u),a_(u,r),Jx(xd),Jt=!!Sd,xd=Sd=null,r.current=u,NC(u),$t(),At=G,xt=B,zi.transition=S}else r.current=u;if(Rc&&(Rc=!1,dr=r,Mc=v),S=r.pendingLanes,S===0&&(ur=null),va(u.stateNode),yi(r,Wt()),o!==null)for(p=r.onRecoverableError,u=0;u<o.length;u++)v=o[u],p(v.value,{componentStack:v.stack,digest:v.digest});if(Lc)throw Lc=!1,r=vh,vh=null,r;return(Mc&1)!==0&&r.tag!==0&&zo(),S=r.pendingLanes,(S&1)!==0?r===_h?Ya++:(Ya=0,_h=r):Ya=0,or(),null}function zo(){if(dr!==null){var r=ya(Mc),o=zi.transition,u=xt;try{if(zi.transition=null,xt=16>r?16:r,dr===null)var p=!1;else{if(r=dr,dr=null,Mc=0,(At&6)!==0)throw Error(n(331));var v=At;for(At|=4,qe=r.current;qe!==null;){var S=qe,B=S.child;if((qe.flags&16)!==0){var G=S.deletions;if(G!==null){for(var te=0;te<G.length;te++){var fe=G[te];for(qe=fe;qe!==null;){var be=qe;switch(be.tag){case 0:case 11:case 15:qa(8,be,S)}var ke=be.child;if(ke!==null)ke.return=be,qe=ke;else for(;qe!==null;){be=qe;var we=be.sibling,He=be.return;if(n_(be),be===fe){qe=null;break}if(we!==null){we.return=He,qe=we;break}qe=He}}}var Ve=S.alternate;if(Ve!==null){var Ye=Ve.child;if(Ye!==null){Ve.child=null;do{var _n=Ye.sibling;Ye.sibling=null,Ye=_n}while(Ye!==null)}}qe=S}}if((S.subtreeFlags&2064)!==0&&B!==null)B.return=S,qe=B;else e:for(;qe!==null;){if(S=qe,(S.flags&2048)!==0)switch(S.tag){case 0:case 11:case 15:qa(9,S,S.return)}var ue=S.sibling;if(ue!==null){ue.return=S.return,qe=ue;break e}qe=S.return}}var se=r.current;for(qe=se;qe!==null;){B=qe;var he=B.child;if((B.subtreeFlags&2064)!==0&&he!==null)he.return=B,qe=he;else e:for(B=se;qe!==null;){if(G=qe,(G.flags&2048)!==0)try{switch(G.tag){case 0:case 11:case 15:kc(9,G)}}catch(Xe){un(G,G.return,Xe)}if(G===B){qe=null;break e}var Ne=G.sibling;if(Ne!==null){Ne.return=G.return,qe=Ne;break e}qe=G.return}}if(At=v,or(),xi&&typeof xi.onPostCommitFiberRoot=="function")try{xi.onPostCommitFiberRoot(Pr,r)}catch{}p=!0}return p}finally{xt=u,zi.transition=o}}return!1}function __(r,o,u){o=Io(u,o),o=Iv(r,o,1),r=lr(r,o,1),o=si(),r!==null&&(Zs(r,1,o),yi(r,o))}function un(r,o,u){if(r.tag===3)__(r,r,u);else for(;o!==null;){if(o.tag===3){__(o,r,u);break}else if(o.tag===1){var p=o.stateNode;if(typeof o.type.getDerivedStateFromError=="function"||typeof p.componentDidCatch=="function"&&(ur===null||!ur.has(p))){r=Io(u,r),r=Bv(o,r,1),o=lr(o,r,1),r=si(),o!==null&&(Zs(o,1,r),yi(o,r));break}}o=o.return}}function PC(r,o,u){var p=r.pingCache;p!==null&&p.delete(o),o=si(),r.pingedLanes|=r.suspendedLanes&u,jn===r&&(Wn&u)===u&&(En===4||En===3&&(Wn&130023424)===Wn&&500>Wt()-gh?Kr(r,0):mh|=u),yi(r,o)}function y_(r,o){o===0&&((r.mode&1)===0?o=1:(o=Dr,Dr<<=1,(Dr&130023424)===0&&(Dr=4194304)));var u=si();r=Ts(r,o),r!==null&&(Zs(r,o,u),yi(r,u))}function TC(r){var o=r.memoizedState,u=0;o!==null&&(u=o.retryLane),y_(r,u)}function DC(r,o){var u=0;switch(r.tag){case 13:var p=r.stateNode,v=r.memoizedState;v!==null&&(u=v.retryLane);break;case 19:p=r.stateNode;break;default:throw Error(n(314))}p!==null&&p.delete(o),y_(r,u)}var w_;w_=function(r,o,u){if(r!==null)if(r.memoizedProps!==o.pendingProps||mi.current)vi=!0;else{if((r.lanes&u)===0&&(o.flags&128)===0)return vi=!1,SC(r,o,u);vi=(r.flags&131072)!==0}else vi=!1,Zt&&(o.flags&1048576)!==0&&Zg(o,lc,o.index);switch(o.lanes=0,o.tag){case 2:var p=o.type;xc(r,o),r=o.pendingProps;var v=Lo(o,Qn.current);To(o,u),v=Vd(null,o,p,r,v,u);var S=Yd();return o.flags|=1,typeof v=="object"&&v!==null&&typeof v.render=="function"&&v.$$typeof===void 0?(o.tag=1,o.memoizedState=null,o.updateQueue=null,gi(p)?(S=!0,rc(o)):S=!1,o.memoizedState=v.state!==null&&v.state!==void 0?v.state:null,zd(o),v.updater=bc,o.stateNode=v,v._reactInternals=o,eh(o,p,r,u),o=sh(null,o,p,!0,S,u)):(o.tag=0,Zt&&S&&Md(o),ii(null,o,v,u),o=o.child),o;case 16:p=o.elementType;e:{switch(xc(r,o),r=o.pendingProps,v=p._init,p=v(p._payload),o.type=p,v=o.tag=BC(p),r=Zi(p,r),v){case 0:o=ih(null,o,p,r,u);break e;case 1:o=Kv(null,o,p,r,u);break e;case 11:o=Fv(null,o,p,r,u);break e;case 14:o=Hv(null,o,p,Zi(p.type,r),u);break e}throw Error(n(306,p,""))}return o;case 0:return p=o.type,v=o.pendingProps,v=o.elementType===p?v:Zi(p,v),ih(r,o,p,v,u);case 1:return p=o.type,v=o.pendingProps,v=o.elementType===p?v:Zi(p,v),Kv(r,o,p,v,u);case 3:e:{if(Vv(o),r===null)throw Error(n(387));p=o.pendingProps,S=o.memoizedState,v=S.element,lv(r,o),pc(o,p,null,u);var B=o.memoizedState;if(p=B.element,S.isDehydrated)if(S={element:p,isDehydrated:!1,cache:B.cache,pendingSuspenseBoundaries:B.pendingSuspenseBoundaries,transitions:B.transitions},o.updateQueue.baseState=S,o.memoizedState=S,o.flags&256){v=Io(Error(n(423)),o),o=Yv(r,o,p,u,v);break e}else if(p!==v){v=Io(Error(n(424)),o),o=Yv(r,o,p,u,v);break e}else for(Li=ir(o.stateNode.containerInfo.firstChild),Ni=o,Zt=!0,Ji=null,u=ov(o,null,p,u),o.child=u;u;)u.flags=u.flags&-3|4096,u=u.sibling;else{if(Ao(),p===v){o=Is(r,o,u);break e}ii(r,o,p,u)}o=o.child}return o;case 5:return dv(o),r===null&&Pd(o),p=o.type,v=o.pendingProps,S=r!==null?r.memoizedProps:null,B=v.children,Cd(p,v)?B=null:S!==null&&Cd(p,S)&&(o.flags|=32),qv(r,o),ii(r,o,B,u),o.child;case 6:return r===null&&Pd(o),null;case 13:return Gv(r,o,u);case 4:return Fd(o,o.stateNode.containerInfo),p=o.pendingProps,r===null?o.child=jo(o,null,p,u):ii(r,o,p,u),o.child;case 11:return p=o.type,v=o.pendingProps,v=o.elementType===p?v:Zi(p,v),Fv(r,o,p,v,u);case 7:return ii(r,o,o.pendingProps,u),o.child;case 8:return ii(r,o,o.pendingProps.children,u),o.child;case 12:return ii(r,o,o.pendingProps.children,u),o.child;case 10:e:{if(p=o.type._context,v=o.pendingProps,S=o.memoizedProps,B=v.value,qt(dc,p._currentValue),p._currentValue=B,S!==null)if(Qi(S.value,B)){if(S.children===v.children&&!mi.current){o=Is(r,o,u);break e}}else for(S=o.child,S!==null&&(S.return=o);S!==null;){var G=S.dependencies;if(G!==null){B=S.child;for(var te=G.firstContext;te!==null;){if(te.context===p){if(S.tag===1){te=Ds(-1,u&-u),te.tag=2;var fe=S.updateQueue;if(fe!==null){fe=fe.shared;var be=fe.pending;be===null?te.next=te:(te.next=be.next,be.next=te),fe.pending=te}}S.lanes|=u,te=S.alternate,te!==null&&(te.lanes|=u),Od(S.return,u,o),G.lanes|=u;break}te=te.next}}else if(S.tag===10)B=S.type===o.type?null:S.child;else if(S.tag===18){if(B=S.return,B===null)throw Error(n(341));B.lanes|=u,G=B.alternate,G!==null&&(G.lanes|=u),Od(B,u,o),B=S.sibling}else B=S.child;if(B!==null)B.return=S;else for(B=S;B!==null;){if(B===o){B=null;break}if(S=B.sibling,S!==null){S.return=B.return,B=S;break}B=B.return}S=B}ii(r,o,v.children,u),o=o.child}return o;case 9:return v=o.type,p=o.pendingProps.children,To(o,u),v=Oi(v),p=p(v),o.flags|=1,ii(r,o,p,u),o.child;case 14:return p=o.type,v=Zi(p,o.pendingProps),v=Zi(p.type,v),Hv(r,o,p,v,u);case 15:return Uv(r,o,o.type,o.pendingProps,u);case 17:return p=o.type,v=o.pendingProps,v=o.elementType===p?v:Zi(p,v),xc(r,o),o.tag=1,gi(p)?(r=!0,rc(o)):r=!1,To(o,u),Tv(o,p,v),eh(o,p,v,u),sh(null,o,p,!0,r,u);case 19:return Qv(r,o,u);case 22:return Wv(r,o,u)}throw Error(n(156,o.tag))};function b_(r,o){return st(r,o)}function IC(r,o,u,p){this.tag=r,this.key=u,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=o,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=p,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Fi(r,o,u,p){return new IC(r,o,u,p)}function Ch(r){return r=r.prototype,!(!r||!r.isReactComponent)}function BC(r){if(typeof r=="function")return Ch(r)?1:0;if(r!=null){if(r=r.$$typeof,r===M)return 11;if(r===O)return 14}return 2}function pr(r,o){var u=r.alternate;return u===null?(u=Fi(r.tag,o,r.key,r.mode),u.elementType=r.elementType,u.type=r.type,u.stateNode=r.stateNode,u.alternate=r,r.alternate=u):(u.pendingProps=o,u.type=r.type,u.flags=0,u.subtreeFlags=0,u.deletions=null),u.flags=r.flags&14680064,u.childLanes=r.childLanes,u.lanes=r.lanes,u.child=r.child,u.memoizedProps=r.memoizedProps,u.memoizedState=r.memoizedState,u.updateQueue=r.updateQueue,o=r.dependencies,u.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext},u.sibling=r.sibling,u.index=r.index,u.ref=r.ref,u}function Tc(r,o,u,p,v,S){var B=2;if(p=r,typeof r=="function")Ch(r)&&(B=1);else if(typeof r=="string")B=5;else e:switch(r){case Q:return Yr(u.children,v,S,o);case ee:B=8,v|=8;break;case q:return r=Fi(12,u,o,v|2),r.elementType=q,r.lanes=S,r;case L:return r=Fi(13,u,o,v),r.elementType=L,r.lanes=S,r;case j:return r=Fi(19,u,o,v),r.elementType=j,r.lanes=S,r;case A:return Dc(u,v,S,o);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case J:B=10;break e;case $:B=9;break e;case M:B=11;break e;case O:B=14;break e;case P:B=16,p=null;break e}throw Error(n(130,r==null?r:typeof r,""))}return o=Fi(B,u,o,v),o.elementType=r,o.type=p,o.lanes=S,o}function Yr(r,o,u,p){return r=Fi(7,r,p,o),r.lanes=u,r}function Dc(r,o,u,p){return r=Fi(22,r,p,o),r.elementType=A,r.lanes=u,r.stateNode={isHidden:!1},r}function kh(r,o,u){return r=Fi(6,r,null,o),r.lanes=u,r}function Eh(r,o,u){return o=Fi(4,r.children!==null?r.children:[],r.key,o),o.lanes=u,o.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},o}function OC(r,o,u,p,v){this.tag=o,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Js(0),this.expirationTimes=Js(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Js(0),this.identifierPrefix=p,this.onRecoverableError=v,this.mutableSourceEagerHydrationData=null}function Nh(r,o,u,p,v,S,B,G,te){return r=new OC(r,o,u,G,te),o===1?(o=1,S===!0&&(o|=8)):o=0,S=Fi(3,null,null,o),r.current=S,S.stateNode=r,S.memoizedState={element:p,isDehydrated:u,cache:null,transitions:null,pendingSuspenseBoundaries:null},zd(S),r}function $C(r,o,u){var p=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:U,key:p==null?null:""+p,children:r,containerInfo:o,implementation:u}}function S_(r){if(!r)return rr;r=r._reactInternals;e:{if(vt(r)!==r||r.tag!==1)throw Error(n(170));var o=r;do{switch(o.tag){case 3:o=o.stateNode.context;break e;case 1:if(gi(o.type)){o=o.stateNode.__reactInternalMemoizedMergedChildContext;break e}}o=o.return}while(o!==null);throw Error(n(171))}if(r.tag===1){var u=r.type;if(gi(u))return Xg(r,u,o)}return o}function x_(r,o,u,p,v,S,B,G,te){return r=Nh(u,p,!0,r,v,S,B,G,te),r.context=S_(null),u=r.current,p=si(),v=hr(u),S=Ds(p,v),S.callback=o??null,lr(u,S,v),r.current.lanes=v,Zs(r,v,p),yi(r,p),r}function Ic(r,o,u,p){var v=o.current,S=si(),B=hr(v);return u=S_(u),o.context===null?o.context=u:o.pendingContext=u,o=Ds(S,B),o.payload={element:r},p=p===void 0?null:p,p!==null&&(o.callback=p),r=lr(v,o,B),r!==null&&(ns(r,v,B,S),fc(r,v,B)),B}function Bc(r){if(r=r.current,!r.child)return null;switch(r.child.tag){case 5:return r.child.stateNode;default:return r.child.stateNode}}function C_(r,o){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var u=r.retryLane;r.retryLane=u!==0&&u<o?u:o}}function Lh(r,o){C_(r,o),(r=r.alternate)&&C_(r,o)}function zC(){return null}var k_=typeof reportError=="function"?reportError:function(r){console.error(r)};function Rh(r){this._internalRoot=r}Oc.prototype.render=Rh.prototype.render=function(r){var o=this._internalRoot;if(o===null)throw Error(n(409));Ic(r,o,null,null)},Oc.prototype.unmount=Rh.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var o=r.containerInfo;qr(function(){Ic(null,r,null,null)}),o[Ms]=null}};function Oc(r){this._internalRoot=r}Oc.prototype.unstable_scheduleHydration=function(r){if(r){var o=wa();r={blockedOn:null,target:r,priority:o};for(var u=0;u<ki.length&&o!==0&&o<ki[u].priority;u++);ki.splice(u,0,r),u===0&&Re(r)}};function Mh(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function $c(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11&&(r.nodeType!==8||r.nodeValue!==" react-mount-point-unstable "))}function E_(){}function FC(r,o,u,p,v){if(v){if(typeof p=="function"){var S=p;p=function(){var fe=Bc(B);S.call(fe)}}var B=x_(o,p,r,0,null,!1,!1,"",E_);return r._reactRootContainer=B,r[Ms]=B.current,ja(r.nodeType===8?r.parentNode:r),qr(),B}for(;v=r.lastChild;)r.removeChild(v);if(typeof p=="function"){var G=p;p=function(){var fe=Bc(te);G.call(fe)}}var te=Nh(r,0,!1,null,null,!1,!1,"",E_);return r._reactRootContainer=te,r[Ms]=te.current,ja(r.nodeType===8?r.parentNode:r),qr(function(){Ic(o,te,u,p)}),te}function zc(r,o,u,p,v){var S=u._reactRootContainer;if(S){var B=S;if(typeof v=="function"){var G=v;v=function(){var te=Bc(B);G.call(te)}}Ic(o,B,r,v)}else B=FC(u,o,r,v,p);return Bc(B)}Ls=function(r){switch(r.tag){case 3:var o=r.stateNode;if(o.current.memoizedState.isDehydrated){var u=Gn(o.pendingLanes);u!==0&&(vo(o,u|1),yi(o,Wt()),(At&6)===0&&($o=Wt()+500,or()))}break;case 13:qr(function(){var p=Ts(r,1);if(p!==null){var v=si();ns(p,r,1,v)}}),Lh(r,1)}},hi=function(r){if(r.tag===13){var o=Ts(r,134217728);if(o!==null){var u=si();ns(o,r,134217728,u)}Lh(r,134217728)}},_o=function(r){if(r.tag===13){var o=hr(r),u=Ts(r,o);if(u!==null){var p=si();ns(u,r,o,p)}Lh(r,o)}},wa=function(){return xt},Xn=function(r,o){var u=xt;try{return xt=r,o()}finally{xt=u}},Dt=function(r,o,u){switch(o){case"input":if(Ct(r,u),o=u.name,u.type==="radio"&&o!=null){for(u=r;u.parentNode;)u=u.parentNode;for(u=u.querySelectorAll("input[name="+JSON.stringify(""+o)+'][type="radio"]'),o=0;o<u.length;o++){var p=u[o];if(p!==r&&p.form===r.form){var v=ic(p);if(!v)throw Error(n(90));ot(p),Ct(p,v)}}}break;case"textarea":It(r,u);break;case"select":o=u.value,o!=null&&St(r,!!u.multiple,o,!1)}},We=bh,Ge=qr;var HC={usingClientEntryPoint:!1,Events:[Da,Eo,ic,ye,Ue,bh]},Ga={findFiberByHostInstance:Br,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},UC={bundleType:Ga.bundleType,version:Ga.version,rendererPackageName:Ga.rendererPackageName,rendererConfig:Ga.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:T.ReactCurrentDispatcher,findHostInstanceByFiber:function(r){return r=Ae(r),r===null?null:r.stateNode},findFiberByHostInstance:Ga.findFiberByHostInstance||zC,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 Fc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Fc.isDisabled&&Fc.supportsFiber)try{Pr=Fc.inject(UC),xi=Fc}catch{}}return wi.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=HC,wi.createPortal=function(r,o){var u=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Mh(o))throw Error(n(200));return $C(r,o,null,u)},wi.createRoot=function(r,o){if(!Mh(r))throw Error(n(299));var u=!1,p="",v=k_;return o!=null&&(o.unstable_strictMode===!0&&(u=!0),o.identifierPrefix!==void 0&&(p=o.identifierPrefix),o.onRecoverableError!==void 0&&(v=o.onRecoverableError)),o=Nh(r,1,!1,null,null,u,!1,p,v),r[Ms]=o.current,ja(r.nodeType===8?r.parentNode:r),new Rh(o)},wi.findDOMNode=function(r){if(r==null)return null;if(r.nodeType===1)return r;var o=r._reactInternals;if(o===void 0)throw typeof r.render=="function"?Error(n(188)):(r=Object.keys(r).join(","),Error(n(268,r)));return r=Ae(o),r=r===null?null:r.stateNode,r},wi.flushSync=function(r){return qr(r)},wi.hydrate=function(r,o,u){if(!$c(o))throw Error(n(200));return zc(null,r,o,!0,u)},wi.hydrateRoot=function(r,o,u){if(!Mh(r))throw Error(n(405));var p=u!=null&&u.hydratedSources||null,v=!1,S="",B=k_;if(u!=null&&(u.unstable_strictMode===!0&&(v=!0),u.identifierPrefix!==void 0&&(S=u.identifierPrefix),u.onRecoverableError!==void 0&&(B=u.onRecoverableError)),o=x_(o,null,r,1,u??null,v,!1,S,B),r[Ms]=o.current,ja(r),p)for(r=0;r<p.length;r++)u=p[r],v=u._getVersion,v=v(u._source),o.mutableSourceEagerHydrationData==null?o.mutableSourceEagerHydrationData=[u,v]:o.mutableSourceEagerHydrationData.push(u,v);return new Oc(o)},wi.render=function(r,o,u){if(!$c(o))throw Error(n(200));return zc(null,r,o,!1,u)},wi.unmountComponentAtNode=function(r){if(!$c(r))throw Error(n(40));return r._reactRootContainer?(qr(function(){zc(null,null,r,!1,function(){r._reactRootContainer=null,r[Ms]=null})}),!0):!1},wi.unstable_batchedUpdates=bh,wi.unstable_renderSubtreeIntoContainer=function(r,o,u,p){if(!$c(u))throw Error(n(200));if(r==null||r._reactInternals===void 0)throw Error(n(38));return zc(r,o,u,!1,p)},wi.version="18.3.1-next-f1338f8080-20240426",wi}var T_;function JC(){if(T_)return Ph.exports;T_=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Ph.exports=QC(),Ph.exports}var D_;function ZC(){if(D_)return Hc;D_=1;var t=JC();return Hc.createRoot=t.createRoot,Hc.hydrateRoot=t.hydrateRoot,Hc}var ek=ZC();const tk=am(ek);function pn(t,e,n={}){return fetch(t,{...n,headers:{...n.headers||{},Authorization:`Bearer ${e}`}})}const s0=t=>`nc_seen_${t}`;async function Oe(t,e,n={}){const i=await pn(t,e,{method:n.method||"GET",headers:{"content-type":"application/json"},body:n.body?JSON.stringify(n.body):void 0}),s=await i.json().catch(()=>({}));if(!i.ok){const a=new Error(s.error||`HTTP ${i.status}`);throw a.status=i.status,a.data=s,a}return s}const an=t=>Array.isArray(t)&&t.length?`/api/route/${t.map(encodeURIComponent).join("/")}/_`:"/api",wn=(t,e)=>`${an(t)}/fleet/${e}`;async function nk(t,e,n,{signal:i}={}){const s=await pn(`${an(e)}/panel/${encodeURIComponent(n)}/ticket`,t,{method:"POST",signal:i}),a=await s.json().catch(()=>({}));return s.status===200&&a&&typeof a.ticket=="string"?{ok:!0,ticket:a.ticket}:s.status===403&&a&&a.reason==="panel-not-granted"?{ok:!1,cause:"not-granted"}:s.status===403?{ok:!1,cause:"node-refused"}:s.status===404?{ok:!1,cause:"no-panel"}:s.status===401?{ok:!1,cause:"unauthorized"}:{ok:!1,cause:"denied"}}const Ar=(t,e)=>Oe(wn(e,"status"),t),cm=(t,e,n)=>Oe(wn(n,"up"),t,{method:"POST",body:e}),wu=(t,e,n)=>Oe(wn(n,"down"),t,{method:"POST",body:e}),r0=(t,e,n)=>Oe(wn(n,"boot"),t,{method:"POST",body:e}),hl=(t,e,n)=>Oe(wn(n,"restart"),t,{method:"POST",body:{cell:e}}),Wu=(t,e)=>Oe(wn(e,"definitions"),t),ik=(t,e)=>Oe(wn(e,"credentials/status"),t),I_=(t,e,n,i)=>Oe(wn(i,"credentials/set"),t,{method:"POST",body:{envKey:e,value:n}}),sk=(t,e,n)=>Oe(wn(n,"credentials/remove"),t,{method:"POST",body:{envKey:e}}),rk=(t,e,n)=>Oe(wn(n,"define-engine"),t,{method:"POST",body:{def:e}}),ok=(t,e,n,i,s)=>Oe(wn(s,"edit-engine"),t,{method:"POST",body:{id:e,patch:n,envChanges:i}}),ak=(t,e,n)=>Oe(wn(n,"remove-engine"),t,{method:"POST",body:{id:e}}),lk=(t,e,n)=>Oe(wn(n,"define-model"),t,{method:"POST",body:{def:e}}),ck=(t,e,n,i)=>Oe(wn(i,"remove-model"),t,{method:"POST",body:{id:e,engine:n}}),uk=(t,e,n,i)=>Oe(wn(i,"model-test"),t,{method:"POST",body:{engine:e,model:n}}),dk=(t,e,n)=>Oe(wn(n,"define-cell"),t,{method:"POST",body:{def:e}}),o0=(t,e,n,i)=>Oe(wn(i,"edit-cell"),t,{method:"POST",body:{id:e,patch:n}}),a0=(t,e,n=!1,i)=>Oe(wn(i,"remove-cell"),t,{method:"POST",body:{id:e,stop:n}}),hk=(t,e,n)=>Oe(wn(n,"import-cell"),t,{method:"POST",body:e}),fk=(t,e,n)=>Oe(wn(n,"restore-cells"),t,{method:"POST",body:{cells:e}}),pk=(t,e,n,i,s)=>Oe(wn(i,"restore-engines"),t,{method:"POST",body:{engines:e,overwrite:!!n,...Array.isArray(s)&&s.length?{models:s}:{}}}),um=(t,e,n)=>Oe(`${an(n)}/sessions/${encodeURIComponent(e)}`,t,{method:"DELETE"}),l0=(t,e,n,i)=>Oe(`${an(i)}/sessions/${encodeURIComponent(e)}/visibility`,t,{method:"PATCH",body:{technical:!!n}}),dm=(t,e,n)=>Oe(`${an(n)}/fs/dirs${e?`?path=${encodeURIComponent(e)}`:""}`,t),c0=t=>Oe("/api/settings",t),mk=t=>Oe("/api/nodes",t),gk=t=>Oe("/api/peers",t),u0=(t,e=[])=>Oe(`${an(e)}/vl-nodes`,t),B_=(t,e,n,i={},s=[])=>Oe(`${an(s)}/vl-nodes/${encodeURIComponent(e)}/commands`,t,{method:"POST",body:{kind:n,args:i}}),vk=(t,e,n=0,i=[])=>Oe(`${an(i)}/vl-nodes/${encodeURIComponent(e)}/events${n?`?after=${encodeURIComponent(n)}`:""}`,t),d0=t=>Oe("/api/topology",t),hm=(t,e)=>Oe(`${an(e)}/sessions`,t),fm=(t,e)=>Oe(`${an(e)}/config`,t),O_=(t,e)=>Oe(`${an(e)}/topology`,t),qf=(t,e)=>Oe("/api/settings/config",t,{method:"POST",body:e}),_k=t=>Oe("/api/settings/token/rotate",t,{method:"POST"}),yk=(t,e)=>Oe("/api/settings/nodes/pair",t,{method:"POST",body:e}),wk=(t,e,n=[])=>Oe(`${an(n)}/settings/peering/invite`,t,{method:"POST",body:e||{}}),h0=(t,e,n)=>Oe(`/api/settings/nodes/${encodeURIComponent(e)}/label`,t,{method:"PATCH",body:{label:n}}),bk=t=>Oe("/api/settings/node-aliases",t),Sk=(t,e,n)=>Oe(`/api/settings/node-aliases/${encodeURIComponent(e)}`,t,{method:"PATCH",body:{alias:n}}),$_=(t,e)=>Oe(`/api/settings/node-aliases/${encodeURIComponent(e)}`,t,{method:"DELETE"}),z_=(t,e,n)=>Oe(`/api/settings/nodes/${encodeURIComponent(e)}`,t,{method:"PATCH",body:n}),xk=(t,e)=>Oe(`/api/settings/nodes/${encodeURIComponent(e)}`,t,{method:"DELETE"}),pm=(t,e,n)=>Oe(`/api/settings/nodes/${encodeURIComponent(e)}/${n}`,t,{method:"POST"}),Ck=(t,e,n)=>Oe(`/api/settings/nodes/${encodeURIComponent(e)}/share`,t,{method:"PATCH",body:{shared:n}}),kk=(t,e,n,i=[])=>Oe(`/api/settings/nodes/${encodeURIComponent(e)}/visibility`,t,{method:"PATCH",body:{visibility:n,selected:i}}),Ek=t=>Oe("/api/settings/audio",t),Nk=(t,e)=>Oe("/api/settings/audio/consent",t,{method:"PATCH",body:{consent:e}}),Lk=t=>Oe("/api/settings/audio/test",t,{method:"POST",body:{}}),Rk=t=>Oe("/api/settings/audio/stop",t,{method:"POST",body:{}}),Mk=t=>Oe("/api/settings/audio/groups",t),Ak=(t,e,n)=>Oe(`/api/settings/audio/groups/${encodeURIComponent(e)}`,t,{method:"PUT",body:n}),jk=(t,e)=>Oe(`/api/settings/audio/groups/${encodeURIComponent(e)}`,t,{method:"DELETE"}),Pk=t=>Oe("/api/settings/service/regenerate",t,{method:"POST"}),Tk=t=>Oe("/api/settings/update/check",t,{method:"POST"}),Dk=t=>Oe("/api/settings/update/apply",t,{method:"POST"}),qu=(t,e)=>`${an(t)}/diagnostics/${e}`,Ik=(t,e=[])=>Oe(qu(e,"status"),t),Bk=(t,{after:e=0,limit:n=200}={},i=[])=>Oe(`${qu(i,"logs")}?after=${encodeURIComponent(e)}&limit=${encodeURIComponent(n)}`,t),F_=(t,e,n,i=[])=>Oe(qu(i,"verbose"),t,{method:"PATCH",body:{enabled:e,durationSeconds:n}}),Ok=(t,e=[])=>Oe(qu(e,"logs"),t,{method:"DELETE"}),$k=(t,e=!0)=>Oe(`/api/asks${e?"?open=1":""}`,t),zk=(t,e,n)=>Oe(`/api/asks/${encodeURIComponent(e)}/answer`,t,{method:"POST",body:{text:n}}),Fk=(t,e)=>Oe(`/api/asks/${encodeURIComponent(e)}`,t,{method:"DELETE"}),Uc=(t,e=[])=>Oe(`${an(e)}/decks`,t),H_=(t,e,n=[])=>Oe(`${an(n)}/decks`,t,{method:"POST",body:{name:e}}),Wc=(t,e,n,i,s=[])=>Oe(`${an(s)}/decks/${encodeURIComponent(e)}`,t,{method:"PUT",body:{layout:n,expectedRevision:i}}),Hk=(t,e,n,i,s=[])=>Oe(`${an(s)}/decks/${encodeURIComponent(e)}`,t,{method:"PATCH",body:{name:n,expectedRevision:i}}),Uk=(t,e,n,i=[])=>Oe(`${an(i)}/decks/${encodeURIComponent(e)}`,t,{method:"DELETE",body:{expectedRevision:n}}),Wk=(t,e=[])=>Oe(`${an(e)}/live-host`,t),qk=(t,e,n,i=[])=>Oe(`${an(i)}/live-host/designate`,t,{method:"POST",body:{cellId:e,expectedRevision:n}}),Kk=(t,e,n=[])=>Oe(`${an(n)}/live-host/clear`,t,{method:"POST",body:{expectedRevision:e}}),Vk={power:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M12 3v8"}),c.jsx("path",{d:"M6.6 6.6a8 8 0 1 0 10.8 0"})]}),folder:c.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:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"3",y:"6",width:"18",height:"12",rx:"2"}),c.jsx("path",{d:"M7 10h.01M11 10h.01M15 10h.01M17 14h.01M7 14h7"})]}),mic:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),c.jsx("path",{d:"M5 11a7 7 0 0 0 14 0"}),c.jsx("path",{d:"M12 18v3"})]}),enter:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M20 5v6a2 2 0 0 1-2 2H5"}),c.jsx("polyline",{points:"9 9 5 13 9 17"})]}),send:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M22 2 15 22 11 13 2 9Z"}),c.jsx("path",{d:"M22 2 11 13"})]}),trash:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M4 7h16"}),c.jsx("path",{d:"M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"}),c.jsx("path",{d:"M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"}),c.jsx("path",{d:"M10 11v6M14 11v6"})]}),x:c.jsx("path",{d:"M6 6l12 12M18 6 6 18"}),monitor:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"3",y:"4",width:"18",height:"12",rx:"2"}),c.jsx("path",{d:"M8 20h8M12 16v4"})]}),refresh:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M21 12a9 9 0 1 1-2.64-6.36L21 8"}),c.jsx("polyline",{points:"21 3 21 8 16 8"})]}),boot:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"3",y:"4",width:"18",height:"13",rx:"2"}),c.jsx("path",{d:"M8 21h8M12 17v4M12 12V7"}),c.jsx("polyline",{points:"9 10 12 7 15 10"})]}),upload:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M12 16V5"}),c.jsx("polyline",{points:"8 9 12 5 16 9"}),c.jsx("path",{d:"M5 20h14"})]}),chevronLeft:c.jsx("polyline",{points:"14 6 8 12 14 18"}),chevronUp:c.jsx("polyline",{points:"6 14 12 8 18 14"}),chevronDown:c.jsx("polyline",{points:"6 10 12 16 18 10"}),history:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M3 12a9 9 0 1 0 3-6.7L3 8"}),c.jsx("polyline",{points:"3 3 3 8 8 8"}),c.jsx("path",{d:"M12 7v5l3 2"})]}),attach:c.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:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),c.jsx("polyline",{points:"14 2 14 8 20 8"})]}),camera:c.jsxs(c.Fragment,{children:[c.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"}),c.jsx("circle",{cx:"12",cy:"13",r:"3.5"})]}),image:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),c.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),c.jsx("path",{d:"M21 15l-5-5L5 21"})]}),gpu:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"}),c.jsx("rect",{x:"10",y:"10",width:"4",height:"4",rx:"1"}),c.jsx("path",{d:"M9 3v3M15 3v3M9 18v3M15 18v3M3 9h3M3 15h3M18 9h3M18 15h3"})]}),zoomIn:c.jsxs(c.Fragment,{children:[c.jsx("circle",{cx:"11",cy:"11",r:"7"}),c.jsx("path",{d:"M21 21l-4.35-4.35"}),c.jsx("path",{d:"M8 11h6M11 8v6"})]}),zoomOut:c.jsxs(c.Fragment,{children:[c.jsx("circle",{cx:"11",cy:"11",r:"7"}),c.jsx("path",{d:"M21 21l-4.35-4.35"}),c.jsx("path",{d:"M8 11h6"})]}),gear:c.jsxs(c.Fragment,{children:[c.jsx("circle",{cx:"12",cy:"12",r:"3"}),c.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:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),c.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})};function dt({name:t,size:e=20}){return c.jsx("svg",{className:"nc-icon",width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Vk[t]||null})}const mm=["it","en","es"];function Yk(){try{const t=typeof navigator<"u"&&navigator.language||"",e=String(t).slice(0,2).toLowerCase();return mm.includes(e)?e:"en"}catch{return"en"}}const cu=Yk(),f0="nc_lang",Kf="nc-lang";function p0(){return typeof localStorage<"u"?localStorage:null}const qc={it:{"update-available":"nuova versione {v} disponibile","update-stale":"interfaccia non allineata: stai eseguendo la v{browser}, il nodo serve la v{ui}. ricarica senza cache; se persiste, riavvia il nodo","reload-no-cache":"ricarica senza cache","update-installed-restart":"versione {v} installata: riavvia il nodo","update-dismiss":"chiudi","install-version-mismatch":"installazione incompleta: frontend e server non coincidono (v{v})",reload:"ricarica","grid-empty":"trascina qui una sessione dalla sidebar, o doppio-clic per la vista singola","grid-full":"il deck può mostrare al massimo 9 sessioni",pin:"fissa in cima",reorder:"riordina","host-lease-live":"host live: supervisione attiva","host-lease-grace":"host live: supervisione in recupero (grace)","host-lease-expired":"host live: supervisione scaduta","host-lease-none":"host live: mai supervisionata","host-lease-unavailable":"host live: garanzia di supervisione non disponibile su questo nodo","reorder-help":"trascina la maniglia; frecce su/giu da tastiera","rename-node":"rinomina nodo","rename-node-prompt":"Nuovo nome del nodo in NexusCrew","rename-node-invalid":"Nome non valido: massimo 64 caratteri, senza a capo.","reorder-deck-help":"trascina il deck; frecce sinistra/destra da tastiera",sessions:"sessioni","new-session":"nuova sessione",new:"nuova",fleet:"Flotta","fleet-tmux":"flotta tmux","other-sessions":"Altre sessioni","view-all":"tutte","view-pinned":"fissate","view-active":"attive","view-off":"spente","view-technical":"tecniche","mark-technical":"nascondi come sessione tecnica","mark-normal":"mostra come sessione normale","position-local":"Locale",files:"file",refresh:"aggiorna","filter-placeholder":"filtra sessioni…","loading-fleet":"carico la flotta…","no-sessions":"nessuna sessione tmux viva — la flotta parte al boot (systemd)","no-match":'nessuna sessione contiene "{q}"',"copy-url":"clicca per copiare l'URL","ssh-only":"solo tunnel SSH/VPN","new-files-outbox":"nuovi file in outbox",terminate:"termina","terminate-confirm":'Terminare la sessione "{name}"?',"cell-on":"tmux vivo","cell-off":"spenta","cell-working":"al lavoro","cell-idle":"in attesa","cell-degraded":"degradata: unit attiva, tmux morto","power-on":"accendi","power-off":"spegni","boot-enable":"attiva al boot","boot-disable":"disattiva al boot","state-on":"accesa","state-off":"spenta",engine:"Engine",model:"Modello","model-default":"Modello predefinito del provider","model-remembered":"Ultimo modello usato con questo engine","boot-persist":"avvia al boot","remove-boot":"togli anche dal boot","power-config-in-settings":"Engine, provider, profilo, modello e permessi si modificano in Impostazioni → Flotta.","no-remote-control":"⚠ engine non-native: niente RC da app claude.ai (da qui la piloti comunque)",cancel:"annulla",name:"nome","name-invalid":"nome non valido: a-zA-Z0-9._- max 64, senza '-' iniziale",cwd:"cartella",browse:"sfoglia","fs-home":"home","fs-parent":".. su",preset:"preset","preset-2x2":"griglia 2×2","preset-columns":"colonne","preset-equalize":"equalizza",collapse:"comprimi",expand:"espandi",create:"crea","auth-prompt":"Incolla il token (stampato dal server):","remember-device":"ricorda su questo device","zoom-out":"testo più piccolo","zoom-in":"testo più grande","terminal-renderer-webgl":"WebGL","terminal-renderer-dom":"DOM","terminal-renderer-switch":"motore grafico: richiesto {requested}, in uso {effective} — tocca per cambiare (ricarica il terminale)",composer:"composer",panel:"pannello","panel-none":"Nessun pannello configurato per questa cella.","panel-checking":"Apertura del pannello…","panel-not-granted":"Questo nodo non concede il pannello a chi lo chiede: l'accesso va concesso sul nodo che possiede la cella, non riprovando qui.","panel-denied":"Ingresso al pannello rifiutato: il biglietto non è più valido. Riprova: verrà chiesto un biglietto nuovo.","cell-peek":"Sbircia senza cambiare cella","cell-tele-ctx":"contesto","cell-tele-free":"libero","cell-tele-5h":"5h usati","cell-tele-7d":"7g usati","cell-activity":"attività","cell-activity-now":"adesso","cell-peek-preview":"Anteprima","cell-peek-stream":"Flusso","cell-peek-panel":"Pannello","cell-peek-vuoto":"Nessuna anteprima disponibile per questa cella.","panel-node-refused":"Il nodo che possiede la cella rifiuta la richiesta: è in sola lettura, o la sua policy blocca questa operazione. Riprovare qui non cambia l'esito.","panel-unauthorized":"Credenziale non valida per questo nodo: va corretta dove è configurata, non riprovando da qui.","panel-unreachable":"Il pannello non è raggiungibile attraverso questo nodo: riprova tra poco.","panel-frame-loading":"pannello montato: caricamento in corso","panel-frame-error":"Il frame del pannello non si è caricato: il biglietto può essere scaduto (30 s di vita, monouso) o la destinazione è irraggiungibile. Riprova: verrà chiesto un biglietto nuovo.","popup-drag-hint":"trascina per spostare; doppio clic per tornare al centro","popup-resize-hint":"trascina per ridimensionare","panel-timeout":"Il pannello non ha risposto in tempo: servizio lento a partire o sovraccarico. Riprova tra poco.","panel-retry":"Riprova","live-host-not-granted":"Questo nodo non concede la designazione della cella ospite Live a chi la chiede: va concessa sul nodo che possiede la cella (nodes live-host <nodo> on), non riprovando qui.","live-host-error":"La designazione della cella ospite Live non è riuscita: riprova tra poco.","host-thread-designated":"cella designata; thread assente","host-thread-present":"thread presente ma inattivo","host-thread-active":"thread attivo","host-thread-unknown":"stato del thread sconosciuto",windows:"{n} finestre","empty-files":"vuota",upload:"carica","no-sessions-short":"nessuna sessione","composer-placeholder":"scrivi o detta…","composer-history-tools":"cronologia e dimensione input","composer-history":"cronologia della cella","composer-history-empty":"nessun input inviato","composer-history-clear":"cancella cronologia di questa cella","composer-expand":"espandi input","composer-collapse":"riduci input","composer-clear-data":"cancella bozze e cronologia","composer-clear-data-help":"Rimuove da questo browser tutte le bozze e la cronologia input delle celle.","composer-clear-confirm":"Cancellare tutte le bozze e la cronologia input salvate in questo browser?","composer-clear-done":"Bozze e cronologia cancellate.","composer-clear-failed":"Impossibile cancellare i dati del composer in questo browser.",attach:"allega","attach-file":"File","attach-camera":"Fotocamera","attach-gallery":"Galleria","attach-inbox":"Inbox","attach-inbox-done":"{n} file aggiunti all'inbox","attach-uploading":"carico…","attach-upload-progress":"allegato {n}/{total}…","attach-uploaded":"{n} allegati caricati",voice:"voice",send:"invia","composer-send-failed":"connessione non pronta — testo conservato, riprova",close:"chiudi","lang-label":"lingua",decks:"deck","new-deck":"nuovo deck","deck-name":"nome deck","open-deck-window":"apri in una nuova finestra","detach-deck":"stacca in una nuova finestra","deck-current":"questo deck (finestra corrente)","deck-owner-unavailable":"nodo owner non condiviso o non raggiungibile","rename-deck":"rinomina deck","delete-deck":"elimina deck","delete-deck-confirm":'Eliminare il deck "{name}"?',"send-to-deck":"manda al deck…","deck-autosave":"salvataggio automatico",saving:"salvataggio…",saved:"salvato","popup-blocked":"popup bloccato: apri qui","expand-owner":"espandi i deck di {owner}","collapse-owner":"comprimi i deck di {owner}","owner-deck-count-one":"{count} deck","owner-deck-count-many":"{count} deck","dot-working":"in uso (finestra attiva)","dot-on":"aperta in background","dot-neutral":"non aperta","dot-warn":"nodo offline","select-drag":"trascina per selezionare","copy-manual":"seleziona e copia manualmente","toggle-sidebar":"mostra/nascondi la barra laterale",settings:"impostazioni","tab-roles":"ruoli","tab-nodes":"nodi",local:"Locale",location:"Dove","pairing-link":"link di pairing","pairing-required":"nome, alias SSH e link di pairing sono obbligatori","pairing-connect-help":"Per collegare un nodo servono: nome, Host SSH già funzionante e link/QR creato sull’altra installazione NexusCrew.","pairing-localhost-hint":"127.0.0.1 nel link è corretto: non aprirlo qui. NexusCrew usa invito e porta attraverso l’Host SSH.","scan-qr":"scansiona QR","pairing-qr-invalid":"QR di pairing non valido","invite-node":"invita un nodo","create-pairing-link":"crea link / QR","visibility-network":"tutta la rete","visibility-relay":"solo relay","visibility-selected":"nodi selezionati","hydra-simple":"locale + nodi, una sola rete","local-ready":"Questo dispositivo è pronto. Puoi usarlo da solo o collegarlo a un nodo.","local-only":"solo locale","add-node":"aggiungi nodo",connect:"collega","node-connected":"Nodo collegato. La rete verrà sincronizzata automaticamente.","pair-authkeys-title":"Riga da sostituire in ~/.ssh/authorized_keys sul peer","pair-authkeys-hint":"Senza questa riga il forward del pannello resta rifiutato: il tunnel sembra attivo e il pannello non risponde.","pair-authkeys-copy":"Copia la riga","pair-authkeys-copied":"Riga copiata","tab-system":"sistema","tab-fleet":"flotta","tab-audio":"audio","system-general":"generale","system-diagnostics":"diagnostica","system-this-node":"questo nodo","system-updates":"aggiornamenti","system-security":"sicurezza","system-local-data":"dati locali del browser","system-terminal":"terminale","alternate-screen":"schermo alternato","alternate-screen-help":"Mantiene il comportamento tmux standard per le nuove sessioni NexusCrew. Un’applicazione che segue il mouse scorre da sé; le altre fanno scorrere la storia di tmux. Non modifica le celle già attive.","tab-input":"input","tab-diagnostics":"diagnostica","input-settings-local":"Preferenze locali di questo browser. Si applicano subito a vista singola e deck, senza modificare il nodo remoto.","terminal-keyboard-gesture":"Apertura tastiera virtuale dal terminale","terminal-keyboard-double-tap":"Doppio tap (predefinito)","terminal-keyboard-single-tap":"Tap singolo","terminal-keyboard-never":"Mai dal terminale","terminal-keyboard-gesture-help":"Il tastierino e STT seguono i controlli separati sotto. Mouse e tastiera fisica restano utilizzabili.","keybar-ime-lock":"Tastierino: mantieni chiusa la tastiera virtuale","keybar-ime-lock-help":"ESC, frecce, PgUp/PgDn, Enter e menu inviano direttamente al PTY senza dare focus a un campo di testo.","voice-ime-lock":"Microfono STT: mantieni chiusa la tastiera virtuale","voice-ime-lock-help":"Il tap sul microfono avvia o ferma la voce senza focalizzare il composer.","keybar-enter-show":"Mostra Enter verticale nel tastierino","keybar-enter-show-help":"Enter resta a destra di PgUp/PgDn ed è alto quanto entrambe le righe.","keybar-layout":"Layout tastierino","keybar-layout-full":"Esteso (predefinito)","keybar-layout-compact":"Compatto","keybar-layout-help":"Compatto: una riga con expand ⊞ per accedere al set completo senza cambiare la preferenza.","input-settings-reset":"ripristina predefiniti input","diagnostics-local":"Questo nodo","diagnostics-target":"Nodo da diagnosticare","diagnostics-verbose":"Log verbosi temporanei","diagnostics-duration":"Durata verbose","diagnostics-expires":"Verbose attivo fino alle {time}","diagnostics-off":"Verbose spento; warning ed errori operativi restano disponibili.","diagnostics-level":"Livello","diagnostics-all-levels":"tutti i livelli","diagnostics-component":"componente","diagnostics-pause":"pausa","diagnostics-autoscroll":"scorrimento automatico","diagnostics-log":"Log diagnostico sanitizzato","diagnostics-empty":"Nessun evento diagnostico.","diagnostics-export":"esporta JSON","diagnostics-export-failed":"Esportazione non disponibile in questo browser.","diagnostics-clear":"svuota","diagnostics-clear-confirm":"Svuotare il buffer diagnostico di questo nodo?","diagnostics-unsupported":"Questo peer è offline o non supporta la diagnostica strutturata.","fleet-editor-loading":"Caricamento dell'editor Fleet…","fleet-editor-load-error":"Impossibile caricare l'editor Fleet.","fleet-editor-unavailable":"Editor Fleet non disponibile in questa posizione.","fleet-stale":"Lettura della flotta non riuscita: l’elenco delle celle potrebbe non essere aggiornato.","fleet-off":"Flotta non disponibile: nessuna cella.","fleet-managed":"gestito da NexusCrew","fleet-custom":"comando personalizzato","fleet-managed-help":"Client, provider e avvio sono gestiti internamente; i segreti non vengono mostrati.","fleet-shell-engine-help":"Shell locale risolta sul dispositivo al momento dell’avvio; nessun percorso viene salvato nel backup.","fleet-shell-command-placeholder":"comando opzionale, es. npm test","fleet-shell-command-help":"Esecuzione tramite shell login interattiva (-lic), con PATH e alias utente. La cella si ferma quando il comando termina; gli errori immediati vengono segnalati.","fleet-shell-command-metachar":"Pipe, redirect, variabili e altri metacaratteri vengono interpretati dalla shell del dispositivo.","fleet-shell-interactive":"Vuoto: apre una shell interattiva locale e mantiene la cella attiva.","fleet-shell-launch-help":"Il comando Shell si configura nella cella da Impostazioni → Flotta.","fleet-credential-title":"API key su questo dispositivo","fleet-credential-help":"La key resta solo sul nodo selezionato e non viene mai mostrata né esportata. Se il nodo è remoto, il valore viaggia fino a lui sul canale accoppiato.","fleet-credential-set":"imposta key","fleet-credential-change":"cambia key","fleet-credential-forget":"dimentica","fleet-credential-saved":"Key salvata localmente.","fleet-credential-removed":"Key locale rimossa.","fleet-credential-remove-confirm":"Rimuovere la key locale {key}?","fleet-credential-source-environment":"ambiente","fleet-credential-source-local":"store locale","fleet-credential-source-compatibility":"config compatibile","fleet-credential-source-missing":"mancante","fleet-credential-source-nexuscrew-store":"store NexusCrew","fleet-credential-source-unreadable":"non verificabile","fleet-credential-source-login":"login del client","fleet-credential-source-none":"nessuna","fleet-credential-source-policy":"origine credenziale","fleet-credential-source-policy-auto":"auto (precedenza legacy)","fleet-credential-source-policy-nexuscrew-store":"solo store NexusCrew","fleet-credential-source-policy-environment":"solo ambiente","fleet-key-section":"KEY","fleet-key-variable":"Variabile","fleet-key-value":"Valore per {key}","fleet-key-used-by":"Usata da: {engines}","fleet-key-used-by-none":"Non ancora usata da engine configurati su questo nodo.","fleet-key-shared-impact":"Sostituire o rimuovere {key} interessa tutti gli engine elencati: {engines}.","fleet-key-enter":"inserisci la key","fleet-key-blank-keeps":"vuoto = mantieni la fonte attuale","fleet-key-reveal":"mostra","fleet-key-hide":"nascondi","fleet-key-local-help":"Il valore resta write-only sul nodo selezionato: non viene mai riletto dalla rete e non entra in engine o backup. Se il nodo selezionato è remoto, il valore lo raggiunge attraverso il canale accoppiato.","fleet-key-create-missing":"Crea esplicitamente l’engine senza key (resterà “key richiesta”).","fleet-key-partial-create":"Engine creato; la key non è stata salvata. Puoi riprovare senza creare duplicati.","fleet-key-partial-edit":"Engine aggiornato; la key non è stata salvata. Le modifiche all’engine restano applicate.","fleet-provider-notice-claude-openrouter":"Claude Code è ottimizzato per modelli Anthropic: altri provider potrebbero non funzionare correttamente. Fast mode richiede il provider Anthropic first-party.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses è beta e stateless; Codex-VL non usa fallback Chat Completions.","fleet-provider-notice-claude-kimi-code":"Kimi Code usa una configurazione Claude isolata con onboarding e fast mode dedicati; la configurazione Claude nativa non viene modificata, ma i suoi strumenti MCP vengono ereditati.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal usa solo ALIBABA_CODE_API_KEY dal credential layer locale; qwen3.8-max è il modello predefinito e non viene usato alcun fallback OpenAI/PAYG.","fleet-provider-notice-kimi-native":'Kimi Code CLI nativo usa il login del CLI (device-code) e la propria configurazione: NexusCrew non legge né copia credenziali. Distinto dal provider "Kimi Code" di Claude Code, che resta il percorso K3 gestito.',"fleet-model-default":"modello predefinito (opzionale)","fleet-model-required":"modello (obbligatorio)","fleet-standard-permissions":"permessi standard","fleet-unsafe-permissions":"non sicuro · ignora approvazioni/sandbox","fleet-unsafe-warning":"Modalità non sicura esplicita: il worker può agire senza le normali approvazioni o protezioni sandbox.","fleet-provider-display":"nome visualizzato del provider","fleet-custom-provider-default":"Provider personalizzato","fleet-api-key-env":"NOME_VARIABILE_API_KEY","fleet-provider-id":"id-provider","fleet-custom-secret-help":"NexusCrew salva solo il nome della variabile d’ambiente, mai il suo valore.","cell-prompt":"Prompt di avvio della cella","cell-prompt-help":"Inviato alla cella quando parte: e’ il suo incarico permanente. Vuoto = nessun prompt, la cella parte e basta.","fleet-boot":"avvio automatico","fleet-remote-control":"controllo remoto","cell-mcp":"Strumenti MCP","cell-mcp-all":"tutti","cell-mcp-none":"nessuno","cell-mcp-some":"scelti","cell-mcp-inert":"Per questo client gli strumenti MCP li registra il client nel proprio config, non NexusCrew: la selezione qui non ha effetto.","cell-mcp-help":"«Tutti» è il comportamento di sempre. «Nessuno» è l’unica esclusione CERTA: toglie ogni strumento e non dipende da dove i server sono definiti — è ciò che serve per una cella di cui non ci si fida. Con «scelti» si concede per nome, ma l’elenco copre solo i server che questo nodo sa enumerare: plugin e connettori non compaiono e resterebbero disponibili.","fleet-model-override":"modello alternativo","fleet-ready":"pronto","fleet-not-ready":"non configurato","fleet-engines":"Engine","fleet-cells":"Celle / sessioni cloud","fleet-models":"Modelli dichiarati","fleet-no-models":"Nessun modello dichiarato: si usano quelli del catalogo.","model-editor-engine":"Profilo","model-editor-id":"Id del modello","model-editor-id-help":"L’id esatto che il fornitore si aspetta. Profilo e id non si cambiano dopo: si ritira e si ridichiara.","model-editor-context":"Finestra di contesto (token)","model-editor-max-tokens":"Massimo di token in uscita","model-editor-reasoning":"Supporta il ragionamento esteso","model-test":"Prova sull’API","model-test-running":"Provo…","model-test-ok":"risponde","model-test-unknown-model":"il fornitore non conosce questo id","model-test-auth":"credenziale mancante o rifiutata","model-test-unreachable":"endpoint non raggiungibile","model-test-unverified":"non verificato","model-test-unverified-help":"Non significa che non funzioni: questo fornitore non espone l’elenco dei modelli, quindi la prova non ha potuto dire né sì né no.","model-remove":"Ritira","model-in-use":"in uso","fleet-backup":"backup / ripristino","fleet-backup-help":"Esporta o ripristina selettivamente engine, celle, modelli dichiarati e system prompt. Token, API key e segreti provider non entrano mai nel file.","fleet-backup-export":"esporta","fleet-backup-import":"importa","fleet-backup-download":"scarica backup","fleet-backup-restore":"ripristina selezionate","fleet-backup-import-help":"Scegli un backup JSON, controlla le celle e seleziona l’engine di destinazione prima del ripristino.","fleet-backup-overwrite":"sovrascrive la cella esistente","fleet-backup-new":"nuova cella","fleet-backup-engine-missing":"scegli un engine disponibile","fleet-backup-restore-unavailable":"Il nodo selezionato supporta solo l’esportazione; aggiornalo per ripristinare backup.","fleet-backup-restored":"{n} celle ripristinate","fleet-backup-confirm-overwrite":"Sovrascrivere queste celle? {cells}","fleet-backup-needs-restart":"riavvio necessario: {cells}","fleet-backup-empty":"nessuna cella da esportare","fleet-backup-select-one":"seleziona almeno una cella","fleet-backup-too-large":"backup troppo grande (massimo 1 MB)","fleet-backup-invalid-json":"il file non contiene JSON valido","fleet-backup-invalid-format":"formato o versione del backup non supportati","fleet-backup-invalid-cell":"il backup contiene una cella non valida","fleet-backup-duplicate-cell":"il backup contiene ID cella duplicati","fleet-backup-invalid-engine":"il backup contiene un engine non valido","fleet-backup-duplicate-engine":"il backup contiene ID engine duplicati","fleet-backup-invalid-model":"il backup contiene un modello non valido","fleet-backup-duplicate-model":"il backup contiene modelli duplicati","fleet-backup-confirm-engine-overwrite":"Sovrascrivere questi engine? I valori ambiente già configurati sul target restano invariati. {engines}","fleet-backup-env-names":"nomi ambiente","fleet-backup-env-values-required":"i valori ambiente vanno configurati sul dispositivo","fleet-system-prompt":"system prompt",characters:"caratteri","select-all":"seleziona tutte","select-none":"nessuna",edit:"modifica",save:"salva",label:"etichetta","command-path":"path assoluto del comando","args-lines":"argomenti, uno per riga","env-write-only":"I valori env sono write-only: vuoto mantiene il valore esistente.","fleet-new-engine":"Nuovo engine","fleet-new-cell":"Nuova cella","fleet-saved":"Definizione salvata.","fleet-restart-confirm":"Modifica salvata. Riavviare ora: {cells}?","fleet-remove-engine":'Eliminare l’engine "{id}"?',"fleet-remove-cell":'Eliminare la cella "{id}"? Se è attiva verrà prima fermata.',"fleet-cwd-needs-repair":"cartella da riparare","fleet-cwd-repair":"ripara","fleet-cwd-repair-title":"Ripara cartella cella {id}","fleet-cwd-repair-help":"La cartella attuale non è portabile su questo dispositivo: appartiene a un altro dispositivo o non esiste sotto la home. Scegli una cartella home-relative (~) sul dispositivo target; il backend ricalcolerà il percorso assoluto.","fleet-cwd-repair-no-source-path":"Il percorso originale non viene mostrato: è specifico del dispositivo di origine.","fleet-cwd-repair-placeholder":"es. Alpha","fleet-cwd-repair-preview":"Nuova cartella: {path}","fleet-cwd-repair-browse":"sfoglia sotto ~","fleet-cwd-repair-fs-empty":"nessuna sottocartella","fleet-cwd-repair-use-current":"usa questa cartella","fleet-cwd-repair-invalid":'percorso non valido: niente assoluto, "..", barra rovesciata o lettera disco',"fleet-cwd-repair-confirm":"Impostare la cartella della cella {id} su {path}? Verrà ricalcolata sul dispositivo target.","fleet-cwd-repair-unportable":"Il percorso scelto non è portabile su questo dispositivo: deve esistere sotto la home.","fleet-cwd-repair-suggestion":"Suggerimento dal dispositivo:","fleet-cwd-repair-use-suggestion":"usa {path}","fleet-cwd-repaired":"Cartella della cella riparata.","fleet-recovery-kimi-code-consent-yes":"Kimi Code: conferma la custom API key (Yes) nel terminale della cella, poi riavvia la cella.","fleet-recovery-kimi-code-config-custom-api-key":'Kimi Code: nel terminale della cella apri /config e abilita "Use custom API key", poi riavvia la cella. Se la chiave è cambiata, aggiorna la credenziale e riprova.',"fleet-recovery-kimi-cli-login":"Kimi Code CLI: nel terminale della cella esegui /login (device-code Kimi) oppure /provider, poi riavvia la cella.","fleet-readiness-degraded":"Avviata senza conferma di prontezza: potrebbe non elaborare subito. Verifica nel terminale prima di affidarle un incarico.","fleet-vl-prompt-degraded":"Avviata senza il prompt di cella: la versione di vl sul nodo non lo supporta (serve 0.3.1+). La cella lavora senza la sua identità: aggiorna vl prima di affidarle un incarico.","fleet-recovery-client-terminal-dialog":"Completa il dialogo mostrato nel terminale della cella, poi riavvia la cella.","settings-readonly":"READONLY attivo: le modifiche sono bloccate dal server (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"questa macchina guarda altri nodi via tunnel SSH","role-node":"nodo (raggiungibile)","published-port":"porta pubblicata (opzionale)","no-nodes":"nessun nodo remoto configurato","node-add":"collega installazione NexusCrew","node-connect-help":"La porta SSH serve a raggiungere il server SSH. La porta NexusCrew è invece la porta locale mostrata da `nexuscrew status` sul nodo remoto.","node-name-label":"Nome del nodo","node-ssh-label":"Host SSH","pair-ssh-local-label":"Host o alias SSH su questo dispositivo","node-ssh-local-help":"Puoi sostituire l’indirizzo del link con lo stesso alias che funziona usando ssh su questo dispositivo. Alias, agent e chiavi restano locali e non viaggiano nel link.","node-ssh-port-label":"Porta SSH","node-ssh-port-help":"Di solito 22; usa la porta pubblica del server SSH.","node-app-port-label":"Porta NexusCrew sul nodo","node-app-port-help":"È la porta mostrata da `nexuscrew status` sul nodo remoto.","node-name-ph":"nome (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"porta remota (opz.)","node-remove-confirm":'Rimuovere il nodo "{name}"?',"node-remove-warning":"Elimina associazione, credenziali e tunnel locale. Non spegne il dispositivo remoto.","peer-inventory-title":"Nodi collegati al hub","peer-group-hubs":"Hub diretti","peer-group-clients":"Client collegati","peer-group-routed":"Nodi raggiungibili tramite la rete","peer-group-vl":"Nodi VL","vl-owners-unavailable":"Owner VL non raggiunti","peer-routed":"instradato","peer-routed-stale":"instradato, non raggiungibile","peer-visibility":"Visibilità nella rete","node-test":"test","tunnel-start":"avvia tunnel","tunnel-stop":"ferma tunnel","tunnel-restart":"riavvia tunnel","share-node":"Condividi questo nodo","share-local-heading":"Condivisione di questo dispositivo","share-local-hub":"Hub di condivisione","share-local-through":"Condividi {device} tramite {hub}","share-local-active":"Condiviso e raggiungibile dalla rete collegata all’hub.","share-local-pending":"Condivisione richiesta, ma il tunnel è giù: questo dispositivo non è ancora raggiungibile.","share-local-private":"Privato: solo questo dispositivo può usare il collegamento all’hub.","share-local-private-down":"Privato, ma il collegamento all’hub è giù. Riconnetti per applicare e verificare la modalità privata.","share-local-reconnect":"Riconnetti e riconcilia","share-off-hub-reconcile-pending":"Stato privato salvato; la revoca sull’hub è ancora in attesa.","fleet-cell-label":"nome leggibile (facoltativo)","fleet-panel-url":"URL pannello (opzionale)","fleet-panel-url-help":"Endpoint del pannello grafico della cella (es. il noVNC di un container): solo http/https verso un host loopback — il proxy risolve la destinazione sulla macchina che ospita la cella.","fleet-panel-url-invalid":"Il pannello non è un port-forward: chi lo apre sceglie quale cella, mai dove connettersi. L’indirizzo viene risolto sulla macchina che ospita la cella, quindi deve essere raggiungibile lì in loopback — 127.0.0.1, localhost o [::1]. L’indirizzo di un container (es. 172.17.0.2) non lo è.","share-off-local-reconcile-pending":"Revoca confermata dall’hub; il tunnel locale deve ancora riconciliarsi.","share-reverse-pool-pending":"Il canale reverse non risulta spento in modo dimostrabile: resta in quarantena, non chiuso.","share-node-off-desc":"Privato: resta collegato al nodo hub, ma gli altri client non possono raggiungerlo.","share-node-on-desc":"Condiviso: il nodo hub può mostrarlo e smistare celle e deck autorizzati.","peer-shared":"Nodo client condiviso nella rete Hydra","peer-private":"Nodo client privato: collegato, non pubblicato nella rete Hydra","peer-vl-federated":"Nodo VL: federato","row-vl-federated":"federato","node-connected-client":"client collegato","transport-used":"in uso","tunnel-up":"tunnel su","tunnel-down":"tunnel giù","vl-poll-online":"online (poll)","vl-poll-offline":"non risponde","authorized-keys-hint":"incolla questa riga in ~/.ssh/authorized_keys sull'host remoto:",copy:"copia",copied:"copiato","token-rotate":"ruota token","token-rotate-explain":"Il nuovo token NON verrà mostrato: recuperalo con `nexuscrew show token`. La sessione corrente verrà invalidata.","service-regenerate":"rigenera service","npm-auto-update":"aggiornamenti automatici da npm","npm-auto-update-help":"Controlla periodicamente latest e installa solo versioni più recenti. Mai downgrade.","npm-update-current":"installata","npm-update-latest":"npm latest","npm-update-check":"controlla ora","npm-update-install":"aggiorna ora","npm-update-restarting":"Aggiornamento avviato; NexusCrew si riaprirà dopo il riavvio del servizio.","npm-update-idle":"aggiornato","npm-update-never":"mai controllato","npm-update-checking":"controllo in corso","npm-update-available":"aggiornamento disponibile","npm-update-installing":"installazione in corso","npm-update-installed":"installato, riavvio in corso","npm-update-error":"controllo fallito","npm-update-unsupported":"disponibile solo con installazione npm globale","service-installed":"service installato","service-missing":"service non installato","service-active":"attivo","service-inactive":"non attivo",confirm:"conferma",add:"aggiungi",enable:"attiva","wizard-title":"benvenuto in NexusCrew","wizard-skip":"configura dopo dai settings","wizard-step-roles":"ruoli di questa installazione","wizard-step-node":"primo nodo remoto (opzionale)","wizard-done":"tutto pronto","wizard-done-desc":"setup completato — puoi cambiare tutto dai settings",next:"continua",back:"indietro",skip:"salta",finish:"fine","err-node-name":"nome non valido (a-z, 0-9, -, max 32)","err-local-name":"nome locale non valido: usa uno slug univoco, non “localhost”","err-ssh":"ssh non valido (atteso user@host o alias)","err-port":"porta non valida (1–65535)","err-ssh-port":"porta SSH non valida (1–65535)","err-node-port":"porta NexusCrew non valida (1–65535)","node-sessions":"{n} sessioni","tunnel-down-since":"tunnel giù da {t}","node-unreachable":"nodo non raggiungibile","peer-cause-assente":"peer non risponde — in attesa che torni (interrogazioni diradate)","peer-cause-nega":"peer nega l'accesso — concedi il permesso sul nodo remoto","peer-cause-rotta":"rotta inesistente sul peer — aggiorna il nodo","node-passive":"client offline · stato normale","node-offline":"nodo offline","node-offline-seen":"offline · visto {t} fa","node-needs-repair":"legacy · ripeti il pairing","asks-title":"domande dalle celle","ask-dismiss":"Scarta la domanda","ask-reply-ph":"scrivi la risposta…","push-enable":"attiva notifiche push","push-disable":"disattiva notifiche push","push-on":"push attive su questo device","push-off":"push non attive","push-denied":"permesso notifiche negato dal browser","push-unsupported":"push non supportate in questo browser","notification-speech-enable":"leggi le notifiche ad alta voce","notification-speech-help":"Usa la voce del browser solo per nuove notifiche mentre questa PWA è visibile e in primo piano. Con l’app chiusa resta la notifica di sistema.","notification-speech-test":"prova voce","notification-speech-testing":"prova in corso…","notification-speech-preview":"NexusCrew. Notifiche vocali attive.","notification-speech-preview-ok":"Prova vocale completata.","notification-speech-preview-failed":"Il browser non ha avviato la prova vocale. Interagisci con la pagina e riprova.","notification-speech-preview-voice-error":"La prova vocale è fallita: voce o audio non disponibili. Controlla la voce selezionata e riprova.","notification-speech-preview-timeout":"La prova vocale è fallita: nessuna risposta dal motore vocale. Controlla la voce selezionata e riprova.","notification-speech-needs-test":"Per questa sessione dell’app, premi “prova voce” prima di ricevere annunci vocali.","notification-speech-unsupported":"Sintesi vocale non supportata in questo browser.","audio-title":"Audio nativo del nodo","audio-help":"Consenso e controlli valgono solo per questo dispositivo. Share e visibilità non autorizzano suoni.","audio-consent":"consenti TTS su questo nodo","audio-consent-help":"Permette a celle autorizzate, locali o remote, di consegnare un comando vocale. Puoi revocarlo in ogni momento.","audio-capability":"Capability locale","audio-loading":"leggo lo stato audio locale…","audio-adapter":"adapter","audio-adapter-none":"nessuno","audio-installed":"installato","audio-installed-yes":"sì","audio-installed-no":"no","audio-liveness":"disponibilità","audio-liveness-ready":"pronto ad accettare","audio-liveness-unavailable":"non disponibile","audio-languages":"lingue dichiarate","audio-limits":"limiti","audio-test":"prova audio locale","audio-testing":"prova in corso…","audio-stop":"ferma audio locale","audio-stopping":"stop in corso…","audio-test-needs-consent":"Attiva il consenso locale prima di provare la voce.","audio-unavailable":"Nessun adapter TTS nativo disponibile su questo nodo.","audio-test-accepted":"Il nodo ha accettato la prova. Non dimostra che qualcuno l’abbia udita.","audio-test-refused":"Il nodo ha rifiutato la prova.","audio-test-unknown":"Esito della prova sconosciuto: il nodo non può confermare l’avvio.","audio-stop-stopped":"Audio locale fermato.","audio-stop-idle":"Nessun enunciato locale da fermare.","audio-groups-title":"Gruppi audio condivisi","audio-groups-help":"Decide su quali dispositivi si sente la voce quando una cella parla. Il gruppo è una preferenza locale di consegna, non un consenso. Ogni nodo conserva consenso, ACL, disponibilità e Stop locale.","audio-groups-empty":"Nessun gruppo: la voce esce solo su questo nodo.","audio-group-name":"nome gruppo","audio-group-mode":"modalità consegna","audio-group-primary":"primo disponibile (in ordine)","audio-group-fanout":"tutti i nodi elencati","audio-group-targets":"nodi target esatti","audio-group-local":"questo nodo","audio-group-unavailable-target":"non rilevato ora","audio-group-no-targets":"Nessun nodo con instanceId disponibile. Il gruppo non può usare nomi, wildcard o “tutti”.","audio-group-new":"nuovo gruppo","audio-group-edit":"modifica","audio-group-delete":"elimina","audio-group-save":"salva gruppo","audio-group-cancel":"annulla","audio-group-invalid":"Il gruppo richiede un nome valido e almeno un nodeId esatto.","audio-group-save-failed":"Salvataggio gruppo audio non riuscito.","node-display-label":"Nome (etichetta)","routed-node-aliases":"Alias nodi instradati","routed-node-aliases-help":"Visibili solo su questo dispositivo; route e nome remoto non cambiano.","node-local-alias":"Alias su questo dispositivo","alias-on-device":"Alias su questo dispositivo","reset-alias":"Ripristina nome remoto","node-slug-hint":"routing su slug: {slug}","device-name-label":"Nome dispositivo","device-name-hint":"come ti vedono i peer (modificabile)","local-route-name-label":"Nome locale / route","local-route-name-hint":"handle tecnico stabile: label leggibile + suffisso del nodeId; modificabile prima della connessione","err-label":"etichetta non valida (max 64 char, niente a capo)","fleet-inventory":"Celle e sessioni","fleet-inventory-help":"tutte le posizioni (Locale + route Hydra)","fleet-manage-location":"Gestisci posizione","fleet-network-overview":"Panoramica rete","fleet-manage-help":"crea e configura celle nella posizione selezionata","fleet-overview-help":"stato operativo di tutte le posizioni, senza duplicare l’editor","fleet-inventory-empty":"nessuna cella o sessione","cell-switcher-refreshing":"aggiorno le celle…","cell-switcher-empty-active":"nessuna cella attiva verificata","cell-switcher-not-confirmed":"stato non confermato","cell-switcher-not-active":"questa cella non è più attiva","cell-switcher-verify-failed":"Verifica non riuscita: riprova tra poco.","cell-switcher-select":"seleziona una cella","cell-switcher-open":"apri cella","cell-switcher-show-all":"tutte","cell-switcher-show-active":"attive","cell-switcher-close":"chiudi selettore celle","fleet-not-available":"fleet non disponibile su questa posizione",start:"avvia",stop:"ferma",restart:"riavvia",delete:"elimina","copy-manual":"copia non riuscita — seleziona e Cmd+C, o copia a mano","copy-empty":"niente selezione: trascina con Shift per selezionare","selection-held":"evidenziazione persa, testo ancora in mano","selection-changed":"il testo sotto la selezione è cambiato","invite-hub-only":"Un invito si conia sull’hub. Ammettere un nodo nuovo è la sola cosa che un nodo collegato non può chiedere per conto di un altro: apri NexusCrew sull’hub e crea l’invito da lì.","row-private":"privato","node-detail-open":"apri il dettaglio","node-detail-reach":"Raggiungibilità","node-detail-route":"percorso","node-detail-ssh":"SSH","node-detail-transport":"trasporto","node-detail-owner":"owner","node-detail-authority":"Cosa può fare questo nodo","authority-owner-equivalent":"Autorità pari alla tua: un nodo accoppiato può fare su questa macchina tutto quello che puoi fare tu.","authority-routed":"Non è accoppiato con questa macchina: la sua autorità vive presso l’hub che lo instrada.","authority-no-grants":"L’unico potere per-nodo che esiste è la scelta delle celle, qui sotto. Dentro quelle celle l’autorità resta piena.","authority-no-grants-elsewhere":"L’unico potere per-nodo che esiste è la scelta delle celle, e si imposta sull’installazione che le possiede — non da qui.","node-detail-network-view":"Cosa vede di questa rete","node-detail-command":"Comando","vl-no-commands":"Il device non dichiara comandi disponibili.","vl-events-title":"Sessione","vl-events-empty":"Nessun evento in memoria: la sessione non ha ancora parlato, oppure quello che ha detto è uscito dal buffer. La storia resta sul device.","vl-events-gap":"eventi non ricevuti:","vl-events-truncated":"contenuto troncato dal device","vl-events-turn-end":"— fine turno —","vl-events-done":"— fine risposta —","vl-events-writer-epoch":"— cambio scrittore —","vl-events-tool":"strumento","vl-events-tool-ok":"concluso","vl-events-tool-failed":"fallito","vl-events-usage":"consumo aggiornato","vl-events-stale":"Aggiornamento non riuscito: quello che vedi potrebbe non essere l’ultimo.","vl-cmd-phase-submitted":"inviato, in attesa di conferma","vl-cmd-phase-inflight":"in corso","vl-cmd-phase-done-ok":"completato","vl-cmd-phase-done-error":"fallito","vl-cmd-status":"stato","vl-cmd-health":"salute","vl-cmd-start":"avvia","vl-cmd-stop":"ferma","vl-cmd-restart":"riavvia","vl-cmd-version":"versione","vl-cmd-capabilities":"capacità","vl-cmd-logs":"log","vl-cmd-prompt":"prompt","vl-prompt-placeholder":"scrivi il prompt per la sessione del device…","vl-prompt-send":"invia prompt","vl-cmd-unpair":"disaccoppia","node-grant-none":"Nessun nodo scelto: condiviso, ma verso nessuno.","node-grant-unknown":"non più in inventario","node-grant-remove":"togli","node-grant-add":"Aggiungi un nodo","node-grant-search":"Cerca fra i nodi","node-grant-no-candidates":"Nessun nodo corrisponde.","cell-scope":"Celle visibili a questo nodo","cell-scope-help":"Vale su cio’ che questo nodo elenca e su cio’ che può toccare, terminale compreso. Dentro le celle concesse resta un nodo accoppiato a pieno titolo: non è una sandbox.","cell-scope-all":"tutte le celle","cell-scope-none":"nessuna cella","cell-scope-selected":"celle selezionate","cell-scope-none-granted":"Nessuna cella scelta: questo nodo non ne vede nessuna.","cell-scope-unknown":"cella non più esistente","cell-scope-add":"Aggiungi una cella","cell-scope-search":"Cerca fra le celle","cell-scope-no-candidates":"Nessuna cella corrisponde.","cell-scope-reset-warning":"Cambiando modo l’elenco viene azzerato: tornando a «celle selezionate» andrà rifatto.","cell-scope-list-unavailable":"Elenco delle celle non disponibile ora: le concessioni qui sotto restano valide, ma non si può dire se esistono ancora.","single-view":"vista singola",retract:"riduci","keybar-expand":"espandi la barra tasti","keybar-retract":"riduci la barra tasti","save-and-start":"salva e avvia",permissions:"Permessi","power-on-hint":"Spegni la cella; puoi anche toglierla dal boot.","launch-engine-help":"Provider, credenziali e nuovi engine si creano in Impostazioni → Flotta. Modello e permessi sono per questa cella.","launch-unavailable-hint":"Configurazione engine non disponibile su questo nodo.","import-as-cell":"Importa come cella","import-help":"Riconcilia una sessione tmux esistente in una cella gestita. Scegli un engine già dichiarato: nessun engine viene inventato.","import-engine-required":"scegli un engine (obbligatorio)","test-and-connect":"testa e collega","pairing-v2-hint":"Incolla o scansiona UN solo link: precompila nome, Host SSH ed etichetta quando il link li include (v2).","invite-v2-hint":"Crea un invito monouso. Serve l’indirizzo SSH di questo dispositivo, raggiungibile da chi lo userà.","invite-target-local":"Il nuovo dispositivo entrerà in","invite-target-this":"questo dispositivo","invite-endpoint-label":"Indirizzo SSH di questo hub visto dagli altri dispositivi","invite-endpoint-auto":"Endpoint già configurato","invite-endpoint-needed":"Inserisci user@host o un alias SSH condiviso. Non è 127.0.0.1 e non è l’URL HTTP NexusCrew.","invite-ssh-hint":"Il target SSH con cui L’ALTRO dispositivo raggiunge QUESTA installazione (user@host o alias). Obbligatorio: viene incluso nel link.","invite-next-steps":"copia questo link, apri NexusCrew sull’altro dispositivo e incollalo in Impostazioni → Nodi (o scansiona il QR): al resto pensa NexusCrew","pair-card-title":"collega con un solo link","pair-card-help":"Incolla il link di pairing generato sull’altro dispositivo (o scansiona il suo QR): NexusCrew decodifica, prova la connessione SSH e collega da solo.","pair-paste-ph":"incolla qui il link di pairing","pair-paste-btn":"incolla","pair-advanced":"avanzate / modifica","pair-progress":"collegamento in corso: SSH → invito → conferma → verifica…","pair-retry":"riprova","pair-invalid-link":"questo non è un link di pairing valido","pair-invalid-hint":"serve il link completo (http://…#pair=…) generato dall’altro NexusCrew: non aprirlo, incollalo qui","pair-missing-ssh":"il link non include il target SSH (formato v1): indica in “avanzate” come questo dispositivo raggiunge l’altro via SSH — non viene mai inventato","pair-missing-name":"manca il nome del nodo: completalo in “avanzate”","pair-clipboard-denied":"lettura degli appunti non consentita: incolla manualmente nel campo","pair-clipboard-empty":"appunti vuoti: copia prima il link di pairing","pair-stage-validation":"dati non validi","pair-stage-conflict":"nome già in uso","pair-stage-ssh-start":"avvio del tunnel SSH fallito","pair-stage-ssh-ready":"peer non raggiungibile via SSH","pair-stage-join":"scambio dell’invito fallito","pair-stage-tunnel-final":"tunnel negoziato fallito","pair-stage-confirm":"conferma del pairing fallita","pair-stage-health":"verifica finale della federazione fallita","pair-stage-internal":"errore interno","pair-stage-generic":"connessione fallita","qr-no-camera":"nessuna camera disponibile su questo dispositivo: usa una foto del QR","qr-permission":"permesso camera negato: consentilo nel browser o usa una foto del QR","qr-unsupported":"scanner live non supportato qui: carica una foto del QR","qr-upload":"usa una foto"},en:{"update-available":"new version {v} available","update-stale":"interface out of step: you are running v{browser}, the node is serving v{ui}. reload without cache; if it persists, restart the node","reload-no-cache":"reload without cache","update-installed-restart":"version {v} installed: restart the node","update-dismiss":"close","install-version-mismatch":"incomplete installation: frontend and server do not match (v{v})",reload:"reload","grid-empty":"drag a session here from the sidebar, or double-click for single view","grid-full":"a deck can show at most 9 sessions",pin:"pin to top",reorder:"reorder","host-lease-live":"live host: supervision active","host-lease-grace":"live host: supervision recovering (grace)","host-lease-expired":"live host: supervision expired","host-lease-none":"live host: never supervised","host-lease-unavailable":"live host: supervision guarantee not available on this node","reorder-help":"drag the handle; keyboard up/down arrows","rename-node":"rename node","rename-node-prompt":"New node name in NexusCrew","rename-node-invalid":"Invalid name: maximum 64 characters, no line breaks.","reorder-deck-help":"drag the deck; keyboard left/right arrows",sessions:"sessions","new-session":"new session",new:"new",fleet:"Fleet","fleet-tmux":"tmux fleet","other-sessions":"Other sessions","view-all":"all","view-pinned":"pinned","view-active":"active","view-off":"off","view-technical":"technical","mark-technical":"hide as technical session","mark-normal":"show as normal session","position-local":"Local",files:"files",refresh:"refresh","filter-placeholder":"filter sessions…","loading-fleet":"loading fleet…","no-sessions":"no live tmux sessions — the fleet starts at boot (systemd)","no-match":'no session matches "{q}"',"copy-url":"click to copy URL","ssh-only":"SSH/VPN tunnel only","new-files-outbox":"new files in outbox",terminate:"terminate","terminate-confirm":'Terminate session "{name}"?',"cell-on":"tmux alive","cell-off":"off","cell-working":"working","cell-idle":"idle","cell-degraded":"degraded: unit active, tmux dead","power-on":"power on","power-off":"power off","boot-enable":"enable at boot","boot-disable":"disable at boot","state-on":"running","state-off":"stopped",engine:"Engine",model:"Model","model-default":"Provider default model","model-remembered":"Last model used with this engine","boot-persist":"start at boot","remove-boot":"also remove from boot","power-config-in-settings":"Edit engine, provider, profile, model and permissions in Settings → Fleet.","no-remote-control":"⚠ non-native engine: no claude.ai app RC (you can still drive it from here)",cancel:"cancel",name:"name","name-invalid":"invalid name: a-zA-Z0-9._- max 64, no leading '-'",cwd:"folder",browse:"browse","fs-home":"home","fs-parent":".. up",preset:"preset","preset-2x2":"2×2 grid","preset-columns":"columns","preset-equalize":"equalize",collapse:"collapse",expand:"expand",create:"create","auth-prompt":"Paste the token (printed by the server):","remember-device":"remember on this device","zoom-out":"smaller text","zoom-in":"bigger text","terminal-renderer-webgl":"WebGL","terminal-renderer-dom":"DOM","terminal-renderer-switch":"graphics renderer: requested {requested}, in use {effective} — tap to switch (reloads the terminal)",composer:"composer",panel:"panel","panel-none":"No panel configured for this cell.","panel-checking":"Opening panel…","panel-not-granted":"This node does not grant the panel to the requester: access must be granted on the node that owns the cell, not by retrying here.","panel-denied":"Panel entry refused: the ticket is no longer valid. Retry: a new ticket will be requested.","cell-peek":"Peek without switching cell","cell-tele-ctx":"context","cell-tele-free":"free","cell-tele-5h":"5h used","cell-tele-7d":"7d used","cell-activity":"activity","cell-activity-now":"now","cell-peek-preview":"Preview","cell-peek-stream":"Stream","cell-peek-panel":"Panel","cell-peek-vuoto":"No preview available for this cell.","panel-node-refused":"The node that owns the cell refuses the request: it is read-only, or its policy blocks this operation. Retrying here does not change the outcome.","panel-unauthorized":"Invalid credential for this node: fix it where it is configured, not by retrying from here.","panel-unreachable":"The panel is not reachable through this node: retry in a little while.","panel-frame-loading":"panel mounted: loading in progress","panel-frame-error":"The panel frame did not load: the ticket may have expired (30 s lifetime, single-use) or the destination is unreachable. Retry: a fresh ticket will be requested.","popup-drag-hint":"drag to move; double-click to recenter","popup-resize-hint":"drag to resize","panel-timeout":"The panel did not answer in time: service slow to start or overloaded. Retry in a little while.","panel-retry":"Retry","live-host-not-granted":"This node does not grant the live host cell designation to the requester: it must be granted on the node that owns the cell (nodes live-host <node> on), not by retrying here.","live-host-error":"The live host cell designation failed: retry in a little while.","host-thread-designated":"cell designated; thread absent","host-thread-present":"thread present but idle","host-thread-active":"thread active","host-thread-unknown":"thread status unknown",windows:"{n} windows","empty-files":"empty",upload:"upload","no-sessions-short":"no sessions","composer-placeholder":"type or dictate…","composer-history-tools":"input history and size","composer-history":"cell history","composer-history-empty":"no submitted input","composer-history-clear":"clear this cell history","composer-expand":"expand input","composer-collapse":"collapse input","composer-clear-data":"clear drafts and history","composer-clear-data-help":"Removes every saved cell draft and input-history entry from this browser.","composer-clear-confirm":"Clear every saved draft and input-history entry from this browser?","composer-clear-done":"Drafts and history cleared.","composer-clear-failed":"Could not clear composer data in this browser.",attach:"attach","attach-file":"File","attach-camera":"Camera","attach-gallery":"Gallery","attach-inbox":"Add Inbox","attach-inbox-done":"{n} file added to the inbox","attach-uploading":"uploading…","attach-upload-progress":"attachment {n}/{total}…","attach-uploaded":"{n} attachments uploaded",voice:"voice",send:"send","composer-send-failed":"connection not ready — text kept, try again",close:"close","lang-label":"language",decks:"decks","new-deck":"new deck","deck-name":"deck name","open-deck-window":"open in a new window","detach-deck":"detach into a new window","deck-current":"this deck (current window)","deck-owner-unavailable":"owner node is not shared or reachable","rename-deck":"rename deck","delete-deck":"delete deck","delete-deck-confirm":'Delete deck "{name}"?',"send-to-deck":"send to deck…","deck-autosave":"autosave",saving:"saving…",saved:"saved","popup-blocked":"popup blocked: open here","expand-owner":"expand {owner} decks","collapse-owner":"collapse {owner} decks","owner-deck-count-one":"{count} deck","owner-deck-count-many":"{count} decks","dot-working":"in use (active window)","dot-on":"open in background","dot-neutral":"not open","dot-warn":"owner offline","select-drag":"drag to select","copy-manual":"select and copy manually","toggle-sidebar":"show/hide the sidebar",settings:"settings","tab-roles":"roles","tab-nodes":"nodes",local:"Local",location:"Location","pairing-link":"pairing link","pairing-required":"name, SSH alias and pairing link are required","pairing-connect-help":"Connecting a node requires a name, a working SSH Host, and a link/QR created by the other NexusCrew installation.","pairing-localhost-hint":"127.0.0.1 in the link is correct: do not open it here. NexusCrew carries the invite and port through the SSH Host.","scan-qr":"scan QR","pairing-qr-invalid":"invalid pairing QR","invite-node":"invite a node","create-pairing-link":"create link / QR","visibility-network":"whole network","visibility-relay":"relay only","visibility-selected":"selected nodes","hydra-simple":"local + nodes, one network","local-ready":"This device is ready. Use it alone or connect it to a node.","local-only":"local only","add-node":"add node",connect:"connect","node-connected":"Node connected. The network will synchronize automatically.","pair-authkeys-title":"Line to replace in ~/.ssh/authorized_keys on the peer","pair-authkeys-hint":"Without this line the panel forward stays refused: the tunnel looks up while the panel does not answer.","pair-authkeys-copy":"Copy the line","pair-authkeys-copied":"Line copied","tab-system":"system","tab-fleet":"fleet","tab-audio":"audio","system-general":"general","system-diagnostics":"diagnostics","system-this-node":"this node","system-updates":"updates","system-security":"security","system-local-data":"local browser data","system-terminal":"terminal","alternate-screen":"alternate screen","alternate-screen-help":"Keeps standard tmux behaviour for new NexusCrew sessions. An application that tracks the mouse scrolls on its own; the others browse the tmux scrollback. It does not change cells already running.","tab-input":"input","tab-diagnostics":"diagnostics","input-settings-local":"Local preferences for this browser. They apply immediately to single view and decks without changing the remote node.","terminal-keyboard-gesture":"Open the virtual keyboard from the terminal","terminal-keyboard-double-tap":"Double tap (default)","terminal-keyboard-single-tap":"Single tap","terminal-keyboard-never":"Never from terminal","terminal-keyboard-gesture-help":"The keypad and STT use the separate controls below. Mouse and physical keyboard remain available.","keybar-ime-lock":"Keypad: keep the virtual keyboard closed","keybar-ime-lock-help":"ESC, arrows, PgUp/PgDn, Enter and menu send directly to the PTY without focusing a text field.","voice-ime-lock":"STT microphone: keep the virtual keyboard closed","voice-ime-lock-help":"Tapping the microphone starts or stops voice without focusing the composer.","keybar-enter-show":"Show the tall Enter keypad key","keybar-enter-show-help":"Enter stays to the right of PgUp/PgDn and spans both rows.","keybar-layout":"Keypad layout","keybar-layout-full":"Full (default)","keybar-layout-compact":"Compact","keybar-layout-help":"Compact: one row with an expand toggle that reaches the full key set without changing the preference.","input-settings-reset":"restore input defaults","diagnostics-local":"This node","diagnostics-target":"Node to diagnose","diagnostics-verbose":"Temporary verbose logs","diagnostics-duration":"Verbose duration","diagnostics-expires":"Verbose enabled until {time}","diagnostics-off":"Verbose is off; operational warnings and errors remain available.","diagnostics-level":"Level","diagnostics-all-levels":"all levels","diagnostics-component":"component","diagnostics-pause":"pause","diagnostics-autoscroll":"autoscroll","diagnostics-log":"Sanitized diagnostic log","diagnostics-empty":"No diagnostic events.","diagnostics-export":"export JSON","diagnostics-export-failed":"Export is not available in this browser.","diagnostics-clear":"clear","diagnostics-clear-confirm":"Clear this node diagnostic buffer?","diagnostics-unsupported":"This peer is offline or does not support structured diagnostics.","fleet-editor-loading":"Loading the Fleet editor…","fleet-editor-load-error":"Unable to load the Fleet editor.","fleet-editor-unavailable":"The Fleet editor is unavailable at this location.","fleet-stale":"Fleet read failed: the cell list may not be up to date.","fleet-off":"Fleet unavailable: no cells.","fleet-managed":"managed by NexusCrew","fleet-custom":"custom command","fleet-managed-help":"Client, provider and launch are managed internally; secrets are never displayed.","fleet-shell-engine-help":"The local shell is resolved on the device at launch time; no executable path is stored in backups.","fleet-shell-command-placeholder":"optional command, e.g. npm test","fleet-shell-command-help":"Runs through an interactive login shell (-lic), with the user PATH and aliases. The cell stops when the command finishes; immediate failures are reported.","fleet-shell-command-metachar":"Pipes, redirects, variables, and other metacharacters are interpreted by the device shell.","fleet-shell-interactive":"Empty: opens a local interactive shell and keeps the cell active.","fleet-shell-launch-help":"Configure the Shell command on the cell in Settings → Fleet.","fleet-credential-title":"API key on this device","fleet-credential-help":"The key stays only on the selected node and is never displayed or exported. If the node is remote, the value travels to it over the paired channel.","fleet-credential-set":"set key","fleet-credential-change":"change key","fleet-credential-forget":"forget","fleet-credential-saved":"Key saved locally.","fleet-credential-removed":"Local key removed.","fleet-credential-remove-confirm":"Remove the local {key} key?","fleet-credential-source-environment":"environment","fleet-credential-source-local":"local store","fleet-credential-source-compatibility":"compatible config","fleet-credential-source-missing":"missing","fleet-credential-source-nexuscrew-store":"NexusCrew store","fleet-credential-source-unreadable":"unreadable","fleet-credential-source-login":"client login","fleet-credential-source-none":"none","fleet-credential-source-policy":"credential source","fleet-credential-source-policy-auto":"auto (legacy precedence)","fleet-credential-source-policy-nexuscrew-store":"NexusCrew store only","fleet-credential-source-policy-environment":"environment only","fleet-key-section":"KEY","fleet-key-variable":"Variable","fleet-key-value":"Value for {key}","fleet-key-used-by":"Used by: {engines}","fleet-key-used-by-none":"Not yet used by configured engines on this node.","fleet-key-shared-impact":"Replacing or removing {key} affects every listed engine: {engines}.","fleet-key-enter":"enter the key","fleet-key-blank-keeps":"blank = keep the current source","fleet-key-reveal":"reveal","fleet-key-hide":"hide","fleet-key-local-help":"The value stays write-only on the selected node: it is never read back over the network and never enters engines or backups. If the selected node is remote, the value reaches it over the paired channel.","fleet-key-create-missing":"Explicitly create the engine without a key (it will remain “key required”).","fleet-key-partial-create":"Engine created; the key was not saved. Retry without creating a duplicate.","fleet-key-partial-edit":"Engine updated; the key was not saved. The engine changes remain applied.","fleet-provider-notice-claude-openrouter":"Claude Code is optimized for Anthropic models; other providers may not work correctly. Fast mode requires the first-party Anthropic provider.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses is beta and stateless; Codex-VL has no Chat Completions fallback.","fleet-provider-notice-claude-kimi-code":"Kimi Code uses isolated Claude configuration with dedicated onboarding and fast-mode flags; native Claude configuration is not modified, but its MCP tools are inherited.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal uses only ALIBABA_CODE_API_KEY from the local credential layer; qwen3.8-max is the default and no OpenAI/PAYG fallback is used.","fleet-provider-notice-kimi-native":'Native Kimi Code CLI uses the CLI login (device code) and its own configuration: NexusCrew never reads or copies credentials. Distinct from the Claude Code "Kimi Code" provider, which remains the managed K3 path.',"fleet-model-default":"default model (optional)","fleet-model-required":"model (required)","fleet-standard-permissions":"standard permissions","fleet-unsafe-permissions":"unsafe · bypass approvals/sandbox","fleet-unsafe-warning":"Explicit unsafe mode: the worker can act without normal approval or sandbox gates.","fleet-provider-display":"provider display name","fleet-custom-provider-default":"Custom provider","fleet-api-key-env":"API_KEY_ENV_NAME","fleet-provider-id":"provider-id","fleet-custom-secret-help":"NexusCrew stores only the environment-variable name, never its value.","cell-prompt":"Cell start-up prompt","cell-prompt-help":"Sent to the cell when it starts: this is its standing brief. Empty means no prompt — the cell just starts.","fleet-boot":"start at boot","fleet-remote-control":"remote control","cell-mcp":"MCP tools","cell-mcp-all":"all","cell-mcp-none":"none","cell-mcp-some":"chosen","cell-mcp-inert":"For this client, MCP tools are registered by the client in its own config, not NexusCrew: the selection here has no effect.","cell-mcp-help":"“All” is the long-standing behaviour. “None” is the only CERTAIN exclusion: it removes every tool and does not depend on where the servers are defined — that is what you want for a cell you do not trust. “Chosen” grants by name, but the list only covers servers this node can enumerate: plugins and connectors do not appear and would stay available.","fleet-model-override":"model override","fleet-ready":"ready","fleet-not-ready":"not configured","fleet-engines":"Engines","fleet-cells":"Cells / cloud sessions","fleet-models":"Declared models","fleet-no-models":"No declared model: the built-in catalog is used.","model-editor-engine":"Profile","model-editor-id":"Model id","model-editor-id-help":"The exact id the provider expects. Profile and id cannot be changed later: withdraw and declare again.","model-editor-context":"Context window (tokens)","model-editor-max-tokens":"Max output tokens","model-editor-reasoning":"Supports extended reasoning","model-test":"Test against the API","model-test-running":"Testing…","model-test-ok":"responds","model-test-unknown-model":"the provider does not know this id","model-test-auth":"credential missing or refused","model-test-unreachable":"endpoint unreachable","model-test-unverified":"not verified","model-test-unverified-help":"This does not mean it fails: this provider does not expose a model list, so the test could say neither yes nor no.","model-remove":"Withdraw","model-in-use":"in use","fleet-backup":"backup / restore","fleet-backup-help":"Selectively export or restore engines, cells, declared models, and system prompts. Tokens, API keys, and provider secrets never enter the file.","fleet-backup-export":"export","fleet-backup-import":"import","fleet-backup-download":"download backup","fleet-backup-restore":"restore selected","fleet-backup-import-help":"Choose a JSON backup, review the cells and select a destination engine before restoring.","fleet-backup-overwrite":"overwrites existing cell","fleet-backup-new":"new cell","fleet-backup-engine-missing":"choose an available engine","fleet-backup-restore-unavailable":"The selected node supports export only; update it to restore backups.","fleet-backup-restored":"{n} cells restored","fleet-backup-confirm-overwrite":"Overwrite these cells? {cells}","fleet-backup-needs-restart":"restart required: {cells}","fleet-backup-empty":"no cells to export","fleet-backup-select-one":"select at least one cell","fleet-backup-too-large":"backup is too large (1 MB maximum)","fleet-backup-invalid-json":"the file does not contain valid JSON","fleet-backup-invalid-format":"unsupported backup format or version","fleet-backup-invalid-cell":"the backup contains an invalid cell","fleet-backup-duplicate-cell":"the backup contains duplicate cell IDs","fleet-backup-invalid-engine":"the backup contains an invalid engine","fleet-backup-duplicate-engine":"the backup contains duplicate engine IDs","fleet-backup-invalid-model":"the backup contains an invalid model","fleet-backup-duplicate-model":"the backup contains duplicate models","fleet-backup-confirm-engine-overwrite":"Overwrite these engines? Environment values already configured on the target stay unchanged. {engines}","fleet-backup-env-names":"environment names","fleet-backup-env-values-required":"environment values must be configured on this device","fleet-system-prompt":"system prompt",characters:"characters","select-all":"select all","select-none":"select none",edit:"edit",save:"save",label:"label","command-path":"absolute command path","args-lines":"arguments, one per line","env-write-only":"Environment values are write-only: blank keeps the existing value.","fleet-new-engine":"New engine","fleet-new-cell":"New cell","fleet-saved":"Definition saved.","fleet-restart-confirm":"Change saved. Restart now: {cells}?","fleet-remove-engine":'Delete engine "{id}"?',"fleet-remove-cell":'Delete cell "{id}"? If active it will be stopped first.',"fleet-cwd-needs-repair":"folder needs repair","fleet-cwd-repair":"repair","fleet-cwd-repair-title":"Repair cell folder {id}","fleet-cwd-repair-help":"The current folder is not portable on this device: it belongs to another device or does not exist under the home directory. Choose a home-relative (~) folder on the target device; the backend will recompute the absolute path.","fleet-cwd-repair-no-source-path":"The original path is not shown: it is specific to the source device.","fleet-cwd-repair-placeholder":"e.g. Alpha","fleet-cwd-repair-preview":"New folder: {path}","fleet-cwd-repair-browse":"browse under ~","fleet-cwd-repair-fs-empty":"no subfolders","fleet-cwd-repair-use-current":"use this folder","fleet-cwd-repair-invalid":'invalid path: no absolute path, "..", backslash or drive letter',"fleet-cwd-repair-confirm":"Set the folder of cell {id} to {path}? It will be recomputed on the target device.","fleet-cwd-repair-unportable":"The chosen path is not portable on this device: it must exist under the home directory.","fleet-cwd-repair-suggestion":"Suggestion from device:","fleet-cwd-repair-use-suggestion":"use {path}","fleet-cwd-repaired":"Cell folder repaired.","fleet-recovery-kimi-code-consent-yes":"Kimi Code: confirm the custom API key (Yes) in the cell terminal, then restart the cell.","fleet-recovery-kimi-code-config-custom-api-key":'Kimi Code: in the cell terminal open /config and enable "Use custom API key", then restart the cell. If the key changed, update the credential and retry.',"fleet-recovery-kimi-cli-login":"Kimi Code CLI: in the cell terminal run /login (Kimi device code) or /provider, then restart the cell.","fleet-readiness-degraded":"Started without readiness confirmation: it may not process right away. Check its terminal before assigning work.","fleet-vl-prompt-degraded":"Started without its cell prompt: the vl version on this node does not support it (0.3.1+ required). The cell works without its identity: upgrade vl before assigning work.","fleet-recovery-client-terminal-dialog":"Complete the dialog shown in the cell terminal, then restart the cell.","settings-readonly":"READONLY active: changes are blocked by the server (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"this machine watches other nodes via SSH tunnels","role-node":"node (reachable)","published-port":"published port (optional)","no-nodes":"no remote nodes configured","node-add":"connect a NexusCrew installation","node-connect-help":"The SSH port reaches the SSH server. The NexusCrew port is the local port reported by `nexuscrew status` on the remote node.","node-name-label":"Node name","node-ssh-label":"SSH host","pair-ssh-local-label":"SSH host or alias on this device","node-ssh-local-help":"You may replace the link address with the same alias that works with ssh on this device. Aliases, agents and private keys stay local and are never carried in the link.","node-ssh-port-label":"SSH port","node-ssh-port-help":"Usually 22; use the SSH server public port.","node-app-port-label":"NexusCrew port on node","node-app-port-help":"The port reported by `nexuscrew status` on the remote node.","node-name-ph":"name (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"remote port (opt.)","node-remove-confirm":'Remove node "{name}"?',"node-remove-warning":"Deletes the pairing, credentials and local tunnel. It does not power off the remote device.","peer-inventory-title":"Nodes connected to the hub","peer-group-hubs":"Direct hubs","peer-group-clients":"Connected clients","peer-group-routed":"Nodes reachable through the network","peer-group-vl":"VL nodes","vl-owners-unavailable":"VL owners unreachable","peer-routed":"routed","peer-routed-stale":"routed, unreachable","peer-visibility":"Network visibility","node-test":"test","tunnel-start":"start tunnel","tunnel-stop":"stop tunnel","tunnel-restart":"restart tunnel","share-node":"Share this node","share-local-heading":"Share this device","share-local-hub":"Sharing hub","share-local-through":"Share {device} through {hub}","share-local-active":"Shared and reachable by the network connected to the hub.","share-local-pending":"Sharing is requested, but the tunnel is down: this device is not reachable yet.","share-local-private":"Private: only this device can use its hub connection.","share-local-private-down":"Private, but the hub connection is down. Reconnect to apply and verify private mode.","share-local-reconnect":"Reconnect and reconcile","share-off-hub-reconcile-pending":"Private state saved; hub revocation is still pending.","fleet-cell-label":"readable name (optional)","fleet-panel-url":"Panel URL (optional)","fleet-panel-url-help":"Graphical panel endpoint for the cell (e.g. a container's noVNC): http/https only, toward a loopback host — the proxy resolves the destination on the machine that hosts the cell.","fleet-panel-url-invalid":"The panel is not a port-forward: whoever opens it picks which cell, never where to connect. The address is resolved on the machine that hosts the cell, so it must be reachable there on loopback — 127.0.0.1, localhost, or [::1]. A container's address (e.g. 172.17.0.2) is not.","share-off-local-reconcile-pending":"Hub revocation confirmed; the local tunnel still needs reconciliation.","share-reverse-pool-pending":"The reverse channel was not demonstrably shut down: it is quarantined, not closed.","share-node-off-desc":"Private: it stays connected to the hub, but other clients cannot reach it.","share-node-on-desc":"Shared: the hub may advertise it and route authorized cells and decks.","peer-shared":"Client node shared on the Hydra network","peer-private":"Private client node: connected, not published on Hydra","peer-vl-federated":"VL node: federated","row-vl-federated":"federated","node-connected-client":"connected client","transport-used":"in use","tunnel-up":"tunnel up","tunnel-down":"tunnel down","vl-poll-online":"online (poll)","vl-poll-offline":"not responding","authorized-keys-hint":"paste this line into ~/.ssh/authorized_keys on the remote host:",copy:"copy",copied:"copied","token-rotate":"rotate token","token-rotate-explain":"The new token will NOT be shown: retrieve it with `nexuscrew show token`. The current session will be invalidated.","service-regenerate":"regenerate service","npm-auto-update":"automatic updates from npm","npm-auto-update-help":"Periodically checks latest and installs only newer versions. Never downgrades.","npm-update-current":"installed","npm-update-latest":"npm latest","npm-update-check":"check now","npm-update-install":"update now","npm-update-restarting":"Update started; NexusCrew will return after the service restarts.","npm-update-idle":"up to date","npm-update-never":"never checked","npm-update-checking":"checking","npm-update-available":"update available","npm-update-installing":"installing","npm-update-installed":"installed, restarting","npm-update-error":"check failed","npm-update-unsupported":"available only for global npm installations","service-installed":"service installed","service-missing":"service not installed","service-active":"active","service-inactive":"not active",confirm:"confirm",add:"add",enable:"enable","wizard-title":"welcome to NexusCrew","wizard-skip":"configure later from settings","wizard-step-roles":"roles of this install","wizard-step-node":"first remote node (optional)","wizard-done":"all set","wizard-done-desc":"setup complete — you can change everything from settings",next:"continue",back:"back",skip:"skip",finish:"finish","err-node-name":"invalid name (a-z, 0-9, -, max 32)","err-local-name":"invalid local name: use a unique slug, not “localhost”","err-ssh":"invalid ssh (expected user@host or alias)","err-port":"invalid port (1–65535)","err-ssh-port":"invalid SSH port (1–65535)","err-node-port":"invalid NexusCrew port (1–65535)","node-sessions":"{n} sessions","tunnel-down-since":"tunnel down for {t}","node-unreachable":"node unreachable","peer-cause-assente":"peer not responding — waiting for it to come back (polls spaced out)","peer-cause-nega":"peer denies access — grant permission on the remote node","peer-cause-rotta":"route no longer exists on the peer — update the node","node-passive":"client offline · expected","node-offline":"node offline","node-offline-seen":"offline · seen {t} ago","node-needs-repair":"legacy · pair again","asks-title":"questions from the cells","ask-dismiss":"Dismiss question","ask-reply-ph":"type your answer…","push-enable":"enable push notifications","push-disable":"disable push notifications","push-on":"push active on this device","push-off":"push not active","push-denied":"notification permission denied by the browser","push-unsupported":"push not supported in this browser","notification-speech-enable":"read notifications aloud","notification-speech-help":"Uses the browser voice only for new notifications while this PWA is visible and in the foreground. When the app is closed, the system notification remains available.","notification-speech-test":"test voice","notification-speech-testing":"testing voice…","notification-speech-preview":"NexusCrew. Spoken notifications are active.","notification-speech-preview-ok":"Voice test completed.","notification-speech-preview-failed":"The browser did not start the voice test. Interact with the page and try again.","notification-speech-preview-voice-error":"The voice test failed: voice or audio unavailable. Check the selected voice and try again.","notification-speech-preview-timeout":"The voice test failed: no response from the speech engine. Check the selected voice and try again.","notification-speech-needs-test":"For this app session, select “test voice” before spoken alerts can play.","notification-speech-unsupported":"Speech synthesis is not supported in this browser.","audio-title":"Native node audio","audio-help":"Consent and controls apply only to this device. Share and visibility do not authorize sounds.","audio-consent":"allow TTS on this node","audio-consent-help":"Allows authorized local or remote cells to deliver a voice command. You can revoke it at any time.","audio-capability":"Local capability","audio-loading":"reading local audio state…","audio-adapter":"adapter","audio-adapter-none":"none","audio-installed":"installed","audio-installed-yes":"yes","audio-installed-no":"no","audio-liveness":"availability","audio-liveness-ready":"ready to accept","audio-liveness-unavailable":"unavailable","audio-languages":"declared languages","audio-limits":"limits","audio-test":"test local audio","audio-testing":"testing audio…","audio-stop":"stop local audio","audio-stopping":"stopping audio…","audio-test-needs-consent":"Enable local consent before testing the voice.","audio-unavailable":"No native TTS adapter is available on this node.","audio-test-accepted":"The node accepted the test. It does not prove that anyone heard it.","audio-test-refused":"The node refused the test.","audio-test-unknown":"Test outcome unknown: the node could not confirm startup.","audio-stop-stopped":"Local audio stopped.","audio-stop-idle":"No local utterance to stop.","audio-groups-title":"Shared audio groups","audio-groups-help":"Chooses which devices play the voice when a cell speaks. A group is a local delivery preference, not consent. Each node keeps its own consent, ACL, availability and local Stop.","audio-groups-empty":"No group: voice plays only on this node.","audio-group-name":"group name","audio-group-mode":"delivery mode","audio-group-primary":"first available (in order)","audio-group-fanout":"all listed nodes","audio-group-targets":"exact target nodes","audio-group-local":"this node","audio-group-unavailable-target":"not currently discovered","audio-group-no-targets":"No node with an available instanceId. A group cannot use names, wildcards, or “all”.","audio-group-new":"new group","audio-group-edit":"edit","audio-group-delete":"delete","audio-group-save":"save group","audio-group-cancel":"cancel","audio-group-invalid":"A group needs a valid name and at least one exact nodeId.","audio-group-save-failed":"Could not save audio group.","node-display-label":"Name (label)","routed-node-aliases":"Routed node aliases","routed-node-aliases-help":"Visible only on this device; the route and remote name do not change.","node-local-alias":"Alias on this device","alias-on-device":"Alias on this device","reset-alias":"Reset remote name","node-slug-hint":"routing on slug: {slug}","device-name-label":"Device name","device-name-hint":"how peers see you (editable)","local-route-name-label":"Local / route name","local-route-name-hint":"stable technical handle: readable label + nodeId suffix; editable before connecting","err-label":"invalid label (max 64 chars, no line breaks)","fleet-inventory":"Cells and sessions","fleet-inventory-help":"all positions (Local + Hydra routes)","fleet-manage-location":"Manage location","fleet-network-overview":"Network overview","fleet-manage-help":"create and configure cells at the selected location","fleet-overview-help":"operational state of every location, separate from the editor","fleet-inventory-empty":"no cells or sessions","cell-switcher-refreshing":"refreshing cells…","cell-switcher-empty-active":"no verified active cells","cell-switcher-not-confirmed":"status not confirmed","cell-switcher-not-active":"this cell is no longer active","cell-switcher-verify-failed":"Could not verify: try again shortly.","cell-switcher-select":"select a cell","cell-switcher-open":"open cell","cell-switcher-show-all":"all","cell-switcher-show-active":"active","cell-switcher-close":"close cell switcher","fleet-not-available":"fleet not available on this position",start:"start",stop:"stop",restart:"restart",delete:"delete","copy-manual":"copy failed — select and press Cmd+C, or copy manually","copy-empty":"nothing selected: drag with Shift to select","selection-held":"highlight gone, text still held","selection-changed":"text under the selection changed","invite-hub-only":"An invite is minted on the hub. Admitting a new node is the one thing a connected node cannot ask on another’s behalf: open NexusCrew on the hub and create the invite there.","row-private":"private","node-detail-open":"open details","node-detail-reach":"Reachability","node-detail-route":"path","node-detail-ssh":"SSH","node-detail-transport":"transport","node-detail-owner":"owner","node-detail-authority":"What this node can do","authority-owner-equivalent":"Authority equal to yours: a paired node can do on this machine everything you can do.","authority-routed":"Not paired with this machine: its authority lives on the hub that routes it.","authority-no-grants":"The only per-node power that exists is the choice of cells, below. Within those cells the authority stays full.","authority-no-grants-elsewhere":"The only per-node power that exists is the choice of cells, and it is set on the installation that owns them — not here.","node-detail-network-view":"What it sees of this network","node-detail-command":"Command","vl-no-commands":"The device declares no commands available.","vl-events-title":"Session","vl-events-empty":"No events in memory: the session has not spoken yet, or what it said has left the buffer. The history stays on the device.","vl-events-gap":"events not received:","vl-events-truncated":"content truncated by the device","vl-events-turn-end":"— end of turn —","vl-events-done":"— turn complete —","vl-events-writer-epoch":"— writer changed —","vl-events-tool":"tool","vl-events-tool-ok":"finished","vl-events-tool-failed":"failed","vl-events-usage":"usage updated","vl-events-stale":"Refresh failed: what you see may not be the latest.","vl-cmd-phase-submitted":"sent, awaiting confirmation","vl-cmd-phase-inflight":"in progress","vl-cmd-phase-done-ok":"completed","vl-cmd-phase-done-error":"failed","vl-cmd-status":"status","vl-cmd-health":"health","vl-cmd-start":"start","vl-cmd-stop":"stop","vl-cmd-restart":"restart","vl-cmd-version":"version","vl-cmd-capabilities":"capabilities","vl-cmd-logs":"logs","vl-cmd-prompt":"prompt","vl-prompt-placeholder":"write the prompt for the device session…","vl-prompt-send":"send prompt","vl-cmd-unpair":"unpair","node-grant-none":"No node chosen: shared, but towards nobody.","node-grant-unknown":"no longer in the inventory","node-grant-remove":"remove","node-grant-add":"Add a node","node-grant-search":"Search the nodes","node-grant-no-candidates":"No node matches.","cell-scope":"Cells this node can see","cell-scope-help":"Applies to what this node lists and to what it can act on, terminal included. Within the granted cells it remains a fully paired node: this is not a sandbox.","cell-scope-all":"every cell","cell-scope-none":"no cell","cell-scope-selected":"selected cells","cell-scope-none-granted":"No cell chosen: this node sees none of them.","cell-scope-unknown":"cell no longer exists","cell-scope-add":"Add a cell","cell-scope-search":"Search the cells","cell-scope-no-candidates":"No cell matches.","cell-scope-reset-warning":"Switching mode clears the list: coming back to “selected cells” means choosing them again.","cell-scope-list-unavailable":"Cell list unavailable right now: the grants below still hold, but we cannot tell whether they still exist.","single-view":"single view",retract:"retract","keybar-expand":"expand the key bar","keybar-retract":"retract the key bar","save-and-start":"save and start",permissions:"Permissions","power-on-hint":"Stop the cell; you can also remove it from boot.","launch-engine-help":"Providers, credentials and new engines are created in Settings → Fleet. Model and permissions are per cell.","launch-unavailable-hint":"Engine configuration is unavailable on this node.","import-as-cell":"Import as cell","import-help":"Reconcile an existing tmux session into a managed cell. Pick an already-declared engine: no engine is invented.","import-engine-required":"pick an engine (required)","test-and-connect":"test and connect","pairing-v2-hint":"Paste or scan ONE link: it prefills name, SSH host and label when the link carries them (v2).","invite-v2-hint":"Create one one-time invitation. It needs this device’s SSH address, reachable by whoever will use it.","invite-target-local":"The new device will join","invite-target-this":"this device","invite-endpoint-label":"This hub’s SSH address as seen by other devices","invite-endpoint-auto":"Configured endpoint","invite-endpoint-needed":"Enter user@host or a shared SSH alias. This is not 127.0.0.1 and not the NexusCrew HTTP URL.","invite-ssh-hint":"The SSH target the OTHER device uses to reach THIS installation (user@host or alias). Required: it is included in the link.","invite-next-steps":"copy this link, open NexusCrew on the other device and paste it in Settings → Nodes (or scan the QR): NexusCrew does the rest","pair-card-title":"connect with one link","pair-card-help":"Paste the pairing link generated on the other device (or scan its QR): NexusCrew decodes it, tests the SSH connection and connects on its own.","pair-paste-ph":"paste the pairing link here","pair-paste-btn":"paste","pair-advanced":"advanced / edit","pair-progress":"connecting: SSH → invite → confirm → verify…","pair-retry":"retry","pair-invalid-link":"this is not a valid pairing link","pair-invalid-hint":"you need the full link (http://…#pair=…) generated by the other NexusCrew: don’t open it, paste it here","pair-missing-ssh":"the link carries no SSH target (v1 format): set in “advanced” how this device reaches the other one over SSH — it is never invented","pair-missing-name":"the node name is missing: fill it in “advanced”","pair-clipboard-denied":"clipboard read not allowed: paste manually into the field","pair-clipboard-empty":"clipboard is empty: copy the pairing link first","pair-stage-validation":"invalid data","pair-stage-conflict":"name already in use","pair-stage-ssh-start":"SSH tunnel start failed","pair-stage-ssh-ready":"peer unreachable over SSH","pair-stage-join":"invite exchange failed","pair-stage-tunnel-final":"negotiated tunnel failed","pair-stage-confirm":"pairing confirmation failed","pair-stage-health":"final federation check failed","pair-stage-internal":"internal error","pair-stage-generic":"connection failed","qr-no-camera":"no camera available on this device: use a photo of the QR","qr-permission":"camera permission denied: allow it in the browser or use a photo of the QR","qr-unsupported":"live scanner not supported here: upload a photo of the QR","qr-upload":"use a photo"},es:{"update-available":"nueva versión {v} disponible","update-stale":"interfaz desalineada: ejecutas la v{browser}, el nodo sirve la v{ui}. recarga sin caché; si persiste, reinicia el nodo","reload-no-cache":"recargar sin caché","update-installed-restart":"versión {v} instalada: reinicia el nodo","update-dismiss":"cerrar","install-version-mismatch":"instalación incompleta: frontend y servidor no coinciden (v{v})",reload:"recargar","grid-empty":"arrastra aquí una sesión desde la barra lateral, o doble clic para vista única","grid-full":"un deck puede mostrar como máximo 9 sesiones",pin:"fijar arriba",reorder:"reordenar","host-lease-live":"host live: supervisión activa","host-lease-grace":"host live: supervisión en recuperación (grace)","host-lease-expired":"host live: supervisión caducada","host-lease-none":"host live: nunca supervisada","host-lease-unavailable":"host live: garantía de supervisión no disponible en este nodo","reorder-help":"arrastra el control; flechas arriba/abajo","rename-node":"renombrar nodo","rename-node-prompt":"Nuevo nombre del nodo en NexusCrew","rename-node-invalid":"Nombre no válido: máximo 64 caracteres, sin saltos de línea.","reorder-deck-help":"arrastra el deck; flechas izquierda/derecha",sessions:"sesiones","new-session":"nueva sesión",new:"nueva",fleet:"Flota","fleet-tmux":"flota tmux","other-sessions":"Otras sesiones","view-all":"todas","view-pinned":"fijadas","view-active":"activas","view-off":"apagadas","view-technical":"técnicas","mark-technical":"ocultar como sesión técnica","mark-normal":"mostrar como sesión normal","position-local":"Local",files:"archivos",refresh:"actualizar","filter-placeholder":"filtrar sesiones…","loading-fleet":"cargando flota…","no-sessions":"sin sesiones tmux vivas — la flota arranca en el boot (systemd)","no-match":"ninguna sesión coincide con «{q}»","copy-url":"clic para copiar la URL","ssh-only":"solo túnel SSH/VPN","new-files-outbox":"archivos nuevos en outbox",terminate:"terminar","terminate-confirm":"¿Terminar la sesión «{name}»?","cell-on":"tmux activo","cell-off":"apagada","cell-working":"trabajando","cell-idle":"en espera","cell-degraded":"degradada: unit activa, tmux muerto","power-on":"encender","power-off":"apagar","boot-enable":"activar al iniciar","boot-disable":"desactivar al iniciar","state-on":"encendida","state-off":"apagada",engine:"Motor",model:"Modelo","model-default":"Modelo predeterminado del proveedor","model-remembered":"Último modelo usado con este motor","boot-persist":"iniciar en el boot","remove-boot":"quitar también del boot","power-config-in-settings":"Modifica motor, proveedor, perfil, modelo y permisos en Ajustes → Flota.","no-remote-control":"⚠ motor no nativo: sin RC de la app claude.ai (aquí puedes pilotarla igual)",cancel:"cancelar",name:"nombre","name-invalid":"nombre inválido: a-zA-Z0-9._- máx 64, sin '-' inicial",cwd:"carpeta",browse:"explorar","fs-home":"home","fs-parent":".. arriba",preset:"preset","preset-2x2":"cuadrícula 2×2","preset-columns":"columnas","preset-equalize":"igualar",collapse:"contraer",expand:"expandir",create:"crear","auth-prompt":"Pega el token (impreso por el servidor):","remember-device":"recordar en este dispositivo","zoom-out":"texto más pequeño","zoom-in":"texto más grande","terminal-renderer-webgl":"WebGL","terminal-renderer-dom":"DOM","terminal-renderer-switch":"motor gráfico: solicitado {requested}, en uso {effective} — toca para cambiar (recarga el terminal)",composer:"composer",panel:"panel","panel-none":"Ningún panel configurado para esta celda.","panel-checking":"Abriendo el panel…","panel-not-granted":"Este nodo no concede el panel a quien lo pide: el acceso se concede en el nodo que posee la celda, no reintentando aquí.","panel-denied":"Entrada al panel rechazada: el billete ya no es válido. Reintenta: se pedirá un billete nuevo.","cell-peek":"Echa un vistazo sin cambiar de celda","cell-tele-ctx":"contexto","cell-tele-free":"libre","cell-tele-5h":"5h usados","cell-tele-7d":"7d usados","cell-activity":"actividad","cell-activity-now":"ahora","cell-peek-preview":"Vista previa","cell-peek-stream":"Flujo","cell-peek-panel":"Panel","cell-peek-vuoto":"No hay vista previa para esta celda.","panel-node-refused":"El nodo que posee la celda rechaza la petición: está en solo lectura, o su política bloquea esta operación. Reintentar aquí no cambia el resultado.","panel-unauthorized":"Credencial no válida para este nodo: se corrige donde está configurada, no reintentando desde aquí.","panel-unreachable":"El panel no es accesible a través de este nodo: reintenta en un momento.","panel-frame-loading":"panel montado: carga en curso","panel-frame-error":"El frame del panel no se ha cargado: el billete puede haber caducado (30 s de vida, monouso) o el destino es inaccesible. Reintenta: se pedirá un billete nuevo.","popup-drag-hint":"arrastra para mover; doble clic para volver al centro","popup-resize-hint":"arrastra para redimensionar","panel-timeout":"El panel no respondió a tiempo: servicio lento en arrancar o sobrecargado. Reintenta en un momento.","panel-retry":"Reintentar","live-host-not-granted":"Este nodo no concede la designación de celda anfitriona Live a quien la pide: se concede en el nodo que posee la celda (nodes live-host <nodo> on), no reintentando aquí.","live-host-error":"La designación de celda anfitriona Live no funcionó: reintenta en un momento.","host-thread-designated":"celda designada; thread ausente","host-thread-present":"thread presente pero inactivo","host-thread-active":"thread activo","host-thread-unknown":"estado del thread desconocido",windows:"{n} ventanas","empty-files":"vacía",upload:"subir","no-sessions-short":"sin sesiones","composer-placeholder":"escribe o dicta…","composer-history-tools":"historial y tamaño de entrada","composer-history":"historial de la celda","composer-history-empty":"ninguna entrada enviada","composer-history-clear":"borrar historial de esta celda","composer-expand":"ampliar entrada","composer-collapse":"reducir entrada","composer-clear-data":"borrar borradores e historial","composer-clear-data-help":"Elimina de este navegador todos los borradores y el historial de entrada de las celdas.","composer-clear-confirm":"¿Borrar todos los borradores y el historial de entrada guardados en este navegador?","composer-clear-done":"Borradores e historial eliminados.","composer-clear-failed":"No se pudieron borrar los datos del composer en este navegador.",attach:"adjuntar","attach-file":"Archivo","attach-camera":"Cámara","attach-gallery":"Galería","attach-inbox":"Inbox","attach-inbox-done":"{n} archivos añadidos a la bandeja","attach-uploading":"subiendo…","attach-upload-progress":"adjunto {n}/{total}…","attach-uploaded":"{n} adjuntos subidos",voice:"voz",send:"enviar","composer-send-failed":"conexión no disponible — texto conservado, inténtalo de nuevo",close:"cerrar","lang-label":"idioma",decks:"decks","new-deck":"nuevo deck","deck-name":"nombre del deck","open-deck-window":"abrir en una ventana nueva","detach-deck":"separar en una ventana nueva","deck-current":"este deck (ventana actual)","deck-owner-unavailable":"el nodo propietario no está compartido o accesible","rename-deck":"renombrar deck","delete-deck":"eliminar deck","delete-deck-confirm":"¿Eliminar el deck «{name}»?","send-to-deck":"enviar al deck…","deck-autosave":"guardado automático",saving:"guardando…",saved:"guardado","popup-blocked":"ventana bloqueada: abrir aquí","expand-owner":"expandir decks de {owner}","collapse-owner":"comprimir decks de {owner}","owner-deck-count-one":"{count} deck","owner-deck-count-many":"{count} decks","dot-working":"en uso (ventana activa)","dot-on":"abierta en segundo plano","dot-neutral":"no abierta","dot-warn":"nodo sin conexión","select-drag":"arrastra para seleccionar","copy-manual":"selecciona y copia manualmente","toggle-sidebar":"mostrar/ocultar la barra lateral",settings:"ajustes","tab-roles":"roles","tab-nodes":"nodos",local:"Local",location:"Ubicación","pairing-link":"enlace de emparejamiento","pairing-required":"nombre, alias SSH y enlace son obligatorios","pairing-connect-help":"Para conectar un nodo necesitas un nombre, un Host SSH funcional y el enlace/QR creado por la otra instalación NexusCrew.","pairing-localhost-hint":"127.0.0.1 en el enlace es correcto: no lo abras aquí. NexusCrew usa la invitación y el puerto mediante el Host SSH.","scan-qr":"escanear QR","pairing-qr-invalid":"QR de emparejamiento no válido","invite-node":"invitar un nodo","create-pairing-link":"crear enlace / QR","visibility-network":"toda la red","visibility-relay":"solo relay","visibility-selected":"nodos seleccionados","hydra-simple":"local + nodos, una red","local-ready":"Este dispositivo está listo. Úsalo solo o conéctalo a un nodo.","local-only":"solo local","add-node":"añadir nodo",connect:"conectar","node-connected":"Nodo conectado. La red se sincronizará automáticamente.","pair-authkeys-title":"Línea que hay que sustituir en ~/.ssh/authorized_keys del peer","pair-authkeys-hint":"Sin esta línea el reenvío del panel sigue rechazado: el túnel parece activo y el panel no responde.","pair-authkeys-copy":"Copiar la línea","pair-authkeys-copied":"Línea copiada","tab-system":"sistema","tab-fleet":"flota","tab-audio":"audio","system-general":"general","system-diagnostics":"diagnóstico","system-this-node":"este nodo","system-updates":"actualizaciones","system-security":"seguridad","system-local-data":"datos locales del navegador","system-terminal":"terminal","alternate-screen":"pantalla alternativa","alternate-screen-help":"Mantiene el comportamiento estándar de tmux para las nuevas sesiones NexusCrew. Una aplicación que sigue el ratón se desplaza sola; las demás recorren el historial de tmux. No modifica las celdas ya activas.","tab-input":"entrada","tab-diagnostics":"diagnóstico","input-settings-local":"Preferencias locales de este navegador. Se aplican de inmediato a la vista única y a los decks sin cambiar el nodo remoto.","terminal-keyboard-gesture":"Abrir el teclado virtual desde el terminal","terminal-keyboard-double-tap":"Doble toque (predeterminado)","terminal-keyboard-single-tap":"Toque único","terminal-keyboard-never":"Nunca desde el terminal","terminal-keyboard-gesture-help":"El teclado auxiliar y STT usan los controles separados de abajo. El ratón y el teclado físico siguen disponibles.","keybar-ime-lock":"Teclado auxiliar: mantener cerrado el teclado virtual","keybar-ime-lock-help":"ESC, flechas, PgUp/PgDn, Enter y menú envían directamente al PTY sin enfocar un campo de texto.","voice-ime-lock":"Micrófono STT: mantener cerrado el teclado virtual","voice-ime-lock-help":"Tocar el micrófono inicia o detiene la voz sin enfocar el compositor.","keybar-enter-show":"Mostrar Enter vertical en el teclado auxiliar","keybar-enter-show-help":"Enter queda a la derecha de PgUp/PgDn y ocupa las dos filas.","keybar-layout":"Distribución del teclado auxiliar","keybar-layout-full":"Completo (predeterminado)","keybar-layout-compact":"Compacto","keybar-layout-help":"Compacto: una fila con un botón expandir que alcanza el conjunto completo sin cambiar la preferencia.","input-settings-reset":"restaurar valores de entrada","diagnostics-local":"Este nodo","diagnostics-target":"Nodo a diagnosticar","diagnostics-verbose":"Logs detallados temporales","diagnostics-duration":"Duración detallada","diagnostics-expires":"Log detallado activo hasta las {time}","diagnostics-off":"El log detallado está apagado; los avisos y errores operativos siguen disponibles.","diagnostics-level":"Nivel","diagnostics-all-levels":"todos los niveles","diagnostics-component":"componente","diagnostics-pause":"pausa","diagnostics-autoscroll":"desplazamiento automático","diagnostics-log":"Log de diagnóstico sanitizado","diagnostics-empty":"No hay eventos de diagnóstico.","diagnostics-export":"exportar JSON","diagnostics-export-failed":"La exportación no está disponible en este navegador.","diagnostics-clear":"vaciar","diagnostics-clear-confirm":"¿Vaciar el búfer de diagnóstico de este nodo?","diagnostics-unsupported":"Este par está desconectado o no admite diagnósticos estructurados.","fleet-editor-loading":"Cargando el editor de Fleet…","fleet-editor-load-error":"No se puede cargar el editor de Fleet.","fleet-editor-unavailable":"El editor de Fleet no está disponible en esta ubicación.","fleet-stale":"Fallo de lectura de la flota: la lista de celdas puede no estar actualizada.","fleet-off":"Flota no disponible: sin celdas.","fleet-managed":"gestionado por NexusCrew","fleet-custom":"comando personalizado","fleet-managed-help":"Cliente, proveedor e inicio se gestionan internamente; los secretos nunca se muestran.","fleet-shell-engine-help":"La shell local se resuelve en el dispositivo al iniciar; no se guarda ninguna ruta ejecutable en las copias.","fleet-shell-command-placeholder":"comando opcional, p. ej. npm test","fleet-shell-command-help":"Se ejecuta mediante una shell de inicio interactiva (-lic), con PATH y alias del usuario. La celda se detiene al terminar; los fallos inmediatos se notifican.","fleet-shell-command-metachar":"Pipes, redirecciones, variables y otros metacaracteres son interpretados por la shell del dispositivo.","fleet-shell-interactive":"Vacío: abre una shell local interactiva y mantiene la celda activa.","fleet-shell-launch-help":"Configura el comando Shell de la celda en Ajustes → Flota.","fleet-credential-title":"Clave API en este dispositivo","fleet-credential-help":"La clave permanece solo en el nodo seleccionado y nunca se muestra ni se exporta. Si el nodo es remoto, el valor viaja hasta él por el canal emparejado.","fleet-credential-set":"poner clave","fleet-credential-change":"cambiar clave","fleet-credential-forget":"olvidar","fleet-credential-saved":"Clave guardada localmente.","fleet-credential-removed":"Clave local eliminada.","fleet-credential-remove-confirm":"¿Eliminar la clave local {key}?","fleet-credential-source-environment":"entorno","fleet-credential-source-local":"almacén local","fleet-credential-source-compatibility":"config compatible","fleet-credential-source-missing":"ausente","fleet-credential-source-nexuscrew-store":"almacén NexusCrew","fleet-credential-source-unreadable":"no verificable","fleet-credential-source-login":"login del cliente","fleet-credential-source-none":"ninguna","fleet-credential-source-policy":"origen de credencial","fleet-credential-source-policy-auto":"auto (precedencia legacy)","fleet-credential-source-policy-nexuscrew-store":"solo almacén NexusCrew","fleet-credential-source-policy-environment":"solo entorno","fleet-key-section":"KEY","fleet-key-variable":"Variable","fleet-key-value":"Valor para {key}","fleet-key-used-by":"Usada por: {engines}","fleet-key-used-by-none":"Aún no la usa ningún motor configurado en este nodo.","fleet-key-shared-impact":"Sustituir o eliminar {key} afecta a todos los motores listados: {engines}.","fleet-key-enter":"introduce la clave","fleet-key-blank-keeps":"vacío = mantener la fuente actual","fleet-key-reveal":"mostrar","fleet-key-hide":"ocultar","fleet-key-local-help":"El valor permanece write-only en el nodo seleccionado: nunca se vuelve a leer desde la red ni entra en motores o copias. Si el nodo seleccionado es remoto, el valor llega a él por el canal emparejado.","fleet-key-create-missing":"Crear explícitamente el motor sin clave (seguirá como “clave requerida”).","fleet-key-partial-create":"Motor creado; la clave no se guardó. Puedes reintentar sin crear un duplicado.","fleet-key-partial-edit":"Motor actualizado; la clave no se guardó. Los cambios del motor siguen aplicados.","fleet-provider-notice-claude-openrouter":"Claude Code está optimizado para modelos Anthropic; otros proveedores podrían no funcionar correctamente. Fast mode requiere el proveedor Anthropic first-party.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses es beta y stateless; Codex-VL no usa fallback de Chat Completions.","fleet-provider-notice-claude-kimi-code":"Kimi Code usa una configuración Claude aislada con onboarding y fast mode dedicados; la configuración Claude nativa no se modifica, pero sus herramientas MCP se heredan.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal usa solo ALIBABA_CODE_API_KEY de la capa local de credenciales; qwen3.8-max es el modelo predeterminado y no se usa fallback OpenAI/PAYG.","fleet-provider-notice-kimi-native":'Kimi Code CLI nativo usa el login del CLI (device-code) y su propia configuración: NexusCrew no lee ni copia credenciales. Distinto del proveedor "Kimi Code" de Claude Code, que sigue siendo la ruta K3 gestionada.',"fleet-model-default":"modelo predeterminado (opcional)","fleet-model-required":"modelo (obligatorio)","fleet-standard-permissions":"permisos estándar","fleet-unsafe-permissions":"inseguro · omitir aprobaciones/sandbox","fleet-unsafe-warning":"Modo inseguro explícito: el worker puede actuar sin las aprobaciones normales ni las protecciones del sandbox.","fleet-provider-display":"nombre visible del proveedor","fleet-custom-provider-default":"Proveedor personalizado","fleet-api-key-env":"NOMBRE_VARIABLE_API_KEY","fleet-provider-id":"id-proveedor","fleet-custom-secret-help":"NexusCrew guarda solo el nombre de la variable de entorno, nunca su valor.","cell-prompt":"Prompt de arranque de la celda","cell-prompt-help":"Se envía a la celda al arrancar: es su encargo permanente. Vacío = sin prompt, la celda solo arranca.","fleet-boot":"inicio automático","fleet-remote-control":"control remoto","cell-mcp":"Herramientas MCP","cell-mcp-all":"todas","cell-mcp-none":"ninguna","cell-mcp-some":"elegidas","cell-mcp-inert":"Para este cliente, las herramientas MCP las registra el cliente en su propia config, no NexusCrew: la selección aquí no tiene efecto.","cell-mcp-help":"«Todas» es el comportamiento de siempre. «Ninguna» es la única exclusión CIERTA: quita toda herramienta y no depende de dónde estén definidos los servidores — es lo que hace falta para una celda en la que no se confía. Con «elegidas» se concede por nombre, pero la lista solo cubre los servidores que este nodo puede enumerar: los plugins y conectores no aparecen y seguirían disponibles.","fleet-model-override":"modelo alternativo","fleet-ready":"listo","fleet-not-ready":"no configurado","fleet-engines":"Motores","fleet-cells":"Celdas / sesiones cloud","fleet-models":"Modelos declarados","fleet-no-models":"Ningún modelo declarado: se usa el catálogo interno.","model-editor-engine":"Perfil","model-editor-id":"Id del modelo","model-editor-id-help":"El id exacto que espera el proveedor. Perfil e id no se cambian después: se retira y se vuelve a declarar.","model-editor-context":"Ventana de contexto (tokens)","model-editor-max-tokens":"Máximo de tokens de salida","model-editor-reasoning":"Admite razonamiento extendido","model-test":"Probar contra la API","model-test-running":"Probando…","model-test-ok":"responde","model-test-unknown-model":"el proveedor no conoce este id","model-test-auth":"credencial ausente o rechazada","model-test-unreachable":"endpoint inalcanzable","model-test-unverified":"no verificado","model-test-unverified-help":"No significa que falle: este proveedor no expone la lista de modelos, así que la prueba no pudo decir ni sí ni no.","model-remove":"Retirar","model-in-use":"en uso","fleet-backup":"copia / restauración","fleet-backup-help":"Exporta o restaura selectivamente motores, celdas, modelos declarados y system prompts. Tokens, claves API y secretos del proveedor nunca entran en el archivo.","fleet-backup-export":"exportar","fleet-backup-import":"importar","fleet-backup-download":"descargar copia","fleet-backup-restore":"restaurar seleccionadas","fleet-backup-import-help":"Elige una copia JSON, revisa las celdas y selecciona un motor de destino antes de restaurar.","fleet-backup-overwrite":"sobrescribe la celda existente","fleet-backup-new":"celda nueva","fleet-backup-engine-missing":"elige un motor disponible","fleet-backup-restore-unavailable":"El nodo seleccionado solo admite exportación; actualízalo para restaurar copias.","fleet-backup-restored":"{n} celdas restauradas","fleet-backup-confirm-overwrite":"¿Sobrescribir estas celdas? {cells}","fleet-backup-needs-restart":"reinicio necesario: {cells}","fleet-backup-empty":"no hay celdas para exportar","fleet-backup-select-one":"selecciona al menos una celda","fleet-backup-too-large":"copia demasiado grande (máximo 1 MB)","fleet-backup-invalid-json":"el archivo no contiene JSON válido","fleet-backup-invalid-format":"formato o versión de copia no compatible","fleet-backup-invalid-cell":"la copia contiene una celda no válida","fleet-backup-duplicate-cell":"la copia contiene IDs de celda duplicados","fleet-backup-invalid-engine":"la copia contiene un motor no válido","fleet-backup-duplicate-engine":"la copia contiene IDs de motor duplicados","fleet-backup-invalid-model":"la copia contiene un modelo no válido","fleet-backup-duplicate-model":"la copia contiene modelos duplicados","fleet-backup-confirm-engine-overwrite":"¿Sobrescribir estos motores? Los valores de entorno ya configurados en el destino no cambian. {engines}","fleet-backup-env-names":"nombres de entorno","fleet-backup-env-values-required":"los valores de entorno deben configurarse en este dispositivo","fleet-system-prompt":"system prompt",characters:"caracteres","select-all":"seleccionar todas","select-none":"ninguna",edit:"editar",save:"guardar",label:"etiqueta","command-path":"ruta absoluta del comando","args-lines":"argumentos, uno por línea","env-write-only":"Los valores env son de solo escritura: vacío conserva el valor existente.","fleet-new-engine":"Nuevo motor","fleet-new-cell":"Nueva celda","fleet-saved":"Definición guardada.","fleet-restart-confirm":"Cambio guardado. ¿Reiniciar ahora: {cells}?","fleet-remove-engine":'¿Eliminar el motor "{id}"?',"fleet-remove-cell":'¿Eliminar la celda "{id}"? Si está activa se detendrá primero.',"fleet-cwd-needs-repair":"carpeta a reparar","fleet-cwd-repair":"reparar","fleet-cwd-repair-title":"Reparar carpeta de celda {id}","fleet-cwd-repair-help":"La carpeta actual no es portátil en este dispositivo: pertenece a otro dispositivo o no existe bajo el directorio home. Elige una carpeta relativa a home (~) en el dispositivo destino; el backend recalculará la ruta absoluta.","fleet-cwd-repair-no-source-path":"La ruta original no se muestra: es específica del dispositivo de origen.","fleet-cwd-repair-placeholder":"p. ej. Dev","fleet-cwd-repair-preview":"Nueva carpeta: {path}","fleet-cwd-repair-browse":"examinar bajo ~","fleet-cwd-repair-fs-empty":"sin subcarpetas","fleet-cwd-repair-use-current":"usar esta carpeta","fleet-cwd-repair-invalid":'ruta no válida: nada de ruta absoluta, "..", barra invertida ni letra de unidad',"fleet-cwd-repair-confirm":"¿Establecer la carpeta de la celda {id} a {path}? Se recalculará en el dispositivo destino.","fleet-cwd-repair-unportable":"La ruta elegida no es portátil en este dispositivo: debe existir bajo el directorio home.","fleet-cwd-repair-suggestion":"Sugerencia del dispositivo:","fleet-cwd-repair-use-suggestion":"usar {path}","fleet-cwd-repaired":"Carpeta de la celda reparada.","fleet-recovery-kimi-code-consent-yes":"Kimi Code: confirma la clave API personalizada (Yes) en el terminal de la celda, luego reinicia la celda.","fleet-recovery-kimi-code-config-custom-api-key":'Kimi Code: en el terminal de la celda abre /config y activa "Use custom API key", luego reinicia la celda. Si la clave cambió, actualiza la credencial y reintenta.',"fleet-recovery-kimi-cli-login":"Kimi Code CLI: en el terminal de la celda ejecuta /login (código de dispositivo Kimi) o /provider, luego reinicia la celda.","fleet-readiness-degraded":"Iniciada sin confirmación de preparación: puede que no procese de inmediato. Revisa su terminal antes de asignarle trabajo.","fleet-vl-prompt-degraded":"Iniciada sin el prompt de celda: la versión de vl en este nodo no lo admite (se requiere 0.3.1+). La celda trabaja sin su identidad: actualiza vl antes de asignarle trabajo.","fleet-recovery-client-terminal-dialog":"Completa el diálogo mostrado en el terminal de la celda, luego reinicia la celda.","settings-readonly":"READONLY activo: los cambios están bloqueados por el servidor (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"esta máquina observa otros nodos vía túneles SSH","role-node":"nodo (alcanzable)","published-port":"puerto publicado (opcional)","no-nodes":"sin nodos remotos configurados","node-add":"conectar una instalación NexusCrew","node-connect-help":"El puerto SSH conecta con el servidor SSH. El puerto NexusCrew es el puerto local indicado por `nexuscrew status` en el nodo remoto.","node-name-label":"Nombre del nodo","node-ssh-label":"Host SSH","pair-ssh-local-label":"Host o alias SSH en este dispositivo","node-ssh-local-help":"Puedes sustituir la dirección del enlace por el mismo alias que funciona con ssh en este dispositivo. Los alias, agentes y claves permanecen locales y nunca viajan en el enlace.","node-ssh-port-label":"Puerto SSH","node-ssh-port-help":"Normalmente 22; usa el puerto público del servidor SSH.","node-app-port-label":"Puerto NexusCrew del nodo","node-app-port-help":"El puerto indicado por `nexuscrew status` en el nodo remoto.","node-name-ph":"nombre (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"puerto remoto (opc.)","node-remove-confirm":"¿Eliminar el nodo «{name}»?","node-remove-warning":"Elimina el emparejamiento, las credenciales y el túnel local. No apaga el dispositivo remoto.","peer-inventory-title":"Nodos conectados al hub","peer-group-hubs":"Hubs directos","peer-group-clients":"Clientes conectados","peer-group-routed":"Nodos accesibles a través de la red","peer-group-vl":"Nodos VL","vl-owners-unavailable":"Owners VL no alcanzados","peer-routed":"enrutado","peer-routed-stale":"enrutado, no accesible","peer-visibility":"Visibilidad en la red","node-test":"test","tunnel-start":"iniciar túnel","tunnel-stop":"detener túnel","tunnel-restart":"reiniciar túnel","share-node":"Compartir este nodo","share-local-heading":"Compartir este dispositivo","share-local-hub":"Hub para compartir","share-local-through":"Compartir {device} mediante {hub}","share-local-active":"Compartido y accesible para la red conectada al hub.","share-local-pending":"Se solicitó compartir, pero el túnel está caído: este dispositivo aún no es accesible.","share-local-private":"Privado: solo este dispositivo puede usar la conexión al hub.","share-local-private-down":"Privado, pero la conexión al hub está caída. Reconecta para aplicar y verificar el modo privado.","share-local-reconnect":"Reconectar y reconciliar","share-off-hub-reconcile-pending":"Estado privado guardado; la revocación en el hub sigue pendiente.","fleet-cell-label":"nombre legible (opcional)","fleet-panel-url":"URL del panel (opcional)","fleet-panel-url-help":"Endpoint del panel gráfico de la celda (p. ej. el noVNC de un contenedor): solo http/https hacia un host loopback — el proxy resuelve el destino en la máquina que aloja la celda.","fleet-panel-url-invalid":"El panel no es un port-forward: quien lo abre elige qué celda, nunca dónde conectarse. La dirección se resuelve en la máquina que aloja la celda, así que debe ser alcanzable allí en loopback — 127.0.0.1, localhost o [::1]. La dirección de un contenedor (p. ej. 172.17.0.2) no lo es.","share-off-local-reconcile-pending":"Revocación confirmada por el hub; el túnel local aún debe reconciliarse.","share-reverse-pool-pending":"El canal inverso no se apagó de forma demostrable: queda en cuarentena, no cerrado.","share-node-off-desc":"Privado: sigue conectado al hub, pero otros clientes no pueden alcanzarlo.","share-node-on-desc":"Compartido: el hub puede anunciarlo y enrutar celdas y decks autorizados.","peer-shared":"Nodo cliente compartido en la red Hydra","peer-private":"Nodo cliente privado: conectado, no publicado en Hydra","peer-vl-federated":"Nodo VL: federado","row-vl-federated":"federado","node-connected-client":"cliente conectado","transport-used":"en uso","tunnel-up":"túnel activo","tunnel-down":"túnel caído","vl-poll-online":"en línea (poll)","vl-poll-offline":"sin respuesta","authorized-keys-hint":"pega esta línea en ~/.ssh/authorized_keys del host remoto:",copy:"copiar",copied:"copiado","token-rotate":"rotar token","token-rotate-explain":"El nuevo token NO se mostrará: recupéralo con `nexuscrew show token`. La sesión actual quedará invalidada.","service-regenerate":"regenerar service","npm-auto-update":"actualizaciones automáticas desde npm","npm-auto-update-help":"Comprueba latest periódicamente e instala solo versiones más recientes. Nunca baja de versión.","npm-update-current":"instalada","npm-update-latest":"npm latest","npm-update-check":"comprobar ahora","npm-update-install":"actualizar ahora","npm-update-restarting":"Actualización iniciada; NexusCrew volverá después de reiniciar el servicio.","npm-update-idle":"actualizado","npm-update-never":"nunca comprobado","npm-update-checking":"comprobando","npm-update-available":"actualización disponible","npm-update-installing":"instalando","npm-update-installed":"instalada, reiniciando","npm-update-error":"comprobación fallida","npm-update-unsupported":"disponible solo con instalación npm global","service-installed":"service instalado","service-missing":"service no instalado","service-active":"activo","service-inactive":"no activo",confirm:"confirmar",add:"añadir",enable:"activar","wizard-title":"bienvenido a NexusCrew","wizard-skip":"configura después desde ajustes","wizard-step-roles":"roles de esta instalación","wizard-step-node":"primer nodo remoto (opcional)","wizard-done":"todo listo","wizard-done-desc":"configuración completa — puedes cambiarlo todo desde ajustes",next:"continuar",back:"atrás",skip:"omitir",finish:"terminar","err-node-name":"nombre inválido (a-z, 0-9, -, máx 32)","err-local-name":"nombre local inválido: usa un slug único, no “localhost”","err-ssh":"ssh inválido (se espera user@host o alias)","err-port":"puerto inválido (1–65535)","err-ssh-port":"puerto SSH inválido (1–65535)","err-node-port":"puerto NexusCrew inválido (1–65535)","node-sessions":"{n} sesiones","tunnel-down-since":"túnel caído desde hace {t}","node-unreachable":"nodo inalcanzable","peer-cause-assente":"el peer no responde — esperando a que vuelva (consultas espaciadas)","peer-cause-nega":"el peer deniega el acceso — concede el permiso en el nodo remoto","peer-cause-rotta":"la ruta ya no existe en el peer — actualiza el nodo","node-passive":"cliente desconectado · estado normal","node-offline":"nodo desconectado","node-offline-seen":"sin conexión · visto hace {t}","node-needs-repair":"legacy · vuelve a enlazar","asks-title":"preguntas de las celdas","ask-dismiss":"Descartar la pregunta","ask-reply-ph":"escribe la respuesta…","push-enable":"activar notificaciones push","push-disable":"desactivar notificaciones push","push-on":"push activas en este dispositivo","push-off":"push no activas","push-denied":"permiso de notificaciones denegado por el navegador","push-unsupported":"push no soportadas en este navegador","notification-speech-enable":"leer las notificaciones en voz alta","notification-speech-help":"Usa la voz del navegador solo para notificaciones nuevas mientras esta PWA está visible y en primer plano. Con la aplicación cerrada permanece la notificación del sistema.","notification-speech-test":"probar voz","notification-speech-testing":"probando voz…","notification-speech-preview":"NexusCrew. Las notificaciones por voz están activas.","notification-speech-preview-ok":"Prueba de voz completada.","notification-speech-preview-failed":"El navegador no inició la prueba de voz. Interactúa con la página y vuelve a intentarlo.","notification-speech-preview-voice-error":"La prueba de voz falló: voz o audio no disponibles. Comprueba la voz seleccionada e inténtalo de nuevo.","notification-speech-preview-timeout":"La prueba de voz falló: sin respuesta del motor de voz. Comprueba la voz seleccionada e inténtalo de nuevo.","notification-speech-needs-test":"Para esta sesión de la aplicación, pulsa “probar voz” antes de recibir avisos hablados.","notification-speech-unsupported":"La síntesis de voz no está disponible en este navegador.","audio-title":"Audio nativo del nodo","audio-help":"El consentimiento y los controles valen solo para este dispositivo. Compartir y visibilidad no autorizan sonidos.","audio-consent":"permitir TTS en este nodo","audio-consent-help":"Permite que celdas autorizadas, locales o remotas, entreguen un comando de voz. Puedes revocarlo en cualquier momento.","audio-capability":"Capacidad local","audio-loading":"leyendo el estado de audio local…","audio-adapter":"adaptador","audio-adapter-none":"ninguno","audio-installed":"instalado","audio-installed-yes":"sí","audio-installed-no":"no","audio-liveness":"disponibilidad","audio-liveness-ready":"listo para aceptar","audio-liveness-unavailable":"no disponible","audio-languages":"idiomas declarados","audio-limits":"límites","audio-test":"probar audio local","audio-testing":"probando audio…","audio-stop":"detener audio local","audio-stopping":"deteniendo audio…","audio-test-needs-consent":"Activa el consentimiento local antes de probar la voz.","audio-unavailable":"No hay un adaptador TTS nativo disponible en este nodo.","audio-test-accepted":"El nodo aceptó la prueba. No demuestra que alguien la haya oído.","audio-test-refused":"El nodo rechazó la prueba.","audio-test-unknown":"Resultado de prueba desconocido: el nodo no pudo confirmar el inicio.","audio-stop-stopped":"Audio local detenido.","audio-stop-idle":"No hay enunciado local que detener.","audio-groups-title":"Grupos de audio compartido","audio-groups-help":"Decide en qué dispositivos se oye la voz cuando habla una celda. Un grupo es una preferencia local de entrega, no un consentimiento. Cada nodo conserva su consentimiento, ACL, disponibilidad y Stop local.","audio-groups-empty":"Sin grupos: la voz sale solo por este nodo.","audio-group-name":"nombre del grupo","audio-group-mode":"modo de entrega","audio-group-primary":"primero disponible (en orden)","audio-group-fanout":"todos los nodos enumerados","audio-group-targets":"nodos destino exactos","audio-group-local":"este nodo","audio-group-unavailable-target":"no detectado ahora","audio-group-no-targets":"No hay ningún nodo con instanceId disponible. Un grupo no puede usar nombres, comodines ni “todos”.","audio-group-new":"nuevo grupo","audio-group-edit":"editar","audio-group-delete":"eliminar","audio-group-save":"guardar grupo","audio-group-cancel":"cancelar","audio-group-invalid":"El grupo necesita un nombre válido y al menos un nodeId exacto.","audio-group-save-failed":"No se pudo guardar el grupo de audio.","node-display-label":"Nombre (etiqueta)","routed-node-aliases":"Alias de nodos enrutados","routed-node-aliases-help":"Visibles solo en este dispositivo; la ruta y el nombre remoto no cambian.","node-local-alias":"Alias en este dispositivo","alias-on-device":"Alias en este dispositivo","reset-alias":"Restablecer nombre remoto","node-slug-hint":"enrutado por slug: {slug}","device-name-label":"Nombre del dispositivo","device-name-hint":"cómo te ven los pares (editable)","local-route-name-label":"Nombre local / ruta","local-route-name-hint":"identificador técnico estable: etiqueta legible + sufijo del nodeId; editable antes de conectar","err-label":"etiqueta no válida (máx 64 caracteres, sin saltos de línea)","fleet-inventory":"Celdas y sesiones","fleet-inventory-help":"todas las posiciones (Local + rutas Hydra)","fleet-manage-location":"Gestionar ubicación","fleet-network-overview":"Vista de red","fleet-manage-help":"crea y configura celdas en la ubicación seleccionada","fleet-overview-help":"estado operativo de todas las ubicaciones, separado del editor","fleet-inventory-empty":"sin celdas ni sesiones","cell-switcher-refreshing":"actualizando celdas…","cell-switcher-empty-active":"no hay celdas activas verificadas","cell-switcher-not-confirmed":"estado sin confirmar","cell-switcher-not-active":"esta celda ya no está activa","cell-switcher-verify-failed":"No se pudo verificar: inténtalo de nuevo dentro de poco.","cell-switcher-select":"selecciona una celda","cell-switcher-open":"abrir celda","cell-switcher-show-all":"todas","cell-switcher-show-active":"activas","cell-switcher-close":"cerrar selector de celdas","fleet-not-available":"fleet no disponible en esta posición",start:"iniciar",stop:"detener",restart:"reiniciar",delete:"eliminar","copy-manual":"copia fallida — selecciona y pulsa Cmd+C, o copia a mano","copy-empty":"nada seleccionado: arrastra con Shift para seleccionar","selection-held":"resaltado perdido, texto aún retenido","selection-changed":"el texto bajo la selección cambió","invite-hub-only":"Una invitación se acuña en el hub. Admitir un nodo nuevo es lo único que un nodo conectado no puede pedir en nombre de otro: abre NexusCrew en el hub y créala allí.","row-private":"privado","node-detail-open":"abrir el detalle","node-detail-reach":"Alcanzabilidad","node-detail-route":"ruta","node-detail-ssh":"SSH","node-detail-transport":"transporte","node-detail-owner":"propietario","node-detail-authority":"Qué puede hacer este nodo","authority-owner-equivalent":"Autoridad igual a la tuya: un nodo emparejado puede hacer en esta máquina todo lo que puedes hacer tú.","authority-routed":"No está emparejado con esta máquina: su autoridad vive en el hub que lo enruta.","authority-no-grants":"El único poder por nodo que existe es la elección de celdas, más abajo. Dentro de esas celdas la autoridad sigue siendo plena.","authority-no-grants-elsewhere":"El único poder por nodo que existe es la elección de celdas, y se configura en la instalación que las posee — no aquí.","node-detail-network-view":"Qué ve de esta red","node-detail-command":"Comando","vl-no-commands":"El dispositivo no declara comandos disponibles.","vl-events-title":"Sesión","vl-events-empty":"Ningún evento en memoria: la sesión aún no ha hablado, o lo que dijo ha salido del búfer. El historial queda en el dispositivo.","vl-events-gap":"eventos no recibidos:","vl-events-truncated":"contenido truncado por el dispositivo","vl-events-turn-end":"— fin del turno —","vl-events-done":"— fin de la respuesta —","vl-events-writer-epoch":"— cambio de escritor —","vl-events-tool":"herramienta","vl-events-tool-ok":"terminada","vl-events-tool-failed":"fallida","vl-events-usage":"consumo actualizado","vl-events-stale":"Actualización fallida: puede que no estés viendo lo último.","vl-cmd-phase-submitted":"enviado, a la espera de confirmación","vl-cmd-phase-inflight":"en curso","vl-cmd-phase-done-ok":"completado","vl-cmd-phase-done-error":"fallido","vl-cmd-status":"estado","vl-cmd-health":"salud","vl-cmd-start":"iniciar","vl-cmd-stop":"detener","vl-cmd-restart":"reiniciar","vl-cmd-version":"versión","vl-cmd-capabilities":"capacidades","vl-cmd-logs":"logs","vl-cmd-prompt":"prompt","vl-prompt-placeholder":"escribe el prompt para la sesión del dispositivo…","vl-prompt-send":"enviar prompt","vl-cmd-unpair":"desemparejar","node-grant-none":"Ningún nodo elegido: compartido, pero hacia nadie.","node-grant-unknown":"ya no está en el inventario","node-grant-remove":"quitar","node-grant-add":"Añadir un nodo","node-grant-search":"Buscar entre los nodos","node-grant-no-candidates":"Ningún nodo coincide.","cell-scope":"Celdas visibles para este nodo","cell-scope-help":"Se aplica a lo que este nodo lista y a lo que puede tocar, incluido el terminal. Dentro de las celdas concedidas sigue siendo un nodo emparejado por completo: no es un sandbox.","cell-scope-all":"todas las celdas","cell-scope-none":"ninguna celda","cell-scope-selected":"celdas seleccionadas","cell-scope-none-granted":"Ninguna celda elegida: este nodo no ve ninguna.","cell-scope-unknown":"la celda ya no existe","cell-scope-add":"Añadir una celda","cell-scope-search":"Buscar entre las celdas","cell-scope-no-candidates":"Ninguna celda coincide.","cell-scope-reset-warning":"Al cambiar de modo la lista se borra: volver a «celdas seleccionadas» obliga a elegirlas de nuevo.","cell-scope-list-unavailable":"Lista de celdas no disponible ahora: las concesiones de abajo siguen vigentes, pero no se puede saber si aún existen.","single-view":"vista única",retract:"reducir","keybar-expand":"ampliar la barra de teclas","keybar-retract":"reducir la barra de teclas","save-and-start":"guardar e iniciar",permissions:"Permisos","power-on-hint":"Detén la celda; también puedes quitarla del boot.","launch-engine-help":"Proveedores, credenciales y nuevos motores se crean en Ajustes → Flota. Modelo y permisos son por celda.","launch-unavailable-hint":"La configuración del motor no está disponible en este nodo.","import-as-cell":"Importar como celda","import-help":"Reconcilia una sesión tmux existente en una celda gestionada. Elige un motor ya declarado: no se inventa ninguno.","import-engine-required":"elige un motor (obligatorio)","test-and-connect":"probar y conectar","pairing-v2-hint":"Pega o escanea UN solo enlace: rellena nombre, Host SSH y etiqueta cuando los incluye (v2).","invite-v2-hint":"Crea una invitación de un solo uso. Hace falta la dirección SSH de este dispositivo, alcanzable por quien la use.","invite-target-local":"El nuevo dispositivo entrará en","invite-target-this":"este dispositivo","invite-endpoint-label":"Dirección SSH de este hub vista por los otros dispositivos","invite-endpoint-auto":"Endpoint ya configurado","invite-endpoint-needed":"Introduce usuario@host o un alias SSH compartido. No es 127.0.0.1 ni la URL HTTP de NexusCrew.","invite-ssh-hint":"El destino SSH con el que el OTRO dispositivo alcanza ESTA instalación (usuario@host o alias). Obligatorio: se incluye en el enlace.","invite-next-steps":"copia este enlace, abre NexusCrew en el otro dispositivo y pégalo en Ajustes → Nodos (o escanea el QR): NexusCrew hace el resto","pair-card-title":"conectar con un solo enlace","pair-card-help":"Pega el enlace de emparejamiento generado en el otro dispositivo (o escanea su QR): NexusCrew lo decodifica, prueba la conexión SSH y conecta solo.","pair-paste-ph":"pega aquí el enlace de emparejamiento","pair-paste-btn":"pegar","pair-advanced":"avanzado / editar","pair-progress":"conectando: SSH → invitación → confirmación → verificación…","pair-retry":"reintentar","pair-invalid-link":"esto no es un enlace de emparejamiento válido","pair-invalid-hint":"se necesita el enlace completo (http://…#pair=…) generado por el otro NexusCrew: no lo abras, pégalo aquí","pair-missing-ssh":"el enlace no incluye el destino SSH (formato v1): indica en “avanzado” cómo este dispositivo alcanza al otro por SSH — nunca se inventa","pair-missing-name":"falta el nombre del nodo: complétalo en “avanzado”","pair-clipboard-denied":"lectura del portapapeles no permitida: pega manualmente en el campo","pair-clipboard-empty":"portapapeles vacío: copia primero el enlace","pair-stage-validation":"datos no válidos","pair-stage-conflict":"nombre ya en uso","pair-stage-ssh-start":"fallo al iniciar el túnel SSH","pair-stage-ssh-ready":"peer inaccesible por SSH","pair-stage-join":"intercambio de invitación fallido","pair-stage-tunnel-final":"túnel negociado fallido","pair-stage-confirm":"confirmación de emparejamiento fallida","pair-stage-health":"verificación final de la federación fallida","pair-stage-internal":"error interno","pair-stage-generic":"conexión fallida","qr-no-camera":"no hay cámara disponible en este dispositivo: usa una foto del QR","qr-permission":"permiso de cámara denegado: permítelo en el navegador o usa una foto del QR","qr-unsupported":"escáner en vivo no soportado aquí: sube una foto del QR","qr-upload":"usar una foto"}};function bu(){const t=p0(),e=t?t.getItem(f0):null;return mm.includes(e)?e:cu}function Gk(t){const e=p0();if(e)try{e.setItem(f0,t)}catch{}typeof window<"u"&&window.dispatchEvent(new Event(Kf))}function m(t){const e=bu(),n=qc[e]||qc[cu];return Object.prototype.hasOwnProperty.call(n,t)?n[t]:Object.prototype.hasOwnProperty.call(qc[cu],t)?qc[cu][t]:t}function Xk(t){return typeof window>"u"?()=>{}:(window.addEventListener(Kf,t),()=>window.removeEventListener(Kf,t))}const m0=mm,Qk="none",g0="favorite",v0="designated",_0="thread-present",y0="thread-active",w0="thread-unknown",gm=new Set([v0,_0,y0,w0]);function Jk(t){return t==="absent"?v0:t==="present"?_0:t==="active"?y0:w0}function Zk(t){return gm.has(t)?`host-thread-${t.replace("thread-","")}`:null}function Su({hostCell:t,threadStatus:e,pins:n=[],item:i}){const s=i&&i.value&&typeof i.value.cell=="string"?i.value.cell:null;return s!=null&&t===s?Jk(e):Array.isArray(n)&&i&&n.includes(i.key)?g0:Qk}function e2(t){return gm.has(t)?"clearAndUnpin":t===g0?"designate":"addPin"}const t2=Object.freeze(["live","grace","expired","none","unavailable"]);function Vf(t,e){return!gm.has(t)||!t2.includes(e)?null:`host-lease-${e}`}const n2="local";function ea(t){return Array.isArray(t)&&t.length?t.join("/"):n2}function Yf(t){return(t&&t.data&&typeof t.data=="object"?t.data.reason:null)==="live-host-not-granted"?"live-host-not-granted":"live-host-error"}async function U_(t){let e;try{e=await t}catch(n){return{ok:!1,error:n}}return e===!0?{ok:!0}:e===!1||e==null?{ok:!1}:{ok:e.ok===!0,error:e.error}}function i2({item:t,pins:e,hostByRoute:n,route:i}){const s=(n||{})[ea(i)]||{},a=Su({hostCell:s.hostCell??null,threadStatus:s.threadStatus,pins:e,item:t}),l=Zk(a);return{state:a,live:!!l,favorite:a==="favorite",filled:a!=="none",titleKey:l||"pin",action:e2(a)}}async function s2({view:t,itemKey:e,cellName:n,route:i,togglePin:s,removePin:a,designate:l,clearHost:d}){if(t.action==="addPin")return s(e),{ok:!0};if(t.action==="designate")return l?U_(l(n,i)):{ok:!1};if(t.action==="clearAndUnpin"){if(!d)return{ok:!1};const h=await U_(d(i));return h.ok&&a(e),h}return{ok:!1}}function xu({item:t,pins:e,hostByRoute:n,route:i=[],cellName:s,togglePin:a,removePin:l,designate:d,clearHost:h,onOutcome:f,baseClassName:g=""}){const y=i2({item:t,pins:e,hostByRoute:n,route:i}),_=`${m(y.titleKey)} ${s}`,w=`${g}${y.live?` ${y.state}`:""}${y.favorite?" on":""}`,b=N=>{N.stopPropagation(),Promise.resolve(s2({view:y,itemKey:t.key,cellName:s,route:i,togglePin:a,removePin:l,designate:d,clearHost:h})).then(x=>{f&&f(x)})};return c.jsx("button",{type:"button",className:w,"data-cell-star":y.state,title:m(y.titleKey),"aria-label":_,onClick:b,children:y.filled?"★":"☆"})}const r2=["all","pinned","active","off","technical"],b0="nc_sidebar_views_v1",S0="nc_sidebar_order_v1";function x0(t){return r2.includes(t)?t:"all"}function o2(t,e=[],n="all"){const i=x0(n);return i==="technical"?t.technical===!0:t.technical===!0?!1:i==="pinned"?e.includes(t.key):i==="active"?!!t.live:i==="off"?!t.live:!0}function a2(t,e,n=[],i=[]){const s=n.indexOf(t.key),a=n.indexOf(e.key),l=s===-1?Number.MAX_SAFE_INTEGER:s,d=a===-1?Number.MAX_SAFE_INTEGER:a,h=i.indexOf(t.key),f=i.indexOf(e.key),g=h===-1?Number.MAX_SAFE_INTEGER:h,y=f===-1?Number.MAX_SAFE_INTEGER:f;return l-d||g-y||+!!e.live-+!!t.live||+!!e.fresh-+!!t.fresh||Number(e.activity||0)-Number(t.activity||0)||String(t.label||"").localeCompare(String(e.label||""))||String(t.key||"").localeCompare(String(e.key||""))}function l2(t=globalThis.localStorage){try{const e=JSON.parse(t.getItem(S0));if(!e||typeof e!="object"||Array.isArray(e))return{};const n={};for(const[i,s]of Object.entries(e).slice(0,64)){if(typeof i!="string"||!i||i.length>160||!Array.isArray(s))continue;const a=[...new Set(s.filter(l=>typeof l=="string"&&l&&l.length<=256))].slice(0,128);a.length&&(n[i]=a)}return n}catch{return{}}}function Vs(t,e){return Array.isArray(t==null?void 0:t[e])?t[e]:[]}function c2(t,e=globalThis.localStorage){try{e.setItem(S0,JSON.stringify(t))}catch{}return t}function u2(t,e,n,i,s=[]){if(typeof e!="string"||!e||n===i)return t;const a=[...new Set(s.filter(_=>typeof _=="string"&&_))];if(!a.includes(n)||!a.includes(i))return t;const l=Vs(t,e).filter(_=>a.includes(_)),d=[...l,...a.filter(_=>!l.includes(_))],h=d.indexOf(n),f=d.indexOf(i);d.splice(h,1);const g=d.indexOf(i),y=h<f?g+1:g;return d.splice(y,0,n),{...t,[e]:d}}function d2(t=globalThis.localStorage){try{const e=JSON.parse(t.getItem(b0));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function W_(t,e){var n,i;return{open:((n=t==null?void 0:t[e])==null?void 0:n.open)!==!1,filter:x0((i=t==null?void 0:t[e])==null?void 0:i.filter)}}function h2(t,e=globalThis.localStorage){try{e.setItem(b0,JSON.stringify(t))}catch{}return t}function q_(t,e=""){const n=String(e||"").trim().toLocaleLowerCase();return n?[t.label,t.key,t.searchText].filter(Boolean).join(" ").toLocaleLowerCase().includes(n):!0}function Nr(t=[],e=[],n="all",i=[]){return[...t].filter(s=>o2(s,e,n)).sort((s,a)=>a2(s,a,e,i))}function li(){return[k.useSyncExternalStore(Xk,bu,bu),Gk]}function Cu({cell:t,token:e,route:n=[],onConfirm:i,onClose:s}){var P,A;li();const a=!!(t&&t.active),l=Array.isArray(n)?n.join("/"):"",[d,h]=k.useState([]),[f,g]=k.useState(!1);k.useEffect(()=>{let R=!0;return(async()=>{if(e)try{const D=await Ar(e,l?l.split("/"):[]);if(!R)return;if(g(D.provider==="builtin"&&(D.capabilities||[]).includes("edit")),D.provider==="builtin"&&(D.capabilities||[]).includes("definitions")){const H=await Wu(e,l?l.split("/"):[]);if(!R)return;const z=new Map((D.engines||[]).map(F=>[F.id,F]));h((H.engines||[]).map(F=>{var K,ne,re,Y,de,oe,pe;return{id:F.id,label:F.label||F.id,client:((K=F.managed)==null?void 0:K.client)||"",models:[...new Set([...((ne=z.get(F.id))==null?void 0:ne.models)||[],...((re=F.managedInfo)==null?void 0:re.models)||[]])].filter(Boolean),defaultModel:((Y=F.managed)==null?void 0:Y.model)||((de=F.managedInfo)==null?void 0:de.defaultModel)||"",policyDefault:((oe=F.managed)==null?void 0:oe.permissionPolicy)||((pe=F.managed)!=null&&pe.client&&F.managed.client==="claude"?"unsafe":"standard")}}))}}catch{}})(),()=>{R=!1}},[e,l]);const y=(t==null?void 0:t.engine)||((P=d[0])==null?void 0:P.id)||"",_=R=>(t==null?void 0:t.models)&&t.models[R]||"",w=R=>{const D=(t==null?void 0:t.permissionPolicies)&&t.permissionPolicies[R];if(D==="standard"||D==="unsafe")return D;const H=d.find(z=>z.id===R);return H?H.policyDefault:"standard"},[b,N]=k.useState(y),[x,E]=k.useState((t==null?void 0:t.model)||""),C=(t==null?void 0:t.permissionPolicy)==="standard"||(t==null?void 0:t.permissionPolicy)==="unsafe"?t.permissionPolicy:((A=t==null?void 0:t.permissionPolicies)==null?void 0:A[t==null?void 0:t.engine])||"",[I,T]=k.useState(C),[W,U]=k.useState((t==null?void 0:t.boot)??!0),[Q,ee]=k.useState(!1),[q,J]=k.useState(null);k.useEffect(()=>{d.length&&(N(R=>R||y),E(R=>R||_((t==null?void 0:t.engine)||y)||""),T(R=>R==="standard"||R==="unsafe"?R:w((t==null?void 0:t.engine)||y)))},[d.length]);const $=k.useMemo(()=>d.find(R=>R.id===b)||null,[d,b]),M=!!($&&["claude","codex","codex-vl","agy","kimi"].includes($.client)),L=($==null?void 0:$.client)==="shell";function j(R){N(R);const D=d.find(H=>H.id===R);E(_(R)||(D==null?void 0:D.defaultModel)||""),T(w(R))}async function O(R){R.preventDefault(),ee(!0),J(null);try{if(a)await i({action:"down",boot:W});else{const D=I==="standard"||I==="unsafe"?I:($==null?void 0:$.policyDefault)||"standard";await i({action:"up",...f?{engine:b,model:x||"",...M?{permissionPolicy:D}:($==null?void 0:$.client)==="pi"?{permissionPolicy:"standard"}:{}}:{},boot:W})}s()}catch(D){J(String(D&&D.message||D)),ee(!1)}}return c.jsx("div",{className:"nc-sheet-overlay nc-launch-overlay",onClick:s,children:c.jsxs("form",{className:"nc-sheet nc-power-sheet nc-launch-sheet",onClick:R=>R.stopPropagation(),onSubmit:O,children:[c.jsxs("div",{className:"nc-sheet-head",children:[c.jsx("b",{children:t==null?void 0:t.cell}),c.jsx("span",{className:"nc-sheet-state",children:m(a?"state-on":"state-off")})]}),a?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"nc-power-config",children:[c.jsx("span",{children:m("engine")}),c.jsx("b",{children:(t==null?void 0:t.engine)||"—"}),(t==null?void 0:t.model)&&c.jsxs("small",{children:[m("model"),": ",t.model]}),c.jsx("small",{children:m("power-on-hint")})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:W,onChange:R=>U(R.target.checked)}),m("remove-boot")]})]}):c.jsxs(c.Fragment,{children:[f&&d.length>0?c.jsxs("div",{className:"nc-launch-fields",children:[c.jsxs("label",{className:"nc-field",children:[m("engine"),c.jsx("select",{value:b,onChange:R=>j(R.target.value),children:d.map(R=>c.jsx("option",{value:R.id,children:R.label},R.id))})]}),!L&&c.jsxs("label",{className:"nc-field",children:[m("model"),c.jsx("input",{value:x,list:"nc-launch-models",placeholder:m("model-default"),onChange:R=>E(R.target.value)}),c.jsx("datalist",{id:"nc-launch-models",children:(($==null?void 0:$.models)||[]).map(R=>c.jsx("option",{value:R},R))})]}),M?c.jsxs("label",{className:"nc-field",children:[m("permissions"),c.jsxs("select",{value:I,onChange:R=>T(R.target.value),children:[c.jsx("option",{value:"standard",children:m("fleet-standard-permissions")}),c.jsx("option",{value:"unsafe",children:m("fleet-unsafe-permissions")})]})]}):c.jsx("small",{className:"nc-note",children:m("fleet-standard-permissions")}),M&&I==="unsafe"&&c.jsx("small",{className:"nc-err",children:m("fleet-unsafe-warning")}),c.jsx("small",{className:"nc-note",children:m(L?"fleet-shell-launch-help":"launch-engine-help")})]}):c.jsxs("div",{className:"nc-power-config",children:[c.jsx("span",{children:m("engine")}),c.jsx("b",{children:(t==null?void 0:t.engine)||"—"}),(t==null?void 0:t.model)&&c.jsxs("small",{children:[m("model"),": ",t.model]}),c.jsx("small",{children:m("launch-unavailable-hint")})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:W,onChange:R=>U(R.target.checked)}),m("boot-persist")]})]}),q&&c.jsx("div",{className:"nc-err",children:q}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:s,disabled:Q,children:m("cancel")}),c.jsx("button",{type:"submit",className:"nc-btn primary",disabled:Q,children:m(a?"power-off":"save-and-start")})]})]})})}const K_=/^[a-z0-9-]{1,32}$/;function Cl(t,e){const n=Array.isArray(t)?t:[];return n.length?`${n.map(encodeURIComponent).join("/")}:${e}`:String(e)}function f2(t,e,n){const i={};for(const s of Array.isArray(e)?e:[]){const a=Array.isArray(s==null?void 0:s.route)?s.route:typeof(s==null?void 0:s.name)=="string"?[s.name]:[];if(!a.length)continue;const l=a.join("/"),d=s.status==="up"||s.tunnel&&s.tunnel.status==="up",h=s.status==="passive"||s.tunnel&&s.tunnel.status==="passive";!d&&!h&&(i[l]=t&&t[l]||n)}return i}function Gf(t,e,n,i=!1){return!t||!Array.isArray(t.cells)?[]:t.cells.map(s=>({...s,route:e,key:`${n}:${s.tmuxSession||s.cell}`,...i?{preserved:!0}:{}}))}function Qa(t,e,n){if(!t)return{};const i=Xf(t);return!fl(t,i)||i!=="stale"?{}:{cells:Gf(t,e,n,!0),fleetState:"stale",fleetAvailable:!1,cellsPreserved:!0}}function Xf(t){return(t==null?void 0:t.fleetState)==="stale"?"stale":(t==null?void 0:t.fleetState)==="disabled"?"disabled":(t==null?void 0:t.available)===!0&&Array.isArray(t.cells)?"available":(t==null?void 0:t.available)===!1?"disabled":"stale"}function fl(t,e){return(e==="available"||e==="stale")&&Array.isArray(t==null?void 0:t.cells)}function V_({nodes:t,topology:e,remote:n,down:i,fleet:s,aliases:a}={}){var f,g,y,_;const l=[],d=new Set,h=new Set;for(const w of Array.isArray(t)?t:[]){if(!w||typeof w.name!="string"||!K_.test(w.name)||w.direction==="inbound"&&w.shared!==!0)continue;const b=[w.name],N=w.name;d.add(N);const x=((f=w.tunnel)==null?void 0:f.status)||"unknown",E=x==="up",C={name:w.name,label:w.label||w.name,originalLabel:w.label||w.name,alias:null,route:b,direct:!0,instanceId:w.nodeId||null,shared:w.shared===!0,tunnelStatus:x,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:w.health||null,direction:w.direction||"outbound",roles:w.roles||null,rolesKnown:w.rolesKnown===!0};if(w.nodeId&&h.add(w.nodeId),!w.nodeId&&w.paired===!1){l.push({...C,status:"needs-repair",downSince:i&&i[N]||null,...Qa(s&&(s[N]||s[w.name]),b,N)});continue}if(((g=w.health)==null?void 0:g.auth)==="failed"||x==="degraded"&&((y=w.health)==null?void 0:y.status)==="degraded"){l.push({...C,status:"needs-repair",downSince:i&&i[N]||null,...Qa(s&&(s[N]||s[w.name]),b,N)});continue}if(x==="passive"||((_=w.health)==null?void 0:_.status)==="passive"){l.push({...C,status:"passive",downSince:null,...Qa(s&&(s[N]||s[w.name]),b,N)});continue}if(!E){l.push({...C,status:"down",downSince:i&&i[N]||null,...Qa(s&&(s[N]||s[w.name]),b,N)});continue}const I=n&&(n[N]||n[w.name])||null,T=s&&(s[N]||s[w.name]),W=!!(I&&!I.error&&Array.isArray(I.sessions)),U=Xf(T),Q=U==="available"&&fl(T,U),ee=fl(T,U);if(!W&&!ee){l.push({...C,status:"unreachable",cause:I&&I.cause||null});continue}const q=(W?I.sessions:[]).filter(M=>M&&typeof M.name=="string"&&M.name).map(M=>({...M,node:N,route:b,key:`${N}:${M.name}`})),J=Gf(T,b,N),$=new Set(J.map(M=>M.tmuxSession).filter(Boolean));l.push({...C,status:"up",sessions:q,cells:J,unmanaged:q.filter(M=>!$.has(M.name)),fleetAvailable:Q,fleetState:U,capabilities:T&&T.capabilities||[],engines:T&&T.engines||[],fleetProvider:T&&T.provider||null,sessionsAvailable:W,inventoryPartial:!W})}for(const w of Array.isArray(e)?e:[]){if(!w||!Array.isArray(w.route)||w.route.length<1||w.route.some($=>!K_.test($)))continue;const b=w.route.join("/");if(d.has(b)||w.instanceId&&h.has(w.instanceId))continue;w.instanceId&&h.add(w.instanceId);const N=w.label||w.route.join(" › "),x=w.instanceId&&a&&typeof a[w.instanceId]=="string"?a[w.instanceId]:null,E={name:w.name,label:x||N,originalLabel:N,alias:x,route:[...w.route],direct:!1,instanceId:w.instanceId||null,shared:!0,tunnelStatus:null,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:w.health||null,lastSeen:w.lastSeen||null};if(w.stale){l.push({...E,status:"offline",downSince:i&&i[b]||w.lastSeen||null,...Qa(s&&s[b],w.route,b)});continue}const C=n&&n[b]||null,I=s&&s[b],T=!!(C&&!C.error&&Array.isArray(C.sessions)),W=Xf(I),U=W==="available"&&fl(I,W),Q=fl(I,W);if(!T&&!Q){l.push({...E,status:"unreachable",downSince:i&&i[b]||null,cause:C&&C.cause||null});continue}const ee=(T?C.sessions:[]).filter($=>$&&typeof $.name=="string"&&$.name).map($=>({...$,node:b,route:w.route,key:`${b}:${$.name}`})),q=Gf(I,w.route,b),J=new Set(q.map($=>$.tmuxSession).filter(Boolean));l.push({...E,status:"up",sessions:ee,cells:q,unmanaged:ee.filter($=>!J.has($.name)),fleetAvailable:U,fleetState:W,capabilities:I&&I.capabilities||[],engines:I&&I.engines||[],fleetProvider:I&&I.provider||null,lastSeen:w.lastSeen||null,sessionsAvailable:T,inventoryPartial:!T})}return l.sort((w,b)=>w.label.localeCompare(b.label))}function C0(t,e={}){if(!t||typeof t!="object")return null;const n=typeof t.nodeId=="string"?t.nodeId:"";if(!n)return null;const i=typeof t.label=="string"&&t.label.trim()||typeof t.cell=="string"&&t.cell.trim()||n,s=Array.isArray(e.route)?[...e.route]:[];return{kind:"vl",nodeId:n,name:n,label:i,cell:t.cell??null,paired:!!t.pairedAt,online:!!t.online,lastSeen:t.lastSeen??null,generation:t.generation??null,version:t.version??null,health:t.health??null,session:t.session??null,capabilities:Array.isArray(t.capabilities)?t.capabilities:[],inflight:t.inflight??null,lastAck:t.lastAck??null,canManage:!!t.canManage,route:s,isLocal:s.length===0,ownerInstanceId:typeof e.instanceId=="string"?e.instanceId:null,ownerLabel:typeof e.label=="string"&&e.label?e.label:null}}function p2(t){var n;const e=[];for(const i of Array.isArray(t)?t:[]){if(!i||i.kind!=="vl"||!i.nodeId)continue;const s=i.online===!0,a=s&&((n=i.session)==null?void 0:n.attached)===!0,l=i.ownerInstanceId||"local";e.push({kind:"vl",name:`vl-${i.nodeId.slice(0,8)}`,label:i.label,route:Array.isArray(i.route)?[...i.route]:[],instanceId:null,direct:!1,status:s?"up":"offline",downSince:s?null:i.lastSeen??null,sessions:a?[{key:`vl:${l}:${i.nodeId}`,name:i.session.profile,attached:!0}]:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:i.health??null,peer:i})}return e}function k0(t,e){const n=t&&Array.isArray(t.nodes)?t.nodes:[],i=new Set([e]),s=[];for(const a of n){const l=a&&typeof a.instanceId=="string"?a.instanceId:"";if(!l||i.has(l)||a.stale===!0||!Array.isArray(a.route)||a.route.length===0)continue;i.add(l);const d=typeof a.label=="string"&&a.label||typeof a.name=="string"&&a.name||a.route.join(" › ");s.push({instanceId:l,route:[...a.route],label:d})}return s}const m2=/fleet\.json/;function vm({fs:t=null,error:e=null}={}){if(e)return{kind:"stale"};if(!t)return{kind:"stale"};if(t.available===!0)return{kind:"data",cells:t.cells||[],capabilities:t.capabilities||[]};const n=typeof t.reason=="string"?t.reason:"";return typeof t.migrationCode=="string"&&t.migrationCode?{kind:"disabled",reason:n||null}:m2.test(n)?{kind:"stale"}:{kind:"disabled",reason:n||null}}const E0={baseMs:4e3,capMs:6e4},N0="peer-assente",L0="peer-nega",R0="rotta-inesistente";function Ih(t){const e=t&&t.status;return e===403?L0:e===404?R0:N0}function g2(t,{baseMs:e,capMs:n}=E0){return!Number.isFinite(t)||t<1?0:Math.min(e*2**(t-1),n)}function Y_(t,e,n){const i=t&&t[e];return!i||!(i.failures>=1)?!0:n>=i.nextAtMs}function G_(t,e,n,i,s=E0){const l=(t&&t[e]||{failures:0}).failures+1;return{...t,[e]:{failures:l,cause:n,nextAtMs:i+g2(l,s)}}}function X_(t,e){if(!t||!(e in t))return t;const n={...t};return delete n[e],n}const v2=4e3;function _m(t,e=!0,n=0){const[i,s]=k.useState([]),a=k.useRef({}),l=k.useRef({}),d=k.useRef({remote:{},fleet:{}});return k.useEffect(()=>{if(!e||!t){s([]);return}let h=!0;async function f(){var Q,ee;const y=Date.now();let _=[],w=[],b={},N="";if(await Promise.all([mk(t).then(q=>{_=Array.isArray(q.nodes)?q.nodes:[]}).catch(()=>{}),d0(t).then(q=>{w=Array.isArray(q.nodes)?q.nodes:[]}).catch(()=>{}),bk(t).then(q=>{b=q&&typeof q.aliasesByInstanceId=="object"?q.aliasesByInstanceId:{}}).catch(()=>{}),pn("/api/config",t).then(q=>q.json()).then(q=>{N=q&&typeof q.instanceId=="string"?q.instanceId:""}).catch(()=>{})]),!h)return;const x=[{instanceId:N||null,route:[],label:null},...k0({nodes:w},N)],E=[];if(await Promise.all(x.map(async q=>{const J=`vl:${q.route.join("/")}`;if(Y_(l.current,J,y))try{const $=await u0(t,q.route);l.current=X_(l.current,J);for(const M of $.nodes||[]){const L=C0(M,q);L&&E.push(L)}}catch($){l.current=G_(l.current,J,Ih($),y)}})),!h)return;const C={},I={},T=new Set(_.map(q=>q.name)),W=[];for(const q of _)((Q=q.tunnel)==null?void 0:Q.status)==="up"&&(q.nodeId||q.paired!==!1)&&(q.direction!=="inbound"||q.shared===!0)&&W.push([q.name]);for(const q of w)!q.stale&&Array.isArray(q.route)&&q.route.length>0&&!(q.route.length===1&&T.has(q.route[0]))&&W.push(q.route);if(await Promise.all(W.map(async q=>{const J=q.join("/");if(!Y_(l.current,J,y)){const L=d.current.remote[J];L&&(C[J]=L);const j=d.current.fleet[J];j&&(I[J]={...j,available:!1,fleetState:"stale"});return}let $=!1;try{C[J]=await hm(t,q),$=!0,d.current.remote[J]=C[J]}catch(L){C[J]={error:"unreachable",cause:Ih(L)},d.current.remote[J]=C[J]}const M=d.current.fleet[J]||null;try{const L=await Ar(t,q),j=vm({fs:L});j.kind==="data"?I[J]={...L,available:!0,cells:j.cells,fleetState:"available"}:j.kind==="disabled"?I[J]={...L,available:!1,cells:[],fleetState:"disabled"}:I[J]={...M||{},available:!1,cells:Array.isArray(M==null?void 0:M.cells)?M.cells:[],fleetState:"stale",...L!=null&&L.reason?{reason:L.reason}:{}},d.current.fleet[J]=I[J]}catch(L){I[J]={...M||{},available:!1,cells:Array.isArray(M==null?void 0:M.cells)?M.cells:[],fleetState:"stale",cause:Ih(L)},d.current.fleet[J]=I[J]}l.current=$?X_(l.current,J):G_(l.current,J,C[J].cause,y)})),!h)return;for(const q of _){if(((ee=q.tunnel)==null?void 0:ee.status)==="up")continue;const J=d.current.fleet[q.name];J&&!I[q.name]&&(I[q.name]={...J,available:!1,fleetState:"stale"})}for(const q of w){if(!q.stale||!Array.isArray(q.route)||!q.route.length)continue;const J=q.route.join("/"),$=d.current.fleet[J];$&&!I[J]&&(I[J]={...$,available:!1,fleetState:"stale"})}const U=V_({nodes:_,topology:w,remote:C,fleet:I,aliases:b,down:a.current});a.current=f2(a.current,U,Math.floor(Date.now()/1e3)),s([...V_({nodes:_,topology:w,remote:C,fleet:I,aliases:b,down:a.current}),...p2(E)])}f();const g=setInterval(f,v2);return()=>{h=!1,clearInterval(g)}},[t,e,n]),i}const Q_=52,J_=14;function ys({position:t,itemKey:e,label:n,onMove:i,onStep:s,canMove:a=()=>!0,scope:l="roster"}){const d=k.useRef(null),h=k.useRef(0),[f,g]=k.useState(!1),y=()=>{var E,C,I,T;const x=d.current;(C=(E=x==null?void 0:x.over)==null?void 0:E.classList)==null||C.remove("nc-roster-over"),(T=(I=x==null?void 0:x.source)==null?void 0:I.classList)==null||T.remove("nc-roster-dragging"),h.current&&cancelAnimationFrame(h.current),h.current=0},_=(x=!1)=>{const E=d.current;if(!E)return;const C=E.target;y(),d.current=null,g(!1);try{E.handle.releasePointerCapture(E.pointerId)}catch{}x&&C&&C!==e&&a(e,C)&&i(e,C)},w=(x,E)=>{var ee,q,J,$,M,L,j,O,P;const C=d.current;if(!C)return;C.x=x,C.y=E;const I=l==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",T=(q=(ee=document.elementFromPoint(x,E))==null?void 0:ee.closest)==null?void 0:q.call(ee,I),W=l==="node"?(J=T==null?void 0:T.dataset)==null?void 0:J.nodeOrderKey:($=T==null?void 0:T.dataset)==null?void 0:$.rosterKey,Q=(l==="node"||((M=T==null?void 0:T.dataset)==null?void 0:M.position)===t)&&W&&W!==e&&a(e,W);C.over!==(Q?T:null)&&((j=(L=C.over)==null?void 0:L.classList)==null||j.remove("nc-roster-over"),C.over=Q?T:null,(P=(O=C.over)==null?void 0:O.classList)==null||P.add("nc-roster-over")),C.target=Q?W:null},b=()=>{const x=d.current;if(!x){h.current=0;return}const E=x.container;if(E){const C=E.getBoundingClientRect(),I=x.y<C.top+Q_?-J_:x.y>C.bottom-Q_?J_:0;I&&(E.scrollTop+=I,w(x.x,x.y))}h.current=requestAnimationFrame(b)};k.useEffect(()=>{const x=C=>{C.key==="Escape"&&d.current&&(C.preventDefault(),_(!1))},E=()=>_(!1);return window.addEventListener("keydown",x),window.addEventListener("blur",E),()=>{window.removeEventListener("keydown",x),window.removeEventListener("blur",E),y(),d.current=null}},[e,t,l]);const N=x=>{var T;if(x.pointerType==="mouse"&&x.button!==0)return;x.preventDefault(),x.stopPropagation(),x.currentTarget.focus({preventScroll:!0});const E=l==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",C=x.currentTarget.closest(E),I=x.currentTarget.closest(".nc-side-scroll, .nc-home-scroll, .nc-cell-switcher-list");d.current={pointerId:x.pointerId,handle:x.currentTarget,source:C,container:I,target:null,over:null,x:x.clientX,y:x.clientY},(T=C==null?void 0:C.classList)==null||T.add("nc-roster-dragging");try{x.currentTarget.setPointerCapture(x.pointerId)}catch{}g(!0),h.current=requestAnimationFrame(b)};return c.jsx("button",{type:"button",className:`nc-roster-handle${f?" active":""}`,"aria-label":`${m("reorder")} ${n}`,"aria-keyshortcuts":"ArrowUp ArrowDown",title:m("reorder-help"),onClick:x=>{x.preventDefault(),x.stopPropagation()},onDragStart:x=>x.preventDefault(),onKeyDown:x=>{x.key!=="ArrowUp"&&x.key!=="ArrowDown"||(x.preventDefault(),x.stopPropagation(),s(x.key==="ArrowUp"?-1:1))},onPointerDown:N,onPointerMove:x=>{!d.current||x.pointerId!==d.current.pointerId||(x.preventDefault(),x.stopPropagation(),w(x.clientX,x.clientY))},onPointerUp:x=>{!d.current||x.pointerId!==d.current.pointerId||(x.preventDefault(),x.stopPropagation(),_(!0))},onPointerCancel:()=>_(!1),onLostPointerCapture:()=>{d.current&&_(!1)},children:"↕"})}const ym="nc_pins";function Bh(){try{const t=JSON.parse(localStorage.getItem(ym));return Array.isArray(t)?t:[]}catch{return[]}}function M0(t){try{return localStorage.setItem(ym,JSON.stringify(t)),null}catch(e){return e instanceof Error?e:new Error(String(e))}}function _2(t,e){const n=t.includes(e)?t.filter(i=>i!==e):[...t,e];return{next:n,error:M0(n)}}function Z_(t,e){if(!Array.isArray(t)||!t.includes(e))return{next:Array.isArray(t)?t:[],error:null};const n=t.filter(i=>i!==e);return{next:n,error:M0(n)}}function y2(t,e,n){if(!t.includes(e)||!t.includes(n)||e===n)return t;const i=[...t],s=i.indexOf(e),a=i.indexOf(n);i.splice(s,1);const l=i.indexOf(n);i.splice(s<a?l+1:l,0,e);try{localStorage.setItem(ym,JSON.stringify(i))}catch{}return i}function w2(t,e,n){const i=t.indexOf(e);return[i===-1?1e9:i,-(n||0)]}function b2(t,e){return t[0]-e[0]||t[1]-e[1]}function wm(){const[t,e]=k.useState(Bh),[n,i]=k.useState(d2),[s,a]=k.useState(l2),[l,d]=k.useState(null),h=E=>e(C=>_2(C,E).next),f=E=>{const C=Z_(Bh(),E);return e(C.next),d(C.error?{key:E,message:C.error.message||String(C.error)}:null),C.error},g=()=>{if(!l)return;const E=Z_(Bh(),l.key);e(E.next),d(E.error?{...l,message:E.error.message||String(E.error)}:null)},y=()=>d(null),_=E=>W_(n,E),w=(E,C)=>i(I=>{const T={...I,[E]:{...W_(I,E),...C}};return h2(T)}),b=(E,C)=>t.includes(E)===t.includes(C);function N(E,C,I,T){const W=t.includes(C),U=t.includes(I);if(W===U){if(W){e(Q=>y2(Q,C,I));return}a(Q=>{var J;const ee=((J=T.find($=>$.key===C))==null?void 0:J.technical)===!0,q=Nr(T,t,ee?"technical":"all",Vs(Q,E)).map($=>$.key);return c2(u2(Q,E,C,I,q))})}}function x(E,C,I,T){var J;const W=((J=T.find($=>$.key===C))==null?void 0:J.technical)===!0,U=t.includes(C),Q=Nr(T,t,W?"technical":"all",Vs(s,E)).map($=>$.key).filter($=>t.includes($)===U),ee=Q.indexOf(C),q=Q[ee+I];ee>=0&&q&&N(E,C,q,T)}return{pins:t,views:n,orders:s,togglePin:h,removePin:f,pinError:l,retryPinPersist:g,clearPinError:y,viewFor:_,updateView:w,canMoveRoster:b,moveRoster:N,stepRoster:x}}const A0="nc_node_order_v1",S2=/^[a-f0-9]{16,64}$/;function to(t){if(S2.test(String((t==null?void 0:t.instanceId)||"")))return`id:${t.instanceId}`;const e=Array.isArray(t==null?void 0:t.route)?t.route.filter(n=>typeof n=="string"&&n):[];return e.length?`route:${e.map(encodeURIComponent).join("/")}`:typeof(t==null?void 0:t.name)=="string"&&t.name?`name:${encodeURIComponent(t.name)}`:""}function ey(t=globalThis.localStorage){try{const e=JSON.parse(t.getItem(A0));return Array.isArray(e)?[...new Set(e.filter(n=>typeof n=="string"&&n&&n.length<=192))].slice(0,128):[]}catch{return[]}}function x2(t,e=globalThis.localStorage){try{e.setItem(A0,JSON.stringify(t))}catch{}return t}function ty(t=[],e=[]){const n=new Map(e.map((i,s)=>[i,s]));return t.map((i,s)=>({group:i,index:s})).sort((i,s)=>{const a=n.has(to(i.group))?n.get(to(i.group)):Number.MAX_SAFE_INTEGER,l=n.has(to(s.group))?n.get(to(s.group)):Number.MAX_SAFE_INTEGER;return a-l||i.index-s.index}).map(({group:i})=>i)}function C2(t,e,n,i=[]){if(!e||!n||e===n)return t;const s=i.map(to).filter(Boolean);if(!s.includes(e)||!s.includes(n))return t;const a=[...t.filter(f=>s.includes(f)),...s.filter(f=>!t.includes(f))],l=a.indexOf(e),d=a.indexOf(n);a.splice(l,1);const h=a.indexOf(n);return a.splice(l<d?h+1:h,0,e),a}const Qf="nexuscrew-node-preferences";function k2(){try{window.dispatchEvent(new Event(Qf))}catch{}}function j0(){const[t,e]=k.useState(ey);k.useEffect(()=>{const a=()=>e(ey());return window.addEventListener("storage",a),window.addEventListener(Qf,a),()=>{window.removeEventListener("storage",a),window.removeEventListener(Qf,a)}},[]);const n=a=>ty(a,t),i=(a,l,d)=>e(h=>{const f=C2(h,a,l,d);return x2(f),k2(),f});return{order:t,groupsFor:n,moveNode:i,stepNode:(a,l,d)=>{const h=ty(d,t).map(to),f=h.indexOf(a),g=h[f+l];f>=0&&g&&i(a,g,d)},nodeKey:to}}function P0({pinError:t,onRetry:e,onDismiss:n}){return t?c.jsxs("div",{className:"nc-pin-error",role:"alert",children:[c.jsx("span",{className:"nc-pin-error-text",children:"★ preferenza non salvata"}),c.jsx("button",{type:"button",className:"nc-pin-error-retry",onClick:e,children:"riprova"}),c.jsx("button",{type:"button",className:"nc-pin-error-close",onClick:n,"aria-label":"chiudi avviso",children:"×"})]}):null}function sa(t,e=Math.floor(Date.now()/1e3)){if(!t)return"";const n=e-t;return n<0||n<60?"ora":n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}g`}function Ws(t){return t.status==="passive"?m("node-passive"):t.status==="down"?t.downSince?m("tunnel-down-since").replace("{t}",sa(t.downSince)):m("tunnel-down"):t.status==="unreachable"?t.cause===L0?m("peer-cause-nega"):t.cause===R0?m("peer-cause-rotta"):t.cause===N0?m("peer-cause-assente"):m("node-unreachable"):t.status==="offline"?t.lastSeen?m("node-offline-seen").replace("{t}",sa(t.lastSeen)):m("node-offline"):t.status==="needs-repair"?m("node-needs-repair"):""}function T0(t,{passive:e=null}={}){return t?t.status==="passive"?e:t.status==="healthy"?"on":"warn":null}function ku(t){return t&&(t.detail||t.status)||""}const E2="restrict,port-forwarding,permitopen=";function N2(t){const e=t&&typeof t.hint=="string"&&t.hint.trim()||"",n=t&&typeof t.authorizedKeys=="string"&&t.authorizedKeys.trim()||"";if(n){const s=e.indexOf(n);return{note:s>=0?e.slice(0,s).replace(/[:\s]+$/,""):e,line:n}}if(!e)return null;const i=e.indexOf(E2);return i<0?{note:e,line:""}:{note:e.slice(0,i).replace(/[:\s]+$/,""),line:e.slice(i).trim()}}function Eu(t,e,n=globalThis.localStorage){if(!(t!=null&&t.outbox)||t.outbox.count<1)return!1;const i=Number(n.getItem(s0(e))||0);return t.outbox.latest>i}function bm(t,e={}){const n=t||{};if(!n.tmux){const i=`${n.engine||""}${n.key?`·${n.key}`:""}`,s=[i,n.model&&n.model!==i?n.model:""].filter(Boolean).join(" · ");return{working:!1,subtitle:String(s||m("cell-off")).trim()}}if(e.working===!0){const i=m("cell-working"),s=String(e.status||"").trim();return{working:!0,subtitle:!s||/^working(?:\.{3}|…)?$/i.test(s)?i:`${i} · ${s}`}}return e.working===!1?{working:!1,subtitle:m("cell-idle")}:{working:!1,subtitle:String(e.preview||n.preview||m("cell-on")).trim()}}function D0(t,e){return[...new Set([t.engine,t.model,t.key,e.preview,t.preview,e.status].filter(Boolean).map(String))].join(" ")}function Sm(t,e,n,i=globalThis.localStorage){return[...(Array.isArray(t)?t:[]).map(s=>{const a=n.get(s.tmuxSession)||{},l=Cl([],s.tmuxSession),d=bm(s,a);return{type:"cell",value:s,key:l,label:s.cell,live:!!s.tmux,fresh:Eu(a,l,i),activity:a.activity||0,working:d.working,subtitle:d.subtitle,searchText:D0(s,a)}}),...(Array.isArray(e)?e:[]).map(s=>{const a=Cl([],s.name);return{type:"session",value:s,key:a,label:s.name,live:!0,technical:s.technical===!0,fresh:Eu(s,a,i),activity:s.activity||0,searchText:`${s.preview||""} ${s.cmd||""}`}})]}function Nu(t,e=globalThis.localStorage){const n=t||{},i=Array.isArray(n.route)?n.route:[],s=new Map((n.sessions||[]).map(l=>[l.name,l])),a=[...(n.cells||[]).map(l=>{const d=s.get(l.tmuxSession)||{},h=Cl(i,l.tmuxSession||l.cell),f=bm(l,d);return{type:"cell",value:l,key:h,label:l.cell,live:!!l.tmux&&!l.preserved,fresh:Eu(d,h,e),activity:d.activity||l.activity||0,working:f.working,subtitle:f.subtitle,searchText:D0(l,d)}}),...(n.unmanaged||[]).map(l=>{const d=Cl(i,l.name);return{type:"session",value:l,key:d,label:l.name,live:!0,technical:l.technical===!0,fresh:Eu(l,d,e),activity:l.activity||0,searchText:`${l.preview||""} ${l.cmd||""}`}})];return{route:i,rawItems:a}}const xm=9,Lu=.2,L2=/^[a-z0-9-]{1,32}(?:\/[a-z0-9-]{1,32}){0,3}$/,ra=/^[a-f0-9]{16,64}$/,Jf=t=>L2.test(t)&&new Set(t.split("/")).size===t.split("/").length;function Mr(t){if(typeof t=="string"&&t){const e=t.indexOf(":");if(e<0)return{session:t};const n=t.slice(0,e),i=t.slice(e+1);return!Jf(n)||!i?null:{session:i,node:n}}if(t&&typeof t=="object"&&typeof t.session=="string"&&t.session){const e=t.ownerId===void 0?void 0:typeof t.ownerId=="string"&&ra.test(t.ownerId)?t.ownerId:null;return e===null?null:t.node===void 0||t.node===null||t.node===""?{session:t.session,...e?{ownerId:e}:{}}:typeof t.node=="string"&&Jf(t.node)?{session:t.session,node:t.node,...e?{ownerId:e}:{}}:null}return null}function ji(t){const e=Mr(t);return e?e.node?`${e.node}:${e.session}`:e.session:""}const I0=9,B0=24,jl=11,R2=t=>{const e=Number(t);return e>=I0&&e<=B0?e:jl};function ta(){return{columns:[]}}function Ss(t){return t.columns.flatMap(e=>e.tiles.map(n=>ji(n)))}function M2(t){const e=[],n=Math.max(0,...t.columns.map(i=>i.tiles.length));for(let i=0;i<n;i+=1)for(const s of t.columns)s.tiles[i]&&e.push(ji(s.tiles[i]));return e}const da=t=>({columns:t.columns.map(e=>({width:e.width,tiles:e.tiles.map(n=>({...n}))}))});function Cm(t,e,n,i){const s=Mr(e);if(!s||Ss(t).includes(ji(s))||Ss(t).length>=xm)return t;const a=da(t),l={session:s.session,height:1,fontSize:jl,...i||{}};if(s.node&&(l.node=s.node),s.ownerId&&(l.ownerId=s.ownerId),n==="end")return a.columns.push({width:1,tiles:[l]}),a;if(n&&typeof n.col=="number"&&typeof n.row=="number"&&a.columns[n.col])return a.columns[n.col].tiles.splice(n.row,0,l),a;if(n&&typeof n.col=="number"){const d=Math.max(0,Math.min(a.columns.length,n.col));return a.columns.splice(d,0,{width:1,tiles:[l]}),a}return a.columns.push({width:1,tiles:[l]}),a}function O0(t,e){const n=ji(e);if(!n||Ss(t).includes(n)||Ss(t).length>=xm)return t;const i=Ss(t).length+1,s=Math.ceil(Math.sqrt(i));if(t.columns.length>=s){let g=0;for(let y=1;y<t.columns.length;y+=1)t.columns[y].tiles.length<t.columns[g].tiles.length&&(g=y);return Cm(t,e,{col:g,row:t.columns[g].tiles.length})}const a=[...M2(t),n],l=new Map(t.columns.flatMap(g=>g.tiles.map(y=>[ji(y),y]))),d=Mr(e),h=t.columns.length?t.columns.reduce((g,y)=>g+(Number(y.width)||1),0)/t.columns.length:1,f=Array.from({length:s},(g,y)=>{var _;return{width:((_=t.columns[y])==null?void 0:_.width)||h,tiles:[]}});return a.forEach((g,y)=>{const _=Mr(g);if(!_)return;const w=l.get(g)||(g===n?d:{})||{},b={session:_.session,height:w.height||1,fontSize:w.fontSize||jl};_.node&&(b.node=_.node),w.ownerId&&(b.ownerId=w.ownerId),w.unavailable===!0&&(b.unavailable=!0),f[y%s].tiles.push(b)}),{columns:f.filter(g=>g.tiles.length)}}function Ru(t,e){const n=ji(e),i=da(t);for(const s of i.columns)s.tiles=s.tiles.filter(a=>ji(a)!==n);return i.columns=i.columns.filter(s=>s.tiles.length>0),i}function A2(t,e,n){const i=ji(e);if(!Ss(t).includes(i))return t;const s=t.columns.flatMap(a=>a.tiles).find(a=>ji(a)===i);return Cm(Ru(t,i),i,n,{fontSize:s.fontSize,height:s.height,...s.ownerId?{ownerId:s.ownerId}:{},...s.unavailable===!0?{unavailable:!0}:{}})}function j2(t,e){if(!(e instanceof Map)||e.size===0)return t;let n=!1;const i=da(t);for(const s of i.columns)for(const a of s.tiles){const l=e.get(ji(a));if(!l)continue;const d=Mr(l);d&&(a.session=d.session,d.node?a.node=d.node:delete a.node,d.ownerId&&(a.ownerId=d.ownerId),n=!0)}return n?so(i):t}function P2(t,e,n){const i=da(t);return i.columns[e]&&(i.columns[e].width=Math.max(Lu,Number(n)||1)),i}function T2(t,e,n,i){const s=da(t),a=s.columns[e]&&s.columns[e].tiles[n];return a&&(a.height=Math.max(Lu,Number(i)||1)),s}function D2(t,e,n,i){if(!(t.columns[e]&&t.columns[e].tiles[n]))return t;const a=da(t),l=a.columns[e].tiles[n],d=Number(l.fontSize)||jl;return l.fontSize=Math.max(I0,Math.min(B0,d+(Number(i)||0))),a}function I2(t,e,n,i){const s=t.columns[e];if(!s||!s.tiles[n])return null;switch(i){case"left":return{col:e};case"right":return{col:e+1};case"top":return{col:e,row:n};case"bottom":return{col:e,row:n+1};default:return null}}function ny(t){for(const e of[.25,.5,.75])if(Math.abs(t-e)<=.03)return e;return t}function so(t){if(!t||!Array.isArray(t.columns))return ta();const e=t.columns.map(i=>({width:Math.max(Lu,Number(i&&i.width)||1),tiles:(Array.isArray(i&&i.tiles)?i.tiles:[]).filter(s=>s&&typeof s.session=="string"&&s.session).filter(s=>s.node==null||typeof s.node=="string"&&Jf(s.node)).filter(s=>s.ownerId==null||typeof s.ownerId=="string"&&ra.test(s.ownerId)).map(s=>{const a={session:s.session,height:Math.max(Lu,Number(s.height)||1),fontSize:R2(s.fontSize)};return s.node!=null&&(a.node=s.node),s.ownerId!=null&&(a.ownerId=s.ownerId),s.unavailable===!0&&(a.unavailable=!0),a})})).filter(i=>i.tiles.length>0),n=new Set;for(const i of e)i.tiles=i.tiles.filter(s=>!n.has(ji(s))&&n.add(ji(s))&&n.size<=xm);return{columns:e.filter(i=>i.tiles.length>0)}}const $0=/^[a-z0-9-]{1,32}$/,B2=/^[A-Za-z0-9._-]{1,32}$/,O2=/^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/,$2=320;function Zf(t){return typeof t=="string"&&$0.test(t)}const z2=64;function oa(t){if(typeof t!="string")return!1;const e=t.trim();return e.length>0&&e.length<=z2&&!/[\x00-\x1f\x7f]/.test(e)}function Lr(t){return String(t??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32).replace(/-+$/g,"")||"node"}function z0(t){if(typeof t!="string"||!t||t.length>$2||t.startsWith("-")||/[\0-\x20\x7f]/.test(t))return!1;if(!t.includes("@"))return/^[A-Za-z0-9][A-Za-z0-9._:-]{0,254}$/.test(t);const e=t.indexOf("@");return e<=0||e!==t.lastIndexOf("@")?!1:B2.test(t.slice(0,e))&&O2.test(t.slice(e+1))}function iy(t){if(t===""||t===null||t===void 0)return null;const e=String(t).trim();if(!/^[0-9]{1,5}$/.test(e))return;const n=Number(e);return Number.isInteger(n)&&n>=1&&n<=65535?n:void 0}function F2({name:t,ssh:e,sshPort:n,remotePort:i}={}){const s=typeof t=="string"?t.trim():t,a=typeof e=="string"?e.trim():e;if(!Zf(s))return{ok:!1,error:"err-node-name"};if(!z0(a))return{ok:!1,error:"err-ssh"};const l=iy(n);if(l===void 0)return{ok:!1,error:"err-ssh-port"};const d=iy(i);if(d===void 0)return{ok:!1,error:"err-node-port"};const h={name:s,ssh:a};return l!==null&&(h.sshPort=l),d!==null&&(h.remotePort=d),{ok:!0,value:h}}function H2(t,e){if(!t||!e||e<t)return null;const n=Math.floor((e-t)/1e3);return n<60?"ora":n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}g`}function ep(t,e){const n=!!(t&&t.status==="up"),i=!!(t&&t.status==="passive");return{up:n,...i?{passive:!0}:{},label:n?"tunnel-up":i?"node-passive":"tunnel-down",since:n?H2(t.since,e):null}}const U2=new Set(["v","instanceId","port","label","invite"]),W2=new Set(["v","instanceId","port","label","invite","name","ssh","sshPort"]);function q2(t){const e=String(t).replace(/-/g,"+").replace(/_/g,"/"),n=e+"=".repeat((4-e.length%4)%4),i=typeof atob=="function"?atob(n):Buffer.from(n,"base64").toString("binary"),s=Uint8Array.from(i,a=>a.charCodeAt(0));return typeof TextDecoder<"u"?new TextDecoder().decode(s):Buffer.from(s).toString("utf8")}function K2(t){let e="";try{const l=new URL(String(t));e=new URLSearchParams(l.hash.replace(/^#/,"")).get("pair")||""}catch{return{ok:!1}}if(!e)return{ok:!1};let n;try{n=JSON.parse(q2(e))}catch{return{ok:!1}}if(!n||typeof n!="object"||Array.isArray(n))return{ok:!1};const i=n.v===1?U2:n.v===2?W2:null;if(!i)return{ok:!1};for(const l of Object.keys(n))if(!i.has(l))return{ok:!1};if(!/^[a-f0-9]{16,64}$/.test(String(n.instanceId)))return{ok:!1};const s=Number(n.port);if(!Number.isInteger(s)||s<1||s>65535)return{ok:!1};if(typeof n.label!="string")return{ok:!1};if(typeof n.invite!="string"||!n.invite)return{ok:!1};const a={ok:!0,version:n.v,label:n.label,invite:n.invite,instanceId:n.instanceId,port:s};if(n.v===2){if(n.name!==void 0){if(typeof n.name!="string"||!$0.test(n.name))return{ok:!1};a.name=n.name}if(n.ssh!==void 0){if(!z0(n.ssh))return{ok:!1};a.ssh=String(n.ssh).trim()}if(n.sshPort!==void 0){const l=Number(n.sshPort);if(!Number.isInteger(l)||l<1||l>65535)return{ok:!1};a.sshPort=l}}return a}function V2(t,e,n=new Set){if(!e||!e.ok)return t;const i={...t},s=(a,l)=>{l==null||l===""||n.has(a)||(i[a]=l)};return s("label",e.label),e.version===2&&(s("name",e.name||(e.ssh?Lr(e.label):"")),s("ssh",e.ssh),e.sshPort!==void 0&&s("sshPort",String(e.sshPort))),i}const Y2=["KIMI_AUTH_ACTION_REQUIRED","CLIENT_INTERACTION_REQUIRED"],G2=["kimi-code-consent-yes","kimi-code-config-custom-api-key","kimi-cli-login","client-terminal-dialog"];function km(t){const e=t&&typeof t=="object"?t.actionRequired:null;return e&&typeof e=="object"&&Y2.includes(e.code)&&G2.includes(e.recovery)?{code:e.code,recovery:e.recovery,text:m(`fleet-recovery-${e.recovery}`)}:t&&typeof t=="object"&&t.vlPromptDegraded===!0?{code:"VL_PROMPT_DEGRADED",recovery:null,text:m("fleet-vl-prompt-degraded")}:t&&typeof t=="object"&&t.readinessDegraded===!0?{code:"READINESS_DEGRADED",recovery:null,text:m("fleet-readiness-degraded")}:null}let tp={sessions:[],cells:[],nodeGroups:[],localNodeId:"",localFresh:!1,refreshedAt:0};function sy(){return tp}function F0(t={}){return tp={sessions:Array.isArray(t.sessions)?t.sessions:[],cells:Array.isArray(t.cells)?t.cells:[],nodeGroups:Array.isArray(t.nodeGroups)?t.nodeGroups:[],localNodeId:typeof t.localNodeId=="string"?t.localNodeId:"",localFresh:t.localFresh===!0,refreshedAt:Number.isFinite(t.refreshedAt)?t.refreshedAt:0},tp}const Fo=(t,e=[])=>`${e.length?e.join("/"):"local"}:${t}`;function X2({onPick:t,token:e,onSettings:n,onOpenVlSession:i,hostByRoute:s={},onDesignateCell:a,onClearHostCell:l}){const[d,h]=li(),f=_m(e),[g,y]=k.useState(null),[_,w]=k.useState(null),[b,N]=k.useState(""),[x,E]=k.useState(""),[C,I]=k.useState({bind:"127.0.0.1",port:""}),[T,W]=k.useState(""),[U,Q]=k.useState([]),[ee,q]=k.useState([]),[J,$]=k.useState(!1),[M,L]=k.useState(null),[j,O]=k.useState({}),[P,A]=k.useState(new Set),[R,D]=k.useState(null),[H,z]=k.useState(null),{pins:F,orders:K,togglePin:ne,removePin:re,pinError:Y,retryPinPersist:de,clearPinError:oe,viewFor:pe,updateView:xe,canMoveRoster:Qe,moveRoster:ot,stepRoster:De}=wm(),je=Z=>s[ea(Z)]||{},{groupsFor:tt,moveNode:Nt,stepNode:Ct,nodeKey:ft}=j0(),ht=tt(f);k.useEffect(()=>{F0({sessions:g||[],cells:U,nodeGroups:f,localNodeId:T})},[g,U,f,T]),k.useEffect(()=>{const Z=new Map;for(const ye of U)Z.set(Fo(ye.cell),!!ye.boot);for(const ye of f){const Ue=ye.route||[ye.name];for(const We of ye.cells||[])Z.set(Fo(We.cell,Ue),!!We.boot)}O(ye=>{let Ue=!1;const We={...ye};for(const[Ge,jt]of Object.entries(ye))Z.has(Ge)&&Z.get(Ge)===jt&&(delete We[Ge],Ue=!0);return Ue?We:ye})},[U,f]);async function kt(){try{const Ge=await(await pn("/api/sessions",e)).json();Ge.error?(w(Ge.error),y([])):(w(null),y(Ge.sessions||[]))}catch(We){w(String(We)),y([])}let Z=null,ye=null;try{Z=await Ar(e)}catch(We){ye=We}const Ue=vm({fs:Z,error:ye});Ue.kind==="data"?(Q(Ue.cells),q(Ue.capabilities),$(!1),L(null)):Ue.kind==="stale"?($(!0),L(null)):(Q([]),q([]),$(!1),L(Ue.reason||""))}k.useEffect(()=>{kt(),pn("/api/config",e).then(ye=>ye.json()).then(ye=>{E(ye.version||""),I({bind:ye.bind||"127.0.0.1",port:ye.port||""}),W(ra.test(String(ye.instanceId||""))?ye.instanceId:"")}).catch(()=>{});const Z=setInterval(kt,4e3);return()=>clearInterval(Z)},[]);async function St(){if(!C.port)return;const Z=`http://${C.bind}:${C.port}/#token=${e}`;try{await navigator.clipboard.writeText(Z)}catch{}}function Ut(Z,ye,Ue){const We=Fo(Z,ye);O(Ge=>({...Ge,[We]:!!Ue}))}function Mt(Z,ye=[]){const Ue=Fo(Z.cell,ye);return Object.prototype.hasOwnProperty.call(j,Ue)?j[Ue]:!!Z.boot}async function It(Z,ye,Ue=[]){Z.stopPropagation();const We=Fo(ye.cell,Ue),Ge=!Mt(ye,Ue);Ut(ye.cell,Ue,Ge),A(jt=>new Set(jt).add(We));try{await r0(e,{cell:ye.cell,enabled:Ge},Ue),Ue.length||Q(jt=>jt.map(Pt=>Pt.cell===ye.cell?{...Pt,boot:Ge}:Pt))}catch(jt){O(Pt=>{const X={...Pt};return delete X[We],X}),w(String((jt==null?void 0:jt.message)||jt))}finally{A(jt=>{const Pt=new Set(jt);return Pt.delete(We),Pt})}}async function tn(Z){if(!R)return;const{cell:ye}=R,Ue=Array.isArray(R.route)?R.route:[];if(Z.action==="up"){const We=await cm(e,{cell:ye,boot:!!Z.boot,...Z.engine?{engine:Z.engine}:{},...Z.model!==void 0?{model:Z.model}:{},...Z.permissionPolicy?{permissionPolicy:Z.permissionPolicy}:{}},Ue),Ge=km(We);Ge&&w(Ge.text),Ut(ye,Ue,!!Z.boot)}else await wu(e,{cell:ye,boot:!!Z.boot},Ue),Z.boot&&Ut(ye,Ue,!1);kt()}async function Ft(Z,ye=[]){try{await um(e,Z,ye)}catch{return}kt()}async function ln(Z,ye,Ue=[]){try{await l0(e,Z,ye,Ue)}catch{return}kt()}async function V(Z){if(!(!(Z!=null&&Z.direct)||H)){z(Z.name);try{await pm(e,Z.name,Z.tunnelStatus==="up"?"down":"up")}catch{}z(null)}}async function Te(Z){if(!(Z!=null&&Z.direct))return;const ye=window.prompt(m("rename-node-prompt"),Z.label||Z.name);if(ye===null)return;const Ue=String(ye).trim();if(!oa(Ue)){window.alert(m("rename-node-invalid"));return}try{await h0(e,Z.name,Ue)}catch(We){window.alert(String((We==null?void 0:We.message)||We))}}const gt=k.useMemo(()=>new Map((g||[]).map(Z=>[Z.name,Z])),[g]),le=k.useMemo(()=>new Set(U.map(Z=>Z.tmuxSession)),[U]),ae=k.useMemo(()=>(g||[]).filter(Z=>!le.has(Z.name)),[g,le]),ge=k.useMemo(()=>Sm(U,ae,gt),[U,ae,gt]),Ce=pe("local"),Me=k.useMemo(()=>Nr(ge,F,Ce.filter,Vs(K,"local")).filter(Z=>q_(Z,b)),[ge,F,Ce.filter,b,K]),nt=ht.reduce((Z,ye)=>Z+(ye.cells||[]).length+(ye.unmanaged||[]).filter(Ue=>!Ue.technical).length,0),ct=Nr(ge,F,"all",Vs(K,"local")).length+nt,pt=ge.filter(Z=>Z.live).length+ht.reduce((Z,ye)=>Z+Nu(ye).rawItems.filter(Ue=>Ue.live).length,0),Lt=(g||[]).filter(Z=>Z.attached).length+ht.reduce((Z,ye)=>Z+(ye.sessions||[]).filter(Ue=>Ue.attached).length,0),Dt=Math.min(Lt,pt),Et=C.port?`${C.bind}:${C.port}`:C.bind;function Bt(Z,ye=null,Ue=ge){var Ke,Ie;const We=Array.isArray(ye==null?void 0:ye.route)?ye.route:[],Ge=We.join("/"),jt=Ge||"local",Pt=We.length?ye==null?void 0:ye.instanceId:T,X=(Ee,et)=>t({session:Ee,...Ge?{node:Ge}:{},...ra.test(String(Pt||""))?{ownerId:Pt}:{},...typeof et=="string"&&et?{cellName:et}:{}}),ie=Qe;if(Z.type==="cell"){const Ee=Z.value,et=je(We),Ot=Su({hostCell:et.hostCell??null,threadStatus:et.threadStatus,pins:F,item:Z}),gn=We.length?((ye==null?void 0:ye.sessions)||[]).find(st=>st.name===Ee.tmuxSession):gt.get(Ee.tmuxSession),Fe=Vf(Ot,et.hostLease??null),Be=Ee.degraded?m("cell-degraded"):Z.working?Z.subtitle:Ee.tmux?m("cell-idle"):m("cell-off"),vt=Fe?`${Be} · ${m(Fe)}`:Be,Mn=We.length===0||((ye==null?void 0:ye.capabilities)||[]).includes(Ee.active?"down":"up"),me=We.length===0?ee.includes("boot"):((ye==null?void 0:ye.capabilities)||[]).includes("boot"),Se=Mt(Ee,We),Ae=Fo(Ee.cell,We),it=`${m(Se?"boot-disable":"boot-enable")} ${Ee.cell}`;return c.jsxs("div",{className:"nc-mcard","data-roster-key":Z.key,"data-position":jt,children:[c.jsx(ys,{position:jt,itemKey:Z.key,label:Ee.cell,canMove:ie,onMove:(st,wt)=>ot(jt,st,wt,Ue),onStep:st=>De(jt,Z.key,st,Ue)}),c.jsxs("button",{className:"nc-mcard-main",onClick:()=>Ee.tmux&&X(Ee.tmuxSession,Ee.cell),title:vt,"aria-label":`${Ee.cell}, ${vt}`,children:[c.jsx("span",{className:`dot ${Ee.degraded?"warn":Ee.tmux?`on${Z.working?" working":""}`:""}`}),c.jsxs("span",{className:"nc-mcard-text",children:[c.jsx("b",{children:Ee.cell}),c.jsx("small",{title:Z.subtitle,children:Z.subtitle})]})]}),Z.activity?c.jsx("span",{className:"nc-rel",children:sa(Z.activity)}):null,Z.fresh&&((Ke=gn==null?void 0:gn.outbox)==null?void 0:Ke.count)>0&&c.jsx("span",{className:"nc-badge",title:m("new-files-outbox"),children:gn.outbox.count}),c.jsx(xu,{item:Z,pins:F,hostByRoute:s,route:We,cellName:Ee.cell,baseClassName:"nc-act pin",togglePin:ne,removePin:re,designate:a,clearHost:l}),me&&c.jsx("button",{className:`nc-act boot${Se?" on":""}`,disabled:P.has(Ae),onClick:st=>It(st,Ee,We),title:it,"aria-label":it,children:c.jsx(dt,{name:"boot",size:16})}),Mn&&c.jsx("button",{className:`nc-act power${Ee.tmux?" on":""}${Ee.degraded?" warn":""}`,onClick:()=>D(We.length?{...Ee,boot:Se,route:We,availableEngines:(ye==null?void 0:ye.engines)||[]}:{...Ee,boot:Se}),title:Ee.active?m("power-off"):m("power-on"),"aria-label":`${Ee.active?m("power-off"):m("power-on")} ${Ee.cell}`,children:c.jsx(dt,{name:"power",size:16})})]},Z.key)}const _e=Z.value;return c.jsxs("div",{className:"nc-mcard","data-roster-key":Z.key,"data-position":jt,children:[c.jsx(ys,{position:jt,itemKey:Z.key,label:_e.name,canMove:ie,onMove:(Ee,et)=>ot(jt,Ee,et,Ue),onStep:Ee=>De(jt,Z.key,Ee,Ue)}),c.jsxs("button",{className:"nc-mcard-main",onClick:()=>X(_e.name),children:[c.jsx("span",{className:_e.attached?"dot on":"dot"}),c.jsxs("span",{className:"nc-mcard-text",children:[c.jsx("b",{children:_e.name}),c.jsx("small",{children:_e.preview?_e.preview:_e.cmd?_e.cmd:m("windows").replace("{n}",String(_e.windows||0))})]})]}),Z.activity?c.jsx("span",{className:"nc-rel",children:sa(Z.activity)}):null,Z.fresh&&((Ie=_e.outbox)==null?void 0:Ie.count)>0&&c.jsx("span",{className:"nc-badge",title:m("new-files-outbox"),children:_e.outbox.count}),c.jsx("button",{className:`nc-act pin${F.includes(Z.key)?" on":""}`,"aria-label":`${m("pin")} ${_e.name}`,title:m("pin"),onClick:()=>ne(Z.key),children:F.includes(Z.key)?"★":"☆"}),c.jsx("button",{className:`nc-act technical${_e.technical?" on":""}`,title:_e.technical?m("mark-normal"):m("mark-technical"),"aria-label":`${_e.technical?m("mark-normal"):m("mark-technical")} ${_e.name}`,onClick:()=>ln(_e.name,!_e.technical,We),children:"T"}),c.jsx("button",{className:"nc-menu",title:m("terminate"),"aria-label":`${m("terminate")} ${_e.name}`,onClick:()=>{window.confirm(m("terminate-confirm").replace("{name}",_e.name))&&Ft(_e.name,We)},children:"⋯"})]},Z.key)}return c.jsxs("div",{className:"nc-home",children:[c.jsxs("header",{className:"nc-home-head",children:[c.jsxs("div",{className:"nc-wordmark",children:["NexusCrew",c.jsx("span",{className:"nc-cursor"})]}),c.jsxs("div",{className:"nc-home-sub",children:[m("fleet-tmux")," · ",pt," ",m("sessions"),Dt>0&&` · ${Dt} attached`]}),c.jsxs("span",{className:"nc-head-actions",children:[c.jsx("button",{className:"nc-refresh",onClick:()=>n("nodes",!1),title:m("settings"),children:c.jsx(dt,{name:"gear",size:18})}),c.jsx("button",{className:"nc-refresh",onClick:kt,title:m("refresh"),children:c.jsx(dt,{name:"refresh",size:18})})]})]}),c.jsxs("main",{className:"nc-home-scroll",children:[c.jsx(P0,{pinError:Y,onRetry:de,onDismiss:oe}),ct>8&&c.jsx("input",{className:"nc-filter",type:"search",placeholder:m("filter-placeholder"),"aria-label":m("filter-placeholder"),value:b,onChange:Z=>N(Z.target.value)}),_&&c.jsx("div",{className:"nc-err",children:_}),J&&c.jsx("div",{className:"nc-set-hint nc-fleet-stale",role:"status",children:m("fleet-stale")}),M!==null&&c.jsxs("div",{className:"nc-set-hint nc-fleet-off",role:"status",children:[m("fleet-off"),M?` (${M})`:""]}),c.jsxs("section",{className:"nc-group","data-position":"local",children:[c.jsx(Oh,{label:m("position-local"),count:Me.length,state:Ce,dotClass:"on",onToggle:()=>xe("local",{open:!Ce.open}),onFilter:Z=>xe("local",{filter:Z})}),Ce.open&&Me.map(Z=>Bt(Z,null,ge)),Ce.open&&g===null&&c.jsx("div",{className:"nc-empty",children:m("loading-fleet")}),Ce.open&&g!==null&&Me.length===0&&!_&&c.jsx("div",{className:"nc-empty",children:b?m("no-match").replace("{q}",b):m("no-sessions-short")})]}),ht.map(Z=>{const ye=T0(Z.health,{passive:"warn"}),Ue=Z.fleetState==="stale"?m("fleet-stale"):Z.fleetState==="disabled"?m("fleet-off"):"",We=Z.fleetState==="stale"?"warn":ye||(Z.status==="up"?"on":Z.status==="passive"?"":"warn"),Ge=[Z.health?ku(Z.health):Z.status==="up"?"":Ws(Z),Ue].filter(Boolean).join(" · "),Pt=(Z.route&&Z.route.length?Z.route:[Z.name]).join("/"),X=pe(Pt);if(Z.kind==="vl")return c.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":Pt,"data-node-order-key":ft(Z),children:[c.jsx(Oh,{label:Z.label||Z.name,count:Z.sessions.length,state:X,dotClass:We,dotTitle:Ge,detail:Z.status==="up"?"":Ws(Z),onToggle:()=>xe(Pt,{open:!X.open}),onFilter:Ee=>xe(Pt,{filter:Ee})}),Z.status==="up"&&X.open&&Z.sessions.map(Ee=>c.jsx("div",{className:"nc-mcard nc-vl-session-row",children:c.jsxs("button",{className:"nc-mcard-main",onClick:()=>i&&i(Z.peer),"aria-label":`${Z.label||Z.name}: ${Ee.name}`,children:[c.jsx("span",{className:"dot on"}),c.jsxs("span",{className:"nc-mcard-text",children:[c.jsx("b",{children:Ee.name}),c.jsx("small",{children:m("vl-events-title")})]})]})},Ee.key)),Z.status==="up"&&X.open&&Z.sessions.length===0&&c.jsx("div",{className:"nc-empty",children:m("no-sessions-short")})]},`nodo-vl-${Pt}-${Z.name}`);const{rawItems:ie}=Nu(Z),_e=Nr(ie,F,X.filter,Vs(K,Pt)).filter(Ee=>q_(Ee,b)),Ke=Z.direct&&Z.health&&Z.health.managed!==!1?c.jsx("button",{type:"button",className:`nc-act power${Z.tunnelStatus==="up"?" on":""}`,disabled:H===Z.name,title:Z.tunnelStatus==="up"?m("power-off"):m("power-on"),"aria-label":`${Z.tunnelStatus==="up"?m("power-off"):m("power-on")} ${Z.label||Z.name}`,onClick:()=>V(Z),children:c.jsx(dt,{name:"power",size:15})}):null,Ie=c.jsxs("span",{className:"nc-node-actions",children:[c.jsx(ys,{scope:"node",position:"nodes",itemKey:ft(Z),label:Z.label||Z.name,onMove:(Ee,et)=>Nt(Ee,et,f),onStep:Ee=>Ct(ft(Z),Ee,f)}),Z.direct&&c.jsx("button",{type:"button",className:"nc-node-rename",title:m("rename-node"),"aria-label":`${m("rename-node")} ${Z.label||Z.name}`,onClick:()=>Te(Z),children:"✎"}),Ke]});return c.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":Pt,"data-node-order-key":ft(Z),children:[c.jsx(Oh,{label:Z.label||Z.name,count:_e.length,state:X,dotClass:We,dotTitle:Ge,detail:Z.status==="up"?Ue:Z.health&&ku(Z.health)||Ws(Z),onToggle:()=>xe(Pt,{open:!X.open}),onFilter:Ee=>xe(Pt,{filter:Ee}),onRename:Z.direct?()=>Te(Z):null,action:Ie}),Z.status==="up"&&X.open&&_e.map(Ee=>Bt(Ee,Z,ie)),Z.status==="up"&&X.open&&_e.length===0&&c.jsx("div",{className:"nc-empty",children:b?m("no-match").replace("{q}",b):m("no-sessions-short")})]},`nodo-${Pt}`)}),c.jsxs("footer",{className:"nc-home-foot",onClick:St,title:m("copy-url"),children:[c.jsxs("span",{className:"nc-home-meta",children:[x&&c.jsxs("span",{className:"nc-home-version",children:["v",x]}),c.jsxs("span",{className:"nc-home-endpoint",children:[Et," · ",m("ssh-only")]})]}),c.jsx("span",{className:"nc-lang",onClick:Z=>Z.stopPropagation(),children:m0.map((Z,ye)=>c.jsxs("span",{children:[ye>0&&" · ",c.jsx("button",{className:`nc-lang-btn${d===Z?" on":""}`,onClick:()=>h(Z),title:Z,children:Z.toUpperCase()})]},Z))})]})]}),c.jsx("button",{className:"nc-fab",onClick:()=>n("fleet",!0),title:m("fleet-new-cell"),"aria-label":m("fleet-new-cell"),children:"+"}),R&&c.jsx(Cu,{cell:R,token:e,route:Array.isArray(R.route)?R.route:[],onConfirm:tn,onClose:()=>D(null)})]})}function Oh({label:t,count:e,state:n,dotClass:i="",dotTitle:s="",detail:a="",onToggle:l,onFilter:d,onRename:h=null,action:f=null}){return c.jsxs("div",{className:"nc-mobile-position-head",onContextMenu:h?g=>{g.preventDefault(),h()}:void 0,children:[c.jsxs("button",{type:"button",className:"nc-mobile-position-toggle",onClick:l,"aria-expanded":n.open,"aria-label":`${t} · ${m("node-sessions").replace("{n}",String(e))}`,children:[c.jsx("span",{className:"nc-mobile-chevron","aria-hidden":"true",children:n.open?"⌄":"›"}),c.jsx("span",{className:`dot ${i}`,title:s}),c.jsxs("span",{className:"nc-mobile-position-copy",children:[c.jsx("b",{children:t}),c.jsx("small",{children:a||m("node-sessions").replace("{n}",String(e))})]})]}),c.jsxs("select",{className:"nc-mobile-position-filter",value:n.filter,"aria-label":`${t} · ${m("filter-placeholder")}`,title:m(`view-${n.filter}`),onChange:g=>d(g.target.value),children:[c.jsx("option",{value:"all",children:m("view-all")}),c.jsx("option",{value:"pinned",children:m("view-pinned")}),c.jsx("option",{value:"active",children:m("view-active")}),c.jsx("option",{value:"off",children:m("view-off")}),c.jsx("option",{value:"technical",children:m("view-technical")})]}),f]})}/**
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 H0=Object.defineProperty,Q2=Object.getOwnPropertyDescriptor,J2=(t,e)=>{for(var n in e)H0(t,n,{get:e[n],enumerable:!0})},mn=(t,e,n,i)=>{for(var s=i>1?void 0:i?Q2(e,n):e,a=t.length-1,l;a>=0;a--)(l=t[a])&&(s=(i?l(e,n,s):l(s))||s);return i&&s&&H0(e,n,s),s},ze=(t,e)=>(n,i)=>e(n,i,t),ry="Terminal input",np={get:()=>ry,set:t=>ry=t},oy="Too much output to announce, navigate to rows manually to read",ip={get:()=>oy,set:t=>oy=t};function Z2(t){return t.replace(/\r?\n/g,"\r")}function e5(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function t5(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function n5(t,e,n,i){if(t.stopPropagation(),t.clipboardData){let s=t.clipboardData.getData("text/plain");U0(s,e,n,i)}}function U0(t,e,n,i){t=Z2(t),t=e5(t,n.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(t,!0),e.value=""}function W0(t,e,n){let i=n.getBoundingClientRect(),s=t.clientX-i.left-10,a=t.clientY-i.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${s}px`,e.style.top=`${a}px`,e.style.zIndex="1000",e.focus()}function ay(t,e,n,i,s){W0(t,e,n),s&&i.rightClickSelect(t),e.value=i.selectionText,e.select()}function Cr(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function Ku(t,e=0,n=t.length){let i="";for(let s=e;s<n;++s){let a=t[s];a>65535?(a-=65536,i+=String.fromCharCode((a>>10)+55296)+String.fromCharCode(a%1024+56320)):i+=String.fromCharCode(a)}return i}var i5=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,n){let i=e.length;if(!i)return 0;let s=0,a=0;if(this._interim){let l=e.charCodeAt(a++);56320<=l&&l<=57343?n[s++]=(this._interim-55296)*1024+l-56320+65536:(n[s++]=this._interim,n[s++]=l),this._interim=0}for(let l=a;l<i;++l){let d=e.charCodeAt(l);if(55296<=d&&d<=56319){if(++l>=i)return this._interim=d,s;let h=e.charCodeAt(l);56320<=h&&h<=57343?n[s++]=(d-55296)*1024+h-56320+65536:(n[s++]=d,n[s++]=h);continue}d!==65279&&(n[s++]=d)}return s}},s5=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,n){let i=e.length;if(!i)return 0;let s=0,a,l,d,h,f=0,g=0;if(this.interim[0]){let w=!1,b=this.interim[0];b&=(b&224)===192?31:(b&240)===224?15:7;let N=0,x;for(;(x=this.interim[++N]&63)&&N<4;)b<<=6,b|=x;let E=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,C=E-N;for(;g<C;){if(g>=i)return 0;if(x=e[g++],(x&192)!==128){g--,w=!0;break}else this.interim[N++]=x,b<<=6,b|=x&63}w||(E===2?b<128?g--:n[s++]=b:E===3?b<2048||b>=55296&&b<=57343||b===65279||(n[s++]=b):b<65536||b>1114111||(n[s++]=b)),this.interim.fill(0)}let y=i-4,_=g;for(;_<i;){for(;_<y&&!((a=e[_])&128)&&!((l=e[_+1])&128)&&!((d=e[_+2])&128)&&!((h=e[_+3])&128);)n[s++]=a,n[s++]=l,n[s++]=d,n[s++]=h,_+=4;if(a=e[_++],a<128)n[s++]=a;else if((a&224)===192){if(_>=i)return this.interim[0]=a,s;if(l=e[_++],(l&192)!==128){_--;continue}if(f=(a&31)<<6|l&63,f<128){_--;continue}n[s++]=f}else if((a&240)===224){if(_>=i)return this.interim[0]=a,s;if(l=e[_++],(l&192)!==128){_--;continue}if(_>=i)return this.interim[0]=a,this.interim[1]=l,s;if(d=e[_++],(d&192)!==128){_--;continue}if(f=(a&15)<<12|(l&63)<<6|d&63,f<2048||f>=55296&&f<=57343||f===65279)continue;n[s++]=f}else if((a&248)===240){if(_>=i)return this.interim[0]=a,s;if(l=e[_++],(l&192)!==128){_--;continue}if(_>=i)return this.interim[0]=a,this.interim[1]=l,s;if(d=e[_++],(d&192)!==128){_--;continue}if(_>=i)return this.interim[0]=a,this.interim[1]=l,this.interim[2]=d,s;if(h=e[_++],(h&192)!==128){_--;continue}if(f=(a&7)<<18|(l&63)<<12|(d&63)<<6|h&63,f<65536||f>1114111)continue;n[s++]=f}}return s}},q0="",Er=" ",Pl=class K0{constructor(){this.fg=0,this.bg=0,this.extended=new Mu}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new K0;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Mu=class V0{constructor(e=0,n=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new V0(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Yi=class Y0 extends Pl{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Mu,this.combinedData=""}static fromCharData(e){let n=new Y0;return n.setFromCharData(e),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Cr(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let n=!1;if(e[1].length>2)n=!0;else if(e[1].length===2){let i=e[1].charCodeAt(0);if(55296<=i&&i<=56319){let s=e[1].charCodeAt(1);56320<=s&&s<=57343?this.content=(i-55296)*1024+s-56320+65536|e[2]<<22:n=!0}else n=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;n&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ly="di$target",sp="di$dependencies",$h=new Map;function r5(t){return t[sp]||[]}function Hn(t){if($h.has(t))return $h.get(t);let e=function(n,i,s){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");o5(e,n,s)};return e._id=t,$h.set(t,e),e}function o5(t,e,n){e[ly]===e?e[sp].push({id:t,index:n}):(e[sp]=[{id:t,index:n}],e[ly]=e)}var ci=Hn("BufferService"),G0=Hn("CoreMouseService"),fo=Hn("CoreService"),a5=Hn("CharsetService"),Em=Hn("InstantiationService"),X0=Hn("LogService"),ui=Hn("OptionsService"),Q0=Hn("OscLinkService"),l5=Hn("UnicodeService"),Tl=Hn("DecorationService"),rp=class{constructor(e,n,i){this._bufferService=e,this._optionsService=n,this._oscLinkService=i}provideLinks(e,n){var y;let i=this._bufferService.buffer.lines.get(e-1);if(!i){n(void 0);return}let s=[],a=this._optionsService.rawOptions.linkHandler,l=new Yi,d=i.getTrimmedLength(),h=-1,f=-1,g=!1;for(let _=0;_<d;_++)if(!(f===-1&&!i.hasContent(_))){if(i.loadCell(_,l),l.hasExtendedAttrs()&&l.extended.urlId)if(f===-1){f=_,h=l.extended.urlId;continue}else g=l.extended.urlId!==h;else f!==-1&&(g=!0);if(g||f!==-1&&_===d-1){let w=(y=this._oscLinkService.getLinkData(h))==null?void 0:y.uri;if(w){let b={start:{x:f+1,y:e},end:{x:_+(!g&&_===d-1?1:0),y:e}},N=!1;if(!(a!=null&&a.allowNonHttpProtocols))try{let x=new URL(w);["http:","https:"].includes(x.protocol)||(N=!0)}catch{N=!0}N||s.push({text:w,range:b,activate:(x,E)=>a?a.activate(x,E,b):c5(x,E),hover:(x,E)=>{var C;return(C=a==null?void 0:a.hover)==null?void 0:C.call(a,x,E,b)},leave:(x,E)=>{var C;return(C=a==null?void 0:a.leave)==null?void 0:C.call(a,x,E,b)}})}g=!1,l.hasExtendedAttrs()&&l.extended.urlId?(f=_,h=l.extended.urlId):(f=-1,h=-1)}}n(s)}};rp=mn([ze(0,ci),ze(1,ui),ze(2,Q0)],rp);function c5(t,e){if(confirm(`Do you want to navigate to ${e}?
52
-
53
- WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}}var Vu=Hn("CharSizeService"),Ys=Hn("CoreBrowserService"),Nm=Hn("MouseService"),Gs=Hn("RenderService"),u5=Hn("SelectionService"),J0=Hn("CharacterJoinerService"),ha=Hn("ThemeService"),Z0=Hn("LinkProviderService"),d5=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?cy.isErrorNoTelemetry(e)?new cy(e.message+`
54
-
55
- `+e.stack):new Error(e.message+`
56
-
57
- `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(n=>{n(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},h5=new d5;function uu(t){f5(t)||h5.onUnexpectedError(t)}var op="Canceled";function f5(t){return t instanceof p5?!0:t instanceof Error&&t.name===op&&t.message===op}var p5=class extends Error{constructor(){super(op),this.name=this.message}};function m5(t){return new Error(`Illegal argument: ${t}`)}var cy=class ap extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof ap)return e;let n=new ap;return n.message=e.message,n.stack=e.stack,n}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},lp=class eS extends Error{constructor(e){super(e||"An unexpected bug occurred."),Object.setPrototypeOf(this,eS.prototype)}};function Mi(t,e=0){return t[t.length-(1+e)]}var g5;(t=>{function e(a){return a<0}t.isLessThan=e;function n(a){return a<=0}t.isLessThanOrEqual=n;function i(a){return a>0}t.isGreaterThan=i;function s(a){return a===0}t.isNeitherLessOrGreaterThan=s,t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(g5||(g5={}));function v5(t,e){let n=this,i=!1,s;return function(){return i||(i=!0,e||(s=t.apply(n,arguments))),s}}var tS;(t=>{function e(T){return T&&typeof T=="object"&&typeof T[Symbol.iterator]=="function"}t.is=e;let n=Object.freeze([]);function i(){return n}t.empty=i;function*s(T){yield T}t.single=s;function a(T){return e(T)?T:s(T)}t.wrap=a;function l(T){return T||n}t.from=l;function*d(T){for(let W=T.length-1;W>=0;W--)yield T[W]}t.reverse=d;function h(T){return!T||T[Symbol.iterator]().next().done===!0}t.isEmpty=h;function f(T){return T[Symbol.iterator]().next().value}t.first=f;function g(T,W){let U=0;for(let Q of T)if(W(Q,U++))return!0;return!1}t.some=g;function y(T,W){for(let U of T)if(W(U))return U}t.find=y;function*_(T,W){for(let U of T)W(U)&&(yield U)}t.filter=_;function*w(T,W){let U=0;for(let Q of T)yield W(Q,U++)}t.map=w;function*b(T,W){let U=0;for(let Q of T)yield*W(Q,U++)}t.flatMap=b;function*N(...T){for(let W of T)yield*W}t.concat=N;function x(T,W,U){let Q=U;for(let ee of T)Q=W(Q,ee);return Q}t.reduce=x;function*E(T,W,U=T.length){for(W<0&&(W+=T.length),U<0?U+=T.length:U>T.length&&(U=T.length);W<U;W++)yield T[W]}t.slice=E;function C(T,W=Number.POSITIVE_INFINITY){let U=[];if(W===0)return[U,T];let Q=T[Symbol.iterator]();for(let ee=0;ee<W;ee++){let q=Q.next();if(q.done)return[U,t.empty()];U.push(q.value)}return[U,{[Symbol.iterator](){return Q}}]}t.consume=C;async function I(T){let W=[];for await(let U of T)W.push(U);return Promise.resolve(W)}t.asyncToArray=I})(tS||(tS={}));function co(t){if(tS.is(t)){let e=[];for(let n of t)if(n)try{n.dispose()}catch(i){e.push(i)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}else if(t)return t.dispose(),t}function _5(...t){return en(()=>co(t))}function en(t){return{dispose:v5(()=>{t()})}}var nS=class iS{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{co(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?iS.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(e),e}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),void 0)}};nS.DISABLE_DISPOSED_WARNING=!1;var Rr=nS,yt=class{constructor(){this._store=new Rr,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)}};yt.None=Object.freeze({dispose(){}});var aa=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var n;this._isDisposed||e===this._value||((n=this._value)==null||n.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},qs=typeof window=="object"?window:globalThis,cp=class up{constructor(e){this.element=e,this.next=up.Undefined,this.prev=up.Undefined}};cp.Undefined=new cp(void 0);var rn=cp,uy=class{constructor(){this._first=rn.Undefined,this._last=rn.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===rn.Undefined}clear(){let e=this._first;for(;e!==rn.Undefined;){let n=e.next;e.prev=rn.Undefined,e.next=rn.Undefined,e=n}this._first=rn.Undefined,this._last=rn.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,n){let i=new rn(e);if(this._first===rn.Undefined)this._first=i,this._last=i;else if(n){let a=this._last;this._last=i,i.prev=a,a.next=i}else{let a=this._first;this._first=i,i.next=a,a.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==rn.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==rn.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==rn.Undefined&&e.next!==rn.Undefined){let n=e.prev;n.next=e.next,e.next.prev=n}else e.prev===rn.Undefined&&e.next===rn.Undefined?(this._first=rn.Undefined,this._last=rn.Undefined):e.next===rn.Undefined?(this._last=this._last.prev,this._last.next=rn.Undefined):e.prev===rn.Undefined&&(this._first=this._first.next,this._first.prev=rn.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==rn.Undefined;)yield e.element,e=e.next}},y5=globalThis.performance&&typeof globalThis.performance.now=="function",w5=class sS{static create(e){return new sS(e)}constructor(e){this._now=y5&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Yn;(t=>{t.None=()=>yt.None;function e(M,L){return y(M,()=>{},0,void 0,!0,void 0,L)}t.defer=e;function n(M){return(L,j=null,O)=>{let P=!1,A;return A=M(R=>{if(!P)return A?A.dispose():P=!0,L.call(j,R)},null,O),P&&A.dispose(),A}}t.once=n;function i(M,L,j){return f((O,P=null,A)=>M(R=>O.call(P,L(R)),null,A),j)}t.map=i;function s(M,L,j){return f((O,P=null,A)=>M(R=>{L(R),O.call(P,R)},null,A),j)}t.forEach=s;function a(M,L,j){return f((O,P=null,A)=>M(R=>L(R)&&O.call(P,R),null,A),j)}t.filter=a;function l(M){return M}t.signal=l;function d(...M){return(L,j=null,O)=>{let P=_5(...M.map(A=>A(R=>L.call(j,R))));return g(P,O)}}t.any=d;function h(M,L,j,O){let P=j;return i(M,A=>(P=L(P,A),P),O)}t.reduce=h;function f(M,L){let j,O={onWillAddFirstListener(){j=M(P.fire,P)},onDidRemoveLastListener(){j==null||j.dispose()}},P=new Le(O);return L==null||L.add(P),P.event}function g(M,L){return L instanceof Array?L.push(M):L&&L.add(M),M}function y(M,L,j=100,O=!1,P=!1,A,R){let D,H,z,F=0,K,ne={leakWarningThreshold:A,onWillAddFirstListener(){D=M(Y=>{F++,H=L(H,Y),O&&!z&&(re.fire(H),H=void 0),K=()=>{let de=H;H=void 0,z=void 0,(!O||F>1)&&re.fire(de),F=0},typeof j=="number"?(clearTimeout(z),z=setTimeout(K,j)):z===void 0&&(z=0,queueMicrotask(K))})},onWillRemoveListener(){P&&F>0&&(K==null||K())},onDidRemoveLastListener(){K=void 0,D.dispose()}},re=new Le(ne);return R==null||R.add(re),re.event}t.debounce=y;function _(M,L=0,j){return t.debounce(M,(O,P)=>O?(O.push(P),O):[P],L,void 0,!0,void 0,j)}t.accumulate=_;function w(M,L=(O,P)=>O===P,j){let O=!0,P;return a(M,A=>{let R=O||!L(A,P);return O=!1,P=A,R},j)}t.latch=w;function b(M,L,j){return[t.filter(M,L,j),t.filter(M,O=>!L(O),j)]}t.split=b;function N(M,L=!1,j=[],O){let P=j.slice(),A=M(H=>{P?P.push(H):D.fire(H)});O&&O.add(A);let R=()=>{P==null||P.forEach(H=>D.fire(H)),P=null},D=new Le({onWillAddFirstListener(){A||(A=M(H=>D.fire(H)),O&&O.add(A))},onDidAddFirstListener(){P&&(L?setTimeout(R):R())},onDidRemoveLastListener(){A&&A.dispose(),A=null}});return O&&O.add(D),D.event}t.buffer=N;function x(M,L){return(j,O,P)=>{let A=L(new C);return M(function(R){let D=A.evaluate(R);D!==E&&j.call(O,D)},void 0,P)}}t.chain=x;let E=Symbol("HaltChainable");class C{constructor(){this.steps=[]}map(L){return this.steps.push(L),this}forEach(L){return this.steps.push(j=>(L(j),j)),this}filter(L){return this.steps.push(j=>L(j)?j:E),this}reduce(L,j){let O=j;return this.steps.push(P=>(O=L(O,P),O)),this}latch(L=(j,O)=>j===O){let j=!0,O;return this.steps.push(P=>{let A=j||!L(P,O);return j=!1,O=P,A?P:E}),this}evaluate(L){for(let j of this.steps)if(L=j(L),L===E)break;return L}}function I(M,L,j=O=>O){let O=(...D)=>R.fire(j(...D)),P=()=>M.on(L,O),A=()=>M.removeListener(L,O),R=new Le({onWillAddFirstListener:P,onDidRemoveLastListener:A});return R.event}t.fromNodeEventEmitter=I;function T(M,L,j=O=>O){let O=(...D)=>R.fire(j(...D)),P=()=>M.addEventListener(L,O),A=()=>M.removeEventListener(L,O),R=new Le({onWillAddFirstListener:P,onDidRemoveLastListener:A});return R.event}t.fromDOMEventEmitter=T;function W(M){return new Promise(L=>n(M)(L))}t.toPromise=W;function U(M){let L=new Le;return M.then(j=>{L.fire(j)},()=>{L.fire(void 0)}).finally(()=>{L.dispose()}),L.event}t.fromPromise=U;function Q(M,L){return M(j=>L.fire(j))}t.forward=Q;function ee(M,L,j){return L(j),M(O=>L(O))}t.runAndSubscribe=ee;class q{constructor(L,j){this._observable=L,this._counter=0,this._hasChanged=!1;let O={onWillAddFirstListener:()=>{L.addObserver(this)},onDidRemoveLastListener:()=>{L.removeObserver(this)}};this.emitter=new Le(O),j&&j.add(this.emitter)}beginUpdate(L){this._counter++}handlePossibleChange(L){}handleChange(L,j){this._hasChanged=!0}endUpdate(L){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function J(M,L){return new q(M,L).emitter.event}t.fromObservable=J;function $(M){return(L,j,O)=>{let P=0,A=!1,R={beginUpdate(){P++},endUpdate(){P--,P===0&&(M.reportChanges(),A&&(A=!1,L.call(j)))},handlePossibleChange(){},handleChange(){A=!0}};M.addObserver(R),M.reportChanges();let D={dispose(){M.removeObserver(R)}};return O instanceof Rr?O.add(D):Array.isArray(O)&&O.push(D),D}}t.fromObservableLight=$})(Yn||(Yn={}));var dp=class hp{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${hp._idPool++}`,hp.all.add(this)}start(e){this._stopWatch=new w5,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};dp.all=new Set,dp._idPool=0;var b5=dp,S5=-1,rS=class oS{constructor(e,n,i=(oS._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=n,this.name=i,this._warnCountdown=0}dispose(){var e;(e=this._stacks)==null||e.clear()}check(e,n){let i=this.threshold;if(i<=0||n<i)return;this._stacks||(this._stacks=new Map);let s=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,s+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=i*.5;let[a,l]=this.getMostFrequentStack(),d=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${l}):`;console.warn(d),console.warn(a);let h=new k5(d,a);this._errorHandler(h)}return()=>{let a=this._stacks.get(e.value)||0;this._stacks.set(e.value,a-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,n=0;for(let[i,s]of this._stacks)(!e||n<s)&&(e=[i,s],n=s);return e}};rS._idPool=1;var x5=rS,C5=class aS{constructor(e){this.value=e}static create(){let e=new Error;return new aS(e.stack??"")}print(){console.warn(this.value.split(`
58
- `).slice(2).join(`
59
- `))}},k5=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},E5=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},N5=0,zh=class{constructor(e){this.value=e,this.id=N5++}},L5=2,R5,Le=class{constructor(t){var e,n,i,s;this._size=0,this._options=t,this._leakageMon=(e=this._options)!=null&&e.leakWarningThreshold?new x5((t==null?void 0:t.onListenerError)??uu,((n=this._options)==null?void 0:n.leakWarningThreshold)??S5):void 0,this._perfMon=(i=this._options)!=null&&i._profName?new b5(this._options._profName):void 0,this._deliveryQueue=(s=this._options)==null?void 0:s.deliveryQueue}dispose(){var t,e,n,i;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(n=(e=this._options)==null?void 0:e.onDidRemoveLastListener)==null||n.call(e),(i=this._leakageMon)==null||i.dispose())}get event(){return this._event??(this._event=(t,e,n)=>{var l,d,h,f,g;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let y=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(y);let _=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],w=new E5(`${y}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((l=this._options)==null?void 0:l.onListenerError)||uu)(w),yt.None}if(this._disposed)return yt.None;e&&(t=t.bind(e));let i=new zh(t),s;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(i.stack=C5.create(),s=this._leakageMon.check(i.stack,this._size+1)),this._listeners?this._listeners instanceof zh?(this._deliveryQueue??(this._deliveryQueue=new M5),this._listeners=[this._listeners,i]):this._listeners.push(i):((h=(d=this._options)==null?void 0:d.onWillAddFirstListener)==null||h.call(d,this),this._listeners=i,(g=(f=this._options)==null?void 0:f.onDidAddFirstListener)==null||g.call(f,this)),this._size++;let a=en(()=>{s==null||s(),this._removeListener(i)});return n instanceof Rr?n.add(a):Array.isArray(n)&&n.push(a),a}),this._event}_removeListener(t){var s,a,l,d;if((a=(s=this._options)==null?void 0:s.onWillRemoveListener)==null||a.call(s,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(d=(l=this._options)==null?void 0:l.onDidRemoveLastListener)==null||d.call(l,this),this._size=0;return}let e=this._listeners,n=e.indexOf(t);if(n===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,e[n]=void 0;let i=this._deliveryQueue.current===this;if(this._size*L5<=e.length){let h=0;for(let f=0;f<e.length;f++)e[f]?e[h++]=e[f]:i&&(this._deliveryQueue.end--,h<this._deliveryQueue.i&&this._deliveryQueue.i--);e.length=h}}_deliver(t,e){var i;if(!t)return;let n=((i=this._options)==null?void 0:i.onListenerError)||uu;if(!n){t.value(e);return}try{t.value(e)}catch(s){n(s)}}_deliverQueue(t){let e=t.current._listeners;for(;t.i<t.end;)this._deliver(e[t.i++],t.value);t.reset()}fire(t){var e,n,i,s;if((e=this._deliveryQueue)!=null&&e.current&&(this._deliverQueue(this._deliveryQueue),(n=this._perfMon)==null||n.stop()),(i=this._perfMon)==null||i.start(this._size),this._listeners)if(this._listeners instanceof zh)this._deliver(this._listeners,t);else{let a=this._deliveryQueue;a.enqueue(this,t,this._listeners.length),this._deliverQueue(a)}(s=this._perfMon)==null||s.stop()}hasListeners(){return this._size>0}},M5=class{constructor(){this.i=-1,this.end=0}enqueue(e,n,i){this.i=0,this.end=i,this.current=e,this.value=n}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},fp=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Le,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Le,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,n){if(this.getZoomLevel(n)===e)return;let i=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(i,e),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),e)}setFullscreen(e,n){if(this.isFullscreen(n)===e)return;let i=this.getWindowId(n);this.mapWindowIdToFullScreen.set(i,e),this._onDidChangeFullscreen.fire(i)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};fp.INSTANCE=new fp;var Lm=fp;function A5(t,e,n){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",n)}Lm.INSTANCE.onDidChangeZoomLevel;function j5(t){return Lm.INSTANCE.getZoomFactor(t)}Lm.INSTANCE.onDidChangeFullscreen;var fa=typeof navigator=="object"?navigator.userAgent:"",pp=fa.indexOf("Firefox")>=0,P5=fa.indexOf("AppleWebKit")>=0,Rm=fa.indexOf("Chrome")>=0,T5=!Rm&&fa.indexOf("Safari")>=0;fa.indexOf("Electron/")>=0;fa.indexOf("Android")>=0;var Fh=!1;if(typeof qs.matchMedia=="function"){let t=qs.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=qs.matchMedia("(display-mode: fullscreen)");Fh=t.matches,A5(qs,t,({matches:n})=>{Fh&&e.matches||(Fh=n)})}var Qo="en",mp=!1,gp=!1,du=!1,lS=!1,Kc,hu=Qo,dy=Qo,D5,is,ro=globalThis,Kn,Jb;typeof ro.vscode<"u"&&typeof ro.vscode.process<"u"?Kn=ro.vscode.process:typeof process<"u"&&typeof((Jb=process==null?void 0:process.versions)==null?void 0:Jb.node)=="string"&&(Kn=process);var Zb,I5=typeof((Zb=Kn==null?void 0:Kn.versions)==null?void 0:Zb.electron)=="string",B5=I5&&(Kn==null?void 0:Kn.type)==="renderer",e0;if(typeof Kn=="object"){mp=Kn.platform==="win32",gp=Kn.platform==="darwin",du=Kn.platform==="linux",du&&Kn.env.SNAP&&Kn.env.SNAP_REVISION,Kn.env.CI||Kn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Kc=Qo,hu=Qo;let t=Kn.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);Kc=e.userLocale,dy=e.osLocale,hu=e.resolvedLanguage||Qo,D5=(e0=e.languagePack)==null?void 0:e0.translationsConfigFile}catch{}lS=!0}else typeof navigator=="object"&&!B5?(is=navigator.userAgent,mp=is.indexOf("Windows")>=0,gp=is.indexOf("Macintosh")>=0,(is.indexOf("Macintosh")>=0||is.indexOf("iPad")>=0||is.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,du=is.indexOf("Linux")>=0,(is==null?void 0:is.indexOf("Mobi"))>=0,hu=globalThis._VSCODE_NLS_LANGUAGE||Qo,Kc=navigator.language.toLowerCase(),dy=Kc):console.error("Unable to resolve platform.");var cS=mp,xs=gp,O5=du,hy=lS,ks=is,gr=hu,$5;(t=>{function e(){return gr}t.value=e;function n(){return gr.length===2?gr==="en":gr.length>=3?gr[0]==="e"&&gr[1]==="n"&&gr[2]==="-":!1}t.isDefaultVariant=n;function i(){return gr==="en"}t.isDefault=i})($5||($5={}));var z5=typeof ro.postMessage=="function"&&!ro.importScripts;(()=>{if(z5){let t=[];ro.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let i=0,s=t.length;i<s;i++){let a=t[i];if(a.id===n.data.vscodeScheduleAsyncWork){t.splice(i,1),a.callback();return}}});let e=0;return n=>{let i=++e;t.push({id:i,callback:n}),ro.postMessage({vscodeScheduleAsyncWork:i},"*")}}return t=>setTimeout(t)})();var F5=!!(ks&&ks.indexOf("Chrome")>=0);ks&&ks.indexOf("Firefox")>=0;!F5&&ks&&ks.indexOf("Safari")>=0;ks&&ks.indexOf("Edg/")>=0;ks&&ks.indexOf("Android")>=0;var Ho=typeof navigator=="object"?navigator:{};hy||document.queryCommandSupported&&document.queryCommandSupported("copy")||Ho&&Ho.clipboard&&Ho.clipboard.writeText,hy||Ho&&Ho.clipboard&&Ho.clipboard.readText;var Mm=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,n){this._keyCodeToStr[e]=n,this._strToKeyCode[n.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Hh=new Mm,fy=new Mm,py=new Mm,H5=new Array(230),uS;(t=>{function e(d){return Hh.keyCodeToStr(d)}t.toString=e;function n(d){return Hh.strToKeyCode(d)}t.fromString=n;function i(d){return fy.keyCodeToStr(d)}t.toUserSettingsUS=i;function s(d){return py.keyCodeToStr(d)}t.toUserSettingsGeneral=s;function a(d){return fy.strToKeyCode(d)||py.strToKeyCode(d)}t.fromUserSettings=a;function l(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 Hh.keyCodeToStr(d)}t.toElectronAccelerator=l})(uS||(uS={}));var U5=class dS{constructor(e,n,i,s,a){this.ctrlKey=e,this.shiftKey=n,this.altKey=i,this.metaKey=s,this.keyCode=a}equals(e){return e instanceof dS&&this.ctrlKey===e.ctrlKey&&this.shiftKey===e.shiftKey&&this.altKey===e.altKey&&this.metaKey===e.metaKey&&this.keyCode===e.keyCode}getHashCode(){let e=this.ctrlKey?"1":"0",n=this.shiftKey?"1":"0",i=this.altKey?"1":"0",s=this.metaKey?"1":"0";return`K${e}${n}${i}${s}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new W5([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},W5=class{constructor(t){if(t.length===0)throw m5("chords");this.chords=t}getHashCode(){let t="";for(let e=0,n=this.chords.length;e<n;e++)e!==0&&(t+=";"),t+=this.chords[e].getHashCode();return t}equals(t){if(t===null||this.chords.length!==t.chords.length)return!1;for(let e=0;e<this.chords.length;e++)if(!this.chords[e].equals(t.chords[e]))return!1;return!0}};function q5(t){if(t.charCode){let n=String.fromCharCode(t.charCode).toUpperCase();return uS.fromString(n)}let e=t.keyCode;if(e===3)return 7;if(pp)switch(e){case 59:return 85;case 60:if(O5)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(xs)return 57;break}else if(P5&&(xs&&e===93||!xs&&e===92))return 57;return H5[e]||0}var K5=xs?256:2048,V5=512,Y5=1024,G5=xs?2048:256,my=class{constructor(t){var n;this._standardKeyboardEventBrand=!0;let e=t;this.browserEvent=e,this.target=e.target,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,this.altGraphKey=(n=e.getModifierState)==null?void 0:n.call(e,"AltGraph"),this.keyCode=q5(e),this.code=e.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(t){return this._asKeybinding===t}_computeKeybinding(){let t=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode);let e=0;return this.ctrlKey&&(e|=K5),this.altKey&&(e|=V5),this.shiftKey&&(e|=Y5),this.metaKey&&(e|=G5),e|=t,e}_computeKeyCodeChord(){let t=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode),new U5(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,t)}},gy=new WeakMap;function X5(t){if(!t.parent||t.parent===t)return null;try{let e=t.location,n=t.parent.location;if(e.origin!=="null"&&n.origin!=="null"&&e.origin!==n.origin)return null}catch{return null}return t.parent}var Q5=class{static getSameOriginWindowChain(t){let e=gy.get(t);if(!e){e=[],gy.set(t,e);let n=t,i;do i=X5(n),i?e.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):e.push({window:new WeakRef(n),iframeElement:null}),n=i;while(n)}return e.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(t,e){if(!e||t===e)return{top:0,left:0};let n=0,i=0,s=this.getSameOriginWindowChain(t);for(let a of s){let l=a.window.deref();if(n+=(l==null?void 0:l.scrollY)??0,i+=(l==null?void 0:l.scrollX)??0,l===e||!a.iframeElement)break;let d=a.iframeElement.getBoundingClientRect();n+=d.top,i+=d.left}return{top:n,left:i}}},Vc=class{constructor(e,n){this.timestamp=Date.now(),this.browserEvent=n,this.leftButton=n.button===0,this.middleButton=n.button===1,this.rightButton=n.button===2,this.buttons=n.buttons,this.target=n.target,this.detail=n.detail||1,n.type==="dblclick"&&(this.detail=2),this.ctrlKey=n.ctrlKey,this.shiftKey=n.shiftKey,this.altKey=n.altKey,this.metaKey=n.metaKey,typeof n.pageX=="number"?(this.posx=n.pageX,this.posy=n.pageY):(this.posx=n.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=n.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let i=Q5.getPositionOfChildWindowRelativeToAncestorWindow(e,n.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},vy=class{constructor(e,n=0,i=0){var a;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,this.deltaX=n;let s=!1;if(Rm){let l=navigator.userAgent.match(/Chrome\/(\d+)/);s=(l?parseInt(l[1]):123)<=122}if(e){let l=e,d=e,h=((a=e.view)==null?void 0:a.devicePixelRatio)||1;if(typeof l.wheelDeltaY<"u")s?this.deltaY=l.wheelDeltaY/(120*h):this.deltaY=l.wheelDeltaY/120;else if(typeof d.VERTICAL_AXIS<"u"&&d.axis===d.VERTICAL_AXIS)this.deltaY=-d.detail/3;else if(e.type==="wheel"){let f=e;f.deltaMode===f.DOM_DELTA_LINE?pp&&!xs?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof l.wheelDeltaX<"u")T5&&cS?this.deltaX=-(l.wheelDeltaX/120):s?this.deltaX=l.wheelDeltaX/(120*h):this.deltaX=l.wheelDeltaX/120;else if(typeof d.HORIZONTAL_AXIS<"u"&&d.axis===d.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let f=e;f.deltaMode===f.DOM_DELTA_LINE?pp&&!xs?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*h):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},hS=Object.freeze(function(t,e){let n=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(n)}}}),J5;(t=>{function e(n){return n===t.None||n===t.Cancelled||n instanceof Z5?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Yn.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:hS})})(J5||(J5={}));var Z5=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?hS:(this._emitter||(this._emitter=new Le),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Am=class{constructor(e,n){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof n=="number"&&this.setIfNotSet(e,n)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,n){if(this._isDisposed)throw new lp("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},n)}setIfNotSet(e,n){if(this._isDisposed)throw new lp("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},n))}},eE=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,n,i=globalThis){if(this.isDisposed)throw new lp("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},n);this.disposable=en(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},tE;(t=>{async function e(i){let s,a=await Promise.all(i.map(l=>l.then(d=>d,d=>{s||(s=d)})));if(typeof s<"u")throw s;return a}t.settled=e;function n(i){return new Promise(async(s,a)=>{try{await i(s,a)}catch(l){a(l)}})}t.withAsyncBody=n})(tE||(tE={}));var _y=class Ui{static fromArray(e){return new Ui(n=>{n.emitMany(e)})}static fromPromise(e){return new Ui(async n=>{n.emitMany(await e)})}static fromPromises(e){return new Ui(async n=>{await Promise.all(e.map(async i=>n.emitOne(await i)))})}static merge(e){return new Ui(async n=>{await Promise.all(e.map(async i=>{for await(let s of i)n.emitOne(s)}))})}constructor(e,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new Le,queueMicrotask(async()=>{let i={emitOne:s=>this.emitOne(s),emitMany:s=>this.emitMany(s),reject:s=>this.reject(s)};try{await Promise.resolve(e(i)),this.resolve()}catch(s){this.reject(s)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await Yn.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var n;return(n=this._onReturn)==null||n.call(this),{done:!0,value:void 0}}}}static map(e,n){return new Ui(async i=>{for await(let s of e)i.emitOne(n(s))})}map(e){return Ui.map(this,e)}static filter(e,n){return new Ui(async i=>{for await(let s of e)n(s)&&i.emitOne(s)})}filter(e){return Ui.filter(this,e)}static coalesce(e){return Ui.filter(e,n=>!!n)}coalesce(){return Ui.coalesce(this)}static async toPromise(e){let n=[];for await(let i of e)n.push(i);return n}toPromise(){return Ui.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};_y.EMPTY=_y.fromArray([]);var{getWindow:bs,getWindowId:nE,onDidRegisterWindow:iE}=(function(){let t=new Map,e={window:qs,disposables:new Rr};t.set(qs.vscodeWindowId,e);let n=new Le,i=new Le,s=new Le;function a(l,d){return(typeof l=="number"?t.get(l):void 0)??(d?e:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:s.event,onDidUnregisterWindow:i.event,registerWindow(l){if(t.has(l.vscodeWindowId))return yt.None;let d=new Rr,h={window:l,disposables:d.add(new Rr)};return t.set(l.vscodeWindowId,h),d.add(en(()=>{t.delete(l.vscodeWindowId),i.fire(l)})),d.add(lt(l,Dn.BEFORE_UNLOAD,()=>{s.fire(l)})),n.fire(h),d},getWindows(){return t.values()},getWindowsCount(){return t.size},getWindowId(l){return l.vscodeWindowId},hasWindow(l){return t.has(l)},getWindowById:a,getWindow(l){var f;let d=l;if((f=d==null?void 0:d.ownerDocument)!=null&&f.defaultView)return d.ownerDocument.defaultView.window;let h=l;return h!=null&&h.view?h.view.window:qs},getDocument(l){return bs(l).document}}})(),sE=class{constructor(e,n,i,s){this._node=e,this._type=n,this._handler=i,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 lt(t,e,n,i){return new sE(t,e,n,i)}var yy=function(t,e,n,i){return lt(t,e,n,i)},jm,rE=class extends eE{constructor(t){super(),this.defaultTarget=t&&bs(t)}cancelAndSet(t,e,n){return super.cancelAndSet(t,e,n??this.defaultTarget)}},wy=class{constructor(e,n=0){this._runner=e,this.priority=n,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){uu(e)}}static sort(e,n){return n.priority-e.priority}};(function(){let t=new Map,e=new Map,n=new Map,i=new Map,s=a=>{n.set(a,!1);let l=t.get(a)??[];for(e.set(a,l),t.set(a,[]),i.set(a,!0);l.length>0;)l.sort(wy.sort),l.shift().execute();i.set(a,!1)};jm=(a,l,d=0)=>{let h=nE(a),f=new wy(l,d),g=t.get(h);return g||(g=[],t.set(h,g)),g.push(f),n.get(h)||(n.set(h,!0),a.requestAnimationFrame(()=>s(h))),f}})();function oE(t){let e=t.getBoundingClientRect(),n=bs(t);return{left:e.left+n.scrollX,top:e.top+n.scrollY,width:e.width,height:e.height}}var Dn={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"},aE=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let n=bi(e);this._maxWidth!==n&&(this._maxWidth=n,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let n=bi(e);this._width!==n&&(this._width=n,this.domNode.style.width=this._width)}setHeight(e){let n=bi(e);this._height!==n&&(this._height=n,this.domNode.style.height=this._height)}setTop(e){let n=bi(e);this._top!==n&&(this._top=n,this.domNode.style.top=this._top)}setLeft(e){let n=bi(e);this._left!==n&&(this._left=n,this.domNode.style.left=this._left)}setBottom(e){let n=bi(e);this._bottom!==n&&(this._bottom=n,this.domNode.style.bottom=this._bottom)}setRight(e){let n=bi(e);this._right!==n&&(this._right=n,this.domNode.style.right=this._right)}setPaddingTop(e){let n=bi(e);this._paddingTop!==n&&(this._paddingTop=n,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let n=bi(e);this._paddingLeft!==n&&(this._paddingLeft=n,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let n=bi(e);this._paddingBottom!==n&&(this._paddingBottom=n,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let n=bi(e);this._paddingRight!==n&&(this._paddingRight=n,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let n=bi(e);this._fontSize!==n&&(this._fontSize=n,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let n=bi(e);this._lineHeight!==n&&(this._lineHeight=n,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let n=bi(e);this._letterSpacing!==n&&(this._letterSpacing=n,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,n){this.domNode.classList.toggle(e,n),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,n){this.domNode.setAttribute(e,n)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function bi(t){return typeof t=="number"?`${t}px`:t}function bl(t){return new aE(t)}var fS=class{constructor(){this._hooks=new Rr,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,n){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(n)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,n,i,s,a){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=a;let l=e;try{e.setPointerCapture(n),this._hooks.add(en(()=>{try{e.releasePointerCapture(n)}catch{}}))}catch{l=bs(e)}this._hooks.add(lt(l,Dn.POINTER_MOVE,d=>{if(d.buttons!==i){this.stopMonitoring(!0);return}d.preventDefault(),this._pointerMoveCallback(d)})),this._hooks.add(lt(l,Dn.POINTER_UP,d=>this.stopMonitoring(!0)))}};function lE(t,e,n){let i=null,s=null;if(typeof n.value=="function"?(i="value",s=n.value,s.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(i="get",s=n.get),!s)throw new Error("not supported");let a=`$memoize$${e}`;n[i]=function(...l){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:s.apply(this,l)}),this[a]}}var vs;(t=>(t.Tap="-xterm-gesturetap",t.Change="-xterm-gesturechange",t.Start="-xterm-gesturestart",t.End="-xterm-gesturesend",t.Contextmenu="-xterm-gesturecontextmenu"))(vs||(vs={}));var pl=class ti extends yt{constructor(){super(),this.dispatched=!1,this.targets=new uy,this.ignoreTargets=new uy,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Yn.runAndSubscribe(iE,({window:e,disposables:n})=>{n.add(lt(e.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),n.add(lt(e.document,"touchend",i=>this.onTouchEnd(e,i))),n.add(lt(e.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:qs,disposables:this._store}))}static addTarget(e){if(!ti.isTouchDevice())return yt.None;ti.INSTANCE||(ti.INSTANCE=new ti);let n=ti.INSTANCE.targets.push(e);return en(n)}static ignoreTarget(e){if(!ti.isTouchDevice())return yt.None;ti.INSTANCE||(ti.INSTANCE=new ti);let n=ti.INSTANCE.ignoreTargets.push(e);return en(n)}static isTouchDevice(){return"ontouchstart"in qs||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let i=0,s=e.targetTouches.length;i<s;i++){let a=e.targetTouches.item(i);this.activeTouches[a.identifier]={id:a.identifier,initialTarget:a.target,initialTimeStamp:n,initialPageX:a.pageX,initialPageY:a.pageY,rollingTimestamps:[n],rollingPageX:[a.pageX],rollingPageY:[a.pageY]};let l=this.newGestureEvent(vs.Start,a.target);l.pageX=a.pageX,l.pageY=a.pageY,this.dispatchEvent(l)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(e,n){let i=Date.now(),s=Object.keys(this.activeTouches).length;for(let a=0,l=n.changedTouches.length;a<l;a++){let d=n.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(d.identifier))){console.warn("move of an UNKNOWN touch",d);continue}let h=this.activeTouches[d.identifier],f=Date.now()-h.initialTimeStamp;if(f<ti.HOLD_DELAY&&Math.abs(h.initialPageX-Mi(h.rollingPageX))<30&&Math.abs(h.initialPageY-Mi(h.rollingPageY))<30){let g=this.newGestureEvent(vs.Tap,h.initialTarget);g.pageX=Mi(h.rollingPageX),g.pageY=Mi(h.rollingPageY),this.dispatchEvent(g)}else if(f>=ti.HOLD_DELAY&&Math.abs(h.initialPageX-Mi(h.rollingPageX))<30&&Math.abs(h.initialPageY-Mi(h.rollingPageY))<30){let g=this.newGestureEvent(vs.Contextmenu,h.initialTarget);g.pageX=Mi(h.rollingPageX),g.pageY=Mi(h.rollingPageY),this.dispatchEvent(g)}else if(s===1){let g=Mi(h.rollingPageX),y=Mi(h.rollingPageY),_=Mi(h.rollingTimestamps)-h.rollingTimestamps[0],w=g-h.rollingPageX[0],b=y-h.rollingPageY[0],N=[...this.targets].filter(x=>h.initialTarget instanceof Node&&x.contains(h.initialTarget));this.inertia(e,N,i,Math.abs(w)/_,w>0?1:-1,g,Math.abs(b)/_,b>0?1:-1,y)}this.dispatchEvent(this.newGestureEvent(vs.End,h.initialTarget)),delete this.activeTouches[d.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,n){let i=document.createEvent("CustomEvent");return i.initEvent(e,!1,!0),i.initialTarget=n,i.tapCount=0,i}dispatchEvent(e){if(e.type===vs.Tap){let n=new Date().getTime(),i=0;n-this._lastSetTapCountTime>ti.CLEAR_TAP_COUNT_TIME?i=1:i=2,this._lastSetTapCountTime=n,e.tapCount=i}else(e.type===vs.Change||e.type===vs.Contextmenu)&&(this._lastSetTapCountTime=0);if(e.initialTarget instanceof Node){for(let i of this.ignoreTargets)if(i.contains(e.initialTarget))return;let n=[];for(let i of this.targets)if(i.contains(e.initialTarget)){let s=0,a=e.initialTarget;for(;a&&a!==i;)s++,a=a.parentElement;n.push([s,i])}n.sort((i,s)=>i[0]-s[0]);for(let[i,s]of n)s.dispatchEvent(e),this.dispatched=!0}}inertia(e,n,i,s,a,l,d,h,f){this.handle=jm(e,()=>{let g=Date.now(),y=g-i,_=0,w=0,b=!0;s+=ti.SCROLL_FRICTION*y,d+=ti.SCROLL_FRICTION*y,s>0&&(b=!1,_=a*s*y),d>0&&(b=!1,w=h*d*y);let N=this.newGestureEvent(vs.Change);N.translationX=_,N.translationY=w,n.forEach(x=>x.dispatchEvent(N)),b||this.inertia(e,n,g,s,a,l+_,d,h,f+w)})}onTouchMove(e){let n=Date.now();for(let i=0,s=e.changedTouches.length;i<s;i++){let a=e.changedTouches.item(i);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("end of an UNKNOWN touch",a);continue}let l=this.activeTouches[a.identifier],d=this.newGestureEvent(vs.Change,l.initialTarget);d.translationX=a.pageX-Mi(l.rollingPageX),d.translationY=a.pageY-Mi(l.rollingPageY),d.pageX=a.pageX,d.pageY=a.pageY,this.dispatchEvent(d),l.rollingPageX.length>3&&(l.rollingPageX.shift(),l.rollingPageY.shift(),l.rollingTimestamps.shift()),l.rollingPageX.push(a.pageX),l.rollingPageY.push(a.pageY),l.rollingTimestamps.push(n)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};pl.SCROLL_FRICTION=-.005,pl.HOLD_DELAY=700,pl.CLEAR_TAP_COUNT_TIME=400,mn([lE],pl,"isTouchDevice",1);var cE=pl,Pm=class extends yt{onclick(e,n){this._register(lt(e,Dn.CLICK,i=>n(new Vc(bs(e),i))))}onmousedown(e,n){this._register(lt(e,Dn.MOUSE_DOWN,i=>n(new Vc(bs(e),i))))}onmouseover(e,n){this._register(lt(e,Dn.MOUSE_OVER,i=>n(new Vc(bs(e),i))))}onmouseleave(e,n){this._register(lt(e,Dn.MOUSE_LEAVE,i=>n(new Vc(bs(e),i))))}onkeydown(e,n){this._register(lt(e,Dn.KEY_DOWN,i=>n(new my(i))))}onkeyup(e,n){this._register(lt(e,Dn.KEY_UP,i=>n(new my(i))))}oninput(e,n){this._register(lt(e,Dn.INPUT,n))}onblur(e,n){this._register(lt(e,Dn.BLUR,n))}onfocus(e,n){this._register(lt(e,Dn.FOCUS,n))}onchange(e,n){this._register(lt(e,Dn.CHANGE,n))}ignoreGesture(e){return cE.ignoreTarget(e)}},by=11,uE=class extends Pm{constructor(t){super(),this._onActivate=t.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=t.bgWidth+"px",this.bgDomNode.style.height=t.bgHeight+"px",typeof t.top<"u"&&(this.bgDomNode.style.top="0px"),typeof t.left<"u"&&(this.bgDomNode.style.left="0px"),typeof t.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof t.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=t.className,this.domNode.style.position="absolute",this.domNode.style.width=by+"px",this.domNode.style.height=by+"px",typeof t.top<"u"&&(this.domNode.style.top=t.top+"px"),typeof t.left<"u"&&(this.domNode.style.left=t.left+"px"),typeof t.bottom<"u"&&(this.domNode.style.bottom=t.bottom+"px"),typeof t.right<"u"&&(this.domNode.style.right=t.right+"px"),this._pointerMoveMonitor=this._register(new fS),this._register(yy(this.bgDomNode,Dn.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(yy(this.domNode,Dn.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new rE),this._pointerdownScheduleRepeatTimer=this._register(new Am)}_arrowPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,bs(t))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(e,200),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),t.preventDefault()}},dE=class vp{constructor(e,n,i,s,a,l,d){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,i=i|0,s=s|0,a=a|0,l=l|0,d=d|0),this.rawScrollLeft=s,this.rawScrollTop=d,n<0&&(n=0),s+n>i&&(s=i-n),s<0&&(s=0),a<0&&(a=0),d+a>l&&(d=l-a),d<0&&(d=0),this.width=n,this.scrollWidth=i,this.scrollLeft=s,this.height=a,this.scrollHeight=l,this.scrollTop=d}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(e,n){return new vp(this._forceIntegerValues,typeof e.width<"u"?e.width:this.width,typeof e.scrollWidth<"u"?e.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof e.height<"u"?e.height:this.height,typeof e.scrollHeight<"u"?e.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(e){return new vp(this._forceIntegerValues,this.width,this.scrollWidth,typeof e.scrollLeft<"u"?e.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof e.scrollTop<"u"?e.scrollTop:this.rawScrollTop)}createScrollEvent(e,n){let i=this.width!==e.width,s=this.scrollWidth!==e.scrollWidth,a=this.scrollLeft!==e.scrollLeft,l=this.height!==e.height,d=this.scrollHeight!==e.scrollHeight,h=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:n,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:i,scrollWidthChanged:s,scrollLeftChanged:a,heightChanged:l,scrollHeightChanged:d,scrollTopChanged:h}}},hE=class extends yt{constructor(t){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Le),this.onScroll=this._onScroll.event,this._smoothScrollDuration=t.smoothScrollDuration,this._scheduleAtNextAnimationFrame=t.scheduleAtNextAnimationFrame,this._state=new dE(t.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(t){this._smoothScrollDuration=t}validateScrollPosition(t){return this._state.withScrollPosition(t)}getScrollDimensions(){return this._state}setScrollDimensions(t,e){var i;let n=this._state.withScrollDimensions(t,e);this._setState(n,!!this._smoothScrolling),(i=this._smoothScrolling)==null||i.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(t){let e=this._state.withScrollPosition(t);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(e,!1)}setScrollPositionSmooth(t,e){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(t);if(this._smoothScrolling){t={scrollLeft:typeof t.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:t.scrollLeft,scrollTop:typeof t.scrollTop>"u"?this._smoothScrolling.to.scrollTop:t.scrollTop};let n=this._state.withScrollPosition(t);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let i;e?i=new xy(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):i=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=i}else{let n=this._state.withScrollPosition(t);this._smoothScrolling=xy.start(this._state,n,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let t=this._smoothScrolling.tick(),e=this._state.withScrollPosition(t);if(this._setState(e,!0),!!this._smoothScrolling){if(t.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(t,e){let n=this._state;n.equals(t)||(this._state=t,this._onScroll.fire(this._state.createScrollEvent(n,e)))}},Sy=class{constructor(e,n,i){this.scrollLeft=e,this.scrollTop=n,this.isDone=i}};function Uh(t,e){let n=e-t;return function(i){return t+n*mE(i)}}function fE(t,e,n){return function(i){return i<n?t(i/n):e((i-n)/(1-n))}}var xy=class _p{constructor(e,n,i,s){this.from=e,this.to=n,this.duration=s,this.startTime=i,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,n,i){if(Math.abs(e-n)>2.5*i){let s,a;return e<n?(s=e+.75*i,a=n-.75*i):(s=e-.75*i,a=n+.75*i),fE(Uh(e,s),Uh(a,n),.33)}return Uh(e,n)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let n=(e-this.startTime)/this.duration;if(n<1){let i=this.scrollLeft(n),s=this.scrollTop(n);return new Sy(i,s,!1)}return new Sy(this.to.scrollLeft,this.to.scrollTop,!0)}combine(e,n,i){return _p.start(e,n,i)}static start(e,n,i){i=i+10;let s=Date.now()-10;return new _p(e,n,s,i)}};function pE(t){return Math.pow(t,3)}function mE(t){return 1-pE(1-t)}var gE=class extends yt{constructor(e,n,i){super(),this._visibility=e,this._visibleClassName=n,this._invisibleClassName=i,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Am)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var n;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(n=this._domNode)==null||n.setClassName(this._invisibleClassName+(e?" fade":"")))}},vE=140,pS=class extends Pm{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 gE(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new fS),this._shouldRender=!0,this.domNode=bl(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(lt(this.domNode.domNode,Dn.POINTER_DOWN,n=>this._domNodePointerDown(n)))}_createArrow(e){let n=this._register(new uE(e));this.domNode.domNode.appendChild(n.bgDomNode),this.domNode.domNode.appendChild(n.domNode)}_createSlider(e,n,i,s){this.slider=bl(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(n),typeof i=="number"&&this.slider.setWidth(i),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(lt(this.slider.domNode,Dn.POINTER_DOWN,a=>{a.button===0&&(a.preventDefault(),this._sliderPointerDown(a))})),this.onclick(this.slider.domNode,a=>{a.leftButton&&a.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let n=this.domNode.domNode.getClientRects()[0].top,i=n+this._scrollbarState.getSliderPosition(),s=n+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),a=this._sliderPointerPosition(e);i<=a&&a<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let n,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")n=e.offsetX,i=e.offsetY;else{let a=oE(this.domNode.domNode);n=e.pageX-a.left,i=e.pageY-a.top}let s=this._pointerDownRelativePosition(n,i);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 n=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,a=>{let l=this._sliderOrthogonalPointerPosition(a),d=Math.abs(l-i);if(cS&&d>vE){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let h=this._sliderPointerPosition(a)-n;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(h))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let n={};this.writeScrollPosition(n,e),this._scrollable.setScrollPositionNow(n)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},mS=class yp{constructor(e,n,i,s,a,l){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(e),this._visibleSize=s,this._scrollSize=a,this._scrollPosition=l,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new yp(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let n=Math.round(e);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(e){let n=Math.round(e);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(e){let n=Math.round(e);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,n,i,s,a){let l=Math.max(0,i-e),d=Math.max(0,l-2*n),h=s>0&&s>i;if(!h)return{computedAvailableSize:Math.round(l),computedIsNeeded:h,computedSliderSize:Math.round(d),computedSliderRatio:0,computedSliderPosition:0};let f=Math.round(Math.max(20,Math.floor(i*d/s))),g=(d-f)/(s-i),y=a*g;return{computedAvailableSize:Math.round(l),computedIsNeeded:h,computedSliderSize:Math.round(f),computedSliderRatio:g,computedSliderPosition:Math.round(y)}}_refreshComputedValues(){let e=yp._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=e.computedAvailableSize,this._computedIsNeeded=e.computedIsNeeded,this._computedSliderSize=e.computedSliderSize,this._computedSliderRatio=e.computedSliderRatio,this._computedSliderPosition=e.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let n=e-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let n=e-this._arrowSize,i=this._scrollPosition;return n<this._computedSliderPosition?i-=this._visibleSize:i+=this._visibleSize,i}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let n=this._computedSliderPosition+e;return Math.round(n/this._computedSliderRatio)}},_E=class extends pS{constructor(e,n,i){let s=e.getScrollDimensions(),a=e.getCurrentScrollPosition();if(super({lazyRender:n.lazyRender,host:i,scrollbarState:new mS(n.horizontalHasArrows?n.arrowSize:0,n.horizontal===2?0:n.horizontalScrollbarSize,n.vertical===2?0:n.verticalScrollbarSize,s.width,s.scrollWidth,a.scrollLeft),visibility:n.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:n.scrollByPage}),n.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((n.horizontalScrollbarSize-n.horizontalSliderSize)/2),0,void 0,n.horizontalSliderSize)}_updateSlider(e,n){this.slider.setWidth(e),this.slider.setLeft(n)}_renderDomNode(e,n){this.domNode.setWidth(e),this.domNode.setHeight(n),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,n){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,n){e.scrollLeft=n}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},yE=class extends pS{constructor(t,e,n){let i=t.getScrollDimensions(),s=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:n,scrollbarState:new mS(e.verticalHasArrows?e.arrowSize:0,e.vertical===2?0:e.verticalScrollbarSize,0,i.height,i.scrollHeight,s.scrollTop),visibility:e.vertical,extraScrollbarClassName:"vertical",scrollable:t,scrollByPage:e.scrollByPage}),e.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((e.verticalScrollbarSize-e.verticalSliderSize)/2),e.verticalSliderSize,void 0)}_updateSlider(t,e){this.slider.setHeight(t),this.slider.setTop(e)}_renderDomNode(t,e){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(t){return this._shouldRender=this._onElementScrollSize(t.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(t.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(t.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(t,e){return e}_sliderPointerPosition(t){return t.pageY}_sliderOrthogonalPointerPosition(t){return t.pageX}_updateScrollbarSize(t){this.slider.setWidth(t)}writeScrollPosition(t,e){t.scrollTop=e}updateOptions(t){this.updateScrollbarSize(t.vertical===2?0:t.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(t.vertical),this._scrollByPage=t.scrollByPage}},wE=500,Cy=50,bE=class{constructor(e,n,i){this.timestamp=e,this.deltaX=n,this.deltaY=i,this.score=0}},wp=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,n=0,i=1,s=this._rear;do{let a=s===this._front?e:Math.pow(2,-i);if(e-=a,n+=this._memory[s].score*a,s===this._front)break;s=(this._capacity+s-1)%this._capacity,i++}while(!0);return n<=.5}acceptStandardWheelEvent(e){if(Rm){let n=bs(e.browserEvent),i=j5(n);this.accept(Date.now(),e.deltaX*i,e.deltaY*i)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,n,i){let s=null,a=new bE(e,n,i);this._front===-1&&this._rear===-1?(this._memory[0]=a,this._front=0,this._rear=0):(s=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=a),a.score=this._computeScore(a,s)}_computeScore(e,n){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let i=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(i+=.25),n){let s=Math.abs(e.deltaX),a=Math.abs(e.deltaY),l=Math.abs(n.deltaX),d=Math.abs(n.deltaY),h=Math.max(Math.min(s,l),1),f=Math.max(Math.min(a,d),1),g=Math.max(s,l),y=Math.max(a,d);g%h===0&&y%f===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};wp.INSTANCE=new wp;var SE=wp,xE=class extends Pm{constructor(t,e,n){super(),this._onScroll=this._register(new Le),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Le),this.onWillScroll=this._onWillScroll.event,this._options=kE(e),this._scrollable=n,this._register(this._scrollable.onScroll(s=>{this._onWillScroll.fire(s),this._onDidScroll(s),this._onScroll.fire(s)}));let i={onMouseWheel:s=>this._onMouseWheel(s),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new yE(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new _E(this._scrollable,this._options,i)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(t),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=bl(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=bl(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=bl(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,s=>this._onMouseOver(s)),this.onmouseleave(this._listenOnDomNode,s=>this._onMouseLeave(s)),this._hideTimeout=this._register(new Am),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=co(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(t){this._verticalScrollbar.delegatePointerDown(t)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(t){this._scrollable.setScrollDimensions(t,!1)}updateClassName(t){this._options.className=t,xs&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(t){typeof t.handleMouseWheel<"u"&&(this._options.handleMouseWheel=t.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof t.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=t.mouseWheelScrollSensitivity),typeof t.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=t.fastScrollSensitivity),typeof t.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=t.scrollPredominantAxis),typeof t.horizontal<"u"&&(this._options.horizontal=t.horizontal),typeof t.vertical<"u"&&(this._options.vertical=t.vertical),typeof t.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=t.horizontalScrollbarSize),typeof t.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=t.verticalScrollbarSize),typeof t.scrollByPage<"u"&&(this._options.scrollByPage=t.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(t){this._revealOnScroll=t}delegateScrollFromMouseWheelEvent(t){this._onMouseWheel(new vy(t))}_setListeningToMouseWheel(t){if(this._mouseWheelToDispose.length>0!==t&&(this._mouseWheelToDispose=co(this._mouseWheelToDispose),t)){let e=n=>{this._onMouseWheel(new vy(n))};this._mouseWheelToDispose.push(lt(this._listenOnDomNode,Dn.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(t){var s;if((s=t.browserEvent)!=null&&s.defaultPrevented)return;let e=SE.INSTANCE;e.acceptStandardWheelEvent(t);let n=!1;if(t.deltaY||t.deltaX){let a=t.deltaY*this._options.mouseWheelScrollSensitivity,l=t.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&l+a===0?l=a=0:Math.abs(a)>=Math.abs(l)?l=0:a=0),this._options.flipAxes&&([a,l]=[l,a]);let d=!xs&&t.browserEvent&&t.browserEvent.shiftKey;(this._options.scrollYToX||d)&&!l&&(l=a,a=0),t.browserEvent&&t.browserEvent.altKey&&(l=l*this._options.fastScrollSensitivity,a=a*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),f={};if(a){let g=Cy*a,y=h.scrollTop-(g<0?Math.floor(g):Math.ceil(g));this._verticalScrollbar.writeScrollPosition(f,y)}if(l){let g=Cy*l,y=h.scrollLeft-(g<0?Math.floor(g):Math.ceil(g));this._horizontalScrollbar.writeScrollPosition(f,y)}f=this._scrollable.validateScrollPosition(f),(h.scrollLeft!==f.scrollLeft||h.scrollTop!==f.scrollTop)&&(this._options.mouseWheelSmoothScroll&&e.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(f):this._scrollable.setScrollPositionNow(f),n=!0)}let i=n;!i&&this._options.alwaysConsumeMouseWheel&&(i=!0),!i&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(i=!0),i&&(t.preventDefault(),t.stopPropagation())}_onDidScroll(t){this._shouldRender=this._horizontalScrollbar.onDidScroll(t)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(t)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let t=this._scrollable.getCurrentScrollPosition(),e=t.scrollTop>0,n=t.scrollLeft>0,i=n?" left":"",s=e?" top":"",a=n||e?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${s}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${s}${i}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(t){this._mouseIsOver=!1,this._hide()}_onMouseOver(t){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),wE)}},CE=class extends xE{constructor(e,n,i){super(e,n,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function kE(t){let e={lazyRender:typeof t.lazyRender<"u"?t.lazyRender:!1,className:typeof t.className<"u"?t.className:"",useShadows:typeof t.useShadows<"u"?t.useShadows:!0,handleMouseWheel:typeof t.handleMouseWheel<"u"?t.handleMouseWheel:!0,flipAxes:typeof t.flipAxes<"u"?t.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof t.consumeMouseWheelIfScrollbarIsNeeded<"u"?t.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof t.alwaysConsumeMouseWheel<"u"?t.alwaysConsumeMouseWheel:!1,scrollYToX:typeof t.scrollYToX<"u"?t.scrollYToX:!1,mouseWheelScrollSensitivity:typeof t.mouseWheelScrollSensitivity<"u"?t.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof t.fastScrollSensitivity<"u"?t.fastScrollSensitivity:5,scrollPredominantAxis:typeof t.scrollPredominantAxis<"u"?t.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof t.mouseWheelSmoothScroll<"u"?t.mouseWheelSmoothScroll:!0,arrowSize:typeof t.arrowSize<"u"?t.arrowSize:11,listenOnDomNode:typeof t.listenOnDomNode<"u"?t.listenOnDomNode:null,horizontal:typeof t.horizontal<"u"?t.horizontal:1,horizontalScrollbarSize:typeof t.horizontalScrollbarSize<"u"?t.horizontalScrollbarSize:10,horizontalSliderSize:typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:0,horizontalHasArrows:typeof t.horizontalHasArrows<"u"?t.horizontalHasArrows:!1,vertical:typeof t.vertical<"u"?t.vertical:1,verticalScrollbarSize:typeof t.verticalScrollbarSize<"u"?t.verticalScrollbarSize:10,verticalHasArrows:typeof t.verticalHasArrows<"u"?t.verticalHasArrows:!1,verticalSliderSize:typeof t.verticalSliderSize<"u"?t.verticalSliderSize:0,scrollByPage:typeof t.scrollByPage<"u"?t.scrollByPage:!1};return e.horizontalSliderSize=typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:e.horizontalScrollbarSize,e.verticalSliderSize=typeof t.verticalSliderSize<"u"?t.verticalSliderSize:e.verticalScrollbarSize,xs&&(e.className+=" mac"),e}var bp=class extends yt{constructor(e,n,i,s,a,l,d,h){super(),this._bufferService=i,this._optionsService=d,this._renderService=h,this._onRequestScrollLines=this._register(new Le),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let f=this._register(new hE({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:g=>jm(s.window,g)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{f.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new CE(n,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},f)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(a.onProtocolChange(g=>{this._scrollableElement.updateOptions({handleMouseWheel:!(g&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Yn.runAndSubscribe(l.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=l.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(en(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),n.appendChild(this._styleElement),this._register(en(()=>this._styleElement.remove())),this._register(Yn.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(g=>this._handleScroll(g)))}scrollLines(e){let n=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:n.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,n){n&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!n,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let n=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),i=n-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=n,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};bp=mn([ze(2,ci),ze(3,Ys),ze(4,G0),ze(5,ha),ze(6,ui),ze(7,Gs)],bp);var Sp=class extends yt{constructor(e,n,i,s,a){super(),this._screenElement=e,this._bufferService=n,this._coreBrowserService=i,this._decorationService=s,this._renderService=a,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(l=>this._removeDecoration(l))),this._register(en(()=>{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 n=this._coreBrowserService.mainDocument.createElement("div");n.classList.add("xterm-decoration"),n.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.layer)==="top"),n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let i=e.options.x??0;return i&&i>this._bufferService.cols&&(n.style.display="none"),this._refreshXPosition(e,n),n}_refreshStyle(e){let n=e.marker.line-this._bufferService.buffers.active.ydisp;if(n<0||n>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${n*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,n=e.element){if(!n)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?n.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":n.style.left=i?`${i*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var n;(n=this._decorationElements.get(e))==null||n.remove(),this._decorationElements.delete(e),e.dispose()}};Sp=mn([ze(1,ci),ze(2,Ys),ze(3,Tl),ze(4,Gs)],Sp);var EE=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let n of this._zones)if(n.color===e.options.overviewRulerOptions.color&&n.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(n,e.marker.line))return;if(this._lineAdjacentToZone(n,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(n,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,n){return n>=e.startBufferLine&&n<=e.endBufferLine}_lineAdjacentToZone(e,n,i){return n>=e.startBufferLine-this._linePadding[i||"full"]&&n<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,n){e.startBufferLine=Math.min(e.startBufferLine,n),e.endBufferLine=Math.max(e.endBufferLine,n)}},fs={full:0,left:0,center:0,right:0},vr={full:0,left:0,center:0,right:0},Ja={full:0,left:0,center:0,right:0},Au=class extends yt{constructor(e,n,i,s,a,l,d,h){var g;super(),this._viewportElement=e,this._screenElement=n,this._bufferService=i,this._decorationService=s,this._renderService=a,this._optionsService=l,this._themeService=d,this._coreBrowserService=h,this._colorZoneStore=new EE,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(g=this._viewportElement.parentElement)==null||g.insertBefore(this._canvas,this._viewportElement),this._register(en(()=>{var y;return(y=this._canvas)==null?void 0:y.remove()}));let f=this._canvas.getContext("2d");if(f)this._ctx=f;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),n=Math.ceil((this._canvas.width-1)/3);vr.full=this._canvas.width,vr.left=e,vr.center=n,vr.right=e,this._refreshDrawHeightConstants(),Ja.full=1,Ja.left=1,Ja.center=1+vr.left,Ja.right=1+vr.left+vr.center}_refreshDrawHeightConstants(){fs.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,n=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);fs.left=n,fs.center=n,fs.right=n}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*fs.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*fs.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*fs.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*fs.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let n of this._decorationService.decorations)this._colorZoneStore.addDecoration(n);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let n of e)n.position!=="full"&&this._renderColorZone(n);for(let n of e)n.position==="full"&&this._renderColorZone(n);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(Ja[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-fs[e.position||"full"]/2),vr[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+fs[e.position||"full"]))}_queueRefresh(e,n){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=n||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Au=mn([ze(2,ci),ze(3,Tl),ze(4,Gs),ze(5,ui),ze(6,ha),ze(7,Ys)],Au);var ve;(t=>(t.NUL="\0",t.SOH="",t.STX="",t.ETX="",t.EOT="",t.ENQ="",t.ACK="",t.BEL="\x07",t.BS="\b",t.HT=" ",t.LF=`
61
- `,t.VT="\v",t.FF="\f",t.CR="\r",t.SO="",t.SI="",t.DLE="",t.DC1="",t.DC2="",t.DC3="",t.DC4="",t.NAK="",t.SYN="",t.ETB="",t.CAN="",t.EM="",t.SUB="",t.ESC="\x1B",t.FS="",t.GS="",t.RS="",t.US="",t.SP=" ",t.DEL=""))(ve||(ve={}));var fu;(t=>(t.PAD="€",t.HOP="",t.BPH="‚",t.NBH="ƒ",t.IND="„",t.NEL="…",t.SSA="†",t.ESA="‡",t.HTS="ˆ",t.HTJ="‰",t.VTS="Š",t.PLD="‹",t.PLU="Œ",t.RI="",t.SS2="Ž",t.SS3="",t.DCS="",t.PU1="‘",t.PU2="’",t.STS="“",t.CCH="”",t.MW="•",t.SPA="–",t.EPA="—",t.SOS="˜",t.SGCI="™",t.SCI="š",t.CSI="›",t.ST="œ",t.OSC="",t.PM="ž",t.APC="Ÿ"))(fu||(fu={}));var gS;(t=>t.ST=`${ve.ESC}\\`)(gS||(gS={}));var xp=class{constructor(e,n,i,s,a,l){this._textarea=e,this._compositionView=n,this._bufferService=i,this._optionsService=s,this._coreService=a,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 n={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let i;n.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(n.start,this._compositionPosition.start):i=this._textarea.value.substring(n.start),i.length>0&&this._coreService.triggerDataEvent(i,!0)}},0)}else{this._isSendingComposition=!1;let n=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(n,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let n=this._textarea.value,i=n.replace(e,"");this._dataAlreadySent=i,n.length>e.length?this._coreService.triggerDataEvent(i,!0):n.length<e.length?this._coreService.triggerDataEvent(`${ve.DEL}`,!0):n.length===e.length&&n!==e&&this._coreService.triggerDataEvent(n,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let n=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),i=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,a=n*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=a+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"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=a+"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)}}};xp=mn([ze(2,ci),ze(3,ui),ze(4,fo),ze(5,Gs)],xp);var In=0,Bn=0,On=0,hn=0,ky={css:"#00000000",rgba:0},Cn;(t=>{function e(s,a,l,d){return d!==void 0?`#${Gr(s)}${Gr(a)}${Gr(l)}${Gr(d)}`:`#${Gr(s)}${Gr(a)}${Gr(l)}`}t.toCss=e;function n(s,a,l,d=255){return(s<<24|a<<16|l<<8|d)>>>0}t.toRgba=n;function i(s,a,l,d){return{css:t.toCss(s,a,l,d),rgba:t.toRgba(s,a,l,d)}}t.toColor=i})(Cn||(Cn={}));var Xt;(t=>{function e(h,f){if(hn=(f.rgba&255)/255,hn===1)return{css:f.css,rgba:f.rgba};let g=f.rgba>>24&255,y=f.rgba>>16&255,_=f.rgba>>8&255,w=h.rgba>>24&255,b=h.rgba>>16&255,N=h.rgba>>8&255;In=w+Math.round((g-w)*hn),Bn=b+Math.round((y-b)*hn),On=N+Math.round((_-N)*hn);let x=Cn.toCss(In,Bn,On),E=Cn.toRgba(In,Bn,On);return{css:x,rgba:E}}t.blend=e;function n(h){return(h.rgba&255)===255}t.isOpaque=n;function i(h,f,g){let y=pu.ensureContrastRatio(h.rgba,f.rgba,g);if(y)return Cn.toColor(y>>24&255,y>>16&255,y>>8&255)}t.ensureContrastRatio=i;function s(h){let f=(h.rgba|255)>>>0;return[In,Bn,On]=pu.toChannels(f),{css:Cn.toCss(In,Bn,On),rgba:f}}t.opaque=s;function a(h,f){return hn=Math.round(f*255),[In,Bn,On]=pu.toChannels(h.rgba),{css:Cn.toCss(In,Bn,On,hn),rgba:Cn.toRgba(In,Bn,On,hn)}}t.opacity=a;function l(h,f){return hn=h.rgba&255,a(h,hn*f/255)}t.multiplyOpacity=l;function d(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}t.toColorRGB=d})(Xt||(Xt={}));var on;(t=>{let e,n;try{let s=document.createElement("canvas");s.width=1,s.height=1;let a=s.getContext("2d",{willReadFrequently:!0});a&&(e=a,e.globalCompositeOperation="copy",n=e.createLinearGradient(0,0,1,1))}catch{}function i(s){if(s.match(/#[\da-f]{3,8}/i))switch(s.length){case 4:return In=parseInt(s.slice(1,2).repeat(2),16),Bn=parseInt(s.slice(2,3).repeat(2),16),On=parseInt(s.slice(3,4).repeat(2),16),Cn.toColor(In,Bn,On);case 5:return In=parseInt(s.slice(1,2).repeat(2),16),Bn=parseInt(s.slice(2,3).repeat(2),16),On=parseInt(s.slice(3,4).repeat(2),16),hn=parseInt(s.slice(4,5).repeat(2),16),Cn.toColor(In,Bn,On,hn);case 7:return{css:s,rgba:(parseInt(s.slice(1),16)<<8|255)>>>0};case 9:return{css:s,rgba:parseInt(s.slice(1),16)>>>0}}let a=s.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(a)return In=parseInt(a[1]),Bn=parseInt(a[2]),On=parseInt(a[3]),hn=Math.round((a[5]===void 0?1:parseFloat(a[5]))*255),Cn.toColor(In,Bn,On,hn);if(!e||!n)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=n,e.fillStyle=s,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[In,Bn,On,hn]=e.getImageData(0,0,1,1).data,hn!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Cn.toRgba(In,Bn,On,hn),css:s}}t.toColor=i})(on||(on={}));var ri;(t=>{function e(i){return n(i>>16&255,i>>8&255,i&255)}t.relativeLuminance=e;function n(i,s,a){let l=i/255,d=s/255,h=a/255,f=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),g=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),y=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return f*.2126+g*.7152+y*.0722}t.relativeLuminance2=n})(ri||(ri={}));var pu;(t=>{function e(l,d){if(hn=(d&255)/255,hn===1)return d;let h=d>>24&255,f=d>>16&255,g=d>>8&255,y=l>>24&255,_=l>>16&255,w=l>>8&255;return In=y+Math.round((h-y)*hn),Bn=_+Math.round((f-_)*hn),On=w+Math.round((g-w)*hn),Cn.toRgba(In,Bn,On)}t.blend=e;function n(l,d,h){let f=ri.relativeLuminance(l>>8),g=ri.relativeLuminance(d>>8);if(Os(f,g)<h){if(g<f){let w=i(l,d,h),b=Os(f,ri.relativeLuminance(w>>8));if(b<h){let N=s(l,d,h),x=Os(f,ri.relativeLuminance(N>>8));return b>x?w:N}return w}let y=s(l,d,h),_=Os(f,ri.relativeLuminance(y>>8));if(_<h){let w=i(l,d,h),b=Os(f,ri.relativeLuminance(w>>8));return _>b?y:w}return y}}t.ensureContrastRatio=n;function i(l,d,h){let f=l>>24&255,g=l>>16&255,y=l>>8&255,_=d>>24&255,w=d>>16&255,b=d>>8&255,N=Os(ri.relativeLuminance2(_,w,b),ri.relativeLuminance2(f,g,y));for(;N<h&&(_>0||w>0||b>0);)_-=Math.max(0,Math.ceil(_*.1)),w-=Math.max(0,Math.ceil(w*.1)),b-=Math.max(0,Math.ceil(b*.1)),N=Os(ri.relativeLuminance2(_,w,b),ri.relativeLuminance2(f,g,y));return(_<<24|w<<16|b<<8|255)>>>0}t.reduceLuminance=i;function s(l,d,h){let f=l>>24&255,g=l>>16&255,y=l>>8&255,_=d>>24&255,w=d>>16&255,b=d>>8&255,N=Os(ri.relativeLuminance2(_,w,b),ri.relativeLuminance2(f,g,y));for(;N<h&&(_<255||w<255||b<255);)_=Math.min(255,_+Math.ceil((255-_)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),b=Math.min(255,b+Math.ceil((255-b)*.1)),N=Os(ri.relativeLuminance2(_,w,b),ri.relativeLuminance2(f,g,y));return(_<<24|w<<16|b<<8|255)>>>0}t.increaseLuminance=s;function a(l){return[l>>24&255,l>>16&255,l>>8&255,l&255]}t.toChannels=a})(pu||(pu={}));function Gr(t){let e=t.toString(16);return e.length<2?"0"+e:e}function Os(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}var NE=class extends Pl{constructor(e,n,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=n,this._width=i}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()]}},ju=class{constructor(t){this._bufferService=t,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Yi}register(t){let e={id:this._nextCharacterJoinerId++,handler:t};return this._characterJoiners.push(e),e.id}deregister(t){for(let e=0;e<this._characterJoiners.length;e++)if(this._characterJoiners[e].id===t)return this._characterJoiners.splice(e,1),!0;return!1}getJoinedCharacters(t){if(this._characterJoiners.length===0)return[];let e=this._bufferService.buffer.lines.get(t);if(!e||e.length===0)return[];let n=[],i=e.translateToString(!0),s=0,a=0,l=0,d=e.getFg(0),h=e.getBg(0);for(let f=0;f<e.getTrimmedLength();f++)if(e.loadCell(f,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==d||this._workCell.bg!==h){if(f-s>1){let g=this._getJoinedRanges(i,l,a,e,s);for(let y=0;y<g.length;y++)n.push(g[y])}s=f,l=a,d=this._workCell.fg,h=this._workCell.bg}a+=this._workCell.getChars().length||Er.length}if(this._bufferService.cols-s>1){let f=this._getJoinedRanges(i,l,a,e,s);for(let g=0;g<f.length;g++)n.push(f[g])}return n}_getJoinedRanges(t,e,n,i,s){let a=t.substring(e,n),l=[];try{l=this._characterJoiners[0].handler(a)}catch(d){console.error(d)}for(let d=1;d<this._characterJoiners.length;d++)try{let h=this._characterJoiners[d].handler(a);for(let f=0;f<h.length;f++)ju._mergeRanges(l,h[f])}catch(h){console.error(h)}return this._stringRangesToCellRanges(l,i,s),l}_stringRangesToCellRanges(t,e,n){let i=0,s=!1,a=0,l=t[i];if(l){for(let d=n;d<this._bufferService.cols;d++){let h=e.getWidth(d),f=e.getString(d).length||Er.length;if(h!==0){if(!s&&l[0]<=a&&(l[0]=d,s=!0),l[1]<=a){if(l[1]=d,l=t[++i],!l)break;l[0]<=a?(l[0]=d,s=!0):s=!1}a+=f}}l&&(l[1]=this._bufferService.cols)}}static _mergeRanges(t,e){let n=!1;for(let i=0;i<t.length;i++){let s=t[i];if(n){if(e[1]<=s[0])return t[i-1][1]=e[1],t;if(e[1]<=s[1])return t[i-1][1]=Math.max(e[1],s[1]),t.splice(i,1),t;t.splice(i,1),i--}else{if(e[1]<=s[0])return t.splice(i,0,e),t;if(e[1]<=s[1])return s[0]=Math.min(e[0],s[0]),t;e[0]<s[1]&&(s[0]=Math.min(e[0],s[0]),n=!0);continue}}return n?t[t.length-1][1]=e[1]:t.push(e),t}};ju=mn([ze(0,ci)],ju);function LE(t){return 57508<=t&&t<=57558}function RE(t){return 9472<=t&&t<=9631}function ME(t){return LE(t)||RE(t)}function AE(){return{css:{canvas:Yc(),cell:Yc()},device:{canvas:Yc(),cell:Yc(),char:{width:0,height:0,left:0,top:0}}}}function Yc(){return{width:0,height:0}}var Cp=class{constructor(e,n,i,s,a,l,d){this._document=e,this._characterJoinerService=n,this._optionsService=i,this._coreBrowserService=s,this._coreService=a,this._decorationService=l,this._themeService=d,this._workCell=new Yi,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,n,i){this._selectionStart=e,this._selectionEnd=n,this._columnSelectMode=i}createRow(e,n,i,s,a,l,d,h,f,g,y){let _=[],w=this._characterJoinerService.getJoinedCharacters(n),b=this._themeService.colors,N=e.getNoBgTrimmedLength();i&&N<l+1&&(N=l+1);let x,E=0,C="",I=0,T=0,W=0,U=0,Q=!1,ee=0,q=!1,J=0,$=0,M=[],L=g!==-1&&y!==-1;for(let j=0;j<N;j++){e.loadCell(j,this._workCell);let O=this._workCell.getWidth();if(O===0)continue;let P=!1,A=j>=$,R=j,D=this._workCell;if(w.length>0&&j===w[0][0]&&A){let je=w.shift(),tt=this._isCellInSelection(je[0],n);for(I=je[0]+1;I<je[1];I++)A&&(A=tt===this._isCellInSelection(I,n));A&&(A=!i||l<je[0]||l>=je[1]),A?(P=!0,D=new NE(this._workCell,e.translateToString(!0,je[0],je[1]),je[1]-je[0]),R=je[1]-1,O=D.getWidth()):$=je[1]}let H=this._isCellInSelection(j,n),z=i&&j===l,F=L&&j>=g&&j<=y,K=!1;this._decorationService.forEachDecorationAtCell(j,n,void 0,je=>{K=!0});let ne=D.getChars()||Er;if(ne===" "&&(D.isUnderline()||D.isOverline())&&(ne=" "),J=O*h-f.get(ne,D.isBold(),D.isItalic()),!x)x=this._document.createElement("span");else if(E&&(H&&q||!H&&!q&&D.bg===T)&&(H&&q&&b.selectionForeground||D.fg===W)&&D.extended.ext===U&&F===Q&&J===ee&&!z&&!P&&!K&&A){D.isInvisible()?C+=Er:C+=ne,E++;continue}else E&&(x.textContent=C),x=this._document.createElement("span"),E=0,C="";if(T=D.bg,W=D.fg,U=D.extended.ext,Q=F,ee=J,q=H,P&&l>=j&&l<=R&&(l=j),!this._coreService.isCursorHidden&&z&&this._coreService.isCursorInitialized){if(M.push("xterm-cursor"),this._coreBrowserService.isFocused)d&&M.push("xterm-cursor-blink"),M.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(a)switch(a){case"outline":M.push("xterm-cursor-outline");break;case"block":M.push("xterm-cursor-block");break;case"bar":M.push("xterm-cursor-bar");break;case"underline":M.push("xterm-cursor-underline");break}}if(D.isBold()&&M.push("xterm-bold"),D.isItalic()&&M.push("xterm-italic"),D.isDim()&&M.push("xterm-dim"),D.isInvisible()?C=Er:C=D.getChars()||Er,D.isUnderline()&&(M.push(`xterm-underline-${D.extended.underlineStyle}`),C===" "&&(C=" "),!D.isUnderlineColorDefault()))if(D.isUnderlineColorRGB())x.style.textDecorationColor=`rgb(${Pl.toColorRGB(D.getUnderlineColor()).join(",")})`;else{let je=D.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&D.isBold()&&je<8&&(je+=8),x.style.textDecorationColor=b.ansi[je].css}D.isOverline()&&(M.push("xterm-overline"),C===" "&&(C=" ")),D.isStrikethrough()&&M.push("xterm-strikethrough"),F&&(x.style.textDecoration="underline");let re=D.getFgColor(),Y=D.getFgColorMode(),de=D.getBgColor(),oe=D.getBgColorMode(),pe=!!D.isInverse();if(pe){let je=re;re=de,de=je;let tt=Y;Y=oe,oe=tt}let xe,Qe,ot=!1;this._decorationService.forEachDecorationAtCell(j,n,void 0,je=>{je.options.layer!=="top"&&ot||(je.backgroundColorRGB&&(oe=50331648,de=je.backgroundColorRGB.rgba>>8&16777215,xe=je.backgroundColorRGB),je.foregroundColorRGB&&(Y=50331648,re=je.foregroundColorRGB.rgba>>8&16777215,Qe=je.foregroundColorRGB),ot=je.options.layer==="top")}),!ot&&H&&(xe=this._coreBrowserService.isFocused?b.selectionBackgroundOpaque:b.selectionInactiveBackgroundOpaque,de=xe.rgba>>8&16777215,oe=50331648,ot=!0,b.selectionForeground&&(Y=50331648,re=b.selectionForeground.rgba>>8&16777215,Qe=b.selectionForeground)),ot&&M.push("xterm-decoration-top");let De;switch(oe){case 16777216:case 33554432:De=b.ansi[de],M.push(`xterm-bg-${de}`);break;case 50331648:De=Cn.toColor(de>>16,de>>8&255,de&255),this._addStyle(x,`background-color:#${Ey((de>>>0).toString(16),"0",6)}`);break;case 0:default:pe?(De=b.foreground,M.push("xterm-bg-257")):De=b.background}switch(xe||D.isDim()&&(xe=Xt.multiplyOpacity(De,.5)),Y){case 16777216:case 33554432:D.isBold()&&re<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(re+=8),this._applyMinimumContrast(x,De,b.ansi[re],D,xe,void 0)||M.push(`xterm-fg-${re}`);break;case 50331648:let je=Cn.toColor(re>>16&255,re>>8&255,re&255);this._applyMinimumContrast(x,De,je,D,xe,Qe)||this._addStyle(x,`color:#${Ey(re.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(x,De,b.foreground,D,xe,Qe)||pe&&M.push("xterm-fg-257")}M.length&&(x.className=M.join(" "),M.length=0),!z&&!P&&!K&&A?E++:x.textContent=C,J!==this.defaultSpacing&&(x.style.letterSpacing=`${J}px`),_.push(x),j=R}return x&&E&&(x.textContent=C),_}_applyMinimumContrast(e,n,i,s,a,l){if(this._optionsService.rawOptions.minimumContrastRatio===1||ME(s.getCode()))return!1;let d=this._getContrastCache(s),h;if(!a&&!l&&(h=d.getColor(n.rgba,i.rgba)),h===void 0){let f=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);h=Xt.ensureContrastRatio(a||n,l||i,f),d.setColor((a||n).rgba,(l||i).rgba,h??null)}return h?(this._addStyle(e,`color:${h.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,n){e.setAttribute("style",`${e.getAttribute("style")||""}${n};`)}_isCellInSelection(e,n){let i=this._selectionStart,s=this._selectionEnd;return!i||!s?!1:this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&n>=i[1]&&e<s[0]&&n<=s[1]:e<i[0]&&n>=i[1]&&e>=s[0]&&n<=s[1]:n>i[1]&&n<s[1]||i[1]===s[1]&&n===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&n===s[1]&&e<s[0]||i[1]<s[1]&&n===i[1]&&e>=i[0]}};Cp=mn([ze(1,J0),ze(2,ui),ze(3,Ys),ze(4,fo),ze(5,Tl),ze(6,ha)],Cp);function Ey(t,e,n){for(;t.length<n;)t=e+t;return t}var jE=class{constructor(e,n){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let i=e.createElement("span");i.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let a=e.createElement("span");a.classList.add("xterm-char-measure-element"),a.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=[i,s,a,l],this._container.appendChild(i),this._container.appendChild(s),this._container.appendChild(a),this._container.appendChild(l),n.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,n,i,s){e===this._font&&n===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=n,this._weight=i,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,n,i){let s=0;if(!n&&!i&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let d=this._measure(e,0);return d>0&&(this._flat[s]=d),d}let a=e;n&&(a+="B"),i&&(a+="I");let l=this._holey.get(a);if(l===void 0){let d=0;n&&(d|=1),i&&(d|=2),l=this._measure(e,d),l>0&&this._holey.set(a,l)}return l}_measure(e,n){let i=this._measureElements[n];return i.textContent=e.repeat(32),i.offsetWidth/32}},PE=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,n,i,s=!1){if(this.selectionStart=n,this.selectionEnd=i,!n||!i||n[0]===i[0]&&n[1]===i[1]){this.clear();return}let a=e.buffers.active.ydisp,l=n[1]-a,d=i[1]-a,h=Math.max(l,0),f=Math.min(d,e.rows-1);if(h>=e.rows||f<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=l,this.viewportEndRow=d,this.viewportCappedStartRow=h,this.viewportCappedEndRow=f,this.startCol=n[0],this.endCol=i[0]}isCellSelected(e,n,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?n>=this.startCol&&i>=this.viewportCappedStartRow&&n<this.endCol&&i<=this.viewportCappedEndRow:n<this.startCol&&i>=this.viewportCappedStartRow&&n>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&n>=this.startCol&&n<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&n<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&n>=this.startCol):!1}};function TE(){return new PE}var Wh="xterm-dom-renderer-owner-",Hi="xterm-rows",Gc="xterm-fg-",Ny="xterm-bg-",Za="xterm-focus",Xc="xterm-selection",DE=1,kp=class extends yt{constructor(e,n,i,s,a,l,d,h,f,g,y,_,w,b){super(),this._terminal=e,this._document=n,this._element=i,this._screenElement=s,this._viewportElement=a,this._helperContainer=l,this._linkifier2=d,this._charSizeService=f,this._optionsService=g,this._bufferService=y,this._coreService=_,this._coreBrowserService=w,this._themeService=b,this._terminalClass=DE++,this._rowElements=[],this._selectionRenderModel=TE(),this.onRequestRedraw=this._register(new Le).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Hi),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Xc),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=AE(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(N=>this._injectCss(N))),this._injectCss(this._themeService.colors),this._rowFactory=h.createInstance(Cp,document),this._element.classList.add(Wh+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(N=>this._handleLinkHover(N))),this._register(this._linkifier2.onHideLinkUnderline(N=>this._handleLinkLeave(N))),this._register(en(()=>{this._element.classList.remove(Wh+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new jE(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 i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let n=`${this._terminalSelector} .${Hi} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=n,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let n=`${this._terminalSelector} .${Hi} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;n+=`${this._terminalSelector} .${Hi} .xterm-dim { color: ${Xt.multiplyOpacity(e.foreground,.5).css};}`,n+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,a=`blink_block_${this._terminalClass}`;n+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,n+=`@keyframes ${s} { 50% { box-shadow: none; }}`,n+=`@keyframes ${a} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,n+=`${this._terminalSelector} .${Hi}.${Za} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Hi}.${Za} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Hi}.${Za} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${a} 1s step-end infinite;}${this._terminalSelector} .${Hi} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Hi} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Hi} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Hi} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Hi} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,n+=`${this._terminalSelector} .${Xc} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Xc} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Xc} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[l,d]of e.ansi.entries())n+=`${this._terminalSelector} .${Gc}${l} { color: ${d.css}; }${this._terminalSelector} .${Gc}${l}.xterm-dim { color: ${Xt.multiplyOpacity(d,.5).css}; }${this._terminalSelector} .${Ny}${l} { background-color: ${d.css}; }`;n+=`${this._terminalSelector} .${Gc}257 { color: ${Xt.opaque(e.background).css}; }${this._terminalSelector} .${Gc}257.xterm-dim { color: ${Xt.multiplyOpacity(Xt.opaque(e.background),.5).css}; }${this._terminalSelector} .${Ny}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=n}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,n){for(let i=this._rowElements.length;i<=n;i++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>n;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,n){this._refreshRowElements(e,n),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Za),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Za),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,n,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,n,i),this.renderRows(0,this._bufferService.rows-1),!e||!n||(this._selectionRenderModel.update(this._terminal,e,n,i),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,a=this._selectionRenderModel.viewportEndRow,l=this._selectionRenderModel.viewportCappedStartRow,d=this._selectionRenderModel.viewportCappedEndRow,h=this._document.createDocumentFragment();if(i){let f=e[0]>n[0];h.appendChild(this._createSelectionElement(l,f?n[0]:e[0],f?e[0]:n[0],d-l+1))}else{let f=s===l?e[0]:0,g=l===a?n[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(l,f,g));let y=d-l-1;if(h.appendChild(this._createSelectionElement(l+1,0,this._bufferService.cols,y)),l!==d){let _=a===d?n[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(d,0,_))}}this._selectionContainer.appendChild(h)}_createSelectionElement(e,n,i,s=1){let a=this._document.createElement("div"),l=n*this.dimensions.css.cell.width,d=this.dimensions.css.cell.width*(i-n);return l+d>this.dimensions.css.canvas.width&&(d=this.dimensions.css.canvas.width-l),a.style.height=`${s*this.dimensions.css.cell.height}px`,a.style.top=`${e*this.dimensions.css.cell.height}px`,a.style.left=`${l}px`,a.style.width=`${d}px`,a}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,n){let i=this._bufferService.buffer,s=i.ybase+i.y,a=Math.min(i.x,this._bufferService.cols-1),l=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,d=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,h=this._optionsService.rawOptions.cursorInactiveStyle;for(let f=e;f<=n;f++){let g=f+i.ydisp,y=this._rowElements[f],_=i.lines.get(g);if(!y||!_)break;y.replaceChildren(...this._rowFactory.createRow(_,g,g===s,d,h,a,l,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Wh}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,n,i,s,a,l){i<0&&(e=0),s<0&&(n=0);let d=this._bufferService.rows-1;i=Math.max(Math.min(i,d),0),s=Math.max(Math.min(s,d),0),a=Math.min(a,this._bufferService.cols);let h=this._bufferService.buffer,f=h.ybase+h.y,g=Math.min(h.x,a-1),y=this._optionsService.rawOptions.cursorBlink,_=this._optionsService.rawOptions.cursorStyle,w=this._optionsService.rawOptions.cursorInactiveStyle;for(let b=i;b<=s;++b){let N=b+h.ydisp,x=this._rowElements[b],E=h.lines.get(N);if(!x||!E)break;x.replaceChildren(...this._rowFactory.createRow(E,N,N===f,_,w,g,y,this.dimensions.css.cell.width,this._widthCache,l?b===i?e:0:-1,l?(b===s?n:a)-1:-1))}}};kp=mn([ze(7,Em),ze(8,Vu),ze(9,ui),ze(10,ci),ze(11,fo),ze(12,Ys),ze(13,ha)],kp);var Ep=class extends yt{constructor(e,n,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Le),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new BE(this._optionsService))}catch{this._measureStrategy=this._register(new IE(e,n,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Ep=mn([ze(2,ui)],Ep);var vS=class extends yt{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(t,e){t!==void 0&&t>0&&e!==void 0&&e>0&&(this._result.width=t,this._result.height=e)}},IE=class extends vS{constructor(t,e,n){super(),this._document=t,this._parentElement=e,this._optionsService=n,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},BE=class extends vS{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let n=this._ctx.measureText("W");if(!("width"in n&&"fontBoundingBoxAscent"in n&&"fontBoundingBoxDescent"in n))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},OE=class extends yt{constructor(e,n,i){super(),this._textarea=e,this._window=n,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new $E(this._window)),this._onDprChange=this._register(new Le),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Le),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Yn.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(lt(this._textarea,"focus",()=>this._isFocused=!0)),this._register(lt(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}},$E=class extends yt{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new aa),this._onDprChange=this._register(new Le),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(en(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=lt(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)}},zE=class extends yt{constructor(){super(),this.linkProviders=[],this._register(en(()=>this.linkProviders.length=0))}registerLinkProvider(t){return this.linkProviders.push(t),{dispose:()=>{let e=this.linkProviders.indexOf(t);e!==-1&&this.linkProviders.splice(e,1)}}}};function Tm(t,e,n){let i=n.getBoundingClientRect(),s=t.getComputedStyle(n),a=parseInt(s.getPropertyValue("padding-left")),l=parseInt(s.getPropertyValue("padding-top"));return[e.clientX-i.left-a,e.clientY-i.top-l]}function FE(t,e,n,i,s,a,l,d,h){if(!a)return;let f=Tm(t,e,n);if(f)return f[0]=Math.ceil((f[0]+(h?l/2:0))/l),f[1]=Math.ceil(f[1]/d),f[0]=Math.min(Math.max(f[0],1),i+(h?1:0)),f[1]=Math.min(Math.max(f[1],1),s),f}var Np=class{constructor(e,n){this._renderService=e,this._charSizeService=n}getCoords(e,n,i,s,a){return FE(window,e,n,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,a)}getMouseReportCoords(e,n){let i=Tm(window,e,n);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};Np=mn([ze(0,Gs),ze(1,Vu)],Np);var HE=class{constructor(e,n){this._renderCallback=e,this._coreBrowserService=n,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,n,i){this._rowCount=i,e=e!==void 0?e:0,n=n!==void 0?n:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,n):n,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),n=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,n),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},_S={};J2(_S,{getSafariVersion:()=>WE,isChromeOS:()=>SS,isFirefox:()=>yS,isIpad:()=>qE,isIphone:()=>KE,isLegacyEdge:()=>UE,isLinux:()=>Dm,isMac:()=>Pu,isNode:()=>Yu,isSafari:()=>wS,isWindows:()=>bS});var Yu=typeof process<"u"&&"title"in process,Dl=Yu?"node":navigator.userAgent,Il=Yu?"node":navigator.platform,yS=Dl.includes("Firefox"),UE=Dl.includes("Edge"),wS=/^((?!chrome|android).)*safari/i.test(Dl);function WE(){if(!wS)return 0;let t=Dl.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}var Pu=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Il),qE=Il==="iPad",KE=Il==="iPhone",bS=["Windows","Win16","Win32","WinCE"].includes(Il),Dm=Il.indexOf("Linux")>=0,SS=/\bCrOS\b/.test(Dl),xS=class{constructor(){this._tasks=[],this._i=0}enqueue(t){this._tasks.push(t),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(t){this._idleCallback=void 0;let e=0,n=0,i=t.timeRemaining(),s=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),n=Math.max(e,n),s=t.timeRemaining(),n*1.5>s){i-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-e))}ms`),this._start();return}i=s}this.clear()}},VE=class extends xS{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let n=performance.now()+e;return{timeRemaining:()=>Math.max(0,n-performance.now())}}},YE=class extends xS{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},Tu=!Yu&&"requestIdleCallback"in window?YE:VE,GE=class{constructor(){this._queue=new Tu}set(t){this._queue.clear(),this._queue.enqueue(t)}flush(){this._queue.flush()}},Lp=class extends yt{constructor(e,n,i,s,a,l,d,h,f){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=a,this._coreBrowserService=h,this._renderer=this._register(new aa),this._pausedResizeTask=new GE,this._observerDisposable=this._register(new aa),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 Le),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Le),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Le),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Le),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new HE((g,y)=>this._renderRows(g,y),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new XE(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(en(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(d.onResize(()=>this._fullRefresh())),this._register(d.buffers.onBufferActivate(()=>{var g;return(g=this._renderer.value)==null?void 0:g.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(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(d.cols,d.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(d.buffer.y,d.buffer.y,!0))),this._register(f.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,n),this._register(this._coreBrowserService.onWindowChange(g=>this._registerIntersectionObserver(g,n)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,n){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});i.observe(n),this._observerDisposable.value=en(()=>i.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,n,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,n);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),n=Math.max(n,s.end)),i||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,n,this._rowCount)}_renderRows(e,n){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,n);return}e=Math.min(e,this._rowCount-1),n=Math.min(n,this._rowCount-1),this._renderer.value.renderRows(e,n),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:n}),this._onRender.fire({start:e,end:n}),this._isNextRenderRedrawOnly=!0}}resize(e,n){this._rowCount=n,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(n=>this.refreshRows(n.start,n.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,n;this._renderer.value&&((n=(e=this._renderer.value).clearTextureAtlas)==null||n.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,n){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var i;return(i=this._renderer.value)==null?void 0:i.handleResize(e,n)}):this._renderer.value.handleResize(e,n),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,n,i){var s;this._selectionState.start=e,this._selectionState.end=n,this._selectionState.columnSelectMode=i,(s=this._renderer.value)==null||s.handleSelectionChanged(e,n,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Lp=mn([ze(2,ui),ze(3,Vu),ze(4,fo),ze(5,Tl),ze(6,ci),ze(7,Ys),ze(8,ha)],Lp);var XE=class{constructor(t,e,n){this._coreBrowserService=t,this._coreService=e,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(t,e){this._isBuffering?(this._start=Math.min(this._start,t),this._end=Math.max(this._end,e)):(this._start=t,this._end=e,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let t={start:this._start,end:this._end};return this._isBuffering=!1,t}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function QE(t,e,n,i){let s=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return eN(s,a,t,e,n,i)+Gu(a,e,n,i)+tN(s,a,t,e,n,i);let l;if(a===e)return l=s>t?"D":"C",El(Math.abs(s-t),kl(l,i));l=a>e?"D":"C";let d=Math.abs(a-e),h=ZE(a>e?t:s,n)+(d-1)*n.cols+1+JE(a>e?s:t);return El(h,kl(l,i))}function JE(t,e){return t-1}function ZE(t,e){return e.cols-t}function eN(t,e,n,i,s,a){return Gu(e,i,s,a).length===0?"":El(kS(t,e,t,e-uo(e,s),!1,s).length,kl("D",a))}function Gu(t,e,n,i){let s=t-uo(t,n),a=e-uo(e,n),l=Math.abs(s-a)-nN(t,e,n);return El(l,kl(CS(t,e),i))}function tN(t,e,n,i,s,a){let l;Gu(e,i,s,a).length>0?l=i-uo(i,s):l=e;let d=i,h=iN(t,e,n,i,s,a);return El(kS(t,l,n,d,h==="C",s).length,kl(h,a))}function nN(t,e,n){var l;let i=0,s=t-uo(t,n),a=e-uo(e,n);for(let d=0;d<Math.abs(s-a);d++){let h=CS(t,e)==="A"?-1:1;(l=n.buffer.lines.get(s+h*d))!=null&&l.isWrapped&&i++}return i}function uo(t,e){let n=0,i=e.buffer.lines.get(t),s=i==null?void 0:i.isWrapped;for(;s&&t>=0&&t<e.rows;)n++,i=e.buffer.lines.get(--t),s=i==null?void 0:i.isWrapped;return n}function iN(t,e,n,i,s,a){let l;return Gu(n,i,s,a).length>0?l=i-uo(i,s):l=e,t<n&&l<=i||t>=n&&l<i?"C":"D"}function CS(t,e){return t>e?"A":"B"}function kS(t,e,n,i,s,a){let l=t,d=e,h="";for(;(l!==n||d!==i)&&d>=0&&d<a.buffer.lines.length;)l+=s?1:-1,s&&l>a.cols-1?(h+=a.buffer.translateBufferLineToString(d,!1,t,l),l=0,t=0,d++):!s&&l<0&&(h+=a.buffer.translateBufferLineToString(d,!1,0,t+1),l=a.cols-1,t=l,d--);return h+a.buffer.translateBufferLineToString(d,!1,t,l)}function kl(t,e){let n=e?"O":"[";return ve.ESC+n+t}function El(t,e){t=Math.floor(t);let n="";for(let i=0;i<t;i++)n+=e;return n}var sN=class{constructor(t){this._bufferService=t,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?t%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)-1]:[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[t,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[Math.max(t,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let t=this.selectionStart,e=this.selectionEnd;return!t||!e?!1:t[1]>e[1]||t[1]===e[1]&&t[0]>e[0]}handleTrim(t){return this.selectionStart&&(this.selectionStart[1]-=t),this.selectionEnd&&(this.selectionEnd[1]-=t),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Ly(t,e){if(t.start.y>t.end.y)throw new Error(`Buffer range end (${t.end.x}, ${t.end.y}) cannot be before start (${t.start.x}, ${t.start.y})`);return e*(t.end.y-t.start.y)+(t.end.x-t.start.x+1)}var qh=50,rN=15,oN=50,aN=500,lN=" ",cN=new RegExp(lN,"g"),Rp=class extends yt{constructor(e,n,i,s,a,l,d,h,f){super(),this._element=e,this._screenElement=n,this._linkifier=i,this._bufferService=s,this._coreService=a,this._mouseService=l,this._optionsService=d,this._renderService=h,this._coreBrowserService=f,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Yi,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Le),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Le),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Le),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Le),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=g=>this._handleMouseMove(g),this._mouseUpListener=g=>this._handleMouseUp(g),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(g=>this._handleTrim(g)),this._register(this._bufferService.buffers.onBufferActivate(g=>this._handleBufferActivate(g))),this.enable(),this._model=new sN(this._bufferService),this._activeSelectionMode=0,this._register(en(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(g=>{g.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!e||!n?!1:e[0]!==n[0]||e[1]!==n[1]}get selectionText(){let e=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;if(!e||!n)return"";let i=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===n[0])return"";let a=e[0]<n[0]?e[0]:n[0],l=e[0]<n[0]?n[0]:e[0];for(let d=e[1];d<=n[1];d++){let h=i.translateBufferLineToString(d,!0,a,l);s.push(h)}}else{let a=e[1]===n[1]?n[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],a));for(let l=e[1]+1;l<=n[1]-1;l++){let d=i.lines.get(l),h=i.translateBufferLineToString(l,!0);d!=null&&d.isWrapped?s[s.length-1]+=h:s.push(h)}if(e[1]!==n[1]){let l=i.lines.get(n[1]),d=i.translateBufferLineToString(n[1],!0,0,n[0]);l&&l.isWrapped?s[s.length-1]+=d:s.push(d)}}return s.map(a=>a.replace(cN," ")).join(bS?`\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())),Dm&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let n=this._getMouseBufferCoords(e),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s||!n?!1:this._areCoordsInSelection(n,i,s)}isCellInSelection(e,n){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([e,n],i,s)}_areCoordsInSelection(e,n,i){return e[1]>n[1]&&e[1]<i[1]||n[1]===i[1]&&e[1]===n[1]&&e[0]>=n[0]&&e[0]<i[0]||n[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||n[1]<i[1]&&e[1]===n[1]&&e[0]>=n[0]}_selectWordAtCursor(e,n){var a,l;let i=(l=(a=this._linkifier.currentLink)==null?void 0:a.link)==null?void 0:l.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=Ly(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,n),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,n){this._model.clearSelection(),e=Math.max(e,0),n=Math.min(n,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,n],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let n=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(n)return n[0]--,n[1]--,n[1]+=this._bufferService.buffer.ydisp,n}_getMouseEventScrollAmount(e){let n=Tm(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return n>=0&&n<=i?0:(n>i&&(n-=i),n=Math.min(Math.max(n,-qh),qh),n/=qh,n/Math.abs(n)+Math.round(n*(rN-1)))}shouldForceSelection(e){return Pu?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(),oN)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let n=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);n&&n.length!==this._model.selectionStart[0]&&n.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let n=this._getMouseBufferCoords(e);n&&(this._activeSelectionMode=2,this._selectLineAt(n[1]))}shouldColumnSelect(e){return e.altKey&&!(Pu&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let n=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let s=i.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]++}(!n||n[0]!==this._model.selectionEnd[0]||n[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let n=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&n<aN&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&i[0]!==void 0&&i[1]!==void 0){let s=QE(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,n=this._model.finalSelectionEnd,i=!!e&&!!n&&(e[0]!==n[0]||e[1]!==n[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,n,i);return}!e||!n||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||n[0]!==this._oldSelectionEnd[0]||n[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,n,i)}_fireOnSelectionChange(e,n,i){this._oldSelectionStart=e,this._oldSelectionEnd=n,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(n=>this._handleTrim(n))}_convertViewportColToCharacterIndex(e,n){let i=n;for(let s=0;n>=s;s++){let a=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:a>1&&n!==s&&(i+=a-1)}return i}setSelection(e,n,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,n],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,n,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let a=this._bufferService.buffer,l=a.lines.get(e[1]);if(!l)return;let d=a.translateBufferLineToString(e[1],!1),h=this._convertViewportColToCharacterIndex(l,e[0]),f=h,g=e[0]-h,y=0,_=0,w=0,b=0;if(d.charAt(h)===" "){for(;h>0&&d.charAt(h-1)===" ";)h--;for(;f<d.length&&d.charAt(f+1)===" ";)f++}else{let E=e[0],C=e[0];l.getWidth(E)===0&&(y++,E--),l.getWidth(C)===2&&(_++,C++);let I=l.getString(C).length;for(I>1&&(b+=I-1,f+=I-1);E>0&&h>0&&!this._isCharWordSeparator(l.loadCell(E-1,this._workCell));){l.loadCell(E-1,this._workCell);let T=this._workCell.getChars().length;this._workCell.getWidth()===0?(y++,E--):T>1&&(w+=T-1,h-=T-1),h--,E--}for(;C<l.length&&f+1<d.length&&!this._isCharWordSeparator(l.loadCell(C+1,this._workCell));){l.loadCell(C+1,this._workCell);let T=this._workCell.getChars().length;this._workCell.getWidth()===2?(_++,C++):T>1&&(b+=T-1,f+=T-1),f++,C++}}f++;let N=h+g-y+w,x=Math.min(this._bufferService.cols,f-h+y+_-w-b);if(!(!n&&d.slice(h,f).trim()==="")){if(i&&N===0&&l.getCodePoint(0)!==32){let E=a.lines.get(e[1]-1);if(E&&l.isWrapped&&E.getCodePoint(this._bufferService.cols-1)!==32){let C=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(C){let I=this._bufferService.cols-C.start;N-=I,x+=I}}}if(s&&N+x===this._bufferService.cols&&l.getCodePoint(this._bufferService.cols-1)!==32){let E=a.lines.get(e[1]+1);if(E!=null&&E.isWrapped&&E.getCodePoint(0)!==32){let C=this._getWordAt([0,e[1]+1],!1,!1,!0);C&&(x+=C.length)}}return{start:N,length:x}}}_selectWordAt(e,n){let i=this._getWordAt(e,n);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let n=this._getWordAt(e,!0);if(n){let i=e[1];for(;n.start<0;)n.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;n.start+n.length>this._bufferService.cols;)n.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?n.start:n.start+n.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let n=this._bufferService.buffer.getWrappedRangeForLine(e),i={start:{x:0,y:n.first},end:{x:this._bufferService.cols-1,y:n.last}};this._model.selectionStart=[0,n.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Ly(i,this._bufferService.cols)}};Rp=mn([ze(3,ci),ze(4,fo),ze(5,Nm),ze(6,ui),ze(7,Gs),ze(8,Ys)],Rp);var Ry=class{constructor(){this._data={}}set(e,n,i){this._data[e]||(this._data[e]={}),this._data[e][n]=i}get(e,n){return this._data[e]?this._data[e][n]:void 0}clear(){this._data={}}},My=class{constructor(){this._color=new Ry,this._css=new Ry}setCss(e,n,i){this._css.set(e,n,i)}getCss(e,n){return this._css.get(e,n)}setColor(e,n,i){this._color.set(e,n,i)}getColor(e,n){return this._color.get(e,n)}clear(){this._color.clear(),this._css.clear()}},Nn=Object.freeze((()=>{let t=[on.toColor("#2e3436"),on.toColor("#cc0000"),on.toColor("#4e9a06"),on.toColor("#c4a000"),on.toColor("#3465a4"),on.toColor("#75507b"),on.toColor("#06989a"),on.toColor("#d3d7cf"),on.toColor("#555753"),on.toColor("#ef2929"),on.toColor("#8ae234"),on.toColor("#fce94f"),on.toColor("#729fcf"),on.toColor("#ad7fa8"),on.toColor("#34e2e2"),on.toColor("#eeeeec")],e=[0,95,135,175,215,255];for(let n=0;n<216;n++){let i=e[n/36%6|0],s=e[n/6%6|0],a=e[n%6];t.push({css:Cn.toCss(i,s,a),rgba:Cn.toRgba(i,s,a)})}for(let n=0;n<24;n++){let i=8+n*10;t.push({css:Cn.toCss(i,i,i),rgba:Cn.toRgba(i,i,i)})}return t})()),Jr=on.toColor("#ffffff"),ml=on.toColor("#000000"),Ay=on.toColor("#ffffff"),jy=ml,el={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},uN=Jr,Mp=class extends yt{constructor(e){super(),this._optionsService=e,this._contrastCache=new My,this._halfContrastCache=new My,this._onChangeColors=this._register(new Le),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Jr,background:ml,cursor:Ay,cursorAccent:jy,selectionForeground:void 0,selectionBackgroundTransparent:el,selectionBackgroundOpaque:Xt.blend(ml,el),selectionInactiveBackgroundTransparent:el,selectionInactiveBackgroundOpaque:Xt.blend(ml,el),scrollbarSliderBackground:Xt.opacity(Jr,.2),scrollbarSliderHoverBackground:Xt.opacity(Jr,.4),scrollbarSliderActiveBackground:Xt.opacity(Jr,.5),overviewRulerBorder:Jr,ansi:Nn.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let n=this._colors;if(n.foreground=zt(e.foreground,Jr),n.background=zt(e.background,ml),n.cursor=Xt.blend(n.background,zt(e.cursor,Ay)),n.cursorAccent=Xt.blend(n.background,zt(e.cursorAccent,jy)),n.selectionBackgroundTransparent=zt(e.selectionBackground,el),n.selectionBackgroundOpaque=Xt.blend(n.background,n.selectionBackgroundTransparent),n.selectionInactiveBackgroundTransparent=zt(e.selectionInactiveBackground,n.selectionBackgroundTransparent),n.selectionInactiveBackgroundOpaque=Xt.blend(n.background,n.selectionInactiveBackgroundTransparent),n.selectionForeground=e.selectionForeground?zt(e.selectionForeground,ky):void 0,n.selectionForeground===ky&&(n.selectionForeground=void 0),Xt.isOpaque(n.selectionBackgroundTransparent)&&(n.selectionBackgroundTransparent=Xt.opacity(n.selectionBackgroundTransparent,.3)),Xt.isOpaque(n.selectionInactiveBackgroundTransparent)&&(n.selectionInactiveBackgroundTransparent=Xt.opacity(n.selectionInactiveBackgroundTransparent,.3)),n.scrollbarSliderBackground=zt(e.scrollbarSliderBackground,Xt.opacity(n.foreground,.2)),n.scrollbarSliderHoverBackground=zt(e.scrollbarSliderHoverBackground,Xt.opacity(n.foreground,.4)),n.scrollbarSliderActiveBackground=zt(e.scrollbarSliderActiveBackground,Xt.opacity(n.foreground,.5)),n.overviewRulerBorder=zt(e.overviewRulerBorder,uN),n.ansi=Nn.slice(),n.ansi[0]=zt(e.black,Nn[0]),n.ansi[1]=zt(e.red,Nn[1]),n.ansi[2]=zt(e.green,Nn[2]),n.ansi[3]=zt(e.yellow,Nn[3]),n.ansi[4]=zt(e.blue,Nn[4]),n.ansi[5]=zt(e.magenta,Nn[5]),n.ansi[6]=zt(e.cyan,Nn[6]),n.ansi[7]=zt(e.white,Nn[7]),n.ansi[8]=zt(e.brightBlack,Nn[8]),n.ansi[9]=zt(e.brightRed,Nn[9]),n.ansi[10]=zt(e.brightGreen,Nn[10]),n.ansi[11]=zt(e.brightYellow,Nn[11]),n.ansi[12]=zt(e.brightBlue,Nn[12]),n.ansi[13]=zt(e.brightMagenta,Nn[13]),n.ansi[14]=zt(e.brightCyan,Nn[14]),n.ansi[15]=zt(e.brightWhite,Nn[15]),e.extendedAnsi){let i=Math.min(n.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)n.ansi[s+16]=zt(e.extendedAnsi[s],Nn[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 n=0;n<this._restoreColors.ansi.length;++n)this._colors.ansi[n]=this._restoreColors.ansi[n];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};Mp=mn([ze(0,ui)],Mp);function zt(t,e){if(t!==void 0)try{return on.toColor(t)}catch{}return e}var dN=class{constructor(...e){this._entries=new Map;for(let[n,i]of e)this.set(n,i)}set(e,n){let i=this._entries.get(e);return this._entries.set(e,n),i}forEach(e){for(let[n,i]of this._entries.entries())e(n,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},hN=class{constructor(){this._services=new dN,this._services.set(Em,this)}setService(t,e){this._services.set(t,e)}getService(t){return this._services.get(t)}createInstance(t,...e){let n=r5(t).sort((a,l)=>a.index-l.index),i=[];for(let a of n){let l=this._services.get(a.id);if(!l)throw new Error(`[createInstance] ${t.name} depends on UNKNOWN service ${a.id._id}.`);i.push(l)}let s=n.length>0?n[0].index:e.length;if(e.length!==s)throw new Error(`[createInstance] First service dependency of ${t.name} at position ${s+1} conflicts with ${e.length} static arguments`);return new t(...e,...i)}},fN={trace:0,debug:1,info:2,warn:3,error:4,off:5},pN="xterm.js: ",Ap=class extends yt{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=fN[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let n=0;n<e.length;n++)typeof e[n]=="function"&&(e[n]=e[n]())}_log(e,n,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":pN)+n,...i)}trace(e,...n){var i;this._logLevel<=0&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,n)}debug(e,...n){var i;this._logLevel<=1&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,n)}info(e,...n){var i;this._logLevel<=2&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,n)}warn(e,...n){var i;this._logLevel<=3&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,n)}error(e,...n){var i;this._logLevel<=4&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,n)}};Ap=mn([ze(0,ui)],Ap);var Py=class extends yt{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Le),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Le),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Le),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let n=new Array(e);for(let i=0;i<Math.min(e,this.length);i++)n[i]=this._array[this._getCyclicIndex(i)];this._array=n,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let n=this._length;n<e;n++)this._array[n]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,n){this._array[this._getCyclicIndex(e)]=n}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,n,...i){if(n){for(let s=e;s<this._length-n;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+n)];this._length-=n,this.onDeleteEmitter.fire({index:e,amount:n})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,n,i){if(!(n<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let a=n-1;a>=0;a--)this.set(e+a+i,this.get(e+a));let s=e+n+i-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<n;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},_t=3,Sn=Object.freeze(new Pl),Qc=0,Kh=2,gl=class ES{constructor(e,n,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*_t);let s=n||Yi.fromCharData([0,q0,1,0]);for(let a=0;a<e;++a)this.setCell(a,s);this.length=e}get(e){let n=this._data[e*_t+0],i=n&2097151;return[this._data[e*_t+1],n&2097152?this._combined[e]:i?Cr(i):"",n>>22,n&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):i]}set(e,n){this._data[e*_t+1]=n[0],n[1].length>1?(this._combined[e]=n[1],this._data[e*_t+0]=e|2097152|n[2]<<22):this._data[e*_t+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(e){return this._data[e*_t+0]>>22}hasWidth(e){return this._data[e*_t+0]&12582912}getFg(e){return this._data[e*_t+1]}getBg(e){return this._data[e*_t+2]}hasContent(e){return this._data[e*_t+0]&4194303}getCodePoint(e){let n=this._data[e*_t+0];return n&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n&2097151}isCombined(e){return this._data[e*_t+0]&2097152}getString(e){let n=this._data[e*_t+0];return n&2097152?this._combined[e]:n&2097151?Cr(n&2097151):""}isProtected(e){return this._data[e*_t+2]&536870912}loadCell(e,n){return Qc=e*_t,n.content=this._data[Qc+0],n.fg=this._data[Qc+1],n.bg=this._data[Qc+2],n.content&2097152&&(n.combinedData=this._combined[e]),n.bg&268435456&&(n.extended=this._extendedAttrs[e]),n}setCell(e,n){n.content&2097152&&(this._combined[e]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[e]=n.extended),this._data[e*_t+0]=n.content,this._data[e*_t+1]=n.fg,this._data[e*_t+2]=n.bg}setCellFromCodepoint(e,n,i,s){s.bg&268435456&&(this._extendedAttrs[e]=s.extended),this._data[e*_t+0]=n|i<<22,this._data[e*_t+1]=s.fg,this._data[e*_t+2]=s.bg}addCodepointToCell(e,n,i){let s=this._data[e*_t+0];s&2097152?this._combined[e]+=Cr(n):s&2097151?(this._combined[e]=Cr(s&2097151)+Cr(n),s&=-2097152,s|=2097152):s=n|1<<22,i&&(s&=-12582913,s|=i<<22),this._data[e*_t+0]=s}insertCells(e,n,i){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,i),n<this.length-e){let s=new Yi;for(let a=this.length-e-n-1;a>=0;--a)this.setCell(e+n+a,this.loadCell(e+a,s));for(let a=0;a<n;++a)this.setCell(e+a,i)}else for(let s=e;s<this.length;++s)this.setCell(s,i);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,i)}deleteCells(e,n,i){if(e%=this.length,n<this.length-e){let s=new Yi;for(let a=0;a<this.length-e-n;++a)this.setCell(e+a,this.loadCell(e+n+a,s));for(let a=this.length-n;a<this.length;++a)this.setCell(a,i)}else for(let s=e;s<this.length;++s)this.setCell(s,i);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,i),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,i)}replaceCells(e,n,i,s=!1){if(s){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,i),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,i);e<n&&e<this.length;)this.isProtected(e)||this.setCell(e,i),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,i),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,i);e<n&&e<this.length;)this.setCell(e++,i)}resize(e,n){if(e===this.length)return this._data.length*4*Kh<this._data.buffer.byteLength;let i=e*_t;if(e>this.length){if(this._data.buffer.byteLength>=i*4)this._data=new Uint32Array(this._data.buffer,0,i);else{let s=new Uint32Array(i);s.set(this._data),this._data=s}for(let s=this.length;s<e;++s)this.setCell(s,n)}else{this._data=this._data.subarray(0,i);let s=Object.keys(this._combined);for(let l=0;l<s.length;l++){let d=parseInt(s[l],10);d>=e&&delete this._combined[d]}let a=Object.keys(this._extendedAttrs);for(let l=0;l<a.length;l++){let d=parseInt(a[l],10);d>=e&&delete this._extendedAttrs[d]}}return this.length=e,i*4*Kh<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Kh<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,n=!1){if(n){for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,e);return}this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,e)}copyFrom(e){this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={};for(let n in e._combined)this._combined[n]=e._combined[n];this._extendedAttrs={};for(let n in e._extendedAttrs)this._extendedAttrs[n]=e._extendedAttrs[n];this.isWrapped=e.isWrapped}clone(){let e=new ES(0);e._data=new Uint32Array(this._data),e.length=this.length;for(let n in this._combined)e._combined[n]=this._combined[n];for(let n in this._extendedAttrs)e._extendedAttrs[n]=this._extendedAttrs[n];return e.isWrapped=this.isWrapped,e}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*_t+0]&4194303)return e+(this._data[e*_t+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*_t+0]&4194303||this._data[e*_t+2]&50331648)return e+(this._data[e*_t+0]>>22);return 0}copyCellsFrom(e,n,i,s,a){let l=e._data;if(a)for(let h=s-1;h>=0;h--){for(let f=0;f<_t;f++)this._data[(i+h)*_t+f]=l[(n+h)*_t+f];l[(n+h)*_t+2]&268435456&&(this._extendedAttrs[i+h]=e._extendedAttrs[n+h])}else for(let h=0;h<s;h++){for(let f=0;f<_t;f++)this._data[(i+h)*_t+f]=l[(n+h)*_t+f];l[(n+h)*_t+2]&268435456&&(this._extendedAttrs[i+h]=e._extendedAttrs[n+h])}let d=Object.keys(e._combined);for(let h=0;h<d.length;h++){let f=parseInt(d[h],10);f>=n&&(this._combined[f-n+i]=e._combined[f])}}translateToString(e,n,i,s){n=n??0,i=i??this.length,e&&(i=Math.min(i,this.getTrimmedLength())),s&&(s.length=0);let a="";for(;n<i;){let l=this._data[n*_t+0],d=l&2097151,h=l&2097152?this._combined[n]:d?Cr(d):Er;if(a+=h,s)for(let f=0;f<h.length;++f)s.push(n);n+=l>>22||1}return s&&s.push(n),a}};function mN(t,e,n,i,s,a){let l=[];for(let d=0;d<t.length-1;d++){let h=d,f=t.get(++h);if(!f.isWrapped)continue;let g=[t.get(d)];for(;h<t.length&&f.isWrapped;)g.push(f),f=t.get(++h);if(!a&&i>=d&&i<h){d+=g.length-1;continue}let y=0,_=Nl(g,y,e),w=1,b=0;for(;w<g.length;){let x=Nl(g,w,e),E=x-b,C=n-_,I=Math.min(E,C);g[y].copyCellsFrom(g[w],b,_,I,!1),_+=I,_===n&&(y++,_=0),b+=I,b===x&&(w++,b=0),_===0&&y!==0&&g[y-1].getWidth(n-1)===2&&(g[y].copyCellsFrom(g[y-1],n-1,_++,1,!1),g[y-1].setCell(n-1,s))}g[y].replaceCells(_,n,s);let N=0;for(let x=g.length-1;x>0&&(x>y||g[x].getTrimmedLength()===0);x--)N++;N>0&&(l.push(d+g.length-N),l.push(N)),d+=g.length-1}return l}function gN(t,e){let n=[],i=0,s=e[i],a=0;for(let l=0;l<t.length;l++)if(s===l){let d=e[++i];t.onDeleteEmitter.fire({index:l-a,amount:d}),l+=d-1,a+=d,s=e[++i]}else n.push(l);return{layout:n,countRemoved:a}}function vN(t,e){let n=[];for(let i=0;i<e.length;i++)n.push(t.get(e[i]));for(let i=0;i<n.length;i++)t.set(i,n[i]);t.length=e.length}function _N(t,e,n){let i=[],s=t.map((h,f)=>Nl(t,f,e)).reduce((h,f)=>h+f),a=0,l=0,d=0;for(;d<s;){if(s-d<n){i.push(s-d);break}a+=n;let h=Nl(t,l,e);a>h&&(a-=h,l++);let f=t[l].getWidth(a-1)===2;f&&a--;let g=f?n-1:n;i.push(g),d+=g}return i}function Nl(t,e,n){if(e===t.length-1)return t[e].getTrimmedLength();let i=!t[e].hasContent(n-1)&&t[e].getWidth(n-1)===1,s=t[e+1].getWidth(0)===2;return i&&s?n-1:n}var NS=class LS{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=LS._nextId++,this._onDispose=this.register(new Le),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),co(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};NS._nextId=1;var yN=NS,Rn={},Zr=Rn.B;Rn[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Rn.A={"#":"£"};Rn.B=void 0;Rn[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Rn.C=Rn[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Rn.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Rn.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Rn.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Rn.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Rn.E=Rn[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Rn.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Rn.H=Rn[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Rn["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Ty=4294967295,Dy=class{constructor(t,e,n){this._hasScrollback=t,this._optionsService=e,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Sn.clone(),this.savedCharset=Zr,this.markers=[],this._nullCell=Yi.fromCharData([0,q0,1,0]),this._whitespaceCell=Yi.fromCharData([0,Er,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Tu,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Py(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(t){return t?(this._nullCell.fg=t.fg,this._nullCell.bg=t.bg,this._nullCell.extended=t.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new Mu),this._nullCell}getWhitespaceCell(t){return t?(this._whitespaceCell.fg=t.fg,this._whitespaceCell.bg=t.bg,this._whitespaceCell.extended=t.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new Mu),this._whitespaceCell}getBlankLine(t,e){return new gl(this._bufferService.cols,this.getNullCell(t),e)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let t=this.ybase+this.y-this.ydisp;return t>=0&&t<this._rows}_getCorrectBufferLength(t){if(!this._hasScrollback)return t;let e=t+this._optionsService.rawOptions.scrollback;return e>Ty?Ty:e}fillViewportRows(t){if(this.lines.length===0){t===void 0&&(t=Sn);let e=this._rows;for(;e--;)this.lines.push(this.getBlankLine(t))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Py(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let n=this.getNullCell(Sn),i=0,s=this._getCorrectBufferLength(e);if(s>this.lines.maxLength&&(this.lines.maxLength=s),this.lines.length>0){if(this._cols<t)for(let l=0;l<this.lines.length;l++)i+=+this.lines.get(l).resize(t,n);let a=0;if(this._rows<e)for(let l=this._rows;l<e;l++)this.lines.length<e+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new gl(t,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new gl(t,n)));else for(let l=this._rows;l>e;l--)this.lines.length>e+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(s<this.lines.maxLength){let l=this.lines.length-s;l>0&&(this.lines.trimStart(l),this.ybase=Math.max(this.ybase-l,0),this.ydisp=Math.max(this.ydisp-l,0),this.savedY=Math.max(this.savedY-l,0)),this.lines.maxLength=s}this.x=Math.min(this.x,t-1),this.y=Math.min(this.y,e-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,t-1),this.scrollTop=0}if(this.scrollBottom=e-1,this._isReflowEnabled&&(this._reflow(t,e),this._cols>t))for(let a=0;a<this.lines.length;a++)i+=+this.lines.get(a).resize(t,n);this._cols=t,this._rows=e,this._memoryCleanupQueue.clear(),i>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let t=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,t=!1);let e=0;for(;this._memoryCleanupPosition<this.lines.length;)if(e+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),e>100)return!0;return t}get _isReflowEnabled(){let t=this._optionsService.rawOptions.windowsPty;return t&&t.buildNumber?this._hasScrollback&&t.backend==="conpty"&&t.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(t,e){this._cols!==t&&(t>this._cols?this._reflowLarger(t,e):this._reflowSmaller(t,e))}_reflowLarger(t,e){let n=this._optionsService.rawOptions.reflowCursorLine,i=mN(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(Sn),n);if(i.length>0){let s=gN(this.lines,i);vN(this.lines,s.layout),this._reflowLargerAdjustViewport(t,e,s.countRemoved)}}_reflowLargerAdjustViewport(t,e,n){let i=this.getNullCell(Sn),s=n;for(;s-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new gl(t,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(t,e){let n=this._optionsService.rawOptions.reflowCursorLine,i=this.getNullCell(Sn),s=[],a=0;for(let l=this.lines.length-1;l>=0;l--){let d=this.lines.get(l);if(!d||!d.isWrapped&&d.getTrimmedLength()<=t)continue;let h=[d];for(;d.isWrapped&&l>0;)d=this.lines.get(--l),h.unshift(d);if(!n){let I=this.ybase+this.y;if(I>=l&&I<l+h.length)continue}let f=h[h.length-1].getTrimmedLength(),g=_N(h,this._cols,t),y=g.length-h.length,_;this.ybase===0&&this.y!==this.lines.length-1?_=Math.max(0,this.y-this.lines.maxLength+y):_=Math.max(0,this.lines.length-this.lines.maxLength+y);let w=[];for(let I=0;I<y;I++){let T=this.getBlankLine(Sn,!0);w.push(T)}w.length>0&&(s.push({start:l+h.length+a,newLines:w}),a+=w.length),h.push(...w);let b=g.length-1,N=g[b];N===0&&(b--,N=g[b]);let x=h.length-y-1,E=f;for(;x>=0;){let I=Math.min(E,N);if(h[b]===void 0)break;if(h[b].copyCellsFrom(h[x],E-I,N-I,I,!0),N-=I,N===0&&(b--,N=g[b]),E-=I,E===0){x--;let T=Math.max(x,0);E=Nl(h,T,this._cols)}}for(let I=0;I<h.length;I++)g[I]<t&&h[I].setCell(g[I],i);let C=y-_;for(;C-- >0;)this.ybase===0?this.y<e-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-e&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+y,this.ybase+e-1)}if(s.length>0){let l=[],d=[];for(let N=0;N<this.lines.length;N++)d.push(this.lines.get(N));let h=this.lines.length,f=h-1,g=0,y=s[g];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let _=0;for(let N=Math.min(this.lines.maxLength-1,h+a-1);N>=0;N--)if(y&&y.start>f+_){for(let x=y.newLines.length-1;x>=0;x--)this.lines.set(N--,y.newLines[x]);N++,l.push({index:f+1,amount:y.newLines.length}),_+=y.newLines.length,y=s[++g]}else this.lines.set(N,d[f--]);let w=0;for(let N=l.length-1;N>=0;N--)l[N].index+=w,this.lines.onInsertEmitter.fire(l[N]),w+=l[N].amount;let b=Math.max(0,h+a-this.lines.maxLength);b>0&&this.lines.onTrimEmitter.fire(b)}}translateBufferLineToString(t,e,n=0,i){let s=this.lines.get(t);return s?s.translateToString(e,n,i):""}getWrappedRangeForLine(t){let e=t,n=t;for(;e>0&&this.lines.get(e).isWrapped;)e--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:e,last:n}}setupTabStops(t){for(t!=null?this.tabs[t]||(t=this.prevStop(t)):(this.tabs={},t=0);t<this._cols;t+=this._optionsService.rawOptions.tabStopWidth)this.tabs[t]=!0}prevStop(t){for(t==null&&(t=this.x);!this.tabs[--t]&&t>0;);return t>=this._cols?this._cols-1:t<0?0:t}nextStop(t){for(t==null&&(t=this.x);!this.tabs[++t]&&t<this._cols;);return t>=this._cols?this._cols-1:t<0?0:t}clearMarkers(t){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].line===t&&(this.markers[e].dispose(),this.markers.splice(e--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].dispose();this.markers.length=0,this._isClearing=!1}addMarker(t){let e=new yN(t);return this.markers.push(e),e.register(this.lines.onTrim(n=>{e.line-=n,e.line<0&&e.dispose()})),e.register(this.lines.onInsert(n=>{e.line>=n.index&&(e.line+=n.amount)})),e.register(this.lines.onDelete(n=>{e.line>=n.index&&e.line<n.index+n.amount&&e.dispose(),e.line>n.index&&(e.line-=n.amount)})),e.register(e.onDispose(()=>this._removeMarker(e))),e}_removeMarker(t){this._isClearing||this.markers.splice(this.markers.indexOf(t),1)}},wN=class extends yt{constructor(e,n){super(),this._optionsService=e,this._bufferService=n,this._onBufferActivate=this._register(new Le),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 Dy(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Dy(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,n){this._normal.resize(e,n),this._alt.resize(e,n),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},RS=2,MS=1,jp=class extends yt{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new Le),this.onResize=this._onResize.event,this._onScroll=this._register(new Le),this.onScroll=this._onScroll.event,this.cols=Math.max(t.rawOptions.cols||0,RS),this.rows=Math.max(t.rawOptions.rows||0,MS),this.buffers=this._register(new wN(t,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(t,e){let n=this.cols!==t,i=this.rows!==e;this.cols=t,this.rows=e,this.buffers.resize(t,e),this._onResize.fire({cols:t,rows:e,colsChanged:n,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(t,e=!1){let n=this.buffer,i;i=this._cachedBlankLine,(!i||i.length!==this.cols||i.getFg(0)!==t.fg||i.getBg(0)!==t.bg)&&(i=n.getBlankLine(t,e),this._cachedBlankLine=i),i.isWrapped=e;let s=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let l=n.lines.isFull;a===n.lines.length-1?l?n.lines.recycle().copyFrom(i):n.lines.push(i.clone()):n.lines.splice(a+1,0,i.clone()),l?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let l=a-s+1;n.lines.shiftElements(s+1,l-1,-1),n.lines.set(a,i.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(t,e){let n=this.buffer;if(t<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else t+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let i=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+t,n.ybase),0),i!==n.ydisp&&(e||this._onScroll.fire(n.ydisp))}};jp=mn([ze(0,ui)],jp);var Uo={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:Pu,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},bN=["normal","bold","100","200","300","400","500","600","700","800","900"],SN=class extends yt{constructor(e){super(),this._onOptionChange=this._register(new Le),this.onOptionChange=this._onOptionChange.event;let n={...Uo};for(let i in e)if(i in n)try{let s=e[i];n[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=n,this.options={...n},this._setupOptions(),this._register(en(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,n){return this.onOptionChange(i=>{i===e&&n(this.rawOptions[e])})}onMultipleOptionChange(e,n){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&n()})}_setupOptions(){let e=i=>{if(!(i in Uo))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},n=(i,s)=>{if(!(i in Uo))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:n.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,n){switch(e){case"cursorStyle":if(n||(n=Uo[e]),!xN(n))throw new Error(`"${n}" is not a valid value for ${e}`);break;case"wordSeparator":n||(n=Uo[e]);break;case"fontWeight":case"fontWeightBold":if(typeof n=="number"&&1<=n&&n<=1e3)break;n=bN.includes(n)?n:Uo[e];break;case"cursorWidth":n=Math.floor(n);case"lineHeight":case"tabStopWidth":if(n<1)throw new Error(`${e} cannot be less than 1, value: ${n}`);break;case"minimumContrastRatio":n=Math.max(1,Math.min(21,Math.round(n*10)/10));break;case"scrollback":if(n=Math.min(n,4294967295),n<0)throw new Error(`${e} cannot be less than 0, value: ${n}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(n<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${n}`);break;case"rows":case"cols":if(!n&&n!==0)throw new Error(`${e} must be numeric, value: ${n}`);break;case"windowsPty":n=n??{};break}return n}};function xN(t){return t==="block"||t==="underline"||t==="bar"}function vl(t,e=5){if(typeof t!="object")return t;let n=Array.isArray(t)?[]:{};for(let i in t)n[i]=e<=1?t[i]:t[i]&&vl(t[i],e-1);return n}var Iy=Object.freeze({insertMode:!1}),By=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Pp=class extends yt{constructor(e,n,i){super(),this._bufferService=e,this._logService=n,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Le),this.onData=this._onData.event,this._onUserInput=this._register(new Le),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Le),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Le),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=vl(Iy),this.decPrivateModes=vl(By)}reset(){this.modes=vl(Iy),this.decPrivateModes=vl(By)}triggerDataEvent(e,n=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;n&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),n&&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(n=>n.charCodeAt(0))),this._onBinary.fire(e))}};Pp=mn([ze(0,ci),ze(1,X0),ze(2,ui)],Pp);var Oy={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:t=>t.button===4||t.action!==1?!1:(t.ctrl=!1,t.alt=!1,t.shift=!1,!0)},VT200:{events:19,restrict:t=>t.action!==32},DRAG:{events:23,restrict:t=>!(t.action===32&&t.button===3)},ANY:{events:31,restrict:t=>!0}};function Vh(t,e){let n=(t.ctrl?16:0)|(t.shift?4:0)|(t.alt?8:0);return t.button===4?(n|=64,n|=t.action):(n|=t.button&3,t.button&4&&(n|=64),t.button&8&&(n|=128),t.action===32?n|=32:t.action===0&&!e&&(n|=3)),n}var Yh=String.fromCharCode,$y={DEFAULT:t=>{let e=[Vh(t,!1)+32,t.col+32,t.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${Yh(e[0])}${Yh(e[1])}${Yh(e[2])}`},SGR:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${Vh(t,!0)};${t.col};${t.row}${e}`},SGR_PIXELS:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${Vh(t,!0)};${t.x};${t.y}${e}`}},Tp=class extends yt{constructor(t,e,n){super(),this._bufferService=t,this._coreService=e,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Le),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(Oy))this.addProtocol(i,Oy[i]);for(let i of Object.keys($y))this.addEncoding(i,$y[i]);this.reset()}addProtocol(t,e){this._protocols[t]=e}addEncoding(t,e){this._encodings[t]=e}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(t){if(!this._protocols[t])throw new Error(`unknown protocol "${t}"`);this._activeProtocol=t,this._onProtocolChange.fire(this._protocols[t].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(t){if(!this._encodings[t])throw new Error(`unknown encoding "${t}"`);this._activeEncoding=t}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(t,e,n){if(t.deltaY===0||t.shiftKey||e===void 0||n===void 0)return 0;let i=e/n,s=this._applyScrollModifier(t.deltaY,t);return t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(s/=i+0,Math.abs(t.deltaY)<50&&(s*=.3),this._wheelPartialScroll+=s,s=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):t.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(s*=this._bufferService.rows),s}_applyScrollModifier(t,e){return e.altKey||e.ctrlKey||e.shiftKey?t*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:t*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(t){if(t.col<0||t.col>=this._bufferService.cols||t.row<0||t.row>=this._bufferService.rows||t.button===4&&t.action===32||t.button===3&&t.action!==32||t.button!==4&&(t.action===2||t.action===3)||(t.col++,t.row++,t.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,t,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(t))return!1;let e=this._encodings[this._activeEncoding](t);return e&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(e):this._coreService.triggerDataEvent(e,!0)),this._lastEvent=t,!0}explainEvents(t){return{down:!!(t&1),up:!!(t&2),drag:!!(t&4),move:!!(t&8),wheel:!!(t&16)}}_equalEvents(t,e,n){if(n){if(t.x!==e.x||t.y!==e.y)return!1}else if(t.col!==e.col||t.row!==e.row)return!1;return!(t.button!==e.button||t.action!==e.action||t.ctrl!==e.ctrl||t.alt!==e.alt||t.shift!==e.shift)}};Tp=mn([ze(0,ci),ze(1,fo),ze(2,ui)],Tp);var Gh=[[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]],CN=[[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]],Ln;function kN(t,e){let n=0,i=e.length-1,s;if(t<e[0][0]||t>e[i][1])return!1;for(;i>=n;)if(s=n+i>>1,t>e[s][1])n=s+1;else if(t<e[s][0])i=s-1;else return!0;return!1}var EN=class{constructor(){if(this.version="6",!Ln){Ln=new Uint8Array(65536),Ln.fill(1),Ln[0]=0,Ln.fill(0,1,32),Ln.fill(0,127,160),Ln.fill(2,4352,4448),Ln[9001]=2,Ln[9002]=2,Ln.fill(2,11904,42192),Ln[12351]=1,Ln.fill(2,44032,55204),Ln.fill(2,63744,64256),Ln.fill(2,65040,65050),Ln.fill(2,65072,65136),Ln.fill(2,65280,65377),Ln.fill(2,65504,65511);for(let e=0;e<Gh.length;++e)Ln.fill(0,Gh[e][0],Gh[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Ln[e]:kN(e,CN)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,n){let i=this.wcwidth(e),s=i===0&&n!==0;if(s){let a=no.extractWidth(n);a===0?s=!1:a>i&&(i=a)}return no.createPropertyValue(0,i,s)}},no=class mu{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Le,this.onChange=this._onChange.event;let e=new EN;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!==0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,n,i=!1){return(e&16777215)<<3|(n&3)<<1|(i?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw new Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(e){let n=0,i=0,s=e.length;for(let a=0;a<s;++a){let l=e.charCodeAt(a);if(55296<=l&&l<=56319){if(++a>=s)return n+this.wcwidth(l);let f=e.charCodeAt(a);56320<=f&&f<=57343?l=(l-55296)*1024+f-56320+65536:n+=this.wcwidth(f)}let d=this.charProperties(l,i),h=mu.extractWidth(d);mu.extractShouldJoin(d)&&(h-=mu.extractWidth(i)),n+=h,i=d}return n}charProperties(e,n){return this._activeProvider.charProperties(e,n)}},NN=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,n){this._charsets[e]=n,this.glevel===e&&(this.charset=n)}};function zy(t){var i;let e=(i=t.buffer.lines.get(t.buffer.ybase+t.buffer.y-1))==null?void 0:i.get(t.cols-1),n=t.buffer.lines.get(t.buffer.ybase+t.buffer.y);n&&e&&(n.isWrapped=e[3]!==0&&e[3]!==32)}var tl=2147483647,LN=256,AS=class Dp{constructor(e=32,n=32){if(this.maxLength=e,this.maxSubParamsLength=n,n>LN)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(e){let n=new Dp;if(!e.length)return n;for(let i=Array.isArray(e[0])?1:0;i<e.length;++i){let s=e[i];if(Array.isArray(s))for(let a=0;a<s.length;++a)n.addSubParam(s[a]);else n.addParam(s)}return n}clone(){let e=new Dp(this.maxLength,this.maxSubParamsLength);return e.params.set(this.params),e.length=this.length,e._subParams.set(this._subParams),e._subParamsLength=this._subParamsLength,e._subParamsIdx.set(this._subParamsIdx),e._rejectDigits=this._rejectDigits,e._rejectSubDigits=this._rejectSubDigits,e._digitIsSub=this._digitIsSub,e}toArray(){let e=[];for(let n=0;n<this.length;++n){e.push(this.params[n]);let i=this._subParamsIdx[n]>>8,s=this._subParamsIdx[n]&255;s-i>0&&e.push(Array.prototype.slice.call(this._subParams,i,s))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>tl?tl:e}addSubParam(e){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>tl?tl:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let n=this._subParamsIdx[e]>>8,i=this._subParamsIdx[e]&255;return i-n>0?this._subParams.subarray(n,i):null}getSubParamsAll(){let e={};for(let n=0;n<this.length;++n){let i=this._subParamsIdx[n]>>8,s=this._subParamsIdx[n]&255;s-i>0&&(e[n]=this._subParams.slice(i,s))}return e}addDigit(e){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i=this._digitIsSub?this._subParams:this.params,s=i[n-1];i[n-1]=~s?Math.min(s*10+e,tl):e}},nl=[],RN=class{constructor(){this._state=0,this._active=nl,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,n){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(n),{dispose:()=>{let s=i.indexOf(n);s!==-1&&i.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=nl}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=nl,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||nl,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,n,i){if(!this._active.length)this._handlerFb(this._id,"PUT",Ku(e,n,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,n,i)}start(){this.reset(),this._state=1}put(e,n,i){if(this._state!==3){if(this._state===1)for(;n<i;){let s=e[n++];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&&i-n>0&&this._put(e,n,i)}}end(e,n=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let i=!1,s=this._active.length-1,a=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=n,a=this._stack.fallThrough,this._stack.paused=!1),!a&&i===!1){for(;s>=0&&(i=this._active[s].end(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=nl,this._id=-1,this._state=0}}},Ai=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,n,i){this._hitLimit||(this._data+=Ku(e,n,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let n=!1;if(this._hitLimit)n=!1;else if(e&&(n=this._handler(this._data),n instanceof Promise))return n.then(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,n}},il=[],MN=class{constructor(){this._handlers=Object.create(null),this._active=il,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=il}registerHandler(e,n){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(n),{dispose:()=>{let s=i.indexOf(n);s!==-1&&i.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=il,this._ident=0}hook(e,n){if(this.reset(),this._ident=e,this._active=this._handlers[e]||il,!this._active.length)this._handlerFb(this._ident,"HOOK",n);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(n)}put(e,n,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",Ku(e,n,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,n,i)}unhook(e,n=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,s=this._active.length-1,a=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=n,a=this._stack.fallThrough,this._stack.paused=!1),!a&&i===!1){for(;s>=0&&(i=this._active[s].unhook(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=il,this._ident=0}},_l=new AS;_l.addParam(0);var Fy=class{constructor(t){this._handler=t,this._data="",this._params=_l,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():_l,this._data="",this._hitLimit=!1}put(t,e,n){this._hitLimit||(this._data+=Ku(t,e,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(t){let e=!1;if(this._hitLimit)e=!1;else if(t&&(e=this._handler(this._data,this._params),e instanceof Promise))return e.then(n=>(this._params=_l,this._data="",this._hitLimit=!1,n));return this._params=_l,this._data="",this._hitLimit=!1,e}},AN=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,n){this.table.fill(e<<4|n)}add(e,n,i,s){this.table[n<<8|e]=i<<4|s}addMany(e,n,i,s){for(let a=0;a<e.length;a++)this.table[n<<8|e[a]]=i<<4|s}},Ki=160,jN=(function(){let t=new AN(4095),e=Array.apply(null,Array(256)).map((d,h)=>h),n=(d,h)=>e.slice(d,h),i=n(32,127),s=n(0,24);s.push(25),s.push.apply(s,n(28,32));let a=n(0,14),l;t.setDefault(1,0),t.addMany(i,0,2,0);for(l in a)t.addMany([24,26,153,154],l,3,0),t.addMany(n(128,144),l,3,0),t.addMany(n(144,152),l,3,0),t.add(156,l,0,0),t.add(27,l,11,1),t.add(157,l,4,8),t.addMany([152,158,159],l,0,7),t.add(155,l,11,3),t.add(144,l,11,9);return t.addMany(s,0,3,0),t.addMany(s,1,3,1),t.add(127,1,0,1),t.addMany(s,8,0,8),t.addMany(s,3,3,3),t.add(127,3,0,3),t.addMany(s,4,3,4),t.add(127,4,0,4),t.addMany(s,6,3,6),t.addMany(s,5,3,5),t.add(127,5,0,5),t.addMany(s,2,3,2),t.add(127,2,0,2),t.add(93,1,4,8),t.addMany(i,8,5,8),t.add(127,8,5,8),t.addMany([156,27,24,26,7],8,6,0),t.addMany(n(28,32),8,0,8),t.addMany([88,94,95],1,0,7),t.addMany(i,7,0,7),t.addMany(s,7,0,7),t.add(156,7,0,0),t.add(127,7,0,7),t.add(91,1,11,3),t.addMany(n(64,127),3,7,0),t.addMany(n(48,60),3,8,4),t.addMany([60,61,62,63],3,9,4),t.addMany(n(48,60),4,8,4),t.addMany(n(64,127),4,7,0),t.addMany([60,61,62,63],4,0,6),t.addMany(n(32,64),6,0,6),t.add(127,6,0,6),t.addMany(n(64,127),6,0,0),t.addMany(n(32,48),3,9,5),t.addMany(n(32,48),5,9,5),t.addMany(n(48,64),5,0,6),t.addMany(n(64,127),5,7,0),t.addMany(n(32,48),4,9,5),t.addMany(n(32,48),1,9,2),t.addMany(n(32,48),2,9,2),t.addMany(n(48,127),2,10,0),t.addMany(n(48,80),1,10,0),t.addMany(n(81,88),1,10,0),t.addMany([89,90,92],1,10,0),t.addMany(n(96,127),1,10,0),t.add(80,1,11,9),t.addMany(s,9,0,9),t.add(127,9,0,9),t.addMany(n(28,32),9,0,9),t.addMany(n(32,48),9,9,12),t.addMany(n(48,60),9,8,10),t.addMany([60,61,62,63],9,9,10),t.addMany(s,11,0,11),t.addMany(n(32,128),11,0,11),t.addMany(n(28,32),11,0,11),t.addMany(s,10,0,10),t.add(127,10,0,10),t.addMany(n(28,32),10,0,10),t.addMany(n(48,60),10,8,10),t.addMany([60,61,62,63],10,0,11),t.addMany(n(32,48),10,9,12),t.addMany(s,12,0,12),t.add(127,12,0,12),t.addMany(n(28,32),12,0,12),t.addMany(n(32,48),12,9,12),t.addMany(n(48,64),12,0,11),t.addMany(n(64,127),12,12,13),t.addMany(n(64,127),10,12,13),t.addMany(n(64,127),9,12,13),t.addMany(s,13,13,13),t.addMany(i,13,13,13),t.add(127,13,0,13),t.addMany([27,156,24,26],13,14,0),t.add(Ki,0,2,0),t.add(Ki,8,5,8),t.add(Ki,6,0,6),t.add(Ki,11,0,11),t.add(Ki,13,13,13),t})(),PN=class extends yt{constructor(e=jN){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 AS,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(n,i,s)=>{},this._executeHandlerFb=n=>{},this._csiHandlerFb=(n,i)=>{},this._escHandlerFb=n=>{},this._errorHandlerFb=n=>n,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(en(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new RN),this._dcsParser=this._register(new MN),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,n=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let a=0;a<e.intermediates.length;++a){let l=e.intermediates.charCodeAt(a);if(32>l||l>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=l}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(n[0]>s||s>n[1])throw new Error(`final must be in range ${n[0]} .. ${n[1]}`);return i<<=8,i|=s,i}identToString(e){let n=[];for(;e;)n.push(String.fromCharCode(e&255)),e>>=8;return n.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,n){let i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];return s.push(n),{dispose:()=>{let a=s.indexOf(n);a!==-1&&s.splice(a,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,n){this._executeHandlers[e.charCodeAt(0)]=n}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,n){let i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];return s.push(n),{dispose:()=>{let a=s.indexOf(n);a!==-1&&s.splice(a,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,n){return this._dcsParser.registerHandler(this._identifier(e),n)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,n){return this._oscParser.registerHandler(e,n)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,n,i,s,a){this._parseStack.state=e,this._parseStack.handlers=n,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=a}parse(e,n,i){let s=0,a=0,l=0,d;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,l=this._parseStack.chunkPos+1;else{if(i===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let h=this._parseStack.handlers,f=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&f>-1){for(;f>=0&&(d=h[f](this._params),d!==!0);f--)if(d instanceof Promise)return this._parseStack.handlerPos=f,d}this._parseStack.handlers=[];break;case 4:if(i===!1&&f>-1){for(;f>=0&&(d=h[f](),d!==!0);f--)if(d instanceof Promise)return this._parseStack.handlerPos=f,d}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],d=this._dcsParser.unhook(s!==24&&s!==26,i),d)return d;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],d=this._oscParser.end(s!==24&&s!==26,i),d)return d;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 h=l;h<n;++h){switch(s=e[h],a=this._transitions.table[this.currentState<<8|(s<160?s:Ki)],a>>4){case 2:for(let w=h+1;;++w){if(w>=n||(s=e[w])<32||s>126&&s<Ki){this._printHandler(e,h,w),h=w-1;break}if(++w>=n||(s=e[w])<32||s>126&&s<Ki){this._printHandler(e,h,w),h=w-1;break}if(++w>=n||(s=e[w])<32||s>126&&s<Ki){this._printHandler(e,h,w),h=w-1;break}if(++w>=n||(s=e[w])<32||s>126&&s<Ki){this._printHandler(e,h,w),h=w-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:h,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let f=this._csiHandlers[this._collect<<8|s],g=f?f.length-1:-1;for(;g>=0&&(d=f[g](this._params),d!==!0);g--)if(d instanceof Promise)return this._preserveStack(3,f,g,a,h),d;g<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++h<n&&(s=e[h])>47&&s<60);h--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let y=this._escHandlers[this._collect<<8|s],_=y?y.length-1:-1;for(;_>=0&&(d=y[_](),d!==!0);_--)if(d instanceof Promise)return this._preserveStack(4,y,_,a,h),d;_<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let w=h+1;;++w)if(w>=n||(s=e[w])===24||s===26||s===27||s>127&&s<Ki){this._dcsParser.put(e,h,w),h=w-1;break}break;case 14:if(d=this._dcsParser.unhook(s!==24&&s!==26),d)return this._preserveStack(6,[],0,a,h),d;s===27&&(a|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let w=h+1;;w++)if(w>=n||(s=e[w])<32||s>127&&s<Ki){this._oscParser.put(e,h,w),h=w-1;break}break;case 6:if(d=this._oscParser.end(s!==24&&s!==26),d)return this._preserveStack(5,[],0,a,h),d;s===27&&(a|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=a&15}}},TN=/^([\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})$/,DN=/^[\da-f]+$/;function Hy(t){if(!t)return;let e=t.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let n=TN.exec(e);if(n){let i=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/i*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/i*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/i*255)]}}else if(e.indexOf("#")===0&&(e=e.slice(1),DN.exec(e)&&[3,6,9,12].includes(e.length))){let n=e.length/3,i=[0,0,0];for(let s=0;s<3;++s){let a=parseInt(e.slice(n*s,n*s+n),16);i[s]=n===1?a<<4:n===2?a:n===3?a>>4:a>>8}return i}}function Xh(t,e){let n=t.toString(16),i=n.length<2?"0"+n:n;switch(e){case 4:return n[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}function IN(t,e=16){let[n,i,s]=t;return`rgb:${Xh(n,e)}/${Xh(i,e)}/${Xh(s,e)}`}var BN={"(":0,")":1,"*":2,"+":3,"-":1,".":2},_r=131072,Uy=10;function Wy(t,e){if(t>24)return e.setWinLines||!1;switch(t){case 1:return!!e.restoreWin;case 2:return!!e.minimizeWin;case 3:return!!e.setWinPosition;case 4:return!!e.setWinSizePixels;case 5:return!!e.raiseWin;case 6:return!!e.lowerWin;case 7:return!!e.refreshWin;case 8:return!!e.setWinSizeChars;case 9:return!!e.maximizeWin;case 10:return!!e.fullscreenWin;case 11:return!!e.getWinState;case 13:return!!e.getWinPosition;case 14:return!!e.getWinSizePixels;case 15:return!!e.getScreenSizePixels;case 16:return!!e.getCellSizePixels;case 18:return!!e.getWinSizeChars;case 19:return!!e.getScreenSizeChars;case 20:return!!e.getIconTitle;case 21:return!!e.getWinTitle;case 22:return!!e.pushTitle;case 23:return!!e.popTitle;case 24:return!!e.setWinLines}return!1}var qy=5e3,Ky=0,ON=class extends yt{constructor(t,e,n,i,s,a,l,d,h=new PN){super(),this._bufferService=t,this._charsetService=e,this._coreService=n,this._logService=i,this._optionsService=s,this._oscLinkService=a,this._coreMouseService=l,this._unicodeService=d,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new i5,this._utf8Decoder=new s5,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Sn.clone(),this._eraseAttrDataInternal=Sn.clone(),this._onRequestBell=this._register(new Le),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Le),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Le),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Le),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Le),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Le),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Le),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Le),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Le),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Le),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Le),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Le),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Le),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 Ip(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(f=>this._activeBuffer=f.activeBuffer)),this._parser.setCsiHandlerFallback((f,g)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(f),params:g.toArray()})}),this._parser.setEscHandlerFallback(f=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(f)})}),this._parser.setExecuteHandlerFallback(f=>{this._logService.debug("Unknown EXECUTE code: ",{code:f})}),this._parser.setOscHandlerFallback((f,g,y)=>{this._logService.debug("Unknown OSC code: ",{identifier:f,action:g,data:y})}),this._parser.setDcsHandlerFallback((f,g,y)=>{g==="HOOK"&&(y=y.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(f),action:g,payload:y})}),this._parser.setPrintHandler((f,g,y)=>this.print(f,g,y)),this._parser.registerCsiHandler({final:"@"},f=>this.insertChars(f)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},f=>this.scrollLeft(f)),this._parser.registerCsiHandler({final:"A"},f=>this.cursorUp(f)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},f=>this.scrollRight(f)),this._parser.registerCsiHandler({final:"B"},f=>this.cursorDown(f)),this._parser.registerCsiHandler({final:"C"},f=>this.cursorForward(f)),this._parser.registerCsiHandler({final:"D"},f=>this.cursorBackward(f)),this._parser.registerCsiHandler({final:"E"},f=>this.cursorNextLine(f)),this._parser.registerCsiHandler({final:"F"},f=>this.cursorPrecedingLine(f)),this._parser.registerCsiHandler({final:"G"},f=>this.cursorCharAbsolute(f)),this._parser.registerCsiHandler({final:"H"},f=>this.cursorPosition(f)),this._parser.registerCsiHandler({final:"I"},f=>this.cursorForwardTab(f)),this._parser.registerCsiHandler({final:"J"},f=>this.eraseInDisplay(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},f=>this.eraseInDisplay(f,!0)),this._parser.registerCsiHandler({final:"K"},f=>this.eraseInLine(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},f=>this.eraseInLine(f,!0)),this._parser.registerCsiHandler({final:"L"},f=>this.insertLines(f)),this._parser.registerCsiHandler({final:"M"},f=>this.deleteLines(f)),this._parser.registerCsiHandler({final:"P"},f=>this.deleteChars(f)),this._parser.registerCsiHandler({final:"S"},f=>this.scrollUp(f)),this._parser.registerCsiHandler({final:"T"},f=>this.scrollDown(f)),this._parser.registerCsiHandler({final:"X"},f=>this.eraseChars(f)),this._parser.registerCsiHandler({final:"Z"},f=>this.cursorBackwardTab(f)),this._parser.registerCsiHandler({final:"`"},f=>this.charPosAbsolute(f)),this._parser.registerCsiHandler({final:"a"},f=>this.hPositionRelative(f)),this._parser.registerCsiHandler({final:"b"},f=>this.repeatPrecedingCharacter(f)),this._parser.registerCsiHandler({final:"c"},f=>this.sendDeviceAttributesPrimary(f)),this._parser.registerCsiHandler({prefix:">",final:"c"},f=>this.sendDeviceAttributesSecondary(f)),this._parser.registerCsiHandler({final:"d"},f=>this.linePosAbsolute(f)),this._parser.registerCsiHandler({final:"e"},f=>this.vPositionRelative(f)),this._parser.registerCsiHandler({final:"f"},f=>this.hVPosition(f)),this._parser.registerCsiHandler({final:"g"},f=>this.tabClear(f)),this._parser.registerCsiHandler({final:"h"},f=>this.setMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"h"},f=>this.setModePrivate(f)),this._parser.registerCsiHandler({final:"l"},f=>this.resetMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"l"},f=>this.resetModePrivate(f)),this._parser.registerCsiHandler({final:"m"},f=>this.charAttributes(f)),this._parser.registerCsiHandler({final:"n"},f=>this.deviceStatus(f)),this._parser.registerCsiHandler({prefix:"?",final:"n"},f=>this.deviceStatusPrivate(f)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},f=>this.softReset(f)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},f=>this.setCursorStyle(f)),this._parser.registerCsiHandler({final:"r"},f=>this.setScrollRegion(f)),this._parser.registerCsiHandler({final:"s"},f=>this.saveCursor(f)),this._parser.registerCsiHandler({final:"t"},f=>this.windowOptions(f)),this._parser.registerCsiHandler({final:"u"},f=>this.restoreCursor(f)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},f=>this.insertColumns(f)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},f=>this.deleteColumns(f)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},f=>this.selectProtected(f)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},f=>this.requestMode(f,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},f=>this.requestMode(f,!1)),this._parser.setExecuteHandler(ve.BEL,()=>this.bell()),this._parser.setExecuteHandler(ve.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(ve.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(ve.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(ve.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(ve.BS,()=>this.backspace()),this._parser.setExecuteHandler(ve.HT,()=>this.tab()),this._parser.setExecuteHandler(ve.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(ve.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(fu.IND,()=>this.index()),this._parser.setExecuteHandler(fu.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(fu.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ai(f=>(this.setTitle(f),this.setIconName(f),!0))),this._parser.registerOscHandler(1,new Ai(f=>this.setIconName(f))),this._parser.registerOscHandler(2,new Ai(f=>this.setTitle(f))),this._parser.registerOscHandler(4,new Ai(f=>this.setOrReportIndexedColor(f))),this._parser.registerOscHandler(8,new Ai(f=>this.setHyperlink(f))),this._parser.registerOscHandler(10,new Ai(f=>this.setOrReportFgColor(f))),this._parser.registerOscHandler(11,new Ai(f=>this.setOrReportBgColor(f))),this._parser.registerOscHandler(12,new Ai(f=>this.setOrReportCursorColor(f))),this._parser.registerOscHandler(104,new Ai(f=>this.restoreIndexedColor(f))),this._parser.registerOscHandler(110,new Ai(f=>this.restoreFgColor(f))),this._parser.registerOscHandler(111,new Ai(f=>this.restoreBgColor(f))),this._parser.registerOscHandler(112,new Ai(f=>this.restoreCursorColor(f))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let f in Rn)this._parser.registerEscHandler({intermediates:"(",final:f},()=>this.selectCharset("("+f)),this._parser.registerEscHandler({intermediates:")",final:f},()=>this.selectCharset(")"+f)),this._parser.registerEscHandler({intermediates:"*",final:f},()=>this.selectCharset("*"+f)),this._parser.registerEscHandler({intermediates:"+",final:f},()=>this.selectCharset("+"+f)),this._parser.registerEscHandler({intermediates:"-",final:f},()=>this.selectCharset("-"+f)),this._parser.registerEscHandler({intermediates:".",final:f},()=>this.selectCharset("."+f)),this._parser.registerEscHandler({intermediates:"/",final:f},()=>this.selectCharset("/"+f));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(f=>(this._logService.error("Parsing error: ",f),f)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Fy((f,g)=>this.requestStatusString(f,g)))}getAttrData(){return this._curAttrData}_preserveStack(t,e,n,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=t,this._parseStack.cursorStartY=e,this._parseStack.decodedLength=n,this._parseStack.position=i}_logSlowResolvingAsync(t){this._logService.logLevel<=3&&Promise.race([t,new Promise((e,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),qy))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${qy} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(t,e){let n,i=this._activeBuffer.x,s=this._activeBuffer.y,a=0,l=this._parseStack.paused;if(l){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,e))return this._logSlowResolvingAsync(n),n;i=this._parseStack.cursorStartX,s=this._parseStack.cursorStartY,this._parseStack.paused=!1,t.length>_r&&(a=this._parseStack.position+_r)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof t=="string"?` "${t}"`:` "${Array.prototype.map.call(t,f=>String.fromCharCode(f)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof t=="string"?t.split("").map(f=>f.charCodeAt(0)):t),this._parseBuffer.length<t.length&&this._parseBuffer.length<_r&&(this._parseBuffer=new Uint32Array(Math.min(t.length,_r))),l||this._dirtyRowTracker.clearRange(),t.length>_r)for(let f=a;f<t.length;f+=_r){let g=f+_r<t.length?f+_r:t.length,y=typeof t=="string"?this._stringDecoder.decode(t.substring(f,g),this._parseBuffer):this._utf8Decoder.decode(t.subarray(f,g),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,y))return this._preserveStack(i,s,y,f),this._logSlowResolvingAsync(n),n}else if(!l){let f=typeof t=="string"?this._stringDecoder.decode(t,this._parseBuffer):this._utf8Decoder.decode(t,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,f))return this._preserveStack(i,s,f,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==i||this._activeBuffer.y!==s)&&this._onCursorMove.fire();let d=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),h=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(h,this._bufferService.rows-1),end:Math.min(d,this._bufferService.rows-1)})}print(t,e,n){let i,s,a=this._charsetService.charset,l=this._optionsService.rawOptions.screenReaderMode,d=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,f=this._coreService.modes.insertMode,g=this._curAttrData,y=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-e>0&&y.getWidth(this._activeBuffer.x-1)===2&&y.setCellFromCodepoint(this._activeBuffer.x-1,0,1,g);let _=this._parser.precedingJoinState;for(let w=e;w<n;++w){if(i=t[w],i<127&&a){let E=a[String.fromCharCode(i)];E&&(i=E.charCodeAt(0))}let b=this._unicodeService.charProperties(i,_);s=no.extractWidth(b);let N=no.extractShouldJoin(b),x=N?no.extractWidth(_):0;if(_=b,l&&this._onA11yChar.fire(Cr(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+s-x>d){if(h){let E=y,C=this._activeBuffer.x-x;for(this._activeBuffer.x=x,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),y=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),x>0&&y instanceof gl&&y.copyCellsFrom(E,C,0,x,!1);C<d;)E.setCellFromCodepoint(C++,0,1,g)}else if(this._activeBuffer.x=d-1,s===2)continue}if(N&&this._activeBuffer.x){let E=y.getWidth(this._activeBuffer.x-1)?1:2;y.addCodepointToCell(this._activeBuffer.x-E,i,s);for(let C=s-x;--C>=0;)y.setCellFromCodepoint(this._activeBuffer.x++,0,0,g);continue}if(f&&(y.insertCells(this._activeBuffer.x,s-x,this._activeBuffer.getNullCell(g)),y.getWidth(d-1)===2&&y.setCellFromCodepoint(d-1,0,1,g)),y.setCellFromCodepoint(this._activeBuffer.x++,i,s,g),s>0)for(;--s;)y.setCellFromCodepoint(this._activeBuffer.x++,0,0,g)}this._parser.precedingJoinState=_,this._activeBuffer.x<d&&n-e>0&&y.getWidth(this._activeBuffer.x)===0&&!y.hasContent(this._activeBuffer.x)&&y.setCellFromCodepoint(this._activeBuffer.x,0,1,g),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(t,e){return t.final==="t"&&!t.prefix&&!t.intermediates?this._parser.registerCsiHandler(t,n=>Wy(n.params[0],this._optionsService.rawOptions.windowOptions)?e(n):!0):this._parser.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._parser.registerDcsHandler(t,new Fy(e))}registerEscHandler(t,e){return this._parser.registerEscHandler(t,e)}registerOscHandler(t,e){return this._parser.registerOscHandler(t,new Ai(e))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var t;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&t.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-t),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(t=this._bufferService.cols-1){this._activeBuffer.x=Math.min(t,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(t,e){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=t,this._activeBuffer.y=this._activeBuffer.scrollTop+e):(this._activeBuffer.x=t,this._activeBuffer.y=e),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(t,e){this._restrictCursor(),this._setCursor(this._activeBuffer.x+t,this._activeBuffer.y+e)}cursorUp(t){let e=this._activeBuffer.y-this._activeBuffer.scrollTop;return e>=0?this._moveCursor(0,-Math.min(e,t.params[0]||1)):this._moveCursor(0,-(t.params[0]||1)),!0}cursorDown(t){let e=this._activeBuffer.scrollBottom-this._activeBuffer.y;return e>=0?this._moveCursor(0,Math.min(e,t.params[0]||1)):this._moveCursor(0,t.params[0]||1),!0}cursorForward(t){return this._moveCursor(t.params[0]||1,0),!0}cursorBackward(t){return this._moveCursor(-(t.params[0]||1),0),!0}cursorNextLine(t){return this.cursorDown(t),this._activeBuffer.x=0,!0}cursorPrecedingLine(t){return this.cursorUp(t),this._activeBuffer.x=0,!0}cursorCharAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(t){return this._setCursor(t.length>=2?(t.params[1]||1)-1:0,(t.params[0]||1)-1),!0}charPosAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(t){return this._moveCursor(t.params[0]||1,0),!0}linePosAbsolute(t){return this._setCursor(this._activeBuffer.x,(t.params[0]||1)-1),!0}vPositionRelative(t){return this._moveCursor(0,t.params[0]||1),!0}hVPosition(t){return this.cursorPosition(t),!0}tabClear(t){let e=t.params[0];return e===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:e===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(t){let e=t.params[0];return e===1&&(this._curAttrData.bg|=536870912),(e===2||e===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(t,e,n,i=!1,s=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);a.replaceCells(e,n,this._activeBuffer.getNullCell(this._eraseAttrData()),s),i&&(a.isWrapped=!1)}_resetBufferLine(t,e=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),e),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+t),n.isWrapped=!1)}eraseInDisplay(t,e=!1){var i;this._restrictCursor(this._bufferService.cols);let n;switch(t.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);n<this._bufferService.rows;n++)this._resetBufferLine(n,e);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,e),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,e);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!((i=this._activeBuffer.lines.get(this._activeBuffer.ybase+n))!=null&&i.getTrimmedLength()););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,e);this._dirtyRowTracker.markDirty(0)}break;case 3:let s=this._activeBuffer.lines.length-this._bufferService.rows;s>0&&(this._activeBuffer.lines.trimStart(s),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-s,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-s,0),this._onScroll.fire(0));break}return!0}eraseInLine(t,e=!1){switch(this._restrictCursor(this._bufferService.cols),t.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,e);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,e);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(t){this._restrictCursor();let e=t.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-i+1;for(;e--;)this._activeBuffer.lines.splice(s-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(t){this._restrictCursor();let e=t.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,i;for(i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-i;e--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.insertCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.deleteCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(t){let e=t.params[0]||1;for(;e--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(t){let e=t.params[0]||1;for(;e--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Sn));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);i.deleteCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);i.insertCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);i.insertCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);i.deleteCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(t.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(t){let e=this._parser.precedingJoinState;if(!e)return!0;let n=t.params[0]||1,i=no.extractWidth(e),s=this._activeBuffer.x-i,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(s),l=new Uint32Array(a.length*n),d=0;for(let f=0;f<a.length;){let g=a.codePointAt(f)||0;l[d++]=g,f+=g>65535?2:1}let h=d;for(let f=1;f<n;++f)l.copyWithin(h,0,d),h+=d;return this.print(l,0,h),!0}sendDeviceAttributesPrimary(t){return t.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(ve.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(ve.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(ve.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(ve.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(ve.ESC+"[>83;40003;0c")),!0}_is(t){return(this._optionsService.rawOptions.termName+"").indexOf(t)===0}setMode(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Zr),this._charsetService.setgCharset(1,Zr),this._charsetService.setgCharset(2,Zr),this._charsetService.setgCharset(3,Zr);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),t.params[e]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(t,e){(N=>(N[N.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",N[N.SET=1]="SET",N[N.RESET=2]="RESET",N[N.PERMANENTLY_SET=3]="PERMANENTLY_SET",N[N.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let i=this._coreService.decPrivateModes,{activeProtocol:s,activeEncoding:a}=this._coreMouseService,l=this._coreService,{buffers:d,cols:h}=this._bufferService,{active:f,alt:g}=d,y=this._optionsService.rawOptions,_=(N,x)=>(l.triggerDataEvent(`${ve.ESC}[${e?"":"?"}${N};${x}$y`),!0),w=N=>N?1:2,b=t.params[0];return e?b===2?_(b,4):b===4?_(b,w(l.modes.insertMode)):b===12?_(b,3):b===20?_(b,w(y.convertEol)):_(b,0):b===1?_(b,w(i.applicationCursorKeys)):b===3?_(b,y.windowOptions.setWinLines?h===80?2:h===132?1:0:0):b===6?_(b,w(i.origin)):b===7?_(b,w(i.wraparound)):b===8?_(b,3):b===9?_(b,w(s==="X10")):b===12?_(b,w(y.cursorBlink)):b===25?_(b,w(!l.isCursorHidden)):b===45?_(b,w(i.reverseWraparound)):b===66?_(b,w(i.applicationKeypad)):b===67?_(b,4):b===1e3?_(b,w(s==="VT200")):b===1002?_(b,w(s==="DRAG")):b===1003?_(b,w(s==="ANY")):b===1004?_(b,w(i.sendFocus)):b===1005?_(b,4):b===1006?_(b,w(a==="SGR")):b===1015?_(b,4):b===1016?_(b,w(a==="SGR_PIXELS")):b===1048?_(b,1):b===47||b===1047||b===1049?_(b,w(f===g)):b===2004?_(b,w(i.bracketedPasteMode)):b===2026?_(b,w(i.synchronizedOutput)):_(b,0)}_updateAttrColor(t,e,n,i,s){return e===2?(t|=50331648,t&=-16777216,t|=Pl.fromColorRGB([n,i,s])):e===5&&(t&=-50331904,t|=33554432|n&255),t}_extractColor(t,e,n){let i=[0,0,-1,0,0,0],s=0,a=0;do{if(i[a+s]=t.params[e+a],t.hasSubParams(e+a)){let l=t.getSubParams(e+a),d=0;do i[1]===5&&(s=1),i[a+d+1+s]=l[d];while(++d<l.length&&d+a+1+s<i.length);break}if(i[1]===5&&a+s>=2||i[1]===2&&a+s>=5)break;i[1]&&(s=1)}while(++a+e<t.length&&a+s<i.length);for(let l=2;l<i.length;++l)i[l]===-1&&(i[l]=0);switch(i[0]){case 38:n.fg=this._updateAttrColor(n.fg,i[1],i[3],i[4],i[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,i[1],i[3],i[4],i[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,i[1],i[3],i[4],i[5])}return a}_processUnderline(t,e){e.extended=e.extended.clone(),(!~t||t>5)&&(t=1),e.extended.underlineStyle=t,e.fg|=268435456,t===0&&(e.fg&=-268435457),e.updateExtended()}_processSGR0(t){t.fg=Sn.fg,t.bg=Sn.bg,t.extended=t.extended.clone(),t.extended.underlineStyle=0,t.extended.underlineColor&=-67108864,t.updateExtended()}charAttributes(t){if(t.length===1&&t.params[0]===0)return this._processSGR0(this._curAttrData),!0;let e=t.length,n,i=this._curAttrData;for(let s=0;s<e;s++)n=t.params[s],n>=30&&n<=37?(i.fg&=-50331904,i.fg|=16777216|n-30):n>=40&&n<=47?(i.bg&=-50331904,i.bg|=16777216|n-40):n>=90&&n<=97?(i.fg&=-50331904,i.fg|=16777216|n-90|8):n>=100&&n<=107?(i.bg&=-50331904,i.bg|=16777216|n-100|8):n===0?this._processSGR0(i):n===1?i.fg|=134217728:n===3?i.bg|=67108864:n===4?(i.fg|=268435456,this._processUnderline(t.hasSubParams(s)?t.getSubParams(s)[0]:1,i)):n===5?i.fg|=536870912:n===7?i.fg|=67108864:n===8?i.fg|=1073741824:n===9?i.fg|=2147483648:n===2?i.bg|=134217728:n===21?this._processUnderline(2,i):n===22?(i.fg&=-134217729,i.bg&=-134217729):n===23?i.bg&=-67108865:n===24?(i.fg&=-268435457,this._processUnderline(0,i)):n===25?i.fg&=-536870913:n===27?i.fg&=-67108865:n===28?i.fg&=-1073741825:n===29?i.fg&=2147483647:n===39?(i.fg&=-67108864,i.fg|=Sn.fg&16777215):n===49?(i.bg&=-67108864,i.bg|=Sn.bg&16777215):n===38||n===48||n===58?s+=this._extractColor(t,s,i):n===53?i.bg|=1073741824:n===55?i.bg&=-1073741825:n===59?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):n===100?(i.fg&=-67108864,i.fg|=Sn.fg&16777215,i.bg&=-67108864,i.bg|=Sn.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${ve.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${ve.ESC}[${e};${n}R`);break}return!0}deviceStatusPrivate(t){switch(t.params[0]){case 6:let e=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${ve.ESC}[?${e};${n}R`);break}return!0}softReset(t){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Sn.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(t){let e=t.length===0?1:t.params[0];if(e===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(e){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let n=e%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(t){let e=t.params[0]||1,n;return(t.length<2||(n=t.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>e&&(this._activeBuffer.scrollTop=e-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(t){if(!Wy(t.params[0],this._optionsService.rawOptions.windowOptions))return!0;let e=t.length>1?t.params[1]:0;switch(t.params[0]){case 14:e!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${ve.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Uy&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Uy&&this._iconNameStack.shift());break;case 23:(e===0||e===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(e===0||e===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(t){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(t){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(t){return this._windowTitle=t,this._onTitleChange.fire(t),!0}setIconName(t){return this._iconName=t,!0}setOrReportIndexedColor(t){let e=[],n=t.split(";");for(;n.length>1;){let i=n.shift(),s=n.shift();if(/^\d+$/.exec(i)){let a=parseInt(i);if(Vy(a))if(s==="?")e.push({type:0,index:a});else{let l=Hy(s);l&&e.push({type:1,index:a,color:l})}}}return e.length&&this._onColor.fire(e),!0}setHyperlink(t){let e=t.indexOf(";");if(e===-1)return!0;let n=t.slice(0,e).trim(),i=t.slice(e+1);return i?this._createHyperlink(n,i):n.trim()?!1:this._finishHyperlink()}_createHyperlink(t,e){this._getCurrentLinkId()&&this._finishHyperlink();let n=t.split(":"),i,s=n.findIndex(a=>a.startsWith("id="));return s!==-1&&(i=n[s].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,uri:e}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(t,e){let n=t.split(";");for(let i=0;i<n.length&&!(e>=this._specialColors.length);++i,++e)if(n[i]==="?")this._onColor.fire([{type:0,index:this._specialColors[e]}]);else{let s=Hy(n[i]);s&&this._onColor.fire([{type:1,index:this._specialColors[e],color:s}])}return!0}setOrReportFgColor(t){return this._setOrReportSpecialColor(t,0)}setOrReportBgColor(t){return this._setOrReportSpecialColor(t,1)}setOrReportCursorColor(t){return this._setOrReportSpecialColor(t,2)}restoreIndexedColor(t){if(!t)return this._onColor.fire([{type:2}]),!0;let e=[],n=t.split(";");for(let i=0;i<n.length;++i)if(/^\d+$/.exec(n[i])){let s=parseInt(n[i]);Vy(s)&&e.push({type:2,index:s})}return e.length&&this._onColor.fire(e),!0}restoreFgColor(t){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(t){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(t){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,Zr),!0}selectCharset(t){return t.length!==2?(this.selectDefaultCharset(),!0):(t[0]==="/"||this._charsetService.setgCharset(BN[t[0]],Rn[t[1]]||Zr),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let t=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,t,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=Sn.clone(),this._eraseAttrDataInternal=Sn.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(t){return this._charsetService.setgLevel(t),!0}screenAlignmentPattern(){let t=new Yi;t.content=1<<22|69,t.fg=this._curAttrData.fg,t.bg=this._curAttrData.bg,this._setCursor(0,0);for(let e=0;e<this._bufferService.rows;++e){let n=this._activeBuffer.ybase+this._activeBuffer.y+e,i=this._activeBuffer.lines.get(n);i&&(i.fill(t),i.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(t,e){let n=l=>(this._coreService.triggerDataEvent(`${ve.ESC}${l}${ve.ESC}\\`),!0),i=this._bufferService.buffer,s=this._optionsService.rawOptions;return n(t==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:t==='"p'?'P1$r61;1"p':t==="r"?`P1$r${i.scrollTop+1};${i.scrollBottom+1}r`:t==="m"?"P1$r0m":t===" q"?`P1$r${{block:2,underline:4,bar:6}[s.cursorStyle]-(s.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(t,e){this._dirtyRowTracker.markRangeDirty(t,e)}},Ip=class{constructor(t){this._bufferService=t,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(t){t<this.start?this.start=t:t>this.end&&(this.end=t)}markRangeDirty(t,e){t>e&&(Ky=t,t=e,e=Ky),t<this.start&&(this.start=t),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Ip=mn([ze(0,ci)],Ip);function Vy(t){return 0<=t&&t<256}var $N=5e7,Yy=12,zN=50,FN=class extends yt{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 Le),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,n){if(n!==void 0&&this._syncCalls>n){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let i;for(;i=this._writeBuffer.shift();){this._action(i);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,n){if(this._pendingData>$N)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(n),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(n)}_innerWrite(e=0,n=!0){let i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],a=this._action(s,n);if(a){let d=h=>performance.now()-i>=Yy?setTimeout(()=>this._innerWrite(0,h)):this._innerWrite(i,h);a.catch(h=>(queueMicrotask(()=>{throw h}),Promise.resolve(!1))).then(d);return}let l=this._callbacks[this._bufferOffset];if(l&&l(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=Yy)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>zN&&(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()}},Bp=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let n=this._bufferService.buffer;if(e.id===void 0){let h=n.addMarker(n.ybase+n.y),f={data:e,id:this._nextId++,lines:[h]};return h.onDispose(()=>this._removeMarkerFromLink(f,h)),this._dataByLinkId.set(f.id,f),f.id}let i=e,s=this._getEntryIdKey(i),a=this._entriesWithId.get(s);if(a)return this.addLineToLink(a.id,n.ybase+n.y),a.id;let l=n.addMarker(n.ybase+n.y),d={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(d,l)),this._entriesWithId.set(d.key,d),this._dataByLinkId.set(d.id,d),d.id}addLineToLink(e,n){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(s=>s.line!==n)){let s=this._bufferService.buffer.addMarker(n);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,s))}}getLinkData(e){var n;return(n=this._dataByLinkId.get(e))==null?void 0:n.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,n){let i=e.lines.indexOf(n);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Bp=mn([ze(0,ci)],Bp);var Gy=!1,HN=class extends yt{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new aa),this._onBinary=this._register(new Le),this.onBinary=this._onBinary.event,this._onData=this._register(new Le),this.onData=this._onData.event,this._onLineFeed=this._register(new Le),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Le),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Le),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Le),this._instantiationService=new hN,this.optionsService=this._register(new SN(e)),this._instantiationService.setService(ui,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(jp)),this._instantiationService.setService(ci,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Ap)),this._instantiationService.setService(X0,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Pp)),this._instantiationService.setService(fo,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Tp)),this._instantiationService.setService(G0,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(no)),this._instantiationService.setService(l5,this.unicodeService),this._charsetService=this._instantiationService.createInstance(NN),this._instantiationService.setService(a5,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Bp),this._instantiationService.setService(Q0,this._oscLinkService),this._inputHandler=this._register(new ON(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Yn.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Yn.forward(this._bufferService.onResize,this._onResize)),this._register(Yn.forward(this.coreService.onData,this._onData)),this._register(Yn.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 FN((n,i)=>this._inputHandler.parse(n,i))),this._register(Yn.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Le),this._onScroll.event(e=>{var n;(n=this._onScrollApi)==null||n.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let n in e)this.optionsService.options[n]=e[n]}write(e,n){this._writeBuffer.write(e,n)}writeSync(e,n){this._logService.logLevel<=3&&!Gy&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Gy=!0),this._writeBuffer.writeSync(e,n)}input(e,n=!0){this.coreService.triggerDataEvent(e,n)}resize(e,n){isNaN(e)||isNaN(n)||(e=Math.max(e,RS),n=Math.max(n,MS),this._bufferService.resize(e,n))}scroll(e,n=!1){this._bufferService.scroll(e,n)}scrollLines(e,n){this._bufferService.scrollLines(e,n)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let n=e-this._bufferService.buffer.ydisp;n!==0&&this.scrollLines(n)}registerEscHandler(e,n){return this._inputHandler.registerEscHandler(e,n)}registerDcsHandler(e,n){return this._inputHandler.registerDcsHandler(e,n)}registerCsiHandler(e,n){return this._inputHandler.registerCsiHandler(e,n)}registerOscHandler(e,n){return this._inputHandler.registerOscHandler(e,n)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,n=this.optionsService.rawOptions.windowsPty;n&&n.buildNumber!==void 0&&n.buildNumber!==void 0?e=n.backend==="conpty"&&n.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(zy.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(zy(this._bufferService),!1))),this._windowsWrappingHeuristics.value=en(()=>{for(let n of e)n.dispose()})}}},UN={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 WN(t,e,n,i){var l;let s={type:0,cancel:!1,key:void 0},a=(t.shiftKey?1:0)|(t.altKey?2:0)|(t.ctrlKey?4:0)|(t.metaKey?8:0);switch(t.keyCode){case 0:t.key==="UIKeyInputUpArrow"?e?s.key=ve.ESC+"OA":s.key=ve.ESC+"[A":t.key==="UIKeyInputLeftArrow"?e?s.key=ve.ESC+"OD":s.key=ve.ESC+"[D":t.key==="UIKeyInputRightArrow"?e?s.key=ve.ESC+"OC":s.key=ve.ESC+"[C":t.key==="UIKeyInputDownArrow"&&(e?s.key=ve.ESC+"OB":s.key=ve.ESC+"[B");break;case 8:s.key=t.ctrlKey?"\b":ve.DEL,t.altKey&&(s.key=ve.ESC+s.key);break;case 9:if(t.shiftKey){s.key=ve.ESC+"[Z";break}s.key=ve.HT,s.cancel=!0;break;case 13:s.key=t.altKey?ve.ESC+ve.CR:ve.CR,s.cancel=!0;break;case 27:s.key=ve.ESC,t.altKey&&(s.key=ve.ESC+ve.ESC),s.cancel=!0;break;case 37:if(t.metaKey)break;a?s.key=ve.ESC+"[1;"+(a+1)+"D":e?s.key=ve.ESC+"OD":s.key=ve.ESC+"[D";break;case 39:if(t.metaKey)break;a?s.key=ve.ESC+"[1;"+(a+1)+"C":e?s.key=ve.ESC+"OC":s.key=ve.ESC+"[C";break;case 38:if(t.metaKey)break;a?s.key=ve.ESC+"[1;"+(a+1)+"A":e?s.key=ve.ESC+"OA":s.key=ve.ESC+"[A";break;case 40:if(t.metaKey)break;a?s.key=ve.ESC+"[1;"+(a+1)+"B":e?s.key=ve.ESC+"OB":s.key=ve.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(s.key=ve.ESC+"[2~");break;case 46:a?s.key=ve.ESC+"[3;"+(a+1)+"~":s.key=ve.ESC+"[3~";break;case 36:a?s.key=ve.ESC+"[1;"+(a+1)+"H":e?s.key=ve.ESC+"OH":s.key=ve.ESC+"[H";break;case 35:a?s.key=ve.ESC+"[1;"+(a+1)+"F":e?s.key=ve.ESC+"OF":s.key=ve.ESC+"[F";break;case 33:t.shiftKey?s.type=2:t.ctrlKey?s.key=ve.ESC+"[5;"+(a+1)+"~":s.key=ve.ESC+"[5~";break;case 34:t.shiftKey?s.type=3:t.ctrlKey?s.key=ve.ESC+"[6;"+(a+1)+"~":s.key=ve.ESC+"[6~";break;case 112:a?s.key=ve.ESC+"[1;"+(a+1)+"P":s.key=ve.ESC+"OP";break;case 113:a?s.key=ve.ESC+"[1;"+(a+1)+"Q":s.key=ve.ESC+"OQ";break;case 114:a?s.key=ve.ESC+"[1;"+(a+1)+"R":s.key=ve.ESC+"OR";break;case 115:a?s.key=ve.ESC+"[1;"+(a+1)+"S":s.key=ve.ESC+"OS";break;case 116:a?s.key=ve.ESC+"[15;"+(a+1)+"~":s.key=ve.ESC+"[15~";break;case 117:a?s.key=ve.ESC+"[17;"+(a+1)+"~":s.key=ve.ESC+"[17~";break;case 118:a?s.key=ve.ESC+"[18;"+(a+1)+"~":s.key=ve.ESC+"[18~";break;case 119:a?s.key=ve.ESC+"[19;"+(a+1)+"~":s.key=ve.ESC+"[19~";break;case 120:a?s.key=ve.ESC+"[20;"+(a+1)+"~":s.key=ve.ESC+"[20~";break;case 121:a?s.key=ve.ESC+"[21;"+(a+1)+"~":s.key=ve.ESC+"[21~";break;case 122:a?s.key=ve.ESC+"[23;"+(a+1)+"~":s.key=ve.ESC+"[23~";break;case 123:a?s.key=ve.ESC+"[24;"+(a+1)+"~":s.key=ve.ESC+"[24~";break;default:if(t.ctrlKey&&!t.shiftKey&&!t.altKey&&!t.metaKey)t.keyCode>=65&&t.keyCode<=90?s.key=String.fromCharCode(t.keyCode-64):t.keyCode===32?s.key=ve.NUL:t.keyCode>=51&&t.keyCode<=55?s.key=String.fromCharCode(t.keyCode-51+27):t.keyCode===56?s.key=ve.DEL:t.keyCode===219?s.key=ve.ESC:t.keyCode===220?s.key=ve.FS:t.keyCode===221&&(s.key=ve.GS);else if((!n||i)&&t.altKey&&!t.metaKey){let d=(l=UN[t.keyCode])==null?void 0:l[t.shiftKey?1:0];if(d)s.key=ve.ESC+d;else if(t.keyCode>=65&&t.keyCode<=90){let h=t.ctrlKey?t.keyCode-64:t.keyCode+32,f=String.fromCharCode(h);t.shiftKey&&(f=f.toUpperCase()),s.key=ve.ESC+f}else if(t.keyCode===32)s.key=ve.ESC+(t.ctrlKey?ve.NUL:" ");else if(t.key==="Dead"&&t.code.startsWith("Key")){let h=t.code.slice(3,4);t.shiftKey||(h=h.toLowerCase()),s.key=ve.ESC+h,s.cancel=!0}}else n&&!t.altKey&&!t.ctrlKey&&!t.shiftKey&&t.metaKey?t.keyCode===65&&(s.type=1):t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.keyCode>=48&&t.key.length===1?s.key=t.key:t.key&&t.ctrlKey&&(t.key==="_"&&(s.key=ve.US),t.key==="@"&&(s.key=ve.NUL));break}return s}var yn=0,qN=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Tu,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Tu,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((a,l)=>this._getKey(a)-this._getKey(l)),n=0,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let a=0;a<s.length;a++)i>=this._array.length||this._getKey(e[n])<=this._getKey(this._array[i])?(s[a]=e[n],n++):s[a]=this._array[i++];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 n=this._getKey(e);if(n===void 0||(yn=this._search(n),yn===-1)||this._getKey(this._array[yn])!==n)return!1;do if(this._array[yn]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(yn),!0;while(++yn<this._array.length&&this._getKey(this._array[yn])===n);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((a,l)=>a-l),n=0,i=new Array(this._array.length-e.length),s=0;for(let a=0;a<this._array.length;a++)e[n]===a?n++:i[s++]=this._array[a];this._array=i,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&&(yn=this._search(e),!(yn<0||yn>=this._array.length)&&this._getKey(this._array[yn])===e))do yield this._array[yn];while(++yn<this._array.length&&this._getKey(this._array[yn])===e)}forEachByKey(e,n){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(yn=this._search(e),!(yn<0||yn>=this._array.length)&&this._getKey(this._array[yn])===e))do n(this._array[yn]);while(++yn<this._array.length&&this._getKey(this._array[yn])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let n=0,i=this._array.length-1;for(;i>=n;){let s=n+i>>1,a=this._getKey(this._array[s]);if(a>e)i=s-1;else if(a<e)n=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return n}},Qh=0,Xy=0,KN=class extends yt{constructor(){super(),this._decorations=new qN(t=>t==null?void 0:t.marker.line),this._onDecorationRegistered=this._register(new Le),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Le),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(en(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let e=new VN(t);if(e){let n=e.marker.onDispose(()=>e.dispose()),i=e.onDispose(()=>{i.dispose(),e&&(this._decorations.delete(e)&&this._onDecorationRemoved.fire(e),n.dispose())});this._decorations.insert(e),this._onDecorationRegistered.fire(e)}return e}reset(){for(let t of this._decorations.values())t.dispose();this._decorations.clear()}*getDecorationsAtCell(t,e,n){let i=0,s=0;for(let a of this._decorations.getKeyIterator(e))i=a.options.x??0,s=i+(a.options.width??1),t>=i&&t<s&&(!n||(a.options.layer??"bottom")===n)&&(yield a)}forEachDecorationAtCell(t,e,n,i){this._decorations.forEachByKey(e,s=>{Qh=s.options.x??0,Xy=Qh+(s.options.width??1),t>=Qh&&t<Xy&&(!n||(s.options.layer??"bottom")===n)&&i(s)})}},VN=class extends Rr{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new Le),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Le),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=t.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=on.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=on.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},YN=1e3,GN=class{constructor(e,n=YN){this._renderCallback=e,this._debounceThresholdMS=n,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,n,i){this._rowCount=i,e=e!==void 0?e:0,n=n!==void 0?n:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,n):n;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let a=s-this._lastRefreshMs,l=this._debounceThresholdMS-a;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),n=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,n)}},Qy=20,Du=class extends yt{constructor(t,e,n,i){super(),this._terminal=t,this._coreBrowserService=n,this._renderService=i,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let s=this._coreBrowserService.mainDocument;this._accessibilityContainer=s.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=s.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let a=0;a<this._terminal.rows;a++)this._rowElements[a]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[a]);if(this._topBoundaryFocusListener=a=>this._handleBoundaryFocus(a,0),this._bottomBoundaryFocusListener=a=>this._handleBoundaryFocus(a,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=s.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new GN(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(a=>this._handleResize(a.rows))),this._register(this._terminal.onRender(a=>this._refreshRows(a.start,a.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(a=>this._handleChar(a))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
64
- `))),this._register(this._terminal.onA11yTab(a=>this._handleTab(a))),this._register(this._terminal.onKey(a=>this._handleKey(a.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(lt(s,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(en(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(t){for(let e=0;e<t;e++)this._handleChar(" ")}_handleChar(t){this._liveRegionLineCount<Qy+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==t&&(this._charsToAnnounce+=t):this._charsToAnnounce+=t,t===`
65
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===Qy+1&&(this._liveRegion.textContent+=ip.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(t){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(t)||this._charsToConsume.push(t)}_refreshRows(t,e){this._liveRegionDebouncer.refresh(t,e,this._terminal.rows)}_renderRows(t,e){let n=this._terminal.buffer,i=n.lines.length.toString();for(let s=t;s<=e;s++){let a=n.lines.get(n.ydisp+s),l=[],d=(a==null?void 0:a.translateToString(!0,void 0,void 0,l))||"",h=(n.ydisp+s+1).toString(),f=this._rowElements[s];f&&(d.length===0?(f.textContent=" ",this._rowColumns.set(f,[0,1])):(f.textContent=d,this._rowColumns.set(f,l)),f.setAttribute("aria-posinset",h),f.setAttribute("aria-setsize",i),this._alignRowWidth(f))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(t,e){let n=t.target,i=this._rowElements[e===0?1:this._rowElements.length-2],s=n.getAttribute("aria-posinset"),a=e===0?"1":`${this._terminal.buffer.lines.length}`;if(s===a||t.relatedTarget!==i)return;let l,d;if(e===0?(l=n,d=this._rowElements.pop(),this._rowContainer.removeChild(d)):(l=this._rowElements.shift(),d=n,this._rowContainer.removeChild(l)),l.removeEventListener("focus",this._topBoundaryFocusListener),d.removeEventListener("focus",this._bottomBoundaryFocusListener),e===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(e===0?-1:1),this._rowElements[e===0?1:this._rowElements.length-2].focus(),t.preventDefault(),t.stopImmediatePropagation()}_handleSelectionChange(){var d;if(this._rowElements.length===0)return;let t=this._coreBrowserService.mainDocument.getSelection();if(!t)return;if(t.isCollapsed){this._rowContainer.contains(t.anchorNode)&&this._terminal.clearSelection();return}if(!t.anchorNode||!t.focusNode){console.error("anchorNode and/or focusNode are null");return}let e={node:t.anchorNode,offset:t.anchorOffset},n={node:t.focusNode,offset:t.focusOffset};if((e.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||e.node===n.node&&e.offset>n.offset)&&([e,n]=[n,e]),e.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(e={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(e.node))return;let i=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:i,offset:((d=i.textContent)==null?void 0:d.length)??0}),!this._rowContainer.contains(n.node))return;let s=({node:h,offset:f})=>{let g=h instanceof Text?h.parentNode:h,y=parseInt(g==null?void 0:g.getAttribute("aria-posinset"),10)-1;if(isNaN(y))return console.warn("row is invalid. Race condition?"),null;let _=this._rowColumns.get(g);if(!_)return console.warn("columns is null. Race condition?"),null;let w=f<_.length?_[f]:_.slice(-1)[0]+1;return w>=this._terminal.cols&&(++y,w=0),{row:y,column:w}},a=s(e),l=s(n);if(!(!a||!l)){if(a.row>l.row||a.row===l.row&&a.column>=l.column)throw new Error("invalid range");this._terminal.select(a.column,a.row,(l.row-a.row)*this._terminal.cols-a.column+l.column)}}_handleResize(t){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let t=this._coreBrowserService.mainDocument.createElement("div");return t.setAttribute("role","listitem"),t.tabIndex=-1,this._refreshRowDimensions(t),t}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let t=0;t<this._terminal.rows;t++)this._refreshRowDimensions(this._rowElements[t]),this._alignRowWidth(this._rowElements[t])}}_refreshRowDimensions(t){t.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(t){var s,a;t.style.transform="";let e=t.getBoundingClientRect().width,n=(a=(s=this._rowColumns.get(t))==null?void 0:s.slice(-1))==null?void 0:a[0];if(!n)return;let i=n*this._renderService.dimensions.css.cell.width;t.style.transform=`scaleX(${i/e})`}};Du=mn([ze(1,Em),ze(2,Ys),ze(3,Gs)],Du);var Op=class extends yt{constructor(t,e,n,i,s){super(),this._element=t,this._mouseService=e,this._renderService=n,this._bufferService=i,this._linkProviderService=s,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Le),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Le),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(en(()=>{var a;co(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(a=this._activeProviderReplies)==null||a.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(lt(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(lt(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(lt(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(lt(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(t){this._lastMouseEvent=t;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);if(!e)return;this._isMouseOut=!1;let n=t.composedPath();for(let i=0;i<n.length;i++){let s=n[i];if(s.classList.contains("xterm"))break;if(s.classList.contains("xterm-hover"))return}(!this._lastBufferCell||e.x!==this._lastBufferCell.x||e.y!==this._lastBufferCell.y)&&(this._handleHover(e),this._lastBufferCell=e)}_handleHover(t){if(this._activeLine!==t.y||this._wasResized){this._clearCurrentLink(),this._askForLink(t,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,t)||(this._clearCurrentLink(),this._askForLink(t,!0))}_askForLink(t,e){var i,s;(!this._activeProviderReplies||!e)&&((i=this._activeProviderReplies)==null||i.forEach(a=>{a==null||a.forEach(l=>{l.link.dispose&&l.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=t.y);let n=!1;for(let[a,l]of this._linkProviderService.linkProviders.entries())e?(s=this._activeProviderReplies)!=null&&s.get(a)&&(n=this._checkLinkProviderResult(a,t,n)):l.provideLinks(t.y,d=>{var f,g;if(this._isMouseOut)return;let h=d==null?void 0:d.map(y=>({link:y}));(f=this._activeProviderReplies)==null||f.set(a,h),n=this._checkLinkProviderResult(a,t,n),((g=this._activeProviderReplies)==null?void 0:g.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(t.y,this._activeProviderReplies)})}_removeIntersectingLinks(t,e){let n=new Set;for(let i=0;i<e.size;i++){let s=e.get(i);if(s)for(let a=0;a<s.length;a++){let l=s[a],d=l.link.range.start.y<t?0:l.link.range.start.x,h=l.link.range.end.y>t?this._bufferService.cols:l.link.range.end.x;for(let f=d;f<=h;f++){if(n.has(f)){s.splice(a--,1);break}n.add(f)}}}}_checkLinkProviderResult(t,e,n){var a;if(!this._activeProviderReplies)return n;let i=this._activeProviderReplies.get(t),s=!1;for(let l=0;l<t;l++)(!this._activeProviderReplies.has(l)||this._activeProviderReplies.get(l))&&(s=!0);if(!s&&i){let l=i.find(d=>this._linkAtPosition(d.link,e));l&&(n=!0,this._handleNewLink(l))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let l=0;l<this._activeProviderReplies.size;l++){let d=(a=this._activeProviderReplies.get(l))==null?void 0:a.find(h=>this._linkAtPosition(h.link,e));if(d){n=!0,this._handleNewLink(d);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(t){if(!this._currentLink)return;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);e&&this._mouseDownLink&&XN(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,e)&&this._currentLink.link.activate(t,this._currentLink.link.text)}_clearCurrentLink(t,e){!this._currentLink||!this._lastMouseEvent||(!t||!e||this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=e)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,co(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(t){if(!this._lastMouseEvent)return;let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._linkAtPosition(t.link,e)&&(this._currentLink=t,this._currentLink.state={decorations:{underline:t.link.decorations===void 0?!0:t.link.decorations.underline,pointerCursor:t.link.decorations===void 0?!0:t.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,t.link,this._lastMouseEvent),t.link.decorations={},Object.defineProperties(t.link.decorations,{pointerCursor:{get:()=>{var n,i;return(i=(n=this._currentLink)==null?void 0:n.state)==null?void 0:i.decorations.pointerCursor},set:n=>{var i;(i=this._currentLink)!=null&&i.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,i;return(i=(n=this._currentLink)==null?void 0:n.state)==null?void 0:i.decorations.underline},set:n=>{var i,s,a;(i=this._currentLink)!=null&&i.state&&((a=(s=this._currentLink)==null?void 0:s.state)==null?void 0:a.decorations.underline)!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(t.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let i=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,s=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=s&&(this._clearCurrentLink(i,s),this._lastMouseEvent)){let a=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);a&&this._askForLink(a,!1)}})))}_linkHover(t,e,n){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!0),this._currentLink.state.decorations.pointerCursor&&t.classList.add("xterm-cursor-pointer")),e.hover&&e.hover(n,e.text)}_fireUnderlineEvent(t,e){let n=t.range,i=this._bufferService.buffer.ydisp,s=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-i-1,n.end.x,n.end.y-i-1,void 0);(e?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(s)}_linkLeave(t,e,n){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!1),this._currentLink.state.decorations.pointerCursor&&t.classList.remove("xterm-cursor-pointer")),e.leave&&e.leave(n,e.text)}_linkAtPosition(t,e){let n=t.range.start.y*this._bufferService.cols+t.range.start.x,i=t.range.end.y*this._bufferService.cols+t.range.end.x,s=e.y*this._bufferService.cols+e.x;return n<=s&&s<=i}_positionFromMouseEvent(t,e,n){let i=n.getCoords(t,e,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(t,e,n,i,s){return{x1:t,y1:e,x2:n,y2:i,cols:this._bufferService.cols,fg:s}}};Op=mn([ze(1,Nm),ze(2,Gs),ze(3,ci),ze(4,Z0)],Op);function XN(t,e){return t.text===e.text&&t.range.start.x===e.range.start.x&&t.range.start.y===e.range.start.y&&t.range.end.x===e.range.end.x&&t.range.end.y===e.range.end.y}var QN=class extends HN{constructor(e={}){super(e),this._linkifier=this._register(new aa),this.browser=_S,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new aa),this._onCursorMove=this._register(new Le),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Le),this.onKey=this._onKey.event,this._onRender=this._register(new Le),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Le),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Le),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Le),this.onBell=this._onBell.event,this._onFocus=this._register(new Le),this._onBlur=this._register(new Le),this._onA11yCharEmitter=this._register(new Le),this._onA11yTabEmitter=this._register(new Le),this._onWillOpen=this._register(new Le),this._setup(),this._decorationService=this._instantiationService.createInstance(KN),this._instantiationService.setService(Tl,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(zE),this._instantiationService.setService(Z0,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(rp)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(n=>this.refresh((n==null?void 0:n.start)??0,(n==null?void 0:n.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(n=>this._reportWindowsOptions(n))),this._register(this._inputHandler.onColor(n=>this._handleColorEvent(n))),this._register(Yn.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Yn.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Yn.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Yn.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(n=>this._afterResize(n.cols,n.rows))),this._register(en(()=>{var n,i;this._customKeyEventHandler=void 0,(i=(n=this.element)==null?void 0:n.parentNode)==null||i.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let n of e){let i,s="";switch(n.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+n.index}switch(n.type){case 0:let a=Xt.toColorRGB(i==="ansi"?this._themeService.colors.ansi[n.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${ve.ESC}]${s};${IN(a)}${gS.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(l=>l.ansi[n.index]=Cn.toColor(...n.color));else{let l=i;this._themeService.modifyColors(d=>d[l]=Cn.toColor(...n.color))}break;case 2:this._themeService.restoreColor(n.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Du,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(ve.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(ve.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,n=this.buffer.lines.get(e);if(!n)return;let i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,a=n.getWidth(i),l=this._renderService.dimensions.css.cell.width*a,d=this.buffer.y*this._renderService.dimensions.css.cell.height,h=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=h+"px",this.textarea.style.top=d+"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(lt(this.element,"copy",n=>{this.hasSelection()&&t5(n,this._selectionService)}));let e=n=>n5(n,this.textarea,this.coreService,this.optionsService);this._register(lt(this.textarea,"paste",e)),this._register(lt(this.element,"paste",e)),yS?this._register(lt(this.element,"mousedown",n=>{n.button===2&&ay(n,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(lt(this.element,"contextmenu",n=>{ay(n,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Dm&&this._register(lt(this.element,"auxclick",n=>{n.button===1&&W0(n,this.textarea,this.screenElement)}))}_bindKeys(){this._register(lt(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(lt(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(lt(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(lt(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(lt(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(lt(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(lt(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var a;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((a=this.element)==null?void 0:a.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let n=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),n.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(lt(this.screenElement,"mousemove",l=>this.updateCursorStyle(l))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),n.appendChild(this.screenElement);let i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",np.get()),SS||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",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(OE,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Ys,this._coreBrowserService),this._register(lt(this.textarea,"focus",l=>this._handleTextAreaFocus(l))),this._register(lt(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Ep,this._document,this._helperContainer),this._instantiationService.setService(Vu,this._charSizeService),this._themeService=this._instantiationService.createInstance(Mp),this._instantiationService.setService(ha,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(ju),this._instantiationService.setService(J0,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Lp,this.rows,this.screenElement)),this._instantiationService.setService(Gs,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(xp,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Np),this._instantiationService.setService(Nm,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Op,this.screenElement));this.element.appendChild(n);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(bp,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(Rp,this.element,this.screenElement,s)),this._instantiationService.setService(u5,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(Yn.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var l;this._selectionService.refresh(),(l=this._viewport)==null||l.queueSync()})),this._register(this._instantiationService.createInstance(Sp,this.screenElement)),this._register(lt(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(Du,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",l=>this._handleScreenReaderModeOptionChange(l))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Au,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",l=>{!this._overviewRulerRenderer&&l&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Au,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(kp,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,n=this.element;function i(l){var g,y,_,w,b;let d=e._mouseService.getMouseReportCoords(l,e.screenElement);if(!d)return!1;let h,f;switch(l.overrideType||l.type){case"mousemove":f=32,l.buttons===void 0?(h=3,l.button!==void 0&&(h=l.button<3?l.button:3)):h=l.buttons&1?0:l.buttons&4?1:l.buttons&2?2:3;break;case"mouseup":f=0,h=l.button<3?l.button:3;break;case"mousedown":f=1,h=l.button<3?l.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(l)===!1)return!1;let N=l.deltaY;if(N===0||e.coreMouseService.consumeWheelEvent(l,(w=(_=(y=(g=e._renderService)==null?void 0:g.dimensions)==null?void 0:y.device)==null?void 0:_.cell)==null?void 0:w.height,(b=e._coreBrowserService)==null?void 0:b.dpr)===0)return!1;f=N<0?0:1,h=4;break;default:return!1}return f===void 0||h===void 0||h>4?!1:e.coreMouseService.triggerMouseEvent({col:d.col,row:d.row,x:d.x,y:d.y,button:h,action:f,ctrl:l.ctrlKey,alt:l.altKey,shift:l.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},a={mouseup:l=>(i(l),l.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(l)),wheel:l=>(i(l),this.cancel(l,!0)),mousedrag:l=>{l.buttons&&i(l)},mousemove:l=>{l.buttons||i(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||(n.addEventListener("mousemove",a.mousemove),s.mousemove=a.mousemove):(n.removeEventListener("mousemove",s.mousemove),s.mousemove=null),l&16?s.wheel||(n.addEventListener("wheel",a.wheel,{passive:!1}),s.wheel=a.wheel):(n.removeEventListener("wheel",s.wheel),s.wheel=null),l&2?s.mouseup||(s.mouseup=a.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),l&4?s.mousedrag||(s.mousedrag=a.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(lt(n,"mousedown",l=>{if(l.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(l)))return i(l),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(l)})),this._register(lt(n,"wheel",l=>{var d,h,f,g,y;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,(g=(f=(h=(d=e._renderService)==null?void 0:d.dimensions)==null?void 0:h.device)==null?void 0:f.cell)==null?void 0:g.height,(y=e._coreBrowserService)==null?void 0:y.dpr)===0)return this.cancel(l,!0);let _=ve.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(l.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(_,!0),this.cancel(l,!0)}}},{passive:!1}))}refresh(e,n){var i;(i=this._renderService)==null||i.refreshRows(e,n)}updateCursorStyle(e){var n;(n=this._selectionService)!=null&&n.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,n){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,n),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let n=e-this._bufferService.buffer.ydisp;n!==0&&this.scrollLines(n)}paste(e){U0(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let n=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),n}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,n,i){this._selectionService.setSelection(e,n,i)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,n){var i;(i=this._selectionService)==null||i.selectLines(e,n)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let n=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!n&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!n&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let i=WN(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let s=this.rows-1;return this.scrollLines(i.type===2?-s:s),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.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((i.key===ve.ETX||i.key===ve.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,n){let i=e.isMac&&!this.options.macOptionIsMeta&&n.altKey&&!n.ctrlKey&&!n.metaKey||e.isWindows&&n.altKey&&n.ctrlKey&&!n.metaKey||e.isWindows&&n.getModifierState("AltGraph");return n.type==="keypress"?i:i&&(!n.keyCode||n.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(JN(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let n;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)n=e.charCode;else if(e.which===null||e.which===void 0)n=e.keyCode;else if(e.which!==0&&e.charCode!==0)n=e.which;else return!1;return!n||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(n=String.fromCharCode(n),this._onKey.fire({key:n,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let n=e.data;return this.coreService.triggerDataEvent(n,!0),this.cancel(e),!0}return!1}resize(e,n){if(e===this.cols&&n===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,n)}_afterResize(e,n){var i;(i=this._charSizeService)==null||i.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(Sn));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var n;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(n=this._selectionService)==null||n.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(ve.ESC+"[I"):this.coreService.triggerDataEvent(ve.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let n=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${ve.ESC}[4;${i};${n}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),a=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${ve.ESC}[6;${a};${s}t`);break}}cancel(e,n){if(!(!this.options.cancelEvents&&!n))return e.preventDefault(),e.stopPropagation(),!1}};function JN(t){return t.keyCode===16||t.keyCode===17||t.keyCode===18}var ZN=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,n){let i={instance:n,dispose:n.dispose,isDisposed:!1};this._addons.push(i),n.dispose=()=>this._wrappedAddonDispose(i),n.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let n=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){n=i;break}if(n===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(n,1)}},eL=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,n){if(!(e<0||e>=this._line.length))return n?(this._line.loadCell(e,n),n):this._line.loadCell(e,new Yi)}translateToString(e,n,i){return this._line.translateToString(e,n,i)}},Jy=class{constructor(t,e){this._buffer=t,this.type=e}init(t){return this._buffer=t,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(t){let e=this._buffer.lines.get(t);if(e)return new eL(e)}getNullCell(){return new Yi}},tL=class extends yt{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new Le),this.onBufferChange=this._onBufferChange.event,this._normal=new Jy(this._core.buffers.normal,"normal"),this._alternate=new Jy(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)}},nL=class{constructor(t){this._core=t}registerCsiHandler(t,e){return this._core.registerCsiHandler(t,n=>e(n.toArray()))}addCsiHandler(t,e){return this.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._core.registerDcsHandler(t,(n,i)=>e(n,i.toArray()))}addDcsHandler(t,e){return this.registerDcsHandler(t,e)}registerEscHandler(t,e){return this._core.registerEscHandler(t,e)}addEscHandler(t,e){return this.registerEscHandler(t,e)}registerOscHandler(t,e){return this._core.registerOscHandler(t,e)}addOscHandler(t,e){return this.registerOscHandler(t,e)}},iL=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}},sL=["cols","rows"],ps=0,rL=class extends yt{constructor(t){super(),this._core=this._register(new QN(t)),this._addonManager=this._register(new ZN),this._publicOptions={...this._core.options};let e=i=>this._core.options[i],n=(i,s)=>{this._checkReadonlyOptions(i),this._core.options[i]=s};for(let i in this._core.options){let s={get:e.bind(this,i),set:n.bind(this,i)};Object.defineProperty(this._publicOptions,i,s)}}_checkReadonlyOptions(t){if(sL.includes(t))throw new Error(`Option "${t}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new nL(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new iL(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 tL(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let t=this._core.coreService.decPrivateModes,e="none";switch(this._core.coreMouseService.activeProtocol){case"X10":e="x10";break;case"VT200":e="vt200";break;case"DRAG":e="drag";break;case"ANY":e="any";break}return{applicationCursorKeysMode:t.applicationCursorKeys,applicationKeypadMode:t.applicationKeypad,bracketedPasteMode:t.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:e,originMode:t.origin,reverseWraparoundMode:t.reverseWraparound,sendFocusMode:t.sendFocus,synchronizedOutputMode:t.synchronizedOutput,wraparoundMode:t.wraparound}}get options(){return this._publicOptions}set options(t){for(let e in t)this._publicOptions[e]=t[e]}blur(){this._core.blur()}focus(){this._core.focus()}input(t,e=!0){this._core.input(t,e)}resize(t,e){this._verifyIntegers(t,e),this._core.resize(t,e)}open(t){this._core.open(t)}attachCustomKeyEventHandler(t){this._core.attachCustomKeyEventHandler(t)}attachCustomWheelEventHandler(t){this._core.attachCustomWheelEventHandler(t)}registerLinkProvider(t){return this._core.registerLinkProvider(t)}registerCharacterJoiner(t){return this._checkProposedApi(),this._core.registerCharacterJoiner(t)}deregisterCharacterJoiner(t){this._checkProposedApi(),this._core.deregisterCharacterJoiner(t)}registerMarker(t=0){return this._verifyIntegers(t),this._core.registerMarker(t)}registerDecoration(t){return this._checkProposedApi(),this._verifyPositiveIntegers(t.x??0,t.width??0,t.height??0),this._core.registerDecoration(t)}hasSelection(){return this._core.hasSelection()}select(t,e,n){this._verifyIntegers(t,e,n),this._core.select(t,e,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(t,e){this._verifyIntegers(t,e),this._core.selectLines(t,e)}dispose(){super.dispose()}scrollLines(t){this._verifyIntegers(t),this._core.scrollLines(t)}scrollPages(t){this._verifyIntegers(t),this._core.scrollPages(t)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(t){this._verifyIntegers(t),this._core.scrollToLine(t)}clear(){this._core.clear()}write(t,e){this._core.write(t,e)}writeln(t,e){this._core.write(t),this._core.write(`\r
66
- `,e)}paste(t){this._core.paste(t)}refresh(t,e){this._verifyIntegers(t,e),this._core.refresh(t,e)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(t){this._addonManager.loadAddon(this,t)}static get strings(){return{get promptLabel(){return np.get()},set promptLabel(t){np.set(t)},get tooMuchOutput(){return ip.get()},set tooMuchOutput(t){ip.set(t)}}}_verifyIntegers(...t){for(ps of t)if(ps===1/0||isNaN(ps)||ps%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(ps of t)if(ps&&(ps===1/0||isNaN(ps)||ps%1!==0||ps<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 oL=2,aL=1,lL=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();if(!t||!this._terminal||isNaN(t.cols)||isNaN(t.rows))return;let e=this._terminal._core;(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(e._renderService.clear(),this._terminal.resize(t.cols,t.rows))}proposeDimensions(){var y;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let e=this._terminal.options.scrollback===0?0:((y=this._terminal.options.overviewRuler)==null?void 0:y.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(n.getPropertyValue("height")),s=Math.max(0,parseInt(n.getPropertyValue("width"))),a=window.getComputedStyle(this._terminal.element),l={top:parseInt(a.getPropertyValue("padding-top")),bottom:parseInt(a.getPropertyValue("padding-bottom")),right:parseInt(a.getPropertyValue("padding-right")),left:parseInt(a.getPropertyValue("padding-left"))},d=l.top+l.bottom,h=l.right+l.left,f=i-d,g=s-h-e;return{cols:Math.max(oL,Math.floor(g/t.css.cell.width)),rows:Math.max(aL,Math.floor(f/t.css.cell.height))}}};const cL=Object.freeze([[4352,4447],[8986,8987],[9001,9002],[9193,9196],[9200,9200],[9203,9203],[9725,9726],[9748,9749],[9800,9811],[9855,9855],[9875,9875],[9889,9889],[9898,9899],[9917,9918],[9924,9925],[9934,9934],[9940,9940],[9962,9962],[9970,9971],[9973,9973],[9978,9978],[9981,9981],[9989,9989],[9994,9995],[10024,10024],[10060,10060],[10062,10062],[10067,10069],[10071,10071],[10133,10135],[10160,10160],[10175,10175],[11035,11036],[11088,11088],[11093,11093],[11904,12350],[12352,12871],[12880,19903],[19968,42182],[43360,43388],[44032,55203],[63744,64255],[65040,65049],[65072,65131],[65281,65376],[65504,65510],[126976,127461],[127488,129791]]),uL=Object.freeze([[768,879],[1155,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1552,1562],[1611,1631],[1648,1648],[1750,1756],[1759,1764],[1767,1768],[1770,1773],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2070,2073],[2075,2083],[2085,2087],[2089,2093],[2137,2139],[2275,2307],[2362,2364],[2369,2376],[2381,2381],[2385,2391],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2817,2817],[2876,2876],[2879,2879],[2881,2884],[2893,2893],[3134,3136],[3142,3144],[3146,3149],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3772],[3784,3790],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[4038,4038],[4448,4607],[4957,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6155,6157],[6832,6911],[7616,7679],[8203,8207],[8232,8238],[8288,8292],[8294,8303],[8400,8432],[11503,11505],[11647,11647],[11744,11775],[12330,12335],[12441,12442],[42607,42610],[42612,42621],[42654,42655],[42736,42737],[43010,43010],[43014,43014],[43019,43019],[43045,43046],[43204,43205],[64286,64286],[65024,65039],[65056,65071],[65279,65279],[66045,66045],[66272,66272],[113824,113827],[119141,119145],[119149,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]]),dL="nc-15.1";function Zy(t,e){let n=0,i=t.length-1;for(;n<=i;){const s=n+i>>1,[a,l]=t[s];if(e<a)i=s-1;else if(e>l)n=s+1;else return!0}return!1}function hL(t,e,n){return(t&16777215)<<3|(e&3)<<1|(n?1:0)}function ew(t){const e=Number(t);return!Number.isFinite(e)||e<0||e<32||e>=127&&e<160||Zy(uL,e)?0:Zy(cL,e)?2:1}function fL(){return{version:dL,wcwidth:ew,charProperties(t,e){let n=ew(t),i=n===0&&e!==0;if(i){const s=e>>1&3;s===0?i=!1:s>n&&(n=s)}return hL(t,n,i)}}}function pL(t){try{const e=t&&t.unicode;if(!e||typeof e.register!="function")return null;const n=fL();return e.versions.includes(n.version)||e.register(n),e.activeVersion=n.version,n}catch{return null}}/**
78
- * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
79
- * @license MIT
80
- *
81
- * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
82
- * @license MIT
83
- *
84
- * Originally forked from (with the author's permission):
85
- * Fabrice Bellard's javascript vt100 for jslinux:
86
- * http://bellard.org/jslinux/
87
- * Copyright (c) 2011 Fabrice Bellard
88
- */var mL=(t,e,n,i)=>{for(var s=e,a=t.length-1,l;a>=0;a--)(l=t[a])&&(s=l(s)||s);return s},gL=(t,e)=>(n,i)=>e(n,i,t),vL=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?tw.isErrorNoTelemetry(t)?new tw(t.message+`
89
-
90
- `+t.stack):new Error(t.message+`
91
-
92
- `+t.stack):t},0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach(e=>{e(t)})}_removeListener(t){this.listeners.splice(this.listeners.indexOf(t),1)}setUnexpectedErrorHandler(t){this.unexpectedErrorHandler=t}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}onUnexpectedExternalError(t){this.unexpectedErrorHandler(t)}},_L=new vL;function Jh(t){yL(t)||_L.onUnexpectedError(t)}var $p="Canceled";function yL(t){return t instanceof wL?!0:t instanceof Error&&t.name===$p&&t.message===$p}var wL=class extends Error{constructor(){super($p),this.name=this.message}},tw=class zp extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof zp)return e;let n=new zp;return n.message=e.message,n.stack=e.stack,n}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},bL;(t=>{function e(a){return a<0}t.isLessThan=e;function n(a){return a<=0}t.isLessThanOrEqual=n;function i(a){return a>0}t.isGreaterThan=i;function s(a){return a===0}t.isNeitherLessOrGreaterThan=s,t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(bL||(bL={}));function SL(t,e){let n=this,i=!1,s;return function(){return i||(i=!0,e||(s=t.apply(n,arguments))),s}}var jS;(t=>{function e(T){return T&&typeof T=="object"&&typeof T[Symbol.iterator]=="function"}t.is=e;let n=Object.freeze([]);function i(){return n}t.empty=i;function*s(T){yield T}t.single=s;function a(T){return e(T)?T:s(T)}t.wrap=a;function l(T){return T||n}t.from=l;function*d(T){for(let W=T.length-1;W>=0;W--)yield T[W]}t.reverse=d;function h(T){return!T||T[Symbol.iterator]().next().done===!0}t.isEmpty=h;function f(T){return T[Symbol.iterator]().next().value}t.first=f;function g(T,W){let U=0;for(let Q of T)if(W(Q,U++))return!0;return!1}t.some=g;function y(T,W){for(let U of T)if(W(U))return U}t.find=y;function*_(T,W){for(let U of T)W(U)&&(yield U)}t.filter=_;function*w(T,W){let U=0;for(let Q of T)yield W(Q,U++)}t.map=w;function*b(T,W){let U=0;for(let Q of T)yield*W(Q,U++)}t.flatMap=b;function*N(...T){for(let W of T)yield*W}t.concat=N;function x(T,W,U){let Q=U;for(let ee of T)Q=W(Q,ee);return Q}t.reduce=x;function*E(T,W,U=T.length){for(W<0&&(W+=T.length),U<0?U+=T.length:U>T.length&&(U=T.length);W<U;W++)yield T[W]}t.slice=E;function C(T,W=Number.POSITIVE_INFINITY){let U=[];if(W===0)return[U,T];let Q=T[Symbol.iterator]();for(let ee=0;ee<W;ee++){let q=Q.next();if(q.done)return[U,t.empty()];U.push(q.value)}return[U,{[Symbol.iterator](){return Q}}]}t.consume=C;async function I(T){let W=[];for await(let U of T)W.push(U);return Promise.resolve(W)}t.asyncToArray=I})(jS||(jS={}));function PS(t){if(jS.is(t)){let e=[];for(let n of t)if(n)try{n.dispose()}catch(i){e.push(i)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}else if(t)return t.dispose(),t}function TS(...t){return ni(()=>PS(t))}function ni(t){return{dispose:SL(()=>{t()})}}var DS=class IS{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{PS(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?IS.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(e),e}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),void 0)}};DS.DISABLE_DISPOSED_WARNING=!1;var na=DS,rs=class{constructor(){this._store=new na,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};rs.None=Object.freeze({dispose(){}});var sl=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){var e;this._isDisposed||t===this._value||((e=this._value)==null||e.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){var t;this._isDisposed=!0,(t=this._value)==null||t.dispose(),this._value=void 0}clearAndLeak(){let t=this._value;return this._value=void 0,t}},Im=typeof process<"u"&&"title"in process,Xu=Im?"node":navigator.userAgent,xL=Im?"node":navigator.platform,CL=Xu.includes("Firefox"),kL=Xu.includes("Edge"),BS=/^((?!chrome|android).)*safari/i.test(Xu);function EL(){if(!BS)return 0;let t=Xu.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}xL.indexOf("Linux")>=0;var NL="",$n=0,zn=0,Fn=0,fn=0,Wi={css:"#00000000",rgba:0},ai;(t=>{function e(s,a,l,d){return d!==void 0?`#${Xr(s)}${Xr(a)}${Xr(l)}${Xr(d)}`:`#${Xr(s)}${Xr(a)}${Xr(l)}`}t.toCss=e;function n(s,a,l,d=255){return(s<<24|a<<16|l<<8|d)>>>0}t.toRgba=n;function i(s,a,l,d){return{css:t.toCss(s,a,l,d),rgba:t.toRgba(s,a,l,d)}}t.toColor=i})(ai||(ai={}));var yl;(t=>{function e(h,f){if(fn=(f.rgba&255)/255,fn===1)return{css:f.css,rgba:f.rgba};let g=f.rgba>>24&255,y=f.rgba>>16&255,_=f.rgba>>8&255,w=h.rgba>>24&255,b=h.rgba>>16&255,N=h.rgba>>8&255;$n=w+Math.round((g-w)*fn),zn=b+Math.round((y-b)*fn),Fn=N+Math.round((_-N)*fn);let x=ai.toCss($n,zn,Fn),E=ai.toRgba($n,zn,Fn);return{css:x,rgba:E}}t.blend=e;function n(h){return(h.rgba&255)===255}t.isOpaque=n;function i(h,f,g){let y=oo.ensureContrastRatio(h.rgba,f.rgba,g);if(y)return ai.toColor(y>>24&255,y>>16&255,y>>8&255)}t.ensureContrastRatio=i;function s(h){let f=(h.rgba|255)>>>0;return[$n,zn,Fn]=oo.toChannels(f),{css:ai.toCss($n,zn,Fn),rgba:f}}t.opaque=s;function a(h,f){return fn=Math.round(f*255),[$n,zn,Fn]=oo.toChannels(h.rgba),{css:ai.toCss($n,zn,Fn,fn),rgba:ai.toRgba($n,zn,Fn,fn)}}t.opacity=a;function l(h,f){return fn=h.rgba&255,a(h,fn*f/255)}t.multiplyOpacity=l;function d(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}t.toColorRGB=d})(yl||(yl={}));var LL;(t=>{let e,n;try{let s=document.createElement("canvas");s.width=1,s.height=1;let a=s.getContext("2d",{willReadFrequently:!0});a&&(e=a,e.globalCompositeOperation="copy",n=e.createLinearGradient(0,0,1,1))}catch{}function i(s){if(s.match(/#[\da-f]{3,8}/i))switch(s.length){case 4:return $n=parseInt(s.slice(1,2).repeat(2),16),zn=parseInt(s.slice(2,3).repeat(2),16),Fn=parseInt(s.slice(3,4).repeat(2),16),ai.toColor($n,zn,Fn);case 5:return $n=parseInt(s.slice(1,2).repeat(2),16),zn=parseInt(s.slice(2,3).repeat(2),16),Fn=parseInt(s.slice(3,4).repeat(2),16),fn=parseInt(s.slice(4,5).repeat(2),16),ai.toColor($n,zn,Fn,fn);case 7:return{css:s,rgba:(parseInt(s.slice(1),16)<<8|255)>>>0};case 9:return{css:s,rgba:parseInt(s.slice(1),16)>>>0}}let a=s.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(a)return $n=parseInt(a[1]),zn=parseInt(a[2]),Fn=parseInt(a[3]),fn=Math.round((a[5]===void 0?1:parseFloat(a[5]))*255),ai.toColor($n,zn,Fn,fn);if(!e||!n)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=n,e.fillStyle=s,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[$n,zn,Fn,fn]=e.getImageData(0,0,1,1).data,fn!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ai.toRgba($n,zn,Fn,fn),css:s}}t.toColor=i})(LL||(LL={}));var oi;(t=>{function e(i){return n(i>>16&255,i>>8&255,i&255)}t.relativeLuminance=e;function n(i,s,a){let l=i/255,d=s/255,h=a/255,f=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),g=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),y=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return f*.2126+g*.7152+y*.0722}t.relativeLuminance2=n})(oi||(oi={}));var oo;(t=>{function e(l,d){if(fn=(d&255)/255,fn===1)return d;let h=d>>24&255,f=d>>16&255,g=d>>8&255,y=l>>24&255,_=l>>16&255,w=l>>8&255;return $n=y+Math.round((h-y)*fn),zn=_+Math.round((f-_)*fn),Fn=w+Math.round((g-w)*fn),ai.toRgba($n,zn,Fn)}t.blend=e;function n(l,d,h){let f=oi.relativeLuminance(l>>8),g=oi.relativeLuminance(d>>8);if($s(f,g)<h){if(g<f){let w=i(l,d,h),b=$s(f,oi.relativeLuminance(w>>8));if(b<h){let N=s(l,d,h),x=$s(f,oi.relativeLuminance(N>>8));return b>x?w:N}return w}let y=s(l,d,h),_=$s(f,oi.relativeLuminance(y>>8));if(_<h){let w=i(l,d,h),b=$s(f,oi.relativeLuminance(w>>8));return _>b?y:w}return y}}t.ensureContrastRatio=n;function i(l,d,h){let f=l>>24&255,g=l>>16&255,y=l>>8&255,_=d>>24&255,w=d>>16&255,b=d>>8&255,N=$s(oi.relativeLuminance2(_,w,b),oi.relativeLuminance2(f,g,y));for(;N<h&&(_>0||w>0||b>0);)_-=Math.max(0,Math.ceil(_*.1)),w-=Math.max(0,Math.ceil(w*.1)),b-=Math.max(0,Math.ceil(b*.1)),N=$s(oi.relativeLuminance2(_,w,b),oi.relativeLuminance2(f,g,y));return(_<<24|w<<16|b<<8|255)>>>0}t.reduceLuminance=i;function s(l,d,h){let f=l>>24&255,g=l>>16&255,y=l>>8&255,_=d>>24&255,w=d>>16&255,b=d>>8&255,N=$s(oi.relativeLuminance2(_,w,b),oi.relativeLuminance2(f,g,y));for(;N<h&&(_<255||w<255||b<255);)_=Math.min(255,_+Math.ceil((255-_)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),b=Math.min(255,b+Math.ceil((255-b)*.1)),N=$s(oi.relativeLuminance2(_,w,b),oi.relativeLuminance2(f,g,y));return(_<<24|w<<16|b<<8|255)>>>0}t.increaseLuminance=s;function a(l){return[l>>24&255,l>>16&255,l>>8&255,l&255]}t.toChannels=a})(oo||(oo={}));function Xr(t){let e=t.toString(16);return e.length<2?"0"+e:e}function $s(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}function xn(t){if(!t)throw new Error("value must not be falsy");return t}function Bm(t){return 57508<=t&&t<=57558}function RL(t){return 57520<=t&&t<=57527}function ML(t){return 57344<=t&&t<=63743}function AL(t){return 9472<=t&&t<=9631}function jL(t){return t>=128512&&t<=128591||t>=127744&&t<=128511||t>=128640&&t<=128767||t>=9728&&t<=9983||t>=9984&&t<=10175||t>=65024&&t<=65039||t>=129280&&t<=129535||t>=127462&&t<=127487}function PL(t,e,n,i){return e===1&&n>Math.ceil(i*1.5)&&t!==void 0&&t>255&&!jL(t)&&!Bm(t)&&!ML(t)}function OS(t){return Bm(t)||AL(t)}function TL(){return{css:{canvas:Jc(),cell:Jc()},device:{canvas:Jc(),cell:Jc(),char:{width:0,height:0,left:0,top:0}}}}function Jc(){return{width:0,height:0}}function DL(t,e,n=0){return(t-(Math.round(e)*2-n))%(Math.round(e)*2)}var qn=0,Tn=0,ms=!1,zs=!1,Zc=!1,Si,Zh=0,IL=class{constructor(t,e,n,i,s,a){this._terminal=t,this._optionService=e,this._selectionRenderModel=n,this._decorationService=i,this._coreBrowserService=s,this._themeService=a,this.result={fg:0,bg:0,ext:0}}resolve(t,e,n,i){if(this.result.bg=t.bg,this.result.fg=t.fg,this.result.ext=t.bg&268435456?t.extended.ext:0,Tn=0,qn=0,zs=!1,ms=!1,Zc=!1,Si=this._themeService.colors,Zh=0,t.getCode()!==0&&t.extended.underlineStyle===4){let s=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));Zh=e*i%(Math.round(s)*2)}if(this._decorationService.forEachDecorationAtCell(e,n,"bottom",s=>{s.backgroundColorRGB&&(Tn=s.backgroundColorRGB.rgba>>8&16777215,zs=!0),s.foregroundColorRGB&&(qn=s.foregroundColorRGB.rgba>>8&16777215,ms=!0)}),Zc=this._selectionRenderModel.isCellSelected(this._terminal,e,n),Zc){if(this.result.fg&67108864||(this.result.bg&50331648)!==0){if(this.result.fg&67108864)switch(this.result.fg&50331648){case 16777216:case 33554432:Tn=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:Tn=(this.result.fg&16777215)<<8|255;break;case 0:default:Tn=this._themeService.colors.foreground.rgba}else switch(this.result.bg&50331648){case 16777216:case 33554432:Tn=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:Tn=(this.result.bg&16777215)<<8|255;break}Tn=oo.blend(Tn,(this._coreBrowserService.isFocused?Si.selectionBackgroundOpaque:Si.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else Tn=(this._coreBrowserService.isFocused?Si.selectionBackgroundOpaque:Si.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(zs=!0,Si.selectionForeground&&(qn=Si.selectionForeground.rgba>>8&16777215,ms=!0),OS(t.getCode())){if(this.result.fg&67108864&&(this.result.bg&50331648)===0)qn=(this._coreBrowserService.isFocused?Si.selectionBackgroundOpaque:Si.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:qn=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:qn=(this.result.bg&16777215)<<8|255;break}else switch(this.result.fg&50331648){case 16777216:case 33554432:qn=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:qn=(this.result.fg&16777215)<<8|255;break;case 0:default:qn=this._themeService.colors.foreground.rgba}qn=oo.blend(qn,(this._coreBrowserService.isFocused?Si.selectionBackgroundOpaque:Si.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}ms=!0}}this._decorationService.forEachDecorationAtCell(e,n,"top",s=>{s.backgroundColorRGB&&(Tn=s.backgroundColorRGB.rgba>>8&16777215,zs=!0),s.foregroundColorRGB&&(qn=s.foregroundColorRGB.rgba>>8&16777215,ms=!0)}),zs&&(Zc?Tn=t.bg&-16777216&-134217729|Tn|50331648:Tn=t.bg&-16777216|Tn|50331648),ms&&(qn=t.fg&-16777216&-67108865|qn|50331648),this.result.fg&67108864&&(zs&&!ms&&((this.result.bg&50331648)===0?qn=this.result.fg&-134217728|Si.background.rgba>>8&16777215&16777215|50331648:qn=this.result.fg&-134217728|this.result.bg&67108863,ms=!0),!zs&&ms&&((this.result.fg&50331648)===0?Tn=this.result.bg&-67108864|Si.foreground.rgba>>8&16777215&16777215|50331648:Tn=this.result.bg&-67108864|this.result.fg&67108863,zs=!0)),Si=void 0,this.result.bg=zs?Tn:this.result.bg,this.result.fg=ms?qn:this.result.fg,this.result.ext&=536870911,this.result.ext|=Zh<<29&3758096384}},BL=.5,$S=CL||kL?"bottom":"ideographic",OL={"▀":[{x:0,y:0,w:8,h:4}],"▁":[{x:0,y:7,w:8,h:1}],"▂":[{x:0,y:6,w:8,h:2}],"▃":[{x:0,y:5,w:8,h:3}],"▄":[{x:0,y:4,w:8,h:4}],"▅":[{x:0,y:3,w:8,h:5}],"▆":[{x:0,y:2,w:8,h:6}],"▇":[{x:0,y:1,w:8,h:7}],"█":[{x:0,y:0,w:8,h:8}],"▉":[{x:0,y:0,w:7,h:8}],"▊":[{x:0,y:0,w:6,h:8}],"▋":[{x:0,y:0,w:5,h:8}],"▌":[{x:0,y:0,w:4,h:8}],"▍":[{x:0,y:0,w:3,h:8}],"▎":[{x:0,y:0,w:2,h:8}],"▏":[{x:0,y:0,w:1,h:8}],"▐":[{x:4,y:0,w:4,h:8}],"▔":[{x:0,y:0,w:8,h:1}],"▕":[{x:7,y:0,w:1,h:8}],"▖":[{x:0,y:4,w:4,h:4}],"▗":[{x:4,y:4,w:4,h:4}],"▘":[{x:0,y:0,w:4,h:4}],"▙":[{x:0,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"▚":[{x:0,y:0,w:4,h:4},{x:4,y:4,w:4,h:4}],"▛":[{x:0,y:0,w:4,h:8},{x:4,y:0,w:4,h:4}],"▜":[{x:0,y:0,w:8,h:4},{x:4,y:0,w:4,h:8}],"▝":[{x:4,y:0,w:4,h:4}],"▞":[{x:4,y:0,w:4,h:4},{x:0,y:4,w:4,h:4}],"▟":[{x:4,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"🭰":[{x:1,y:0,w:1,h:8}],"🭱":[{x:2,y:0,w:1,h:8}],"🭲":[{x:3,y:0,w:1,h:8}],"🭳":[{x:4,y:0,w:1,h:8}],"🭴":[{x:5,y:0,w:1,h:8}],"🭵":[{x:6,y:0,w:1,h:8}],"🭶":[{x:0,y:1,w:8,h:1}],"🭷":[{x:0,y:2,w:8,h:1}],"🭸":[{x:0,y:3,w:8,h:1}],"🭹":[{x:0,y:4,w:8,h:1}],"🭺":[{x:0,y:5,w:8,h:1}],"🭻":[{x:0,y:6,w:8,h:1}],"🭼":[{x:0,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🭽":[{x:0,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭾":[{x:7,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭿":[{x:7,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🮀":[{x:0,y:0,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮁":[{x:0,y:0,w:8,h:1},{x:0,y:2,w:8,h:1},{x:0,y:4,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮂":[{x:0,y:0,w:8,h:2}],"🮃":[{x:0,y:0,w:8,h:3}],"🮄":[{x:0,y:0,w:8,h:5}],"🮅":[{x:0,y:0,w:8,h:6}],"🮆":[{x:0,y:0,w:8,h:7}],"🮇":[{x:6,y:0,w:2,h:8}],"🮈":[{x:5,y:0,w:3,h:8}],"🮉":[{x:3,y:0,w:5,h:8}],"🮊":[{x:2,y:0,w:6,h:8}],"🮋":[{x:1,y:0,w:7,h:8}],"🮕":[{x:0,y:0,w:2,h:2},{x:4,y:0,w:2,h:2},{x:2,y:2,w:2,h:2},{x:6,y:2,w:2,h:2},{x:0,y:4,w:2,h:2},{x:4,y:4,w:2,h:2},{x:2,y:6,w:2,h:2},{x:6,y:6,w:2,h:2}],"🮖":[{x:2,y:0,w:2,h:2},{x:6,y:0,w:2,h:2},{x:0,y:2,w:2,h:2},{x:4,y:2,w:2,h:2},{x:2,y:4,w:2,h:2},{x:6,y:4,w:2,h:2},{x:0,y:6,w:2,h:2},{x:4,y:6,w:2,h:2}],"🮗":[{x:0,y:2,w:8,h:2},{x:0,y:6,w:8,h:2}]},$L={"░":[[1,0,0,0],[0,0,0,0],[0,0,1,0],[0,0,0,0]],"▒":[[1,0],[0,0],[0,1],[0,0]],"▓":[[0,1],[1,1],[1,0],[1,1]]},zL={"─":{1:"M0,.5 L1,.5"},"━":{3:"M0,.5 L1,.5"},"│":{1:"M.5,0 L.5,1"},"┃":{3:"M.5,0 L.5,1"},"┌":{1:"M0.5,1 L.5,.5 L1,.5"},"┏":{3:"M0.5,1 L.5,.5 L1,.5"},"┐":{1:"M0,.5 L.5,.5 L.5,1"},"┓":{3:"M0,.5 L.5,.5 L.5,1"},"└":{1:"M.5,0 L.5,.5 L1,.5"},"┗":{3:"M.5,0 L.5,.5 L1,.5"},"┘":{1:"M.5,0 L.5,.5 L0,.5"},"┛":{3:"M.5,0 L.5,.5 L0,.5"},"├":{1:"M.5,0 L.5,1 M.5,.5 L1,.5"},"┣":{3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"┤":{1:"M.5,0 L.5,1 M.5,.5 L0,.5"},"┫":{3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"┬":{1:"M0,.5 L1,.5 M.5,.5 L.5,1"},"┳":{3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"┴":{1:"M0,.5 L1,.5 M.5,.5 L.5,0"},"┻":{3:"M0,.5 L1,.5 M.5,.5 L.5,0"},"┼":{1:"M0,.5 L1,.5 M.5,0 L.5,1"},"╋":{3:"M0,.5 L1,.5 M.5,0 L.5,1"},"╴":{1:"M.5,.5 L0,.5"},"╸":{3:"M.5,.5 L0,.5"},"╵":{1:"M.5,.5 L.5,0"},"╹":{3:"M.5,.5 L.5,0"},"╶":{1:"M.5,.5 L1,.5"},"╺":{3:"M.5,.5 L1,.5"},"╷":{1:"M.5,.5 L.5,1"},"╻":{3:"M.5,.5 L.5,1"},"═":{1:(t,e)=>`M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e}`},"║":{1:(t,e)=>`M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1`},"╒":{1:(t,e)=>`M.5,1 L.5,${.5-e} L1,${.5-e} M.5,${.5+e} L1,${.5+e}`},"╓":{1:(t,e)=>`M${.5-t},1 L${.5-t},.5 L1,.5 M${.5+t},.5 L${.5+t},1`},"╔":{1:(t,e)=>`M1,${.5-e} L${.5-t},${.5-e} L${.5-t},1 M1,${.5+e} L${.5+t},${.5+e} L${.5+t},1`},"╕":{1:(t,e)=>`M0,${.5-e} L.5,${.5-e} L.5,1 M0,${.5+e} L.5,${.5+e}`},"╖":{1:(t,e)=>`M${.5+t},1 L${.5+t},.5 L0,.5 M${.5-t},.5 L${.5-t},1`},"╗":{1:(t,e)=>`M0,${.5+e} L${.5-t},${.5+e} L${.5-t},1 M0,${.5-e} L${.5+t},${.5-e} L${.5+t},1`},"╘":{1:(t,e)=>`M.5,0 L.5,${.5+e} L1,${.5+e} M.5,${.5-e} L1,${.5-e}`},"╙":{1:(t,e)=>`M1,.5 L${.5-t},.5 L${.5-t},0 M${.5+t},.5 L${.5+t},0`},"╚":{1:(t,e)=>`M1,${.5-e} L${.5+t},${.5-e} L${.5+t},0 M1,${.5+e} L${.5-t},${.5+e} L${.5-t},0`},"╛":{1:(t,e)=>`M0,${.5+e} L.5,${.5+e} L.5,0 M0,${.5-e} L.5,${.5-e}`},"╜":{1:(t,e)=>`M0,.5 L${.5+t},.5 L${.5+t},0 M${.5-t},.5 L${.5-t},0`},"╝":{1:(t,e)=>`M0,${.5-e} L${.5-t},${.5-e} L${.5-t},0 M0,${.5+e} L${.5+t},${.5+e} L${.5+t},0`},"╞":{1:(t,e)=>`M.5,0 L.5,1 M.5,${.5-e} L1,${.5-e} M.5,${.5+e} L1,${.5+e}`},"╟":{1:(t,e)=>`M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1 M${.5+t},.5 L1,.5`},"╠":{1:(t,e)=>`M${.5-t},0 L${.5-t},1 M1,${.5+e} L${.5+t},${.5+e} L${.5+t},1 M1,${.5-e} L${.5+t},${.5-e} L${.5+t},0`},"╡":{1:(t,e)=>`M.5,0 L.5,1 M0,${.5-e} L.5,${.5-e} M0,${.5+e} L.5,${.5+e}`},"╢":{1:(t,e)=>`M0,.5 L${.5-t},.5 M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1`},"╣":{1:(t,e)=>`M${.5+t},0 L${.5+t},1 M0,${.5+e} L${.5-t},${.5+e} L${.5-t},1 M0,${.5-e} L${.5-t},${.5-e} L${.5-t},0`},"╤":{1:(t,e)=>`M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e} M.5,${.5+e} L.5,1`},"╥":{1:(t,e)=>`M0,.5 L1,.5 M${.5-t},.5 L${.5-t},1 M${.5+t},.5 L${.5+t},1`},"╦":{1:(t,e)=>`M0,${.5-e} L1,${.5-e} M0,${.5+e} L${.5-t},${.5+e} L${.5-t},1 M1,${.5+e} L${.5+t},${.5+e} L${.5+t},1`},"╧":{1:(t,e)=>`M.5,0 L.5,${.5-e} M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e}`},"╨":{1:(t,e)=>`M0,.5 L1,.5 M${.5-t},.5 L${.5-t},0 M${.5+t},.5 L${.5+t},0`},"╩":{1:(t,e)=>`M0,${.5+e} L1,${.5+e} M0,${.5-e} L${.5-t},${.5-e} L${.5-t},0 M1,${.5-e} L${.5+t},${.5-e} L${.5+t},0`},"╪":{1:(t,e)=>`M.5,0 L.5,1 M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e}`},"╫":{1:(t,e)=>`M0,.5 L1,.5 M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1`},"╬":{1:(t,e)=>`M0,${.5+e} L${.5-t},${.5+e} L${.5-t},1 M1,${.5+e} L${.5+t},${.5+e} L${.5+t},1 M0,${.5-e} L${.5-t},${.5-e} L${.5-t},0 M1,${.5-e} L${.5+t},${.5-e} L${.5+t},0`},"╱":{1:"M1,0 L0,1"},"╲":{1:"M0,0 L1,1"},"╳":{1:"M1,0 L0,1 M0,0 L1,1"},"╼":{1:"M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"╽":{1:"M.5,.5 L.5,0",3:"M.5,.5 L.5,1"},"╾":{1:"M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"╿":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"┍":{1:"M.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"┎":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"┑":{1:"M.5,.5 L.5,1",3:"M.5,.5 L0,.5"},"┒":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"┕":{1:"M.5,.5 L.5,0",3:"M.5,.5 L1,.5"},"┖":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"┙":{1:"M.5,.5 L.5,0",3:"M.5,.5 L0,.5"},"┚":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,0"},"┝":{1:"M.5,0 L.5,1",3:"M.5,.5 L1,.5"},"┞":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"┟":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"┠":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1"},"┡":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"┢":{1:"M.5,.5 L.5,0",3:"M0.5,1 L.5,.5 L1,.5"},"┥":{1:"M.5,0 L.5,1",3:"M.5,.5 L0,.5"},"┦":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"┧":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"┨":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1"},"┩":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L0,.5"},"┪":{1:"M.5,.5 L.5,0",3:"M0,.5 L.5,.5 L.5,1"},"┭":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┮":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"┯":{1:"M.5,.5 L.5,1",3:"M0,.5 L1,.5"},"┰":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"┱":{1:"M.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"┲":{1:"M.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"┵":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┶":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"┷":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5"},"┸":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,0"},"┹":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"┺":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,.5 L1,.5"},"┽":{1:"M.5,0 L.5,1 M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┾":{1:"M.5,0 L.5,1 M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"┿":{1:"M.5,0 L.5,1",3:"M0,.5 L1,.5"},"╀":{1:"M0,.5 L1,.5 M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"╁":{1:"M.5,.5 L.5,0 M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"╂":{1:"M0,.5 L1,.5",3:"M.5,0 L.5,1"},"╃":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"╄":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"╅":{1:"M.5,0 L.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"╆":{1:"M.5,0 L.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"╇":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0 M0,.5 L1,.5"},"╈":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"╉":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"╊":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"╌":{1:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"╍":{3:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"┄":{1:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"┅":{3:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"┈":{1:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5"},"┉":{3:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5"},"╎":{1:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"╏":{3:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"┆":{1:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"┇":{3:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"┊":{1:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"┋":{3:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"╭":{1:(t,e)=>`M.5,1 L.5,${.5+e/.15*.5} C.5,${.5+e/.15*.5},.5,.5,1,.5`},"╮":{1:(t,e)=>`M.5,1 L.5,${.5+e/.15*.5} C.5,${.5+e/.15*.5},.5,.5,0,.5`},"╯":{1:(t,e)=>`M.5,0 L.5,${.5-e/.15*.5} C.5,${.5-e/.15*.5},.5,.5,0,.5`},"╰":{1:(t,e)=>`M.5,0 L.5,${.5-e/.15*.5} C.5,${.5-e/.15*.5},.5,.5,1,.5`}},Ll={"":{d:"M.3,1 L.03,1 L.03,.88 C.03,.82,.06,.78,.11,.73 C.15,.7,.2,.68,.28,.65 L.43,.6 C.49,.58,.53,.56,.56,.53 C.59,.5,.6,.47,.6,.43 L.6,.27 L.4,.27 L.69,.1 L.98,.27 L.78,.27 L.78,.46 C.78,.52,.76,.56,.72,.61 C.68,.66,.63,.67,.56,.7 L.48,.72 C.42,.74,.38,.76,.35,.78 C.32,.8,.31,.84,.31,.88 L.31,1 M.3,.5 L.03,.59 L.03,.09 L.3,.09 L.3,.655",type:0},"":{d:"M.7,.4 L.7,.47 L.2,.47 L.2,.03 L.355,.03 L.355,.4 L.705,.4 M.7,.5 L.86,.5 L.86,.95 L.69,.95 L.44,.66 L.46,.86 L.46,.95 L.3,.95 L.3,.49 L.46,.49 L.71,.78 L.69,.565 L.69,.5",type:0},"":{d:"M.25,.94 C.16,.94,.11,.92,.11,.87 L.11,.53 C.11,.48,.15,.455,.23,.45 L.23,.3 C.23,.25,.26,.22,.31,.19 C.36,.16,.43,.15,.51,.15 C.59,.15,.66,.16,.71,.19 C.77,.22,.79,.26,.79,.3 L.79,.45 C.87,.45,.91,.48,.91,.53 L.91,.87 C.91,.92,.86,.94,.77,.94 L.24,.94 M.53,.2 C.49,.2,.45,.21,.42,.23 C.39,.25,.38,.27,.38,.3 L.38,.45 L.68,.45 L.68,.3 C.68,.27,.67,.25,.64,.23 C.61,.21,.58,.2,.53,.2 M.58,.82 L.58,.66 C.63,.65,.65,.63,.65,.6 C.65,.58,.64,.57,.61,.56 C.58,.55,.56,.54,.52,.54 C.48,.54,.46,.55,.43,.56 C.4,.57,.39,.59,.39,.6 C.39,.63,.41,.64,.46,.66 L.46,.82 L.57,.82",type:0},"":{d:"M0,0 L1,.5 L0,1",type:0,rightPadding:2},"":{d:"M-1,-.5 L1,.5 L-1,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M1,0 L0,.5 L1,1",type:0,leftPadding:2},"":{d:"M2,-.5 L0,.5 L2,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M0,0 L0,1 C0.552,1,1,0.776,1,.5 C1,0.224,0.552,0,0,0",type:0,rightPadding:1},"":{d:"M.2,1 C.422,1,.8,.826,.78,.5 C.8,.174,0.422,0,.2,0",type:1,rightPadding:1},"":{d:"M1,0 L1,1 C0.448,1,0,0.776,0,.5 C0,0.224,0.448,0,1,0",type:0,leftPadding:1},"":{d:"M.8,1 C0.578,1,0.2,.826,.22,.5 C0.2,0.174,0.578,0,0.8,0",type:1,leftPadding:1},"":{d:"M-.5,-.5 L1.5,1.5 L-.5,1.5",type:0},"":{d:"M-.5,-.5 L1.5,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M1.5,-.5 L-.5,1.5 L1.5,1.5",type:0},"":{d:"M1.5,-.5 L-.5,1.5 L-.5,-.5",type:0},"":{d:"M1.5,-.5 L-.5,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M-.5,-.5 L1.5,1.5 L1.5,-.5",type:0}};Ll[""]=Ll[""];Ll[""]=Ll[""];function FL(t,e,n,i,s,a,l,d){let h=OL[e];if(h)return HL(t,h,n,i,s,a),!0;let f=$L[e];if(f)return UL(t,f,n,i,s,a),!0;let g=zL[e];if(g)return WL(t,g,n,i,s,a,d),!0;let y=Ll[e];return y?(qL(t,y,n,i,s,a,l,d),!0):!1}function HL(t,e,n,i,s,a){for(let l=0;l<e.length;l++){let d=e[l],h=s/8,f=a/8;t.fillRect(n+d.x*h,i+d.y*f,d.w*h,d.h*f)}}var nw=new Map;function UL(t,e,n,i,s,a){let l=nw.get(e);l||(l=new Map,nw.set(e,l));let d=t.fillStyle;if(typeof d!="string")throw new Error(`Unexpected fillStyle type "${d}"`);let h=l.get(d);if(!h){let f=e[0].length,g=e.length,y=t.canvas.ownerDocument.createElement("canvas");y.width=f,y.height=g;let _=xn(y.getContext("2d")),w=new ImageData(f,g),b,N,x,E;if(d.startsWith("#"))b=parseInt(d.slice(1,3),16),N=parseInt(d.slice(3,5),16),x=parseInt(d.slice(5,7),16),E=d.length>7&&parseInt(d.slice(7,9),16)||1;else if(d.startsWith("rgba"))[b,N,x,E]=d.substring(5,d.length-1).split(",").map(C=>parseFloat(C));else throw new Error(`Unexpected fillStyle color format "${d}" when drawing pattern glyph`);for(let C=0;C<g;C++)for(let I=0;I<f;I++)w.data[(C*f+I)*4]=b,w.data[(C*f+I)*4+1]=N,w.data[(C*f+I)*4+2]=x,w.data[(C*f+I)*4+3]=e[C][I]*(E*255);_.putImageData(w,0,0),h=xn(t.createPattern(y,null)),l.set(d,h)}t.fillStyle=h,t.fillRect(n,i,s,a)}function WL(t,e,n,i,s,a,l){t.strokeStyle=t.fillStyle;for(let[d,h]of Object.entries(e)){t.beginPath(),t.lineWidth=l*Number.parseInt(d);let f;if(typeof h=="function"){let g=.15/a*s;f=h(.15,g)}else f=h;for(let g of f.split(" ")){let y=g[0],_=zS[y];if(!_){console.error(`Could not find drawing instructions for "${y}"`);continue}let w=g.substring(1).split(",");!w[0]||!w[1]||_(t,FS(w,s,a,n,i,!0,l))}t.stroke(),t.closePath()}}function qL(t,e,n,i,s,a,l,d){let h=new Path2D;h.rect(n,i,s,a),t.clip(h),t.beginPath();let f=l/12;t.lineWidth=d*f;for(let g of e.d.split(" ")){let y=g[0],_=zS[y];if(!_){console.error(`Could not find drawing instructions for "${y}"`);continue}let w=g.substring(1).split(",");!w[0]||!w[1]||_(t,FS(w,s,a,n,i,!1,d,(e.leftPadding??0)*(f/2),(e.rightPadding??0)*(f/2)))}e.type===1?(t.strokeStyle=t.fillStyle,t.stroke()):t.fill(),t.closePath()}function iw(t,e,n=0){return Math.max(Math.min(t,e),n)}var zS={C:(t,e)=>t.bezierCurveTo(e[0],e[1],e[2],e[3],e[4],e[5]),L:(t,e)=>t.lineTo(e[0],e[1]),M:(t,e)=>t.moveTo(e[0],e[1])};function FS(t,e,n,i,s,a,l,d=0,h=0){let f=t.map(g=>parseFloat(g)||parseInt(g));if(f.length<2)throw new Error("Too few arguments for instruction");for(let g=0;g<f.length;g+=2)f[g]*=e-d*l-h*l,a&&f[g]!==0&&(f[g]=iw(Math.round(f[g]+.5)-.5,e,0)),f[g]+=i+d*l;for(let g=1;g<f.length;g+=2)f[g]*=n,a&&f[g]!==0&&(f[g]=iw(Math.round(f[g]+.5)-.5,n,0)),f[g]+=s;return f}var sw=class{constructor(){this._data={}}set(t,e,n){this._data[t]||(this._data[t]={}),this._data[t][e]=n}get(t,e){return this._data[t]?this._data[t][e]:void 0}clear(){this._data={}}},rw=class{constructor(){this._data=new sw}set(t,e,n,i,s){this._data.get(t,e)||this._data.set(t,e,new sw),this._data.get(t,e).set(n,i,s)}get(t,e,n,i){var s;return(s=this._data.get(t,e))==null?void 0:s.get(n,i)}clear(){this._data.clear()}},HS=class{constructor(){this._tasks=[],this._i=0}enqueue(t){this._tasks.push(t),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(t){this._idleCallback=void 0;let e=0,n=0,i=t.timeRemaining(),s=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),n=Math.max(e,n),s=t.timeRemaining(),n*1.5>s){i-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-e))}ms`),this._start();return}i=s}this.clear()}},KL=class extends HS{_requestCallback(t){return setTimeout(()=>t(this._createDeadline(16)))}_cancelCallback(t){clearTimeout(t)}_createDeadline(t){let e=performance.now()+t;return{timeRemaining:()=>Math.max(0,e-performance.now())}}},VL=class extends HS{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},YL=!Im&&"requestIdleCallback"in window?VL:KL,Jo=class US{constructor(){this.fg=0,this.bg=0,this.extended=new WS}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new US;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},WS=class qS{constructor(e=0,n=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new qS(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},GL=globalThis.performance&&typeof globalThis.performance.now=="function",XL=class KS{static create(e){return new KS(e)}constructor(e){this._now=GL&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Ks;(t=>{t.None=()=>rs.None;function e(M,L){return y(M,()=>{},0,void 0,!0,void 0,L)}t.defer=e;function n(M){return(L,j=null,O)=>{let P=!1,A;return A=M(R=>{if(!P)return A?A.dispose():P=!0,L.call(j,R)},null,O),P&&A.dispose(),A}}t.once=n;function i(M,L,j){return f((O,P=null,A)=>M(R=>O.call(P,L(R)),null,A),j)}t.map=i;function s(M,L,j){return f((O,P=null,A)=>M(R=>{L(R),O.call(P,R)},null,A),j)}t.forEach=s;function a(M,L,j){return f((O,P=null,A)=>M(R=>L(R)&&O.call(P,R),null,A),j)}t.filter=a;function l(M){return M}t.signal=l;function d(...M){return(L,j=null,O)=>{let P=TS(...M.map(A=>A(R=>L.call(j,R))));return g(P,O)}}t.any=d;function h(M,L,j,O){let P=j;return i(M,A=>(P=L(P,A),P),O)}t.reduce=h;function f(M,L){let j,O={onWillAddFirstListener(){j=M(P.fire,P)},onDidRemoveLastListener(){j==null||j.dispose()}},P=new Qt(O);return L==null||L.add(P),P.event}function g(M,L){return L instanceof Array?L.push(M):L&&L.add(M),M}function y(M,L,j=100,O=!1,P=!1,A,R){let D,H,z,F=0,K,ne={leakWarningThreshold:A,onWillAddFirstListener(){D=M(Y=>{F++,H=L(H,Y),O&&!z&&(re.fire(H),H=void 0),K=()=>{let de=H;H=void 0,z=void 0,(!O||F>1)&&re.fire(de),F=0},typeof j=="number"?(clearTimeout(z),z=setTimeout(K,j)):z===void 0&&(z=0,queueMicrotask(K))})},onWillRemoveListener(){P&&F>0&&(K==null||K())},onDidRemoveLastListener(){K=void 0,D.dispose()}},re=new Qt(ne);return R==null||R.add(re),re.event}t.debounce=y;function _(M,L=0,j){return t.debounce(M,(O,P)=>O?(O.push(P),O):[P],L,void 0,!0,void 0,j)}t.accumulate=_;function w(M,L=(O,P)=>O===P,j){let O=!0,P;return a(M,A=>{let R=O||!L(A,P);return O=!1,P=A,R},j)}t.latch=w;function b(M,L,j){return[t.filter(M,L,j),t.filter(M,O=>!L(O),j)]}t.split=b;function N(M,L=!1,j=[],O){let P=j.slice(),A=M(H=>{P?P.push(H):D.fire(H)});O&&O.add(A);let R=()=>{P==null||P.forEach(H=>D.fire(H)),P=null},D=new Qt({onWillAddFirstListener(){A||(A=M(H=>D.fire(H)),O&&O.add(A))},onDidAddFirstListener(){P&&(L?setTimeout(R):R())},onDidRemoveLastListener(){A&&A.dispose(),A=null}});return O&&O.add(D),D.event}t.buffer=N;function x(M,L){return(j,O,P)=>{let A=L(new C);return M(function(R){let D=A.evaluate(R);D!==E&&j.call(O,D)},void 0,P)}}t.chain=x;let E=Symbol("HaltChainable");class C{constructor(){this.steps=[]}map(L){return this.steps.push(L),this}forEach(L){return this.steps.push(j=>(L(j),j)),this}filter(L){return this.steps.push(j=>L(j)?j:E),this}reduce(L,j){let O=j;return this.steps.push(P=>(O=L(O,P),O)),this}latch(L=(j,O)=>j===O){let j=!0,O;return this.steps.push(P=>{let A=j||!L(P,O);return j=!1,O=P,A?P:E}),this}evaluate(L){for(let j of this.steps)if(L=j(L),L===E)break;return L}}function I(M,L,j=O=>O){let O=(...D)=>R.fire(j(...D)),P=()=>M.on(L,O),A=()=>M.removeListener(L,O),R=new Qt({onWillAddFirstListener:P,onDidRemoveLastListener:A});return R.event}t.fromNodeEventEmitter=I;function T(M,L,j=O=>O){let O=(...D)=>R.fire(j(...D)),P=()=>M.addEventListener(L,O),A=()=>M.removeEventListener(L,O),R=new Qt({onWillAddFirstListener:P,onDidRemoveLastListener:A});return R.event}t.fromDOMEventEmitter=T;function W(M){return new Promise(L=>n(M)(L))}t.toPromise=W;function U(M){let L=new Qt;return M.then(j=>{L.fire(j)},()=>{L.fire(void 0)}).finally(()=>{L.dispose()}),L.event}t.fromPromise=U;function Q(M,L){return M(j=>L.fire(j))}t.forward=Q;function ee(M,L,j){return L(j),M(O=>L(O))}t.runAndSubscribe=ee;class q{constructor(L,j){this._observable=L,this._counter=0,this._hasChanged=!1;let O={onWillAddFirstListener:()=>{L.addObserver(this)},onDidRemoveLastListener:()=>{L.removeObserver(this)}};this.emitter=new Qt(O),j&&j.add(this.emitter)}beginUpdate(L){this._counter++}handlePossibleChange(L){}handleChange(L,j){this._hasChanged=!0}endUpdate(L){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function J(M,L){return new q(M,L).emitter.event}t.fromObservable=J;function $(M){return(L,j,O)=>{let P=0,A=!1,R={beginUpdate(){P++},endUpdate(){P--,P===0&&(M.reportChanges(),A&&(A=!1,L.call(j)))},handlePossibleChange(){},handleChange(){A=!0}};M.addObserver(R),M.reportChanges();let D={dispose(){M.removeObserver(R)}};return O instanceof na?O.add(D):Array.isArray(O)&&O.push(D),D}}t.fromObservableLight=$})(Ks||(Ks={}));var Fp=class Hp{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${Hp._idPool++}`,Hp.all.add(this)}start(e){this._stopWatch=new XL,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};Fp.all=new Set,Fp._idPool=0;var QL=Fp,JL=-1,VS=class YS{constructor(e,n,i=(YS._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=n,this.name=i,this._warnCountdown=0}dispose(){var e;(e=this._stacks)==null||e.clear()}check(e,n){let i=this.threshold;if(i<=0||n<i)return;this._stacks||(this._stacks=new Map);let s=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,s+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=i*.5;let[a,l]=this.getMostFrequentStack(),d=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${l}):`;console.warn(d),console.warn(a);let h=new tR(d,a);this._errorHandler(h)}return()=>{let a=this._stacks.get(e.value)||0;this._stacks.set(e.value,a-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,n=0;for(let[i,s]of this._stacks)(!e||n<s)&&(e=[i,s],n=s);return e}};VS._idPool=1;var ZL=VS,eR=class GS{constructor(e){this.value=e}static create(){let e=new Error;return new GS(e.stack??"")}print(){console.warn(this.value.split(`
93
- `).slice(2).join(`
94
- `))}},tR=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},nR=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},iR=0,ef=class{constructor(t){this.value=t,this.id=iR++}},sR=2,rR,Qt=class{constructor(t){var e,n,i,s;this._size=0,this._options=t,this._leakageMon=(e=this._options)!=null&&e.leakWarningThreshold?new ZL((t==null?void 0:t.onListenerError)??Jh,((n=this._options)==null?void 0:n.leakWarningThreshold)??JL):void 0,this._perfMon=(i=this._options)!=null&&i._profName?new QL(this._options._profName):void 0,this._deliveryQueue=(s=this._options)==null?void 0:s.deliveryQueue}dispose(){var t,e,n,i;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(n=(e=this._options)==null?void 0:e.onDidRemoveLastListener)==null||n.call(e),(i=this._leakageMon)==null||i.dispose())}get event(){return this._event??(this._event=(t,e,n)=>{var l,d,h,f,g;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let y=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(y);let _=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],w=new nR(`${y}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((l=this._options)==null?void 0:l.onListenerError)||Jh)(w),rs.None}if(this._disposed)return rs.None;e&&(t=t.bind(e));let i=new ef(t),s;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(i.stack=eR.create(),s=this._leakageMon.check(i.stack,this._size+1)),this._listeners?this._listeners instanceof ef?(this._deliveryQueue??(this._deliveryQueue=new oR),this._listeners=[this._listeners,i]):this._listeners.push(i):((h=(d=this._options)==null?void 0:d.onWillAddFirstListener)==null||h.call(d,this),this._listeners=i,(g=(f=this._options)==null?void 0:f.onDidAddFirstListener)==null||g.call(f,this)),this._size++;let a=ni(()=>{s==null||s(),this._removeListener(i)});return n instanceof na?n.add(a):Array.isArray(n)&&n.push(a),a}),this._event}_removeListener(t){var s,a,l,d;if((a=(s=this._options)==null?void 0:s.onWillRemoveListener)==null||a.call(s,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(d=(l=this._options)==null?void 0:l.onDidRemoveLastListener)==null||d.call(l,this),this._size=0;return}let e=this._listeners,n=e.indexOf(t);if(n===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,e[n]=void 0;let i=this._deliveryQueue.current===this;if(this._size*sR<=e.length){let h=0;for(let f=0;f<e.length;f++)e[f]?e[h++]=e[f]:i&&(this._deliveryQueue.end--,h<this._deliveryQueue.i&&this._deliveryQueue.i--);e.length=h}}_deliver(t,e){var i;if(!t)return;let n=((i=this._options)==null?void 0:i.onListenerError)||Jh;if(!n){t.value(e);return}try{t.value(e)}catch(s){n(s)}}_deliverQueue(t){let e=t.current._listeners;for(;t.i<t.end;)this._deliver(e[t.i++],t.value);t.reset()}fire(t){var e,n,i,s;if((e=this._deliveryQueue)!=null&&e.current&&(this._deliverQueue(this._deliveryQueue),(n=this._perfMon)==null||n.stop()),(i=this._perfMon)==null||i.start(this._size),this._listeners)if(this._listeners instanceof ef)this._deliver(this._listeners,t);else{let a=this._deliveryQueue;a.enqueue(this,t,this._listeners.length),this._deliverQueue(a)}(s=this._perfMon)==null||s.stop()}hasListeners(){return this._size>0}},oR=class{constructor(){this.i=-1,this.end=0}enqueue(t,e,n){this.i=0,this.end=n,this.current=t,this.value=e}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},ow={texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},offset:{x:0,y:0},size:{x:0,y:0},sizeClipSpace:{x:0,y:0}},rl=2,ol,Sr=class Xo{constructor(e,n,i){this._document=e,this._config=n,this._unicodeService=i,this._didWarmUp=!1,this._cacheMap=new rw,this._cacheMapCombined=new rw,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new Jo,this._textureSize=512,this._onAddTextureAtlasCanvas=new Qt,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new Qt,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=XS(e,this._config.deviceCellWidth*4+rl*2,this._config.deviceCellHeight+rl*2),this._tmpCtx=xn(this._tmpCanvas.getContext("2d",{alpha:this._config.allowTransparency,willReadFrequently:!0}))}get pages(){return this._pages}dispose(){this._tmpCanvas.remove();for(let e of this.pages)e.canvas.remove();this._onAddTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)}_doWarmUp(){let e=new YL;for(let n=33;n<126;n++)e.enqueue(()=>{if(!this._cacheMap.get(n,0,0,0)){let i=this._drawToCache(n,0,0,0,!1,void 0);this._cacheMap.set(n,0,0,0,i)}})}beginFrame(){return this._requestClearModel}clearTexture(){if(!(this._pages[0].currentRow.x===0&&this._pages[0].currentRow.y===0)){for(let e of this._pages)e.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(Xo.maxAtlasPages&&this._pages.length>=Math.max(4,Xo.maxAtlasPages)){let n=this._pages.filter(f=>f.canvas.width*2<=(Xo.maxTextureSize||4096)).sort((f,g)=>g.canvas.width!==f.canvas.width?g.canvas.width-f.canvas.width:g.percentageUsed-f.percentageUsed),i=-1,s=0;for(let f=0;f<n.length;f++)if(n[f].canvas.width!==s)i=f,s=n[f].canvas.width;else if(f-i===3)break;let a=n.slice(i,i+4),l=a.map(f=>f.glyphs[0].texturePage).sort((f,g)=>f>g?1:-1),d=this.pages.length-a.length,h=this._mergePages(a,d);h.version++;for(let f=l.length-1;f>=0;f--)this._deletePage(l[f]);this.pages.push(h),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(h.canvas)}let e=new tf(this._document,this._textureSize);return this._pages.push(e),this._activePages.push(e),this._onAddTextureAtlasCanvas.fire(e.canvas),e}_mergePages(e,n){let i=e[0].canvas.width*2,s=new tf(this._document,i,e);for(let[a,l]of e.entries()){let d=a*l.canvas.width%i,h=Math.floor(a/2)*l.canvas.height;s.ctx.drawImage(l.canvas,d,h);for(let g of l.glyphs)g.texturePage=n,g.sizeClipSpace.x=g.size.x/i,g.sizeClipSpace.y=g.size.y/i,g.texturePosition.x+=d,g.texturePosition.y+=h,g.texturePositionClipSpace.x=g.texturePosition.x/i,g.texturePositionClipSpace.y=g.texturePosition.y/i;this._onRemoveTextureAtlasCanvas.fire(l.canvas);let f=this._activePages.indexOf(l);f!==-1&&this._activePages.splice(f,1)}return s}_deletePage(e){this._pages.splice(e,1);for(let n=e;n<this._pages.length;n++){let i=this._pages[n];for(let s of i.glyphs)s.texturePage--;i.version++}}getRasterizedGlyphCombinedChar(e,n,i,s,a,l){return this._getFromCacheMap(this._cacheMapCombined,e,n,i,s,a,l)}getRasterizedGlyph(e,n,i,s,a,l){return this._getFromCacheMap(this._cacheMap,e,n,i,s,a,l)}_getFromCacheMap(e,n,i,s,a,l,d){return ol=e.get(n,i,s,a),ol||(ol=this._drawToCache(n,i,s,a,l,d),e.set(n,i,s,a,ol)),ol}_getColorFromAnsiIndex(e){if(e>=this._config.colors.ansi.length)throw new Error("No color found for idx "+e);return this._config.colors.ansi[e]}_getBackgroundColor(e,n,i,s){if(this._config.allowTransparency)return Wi;let a;switch(e){case 16777216:case 33554432:a=this._getColorFromAnsiIndex(n);break;case 50331648:let l=Jo.toColorRGB(n);a=ai.toColor(l[0],l[1],l[2]);break;case 0:default:i?a=yl.opaque(this._config.colors.foreground):a=this._config.colors.background;break}return this._config.allowTransparency||(a=yl.opaque(a)),a}_getForegroundColor(e,n,i,s,a,l,d,h,f,g){let y=this._getMinimumContrastColor(e,n,i,s,a,l,d,f,h,g);if(y)return y;let _;switch(a){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&f&&l<8&&(l+=8),_=this._getColorFromAnsiIndex(l);break;case 50331648:let w=Jo.toColorRGB(l);_=ai.toColor(w[0],w[1],w[2]);break;case 0:default:d?_=this._config.colors.background:_=this._config.colors.foreground}return this._config.allowTransparency&&(_=yl.opaque(_)),h&&(_=yl.multiplyOpacity(_,BL)),_}_resolveBackgroundRgba(e,n,i){switch(e){case 16777216:case 33554432:return this._getColorFromAnsiIndex(n).rgba;case 50331648:return n<<8;case 0:default:return i?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(e,n,i,s){switch(e){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&s&&n<8&&(n+=8),this._getColorFromAnsiIndex(n).rgba;case 50331648:return n<<8;case 0:default:return i?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(e,n,i,s,a,l,d,h,f,g){if(this._config.minimumContrastRatio===1||g)return;let y=this._getContrastCache(f),_=y.getColor(e,s);if(_!==void 0)return _||void 0;let w=this._resolveBackgroundRgba(n,i,d),b=this._resolveForegroundRgba(a,l,d,h),N=oo.ensureContrastRatio(w,b,this._config.minimumContrastRatio/(f?2:1));if(!N){y.setColor(e,s,null);return}let x=ai.toColor(N>>24&255,N>>16&255,N>>8&255);return y.setColor(e,s,x),x}_getContrastCache(e){return e?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(e,n,i,s,a,l){let d=typeof e=="number"?String.fromCharCode(e):e;l&&this._tmpCanvas.parentElement!==l&&(this._tmpCanvas.style.display="none",l.append(this._tmpCanvas));let h=Math.min(this._config.deviceCellWidth*Math.max(d.length,2)+rl*2,this._config.deviceMaxTextureSize);this._tmpCanvas.width<h&&(this._tmpCanvas.width=h);let f=Math.min(this._config.deviceCellHeight+rl*4,this._textureSize);if(this._tmpCanvas.height<f&&(this._tmpCanvas.height=f),this._tmpCtx.save(),this._workAttributeData.fg=i,this._workAttributeData.bg=n,this._workAttributeData.extended.ext=s,!!this._workAttributeData.isInvisible())return ow;let g=!!this._workAttributeData.isBold(),y=!!this._workAttributeData.isInverse(),_=!!this._workAttributeData.isDim(),w=!!this._workAttributeData.isItalic(),b=!!this._workAttributeData.isUnderline(),N=!!this._workAttributeData.isStrikethrough(),x=!!this._workAttributeData.isOverline(),E=this._workAttributeData.getFgColor(),C=this._workAttributeData.getFgColorMode(),I=this._workAttributeData.getBgColor(),T=this._workAttributeData.getBgColorMode();if(y){let H=E;E=I,I=H;let z=C;C=T,T=z}let W=this._getBackgroundColor(T,I,y,_);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=W.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over";let U=g?this._config.fontWeightBold:this._config.fontWeight,Q=w?"italic":"";this._tmpCtx.font=`${Q} ${U} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=$S;let ee=d.length===1&&Bm(d.charCodeAt(0)),q=d.length===1&&RL(d.charCodeAt(0)),J=this._getForegroundColor(n,T,I,i,C,E,y,_,g,OS(d.charCodeAt(0)));this._tmpCtx.fillStyle=J.css;let $=q?0:rl*2,M=!1;this._config.customGlyphs!==!1&&(M=FL(this._tmpCtx,d,$,$,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.fontSize,this._config.devicePixelRatio));let L=!ee,j;if(typeof e=="number"?j=this._unicodeService.wcwidth(e):j=this._unicodeService.getStringCellWidth(e),b){this._tmpCtx.save();let H=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),z=H%2===1?.5:0;if(this._tmpCtx.lineWidth=H,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())L=!1,this._tmpCtx.strokeStyle=`rgb(${Jo.toColorRGB(this._workAttributeData.getUnderlineColor()).join(",")})`;else{L=!1;let de=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&de<8&&(de+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(de).css}this._tmpCtx.beginPath();let F=$,K=Math.ceil($+this._config.deviceCharHeight)-z-(a?H*2:0),ne=K+H,re=K+H*2,Y=this._workAttributeData.getUnderlineVariantOffset();for(let de=0;de<j;de++){this._tmpCtx.save();let oe=F+de*this._config.deviceCellWidth,pe=F+(de+1)*this._config.deviceCellWidth,xe=oe+this._config.deviceCellWidth/2;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(oe,K),this._tmpCtx.lineTo(pe,K),this._tmpCtx.moveTo(oe,re),this._tmpCtx.lineTo(pe,re);break;case 3:let Qe=H<=1?re:Math.ceil($+this._config.deviceCharHeight-H/2)-z,ot=H<=1?K:Math.ceil($+this._config.deviceCharHeight+H/2)-z,De=new Path2D;De.rect(oe,K,this._config.deviceCellWidth,re-K),this._tmpCtx.clip(De),this._tmpCtx.moveTo(oe-this._config.deviceCellWidth/2,ne),this._tmpCtx.bezierCurveTo(oe-this._config.deviceCellWidth/2,ot,oe,ot,oe,ne),this._tmpCtx.bezierCurveTo(oe,Qe,xe,Qe,xe,ne),this._tmpCtx.bezierCurveTo(xe,ot,pe,ot,pe,ne),this._tmpCtx.bezierCurveTo(pe,Qe,pe+this._config.deviceCellWidth/2,Qe,pe+this._config.deviceCellWidth/2,ne);break;case 4:let je=Y===0?0:Y>=H?H*2-Y:H-Y;Y>=H||je===0?(this._tmpCtx.setLineDash([Math.round(H),Math.round(H)]),this._tmpCtx.moveTo(oe+je,K),this._tmpCtx.lineTo(pe,K)):(this._tmpCtx.setLineDash([Math.round(H),Math.round(H)]),this._tmpCtx.moveTo(oe,K),this._tmpCtx.lineTo(oe+je,K),this._tmpCtx.moveTo(oe+je+H,K),this._tmpCtx.lineTo(pe,K)),Y=DL(pe-oe,H,Y);break;case 5:let tt=.6,Nt=.3,Ct=pe-oe,ft=Math.floor(tt*Ct),ht=Math.floor(Nt*Ct),kt=Ct-ft-ht;this._tmpCtx.setLineDash([ft,ht,kt]),this._tmpCtx.moveTo(oe,K),this._tmpCtx.lineTo(pe,K);break;case 1:default:this._tmpCtx.moveTo(oe,K),this._tmpCtx.lineTo(pe,K);break}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!M&&this._config.fontSize>=12&&!this._config.allowTransparency&&d!==" "){this._tmpCtx.save(),this._tmpCtx.textBaseline="alphabetic";let de=this._tmpCtx.measureText(d);if(this._tmpCtx.restore(),"actualBoundingBoxDescent"in de&&de.actualBoundingBoxDescent>0){this._tmpCtx.save();let oe=new Path2D;oe.rect(F,K-Math.ceil(H/2),this._config.deviceCellWidth*j,re-K+Math.ceil(H/2)),this._tmpCtx.clip(oe),this._tmpCtx.lineWidth=this._config.devicePixelRatio*3,this._tmpCtx.strokeStyle=W.css,this._tmpCtx.strokeText(d,$,$+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(x){let H=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),z=H%2===1?.5:0;this._tmpCtx.lineWidth=H,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo($,$+z),this._tmpCtx.lineTo($+this._config.deviceCharWidth*j,$+z),this._tmpCtx.stroke()}if(M||this._tmpCtx.fillText(d,$,$+this._config.deviceCharHeight),d==="_"&&!this._config.allowTransparency){let H=nf(this._tmpCtx.getImageData($,$,this._config.deviceCellWidth,this._config.deviceCellHeight),W,J,L);if(H)for(let z=1;z<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=W.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(d,$,$+this._config.deviceCharHeight-z),H=nf(this._tmpCtx.getImageData($,$,this._config.deviceCellWidth,this._config.deviceCellHeight),W,J,L),!!H);z++);}if(N){let H=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),z=this._tmpCtx.lineWidth%2===1?.5:0;this._tmpCtx.lineWidth=H,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo($,$+Math.floor(this._config.deviceCharHeight/2)-z),this._tmpCtx.lineTo($+this._config.deviceCharWidth*j,$+Math.floor(this._config.deviceCharHeight/2)-z),this._tmpCtx.stroke()}this._tmpCtx.restore();let O=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),P;if(this._config.allowTransparency?P=aR(O):P=nf(O,W,J,L),P)return ow;let A=this._findGlyphBoundingBox(O,this._workBoundingBox,h,q,M,$),R,D;for(;;){if(this._activePages.length===0){let H=this._createNewPage();R=H,D=H.currentRow,D.height=A.size.y;break}R=this._activePages[this._activePages.length-1],D=R.currentRow;for(let H of this._activePages)A.size.y<=H.currentRow.height&&(R=H,D=H.currentRow);for(let H=this._activePages.length-1;H>=0;H--)for(let z of this._activePages[H].fixedRows)z.height<=D.height&&A.size.y<=z.height&&(R=this._activePages[H],D=z);if(A.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new tf(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),R=this._overflowSizePage,D=this._overflowSizePage.currentRow,D.x+A.size.x>=R.canvas.width&&(D.x=0,D.y+=D.height,D.height=0);break}if(D.y+A.size.y>=R.canvas.height||D.height>A.size.y+2){let H=!1;if(R.currentRow.y+R.currentRow.height+A.size.y>=R.canvas.height){let z;for(let F of this._activePages)if(F.currentRow.y+F.currentRow.height+A.size.y<F.canvas.height){z=F;break}if(z)R=z;else if(Xo.maxAtlasPages&&this._pages.length>=Xo.maxAtlasPages&&D.y+A.size.y<=R.canvas.height&&D.height>=A.size.y&&D.x+A.size.x<=R.canvas.width)H=!0;else{let F=this._createNewPage();R=F,D=F.currentRow,D.height=A.size.y,H=!0}}H||(R.currentRow.height>0&&R.fixedRows.push(R.currentRow),D={x:0,y:R.currentRow.y+R.currentRow.height,height:A.size.y},R.fixedRows.push(D),R.currentRow={x:0,y:D.y+D.height,height:0})}if(D.x+A.size.x<=R.canvas.width)break;D===R.currentRow?(D.x=0,D.y+=D.height,D.height=0):R.fixedRows.splice(R.fixedRows.indexOf(D),1)}return A.texturePage=this._pages.indexOf(R),A.texturePosition.x=D.x,A.texturePosition.y=D.y,A.texturePositionClipSpace.x=D.x/R.canvas.width,A.texturePositionClipSpace.y=D.y/R.canvas.height,A.sizeClipSpace.x/=R.canvas.width,A.sizeClipSpace.y/=R.canvas.height,D.height=Math.max(D.height,A.size.y),D.x+=A.size.x,R.ctx.putImageData(O,A.texturePosition.x-this._workBoundingBox.left,A.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,A.size.x,A.size.y),R.addGlyph(A),R.version++,A}_findGlyphBoundingBox(e,n,i,s,a,l){n.top=0;let d=s?this._config.deviceCellHeight:this._tmpCanvas.height,h=s?this._config.deviceCellWidth:i,f=!1;for(let g=0;g<d;g++){for(let y=0;y<h;y++){let _=g*this._tmpCanvas.width*4+y*4+3;if(e.data[_]!==0){n.top=g,f=!0;break}}if(f)break}n.left=0,f=!1;for(let g=0;g<l+h;g++){for(let y=0;y<d;y++){let _=y*this._tmpCanvas.width*4+g*4+3;if(e.data[_]!==0){n.left=g,f=!0;break}}if(f)break}n.right=h,f=!1;for(let g=l+h-1;g>=l;g--){for(let y=0;y<d;y++){let _=y*this._tmpCanvas.width*4+g*4+3;if(e.data[_]!==0){n.right=g,f=!0;break}}if(f)break}n.bottom=d,f=!1;for(let g=d-1;g>=0;g--){for(let y=0;y<h;y++){let _=g*this._tmpCanvas.width*4+y*4+3;if(e.data[_]!==0){n.bottom=g,f=!0;break}}if(f)break}return{texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:n.right-n.left+1,y:n.bottom-n.top+1},sizeClipSpace:{x:n.right-n.left+1,y:n.bottom-n.top+1},offset:{x:-n.left+l+(s||a?Math.floor((this._config.deviceCellWidth-this._config.deviceCharWidth)/2):0),y:-n.top+l+(s||a?this._config.lineHeight===1?0:Math.round((this._config.deviceCellHeight-this._config.deviceCharHeight)/2):0)}}}},tf=class{constructor(t,e,n){if(this._usedPixels=0,this._glyphs=[],this.version=0,this.currentRow={x:0,y:0,height:0},this.fixedRows=[],n)for(let i of n)this._glyphs.push(...i.glyphs),this._usedPixels+=i._usedPixels;this.canvas=XS(t,e,e),this.ctx=xn(this.canvas.getContext("2d",{alpha:!0}))}get percentageUsed(){return this._usedPixels/(this.canvas.width*this.canvas.height)}get glyphs(){return this._glyphs}addGlyph(t){this._glyphs.push(t),this._usedPixels+=t.size.x*t.size.y}clear(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.currentRow.x=0,this.currentRow.y=0,this.currentRow.height=0,this.fixedRows.length=0,this.version++}};function nf(t,e,n,i){let s=e.rgba>>>24,a=e.rgba>>>16&255,l=e.rgba>>>8&255,d=n.rgba>>>24,h=n.rgba>>>16&255,f=n.rgba>>>8&255,g=Math.floor((Math.abs(s-d)+Math.abs(a-h)+Math.abs(l-f))/12),y=!0;for(let _=0;_<t.data.length;_+=4)t.data[_]===s&&t.data[_+1]===a&&t.data[_+2]===l||i&&Math.abs(t.data[_]-s)+Math.abs(t.data[_+1]-a)+Math.abs(t.data[_+2]-l)<g?t.data[_+3]=0:y=!1;return y}function aR(t){for(let e=0;e<t.data.length;e+=4)if(t.data[e+3]>0)return!1;return!0}function XS(t,e,n){let i=t.createElement("canvas");return i.width=e,i.height=n,i}function lR(t,e,n,i,s,a,l,d){let h={foreground:a.foreground,background:a.background,cursor:Wi,cursorAccent:Wi,selectionForeground:Wi,selectionBackgroundTransparent:Wi,selectionBackgroundOpaque:Wi,selectionInactiveBackgroundTransparent:Wi,selectionInactiveBackgroundOpaque:Wi,overviewRulerBorder:Wi,scrollbarSliderBackground:Wi,scrollbarSliderHoverBackground:Wi,scrollbarSliderActiveBackground:Wi,ansi:a.ansi.slice(),contrastCache:a.contrastCache,halfContrastCache:a.halfContrastCache};return{customGlyphs:s.customGlyphs,devicePixelRatio:l,deviceMaxTextureSize:d,letterSpacing:s.letterSpacing,lineHeight:s.lineHeight,deviceCellWidth:t,deviceCellHeight:e,deviceCharWidth:n,deviceCharHeight:i,fontFamily:s.fontFamily,fontSize:s.fontSize,fontWeight:s.fontWeight,fontWeightBold:s.fontWeightBold,allowTransparency:s.allowTransparency,drawBoldTextInBrightColors:s.drawBoldTextInBrightColors,minimumContrastRatio:s.minimumContrastRatio,colors:h}}function aw(t,e){for(let n=0;n<t.colors.ansi.length;n++)if(t.colors.ansi[n].rgba!==e.colors.ansi[n].rgba)return!1;return t.devicePixelRatio===e.devicePixelRatio&&t.customGlyphs===e.customGlyphs&&t.lineHeight===e.lineHeight&&t.letterSpacing===e.letterSpacing&&t.fontFamily===e.fontFamily&&t.fontSize===e.fontSize&&t.fontWeight===e.fontWeight&&t.fontWeightBold===e.fontWeightBold&&t.allowTransparency===e.allowTransparency&&t.deviceCharWidth===e.deviceCharWidth&&t.deviceCharHeight===e.deviceCharHeight&&t.drawBoldTextInBrightColors===e.drawBoldTextInBrightColors&&t.minimumContrastRatio===e.minimumContrastRatio&&t.colors.foreground.rgba===e.colors.foreground.rgba&&t.colors.background.rgba===e.colors.background.rgba}function cR(t){return(t&50331648)===16777216||(t&50331648)===33554432}var Vi=[];function QS(t,e,n,i,s,a,l,d,h){let f=lR(i,s,a,l,e,n,d,h);for(let _=0;_<Vi.length;_++){let w=Vi[_],b=w.ownedBy.indexOf(t);if(b>=0){if(aw(w.config,f))return w.atlas;w.ownedBy.length===1?(w.atlas.dispose(),Vi.splice(_,1)):w.ownedBy.splice(b,1);break}}for(let _=0;_<Vi.length;_++){let w=Vi[_];if(aw(w.config,f))return w.ownedBy.push(t),w.atlas}let g=t._core,y={atlas:new Sr(document,f,g.unicodeService),config:f,ownedBy:[t]};return Vi.push(y),y.atlas}function lw(t){for(let e=0;e<Vi.length;e++){let n=Vi[e].ownedBy.indexOf(t);if(n!==-1){Vi[e].ownedBy.length===1?(Vi[e].atlas.dispose(),Vi.splice(e,1)):Vi[e].ownedBy.splice(n,1);break}}}var eu=600,uR=class{constructor(t,e){this._renderCallback=t,this._coreBrowserService=e,this.isCursorVisible=!0,this._coreBrowserService.isFocused&&this._restartInterval()}get isPaused(){return!(this._blinkStartTimeout||this._blinkInterval)}dispose(){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}restartBlinkAnimation(){this.isPaused||(this._animationTimeRestarted=Date.now(),this.isCursorVisible=!0,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})))}_restartInterval(t=eu){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let e=eu-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,e>0){this._restartInterval(e);return}}this.isCursorVisible=!1,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0}),this._blinkInterval=this._coreBrowserService.window.setInterval(()=>{if(this._animationTimeRestarted){let e=eu-(Date.now()-this._animationTimeRestarted);this._animationTimeRestarted=void 0,this._restartInterval(e);return}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},eu)},t)}pause(){this.isCursorVisible=!0,this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}resume(){this.pause(),this._animationTimeRestarted=void 0,this._restartInterval(),this.restartBlinkAnimation()}};function cw(t,e,n){let i=new e.ResizeObserver(s=>{let a=s.find(h=>h.target===t);if(!a)return;if(!("devicePixelContentBoxSize"in a)){i==null||i.disconnect(),i=void 0;return}let l=a.devicePixelContentBoxSize[0].inlineSize,d=a.devicePixelContentBoxSize[0].blockSize;l>0&&d>0&&n(l,d)});try{i.observe(t,{box:["device-pixel-content-box"]})}catch{i.disconnect(),i=void 0}return ni(()=>i==null?void 0:i.disconnect())}function dR(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}var uw=class JS extends Jo{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new WS,this.combinedData=""}static fromCharData(e){let n=new JS;return n.setFromCharData(e),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?dR(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let n=!1;if(e[1].length>2)n=!0;else if(e[1].length===2){let i=e[1].charCodeAt(0);if(55296<=i&&i<=56319){let s=e[1].charCodeAt(1);56320<=s&&s<=57343?this.content=(i-55296)*1024+s-56320+65536|e[2]<<22:n=!0}else n=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;n&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ZS=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function e1(t,e,n){let i=xn(t.createProgram());if(t.attachShader(i,xn(dw(t,t.VERTEX_SHADER,e))),t.attachShader(i,xn(dw(t,t.FRAGMENT_SHADER,n))),t.linkProgram(i),t.getProgramParameter(i,t.LINK_STATUS))return i;console.error(t.getProgramInfoLog(i)),t.deleteProgram(i)}function dw(t,e,n){let i=xn(t.createShader(e));if(t.shaderSource(i,n),t.compileShader(i),t.getShaderParameter(i,t.COMPILE_STATUS))return i;console.error(t.getShaderInfoLog(i)),t.deleteShader(i)}function hR(t,e){let n=Math.min(t.length*2,e),i=new Float32Array(n);for(let s=0;s<t.length;s++)i[s]=t[s];return i}var fR=class{constructor(t){this.texture=t,this.version=-1}},pR=`#version 300 es
95
- layout (location = 0) in vec2 a_unitquad;
96
- layout (location = 1) in vec2 a_cellpos;
97
- layout (location = 2) in vec2 a_offset;
98
- layout (location = 3) in vec2 a_size;
99
- layout (location = 4) in float a_texpage;
100
- layout (location = 5) in vec2 a_texcoord;
101
- layout (location = 6) in vec2 a_texsize;
102
-
103
- uniform mat4 u_projection;
104
- uniform vec2 u_resolution;
105
-
106
- out vec2 v_texcoord;
107
- flat out int v_texpage;
108
-
109
- void main() {
110
- vec2 zeroToOne = (a_offset / u_resolution) + a_cellpos + (a_unitquad * a_size);
111
- gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);
112
- v_texpage = int(a_texpage);
113
- v_texcoord = a_texcoord + a_unitquad * a_texsize;
114
- }`;function mR(t){let e="";for(let n=1;n<t;n++)e+=` else if (v_texpage == ${n}) { outColor = texture(u_texture[${n}], v_texcoord); }`;return`#version 300 es
115
- precision lowp float;
116
-
117
- in vec2 v_texcoord;
118
- flat in int v_texpage;
119
-
120
- uniform sampler2D u_texture[${t}];
121
-
122
- out vec4 outColor;
123
-
124
- void main() {
125
- if (v_texpage == 0) {
126
- outColor = texture(u_texture[0], v_texcoord);
127
- } ${e}
128
- }`}var xr=11,Wo=xr*Float32Array.BYTES_PER_ELEMENT,gR=2,dn=0,Gt,sf=0,al=0,vR=class extends rs{constructor(t,e,n,i){super(),this._terminal=t,this._gl=e,this._dimensions=n,this._optionsService=i,this._activeBuffer=0,this._vertices={count:0,attributes:new Float32Array(0),attributesBuffers:[new Float32Array(0),new Float32Array(0)]};let s=this._gl;Sr.maxAtlasPages===void 0&&(Sr.maxAtlasPages=Math.min(32,xn(s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS))),Sr.maxTextureSize=xn(s.getParameter(s.MAX_TEXTURE_SIZE))),this._program=xn(e1(s,pR,mR(Sr.maxAtlasPages))),this._register(ni(()=>s.deleteProgram(this._program))),this._projectionLocation=xn(s.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=xn(s.getUniformLocation(this._program,"u_resolution")),this._textureLocation=xn(s.getUniformLocation(this._program,"u_texture")),this._vertexArrayObject=s.createVertexArray(),s.bindVertexArray(this._vertexArrayObject);let a=new Float32Array([0,0,1,0,0,1,1,1]),l=s.createBuffer();this._register(ni(()=>s.deleteBuffer(l))),s.bindBuffer(s.ARRAY_BUFFER,l),s.bufferData(s.ARRAY_BUFFER,a,s.STATIC_DRAW),s.enableVertexAttribArray(0),s.vertexAttribPointer(0,2,this._gl.FLOAT,!1,0,0);let d=new Uint8Array([0,1,2,3]),h=s.createBuffer();this._register(ni(()=>s.deleteBuffer(h))),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,h),s.bufferData(s.ELEMENT_ARRAY_BUFFER,d,s.STATIC_DRAW),this._attributesBuffer=xn(s.createBuffer()),this._register(ni(()=>s.deleteBuffer(this._attributesBuffer))),s.bindBuffer(s.ARRAY_BUFFER,this._attributesBuffer),s.enableVertexAttribArray(2),s.vertexAttribPointer(2,2,s.FLOAT,!1,Wo,0),s.vertexAttribDivisor(2,1),s.enableVertexAttribArray(3),s.vertexAttribPointer(3,2,s.FLOAT,!1,Wo,2*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(3,1),s.enableVertexAttribArray(4),s.vertexAttribPointer(4,1,s.FLOAT,!1,Wo,4*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(4,1),s.enableVertexAttribArray(5),s.vertexAttribPointer(5,2,s.FLOAT,!1,Wo,5*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(5,1),s.enableVertexAttribArray(6),s.vertexAttribPointer(6,2,s.FLOAT,!1,Wo,7*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(6,1),s.enableVertexAttribArray(1),s.vertexAttribPointer(1,2,s.FLOAT,!1,Wo,9*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(1,1),s.useProgram(this._program);let f=new Int32Array(Sr.maxAtlasPages);for(let g=0;g<Sr.maxAtlasPages;g++)f[g]=g;s.uniform1iv(this._textureLocation,f),s.uniformMatrix4fv(this._projectionLocation,!1,ZS),this._atlasTextures=[];for(let g=0;g<Sr.maxAtlasPages;g++){let y=new fR(xn(s.createTexture()));this._register(ni(()=>s.deleteTexture(y.texture))),s.activeTexture(s.TEXTURE0+g),s.bindTexture(s.TEXTURE_2D,y.texture),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,new Uint8Array([255,0,0,255])),this._atlasTextures[g]=y}s.enable(s.BLEND),s.blendFunc(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA),this.handleResize()}beginFrame(){return this._atlas?this._atlas.beginFrame():!0}updateCell(t,e,n,i,s,a,l,d,h){this._updateCell(this._vertices.attributes,t,e,n,i,s,a,l,d,h)}_updateCell(t,e,n,i,s,a,l,d,h,f){if(dn=(n*this._terminal.cols+e)*xr,i===0||i===void 0){t.fill(0,dn,dn+xr-1-gR);return}this._atlas&&(d&&d.length>1?Gt=this._atlas.getRasterizedGlyphCombinedChar(d,s,a,l,!1,this._terminal.element):Gt=this._atlas.getRasterizedGlyph(i,s,a,l,!1,this._terminal.element),sf=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),s!==f&&Gt.offset.x>sf?(al=Gt.offset.x-sf,t[dn]=-(Gt.offset.x-al)+this._dimensions.device.char.left,t[dn+1]=-Gt.offset.y+this._dimensions.device.char.top,t[dn+2]=(Gt.size.x-al)/this._dimensions.device.canvas.width,t[dn+3]=Gt.size.y/this._dimensions.device.canvas.height,t[dn+4]=Gt.texturePage,t[dn+5]=Gt.texturePositionClipSpace.x+al/this._atlas.pages[Gt.texturePage].canvas.width,t[dn+6]=Gt.texturePositionClipSpace.y,t[dn+7]=Gt.sizeClipSpace.x-al/this._atlas.pages[Gt.texturePage].canvas.width,t[dn+8]=Gt.sizeClipSpace.y):(t[dn]=-Gt.offset.x+this._dimensions.device.char.left,t[dn+1]=-Gt.offset.y+this._dimensions.device.char.top,t[dn+2]=Gt.size.x/this._dimensions.device.canvas.width,t[dn+3]=Gt.size.y/this._dimensions.device.canvas.height,t[dn+4]=Gt.texturePage,t[dn+5]=Gt.texturePositionClipSpace.x,t[dn+6]=Gt.texturePositionClipSpace.y,t[dn+7]=Gt.sizeClipSpace.x,t[dn+8]=Gt.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&PL(i,h,Gt.size.x,this._dimensions.device.cell.width)&&(t[dn+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width))}clear(){let t=this._terminal,e=t.cols*t.rows*xr;this._vertices.count!==e?this._vertices.attributes=new Float32Array(e):this._vertices.attributes.fill(0);let n=0;for(;n<this._vertices.attributesBuffers.length;n++)this._vertices.count!==e?this._vertices.attributesBuffers[n]=new Float32Array(e):this._vertices.attributesBuffers[n].fill(0);this._vertices.count=e,n=0;for(let i=0;i<t.rows;i++)for(let s=0;s<t.cols;s++)this._vertices.attributes[n+9]=s/t.cols,this._vertices.attributes[n+10]=i/t.rows,n+=xr}handleResize(){let t=this._gl;t.useProgram(this._program),t.viewport(0,0,t.canvas.width,t.canvas.height),t.uniform2f(this._resolutionLocation,t.canvas.width,t.canvas.height),this.clear()}render(t){if(!this._atlas)return;let e=this._gl;e.useProgram(this._program),e.bindVertexArray(this._vertexArrayObject),this._activeBuffer=(this._activeBuffer+1)%2;let n=this._vertices.attributesBuffers[this._activeBuffer],i=0;for(let s=0;s<t.lineLengths.length;s++){let a=s*this._terminal.cols*xr,l=this._vertices.attributes.subarray(a,a+t.lineLengths[s]*xr);n.set(l,i),i+=l.length}e.bindBuffer(e.ARRAY_BUFFER,this._attributesBuffer),e.bufferData(e.ARRAY_BUFFER,n.subarray(0,i),e.STREAM_DRAW);for(let s=0;s<this._atlas.pages.length;s++)this._atlas.pages[s].version!==this._atlasTextures[s].version&&this._bindAtlasPageTexture(e,this._atlas,s);e.drawElementsInstanced(e.TRIANGLE_STRIP,4,e.UNSIGNED_BYTE,0,i/xr)}setAtlas(t){this._atlas=t;for(let e of this._atlasTextures)e.version=-1}_bindAtlasPageTexture(t,e,n){t.activeTexture(t.TEXTURE0+n),t.bindTexture(t.TEXTURE_2D,this._atlasTextures[n].texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e.pages[n].canvas),t.generateMipmap(t.TEXTURE_2D),this._atlasTextures[n].version=e.pages[n].version}setDimensions(t){this._dimensions=t}},_R=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(t,e,n,i=!1){if(this.selectionStart=e,this.selectionEnd=n,!e||!n||e[0]===n[0]&&e[1]===n[1]){this.clear();return}let s=t.buffers.active.ydisp,a=e[1]-s,l=n[1]-s,d=Math.max(a,0),h=Math.min(l,t.rows-1);if(d>=t.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=a,this.viewportEndRow=l,this.viewportCappedStartRow=d,this.viewportCappedEndRow=h,this.startCol=e[0],this.endCol=n[0]}isCellSelected(t,e,n){return this.hasSelection?(n-=t.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?e>=this.startCol&&n>=this.viewportCappedStartRow&&e<this.endCol&&n<=this.viewportCappedEndRow:e<this.startCol&&n>=this.viewportCappedStartRow&&e>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&e>=this.startCol&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&e>=this.startCol):!1}};function yR(){return new _R}var Iu=4,gu=1,vu=2,rf=3,wR=2147483648,bR=class{constructor(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection=yR()}resize(t,e){let n=t*e*Iu;n!==this.cells.length&&(this.cells=new Uint32Array(n),this.lineLengths=new Uint32Array(e))}clear(){this.cells.fill(0,0),this.lineLengths.fill(0,0)}},SR=`#version 300 es
129
- layout (location = 0) in vec2 a_position;
130
- layout (location = 1) in vec2 a_size;
131
- layout (location = 2) in vec4 a_color;
132
- layout (location = 3) in vec2 a_unitquad;
133
-
134
- uniform mat4 u_projection;
135
-
136
- out vec4 v_color;
137
-
138
- void main() {
139
- vec2 zeroToOne = a_position + (a_unitquad * a_size);
140
- gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);
141
- v_color = a_color;
142
- }`,xR=`#version 300 es
143
- precision lowp float;
144
-
145
- in vec4 v_color;
146
-
147
- out vec4 outColor;
148
-
149
- void main() {
150
- outColor = v_color;
151
- }`,Hs=8,of=Hs*Float32Array.BYTES_PER_ELEMENT,CR=20*Hs,hw=class{constructor(){this.attributes=new Float32Array(CR),this.count=0}},Fs=0,fw=0,pw=0,mw=0,gw=0,vw=0,_w=0,kR=class extends rs{constructor(t,e,n,i){super(),this._terminal=t,this._gl=e,this._dimensions=n,this._themeService=i,this._vertices=new hw,this._verticesCursor=new hw;let s=this._gl;this._program=xn(e1(s,SR,xR)),this._register(ni(()=>s.deleteProgram(this._program))),this._projectionLocation=xn(s.getUniformLocation(this._program,"u_projection")),this._vertexArrayObject=s.createVertexArray(),s.bindVertexArray(this._vertexArrayObject);let a=new Float32Array([0,0,1,0,0,1,1,1]),l=s.createBuffer();this._register(ni(()=>s.deleteBuffer(l))),s.bindBuffer(s.ARRAY_BUFFER,l),s.bufferData(s.ARRAY_BUFFER,a,s.STATIC_DRAW),s.enableVertexAttribArray(3),s.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let d=new Uint8Array([0,1,2,3]),h=s.createBuffer();this._register(ni(()=>s.deleteBuffer(h))),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,h),s.bufferData(s.ELEMENT_ARRAY_BUFFER,d,s.STATIC_DRAW),this._attributesBuffer=xn(s.createBuffer()),this._register(ni(()=>s.deleteBuffer(this._attributesBuffer))),s.bindBuffer(s.ARRAY_BUFFER,this._attributesBuffer),s.enableVertexAttribArray(0),s.vertexAttribPointer(0,2,s.FLOAT,!1,of,0),s.vertexAttribDivisor(0,1),s.enableVertexAttribArray(1),s.vertexAttribPointer(1,2,s.FLOAT,!1,of,2*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(1,1),s.enableVertexAttribArray(2),s.vertexAttribPointer(2,4,s.FLOAT,!1,of,4*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(2,1),this._updateCachedColors(i.colors),this._register(this._themeService.onChangeColors(f=>{this._updateCachedColors(f),this._updateViewportRectangle()}))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(t){let e=this._gl;e.useProgram(this._program),e.bindVertexArray(this._vertexArrayObject),e.uniformMatrix4fv(this._projectionLocation,!1,ZS),e.bindBuffer(e.ARRAY_BUFFER,this._attributesBuffer),e.bufferData(e.ARRAY_BUFFER,t.attributes,e.DYNAMIC_DRAW),e.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,e.UNSIGNED_BYTE,0,t.count)}handleResize(){this._updateViewportRectangle()}setDimensions(t){this._dimensions=t}_updateCachedColors(t){this._bgFloat=this._colorToFloat32Array(t.background),this._cursorFloat=this._colorToFloat32Array(t.cursor)}_updateViewportRectangle(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.device.cell.width,this._terminal.rows*this._dimensions.device.cell.height,this._bgFloat)}updateBackgrounds(t){let e=this._terminal,n=this._vertices,i=1,s,a,l,d,h,f,g,y,_,w,b;for(s=0;s<e.rows;s++){for(l=-1,d=0,h=0,f=!1,a=0;a<e.cols;a++)g=(s*e.cols+a)*Iu,y=t.cells[g+gu],_=t.cells[g+vu],w=!!(_&67108864),(y!==d||_!==h&&(f||w))&&((d!==0||f&&h!==0)&&(b=i++*Hs,this._updateRectangle(n,b,h,d,l,a,s)),l=a,d=y,h=_,f=w);(d!==0||f&&h!==0)&&(b=i++*Hs,this._updateRectangle(n,b,h,d,l,e.cols,s))}n.count=i}updateCursor(t){let e=this._verticesCursor,n=t.cursor;if(!n||n.style==="block"){e.count=0;return}let i,s=0;(n.style==="bar"||n.style==="outline")&&(i=s++*Hs,this._addRectangleFloat(e.attributes,i,n.x*this._dimensions.device.cell.width,n.y*this._dimensions.device.cell.height,n.style==="bar"?n.dpr*n.cursorWidth:n.dpr,this._dimensions.device.cell.height,this._cursorFloat)),(n.style==="underline"||n.style==="outline")&&(i=s++*Hs,this._addRectangleFloat(e.attributes,i,n.x*this._dimensions.device.cell.width,(n.y+1)*this._dimensions.device.cell.height-n.dpr,n.width*this._dimensions.device.cell.width,n.dpr,this._cursorFloat)),n.style==="outline"&&(i=s++*Hs,this._addRectangleFloat(e.attributes,i,n.x*this._dimensions.device.cell.width,n.y*this._dimensions.device.cell.height,n.width*this._dimensions.device.cell.width,n.dpr,this._cursorFloat),i=s++*Hs,this._addRectangleFloat(e.attributes,i,(n.x+n.width)*this._dimensions.device.cell.width-n.dpr,n.y*this._dimensions.device.cell.height,n.dpr,this._dimensions.device.cell.height,this._cursorFloat)),e.count=s}_updateRectangle(t,e,n,i,s,a,l){if(n&67108864)switch(n&50331648){case 16777216:case 33554432:Fs=this._themeService.colors.ansi[n&255].rgba;break;case 50331648:Fs=(n&16777215)<<8;break;case 0:default:Fs=this._themeService.colors.foreground.rgba}else switch(i&50331648){case 16777216:case 33554432:Fs=this._themeService.colors.ansi[i&255].rgba;break;case 50331648:Fs=(i&16777215)<<8;break;case 0:default:Fs=this._themeService.colors.background.rgba}t.attributes.length<e+4&&(t.attributes=hR(t.attributes,this._terminal.rows*this._terminal.cols*Hs)),fw=s*this._dimensions.device.cell.width,pw=l*this._dimensions.device.cell.height,mw=(Fs>>24&255)/255,gw=(Fs>>16&255)/255,vw=(Fs>>8&255)/255,_w=1,this._addRectangle(t.attributes,e,fw,pw,(a-s)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,mw,gw,vw,_w)}_addRectangle(t,e,n,i,s,a,l,d,h,f){t[e]=n/this._dimensions.device.canvas.width,t[e+1]=i/this._dimensions.device.canvas.height,t[e+2]=s/this._dimensions.device.canvas.width,t[e+3]=a/this._dimensions.device.canvas.height,t[e+4]=l,t[e+5]=d,t[e+6]=h,t[e+7]=f}_addRectangleFloat(t,e,n,i,s,a,l){t[e]=n/this._dimensions.device.canvas.width,t[e+1]=i/this._dimensions.device.canvas.height,t[e+2]=s/this._dimensions.device.canvas.width,t[e+3]=a/this._dimensions.device.canvas.height,t[e+4]=l[0],t[e+5]=l[1],t[e+6]=l[2],t[e+7]=l[3]}_colorToFloat32Array(t){return new Float32Array([(t.rgba>>24&255)/255,(t.rgba>>16&255)/255,(t.rgba>>8&255)/255,(t.rgba&255)/255])}},ER=class extends rs{constructor(t,e,n,i,s,a,l,d){super(),this._container=e,this._alpha=s,this._coreBrowserService=a,this._optionsService=l,this._themeService=d,this._deviceCharWidth=0,this._deviceCharHeight=0,this._deviceCellWidth=0,this._deviceCellHeight=0,this._deviceCharLeft=0,this._deviceCharTop=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add(`xterm-${n}-layer`),this._canvas.style.zIndex=i.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors(h=>{this._refreshCharAtlas(t,h),this.reset(t)})),this._register(ni(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=xn(this._canvas.getContext("2d",{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(t){}handleFocus(t){}handleCursorMove(t){}handleGridChanged(t,e,n){}handleSelectionChanged(t,e,n,i=!1){}_setTransparency(t,e){if(e===this._alpha)return;let n=this._canvas;this._alpha=e,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,n),this._refreshCharAtlas(t,this._themeService.colors),this.handleGridChanged(t,0,t.rows-1)}_refreshCharAtlas(t,e){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=QS(t,this._optionsService.rawOptions,e,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr,2048),this._charAtlas.warmUp())}resize(t,e){this._deviceCellWidth=e.device.cell.width,this._deviceCellHeight=e.device.cell.height,this._deviceCharWidth=e.device.char.width,this._deviceCharHeight=e.device.char.height,this._deviceCharLeft=e.device.char.left,this._deviceCharTop=e.device.char.top,this._canvas.width=e.device.canvas.width,this._canvas.height=e.device.canvas.height,this._canvas.style.width=`${e.css.canvas.width}px`,this._canvas.style.height=`${e.css.canvas.height}px`,this._alpha||this._clearAll(),this._refreshCharAtlas(t,this._themeService.colors)}_fillBottomLineAtCells(t,e,n=1){this._ctx.fillRect(t*this._deviceCellWidth,(e+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,n*this._deviceCellWidth,this._coreBrowserService.dpr)}_clearAll(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))}_clearCells(t,e,n,i){this._alpha?this._ctx.clearRect(t*this._deviceCellWidth,e*this._deviceCellHeight,n*this._deviceCellWidth,i*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(t*this._deviceCellWidth,e*this._deviceCellHeight,n*this._deviceCellWidth,i*this._deviceCellHeight))}_fillCharTrueColor(t,e,n,i){this._ctx.font=this._getFont(t,!1,!1),this._ctx.textBaseline=$S,this._clipCell(n,i,e.getWidth()),this._ctx.fillText(e.getChars(),n*this._deviceCellWidth+this._deviceCharLeft,i*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(t,e,n){this._ctx.beginPath(),this._ctx.rect(t*this._deviceCellWidth,e*this._deviceCellHeight,n*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(t,e,n){let i=e?t.options.fontWeightBold:t.options.fontWeight;return`${n?"italic":""} ${i} ${t.options.fontSize*this._coreBrowserService.dpr}px ${t.options.fontFamily}`}},NR=class extends ER{constructor(t,e,n,i,s,a,l){super(n,t,"link",e,!0,s,a,l),this._register(i.onShowLinkUnderline(d=>this._handleShowLinkUnderline(d))),this._register(i.onHideLinkUnderline(d=>this._handleHideLinkUnderline(d)))}resize(t,e){super.resize(t,e),this._state=void 0}reset(t){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);let t=this._state.y2-this._state.y1-1;t>0&&this._clearCells(0,this._state.y1+1,this._state.cols,t),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(t){if(t.fg===257?this._ctx.fillStyle=this._themeService.colors.background.css:t.fg!==void 0&&cR(t.fg)?this._ctx.fillStyle=this._themeService.colors.ansi[t.fg].css:this._ctx.fillStyle=this._themeService.colors.foreground.css,t.y1===t.y2)this._fillBottomLineAtCells(t.x1,t.y1,t.x2-t.x1);else{this._fillBottomLineAtCells(t.x1,t.y1,t.cols-t.x1);for(let e=t.y1+1;e<t.y2;e++)this._fillBottomLineAtCells(0,e,t.cols);this._fillBottomLineAtCells(0,t.y2,t.x2)}this._state=t}_handleHideLinkUnderline(t){this._clearCurrentLink()}},io=typeof window=="object"?window:globalThis,Up=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Qt,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Qt,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,n){if(this.getZoomLevel(n)===e)return;let i=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(i,e),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),e)}setFullscreen(e,n){if(this.isFullscreen(n)===e)return;let i=this.getWindowId(n);this.mapWindowIdToFullScreen.set(i,e),this._onDidChangeFullscreen.fire(i)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};Up.INSTANCE=new Up;var t1=Up;function LR(t,e,n){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",n)}t1.INSTANCE.onDidChangeZoomLevel;t1.INSTANCE.onDidChangeFullscreen;var pa=typeof navigator=="object"?navigator.userAgent:"";pa.indexOf("Firefox")>=0;pa.indexOf("AppleWebKit")>=0;var RR=pa.indexOf("Chrome")>=0;!RR&&pa.indexOf("Safari")>=0;pa.indexOf("Electron/")>=0;pa.indexOf("Android")>=0;var af=!1;if(typeof io.matchMedia=="function"){let t=io.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=io.matchMedia("(display-mode: fullscreen)");af=t.matches,LR(io,t,({matches:n})=>{af&&e.matches||(af=n)})}var Zo="en",lf=!1,n1=!1,tu,_u=Zo,yw=Zo,MR,ss,ao=globalThis,Vn,t0;typeof ao.vscode<"u"&&typeof ao.vscode.process<"u"?Vn=ao.vscode.process:typeof process<"u"&&typeof((t0=process==null?void 0:process.versions)==null?void 0:t0.node)=="string"&&(Vn=process);var n0,AR=typeof((n0=Vn==null?void 0:Vn.versions)==null?void 0:n0.electron)=="string",jR=AR&&(Vn==null?void 0:Vn.type)==="renderer",i0;if(typeof Vn=="object"){Vn.platform,Vn.platform,lf=Vn.platform==="linux",lf&&Vn.env.SNAP&&Vn.env.SNAP_REVISION,Vn.env.CI||Vn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,tu=Zo,_u=Zo;let t=Vn.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);tu=e.userLocale,yw=e.osLocale,_u=e.resolvedLanguage||Zo,MR=(i0=e.languagePack)==null?void 0:i0.translationsConfigFile}catch{}n1=!0}else typeof navigator=="object"&&!jR?(ss=navigator.userAgent,ss.indexOf("Windows")>=0,ss.indexOf("Macintosh")>=0,(ss.indexOf("Macintosh")>=0||ss.indexOf("iPad")>=0||ss.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,lf=ss.indexOf("Linux")>=0,(ss==null?void 0:ss.indexOf("Mobi"))>=0,_u=globalThis._VSCODE_NLS_LANGUAGE||Zo,tu=navigator.language.toLowerCase(),yw=tu):console.error("Unable to resolve platform.");var ww=n1,Es=ss,yr=_u,PR;(t=>{function e(){return yr}t.value=e;function n(){return yr.length===2?yr==="en":yr.length>=3?yr[0]==="e"&&yr[1]==="n"&&yr[2]==="-":!1}t.isDefaultVariant=n;function i(){return yr==="en"}t.isDefault=i})(PR||(PR={}));var TR=typeof ao.postMessage=="function"&&!ao.importScripts;(()=>{if(TR){let t=[];ao.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let i=0,s=t.length;i<s;i++){let a=t[i];if(a.id===n.data.vscodeScheduleAsyncWork){t.splice(i,1),a.callback();return}}});let e=0;return n=>{let i=++e;t.push({id:i,callback:n}),ao.postMessage({vscodeScheduleAsyncWork:i},"*")}}return t=>setTimeout(t)})();var DR=!!(Es&&Es.indexOf("Chrome")>=0);Es&&Es.indexOf("Firefox")>=0;!DR&&Es&&Es.indexOf("Safari")>=0;Es&&Es.indexOf("Edg/")>=0;Es&&Es.indexOf("Android")>=0;var qo=typeof navigator=="object"?navigator:{};ww||document.queryCommandSupported&&document.queryCommandSupported("copy")||qo&&qo.clipboard&&qo.clipboard.writeText,ww||qo&&qo.clipboard&&qo.clipboard.readText;var Om=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(t,e){this._keyCodeToStr[t]=e,this._strToKeyCode[e.toLowerCase()]=t}keyCodeToStr(t){return this._keyCodeToStr[t]}strToKeyCode(t){return this._strToKeyCode[t.toLowerCase()]||0}},cf=new Om,bw=new Om,Sw=new Om;new Array(230);var IR;(t=>{function e(d){return cf.keyCodeToStr(d)}t.toString=e;function n(d){return cf.strToKeyCode(d)}t.fromString=n;function i(d){return bw.keyCodeToStr(d)}t.toUserSettingsUS=i;function s(d){return Sw.keyCodeToStr(d)}t.toUserSettingsGeneral=s;function a(d){return bw.strToKeyCode(d)||Sw.strToKeyCode(d)}t.fromUserSettings=a;function l(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 cf.keyCodeToStr(d)}t.toElectronAccelerator=l})(IR||(IR={}));var i1=Object.freeze(function(t,e){let n=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(n)}}}),BR;(t=>{function e(n){return n===t.None||n===t.Cancelled||n instanceof OR?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ks.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:i1})})(BR||(BR={}));var OR=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?i1:(this._emitter||(this._emitter=new Qt),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},$R;(t=>{async function e(i){let s,a=await Promise.all(i.map(l=>l.then(d=>d,d=>{s||(s=d)})));if(typeof s<"u")throw s;return a}t.settled=e;function n(i){return new Promise(async(s,a)=>{try{await i(s,a)}catch(l){a(l)}})}t.withAsyncBody=n})($R||($R={}));var xw=class qi{static fromArray(e){return new qi(n=>{n.emitMany(e)})}static fromPromise(e){return new qi(async n=>{n.emitMany(await e)})}static fromPromises(e){return new qi(async n=>{await Promise.all(e.map(async i=>n.emitOne(await i)))})}static merge(e){return new qi(async n=>{await Promise.all(e.map(async i=>{for await(let s of i)n.emitOne(s)}))})}constructor(e,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new Qt,queueMicrotask(async()=>{let i={emitOne:s=>this.emitOne(s),emitMany:s=>this.emitMany(s),reject:s=>this.reject(s)};try{await Promise.resolve(e(i)),this.resolve()}catch(s){this.reject(s)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await Ks.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var n;return(n=this._onReturn)==null||n.call(this),{done:!0,value:void 0}}}}static map(e,n){return new qi(async i=>{for await(let s of e)i.emitOne(n(s))})}map(e){return qi.map(this,e)}static filter(e,n){return new qi(async i=>{for await(let s of e)n(s)&&i.emitOne(s)})}filter(e){return qi.filter(this,e)}static coalesce(e){return qi.filter(e,n=>!!n)}coalesce(){return qi.coalesce(this)}static async toPromise(e){let n=[];for await(let i of e)n.push(i);return n}toPromise(){return qi.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};xw.EMPTY=xw.fromArray([]);var{getWindow:zR}=(function(){let t=new Map,e={window:io,disposables:new na};t.set(io.vscodeWindowId,e);let n=new Qt,i=new Qt,s=new Qt;function a(l,d){return(typeof l=="number"?t.get(l):void 0)??(d?e:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:s.event,onDidUnregisterWindow:i.event,registerWindow(l){if(t.has(l.vscodeWindowId))return rs.None;let d=new na,h={window:l,disposables:d.add(new na)};return t.set(l.vscodeWindowId,h),d.add(ni(()=>{t.delete(l.vscodeWindowId),i.fire(l)})),d.add(Wp(l,HR.BEFORE_UNLOAD,()=>{s.fire(l)})),n.fire(h),d},getWindows(){return t.values()},getWindowsCount(){return t.size},getWindowId(l){return l.vscodeWindowId},hasWindow(l){return t.has(l)},getWindowById:a,getWindow(l){var f;let d=l;if((f=d==null?void 0:d.ownerDocument)!=null&&f.defaultView)return d.ownerDocument.defaultView.window;let h=l;return h!=null&&h.view?h.view.window:io},getDocument(l){return zR(l).document}}})(),FR=class{constructor(t,e,n,i){this._node=t,this._type=e,this._handler=n,this._options=i||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Wp(t,e,n,i){return new FR(t,e,n,i)}var HR={BEFORE_UNLOAD:"beforeunload"},UR=class extends rs{constructor(t,e,n,i,s,a,l,d,h){super(),this._terminal=t,this._characterJoinerService=e,this._charSizeService=n,this._coreBrowserService=i,this._coreService=s,this._decorationService=a,this._optionsService=l,this._themeService=d,this._cursorBlinkStateManager=new sl,this._charAtlasDisposable=this._register(new sl),this._observerDisposable=this._register(new sl),this._model=new bR,this._workCell=new uw,this._workCell2=new uw,this._rectangleRenderer=this._register(new sl),this._glyphRenderer=this._register(new sl),this._onChangeTextureAtlas=this._register(new Qt),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Qt),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Qt),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new Qt),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new Qt),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas");let f={antialias:!1,depth:!1,preserveDrawingBuffer:h};if(this._gl=this._canvas.getContext("webgl2",f),!this._gl)throw new Error("WebGL2 not supported "+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new IL(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new NR(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,l,this._themeService)],this.dimensions=TL(),this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(l.onOptionChange(()=>this._handleOptionsChanged())),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(Wp(this._canvas,"webglcontextlost",g=>{console.log("webglcontextlost event received"),g.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,console.warn("webgl context not restored; firing onContextLoss"),this._onContextLoss.fire(g)},3e3)})),this._register(Wp(this._canvas,"webglcontextrestored",g=>{console.warn("webglcontextrestored event received"),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,lw(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=cw(this._canvas,this._coreBrowserService.window,(g,y)=>this._setCanvasDevicePixelDimensions(g,y)),this._register(this._coreBrowserService.onWindowChange(g=>{this._observerDisposable.value=cw(this._canvas,g,(y,_)=>this._setCanvasDevicePixelDimensions(y,_))})),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(ni(()=>{var g;for(let y of this._renderLayers)y.dispose();(g=this._canvas.parentElement)==null||g.removeChild(this._canvas),lw(this._terminal)}))}get textureAtlas(){var t;return(t=this._charAtlas)==null?void 0:t.pages[0].canvas}_handleColorChange(){this._refreshCharAtlas(),this._clearModel(!0)}handleDevicePixelRatioChange(){this._devicePixelRatio!==this._coreBrowserService.dpr&&(this._devicePixelRatio=this._coreBrowserService.dpr,this.handleResize(this._terminal.cols,this._terminal.rows))}handleResize(t,e){var n,i,s,a;this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(let l of this._renderLayers)l.resize(this._terminal,this.dimensions);this._canvas.width=this.dimensions.device.canvas.width,this._canvas.height=this.dimensions.device.canvas.height,this._canvas.style.width=`${this.dimensions.css.canvas.width}px`,this._canvas.style.height=`${this.dimensions.css.canvas.height}px`,this._core.screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._core.screenElement.style.height=`${this.dimensions.css.canvas.height}px`,(n=this._rectangleRenderer.value)==null||n.setDimensions(this.dimensions),(i=this._rectangleRenderer.value)==null||i.handleResize(),(s=this._glyphRenderer.value)==null||s.setDimensions(this.dimensions),(a=this._glyphRenderer.value)==null||a.handleResize(),this._refreshCharAtlas(),this._clearModel(!1)}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){var t;for(let e of this._renderLayers)e.handleBlur(this._terminal);(t=this._cursorBlinkStateManager.value)==null||t.pause(),this._requestRedrawViewport()}handleFocus(){var t;for(let e of this._renderLayers)e.handleFocus(this._terminal);(t=this._cursorBlinkStateManager.value)==null||t.resume(),this._requestRedrawViewport()}handleSelectionChanged(t,e,n){for(let i of this._renderLayers)i.handleSelectionChanged(this._terminal,t,e,n);this._model.selection.update(this._core,t,e,n),this._requestRedrawViewport()}handleCursorMove(){var t;for(let e of this._renderLayers)e.handleCursorMove(this._terminal);(t=this._cursorBlinkStateManager.value)==null||t.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new kR(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new vR(this._terminal,this._gl,this.dimensions,this._optionsService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){var e;if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0){this._isAttached=!1;return}let t=QS(this._terminal,this._optionsService.rawOptions,this._themeService.colors,this.dimensions.device.cell.width,this.dimensions.device.cell.height,this.dimensions.device.char.width,this.dimensions.device.char.height,this._coreBrowserService.dpr,this._deviceMaxTextureSize);this._charAtlas!==t&&(this._onChangeTextureAtlas.fire(t.pages[0].canvas),this._charAtlasDisposable.value=TS(Ks.forward(t.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),Ks.forward(t.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas))),this._charAtlas=t,this._charAtlas.warmUp(),(e=this._glyphRenderer.value)==null||e.setAtlas(this._charAtlas)}_clearModel(t){var e;this._model.clear(),t&&((e=this._glyphRenderer.value)==null||e.clear())}clearTextureAtlas(){var t;(t=this._charAtlas)==null||t.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){var t;this._clearModel(!0);for(let e of this._renderLayers)e.reset(this._terminal);(t=this._cursorBlinkStateManager.value)==null||t.restartBlinkAnimation(),this._updateCursorBlink()}renderRows(t,e){var n;if(!this._isAttached)if((n=this._core.screenElement)!=null&&n.isConnected&&this._charSizeService.width&&this._charSizeService.height)this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0;else return;for(let i of this._renderLayers)i.handleGridChanged(this._terminal,t,e);!this._glyphRenderer.value||!this._rectangleRenderer.value||(this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(t,e),this._rectangleRenderer.value.renderBackgrounds(),this._glyphRenderer.value.render(this._model),(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible)&&this._rectangleRenderer.value.renderCursor())}_updateCursorBlink(){this._coreService.decPrivateModes.cursorBlink??this._terminal.options.cursorBlink?this._cursorBlinkStateManager.value=new uR(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(t,e){let n=this._core,i=this._workCell,s,a,l,d,h,f,g=0,y=!0,_,w,b,N,x,E,C,I,T;t=Cw(t,n.rows-1,0),e=Cw(e,n.rows-1,0);let W=this._coreService.decPrivateModes.cursorStyle??n.options.cursorStyle??"block",U=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,Q=U-n.buffer.ydisp,ee=Math.min(this._terminal.buffer.active.cursorX,n.cols-1),q=-1,J=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let $=!1;for(a=t;a<=e;a++)for(l=a+n.buffer.ydisp,d=n.buffer.lines.get(l),this._model.lineLengths[a]=0,b=U===l,g=0,h=this._characterJoinerService.getJoinedCharacters(l),I=0;I<n.cols;I++){if(s=this._cellColorResolver.result.bg,d.loadCell(I,i),I===0&&(s=this._cellColorResolver.result.bg),f=!1,y=I>=g,_=I,h.length>0&&I===h[0][0]&&y){w=h.shift();let M=this._model.selection.isCellSelected(this._terminal,w[0],l);for(C=w[0]+1;C<w[1];C++)y&&(y=M===this._model.selection.isCellSelected(this._terminal,C,l));y&&(y=!b||ee<w[0]||ee>=w[1]),y?(f=!0,i=new WR(i,d.translateToString(!0,w[0],w[1]),w[1]-w[0]),_=w[1]-1):g=w[1]}if(N=i.getChars(),x=i.getCode(),C=(a*n.cols+I)*Iu,this._cellColorResolver.resolve(i,I,l,this.dimensions.device.cell.width),J&&l===U&&(I===ee&&(this._model.cursor={x:ee,y:Q,width:i.getWidth(),style:this._coreBrowserService.isFocused?W:n.options.cursorInactiveStyle,cursorWidth:n.options.cursorWidth,dpr:this._devicePixelRatio},q=ee+i.getWidth()-1),I>=ee&&I<=q&&(this._coreBrowserService.isFocused&&W==="block"||this._coreBrowserService.isFocused===!1&&n.options.cursorInactiveStyle==="block")&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),x!==0&&(this._model.lineLengths[a]=I+1),!(this._model.cells[C]===x&&this._model.cells[C+gu]===this._cellColorResolver.result.bg&&this._model.cells[C+vu]===this._cellColorResolver.result.fg&&this._model.cells[C+rf]===this._cellColorResolver.result.ext)&&($=!0,N.length>1&&(x|=wR),this._model.cells[C]=x,this._model.cells[C+gu]=this._cellColorResolver.result.bg,this._model.cells[C+vu]=this._cellColorResolver.result.fg,this._model.cells[C+rf]=this._cellColorResolver.result.ext,E=i.getWidth(),this._glyphRenderer.value.updateCell(I,a,x,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,N,E,s),f)){for(i=this._workCell,I++;I<=_;I++)T=(a*n.cols+I)*Iu,this._glyphRenderer.value.updateCell(I,a,0,0,0,0,NL,0,0),this._model.cells[T]=0,this._model.cells[T+gu]=this._cellColorResolver.result.bg,this._model.cells[T+vu]=this._cellColorResolver.result.fg,this._model.cells[T+rf]=this._cellColorResolver.result.ext;I--}}$&&this._rectangleRenderer.value.updateBackgrounds(this._model),this._rectangleRenderer.value.updateCursor(this._model)}_updateDimensions(){!this._charSizeService.width||!this._charSizeService.height||(this.dimensions.device.char.width=Math.floor(this._charSizeService.width*this._devicePixelRatio),this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*this._devicePixelRatio),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.top=this._optionsService.rawOptions.lineHeight===1?0:Math.round((this.dimensions.device.cell.height-this.dimensions.device.char.height)/2),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.char.left=Math.floor(this._optionsService.rawOptions.letterSpacing/2),this.dimensions.device.canvas.height=this._terminal.rows*this.dimensions.device.cell.height,this.dimensions.device.canvas.width=this._terminal.cols*this.dimensions.device.cell.width,this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/this._devicePixelRatio),this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/this._devicePixelRatio),this.dimensions.css.cell.height=this.dimensions.device.cell.height/this._devicePixelRatio,this.dimensions.css.cell.width=this.dimensions.device.cell.width/this._devicePixelRatio)}_setCanvasDevicePixelDimensions(t,e){this._canvas.width===t&&this._canvas.height===e||(this._canvas.width=t,this._canvas.height=e,this._requestRedrawViewport())}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){let t=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:t,end:t})}},WR=class extends Jo{constructor(t,e,n){super(),this.content=0,this.combinedData="",this.fg=t.fg,this.bg=t.bg,this.combinedData=e,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(t){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function Cw(t,e,n=0){return Math.max(Math.min(t,e),n)}var kw="di$target",Ew="di$dependencies",uf=new Map;function Ns(t){if(uf.has(t))return uf.get(t);let e=function(n,i,s){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");qR(e,n,s)};return e._id=t,uf.set(t,e),e}function qR(t,e,n){e[kw]===e?e[Ew].push({id:t,index:n}):(e[Ew]=[{id:t,index:n}],e[kw]=e)}Ns("BufferService");Ns("CoreMouseService");Ns("CoreService");Ns("CharsetService");Ns("InstantiationService");Ns("LogService");var KR=Ns("OptionsService");Ns("OscLinkService");Ns("UnicodeService");Ns("DecorationService");var VR={trace:0,debug:1,info:2,warn:3,error:4,off:5},YR="xterm.js: ",Nw=class extends rs{constructor(t){super(),this._optionsService=t,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=VR[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(t){for(let e=0;e<t.length;e++)typeof t[e]=="function"&&(t[e]=t[e]())}_log(t,e,n){this._evalLazyOptionalParams(n),t.call(console,(this._optionsService.options.logger?"":YR)+e,...n)}trace(t,...e){var n;this._logLevel<=0&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.trace.bind(this._optionsService.options.logger))??console.log,t,e)}debug(t,...e){var n;this._logLevel<=1&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.debug.bind(this._optionsService.options.logger))??console.log,t,e)}info(t,...e){var n;this._logLevel<=2&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.info.bind(this._optionsService.options.logger))??console.info,t,e)}warn(t,...e){var n;this._logLevel<=3&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.warn.bind(this._optionsService.options.logger))??console.warn,t,e)}error(t,...e){var n;this._logLevel<=4&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.error.bind(this._optionsService.options.logger))??console.error,t,e)}};Nw=mL([gL(0,KR)],Nw);var GR=class extends rs{constructor(t){if(BS&&EL()<16){let e={antialias:!1,depth:!1,preserveDrawingBuffer:!0};if(!document.createElement("canvas").getContext("webgl2",e))throw new Error("Webgl2 is only supported on Safari 16 and above")}super(),this._preserveDrawingBuffer=t,this._onChangeTextureAtlas=this._register(new Qt),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Qt),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Qt),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new Qt),this.onContextLoss=this._onContextLoss.event}activate(t){let e=t._core;if(!t.element){this._register(e.onWillOpen(()=>this.activate(t)));return}this._terminal=t;let n=e.coreService,i=e.optionsService,s=e,a=s._renderService,l=s._characterJoinerService,d=s._charSizeService,h=s._coreBrowserService,f=s._decorationService;s._logService;let g=s._themeService;this._renderer=this._register(new UR(t,l,d,h,n,f,i,g,this._preserveDrawingBuffer)),this._register(Ks.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(Ks.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(Ks.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(Ks.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),a.setRenderer(this._renderer),this._register(ni(()=>{if(this._terminal._core._store._isDisposed)return;let y=this._terminal._core._renderService;y.setRenderer(this._terminal._core._createRenderer()),y.handleResize(t.cols,t.rows)}))}get textureAtlas(){var t;return(t=this._renderer)==null?void 0:t.textureAtlas}clearTextureAtlas(){var t;(t=this._renderer)==null||t.clearTextureAtlas()}};const s1="nc-terminal-renderer",la="webgl",ho="dom";function r1(t){if(t!==void 0)return t;try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function Sl(t){const e=r1(t);try{return e&&e.getItem(s1)===ho?ho:la}catch{return la}}function XR(t,e){const n=t===ho?ho:la,i=r1(e);try{i&&i.setItem(s1,n)}catch{}return n}function QR(t){return t===ho?la:ho}function JR(t,{preference:e,createAddon:n,onFallback:i}={}){const s=e||Sl(),a={kind:ho,dispose:()=>{}};if(s!==la||!t||typeof t.loadAddon!="function"||typeof n!="function")return a;let l;try{if(l=n(),!l)return a;t.loadAddon(l)}catch{try{l&&l.dispose()}catch{}return i&&i("unavailable"),a}let d=!1;const h=()=>{if(!d){d=!0;try{l.dispose()}catch{}}};return typeof l.onContextLoss=="function"&&l.onContextLoss(()=>{h(),i&&i("context-loss")}),{kind:la,dispose:h}}function ZR(t,e){return t?`/api/route/${String(t).split("/").map(encodeURIComponent).join("/")}/_/ws?token=${encodeURIComponent(e||"")}`:"/ws"}function eM({session:t,node:e,token:n,cols:i,rows:s,readonly:a=!1,takeSize:l,focused:d,onData:h,onExit:f,onFiles:g,retryBaseMs:y=250,retryStableMs:_=5e3,onRetryScheduled:w}){const b=["localhost","127.0.0.1","::1","[::1]"].includes(location.hostname);if(location.protocol!=="https:"&&!b)throw new Error("nexuscrew: ws:// rifiutato su origine non-locale e non-TLS (apri via tunnel su localhost o servi in HTTPS)");const x=`${location.protocol==="https:"?"wss":"ws"}://${location.host}${ZR(e,n)}`;let E=null,C=!1,I=!1,T=null,W=null,U=0,Q=null,ee=d;const q=()=>{if(C||I||T)return;const $=Math.min(5e3,Math.max(0,y)*2**Math.min(U++,5));typeof w=="function"&&w($),T=setTimeout(()=>{T=null,J()},$)},J=()=>{if(C||I)return;const $=new WebSocket(x);E=$,$.binaryType="arraybuffer",$.onopen=()=>{if(E!==$||C)return;W&&clearTimeout(W);const M=Number(_),L=Number.isFinite(M)?Math.max(0,M):5e3;W=setTimeout(()=>{W=null,E===$&&$.readyState===1&&(U=0)},L),typeof W.unref=="function"&&W.unref();const j={type:"attach",session:t,token:n,cols:i,rows:s,readonly:a};Q&&(j.reconnectToken=Q),l!==void 0&&(j.takeSize=l),$.send(JSON.stringify(j)),ee!==void 0&&$.send(JSON.stringify({type:"focus",on:!!ee}))},$.onmessage=M=>{if(!(E!==$||C))if(typeof M.data=="string"){let L;try{L=JSON.parse(M.data)}catch{return}L.type==="attached"&&typeof L.reconnectToken=="string"&&L.reconnectToken&&(Q=L.reconnectToken),L.type==="exit"&&(I=!0,f&&f(L.code)),L.type==="files"&&g&&g(L)}else h&&h(new Uint8Array(M.data))},$.onerror=()=>{if(E===$)try{$.close()}catch{}},$.onclose=M=>{E!==$||C||I||(W&&(clearTimeout(W),W=null),![1e3,1002,4401,4404].includes(M==null?void 0:M.code)&&q())}};return J(),{sendInput:$=>{if(!E||E.readyState!==1)return!1;try{return E.send(typeof $=="string"?new TextEncoder().encode($):$),!0}catch{try{E.close()}catch{}return!1}},isReady:()=>!!E&&E.readyState===1,resize:($,M)=>{i=$,s=M,(E==null?void 0:E.readyState)===1&&E.send(JSON.stringify({type:"resize",cols:$,rows:M}))},action:$=>{(E==null?void 0:E.readyState)===1&&E.send(JSON.stringify({type:"action",name:$}))},focus:$=>{ee=$,(E==null?void 0:E.readyState)===1&&E.send(JSON.stringify({type:"focus",on:!!$}))},close:()=>{if(C=!0,T&&clearTimeout(T),W&&clearTimeout(W),T=null,W=null,E)try{E.close()}catch{}},get raw(){return E}}}async function qp(t){const e=String(t||"");if(!e)return!1;try{if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")return await navigator.clipboard.writeText(e),!0}catch{}try{const n=document.createElement("textarea");n.value=e,n.readOnly=!0,n.style.position="fixed",n.style.opacity="0",n.style.pointerEvents="none",document.body.appendChild(n),n.select();const i=document.execCommand&&document.execCommand("copy");if(n.remove(),i)return!0}catch{}return!1}const tM="\r";function nM(t){const e=String(t||"");let n=e.length;for(;n>0;){const i=e.charCodeAt(n-1);if(i===10||i===13)n-=1;else break}return e.slice(0,n)}function iM({isReady:t,paste:e,send:n}){return i=>{if(!i||!t())return!1;try{return e(i)===!1||!t()?!1:n(tM)!==!1}catch{return!1}}}function sM(t){return!t||typeof t!="object"?!1:!!t.shiftKey}function rM(t){return!t||typeof t!="object"||String(t.key||"").toLowerCase()!=="c"?!1:!!(t.metaKey||t.ctrlKey&&t.shiftKey)}function oM(t){return/mac|iphone|ipad/i.test(String(t||""))?"⌘C":"Ctrl+Shift+C"}const aM=450,Lw=8;function Rw(t,e,n,i){return Math.abs(Number(n)-Number(t))>Lw||Math.abs(Number(i)-Number(e))>Lw}function lM({range:t,cell:e,cols:n}){const i=Number(n),s=Number(t.start.row)*i+Number(t.start.col),a=Number(t.end.row)*i+Number(t.end.col),l=Number(e.row)*i+Number(e.col),d={start:{row:t.start.row,col:t.start.col},end:{row:t.end.row,col:t.end.col},moved:null};if(l<s)d.start={row:Number(e.row),col:Number(e.col)},d.moved="start";else if(l>a)d.end={row:Number(e.row),col:Number(e.col)},d.moved="end";else{if(l===s||l===a)return d;l-s<=a-l?(d.start={row:Number(e.row),col:Number(e.col)},d.moved="start"):(d.end={row:Number(e.row),col:Number(e.col)},d.moved="end")}return d}function cM(t){const e=t!=="mouse";return{handles:e,magnifier:e}}function uM(t,e){if(!t||!t.start||!t.end)return null;const n=Number(e);if(!Number.isFinite(n)||n<=0)return null;const i=Number(t.start.y)*n+Number(t.start.x),s=Number(t.end.y)*n+Number(t.end.x),a=Math.min(i,s),l=Math.max(a,Math.max(i,s)-1);return{start:{row:Math.floor(a/n),col:a%n},end:{row:Math.floor(l/n),col:l%n}}}function Mw(t,e,n){const i=Number(t.row)*Number(n)+Number(t.col),s=Number(e.row)*Number(n)+Number(e.col);return i<=s?{start:{row:t.row,col:t.col},end:{row:e.row,col:e.col}}:{start:{row:e.row,col:e.col},end:{row:t.row,col:t.col}}}function dM({moving:t,fixed:e,which:n,cols:i,maxRow:s}){const a=Number(i);let l=Math.max(0,Math.min(Number(s),Number(t.row))),d=Math.max(0,Math.min(a-1,Number(t.col)));const h=l*a+d,f=Number(e.row)*a+Number(e.col);return n==="start"&&h>f&&(l=Number(e.row),d=Number(e.col)),n==="end"&&h<f&&(l=Number(e.row),d=Number(e.col)),{row:l,col:d}}function Ko({line:t,col:e,side:n,cols:i}){const s=Math.max(0,Math.min(Number(i)-1,Number(e))),a=t&&typeof t.getCell=="function"?t.getCell(s):null;return(a&&typeof a.getWidth=="function"?Number(a.getWidth()):1)!==0?s:n==="end"?Math.min(Number(i)-1,s+1):Math.max(0,s-1)}function Aw({line:t,col:e,cols:n}){const i=Math.max(0,Math.min(Number(n)-1,Number(e))),s=d=>{const h=t&&typeof t.getCell=="function"?t.getCell(d):null;return h&&typeof h.getChars=="function"?h.getChars():""};if(s(i)===""||s(i)===" ")return{start:i,end:i};let a=i;for(;a>0;){const d=s(a-1);if(d===""||d===" ")break;a-=1}let l=i;for(;l<Number(n)-1;){const d=s(l+1);if(d===""||d===" ")break;l+=1}return{start:a,end:l}}function hM({startLeft:t,endLeft:e,targetWidth:n=46}){return Math.abs(Number(e)-Number(t))<Number(n)}function fM({anchorLeft:t,anchorTop:e,hostWidth:n,hostHeight:i,bubbleWidth:s,bubbleHeight:a,pinHeight:l=30,margin:d=4,gap:h=8}){const f=Number(s),g=Number(a),y=Number(d),_=Math.max(y,Number(n)-y-f),w=Math.max(y,Math.min(_,Number(t)-Math.round(f/2)));let b=Number(e)-Number(h)-g,N=!1;b<y&&(b=Number(e)+Number(l)+Number(h),N=!0);const x=Math.max(y,Number(i)-y-g);return b>x&&(b=x),{left:w,top:b,flipped:N}}function jw(t,e){const n=Number(e),i=Number(t.start.row)*n+Number(t.start.col),s=Number(t.end.row)*n+Number(t.end.col);return{col:t.start.col,row:t.start.row,length:s-i+1}}const Pw=28,pM=50;function mM({range:t,viewportY:e,rows:n,cols:i=0,cellWidth:s,cellHeight:a,screenLeft:l=0,screenTop:d=0}){const h={},f=Number(i)*Number(s);for(const g of["start","end"]){const y=t[g],_=Number(y.row)-Number(e),w=_>=0&&_<Number(n),b=(g==="start"?Number(y.col):Number(y.col)+1)*Number(s),N=g==="start"?b-Pw<0:b+Pw>f;h[g]={left:Number(l)+b,top:Number(d)+(_+1)*Number(a),visible:w,flip:N}}return h}function gM({visibleRow:t,rows:e}){const n=Number(t);return n<=0?-1:n>=Number(e)-1?1:0}function vM({range:t,side:e,line:n,cols:i}){if(!t||!t.start||!t.end||!n)return null;const s=Math.max(0,Number(i)-1),a=e==="end"?t.end:t.start,l=Number(a.row);let d,h;Number(t.start.row)===Number(t.end.row)?(d=Number(t.start.col),h=Number(t.end.col)):l===Number(t.start.row)?(d=Number(t.start.col),h=s):l===Number(t.end.row)?(d=0,h=Number(t.end.col)):(d=0,h=s),d=Math.max(0,Math.min(s,d)),h=Math.max(d,Math.min(s,h));const f=n.translateToString(!0,0,d);let g=n.translateToString(!1,d,h+1);g.replace(/\s+$/,"")===""&&(g="");const y=n.translateToString(!0,Math.min(s+1,h+1),s+1);return{row:l,before:f,sel:g,after:y}}const Kp="(min-width:1024px) and (pointer:fine)";function _M(){const[t,e]=k.useState(()=>window.matchMedia(Kp).matches);return k.useEffect(()=>{const n=window.matchMedia(Kp),i=s=>e(s.matches);return n.addEventListener("change",i),()=>n.removeEventListener("change",i)},[]),t}const yM=new Map([["image/png","png"],["image/jpeg","jpg"],["image/gif","gif"],["image/webp","webp"],["application/pdf","pdf"],["text/plain","txt"]]);function df(t){return t?t.files&&t.files.length>0||Array.from(t.items||[]).some(e=>e&&e.kind==="file")?!0:Array.from(t.types||[]).includes("Files"):!1}function Tw(t){if(!t)return[];const e=Array.from(t.files||[]).filter(Boolean);return e.length?e:Array.from(t.items||[]).filter(n=>n&&n.kind==="file"&&typeof n.getAsFile=="function").map(n=>n.getAsFile()).filter(Boolean)}function wM(t,e=0,n=Date.now()){const i=String((t==null?void 0:t.name)||"").trim();if(i)return i;const s=yM.get(String((t==null?void 0:t.type)||"").toLowerCase())||"bin";return`clipboard-${n}-${e+1}.${s}`}async function Vp({files:t,token:e,session:n,node:i="",paste:s=!0,fetchImpl:a=pn,onProgress:l=()=>{},now:d=Date.now()}={}){const h=Array.from(t||[]).filter(Boolean),f=[],g=[];if(!n||!h.length)return{paths:f,errors:g};const y=an(i?String(i).split("/"):[]);for(let _=0;_<h.length;_+=1){const w=h[_],b=wM(w,_,d);l({index:_,total:h.length,name:b,state:"uploading"});try{const N=new FormData;N.append("session",n),N.append("paste",s?"true":"false"),N.append("file",w,b);const x=await a(`${y}/files/upload`,e,{method:"POST",body:N}),E=await x.json().catch(()=>({}));if(!x.ok||E.error)throw new Error(E.error||`HTTP ${x.status}`);f.push(E.path),l({index:_,total:h.length,name:b,state:"done",path:E.path})}catch(N){const x=String((N==null?void 0:N.message)||N);g.push({name:b,message:x}),l({index:_,total:h.length,name:b,state:"error",error:x})}}return{paths:f,errors:g}}const bM=420,SM=32;function xM(t){if(!t||typeof t!="object")return!1;const e=String(t.tagName||"").toLowerCase();return e==="textarea"||e==="input"||t.isContentEditable===!0}function Yp({documentRef:t,navigatorRef:e}={}){const n=t||(typeof document<"u"?document:null),i=e||(typeof navigator<"u"?navigator:null);let s=!1;try{i!=null&&i.virtualKeyboard&&typeof i.virtualKeyboard.hide=="function"&&(i.virtualKeyboard.hide(),s=!0)}catch{}const a=n&&n.activeElement;let l=!1;if(xM(a)&&typeof a.blur=="function")try{a.blur(),l=!0}catch{}return{blurred:l,apiRequested:s}}function o1(t,e,n=!1){const i=t&&t.textarea;if(!i)return null;const a=e==="single-tap"||e==="double-tap"&&n?"text":"none";return i.inputMode=a,i.setAttribute("inputmode",a),a}function CM(t,e){if(!t||!t.textarea)return!1;o1(t,"double-tap",!0);try{t.focus()}catch{return!1}const n=typeof navigator<"u"?navigator:null;try{n!=null&&n.virtualKeyboard&&typeof n.virtualKeyboard.show=="function"&&n.virtualKeyboard.show()}catch{}return!0}function kM(t,e,n){return t==="never"?{open:!1,next:null}:t==="single-tap"?{open:!0,next:null}:!n||!Number.isFinite(n.at)||!Number.isFinite(n.x)||!Number.isFinite(n.y)?{open:!1,next:null}:e&&n.at>=e.at&&n.at-e.at<=bM&&Math.hypot(n.x-e.x,n.y-e.y)<=SM?{open:!0,next:null}:{open:!1,next:n}}const EM=24,Dw=80,a1=8,NM="\x1B[5~",LM="\x1B[6~",RM=64,MM=65;function AM(t,e,n){const i=t==="up"?RM:MM,s=a=>Math.max(1,Math.min(9999,Number.isFinite(a)?Math.round(a):1));return`\x1B[<${i};${s(e)};${s(n)}M`}function jM({alternateScreen:t=!1,readonly:e=!1,mouseTracking:n=!1}={}){return e?"scroll":n?"mouse":t?"page":"scroll"}function PM(t,e){return t==="page"?Number.isFinite(e)&&e>0?Math.max(Dw,e):Dw:Number.isFinite(e)&&e>0?e:EM}function TM({mode:t="scroll",accumulated:e=0,threshold:n=0}={}){const i=PM(t,n);if(!Number.isFinite(e))return{mode:t,up:0,down:0,remainder:0};const s=Math.abs(e);if(s<i)return{mode:t,up:0,down:0,remainder:e};const a=Math.floor(s/i),l=Math.min(a,a1),d=(e>=0?1:-1)*(s%i);return{mode:t,up:e>0?l:0,down:e<0?l:0,remainder:d}}function DM(t,e=null){const n=[],i=e&&Number.isFinite(e.col)?e.col:1,s=e&&Number.isFinite(e.row)?e.row:1,a=d=>Math.min(a1,Number.isFinite(d)?Math.max(0,Math.floor(d)):0),l=d=>t.mode==="mouse"?{kind:"input",seq:AM(d,i,s)}:t.mode==="page"?{kind:"input",seq:d==="up"?NM:LM}:{kind:"action",name:d==="up"?"scroll-up":"scroll-down"};for(let d=0;d<a(t.up);d+=1)n.push(l("up"));for(let d=0;d<a(t.down);d+=1)n.push(l("down"));return n}function $m({session:t,node:e,token:n,readonly:i,takeSize:s,focused:a,sendRef:l,composerRef:d,actionRef:h,ctrlRef:f,setCtrlArmed:g,onFiles:y,fontSize:_=13,selectionMode:w=!1,onSelectionModeChange:b,keyboardGesture:N="double-tap",onRendererChange:x}){const E=k.useRef(null),C=k.useRef(null),I=k.useRef(null),T=k.useRef(_);T.current=_;const W=k.useRef(a);W.current=a;const U=k.useRef(w);U.current=w;const Q=k.useRef(N);Q.current=N;const[ee,q]=k.useState(""),[J,$]=k.useState(""),[M,L]=k.useState(null),[j,O]=k.useState(null),[P,A]=k.useState(!1),[R,D]=k.useState(null),H=k.useRef(null),[z,F]=k.useState(null),[K,ne]=k.useState(0),[re,Y]=k.useState(null),[de,oe]=k.useState("start"),[pe,xe]=k.useState(null),[Qe,ot]=k.useState(!1),[De,je]=k.useState(null),[tt,Nt]=k.useState(null),Ct=k.useRef(null),ft=k.useRef(null),[ht,kt]=k.useState(!1),St=async()=>{var gt,le,ae,ge;const V=((le=(gt=C.current)==null?void 0:gt.term)==null?void 0:le.getSelection())||ee;if(!V){$(m("copy-empty")),setTimeout(()=>$(""),1500);return}const Te=await qp(V);$(m(Te?"copied":"copy-manual")),Te&&((ge=(ae=C.current)==null?void 0:ae.term)==null||ge.clearSelection(),q(""),A(!1),b==null||b(!1)),setTimeout(()=>$(""),1800)},Ut=k.useRef(St);Ut.current=St;const Mt=k.useRef({startHandleDrag:()=>{}}),It=k.useRef(null);It.current=z,k.useEffect(()=>{const V=E.current;V&&(V.dataset.selectionOrigin=tt||"")},[tt]),k.useEffect(()=>{const V=C.current;V&&V.sock&&V.sock.focus&&V.sock.focus(!!a)},[a]),k.useEffect(()=>{const V=C.current;V&&(V.term.options.fontSize=_,V.fit.fit(),V.sock.resize(V.term.cols,V.term.rows))},[_]),k.useEffect(()=>{var V,Te;(Te=(V=C.current)==null?void 0:V.setKeyboardGesture)==null||Te.call(V,N)},[N]),k.useEffect(()=>{var Ci,Xi,as,er,ki,ql,ba;const V=new rL({cursorBlink:!0,fontSize:T.current,scrollback:1e3,allowProposedApi:!0,theme:{background:"#0a0e0a"}}),Te=new lL;V.loadAddon(Te),V.open(E.current),Te.fit(),pL(V);const gt=JR(V,{preference:Sl(),createAddon:()=>new GR,onFallback:()=>{x&&x("dom")}});I.current=gt,x&&x(gt.kind);let le=!1,ae=!1;const ge=ce=>Pe=>{for(const Re of Pe){const $e=Array.isArray(Re)?Re[0]:Re;$e===1006&&(le=ce),$e===1016&&(ae=ce)}return!1};(Xi=(Ci=V.parser)==null?void 0:Ci.registerCsiHandler)==null||Xi.call(Ci,{prefix:"?",final:"h"},ge(!0)),(er=(as=V.parser)==null?void 0:as.registerCsiHandler)==null||er.call(as,{prefix:"?",final:"l"},ge(!1)),(ql=(ki=V.parser)==null?void 0:ki.registerEscHandler)==null||ql.call(ki,{final:"c"},()=>(le=!1,ae=!1,!1));const Ce=()=>{const ce=le&&!ae&&(V.modes&&V.modes.mouseTrackingMode||"none")!=="none",Pe=E.current;return Pe&&(Pe.dataset.mouseTracking=ce?"on":"off"),ce},Me=new TextDecoder;let nt=Q.current==="single-tap",ct=null;const pt=()=>{nt=Q.current==="single-tap",o1(V,Q.current,nt)},Lt=ce=>{Q.current=ce,ct=null,pt()},Dt=()=>Q.current==="never"?!1:(nt=!0,CM(V));pt();const Et=V.textarea,Bt=()=>{Q.current==="double-tap"&&pt()};Et==null||Et.addEventListener("blur",Bt);let Z;try{Z=eM({session:t,node:e,token:n,readonly:i,takeSize:s,focused:W.current,onFiles:y,cols:V.cols,rows:V.rows,onData:ce=>V.write(Me.decode(ce)),onExit:()=>V.write(`\r
152
- \x1B[33m[sessione finita]\x1B[0m\r
153
- `)})}catch(ce){return V.write(`\r
154
- \x1B[31m${ce.message}\x1B[0m\r
155
- `),()=>{var Pe,Re;try{(Re=(Pe=I.current)==null?void 0:Pe.dispose)==null||Re.call(Pe)}catch{}I.current=null,V.dispose()}}C.current={term:V,fit:Te,sock:Z,setKeyboardGesture:Lt};let ye=null;const Ue=V.onData(ce=>{if(i){ye&&(ye.ok=!1);return}if(!ye&&f&&f.current&&ce.length===1){const Re=ce.charCodeAt(0);let $e=Re;Re>=97&&Re<=122?$e=Re-96:Re>=64&&Re<=95?$e=Re-64:Re===32&&($e=0),ce=String.fromCharCode($e),f.current=!1,g&&g(!1)}const Pe=Z.sendInput(ce);ye&&(ye.seen=!0,ye.ok=ye.ok&&Pe)});l&&(l.current=ce=>Z.sendInput(ce)),h&&(h.current=ce=>Z.action(ce)),d&&(d.current=iM({isReady:()=>!i&&Z.isReady(),paste:ce=>{const Pe={seen:!1,ok:!0};ye=Pe;try{V.paste(ce)}catch{Pe.ok=!1}finally{ye=null}return Pe.seen&&Pe.ok},send:ce=>Z.sendInput(ce)}));const We=ce=>{Ct.current=ce,Nt(ce)};let Ge=null;const jt=V.onSelectionChange(()=>{const ce=V.getSelection();ce?(q(ce),A(!1)):A(!0);const Pe=uM(V.getSelectionPosition(),V.cols),Re=Pe?Mw(Pe.start,Pe.end,V.cols):null;D(Re),H.current=Re,Re||We(null),!Re&&Ge&&vo();let $e=null;if(Re&&typeof V.buffer.active.getLine=="function"){const rt=[];for(let ut=Re.start.row;ut<=Re.end.row;ut++){const Rt=V.buffer.active.getLine(ut);rt.push(Rt?Rt.translateToString():"")}$e={startRow:Re.start.row,endRow:Re.end.row,lines:rt}}ft.current=$e,kt(!1)}),Pt=V.onRender(ce=>{var Pe;if((Pe=V.hasSelection)!=null&&Pe.call(V)){const Re=ft.current,$e=ce&&ce.start,rt=ce&&ce.end;if(Re&&Number.isInteger($e)&&Number.isInteger(rt)&&typeof V.buffer.active.getLine=="function"){const ut=Number(V.buffer.active.viewportY)||0,Rt=Math.max(ut+$e,Re.startRow),Ht=Math.min(ut+rt,Re.endRow);for(let vn=Rt;vn<=Ht;vn++){const Jt=V.buffer.active.getLine(vn);if((Jt?Jt.translateToString():"")!==Re.lines[vn-Re.startRow]){kt(!0);break}}}ne(ut=>ut+1)}}),X=V.onScroll(()=>{var ce;(ce=V.hasSelection)!=null&&ce.call(V)&&ne(Pe=>Pe+1)});V.attachCustomKeyEventHandler(ce=>(ce.ctrlKey||ce.metaKey)&&ce.key.toLowerCase()==="c"&&V.getSelection()?(ce.type==="keydown"&&qp(V.getSelection()),!1):!0);const ie=E.current;let _e=!1;const Ke=async ce=>{if(!ce.length||_e)return;if(i){L({error:m("settings-readonly")});return}_e=!0,L({current:0,total:ce.length,name:""});const Pe=await Vp({files:ce,token:n,session:t,node:e,paste:!0,onProgress:({index:Re,total:$e,name:rt,state:ut,error:Rt})=>L({current:Re+1,total:$e,name:rt,...ut==="error"?{error:Rt}:{}})});_e=!1,Pe.errors.length?L({error:Pe.errors.map(Re=>`${Re.name}: ${Re.message}`).join(" · ")}):(L({done:!0,total:Pe.paths.length}),setTimeout(()=>L(null),1600))},Ie=ce=>{const Pe=ce.clipboardData;if(!df(Pe))return;const Re=Tw(Pe);Re.length&&(ce.preventDefault(),ce.stopPropagation(),Ke(Re))},Ee=ce=>{df(ce.dataTransfer)&&(ce.preventDefault(),ce.stopPropagation())},et=ce=>{df(ce.dataTransfer)&&(ce.preventDefault(),ce.stopPropagation(),Ke(Tw(ce.dataTransfer)))};ie.addEventListener("paste",Ie,!0),ie.addEventListener("dragenter",Ee,!0),ie.addEventListener("dragover",Ee,!0),ie.addEventListener("drop",et,!0);const Ot=24,gn=(ce,Pe)=>{const $e=(ie.querySelector(".xterm-screen")||ie).getBoundingClientRect(),rt=Math.floor((ce-$e.left)/Math.max(1,$e.width)*V.cols)+1,ut=Math.floor((Pe-$e.top)/Math.max(1,$e.height)*V.rows)+1;return{col:Math.max(1,Math.min(V.cols,rt)),row:Math.max(1,Math.min(V.rows,ut))}},Fe=(ce,Pe={mode:null,remainder:0},Re=null,$e=null)=>{const rt=E.current,ut=rt?rt.getBoundingClientRect().height:Ot,Rt=jM({alternateScreen:V.buffer.active.type==="alternate",readonly:i,mouseTracking:Ce()}),Ht=Rt==="mouse"?"mouse":Re||Rt,vn=Pe.mode===Ht?Pe.remainder+ce:ce,Jt=TM({mode:Ht,accumulated:vn,threshold:Ht==="page"?ut:Ot});for(const pi of DM(Jt,$e))pi.kind==="input"?Z.sendInput(pi.seq):Z.action(pi.name);return{mode:Ht,remainder:Jt.remainder}};let Be=null,vt=null,Mn=null,me=null,Se=!1,Ae=!1,it={mode:null,remainder:0},st=null,wt=null,cn=null,$t=!1;const Wt=750;let Xs=0;const Di=()=>{cn&&clearTimeout(cn),cn=null},Gi=(ce,Pe)=>{const $e=(ie.querySelector(".xterm-screen")||ie).getBoundingClientRect(),rt=Math.max(0,Math.min(V.cols-1,Math.floor((ce-$e.left)/Math.max(1,$e.width)*V.cols))),ut=Math.max(0,Math.min(V.rows-1,Math.floor((Pe-$e.top)/Math.max(1,$e.height)*V.rows)));return{col:rt,row:V.buffer.active.viewportY+ut}},go=()=>{const Re=(ie.querySelector(".xterm-screen")||ie).getBoundingClientRect().height/Math.max(1,V.rows),$e=ie.querySelector(".nc-sel-handle"),rt=$e?$e.getBoundingClientRect().height:0;return-.3*(rt>0?rt:Re)},id=(ce,Pe)=>Gi(ce.clientX,ce.clientY+Pe),jr=ce=>{const Re=(ie.querySelector(".xterm-screen")||ie).getBoundingClientRect(),$e=ie.getBoundingClientRect(),rt=Re.width/Math.max(1,V.cols),ut=Re.height/Math.max(1,V.rows),Rt=Number(V.buffer.active.viewportY)||0,Ht=Math.max(0,Math.min(V.rows-1,ce.row-Rt));O({left:`${Re.left-$e.left+ce.col*rt}px`,top:`${Re.top-$e.top+Ht*ut}px`,width:`${rt}px`,height:`${ut}px`})},Pr=ce=>{if(Xs=Date.now(),We("touch"),Di(),$t=!1,Se=!1,Ae||ce.touches.length!==1){Ae=!0,Se=!0,ct=null,O(null),Be=null,vt=null,Mn=null,me=null;return}if(U.current){ce.preventDefault(),ce.stopPropagation();const Re=Gi(ce.touches[0].clientX,ce.touches[0].clientY),$e=V.buffer.active.getLine(Re.row),rt=Ko({line:$e,col:Re.col,side:"start",cols:V.cols}),ut=Aw({line:$e,col:rt,cols:V.cols});wt={row:Re.row,col:ut.start};const Rt={row:Re.row,col:ut.end};V.clearSelection(),We("touch"),ot(!0),oe("end"),V.select(ut.start,Re.row,ut.end-ut.start+1),jr(Rt);return}Be=ce.touches[0].clientY,vt=ce.touches[0].clientX,Mn=vt,me=Be,it={mode:null,remainder:0},st=null;const Pe={x:vt,y:Be};cn=setTimeout(()=>{var Ht;cn=null,$t=!0,Se=!0,ct=null,U.current=!0,b==null||b(!0);const Re=Gi(Pe.x,Pe.y),$e=V.buffer.active.getLine(Re.row),rt=Ko({line:$e,col:Re.col,side:"start",cols:V.cols}),ut=Aw({line:$e,col:rt,cols:V.cols});wt={row:Re.row,col:ut.start};const Rt={row:Re.row,col:ut.end};V.clearSelection(),We("touch"),ot(!0),oe("end"),V.select(ut.start,Re.row,ut.end-ut.start+1),jr(Rt);try{(Ht=navigator.vibrate)==null||Ht.call(navigator,10)}catch{}Be=null,vt=null,st=null,it={mode:null,remainder:0}},aM)},xi=ce=>{if($t&&wt&&ce.touches.length===1){ce.preventDefault(),ce.stopPropagation();const $e=Gi(ce.touches[0].clientX,ce.touches[0].clientY),rt=wt.row*V.cols+wt.col,ut=$e.row*V.cols+$e.col,Rt=rt<=ut?"end":"start",Ht=V.buffer.active.getLine($e.row),vn=Ko({line:Ht,col:$e.col,side:Rt,cols:V.cols}),Jt={row:$e.row,col:vn},pi=Jt.row*V.cols+Jt.col,ls=rt<=pi?wt:Jt;oe(Rt),V.select(ls.col,ls.row,Math.abs(pi-rt)+1),jr(Jt);return}if(U.current&&wt&&ce.touches.length===1){ce.preventDefault(),ce.stopPropagation();const $e=Gi(ce.touches[0].clientX,ce.touches[0].clientY),rt=wt.row*V.cols+wt.col,ut=$e.row*V.cols+$e.col,Rt=rt<=ut?"end":"start",Ht=V.buffer.active.getLine($e.row),vn=Ko({line:Ht,col:$e.col,side:Rt,cols:V.cols}),Jt={row:$e.row,col:vn},pi=Jt.row*V.cols+Jt.col,ls=rt<=pi?wt:Jt;oe(Rt),V.select(ls.col,ls.row,Math.abs(pi-rt)+1),jr(Jt);return}if(Be===null||ce.touches.length!==1)return;ce.preventDefault(),ce.stopPropagation();const Pe=ce.touches[0];if(Rw(Mn,me,Pe.clientX,Pe.clientY)&&(Se=!0,ct=null,cn&&Di()),st===null&&(Math.abs(Pe.clientY-Be)>8||Math.abs(Pe.clientX-vt)>8)&&(st=Math.abs(Pe.clientY-Be)>Math.abs(Pe.clientX-vt)),!st)return;const Re=Pe.clientY-Be;Be=Pe.clientY,it=Fe(Re,it,"scroll",gn(Pe.clientX,Pe.clientY))},va=()=>{Di(),Be=null,vt=null,Mn=null,me=null,wt=null,$t=!1,Se=!1,Ae=!1,O(null),ot(!1),it={mode:null,remainder:0},Xs=Date.now()},di=ce=>{if(Ae){ct=null,Di(),(!ce.touches||ce.touches.length===0)&&va();return}const Pe=ce.changedTouches&&ce.changedTouches[0];if(!Se&&!$t&&!U.current&&Pe){const Re={at:Date.now(),x:Pe.clientX,y:Pe.clientY},$e=kM(Q.current,ct,Re);ct=$e.next,$e.open&&Dt()}va()},zl=()=>{ct=null,va()};let Fl={mode:null,remainder:0};const Hl=ce=>{ce.preventDefault(),ce.stopPropagation(),Fl=Fe(-ce.deltaY,Fl,"scroll",gn(ce.clientX,ce.clientY))};ie.addEventListener("touchstart",Pr,{passive:!1}),ie.addEventListener("touchmove",xi,{passive:!1,capture:!0}),ie.addEventListener("touchend",di,{passive:!0}),ie.addEventListener("touchcancel",zl,{passive:!0});const Tr=()=>{typeof window.matchMedia=="function"&&window.matchMedia(Kp).matches||!U.current&&Q.current==="double-tap"&&Dt()};ie.addEventListener("dblclick",Tr);const Dr=ce=>{(U.current||$t)&&(ce.preventDefault(),ce.stopPropagation())};ie.addEventListener("contextmenu",Dr,!0),ie.addEventListener("wheel",Hl,{passive:!1,capture:!0});let Gn=null;const Ir=ce=>{Date.now()-Xs>=Wt&&We("mouse"),sM(ce)&&(ce.preventDefault(),ce.stopPropagation(),Gn={cell:Gi(ce.clientX,ce.clientY),clientX:ce.clientX,clientY:ce.clientY,extendFrom:H.current,dragged:!1})},Ul=ce=>{var Rt;if(!Gn){(Rt=V.hasSelection)!=null&&Rt.call(V)&&Ce()&&(ce.preventDefault(),ce.stopPropagation());return}if(ce.preventDefault(),ce.stopPropagation(),!Gn.dragged&&!Rw(Gn.clientX,Gn.clientY,ce.clientX,ce.clientY))return;Gn.dragged=!0;const Pe=Gn.cell,Re=Gi(ce.clientX,ce.clientY),$e=Pe.row*V.cols+Pe.col,rt=Re.row*V.cols+Re.col,ut=$e<=rt?Pe:Re;V.select(ut.col,ut.row,Math.abs(rt-$e)+1)},Wl=ce=>{if(!Gn)return;ce.stopPropagation();const{cell:Pe,extendFrom:Re,dragged:$e}=Gn;if(Gn=null,$e||!Re)return;const rt=lM({range:Re,cell:Pe,cols:V.cols});if(!rt.moved)return;const ut=rt[rt.moved],Rt=V.buffer.active.getLine(ut.row);ut.col=Ko({line:Rt,col:ut.col,side:rt.moved,cols:V.cols});const Ht=jw({start:rt.start,end:rt.end},V.cols);V.select(Ht.col,Ht.row,Ht.length)};ie.addEventListener("mousedown",Ir,!0),ie.addEventListener("mousemove",Ul,!0),ie.addEventListener("mouseup",Wl,!0);let Qs=null,os={x:0,y:0,type:"touch"};const Js=()=>{Qs&&(clearInterval(Qs),Qs=null)},Zs=(ce,Pe,Re)=>{if(!Ge||!Ge.fixed)return;const $e=Ge.fixed,rt=Re==="mouse"?Gi(ce,Pe):id({clientX:ce,clientY:Pe},go()),ut=V.buffer.active.getLine(rt.row),Rt={row:rt.row,col:Ko({line:ut,col:rt.col,side:Ge.which,cols:V.cols})},Ht=Math.max(0,Number(V.buffer.active.baseY||0)+V.rows-1),vn=dM({moving:Rt,fixed:$e,which:Ge.which,cols:V.cols,maxRow:Ht}),Jt=jw(Mw(vn,$e,V.cols),V.cols);V.select(Jt.col,Jt.row,Jt.length);const pi=Number(V.buffer.active.viewportY)||0,ls=gM({visibleRow:vn.row-pi,rows:V.rows});Js(),!(ls===0||V.buffer.active.type==="alternate")&&(Qs=setInterval(()=>{const Sa=Number(V.buffer.active.viewportY)||0;if(V.scrollLines(ls),(Number(V.buffer.active.viewportY)||0)===Sa){Js();return}Zs(os.x-Ge.offsetX,os.y-Ge.offsetY,os.type)},130))},_a=ce=>{Ge&&(ce.preventDefault(),os={x:ce.clientX,y:ce.clientY,type:ce.pointerType||os.type},Zs(ce.clientX-Ge.offsetX,ce.clientY-Ge.offsetY,os.type))},vo=()=>{Ge=null,Js(),Y(null),window.removeEventListener("pointermove",_a),window.removeEventListener("pointerup",xt),window.removeEventListener("pointercancel",xt)},xt=()=>vo();Mt.current={startHandleDrag:(ce,Pe)=>{if(!V.getSelectionPosition())return;Pe.preventDefault(),Pe.stopPropagation();const Re=It.current&&It.current[ce],$e=ie.getBoundingClientRect();Ge={which:ce,offsetX:Re?Pe.clientX-($e.left+Re.left):0,offsetY:Re?Pe.clientY-($e.top+Re.top):0,fixed:H.current?ce==="start"?H.current.end:H.current.start:null},os={x:Pe.clientX,y:Pe.clientY,type:Pe.pointerType||"touch"},Y(ce),oe(ce),window.addEventListener("pointermove",_a),window.addEventListener("pointerup",xt),window.addEventListener("pointercancel",xt)}};const ya=ce=>{!rM(ce)||!(C.current&&C.current.term&&C.current.term.getSelection())||(ce.preventDefault(),ce.stopPropagation(),Ut.current&&Ut.current())};ie.addEventListener("keydown",ya,!0);const Ls=()=>{Te.fit(),Z.resize(V.cols,V.rows)};window.addEventListener("resize",Ls);const hi=window.visualViewport;let _o=hi&&Number(hi.height);const wa=()=>{const ce=hi&&Number(hi.height);nt&&Q.current==="double-tap"&&Number.isFinite(_o)&&Number.isFinite(ce)&&ce>_o+80&&pt(),_o=ce,Ls()};hi&&(hi.addEventListener("resize",wa),hi.addEventListener("scroll",Ls));const Xn=typeof navigator<"u"?navigator.virtualKeyboard:null,yo=()=>{var ce;nt&&Q.current==="double-tap"&&Number(((ce=Xn==null?void 0:Xn.boundingRect)==null?void 0:ce.height)||0)===0&&pt()};(ba=Xn==null?void 0:Xn.addEventListener)==null||ba.call(Xn,"geometrychange",yo);let Rs=null,fi=0;return typeof ResizeObserver<"u"&&(Rs=new ResizeObserver(()=>{fi&&cancelAnimationFrame(fi),fi=requestAnimationFrame(Ls)}),Rs.observe(ie)),()=>{var ce;C.current=null,l&&(l.current=()=>!1),d&&(d.current=()=>!1),h&&(h.current=()=>!1),Ue.dispose(),jt.dispose(),Pt.dispose(),X.dispose(),Js(),window.removeEventListener("pointermove",_a),window.removeEventListener("pointerup",xt),window.removeEventListener("pointercancel",xt),Mt.current={startHandleDrag:()=>{}},ie.removeEventListener("touchstart",Pr),ie.removeEventListener("touchmove",xi,{capture:!0}),ie.removeEventListener("touchend",di),ie.removeEventListener("touchcancel",zl),ie.removeEventListener("dblclick",Tr),ie.removeEventListener("contextmenu",Dr,!0),Di(),ie.removeEventListener("wheel",Hl,{capture:!0}),ie.removeEventListener("mousedown",Ir,!0),ie.removeEventListener("mousemove",Ul,!0),ie.removeEventListener("mouseup",Wl,!0),ie.removeEventListener("keydown",ya,!0),ie.removeEventListener("paste",Ie,!0),ie.removeEventListener("dragenter",Ee,!0),ie.removeEventListener("dragover",Ee,!0),ie.removeEventListener("drop",et,!0),window.removeEventListener("resize",Ls),hi&&(hi.removeEventListener("resize",wa),hi.removeEventListener("scroll",Ls)),(ce=Xn==null?void 0:Xn.removeEventListener)==null||ce.call(Xn,"geometrychange",yo),Et==null||Et.removeEventListener("blur",Bt),Rs&&Rs.disconnect(),fi&&cancelAnimationFrame(fi),Z.close(),V.dispose()}},[t,e,n,i,s,l,d,h,f,g,y]),k.useEffect(()=>{const V=E.current,Te=C.current?C.current.term:null;if(!V||!Te||!R){F(null),xe(null),je(null);return}const le=(V.querySelector(".xterm-screen")||V).getBoundingClientRect(),ae=V.getBoundingClientRect(),ge=le.width/Math.max(1,Te.cols),Ce=le.height/Math.max(1,Te.rows),Me=mM({range:R,viewportY:Number(Te.buffer.active.viewportY)||0,rows:Te.rows,cols:Te.cols,cellWidth:ge,cellHeight:Ce,screenLeft:le.left-ae.left,screenTop:le.top-ae.top});F(Me);let nt=null;const ct=R[de==="end"?"end":"start"].row;typeof Te.buffer.active.getLine=="function"&&(nt=Te.buffer.active.getLine(Number(ct)));const pt=Math.max(16,Math.round(Ce*2)),Lt=nt?{...vM({range:R,side:de,line:nt,cols:Te.cols}),fontSize:pt}:null;xe(Lt);const Dt=re!==null||Qe,Et=Me[de==="end"?"end":"start"];if(!Dt||!Lt||!Et||!Et.visible){je(null);return}const Bt=(Lt.before+Lt.sel+Lt.after).length,Z=ge*(pt/Math.max(1,Ce)),ye=Math.min(ae.width-8,Math.round(Bt*Z)+16),Ue=Math.round(pt*1.25)+12;je(fM({anchorLeft:Et.left,anchorTop:Et.top,hostWidth:ae.width,hostHeight:ae.height,bubbleWidth:ye,bubbleHeight:Ue}))},[R,K,de,re,Qe]);const tn=cM(tt),Ft=k.useRef({}),ln=(V,Te)=>{if(re!==V)return Ft.current[V]={flip:Te,ts:0},Te;const gt=Ft.current[V]||{flip:Te,ts:0};if(gt.flip===Te)return Ft.current[V]=gt,Te;const le=Date.now();return le-gt.ts<pM?gt.flip:(Ft.current[V]={flip:Te,ts:le},Te)};return c.jsxs("div",{className:`nc-terminal${w?" selecting":""}`,children:[c.jsx("div",{className:"nc-terminal-host",ref:E}),j&&c.jsx("div",{className:"nc-touch-selection-caret",style:j,"aria-hidden":"true"}),R&&z&&tn.handles&&["start","end"].map(V=>z[V].visible&&c.jsx("div",{className:`nc-sel-handle ${V}${re===V?" dragging":""}${ln(V,z[V].flip)?" flip":""}${hM({startLeft:z.start.left,endLeft:z.end.left})?" tight":""}`,style:{left:`${z[V].left}px`,top:`${z[V].top}px`},onPointerDown:Te=>Mt.current.startHandleDrag(V,Te),"aria-hidden":"true"},`nc-sel-handle-${V}`)),R&&pe&&tn.magnifier&&De&&c.jsx("div",{className:`nc-zoom-bubble${De.flipped?" flipped":""}`,style:{left:`${De.left}px`,top:`${De.top}px`},"aria-hidden":"true",children:c.jsxs("pre",{className:"nc-zoom-line",style:{fontSize:`${pe.fontSize}px`},children:[c.jsx("span",{children:pe.before}),c.jsx("span",{className:"nc-zoom-sel",children:pe.sel}),c.jsx("span",{children:pe.after})]})}),M&&c.jsx("div",{className:`nc-upload-state${M.error?" error":""}`,role:"status",children:M.error?M.error:M.done?m("attach-uploaded").replace("{n}",String(M.total||0)):m("attach-upload-progress").replace("{n}",String(M.current||0)).replace("{total}",String(M.total||0))}),(ee||w)&&c.jsxs("div",{className:"nc-selection-tools",children:[ee?c.jsx("button",{type:"button",onClick:St,children:J||`${m("copy")} · ${oM(typeof navigator<"u"?navigator.userAgent:"")}`}):c.jsx("span",{children:m("select-drag")}),ee&&P&&c.jsx("span",{className:"nc-selection-held",children:m("selection-held")}),ee&&!P&&ht&&c.jsx("span",{className:"nc-selection-changed",children:m("selection-changed")}),c.jsx("button",{type:"button",onClick:()=>{var V,Te;(Te=(V=C.current)==null?void 0:V.term)==null||Te.clearSelection(),q(""),A(!1),b==null||b(!1)},children:m("cancel")}),J===m("copy-manual")&&c.jsx("textarea",{readOnly:!0,value:ee,onFocus:V=>V.target.select()})]})]})}const Iw="",Kt="\x1B",IM=[{label:"↑",seq:Kt+"[A"},{label:"↓",seq:Kt+"[B"},{label:"PGUP",seq:Kt+"[5~"},{label:"PGDN",seq:Kt+"[6~"}],BM=new Set([Kt+"[A",Kt+"[B",Kt+"[C",Kt+"[D",Kt+"[5~",Kt+"[6~"]),OM=350,$M=55;function zM({send:t,action:e,ctrlArmed:n=!1,onCtrl:i,onKeyboard:s,selectionMode:a=!1,onSelectionMode:l,onCellSwitcher:d,cellSwitcherOpen:h=!1,keepKeyboardClosed:f=!0,showEnter:g=!0,keybarLayout:y="full"}){const[_,w]=k.useState(!1),[b,N]=k.useState(!1),[x,E]=k.useState(!1),[C,I]=k.useState(!1),T=y==="compact"&&!C,W=k.useRef({delay:null,interval:null}),U=k.useRef(()=>{}),Q=()=>{const D=W.current;D.delay!==null&&clearTimeout(D.delay),D.interval!==null&&clearInterval(D.interval),D.delay=null,D.interval=null};U.current=Q,k.useEffect(()=>{const D=()=>{document.visibilityState==="hidden"&&U.current()},H=()=>U.current();return window.addEventListener("blur",H),document.addEventListener("visibilitychange",D),()=>{window.removeEventListener("blur",H),document.removeEventListener("visibilitychange",D),U.current()}},[]),k.useEffect(()=>{y!=="compact"&&I(!1)},[y]);const ee=D=>{x?(t(Kt+D),E(!1)):t(D)},q=D=>{f&&Yp(),D()},J=D=>({onPointerDown:H=>{H.preventDefault(),q(D)},onClick:H=>{H.detail===0&&q(D)}}),$=D=>({onPointerDown:H=>{H.preventDefault(),Q(),q(D),!x&&(W.current.delay=setTimeout(()=>{W.current.delay=null,D(),W.current.interval=setInterval(D,$M)},OM))},onPointerUp:Q,onPointerLeave:Q,onPointerCancel:Q,onLostPointerCapture:Q,onTouchCancel:Q,onClick:H=>{H.detail===0&&q(D)}}),M=(D,H,z)=>c.jsx("button",{type:"button",...BM.has(H)&&!z?$(()=>ee(H)):J(()=>{ee(H),z&&z()}),children:D},D),L=(D,H)=>c.jsx("button",{type:"button",...J(()=>{e(H),N(!1)}),children:D},D),j=d?c.jsx("button",{type:"button","aria-label":m("fleet-cells"),title:m("fleet-cells"),"aria-expanded":h,...J(d),children:"◫"},"cells"):c.jsx("button",{type:"button",...J(()=>{s&&s()}),children:"⌨"},"kbd"),O=g&&c.jsx("button",{type:"button",className:"nc-enter-key","aria-label":"ENTER",title:"ENTER",...J(()=>ee("\r")),children:c.jsx(dt,{name:"enter",size:24})}),P=b&&c.jsxs("div",{className:"nc-keymenu",children:[L("←WIN","prev-window"),L("WIN→","next-window"),L("⬅PANE","pane-left"),L("PANE➡","pane-right"),M("SCROLL",Iw+"[",()=>{w(!0),N(!1)}),c.jsx("button",{type:"button",className:a?"armed":"",...J(()=>{l==null||l(!a),N(!1)}),children:"SELECT"}),M("⌃C","",()=>N(!1)),M("DETACH",Iw+"d",()=>N(!1))]});if(_)return c.jsxs("div",{className:"nc-keybar copy",children:[c.jsx("span",{className:"tag",children:"copy-mode"}),IM.map(D=>M(D.label,D.seq)),M("ESCI (q)","q",()=>w(!1))]});if(T)return c.jsxs("div",{className:"nc-keybar termux",children:[P,c.jsxs("div",{className:`nc-keygrid compact${g?"":" no-enter"}`,children:[c.jsx("div",{className:"nc-keyrows",children:c.jsxs("div",{className:"row",children:[c.jsx("button",{type:"button","aria-label":m("keybar-expand"),title:m("expand"),...J(()=>I(!0)),children:c.jsx(dt,{name:"chevronUp",size:20})},"expand"),j,c.jsx("button",{type:"button",className:b?"armed":"",...J(()=>N(D=>!D)),children:"☰"},"menu"),M("↑",Kt+"[A"),M("↓",Kt+"[B"),M("←",Kt+"[D"),M("→",Kt+"[C"),M("PGUP",Kt+"[5~"),M("PGDN",Kt+"[6~")]})}),O]})]});const A=y==="compact"&&C,R=A&&c.jsx("button",{type:"button",className:"nc-retract-key","aria-label":m("keybar-retract"),title:m("retract"),...J(()=>I(!1)),children:c.jsx(dt,{name:"chevronDown",size:20})});return c.jsxs("div",{className:`nc-keybar termux${A?" expanded":""}`,children:[P,c.jsxs("div",{className:`nc-keygrid${g?"":" no-enter"}${A?" expanded":""}`,children:[R,c.jsxs("div",{className:"nc-keyrows",children:[c.jsxs("div",{className:"row",children:[M("ESC",Kt),c.jsx("button",{type:"button",className:b?"armed":"",...J(()=>N(D=>!D)),children:"☰"},"menu"),M("/","/"),M("—","-"),M("HOME",Kt+"[H"),M("↑",Kt+"[A"),M("END",Kt+"[F"),M("PGUP",Kt+"[5~")]}),c.jsxs("div",{className:"row",children:[M("⇥"," "),j,c.jsx("button",{type:"button",className:n?"armed":"",...J(()=>{i&&i()}),children:"CTRL"},"ctrl"),c.jsx("button",{type:"button",className:x?"armed":"",...J(()=>E(D=>!D)),children:"ALT"},"alt"),M("←",Kt+"[D"),M("↓",Kt+"[B"),M("→",Kt+"[C"),M("PGDN",Kt+"[6~")]})]}),O]})]})}const FM=t=>t>1048576?`${(t/1048576).toFixed(1)}M`:t>1024?`${(t/1024).toFixed(0)}K`:`${t}B`;function l1({session:t,node:e,token:n,filesEvent:i,onClose:s}){li();const a=e?`/api/route/${String(e).split("/").map(encodeURIComponent).join("/")}/_`:"/api",l=e?`${e}:${t}`:t,[d,h]=k.useState("outbox"),[f,g]=k.useState({inbox:[],outbox:[]}),[y,_]=k.useState(""),w=k.useRef(null);async function b(){try{const I=await(await pn(`${a}/files?session=${encodeURIComponent(t)}`,n)).json();if(I.error){_(I.error);return}g(I);const T=I.outbox[0]?I.outbox[0].mtime:0;localStorage.setItem(s0(l),String(T))}catch(C){_(String(C))}}k.useEffect(()=>{b()},[t,e]),k.useEffect(()=>{i&&i.session===t&&b()},[i]);async function N(C){for(const I of C){_(`carico ${I.name}…`);const T=new FormData;T.append("session",t),T.append("file",I);try{const U=await(await pn(`${a}/files/upload`,n,{method:"POST",body:T})).json();_(U.error?`errore: ${U.error}`:"")}catch(W){_(String(W))}}b()}async function x(C){const I=await pn(`${a}/files/download?session=${encodeURIComponent(t)}&box=${d}&name=${encodeURIComponent(C)}`,n);if(!I.ok){const Q=await I.json().catch(()=>({}));_(Q.error?`errore: ${Q.error}`:"errore download");return}const T=await I.blob(),W=URL.createObjectURL(T),U=document.createElement("a");U.href=W,U.download=C,U.click(),URL.revokeObjectURL(W)}async function E(C){const I=await pn(`${a}/files?session=${encodeURIComponent(t)}&box=${d}&name=${encodeURIComponent(C)}`,n,{method:"DELETE"});if(!I.ok){const T=await I.json().catch(()=>({}));_(T.error?`errore: ${T.error}`:"errore delete");return}b()}return c.jsxs("div",{className:"nc-files",children:[c.jsxs("header",{children:[c.jsx("b",{children:e?`${e}:${t}`:t}),c.jsx("button",{onClick:s,title:m("close"),children:c.jsx(dt,{name:"x",size:20})})]}),c.jsxs("nav",{children:[c.jsx("button",{className:d==="outbox"?"on":"",onClick:()=>h("outbox"),children:"outbox"}),c.jsx("button",{className:d==="inbox"?"on":"",onClick:()=>h("inbox"),children:"inbox"}),c.jsxs("button",{className:"up",onClick:()=>w.current&&w.current.click(),children:[c.jsx(dt,{name:"upload",size:18})," ",m("upload")]}),c.jsx("input",{type:"file",multiple:!0,ref:w,style:{display:"none"},onChange:C=>{N(Array.from(C.target.files||[])),C.target.value=""}})]}),y&&c.jsx("div",{className:"nc-busy",children:y}),c.jsxs("ul",{children:[f[d].map(C=>c.jsxs("li",{children:[c.jsx("span",{className:"name",onClick:()=>x(C.name),children:C.name}),c.jsx("small",{children:FM(C.size)}),c.jsx("button",{onClick:()=>E(C.name),title:m("delete"),children:c.jsx(dt,{name:"trash",size:18})})]},C.name)),f[d].length===0&&c.jsx("li",{className:"empty",children:m("empty-files")})]})]})}const Qu="nc_composer_v1",Gp="nc-composer-reset",HM=50,c1=256*1024,u1=512*1024,UM=768*1024,Bw=2*1024*1024,d1=720*60*60*1e3,Xp=1;function h1(t){const e=Number(t);return Number.isFinite(e)&&e>0?e:0}function zm(t){if(t!==void 0)return t;try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function Bu(){return{version:Xp,cells:{}}}function f1(t){const e=[];for(const i of Array.isArray(t)?t:[]){const s=typeof i=="string"?i:i&&i.text,a=h1(typeof i=="string"?0:i&&i.at);if(!(typeof s!="string"||!s||s.length>c1)&&!(e.length&&e[e.length-1].text===s)&&(e.push({text:s,at:a}),e.length>=HM))break}let n=0;return e.filter(i=>n+i.text.length>UM?!1:(n+=i.text.length,!0))}function Ou(t){if(!t||typeof t!="object")return null;const e=typeof t.draft=="string"&&t.draft.length<=u1?t.draft:"",n=f1(t.history),i=h1(t.updatedAt),s=t.expanded===!0;return!e&&!n.length&&!s?null:{draft:e,history:n,expanded:s,updatedAt:i}}function WM(t){let e;try{e=typeof t=="string"?JSON.parse(t):t}catch{return Bu()}if(!e||typeof e!="object"||e.version!==Xp||!e.cells||typeof e.cells!="object")return Bu();const n=Object.create(null);for(const[i,s]of Object.entries(e.cells)){if(!i||typeof i!="string"||i.length>512||i==="__proto__"||i==="constructor"||i==="prototype")continue;const a=Ou(s);a&&(n[i]=a)}return{version:Xp,cells:n}}function p1(t){const e=zm(t);if(!e)return Bu();try{return WM(e.getItem(Qu))}catch{return Bu()}}function Ow(t){try{return JSON.stringify(t).length}catch{return 1/0}}function qM(t,e,n){for(const[i,s]of Object.entries(t.cells))i!==n&&s.updatedAt>0&&e-s.updatedAt>d1&&delete t.cells[i]}function m1(t,e){return Object.entries(t.cells).filter(([n])=>n!==e).sort((n,i)=>n[1].updatedAt-i[1].updatedAt).map(([n])=>n)}function KM(t,e){for(;Ow(t)>Bw;){const n=Object.entries(t.cells).filter(([,i])=>i.history.length).sort((i,s)=>i[1].updatedAt-s[1].updatedAt);if(!n.length)break;n[0][1].history.pop()}for(const n of m1(t,e)){if(Ow(t)<=Bw)break;delete t.cells[n]}}function g1(t,e,n){const i=zm(t);if(!i)return!1;KM(e,n);const s=()=>(i.setItem(Qu,JSON.stringify(e)),!0);try{return s()}catch{for(const l of m1(e,n)){delete e.cells[l];try{return s()}catch{}}return!1}}function Bl(t,e,n,i){const s=p1(e);qM(s,n,t);const a=Ou(s.cells[t])||{draft:"",history:[],expanded:!1,updatedAt:0},l=i({...a,history:[...a.history]}),d=Ou(l);return d?s.cells[t]={...d,updatedAt:n}:delete s.cells[t],{ok:g1(e,s,t),cell:s.cells[t]||{draft:"",history:[],expanded:!1,updatedAt:n}}}function VM({ownerId:t,node:e,session:n}){const i=String(n||"");if(!i)return"";const s=ra.test(String(t||""))?String(t):e?`route:${String(e)}`:"local";return`${encodeURIComponent(s)}:${encodeURIComponent(i)}`}function ll(t,e,n=Date.now()){if(!t)return{draft:"",history:[],expanded:!1,updatedAt:0};const i=p1(e),s=Ou(i.cells[t]);return!s||s.updatedAt>0&&n-s.updatedAt>d1?(i.cells[t]&&(delete i.cells[t],g1(e,i,"")),{draft:"",history:[],expanded:!1,updatedAt:0}):{...s,history:[...s.history]}}function $w(t,e,n,i=Date.now()){const s=String(e||"");return!t||s.length>u1?!1:Bl(t,n,i,a=>({...a,draft:s})).ok}function zw(t,e,n=Date.now()){return t?Bl(t,e,n,i=>({...i,draft:""})).ok:!1}function YM(t,e,n,i=Date.now()){return t?Bl(t,n,i,s=>({...s,expanded:!!e})).ok:!1}function GM(t,e,n,i=Date.now()){const s=String(e||"");return!t||!s||s.length>c1?!1:Bl(t,n,i,a=>{const l=a.history.filter(d=>d.text!==s);return l.unshift({text:s,at:i}),{...a,history:f1(l)}}).ok}function XM(t,e,n=Date.now()){return t?Bl(t,e,n,i=>({...i,history:[]})).ok:!1}function QM(t){const e=zm(t);if(!e)return!1;try{return e.removeItem(Qu),!0}catch{return!1}}const JM=300;function ZM(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function eA({ownerId:t,node:e,session:n,storage:i=ZM()}){const s=k.useMemo(()=>VM({ownerId:t,node:e,session:n}),[t,e,n]),a=k.useMemo(()=>ll(s,i),[]),[l,d]=k.useState(a.draft),[h,f]=k.useState(a.expanded),[g,y]=k.useState(a.history),[_,w]=k.useState(-1),b=k.useRef(s),N=k.useRef(a.draft),x=k.useRef(null),E=k.useRef(a.updatedAt||0),C=k.useRef(a.draft),I=k.useCallback(()=>{x.current&&clearTimeout(x.current),x.current=null},[]),T=k.useCallback(()=>{I(),$w(b.current,N.current,i)},[I,i]),W=k.useCallback(()=>{I(),x.current=setTimeout(()=>{x.current=null,$w(b.current,N.current,i)},JM)},[I,i]),U=k.useCallback(j=>{const O=String(typeof j=="function"?j(N.current):j||"");N.current=O,E.current=Date.now(),C.current=O,w(-1),d(O),W()},[W]),Q=k.useCallback((j,O)=>{I(),N.current=j,E.current=Date.now(),d(j),w(O),W()},[I,W]),ee=k.useCallback(()=>{if(!g.length)return!1;const j=Math.min(_+1,g.length-1);return _<0&&(C.current=N.current),Q(g[j].text,j),!0},[Q,g,_]),q=k.useCallback(()=>{if(_<0)return!1;const j=_-1;return Q(j<0?C.current:g[j].text,j),!0},[Q,g,_]),J=k.useCallback(j=>{C.current=N.current;const O=g.findIndex(P=>P.text===j);Q(String(j||""),O)},[Q,g]),$=k.useCallback(()=>{f(j=>{const O=!j;return YM(b.current,O,i),O})},[i]),M=k.useCallback((j,O,P)=>{if(!j)return;if(GM(j,P,i),!(b.current===j)){ll(j,i).draft===O&&zw(j,i);return}y(ll(j,i).history),C.current="",w(-1),N.current===O?(I(),N.current="",E.current=Date.now(),d(""),zw(j,i)):W()},[I,W,i]),L=k.useCallback(()=>{XM(b.current,i),y([]),w(-1),C.current=N.current},[i]);return k.useEffect(()=>{if(b.current===s)return;T(),b.current=s;const j=ll(s,i);N.current=j.draft,E.current=j.updatedAt||0,C.current=j.draft,d(j.draft),f(j.expanded),y(j.history),w(-1)},[s,T,i]),k.useEffect(()=>{const j=()=>T(),O=()=>{document.visibilityState==="hidden"&&T()};return window.addEventListener("pagehide",j),document.addEventListener("visibilitychange",O),()=>{window.removeEventListener("pagehide",j),document.removeEventListener("visibilitychange",O),T()}},[T]),k.useEffect(()=>{const j=()=>{I(),N.current="",E.current=0,C.current="",d(""),f(!1),y([]),w(-1)},O=A=>{if(A.key!==Qu)return;if(A.newValue==null){j();return}const R=ll(b.current,i);R.updatedAt<E.current||(I(),N.current=R.draft,E.current=R.updatedAt,C.current=R.draft,d(R.draft),f(R.expanded),y(R.history),w(-1))},P=()=>j();return window.addEventListener("storage",O),window.addEventListener(Gp,P),()=>{window.removeEventListener("storage",O),window.removeEventListener(Gp,P)}},[I,i]),{cellKey:s,text:l,setText:U,expanded:h,toggleExpanded:$,history:g,historyCursor:_,recallPrevious:ee,recallNext:q,selectHistory:J,confirmSubmitted:M,clearHistory:L,flush:T}}function v1({submitText:t,token:e,session:n,node:i,ownerId:s,readonly:a=!1,keepKeyboardClosedOnVoice:l=!0}){li();const d=i?`/api/route/${String(i).split("/").map(encodeURIComponent).join("/")}/_`:"/api",{cellKey:h,text:f,setText:g,expanded:y,toggleExpanded:_,history:w,historyCursor:b,recallPrevious:N,recallNext:x,selectHistory:E,confirmSubmitted:C,clearHistory:I,flush:T}=eA({ownerId:s,node:i,session:n}),[W,U]=k.useState(!1),[Q,ee]=k.useState(""),[q,J]=k.useState(""),[$,M]=k.useState(!1),L=k.useRef(null),j=k.useRef(null),O=k.useRef(null),[P,A]=k.useState(!1),[R,D]=k.useState({left:0,bottom:0}),[H,z]=k.useState(!1),[F,K]=k.useState(!1),ne=k.useRef(null),re=k.useRef(null),Y=k.useRef(null),de=k.useRef(null),oe=k.useRef(null),pe=k.useRef(null),xe=k.useRef(null),Qe=k.useRef(null),ot=k.useRef(!1),[De,je]=k.useState(!1),[tt,Nt]=k.useState({left:0,bottom:0,width:320}),Ct=k.useRef(`nc-attach-${Math.random().toString(36).slice(2,8)}`);k.useEffect(()=>{let ae=!1;if(i){M(!1);return}return pn(`${d}/voice/status`,e).then(ge=>ge.json()).then(ge=>{ae||M(!!ge.serverSttConfigured)}).catch(()=>{ae||M(!1)}),()=>{ae=!0}},[e,d]);const ht=!!(typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition)||$);async function kt(){const ae=O.current&&typeof O.current.value=="string"?O.current.value:f;Yp(),ae!==f&&g(ae);const ge=ae,Ce=nM(ge);if(!Ce||F)return;if(a){ee(m("settings-readonly"));return}K(!0),ee("");let Me=!1;try{Me=!!await t(Ce)}catch{Me=!1}Me?C(h,ge,Ce):ee(m("composer-send-failed")),K(!1)}function St(){const ae=ne.current&&ne.current.getBoundingClientRect();ae&&D({left:Math.max(6,Math.min(ae.left,window.innerWidth-186)),bottom:window.innerHeight-ae.top+6}),A(!0)}function Ut(ae){A(!1),ae&&ne.current&&ne.current.focus()}function Mt(){const ae=Y.current&&Y.current.getBoundingClientRect();if(ae){const ge=Math.max(220,Math.min(360,window.innerWidth-12));Nt({left:Math.max(6,Math.min(ae.right-ge,window.innerWidth-ge-6)),bottom:window.innerHeight-ae.top+6,width:ge})}je(!0)}function It(ae){je(!1),ae&&Y.current&&Y.current.focus()}k.useEffect(()=>{if(!P)return;const ae=Ce=>{Ce.key==="Escape"&&Ut(!0)},ge=Ce=>{const Me=re.current&&re.current.contains(Ce.target),nt=ne.current&&ne.current.contains(Ce.target);!Me&&!nt&&Ut(!1)};return document.addEventListener("keydown",ae),document.addEventListener("pointerdown",ge),()=>{document.removeEventListener("keydown",ae),document.removeEventListener("pointerdown",ge)}},[P]),k.useEffect(()=>{if(!De)return;const ae=Ce=>{Ce.key==="Escape"&&It(!0)},ge=Ce=>{const Me=de.current&&de.current.contains(Ce.target),nt=Y.current&&Y.current.contains(Ce.target);!Me&&!nt&&It(!1)};return document.addEventListener("keydown",ae),document.addEventListener("pointerdown",ge),()=>{document.removeEventListener("keydown",ae),document.removeEventListener("pointerdown",ge)}},[De]);function tn(ae){if(!(ae.isComposing||ot.current||ae.altKey||ae.ctrlKey||ae.metaKey)){if(ae.key==="ArrowUp"&&ae.currentTarget.selectionStart===0&&ae.currentTarget.selectionEnd===0){N()&&ae.preventDefault();return}ae.key==="ArrowDown"&&b>=0&&ae.currentTarget.selectionStart===f.length&&ae.currentTarget.selectionEnd===f.length&&x()&&ae.preventDefault()}}function Ft(ae){Ut(!1),ae.current&&ae.current.click()}async function ln(ae){if(!ae.length||!n)return;z(!0),ee("");const{paths:ge,errors:Ce}=await Vp({files:ae,token:e,session:n,node:i,paste:!1});Ce.length&&ee(Ce.map(Me=>`${Me.name}: ${Me.message}`).join(" · ")),ge.length&&g(Me=>Me+(Me&&!Me.endsWith(" ")?" ":"")+ge.join(" ")),z(!1)}async function V(ae){var Me;if(!ae.length||!n)return;z(!0),ee(""),J("");const{paths:ge,errors:Ce}=await Vp({files:ae,token:e,session:n,node:i,paste:!1});if(Ce.length&&ee(Ce.map(nt=>`${nt.name}: ${nt.message}`).join(" · ")),ge.length){J(m("attach-inbox-done").replace("{n}",String(ge.length)));try{(Me=navigator.vibrate)==null||Me.call(navigator,10)}catch{}setTimeout(()=>J(""),2500)}z(!1)}function Te(){L.current&&L.current.stop(),j.current&&j.current.stop(),U(!1)}async function gt(){ee("");const ae=window.SpeechRecognition||window.webkitSpeechRecognition;if(ae){const ge=new ae;ge.lang="it-IT",ge.continuous=!1,ge.interimResults=!0;const Ce=f?`${f} `:"";ge.onresult=Me=>{const nt=Array.from(Me.results).map(ct=>ct[0].transcript).join("");g(Ce+nt)},ge.onend=()=>U(!1),ge.onerror=Me=>{ee(`voice: ${Me.error||"errore"}`),U(!1)},L.current=ge,ge.start(),U(!0);return}try{const ge=await navigator.mediaDevices.getUserMedia({audio:!0}),Ce=new MediaRecorder(ge),Me=[];Ce.ondataavailable=nt=>Me.push(nt.data),Ce.onstop=async()=>{ge.getTracks().forEach(nt=>nt.stop()),U(!1),ee("trascrivo…");try{const nt=new Blob(Me,{type:Ce.mimeType||"audio/webm"}),pt=await(await pn(`${d}/voice/transcribe`,e,{method:"POST",headers:{"content-type":"application/octet-stream"},body:nt})).json();pt.error?ee(pt.error):(ee(""),g(Lt=>Lt+(Lt?" ":"")+(pt.text||"")))}catch(nt){ee(String(nt))}},j.current={stop:()=>Ce.state!=="inactive"&&Ce.stop()},Ce.start(),U(!0)}catch{ee("microfono non disponibile"),U(!1)}}function le(){l&&Yp(),W?Te():gt()}return c.jsxs("div",{className:"nc-composer",children:[Q&&c.jsx("div",{className:"nc-composer-err",children:Q}),q&&c.jsx("div",{className:"nc-composer-info",children:q}),c.jsxs("div",{className:"nc-composer-row",children:[n&&c.jsx("button",{ref:ne,className:H?"attach busy":"attach",disabled:H,onClick:()=>P?Ut(!1):St(),title:m(H?"attach-uploading":"attach"),"aria-label":m("attach"),"aria-haspopup":"menu","aria-expanded":P,"aria-controls":Ct.current,children:c.jsx(dt,{name:"attach",size:22})}),P&&c.jsxs("div",{ref:re,id:Ct.current,role:"menu",className:"nc-attach-menu",style:{left:R.left,bottom:R.bottom},children:[c.jsxs("button",{role:"menuitem",onClick:()=>Ft(oe),children:[c.jsx(dt,{name:"file",size:18})," ",m("attach-file")]}),c.jsxs("button",{role:"menuitem",onClick:()=>Ft(pe),children:[c.jsx(dt,{name:"camera",size:18})," ",m("attach-camera")]}),c.jsxs("button",{role:"menuitem",onClick:()=>Ft(xe),children:[c.jsx(dt,{name:"image",size:18})," ",m("attach-gallery")]}),c.jsxs("button",{role:"menuitem",onClick:()=>Ft(Qe),children:[c.jsx(dt,{name:"folder",size:18})," ",m("attach-inbox")]})]}),c.jsx("button",{ref:Y,type:"button",className:"history",onPointerDown:ae=>ae.preventDefault(),onClick:()=>De?It(!1):Mt(),title:m("composer-history-tools"),"aria-label":m("composer-history-tools"),"aria-haspopup":"menu","aria-expanded":De,children:c.jsx(dt,{name:"history",size:21})}),De&&c.jsxs("div",{ref:de,role:"menu",className:"nc-composer-history-menu",style:{left:tt.left,bottom:tt.bottom,width:tt.width},children:[c.jsxs("button",{role:"menuitem",className:"nc-composer-history-action",onPointerDown:ae=>ae.preventDefault(),onClick:()=>{_(),It(!1)},children:[c.jsx(dt,{name:y?"chevronDown":"chevronUp",size:18}),m(y?"composer-collapse":"composer-expand")]}),c.jsx("div",{className:"nc-composer-history-title",children:m("composer-history")}),w.length===0&&c.jsx("div",{className:"nc-composer-history-empty",children:m("composer-history-empty")}),w.map((ae,ge)=>c.jsxs("button",{type:"button",role:"menuitem",className:"nc-composer-history-entry",onPointerDown:Ce=>Ce.preventDefault(),onClick:()=>{E(ae.text),It(!1)},children:[c.jsx("span",{children:ae.text.replace(/\s+/g," ").slice(0,180)}),ae.at>0&&c.jsx("small",{children:new Date(ae.at).toLocaleString()})]},`${ae.at}:${ge}`)),w.length>0&&c.jsx("button",{type:"button",role:"menuitem",className:"nc-composer-history-clear",onPointerDown:ae=>ae.preventDefault(),onClick:()=>{I(),It(!1)},children:m("composer-history-clear")})]}),c.jsx("input",{ref:oe,type:"file",multiple:!0,hidden:!0,onChange:ae=>{ln(Array.from(ae.target.files||[])),ae.target.value=""}}),c.jsx("input",{ref:pe,type:"file",accept:"image/*",capture:"environment",hidden:!0,onChange:ae=>{ln(Array.from(ae.target.files||[])),ae.target.value=""}}),c.jsx("input",{ref:xe,type:"file",accept:"image/*,video/*",multiple:!0,hidden:!0,onChange:ae=>{ln(Array.from(ae.target.files||[])),ae.target.value=""}}),c.jsx("input",{ref:Qe,type:"file",multiple:!0,hidden:!0,onChange:ae=>{V(Array.from(ae.target.files||[])),ae.target.value=""}}),c.jsx("textarea",{ref:O,className:y?"expanded":"",rows:y?8:2,value:f,placeholder:m("composer-placeholder"),onChange:ae=>g(ae.target.value),onKeyDown:tn,onCompositionStart:()=>{ot.current=!0},onCompositionEnd:()=>{ot.current=!1},onBlur:T}),ht&&c.jsx("button",{type:"button",className:W?"mic on":"mic",title:m("voice"),"aria-label":m("voice"),onPointerDown:ae=>{ae.preventDefault(),le()},onClick:ae=>{ae.detail===0&&le()},children:c.jsx(dt,{name:"mic",size:22})}),c.jsx("button",{type:"button",className:"go",disabled:F,onPointerDown:ae=>ae.preventDefault(),onClick:kt,title:m("send"),children:c.jsx(dt,{name:"enter",size:22})})]})]})}const Fm="nc_popup_assetto",tA=320,nA=240,iA=1100,sA=820,Fw=48,rA=44;function _1(){return{vw:window.innerWidth||1024,vh:window.innerHeight||768}}function wl(t){const{vw:e,vh:n}=_1(),i=Math.max(tA,Math.min(t.w,e)),s=Math.max(nA,Math.min(t.h,n)),a=Math.max(-(i-Fw),Math.min(t.x,e-Fw)),l=Math.max(0,Math.min(t.y,Math.max(0,n-rA)));return{x:a,y:l,w:i,h:s}}function Hw(){try{const t=window.localStorage.getItem(Fm);if(!t)return null;const e=JSON.parse(t);return!e||![e.x,e.y,e.w,e.h].every(n=>typeof n=="number"&&Number.isFinite(n))?null:wl(e)}catch{return null}}function oA(t){try{window.localStorage.setItem(Fm,JSON.stringify(t))}catch{}}function aA(){const[t,e]=k.useState(()=>typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 720px)").matches);return k.useEffect(()=>{if(typeof window.matchMedia!="function")return;const n=window.matchMedia("(max-width: 720px)"),i=s=>e(!!(s&&s.matches));if(typeof n.addEventListener=="function")return n.addEventListener("change",i),()=>n.removeEventListener("change",i)},[]),t}function y1({title:t,subtitle:e,onClose:n,children:i}){const s=k.useRef(null),a=k.useRef(null),l=aA(),[d,h]=k.useState(()=>l?null:Hw()),f=k.useRef(null),[g,y]=k.useState(!1),_=k.useCallback(()=>{n&&n()},[n]);k.useEffect(()=>{const E=C=>{C.key==="Escape"&&(C.stopPropagation(),_())};return document.addEventListener("keydown",E,!0),()=>document.removeEventListener("keydown",E,!0)},[_]),k.useEffect(()=>{const E=a.current;E&&typeof E.focus=="function"&&E.focus()},[]);const w=()=>{const{vw:E,vh:C}=_1(),I=Math.min(iA,Math.floor(E*.96)),T=Math.min(sA,Math.floor(C*.92));return wl({x:Math.round((E-I)/2),y:Math.round((C-T)/2),w:I,h:T})},b=E=>C=>{if(l||C.button!==0||C.target&&typeof C.target.closest=="function"&&C.target.closest(".nc-popup-chiudi"))return;C.preventDefault();const I=d||w();f.current={mode:E,startX:C.clientX,startY:C.clientY,base:I},h(I),y(!0)};k.useEffect(()=>{if(!g)return;const E=I=>{const T=f.current;if(!T)return;const W=I.clientX-T.startX,U=I.clientY-T.startY;T.mode==="move"?h(wl({...T.base,x:T.base.x+W,y:T.base.y+U})):h(wl({...T.base,w:T.base.w+W,h:T.base.h+U}))},C=()=>{f.current=null,y(!1),h(I=>(I&&oA(I),I))};return window.addEventListener("mousemove",E),window.addEventListener("mouseup",C),()=>{window.removeEventListener("mousemove",E),window.removeEventListener("mouseup",C)}},[g]);const N=()=>{if(!l){f.current=null,y(!1),h(null);try{window.localStorage.removeItem(Fm)}catch{}}};k.useEffect(()=>{if(l)return;const E=()=>h(C=>C&&wl(C));return window.addEventListener("resize",E),()=>window.removeEventListener("resize",E)},[l]),k.useEffect(()=>{l||h(E=>E||Hw())},[l]);const x=!!(d&&!l);return c.jsxs("div",{className:"nc-popup-velo",onMouseDown:E=>{E.target===E.currentTarget&&_()},role:"presentation",children:[c.jsxs("div",{className:x?"nc-popup nc-popup-libera":"nc-popup",style:x?{left:d.x,top:d.y,width:d.w,height:d.h}:void 0,ref:s,role:"dialog","aria-modal":"true","aria-label":t||m("panel"),children:[c.jsxs("header",{className:"nc-popup-testa",onMouseDown:b("move"),onDoubleClick:N,title:m("popup-drag-hint"),children:[c.jsxs("span",{className:"nc-popup-titolo",children:[t,e?c.jsx("small",{className:"nc-popup-sub",children:e}):null]}),c.jsx("button",{type:"button",ref:a,className:"nc-popup-chiudi",onClick:_,title:m("close"),"aria-label":m("close"),children:"✕"})]}),c.jsx("div",{className:"nc-popup-corpo",children:i}),!l&&c.jsx("div",{className:"nc-popup-angolo",onMouseDown:b("resize"),title:m("popup-resize-hint"),role:"presentation"})]}),g&&c.jsx("div",{className:"nc-popup-velo-drag",role:"presentation"})]})}function Hm({cellId:t,panelUrl:e,route:n=[],panelPort:i=0,token:s,title:a,requestTimeoutMs:l=4e3}){const[d,h]=k.useState(t&&s?"requesting":"none"),[f,g]=k.useState(""),y=Array.isArray(n)?n.join("\0"):"",_=k.useMemo(()=>Array.isArray(n)?n:[],[y]),w=k.useRef(0),b=k.useCallback(async()=>{if(!t||!s||!e){h("none");return}const I=w.current+=1;h("requesting");const T=new AbortController,W=setTimeout(()=>T.abort(),l);try{const U=await nk(s,_,t,{signal:T.signal});if(clearTimeout(W),I!==w.current)return;if(U.ok){let Q="/";try{Q=new URL(e).pathname||"/"}catch{}const ee=i?`http://127.0.0.1:${i}`:an(_);g(`${ee}/panel/${encodeURIComponent(t)}${Q}?ticket=${encodeURIComponent(U.ticket)}`),h("ready")}else h(U.cause)}catch(U){if(clearTimeout(W),I!==w.current)return;h(U&&U.name==="AbortError"?"timeout":"unreachable")}},[t,e,_,i,s,l]),N=k.useCallback(()=>{h(I=>I==="ready"?"loaded":I)},[]),x=k.useCallback(()=>{h(I=>I==="ready"||I==="loaded"?"frame-error":I)},[]),E=k.useCallback(I=>{I&&(I.onload=N,I.onerror=x)},[N,x]);k.useEffect(()=>{b()},[b]);const C=(I,T=!0)=>c.jsxs("div",{className:"nc-cellpanel nc-cellpanel-msg",role:"status",children:[c.jsx("span",{children:m(I)}),T&&c.jsx("span",{className:"nc-cellpanel-actions",children:c.jsx("button",{type:"button",title:m("panel-retry"),onClick:()=>b(),children:m("panel-retry")})})]});return d==="none"||d==="no-panel"?C("panel-none",!1):d==="requesting"?c.jsx("div",{className:"nc-cellpanel nc-cellpanel-msg",role:"status",children:c.jsx("span",{children:m("panel-checking")})}):d==="not-granted"?C("panel-not-granted",!1):d==="node-refused"?C("panel-node-refused",!1):d==="unauthorized"?C("panel-unauthorized",!1):d==="denied"?C("panel-denied"):d==="timeout"?C("panel-timeout"):d==="unreachable"?C("panel-unreachable"):d==="frame-error"?C("panel-frame-error"):c.jsxs(c.Fragment,{children:[d==="ready"&&c.jsx("div",{className:"nc-cellpanel-loading",role:"status",children:m("panel-frame-loading")}),c.jsx("iframe",{ref:E,className:"nc-cellpanel nc-cellpanel-frame","data-frame-state":d,src:f,title:a||m("panel"),allowFullScreen:!0})]})}const lA=1800*1e3;function Qp(t,e,n=Date.now()){const i=Number(e);if(!Number.isFinite(i)||i<=0)return"";const s=n-i;if(s<0||s>lA)return"";if(s<60*1e3)return`${t("cell-activity")} ${t("cell-activity-now")}`;const a=Math.floor(s/6e4);return a<60?`${t("cell-activity")} ${a}m`:`${t("cell-activity")} ${Math.floor(a/60)}h`}function Jp(t,e){if(!e||typeof e!="object")return"";const n=[];return Number.isInteger(e.contextFreePct)&&n.push(`${t("cell-tele-ctx")} ${e.contextFreePct}% ${t("cell-tele-free")}`),Number.isInteger(e.tier5hUsedPct)&&n.push(`${t("cell-tele-5h")} ${e.tier5hUsedPct}%`),Number.isInteger(e.tier7dUsedPct)&&n.push(`${t("cell-tele-7d")} ${e.tier7dUsedPct}%`),n.join(" · ")}function w1({row:t,token:e,initialSource:n="preview",panelPort:i=0,onClose:s}){const[a,l]=k.useState(n==="panel"&&!t.panelUrl?"preview":n),d=k.useRef(()=>{}),h=k.useRef(()=>!1),f=k.useRef(()=>{}),g=k.useRef(!1),[y,_]=k.useState(!1),w=[["preview",m("cell-peek-preview")],["stream",m("cell-peek-stream")],...t.panelUrl?[["panel",m("cell-peek-panel")]]:[]];return c.jsxs(y1,{title:t.cellName,subtitle:[t.nodeLabel,t.subtitle].filter(Boolean).join(" · "),onClose:s,children:[c.jsx("div",{className:"nc-peek-sorgenti",role:"tablist",children:w.map(([b,N])=>c.jsx("button",{type:"button",role:"tab","aria-selected":a===b,className:`nc-peek-sorgente${a===b?" attiva":""}`,onClick:()=>l(b),children:N},b))}),a==="stream"?c.jsx("div",{className:"nc-peek-stream",children:c.jsx($m,{session:t.session,node:t.node||void 0,token:e,readonly:!1,takeSize:!1,focused:!0,sendRef:d,composerRef:h,actionRef:f,ctrlRef:g,setCtrlArmed:_},`peek:${t.key}`)}):a==="panel"?c.jsx(Hm,{cellId:t.cellName,panelUrl:t.panelUrl,route:t.route||[],panelPort:i,token:e,title:t.cellName}):c.jsxs(c.Fragment,{children:[c.jsx("pre",{className:"nc-peek-testo",children:t.preview||m("cell-peek-vuoto")}),[Qp(m,t.activity),Jp(m,t.telemetry)].filter(Boolean).join(" · ")&&c.jsx("small",{className:"nc-cell-switcher-telemetry",children:[Qp(m,t.activity),Jp(m,t.telemetry)].filter(Boolean).join(" · ")})]})]})}function hf(t){return String(t||"?").replace(/^[^a-zA-Z0-9]+/,"").charAt(0).toUpperCase()||"?"}const cA=180,uA=480,Vo=(t,e=[])=>`${e.length?e.join("/"):"local"}:${t}`;function dA({sessions:t=[],cells:e=[],activeSessions:n=[],nodeGroups:i=[],onPick:s,onAddTile:a,onPower:l,onBoot:d,onNodePower:h,onKill:f,onVisibility:g,onNew:y,onNodeRename:_,onSettings:w,onBootError:b,localNodeId:N,fleetCapabilities:x=[],fleetStale:E=!1,fleetOff:C=null,bootSettlement:I=null,hostByRoute:T={},onDesignateCell:W,onClearHostCell:U,onBootSettlementApplied:Q,onOpenVlSession:ee,token:q="",onPeekOpen:J,overlayOpen:$=!1,width:M=240,collapsed:L=!1,onResize:j,onToggleCollapse:O}){const[P,A]=li(),{pins:R,orders:D,togglePin:H,removePin:z,pinError:F,retryPinPersist:K,clearPinError:ne,viewFor:re,updateView:Y,canMoveRoster:de,moveRoster:oe,stepRoster:pe}=wm(),{groupsFor:xe,moveNode:Qe,stepNode:ot,nodeKey:De}=j0(),je=X=>T[ea(X)]||{},tt=new Set((e||[]).map(X=>X.tmuxSession)),Nt=new Map((t||[]).map(X=>[X.name,X])),Ct=(X,ie)=>w2(R,X,ie),ft=b2,ht=[...e||[]].sort((X,ie)=>ft(Ct(X.tmuxSession,(Nt.get(X.tmuxSession)||{}).activity),Ct(ie.tmuxSession,(Nt.get(ie.tmuxSession)||{}).activity))),kt=(t||[]).filter(X=>!tt.has(X.name)).sort((X,ie)=>ft(Ct(X.name,X.activity),Ct(ie.name,ie.activity))||X.name.localeCompare(ie.name)),St=new Set(n||[]),[Ut,Mt]=k.useState(null),[It,tn]=k.useState("preview"),Ft=(X,ie,_e=[],Ke="",Ie=null)=>{const et=(_e.length===0?Nt.get(ie.tmuxSession):(Ie||[]).find(Ot=>Ot&&Ot.name===ie.tmuxSession))||{};return{key:X.key,cellName:ie.cell,subtitle:X.subtitle||"",nodeLabel:Ke,node:_e.length?_e.join("/"):"",session:ie.tmuxSession,route:_e,panelUrl:ie.panelUrl||"",telemetry:et.telemetry||null,preview:et.preview||ie.preview||"",activity:et.activity||ie.activity||0}},ln=(X,ie,_e=[],Ke="",Ie="preview")=>Ee=>{Ee&&Ee.stopPropagation(),tn(Ie),Mt(X.key),typeof J=="function"&&J()};k.useEffect(()=>{$&&(Mt(null),tn("preview"))},[$]);const V=Sm(ht,kt,Nt),Te=Nr(V,R,re("local").filter,Vs(D,"local")),le=xe(i||[]).map(X=>{const ie=(X.route&&X.route.length?X.route:[X.name]).join("/"),_e=re(ie);if(X.kind==="vl")return{g:X,nodeRoute:ie,groupView:_e,rawItems:[],items:[]};const{rawItems:Ke}=Nu(X),Ie=Nr(Ke,R,_e.filter,Vs(D,ie));return{g:X,nodeRoute:ie,groupView:_e,rawItems:Ke,items:Ie}}),ae=[...Te,...le.flatMap(({items:X,nodeRoute:ie,g:_e})=>(X||[]).map(Ke=>({...Ke,nodeRoute:ie,nodeLabel:_e.label||_e.name})))].filter(X=>X.type==="cell"),ge=Ut?ae.find(X=>X.key===Ut):null,Ce=(X,ie,_e)=>s&&s({session:X,...ie?{node:ie}:{},...ra.test(String(_e||""))?{ownerId:_e}:{}}),Me=async X=>{if(!(X!=null&&X.direct)||!_)return;const ie=window.prompt(m("rename-node-prompt"),X.label||X.name);if(ie!==null)try{await _(X,ie)||window.alert(m("rename-node-invalid"))}catch(_e){window.alert(String((_e==null?void 0:_e.message)||_e))}},[nt,ct]=k.useState({}),[pt,Lt]=k.useState(new Set);k.useEffect(()=>{const X=new Map;for(const ie of e||[])X.set(Vo(ie.cell),!!ie.boot);for(const ie of i||[]){const _e=ie.route||[ie.name];for(const Ke of ie.cells||[])X.set(Vo(Ke.cell,_e),!!Ke.boot)}ct(ie=>{let _e=!1;const Ke={...ie};for(const[Ie,Ee]of Object.entries(ie))X.has(Ie)&&X.get(Ie)===Ee&&(delete Ke[Ie],_e=!0);return _e?Ke:ie})},[e,i]),k.useEffect(()=>{if(!(I!=null&&I.cell))return;const X=Array.isArray(I.route)?I.route:[],ie=Vo(I.cell,X);ct(_e=>({..._e,[ie]:!!I.enabled})),Q&&Q(I.id)},[I,Q]);const Dt=(X,ie=[])=>{const _e=Vo(X.cell,ie);return Object.prototype.hasOwnProperty.call(nt,_e)?nt[_e]:!!X.boot},Et=async(X,ie,_e=[])=>{if(X.stopPropagation(),!d)return;const Ke=Vo(ie.cell,_e),Ie=!Dt(ie,_e);ct(Ee=>({...Ee,[Ke]:Ie})),Lt(Ee=>new Set(Ee).add(Ke));try{await d(ie.cell,Ie,_e)}catch(Ee){ct(et=>{const Ot={...et};return delete Ot[Ke],Ot}),b&&b(Ee)}finally{Lt(Ee=>{const et=new Set(Ee);return et.delete(Ke),et})}},Bt=(X,ie=[])=>{const _e=Vo(X.cell,ie),Ke=Dt(X,ie),Ie=`${m(Ke?"boot-disable":"boot-enable")} ${X.cell}`;return c.jsx("button",{className:`nc-boot${Ke?" on":""}`,disabled:pt.has(_e),onClick:Ee=>Et(Ee,X,ie),title:Ie,"aria-label":Ie,children:c.jsx(dt,{name:"boot",size:14})})},[Z,ye]=k.useState(null),Ue=(X,ie)=>{const _e=X.currentTarget.getBoundingClientRect();ye({text:ie,y:_e.top+_e.height/2})},We=()=>ye(null),Ge=k.useRef(null);k.useEffect(()=>()=>{Ge.current&&Ge.current()},[]);function jt(X){X.preventDefault(),X.stopPropagation();const ie=X.clientX,_e=M,Ke=Ee=>{const et=Math.max(cA,Math.min(uA,_e+(Ee.clientX-ie)));j&&j(et)},Ie=()=>{window.removeEventListener("pointermove",Ke),window.removeEventListener("pointerup",Ie),window.removeEventListener("pointercancel",Ie),window.removeEventListener("blur",Ie),Ge.current=null};window.addEventListener("pointermove",Ke),window.addEventListener("pointerup",Ie),window.addEventListener("pointercancel",Ie),window.addEventListener("blur",Ie),Ge.current=Ie}const Pt=L?{width:48,flex:"0 0 48px"}:{width:M,flex:`0 0 ${M}px`};return L?c.jsxs("aside",{className:"nc-sidebar mini",style:Pt,children:[c.jsx("div",{className:"nc-side-head mini",children:c.jsx("button",{className:"nc-collapse-btn",onClick:O,title:m("expand"),children:"⟩"})}),c.jsx("button",{className:"nc-side-gear mini",onClick:()=>w&&w("nodes",!1),title:m("settings"),onMouseEnter:X=>Ue(X,m("settings")),onMouseLeave:We,children:c.jsx(dt,{name:"gear",size:16})}),c.jsx("div",{className:"nc-side-scroll mini",children:c.jsxs("div",{className:"nc-side-group mini",children:[re("local").open&&Te.map(X=>X.type==="cell"?(()=>{const ie=X.value,_e=ie.degraded?"warn":ie.tmux?"on":"",Ke=!!ie.tmux;return c.jsx("button",{type:"button",className:`nc-mini-dot${St.has(ie.tmuxSession)?" active":""}`,onMouseEnter:Ie=>Ue(Ie,`${ie.cell}: ${X.subtitle}`),onMouseLeave:We,draggable:Ke,onDragStart:Ke?Ie=>Ie.dataTransfer.setData("text/nc-session",ie.tmuxSession):void 0,onClick:Ke?()=>a&&a(ie.tmuxSession):()=>l&&l(ie),onDoubleClick:Ke?()=>Ce(ie.tmuxSession,"",N):void 0,children:c.jsx("span",{className:`nc-dot ${_e}${X.working?" working":""}`})},X.key)})():(()=>{const ie=X.value;return c.jsx("button",{type:"button",className:`nc-mini-init${St.has(ie.name)?" active":""}`,onMouseEnter:_e=>Ue(_e,ie.name),onMouseLeave:We,draggable:!0,onDragStart:_e=>_e.dataTransfer.setData("text/nc-session",ie.name),onClick:()=>a&&a(ie.name),onDoubleClick:()=>Ce(ie.name,"",N),children:hf(ie.name)},X.key)})()),le.flatMap(({g:X,nodeRoute:ie,groupView:_e,items:Ke})=>X.kind==="vl"?X.status==="up"&&X.sessions.length?X.sessions.map(Ie=>c.jsx("button",{type:"button",className:"nc-mini-init",onMouseEnter:Ee=>Ue(Ee,`${X.label||ie}: ${Ie.name}`),onMouseLeave:We,onClick:()=>ee&&ee(X.peer),children:hf(Ie.name)},Ie.key)):[c.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:Ie=>Ue(Ie,`${X.label||X.name}: ${X.status==="up"?m("no-sessions-short"):Ws(X)}`),onMouseLeave:We,children:c.jsx("span",{className:`nc-dot${X.status==="up"?" on":" warn"}`})},`nodo-vl-${ie}-${X.name}`)]:X.status==="up"?_e.open?Ke.map(Ie=>Ie.type==="cell"?(()=>{const Ee=Ie.value,et=!!Ee.tmux;return c.jsx("button",{type:"button",className:`nc-mini-dot${St.has(Ie.key)?" active":""}`,onMouseEnter:Ot=>Ue(Ot,`${X.label||ie}: ${Ee.cell} · ${Ie.subtitle}`),onMouseLeave:We,draggable:et,onDragStart:et?Ot=>Ot.dataTransfer.setData("text/nc-session",Ie.key):void 0,onClick:et?()=>a&&a(Ie.key):()=>l&&l({...Ee,route:X.route,availableEngines:X.engines||[]}),onDoubleClick:et?()=>Ce(Ee.tmuxSession,ie,X.instanceId):void 0,children:c.jsx("span",{className:`nc-dot ${Ee.degraded?"warn":et?`on${Ie.working?" working":""}`:""}`})},Ie.key)})():(()=>{const Ee=Ie.value;return c.jsx("button",{type:"button",className:`nc-mini-init${St.has(Ie.key)?" active":""}`,onMouseEnter:et=>Ue(et,`${X.label||ie}: ${Ee.name}`),onMouseLeave:We,draggable:!0,onDragStart:et=>et.dataTransfer.setData("text/nc-session",Ie.key),onClick:()=>a&&a(Ie.key),onDoubleClick:()=>Ce(Ee.name,ie,X.instanceId),children:hf(Ee.name)},Ie.key)})()):[]:[c.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:Ie=>Ue(Ie,`${X.label||(X.route||[X.name]).join(" › ")}: ${Ws(X)}`),onMouseLeave:We,children:c.jsx("span",{className:`nc-dot${X.status==="passive"?"":" warn"}`})},`nodo-${(X.route||[X.name]).join("/")}`)])]})}),Z&&c.jsx("div",{className:"nc-mini-tip",style:{top:Z.y},children:Z.text})]}):c.jsxs("aside",{className:"nc-sidebar",style:Pt,children:[c.jsxs("div",{className:"nc-side-head",children:[c.jsx("button",{className:"nc-collapse-btn",onClick:O,title:m("collapse"),children:"⟨"}),c.jsx("span",{className:"nc-side-title",children:m("fleet")}),E&&c.jsx("span",{className:"nc-side-fleet-stale",role:"status",title:m("fleet-stale"),"aria-label":m("fleet-stale"),children:"●"}),C!==null&&c.jsx("span",{className:"nc-side-fleet-off",role:"status",title:`${m("fleet-off")}${C?` (${C})`:""}`,"aria-label":`${m("fleet-off")}${C?` (${C})`:""}`,children:"○"}),c.jsxs("button",{className:"nc-new-btn",onClick:y,title:m("fleet-new-cell"),children:["+ ",m("new")]})]}),c.jsxs("button",{className:"nc-side-gear",onClick:()=>w&&w("nodes",!1),title:m("settings"),children:[c.jsx(dt,{name:"gear",size:15})," ",m("settings")]}),c.jsx(P0,{pinError:F,onRetry:K,onDismiss:ne}),c.jsxs("div",{className:"nc-side-scroll",children:[c.jsx(hA,{label:m("position-local"),count:Te.length,state:re("local"),onToggle:()=>Y("local",{open:!re("local").open}),onFilter:X=>Y("local",{filter:X})}),re("local").open&&c.jsxs("div",{className:"nc-side-group",children:[Te.map(X=>X.type==="cell"?(()=>{const ie=X.value,_e=je([]),Ke=Su({hostCell:_e.hostCell??null,threadStatus:_e.threadStatus,pins:R,item:X}),Ie=ie.degraded?"warn":ie.tmux?"on":"",Ee=Vf(Ke,_e.hostLease??null),et=ie.degraded?m("cell-degraded"):X.working?X.subtitle:ie.tmux?m("cell-idle"):m("cell-off"),Ot=Ee?`${et} · ${m(Ee)}`:et,gn=!!ie.tmux;return c.jsxs("div",{"data-roster-key":X.key,"data-position":"local",className:`nc-cell${gn?" live":""}${St.has(ie.tmuxSession)?" active":""}`,title:`${ie.cell} · ${X.subtitle}${Ot===X.subtitle?"":` · ${Ot}`}`,"aria-label":`${ie.cell}, ${X.subtitle}${Ot===X.subtitle?"":`, ${Ot}`}`,draggable:gn,onDragStart:gn?Fe=>Fe.dataTransfer.setData("text/nc-session",ie.tmuxSession):void 0,onClick:gn?()=>a&&a(ie.tmuxSession):void 0,onDoubleClick:gn?()=>Ce(ie.tmuxSession,"",N):void 0,children:[c.jsx(ys,{position:"local",itemKey:X.key,label:ie.cell,canMove:de,onMove:(Fe,Be)=>oe("local",Fe,Be,V),onStep:Fe=>pe("local",X.key,Fe,V)}),gn?c.jsx("button",{type:"button",className:"nc-side-peek",title:m("cell-peek"),"aria-label":`${m("cell-peek")}: ${ie.cell}`,onClick:ln(X,ie,[],""),children:c.jsx("span",{className:`nc-dot ${Ie}${X.working?" working":""}`})}):c.jsx("span",{className:`nc-dot ${Ie}${X.working?" working":""}`}),c.jsxs("span",{className:"nc-cell-main",children:[c.jsx("b",{title:ie.cell,children:ie.cell}),c.jsx("small",{title:X.subtitle,children:X.subtitle})]}),c.jsx(xu,{item:X,pins:R,hostByRoute:T,route:[],cellName:ie.cell,baseClassName:"nc-pin",togglePin:H,removePin:z,designate:W,clearHost:U}),d&&x.includes("boot")&&Bt(ie),c.jsx("button",{className:`nc-power${ie.tmux?" on":""}${ie.degraded?" warn":""}`,onClick:Fe=>{Fe.stopPropagation(),l&&l({...ie,boot:Dt(ie)})},title:ie.active?m("power-off"):m("power-on"),children:c.jsx(dt,{name:"power",size:14})})]},X.key)})():(()=>{var _e;const ie=X.value;return c.jsxs("div",{"data-roster-key":X.key,"data-position":"local",className:`nc-side-card${St.has(ie.name)?" active":""}`,draggable:!0,onDragStart:Ke=>Ke.dataTransfer.setData("text/nc-session",ie.name),onClick:()=>a&&a(ie.name),onDoubleClick:()=>Ce(ie.name,"",N),children:[c.jsx(ys,{position:"local",itemKey:X.key,label:ie.name,canMove:de,onMove:(Ke,Ie)=>oe("local",Ke,Ie,V),onStep:Ke=>pe("local",X.key,Ke,V)}),c.jsx("span",{className:ie.attached?"nc-dot on":"nc-dot"}),c.jsxs("span",{className:"nc-card-main",children:[c.jsx("b",{children:ie.name}),c.jsxs("small",{children:[ie.preview||ie.cmd||m("windows").replace("{n}",String(ie.windows||0)),((_e=ie.outbox)==null?void 0:_e.count)>0?` · 📦${ie.outbox.count}`:""]})]}),ie.activity?c.jsx("span",{className:"nc-rel",children:sa(ie.activity)}):null,c.jsx("button",{className:`nc-pin${R.includes(X.key)?" on":""}`,title:m("pin"),onClick:Ke=>{Ke.stopPropagation(),H(X.key)},children:R.includes(X.key)?"★":"☆"}),c.jsx("button",{className:`nc-technical${ie.technical?" on":""}`,title:ie.technical?m("mark-normal"):m("mark-technical"),"aria-label":`${ie.technical?m("mark-normal"):m("mark-technical")} ${ie.name}`,onClick:Ke=>{Ke.stopPropagation(),g&&g(ie.name,!ie.technical,[])},children:"T"}),c.jsx("button",{className:"nc-menu",title:m("terminate"),onClick:Ke=>{Ke.stopPropagation(),window.confirm(m("terminate-confirm").replace("{name}",ie.name))&&f&&f(ie.name)},children:"⋯"})]},X.key)})()),Te.length===0&&c.jsx("div",{className:"nc-empty",children:m("no-sessions-short")})]}),le.map(({g:X,nodeRoute:ie,groupView:_e,rawItems:Ke,items:Ie})=>{const Ee=T0(X.health),et=X.fleetState==="stale"?m("fleet-stale"):X.fleetState==="disabled"?m("fleet-off"):"",Ot=X.fleetState==="stale"?"warn":Ee||(X.status==="up"?"on":X.status==="passive"?"":"warn"),gn=[X.health?ku(X.health):"",et].filter(Boolean).join(" · ");return X.kind==="vl"?c.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":De(X),children:[c.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:()=>Y(ie,{open:!_e.open}),onKeyDown:Fe=>{(Fe.key==="Enter"||Fe.key===" ")&&(Fe.preventDefault(),Y(ie,{open:!_e.open}))},children:[c.jsx(ys,{scope:"node",position:"nodes",itemKey:De(X),label:X.label||X.name,onMove:(Fe,Be)=>Qe(Fe,Be,i||[]),onStep:Fe=>ot(De(X),Fe,i||[])}),c.jsx("span",{className:"nc-node-chevron",children:_e.open?"⌄":"›"}),c.jsx("span",{className:`nc-dot ${Ot}`,title:gn}),c.jsx("b",{children:X.label||X.name}),c.jsxs("small",{children:[" · ",X.status==="up"?[m("node-sessions").replace("{n}",String(X.sessions.length)),et].filter(Boolean).join(" · "):Ws(X)]})]}),X.status==="up"&&_e.open&&c.jsxs("div",{className:"nc-side-group",children:[X.sessions.map(Fe=>c.jsxs("div",{className:"nc-side-card nc-vl-session-row",role:"button",tabIndex:0,onClick:()=>ee&&ee(X.peer),onKeyDown:Be=>{(Be.key==="Enter"||Be.key===" ")&&(Be.preventDefault(),ee&&ee(X.peer))},children:[c.jsx("span",{className:"nc-dot on"}),c.jsxs("span",{className:"nc-card-main",children:[c.jsx("b",{children:Fe.name}),c.jsx("small",{children:m("vl-events-title")})]})]},Fe.key)),X.sessions.length===0&&c.jsx("div",{className:"nc-empty",children:m("no-sessions-short")})]})]},`nodo-vl-${ie}-${X.name}`):c.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":De(X),children:[c.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onContextMenu:X.direct&&_?Fe=>{Fe.preventDefault(),Me(X)}:void 0,onClick:()=>Y(ie,{open:!_e.open}),onKeyDown:Fe=>{(Fe.key==="Enter"||Fe.key===" ")&&(Fe.preventDefault(),Y(ie,{open:!_e.open}))},children:[c.jsx(ys,{scope:"node",position:"nodes",itemKey:De(X),label:X.label||X.name,onMove:(Fe,Be)=>Qe(Fe,Be,i||[]),onStep:Fe=>ot(De(X),Fe,i||[])}),c.jsx("span",{className:"nc-node-chevron",children:_e.open?"⌄":"›"}),c.jsx("span",{className:`nc-dot ${Ot}`,title:gn}),c.jsx("b",{children:X.label||X.name}),c.jsxs("small",{children:[" · ",X.status==="up"?[m("node-sessions").replace("{n}",String(Ie.length)),et].filter(Boolean).join(" · "):X.health&&ku(X.health)||Ws(X)]}),c.jsxs("select",{className:"nc-node-filter",value:_e.filter,title:m(`view-${_e.filter}`),onClick:Fe=>Fe.stopPropagation(),onChange:Fe=>Y(ie,{filter:Fe.target.value}),children:[c.jsx("option",{value:"all",children:m("view-all")}),c.jsx("option",{value:"pinned",children:m("view-pinned")}),c.jsx("option",{value:"active",children:m("view-active")}),c.jsx("option",{value:"off",children:m("view-off")}),c.jsx("option",{value:"technical",children:m("view-technical")})]}),X.direct&&_&&c.jsx("button",{type:"button",className:"nc-node-rename",title:m("rename-node"),"aria-label":`${m("rename-node")} ${X.label||X.name}`,onClick:Fe=>{Fe.stopPropagation(),Me(X)},children:"✎"}),X.direct&&X.health&&X.health.managed!==!1&&c.jsx("button",{type:"button",className:`nc-power${X.tunnelStatus==="up"?" on":""}`,title:X.tunnelStatus==="up"?m("power-off"):m("power-on"),onClick:Fe=>{Fe.stopPropagation(),h&&h(X)},children:c.jsx(dt,{name:"power",size:14})})]}),(X.status==="up"||X.cellsPreserved)&&_e.open&&c.jsxs("div",{className:"nc-side-group",children:[Ie.map(Fe=>Fe.type==="cell"?(()=>{const Be=Fe.value,vt=X.route||[X.name],Mn=je(vt),me=Su({hostCell:Mn.hostCell??null,threadStatus:Mn.threadStatus,pins:R,item:Fe}),Se=Vf(me,Mn.hostLease??null),Ae=!!Be.tmux&&!X.cellsPreserved,it=Be.degraded?"warn":Be.tmux&&!X.cellsPreserved?"on":"",st=X.cellsPreserved?`${m("fleet-stale")}`:Fe.working?Fe.subtitle:Be.tmux?m("cell-idle"):m("cell-off"),wt=Se?`${st} · ${m(Se)}`:st;return c.jsxs("div",{"data-roster-key":Fe.key,"data-position":ie,className:`nc-side-card nc-cell${Ae?" live":""}${X.cellsPreserved?" preserved":""}${St.has(Be.key)?" active":""}`,title:wt,draggable:Ae,onDragStart:Ae?cn=>cn.dataTransfer.setData("text/nc-session",Be.key):void 0,onClick:Ae?()=>a&&a(Be.key):void 0,onDoubleClick:Ae?()=>Ce(Be.tmuxSession,ie,X.instanceId):void 0,children:[c.jsx(ys,{position:ie,itemKey:Fe.key,label:Be.cell,canMove:de,onMove:(cn,$t)=>oe(ie,cn,$t,Ke),onStep:cn=>pe(ie,Fe.key,cn,Ke)}),Ae?c.jsx("button",{type:"button",className:"nc-side-peek",title:m("cell-peek"),"aria-label":`${m("cell-peek")}: ${Be.cell}`,onClick:ln(Fe,Be,X.route||[X.name],X.label||X.name),children:c.jsx("span",{className:`nc-dot ${it}${Fe.working?" working":""}`})}):c.jsx("span",{className:`nc-dot ${it}${Fe.working?" working":""}`}),c.jsxs("span",{className:"nc-card-main",children:[c.jsx("b",{children:Be.cell}),c.jsx("small",{title:Fe.subtitle,children:Fe.subtitle})]}),c.jsx(xu,{item:Fe,pins:R,hostByRoute:T,route:vt,cellName:Be.cell,baseClassName:"nc-pin",togglePin:H,removePin:z,designate:W,clearHost:U}),d&&(X.capabilities||[]).includes("boot")&&Bt(Be,X.route||[]),(X.capabilities||[]).includes(Be.active?"down":"up")&&c.jsx("button",{className:`nc-power${Be.active?" on":""}${Be.degraded?" warn":""}`,onClick:cn=>{cn.stopPropagation(),l&&l({...Be,boot:Dt(Be,X.route||[]),route:X.route,availableEngines:X.engines||[]})},title:Be.active?m("power-off"):m("power-on"),children:c.jsx(dt,{name:"power",size:14})})]},Fe.key)})():(()=>{const Be=Fe.value;return c.jsxs("div",{"data-roster-key":Fe.key,"data-position":ie,className:`nc-side-card${St.has(Be.key)?" active":""}`,draggable:!0,onDragStart:vt=>vt.dataTransfer.setData("text/nc-session",Be.key),onClick:()=>a&&a(Be.key),onDoubleClick:()=>Ce(Be.name,Be.node||ie,X.instanceId),children:[c.jsx(ys,{position:ie,itemKey:Fe.key,label:Be.name,canMove:de,onMove:(vt,Mn)=>oe(ie,vt,Mn,Ke),onStep:vt=>pe(ie,Fe.key,vt,Ke)}),c.jsx("span",{className:Be.attached?"nc-dot on":"nc-dot"}),c.jsxs("span",{className:"nc-card-main",children:[c.jsx("b",{children:Be.name}),c.jsx("small",{children:Be.preview?Be.preview:Be.cmd?Be.cmd:m("windows").replace("{n}",String(Be.windows||0))})]}),Be.activity?c.jsx("span",{className:"nc-rel",children:sa(Be.activity)}):null,c.jsx("button",{className:`nc-pin${R.includes(Fe.key)?" on":""}`,title:m("pin"),onClick:vt=>{vt.stopPropagation(),H(Fe.key)},children:R.includes(Fe.key)?"★":"☆"}),c.jsx("button",{className:`nc-technical${Be.technical?" on":""}`,title:Be.technical?m("mark-normal"):m("mark-technical"),"aria-label":`${Be.technical?m("mark-normal"):m("mark-technical")} ${Be.name}`,onClick:vt=>{vt.stopPropagation(),g&&g(Be.name,!Be.technical,X.route||[])},children:"T"}),c.jsx("button",{className:"nc-menu",title:m("terminate"),onClick:vt=>{vt.stopPropagation(),window.confirm(m("terminate-confirm").replace("{name}",Be.name))&&f&&f(Be.name,X.route)},children:"⋯"})]},Fe.key)})()),Ie.length===0&&c.jsx("div",{className:"nc-empty",children:m("no-sessions-short")})]})]},`nodo-${(X.route||[X.name]).join("/")}`)})]}),c.jsx("div",{className:"nc-side-lang",children:m0.map((X,ie)=>c.jsxs("span",{children:[ie>0&&" · ",c.jsx("button",{className:`nc-lang-btn${P===X?" on":""}`,onClick:()=>A(X),title:X,children:X.toUpperCase()})]},X))}),c.jsx("div",{className:"nc-side-resize",onPointerDown:jt,title:""}),ge&&(()=>{const X=ge.value,ie=ge.nodeRoute?i.find(Ke=>(Ke.route||[Ke.name]).join("/")===ge.nodeRoute)||{}:null,_e=ge.nodeRoute?ie.route||[ge.nodeRoute]:[];return c.jsx(w1,{row:Ft(ge,X,_e,ge.nodeLabel||"",ie&&ie.sessions),token:q,initialSource:It,onClose:()=>{Mt(null),tn("preview")}})})()]})}function hA({label:t,count:e,state:n,onToggle:i,onFilter:s}){return c.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:i,onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),i())},children:[c.jsx("span",{className:"nc-node-chevron",children:n.open?"⌄":"›"}),c.jsx("span",{className:"nc-dot on"}),c.jsx("b",{children:t}),c.jsxs("small",{children:[" · ",m("node-sessions").replace("{n}",String(e))]}),c.jsxs("select",{className:"nc-node-filter",value:n.filter,title:m(`view-${n.filter}`),onClick:a=>a.stopPropagation(),onChange:a=>s(a.target.value),children:[c.jsx("option",{value:"all",children:m("view-all")}),c.jsx("option",{value:"pinned",children:m("view-pinned")}),c.jsx("option",{value:"active",children:m("view-active")}),c.jsx("option",{value:"off",children:m("view-off")}),c.jsx("option",{value:"technical",children:m("view-technical")})]})]})}function fA(t,e,n){return!t&&e?n+1:n}function pA({tileKey:t,node:e,nodeGroups:n,sessionsAlive:i}={}){const s=e&&Array.isArray(n)?n.find(a=>Array.isArray(a==null?void 0:a.route)&&a.route.join("/")===e):null;return s&&s.status!=="up"?!0:!i||i.has(t)}const Um="nc_input_preferences_v1",ff="nc-input-preferences",b1=Object.freeze(["double-tap","single-tap","never"]),S1=Object.freeze(["full","compact"]),kr=Object.freeze({terminalKeyboardGesture:"double-tap",keybarKeepsKeyboardClosed:!0,voiceKeepsKeyboardClosed:!0,showKeybarEnter:!0,keybarLayout:"full"});function Wm(t){const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{};return{terminalKeyboardGesture:b1.includes(e.terminalKeyboardGesture)?e.terminalKeyboardGesture:kr.terminalKeyboardGesture,keybarKeepsKeyboardClosed:typeof e.keybarKeepsKeyboardClosed=="boolean"?e.keybarKeepsKeyboardClosed:kr.keybarKeepsKeyboardClosed,voiceKeepsKeyboardClosed:typeof e.voiceKeepsKeyboardClosed=="boolean"?e.voiceKeepsKeyboardClosed:kr.voiceKeepsKeyboardClosed,showKeybarEnter:typeof e.showKeybarEnter=="boolean"?e.showKeybarEnter:kr.showKeybarEnter,keybarLayout:S1.includes(e.keybarLayout)?e.keybarLayout:kr.keybarLayout}}function x1(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function Uw(t=x1()){if(!t)return{...kr};try{return Wm(JSON.parse(t.getItem(Um)||"null"))}catch{return{...kr}}}function mA(t,e=x1()){const n=Wm(t);if(e)try{e.setItem(Um,JSON.stringify(n))}catch{}return n}function qm(){const[t,e]=k.useState(Uw);k.useEffect(()=>{const i=s=>{if((s==null?void 0:s.type)==="storage"&&s.key!==Um&&s.key!==null)return;const a=s!=null&&s.detail?Wm(s.detail):Uw();e(a)};return window.addEventListener(ff,i),window.addEventListener("storage",i),()=>{window.removeEventListener(ff,i),window.removeEventListener("storage",i)}},[]);const n=k.useCallback(i=>{e(s=>{const a=mA({...s,...i||{}});return window.dispatchEvent(new CustomEvent(ff,{detail:a})),a})},[]);return[t,n]}function gA({session:t,node:e,ownerId:n,cellName:i,token:s,readonly:a=!1,focused:l,onFocus:d,onClose:h,onOpenSingle:f,alive:g=!0,sessionAlive:y=g,available:_=!0,fontSize:w=jl,onZoom:b,decks:N=[],currentDeck:x,onSendToDeck:E,panelUrl:C="",panelCellId:I="",panelPort:T=0}){const[W]=qm(),U=i||t,Q=k.useRef(()=>{}),ee=k.useRef(()=>!1),q=k.useRef(()=>{}),J=k.useRef(!1),[$,M]=k.useState(!1),[L,j]=k.useState(!1),[O,P]=k.useState(!1),[A,R]=k.useState(!1),[D,H]=k.useState(null),[z,F]=k.useState(0),K=k.useRef(y),ne=e?`${e}:${t}`:t,re=N.filter(Y=>Y.id!==x&&Y.available!==!1);return k.useEffect(()=>{const Y=K.current;!Y&&y&&F(de=>fA(Y,y,de)),K.current=y},[y]),c.jsxs("div",{className:`nc-tile${l?" focused":""}`,onMouseDown:()=>d&&d(ne),children:[c.jsxs("div",{className:"nc-tile-head",draggable:!0,onDragStart:Y=>{Y.dataTransfer.setData("text/nc-session",ne),Y.dataTransfer.effectAllowed="move"},children:[c.jsxs("button",{className:"nc-tile-name",onClick:()=>d&&d(ne),title:e?`${U} · ${e}`:U,children:[c.jsx("span",{className:g?"nc-dot on":"nc-dot"}),c.jsx("b",{children:U})]}),c.jsxs("span",{className:"nc-tile-actions",children:[b&&c.jsx("button",{onClick:()=>b(-1),title:m("zoom-out"),children:c.jsx(dt,{name:"zoomOut",size:14})}),b&&c.jsx("button",{onClick:()=>b(1),title:m("zoom-in"),children:c.jsx(dt,{name:"zoomIn",size:14})}),E&&re.length>0&&c.jsxs("select",{className:"nc-tile-deck",title:m("send-to-deck"),value:"",onMouseDown:Y=>Y.stopPropagation(),onChange:Y=>{const de=Y.target.value;de&&E(ne,de),Y.target.value=""},children:[c.jsx("option",{value:"",children:m("send-to-deck")}),re.map(Y=>c.jsxs("option",{value:Y.id,children:[Y.ownerLabel," · ",Y.name]},Y.id))]}),c.jsx("button",{onClick:()=>j(Y=>!Y),title:m("composer"),children:"⌨"}),c.jsx("button",{onClick:()=>P(Y=>!Y),title:m("files"),children:"📁"}),C&&c.jsx("button",{onClick:()=>R(Y=>!Y),title:m("panel"),"aria-pressed":A,children:c.jsx(dt,{name:"monitor",size:14})}),f&&c.jsx("button",{onClick:()=>f({session:t,node:e,ownerId:n}),title:m("single-view"),children:"↗"}),h&&c.jsx("button",{className:"nc-tile-close",onClick:()=>h(ne),title:m("close"),children:"✕"})]})]}),c.jsxs("div",{className:"nc-tile-body",children:[_?c.jsx($m,{session:t,node:e,token:s,readonly:a,takeSize:!1,focused:l,sendRef:Q,composerRef:ee,actionRef:q,ctrlRef:J,setCtrlArmed:M,onFiles:H,fontSize:w,keyboardGesture:W.terminalKeyboardGesture},`${ne}:${z}`):c.jsx("div",{className:"nc-tile-unavailable",children:m("deck-owner-unavailable")}),_&&O&&c.jsx("div",{className:"nc-tile-files",onMouseDown:Y=>Y.stopPropagation(),children:c.jsx(l1,{session:t,node:e,token:s,filesEvent:D,onClose:()=>P(!1)})})]}),_&&L&&c.jsx("div",{className:"nc-tile-composer",onMouseDown:Y=>Y.stopPropagation(),children:c.jsx(v1,{submitText:Y=>ee.current(Y),token:s,session:t,node:e,ownerId:n,readonly:a,keepKeyboardClosedOnVoice:W.voiceKeepsKeyboardClosed})}),_&&A&&C&&I&&c.jsx(y1,{title:U,onClose:()=>R(!1),children:c.jsx(Hm,{cellId:I,panelUrl:C,route:e?e.split("/"):[],panelPort:T,token:s,title:U})})]})}function C1({session:t,node:e,ownerId:n,cells:i,nodeGroups:s}={}){const a=typeof t=="string"?t:"";if(!a)return null;if(e){const d=Array.isArray(s)?s:[];for(const h of d){if(!h||(Array.isArray(h.route)?h.route:[]).join("/")!==e||n&&h.instanceId&&String(n)!==String(h.instanceId))continue;const g=(Array.isArray(h.cells)?h.cells:[]).find(y=>y&&y.tmuxSession===a);if(g)return g}return null}return(Array.isArray(i)?i:[]).find(d=>d&&d.tmuxSession===a)||null}function Km({session:t,cell:e,node:n,ownerId:i,cells:s,nodeGroups:a}={}){const l=typeof t=="string"?t:"";if(e&&typeof e.cell=="string"&&e.cell)return e.cell;const d=C1({session:l,node:n,ownerId:i,cells:s,nodeGroups:a});return d&&d.cell?d.cell:l}function $u(t,e,n){const i=l=>Number.isInteger(l)&&l>0&&l<65536?l:0;if(t==null)return i(n);if(!Array.isArray(t))return 0;if(t.length===0)return i(n);const s=typeof t[0]=="string"?t[0]:null;return s?i((e&&typeof e=="object"?e:{})[s]):0}const Ww=.2,qw=.28,k1=(t,e)=>Array.from((t==null?void 0:t.types)||[]).includes(e),pf=t=>k1(t,"text/nc-session"),Kw=t=>{var e;return k1(t,"Files")||(((e=t==null?void 0:t.files)==null?void 0:e.length)||0)>0};function vA(t,e){return t&&Array.isArray(e)?e.find(n=>Array.isArray(n==null?void 0:n.route)&&n.route.join("/")===t):null}function _A(t,e,n){const i=(t-n.left)/(n.width||1),s=(e-n.top)/(n.height||1);return i<qw?"left":i>1-qw?"right":s<.5?"top":"bottom"}function yA({layout:t,onLayoutChange:e,token:n,readonly:i=!1,sessionsAlive:s,focusSession:a,onFocus:l,onOpenSingle:d,decks:h=[],currentDeck:f,onSendToDeck:g,cells:y=[],nodeGroups:_=[],panelPort:w=0,nodePanelPorts:b={}}){li();const[N,x]=k.useState(null),E=k.useRef(null),C=k.useRef([]),I=k.useRef(null);function T(L,j){const O=()=>{window.removeEventListener("pointermove",L),window.removeEventListener("pointerup",O),window.removeEventListener("pointercancel",O),window.removeEventListener("blur",O),I.current=null};window.addEventListener("pointermove",L),window.addEventListener("pointerup",O),window.addEventListener("pointercancel",O),window.addEventListener("blur",O),I.current=O}k.useEffect(()=>()=>{I.current&&I.current()},[]),k.useEffect(()=>{const L=()=>x(null);return window.addEventListener("dragend",L),window.addEventListener("drop",L),()=>{window.removeEventListener("dragend",L),window.removeEventListener("drop",L)}},[]);const W=t.columns.length,U=L=>N&&N.col===L&&N.row===void 0,Q=!!N&&N.col===W,ee=(L,j)=>N&&N.col===L&&N.row===j&&N.quadrant?` drop-${N.quadrant}`:"";function q(L){if(L.preventDefault(),Kw(L.dataTransfer)){x(null);return}const j=L.dataTransfer.getData("text/nc-session"),O=N;if(x(null),!j||!O)return;let P;if(O.quadrant){if(P=I2(t,O.col,O.row,O.quadrant),!P)return}else P={col:O.col};e(Ss(t).includes(j)?A2(t,j,P):Cm(t,j,P))}function J(L,j){L.preventDefault(),L.stopPropagation();const O=L.clientX,P=t.columns[j].width,A=E.current&&E.current.clientWidth||1,R=t.columns[j+1];T(H=>{let z=Math.max(Ww,P+(H.clientX-O)/A);if(R){const F=ny(z/(z+R.width));z=F/(1-F)*R.width}e(P2(t,j,z))})}function $(L,j,O){L.preventDefault(),L.stopPropagation();const P=L.clientY,A=t.columns[j].tiles[O].height,R=C.current[j],D=R&&R.clientHeight||1,H=t.columns[j].tiles[O+1];T(F=>{let K=Math.max(Ww,A+(F.clientY-P)/D);if(H){const ne=ny(K/(K+H.height));K=ne/(1-ne)*H.height}e(T2(t,j,O,K))})}function M(L){e(Ru(t,L))}return c.jsxs("div",{className:"nc-grid",ref:E,onDragOver:L=>{if(Kw(L.dataTransfer)){L.preventDefault(),x(null);return}pf(L.dataTransfer)&&(L.preventDefault(),N&&N.col===W||x({col:W}))},onDrop:q,onDragLeave:L=>{const j=L.relatedTarget;(!j||!(E.current&&E.current.contains(j)))&&x(null)},children:[t.columns.flatMap((L,j)=>{const O=[];return O.push(c.jsx("div",{className:`nc-col${U(j)?" drop-newcol":""}`,ref:P=>{C.current[j]=P},style:{flexGrow:L.width,flexBasis:0},onDragOver:P=>{pf(P.dataTransfer)&&(P.preventDefault(),P.stopPropagation(),N&&N.col===j&&N.row===void 0||x({col:j}))},children:L.tiles.flatMap((P,A)=>{const R=[],D=ji(P),H=vA(P.node,_),z=P.unavailable!==!0&&(P.node?(H==null?void 0:H.status)==="up":!s||s.has(D)),F=P.unavailable!==!0&&pA({tileKey:D,node:P.node,nodeGroups:_,sessionsAlive:s}),K=C1({session:P.session,node:P.node,ownerId:P.ownerId,cells:y,nodeGroups:_}),ne=Km({session:P.session,cell:K,node:P.node,ownerId:P.ownerId,cells:y,nodeGroups:_}),re=typeof(K==null?void 0:K.panelUrl)=="string"?K.panelUrl.trim():"",Y=typeof(K==null?void 0:K.cell)=="string"?K.cell:"";return R.push(c.jsx("div",{className:`nc-tile-slot${ee(j,A)}`,style:{flexGrow:P.height,flexBasis:0},onDragOver:de=>{if(!pf(de.dataTransfer))return;de.preventDefault(),de.stopPropagation();const oe=_A(de.clientX,de.clientY,de.currentTarget.getBoundingClientRect());N&&N.col===j&&N.row===A&&N.quadrant===oe||x({col:j,row:A,quadrant:oe})},children:c.jsx(gA,{session:P.session,node:P.node,ownerId:P.ownerId,cellName:ne,token:n,readonly:i,focused:a===D,onFocus:l,onClose:M,onOpenSingle:d,available:P.unavailable!==!0,alive:z,sessionAlive:F,fontSize:P.fontSize,onZoom:de=>e(D2(t,j,A,de)),decks:h,currentDeck:f,onSendToDeck:g,panelUrl:re,panelCellId:Y,panelPort:$u(P.node?P.node.split("/"):[],b,w)})},D)),A<L.tiles.length-1&&R.push(c.jsx("div",{className:"nc-divider-h",onPointerDown:de=>$(de,j,A)},`h${A}`)),R})},`c${j}`)),j<W-1&&O.push(c.jsx("div",{className:"nc-divider-v",onPointerDown:P=>J(P,j)},`v${j}`)),O}),Q&&c.jsx("div",{className:"nc-drop-line-v nc-drop-line-end"}),W===0&&c.jsx("div",{className:"nc-grid-empty",children:m("grid-empty")})]})}const ws="local",Pi=/^[a-f0-9]{16,64}$/;function lo(t,e){return`${t&&Pi.test(t)?t:ws}:${e}`}function Ol(t){const e=String(t||""),n=e.indexOf(":");if(n<1)return null;const i=e.slice(0,n),s=e.slice(n+1);return i!==ws&&!Pi.test(i)||!/^[a-z0-9-]{1,32}$/.test(s)?null:{ownerId:i===ws?null:i,name:s}}function Ju(t){return Array.isArray(t)&&t.length?t.join("/"):""}function Vm(t){return{columns:so(t).columns.map(e=>({width:e.width,tiles:e.tiles.map(n=>({...n}))}))}}function wA(t){const e=new Map;for(const n of Array.isArray(t)?t:[])n&&Pi.test(String(n.instanceId||""))&&Array.isArray(n.route)&&e.set(Ju(n.route),n.instanceId);return e}function bA(t){const e=new Map;for(const n of Array.isArray(t)?t:[])n&&Pi.test(String(n.instanceId||""))&&Array.isArray(n.route)&&e.set(n.instanceId,[...n.route]);return e}function Zp(t,e,n=[]){const i=Vm(t),s=wA(n);for(const a of i.columns)for(const l of a.tiles)l.ownerId||(!l.node&&Pi.test(String(e||""))?l.ownerId=e:l.node&&s.has(l.node)&&(l.ownerId=s.get(l.node)));return i}function cl(t,e){const n=Ol(t);return!n||!n.ownerId||!e||n.ownerId!==e?t:lo(null,n.name)}function em(t,e,n=[]){const i=Vm(t),s=new Map;for(const a of n)a&&Pi.test(String(a.instanceId||""))&&Array.isArray(a.route)&&s.set(a.instanceId,[...a.route]);for(const a of i.columns)for(const l of a.tiles)l.ownerId&&(l.ownerId===e?(delete l.node,delete l.unavailable):s.has(l.ownerId)?(l.node=Ju(s.get(l.ownerId)),delete l.unavailable):l.unavailable=!0);return i}function Vw(t,e,n=[]){const i=Vm(t),s=bA(n);for(const a of i.columns)for(const l of a.tiles)delete l.unavailable,l.ownerId&&(l.ownerId===e?delete l.node:s.has(l.ownerId)&&(l.node=Ju(s.get(l.ownerId))));return i}function E1(t,e,n=[]){const i=Mr(t);if(!i)return null;if(i.ownerId)return i;if(!i.node)return{...i,...Pi.test(String(e||""))?{ownerId:e}:{}};const s=n.find(a=>Ju(a&&a.route)===i.node);return{...i,...s&&Pi.test(String(s.instanceId||""))?{ownerId:s.instanceId}:{}}}const SA=/^[a-z0-9-]{1,32}$/,Ti="main",N1="nc_decks",L1="nc_deck_order_v1",R1=24;function Yw(t){return typeof t!="string"?"":t.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,32).replace(/-+$/,"")}function ca(t){return typeof t=="string"&&SA.test(t)}function xA(t){const e=String(t||"").match(/^\/deck\/([^/]+)\/?$/);if(e){let n;try{n=decodeURIComponent(e[1])}catch{n=e[1]}return ca(n)?n:Ti}return Ti}function CA(t){const e=String(t||"").match(/^\/deck\/([^/]+)\/([^/]+)\/?$/);if(e){let i,s;try{i=decodeURIComponent(e[1]),s=decodeURIComponent(e[2])}catch{return{id:lo(null,Ti),ownerId:null,name:Ti}}if(Pi.test(i)&&ca(s))return{id:lo(i,s),ownerId:i,name:s}}const n=xA(t);return{id:lo(null,n),ownerId:null,name:n}}function mf(t,e){const n=typeof t=="object"&&t?{ownerId:t.ownerId||null,name:t.name}:Ol(t)||{ownerId:null,name:t},i=ca(n.name)?n.name:Ti,s=n.ownerId?`/deck/${encodeURIComponent(n.ownerId)}/${encodeURIComponent(i)}`:i===Ti?"/":`/deck/${encodeURIComponent(i)}`;return e?`${s}#token=${encodeURIComponent(e)}`:s}function M1(t){return t===Ti?"nc_grid_v1":`nc_grid_v1__${t}`}function A1(t){const e=[Ti];if(Array.isArray(t)){for(const n of t)if(ca(n)&&n!==Ti&&!e.includes(n)&&e.push(n),e.length>=R1)break}return e}function ma(){return typeof localStorage<"u"?localStorage:null}function kA(){const t=ma();if(!t)return[Ti];try{return A1(JSON.parse(t.getItem(N1)||"null"))}catch{return[Ti]}}function EA(t){const e=ma();if(e)try{e.setItem(N1,JSON.stringify(A1(t)))}catch{}}function $l(t){return t==="local"||Pi.test(String(t||""))}function Zu(t,e){const n=Ol(t);return!!n&&(n.ownerId||"local")===e}function Cs(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[n,i]of Object.entries(t).slice(0,64)){if(!$l(n)||!Array.isArray(i))continue;const s=[...new Set(i.filter(a=>typeof a=="string"&&a.length<=100&&Zu(a,n)))].slice(0,R1);s.length&&(e[n]=s)}return e}function nu(t=ma()){if(!t)return{};try{return Cs(JSON.parse(t.getItem(L1)||"null"))}catch{return{}}}function gf(t,e=ma()){const n=Cs(t);if(e)try{e.setItem(L1,JSON.stringify(n))}catch{}return n}function ed(t,e){return Array.isArray(t==null?void 0:t[e])?t[e]:[]}function NA(t,e,n,i,s=[]){if(!$l(e)||n===i)return Cs(t);const a=[...new Set(s.filter(y=>Zu(y,e)))];if(!a.includes(n)||!a.includes(i))return Cs(t);const l=ed(t,e).filter(y=>a.includes(y)),d=[...l,...a.filter(y=>!l.includes(y))],h=d.indexOf(n),f=d.indexOf(i);d.splice(h,1);const g=d.indexOf(i);return d.splice(h<f?g+1:g,0,n),Cs({...t,[e]:d})}function LA(t,e,n,i){if(!$l(e)||!Zu(i,e))return Cs(t);const s=ed(t,e);return s.includes(n)?Cs({...t,[e]:s.map(a=>a===n?i:a)}):Cs(t)}function RA(t,e,n){return $l(e)?Cs({...t,[e]:ed(t,e).filter(i=>i!==n)}):Cs(t)}function Gw(t,e={}){const n=new Map;for(const s of Array.isArray(t)?t:[]){const a=s!=null&&s.local?"local":String((s==null?void 0:s.ownerId)||"");!$l(a)||!Zu(s==null?void 0:s.id,a)||(n.has(a)||n.set(a,[]),n.get(a).push(s))}const i=[];for(const[,s]of n){const a=s[0].local?"local":s[0].ownerId,l=ed(e,a),d=new Map(l.map((h,f)=>[h,f]));s.sort((h,f)=>{const g=d.has(h.id)?d.get(h.id):Number.MAX_SAFE_INTEGER,y=d.has(f.id)?d.get(f.id):Number.MAX_SAFE_INTEGER;return g-y}),i.push(...s)}return i}function tm(t){const e=ma();if(!e)return null;try{return JSON.parse(e.getItem(M1(t))||"null")}catch{return null}}function MA(t,e){const n=ma();if(n)try{n.setItem(M1(t),JSON.stringify(e))}catch{}}const Ym="nc_deckbar_collapsed_v1",j1=64;function Gm(t){return t===ws||Pi.test(String(t||""))}function Xm(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};let n=0;for(const[i,s]of Object.entries(t)){if(n>=j1)break;if(Gm(i)){if(s===!0)e[i]=!0;else if(s===!1)e[i]=!1;else continue;n+=1}}return e}function P1(t,e){return Gm(e)&&Object.prototype.hasOwnProperty.call(t||{},e)?t[e]===!0:!0}function AA(t,e){const n=Xm(t);return Gm(e)&&(!Object.prototype.hasOwnProperty.call(n,e)&&Object.keys(n).length>=j1&&delete n[Object.keys(n)[0]],n[e]=!P1(n,e)),n}function T1(){return typeof localStorage<"u"?localStorage:null}function Xw(t=T1()){if(!t)return{};try{return Xm(JSON.parse(t.getItem(Ym)||"null"))}catch{return{}}}function jA(t,e=T1()){const n=Xm(t);if(e)try{e.setItem(Ym,JSON.stringify(n))}catch{}return n}function PA(){const[t,e]=k.useState(Xw);k.useEffect(()=>{const s=a=>{(a.key===Ym||a.key===null)&&e(Xw())};return window.addEventListener("storage",s),()=>window.removeEventListener("storage",s)},[]);const n=k.useCallback(s=>P1(t,s),[t]),i=k.useCallback(s=>{e(a=>jA(AA(a,s)))},[]);return{collapsed:t,isCollapsed:n,toggle:i}}const Qm="nc_deck_presence_v1",Qw=3e4,TA=18e4,D1=1e4,I1=32,DA=/^[A-Za-z0-9_-]{1,64}$/,IA=new Set([...Object.getOwnPropertyNames(Object.prototype),"prototype"]),Jw="working",BA="on",OA="neutral",$A="warn";function Jm(t){return typeof t=="string"&&DA.test(t)&&!IA.has(t)}function B1(t){return typeof t=="string"&&Ol(t)!==null}function Zm(t){return typeof t=="number"&&Number.isFinite(t)&&t>=0}function ua(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};let n=0;for(const[i,s]of Object.entries(t)){if(n>=I1)break;Jm(i)&&(!s||typeof s!="object"||B1(s.deckId)&&Zm(s.ts)&&(e[i]={deckId:s.deckId,ts:s.ts,focus:s.focus===!0,visible:s.visible===!0},n+=1))}return e}function O1(t,e){const n=ua(t);if(!Zm(e))return n;const i={};for(const[s,a]of Object.entries(n)){const l=a.visible?Qw:TA,d=e-l;a.ts>=d&&a.ts<=e+Qw&&(i[s]=a)}return i}function Zw(t,e,n,i){if(!Jm(e)||!Zm(i))return ua(t);const s=O1(t,i);if(!B1(n==null?void 0:n.deckId))return s;if(!Object.prototype.hasOwnProperty.call(s,e)&&Object.keys(s).length>=I1){let a="",l=1/0;for(const[d,h]of Object.entries(s))h.ts<l&&(a=d,l=h.ts);a&&delete s[a]}return s[e]={deckId:n.deckId,ts:i,focus:(n==null?void 0:n.focus)===!0,visible:(n==null?void 0:n.visible)===!0},ua(s)}function zA(t,e){const n=ua(t);if(!Jm(e))return n;const i={...n};return delete i[e],i}function FA(t,e){const n=O1(t,e),i={};for(const s of Object.values(n)){const a=s.focus&&s.visible?Jw:BA;i[s.deckId]!==Jw&&(i[s.deckId]=a)}return i}function $1(){return typeof localStorage<"u"?localStorage:null}function iu(t=$1()){if(!t)return{};try{return ua(JSON.parse(t.getItem(Qm)||"null"))}catch{return{}}}function vf(t,e=$1()){const n=ua(t);if(e)try{e.setItem(Qm,JSON.stringify(n))}catch{}return n}const HA=Math.min(D1,5e3);function UA(){var t,e;try{const n=(e=(t=globalThis.crypto)==null?void 0:t.randomUUID)==null?void 0:e.call(t);if(n)return`w${n.replaceAll("-","")}`}catch{}return`w${Date.now().toString(36)}${Math.random().toString(36).slice(2,14)}`}const WA=UA();function eb(){const t=typeof document<"u"&&typeof document.hasFocus=="function"?document.hasFocus():!0,e=typeof document<"u"&&typeof document.visibilityState=="string"?document.visibilityState!=="hidden":!0;return{focus:t,visible:e}}function qA(t,e=!0){const i=k.useRef(WA).current,s=k.useRef(t);s.current=t;const[a,l]=k.useState(()=>({map:{},now:Date.now()})),d=k.useCallback(()=>{l({map:iu(),now:Date.now()})},[]);k.useEffect(()=>{if(!e)return;const g=()=>{const x=Date.now(),E=Zw(iu(),i,{deckId:s.current,...eb()},x);return vf(E),{map:E,now:x}},y=()=>l(g());y();const _=setInterval(g,D1),w=setInterval(d,HA),b=y,N=x=>{(x.key===Qm||x.key===null)&&d()};return window.addEventListener("focus",b),window.addEventListener("blur",b),typeof document<"u"&&document.addEventListener("visibilitychange",b),window.addEventListener("storage",N),()=>{clearInterval(_),clearInterval(w),window.removeEventListener("focus",b),window.removeEventListener("blur",b),typeof document<"u"&&document.removeEventListener("visibilitychange",b),window.removeEventListener("storage",N);try{vf(zA(iu(),i))}catch{}}},[e,i,d]),k.useEffect(()=>{if(!e)return;const g=Date.now(),y=Zw(iu(),i,{deckId:t,...eb()},g);vf(y),l({map:y,now:g})},[t,e,i]);const h=k.useMemo(()=>e?FA(a.map,a.now):{},[e,a]);return{dotFor:k.useCallback((g,y=!1)=>e?y?$A:h[g]||OA:null,[h,e]),windowId:i}}const tb=52,nb=18;function KA({ownerKey:t,deckId:e,label:n,onMove:i,onStep:s}){const a=k.useRef(null),l=k.useRef(0),[d,h]=k.useState(!1),f=()=>{var N,x,E,C;const b=a.current;(x=(N=b==null?void 0:b.over)==null?void 0:N.classList)==null||x.remove("nc-deck-over"),(C=(E=b==null?void 0:b.source)==null?void 0:E.classList)==null||C.remove("nc-deck-dragging"),l.current&&cancelAnimationFrame(l.current),l.current=0},g=(b=!1)=>{const N=a.current;if(!N)return;const x=N.target;f(),a.current=null,h(!1);try{N.handle.releasePointerCapture(N.pointerId)}catch{}b&&x&&x!==e&&i(e,x)},y=(b,N)=>{var T,W,U,Q,ee,q,J,$;const x=a.current;if(!x)return;x.x=b,x.y=N;const E=(W=(T=document.elementFromPoint(b,N))==null?void 0:T.closest)==null?void 0:W.call(T,"[data-deck-id][data-owner-key]"),C=(U=E==null?void 0:E.dataset)==null?void 0:U.deckId,I=((Q=E==null?void 0:E.dataset)==null?void 0:Q.ownerKey)===t&&C&&C!==e;x.over!==(I?E:null)&&((q=(ee=x.over)==null?void 0:ee.classList)==null||q.remove("nc-deck-over"),x.over=I?E:null,($=(J=x.over)==null?void 0:J.classList)==null||$.add("nc-deck-over")),x.target=I?C:null},_=()=>{var x,E;const b=a.current;if(!b){l.current=0;return}const N=(E=(x=b.container)==null?void 0:x.getBoundingClientRect)==null?void 0:E.call(x);if(N){const C=b.x<N.left+tb?-nb:b.x>N.right-tb?nb:0;C&&(b.container.scrollLeft+=C,y(b.x,b.y))}l.current=requestAnimationFrame(_)};k.useEffect(()=>{const b=x=>{x.key==="Escape"&&a.current&&(x.preventDefault(),g(!1))},N=()=>g(!1);return window.addEventListener("keydown",b),window.addEventListener("blur",N),()=>{window.removeEventListener("keydown",b),window.removeEventListener("blur",N),f(),a.current=null}},[e,t]);const w=b=>{var E;if(b.pointerType==="mouse"&&b.button!==0)return;b.preventDefault(),b.stopPropagation(),b.currentTarget.focus({preventScroll:!0});const N=b.currentTarget.closest("[data-deck-id][data-owner-key]"),x=b.currentTarget.closest(".nc-deckbar");a.current={pointerId:b.pointerId,handle:b.currentTarget,source:N,container:x,target:null,over:null,x:b.clientX,y:b.clientY},(E=N==null?void 0:N.classList)==null||E.add("nc-deck-dragging");try{b.currentTarget.setPointerCapture(b.pointerId)}catch{}h(!0),l.current=requestAnimationFrame(_)};return c.jsx("button",{type:"button",className:`nc-deck-handle${d?" active":""}`,"aria-label":`${m("reorder")} ${n}`,"aria-keyshortcuts":"ArrowLeft ArrowRight",title:m("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(),s(b.key==="ArrowLeft"?-1:1))},onPointerDown:w,onPointerMove:b=>{!a.current||b.pointerId!==a.current.pointerId||(b.preventDefault(),b.stopPropagation(),y(b.clientX,b.clientY))},onPointerUp:b=>{!a.current||b.pointerId!==a.current.pointerId||(b.preventDefault(),b.stopPropagation(),g(!0))},onPointerCancel:()=>g(!1),onLostPointerCapture:()=>{a.current&&g(!1)},children:"↔"})}function VA({decks:t=[],currentDeck:e="local:main",onCreate:n,onRename:i,onDelete:s,onReorder:a,onOpenWindow:l,onNavigate:d,saveState:h="idle",error:f="",sidebarVisible:g,onToggleSidebar:y}){li();const{isCollapsed:_,toggle:w}=PA(),{dotFor:b}=qA(e),[N,x]=k.useState(null),[E,C]=k.useState(""),[I,T]=k.useState(!1),[W,U]=k.useState(""),[Q,ee]=k.useState(""),q=Yw(E),J=ca(q),$=[];for(const P of t){const A=P.local?"local":P.ownerId;let R=$.find(D=>D.key===A);R||(R={key:A,label:P.ownerLabel||(P.local?"Local":A),local:!!P.local,decks:[]},$.push(R)),R.decks.push(P)}const M=async()=>{if(J){T(!0),U("");try{n&&await n(q,N),C(""),x(null)}catch(P){U(String(P.message||P))}T(!1)}},L=P=>{ee(""),l&&l(P.id)||ee(P.id)},j=async P=>{if(!(P.id===e||!d||I||P.available===!1)){T(!0),U("");try{await d(P.id)}catch(A){U(String((A==null?void 0:A.message)||A))}T(!1)}},O=(P,A,R)=>{const D=P.decks.findIndex(z=>z.id===A.id),H=P.decks[D+R];D>=0&&H&&a&&!I&&a(A.id,H.id)};return c.jsxs("div",{className:"nc-deckbar",children:[y&&c.jsx("button",{className:"nc-deck-sidebar-toggle",title:m("toggle-sidebar"),onClick:y,children:g?"◀":"☰"}),c.jsx("span",{className:"nc-deckbar-label",children:m("decks")}),c.jsx("div",{className:"nc-deck-chips",children:$.map(P=>{const A=_(P.key),R=`nc-deck-content-${P.key}`,D=P.local?"Local":P.label,H=P.decks.some(K=>K.id===e),z=(P.decks.find(K=>K.id===e)||{}).name,F=m(P.decks.length===1?"owner-deck-count-one":"owner-deck-count-many").replace("{count}",P.decks.length);return c.jsxs("span",{className:`nc-deck-owner-group${A?" collapsed":""}`,"data-owner-key":P.key,"data-collapsed":A?"1":"0",children:[c.jsxs("button",{type:"button",className:"nc-deck-owner-toggle","aria-expanded":!A,"aria-controls":R,title:m(A?"expand-owner":"collapse-owner").replace("{owner}",D),onClick:()=>{!A&&N===P.key&&(C(""),x(null)),w(P.key)},children:[c.jsx("span",{className:"nc-deck-owner-caret","aria-hidden":"true",children:A?"▸":"▾"}),c.jsx("span",{className:"nc-deck-owner",children:D})]}),A&&c.jsxs("span",{className:"nc-deck-summary",title:F,children:[c.jsx("span",{className:"nc-deck-summary-count",children:P.decks.length}),H&&c.jsxs("span",{className:"nc-deck-summary-current",children:["• ",z]})]}),c.jsxs("span",{id:R,className:"nc-deck-owner-content",hidden:A,children:[P.decks.map(K=>{const ne=b(K.id,K.available===!1);return c.jsxs("span",{"data-deck-id":K.id,"data-owner-key":P.key,className:`nc-deck-chip${K.id===e?" current":""}${K.available===!1?" offline":""}`,children:[ne&&c.jsx(YA,{state:ne}),c.jsx(KA,{ownerKey:P.key,deckId:K.id,label:`${P.label} · ${K.name}`,onMove:(re,Y)=>{a&&!I&&a(re,Y)},onStep:re=>O(P,K,re)}),c.jsxs("button",{className:"nc-deck-open",title:K.available===!1?`${K.ownerLabel} offline`:K.id===e?m("deck-current"):`${K.ownerLabel} · ${K.name}`,disabled:I||K.available===!1,onClick:()=>j(K),children:[K.name,K.id===e?" •":""]}),c.jsx("button",{className:"nc-deck-mini",disabled:K.available===!1,title:m("detach-deck"),onClick:()=>L(K),children:"↗"}),K.name!==Ti&&c.jsxs(c.Fragment,{children:[c.jsx("button",{className:"nc-deck-mini",disabled:K.available===!1,title:m("rename-deck"),onClick:()=>{const re=(typeof window<"u"?window.prompt(m("rename-deck"),K.name):"")||"",Y=Yw(re);ca(Y)&&Y!==K.name&&i&&i(K.id,Y).catch(de=>U(String(de.message||de)))},children:"✎"}),c.jsx("button",{className:"nc-deck-mini nc-deck-del",disabled:K.available===!1,title:m("delete-deck"),onClick:()=>{(typeof window>"u"||window.confirm(m("delete-deck-confirm").replace("{name}",`${K.ownerLabel} · ${K.name}`)))&&s&&s(K.id).catch(re=>U(String(re.message||re)))},children:"✕"})]})]},K.id)}),N===P.key?c.jsxs("span",{className:"nc-deck-add",children:[c.jsx("input",{autoFocus:!0,className:J||!E?"":"invalid",placeholder:m("deck-name"),value:E,onChange:K=>C(K.target.value),onKeyDown:K=>{K.key==="Enter"&&M(),K.key==="Escape"&&(C(""),x(null))}}),E&&J&&q!==E&&c.jsxs("span",{className:"nc-deck-slug",children:["→ ",q]}),c.jsx("button",{className:"nc-deck-ok",disabled:!J||I,onClick:M,children:m("create")}),c.jsx("button",{className:"nc-deck-cancel",onClick:()=>{C(""),x(null)},children:m("cancel")})]}):c.jsxs("button",{className:"nc-deck-newbtn",disabled:I||P.decks.every(K=>K.available===!1),title:`${m("new-deck")} · ${P.label}`,onClick:()=>{C(""),x(P.key)},children:["+ ",m("new")]})]})]},P.key)})}),c.jsx("span",{className:`nc-deck-state ${h}`,title:m("deck-autosave"),children:m(h==="saving"?"saving":h==="saved"?"saved":"deck-autosave")}),(W||f)&&c.jsx("span",{className:"nc-deck-error",children:W||f}),Q&&c.jsx("button",{className:"nc-deck-fallback",onClick:()=>l&&l(Q),children:m("popup-blocked")})]})}function YA({state:t}){if(!t)return null;const e=m(`dot-${t}`);return c.jsx("span",{className:`nc-deck-dot ${t}`,role:"img","aria-label":e,title:e})}var Yo={},_f,ib;function GA(){return ib||(ib=1,_f=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),_f}var yf={},wr={},sb;function po(){if(sb)return wr;sb=1;let t;const e=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return wr.getSymbolSize=function(i){if(!i)throw new Error('"version" cannot be null or undefined');if(i<1||i>40)throw new Error('"version" should be in range from 1 to 40');return i*4+17},wr.getSymbolTotalCodewords=function(i){return e[i]},wr.getBCHDigit=function(n){let i=0;for(;n!==0;)i++,n>>>=1;return i},wr.setToSJISFunction=function(i){if(typeof i!="function")throw new Error('"toSJISFunc" is not a valid function.');t=i},wr.isKanjiModeEnabled=function(){return typeof t<"u"},wr.toSJIS=function(i){return t(i)},wr}var wf={},rb;function eg(){return rb||(rb=1,(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function e(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+n)}}t.isValid=function(i){return i&&typeof i.bit<"u"&&i.bit>=0&&i.bit<4},t.from=function(i,s){if(t.isValid(i))return i;try{return e(i)}catch{return s}}})(wf)),wf}var bf,ob;function XA(){if(ob)return bf;ob=1;function t(){this.buffer=[],this.length=0}return t.prototype={get:function(e){const n=Math.floor(e/8);return(this.buffer[n]>>>7-e%8&1)===1},put:function(e,n){for(let i=0;i<n;i++)this.putBit((e>>>n-i-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),e&&(this.buffer[n]|=128>>>this.length%8),this.length++}},bf=t,bf}var Sf,ab;function QA(){if(ab)return Sf;ab=1;function t(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}return t.prototype.set=function(e,n,i,s){const a=e*this.size+n;this.data[a]=i,s&&(this.reservedBit[a]=!0)},t.prototype.get=function(e,n){return this.data[e*this.size+n]},t.prototype.xor=function(e,n,i){this.data[e*this.size+n]^=i},t.prototype.isReserved=function(e,n){return this.reservedBit[e*this.size+n]},Sf=t,Sf}var xf={},lb;function JA(){return lb||(lb=1,(function(t){const e=po().getSymbolSize;t.getRowColCoords=function(i){if(i===1)return[];const s=Math.floor(i/7)+2,a=e(i),l=a===145?26:Math.ceil((a-13)/(2*s-2))*2,d=[a-7];for(let h=1;h<s-1;h++)d[h]=d[h-1]-l;return d.push(6),d.reverse()},t.getPositions=function(i){const s=[],a=t.getRowColCoords(i),l=a.length;for(let d=0;d<l;d++)for(let h=0;h<l;h++)d===0&&h===0||d===0&&h===l-1||d===l-1&&h===0||s.push([a[d],a[h]]);return s}})(xf)),xf}var Cf={},cb;function ZA(){if(cb)return Cf;cb=1;const t=po().getSymbolSize,e=7;return Cf.getPositions=function(i){const s=t(i);return[[0,0],[s-e,0],[0,s-e]]},Cf}var kf={},ub;function ej(){return ub||(ub=1,(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const e={N1:3,N2:3,N3:40,N4:10};t.isValid=function(s){return s!=null&&s!==""&&!isNaN(s)&&s>=0&&s<=7},t.from=function(s){return t.isValid(s)?parseInt(s,10):void 0},t.getPenaltyN1=function(s){const a=s.size;let l=0,d=0,h=0,f=null,g=null;for(let y=0;y<a;y++){d=h=0,f=g=null;for(let _=0;_<a;_++){let w=s.get(y,_);w===f?d++:(d>=5&&(l+=e.N1+(d-5)),f=w,d=1),w=s.get(_,y),w===g?h++:(h>=5&&(l+=e.N1+(h-5)),g=w,h=1)}d>=5&&(l+=e.N1+(d-5)),h>=5&&(l+=e.N1+(h-5))}return l},t.getPenaltyN2=function(s){const a=s.size;let l=0;for(let d=0;d<a-1;d++)for(let h=0;h<a-1;h++){const f=s.get(d,h)+s.get(d,h+1)+s.get(d+1,h)+s.get(d+1,h+1);(f===4||f===0)&&l++}return l*e.N2},t.getPenaltyN3=function(s){const a=s.size;let l=0,d=0,h=0;for(let f=0;f<a;f++){d=h=0;for(let g=0;g<a;g++)d=d<<1&2047|s.get(f,g),g>=10&&(d===1488||d===93)&&l++,h=h<<1&2047|s.get(g,f),g>=10&&(h===1488||h===93)&&l++}return l*e.N3},t.getPenaltyN4=function(s){let a=0;const l=s.data.length;for(let h=0;h<l;h++)a+=s.data[h];return Math.abs(Math.ceil(a*100/l/5)-10)*e.N4};function n(i,s,a){switch(i){case t.Patterns.PATTERN000:return(s+a)%2===0;case t.Patterns.PATTERN001:return s%2===0;case t.Patterns.PATTERN010:return a%3===0;case t.Patterns.PATTERN011:return(s+a)%3===0;case t.Patterns.PATTERN100:return(Math.floor(s/2)+Math.floor(a/3))%2===0;case t.Patterns.PATTERN101:return s*a%2+s*a%3===0;case t.Patterns.PATTERN110:return(s*a%2+s*a%3)%2===0;case t.Patterns.PATTERN111:return(s*a%3+(s+a)%2)%2===0;default:throw new Error("bad maskPattern:"+i)}}t.applyMask=function(s,a){const l=a.size;for(let d=0;d<l;d++)for(let h=0;h<l;h++)a.isReserved(h,d)||a.xor(h,d,n(s,h,d))},t.getBestMask=function(s,a){const l=Object.keys(t.Patterns).length;let d=0,h=1/0;for(let f=0;f<l;f++){a(f),t.applyMask(f,s);const g=t.getPenaltyN1(s)+t.getPenaltyN2(s)+t.getPenaltyN3(s)+t.getPenaltyN4(s);t.applyMask(f,s),g<h&&(h=g,d=f)}return d}})(kf)),kf}var su={},db;function z1(){if(db)return su;db=1;const t=eg(),e=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],n=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return su.getBlocksCount=function(s,a){switch(a){case t.L:return e[(s-1)*4+0];case t.M:return e[(s-1)*4+1];case t.Q:return e[(s-1)*4+2];case t.H:return e[(s-1)*4+3];default:return}},su.getTotalCodewordsCount=function(s,a){switch(a){case t.L:return n[(s-1)*4+0];case t.M:return n[(s-1)*4+1];case t.Q:return n[(s-1)*4+2];case t.H:return n[(s-1)*4+3];default:return}},su}var Ef={},ul={},hb;function tj(){if(hb)return ul;hb=1;const t=new Uint8Array(512),e=new Uint8Array(256);return(function(){let i=1;for(let s=0;s<255;s++)t[s]=i,e[i]=s,i<<=1,i&256&&(i^=285);for(let s=255;s<512;s++)t[s]=t[s-255]})(),ul.log=function(i){if(i<1)throw new Error("log("+i+")");return e[i]},ul.exp=function(i){return t[i]},ul.mul=function(i,s){return i===0||s===0?0:t[e[i]+e[s]]},ul}var fb;function nj(){return fb||(fb=1,(function(t){const e=tj();t.mul=function(i,s){const a=new Uint8Array(i.length+s.length-1);for(let l=0;l<i.length;l++)for(let d=0;d<s.length;d++)a[l+d]^=e.mul(i[l],s[d]);return a},t.mod=function(i,s){let a=new Uint8Array(i);for(;a.length-s.length>=0;){const l=a[0];for(let h=0;h<s.length;h++)a[h]^=e.mul(s[h],l);let d=0;for(;d<a.length&&a[d]===0;)d++;a=a.slice(d)}return a},t.generateECPolynomial=function(i){let s=new Uint8Array([1]);for(let a=0;a<i;a++)s=t.mul(s,new Uint8Array([1,e.exp(a)]));return s}})(Ef)),Ef}var Nf,pb;function ij(){if(pb)return Nf;pb=1;const t=nj();function e(n){this.genPoly=void 0,this.degree=n,this.degree&&this.initialize(this.degree)}return e.prototype.initialize=function(i){this.degree=i,this.genPoly=t.generateECPolynomial(this.degree)},e.prototype.encode=function(i){if(!this.genPoly)throw new Error("Encoder not initialized");const s=new Uint8Array(i.length+this.degree);s.set(i);const a=t.mod(s,this.genPoly),l=this.degree-a.length;if(l>0){const d=new Uint8Array(this.degree);return d.set(a,l),d}return a},Nf=e,Nf}var Lf={},Rf={},Mf={},mb;function F1(){return mb||(mb=1,Mf.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}),Mf}var gs={},gb;function H1(){if(gb)return gs;gb=1;const t="[0-9]+",e="[A-Z $%*+\\-./:]+";let n="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";n=n.replace(/u/g,"\\u");const i="(?:(?![A-Z0-9 $%*+\\-./:]|"+n+`)(?:.|[\r
156
- ]))+`;gs.KANJI=new RegExp(n,"g"),gs.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),gs.BYTE=new RegExp(i,"g"),gs.NUMERIC=new RegExp(t,"g"),gs.ALPHANUMERIC=new RegExp(e,"g");const s=new RegExp("^"+n+"$"),a=new RegExp("^"+t+"$"),l=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return gs.testKanji=function(h){return s.test(h)},gs.testNumeric=function(h){return a.test(h)},gs.testAlphanumeric=function(h){return l.test(h)},gs}var vb;function mo(){return vb||(vb=1,(function(t){const e=F1(),n=H1();t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(a,l){if(!a.ccBits)throw new Error("Invalid mode: "+a);if(!e.isValid(l))throw new Error("Invalid version: "+l);return l>=1&&l<10?a.ccBits[0]:l<27?a.ccBits[1]:a.ccBits[2]},t.getBestModeForData=function(a){return n.testNumeric(a)?t.NUMERIC:n.testAlphanumeric(a)?t.ALPHANUMERIC:n.testKanji(a)?t.KANJI:t.BYTE},t.toString=function(a){if(a&&a.id)return a.id;throw new Error("Invalid mode")},t.isValid=function(a){return a&&a.bit&&a.ccBits};function i(s){if(typeof s!="string")throw new Error("Param is not a string");switch(s.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+s)}}t.from=function(a,l){if(t.isValid(a))return a;try{return i(a)}catch{return l}}})(Rf)),Rf}var _b;function sj(){return _b||(_b=1,(function(t){const e=po(),n=z1(),i=eg(),s=mo(),a=F1(),l=7973,d=e.getBCHDigit(l);function h(_,w,b){for(let N=1;N<=40;N++)if(w<=t.getCapacity(N,b,_))return N}function f(_,w){return s.getCharCountIndicator(_,w)+4}function g(_,w){let b=0;return _.forEach(function(N){const x=f(N.mode,w);b+=x+N.getBitsLength()}),b}function y(_,w){for(let b=1;b<=40;b++)if(g(_,b)<=t.getCapacity(b,w,s.MIXED))return b}t.from=function(w,b){return a.isValid(w)?parseInt(w,10):b},t.getCapacity=function(w,b,N){if(!a.isValid(w))throw new Error("Invalid QR Code version");typeof N>"u"&&(N=s.BYTE);const x=e.getSymbolTotalCodewords(w),E=n.getTotalCodewordsCount(w,b),C=(x-E)*8;if(N===s.MIXED)return C;const I=C-f(N,w);switch(N){case s.NUMERIC:return Math.floor(I/10*3);case s.ALPHANUMERIC:return Math.floor(I/11*2);case s.KANJI:return Math.floor(I/13);case s.BYTE:default:return Math.floor(I/8)}},t.getBestVersionForData=function(w,b){let N;const x=i.from(b,i.M);if(Array.isArray(w)){if(w.length>1)return y(w,x);if(w.length===0)return 1;N=w[0]}else N=w;return h(N.mode,N.getLength(),x)},t.getEncodedBits=function(w){if(!a.isValid(w)||w<7)throw new Error("Invalid QR Code version");let b=w<<12;for(;e.getBCHDigit(b)-d>=0;)b^=l<<e.getBCHDigit(b)-d;return w<<12|b}})(Lf)),Lf}var Af={},yb;function rj(){if(yb)return Af;yb=1;const t=po(),e=1335,n=21522,i=t.getBCHDigit(e);return Af.getEncodedBits=function(a,l){const d=a.bit<<3|l;let h=d<<10;for(;t.getBCHDigit(h)-i>=0;)h^=e<<t.getBCHDigit(h)-i;return(d<<10|h)^n},Af}var jf={},Pf,wb;function oj(){if(wb)return Pf;wb=1;const t=mo();function e(n){this.mode=t.NUMERIC,this.data=n.toString()}return e.getBitsLength=function(i){return 10*Math.floor(i/3)+(i%3?i%3*3+1:0)},e.prototype.getLength=function(){return this.data.length},e.prototype.getBitsLength=function(){return e.getBitsLength(this.data.length)},e.prototype.write=function(i){let s,a,l;for(s=0;s+3<=this.data.length;s+=3)a=this.data.substr(s,3),l=parseInt(a,10),i.put(l,10);const d=this.data.length-s;d>0&&(a=this.data.substr(s),l=parseInt(a,10),i.put(l,d*3+1))},Pf=e,Pf}var Tf,bb;function aj(){if(bb)return Tf;bb=1;const t=mo(),e=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function n(i){this.mode=t.ALPHANUMERIC,this.data=i}return n.getBitsLength=function(s){return 11*Math.floor(s/2)+6*(s%2)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(s){let a;for(a=0;a+2<=this.data.length;a+=2){let l=e.indexOf(this.data[a])*45;l+=e.indexOf(this.data[a+1]),s.put(l,11)}this.data.length%2&&s.put(e.indexOf(this.data[a]),6)},Tf=n,Tf}var Df,Sb;function lj(){if(Sb)return Df;Sb=1;const t=mo();function e(n){this.mode=t.BYTE,typeof n=="string"?this.data=new TextEncoder().encode(n):this.data=new Uint8Array(n)}return e.getBitsLength=function(i){return i*8},e.prototype.getLength=function(){return this.data.length},e.prototype.getBitsLength=function(){return e.getBitsLength(this.data.length)},e.prototype.write=function(n){for(let i=0,s=this.data.length;i<s;i++)n.put(this.data[i],8)},Df=e,Df}var If,xb;function cj(){if(xb)return If;xb=1;const t=mo(),e=po();function n(i){this.mode=t.KANJI,this.data=i}return n.getBitsLength=function(s){return s*13},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(i){let s;for(s=0;s<this.data.length;s++){let a=e.toSJIS(this.data[s]);if(a>=33088&&a<=40956)a-=33088;else if(a>=57408&&a<=60351)a-=49472;else throw new Error("Invalid SJIS character: "+this.data[s]+`
157
- Make sure your charset is UTF-8`);a=(a>>>8&255)*192+(a&255),i.put(a,13)}},If=n,If}var Bf={exports:{}},Cb;function uj(){return Cb||(Cb=1,(function(t){var e={single_source_shortest_paths:function(n,i,s){var a={},l={};l[i]=0;var d=e.PriorityQueue.make();d.push(i,0);for(var h,f,g,y,_,w,b,N,x;!d.empty();){h=d.pop(),f=h.value,y=h.cost,_=n[f]||{};for(g in _)_.hasOwnProperty(g)&&(w=_[g],b=y+w,N=l[g],x=typeof l[g]>"u",(x||N>b)&&(l[g]=b,d.push(g,b),a[g]=f))}if(typeof s<"u"&&typeof l[s]>"u"){var E=["Could not find a path from ",i," to ",s,"."].join("");throw new Error(E)}return a},extract_shortest_path_from_predecessor_list:function(n,i){for(var s=[],a=i;a;)s.push(a),n[a],a=n[a];return s.reverse(),s},find_path:function(n,i,s){var a=e.single_source_shortest_paths(n,i,s);return e.extract_shortest_path_from_predecessor_list(a,s)},PriorityQueue:{make:function(n){var i=e.PriorityQueue,s={},a;n=n||{};for(a in i)i.hasOwnProperty(a)&&(s[a]=i[a]);return s.queue=[],s.sorter=n.sorter||i.default_sorter,s},default_sorter:function(n,i){return n.cost-i.cost},push:function(n,i){var s={value:n,cost:i};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=e})(Bf)),Bf.exports}var kb;function dj(){return kb||(kb=1,(function(t){const e=mo(),n=oj(),i=aj(),s=lj(),a=cj(),l=H1(),d=po(),h=uj();function f(E){return unescape(encodeURIComponent(E)).length}function g(E,C,I){const T=[];let W;for(;(W=E.exec(I))!==null;)T.push({data:W[0],index:W.index,mode:C,length:W[0].length});return T}function y(E){const C=g(l.NUMERIC,e.NUMERIC,E),I=g(l.ALPHANUMERIC,e.ALPHANUMERIC,E);let T,W;return d.isKanjiModeEnabled()?(T=g(l.BYTE,e.BYTE,E),W=g(l.KANJI,e.KANJI,E)):(T=g(l.BYTE_KANJI,e.BYTE,E),W=[]),C.concat(I,T,W).sort(function(Q,ee){return Q.index-ee.index}).map(function(Q){return{data:Q.data,mode:Q.mode,length:Q.length}})}function _(E,C){switch(C){case e.NUMERIC:return n.getBitsLength(E);case e.ALPHANUMERIC:return i.getBitsLength(E);case e.KANJI:return a.getBitsLength(E);case e.BYTE:return s.getBitsLength(E)}}function w(E){return E.reduce(function(C,I){const T=C.length-1>=0?C[C.length-1]:null;return T&&T.mode===I.mode?(C[C.length-1].data+=I.data,C):(C.push(I),C)},[])}function b(E){const C=[];for(let I=0;I<E.length;I++){const T=E[I];switch(T.mode){case e.NUMERIC:C.push([T,{data:T.data,mode:e.ALPHANUMERIC,length:T.length},{data:T.data,mode:e.BYTE,length:T.length}]);break;case e.ALPHANUMERIC:C.push([T,{data:T.data,mode:e.BYTE,length:T.length}]);break;case e.KANJI:C.push([T,{data:T.data,mode:e.BYTE,length:f(T.data)}]);break;case e.BYTE:C.push([{data:T.data,mode:e.BYTE,length:f(T.data)}])}}return C}function N(E,C){const I={},T={start:{}};let W=["start"];for(let U=0;U<E.length;U++){const Q=E[U],ee=[];for(let q=0;q<Q.length;q++){const J=Q[q],$=""+U+q;ee.push($),I[$]={node:J,lastCount:0},T[$]={};for(let M=0;M<W.length;M++){const L=W[M];I[L]&&I[L].node.mode===J.mode?(T[L][$]=_(I[L].lastCount+J.length,J.mode)-_(I[L].lastCount,J.mode),I[L].lastCount+=J.length):(I[L]&&(I[L].lastCount=J.length),T[L][$]=_(J.length,J.mode)+4+e.getCharCountIndicator(J.mode,C))}}W=ee}for(let U=0;U<W.length;U++)T[W[U]].end=0;return{map:T,table:I}}function x(E,C){let I;const T=e.getBestModeForData(E);if(I=e.from(C,T),I!==e.BYTE&&I.bit<T.bit)throw new Error('"'+E+'" cannot be encoded with mode '+e.toString(I)+`.
158
- Suggested mode is: `+e.toString(T));switch(I===e.KANJI&&!d.isKanjiModeEnabled()&&(I=e.BYTE),I){case e.NUMERIC:return new n(E);case e.ALPHANUMERIC:return new i(E);case e.KANJI:return new a(E);case e.BYTE:return new s(E)}}t.fromArray=function(C){return C.reduce(function(I,T){return typeof T=="string"?I.push(x(T,null)):T.data&&I.push(x(T.data,T.mode)),I},[])},t.fromString=function(C,I){const T=y(C,d.isKanjiModeEnabled()),W=b(T),U=N(W,I),Q=h.find_path(U.map,"start","end"),ee=[];for(let q=1;q<Q.length-1;q++)ee.push(U.table[Q[q]].node);return t.fromArray(w(ee))},t.rawSplit=function(C){return t.fromArray(y(C,d.isKanjiModeEnabled()))}})(jf)),jf}var Eb;function hj(){if(Eb)return yf;Eb=1;const t=po(),e=eg(),n=XA(),i=QA(),s=JA(),a=ZA(),l=ej(),d=z1(),h=ij(),f=sj(),g=rj(),y=mo(),_=dj();function w(U,Q){const ee=U.size,q=a.getPositions(Q);for(let J=0;J<q.length;J++){const $=q[J][0],M=q[J][1];for(let L=-1;L<=7;L++)if(!($+L<=-1||ee<=$+L))for(let j=-1;j<=7;j++)M+j<=-1||ee<=M+j||(L>=0&&L<=6&&(j===0||j===6)||j>=0&&j<=6&&(L===0||L===6)||L>=2&&L<=4&&j>=2&&j<=4?U.set($+L,M+j,!0,!0):U.set($+L,M+j,!1,!0))}}function b(U){const Q=U.size;for(let ee=8;ee<Q-8;ee++){const q=ee%2===0;U.set(ee,6,q,!0),U.set(6,ee,q,!0)}}function N(U,Q){const ee=s.getPositions(Q);for(let q=0;q<ee.length;q++){const J=ee[q][0],$=ee[q][1];for(let M=-2;M<=2;M++)for(let L=-2;L<=2;L++)M===-2||M===2||L===-2||L===2||M===0&&L===0?U.set(J+M,$+L,!0,!0):U.set(J+M,$+L,!1,!0)}}function x(U,Q){const ee=U.size,q=f.getEncodedBits(Q);let J,$,M;for(let L=0;L<18;L++)J=Math.floor(L/3),$=L%3+ee-8-3,M=(q>>L&1)===1,U.set(J,$,M,!0),U.set($,J,M,!0)}function E(U,Q,ee){const q=U.size,J=g.getEncodedBits(Q,ee);let $,M;for($=0;$<15;$++)M=(J>>$&1)===1,$<6?U.set($,8,M,!0):$<8?U.set($+1,8,M,!0):U.set(q-15+$,8,M,!0),$<8?U.set(8,q-$-1,M,!0):$<9?U.set(8,15-$-1+1,M,!0):U.set(8,15-$-1,M,!0);U.set(q-8,8,1,!0)}function C(U,Q){const ee=U.size;let q=-1,J=ee-1,$=7,M=0;for(let L=ee-1;L>0;L-=2)for(L===6&&L--;;){for(let j=0;j<2;j++)if(!U.isReserved(J,L-j)){let O=!1;M<Q.length&&(O=(Q[M]>>>$&1)===1),U.set(J,L-j,O),$--,$===-1&&(M++,$=7)}if(J+=q,J<0||ee<=J){J-=q,q=-q;break}}}function I(U,Q,ee){const q=new n;ee.forEach(function(j){q.put(j.mode.bit,4),q.put(j.getLength(),y.getCharCountIndicator(j.mode,U)),j.write(q)});const J=t.getSymbolTotalCodewords(U),$=d.getTotalCodewordsCount(U,Q),M=(J-$)*8;for(q.getLengthInBits()+4<=M&&q.put(0,4);q.getLengthInBits()%8!==0;)q.putBit(0);const L=(M-q.getLengthInBits())/8;for(let j=0;j<L;j++)q.put(j%2?17:236,8);return T(q,U,Q)}function T(U,Q,ee){const q=t.getSymbolTotalCodewords(Q),J=d.getTotalCodewordsCount(Q,ee),$=q-J,M=d.getBlocksCount(Q,ee),L=q%M,j=M-L,O=Math.floor(q/M),P=Math.floor($/M),A=P+1,R=O-P,D=new h(R);let H=0;const z=new Array(M),F=new Array(M);let K=0;const ne=new Uint8Array(U.buffer);for(let pe=0;pe<M;pe++){const xe=pe<j?P:A;z[pe]=ne.slice(H,H+xe),F[pe]=D.encode(z[pe]),H+=xe,K=Math.max(K,xe)}const re=new Uint8Array(q);let Y=0,de,oe;for(de=0;de<K;de++)for(oe=0;oe<M;oe++)de<z[oe].length&&(re[Y++]=z[oe][de]);for(de=0;de<R;de++)for(oe=0;oe<M;oe++)re[Y++]=F[oe][de];return re}function W(U,Q,ee,q){let J;if(Array.isArray(U))J=_.fromArray(U);else if(typeof U=="string"){let O=Q;if(!O){const P=_.rawSplit(U);O=f.getBestVersionForData(P,ee)}J=_.fromString(U,O||40)}else throw new Error("Invalid data");const $=f.getBestVersionForData(J,ee);if(!$)throw new Error("The amount of data is too big to be stored in a QR Code");if(!Q)Q=$;else if(Q<$)throw new Error(`
159
- The chosen QR Code version cannot contain this amount of data.
160
- Minimum version required to store current data is: `+$+`.
161
- `);const M=I(Q,ee,J),L=t.getSymbolSize(Q),j=new i(L);return w(j,Q),b(j),N(j,Q),E(j,ee,0),Q>=7&&x(j,Q),C(j,M),isNaN(q)&&(q=l.getBestMask(j,E.bind(null,j,ee))),l.applyMask(q,j),E(j,ee,q),{modules:j,version:Q,errorCorrectionLevel:ee,maskPattern:q,segments:J}}return yf.create=function(Q,ee){if(typeof Q>"u"||Q==="")throw new Error("No input text");let q=e.M,J,$;return typeof ee<"u"&&(q=e.from(ee.errorCorrectionLevel,e.M),J=f.from(ee.version),$=l.from(ee.maskPattern),ee.toSJISFunc&&t.setToSJISFunction(ee.toSJISFunc)),W(Q,J,q,$)},yf}var Of={},$f={},Nb;function U1(){return Nb||(Nb=1,(function(t){function e(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let i=n.slice().replace("#","").split("");if(i.length<3||i.length===5||i.length>8)throw new Error("Invalid hex color: "+n);(i.length===3||i.length===4)&&(i=Array.prototype.concat.apply([],i.map(function(a){return[a,a]}))),i.length===6&&i.push("F","F");const s=parseInt(i.join(""),16);return{r:s>>24&255,g:s>>16&255,b:s>>8&255,a:s&255,hex:"#"+i.slice(0,6).join("")}}t.getOptions=function(i){i||(i={}),i.color||(i.color={});const s=typeof i.margin>"u"||i.margin===null||i.margin<0?4:i.margin,a=i.width&&i.width>=21?i.width:void 0,l=i.scale||4;return{width:a,scale:a?4:l,margin:s,color:{dark:e(i.color.dark||"#000000ff"),light:e(i.color.light||"#ffffffff")},type:i.type,rendererOpts:i.rendererOpts||{}}},t.getScale=function(i,s){return s.width&&s.width>=i+s.margin*2?s.width/(i+s.margin*2):s.scale},t.getImageWidth=function(i,s){const a=t.getScale(i,s);return Math.floor((i+s.margin*2)*a)},t.qrToImageData=function(i,s,a){const l=s.modules.size,d=s.modules.data,h=t.getScale(l,a),f=Math.floor((l+a.margin*2)*h),g=a.margin*h,y=[a.color.light,a.color.dark];for(let _=0;_<f;_++)for(let w=0;w<f;w++){let b=(_*f+w)*4,N=a.color.light;if(_>=g&&w>=g&&_<f-g&&w<f-g){const x=Math.floor((_-g)/h),E=Math.floor((w-g)/h);N=y[d[x*l+E]?1:0]}i[b++]=N.r,i[b++]=N.g,i[b++]=N.b,i[b]=N.a}}})($f)),$f}var Lb;function fj(){return Lb||(Lb=1,(function(t){const e=U1();function n(s,a,l){s.clearRect(0,0,a.width,a.height),a.style||(a.style={}),a.height=l,a.width=l,a.style.height=l+"px",a.style.width=l+"px"}function i(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(a,l,d){let h=d,f=l;typeof h>"u"&&(!l||!l.getContext)&&(h=l,l=void 0),l||(f=i()),h=e.getOptions(h);const g=e.getImageWidth(a.modules.size,h),y=f.getContext("2d"),_=y.createImageData(g,g);return e.qrToImageData(_.data,a,h),n(y,f,g),y.putImageData(_,0,0),f},t.renderToDataURL=function(a,l,d){let h=d;typeof h>"u"&&(!l||!l.getContext)&&(h=l,l=void 0),h||(h={});const f=t.render(a,l,h),g=h.type||"image/png",y=h.rendererOpts||{};return f.toDataURL(g,y.quality)}})(Of)),Of}var zf={},Rb;function pj(){if(Rb)return zf;Rb=1;const t=U1();function e(s,a){const l=s.a/255,d=a+'="'+s.hex+'"';return l<1?d+" "+a+'-opacity="'+l.toFixed(2).slice(1)+'"':d}function n(s,a,l){let d=s+a;return typeof l<"u"&&(d+=" "+l),d}function i(s,a,l){let d="",h=0,f=!1,g=0;for(let y=0;y<s.length;y++){const _=Math.floor(y%a),w=Math.floor(y/a);!_&&!f&&(f=!0),s[y]?(g++,y>0&&_>0&&s[y-1]||(d+=f?n("M",_+l,.5+w+l):n("m",h,0),h=0,f=!1),_+1<a&&s[y+1]||(d+=n("h",g),g=0)):h++}return d}return zf.render=function(a,l,d){const h=t.getOptions(l),f=a.modules.size,g=a.modules.data,y=f+h.margin*2,_=h.color.light.a?"<path "+e(h.color.light,"fill")+' d="M0 0h'+y+"v"+y+'H0z"/>':"",w="<path "+e(h.color.dark,"stroke")+' d="'+i(g,f,h.margin)+'"/>',b='viewBox="0 0 '+y+" "+y+'"',x='<svg xmlns="http://www.w3.org/2000/svg" '+(h.width?'width="'+h.width+'" height="'+h.width+'" ':"")+b+' shape-rendering="crispEdges">'+_+w+`</svg>
162
- `;return typeof d=="function"&&d(null,x),x},zf}var Mb;function mj(){if(Mb)return Yo;Mb=1;const t=GA(),e=hj(),n=fj(),i=pj();function s(a,l,d,h,f){const g=[].slice.call(arguments,1),y=g.length,_=typeof g[y-1]=="function";if(!_&&!t())throw new Error("Callback required as last argument");if(_){if(y<2)throw new Error("Too few arguments provided");y===2?(f=d,d=l,l=h=void 0):y===3&&(l.getContext&&typeof f>"u"?(f=h,h=void 0):(f=h,h=d,d=l,l=void 0))}else{if(y<1)throw new Error("Too few arguments provided");return y===1?(d=l,l=h=void 0):y===2&&!l.getContext&&(h=d,d=l,l=void 0),new Promise(function(w,b){try{const N=e.create(d,h);w(a(N,l,h))}catch(N){b(N)}})}try{const w=e.create(d,h);f(null,a(w,l,h))}catch(w){f(w)}}return Yo.create=e.create,Yo.toCanvas=s.bind(null,n.render),Yo.toDataURL=s.bind(null,n.renderToDataURL),Yo.toString=s.bind(null,function(a,l,d){return i.render(a,d)}),Yo}var gj=mj();const vj=am(gj);function Ab(t){return typeof t=="string"?t.trim():t&&typeof t=="object"&&typeof t.data=="string"?t.data.trim():""}function _j(t){const e=String(t||"").trim();if(!e)return{kind:"empty"};const n=K2(e);if(!n||!n.ok)return{kind:"invalid"};const i=[];return n.ssh||i.push("ssh"),n.name||i.push("name"),i.length?{kind:"partial",decoded:n,missing:i}:{kind:"complete",decoded:n}}function yj(t,e,n=new Set,i=!1){if(!e||!e.ok)return t;const s=V2(t,e,n);return e.version===2&&e.name&&!n.has("name")&&!i&&(s.name=e.name),!n.has("label")&&!s.label&&e.label&&(s.label=e.label),s}function jb(t,e,n=new Set,i=!1){const s=String(e||"").trim(),a=_j(s);let l={...t,pairingUrl:s};return(a.kind==="complete"||a.kind==="partial")&&(l={...yj(l,a.decoded,n,i),pairingUrl:s}),{classification:a,form:l}}function yu(t,e){const n=String(e||"").toLowerCase();if(!/^[a-f0-9]{16,64}$/.test(n))return"";const i=String(t||"NexusCrew").replace(/([a-z0-9])([A-Z])/g,"$1 $2");let s=Lr(i);(s==="localhost"||s==="node")&&(s="nexuscrew");const a=n.slice(0,4),l=Math.max(1,32-a.length-1);return`${s.slice(0,l).replace(/-+$/g,"")||"n"}-${a}`}function wj(t,{deviceDefault:e="",localNodeId:n="",localNameDefault:i=""}={}){const s={name:t.name,ssh:t.ssh,pairingUrl:t.pairingUrl,...t.label?{label:t.label}:{},...t.sshPort?{sshPort:Number(t.sshPort)}:{}},a=t.localLabel||e;a&&(s.localLabel=a);const l=String(t.localName||yu(a,n)||i||"").trim();return l&&(s.localName=l),s}function bj(){const t=new Set;let e=!1;return{canAuto(n){return!e&&!t.has(String(n||""))},start(n){return e?!1:(e=!0,t.add(String(n||"")),!0)},finish(){e=!1},reset(n){t.delete(String(n||""))},isBusy(){return e}}}const Sj=["validation","conflict","ssh-start","ssh-ready","join","tunnel-final","confirm","health"];function xj(t){const e=t&&t.data||{},n=typeof e.stage=="string"&&e.stage?e.stage:"",i=typeof e.detail=="string"&&e.detail?e.detail:"";return{stage:n,code:typeof e.code=="string"?e.code:"",detail:i,hint:typeof e.hint=="string"?e.hint:"",suggestedName:typeof e.suggestedName=="string"?e.suggestedName:"",retryable:typeof e.retryable=="boolean"?e.retryable:!n,message:i||String(t&&t.message||t)}}const Cj="modulepreload",kj=function(t){return"/"+t},Pb={},Ej=function(e,n,i){let s=Promise.resolve();if(n&&n.length>0){let l=function(f){return Promise.all(f.map(g=>Promise.resolve(g).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),h=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));s=l(n.map(f=>{if(f=kj(f),f in Pb)return;Pb[f]=!0;const g=f.endsWith(".css"),y=g?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${y}`))return;const _=document.createElement("link");if(_.rel=g?"stylesheet":Cj,g||(_.as="script"),_.crossOrigin="",_.href=f,h&&_.setAttribute("nonce",h),document.head.appendChild(_),g)return new Promise((w,b)=>{_.addEventListener("load",w),_.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${f}`)))})}))}function a(l){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=l,window.dispatchEvent(d),!d.defaultPrevented)throw l}return s.then(l=>{for(const d of l||[])d.status==="rejected"&&a(d.reason);return e().catch(a)})};class mt{constructor(e,n,i,s,a){this._legacyCanvasSize=mt.DEFAULT_CANVAS_SIZE,this._preferredCamera="environment",this._maxScansPerSecond=25,this._lastScanTimestamp=-1,this._destroyed=this._flashOn=this._paused=this._active=!1,this.$video=e,this.$canvas=document.createElement("canvas"),i&&typeof i=="object"?this._onDecode=n:(console.warn(i||s||a?"You're using a deprecated version of the QrScanner constructor which will be removed in the future":"Note that the type of the scan result passed to onDecode will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),this._legacyOnDecode=n),n=typeof i=="object"?i:{},this._onDecodeError=n.onDecodeError||(typeof i=="function"?i:this._onDecodeError),this._calculateScanRegion=n.calculateScanRegion||(typeof s=="function"?s:this._calculateScanRegion),this._preferredCamera=n.preferredCamera||a||this._preferredCamera,this._legacyCanvasSize=typeof i=="number"?i:typeof s=="number"?s:this._legacyCanvasSize,this._maxScansPerSecond=n.maxScansPerSecond||this._maxScansPerSecond,this._onPlay=this._onPlay.bind(this),this._onLoadedMetaData=this._onLoadedMetaData.bind(this),this._onVisibilityChange=this._onVisibilityChange.bind(this),this._updateOverlay=this._updateOverlay.bind(this),e.disablePictureInPicture=!0,e.playsInline=!0,e.muted=!0;let l=!1;if(e.hidden&&(e.hidden=!1,l=!0),document.body.contains(e)||(document.body.appendChild(e),l=!0),i=e.parentElement,n.highlightScanRegion||n.highlightCodeOutline){if(s=!!n.overlay,this.$overlay=n.overlay||document.createElement("div"),a=this.$overlay.style,a.position="absolute",a.display="none",a.pointerEvents="none",this.$overlay.classList.add("scan-region-highlight"),!s&&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{}i.insertBefore(this.$overlay,this.$video.nextSibling)}n.highlightCodeOutline&&(this.$overlay.insertAdjacentHTML("beforeend",'<svg class="code-outline-highlight" preserveAspectRatio="none" style="display:none;width:100%;height:100%;fill:none;stroke:#e9b213;stroke-width:5;stroke-dasharray:25;stroke-linecap:round;stroke-linejoin:round"><polygon/></svg>'),this.$codeOutlineHighlight=this.$overlay.lastElementChild)}this._scanRegion=this._calculateScanRegion(e),requestAnimationFrame(()=>{let d=window.getComputedStyle(e);d.display==="none"&&(e.style.setProperty("display","block","important"),l=!0),d.visibility!=="visible"&&(e.style.setProperty("visibility","visible","important"),l=!0),l&&(console.warn("QrScanner has overwritten the video hiding style to avoid Safari stopping the playback."),e.style.opacity="0",e.style.width="0",e.style.height="0",this.$overlay&&this.$overlay.parentElement&&this.$overlay.parentElement.removeChild(this.$overlay),delete this.$overlay,delete this.$codeOutlineHighlight),this.$overlay&&this._updateOverlay()}),e.addEventListener("play",this._onPlay),e.addEventListener("loadedmetadata",this._onLoadedMetaData),document.addEventListener("visibilitychange",this._onVisibilityChange),window.addEventListener("resize",this._updateOverlay),this._qrEnginePromise=mt.createQrEngine()}static set WORKER_PATH(e){console.warn("Setting QrScanner.WORKER_PATH is not required and not supported anymore. Have a look at the README for new setup instructions.")}static async hasCamera(){try{return!!(await mt.listCameras(!1)).length}catch{return!1}}static async listCameras(e=!1){if(!navigator.mediaDevices)return[];let n=async()=>(await navigator.mediaDevices.enumerateDevices()).filter(s=>s.kind==="videoinput"),i;try{e&&(await n()).every(s=>!s.label)&&(i=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch{}try{return(await n()).map((s,a)=>({id:s.deviceId,label:s.label||(a===0?"Default Camera":`Camera ${a+1}`)}))}finally{i&&(console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"),mt._stopVideoStream(i))}}async hasFlash(){let e;try{if(this.$video.srcObject){if(!(this.$video.srcObject instanceof MediaStream))return!1;e=this.$video.srcObject}else e=(await this._getCameraStream()).stream;return"torch"in e.getVideoTracks()[0].getSettings()}catch{return!1}finally{e&&e!==this.$video.srcObject&&(console.warn("Call hasFlash after successfully starting the scanner to avoid creating a temporary video stream"),mt._stopVideoStream(e))}}isFlashOn(){return this._flashOn}async toggleFlash(){this._flashOn?await this.turnFlashOff():await this.turnFlashOn()}async turnFlashOn(){if(!this._flashOn&&!this._destroyed&&(this._flashOn=!0,this._active&&!this._paused))try{if(!await this.hasFlash())throw"No flash available";await this.$video.srcObject.getVideoTracks()[0].applyConstraints({advanced:[{torch:!0}]})}catch(e){throw this._flashOn=!1,e}}async turnFlashOff(){this._flashOn&&(this._flashOn=!1,await this._restartVideoStream())}destroy(){this.$video.removeEventListener("loadedmetadata",this._onLoadedMetaData),this.$video.removeEventListener("play",this._onPlay),document.removeEventListener("visibilitychange",this._onVisibilityChange),window.removeEventListener("resize",this._updateOverlay),this._destroyed=!0,this._flashOn=!1,this.stop(),mt._postWorkerMessage(this._qrEnginePromise,"close")}async start(){if(this._destroyed)throw Error("The QR scanner can not be started as it had been destroyed.");if((!this._active||this._paused)&&(window.location.protocol!=="https:"&&console.warn("The camera stream is only accessible if the page is transferred via https."),this._active=!0,!document.hidden))if(this._paused=!1,this.$video.srcObject)await this.$video.play();else try{let{stream:e,facingMode:n}=await this._getCameraStream();!this._active||this._paused?mt._stopVideoStream(e):(this._setVideoMirror(n),this.$video.srcObject=e,await this.$video.play(),this._flashOn&&(this._flashOn=!1,this.turnFlashOn().catch(()=>{})))}catch(e){if(!this._paused)throw this._active=!1,e}}stop(){this.pause(),this._active=!1}async pause(e=!1){if(this._paused=!0,!this._active)return!0;this.$video.pause(),this.$overlay&&(this.$overlay.style.display="none");let n=()=>{this.$video.srcObject instanceof MediaStream&&(mt._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return e?(n(),!0):(await new Promise(i=>setTimeout(i,300)),this._paused?(n(),!0):!1)}async setCamera(e){e!==this._preferredCamera&&(this._preferredCamera=e,await this._restartVideoStream())}static async scanImage(e,n,i,s,a=!1,l=!1){let d,h=!1;n&&("scanRegion"in n||"qrEngine"in n||"canvas"in n||"disallowCanvasResizing"in n||"alsoTryWithoutScanRegion"in n||"returnDetailedScanResult"in n)?(d=n.scanRegion,i=n.qrEngine,s=n.canvas,a=n.disallowCanvasResizing||!1,l=n.alsoTryWithoutScanRegion||!1,h=!0):console.warn(n||i||s||a||l?"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=!!i;try{let f,g;[i,f]=await Promise.all([i||mt.createQrEngine(),mt._loadImage(e)]),[s,g]=mt._drawToCanvas(f,d,s,a);let y;if(i instanceof Worker){let _=i;n||mt._postWorkerMessageSync(_,"inversionMode","both"),y=await new Promise((w,b)=>{let N,x,E,C=-1;x=T=>{T.data.id===C&&(_.removeEventListener("message",x),_.removeEventListener("error",E),clearTimeout(N),T.data.data!==null?w({data:T.data.data,cornerPoints:mt._convertPoints(T.data.cornerPoints,d)}):b(mt.NO_QR_CODE_FOUND))},E=T=>{_.removeEventListener("message",x),_.removeEventListener("error",E),clearTimeout(N),b("Scanner error: "+(T?T.message||T:"Unknown Error"))},_.addEventListener("message",x),_.addEventListener("error",E),N=setTimeout(()=>E("timeout"),1e4);let I=g.getImageData(0,0,s.width,s.height);C=mt._postWorkerMessageSync(_,"decode",I,[I.data.buffer])})}else y=await Promise.race([new Promise((_,w)=>window.setTimeout(()=>w("Scanner error: timeout"),1e4)),(async()=>{try{var[_]=await i.detect(s);if(!_)throw mt.NO_QR_CODE_FOUND;return{data:_.rawValue,cornerPoints:mt._convertPoints(_.cornerPoints,d)}}catch(w){if(_=w.message||w,/not implemented|service unavailable/.test(_))return mt._disableBarcodeDetector=!0,mt.scanImage(e,{scanRegion:d,canvas:s,disallowCanvasResizing:a,alsoTryWithoutScanRegion:l});throw`Scanner error: ${_}`}})()]);return h?y:y.data}catch(f){if(!d||!l)throw f;let g=await mt.scanImage(e,{qrEngine:i,canvas:s,disallowCanvasResizing:a});return h?g:g.data}finally{n||mt._postWorkerMessage(i,"close")}}setGrayscaleWeights(e,n,i,s=!0){mt._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:e,green:n,blue:i,useIntegerApproximation:s})}setInversionMode(e){mt._postWorkerMessage(this._qrEnginePromise,"inversionMode",e)}static async createQrEngine(e){if(e&&console.warn("Specifying a worker path is not required and not supported anymore."),e=()=>Ej(()=>import("./qr-scanner-worker.min-D85Z9gVD.js"),[]).then(i=>i.createWorker()),!(!mt._disableBarcodeDetector&&"BarcodeDetector"in window&&BarcodeDetector.getSupportedFormats&&(await BarcodeDetector.getSupportedFormats()).includes("qr_code")))return e();let n=navigator.userAgentData;return n&&n.brands.some(({brand:i})=>/Chromium/i.test(i))&&/mac ?OS/i.test(n.platform)&&await n.getHighEntropyValues(["architecture","platformVersion"]).then(({architecture:i,platformVersion:s})=>/arm/i.test(i||"arm")&&13<=parseInt(s||"13")).catch(()=>!0)?e():new BarcodeDetector({formats:["qr_code"]})}_onPlay(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay(),this.$overlay&&(this.$overlay.style.display=""),this._scanFrame()}_onLoadedMetaData(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay()}_onVisibilityChange(){document.hidden?this.pause():this._active&&this.start()}_calculateScanRegion(e){let n=Math.round(.6666666666666666*Math.min(e.videoWidth,e.videoHeight));return{x:Math.round((e.videoWidth-n)/2),y:Math.round((e.videoHeight-n)/2),width:n,height:n,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame(()=>{if(this.$overlay){var e=this.$video,n=e.videoWidth,i=e.videoHeight,s=e.offsetWidth,a=e.offsetHeight,l=e.offsetLeft,d=e.offsetTop,h=window.getComputedStyle(e),f=h.objectFit,g=n/i,y=s/a;switch(f){case"none":var _=n,w=i;break;case"fill":_=s,w=a;break;default:(f==="cover"?g>y:g<y)?(w=a,_=w*g):(_=s,w=_/g),f==="scale-down"&&(_=Math.min(_,n),w=Math.min(w,i))}var[b,N]=h.objectPosition.split(" ").map((E,C)=>{const I=parseFloat(E);return E.endsWith("%")?(C?a-w:s-_)*I/100:I});h=this._scanRegion.width||n,y=this._scanRegion.height||i,f=this._scanRegion.x||0;var x=this._scanRegion.y||0;g=this.$overlay.style,g.width=`${h/n*_}px`,g.height=`${y/i*w}px`,g.top=`${d+N+x/i*w}px`,i=/scaleX\(-1\)/.test(e.style.transform),g.left=`${l+(i?s-b-_:b)+(i?n-f-h:f)/n*_}px`,g.transform=e.style.transform}})}static _convertPoints(e,n){if(!n)return e;let i=n.x||0,s=n.y||0,a=n.width&&n.downScaledWidth?n.width/n.downScaledWidth:1;n=n.height&&n.downScaledHeight?n.height/n.downScaledHeight:1;for(let l of e)l.x=l.x*a+i,l.y=l.y*n+s;return e}_scanFrame(){!this._active||this.$video.paused||this.$video.ended||("requestVideoFrameCallback"in this.$video?this.$video.requestVideoFrameCallback.bind(this.$video):requestAnimationFrame)(async()=>{if(!(1>=this.$video.readyState)){var e=Date.now()-this._lastScanTimestamp,n=1e3/this._maxScansPerSecond;e<n&&await new Promise(s=>setTimeout(s,n-e)),this._lastScanTimestamp=Date.now();try{var i=await mt.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(s){if(!this._active)return;this._onDecodeError(s)}!mt._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=mt.createQrEngine()),i?(this._onDecode?this._onDecode(i):this._legacyOnDecode&&this._legacyOnDecode(i.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",i.cornerPoints.map(({x:s,y:a})=>`${s},${a}`).join(" ")),this.$codeOutlineHighlight.style.display="")):this.$codeOutlineHighlight&&!this._codeOutlineHighlightRemovalTimeout&&(this._codeOutlineHighlightRemovalTimeout=setTimeout(()=>this.$codeOutlineHighlight.style.display="none",100))}this._scanFrame()})}_onDecodeError(e){e!==mt.NO_QR_CODE_FOUND&&console.log(e)}async _getCameraStream(){if(!navigator.mediaDevices)throw"Camera not found.";let e=/^(environment|user)$/.test(this._preferredCamera)?"facingMode":"deviceId",n=[{width:{min:1024}},{width:{min:768}},{}],i=n.map(s=>Object.assign({},s,{[e]:{exact:this._preferredCamera}}));for(let s of[...i,...n])try{let a=await navigator.mediaDevices.getUserMedia({video:s,audio:!1}),l=this._getFacingMode(a)||(s.facingMode?this._preferredCamera:this._preferredCamera==="environment"?"user":"environment");return{stream:a,facingMode:l}}catch{}throw"Camera not found."}async _restartVideoStream(){let e=this._paused;await this.pause(!0)&&!e&&this._active&&await this.start()}static _stopVideoStream(e){for(let n of e.getTracks())n.stop(),e.removeTrack(n)}_setVideoMirror(e){this.$video.style.transform="scaleX("+(e==="user"?-1:1)+")"}_getFacingMode(e){return(e=e.getVideoTracks()[0])?/rear|back|environment/i.test(e.label)?"environment":/front|user|face/i.test(e.label)?"user":null:null}static _drawToCanvas(e,n,i,s=!1){i=i||document.createElement("canvas");let a=n&&n.x?n.x:0,l=n&&n.y?n.y:0,d=n&&n.width?n.width:e.videoWidth||e.width,h=n&&n.height?n.height:e.videoHeight||e.height;return s||(s=n&&n.downScaledWidth?n.downScaledWidth:d,n=n&&n.downScaledHeight?n.downScaledHeight:h,i.width!==s&&(i.width=s),i.height!==n&&(i.height=n)),n=i.getContext("2d",{alpha:!1}),n.imageSmoothingEnabled=!1,n.drawImage(e,a,l,d,h,0,0,i.width,i.height),[i,n]}static async _loadImage(e){if(e instanceof Image)return await mt._awaitImageLoad(e),e;if(e instanceof HTMLVideoElement||e instanceof HTMLCanvasElement||e instanceof SVGImageElement||"OffscreenCanvas"in window&&e instanceof OffscreenCanvas||"ImageBitmap"in window&&e instanceof ImageBitmap)return e;if(e instanceof File||e instanceof Blob||e instanceof URL||typeof e=="string"){let n=new Image;n.src=e instanceof File||e instanceof Blob?URL.createObjectURL(e):e.toString();try{return await mt._awaitImageLoad(n),n}finally{(e instanceof File||e instanceof Blob)&&URL.revokeObjectURL(n.src)}}else throw"Unsupported image type."}static async _awaitImageLoad(e){e.complete&&e.naturalWidth!==0||await new Promise((n,i)=>{let s=a=>{e.removeEventListener("load",s),e.removeEventListener("error",s),a instanceof ErrorEvent?i("Image load error"):n()};e.addEventListener("load",s),e.addEventListener("error",s)})}static async _postWorkerMessage(e,n,i,s){return mt._postWorkerMessageSync(await e,n,i,s)}static _postWorkerMessageSync(e,n,i,s){if(!(e instanceof Worker))return-1;let a=mt._workerMessageId++;return e.postMessage({id:a,type:n,data:i},s),a}}mt.DEFAULT_CANVAS_SIZE=400;mt.NO_QR_CODE_FOUND="No QR code found";mt._disableBarcodeDetector=!1;mt._workerMessageId=0;function Nj({onResult:t,onClose:e}){const n=k.useRef(null),i=k.useRef(null),s=k.useRef(!1),[a,l]=k.useState("");k.useEffect(()=>{let h=!1;const f=n.current,g=y=>{h||s.current||(s.current=!0,t(y))};return(async()=>{if(typeof navigator>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!="function"){l(m("qr-unsupported"));return}let y=!1;try{y=await mt.hasCamera()}catch{y=!1}if(!y){l(m("qr-no-camera"));return}if(h||!f)return;const _=new mt(f,w=>{const b=Ab(w);b&&g(b)},{returnDetailedScanResult:!0,preferredCamera:"environment",calculateScanRegion:w=>{const b=w.videoWidth||640,N=w.videoHeight||480,x=Math.max(1,Math.round(Math.min(b,N)*.92));return{x:Math.round((b-x)/2),y:Math.round((N-x)/2),width:x,height:x,downScaledWidth:600,downScaledHeight:600}},highlightScanRegion:!0,highlightCodeOutline:!0});i.current=_;try{await _.start()}catch(w){if(h)return;const b=w&&w.name||"";l(m(b==="NotAllowedError"||b==="SecurityError"?"qr-permission":b==="NotFoundError"||b==="OverconstrainedError"||b==="NotReadableError"?"qr-no-camera":"qr-unsupported"))}})(),()=>{h=!0;const y=i.current;if(y){try{y.stop()}catch{}try{y.destroy()}catch{}i.current=null}const _=f,w=_&&_.srcObject;if(w&&typeof w.getTracks=="function"){for(const b of w.getTracks())try{b.stop()}catch{}try{_.srcObject=null}catch{}}}},[]);const d=async h=>{const f=h.target.files&&h.target.files[0];if(h.target.value="",!!f)try{const g=await mt.scanImage(f,{returnDetailedScanResult:!0}),y=Ab(g);if(!y)throw new Error("empty");s.current||(s.current=!0,t(y))}catch{l(m("pairing-qr-invalid"))}};return c.jsx("div",{className:"nc-sheet-overlay nc-qr-overlay",onClick:e,children:c.jsxs("div",{className:"nc-sheet nc-qr-modal",onClick:h=>h.stopPropagation(),children:[c.jsx("div",{className:"nc-sheet-head",children:c.jsx("b",{children:m("scan-qr")})}),c.jsx("video",{ref:n,className:"nc-qr-video",playsInline:!0,muted:!0}),a&&c.jsx("div",{className:"nc-err",role:"alert",children:a}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsxs("label",{className:"nc-btn ghost nc-qr-upload",children:[m("qr-upload"),c.jsx("input",{type:"file",accept:"image/*",hidden:!0,onChange:d})]}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:e,children:m("cancel")})]})]})})}function tg({line:t,note:e}){const[n,i]=k.useState(!1);return t?c.jsxs("div",{className:"nc-authkeys",role:"group",children:[c.jsx("div",{className:"nc-sheet-label",children:m("pair-authkeys-title")}),c.jsx("small",{className:"nc-set-hint",children:e||m("pair-authkeys-hint")}),c.jsx("textarea",{className:"nc-authkeys-line",readOnly:!0,rows:3,value:t,"aria-label":m("pair-authkeys-title"),onFocus:s=>s.target.select()}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:async()=>{i(await qp(t))},children:m(n?"pair-authkeys-copied":"pair-authkeys-copy")})]}):null}const Tb=()=>({name:"",label:"",ssh:"",sshPort:"",pairingUrl:"",localLabel:"",localName:""});function W1({token:t,initial:e="",autoStart:n=!1,deviceDefault:i="",localNodeId:s="",localNameDefault:a="",readonly:l=!1,onSuccess:d,onBusyChange:h}){const[f,g]=k.useState(Tb),[y,_]=k.useState(!1),[w,b]=k.useState(!1),[N,x]=k.useState("idle"),[E,C]=k.useState(null),[I,T]=k.useState(""),[W,U]=k.useState(null),[Q,ee]=k.useState(!1),[q,J]=k.useState(!1),$=k.useRef(bj()),M=k.useRef(new Set),L=N==="busy",j=yu(f.localLabel||i,s)||a,O=q?f.localName:j;k.useEffect(()=>(h&&h(L),()=>{h&&h(!1)}),[L,h]);const P=async F=>{const K=String(F.pairingUrl||"").trim();if($.current.start(K)){x("busy"),C(null),T("");try{const ne=await yk(t,wj({...F,localName:q?F.localName:yu(F.localLabel||i,s)||a},{deviceDefault:i,localNodeId:s,localNameDefault:a}));x("ok"),_(!1),g(Tb()),U(ne&&ne.authorizedKeys?{line:ne.authorizedKeys,note:ne.authorizedKeysNote||""}:null),M.current=new Set,ee(!1),J(!1),$.current.finish(),d&&await d(ne)}catch(ne){const re=xj(ne);C(re),x("idle"),$.current.finish(),re.code==="peer-name-conflict"&&Zf(re.suggestedName)&&(J(!0),M.current.add("localName"),g(Y=>({...Y,localName:re.suggestedName}))),(re.stage==="validation"||re.stage==="conflict"||re.stage==="ssh-start"||re.stage==="ssh-ready"||String(re.code||"").startsWith("ssh-"))&&_(!0)}}},A=(F,K=!0)=>{const{classification:ne,form:re}=jb(f,F,M.current,Q),Y=re.pairingUrl;if(C(null),T(""),N==="ok"&&x("idle"),g(re),ne.kind==="invalid"){C({stage:"validation",code:"bad-link",message:m("pair-invalid-link"),hint:m("pair-invalid-hint"),retryable:!0});return}if(ne.kind==="partial"){_(!0),T(ne.missing.includes("ssh")?m("pair-missing-ssh"):m("pair-missing-name"));return}ne.kind==="complete"&&K&&!l&&$.current.canAuto(Y)&&P(re)};k.useEffect(()=>{e&&A(e,n)},[]);const R=()=>{const F=String(f.pairingUrl||"").trim(),{classification:K,form:ne}=jb(f,F,M.current,Q);if(g(ne),T(""),C(null),K.kind==="empty"){C({stage:"validation",message:m("pairing-required"),retryable:!0});return}if(K.kind==="invalid"){C({stage:"validation",code:"bad-link",message:m("pair-invalid-link"),hint:m("pair-invalid-hint"),retryable:!0});return}if(!ne.ssh||!ne.name){_(!0),T(ne.ssh?m("pair-missing-name"):m("pair-missing-ssh"));return}if(ne.label&&!oa(ne.label)){C({stage:"validation",message:m("err-label"),retryable:!0});return}if(ne.localLabel&&!oa(ne.localLabel)){C({stage:"validation",message:m("err-label"),retryable:!0});return}const re=q?ne.localName:yu(ne.localLabel||i,s)||a;if(!Zf(re)||re==="localhost"){_(!0),C({stage:"validation",code:"bad-local-name",message:m("err-local-name"),retryable:!0});return}$.current.reset(F),P(ne)},D=async()=>{try{if(!navigator.clipboard||typeof navigator.clipboard.readText!="function")throw new Error("unsupported");const F=await navigator.clipboard.readText();F&&F.trim()?A(F):T(m("pair-clipboard-empty"))}catch{T(m("pair-clipboard-denied"))}},H=(F,K)=>{M.current.add(F),g(ne=>({...ne,[F]:K}))},z=E&&E.stage&&(Sj.includes(E.stage)||E.stage==="internal")?m(`pair-stage-${E.stage}`):m("pair-stage-generic");return c.jsxs("div",{className:"nc-set-form nc-pair-card",children:[c.jsx("div",{className:"nc-sheet-label",children:m("pair-card-title")}),c.jsx("div",{className:"nc-set-info",children:m("pair-card-help")}),c.jsx("input",{className:"nc-pair-input",placeholder:m("pair-paste-ph"),value:f.pairingUrl,disabled:l||L,onChange:F=>{g({...f,pairingUrl:F.target.value}),C(null),T("")},onPaste:F=>{const K=F.clipboardData&&F.clipboardData.getData("text")||"";K.trim()&&(F.preventDefault(),A(K))},onKeyDown:F=>{F.key==="Enter"&&(F.preventDefault(),R())}}),c.jsxs("div",{className:"nc-pair-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:l||L,onClick:D,children:m("pair-paste-btn")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:l||L,onClick:()=>b(!0),children:m("scan-qr")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:l||L,title:l?m("settings-readonly"):"",onClick:R,children:m("test-and-connect")})]}),c.jsxs("div",{className:"nc-pair-status","aria-live":"polite",children:[L&&c.jsx("div",{className:"nc-pair-progress",children:m("pair-progress")}),N==="ok"&&c.jsx("div",{className:"nc-set-test ok",children:m("node-connected")}),N==="ok"&&W&&c.jsx(tg,{line:W.line,note:W.note}),I&&c.jsx("div",{className:"nc-set-hint nc-pair-notice",children:I}),E&&c.jsxs("div",{className:"nc-err",role:"alert",children:[c.jsx("b",{children:z})," — ",E.message,E.hint&&c.jsx("div",{className:"nc-pair-hint",children:E.hint}),E.retryable&&c.jsx("div",{children:c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:l||L,onClick:R,children:m("pair-retry")})})]})]}),c.jsxs("button",{type:"button",className:"nc-btn ghost nc-pair-advanced-toggle",disabled:L,onClick:()=>_(F=>!F),children:[y?"▾":"▸"," ",m("pair-advanced")]}),y&&c.jsxs("div",{className:"nc-pair-advanced",children:[c.jsxs("label",{className:"nc-field",children:[m("node-display-label"),c.jsx("input",{placeholder:"Home Relay",value:f.label,disabled:l||L,onChange:F=>{M.current.add("label"),g(K=>({...K,label:F.target.value,name:Q?K.name:Lr(F.target.value)}))}})]}),c.jsxs("label",{className:"nc-field",children:[m("node-name-label"),c.jsx("input",{placeholder:m("node-name-ph"),value:f.name,disabled:l||L,onChange:F=>{ee(!0),M.current.add("name"),g(K=>({...K,name:F.target.value?Lr(F.target.value):""}))}})]}),c.jsx("small",{className:"nc-set-hint",children:m("node-slug-hint").replace("{slug}",f.name||"home-relay")}),c.jsxs("label",{className:"nc-field",children:[m("pair-ssh-local-label"),c.jsx("input",{placeholder:"my-relay",value:f.ssh,disabled:l||L,onChange:F=>{M.current.add("ssh"),H("ssh",F.target.value)}}),c.jsx("small",{className:"nc-set-hint",children:m("node-ssh-local-help")})]}),c.jsxs("label",{className:"nc-field",children:[m("node-ssh-port-label"),c.jsx("input",{inputMode:"numeric",placeholder:m("node-ssh-port-help"),value:f.sshPort,disabled:l||L,onChange:F=>H("sshPort",F.target.value.replace(/[^0-9]/g,"").slice(0,5))})]}),c.jsxs("label",{className:"nc-field",children:[m("device-name-label"),c.jsx("input",{placeholder:i||"NexusCrew",value:f.localLabel,disabled:l||L,onChange:F=>H("localLabel",F.target.value)}),c.jsx("small",{className:"nc-set-hint",children:m("device-name-hint")})]}),c.jsxs("label",{className:"nc-field",children:[m("local-route-name-label"),c.jsx("input",{placeholder:j||"nexuscrew-5bd6",value:O,disabled:l||L,onChange:F=>{J(!0),M.current.add("localName"),g(K=>({...K,localName:F.target.value?Lr(F.target.value):""}))}}),c.jsx("small",{className:"nc-set-hint",children:m("local-route-name-hint")})]})]}),w&&c.jsx(Nj,{onResult:F=>{b(!1),A(F)},onClose:()=>b(!1)})]})}const _s={routed:"peer-routed",routedStale:"peer-routed-stale",up:"tunnel-up",down:"tunnel-down",passive:"node-connected-client",vlOnline:"vl-poll-online",vlOffline:"vl-poll-offline"};function ng(t){if(!t||typeof t!="object")return{key:_s.down,up:!1};if(t.kind==="vl")return t.online?{key:_s.vlOnline,up:!0}:{key:_s.vlOffline,up:!1};if(t.kind==="transitive"){const n=t.stale===!0;return{key:n?_s.routedStale:_s.routed,up:!n,routed:!0}}const e=t.tunnel&&t.tunnel.status;return e==="up"?{key:_s.up,up:!0}:e==="passive"?{key:_s.passive,up:!1,passive:!0}:{key:_s.down,up:!1}}function q1(t){if(!t||typeof t!="object")return{key:"peer-private",shortKey:"row-private",shared:!1};if(t.kind==="vl")return{key:"peer-vl-federated",shortKey:"row-vl-federated",shared:!0};if(t.shared!==!0)return{key:"peer-private",shortKey:"row-private",shared:!1};const e=t.visibility||"network";if(e==="relay-only")return{key:"visibility-relay",shortKey:"visibility-relay",shared:!0,visibility:e};if(e==="selected"){const n=Array.isArray(t.selected)?t.selected.length:0;return{key:"visibility-selected",shortKey:"visibility-selected",shared:!0,visibility:e,count:n}}return{key:"visibility-network",shortKey:"visibility-network",shared:!0,visibility:e}}function Lj(t){const n=t.health&&typeof t.health.detail=="string"&&t.health.detail.trim()||m(t.online?_s.vlOnline:_s.vlOffline);return t.ownerLabel?`${t.ownerLabel} · ${n}`:n}function Rj(t){if(!t||typeof t!="object")return null;const e=typeof t.name=="string"?t.name:"";if(!e)return null;const n=t.kind==="transitive";return{name:e,title:typeof t.label=="string"&&t.label.trim()||e,subtitle:t.kind==="vl"?Lj(t):e,reach:ng(t),exposure:q1(t),routed:n,routeLabel:n&&Array.isArray(t.route)?t.route.join(" › "):null}}function Mj(t){if(!t||typeof t!="object"||typeof t.name!="string"||!t.name)return null;const e=t.kind==="transitive";return{name:t.name,title:typeof t.label=="string"&&t.label.trim()||t.name,routed:e,route:e&&Array.isArray(t.route)?[...t.route]:null,ssh:!e&&t.direction==="outbound"&&t.ssh?String(t.ssh):null,inbound:!e&&t.direction==="inbound",transport:t.tunnel&&typeof t.tunnel.transport=="string"&&t.tunnel.transport||null}}function Aj(t){return!t||typeof t!="object"?null:t.kind==="transitive"?{key:"authority-routed",ownerEquivalent:!1,grants:[],model:"none"}:{key:"authority-owner-equivalent",ownerEquivalent:!0,grants:[],model:"none"}}function jj(t,e){if(!t||t.visibility!=="selected")return[];const n=[...new Set(Array.isArray(t.selected)?t.selected:[])],i=new Map;for(const s of Array.isArray(e)?e:[])s&&s.nodeId&&!i.has(s.nodeId)&&i.set(s.nodeId,s);return n.map(s=>{const a=i.get(s);return{id:s,label:a?typeof a.label=="string"&&a.label.trim()||a.name:s,known:!!a}})}function Pj(t,e,n=""){if(!t)return[];const i=new Set(Array.isArray(t.selected)?t.selected:[]),s=String(n||"").trim().toLowerCase(),a=new Set,l=[],d=h=>t.nodeId?h.nodeId===t.nodeId:h.name===t.name;for(const h of Array.isArray(e)?e:[]){if(!h||!h.nodeId||d(h)||i.has(h.nodeId)||a.has(h.nodeId))continue;const f=typeof h.label=="string"&&h.label.trim()||h.name;s&&!`${f} ${h.name}`.toLowerCase().includes(s)||(a.add(h.nodeId),l.push({id:h.nodeId,label:f,name:h.name}))}return l.sort((h,f)=>h.label.localeCompare(f.label))}function Tj(t,{readonly:e=!1,busy:n=!1}={}){if(!t||typeof t!="object")return[];const i=t.actions&&typeof t.actions=="object"?t.actions:{},s=ng(t).up,a=[],l=(d,h,{mutating:f=!0,danger:g=!1}={})=>{a.push({key:d,action:h,danger:g,disabled:n||f&&e})};return i.edit&&l("edit","edit"),i.test&&l("node-test","test",{mutating:!1}),i.disconnect&&s&&l("tunnel-stop","down"),i.connect&&!s&&l("tunnel-start","up"),i.restart&&l("tunnel-restart","restart"),i.remove&&l("delete","remove",{danger:!0}),a}function K1(t){const e=t&&typeof t.cellVisibility=="string"?t.cellVisibility:"all";return["all","none","selected"].includes(e)?e:"all"}function Dj(t,e){if(K1(t)!=="selected")return[];const n=[...new Set(Array.isArray(t.cells)?t.cells:[])];if(!Array.isArray(e))return n.map(s=>({id:s,label:s,known:!0}));const i=new Set(e.map(s=>typeof s=="string"?s:s&&(s.cell||s.id)).filter(Boolean));return n.map(s=>({id:s,label:s,known:i.has(s)}))}function Ij(t,e,n=""){const i=new Set(Array.isArray(t&&t.cells)?t.cells:[]),s=String(n||"").trim().toLowerCase(),a=new Set,l=[];for(const d of Array.isArray(e)?e:[]){const h=typeof d=="string"?d:d&&(d.cell||d.id);!h||i.has(h)||a.has(h)||s&&!h.toLowerCase().includes(s)||(a.add(h),l.push({id:h,label:h}))}return l.sort((d,h)=>d.label.localeCompare(h.label))}function Bj(t,e,{readonly:n=!1,busy:i=!1}={}){const s=Mj(t);return s?{identity:s,reach:ng(t),authority:Aj(t),exposure:q1(t),grants:jj(t,e),cellScope:K1(t),actions:Tj(t,{readonly:n,busy:i}),canEditVisibility:!!(t.actions&&t.actions.visibility)&&t.shared===!0&&t.kind!=="transitive",canEditCellScope:!!(t.actions&&t.actions.edit)&&t.kind!=="transitive"}:null}const Oj=new Set(["update_candidate"]),Db=4096,$j=new Set(["prompt"]),Ib={logs:{limit:50}};function zj(t){if(!t||t.kind!=="vl")return[];const e=Array.isArray(t.capabilities)?t.capabilities:[],n=new Set,i=[];for(const s of e)typeof s!="string"||!s||Oj.has(s)||$j.has(s)||n.has(s)||(n.add(s),i.push(s));return i}function Bb(t){return!!(t&&t.kind==="vl"&&Array.isArray(t.capabilities)&&t.capabilities.includes("prompt"))}function Fj(t){return Ib[t]?{...Ib[t]}:{}}function Hj(t,e){return t?t.inflight&&typeof t.inflight=="object"?{phase:"inflight",kind:t.inflight.kind}:e?t.lastAck&&t.lastAck.id===e.id?{phase:"done",kind:e.kind,status:t.lastAck.status,result:t.lastAck.result,at:t.lastAck.at}:{phase:"submitted",kind:e.kind}:t.lastAck&&typeof t.lastAck=="object"?{phase:"done",kind:null,status:t.lastAck.status,result:t.lastAck.result,at:t.lastAck.at}:null:null}function Uj({title:t,subtitle:e,status:n,footer:i,onClose:s,plain:a=!1,children:l}){const d=k.useRef(null),h=k.useRef(null);return k.useEffect(()=>(h.current=document.activeElement,d.current&&d.current.focus(),()=>{const f=h.current;f&&typeof f.focus=="function"&&document.contains(f)&&f.focus()}),[]),k.useEffect(()=>{const f=g=>{g.key==="Escape"&&(g.stopPropagation(),s&&s())};return document.addEventListener("keydown",f,!0),()=>document.removeEventListener("keydown",f,!0)},[s]),c.jsx("div",{className:"nc-detail-overlay",onMouseDown:f=>{f.target===f.currentTarget&&s&&s()},children:c.jsxs("div",{className:"nc-detail-sheet",ref:d,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":typeof t=="string"?t:void 0,children:[c.jsxs("div",{className:"nc-detail-head",children:[c.jsxs("div",{className:"nc-detail-title",children:[c.jsx("b",{children:t}),e&&c.jsx("small",{children:e})]}),n,c.jsx("button",{type:"button",className:"nc-btn ghost nc-detail-close",onClick:s,"aria-label":m("close"),children:c.jsx(dt,{name:"x",size:14})})]}),c.jsx("div",{className:`nc-detail-body${a?" plain":""}`,children:l}),i&&c.jsx("div",{className:"nc-detail-foot",children:i})]})})}function Go({title:t,hint:e,children:n}){return n==null||n===!1?null:c.jsxs("section",{className:"nc-detail-section",children:[t&&c.jsx("div",{className:"nc-sheet-label",children:t}),e&&c.jsx("small",{className:"nc-set-hint",children:e}),n]})}function Wj({node:t,nodes:e,token:n,readonly:i,refresh:s,onClose:a}){var Ft,ln;li();const[l,d]=k.useState(null),[h,f]=k.useState(null),[g,y]=k.useState(null),[_,w]=k.useState(null),[b,N]=k.useState(!1),[x,E]=k.useState(""),[C,I]=k.useState(!1),[T,W]=k.useState(null),[U,Q]=k.useState(!1),[ee,q]=k.useState(""),[J,$]=k.useState(!1),[M,L]=k.useState(null),[j,O]=k.useState(!1),[P,A]=k.useState(""),R=k.useMemo(()=>Bj(t,e,{readonly:i,busy:!!l}),[t,e,i,l]);if(!R)return null;const{identity:D,reach:H,authority:z,exposure:F,grants:K,actions:ne,canEditVisibility:re,canEditCellScope:Y,cellScope:de}=R,oe=D.routed?{up:H.up,since:null}:ep(t.tunnel,Date.now()),pe=async(V,Te)=>{f(null),d(V);try{await Te()}catch(gt){f(String(gt&&gt.message||gt))}d(null)},xe=V=>{if(V==="edit"){w({label:t.label||t.name,ssh:t.ssh||"",sshPort:t.sshPort?String(t.sshPort):"",autostart:t.autostart===!0,visibility:t.visibility||"network"});return}if(V==="remove"){N(!0);return}pe(`${t.name}:${V}`,async()=>{const Te=await pm(n,t.name,V);V==="test"&&y(Te),await s()})},Qe=(V,Te=Fj(V))=>pe(`${t.nodeId}:${V}`,async()=>{const gt=await B_(n,t.nodeId,V,Te,t.route||[]);L({id:gt.id,kind:V,submittedAt:Date.now()}),await s()}),ot=()=>{const V=P.trim().slice(0,Db);V&&pe(`${t.nodeId}:prompt`,async()=>{const Te=await B_(n,t.nodeId,"prompt",{text:V},t.route||[]);L({id:Te.id,kind:"prompt",submittedAt:Date.now()}),A(""),O(!1),await s()})},De=()=>{if(!oa(_.label)){f(m("err-label"));return}const V=D.inbound?{label:_.label,visibility:_.visibility,selected:_.visibility==="selected"?[...t.selected||[]]:[]}:{label:_.label,ssh:_.ssh,autostart:_.autostart,..._.sshPort?{sshPort:Number(_.sshPort)}:{}};return pe(`${t.name}:edit`,async()=>{await z_(n,t.name,V),w(null),await s()})},je=(V,Te)=>pe(`${t.name}:visibility`,async()=>{await kk(n,t.name,V,Te),await s()}),tt=re&&t.visibility==="selected"?Pj(t,e,x):[],Nt=(V,Te)=>pe(`${t.name}:cell-scope`,async()=>{await z_(n,t.name,V==="selected"?{cellVisibility:V,cells:Array.isArray(Te)?Te:t.cells||[]}:{cellVisibility:V}),await s()}),Ct=async({retry:V=!1}={})=>{if(V&&U)Q(!1);else if(T!==null||U)return;try{const Te=await Wu(n);W(Array.isArray(Te&&Te.cells)?Te.cells:[])}catch{Q(!0)}};k.useEffect(()=>{Y&&de==="selected"&&T===null&&Ct()},[Y,de,T]);const ft=Dj(t,T),ht=de==="selected"?Ij(t,T,ee):[],kt=c.jsxs("span",{className:`nc-set-tunnel${H.up?" up":""}`,children:[m(H.key),oe.since?` · ${oe.since}`:""]}),St=t.kind==="vl",Ut=St?zj(t):[],Mt=St?Hj(t,M):null,It=V=>{const Te=`vl-cmd-${V}`,gt=m(Te);return gt===Te?V:gt},tn=St?[...Ut.map(V=>c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!l||i,title:i?m("settings-readonly"):void 0,onClick:()=>Qe(V),children:It(V)},V)),...Bb(t)?[c.jsx("button",{type:"button",className:`nc-btn ghost${j?" on":""}`,disabled:!!l||i,title:i?m("settings-readonly"):void 0,onClick:()=>O(V=>!V),children:It("prompt")},"prompt")]:[]]:ne.map(V=>c.jsx("button",{type:"button",className:`nc-btn ${V.danger?"danger":"ghost"}`,disabled:V.disabled,title:V.disabled&&i?m("settings-readonly"):void 0,onClick:()=>xe(V.action),children:V.action==="remove"?c.jsxs(c.Fragment,{children:[c.jsx(dt,{name:"trash",size:14})," ",m(V.key)]}):m(V.key)},V.action));return c.jsxs(Uj,{title:D.title,subtitle:D.name,status:kt,footer:tn,onClose:a,children:[c.jsxs(Go,{title:m("node-detail-reach"),children:[c.jsxs("dl",{className:"nc-detail-facts",children:[D.route&&c.jsxs(c.Fragment,{children:[c.jsx("dt",{children:m("node-detail-route")}),c.jsx("dd",{children:D.route.join(" › ")})]}),D.ssh&&c.jsxs(c.Fragment,{children:[c.jsx("dt",{children:m("node-detail-ssh")}),c.jsxs("dd",{children:[D.ssh,t.sshPort?`:${t.sshPort}`:""]})]}),D.transport&&c.jsxs(c.Fragment,{children:[c.jsx("dt",{children:m("node-detail-transport")}),c.jsx("dd",{children:D.transport})]}),St&&t.ownerLabel&&c.jsxs(c.Fragment,{children:[c.jsx("dt",{children:m("node-detail-owner")}),c.jsx("dd",{children:t.ownerLabel})]})]}),((Ft=t.health)==null?void 0:Ft.detail)&&c.jsx("div",{className:`nc-set-test${St?t.health.state==="running"?" ok":t.health.state==="starting"?"":" ko":t.health.status==="healthy"?" ok":t.health.status==="passive"?"":" ko"}`,children:t.health.detail}),(()=>{const V=N2(t.health);return V?V.line?c.jsx(tg,{line:V.line,note:V.note}):c.jsx("small",{className:"nc-set-hint",children:V.note}):null})(),g&&c.jsxs("div",{className:`nc-set-test${g.ok?" ok":" ko"}`,children:[g.result,g.detail?` — ${g.detail}`:""]})]}),St&&c.jsxs(Go,{title:m("node-detail-command"),children:[Ut.length===0&&!Bb(t)&&c.jsx("small",{className:"nc-set-hint",children:m("vl-no-commands")}),j&&c.jsxs("div",{className:"nc-vl-prompt",children:[c.jsx("textarea",{value:P,maxLength:Db,placeholder:m("vl-prompt-placeholder"),"aria-label":m("vl-prompt-placeholder"),disabled:!!l||i,onChange:V=>A(V.target.value)}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:!!l||i||!P.trim(),onClick:ot,children:m("vl-prompt-send")})]}),Mt&&c.jsxs("div",{className:`nc-set-test${Mt.phase==="done"?Mt.status==="ok"?" ok":" ko":""}`,children:[Mt.kind&&`${It(Mt.kind)}: `,Mt.phase==="submitted"&&m("vl-cmd-phase-submitted"),Mt.phase==="inflight"&&m("vl-cmd-phase-inflight"),Mt.phase==="done"&&m(Mt.status==="ok"?"vl-cmd-phase-done-ok":"vl-cmd-phase-done-error"),Mt.phase==="done"&&((ln=Mt.result)!=null&&ln.detail)?` — ${Mt.result.detail}`:""]})]}),c.jsxs(Go,{title:m("node-detail-authority"),children:[c.jsx("div",{className:"nc-set-info",children:m(z.key)}),z.grants.length===0&&c.jsx("small",{className:"nc-set-hint",children:m(Y?"authority-no-grants":"authority-no-grants-elsewhere")})]}),c.jsxs(Go,{title:m("node-detail-network-view"),children:[c.jsx("div",{className:"nc-set-info",children:m(St?F.key:F.shared?"peer-shared":"peer-private")}),re&&c.jsxs(c.Fragment,{children:[c.jsxs("label",{className:"nc-field",children:[m("peer-visibility"),c.jsxs("select",{value:t.visibility||"network",disabled:i||!!l,onChange:V=>je(V.target.value),children:[c.jsx("option",{value:"network",children:m("visibility-network")}),c.jsx("option",{value:"relay-only",children:m("visibility-relay")}),c.jsx("option",{value:"selected",children:m("visibility-selected")})]})]}),t.visibility==="selected"&&c.jsxs("div",{className:"nc-detail-grants",children:[K.length===0&&c.jsx("small",{className:"nc-set-hint",children:m("node-grant-none")}),K.map(V=>c.jsxs("div",{className:`nc-detail-grant${V.known?"":" unknown"}`,children:[c.jsxs("span",{children:[V.label,V.known?"":` — ${m("node-grant-unknown")}`]}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||!!l,onClick:()=>je("selected",(t.selected||[]).filter(Te=>Te!==V.id)),children:m("node-grant-remove")})]},V.id)),!C&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||!!l,onClick:()=>{I(!0),E("")},children:m("node-grant-add")}),C&&c.jsxs("div",{className:"nc-detail-picker",children:[c.jsx("input",{value:x,placeholder:m("node-grant-search"),disabled:i||!!l,onChange:V=>E(V.target.value)}),c.jsxs("div",{className:"nc-detail-picker-list",children:[tt.length===0&&c.jsx("small",{className:"nc-set-hint",children:m("node-grant-no-candidates")}),tt.map(V=>c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||!!l,onClick:async()=>{await je("selected",[...t.selected||[],V.id]),I(!1),E("")},children:V.label},V.id))]}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!l,onClick:()=>{I(!1),E("")},children:m("cancel")})]})]})]})]}),Y&&c.jsxs(Go,{title:m("cell-scope"),children:[c.jsx("small",{className:"nc-set-hint",children:m("cell-scope-help")}),c.jsx("label",{className:"nc-field",children:c.jsxs("select",{value:de,"aria-label":m("cell-scope"),disabled:i||!!l,onChange:V=>{V.target.value==="selected"&&Ct(),Nt(V.target.value)},children:[c.jsx("option",{value:"all",children:m("cell-scope-all")}),c.jsx("option",{value:"none",children:m("cell-scope-none")}),c.jsx("option",{value:"selected",children:m("cell-scope-selected")})]})}),de==="selected"&&ft.length>0&&c.jsx("small",{className:"nc-set-hint",children:m("cell-scope-reset-warning")}),U&&c.jsx("small",{className:"nc-set-hint",children:m("cell-scope-list-unavailable")}),de==="selected"&&c.jsxs("div",{className:"nc-detail-grants",children:[ft.length===0&&c.jsx("small",{className:"nc-set-hint",children:m("cell-scope-none-granted")}),ft.map(V=>c.jsxs("div",{className:`nc-detail-grant${V.known?"":" unknown"}`,children:[c.jsxs("span",{children:[V.label,V.known?"":` — ${m("cell-scope-unknown")}`]}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||!!l,onClick:()=>Nt("selected",(t.cells||[]).filter(Te=>Te!==V.id)),children:m("node-grant-remove")})]},V.id)),!J&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||!!l,onClick:async()=>{await Ct({retry:!0}),$(!0),q("")},children:m("cell-scope-add")}),J&&c.jsxs("div",{className:"nc-detail-picker",children:[c.jsx("input",{value:ee,placeholder:m("cell-scope-search"),disabled:i||!!l,onChange:V=>q(V.target.value)}),c.jsxs("div",{className:"nc-detail-picker-list",children:[ht.length===0&&c.jsx("small",{className:"nc-set-hint",children:m("cell-scope-no-candidates")}),ht.map(V=>c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||!!l,onClick:async()=>{await Nt("selected",[...t.cells||[],V.id]),$(!1),q("")},children:V.label},V.id))]}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!l,onClick:()=>{$(!1),q("")},children:m("cancel")})]})]})]}),_&&c.jsxs(Go,{title:m("edit"),children:[c.jsxs("label",{className:"nc-field",children:[m("node-display-label"),c.jsx("input",{value:_.label,disabled:!!l,onChange:V=>w({..._,label:V.target.value})})]}),D.inbound?c.jsxs("label",{className:"nc-field",children:[m("peer-visibility"),c.jsxs("select",{value:_.visibility,disabled:!!l,onChange:V=>w({..._,visibility:V.target.value}),children:[c.jsx("option",{value:"network",children:m("visibility-network")}),c.jsx("option",{value:"relay-only",children:m("visibility-relay")}),c.jsx("option",{value:"selected",children:m("visibility-selected")})]})]}):c.jsxs(c.Fragment,{children:[c.jsxs("label",{className:"nc-field",children:[m("node-ssh-label"),c.jsx("input",{value:_.ssh,disabled:!!l,onChange:V=>w({..._,ssh:V.target.value})})]}),c.jsxs("label",{className:"nc-field",children:[m("node-ssh-port-label"),c.jsx("input",{inputMode:"numeric",value:_.sshPort,disabled:!!l,onChange:V=>w({..._,sshPort:V.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:_.autostart,disabled:!!l,onChange:V=>w({..._,autostart:V.target.checked})})," ",m("boot-persist")]})]}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn primary",disabled:!!l,onClick:De,children:m("save")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!l,onClick:()=>w(null),children:m("cancel")})]})]}),b&&c.jsxs("div",{className:"nc-set-confirm",children:[c.jsx("b",{children:m("node-remove-confirm").replace("{name}",D.title)}),c.jsx("small",{children:m("node-remove-warning")}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn danger",disabled:!!l,onClick:()=>pe(`${t.name}:remove`,async()=>{await xk(n,t.name),N(!1),await s(),a&&a()}),children:m("delete")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!l,onClick:()=>N(!1),children:m("cancel")})]})]}),h&&c.jsx("div",{className:"nc-err",children:h})]})}function ig(){return typeof navigator<"u"&&"serviceWorker"in navigator&&typeof window<"u"&&"PushManager"in window&&typeof Notification<"u"}function qj(t){const e="=".repeat((4-t.length%4)%4),n=(t+e).replace(/-/g,"+").replace(/_/g,"/"),i=atob(n),s=new Uint8Array(i.length);for(let a=0;a<i.length;a+=1)s[a]=i.charCodeAt(a);return s}async function Kj(){if(!ig())return"unsupported";if(Notification.permission==="denied")return"denied";try{return await(await navigator.serviceWorker.ready).pushManager.getSubscription()?"subscribed":"idle"}catch{return"idle"}}async function Vj(t){if(!ig())throw new Error("push-unsupported");if(await Notification.requestPermission()!=="granted")throw new Error("push-denied");const n=await pn("/api/push/vapid",t),{publicKey:i}=await n.json();if(!i)throw new Error("vapid non disponibile");const a=await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:qj(i)}),l=await pn("/api/push/subscribe",t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({subscription:a.toJSON()})});if(!l.ok){try{await a.unsubscribe()}catch{}const d=await l.json().catch(()=>({}));throw new Error(d.error||`HTTP ${l.status}`)}return!0}async function Yj(t){if(!ig())return!1;const n=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!n)return!1;const i=n.endpoint;try{await n.unsubscribe()}catch{}try{await pn("/api/push/subscribe",t,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:i})})}catch{}return!0}const nm="nexuscrew.fleet",V1=3,Gj="nexuscrew.cells",Y1=/^[A-Za-z0-9._-]{1,32}$/,td=/^[a-z0-9._-]{1,32}$/,G1=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,X1=new Set(["standard","unsafe"]),Xj=4096,Qj=4096,zu=256,Q1=8192,Jj=4096,Zj=32,eP=64,ru=100,tP=new Set(["format","version","exportedAt","cells","engines","models"]),nP=new Set(["id","cwdRel","engine","boot","model","models","permissionPolicies","commands","systemPrompt","prompt","label","mcp"]),iP=new Set(["id","cwd","engine","boot","model","models","permissionPolicies","systemPrompt","prompt"]);function eo(t){if(typeof t!="string"||t.length>Qj)return null;for(let n=0;n<t.length;n+=1){const i=t.charCodeAt(n);if(i<=31||i===127||i===92)return null}if(t==="")return"";if(t.charAt(0)==="/"||/^[A-Za-z]:/.test(t))return null;const e=[];for(const n of t.split("/"))if(!(n===""||n===".")){if(n==="..")return null;e.push(n)}return e.join("/")}const sP=new Set(["id","label","rc","managed","command","args","envKeys","model","promptMode","promptFlag","panelUrl"]),rP=new Set(["client","provider","credentialProfile","model","permissionPolicy","displayName","protocol","baseUrl","envKey","providerId"]),oP=new Set(["127.0.0.1","localhost","[::1]"]);function sg(t){if(typeof t!="string"||!t||t.length>512||/[\x00-\x1f\x7f]|\s/.test(t))return!1;let e;try{e=new URL(t)}catch{return!1}return!(e.protocol!=="http:"&&e.protocol!=="https:"||!oP.has(e.hostname))}function Us(t,e){return typeof t=="string"&&t.length<=e&&!/[\x00-\x1f\x7f]/.test(t)}function rg(t){const e=String(t||"");return/(?:bearer\s+|authorization\s*[:=]|(?:api[_-]?key|secret|token)\s*[:=])/i.test(e)||/^-{1,2}(?:api[-_]?key|access[-_]?key|auth(?:orization)?[-_]?token|token|secret|password|credential)(?:$|=)/i.test(e)||/\b(?:sk|fw|fpk|hf|zai)[-_][A-Za-z0-9._-]{8,}\b/i.test(e)||/https?:\/\/[^\s/@:]+:[^\s/@]+@/i.test(e)}function xl(t,e){if(t===void 0)return{};if(!t||typeof t!="object"||Array.isArray(t))return null;const n=Object.entries(t);if(n.length>128)return null;const i={};for(const[s,a]of n){if(!td.test(s)||!e(a))return null;i[s]=a}return i}function J1(t){if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(d=>!nP.has(d))||!Y1.test(String(t.id||""))||typeof t.cwdRel!="string")return null;const e=eo(t.cwdRel);if(e===null||!td.test(String(t.engine||""))||t.boot!==void 0&&typeof t.boot!="boolean"||t.model!==void 0&&(typeof t.model!="string"||t.model.length>zu)||t.systemPrompt!==void 0&&t.prompt!==void 0&&t.systemPrompt!==t.prompt)return null;const n=t.systemPrompt===void 0?t.prompt===void 0?"":t.prompt:t.systemPrompt;if(typeof n!="string"||n.length>Q1)return null;const i=xl(t.models,d=>typeof d=="string"&&!!d&&d.length<=zu),s=xl(t.permissionPolicies,d=>X1.has(d)),a=xl(t.commands,d=>Us(d,Jj)&&!rg(d));if(i===null||s===null||a===null)return null;const l={id:t.id,cwdRel:e,engine:t.engine,boot:t.boot===!0,systemPrompt:n};if(t.model&&(l.model=t.model),t.label!==void 0){if(!Us(t.label,eP)||!String(t.label).trim())return null;l.label=String(t.label).trim()}return Object.keys(i).length&&(l.models=i),Object.keys(s).length&&(l.permissionPolicies=s),Object.keys(a).length&&(l.commands=a),l}function aP(t){if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(a=>!iP.has(a))||!Y1.test(String(t.id||""))||typeof t.cwd!="string"||!t.cwd||t.cwd.length>Xj||!td.test(String(t.engine||""))||t.boot!==void 0&&typeof t.boot!="boolean"||t.model!==void 0&&(typeof t.model!="string"||t.model.length>zu)||t.systemPrompt!==void 0&&t.prompt!==void 0&&t.systemPrompt!==t.prompt)return null;const e=t.systemPrompt===void 0?t.prompt===void 0?"":t.prompt:t.systemPrompt;if(typeof e!="string"||e.length>Q1)return null;const n=xl(t.models,a=>typeof a=="string"&&!!a&&a.length<=zu),i=xl(t.permissionPolicies,a=>X1.has(a));if(n===null||i===null)return null;const s={id:t.id,cwd:t.cwd,engine:t.engine,boot:t.boot===!0,systemPrompt:e};return t.model&&(s.model=t.model),Object.keys(n).length&&(s.models=n),Object.keys(i).length&&(s.permissionPolicies=i),s}function lP(t){if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(n=>!rP.has(n)))return null;const e={};for(const[n,i]of Object.entries(t)){if(typeof i!="string"||!Us(i,n==="baseUrl"?512:128)||rg(i))return null;e[n]=i}return!e.client||!e.provider||e.envKey&&!G1.test(e.envKey)?null:e}function Z1(t){if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(i=>!sP.has(i))||!td.test(String(t.id||""))||!Us(t.label||t.id,64)||t.rc!==void 0&&typeof t.rc!="boolean"||t.panelUrl!==void 0&&!sg(t.panelUrl))return null;const e={id:t.id,label:t.label||t.id,rc:t.rc===!0};if(t.panelUrl!==void 0&&(e.panelUrl=t.panelUrl),t.managed!==void 0){const i=lP(t.managed);return!i||["command","args","envKeys","model","promptMode","promptFlag"].some(s=>t[s]!==void 0)?null:(e.managed=i,e)}if(!Us(t.command,512)||!t.command.startsWith("/")||!Array.isArray(t.args)||t.args.length>32||t.args.some(i=>!Us(i,1024)||rg(i))||t.promptMode!=="flag"&&t.promptMode!=="send-keys"||t.promptMode==="flag"&&(!Us(t.promptFlag,32)||/\s/.test(t.promptFlag)))return null;if(t.model!==void 0){if(!t.model||typeof t.model!="object"||Array.isArray(t.model)||Object.keys(t.model).some(i=>i!=="flag"&&i!=="value")||!Us(t.model.flag,32)||/\s/.test(t.model.flag)||!Us(t.model.value||"",128))return null;e.model={flag:t.model.flag,value:t.model.value||""}}const n=t.envKeys===void 0?[]:t.envKeys;return!Array.isArray(n)||n.length>32||n.some(i=>!G1.test(i))?null:(Object.assign(e,{command:t.command,args:[...t.args],envKeys:[...new Set(n)].sort(),promptMode:t.promptMode}),t.promptMode==="flag"&&(e.promptFlag=t.promptFlag),e)}function ex(t){if(!t||typeof t!="object"||Array.isArray(t))return null;const e=t.managed?{id:t.id,label:t.label,rc:t.rc,managed:t.managed,...t.panelUrl!==void 0?{panelUrl:t.panelUrl}:{}}:{id:t.id,label:t.label,rc:t.rc,command:t.command,args:t.args,envKeys:t.envKeys,model:t.model,promptMode:t.promptMode,promptFlag:t.promptFlag,...t.panelUrl!==void 0?{panelUrl:t.panelUrl}:{}},n=Z1(e);return n||null}function cP(t,e,n){const i=new Set;for(const s of Array.isArray(e)?e:[]){if(!n.has(s.id)||!s.managed)continue;const{client:a,provider:l,credentialProfile:d}=s.managed;i.add(d?`${a}.${l}-${d}`:`${a}.${l}`),i.add(`${a}.${l}`)}return(Array.isArray(t)?t:[]).filter(s=>s&&i.has(s.engine))}function uP(t,e,n=[],i=[],s=new Date,a=[]){n instanceof Date&&(s=n,n=[],i=[]);const l=e instanceof Set?e:new Set(e||[]),d=i instanceof Set?i:new Set(i||[]),h=[];for(const y of Array.isArray(t)?t:[]){if(!l.has(y.id))continue;const _=J1({id:y.id,cwdRel:y.cwdRel,engine:y.engine,boot:y.boot===!0,...y.label?{label:y.label}:{},...y.model?{model:y.model}:{},...y.models?{models:y.models}:{},...y.permissionPolicies?{permissionPolicies:y.permissionPolicies}:{},systemPrompt:y.prompt||"",...y.commands?{commands:y.commands}:{}});if(!_)return{ok:!1,error:"invalid-cell",invalidCellIds:[y.id]};h.push(_)}const f=[];for(const y of Array.isArray(n)?n:[]){if(!d.has(y.id))continue;const _=ex(y);_&&f.push(_)}const g=cP(a,n,d);return{format:nm,version:V1,exportedAt:s.toISOString(),cells:h,engines:f,...g.length?{models:g}:{}}}function dP(t){let e;try{e=JSON.parse(String(t||""))}catch{return{ok:!1,error:"invalid-json",cells:[],engines:[]}}const n=(e==null?void 0:e.format)===Gj&&(e==null?void 0:e.version)===1,i=(e==null?void 0:e.format)===nm&&(e==null?void 0:e.version)===2,s=(e==null?void 0:e.format)===nm&&(e==null?void 0:e.version)===V1,a=n||i,l=i||s;if(l&&Array.isArray(e.engines)&&e.engines.length>ru)return{ok:!1,error:"invalid-format",detail:`${e.engines.length} engine dichiarati, cap ${ru}; riduci gli engine a ${ru} o meno`,cells:[],engines:[]};if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(_=>!tP.has(_))||!n&&!i&&!s||!Array.isArray(e.cells)||e.cells.length>Zj||l&&(!Array.isArray(e.engines)||e.engines.length>ru))return{ok:!1,error:"invalid-format",cells:[],engines:[]};const d=[],h=new Set;for(const _ of e.cells){const w=a?aP(_):J1(_);if(!w)return{ok:!1,error:"invalid-cell",cells:[],engines:[]};if(h.has(w.id))return{ok:!1,error:"duplicate-cell",cells:[],engines:[]};h.add(w.id),d.push(w)}const f=[],g=new Set;for(const _ of l?e.engines:[]){const w=Z1(_);if(!w)return{ok:!1,error:"invalid-engine",cells:[],engines:[]};if(g.has(w.id))return{ok:!1,error:"duplicate-engine",cells:[],engines:[]};g.add(w.id),f.push(w)}const y=[];if(e.models!==void 0){if(!Array.isArray(e.models)||e.models.length>64)return{ok:!1,error:"invalid-model",cells:[],engines:[]};const _=new Set;for(const w of e.models){if(!w||typeof w!="object"||Array.isArray(w))return{ok:!1,error:"invalid-model",cells:[],engines:[]};const b=new Set(["id","engine","label","contextWindow","maxTokens","reasoning"]);if(Object.keys(w).some(C=>!b.has(C)))return{ok:!1,error:"invalid-model",cells:[],engines:[]};const N=typeof w.id=="string"?w.id.trim():"",x=typeof w.engine=="string"?w.engine.trim():"";if(!N||!x)return{ok:!1,error:"invalid-model",cells:[],engines:[]};const E=`${x}::${N}`;if(_.has(E))return{ok:!1,error:"duplicate-model",cells:[],engines:[]};_.add(E),y.push({...w,id:N,engine:x})}}return{ok:!0,cells:d,engines:f,models:y,legacy:a,exportedAt:typeof e.exportedAt=="string"?e.exportedAt:""}}function hP(t,e,n){const i=new Set(n||[]);if(!i.has(e))return null;const s=f=>Object.fromEntries(Object.entries(f||{}).filter(([g])=>i.has(g))),a={id:t.id,engine:e,boot:t.boot===!0,prompt:t.systemPrompt||""};typeof t.label=="string"&&t.label&&(a.label=t.label),typeof t.cwdRel=="string"?a.cwdRel=t.cwdRel:typeof t.cwd=="string"&&t.cwd&&(a.cwd=t.cwd),e===t.engine&&t.model?a.model=t.model:t.models&&t.models[e]&&(a.model=t.models[e]);const l=s(t.models),d=s(t.permissionPolicies),h=s(t.commands);return Object.keys(l).length&&(a.models=l),Object.keys(d).length&&(a.permissionPolicies=d),Object.keys(h).length&&(a.commands=h),a}const fP=()=>({kind:"managed",id:"claude.native",label:"",client:"claude",provider:"native",credentialProfile:"",managedModel:"",permissionPolicy:"unsafe",credentialSourcePolicy:"auto",displayName:"",protocol:"anthropic_messages",baseUrl:"",envKey:"",providerId:"nexuscrew-custom",command:"",argsText:"",rc:!0,promptMode:"send-keys",promptFlag:"",modelFlag:"",modelValue:"",envRows:[],credentialValue:"",credentialReveal:!1,allowMissingCredential:!1,panelUrl:""}),Ob=(t="")=>({id:"",cwd:"",engine:t,boot:!1,label:"",model:"",prompt:"",commands:{},command:"",panelUrl:""}),tx=t=>t==="claude"?"unsafe":"standard",Rl=(t,e)=>t.find(n=>n.client===e.client&&n.provider===e.provider&&(n.credentialProfile||"")===(e.credentialProfile||"")),pP=(t,e)=>{var n;return((n=Rl(t,e))==null?void 0:n.label)||`${e.client} · ${e.provider}`};function mP(t){var e,n,i,s,a,l,d,h,f,g,y,_,w,b,N;return{kind:t.managed?"managed":"custom",id:t.id,label:t.label||"",command:t.command||"",argsText:(t.args||[]).join(`
163
- `),rc:!!t.rc,client:((e=t.managed)==null?void 0:e.client)||"claude",provider:((n=t.managed)==null?void 0:n.provider)||"native",credentialProfile:((i=t.managed)==null?void 0:i.credentialProfile)||"",managedModel:((s=t.managed)==null?void 0:s.model)||"",permissionPolicy:((a=t.managed)==null?void 0:a.permissionPolicy)||tx((l=t.managed)==null?void 0:l.client),credentialSourcePolicy:((d=t.managed)==null?void 0:d.credentialSourcePolicy)||"auto",displayName:((h=t.managed)==null?void 0:h.displayName)||"",protocol:((f=t.managed)==null?void 0:f.protocol)||"",baseUrl:((g=t.managed)==null?void 0:g.baseUrl)||"",envKey:((y=t.managed)==null?void 0:y.envKey)||"",providerId:((_=t.managed)==null?void 0:_.providerId)||"nexuscrew-custom",modelOptions:t.availableModels||((w=t.managedInfo)==null?void 0:w.models)||[],promptMode:t.promptMode||"send-keys",promptFlag:t.promptFlag||"",modelFlag:((b=t.model)==null?void 0:b.flag)||"",modelValue:((N=t.model)==null?void 0:N.value)||"",envRows:(t.envKeys||[]).map(x=>({key:x,value:"",configured:!0,remove:!1})),credentialValue:"",credentialReveal:!1,allowMissingCredential:!1,panelUrl:t.panelUrl||""}}function $b(t,e,n){const i=(e.panelUrl||"").trim();return n?i&&(t.panelUrl=i):t.panelUrl=i||null,t}function gP(t,e,n=[]){if(t.kind==="managed"){const s={client:t.client,provider:t.provider,model:t.client==="shell"?"":t.managedModel||"",permissionPolicy:t.client==="shell"?"standard":t.permissionPolicy||tx(t.client)};t.credentialProfile&&(s.credentialProfile=t.credentialProfile),t.credentialSourcePolicy&&t.credentialSourcePolicy!=="auto"&&(s.credentialSourcePolicy=t.credentialSourcePolicy);const a=Rl(n,t);return(a==null?void 0:a.credentialEnv)===!0&&(s.envKey=t.envKey),t.provider==="custom"&&Object.assign(s,{displayName:t.displayName,protocol:t.protocol,baseUrl:t.baseUrl,envKey:t.envKey,providerId:t.providerId}),$b({...e?{id:t.id}:{},label:t.label||pP(n,t),rc:!!t.rc,managed:s},t,e)}const i={...e?{id:t.id}:{},label:t.label||t.id,rc:!!t.rc,command:t.command,args:t.argsText.split(`
164
- `).filter(s=>s!==""),promptMode:t.promptMode};return t.modelFlag&&(i.model={flag:t.modelFlag,value:t.modelValue||""}),t.promptMode==="flag"&&(i.promptFlag=t.promptFlag),e&&(i.env=Object.fromEntries(t.envRows.filter(s=>!s.remove&&s.key).map(s=>[s.key,s.value]))),$b(i,t,e)}function br({children:t,onClose:e,label:n,error:i=""}){const s=k.useRef(null),a=k.useRef(null),l=k.useRef(e);return l.current=e,k.useEffect(()=>{const d=document.activeElement,h=s.current,f=()=>Array.from((h==null?void 0:h.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [href], [tabindex]:not([tabindex="-1"])'))||[]).filter(_=>_.offsetParent!==null),g=requestAnimationFrame(()=>{var _;return(_=f()[0]||h)==null?void 0:_.focus({preventScroll:!0})}),y=_=>{var x;if(_.key==="Escape"){_.preventDefault(),(x=l.current)==null||x.call(l);return}if(_.key!=="Tab")return;const w=f();if(!w.length){_.preventDefault(),h==null||h.focus();return}const b=w[0],N=w[w.length-1];_.shiftKey&&document.activeElement===b?(_.preventDefault(),N.focus()):!_.shiftKey&&document.activeElement===N&&(_.preventDefault(),b.focus())};return document.addEventListener("keydown",y),()=>{cancelAnimationFrame(g),document.removeEventListener("keydown",y),d&&d.isConnected&&typeof d.focus=="function"&&d.focus({preventScroll:!0})}},[]),k.useEffect(()=>{i&&requestAnimationFrame(()=>{var d;return(d=a.current)==null?void 0:d.scrollIntoView({block:"nearest"})})},[i]),c.jsx("div",{className:"nc-fleet-modal",role:"presentation",onMouseDown:d=>{d.target===d.currentTarget&&e()},children:c.jsxs("div",{ref:s,className:"nc-fleet-modal-dialog",role:"dialog","aria-modal":"true","aria-label":n||m("settings"),tabIndex:-1,children:[t,i&&c.jsx("div",{ref:a,className:"nc-err nc-fleet-modal-error",role:"alert","aria-live":"assertive",children:i})]})})}function Ff({token:t,targets:e=[],readonly:n=!1,onPower:i,onImport:s}){const[a,l]=k.useState([]),[d,h]=k.useState(0);k.useEffect(()=>{let x=!0;async function E(){const I=[{route:[],label:m("local")}].concat((e||[]).map(W=>({route:Array.isArray(W.route)?W.route:[],label:W.label||(W.route||[]).join(" › ")}))),T=await Promise.all(I.map(async W=>{const U={...W,available:!1,readonly:!1,capabilities:[],provider:null,cells:[],unmanaged:[],err:""};try{const Q=await Ar(t,W.route);U.available=!!Q.available,U.capabilities=Q.capabilities||[],U.provider=Q.provider||null,U.cells=(Q.cells||[]).map(ee=>({...ee,route:W.route}));try{U.readonly=!!(await fm(t,W.route)).readonlyDefault}catch{}try{const ee=await hm(t,W.route),q=new Set(U.cells.map(J=>J.tmuxSession).filter(Boolean));U.unmanaged=(ee.sessions||[]).filter(J=>J&&!q.has(J.name))}catch{}}catch(Q){U.err=String(Q&&Q.message||Q)}return U}));x&&l(T)}E();const C=setInterval(E,6e3);return()=>{x=!1,clearInterval(C)}},[t,e,d]);const f=(x,E)=>Array.isArray(x.capabilities)&&x.capabilities.includes(E)&&!n&&!x.readonly,g=()=>h(x=>x+1),y=(x,E)=>{i&&i({...x,route:E})},_=(x,E)=>{i&&i({...x,route:E})},w=async(x,E)=>{try{await hl(t,x.cell,E)}catch{}g()},b=async(x,E)=>{if(window.confirm(m("fleet-remove-cell").replace("{id}",x.cell))){try{await a0(t,x.cell,!0,E)}catch{}g()}},N=async(x,E)=>{if(window.confirm(m("terminate-confirm").replace("{name}",x.name))){try{await um(t,x.name,E)}catch{}g()}};return c.jsxs("div",{className:"nc-fleet-inventory",children:[c.jsxs("div",{className:"nc-fleet-section-head",children:[c.jsx("b",{children:m("fleet-inventory")}),c.jsx("small",{children:m("fleet-inventory-help")})]}),a.map(x=>{const E=x.route.length?x.route.join("/"):"local";return c.jsxs("div",{className:"nc-fleet-pos",children:[c.jsxs("div",{className:"nc-fleet-pos-title",children:[c.jsx("span",{className:`dot ${x.available?"on":"warn"}`}),c.jsx("b",{children:x.label}),c.jsx("small",{children:x.available?`${x.cells.length} ${m("fleet-cells")} · ${x.unmanaged.length} ${m("fleet-tmux")}`:x.err||m("fleet-not-available")})]}),x.cells.map(C=>c.jsxs("div",{className:"nc-fleet-item nc-fleet-cell",children:[c.jsxs("span",{children:[c.jsx("b",{children:C.cell}),c.jsx("small",{children:`${C.engine||""}${C.key?`·${C.key}`:""}${C.active?"":` · ${m("cell-off")}`}`})]}),c.jsxs("span",{className:"nc-fleet-cell-actions",children:[C.active&&f(x,"down")&&c.jsx("button",{className:"nc-btn ghost",title:m("power-off"),onClick:()=>_(C,x.route),children:m("stop")}),!C.active&&f(x,"up")&&c.jsx("button",{className:"nc-btn ghost",title:m("power-on"),onClick:()=>y(C,x.route),children:m("start")}),f(x,"restart")&&C.active&&c.jsx("button",{className:"nc-btn ghost",title:m("restart"),onClick:()=>w(C,x.route),children:m("restart")}),f(x,"remove")&&c.jsx("button",{className:"nc-btn danger",title:m("delete"),onClick:()=>b(C,x.route),children:"×"})]})]},`${E}:${C.cell}`)),x.unmanaged.map(C=>c.jsxs("div",{className:"nc-fleet-item nc-fleet-unmanaged",children:[c.jsxs("span",{children:[c.jsx("b",{children:C.name}),c.jsx("small",{children:m("fleet-tmux")})]}),c.jsxs("span",{className:"nc-fleet-cell-actions",children:[f(x,"import")&&s&&c.jsx("button",{className:"nc-btn ghost",title:m("import-as-cell"),onClick:()=>s(C,x.route),children:m("import-as-cell")}),c.jsx("button",{className:"nc-btn danger",title:m("terminate"),onClick:()=>N(C,x.route),children:"×"})]})]},`${E}:u:${C.name}`)),x.available&&x.cells.length===0&&x.unmanaged.length===0&&c.jsx("div",{className:"nc-empty",children:m("fleet-inventory-empty")})]},E)})]})}function vP({cells:t=[],engines:e=[],models:n=[],busy:i,canRestore:s=!1,onRestore:a,onClose:l}){const[d,h]=k.useState("export"),[f,g]=k.useState([]),[y,_]=k.useState(()=>new Set(t.map(P=>P.id))),[w,b]=k.useState(()=>new Set(e.map(P=>P.id))),[N,x]=k.useState([]),[E,C]=k.useState([]),[I,T]=k.useState(""),W=new Set(e.map(P=>P.id)),U=new Set(t.map(P=>P.id)),Q=(P,A)=>P(R=>{const D=new Set(R);return D.has(A)?D.delete(A):D.add(A),D}),ee=()=>{const P=uP(t,y,e,w,new Date,n);if(P.ok===!1){T(m(`fleet-backup-${P.error}`));return}const A=t.filter(F=>y.has(F.id)).length,R=e.filter(F=>w.has(F.id)).length;if(P.cells.length!==A){T(m("fleet-backup-invalid-cell"));return}if(P.engines.length!==R){T(m("fleet-backup-invalid-engine"));return}if(!P.cells.length&&!P.engines.length){T(m("fleet-backup-select-one"));return}const D=new Blob([`${JSON.stringify(P,null,2)}
165
- `],{type:"application/json"}),H=URL.createObjectURL(D),z=document.createElement("a");z.href=H,z.download=`nexuscrew-fleet-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(z),z.click(),z.remove(),setTimeout(()=>URL.revokeObjectURL(H),0),T("")},q=async P=>{if(T(""),x([]),C([]),!!P){if(P.size>1024*1024){T(m("fleet-backup-too-large"));return}try{const A=dP(await P.text());if(!A.ok){T(m(`fleet-backup-${A.error}`));return}g(Array.isArray(A.models)?A.models:[]);const R=new Set(A.engines.map(D=>D.id));C(A.engines.map(D=>({engine:D,exists:W.has(D.id),selected:!W.has(D.id)}))),x(A.cells.map(D=>{const H=W.has(D.engine)||R.has(D.engine),z=U.has(D.id);return{cell:D,engine:H?D.engine:"",selected:H&&!z,exists:z}}))}catch(A){T(String(A.message||A))}}},J=(P,A)=>x(R=>R.map((D,H)=>H===P?{...D,...A}:D)),$=(P,A)=>C(R=>R.map((D,H)=>H===P?{...D,...A}:D)),M=new Set([...W,...E.filter(P=>P.selected).map(P=>P.engine.id)]),L=N.filter(P=>P.selected&&P.engine&&M.has(P.engine)),j=E.filter(P=>P.selected),O=[...new Map([...e.map(P=>[P.id,P.label||P.id]),...E.filter(P=>P.selected).map(P=>[P.engine.id,P.engine.label||P.engine.id])]).entries()];return c.jsxs("div",{className:"nc-set-form nc-fleet-form nc-backup-dialog",children:[c.jsx("b",{children:m("fleet-backup")}),c.jsx("small",{children:m("fleet-backup-help")}),c.jsxs("div",{className:"nc-set-tabs nc-backup-tabs",children:[c.jsx("button",{type:"button",className:`nc-set-tabbtn${d==="export"?" on":""}`,onClick:()=>{h("export"),T("")},children:m("fleet-backup-export")}),c.jsx("button",{type:"button",className:`nc-set-tabbtn${d==="import"?" on":""}`,disabled:!s,title:s?"":m("fleet-backup-restore-unavailable"),onClick:()=>{h("import"),T("")},children:m("fleet-backup-import")})]}),d==="export"?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{_(new Set(t.map(P=>P.id))),b(new Set(e.map(P=>P.id)))},children:m("select-all")}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{_(new Set),b(new Set)},children:m("select-none")})]}),c.jsxs("div",{className:"nc-backup-list",children:[c.jsx("b",{children:m("fleet-engines")}),e.map(P=>{var A;return c.jsxs("label",{className:"nc-check nc-backup-row",children:[c.jsx("input",{type:"checkbox",checked:w.has(P.id),onChange:()=>Q(b,P.id)}),c.jsxs("span",{children:[c.jsx("b",{children:P.label||P.id}),c.jsxs("small",{children:[P.id,(A=P.envKeys)!=null&&A.length?` · ${P.envKeys.length} ${m("fleet-backup-env-names")}`:""]})]})]},P.id)}),c.jsx("b",{children:m("fleet-cells")}),t.map(P=>c.jsxs("label",{className:"nc-check nc-backup-row",children:[c.jsx("input",{type:"checkbox",checked:y.has(P.id),onChange:()=>Q(_,P.id)}),c.jsxs("span",{children:[c.jsx("b",{children:P.id}),c.jsxs("small",{children:[P.engine," · ",m("fleet-system-prompt")," ",(P.prompt||"").length," ",m("characters")]})]})]},P.id)),!t.length&&!e.length&&c.jsx("div",{className:"nc-empty",children:m("fleet-backup-empty")})]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:l,children:m("cancel")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:!y.size&&!w.size,onClick:ee,children:m("fleet-backup-download")})]})]}):c.jsxs(c.Fragment,{children:[c.jsx("input",{type:"file",accept:"application/json,.json",disabled:i,onChange:P=>q(P.target.files&&P.target.files[0])}),c.jsx("small",{children:m("fleet-backup-import-help")}),!!(N.length||E.length)&&c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{C(P=>P.map(A=>({...A,selected:!0}))),x(P=>P.map(A=>({...A,selected:!!A.engine})))},children:m("select-all")}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{C(P=>P.map(A=>({...A,selected:!1}))),x(P=>P.map(A=>({...A,selected:!1})))},children:m("select-none")})]}),c.jsxs("div",{className:"nc-backup-list",children:[!!E.length&&c.jsx("b",{children:m("fleet-engines")}),E.map((P,A)=>{var R;return c.jsx("div",{className:"nc-backup-import-row",children:c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:P.selected,onChange:D=>$(A,{selected:D.target.checked})}),c.jsxs("span",{children:[c.jsx("b",{children:P.engine.label||P.engine.id}),c.jsxs("small",{children:[P.engine.id," · ",P.exists?m("fleet-backup-overwrite"):m("fleet-backup-new"),(R=P.engine.envKeys)!=null&&R.length?` · ${m("fleet-backup-env-values-required")}`:""]})]})]})},P.engine.id)}),!!N.length&&c.jsx("b",{children:m("fleet-cells")}),N.map((P,A)=>c.jsxs("div",{className:"nc-backup-import-row",children:[c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:P.selected,disabled:!P.engine||!M.has(P.engine),onChange:R=>J(A,{selected:R.target.checked})}),c.jsxs("span",{children:[c.jsx("b",{children:P.cell.id}),c.jsxs("small",{children:[P.exists?m("fleet-backup-overwrite"):m("fleet-backup-new")," · ",m("fleet-system-prompt")," ",P.cell.systemPrompt.length," ",m("characters")]})]})]}),c.jsxs("select",{value:P.engine,onChange:R=>J(A,{engine:R.target.value,selected:!!R.target.value}),children:[c.jsx("option",{value:"",children:m("fleet-backup-engine-missing")}),O.map(([R,D])=>c.jsx("option",{value:R,children:D},R))]})]},P.cell.id))]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:l,children:m("cancel")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:i||!L.length&&!j.length,onClick:()=>a({engineRows:E,cellRows:N,models:f}),children:m("fleet-backup-restore")})]})]}),I&&c.jsx("div",{className:"nc-err",children:I})]})}function _P({state:t,setState:e,busy:n,onSave:i,catalog:s}){var E;const a=t.form,l=C=>e({...t,form:{...a,...C}}),d=a.envRows||[],h=[...new Map(s.map(C=>[C.client,C.clientLabel||C.client])).entries()],f=s.filter(C=>C.client===a.client),g=Rl(s,a),y=typeof(g==null?void 0:g.credentialEnv)=="string"?g.credentialEnv:"",_=Array.isArray(g==null?void 0:g.credentialUsedBy)?g.credentialUsedBy:[],w=(g==null?void 0:g.credentialSource)||"missing",b=!!(g!=null&&g.credentialEnv)||a.credentialProfile==="a"||a.credentialProfile==="p",N=!!y&&t.mode==="new"&&(g==null?void 0:g.authConfigured)!==!0&&!a.credentialValue&&!a.allowMissingCredential,x=C=>{C&&l({client:C.client,provider:C.provider,credentialProfile:C.credentialProfile||"",managedModel:C.model||"",protocol:C.protocol||"",permissionPolicy:C.permissionPolicyDefault||"standard",credentialSourcePolicy:"auto",rc:!!C.rc,displayName:C.custom?m("fleet-custom-provider-default"):"",baseUrl:C.custom?"":C.endpoint||"",envKey:C.defaultEnvKey||"",providerId:"nexuscrew-custom",credentialValue:"",credentialReveal:!1,allowMissingCredential:!1,...t.mode==="new"?{id:C.id,label:""}:{}})};return c.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[c.jsx("b",{children:t.mode==="new"?m("fleet-new-engine"):`${m("edit")} ${a.id}`}),c.jsx("input",{value:a.id,disabled:t.mode!=="new",placeholder:"id",onChange:C=>l({id:C.target.value})}),c.jsx("input",{value:a.label,placeholder:m("label"),onChange:C=>l({label:C.target.value})}),c.jsxs("select",{value:a.kind,disabled:t.mode!=="new",onChange:C=>l({kind:C.target.value}),children:[c.jsx("option",{value:"managed",children:m("fleet-managed")}),c.jsx("option",{value:"custom",children:m("fleet-custom")})]}),a.kind==="managed"?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("select",{value:a.client,disabled:t.mode!=="new",onChange:C=>x(s.find(I=>I.client===C.target.value&&I.default)||s.find(I=>I.client===C.target.value)),children:h.map(([C,I])=>c.jsx("option",{value:C,children:I},C))}),c.jsx("select",{value:((E=Rl(s,a))==null?void 0:E.id)||"",disabled:t.mode!=="new",onChange:C=>x(s.find(I=>I.id===C.target.value)),children:f.map(C=>c.jsx("option",{value:C.id,children:C.label},C.id))})]}),a.client!=="shell"&&c.jsxs(c.Fragment,{children:[c.jsx("input",{value:a.managedModel,list:"nc-managed-models",placeholder:m(g!=null&&g.requiresModel?"fleet-model-required":"fleet-model-default"),onChange:C=>l({managedModel:C.target.value})}),c.jsx("datalist",{id:"nc-managed-models",children:[...(g==null?void 0:g.models)||[],...a.modelOptions||[]].filter((C,I,T)=>C&&T.indexOf(C)===I).map(C=>c.jsx("option",{value:C},C))})]}),g!=null&&g.supportsUnsafe?c.jsxs("select",{value:a.permissionPolicy,onChange:C=>l({permissionPolicy:C.target.value}),children:[c.jsx("option",{value:"standard",children:m("fleet-standard-permissions")}),c.jsx("option",{value:"unsafe",children:m("fleet-unsafe-permissions")})]}):c.jsx("small",{children:m("fleet-standard-permissions")}),(g==null?void 0:g.supportsUnsafe)&&a.permissionPolicy==="unsafe"&&c.jsx("small",{className:"nc-err",children:m("fleet-unsafe-warning")}),b&&c.jsxs("select",{"aria-label":m("fleet-credential-source-policy"),value:a.credentialSourcePolicy||"auto",onChange:C=>l({credentialSourcePolicy:C.target.value}),children:[c.jsx("option",{value:"auto",children:m("fleet-credential-source-policy-auto")}),c.jsx("option",{value:"nexuscrew-store",children:m("fleet-credential-source-policy-nexuscrew-store")}),c.jsx("option",{value:"environment",children:m("fleet-credential-source-policy-environment")})]}),(g==null?void 0:g.credentialEnv)===!0&&c.jsxs(c.Fragment,{children:[c.jsx("input",{value:a.envKey,placeholder:m("fleet-api-key-env"),onChange:C=>l({envKey:C.target.value})}),c.jsx("small",{children:m("fleet-custom-secret-help")})]}),y&&c.jsxs("section",{className:"nc-fleet-key","aria-label":m("fleet-key-section"),children:[c.jsxs("div",{className:"nc-fleet-key-head",children:[c.jsx("b",{children:m("fleet-key-section")}),c.jsx("span",{children:m(`fleet-credential-source-${w}`)})]}),c.jsxs("label",{className:"nc-field",children:[m("fleet-key-variable"),c.jsx("input",{value:y,readOnly:!0,"aria-label":m("fleet-key-variable")})]}),c.jsx("small",{children:_.length?m("fleet-key-used-by").replace("{engines}",_.join(", ")):m("fleet-key-used-by-none")}),_.length>0&&c.jsx("small",{children:m("fleet-key-shared-impact").replace("{key}",y).replace("{engines}",_.join(", "))}),c.jsxs("div",{className:"nc-fleet-key-input",children:[c.jsx("input",{type:a.credentialReveal?"text":"password",value:a.credentialValue||"","aria-label":m("fleet-key-value").replace("{key}",y),autoComplete:"new-password",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",placeholder:g!=null&&g.authConfigured||t.mode==="edit"?m("fleet-key-blank-keeps"):m("fleet-key-enter"),onChange:C=>l({credentialValue:C.target.value,allowMissingCredential:C.target.value?!1:a.allowMissingCredential})}),c.jsx("button",{type:"button",className:"nc-btn ghost","aria-label":m(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal"),onClick:()=>l({credentialReveal:!a.credentialReveal}),children:m(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal")})]}),c.jsx("small",{children:m("fleet-key-local-help")}),t.mode==="new"&&(g==null?void 0:g.authConfigured)!==!0&&!a.credentialValue&&c.jsxs("label",{className:"nc-check nc-fleet-key-missing",children:[c.jsx("input",{type:"checkbox",checked:!!a.allowMissingCredential,onChange:C=>l({allowMissingCredential:C.target.checked})}),m("fleet-key-create-missing")]}),(g==null?void 0:g.notice)&&c.jsx("small",{className:"nc-fleet-provider-notice",children:m(`fleet-provider-notice-${g.notice}`)})]}),(g==null?void 0:g.notice)&&!y&&c.jsx("small",{className:"nc-fleet-provider-notice",children:m(`fleet-provider-notice-${g.notice}`)}),a.provider==="custom"&&c.jsxs(c.Fragment,{children:[c.jsx("input",{value:a.displayName,placeholder:m("fleet-provider-display"),onChange:C=>l({displayName:C.target.value})}),c.jsx("input",{value:a.baseUrl,placeholder:"https://api.example.com/v1",onChange:C=>l({baseUrl:C.target.value})}),((g==null?void 0:g.protocols)||[]).length>1&&c.jsx("select",{value:a.protocol,onChange:C=>l({protocol:C.target.value}),children:g.protocols.map(C=>c.jsx("option",{value:C,children:C},C))}),c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("input",{value:a.envKey,placeholder:m("fleet-api-key-env"),onChange:C=>l({envKey:C.target.value})}),c.jsx("input",{value:a.providerId,placeholder:m("fleet-provider-id"),onChange:C=>l({providerId:C.target.value})})]}),c.jsxs("small",{children:[a.protocol," · ",m("fleet-custom-secret-help")]})]}),c.jsx("small",{children:m(a.client==="shell"?"fleet-shell-engine-help":"fleet-managed-help")})]}):c.jsxs(c.Fragment,{children:[c.jsx("input",{value:a.command,placeholder:m("command-path"),onChange:C=>l({command:C.target.value})}),c.jsx("textarea",{value:a.argsText,placeholder:m("args-lines"),onChange:C=>l({argsText:C.target.value})}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:a.rc,onChange:C=>l({rc:C.target.checked})})," ",m("fleet-remote-control")]}),c.jsxs("select",{value:a.promptMode,onChange:C=>l({promptMode:C.target.value}),children:[c.jsx("option",{value:"send-keys",children:"send-keys"}),c.jsx("option",{value:"flag",children:"flag"})]}),a.promptMode==="flag"&&c.jsx("input",{value:a.promptFlag,placeholder:"prompt flag",onChange:C=>l({promptFlag:C.target.value})}),c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("input",{value:a.modelFlag,placeholder:"model flag",onChange:C=>l({modelFlag:C.target.value})}),c.jsx("input",{value:a.modelValue,placeholder:"model default",onChange:C=>l({modelValue:C.target.value})})]}),c.jsx("small",{children:m("env-write-only")}),d.map((C,I)=>c.jsxs("div",{className:"nc-fleet-env",children:[c.jsx("input",{value:C.key,disabled:C.configured,placeholder:"ENV_KEY",onChange:T=>{const W=d.slice();W[I]={...C,key:T.target.value},l({envRows:W})}}),c.jsx("input",{type:"password",value:C.value,placeholder:C.configured?"•••••• (unchanged)":"value",onChange:T=>{const W=d.slice();W[I]={...C,value:T.target.value},l({envRows:W})}}),c.jsx("button",{className:"nc-btn danger",onClick:()=>l({envRows:d.filter((T,W)=>W!==I)}),children:"×"})]},`${C.key}-${I}`)),c.jsx("button",{className:"nc-btn ghost",onClick:()=>l({envRows:[...d,{key:"",value:"",configured:!1}]}),children:"+ env"})]}),c.jsx("input",{value:a.panelUrl||"",maxLength:512,placeholder:m("fleet-panel-url"),onChange:C=>l({panelUrl:C.target.value})}),c.jsx("small",{children:m("fleet-panel-url-help")}),a.panelUrl&&!sg(a.panelUrl)&&c.jsx("small",{className:"nc-err",children:m("fleet-panel-url-invalid")}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",onClick:()=>e(null),children:m("cancel")}),c.jsx("button",{className:"nc-btn primary",disabled:n||!a.id||N||a.kind==="custom"&&!a.command||a.kind==="managed"&&(g==null?void 0:g.requiresModel)&&!a.managedModel||a.kind==="managed"&&(g==null?void 0:g.credentialEnv)===!0&&!a.envKey||a.kind==="managed"&&a.provider==="custom"&&(!a.displayName||!a.baseUrl||!a.envKey||!a.providerId),onClick:i,children:m("save")})]})]})}function yP({state:t,setState:e,busy:n,onSave:i,onTest:s,profiles:a=[],canTest:l=!0}){const[d,h]=k.useState(null),[f,g]=k.useState(!1),y=t.form,_=x=>e({...t,form:{...y,...x}}),w=/^[^\x00-\x1f\x7f]{1,128}$/.test(y.id||""),b=!!(y.id||"").trim()&&!!(y.engine||"").trim()&&w,N=async()=>{h(null),g(!0);try{h(await s(y.engine,y.id))}catch(x){h({outcome:"unverified",detail:String(x&&x.message||x)})}g(!1)};return c.jsxs("div",{className:"nc-fleet-form",children:[c.jsxs("label",{className:"nc-field",children:[m("model-editor-engine"),c.jsxs("select",{value:y.engine||"",disabled:n||t.mode==="edit",onChange:x=>{h(null),_({engine:x.target.value})},children:[c.jsx("option",{value:"",children:"—"}),a.map(x=>c.jsx("option",{value:x.id,children:x.label?`${x.id} · ${x.label}`:x.id},x.id))]})]}),c.jsxs("label",{className:"nc-field",children:[m("model-editor-id"),c.jsx("input",{value:y.id||"",disabled:n||t.mode==="edit",placeholder:"qwen3.9-max",onChange:x=>{h(null),_({id:x.target.value})}})]}),c.jsx("small",{className:"nc-set-hint",children:m("model-editor-id-help")}),c.jsxs("label",{className:"nc-field",children:[m("model-editor-context"),c.jsx("input",{inputMode:"numeric",value:y.contextWindow||"",disabled:n,onChange:x=>_({contextWindow:x.target.value.replace(/[^0-9]/g,"").slice(0,9)})})]}),c.jsxs("label",{className:"nc-field",children:[m("model-editor-max-tokens"),c.jsx("input",{inputMode:"numeric",value:y.maxTokens||"",disabled:n,onChange:x=>_({maxTokens:x.target.value.replace(/[^0-9]/g,"").slice(0,9)})})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:y.reasoning===!0,disabled:n,onChange:x=>_({reasoning:x.target.checked})})," ",m("model-editor-reasoning")]}),c.jsxs("div",{className:"nc-set-row",children:[l&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||f||!b,onClick:N,children:m(f?"model-test-running":"model-test")}),d&&c.jsxs("span",{className:`nc-model-test ${d.outcome}`,children:[m(`model-test-${d.outcome}`),d.outcome==="ok"&&Number.isInteger(d.latencyMs)?` · ${d.latencyMs}ms`:""]})]}),d&&d.detail&&c.jsx("small",{className:"nc-set-hint",children:d.detail}),d&&d.outcome==="unverified"&&c.jsx("small",{className:"nc-set-hint",children:m("model-test-unverified-help")}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>e(null),children:m("cancel")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||!b,onClick:()=>i(y),children:m("save")})]})]})}function wP({token:t,route:e,targets:n=[],location:i,setLocation:s,state:a,setState:l,engines:d,mcpServers:h=[],managedCatalog:f=[],busy:g,onSave:y}){var j,O,P;const[_,w]=k.useState(null),[b,N]=k.useState(""),x=a.form,E=A=>l({...a,form:{...x,...A}}),C=d.find(A=>A.id===x.engine),I=((j=C==null?void 0:C.managed)==null?void 0:j.client)==="shell",T=((O=C==null?void 0:C.managed)==null?void 0:O.client)||"",W=((P=f.find(A=>A.client===T))==null?void 0:P.mcpManaged)!==!1,U=A=>{var H,z,F,K;const R=d.find(ne=>ne.id===A),D={...x.commands||{}};((H=C==null?void 0:C.managed)==null?void 0:H.client)==="shell"&&(x.command?D[x.engine]=x.command:delete D[x.engine]),E({engine:A,model:((z=x.models)==null?void 0:z[A])||((F=R==null?void 0:R.managed)==null?void 0:F.model)||((K=R==null?void 0:R.model)==null?void 0:K.value)||"",commands:D,command:D[A]||""})},Q=A=>{const R={...x.commands||{}};A?R[x.engine]=A:delete R[x.engine],E({command:A,commands:R})},ee=I&&/[|&;<>()`$*?{}\[\]~]/.test(x.command||""),q=[...new Set([...h||[],...Array.isArray(x.mcp)?x.mcp:[]])].sort(),J=Array.isArray(x.mcp)?x.mcp.length?"some":"none":"all",$=A=>{var R;return E({mcp:A==="all"?void 0:A==="none"?[]:(R=x.mcp)!=null&&R.length?x.mcp:[...q]})},M=A=>{const R=Array.isArray(x.mcp)?x.mcp:[];E({mcp:R.includes(A)?R.filter(D=>D!==A):[...R,A].sort()})},L=async A=>{try{const R=await dm(t,A,e);w(R),E({cwd:R.path}),N("")}catch(R){N(String(R.message||R))}};return c.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[c.jsx("b",{children:a.mode==="new"?m("fleet-new-cell"):`${m("edit")} ${x.id}`}),a.mode==="new"&&c.jsxs("label",{className:"nc-field",children:[m("location"),c.jsx("span",{className:"nc-req",children:" *"}),c.jsxs("select",{value:i,onChange:A=>{s(A.target.value),E({engine:""})},children:[c.jsx("option",{value:"",children:m("local")}),n.map(A=>c.jsxs("option",{value:A.route.join("/"),disabled:A.status&&A.status!=="up",children:[A.label,A.status&&A.status!=="up"?` · ${m("node-offline")}`:""]},A.route.join("/")))]})]}),c.jsx("input",{value:x.id,disabled:a.mode!=="new",placeholder:"id",onChange:A=>E({id:A.target.value})}),c.jsx("input",{value:x.label||"",maxLength:64,placeholder:m("fleet-cell-label"),onChange:A=>E({label:A.target.value})}),c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("input",{value:x.cwd,placeholder:m("cwd"),onChange:A=>E({cwd:A.target.value})}),c.jsx("button",{className:"nc-btn ghost",onClick:()=>_?w(null):L(x.cwd),children:m("browse")})]}),_&&c.jsxs("div",{className:"nc-fs",children:[c.jsx("div",{className:"nc-fs-path",children:_.path}),c.jsxs("div",{className:"nc-fs-list",children:[_.parent&&c.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>L(_.parent),children:["↑ ",m("fs-parent")]}),(_.dirs||[]).map(A=>c.jsxs("button",{className:"nc-fs-item",onClick:()=>L(`${_.path.replace(/\/$/,"")}/${A}`),children:["📁 ",A]},A))]})]}),b&&c.jsx("div",{className:"nc-err",children:b}),c.jsx("select",{value:x.engine,onChange:A=>U(A.target.value),children:d.map(A=>c.jsx("option",{value:A.id,children:A.label},A.id))}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:!!x.boot,onChange:A=>E({boot:A.target.checked})})," ",m("fleet-boot")]}),c.jsx("input",{value:x.panelUrl||"",maxLength:512,placeholder:m("fleet-panel-url"),onChange:A=>E({panelUrl:A.target.value})}),c.jsx("small",{children:m("fleet-panel-url-help")}),x.panelUrl&&!sg(x.panelUrl)&&c.jsx("small",{className:"nc-err",children:m("fleet-panel-url-invalid")}),I?c.jsxs(c.Fragment,{children:[c.jsx("input",{value:x.command||"",maxLength:4096,placeholder:m("fleet-shell-command-placeholder"),onChange:A=>Q(A.target.value)}),c.jsx("small",{children:x.command?m("fleet-shell-command-help"):m("fleet-shell-interactive")}),ee&&c.jsx("small",{className:"nc-note",children:m("fleet-shell-command-metachar")})]}):c.jsxs(c.Fragment,{children:[c.jsx("input",{value:x.model||"",list:"nc-cell-models",placeholder:m("fleet-model-override"),onChange:A=>E({model:A.target.value})}),c.jsx("datalist",{id:"nc-cell-models",children:((C==null?void 0:C.availableModels)||[]).map(A=>c.jsx("option",{value:A},A))}),c.jsx("textarea",{value:x.prompt||"",placeholder:m("cell-prompt"),onChange:A=>E({prompt:A.target.value})}),c.jsx("small",{children:m("cell-prompt-help")}),c.jsxs("label",{className:"nc-field",children:[m("cell-mcp"),c.jsxs("select",{value:J,onChange:A=>$(A.target.value),children:[c.jsx("option",{value:"all",children:m("cell-mcp-all")}),c.jsx("option",{value:"none",children:m("cell-mcp-none")}),c.jsx("option",{value:"some",children:m("cell-mcp-some")})]})]}),!W&&c.jsx("small",{className:"nc-note",children:m("cell-mcp-inert")}),J==="some"&&c.jsx("div",{className:"nc-fleet-mcp-list",children:q.map(A=>c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:(x.mcp||[]).includes(A),onChange:()=>M(A)})," ",A]},A))}),c.jsx("small",{children:m("cell-mcp-help")})]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",onClick:()=>l(null),children:m("cancel")}),c.jsx("button",{className:"nc-btn primary",disabled:g||!x.id||!x.cwd||!x.engine,onClick:y,children:m("save")})]})]})}function zb({token:t,route:e=[],state:n,setState:i,busy:s,onSave:a}){const[l,d]=k.useState(null),[h,f]=k.useState([]),[g,y]=k.useState(""),_=Array.isArray(e)?e.join("/"):"";k.useEffect(()=>{let E=!0;return Wu(t,_?_.split("/"):[]).then(C=>{E&&(f(C.engines||[]),y(""))}).catch(C=>{E&&(f([]),y(String(C.message||C)))}),()=>{E=!1}},[t,_]);const w=n.form,b=E=>i({...n,form:{...w,...E}}),N=async E=>{try{const C=await dm(t,E,e);d(C),b({cwd:C.path})}catch{}},x=!w.id&&w.tmuxSession?w.tmuxSession.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32):w.id;return c.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[c.jsxs("b",{children:[m("import-as-cell")," · ",w.tmuxSession]}),c.jsx("small",{children:m("import-help")}),c.jsx("input",{value:w.tmuxSession,disabled:!0,placeholder:"tmux session",readOnly:!0}),c.jsx("input",{value:w.id,placeholder:m("name"),onChange:E=>b({id:E.target.value})}),c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("input",{value:w.cwd,placeholder:m("cwd"),onChange:E=>b({cwd:E.target.value})}),c.jsx("button",{className:"nc-btn ghost",type:"button",onClick:()=>l?d(null):N(w.cwd),children:m("browse")})]}),l&&c.jsxs("div",{className:"nc-fs",children:[c.jsx("div",{className:"nc-fs-path",children:l.path}),c.jsxs("div",{className:"nc-fs-list",children:[l.parent&&c.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>N(l.parent),children:["↑ ",m("fs-parent")]}),(l.dirs||[]).map(E=>c.jsxs("button",{className:"nc-fs-item",onClick:()=>N(`${l.path.replace(/\/$/,"")}/${E}`),children:["📁 ",E]},E))]})]}),c.jsxs("select",{value:w.engine,onChange:E=>b({engine:E.target.value}),children:[c.jsx("option",{value:"",children:m("import-engine-required")}),h.map(E=>c.jsx("option",{value:E.id,children:E.label},E.id))]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:!!w.boot,onChange:E=>b({boot:E.target.checked})})," ",m("fleet-boot")]}),(n.err||g)&&c.jsx("div",{className:"nc-err",children:n.err||g}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",onClick:()=>i(null),children:m("cancel")}),c.jsx("button",{className:"nc-btn primary",disabled:s||!w.tmuxSession||!w.engine||!h.length,onClick:a,children:m(x?"import-as-cell":"save")})]})]})}function ou(t){const e=eo(t);return e===null?`~/${t}`:e?`~/${e}`:"~"}function bP(t){if(!t||typeof t.path!="string"||typeof t.home!="string")return"";const{path:e,home:n}=t;return!n||e===n||!e.startsWith(n+"/")?"":e.slice(n.length+1).replace(/\/+$/,"")}function SP({token:t,route:e,cell:n,busy:i=!1,onSaved:s,onClose:a}){const[l,d]=k.useState(""),[h,f]=k.useState(null),[g,y]=k.useState(!1),[_,w]=k.useState(""),b=typeof(n==null?void 0:n.cwdSuggestion)=="string"&&eo(n.cwdSuggestion)!==null?eo(n.cwdSuggestion):null,[N,x]=k.useState(b),E=n==null?void 0:n.id,C=i||g,I=async q=>{const J=eo(q);if(J===null){f({rel:"",dirs:[],loading:!1,err:m("fleet-cwd-repair-invalid")});return}f({rel:J,dirs:[],loading:!0,err:""});try{const $=await dm(t,J,e),M=bP($);f({rel:M,dirs:Array.isArray($.dirs)?$.dirs:[],loading:!1,err:""})}catch($){f({rel:J,dirs:[],loading:!1,err:String($&&$.message||$)})}},T=q=>{if(!h)return;const J=h.rel?`${h.rel}/${q}`:q;I(J)},W=()=>{h!=null&&h.rel&&I(h.rel.split("/").slice(0,-1).join("/"))},U=()=>{h&&(d(h.rel||""),f(null),w(""),x(null))},Q=()=>{N!==null&&(d(N),x(null),w(""))},ee=async()=>{if(C)return;const q=eo(l);if(q===null){w(m("fleet-cwd-repair-invalid"));return}const J=ou(q);let $=!0;try{$=window.confirm(m("fleet-cwd-repair-confirm").replace("{id}",String(E||"")).replace("{path}",J))}catch{$=!1}if($){y(!0),w(""),x(null);try{const M=await o0(t,E,{cwdRel:q},e);s==null||s(M)}catch(M){const L=M&&M.data||{};if(L.code==="unportable-cwd"){w(m("fleet-cwd-repair-unportable"));const j=Array.isArray(L.cells)?L.cells.find(P=>P&&P.id===E):null,O=j&&typeof j.suggestion=="string"?j.suggestion:null;O!==null&&eo(O)!==null&&x(O)}else w(String(M&&M.message||M))}finally{y(!1)}}};return c.jsxs("div",{className:"nc-set-form nc-fleet-form nc-cwd-repair",children:[c.jsx("b",{children:m("fleet-cwd-repair-title").replace("{id}",String(E||""))}),c.jsx("small",{className:"nc-set-info",children:m("fleet-cwd-repair-help")}),c.jsx("small",{className:"nc-cwd-no-source",children:m("fleet-cwd-repair-no-source-path")}),c.jsxs("label",{className:"nc-field",children:[m("cwd"),c.jsxs("div",{className:"nc-cwd-rel-row",children:[c.jsx("span",{className:"nc-cwd-rel-prefix",children:"~/"}),c.jsx("input",{value:l,placeholder:m("fleet-cwd-repair-placeholder"),autoComplete:"off",spellCheck:"false",autoCapitalize:"none",onChange:q=>d(q.target.value)}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:C,onClick:()=>h?f(null):I(""),children:m(h?"close":"fleet-cwd-repair-browse")})]})]}),c.jsx("div",{className:"nc-cwd-preview",children:m("fleet-cwd-repair-preview").replace("{path}",ou(l))}),h&&c.jsxs("div",{className:"nc-fs",children:[c.jsx("div",{className:"nc-fs-path",children:ou(h.rel)}),c.jsxs("div",{className:"nc-fs-list",children:[h.rel&&c.jsxs("button",{type:"button",className:"nc-fs-item nc-fs-nav",onClick:W,children:["↑ ",m("fs-parent")]}),h.loading&&c.jsx("div",{className:"nc-fs-empty",children:"…"}),!h.loading&&h.dirs.length===0&&c.jsx("div",{className:"nc-fs-empty",children:m("fleet-cwd-repair-fs-empty")}),!h.loading&&h.dirs.map(q=>c.jsxs("button",{type:"button",className:"nc-fs-item",onClick:()=>T(q),children:["📁 ",q]},q))]}),h.err&&c.jsx("div",{className:"nc-err",children:h.err}),c.jsx("div",{className:"nc-sheet-actions",children:c.jsx("button",{type:"button",className:"nc-btn primary",disabled:C||h.loading||!!h.err,onClick:U,children:m("fleet-cwd-repair-use-current")})})]}),_&&c.jsx("div",{className:"nc-err",role:"alert",children:_}),N!==null&&c.jsxs("div",{className:"nc-cwd-suggestion",role:"status",children:[c.jsx("span",{children:m("fleet-cwd-repair-suggestion")}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:Q,children:m("fleet-cwd-repair-use-suggestion").replace("{path}",ou(N))})]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:g,onClick:a,children:m("cancel")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:C,onClick:ee,children:g?"…":m("save")})]})]})}function xP({token:t,readonly:e,targets:n=[],startNewCell:i=!1,initialLocation:s=""}){const[a,l]=k.useState({engines:[],cells:[],managedCatalog:[]}),[d,h]=k.useState({available:!1,capabilities:[]}),[f,g]=k.useState(!1),[y,_]=k.useState(null),[w,b]=k.useState(null),[N,x]=k.useState({}),[E,C]=k.useState(null),[I,T]=k.useState(!1),[W,U]=k.useState(""),[Q,ee]=k.useState(""),[q,J]=k.useState(s),[$,M]=k.useState(!1),[L,j]=k.useState(null),[O,P]=k.useState(null),[A,R]=k.useState(null),[D,H]=k.useState(!1),[z,F]=k.useState([]),[K,ne]=k.useState(null),[re,Y]=k.useState("manage"),de=k.useRef(!1),oe=q?q.split("/"):[],pe=k.useCallback(async()=>{try{const le=await Ar(t,oe);h(le);try{const ae=await fm(t,oe);M(!!ae.readonlyDefault)}catch{M(!1)}if(le.provider==="builtin"&&(le.capabilities||[]).includes("definitions")){const ae=await Wu(t,oe),ge=new Map((le.engines||[]).map(Ce=>[Ce.id,Ce]));if(ae.engines=(ae.engines||[]).map(Ce=>{var Me;return{...Ce,availableModels:((Me=ge.get(Ce.id))==null?void 0:Me.models)||[]}}),l(ae),(le.capabilities||[]).includes("credentials"))try{F((await ik(t,oe)).credentials||[])}catch{F([])}else F([])}U("")}catch(le){U(String(le.message||le))}finally{g(!0)}},[t,q]);k.useEffect(()=>{pe();const le=setInterval(pe,5e3);return()=>clearInterval(le)},[pe]);const xe=new Set((d.cells||[]).filter(le=>le.active).map(le=>le.cell)),Qe=d.provider==="builtin"&&(d.capabilities||[]).includes("edit"),ot=(d.capabilities||[]).includes("restore");k.useEffect(()=>{!i||de.current||!Qe||!a.engines.length||(de.current=!0,C({mode:"new",form:Ob(a.engines[0].id)}))},[i,Qe,a.engines]);const De=async le=>{T(!0),U(""),ee("");try{await le(),await pe()}catch(ae){U(String(ae.message||ae))}T(!1)},je=async(le,ae)=>{const ge=await uk(t,le,ae,oe);return x(Ce=>({...Ce,[`${le}::${ae}`]:ge})),ge},tt=le=>De(async()=>{const ae={id:String(le.id||"").trim(),engine:String(le.engine||"").trim()};for(const ge of["contextWindow","maxTokens"]){const Ce=String(le[ge]||"").trim();Ce&&(ae[ge]=Number(Ce))}le.reasoning===!0&&(ae.reasoning=!0),await lk(t,ae,oe),b(null),await pe()}),Nt=()=>De(async()=>{var Bt;const le=y.mode==="new",ae=y.form,ge=a.managedCatalog||[],Ce=ae.kind==="managed"?Rl(ge,ae):null,Me=typeof(Ce==null?void 0:Ce.credentialEnv)=="string"?Ce.credentialEnv:"",nt=Me&&ae.credentialValue||"",ct=gP(ae,le,ge);!le&&y.form.kind==="custom"&&!y.form.modelFlag&&(ct.model=null),!le&&y.form.kind==="custom"&&y.form.promptMode!=="flag"&&(ct.promptFlag=null);let pt;if(le)pt=await rk(t,ct,oe);else{const Z=y.original,ye=new Set(y.form.envRows.filter(Ge=>!Ge.remove).map(Ge=>Ge.key)),Ue=(Z.envKeys||[]).filter(Ge=>!ye.has(Ge)),We=Object.fromEntries(y.form.envRows.filter(Ge=>!Ge.remove&&Ge.key&&(!Ge.configured||Ge.value!=="")).map(Ge=>[Ge.key,Ge.value]));pt=await ok(t,Z.id,ct,y.form.kind==="custom"?{set:We,remove:Ue}:void 0,oe)}let Lt=null;if(Me&&nt)try{Lt=await I_(t,Me,nt,oe),F(Lt.credentials||[])}catch{throw await pe(),le&&_({mode:"edit",original:{...ct,id:ae.id},form:{...ae,credentialReveal:!1}}),new Error(m(le?"fleet-key-partial-create":"fleet-key-partial-edit"))}await pe(),_(null),ee(m("fleet-saved"));const Dt=((Bt=((Lt==null?void 0:Lt.credentials)||[]).find(Z=>Z.envKey===Me))==null?void 0:Bt.activeCells)||[],Et=[...new Set([...(pt==null?void 0:pt.activeCells)||[],...Dt])];if(Et.length&&window.confirm(m("fleet-restart-confirm").replace("{cells}",Et.join(", "))))for(const Z of Et)await hl(t,Z,oe)}),Ct=()=>De(async()=>{var Dt,Et,Bt,Z,ye,Ue;const le=E.mode==="new",ae=E.form,ge={...le?{id:ae.id}:{},cwd:ae.cwd,engine:ae.engine,boot:!!ae.boot},Ce={...ae.commands||{}},Me=a.engines.find(We=>We.id===ae.engine);((Dt=Me==null?void 0:Me.managed)==null?void 0:Dt.client)==="shell"&&typeof ae.command=="string"&&ae.command.length?Ce[ae.engine]=ae.command:((Et=Me==null?void 0:Me.managed)==null?void 0:Et.client)==="shell"&&delete Ce[ae.engine],(Object.keys(Ce).length||!le)&&(ge.commands=Ce);const nt=(ae.label||"").trim();le?nt&&(ge.label=nt):ge.label=nt||null;const ct=(ae.panelUrl||"").trim();le?ct&&(ge.panelUrl=ct):ge.panelUrl=ct||null,le?Array.isArray(ae.mcp)&&(ge.mcp=ae.mcp):ge.mcp=Array.isArray(ae.mcp)?ae.mcp:null,le?(((Bt=Me==null?void 0:Me.managed)==null?void 0:Bt.client)!=="shell"&&ae.model&&(ge.model=ae.model),((Z=Me==null?void 0:Me.managed)==null?void 0:Z.client)!=="shell"&&ae.prompt&&(ge.prompt=ae.prompt)):(ge.model=((ye=Me==null?void 0:Me.managed)==null?void 0:ye.client)==="shell"?null:ae.model||null,((Ue=Me==null?void 0:Me.managed)==null?void 0:Ue.client)!=="shell"&&(ge.prompt=ae.prompt||null));const pt=le?await dk(t,ge,oe):await o0(t,E.original.id,ge,oe),Lt=le?ae.id:E.original.id;C(null),ee(m("fleet-saved")),!le&&(pt!=null&&pt.active)&&window.confirm(m("fleet-restart-confirm").replace("{cells}",Lt))&&await hl(t,Lt,oe)}),ft=e||$,ht=d.capabilities||[],kt=oe.length>0&&ft,St=le=>z.find(ae=>{var ge;return(ge=ae.engines)==null?void 0:ge.includes(le.id)})||null,Ut=()=>De(async()=>{var ge;const le=await I_(t,K.envKey,K.value,oe);F(le.credentials||[]),ne(null),ee(m("fleet-credential-saved"));const ae=((ge=(le.credentials||[]).find(Ce=>Ce.envKey===K.envKey))==null?void 0:ge.activeCells)||[];if(ae.length&&window.confirm(m("fleet-restart-confirm").replace("{cells}",ae.join(", "))))for(const Ce of ae)await hl(t,Ce,oe)}),Mt=le=>De(async()=>{if(!window.confirm(m("fleet-credential-remove-confirm").replace("{key}",le.envKey)))return;const ae=await sk(t,le.envKey,oe);F(ae.credentials||[]),ee(m("fleet-credential-removed"))}),It=le=>j({...le,route:Array.isArray(le==null?void 0:le.route)?le.route:oe}),tn=async le=>{if(!L)return;const ae=L.cell||L.id,ge=Array.isArray(L.route)?L.route:oe;if(le.action==="up"){const Ce=await cm(t,{cell:ae,boot:!!le.boot,...le.engine?{engine:le.engine}:{},...le.model!==void 0?{model:le.model}:{},...le.permissionPolicy?{permissionPolicy:le.permissionPolicy}:{}},ge),Me=km(Ce);Me&&ee(Me.text)}else await wu(t,{cell:ae,boot:!!le.boot},ge)},Ft=(le,ae)=>{U(""),P({mode:"new",route:Array.isArray(ae)?ae:oe,form:{tmuxSession:le.name,id:"",engine:"",cwd:"",boot:!1},err:""})},ln=()=>De(async()=>{const le=O.form;if(!le.engine){P({...O,err:m("import-engine-required")});return}await hk(t,{tmuxSession:le.tmuxSession,id:le.id||void 0,engine:le.engine,cwd:le.cwd||void 0,boot:!!le.boot},le.route||oe),P(null),ee(m("fleet-saved"))}),V=({engineRows:le=[],cellRows:ae=[],models:ge=[]})=>De(async()=>{const Ce=le.filter(Z=>Z.selected),Me=Ce.map(Z=>ex(Z.engine));if(Me.some(Z=>!Z))throw new Error(m("fleet-backup-invalid-engine"));const nt=Ce.filter(Z=>Z.exists).map(Z=>Z.engine.id);if(nt.length&&!window.confirm(m("fleet-backup-confirm-engine-overwrite").replace("{engines}",nt.join(", "))))return;const ct=[...new Set([...a.engines.map(Z=>Z.id),...Me.map(Z=>Z.id)])],pt=[];for(const Z of ae.filter(ye=>ye.selected)){const ye=hP(Z.cell,Z.engine,ct);if(!ye)throw new Error(`${Z.cell.id}: ${m("fleet-backup-engine-missing")}`);pt.push(ye)}const Lt=ae.filter(Z=>Z.selected&&Z.exists).map(Z=>Z.cell.id);if(Lt.length&&!window.confirm(m("fleet-backup-confirm-overwrite").replace("{cells}",Lt.join(", "))))return;const Dt=Me.length?await pk(t,Me,nt.length>0,oe,ge):{needsRestart:[]},Et=pt.length?await fk(t,pt,oe):{needsRestart:[]},Bt=[...new Set([...Dt.needsRestart||[],...Et.needsRestart||[]])];H(!1),ee(`${m("fleet-backup-restored").replace("{n}",String(pt.length))}${Me.length?` · ${Me.length} ${m("fleet-engines").toLowerCase()}`:""}${Bt.length?` · ${m("fleet-backup-needs-restart").replace("{cells}",Bt.join(", "))}`:""}`)}),Te=c.jsxs("label",{className:"nc-field",children:[m("location"),c.jsxs("select",{value:q,onChange:le=>{J(le.target.value),_(null),C(null),U(""),ee(""),M(!1),g(!1),h({available:!1,capabilities:[]}),l({engines:[],cells:[],managedCatalog:[]}),F([]),ne(null)},children:[c.jsx("option",{value:"",children:m("local")}),n.map(le=>c.jsxs("option",{value:le.route.join("/"),disabled:le.status&&le.status!=="up",children:[le.label,le.status&&le.status!=="up"?` · ${m("node-offline")}`:""]},le.route.join("/")))]})]}),gt=c.jsxs("div",{className:"nc-fleet-view-tabs",role:"tablist","aria-label":m("tab-fleet"),children:[c.jsx("button",{type:"button",role:"tab","aria-selected":re==="manage",className:`nc-set-tabbtn${re==="manage"?" on":""}`,onClick:()=>Y("manage"),children:m("fleet-manage-location")}),c.jsx("button",{type:"button",role:"tab","aria-selected":re==="overview",className:`nc-set-tabbtn${re==="overview"?" on":""}`,onClick:()=>Y("overview"),children:m("fleet-network-overview")})]});return f?Qe?c.jsxs("div",{className:"nc-set-tab nc-fleet-editor",children:[gt,re==="overview"?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-set-info",children:m("fleet-overview-help")}),c.jsx(Ff,{token:t,targets:n,readonly:e,onPower:It,onImport:Ft})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-set-info",children:m("fleet-manage-help")}),Te,c.jsxs("div",{className:"nc-set-row nc-fleet-backup-actions",children:[c.jsx("button",{className:"nc-btn ghost",disabled:ft||I,onClick:()=>{U(""),H(!0)},children:m("fleet-backup")}),c.jsx("small",{children:m("fleet-backup-help")})]}),c.jsxs("div",{className:"nc-fleet-section-head",children:[c.jsx("b",{children:m("fleet-cells")}),c.jsx("span",{className:"nc-fleet-head-actions",children:c.jsxs("button",{className:"nc-btn primary",disabled:ft||I||!a.engines.length,onClick:()=>{var le;U(""),C({mode:"new",form:Ob((le=a.engines[0])==null?void 0:le.id)})},children:["+ ",m("add")]})})]}),a.cells.map(le=>{const ae=xe.has(le.id),ge=le.needsRepair===!0;return c.jsxs("div",{className:"nc-fleet-item",children:[c.jsxs("span",{children:[c.jsx("b",{children:le.id}),le.label?c.jsxs("small",{className:"nc-fleet-label",children:[" ",le.label]}):null,c.jsxs("small",{children:[le.engine," · ",ge?c.jsx("span",{className:"nc-fleet-tag nc-fleet-tag-warn",children:m("fleet-cwd-needs-repair")}):le.cwd,ae?` · ${m("service-active")}`:` · ${m("cell-off")}`]})]}),c.jsxs("span",{children:[ae&&ht.includes("down")&&c.jsx("button",{className:"nc-btn ghost",disabled:ft||I,onClick:()=>De(()=>wu(t,{cell:le.id},oe)),children:m("stop")}),!ae&&ht.includes("up")&&c.jsx("button",{className:"nc-btn primary",disabled:ft||I,onClick:()=>It({cell:le.id,id:le.id,engine:le.engine,model:le.model,models:le.models,permissionPolicies:le.permissionPolicies,active:!1,boot:le.boot}),children:m("start")}),ae&&ht.includes("restart")&&c.jsx("button",{className:"nc-btn ghost",disabled:ft||I,onClick:()=>De(()=>hl(t,le.id,oe)),children:m("restart")}),ge?c.jsx("button",{className:"nc-btn ghost",disabled:ft||I,onClick:()=>{U(""),R(le)},children:m("fleet-cwd-repair")}):c.jsx("button",{className:"nc-btn ghost",disabled:ft||I,onClick:()=>{var Ce;U(""),C({mode:"edit",original:le,form:{...le,commands:{...le.commands||{}},command:((Ce=le.commands)==null?void 0:Ce[le.engine])||""}})},children:m("edit")}),c.jsx("button",{className:"nc-btn danger",disabled:ft||I,onClick:()=>De(async()=>{window.confirm(m("fleet-remove-cell").replace("{id}",le.id))&&await a0(t,le.id,!0,oe)}),children:"×"})]})]},le.id)}),c.jsxs("div",{className:"nc-fleet-section-head",children:[c.jsx("b",{children:m("fleet-engines")}),c.jsxs("button",{className:"nc-btn primary",disabled:ft||I,onClick:()=>{U(""),_({mode:"new",form:fP()})},children:["+ ",m("add")]})]}),a.engines.map(le=>{var ge,Ce;const ae=St(le);return c.jsxs("div",{className:"nc-fleet-item",children:[c.jsxs("span",{children:[c.jsx("b",{children:le.label}),c.jsx("small",{children:le.managed?`${le.id} · ${le.managed.client} / ${le.managed.provider} · ${(ge=le.managedInfo)!=null&&ge.configured?m("fleet-ready"):((Ce=le.managedInfo)==null?void 0:Ce.reason)||m("fleet-not-ready")}`:`${le.id} · ${le.command}`}),ae&&c.jsxs("small",{children:[ae.envKey," · ",m(`fleet-credential-source-${ae.source||"missing"}`)]})]}),c.jsxs("span",{children:[ae&&c.jsx("button",{className:"nc-btn ghost",disabled:ft||I,onClick:()=>{U(""),ne({envKey:ae.envKey,value:""})},children:ae.configured?m("fleet-credential-change"):m("fleet-credential-set")}),(ae==null?void 0:ae.source)==="local"&&c.jsx("button",{className:"nc-btn danger",disabled:ft||I,onClick:()=>Mt(ae),children:m("fleet-credential-forget")}),c.jsx("button",{className:"nc-btn ghost",disabled:ft||I,onClick:()=>{U(""),_({mode:"edit",original:le,form:mP(le)})},children:m("edit")}),c.jsx("button",{className:"nc-btn danger",disabled:ft||I,onClick:()=>De(async()=>{window.confirm(m("fleet-remove-engine").replace("{id}",le.id))&&await ak(t,le.id,oe)}),children:"×"})]})]},le.id)}),c.jsxs("div",{className:"nc-fleet-section-head",children:[c.jsx("b",{children:m("fleet-models")}),c.jsxs("button",{className:"nc-btn primary",disabled:ft||I,onClick:()=>{U(""),b({mode:"new",form:{id:"",engine:""}})},children:["+ ",m("add")]})]}),!(a.models||[]).length&&c.jsx("small",{className:"nc-set-hint",children:m("fleet-no-models")}),(a.models||[]).map(le=>{const ae=`${le.engine}::${le.id}`,ge=N[ae],Ce=(a.engines||[]).some(Me=>Me.managed&&Me.managed.model===le.id);return c.jsxs("div",{className:"nc-fleet-item",children:[c.jsxs("span",{children:[c.jsx("b",{children:le.id}),c.jsxs("small",{children:[le.engine,le.contextWindow?` · ${le.contextWindow}`:"",Ce?` · ${m("model-in-use")}`:""]}),ge&&c.jsxs("small",{className:`nc-model-test ${ge.outcome}`,children:[m(`model-test-${ge.outcome}`),ge.outcome==="ok"&&Number.isInteger(ge.latencyMs)?` · ${ge.latencyMs}ms`:""]})]}),c.jsxs("span",{children:[ht.includes("model-test")&&c.jsx("button",{className:"nc-btn ghost",disabled:I||kt,onClick:()=>De(()=>je(le.engine,le.id)),children:m("model-test")}),c.jsx("button",{className:"nc-btn danger",disabled:ft||I,onClick:()=>De(()=>ck(t,le.id,le.engine,oe)),children:"×"})]})]},ae)})]}),w&&c.jsx(br,{onClose:()=>b(null),label:m("fleet-models"),error:W,children:c.jsx(yP,{state:w,setState:b,busy:I,onSave:tt,onTest:je,profiles:a.managedCatalog||[],canTest:ht.includes("model-test")&&!kt})}),y&&c.jsx(br,{onClose:()=>_(null),label:m("fleet-new-engine"),error:W,children:c.jsx(_P,{state:y,setState:_,busy:I,onSave:Nt,catalog:a.managedCatalog||[]})}),E&&c.jsx(br,{onClose:()=>C(null),label:m("fleet-new-cell"),error:W,children:c.jsx(wP,{token:t,route:oe,targets:n,location:q,setLocation:J,state:E,setState:C,engines:a.engines,mcpServers:a.mcpServers||[],managedCatalog:a.managedCatalog||[],busy:I,onSave:Ct})}),A&&c.jsx(br,{onClose:()=>R(null),label:m("fleet-cwd-repair-title").replace("{id}",A.id),error:"",children:c.jsx(SP,{token:t,route:oe,cell:A,busy:I,onSaved:async()=>{R(null),ee(m("fleet-cwd-repaired")),await pe()},onClose:()=>R(null)})}),Q&&c.jsx("div",{className:"nc-set-note",children:Q}),W&&c.jsx("div",{className:"nc-err",children:W}),D&&c.jsx(br,{onClose:()=>H(!1),label:m("fleet-backup"),error:W,children:c.jsx(vP,{cells:a.cells,engines:a.engines,models:a.models||[],busy:I,canRestore:ot,onRestore:V,onClose:()=>H(!1)})}),K&&c.jsx(br,{onClose:()=>ne(null),label:m("fleet-credential-title"),error:W,children:c.jsxs("div",{className:"nc-fleet-form nc-credential-form",children:[c.jsx("b",{children:m("fleet-credential-title")}),c.jsx("small",{children:m("fleet-credential-help")}),c.jsxs("label",{className:"nc-field",children:[K.envKey,c.jsx("input",{type:"password",autoComplete:"off",spellCheck:"false",autoCapitalize:"none",value:K.value,onChange:le=>ne({...K,value:le.target.value})})]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",onClick:()=>ne(null),children:m("cancel")}),c.jsx("button",{className:"nc-btn primary",disabled:I||!K.value,onClick:Ut,children:m("save")})]})]})}),O&&c.jsx(br,{onClose:()=>P(null),label:m("import-as-cell"),error:W,children:c.jsx(zb,{token:t,route:O.route||oe,state:O,setState:P,busy:I,onSave:ln})}),L&&c.jsx(Cu,{cell:L,token:t,route:Array.isArray(L.route)?L.route:oe,onConfirm:async le=>{try{await tn(le)}finally{await pe()}},onClose:()=>j(null)})]}):c.jsxs("div",{className:"nc-set-tab",children:[gt,re==="overview"?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-set-info",children:m("fleet-overview-help")}),c.jsx(Ff,{token:t,targets:n,readonly:e,onPower:It,onImport:Ft})]}):c.jsxs(c.Fragment,{children:[Te,c.jsxs("div",{className:"nc-set-info",children:[m(W?"fleet-editor-load-error":"fleet-editor-unavailable"),!W&&d.reason?` ${d.reason}`:""]})]}),W&&c.jsx("div",{className:"nc-err",children:W}),O&&c.jsx(br,{onClose:()=>P(null),label:m("import-as-cell"),error:W,children:c.jsx(zb,{token:t,route:O.route||oe,state:O,setState:P,busy:I,onSave:ln})}),L&&c.jsx(Cu,{cell:L,token:t,route:Array.isArray(L.route)?L.route:oe,onConfirm:async le=>{try{await tn(le)}finally{await pe()}},onClose:()=>j(null)})]}):c.jsxs("div",{className:"nc-set-tab",children:[gt,re==="overview"?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-set-info",children:m("fleet-overview-help")}),c.jsx(Ff,{token:t,targets:n,readonly:e,onPower:It,onImport:Ft})]}):c.jsxs(c.Fragment,{children:[Te,c.jsx("div",{className:"nc-set-info",children:m("fleet-editor-loading")})]})]})}const og="nc_notification_speech_v1",au="nc-notification-speech",im="nc-notification-speech-preview",CP=320,kP=2,EP=3e4,NP=1e4,LP=6e4,RP=64,Fb=Object.freeze({enabled:!1}),MP=Object.freeze({it:"it-IT",en:"en-US",es:"es-ES"}),AP=Object.freeze({it:new Set(["che","con","correzione","della","delle","difetto","il","lavoro","nessun","non","per","pronto","pubblicata","pubblicato","rilascio","sono","stato","tutti","verificata","verificato","versione","completata","completato","riepilogo"]),en:new Set(["all","and","completed","fix","for","issue","no","published","ready","release","summary","the","verified","version","with","work"]),es:new Set(["con","correccion","defecto","el","esta","para","publicada","publicado","resumen","sin","todos","trabajo","verificada","verificado","version","y"])}),ag=new WeakSet;function lg(t){return{enabled:(t&&typeof t=="object"&&!Array.isArray(t)?t:{}).enabled===!0}}function nx(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function Hb(t=nx()){if(!t)return{...Fb};try{return lg(JSON.parse(t.getItem(og)||"null"))}catch{return{...Fb}}}function jP(t,e=nx()){const n=lg(t);if(e)try{e.setItem(og,JSON.stringify(n))}catch{}return n}function ga(){try{return typeof window<"u"?window:null}catch{return null}}function Ml(t=ga()){try{return!!(t&&t.speechSynthesis&&typeof t.speechSynthesis.speak=="function"&&typeof t.SpeechSynthesisUtterance=="function")}catch{return!1}}function ix(t=ga()){return!!(t&&(typeof t=="object"||typeof t=="function")&&ag.has(t))}function sm(t=ga()){t&&(typeof t=="object"||typeof t=="function")&&ag.delete(t)}function ia(t){const e=String(t||"").trim().toLowerCase().split("-")[0];return MP[e]||""}function nd(t){return String(t||"").normalize("NFC").replace(/[\p{Cc}\p{Cf}]+/gu," ").replace(/\s+/g," ").trim()}function PP(t){const e=nd(t).normalize("NFD").replace(new RegExp("\\p{M}+","gu"),"").toLowerCase(),n=new Set(e.match(new RegExp("\\p{L}+","gu"))||[]);if(n.size<4)return"";const i=Object.entries(AP).map(([s,a])=>({lang:s,score:[...n].reduce((l,d)=>l+(a.has(d)?1:0),0)})).sort((s,a)=>a.score-s.score);return i[0].score>=3&&i[0].score-i[1].score>=2?i[0].lang:""}function TP(t,e){const n=ia(t&&t.lang);return n||ia(PP(t&&t.body))||ia(e)}function sx(t){try{const e=t&&t.speechSynthesis&&t.speechSynthesis.getVoices;return typeof e=="function"?Array.from(e.call(t.speechSynthesis)||[]).filter(Boolean):[]}catch{return[]}}function rx(t,e){const n=ia(e);if(!n)return null;const i=Array.from(t||[]).filter(d=>d&&typeof d.lang=="string"&&d.lang.trim()),s=i.filter(d=>d.lang.trim().toLowerCase()===n.toLowerCase()),a=n.slice(0,2).toLowerCase(),l=i.filter(d=>d.lang.trim().toLowerCase().split("-")[0]===a);return s.find(d=>d.default===!0)||s[0]||l.find(d=>d.default===!0)||l[0]||null}function Ub(t){return nd(t).replace(/\bBearer\s+\S+/gi,"Bearer [redacted]").replace(/\b(?:sk|hf|zai|xox[baprs]|gh[pousr]|npm)[_-][A-Za-z0-9._-]{8,}\b/gi,"[redacted]").replace(/\b(?:token|password|secret|credential|api[_-]?key)\s*[=:]\s*(?:"[^"]*"|'[^']*'|\S+)/gi,"[redacted]").replace(/\b[A-Z][A-Z0-9_]{2,}\s*=\s*(?:"[^"]*"|'[^']*'|\S+)/g,"[redacted]").replace(/(?:\/home\/[^/\s]+|\/Users\/[^/\s]+|\/data\/(?:data|user\/\d+)\/[^/\s]+)(?:\/[^\s]*)?/g,"[private path]").replace(/\b[A-Za-z]:\\Users\\[^\\\s]+(?:\\[^\s]*)?/g,"[private path]")}function DP(t,e=CP){const n=Ub(t&&t.title),i=Ub(t&&t.body),s=[n,i&&i!==n?i:""].filter(Boolean).join(". "),a=Array.from(s);return a.length<=e?s:`${a.slice(0,Math.max(0,e-1)).join("").trimEnd()}…`}function IP(t){try{return!!(t&&t.visibilityState==="visible"&&typeof t.hasFocus=="function"&&t.hasFocus())}catch{return!1}}function ox(t=ga()){if(!Ml(t))return!1;try{return t.speechSynthesis.cancel(),!0}catch{return!1}}function BP(t){try{t&&typeof t.dispatchEvent=="function"&&typeof t.Event=="function"&&t.dispatchEvent(new t.Event(im))}catch{}}function OP(t,e,n=ga(),i={}){var f;if(sm(n),!Ml(n))return Promise.resolve(!1);const s=nd(t);if(!s||(f=i.signal)!=null&&f.aborted)return Promise.resolve(!1);const a=Number.isFinite(i.timeoutMs)&&i.timeoutMs>0?i.timeoutMs:NP,l=i.setTimer||((g,y)=>setTimeout(g,y)),d=i.clearTimer||(g=>clearTimeout(g)),h=i.signal;return BP(n),new Promise(g=>{let y=!1,_=!1,w=null,b=null;const N=x=>{if(!y){if(y=!0,h&&b&&h.removeEventListener("abort",b),w!==null&&d(w),x!==!0)try{n.speechSynthesis.cancel()}catch{}else ag.add(n);g(x)}};b=()=>N("no-activation"),h&&h.addEventListener("abort",b,{once:!0});try{n.speechSynthesis.cancel();const x=new n.SpeechSynthesisUtterance(s);x.lang=ia(e);const E=rx(sx(n),x.lang);E&&(x.voice=E),x.onstart=()=>{_=!0},x.onend=()=>N(_?!0:"no-activation"),x.onerror=()=>N("voice-error"),w=l(()=>N("timeout"),a),n.speechSynthesis.speak(x)}catch{N("no-activation")}})}function $P(t={}){const e=t.scope||ga(),n=t.document||e&&e.document,i=Number.isInteger(t.maxPending)&&t.maxPending>=0?t.maxPending:kP,s=Number.isFinite(t.watchdogMs)&&t.watchdogMs>0?t.watchdogMs:EP,a=Number.isFinite(t.dedupWindowMs)&&t.dedupWindowMs>0?t.dedupWindowMs:LP,l=Number.isInteger(t.maxDedup)&&t.maxDedup>0?t.maxDedup:RP,d=t.now||Date.now,h=t.setTimer||(($,M)=>setTimeout($,M)),f=t.clearTimer||($=>clearTimeout($)),g=t.isPrimed||(()=>ix(e)),y=e&&e.speechSynthesis;let _=null,w=null,b=[],N=[],x=()=>{};const E=new Map,C=()=>{N=sx(e)};if(C(),y&&typeof y.addEventListener=="function")y.addEventListener("voiceschanged",C),x=()=>y.removeEventListener("voiceschanged",C);else if(y&&"onvoiceschanged"in y){const $=y.onvoiceschanged,M=(...L)=>{C(),typeof $=="function"&&$.apply(y,L)};y.onvoiceschanged=M,x=()=>{y.onvoiceschanged===M&&(y.onvoiceschanged=$)}}const I=$=>{if($&&typeof $.id=="string"&&$.id)return`id:${$.id}`;const M=Number($&&$.ts),L=nd($&&$.title);return Number.isFinite(M)&&L?`frame:${M}:${L}`:""},T=$=>{if(!$)return!0;const M=d();for(const[L,j]of E)M-j>=a&&E.delete(L);if(E.has($))return!1;for(E.set($,M);E.size>l;)E.delete(E.keys().next().value);return!0},W=()=>{w!==null&&f(w),w=null},U=()=>{W(),_&&(_.onend=null,_.onerror=null,_=null),ox(e)},Q=$=>{if(!Ml(e))return b=[],"unsupported";let M;try{M=new e.SpeechSynthesisUtterance($.text),M.lang=ia($.lang);const j=rx(N,M.lang);j&&(M.voice=j)}catch{return b=[],"error"}_=M;const L=()=>{if(_!==M)return;W(),_=null,M.onend=null,M.onerror=null;const j=b.shift();j&&Q(j)};M.onend=L,M.onerror=L;try{return w=h(()=>{if(_!==M)return;_=null,M.onend=null,M.onerror=null;try{e.speechSynthesis.cancel()}catch{}W();const j=b.shift();j&&Q(j)},s),e.speechSynthesis.speak(M),"speaking"}catch{return L(),"error"}},ee=($,M)=>{if(!Ml(e))return"unsupported";const L=DP($);if(!L)return"empty";if(!T(I($)))return"duplicate";if(!IP(n))return"inactive";if(!g())return"unprimed";const j={text:L,lang:M};return $&&$.urgency==="high"?(b=[],U(),Q(j)):_?i===0?"dropped":(b.length>=i&&b.shift(),b.push(j),"queued"):Q(j)},q=()=>{b=[],U()};return{enqueue:ee,stop:q,dispose:()=>{q(),x(),x=()=>{}}}}function ax(){const[t,e]=k.useState(Hb);k.useEffect(()=>{const i=s=>{if((s==null?void 0:s.type)==="storage"&&s.key!==og&&s.key!==null)return;const a=(s==null?void 0:s.type)===au?lg(s.detail):Hb();e(a)};return window.addEventListener(au,i),window.addEventListener("storage",i),()=>{window.removeEventListener(au,i),window.removeEventListener("storage",i)}},[]);const n=k.useCallback(i=>{const s=jP({enabled:i===!0});return e(s),window.dispatchEvent(new CustomEvent(au,{detail:s})),s.enabled},[]);return[t.enabled,n]}function zP({text:t}){const[e,n]=k.useState(!1),i=async()=>{try{await navigator.clipboard.writeText(t),n(!0),setTimeout(()=>n(!1),1500)}catch{}};return c.jsxs("div",{className:"nc-set-copyline",children:[c.jsx("code",{children:t}),c.jsxs("button",{type:"button",className:"nc-btn ghost",onClick:i,children:[c.jsx(dt,{name:"copy",size:14})," ",m(e?"copied":"copy")]})]})}function FP({value:t}){const[e,n]=k.useState("");return k.useEffect(()=>{let i=!0;return vj.toDataURL(t,{margin:1,width:220}).then(s=>{i&&n(s)}).catch(()=>{}),()=>{i=!1}},[t]),e?c.jsx("img",{src:e,width:"220",height:"220",alt:"NexusCrew pairing QR"}):null}function HP({token:t,nodes:e,roster:n,settings:i,readonly:s,refresh:a,refreshAliases:l,vlUnavailable:d=[]}){const[h,f]=k.useState(null),[g,y]=k.useState(null),[_,w]=k.useState(null),[b,N]=k.useState({ssh:"",sshPort:"",name:""}),[x,E]=k.useState(""),[C,I]=k.useState(""),[T,W]=k.useState(!1),[U,Q]=k.useState(null),ee=Date.now(),q=i&&i.deviceName||"",J=(e||[]).filter(R=>R&&R.direction==="outbound"&&R.name&&R.ssh),$=J.find(R=>R.name===x)||J[0]||null,M=$?ep($.tunnel,ee):null,L=$!=null&&$.shared?M!=null&&M.up?"share-local-active":"share-local-pending":M!=null&&M.up?"share-local-private":"share-local-private-down",j=[{key:"peer-group-hubs",rows:(e||[]).filter(R=>R.kind!=="transitive"&&R.kind!=="vl"&&R.relation!=="client")},{key:"peer-group-clients",rows:(e||[]).filter(R=>R.kind!=="transitive"&&R.kind!=="vl"&&R.relation==="client")},{key:"peer-group-routed",rows:(e||[]).filter(R=>R.kind==="transitive")},{key:"peer-group-vl",rows:(e||[]).filter(R=>R.kind==="vl")}],O=U&&(e||[]).find(R=>`${R.kind||"direct"}:${R.nodeId||R.name}`===U)||null,P=async R=>{if($){f(null),y(`${$.name}:share`);try{const D=await Ck(t,$.name,R);await a(),D&&D.reversePoolPending===!0&&f(`${$.name}: ${m("share-reverse-pool-pending")}`)}catch(D){const H=D!=null&&D.data&&D.data.shared===!1?D.data:null;if(H)try{await a()}catch{}const z=D!=null&&D.data&&typeof D.data.hint=="string"?D.data.hint:"",F=(H==null?void 0:H.revoked)===!0&&(H==null?void 0:H.localReconcilePending)===!0?m("share-off-local-reconcile-pending"):(H==null?void 0:H.revoked)===!1&&(H==null?void 0:H.reconcilePending)===!0?m("share-off-hub-reconcile-pending"):"",K=D!=null&&D.data&&D.data.reversePoolPending===!0?m("share-reverse-pool-pending"):"",ne=D!=null&&D.data&&typeof D.data.code=="string"?D.data.code:"",re=D!=null&&D.data&&typeof D.data.detail=="string"?D.data.detail.trim():"",Y=re&&re!==String(D.message||"")?re:"";f(`${$.name}: ${String(D.message||D)}${ne?` [${ne}]`:""}${Y?` — ${Y}`:""}${z?` — ${z}`:""}${F?` — ${F}`:""}${K?` — ${K}`:""}`)}y(null)}},A=async()=>{f(null);const R=Lr(b.name||C||q||"NexusCrew"),D=F2({name:R,ssh:b.ssh,sshPort:b.sshPort});if(!D.ok){f(m(D.error));return}y("invite");try{w(await wk(t,{...C||q?{label:C||q}:{},name:R,ssh:D.value.ssh,...D.value.sshPort?{sshPort:D.value.sshPort}:{}}))}catch(H){f(String(H.message||H))}y(null)};return c.jsxs("div",{className:"nc-set-tab",children:[c.jsx("div",{className:"nc-sheet-label",children:m("peer-inventory-title")}),(e||[]).length===0&&c.jsx("div",{className:"nc-empty",children:m("no-nodes")}),j.map(R=>R.rows.length>0&&c.jsxs("div",{className:"nc-peer-group",children:[c.jsxs("div",{className:"nc-peer-group-title",children:[m(R.key)," ",c.jsx("span",{children:R.rows.length})]}),R.rows.map(D=>{const H=Rj(D);if(!H)return null;const z=`${D.kind||"direct"}:${D.nodeId||D.name}`,F=H.routed?{up:H.reach.up,since:null}:ep(D.tunnel,ee);return c.jsxs("button",{type:"button",className:`nc-set-node nc-node-row${H.routed?" routed":""}`,"aria-label":`${H.title} — ${m("node-detail-open")}`,onClick:()=>Q(z),children:[c.jsx("span",{className:`nc-dot ${H.reach.up?"on":""}`}),c.jsxs("span",{className:"nc-node-row-text",children:[c.jsx("b",{children:H.title}),c.jsxs("small",{children:[H.routed?H.routeLabel:`${H.subtitle} · ${m(H.exposure.shortKey)}`,!H.routed&&H.exposure.shortKey==="visibility-selected"?` (${H.exposure.count})`:""]})]}),c.jsxs("span",{className:`nc-set-tunnel${H.reach.up?" up":""}`,children:[m(H.reach.key),F.since?` · ${F.since}`:""]}),c.jsx("span",{className:"nc-node-row-more",children:c.jsx(dt,{name:"chevronDown",size:14})})]},z)})]},R.key)),d.length>0&&c.jsxs("div",{className:"nc-err",children:[m("vl-owners-unavailable"),": ",d.map(R=>R.label||R.route.join("/")).join(", ")]}),O&&c.jsx(Wj,{node:O,nodes:e||[],token:t,readonly:s,refresh:a,onClose:()=>Q(null)}),(n||[]).some(R=>!R.direct&&R.instanceId)&&c.jsxs("div",{className:"nc-set-form",children:[c.jsx("div",{className:"nc-sheet-label",children:m("routed-node-aliases")}),c.jsx("small",{className:"nc-set-hint",children:m("routed-node-aliases-help")}),(n||[]).filter(R=>!R.direct&&R.instanceId).map(R=>c.jsxs("div",{className:"nc-set-node",children:[c.jsxs("div",{className:"nc-set-node-head",children:[c.jsx("span",{className:`nc-dot ${R.status==="up"?"on":""}`}),c.jsx("b",{children:R.label||R.name}),c.jsx("small",{children:(R.route||[]).join(" › ")})]}),c.jsxs("div",{className:"nc-set-node-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!g,onClick:async()=>{const D=window.prompt(m("node-local-alias"),R.alias||"");if(D!=null){if(D.trim()&&!oa(D.normalize("NFC"))){f(m("err-label"));return}y(`${R.instanceId}:alias`),f(null);try{D.trim()?await Sk(t,R.instanceId,D):await $_(t,R.instanceId),l()}catch(H){f(String(H.message||H))}y(null)}},children:m("alias-on-device")}),R.alias&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!g,onClick:async()=>{y(`${R.instanceId}:alias-reset`),f(null);try{await $_(t,R.instanceId),l()}catch(D){f(String(D.message||D))}y(null)},children:m("reset-alias")})]})]},R.instanceId))]}),$&&c.jsxs("div",{className:"nc-set-form nc-local-share",children:[c.jsx("div",{className:"nc-sheet-label",children:m("share-local-heading")}),J.length>1&&c.jsxs("label",{className:"nc-field",children:[m("share-local-hub"),c.jsx("select",{value:$.name,disabled:s||!!g,onChange:R=>E(R.target.value),children:J.map(R=>c.jsx("option",{value:R.name,children:R.label||R.name},R.name))})]}),c.jsxs("label",{className:"nc-check nc-node-share",children:[c.jsx("input",{type:"checkbox",checked:$.shared===!0,disabled:s||!!g,onChange:R=>P(R.target.checked)}),c.jsxs("span",{children:[c.jsx("b",{children:m("share-local-through").replace("{device}",q||m("local")).replace("{hub}",$.label||$.name)}),c.jsx("small",{children:m($.shared?"share-node-on-desc":"share-node-off-desc")})]})]}),c.jsx("div",{className:`nc-set-test${$.shared&&(M!=null&&M.up)?" ok":M!=null&&M.up?"":" ko"}`,children:m(L)}),!(M!=null&&M.up)&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!g,onClick:()=>P($.shared===!0),children:m("share-local-reconnect")})]}),c.jsx(W1,{token:t,deviceDefault:q,localNodeId:i&&i.nodeId||"",localNameDefault:i&&i.localName||"",readonly:s,onSuccess:a}),c.jsxs("div",{className:"nc-set-form",children:[c.jsx("div",{className:"nc-sheet-label",children:m("invite-node")}),c.jsx("small",{className:"nc-set-hint",children:m("invite-v2-hint")}),c.jsxs("div",{className:"nc-set-info nc-invite-endpoint",children:[m("invite-target-local"),": ",c.jsx("b",{children:q||m("invite-target-this")})]}),c.jsxs("label",{className:"nc-field",children:[m("invite-endpoint-label"),c.jsx("input",{placeholder:"user@host",value:b.ssh,disabled:s,onChange:R=>N({...b,ssh:R.target.value})}),c.jsx("small",{className:"nc-set-hint",children:m("invite-endpoint-needed")})]}),J.length>0&&c.jsx("small",{className:"nc-set-hint nc-invite-hub-hint",children:m("invite-hub-only")}),T&&c.jsxs("div",{className:"nc-invite-advanced",children:[c.jsxs("label",{className:"nc-field",children:[m("node-ssh-port-label"),c.jsx("input",{inputMode:"numeric",placeholder:"22",value:b.sshPort,disabled:s,onChange:R=>N({...b,sshPort:R.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),c.jsxs("label",{className:"nc-field",children:[m("device-name-label"),c.jsx("input",{placeholder:q||"NexusCrew",value:C,disabled:s,onChange:R=>I(R.target.value)}),c.jsx("small",{className:"nc-set-hint",children:m("device-name-hint")})]}),c.jsxs("label",{className:"nc-field",children:[m("node-name-label"),c.jsx("input",{placeholder:Lr(C||q||m("node-name-ph")),value:b.name,disabled:s,onChange:R=>N({...b,name:R.target.value?Lr(R.target.value):""})})]})]}),c.jsxs("div",{className:"nc-set-row nc-invite-actions",children:[c.jsx("button",{type:"button",className:"nc-btn primary",disabled:s||!!g||!b.ssh.trim(),onClick:A,children:m("create-pairing-link")}),c.jsxs("button",{type:"button",className:"nc-btn ghost",disabled:!!g,onClick:()=>W(R=>!R),children:[T?"▾":"▸"," ",m("pair-advanced")]})]}),_&&c.jsxs(c.Fragment,{children:[c.jsx(FP,{value:_.pairingUrl}),c.jsx(zP,{text:_.pairingUrl}),c.jsx("div",{className:"nc-set-info",children:m("invite-next-steps")})]})]}),h&&c.jsx("div",{className:"nc-err",children:h})]})}function UP({token:t,readonly:e}){const[n,i]=k.useState("idle"),[s,a]=k.useState(!1),[l,d]=k.useState(null);k.useEffect(()=>{let f=!1;return Kj().then(g=>{f||i(g)}),()=>{f=!0}},[]);const h=async()=>{d(null),a(!0);try{n==="subscribed"?(await Yj(t),i("idle")):(await Vj(t),i("subscribed"))}catch(f){const g=String(f.message||f);g==="push-denied"?(i("denied"),d(m("push-denied"))):g==="push-unsupported"?(i("unsupported"),d(m("push-unsupported"))):d(g)}a(!1)};return n==="unsupported"?c.jsx("div",{className:"nc-set-info",children:m("push-unsupported")}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:e||s||n==="denied",title:e?m("settings-readonly"):"",onClick:h,children:m(n==="subscribed"?"push-disable":"push-enable")}),c.jsx("span",{className:"nc-set-info",children:m(n==="subscribed"?"push-on":n==="denied"?"push-denied":"push-off")})]}),l&&c.jsx("div",{className:"nc-err",children:l})]})}function WP(){const[t,e]=ax(),[n,i]=k.useState(""),[s,a]=k.useState(""),[l,d]=k.useState(!1),[h,f]=k.useState(ix),g=k.useRef(0),y=k.useRef(!1),_=k.useRef(null),w=Ml();k.useEffect(()=>()=>{var x;g.current+=1,y.current&&((x=_.current)==null||x.abort(),_.current=null,y.current=!1,sm())},[]);const b=async()=>{const x=g.current+=1,E=typeof AbortController=="function"?new AbortController:null;i(""),a(""),d(!0),f(!1),y.current=!0,_.current=E;const C=await OP(m("notification-speech-preview"),bu(),void 0,E?{signal:E.signal}:{});return x!==g.current||(_.current=null,y.current=!1,d(!1),f(C===!0),C===!0?a(m("notification-speech-preview-ok")):i(m(C==="voice-error"?"notification-speech-preview-voice-error":C==="timeout"?"notification-speech-preview-timeout":"notification-speech-preview-failed"))),C},N=x=>{var E;if(e(x),i(""),a(""),x)b();else{g.current+=1;const C=y.current;(E=_.current)==null||E.abort(),_.current=null,y.current=!1,d(!1),f(!1),sm(),C||ox()}};return c.jsxs("div",{className:"nc-set-form",children:[c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox","aria-label":m("notification-speech-enable"),checked:t,disabled:!w,onChange:x=>N(x.target.checked)}),c.jsxs("span",{children:[c.jsx("b",{children:m("notification-speech-enable")}),c.jsx("small",{children:m("notification-speech-help")})]})]}),w?c.jsx("div",{className:"nc-set-row",children:c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!t||l,onClick:()=>{b()},children:m(l?"notification-speech-testing":"notification-speech-test")})}):c.jsx("div",{className:"nc-set-info",children:m("notification-speech-unsupported")}),t&&!h&&!l&&!n&&c.jsx("div",{className:"nc-set-info",children:m("notification-speech-needs-test")}),s&&c.jsx("div",{className:"nc-set-info",role:"status",children:s}),n&&c.jsx("div",{className:"nc-err",children:n})]})}function qP({token:t,readonly:e,nodes:n=[],settings:i=null}){const[s,a]=k.useState(null),[l,d]=k.useState([]),[h,f]=k.useState({name:"",mode:"primary-failover",targets:[]}),[g,y]=k.useState(null),[_,w]=k.useState(!1),[b,N]=k.useState(null),[x,E]=k.useState(""),C=k.useCallback(async()=>{try{const[A,R]=await Promise.all([Ek(t),Mk(t)]);a(A),d(Array.isArray(R==null?void 0:R.groups)?R.groups:[]),E("")}catch(A){E(String(A.message||A))}},[t]);k.useEffect(()=>{C()},[C]);const I=async A=>{w(!0),N(null),E("");try{a(await Nk(t,A))}catch(R){E(String(R.message||R))}w(!1)},T=async()=>{w(!0),N(null),E("");try{N({kind:"test",...await Lk(t)})}catch(A){E(String(A.message||A))}w(!1)},W=async()=>{w(!0),N(null),E("");try{N({kind:"stop",...await Rk(t)})}catch(A){E(String(A.message||A))}w(!1)},U=[],Q=new Set,ee=(A,R)=>{const D=typeof A=="string"?A.toLowerCase():"";!/^[a-f0-9]{32}$/.test(D)||Q.has(D)||(Q.add(D),U.push({id:D,label:R||D}))};ee(i==null?void 0:i.nodeId,m("audio-group-local"));for(const A of n||[])ee((A==null?void 0:A.nodeId)||(A==null?void 0:A.instanceId),(A==null?void 0:A.label)||(A==null?void 0:A.name)||(A==null?void 0:A.nodeId));for(const A of h.targets)ee(A,`${A} (${m("audio-group-unavailable-target")})`);const q=(A=null)=>{E(""),A?(y(A.name),f({name:A.name,mode:A.mode,targets:[...A.targets||[]]})):(y(null),f({name:"",mode:"primary-failover",targets:[]}))},J=(A,R)=>f(D=>({...D,targets:R?[...new Set([...D.targets,A])]:D.targets.filter(H=>H!==A)})),$=async()=>{const A=h.name.trim().toLowerCase();if(!/^[a-z0-9][a-z0-9-]{0,31}$/.test(A)||h.targets.length<1){E(m("audio-group-invalid"));return}w(!0),E("");try{const R=await Ak(t,A,{targets:h.targets,mode:h.mode}),D=R==null?void 0:R.group;if(!D||!D.name)throw new Error(m("audio-group-save-failed"));d(H=>[...H.filter(z=>z.name!==D.name),D].sort((z,F)=>z.name.localeCompare(F.name))),q(null)}catch(R){E(String(R.message||R))}w(!1)},M=async A=>{w(!0),E("");try{await jk(t,A),d(R=>R.filter(D=>D.name!==A)),g===A&&q(null)}catch(R){E(String(R.message||R))}w(!1)},L=(s==null?void 0:s.installed)===!0,j=(s==null?void 0:s.liveness)==="ready",O=(s==null?void 0:s.consent)===!0&&L&&j,P=b?b.kind==="stop"?m(b.stopped?"audio-stop-stopped":"audio-stop-idle"):b.status==="accepted"||b.status==="spoken"?m("audio-test-accepted"):b.status==="unknown"?m("audio-test-unknown"):`${m("audio-test-refused")}${b.reason?` (${b.reason})`:""}`:"";return c.jsxs("div",{className:"nc-set-tab nc-audio-settings",children:[c.jsxs("div",{className:"nc-set-info",children:[c.jsx("b",{children:m("audio-title")}),c.jsx("br",{}),m("audio-help")]}),s?c.jsxs(c.Fragment,{children:[c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox","aria-label":m("audio-consent"),checked:s.consent===!0,disabled:e||_,onChange:A=>{I(A.target.checked)}}),c.jsxs("span",{children:[c.jsx("b",{children:m("audio-consent")}),c.jsx("small",{children:m("audio-consent-help")})]})]}),c.jsxs("div",{className:"nc-set-form",children:[c.jsx("div",{className:"nc-sheet-label",children:m("audio-capability")}),c.jsxs("div",{className:"nc-set-info",children:[m("audio-adapter"),": ",s.adapter||m("audio-adapter-none"),c.jsx("br",{}),m("audio-installed"),": ",m(L?"audio-installed-yes":"audio-installed-no"),c.jsx("br",{}),m("audio-liveness"),": ",m(j?"audio-liveness-ready":"audio-liveness-unavailable"),Array.isArray(s.languages)&&s.languages.length>0&&c.jsxs(c.Fragment,{children:[c.jsx("br",{}),m("audio-languages"),": ",s.languages.join(", ")]})]}),s.limits&&c.jsxs("small",{className:"nc-set-hint",children:[m("audio-limits"),": ",s.limits]})]}),!s.consent&&c.jsx("div",{className:"nc-set-info",children:m("audio-test-needs-consent")}),!L&&c.jsx("div",{className:"nc-set-info",children:m("audio-unavailable")}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn primary",disabled:e||_||!O,title:e?m("settings-readonly"):"",onClick:()=>{T()},children:m(_?"audio-testing":"audio-test")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:_,onClick:()=>{W()},children:m(_?"audio-stopping":"audio-stop")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:_,onClick:()=>{C()},children:m("refresh")})]}),c.jsxs("div",{className:"nc-set-form",children:[c.jsx("div",{className:"nc-sheet-label",children:m("audio-groups-title")}),c.jsx("small",{className:"nc-set-hint",children:m("audio-groups-help")}),l.length===0&&c.jsx("div",{className:"nc-set-info",children:m("audio-groups-empty")}),l.map(A=>{var R;return c.jsxs("div",{className:"nc-set-row",children:[c.jsxs("span",{children:[c.jsx("b",{children:A.name})," ",c.jsxs("small",{children:["· ",A.mode==="fanout"?m("audio-group-fanout"):m("audio-group-primary")," · ",((R=A.targets)==null?void 0:R.length)||0]})]}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:e||_,onClick:()=>q(A),children:m("audio-group-edit")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:e||_,onClick:()=>{M(A.name)},children:m("audio-group-delete")})]},A.name)}),c.jsx("div",{className:"nc-set-row",children:c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:e||_,onClick:()=>q(null),children:m("audio-group-new")})}),c.jsxs("label",{className:"nc-field",children:[m("audio-group-name"),c.jsx("input",{"aria-label":m("audio-group-name"),value:h.name,maxLength:"32",disabled:e||_,onChange:A=>f(R=>({...R,name:A.target.value}))})]}),c.jsxs("label",{className:"nc-field",children:[m("audio-group-mode"),c.jsxs("select",{"aria-label":m("audio-group-mode"),value:h.mode,disabled:e||_,onChange:A=>f(R=>({...R,mode:A.target.value})),children:[c.jsx("option",{value:"primary-failover",children:m("audio-group-primary")}),c.jsx("option",{value:"fanout",children:m("audio-group-fanout")})]})]}),c.jsx("div",{className:"nc-set-info",children:m("audio-group-targets")}),U.length===0?c.jsx("small",{className:"nc-set-hint",children:m("audio-group-no-targets")}):U.map(A=>c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:h.targets.includes(A.id),disabled:e||_,onChange:R=>J(A.id,R.target.checked)}),c.jsxs("span",{children:[A.label,c.jsx("small",{children:A.id})]})]},A.id)),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn primary",disabled:e||_,onClick:()=>{$()},children:m("audio-group-save")}),g&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:_,onClick:()=>q(null),children:m("audio-group-cancel")})]})]})]}):c.jsx("div",{className:"nc-set-info",children:m("audio-loading")}),P&&c.jsx("div",{className:"nc-set-note",role:"status",children:P}),x&&c.jsx("div",{className:"nc-err",children:x})]})}function KP(){const[t,e]=qm();return c.jsxs("div",{className:"nc-set-tab nc-input-settings",children:[c.jsx("div",{className:"nc-set-info",children:m("input-settings-local")}),c.jsxs("div",{className:"nc-set-form",children:[c.jsxs("label",{className:"nc-field",children:[m("terminal-keyboard-gesture"),c.jsx("select",{"aria-label":m("terminal-keyboard-gesture"),value:t.terminalKeyboardGesture,onChange:n=>e({terminalKeyboardGesture:n.target.value}),children:b1.map(n=>c.jsx("option",{value:n,children:m(`terminal-keyboard-${n}`)},n))}),c.jsx("small",{children:m("terminal-keyboard-gesture-help")})]}),c.jsxs("label",{className:"nc-field",children:[m("keybar-layout"),c.jsx("select",{"aria-label":m("keybar-layout"),value:t.keybarLayout,onChange:n=>e({keybarLayout:n.target.value}),children:S1.map(n=>c.jsx("option",{value:n,children:m(`keybar-layout-${n}`)},n))}),c.jsx("small",{children:m("keybar-layout-help")})]})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:t.keybarKeepsKeyboardClosed,onChange:n=>e({keybarKeepsKeyboardClosed:n.target.checked})}),c.jsxs("span",{children:[c.jsx("b",{children:m("keybar-ime-lock")}),c.jsx("small",{children:m("keybar-ime-lock-help")})]})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:t.voiceKeepsKeyboardClosed,onChange:n=>e({voiceKeepsKeyboardClosed:n.target.checked})}),c.jsxs("span",{children:[c.jsx("b",{children:m("voice-ime-lock")}),c.jsx("small",{children:m("voice-ime-lock-help")})]})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:t.showKeybarEnter,onChange:n=>e({showKeybarEnter:n.target.checked})}),c.jsxs("span",{children:[c.jsx("b",{children:m("keybar-enter-show")}),c.jsx("small",{children:m("keybar-enter-show-help")})]})]}),c.jsx("div",{className:"nc-set-row",children:c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>e(kr),children:m("input-settings-reset")})})]})}function VP({token:t,roster:e=[],readonly:n}){const i=[{key:"local",route:[],label:m("diagnostics-local"),status:"up"},...e.filter(O=>Array.isArray(O.route)&&O.route.length).map(O=>({key:O.route.join("/"),route:O.route,label:O.label||O.name,status:O.status}))],[s,a]=k.useState("local"),l=i.find(O=>O.key===s)||i[0],[d,h]=k.useState(null),[f,g]=k.useState([]),[y,_]=k.useState(""),[w,b]=k.useState(!1),[N,x]=k.useState(!0),[E,C]=k.useState(900),[I,T]=k.useState("all"),[W,U]=k.useState(""),Q=k.useRef(0),ee=k.useRef(null),q=k.useCallback(async()=>{try{const O=await Ik(t,l.route);if(h(O),_(""),!w){const P=await Bk(t,{after:Q.current,limit:200},l.route);Array.isArray(P.records)&&P.records.length&&(Q.current=P.cursor,g(A=>[...A,...P.records].slice(-500)))}}catch(O){_(O&&O.status===404?m("diagnostics-unsupported"):String(O.message||O))}},[t,l.key,w]);k.useEffect(()=>{Q.current=0,g([]),h(null),_("")},[l.key]),k.useEffect(()=>{let O=null,P=!0;const A=()=>{!P||document.visibilityState==="hidden"||q()},R=()=>{O&&clearInterval(O),O=document.visibilityState==="hidden"?null:setInterval(A,2e3),document.visibilityState!=="hidden"&&A()};return document.addEventListener("visibilitychange",R),R(),()=>{P=!1,O&&clearInterval(O),document.removeEventListener("visibilitychange",R)}},[q]),k.useEffect(()=>{N&&ee.current&&(ee.current.scrollTop=ee.current.scrollHeight)},[f,N]);const J=f.filter(O=>(I==="all"||O.level===I)&&(!W||String(O.component||"").toLowerCase().includes(W.toLowerCase()))),$=J.map(O=>`${O.ts} ${O.level.toUpperCase()} ${O.component} ${O.code} ${O.message}${Object.keys(O.meta||{}).length?` ${JSON.stringify(O.meta)}`:""}`).join(`
166
- `),M=async O=>{_("");try{const P=await O();h(P),await q()}catch(P){_(String(P.message||P))}},L=async()=>{try{await navigator.clipboard.writeText($)}catch{_(m("copy-manual"))}},j=()=>{try{const O=new Blob([`${JSON.stringify(J,null,2)}
167
- `],{type:"application/json"}),P=URL.createObjectURL(O),A=document.createElement("a");A.href=P,A.download="nexuscrew-diagnostics.json",A.click(),URL.revokeObjectURL(P)}catch{_(m("diagnostics-export-failed"))}};return c.jsxs("div",{className:"nc-set-tab nc-diagnostics",children:[c.jsxs("label",{className:"nc-field",children:[m("diagnostics-target"),c.jsx("select",{value:l.key,onChange:O=>a(O.target.value),children:i.map(O=>c.jsxs("option",{value:O.key,children:[O.label,O.status!=="up"?` · ${O.status}`:""]},O.key))})]}),c.jsxs("div",{className:"nc-set-form nc-diag-controls",children:[c.jsx("div",{className:"nc-sheet-label",children:m("diagnostics-verbose")}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("select",{"aria-label":m("diagnostics-duration"),value:E,onChange:O=>C(Number(O.target.value)),disabled:n,children:[300,900,1800,3600].map(O=>c.jsxs("option",{value:O,children:[O/60," min"]},O))}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||(d==null?void 0:d.verbose)===!0,onClick:()=>M(()=>F_(t,!0,E,l.route)),children:m("enable")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||(d==null?void 0:d.verbose)!==!0,onClick:()=>M(()=>F_(t,!1,E,l.route)),children:m("stop")})]}),c.jsx("small",{className:"nc-set-hint",children:d!=null&&d.verbose?m("diagnostics-expires").replace("{time}",new Date(d.expiresAt).toLocaleTimeString()):m("diagnostics-off")})]}),c.jsxs("div",{className:"nc-diag-filters",children:[c.jsxs("select",{"aria-label":m("diagnostics-level"),value:I,onChange:O=>T(O.target.value),children:[c.jsx("option",{value:"all",children:m("diagnostics-all-levels")}),["debug","info","warn","error"].map(O=>c.jsx("option",{value:O,children:O},O))]}),c.jsx("input",{"aria-label":m("diagnostics-component"),placeholder:m("diagnostics-component"),value:W,onChange:O=>U(O.target.value)})]}),c.jsxs("div",{className:"nc-set-row",children:[c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:w,onChange:O=>b(O.target.checked)})," ",m("diagnostics-pause")]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:N,onChange:O=>x(O.target.checked)})," ",m("diagnostics-autoscroll")]})]}),c.jsx("pre",{ref:ee,className:"nc-diag-log","aria-label":m("diagnostics-log"),children:$||m("diagnostics-empty")}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:L,children:m("copy")}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:j,children:m("diagnostics-export")}),c.jsx("button",{type:"button",className:"nc-btn danger",disabled:n,onClick:()=>{window.confirm(m("diagnostics-clear-confirm"))&&M(async()=>{const O=await Ok(t,l.route);return Q.current=0,g([]),O})},children:m("diagnostics-clear")})]}),y&&c.jsx("div",{className:"nc-err",children:y})]})}function YP({token:t,settings:e,readonly:n,refresh:i,roster:s,section:a,setSection:l}){const[d,h]=k.useState(null),[f,g]=k.useState(null),[y,_]=k.useState(!1),[w,b]=k.useState(!1),[N,x]=k.useState(null),[E,C]=k.useState(!0),[I,T]=k.useState(!1);k.useEffect(()=>{x(e&&e.update||null),C(!e||e.autoUpdate!==!1),T(!!(e&&e.alternateScreen))},[e]);const W=async()=>{h(null),g(null),b(!0);try{const L=await _k(t);g(L.note||"ok"),_(!1)}catch(L){h(String(L.message||L))}b(!1)},U=async()=>{h(null),g(null),b(!0);try{const L=await Pk(t);g(`${L.note||"ok"}${L.target?` (${L.target})`:""}`)}catch(L){h(String(L.message||L))}b(!1)},Q=async L=>{h(null),g(null),b(!0);try{await qf(t,{autoUpdate:L}),C(L),i&&await i()}catch(j){h(String(j.message||j))}b(!1)},ee=async L=>{h(null),g(null),b(!0);try{await qf(t,{alternateScreen:L}),T(L),i&&await i()}catch(j){h(String(j.message||j))}b(!1)},q=async()=>{h(null),g(null),b(!0);try{x(await Tk(t))}catch(L){h(String(L.message||L))}b(!1)},J=async()=>{h(null),g(null),b(!0);try{const L=await Dk(t);x(L),g(m("npm-update-restarting"))}catch(L){h(String(L.message||L))}b(!1)},$=()=>{window.confirm(m("composer-clear-confirm"))&&(h(null),QM()?(window.dispatchEvent(new Event(Gp)),g(m("composer-clear-done"))):h(m("composer-clear-failed")))},M=e&&e.service;return c.jsxs("div",{className:"nc-set-tab",children:[c.jsx("div",{className:"nc-system-tabs",role:"tablist","aria-label":m("tab-system"),children:["general","diagnostics"].map(L=>c.jsx("button",{type:"button",role:"tab","aria-selected":a===L,className:`nc-set-tabbtn${a===L?" on":""}`,onClick:()=>l(L),children:m(`system-${L}`)},L))}),a==="general"&&c.jsxs(c.Fragment,{children:[c.jsxs("section",{className:"nc-system-group",children:[c.jsx("h3",{children:m("system-this-node")}),e&&c.jsxs("div",{className:"nc-set-info",children:["v",e.version," · ",e.platform," · :",e.port,c.jsx("br",{}),M&&M.installed?m("service-installed"):m("service-missing"),M&&M.installed?` · ${M.active?m("service-active"):m("service-inactive")}`:"",M?` · boot ${M.boot?"on":"off"}`:""]}),c.jsx("div",{className:"nc-set-row",children:c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||w,title:n?m("settings-readonly"):"",onClick:U,children:m("service-regenerate")})}),c.jsx(UP,{token:t,readonly:n}),c.jsx(WP,{})]}),c.jsxs("section",{className:"nc-system-group",children:[c.jsx("h3",{children:m("system-updates")}),c.jsxs("div",{className:"nc-set-form nc-update-settings",children:[c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:E,disabled:n||w||N&&!N.supported,onChange:L=>Q(L.target.checked)}),c.jsxs("span",{children:[c.jsx("b",{children:m("npm-auto-update")}),c.jsx("small",{children:m("npm-auto-update-help")})]})]}),N&&c.jsxs("div",{className:"nc-set-info",children:[m("npm-update-current")," v",N.current,N.latest?` · ${m("npm-update-latest")} v${N.latest}`:""," · ",m(N.supported?N.phase==="idle"&&N.checked!==!0?"npm-update-never":`npm-update-${N.phase}`:"unsupported")]}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||w||!N||!N.supported,onClick:q,children:m("npm-update-check")}),N&&N.available&&c.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||w||N.phase==="installing",onClick:J,children:m("npm-update-install")})]}),N&&N.lastError&&c.jsx("div",{className:"nc-err",children:N.lastError})]})]}),c.jsxs("section",{className:"nc-system-group",children:[c.jsx("h3",{children:m("system-security")}),c.jsx("div",{className:"nc-set-row",children:c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||w,title:n?m("settings-readonly"):"",onClick:()=>{h(null),g(null),_(!0)},children:m("token-rotate")})})]}),c.jsxs("section",{className:"nc-system-group",children:[c.jsx("h3",{children:m("system-local-data")}),c.jsxs("div",{className:"nc-set-form",children:[c.jsx("div",{className:"nc-sheet-label",children:m("composer-clear-data")}),c.jsx("small",{className:"nc-set-hint",children:m("composer-clear-data-help")}),c.jsx("div",{className:"nc-set-row",children:c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:$,children:m("composer-clear-data")})})]})]})]}),a==="diagnostics"&&c.jsxs("section",{className:"nc-system-group nc-system-diagnostics",children:[c.jsx("h3",{children:m("system-diagnostics")}),c.jsxs("div",{className:"nc-set-form nc-alternate-screen-settings",children:[c.jsx("div",{className:"nc-sheet-label",children:m("system-terminal")}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox","aria-label":m("alternate-screen"),checked:I,disabled:n||w,onChange:L=>ee(L.target.checked)}),c.jsxs("span",{children:[c.jsx("b",{children:m("alternate-screen")}),c.jsx("small",{children:m("alternate-screen-help")})]})]})]}),c.jsx(VP,{token:t,roster:s,readonly:n})]}),y&&c.jsxs("div",{className:"nc-set-confirm",children:[c.jsx("div",{children:m("token-rotate-explain")}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:w,onClick:()=>_(!1),children:m("cancel")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:w,onClick:W,children:m("confirm")})]})]}),f&&c.jsx("div",{className:"nc-set-note",children:f}),d&&c.jsx("div",{className:"nc-err",children:d})]})}function GP({token:t,onClose:e,initialTab:n="nodes",initialLocation:i="",startNewCell:s=!1}){li();const a=n==="diagnostics"?"diagnostics":"general",[l,d]=k.useState(n==="diagnostics"?"system":n),h=k.useRef(null),f=k.useRef(null),[g,y]=k.useState({start:!1,end:!1}),[_,w]=k.useState(a),[b,N]=k.useState(null),[x,E]=k.useState([]),[C,I]=k.useState([]),[T,W]=k.useState(!1),[U,Q]=k.useState(null),[ee,q]=k.useState(0),J=_m(t,!0,ee),$=k.useCallback(()=>{const L=h.current;if(!L)return;const j=L.scrollWidth>L.clientWidth+1,O={start:j&&L.scrollLeft>1,end:j&&L.scrollLeft+L.clientWidth<L.scrollWidth-1};y(P=>P.start===O.start&&P.end===O.end?P:O)},[]);k.useEffect(()=>{const L=h.current;if(!L)return;const j=typeof ResizeObserver=="function"?new ResizeObserver($):null;return j==null||j.observe(L),window.addEventListener("resize",$),$(),()=>{j==null||j.disconnect(),window.removeEventListener("resize",$)}},[$]),k.useEffect(()=>{var j,O;(O=(j=f.current)==null?void 0:j.scrollIntoView)==null||O.call(j,{behavior:"smooth",block:"nearest",inline:"nearest"});const L=window.requestAnimationFrame?window.requestAnimationFrame($):setTimeout($,0);return()=>{window.cancelAnimationFrame?window.cancelAnimationFrame(L):clearTimeout(L)}},[l,$]);const M=k.useCallback(async()=>{var L;try{const j=await c0(t);N(j),Q(null)}catch(j){Q(String(j.message||j))}try{const O=(await gk(t)).peers||[];let P=[],A=[];try{const[R,D]=await Promise.all([pn("/api/config",t).then(K=>K.json()).catch(()=>null),d0(t).catch(()=>null)]),H=R&&typeof R.instanceId=="string"?R.instanceId:"",z=[{instanceId:H||null,route:[],label:null},...k0(D,H)],F=await Promise.all(z.map(async K=>{try{return{ok:!0,peers:((await u0(t,K.route)).nodes||[]).map(Y=>C0(Y,K)).filter(Boolean)}}catch(ne){return{ok:!1,owner:K,error:ne}}}));for(const K of F){if(K.ok){P.push(...K.peers);continue}K.owner.route.length!==0&&A.push({instanceId:K.owner.instanceId,label:K.owner.label,route:K.owner.route,failure:/timeout/i.test(String(((L=K.error)==null?void 0:L.message)||K.error))?"timeout":"unreachable"})}}catch{}I(A),E([...O,...P])}catch(j){Q(String(j.message||j))}},[t]);return k.useEffect(()=>{M();const L=setInterval(M,5e3);return()=>clearInterval(L)},[M]),k.useEffect(()=>{let L=!1;return pn("/api/config",t).then(j=>j.json()).then(j=>{L||W(!!j.readonlyDefault)}).catch(()=>{}),()=>{L=!0}},[t]),c.jsx("div",{className:"nc-set-overlay",onClick:e,children:c.jsxs("div",{className:"nc-set-panel",onClick:L=>L.stopPropagation(),children:[c.jsxs("div",{className:"nc-set-head",children:[c.jsx(dt,{name:"gear",size:18}),c.jsx("b",{children:m("settings")}),c.jsx("button",{type:"button",className:"nc-set-close",onClick:e,title:m("close"),children:c.jsx(dt,{name:"x",size:18})})]}),T&&c.jsx("div",{className:"nc-set-readonly",children:m("settings-readonly")}),U&&c.jsx("div",{className:"nc-err",children:U}),c.jsx("div",{className:`nc-set-tabs-wrap${g.start?" has-start-overflow":""}${g.end?" has-end-overflow":""}`,children:c.jsx("div",{className:"nc-set-tabs",ref:h,onScroll:$,children:["nodes","fleet","audio","input","system"].map(L=>c.jsx("button",{ref:l===L?f:null,type:"button",className:`nc-set-tabbtn${l===L?" on":""}`,onClick:()=>d(L),children:m(`tab-${L}`)},L))})}),c.jsxs("div",{className:"nc-set-body",children:[l==="nodes"&&c.jsx(HP,{token:t,nodes:x,roster:J,settings:b,readonly:T,vlUnavailable:C,refresh:M,refreshAliases:()=>q(L=>L+1)}),l==="fleet"&&c.jsx(xP,{token:t,readonly:T,startNewCell:s,initialLocation:i,targets:J.map(L=>({route:L.route,label:L.label||L.name,status:L.status}))}),l==="audio"&&c.jsx(qP,{token:t,readonly:T,nodes:x,settings:b}),l==="input"&&c.jsx(KP,{}),l==="system"&&c.jsx(YP,{token:t,settings:b,readonly:T,refresh:M,roster:J,section:_,setSection:w})]})]})})}function XP({token:t,initialPair:e,deviceDefault:n="",localNodeId:i="",localNameDefault:s="",onPairDone:a,onDone:l}){li();const[d,h]=k.useState(e?"pair":"welcome"),[f,g]=k.useState(!1),[y,_]=k.useState(null),[w,b]=k.useState(null),N=async()=>{g(!0),_(null);try{await qf(t,{wizardDone:!0}),a&&a(),l()}catch(x){_(String(x.message||x)),g(!1)}};return c.jsx("div",{className:"nc-wiz-overlay",children:c.jsxs("div",{className:"nc-wiz",children:[c.jsxs("div",{className:"nc-wiz-head",children:[c.jsx("b",{children:m("wizard-title")}),c.jsx("small",{children:m("hydra-simple")})]}),d==="welcome"&&c.jsxs("div",{className:"nc-wiz-body",children:[c.jsx("div",{className:"nc-wiz-done",children:m("local-ready")}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",disabled:f,onClick:N,children:m("local-only")}),c.jsx("button",{className:"nc-btn primary",disabled:f,onClick:()=>h("pair"),children:m("add-node")})]})]}),d==="pair"&&c.jsxs("div",{className:"nc-wiz-body",children:[c.jsx(W1,{token:t,initial:e||"",autoStart:!!e,deviceDefault:n,localNodeId:i,localNameDefault:s,onBusyChange:g,onSuccess:async x=>{b(x&&x.authorizedKeys?{line:x.authorizedKeys,note:x.authorizedKeysNote||""}:null),a&&a(),h("done")}}),c.jsx("div",{className:"nc-sheet-actions",children:c.jsx("button",{className:"nc-btn ghost",disabled:f,onClick:()=>{a&&a(),h("welcome")},children:m("back")})})]}),d==="done"&&c.jsxs("div",{className:"nc-wiz-body",children:[c.jsx("div",{className:"nc-wiz-done",children:m("node-connected")}),w&&c.jsx(tg,{line:w.line,note:w.note}),c.jsx("div",{className:"nc-sheet-actions",children:c.jsx("button",{className:"nc-btn primary",disabled:f,onClick:N,children:m("finish")})})]}),y&&c.jsx("div",{className:"nc-err",children:y})]})})}function QP(t,e){if(typeof EventSource>"u"||!t)return()=>{};const n=new EventSource(`/api/events?token=${encodeURIComponent(t)}`);return n.onmessage=i=>{try{const s=JSON.parse(i.data);s&&typeof s=="object"&&typeof s.type=="string"&&e(s)}catch{}},()=>{try{n.close()}catch{}}}const JP=6e3,ZP=12e3;function eT({n:t,onClose:e}){return c.jsxs("div",{className:`nc-ntf-toast${t.urgency==="high"?" high":""}`,role:"status","aria-live":"polite",children:[c.jsxs("div",{className:"nc-ntf-toast-txt",children:[c.jsx("b",{children:t.title}),t.body&&c.jsx("small",{children:t.body}),t.session&&c.jsx("span",{className:"nc-ntf-from",children:t.session})]}),c.jsx("button",{type:"button",className:"nc-ntf-x",onClick:e,title:m("close"),children:c.jsx(dt,{name:"x",size:14})})]})}function tT({ask:t,token:e,onAnswered:n,onDismiss:i}){const[s,a]=k.useState(""),[l,d]=k.useState(!1),[h,f]=k.useState(null),[g,y]=k.useState(!1),_=async b=>{const N=String(b||"").trim();if(!(!N||l)){f(null),d(!0);try{await zk(e,t.id,N),n(t.id)}catch(x){f(String(x.message||x))}d(!1)}},w=async()=>{if(!g){y(!0);try{await Fk(e,t.id),i(t.id)}catch{y(!1)}}};return c.jsxs("div",{className:"nc-ask-card",children:[c.jsxs("div",{className:"nc-ask-head",children:[c.jsx("span",{className:"nc-ntf-from",children:t.session}),c.jsxs("code",{className:"nc-ask-id",children:["#",t.id]}),c.jsx("button",{type:"button",className:"nc-ask-dismiss",title:m("ask-dismiss"),"aria-label":m("ask-dismiss"),disabled:g,onClick:w,children:c.jsx(dt,{name:"x",size:14})})]}),c.jsx("div",{className:"nc-ask-q",children:t.question}),Array.isArray(t.options)&&t.options.length>0&&c.jsx("div",{className:"nc-ask-opts",children:t.options.map(b=>c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:l,onClick:()=>_(b),children:b},b))}),c.jsxs("div",{className:"nc-ask-reply",children:[c.jsx("textarea",{rows:2,placeholder:m("ask-reply-ph"),value:s,disabled:l,onChange:b=>a(b.target.value)}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:l||!s.trim(),onClick:()=>_(s),children:m("send")})]}),h&&c.jsx("div",{className:"nc-err",children:h})]})}function nT({token:t}){const[e]=li(),[n]=ax(),[i,s]=k.useState([]),[a,l]=k.useState([]),[d,h]=k.useState(()=>{try{return/(?:^|[#&])ask=/.test(location.hash)}catch{return!1}}),f=k.useRef(0),g=k.useRef(null);g.current||(g.current=$P());const y=k.useRef({enabled:n,lang:e});y.current={enabled:n,lang:e};const _=k.useCallback(x=>{s(E=>E.filter(C=>C.key!==x))},[]),w=k.useCallback(x=>{const E=`t${f.current+=1}`;s(I=>[...I.slice(-3),{...x,key:E}]),setTimeout(()=>_(E),x.urgency==="high"?ZP:JP);const C=y.current;if(C.enabled)try{g.current.enqueue(x,TP(x,C.lang))}catch{}},[_]);k.useEffect(()=>{n||g.current.stop()},[n]),k.useEffect(()=>{const x=()=>{(document.visibilityState!=="visible"||!document.hasFocus())&&g.current.stop()},E=()=>g.current.stop();return document.addEventListener("visibilitychange",x),window.addEventListener("blur",x),window.addEventListener(im,E),()=>{document.removeEventListener("visibilitychange",x),window.removeEventListener("blur",x),window.removeEventListener(im,E),typeof g.current.dispose=="function"?g.current.dispose():g.current.stop()}},[]),k.useEffect(()=>{if(!t)return;let x=!1;$k(t).then(C=>{x||l(C.asks||[])}).catch(()=>{});const E=QP(t,C=>{C.type==="notify"?w(C):C.type==="ask"&&C.ask&&C.ask.id?l(I=>I.some(T=>T.id===C.ask.id)?I:[...I,C.ask]):C.type==="ask-answered"&&C.id?l(I=>I.filter(T=>T.id!==C.id)):C.type==="ask-dismissed"&&C.id&&l(I=>I.filter(T=>T.id!==C.id))});return()=>{x=!0,E()}},[t,w]);const b=x=>l(E=>E.filter(C=>C.id!==x)),N=x=>l(E=>E.filter(C=>C.id!==x));return c.jsxs(c.Fragment,{children:[i.length>0&&c.jsx("div",{className:"nc-ntf-toasts",children:i.map(x=>c.jsx(eT,{n:x,onClose:()=>_(x.key)},x.key))}),a.length>0&&!d&&c.jsxs("button",{type:"button",className:"nc-ask-badge",onClick:()=>h(!0),title:m("asks-title"),children:["? ",c.jsx("span",{className:"nc-ask-count",children:a.length})]}),a.length>0&&d&&c.jsxs("div",{className:"nc-ask-panel",children:[c.jsxs("div",{className:"nc-ask-panel-head",children:[c.jsx("b",{children:m("asks-title")}),c.jsx("span",{className:"nc-ask-count",children:a.length}),c.jsx("button",{type:"button",className:"nc-ntf-x",onClick:()=>h(!1),title:m("close"),children:c.jsx(dt,{name:"x",size:16})})]}),c.jsx("div",{className:"nc-ask-panel-body",children:a.map(x=>c.jsx(tT,{ask:x,token:t,onAnswered:b,onDismiss:N},x.id))})]})]})}const iT=4e3;async function sT(t){const e=await pn("/api/sessions",t);if((e==null?void 0:e.ok)===!1)throw new Error(`HTTP ${e.status}`);const n=await e.json();if(!Array.isArray(n==null?void 0:n.sessions))throw new Error("invalid sessions payload");return n.sessions}async function Hf(t,e=[]){var d;const[n,i]=await Promise.allSettled([e.length?hm(t,e):sT(t),Ar(t,e)]),s=n.status==="fulfilled"&&Array.isArray((d=n.value)==null?void 0:d.sessions)?n.value.sessions:Array.isArray(n.value)?n.value:null,a=i.status==="fulfilled"?i.value:null,l=(a==null?void 0:a.available)===!0&&Array.isArray(a.cells)?a.cells:null;return{sessions:s,cells:l,fresh:Array.isArray(s)&&Array.isArray(l)}}function lx(t,e,n){return n===!0&&(t==null?void 0:t.degraded)!==!0&&(t==null?void 0:t.active)===!0&&t.tmux!==!1&&!!t.tmuxSession&&(e||[]).some(i=>(i==null?void 0:i.name)===t.tmuxSession)}function rT(t){const e=new Map((t.sessions||[]).map(s=>[s.name,s])),n=[],i=(s,a,l,d=[],h="")=>{const f=new Map((a||[]).map(g=>[g.name,g]));for(const g of s||[]){const y=f.get(g.tmuxSession)||{},_=bm(g,y),w=lx(g,a,l);n.push({key:Cl(d,g.tmuxSession||g.cell),session:g.tmuxSession,route:d,cellName:g.cell,label:g.cell,node:d.length?d.join("/"):"",nodeLabel:h,live:w,selectable:w,verified:l===!0,working:_.working,degraded:!!g.degraded,active:g.active===!0,activity:y.activity||g.activity||0,subtitle:_.subtitle,preview:y.preview||g.preview||"",telemetry:y.telemetry||null,panelUrl:g.panelUrl||""})}};i(t.cells,[...e.values()],t.localFresh===!0);for(const s of t.nodeGroups||[]){const a=Array.isArray(s.route)?s.route:[];s.kind==="vl"||!a.length||i(s.cells,s.sessions,s.switcherFresh===!0,a,s.label||s.name||"")}return n}function oT(t){const e=new Map,n=Array.isArray(t.sessions)?t.sessions:[],i=Array.isArray(t.cells)?t.cells:[],s=new Map(n.map(l=>[l.name,l])),a=new Set(i.map(l=>l.tmuxSession).filter(Boolean));e.set("local",Sm(i,n.filter(l=>!a.has(l.name)),s));for(const l of t.nodeGroups||[]){const d=Array.isArray(l.route)?l.route:[];if(l.kind==="vl"||!d.length)continue;const h=Array.isArray(l.cells)?l.cells:[],f=Array.isArray(l.sessions)?l.sessions:[],g=new Set(h.map(y=>y.tmuxSession).filter(Boolean));e.set(d.join("/"),Nu({...l,route:d,cells:h,sessions:f,unmanaged:f.filter(y=>!g.has(y.name))}).rawItems)}return e}function aT(t,e,n,i){return[...new Set(t.map(a=>a.node||"local"))].flatMap(a=>{const l=t.filter(g=>(g.node||"local")===a),d=new Map((e.get(a)||[]).map(g=>[g.key,g])),h=new Map(l.map(g=>[g.key,g])),f=l.map(g=>{const y=d.get(g.key);return{...g,label:(y==null?void 0:y.label)||g.label,live:(y==null?void 0:y.live)??g.live,fresh:(y==null?void 0:y.fresh)===!0,activity:(y==null?void 0:y.activity)??g.activity}});return Nr(f,n,"all",Vs(i,a)).map(g=>h.get(g.key))})}function lT({token:t,current:e,onPick:n,onClose:i,panelPort:s=0,nodePanelPorts:a={},hostByRoute:l={},onDesignateCell:d,onClearHostCell:h}){const[f,g]=k.useState(sy),[y,_]=k.useState(!1),[w,b]=k.useState(!1),[N,x]=k.useState(""),[E,C]=k.useState(null),[I,T]=k.useState(""),[W,U]=k.useState(""),Q=k.useRef(null),ee=k.useRef(null),q=k.useMemo(()=>rT(f),[f]),J=k.useMemo(()=>oT(f),[f]),{pins:$,orders:M,togglePin:L,removePin:j,pinError:O,canMoveRoster:P,moveRoster:A,stepRoster:R}=wm(),D=k.useMemo(()=>aT(q,J,$,M),[q,J,$,M]),H=k.useMemo(()=>y?D:D.filter(Y=>Y.selectable||Y.degraded&&Y.active),[D,y]),z=k.useMemo(()=>q.find(Y=>Y.key===I&&Y.selectable),[q,I]),F=k.useMemo(()=>E?q.find(Y=>Y.key===E.key):null,[q,E]);k.useEffect(()=>{O&&O.message&&x(O.message)},[O]),k.useEffect(()=>{var oe;const Y=document.activeElement;(oe=ee.current)==null||oe.focus();const de=pe=>{pe.key==="Escape"&&i()};return document.addEventListener("keydown",de),()=>{var pe;document.removeEventListener("keydown",de),(pe=Y==null?void 0:Y.focus)==null||pe.call(Y)}},[i]),k.useEffect(()=>{let Y=!0,de=!1;const oe=async()=>{if(de)return;de=!0;const xe=sy(),Qe=Array.isArray(xe.nodeGroups)?xe.nodeGroups:[],ot=Hf(t),De=ht=>ht.kind!=="vl"&&Array.isArray(ht.route)&&ht.route.length>0,je=await Promise.all(Qe.filter(De).map(async ht=>({group:ht,result:await Hf(t,ht.route)}))),tt=await ot;if(!Y)return;const Nt=new Map(je.map(({group:ht,result:kt})=>[JSON.stringify(ht.route||[]),kt])),Ct=Qe.map(ht=>{if(!De(ht))return{...ht,switcherFresh:!1};const kt=Nt.get(JSON.stringify(ht.route||[]));return kt?{...ht,sessions:kt.sessions||ht.sessions||[],cells:kt.cells||ht.cells||[],switcherFresh:kt.fresh}:{...ht,switcherFresh:!1}}),ft=F0({...xe,sessions:tt.sessions||xe.sessions||[],cells:tt.cells||xe.cells||[],localFresh:tt.fresh,nodeGroups:Ct,refreshedAt:Date.now()});g(ft),b(!0),de=!1};oe();const pe=setInterval(oe,iT);return()=>{Y=!1,clearInterval(pe)}},[t]);const K=Y=>Y.degraded?m("cell-degraded"):Y.verified?Y.selectable?Y.working?m("cell-working"):m("cell-idle"):m("cell-off"):m("cell-switcher-not-confirmed"),ne=Y=>{if(x(""),!Y.selectable){x(Y.verified?m("cell-switcher-not-active"):m("cell-switcher-not-confirmed"));return}T(Y.key)},re=async()=>{const Y=z;if(!Y){x(m("cell-switcher-select"));return}x(""),U(Y.key);try{const de=await Hf(t,Y.route),oe=(de.cells||[]).find(pe=>(pe==null?void 0:pe.cell)===Y.cellName&&(pe==null?void 0:pe.tmuxSession)===Y.session);if(de.fresh!==!0){x(m("cell-switcher-verify-failed"));return}if(!lx(oe,de.sessions,de.fresh)){x(m("cell-switcher-not-active"));return}n({session:Y.session,...Y.node?{node:Y.node}:{},cellName:Y.cellName}),i()}catch{x(m("cell-switcher-verify-failed"))}finally{U("")}};return c.jsx("div",{className:"nc-cell-switcher-backdrop",onClick:i,children:c.jsxs("aside",{ref:Q,className:"nc-cell-switcher",role:"dialog","aria-label":m("fleet-cells"),tabIndex:-1,onClick:Y=>Y.stopPropagation(),children:[c.jsxs("div",{className:"nc-cell-switcher-list",children:[!w&&c.jsx("div",{className:"nc-empty",role:"status",children:m("cell-switcher-refreshing")}),w&&H.length===0&&c.jsx("div",{className:"nc-empty",role:"status",children:m("cell-switcher-empty-active")}),H.map(Y=>{const de=(e==null?void 0:e.session)===Y.session&&((e==null?void 0:e.node)||"")===Y.node,oe=I===Y.key,pe=K(Y),xe=Qp(m,Y.activity),Qe=Jp(m,Y.telemetry),ot=[xe,Qe].filter(Boolean).join(" · "),De=Y.node||"local",je=J.get(De)||q.filter(tt=>(tt.node||"local")===De);return c.jsxs("div",{className:`nc-cell-switcher-row${de?" current":""}${oe?" selected":""}${Y.selectable?"":" off"}`,"data-roster-key":Y.key,"data-position":De,children:[c.jsx(ys,{position:De,itemKey:Y.key,label:Y.cellName,canMove:P,onMove:(tt,Nt)=>A(De,tt,Nt,je),onStep:tt=>R(De,Y.key,tt,je)}),c.jsx("button",{type:"button",className:"nc-cell-switcher-peek",title:m("cell-peek"),"aria-label":`${m("cell-peek")}: ${Y.cellName}`,onClick:tt=>{tt.stopPropagation(),C({key:Y.key,source:"preview"})},children:c.jsx("span",{className:`nc-cell-switcher-dot${Y.degraded?" warn":Y.live?` on${Y.working?" working":""}`:""}`})}),c.jsxs("span",{className:"nc-cell-switcher-acts",children:[c.jsx("button",{type:"button",className:"nc-cell-switcher-act",title:m("cell-peek-stream"),"aria-label":`${m("cell-peek-stream")}: ${Y.cellName}`,onClick:tt=>{tt.stopPropagation(),C({key:Y.key,source:"stream"})},children:"▶"}),Y.panelUrl&&c.jsx("button",{type:"button",className:"nc-cell-switcher-act",title:m("cell-peek-panel"),"aria-label":`${m("cell-peek-panel")}: ${Y.cellName}`,onClick:tt=>{tt.stopPropagation(),C({key:Y.key,source:"panel"})},children:"▣"})]}),c.jsx("button",{type:"button",className:"nc-cell-switcher-row-select","aria-current":de?"true":void 0,"aria-pressed":oe,"aria-disabled":!Y.selectable,disabled:W===Y.key,onClick:()=>ne(Y),children:c.jsxs("span",{className:"nc-cell-switcher-copy",children:[c.jsx("b",{children:Y.cellName}),c.jsx("small",{className:"nc-cell-switcher-state",children:pe}),c.jsx("small",{children:[Y.nodeLabel,Y.subtitle].filter(Boolean).join(" · ")}),ot&&c.jsx("small",{className:"nc-cell-switcher-telemetry",children:ot})]})}),c.jsx(xu,{item:{key:Y.key,value:{cell:Y.cellName}},pins:$,hostByRoute:l,route:Y.route||[],cellName:Y.cellName,baseClassName:"nc-cell-switcher-star",togglePin:L,removePin:j,designate:d,clearHost:h,onOutcome:tt=>{tt.ok||x(m(Yf(tt.error)))}})]},Y.key)})]}),N&&c.jsx("div",{className:"nc-cell-switcher-notice",role:"status",children:N}),E&&F&&c.jsx(w1,{row:F,token:t,initialSource:E.source,panelPort:$u(F.route||[],a,s),onClose:()=>C(null)}),c.jsx("div",{className:"nc-cell-switcher-actions",children:c.jsx("button",{type:"button",className:"nc-cell-switcher-open",disabled:!z||!!W,onClick:re,children:z?`${m("cell-switcher-open")}: ${z.cellName}`:m("cell-switcher-select")})}),c.jsxs("div",{className:"nc-cell-switcher-controls",children:[c.jsx("b",{children:m("fleet-cells")}),c.jsx("button",{type:"button",className:"nc-cell-switcher-filter","aria-pressed":y,onClick:()=>{x(""),_(Y=>!Y)},children:m(y?"cell-switcher-show-active":"cell-switcher-show-all")}),c.jsx("button",{ref:ee,type:"button",className:"nc-cell-switcher-close","aria-label":m("cell-switcher-close"),title:m("cell-switcher-close"),onClick:i,children:"×"})]})]})})}const cT=2e3;function uT(t){if(t.kind==="gap")return`${m("vl-events-gap")} ${t.count||"?"}`;if(t.kind==="truncate")return m("vl-events-truncated");if(t.kind==="turn_end")return m("vl-events-turn-end");if(t.kind==="done")return m("vl-events-done");if(t.kind==="writer_epoch")return m("vl-events-writer-epoch");if(t.kind==="tool_start")return`${m("vl-events-tool")} ${t.name||""}`.trim();if(t.kind==="tool_end"){const e=t.isError?m("vl-events-tool-failed"):m("vl-events-tool-ok");return`${m("vl-events-tool")} ${t.name||""} — ${e}`.trim()}return t.kind==="usage"?t.text||m("vl-events-usage"):t.text||""}function dT({token:t,nodeId:e,route:n=[]}){const[i,s]=k.useState([]),[a,l]=k.useState(!1),d=k.useRef(0),h=k.useRef(!1);return k.useEffect(()=>{let f=!0;d.current=0,h.current=!1,s([]);const g=async()=>{if(!h.current){h.current=!0;try{const w=await vk(t,e,d.current,n);if(!f)return;l(!1);const N=(Array.isArray(w==null?void 0:w.events)?w.events:[]).filter(x=>Number.isSafeInteger(x==null?void 0:x.seq)&&x.seq>d.current);N.length&&(s(x=>x.concat(N).slice(-500)),d.current=N[N.length-1].seq),Number.isSafeInteger(w==null?void 0:w.cursor)&&w.cursor>d.current&&(d.current=w.cursor)}catch{f&&l(!0)}finally{h.current=!1}}},y=()=>{g().catch(()=>{})};y();const _=setInterval(y,cT);return()=>{f=!1,clearInterval(_)}},[t,e,JSON.stringify(n)]),c.jsxs("div",{className:"nc-vl-events",children:[a&&c.jsx("div",{className:"nc-set-hint nc-vl-events-stale",children:m("vl-events-stale")}),i.length===0&&!a&&c.jsx("small",{className:"nc-set-hint","data-testid":"vl-events-empty",children:m("vl-events-empty")}),i.length>0&&c.jsx("ol",{className:"nc-vl-events-list",children:i.map(f=>c.jsx("li",{"data-testid":`vl-ev-${f.seq}`,className:`nc-vl-ev nc-vl-ev-${f.kind}${f.isError?" error":""}${f.kind==="gap"?" gap":""}`,children:uT(f)},`${f.seq}-${f.kind}`))})]})}function Wb({peer:t,token:e,onBack:n}){var i;return li(),t?c.jsxs("section",{className:"nc-vl-session-view",children:[c.jsxs("header",{className:"nc-bar nc-bar-single",children:[c.jsxs("button",{onClick:n,title:m("back"),children:[c.jsx(dt,{name:"chevronLeft",size:18}),c.jsx("span",{className:"nc-bar-label",children:m("back")})]}),c.jsxs("span",{className:"nc-bar-center",children:[c.jsx("b",{title:t.label,children:t.label}),((i=t.session)==null?void 0:i.profile)&&c.jsxs("small",{className:"nc-bar-sub",children:[t.session.profile," · ",m("vl-events-title")]})]}),c.jsx("span",{className:"nc-bar-right"})]}),c.jsx("div",{className:"nc-vl-session-body",children:c.jsx(dT,{token:e,nodeId:t.nodeId,route:t.route||[]})})]}):null}const Uf=t=>Ss(so(t)).length===0,Wf=t=>Array.isArray(t)?t.join("/"):"";function hT(t){const e=new Set,n=[];for(const i of Array.isArray(t)?t:[])!i||!Pi.test(String(i.instanceId||""))||!Array.isArray(i.route)||!i.route.length||e.has(i.instanceId)||(e.add(i.instanceId),n.push({instanceId:i.instanceId,route:[...i.route],label:String(i.label||i.name||i.route.join(" › ")),status:i.status||"offline"}));return n.sort((i,s)=>i.label.localeCompare(s.label))}function dl(t){return{instanceId:t.ownerId,route:t.ownerRoute||[],label:t.ownerLabel,status:t.available===!1?"offline":"up"}}function Qr(t,e,n,i=!1,s=!0){const a=e.instanceId;return{...t,id:lo(i?null:a,t.name),ownerId:a,ownerRoute:i?[]:[...e.route],ownerLabel:i?"Local":e.label,local:i,available:s,ownerTopology:Array.isArray(n)?n:[],layout:Zp(t.layout,a,n)}}function fT(t,e,n,i,s=[]){const[a,l]=k.useState([]),[d,h]=k.useState(!1),[f,g]=k.useState("idle"),[y,_]=k.useState(""),[w,b]=k.useState(""),N=k.useRef([]),x=k.useRef([]),E=k.useRef(""),C=k.useRef(e),I=k.useRef(n),T=k.useRef(!1),W=k.useRef(!0),U=k.useRef(""),Q=k.useMemo(()=>hT(s),[s]),ee=Q.map(F=>`${F.instanceId}:${Wf(F.route)}:${F.status}:${F.label}`).join("|");x.current=Q,I.current=n,C.current=e,N.current=a;const q=k.useCallback(F=>em(F.layout,E.current,x.current),[]),J=k.useCallback(()=>cl(C.current,E.current),[]),$=k.useCallback(F=>(Array.isArray(F)?F:[]).find(K=>K.id===J()),[J]),M=k.useCallback((F,K=!0,ne)=>{const re=ne===void 0?J():cl(ne,E.current),Y=Gw(F,nu()),de=N.current.some(pe=>pe.id===re);N.current=Y,l(Y);const oe=Y.find(pe=>pe.id===re);if(K&&oe){W.current=!0;const pe=q(oe);i(pe),oe.local&&MA(oe.name,pe)}else de&&!oe&&(W.current=!0,i(ta()),_("deck non più condiviso dal nodo owner"));EA(Y.filter(pe=>pe.local).map(pe=>pe.name))},[i,q]),L=k.useCallback(async F=>{let K=await Uc(t);const ne=K.decks.find(re=>re.name==="main");if(K.decks.length===1&&ne&&ne.revision===0&&Uf(ne.layout)){const re=kA(),Y=so(tm("main")||ta());if(!Uf(Y)){const de=Zp(Y,F,[]);K.decks[0]=await Wc(t,"main",de,0,[])}for(const de of re.filter(oe=>oe!=="main"))try{let oe=await H_(t,de,[]);const pe=so(tm(de)||ta());Uf(pe)||(oe=await Wc(t,de,Zp(pe,F,[]),oe.revision,[]))}catch{}K=await Uc(t)}return K},[t]),j=k.useCallback(async({migrate:F=!1}={})=>{const K=await fm(t,[]),ne=Pi.test(String(K.instanceId||""))?K.instanceId:"";if(!ne)throw new Error("instanceId locale non disponibile");E.current=ne,b(ne);const[re,Y]=await Promise.all([F?L(ne):Uc(t),O_(t,[]).catch(()=>({nodes:[]}))]),de={instanceId:ne,route:[],label:"Local"},oe=re.decks.map(xe=>Qr(xe,de,Y.nodes,!0,!0)),pe=N.current;return await Promise.all(x.current.map(async xe=>{if(xe.status!=="up"){oe.push(...pe.filter(Qe=>!Qe.local&&Qe.ownerId===xe.instanceId).map(Qe=>({...Qe,ownerRoute:[...xe.route],ownerLabel:xe.label,available:!1})));return}try{const[Qe,ot]=await Promise.all([Uc(t,xe.route),O_(t,xe.route).catch(()=>({nodes:[]}))]);oe.push(...Qe.decks.map(De=>Qr(De,xe,ot.nodes,!1,!0)))}catch{oe.push(...pe.filter(ot=>!ot.local&&ot.ownerId===xe.instanceId).map(ot=>({...ot,ownerRoute:[...xe.route],ownerLabel:xe.label,available:!1})))}})),oe.sort((xe,Qe)=>xe.local===Qe.local?xe.ownerLabel.localeCompare(Qe.ownerLabel)||(xe.name==="main"?-1:Qe.name==="main"?1:xe.name.localeCompare(Qe.name)):xe.local?-1:1),oe},[t,L,ee]);k.useEffect(()=>{if(!t)return;let F=!1;const K=U.current!==t;return U.current=t,j({migrate:K}).then(ne=>{if(F)return;const re=$(N.current),Y=$(ne),de=Y&&(!re||Y.revision>re.revision||re.available!==Y.available||Wf(re.ownerRoute)!==Wf(Y.ownerRoute));M(ne,K||!!de&&!T.current),h(!0),Y&&_("")}).catch(ne=>{F||(h(!0),_(String(ne.message||ne)))}),()=>{F=!0}},[M,j,ee,t,$]);const O=k.useCallback(async F=>{if(!d||!T.current)return!0;const K=F===void 0?J():cl(F,E.current),ne=N.current.find(re=>re.id===K);if(!ne)return _(`deck inesistente: ${K}`),!1;if(ne.available===!1)return _(`nodo owner offline: ${ne.ownerLabel}`),!1;g("saving");try{const re=Vw(so(I.current),ne.ownerId,ne.ownerTopology),Y=await Wc(t,ne.name,re,ne.revision,ne.ownerRoute),de=Qr(Y,dl(ne),ne.ownerTopology,ne.local,!0);return M(N.current.map(oe=>oe.id===K?de:oe),!1),T.current=!1,g("saved"),_(""),setTimeout(()=>g("idle"),1500),!0}catch(re){if(g("error"),_(String(re.message||re)),re.status===409&&re.data&&re.data.current){const Y=N.current.find(oe=>oe.id===K),de=Qr(re.data.current,dl(Y),Y.ownerTopology,Y.local,!0);M(N.current.map(oe=>oe.id===F?de:oe),!1)}return!1}},[d,t,M]);return k.useEffect(()=>{if(!d)return;if(W.current){W.current=!1;return}T.current=!0,g("saving");const F=setTimeout(O,650);return()=>clearTimeout(F)},[n,d,O]),k.useEffect(()=>{if(!d)return;const F=setInterval(async()=>{try{const K=await j(),ne=$(N.current),re=$(K),Y=re&&(!ne||re.revision>ne.revision||ne.available!==re.available);M(K,Y&&!T.current)}catch{}},5e3);return()=>clearInterval(F)},[d,j,M]),{decks:a,records:a,localNodeId:w,ready:d,saveState:f,error:y,setError:_,saveNow:O,select:async F=>{if(T.current&&!await O(J()))throw new Error("salvataggio del deck corrente fallito: cambio annullato");const K=N.current.find(ne=>ne.id===F);if(!K)throw new Error(`deck inesistente: ${F}`);return T.current=!1,W.current=!0,q(K)},add:async(F,K=null)=>{const ne=K===ws?N.current.find(de=>de.local):K?N.current.find(de=>de.ownerId===K):null;if(!ne||ne.available===!1)throw new Error("nodo owner non disponibile");const re=await H_(t,F,ne.ownerRoute),Y=Qr(re,dl(ne),ne.ownerTopology,ne.local,!0);return M([...N.current,Y],!1),Y},rename:async(F,K)=>{const ne=N.current.find(pe=>pe.id===F);if(!ne)throw new Error("deck inesistente");if(cl(F,E.current)===J()&&T.current&&!await O(F))throw new Error(`salvataggio di "${ne.name}" fallito: rinomina annullata`);const re=N.current.find(pe=>pe.id===F);if(!re)throw new Error("deck inesistente");const Y=await Hk(t,re.name,K,re.revision,re.ownerRoute),de=Qr(Y,dl(re),re.ownerTopology,re.local,!0),oe=re.local?ws:re.ownerId;return gf(LA(nu(),oe,F,de.id)),M(N.current.map(pe=>pe.id===F?de:pe),!1),de},remove:async F=>{const K=N.current.find(re=>re.id===F);if(!K)throw new Error("deck inesistente");cl(F,E.current)===J()&&(T.current=!1),await Uk(t,K.name,K.revision,K.ownerRoute);const ne=K.local?ws:K.ownerId;gf(RA(nu(),ne,F)),M(N.current.filter(re=>re.id!==F),!1)},reorder:(F,K)=>{const ne=N.current.find(xe=>xe.id===F),re=N.current.find(xe=>xe.id===K);if(!ne||!re)return!1;const Y=ne.local?ws:ne.ownerId,de=re.local?ws:re.ownerId;if(Y!==de)return!1;const oe=N.current.filter(xe=>(xe.local?ws:xe.ownerId)===Y).map(xe=>xe.id),pe=gf(NA(nu(),Y,F,K,oe));return M(Gw(N.current,pe),!1),!0},addTileTo:async(F,K)=>{const ne=N.current.find(xe=>xe.id===F);if(!ne)throw new Error("deck inesistente");if(ne.available===!1)throw new Error(`nodo owner offline: ${ne.ownerLabel}`);const re=E1(K,E.current,x.current);if(!re)throw new Error("riferimento sessione non valido");const Y=q(ne),de=Vw(O0(Y,re),ne.ownerId,ne.ownerTopology),oe=await Wc(t,ne.name,de,ne.revision,ne.ownerRoute),pe=Qr(oe,dl(ne),ne.ownerTopology,ne.local,!0);return M(N.current.map(xe=>xe.id===F?pe:xe),!1),pe},localMainId:lo(null,"main"),parseDeckId:Ol}}const pT="/sw.js",rm="nc-sw-update";let Al=null,Fu=!1,Hu=null,cx=Object.freeze({needed:!1,kind:null,version:"",browserVersion:""}),ux=!1;function cg(){typeof window<"u"&&window.dispatchEvent(new Event(rm))}function ug(){const t=Hu||(Fu?{kind:"reload",version:"",browserVersion:""}:null);cx=Object.freeze({needed:!!t,kind:(t==null?void 0:t.kind)||null,version:(t==null?void 0:t.version)||"",browserVersion:(t==null?void 0:t.browserVersion)||""})}function qb(){return cx}function mT(t){return typeof window>"u"?()=>{}:(window.addEventListener(rm,t),()=>window.removeEventListener(rm,t))}function dg(t){Fu!==t&&(Fu=t,ug(),cg())}const lu="nc-auto-reload",Uu="nc-reload";function hg(){try{return typeof location<"u"?location:null}catch{return null}}function dx(){try{return typeof history<"u"?history:null}catch{return null}}function gT(t){const e=t===void 0?hg():t;if(!e||typeof e.search!="string")return null;try{return new URLSearchParams(e.search).get(Uu)}catch{return null}}function vT(t,{location:e,history:n}={}){const i=e===void 0?hg():e,s=n===void 0?dx():n;if(!i||!s||typeof s.replaceState!="function")return!1;try{const a=new URLSearchParams(i.search||"");return a.set(Uu,t),s.replaceState(s.state??null,"",`${i.pathname||"/"}?${a.toString()}${i.hash||""}`),!0}catch{return!1}}function _T({location:t,history:e}={}){const n=t===void 0?hg():t,i=e===void 0?dx():e;if(!n||!i||typeof i.replaceState!="function")return!1;try{const s=new URLSearchParams(n.search||"");if(!s.has(Uu))return!1;s.delete(Uu);const a=s.toString();return i.replaceState(i.state??null,"",`${n.pathname||"/"}${a?`?${a}`:""}${n.hash||""}`),!0}catch{return!1}}const hx="nc-update-dismissed";function fx(){try{return typeof sessionStorage<"u"?sessionStorage:null}catch{return null}}function yT(t,e,n){return[t,e,n].map(i=>i||"").join("|")}let om=null;function wT(t,e,n){const i=n;return t&&e&&t!==e&&t!==i?{kind:"install",version:t,browserVersion:i}:e&&i&&e!==i?{kind:"stale",version:e,browserVersion:i}:null}function bT(t,e){if(!t)return!1;try{return t.getItem(hx)===e}catch{return!1}}function ST(t={}){const e=t.storage===void 0?fx():t.storage;if(om&&e)try{e.setItem(hx,om)}catch{}Fu=!1,Hu=null,ug(),cg()}function xT(t,e,n,i={}){const s=i.storage===void 0?fx():i.storage,a=n,l=yT(t,e,a);om=l;const d=wT(t,e,a);let h=bT(s,l)?null:d;if(h&&h.kind==="stale"){const g=`${e}|${a}`,y=gT(i.location)===g;let _=!1;if(!y&&s&&s.getItem(lu)!==g){try{s.setItem(lu,g)}catch{}_=s.getItem(lu)===g}_&&(vT(g,{location:i.location,history:i.history}),(i.applyImpl||px)(),h=null)}const f=JSON.stringify(h)===JSON.stringify(Hu);if(Hu=h,ug(),f||cg(),!d){try{s&&s.removeItem(lu)}catch{}_T({location:i.location,history:i.history})}}const CT=1200;async function Kb(t){if(typeof fetch=="function")try{await Promise.race([fetch(t,{cache:"reload"}),new Promise(e=>setTimeout(e,CT))])}catch{}}async function px(){try{Al&&await Al.update()}catch{}typeof location<"u"&&(await Kb(location.pathname),await Kb("/version.json"),location.reload())}function kT(t){t.addEventListener("statechange",()=>{t.state==="installed"&&navigator.serviceWorker.controller&&dg(!0)})}function ET(){typeof navigator>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{ux&&location.reload()}),navigator.serviceWorker.register(pT).then(t=>{Al=t,t.waiting&&dg(!0),t.addEventListener("updatefound",()=>{const e=t.installing;e&&kT(e)}),setInterval(()=>{t.update().catch(()=>{})},3600*1e3)}).catch(()=>{}))}function NT(){ux=!0,dg(!1);const t=Al&&Al.waiting;t?(t.postMessage({type:"SKIP_WAITING"}),setTimeout(()=>location.reload(),4e3)):location.reload()}function LT({hash:t="",origin:e="",pathname:n="",search:i=""}={}){const s=String(t||"").replace(/^#/,""),a=`${n||""}${i||""}`;if(!s)return{token:"",pair:"",nextUrl:a};const l=new URLSearchParams(s),d=l.get("token")||"",h=l.get("pair")||"",f=h?`${e||""}${n||""}#pair=${h}`:"";return{token:d,pair:f,nextUrl:a}}const mx=9,gx=24,vx="nc_side_w",Vb="nc_side_min",RT=240,Yb=new Set(["absent","present","active","unknown"]);function MT(){const t=Number(localStorage.getItem(vx));return t>=180&&t<=480?t:RT}function AT(){const t=Number(localStorage.getItem("nc_fontsize"));return t>=mx&&t<=gx?t:13}function jT(){const t={token:"",pair:""};try{const{token:e,pair:n,nextUrl:i}=LT({hash:location.hash,origin:location.origin,pathname:location.pathname,search:location.search});if(e){t.token=e;try{localStorage.setItem("nc_token",e)}catch{}}if(n){t.pair=n;try{sessionStorage.setItem("nc_pair",n)}catch{}}if(location.hash)try{history.replaceState(null,"",i)}catch{}}catch{}if(t.token||(t.token=sessionStorage.getItem("nc_token")||localStorage.getItem("nc_token")||""),!t.pair){const e=sessionStorage.getItem("nc_pair");e&&(t.pair=e)}return t}function Gb(t){try{return so(tm(t))}catch{return ta()}}function Xb(t){if(!t)return"";const e=Math.floor(Date.now()/1e3)-t;return e<0||e<60?"ora":e<3600?`${Math.floor(e/60)}m`:e<86400?`${Math.floor(e/3600)}h`:`${Math.floor(e/86400)}g`}function Qb({session:t,node:e,ownerId:n,cellName:i,token:s,readonly:a=!1,panelPort:l=0,onBack:d,onCellSwitcher:h,cellSwitcherOpen:f=!1}){li();const[g]=qm(),[y,_]=k.useState(!1),[w,b]=k.useState(()=>window.matchMedia("(pointer: coarse)").matches),[N,x]=k.useState(null),[E,C]=k.useState(AT),[I,T]=k.useState(Sl),[W,U]=k.useState(()=>Sl()),Q=()=>{const oe=XR(QR(Sl()));T(oe),typeof window<"u"&&window.location.reload()},[ee,q]=k.useState(i||t),[J,$]=k.useState(""),[M,L]=k.useState(""),[j,O]=k.useState(""),[P,A]=k.useState(!1),R=oe=>C(pe=>{const xe=Math.max(mx,Math.min(gx,pe+oe));return localStorage.setItem("nc_fontsize",String(xe)),xe}),D=k.useRef(()=>{}),H=k.useRef(()=>!1),z=k.useRef(()=>{}),F=k.useRef(!1),[K,ne]=k.useState(!1),[re,Y]=k.useState(!1),de=()=>{F.current=!F.current,ne(F.current)};return k.useEffect(()=>{q(i||t),A(!1)},[i,t]),k.useEffect(()=>{let oe=!0;const pe=e?e.split("/"):[],xe=e?`/api/route/${e.split("/").map(encodeURIComponent).join("/")}/_`:"/api";async function Qe(){let De=null,je=null;try{const Ct=await(await pn(`${xe}/sessions`,s)).json();Array.isArray(Ct.sessions)&&(De=Ct.sessions.find(ft=>ft.name===t))}catch{}try{const Nt=await Ar(s,pe);Nt.available&&Array.isArray(Nt.cells)&&(je=Nt.cells.find(Ct=>Ct.tmuxSession===t))}catch{}if(!oe)return;q(Km({session:t,cell:je||(i?{cell:i}:null)})),L(typeof(je==null?void 0:je.panelUrl)=="string"?je.panelUrl.trim():""),O(typeof(je==null?void 0:je.cell)=="string"?je.cell:"");let tt="";je?tt=`${je.engine}${je.key?`·${je.key}`:""}`:De&&(tt=De.attached?`attached · ${Xb(De.activity)}`:De.activity?Xb(De.activity):""),$(tt)}Qe();const ot=setInterval(Qe,4e3);return()=>{oe=!1,clearInterval(ot)}},[t,e,s]),c.jsxs("div",{className:"nc-app",children:[c.jsxs("header",{className:"nc-bar nc-bar-single",children:[c.jsxs("button",{onClick:d,title:m("sessions"),children:[c.jsx(dt,{name:"chevronLeft",size:18}),c.jsx("span",{className:"nc-bar-label",children:m("sessions")})]}),c.jsxs("span",{className:"nc-bar-center",children:[c.jsx("b",{title:e?`${ee} · ${e}`:ee,children:ee}),J&&c.jsx("small",{className:"nc-bar-sub",children:J})]}),c.jsxs("span",{className:"nc-bar-right",children:[c.jsx("button",{onClick:()=>R(-1),title:m("zoom-out"),children:c.jsx(dt,{name:"zoomOut",size:18})}),c.jsx("button",{onClick:()=>R(1),title:m("zoom-in"),children:c.jsx(dt,{name:"zoomIn",size:18})}),c.jsx("button",{type:"button",className:`nc-renderer-toggle${W==="webgl"?" on":""}`,onClick:Q,"aria-pressed":W==="webgl",title:m("terminal-renderer-switch").replace("{requested}",m(I==="dom"?"terminal-renderer-dom":"terminal-renderer-webgl")).replace("{effective}",m(W==="dom"?"terminal-renderer-dom":"terminal-renderer-webgl")),"aria-label":m("terminal-renderer-switch").replace("{requested}",m(I==="dom"?"terminal-renderer-dom":"terminal-renderer-webgl")).replace("{effective}",m(W==="dom"?"terminal-renderer-dom":"terminal-renderer-webgl")),children:c.jsx(dt,{name:"gpu",size:18})}),c.jsx("button",{onClick:()=>b(oe=>!oe),title:m("composer"),children:c.jsx(dt,{name:"keyboard",size:20})}),c.jsx("button",{onClick:()=>_(oe=>!oe),title:m("files"),children:c.jsx(dt,{name:"folder",size:20})}),M&&c.jsx("button",{onClick:()=>A(oe=>!oe),title:m("panel"),"aria-pressed":P,children:c.jsx(dt,{name:"monitor",size:20})})]})]}),c.jsxs("div",{className:"nc-termwrap",children:[c.jsx($m,{session:t,node:e,token:s,readonly:a,takeSize:!0,sendRef:D,composerRef:H,actionRef:z,ctrlRef:F,setCtrlArmed:ne,onFiles:x,fontSize:E,selectionMode:re,onSelectionModeChange:Y,keyboardGesture:g.terminalKeyboardGesture,onRendererChange:U}),P&&M&&j&&c.jsx(Hm,{cellId:j,panelUrl:M,route:e?e.split("/"):[],panelPort:l,token:s,title:ee})]}),c.jsx(zM,{onKeyboard:()=>b(oe=>!oe),onCellSwitcher:h,cellSwitcherOpen:f,send:oe=>D.current(oe),action:oe=>z.current(oe),ctrlArmed:K,onCtrl:de,selectionMode:re,onSelectionMode:Y,keepKeyboardClosed:g.keybarKeepsKeyboardClosed,showEnter:g.showKeybarEnter,keybarLayout:g.keybarLayout}),w&&c.jsx(v1,{submitText:oe=>H.current(oe),token:s,session:t,node:e,ownerId:n,readonly:a,keepKeyboardClosedOnVoice:g.voiceKeepsKeyboardClosed}),y&&c.jsx(l1,{session:t,node:e,token:s,filesEvent:N,onClose:()=>_(!1)})]})}function PT(){li();const[t]=k.useState(jT),[e,n]=k.useState(t.token),[i,s]=k.useState(t.pair||""),a=k.useCallback(()=>{s("");try{sessionStorage.removeItem("nc_pair")}catch{}},[]),[l,d]=k.useState(!1),h=_M(),[f]=k.useState(()=>CA(typeof location<"u"?location.pathname:"/")),[g,y]=k.useState(f.id),_=g===lo(null,Ti),[w,b]=k.useState(null),N=me=>{const Se=Mr(me);b(Se?{...Se,...typeof(me==null?void 0:me.cellName)=="string"&&me.cellName?{cellName:me.cellName}:{}}:null)},[x,E]=k.useState([]),[C,I]=k.useState([]),[T,W]=k.useState([]),[U,Q]=k.useState(!1),[ee,q]=k.useState(null),[J,$]=k.useState(()=>f.ownerId?ta():Gb(f.name)),[M,L]=k.useState(null),[j,O]=k.useState(null),P=me=>O(Mr(me)),[A,R]=k.useState(null),D=_m(e,h),H=k.useMemo(()=>(D||[]).filter(me=>me.instanceId).map(me=>({instanceId:me.instanceId,route:me.route,label:me.label,status:me.status})),[D]),z=fT(e,g,J,$,H),F=z.decks;k.useEffect(()=>{const me=new Map;for(const Se of D||[]){const Ae=(Se.route||[Se.name]).join("/"),it=new Set((Se.sessions||[]).map(st=>st.name));for(const st of Se.cells||[])!st.cell||!st.tmuxSession||st.cell===st.tmuxSession||it.has(st.cell)||me.set(`${Ae}:${st.cell}`,`${Ae}:${st.tmuxSession}`)}$(Se=>j2(Se,me))},[D]),k.useEffect(()=>{z.localNodeId&&(f.ownerId&&f.ownerId===z.localNodeId&&$(me=>me.columns.some(Se=>Se.tiles.length)?me:Gb(f.name)),$(me=>{const Se=em(me,z.localNodeId,H);return JSON.stringify(Se)===JSON.stringify(me)?me:Se}))},[H,z.localNodeId]);const[K,ne]=k.useState(null),[re,Y]=k.useState(null),de=k.useRef(0),[oe,pe]=k.useState(!1),[xe,Qe]=k.useState(MT),[ot,De]=k.useState(!_),[je,tt]=k.useState(()=>_?localStorage.getItem(Vb)==="1":!0),[Nt,Ct]=k.useState(!1),[ft,ht]=k.useState("nodes"),[kt,St]=k.useState(!1),[Ut,Mt]=k.useState(""),[It,tn]=k.useState(!1),Ft=(me="nodes",Se=!1,Ae="")=>{ht(me),St(Se),Mt(Ae),Ct(!0)},[ln,V]=k.useState(!1),[Te,gt]=k.useState({deviceDefault:"",localNodeId:"",localNameDefault:""}),[le,ae]=k.useState(!1),[ge,Ce]=k.useState(0),[Me,nt]=k.useState({});k.useEffect(()=>{try{localStorage.setItem(vx,String(xe))}catch{}},[xe]),k.useEffect(()=>{try{localStorage.setItem(Vb,je?"1":"")}catch{}},[je]),k.useEffect(()=>{if(!e)return;let me=!1;return Promise.all([c0(e),pn("/api/config",e).then(Se=>Se.json())]).then(([Se,Ae])=>{me||(gt({deviceDefault:Se.deviceName||"",localNodeId:Se.nodeId||"",localNameDefault:Se.localName||""}),ae(!!Ae.readonlyDefault),Ce(Number.isInteger(Ae.panelPort)?Ae.panelPort:0),nt(Ae.nodePanelPorts&&typeof Ae.nodePanelPorts=="object"&&!Array.isArray(Ae.nodePanelPorts)?Ae.nodePanelPorts:{}),(Se.firstRun===!0&&!Ae.readonlyDefault||i)&&V(!0))}).catch(()=>{}),()=>{me=!0}},[e,i]);const[ct,pt]=k.useState({}),Lt=k.useRef(D);k.useEffect(()=>{Lt.current=D},[D]);const Dt=k.useCallback(async()=>{try{const st=await(await pn("/api/sessions",e)).json();st.error||E(st.sessions||[])}catch{}let me=null,Se=null;try{me=await Ar(e)}catch(it){Se=it}const Ae=vm({fs:me,error:Se});Ae.kind==="data"?(I(Ae.cells),W(Ae.capabilities),Q(!1),q(null)):Ae.kind==="stale"?(Q(!0),q(null)):(I([]),W([]),Q(!1),q(Ae.reason||""))},[e]);k.useEffect(()=>{let me=!1;const Se=async()=>{const it=[[],...(Lt.current||[]).filter(wt=>wt.kind!=="vl"&&wt.status==="up").map(wt=>Array.isArray(wt.route)&&wt.route.length?wt.route:[wt.name])],st=await Promise.all(it.map(async wt=>{const cn=ea(wt);try{const $t=await Wk(e,wt);return[cn,{hostCell:$t&&typeof $t.hostCell=="string"?$t.hostCell:null,hostLease:$t&&$t.host&&typeof $t.host.lease=="string"?$t.host.lease:null,hostRevision:Number.isInteger($t&&$t.revision)?$t.revision:0,threadStatus:$t&&Yb.has($t.threadStatus)?$t.threadStatus:"unknown"}]}catch{return[cn,{error:!0}]}}));me||pt(wt=>{let cn=!1;const $t={...wt};for(const Wt of st){if(!Wt)continue;const[Xs,Di]=Wt;$t[Xs]=Di.error?{...wt[Xs]||{},threadStatus:"unknown"}:Di,cn=!0}return cn?$t:wt})};Se();const Ae=setInterval(Se,4e3);return()=>{me=!0,clearInterval(Ae)}},[e]),k.useEffect(()=>{if(!h)return;Dt();const me=setInterval(Dt,4e3);return()=>clearInterval(me)},[h,Dt]);const Et=k.useCallback(async(me,Se=[])=>{const Ae=ea(Se),it=ct[Ae]&&ct[Ae].hostRevision||0;try{const st=await qk(e,me,it,Se);return pt(wt=>({...wt,[Ae]:{hostCell:st.hostCell||null,hostLease:st.host&&typeof st.host.lease=="string"?st.host.lease:null,hostRevision:Number.isInteger(st.revision)?st.revision:it,threadStatus:Yb.has(st.threadStatus)?st.threadStatus:"unknown"}})),{ok:!0}}catch(st){return{ok:!1,error:st}}},[e,ct]),Bt=k.useCallback(async(me,Se=[])=>{const Ae=await Et(me,Se);return Ae.ok||window.alert(m(Yf(Ae.error))),Ae.ok},[Et]),Z=k.useCallback(async(me=[])=>{const Se=ea(me),Ae=ct[Se]&&ct[Se].hostRevision||0;try{const it=await Kk(e,Ae,me);return pt(st=>({...st,[Se]:{hostCell:it.hostCell||null,hostLease:null,hostRevision:Number.isInteger(it.revision)?it.revision:Ae,threadStatus:"unknown"}})),{ok:!0}}catch(it){return{ok:!1,error:it}}},[e,ct]),ye=k.useCallback(async(me=[])=>{const Se=await Z(me);return Se.ok||window.alert(m(Yf(Se.error))),Se.ok},[Z]);k.useEffect(()=>{let me=!1;const Se=()=>{pn("/api/config",e).then(it=>it.json()).then(it=>{me||xT(it.version,it.uiVersion,"0.9.28")}).catch(()=>{})};Se();const Ae=setInterval(Se,6e4);return()=>{me=!0,clearInterval(Ae)}},[e]);const Ue=new Set([...x.map(me=>me.name),...D.flatMap(me=>me.sessions.map(Se=>Se.key))]),We=Ss(J),Ge=me=>$(Se=>{const Ae=E1(me,z.localNodeId,H)||me,it=O0(Se,Ae);return it===Se&&Ss(Se).length>=9&&z.setError(m("grid-full")),it}),jt=async(me,Se=[])=>{try{await um(e,me,Se)}catch{return}const Ae=Se.length?`${Se.join("/")}:${me}`:me;$(it=>Ru(it,Ae)),Dt()},Pt=async(me,Se,Ae=[])=>{try{await l0(e,me,Se,Ae)}catch{return}Dt()},X=async(me,Se,Ae=[])=>{await r0(e,{cell:me,enabled:!!Se},Ae),Dt()},ie=async me=>{if(!K)return;const{cell:Se}=K,Ae=Array.isArray(K.route)?K.route:[];if(me.action==="up"){const st=await cm(e,{cell:Se,boot:!!me.boot,...me.engine?{engine:me.engine}:{},...me.model!==void 0?{model:me.model}:{},...me.permissionPolicy?{permissionPolicy:me.permissionPolicy}:{}},Ae),wt=km(st);wt&&z.setError(wt.text)}else await wu(e,{cell:Se,boot:!!me.boot},Ae);const it=me.action==="up"?!!me.boot:me.boot?!1:!!K.boot;Y({id:++de.current,cell:Se,route:Ae,enabled:it}),Dt()},_e=k.useCallback(me=>{Y(Se=>(Se==null?void 0:Se.id)===me?null:Se)},[]),Ke=async me=>{if(!(!(me!=null&&me.direct)||oe)){pe(!0);try{await pm(e,me.name,me.tunnelStatus==="up"?"down":"up")}finally{pe(!1)}}},Ie=async(me,Se)=>{const Ae=String(Se||"").trim();return!(me!=null&&me.direct)||!oa(Ae)?!1:(await h0(e,me.name,Ae),!0)},Ee=me=>{const Se=F.find(Ae=>Ae.id===me);if(!Se)return!1;try{const Ae=window.open(mf(Se,e),"_blank");return Ae&&(Ae.opener=null),!!Ae}catch{return!1}},et=async me=>{if(!me||me===g)return;const Se=await z.select(me),Ae=z.records.find(it=>it.id===me);y(me),$(Se),L(null),O(null);try{history.replaceState(null,"",mf(Ae||me,null))}catch{}},Ot=async(me,Se)=>{const Ae=await z.add(me,Se);await et(Ae.id)},gn=async(me,Se)=>{const Ae=await z.rename(me,Se);if(me===g){y(Ae.id),$(em(Ae.layout,z.localNodeId,H)),L(null),O(null);try{history.replaceState(null,"",mf(Ae,null))}catch{}}},Fe=async me=>{await z.remove(me),me===g&&await et(z.localMainId)},Be=async(me,Se)=>{!Se||Se===g||(await z.addTileTo(Se,me),$(Ae=>Ru(Ae,me)))};if(!e)return c.jsxs("div",{className:"nc-auth",children:[c.jsx("p",{children:m("auth-prompt")}),c.jsx("input",{onChange:me=>n(me.target.value.trim()),placeholder:"token"}),c.jsxs("label",{children:[c.jsx("input",{type:"checkbox",checked:l,onChange:me=>d(me.target.checked)})," ",m("remember-device")]}),c.jsx("button",{onClick:()=>{(l?localStorage:sessionStorage).setItem("nc_token",e)},children:"ok"})]});const vt=c.jsxs(c.Fragment,{children:[Nt&&c.jsx(GP,{token:e,initialTab:ft,initialLocation:Ut,startNewCell:kt,onClose:()=>{Ct(!1),St(!1),Mt("")}}),ln&&c.jsx(XP,{token:e,initialPair:i,...Te,onPairDone:a,onDone:()=>V(!1)}),c.jsx(nT,{token:e})]});if(!h)return A?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-single-overlay",children:c.jsx(Wb,{peer:A,token:e,onBack:()=>R(null)})}),vt]}):w?c.jsxs(c.Fragment,{children:[c.jsx(Qb,{session:w.session,node:w.node,ownerId:w.ownerId,cellName:w.cellName,token:e,readonly:le,panelPort:$u(w.node?w.node.split("/"):[],Me,ge),onBack:()=>b(null),onCellSwitcher:()=>tn(!0),cellSwitcherOpen:It}),It&&c.jsx(lT,{token:e,current:w,panelPort:ge,nodePanelPorts:Me,hostByRoute:ct,onDesignateCell:Et,onClearHostCell:Z,onPick:me=>{N(me),tn(!1)},onClose:()=>tn(!1)}),vt]}):c.jsxs(c.Fragment,{children:[c.jsx(X2,{onPick:N,token:e,onSettings:Ft,onOpenVlSession:R,hostByRoute:ct,onDesignateCell:Bt,onClearHostCell:ye}),vt]});const Mn=_||!ot;return c.jsxs("div",{className:"nc-workspace",children:[Mn&&c.jsx(dA,{sessions:x,cells:C,activeSessions:We,nodeGroups:D,token:e,onPeekOpen:()=>tn(!1),overlayOpen:It,fleetCapabilities:T,fleetStale:U,fleetOff:ee,bootSettlement:re,onBootSettlementApplied:_e,localNodeId:z.localNodeId,hostByRoute:ct,onDesignateCell:Bt,onClearHostCell:ye,onPick:P,onAddTile:Ge,onPower:ne,onBoot:X,onBootError:me=>z.setError(String((me==null?void 0:me.message)||me)),onNodePower:Ke,onNodeRename:Ie,onKill:jt,onVisibility:Pt,onNew:()=>Ft("fleet",!0),onSettings:Ft,onOpenVlSession:R,width:xe,collapsed:je,onResize:Qe,onToggleCollapse:()=>tt(me=>!me)}),c.jsxs("div",{className:"nc-workspace-main",children:[c.jsx(VA,{decks:F,currentDeck:g,onCreate:Ot,onRename:gn,onDelete:Fe,onReorder:z.reorder,onOpenWindow:Ee,onNavigate:et,saveState:z.saveState,error:z.error,sidebarVisible:Mn,onToggleSidebar:_?null:()=>De(me=>!me)}),c.jsx(yA,{layout:J,onLayoutChange:$,token:e,readonly:le,sessionsAlive:Ue,focusSession:M,onFocus:L,onOpenSingle:P,decks:F,currentDeck:g,onSendToDeck:Be,cells:C,nodeGroups:D,panelPort:ge,nodePanelPorts:Me})]}),A&&c.jsx("div",{className:"nc-single-overlay",children:c.jsx(Wb,{peer:A,token:e,onBack:()=>R(null)})}),j&&c.jsx("div",{className:"nc-single-overlay",children:c.jsx(Qb,{session:j.session,node:j.node,ownerId:j.ownerId,cellName:Km({session:j.session,node:j.node,ownerId:j.ownerId,cells:C,nodeGroups:D}),token:e,readonly:le,panelPort:$u(j.node?j.node.split("/"):[],Me,ge),onBack:()=>O(null)})}),K&&c.jsx(Cu,{cell:K,token:e,route:Array.isArray(K.route)?K.route:[],onConfirm:ie,onClose:()=>ne(null)}),vt]})}function TT(t){return t.kind==="install"?m("update-installed-restart").replace("{v}",t.version):t.kind==="stale"?m("update-stale").replace("{ui}",t.version).replace("{browser}",t.browserVersion):m("update-available").replace("{v}",t.version).replace(" "," ").trim()}function DT(){li();const t=k.useSyncExternalStore(mT,qb,qb);return t.needed?c.jsxs("div",{className:"nc-update",role:"status","aria-live":"polite",children:[c.jsx("span",{className:"nc-update-msg",children:TT(t)}),t.kind==="stale"&&c.jsx("button",{className:"nc-update-btn",onClick:px,children:m("reload-no-cache")}),t.kind==="reload"&&c.jsx("button",{className:"nc-update-btn",onClick:NT,children:m("reload")}),c.jsx("button",{className:"nc-update-close",onClick:ST,"aria-label":m("update-dismiss"),title:m("update-dismiss"),children:"×"})]}):null}ET();tk.createRoot(document.getElementById("root")).render(c.jsxs(YC.StrictMode,{children:[c.jsx(PT,{}),c.jsx(DT,{})]}));