@mndw/cli 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,94 @@
1
+ var f_=Object.defineProperty;var h_=Object.getPrototypeOf;var p_=Reflect.get;var Of=t=>{throw TypeError(t)};var g_=(t,e,n)=>e in t?f_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var X=(t,e,n)=>g_(t,typeof e!="symbol"?e+"":e,n),wc=(t,e,n)=>e.has(t)||Of("Cannot "+n);var x=(t,e,n)=>(wc(t,e,"read from private field"),n?n.call(t):e.get(t)),Ce=(t,e,n)=>e.has(t)?Of("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),Ke=(t,e,n,r)=>(wc(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),Ye=(t,e,n)=>(wc(t,e,"access private method"),n);var Mf=(t,e,n)=>p_(h_(t),n,e);import{setMndwUiLocale as m_,deepActiveElement as v_,coercePlacement as Nf,isMobileSheet as b_,resolveSizing as Lf,computePopoverCoords as __,createFocusTrap as mu,composedContains as w_,tabbableElements as y_,column as pi,defineMndwUi as k_}from"/shared/mndw-ui@0.3.2.js";import{firstValueFrom as md,race as E_,Observable as el,ReplaySubject as S_,map as T_,timeout as ug,tap as yc,timer as x_,exhaustMap as C_,catchError as P_,EMPTY as R_,takeUntil as If,Subject as A_,Subscription as O_,filter as M_,BehaviorSubject as N_}from"/shared/rxjs@7.8.2.js";import{FetchTransport as L_,SessionManager as I_,RciManager as z_}from"/shared/rci-tools-core@0.6.0.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();const D_="/assets/sprite-XQfBvd_1.svg",dg=!1;var vd=Array.isArray,H_=Array.prototype.indexOf,tl=Array.prototype.includes,$l=Array.from,B_=Object.defineProperty,So=Object.getOwnPropertyDescriptor,fg=Object.getOwnPropertyDescriptors,hg=Object.prototype,U_=Array.prototype,Fl=Object.getPrototypeOf,zf=Object.isExtensible;const j_=()=>{};function $_(t){for(var e=0;e<t.length;e++)t[e]()}function pg(){var t,e,n=new Promise((r,i)=>{t=r,e=i});return{promise:n,resolve:t,reject:e}}function F_(t,e){if(Array.isArray(t))return t;if(!(Symbol.iterator in t))return Array.from(t);const n=[];for(const r of t)if(n.push(r),n.length===e)break;return n}const fn=2,Ps=4,Gl=8,gg=1<<24,yr=16,cr=32,Qr=64,vu=128,ar=512,sn=1024,Xt=2048,Tr=4096,In=8192,lr=16384,$s=32768,bu=1<<25,Ei=65536,nl=1<<17,G_=1<<18,Fs=1<<19,V_=1<<20,zr=1<<25,Wi=65536,rl=1<<21,ds=1<<22,bi=1<<23,fs=Symbol("$state"),Z_=Symbol(""),$a=Symbol("attributes"),_u=Symbol("class"),wu=Symbol("style"),lo=Symbol("text"),aa=new class extends Error{constructor(){super(...arguments);X(this,"name","StaleReactionError");X(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};function bd(t){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function W_(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function q_(t,e,n){throw new Error("https://svelte.dev/e/each_key_duplicate")}function K_(t){throw new Error("https://svelte.dev/e/effect_in_teardown")}function Y_(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function X_(t){throw new Error("https://svelte.dev/e/effect_orphan")}function J_(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function Q_(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function ew(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function tw(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function nw(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const rw=1,iw=2,mg=4,sw=8,ow=16,aw=1,lw=2,rn=Symbol("uninitialized"),cw="http://www.w3.org/1999/xhtml";function uw(){console.warn("https://svelte.dev/e/derived_inert")}function dw(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function vg(t){return t===this.v}function bg(t,e){return t!=t?e==e:t!==e||t!==null&&typeof t=="object"||typeof t=="function"}function _g(t){return!bg(t,this.v)}let la=!1,fw=!1;function hw(){la=!0}const pw=[];function ya(t,e=!1,n=!1){return Fa(t,new Map,"",pw,null,n)}function Fa(t,e,n,r,i=null,s=!1){if(typeof t=="object"&&t!==null){var o=e.get(t);if(o!==void 0)return o;if(t instanceof Map)return new Map(t);if(t instanceof Set)return new Set(t);if(vd(t)){var a=Array(t.length);e.set(t,a),i!==null&&e.set(i,a);for(var l=0;l<t.length;l+=1){var c=t[l];l in t&&(a[l]=Fa(c,e,n,r,null,s))}return a}if(Fl(t)===hg){a={},e.set(t,a),i!==null&&e.set(i,a);for(var u of Object.keys(t))a[u]=Fa(t[u],e,n,r,null,s);return a}if(t instanceof Date)return structuredClone(t);if(typeof t.toJSON=="function"&&!s)return Fa(t.toJSON(),e,n,r,t)}if(t instanceof EventTarget)return t;try{return structuredClone(t)}catch{return t}}let kt=null;function Rs(t){kt=t}function gw(t){return _d().get(t)}function mw(t,e){return _d().set(t,e),e}function vw(t){return _d().has(t)}function Ze(t,e=!1,n){kt={p:kt,i:!1,c:null,e:null,s:t,x:null,r:ct,l:la&&!e?{s:null,u:null,$:[]}:null}}function We(t){var e=kt,n=e.e;if(n!==null){e.e=null;for(var r of n)Ug(r)}return e.i=!0,kt=e.p,{}}function Gs(){return!la||kt!==null&&kt.l===null}function _d(t){return kt===null&&bd(),kt.c??(kt.c=new Map(bw(kt)||void 0))}function bw(t){let e=t.p;for(;e!==null;){const n=e.c;if(n!==null)return n;e=e.p}return null}let Ni=[];function wg(){var t=Ni;Ni=[],$_(t)}function Yr(t){if(Ni.length===0&&!xo){var e=Ni;queueMicrotask(()=>{e===Ni&&wg()})}Ni.push(t)}function _w(){for(;Ni.length>0;)wg()}function yg(t){var e=ct;if(e===null)return lt.f|=bi,t;if((e.f&$s)===0&&(e.f&Ps)===0)throw t;gi(t,e)}function gi(t,e){if(!(e!==null&&(e.f&lr)!==0)){for(;e!==null;){if((e.f&vu)!==0){if((e.f&$s)===0)throw t;try{e.b.error(t);return}catch(n){t=n}}e=e.parent}throw t}}const ww=-7169;function Gt(t,e){t.f=t.f&ww|e}function wd(t){(t.f&ar)!==0||t.deps===null?Gt(t,sn):Gt(t,Tr)}function kg(t){if(t!==null)for(const e of t)(e.f&fn)===0||(e.f&Wi)===0||(e.f^=Wi,kg(e.deps))}function Eg(t,e,n){(t.f&Xt)!==0?e.add(t):(t.f&Tr)!==0&&n.add(t),kg(t.deps),Gt(t,sn)}function ca(t){var e=lt,n=ct;Fn(null),ur(null);try{return t()}finally{Fn(e),ur(n)}}function yw(t){let e=0,n=ei(0),r;return()=>{Td()&&(d(n),xd(()=>(e===0&&(r=Cr(()=>t(()=>dn(n)))),e+=1,()=>{Yr(()=>{e-=1,e===0&&(r==null||r(),r=void 0,dn(n))})})))}}var kw=Ei|Fs;function Ew(t,e,n,r){new Sw(t,e,n,r)}var rr,gd,ir,zi,Dn,sr,Mn,Yn,Fr,Di,di,ws,Wo,qo,Gr,zl,Nt,Tw,xw,yu,Cw,ku,Ga,Va,Eu,Su;class Sw{constructor(e,n,r,i){Ce(this,Nt);X(this,"parent");X(this,"is_pending",!1);X(this,"transform_error");Ce(this,rr);Ce(this,gd,null);Ce(this,ir);Ce(this,zi);Ce(this,Dn);Ce(this,sr,null);Ce(this,Mn,null);Ce(this,Yn,null);Ce(this,Fr,null);Ce(this,Di,0);Ce(this,di,0);Ce(this,ws,!1);Ce(this,Wo,new Set);Ce(this,qo,new Set);Ce(this,Gr,null);Ce(this,zl,yw(()=>(Ke(this,Gr,ei(x(this,Di))),()=>{Ke(this,Gr,null)})));var s;Ke(this,rr,e),Ke(this,ir,n),Ke(this,zi,o=>{var a=ct;a.b=this,a.f|=vu,r(o)}),this.parent=ct.b,this.transform_error=i??((s=this.parent)==null?void 0:s.transform_error)??(o=>o),Ke(this,Dn,Vs(()=>{Ye(this,Nt,ku).call(this)},kw))}defer_effect(e){Eg(e,x(this,Wo),x(this,qo))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!x(this,ir).pending}update_pending_count(e,n){Ye(this,Nt,Eu).call(this,e,n),Ke(this,Di,x(this,Di)+e),!(!x(this,Gr)||x(this,ws))&&(Ke(this,ws,!0),Yr(()=>{Ke(this,ws,!1),x(this,Gr)&&As(x(this,Gr),x(this,Di))}))}get_effect_pending(){return x(this,zl).call(this),d(x(this,Gr))}error(e){if(!x(this,ir).onerror&&!x(this,ir).failed)throw e;Qe!=null&&Qe.is_fork?(x(this,sr)&&Qe.skip_effect(x(this,sr)),x(this,Mn)&&Qe.skip_effect(x(this,Mn)),x(this,Yn)&&Qe.skip_effect(x(this,Yn)),Qe.oncommit(()=>{Ye(this,Nt,Su).call(this,e)})):Ye(this,Nt,Su).call(this,e)}}rr=new WeakMap,gd=new WeakMap,ir=new WeakMap,zi=new WeakMap,Dn=new WeakMap,sr=new WeakMap,Mn=new WeakMap,Yn=new WeakMap,Fr=new WeakMap,Di=new WeakMap,di=new WeakMap,ws=new WeakMap,Wo=new WeakMap,qo=new WeakMap,Gr=new WeakMap,zl=new WeakMap,Nt=new WeakSet,Tw=function(){try{Ke(this,sr,or(()=>x(this,zi).call(this,x(this,rr))))}catch(e){this.error(e)}},xw=function(e){const n=x(this,ir).failed,{reset:r,invoke_onerror:i}=Ye(this,Nt,yu).call(this,e);Yr(i),n&&Ke(this,Yn,or(()=>{n(x(this,rr),()=>e,()=>r)}))},yu=function(e){var n=!1,r=!1;const i=()=>{if(n){dw();return}n=!0,r&&nw(),x(this,Yn)!==null&&Fi(x(this,Yn),()=>{Ke(this,Yn,null)}),Ye(this,Nt,Va).call(this,()=>{Ye(this,Nt,ku).call(this)})};return{reset:i,invoke_onerror:()=>{var o,a;try{r=!0,(a=(o=x(this,ir)).onerror)==null||a.call(o,e,i),r=!1}catch(l){gi(l,x(this,Dn)&&x(this,Dn).parent)}}}},Cw=function(){const e=x(this,ir).pending;e&&(this.is_pending=!0,Ke(this,Mn,or(()=>e(x(this,rr)))),Yr(()=>{var n=Ke(this,Fr,document.createDocumentFragment()),r=Xr();n.append(r),Ke(this,sr,Ye(this,Nt,Va).call(this,()=>or(()=>x(this,zi).call(this,r)))),x(this,di)===0&&(x(this,rr).before(n),Ke(this,Fr,null),Fi(x(this,Mn),()=>{Ke(this,Mn,null)}),Ye(this,Nt,Ga).call(this,Qe))}))},ku=function(){try{if(this.is_pending=this.has_pending_snippet(),Ke(this,di,0),Ke(this,Di,0),Ke(this,sr,or(()=>{x(this,zi).call(this,x(this,rr))})),x(this,di)>0){var e=Ke(this,Fr,document.createDocumentFragment());Pd(x(this,sr),e);const n=x(this,ir).pending;Ke(this,Mn,or(()=>n(x(this,rr))))}else Ye(this,Nt,Ga).call(this,Qe)}catch(n){this.error(n)}},Ga=function(e){this.is_pending=!1,e.transfer_effects(x(this,Wo),x(this,qo))},Va=function(e){var n=ct,r=lt,i=kt;ur(x(this,Dn)),Fn(x(this,Dn)),Rs(x(this,Dn).ctx);try{return qi.ensure(),e()}catch(s){return yg(s),null}finally{ur(n),Fn(r),Rs(i)}},Eu=function(e,n){var r;if(!this.has_pending_snippet()){this.parent&&Ye(r=this.parent,Nt,Eu).call(r,e,n);return}Ke(this,di,x(this,di)+e),x(this,di)===0&&(Ye(this,Nt,Ga).call(this,n),x(this,Mn)&&Fi(x(this,Mn),()=>{Ke(this,Mn,null)}),x(this,Fr)&&(x(this,rr).before(x(this,Fr)),Ke(this,Fr,null)))},Su=function(e){x(this,sr)&&($n(x(this,sr)),Ke(this,sr,null)),x(this,Mn)&&($n(x(this,Mn)),Ke(this,Mn,null)),x(this,Yn)&&($n(x(this,Yn)),Ke(this,Yn,null));let n=x(this,ir).failed;const r=i=>{const{reset:s,invoke_onerror:o}=Ye(this,Nt,yu).call(this,i);o(),n&&Ke(this,Yn,Ye(this,Nt,Va).call(this,()=>{try{return or(()=>{var a=ct;a.b=this,a.f|=vu,n(x(this,rr),()=>i,()=>s)})}catch(a){return gi(a,x(this,Dn).parent),null}}))};Yr(()=>{var i;try{i=this.transform_error(e)}catch(s){gi(s,x(this,Dn)&&x(this,Dn).parent);return}i!==null&&typeof i=="object"&&typeof i.then=="function"?i.then(r,s=>gi(s,x(this,Dn)&&x(this,Dn).parent)):r(i)})};function Pw(t,e,n,r){const i=Gs()?yd:Tg;var s=t.filter(p=>!p.settled),o=e.map(i);if(n.length===0&&s.length===0){r(o);return}var a=ct,l=Rw(),c=s.length===1?s[0].promise:s.length>1?Promise.all(s.map(p=>p.promise)):null;function u(p){if((a.f&lr)===0){l();try{r([...o,...p])}catch(g){gi(g,a)}il()}}var f=Sg();if(n.length===0){c.then(()=>u([])).finally(f);return}function h(){Promise.all(n.map(p=>Aw(p))).then(u).catch(p=>gi(p,a)).finally(f)}c?c.then(()=>{l(),h(),il()}):h()}function Rw(){var t=ct,e=lt,n=kt,r=Qe;return function(s=!0){ur(t),Fn(e),Rs(n),s&&(t.f&lr)===0&&(r==null||r.activate(),r==null||r.apply())}}function il(t=!0){ur(null),Fn(null),Rs(null),t&&(Qe==null||Qe.deactivate())}function Sg(){var t=ct,e=t.b,n=Qe,r=!!(e!=null&&e.is_rendered());return e==null||e.update_pending_count(1,n),n.increment(r,t),()=>{e==null||e.update_pending_count(-1,n),n.decrement(r,t)}}function yd(t){var e=fn|Xt;return ct!==null&&(ct.f|=Fs),{ctx:kt,deps:null,effects:null,equals:vg,f:e,fn:t,reactions:null,rv:0,v:rn,wv:0,parent:ct,ac:null}}const co=Symbol("obsolete");function Aw(t,e,n){let r=ct;r===null&&W_();var i=void 0,s=ei(rn),o=!lt,a=new Set;return Vw(()=>{var p,g;var l=ct,c=pg();i=c.promise;try{Promise.resolve(t()).then(c.resolve,m=>{m!==aa&&c.reject(m)}).finally(il)}catch(m){c.reject(m),il()}var u=Qe;if(o){if((l.f&$s)!==0)var f=Sg();if((p=r.b)!=null&&p.is_rendered())(g=u.async_deriveds.get(l))==null||g.reject(co);else for(const m of a.values())m.reject(co);a.add(c),u.async_deriveds.set(l,c)}const h=(m,b=void 0)=>{f==null||f(),a.delete(c),b!==co&&(u.activate(),b?(s.f|=bi,As(s,b)):((s.f&bi)!==0&&(s.f^=bi),As(s,m)),u.deactivate())};c.promise.then(h,m=>h(null,m||"unknown"))}),Bg(()=>{for(const l of a)l.reject(co)}),new Promise(l=>{function c(u){function f(){u===i?l(s):c(i)}u.then(f,f)}c(i)})}function G(t){const e=yd(t);return Zg(e),e}function Tg(t){const e=yd(t);return e.equals=_g,e}function Ow(t){var e=t.effects;if(e!==null){t.effects=null;for(var n=0;n<e.length;n+=1)$n(e[n])}}function kd(t){var e,n=ct,r=t.parent;if(!Si&&r!==null&&t.v!==rn&&(r.f&(lr|In))!==0)return uw(),t.v;ur(r);try{t.f&=~Wi,Ow(t),e=Yg(t)}finally{ur(n)}return e}function xg(t){var e=kd(t);if(!t.equals(e)&&(t.wv=qg(),(!(Qe!=null&&Qe.is_fork)||t.deps===null)&&(Qe!==null?(Qe.capture(t,e,!0),To==null||To.capture(t,e,!0)):t.v=e,t.deps===null))){Gt(t,sn);return}Si||(vn!==null?(Td()||Qe!=null&&Qe.is_fork)&&vn.set(t,e):wd(t))}function Mw(t){var e;if(t.effects!==null)for(const n of t.effects)(n.teardown||n.ac)&&((e=n.teardown)==null||e.call(n),n.ac!==null&&ca(()=>{n.ac.abort(aa),n.ac=null}),n.fn!==null&&(n.teardown=j_),Lo(n,0),Cd(n))}function Cg(t){if(t.effects!==null)for(const e of t.effects)e.teardown&&e.fn!==null&&Os(e)}let kc=null,es=null,Qe=null,To=null,vn=null,Tu=null,xo=!1,Ec=!1,as=null,Za=null;var Df=0;let Nw=1;var ys,fi,Hi,ks,Es,Ss,Vr,Ts,Hn,Ko,Zr,mr,Or,xs,Bi,Et,xu,uo,Cu,Pg,Rg,ss,Lw,fo;const Dl=class Dl{constructor(){Ce(this,Et);X(this,"id",Nw++);Ce(this,ys,!1);X(this,"linked",!0);Ce(this,fi,null);Ce(this,Hi,null);X(this,"async_deriveds",new Map);X(this,"current",new Map);X(this,"previous",new Map);Ce(this,ks,new Set);Ce(this,Es,new Set);Ce(this,Ss,0);Ce(this,Vr,new Map);Ce(this,Ts,null);Ce(this,Hn,[]);Ce(this,Ko,[]);Ce(this,Zr,new Set);Ce(this,mr,new Set);Ce(this,Or,new Map);Ce(this,xs,new Set);X(this,"is_fork",!1);Ce(this,Bi,!1);es===null?kc=es=this:(Ke(es,Hi,this),Ke(this,fi,es)),es=this}skip_effect(e){x(this,Or).has(e)||x(this,Or).set(e,{d:[],m:[]}),x(this,xs).delete(e)}unskip_effect(e,n=r=>this.schedule(r)){var r=x(this,Or).get(e);if(r){x(this,Or).delete(e);for(var i of r.d)Gt(i,Xt),n(i);for(i of r.m)Gt(i,Tr),n(i)}x(this,xs).add(e)}capture(e,n,r=!1){e.v!==rn&&!this.previous.has(e)&&this.previous.set(e,e.v),(e.f&bi)===0&&(this.current.set(e,[n,r]),vn==null||vn.set(e,n)),this.is_fork||(e.v=n)}activate(){Qe=this}deactivate(){Qe=null,vn=null}flush(){try{Ec=!0,Qe=this,Ye(this,Et,uo).call(this)}finally{Df=0,Tu=null,as=null,Za=null,Ec=!1,Qe=null,vn=null,$i.clear()}}discard(){var e;for(const n of x(this,Es))n(this);x(this,Es).clear();for(const n of this.async_deriveds.values())n.reject(co);Ye(this,Et,fo).call(this),(e=x(this,Ts))==null||e.resolve()}register_created_effect(e){x(this,Ko).push(e)}increment(e,n){if(Ke(this,Ss,x(this,Ss)+1),e){let r=x(this,Vr).get(n)??0;x(this,Vr).set(n,r+1)}}decrement(e,n){if(Ke(this,Ss,x(this,Ss)-1),e){let r=x(this,Vr).get(n)??0;r===1?x(this,Vr).delete(n):x(this,Vr).set(n,r-1)}x(this,Bi)||(Ke(this,Bi,!0),Yr(()=>{Ke(this,Bi,!1),this.linked&&this.flush()}))}transfer_effects(e,n){for(const r of e)x(this,Zr).add(r);for(const r of n)x(this,mr).add(r);e.clear(),n.clear()}oncommit(e){x(this,ks).add(e)}ondiscard(e){x(this,Es).add(e)}settled(){return(x(this,Ts)??Ke(this,Ts,pg())).promise}static ensure(){if(Qe===null){const e=Qe=new Dl;!Ec&&!xo&&Yr(()=>{x(e,ys)||e.flush()})}return Qe}apply(){{vn=null;return}}schedule(e){var i;if(Tu=e,(i=e.b)!=null&&i.is_pending&&(e.f&(Ps|Gl|gg))!==0&&(e.f&$s)===0){e.b.defer_effect(e);return}for(var n=e;n.parent!==null;){n=n.parent;var r=n.f;if(as!==null&&n===ct&&(lt===null||(lt.f&fn)===0))return;if((r&(Qr|cr))!==0){if((r&sn)===0)return;n.f^=sn}}x(this,Hn).push(n)}};ys=new WeakMap,fi=new WeakMap,Hi=new WeakMap,ks=new WeakMap,Es=new WeakMap,Ss=new WeakMap,Vr=new WeakMap,Ts=new WeakMap,Hn=new WeakMap,Ko=new WeakMap,Zr=new WeakMap,mr=new WeakMap,Or=new WeakMap,xs=new WeakMap,Bi=new WeakMap,Et=new WeakSet,xu=function(){if(this.is_fork)return!0;for(const r of x(this,Vr).keys()){for(var e=r,n=!1;e.parent!==null;){if(x(this,Or).has(e)){n=!0;break}e=e.parent}if(!n)return!0}return!1},uo=function(){var l,c,u,f;Ke(this,ys,!0),Df++>1e3&&(Ye(this,Et,fo).call(this),zw());for(const h of x(this,Zr))x(this,mr).delete(h),Gt(h,Xt),this.schedule(h);for(const h of x(this,mr))Gt(h,Tr),this.schedule(h);const e=x(this,Hn);Ke(this,Hn,[]),this.apply();var n=as=[],r=[],i=Za=[];for(const h of e)try{Ye(this,Et,Cu).call(this,h,n,r)}catch(p){throw Mg(h),Ye(this,Et,xu).call(this)||this.discard(),p}if(Qe=null,i.length>0){var s=Dl.ensure();for(const h of i)s.schedule(h)}if(as=null,Za=null,Ye(this,Et,xu).call(this)){Ye(this,Et,ss).call(this,r),Ye(this,Et,ss).call(this,n);for(const[h,p]of x(this,Or))Og(h,p);i.length>0&&Ye(l=Qe,Et,uo).call(l);return}const o=Ye(this,Et,Pg).call(this);if(o){Ye(this,Et,ss).call(this,r),Ye(this,Et,ss).call(this,n),Ye(c=o,Et,Rg).call(c,this);return}x(this,Zr).clear(),x(this,mr).clear();for(const h of x(this,ks))h(this);x(this,ks).clear(),To=this,Hf(r),Hf(n),To=null,(u=x(this,Ts))==null||u.resolve();var a=Qe;if(x(this,Ss)===0&&(x(this,Hn).length===0||a!==null)&&Ye(this,Et,fo).call(this),x(this,Hn).length>0)if(a!==null){const h=a;x(h,Hn).push(...x(this,Hn).filter(p=>!x(h,Hn).includes(p)))}else a=this;a!==null&&Ye(f=a,Et,uo).call(f)},Cu=function(e,n,r){e.f^=sn;for(var i=e.first;i!==null;){var s=i.f,o=(s&(cr|Qr))!==0,a=o&&(s&sn)!==0,l=a||(s&In)!==0||x(this,Or).has(i);if(!l&&i.fn!==null){o?i.f^=sn:(s&Ps)!==0?n.push(i):da(i)&&((s&yr)!==0&&x(this,mr).add(i),Os(i));var c=i.first;if(c!==null){i=c;continue}}for(;i!==null;){var u=i.next;if(u!==null){i=u;break}i=i.parent}}},Pg=function(){for(var e=x(this,fi);e!==null;){if(!e.is_fork){for(const[n,[,r]]of this.current)if(e.current.has(n)&&!r)return e}e=x(e,fi)}return null},Rg=function(e){var r;for(const[i,s]of e.current)!this.previous.has(i)&&e.previous.has(i)&&this.previous.set(i,e.previous.get(i)),this.current.set(i,s);for(const[i,s]of e.async_deriveds){const o=this.async_deriveds.get(i);o&&s.promise.then(o.resolve).catch(o.reject)}e.async_deriveds.clear(),this.transfer_effects(x(e,Zr),x(e,mr));const n=i=>{var s=i.reactions;if(s!==null&&!((i.f&fn)!==0&&(i.f&(Xt|Tr))===0))for(const l of s){var o=l.f;if((o&fn)!==0)n(l);else{var a=l;o&(ds|yr)&&!this.async_deriveds.has(a)&&(x(this,mr).delete(a),Gt(a,Xt),this.schedule(a))}}};for(const i of this.current.keys())n(i);this.oncommit(()=>e.discard()),Ye(r=e,Et,fo).call(r),Qe=this,Ye(this,Et,uo).call(this)},ss=function(e){for(var n=0;n<e.length;n+=1)Eg(e[n],x(this,Zr),x(this,mr))},Lw=function(){var f;for(let h=kc;h!==null;h=x(h,Hi)){var e=h.id<this.id,n=[];for(const[p,[g,m]]of this.current){if(h.current.has(p)){var r=h.current.get(p)[0];if(e&&g!==r)h.current.set(p,[g,m]);else continue}n.push(p)}if(e)for(const[p,g]of this.async_deriveds){const m=h.async_deriveds.get(p);m&&g.promise.then(m.resolve).catch(m.reject)}var i=[...h.current.keys()].filter(p=>!h.current.get(p)[1]);if(!(!x(h,ys)||i.length===0)){var s=i.filter(p=>!this.current.has(p));if(s.length===0)e&&h.discard();else if(n.length>0){if(e)for(const p of x(this,xs))h.unskip_effect(p,g=>{var m;(g.f&(yr|ds))!==0?h.schedule(g):Ye(m=h,Et,ss).call(m,[g])});h.activate();var o=new Set,a=new Map;for(var l of n)Ag(l,s,o,a);a=new Map;var c=[...h.current].filter(([p,g])=>{const m=this.current.get(p);return m?m[0]!==g[0]||m[1]!==g[1]:!0}).map(([p])=>p);if(c.length>0)for(const p of x(this,Ko))(p.f&(lr|In|nl))===0&&Ed(p,c,a)&&((p.f&(ds|yr))!==0?(Gt(p,Xt),h.schedule(p)):x(h,Zr).add(p));if(x(h,Hn).length>0&&!x(h,Bi)){h.apply();for(var u of x(h,Hn))Ye(f=h,Et,Cu).call(f,u,[],[]);Ke(h,Hn,[])}h.deactivate()}}}},fo=function(){if(this.linked){var e=x(this,fi),n=x(this,Hi);e===null?kc=n:Ke(e,Hi,n),n===null?es=e:Ke(n,fi,e),this.linked=!1}};let qi=Dl;function Iw(t){var e=xo;xo=!0;try{for(var n;;){if(_w(),Qe===null)return n;Qe.flush()}}finally{xo=e}}function zw(){try{J_()}catch(t){gi(t,Tu)}}let gr=null;function Hf(t){var e=t.length;if(e!==0){for(var n=0;n<e;){var r=t[n++];if((r.f&(lr|In))===0&&da(r)&&(gr=new Set,Os(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&Fg(r),(gr==null?void 0:gr.size)>0)){$i.clear();for(const i of gr){if((i.f&(lr|In))!==0)continue;const s=[i];let o=i.parent;for(;o!==null;)gr.has(o)&&(gr.delete(o),s.push(o)),o=o.parent;for(let a=s.length-1;a>=0;a--){const l=s[a];(l.f&(lr|In))===0&&Os(l)}}gr.clear()}}gr=null}}function Ag(t,e,n,r){if(!n.has(t)&&(n.add(t),t.reactions!==null))for(const i of t.reactions){const s=i.f;(s&fn)!==0?Ag(i,e,n,r):(s&(ds|yr))!==0&&(s&Xt)===0&&Ed(i,e,r)&&(Gt(i,Xt),Sd(i))}}function Ed(t,e,n){const r=n.get(t);if(r!==void 0)return r;if(t.deps!==null)for(const i of t.deps){if(tl.call(e,i))return!0;if((i.f&fn)!==0&&Ed(i,e,n))return n.set(i,!0),!0}return n.set(t,!1),!1}function Sd(t){Qe.schedule(t)}function Og(t,e){if(!((t.f&cr)!==0&&(t.f&sn)!==0)){(t.f&Xt)!==0?e.d.push(t):(t.f&Tr)!==0&&e.m.push(t),Gt(t,sn);for(var n=t.first;n!==null;)Og(n,e),n=n.next}}function Mg(t){Gt(t,sn);for(var e=t.first;e!==null;)Mg(e),e=e.next}let sl=new Set;const $i=new Map;let Ng=!1;function ei(t,e){var n={f:0,v:t,reactions:null,equals:vg,rv:0,wv:0};return n}function te(t,e){const n=ei(t);return Zg(n),n}function Dw(t,e=!1,n=!0){var i;const r=ei(t);return e||(r.equals=_g),la&&n&&kt!==null&&kt.l!==null&&((i=kt.l).s??(i.s=[])).push(r),r}function k(t,e,n=!1){lt!==null&&(!kr||(lt.f&nl)!==0)&&Gs()&&(lt.f&(fn|yr|ds|nl))!==0&&(Hr===null||!Hr.has(t))&&tw();let r=n?pt(e):e;return As(t,r,Za)}function As(t,e,n=null){if(!t.equals(e)){$i.set(t,Si?e:t.v);var r=qi.ensure();if(r.capture(t,e),(t.f&fn)!==0){const i=t;(t.f&Xt)!==0&&kd(i),vn===null&&wd(i)}t.wv=qg(),Lg(t,Xt,n),Gs()&&ct!==null&&(ct.f&sn)!==0&&(ct.f&(cr|Qr))===0&&(nr===null?qw([t]):nr.push(t)),!r.is_fork&&sl.size>0&&!Ng&&Hw()}return e}function Hw(){Ng=!1;for(const t of sl){(t.f&sn)!==0&&Gt(t,Tr);let e;try{e=da(t)}catch{e=!0}e&&Os(t)}sl.clear()}function dn(t){k(t,t.v+1)}function Lg(t,e,n){var r=t.reactions;if(r!==null)for(var i=Gs(),s=r.length,o=0;o<s;o++){var a=r[o],l=a.f;if(!(!i&&a===ct)){var c=(l&Xt)===0;if(c&&Gt(a,e),(l&nl)!==0)sl.add(a);else if((l&fn)!==0){var u=a;vn==null||vn.delete(u),(l&Wi)===0&&(l&ar&&(ct===null||(ct.f&rl)===0)&&(a.f|=Wi),Lg(u,Tr,n))}else if(c){var f=a;(l&yr)!==0&&gr!==null&&gr.add(f),n!==null?n.push(f):Sd(f)}}}}function pt(t){if(typeof t!="object"||t===null||fs in t)return t;const e=Fl(t);if(e!==hg&&e!==U_)return t;var n=new Map,r=vd(t),i=te(0),s=xr,o=a=>{if(xr===s)return a();var l=lt,c=xr;Fn(null),Uf(s);var u=a();return Fn(l),Uf(c),u};return r&&n.set("length",te(t.length)),new Proxy(t,{defineProperty(a,l,c){(!("value"in c)||c.configurable===!1||c.enumerable===!1||c.writable===!1)&&Q_();var u=n.get(l);return u===void 0?o(()=>{var f=te(c.value);return n.set(l,f),f}):k(u,c.value,!0),!0},deleteProperty(a,l){var c=n.get(l);if(c===void 0){if(l in a){const u=o(()=>te(rn));n.set(l,u),dn(i)}}else k(c,rn),dn(i);return!0},get(a,l,c){var p;if(l===fs)return t;var u=n.get(l),f=l in a;if(u===void 0&&(!f||(p=So(a,l))!=null&&p.writable)&&(u=o(()=>{var g=pt(f?a[l]:rn),m=te(g);return m}),n.set(l,u)),u!==void 0){var h=d(u);return h===rn?void 0:h}return Reflect.get(a,l,c)},getOwnPropertyDescriptor(a,l){var c=Reflect.getOwnPropertyDescriptor(a,l);if(c&&"value"in c){var u=n.get(l);u&&(c.value=d(u))}else if(c===void 0){var f=n.get(l),h=f==null?void 0:f.v;if(f!==void 0&&h!==rn)return{enumerable:!0,configurable:!0,value:h,writable:!0}}return c},has(a,l){var h;if(l===fs)return!0;var c=n.get(l),u=c!==void 0&&c.v!==rn||Reflect.has(a,l);if(c!==void 0||ct!==null&&(!u||(h=So(a,l))!=null&&h.writable)){c===void 0&&(c=o(()=>{var p=u?pt(a[l]):rn,g=te(p);return g}),n.set(l,c));var f=d(c);if(f===rn)return!1}return u},set(a,l,c,u){var R;var f=n.get(l),h=l in a;if(r&&l==="length")for(var p=c;p<f.v;p+=1){var g=n.get(p+"");g!==void 0?k(g,rn):p in a&&(g=o(()=>te(rn)),n.set(p+"",g))}if(f===void 0)(!h||(R=So(a,l))!=null&&R.writable)&&(f=o(()=>te(void 0)),k(f,pt(c)),n.set(l,f));else{h=f.v!==rn;var m=o(()=>pt(c));k(f,m)}var b=Reflect.getOwnPropertyDescriptor(a,l);if(b!=null&&b.set&&b.set.call(u,c),!h){if(r&&typeof l=="string"){var _=n.get("length"),y=Number(l);Number.isInteger(y)&&y>=_.v&&k(_,y+1)}dn(i)}return!0},ownKeys(a){d(i);var l=Reflect.ownKeys(a).filter(f=>{var h=n.get(f);return h===void 0||h.v!==rn});for(var[c,u]of n)u.v!==rn&&!(c in a)&&l.push(c);return l},setPrototypeOf(){ew()}})}var No,Ig,zg,Dg;function Bw(){if(No===void 0){No=window,Ig=/Firefox/.test(navigator.userAgent);var t=Element.prototype,e=Node.prototype,n=Text.prototype;zg=So(e,"firstChild").get,Dg=So(e,"nextSibling").get,zf(t)&&(t[_u]=void 0,t[$a]=null,t[wu]=void 0,t.__e=void 0),zf(n)&&(n[lo]=void 0)}}function Xr(t=""){return document.createTextNode(t)}function ol(t){return zg.call(t)}function ua(t){return Dg.call(t)}function v(t,e){return ol(t)}function tt(t,e=!1){{var n=ol(t);return n instanceof Comment&&n.data===""?ua(n):n}}function S(t,e=1,n=!1){let r=t;for(;e--;)r=ua(r);return r}function Uw(t){t.textContent=""}function Hg(){return!1}function jw(t,e,n){return n?document.createElement(t,{is:n}):document.createElement(t)}function $w(t){ct===null&&(lt===null&&X_(),Y_()),Si&&K_()}function Fw(t,e){var n=e.last;n===null?e.last=e.first=t:(n.next=t,t.prev=n,e.last=t)}function ii(t,e){var n=ct;n!==null&&(n.f&In)!==0&&(t|=In);var r={ctx:kt,deps:null,nodes:null,f:t|Xt|ar,first:null,fn:e,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};Qe==null||Qe.register_created_effect(r);var i=r;if((t&Ps)!==0)as!==null?as.push(r):qi.ensure().schedule(r);else if(e!==null){try{Os(r)}catch(o){throw $n(r),o}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&(i.f&Fs)===0&&(i=i.first,(t&yr)!==0&&(t&Ei)!==0&&i!==null&&(i.f|=Ei))}if(i!==null&&(i.parent=n,n!==null&&Fw(i,n),lt!==null&&(lt.f&fn)!==0&&(t&Qr)===0)){var s=lt;(s.effects??(s.effects=[])).push(i)}return r}function Td(){return lt!==null&&!kr}function Bg(t){const e=ii(Gl,null);return Gt(e,sn),e.teardown=t,e}function Qn(t){$w();var e=ct.f,n=!lt&&(e&cr)!==0&&kt!==null&&!kt.i;if(n){var r=kt;(r.e??(r.e=[])).push(t)}else return Ug(t)}function Ug(t){return ii(Ps|V_,t)}function Gw(t){qi.ensure();const e=ii(Qr|Fs,t);return(n={})=>new Promise(r=>{n.outro?Fi(e,()=>{$n(e),r(void 0)}):($n(e),r(void 0))})}function jg(t){return ii(Ps,t)}function Vw(t){return ii(ds|Fs,t)}function xd(t,e=0){return ii(Gl|e,t)}function w(t,e=[],n=[],r=[]){Pw(r,e,n,i=>{ii(Gl,()=>{t(...i.map(d))})})}function Vs(t,e=0){var n=ii(yr|e,t);return n}function or(t){return ii(cr|Fs,t)}function $g(t){var e=t.teardown;if(e!==null){const n=Si,r=lt;Bf(!0),Fn(null);try{e.call(null)}finally{Bf(n),Fn(r)}}}function Cd(t,e=!1){var n=t.first;for(t.first=t.last=null;n!==null;){const i=n.ac;i!==null&&ca(()=>{i.abort(aa)});var r=n.next;(n.f&Qr)!==0?n.parent=null:$n(n,e),n=r}}function Zw(t){for(var e=t.first;e!==null;){var n=e.next;(e.f&cr)===0&&$n(e),e=n}}function $n(t,e=!0){var n=!1;(e||(t.f&G_)!==0)&&t.nodes!==null&&t.nodes.end!==null&&(Ww(t.nodes.start,t.nodes.end),n=!0),t.f|=bu,Cd(t,e&&!n),Lo(t,0);var r=t.nodes&&t.nodes.t;if(r!==null)for(const s of r)s.stop();$g(t),t.f^=bu,t.f|=lr;var i=t.parent;i!==null&&i.first!==null&&Fg(t),t.next=t.prev=t.teardown=t.ctx=t.deps=t.fn=t.nodes=t.ac=t.b=null}function Ww(t,e){for(;t!==null;){var n=t===e?null:ua(t);t.remove(),t=n}}function Fg(t){var e=t.parent,n=t.prev,r=t.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),e!==null&&(e.first===t&&(e.first=r),e.last===t&&(e.last=n))}function Fi(t,e,n=!0){var r=[];Gg(t,r,!0);var i=()=>{n&&$n(t),e&&e()},s=r.length;if(s>0){var o=()=>--s||i();for(var a of r)a.out(o)}else i()}function Gg(t,e,n){if((t.f&In)===0){t.f^=In;var r=t.nodes&&t.nodes.t;if(r!==null)for(const a of r)(a.is_global||n)&&e.push(a);for(var i=t.first;i!==null;){var s=i.next;if((i.f&Qr)===0){var o=(i.f&Ei)!==0||(i.f&cr)!==0&&(t.f&yr)!==0;Gg(i,e,o?n:!1)}i=s}}}function al(t){Vg(t,!0)}function Vg(t,e){if((t.f&In)!==0){t.f^=In,(t.f&sn)===0&&(Gt(t,Xt),qi.ensure().schedule(t));for(var n=t.first;n!==null;){var r=n.next,i=(n.f&Ei)!==0||(n.f&cr)!==0;Vg(n,i?e:!1),n=r}var s=t.nodes&&t.nodes.t;if(s!==null)for(const o of s)(o.is_global||e)&&o.in()}}function Pd(t,e){if(t.nodes)for(var n=t.nodes.start,r=t.nodes.end;n!==null;){var i=n===r?null:ua(n);e.append(n),n=i}}let Wa=!1,Si=!1;function Bf(t){Si=t}let lt=null,kr=!1;function Fn(t){lt=t}let ct=null;function ur(t){ct=t}let Hr=null;function Zg(t){lt!==null&&(Hr??(Hr=new Set)).add(t)}let Bn=null,Kn=0,nr=null;function qw(t){nr=t}let Wg=1,Li=0,xr=Li;function Uf(t){xr=t}function qg(){return++Wg}function da(t){var e=t.f;if((e&Xt)!==0)return!0;if(e&fn&&(t.f&=~Wi),(e&Tr)!==0){for(var n=t.deps,r=n.length,i=0;i<r;i++){var s=n[i];if(da(s)&&xg(s),s.wv>t.wv)return!0}(e&ar)!==0&&vn===null&&Gt(t,sn)}return!1}function Kg(t,e,n=!0){var r=t.reactions;if(r!==null&&!(Hr!==null&&Hr.has(t)))for(var i=0;i<r.length;i++){var s=r[i];(s.f&fn)!==0?Kg(s,e,!1):e===s&&(n?Gt(s,Xt):(s.f&sn)!==0&&Gt(s,Tr),Sd(s))}}function Yg(t){var m;var e=Bn,n=Kn,r=nr,i=lt,s=Hr,o=kt,a=kr,l=xr,c=t.f;Bn=null,Kn=0,nr=null,lt=(c&(cr|Qr))===0?t:null,Hr=null,Rs(t.ctx),kr=!1,xr=++Li,t.ac!==null&&(ca(()=>{t.ac.abort(aa)}),t.ac=null);try{t.f|=rl;var u=t.fn,f=u();t.f|=$s;var h=t.deps,p=Qe==null?void 0:Qe.is_fork;if(Bn!==null){var g;if(p||Lo(t,Kn),h!==null&&Kn>0)for(h.length=Kn+Bn.length,g=0;g<Bn.length;g++)h[Kn+g]=Bn[g];else t.deps=h=Bn;if(Td()&&(t.f&ar)!==0)for(g=Kn;g<h.length;g++)((m=h[g]).reactions??(m.reactions=[])).push(t)}else!p&&h!==null&&Kn<h.length&&(Lo(t,Kn),h.length=Kn);if(Gs()&&nr!==null&&!kr&&h!==null&&(t.f&(fn|Tr|Xt))===0)for(g=0;g<nr.length;g++)Kg(nr[g],t);if(i!==null&&i!==t){if(Li++,i.deps!==null)for(let b=0;b<n;b+=1)i.deps[b].rv=Li;if(e!==null)for(const b of e)b.rv=Li;nr!==null&&(r===null?r=nr:r.push(...nr))}return(t.f&bi)!==0&&(t.f^=bi),f}catch(b){return yg(b)}finally{t.f^=rl,Bn=e,Kn=n,nr=r,lt=i,Hr=s,Rs(o),kr=a,xr=l}}function Kw(t,e){let n=e.reactions;if(n!==null){var r=H_.call(n,t);if(r!==-1){var i=n.length-1;i===0?n=e.reactions=null:(n[r]=n[i],n.pop())}}if(n===null&&(e.f&fn)!==0&&(Bn===null||!tl.call(Bn,e))){var s=e;(s.f&ar)!==0&&(s.f^=ar,s.f&=~Wi),s.v!==rn&&wd(s),s.ac!==null&&ca(()=>{s.ac.abort(aa),s.ac=null,Gt(s,Xt)}),Mw(s),Lo(s,0)}}function Lo(t,e){var n=t.deps;if(n!==null)for(var r=e;r<n.length;r++)Kw(t,n[r])}function Os(t){var e=t.f;if((e&lr)===0){Gt(t,sn);var n=ct,r=Wa;ct=t,Wa=(e&(cr|Qr))===0;try{(e&(yr|gg))!==0?Zw(t):Cd(t),$g(t);var i=Yg(t);t.teardown=typeof i=="function"?i:null,t.wv=Wg;var s;dg&&fw&&(t.f&Xt)!==0&&t.deps}finally{Wa=r,ct=n}}}async function Co(){await Promise.resolve(),Iw()}function d(t){var e=t.f,n=(e&fn)!==0;if(lt!==null&&!kr){var r=ct!==null&&(ct.f&lr)!==0;if(!r&&(Hr===null||!Hr.has(t))){var i=lt.deps;if((lt.f&rl)!==0)t.rv<Li&&(t.rv=Li,Bn===null&&i!==null&&i[Kn]===t?Kn++:Bn===null?Bn=[t]:Bn.push(t));else{lt.deps??(lt.deps=[]),tl.call(lt.deps,t)||lt.deps.push(t);var s=t.reactions;s===null?t.reactions=[lt]:tl.call(s,lt)||s.push(lt)}}}if(Si&&$i.has(t))return $i.get(t);if(n){var o=t;if(Si){var a=o.v;return((o.f&sn)===0&&o.reactions!==null||Jg(o))&&(a=kd(o)),$i.set(o,a),a}var l=(o.f&ar)===0&&!kr&&lt!==null&&(Wa||(lt.f&ar)!==0),c=(o.f&$s)===0;da(o)&&(l&&(o.f|=ar),xg(o)),l&&!c&&(Cg(o),Xg(o))}if(vn!=null&&vn.has(t))return vn.get(t);if((t.f&bi)!==0)throw t.v;return t.v}function Xg(t){if(t.f|=ar,t.deps!==null)for(const e of t.deps)(e.reactions??(e.reactions=[])).push(t),(e.f&fn)!==0&&(e.f&ar)===0&&(Cg(e),Xg(e))}function Jg(t){if(t.v===rn)return!0;if(t.deps===null)return!1;for(const e of t.deps)if($i.has(e)||(e.f&fn)!==0&&Jg(e))return!0;return!1}function Cr(t){var e=kr;try{return kr=!0,t()}finally{kr=e}}function Yw(t){if(!(typeof t!="object"||!t||t instanceof EventTarget)){if(fs in t)Pu(t);else if(!Array.isArray(t))for(let e in t){const n=t[e];typeof n=="object"&&n&&fs in n&&Pu(n)}}}function Pu(t,e=new Set){if(typeof t=="object"&&t!==null&&!(t instanceof EventTarget)&&!e.has(t)){e.add(t),t instanceof Date&&t.getTime();for(let r in t)try{Pu(t[r],e)}catch{}const n=Fl(t);if(n!==Object.prototype&&n!==Array.prototype&&n!==Map.prototype&&n!==Set.prototype&&n!==Date.prototype){const r=fg(n);for(let i in r){const s=r[i].get;if(s)try{s.call(t)}catch{}}}}}const Xw=["touchstart","touchmove"];function Jw(t){return Xw.includes(t)}const Ii=Symbol("events"),Qg=new Set,Ru=new Set;function em(t,e,n,r={}){function i(s){if(r.capture||Au.call(e,s),!s.cancelBubble)return ca(()=>n==null?void 0:n.call(this,s))}return t.startsWith("pointer")||t.startsWith("touch")||t==="wheel"?Yr(()=>{e.addEventListener(t,i,r)}):e.addEventListener(t,i,r),i}function jf(t,e,n,r={}){var i=em(e,t,n,r);return()=>{t.removeEventListener(e,i,r)}}function Pt(t,e,n,r,i){var s={capture:r,passive:i},o=em(t,e,n,s);(e===document.body||e===window||e===document||e instanceof HTMLMediaElement)&&Bg(()=>{e.removeEventListener(t,o,s)})}function de(t,e,n){(e[Ii]??(e[Ii]={}))[t]=n}function bt(t){for(var e=0;e<t.length;e++)Qg.add(t[e]);for(var n of Ru)n(t)}let $f=null;function Au(t){var m,b;var e=this,n=e.ownerDocument,r=t.type,i=((m=t.composedPath)==null?void 0:m.call(t))||[],s=i[0]||t.target;$f=t;var o=0,a=$f===t&&t[Ii];if(a){var l=i.indexOf(a);if(l!==-1&&(e===document||e===window)){t[Ii]=e;return}var c=i.indexOf(e);if(c===-1)return;l<=c&&(o=l)}if(s=i[o]||t.target,s!==e){B_(t,"currentTarget",{configurable:!0,get(){return s||n}});var u=lt,f=ct;Fn(null),ur(null);try{for(var h,p=[];s!==null&&s!==e;){try{var g=(b=s[Ii])==null?void 0:b[r];g!=null&&(!s.disabled||t.target===s)&&g.call(s,t)}catch(_){h?p.push(_):h=_}if(t.cancelBubble)break;o++,s=o<i.length?i[o]:null}if(h){for(let _ of p)queueMicrotask(()=>{throw _});throw h}}finally{t[Ii]=e,delete t.currentTarget,Fn(u),ur(f)}}}var lg;const Sc=((lg=globalThis==null?void 0:globalThis.window)==null?void 0:lg.trustedTypes)&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:t=>t});function Qw(t){return(Sc==null?void 0:Sc.createHTML(t))??t}function ey(t){var e=jw("template");return e.innerHTML=Qw(t.replaceAll("<!>","<!---->")),e.content}function ll(t,e){var n=ct;n.nodes===null&&(n.nodes={start:t,end:e,a:null,t:null})}function N(t,e){var n=(e&aw)!==0,r=(e&lw)!==0,i,s=!t.startsWith("<!>");return()=>{i===void 0&&(i=ey(s?t:"<!>"+t),n||(i=ol(i)));var o=r||Ig?document.importNode(i,!0):i.cloneNode(!0);if(n){var a=ol(o),l=o.lastChild;ll(a,l)}else ll(o,o);return o}}function ka(t=""){{var e=Xr(t+"");return ll(e,e),e}}function _n(){var t=document.createDocumentFragment(),e=document.createComment(""),n=Xr();return t.append(e,n),ll(e,n),t}function C(t,e){t!==null&&t.before(e)}function E(t,e){var n=e==null?"":typeof e=="object"?`${e}`:e;n!==(t[lo]??(t[lo]=t.nodeValue))&&(t[lo]=n,t.nodeValue=`${n}`)}function Vl(t,e){return ty(t,e)}const Ea=new Map;function ty(t,{target:e,anchor:n,props:r={},events:i,context:s,intro:o=!0,transformError:a}){Bw();var l=void 0,c=Gw(()=>{var u=n??e.appendChild(Xr());Ew(u,{pending:()=>{}},p=>{Ze({});var g=kt;s&&(g.c=s),i&&(r.$$events=i),l=t(p,r)||{},We()},a);var f=new Set,h=p=>{for(var g=0;g<p.length;g++){var m=p[g];if(!f.has(m)){f.add(m);var b=Jw(m);for(const R of[e,document]){var _=Ea.get(R);_===void 0&&(_=new Map,Ea.set(R,_));var y=_.get(m);y===void 0?(R.addEventListener(m,Au,{passive:b}),_.set(m,1)):_.set(m,y+1)}}}};return h($l(Qg)),Ru.add(h),()=>{var b;for(var p of f)for(const _ of[e,document]){var g=Ea.get(_),m=g.get(p);--m==0?(_.removeEventListener(p,Au),g.delete(p),g.size===0&&Ea.delete(_)):g.set(p,m)}Ru.delete(h),u!==n&&((b=u.parentNode)==null||b.removeChild(u))}});return Ou.set(l,c),l}let Ou=new WeakMap;function Rd(t,e){const n=Ou.get(t);return n?(Ou.delete(t),n(e)):Promise.resolve()}var vr,Mr,Xn,Ui,Yo,Xo,Hl;class Zl{constructor(e,n=!0){X(this,"anchor");Ce(this,vr,new Map);Ce(this,Mr,new Map);Ce(this,Xn,new Map);Ce(this,Ui,new Set);Ce(this,Yo,!0);Ce(this,Xo,e=>{if(x(this,vr).has(e)){var n=x(this,vr).get(e),r=x(this,Mr).get(n);if(r)al(r),x(this,Ui).delete(n);else{var i=x(this,Xn).get(n);i&&(al(i.effect),x(this,Mr).set(n,i.effect),x(this,Xn).delete(n),i.fragment.lastChild.remove(),this.anchor.before(i.fragment),r=i.effect)}for(const[s,o]of x(this,vr)){if(x(this,vr).delete(s),s===e)break;const a=x(this,Xn).get(o);a&&($n(a.effect),x(this,Xn).delete(o))}for(const[s,o]of x(this,Mr)){if(s===n||x(this,Ui).has(s))continue;const a=()=>{if(Array.from(x(this,vr).values()).includes(s)){var c=document.createDocumentFragment();Pd(o,c),c.append(Xr()),x(this,Xn).set(s,{effect:o,fragment:c})}else $n(o);x(this,Ui).delete(s),x(this,Mr).delete(s)};x(this,Yo)||!r?(x(this,Ui).add(s),Fi(o,a,!1)):a()}}});Ce(this,Hl,e=>{x(this,vr).delete(e);const n=Array.from(x(this,vr).values());for(const[r,i]of x(this,Xn))n.includes(r)||($n(i.effect),x(this,Xn).delete(r))});this.anchor=e,Ke(this,Yo,n)}ensure(e,n){var r=Qe,i=Hg();if(n&&!x(this,Mr).has(e)&&!x(this,Xn).has(e))if(i){var s=document.createDocumentFragment(),o=Xr();s.append(o),x(this,Xn).set(e,{effect:or(()=>n(o)),fragment:s})}else x(this,Mr).set(e,or(()=>n(this.anchor)));if(x(this,vr).set(r,e),i){for(const[a,l]of x(this,Mr))a===e?r.unskip_effect(l):r.skip_effect(l);for(const[a,l]of x(this,Xn))a===e?r.unskip_effect(l.effect):r.skip_effect(l.effect);r.oncommit(x(this,Xo)),r.ondiscard(x(this,Hl))}else x(this,Xo).call(this,r)}}vr=new WeakMap,Mr=new WeakMap,Xn=new WeakMap,Ui=new WeakMap,Yo=new WeakMap,Xo=new WeakMap,Hl=new WeakMap;function W(t,e,n=!1){var r=new Zl(t),i=n?Ei:0;function s(o,a){r.ensure(o,a)}Vs(()=>{var o=!1;e((a,l=0)=>{o=!0,s(l,a)}),o||s(-1,null)},i)}const ny=Symbol("NaN");function tm(t,e,n){var r=new Zl(t),i=!Gs();Vs(()=>{var s=e();s!==s&&(s=ny),i&&s!==null&&typeof s=="object"&&(s={}),r.ensure(s,n)})}function ry(t,e,n){for(var r=[],i=e.length,s,o=e.length,a=0;a<i;a++){let f=e[a];Fi(f,()=>{if(s){if(s.pending.delete(f),s.done.add(f),s.pending.size===0){var h=t.outrogroups;Mu(t,$l(s.done)),h.delete(s),h.size===0&&(t.outrogroups=null)}}else o-=1},!1)}if(o===0){var l=r.length===0&&n!==null;if(l){var c=n,u=c.parentNode;Uw(u),u.append(c),t.items.clear()}Mu(t,e,!l)}else s={pending:new Set(e),done:new Set},(t.outrogroups??(t.outrogroups=new Set)).add(s)}function Mu(t,e,n=!0){var r;if(t.pending.size>0){r=new Set;for(const o of t.pending.values())for(const a of o)r.add(t.items.get(a).e)}for(var i=0;i<e.length;i++){var s=e[i];if(r!=null&&r.has(s)){s.f|=zr;const o=document.createDocumentFragment();Pd(s,o)}else $n(e[i],n)}}var Ff;function Mt(t,e,n,r,i,s=null){var o=t,a=new Map,l=(e&mg)!==0;if(l){var c=t;o=c.appendChild(Xr())}var u=null,f=Tg(()=>{var R=n();return vd(R)?R:R==null?[]:$l(R)}),h,p=new Map,g=!0;function m(R){(y.effect.f&lr)===0&&(y.pending.delete(R),y.fallback=u,iy(y,h,o,e,r),u!==null&&(h.length===0?(u.f&zr)===0?al(u):(u.f^=zr,ho(u,null,o)):Fi(u,()=>{u=null})))}function b(R){y.pending.delete(R)}var _=Vs(()=>{h=d(f);for(var R=h.length,L=new Set,P=Qe,A=Hg(),O=0;O<R;O+=1){var D=h[O],z=r(D,O),B=g?null:a.get(z);B?(B.v&&As(B.v,D),B.i&&As(B.i,O),A&&P.unskip_effect(B.e)):(B=sy(a,g?o:Ff??(Ff=Xr()),D,z,O,i,e,n),g||(B.e.f|=zr),a.set(z,B)),L.add(z)}if(R===0&&s&&!u&&(g?u=or(()=>s(o)):(u=or(()=>s(Ff??(Ff=Xr()))),u.f|=zr)),R>L.size&&q_(),!g)if(p.set(P,L),A){for(const[j,q]of a)L.has(j)||P.skip_effect(q.e);P.oncommit(m),P.ondiscard(b)}else m(P);d(f)}),y={effect:_,items:a,pending:p,outrogroups:null,fallback:u};g=!1}function ro(t){for(;t!==null&&(t.f&cr)===0;)t=t.next;return t}function iy(t,e,n,r,i){var B,j,q,ie,ve,pe,ee,be,Ee;var s=(r&sw)!==0,o=e.length,a=t.items,l=ro(t.effect.first),c,u=null,f,h=[],p=[],g,m,b,_;if(s)for(_=0;_<o;_+=1)g=e[_],m=i(g,_),b=a.get(m).e,(b.f&zr)===0&&((j=(B=b.nodes)==null?void 0:B.a)==null||j.measure(),(f??(f=new Set)).add(b));for(_=0;_<o;_+=1){if(g=e[_],m=i(g,_),b=a.get(m).e,t.outrogroups!==null)for(const Me of t.outrogroups)Me.pending.delete(b),Me.done.delete(b);if((b.f&In)!==0&&(al(b),s&&((ie=(q=b.nodes)==null?void 0:q.a)==null||ie.unfix(),(f??(f=new Set)).delete(b))),(b.f&zr)!==0)if(b.f^=zr,b===l)ho(b,null,n);else{var y=u?u.next:l;b===t.effect.last&&(t.effect.last=b.prev),b.prev&&(b.prev.next=b.next),b.next&&(b.next.prev=b.prev),ci(t,u,b),ci(t,b,y),ho(b,y,n),u=b,h=[],p=[],l=ro(u.next);continue}if(b!==l){if(c!==void 0&&c.has(b)){if(h.length<p.length){var R=p[0],L;u=R.prev;var P=h[0],A=h[h.length-1];for(L=0;L<h.length;L+=1)ho(h[L],R,n);for(L=0;L<p.length;L+=1)c.delete(p[L]);ci(t,P.prev,A.next),ci(t,u,P),ci(t,A,R),l=R,u=A,_-=1,h=[],p=[]}else c.delete(b),ho(b,l,n),ci(t,b.prev,b.next),ci(t,b,u===null?t.effect.first:u.next),ci(t,u,b),u=b;continue}for(h=[],p=[];l!==null&&l!==b;)(c??(c=new Set)).add(l),p.push(l),l=ro(l.next);if(l===null)continue}(b.f&zr)===0&&h.push(b),u=b,l=ro(b.next)}if(t.outrogroups!==null){for(const Me of t.outrogroups)Me.pending.size===0&&(Mu(t,$l(Me.done)),(ve=t.outrogroups)==null||ve.delete(Me));t.outrogroups.size===0&&(t.outrogroups=null)}if(l!==null||c!==void 0){var O=[];if(c!==void 0)for(b of c)(b.f&In)===0&&O.push(b);for(;l!==null;)(l.f&In)===0&&l!==t.fallback&&O.push(l),l=ro(l.next);var D=O.length;if(D>0){var z=(r&mg)!==0&&o===0?n:null;if(s){for(_=0;_<D;_+=1)(ee=(pe=O[_].nodes)==null?void 0:pe.a)==null||ee.measure();for(_=0;_<D;_+=1)(Ee=(be=O[_].nodes)==null?void 0:be.a)==null||Ee.fix()}ry(t,O,z)}}s&&Yr(()=>{var Me,$e;if(f!==void 0)for(b of f)($e=(Me=b.nodes)==null?void 0:Me.a)==null||$e.apply()})}function sy(t,e,n,r,i,s,o,a){var l=(o&rw)!==0?(o&ow)===0?Dw(n,!1,!1):ei(n):null,c=(o&iw)!==0?ei(i):null;return{v:l,i:c,e:or(()=>(s(e,l??n,c??i,a),()=>{t.delete(r)}))}}function ho(t,e,n){if(t.nodes)for(var r=t.nodes.start,i=t.nodes.end,s=e&&(e.f&zr)===0?e.nodes.start:n;r!==null;){var o=ua(r);if(s.before(r),r===i)return;r=o}}function ci(t,e,n){e===null?t.effect.first=n:e.next=n,n===null?t.effect.last=e:n.prev=e}function oy(t,e,...n){var r=new Zl(t);Vs(()=>{const i=e()??null;r.ensure(i,i&&(s=>i(s,...n)))},Ei)}function ay(t,e,n){var r=new Zl(t);Vs(()=>{var i=e()??null;r.ensure(i,i&&(s=>n(s,i)))},Ei)}function Zs(t,e,n){jg(()=>{var r=Cr(()=>e(t,n==null?void 0:n())||{});if(n&&(r!=null&&r.update)){var i=!1,s={};xd(()=>{var o=n();Yw(o),i&&bg(s,o)&&(s=o,r.update(o))}),i=!0}if(r!=null&&r.destroy)return()=>r.destroy()})}const Gf=[...`
2
+ \r\f \v\uFEFF`];function ly(t,e,n){var r=t==null?"":""+t;if(e&&(r=r?r+" "+e:e),n){for(var i of Object.keys(n))if(n[i])r=r?r+" "+i:i;else if(r.length)for(var s=i.length,o=0;(o=r.indexOf(i,o))>=0;){var a=o+s;(o===0||Gf.includes(r[o-1]))&&(a===r.length||Gf.includes(r[a]))?r=(o===0?"":r.substring(0,o))+r.substring(a+1):o=a}}return r===""?null:r}function Vf(t,e=!1){var n=e?" !important;":";",r="";for(var i of Object.keys(t)){var s=t[i];s!=null&&s!==""&&(r+=" "+i+": "+s+n)}return r}function Tc(t){return t[0]!=="-"||t[1]!=="-"?t.toLowerCase():t}function cy(t,e){if(e){var n="",r,i;if(Array.isArray(e)?(r=e[0],i=e[1]):r=e,t){t=String(t).replaceAll(/\s*\/\*.*?\*\/\s*/g,"").trim();var s=!1,o=0,a=!1,l=[];r&&l.push(...Object.keys(r).map(Tc)),i&&l.push(...Object.keys(i).map(Tc));var c=0,u=-1;const m=t.length;for(var f=0;f<m;f++){var h=t[f];if(a?h==="/"&&t[f-1]==="*"&&(a=!1):s?s===h&&(s=!1):h==="/"&&t[f+1]==="*"?a=!0:h==='"'||h==="'"?s=h:h==="("?o++:h===")"&&o--,!a&&s===!1&&o===0){if(h===":"&&u===-1)u=f;else if(h===";"||f===m-1){if(u!==-1){var p=Tc(t.substring(c,u).trim());if(!l.includes(p)){h!==";"&&f++;var g=t.substring(c,f).trim();n+=" "+g+";"}}c=f+1,u=-1}}}}return r&&(n+=Vf(r)),i&&(n+=Vf(i,!0)),n=n.trim(),n===""?null:n}return t==null?null:String(t)}function Pe(t,e,n,r,i,s){var o=t[_u];if(o!==n||o===void 0){var a=ly(n,r,s);a==null?t.removeAttribute("class"):t.className=a,t[_u]=n}else if(s&&i!==s)for(var l in s){var c=!!s[l];(i==null||c!==!!i[l])&&t.classList.toggle(l,c)}return s}function xc(t,e={},n,r){for(var i in n){var s=n[i];e[i]!==s&&(n[i]==null?t.style.removeProperty(i):t.style.setProperty(i,s,r))}}function cl(t,e,n,r){var i=t[wu];if(i!==e){var s=cy(e,r);s==null?t.removeAttribute("style"):t.style.cssText=s,t[wu]=e}else r&&(Array.isArray(r)?(xc(t,n==null?void 0:n[0],r[0]),xc(t,n==null?void 0:n[1],r[1],"important")):xc(t,n,r));return r}const uy=Symbol("is custom element"),dy=Symbol("is html");function Ae(t,e,n,r){var i=fy(t);i[e]!==(i[e]=n)&&(e==="loading"&&(t[Z_]=n),n==null?t.removeAttribute(e):typeof n!="string"&&nm(t).includes(e)?t[e]=n:t.setAttribute(e,n))}function T(t,e,n){var r=lt,i=ct;Fn(null),ur(null);try{e!=="style"&&(Nu.has(t.getAttribute("is")||t.nodeName)||!customElements||customElements.get(t.getAttribute("is")||t.nodeName.toLowerCase())?nm(t).includes(e):n&&typeof n=="object")?t[e]=n:Ae(t,e,n==null?n:String(n))}finally{Fn(r),ur(i)}}function fy(t){return t[$a]??(t[$a]={[uy]:t.nodeName.includes("-"),[dy]:t.namespaceURI===cw})}var Nu=new Map;function nm(t){var e=t.getAttribute("is")||t.nodeName,n=Nu.get(e);if(n)return n;Nu.set(e,n=[]);for(var r,i=t,s=Element.prototype;s!==i;){r=fg(i);for(var o in r)r[o].set&&o!=="innerHTML"&&o!=="textContent"&&o!=="innerText"&&n.push(o);i=Fl(i)}return n}function Cc(t,e){return t===e||(t==null?void 0:t[fs])===e}function Br(t={},e,n,r){var i=kt.r,s=ct;return jg(()=>{var o,a;return xd(()=>{o=a,a=(r==null?void 0:r())||[],Cr(()=>{Cc(n(...a),t)||(e(t,...a),o&&Cc(n(...o),t)&&e(null,...o))})}),()=>{let l=s;for(;l!==i&&l.parent!==null&&l.parent.f&bu;)l=l.parent;const c=()=>{a&&Cc(n(...a),t)&&e(null,...a)},u=l.teardown;l.teardown=()=>{c(),u==null||u()}}}),t}function Tn(t,e,n,r){var i=r,s=!0,o=()=>(s&&(s=!1,i=r),i),a;a=t[e],a===void 0&&r!==void 0&&(a=o());var l;return l=()=>{var c=t[e];return c===void 0?o():(s=!0,c)},l}function Gn(t){kt===null&&bd(),la&&kt.l!==null?hy(kt).m.push(t):Qn(()=>{const e=Cr(t);if(typeof e=="function")return e})}function si(t){kt===null&&bd(),Gn(()=>()=>Cr(t))}function hy(t){var e=t.l;return e.u??(e.u={a:[],b:[],m:[]})}const py="5";var cg;typeof window<"u"&&((cg=window.__svelte??(window.__svelte={})).v??(cg.v=new Set)).add(py);const gy="modulepreload",my=function(t){return"/"+t},Zf={},ul=function(e,n,r){let i=Promise.resolve();if(n&&n.length>0){let o=function(c){return Promise.all(c.map(u=>Promise.resolve(u).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=o(n.map(c=>{if(c=my(c),c in Zf)return;Zf[c]=!0;const u=c.endsWith(".css"),f=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${f}`))return;const h=document.createElement("link");if(h.rel=u?"stylesheet":gy,u||(h.as="script"),h.crossOrigin="",h.href=c,l&&h.setAttribute("nonce",l),document.head.appendChild(h),u)return new Promise((p,g)=>{h.addEventListener("load",p),h.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${c}`)))})}))}function s(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&s(a.reason);return e().catch(s)})};function Po(t,e){if(e)for(const n in e)t=t.replace(`:${n}`,String(e[n]));return Rt.name==="#"?t==="/"?"/#/":dl("#",t):Rt.name?dl(Rt.name,t):t}function vy(t,e){let n=Po(t,e==null?void 0:e.params);return e!=null&&e.search&&(n+=Md(e.search)),e!=null&&e.hash&&!e.hash.startsWith("#")&&(n+="#"+e.hash),n}function rm(t){return Promise.all(t.map(e=>by(e)))}function by(t){return new Promise(e=>{_y(t)?Promise.resolve(t()).then(n=>{e(n.default)}):e(t)})}function _y(t){return typeof t=="function"&&!!/\(\)\s?=>\s?(import|__vite_ssr_dynamic_import__)\(.*\)/.test(String(t))}function dl(...t){let e="";for(let n of t)n.startsWith("/")||(e+="/"),n.endsWith("/")&&(n=n.slice(0,-1)),e+=n;return e}function Ad(t){return Rt.name&&t.startsWith(Rt.name)&&(t=t.slice(Rt.name.length)||"/"),t}function Od(){const t=Rt.name==="#"?globalThis.location.hash.slice(1):globalThis.location.pathname,e=Rt.name==="#"?"":globalThis.location.hash;return{pathname:t,search:globalThis.location.search,state:history.state,hash:e}}function Md(t){if(!t)return;if(typeof t=="string")return t.startsWith("?")||(t="?"+t),t;const e=Object.fromEntries(Object.entries(t).map(([r,i])=>[r,String(i)]));return Object.keys(e).length===0?void 0:"?"+new URLSearchParams(e).toString()}function Nd(t){if(!t)return{};if(typeof t=="string"){const e=new URLSearchParams(t);return Object.fromEntries([...e.entries()].map(([n,r])=>[n,wy(r)]))}return t}function wy(t){if(t==="")return"";if(t==="true")return!0;if(t==="false")return!1;const e=Number(t);return Number.isNaN(e)?t:e}function Lu(t,e){return im((n,r)=>n===r,t,e)}Lu.startsWith=(t,e)=>im((n,r)=>n.startsWith(r),t,e);function im(t,e,n){if(!e.includes(":")){const s=Rt.name&&Rt.name!=="#"?Po(e):e;return t(Un.pathname,s)}if(n)return Rt.name==="#"?t(Un.pathname,Po(e,n).replace("/#","")):t(Un.pathname,Po(e,n));const r=e.split("/").slice(1);let i=Un.pathname.split("/").slice(1);if(r.length>i.length)return!1;for(const[s,o]of r.entries()){const a=i[s];if(!o.startsWith(":")&&o!==a)return!1}return!0}function Ld(t,e){t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1));const n=t.split("/").slice(1),r=yy(Object.keys(e));let i,s=[],o=[],a={},l={};const c=e["/"];c&&typeof c=="object"&&"meta"in c&&c.meta&&(l={...l,...c.meta});let u=!1;e:for(const f of r){const h=f.split("/");h[0]===""&&h.shift();for(let[p,g]of h.entries()){u=g.startsWith("(")&&g.endsWith(")"),u&&(g=g.slice(1,-1));const m=n[p],b=g===""&&typeof e["/"]!="function";if(g.startsWith(":"))a[g.slice(1)]=decodeURIComponent(m);else if(g.startsWith("*")){const L=g.slice(1);L&&(a[L]=n.slice(p).map(decodeURIComponent).join("/")),u?s=[]:"layout"in e&&e.layout&&s.push(e.layout);const P=(p?"/":"")+h.join("/");i=e[P];break e}else if(g.toLowerCase()!==(m==null?void 0:m.toLowerCase())&&!b)break;if(p!==h.length-1)continue;const _=e["/"+h.join("/")];if(typeof _=="function"&&h.length!==n.length)continue;if(!u&&"layout"in e&&e.layout&&s.push(e.layout),"hooks"in e&&e.hooks&&o.push(e.hooks),"meta"in e&&e.meta&&(l={...l,...e.meta}),typeof _=="function"){if(h.length===n.length){i=_;break e}continue}const y=b?t:"/"+n.slice(p+1).join("/"),R=Ld(y,_);if(R.match)i=R.match,a={...a,...R.params},o.push(...R.hooks),l={...l,...R.meta},R.breakFromLayouts?(s=[],u=!0):s.push(...R.layouts);else continue;break e}}return{match:i,layouts:s,hooks:o,params:a,meta:l,breakFromLayouts:u}}function yy(t){return t.toSorted((e,n)=>Wf(e)-Wf(n))}function Wf(t){return t===""||t==="/"?1:t.includes("*")?4:t.includes(":")?3:2}const ky=200,Ey=Math.PI/6,Sy=50;async function sm(t,e,n){const{match:r,layouts:i,hooks:s,meta:o}=Ld(e,t);for(const{onPreload:a}of s)a==null||a({pathname:e,meta:o,...n,search:Nd(n==null?void 0:n.search)});await rm(r?[...i,r]:i)}const qf=new Set,ts=new Set;function Ty(t){function e(o){if(!o.getAttribute("href"))return;const l=new URL(o.href),c=Ad(l.pathname),{replace:u,state:f}=o.dataset;sm(t,c,{replace:u===""||u==="true",search:l.search,state:f,hash:l.hash})}let n=null;function r(o){if(!o.getPredictedEvents||n)return;if(n=setTimeout(()=>{n=null},Sy),ts.size===0){document.removeEventListener("pointermove",r);return}const l=o.getPredictedEvents().at(-1);if(!l)return;const c=o.clientX,u=o.clientY,f=l.clientX-c,h=l.clientY-u,p=Math.hypot(f,h);if(p<2)return;const g=f/p,m=h/p;e:for(const b of ts){b.isConnected||ts.delete(b);const _=b.getBoundingClientRect(),y=[{x:_.left,y:_.top},{x:_.right,y:_.top},{x:_.left,y:_.bottom},{x:_.right,y:_.bottom},{x:_.left+_.width/2,y:_.top+_.height/2}];for(const R of y){const L=R.x-c,P=R.y-u,A=Math.hypot(L,P);if(A>ky||A<.001)continue;const O=L/A,D=P/A,z=g*O+m*D;if(Math.acos(Math.max(-1,Math.min(1,z)))<=Ey){e(b),ts.delete(b);continue e}}}}const i=new IntersectionObserver(o=>{for(const a of o)a.isIntersecting&&(i.unobserve(a.target),e(a.target))});new MutationObserver(()=>{const o=document.querySelectorAll("a[data-preload]");for(const a of o)if(!qf.has(a)){switch(qf.add(a),a.dataset.preload){case"":case"true":case"hover":{a.addEventListener("mouseenter",function l(){a.removeEventListener("mouseenter",l),e(a)});break}case"predict":{ts.size===0&&document.addEventListener("pointermove",r),ts.add(a);break}case"viewport":{i.observe(a);break}default:{console.warn(`Unknown preload strategy \`${a.dataset.preload}\` on`,a,`
3
+ Available strategies are: hover, viewport, predict`);break}}a.addEventListener("focus",function l(){a.removeEventListener("focus",l),e(a)})}}).observe(document.body,{subtree:!0,childList:!0})}class Kf extends Error{constructor(e){super(`Navigating to: ${e}`),this.name="Redirect"}}var xy=["forEach","isDisjointFrom","isSubsetOf","isSupersetOf"],Cy=["difference","intersection","symmetricDifference","union"],Yf=!1,Cs,br,hi,Bl,js,om,am;const Ul=class Ul extends Set{constructor(n){super();Ce(this,js);Ce(this,Cs,new Map);Ce(this,br,te(0));Ce(this,hi,te(0));Ce(this,Bl,xr||-1);if(n){for(var r of n)super.add(r);x(this,hi).v=super.size}Yf||Ye(this,js,am).call(this)}has(n){var r=super.has(n),i=x(this,Cs),s=i.get(n);if(s===void 0){if(!r)return d(x(this,br)),!1;s=Ye(this,js,om).call(this,!0),i.set(n,s)}return d(s),r}add(n){return super.has(n)||(super.add(n),k(x(this,hi),super.size),dn(x(this,br))),this}delete(n){var r=super.delete(n),i=x(this,Cs),s=i.get(n);return s!==void 0&&(i.delete(n),k(s,!1)),r&&(k(x(this,hi),super.size),dn(x(this,br))),r}clear(){if(super.size!==0){super.clear();var n=x(this,Cs);for(var r of n.values())k(r,!1);n.clear(),k(x(this,hi),0),dn(x(this,br))}}keys(){return this.values()}values(){return d(x(this,br)),super.values()}entries(){return d(x(this,br)),super.entries()}[Symbol.iterator](){return this.keys()}get size(){return d(x(this,hi))}};Cs=new WeakMap,br=new WeakMap,hi=new WeakMap,Bl=new WeakMap,js=new WeakSet,om=function(n){return xr===x(this,Bl)?te(n):ei(n)},am=function(){Yf=!0;var n=Ul.prototype,r=Set.prototype;for(const i of xy)n[i]=function(...s){return d(x(this,br)),r[i].apply(this,s)};for(const i of Cy)n[i]=function(...s){d(x(this,br));var o=r[i].apply(this,s);return new Ul(o)}};let Gi=Ul;var Nr,Lr,Wr,jl,Sr,po,qa;const Af=class Af extends Map{constructor(n){super();Ce(this,Sr);Ce(this,Nr,new Map);Ce(this,Lr,te(0));Ce(this,Wr,te(0));Ce(this,jl,xr||-1);if(n){for(var[r,i]of n)super.set(r,i);x(this,Wr).v=super.size}}has(n){var r=x(this,Nr),i=r.get(n);if(i===void 0)if(super.has(n))i=Ye(this,Sr,po).call(this,0),r.set(n,i);else return d(x(this,Lr)),!1;return d(i),!0}forEach(n,r){Ye(this,Sr,qa).call(this),super.forEach(n,r)}get(n){var r=x(this,Nr),i=r.get(n);if(i===void 0)if(super.has(n))i=Ye(this,Sr,po).call(this,0),r.set(n,i);else{d(x(this,Lr));return}return d(i),super.get(n)}set(n,r){var f;var i=x(this,Nr),s=i.get(n),o=super.get(n),a=super.set(n,r),l=x(this,Lr);if(s===void 0)s=Ye(this,Sr,po).call(this,0),i.set(n,s),k(x(this,Wr),super.size),dn(l);else if(o!==r){dn(s);var c=l.reactions===null?null:new Set(l.reactions),u=c===null||!((f=s.reactions)!=null&&f.every(h=>c.has(h)));u&&dn(l)}return a}delete(n){var r=x(this,Nr),i=r.get(n),s=super.delete(n);return i!==void 0&&(r.delete(n),k(i,-1)),s&&(k(x(this,Wr),super.size),dn(x(this,Lr))),s}clear(){if(super.size!==0){super.clear();var n=x(this,Nr);k(x(this,Wr),0);for(var r of n.values())k(r,-1);dn(x(this,Lr)),n.clear()}}keys(){return d(x(this,Lr)),super.keys()}values(){return Ye(this,Sr,qa).call(this),super.values()}entries(){return Ye(this,Sr,qa).call(this),super.entries()}[Symbol.iterator](){return this.entries()}get size(){return d(x(this,Wr)),super.size}};Nr=new WeakMap,Lr=new WeakMap,Wr=new WeakMap,jl=new WeakMap,Sr=new WeakSet,po=function(n){return xr===x(this,jl)?te(n):ei(n)},qa=function(){d(x(this,Lr));var n=x(this,Nr);if(x(this,Wr).v!==n.size){for(var r of Mf(Af.prototype,this,"keys").call(this))if(!n.has(r)){var i=Ye(this,Sr,po).call(this,0);n.set(r,i)}}for([,i]of x(this,Nr))d(i)};let Ti=Af;const Py=Symbol("replace");var pn,Jo,qr,ji,go;class Ry extends URLSearchParams{constructor(){super(...arguments);Ce(this,ji);Ce(this,pn,te(0));Ce(this,Jo,Oy());Ce(this,qr,!1)}[Py](n){if(!x(this,qr)&&n.toString()!==super.toString()){Ke(this,qr,!0);for(const r of[...super.keys()])super.delete(r);for(const[r,i]of n)super.append(r,i);dn(x(this,pn)),Ke(this,qr,!1)}}append(n,r){super.append(n,r),Ye(this,ji,go).call(this),dn(x(this,pn))}delete(n,r){var i=super.has(n,r);super.delete(n,r),i&&(Ye(this,ji,go).call(this),dn(x(this,pn)))}get(n){return d(x(this,pn)),super.get(n)}getAll(n){return d(x(this,pn)),super.getAll(n)}has(n,r){return d(x(this,pn)),super.has(n,r)}keys(){return d(x(this,pn)),super.keys()}forEach(n,r){d(x(this,pn)),super.forEach(n,r)}set(n,r){var i=super.getAll(n);super.set(n,r);var s=super.getAll(n);(i.length!==s.length||i.some((o,a)=>o!==s[a]))&&(Ye(this,ji,go).call(this),dn(x(this,pn)))}sort(){super.sort(),Ye(this,ji,go).call(this),dn(x(this,pn))}toString(){return d(x(this,pn)),super.toString()}values(){return d(x(this,pn)),super.values()}entries(){return d(x(this,pn)),super.entries()}[Symbol.iterator](){return this.entries()}get size(){return d(x(this,pn)),super.size}}pn=new WeakMap,Jo=new WeakMap,qr=new WeakMap,ji=new WeakSet,go=function(){if(!x(this,Jo)||x(this,qr))return;Ke(this,qr,!0);const n=this.toString();x(this,Jo).search=n&&`?${n}`,Ke(this,qr,!1)};let Ay=null;function Oy(){return Ay}let Sa=new Ry(globalThis.location.search);function Xf(t){if(Sa.toString()===t)return;const e=new URLSearchParams(t);for(const[n,r]of e)Sa.set(n,r);for(const n of Sa.keys())e.has(n)||Sa.delete(n)}let Ro;const Rt={name:void 0};let Iu=pt({value:[]}),Un=pt({pathname:"/",search:"",state:null,hash:""});queueMicrotask(()=>{const t=Od();Un.pathname=t.pathname,Un.search=t.search,Un.state=t.state,Un.hash=t.hash});let zu=pt({value:{}}),lm=pt({value:{}}),Mi=null,Ta=null,Ka=null;function My(t){if(t){const e=new URL(globalThis.location.toString());t==="#"?(Rt.name="#",globalThis.location.href.includes("#")||(e.hash="/",history.replaceState(history.state||{},"",e.toString()))):(Rt.name=(t.startsWith("/")?"":"/")+t,e.pathname.startsWith(Rt.name)||(e.pathname=dl(Rt.name,e.pathname),history.replaceState(history.state||{},"",e.toString())))}Object.assign(Un,Od())}function Ny(t){return Ro=t,Ty(Ro),{p:vy,navigate:Ly,isActive:Lu,async preload(e){await sm(Ro,e)},route:{get params(){return zu.value},getParams(e){if(!Lu(e))throw new Error(`\`${e}\` does not match the current route`);return zu.value},get pathname(){return Ad(Un.pathname)},get search(){return Nd(Un.search)},get state(){return Un.state},get hash(){return Un.hash},get meta(){return lm.value}}}}async function Ly(t,e={}){if(typeof t=="number")return globalThis.history.go(t),new Kf(`History entry: ${t}`);t=Po(t,e.params),Rt.name==="#"?t=t.replace("/#",""):e.hash&&!e.hash.startsWith("#")&&(e.hash="#"+e.hash);const n=fl(t,e);return Ka=n,await n,new Kf(`${t}${Md((e==null?void 0:e.search)??"")}${(e==null?void 0:e.hash)??""}`)}async function fl(t,e={}){if(!Ro)throw new Error("Router not initialized: `createRouter` was not called.");if(Ta&&Ta!==Mi)return;Mi==null||Mi.abort(),Mi=new AbortController;const{signal:n}=Mi,r=Iy(t),{match:i,layouts:s,hooks:o,meta:a,params:l}=Ld(r,Ro),c=Nd(e.search),u={pathname:r,meta:a,...e,search:c};let f=[];for(const p of o){if(n.aborted)return Ka;try{const{beforeLoad:g}=p;f.push(p),Ta=Mi,await(g==null?void 0:g(u))}catch(g){if(n.aborted)return Ka;for(const{onError:m}of f)m==null||m(g,u);return}finally{Ta=null}}let h;try{h=await rm(i?[...s,i]:s)}catch(p){for(const{onError:g}of o)g==null||g(p,u);throw p}if(n.aborted)return Ka;if(t){const p=Md(e.search),g=new URL(globalThis.location.toString());g.search=p||"",g.hash=e.hash||"",Rt.name==="#"?g.hash=t:Rt.name&&!t.startsWith(Rt.name)?g.pathname=dl(Rt.name,t):g.pathname=t;const m=e.replace?"replaceState":"pushState";globalThis.history[m](e.state||{},"",g.toString()),Xf(p)}else Xf(globalThis.location.search);e.viewTransition&&document.startViewTransition!==void 0?document.startViewTransition(()=>{Iu.value=h}):Iu.value=h,zu.value=l,lm.value=a,Object.assign(Un,Od()),e.scrollToTop!==!1&&window.scrollTo({top:0,left:0,behavior:e.scrollToTop});for(const{afterLoad:p}of o)p==null||p(u)}function Iy(t){let e;return t?e=t:Rt.name==="#"?e=globalThis.location.hash.slice(1):e=globalThis.location.pathname,Rt.name&&e.startsWith(Rt.name)&&(e=e.slice(Rt.name.length)||"/"),Ad(e)}function zy(t){var f;const e=t.target.closest("a");if(!e||e.hasAttribute("target")||e.hasAttribute("download")||!e.hasAttribute("href")||(f=e.getAttribute("href"))!=null&&f.startsWith("#"))return;const n=new URL(e.href),r=globalThis.location.origin;if(n.origin!==r)return;const i=Rt.name==="#"?n.hash:n.pathname,s=Rt.name==="#"?void 0:n.hash;t.preventDefault();const{replace:o,state:a,scrollToTop:l,viewTransition:c}=e.dataset;let u;if(a)try{u=JSON.parse(a)}catch{u=a}fl(i,{replace:o===""||o==="true",search:n.search,state:u,hash:s,scrollToTop:l==="false"?!1:l,viewTransition:c===""||c==="true"})}function cm(t,e){Ze(e,!0);const n=G(()=>e.tree[0]),r=G(()=>e.tree.slice(1));var i=_n(),s=tt(i);ay(s,()=>d(n),(o,a)=>{a(o,{children:(l,c)=>{var u=_n(),f=tt(u);{var h=p=>{cm(p,{get tree(){return d(r)}})};W(f,p=>{d(r).length>0&&p(h)})}C(l,u)},$$slots:{default:!0}})}),C(t,i),We()}function Dy(t,e){Ze(e,!0),My(e.base),fl(),Qn(()=>{const n=jf(globalThis,"popstate",()=>fl()),r=jf(globalThis,"click",zy);return()=>{n(),r()}}),cm(t,{get tree(){return Iu.value}}),We()}const Hy=720;function fa(){return window.matchMedia("(max-width: "+Hy+"px)")}const Id="mndw",Ms=`${Id}:plugin`,um=["en","ru"],dm=5e3,By=300,Uy=1e4,jy=6e4,$y=24e4,Jf=15e3,fm=10*1024*1024,zd=Object.freeze({theme:"dark",locale:"en"}),Dd=Object.freeze({deviceName:"Unknown",vendor:"Unknown",manufacturer:"Unknown",model:"Unknown",series:"Unknown",region:"Unknown",hwId:"Unknown",hwVersion:"Unknown",firmwareVersion:"Unknown",firmwareRelease:"Unknown",features:Object.freeze([]),components:Object.freeze([]),switchports:Object.freeze({list:Object.freeze([]),layout:Object.freeze([]),hasPortStats:!1}),usb:Object.freeze({ports:Object.freeze([])})}),hm="/api/mgmt/list",Fy="/api/mgmt/capability",Gy="/api/mgmt/upload",Qf="/api/mgmt/approve",Vy="/api/mgmt/deny",Zy="/api/mgmt/enable",Wy="/api/mgmt/disable",qy="/api/mgmt/delete",Ky="/api/mgmt/restart",Yy="/api/mgmt/runtime",Pc="/api/mgmt/palette",Xy="/api/mgmt/device-hardware",eh="/api/mgmt/telemetry",Jy="/api/mgmt/opkg/list",Qy="/api/mgmt/opkg/install",e0="/api/mgmt/opkg/remove",t0="/api/mgmt/opkg/update",n0="/api/mgmt/opkg/upgrade",r0="/api/mgmt/opkg/info",i0="/api/mgmt/self-update/status",s0="/api/mgmt/self-update/check",o0="/api/mgmt/self-update/apply",a0="/api/mgmt/self-update/revert",l0="/api/mgmt/service/list",c0="/api/mgmt/service/status",u0="/api/mgmt/service/start",d0="/api/mgmt/service/stop",f0="/api/mgmt/service/restart",h0="/api/mgmt/service/set-enabled",th={builtin:"/plugins/",user:"/user-plugins/"};function nh(t){return t.split(",").map(e=>e.trim()).filter(e=>e!=="")}var rh;function Z(t,e,n){function r(a,l){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:l,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(t))return;a._zod.traits.add(t),e(a,l);const c=o.prototype,u=Object.keys(c);for(let f=0;f<u.length;f++){const h=u[f];h in a||(a[h]=c[h].bind(a))}}const i=(n==null?void 0:n.Parent)??Object;class s extends i{}Object.defineProperty(s,"name",{value:t});function o(a){var l;const c=n!=null&&n.Parent?new s:this;r(c,a),(l=c._zod).deferred??(l.deferred=[]);for(const u of c._zod.deferred)u();return c}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var l,c;return n!=null&&n.Parent&&a instanceof n.Parent?!0:(c=(l=a==null?void 0:a._zod)==null?void 0:l.traits)==null?void 0:c.has(t)}}),Object.defineProperty(o,"name",{value:t}),o}class hs extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class pm extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(rh=globalThis).__zod_globalConfig??(rh.__zod_globalConfig={});const Hd=globalThis.__zod_globalConfig;function ti(t){return Hd}function gm(t){const e=Object.values(t).filter(r=>typeof r=="number");return Object.entries(t).filter(([r,i])=>e.indexOf(+r)===-1).map(([r,i])=>i)}function Du(t,e){return typeof e=="bigint"?e.toString():e}function Wl(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function Bd(t){return t==null}function Ud(t){const e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function p0(t,e){const n=t/e,r=Math.round(n),i=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}const ih=Symbol("evaluating");function St(t,e,n){let r;Object.defineProperty(t,e,{get(){if(r!==ih)return r===void 0&&(r=ih,r=n()),r},set(i){Object.defineProperty(t,e,{value:i})},configurable:!0})}function Yi(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ri(...t){const e={};for(const n of t){const r=Object.getOwnPropertyDescriptors(n);Object.assign(e,r)}return Object.defineProperties({},e)}function sh(t){return JSON.stringify(t)}function g0(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const mm="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function Io(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const m0=Wl(()=>{var t;if(Hd.jitless||typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)!=null&&t.includes("Cloudflare")))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Ns(t){if(Io(t)===!1)return!1;const e=t.constructor;if(e===void 0||typeof e!="function")return!0;const n=e.prototype;return!(Io(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function vm(t){return Ns(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}const v0=new Set(["string","number","symbol"]);function Ls(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ai(t,e,n){const r=new t._zod.constr(e??t._zod.def);return(!e||n!=null&&n.parent)&&(r._zod.parent=t),r}function Oe(t){const e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if((e==null?void 0:e.message)!==void 0){if((e==null?void 0:e.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function b0(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const _0={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function w0(t,e){const n=t._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=Ri(t._zod.def,{get shape(){const o={};for(const a in e){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(o[a]=n.shape[a])}return Yi(this,"shape",o),o},checks:[]});return Ai(t,s)}function y0(t,e){const n=t._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=Ri(t._zod.def,{get shape(){const o={...t._zod.def.shape};for(const a in e){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete o[a]}return Yi(this,"shape",o),o},checks:[]});return Ai(t,s)}function k0(t,e){if(!Ns(e))throw new Error("Invalid input to extend: expected a plain object");const n=t._zod.def.checks;if(n&&n.length>0){const s=t._zod.def.shape;for(const o in e)if(Object.getOwnPropertyDescriptor(s,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=Ri(t._zod.def,{get shape(){const s={...t._zod.def.shape,...e};return Yi(this,"shape",s),s}});return Ai(t,i)}function E0(t,e){if(!Ns(e))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Ri(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e};return Yi(this,"shape",r),r}});return Ai(t,n)}function S0(t,e){var r;if((r=t._zod.def.checks)!=null&&r.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=Ri(t._zod.def,{get shape(){const i={...t._zod.def.shape,...e._zod.def.shape};return Yi(this,"shape",i),i},get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return Ai(t,n)}function T0(t,e,n){const i=e._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=Ri(e._zod.def,{get shape(){const a=e._zod.def.shape,l={...a};if(n)for(const c in n){if(!(c in a))throw new Error(`Unrecognized key: "${c}"`);n[c]&&(l[c]=t?new t({type:"optional",innerType:a[c]}):a[c])}else for(const c in a)l[c]=t?new t({type:"optional",innerType:a[c]}):a[c];return Yi(this,"shape",l),l},checks:[]});return Ai(e,o)}function x0(t,e,n){const r=Ri(e._zod.def,{get shape(){const i=e._zod.def.shape,s={...i};if(n)for(const o in n){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(s[o]=new t({type:"nonoptional",innerType:i[o]}))}else for(const o in i)s[o]=new t({type:"nonoptional",innerType:i[o]});return Yi(this,"shape",s),s}});return Ai(e,r)}function ls(t,e=0){var n;if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(((n=t.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function C0(t,e=0){var n;if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(((n=t.issues[r])==null?void 0:n.continue)===!1)return!0;return!1}function cs(t,e){return e.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(t),n})}function xa(t){return typeof t=="string"?t:t==null?void 0:t.message}function ni(t,e,n){var l,c,u,f,h,p;const r=t.message?t.message:xa((u=(c=(l=t.inst)==null?void 0:l._zod.def)==null?void 0:c.error)==null?void 0:u.call(c,t))??xa((f=e==null?void 0:e.error)==null?void 0:f.call(e,t))??xa((h=n.customError)==null?void 0:h.call(n,t))??xa((p=n.localeError)==null?void 0:p.call(n,t))??"Invalid input",{inst:i,continue:s,input:o,...a}=t;return a.path??(a.path=[]),a.message=r,e!=null&&e.reportInput&&(a.input=o),a}function jd(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function zo(...t){const[e,n,r]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:r}:{...e}}const bm=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,Du,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},_m=Z("$ZodError",bm),wm=Z("$ZodError",bm,{Parent:Error});function P0(t,e=n=>n.message){const n={},r=[];for(const i of t.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(e(i))):r.push(e(i));return{formErrors:r,fieldErrors:n}}function R0(t,e=n=>n.message){const n={_errors:[]},r=(i,s=[])=>{for(const o of i.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(a=>r({issues:a},[...s,...o.path]));else if(o.code==="invalid_key")r({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")r({issues:o.issues},[...s,...o.path]);else{const a=[...s,...o.path];if(a.length===0)n._errors.push(e(o));else{let l=n,c=0;for(;c<a.length;){const u=a[c];c===a.length-1?(l[u]=l[u]||{_errors:[]},l[u]._errors.push(e(o))):l[u]=l[u]||{_errors:[]},l=l[u],c++}}}};return r(t),n}const $d=t=>(e,n,r,i)=>{const s=r?{...r,async:!1}:{async:!1},o=e._zod.run({value:n,issues:[]},s);if(o instanceof Promise)throw new hs;if(o.issues.length){const a=new((i==null?void 0:i.Err)??t)(o.issues.map(l=>ni(l,s,ti())));throw mm(a,i==null?void 0:i.callee),a}return o.value},Fd=t=>async(e,n,r,i)=>{const s=r?{...r,async:!0}:{async:!0};let o=e._zod.run({value:n,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((i==null?void 0:i.Err)??t)(o.issues.map(l=>ni(l,s,ti())));throw mm(a,i==null?void 0:i.callee),a}return o.value},ql=t=>(e,n,r)=>{const i=r?{...r,async:!1}:{async:!1},s=e._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new hs;return s.issues.length?{success:!1,error:new(t??_m)(s.issues.map(o=>ni(o,i,ti())))}:{success:!0,data:s.value}},A0=ql(wm),Kl=t=>async(e,n,r)=>{const i=r?{...r,async:!0}:{async:!0};let s=e._zod.run({value:n,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new t(s.issues.map(o=>ni(o,i,ti())))}:{success:!0,data:s.value}},O0=Kl(wm),M0=t=>(e,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return $d(t)(e,n,i)},N0=t=>(e,n,r)=>$d(t)(e,n,r),L0=t=>async(e,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return Fd(t)(e,n,i)},I0=t=>async(e,n,r)=>Fd(t)(e,n,r),z0=t=>(e,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return ql(t)(e,n,i)},D0=t=>(e,n,r)=>ql(t)(e,n,r),H0=t=>async(e,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return Kl(t)(e,n,i)},B0=t=>async(e,n,r)=>Kl(t)(e,n,r),U0=/^[cC][0-9a-z]{6,}$/,j0=/^[0-9a-z]+$/,$0=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,F0=/^[0-9a-vA-V]{20}$/,G0=/^[A-Za-z0-9]{27}$/,V0=/^[a-zA-Z0-9_-]{21}$/,Z0=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,W0=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,oh=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,q0=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,K0="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Y0(){return new RegExp(K0,"u")}const X0=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,J0=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Q0=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,e1=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,t1=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ym=/^[A-Za-z0-9_-]*$/,n1=/^https?$/,r1=/^\+[1-9]\d{6,14}$/,km="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",i1=new RegExp(`^${km}$`);function Em(t){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function s1(t){return new RegExp(`^${Em(t)}$`)}function o1(t){const e=Em({precision:t.precision}),n=["Z"];t.local&&n.push(""),t.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${e}(?:${n.join("|")})`;return new RegExp(`^${km}T(?:${r})$`)}const a1=t=>{const e=t?`[\\s\\S]{${(t==null?void 0:t.minimum)??0},${(t==null?void 0:t.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},l1=/^-?\d+$/,Sm=/^-?\d+(?:\.\d+)?$/,c1=/^(?:true|false)$/i,u1=/^[^A-Z]*$/,d1=/^[^a-z]*$/,Vn=Z("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[])}),Tm={number:"number",bigint:"bigint",object:"date"},xm=Z("$ZodCheckLessThan",(t,e)=>{Vn.init(t,e);const n=Tm[typeof e.value];t._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?i.maximum=e.value:i.exclusiveMaximum=e.value)}),t._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Cm=Z("$ZodCheckGreaterThan",(t,e)=>{Vn.init(t,e);const n=Tm[typeof e.value];t._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?i.minimum=e.value:i.exclusiveMinimum=e.value)}),t._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:r.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),f1=Z("$ZodCheckMultipleOf",(t,e)=>{Vn.init(t,e),t._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=e.value)}),t._zod.check=n=>{if(typeof n.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%e.value===BigInt(0):p0(n.value,e.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:e.value,input:n.value,inst:t,continue:!e.abort})}}),h1=Z("$ZodCheckNumberFormat",(t,e)=>{var o;Vn.init(t,e),e.format=e.format||"float64";const n=(o=e.format)==null?void 0:o.includes("int"),r=n?"int":"number",[i,s]=_0[e.format];t._zod.onattach.push(a=>{const l=a._zod.bag;l.format=e.format,l.minimum=i,l.maximum=s,n&&(l.pattern=l1)}),t._zod.check=a=>{const l=a.value;if(n){if(!Number.isInteger(l)){a.issues.push({expected:r,format:e.format,code:"invalid_type",continue:!1,input:l,inst:t});return}if(!Number.isSafeInteger(l)){l>0?a.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:r,inclusive:!0,continue:!e.abort}):a.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:r,inclusive:!0,continue:!e.abort});return}}l<i&&a.issues.push({origin:"number",input:l,code:"too_small",minimum:i,inclusive:!0,inst:t,continue:!e.abort}),l>s&&a.issues.push({origin:"number",input:l,code:"too_big",maximum:s,inclusive:!0,inst:t,continue:!e.abort})}}),p1=Z("$ZodCheckMaxLength",(t,e)=>{var n;Vn.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!Bd(i)&&i.length!==void 0}),t._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<i&&(r._zod.bag.maximum=e.maximum)}),t._zod.check=r=>{const i=r.value;if(i.length<=e.maximum)return;const o=jd(i);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:i,inst:t,continue:!e.abort})}}),g1=Z("$ZodCheckMinLength",(t,e)=>{var n;Vn.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!Bd(i)&&i.length!==void 0}),t._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>i&&(r._zod.bag.minimum=e.minimum)}),t._zod.check=r=>{const i=r.value;if(i.length>=e.minimum)return;const o=jd(i);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:t,continue:!e.abort})}}),m1=Z("$ZodCheckLengthEquals",(t,e)=>{var n;Vn.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!Bd(i)&&i.length!==void 0}),t._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=e.length,i.maximum=e.length,i.length=e.length}),t._zod.check=r=>{const i=r.value,s=i.length;if(s===e.length)return;const o=jd(i),a=s>e.length;r.issues.push({origin:o,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:r.value,inst:t,continue:!e.abort})}}),Yl=Z("$ZodCheckStringFormat",(t,e)=>{var n,r;Vn.init(t,e),t._zod.onattach.push(i=>{const s=i._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(n=t._zod).check??(n.check=i=>{e.pattern.lastIndex=0,!e.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:e.format,input:i.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(r=t._zod).check??(r.check=()=>{})}),v1=Z("$ZodCheckRegex",(t,e)=>{Yl.init(t,e),t._zod.check=n=>{e.pattern.lastIndex=0,!e.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),b1=Z("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=u1),Yl.init(t,e)}),_1=Z("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=d1),Yl.init(t,e)}),w1=Z("$ZodCheckIncludes",(t,e)=>{Vn.init(t,e);const n=Ls(e.includes),r=new RegExp(typeof e.position=="number"?`^.{${e.position}}${n}`:n);e.pattern=r,t._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=i=>{i.value.includes(e.includes,e.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:i.value,inst:t,continue:!e.abort})}}),y1=Z("$ZodCheckStartsWith",(t,e)=>{Vn.init(t,e);const n=new RegExp(`^${Ls(e.prefix)}.*`);e.pattern??(e.pattern=n),t._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),t._zod.check=r=>{r.value.startsWith(e.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:r.value,inst:t,continue:!e.abort})}}),k1=Z("$ZodCheckEndsWith",(t,e)=>{Vn.init(t,e);const n=new RegExp(`.*${Ls(e.suffix)}$`);e.pattern??(e.pattern=n),t._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),t._zod.check=r=>{r.value.endsWith(e.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:r.value,inst:t,continue:!e.abort})}}),E1=Z("$ZodCheckOverwrite",(t,e)=>{Vn.init(t,e),t._zod.check=n=>{n.value=e.tx(n.value)}});class S1{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const r=e.split(`
4
+ `).filter(o=>o),i=Math.min(...r.map(o=>o.length-o.trimStart().length)),s=r.map(o=>o.slice(i)).map(o=>" ".repeat(this.indent*2)+o);for(const o of s)this.content.push(o)}compile(){const e=Function,n=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new e(...n,i.join(`
5
+ `))}}const T1={major:4,minor:4,patch:3},Bt=Z("$ZodType",(t,e)=>{var i;var n;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=T1;const r=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&r.unshift(t);for(const s of r)for(const o of s._zod.onattach)o(t);if(r.length===0)(n=t._zod).deferred??(n.deferred=[]),(i=t._zod.deferred)==null||i.push(()=>{t._zod.run=t._zod.parse});else{const s=(a,l,c)=>{let u=ls(a),f;for(const h of l){if(h._zod.def.when){if(C0(a)||!h._zod.def.when(a))continue}else if(u)continue;const p=a.issues.length,g=h._zod.check(a);if(g instanceof Promise&&(c==null?void 0:c.async)===!1)throw new hs;if(f||g instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await g,a.issues.length!==p&&(u||(u=ls(a,p)))});else{if(a.issues.length===p)continue;u||(u=ls(a,p))}}return f?f.then(()=>a):a},o=(a,l,c)=>{if(ls(a))return a.aborted=!0,a;const u=s(l,r,c);if(u instanceof Promise){if(c.async===!1)throw new hs;return u.then(f=>t._zod.parse(f,c))}return t._zod.parse(u,c)};t._zod.run=(a,l)=>{if(l.skipChecks)return t._zod.parse(a,l);if(l.direction==="backward"){const u=t._zod.parse({value:a.value,issues:[]},{...l,skipChecks:!0});return u instanceof Promise?u.then(f=>o(f,a,l)):o(u,a,l)}const c=t._zod.parse(a,l);if(c instanceof Promise){if(l.async===!1)throw new hs;return c.then(u=>s(u,r,l))}return s(c,r,l)}}St(t,"~standard",()=>({validate:s=>{var o;try{const a=A0(t,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return O0(t,s).then(l=>{var c;return l.success?{value:l.data}:{issues:(c=l.error)==null?void 0:c.issues}})}},vendor:"zod",version:1}))}),Gd=Z("$ZodString",(t,e)=>{var n;Bt.init(t,e),t._zod.pattern=[...((n=t==null?void 0:t._zod.bag)==null?void 0:n.patterns)??[]].pop()??a1(t._zod.bag),t._zod.parse=(r,i)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:t}),r}}),zt=Z("$ZodStringFormat",(t,e)=>{Yl.init(t,e),Gd.init(t,e)}),x1=Z("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=W0),zt.init(t,e)}),C1=Z("$ZodUUID",(t,e)=>{if(e.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(r===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=oh(r))}else e.pattern??(e.pattern=oh());zt.init(t,e)}),P1=Z("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=q0),zt.init(t,e)}),R1=Z("$ZodURL",(t,e)=>{zt.init(t,e),t._zod.check=n=>{var r;try{const i=n.value.trim();if(!e.normalize&&((r=e.protocol)==null?void 0:r.source)===n1.source&&!/^https?:\/\//i.test(i)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:t,continue:!e.abort});return}const s=new URL(i);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(s.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:n.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:n.value,inst:t,continue:!e.abort})),e.normalize?n.value=s.href:n.value=i;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:t,continue:!e.abort})}}}),A1=Z("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=Y0()),zt.init(t,e)}),O1=Z("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=V0),zt.init(t,e)}),M1=Z("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=U0),zt.init(t,e)}),N1=Z("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=j0),zt.init(t,e)}),L1=Z("$ZodULID",(t,e)=>{e.pattern??(e.pattern=$0),zt.init(t,e)}),I1=Z("$ZodXID",(t,e)=>{e.pattern??(e.pattern=F0),zt.init(t,e)}),z1=Z("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=G0),zt.init(t,e)}),D1=Z("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=o1(e)),zt.init(t,e)}),H1=Z("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=i1),zt.init(t,e)}),B1=Z("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=s1(e)),zt.init(t,e)}),U1=Z("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=Z0),zt.init(t,e)}),j1=Z("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=X0),zt.init(t,e),t._zod.bag.format="ipv4"}),$1=Z("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=J0),zt.init(t,e),t._zod.bag.format="ipv6",t._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:t,continue:!e.abort})}}}),F1=Z("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=Q0),zt.init(t,e)}),G1=Z("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=e1),zt.init(t,e),t._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[i,s]=r;if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${i}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:t,continue:!e.abort})}}});function Pm(t){if(t==="")return!0;if(/\s/.test(t)||t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const V1=Z("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=t1),zt.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=n=>{Pm(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:t,continue:!e.abort})}});function Z1(t){if(!ym.test(t))return!1;const e=t.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=e.padEnd(Math.ceil(e.length/4)*4,"=");return Pm(n)}const W1=Z("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=ym),zt.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=n=>{Z1(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:t,continue:!e.abort})}}),q1=Z("$ZodE164",(t,e)=>{e.pattern??(e.pattern=r1),zt.init(t,e)});function K1(t,e=null){try{const n=t.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||e&&(!("alg"in i)||i.alg!==e))}catch{return!1}}const Y1=Z("$ZodJWT",(t,e)=>{zt.init(t,e),t._zod.check=n=>{K1(n.value,e.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:t,continue:!e.abort})}}),Rm=Z("$ZodNumber",(t,e)=>{Bt.init(t,e),t._zod.pattern=t._zod.bag.pattern??Sm,t._zod.parse=(n,r)=>{if(e.coerce)try{n.value=Number(n.value)}catch{}const i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;const s=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:t,...s?{received:s}:{}}),n}}),X1=Z("$ZodNumberFormat",(t,e)=>{h1.init(t,e),Rm.init(t,e)}),J1=Z("$ZodBoolean",(t,e)=>{Bt.init(t,e),t._zod.pattern=c1,t._zod.parse=(n,r)=>{if(e.coerce)try{n.value=!!n.value}catch{}const i=n.value;return typeof i=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:t}),n}}),Q1=Z("$ZodUnknown",(t,e)=>{Bt.init(t,e),t._zod.parse=n=>n}),ek=Z("$ZodNever",(t,e)=>{Bt.init(t,e),t._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:t}),n)});function ah(t,e,n){t.issues.length&&e.issues.push(...cs(n,t.issues)),e.value[n]=t.value}const tk=Z("$ZodArray",(t,e)=>{Bt.init(t,e),t._zod.parse=(n,r)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:t}),n;n.value=Array(i.length);const s=[];for(let o=0;o<i.length;o++){const a=i[o],l=e.element._zod.run({value:a,issues:[]},r);l instanceof Promise?s.push(l.then(c=>ah(c,n,o))):ah(l,n,o)}return s.length?Promise.all(s).then(()=>n):n}});function hl(t,e,n,r,i,s){const o=n in r;if(t.issues.length){if(i&&s&&!o)return;e.issues.push(...cs(n,t.issues))}if(!o&&!i){t.issues.length||e.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}t.value===void 0?o&&(e.value[n]=void 0):e.value[n]=t.value}function Am(t){var r,i,s,o;const e=Object.keys(t.shape);for(const a of e)if(!((o=(s=(i=(r=t.shape)==null?void 0:r[a])==null?void 0:i._zod)==null?void 0:s.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=b0(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}}function Om(t,e,n,r,i,s){const o=[],a=i.keySet,l=i.catchall._zod,c=l.def.type,u=l.optin==="optional",f=l.optout==="optional";for(const h in e){if(h==="__proto__"||a.has(h))continue;if(c==="never"){o.push(h);continue}const p=l.run({value:e[h],issues:[]},r);p instanceof Promise?t.push(p.then(g=>hl(g,n,h,e,u,f))):hl(p,n,h,e,u,f)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:s}),t.length?Promise.all(t).then(()=>n):n}const nk=Z("$ZodObject",(t,e)=>{Bt.init(t,e);const n=Object.getOwnPropertyDescriptor(e,"shape");if(!(n!=null&&n.get)){const a=e.shape;Object.defineProperty(e,"shape",{get:()=>{const l={...a};return Object.defineProperty(e,"shape",{value:l}),l}})}const r=Wl(()=>Am(e));St(t._zod,"propValues",()=>{const a=e.shape,l={};for(const c in a){const u=a[c]._zod;if(u.values){l[c]??(l[c]=new Set);for(const f of u.values)l[c].add(f)}}return l});const i=Io,s=e.catchall;let o;t._zod.parse=(a,l)=>{o??(o=r.value);const c=a.value;if(!i(c))return a.issues.push({expected:"object",code:"invalid_type",input:c,inst:t}),a;a.value={};const u=[],f=o.shape;for(const h of o.keys){const p=f[h],g=p._zod.optin==="optional",m=p._zod.optout==="optional",b=p._zod.run({value:c[h],issues:[]},l);b instanceof Promise?u.push(b.then(_=>hl(_,a,h,c,g,m))):hl(b,a,h,c,g,m)}return s?Om(u,c,a,l,r.value,t):u.length?Promise.all(u).then(()=>a):a}}),rk=Z("$ZodObjectJIT",(t,e)=>{nk.init(t,e);const n=t._zod.parse,r=Wl(()=>Am(e)),i=h=>{var R,L;const p=new S1(["shape","payload","ctx"]),g=r.value,m=P=>{const A=sh(P);return`shape[${A}]._zod.run({ value: input[${A}], issues: [] }, ctx)`};p.write("const input = payload.value;");const b=Object.create(null);let _=0;for(const P of g.keys)b[P]=`key_${_++}`;p.write("const newResult = {};");for(const P of g.keys){const A=b[P],O=sh(P),D=h[P],z=((R=D==null?void 0:D._zod)==null?void 0:R.optin)==="optional",B=((L=D==null?void 0:D._zod)==null?void 0:L.optout)==="optional";p.write(`const ${A} = ${m(P)};`),z&&B?p.write(`
6
+ if (${A}.issues.length) {
7
+ if (${O} in input) {
8
+ payload.issues = payload.issues.concat(${A}.issues.map(iss => ({
9
+ ...iss,
10
+ path: iss.path ? [${O}, ...iss.path] : [${O}]
11
+ })));
12
+ }
13
+ }
14
+
15
+ if (${A}.value === undefined) {
16
+ if (${O} in input) {
17
+ newResult[${O}] = undefined;
18
+ }
19
+ } else {
20
+ newResult[${O}] = ${A}.value;
21
+ }
22
+
23
+ `):z?p.write(`
24
+ if (${A}.issues.length) {
25
+ payload.issues = payload.issues.concat(${A}.issues.map(iss => ({
26
+ ...iss,
27
+ path: iss.path ? [${O}, ...iss.path] : [${O}]
28
+ })));
29
+ }
30
+
31
+ if (${A}.value === undefined) {
32
+ if (${O} in input) {
33
+ newResult[${O}] = undefined;
34
+ }
35
+ } else {
36
+ newResult[${O}] = ${A}.value;
37
+ }
38
+
39
+ `):p.write(`
40
+ const ${A}_present = ${O} in input;
41
+ if (${A}.issues.length) {
42
+ payload.issues = payload.issues.concat(${A}.issues.map(iss => ({
43
+ ...iss,
44
+ path: iss.path ? [${O}, ...iss.path] : [${O}]
45
+ })));
46
+ }
47
+ if (!${A}_present && !${A}.issues.length) {
48
+ payload.issues.push({
49
+ code: "invalid_type",
50
+ expected: "nonoptional",
51
+ input: undefined,
52
+ path: [${O}]
53
+ });
54
+ }
55
+
56
+ if (${A}_present) {
57
+ if (${A}.value === undefined) {
58
+ newResult[${O}] = undefined;
59
+ } else {
60
+ newResult[${O}] = ${A}.value;
61
+ }
62
+ }
63
+
64
+ `)}p.write("payload.value = newResult;"),p.write("return payload;");const y=p.compile();return(P,A)=>y(h,P,A)};let s;const o=Io,a=!Hd.jitless,c=a&&m0.value,u=e.catchall;let f;t._zod.parse=(h,p)=>{f??(f=r.value);const g=h.value;return o(g)?a&&c&&(p==null?void 0:p.async)===!1&&p.jitless!==!0?(s||(s=i(e.shape)),h=s(h,p),u?Om([],g,h,p,f,t):h):n(h,p):(h.issues.push({expected:"object",code:"invalid_type",input:g,inst:t}),h)}});function lh(t,e,n,r){for(const s of t)if(s.issues.length===0)return e.value=s.value,e;const i=t.filter(s=>!ls(s));return i.length===1?(e.value=i[0].value,i[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:n,errors:t.map(s=>s.issues.map(o=>ni(o,r,ti())))}),e)}const Mm=Z("$ZodUnion",(t,e)=>{Bt.init(t,e),St(t._zod,"optin",()=>e.options.some(r=>r._zod.optin==="optional")?"optional":void 0),St(t._zod,"optout",()=>e.options.some(r=>r._zod.optout==="optional")?"optional":void 0),St(t._zod,"values",()=>{if(e.options.every(r=>r._zod.values))return new Set(e.options.flatMap(r=>Array.from(r._zod.values)))}),St(t._zod,"pattern",()=>{if(e.options.every(r=>r._zod.pattern)){const r=e.options.map(i=>i._zod.pattern);return new RegExp(`^(${r.map(i=>Ud(i.source)).join("|")})$`)}});const n=e.options.length===1?e.options[0]._zod.run:null;t._zod.parse=(r,i)=>{if(n)return n(r,i);let s=!1;const o=[];for(const a of e.options){const l=a._zod.run({value:r.value,issues:[]},i);if(l instanceof Promise)o.push(l),s=!0;else{if(l.issues.length===0)return l;o.push(l)}}return s?Promise.all(o).then(a=>lh(a,r,t,i)):lh(o,r,t,i)}}),ik=Z("$ZodDiscriminatedUnion",(t,e)=>{e.inclusive=!1,Mm.init(t,e);const n=t._zod.parse;St(t._zod,"propValues",()=>{const i={};for(const s of e.options){const o=s._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(s)}"`);for(const[a,l]of Object.entries(o)){i[a]||(i[a]=new Set);for(const c of l)i[a].add(c)}}return i});const r=Wl(()=>{var o;const i=e.options,s=new Map;for(const a of i){const l=(o=a._zod.propValues)==null?void 0:o[e.discriminator];if(!l||l.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(a)}"`);for(const c of l){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,a)}}return s});t._zod.parse=(i,s)=>{const o=i.value;if(!Io(o))return i.issues.push({code:"invalid_type",expected:"object",input:o,inst:t}),i;const a=r.value.get(o==null?void 0:o[e.discriminator]);return a?a._zod.run(i,s):e.unionFallback||s.direction==="backward"?n(i,s):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,options:Array.from(r.value.keys()),input:o,path:[e.discriminator],inst:t}),i)}}),sk=Z("$ZodIntersection",(t,e)=>{Bt.init(t,e),t._zod.parse=(n,r)=>{const i=n.value,s=e.left._zod.run({value:i,issues:[]},r),o=e.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([l,c])=>ch(n,l,c)):ch(n,s,o)}});function Hu(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(Ns(t)&&Ns(e)){const n=Object.keys(e),r=Object.keys(t).filter(s=>n.indexOf(s)!==-1),i={...t,...e};for(const s of r){const o=Hu(t[s],e[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};i[s]=o.data}return{valid:!0,data:i}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<t.length;r++){const i=t[r],s=e[r],o=Hu(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function ch(t,e,n){const r=new Map;let i;for(const a of e.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(const l of a.keys)r.has(l)||r.set(l,{}),r.get(l).l=!0}else t.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const l of a.keys)r.has(l)||r.set(l,{}),r.get(l).r=!0;else t.issues.push(a);const s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&i&&t.issues.push({...i,keys:s}),ls(t))return t;const o=Hu(e.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return t.value=o.data,t}const ok=Z("$ZodRecord",(t,e)=>{Bt.init(t,e),t._zod.parse=(n,r)=>{const i=n.value;if(!Ns(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:t}),n;const s=[],o=e.keyType._zod.values;if(o){n.value={};const a=new Set;for(const c of o)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){a.add(typeof c=="number"?c.toString():c);const u=e.keyType._zod.run({value:c,issues:[]},r);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(u.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(p=>ni(p,r,ti())),input:c,path:[c],inst:t});continue}const f=u.value,h=e.valueType._zod.run({value:i[c],issues:[]},r);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&n.issues.push(...cs(c,p.issues)),n.value[f]=p.value})):(h.issues.length&&n.issues.push(...cs(c,h.issues)),n.value[f]=h.value)}let l;for(const c in i)a.has(c)||(l=l??[],l.push(c));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:t,keys:l})}else{n.value={};for(const a of Reflect.ownKeys(i)){if(a==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,a))continue;let l=e.keyType._zod.run({value:a,issues:[]},r);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Sm.test(a)&&l.issues.length){const f=e.keyType._zod.run({value:Number(a),issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(l=f)}if(l.issues.length){e.mode==="loose"?n.value[a]=i[a]:n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(f=>ni(f,r,ti())),input:a,path:[a],inst:t});continue}const u=e.valueType._zod.run({value:i[a],issues:[]},r);u instanceof Promise?s.push(u.then(f=>{f.issues.length&&n.issues.push(...cs(a,f.issues)),n.value[l.value]=f.value})):(u.issues.length&&n.issues.push(...cs(a,u.issues)),n.value[l.value]=u.value)}}return s.length?Promise.all(s).then(()=>n):n}}),ak=Z("$ZodEnum",(t,e)=>{Bt.init(t,e);const n=gm(e.entries),r=new Set(n);t._zod.values=r,t._zod.pattern=new RegExp(`^(${n.filter(i=>v0.has(typeof i)).map(i=>typeof i=="string"?Ls(i):i.toString()).join("|")})$`),t._zod.parse=(i,s)=>{const o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:n,input:o,inst:t}),i}}),lk=Z("$ZodLiteral",(t,e)=>{if(Bt.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(e.values);t._zod.values=n,t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?Ls(r):r?Ls(r.toString()):String(r)).join("|")})$`),t._zod.parse=(r,i)=>{const s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:e.values,input:s,inst:t}),r}}),ck=Z("$ZodTransform",(t,e)=>{Bt.init(t,e),t._zod.optin="optional",t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new pm(t.constructor.name);const i=e.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(n.value=o,n.fallback=!0,n));if(i instanceof Promise)throw new hs;return n.value=i,n.fallback=!0,n}});function uh(t,e){return e===void 0&&(t.issues.length||t.fallback)?{issues:[],value:void 0}:t}const Nm=Z("$ZodOptional",(t,e)=>{Bt.init(t,e),t._zod.optin="optional",t._zod.optout="optional",St(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),St(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${Ud(n.source)})?$`):void 0}),t._zod.parse=(n,r)=>{if(e.innerType._zod.optin==="optional"){const i=n.value,s=e.innerType._zod.run(n,r);return s instanceof Promise?s.then(o=>uh(o,i)):uh(s,i)}return n.value===void 0?n:e.innerType._zod.run(n,r)}}),uk=Z("$ZodExactOptional",(t,e)=>{Nm.init(t,e),St(t._zod,"values",()=>e.innerType._zod.values),St(t._zod,"pattern",()=>e.innerType._zod.pattern),t._zod.parse=(n,r)=>e.innerType._zod.run(n,r)}),dk=Z("$ZodNullable",(t,e)=>{Bt.init(t,e),St(t._zod,"optin",()=>e.innerType._zod.optin),St(t._zod,"optout",()=>e.innerType._zod.optout),St(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${Ud(n.source)}|null)$`):void 0}),St(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(n,r)=>n.value===null?n:e.innerType._zod.run(n,r)}),fk=Z("$ZodDefault",(t,e)=>{Bt.init(t,e),t._zod.optin="optional",St(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);if(n.value===void 0)return n.value=e.defaultValue,n;const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>dh(s,e)):dh(i,e)}});function dh(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const hk=Z("$ZodPrefault",(t,e)=>{Bt.init(t,e),t._zod.optin="optional",St(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=e.defaultValue),e.innerType._zod.run(n,r))}),pk=Z("$ZodNonOptional",(t,e)=>{Bt.init(t,e),St(t._zod,"values",()=>{const n=e.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),t._zod.parse=(n,r)=>{const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>fh(s,t)):fh(i,t)}});function fh(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}const gk=Z("$ZodCatch",(t,e)=>{Bt.init(t,e),t._zod.optin="optional",St(t._zod,"optout",()=>e.innerType._zod.optout),St(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>(n.value=s.value,s.issues.length&&(n.value=e.catchValue({...n,error:{issues:s.issues.map(o=>ni(o,r,ti()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=i.value,i.issues.length&&(n.value=e.catchValue({...n,error:{issues:i.issues.map(s=>ni(s,r,ti()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),Lm=Z("$ZodPipe",(t,e)=>{Bt.init(t,e),St(t._zod,"values",()=>e.in._zod.values),St(t._zod,"optin",()=>e.in._zod.optin),St(t._zod,"optout",()=>e.out._zod.optout),St(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=e.out._zod.run(n,r);return s instanceof Promise?s.then(o=>Ca(o,e.in,r)):Ca(s,e.in,r)}const i=e.in._zod.run(n,r);return i instanceof Promise?i.then(s=>Ca(s,e.out,r)):Ca(i,e.out,r)}});function Ca(t,e,n){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues,fallback:t.fallback},n)}const mk=Z("$ZodPreprocess",(t,e)=>{Lm.init(t,e)}),vk=Z("$ZodReadonly",(t,e)=>{Bt.init(t,e),St(t._zod,"propValues",()=>e.innerType._zod.propValues),St(t._zod,"values",()=>e.innerType._zod.values),St(t._zod,"optin",()=>{var n,r;return(r=(n=e.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),St(t._zod,"optout",()=>{var n,r;return(r=(n=e.innerType)==null?void 0:n._zod)==null?void 0:r.optout}),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(hh):hh(i)}});function hh(t){return t.value=Object.freeze(t.value),t}const bk=Z("$ZodCustom",(t,e)=>{Vn.init(t,e),Bt.init(t,e),t._zod.parse=(n,r)=>n,t._zod.check=n=>{const r=n.value,i=e.fn(r);if(i instanceof Promise)return i.then(s=>ph(s,n,r,t));ph(i,n,r,t)}});function ph(t,e,n,r){if(!t){const i={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),e.issues.push(zo(i))}}var gh;class _k{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...n){const r=n[0];return this._map.set(e,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const n=this._map.get(e);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(e),this}get(e){const n=e._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const i={...r,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function wk(){return new _k}(gh=globalThis).__zod_globalRegistry??(gh.__zod_globalRegistry=wk());const mo=globalThis.__zod_globalRegistry;function yk(t,e){return new t({type:"string",...Oe(e)})}function kk(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...Oe(e)})}function mh(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...Oe(e)})}function Ek(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...Oe(e)})}function Sk(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Oe(e)})}function Tk(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Oe(e)})}function xk(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Oe(e)})}function Ck(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...Oe(e)})}function Pk(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...Oe(e)})}function Rk(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...Oe(e)})}function Ak(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...Oe(e)})}function Ok(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...Oe(e)})}function Mk(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...Oe(e)})}function Nk(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...Oe(e)})}function Lk(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...Oe(e)})}function Ik(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...Oe(e)})}function zk(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...Oe(e)})}function Dk(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Oe(e)})}function Hk(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Oe(e)})}function Bk(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...Oe(e)})}function Uk(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...Oe(e)})}function jk(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...Oe(e)})}function $k(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...Oe(e)})}function Fk(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Oe(e)})}function Gk(t,e){return new t({type:"string",format:"date",check:"string_format",...Oe(e)})}function Vk(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...Oe(e)})}function Zk(t,e){return new t({type:"string",format:"duration",check:"string_format",...Oe(e)})}function Wk(t,e){return new t({type:"number",checks:[],...Oe(e)})}function qk(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...Oe(e)})}function Kk(t,e){return new t({type:"boolean",...Oe(e)})}function Yk(t){return new t({type:"unknown"})}function Xk(t,e){return new t({type:"never",...Oe(e)})}function vh(t,e){return new xm({check:"less_than",...Oe(e),value:t,inclusive:!1})}function Rc(t,e){return new xm({check:"less_than",...Oe(e),value:t,inclusive:!0})}function bh(t,e){return new Cm({check:"greater_than",...Oe(e),value:t,inclusive:!1})}function Ac(t,e){return new Cm({check:"greater_than",...Oe(e),value:t,inclusive:!0})}function _h(t,e){return new f1({check:"multiple_of",...Oe(e),value:t})}function Im(t,e){return new p1({check:"max_length",...Oe(e),maximum:t})}function pl(t,e){return new g1({check:"min_length",...Oe(e),minimum:t})}function zm(t,e){return new m1({check:"length_equals",...Oe(e),length:t})}function Jk(t,e){return new v1({check:"string_format",format:"regex",...Oe(e),pattern:t})}function Qk(t){return new b1({check:"string_format",format:"lowercase",...Oe(t)})}function eE(t){return new _1({check:"string_format",format:"uppercase",...Oe(t)})}function tE(t,e){return new w1({check:"string_format",format:"includes",...Oe(e),includes:t})}function nE(t,e){return new y1({check:"string_format",format:"starts_with",...Oe(e),prefix:t})}function rE(t,e){return new k1({check:"string_format",format:"ends_with",...Oe(e),suffix:t})}function Ws(t){return new E1({check:"overwrite",tx:t})}function iE(t){return Ws(e=>e.normalize(t))}function sE(){return Ws(t=>t.trim())}function oE(){return Ws(t=>t.toLowerCase())}function aE(){return Ws(t=>t.toUpperCase())}function lE(){return Ws(t=>g0(t))}function cE(t,e,n){return new t({type:"array",element:e,...Oe(n)})}function uE(t,e,n){return new t({type:"custom",check:"custom",fn:e,...Oe(n)})}function dE(t,e){const n=fE(r=>(r.addIssue=i=>{if(typeof i=="string")r.issues.push(zo(i,r.value,n._zod.def));else{const s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),r.issues.push(zo(s))}},t(r.value,r)),e);return n}function fE(t,e){const n=new Vn({check:"custom",...Oe(e)});return n._zod.check=t,n}function Dm(t){let e=(t==null?void 0:t.target)??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:(t==null?void 0:t.metadata)??mo,target:e,unrepresentable:(t==null?void 0:t.unrepresentable)??"throw",override:(t==null?void 0:t.override)??(()=>{}),io:(t==null?void 0:t.io)??"output",counter:0,seen:new Map,cycles:(t==null?void 0:t.cycles)??"ref",reused:(t==null?void 0:t.reused)??"inline",external:(t==null?void 0:t.external)??void 0}}function Jt(t,e,n={path:[],schemaPath:[]}){var u,f;var r;const i=t._zod.def,s=e.seen.get(t);if(s)return s.count++,n.schemaPath.includes(t)&&(s.cycle=n.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:n.path};e.seen.set(t,o);const a=(f=(u=t._zod).toJSONSchema)==null?void 0:f.call(u);if(a)o.schema=a;else{const h={...n,schemaPath:[...n.schemaPath,t],path:n.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,o.schema,h);else{const g=o.schema,m=e.processors[i.type];if(!m)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);m(t,e,g,h)}const p=t._zod.parent;p&&(o.ref||(o.ref=p),Jt(p,e,h),e.seen.get(p).isParent=!0)}const l=e.metadataRegistry.get(t);return l&&Object.assign(o.schema,l),e.io==="input"&&On(t)&&(delete o.schema.examples,delete o.schema.default),e.io==="input"&&"_prefault"in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,e.seen.get(t).schema}function Hm(t,e){var o,a,l,c;const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const u of t.seen.entries()){const f=(o=t.metadataRegistry.get(u[0]))==null?void 0:o.id;if(f){const h=r.get(f);if(h&&h!==u[0])throw new Error(`Duplicate schema id "${f}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(f,u[0])}}const i=u=>{var m;const f=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){const b=(m=t.external.registry.get(u[0]))==null?void 0:m.id,_=t.external.uri??(R=>R);if(b)return{ref:_(b)};const y=u[1].defId??u[1].schema.id??`schema${t.counter++}`;return u[1].defId=y,{defId:y,ref:`${_("__shared")}#/${f}/${y}`}}if(u[1]===n)return{ref:"#"};const p=`#/${f}/`,g=u[1].schema.id??`__schema${t.counter++}`;return{defId:g,ref:p+g}},s=u=>{if(u[1].schema.$ref)return;const f=u[1],{ref:h,defId:p}=i(u);f.def={...f.schema},p&&(f.defId=p);const g=f.schema;for(const m in g)delete g[m];g.$ref=h};if(t.cycles==="throw")for(const u of t.seen.entries()){const f=u[1];if(f.cycle)throw new Error(`Cycle detected: #/${(a=f.cycle)==null?void 0:a.join("/")}/<root>
65
+
66
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const u of t.seen.entries()){const f=u[1];if(e===u[0]){s(u);continue}if(t.external){const p=(l=t.external.registry.get(u[0]))==null?void 0:l.id;if(e!==u[0]&&p){s(u);continue}}if((c=t.metadataRegistry.get(u[0]))==null?void 0:c.id){s(u);continue}if(f.cycle){s(u);continue}if(f.count>1&&t.reused==="ref"){s(u);continue}}}function Bm(t,e){var a,l,c,u;const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=f=>{const h=t.seen.get(f);if(h.ref===null)return;const p=h.def??h.schema,g={...p},m=h.ref;if(h.ref=null,m){r(m);const _=t.seen.get(m),y=_.schema;if(y.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(y)):Object.assign(p,y),Object.assign(p,g),f._zod.parent===m)for(const L in p)L==="$ref"||L==="allOf"||L in g||delete p[L];if(y.$ref&&_.def)for(const L in p)L==="$ref"||L==="allOf"||L in _.def&&JSON.stringify(p[L])===JSON.stringify(_.def[L])&&delete p[L]}const b=f._zod.parent;if(b&&b!==m){r(b);const _=t.seen.get(b);if(_!=null&&_.schema.$ref&&(p.$ref=_.schema.$ref,_.def))for(const y in p)y==="$ref"||y==="allOf"||y in _.def&&JSON.stringify(p[y])===JSON.stringify(_.def[y])&&delete p[y]}t.override({zodSchema:f,jsonSchema:p,path:h.path??[]})};for(const f of[...t.seen.entries()].reverse())r(f[0]);const i={};if(t.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":t.target,(a=t.external)!=null&&a.uri){const f=(l=t.external.registry.get(e))==null?void 0:l.id;if(!f)throw new Error("Schema is missing an `id` property");i.$id=t.external.uri(f)}Object.assign(i,n.def??n.schema);const s=(c=t.metadataRegistry.get(e))==null?void 0:c.id;s!==void 0&&i.id===s&&delete i.id;const o=((u=t.external)==null?void 0:u.defs)??{};for(const f of t.seen.entries()){const h=f[1];h.def&&h.defId&&(h.def.id===h.defId&&delete h.def.id,o[h.defId]=h.def)}t.external||Object.keys(o).length>0&&(t.target==="draft-2020-12"?i.$defs=o:i.definitions=o);try{const f=JSON.parse(JSON.stringify(i));return Object.defineProperty(f,"~standard",{value:{...e["~standard"],jsonSchema:{input:gl(e,"input",t.processors),output:gl(e,"output",t.processors)}},enumerable:!1,writable:!1}),f}catch{throw new Error("Error converting schema to JSON.")}}function On(t,e){const n=e??{seen:new Set};if(n.seen.has(t))return!1;n.seen.add(t);const r=t._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return On(r.element,n);if(r.type==="set")return On(r.valueType,n);if(r.type==="lazy")return On(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return On(r.innerType,n);if(r.type==="intersection")return On(r.left,n)||On(r.right,n);if(r.type==="record"||r.type==="map")return On(r.keyType,n)||On(r.valueType,n);if(r.type==="pipe")return t._zod.traits.has("$ZodCodec")?!0:On(r.in,n)||On(r.out,n);if(r.type==="object"){for(const i in r.shape)if(On(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(On(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(On(i,n))return!0;return!!(r.rest&&On(r.rest,n))}return!1}const hE=(t,e={})=>n=>{const r=Dm({...n,processors:e});return Jt(t,r),Hm(r,t),Bm(r,t)},gl=(t,e,n={})=>r=>{const{libraryOptions:i,target:s}=r??{},o=Dm({...i??{},target:s,io:e,processors:n});return Jt(t,o),Hm(o,t),Bm(o,t)},pE={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},gE=(t,e,n,r)=>{const i=n;i.type="string";const{minimum:s,maximum:o,format:a,patterns:l,contentEncoding:c}=t._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=pE[a]??a,i.format===""&&delete i.format,a==="time"&&delete i.format),c&&(i.contentEncoding=c),l&&l.size>0){const u=[...l];u.length===1?i.pattern=u[0].source:u.length>1&&(i.allOf=[...u.map(f=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},mE=(t,e,n,r)=>{const i=n,{minimum:s,maximum:o,format:a,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:u}=t._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number";const f=typeof u=="number"&&u>=(s??Number.NEGATIVE_INFINITY),h=typeof c=="number"&&c<=(o??Number.POSITIVE_INFINITY),p=e.target==="draft-04"||e.target==="openapi-3.0";f?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof s=="number"&&(i.minimum=s),h?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o=="number"&&(i.maximum=o),typeof l=="number"&&(i.multipleOf=l)},vE=(t,e,n,r)=>{n.type="boolean"},bE=(t,e,n,r)=>{n.not={}},_E=(t,e,n,r)=>{},wE=(t,e,n,r)=>{const i=t._zod.def,s=gm(i.entries);s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),n.enum=s},yE=(t,e,n,r)=>{const i=t._zod.def,s=[];for(const o of i.values)if(o===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){const o=s[0];n.type=o===null?"null":typeof o,e.target==="draft-04"||e.target==="openapi-3.0"?n.enum=[o]:n.const=o}else s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),s.every(o=>typeof o=="boolean")&&(n.type="boolean"),s.every(o=>o===null)&&(n.type="null"),n.enum=s},kE=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},EE=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},SE=(t,e,n,r)=>{const i=n,s=t._zod.def,{minimum:o,maximum:a}=t._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=Jt(s.element,e,{...r,path:[...r.path,"items"]})},TE=(t,e,n,r)=>{var c;const i=n,s=t._zod.def;i.type="object",i.properties={};const o=s.shape;for(const u in o)i.properties[u]=Jt(o[u],e,{...r,path:[...r.path,"properties",u]});const a=new Set(Object.keys(o)),l=new Set([...a].filter(u=>{const f=s.shape[u]._zod;return e.io==="input"?f.optin===void 0:f.optout===void 0}));l.size>0&&(i.required=Array.from(l)),((c=s.catchall)==null?void 0:c._zod.def.type)==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=Jt(s.catchall,e,{...r,path:[...r.path,"additionalProperties"]})):e.io==="output"&&(i.additionalProperties=!1)},xE=(t,e,n,r)=>{const i=t._zod.def,s=i.inclusive===!1,o=i.options.map((a,l)=>Jt(a,e,{...r,path:[...r.path,s?"oneOf":"anyOf",l]}));s?n.oneOf=o:n.anyOf=o},CE=(t,e,n,r)=>{const i=t._zod.def,s=Jt(i.left,e,{...r,path:[...r.path,"allOf",0]}),o=Jt(i.right,e,{...r,path:[...r.path,"allOf",1]}),a=c=>"allOf"in c&&Object.keys(c).length===1,l=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=l},PE=(t,e,n,r)=>{const i=n,s=t._zod.def;i.type="object";const o=s.keyType,a=o._zod.bag,l=a==null?void 0:a.patterns;if(s.mode==="loose"&&l&&l.size>0){const u=Jt(s.valueType,e,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const f of l)i.patternProperties[f.source]=u}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(i.propertyNames=Jt(s.keyType,e,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=Jt(s.valueType,e,{...r,path:[...r.path,"additionalProperties"]});const c=o._zod.values;if(c){const u=[...c].filter(f=>typeof f=="string"||typeof f=="number");u.length>0&&(i.required=u)}},RE=(t,e,n,r)=>{const i=t._zod.def,s=Jt(i.innerType,e,r),o=e.seen.get(t);e.target==="openapi-3.0"?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},AE=(t,e,n,r)=>{const i=t._zod.def;Jt(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType},OE=(t,e,n,r)=>{const i=t._zod.def;Jt(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},ME=(t,e,n,r)=>{const i=t._zod.def;Jt(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType,e.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},NE=(t,e,n,r)=>{const i=t._zod.def;Jt(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o},LE=(t,e,n,r)=>{const i=t._zod.def,s=i.in._zod.traits.has("$ZodTransform"),o=e.io==="input"?s?i.out:i.in:i.out;Jt(o,e,r);const a=e.seen.get(t);a.ref=o},IE=(t,e,n,r)=>{const i=t._zod.def;Jt(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType,n.readOnly=!0},Um=(t,e,n,r)=>{const i=t._zod.def;Jt(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType},zE=Z("ZodISODateTime",(t,e)=>{D1.init(t,e),jt.init(t,e)});function DE(t){return Fk(zE,t)}const HE=Z("ZodISODate",(t,e)=>{H1.init(t,e),jt.init(t,e)});function BE(t){return Gk(HE,t)}const UE=Z("ZodISOTime",(t,e)=>{B1.init(t,e),jt.init(t,e)});function jE(t){return Vk(UE,t)}const $E=Z("ZodISODuration",(t,e)=>{U1.init(t,e),jt.init(t,e)});function FE(t){return Zk($E,t)}const GE=(t,e)=>{_m.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:n=>R0(t,n)},flatten:{value:n=>P0(t,n)},addIssue:{value:n=>{t.issues.push(n),t.message=JSON.stringify(t.issues,Du,2)}},addIssues:{value:n=>{t.issues.push(...n),t.message=JSON.stringify(t.issues,Du,2)}},isEmpty:{get(){return t.issues.length===0}}})},dr=Z("ZodError",GE,{Parent:Error}),VE=$d(dr),ZE=Fd(dr),WE=ql(dr),qE=Kl(dr),KE=M0(dr),YE=N0(dr),XE=L0(dr),JE=I0(dr),QE=z0(dr),eS=D0(dr),tS=H0(dr),nS=B0(dr),wh=new WeakMap;function ha(t,e,n){const r=Object.getPrototypeOf(t);let i=wh.get(r);if(i||(i=new Set,wh.set(r,i)),!i.has(e)){i.add(e);for(const s in n){const o=n[s];Object.defineProperty(r,s,{configurable:!0,enumerable:!1,get(){const a=o.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}const Ut=Z("ZodType",(t,e)=>(Bt.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:gl(t,"input"),output:gl(t,"output")}}),t.toJSONSchema=hE(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.parse=(n,r)=>VE(t,n,r,{callee:t.parse}),t.safeParse=(n,r)=>WE(t,n,r),t.parseAsync=async(n,r)=>ZE(t,n,r,{callee:t.parseAsync}),t.safeParseAsync=async(n,r)=>qE(t,n,r),t.spa=t.safeParseAsync,t.encode=(n,r)=>KE(t,n,r),t.decode=(n,r)=>YE(t,n,r),t.encodeAsync=async(n,r)=>XE(t,n,r),t.decodeAsync=async(n,r)=>JE(t,n,r),t.safeEncode=(n,r)=>QE(t,n,r),t.safeDecode=(n,r)=>eS(t,n,r),t.safeEncodeAsync=async(n,r)=>tS(t,n,r),t.safeDecodeAsync=async(n,r)=>nS(t,n,r),ha(t,"ZodType",{check(...n){const r=this.def;return this.clone(Ri(r,{checks:[...r.checks??[],...n.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,r){return Ai(this,n,r)},brand(){return this},register(n,r){return n.add(this,r),this},refine(n,r){return this.check(WS(n,r))},superRefine(n,r){return this.check(qS(n,r))},overwrite(n){return this.check(Ws(n))},optional(){return Sh(this)},exactOptional(){return LS(this)},nullable(){return Th(this)},nullish(){return Sh(Th(this))},nonoptional(n){return US(this,n)},array(){return Ht(this)},or(n){return mi([this,n])},and(n){return AS(this,n)},transform(n){return xh(this,Gm(n))},default(n){return DS(this,n)},prefault(n){return BS(this,n)},catch(n){return $S(this,n)},pipe(n){return xh(this,n)},readonly(){return VS(this)},describe(n){const r=this.clone();return mo.add(r,{description:n}),r},meta(...n){if(n.length===0)return mo.get(this);const r=this.clone();return mo.add(r,n[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(t,"description",{get(){var n;return(n=mo.get(t))==null?void 0:n.description},configurable:!0}),t)),jm=Z("_ZodString",(t,e)=>{Gd.init(t,e),Ut.init(t,e),t._zod.processJSONSchema=(r,i,s)=>gE(t,r,i);const n=t._zod.bag;t.format=n.format??null,t.minLength=n.minimum??null,t.maxLength=n.maximum??null,ha(t,"_ZodString",{regex(...r){return this.check(Jk(...r))},includes(...r){return this.check(tE(...r))},startsWith(...r){return this.check(nE(...r))},endsWith(...r){return this.check(rE(...r))},min(...r){return this.check(pl(...r))},max(...r){return this.check(Im(...r))},length(...r){return this.check(zm(...r))},nonempty(...r){return this.check(pl(1,...r))},lowercase(r){return this.check(Qk(r))},uppercase(r){return this.check(eE(r))},trim(){return this.check(sE())},normalize(...r){return this.check(iE(...r))},toLowerCase(){return this.check(oE())},toUpperCase(){return this.check(aE())},slugify(){return this.check(lE())}})}),rS=Z("ZodString",(t,e)=>{Gd.init(t,e),jm.init(t,e),t.email=n=>t.check(kk(iS,n)),t.url=n=>t.check(Ck(sS,n)),t.jwt=n=>t.check($k(wS,n)),t.emoji=n=>t.check(Pk(oS,n)),t.guid=n=>t.check(mh(yh,n)),t.uuid=n=>t.check(Ek(Pa,n)),t.uuidv4=n=>t.check(Sk(Pa,n)),t.uuidv6=n=>t.check(Tk(Pa,n)),t.uuidv7=n=>t.check(xk(Pa,n)),t.nanoid=n=>t.check(Rk(aS,n)),t.guid=n=>t.check(mh(yh,n)),t.cuid=n=>t.check(Ak(lS,n)),t.cuid2=n=>t.check(Ok(cS,n)),t.ulid=n=>t.check(Mk(uS,n)),t.base64=n=>t.check(Bk(vS,n)),t.base64url=n=>t.check(Uk(bS,n)),t.xid=n=>t.check(Nk(dS,n)),t.ksuid=n=>t.check(Lk(fS,n)),t.ipv4=n=>t.check(Ik(hS,n)),t.ipv6=n=>t.check(zk(pS,n)),t.cidrv4=n=>t.check(Dk(gS,n)),t.cidrv6=n=>t.check(Hk(mS,n)),t.e164=n=>t.check(jk(_S,n)),t.datetime=n=>t.check(DE(n)),t.date=n=>t.check(BE(n)),t.time=n=>t.check(jE(n)),t.duration=n=>t.check(FE(n))});function me(t){return yk(rS,t)}const jt=Z("ZodStringFormat",(t,e)=>{zt.init(t,e),jm.init(t,e)}),iS=Z("ZodEmail",(t,e)=>{P1.init(t,e),jt.init(t,e)}),yh=Z("ZodGUID",(t,e)=>{x1.init(t,e),jt.init(t,e)}),Pa=Z("ZodUUID",(t,e)=>{C1.init(t,e),jt.init(t,e)}),sS=Z("ZodURL",(t,e)=>{R1.init(t,e),jt.init(t,e)}),oS=Z("ZodEmoji",(t,e)=>{A1.init(t,e),jt.init(t,e)}),aS=Z("ZodNanoID",(t,e)=>{O1.init(t,e),jt.init(t,e)}),lS=Z("ZodCUID",(t,e)=>{M1.init(t,e),jt.init(t,e)}),cS=Z("ZodCUID2",(t,e)=>{N1.init(t,e),jt.init(t,e)}),uS=Z("ZodULID",(t,e)=>{L1.init(t,e),jt.init(t,e)}),dS=Z("ZodXID",(t,e)=>{I1.init(t,e),jt.init(t,e)}),fS=Z("ZodKSUID",(t,e)=>{z1.init(t,e),jt.init(t,e)}),hS=Z("ZodIPv4",(t,e)=>{j1.init(t,e),jt.init(t,e)}),pS=Z("ZodIPv6",(t,e)=>{$1.init(t,e),jt.init(t,e)}),gS=Z("ZodCIDRv4",(t,e)=>{F1.init(t,e),jt.init(t,e)}),mS=Z("ZodCIDRv6",(t,e)=>{G1.init(t,e),jt.init(t,e)}),vS=Z("ZodBase64",(t,e)=>{V1.init(t,e),jt.init(t,e)}),bS=Z("ZodBase64URL",(t,e)=>{W1.init(t,e),jt.init(t,e)}),_S=Z("ZodE164",(t,e)=>{q1.init(t,e),jt.init(t,e)}),wS=Z("ZodJWT",(t,e)=>{Y1.init(t,e),jt.init(t,e)}),$m=Z("ZodNumber",(t,e)=>{Rm.init(t,e),Ut.init(t,e),t._zod.processJSONSchema=(r,i,s)=>mE(t,r,i),ha(t,"ZodNumber",{gt(r,i){return this.check(bh(r,i))},gte(r,i){return this.check(Ac(r,i))},min(r,i){return this.check(Ac(r,i))},lt(r,i){return this.check(vh(r,i))},lte(r,i){return this.check(Rc(r,i))},max(r,i){return this.check(Rc(r,i))},int(r){return this.check(kh(r))},safe(r){return this.check(kh(r))},positive(r){return this.check(bh(0,r))},nonnegative(r){return this.check(Ac(0,r))},negative(r){return this.check(vh(0,r))},nonpositive(r){return this.check(Rc(0,r))},multipleOf(r,i){return this.check(_h(r,i))},step(r,i){return this.check(_h(r,i))},finite(){return this}});const n=t._zod.bag;t.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),t.isFinite=!0,t.format=n.format??null});function bn(t){return Wk($m,t)}const yS=Z("ZodNumberFormat",(t,e)=>{X1.init(t,e),$m.init(t,e)});function kh(t){return qk(yS,t)}const kS=Z("ZodBoolean",(t,e)=>{J1.init(t,e),Ut.init(t,e),t._zod.processJSONSchema=(n,r,i)=>vE(t,n,r)});function _i(t){return Kk(kS,t)}const ES=Z("ZodUnknown",(t,e)=>{Q1.init(t,e),Ut.init(t,e),t._zod.processJSONSchema=(n,r,i)=>_E()});function Bu(){return Yk(ES)}const SS=Z("ZodNever",(t,e)=>{ek.init(t,e),Ut.init(t,e),t._zod.processJSONSchema=(n,r,i)=>bE(t,n,r)});function TS(t){return Xk(SS,t)}const xS=Z("ZodArray",(t,e)=>{tk.init(t,e),Ut.init(t,e),t._zod.processJSONSchema=(n,r,i)=>SE(t,n,r,i),t.element=e.element,ha(t,"ZodArray",{min(n,r){return this.check(pl(n,r))},nonempty(n){return this.check(pl(1,n))},max(n,r){return this.check(Im(n,r))},length(n,r){return this.check(zm(n,r))},unwrap(){return this.element}})});function Ht(t,e){return cE(xS,t,e)}const CS=Z("ZodObject",(t,e)=>{rk.init(t,e),Ut.init(t,e),t._zod.processJSONSchema=(n,r,i)=>TE(t,n,r,i),St(t,"shape",()=>e.shape),ha(t,"ZodObject",{keyof(){return Cn(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:Bu()})},loose(){return this.clone({...this._zod.def,catchall:Bu()})},strict(){return this.clone({...this._zod.def,catchall:TS()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return k0(this,n)},safeExtend(n){return E0(this,n)},merge(n){return S0(this,n)},pick(n){return w0(this,n)},omit(n){return y0(this,n)},partial(...n){return T0(Vm,this,n[0])},required(...n){return x0(Zm,this,n[0])}})});function ot(t,e){const n={type:"object",shape:t??{},...Oe(e)};return new CS(n)}const Fm=Z("ZodUnion",(t,e)=>{Mm.init(t,e),Ut.init(t,e),t._zod.processJSONSchema=(n,r,i)=>xE(t,n,r,i),t.options=e.options});function mi(t,e){return new Fm({type:"union",options:t,...Oe(e)})}const PS=Z("ZodDiscriminatedUnion",(t,e)=>{Fm.init(t,e),ik.init(t,e)});function Vd(t,e,n){return new PS({type:"union",options:e,discriminator:t,...Oe(n)})}const RS=Z("ZodIntersection",(t,e)=>{sk.init(t,e),Ut.init(t,e),t._zod.processJSONSchema=(n,r,i)=>CE(t,n,r,i)});function AS(t,e){return new RS({type:"intersection",left:t,right:e})}const Eh=Z("ZodRecord",(t,e)=>{ok.init(t,e),Ut.init(t,e),t._zod.processJSONSchema=(n,r,i)=>PE(t,n,r,i),t.keyType=e.keyType,t.valueType=e.valueType});function qs(t,e,n){return!e||!e._zod?new Eh({type:"record",keyType:me(),valueType:t,...Oe(e)}):new Eh({type:"record",keyType:t,valueType:e,...Oe(n)})}const Uu=Z("ZodEnum",(t,e)=>{ak.init(t,e),Ut.init(t,e),t._zod.processJSONSchema=(r,i,s)=>wE(t,r,i),t.enum=e.entries,t.options=Object.values(e.entries);const n=new Set(Object.keys(e.entries));t.extract=(r,i)=>{const s={};for(const o of r)if(n.has(o))s[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Uu({...e,checks:[],...Oe(i),entries:s})},t.exclude=(r,i)=>{const s={...e.entries};for(const o of r)if(n.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new Uu({...e,checks:[],...Oe(i),entries:s})}});function Cn(t,e){const n=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new Uu({type:"enum",entries:n,...Oe(e)})}const OS=Z("ZodLiteral",(t,e)=>{lk.init(t,e),Ut.init(t,e),t._zod.processJSONSchema=(n,r,i)=>yE(t,n,r),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function Yt(t,e){return new OS({type:"literal",values:Array.isArray(t)?t:[t],...Oe(e)})}const MS=Z("ZodTransform",(t,e)=>{ck.init(t,e),Ut.init(t,e),t._zod.processJSONSchema=(n,r,i)=>EE(t,n),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new pm(t.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(zo(s,n.value,e));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),n.issues.push(zo(o))}};const i=e.transform(n.value,n);return i instanceof Promise?i.then(s=>(n.value=s,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Gm(t){return new MS({type:"transform",transform:t})}const Vm=Z("ZodOptional",(t,e)=>{Nm.init(t,e),Ut.init(t,e),t._zod.processJSONSchema=(n,r,i)=>Um(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function Sh(t){return new Vm({type:"optional",innerType:t})}const NS=Z("ZodExactOptional",(t,e)=>{uk.init(t,e),Ut.init(t,e),t._zod.processJSONSchema=(n,r,i)=>Um(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function LS(t){return new NS({type:"optional",innerType:t})}const IS=Z("ZodNullable",(t,e)=>{dk.init(t,e),Ut.init(t,e),t._zod.processJSONSchema=(n,r,i)=>RE(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function Th(t){return new IS({type:"nullable",innerType:t})}const zS=Z("ZodDefault",(t,e)=>{fk.init(t,e),Ut.init(t,e),t._zod.processJSONSchema=(n,r,i)=>OE(t,n,r,i),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function DS(t,e){return new zS({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():vm(e)}})}const HS=Z("ZodPrefault",(t,e)=>{hk.init(t,e),Ut.init(t,e),t._zod.processJSONSchema=(n,r,i)=>ME(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function BS(t,e){return new HS({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():vm(e)}})}const Zm=Z("ZodNonOptional",(t,e)=>{pk.init(t,e),Ut.init(t,e),t._zod.processJSONSchema=(n,r,i)=>AE(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function US(t,e){return new Zm({type:"nonoptional",innerType:t,...Oe(e)})}const jS=Z("ZodCatch",(t,e)=>{gk.init(t,e),Ut.init(t,e),t._zod.processJSONSchema=(n,r,i)=>NE(t,n,r,i),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function $S(t,e){return new jS({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const Wm=Z("ZodPipe",(t,e)=>{Lm.init(t,e),Ut.init(t,e),t._zod.processJSONSchema=(n,r,i)=>LE(t,n,r,i),t.in=e.in,t.out=e.out});function xh(t,e){return new Wm({type:"pipe",in:t,out:e})}const FS=Z("ZodPreprocess",(t,e)=>{Wm.init(t,e),mk.init(t,e)}),GS=Z("ZodReadonly",(t,e)=>{vk.init(t,e),Ut.init(t,e),t._zod.processJSONSchema=(n,r,i)=>IE(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function VS(t){return new GS({type:"readonly",innerType:t})}const ZS=Z("ZodCustom",(t,e)=>{bk.init(t,e),Ut.init(t,e),t._zod.processJSONSchema=(n,r,i)=>kE(t,n)});function WS(t,e={}){return uE(ZS,t,e)}function qS(t,e){return dE(t,e)}function KS(t,e){return new FS({type:"pipe",in:Gm(t),out:e})}const YS=["/","/login","/packages","/packages/services","/settings"],XS=new Set(YS);function qm(t){return XS.has(t)}function Km(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Ym(t,e,n,r){for(const[i,s]of Object.entries(t)){const o=n===""?i:`${n}.${i}`;if(typeof s=="string"){if(Object.hasOwn(r,o))throw new Error(`Plugin catalog ${e} contains duplicate key "${o}"`);r[o]=s}else if(Km(s))Ym(s,e,o,r);else throw new Error(`Plugin catalog ${e} key "${o}" must be a string or object`)}}function JS(t,e){if(!Km(t))throw new Error(`Plugin catalog ${e} must be a JSON object`);const n={};return Ym(t,e,"",n),Object.freeze(n)}const QS=me().regex(/^[0-9A-HJKMNP-TV-Z]{26}$/),Be=me().min(1),Zd=bn().int(),Ra=Zd.nonnegative(),Ch=4*1024;Cn(["hook","log","internal"]);const eT=/^events:(\*|[a-z][a-z0-9]*(?:,[a-z][a-z0-9]*)*)$/,tT=me().regex(eT),Ct=(t,e,n)=>{const r=typeof e=="string"?Yt(e):e;return ot({id:QS,ts:Zd,topic:Yt(t),source:r,payload:n}).strict()},cn=t=>ot(t).strict(),Ph=mi([Ct("wan.connected",mi([Yt("hook"),Yt("log")]),cn({interface:Be,address:Be,mask:Be,gateway:Be})),Ct("wan.disconnected",mi([Yt("hook"),Yt("log")]),cn({interface:Be})),Ct("net.ip_changed",mi([Yt("hook"),Yt("log")]),ot({address:Be,mask:Be,link:Be,connected:_i()}).strict()),Ct("net.dhcp_lease","log",cn({mac:Be,ip:Be,hostname:Be,action:Be})),Ct("net.dns_changed","log",ot({resolvers:Ht(Be)}).strict()),Ct("wifi.client_join","log",cn({mac:Be,band:Be,ssid:Be,iface:Be})),Ct("wifi.client_leave","log",cn({mac:Be,band:Be,ssid:Be,iface:Be})),Ct("firewall.rebuilt","hook",cn({table_type:Be,table:Be})),Ct("usb.attached","hook",cn({device:Be,model:Be,vendor:Be,port:Be})),Ct("usb.detached","hook",cn({device:Be,port:Be})),Ct("fs.mounted","hook",cn({fs_type:Be,label:Be,directory:Be})),Ct("fs.unmounted","hook",cn({label:Be,directory:Be})),Ct("clock.synced","hook",ot({offset_ms:Zd.optional()}).strict()),Ct("schedule.fired","hook",ot({name:Be,action:Be,elapsed:Ra}).strict()),Ct("button.pressed","hook",cn({button:Be,gesture:Be})),Ct("auth.login","log",ot({user:Be,ip:Be,success:_i()}).strict()),Ct("firmware.available","log",cn({version:Be})),Ct("plugin.installed","internal",cn({name:Be,version:Be})),Ct("plugin.removed","internal",cn({name:Be})),Ct("plugin.approved","internal",cn({name:Be,version:Be})),Ct("plugin.started","internal",cn({name:Be})),Ct("plugin.stopped","internal",ot({name:Be,reason:Be}).strict()),Ct("daemon.started","internal",ot({version:Be,uptime_ms:Ra}).strict()),Ct("daemon.stopping","internal",cn({reason:Be})),Ct("daemon.updated","internal",cn({version:Be})),Ct("storage.low","internal",ot({path:Yt("/opt"),available_bytes:Ra,threshold_bytes:Ra}).strict()),Ct("telemetry.gathering_changed","internal",ot({enabled:_i()}).strict())]).superRefine((t,e)=>{new TextEncoder().encode(JSON.stringify(t.payload)).length>Ch&&e.addIssue({code:"custom",message:`payload exceeds ${Ch} bytes`})});function Oc(t,e){const n=e&&e.cache?e.cache:lT,r=e&&e.serializer?e.serializer:oT;return(e&&e.strategy?e.strategy:iT)(t,{cache:n,serializer:r})}function nT(t){return t==null||typeof t=="number"||typeof t=="boolean"}function rT(t,e,n,r){const i=nT(r)?r:n(r);let s=e.get(i);return typeof s>"u"&&(s=t.call(this,r),e.set(i,s)),s}function Xm(t,e,n){const r=Array.prototype.slice.call(arguments,3),i=n(r);let s=e.get(i);return typeof s>"u"&&(s=t.apply(this,r),e.set(i,s)),s}function Jm(t,e,n,r,i){return n.bind(e,t,r,i)}function iT(t,e){const n=t.length===1?rT:Xm;return Jm(t,this,n,e.cache.create(),e.serializer)}function sT(t,e){return Jm(t,this,Xm,e.cache.create(),e.serializer)}const oT=function(){return JSON.stringify(arguments)};var aT=class{constructor(){this.cache=Object.create(null)}get(t){return this.cache[t]}set(t,e){this.cache[t]=e}};const lT={create:function(){return new aT}},Mc={variadic:sT},cT=/(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;function uT(t){const e={};return t.replace(cT,n=>{const r=n.length;switch(n[0]){case"G":e.era=r===4?"long":r===5?"narrow":"short";break;case"y":e.year=r===2?"2-digit":"numeric";break;case"Y":case"u":case"U":case"r":throw new RangeError("`Y/u/U/r` (year) patterns are not supported, use `y` instead");case"q":case"Q":throw new RangeError("`q/Q` (quarter) patterns are not supported");case"M":case"L":e.month=["numeric","2-digit","short","long","narrow"][r-1];break;case"w":case"W":throw new RangeError("`w/W` (week) patterns are not supported");case"d":e.day=["numeric","2-digit"][r-1];break;case"D":case"F":case"g":throw new RangeError("`D/F/g` (day) patterns are not supported, use `d` instead");case"E":e.weekday=r===4?"long":r===5?"narrow":"short";break;case"e":if(r<4)throw new RangeError("`e..eee` (weekday) patterns are not supported");e.weekday=["short","long","narrow","short"][r-3];break;case"c":if(r<4)throw new RangeError("`c..ccc` (weekday) patterns are not supported");e.weekday=["short","long","narrow","short"][r-3];break;case"a":e.hour12=!0;break;case"b":case"B":throw new RangeError("`b/B` (period) patterns are not supported, use `a` instead");case"h":e.hourCycle="h12",e.hour=["numeric","2-digit"][r-1];break;case"H":e.hourCycle="h23",e.hour=["numeric","2-digit"][r-1];break;case"K":e.hourCycle="h11",e.hour=["numeric","2-digit"][r-1];break;case"k":e.hourCycle="h24",e.hour=["numeric","2-digit"][r-1];break;case"j":case"J":case"C":throw new RangeError("`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead");case"m":e.minute=["numeric","2-digit"][r-1];break;case"s":e.second=["numeric","2-digit"][r-1];break;case"S":case"A":throw new RangeError("`S/A` (second) patterns are not supported, use `s` instead");case"z":e.timeZoneName=r<4?"short":"long";break;case"Z":case"O":case"v":case"V":case"X":case"x":throw new RangeError("`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead")}return""}),e}const dT=/[\t-\r \x85\u200E\u200F\u2028\u2029]/i;function fT(t){if(t.length===0)throw new Error("Number skeleton cannot be empty");const e=t.split(dT).filter(r=>r.length>0),n=[];for(const r of e){let i=r.split("/");if(i.length===0)throw new Error("Invalid number skeleton");const[s,...o]=i;for(const a of o)if(a.length===0)throw new Error("Invalid number skeleton");n.push({stem:s,options:o})}return n}function hT(t){return t.replace(/^(.*?)-/,"")}const Rh=/^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g,Qm=/^(@+)?(\+|#+)?[rs]?$/g,pT=/(\*)(0+)|(#+)(0+)|(0+)/g,ev=/^(0+)$/;function Ah(t){const e={};return t[t.length-1]==="r"?e.roundingPriority="morePrecision":t[t.length-1]==="s"&&(e.roundingPriority="lessPrecision"),t.replace(Qm,function(n,r,i){return typeof i!="string"?(e.minimumSignificantDigits=r.length,e.maximumSignificantDigits=r.length):i==="+"?e.minimumSignificantDigits=r.length:r[0]==="#"?e.maximumSignificantDigits=r.length:(e.minimumSignificantDigits=r.length,e.maximumSignificantDigits=r.length+(typeof i=="string"?i.length:0)),""}),e}function tv(t){switch(t){case"sign-auto":return{signDisplay:"auto"};case"sign-accounting":case"()":return{currencySign:"accounting"};case"sign-always":case"+!":return{signDisplay:"always"};case"sign-accounting-always":case"()!":return{signDisplay:"always",currencySign:"accounting"};case"sign-except-zero":case"+?":return{signDisplay:"exceptZero"};case"sign-accounting-except-zero":case"()?":return{signDisplay:"exceptZero",currencySign:"accounting"};case"sign-never":case"+_":return{signDisplay:"never"}}}function gT(t){let e;if(t[0]==="E"&&t[1]==="E"?(e={notation:"engineering"},t=t.slice(2)):t[0]==="E"&&(e={notation:"scientific"},t=t.slice(1)),e){const n=t.slice(0,2);if(n==="+!"?(e.signDisplay="always",t=t.slice(2)):n==="+?"&&(e.signDisplay="exceptZero",t=t.slice(2)),!ev.test(t))throw new Error("Malformed concise eng/scientific notation");e.minimumIntegerDigits=t.length}return e}function Oh(t){const e={},n=tv(t);return n||e}function mT(t){let e={};for(const n of t){switch(n.stem){case"percent":case"%":e.style="percent";continue;case"%x100":e.style="percent",e.scale=100;continue;case"currency":e.style="currency",e.currency=n.options[0];continue;case"group-off":case",_":e.useGrouping=!1;continue;case"precision-integer":case".":e.maximumFractionDigits=0;continue;case"measure-unit":case"unit":e.style="unit",e.unit=hT(n.options[0]);continue;case"compact-short":case"K":e.notation="compact",e.compactDisplay="short";continue;case"compact-long":case"KK":e.notation="compact",e.compactDisplay="long";continue;case"scientific":e={...e,notation:"scientific",...n.options.reduce((s,o)=>({...s,...Oh(o)}),{})};continue;case"engineering":e={...e,notation:"engineering",...n.options.reduce((s,o)=>({...s,...Oh(o)}),{})};continue;case"notation-simple":e.notation="standard";continue;case"unit-width-narrow":e.currencyDisplay="narrowSymbol",e.unitDisplay="narrow";continue;case"unit-width-short":e.currencyDisplay="code",e.unitDisplay="short";continue;case"unit-width-full-name":e.currencyDisplay="name",e.unitDisplay="long";continue;case"unit-width-iso-code":e.currencyDisplay="symbol";continue;case"scale":e.scale=parseFloat(n.options[0]);continue;case"rounding-mode-floor":e.roundingMode="floor";continue;case"rounding-mode-ceiling":e.roundingMode="ceil";continue;case"rounding-mode-down":e.roundingMode="trunc";continue;case"rounding-mode-up":e.roundingMode="expand";continue;case"rounding-mode-half-even":e.roundingMode="halfEven";continue;case"rounding-mode-half-down":e.roundingMode="halfTrunc";continue;case"rounding-mode-half-up":e.roundingMode="halfExpand";continue;case"integer-width":if(n.options.length>1)throw new RangeError("integer-width stems only accept a single optional option");n.options[0].replace(pT,function(s,o,a,l,c,u){if(o)e.minimumIntegerDigits=a.length;else{if(l&&c)throw new Error("We currently do not support maximum integer digits");if(u)throw new Error("We currently do not support exact integer digits")}return""});continue}if(ev.test(n.stem)){e.minimumIntegerDigits=n.stem.length;continue}if(Rh.test(n.stem)){if(n.options.length>1)throw new RangeError("Fraction-precision stems only accept a single optional option");n.stem.replace(Rh,function(o,a,l,c,u,f){return l==="*"?e.minimumFractionDigits=a.length:c&&c[0]==="#"?e.maximumFractionDigits=c.length:u&&f?(e.minimumFractionDigits=u.length,e.maximumFractionDigits=u.length+f.length):(e.minimumFractionDigits=a.length,e.maximumFractionDigits=a.length),""});const s=n.options[0];s==="w"?e={...e,trailingZeroDisplay:"stripIfInteger"}:s&&(e={...e,...Ah(s)});continue}if(Qm.test(n.stem)){e={...e,...Ah(n.stem)};continue}const r=tv(n.stem);r&&(e={...e,...r});const i=gT(n.stem);i&&(e={...e,...i})}return e}let vT=(function(t){return t[t.EXPECT_ARGUMENT_CLOSING_BRACE=1]="EXPECT_ARGUMENT_CLOSING_BRACE",t[t.EMPTY_ARGUMENT=2]="EMPTY_ARGUMENT",t[t.MALFORMED_ARGUMENT=3]="MALFORMED_ARGUMENT",t[t.EXPECT_ARGUMENT_TYPE=4]="EXPECT_ARGUMENT_TYPE",t[t.INVALID_ARGUMENT_TYPE=5]="INVALID_ARGUMENT_TYPE",t[t.EXPECT_ARGUMENT_STYLE=6]="EXPECT_ARGUMENT_STYLE",t[t.INVALID_NUMBER_SKELETON=7]="INVALID_NUMBER_SKELETON",t[t.INVALID_DATE_TIME_SKELETON=8]="INVALID_DATE_TIME_SKELETON",t[t.EXPECT_NUMBER_SKELETON=9]="EXPECT_NUMBER_SKELETON",t[t.EXPECT_DATE_TIME_SKELETON=10]="EXPECT_DATE_TIME_SKELETON",t[t.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE=11]="UNCLOSED_QUOTE_IN_ARGUMENT_STYLE",t[t.EXPECT_SELECT_ARGUMENT_OPTIONS=12]="EXPECT_SELECT_ARGUMENT_OPTIONS",t[t.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE=13]="EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE",t[t.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE=14]="INVALID_PLURAL_ARGUMENT_OFFSET_VALUE",t[t.EXPECT_SELECT_ARGUMENT_SELECTOR=15]="EXPECT_SELECT_ARGUMENT_SELECTOR",t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR=16]="EXPECT_PLURAL_ARGUMENT_SELECTOR",t[t.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT=17]="EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT",t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT=18]="EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT",t[t.INVALID_PLURAL_ARGUMENT_SELECTOR=19]="INVALID_PLURAL_ARGUMENT_SELECTOR",t[t.DUPLICATE_PLURAL_ARGUMENT_SELECTOR=20]="DUPLICATE_PLURAL_ARGUMENT_SELECTOR",t[t.DUPLICATE_SELECT_ARGUMENT_SELECTOR=21]="DUPLICATE_SELECT_ARGUMENT_SELECTOR",t[t.MISSING_OTHER_CLAUSE=22]="MISSING_OTHER_CLAUSE",t[t.INVALID_TAG=23]="INVALID_TAG",t[t.INVALID_TAG_NAME=25]="INVALID_TAG_NAME",t[t.UNMATCHED_CLOSING_TAG=26]="UNMATCHED_CLOSING_TAG",t[t.UNCLOSED_TAG=27]="UNCLOSED_TAG",t})({});function Mh(t){return t.type===0}function bT(t){return t.type===1}function nv(t){return t.type===2}function rv(t){return t.type===3}function iv(t){return t.type===4}function sv(t){return t.type===5}function ov(t){return t.type===6}function _T(t){return t.type===7}function av(t){return t.type===8}function lv(t){return!!(t&&typeof t=="object"&&t.type===0)}function ju(t){return!!(t&&typeof t=="object"&&t.type===1)}const cv=/[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/,Aa={"001":["H","h"],419:["h","H","hB","hb"],AC:["H","h","hb","hB"],AD:["H","hB"],AE:["h","hB","hb","H"],AF:["H","hb","hB","h"],AG:["h","hb","H","hB"],AI:["H","h","hb","hB"],AL:["h","H","hB"],AM:["H","hB"],AO:["H","hB"],AR:["h","H","hB","hb"],AS:["h","H"],AT:["H","hB"],AU:["h","hb","H","hB"],AW:["H","hB"],AX:["H"],AZ:["H","hB","h"],BA:["H","hB","h"],BB:["h","hb","H","hB"],BD:["h","hB","H"],BE:["H","hB"],BF:["H","hB"],BG:["H","hB","h"],BH:["h","hB","hb","H"],BI:["H","h"],BJ:["H","hB"],BL:["H","hB"],BM:["h","hb","H","hB"],BN:["hb","hB","h","H"],BO:["h","H","hB","hb"],BQ:["H"],BR:["H","hB"],BS:["h","hb","H","hB"],BT:["h","H"],BW:["H","h","hb","hB"],BY:["H","h"],BZ:["H","h","hb","hB"],CA:["h","hb","H","hB"],CC:["H","h","hb","hB"],CD:["hB","H"],CF:["H","h","hB"],CG:["H","hB"],CH:["H","hB","h"],CI:["H","hB"],CK:["H","h","hb","hB"],CL:["h","H","hB","hb"],CM:["H","h","hB"],CN:["H","hB","hb","h"],CO:["h","H","hB","hb"],CP:["H"],CR:["h","H","hB","hb"],CU:["h","H","hB","hb"],CV:["H","hB"],CW:["H","hB"],CX:["H","h","hb","hB"],CY:["h","H","hb","hB"],CZ:["H"],DE:["H","hB"],DG:["H","h","hb","hB"],DJ:["h","H"],DK:["H"],DM:["h","hb","H","hB"],DO:["h","H","hB","hb"],DZ:["h","hB","hb","H"],EA:["H","h","hB","hb"],EC:["h","H","hB","hb"],EE:["H","hB"],EG:["h","hB","hb","H"],EH:["h","hB","hb","H"],ER:["h","H"],ES:["H","hB","h","hb"],ET:["hB","hb","h","H"],FI:["H"],FJ:["h","hb","H","hB"],FK:["H","h","hb","hB"],FM:["h","hb","H","hB"],FO:["H","h"],FR:["H","hB"],GA:["H","hB"],GB:["H","h","hb","hB"],GD:["h","hb","H","hB"],GE:["H","hB","h"],GF:["H","hB"],GG:["H","h","hb","hB"],GH:["h","H"],GI:["H","h","hb","hB"],GL:["H","h"],GM:["h","hb","H","hB"],GN:["H","hB"],GP:["H","hB"],GQ:["H","hB","h","hb"],GR:["h","H","hb","hB"],GS:["H","h","hb","hB"],GT:["h","H","hB","hb"],GU:["h","hb","H","hB"],GW:["H","hB"],GY:["h","hb","H","hB"],HK:["h","hB","hb","H"],HN:["h","H","hB","hb"],HR:["H","hB"],HU:["H","h"],IC:["H","h","hB","hb"],ID:["H"],IE:["H","h","hb","hB"],IL:["H","hB"],IM:["H","h","hb","hB"],IN:["h","H"],IO:["H","h","hb","hB"],IQ:["h","hB","hb","H"],IR:["hB","H"],IS:["H"],IT:["H","hB"],JE:["H","h","hb","hB"],JM:["h","hb","H","hB"],JO:["h","hB","hb","H"],JP:["H","K","h"],KE:["hB","hb","H","h"],KG:["H","h","hB","hb"],KH:["hB","h","H","hb"],KI:["h","hb","H","hB"],KM:["H","h","hB","hb"],KN:["h","hb","H","hB"],KP:["h","H","hB","hb"],KR:["h","H","hB","hb"],KW:["h","hB","hb","H"],KY:["h","hb","H","hB"],KZ:["H","hB"],LA:["H","hb","hB","h"],LB:["h","hB","hb","H"],LC:["h","hb","H","hB"],LI:["H","hB","h"],LK:["H","h","hB","hb"],LR:["h","hb","H","hB"],LS:["h","H"],LT:["H","h","hb","hB"],LU:["H","h","hB"],LV:["H","hB","hb","h"],LY:["h","hB","hb","H"],MA:["H","h","hB","hb"],MC:["H","hB"],MD:["H","hB"],ME:["H","hB","h"],MF:["H","hB"],MG:["H","h"],MH:["h","hb","H","hB"],MK:["H","h","hb","hB"],ML:["H"],MM:["hB","hb","H","h"],MN:["H","h","hb","hB"],MO:["h","hB","hb","H"],MP:["h","hb","H","hB"],MQ:["H","hB"],MR:["h","hB","hb","H"],MS:["H","h","hb","hB"],MT:["H","h"],MU:["H","h"],MV:["H","h"],MW:["h","hb","H","hB"],MX:["h","H","hB","hb"],MY:["hb","hB","h","H"],MZ:["H","hB"],NA:["h","H","hB","hb"],NC:["H","hB"],NE:["H"],NF:["H","h","hb","hB"],NG:["H","h","hb","hB"],NI:["h","H","hB","hb"],NL:["H","hB"],NO:["H","h"],NP:["H","h","hB"],NR:["H","h","hb","hB"],NU:["H","h","hb","hB"],NZ:["h","hb","H","hB"],OM:["h","hB","hb","H"],PA:["h","H","hB","hb"],PE:["h","H","hB","hb"],PF:["H","h","hB"],PG:["h","H"],PH:["h","hB","hb","H"],PK:["h","hB","H"],PL:["H","h"],PM:["H","hB"],PN:["H","h","hb","hB"],PR:["h","H","hB","hb"],PS:["h","hB","hb","H"],PT:["H","hB"],PW:["h","H"],PY:["h","H","hB","hb"],QA:["h","hB","hb","H"],RE:["H","hB"],RO:["H","hB"],RS:["H","hB","h"],RU:["H"],RW:["H","h"],SA:["h","hB","hb","H"],SB:["h","hb","H","hB"],SC:["H","h","hB"],SD:["h","hB","hb","H"],SE:["H"],SG:["h","hb","H","hB"],SH:["H","h","hb","hB"],SI:["H","hB"],SJ:["H"],SK:["H"],SL:["h","hb","H","hB"],SM:["H","h","hB"],SN:["H","h","hB"],SO:["h","H"],SR:["H","hB"],SS:["h","hb","H","hB"],ST:["H","hB"],SV:["h","H","hB","hb"],SX:["H","h","hb","hB"],SY:["h","hB","hb","H"],SZ:["h","hb","H","hB"],TA:["H","h","hb","hB"],TC:["h","hb","H","hB"],TD:["h","H","hB"],TF:["H","h","hB"],TG:["H","hB"],TH:["H","h"],TJ:["H","h"],TL:["H","hB","hb","h"],TM:["H","h"],TN:["h","hB","hb","H"],TO:["h","H"],TR:["H","hB"],TT:["h","hb","H","hB"],TW:["hB","hb","h","H"],TZ:["hB","hb","H","h"],UA:["H","hB","h"],UG:["hB","hb","H","h"],UM:["h","hb","H","hB"],US:["h","hb","H","hB"],UY:["h","H","hB","hb"],UZ:["H","hB","h"],VA:["H","h","hB"],VC:["h","hb","H","hB"],VE:["h","H","hB","hb"],VG:["h","hb","H","hB"],VI:["h","hb","H","hB"],VN:["H","h"],VU:["h","H"],WF:["H","hB"],WS:["h","H"],XK:["H","hB","h"],YE:["h","hB","hb","H"],YT:["H","hB"],ZA:["H","h","hb","hB"],ZM:["h","hb","H","hB"],ZW:["H","h"],"af-ZA":["H","h","hB","hb"],"ar-001":["h","hB","hb","H"],"ca-ES":["H","h","hB"],"en-001":["h","hb","H","hB"],"en-HK":["h","hb","H","hB"],"en-IL":["H","h","hb","hB"],"en-MY":["h","hb","H","hB"],"es-BR":["H","h","hB","hb"],"es-ES":["H","h","hB","hb"],"es-GQ":["H","h","hB","hb"],"fr-CA":["H","h","hB"],"gl-ES":["H","h","hB"],"gu-IN":["hB","hb","h","H"],"hi-IN":["hB","h","H"],"it-CH":["H","h","hB"],"it-IT":["H","h","hB"],"kn-IN":["hB","h","H"],"ku-SY":["H","hB"],"ml-IN":["hB","h","H"],"mr-IN":["hB","hb","h","H"],"pa-IN":["hB","hb","h","H"],"ta-IN":["hB","h","hb","H"],"te-IN":["hB","h","H"],"zu-ZA":["H","hB","hb","h"]};function wT(t,e){let n="";for(let r=0;r<t.length;r++){const i=t.charAt(r);if(i==="j"){let s=0;for(;r+1<t.length&&t.charAt(r+1)===i;)s++,r++;let o=1+(s&1),a=s<2?1:3+(s>>1),l="a",c=yT(e);for((c=="H"||c=="k")&&(a=0);a-- >0;)n+=l;for(;o-- >0;)n=c+n}else i==="J"?n+="H":n+=i}return n}function yT(t){let e=t.hourCycle;if(e===void 0&&t.hourCycles&&t.hourCycles.length&&(e=t.hourCycles[0]),e)switch(e){case"h24":return"k";case"h23":return"H";case"h12":return"h";case"h11":return"K";default:throw new Error("Invalid hourCycle")}const n=t.language;let r;return n!=="root"&&(r=t.maximize().region),(Aa[r||""]||Aa[n||""]||Aa[`${n}-001`]||Aa["001"])[0]}const kT=new RegExp(`^${cv.source}*`),ET=new RegExp(`${cv.source}*$`);function ht(t,e){return{start:t,end:e}}const ST=!!Object.fromEntries,TT=!!String.prototype.trimStart,xT=!!String.prototype.trimEnd,Nh=ST?Object.fromEntries:function(e){const n={};for(const[r,i]of e)n[r]=i;return n},CT=TT?function(e){return e.trimStart()}:function(e){return e.replace(kT,"")},PT=xT?function(e){return e.trimEnd()}:function(e){return e.replace(ET,"")},Lh=new RegExp("([^\\p{White_Space}\\p{Pattern_Syntax}]*)","yu");function RT(t,e){return Lh.lastIndex=e,Lh.exec(t)[1]??""}function AT(t){if(t.length===0)return null;let e=1,n=1;for(let r=0;r<t.length;){const i=t.charCodeAt(r);switch(i){case 35:case 39:case 60:case 123:case 125:return null}if(i===10)e++,n=1,r++;else if(n++,i>=55296&&i<=56319&&r+1<t.length){const s=t.charCodeAt(r+1);r+=s>=56320&&s<=57343?2:1}else r++}return{offset:t.length,line:e,column:n}}var OT=class{constructor(t,e={}){this.message=t,this.position={offset:0,line:1,column:1},this.ignoreTag=!!e.ignoreTag,this.locale=e.locale,this.requiresOtherClause=!!e.requiresOtherClause,this.shouldParseSkeletons=!!e.shouldParseSkeletons}parse(){if(this.offset()!==0)throw Error("parser can only be used once");if(this.message.length>0){const t=this.message.charCodeAt(0);if(t!==35&&t!==39&&t!==60&&t!==123&&t!==125){const e=AT(this.message);if(e){const n=this.clonePosition();return this.position=e,{val:[{type:0,value:this.message,location:ht(n,this.clonePosition())}],err:null}}}}return this.parseMessage(0,"",!1)}parseMessage(t,e,n){let r=[];for(;!this.isEOF();){const i=this.char();if(i===123){const s=this.parseArgument(t,n);if(s.err)return s;r.push(s.val)}else{if(i===125&&t>0)break;if(i===35&&(e==="plural"||e==="selectordinal")){const s=this.clonePosition();this.bump(),r.push({type:7,location:ht(s,this.clonePosition())})}else if(i===60&&!this.ignoreTag&&this.peek()===47){if(n)break;return this.error(26,ht(this.clonePosition(),this.clonePosition()))}else if(i===60&&!this.ignoreTag&&$u(this.peek()||0)){const s=this.parseTag(t,e);if(s.err)return s;r.push(s.val)}else{const s=this.parseLiteral(t,e);if(s.err)return s;r.push(s.val)}}}return{val:r,err:null}}parseTag(t,e){const n=this.clonePosition();this.bump();const r=this.parseTagName();if(this.bumpSpace(),this.bumpIf("/>"))return{val:{type:0,value:`<${r}/>`,location:ht(n,this.clonePosition())},err:null};if(this.bumpIf(">")){const i=this.parseMessage(t+1,e,!0);if(i.err)return i;const s=i.val,o=this.clonePosition();if(this.bumpIf("</")){if(this.isEOF()||!$u(this.char()))return this.error(23,ht(o,this.clonePosition()));const a=this.clonePosition();return r!==this.parseTagName()?this.error(26,ht(a,this.clonePosition())):(this.bumpSpace(),this.bumpIf(">")?{val:{type:8,value:r,children:s,location:ht(n,this.clonePosition())},err:null}:this.error(23,ht(o,this.clonePosition())))}else return this.error(27,ht(n,this.clonePosition()))}else return this.error(23,ht(n,this.clonePosition()))}parseTagName(){const t=this.offset();for(this.bump();!this.isEOF()&&NT(this.char());)this.bump();return this.message.slice(t,this.offset())}parseLiteral(t,e){const n=this.clonePosition();let r="";for(;;){const s=this.tryParseQuote(e);if(s){r+=s;continue}const o=this.tryParseUnquoted(t,e);if(o){r+=o;continue}const a=this.tryParseLeftAngleBracket();if(a){r+=a;continue}break}const i=ht(n,this.clonePosition());return{val:{type:0,value:r,location:i},err:null}}tryParseLeftAngleBracket(){return!this.isEOF()&&this.char()===60&&(this.ignoreTag||!MT(this.peek()||0))?(this.bump(),"<"):null}tryParseQuote(t){if(this.isEOF()||this.char()!==39)return null;switch(this.peek()){case 39:return this.bump(),this.bump(),"'";case 123:case 60:case 62:case 125:break;case 35:if(t==="plural"||t==="selectordinal")break;return null;default:return null}this.bump();const e=[this.char()];for(this.bump();!this.isEOF();){const n=this.char();if(n===39)if(this.peek()===39)e.push(39),this.bump();else{this.bump();break}else e.push(n);this.bump()}return String.fromCodePoint(...e)}tryParseUnquoted(t,e){if(this.isEOF())return null;const n=this.char();return n===60||n===123||n===35&&(e==="plural"||e==="selectordinal")||n===125&&t>0?null:(this.bump(),String.fromCodePoint(n))}parseArgument(t,e){const n=this.clonePosition();if(this.bump(),this.bumpSpace(),this.isEOF())return this.error(1,ht(n,this.clonePosition()));if(this.char()===125)return this.bump(),this.error(2,ht(n,this.clonePosition()));let r=this.parseIdentifierIfPossible().value;if(!r)return this.error(3,ht(n,this.clonePosition()));if(this.bumpSpace(),this.isEOF())return this.error(1,ht(n,this.clonePosition()));switch(this.char()){case 125:return this.bump(),{val:{type:1,value:r,location:ht(n,this.clonePosition())},err:null};case 44:return this.bump(),this.bumpSpace(),this.isEOF()?this.error(1,ht(n,this.clonePosition())):this.parseArgumentOptions(t,e,r,n);default:return this.error(3,ht(n,this.clonePosition()))}}parseIdentifierIfPossible(){const t=this.clonePosition(),e=this.offset(),n=RT(this.message,e),r=e+n.length;return this.bumpTo(r),{value:n,location:ht(t,this.clonePosition())}}parseArgumentOptions(t,e,n,r){let i=this.clonePosition(),s=this.parseIdentifierIfPossible().value,o=this.clonePosition();switch(s){case"":return this.error(4,ht(i,o));case"number":case"date":case"time":{this.bumpSpace();let a=null;if(this.bumpIf(",")){this.bumpSpace();const u=this.clonePosition(),f=this.parseSimpleArgStyleIfPossible();if(f.err)return f;const h=PT(f.val);if(h.length===0)return this.error(6,ht(this.clonePosition(),this.clonePosition()));a={style:h,styleLocation:ht(u,this.clonePosition())}}const l=this.tryParseArgumentClose(r);if(l.err)return l;const c=ht(r,this.clonePosition());if(a&&a.style.startsWith("::")){let u=CT(a.style.slice(2));if(s==="number"){const f=this.parseNumberSkeletonFromString(u,a.styleLocation);return f.err?f:{val:{type:2,value:n,location:c,style:f.val},err:null}}else{if(u.length===0)return this.error(10,c);let f=u;this.locale&&(f=wT(u,this.locale));const h={type:1,pattern:f,location:a.styleLocation,parsedOptions:this.shouldParseSkeletons?uT(f):{}};return{val:{type:s==="date"?3:4,value:n,location:c,style:h},err:null}}}return{val:{type:s==="number"?2:s==="date"?3:4,value:n,location:c,style:(a==null?void 0:a.style)??null},err:null}}case"plural":case"selectordinal":case"select":{const a=this.clonePosition();if(this.bumpSpace(),!this.bumpIf(","))return this.error(12,ht(a,{...a}));this.bumpSpace();let l=this.parseIdentifierIfPossible(),c=0;if(s!=="select"&&l.value==="offset"){if(!this.bumpIf(":"))return this.error(13,ht(this.clonePosition(),this.clonePosition()));this.bumpSpace();const p=this.tryParseDecimalInteger(13,14);if(p.err)return p;this.bumpSpace(),l=this.parseIdentifierIfPossible(),c=p.val}const u=this.tryParsePluralOrSelectOptions(t,s,e,l);if(u.err)return u;const f=this.tryParseArgumentClose(r);if(f.err)return f;const h=ht(r,this.clonePosition());return s==="select"?{val:{type:5,value:n,options:Nh(u.val),location:h},err:null}:{val:{type:6,value:n,options:Nh(u.val),offset:c,pluralType:s==="plural"?"cardinal":"ordinal",location:h},err:null}}default:return this.error(5,ht(i,o))}}tryParseArgumentClose(t){return this.isEOF()||this.char()!==125?this.error(1,ht(t,this.clonePosition())):(this.bump(),{val:!0,err:null})}parseSimpleArgStyleIfPossible(){let t=0;const e=this.clonePosition();for(;!this.isEOF();)switch(this.char()){case 39:{this.bump();let n=this.clonePosition();if(!this.bumpUntil("'"))return this.error(11,ht(n,this.clonePosition()));this.bump();break}case 123:t+=1,this.bump();break;case 125:if(t>0)t-=1;else return{val:this.message.slice(e.offset,this.offset()),err:null};break;default:this.bump();break}return{val:this.message.slice(e.offset,this.offset()),err:null}}parseNumberSkeletonFromString(t,e){let n=[];try{n=fT(t)}catch{return this.error(7,e)}return{val:{type:0,tokens:n,location:e,parsedOptions:this.shouldParseSkeletons?mT(n):{}},err:null}}tryParsePluralOrSelectOptions(t,e,n,r){let i=!1;const s=[],o=new Set;let{value:a,location:l}=r;for(;;){if(a.length===0){const h=this.clonePosition();if(e!=="select"&&this.bumpIf("=")){const p=this.tryParseDecimalInteger(16,19);if(p.err)return p;l=ht(h,this.clonePosition()),a=this.message.slice(h.offset,this.offset())}else break}if(o.has(a))return this.error(e==="select"?21:20,l);a==="other"&&(i=!0),this.bumpSpace();const c=this.clonePosition();if(!this.bumpIf("{"))return this.error(e==="select"?17:18,ht(this.clonePosition(),this.clonePosition()));const u=this.parseMessage(t+1,e,n);if(u.err)return u;const f=this.tryParseArgumentClose(c);if(f.err)return f;s.push([a,{value:u.val,location:ht(c,this.clonePosition())}]),o.add(a),this.bumpSpace(),{value:a,location:l}=this.parseIdentifierIfPossible()}return s.length===0?this.error(e==="select"?15:16,ht(this.clonePosition(),this.clonePosition())):this.requiresOtherClause&&!i?this.error(22,ht(this.clonePosition(),this.clonePosition())):{val:s,err:null}}tryParseDecimalInteger(t,e){let n=1;const r=this.clonePosition();this.bumpIf("+")||this.bumpIf("-")&&(n=-1);let i=!1,s=0;for(;!this.isEOF();){const a=this.char();if(a>=48&&a<=57)i=!0,s=s*10+(a-48),this.bump();else break}const o=ht(r,this.clonePosition());return i?(s*=n,Number.isSafeInteger(s)?{val:s,err:null}:this.error(e,o)):this.error(t,o)}offset(){return this.position.offset}isEOF(){return this.offset()===this.message.length}clonePosition(){return{offset:this.position.offset,line:this.position.line,column:this.position.column}}char(){const t=this.position.offset;if(t>=this.message.length)throw Error("out of bound");const e=this.message.codePointAt(t);if(e===void 0)throw Error(`Offset ${t} is at invalid UTF-16 code unit boundary`);return e}error(t,e){return{val:null,err:{kind:t,message:this.message,location:e}}}bump(){if(this.isEOF())return;const t=this.char();t===10?(this.position.line+=1,this.position.column=1,this.position.offset+=1):(this.position.column+=1,this.position.offset+=t<65536?1:2)}bumpIf(t){if(this.message.startsWith(t,this.offset())){for(let e=0;e<t.length;e++)this.bump();return!0}return!1}bumpUntil(t){const e=this.offset(),n=this.message.indexOf(t,e);return n>=0?(this.bumpTo(n),!0):(this.bumpTo(this.message.length),!1)}bumpTo(t){if(this.offset()>t)throw Error(`targetOffset ${t} must be greater than or equal to the current offset ${this.offset()}`);for(t=Math.min(t,this.message.length);;){const e=this.offset();if(e===t)break;if(e>t)throw Error(`targetOffset ${t} is at invalid UTF-16 code unit boundary`);if(this.bump(),this.isEOF())break}}bumpSpace(){for(;!this.isEOF()&&LT(this.char());)this.bump()}peek(){if(this.isEOF())return null;const t=this.char(),e=this.offset();return this.message.charCodeAt(e+(t>=65536?2:1))??null}};function $u(t){return t>=97&&t<=122||t>=65&&t<=90}function MT(t){return $u(t)||t===47}function NT(t){return t===45||t===46||t>=48&&t<=57||t===95||t>=97&&t<=122||t>=65&&t<=90||t==183||t>=192&&t<=214||t>=216&&t<=246||t>=248&&t<=893||t>=895&&t<=8191||t>=8204&&t<=8205||t>=8255&&t<=8256||t>=8304&&t<=8591||t>=11264&&t<=12271||t>=12289&&t<=55295||t>=63744&&t<=64975||t>=65008&&t<=65533||t>=65536&&t<=983039}function LT(t){return t>=9&&t<=13||t===32||t===133||t>=8206&&t<=8207||t===8232||t===8233}function Fu(t){t.forEach(e=>{if(delete e.location,sv(e)||ov(e))for(const n in e.options)delete e.options[n].location,Fu(e.options[n].value);else nv(e)&&lv(e.style)||(rv(e)||iv(e))&&ju(e.style)?delete e.style.location:av(e)&&Fu(e.children)})}function IT(t,e={}){e={shouldParseSkeletons:!0,requiresOtherClause:!0,...e};const n=new OT(t,e).parse();if(n.err){const r=SyntaxError(vT[n.err.kind]);throw r.location=n.err.location,r.originalMessage=n.err.message,r}return e!=null&&e.captureLocation||Fu(n.val),n.val}var Xl=class extends Error{constructor(t,e,n){super(t),this.code=e,this.originalMessage=n}toString(){return`[formatjs Error: ${this.code}] ${this.message}`}},Ih=class extends Xl{constructor(t,e,n,r){super(`Invalid values for "${t}": "${e}". Options are "${Object.keys(n).join('", "')}"`,"INVALID_VALUE",r)}},zT=class extends Xl{constructor(t,e,n){super(`Value for "${t}" must be of type ${e}`,"INVALID_VALUE",n)}},DT=class extends Xl{constructor(t,e){super(`The intl string context variable "${t}" was not provided to the string "${e}"`,"MISSING_VALUE",e)}};function HT(t){return t.length<2?t:t.reduce((e,n)=>{const r=e[e.length-1];return!r||r.type!==0||n.type!==0?e.push(n):r.value+=n.value,e},[])}function BT(t){return typeof t=="function"}function Ya(t,e,n,r,i,s,o){if(t.length===1&&Mh(t[0]))return[{type:0,value:t[0].value}];const a=[];for(const l of t){if(Mh(l)){a.push({type:0,value:l.value});continue}if(_T(l)){typeof s=="number"&&a.push({type:0,value:n.getNumberFormat(e).format(s)});continue}const{value:c}=l;if(!(i&&c in i))throw new DT(c,o);let u=i[c];if(bT(l)){(!u||typeof u=="string"||typeof u=="number"||typeof u=="bigint")&&(u=typeof u=="string"||typeof u=="number"||typeof u=="bigint"?String(u):""),a.push({type:typeof u=="string"?0:1,value:u});continue}if(rv(l)){const f=typeof l.style=="string"?r.date[l.style]:ju(l.style)?l.style.parsedOptions:void 0;a.push({type:0,value:n.getDateTimeFormat(e,f).format(u)});continue}if(iv(l)){const f=typeof l.style=="string"?r.time[l.style]:ju(l.style)?l.style.parsedOptions:r.time.medium;a.push({type:0,value:n.getDateTimeFormat(e,f).format(u)});continue}if(nv(l)){const f=typeof l.style=="string"?r.number[l.style]:lv(l.style)?l.style.parsedOptions:void 0;if(f&&f.scale){const h=f.scale||1;if(typeof u=="bigint"){if(!Number.isInteger(h))throw new TypeError(`Cannot apply fractional scale ${h} to bigint value. Scale must be an integer when formatting bigint.`);u=u*BigInt(h)}else u=u*h}a.push({type:0,value:n.getNumberFormat(e,f).format(u)});continue}if(av(l)){const{children:f,value:h}=l,p=i[h];if(!BT(p))throw new zT(h,"function",o);let g=p(Ya(f,e,n,r,i,s).map(m=>m.value));Array.isArray(g)||(g=[g]),a.push(...g.map(m=>({type:typeof m=="string"?0:1,value:m})))}if(sv(l)){const f=u,h=(Object.prototype.hasOwnProperty.call(l.options,f)?l.options[f]:void 0)||l.options.other;if(!h)throw new Ih(l.value,u,Object.keys(l.options),o);a.push(...Ya(h.value,e,n,r,i));continue}if(ov(l)){const f=`=${u}`;let h=Object.prototype.hasOwnProperty.call(l.options,f)?l.options[f]:void 0;if(!h){if(!Intl.PluralRules)throw new Xl(`Intl.PluralRules is not available in this environment.
67
+ Try polyfilling it using "@formatjs/intl-pluralrules"
68
+ `,"MISSING_INTL_API",o);const g=typeof u=="bigint"?Number(u):u,m=n.getPluralRules(e,{type:l.pluralType}).select(g-(l.offset||0));h=(Object.prototype.hasOwnProperty.call(l.options,m)?l.options[m]:void 0)||l.options.other}if(!h)throw new Ih(l.value,u,Object.keys(l.options),o);const p=typeof u=="bigint"?Number(u):u;a.push(...Ya(h.value,e,n,r,i,p-(l.offset||0)));continue}}return HT(a)}function UT(t,e){return e?{...t,...e,...Object.keys(t).reduce((n,r)=>(n[r]={...t[r],...e[r]},n),{})}:t}function jT(t,e){return e?Object.keys(t).reduce((n,r)=>(n[r]=UT(t[r],e[r]),n),{...t}):t}function Nc(t){return{create(){return{get(e){return t[e]},set(e,n){t[e]=n}}}}}function $T(t={number:{},dateTime:{},pluralRules:{}}){return{getNumberFormat:Oc((...e)=>new Intl.NumberFormat(...e),{cache:Nc(t.number),strategy:Mc.variadic}),getDateTimeFormat:Oc((...e)=>new Intl.DateTimeFormat(...e),{cache:Nc(t.dateTime),strategy:Mc.variadic}),getPluralRules:Oc((...e)=>new Intl.PluralRules(...e),{cache:Nc(t.pluralRules),strategy:Mc.variadic})}}var gn,FT=(gn=class{constructor(e,n=gn.defaultLocale,r,i){if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=s=>{const o=this.formatToParts(s);if(o.length===1)return o[0].value;const a=o.reduce((l,c)=>(!l.length||c.type!==0||typeof l[l.length-1]!="string"?l.push(c.value):l[l.length-1]+=c.value,l),[]);return a.length<=1?a[0]||"":a},this.formatToParts=s=>Ya(this.ast,this.locales,this.formatters,this.formats,s,void 0,this.message),this.resolvedOptions=()=>{var s;return{locale:((s=this.resolvedLocale)==null?void 0:s.toString())||Intl.NumberFormat.supportedLocalesOf(this.locales)[0]}},this.getAst=()=>this.ast,this.locales=n,this.resolvedLocale=gn.resolveLocale(n),typeof e=="string"){if(this.message=e,!gn.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");const{...s}=i||{};this.ast=gn.__parse(e,{...s,locale:this.resolvedLocale})}else this.ast=e;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=jT(gn.formats,r),this.formatters=i&&i.formatters||$T(this.formatterCache)}static get defaultLocale(){return gn.memoizedDefaultLocale||(gn.memoizedDefaultLocale=new Intl.NumberFormat().resolvedOptions().locale),gn.memoizedDefaultLocale}},gn.memoizedDefaultLocale=null,gn.resolveLocale=e=>{if(typeof Intl.Locale>"u")return;const n=Intl.NumberFormat.supportedLocalesOf(e);return n.length>0?new Intl.Locale(n[0]):new Intl.Locale(typeof e=="string"?e:e[0])},gn.__parse=IT,gn.formats={number:{integer:{maximumFractionDigits:0},currency:{style:"currency"},percent:{style:"percent"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},gn),GT=FT;function Do(t){return t==="en-XA"?"en":t}function Wd(t,e,n){if(e===void 0)return t;try{const r=new GT(t,Do(n)).format(e);return typeof r=="string"?r:String(r)}catch{return t}}const qd=["persistent-rci-session:read","persistent-rci-session:write"],uv=Cn(qd),dv=mi([uv,tT]),VT=t=>qd.includes(t);function ZT(t){const e=t.replace("#",""),n=e.length===3?e.split("").map(r=>r+r).join(""):e;return[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)]}function Lc(t){const e=t/255;return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function zh(t){const[e,n,r]=ZT(t);return .2126*Lc(e)+.7152*Lc(n)+.0722*Lc(r)}function Ao(t,e){const n=zh(t),r=zh(e),i=Math.max(n,r),s=Math.min(n,r);return(i+.05)/(s+.05)}const Kd=[{token:"bg",cssVar:"--mndw-bg"},{token:"surface",cssVar:"--mndw-surface"},{token:"surfaceRaised",cssVar:"--mndw-surface-raised"},{token:"border",cssVar:"--mndw-border"},{token:"textSubtle",cssVar:"--mndw-text-subtle"},{token:"textMuted",cssVar:"--mndw-text-muted"},{token:"text",cssVar:"--mndw-text"},{token:"accent",cssVar:"--mndw-accent"},{token:"accentHover",cssVar:"--mndw-accent-hover"},{token:"accentContrast",cssVar:"--mndw-accent-contrast"},{token:"danger",cssVar:"--mndw-danger"},{token:"dangerBg",cssVar:"--mndw-danger-bg"},{token:"success",cssVar:"--mndw-success"},{token:"successBg",cssVar:"--mndw-success-bg"},{token:"warning",cssVar:"--mndw-warning"},{token:"warningBg",cssVar:"--mndw-warning-bg"},{token:"info",cssVar:"--mndw-info"},{token:"infoBg",cssVar:"--mndw-info-bg"},{token:"focusRing",cssVar:"--mndw-focus-ring"},{token:"surfaceHover",cssVar:"--mndw-surface-hover"},{token:"controlHover",cssVar:"--mndw-control-hover"},{token:"shadowColor",cssVar:"--mndw-shadow-color"}],WT=[{fg:"text",bg:"surface",min:4.5},{fg:"text",bg:"bg",min:4.5},{fg:"textMuted",bg:"surface",min:4.5},{fg:"textSubtle",bg:"surface",min:4.5},{fg:"border",bg:"surface",min:3},{fg:"accentContrast",bg:"accent",min:4.5},{fg:"danger",bg:"dangerBg",min:4.5},{fg:"text",bg:"surfaceRaised",min:4.5},{fg:"text",bg:"surfaceHover",min:4.5},{fg:"text",bg:"controlHover",min:4.5},{fg:"textSubtle",bg:"surfaceRaised",min:4.5},{fg:"textMuted",bg:"surfaceRaised",min:4.5},{fg:"border",bg:"surfaceRaised",min:3},{fg:"focusRing",bg:"surfaceRaised",min:3},{fg:"success",bg:"successBg",min:4.5},{fg:"warning",bg:"warningBg",min:4.5},{fg:"info",bg:"infoBg",min:4.5}];function qT(t,e={}){const n=e.selector??":root",r=i=>Kd.map(s=>` ${s.cssVar}: ${t[i][s.token]};`).join(`
69
+ `);return`${n},
70
+ ${n}[data-theme='dark'] {
71
+ ${r("dark")}
72
+ }
73
+
74
+ ${n}[data-theme='light'] {
75
+ ${r("light")}
76
+ }
77
+ `}const fv=(t,e)=>{if(typeof t=="number"){if(e===3)return{mode:"rgb",r:(t>>8&15|t>>4&240)/255,g:(t>>4&15|t&240)/255,b:(t&15|t<<4&240)/255};if(e===4)return{mode:"rgb",r:(t>>12&15|t>>8&240)/255,g:(t>>8&15|t>>4&240)/255,b:(t>>4&15|t&240)/255,alpha:(t&15|t<<4&240)/255};if(e===6)return{mode:"rgb",r:(t>>16&255)/255,g:(t>>8&255)/255,b:(t&255)/255};if(e===8)return{mode:"rgb",r:(t>>24&255)/255,g:(t>>16&255)/255,b:(t>>8&255)/255,alpha:(t&255)/255}}},KT={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},YT=t=>fv(KT[t.toLowerCase()],6),XT=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,JT=t=>{let e;return(e=t.match(XT))?fv(parseInt(e[1],16),e[1].length):void 0},wi="([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)",Oo=`${wi}%`,Yd=`(?:${wi}%|${wi})`,QT=`(?:${wi}(deg|grad|rad|turn)|${wi})`,Is="\\s*,\\s*",ex=new RegExp(`^rgba?\\(\\s*${wi}${Is}${wi}${Is}${wi}\\s*(?:,\\s*${Yd}\\s*)?\\)$`),tx=new RegExp(`^rgba?\\(\\s*${Oo}${Is}${Oo}${Is}${Oo}\\s*(?:,\\s*${Yd}\\s*)?\\)$`),nx=t=>{let e={mode:"rgb"},n;if(n=t.match(ex))n[1]!==void 0&&(e.r=n[1]/255),n[2]!==void 0&&(e.g=n[2]/255),n[3]!==void 0&&(e.b=n[3]/255);else if(n=t.match(tx))n[1]!==void 0&&(e.r=n[1]/100),n[2]!==void 0&&(e.g=n[2]/100),n[3]!==void 0&&(e.b=n[3]/100);else return;return n[4]!==void 0?e.alpha=Math.max(0,Math.min(1,n[4]/100)):n[5]!==void 0&&(e.alpha=Math.max(0,Math.min(1,+n[5]))),e},ml=(t,e)=>t===void 0?void 0:typeof t!="object"?dx(t):t.mode!==void 0?t:e?{...t,mode:e}:void 0,xi=(t="rgb")=>e=>(e=ml(e,t))!==void 0?e.mode===t?e:Ir[e.mode][t]?Ir[e.mode][t](e):t==="rgb"?Ir[e.mode].rgb(e):Ir.rgb[t](Ir[e.mode].rgb(e)):void 0,Ir={},hv={},vl=[],pv={},rx=t=>t,wt=t=>(Ir[t.mode]={...Ir[t.mode],...t.toMode},Object.keys(t.fromMode||{}).forEach(e=>{Ir[e]||(Ir[e]={}),Ir[e][t.mode]=t.fromMode[e]}),t.ranges||(t.ranges={}),t.difference||(t.difference={}),t.channels.forEach(e=>{if(t.ranges[e]===void 0&&(t.ranges[e]=[0,1]),!t.interpolate[e])throw new Error(`Missing interpolator for: ${e}`);typeof t.interpolate[e]=="function"&&(t.interpolate[e]={use:t.interpolate[e]}),t.interpolate[e].fixup||(t.interpolate[e].fixup=rx)}),hv[t.mode]=t,(t.parse||[]).forEach(e=>{ix(e,t.mode)}),xi(t.mode)),Jl=t=>hv[t],ix=(t,e)=>{if(typeof t=="string"){if(!e)throw new Error("'mode' required when 'parser' is a string");pv[t]=e}else typeof t=="function"&&vl.indexOf(t)<0&&vl.push(t)},Gu=/[^\x00-\x7F]|[a-zA-Z_]/,sx=/[^\x00-\x7F]|[-\w]/,ce={Function:"function",Ident:"ident",Number:"number",Percentage:"percentage",ParenClose:")",None:"none",Hue:"hue",Alpha:"alpha"};let Ve=0;function Oa(t){let e=t[Ve],n=t[Ve+1];return e==="-"||e==="+"?/\d/.test(n)||n==="."&&/\d/.test(t[Ve+2]):e==="."?/\d/.test(n):/\d/.test(e)}function Vu(t){if(Ve>=t.length)return!1;let e=t[Ve];if(Gu.test(e))return!0;if(e==="-"){if(t.length-Ve<2)return!1;let n=t[Ve+1];return!!(n==="-"||Gu.test(n))}return!1}const ox={deg:1,rad:180/Math.PI,grad:9/10,turn:360};function io(t){let e="";if((t[Ve]==="-"||t[Ve]==="+")&&(e+=t[Ve++]),e+=Ma(t),t[Ve]==="."&&/\d/.test(t[Ve+1])&&(e+=t[Ve++]+Ma(t)),(t[Ve]==="e"||t[Ve]==="E")&&((t[Ve+1]==="-"||t[Ve+1]==="+")&&/\d/.test(t[Ve+2])?e+=t[Ve++]+t[Ve++]+Ma(t):/\d/.test(t[Ve+1])&&(e+=t[Ve++]+Ma(t))),Vu(t)){let n=bl(t);return n==="deg"||n==="rad"||n==="turn"||n==="grad"?{type:ce.Hue,value:e*ox[n]}:void 0}return t[Ve]==="%"?(Ve++,{type:ce.Percentage,value:+e}):{type:ce.Number,value:+e}}function Ma(t){let e="";for(;/\d/.test(t[Ve]);)e+=t[Ve++];return e}function bl(t){let e="";for(;Ve<t.length&&sx.test(t[Ve]);)e+=t[Ve++];return e}function ax(t){let e=bl(t);return t[Ve]==="("?(Ve++,{type:ce.Function,value:e}):e==="none"?{type:ce.None,value:void 0}:{type:ce.Ident,value:e}}function lx(t=""){let e=t.trim(),n=[],r;for(Ve=0;Ve<e.length;){if(r=e[Ve++],r===`
78
+ `||r===" "||r===" "){for(;Ve<e.length&&(e[Ve]===`
79
+ `||e[Ve]===" "||e[Ve]===" ");)Ve++;continue}if(r===",")return;if(r===")"){n.push({type:ce.ParenClose});continue}if(r==="+"){if(Ve--,Oa(e)){n.push(io(e));continue}return}if(r==="-"){if(Ve--,Oa(e)){n.push(io(e));continue}if(Vu(e)){n.push({type:ce.Ident,value:bl(e)});continue}return}if(r==="."){if(Ve--,Oa(e)){n.push(io(e));continue}return}if(r==="/"){for(;Ve<e.length&&(e[Ve]===`
80
+ `||e[Ve]===" "||e[Ve]===" ");)Ve++;let i;if(Oa(e)&&(i=io(e),i.type!==ce.Hue)){n.push({type:ce.Alpha,value:i});continue}if(Vu(e)&&bl(e)==="none"){n.push({type:ce.Alpha,value:{type:ce.None,value:void 0}});continue}return}if(/\d/.test(r)){Ve--,n.push(io(e));continue}if(Gu.test(r)){Ve--,n.push(ax(e));continue}return}return n}function cx(t){t._i=0;let e=t[t._i++];if(!e||e.type!==ce.Function||e.value!=="color"||(e=t[t._i++],e.type!==ce.Ident))return;const n=pv[e.value];if(!n)return;const r={mode:n},i=gv(t,!1);if(!i)return;const s=Jl(n).channels;for(let o=0,a,l;o<s.length;o++)a=i[o],l=s[o],a.type!==ce.None&&(r[l]=a.type===ce.Number?a.value:a.value/100,l==="alpha"&&(r[l]=Math.max(0,Math.min(1,r[l]))));return r}function gv(t,e){const n=[];let r;for(;t._i<t.length;){if(r=t[t._i++],r.type===ce.None||r.type===ce.Number||r.type===ce.Alpha||r.type===ce.Percentage||e&&r.type===ce.Hue){n.push(r);continue}if(r.type===ce.ParenClose){if(t._i<t.length)return;continue}return}if(!(n.length<3||n.length>4)){if(n.length===4){if(n[3].type!==ce.Alpha)return;n[3]=n[3].value}return n.length===3&&n.push({type:ce.None,value:void 0}),n.every(i=>i.type!==ce.Alpha)?n:void 0}}function ux(t,e){t._i=0;let n=t[t._i++];if(!n||n.type!==ce.Function)return;let r=gv(t,e);if(r)return r.unshift(n.value),r}const dx=t=>{if(typeof t!="string")return;const e=lx(t),n=e?ux(e,!0):void 0;let r,i=0,s=vl.length;for(;i<s;)if((r=vl[i++](t,n))!==void 0)return r;return e?cx(e):void 0};function fx(t,e){if(!e||e[0]!=="rgb"&&e[0]!=="rgba")return;const n={mode:"rgb"},[,r,i,s,o]=e;if(!(r.type===ce.Hue||i.type===ce.Hue||s.type===ce.Hue))return r.type!==ce.None&&(n.r=r.type===ce.Number?r.value/255:r.value/100),i.type!==ce.None&&(n.g=i.type===ce.Number?i.value/255:i.value/100),s.type!==ce.None&&(n.b=s.type===ce.Number?s.value/255:s.value/100),o.type!==ce.None&&(n.alpha=Math.min(1,Math.max(0,o.type===ce.Number?o.value:o.value/100))),n}const hx=t=>t==="transparent"?{mode:"rgb",r:0,g:0,b:0,alpha:0}:void 0,px=(t,e,n)=>t+n*(e-t),gx=t=>{let e=[];for(let n=0;n<t.length-1;n++){let r=t[n],i=t[n+1];r===void 0&&i===void 0?e.push(void 0):r!==void 0&&i!==void 0?e.push([r,i]):e.push(r!==void 0?[r,r]:[i,i])}return e},mx=t=>e=>{let n=gx(e);return r=>{let i=r*n.length,s=r>=1?n.length-1:Math.max(Math.floor(i),0),o=n[s];return o===void 0?void 0:t(o[0],o[1],i-s)}},_e=mx(px),on=t=>{let e=!1,n=t.map(r=>r!==void 0?(e=!0,r):1);return e?n:t},Ks={mode:"rgb",channels:["r","g","b","alpha"],parse:[fx,JT,nx,YT,hx,"srgb"],serialize:"srgb",interpolate:{r:_e,g:_e,b:_e,alpha:{use:_e,fixup:on}},gamut:!0,white:{r:1,g:1,b:1},black:{r:0,g:0,b:0}},Ic=(t=0)=>Math.pow(Math.abs(t),563/256)*Math.sign(t),Dh=t=>{let e=Ic(t.r),n=Ic(t.g),r=Ic(t.b),i={mode:"xyz65",x:.5766690429101305*e+.1855582379065463*n+.1882286462349947*r,y:.297344975250536*e+.6273635662554661*n+.0752914584939979*r,z:.0270313613864123*e+.0706888525358272*n+.9913375368376386*r};return t.alpha!==void 0&&(i.alpha=t.alpha),i},zc=t=>Math.pow(Math.abs(t),256/563)*Math.sign(t),Hh=({x:t,y:e,z:n,alpha:r})=>{t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=0);let i={mode:"a98",r:zc(t*2.0415879038107465-e*.5650069742788597-.3447313507783297*n),g:zc(t*-.9692436362808798+e*1.8759675015077206+.0415550574071756*n),b:zc(t*.0134442806320312-e*.1183623922310184+1.0151749943912058*n)};return r!==void 0&&(i.alpha=r),i},Dc=(t=0)=>{const e=Math.abs(t);return e<=.04045?t/12.92:(Math.sign(t)||1)*Math.pow((e+.055)/1.055,2.4)},Ys=({r:t,g:e,b:n,alpha:r})=>{let i={mode:"lrgb",r:Dc(t),g:Dc(e),b:Dc(n)};return r!==void 0&&(i.alpha=r),i},Xi=t=>{let{r:e,g:n,b:r,alpha:i}=Ys(t),s={mode:"xyz65",x:.4123907992659593*e+.357584339383878*n+.1804807884018343*r,y:.2126390058715102*e+.715168678767756*n+.0721923153607337*r,z:.0193308187155918*e+.119194779794626*n+.9505321522496607*r};return i!==void 0&&(s.alpha=i),s},Hc=(t=0)=>{const e=Math.abs(t);return e>.0031308?(Math.sign(t)||1)*(1.055*Math.pow(e,1/2.4)-.055):t*12.92},Xs=({r:t,g:e,b:n,alpha:r},i="rgb")=>{let s={mode:i,r:Hc(t),g:Hc(e),b:Hc(n)};return r!==void 0&&(s.alpha=r),s},Ji=({x:t,y:e,z:n,alpha:r})=>{t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=0);let i=Xs({r:t*3.2409699419045226-e*1.537383177570094-.4986107602930034*n,g:t*-.9692436362808796+e*1.8759675015077204+.0415550574071756*n,b:t*.0556300796969936-e*.2039769588889765+1.0569715142428784*n});return r!==void 0&&(i.alpha=r),i},vx={...Ks,mode:"a98",parse:["a98-rgb"],serialize:"a98-rgb",fromMode:{rgb:t=>Hh(Xi(t)),xyz65:Hh},toMode:{rgb:t=>Ji(Dh(t)),xyz65:Dh}},wn=t=>(t=t%360)<0?t+360:t,bx=(t,e)=>t.map((n,r,i)=>{if(n===void 0)return n;let s=wn(n);return r===0||t[r-1]===void 0?s:e(s-wn(i[r-1]))}).reduce((n,r)=>!n.length||r===void 0||n[n.length-1]===void 0?(n.push(r),n):(n.push(r+n[n.length-1]),n),[]),oi=t=>bx(t,e=>Math.abs(e)<=180?e:e-360*Math.sign(e)),un=[-.14861,1.78277,-.29227,-.90649,1.97294,0],_x=Math.PI/180,wx=180/Math.PI;let Bh=un[3]*un[4],Uh=un[1]*un[4],jh=un[1]*un[2]-un[0]*un[3];const yx=({r:t,g:e,b:n,alpha:r})=>{t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=0);let i=(jh*n+t*Bh-e*Uh)/(jh+Bh-Uh),s=n-i,o=(un[4]*(e-i)-un[2]*s)/un[3],a={mode:"cubehelix",l:i,s:i===0||i===1?void 0:Math.sqrt(s*s+o*o)/(un[4]*i*(1-i))};return a.s&&(a.h=Math.atan2(o,s)*wx-120),r!==void 0&&(a.alpha=r),a},kx=({h:t,s:e,l:n,alpha:r})=>{let i={mode:"rgb"};t=(t===void 0?0:t+120)*_x,n===void 0&&(n=0);let s=e===void 0?0:e*n*(1-n),o=Math.cos(t),a=Math.sin(t);return i.r=n+s*(un[0]*o+un[1]*a),i.g=n+s*(un[2]*o+un[3]*a),i.b=n+s*(un[4]*o+un[5]*a),r!==void 0&&(i.alpha=r),i},Ql=(t,e)=>{if(t.h===void 0||e.h===void 0||!t.s||!e.s)return 0;let n=wn(t.h),r=wn(e.h),i=Math.sin((r-n+360)/2*Math.PI/180);return 2*Math.sqrt(t.s*e.s)*i},Ex=(t,e)=>{if(t.h===void 0||e.h===void 0)return 0;let n=wn(t.h),r=wn(e.h);return Math.abs(r-n)>180?n-(r-360*Math.sign(r-n)):r-n},ec=(t,e)=>{if(t.h===void 0||e.h===void 0||!t.c||!e.c)return 0;let n=wn(t.h),r=wn(e.h),i=Math.sin((r-n+360)/2*Math.PI/180);return 2*Math.sqrt(t.c*e.c)*i},ai=t=>{let e=t.reduce((r,i)=>{if(i!==void 0){let s=i*Math.PI/180;r.sin+=Math.sin(s),r.cos+=Math.cos(s)}return r},{sin:0,cos:0}),n=Math.atan2(e.sin,e.cos)*180/Math.PI;return n<0?360+n:n},Sx={mode:"cubehelix",channels:["h","s","l","alpha"],parse:["--cubehelix"],serialize:"--cubehelix",ranges:{h:[0,360],s:[0,4.614],l:[0,1]},fromMode:{rgb:yx},toMode:{rgb:kx},interpolate:{h:{use:_e,fixup:oi},s:_e,l:_e,alpha:{use:_e,fixup:on}},difference:{h:Ql},average:{h:ai}},Ci=({l:t,a:e,b:n,alpha:r},i="lch")=>{e===void 0&&(e=0),n===void 0&&(n=0);let s=Math.sqrt(e*e+n*n),o={mode:i,l:t,c:s};return s&&(o.h=wn(Math.atan2(n,e)*180/Math.PI)),r!==void 0&&(o.alpha=r),o},Pi=({l:t,c:e,h:n,alpha:r},i="lab")=>{n===void 0&&(n=0);let s={mode:i,l:t,a:e?e*Math.cos(n/180*Math.PI):0,b:e?e*Math.sin(n/180*Math.PI):0};return r!==void 0&&(s.alpha=r),s},mv=Math.pow(29,3)/Math.pow(3,3),vv=Math.pow(6,3)/Math.pow(29,3),Qt={X:.3457/.3585,Y:1,Z:(1-.3457-.3585)/.3585},ps={X:.3127/.329,Y:1,Z:(1-.3127-.329)/.329};let Bc=t=>Math.pow(t,3)>vv?Math.pow(t,3):(116*t-16)/mv;const bv=({l:t,a:e,b:n,alpha:r})=>{t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=0);let i=(t+16)/116,s=e/500+i,o=i-n/200,a={mode:"xyz65",x:Bc(s)*ps.X,y:Bc(i)*ps.Y,z:Bc(o)*ps.Z};return r!==void 0&&(a.alpha=r),a},tc=t=>Ji(bv(t)),Uc=t=>t>vv?Math.cbrt(t):(mv*t+16)/116,_v=({x:t,y:e,z:n,alpha:r})=>{t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=0);let i=Uc(t/ps.X),s=Uc(e/ps.Y),o=Uc(n/ps.Z),a={mode:"lab65",l:116*s-16,a:500*(i-s),b:200*(s-o)};return r!==void 0&&(a.alpha=r),a},nc=t=>{let e=_v(Xi(t));return t.r===t.b&&t.b===t.g&&(e.a=e.b=0),e},_l=1,wv=1,Ho=26/180*Math.PI,wl=Math.cos(Ho),yl=Math.sin(Ho),yv=100/Math.log(139/100),Zu=({l:t,c:e,h:n,alpha:r})=>{t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=0);let i={mode:"lab65",l:(Math.exp(t*_l/yv)-1)/.0039},s=(Math.exp(.0435*e*wv*_l)-1)/.075,o=s*Math.cos(n/180*Math.PI-Ho),a=s*Math.sin(n/180*Math.PI-Ho);return i.a=o*wl-a/.83*yl,i.b=o*yl+a/.83*wl,r!==void 0&&(i.alpha=r),i},Wu=({l:t,a:e,b:n,alpha:r})=>{t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=0);let i=e*wl+n*yl,s=.83*(n*wl-e*yl),o=Math.sqrt(i*i+s*s),a={mode:"dlch",l:yv/_l*Math.log(1+.0039*t),c:Math.log(1+.075*o)/(.0435*wv*_l)};return a.c&&(a.h=wn((Math.atan2(s,i)+Ho)/Math.PI*180)),r!==void 0&&(a.alpha=r),a},$h=t=>Zu(Ci(t,"dlch")),Fh=t=>Pi(Wu(t),"dlab"),Tx={mode:"dlab",parse:["--din99o-lab"],serialize:"--din99o-lab",toMode:{lab65:$h,rgb:t=>tc($h(t))},fromMode:{lab65:Fh,rgb:t=>Fh(nc(t))},channels:["l","a","b","alpha"],ranges:{l:[0,100],a:[-40.09,45.501],b:[-40.469,44.344]},interpolate:{l:_e,a:_e,b:_e,alpha:{use:_e,fixup:on}}},xx={mode:"dlch",parse:["--din99o-lch"],serialize:"--din99o-lch",toMode:{lab65:Zu,dlab:t=>Pi(t,"dlab"),rgb:t=>tc(Zu(t))},fromMode:{lab65:Wu,dlab:t=>Ci(t,"dlch"),rgb:t=>Wu(nc(t))},channels:["l","c","h","alpha"],ranges:{l:[0,100],c:[0,51.484],h:[0,360]},interpolate:{l:_e,c:_e,h:{use:_e,fixup:oi},alpha:{use:_e,fixup:on}},difference:{h:ec},average:{h:ai}};function Cx({h:t,s:e,i:n,alpha:r}){t=wn(t!==void 0?t:0),e===void 0&&(e=0),n===void 0&&(n=0);let i=Math.abs(t/60%2-1),s;switch(Math.floor(t/60)){case 0:s={r:n*(1+e*(3/(2-i)-1)),g:n*(1+e*(3*(1-i)/(2-i)-1)),b:n*(1-e)};break;case 1:s={r:n*(1+e*(3*(1-i)/(2-i)-1)),g:n*(1+e*(3/(2-i)-1)),b:n*(1-e)};break;case 2:s={r:n*(1-e),g:n*(1+e*(3/(2-i)-1)),b:n*(1+e*(3*(1-i)/(2-i)-1))};break;case 3:s={r:n*(1-e),g:n*(1+e*(3*(1-i)/(2-i)-1)),b:n*(1+e*(3/(2-i)-1))};break;case 4:s={r:n*(1+e*(3*(1-i)/(2-i)-1)),g:n*(1-e),b:n*(1+e*(3/(2-i)-1))};break;case 5:s={r:n*(1+e*(3/(2-i)-1)),g:n*(1-e),b:n*(1+e*(3*(1-i)/(2-i)-1))};break;default:s={r:n*(1-e),g:n*(1-e),b:n*(1-e)}}return s.mode="rgb",r!==void 0&&(s.alpha=r),s}function Px({r:t,g:e,b:n,alpha:r}){t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=0);let i=Math.max(t,e,n),s=Math.min(t,e,n),o={mode:"hsi",s:t+e+n===0?0:1-3*s/(t+e+n),i:(t+e+n)/3};return i-s!==0&&(o.h=(i===t?(e-n)/(i-s)+(e<n)*6:i===e?(n-t)/(i-s)+2:(t-e)/(i-s)+4)*60),r!==void 0&&(o.alpha=r),o}const Rx={mode:"hsi",toMode:{rgb:Cx},parse:["--hsi"],serialize:"--hsi",fromMode:{rgb:Px},channels:["h","s","i","alpha"],ranges:{h:[0,360]},gamut:"rgb",interpolate:{h:{use:_e,fixup:oi},s:_e,i:_e,alpha:{use:_e,fixup:on}},difference:{h:Ql},average:{h:ai}};function Ax({h:t,s:e,l:n,alpha:r}){t=wn(t!==void 0?t:0),e===void 0&&(e=0),n===void 0&&(n=0);let i=n+e*(n<.5?n:1-n),s=i-(i-n)*2*Math.abs(t/60%2-1),o;switch(Math.floor(t/60)){case 0:o={r:i,g:s,b:2*n-i};break;case 1:o={r:s,g:i,b:2*n-i};break;case 2:o={r:2*n-i,g:i,b:s};break;case 3:o={r:2*n-i,g:s,b:i};break;case 4:o={r:s,g:2*n-i,b:i};break;case 5:o={r:i,g:2*n-i,b:s};break;default:o={r:2*n-i,g:2*n-i,b:2*n-i}}return o.mode="rgb",r!==void 0&&(o.alpha=r),o}function Ox({r:t,g:e,b:n,alpha:r}){t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=0);let i=Math.max(t,e,n),s=Math.min(t,e,n),o={mode:"hsl",s:i===s?0:(i-s)/(1-Math.abs(i+s-1)),l:.5*(i+s)};return i-s!==0&&(o.h=(i===t?(e-n)/(i-s)+(e<n)*6:i===e?(n-t)/(i-s)+2:(t-e)/(i-s)+4)*60),r!==void 0&&(o.alpha=r),o}const Mx=(t,e)=>{switch(e){case"deg":return+t;case"rad":return t/Math.PI*180;case"grad":return t/10*9;case"turn":return t*360}},Nx=new RegExp(`^hsla?\\(\\s*${QT}${Is}${Oo}${Is}${Oo}\\s*(?:,\\s*${Yd}\\s*)?\\)$`),Lx=t=>{let e=t.match(Nx);if(!e)return;let n={mode:"hsl"};return e[3]!==void 0?n.h=+e[3]:e[1]!==void 0&&e[2]!==void 0&&(n.h=Mx(e[1],e[2])),e[4]!==void 0&&(n.s=Math.min(Math.max(0,e[4]/100),1)),e[5]!==void 0&&(n.l=Math.min(Math.max(0,e[5]/100),1)),e[6]!==void 0?n.alpha=Math.max(0,Math.min(1,e[6]/100)):e[7]!==void 0&&(n.alpha=Math.max(0,Math.min(1,+e[7]))),n};function Ix(t,e){if(!e||e[0]!=="hsl"&&e[0]!=="hsla")return;const n={mode:"hsl"},[,r,i,s,o]=e;if(r.type!==ce.None){if(r.type===ce.Percentage)return;n.h=r.value}if(i.type!==ce.None){if(i.type===ce.Hue)return;n.s=i.value/100}if(s.type!==ce.None){if(s.type===ce.Hue)return;n.l=s.value/100}return o.type!==ce.None&&(n.alpha=Math.min(1,Math.max(0,o.type===ce.Number?o.value:o.value/100))),n}const kv={mode:"hsl",toMode:{rgb:Ax},fromMode:{rgb:Ox},channels:["h","s","l","alpha"],ranges:{h:[0,360]},gamut:"rgb",parse:[Ix,Lx],serialize:t=>`hsl(${t.h!==void 0?t.h:"none"} ${t.s!==void 0?t.s*100+"%":"none"} ${t.l!==void 0?t.l*100+"%":"none"}${t.alpha<1?` / ${t.alpha}`:""})`,interpolate:{h:{use:_e,fixup:oi},s:_e,l:_e,alpha:{use:_e,fixup:on}},difference:{h:Ql},average:{h:ai}};function Ev({h:t,s:e,v:n,alpha:r}){t=wn(t!==void 0?t:0),e===void 0&&(e=0),n===void 0&&(n=0);let i=Math.abs(t/60%2-1),s;switch(Math.floor(t/60)){case 0:s={r:n,g:n*(1-e*i),b:n*(1-e)};break;case 1:s={r:n*(1-e*i),g:n,b:n*(1-e)};break;case 2:s={r:n*(1-e),g:n,b:n*(1-e*i)};break;case 3:s={r:n*(1-e),g:n*(1-e*i),b:n};break;case 4:s={r:n*(1-e*i),g:n*(1-e),b:n};break;case 5:s={r:n,g:n*(1-e),b:n*(1-e*i)};break;default:s={r:n*(1-e),g:n*(1-e),b:n*(1-e)}}return s.mode="rgb",r!==void 0&&(s.alpha=r),s}function Sv({r:t,g:e,b:n,alpha:r}){t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=0);let i=Math.max(t,e,n),s=Math.min(t,e,n),o={mode:"hsv",s:i===0?0:1-s/i,v:i};return i-s!==0&&(o.h=(i===t?(e-n)/(i-s)+(e<n)*6:i===e?(n-t)/(i-s)+2:(t-e)/(i-s)+4)*60),r!==void 0&&(o.alpha=r),o}const Tv={mode:"hsv",toMode:{rgb:Ev},parse:["--hsv"],serialize:"--hsv",fromMode:{rgb:Sv},channels:["h","s","v","alpha"],ranges:{h:[0,360]},gamut:"rgb",interpolate:{h:{use:_e,fixup:oi},s:_e,v:_e,alpha:{use:_e,fixup:on}},difference:{h:Ql},average:{h:ai}};function zx({h:t,w:e,b:n,alpha:r}){if(e===void 0&&(e=0),n===void 0&&(n=0),e+n>1){let i=e+n;e/=i,n/=i}return Ev({h:t,s:n===1?1:1-e/(1-n),v:1-n,alpha:r})}function Dx(t){let e=Sv(t);if(e===void 0)return;let n=e.s!==void 0?e.s:0,r=e.v!==void 0?e.v:0,i={mode:"hwb",w:(1-n)*r,b:1-r};return e.h!==void 0&&(i.h=e.h),e.alpha!==void 0&&(i.alpha=e.alpha),i}function Hx(t,e){if(!e||e[0]!=="hwb")return;const n={mode:"hwb"},[,r,i,s,o]=e;if(r.type!==ce.None){if(r.type===ce.Percentage)return;n.h=r.value}if(i.type!==ce.None){if(i.type===ce.Hue)return;n.w=i.value/100}if(s.type!==ce.None){if(s.type===ce.Hue)return;n.b=s.value/100}return o.type!==ce.None&&(n.alpha=Math.min(1,Math.max(0,o.type===ce.Number?o.value:o.value/100))),n}const Bx={mode:"hwb",toMode:{rgb:zx},fromMode:{rgb:Dx},channels:["h","w","b","alpha"],ranges:{h:[0,360]},gamut:"rgb",parse:[Hx],serialize:t=>`hwb(${t.h!==void 0?t.h:"none"} ${t.w!==void 0?t.w*100+"%":"none"} ${t.b!==void 0?t.b*100+"%":"none"}${t.alpha<1?` / ${t.alpha}`:""})`,interpolate:{h:{use:_e,fixup:oi},w:_e,b:_e,alpha:{use:_e,fixup:on}},difference:{h:Ex},average:{h:ai}},xv=203,rc=.1593017578125,Cv=78.84375,ic=.8359375,sc=18.8515625,oc=18.6875;function jc(t){if(t<0)return 0;const e=Math.pow(t,1/Cv);return 1e4*Math.pow(Math.max(0,e-ic)/(sc-oc*e),1/rc)}function $c(t){if(t<0)return 0;const e=Math.pow(t/1e4,rc);return Math.pow((ic+sc*e)/(1+oc*e),Cv)}const Fc=t=>Math.max(t/xv,0),Gh=({i:t,t:e,p:n,alpha:r})=>{t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=0);const i=jc(t+.008609037037932761*e+.11102962500302593*n),s=jc(t-.00860903703793275*e-.11102962500302599*n),o=jc(t+.5600313357106791*e-.32062717498731885*n),a={mode:"xyz65",x:Fc(2.070152218389422*i-1.3263473389671556*s+.2066510476294051*o),y:Fc(.3647385209748074*i+.680566024947227*s-.0453045459220346*o),z:Fc(-.049747207535812*i-.0492609666966138*s+1.1880659249923042*o)};return r!==void 0&&(a.alpha=r),a},Gc=(t=0)=>Math.max(t*xv,0),Vh=({x:t,y:e,z:n,alpha:r})=>{const i=Gc(t),s=Gc(e),o=Gc(n),a=$c(.3592832590121217*i+.6976051147779502*s-.0358915932320289*o),l=$c(-.1920808463704995*i+1.1004767970374323*s+.0753748658519118*o),c=$c(.0070797844607477*i+.0748396662186366*s+.8433265453898765*o),u=.5*a+.5*l,f=1.61376953125*a-3.323486328125*l+1.709716796875*c,h=4.378173828125*a-4.24560546875*l-.132568359375*c,p={mode:"itp",i:u,t:f,p:h};return r!==void 0&&(p.alpha=r),p},Ux={mode:"itp",channels:["i","t","p","alpha"],parse:["--ictcp"],serialize:"--ictcp",toMode:{xyz65:Gh,rgb:t=>Ji(Gh(t))},fromMode:{xyz65:Vh,rgb:t=>Vh(Xi(t))},ranges:{i:[0,.581],t:[-.369,.272],p:[-.164,.331]},interpolate:{i:_e,t:_e,p:_e,alpha:{use:_e,fixup:on}}},jx=134.03437499999998,$x=16295499532821565e-27,Vc=t=>{if(t<0)return 0;let e=Math.pow(t/1e4,rc);return Math.pow((ic+sc*e)/(1+oc*e),jx)},Zc=(t=0)=>Math.max(t*203,0),Pv=({x:t,y:e,z:n,alpha:r})=>{t=Zc(t),e=Zc(e),n=Zc(n);let i=1.15*t-.15*n,s=.66*e+.34*t,o=Vc(.41478972*i+.579999*s+.014648*n),a=Vc(-.20151*i+1.120649*s+.0531008*n),l=Vc(-.0166008*i+.2648*s+.6684799*n),c=(o+a)/2,u={mode:"jab",j:.44*c/(1-.56*c)-$x,a:3.524*o-4.066708*a+.542708*l,b:.199076*o+1.096799*a-1.295875*l};return r!==void 0&&(u.alpha=r),u},Fx=134.03437499999998,Zh=16295499532821565e-27,Wc=t=>{if(t<0)return 0;let e=Math.pow(t,1/Fx);return 1e4*Math.pow((ic-e)/(oc*e-sc),1/rc)},qc=t=>t/203,Rv=({j:t,a:e,b:n,alpha:r})=>{t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=0);let i=(t+Zh)/(.44+.56*(t+Zh)),s=Wc(i+.13860504*e+.058047316*n),o=Wc(i-.13860504*e-.058047316*n),a=Wc(i-.096019242*e-.8118919*n),l={mode:"xyz65",x:qc(1.661373024652174*s-.914523081304348*o+.23136208173913045*a),y:qc(-.3250758611844533*s+1.571847026732543*o-.21825383453227928*a),z:qc(-.090982811*s-.31272829*o+1.5227666*a)};return r!==void 0&&(l.alpha=r),l},Av=t=>{let e=Pv(Xi(t));return t.r===t.b&&t.b===t.g&&(e.a=e.b=0),e},Ov=t=>Ji(Rv(t)),Gx={mode:"jab",channels:["j","a","b","alpha"],parse:["--jzazbz"],serialize:"--jzazbz",fromMode:{rgb:Av,xyz65:Pv},toMode:{rgb:Ov,xyz65:Rv},ranges:{j:[0,.222],a:[-.109,.129],b:[-.185,.134]},interpolate:{j:_e,a:_e,b:_e,alpha:{use:_e,fixup:on}}},Wh=({j:t,a:e,b:n,alpha:r})=>{e===void 0&&(e=0),n===void 0&&(n=0);let i=Math.sqrt(e*e+n*n),s={mode:"jch",j:t,c:i};return i&&(s.h=wn(Math.atan2(n,e)*180/Math.PI)),r!==void 0&&(s.alpha=r),s},qh=({j:t,c:e,h:n,alpha:r})=>{n===void 0&&(n=0);let i={mode:"jab",j:t,a:e?e*Math.cos(n/180*Math.PI):0,b:e?e*Math.sin(n/180*Math.PI):0};return r!==void 0&&(i.alpha=r),i},Vx={mode:"jch",parse:["--jzczhz"],serialize:"--jzczhz",toMode:{jab:qh,rgb:t=>Ov(qh(t))},fromMode:{rgb:t=>Wh(Av(t)),jab:Wh},channels:["j","c","h","alpha"],ranges:{j:[0,.221],c:[0,.19],h:[0,360]},interpolate:{h:{use:_e,fixup:oi},c:_e,j:_e,alpha:{use:_e,fixup:on}},difference:{h:ec},average:{h:ai}},ac=Math.pow(29,3)/Math.pow(3,3),Xd=Math.pow(6,3)/Math.pow(29,3);let Kc=t=>Math.pow(t,3)>Xd?Math.pow(t,3):(116*t-16)/ac;const Jd=({l:t,a:e,b:n,alpha:r})=>{t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=0);let i=(t+16)/116,s=e/500+i,o=i-n/200,a={mode:"xyz50",x:Kc(s)*Qt.X,y:Kc(i)*Qt.Y,z:Kc(o)*Qt.Z};return r!==void 0&&(a.alpha=r),a},pa=({x:t,y:e,z:n,alpha:r})=>{t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=0);let i=Xs({r:t*3.1341359569958707-e*1.6173863321612538-.4906619460083532*n,g:t*-.978795502912089+e*1.916254567259524+.03344273116131949*n,b:t*.07195537988411677-e*.2289768264158322+1.405386058324125*n});return r!==void 0&&(i.alpha=r),i},Mv=t=>pa(Jd(t)),ga=t=>{let{r:e,g:n,b:r,alpha:i}=Ys(t),s={mode:"xyz50",x:.436065742824811*e+.3851514688337912*n+.14307845442264197*r,y:.22249319175623702*e+.7168870538238823*n+.06061979053616537*r,z:.013923904500943465*e+.09708128566574634*n+.7140993584005155*r};return i!==void 0&&(s.alpha=i),s},Yc=t=>t>Xd?Math.cbrt(t):(ac*t+16)/116,Qd=({x:t,y:e,z:n,alpha:r})=>{t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=0);let i=Yc(t/Qt.X),s=Yc(e/Qt.Y),o=Yc(n/Qt.Z),a={mode:"lab",l:116*s-16,a:500*(i-s),b:200*(s-o)};return r!==void 0&&(a.alpha=r),a},Nv=t=>{let e=Qd(ga(t));return t.r===t.b&&t.b===t.g&&(e.a=e.b=0),e};function Zx(t,e){if(!e||e[0]!=="lab")return;const n={mode:"lab"},[,r,i,s,o]=e;if(!(r.type===ce.Hue||i.type===ce.Hue||s.type===ce.Hue))return r.type!==ce.None&&(n.l=Math.min(Math.max(0,r.value),100)),i.type!==ce.None&&(n.a=i.type===ce.Number?i.value:i.value*125/100),s.type!==ce.None&&(n.b=s.type===ce.Number?s.value:s.value*125/100),o.type!==ce.None&&(n.alpha=Math.min(1,Math.max(0,o.type===ce.Number?o.value:o.value/100))),n}const ef={mode:"lab",toMode:{xyz50:Jd,rgb:Mv},fromMode:{xyz50:Qd,rgb:Nv},channels:["l","a","b","alpha"],ranges:{l:[0,100],a:[-125,125],b:[-125,125]},parse:[Zx],serialize:t=>`lab(${t.l!==void 0?t.l:"none"} ${t.a!==void 0?t.a:"none"} ${t.b!==void 0?t.b:"none"}${t.alpha<1?` / ${t.alpha}`:""})`,interpolate:{l:_e,a:_e,b:_e,alpha:{use:_e,fixup:on}}},Wx={...ef,mode:"lab65",parse:["--lab-d65"],serialize:"--lab-d65",toMode:{xyz65:bv,rgb:tc},fromMode:{xyz65:_v,rgb:nc},ranges:{l:[0,100],a:[-125,125],b:[-125,125]}};function qx(t,e){if(!e||e[0]!=="lch")return;const n={mode:"lch"},[,r,i,s,o]=e;if(r.type!==ce.None){if(r.type===ce.Hue)return;n.l=Math.min(Math.max(0,r.value),100)}if(i.type!==ce.None&&(n.c=Math.max(0,i.type===ce.Number?i.value:i.value*150/100)),s.type!==ce.None){if(s.type===ce.Percentage)return;n.h=s.value}return o.type!==ce.None&&(n.alpha=Math.min(1,Math.max(0,o.type===ce.Number?o.value:o.value/100))),n}const tf={mode:"lch",toMode:{lab:Pi,rgb:t=>Mv(Pi(t))},fromMode:{rgb:t=>Ci(Nv(t)),lab:Ci},channels:["l","c","h","alpha"],ranges:{l:[0,100],c:[0,150],h:[0,360]},parse:[qx],serialize:t=>`lch(${t.l!==void 0?t.l:"none"} ${t.c!==void 0?t.c:"none"} ${t.h!==void 0?t.h:"none"}${t.alpha<1?` / ${t.alpha}`:""})`,interpolate:{h:{use:_e,fixup:oi},c:_e,l:_e,alpha:{use:_e,fixup:on}},difference:{h:ec},average:{h:ai}},Kx={...tf,mode:"lch65",parse:["--lch-d65"],serialize:"--lch-d65",toMode:{lab65:t=>Pi(t,"lab65"),rgb:t=>tc(Pi(t,"lab65"))},fromMode:{rgb:t=>Ci(nc(t),"lch65"),lab65:t=>Ci(t,"lch65")},ranges:{l:[0,100],c:[0,150],h:[0,360]}},Lv=({l:t,u:e,v:n,alpha:r})=>{e===void 0&&(e=0),n===void 0&&(n=0);let i=Math.sqrt(e*e+n*n),s={mode:"lchuv",l:t,c:i};return i&&(s.h=wn(Math.atan2(n,e)*180/Math.PI)),r!==void 0&&(s.alpha=r),s},Iv=({l:t,c:e,h:n,alpha:r})=>{n===void 0&&(n=0);let i={mode:"luv",l:t,u:e?e*Math.cos(n/180*Math.PI):0,v:e?e*Math.sin(n/180*Math.PI):0};return r!==void 0&&(i.alpha=r),i},zv=(t,e,n)=>4*t/(t+15*e+3*n),Dv=(t,e,n)=>9*e/(t+15*e+3*n),Yx=zv(Qt.X,Qt.Y,Qt.Z),Xx=Dv(Qt.X,Qt.Y,Qt.Z),Jx=t=>t<=Xd?ac*t:116*Math.cbrt(t)-16,qu=({x:t,y:e,z:n,alpha:r})=>{t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=0);let i=Jx(e/Qt.Y),s=zv(t,e,n),o=Dv(t,e,n);!isFinite(s)||!isFinite(o)?i=s=o=0:(s=13*i*(s-Yx),o=13*i*(o-Xx));let a={mode:"luv",l:i,u:s,v:o};return r!==void 0&&(a.alpha=r),a},Qx=(t,e,n)=>4*t/(t+15*e+3*n),e2=(t,e,n)=>9*e/(t+15*e+3*n),t2=Qx(Qt.X,Qt.Y,Qt.Z),n2=e2(Qt.X,Qt.Y,Qt.Z),Ku=({l:t,u:e,v:n,alpha:r})=>{if(t===void 0&&(t=0),t===0)return{mode:"xyz50",x:0,y:0,z:0};e===void 0&&(e=0),n===void 0&&(n=0);let i=e/(13*t)+t2,s=n/(13*t)+n2,o=Qt.Y*(t<=8?t/ac:Math.pow((t+16)/116,3)),a=o*(9*i)/(4*s),l=o*(12-3*i-20*s)/(4*s),c={mode:"xyz50",x:a,y:o,z:l};return r!==void 0&&(c.alpha=r),c},r2=t=>Lv(qu(ga(t))),i2=t=>pa(Ku(Iv(t))),s2={mode:"lchuv",toMode:{luv:Iv,rgb:i2},fromMode:{rgb:r2,luv:Lv},channels:["l","c","h","alpha"],parse:["--lchuv"],serialize:"--lchuv",ranges:{l:[0,100],c:[0,176.956],h:[0,360]},interpolate:{h:{use:_e,fixup:oi},c:_e,l:_e,alpha:{use:_e,fixup:on}},difference:{h:ec},average:{h:ai}},o2={...Ks,mode:"lrgb",toMode:{rgb:Xs},fromMode:{rgb:Ys},parse:["srgb-linear"],serialize:"srgb-linear"},a2={mode:"luv",toMode:{xyz50:Ku,rgb:t=>pa(Ku(t))},fromMode:{xyz50:qu,rgb:t=>qu(ga(t))},channels:["l","u","v","alpha"],parse:["--luv"],serialize:"--luv",ranges:{l:[0,100],u:[-84.936,175.042],v:[-125.882,87.243]},interpolate:{l:_e,u:_e,v:_e,alpha:{use:_e,fixup:on}}},Hv=({r:t,g:e,b:n,alpha:r})=>{t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=0);let i=Math.cbrt(.412221469470763*t+.5363325372617348*e+.0514459932675022*n),s=Math.cbrt(.2119034958178252*t+.6806995506452344*e+.1073969535369406*n),o=Math.cbrt(.0883024591900564*t+.2817188391361215*e+.6299787016738222*n),a={mode:"oklab",l:.210454268309314*i+.7936177747023054*s-.0040720430116193*o,a:1.9779985324311684*i-2.42859224204858*s+.450593709617411*o,b:.0259040424655478*i+.7827717124575296*s-.8086757549230774*o};return r!==void 0&&(a.alpha=r),a},lc=t=>{let e=Hv(Ys(t));return t.r===t.b&&t.b===t.g&&(e.a=e.b=0),e},ma=({l:t,a:e,b:n,alpha:r})=>{t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=0);let i=Math.pow(t+.3963377773761749*e+.2158037573099136*n,3),s=Math.pow(t-.1055613458156586*e-.0638541728258133*n,3),o=Math.pow(t-.0894841775298119*e-1.2914855480194092*n,3),a={mode:"lrgb",r:4.076741636075957*i-3.3077115392580616*s+.2309699031821044*o,g:-1.2684379732850317*i+2.6097573492876887*s-.3413193760026573*o,b:-.0041960761386756*i-.7034186179359362*s+1.7076146940746117*o};return r!==void 0&&(a.alpha=r),a},cc=t=>Xs(ma(t));function Yu(t){const r=1.170873786407767;return .5*(r*t-.206+Math.sqrt((r*t-.206)*(r*t-.206)+4*.03*r*t))}function kl(t){return(t*t+.206*t)/(1.170873786407767*(t+.03))}function l2(t,e){let n,r,i,s,o,a,l,c;-1.88170328*t-.80936493*e>1?(n=1.19086277,r=1.76576728,i=.59662641,s=.75515197,o=.56771245,a=4.0767416621,l=-3.3077115913,c=.2309699292):1.81444104*t-1.19445276*e>1?(n=.73956515,r=-.45954404,i=.08285427,s=.1254107,o=.14503204,a=-1.2684380046,l=2.6097574011,c=-.3413193965):(n=1.35733652,r=-.00915799,i=-1.1513021,s=-.50559606,o=.00692167,a=-.0041960863,l=-.7034186147,c=1.707614701);let u=n+r*t+i*e+s*t*t+o*t*e,f=.3963377774*t+.2158037573*e,h=-.1055613458*t-.0638541728*e,p=-.0894841775*t-1.291485548*e;{let g=1+u*f,m=1+u*h,b=1+u*p,_=g*g*g,y=m*m*m,R=b*b*b,L=3*f*g*g,P=3*h*m*m,A=3*p*b*b,O=6*f*f*g,D=6*h*h*m,z=6*p*p*b,B=a*_+l*y+c*R,j=a*L+l*P+c*A,q=a*O+l*D+c*z;u=u-B*j/(j*j-.5*B*q)}return u}function nf(t,e){let n=l2(t,e),r=ma({l:1,a:n*t,b:n*e}),i=Math.cbrt(1/Math.max(r.r,r.g,r.b)),s=i*n;return[i,s]}function c2(t,e,n,r,i,s=null){s||(s=nf(t,e));let o;if((n-i)*s[1]-(s[0]-i)*r<=0)o=s[1]*i/(r*s[0]+s[1]*(i-n));else{o=s[1]*(i-1)/(r*(s[0]-1)+s[1]*(i-n));{let a=n-i,l=r,c=.3963377774*t+.2158037573*e,u=-.1055613458*t-.0638541728*e,f=-.0894841775*t-1.291485548*e,h=a+l*c,p=a+l*u,g=a+l*f;{let m=i*(1-o)+o*n,b=o*r,_=m+b*c,y=m+b*u,R=m+b*f,L=_*_*_,P=y*y*y,A=R*R*R,O=3*h*_*_,D=3*p*y*y,z=3*g*R*R,B=6*h*h*_,j=6*p*p*y,q=6*g*g*R,ie=4.0767416621*L-3.3077115913*P+.2309699292*A-1,ve=4.0767416621*O-3.3077115913*D+.2309699292*z,pe=4.0767416621*B-3.3077115913*j+.2309699292*q,ee=ve/(ve*ve-.5*ie*pe),be=-ie*ee,Ee=-1.2684380046*L+2.6097574011*P-.3413193965*A-1,Me=-1.2684380046*O+2.6097574011*D-.3413193965*z,$e=-1.2684380046*B+2.6097574011*j-.3413193965*q,ge=Me/(Me*Me-.5*Ee*$e),ze=-Ee*ge,Je=-.0041960863*L-.7034186147*P+1.707614701*A-1,ae=-.0041960863*O-.7034186147*D+1.707614701*z,Se=-.0041960863*B-.7034186147*j+1.707614701*q,Te=ae/(ae*ae-.5*Je*Se),I=-Je*Te;be=ee>=0?be:1e6,ze=ge>=0?ze:1e6,I=Te>=0?I:1e6,o+=Math.min(be,Math.min(ze,I))}}}return o}function rf(t,e,n=null){n||(n=nf(t,e));let r=n[0],i=n[1];return[i/r,i/(1-r)]}function Bv(t,e,n){let r=nf(e,n),i=c2(e,n,t,1,t,r),s=rf(e,n,r),o=.11516993+1/(7.4477897+4.1590124*n+e*(-2.19557347+1.75198401*n+e*(-2.13704948-10.02301043*n+e*(-4.24894561+5.38770819*n+4.69891013*e)))),a=.11239642+1/(1.6132032-.68124379*n+e*(.40370612+.90148123*n+e*(-.27087943+.6122399*n+e*(.00299215-.45399568*n-.14661872*e)))),l=i/Math.min(t*s[0],(1-t)*s[1]),c=t*o,u=(1-t)*a,f=.9*l*Math.sqrt(Math.sqrt(1/(1/(c*c*c*c)+1/(u*u*u*u))));return c=t*.4,u=(1-t)*.8,[Math.sqrt(1/(1/(c*c)+1/(u*u))),f,i]}function Kh(t){const e=t.l!==void 0?t.l:0,n=t.a!==void 0?t.a:0,r=t.b!==void 0?t.b:0,i={mode:"okhsl",l:Yu(e)};t.alpha!==void 0&&(i.alpha=t.alpha);let s=Math.sqrt(n*n+r*r);if(!s)return i.s=0,i;let[o,a,l]=Bv(e,n/s,r/s),c;if(s<a){let u=0,f=.8*o,h=1-f/a;c=(s-u)/(f+h*(s-u))*.8}else{let u=a,f=.2*a*a*1.25*1.25/o,h=1-f/(l-a);c=.8+.2*((s-u)/(f+h*(s-u)))}return c&&(i.s=c,i.h=wn(Math.atan2(r,n)*180/Math.PI)),i}function Yh(t){let e=t.h!==void 0?t.h:0,n=t.s!==void 0?t.s:0,r=t.l!==void 0?t.l:0;const i={mode:"oklab",l:kl(r)};if(t.alpha!==void 0&&(i.alpha=t.alpha),!n||r===1)return i.a=i.b=0,i;let s=Math.cos(e/180*Math.PI),o=Math.sin(e/180*Math.PI),[a,l,c]=Bv(i.l,s,o),u,f,h,p;n<.8?(u=1.25*n,f=0,h=.8*a,p=1-h/l):(u=5*(n-.8),f=l,h=.2*l*l*1.25*1.25/a,p=1-h/(c-l));let g=f+u*h/(1-p*u);return i.a=g*s,i.b=g*o,i}const u2={...kv,mode:"okhsl",channels:["h","s","l","alpha"],parse:["--okhsl"],serialize:"--okhsl",fromMode:{oklab:Kh,rgb:t=>Kh(lc(t))},toMode:{oklab:Yh,rgb:t=>cc(Yh(t))}};function Xh(t){let e=t.l!==void 0?t.l:0,n=t.a!==void 0?t.a:0,r=t.b!==void 0?t.b:0,i=Math.sqrt(n*n+r*r),s=i?n/i:1,o=i?r/i:1,[a,l]=rf(s,o),c=.5,u=1-c/a,f=l/(i+e*l),h=f*e,p=f*i,g=kl(h),m=p*g/h,b=ma({l:g,a:s*m,b:o*m}),_=Math.cbrt(1/Math.max(b.r,b.g,b.b,0));e=e/_,i=i/_*Yu(e)/e,e=Yu(e);const y={mode:"okhsv",s:i?(c+l)*p/(l*c+l*u*p):0,v:e?e/h:0};return y.s&&(y.h=wn(Math.atan2(r,n)*180/Math.PI)),t.alpha!==void 0&&(y.alpha=t.alpha),y}function Jh(t){const e={mode:"oklab"};t.alpha!==void 0&&(e.alpha=t.alpha);const n=t.h!==void 0?t.h:0,r=t.s!==void 0?t.s:0,i=t.v!==void 0?t.v:0,s=Math.cos(n/180*Math.PI),o=Math.sin(n/180*Math.PI),[a,l]=rf(s,o),c=.5,u=1-c/a,f=1-r*c/(c+l-l*u*r),h=r*l*c/(c+l-l*u*r),p=kl(f),g=h*p/f,m=ma({l:p,a:s*g,b:o*g}),b=Math.cbrt(1/Math.max(m.r,m.g,m.b,0)),_=kl(i*f),y=h*_/f;return e.l=_*b,e.a=y*s*b,e.b=y*o*b,e}const d2={...Tv,mode:"okhsv",channels:["h","s","v","alpha"],parse:["--okhsv"],serialize:"--okhsv",fromMode:{oklab:Xh,rgb:t=>Xh(lc(t))},toMode:{oklab:Jh,rgb:t=>cc(Jh(t))}};function f2(t,e){if(!e||e[0]!=="oklab")return;const n={mode:"oklab"},[,r,i,s,o]=e;if(!(r.type===ce.Hue||i.type===ce.Hue||s.type===ce.Hue))return r.type!==ce.None&&(n.l=Math.min(Math.max(0,r.type===ce.Number?r.value:r.value/100),1)),i.type!==ce.None&&(n.a=i.type===ce.Number?i.value:i.value*.4/100),s.type!==ce.None&&(n.b=s.type===ce.Number?s.value:s.value*.4/100),o.type!==ce.None&&(n.alpha=Math.min(1,Math.max(0,o.type===ce.Number?o.value:o.value/100))),n}const h2={...ef,mode:"oklab",toMode:{lrgb:ma,rgb:cc},fromMode:{lrgb:Hv,rgb:lc},ranges:{l:[0,1],a:[-.4,.4],b:[-.4,.4]},parse:[f2],serialize:t=>`oklab(${t.l!==void 0?t.l:"none"} ${t.a!==void 0?t.a:"none"} ${t.b!==void 0?t.b:"none"}${t.alpha<1?` / ${t.alpha}`:""})`};function p2(t,e){if(!e||e[0]!=="oklch")return;const n={mode:"oklch"},[,r,i,s,o]=e;if(r.type!==ce.None){if(r.type===ce.Hue)return;n.l=Math.min(Math.max(0,r.type===ce.Number?r.value:r.value/100),1)}if(i.type!==ce.None&&(n.c=Math.max(0,i.type===ce.Number?i.value:i.value*.4/100)),s.type!==ce.None){if(s.type===ce.Percentage)return;n.h=s.value}return o.type!==ce.None&&(n.alpha=Math.min(1,Math.max(0,o.type===ce.Number?o.value:o.value/100))),n}const g2={...tf,mode:"oklch",toMode:{oklab:t=>Pi(t,"oklab"),rgb:t=>cc(Pi(t,"oklab"))},fromMode:{rgb:t=>Ci(lc(t),"oklch"),oklab:t=>Ci(t,"oklch")},parse:[p2],serialize:t=>`oklch(${t.l!==void 0?t.l:"none"} ${t.c!==void 0?t.c:"none"} ${t.h!==void 0?t.h:"none"}${t.alpha<1?` / ${t.alpha}`:""})`,ranges:{l:[0,1],c:[0,.4],h:[0,360]}},Qh=t=>{let{r:e,g:n,b:r,alpha:i}=Ys(t),s={mode:"xyz65",x:.486570948648216*e+.265667693169093*n+.1982172852343625*r,y:.2289745640697487*e+.6917385218365062*n+.079286914093745*r,z:0*e+.0451133818589026*n+1.043944368900976*r};return i!==void 0&&(s.alpha=i),s},ep=({x:t,y:e,z:n,alpha:r})=>{t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=0);let i=Xs({r:t*2.4934969119414263-e*.9313836179191242-.402710784450717*n,g:t*-.8294889695615749+e*1.7626640603183465+.0236246858419436*n,b:t*.0358458302437845-e*.0761723892680418+.9568845240076871*n},"p3");return r!==void 0&&(i.alpha=r),i},m2={...Ks,mode:"p3",parse:["display-p3"],serialize:"display-p3",fromMode:{rgb:t=>ep(Xi(t)),xyz65:ep},toMode:{rgb:t=>Ji(Qh(t)),xyz65:Qh}},Xc=t=>{let e=Math.abs(t);return e>=1/512?Math.sign(t)*Math.pow(e,1/1.8):16*t},tp=({x:t,y:e,z:n,alpha:r})=>{t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=0);let i={mode:"prophoto",r:Xc(t*1.3457868816471585-e*.2555720873797946-.0511018649755453*n),g:Xc(t*-.5446307051249019+e*1.5082477428451466+.0205274474364214*n),b:Xc(t*0+e*0+1.2119675456389452*n)};return r!==void 0&&(i.alpha=r),i},Jc=(t=0)=>{let e=Math.abs(t);return e>=16/512?Math.sign(t)*Math.pow(e,1.8):t/16},np=t=>{let e=Jc(t.r),n=Jc(t.g),r=Jc(t.b),i={mode:"xyz50",x:.7977666449006423*e+.1351812974005331*n+.0313477341283922*r,y:.2880748288194013*e+.7118352342418731*n+899369387256e-16*r,z:0*e+0*n+.8251046025104602*r};return t.alpha!==void 0&&(i.alpha=t.alpha),i},v2={...Ks,mode:"prophoto",parse:["prophoto-rgb"],serialize:"prophoto-rgb",fromMode:{xyz50:tp,rgb:t=>tp(ga(t))},toMode:{xyz50:np,rgb:t=>pa(np(t))}},rp=1.09929682680944,b2=.018053968510807,Qc=t=>{const e=Math.abs(t);return e>b2?(Math.sign(t)||1)*(rp*Math.pow(e,.45)-(rp-1)):4.5*t},ip=({x:t,y:e,z:n,alpha:r})=>{t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=0);let i={mode:"rec2020",r:Qc(t*1.7166511879712683-e*.3556707837763925-.2533662813736599*n),g:Qc(t*-.6666843518324893+e*1.6164812366349395+.0157685458139111*n),b:Qc(t*.0176398574453108-e*.0427706132578085+.9421031212354739*n)};return r!==void 0&&(i.alpha=r),i},sp=1.09929682680944,_2=.018053968510807,eu=(t=0)=>{let e=Math.abs(t);return e<_2*4.5?t/4.5:(Math.sign(t)||1)*Math.pow((e+sp-1)/sp,1/.45)},op=t=>{let e=eu(t.r),n=eu(t.g),r=eu(t.b),i={mode:"xyz65",x:.6369580483012911*e+.1446169035862083*n+.1688809751641721*r,y:.262700212011267*e+.6779980715188708*n+.059301716469862*r,z:0*e+.0280726930490874*n+1.0609850577107909*r};return t.alpha!==void 0&&(i.alpha=t.alpha),i},w2={...Ks,mode:"rec2020",fromMode:{xyz65:ip,rgb:t=>ip(Xi(t))},toMode:{xyz65:op,rgb:t=>Ji(op(t))},parse:["rec2020"],serialize:"rec2020"},Vi=.0037930732552754493,Uv=Math.cbrt(Vi),tu=t=>Math.cbrt(t)-Uv,y2=t=>{const{r:e,g:n,b:r,alpha:i}=Ys(t),s=tu(.3*e+.622*n+.078*r+Vi),o=tu(.23*e+.692*n+.078*r+Vi),a=tu(.2434226892454782*e+.2047674442449682*n+.5518098665095535*r+Vi),l={mode:"xyb",x:(s-o)/2,y:(s+o)/2,b:a-(s+o)/2};return i!==void 0&&(l.alpha=i),l},nu=t=>Math.pow(t+Uv,3),k2=({x:t,y:e,b:n,alpha:r})=>{t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=0);const i=nu(t+e)-Vi,s=nu(e-t)-Vi,o=nu(n+e)-Vi,a=Xs({r:11.031566904639861*i-9.866943908131562*s-.16462299650829934*o,g:-3.2541473810744237*i+4.418770377582723*s-.16462299650829934*o,b:-3.6588512867136815*i+2.7129230459360922*s+1.9459282407775895*o});return r!==void 0&&(a.alpha=r),a},E2={mode:"xyb",channels:["x","y","b","alpha"],parse:["--xyb"],serialize:"--xyb",toMode:{rgb:k2},fromMode:{rgb:y2},ranges:{x:[-.0154,.0281],y:[0,.8453],b:[-.2778,.388]},interpolate:{x:_e,y:_e,b:_e,alpha:{use:_e,fixup:on}}},S2={mode:"xyz50",parse:["xyz-d50"],serialize:"xyz-d50",toMode:{rgb:pa,lab:Qd},fromMode:{rgb:ga,lab:Jd},channels:["x","y","z","alpha"],ranges:{x:[0,.964],y:[0,.999],z:[0,.825]},interpolate:{x:_e,y:_e,z:_e,alpha:{use:_e,fixup:on}}},T2=t=>{let{x:e,y:n,z:r,alpha:i}=t;e===void 0&&(e=0),n===void 0&&(n=0),r===void 0&&(r=0);let s={mode:"xyz50",x:1.0479298208405488*e+.0229467933410191*n-.0501922295431356*r,y:.0296278156881593*e+.990434484573249*n-.0170738250293851*r,z:-.0092430581525912*e+.0150551448965779*n+.7518742899580008*r};return i!==void 0&&(s.alpha=i),s},x2=t=>{let{x:e,y:n,z:r,alpha:i}=t;e===void 0&&(e=0),n===void 0&&(n=0),r===void 0&&(r=0);let s={mode:"xyz65",x:.9554734527042182*e-.0230985368742614*n+.0632593086610217*r,y:-.0283697069632081*e+1.0099954580058226*n+.021041398966943*r,z:.0123140016883199*e-.0205076964334779*n+1.3303659366080753*r};return i!==void 0&&(s.alpha=i),s},C2={mode:"xyz65",toMode:{rgb:Ji,xyz50:T2},fromMode:{rgb:Xi,xyz50:x2},ranges:{x:[0,.95],y:[0,1],z:[0,1.088]},channels:["x","y","z","alpha"],parse:["xyz","xyz-d65"],serialize:"xyz-d65",interpolate:{x:_e,y:_e,z:_e,alpha:{use:_e,fixup:on}}},P2=({r:t,g:e,b:n,alpha:r})=>{t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=0);const i={mode:"yiq",y:.29889531*t+.58662247*e+.11448223*n,i:.59597799*t-.2741761*e-.32180189*n,q:.21147017*t-.52261711*e+.31114694*n};return r!==void 0&&(i.alpha=r),i},R2=({y:t,i:e,q:n,alpha:r})=>{t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=0);const i={mode:"rgb",r:t+.95608445*e+.6208885*n,g:t-.27137664*e-.6486059*n,b:t-1.10561724*e+1.70250126*n};return r!==void 0&&(i.alpha=r),i},A2={mode:"yiq",toMode:{rgb:R2},fromMode:{rgb:P2},channels:["y","i","q","alpha"],parse:["--yiq"],serialize:"--yiq",ranges:{i:[-.595,.595],q:[-.522,.522]},interpolate:{y:_e,i:_e,q:_e,alpha:{use:_e,fixup:on}}},O2=t=>Math.max(0,Math.min(1,t||0)),ru=t=>Math.round(O2(t)*255),M2=xi("rgb"),N2=t=>{if(t===void 0)return;let e=ru(t.r),n=ru(t.g),r=ru(t.b);return"#"+(1<<24|e<<16|n<<8|r).toString(16).slice(1)},L2=t=>N2(M2(t)),jv=xi("rgb"),$v=t=>{const e={mode:t.mode,r:Math.max(0,Math.min(t.r!==void 0?t.r:0,1)),g:Math.max(0,Math.min(t.g!==void 0?t.g:0,1)),b:Math.max(0,Math.min(t.b!==void 0?t.b:0,1))};return t.alpha!==void 0&&(e.alpha=t.alpha),e},I2=t=>$v(jv(t)),Fv=t=>t!==void 0&&(t.r===void 0||t.r>=0&&t.r<=1)&&(t.g===void 0||t.g>=0&&t.g<=1)&&(t.b===void 0||t.b>=0&&t.b<=1);function z2(t){return Fv(jv(t))}function Gv(t="rgb"){const{gamut:e}=Jl(t);if(!e)return r=>!0;const n=xi(typeof e=="string"?e:t);return r=>Fv(n(r))}function D2(t="rgb"){const{gamut:e}=Jl(t);if(!e)return s=>ml(s);const n=typeof e=="string"?e:t,r=xi(n),i=Gv(n);return s=>{const o=ml(s);if(!o)return;const a=r(o);if(i(a))return o;const l=$v(a);return o.mode===l.mode?l:xi(o.mode)(l)}}function H2(t,e="lch",n="rgb"){t=ml(t);let r=n==="rgb"?z2:Gv(n),i=n==="rgb"?I2:D2(n);if(t===void 0||r(t))return t;let s=xi(t.mode);t=xi(e)(t);let o={...t,c:0};if(!r(o))return s(i(o));let a=0,l=t.c!==void 0?t.c:0,c=Jl(e).ranges.c,u=(c[1]-c[0])/Math.pow(2,13),f=o.c;for(;l-a>u;)o.c=a+(l-a)*.5,r(o)?(f=o.c,a=o.c):l=o.c;return s(r(o)?o:{...o,c:f})}wt(vx);wt(Sx);wt(Tx);wt(xx);wt(Rx);wt(kv);wt(Tv);wt(Bx);wt(Ux);wt(Gx);wt(Vx);wt(ef);wt(Wx);wt(tf);wt(Kx);wt(s2);wt(o2);wt(a2);wt(u2);wt(d2);wt(h2);const B2=wt(g2);wt(m2);wt(v2);wt(w2);wt(Ks);wt(E2);wt(S2);wt(C2);wt(A2);function vo(t,e,n){const r=H2({mode:"oklch",l:t,c:e,h:n},"oklch");return L2(r??{mode:"oklch",l:t,c:0,h:n})}function Vv(t){const e=B2(t);return e?{l:e.l,c:e.c,h:e.h??0}:{l:0,c:0,h:0}}function U2(t,e){const{l:n,c:r,h:i}=Vv(t);return vo(Math.min(1,Math.max(0,n+e)),r,i)}function j2(t){const{hue:e,chroma:n,bgHex:r,target:i}=t,s=.01;let o=t.l;const a=Ao(vo(1,0,e),r),l=Ao(vo(0,0,e),r),c=a>=l?s:-s;let u=vo(o,n,e);for(;Ao(u,r)<i&&o>0&&o<1;)o=Math.min(1,Math.max(0,o+c)),u=vo(o,n,e);return u}function $2(t,e,n){const{l:r,c:i,h:s}=Vv(t);return j2({hue:s,chroma:i,l:r,bgHex:e,target:n})}const F2={dark:.12,light:-.12};function G2(t,e,n){const r=U2(t,F2[n]);return Ao(r,e)>=4.5?r:$2(r,e,4.5)}const Xa=["dark","light"],Xu=Kd.map(t=>t.token),V2=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;function Zv(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Z2(t,e,n){if(!Zv(t))return n.push(`"${e}" must be an object of palette colour tokens.`),!1;let r=!0;for(const i of Xu){const s=t[i];if(s===void 0){if(i==="controlHover")continue;n.push(`"${e}" is missing the token "${i}".`),r=!1;continue}if(typeof s!="string"){n.push(`"${e}.${i}" must be a string, got ${typeof s}.`),r=!1;continue}V2.test(s)||(n.push(`"${e}.${i}" must be a hex colour like #1a2b3c, got "${s}".`),r=!1)}for(const i of Object.keys(t))Xu.includes(i)||(n.push(`"${e}" has an unknown token "${i}".`),r=!1);return r}function W2(t){const e=[];for(const n of Xa)for(const r of WT){const i=Ao(t[n][r.fg],t[n][r.bg]);i<r.min&&e.push({theme:n,pair:`${r.fg} on ${r.bg}`,ratio:Number(i.toFixed(2)),min:r.min})}return e}function Wv(t){const e=[];if(!Zv(t))return{palette:null,structuralErrors:['The file must contain a JSON object with "dark" and "light" keys.'],contrastWarnings:[]};let n=!0;for(const i of Xa){if(!(i in t)){e.push(`Missing the "${i}" theme.`),n=!1;continue}Z2(t[i],i,e)||(n=!1)}for(const i of Object.keys(t))Xa.includes(i)||(e.push(`Unknown top-level key "${i}"; expected only "dark" and "light".`),n=!1);if(!n)return{palette:null,structuralErrors:e,contrastWarnings:[]};const r={dark:{},light:{}};for(const i of Xa){const s=t[i];for(const o of Xu)o==="controlHover"&&s[o]===void 0?r[i].controlHover=G2(s.surface,s.text,i):r[i][o]=s[o]}return{palette:r,structuralErrors:[],contrastWarnings:W2(r)}}const qv=["execute","queue","initBackgroundProcess","queueBackgroundProcess"];function Kv(t){return t.reason===void 0?new DOMException("The operation was aborted.","AbortError"):t.reason}function q2(t){return new el(e=>{const n=()=>{e.error(Kv(t))};if(t.aborted){n();return}return t.addEventListener("abort",n,{once:!0}),()=>t.removeEventListener("abort",n)})}function K2(t){const e=(r,i)=>{const{signal:s,...o}=i??{},a=i===void 0?void 0:o;if((s==null?void 0:s.aborted)===!0)return Promise.resolve().then(()=>{throw Kv(s)});const l=t.queue(r,a);return md(s===void 0?l:E_(l,q2(s)))},n=Object.create(null);for(const r of qv)n[r]=t[r].bind(t);return n.query=e,Object.freeze(n)}const El=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),Yv=ot({capability:uv,reason:me().min(1),prerequisite:me().min(1).optional()}),sf=bn().int().nonnegative().nullable(),Y2=ot({kind:Cn(["exec","service"]),state:Yt("blocked"),retryAfterSeconds:sf,blockers:Ht(Yv).min(1)}),X2=ot({kind:Cn(["exec","service"]),state:Yt("incompatible"),retryAfterSeconds:sf,requiredProtocol:bn().int(),supportedProtocols:Ht(bn().int())}),J2=ot({kind:Cn(["exec","service"]),state:Cn(["ready","starting","unavailable","maintenance","disabled","not-approved"]),retryAfterSeconds:sf}),Q2=t=>{if(!El(t))return t;if(({blocked:["requiredProtocol","supportedProtocols"],incompatible:["blockers"]}[String(t.state)]??["blockers","requiredProtocol","supportedProtocols"]).some(r=>Object.prototype.hasOwnProperty.call(t,r)))throw new Error("backend status contains fields for a different variant");return t},eC=KS(Q2,Vd("state",[Y2,X2,J2])),ap=Object.freeze({notApproved:4001,disabled:4002}),tC=new Set(["BACKEND_BUSY","BACKEND_STARTING","BACKEND_UNAVAILABLE","BACKEND_MAINTENANCE","BAD_GATEWAY","SERVER_BUSY","REQUEST_TIMEOUT","SCRIPT_TIMEOUT","STATUS_QUERY_FAILED"]),nC=(t,e)=>t==="HTTP_ERROR"?e===408||e===425||e===429||e!==void 0&&e>=500:tC.has(t);class xn extends Error{constructor(n,r,i,s={}){super(n);X(this,"id");X(this,"code");X(this,"status");X(this,"retryable");X(this,"details");this.name="BackendError",this.code=r,this.id=i,this.status=s.status,this.retryable=s.retryable??nC(r,s.status),this.details=s.details}}class Ju extends xn{constructor(n,r={}){const i=r.code??"UNKNOWN_ID";super(`Unknown backend binding id: "${n}"`,i,n,r);X(this,"code");this.code=i,this.name="BackendUnknownId"}}class Xv extends xn{constructor(n,r={}){super(`Backend "${n}" is not approved`,"NOT_APPROVED",n,r);X(this,"code","NOT_APPROVED");this.name="BackendNotApproved"}}class of extends xn{constructor(n,r={}){super(`Backend "${n}" is disabled`,"DISABLED",n,r);X(this,"code","DISABLED");this.name="BackendDisabled"}}class lp extends xn{constructor(n,r,i={}){super(`Backend route "${n}" is not an ${r} route`,"TRANSPORT_MISMATCH",n,i);X(this,"code","TRANSPORT_MISMATCH");this.expected=r,this.name="BackendTransportMismatch"}}class rC extends xn{constructor(n,r,i={}){super(`Backend "${n}" is starting`,"BACKEND_STARTING",n,i);X(this,"code","BACKEND_STARTING");this.retryAfterSeconds=r,this.name="BackendStarting"}}class iC extends xn{constructor(n,r={}){super(`Backend "${n}" is unavailable`,"BACKEND_UNAVAILABLE",n,r);X(this,"code","BACKEND_UNAVAILABLE");this.name="BackendUnavailable"}}class sC extends xn{constructor(n,r={}){super(`Backend "${n}" is incompatible`,"BACKEND_INCOMPATIBLE",n,r);X(this,"code","BACKEND_INCOMPATIBLE");this.name="BackendIncompatible"}}class oC extends xn{constructor(n,r,i={}){super(`Backend "${n}" is under maintenance`,"BACKEND_MAINTENANCE",n,i);X(this,"code","BACKEND_MAINTENANCE");this.retryAfterSeconds=r,this.name="BackendMaintenance"}}class aC extends xn{constructor(n,r,i,s={}){super(`Backend "${n}" is blocked on an unmet activation prerequisite`,"BACKEND_BLOCKED",n,s);X(this,"code","BACKEND_BLOCKED");this.blockers=r,this.retryAfterSeconds=i,this.name="BackendBlocked"}}class lC extends xn{constructor(n,r={}){super(`Backend "${n}" returned a bad gateway response`,"BAD_GATEWAY",n,r);X(this,"code","BAD_GATEWAY");this.name="BackendBadGateway"}}class iu extends xn{constructor(n,r){super(r,"STATUS_QUERY_FAILED",void 0,{status:n??void 0});X(this,"code","STATUS_QUERY_FAILED");this.httpStatus=n,this.name="BackendStatusQueryError"}}const su=t=>{const e=t.headers.get("Retry-After");if(e===null||!/^\d+$/.test(e))return null;const n=Number(e);return Number.isSafeInteger(n)?n:null},cC=t=>{const e=Ht(Yv).safeParse(t);return e.success?e.data:[]},pr=(t,e)=>(n,r,i,s)=>new xn(i.message??e,t,n,{...s,status:r.status}),Jv={DISABLED:(t,e,n,r)=>new of(t,r),NOT_APPROVED:(t,e,n,r)=>new Xv(t,r),ROUTE_NOT_FOUND:(t,e,n,r)=>new Ju(t,{...r,code:"ROUTE_NOT_FOUND"}),BACKEND_STARTING:(t,e,n,r)=>new rC(t,su(e),r),BACKEND_UNAVAILABLE:(t,e,n,r)=>new iC(t,r),BACKEND_INCOMPATIBLE:(t,e,n,r)=>new sC(t,r),BACKEND_MAINTENANCE:(t,e,n,r)=>new oC(t,su(e),r),BACKEND_BLOCKED:(t,e,n,r)=>new aC(t,cC(n.detail),su(e),r),BAD_GATEWAY:(t,e,n,r)=>new lC(t,r),BAD_REQUEST:pr("BAD_REQUEST","Backend request was rejected"),INTERNAL:pr("INTERNAL","Backend request failed"),SERVER_BUSY:pr("SERVER_BUSY","Backend request intake is busy"),REQUEST_TIMEOUT:pr("REQUEST_TIMEOUT","Backend request timed out"),SCRIPT_FAILED:pr("SCRIPT_FAILED","Backend script failed"),SCRIPT_TIMEOUT:pr("SCRIPT_TIMEOUT","Backend script timed out"),BACKEND_BUSY:pr("BACKEND_BUSY","Backend is busy"),BACKEND_BODY_TOO_LARGE:pr("BACKEND_BODY_TOO_LARGE","Backend request body is too large"),BACKEND_OUTPUT_TOO_LARGE:pr("BACKEND_OUTPUT_TOO_LARGE","Backend output is too large"),CSRF_REQUIRED:pr("CSRF_REQUIRED","Backend request requires CSRF protection"),UNAUTHORIZED:pr("UNAUTHORIZED","Backend request is unauthorized")},uC="X-Mndw-Error",dC="INTERNAL",fC="Backend platform request failed",hC=t=>Object.prototype.hasOwnProperty.call(Jv,t)?t:void 0,pC=t=>{if(!t)return"";const e=new URLSearchParams;for(const[r,i]of Object.entries(t))e.set(r,String(i));const n=e.toString();return n?`?${n}`:""},gC=t=>t===null||typeof t!="object"?!1:!(t instanceof FormData||t instanceof Blob||t instanceof ArrayBuffer||t instanceof URLSearchParams||t instanceof ReadableStream),mC=t=>t.startsWith("https:")?"wss:":"ws:",cp=(t,e)=>t.enabled?t.approval!=="approved"?new Xv(e):null:new of(e),vC=async(t,e)=>{if(e.ok||e.redirected!==!1||!e.headers.has(uC))return e;let n;try{n=await e.clone().json()}catch{n=void 0}const r=El(n)&&El(n.error)?n.error:void 0,i={code:typeof(r==null?void 0:r.code)=="string"?r.code:void 0,message:typeof(r==null?void 0:r.message)=="string"?r.message:void 0,detail:r==null?void 0:r.detail},s=i.code?hC(i.code):void 0,o={status:e.status,details:i.detail};throw s?Jv[s](t,e,i,o):new xn(i.message??fC,dC,t,o)},bC=t=>El(t)&&t.name==="AbortError",_C=async(t,e,n,r)=>{const i=`${t.origin}/api/plugins/${t.pluginName}/${e.path}${pC(r.query)}`,s=new Headers(r.headers);e.method!=="GET"&&e.method!=="HEAD"&&s.set("X-Mndw-Csrf","1");let o;r.body!==void 0&&r.body!==null&&(gC(r.body)?(o=JSON.stringify(r.body),s.has("content-type")||s.set("content-type","application/json")):o=r.body);const a=await t.fetchImpl(i,{method:e.method,headers:s,body:o,signal:r.signal});return vC(n,a)},wC=(t,e)=>{const n=new EventTarget,r=Object.assign(n,{binaryType:"blob",bufferedAmount:0,extensions:"",onclose:null,onerror:null,onmessage:null,onopen:null,protocol:"",readyState:3,url:"",close:()=>{},send:i=>{throw new DOMException("WebSocket is already in CLOSING or CLOSED state","InvalidStateError")}});return queueMicrotask(()=>{var s;const i=new Event("close");Object.defineProperties(i,{code:{value:t,enumerable:!0},reason:{value:e,enumerable:!0},wasClean:{value:!0,enumerable:!0}}),r.dispatchEvent(i),(s=r.onclose)==null||s.call(r,i)}),r};function up(t,e,n={}){const r={pluginName:t,descriptor:e,fetchImpl:n.fetch??globalThis.fetch.bind(globalThis),WebSocketCtor:n.WebSocketCtor??globalThis.WebSocket,origin:n.origin??(typeof location<"u"?location.origin:"http://localhost")},i=()=>new xn(`Plugin "${t}" has no backend declared; declare the manifest backend field.`,"BACKEND_NOT_DECLARED"),s=async(a,l={})=>{if(e===void 0)throw i();const c=e.routes[a];if(!c)throw new Ju(a);if(c.transport!=="http"||!c.method)throw new lp(a,"http");const u=cp(e,a);return u?Promise.reject(u):_C(r,c,a,l)};function o(a,l={}){return s(a,l).then(async c=>{var p,g;if(!c.ok){const m=await c.text();throw new xn(`Backend route "${a}" returned HTTP ${c.status}`,"HTTP_ERROR",a,{status:c.status,details:m})}const u=((g=(p=c.headers.get("content-type"))==null?void 0:p.split(";",1)[0])==null?void 0:g.trim().toLowerCase())??"",f=l.as??(u==="application/json"||u.endsWith("+json")?"json":u.startsWith("text/")?"text":"blob");if(f==="text")return c.text();if(f==="blob")return c.blob();const h=await c.text();try{return JSON.parse(h)}catch(m){throw bC(m)?m:new xn(`Backend route "${a}" returned invalid JSON`,"INVALID_RESPONSE",a,{status:c.status,details:h})}})}return{fetch(a,l={}){return s(a,l)},call:o,socket(a,l={}){if(e===void 0)throw i();const c=e.routes[a];if(!c)throw new Ju(a);if(c.transport!=="websocket")throw new lp(a,"websocket");const u=cp(e,a);if(u)return wC(u instanceof of?ap.disabled:ap.notApproved,u.message);const f=`${mC(r.origin)}//${r.origin.replace(/^[a-z]+:\/\//,"")}/ws/plugins/${r.pluginName}/${c.path}`,h=l.protocols??c.protocols;return new r.WebSocketCtor(f,h)},async status(a={}){if(e===void 0)throw i();const l=`${r.origin}/api/plugins/${r.pluginName}/_mndw/status`;return r.fetchImpl(l,{method:"GET",signal:a.signal}).then(async c=>{if(!c.ok)throw new iu(c.status,`Backend status query failed with HTTP ${c.status}`);try{return eC.parse(await c.json())}catch(u){throw u instanceof iu?u:new iu(c.status,"Backend status response is invalid")}})}}}class dp extends Error{constructor(n,r){super(r);X(this,"status");this.name="TelemetryError",this.status=n}}const yi=t=>typeof t=="number"&&Number.isFinite(t),yC=["unanchored","anchored","suspect"],kC=t=>{if(t===void 0)return;if(t===null||typeof t!="object"||Array.isArray(t))throw new Error("telemetry clock is invalid");const e=t,{state:n,historyEndMs:r,historyCurrent:i,replayPending:s}=e;if(typeof n!="string"||!yC.includes(n))throw new Error("telemetry clock state is invalid");if(r!==null&&(!yi(r)||!Number.isInteger(r)||r<0))throw new Error("telemetry clock historyEndMs must be a non-negative integer or null");if(typeof i!="boolean"||typeof s!="boolean")throw new Error("telemetry clock flags must be booleans");if(r===null&&i)throw new Error("telemetry clock cannot be current without history");return{state:n,historyEndMs:r,historyCurrent:i,replayPending:s}},EC=new Set(["accent","success","warning","muted"]),SC=t=>{if(typeof t!="string"||!EC.has(t))throw new Error(`invalid projected chart color: ${String(t)}`);return t},fp=(t,e)=>{if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`projected point in ${e} is invalid`);const n=t;if(!yi(n.time))throw new Error(`projected point time in ${e} is invalid`);if(n.value!==null&&!yi(n.value))throw new Error(`projected point value in ${e} must be finite or null`);return{time:n.time,value:n.value===null?Number.NaN:n.value}},TC=(t,e)=>{if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`projected band point in ${e} is invalid`);const n=t;if(!yi(n.time)||!yi(n.min)||!yi(n.max))throw new Error(`projected band point in ${e} is invalid`);return{time:n.time,min:n.min,max:n.max}},xC=(t,e)=>{if(e===null||typeof e!="object"||Array.isArray(e))throw new Error(`projected series ${t} is invalid`);const n=e;if(typeof n.supported!="boolean")throw new Error(`projected series ${t} supported is invalid`);if(typeof n.unit!="string"||n.unit.length===0)throw new Error(`projected series ${t} has invalid unit`);if(n.label!==void 0&&n.label!==null&&typeof n.label!="string")throw new Error(`projected series ${t} label is invalid`);if(!Array.isArray(n.points)||!Array.isArray(n.segments)||!Array.isArray(n.bands))throw new Error(`projected series ${t} arrays are invalid`);const r=n.points.map(a=>fp(a,t)),i=n.segments.map(a=>{if(a===null||typeof a!="object"||Array.isArray(a))throw new Error(`projected segment in ${t} is invalid`);const l=a;if(!Array.isArray(l.data))throw new Error(`projected segment data in ${t} is invalid`);return{data:l.data.map(c=>fp(c,t))}}),s=n.bands.map(a=>{if(a===null||typeof a!="object"||Array.isArray(a))throw new Error(`projected band in ${t} is invalid`);const l=a;if(typeof l.id!="string"||!Array.isArray(l.data))throw new Error(`projected band in ${t} is invalid`);return{id:l.id,data:l.data.map(c=>TC(c,t)),color:SC(l.color)}});let o;if(n.valueDomain!==void 0&&n.valueDomain!==null){if(typeof n.valueDomain!="object"||Array.isArray(n.valueDomain))throw new Error(`projected series ${t} valueDomain is invalid`);const a=n.valueDomain;if(!yi(a.min)||!yi(a.max))throw new Error(`projected series ${t} valueDomain is invalid`);o={min:a.min,max:a.max}}return{label:typeof n.label=="string"?n.label:void 0,supported:n.supported,unit:n.unit,points:r,segments:i,bands:s,valueDomain:o}},CC=t=>{if(t===null||typeof t!="object"||Array.isArray(t))throw new Error("projected telemetry response must be an object");const e=t,n=e.gathering;if(n===null||typeof n!="object"||Array.isArray(n)||typeof n.enabled!="boolean")throw new Error("projected telemetry gathering is invalid");const r=e.keys;if(r===null||typeof r!="object"||Array.isArray(r))throw new Error("projected telemetry keys are invalid");const i={};for(const[s,o]of Object.entries(r))i[s]=xC(s,o);return{keys:i,gathering:{enabled:n.enabled},clock:kC(e.clock),sessionConfigured:typeof e.sessionConfigured=="boolean"?e.sessionConfigured:!1}},PC=t=>t!==null&&typeof t=="object"&&"name"in t&&t.name==="AbortError";function RC(t=globalThis.fetch){const e=async(n,r,i)=>{const s=await t(n,{method:"GET",cache:"no-store",signal:i.signal});if(!s.ok)throw new dp(s.status,i.unavailableMessage);try{return r(await s.json())}catch(o){throw PC(o)?o:new dp(s.status,o instanceof Error?o.message:i.invalidResponseMessage)}};return{async fetchProjected(n,r={}){return e(`/api/mndw/telemetry?project=${n}`,CC,{signal:r.signal,unavailableMessage:"Projected telemetry is unavailable.",invalidResponseMessage:"Invalid projected telemetry response."})}}}const af=t=>e=>{if(e.code!=="unrecognized_keys")return;const n=[...e.keys].sort()[0]??"<unknown>";return`${t} contains unknown field "${n}"`},AC=me().regex(/^[a-z0-9][a-z0-9-]*$/,{message:"name must be lowercase alphanumeric with hyphens (e.g. my-widget)"}),OC=t=>!t.startsWith("/")&&!t.includes("..")&&!t.includes("\\")&&!t.split("/").some(e=>e==="."||e===".."),Qv=t=>{const e=t.split("/").filter(Boolean);return!!e[e.length-1]},lf=me().min(1).refine(OC,{message:"must be a safe relative path"}),MC=lf.refine(Qv,{message:"entry must include a file name"}),Qu=t=>{try{if(typeof Intl.getCanonicalLocales=="function")return Intl.getCanonicalLocales(t)[0];if(typeof Intl.Locale=="function")return new Intl.Locale(t).toString()}catch{}},NC=me().min(1).superRefine((t,e)=>{const n=Qu(t);n===void 0?e.addIssue({code:"custom",message:"must be a valid BCP-47 locale tag"}):n!==t&&e.addIssue({code:"custom",message:`must use canonical BCP-47 spelling (${n})`})}),LC=lf.refine(t=>t.endsWith(".json"),{message:"catalog path must end with .json"}),IC=ot({defaultLocale:NC,locales:qs(me(),LC)}).strict().superRefine((t,e)=>{const n=Object.keys(t.locales);n.length===0&&e.addIssue({code:"custom",path:["locales"],message:"locales must contain at least one locale"});const r=new Map;for(const s of n){const o=Qu(s);if(o===void 0){e.addIssue({code:"custom",path:["locales",s],message:"must be a valid BCP-47 locale tag"});continue}o!==s&&e.addIssue({code:"custom",path:["locales",s],message:`must use canonical BCP-47 spelling (${o})`});const a=r.get(o);a!==void 0&&a!==s?e.addIssue({code:"custom",path:["locales",s],message:`canonical locale collides with ${a}`}):r.set(o,s)}const i=Qu(t.defaultLocale);i!==void 0&&!r.has(i)&&e.addIssue({code:"custom",path:["defaultLocale"],message:"defaultLocale must be present in locales"})}),eb=me().regex(/^[a-z0-9][a-z0-9+_.-]*$/),tb=Cn(["session","public"]).default("session"),zC=me().transform(t=>t.toUpperCase()).pipe(Cn(["GET","HEAD","POST","PUT","PATCH","DELETE"])),nb=t=>{if(t.length===0||t.startsWith("/")||t.includes("\\")||t.includes("?")||t.includes("#"))return!1;let e;try{e=decodeURIComponent(t)}catch{return!1}if(e!==t||e.includes("%")||e.startsWith("/")||e.includes("\\"))return!1;const n=e.split("/");return n.every(r=>r.length>0&&r!=="."&&r!=="..")&&n[0]!=="_mndw"},rb=lf.regex(/^backend\//,{message:"command must start with backend/"}).refine(Qv,{message:"command must include a file name"}).refine(t=>!t.split("/").some(e=>e==="."||e===".."),{message:"command must not contain dot segments"}),DC=me().min(1).refine(t=>[...t].every(e=>{const n=e.codePointAt(0)??0;return n>31&&n!==127}),{message:"args must not contain control characters"}),ib=ot({id:me().min(1),transport:Yt("http"),method:zC,path:me().refine(nb,{message:"path must be canonical and safe"}),access:tb}),HC=ot({id:me().min(1),transport:Yt("websocket"),path:me().refine(nb,{message:"path must be canonical and safe"}),access:tb,protocols:Ht(me().min(1)).optional()}),BC=ib.extend({command:rb}),sb=(t,e)=>{const n=t.map(i=>i.id);new Set(n).size!==n.length&&e.addIssue({code:"custom",message:"backend.routes contains duplicate id"});const r=t.map(i=>i.transport==="http"?`${i.transport}:${i.method}:${i.path}`:`${i.transport}:${i.path}`);new Set(r).size!==r.length&&e.addIssue({code:"custom",message:"backend.routes contains duplicate route tuple"});for(const i of t)i.transport==="http"&&i.access==="public"&&!["GET","HEAD"].includes(i.method??"")&&e.addIssue({code:"custom",message:"public HTTP routes may only use GET or HEAD"})},UC=ot({kind:Yt("exec"),packages:Ht(eb).optional(),routes:Ht(BC).min(1,{message:"backend.routes must contain at least one route"})}).strict().superRefine((t,e)=>{sb(t.routes,e)}),jC=ot({kind:Yt("service"),protocolVersion:bn().int().positive(),command:rb,args:Ht(DC).optional(),packages:Ht(eb).optional(),routes:Ht(mi([ib,HC])).min(1,{message:"backend.routes must contain at least one route"})}).strict().superRefine((t,e)=>{sb(t.routes,e)}),$C=mi([UC,jC]),hp=bn().int({message:"gridColumns must be an integer"}).min(1,{message:"gridColumns must be at least 1"}).max(12,{message:"gridColumns must be at most 12"}),pp=bn().int().positive(),FC=Yt(1).describe("Manifest format version. Must be 1."),GC=AC.describe("Unique plugin id used as the on-disk folder and URL segment."),VC=me().regex(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/,{message:"version must be valid SemVer (for example, 1.2.3)"}).describe("Semantic version of this plugin."),ZC=me().min(1).describe("Human-readable name shown in the dashboard or navigation."),WC=me().refine(t=>{const e=Array.from(t).length;return e>=1&&e<=160},{message:"Description must contain between 1 and 160 Unicode code points."}).meta({minLength:1,maxLength:160}).describe("Optional plain-text description in the plugin default language."),qC=MC.describe("Relative path to the bundled entry module."),KC=dv,YC=Ht(KC).superRefine((t,e)=>{new Set(t).size!==t.length&&e.addIssue({code:"custom",message:"capabilities contains duplicate capability"})}),XC=ot({w:hp,h:pp,minW:hp.optional(),minH:pp.optional()},{error:af("size")}).strict().refine(t=>t.minW===void 0||t.minW<=t.w,{message:"size.minW must be less than or equal to size.w",path:["minW"]}).refine(t=>t.minH===void 0||t.minH<=t.h,{message:"size.minH must be less than or equal to size.h",path:["minH"]}),JC=me().regex(/^\/[^/?#*]+$/).refine(t=>!qm(t),{message:"route is reserved by the host"}),ob={$schema:me({error:"$schema must be a string"}).optional().describe("JSON Schema editor hint for this manifest."),manifestVersion:FC,name:GC,version:VC,label:ZC,description:WC.optional(),entry:qC,capabilities:YC.optional(),i18n:IC.optional(),backend:$C.optional()},QC=ot({...ob,type:Yt("widget"),size:XC},{error:af("manifest")}).strict(),eP=ot({...ob,type:Yt("page"),route:JC},{error:af("manifest")}).strict(),tP=Vd("type",[QC,eP]),nP={permissions:"permissions was renamed to capabilities in 0.3",icon:"icon was removed in 0.3",fixedHeight:"fixedHeight was removed in 0.3"};class gp extends Error{constructor(n,r){const i=r.map(o=>{const a=o.code==="unrecognized_keys"?[...o.path,[...o.keys].sort()[0]??"<unknown>"]:o.path;return{path:a.length===0?"<root>":a.join("."),message:o.message}}),s=i.map(o=>`${o.path}: ${o.message}`).join("; ");super(`Invalid manifest for "${n}": ${s}`);X(this,"issues");this.issues=i}}function ab(t){let e=t;if(typeof t=="object"&&t!==null&&!Array.isArray(t)){const r=t,i=typeof r.name=="string"?r.name:"unknown";for(const[o,a]of Object.entries(nP))if(Object.prototype.hasOwnProperty.call(r,o))throw new gp(i,[{code:"custom",path:[o],message:a}]);const s={...r};(r.type==="page"||r.type==="widget")&&delete s[r.type==="page"?"size":"route"],e=s}const n=tP.safeParse(e);if(!n.success){const r=typeof t=="object"&&t!==null&&typeof t.name=="string"?t.name:"unknown";throw new gp(r,n.error.issues)}return delete n.data.$schema,n.data}ot({cid:me().optional(),mac:me().optional(),ip:me().optional(),fqdn:me().optional(),"fqdn-certificate-valid":_i().optional(),capabilities:qs(me(),Bu()).optional()}).passthrough();const rP=[{specifiers:["@rci-tools/core"],bundle:"rci-tools-core",version:"0.6.0",entryPoint:"@rci-tools/core",external:["rxjs","hash-wasm"],framework:"base"},{specifiers:["rxjs"],bundle:"rxjs",version:"7.8.2",entryPoint:"rxjs",framework:"base"},{specifiers:["rxjs/operators"],bundle:"rxjs-operators",version:"7.8.2",entryPoint:"rxjs/operators",framework:"base"},{specifiers:["hash-wasm"],bundle:"hash-wasm",version:"4.12.0",entryPoint:"hash-wasm",framework:"base"},{specifiers:["d3"],bundle:"d3",version:"7.9.0",entryPoint:"d3",framework:"base"},{specifiers:["@mndw/ui"],bundle:"mndw-ui",version:"0.3.2",entryPoint:"@mndw/ui",external:["d3"],framework:"base"},{specifiers:["vue"],bundle:"vue",version:"3.5.39",entryPoint:"vue",banner:"var __VUE_OPTIONS_API__=true,__VUE_PROD_DEVTOOLS__=false,__VUE_PROD_HYDRATION_MISMATCH_DETAILS__=false;",framework:"vue"},{specifiers:["zone.js"],bundle:"zone",version:"0.15.1",entryPoint:"zone.js",framework:"angular"},{specifiers:["@angular/core","@angular/core/rxjs-interop"],bundle:"angular-core",version:"21.2.18",stdin:"export * from '@angular/core'; export * from '@angular/core/rxjs-interop';",external:["rxjs","rxjs/operators","@angular/compiler"],framework:"angular"},{specifiers:["@angular/common"],bundle:"angular-common",version:"21.2.18",entryPoint:"@angular/common",external:["rxjs","@angular/compiler","@angular/core"],framework:"angular"},{specifiers:["@angular/platform-browser"],bundle:"angular-platform-browser",version:"21.2.18",entryPoint:"@angular/platform-browser",external:["rxjs","@angular/compiler","@angular/core"],framework:"angular"},{specifiers:["@angular/compiler"],bundle:"angular-compiler",version:"21.2.18",entryPoint:"@angular/compiler",external:["rxjs"],framework:"angular"}],cf=()=>Object.fromEntries(rP.flatMap(t=>t.specifiers.map(e=>[e,t.version]))),iP=Cn(["builtin","registry","upload"]),sP=Cn(["pending","approved"]),oP=Cn(["ready","installing","failed"]),aP=Cn(["stopped","capacity_blocked","starting","ready","backoff","failed"]),lP=ot({kind:Cn(["exec","service"]),packages:Ht(me()).optional(),args:Ht(me()).optional(),publicRoutes:Ht(me()).optional()}),cP=qs(me(),_i()).superRefine((t,e)=>{for(const n of Object.keys(t))VT(n)||e.addIssue({code:"custom",path:[n],message:"only persistent RCI capabilities may be granted"})}),uP=ot({transport:Cn(["http","websocket"]),path:me(),method:Cn(["GET","HEAD","POST","PUT","PATCH","DELETE"]).optional(),protocols:Ht(me()).optional()}),dP=ot({routes:qs(me(),uP)}),fP=ot({w:bn(),h:bn(),minW:bn().optional(),minH:bn().optional()}),hP=ot({defaultLocale:me(),locales:qs(me(),me())}),pP=ot({state:aP,restartCount:bn(),consecutiveFailures:bn(),startedAt:me().optional(),nextAttemptAt:me().optional(),lastExit:me().optional(),lastError:me().optional(),recentStderr:Ht(me()).optional(),requiredProtocol:bn().optional(),compatible:_i().optional(),supportedProtocols:Ht(bn()).optional()}),gP=ot({sdkVersion:me(),sharedDependencies:qs(me(),me())}),lb={name:me(),version:me(),label:me(),description:me().optional(),entry:me(),source:iP,approval:sP,enabled:_i(),capabilities:Ht(dv).optional(),capabilityGrants:cP.optional(),depsStatus:oP,backend:dP,review:lP.optional(),i18n:hP.optional(),catalogBaseUrl:me().optional(),runtime:pP.optional(),lock:gP.optional()},mP=ot({...lb,type:Yt("widget"),size:fP}),vP=ot({...lb,type:Yt("page"),route:me()}),cb=Vd("type",[mP,vP]),bP=ot({plugins:Ht(cb)}),ub=t=>bP.parse(t).plugins,ou=t=>cb.parse(t),Sl=new Ti;function uc(t){return Sl.get(t)??"ready"}function zs(t){Sl.clear();for(const e of t)Sl.set(e.name,e.depsStatus)}let _P=0,Na=null,mp;function wP(){clearTimeout(mp),mp=void 0,Na==null||Na.abort(),Na=null,_P+=1}let Bo=0,Uo=new AbortController;function yP(t=!1){return Uo.abort(),Uo=new AbortController,Bo+=1,t||(V.pluginLoadError=null),V.authInitInFlight=!0,Bo}function Ur(){return Bo}function kP(){return Uo.signal}function EP(t){t===Bo&&(V.authInitInFlight=!1)}const V=pt({authenticated:!1,ready:!1,authInitInFlight:!1,pluginLoadRevision:0,pluginLoadFailureSeq:0,hostInfo:null,deviceInfo:null,pluginLoadError:null,loginError:null,loginUsername:"",mobileSidebarOpen:!1,desktopSidebarCollapsed:!1,theme:"dark",locale:"en",localeSwitchPending:!1});function au(){fa().matches?V.mobileSidebarOpen=!V.mobileSidebarOpen:V.desktopSidebarCollapsed=!V.desktopSidebarCollapsed}function dc(){Bo+=1,Uo.abort(),Uo=new AbortController,wP(),V.authenticated=!1,V.ready=!1,V.authInitInFlight=!1,V.pluginLoadError=null,V.loginError=null,V.loginUsername="",V.pluginLoadFailureSeq=0,V.hostInfo=null,V.deviceInfo=null}const SP={loading:"Loading…",error:"Something went wrong.","plugin-load-error":"Couldn't load plugins."},TP={"toggle-menu":"Toggle menu",close:"Close navigation",dashboard:"Dashboard","package-manager":"Entware","page-load-failed":"Page failed to load",settings:"Settings","light-theme":"Switch to light theme","dark-theme":"Switch to dark theme","color-theme":"Toggle color theme",language:"Language","language-english":"Switch to English","language-russian":"Switch to Russian",logout:"Log out"},xP={"add-widget":"Add widget","arrange-widgets":"Arrange widgets","no-widgets":"No widgets available",preparing:"preparing…",unavailable:"unavailable","move-up":"Move {label} up","move-down":"Move {label} down","remove-widget":"Remove {label}","preparing-dependencies":"Preparing… installing dependencies","dependency-install-failed":"Dependency install failed","plugin-load-failed":"Plugin “{label}” failed to load","retry-plugin-load":"Retry","remove-failed-plugin":"Remove","widget-error":"Error loading widget","empty-error-title":"Widgets unavailable","empty-error-text":"Plugins could not be loaded — see the message above.","empty-no-plugins":"No enabled plugins provide widgets.","empty-install-plugins":"Manage plugins","empty-title":"Dashboard is empty","empty-add-widget":"Add a widget to get started.","widget-removed":"Widget “{label}” removed","layout-save-failed":"Dashboard changes were not saved. Browser storage may be unavailable or full."},CP=JSON.parse(`{"title":"Settings","general-tab":"General","diagnostics-tab":"Diagnostics","plugins-tab":"Plugins","self-update-tab":"Update mndw","self-update-description":"Check for and safely install a new mndw package, or restore the previous package.","self-update-current":"Running version: {version}","self-update-rollback":"Rollback version: {version}","self-update-available":"Update available: {version}","self-update-check":"Check for updates","self-update-apply":"Apply update","self-update-revert":"Revert","self-update-confirm-update-title":"Confirm update","self-update-confirm-revert-title":"Confirm revert","self-update-confirm-update":"Install update to {version}? mndw will restart.","self-update-confirm-revert":"Revert to {version}? mndw will restart.","self-update-progress-title":"mndw update","self-update-checking":"Checking…","self-update-preparing":"Preparing update…","self-update-updating":"Updating to {version}…","self-update-reverting":"Reverting to {version}…","self-update-success":"Update complete. Running version: {version}","self-update-busy":"Entware is busy installing or updating packages. Try again shortly.","self-update-no-update":"No update is available. Check again later.","self-update-rollback-unavailable":"No rollback is available.","self-update-unconfirmed":"Update started, but its final state could not be confirmed. Check again.","self-update-unconfirmed-modal":"Unable to confirm self-update completion. Check status again after closing this dialog.","self-update-failure-generic":"Self-update failed. Check again or retry later.","self-update-failure-update-missing":"Update package was not found.","self-update-failure-opkg-install-failed":"Update package installation failed.","self-update-failure-opkg-revert-failed":"Rollback package installation failed.","self-update-failure-rollback-missing":"Rollback package was not found.","self-update-failure-helper-exited":"Update helper stopped before completion.","self-update-failure-unexpected-version":"Device version changed unexpectedly during update.","self-update-failure-state-corrupt":"Self-update state is corrupted. Check again.","general":"General","language":{"label":"Language","english":"English","russian":"Русский","pending":"Applying language…"},"appearance":"Interface","dark-theme":"Dark theme","device":"Device","telemetry-label":"Background telemetry","telemetry-toggle":"Enable telemetry","telemetry-description":"Store CPU, memory, and temperature history for 30 days.","telemetry-session-note":"A background router access session is needed for telemetry.","telemetry-session-link":"Configure background router access","telemetry-wear-note":"Telemetry collection will increase the load on the storage device where Entware is installed and may accelerate its wear.","telemetry-error":"Could not update background telemetry.","name":"Name:","vendor":"Vendor:","firmware":"Firmware:","device-unavailable":"Device info unavailable.","persistent-rci-title":"Background router access","persistent-rci-description":"mndw keeps its own RCI sign-in to this router so telemetry history and plugins work without an open browser tab. Tokens stay inside mndw.","persistent-loading":"Loading background router access…","configure-persistent":"Configure background router access","persistent-tokenless-toggle":"Controller and extender access","persistent-tokenless-description":"No controller token is needed on this firmware.","persistent-needs-token":"Firmware now requires a controller token for background router access.","persistent-storage-disabled":"Background router access storage is disabled.","persistent-storage-decrypt-failed":"Background router access storage could not be decrypted.","controller-token":"Controller token","controller-token-hint":"Create a token in the router's web interface on the Users & Access page, or in the router's command line.","controller-token-set-placeholder":"Token is set","test":"Test","save":"Save","clear-controller-session":"Clear controller access","clear-controller-session-title":"Clear controller access?","clear-controller-session-confirm":"Persistent RCI sessions will stop until you save a controller token again.","update-firmware-persistent":"Update device firmware to enable background router access.","controller-token-valid":"Controller token is valid","persistent-extenders-title":"Extenders","persistent-extenders-summary":"Extenders ({count})","persistent-extenders-summary-problems":"Extenders ({count}) · {problems} without access","persistent-enumeration-stale":"Extender membership is temporarily stale; live connections are still monitored.","extender-reason-certificate-invalid":"certificate is invalid","extender-reason-no-auth-token":"auth-token capability unavailable","extender-reason-missing-fqdn":"secure relay name unavailable","extender-state-offline":"offline","extender-state-establishing":"coming online","extender-state-live":"connected","extender-state-dead":"reconnecting","persistent-state-unavailable":"Background router access state unavailable","persistent-request-failed":"Background router access request failed","controller-token-rejected":"Controller token rejected","firmware-unsupported":"Device firmware does not support background router access","device-unreachable":"Device unreachable","palette-import-aria-label":"Import palette JSON","palette":{"title":"Palette","loading":"Loading palette…","reading":"Reading palette…","saved":"Saved.","drop":"Drop a palette JSON file here or choose one.","read-failed":"Could not read palette file.","invalid-json":"Invalid JSON file.","invalid-structure":"The palette file is invalid.","load-failed":"Could not load the palette.","operation-failed":"Could not update the palette.","preview-note":"Previewing the imported palette. Nothing is saved to the device until you confirm.","contrast-warnings":"Contrast warnings ({theme})","warning-item":"{pair}: {ratio} (needs {min})","theme-dark":"Dark theme","theme-light":"Light theme","confirm":"Confirm","discard":"Discard","reset-confirmation":"Discard the imported palette and return to the built-in colours?","reset-confirm":"Yes, reset","reset":"Reset to default","export":"Export palette"},"backend-capacity":"Backend capacity","backend-approval-title":"Approve backend for {label}","backend-approval-declaration":"declares a backend. Review its capabilities before approving.","backend-approval-deny":"Deny","backend-approval-approve":"Approve","plugin-risk-warning-intro":"Plugins run with full access.","plugin-risk-warning-page":"A plugin page runs in this dashboard and can call the router API; if it has a backend, that backend runs on the router as root.","plugin-risk-warning-trust":"Manifest capabilities describe what the plugin asks for; they are not a sandbox. Install plugins only from authors you trust.","upload-plugin-zip":"Upload plugin ZIP","diagnostics-description":"Download recent daemon and plugin runtime state for troubleshooting.","download-diagnostics":"Download diagnostics","downloading":"Downloading…","diagnostics-failed":"Diagnostics download failed","plugin-manager":{"title":"Plugin manager","plugin-updated-notice":"A newer plugin version is installed. Reload to use it.","reload-now":"Reload now","later":"Later","loading":"Loading plugins…","retry":"Retry","dismiss":"Dismiss","keep-notice":"Keep","diagnostics":"Diagnostics","last-error":"Last error","exec":"Exec","services":"Services","per-plugin-exec-limit":"Per-plugin exec limit","service-protocols":"Service protocols","runtime-status-unavailable":"Runtime status unavailable: {error}","maintenance-busy":"Plugin is busy with another maintenance operation. Try again shortly.","confirming-state":"Confirming plugin state…","operation-finishing":"Plugin operation is still finishing. Refresh to check again.","outcome-unknown":"Could not confirm restart outcome. Refresh to check plugin status.","installed-title":"Installed plugins","no-installed":"No plugins installed.","no-installed-next":"Upload a plugin to add it to this router.","version":"Version","type-widget":"Widget","type-page":"Page","builtin":"Built-in","uploaded":"Uploaded","installing-dependencies":"Installing dependencies…","dependency-install-failed":"Dependency install failed","plugin-load-failed":"Failed to load","plugin-load-timeout":"Did not load within {seconds} seconds","plugin-load-error":"The plugin file did not load or contains an error","version-mismatch":"Version mismatch","sdk-major-badge":"Built for another SDK version","load-version-warning":"Built against {versions}. Plugin still loads, but may misbehave with this host.","version-warning":{"title":"Version compatibility","sdk-major":"Built for @mndw/sdk {pluginVersion}; this dashboard provides {hostVersion}. The plugin may not work.","sdk-newer-minor":"Built for a newer @mndw/sdk ({pluginVersion}) than this dashboard provides ({hostVersion}). Some features may not work.","shared-major":"Built for {name} {pluginVersion}; this dashboard provides {hostVersion}. The plugin may not work.","install-anyway":"You can still install it."},"endpoint":"{count, plural, one {# endpoint} other {# endpoints}}","websocket":"{count, plural, one {# websocket} other {# websockets}}","persistent-rci-read":"Persistent RCI read","persistent-rci-write":"Persistent RCI write","refresh":"Refresh","enable":"Enable","disable":"Disable","restart-backend":"Restart backend","delete-confirmation":"Delete {label}? This cannot be undone.","cancel":"Cancel","delete-plugin":"Delete plugin","delete":"Delete","backend":"Backend","protocol":"Protocol","incompatible":"incompatible","supported-service-protocols":"Supported service protocols","runtime-state-stopped":"Stopped","runtime-state-capacity-blocked":"Waiting for a free slot","runtime-state-starting":"Starting","runtime-state-ready":"Running","runtime-state-backoff":"Restarting after a failure","runtime-state-failed":"Failed","pending-title":"Pending approvals","deny-confirmation":"Deny {label}? This cannot be undone.","deny-plugin":"Deny plugin","deny":"Deny","approve":"Approve","routes":"Routes","backend-kind-service":"Background process","backend-kind-exec":"Runs a command per request","packages":"Installs packages","service-args":"Service arguments","public-routes":"Public routes (reachable from the LAN without sign-in)","capabilities":"Capabilities","upload-drop":"Drop a plugin ZIP here or choose a file.","uploading":"Uploading plugin…","waiting-approval":"Waiting for approval…","installed-success":"Installed “{label}”.","approved-success":"Approved “{label}”.","choose-zip":"Choose a ZIP file.","empty-zip":"The ZIP file is empty.","zip-too-large":"The ZIP file exceeds the {limit} upload limit.","upload-limit-unit":"MiB","upload-target-mismatch":"{filename} targets {archiveTarget}, but this device reports {deviceTarget}. Choose the matching archive."}}`),PP={cancel:"Cancel",close:"Close",save:"Save",retry:"Retry",undo:"Undo"},RP={username:"Username",password:"Password",hint:"Use the router's administrator username and password.",submit:"Log in","logging-in":"Logging in…","invalid-credentials":"Invalid credentials","connection-failed":"Connection failed"},AP={region:"Notifications",dismiss:"Dismiss"},OP={tab:"Packages",refresh:"Check for updates",checking:"Checking…",search:"Search name or description…","search-label":"Search name or description",all:"All",installed:"Installed","status-installed":"Installed",updates:"Updates ({count})","selection-hint":"Select packages to install, update or remove them together","selection-count":"Selected: {count}","action-count":"{action} ({count})","clear-selection":"Clear selection",install:"Install",remove:"Remove",update:"Update","update-in-settings":"Update in Settings",installing:"Installing…",removing:"Removing…",updating:"Updating…","action-failed":"{action} failed","update-available":"Update available",available:"Available",loading:"Loading…","load-failed":"Failed to load packages",empty:"No packages found","empty-next":"Refresh the package list to check again.","no-match":"No packages match your filter","no-match-next":"Try a different search or package filter.","show-all":"Show all packages",package:"Package",version:"Version",status:"Status",description:"Description",expand:"Expand {name}",collapse:"Collapse {name}","never-refreshed":"The package list has not been updated yet","just-now":"Package list updated just now","refreshed-ago":"Package list updated {age}","detail-failed":"Failed to load package details",size:"Feed size","installed-size":"Installed size","installed-time":"Installed time",dependencies:"Dependencies","confirm-remove-title":"Confirm package removal","confirm-remove":"Remove {names}?",protected:"Protected package","protected-label":"Protected","dependency-conflict":"Can't remove {package}: it is required by {dependents}.","dependency-conflict-generic":"Can't remove {package}: it is required by other installed packages."},MP={tab:"Services",description:"Inspect and control device init services.",refresh:"Refresh states",service:"Service",state:"State",autostart:"Autostart",actions:"Actions",start:"Start",stop:"Stop",restart:"Restart",enabled:"Enabled",disabled:"Disabled","enable-at-boot":"Enable at boot","disable-at-boot":"Disable at boot",pid:"PID {pid}","autostart-pinned":"Autostart is fixed by ENABLED= in the script","state-running":"Running","state-stopped":"Stopped","state-unknown":"Unknown","probe-failed":"Unknown",empty:"No services found","empty-next":"Refresh to check the service list again.","load-failed":"Failed to load services",unavailable:"No service manager available","unavailable-description":"This device does not expose an init service directory.","protected-label":"Protected",protected:"Protected service","confirm-title":"Confirm service action",confirm:"{action} service {name}?","confirm-enable-boot":"Enable {name} at boot? The running service is unchanged until reboot.","confirm-disable-boot":"Disable {name} at boot? The running service is unchanged until reboot."},NP={"device-timeout":"The device did not respond.","invalid-manifest":"The plugin manifest is invalid.","invalid-zip":"The file is not a valid ZIP archive.","manifest-missing":"The archive has no manifest.json at its root.","unsupported-manifest-version":"This plugin manifest version is no longer supported.",conflict:"A plugin with that name already exists.","upload-too-large":"The plugin exceeds the {limit} upload limit.","opkg-failed":"Installing the plugin's system packages failed.","daemon-failed":"Starting the plugin's backend failed.",unauthorized:"Your session has expired. Please log in again.","service-capacity":"No service capacity is available. Stop another backend and try again.","backend-busy":"The backend is busy. Try again shortly.","backend-unavailable":"The backend is unavailable.","backend-incompatible":"This backend requires an unsupported protocol version.","backend-maintenance":"The backend is being updated. Try again shortly.","controller-session-unavailable":"Controller token session is unavailable.","rci-socket-start-failed":"Background router access could not start. Try again."},db={app:SP,nav:TP,dashboard:xP,settings:CP,"page-plugin":{opening:"Opening {title}…","open-error":"Could not open the page of plugin {title}.","load-failed":"Page “{title}” failed to load",slow:"The plugin is taking too long to respond."},"plugin-load":{failed:"Plugins failed to load: {names}",loaded:"Plugins loaded"},common:PP,login:RP,toast:AP,packages:OP,services:MP,errors:NP},LP={loading:"Загрузка…",error:"Произошла ошибка.","plugin-load-error":"Не удалось загрузить плагины."},IP={"toggle-menu":"Переключить меню",close:"Закрыть навигацию",dashboard:"Дашборд","package-manager":"Entware","page-load-failed":"Не удалось загрузить страницу",settings:"Настройки","light-theme":"Включить светлую тему","dark-theme":"Включить тёмную тему","color-theme":"Переключить цветовую тему",language:"Язык","language-english":"Переключить на английский","language-russian":"Переключить на русский",logout:"Выйти"},zP={"add-widget":"Добавить виджет","arrange-widgets":"Упорядочить виджеты","no-widgets":"Нет доступных виджетов",preparing:"подготовка…",unavailable:"недоступен","move-up":"Переместить {label} выше","move-down":"Переместить {label} ниже","remove-widget":"Удалить {label}","preparing-dependencies":"Подготовка… установка зависимостей","dependency-install-failed":"Не удалось установить зависимости","plugin-load-failed":"Не удалось загрузить плагин «{label}»","retry-plugin-load":"Повторить","remove-failed-plugin":"Удалить","widget-error":"Не удалось загрузить виджет","empty-error-title":"Виджеты недоступны","empty-error-text":"Не удалось загрузить плагины — см. сообщение выше.","empty-no-plugins":"Ни один включённый плагин не предоставляет виджетов.","empty-install-plugins":"Управление плагинами","empty-title":"Дашборд пуст","empty-add-widget":"Добавьте виджет, чтобы начать.","widget-removed":"Виджет «{label}» удалён","layout-save-failed":"Изменения дашборда не сохранены. Хранилище браузера может быть недоступно или заполнено."},DP=JSON.parse('{"title":"Настройки","general-tab":"Общие","diagnostics-tab":"Диагностика","plugins-tab":"Плагины","self-update-tab":"Обновление mndw","self-update-description":"Проверяйте и безопасно устанавливайте новую версию mndw или восстанавливайте предыдущую.","self-update-current":"Текущая версия: {version}","self-update-rollback":"Версия для отката: {version}","self-update-available":"Доступно обновление: {version}","self-update-check":"Проверить обновления","self-update-apply":"Установить обновление","self-update-revert":"Откатить","self-update-confirm-update-title":"Подтвердите обновление","self-update-confirm-revert-title":"Подтвердите откат","self-update-confirm-update":"Установить обновление до версии {version}? mndw будет перезапущен.","self-update-confirm-revert":"Откатить до версии {version}? mndw будет перезапущен.","self-update-progress-title":"Обновление mndw","self-update-checking":"Проверка…","self-update-preparing":"Подготовка обновления…","self-update-updating":"Обновление до {version}…","self-update-reverting":"Откат до {version}…","self-update-success":"Обновление завершено. Текущая версия: {version}","self-update-busy":"Entware занят установкой или обновлением пакетов. Повторите попытку позже.","self-update-no-update":"Обновление недоступно. Повторите проверку позже.","self-update-rollback-unavailable":"Откат недоступен.","self-update-unconfirmed":"Обновление запущено, но результат не подтверждён. Проверьте состояние ещё раз.","self-update-unconfirmed-modal":"Не удалось подтвердить завершение обновления. Закройте диалог и проверьте состояние ещё раз.","self-update-failure-generic":"Не удалось обновить систему. Повторите попытку позже.","self-update-failure-update-missing":"Пакет обновления не найден.","self-update-failure-opkg-install-failed":"Не удалось установить пакет обновления.","self-update-failure-opkg-revert-failed":"Не удалось установить пакет отката.","self-update-failure-rollback-missing":"Пакет отката не найден.","self-update-failure-helper-exited":"Помощник обновления завершился раньше времени.","self-update-failure-unexpected-version":"Версия устройства неожиданно изменилась во время обновления.","self-update-failure-state-corrupt":"Состояние обновления повреждено. Выполните проверку снова.","general":"Общие","language":{"label":"Язык","english":"English","russian":"Русский","pending":"Применение языка…"},"appearance":"Интерфейс","dark-theme":"Тёмная тема","device":"Устройство","telemetry-label":"Фоновая телеметрия","telemetry-toggle":"Включить телеметрию","telemetry-description":"Хранить историю CPU, памяти и температуры в течение 30 дней.","telemetry-session-note":"Для телеметрии нужна сессия фонового доступа к роутеру.","telemetry-session-link":"Настроить фоновый доступ к роутеру","telemetry-wear-note":"Сбор телеметрии увеличит нагрузку на накопитель, на котором установлен Entware, и может ускорить его износ.","telemetry-error":"Не удалось обновить фоновую телеметрию.","name":"Имя:","vendor":"Производитель:","firmware":"Прошивка:","device-unavailable":"Информация об устройстве недоступна.","persistent-rci-title":"Фоновый доступ к роутеру","persistent-rci-description":"mndw хранит собственную сессию входа на роутер, чтобы история телеметрии и плагины работали без открытой вкладки браузера. Токены остаются внутри mndw.","persistent-loading":"Загрузка фонового доступа к роутеру…","configure-persistent":"Настроить фоновый доступ к роутеру","persistent-tokenless-toggle":"Доступ к контроллеру и ретрансляторам","persistent-tokenless-description":"Для этой прошивки токен контроллера не нужен.","persistent-needs-token":"Для фонового доступа к роутеру прошивка требует токен контроллера.","persistent-storage-disabled":"Хранилище фонового доступа к роутеру отключено.","persistent-storage-decrypt-failed":"Не удалось расшифровать хранилище фонового доступа к роутеру.","controller-token":"Токен контроллера","controller-token-hint":"Токен создаётся в веб-интерфейсе роутера на странице «Пользователи и доступ» или в командной строке роутера.","controller-token-set-placeholder":"Токен задан","test":"Проверить","save":"Сохранить","clear-controller-session":"Удалить доступ к контроллеру","clear-controller-session-title":"Удалить доступ к контроллеру?","clear-controller-session-confirm":"Постоянные сессии RCI будут остановлены, пока вы снова не сохраните токен контроллера.","update-firmware-persistent":"Обновите прошивку устройства, чтобы включить фоновый доступ к роутеру.","controller-token-valid":"Токен контроллера действителен","persistent-extenders-title":"Ретрансляторы","persistent-extenders-summary":"Ретрансляторы ({count})","persistent-extenders-summary-problems":"Ретрансляторы ({count}) · без доступа: {problems}","persistent-enumeration-stale":"Список ретрансляторов временно устарел; активные подключения всё ещё проверяются.","extender-reason-certificate-invalid":"сертификат недействителен","extender-reason-no-auth-token":"возможность auth-token недоступна","extender-reason-missing-fqdn":"имя защищённого ретранслятора недоступно","extender-state-offline":"не в сети","extender-state-establishing":"подключается","extender-state-live":"подключён","extender-state-dead":"переподключается","persistent-state-unavailable":"Состояние фонового доступа к роутеру недоступно","persistent-request-failed":"Не удалось запросить состояние фонового доступа к роутеру","controller-token-rejected":"Токен контроллера отклонён","firmware-unsupported":"Прошивка устройства не поддерживает фоновый доступ к роутеру","device-unreachable":"Устройство недоступно","palette-import-aria-label":"Импорт JSON-палитры","palette":{"title":"Палитра","loading":"Загрузка палитры…","reading":"Чтение палитры…","saved":"Сохранено.","drop":"Перетащите JSON-файл палитры сюда или выберите файл.","read-failed":"Не удалось прочитать файл палитры.","invalid-json":"Файл содержит неверный JSON.","invalid-structure":"Файл палитры недействителен.","load-failed":"Не удалось загрузить палитру.","operation-failed":"Не удалось обновить палитру.","preview-note":"Предпросмотр импортированной палитры. На устройство ничего не сохранится, пока вы не подтвердите.","contrast-warnings":"Предупреждения о контрасте ({theme})","warning-item":"{pair}: {ratio} (минимум {min})","theme-dark":"Тёмная тема","theme-light":"Светлая тема","confirm":"Подтвердить","discard":"Не применять","reset-confirmation":"Сбросить импортированную палитру и вернуться к встроенным цветам?","reset-confirm":"Да, сбросить","reset":"Сбросить к встроенным цветам","export":"Экспорт палитры"},"backend-capacity":"Ёмкость серверной части","backend-approval-title":"Подтвердить серверную часть для {label}","backend-approval-declaration":"объявляет серверную часть. Проверьте её возможности перед подтверждением.","backend-approval-deny":"Отклонить","backend-approval-approve":"Подтвердить","plugin-risk-warning-intro":"Плагины работают с полным доступом.","plugin-risk-warning-page":"Страница плагина работает внутри mndw и может вызывать API роутера; если у плагина есть серверная часть, она запускается на роутере с правами root.","plugin-risk-warning-trust":"Доступы в манифесте описывают запросы плагина, но не изолируют его. Устанавливайте плагины только от авторов, которым доверяете.","upload-plugin-zip":"Загрузить ZIP плагина","diagnostics-description":"Скачать состояние демона и плагинов для диагностики.","download-diagnostics":"Скачать диагностику","downloading":"Скачивание…","diagnostics-failed":"Не удалось скачать диагностику","plugin-manager":{"title":"Менеджер плагинов","plugin-updated-notice":"Установлена новая версия плагина. Перезагрузите страницу, чтобы использовать её.","reload-now":"Перезагрузить сейчас","later":"Позже","loading":"Загрузка плагинов…","retry":"Повторить","dismiss":"Скрыть","keep-notice":"Оставить","diagnostics":"Диагностика","last-error":"Последняя ошибка","exec":"Exec","services":"Сервисы","per-plugin-exec-limit":"Лимит Exec для плагина","service-protocols":"Протоколы сервисов","runtime-status-unavailable":"Состояние серверной части недоступно: {error}","maintenance-busy":"Плагин занят другой операцией обслуживания. Повторите попытку позже.","confirming-state":"Проверка состояния плагина…","operation-finishing":"Операция с плагином ещё выполняется. Обновите страницу, чтобы проверить результат.","outcome-unknown":"Не удалось подтвердить результат перезапуска. Обновите страницу, чтобы проверить состояние плагина.","installed-title":"Установленные плагины","no-installed":"Плагины не установлены.","no-installed-next":"Загрузите плагин, чтобы добавить его на этот роутер.","version":"Версия","type-widget":"Виджет","type-page":"Страница","builtin":"Встроенный","uploaded":"Загруженный","installing-dependencies":"Установка зависимостей…","dependency-install-failed":"Не удалось установить зависимости","plugin-load-failed":"Не удалось загрузить","plugin-load-timeout":"Загрузка не завершилась за {seconds} с","plugin-load-error":"Файл плагина не загрузился или содержит ошибку","version-mismatch":"Несоответствие версии","sdk-major-badge":"Собран для другой версии SDK","load-version-warning":"Собрано для версий {versions}. Плагин всё ещё загружается, но может работать неправильно с этим хостом.","version-warning":{"title":"Совместимость версий","sdk-major":"Собрано для @mndw/sdk {pluginVersion}; эта версия mndw предоставляет {hostVersion}. Плагин может не работать.","sdk-newer-minor":"Собрано для более новой версии @mndw/sdk ({pluginVersion}), чем предоставляет эта версия mndw ({hostVersion}). Некоторые функции могут не работать.","shared-major":"Собрано для {name} {pluginVersion}; эта версия mndw предоставляет {hostVersion}. Плагин может не работать.","install-anyway":"Плагин всё равно можно установить."},"endpoint":"{count, plural, one {# конечная точка} few {# конечные точки} many {# конечных точек} other {# конечной точки}}","websocket":"{count, plural, one {# веб-сокет} few {# веб-сокета} many {# веб-сокетов} other {# веб-сокета}}","persistent-rci-read":"Чтение через постоянный RCI","persistent-rci-write":"Запись через постоянный RCI","refresh":"Обновить","enable":"Включить","disable":"Отключить","restart-backend":"Перезапустить серверную часть","delete-confirmation":"Удалить {label}? Это действие нельзя отменить.","cancel":"Отмена","delete-plugin":"Удалить плагин","delete":"Удалить","backend":"Серверная часть","protocol":"Протокол","incompatible":"несовместима","supported-service-protocols":"Поддерживаемые протоколы сервисов","runtime-state-stopped":"Остановлена","runtime-state-capacity-blocked":"Ожидает свободный слот","runtime-state-starting":"Запускается","runtime-state-ready":"Работает","runtime-state-backoff":"Перезапускается после сбоя","runtime-state-failed":"Ошибка","pending-title":"Ожидающие подтверждения","deny-confirmation":"Отклонить {label}? Это действие нельзя отменить.","deny-plugin":"Отклонить плагин","deny":"Отклонить","approve":"Подтвердить","routes":"Маршруты","backend-kind-service":"Фоновый процесс","backend-kind-exec":"Команда на каждый запрос","packages":"Устанавливает пакеты","service-args":"Аргументы сервиса","public-routes":"Публичные маршруты (доступны из локальной сети без входа)","capabilities":"Доступы","upload-drop":"Перетащите ZIP плагина сюда или выберите файл.","uploading":"Загрузка плагина…","waiting-approval":"Ожидание подтверждения…","installed-success":"Плагин «{label}» установлен.","approved-success":"Плагин «{label}» подтверждён.","choose-zip":"Выберите ZIP-файл.","empty-zip":"ZIP-файл пуст.","zip-too-large":"Размер ZIP-файла превышает лимит загрузки {limit}.","upload-limit-unit":"МБ","upload-target-mismatch":"Файл {filename} предназначен для {archiveTarget}, но устройство сообщает {deviceTarget}. Выберите подходящий архив."}}'),HP={cancel:"Отмена",close:"Закрыть",save:"Сохранить",retry:"Повторить",undo:"Отменить"},BP={username:"Имя пользователя",password:"Пароль",hint:"Используйте логин и пароль администратора роутера.",submit:"Войти","logging-in":"Выполняется вход…","invalid-credentials":"Неверные учётные данные","connection-failed":"Ошибка соединения"},UP={region:"Уведомления",dismiss:"Закрыть"},jP={tab:"Пакеты",refresh:"Проверить обновления",checking:"Проверяю…",search:"Поиск по имени или описанию…","search-label":"Поиск по имени или описанию",all:"Все",installed:"Установленные","status-installed":"Установлен",updates:"Обновления ({count})","selection-hint":"Отметьте пакеты, чтобы установить, обновить или удалить их разом","selection-count":"Выбрано: {count}","action-count":"{action} ({count})","clear-selection":"Очистить выбор",install:"Установить",remove:"Удалить",update:"Обновить","update-in-settings":"Обновить в настройках",installing:"Установка…",removing:"Удаление…",updating:"Обновление…","action-failed":"Не удалось выполнить: {action}","update-available":"Есть обновление",available:"Доступен",loading:"Загрузка…","load-failed":"Не удалось загрузить пакеты",empty:"Пакеты не найдены","empty-next":"Обновите список пакетов, чтобы проверить ещё раз.","no-match":"Нет пакетов, соответствующих фильтру","no-match-next":"Измените поисковый запрос или фильтр пакетов.","show-all":"Показать все пакеты",package:"Пакет",version:"Версия",status:"Состояние",description:"Описание",expand:"Развернуть {name}",collapse:"Свернуть {name}","never-refreshed":"Список пакетов ещё не обновлялся","just-now":"Список пакетов обновлён только что","refreshed-ago":"Список пакетов обновлён {age}","detail-failed":"Не удалось загрузить сведения о пакете",size:"Размер в репозитории","installed-size":"Установленный размер","installed-time":"Время установки",dependencies:"Зависимости","confirm-remove-title":"Подтвердите удаление пакета","confirm-remove":"Удалить {names}?",protected:"Защищённый пакет","protected-label":"Защищён","dependency-conflict":"Невозможно удалить {package}: от него зависит {dependents}.","dependency-conflict-generic":"Невозможно удалить {package}: от него зависят другие установленные пакеты."},$P={tab:"Сервисы",description:"Просмотр и управление сервисами устройства.",refresh:"Обновить состояния",service:"Сервис",state:"Состояние",autostart:"Автозапуск",actions:"Действия",start:"Запустить",stop:"Остановить",restart:"Перезапустить",enabled:"Включён",disabled:"Выключен","enable-at-boot":"Включать при загрузке","disable-at-boot":"Не включать при загрузке",pid:"PID {pid}","autostart-pinned":"Автозапуск задан строкой ENABLED= в скрипте","state-running":"Работает","state-stopped":"Остановлен","state-unknown":"Неизвестно","probe-failed":"Неизвестно",empty:"Сервисы не найдены","empty-next":"Обновите список, чтобы проверить сервисы ещё раз.","load-failed":"Не удалось загрузить сервисы",unavailable:"Менеджер сервисов недоступен","unavailable-description":"На устройстве нет доступного каталога init-сервисов.","protected-label":"Защищён",protected:"Защищённый сервис","confirm-title":"Подтвердите действие с сервисом",confirm:"{action} сервис {name}?","confirm-enable-boot":"Включать {name} при загрузке? Работающий сервис не изменится до перезагрузки.","confirm-disable-boot":"Не включать {name} при загрузке? Работающий сервис не изменится до перезагрузки."},FP={"device-timeout":"Устройство не отвечает.","invalid-manifest":"Манифест плагина недействителен.","invalid-zip":"Файл не является ZIP-архивом.","manifest-missing":"В архиве нет manifest.json в корне.","unsupported-manifest-version":"Версия манифеста плагина больше не поддерживается.",conflict:"Плагин с таким именем уже существует.","upload-too-large":"Плагин превышает лимит загрузки {limit}.","opkg-failed":"Не удалось установить системные пакеты плагина.","daemon-failed":"Не удалось запустить серверную часть плагина.",unauthorized:"Сессия истекла. Войдите снова.","service-capacity":"Нет свободных сервисных ресурсов.","backend-busy":"Серверная часть занята. Повторите позже.","backend-unavailable":"Серверная часть недоступна.","backend-incompatible":"Протокол серверной части не поддерживается.","backend-maintenance":"Серверная часть обновляется. Повторите позже.","controller-session-unavailable":"Сессия токена контроллера недоступна.","rci-socket-start-failed":"Не удалось запустить фоновый доступ к роутеру. Повторите попытку."},GP={app:LP,nav:IP,dashboard:zP,settings:DP,"page-plugin":{opening:"Открываем {title}…","open-error":"Не удалось открыть страницу плагина {title}.","load-failed":"Не удалось загрузить страницу «{title}»",slow:"Плагин долго не отвечает."},"plugin-load":{failed:"Не удалось загрузить плагины: {names}",loaded:"Плагины загружены"},common:HP,login:BP,toast:UP,packages:jP,services:$P,errors:FP},VP={A:"Ȧ",B:"Ḃ",C:"Ç",D:"Ḋ",E:"Ḗ",F:"Ḟ",G:"Ġ",H:"Ḧ",I:"Ī",J:"Ĵ",K:"Ḱ",L:"Ŀ",M:"Ṁ",N:"Ṅ",O:"Ö",P:"Ṕ",Q:"Q",R:"Ŕ",S:"Ṡ",T:"Ṫ",U:"Ū",V:"Ṽ",W:"Ẇ",X:"Ẋ",Y:"Ẏ",Z:"Ż",a:"ȧ",b:"ḃ",c:"ç",d:"ḋ",e:"ḗ",f:"ḟ",g:"ġ",h:"ḧ",i:"ī",j:"ĵ",k:"ḱ",l:"ŀ",m:"ṁ",n:"ṅ",o:"ö",p:"ṕ",q:"q",r:"ŕ",s:"ṡ",t:"ṫ",u:"ū",v:"ṽ",w:"ẇ",x:"ẋ",y:"ẏ",z:"ż"};function ZP(t){return[...t].map(e=>VP[e]??e).join("")}function WP(t){const e=t.replace(/\b\w+\b/g,n=>{const r="~".repeat(Math.max(1,Math.ceil(n.length*.35)));return`${n}${r}`});return`[${ZP(e)}]`}function fb(t){return Object.fromEntries(Object.entries(t).map(([e,n])=>[e,typeof n=="string"?WP(n):fb(n)]))}const hb=`${Id}:locale`,lu={en:db,ru:GP},qP=fb(db);function pb(t){try{if(typeof Intl.getCanonicalLocales=="function")return Intl.getCanonicalLocales(t)[0];if(typeof Intl.Locale=="function")return new Intl.Locale(t).toString()}catch{}}function gb(){return!1}function uf(){return um}function mb(t){const e=pb(t);return uf().find(n=>n===e)}function vp(t){const e=pb(t);if(e!==void 0)return mb(e)??uf().find(n=>n===e.split("-")[0])}function KP(t){try{return(t==null?void 0:t.getItem(hb))??void 0}catch{return}}function YP(){const t=[...navigator.languages];return navigator.language!==""&&t.push(navigator.language),t}function XP(t){const e=t.catalog,n=t.storage??globalThis.localStorage,r=t.document??globalThis.document,i=t.setUiLocale??m_;let s=te(pt(um[0])),o=!1;const a=new Gi,l=new Gi,c=m=>{r.documentElement.lang=m,r.documentElement.dir="ltr"},u=m=>{k(s,m,!0),i(m),c(m);for(const b of a)b(m)};return Object.freeze({initLocale:()=>{const m=KP(n),_=(m===void 0?void 0:mb(m))??YP().map(vp).find(y=>y!==void 0)??"en";return u(_),_},getLocale:()=>d(s),setLocale:async m=>{const b=vp(m)??"en";if(b===d(s))return;o=!0;for(const y of l)y(!0);const _=e.preparePluginCatalogGeneration(b);await _.promise,e.commitPluginCatalogGeneration(_,()=>{u(b);try{n==null||n.setItem(hb,b)}catch{}}),o=!1;for(const y of l)y(!1)},subscribeLocale:m=>(a.add(m),()=>{a.delete(m)}),isLocaleSwitchPending:()=>o,subscribeLocalePending:m=>(l.add(m),()=>{l.delete(m)}),hostT:(m,b,_)=>vb(m,b,_??d(s)),hostFormatNumber:(m,b)=>new Intl.NumberFormat(Do(d(s)),b).format(m),hostFormatDate:(m,b)=>new Intl.DateTimeFormat(Do(d(s)),b).format(m),getAvailableLocales:uf,isPseudoLocaleEnabled:gb})}function vb(t,e,n){const r=n==="en-XA"&&gb()?qP:lu[n]??lu.en,i=bp(r,t)??bp(lu.en,t)??t;return e===void 0?i:Wd(i,e,n)}function bp(t,e){let n=t;for(const r of e.split(".")){if(typeof n=="string")return;n=n[r]}return typeof n=="string"?n:void 0}function M(t,e){return vb(t,e,V.locale)}var JP=N('<h2 class="mndw-overlay-dialog__title svelte-1ervcvh"> </h2>'),QP=N('<button type="button" class="mndw-overlay-dialog__close svelte-1ervcvh">&times;</button>'),eR=N('<header class="mndw-overlay-dialog__header svelte-1ervcvh"><!> <!></header>'),tR=N('<p class="mndw-overlay-dialog__description svelte-1ervcvh"> </p>'),nR=N('<div role="dialog"><!> <!> <div class="mndw-overlay-dialog__body svelte-1ervcvh"></div></div>');function rR(t,e){Ze(e,!0);const n=Math.random().toString(36).slice(2),r=`mndw-overlay-title-${n}`,i=`mndw-overlay-desc-${n}`;function s(p,g){return p.appendChild(g),{destroy(){g.parentNode===p&&p.removeChild(g)}}}const o=G(()=>e.layer.mobileSheet?"width:100%;height:auto;max-height:100dvh":[e.layer.sizing.width?`width:${e.layer.sizing.width}`:"",e.layer.sizing.height?`height:${e.layer.sizing.height}`:"",e.layer.sizing.maxWidth?`max-width:${e.layer.sizing.maxWidth}`:"",e.layer.sizing.maxHeight?`max-height:${e.layer.sizing.maxHeight}`:""].filter(Boolean).join(";"));var a=nR(),l=v(a);{var c=p=>{var g=eR(),m=v(g);{var b=R=>{var L=JP(),P=v(L);w(()=>{Ae(L,"id",r),E(P,e.layer.shell.title)}),C(R,L)};W(m,R=>{var L;(L=e.layer.shell)!=null&&L.title&&R(b)})}var _=S(m,2);{var y=R=>{var L=QP();w(P=>Ae(L,"aria-label",P),[()=>M("common.close")]),de("click",L,()=>e.layer.close(void 0,"action")),C(R,L)};W(_,R=>{var L;(L=e.layer.shell)!=null&&L.showCloseButton&&R(y)})}C(p,g)};W(l,p=>{var g,m;((g=e.layer.shell)!=null&&g.title||(m=e.layer.shell)!=null&&m.showCloseButton)&&p(c)})}var u=S(l,2);{var f=p=>{var g=tR(),m=v(g);w(()=>{Ae(g,"id",i),E(m,e.layer.shell.description)}),C(p,g)};W(u,p=>{var g;(g=e.layer.shell)!=null&&g.description&&p(f)})}var h=S(u,2);Zs(h,(p,g)=>s==null?void 0:s(p,g),()=>e.layer.contentElement),w(()=>{var p,g;Pe(a,1,`mndw-overlay-dialog mndw-overlay-dialog--${e.layer.kind??""} mndw-overlay-dialog--${e.layer.placement??""} ${e.layer.mobileSheet?"mndw-overlay-dialog--sheet":""} ${e.layer.className??""??""}`,"svelte-1ervcvh"),Ae(a,"data-locale",V.locale),Ae(a,"aria-modal",e.layer.kind==="modal"||e.layer.kind==="drawer"?"true":void 0),Ae(a,"aria-labelledby",(p=e.layer.shell)!=null&&p.title?r:void 0),Ae(a,"aria-describedby",(g=e.layer.shell)!=null&&g.description?i:void 0),cl(a,d(o))}),C(t,a),We()}bt(["click"]);var iR=N('<div class="mndw-overlay-backdrop svelte-11o3k6p" aria-hidden="true"></div>'),sR=N("<div><!> <div></div></div>");function oR(t,e){Ze(e,!0);const n=1e3,r=G(()=>e.runtime.store.layers);function i(h){return n+h}function s(h){return h.kind==="modal"||h.kind==="drawer"}function o(h){return h.kind==="popover"?h.position?`position:absolute;top:${h.position.top}px;left:${h.position.left}px`:"position:absolute;opacity:0;pointer-events:none":""}function a(h,p){h.appendChild(p.hostElement),p.kind==="drawer"&&p.placement==="bottom"&&(p.hostElement.style.display="flex",p.hostElement.style.flexDirection="column",p.hostElement.style.justifyContent="flex-end",p.hostElement.style.width="100%",p.hostElement.style.height="100%",p.hostElement.style.minHeight="0");let g;return p.shell&&(g=Vl(rR,{target:p.hostElement,props:{layer:p}})),requestAnimationFrame(()=>{p.state!=="closed"&&p.reposition()}),{destroy(){g&&Rd(g),p.hostElement.remove()}}}function l(h){if(h.key==="Escape"){for(let p=d(r).length-1;p>=0;p--)if(d(r)[p].closeOnEscape){d(r)[p].closeWithReason("escape"),h.stopPropagation();return}}}function c(h){const p=h.composedPath();for(let g=d(r).length-1;g>=0;g--){const m=d(r)[g];if(p.includes(m.hostElement)||m.anchorElement&&p.includes(m.anchorElement))return;if(m.closeOnOutsideClick){m.closeWithReason("outside-click");return}if(s(m))return}}Qn(()=>{const h=d(r).some(g=>g.lockScroll),p=document.body.style.overflow;return h&&(document.body.style.overflow="hidden"),()=>{document.body.style.overflow=p}});var u=_n();Pt("keydown",No,l),Pt("pointerdown",No,c);var f=tt(u);Mt(f,19,()=>d(r),h=>h.id,(h,p,g)=>{var m=sR();let b;var _=v(m);{var y=P=>{var A=iR();C(P,A)},R=G(()=>s(d(p))&&d(p).backdrop);W(_,P=>{d(R)&&P(y)})}var L=S(_,2);Zs(L,(P,A)=>a==null?void 0:a(P,A),()=>d(p)),w((P,A)=>{Pe(m,1,`mndw-overlay-layer mndw-overlay-layer--${d(p).kind??""}`,"svelte-11o3k6p"),b=cl(m,"",b,P),Pe(L,1,`mndw-overlay-positioner mndw-overlay-positioner--${d(p).kind??""} mndw-overlay-positioner--${d(p).placement??""} ${d(p).mobileSheet?"mndw-overlay-positioner--sheet":""} ${d(p).kind==="popover"&&!d(p).position?"mndw-overlay-positioner--unpositioned":""}`,"svelte-11o3k6p"),cl(L,A)},[()=>({"z-index":i(d(g))}),()=>o(d(p))]),C(h,m)}),C(t,u),We()}const aR={success:4e3,info:4e3,warning:0,error:0},lR=4,cR=.35,uR=.5;function dR(t){return{get label(){var e;return((e=t.getLabel)==null?void 0:e.call(t))??t.label},onAction:t.onAction,...t.busy===void 0?{}:{busy:t.busy}}}function _p(t,e,n,r){return{id:t,get message(){var i;return((i=e.getMessage)==null?void 0:i.call(e))??e.message},variant:n,duration:r,...e.key===void 0?{}:{key:e.key},...e.action===void 0?{}:{action:dR(e.action)}}}function fR(t,e,n){return e<=0?!1:Math.abs(t)>=e*cR||Math.abs(n)>=uR}var Qo;class hR{constructor(){Ce(this,Qo,te(pt([])));X(this,"nextId",1);X(this,"maxToasts",lR);X(this,"timers",new Ti)}get toasts(){return d(x(this,Qo))}set toasts(e){k(x(this,Qo),e,!0)}show(e){const n=e.variant??"info",r=e.duration??aR[n],i=e.key===void 0?-1:this.toasts.findIndex(s=>s.key===e.key);if(i!==-1){const s=this.toasts[i];return s===void 0?this.add(e,n,r):(this.clearTimer(s.id),this.toasts[i]=_p(s.id,e,n,r),this.startTimer(s.id,r),s.id)}return this.add(e,n,r)}add(e,n,r){const i=this.nextId++;return this.toasts.push(_p(i,e,n,r)),this.enforceCap(),this.startTimer(i,r),i}startTimer(e,n){n>0&&this.timers.set(e,setTimeout(()=>this.dismiss(e),n))}success(e,n){return this.show({...n,message:e,variant:"success"})}info(e,n){return this.show({...n,message:e,variant:"info"})}error(e,n){return this.show({...n,message:e,variant:"error"})}dismiss(e){this.clearTimer(e);const n=this.toasts.findIndex(r=>r.id===e);n!==-1&&this.toasts.splice(n,1)}dismissKey(e){const n=this.toasts.find(r=>r.key===e);n!==void 0&&this.dismiss(n.id)}setMaxToasts(e){this.maxToasts=Math.max(1,Math.trunc(e)),this.enforceCap()}clear(){for(const e of this.timers.keys())this.clearTimer(e);this.toasts=[]}enforceCap(){for(;this.toasts.length>this.maxToasts;){const e=this.toasts.shift();e!==void 0&&this.clearTimer(e.id)}}clearTimer(e){const n=this.timers.get(e);n!==void 0&&(clearTimeout(n),this.timers.delete(e))}}Qo=new WeakMap;const Xe=new hR;var pR=N('<button type="button" class="mndw-toast__action svelte-1g105wt"> </button>'),gR=N('<div><span class="mndw-toast__body svelte-1g105wt"> </span> <!> <button type="button" class="mndw-toast__dismiss svelte-1g105wt"><mndw-icon></mndw-icon></button></div>',2),mR=N('<div role="region"></div>');function vR(t,e){Ze(e,!0);let n=Tn(e,"store",3,Xe);const r=fa();let i=te(pt(r.matches));const s=h=>{k(i,h.matches,!0),n().setMaxToasts(h.matches?3:4)};function o(h){return h==="error"?"danger":h}function a(h){try{const p=h.onAction();p!==void 0&&p.catch(g=>{console.error("[mndw] Toast action failed:",g)})}catch(p){console.error("[mndw] Toast action failed:",p)}}function l(h,p){let g=p,m=null,b=0,_=0,y=!1;const R=O=>{h.style.transition="transform 0.15s ease, opacity 0.15s ease",h.style.transform="",h.style.opacity=""},L=O=>{!g.enabled||O.pointerType==="mouse"||m!==null||(m=O.pointerId,b=O.clientX,_=O.timeStamp,y=!0,h.style.transition="",h.setPointerCapture(O.pointerId))},P=O=>{if(!y||O.pointerId!==m)return;const D=O.clientX-b;h.style.transform=`translateX(${D}px)`,h.style.opacity=String(Math.max(.3,1-Math.abs(D)/h.offsetWidth))},A=O=>{if(!y||O.pointerId!==m)return;const D=O.clientX-b,z=Math.max(1,O.timeStamp-_),B=D/z;y=!1,m=null,fR(D,h.offsetWidth,B)?g.onDismiss():R()};return h.style.touchAction="pan-y",h.addEventListener("pointerdown",L),h.addEventListener("pointermove",P),h.addEventListener("pointerup",A),h.addEventListener("pointercancel",A),{update(O){g=O},destroy(){h.removeEventListener("pointerdown",L),h.removeEventListener("pointermove",P),h.removeEventListener("pointerup",A),h.removeEventListener("pointercancel",A)}}}Gn(()=>(n().setMaxToasts(d(i)?3:4),r.addEventListener("change",s),()=>{r.removeEventListener("change",s)}));var c=_n(),u=tt(c);{var f=h=>{var p=mR();let g;Mt(p,21,()=>n().toasts,m=>m.id,(m,b)=>{var _=gR(),y=v(_),R=v(y),L=S(y,2);{var P=D=>{var z=pR(),B=v(z);w(()=>{z.disabled=d(b).action.busy===!0,Ae(z,"aria-busy",d(b).action.busy===!0?"true":void 0),E(B,d(b).action.label)}),de("click",z,()=>{d(b).action!==void 0&&a(d(b).action)}),C(D,z)};W(L,D=>{d(b).action!==void 0&&D(P)})}var A=S(L,2),O=v(A);T(O,"name","x"),Zs(_,(D,z)=>l==null?void 0:l(D,z),()=>({enabled:d(i),onDismiss:()=>n().dismiss(d(b).id)})),w((D,z)=>{Pe(_,1,`mndw-toast mndw-alert mndw-alert--${D??""}`,"svelte-1g105wt"),Ae(_,"role",d(b).variant==="error"?"alert":"status"),Ae(_,"aria-live",d(b).variant==="error"?"assertive":"polite"),E(R,d(b).message),Ae(A,"aria-label",z)},[()=>o(d(b).variant),()=>M("toast.dismiss")]),de("click",A,()=>n().dismiss(d(b).id)),C(m,_)}),w(m=>{g=Pe(p,1,"mndw-toast-host svelte-1g105wt",null,g,{"mndw-toast-host--mobile":d(i)}),Ae(p,"aria-label",m)},[()=>M("toast.region")]),C(h,p)};W(u,h=>{n().toasts.length>0&&h(f)})}C(t,c),We()}bt(["click"]);const bb=globalThis.fetch.bind(globalThis);async function bo(t,e={},n=2e4){const r=new AbortController,i=e.signal,s=()=>r.abort(i==null?void 0:i.reason);i!=null&&(i.aborted?s():i.addEventListener("abort",s,{once:!0}));const o=globalThis.setTimeout(()=>r.abort(),n);try{return await bb(t,{...e,signal:r.signal})}finally{globalThis.clearTimeout(o),i==null||i.removeEventListener("abort",s)}}function _b(){const t=new S_(1);let e=!1;const n={ended$:t.asObservable(),get ended(){return e},end:()=>{e||(e=!0,t.next(),t.complete())}};return Object.freeze(n)}function Ja(t,e,n){return new el(r=>{if(n.ended){r.complete();return}let i;const s=()=>{const a=i;i=void 0,a==null||a()},o=n.ended$.subscribe(()=>{s(),r.complete()});return r.next(t()),!r.closed&&!n.ended&&(i=e(a=>r.next(a)),n.ended&&s()),()=>{o.unsubscribe(),s()}})}const ed=3e3;function bR(t={}){return{catalogSuccessCache:new Map,catalogCells:new Set,activeGeneration:void 0,nextGenerationToken:0,fetchCatalog:t.fetchCatalog??yR,now:t.now??Date.now,setTimeout:t.setTimeout??globalThis.setTimeout.bind(globalThis),queueMicrotask:t.queueMicrotask??globalThis.queueMicrotask.bind(globalThis)}}function cu(t,e){return`${t.name}/${t.version}/${e}`}function _R(t,e){const n=t.locales[e];if(n!==void 0)return`${t.baseUrl.replace(/\/$/,"")}/${n}?v=${encodeURIComponent(t.version)}`}function wR(t){return t.split("-")[0]}function wb(t,e){if(t.locales[e]!==void 0)return e;const n=wR(e);return n!==void 0&&t.locales[n]!==void 0?n:t.defaultLocale}async function yR(t){const e=await fetch(t);if(!e.ok)throw new Error(`HTTP ${e.status}`);return JS(await e.json(),t)}async function wp(t,e,n,r){const i=t.catalogSuccessCache.get(cu(e,n));if(i!==void 0)return i;const s=_R(e,n);if(s===void 0)throw new Error(`Plugin "${e.name}" does not declare a catalog for ${n}`);try{const o=await t.fetchCatalog(s);if(r!==void 0&&t.now()>r)throw new Error("catalog request completed after deadline");return t.catalogSuccessCache.set(cu(e,n),o),o}catch(o){throw t.catalogSuccessCache.delete(cu(e,n)),o}}function kR(t,e){const n=Math.max(0,e-t.now());return new Promise((r,i)=>{t.setTimeout(()=>i(new Error("catalog deadline exceeded")),n)})}async function yb(t,e,n,r){var f,h;const i=wb(e,n),s=e.defaultLocale,o=wp(t,e,i,r),a=i===s?o:wp(t,e,s,r),l=await Promise.race([Promise.allSettled([o,a]),kR(t,r)]).catch(()=>{}),c=Array.isArray(l)&&((f=l[0])==null?void 0:f.status)==="fulfilled"?l[0].value:void 0,u=Array.isArray(l)&&((h=l[1])==null?void 0:h.status)==="fulfilled"?l[1].value:void 0;return{hostLocale:n,resolvedCatalogLocale:i,...c===void 0?{}:{primaryCatalog:c},...u===void 0?{}:{defaultCatalog:u},fallbackStatus:c!==void 0?"primary":u!==void 0?"default":"key"}}function kb(t,e){return{hostLocale:e,resolvedCatalogLocale:wb(t,e),fallbackStatus:"key"}}class ER{constructor(e,n){X(this,"source");X(this,"state");X(this,"listeners",new Set);this.source=Object.freeze({...e,locales:Object.freeze({...e.locales})}),this.state=new Ti([["current",kb(this.source,n)]])}readCurrentState(){const e=this.state.get("current");if(e===void 0)throw new Error(`Catalog state is missing for plugin "${this.source.name}"`);return e}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}commit(e,n=!0){if(this.state.set("current",Object.freeze(e)),n)for(const r of this.listeners)r()}}function SR(t,e,n){const r=new ER(e,n);return t.catalogCells.add(r),t.activeGeneration!==void 0&&t.activeGeneration.add(r),r}function TR(t,e){t.catalogCells.add(e)}function xR(t,e){t.catalogCells.delete(e)}function CR(t){var e;(e=t.activeGeneration)==null||e.discard(),t.catalogCells.clear(),t.activeGeneration=void 0}function Eb(t,e,n,r){if(r!==void 0)return{name:t,version:e,baseUrl:n,defaultLocale:r.defaultLocale,locales:r.locales}}async function PR(t,e,n,r=ed){e.commit(await yb(t,e.source,n,t.now()+r))}class RR{constructor(e,n){X(this,"runtime");X(this,"token");X(this,"targetLocale");X(this,"deadline");X(this,"promise");X(this,"pending",0);X(this,"initialEnrollmentDone",!1);X(this,"settled",!1);X(this,"cells",new Map);X(this,"resolvedStates",new Map);X(this,"resolvePromise");this.runtime=e,this.token=++e.nextGenerationToken,this.targetLocale=n,this.deadline=e.now()+ed,this.promise=new Promise(r=>{this.resolvePromise=r}),e.setTimeout(()=>this.settle(),ed)}add(e){if(this.settled||this.runtime.now()>=this.deadline||this.cells.has(e))return;this.pending+=1;const n=yb(this.runtime,e.source,this.targetLocale,this.deadline).catch(()=>kb(e.source,this.targetLocale));this.cells.set(e,n),n.then(r=>{this.resolvedStates.set(e,r)}).finally(()=>{this.pending-=1,this.settle()})}closeEnrollment(){this.initialEnrollmentDone=!0,this.settle()}discard(){this.settled||(this.settled=!0,this.resolvePromise())}settle(){this.settled||!this.initialEnrollmentDone||this.pending>0||this.runtime.queueMicrotask(()=>{this.settled||!this.initialEnrollmentDone||this.pending>0||(this.settled=!0,this.resolvePromise())})}commit(e){if(this.runtime.activeGeneration===this){for(const[n,r]of this.resolvedStates)n.commit(r,!1);e();for(const n of this.resolvedStates.keys()){const r=this.resolvedStates.get(n);this.runtime.activeGeneration===this&&r!==void 0&&n.commit(r)}this.runtime.activeGeneration=void 0}}}function AR(t,e){if(t.activeGeneration!==void 0)throw new Error("A plugin catalog generation is already pending");const n=new RR(t,e);t.activeGeneration=n;for(const r of t.catalogCells)n.add(r);return n.closeEnrollment(),n}function OR(t,e){t.commit(e)}function MR(t,e){e.discard(),t.activeGeneration===e&&(t.activeGeneration=void 0)}function NR(t){return t.activeGeneration}function LR(t,e,n,r){var o,a;const i=t==null?void 0:t.readCurrentState(),s=((o=i==null?void 0:i.primaryCatalog)==null?void 0:o[e])??((a=i==null?void 0:i.defaultCatalog)==null?void 0:a[e])??e;return Wd(s,n,r)}function yp(t,e,n,r){var o,a;const i=t==null?void 0:t.readCurrentState(),s=((o=i==null?void 0:i.primaryCatalog)==null?void 0:o[e])??((a=i==null?void 0:i.defaultCatalog)==null?void 0:a[e]);return s===void 0?n??"":Wd(s,void 0,r)}function zn(t,e,n){const r=yp(e,"manifest.label",t.label,n),i=yp(e,"manifest.description",t.description,n);return{label:r,...i===""?{}:{description:i}}}function IR(t,e,n,r){const s={get locale(){return e()},direction:"ltr",t:(o,a)=>LR(t,o,a,e()),formatNumber:(o,a)=>new Intl.NumberFormat(Do(e()),a).format(o),formatDate:(o,a)=>new Intl.DateTimeFormat(Do(e()),a).format(o),locale$:Ja(e,t===void 0?n:o=>t.subscribe(()=>o(e())),r)};return Object.freeze(s)}function zR(t={}){const e=bR(t);return{createPluginCatalogCell:(n,r)=>SR(e,n,r),registerPluginCatalogCell:n=>TR(e,n),unregisterPluginCatalogCell:n=>xR(e,n),clearPluginCatalogCells:()=>CR(e),loadInitialPluginCatalog:(n,r,i)=>PR(e,n,r,i),preparePluginCatalogGeneration:n=>AR(e,n),commitPluginCatalogGeneration:(n,r)=>OR(n,r),discardPluginCatalogGeneration:n=>MR(e,n),getActivePluginCatalogGeneration:()=>NR(e)}}class td extends Error{constructor(n,r,i){super(r,i);X(this,"code");this.name="PageRouteError",this.code=n}}const DR={light:{bg:"#f7fcfd",surface:"#edf2f3",surfaceRaised:"#f2f7f8",border:"#80878a",textSubtle:"#2f353a",textMuted:"#1d2328",text:"#0c1217",accent:"#016ca5",accentHover:"#005583",accentContrast:"#ffffff",danger:"#c5001b",dangerBg:"#ffe9e6",success:"#137738",successBg:"#d7f9dc",warning:"#916100",warningBg:"#ffebd1",info:"#016ca5",infoBg:"#e0f1ff",focusRing:"#004f7a",surfaceHover:"#e8edee",controlHover:"#c6cbcc",shadowColor:"#4145462e"},dark:{bg:"#030405",surface:"#0d0f10",surfaceRaised:"#151719",border:"#606569",textSubtle:"#b9c0c7",textMuted:"#d1d9e1",text:"#eaf3fb",accent:"#016ca5",accentHover:"#2b84bf",accentContrast:"#ffffff",danger:"#ed3f3f",dangerBg:"#390204",success:"#5cb572",successBg:"#05210d",warning:"#efa831",warningBg:"#271700",info:"#338ac5",infoBg:"#021d2f",focusRing:"#338ac5",surfaceHover:"#1e2022",controlHover:"#292b2c",shadowColor:"#0102038c"}},df="0.3.2",HR=1;function BR(t){return typeof t!="object"||t===null||Array.isArray(t)?!1:Object.values(t).every(e=>typeof e=="string")}async function UR(t,e=fetch){try{const n=await e(`${t}/mndw.lock.json`);if(!n.ok)return null;const r=await n.json();if(typeof r!="object"||r===null)return null;const i=r;if(i.lockVersion!==HR)return null;const s=i.sdkVersion,o=i.sharedDependencies;return typeof s!="string"||!BR(o)?null:{sdkVersion:s,sharedDependencies:o}}catch{return null}}function _o(t){if(typeof t!="string")return null;const e=/^(\d+)(?:\.(\d+))?(?:[.+-]|$)/.exec(t.trim());return e===null?null:{major:Number(e[1]),minor:e[2]===void 0?null:Number(e[2])}}function vi(t){const e=_o(t);return e===null?null:e.major>0?String(e.major):e.minor===null?"0":`0.${e.minor}`}function Sb(t,e=cf(),n=df){const r=[],i=_o(t.sdkVersion),s=_o(n),o=vi(t.sdkVersion),a=vi(n);i!==null&&s!==null&&o!==null&&a!==null&&(o!==a?r.push({kind:"sdk-major",name:"@mndw/sdk",pluginVersion:t.sdkVersion,hostVersion:n}):i.major>0&&i.minor!==null&&s.minor!==null&&i.minor>s.minor&&r.push({kind:"sdk-newer-minor",name:"@mndw/sdk",pluginVersion:t.sdkVersion,hostVersion:n}));for(const[l,c]of Object.entries(t.sharedDependencies)){const u=e[l];if(u===void 0)continue;const f=_o(c),h=_o(u),p=vi(c),g=vi(u);f!==null&&h!==null&&p!==null&&g!==null&&p!==g&&r.push({kind:"shared-major",name:l,pluginVersion:c,hostVersion:u})}return r}function jR(t,e=cf(),n=df){const r=[];for(const[o,a]of Object.entries(t.sharedDependencies)){const l=e[o];if(l===void 0)continue;const c=vi(a),u=vi(l);c===null||u===null||c!==u&&r.push(`${o} @${c} (host provides @${u})`)}const i=vi(t.sdkVersion),s=vi(n);return i!==null&&s!==null&&i!==s&&r.push(`@mndw/sdk @${i} (host provides @${s})`),r}function $R(t,e,n=cf(),r=df){const i=jR(e,n,r);return i.length>0&&console.warn(`[mndw] plugin "${t}" was built against ${i.join(", ")}; it may misbehave with the versions this host provides`),i}const jo=pt({});function FR(){for(const t of Object.keys(jo))delete jo[t]}function Tb(t,e){if(e.length===0){delete jo[t];return}jo[t]=[...e]}function GR(t){return jo[t]??[]}const Dr=pt({});let xb=te("pending"),nd=te(0);function kp(){return d(nd)}function tr(){return d(xb)}function ki(t){k(xb,t,!0)}function ff(t,e=!1){var r;const n={...Dr};for(const i of Object.keys(Dr))delete Dr[i];for(const i of t){const s=i.enabled&&i.approval==="approved";Dr[i.name]={runnable:s,status:s?"loading":"not-runnable",type:i.type,version:i.version,label:i.label,...i.description===void 0?{}:{description:i.description},...e&&((r=n[i.name])==null?void 0:r.version)===i.version&&n[i.name].catalog!==void 0?{catalog:n[i.name].catalog}:{},...i.type==="widget"?{size:i.size}:{},...i.type==="page"?{route:i.route}:{}}}}function fc(t,e=!1){ff(t,e),k(nd,d(nd)+1)}function jn(t,e,n){const r=Dr[t];if(r!==void 0){const{failureKind:i,...s}=r;Dr[t]={...s,...e==="not-runnable"?{runnable:!1}:{},status:e,...e==="failed"&&n!==void 0?{failureKind:n}:{}}}}function hf(t,e){const n=Dr[t];if(n!==void 0){const{catalog:r,...i}=n;Dr[t]={...i,...e===void 0?{}:{catalog:e}}}}function mn(t){return Dr[t]}function va(){return Dr}const gs="plugin-load";let rd=0,Ds=0,ms=!1,Hs=!1;function Cb(){return ms||Ds>0}function Pb(){return Object.entries(va()).filter(([,t])=>t.runnable&&t.status==="failed").map(([t,e])=>({name:t,label:zn(e,e.catalog,V.locale).label})).sort((t,e)=>t.label.localeCompare(e.label)||t.name.localeCompare(e.name))}function VR(t){const e=va(),r=t.map(i=>{const s=e[i];return{name:i,label:s===void 0?i:zn(s,s.catalog,V.locale).label}}).sort((i,s)=>i.label.localeCompare(s.label)||i.name.localeCompare(s.name)).map(({label:i})=>i).join(", ");return M("plugin-load.failed",{names:r})}function Ep(t,e,n){Xe.error(t(),{key:gs,getMessage:t,action:{label:M("common.retry"),getLabel:()=>M("common.retry"),busy:Cb(),onAction:()=>ZR(e,n)}})}async function ZR(t,e){if(!e()||ms)return;ms=!0,Hs=!0,Bs(t,e);const n=Pb().map(({name:r})=>r);await Promise.all(n.map(async r=>{try{await t(r)}catch(i){console.error(`[mndw] Plugin retry failed for "${r}":`,i)}})),e()&&(ms=!1,Bs(t,e))}function Bs(t,e){if(!e())return;const n=Pb();if(n.length>0){const r=n.map(({name:i})=>i);Ep(()=>VR(r),t,e);return}if(Cb()){const r=Xe.toasts.find(({key:i})=>i===gs);r!==void 0&&Ep(()=>r.message,t,e);return}if(Hs){Xe.success(M("plugin-load.loaded"),{key:gs,duration:4e3}),Hs=!1;return}Xe.dismissKey(gs)}function WR(t,e){Ds+=1,Hs=!0,Bs(t,e)}function qR(t,e){Ds=Math.max(0,Ds-1),Bs(t,e)}function KR(){return rd+=1,Ds=0,ms=!1,Hs=!1,Xe.dismissKey(gs),rd}function YR(t){t===rd&&(Ds=0,ms=!1,Hs=!1,Xe.dismissKey(gs))}let id=0,ns,$r;const Rb=15e3;function XR(t,e,n){return`${t}/${e}?v=${encodeURIComponent(n)}`}function JR(t,e){const n=t;if(typeof n.createInstance!="function")throw new Error(`Plugin "${e}" does not export { createInstance }`);return n}async function QR(t){const e=await bb(hm,{signal:t});if(!e.ok)throw new Error(`HTTP ${e.status}`);return ub(await e.json())}async function eA(t,e){const n=await UR(e);return n?$R(t.name,n):[]}function Ab(t){const e=new Set,n=new Set,r=new Set,i=new Set,s=t.filter(o=>{if(e.has(o.name))return console.error(`[mndw] Skipping duplicate plugin "${o.name}"`),i.add(o.name),!1;if(e.add(o.name),o.type==="page"){if(n.has(o.route))return console.error(`[mndw] Skipping duplicate page route "${o.route}"`),i.add(o.name),!1;n.add(o.route)}return r.add(o.name),!0});for(const o of i)r.has(o)||jn(o,"not-runnable");return s}let Mo;const wo=new Map;async function tA(t,e,n,r){const s=`${t.source==="builtin"?th.builtin:th.user}${t.name}`,o=u=>XR(s,u,t.version);let a,l=!1,c;try{const u=Eb(t.name,t.version,t.catalogBaseUrl??s,t.i18n),f=u===void 0?void 0:e.catalogService.createPluginCatalogCell(u,e.getLocale());if(hf(t.name,f),f!==void 0&&await e.catalogService.loadInitialPluginCatalog(f,e.getLocale()),!r()||n.aborted)return{loaded:!1};if(a=e.acquireStylesheet(o("index.css"),t.name,t.version),c=()=>a==null?void 0:a.release(),n.addEventListener("abort",c,{once:!0}),n.aborted&&c(),await a.loaded,!r()||n.aborted)return{loaded:!1};const h=await e.importModule(o(t.entry)),p=JR(h,t.name);return n.aborted||!r()?{loaded:!1}:(e.registry.register({entry:t,module:p,...f===void 0?{}:{catalog:f},stylesheetLease:a}),l=!0,console.log(`[mndw] Loaded plugin: ${t.name} (${t.source})`),Promise.resolve().then(()=>e.checkVersions(t,s)).then(g=>{r()&&Tb(t.name,g)}).catch(g=>{console.error(`[mndw] Version check failed for "${t.name}":`,g)}),{loaded:!0})}catch(u){return console.error(`[mndw] Failed to load plugin "${t.name}":`,u),{loaded:!1,failureKind:"error"}}finally{c!==void 0&&n.removeEventListener("abort",c),l||a==null||a.release()}}async function nA(t,e,n){const r=new AbortController,i=new Promise(o=>{r.signal.addEventListener("abort",()=>{console.error(`[mndw] Plugin "${t.name}" did not load within ${e.loadTimeoutMs} ms; skipping it`),o({loaded:!1,failureKind:"timeout"})},{once:!0})}),s=setTimeout(()=>r.abort(),e.loadTimeoutMs);try{return await Promise.race([tA(t,e,r.signal,n),i])}finally{clearTimeout(s)}}function vs(t){return t.generation===id&&t.authGeneration===Ur()&&!t.authSignal.aborted}async function pf(t,e,n=e.pluginTokens.get(t.name)??0){jn(t.name,"loading");const r=()=>vs(e)&&e.pluginTokens.get(t.name)===n,i=await nA(t,e.deps,r);return r()&&jn(t.name,i.loaded?"loaded":"failed",i.failureKind),i.loaded}async function Ki(t){const e=Mo,n=e==null?void 0:e.entries.get(t),r=mn(t);if(e===void 0||n===void 0||(r==null?void 0:r.runnable)!==!0||!vs(e))return!1;const i=wo.get(t);if(i!==void 0)return i;const s=()=>vs(e);WR(Ki,s);const o=pf(n,e).finally(()=>{wo.get(t)===o&&wo.delete(t),s()&&qR(Ki,s)});return wo.set(t,o),o}async function rA(t){const e=Mo;if(e===void 0||!vs(e))return!1;const n={...va()},r=Ab(t.filter(a=>a.enabled&&a.approval==="approved")),i=new Map(r.map(a=>[a.name,a]));let s=!1;zs(t),fc(t,!0),ki("ok");for(const a of e.entries.keys())i.has(a)||(e.pluginTokens.set(a,(e.pluginTokens.get(a)??0)+1),e.entries.delete(a),e.deps.registry.remove(a),Tb(a,[]));const o=[];for(const a of r){const l=a.name,c=e.entries.get(l),u=n[l],f=e.deps.registry.get(l),h=c!==void 0&&c.version!==a.version;if(e.entries.set(l,a),f!==void 0){hf(l,f.catalog),f.entry.version!==a.version&&(s=!0),jn(l,"loaded");continue}if(c===void 0||h){const p=(e.pluginTokens.get(l)??0)+1;e.pluginTokens.set(l,p),o.push(pf(a,e,p));continue}(u==null?void 0:u.status)==="failed"?jn(l,"failed",u.failureKind):(u==null?void 0:u.status)==="loading"?jn(l,"loading"):jn(l,"failed","error")}return await Promise.all(o),vs(e)&&(V.pluginLoadError=null,Bs(Ki,()=>vs(e))),s}async function iA(t){ns==null||ns.abort();const e=++id,n=Ur(),r=kP(),i=new AbortController;ns=i;const s=()=>i.abort(r.reason);r.aborted?s():r.addEventListener("abort",s,{once:!0});const o=()=>e===id&&n===Ur(),a=t.fetchList??QR,l=t.catalogService,c=t.registry,u={importModule:t.importModule??(b=>import(b)),acquireStylesheet:t.acquireStylesheet??((b,_,y)=>t.pluginStylesheets.acquire(_,y,b)),checkVersions:t.checkVersions??eA,catalogService:l,registry:c,retryPlugin:Ki,getLocale:t.getLocale??(()=>"en"),loadTimeoutMs:t.loadTimeoutMs??Rb};Mo=void 0,wo.clear(),$r!==void 0&&($r.signal.removeEventListener("abort",$r.handler),$r=void 0);const f=KR(),h=()=>{($r==null?void 0:$r.handler)===h&&($r=void 0),YR(f)};r.aborted?h():($r={signal:r,handler:h},r.addEventListener("abort",h,{once:!0})),ki("pending"),ff([]),u.registry.clear(),zs([]),FR();let p;try{let b,_=()=>{};const y=new Promise((P,A)=>{_=A}),R=()=>{_(i.signal.reason??new DOMException("Plugin list request aborted","AbortError"))};i.signal.addEventListener("abort",R,{once:!0}),i.signal.aborted&&R();const L=new Promise((P,A)=>{b=setTimeout(()=>{A(new Error(`Plugin list fetch timed out after ${Jf} ms`)),i.abort()},Jf)});try{p=await Promise.race([a(i.signal),L,y])}finally{clearTimeout(b),i.signal.removeEventListener("abort",R),r.removeEventListener("abort",s),ns===i&&(ns=void 0)}}catch(b){o()&&(r.aborted||(Mo={generation:e,authGeneration:n,authSignal:r,deps:u,entries:new Map,pluginTokens:new Map}),console.error("[mndw] Failed to load plugin list:",b),V.pluginLoadError="list",ki("failed"));return}if(!o())return;zs(p),fc(p),ki("ok");const g=Ab(p.filter(b=>b.enabled&&b.approval==="approved")),m={generation:e,authGeneration:n,authSignal:r,deps:u,entries:new Map(g.map(b=>[b.name,b])),pluginTokens:new Map(g.map(b=>[b.name,0]))};Mo=m,await Promise.all(g.map(b=>pf(b,m,0))),o()&&(V.pluginLoadError=null,Bs(Ki,o))}const sd="mndw:sandbox-reloaded";function sA(t){const e=t;if(typeof e.createInstance!="function")throw new Error("Sandbox plugin does not export { createInstance }");return e}function oA(t){const e={};if(t===void 0)return{routes:e};for(const n of t.routes)e[n.id]=n.transport==="http"?{transport:"http",method:n.method,path:n.path}:{transport:"websocket",path:n.path,...n.protocols===void 0?{}:{protocols:n.protocols}};return{routes:e}}function Ob(t,e){const n={name:t.name,version:t.version,label:t.label,...t.description===void 0?{}:{description:t.description},entry:t.entry,...t.i18n===void 0?{}:{i18n:t.i18n},...e===void 0?{}:{catalogBaseUrl:e},source:"builtin",approval:"approved",enabled:!0,depsStatus:"ready",backend:oA(t.backend)};return t.type==="widget"?{...n,type:"widget",size:t.size}:{...n,type:"page",route:t.route}}async function gf(t,e,n=()=>!0){let r=e;if(r===void 0){const c=await t.importManifestModule();if(c.default===void 0||c.default===null)throw new Error("Sandbox manifest module has no default export");const u=ab(c.default),f=t.catalogBaseUrl??c.__catalogBaseUrl;r=Ob(u,f)}const i=t.catalogService,s=t.getLocale,o=Eb(r.name,r.version,r.catalogBaseUrl??`/plugins/${r.name}`,r.i18n),a=o===void 0?void 0:i.createPluginCatalogCell(o,s());a!==void 0&&await i.loadInitialPluginCatalog(a,s()),n()&&hf(r.name,a);const l=sA(await t.importPluginModule());return{entry:r,module:l,...a===void 0?{}:{catalog:a}}}let _r,od=0;const yo=new Map;function Tl(){return od+=1,od}function xl(t,e){return t===od&&e()}async function aA(t){const e=t.registry,n=()=>t.isCurrent===void 0||t.isCurrent();if(!n())return;const r=Tl(),i=()=>xl(r,n);if(!i())return;_r=void 0,yo.clear(),ki("pending"),ff([]),zs([]),e.clear();let s;try{const o=await t.importManifestModule();if(o.default===void 0||o.default===null)throw new Error("Sandbox manifest module has no default export");const a=ab(o.default);if(s=Ob(a,t.catalogBaseUrl??o.__catalogBaseUrl),!i())return;zs([s]),fc([s]),ki("ok"),V.pluginLoadError=null,_r={deps:{...t,isCurrent:n},entry:s,isCurrent:n};const c=await gf(t,s,i);if(!i())return;e.register(c),jn(s.name,"loaded"),console.log(`[mndw] Sandbox plugin loaded: ${c.entry.name}`)}catch(o){if(!i())return;s===void 0?(V.pluginLoadError="list",ki("failed")):jn(s.name,"failed","error"),console.error("[mndw] Failed to load sandbox plugin:",o)}}async function lA(t){const e=_r,n=mn(t);if((e==null?void 0:e.entry.name)!==t||(n==null?void 0:n.runnable)!==!0||n.status!=="failed"||!e.isCurrent())return!1;const r=yo.get(t);if(r!==void 0)return r;const i=Tl(),s=()=>_r===e&&xl(i,e.isCurrent);if(!s())return!1;jn(t,"loading");const o=(async()=>{try{const a=await gf(e.deps,e.entry,s);return s()?(e.deps.registry.get(t)===void 0&&e.deps.registry.register(a),jn(t,"loaded"),!0):!1}catch(a){return s()&&(jn(t,"failed","error"),console.error("[mndw] Failed to retry sandbox plugin:",a)),!1}})().finally(()=>{yo.get(t)===o&&yo.delete(t)});return yo.set(t,o),o}async function cA(t){const e=t.registry,n=t.remountWidgets??uA,r=t.reloadPage??dA,i=t.pluginContextServices,s=t.isCurrent??(_r==null?void 0:_r.isCurrent)??(()=>!0),o=t.isCurrent===void 0?{...t,isCurrent:s}:t;if(!s())return"failed";let a;try{a=await gf(o,void 0,s)}catch(b){return s()&&console.error("[mndw] Sandbox reload rejected (invalid update kept previous plugin):",b),"failed"}if(!s())return"failed";const l=a.entry.name,c=e.get(l);if(c===void 0){const b=Tl();return xl(b,s)?(e.register(a),zs([a.entry]),fc([a.entry]),ki("ok"),jn(l,"loaded"),V.pluginLoadError=null,_r={deps:o,entry:a.entry,isCurrent:s},"reloaded"):"failed"}const u=Tl(),f=()=>xl(u,s);if(!f())return"failed";const h=_r;let p;const g=t.pluginStylesheets,m=g.retain(l,c.entry.version);try{p=e.replace(a)}catch(b){return m.release(),console.error(`[mndw] Sandbox reload needs a restart of \`mndw dev\`: ${b.message}`),"restart-required"}_r={deps:o,entry:a.entry,isCurrent:s};try{const b=await n(l,a,c,e,i,t.pluginStylesheets);if(!f())return"failed";const _=await r(l,a,c);if(!f())return"failed";if(!b||!_)throw new Error("a widget or page remount reported failure");return jn(l,"loaded"),console.log(`[mndw] Sandbox plugin reloaded: ${l}`),"reloaded"}catch(b){if(!f())return"failed";const _={...p,stylesheetLease:g.retain(l,p.entry.version)};return e.replace(_),_r=h,console.error(`[mndw] Sandbox reload failed, kept previous plugin "${l}":`,b),"failed"}finally{m.release()}}async function uA(t,e,n,r,i,s){const{remountWidgetTiles:o}=await ul(async()=>{const{remountWidgetTiles:a}=await Promise.resolve().then(()=>MM);return{remountWidgetTiles:a}},[]);return o(i,r,t,e,n,s)}async function dA(t,e,n){const r=[],i={pluginName:t,next:e,prior:n,register:o=>r.push(o)};return window.dispatchEvent(new CustomEvent(sd,{detail:i})),(await Promise.all(r)).every(Boolean)}const Mb={importPluginModule:()=>ul(()=>import("./_virtual_sandbox-plugin-Cg-1CvkF.js"),[]),importManifestModule:()=>ul(()=>import("./_virtual_sandbox-manifest-DbTeSIus.js"),[])};function La(){return{received:!1,value:void 0}}function fA(t,e,n=()=>!0){let r=La(),i=La(),s=!1,o=Promise.resolve();const a=()=>{s||(s=!0,queueMicrotask(()=>{s=!1;const l=r,c=i;r=La(),i=La();const u={importPluginModule:l.received?()=>Promise.resolve(l.value):e.importPluginModule,importManifestModule:c.received?()=>Promise.resolve(c.value):e.importManifestModule};o=o.then(()=>cA({...u,registry:t.registry,catalogService:t.catalog,pluginStylesheets:t.pluginStylesheets,getLocale:()=>t.locale.getLocale(),isCurrent:n,pluginContextServices:{locale:t.locale,palette:t.palette,telemetry:t.telemetry,telemetryGathering:t.telemetryGathering,eventStream:t.eventStream,rci:t.rci,theme:t.theme,tickerPool:t.tickerPool,overlayRuntime:t.overlayRuntime,navigation:()=>t.router.navigation()}})).then(()=>{}).catch(f=>{console.error("[mndw] Sandbox HMR transaction failed:",f)})}))};return{plugin:l=>{r={received:!0,value:l},a()},manifest:l=>{i={received:!0,value:l},a()}}}function hA(t,e=void 0,n=Mb,r=()=>!0){if(e===void 0)return;const i=fA(t,n,r);e.accept("virtual:sandbox-plugin",s=>{i.plugin(s)}),e.accept("virtual:sandbox-manifest",s=>{i.manifest(s)})}const pA=ot({id:me(),label:me(),index:bn().finite().int().nonnegative(),type:me(),group:me(),color:me(),interfaceId:me()}),gA=ot({list:Ht(pA),layout:Ht(Ht(me())),hasPortStats:_i()}),mA=ot({switchports:gA,usbPortCount:bn().finite().int().nonnegative()});function Nb(){return{list:[],layout:[],hasPortStats:!1}}function vA(t){return mA.parse(t)}function bA(t,e){const n=e("single_usb_port")?1:Math.max(0,Math.trunc(t));if(n===0)return{ports:[]};if(!(e("usb_3")||e("usb_3_conf")))return{ports:Array.from({length:n},()=>"usb2")};const i=e("usb_3_first")?0:n-1;return{ports:Array.from({length:n},(o,a)=>a===i?"usb3":"usb2")}}const Sp=ot({exact:me(),cdate:me()}),Tp=ot({version:me()}),_A=ot({release:me(),sandbox:me().optional(),title:me().optional(),arch:me(),ndm:Sp,bsp:Sp,ndw:ot({version:me().optional(),features:me(),components:me()}),ndw3:Tp.optional(),ndw4:Tp.optional(),manufacturer:me(),vendor:me(),series:me(),model:me(),hw_version:me(),hw_type:me().optional(),hw_id:me(),device:me(),region:me(),description:me()}),wA=t=>{const e={path:"show.version"};return t.driver.queue(e).pipe(T_(n=>_A.parse(n)))};function yA(t,e){return Promise.resolve({theme:t.getTheme(),locale:e.getLocale()})}function kA(){return{deviceName:"Unknown",vendor:"Unknown",manufacturer:"Unknown",model:"Unknown",series:"Unknown",region:"Unknown",hwId:"Unknown",hwVersion:"Unknown",firmwareVersion:"Unknown",firmwareRelease:"Unknown",features:[],components:[]}}async function EA(t){try{const e=await md(wA(t).pipe(ug(dm)));return{deviceName:e.device??"Unknown",vendor:e.vendor??"Unknown",manufacturer:e.manufacturer??"Unknown",model:e.model??"Unknown",series:e.series??"Unknown",region:e.region??"Unknown",hwId:e.hw_id??"Unknown",hwVersion:e.hw_version??"Unknown",hwType:e.hw_type,firmwareVersion:e.title??"Unknown",firmwareRelease:e.release??"Unknown",architecture:e.arch,features:nh(e.ndw.features),components:nh(e.ndw.components)}}catch{return kA()}}async function SA(t,e){const n=EA(e),r=Promise.resolve().then(()=>t.getDeviceHardware()).catch(()=>({switchports:Nb(),usbPortCount:0})),[i,s]=await Promise.all([n,r]),o=new Set(i.features.map(l=>l.toLowerCase())),a=bA(s.usbPortCount,l=>o.has(l.toLowerCase()));return{...i,switchports:s.switchports,usb:a}}function TA(){return!0}async function mf(t,e={}){const n=yP(e.preservePluginLoadError),r=()=>n===Ur(),i=e.loadPlugins??iA,s=e.loadSandboxPlugin??aA,o=e.createRouter??(a=>t.router.create(a));try{try{const a=await yA(t.theme,t.locale);r()&&(V.hostInfo=a)}catch(a){r()&&console.error("[mndw] Failed to fetch host info:",a)}if(!r())return;try{const a=await SA(t.mgmtClient,t.rci);r()&&(V.deviceInfo=a)}catch(a){r()&&console.error("[mndw] Failed to fetch device info:",a)}if(!r())return;if(TA()){let a=Mb,l=e.setupHmr??((c,u)=>hA(c,void 0,void 0,u));{const c=await ul(()=>import("./sandbox-url-DLSaHqd4.js"),[]);if(!r())return;a=c.sandboxUrlImports(),l=e.setupHmr??((u,f)=>c.setupSandboxUrlHmr(u,void 0,f))}if(await s({...a,registry:t.registry,catalogService:t.catalog,pluginStylesheets:t.pluginStylesheets,getLocale:()=>t.locale.getLocale(),isCurrent:r,pluginContextServices:{locale:t.locale,palette:t.palette,telemetry:t.telemetry,telemetryGathering:t.telemetryGathering,eventStream:t.eventStream,rci:t.rci,theme:t.theme,tickerPool:t.tickerPool,overlayRuntime:t.overlayRuntime,navigation:()=>t.router.navigation()}}),!r())return;l(t,r)}if(!r()||(o(t.registry),!r()))return;V.ready=!0}finally{EP(n)}return n}const Cl=Symbol("mndw.host-services");function xA(t){mw(Cl,t)}function yn(){if(!vw(Cl))throw new Error("Host services context was not set");return gw(Cl)}function CA(t){return new Map([[Cl,t]])}var PA=N('<div class="mndw-alert mndw-alert--danger" role="alert"> </div>'),RA=N('<div class="mndw-login"><form class="mndw-login__form"><mndw-select><mndw-option>EN</mndw-option> <mndw-option>RU</mndw-option></mndw-select> <h1 class="mndw-login__title">mndw</h1> <mndw-field><mndw-input></mndw-input></mndw-field> <mndw-field><mndw-input></mndw-input></mndw-field> <p class="mndw-login__hint"> </p> <!> <mndw-button> </mndw-button></form></div>',2);function AA(t,e){Ze(e,!0);const n=yn();let r=te(pt(V.loginUsername)),i=te(""),s=te(pt(V.loginError??"")),o=te(!1),a=te(!1);V.loginUsername="",V.loginError=null;let l;Gn(()=>{let pe=!0;return(async()=>{await customElements.whenDefined("mndw-input");const be=l;if(!pe||!be||(await be.updateComplete,!pe))return;const Ee=v_();(Ee===null||Ee===document.body)&&be.focus()})(),()=>{pe=!1}});function c(){return d(r).trim()!==""&&d(i)!==""}function u(){return c()&&!d(o)&&!d(a)}function f(pe){V.localeSwitchPending||n.locale.setLocale(pe.detail.value).catch(()=>{})}function h(pe){k(r,pe.detail.value,!0),k(a,!1)}function p(pe){k(i,pe.detail.value,!0),k(a,!1)}function g(pe){const ee=pe.target,be=pe.composedPath()[0];pe.key!=="Enter"||!(ee instanceof HTMLElement)||ee.localName!=="mndw-input"||be instanceof HTMLButtonElement||(pe.preventDefault(),u()&&m(pe))}function m(pe){pe.preventDefault(),u()&&(k(o,!0),k(s,""),n.rci.login(d(r),d(i)).subscribe({next(ee){if(ee){const be=d(r);V.authenticated=!0;const Ee=mf(n),Me=Ur();Ee.catch(()=>{Me===Ur()&&(dc(),V.loginError=M("login.connection-failed"),V.loginUsername=be)})}else k(s,M("login.invalid-credentials"),!0),k(o,!1),k(a,!0)},error(){k(s,M("login.connection-failed"),!0),k(o,!1),k(a,!1)}}))}var b=RA(),_=v(b),y=v(_);Pe(y,1,"mndw-login__locale-select"),w(()=>T(y,"label",M("nav.language"))),w(()=>T(y,"value",V.locale)),w(()=>T(y,"aria-busy",String(V.localeSwitchPending)));var R=v(y);T(R,"value","en");var L=S(R,2);T(L,"value","ru");var P=S(y,4);w(()=>T(P,"label",M("login.username")));var A=v(P);T(A,"name","username"),T(A,"autocomplete","username"),w(()=>T(A,"value",d(r))),w(()=>T(A,"disabled",d(o))),Br(A,pe=>l=pe,()=>l);var O=S(P,2);w(()=>T(O,"label",M("login.password")));var D=v(O);T(D,"type","password"),T(D,"name","password"),T(D,"autocomplete","current-password"),w(()=>T(D,"value",d(i))),w(()=>T(D,"disabled",d(o)));var z=S(O,2),B=v(z),j=S(z,2);{var q=pe=>{var ee=PA(),be=v(ee);w(()=>E(be,d(s))),C(pe,ee)};W(j,pe=>{d(s)&&pe(q)})}var ie=S(j,2);Pe(ie,1,"mndw-login__submit"),T(ie,"variant","primary"),T(ie,"type","submit"),w(()=>T(ie,"disabled",!u()));var ve=v(ie);w((pe,ee)=>{Ae(b,"data-locale",V.locale),E(B,pe),E(ve,ee)},[()=>M("login.hint"),()=>d(o)?M("login.logging-in"):M("login.submit")]),Pt("submit",_,m),Pt("mndwchange",y,f),Pt("mndwinput",A,h),de("keydown",A,g),Pt("mndwinput",D,p),de("keydown",D,g),C(t,b),We()}bt(["keydown"]);var OA=N('<div class="mndw-loading" role="status" aria-busy="true"> </div>'),MA=N("<!> <!> <!>",1);function NA(t,e){Ze(e,!0);const n=Cr(()=>e.services);xA(n),V.theme=n.theme.getTheme(),V.locale=n.locale.getLocale(),V.localeSwitchPending=n.locale.isLocaleSwitchPending();const r=n.theme.subscribeTheme(p=>{V.theme=p}),i=n.locale.subscribeLocale(p=>{V.locale=p}),s=n.locale.subscribeLocalePending(p=>{V.localeSwitchPending=p});si(()=>{r(),i(),s()});var o=MA(),a=tt(o);oR(a,{get runtime(){return n.overlayRuntime}});var l=S(a,2);vR(l,{});var c=S(l,2);{var u=p=>{AA(p,{})},f=p=>{var g=_n(),m=tt(g);tm(m,()=>V.pluginLoadRevision,b=>{Dy(b,{})}),C(p,g)},h=p=>{var g=OA(),m=v(g);w(b=>{Ae(g,"data-locale",V.locale),E(m,b)},[()=>M("app.loading")]),C(p,g)};W(c,p=>{V.authenticated?V.ready?p(f,1):p(h,-1):p(u)})}C(t,o),We()}async function LA(t){const e=t.initLocale();t.defineUi(e),t.initTheme();try{await t.initPalette()}catch(i){console.warn("[mndw] Palette startup load failed; continuing to login.",i)}let n=!1;try{n=await t.checkAuthenticated()}catch{n=!1}t.setAuthenticated(n);let r=!1;if(t.subscribeAuthErrors(()=>{r=!0,t.resetToLogin()}),t.mountApp(),n&&!r){let i;try{const s=t.initAuthenticated();i=t.getAuthRunGeneration(),await s}catch{(i===void 0||i===t.getAuthRunGeneration())&&t.resetToLogin()}}}const Pn=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),Jr=t=>typeof t=="string"&&t.length>0,ko=Object.freeze({"X-Mndw-Csrf":"1"}),IA=async t=>{try{return await t.json()}catch{return}};function zA(t,e){const n=Pn(t)?t:void 0,r=n==null?void 0:n.error,i=Pn(r)?r:void 0,s=i==null?void 0:i.code,o=i==null?void 0:i.message;return{code:Jr(s)?s:"UNKNOWN",message:Jr(o)?o:e,detail:i==null?void 0:i.detail}}class ba extends Error{constructor(n,r,i,s){super(n);X(this,"code");X(this,"detail");X(this,"status");this.name="HostApiError",this.code=r,this.detail=i,this.status=s}}function DA(t){const e={};if(t instanceof Headers)return t.forEach((n,r)=>{e[r]=n}),e;if(Array.isArray(t)){for(const[n,r]of t)e[n]=r;return e}return t!==void 0&&Object.assign(e,t),e}function xp(t,e,n){const r=Object.keys(t).find(i=>i.toLowerCase()===e.toLowerCase());t[r??e]=n}function vt(t){return t("Malformed response","UNKNOWN")}function _a(t,e){const n=()=>vt(e);async function r(o){try{return await o.json()}catch{throw n()}}async function i(o){const a=zA(await IA(o),o.statusText);return e(a.message,a.code,a.detail,o.status)}return{request:(async(o,a={})=>{var _;const{csrf:l,json:c,response:u,...f}=a,h=((_=f.method)==null?void 0:_.toUpperCase())??"GET",p=h!=="GET"&&h!=="HEAD"||l===!0,g=Object.prototype.hasOwnProperty.call(a,"json"),m={...f};if(g&&(m.body=JSON.stringify(c)),p||g){const y=DA(f.headers);if(g&&xp(y,"Content-Type","application/json"),p)for(const[R,L]of Object.entries(ko))xp(y,R,L);m.headers=y}const b=await t(o,m);if(!b.ok)throw await i(b);return u==="raw"?b:await r(b)}),parseJson:r,malformed:n,errorFromResponse:i}}class bs extends ba{constructor(e,n,r,i){super(e,n,r,i),this.name="MgmtError"}}const Lb=(t,e,n,r)=>new bs(t,e,n,r);function HA(t){switch(t){case"read":return dm;case"mutation":return jy;case"install":return $y}}function rs(t){return typeof t=="number"&&Number.isInteger(t)&&t>=0}function BA(t){if(!Pn(t)||!rs(t.maxConcurrentExecTotal)||!rs(t.maxConcurrentExecPerPlugin)||!rs(t.maxSupervisedServices)||!rs(t.currentExec)||!rs(t.reservedServices)||!Array.isArray(t.supportedServiceProtocols)||!t.supportedServiceProtocols.every(rs))throw vt(Lb);return{maxConcurrentExecTotal:t.maxConcurrentExecTotal,maxConcurrentExecPerPlugin:t.maxConcurrentExecPerPlugin,maxSupervisedServices:t.maxSupervisedServices,currentExec:t.currentExec,reservedServices:t.reservedServices,supportedServiceProtocols:t.supportedServiceProtocols}}function UA(t){return t instanceof DOMException&&t.name==="TimeoutError"||t instanceof TypeError?"ambiguous":t instanceof bs&&t.code==="BACKEND_MAINTENANCE"?"rejected-maintenance":"error"}function jA(t=globalThis.fetch,e=n=>AbortSignal.timeout(HA(n))){const n=_a(t,Lb);function r(a){return e(a)}async function i(a){if(a.status!==204)throw a.ok?new bs("The device returned an unexpected response.","UNKNOWN"):await n.errorFromResponse(a)}async function s(a,l,c){return await n.request(a,{method:"POST",json:{name:l},signal:r(c),response:"raw"})}async function o(a,l){const c=await s(a,l,a===Qf?"install":"mutation");return ou(await n.parseJson(c))}return{async listPlugins(){return ub(await n.request(hm,{method:"GET",signal:r("read")}))},async uploadPlugin(a){const l=await n.request(Gy,{method:"POST",headers:{"Content-Type":"application/zip"},body:a,response:"raw"});if(l.status===201||l.status===202){const c=ou(await n.parseJson(l));return{status:l.status===201?"installed":"pending",entry:c}}throw await n.errorFromResponse(l)},approvePlugin:a=>o(Qf,a),enablePlugin:a=>o(Zy,a),disablePlugin:a=>o(Wy,a),async setPluginCapability(a,l,c){const u=await n.request(Fy,{method:"POST",json:{name:a,capability:l,enabled:c},signal:r("mutation")});return ou(u)},async denyPlugin(a){await s(Vy,a,"mutation")},async deletePlugin(a){await s(qy,a,"mutation")},async restartPlugin(a){await s(Ky,a,"mutation")},async getRuntime(){const a=await n.request(Yy,{method:"GET",signal:r("read")});return BA(a)},async getDeviceHardware(){try{const a=await n.request(Xy,{method:"GET",signal:r("read")});return vA(a)}catch{return{switchports:Nb(),usbPortCount:0}}},async getPalette(){const a=await n.request(Pc,{method:"GET",cache:"no-store",signal:r("read")});if(a===null||typeof a!="object"||Array.isArray(a)||!Object.prototype.hasOwnProperty.call(a,"palette"))throw new bs("The device returned an unexpected palette response.","UNKNOWN");return a.palette??null},async putPalette(a){const l=await n.request(Pc,{method:"PUT",json:a,signal:r("mutation"),response:"raw"});await i(l)},async deletePalette(){const a=await n.request(Pc,{method:"DELETE",signal:r("mutation"),response:"raw"});await i(a)},async getTelemetry(){const a=await n.request(eh,{method:"GET",signal:r("read")});if(a===null||typeof a!="object"||typeof a.enabled!="boolean")throw new bs("The device returned an unexpected telemetry response.","UNKNOWN");return{enabled:a.enabled}},async setTelemetry(a){const l=await n.request(eh,{method:"PUT",json:{enabled:a},signal:r("mutation"),response:"raw"});await i(l)}}}const Cp={INVALID_ZIP:"errors.invalid-zip",MANIFEST_MISSING:"errors.manifest-missing",UNSUPPORTED_MANIFEST_VERSION:"errors.unsupported-manifest-version",CONFLICT:"errors.conflict",UPLOAD_TOO_LARGE:"errors.upload-too-large",OPKG_FAILED:"errors.opkg-failed",DAEMON_FAILED:"errors.daemon-failed",UNAUTHORIZED:"errors.unauthorized",SERVICE_CAPACITY_EXCEEDED:"errors.service-capacity",BACKEND_BUSY:"errors.backend-busy",BACKEND_UNAVAILABLE:"errors.backend-unavailable",BACKEND_INCOMPATIBLE:"errors.backend-incompatible",BACKEND_MAINTENANCE:"errors.backend-maintenance",CONTROLLER_SESSION_UNAVAILABLE:"errors.controller-session-unavailable",RCI_SOCKET_START_FAILED:"errors.rci-socket-start-failed"};function vf(t,e,n){return t instanceof DOMException&&t.name==="TimeoutError"?e("errors.device-timeout"):t instanceof bs?t.code==="MANIFEST_INVALID"?Jr(t.detail)?`${e("errors.invalid-manifest")}: ${t.detail}`:e("errors.invalid-manifest"):(Cp[t.code]===void 0?t.message:e(Cp[t.code],t.code==="UPLOAD_TOO_LARGE"?{limit:n()}:void 0))||e("app.error"):t instanceof Error?t.message:e("app.error")}const ad="mndw-palette-override",$A=":root:root";function FA(t){const e=t.getElementById(ad);if(e instanceof HTMLStyleElement)return e;const n=t.createElement("style");return n.id=ad,t.head.appendChild(n),n}function so(t,e){var n;if(e===null){(n=t.getElementById(ad))==null||n.remove();return}FA(t).textContent=qT(e,{selector:$A})}function is(t){return Object.freeze({dark:{...t.dark},light:{...t.light}})}function GA(t,e){return JSON.stringify(t)!==JSON.stringify(e)}function VA(t){const e=t.document??globalThis.document;let n=null;const r=new Set,i=()=>is(n??DR),s=()=>{const a=i();for(const l of r)l(is(a))},o=async a=>{const l=await t.mgmtClient.getPalette();let c=null;if(l!==null){const f=Wv(l);if(f.palette===null)throw new Error("The device returned an invalid palette.");c=f.palette}const u=GA(n,c);n=c,so(e,c),a&&u&&s()};return{getApplied:()=>n===null?null:is(n),getExportable:i,getTokens:i,refreshPalette:async()=>{await o(!0)},initPalette:async()=>{try{await o(!1)}catch(a){console.warn("[mndw] Could not load the device palette; using defaults.",a)}},previewOverride:a=>{const l=is(a);so(e,l);for(const c of r)c(is(l))},discardPreview:()=>{so(e,n),s()},commitOverride:async a=>{await t.mgmtClient.putPalette(a),n=is(a),so(e,n),s()},resetToDefault:async()=>{await t.mgmtClient.deletePalette(),n=null,so(e,null),s()},subscribePalette:a=>(r.add(a),()=>{r.delete(a)})}}class Eo extends ba{constructor(e,n,r,i){super(e,n,r,i),this.name="OpkgError"}}const Ln=(t,e,n,r)=>new Eo(t,e,n,r);function ZA(t){if(t.code!=="DEPENDENCY_CONFLICT"||!Pn(t.detail))return;const e=t.detail.package,n=t.detail.dependents;if(typeof e!="string"||e.length===0)return;const r=Array.isArray(n)&&n.every(i=>typeof i=="string");return{package:e,dependents:r?n:[]}}function WA(t){if(!Pn(t))throw vt(Ln);const e=t.name,n=t.version,r=t.description,i=t.status,s=t.newVersion,o=i==="installed"||i==="update_available"||i==="available";if(typeof e!="string"||e.length===0||typeof n!="string"||typeof r!="string"||!o||(i==="available"||i==="update_available")&&n.length===0)throw vt(Ln);if(i==="update_available"){if(typeof s!="string"||s.length===0)throw vt(Ln)}else if(s!==void 0)throw vt(Ln);return{name:e,version:n,description:r,status:i,...s===void 0?{}:{newVersion:s}}}function qA(t){if(!Pn(t)||!Array.isArray(t.packages))throw vt(Ln);const e=t.metadataUpdatedAt;if(e!==null&&typeof e!="string"||typeof e=="string"&&Number.isNaN(Date.parse(e)))throw vt(Ln);return{packages:t.packages.map(n=>WA(n)),metadataUpdatedAt:e}}function KA(t){if(!Pn(t))throw vt(Ln);const e=t.status;if(typeof t.name!="string"||t.name.length===0||typeof t.version!="string"||typeof t.description!="string"||!Array.isArray(t.dependencies)||!t.dependencies.every(o=>typeof o=="string")||e!=="installed"&&e!=="update_available"&&e!=="available")throw vt(Ln);const n=["size","installedSize","installedTime"];for(const o of n)if(t[o]!==void 0&&typeof t[o]!="string")throw vt(Ln);const r=typeof t.size=="string"?t.size:void 0,i=typeof t.installedSize=="string"?t.installedSize:void 0,s=typeof t.installedTime=="string"?t.installedTime:void 0;return{name:t.name,version:t.version,description:t.description,dependencies:t.dependencies,status:e,...r===void 0?{}:{size:r},...i===void 0?{}:{installedSize:i},...s===void 0?{}:{installedTime:s}}}function YA(t){if(!Pn(t)||t.ok!==!0||typeof t.message!="string"||!Array.isArray(t.packages)||!t.packages.every(e=>typeof e=="string"))throw vt(Ln);return{message:t.message,packages:t.packages}}function XA(t){if(!Pn(t)||t.ok!==!0||typeof t.message!="string")throw vt(Ln);return{message:t.message}}function JA(t=globalThis.fetch){const e=_a(t,Ln);async function n(r,i){const s=await e.request(r,{method:"POST",json:{packages:i}});return YA(s)}return{async list(){const r=await e.request(Jy,{method:"GET"});return qA(r)},async info(r){const i=new URLSearchParams({name:r}),s=await e.request(`${r0}?${i.toString()}`,{method:"GET"});return KA(s)},install:r=>n(Qy,r),remove:r=>n(e0,r),upgrade:r=>n(n0,r),async update(){const r=await e.request(t0,{method:"POST",json:{}});return XA(r)}}}class ld extends ba{constructor(e,n,r,i){super(e,n,i,r),this.name="ServiceError"}}const Us=(t,e,n,r)=>new ld(t,e,r,n);function bf(t){if(!Pn(t)||typeof t.name!="string"||typeof t.label!="string"||t.state!=="running"&&t.state!=="stopped"&&t.state!=="unknown"||typeof t.enabledAtBoot!="boolean"||t.pid!==void 0&&typeof t.pid!="number"||typeof t.autostartPinned!="boolean"||typeof t.protected!="boolean")throw vt(Us);return{name:t.name,label:t.label,state:t.state,enabledAtBoot:t.enabledAtBoot,...t.pid===void 0?{}:{pid:t.pid},autostartPinned:t.autostartPinned,protected:t.protected}}function QA(t){if(!Pn(t)||!Array.isArray(t.services))throw vt(Us);return t.services.map(e=>bf(e))}function Pp(t){if(!Pn(t)||t.ok!==!0||t.service===void 0)throw vt(Us);return{ok:!0,service:bf(t.service)}}function eO(t=globalThis.fetch){const e=_a(t,Us);async function n(r,i){const s=await e.request(r,{method:"POST",json:{name:i}});return Pp(s)}return{async list(){return QA(await e.request(l0,{method:"GET"}))},async status(r,i){const s=new URLSearchParams({name:r}),o=await e.request(`${c0}?${s.toString()}`,{method:"GET",signal:i});if(!Pn(o)||o.service===void 0)throw vt(Us);return bf(o.service)},start:r=>n(u0,r),stop:r=>n(d0,r),restart:r=>n(f0,r),async setEnabled(r,i){const s=await e.request(h0,{method:"POST",json:{name:r,enabled:i}});return Pp(s)}}}class Ib extends ba{constructor(e,n,r,i){super(e,n,i,r),this.name="SelfUpdateError"}}const wr=(t,e,n,r)=>new Ib(t,e,r,n),zb=t=>t==="update"||t==="revert";function tO(t){if(!Pn(t)||t.state!=="idle"&&t.state!=="in-progress"&&t.state!=="failed"||!Jr(t.version)||t.operation!==void 0&&!zb(t.operation))throw vt(wr);for(const i of["targetVersion","failureCode","rollbackVersion"])if(t[i]!==void 0&&!Jr(t[i]))throw vt(wr);const e=t.targetVersion===void 0?void 0:t.targetVersion,n=t.failureCode===void 0?void 0:t.failureCode,r=t.rollbackVersion===void 0?void 0:t.rollbackVersion;return{state:t.state,version:t.version,...t.operation===void 0?{}:{operation:t.operation},...e===void 0?{}:{targetVersion:e},...n===void 0?{}:{failureCode:n},...r===void 0?{}:{rollbackVersion:r}}}function nO(t){if(!Pn(t)||!Jr(t.currentVersion)||typeof t.updateAvailable!="boolean"||typeof t.rollbackAvailable!="boolean"||t.targetVersion!==void 0&&!Jr(t.targetVersion)||t.rollbackVersion!==void 0&&!Jr(t.rollbackVersion)||t.updateAvailable!==(t.targetVersion!==void 0)||t.rollbackAvailable!==(t.rollbackVersion!==void 0))throw vt(wr);const e=t.targetVersion===void 0?void 0:t.targetVersion,n=t.rollbackVersion===void 0?void 0:t.rollbackVersion;return{currentVersion:t.currentVersion,updateAvailable:t.updateAvailable,rollbackAvailable:t.rollbackAvailable,...e===void 0?{}:{targetVersion:e},...n===void 0?{}:{rollbackVersion:n}}}function Rp(t){if(!Pn(t)||!zb(t.operation)||!Jr(t.targetVersion))throw vt(wr);return{operation:t.operation,targetVersion:t.targetVersion}}function rO(t=globalThis.fetch){const e=_a(t,wr);async function n(r){return e.request(r,{method:"POST",json:{}})}return{async status(){return tO(await e.request(i0,{method:"GET"}))},async check(){return nO(await n(s0))},async apply(){return Rp(await n(o0))},async revert(){return Rp(await n(a0))}}}class iO{constructor(e){X(this,"plugins",new Ti);X(this,"catalog");this.catalog=e.catalog}register(e){if(this.plugins.has(e.entry.name))throw new Error(`Duplicate plugin name "${e.entry.name}"`);this.plugins.set(e.entry.name,e),e.catalog!==void 0&&this.catalog.registerPluginCatalogCell(e.catalog)}replace(e){var r,i;const n=this.plugins.get(e.entry.name);if(n===void 0)throw new Error(`Cannot replace unknown plugin "${e.entry.name}"`);if(n.entry.type!==e.entry.type)throw new Error(`Cannot change plugin "${e.entry.name}" type from ${n.entry.type} to ${e.entry.type}`);if(n.entry.type==="page"&&e.entry.type==="page"&&n.entry.route!==e.entry.route)throw new Error(`Cannot change page "${e.entry.name}" route from ${n.entry.route} to ${e.entry.route}`);return n.entry.version===e.entry.version?e.stylesheetLease===void 0&&n.stylesheetLease!==void 0?e.stylesheetLease=n.stylesheetLease:e.stylesheetLease!==n.stylesheetLease&&((r=n.stylesheetLease)==null||r.release()):(i=n.stylesheetLease)==null||i.release(),this.plugins.set(e.entry.name,e),n.catalog!==void 0&&this.catalog.unregisterPluginCatalogCell(n.catalog),e.catalog!==void 0&&this.catalog.registerPluginCatalogCell(e.catalog),n}get(e){return this.plugins.get(e)}remove(e){var r;const n=this.plugins.get(e);if(n!==void 0)return this.plugins.delete(e),(r=n.stylesheetLease)==null||r.release(),n.catalog!==void 0&&this.catalog.unregisterPluginCatalogCell(n.catalog),n}getWidgets(){return[...this.plugins.values()].filter(e=>e.entry.type==="widget")}getPages(){return[...this.plugins.values()].filter(e=>e.entry.type==="page")}getAll(){return[...this.plugins.values()]}clear(){var e;for(const n of this.plugins.values())(e=n.stylesheetLease)==null||e.release(),n.catalog!==void 0&&this.catalog.unregisterPluginCatalogCell(n.catalog);this.plugins.clear(),this.catalog.clearPluginCatalogCells()}}function sO(t){return new iO(t)}const oO=["transient","unauthorized","validation","redemption-failed","controller-unavailable","malformed-response"];class Ar extends Error{constructor(n,r){super(n);X(this,"code");X(this,"status");this.name="PersistentRciSessionError",this.code=n,this.status=r}}const Ia="/api/mndw/rci-session",aO=["offline","establishing","live","dead"],lO=["certificate-invalid","no-auth-token","missing-fqdn"],cO=["token","none","unknown"],uO=["supported","invalid","unsupported","unknown","needs-token"],dO=["ok","empty","disabled","decrypt-failed"];class fO{async getCapability(){const e=await this.read(await bo(`${Ia}/capability`,{headers:{...ko}}));return this.parseCapability(e)}async testController(e){return await this.read(await this.post("/controller/test",{token:e}))}async saveController(e){return await this.read(await this.post("/controller",{token:e}))}async clearController(){await this.read(await bo(`${Ia}/controller`,{method:"DELETE",headers:{...ko}}))}async setEnabled(e){await this.read(await bo(`${Ia}/enabled`,{method:"PUT",headers:{"Content-Type":"application/json",...ko},body:JSON.stringify({enabled:e})}))}async post(e,n){return await bo(`${Ia}${e}`,{method:"POST",headers:{"Content-Type":"application/json",...ko},body:JSON.stringify(n)})}async read(e){const n=await e.text();let r;try{r=n===""?void 0:JSON.parse(n)}catch{throw new Ar("MALFORMED_RESPONSE",e.status)}if(!e.ok){const i=this.errorCode(r)??`HTTP_${e.status}`;throw new Ar(i,e.status)}return r}parseCapability(e){if(!this.isRecord(e)||!this.isRecord(e.store)||!this.isRecord(e.controller)||!Array.isArray(e.extenders)||typeof e.stale!="boolean"||!this.isStoreState(e.store.state)||!this.isSupport(e.controller.support)||!this.isAuthMode(e.controller.auth)||typeof e.controller.enabled!="boolean")throw new Ar("MALFORMED_RESPONSE",200);const n={support:e.controller.support,auth:e.controller.auth,enabled:e.controller.enabled};if(e.controller.lastCheckedAt!==void 0){if(typeof e.controller.lastCheckedAt!="string")throw new Ar("MALFORMED_RESPONSE",200);n.lastCheckedAt=e.controller.lastCheckedAt}const r=e.extenders.map(s=>this.parseExtender(s)),i={store:{state:e.store.state},controller:n,extenders:r,stale:e.stale};if(e.lastEnumerationError!==void 0){if(!this.isFailureCategory(e.lastEnumerationError))throw new Ar("MALFORMED_RESPONSE",200);i.lastEnumerationError=e.lastEnumerationError}if(e.lastEnumerationErrorAt!==void 0){if(typeof e.lastEnumerationErrorAt!="string")throw new Ar("MALFORMED_RESPONSE",200);i.lastEnumerationErrorAt=e.lastEnumerationErrorAt}return i}parseExtender(e){if(!this.isRecord(e)||typeof e.identity!="string"||typeof e.name!="string"||typeof e.eligible!="boolean")throw new Ar("MALFORMED_RESPONSE",200);if(!e.eligible){if(!this.isEligibilityReason(e.reason)||e.state!==void 0||e.lastError!==void 0||e.lastHeartbeatAt!==void 0)throw new Ar("MALFORMED_RESPONSE",200);return{identity:e.identity,name:e.name,eligible:!1,reason:e.reason}}if(e.reason!==void 0||e.state!==void 0&&!this.isSessionState(e.state)||e.lastError!==void 0&&!this.isFailureCategory(e.lastError)||e.lastHeartbeatAt!==void 0&&typeof e.lastHeartbeatAt!="string")throw new Ar("MALFORMED_RESPONSE",200);const n={identity:e.identity,name:e.name,eligible:!0};return e.state!==void 0&&(n.state=e.state),e.lastError!==void 0&&(n.lastError=e.lastError),e.lastHeartbeatAt!==void 0&&(n.lastHeartbeatAt=e.lastHeartbeatAt),n}errorCode(e){if(this.isRecord(e)&&this.isRecord(e.error)&&typeof e.error.code=="string")return e.error.code}isRecord(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}isStoreState(e){return typeof e=="string"&&dO.includes(e)}isSupport(e){return typeof e=="string"&&uO.includes(e)}isAuthMode(e){return typeof e=="string"&&cO.includes(e)}isSessionState(e){return typeof e=="string"&&aO.includes(e)}isEligibilityReason(e){return typeof e=="string"&&lO.includes(e)}isFailureCategory(e){return typeof e=="string"&&oO.includes(e)}}function hO(){return new fO}const pO=3e4,gO={path:"show.system"};class mO{constructor(){X(this,"transport");X(this,"heartbeatSubscription",null);X(this,"driver");X(this,"auth");const e=window.location.origin;this.transport=new L_,this.auth=new I_(e,this.transport),this.driver=new z_(e,this.transport)}login(e,n){return this.auth.login(e,n).pipe(yc(r=>{r?this.startHeartbeat():this.stopHeartbeat()}))}logout(){return this.stopHeartbeat(),this.auth.logout()}isAuthenticated(){return this.auth.isAuthenticated().pipe(yc(e=>{e?this.startHeartbeat():this.stopHeartbeat()}))}get authError$(){return this.transport.authError$.pipe(yc(()=>this.stopHeartbeat()))}startHeartbeat(){this.heartbeatSubscription===null&&(this.heartbeatSubscription=x_(0,pO).pipe(C_(()=>this.heartbeatRequest())).subscribe())}stopHeartbeat(){var e;(e=this.heartbeatSubscription)==null||e.unsubscribe(),this.heartbeatSubscription=null}heartbeatRequest(){return this.driver.queue(gO).pipe(P_(()=>R_))}}function vO(){return new mO}function bO(t=globalThis.fetch){return RC(t)}const _O=500,wO=5e3,Ap=.2,yO=100,kO=1024,EO=2048,SO=t=>(typeof t=="string"?[t]:[...t]).flatMap(n=>n.split(",")).filter(n=>n.length>0),TO=(t,e)=>t==="*"||e===t||e.startsWith(`${t}.`),xO=(t,e)=>{if(t==="*")return e;if(e==="*"||t===e||t.startsWith(`${e}.`))return t;if(e.startsWith(`${t}.`))return e},CO=(t,e)=>{const n=new Set;for(const r of t)for(const i of e){const s=xO(r,i);s!==void 0&&n.add(s)}return[...n]},PO=t=>{const e=t.split(".",1)[0]??t;return new Error(`Event topic "${t}" is not granted; add manifest capability "events:${e}".`)},RO=(t,e)=>e.some(n=>n==="*"||t===n||t.startsWith(`${n}.`)),AO=t=>{const e=new Set;for(const n of t){if(!n.startsWith("events:"))continue;const r=n.slice(7);for(const i of r.split(","))(i==="*"||/^[a-z][a-z0-9]*(?:\.[a-z][a-z0-9]*)*$/.test(i))&&e.add(i)}return[...e]},OO=t=>t!==null&&typeof t=="object"&&!Array.isArray(t)?t:void 0,cd=t=>{if(Array.isArray(t)){for(const n of t)cd(n);Object.freeze(t);return}if(t===null||typeof t!="object")return;const e=Object.getPrototypeOf(t);if(!(e!==Object.prototype&&e!==null)){for(const n of Object.values(t))cd(n);Object.freeze(t)}};class MO{constructor(e={}){X(this,"socketFactory");X(this,"schedule");X(this,"cancelSchedule");X(this,"random");X(this,"diagnostic");X(this,"registrations",new Map);X(this,"deliveredIds",new Set);X(this,"deliveredOrder",[]);X(this,"liveBuffer",[]);X(this,"socket");X(this,"lastSentWireFilters");X(this,"reconnectTimer");X(this,"reconnectAttempt",0);X(this,"nextHandlerId",1);X(this,"lastSeenId","");X(this,"replayCursor","");X(this,"catchingUp",!1);X(this,"replaying",!1);X(this,"closing",!1);this.socketFactory=e.WebSocket??(typeof WebSocket>"u"?void 0:WebSocket),this.schedule=e.setTimeout??globalThis.setTimeout,this.cancelSchedule=e.clearTimeout??globalThis.clearTimeout,this.random=e.random??Math.random,this.diagnostic=e.diagnostic??((n,r)=>console.warn(`[mndw] ${n}`,r))}createFacade(e,n,r,i){const s=AO(r);return this.disposeFacade(e),this.registrations.set(e,{id:e,pluginName:n,grants:s,subscriptions:new Map,resyncHandlers:new Map}),{select$:o=>this.selectEvents(e,o,i),resync$:new el(o=>{const a=this.registrations.get(e);if(a===void 0){o.complete();return}if(a.grants.length===0){o.complete();return}const l=this.nextHandlerId++;return a.resyncHandlers.set(l,()=>o.next()),()=>{a.resyncHandlers.delete(l)}}).pipe(If(i.ended$))}}selectEvents(e,n,r){return new el(i=>{const s=this.registrations.get(e);if(s===void 0){i.complete();return}const o=SO(n),a=o.find(u=>u!=="*"&&!RO(u,s.grants));if(a!==void 0){i.error(PO(a));return}const l=CO(o,s.grants);if(l.length===0){i.complete();return}const c=this.nextHandlerId++;return s.subscriptions.set(c,{filters:l,handler:u=>i.next(u)}),this.updateWireSubscription(),()=>{s.subscriptions.delete(c)&&this.updateWireSubscription()}}).pipe(If(r.ended$))}disposeFacade(e){this.registrations.delete(e)&&(this.updateWireSubscription(),this.registrations.size===0&&this.closeSocket())}effectiveWireFilters(){const e=new Set;for(const n of this.registrations.values())for(const r of n.subscriptions.values())for(const i of r.filters)e.add(i);return[...e].sort()}ensureSocket(){if(this.socket!==void 0||this.reconnectTimer!==void 0||this.closing||this.effectiveWireFilters().length===0)return;if(this.socketFactory===void 0){this.diagnostic("event stream WebSocket is unavailable");return}const e=new this.socketFactory("/ws/events");this.socket=e,e.addEventListener("open",()=>this.handleOpen(e)),e.addEventListener("message",n=>this.handleMessage(e,n.data)),e.addEventListener("close",()=>this.handleClose(e)),e.addEventListener("error",n=>this.diagnostic("event stream socket error",n))}handleOpen(e){this.socket===e&&(this.reconnectAttempt=0,this.lastSentWireFilters=void 0,this.sendSubscribe(),this.catchingUp=!0,this.replaying=!1,this.replayCursor=this.lastSeenId,this.requestReplay(this.lastSeenId))}handleClose(e){this.socket===e&&(this.socket=void 0,this.lastSentWireFilters=void 0,this.registrations.size>0&&!this.closing&&this.scheduleReconnect())}handleMessage(e,n){if(this.socket!==e||typeof n!="string")return;let r;try{r=JSON.parse(n)}catch(s){this.diagnostic("event stream returned invalid JSON",s);return}const i=OO(r);(i==null?void 0:i.type)==="event"?this.handleIncomingEvent(i.event):(i==null?void 0:i.type)==="replay"?this.handleReplay(i):(i==null?void 0:i.type)==="error"&&this.handleServerError(i)}handleIncomingEvent(e){const n=Ph.safeParse(e);if(!n.success){this.diagnostic("event stream returned invalid event",n.error);return}if(this.catchingUp){if(this.liveBuffer.length>=kO){this.liveBuffer.length=0,this.closeActiveSocket();return}this.liveBuffer.push(n.data);return}this.deliver(n.data)}handleReplay(e){if(!this.catchingUp||!Array.isArray(e.events)||typeof e.hasMore!="boolean")return;const n=e.events.map(i=>Ph.safeParse(i)).filter(i=>i.success);for(const i of n)i.success&&(this.replayCursor=i.data.id,this.deliver(i.data));if(this.replaying=!1,e.hasMore&&this.replayCursor!==""){this.requestReplay(this.replayCursor);return}this.catchingUp=!1,this.replaying=!1;const r=this.liveBuffer.splice(0);for(const i of r)this.deliver(i);for(const i of this.registrations.values())for(const s of i.resyncHandlers.values())try{s()}catch(o){this.diagnostic(`event resync handler failed for ${i.pluginName}`,o)}}handleServerError(e){if(e.code==="CURSOR_EXPIRED"){this.catchingUp=!1,this.replaying=!1;const r=this.liveBuffer.splice(0);for(const i of r)this.deliver(i);this.diagnostic("event stream replay cursor expired");for(const i of this.registrations.values())for(const s of i.resyncHandlers.values())try{s()}catch(o){this.diagnostic(`event resync handler failed for ${i.pluginName}`,o)}return}const n=typeof e.message=="string"?e.message:typeof e.code=="string"?e.code:"unknown";this.diagnostic(`event stream server error: ${n}`)}deliver(e){if(this.lastSeenId=e.id,!this.deliveredIds.has(e.id)){for(this.deliveredIds.add(e.id),this.deliveredOrder.push(e.id);this.deliveredOrder.length>EO;){const n=this.deliveredOrder.shift();n!==void 0&&this.deliveredIds.delete(n)}cd(e);for(const n of this.registrations.values())for(const r of n.subscriptions.values())if(r.filters.some(i=>TO(i,e.topic)))try{r.handler(e)}catch(i){this.diagnostic(`event handler failed for ${n.pluginName}`,i)}}}sendSubscribe(e=this.effectiveWireFilters()){const n=this.lastSentWireFilters;(n==null?void 0:n.length)===e.length&&n.every((r,i)=>r===e[i])||(this.send({type:"subscribe",topics:[...e]}),this.lastSentWireFilters=[...e])}updateWireSubscription(){const e=this.effectiveWireFilters();if(e.length===0){this.closeSocket();return}const n=this.socket;(n==null?void 0:n.readyState)===1&&this.sendSubscribe(e),this.ensureSocket()}requestReplay(e){this.replaying||(this.replaying=!0,this.send({type:"replay",after:e,limit:yO}))}send(e){const n=this.socket;(n==null?void 0:n.readyState)===1&&n.send(JSON.stringify(e))}scheduleReconnect(){if(this.reconnectTimer!==void 0||this.effectiveWireFilters().length===0)return;const e=Math.min(wO,_O*2**this.reconnectAttempt++),n=1-Ap+this.random()*2*Ap;this.reconnectTimer=this.schedule(()=>{this.reconnectTimer=void 0,this.ensureSocket()},Math.round(e*n))}closeActiveSocket(){const e=this.socket;e!==void 0&&(this.catchingUp=!1,this.replaying=!1,e.close(1008,"event stream catch-up overflow"))}closeSocket(){this.reconnectTimer!==void 0&&(this.cancelSchedule(this.reconnectTimer),this.reconnectTimer=void 0),this.catchingUp=!1,this.replaying=!1,this.liveBuffer.length=0,this.lastSentWireFilters=void 0;const e=this.socket;this.socket=void 0,e!==void 0&&e.close(1e3,"no event subscribers")}}function NO(t={}){return new MO(t)}let LO=0;function IO(t){const e=new Map,n=`host-telemetry-gathering:${++LO}`;let r=1,i=null,s=0,o,a=!1;const l=()=>{for(const p of[...e.values()])p()},c=p=>{(i==null?void 0:i.enabled)!==p&&(i=Object.freeze({enabled:p}),l())},u=()=>{const p=++s;t.getTelemetry().then(({enabled:g})=>{p===s&&c(g)}).catch(()=>{})},f=()=>{if(o===void 0)return;const p=o;o=void 0,p.end(),a&&(a=!1,t.eventStream.disposeFacade(n))},h=()=>{o=_b();const p=t.eventStream.createFacade(n,"host",["events:telemetry"],o);p!==void 0&&(a=!0,p.select$("telemetry.gathering_changed").subscribe(g=>{g.topic==="telemetry.gathering_changed"&&(s+=1,c(g.payload.enabled))}),p.resync$.subscribe(u)),u()};return{get:()=>i,subscribe:p=>{const g=r++;return e.set(g,p),e.size===1&&h(),()=>{e.delete(g)&&e.size===0&&f()}},report:p=>{s+=1,c(p)}}}const Op=`${Id}:theme`,uu="dark";function zO(t={}){const e=t.document??globalThis.document;let n=uu;const r=new Set;function i(){try{const h=(t.storage??globalThis.localStorage).getItem(Op);return h==="light"||h==="dark"?h:uu}catch{return uu}}function s(h){e.documentElement.dataset.theme=h}function o(h){for(const p of r)p(h)}function a(){return n=i(),s(n),o(n),n}function l(){return n}function c(h){if(h!==n){n=h,s(h);try{(t.storage??globalThis.localStorage).setItem(Op,h)}catch{}o(h)}}function u(){c(n==="dark"?"light":"dark")}function f(h){return r.add(h),()=>{r.delete(h)}}return Object.freeze({initTheme:a,getTheme:l,setTheme:c,toggleTheme:u,subscribeTheme:f})}const DO=()=>new Worker(new URL("/assets/ticker-pool.worker-DJA1ERT2.js",import.meta.url),{type:"module"});function HO(t=DO){const e=new Map;let n=1,r;const i=()=>{let l=0;for(const c of e.values())c.running&&!c.destroyed&&(l+=1);return l},s=()=>{if(i()!==0||r===void 0)return;const l=r;r=void 0,l.onmessage=null,l.terminate()},o=()=>{if(r!==void 0)return r;const l=t();return l.onmessage=c=>{const u=e.get(c.data.id);u!==void 0&&u.running&&!u.destroyed&&u.subject.next({timestamp:c.data.timestamp,drift:c.data.drift})},r=l,l};return Object.freeze({create:l=>{const c={id:n++,subject:new A_,running:!1,destroyed:!1,interval:1e3};e.set(c.id,c);const u=new O_,f=()=>{c.destroyed||(c.running&&(c.running=!1,r==null||r.postMessage({command:"stop",id:c.id})),c.destroyed=!0,e.delete(c.id),u.unsubscribe(),c.subject.complete(),s())};return u.add(l.ended$.subscribe(f)),{start:h=>{c.destroyed||(c.interval=h,c.running=!0,o().postMessage({command:"start",id:c.id,interval:h}))},setInterval:h=>{c.destroyed||(c.interval=h,r!==void 0&&r.postMessage({command:"setInterval",id:c.id,interval:h}))},stop:()=>{c.destroyed||!c.running||(c.running=!1,r==null||r.postMessage({command:"stop",id:c.id}),s())},tick$:c.subject.asObservable(),destroy:f}}})}class BO{constructor(){X(this,"stylesheets",new Map)}acquire(e,n,r){let i=this.stylesheets.get(e);i===void 0&&(i=new Map,this.stylesheets.set(e,i));const s=i.get(n);if(s!==void 0)return s.leases+=1,this.createLease(e,i,s);const o=document.createElement("link");let a=()=>{};const l=new Promise(u=>{a=u}),c={version:n,link:o,loaded:l,resolveLoaded:a,leases:1};return o.rel="stylesheet",o.href=r,o.dataset.pluginStyle=e,o.onload=()=>c.resolveLoaded(),o.onerror=()=>{console.warn(`[mndw] No stylesheet for plugin "${e}" at ${r}`),c.resolveLoaded()},i.set(n,c),document.head.appendChild(o),this.createLease(e,i,c)}retain(e,n){const r=this.stylesheets.get(e),i=r==null?void 0:r.get(n);return r===void 0||i===void 0?{loaded:Promise.resolve(),release:()=>{}}:(i.leases+=1,this.createLease(e,r,i))}createLease(e,n,r){let i=!1;return{loaded:r.loaded,release:()=>{i||(i=!0,r.leases-=1,!(r.leases!==0||n.get(r.version)!==r)&&(n.delete(r.version),n.size===0&&this.stylesheets.get(e)===n&&this.stylesheets.delete(e),r.link.remove(),r.resolveLoaded()))}}}}const UO=1e4;function jO(t){switch(t){case"modal":return{placement:"center",closeOnEscape:!0,closeOnOutsideClick:!1,trapFocus:!0,restoreFocus:!0,lockScroll:!0,backdrop:!0};case"drawer":return{placement:"right",closeOnEscape:!0,closeOnOutsideClick:!0,trapFocus:!0,restoreFocus:!0,lockScroll:!0,backdrop:!0};case"popover":return{placement:"bottom-start",closeOnEscape:!0,closeOnOutsideClick:!0,trapFocus:!1,restoreFocus:!1,lockScroll:!1,backdrop:!1};case"custom":return{placement:"center",closeOnEscape:!1,closeOnOutsideClick:!1,trapFocus:!1,restoreFocus:!1,lockScroll:!1,backdrop:!1}}}var ea,ta,na,ra,ia,sa;class Mp{constructor(e,n,r,i,s){X(this,"id");X(this,"pluginName");X(this,"instanceId");X(this,"kind");X(this,"hostElement");X(this,"contentElement");Ce(this,ea,te("opening"));Ce(this,ta,te(null));Ce(this,na,te("center"));X(this,"mobileSheet");Ce(this,ra,te(void 0));Ce(this,ia,te(pt({})));Ce(this,sa,te(null));X(this,"behavior");X(this,"closeOnEscape");X(this,"closeOnOutsideClick");X(this,"trapFocus");X(this,"restoreFocus");X(this,"lockScroll");X(this,"backdrop");X(this,"closed");X(this,"abortController",new AbortController);X(this,"anchorElement");X(this,"cleanup",null);X(this,"onCloseListeners",new Set);X(this,"previousFocus");X(this,"closedResolve");X(this,"openTimeout");X(this,"focusTrap",null);X(this,"repositionHandler",null);X(this,"anchorObserver",null);X(this,"runtime");var a;this.runtime=e,this.id=e.allocateLayerId(),this.pluginName=n,this.instanceId=r,this.kind=i.kind;const o=jO(i.kind);this.behavior=o,this.closeOnEscape=i.closeOnEscape??o.closeOnEscape,this.closeOnOutsideClick=i.closeOnOutsideClick??o.closeOnOutsideClick,this.trapFocus=i.trapFocus??o.trapFocus,this.restoreFocus=i.restoreFocus??o.restoreFocus,this.lockScroll=i.lockScroll??o.lockScroll,this.backdrop=o.backdrop,this.shell=s,this.placement=Nf(i.kind,i.placement),this.mobileSheet=b_(i.kind),this.className=i.className,this.sizing=Lf(i.kind,i,this.mobileSheet),this.anchorElement=((a=i.anchor)==null?void 0:a.element)??null,this.hostElement=document.createElement("div"),this.hostElement.className="mndw-overlay-layer",this.contentElement=document.createElement("div"),this.contentElement.className="mndw-overlay-content",s||this.hostElement.appendChild(this.contentElement),this.previousFocus=this.restoreFocus&&document.activeElement instanceof HTMLElement?document.activeElement:null,this.closed=new Promise(l=>{this.closedResolve=l}),this.openTimeout=setTimeout(()=>{this.state==="opening"&&this.closeInternal("mount-failed")},UO),this.attachAnchorObservers()}get state(){return d(x(this,ea))}set state(e){k(x(this,ea),e,!0)}get shell(){return d(x(this,ta))}set shell(e){k(x(this,ta),e,!0)}get placement(){return d(x(this,na))}set placement(e){k(x(this,na),e,!0)}get className(){return d(x(this,ra))}set className(e){k(x(this,ra),e,!0)}get sizing(){return d(x(this,ia))}set sizing(e){k(x(this,ia),e,!0)}get position(){return d(x(this,sa))}set position(e){k(x(this,sa),e,!0)}get isOpen(){return this.state==="opening"||this.state==="open"}get signal(){return this.abortController.signal}close(e,n="api"){this.closeInternal(n,e)}closeWithReason(e,n){this.closeInternal(e,n)}setCleanup(e){this.state!=="closed"&&(this.cleanup=e)}markReady(){this.state==="opening"&&(this.clearOpenTimeout(),this.state="open",this.trapFocus&&requestAnimationFrame(()=>this.activateFocusTrap()))}update(e){if(this.isOpen){if(e.className!==void 0&&(this.className=e.className),e.placement!==void 0&&(this.placement=Nf(this.kind,e.placement)),e.anchor!==void 0&&!this.shell&&(this.anchorElement=e.anchor.element,this.attachAnchorObservers()),this.shell){const n={...this.shell??{showCloseButton:!0}};e.title!==void 0&&(n.title=e.title),e.description!==void 0&&(n.description=e.description),e.showCloseButton!==void 0&&(n.showCloseButton=e.showCloseButton),this.shell=n}(e.width!==void 0||e.height!==void 0||e.maxWidth!==void 0||e.maxHeight!==void 0)&&(this.sizing=Lf(this.kind,{kind:this.kind,width:e.width,height:e.height,maxWidth:e.maxWidth,maxHeight:e.maxHeight},this.mobileSheet)),this.reposition()}}onClose(e){return this.onCloseListeners.add(e),()=>{this.onCloseListeners.delete(e)}}reposition(){if(this.kind!=="popover"||!this.anchorElement)return;const e=this.contentElement.getBoundingClientRect();if(e.width<=0||e.height<=0)return;const n=__({element:this.anchorElement},{width:e.width,height:e.height},this.placement);this.placement=n.placement,this.position={top:n.top,left:n.left}}attachAnchorObservers(){if(this.detachAnchorObservers(),this.kind!=="popover"||!this.anchorElement)return;const e=this.anchorElement;this.repositionHandler=()=>{requestAnimationFrame(()=>this.reposition())},window.addEventListener("scroll",this.repositionHandler,!0),window.addEventListener("resize",this.repositionHandler),this.anchorObserver=new MutationObserver(()=>{e.isConnected||this.closeInternal("anchor-lost")}),this.anchorObserver.observe(document.body,{childList:!0,subtree:!0})}detachAnchorObservers(){var e;this.repositionHandler&&(window.removeEventListener("scroll",this.repositionHandler,!0),window.removeEventListener("resize",this.repositionHandler),this.repositionHandler=null),(e=this.anchorObserver)==null||e.disconnect(),this.anchorObserver=null}clearOpenTimeout(){this.openTimeout!==void 0&&(clearTimeout(this.openTimeout),this.openTimeout=void 0)}async closeInternal(e,n){var s;if(this.state==="closing"||this.state==="closed")return;this.state="closing",(s=this.focusTrap)==null||s.deactivate(),this.focusTrap=null,this.clearOpenTimeout(),this.abortController.abort(),this.detachAnchorObservers();const r=this.cleanup;if(r)try{await(r instanceof Promise?await r:r)()}catch(o){console.error(`[mndw] Overlay cleanup for "${this.pluginName}" failed:`,o)}this.restoreFocusOnClose(),this.runtime.removeLayer(this),this.state="closed";const i={reason:e,result:n};this.closedResolve(i);for(const o of this.onCloseListeners)try{o(i)}catch(a){console.error(`[mndw] Overlay onClose listener for "${this.pluginName}" failed:`,a)}}restoreFocusOnClose(){var n,r;const e=document.activeElement;if(this.kind==="popover"&&((n=this.anchorElement)!=null&&n.isConnected)){const i=this.contentElement.contains(e),s=!e||e===document.body;(i||s)&&this.anchorElement.focus();return}this.restoreFocus&&((r=this.previousFocus)!=null&&r.isConnected)&&this.previousFocus.focus()}activateFocusTrap(){this.state!=="open"||this.focusTrap||!this.hostElement.isConnected||(this.focusTrap=mu(this.hostElement,{initialFocus:()=>y_(this.contentElement)[0]??null,restoreFocus:!1,allowFocus:e=>this.runtime.store.layers.some(n=>n.id>this.id&&w_(n.hostElement,e))}))}}ea=new WeakMap,ta=new WeakMap,na=new WeakMap,ra=new WeakMap,ia=new WeakMap,sa=new WeakMap;var oa;class $O{constructor(){Ce(this,oa,te(pt([])))}get layers(){return d(x(this,oa))}set layers(e){k(x(this,oa),e,!0)}}oa=new WeakMap;function FO(){const t=new $O;let e=1;return{store:t,allocateLayerId:()=>e++,removeLayer:n=>{const r=t.layers.indexOf(n);r!==-1&&t.layers.splice(r,1)},addLayer:n=>{if(n.kind==="modal")for(const r of[...t.layers])r.instanceId===n.instanceId&&r.kind==="popover"&&r.closeWithReason("replaced");t.layers.push(n)}}}function _f(t,e,n){let r=!1;function i(){if(r)throw new Error(`[mndw] Overlay service for "${t}" (${e}) is disposed; the plugin instance was unmounted.`)}function s(){return n.store.layers.filter(l=>l.instanceId===e)}const o={createLayer(l){i();const c=new Mp(n,t,e,l,null);return n.addLayer(c),c},open(l){i();const{title:c,description:u,showCloseButton:f,mount:h,kind:p,...g}=l,m=new Mp(n,t,e,{kind:p,...g},{title:c,description:u,showCloseButton:f??!0});n.addLayer(m);try{const b=h(m.contentElement,m,m.signal);b instanceof Promise?b.then(()=>m.markReady()).catch(_=>{console.error(`[mndw] Overlay mount for "${t}" failed:`,_),m.closeWithReason("mount-failed")}):m.markReady()}catch(b){console.error(`[mndw] Overlay mount for "${t}" failed:`,b),m.closeWithReason("mount-failed")}return m},closeAll(){for(const l of s())l.close(void 0,"api")}};function a(l="plugin-unmount"){if(!r){r=!0;for(const c of s())c.closeWithReason(l)}}return{service:o,dispose:a}}function GO(t){return _f("@mndw/ui","@mndw/ui",t).service}var VO=N('<a class="mndw-empty-state__link"> </a>'),ZO=N("<mndw-button> </mndw-button>",2),WO=N('<section><h2 class="mndw-empty-state__title"> </h2> <p class="mndw-empty-state__text"> </p> <!></section>');function Zi(t,e){Ze(e,!0);let n=Tn(e,"mode",3,"dashboard");var r=WO();let i;var s=v(r),o=v(s),a=S(s,2),l=v(a),c=S(a,2);{var u=h=>{var p=VO(),g=v(p);w(()=>{Ae(p,"href",e.action.href),E(g,e.action.label)}),C(h,p)},f=h=>{var p=ZO();w(()=>T(p,"variant",e.action.variant??"primary"));var g=v(p);w(()=>E(g,e.action.label)),de("click",p,function(...m){var b;(b=e.action.onActivate)==null||b.apply(this,m)}),C(h,p)};W(c,h=>{var p,g;((p=e.action)==null?void 0:p.href)!==void 0?h(u):((g=e.action)==null?void 0:g.onActivate)!==void 0&&h(f,1)})}w(()=>{i=Pe(r,1,"mndw-empty-state",null,i,{"mndw-empty-state--compact":n()==="compact"}),E(o,e.title),E(l,e.text)}),C(t,r),We()}bt(["click"]);class U{static getElements(e,n=document){if(typeof e=="string"){const r="getElementById"in n?n:void 0;if(r&&!isNaN(+e[0])){const s=r.getElementById(e);return s?[s]:[]}let i=n.querySelectorAll(e);if(!i.length&&e[0]!=="."&&e[0]!=="#"&&(i=n.querySelectorAll("."+e),i.length||(i=n.querySelectorAll("#"+e)),!i.length)){const s=n.querySelector(`[gs-id="${e}"]`);return s?[s]:[]}return Array.from(i)}return[e]}static getElement(e,n=document){if(typeof e=="string"){const r="getElementById"in n?n:void 0;if(!e.length)return null;if(r&&e[0]==="#")return r.getElementById(e.substring(1));if(e[0]==="#"||e[0]==="."||e[0]==="[")return n.querySelector(e);if(r&&!isNaN(+e[0]))return r.getElementById(e);let i=n.querySelector(e);return r&&!i&&(i=r.getElementById(e)),i||(i=n.querySelector("."+e)),i}return e}static lazyLoad(e){var n,r;return e.lazyLoad||((r=(n=e.grid)==null?void 0:n.opts)==null?void 0:r.lazyLoad)&&e.lazyLoad!==!1}static createDiv(e,n){const r=document.createElement("div");return e.forEach(i=>{i&&r.classList.add(i)}),n==null||n.appendChild(r),r}static shouldSizeToContent(e,n=!1){return(e==null?void 0:e.grid)&&(n?e.sizeToContent===!0||e.grid.opts.sizeToContent===!0&&e.sizeToContent===void 0:!!e.sizeToContent||e.grid.opts.sizeToContent&&e.sizeToContent!==!1)}static isIntercepted(e,n){return!(e.y>=n.y+n.h||e.y+e.h<=n.y||e.x+e.w<=n.x||e.x>=n.x+n.w)}static isTouching(e,n){return U.isIntercepted(e,{x:n.x-.5,y:n.y-.5,w:n.w+1,h:n.h+1})}static areaIntercept(e,n){const r=e.x>n.x?e.x:n.x,i=e.x+e.w<n.x+n.w?e.x+e.w:n.x+n.w;if(i<=r)return 0;const s=e.y>n.y?e.y:n.y,o=e.y+e.h<n.y+n.h?e.y+e.h:n.y+n.h;return o<=s?0:(i-r)*(o-s)}static area(e){return e.w*e.h}static sort(e,n=1){return e.sort((i,s)=>{const o=n*((i.y??1e4)-(s.y??1e4));return o===0?n*((i.x??1e4)-(s.x??1e4)):o})}static find(e,n){return n?e.find(r=>r.id===n):void 0}static toBool(e){return typeof e=="boolean"?e:typeof e=="string"?(e=e.toLowerCase(),!(e===""||e==="no"||e==="false"||e==="0")):!!e}static toNumber(e){return e===null||e.length===0?void 0:Number(e)}static parseHeight(e){let n,r="px";if(typeof e=="string")if(e==="auto"||e==="")n=0;else{const i=e.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw|%|cm|mm)?$/);if(!i)throw new Error(`Invalid height val = ${e}`);r=i[2]||"px",n=parseFloat(i[1])}else n=e;return{h:n,unit:r}}static defaults(e,...n){return n.forEach(r=>{for(const i in r){if(!r.hasOwnProperty(i))return;e[i]===null||e[i]===void 0?e[i]=r[i]:typeof r[i]=="object"&&typeof e[i]=="object"&&U.defaults(e[i],r[i])}}),e}static same(e,n){if(typeof e!="object")return e==n;if(typeof e!=typeof n||Object.keys(e).length!==Object.keys(n).length)return!1;for(const r in e)if(e[r]!==n[r])return!1;return!0}static copyPos(e,n,r=!1){return n.x!==void 0&&(e.x=n.x),n.y!==void 0&&(e.y=n.y),n.w!==void 0&&(e.w=n.w),n.h!==void 0&&(e.h=n.h),r&&(n.minW&&(e.minW=n.minW),n.minH&&(e.minH=n.minH),n.maxW&&(e.maxW=n.maxW),n.maxH&&(e.maxH=n.maxH)),e}static samePos(e,n){return e&&n&&e.x===n.x&&e.y===n.y&&(e.w||1)===(n.w||1)&&(e.h||1)===(n.h||1)}static sanitizeMinMax(e){e.minW||delete e.minW,e.minH||delete e.minH,e.maxW||delete e.maxW,e.maxH||delete e.maxH}static removeInternalAndSame(e,n){if(!(typeof e!="object"||typeof n!="object")&&!(Array.isArray(e)||Array.isArray(n)))for(let r in e){const i=e[r],s=n[r];r[0]==="_"||i===s?delete e[r]:i&&typeof i=="object"&&s!==void 0&&(U.removeInternalAndSame(i,s),Object.keys(i).length||delete e[r])}}static removeInternalForSave(e,n=!0){for(let r in e)(r[0]==="_"||e[r]===null||e[r]===void 0)&&delete e[r];delete e.grid,n&&delete e.el,e.autoPosition||delete e.autoPosition,e.noResize||delete e.noResize,e.noMove||delete e.noMove,e.locked||delete e.locked,(e.w===1||e.w===e.minW)&&delete e.w,(e.h===1||e.h===e.minH)&&delete e.h}static throttle(e,n){let r=!1;return(...i)=>{r||(r=!0,setTimeout(()=>{e(...i),r=!1},n))}}static removePositioningStyles(e){const n=e.style;n.position&&n.removeProperty("position"),n.left&&n.removeProperty("left"),n.top&&n.removeProperty("top"),n.width&&n.removeProperty("width"),n.height&&n.removeProperty("height")}static getScrollElement(e){if(!e)return document.scrollingElement||document.documentElement;const n=getComputedStyle(e).overflowY;return(n==="auto"||n==="scroll")&&e.scrollHeight>e.clientHeight?e:U.getScrollElement(e.parentElement)}static updateScrollResize(e,n,r){const i=U.getScrollElement(n),s=i.clientHeight,o=i===U.getScrollElement()?0:i.getBoundingClientRect().top,a=e.clientY-o,l=a<r,c=a>s-r;l?i.scrollBy({behavior:"smooth",top:a-r}):c&&i.scrollBy({behavior:"smooth",top:r-(s-a)})}static clone(e){return e==null||typeof e!="object"?e:e instanceof Array?[...e]:{...e}}static cloneDeep(e){const n=["parentGrid","el","grid","subGrid","engine"],r=U.clone(e);for(const i in r)r.hasOwnProperty(i)&&typeof r[i]=="object"&&i.substring(0,2)!=="__"&&!n.find(s=>s===i)&&(r[i]=U.cloneDeep(e[i]));return r}static cloneNode(e){const n=e.cloneNode(!0);return n.removeAttribute("id"),n}static appendTo(e,n){let r;typeof n=="string"?r=U.getElement(n):r=n,r&&r.appendChild(e)}static addElStyles(e,n){if(n instanceof Object)for(const r in n)n.hasOwnProperty(r)&&(Array.isArray(n[r])?n[r].forEach(i=>{e.style[r]=i}):e.style[r]=n[r])}static initEvent(e,n){const r={type:n.type},i={button:0,which:0,buttons:1,bubbles:!0,cancelable:!0,target:n.target?n.target:e.target};return["altKey","ctrlKey","metaKey","shiftKey"].forEach(s=>r[s]=e[s]),["pageX","pageY","clientX","clientY","screenX","screenY"].forEach(s=>r[s]=e[s]),{...r,...i}}static simulateMouseEvent(e,n,r){const i=e,s=new MouseEvent(n,{bubbles:!0,composed:!0,cancelable:!0,view:window,detail:1,screenX:e.screenX,screenY:e.screenY,clientX:e.clientX,clientY:e.clientY,ctrlKey:i.ctrlKey??!1,altKey:i.altKey??!1,shiftKey:i.shiftKey??!1,metaKey:i.metaKey??!1,button:0,relatedTarget:e.target});(r||e.target).dispatchEvent(s)}static getValuesFromTransformedElement(e){const n=document.createElement("div");U.addElStyles(n,{opacity:"0",position:"fixed",top:"0px",left:"0px",width:"1px",height:"1px",zIndex:"-999999"}),e.appendChild(n);const r=n.getBoundingClientRect();return e.removeChild(n),n.remove(),{xScale:1/r.width,yScale:1/r.height,xOffset:r.left,yOffset:r.top}}static swap(e,n,r){if(!e)return;const i=e[n];e[n]=e[r],e[r]=i}static canBeRotated(e){var n;return!(!e||e.w===e.h||e.locked||e.noResize||(n=e.grid)!=null&&n.opts.disableResize||e.minW&&e.minW===e.maxW||e.minH&&e.minH===e.maxH)}}class Kr{constructor(e={}){this.addedNodes=[],this.removedNodes=[],this.defaultColumn=12,this.column=e.column||this.defaultColumn,this.column>this.defaultColumn&&(this.defaultColumn=this.column),this.maxRow=e.maxRow,this._float=e.float,this.nodes=e.nodes||[],this.onChange=e.onChange}batchUpdate(e=!0,n=!0){return!!this.batchMode===e?this:(this.batchMode=e,e?(this._prevFloat=this._float,this._float=!0,this.cleanNodes(),this.saveInitial()):(this._float=this._prevFloat,delete this._prevFloat,n&&this._packNodes(),this._notify()),this)}_useEntireRowArea(e,n){return(!this.float||this.batchMode&&!this._prevFloat)&&!this._hasLocked&&(!e._moving||e._skipDown||n.y<=e.y)}_fixCollisions(e,n=e,r,i={}){if(this.sortNodes(-1),r=r||this.collide(e,n),!r)return!1;if(e._moving&&!i.nested&&!this.float&&this.swap(e,r))return!0;let s=n;!this._loading&&this._useEntireRowArea(e,n)&&(s={x:0,w:this.column,y:n.y,h:n.h},r=this.collide(e,s,i.skip));let o=!1;const a={nested:!0,pack:!1};let l=0;for(;r=r||this.collide(e,s,i.skip);){if(l++>this.nodes.length*2)throw new Error("Infinite collide check");let c;if(r.locked||this._loading||e._moving&&!e._skipDown&&n.y>e.y&&!this.float&&(!this.collide(r,{...r,y:e.y},e)||!this.collide(r,{...r,y:n.y-r.h},e))){e._skipDown=e._skipDown||n.y>e.y;const u={...n,y:r.y+r.h,...a};c=this._loading&&U.samePos(e,u)?!0:this.moveNode(e,u),(r.locked||this._loading)&&c?U.copyPos(n,e):!r.locked&&c&&i.pack&&(this._packNodes(),n.y=r.y+r.h,U.copyPos(e,n)),o=o||c}else c=this.moveNode(r,{...r,y:n.y+n.h,skip:e,...a});if(!c)return o;r=void 0}return o}collide(e,n=e,r){const i=e._id,s=r==null?void 0:r._id;return this.nodes.find(o=>o._id!==i&&o._id!==s&&U.isIntercepted(o,n))}collideAll(e,n=e,r){const i=e._id,s=r==null?void 0:r._id;return this.nodes.filter(o=>o._id!==i&&o._id!==s&&U.isIntercepted(o,n))}directionCollideCoverage(e,n,r){if(!n.rect||!e._rect)return;const i=e._rect,s={...n.rect};s.y>i.y?(s.h+=s.y-i.y,s.y=i.y):s.h+=i.y-s.y,s.x>i.x?(s.w+=s.x-i.x,s.x=i.x):s.w+=i.x-s.x;let o,a=.5;for(let l of r){if(l.locked||!l._rect)break;const c=l._rect;let u=Number.MAX_VALUE,f=Number.MAX_VALUE;i.y<c.y?u=(s.y+s.h-c.y)/c.h:i.y+i.h>c.y+c.h&&(u=(c.y+c.h-s.y)/c.h),i.x<c.x?f=(s.x+s.w-c.x)/c.w:i.x+i.w>c.x+c.w&&(f=(c.x+c.w-s.x)/c.w);const h=Math.min(f,u);h>a&&(a=h,o=l)}return n.collide=o,o}cacheRects(e,n,r,i,s,o){return this.nodes.forEach(a=>a._rect={y:a.y*n+r,x:a.x*e+o,w:a.w*e-o-i,h:a.h*n-r-s}),this}swap(e,n){if(!n||n.locked||!e||e.locked)return!1;function r(){const s=n.x,o=n.y;return n.x=e.x,n.y=e.y,e.h!=n.h?(e.x=s,e.y=n.y+n.h):e.w!=n.w?(e.x=n.x+n.w,e.y=o):(e.x=s,e.y=o),e._dirty=n._dirty=!0,!0}let i;if(e.w===n.w&&e.h===n.h&&(e.x===n.x||e.y===n.y)&&(i=U.isTouching(e,n)))return r();if(i!==!1){if(e.w===n.w&&e.x===n.x&&(i||(i=U.isTouching(e,n)))){if(n.y<e.y){const s=e;e=n,n=s}return r()}if(i!==!1){if(e.h===n.h&&e.y===n.y&&(i||(i=U.isTouching(e,n)))){if(n.x<e.x){const s=e;e=n,n=s}return r()}return!1}}}isAreaEmpty(e,n,r,i){const s={x:e||0,y:n||0,w:r||1,h:i||1};return!this.collide(s)}compact(e="compact",n=!0){if(this.nodes.length===0)return this;n&&this.sortNodes();const r=this.batchMode;r||this.batchUpdate();const i=this._inColumnResize;i||(this._inColumnResize=!0);const s=this.nodes;return this.nodes=[],s.forEach((o,a,l)=>{let c;o.locked||(o.autoPosition=!0,e==="list"&&a&&(c=l[a-1])),this.addNode(o,!1,c)}),i||delete this._inColumnResize,r||this.batchUpdate(!1),this}set float(e){this._float!==e&&(this._float=e||!1,e||this._packNodes()._notify())}get float(){return this._float||!1}sortNodes(e=1){return this.nodes=U.sort(this.nodes,e),this}_packNodes(){return this.batchMode?this:(this.sortNodes(),this.float?this.nodes.forEach(e=>{if(e._updating||e._orig===void 0||e.y===e._orig.y)return;let n=e.y;for(;n>e._orig.y;)--n,this.collide(e,{x:e.x,y:n,w:e.w,h:e.h})||(e._dirty=!0,e.y=n)}):this.nodes.forEach((e,n)=>{if(!e.locked)for(;e.y>0;){const r=n===0?0:e.y-1;if(!(n===0||!this.collide(e,{x:e.x,y:r,w:e.w,h:e.h})))break;e._dirty=e.y!==r,e.y=r}}),this)}prepareNode(e,n){e._id=e._id??Kr._idSeq++;const r=e.id;if(r){let s=1;for(;this.nodes.find(o=>o.id===e.id&&o!==e);)e.id=r+"_"+s++}(e.x===void 0||e.y===void 0||e.x===null||e.y===null)&&(e.autoPosition=!0);const i={x:0,y:0,w:1,h:1};return U.defaults(e,i),e.autoPosition||delete e.autoPosition,e.noResize||delete e.noResize,e.noMove||delete e.noMove,U.sanitizeMinMax(e),typeof e.x=="string"&&(e.x=Number(e.x)),typeof e.y=="string"&&(e.y=Number(e.y)),typeof e.w=="string"&&(e.w=Number(e.w)),typeof e.h=="string"&&(e.h=Number(e.h)),isNaN(e.x)&&(e.x=i.x,e.autoPosition=!0),isNaN(e.y)&&(e.y=i.y,e.autoPosition=!0),isNaN(e.w)&&(e.w=i.w),isNaN(e.h)&&(e.h=i.h),this.nodeBoundFix(e,n),e}nodeBoundFix(e,n){const r=e._orig||U.copyPos({},e);if(e.maxW&&(e.w=Math.min(e.w||1,e.maxW)),e.maxH&&(e.h=Math.min(e.h||1,e.maxH)),e.minW&&(e.w=Math.max(e.w||1,e.minW)),e.minH&&(e.h=Math.max(e.h||1,e.minH)),(e.x||0)+(e.w||1)>this.column&&this.column<this.defaultColumn&&!this._inColumnResize&&!this.skipCacheUpdate&&e._id!=null&&this.findCacheLayout(e,this.defaultColumn)===-1){const s={...e};s.autoPosition||s.x===void 0?(delete s.x,delete s.y):s.x=Math.min(this.defaultColumn-1,s.x),s.w=Math.min(this.defaultColumn,s.w||1),this.cacheOneLayout(s,this.defaultColumn)}return e.w>this.column?e.w=this.column:e.w<1&&(e.w=1),this.maxRow&&e.h>this.maxRow?e.h=this.maxRow:e.h<1&&(e.h=1),e.x<0&&(e.x=0),e.y<0&&(e.y=0),e.x+e.w>this.column&&(n?e.w=this.column-e.x:e.x=this.column-e.w),this.maxRow&&e.y+e.h>this.maxRow&&(n?e.h=this.maxRow-e.y:e.y=this.maxRow-e.h),U.samePos(e,r)||(e._dirty=!0),this}getDirtyNodes(e){return e?this.nodes.filter(n=>n._dirty&&!U.samePos(n,n._orig)):this.nodes.filter(n=>n._dirty)}_notify(e){if(this.batchMode||!this.onChange)return this;const n=(e||[]).concat(this.getDirtyNodes());return this.onChange(n),this}cleanNodes(){return this.batchMode?this:(this.nodes.forEach(e=>{delete e._dirty,delete e._lastTried}),this)}saveInitial(){return this.nodes.forEach(e=>{e._orig=U.copyPos({},e),delete e._dirty}),this._hasLocked=this.nodes.some(e=>e.locked),this}restoreInitial(){return this.nodes.forEach(e=>{!e._orig||U.samePos(e,e._orig)||(U.copyPos(e,e._orig),e._dirty=!0)}),this._notify(),this}findEmptyPosition(e,n=this.nodes,r=this.column,i){const s=i?i.y*r+(i.x+i.w):0;let o=!1;for(let a=s;!o;++a){const l=a%r,c=Math.floor(a/r);if(l+e.w>r)continue;const u={x:l,y:c,w:e.w,h:e.h};n.find(f=>U.isIntercepted(u,f))||((e.x!==l||e.y!==c)&&(e._dirty=!0),e.x=l,e.y=c,delete e.autoPosition,o=!0)}return o}addNode(e,n=!1,r){const i=this.nodes.find(o=>o._id===e._id);if(i)return i;this._inColumnResize?this.nodeBoundFix(e):this.prepareNode(e),delete e._temporaryRemoved,delete e._removeDOM;let s;return e.autoPosition&&this.findEmptyPosition(e,this.nodes,this.column,r)&&(delete e.autoPosition,s=!0),this.nodes.push(e),n&&this.addedNodes.push(e),s||this._fixCollisions(e),this.batchMode||this._packNodes()._notify(),e}removeNode(e,n=!0,r=!1){return this.nodes.find(i=>i._id===e._id)?(r&&this.removedNodes.push(e),n&&(e._removeDOM=!0),this.nodes=this.nodes.filter(i=>i._id!==e._id),e._isAboutToRemove||this._packNodes(),this._notify([e]),this):this}removeAll(e=!0,n=!0){if(delete this._layouts,!this.nodes.length)return this;e&&this.nodes.forEach(i=>i._removeDOM=!0);const r=this.nodes;return this.removedNodes=n?r:[],this.nodes=[],this._notify(r)}moveNodeCheck(e,n){if(!this.changedPosConstrain(e,n))return!1;if(n.pack=!0,!this.maxRow)return this.moveNode(e,n);let r;const i=new Kr({column:this.column,float:this.float,nodes:this.nodes.map(o=>o._id===e._id?(r={...o},r):{...o})});if(!r)return!1;const s=i.moveNode(r,n)&&i.getRow()<=Math.max(this.getRow(),this.maxRow);if(!s&&!n.resizing&&n.collide){const o=n.collide.el.gridstackNode;if(this.swap(e,o))return this._notify(),!0}return s?(i.nodes.filter(o=>o._dirty).forEach(o=>{const a=this.nodes.find(l=>l._id===o._id);a&&(U.copyPos(a,o),a._dirty=!0)}),this._notify(),!0):!1}willItFit(e){if(delete e._willFitPos,!this.maxRow)return!0;const n=new Kr({column:this.column,float:this.float,nodes:this.nodes.map(i=>({...i}))}),r={...e};return this.cleanupNode(r),delete r.el,delete r._id,delete r.content,delete r.grid,n.addNode(r),n.getRow()<=this.maxRow?(e._willFitPos=U.copyPos({},r),!0):!1}changedPosConstrain(e,n){return n.w=n.w||e.w,n.h=n.h||e.h,e.x!==n.x||e.y!==n.y?!0:(e.maxW&&(n.w=Math.min(n.w,e.maxW)),e.maxH&&(n.h=Math.min(n.h,e.maxH)),e.minW&&(n.w=Math.max(n.w,e.minW)),e.minH&&(n.h=Math.max(n.h,e.minH)),e.w!==n.w||e.h!==n.h)}moveNode(e,n){var c,u;if(!e||!n)return!1;let r;n.pack===void 0&&!this.batchMode&&(r=n.pack=!0),typeof n.x!="number"&&(n.x=e.x),typeof n.y!="number"&&(n.y=e.y),typeof n.w!="number"&&(n.w=e.w),typeof n.h!="number"&&(n.h=e.h);const i=e.w!==n.w||e.h!==n.h,s=U.copyPos({},e,!0);if(U.copyPos(s,n),this.nodeBoundFix(s,i),U.copyPos(n,s),!n.forceCollide&&U.samePos(e,n))return!1;const o=U.copyPos({},e),a=this.collideAll(e,s,n.skip);let l=!0;if(a.length){const f=e._moving&&!n.nested;let h=f?this.directionCollideCoverage(e,n,a):a[0];if(f&&h&&((u=(c=e.grid)==null?void 0:c.opts)!=null&&u.subGridDynamic)&&!e.grid._isTemp){const p=U.areaIntercept(n.rect,h._rect),g=U.area(n.rect),m=U.area(h._rect);p/(g<m?g:m)>.8&&(h.grid.makeSubGrid(h.el,void 0,e),h=void 0)}h?l=!this._fixCollisions(e,s,h,n):(l=!1,r&&delete n.pack)}return l&&!U.samePos(e,s)&&(e._dirty=!0,U.copyPos(e,s)),n.pack&&this._packNodes()._notify(),!U.samePos(e,o)}getRow(){return this.nodes.reduce((e,n)=>Math.max(e,n.y+n.h),0)}beginUpdate(e){return e._updating||(e._updating=!0,delete e._skipDown,this.batchMode||this.saveInitial()),this}endUpdate(){const e=this.nodes.find(n=>n._updating);return e&&(delete e._updating,delete e._skipDown),this}save(e=!0,n,r){var a;const i=((a=this._layouts)==null?void 0:a.length)||0;let s;i&&(r?r!==this.column&&(s=this._layouts[r]):this.column!==i-1&&(s=this._layouts[i-1]));const o=[];return this.sortNodes(),this.nodes.forEach(l=>{const c=s==null?void 0:s.find(f=>f._id===l._id),u={...l,...c||{}};U.removeInternalForSave(u,!e),n&&n(l,u),o.push(u)}),o}layoutsNodesChange(e){return!this._layouts||this._inColumnResize?this:(this._layouts.forEach((n,r)=>{if(!n||r===this.column)return this;if(r<this.column)this._layouts[r]=void 0;else{const i=r/this.column;e.forEach(s=>{if(!s._orig)return;const o=n.find(a=>a._id===s._id);o&&(o.y>=0&&s.y!==s._orig.y&&(o.y+=s.y-s._orig.y,o.y<0&&(o.y=0)),s.x!==s._orig.x&&(o.x=Math.round(s.x*i),o.x<0&&(o.x=0)),s.w!==s._orig.w&&(o.w=Math.round(s.w*i),o.w<1&&(o.w=1)))})}}),this)}columnChanged(e,n,r="moveScale"){var a;if(!this.nodes.length||!n||e===n)return this;const i=r==="compact"||r==="list";i&&this.sortNodes(1),n<e&&this.cacheLayout(this.nodes,e),this.batchUpdate();let s=[],o=i?this.nodes:U.sort(this.nodes,-1);if(n>e&&this._layouts){const l=this._layouts[n]||[],c=this._layouts.length-1;!l.length&&e!==c&&((a=this._layouts[c])!=null&&a.length)&&(e=c,this._layouts[c].forEach(u=>{const f=o.find(h=>h._id===u._id);f&&(!i&&!u.autoPosition&&(f.x=u.x??f.x,f.y=u.y??f.y),f.w=u.w??f.w,(u.x==null||u.y===void 0)&&(f.autoPosition=!0))})),l.forEach(u=>{const f=o.findIndex(h=>h._id===u._id);if(f!==-1){const h=o[f];if(i){h.w=u.w;return}(u.autoPosition||isNaN(u.x)||isNaN(u.y))&&this.findEmptyPosition(u,s),u.autoPosition||(h.x=u.x??h.x,h.y=u.y??h.y,h.w=u.w??h.w,s.push(h)),o.splice(f,1)}})}if(i)this.compact(r,!1);else{if(o.length)if(typeof r=="function")r(n,e,s,o);else{const l=i||r==="none"?1:n/e,c=r==="move"||r==="moveScale",u=r==="scale"||r==="moveScale";o.forEach(f=>{f.x=n===1?0:c?Math.round(f.x*l):Math.min(f.x,n-1),f.w=n===1||e===1?1:u?Math.round(f.w*l)||1:Math.min(f.w,n),s.push(f)}),o=[]}s=U.sort(s,-1),this._inColumnResize=!0,this.nodes=[],s.forEach(l=>{this.addNode(l,!1),delete l._orig})}return this.nodes.forEach(l=>delete l._orig),this.batchUpdate(!1,!i),delete this._inColumnResize,this}cacheLayout(e,n,r=!1){const i=[];return e.forEach((s,o)=>{if(s._id===void 0){const a=s.id?this.nodes.find(l=>l.id===s.id):void 0;s._id=(a==null?void 0:a._id)??Kr._idSeq++}i[o]={x:s.x,y:s.y,w:s.w,_id:s._id}}),this._layouts=r?[]:this._layouts||[],this._layouts[n]=i,this}cacheOneLayout(e,n){e._id=e._id??Kr._idSeq++;const r={x:e.x,y:e.y,w:e.w,_id:e._id};(e.autoPosition||e.x===void 0)&&(delete r.x,delete r.y,e.autoPosition&&(r.autoPosition=!0)),this._layouts=this._layouts||[],this._layouts[n]=this._layouts[n]||[];const i=this.findCacheLayout(e,n);return i===-1?this._layouts[n].push(r):this._layouts[n][i]=r,this}findCacheLayout(e,n){var r,i;return((i=(r=this._layouts)==null?void 0:r[n])==null?void 0:i.findIndex(s=>s._id===e._id))??-1}removeNodeFromLayoutCache(e){if(this._layouts)for(let n=0;n<this._layouts.length;n++){const r=this.findCacheLayout(e,n);r!==-1&&this._layouts[n].splice(r,1)}}cleanupNode(e){for(const n in e)n[0]==="_"&&n!=="_id"&&delete e[n];return this}}Kr._idSeq=0;const qn={alwaysShowResizeHandle:"mobile",animate:!0,auto:!0,cellHeight:"auto",cellHeightThrottle:100,cellHeightUnit:"px",column:12,draggable:{handle:".grid-stack-item-content",appendTo:"body",scroll:!0},handle:".grid-stack-item-content",itemClass:"grid-stack-item",margin:10,marginUnit:"px",maxRow:0,minRow:0,placeholderClass:"grid-stack-placeholder",placeholderText:"",removableOptions:{accept:"grid-stack-item",decline:"grid-stack-non-removable"},resizable:{handles:"se"},rtl:"auto"};class Ue{}const Er=typeof window<"u"&&typeof document<"u"&&("ontouchstart"in document||"ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0);class Jn{}function Pl(t,e){t.touches.length>1||(t.cancelable&&t.preventDefault(),U.simulateMouseEvent(t.changedTouches[0],e))}function Db(t,e){t.cancelable&&t.preventDefault(),U.simulateMouseEvent(t,e)}function Rl(t){Jn.touchHandled||(Jn.touchHandled=!0,Pl(t,"mousedown"))}function Al(t){Jn.touchHandled&&Pl(t,"mousemove")}function Ol(t){if(!Jn.touchHandled)return;Jn.pointerLeaveTimeout&&(window.clearTimeout(Jn.pointerLeaveTimeout),delete Jn.pointerLeaveTimeout);const e=!!Ue.dragElement;Pl(t,"mouseup"),e||Pl(t,"click"),Jn.touchHandled=!1}function Ml(t){t.pointerType!=="mouse"&&t.target.releasePointerCapture(t.pointerId)}function Np(t){Ue.dragElement&&t.pointerType!=="mouse"&&Db(t,"mouseenter")}function Lp(t){Ue.dragElement&&t.pointerType!=="mouse"&&(Jn.pointerLeaveTimeout=window.setTimeout(()=>{delete Jn.pointerLeaveTimeout,Db(t,"mouseleave")},10))}class hc{constructor(e,n,r){this.host=e,this.dir=n,this.option=r,this.moving=!1,this._mouseDown=this._mouseDown.bind(this),this._mouseMove=this._mouseMove.bind(this),this._mouseUp=this._mouseUp.bind(this),this._keyEvent=this._keyEvent.bind(this),this._init()}_init(){if(this.option.element)try{this.el=this.option.element instanceof HTMLElement?this.option.element:this.host.querySelector(this.option.element)}catch(e){this.option.element=void 0,console.error("Query for resizeable handle failed, falling back",e)}return this.el||(this.el=document.createElement("div"),this.host.appendChild(this.el)),this.el.classList.add("ui-resizable-handle"),this.el.classList.add(`${hc.prefix}${this.dir}`),this.el.style.zIndex="100",this.el.style.userSelect="none",this.el.addEventListener("mousedown",this._mouseDown),Er&&(this.el.addEventListener("touchstart",Rl),this.el.addEventListener("pointerdown",Ml)),this}destroy(){return this.moving&&this._mouseUp(this.mouseDownEvent),this.el.removeEventListener("mousedown",this._mouseDown),Er&&(this.el.removeEventListener("touchstart",Rl),this.el.removeEventListener("pointerdown",Ml)),this.option.element||this.host.removeChild(this.el),delete this.el,delete this.host,this}_mouseDown(e){this.mouseDownEvent=e,document.addEventListener("mousemove",this._mouseMove,{capture:!0,passive:!0}),document.addEventListener("mouseup",this._mouseUp,!0),Er&&(this.el.addEventListener("touchmove",Al),this.el.addEventListener("touchend",Ol)),e.stopPropagation(),e.preventDefault()}_mouseMove(e){const n=this.mouseDownEvent;this.moving?this._triggerEvent("move",e):Math.abs(e.x-n.x)+Math.abs(e.y-n.y)>2&&(this.moving=!0,this._triggerEvent("start",this.mouseDownEvent),this._triggerEvent("move",e),document.addEventListener("keydown",this._keyEvent)),e.stopPropagation()}_mouseUp(e){this.moving&&(this._triggerEvent("stop",e),document.removeEventListener("keydown",this._keyEvent)),document.removeEventListener("mousemove",this._mouseMove,!0),document.removeEventListener("mouseup",this._mouseUp,!0),Er&&(this.el.removeEventListener("touchmove",Al),this.el.removeEventListener("touchend",Ol)),delete this.moving,delete this.mouseDownEvent,e.stopPropagation(),e.preventDefault()}_keyEvent(e){var n,r;e.key==="Escape"&&((r=(n=this.host.gridstackNode)==null?void 0:n.grid)==null||r.engine.restoreInitial(),this._mouseUp(this.mouseDownEvent))}_triggerEvent(e,n){return this.option[e]&&this.option[e](n),this}}hc.prefix="ui-resizable-";class wf{constructor(){this._eventRegister={}}get disabled(){return this._disabled}on(e,n){this._eventRegister[e]=n}off(e){delete this._eventRegister[e]}enable(){this._disabled=!1}disable(){this._disabled=!0}destroy(){delete this._eventRegister}triggerEvent(e,n){if(!this.disabled&&this._eventRegister&&this._eventRegister[e])return this._eventRegister[e](n)}}class $o extends wf{constructor(e,n={}){super(),this.el=e,this.option=n,this.rectScale={x:1,y:1},this._ui=()=>{const i=this.el.parentElement.getBoundingClientRect(),s={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,right:this.originalRect.right,top:this.originalRect.top-this.scrolled},o=this.temporalRect||s;return{position:{left:this.option.rtl?(i.right-o.right)*this.rectScale.x:(o.left-i.left)*this.rectScale.x,top:(o.top-i.top)*this.rectScale.y},size:{width:o.width*this.rectScale.x,height:o.height*this.rectScale.y}}},this._mouseOver=this._mouseOver.bind(this),this._mouseOut=this._mouseOut.bind(this),this.enable(),this._setupAutoHide(this.option.autoHide),this._setupHandlers()}on(e,n){super.on(e,n)}off(e){super.off(e)}enable(){super.enable(),this.el.classList.remove("ui-resizable-disabled"),this._setupAutoHide(this.option.autoHide)}disable(){super.disable(),this.el.classList.add("ui-resizable-disabled"),this._setupAutoHide(!1)}destroy(){this._removeHandlers(),this._setupAutoHide(!1),delete this.el,super.destroy()}updateOption(e){const n=e.handles&&e.handles!==this.option.handles,r=e.autoHide&&e.autoHide!==this.option.autoHide;return Object.keys(e).forEach(i=>this.option[i]=e[i]),n&&(this._removeHandlers(),this._setupHandlers()),r&&this._setupAutoHide(this.option.autoHide),this}_setupAutoHide(e){return e?(this.el.classList.add("ui-resizable-autohide"),this.el.addEventListener("mouseover",this._mouseOver),this.el.addEventListener("mouseout",this._mouseOut)):(this.el.classList.remove("ui-resizable-autohide"),this.el.removeEventListener("mouseover",this._mouseOver),this.el.removeEventListener("mouseout",this._mouseOut),Ue.overResizeElement===this&&delete Ue.overResizeElement),this}_mouseOver(e){Ue.overResizeElement||Ue.dragElement||(Ue.overResizeElement=this,this.el.classList.remove("ui-resizable-autohide"))}_mouseOut(e){Ue.overResizeElement===this&&(delete Ue.overResizeElement,this.el.classList.add("ui-resizable-autohide"))}_setupHandlers(){return this.handlers=this.option.handles.split(",").map(e=>e.trim()).map(e=>new hc(this.el,e,{element:this.option.element,start:n=>this._resizeStart(n),stop:n=>this._resizeStop(n),move:n=>this._resizing(n,e)})),this}_resizeStart(e){this.sizeToContent=U.shouldSizeToContent(this.el.gridstackNode,!0),this.originalRect=this.el.getBoundingClientRect(),this.scrollEl=U.getScrollElement(this.el),this.scrollY=this.scrollEl.scrollTop,this.scrolled=0,this.startEvent=e,this._setupHelper(),this._applyChange();const n=U.initEvent(e,{type:"resizestart",target:this.el});return this.option.start&&this.option.start(n,this._ui()),this.el.classList.add("ui-resizable-resizing"),this.triggerEvent("resizestart",n),this}_resizing(e,n){this.scrolled=this.scrollEl.scrollTop-this.scrollY,this.temporalRect=this._getChange(e,n),this._applyChange();const r=U.initEvent(e,{type:"resize",target:this.el});return r.resizeDir=n,r.hasMovedX=this.option.rtl?n.includes("e"):n.includes("w"),r.hasMovedY=n.includes("n"),this.option.resize&&this.option.resize(r,this._ui()),this.triggerEvent("resize",r),this}_resizeStop(e){const n=U.initEvent(e,{type:"resizestop",target:this.el});return this._cleanHelper(),this.option.stop&&this.option.stop(n),this.el.classList.remove("ui-resizable-resizing"),this.triggerEvent("resizestop",n),delete this.startEvent,delete this.originalRect,delete this.temporalRect,delete this.scrollY,delete this.scrolled,this}_setupHelper(){this.elOriginStyleVal=$o._originStyleProp.map(r=>this.el.style[r]),this.parentOriginStylePosition=this.el.parentElement.style.position;const e=this.el.parentElement,n=U.getValuesFromTransformedElement(e);return this.rectScale={x:n.xScale,y:n.yScale},getComputedStyle(this.el.parentElement).position.match(/static/)&&(this.el.parentElement.style.position="relative"),this.el.style.position="absolute",this.el.style.opacity="0.8",this}_cleanHelper(){return $o._originStyleProp.forEach((e,n)=>{this.el.style[e]=this.elOriginStyleVal[n]||null}),this.el.parentElement.style.position=this.parentOriginStylePosition||null,this}_getChange(e,n){const r=this.startEvent,i={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,right:this.originalRect.right,top:this.originalRect.top-this.scrolled},s=e.clientX-r.clientX,o=this.sizeToContent?0:e.clientY-r.clientY;let a,l;const c=this.option.rtl;!c&&n.indexOf("e")>-1?i.width+=s:c&&n.indexOf("w")>-1?i.width-=s:!c&&n.indexOf("w")>-1?(i.width-=s,i.left+=s,a=!0):c&&n.indexOf("e")>-1&&(i.width+=s,i.right+=s,a=!0),n.indexOf("s")>-1?i.height+=o:n.indexOf("n")>-1&&(i.height-=o,i.top+=o,l=!0);const u=this._constrainSize(i.width,i.height,a,l);return Math.round(i.width)!==Math.round(u.width)&&(!c&&n.indexOf("w")>-1?i.left+=i.width-u.width:c&&n.indexOf("e")>-1&&(i.right-=i.width-u.width),i.width=u.width),Math.round(i.height)!==Math.round(u.height)&&(n.indexOf("n")>-1&&(i.top+=i.height-u.height),i.height=u.height),i}_constrainSize(e,n,r,i){const s=this.option,o=(r?s.maxWidthMoveLeft:s.maxWidth)||Number.MAX_SAFE_INTEGER,a=s.minWidth/this.rectScale.x||e,l=(i?s.maxHeightMoveUp:s.maxHeight)||Number.MAX_SAFE_INTEGER,c=s.minHeight/this.rectScale.y||n,u=Math.min(o,Math.max(a,e)),f=Math.min(l,Math.max(c,n));return{width:u,height:f}}_applyChange(){let e={left:0,right:0,top:0,width:0,height:0};if(this.el.style.position==="absolute"){const n=this.el.parentElement,{left:r,right:i,top:s}=n.getBoundingClientRect();e={left:r,right:i,top:s,width:0,height:0}}return this.temporalRect?(Object.entries(this.temporalRect).forEach(([n,r])=>{if(this.option.rtl?n==="left":n==="right")return;const i=n==="width"||n==="left"||n==="right"?this.rectScale.x:n==="height"||n==="top"?this.rectScale.y:1;let s;n==="right"?s=(e.right-r)*this.rectScale.x+"px":s=(r-e[n])*i+"px",this.el.style[n]=s}),this):this}_removeHandlers(){return this.handlers.forEach(e=>e.destroy()),delete this.handlers,this}}$o._originStyleProp=["width","height","position","left","right","top","opacity","zIndex"];const qO='input,textarea,button,select,option,[contenteditable="true"],.ui-resizable-handle';class Fo extends wf{constructor(e,n={}){var s;super(),this.el=e,this.option=n,this.dragTransform={xScale:1,yScale:1,xOffset:0,yOffset:0},this._autoScrollTick=()=>{const o=this.helper,a=this._autoScrollContainer;if(!o||!a){this._stopScrolling();return}const l=this._getClipping(o,a);if(l===0){this._stopScrolling();return}if(!this._autoScrollMaxSpeed){const p=window.innerHeight||document.documentElement.clientHeight;this._autoScrollMaxSpeed=Math.max(p/150,4)}const c=Math.abs(l),u=Math.min(c*.5,this._autoScrollMaxSpeed),f=l>0?u:-u,h=a.scrollTop;if(a.scrollTop+=f,a.scrollTop===h){this._stopScrolling();return}this.dragging&&this.lastDrag&&(this._dragFollow(this.lastDrag),this._callDrag(this.lastDrag)),this._autoScrollAnimId=requestAnimationFrame(this._autoScrollTick)};const r=(s=n==null?void 0:n.handle)==null?void 0:s.substring(1),i=e.gridstackNode;this.dragEls=!r||e.classList.contains(r)?[e]:i!=null&&i.subGrid?[e.querySelector(n.handle)||e]:this.getAllHandles(),this.dragEls.length===0&&(this.dragEls=[e]),this._mouseDown=this._mouseDown.bind(this),this._mouseMove=this._mouseMove.bind(this),this._mouseUp=this._mouseUp.bind(this),this._keyEvent=this._keyEvent.bind(this),this.enable()}getAllHandles(){return Array.from(this.el.querySelectorAll(this.option.handle)).filter(e=>{if(!(e instanceof HTMLElement))return!1;const n=e.closest(".grid-stack-item");return n===this.el||!n})}on(e,n){super.on(e,n)}off(e){super.off(e)}enable(){this.disabled!==!1&&(super.enable(),this.dragEls.forEach(e=>{e.addEventListener("mousedown",this._mouseDown),Er&&(e.addEventListener("touchstart",Rl),e.addEventListener("pointerdown",Ml))}),this.el.classList.remove("ui-draggable-disabled"))}disable(e=!1){this.disabled!==!0&&(super.disable(),this.dragEls.forEach(n=>{n.removeEventListener("mousedown",this._mouseDown),Er&&(n.removeEventListener("touchstart",Rl),n.removeEventListener("pointerdown",Ml))}),e||this.el.classList.add("ui-draggable-disabled"))}destroy(){this.dragTimeout&&window.clearTimeout(this.dragTimeout),delete this.dragTimeout,this.mouseDownEvent&&this._mouseUp(this.mouseDownEvent),this.disable(!0),delete this.el,delete this.helper,delete this.option,super.destroy()}updateOption(e){return Object.keys(e).forEach(n=>this.option[n]=e[n]),this}_mouseDown(e){if(Jn.touchHandled&&e.isTrusted&&(Jn.touchHandled=!1),!Ue.mouseHandled)return e.button!==0||!this.dragEls.find(n=>n===e.target)&&e.target.closest(qO)||this.option.cancel&&e.target.closest(this.option.cancel)||(this.mouseDownEvent=e,delete this.dragging,delete Ue.dragElement,delete Ue.dropElement,delete this._autoScrollMaxSpeed,delete this._autoScrollContainer,document.addEventListener("mousemove",this._mouseMove,{capture:!0,passive:!0}),document.addEventListener("mouseup",this._mouseUp,!0),Er&&(e.currentTarget.addEventListener("touchmove",Al),e.currentTarget.addEventListener("touchend",Ol)),e.preventDefault(),document.activeElement&&document.activeElement.blur(),Ue.mouseHandled=!0),!0}_callDrag(e){if(!this.dragging)return;const n=U.initEvent(e,{target:this.el,type:"drag"});this.option.drag&&this.option.drag(n,this.ui()),this.triggerEvent("drag",n)}_mouseMove(e){var r;const n=this.mouseDownEvent;if(this.lastDrag=e,this.dragging)if(this._dragFollow(e),Ue.pauseDrag){const i=Number.isInteger(Ue.pauseDrag)?Ue.pauseDrag:100;this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>this._callDrag(e),i)}else this._callDrag(e);else if(Math.abs(e.x-n.x)+Math.abs(e.y-n.y)>3){this.dragging=!0,Ue.dragElement=this;const i=(r=this.el.gridstackNode)==null?void 0:r.grid;i?Ue.dropElement=i.el.ddElement.ddDroppable:delete Ue.dropElement,this.helper=this._createHelper(),this._setupHelperContainmentStyle(),this.dragTransform=U.getValuesFromTransformedElement(this.helperContainment),this.dragOffset=this._getDragOffset(e,this.el,this.helperContainment),this._setupHelperStyle(e);const s=U.initEvent(e,{target:this.el,type:"dragstart"});this.option.start&&this.option.start(s,this.ui()),this.triggerEvent("dragstart",s),document.addEventListener("keydown",this._keyEvent)}return!0}_mouseUp(e){var n,r;if(this._stopScrolling(),document.removeEventListener("mousemove",this._mouseMove,!0),document.removeEventListener("mouseup",this._mouseUp,!0),Er&&e.currentTarget&&(e.currentTarget.removeEventListener("touchmove",Al,!0),e.currentTarget.removeEventListener("touchend",Ol,!0)),this.dragging){delete this.dragging,(n=this.el.gridstackNode)==null||delete n._origRotate,document.removeEventListener("keydown",this._keyEvent),((r=Ue.dropElement)==null?void 0:r.el)===this.el.parentElement&&delete Ue.dropElement,this.helperContainment.style.position=this.parentOriginStylePosition||null,this.helper!==this.el&&this.helper.remove(),this._removeHelperStyle();const i=U.initEvent(e,{target:this.el,type:"dragstop"});this.option.stop&&this.option.stop(i),this.triggerEvent("dragstop",i),Ue.dropElement&&Ue.dropElement.drop(e)}delete this.helper,delete this.mouseDownEvent,delete Ue.dragElement,delete Ue.dropElement,delete Ue.mouseHandled,e.preventDefault()}_keyEvent(e){var i,s;const n=this.el.gridstackNode,r=(n==null?void 0:n.grid)||((s=(i=Ue.dropElement)==null?void 0:i.el)==null?void 0:s.gridstack);if(e.key==="Escape")n&&n._origRotate&&(n._orig=n._origRotate,delete n._origRotate),r==null||r.cancelDrag(),this._mouseUp(this.mouseDownEvent);else if(n&&r&&(e.key==="r"||e.key==="R")){if(!U.canBeRotated(n))return;n._origRotate=n._origRotate||{...n._orig},delete n._moving,r.setAnimation(!1).rotate(n.el,{top:-this.dragOffset.offsetTop,left:-this.dragOffset.offsetX}).setAnimation(),n._moving=!0,this.dragOffset=this._getDragOffset(this.lastDrag,n.el,this.helperContainment),this.helper.style.width=this.dragOffset.width+"px",this.helper.style.height=this.dragOffset.height+"px",U.swap(n._orig,"w","h"),delete n._rect,this._mouseMove(this.lastDrag)}}_createHelper(){let e=this.el;return typeof this.option.helper=="function"?e=this.option.helper(this.el):this.option.helper==="clone"&&(e=U.cloneNode(this.el)),e.parentElement||U.appendTo(e,this.option.appendTo==="parent"?this.el.parentElement:this.option.appendTo),this.dragElementOriginStyle=Fo.originStyleProp.map(n=>this.el.style[n]),e}_setupHelperStyle(e){var r,i;this.helper.classList.add("ui-draggable-dragging"),(i=(r=this.el.gridstackNode)==null?void 0:r.grid)==null||i.el.classList.add("grid-stack-dragging");const n=this.helper.style;return n.pointerEvents="none",n.width=this.dragOffset.width+"px",n.height=this.dragOffset.height+"px",n.willChange="left, right, top",n.position="fixed",this._dragFollow(e),n.transition="none",setTimeout(()=>{this.helper&&(n.transition=null)},0),this}_removeHelperStyle(){var n,r,i;this.helper.classList.remove("ui-draggable-dragging"),(r=(n=this.el.gridstackNode)==null?void 0:n.grid)==null||r.el.classList.remove("grid-stack-dragging");const e=(i=this.helper)==null?void 0:i.gridstackNode;if(!(e!=null&&e._isAboutToRemove)&&this.dragElementOriginStyle){const s=this.helper,o=this.dragElementOriginStyle.transition||null;s.style.transition=this.dragElementOriginStyle.transition="none",Fo.originStyleProp.forEach(a=>s.style[a]=this.dragElementOriginStyle[a]||null),setTimeout(()=>s.style.transition=o,50)}return delete this.dragElementOriginStyle,this}_dragFollow(e){const n=this.helper.style,r=this.dragOffset;this.option.rtl?(n.right=(window.innerWidth-e.clientX+r.offsetX)*this.dragTransform.xScale+"px",n.left&&(n.left="")):(n.left=(e.clientX+r.offsetX)*this.dragTransform.xScale+"px",n.right&&(n.right="")),n.top=(e.clientY+r.offsetTop)*this.dragTransform.yScale+"px"}_setupHelperContainmentStyle(){return this.helperContainment=this.helper.parentElement,this.helper.style.position!=="fixed"&&(this.parentOriginStylePosition=this.helperContainment.style.position,getComputedStyle(this.helperContainment).position.match(/static/)&&(this.helperContainment.style.position="relative")),this}_getDragOffset(e,n,r){let i=0,s=0;r&&(i=this.dragTransform.xOffset,s=this.dragTransform.yOffset);const o=n.getBoundingClientRect();let a=this.option.rtl?o.right:o.left,l=this.option.rtl?e.clientX-o.right+i:-e.clientX+o.left-i;return{x:a,top:o.top,offsetX:l,offsetTop:-e.clientY+o.top-s,width:o.width*this.dragTransform.xScale,height:o.height*this.dragTransform.yScale}}updateScrollPosition(e){this._autoScrollContainer=U.getScrollElement(e),this._getClipping(this.helper,this._autoScrollContainer)===0?this._stopScrolling():this._autoScrollAnimId||(this._autoScrollAnimId=requestAnimationFrame(this._autoScrollTick))}_getClipping(e,n){const r=e.getBoundingClientRect(),i=n.getBoundingClientRect(),s=window.innerHeight||document.documentElement.clientHeight;if(r.bottom<i.top||r.top>i.bottom)return 0;const o=r.bottom-Math.min(i.bottom,s),a=r.top-Math.max(i.top,0);return a<0?a:o>0?o:0}_stopScrolling(){this._autoScrollAnimId&&(cancelAnimationFrame(this._autoScrollAnimId),delete this._autoScrollAnimId)}ui(){const n=this.el.parentElement.getBoundingClientRect(),r=this.helper.getBoundingClientRect(),i=this.option.rtl?(n.right-r.right)*this.dragTransform.xScale:(r.left-n.left)*this.dragTransform.xScale;return{position:{top:(r.top-n.top)*this.dragTransform.yScale,left:i}}}}Fo.originStyleProp=["width","height","transform","transform-origin","transition","pointerEvents","position","left","right","top","minWidth","willChange"];class KO extends wf{constructor(e,n={}){super(),this.el=e,this.option=n,this._mouseEnter=this._mouseEnter.bind(this),this._mouseLeave=this._mouseLeave.bind(this),this.enable(),this._setupAccept()}on(e,n){super.on(e,n)}off(e){super.off(e)}enable(){this.disabled!==!1&&(super.enable(),this.el.classList.add("ui-droppable"),this.el.classList.remove("ui-droppable-disabled"),this.el.addEventListener("mouseenter",this._mouseEnter),this.el.addEventListener("mouseleave",this._mouseLeave),Er&&(this.el.addEventListener("pointerenter",Np),this.el.addEventListener("pointerleave",Lp)))}disable(e=!1){this.disabled!==!0&&(super.disable(),this.el.classList.remove("ui-droppable"),e||this.el.classList.add("ui-droppable-disabled"),this.el.removeEventListener("mouseenter",this._mouseEnter),this.el.removeEventListener("mouseleave",this._mouseLeave),Er&&(this.el.removeEventListener("pointerenter",Np),this.el.removeEventListener("pointerleave",Lp)))}destroy(){this.disable(!0),this.el.classList.remove("ui-droppable"),this.el.classList.remove("ui-droppable-disabled"),super.destroy()}updateOption(e){return Object.keys(e).forEach(n=>this.option[n]=e[n]),this._setupAccept(),this}_mouseEnter(e){if(!Ue.dragElement||Jn.touchHandled&&e.isTrusted||!this._canDrop(Ue.dragElement.el))return;e.preventDefault(),e.stopPropagation(),Ue.dragElement._stopScrolling(),Ue.dropElement&&Ue.dropElement!==this&&Ue.dropElement._mouseLeave(e,!0),Ue.dropElement=this;const n=U.initEvent(e,{target:this.el,type:"dropover"});this.option.over&&this.option.over(n,this._ui(Ue.dragElement)),this.triggerEvent("dropover",n),this.el.classList.add("ui-droppable-over")}_mouseLeave(e,n=!1){var i;if(!Ue.dragElement||Ue.dropElement!==this)return;e.preventDefault(),e.stopPropagation(),n&&Ue.dragElement._stopScrolling();const r=U.initEvent(e,{target:this.el,type:"dropout"});if(this.option.out&&this.option.out(r,this._ui(Ue.dragElement)),this.triggerEvent("dropout",r),Ue.dropElement===this&&(delete Ue.dropElement,!n)){let s,o=this.el.parentElement;for(;!s&&o;)s=(i=o.ddElement)==null?void 0:i.ddDroppable,o=o.parentElement;s&&s._mouseEnter(e)}}drop(e){e.preventDefault();const n=U.initEvent(e,{target:this.el,type:"drop"});this.option.drop&&this.option.drop(n,this._ui(Ue.dragElement)),this.triggerEvent("drop",n)}_canDrop(e){return e&&(!this.accept||this.accept(e))}_setupAccept(){return this.option.accept?(typeof this.option.accept=="string"?this.accept=e=>e.classList.contains(this.option.accept)||e.matches(this.option.accept):this.accept=this.option.accept,this):this}_ui(e){return{draggable:e.el,...e.ui()}}}class yf{static init(e){return e.ddElement||(e.ddElement=new yf(e)),e.ddElement}constructor(e){this.el=e}on(e,n){return this.ddDraggable&&["drag","dragstart","dragstop"].indexOf(e)>-1?this.ddDraggable.on(e,n):this.ddDroppable&&["drop","dropover","dropout"].indexOf(e)>-1?this.ddDroppable.on(e,n):this.ddResizable&&["resizestart","resize","resizestop"].indexOf(e)>-1&&this.ddResizable.on(e,n),this}off(e){return this.ddDraggable&&["drag","dragstart","dragstop"].indexOf(e)>-1?this.ddDraggable.off(e):this.ddDroppable&&["drop","dropover","dropout"].indexOf(e)>-1?this.ddDroppable.off(e):this.ddResizable&&["resizestart","resize","resizestop"].indexOf(e)>-1&&this.ddResizable.off(e),this}setupDraggable(e){return this.ddDraggable?this.ddDraggable.updateOption(e):this.ddDraggable=new Fo(this.el,e),this}cleanDraggable(){return this.ddDraggable&&(this.ddDraggable.destroy(),delete this.ddDraggable),this}setupResizable(e){return this.ddResizable?this.ddResizable.updateOption(e):this.ddResizable=new $o(this.el,e),this}cleanResizable(){return this.ddResizable&&(this.ddResizable.destroy(),delete this.ddResizable),this}setupDroppable(e){return this.ddDroppable?this.ddDroppable.updateOption(e):this.ddDroppable=new KO(this.el,e),this}cleanDroppable(){return this.ddDroppable&&(this.ddDroppable.destroy(),delete this.ddDroppable),this}}class YO{resizable(e,n,r,i){return this._getDDElements(e,n).forEach(s=>{if(n==="disable"||n==="enable")s.ddResizable&&s.ddResizable[n]();else if(n==="destroy")s.ddResizable&&s.cleanResizable();else if(n==="option")s.setupResizable({[r]:i});else{const a=s.el.gridstackNode.grid;let l=s.el.getAttribute("gs-resize-handles")||a.opts.resizable.handles||"e,s,se";l==="all"&&(l="n,e,s,w,se,sw,ne,nw");const c=!a.opts.alwaysShowResizeHandle;s.setupResizable({...a.opts.resizable,handles:l,autoHide:c,start:n.start,stop:n.stop,resize:n.resize,rtl:n.rtl})}}),this}draggable(e,n,r,i){return this._getDDElements(e,n).forEach(s=>{if(n==="disable"||n==="enable")s.ddDraggable&&s.ddDraggable[n]();else if(n==="destroy")s.ddDraggable&&s.cleanDraggable();else if(n==="option")s.setupDraggable({[r]:i});else{const o=s.el.gridstackNode.grid;s.setupDraggable({...o.opts.draggable,start:n.start,stop:n.stop,drag:n.drag,rtl:n.rtl})}}),this}dragIn(e,n){return this._getDDElements(e).forEach(r=>r.setupDraggable(n)),this}droppable(e,n,r,i){return typeof n.accept=="function"&&!n._accept&&(n._accept=n.accept,n.accept=s=>n._accept(s)),this._getDDElements(e,n).forEach(s=>{n==="disable"||n==="enable"?s.ddDroppable&&s.ddDroppable[n]():n==="destroy"?s.ddDroppable&&s.cleanDroppable():n==="option"?s.setupDroppable({[r]:i}):s.setupDroppable(n)}),this}isDroppable(e){var n;return!!((n=e==null?void 0:e.ddElement)!=null&&n.ddDroppable&&!e.ddElement.ddDroppable.disabled)}isDraggable(e){var n;return!!((n=e==null?void 0:e.ddElement)!=null&&n.ddDraggable&&!e.ddElement.ddDraggable.disabled)}isResizable(e){var n;return!!((n=e==null?void 0:e.ddElement)!=null&&n.ddResizable&&!e.ddElement.ddResizable.disabled)}on(e,n,r){return this._getDDElements(e).forEach(i=>i.on(n,s=>{r(s,Ue.dragElement?Ue.dragElement.el:s.target,Ue.dragElement?Ue.dragElement.helper:null)})),this}off(e,n){return this._getDDElements(e).forEach(r=>r.off(n)),this}_getDDElements(e,n){const r=e.gridstack||n!=="destroy"&&n!=="disable",i=U.getElements(e);return i.length?i.map(o=>o.ddElement||(r?yf.init(o):null)).filter(o=>o):[]}}/*!
81
+ * GridStack 12.6.0
82
+ * https://gridstackjs.com/
83
+ *
84
+ * Copyright (c) 2021-2025 Alain Dumesny
85
+ * see root license https://github.com/gridstack/gridstack.js/tree/master/LICENSE
86
+ */const An=new YO;class Le{static init(e={},n=".grid-stack"){if(typeof document>"u")return null;const r=Le.getGridElement(n);return r?(r.gridstack||(r.gridstack=new Le(r,U.cloneDeep(e))),r.gridstack):(console.error(typeof n=="string"?'GridStack.initAll() no grid was found with selector "'+n+`" - element missing or wrong selector ?
87
+ Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.`:"GridStack.init() no grid element was passed."),null)}static initAll(e={},n=".grid-stack"){const r=[];return typeof document>"u"||(Le.getGridElements(n).forEach(i=>{i.gridstack||(i.gridstack=new Le(i,U.cloneDeep(e))),r.push(i.gridstack)}),r.length===0&&console.error('GridStack.initAll() no grid was found with selector "'+n+`" - element missing or wrong selector ?
88
+ Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.`)),r}static addGrid(e,n={}){if(!e)return null;let r=e;if(r.gridstack){const o=r.gridstack;return n&&(o.opts={...o.opts,...n}),n.children!==void 0&&o.load(n.children),o}return(!e.classList.contains("grid-stack")||Le.addRemoveCB)&&(Le.addRemoveCB?r=Le.addRemoveCB(e,n,!0,!0):r=U.createDiv(["grid-stack",n.class],e)),Le.init(n,r)}static registerEngine(e){Le.engineClass=e}get placeholder(){if(!this._placeholder){this._placeholder=U.createDiv([this.opts.placeholderClass,qn.itemClass,this.opts.itemClass]);const e=U.createDiv(["placeholder-content"],this._placeholder);this.opts.placeholderText&&(e.textContent=this.opts.placeholderText)}return this._placeholder}constructor(e,n={}){var c;this.el=e,this.opts=n,this.animationDelay=310,this._gsEventHandler={},this._extraDragRow=0,this.dragTransform={xScale:1,yScale:1,xOffset:0,yOffset:0},e.gridstack=this,this.opts=n=n||{},e.classList.contains("grid-stack")||this.el.classList.add("grid-stack"),n.row&&(n.minRow=n.maxRow=n.row,delete n.row);const r=U.toNumber(e.getAttribute("gs-row"));n.column==="auto"&&delete n.column,n.alwaysShowResizeHandle!==void 0&&(n._alwaysShowResizeHandle=n.alwaysShowResizeHandle);const i=n.columnOpts;if(i){const u=i.breakpoints;!i.columnWidth&&!(u!=null&&u.length)?delete n.columnOpts:(i.columnMax=i.columnMax||12,(u==null?void 0:u.length)>1&&u.sort((f,h)=>(h.w||0)-(f.w||0)))}const s={...U.cloneDeep(qn),column:U.toNumber(e.getAttribute("gs-column"))||qn.column,minRow:r||U.toNumber(e.getAttribute("gs-min-row"))||qn.minRow,maxRow:r||U.toNumber(e.getAttribute("gs-max-row"))||qn.maxRow,staticGrid:U.toBool(e.getAttribute("gs-static"))||qn.staticGrid,sizeToContent:U.toBool(e.getAttribute("gs-size-to-content"))||void 0,draggable:{handle:(n.handleClass?"."+n.handleClass:n.handle?n.handle:"")||qn.draggable.handle},removableOptions:{accept:n.itemClass||qn.removableOptions.accept,decline:qn.removableOptions.decline}};e.getAttribute("gs-animate")&&(s.animate=U.toBool(e.getAttribute("gs-animate"))),n=U.defaults(n,s),this._initMargin(),this.checkDynamicColumn(),this._updateColumnVar(n),n.rtl==="auto"&&(n.rtl=e.style.direction==="rtl"),n.rtl&&this.el.classList.add("grid-stack-rtl");const o=this.el.closest("."+qn.itemClass),a=o==null?void 0:o.gridstackNode;if(a&&(a.subGrid=this,this.parentGridNode=a,this.el.classList.add("grid-stack-nested"),a.el.classList.add("grid-stack-sub-grid")),this._isAutoCellHeight=n.cellHeight==="auto",this._isAutoCellHeight||n.cellHeight==="initial")this.cellHeight(void 0);else{typeof n.cellHeight=="number"&&n.cellHeightUnit&&n.cellHeightUnit!==qn.cellHeightUnit&&(n.cellHeight=n.cellHeight+n.cellHeightUnit,delete n.cellHeightUnit);const u=n.cellHeight;delete n.cellHeight,this.cellHeight(u)}n.alwaysShowResizeHandle==="mobile"&&(n.alwaysShowResizeHandle=Er),this._setStaticClass();const l=n.engineClass||Le.engineClass||Kr;if(this.engine=new l({column:this.getColumn(),float:n.float,maxRow:n.maxRow,onChange:u=>{u.forEach(f=>{const h=f.el;h&&(f._removeDOM?(h&&h.remove(),delete f._removeDOM):this._writePosAttr(h,f))}),this._updateContainerHeight()}}),n.auto&&(this.batchUpdate(),this.engine._loading=!0,this.getGridItems().forEach(u=>this._prepareElement(u)),delete this.engine._loading,this.batchUpdate(!1)),n.children){const u=n.children;delete n.children,u.length&&this.load(u)}this.setAnimation(),n.subGridDynamic&&!Ue.pauseDrag&&(Ue.pauseDrag=!0),((c=n.draggable)==null?void 0:c.pause)!==void 0&&(Ue.pauseDrag=n.draggable.pause),this._setupRemoveDrop(),this._setupAcceptWidget(),this._updateResizeEvent()}_updateColumnVar(e=this.opts){this.el.classList.add("gs-"+e.column),typeof e.column=="number"&&this.el.style.setProperty("--gs-column-width",`${100/e.column}%`)}addWidget(e){if(!e)return;if(typeof e=="string"){console.error("V11: GridStack.addWidget() does not support string anymore. see #2736");return}if(e.ELEMENT_NODE)return console.error("V11: GridStack.addWidget() does not support HTMLElement anymore. use makeWidget()"),this.makeWidget(e);let n,r=e;if(r.grid=this,r.el?n=r.el:Le.addRemoveCB?n=Le.addRemoveCB(this.el,e,!0,!1):n=this.createWidgetDivs(r),!n)return;if(r=n.gridstackNode,r&&n.parentElement===this.el&&this.engine.nodes.find(s=>s._id===r._id))return n;const i=this._readAttr(n);return U.defaults(e,i),this.engine.prepareNode(e),this.el.appendChild(n),this.makeWidget(n,e),n}createWidgetDivs(e){const n=U.createDiv(["grid-stack-item",this.opts.itemClass]),r=U.createDiv(["grid-stack-item-content"],n);return U.lazyLoad(e)?e.visibleObservable||(e.visibleObservable=new IntersectionObserver(([i])=>{var s,o;i.isIntersecting&&((s=e.visibleObservable)==null||s.disconnect(),delete e.visibleObservable,Le.renderCB(r,e),(o=e.grid)==null||o.prepareDragDrop(e.el))}),window.setTimeout(()=>{var i;return(i=e.visibleObservable)==null?void 0:i.observe(n)})):Le.renderCB(r,e),n}makeSubGrid(e,n,r,i=!0){var p,g,m;let s=e.gridstackNode;if(s||(s=this.makeWidget(e).gridstackNode),(p=s.subGrid)!=null&&p.el)return s.subGrid;let o,a=this;for(;a&&!o;)o=(g=a.opts)==null?void 0:g.subGridOpts,a=(m=a.parentGridNode)==null?void 0:m.grid;n=U.cloneDeep({...this.opts,id:void 0,children:void 0,column:"auto",columnOpts:void 0,layout:"list",subGridOpts:void 0,...o||{},...n||s.subGridOpts||{}}),s.subGridOpts=n;let l;n.column==="auto"&&(l=!0,n.column=Math.max(s.w||1,(r==null?void 0:r.w)||1),delete n.columnOpts);let c=s.el.querySelector(".grid-stack-item-content"),u,f;if(i&&(this._removeDD(s.el),f={...s,x:0,y:0},U.removeInternalForSave(f),delete f.subGridOpts,s.content&&(f.content=s.content,delete s.content),Le.addRemoveCB?u=Le.addRemoveCB(this.el,f,!0,!1):(u=U.createDiv(["grid-stack-item"]),u.appendChild(c),c=U.createDiv(["grid-stack-item-content"],s.el)),this.prepareDragDrop(s.el)),r){const b=l?n.column:s.w,_=s.h+r.h,y=s.el.style;y.transition="none",this.update(s.el,{w:b,h:_}),setTimeout(()=>y.transition=null)}const h=s.subGrid=Le.addGrid(c,n);return r!=null&&r._moving&&(h._isTemp=!0),l&&(h._autoColumn=!0),i&&h.makeWidget(u,f),r&&(r._moving?window.setTimeout(()=>U.simulateMouseEvent(r._event,"mouseenter",h.el),0):h.makeWidget(s.el,s)),this.resizeToContentCheck(!1,s),h}removeAsSubGrid(e){var r;const n=(r=this.parentGridNode)==null?void 0:r.grid;n&&(n.batchUpdate(),n.removeWidget(this.parentGridNode.el,!0,!0),this.engine.nodes.forEach(i=>{i.x+=this.parentGridNode.x,i.y+=this.parentGridNode.y,n.makeWidget(i.el,i)}),n.batchUpdate(!1),this.parentGridNode&&delete this.parentGridNode.subGrid,delete this.parentGridNode,e&&window.setTimeout(()=>U.simulateMouseEvent(e._event,"mouseenter",n.el),0))}save(e=!0,n=!1,r=Le.saveCB,i){const s=this.engine.save(e,r,i);if(s.forEach(o=>{var a;if(e&&o.el&&!o.subGrid&&!r){const l=o.el.querySelector(".grid-stack-item-content");o.content=l==null?void 0:l.innerHTML,o.content||delete o.content}else if(!e&&!r&&delete o.content,(a=o.subGrid)!=null&&a.el){const l=o.w||o.subGrid.getColumn(),c=o.subGrid.save(e,n,r,l);o.subGridOpts=n?c:{children:c},delete o.subGrid}delete o.el}),n){const o=U.cloneDeep(this.opts);o.marginBottom===o.marginTop&&o.marginRight===o.marginLeft&&o.marginTop===o.marginRight&&(o.margin=o.marginTop,delete o.marginTop,delete o.marginRight,delete o.marginBottom,delete o.marginLeft),o.rtl===(this.el.style.direction==="rtl")&&(o.rtl="auto"),this._isAutoCellHeight&&(o.cellHeight="auto"),this._autoColumn&&(o.column="auto");const a=o._alwaysShowResizeHandle;return delete o._alwaysShowResizeHandle,a!==void 0?o.alwaysShowResizeHandle=a:delete o.alwaysShowResizeHandle,U.removeInternalAndSame(o,qn),o.children=s,o}return s}load(e,n=Le.addRemoveCB||!0){e.forEach(u=>{u.w=u.w||u.minW||1,u.h=u.h||u.minH||1}),e=U.sort(e),this.engine.skipCacheUpdate=this._ignoreLayoutsNodeChange=!0;let r=0;e.forEach(u=>{r=Math.max(r,(u.x||0)+u.w)}),r>this.engine.defaultColumn&&(this.engine.defaultColumn=r);const i=this.getColumn();r>i&&(this.engine.nodes.length===0&&this.responseLayout?(this.engine.nodes=e,this.engine.columnChanged(r,i,this.responseLayout),e=this.engine.nodes,this.engine.nodes=[],delete this.responseLayout):this.engine.cacheLayout(e,r,!0));const s=Le.addRemoveCB;typeof n=="function"&&(Le.addRemoveCB=n);const o=[];this.batchUpdate();const a=!this.engine.nodes.length,l=a&&this.opts.animate;l&&this.setAnimation(!1),!a&&n&&[...this.engine.nodes].forEach(f=>{if(!f.id)return;U.find(e,f.id)||(Le.addRemoveCB&&Le.addRemoveCB(this.el,f,!1,!1),o.push(f),this.removeWidget(f.el,!0,!1))}),this.engine._loading=!0;const c=[];return this.engine.nodes=this.engine.nodes.filter(u=>U.find(e,u.id)?(c.push(u),!1):!0),e.forEach(u=>{var h;const f=U.find(c,u.id);if(f){if(U.shouldSizeToContent(f)&&(u.h=f.h),this.engine.nodeBoundFix(u),(u.autoPosition||u.x===void 0||u.y===void 0)&&(u.w=u.w||f.w,u.h=u.h||f.h,this.engine.findEmptyPosition(u)),this.engine.nodes.push(f),U.samePos(f,u)&&this.engine.nodes.length>1&&(this.moveNode(f,{...u,forceCollide:!0}),U.copyPos(u,f)),this.update(f.el,u),(h=u.subGridOpts)!=null&&h.children){const p=f.el.querySelector(".grid-stack");p&&p.gridstack&&p.gridstack.load(u.subGridOpts.children)}}else n&&this.addWidget(u)}),delete this.engine._loading,this.engine.removedNodes=o,this.batchUpdate(!1),delete this._ignoreLayoutsNodeChange,delete this.engine.skipCacheUpdate,s?Le.addRemoveCB=s:delete Le.addRemoveCB,l&&this.setAnimation(!0,!0),this}batchUpdate(e=!0){return this.engine.batchUpdate(e),e||(this._updateContainerHeight(),this._triggerRemoveEvent(),this._triggerAddEvent(),this._triggerChangeEvent()),this}getCellHeight(e=!1){if(this.opts.cellHeight&&this.opts.cellHeight!=="auto"&&(!e||!this.opts.cellHeightUnit||this.opts.cellHeightUnit==="px"))return this.opts.cellHeight;if(this.opts.cellHeightUnit==="rem")return this.opts.cellHeight*parseFloat(getComputedStyle(document.documentElement).fontSize);if(this.opts.cellHeightUnit==="em")return this.opts.cellHeight*parseFloat(getComputedStyle(this.el).fontSize);if(this.opts.cellHeightUnit==="cm")return this.opts.cellHeight*(96/2.54);if(this.opts.cellHeightUnit==="mm")return this.opts.cellHeight*(96/2.54)/10;const n=this.el.querySelector("."+this.opts.itemClass);if(n){const i=U.toNumber(n.getAttribute("gs-h"))||1;return Math.round(n.offsetHeight/i)}const r=parseInt(this.el.getAttribute("gs-current-row"));return r?Math.round(this.el.getBoundingClientRect().height/r):this.opts.cellHeight}cellHeight(e){if(e!==void 0&&this._isAutoCellHeight!==(e==="auto")&&(this._isAutoCellHeight=e==="auto",this._updateResizeEvent()),(e==="initial"||e==="auto")&&(e=void 0),e===void 0){const r=-this.opts.marginRight-this.opts.marginLeft+this.opts.marginTop+this.opts.marginBottom;e=this.cellWidth()+r}const n=U.parseHeight(e);return this.opts.cellHeightUnit===n.unit&&this.opts.cellHeight===n.h?this:(this.opts.cellHeightUnit=n.unit,this.opts.cellHeight=n.h,this.el.style.setProperty("--gs-cell-height",`${this.opts.cellHeight}${this.opts.cellHeightUnit}`),this._updateContainerHeight(),this.resizeToContentCheck(),this)}cellWidth(){return this._widthOrContainer()/this.getColumn()}_widthOrContainer(e=!1){var n;return e&&((n=this.opts.columnOpts)!=null&&n.breakpointForWindow)?window.innerWidth:this.el.clientWidth||this.el.parentElement.clientWidth||window.innerWidth}checkDynamicColumn(){var s,o;const e=this.opts.columnOpts;if(!e||!e.columnWidth&&!((s=e.breakpoints)!=null&&s.length))return!1;const n=this.getColumn();let r=n;const i=this._widthOrContainer(!0);if(e.columnWidth)r=Math.min(Math.round(i/e.columnWidth)||1,e.columnMax);else{r=e.columnMax;let a=0;for(;a<e.breakpoints.length&&i<=e.breakpoints[a].w;)r=e.breakpoints[a++].c||n}if(r!==n){const a=(o=e.breakpoints)==null?void 0:o.find(l=>l.c===r);return this.column(r,(a==null?void 0:a.layout)||e.layout),!0}return!1}compact(e="compact",n=!0){return this.engine.compact(e,n),this._triggerChangeEvent(),this}column(e,n="moveScale"){if(!e||e<1||this.opts.column===e)return this;const r=this.getColumn();return this.opts.column=e,this.engine?(this.engine.column=e,this.el.classList.remove("gs-"+r),this._updateColumnVar(),this.engine.columnChanged(r,e,n),this._isAutoCellHeight&&this.cellHeight(),this.resizeToContentCheck(!0),this._ignoreLayoutsNodeChange=!0,this._triggerChangeEvent(),delete this._ignoreLayoutsNodeChange,this):(this.responseLayout=n,this)}getColumn(){return this.opts.column}getGridItems(){return Array.from(this.el.children).filter(e=>e.matches("."+this.opts.itemClass)&&!e.matches("."+this.opts.placeholderClass))}isIgnoreChangeCB(){return this._ignoreLayoutsNodeChange}destroy(e=!0){var n;if(this.el)return this.offAll(),this._updateResizeEvent(!0),this.setStatic(!0,!1),this.setAnimation(!1),e?this.el.parentNode.removeChild(this.el):(this.removeAll(e),this.el.removeAttribute("gs-current-row")),this.parentGridNode&&delete this.parentGridNode.subGrid,delete this.parentGridNode,delete this.opts,(n=this._placeholder)==null||delete n.gridstackNode,delete this._placeholder,delete this.engine,delete this.el.gridstack,delete this.el,this}float(e){return this.opts.float!==e&&(this.opts.float=this.engine.float=e,this._triggerChangeEvent()),this}getFloat(){return this.engine.float}getCellFromPixel(e,n=!1){const r=this.el.getBoundingClientRect();let i;n?i={top:r.top+document.documentElement.scrollTop,left:r.left}:i={top:this.el.offsetTop,left:this.el.offsetLeft};const s=e.left-i.left,o=e.top-i.top,a=r.width/this.getColumn(),l=r.height/parseInt(this.el.getAttribute("gs-current-row"));return{x:Math.floor(s/a),y:Math.floor(o/l)}}getRow(){return Math.max(this.engine.getRow(),this.opts.minRow||0)}isAreaEmpty(e,n,r,i){return this.engine.isAreaEmpty(e,n,r,i)}makeWidget(e,n){const r=Le.getElement(e);if(!r||r.gridstackNode)return r;r.parentElement||this.el.appendChild(r),this._prepareElement(r,!0,n);const i=r.gridstackNode;this._updateContainerHeight(),i.subGridOpts&&this.makeSubGrid(r,i.subGridOpts,void 0,!1);let s;return this.opts.column===1&&!this._ignoreLayoutsNodeChange&&(s=this._ignoreLayoutsNodeChange=!0),this._triggerAddEvent(),this._triggerChangeEvent(),s&&delete this._ignoreLayoutsNodeChange,r}on(e,n){return e.indexOf(" ")!==-1?(e.split(" ").forEach(i=>this.on(i,n)),this):(e==="change"||e==="added"||e==="removed"||e==="enable"||e==="disable"?(e==="enable"||e==="disable"?this._gsEventHandler[e]=i=>n(i):this._gsEventHandler[e]=i=>{i.detail&&n(i,i.detail)},this.el.addEventListener(e,this._gsEventHandler[e])):e==="drag"||e==="dragstart"||e==="dragstop"||e==="resizestart"||e==="resize"||e==="resizestop"||e==="dropped"||e==="resizecontent"?this._gsEventHandler[e]=n:console.error("GridStack.on("+e+") event not supported"),this)}off(e){return e.indexOf(" ")!==-1?(e.split(" ").forEach(r=>this.off(r)),this):((e==="change"||e==="added"||e==="removed"||e==="enable"||e==="disable")&&this._gsEventHandler[e]&&this.el.removeEventListener(e,this._gsEventHandler[e]),delete this._gsEventHandler[e],this)}offAll(){return Object.keys(this._gsEventHandler).forEach(e=>this.off(e)),this}removeWidget(e,n=!0,r=!0){return e?(Le.getElements(e).forEach(i=>{if(i.parentElement&&i.parentElement!==this.el)return;let s=i.gridstackNode;s||(s=this.engine.nodes.find(o=>i===o.el)),s&&(n&&Le.addRemoveCB&&Le.addRemoveCB(this.el,s,!1,!1),delete i.gridstackNode,this._removeDD(i),this.engine.removeNode(s,n,r),n&&i.parentElement&&i.remove())}),r&&(this._triggerRemoveEvent(),this._triggerChangeEvent()),this):(console.error("Error: GridStack.removeWidget(undefined) called"),this)}removeAll(e=!0,n=!0){return this.engine.nodes.forEach(r=>{e&&Le.addRemoveCB&&Le.addRemoveCB(this.el,r,!1,!1),delete r.el.gridstackNode,this.opts.staticGrid||this._removeDD(r.el)}),this.engine.removeAll(e,n),n&&this._triggerRemoveEvent(),this}setAnimation(e=this.opts.animate,n){return n?setTimeout(()=>{this.opts&&this.setAnimation(e)}):e?this.el.classList.add("grid-stack-animate"):this.el.classList.remove("grid-stack-animate"),this.opts.animate=e,this}hasAnimationCSS(){return this.el.classList.contains("grid-stack-animate")}setStatic(e,n=!0,r=!0){return!!this.opts.staticGrid===e?this:(e?this.opts.staticGrid=!0:delete this.opts.staticGrid,this._setupRemoveDrop(),this._setupAcceptWidget(),this.engine.nodes.forEach(i=>{this.prepareDragDrop(i.el),i.subGrid&&r&&i.subGrid.setStatic(e,n,r)}),n&&this._setStaticClass(),this)}updateOptions(e){var r;const n=this.opts;if(e===n)return this;if(e.acceptWidgets!==void 0&&(n.acceptWidgets=e.acceptWidgets,this._setupAcceptWidget()),e.animate!==void 0&&this.setAnimation(e.animate),e.cellHeight&&this.cellHeight(e.cellHeight),e.class!==void 0&&e.class!==n.class&&(n.class&&this.el.classList.remove(n.class),e.class&&this.el.classList.add(e.class)),e.columnOpts){const i=!!this.opts.columnOpts;this.opts.columnOpts=e.columnOpts,i!==!!this.opts.columnOpts&&this._updateResizeEvent(),this.checkDynamicColumn()}else e.columnOpts===null&&this.opts.columnOpts?(delete this.opts.columnOpts,this._updateResizeEvent()):typeof e.column=="number"&&this.column(e.column);return e.margin!==void 0&&this.margin(e.margin),e.staticGrid!==void 0&&this.setStatic(e.staticGrid),e.disableDrag!==void 0&&!e.staticGrid&&this.enableMove(!e.disableDrag),e.disableResize!==void 0&&!e.staticGrid&&this.enableResize(!e.disableResize),e.float!==void 0&&this.float(e.float),e.row!==void 0?(n.minRow=n.maxRow=n.row=e.row,this._updateContainerHeight()):(e.minRow!==void 0&&(n.minRow=e.minRow,this._updateContainerHeight()),e.maxRow!==void 0&&(n.maxRow=this.engine.maxRow=e.maxRow)),e.lazyLoad!==void 0&&(n.lazyLoad=e.lazyLoad),(r=e.children)!=null&&r.length&&this.load(e.children),this}update(e,n){return Le.getElements(e).forEach(r=>{var u;const i=r==null?void 0:r.gridstackNode;if(!i)return;const s={...U.copyPos({},i),...U.cloneDeep(n)};this.engine.nodeBoundFix(s),delete s.autoPosition;const o=["x","y","w","h"];let a;if(o.some(f=>s[f]!==void 0&&s[f]!==i[f])&&(a={},o.forEach(f=>{a[f]=s[f]!==void 0?s[f]:i[f],delete s[f]})),!a&&(s.minW||s.minH||s.maxW||s.maxH)&&(a={}),s.content!==void 0){const f=r.querySelector(".grid-stack-item-content");f&&f.textContent!==s.content&&(i.content=s.content,Le.renderCB(f,s),(u=i.subGrid)!=null&&u.el&&(f.appendChild(i.subGrid.el),i.subGrid._updateContainerHeight())),delete s.content}let l=!1,c=!1;for(const f in s)f[0]!=="_"&&i[f]!==s[f]&&(i[f]=s[f],l=!0,c=c||!this.opts.staticGrid&&(f==="noResize"||f==="noMove"||f==="locked"));if(U.sanitizeMinMax(i),a){const f=a.w!==void 0&&a.w!==i.w;this.moveNode(i,a),f&&i.subGrid?i.subGrid.onResize(this.hasAnimationCSS()?i.w:void 0):this.resizeToContentCheck(f,i),delete i._orig}(a||l)&&this._writeAttr(r,i),c&&this.prepareDragDrop(i.el),Le.updateCB&&Le.updateCB(i)}),this}moveNode(e,n){const r=e._updating;r||this.engine.cleanNodes().beginUpdate(e),this.engine.moveNode(e,n),this._updateContainerHeight(),r||(this._triggerChangeEvent(),this.engine.endUpdate())}resizeToContent(e){var h,p;if(!e||(e.classList.remove("size-to-content-max"),!e.clientHeight))return;const n=e.gridstackNode;if(!n)return;const r=n.grid;if(!r||e.parentElement!==r.el)return;const i=r.getCellHeight(!0);if(!i)return;let s=n.h?n.h*i:e.clientHeight,o;if(n.resizeToContentParent&&(o=e.querySelector(n.resizeToContentParent)),o||(o=e.querySelector(Le.resizeToContentParent)),!o)return;const a=e.clientHeight-o.clientHeight,l=n.h?n.h*i-a:o.clientHeight;let c;if(n.subGrid){c=n.subGrid.getRow()*n.subGrid.getCellHeight(!0);const g=n.subGrid.el.getBoundingClientRect(),m=e.getBoundingClientRect();c+=g.top-m.top}else{if((p=(h=n.subGridOpts)==null?void 0:h.children)!=null&&p.length)return;{const g=o.firstElementChild;if(!g){console.error(`Error: GridStack.resizeToContent() widget id:${n.id} '${Le.resizeToContentParent}'.firstElementChild is null, make sure to have a div like container. Skipping sizing.`);return}c=g.getBoundingClientRect().height||l}}if(l===c)return;s+=c-l;let u=Math.ceil(s/i);const f=Number.isInteger(n.sizeToContent)?n.sizeToContent:0;f&&u>f&&(u=f,e.classList.add("size-to-content-max")),n.minH&&u<n.minH?u=n.minH:n.maxH&&u>n.maxH&&(u=n.maxH),u!==n.h&&(r._ignoreLayoutsNodeChange=!0,r.moveNode(n,{h:u}),delete r._ignoreLayoutsNodeChange)}resizeToContentCBCheck(e){Le.resizeToContentCB?Le.resizeToContentCB(e):this.resizeToContent(e)}rotate(e,n){return Le.getElements(e).forEach(r=>{const i=r.gridstackNode;if(!U.canBeRotated(i))return;const s={w:i.h,h:i.w,minH:i.minW,minW:i.minH,maxH:i.maxW,maxW:i.maxH};if(n){const a=n.left>0?Math.floor(n.left/this.cellWidth()):0,l=n.top>0?Math.floor(n.top/this.opts.cellHeight):0;s.x=i.x+a-(i.h-(l+1)),s.y=i.y+l-a}Object.keys(s).forEach(a=>{s[a]===void 0&&delete s[a]});const o=i._orig;this.update(r,s),i._orig=o}),this}margin(e){if(!(typeof e=="string"&&e.split(" ").length>1)){const r=U.parseHeight(e);if(this.opts.marginUnit===r.unit&&this.opts.margin===r.h)return}return this.opts.margin=e,this.opts.marginTop=this.opts.marginBottom=this.opts.marginLeft=this.opts.marginRight=void 0,this._initMargin(),this}getMargin(){return this.opts.margin}willItFit(e){return this.engine.willItFit(e)}_triggerChangeEvent(){if(this.engine.batchMode)return this;const e=this.engine.getDirtyNodes(!0);return e&&e.length&&(this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(e),this._triggerEvent("change",e)),this.engine.saveInitial(),this}_triggerAddEvent(){var e;if(this.engine.batchMode)return this;if((e=this.engine.addedNodes)!=null&&e.length){this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(this.engine.addedNodes),this.engine.addedNodes.forEach(r=>{delete r._dirty});const n=[...this.engine.addedNodes];this.engine.addedNodes=[],this._triggerEvent("added",n)}return this}_triggerRemoveEvent(){var e;if(this.engine.batchMode)return this;if((e=this.engine.removedNodes)!=null&&e.length){const n=[...this.engine.removedNodes];this.engine.removedNodes=[],this._triggerEvent("removed",n)}return this}_triggerEvent(e,n){const r=n?new CustomEvent(e,{bubbles:!1,detail:n}):new Event(e);let i=this;for(;i.parentGridNode;)i=i.parentGridNode.grid;return i.el.dispatchEvent(r),this}_updateContainerHeight(){if(!this.engine||this.engine.batchMode)return this;const e=this.parentGridNode;let n=this.getRow()+this._extraDragRow;const r=this.opts.cellHeight,i=this.opts.cellHeightUnit;if(!r)return this;if(!e&&!this.opts.minRow){const s=U.parseHeight(getComputedStyle(this.el).minHeight);if(s.h>0&&s.unit===i){const o=Math.floor(s.h/r);n<o&&(n=o)}}return this.el.setAttribute("gs-current-row",String(n)),this.el.style.removeProperty("min-height"),this.el.style.removeProperty("height"),n&&(this.el.style[e?"minHeight":"height"]=n*r+i),e&&U.shouldSizeToContent(e)&&e.grid.resizeToContentCBCheck(e.el),this}_prepareElement(e,n=!1,r){r=r||this._readAttr(e),e.gridstackNode=r,r.el=e,r.grid=this,r=this.engine.addNode(r,n),this._writeAttr(e,r),e.classList.add(qn.itemClass,this.opts.itemClass);const i=U.shouldSizeToContent(r);return i?e.classList.add("size-to-content"):e.classList.remove("size-to-content"),i&&this.resizeToContentCheck(!1,r),U.lazyLoad(r)||this.prepareDragDrop(r.el),this}_writePosAttr(e,n){if(!n._moving&&!n._resizing||this._placeholder===e){const r=this.opts.rtl?"right":"left";e.style.top=n.y?n.y===1?"var(--gs-cell-height)":`calc(${n.y} * var(--gs-cell-height))`:null,e.style[r]=n.x?n.x===1?"var(--gs-column-width)":`calc(${n.x} * var(--gs-column-width))`:null,e.style.width=n.w>1?`calc(${n.w} * var(--gs-column-width))`:null,e.style.height=n.h>1?`calc(${n.h} * var(--gs-cell-height))`:null}return e.setAttribute("gs-x",String(n.x)),e.setAttribute("gs-y",String(n.y)),n.w>1?e.setAttribute("gs-w",String(n.w)):e.removeAttribute("gs-w"),n.h>1?e.setAttribute("gs-h",String(n.h)):e.removeAttribute("gs-h"),this}_writeAttr(e,n){if(!n)return this;this._writePosAttr(e,n);const r={noResize:"gs-no-resize",noMove:"gs-no-move",locked:"gs-locked",id:"gs-id",sizeToContent:"gs-size-to-content"};for(const i in r)n[i]?e.setAttribute(r[i],String(n[i])):e.removeAttribute(r[i]);return this}_readAttr(e,n=!0){const r={};r.x=U.toNumber(e.getAttribute("gs-x")),r.y=U.toNumber(e.getAttribute("gs-y")),r.w=U.toNumber(e.getAttribute("gs-w")),r.h=U.toNumber(e.getAttribute("gs-h")),r.autoPosition=U.toBool(e.getAttribute("gs-auto-position")),r.noResize=U.toBool(e.getAttribute("gs-no-resize")),r.noMove=U.toBool(e.getAttribute("gs-no-move")),r.locked=U.toBool(e.getAttribute("gs-locked"));const i=e.getAttribute("gs-size-to-content");i&&(i==="true"||i==="false"?r.sizeToContent=U.toBool(i):r.sizeToContent=parseInt(i,10)),r.id=e.getAttribute("gs-id"),r.maxW=U.toNumber(e.getAttribute("gs-max-w")),r.minW=U.toNumber(e.getAttribute("gs-min-w")),r.maxH=U.toNumber(e.getAttribute("gs-max-h")),r.minH=U.toNumber(e.getAttribute("gs-min-h")),n&&(r.w===1&&e.removeAttribute("gs-w"),r.h===1&&e.removeAttribute("gs-h"),r.maxW&&e.removeAttribute("gs-max-w"),r.minW&&e.removeAttribute("gs-min-w"),r.maxH&&e.removeAttribute("gs-max-h"),r.minH&&e.removeAttribute("gs-min-h"));for(const s in r){if(!r.hasOwnProperty(s))return;!r[s]&&r[s]!==0&&s!=="sizeToContent"&&delete r[s]}return r}_setStaticClass(){const e=["grid-stack-static"];return this.opts.staticGrid?(this.el.classList.add(...e),this.el.setAttribute("gs-static","true")):(this.el.classList.remove(...e),this.el.removeAttribute("gs-static")),this}onResize(e=(n=>(n=this.el)==null?void 0:n.clientWidth)()){if(!e||this.prevWidth===e)return;this.prevWidth=e,this.batchUpdate();let r=!1;return this._autoColumn&&this.parentGridNode?this.opts.column!==this.parentGridNode.w&&(this.column(this.parentGridNode.w,this.opts.layout||"list"),r=!0):r=this.checkDynamicColumn(),this._isAutoCellHeight&&this.cellHeight(),this.engine.nodes.forEach(i=>{i.subGrid&&i.subGrid.onResize()}),this._skipInitialResize||this.resizeToContentCheck(r),delete this._skipInitialResize,this.batchUpdate(!1),this}resizeToContentCheck(e=!1,n=void 0){if(this.engine){if(e&&this.hasAnimationCSS())return setTimeout(()=>this.resizeToContentCheck(!1,n),this.animationDelay);if(n)U.shouldSizeToContent(n)&&this.resizeToContentCBCheck(n.el);else if(this.engine.nodes.some(r=>U.shouldSizeToContent(r))){const r=[...this.engine.nodes];this.batchUpdate(),r.forEach(i=>{U.shouldSizeToContent(i)&&this.resizeToContentCBCheck(i.el)}),this._ignoreLayoutsNodeChange=!0,this.batchUpdate(!1),this._ignoreLayoutsNodeChange=!1}this._gsEventHandler.resizecontent&&this._gsEventHandler.resizecontent(null,n?[n]:this.engine.nodes)}}_updateResizeEvent(e=!1){const n=!this.parentGridNode&&(this._isAutoCellHeight||this.opts.sizeToContent||this.opts.columnOpts||this.engine.nodes.find(r=>r.sizeToContent));return!e&&n&&!this.resizeObserver?(this._sizeThrottle=U.throttle(()=>this.onResize(),this.opts.cellHeightThrottle),this.resizeObserver=new ResizeObserver(()=>this._sizeThrottle()),this.resizeObserver.observe(this.el),this._skipInitialResize=!0):(e||!n)&&this.resizeObserver&&(this.resizeObserver.disconnect(),delete this.resizeObserver,delete this._sizeThrottle),this}static getElement(e=".grid-stack-item"){return U.getElement(e)}static getElements(e=".grid-stack-item"){return U.getElements(e)}static getGridElement(e){return Le.getElement(e)}static getGridElements(e){return U.getElements(e)}_initMargin(){let e,n=0,r=[];typeof this.opts.margin=="string"&&(r=this.opts.margin.split(" ")),r.length===2?(this.opts.marginTop=this.opts.marginBottom=r[0],this.opts.marginLeft=this.opts.marginRight=r[1]):r.length===4?(this.opts.marginTop=r[0],this.opts.marginRight=r[1],this.opts.marginBottom=r[2],this.opts.marginLeft=r[3]):(e=U.parseHeight(this.opts.margin),this.opts.marginUnit=e.unit,n=this.opts.margin=e.h),["marginTop","marginRight","marginBottom","marginLeft"].forEach(o=>{this.opts[o]===void 0?this.opts[o]=n:(e=U.parseHeight(this.opts[o]),this.opts[o]=e.h,delete this.opts.margin)}),this.opts.marginUnit=e.unit,this.opts.marginTop===this.opts.marginBottom&&this.opts.marginLeft===this.opts.marginRight&&this.opts.marginTop===this.opts.marginRight&&(this.opts.margin=this.opts.marginTop);const s=this.el.style;return s.setProperty("--gs-item-margin-top",`${this.opts.marginTop}${this.opts.marginUnit}`),s.setProperty("--gs-item-margin-bottom",`${this.opts.marginBottom}${this.opts.marginUnit}`),s.setProperty("--gs-item-margin-right",`${this.opts.marginRight}${this.opts.marginUnit}`),s.setProperty("--gs-item-margin-left",`${this.opts.marginLeft}${this.opts.marginUnit}`),this}static getDD(){return An}static setupDragIn(e,n,r,i=document){(n==null?void 0:n.pause)!==void 0&&(Ue.pauseDrag=n.pause),n={appendTo:"body",helper:"clone",...n||{}},(typeof e=="string"?U.getElements(e,i):e).forEach((o,a)=>{An.isDraggable(o)||An.dragIn(o,n),r!=null&&r[a]&&(o.gridstackNode=r[a])})}movable(e,n){return this.opts.staticGrid?this:(Le.getElements(e).forEach(r=>{const i=r.gridstackNode;i&&(n?delete i.noMove:i.noMove=!0,this.prepareDragDrop(i.el))}),this)}resizable(e,n){return this.opts.staticGrid?this:(Le.getElements(e).forEach(r=>{const i=r.gridstackNode;i&&(n?delete i.noResize:i.noResize=!0,this.prepareDragDrop(i.el))}),this)}disable(e=!0){if(!this.opts.staticGrid)return this.enableMove(!1,e),this.enableResize(!1,e),this._triggerEvent("disable"),this}enable(e=!0){if(!this.opts.staticGrid)return this.enableMove(!0,e),this.enableResize(!0,e),this._triggerEvent("enable"),this}enableMove(e,n=!0){return this.opts.staticGrid?this:(e?delete this.opts.disableDrag:this.opts.disableDrag=!0,this.engine.nodes.forEach(r=>{this.prepareDragDrop(r.el),r.subGrid&&n&&r.subGrid.enableMove(e,n)}),this)}enableResize(e,n=!0){return this.opts.staticGrid?this:(e?delete this.opts.disableResize:this.opts.disableResize=!0,this.engine.nodes.forEach(r=>{this.prepareDragDrop(r.el),r.subGrid&&n&&r.subGrid.enableResize(e,n)}),this)}cancelDrag(){var n;const e=(n=this._placeholder)==null?void 0:n.gridstackNode;e&&(e._isExternal?(e._isAboutToRemove=!0,this.engine.removeNode(e)):e._isAboutToRemove&&Le._itemRemoving(e.el,!1),this.engine.restoreInitial())}_removeDD(e){return An.draggable(e,"destroy").resizable(e,"destroy"),e.gridstackNode&&delete e.gridstackNode._initDD,delete e.ddElement,this}_setupAcceptWidget(){if(this.opts.staticGrid||!this.opts.acceptWidgets&&!this.opts.removable)return An.droppable(this.el,"destroy"),this;let e,n;const r=(i,s,o)=>{var h;o=o||s;const a=o.gridstackNode;if(!a)return;if(!((h=a.grid)!=null&&h.el)){o.style.transform=`scale(${1/this.dragTransform.xScale},${1/this.dragTransform.yScale})`;const p=o.getBoundingClientRect();o.style.left=p.x+(this.dragTransform.xScale-1)*(i.clientX-p.x)/this.dragTransform.xScale+"px",o.style.top=p.y+(this.dragTransform.yScale-1)*(i.clientY-p.y)/this.dragTransform.yScale+"px",o.style.transformOrigin="0px 0px"}let{top:l,left:c}=o.getBoundingClientRect();const u=this.el.getBoundingClientRect();c-=u.left,l-=u.top;const f={position:{top:l*this.dragTransform.xScale,left:c*this.dragTransform.yScale}};if(a._temporaryRemoved){if(a.x=Math.max(0,Math.round(c/n)),a.y=Math.max(0,Math.round(l/e)),delete a.autoPosition,this.engine.nodeBoundFix(a),!this.engine.willItFit(a)){if(a.autoPosition=!0,!this.engine.willItFit(a)){An.off(s,"drag");return}a._willFitPos&&(U.copyPos(a,a._willFitPos),delete a._willFitPos)}this._onStartMoving(o,i,f,a,n,e)}else this._dragOrResize(o,i,f,a,n,e)};return An.droppable(this.el,{accept:i=>{const s=i.gridstackNode||this._readAttr(i,!1);if((s==null?void 0:s.grid)===this)return!0;if(!this.opts.acceptWidgets)return!1;let o=!0;if(typeof this.opts.acceptWidgets=="function")o=this.opts.acceptWidgets(i);else{const a=this.opts.acceptWidgets===!0?".grid-stack-item":this.opts.acceptWidgets;o=i.matches(a)}if(o&&s&&this.opts.maxRow){const a={w:s.w,h:s.h,minW:s.minW,minH:s.minH};o=this.engine.willItFit(a)}return o}}).on(this.el,"dropover",(i,s,o)=>{let a=(o==null?void 0:o.gridstackNode)||s.gridstackNode;if((a==null?void 0:a.grid)===this&&!a._temporaryRemoved)return!1;if(a!=null&&a._sidebarOrig&&(a.w=a._sidebarOrig.w,a.h=a._sidebarOrig.h),a!=null&&a.grid&&a.grid!==this&&!a._temporaryRemoved&&a.grid._leave(s,o),o=o||s,n=this.cellWidth(),e=this.getCellHeight(!0),!a){const u=o.getAttribute("data-gs-widget")||o.getAttribute("gridstacknode");if(u){try{a=JSON.parse(u)}catch{console.error("Gridstack dropover: Bad JSON format: ",u)}o.removeAttribute("data-gs-widget"),o.removeAttribute("gridstacknode")}a||(a=this._readAttr(o)),a._sidebarOrig={w:a.w,h:a.h}}a.grid||(a.el||(a={...a}),a._isExternal=!0,o.gridstackNode=a);const l=a.w||Math.round(o.offsetWidth/n)||1,c=a.h||Math.round(o.offsetHeight/e)||1;return a.grid&&a.grid!==this?(s._gridstackNodeOrig||(s._gridstackNodeOrig=a),s.gridstackNode=a={...a,w:l,h:c,grid:this},delete a.x,delete a.y,this.engine.cleanupNode(a).nodeBoundFix(a),a._initDD=a._isExternal=a._temporaryRemoved=!0):(a.w=l,a.h=c,a._temporaryRemoved=!0),Le._itemRemoving(a.el,!1),An.on(s,"drag",r),r(i,s,o),!1}).on(this.el,"dropout",(i,s,o)=>{const a=(o==null?void 0:o.gridstackNode)||s.gridstackNode;return a&&(!a.grid||a.grid===this)&&(this._leave(s,o),this._isTemp&&this.removeAsSubGrid(a)),!1}).on(this.el,"drop",(i,s,o)=>{var h,p,g;const a=(o==null?void 0:o.gridstackNode)||s.gridstackNode;if((a==null?void 0:a.grid)===this&&!a._isExternal)return!1;const l=!!this.placeholder.parentElement,c=s!==o;this.placeholder.remove(),delete this.placeholder.gridstackNode,l&&this.opts.animate&&(this.setAnimation(!1),this.setAnimation(!0,!0));const u=s._gridstackNodeOrig;if(delete s._gridstackNodeOrig,l&&(u!=null&&u.grid)&&u.grid!==this){const m=u.grid;m.engine.removeNodeFromLayoutCache(u),m.engine.removedNodes.push(u),m._triggerRemoveEvent()._triggerChangeEvent(),m.parentGridNode&&!m.engine.nodes.length&&m.opts.subGridDynamic&&m.removeAsSubGrid()}if(!a||(l&&(this.engine.cleanupNode(a),a.grid=this),(h=a.grid)==null||delete h._isTemp,An.off(s,"drag"),o!==s?(o.remove(),s=o):s.remove(),this._removeDD(s),!l))return!1;const f=(g=(p=a.subGrid)==null?void 0:p.el)==null?void 0:g.gridstack;return U.copyPos(a,this._readAttr(this.placeholder)),U.removePositioningStyles(s),c&&(a.content||a.subGridOpts||Le.addRemoveCB)?(delete a.el,s=this.addWidget(a)):(this._prepareElement(s,!0,a),this.el.appendChild(s),this.resizeToContentCheck(!1,a),f&&(f.parentGridNode=a),this._updateContainerHeight()),this.engine.addedNodes.push(a),this._triggerAddEvent(),this._triggerChangeEvent(),this.engine.endUpdate(),this._gsEventHandler.dropped&&this._gsEventHandler.dropped({...i,type:"dropped"},u&&u.grid?u:void 0,a),!1}),this}static _itemRemoving(e,n){if(!e)return;const r=e?e.gridstackNode:void 0;!(r!=null&&r.grid)||e.classList.contains(r.grid.opts.removableOptions.decline)||(n?r._isAboutToRemove=!0:delete r._isAboutToRemove,n?e.classList.add("grid-stack-item-removing"):e.classList.remove("grid-stack-item-removing"))}_setupRemoveDrop(){if(typeof this.opts.removable!="string")return this;const e=document.querySelector(this.opts.removable);return e?(!this.opts.staticGrid&&!An.isDroppable(e)&&An.droppable(e,this.opts.removableOptions).on(e,"dropover",(n,r)=>Le._itemRemoving(r,!0)).on(e,"dropout",(n,r)=>Le._itemRemoving(r,!1)),this):this}prepareDragDrop(e,n=!1){const r=e==null?void 0:e.gridstackNode;if(!r)return;const i=r.noMove||this.opts.disableDrag,s=r.noResize||this.opts.disableResize,o=this.opts.staticGrid||i&&s;if((n||o)&&(r._initDD&&(this._removeDD(e),delete r._initDD),o))return e.classList.add("ui-draggable-disabled","ui-resizable-disabled"),this;if(!r._initDD){let a,l;const c=(h,p)=>{this.triggerEvent(h,h.target),a=this.cellWidth(),l=this.getCellHeight(!0),this._onStartMoving(e,h,p,r,a,l)},u=(h,p)=>{this._dragOrResize(e,h,p,r,a,l)},f=h=>{this.placeholder.remove(),delete this.placeholder.gridstackNode,delete r._moving,delete r._resizing,delete r._event,delete r._lastTried;const p=r.w!==r._orig.w,g=h.target;if(!(!g.gridstackNode||g.gridstackNode.grid!==this)){if(r.el=g,r._isAboutToRemove){const m=e.gridstackNode.grid;m._gsEventHandler[h.type]&&m._gsEventHandler[h.type](h,g),m.engine.nodes.push(r),m.removeWidget(e,!0,!0)}else U.removePositioningStyles(g),r._temporaryRemoved?(this._writePosAttr(g,r),this.engine.addNode(r)):this._writePosAttr(g,r),this.triggerEvent(h,g);this._extraDragRow=0,this._updateContainerHeight(),this._triggerChangeEvent(),this.engine.endUpdate(),h.type==="resizestop"&&(Number.isInteger(r.sizeToContent)&&(r.sizeToContent=r.h),this.resizeToContentCheck(p,r))}};An.draggable(e,{start:c,stop:f,drag:u,rtl:this.opts.rtl}).resizable(e,{start:c,stop:f,resize:u,rtl:this.opts.rtl}),r._initDD=!0}return An.draggable(e,i?"disable":"enable").resizable(e,s?"disable":"enable"),this}_onStartMoving(e,n,r,i,s,o){var a;if(this.engine.cleanNodes().beginUpdate(i),this._writePosAttr(this.placeholder,i),this.el.appendChild(this.placeholder),this.placeholder.gridstackNode=i,(a=i.grid)!=null&&a.el)this.dragTransform=U.getValuesFromTransformedElement(e);else if(this.placeholder&&this.placeholder.closest(".grid-stack")){const l=this.placeholder.closest(".grid-stack");this.dragTransform=U.getValuesFromTransformedElement(l)}else this.dragTransform={xScale:1,xOffset:0,yScale:1,yOffset:0};if(i.el=this.placeholder,i._lastUiPosition=r.position,i._prevYPix=r.position.top,i._moving=n.type==="dragstart",i._resizing=n.type==="resizestart",delete i._lastTried,n.type==="dropover"&&i._temporaryRemoved&&(this.engine.addNode(i),i._moving=!0),this.engine.cacheRects(s,o,this.opts.marginTop,this.opts.marginRight,this.opts.marginBottom,this.opts.marginLeft),n.type==="resizestart"){const l=this.getColumn()-i.x,c=(this.opts.maxRow||Number.MAX_SAFE_INTEGER)-i.y;An.resizable(e,"option","minWidth",s*Math.min(i.minW||1,l)).resizable(e,"option","minHeight",o*Math.min(i.minH||1,c)).resizable(e,"option","maxWidth",s*Math.min(i.maxW||Number.MAX_SAFE_INTEGER,l)).resizable(e,"option","maxWidthMoveLeft",s*Math.min(i.maxW||Number.MAX_SAFE_INTEGER,i.x+i.w)).resizable(e,"option","maxHeight",o*Math.min(i.maxH||Number.MAX_SAFE_INTEGER,c)).resizable(e,"option","maxHeightMoveUp",o*Math.min(i.maxH||Number.MAX_SAFE_INTEGER,i.y+i.h))}}_dragOrResize(e,n,r,i,s,o){var b;const a={...i._orig};let l,c=this.opts.marginLeft,u=this.opts.marginRight,f=this.opts.marginTop,h=this.opts.marginBottom;const p=Math.round(o*.1),g=Math.round(s*.1);if(c=Math.min(c,g),u=Math.min(u,g),f=Math.min(f,p),h=Math.min(h,p),n.type==="drag"){if(i._temporaryRemoved)return;i._prevYPix=r.position.top,this.opts.draggable.scroll!==!1&&((b=Ue.dragElement)==null||b.updateScrollPosition(this.el));const _=r.position.left+(r.position.left>i._lastUiPosition.left?-u:c),y=r.position.top+(r.position.top>i._lastUiPosition.top?-h:f);a.x=Math.round(_/s),a.y=Math.round(y/o);const R=this._extraDragRow;if(this.engine.collide(i,a)){const L=this.getRow();let P=Math.max(0,a.y+i.h-L);this.opts.maxRow&&L+P>this.opts.maxRow&&(P=Math.max(0,this.opts.maxRow-L)),this._extraDragRow=P}else this._extraDragRow=0;if(this._extraDragRow!==R&&this._updateContainerHeight(),i.x===a.x&&i.y===a.y)return}else if(n.type==="resize"){if(a.x<0||(U.updateScrollResize(n,e,o),a.w=Math.round((r.size.width-c)/s),a.h=Math.round((r.size.height-f)/o),i.w===a.w&&i.h===a.h)||i._lastTried&&i._lastTried.w===a.w&&i._lastTried.h===a.h)return;if(n.hasMovedX){const _=r.position.left+c;a.x=Math.round(_/s)}if(n.hasMovedY){const _=r.position.top+f;a.y=Math.round(_/o)}l=!0}i._event=n,i._lastTried=a;const m={x:r.position.left+c,y:r.position.top+f,w:(r.size?r.size.width:i.w*s)-c-u,h:(r.size?r.size.height:i.h*o)-f-h};if(this.engine.moveNodeCheck(i,{...a,cellWidth:s,cellHeight:o,rect:m,resizing:l})){i._lastUiPosition=r.position,this.engine.cacheRects(s,o,f,u,h,c),delete i._skipDown,l&&i.subGrid&&i.subGrid.onResize(),this._extraDragRow=0,this._updateContainerHeight();const _=n.target;i._sidebarOrig||this._writePosAttr(_,i),this.triggerEvent(n,_)}}triggerEvent(e,n){let r=this;for(;r.parentGridNode;)r=r.parentGridNode.grid;r._gsEventHandler[e.type]&&r._gsEventHandler[e.type](e,n)}_leave(e,n){n=n||e;const r=n.gridstackNode;if(!r||(n.style.transform=n.style.transformOrigin=null,An.off(e,"drag"),r._temporaryRemoved))return;r._temporaryRemoved=!0,this.engine.removeNode(r),r.el=r._isExternal&&n?n:e;const i=r._sidebarOrig;r._isExternal&&this.engine.cleanupNode(r),r._sidebarOrig=i,this.opts.removable===!0&&Le._itemRemoving(e,!0),e._gridstackNodeOrig?(e.gridstackNode=e._gridstackNodeOrig,delete e._gridstackNodeOrig):r._isExternal&&this.engine.restoreInitial()}}Le.renderCB=(t,e)=>{t&&(e!=null&&e.content)&&(t.textContent=e.content)};Le.resizeToContentParent=".grid-stack-item-content";Le.Utils=U;Le.Engine=Kr;Le.GDRev="12.6.0";function ud(t){return{...t,w:Math.max(t.w,t.minW??t.w),h:Math.max(t.h,t.minH??t.h)}}const kf="mndw:dashboard:grid-layout",XO=/^widget-(.+):([1-9]\d*)$/;function Nn(t){const e=XO.exec(t);if(e===null)return null;const n=Number(e[2]);return!Number.isSafeInteger(n)||n<1?null:{pluginName:e[1],counter:n}}function Ef(t){if(typeof t!="object"||t===null)return!1;const e=t;return typeof e.id=="string"&&Number.isInteger(e.x)&&e.x>=0&&Number.isInteger(e.y)&&e.y>=0&&Number.isInteger(e.w)&&e.w>0&&Number.isInteger(e.h)&&e.h>0}function Ip(t){return Ef(t)?{id:t.id,x:t.x,y:t.y,w:t.w,h:t.h}:null}function zp(){try{localStorage.removeItem(kf)}catch(t){console.error("[mndw] Failed to clear dashboard layout:",t)}}function JO(t,e){const n=Nn(t),r=Nn(e);return n===null||r===null?t.localeCompare(e):n.pluginName.localeCompare(r.pluginName)||n.counter-r.counter}function QO(t){return[...t].sort((e,n)=>e.y-n.y||e.x-n.x||JO(e.id,n.id)).map(e=>e.id)}function eM(t,e){const n=new Set(e.map(s=>s.id)),r=new Set,i=[];if(Array.isArray(t))for(const s of t)typeof s=="string"&&n.has(s)&&!r.has(s)&&(r.add(s),i.push(s));for(const s of QO(e))r.has(s)||(r.add(s),i.push(s));return i}function tM(t,e){const n=ud(e);return{x:0,y:t.reduce((i,s)=>Math.max(i,s.y+s.h),0),w:Math.min(n.w,12),h:n.h}}function nM(t,e,n){const r=new Set,i=[];for(const s of t){if(!Ef(s)||r.has(s.id))continue;const o=Nn(s.id);if(o===null)continue;const a=n==null?void 0:n(o.pluginName);if(n!==void 0&&(a==null?void 0:a.type)!=="widget")continue;if(a!==void 0&&(!a.runnable||a.status!=="loaded")){r.add(s.id),i.push({id:s.id,x:s.x,y:s.y,w:s.w,h:s.h});continue}const l=(a==null?void 0:a.size)??e(o.pluginName);if(l===void 0)continue;const c=Math.min(Math.max(s.w,l.minW??1),12),u=Math.max(s.h,l.minH??1);r.add(s.id),i.push({id:s.id,x:Math.min(s.x,12-c),y:s.y,w:c,h:u})}return i}function rM(t){const e=new Set,n=[];for(const r of t)!Ef(r)||e.has(r.id)||Nn(r.id)===null||(e.add(r.id),n.push({id:r.id,x:r.x,y:r.y,w:r.w,h:r.h}));return n}function iM(t){return typeof t=="object"&&t!==null&&!("version"in t)&&Array.isArray(t.tiles)}function sM(t){const e={tiles:t.tiles.map(({id:n,x:r,y:i,w:s,h:o})=>({id:n,x:r,y:i,w:s,h:o})),mobileOrder:[...t.mobileOrder]};try{return localStorage.setItem(kf,JSON.stringify(e)),!0}catch(n){return console.error("[mndw] Failed to save dashboard layout:",n),!1}}function oM(t,e){let n;try{n=localStorage.getItem(kf)}catch(o){return console.error("[mndw] Failed to load dashboard layout:",o),null}if(n===null)return null;let r;try{r=JSON.parse(n)}catch(o){return console.warn("[mndw] Failed to parse dashboard layout, discarding:",o),zp(),null}if(!iM(r))return console.warn("[mndw] Malformed dashboard layout, discarding"),zp(),null;const s=(e==null?void 0:e.listOutcome)==="failed"||(e==null?void 0:e.listOutcome)==="pending"?rM(r.tiles):nM(r.tiles,t,e===void 0?void 0:e.getPlugin);return{tiles:s,mobileOrder:eM(r.mobileOrder,s)}}var aM=N('<div class="mndw-grid-scroll mndw-scrollbar"><div class="grid-stack"></div></div>');function lM(t,e){Ze(e,!0);let n;const r=12,i="mndw-grid-resize-indicator",s=`.${i}`;function o(f){const h=f.gridstackNode;return h===void 0||!Number.isInteger(h.w)||!Number.isInteger(h.h)?null:{w:h.w,h:h.h}}function a(f){var h;(h=f.querySelector(s))==null||h.remove()}function l(f){const h=o(f);if(h===null){a(f);return}let p=f.querySelector(s);p===null&&(p=document.createElement("div"),p.className=i,p.setAttribute("aria-hidden","true"),f.appendChild(p)),p.textContent=`${h.w} × ${h.h}`}Gn(()=>{const f=Le.init({column:r,animate:!0,float:!1,cellHeight:60,margin:10,draggable:{handle:".mndw-grid-tile__title"},resizable:{handles:"se"}},n);f.on("removed",(p,g)=>{for(const m of g)typeof m.id=="string"&&e.onWidgetRemoved(m.id,Ip(m)??void 0)});const h=()=>{const p=f.save(!1,!1,(m,b)=>{b.x??(b.x=m.x),b.y??(b.y=m.y),b.w??(b.w=m.w),b.h??(b.h=m.h)}),g=Array.isArray(p)?p.map(Ip).filter(m=>m!==null):[];e.onLayoutChanged(g)};return f.on("added",h),f.on("change",h),f.on("resizestart",(p,g)=>{l(g)}),f.on("resize",(p,g)=>{l(g)}),f.on("resizestop",(p,g)=>{a(g);const m=g.gridstackNode;m!==void 0&&typeof m.id=="string"&&Number.isInteger(m.w)&&Number.isInteger(m.h)&&e.onWidgetResized(m.id,{w:m.w,h:m.h})}),e.onGridReady(f),()=>{f.off("removed"),f.off("added"),f.off("change"),f.off("resizestart"),f.off("resize"),f.off("resizestop"),n.querySelectorAll(s).forEach(p=>{p.remove()}),f.destroy(!1),e.onGridDestroyed()}});var c=aM(),u=v(c);Br(u,f=>n=f,()=>n),C(t,c),We()}var cM=N("<br/> <span> </span>",1),uM=N('<span class="mndw-floating-panel__description"> </span>'),dM=N('<mndw-button><span class="mndw-floating-panel__label"> <!></span> <!></mndw-button>',2),fM=N('<div class="mndw-floating-panel"><!></div>');function hM(t,e){Ze(e,!0);const n=yn().registry;let r=G(()=>{const u=V.locale;return n.getWidgets().map(f=>({widget:f,...zn(f.entry,f.catalog,u)})).sort((f,h)=>f.label.localeCompare(h.label)||f.widget.entry.name.localeCompare(h.widget.entry.name))});function i(u){e.onAddWidget(u),e.close(void 0)}function s(u,f,h){return[u,f,h].filter(p=>p!==void 0&&p!=="").join(" ")}var o=fM(),a=v(o);{var l=u=>{{let f=G(()=>M("dashboard.no-widgets")),h=G(()=>M("dashboard.empty-no-plugins"));Zi(u,{mode:"compact",get title(){return d(f)},get text(){return d(h)}})}},c=u=>{var f=_n(),h=tt(f);Mt(h,17,()=>d(r),p=>p.widget.entry.name,(p,g)=>{const m=G(()=>d(g).widget),b=G(()=>uc(d(m).entry.name)),_=G(()=>d(b)==="installing"?M("dashboard.preparing"):d(b)==="failed"?M("dashboard.unavailable"):"");var y=dM();T(y,"variant","secondary"),w(()=>T(y,"aria-label",s(d(g).label,d(g).description,d(_))));var R=v(y),L=v(R),P=S(L);{var A=z=>{var B=cM(),j=S(tt(B),2),q=v(j);w(()=>{Pe(j,1,`mndw-floating-panel__deps ${d(b)==="failed"?"mndw-floating-panel__deps--failed":""}`),E(q,d(_))}),C(z,B)};W(P,z=>{d(_)!==""&&z(A)})}var O=S(R,2);{var D=z=>{var B=uM(),j=v(B);w(()=>E(j,d(g).description)),C(z,B)};W(O,z=>{d(g).description&&z(D)})}w(()=>E(L,`${d(g).label??""} `)),de("click",y,()=>i(d(m).entry.name)),C(p,y)}),C(u,f)};W(a,u=>{d(r).length===0?u(l):u(c,-1)})}C(t,o),We()}bt(["click"]);function pM(t,e,n){let r=t.aborted;const i=new Set,s=c=>{i.has(c)||i.add(c)},o=c=>{i.delete(c)},a=()=>{if(!r){r=!0;for(const c of[...i])c()}};t.addEventListener("abort",a,{once:!0});const l=Object.assign(Object.create(null),{createTicker:e,createRefreshLoop(c){let u=!1,f=!1,h=c.intervalMs,p=null,g=0,m,b=r;const _=()=>{p!==null&&(clearInterval(p),p=null)},y=()=>{u&&(u=!1,g+=1,f=!1,_(),m==null||m.abort(),m=void 0),o(y)},R=A=>{if(!u||b||f)return;f=!0;const O=g,D=new AbortController;m=D;let z;try{z=c.load(D.signal)}catch(B){f=!1,m=void 0,D.abort(),u&&!b&&g===O&&c.onError(B,A);return}z.then(B=>{u&&!b&&g===O&&c.onSuccess(B)},B=>{u&&!b&&g===O&&c.onError(B,A)}).finally(()=>{g===O&&(f=!1,m===D&&(m=void 0))})},L=()=>{_(),p=setInterval(()=>R(!1),h)};return{start(A={}){u||b||r||(u=!0,g+=1,s(y),L(),A.immediate!==!1&&R(!0))},stop:y,setIntervalMs(A){h=A,u&&L()},dispose(){b=!0,y()}}}});return Object.freeze(l)}const Sf=new Map;function gM(t){return t.includes(":instance:")}function Tf(t){return Sf.get(t)}function mM(t){const e=Symbol();return Sf.set(t,e),e}function Hb(t){const e=[];for(let n=0;n<localStorage.length;n++){const r=localStorage.key(n);r!=null&&r.startsWith(t)&&e.push(r)}for(const n of e)localStorage.removeItem(n)}class Dp{constructor(e){X(this,"prefix");X(this,"instanceRevision");this.prefix=e,this.instanceRevision=gM(e)?mM(e):null}async get(e){return Promise.resolve(localStorage.getItem(this.prefix+e))}async set(e,n){return this.canWrite()&&localStorage.setItem(this.prefix+e,n),Promise.resolve()}async delete(e){return this.canWrite()&&localStorage.removeItem(this.prefix+e),Promise.resolve()}async keys(){const e=[];for(let n=0;n<localStorage.length;n++){const r=localStorage.key(n);r!=null&&r.startsWith(this.prefix)&&e.push(r.slice(this.prefix.length))}return Promise.resolve(e)}canWrite(){return this.instanceRevision===null||Tf(this.prefix)===this.instanceRevision}}function Go(t,e){const n=`${Ms}:${t}:instance:${e}:`;Hb(n)}function vM(t,e){return Tf(`${Ms}:${t}:instance:${e}:`)}function Hp(t,e,n){const r=`${Ms}:${t}:instance:${e}:`;Tf(r)===n&&(Hb(r),Sf.delete(r))}function bM(t,e){const n=Object.create(null);for(const r of e){const i=t[r];typeof i=="function"&&(n[r]=i.bind(t))}return Object.freeze(n)}function Bb(t){if(t===null||typeof t!="object"&&typeof t!="function"||Object.isFrozen(t))return t;for(const e of Object.values(t))Bb(e);return Object.freeze(t)}function _M(t){const e={list:t.switchports.list.map(l=>({...l})),layout:t.switchports.layout.map(l=>[...l]),hasPortStats:t.switchports.hasPortStats},n={ports:[...t.usb.ports]},r=[...t.features],i=[...t.components],s=new Set(r.map(l=>l.toLowerCase())),o=new Set(i.map(l=>l.toLowerCase())),a={...t,features:r,components:i,switchports:e,usb:n,hasFeature:l=>s.has(l.toLowerCase()),hasComponent:l=>o.has(l.toLowerCase())};return Bb(a)}const gt={dashboard:"/",login:"/login",packages:"/packages",packageServices:"/packages/services",settings:"/settings",settingsTab:{general:"/settings/general",diagnostics:"/settings/diagnostics",plugins:"/settings/plugins","self-update":"/settings/self-update"}},Bp=gt.settingsTab,wM=/^[a-z][a-z\d+.-]*:/i;function yM(t){if(t==="")return"";if(t.startsWith("/")||t.includes("\\")||t.includes("?")||t.includes("#")||wM.test(t))return;const e=t.endsWith("/")?t.slice(0,-1):t;if(e==="")return;const n=e.split("/");for(const r of n){if(r==="")return;let i;try{i=decodeURIComponent(r)}catch{return}if(i==="."||i===".."||i.includes("/")||i.includes("\\"))return}return e}function kM(t,e){try{if(typeof t!="object"||t===null)return;const n=t;switch(n.kind){case"dashboard":return gt.dashboard;case"packages":return gt.packages;case"settings":{const r=n.tab;return r===void 0?gt.settings:typeof r!="string"||!Object.hasOwn(Bp,r)?void 0:Bp[r]}case"plugin-page":{if(typeof n.plugin!="string")return;const r=e.pageTable.baseRouteOf(n.plugin);if(r===void 0)return;const i=n.path;if(i!==void 0&&typeof i!="string")return;const s=yM(i??"");return s===void 0?void 0:s===""?r:`${r}/${s}`}default:return}}catch{return}}function Up(t,e){try{const n=e.getRouter();if(n===void 0)return;const r=kM(t,n);return r===void 0?void 0:{router:n,path:r}}catch{return}}function EM(t){return Object.freeze({href:e=>{var n;return(n=Up(e,t))==null?void 0:n.path},navigate:e=>{try{if(t.isDisposed())return!1;const n=Up(e,t);return n===void 0?!1:(n.router.navigate(n.path),!0)}catch{return!1}}})}let SM=0;const TM=()=>{const t=globalThis.crypto;return(t==null?void 0:t.randomUUID)!==void 0?t.randomUUID():`event-context-${++SM}`};function xM(t){const{routes:e}=t.backend;if(Object.keys(e??{}).length===0)return up(t.name,void 0);const n={routes:e??{},approval:t.approval,enabled:t.enabled};return up(t.name,n)}function xf(t){const{entry:e,instanceId:n,deviceInfo:r,setTileTitle:i,pageRoute:s,catalogCell:o,services:a}=t,l=()=>a.locale.getLocale(),c=q=>a.locale.subscribeLocale(q),u=()=>a.palette.getTokens(),f=a.eventStream;if(e.type==="page"&&s===void 0)throw new Error(`Page plugin "${e.name}" requires a page route`);const h=_b(),p=new AbortController,g=Ja(()=>a.theme.getTheme(),q=>a.theme.subscribeTheme(q),h),m=Ja(u,q=>a.palette.subscribePalette(q),h),b=Ja(()=>a.telemetryGathering.get(),q=>a.telemetryGathering.subscribe(()=>q(a.telemetryGathering.get())),h).pipe(M_(q=>q!==null)),_={fetchProjected:(...q)=>a.telemetry.fetchProjected(...q),gathering$:b},y=Object.create(null);Object.defineProperties(y,{theme:{enumerable:!0,get:()=>a.theme.getTheme()},theme$:{enumerable:!0,value:g},palette:{enumerable:!0,get:()=>u()},palette$:{enumerable:!0,value:m}}),Object.freeze(y);const{service:R,dispose:L}=_f(e.name,n,a.overlayRuntime),P=TM(),A=f.createFacade(P,e.name,e.capabilities??[],h);let O=!1;const D=EM({getRouter:()=>a.navigation(),isDisposed:()=>O}),z=q=>{O||(O=!0,p.abort(),h.end(),f.disposeFacade(P),L(q))},B=e.type==="page"?(()=>{if(s===void 0)throw new Error(`Page plugin "${e.name}" requires a page route`);return{kind:"page",pageRoute:s}})():{kind:"widget",setTileTitle:i??(()=>{})},j={signal:p.signal,navigation:D,telemetry:_,events:A,storage:Object.freeze(Object.assign(Object.create(null),{instance:new Dp(`${Ms}:${e.name}:instance:${n}:`),shared:new Dp(`${Ms}:${e.name}:shared:`)})),device:Object.freeze(Object.assign(Object.create(null),{info:_M(r),rci:K2(bM(a.rci.driver,qv))})),i18n:IR(o,l,c,h),instanceId:n,timers:pM(p.signal,()=>a.tickerPool.create(h)),backend:xM(e),overlay:R,...B,appearance:y};return Object.setPrototypeOf(j,null),{context:Object.freeze(j),dispose:z}}function CM(t,e,n,r,i,s){V.hostInfo;const o=V.deviceInfo??Dd,a=e.get(n);if(!a)throw new Error(`No loaded plugin "${n}"`);return xf({entry:a.entry,instanceId:r,deviceInfo:o,setTileTitle:s,catalogCell:a.catalog,services:t})}function Ub(t){return t===null||typeof t!="object"&&typeof t!="function"?!1:typeof t.then=="function"}function PM(t,e,n,r,i){var a;const s=e.entry.name,o=(a=i==null?void 0:i.pluginStylesheets)==null?void 0:a.retain(s,e.entry.version);try{const l=e.module.createInstance(t,n);return Ub(l)?Promise.resolve(l).then(c=>({pluginName:s,instanceId:n.instanceId,instance:c,stylesheetLease:o,disposeOverlayService:r})).catch(c=>(console.error(`[mndw] Plugin "${s}" createInstance failed:`,c),o==null||o.release(),r("plugin-unmount"),i!=null&&i.errorText&&(t.textContent=i.errorText),null)):{pluginName:s,instanceId:n.instanceId,instance:l,stylesheetLease:o,disposeOverlayService:r}}catch(l){return console.error(`[mndw] Plugin "${s}" createInstance failed:`,l),o==null||o.release(),r("plugin-unmount"),i!=null&&i.errorText&&(t.textContent=i.errorText),null}}function jp(t,e,n,r){var s,o,a;if(r)try{(s=t.disposeOverlayService)==null||s.call(t,(n==null?void 0:n.closeReason)??"plugin-unmount")}catch(l){console.error(`[mndw] Plugin "${t.pluginName}" overlay teardown failed:`,l)}let i;try{i=t.instance.unmount()}catch(l){console.error(`[mndw] Plugin "${t.pluginName}" unmount failed:`,l),(o=t.stylesheetLease)==null||o.release(),i=void 0}Ub(i)?Promise.resolve(i).catch(l=>{console.error(`[mndw] Plugin "${t.pluginName}" unmount failed:`,l)}).finally(()=>{var l;return(l=t.stylesheetLease)==null?void 0:l.release()}):(a=t.stylesheetLease)==null||a.release(),(n==null?void 0:n.clearStorage)!==!1&&Go(t.pluginName,t.instanceId),e.innerHTML=""}function jb(t,e,n,r){let i=null,s=!1,o=!1,a,l=!1;const c=h=>{l||(l=!0,n.dispose(h))},u=PM(t,e,n.context,c,r);let f;return u instanceof Promise?f=u.then(h=>(s=!0,i=h,o&&(h!==null?jp(h,t,a,!1):((a==null?void 0:a.clearStorage)===!0&&Go(e.entry.name,n.context.instanceId),t.innerHTML=""),i=null),h!==null)):(s=!0,i=u,f=Promise.resolve(u!==null)),{getMounted:()=>i,whenReady:()=>f,dispose(h){if(!o){if(o=!0,a=h,i!==null){jp(i,t,h,!0),i=null;return}if(!s){try{c((h==null?void 0:h.closeReason)??"plugin-unmount")}catch(p){console.error(`[mndw] Plugin "${e.entry.name}" context teardown failed:`,p)}t.innerHTML="";return}(h==null?void 0:h.clearStorage)===!0&&Go(e.entry.name,n.context.instanceId)}}}}function $b(t,e,n,r){return jb(t,e,n,r)}const er=new Map;function dd(){return{getMounted:()=>null,whenReady:()=>Promise.resolve(!1),dispose:()=>{}}}function $p(t,e,n){t.textContent="";const r=document.createElement("div");r.className=`mndw-grid-tile__notice mndw-grid-tile__notice--${e}`,r.setAttribute("role",e==="installing"?"status":"alert"),r.textContent=n(e==="installing"?"dashboard.preparing-dependencies":"dashboard.dependency-install-failed"),t.appendChild(r)}function Cf(t,e,n,r){var h;const i=mn(t.pluginName),s=(i==null?void 0:i.status)==="loading",o=i===void 0?t.pluginName:zn(i,i.catalog,V.locale).label,a=t.body.querySelector(".mndw-grid-tile__notice--plugin-load-failed");if((a==null?void 0:a.getAttribute("aria-busy"))===String(s)&&((h=a.querySelector("h3"))==null?void 0:h.textContent)===r("dashboard.plugin-load-failed",{label:o}))return;const l=document.createElement("section");l.className="mndw-grid-tile__notice mndw-grid-tile__notice--plugin-load-failed",l.setAttribute("role","alert"),l.setAttribute("aria-busy",String(s));const c=document.createElement("h3");c.textContent=r("dashboard.plugin-load-failed",{label:o});const u=document.createElement("button");u.type="button",u.className="mndw-grid-tile__retry",u.textContent=r("dashboard.retry-plugin-load"),u.disabled=s,u.setAttribute("aria-busy",String(s)),u.onclick=()=>{u.disabled||(u.disabled=!0,u.setAttribute("aria-busy","true"),l.setAttribute("aria-busy","true"),n())};const f=document.createElement("button");f.type="button",f.className="mndw-grid-tile__remove-failed",f.textContent=r("dashboard.remove-failed-plugin"),f.onclick=()=>e(t.id),l.append(c,u,f),t.body.replaceChildren(l),t.retrying=s}async function Fb(t){if(!t.retrying){t.retrying=!0;try{await lA(t.pluginName)}finally{t.retrying=!1}}}function RM(t,e,n){const r=document.createElement("div");r.className="mndw-grid-tile",r.dataset.widgetId="";const i=document.createElement("div");i.className="mndw-grid-tile__title",i.textContent=t;const s=document.createElement("button");s.type="button",s.className="mndw-grid-tile__close";const o=document.createElement("mndw-icon");o.setAttribute("name","x"),s.append(o),s.setAttribute("aria-label",n("dashboard.remove-widget",{label:t})),s.onclick=p=>{p.stopPropagation(),e()};const a=document.createElement("div");a.className="mndw-grid-tile__body";let l=t,c=t;const u=p=>{const g=c===l;l=p,i.setAttribute("data-manifest-label",p),s.setAttribute("aria-label",n("dashboard.remove-widget",{label:p})),g&&(c=p,i.textContent=p)};i.setAttribute("data-manifest-label",l);const f=p=>{const g=l,m=p||g;c=m,i.textContent=m,s.setAttribute("aria-label",n("dashboard.remove-widget",{label:g}))},h=()=>c;return r.append(i,s,a),{frame:r,body:a,setTileTitle:f,getTileTitle:h,setManifestLabel:u}}function Gb(t,e,n){t.catalogUnsubscribe(),t.setManifestLabel(zn(e.entry,n,V.locale).label),t.catalogUnsubscribe=(n==null?void 0:n.subscribe(()=>{t.setManifestLabel(zn(e.entry,n,V.locale).label)}))??(()=>{})}function pc(t,e,n,r){const i=uc(t.pluginName);if(t.pluginLoadPlaceholder=!1,t.retrying=!1,i==="installing"){$p(t.body,"installing",n.locale.hostT),t.handle=dd(),t.pending=!0;return}if(i==="failed"){$p(t.body,"failed",n.locale.hostT),t.handle=dd(),t.pending=!1;return}t.body.textContent="";const s=$b(t.body,e,CM(n,r,t.pluginName,t.instanceId,void 0,t.setTileTitle),{errorText:n.locale.hostT("dashboard.widget-error"),pluginStylesheets:t.pluginStylesheets});t.handle=s,t.pending=!1,s.whenReady().then(o=>{o||er.get(t.id)!==t||t.handle!==s||Cf(t,t.onRemoveRequest,()=>{er.get(t.id)!==t||t.handle!==s||(s.dispose(),pc(t,e,n,r))},n.locale.hostT)})}function gc(t,e,n,r,i,s){const o=`widget-${r}`,a=er.get(o);if(a!==void 0)return a;const l=e.get(n),c=(l==null?void 0:l.entry.type)==="widget"?l:void 0,u=mn(n);if(c===void 0&&!((u==null?void 0:u.runnable)===!0&&u.type==="widget"&&(u.status==="failed"||u.status==="loading")))return null;const f=c===void 0?u===void 0?n:zn(u,u.catalog,V.locale).label:zn(c.entry,c.catalog,V.locale).label,{frame:h,body:p,setTileTitle:g,getTileTitle:m,setManifestLabel:b}=RM(f,()=>i(o),t.locale.hostT);h.dataset.widgetId=o,p.dataset.theme=t.theme.getTheme();const _=t.theme.subscribeTheme(R=>{p.dataset.theme=R}),y={id:o,pluginName:n,instanceId:r,frame:h,body:p,themeUnsubscribe:_,catalogUnsubscribe:()=>{},handle:dd(),setTileTitle:g,getTileTitle:m,setManifestLabel:b,pending:!1,pluginLoadPlaceholder:c===void 0,retrying:(u==null?void 0:u.status)==="loading",onRemoveRequest:i,hostT:t.locale.hostT,pluginStylesheets:s};return er.set(o,y),c!==void 0&&Gb(y,c,c.catalog),y.pluginLoadPlaceholder?Cf(y,i,()=>{Fb(y)},y.hostT):c!==void 0&&pc(y,c,t,e),y}function AM(t,e,n,r){if(er.get(t.id)!==t||!t.pluginLoadPlaceholder)return;const i=mn(t.pluginName);if((i==null?void 0:i.status)==="loaded"){const s=n.get(t.pluginName);(s==null?void 0:s.entry.type)==="widget"&&pc(t,s,r,n);return}((i==null?void 0:i.status)==="failed"||(i==null?void 0:i.status)==="loading")&&Cf(t,e,()=>{Fb(t)},r.locale.hostT)}function Vb(t,e){for(const n of er.values())n.pluginLoadPlaceholder&&AM(n,n.onRemoveRequest,e,t)}function Nl(t){return er.get(t)}function Zb(t,e){for(const n of er.values()){if(!n.pending)continue;const r=e.get(n.pluginName);if((r==null?void 0:r.entry.type)!=="widget"){n.pending=!1;continue}pc(n,r,t,e)}}function os(t,e={}){const n=er.get(t);n!==void 0&&(er.delete(t),n.themeUnsubscribe(),n.catalogUnsubscribe(),n.frame.remove(),n.handle.dispose({clearStorage:e.clearStorage??!0,closeReason:"plugin-unmount"}))}async function OM(t,e,n,r,i,s){const o=[...er.values()].filter(f=>f.pluginName===n&&!f.pending);if(o.length===0)return!0;for(const f of o)f.handle.dispose({clearStorage:!1,closeReason:"host-navigation"});const a=f=>o.map(h=>{Gb(h,f,f.catalog),h.setTileTitle(""),V.hostInfo;const p=V.deviceInfo??Dd;return h.handle=$b(h.body,f,xf({entry:f.entry,instanceId:h.instanceId,deviceInfo:p,setTileTitle:h.setTileTitle,catalogCell:f.catalog,services:t}),{errorText:t.locale.hostT("dashboard.widget-error"),pluginStylesheets:s??h.pluginStylesheets}),h.handle}),l=a(r);if((await Promise.all(l.map(f=>f.whenReady()))).every(Boolean))return!0;for(const f of l)f.dispose({clearStorage:!1,closeReason:"host-navigation"});const u=a(i);return await Promise.all(u.map(f=>f.whenReady())),!1}function Wb(t="plugin-unmount"){for(const[e,n]of er)try{n.handle.dispose({clearStorage:!1,closeReason:t})}catch(r){console.error(`[mndw] Failed to unmount tile ${e}:`,r)}finally{n.themeUnsubscribe(),n.catalogUnsubscribe()}er.clear()}const MM=Object.freeze(Object.defineProperty({__proto__:null,destroyAllTiles:Wb,ensureTileController:gc,getTileController:Nl,hydratePendingTiles:Zb,refreshPluginLoadPlaceholders:Vb,remountWidgetTiles:OM,removeTileController:os},Symbol.toStringTag,{value:"Module"}));var NM=N('<div class="mndw-mobile-tile"></div>'),LM=N('<div class="mndw-mobile-dashboard mndw-scrollbar"></div>');function IM(t,e){Ze(e,!0);const n=yn(),r=n.registry,i={locale:n.locale,palette:n.palette,telemetry:n.telemetry,telemetryGathering:n.telemetryGathering,eventStream:n.eventStream,rci:n.rci,theme:n.theme,tickerPool:n.tickerPool,overlayRuntime:n.overlayRuntime,navigation:n.router.navigation};function s(a,l){const c=Nn(l);if(c===null){a.remove();return}const u=gc(i,r,c.pluginName,`${c.pluginName}:${c.counter}`,e.onRemoveRequest,n.pluginStylesheets);if(u===null){a.remove();return}a.appendChild(u.frame)}var o=LM();Mt(o,20,()=>e.order,a=>a,(a,l)=>{var c=NM();Zs(c,(u,f)=>s==null?void 0:s(u,f),()=>l),C(a,c)}),C(t,o),We()}var zM=N('<li><span class="mndw-order-card__handle" aria-hidden="true"><mndw-icon></mndw-icon></span> <span class="mndw-order-card__label"> </span> <span class="mndw-order-card__moves"><mndw-button><mndw-icon></mndw-icon></mndw-button> <mndw-button><mndw-icon></mndw-icon></mndw-button></span></li>',2),DM=N('<div class="mndw-order-overlay"><ul class="mndw-order-overlay__list"></ul> <div class="mndw-order-overlay__actions"><mndw-button> </mndw-button></div></div>',2);function HM(t,e){Ze(e,!0);let n=te(pt(Cr(()=>e.cards.map(m=>({...m}))))),r=te(null),i=pt([]);function s(){e.onCommit(d(n).map(m=>m.id)),e.close(void 0)}function o(m,b){const _=m+b;if(_<0||_>=d(n).length)return;const y=[...d(n)],[R]=y.splice(m,1);R!==void 0&&(y.splice(_,0,R),k(n,y,!0))}function a(m,b){var _,y;k(r,b,!0),(y=(_=m.currentTarget).setPointerCapture)==null||y.call(_,m.pointerId)}function l(m){var _;const b=d(r);if(b!==null)for(let y=0;y<d(n).length;y+=1){if(y===b)continue;const R=(_=i[y])==null?void 0:_.getBoundingClientRect();if(R!==void 0&&m.clientY>=R.top&&m.clientY<=R.bottom){o(b,y-b),k(r,y,!0);return}}}function c(){k(r,null)}var u=DM(),f=v(u);Mt(f,23,()=>d(n),m=>m.id,(m,b,_)=>{var y=zM();let R;var L=v(y),P=v(L);T(P,"name","menu");var A=S(L,2),O=v(A),D=S(A,2),z=v(D);T(z,"variant","ghost"),w(()=>T(z,"disabled",d(_)===0)),w(()=>T(z,"aria-label",M("dashboard.move-up",{label:d(b).label})));var B=v(z);T(B,"name","arrow-up");var j=S(z,2);T(j,"variant","ghost"),w(()=>T(j,"disabled",d(_)===d(n).length-1)),w(()=>T(j,"aria-label",M("dashboard.move-down",{label:d(b).label})));var q=v(j);T(q,"name","arrow-down"),Br(y,(ie,ve)=>i[ve]=ie,ie=>i==null?void 0:i[ie],()=>[d(_)]),w(()=>{R=Pe(y,1,"mndw-order-card",null,R,{"mndw-order-card--dragging":d(r)===d(_)}),E(O,d(b).label)}),de("pointerdown",L,ie=>a(ie,d(_))),de("pointermove",L,l),de("pointerup",L,c),de("click",z,()=>o(d(_),-1)),de("click",j,()=>o(d(_),1)),C(m,y)});var h=S(f,2),p=v(h);T(p,"variant","primary");var g=v(p);w(m=>E(g,m),[()=>M("common.save")]),de("click",p,s),C(t,u),We()}bt(["pointerdown","pointermove","pointerup","click"]);const Vo=new Map;function qb(t){return`${Ms}:${t}:counter`}function Kb(t){return Number.isSafeInteger(t)&&t>=0}function BM(t){try{const e=localStorage.getItem(qb(t));if(e===null||e.trim()==="")return 0;const n=Number(e);return Kb(n)?(Vo.set(t,Math.max(Vo.get(t)??0,n)),n):0}catch(e){return console.error(`[mndw] Failed to read widget counter for "${t}":`,e),0}}function Yb(t){return Math.max(BM(t),Vo.get(t)??0)}function Xb(t,e){try{localStorage.setItem(qb(t),String(e))}catch(n){console.error(`[mndw] Failed to write widget counter for "${t}":`,n)}}function Jb(t){const e=Yb(t);if(e===Number.MAX_SAFE_INTEGER)throw new RangeError(`Widget instance counter exhausted for "${t}"`);const n=e+1;return Vo.set(t,n),Xb(t,n),`${t}:${n}`}function UM(t,e){if(!Kb(e)){console.error(`[mndw] Ignoring invalid restored widget counter for "${t}":`,e);return}e>Yb(t)&&(Vo.set(t,e),Xb(t,e))}function jM(t){return(t==null?void 0:t.entry.type)==="widget"}function du(t,e,n,r,i,s,o){const a=n.get(i),l=jM(a)?a:void 0,c=mn(i),u=(c==null?void 0:c.runnable)===!0&&c.type==="widget"&&(c.status==="failed"||c.status==="loading");if(l===void 0&&!u)return null;const f=(o==null?void 0:o.instanceId)??Jb(i),h=gc(t,n,i,f,s,e);if(h===null)return null;const p=l!==void 0?ud(l.entry.size):o===void 0?ud((c==null?void 0:c.size)??{w:4,h:3}):{w:o.w,h:o.h},g=r.addWidget({id:h.id,x:o==null?void 0:o.x,y:o==null?void 0:o.y,w:(o==null?void 0:o.w)??p.w,h:(o==null?void 0:o.h)??p.h,...l===void 0?{}:{minW:p.minW,minH:p.minH}}),m=g.querySelector(".grid-stack-item-content");return m===null?(r.removeWidget(g,!0),null):(m.appendChild(h.frame),r.prepareDragDrop(g,!0),h.id)}function $M(t,e){var i;const n=Nl(t),r=(i=n==null?void 0:n.handle.getMounted())==null?void 0:i.instance;if((r==null?void 0:r.onResize)!==void 0)try{r.onResize(e)}catch(s){console.error(`[mndw] Widget "${n==null?void 0:n.pluginName}" onResize failed:`,s)}}function ri(t,e,n){return t.open({kind:"modal",title:n.title,showCloseButton:n.showCloseButton??!0,closeOnEscape:n.closeOnEscape??!0,closeOnOutsideClick:n.closeOnOutsideClick??!1,mount(r,i){let s,o=()=>{};const a=new Promise(c=>{o=c}),l={...n.props,close(c){i.close(c)}};i.setCleanup(async()=>{await a,s&&await Rd(s)});try{s=Vl(e,{target:r,props:l,...n.context===void 0?{}:{context:n.context}})}finally{o()}}})}var FM=N("<mndw-button> </mndw-button>",2),GM=N("<mndw-button><mndw-icon></mndw-icon> </mndw-button> <!>",3),VM=N('<div class="mndw-dashboard__grid-wrapper"><!></div>'),ZM=N('<div class="mndw-dashboard-page"><div class="mndw-dashboard__toolbar"><!></div> <!> <!></div>');function fu(t,e){Ze(e,!0);const n=500,r="dashboard-layout-save",i="dashboard-widget-removal",s=8e3,o=yn(),a=CA(o),l=o.registry,c={locale:o.locale,palette:o.palette,telemetry:o.telemetry,telemetryGathering:o.telemetryGathering,eventStream:o.eventStream,rci:o.rci,theme:o.theme,tickerPool:o.tickerPool,overlayRuntime:o.overlayRuntime,navigation:o.router.navigation};function u(F){const ne=l.get(F);return(ne==null?void 0:ne.entry.type)==="widget"?ne.entry.size:void 0}const f=fa();let h,p=te(null),g=te(!1),m=null,b=null,_=te(pt(f.matches)),y=te(pt([])),R=te(pt([])),L=G(()=>d(y).filter(F=>q(F.id))),P=G(()=>{const F=new Set(d(L).map(ne=>ne.id));return d(R).filter(ne=>F.has(ne))}),A=!1,O,D,z,B=te(null),j=null;{const F=oM(u,{listOutcome:tr(),getPlugin:mn});if(F!==null){k(y,F.tiles,!0),k(R,F.mobileOrder,!0);const ne=new Map;for(const re of F.tiles){const Q=Nn(re.id);Q!==null&&ne.set(Q.pluginName,Math.max(ne.get(Q.pluginName)??0,Q.counter))}for(const[re,Q]of ne)UM(re,Q)}}function q(F){var Q;const ne=Nn(F);if(ne===null)return!1;const re=mn(ne.pluginName);return re!==void 0?re.runnable&&re.type==="widget"&&re.status!=="not-runnable":((Q=l.get(ne.pluginName))==null?void 0:Q.entry.type)==="widget"}function ie(F){const ne=Nn(F.id);if(ne===null)return!1;const re=mn(ne.pluginName);return re!==void 0&&re.type==="widget"&&!re.runnable}function ve(F){const ne=new Set(F.map(Q=>Q.id)),re=d(y).filter(Q=>ie(Q)&&!ne.has(Q.id));return[...F,...re]}function pe(F){const ne=new Set(d(P));let re=0;const Q=d(R).map(Fe=>{if(!ne.has(Fe))return Fe;const nt=F[re];return re+=1,nt??Fe});for(const Fe of F.slice(re))Q.includes(Fe)||Q.push(Fe);return Q}function ee(F={tiles:ya(d(y)),mobileOrder:ya(d(R))}){if(tr()!=="ok"){clearTimeout(O),j=null;return}clearTimeout(O),j=null,sM(F)?Xe.dismissKey(r):Xe.show({key:r,message:M("dashboard.layout-save-failed"),variant:"warning"})}function be(){tr()==="ok"&&(clearTimeout(O),j={tiles:ya(d(y)),mobileOrder:ya(d(R))},O=setTimeout(()=>{j!==null&&ee(j)},n))}function Ee(){const F=d(B);F!==null&&(k(B,null),Go(F.pluginName,F.instanceId),F.mountSettlement!==null&&F.mountSettlement.then(()=>Hp(F.pluginName,F.instanceId,F.storageRevision),()=>Hp(F.pluginName,F.instanceId,F.storageRevision)))}function Me(){const F=d(B);F!==null&&(k(B,null),k(y,[...d(y)],!0),d(y).splice(Math.min(F.tileIndex,d(y).length),0,F.tile),k(R,[...d(R)],!0),d(R).splice(Math.min(F.mobileIndex,d(R).length),0,F.tile.id),!d(_)&&d(p)!==null&&Je(),ee(),Xe.dismiss(F.toastId))}function $e(F,ne){var Wn;if(A||tr()!=="ok")return;const re=Nn(F),Q=d(y).findIndex(fr=>fr.id===F),Fe=ne??d(y)[Q]??{id:F,x:0,y:0,w:1,h:1};if(re===null||Q===-1){os(F,{clearStorage:!0});return}Ee();const nt=Nl(F),Ot=((Wn=nt==null?void 0:nt.handle)==null?void 0:Wn.whenReady())??null,$=`${re.pluginName}:${re.counter}`,le=l.get(re.pluginName),Ie=(nt==null?void 0:nt.getTileTitle())||(le===void 0?void 0:zn(le.entry,le.catalog,V.locale).label)||re.pluginName,at=d(R).indexOf(F);os(F,{clearStorage:!1}),k(y,d(y).filter(fr=>fr.id!==F),!0),k(R,d(R).filter(fr=>fr!==F),!0),ee();const Zn=Xe.info(M("dashboard.widget-removed",{label:Ie}),{key:i,duration:s,action:{label:M("common.undo"),onAction:Me}});k(B,{tile:Fe,tileIndex:Q,mobileIndex:at===-1?d(R).length:at,pluginName:re.pluginName,instanceId:$,storageRevision:vM(re.pluginName,$),mountSettlement:Ot,toastId:Zn},!0)}function ge(F){if(tr()!=="ok")return;const ne=d(p);if(!d(_)&&ne!==null){const re=ne.getGridItems().find(Q=>{var Fe;return((Fe=Q.gridstackNode)==null?void 0:Fe.id)===F});if(re!==void 0){ne.removeWidget(re,!0);return}}$e(F)}function ze(F){k(p,F,!0),A=!0;try{for(const ne of d(L)){const re=Nn(ne.id);re!==null&&du(c,o.pluginStylesheets,l,F,re.pluginName,ge,{x:ne.x,y:ne.y,w:ne.w,h:ne.h,instanceId:`${re.pluginName}:${re.counter}`})}}finally{A=!1}}function Je(){var re;if(d(_)||d(p)===null)return;const F=new Map(d(y).filter(Q=>q(Q.id)).map(Q=>[Q.id,Q])),ne=[];A=!0;try{for(const Q of d(p).getGridItems()){const Fe=(re=Q.gridstackNode)==null?void 0:re.id;if(typeof Fe!="string"){d(p).removeWidget(Q,!0,!1);continue}const nt=F.get(Fe);if(nt===void 0){d(p).removeWidget(Q,!0,!1);const Ot=Nn(Fe),$=Ot===null?void 0:mn(Ot.pluginName),le=($==null?void 0:$.type)==="widget"&&!$.runnable;os(Fe,{clearStorage:!le});continue}ne.push(Fe),d(p).update(Q,{x:nt.x,y:nt.y,w:nt.w,h:nt.h})}for(const Q of F.values()){if(ne.includes(Q.id))continue;const Fe=Nn(Q.id);Fe!==null&&du(c,o.pluginStylesheets,l,d(p),Fe.pluginName,ge,{x:Q.x,y:Q.y,w:Q.w,h:Q.h,instanceId:`${Fe.pluginName}:${Fe.counter}`})}}finally{A=!1}}function ae(){k(p,null)}function Se(F){A||tr()!=="ok"||(k(y,ve(F),!0),be())}function Te(F,ne){$M(F,ne)}function I(F){if(tr()!=="ok")return null;const ne=u(F);if(ne===void 0)return null;const re=Jb(F),Q=gc(c,l,F,re,ge,o.pluginStylesheets);return Q===null?null:(k(y,[...d(y),{id:Q.id,...tM(d(y),ne)}],!0),k(R,[...d(R),Q.id],!0),ee(),Q.id)}function K(F){if(tr()!=="ok")return null;if(d(_))return I(F);const ne=d(p);if(ne===null)return null;const re=du(c,o.pluginStylesheets,l,ne,F,ge);return re!==null?(k(R,[...d(R),re],!0),ee(),re):null}async function we(F){await Co();const ne=[...(h==null?void 0:h.querySelectorAll(".mndw-grid-tile"))??[]].find(Q=>Q.dataset.widgetId===F);if(ne===void 0)return;const re=window.matchMedia("(prefers-reduced-motion: reduce)").matches;typeof ne.scrollIntoView=="function"&&ne.scrollIntoView({behavior:re?"auto":"smooth",block:"center"}),z==null||z.classList.remove("mndw-grid-tile--newly-added"),D!==void 0&&clearTimeout(D),z=ne,ne.classList.add("mndw-grid-tile--newly-added"),D=setTimeout(()=>{ne.classList.remove("mndw-grid-tile--newly-added"),z===ne&&(z=void 0),D=void 0},1600)}function De(){if(m!==null)return;const F=document.activeElement;let ne=null;const re=ri(o.hostOverlay,hM,{title:M("dashboard.add-widget"),props:{onAddWidget:Q=>(ne=K(Q),ne)},closeOnOutsideClick:!0,context:a});m=re,re.closed.then(async()=>{if(m===re&&(m=null),ne!==null){if(F instanceof HTMLElement&&!F.isConnected){const Q=(h==null?void 0:h.querySelector(".mndw-dashboard__toolbar mndw-button"))??(h==null?void 0:h.querySelector(".mndw-grid-tile__close"));Q==null||Q.focus({preventScroll:!0})}await we(ne)}})}function ke(){if(b!==null)return;k(g,!0);const F=ri(o.hostOverlay,HM,{title:M("dashboard.arrange-widgets"),props:{cards:d(se),onCommit:he},closeOnOutsideClick:!0});b=F,F.closed.then(()=>{b===F&&(b=null,k(g,!1))})}const Y=F=>{k(_,F.matches,!0),F.matches||(b==null||b.close(),b=null,k(g,!1))},se=G(()=>d(g)?d(P).flatMap(F=>{var nt;const ne=Nn(F);if(ne===null)return[];const re=l.get(ne.pluginName),Q=re===void 0?ne.pluginName:zn(re.entry,re.catalog,V.locale).label,Fe=((nt=Nl(F))==null?void 0:nt.getTileTitle())??"";return[{id:F,label:Fe||Q}]}):[]);function he(F){tr()==="ok"&&(k(R,pe(F),!0),ee())}let Ne=tr(),ut=kp(),xt=!1;function Lt(){var Ot;const F=d(B);F!==null&&((Ot=mn(F.pluginName))==null?void 0:Ot.type)!=="widget"&&(Ee(),Xe.dismiss(F.toastId));const ne=d(y).filter($=>{var Ie;const le=Nn($.id);return le!==null&&((Ie=mn(le.pluginName))==null?void 0:Ie.type)==="widget"}),re=new Set(ne.map($=>$.id)),Q=d(R).filter($=>re.has($)),Fe=ne.length!==d(y).length,nt=Q.length!==d(R).length;for(const $ of d(y)){const le=Nn($.id);if(le===null||!re.has($.id)){os($.id,{clearStorage:!0}),le!==null&&Go(le.pluginName,`${le.pluginName}:${le.counter}`);continue}const Ie=mn(le.pluginName);(Ie==null?void 0:Ie.type)==="widget"&&!Ie.runnable&&os($.id,{clearStorage:!1})}return!Fe&&!nt?!1:(k(y,ne,!0),k(R,Q,!0),!0)}Qn(()=>{[...Sl.entries()],Object.values(va()).map(re=>`${re.status}:${re.runnable}`);const F=tr(),ne=kp();if(Zb(c,l),Vb(c,l),F==="ok"){if(!xt||Ne!=="ok"||ut!==ne){const re=Ne!=="ok",Q=Lt();xt=!0,Je(),(re||Q)&&ee()}}else xt=!1;Ne=F,ut=ne}),Qn(()=>{const F=d(B);F!==null&&!Xe.toasts.some(ne=>ne.id===F.toastId)&&Ee()}),Gn(()=>(f.addEventListener("change",Y),window.addEventListener("pagehide",Dt),()=>{f.removeEventListener("change",Y),window.removeEventListener("pagehide",Dt)}));function Dt(){Ee(),Xe.dismissKey(i)}si(()=>{D!==void 0&&clearTimeout(D),z==null||z.classList.remove("mndw-grid-tile--newly-added"),z=void 0,j!==null&&tr()==="ok"&&ee(j),Ee(),Xe.dismissKey(i),m==null||m.close(),b==null||b.close(),Wb("host-navigation")});var At=ZM(),He=v(At),ft=v(He);{var yt=F=>{var ne=GM(),re=tt(ne);T(re,"variant","secondary");var Q=v(re);T(Q,"name","plus"),T(Q,"aria-hidden","true");var Fe=S(Q),nt=S(re,2);{var Ot=$=>{var le=FM();T(le,"variant","secondary");var Ie=v(le);w(at=>E(Ie,at),[()=>M("dashboard.arrange-widgets")]),de("click",le,ke),C($,le)};W(nt,$=>{d(_)&&d(P).length>1&&$(Ot)})}w($=>E(Fe,` ${$??""}`),[()=>M("dashboard.add-widget")]),de("click",re,De),C(F,ne)},Zt=G(()=>l.getWidgets().length>0&&d(L).length>0);W(ft,F=>{d(Zt)&&F(yt)})}var $t=S(He,2);{var kn=F=>{{let ne=G(()=>M("dashboard.empty-error-title")),re=G(()=>M("dashboard.empty-error-text"));Zi(F,{get title(){return d(ne)},get text(){return d(re)}})}},Wt=F=>{{let ne=G(()=>M("dashboard.no-widgets")),re=G(()=>M("dashboard.empty-no-plugins")),Q=G(()=>({label:M("dashboard.empty-install-plugins"),href:gt.settingsTab.plugins}));Zi(F,{get title(){return d(ne)},get text(){return d(re)},get action(){return d(Q)}})}},qt=G(()=>l.getWidgets().length===0&&d(L).length===0),an=F=>{{let ne=G(()=>M("dashboard.empty-title")),re=G(()=>M("dashboard.empty-add-widget")),Q=G(()=>({label:M("dashboard.add-widget"),onActivate:De}));Zi(F,{get title(){return d(ne)},get text(){return d(re)},get action(){return d(Q)}})}};W($t,F=>{V.pluginLoadError!==null?F(kn):d(qt)?F(Wt,1):d(L).length===0&&F(an,2)})}var En=S($t,2);{var Rn=F=>{IM(F,{get order(){return d(P)},onRemoveRequest:ge})},Sn=F=>{var ne=VM(),re=v(ne);lM(re,{onGridReady:ze,onGridDestroyed:ae,onWidgetRemoved:$e,onLayoutChanged:Se,onWidgetResized:Te}),C(F,ne)};W(En,F=>{d(_)?F(Rn):F(Sn,-1)})}Br(At,F=>h=F,()=>h),w(()=>Ae(At,"data-locale",V.locale)),C(t,At),We()}bt(["click"]);const Qb="mndw-sidebar",e_="mndw-sidebar-toggle";var WM=N('<span class="mndw-header__device"> </span>'),qM=N('<header class="mndw-header"><div class="mndw-header__left"><mndw-button><mndw-icon></mndw-icon></mndw-button> <span class="mndw-header__brand">mndw</span> <!></div> <div class="mndw-header__right"><mndw-select><mndw-option>EN</mndw-option> <mndw-option>RU</mndw-option></mndw-select> <mndw-button><mndw-icon></mndw-icon></mndw-button> <mndw-button><mndw-icon></mndw-icon> </mndw-button></div></header>',2);function KM(t,e){Ze(e,!0);const n=yn(),r=fa();let i=te(pt(r.matches));Gn(()=>{const A=O=>{k(i,O.matches,!0)};return r.addEventListener("change",A),()=>{r.removeEventListener("change",A)}});function s(A){V.localeSwitchPending||n.locale.setLocale(A.detail.value).catch(()=>{})}async function o(){try{await new Promise(A=>{n.rci.logout().subscribe({next:()=>A(),error:()=>A()})})}finally{dc()}}var a=qM(),l=v(a),c=v(l);w(()=>T(c,"id",e_)),T(c,"variant","ghost"),Pe(c,1,"mndw-header__menu-toggle"),w(()=>T(c,"aria-label",M("nav.toggle-menu"))),w(()=>T(c,"aria-expanded",d(i)?V.mobileSidebarOpen:!V.desktopSidebarCollapsed)),w(()=>T(c,"aria-controls",Qb));var u=v(c);T(u,"name","menu");var f=S(c,4);{var h=A=>{var O=WM(),D=v(O);w(()=>E(D,V.deviceInfo.deviceName)),C(A,O)};W(f,A=>{V.deviceInfo&&A(h)})}var p=S(l,2),g=v(p);Pe(g,1,"mndw-header__locale-select"),w(()=>T(g,"label",M("nav.language"))),w(()=>T(g,"value",V.locale)),w(()=>T(g,"aria-busy",String(V.localeSwitchPending)));var m=v(g);T(m,"value","en");var b=S(m,2);T(b,"value","ru");var _=S(g,2);T(_,"variant","ghost"),Pe(_,1,"mndw-header__theme-toggle"),w(()=>T(_,"title",V.theme==="dark"?M("nav.light-theme"):M("nav.dark-theme"))),w(()=>T(_,"aria-label",M("nav.color-theme")));var y=v(_);w(()=>T(y,"name",V.theme==="dark"?"sun":"moon"));var R=S(_,2);T(R,"variant","ghost"),Pe(R,1,"mndw-header__logout");var L=v(R);T(L,"name","log-out");var P=S(L);w(A=>{Ae(a,"data-locale",V.locale),E(P,` ${A??""}`)},[()=>M("nav.logout")]),de("click",c,function(...A){au==null||au.apply(this,A)}),Pt("mndwchange",g,s),de("click",_,function(...A){var O;(O=n.theme.toggleTheme)==null||O.apply(this,A)}),de("click",R,o),C(t,a),We()}bt(["click"]);const hu=(t,e)=>{let n=null,r=!1,i=!1,s=e;const o=a=>{s=a,r=(a==null?void 0:a.enabled)??!0,r&&!n?t.hasAttribute("inert")?queueMicrotask(()=>{r&&!i&&!n&&!t.hasAttribute("inert")&&(n=mu(t,s))}):n=mu(t,s):!r&&n&&(n.deactivate(),n=null)};return o(e),{update:o,destroy(){i=!0,n==null||n.deactivate(),n=null}}};function Pf(t){const e=t.getPages().map(i=>{const s=mn(i.entry.name);return{name:i.entry.name,label:zn(i.entry,i.catalog??(s==null?void 0:s.catalog),V.locale).label,route:i.entry.route,status:"loaded"}}),n=new Set(e.map(({name:i})=>i)),r=Object.entries(va()).flatMap(([i,s])=>{if(!s.runnable||s.status!=="failed"&&s.status!=="loading"||s.type!=="page"||s.route===void 0||n.has(i))return[];const{label:o}=zn(s,s.catalog,V.locale);return[{name:i,label:o,route:s.route,status:s.status}]});return[...e,...r].sort((i,s)=>i.label.localeCompare(s.label)||i.name.localeCompare(s.name))}var YM=N('<div class="mndw-sidebar-backdrop" role="presentation"></div>'),XM=N('<mndw-icon></mndw-icon> <span class="mndw-visually-hidden svelte-mfxfye"> </span>',3),JM=N("<a> <!></a>"),QM=N('<hr class="mndw-sidebar__separator"/> <!>',1),eN=N('<!> <nav><a> </a> <a> </a> <!> <div class="mndw-sidebar__spacer"></div> <a> </a></nav>',1);function tN(t,e){Ze(e,!0);const n=yn(),r=n.registry,i=fa();let s=te(pt(i.matches)),o;const a=G(()=>d(s)?!V.mobileSidebarOpen:V.desktopSidebarCollapsed);let l=Cr(()=>d(s)?!V.mobileSidebarOpen:V.desktopSidebarCollapsed);const c=ee=>{k(s,ee.matches,!0)},u=G(()=>(V.locale,Pf(r).map(ee=>({...ee,failed:ee.status!=="loaded"})))),f=G(()=>{var ee;return((ee=n.router.current)==null?void 0:ee.route.pathname)??globalThis.location.pathname});function h(ee){return(ee.length>1&&ee.endsWith("/")?ee.slice(0,-1):ee).toLowerCase()}function p(ee){const be=h(d(f)),Ee=h(ee);return Ee==="/"?be==="/":be===Ee||be.startsWith(`${Ee}/`)}function g(){d(s)&&(V.mobileSidebarOpen=!1)}function m(ee){ee.key==="Escape"&&d(s)&&V.mobileSidebarOpen&&(V.mobileSidebarOpen=!1)}Gn(()=>(i.addEventListener("change",c),()=>{i.removeEventListener("change",c)})),Qn(()=>{var Ee;const ee=d(a),be=l;l=ee,!be&&ee&&(o!=null&&o.contains(document.activeElement))&&((Ee=document.getElementById(e_))==null||Ee.focus())});var b=eN();Pt("keydown",No,m);var _=tt(b);{var y=ee=>{var be=YM();de("click",be,g),C(ee,be)};W(_,ee=>{d(s)&&V.mobileSidebarOpen&&ee(y)})}var R=S(_,2);let L;var P=v(R);let A;var O=v(P),D=S(P,2);let z;var B=v(D),j=S(D,2);{var q=ee=>{var be=QM(),Ee=S(tt(be),2);Mt(Ee,17,()=>d(u),Me=>Me.name,(Me,$e)=>{var ge=JM();let ze;var Je=v(ge),ae=S(Je);{var Se=Te=>{var I=XM(),K=tt(I);Pe(K,1,"mndw-sidebar__warning svelte-mfxfye"),T(K,"name","circle-alert"),w(()=>T(K,"title",M("nav.page-load-failed"))),T(K,"aria-hidden","true");var we=S(K,2),De=v(we);w(ke=>E(De,ke),[()=>M("nav.page-load-failed")]),C(Te,I)};W(ae,Te=>{d($e).failed&&Te(Se)})}w((Te,I)=>{Ae(ge,"href",d($e).route),ze=Pe(ge,1,"mndw-sidebar__link",null,ze,Te),Ae(ge,"aria-current",I),E(Je,`${d($e).label??""} `)},[()=>({active:p(d($e).route)}),()=>p(d($e).route)?"page":void 0]),de("click",ge,g),C(Me,ge)}),C(ee,be)};W(j,ee=>{d(u).length>0&&ee(q)})}var ie=S(j,4);let ve;var pe=v(ie);Br(R,ee=>o=ee,()=>o),Zs(R,(ee,be)=>hu==null?void 0:hu(ee,be),()=>({enabled:d(s)&&V.mobileSidebarOpen})),w((ee,be,Ee,Me,$e,ge,ze,Je,ae)=>{Ae(R,"id",Qb),L=Pe(R,1,"mndw-sidebar",null,L,{collapsed:!d(s)&&V.desktopSidebarCollapsed,"mobile-collapsed":d(s)&&!V.mobileSidebarOpen}),Ae(R,"data-locale",V.locale),R.inert=d(a),Ae(P,"href",gt.dashboard),A=Pe(P,1,"mndw-sidebar__link",null,A,ee),Ae(P,"aria-current",be),E(O,Ee),Ae(D,"href",gt.packages),z=Pe(D,1,"mndw-sidebar__link",null,z,Me),Ae(D,"aria-current",$e),E(B,ge),Ae(ie,"href",gt.settings),ve=Pe(ie,1,"mndw-sidebar__link",null,ve,ze),Ae(ie,"aria-current",Je),E(pe,ae)},[()=>({active:p(gt.dashboard)}),()=>p(gt.dashboard)?"page":void 0,()=>M("nav.dashboard"),()=>({active:p(gt.packages)}),()=>p(gt.packages)?"page":void 0,()=>M("nav.package-manager"),()=>({active:p(gt.settings)}),()=>p(gt.settings)?"page":void 0,()=>M("nav.settings")]),de("click",P,g),de("click",D,g),de("click",ie,g),C(t,b),We()}bt(["click"]);var nN=N('<div class="mndw-alert mndw-alert--danger mndw-plugin-load-alert svelte-1bwqjg3" role="alert"><span> </span> <mndw-button> </mndw-button></div>',2),rN=N('<div class="mndw-app-shell"><!> <!> <div class="mndw-app-shell__body"><!> <main class="mndw-app-shell__content"><!></main></div></div>');function iN(t,e){Ze(e,!0);const n=yn();let r=te(void 0);function i(){var _;const g=document.activeElement;if(g===null)return!1;const m=g.getRootNode(),b=m instanceof ShadowRoot?m.host:g;return((_=d(r))==null?void 0:_.contains(b))??!1}async function s(){var _,y,R;if(V.authInitInFlight)return;const g=i();let m,b;try{const L=mf(n,{preservePluginLoadError:!0});b=Ur(),m=await L}catch{(b===void 0||b===Ur())&&dc();return}if(!(m===void 0||m!==Ur())){if(V.ready&&V.pluginLoadError===null)V.pluginLoadRevision+=1;else if(V.pluginLoadError!==null&&(V.pluginLoadFailureSeq+=1,g)){await Co();const L=(_=d(r))==null?void 0:_.querySelector("mndw-button");(R=(y=L==null?void 0:L.shadowRoot)==null?void 0:y.querySelector("button"))==null||R.focus()}}}var o=rN(),a=v(o);KM(a,{});var l=S(a,2);{var c=g=>{var m=_n(),b=tt(m);tm(b,()=>V.pluginLoadFailureSeq,_=>{var y=nN(),R=v(y),L=v(R),P=S(R,2);T(P,"variant","secondary"),w(()=>T(P,"disabled",V.authInitInFlight)),w(()=>T(P,"aria-busy",V.authInitInFlight));var A=v(P);Br(y,O=>k(r,O),()=>d(r)),w((O,D)=>{E(L,O),E(A,D)},[()=>M("app.plugin-load-error"),()=>M("common.retry")]),de("click",P,s),C(_,y)}),C(g,m)};W(l,g=>{V.authenticated&&V.pluginLoadError==="list"&&g(c)})}var u=S(l,2),f=v(u);tN(f,{});var h=S(f,2),p=v(h);oy(p,()=>e.children),C(t,o),We()}bt(["click"]);function fd(t){return t==="/"?"":t.length>1&&t.endsWith("/")?t.slice(0,-1):t}function za(t,e){return new td("INVALID_PATH",`Invalid page child path "${t}"`,{cause:e})}function sN(t){if(t===""||t==="/")return"";if(!t.startsWith("/")||t.startsWith("//")||t.includes("?")||t.includes("#"))throw za(t);const e=fd(t);if(e==="")return"";const n=e.slice(1).split("/"),r=n.length-1;for(const[i,s]of n.entries()){if(s===""){if(i!==r)throw za(t);continue}let o;try{o=decodeURIComponent(s)}catch(a){throw za(t,a)}if(o==="."||o===".."||o.includes("/")||o.includes("\\"))throw za(t)}return e}class oN{constructor(e,n,r){X(this,"baseRoute");X(this,"deps");X(this,"childPathSubject");X(this,"currentChildPath");X(this,"completed",!1);X(this,"navigationSerial",0);X(this,"pageRoute");this.baseRoute=e,this.deps=r,this.currentChildPath=fd(n),this.childPathSubject=new N_(this.currentChildPath),this.pageRoute=Object.freeze({childPath$:this.childPathSubject.asObservable(),navigate:(i,s)=>this.navigate(i,s)})}setPath(e){if(this.completed)return;const n=fd(e);n!==this.currentChildPath&&(this.currentChildPath=n,this.childPathSubject.next(n))}complete(){this.completed||(this.completed=!0,this.childPathSubject.complete())}async navigate(e,n){if(this.completed)throw new td("COMPLETED","Page route is no longer active");const r=sN(e);if(r===this.currentChildPath)return;const i=++this.navigationSerial,s=this.deps.getLocation();try{await this.deps.navigate(`${this.baseRoute}${r}`,{replace:(n==null?void 0:n.replace)??!1,search:s.search,hash:s.hash,scrollToTop:(n==null?void 0:n.scrollToTop)===!1?!1:"auto"})}catch(o){throw new td("NAVIGATION_FAILED",`Navigation to "${r}" failed`,{cause:o})}!this.completed&&i===this.navigationSerial&&this.setPath(r)}}var aN=N('<div class="mndw-page-plugin__notice"> </div>'),lN=N('<div class="mndw-page-plugin__notice mndw-page-plugin__panel svelte-190o6f4"><span> </span> <mndw-button> </mndw-button></div>',2),cN=N('<div class="mndw-page-plugin__notice mndw-page-plugin__panel svelte-190o6f4" role="status"> </div>'),uN=N('<div class="mndw-page-plugin__notice mndw-page-plugin__panel svelte-190o6f4" role="status"><span> </span> <mndw-button> </mndw-button></div>',2),dN=N('<div class="mndw-page-plugin__notice mndw-page-plugin__panel svelte-190o6f4" role="alert"><span> </span> <mndw-button> </mndw-button></div>',2),fN=N('<div class="mndw-page-plugin-wrap"><!> <div class="mndw-page-plugin"></div></div>');function Fp(t,e){Ze(e,!0);const n={clearStorage:!1,closeReason:"host-navigation"};let r,i=null,s=0,o=null,a=te("none"),l=te(null),c,u;const f=yn(),h=f.registry,p={locale:f.locale,palette:f.palette,telemetry:f.telemetry,telemetryGathering:f.telemetryGathering,eventStream:f.eventStream,rci:f.rci,theme:f.theme,tickerPool:f.tickerPool,overlayRuntime:f.overlayRuntime,navigation:f.router.navigation};function g(I){return r=I,{destroy(){r=void 0}}}const m=G(()=>{const I=f.router.current;return I===void 0?null:Rf(I.route.pathname,f.router.pageRouteDefinitions(h))}),b=G(()=>{var I;return((I=d(m))==null?void 0:I.name)??null}),_=G(()=>d(b)===null?"ready":uc(d(b))),y=G(()=>d(b)===null?void 0:mn(d(b))),R=G(()=>{var I;return((I=d(y))==null?void 0:I.status)==="loading"}),L=G(()=>{var I;return((I=d(y))==null?void 0:I.status)==="failed"}),P=G(()=>d(_)==="ready"&&!d(R)&&!d(L)?d(b):null),A=G(()=>{var we;if(d(b)===null)return"";const I=h.get(d(b)),K=(I==null?void 0:I.entry)??d(y);return K===void 0?"":zn(K,(I==null?void 0:I.catalog)??((we=d(y))==null?void 0:we.catalog),V.locale).label}),O=G(()=>d(l)===null?"":zn(d(l).entry,d(l).catalog,V.locale).label),D=G(()=>d(R)||d(a)==="pending"||d(a)==="loading"||d(a)==="slow");async function z(){var I;d(b)!==null&&((I=d(y))==null?void 0:I.runnable)===!0&&!d(R)&&await Ki(d(b))}function B(){c!==void 0&&(clearTimeout(c),c=void 0),u!==void 0&&(clearTimeout(u),u=void 0)}function j(){B(),k(a,"none"),k(l,null)}function q(I,K){B(),k(a,"pending"),k(l,K),c=setTimeout(()=>{I===s&&d(a)==="pending"&&k(a,"loading")},By),u=setTimeout(()=>{I===s&&(d(a)==="pending"||d(a)==="loading")&&k(a,"slow")},Uy)}function ie(){var I;s+=1,j(),o!==null&&(o.controller.complete(),(I=o.mount)==null||I.dispose(n),o.unsubscribeTheme(),o.child.remove(),o=null)}function ve(I){var we;if(i=I,I===null)return;const K=h.get(I);r===void 0||K===void 0||K.entry.type!=="page"||pe(K,((we=d(m))==null?void 0:we.name)===I?d(m).childPath:"")}function pe(I,K,we="full"){if(r===void 0)return Promise.resolve(!1);s+=1;const De=s,ke=document.createElement("div");ke.className="mndw-page-plugin__mount",ke.dataset.theme=f.theme.getTheme();const Y=f.theme.subscribeTheme(At=>{ke.dataset.theme=At});r.appendChild(ke);const se=f.router.pageRouteDefinitions(f.registry).find(At=>At.name===I.entry.name);if(se===void 0)return Y(),ke.remove(),Promise.resolve(!1);q(De,I);const he=f.router.current,Ne=new oN(se.route,K,{navigate:(At,He)=>he===void 0?Promise.reject(new Error("Host router is unavailable")):he.navigate(At,He),getLocation:()=>({search:globalThis.location.search,hash:globalThis.location.hash})}),ut={generation:De,pluginName:I.entry.name,child:ke,controller:Ne,mount:null,unsubscribeTheme:Y};o=ut,V.hostInfo;const xt=V.deviceInfo??Dd,Lt=xf({entry:I.entry,instanceId:`${I.entry.name}:1`,deviceInfo:xt,pageRoute:Ne.pageRoute,catalogCell:I.catalog,services:p}),Dt=jb(ke,I,Lt,{pluginStylesheets:f.pluginStylesheets});return ut.mount=Dt,Dt.whenReady().then(At=>(De!==s?ke.remove():(B(),At?(k(a,"none"),k(l,null)):we==="full"?(ke.replaceChildren(),k(a,"error")):(k(a,"none"),k(l,null))),At))}async function ee(I,K){var we,De;return ie(),await pe(I,((we=d(m))==null?void 0:we.childPath)??"","loading-only")?!0:(ie(),await pe(K,((De=d(m))==null?void 0:De.childPath)??"","full"),!1)}function be(){ie(),ve(d(P))}function Ee(I){const{detail:K}=I;o===null||K.pluginName!==i||K.register(ee(K.next,K.prior))}Qn(()=>{d(P)!==i&&(ie(),ve(d(P)))}),Qn(()=>{const I=d(m);I!==null&&(o==null?void 0:o.pluginName)===I.name&&o.controller.setPath(I.childPath)}),Qn(()=>(window.addEventListener(sd,Ee),()=>window.removeEventListener(sd,Ee))),si(ie);var Me=fN(),$e=v(Me);{var ge=I=>{var K=aN(),we=v(K);w(De=>{Ae(K,"role",d(_)==="failed"?"alert":"status"),E(we,De)},[()=>d(_)==="installing"?M("dashboard.preparing-dependencies"):M("dashboard.dependency-install-failed")]),C(I,K)},ze=I=>{var K=lN(),we=v(K),De=v(we),ke=S(we,2);T(ke,"variant","secondary"),w(()=>T(ke,"disabled",d(R))),w(()=>T(ke,"aria-busy",d(R)?"true":void 0));var Y=v(ke);w((se,he)=>{Ae(K,"role",d(R)?"status":"alert"),E(De,se),E(Y,he)},[()=>M("page-plugin.load-failed",{title:d(A)}),()=>M("common.retry")]),de("click",ke,z),C(I,K)},Je=I=>{var K=cN(),we=v(K);w(De=>E(we,De),[()=>M("page-plugin.opening",{title:d(O)})]),C(I,K)},ae=I=>{var K=uN(),we=v(K),De=v(we),ke=S(we,2);T(ke,"variant","secondary");var Y=v(ke);w((se,he)=>{E(De,se),E(Y,he)},[()=>M("page-plugin.slow"),()=>M("common.retry")]),de("click",ke,be),C(I,K)},Se=I=>{var K=dN(),we=v(K),De=v(we),ke=S(we,2);T(ke,"variant","secondary");var Y=v(ke);w((se,he)=>{E(De,se),E(Y,he)},[()=>M("page-plugin.open-error",{title:d(O)}),()=>M("common.retry")]),de("click",ke,be),C(I,K)};W($e,I=>{d(b)!==null&&d(_)!=="ready"?I(ge):d(L)||d(R)?I(ze,1):d(a)==="loading"?I(Je,2):d(a)==="slow"?I(ae,3):d(a)==="error"&&I(Se,4)})}var Te=S($e,2);Zs(Te,I=>g==null?void 0:g(I)),w(()=>Ae(Te,"aria-busy",d(D)?"true":void 0)),C(t,Me),We()}bt(["click"]);hw();function Js(t,e){return()=>{let n,r,i;const s=o=>{if(n!==void 0){if(i===void 0){const a=pt({row:o.row,value:o.value,colId:o.colId}),l=Object.assign(a,e(a));i=l,r=Vl(t,{target:n,props:l});return}i.row=o.row,i.value=o.value,i.colId=o.colId}};return{mount(o){n=o.node,s(o)},update(o){s(o)},destroy(){r!==void 0&&(Rd(r),r=void 0),n=void 0,i=void 0}}}}function Qa(){return t=>Js(t,()=>({}))}var hN=N('<span class="package-description svelte-84q0nr"> </span>'),pN=N('<span class="version-change svelte-84q0nr"> </span>'),gN=N('<span class="package-compact-meta svelte-84q0nr"><span> </span><!><span aria-hidden="true">&nbsp;·&nbsp;</span><span> </span></span>'),mN=N('<span class="package-name svelte-84q0nr"> </span> <!> <!>',1);function vN(t,e){Ze(e,!0);const n=G(()=>e.row.status==="installed"?M("packages.status-installed"):e.row.status==="update_available"?M("packages.update-available"):M("packages.available")),r=G(()=>`${e.row.version}${e.row.newVersion===void 0?"":` → ${e.row.newVersion}`} · ${d(n)}`);var i=mN(),s=tt(i),o=v(s),a=S(s,2);{var l=f=>{var h=hN(),p=v(h);w(()=>{Ae(h,"title",e.row.description),E(p,e.row.description)}),C(f,h)};W(a,f=>{e.row.description!==""&&f(l)})}var c=S(a,2);{var u=f=>{var h=gN(),p=v(h),g=v(p),m=S(p);{var b=R=>{var L=pN(),P=v(L);w(()=>E(P,` → ${e.row.newVersion??""}`)),C(R,L)};W(m,R=>{e.row.newVersion&&R(b)})}var _=S(m,2),y=v(_);w(()=>{Ae(h,"title",d(r)),E(g,e.row.version),E(y,d(n))}),C(f,h)};W(c,f=>{e.row.compact&&f(u)})}w(()=>{Ae(s,"title",e.value),E(o,e.value)}),C(t,i),We()}var bN=N('<span class="new-version svelte-sgt4ns"> </span>'),_N=N('<span class="ver-value svelte-sgt4ns"> </span><!>',1);function wN(t,e){Ze(e,!0);var n=_N(),r=tt(n),i=v(r),s=S(r);{var o=a=>{var l=bN(),c=v(l);w(()=>E(c,`→ ${e.row.newVersion??""}`)),C(a,l)};W(s,a=>{e.row.newVersion&&a(o)})}w(()=>{Ae(r,"data-col",e.colId),Ae(r,"title",e.value),E(i,e.value)}),C(t,n),We()}var yN=N("<span> </span>");function kN(t,e){Ze(e,!0);const n=G(()=>e.value==="installed"?M("packages.status-installed"):e.value==="update_available"?M("packages.update-available"):e.value==="available"?M("packages.available"):e.value);var r=yN(),i=v(r);w(()=>{Pe(r,1,`badge badge-${e.value??""}`,"svelte-tq54e2"),Ae(r,"data-col",e.colId),E(i,d(n))}),C(t,r),We()}function us(t){return t==="mndw"}var EN=N('<span role="status"> </span>'),SN=N('<span><span aria-hidden="true"> </span><span class="mndw-visually-hidden"> </span></span>'),TN=N("<a> </a>"),xN=N("<mndw-button> </mndw-button>",2);function CN(t,e){Ze(e,!0);const n=G(()=>us(e.row.name)),r=G(()=>e.row.status==="available"?"install":e.row.status==="update_available"?"upgrade":"remove"),i=G(()=>d(r)==="install"?M("packages.install"):d(r)==="upgrade"?M("packages.update"):M("packages.remove")),s=G(()=>{if(e.row.busyAction==="install")return M("packages.installing");if(e.row.busyAction==="remove")return M("packages.removing");if(e.row.busyAction==="upgrade")return M("packages.updating")});var o=_n(),a=tt(o);{var l=h=>{var p=EN();let g;var m=v(p);w(()=>{g=Pe(p,1,"action-label svelte-1r6mv7p",null,g,{"compact-action":e.row.compact}),E(m,d(s))}),C(h,p)},c=h=>{var p=SN();let g;var m=v(p),b=v(m),_=S(m),y=v(_);w((R,L,P)=>{g=Pe(p,1,"action-label protected-label svelte-1r6mv7p",null,g,{"compact-action":e.row.compact}),Ae(p,"title",R),E(b,L),E(y,P)},[()=>M("packages.protected"),()=>M("packages.protected-label"),()=>M("packages.protected")]),C(h,p)},u=h=>{var p=TN();let g;var m=v(p);w(b=>{g=Pe(p,1,"settings-update-link svelte-1r6mv7p",null,g,{"compact-action":e.row.compact}),Ae(p,"href",gt.settingsTab["self-update"]),E(m,b)},[()=>M("packages.update-in-settings")]),de("click",p,b=>{b.preventDefault(),e.onUpdateInSettings()}),C(h,p)},f=h=>{var p=xN();w(()=>T(p,"variant",d(r)==="remove"?"secondary":"primary")),w(()=>T(p,"disabled",e.row.actionsDisabled===!0)),w(()=>T(p,"data-package",e.row.name)),T(p,"data-package-action","primary"),T(p,"data-no-expand",!0);let g;var m=v(p);w(()=>{g=Pe(p,1,"svelte-1r6mv7p",null,g,{"compact-action":e.row.compact}),E(m,d(i))}),de("click",p,()=>e.onAction(d(r))),C(h,p)};W(a,h=>{d(s)!==void 0?h(l):d(r)==="remove"&&d(n)?h(c,1):d(r)==="upgrade"&&d(n)?h(u,2):h(f,-1)})}C(t,o),We()}bt(["click"]);function PN(t,e=()=>{}){return Js(CN,n=>({onAction:r=>t(r,n.row.name),onUpdateInSettings:e}))}var RN=N('<p class="svelte-uhnzp9"> </p>'),AN=N('<p role="alert" class="svelte-uhnzp9"> </p> <mndw-button> </mndw-button>',3),Da=N('<dt class="svelte-uhnzp9"> </dt><dd class="svelte-uhnzp9"> </dd>',1),ON=N('<dl class="svelte-uhnzp9"><dt class="svelte-uhnzp9"> </dt> <dd class="svelte-uhnzp9"> </dd> <!> <!> <!> <!></dl>'),MN=N("<mndw-button> </mndw-button>",2),NN=N('<div class="detail svelte-uhnzp9"><!> <!></div>');function LN(t,e){Ze(e,!0);let n=G(()=>e.value.name);const r=G(()=>us(e.row.name));let i=G(()=>e.cache.get(d(n)));Qn(()=>{e.load(d(n))});var s=NN(),o=v(s);{var a=h=>{var p=RN(),g=v(p);w(m=>E(g,m),[()=>M("packages.loading")]),C(h,p)},l=h=>{var p=AN(),g=tt(p),m=v(g),b=S(g,2);T(b,"variant","secondary"),w(()=>T(b,"disabled",e.row.actionsDisabled===!0));var _=v(b);w(y=>{E(m,d(i).message),E(_,y)},[()=>M("common.retry")]),de("click",b,()=>e.retry(d(n))),C(h,p)},c=h=>{var p=ON(),g=v(p),m=v(g),b=S(g,2),_=v(b),y=S(b,2);{var R=B=>{var j=Da(),q=tt(j),ie=v(q),ve=S(q),pe=v(ve);w(ee=>{E(ie,ee),E(pe,d(i).info.size)},[()=>M("packages.size")]),C(B,j)};W(y,B=>{d(i).info.size&&B(R)})}var L=S(y,2);{var P=B=>{var j=Da(),q=tt(j),ie=v(q),ve=S(q),pe=v(ve);w(ee=>{E(ie,ee),E(pe,d(i).info.installedSize)},[()=>M("packages.installed-size")]),C(B,j)};W(L,B=>{d(i).info.installedSize&&B(P)})}var A=S(L,2);{var O=B=>{var j=Da(),q=tt(j),ie=v(q),ve=S(q),pe=v(ve);w(ee=>{E(ie,ee),E(pe,d(i).info.installedTime)},[()=>M("packages.installed-time")]),C(B,j)};W(A,B=>{d(i).info.installedTime&&B(O)})}var D=S(A,2);{var z=B=>{var j=Da(),q=tt(j),ie=v(q),ve=S(q),pe=v(ve);w((ee,be)=>{E(ie,ee),E(pe,be)},[()=>M("packages.dependencies"),()=>d(i).info.dependencies.join(", ")]),C(B,j)};W(D,B=>{d(i).info.dependencies.length>0&&B(z)})}w(B=>{E(m,B),E(_,d(i).info.description)},[()=>M("packages.description")]),C(h,p)};W(o,h=>{var p;((p=d(i))==null?void 0:p.status)==="pending"||d(i)===void 0?h(a):d(i).status==="failure"?h(l,1):d(i).status==="success"&&h(c,2)})}var u=S(o,2);{var f=h=>{var p=MN();T(p,"variant","secondary"),w(()=>T(p,"disabled",e.row.actionsDisabled===!0)),w(()=>T(p,"data-package",d(n))),T(p,"data-package-action","detail"),T(p,"data-no-expand",!0);var g=v(p);w(m=>E(g,m),[()=>M("packages.remove")]),de("click",p,()=>e.onRemove()),C(h,p)};W(u,h=>{e.row.status==="update_available"&&!d(r)&&h(f)})}w(()=>{Ae(s,"data-col",e.colId),Ae(s,"data-package",d(n))}),C(t,s),We()}bt(["click"]);function IN(t){return Js(LN,e=>({cache:t.cache,load:t.load,retry:t.retry,onRemove:()=>t.onRemove(e.row.name)}))}const Gp=/[.\-+]/,Vp=t=>t.length>0&&/^[0-9]+$/.test(t);function zN(t,e){const n=t.split(Gp),r=e.split(Gp),i=Math.min(n.length,r.length);for(let s=0;s<i;s+=1){const o=n[s],a=r[s];if(o!==a)if(Vp(o)&&Vp(a)){const l=Number(o)-Number(a);if(l!==0)return l<0?-1:1}else{const l=o.localeCompare(a);if(l!==0)return l<0?-1:1}}return n.length-r.length}var DN=N('<div class="confirm-modal svelte-erapy5"><p class="svelte-erapy5"> </p> <div class="actions svelte-erapy5"><mndw-button> </mndw-button> <mndw-button> </mndw-button></div></div>',2);function Zo(t,e){Ze(e,!0);var n=DN(),r=v(n),i=v(r),s=S(r,2),o=v(s);T(o,"variant","secondary");var a=v(o),l=S(o,2);T(l,"variant","danger");var c=v(l);w(u=>{E(i,e.message),E(a,u),E(c,e.confirmLabel)},[()=>M("common.cancel")]),de("click",o,()=>e.close(!1)),de("click",l,()=>e.close(!0)),C(t,n),We()}bt(["click"]);const HN=40;function t_(t,e){if(typeof ResizeObserver>"u")return e(!1),()=>{};const n=Number.parseFloat(getComputedStyle(document.documentElement).fontSize),r=HN*(n>0?n:16),i=new ResizeObserver(s=>{for(const o of s)o.target===t&&e(o.contentRect.width<r)});return i.observe(t),()=>i.disconnect()}var BN=N('<span class="selection-hint svelte-m3c4ux"> </span>'),pu=N("<mndw-button> </mndw-button>",2),UN=N('<span class="selected-count svelte-m3c4ux"> </span> <!> <!> <!> <mndw-button> </mndw-button>',3),jN=N('<div class="mndw-alert mndw-alert--danger package-load-error svelte-m3c4ux" role="alert"><p class="svelte-m3c4ux"> </p> <mndw-button> </mndw-button></div>',2),$N=N('<div class="msg-cell svelte-m3c4ux" role="status"> </div>'),FN=N("<mndw-table></mndw-table>",2),GN=N('<section class="packages-panel svelte-m3c4ux"><div><span class="freshness svelte-m3c4ux"><mndw-icon></mndw-icon> </span> <mndw-button> </mndw-button></div> <div class="filter-row mndw-table-controls svelte-m3c4ux"><mndw-tabs><mndw-tab> </mndw-tab> <mndw-tab> </mndw-tab> <mndw-tab> </mndw-tab></mndw-tabs> <mndw-field><mndw-input></mndw-input></mndw-field></div> <div class="selection-row mndw-table-controls svelte-m3c4ux"><!></div> <div class="table-wrap svelte-m3c4ux"><!> <!></div></section>',2);function VN(t,e){Ze(e,!0);const n="packages.list",r="packages.refresh";function i(H){return`packages.${H}`}let s=Tn(e,"now",3,()=>new Date),o,a=te(!1);const l=yn(),c=l.locale.hostT,u=l.opkgClient;let f=te(pt([])),h=te(null),p=te(null),g=new Gi,m=te(""),b=te("installed"),_=te(0),y=te(!0),R=te(!1),L=te(null),P=new Gi,A=te(!1),O=te(""),D=te(null),z,B=0,j=!1;si(()=>{j=!0});const q=new Ti;let ie=0;const ve=G(()=>d(R)||P.size>0),pe=G(()=>d(f).map(H=>({...H,...P.has(H.name)&&d(L)!==null?{busyAction:d(L)}:{},actionsDisabled:d(ve),compact:d(a)}))),ee=G(()=>d(pe).filter(H=>{if(d(b)==="installed"&&H.status==="available"||d(b)==="updates"&&H.status!=="update_available")return!1;const oe=d(m).toLowerCase();return H.name.toLowerCase().includes(oe)||H.description.toLowerCase().includes(oe)})),be=G(()=>g.size),Ee=G(()=>d(f).filter(H=>H.status==="update_available").length),Me=G(()=>[...g]),$e=G(()=>d(f).filter(H=>g.has(H.name))),ge=G(()=>d($e).filter(H=>H.status==="available").length),ze=G(()=>d($e).filter(H=>H.status!=="available"&&!us(H.name)).length),Je=G(()=>d($e).filter(H=>H.status==="update_available"&&!us(H.name)).length),ae=G(()=>{if(d(h)===null)return c("packages.never-refreshed");if(d(p)===null)return"";const H=Math.max(0,d(p).getTime()-Date.parse(d(h)));if(H<6e4)return c("packages.just-now");const oe=new Intl.RelativeTimeFormat(V.locale,{numeric:"auto"}),ye=Math.floor(H/6e4);if(ye<60)return c("packages.refreshed-ago",{age:oe.format(-ye,"minute")});const Ge=Math.floor(H/36e5);if(Ge<24)return c("packages.refreshed-ago",{age:oe.format(-Ge,"hour")});const qe=Math.floor(H/864e5);return c("packages.refreshed-ago",{age:oe.format(-qe,"day")})}),Se=G(()=>d(h)===null||d(p)===null?!1:d(p).getTime()-Date.parse(d(h))>3600*1e3),Te=G(()=>d(h)===null||d(Se));async function I(){(d(m)!==""||d(b)!=="all")&&k(_,d(_)+1),k(m,""),k(b,"all"),await Co(),z==null||z.focus()}function K(){ie+=1,q.clear()}function we(H){if(q.has(H))return;const oe=ie,ye=u.info(H);q.set(H,{status:"pending",promise:ye}),ye.then(Ge=>{var qe;oe===ie&&((qe=q.get(H))==null?void 0:qe.status)==="pending"&&q.set(H,{status:"success",info:Ge})}).catch(Ge=>{var qe;oe===ie&&((qe=q.get(H))==null?void 0:qe.status)==="pending"&&q.set(H,{status:"failure",message:Ge instanceof Eo?Ge.message:c("packages.detail-failed")})})}function De(H){var oe;((oe=q.get(H))==null?void 0:oe.status)==="failure"&&(q.delete(H),we(H))}async function ke(H=d(f).length===0){H&&k(y,!0);try{const oe=await u.list();if(j)return;k(f,oe.packages,!0),k(h,oe.metadataUpdatedAt,!0),k(p,s()(),!0),K(),k(A,!1),k(O,""),g.clear(),Xe.dismissKey(n)}catch(oe){if(j)return;k(A,!0),k(O,oe instanceof Eo?oe.message:c("packages.load-failed"),!0)}finally{j||k(y,!1)}}async function Y(H,oe){const ye=Array.from(g).filter(Ge=>{const qe=d(f).find(_t=>_t.name===Ge);return qe!==void 0&&oe(qe)});if(ye.length!==0&&!d(ve)){if(H==="remove"){const qe=await ri(l.hostOverlay,Zo,{title:c("packages.confirm-remove-title"),props:{message:c("packages.confirm-remove",{names:ye.join(", ")}),confirmLabel:c("packages.remove")}}).closed;if(j)return;qe.result&&await se("remove",ye,void 0,!0);return}await se(H,ye,void 0,!0)}}async function se(H,oe,ye,Ge=!1){if(oe.length===0||d(ve))return;k(L,H,!0),P.clear();for(const je of oe)P.add(je);const qe=H==="install"?"packages.installing":H==="remove"?"packages.removing":"packages.updating",_t=i(H);try{let je;try{je=(H==="install"?await u.install(oe):H==="remove"?await u.remove(oe):await u.upgrade(oe)).message}catch(tn){if(j)return;Xe.error(Ne(tn,qe),{key:_t})}if(j||(await ke(!1),j))return;je!==void 0&&Xe.success(je,{key:_t})}finally{Ge&&g.clear(),j||(P.clear(),k(L,null)),!j&&ye!==void 0&&await he(ye)}}async function he(H){if(await Co(),j)return;const oe=d(D);oe!==null&&await oe.updateComplete,await Co();const ye=[...document.querySelectorAll("mndw-button[data-package][data-package-action]")].filter(_t=>_t.dataset.package===H.packageName&&!_t.disabled),qe=ye.find(_t=>_t.dataset.packageAction===H.source)??ye[0]??document.querySelector(".packages-panel .status-row mndw-button");qe==null||qe.focus()}function Ne(H,oe){if(!(H instanceof Eo))return c("packages.action-failed",{action:c(oe)});const ye=ZA(H);return ye===void 0?H.message:ye.dependents.length>0?c("packages.dependency-conflict",{package:ye.package,dependents:ye.dependents.join(", ")}):c("packages.dependency-conflict-generic",{package:ye.package})}async function ut(){if(!d(ve)){k(R,!0);try{const H=await u.update();if(j||(await ke(!1),j))return;Xe.success(H.message,{key:r})}catch(H){if(j)return;Xe.error(H instanceof Eo?H.message:c("app.error"),{key:r})}finally{j||k(R,!1)}}}function xt(H){const oe=H.detail.value;(oe==="all"||oe==="installed"||oe==="updates")&&oe!==d(b)&&(k(b,oe,!0),k(_,d(_)+1))}function Lt(H){d(m)!==H.detail.value&&(k(m,H.detail.value,!0),k(_,d(_)+1))}async function Dt(H,oe="primary"){const Ge=await ri(l.hostOverlay,Zo,{title:c("packages.confirm-remove-title"),props:{message:c("packages.confirm-remove",{names:H}),confirmLabel:c("packages.remove")}}).closed;j||Ge.result&&await se("remove",[H],{packageName:H,source:oe})}const At={installed:0,update_available:1,available:2},He=Qa()(vN),ft=Qa()(wN),yt=Qa()(kN),Zt=IN({cache:q,load:we,retry:De,onRemove:H=>Dt(H,"detail")}),$t=PN((H,oe)=>{if(!d(ve)){if(H==="remove"){Dt(oe);return}se(H,[oe],{packageName:oe,source:"primary"})}},()=>{var H;(H=l.router.current)==null||H.navigate(gt.settingsTab["self-update"])}),kn=G(()=>[pi()({id:"name",label:c("packages.package"),accessor:H=>H.name,sortable:!0,width:d(a)?"8rem":"11.25rem",renderer:He}),pi()({id:"version",label:c("packages.version"),accessor:H=>H.version,sortable:!0,comparator:zN,renderer:ft}),pi()({id:"status",label:c("packages.status"),accessor:H=>H.status,sortable:!0,comparator:(H,oe)=>At[H]-At[oe],renderer:yt}),pi()({id:"actions",label:"",...d(a)?{width:"6rem"}:{},renderer:$t})]),Wt=G(()=>d(a)?["version","status"]:[]);let qt=new Gi,an=te(null);const En=G(()=>({expandRow:H=>c("packages.expand",{name:H}),collapseRow:H=>c("packages.collapse",{name:H})}));function Rn(H){g.clear();for(const oe of H.detail.selected)g.add(oe)}function Sn(H){k(an,H.detail.sort,!0)}function F(H){qt.clear();for(const oe of H.detail.expanded)qt.add(oe)}Qn(()=>{const H=new Set(d(ee).map(oe=>oe.name));Cr(()=>{const oe=[...qt].filter(ye=>!H.has(ye));for(const ye of oe)qt.delete(ye)})}),Qn(()=>{const H=d(_),oe=Cr(()=>{var qe;return(qe=d(ee)[0])==null?void 0:qe.name}),ye=d(D),Ge=++B;oe===void 0||ye===null||(async()=>(await ye.updateComplete,!(Ge!==B||H!==d(_)||Cr(()=>{var qe;return(qe=d(ee)[0])==null?void 0:qe.name})!==oe)&&ye.scrollToRow(oe,{align:"start"})))()}),Gn(()=>(ke(),t_(o,H=>{k(a,H,!0)})));var ne=GN(),re=v(ne),Q=v(re),Fe=v(Q);w(()=>T(Fe,"name",d(Te)?"circle-alert":"info")),T(Fe,"aria-hidden","true"),Pe(Fe,1,"svelte-m3c4ux");var nt=S(Fe),Ot=S(Q,2);T(Ot,"variant","secondary"),w(()=>T(Ot,"disabled",d(ve))),Pe(Ot,1,"svelte-m3c4ux");var $=v(Ot),le=S(re,2),Ie=v(le);w(()=>T(Ie,"value",d(b))),Pe(Ie,1,"svelte-m3c4ux");var at=v(Ie);T(at,"id","all");var Zn=v(at),Wn=S(at,2);T(Wn,"id","installed");var fr=v(Wn),ue=S(Wn,2);T(ue,"id","updates");var Re=v(ue),it=S(Ie,2);Pe(it,1,"search-field svelte-m3c4ux"),w(()=>T(it,"label",c("packages.search-label")));var dt=v(it);T(dt,"type","search"),w(()=>T(dt,"value",d(m))),w(()=>T(dt,"aria-label",c("packages.search-label"))),w(()=>T(dt,"placeholder",c("packages.search"))),Br(dt,H=>z=H,()=>z);var ln=S(le,2),hn=v(ln);{var J=H=>{var oe=BN(),ye=v(oe);w(Ge=>E(ye,Ge),[()=>c("packages.selection-hint")]),C(H,oe)},fe=H=>{var oe=UN(),ye=tt(oe),Ge=v(ye),qe=S(ye,2);{var _t=et=>{var st=pu();T(st,"variant","primary"),w(()=>T(st,"disabled",d(ve)));var Ft=v(st);w(nn=>E(Ft,nn),[()=>c("packages.action-count",{action:c("packages.install"),count:d(ge)})]),de("click",st,()=>void Y("install",nn=>nn.status==="available")),C(et,st)};W(qe,et=>{d(ge)>0&&et(_t)})}var je=S(qe,2);{var tn=et=>{var st=pu();T(st,"variant","primary"),w(()=>T(st,"disabled",d(ve)));var Ft=v(st);w(nn=>E(Ft,nn),[()=>c("packages.action-count",{action:c("packages.update"),count:d(Je)})]),de("click",st,()=>void Y("upgrade",nn=>nn.status==="update_available"&&!us(nn.name))),C(et,st)};W(je,et=>{d(Je)>0&&et(tn)})}var Pr=S(je,2);{var Qs=et=>{var st=pu();T(st,"variant","secondary"),w(()=>T(st,"disabled",d(ve)));var Ft=v(st);w(nn=>E(Ft,nn),[()=>c("packages.action-count",{action:c("packages.remove"),count:d(ze)})]),de("click",st,()=>void Y("remove",nn=>nn.status!=="available"&&!us(nn.name))),C(et,st)};W(Pr,et=>{d(ze)>0&&et(Qs)})}var Vt=S(Pr,2);T(Vt,"variant","secondary"),w(()=>T(Vt,"disabled",d(ve)));var Tt=v(Vt);w((et,st)=>{E(Ge,et),E(Tt,st)},[()=>c("packages.selection-count",{count:d(be)}),()=>c("packages.clear-selection")]),de("click",Vt,()=>g.clear()),C(H,oe)};W(hn,H=>{d(be)===0?H(J):H(fe,-1)})}var xe=S(ln,2),rt=v(xe);{var mt=H=>{var oe=jN(),ye=v(oe),Ge=v(ye),qe=S(ye,2);T(qe,"variant","secondary"),w(()=>T(qe,"disabled",d(ve)||d(y)));var _t=v(qe);w(je=>{E(Ge,d(O)),E(_t,je)},[()=>c("common.retry")]),de("click",qe,()=>void ke()),C(H,oe)};W(rt,H=>{d(A)&&H(mt)})}var It=S(rt,2);{var Kt=H=>{var oe=$N(),ye=v(oe);w(Ge=>E(ye,Ge),[()=>c("packages.loading")]),C(H,oe)},en=H=>{var oe=_n(),ye=tt(oe);{var Ge=_t=>{{let je=G(()=>c(d(f).length===0?"packages.empty":"packages.no-match")),tn=G(()=>c(d(f).length===0?"packages.empty-next":"packages.no-match-next")),Pr=G(()=>d(f).length===0?{label:c("packages.refresh"),onActivate:()=>void ke(),variant:"secondary"}:{label:c("packages.show-all"),onActivate:I,variant:"secondary"});Zi(_t,{mode:"compact",get title(){return d(je)},get text(){return d(tn)},get action(){return d(Pr)}})}},qe=_t=>{var je=FN();w(()=>T(je,"columns",d(kn))),w(()=>T(je,"rows",d(ee))),w(()=>T(je,"hiddenColumns",d(Wt))),T(je,"rowKey","name"),T(je,"virtual",!0),T(je,"rowLabel",tn=>tn.name),T(je,"selectable",!0),w(()=>T(je,"selected",d(Me))),T(je,"expandable",!0),T(je,"toggleAfterColumn","name"),T(je,"expandOn","row"),w(()=>T(je,"expanded",[...qt])),w(()=>T(je,"expandedRenderer",Zt)),T(je,"columnMenu",!1),T(je,"sortMode","client"),w(()=>T(je,"sort",d(an))),w(()=>T(je,"labels",d(En))),Pe(je,1,"svelte-m3c4ux"),Br(je,tn=>k(D,tn),()=>d(D)),Pt("mndwselectionchange",je,Rn),Pt("mndwsortchange",je,Sn),Pt("mndwrowexpand",je,F),C(_t,je)};W(ye,_t=>{d(ee).length===0?_t(Ge):_t(qe,-1)})}C(H,oe)};W(It,H=>{d(y)&&d(f).length===0?H(Kt):d(A)&&d(f).length===0||H(en,1)})}Br(ne,H=>o=H,()=>o),w((H,oe,ye,Ge)=>{Ae(ne,"data-locale",V.locale),Pe(re,1,`status-row mndw-table-controls mndw-alert ${d(Te)?"mndw-alert--warning":"mndw-alert--info"}${d(a)?" compact":""}`,"svelte-m3c4ux"),E(nt,` ${d(ae)??""}`),E($,H),E(Zn,oe),E(fr,ye),E(Re,Ge)},[()=>c(d(R)?"packages.checking":"packages.refresh"),()=>c("packages.all"),()=>c("packages.installed"),()=>c("packages.updates",{count:d(Ee)})]),de("click",Ot,()=>void ut()),Pt("mndwchange",Ie,xt),Pt("mndwinput",dt,Lt),C(t,ne),We()}bt(["click"]);var ZN=N("<mndw-switch></mndw-switch>",2);function n_(t,e){Ze(e,!0);const n=G(()=>e.row.busy||e.row.service.protected||e.row.service.autostartPinned),r=G(()=>e.row.service.enabledAtBoot?M("services.disable-at-boot"):M("services.enable-at-boot")),i=G(()=>e.row.service.protected?M("services.protected"):e.row.service.autostartPinned?M("services.autostart-pinned"):d(r)),s=a=>{const l=a.currentTarget;l.checked=e.row.service.enabledAtBoot,e.onToggle(!e.row.service.enabledAtBoot)};var o=ZN();w(()=>T(o,"checked",e.row.service.enabledAtBoot)),w(()=>T(o,"disabled",d(n))),w(()=>T(o,"aria-label",d(r))),w(()=>T(o,"title",d(i))),Pt("mndwchange",o,s),C(t,o),We()}var WN=N('<small class="pid svelte-1ugk9ic"> </small>'),qN=N("<span> </span> <!>",1);function r_(t,e){Ze(e,!0);const n={running:"badge-running",stopped:"badge-stopped",unknown:"badge-unknown"},r=G(()=>n[e.row.service.state]??"badge-unknown"),i=G(()=>e.row.rowError?M("services.probe-failed"):M(`services.state-${e.row.service.state}`));var s=qN(),o=tt(s),a=v(o),l=S(o,2);{var c=u=>{var f=WN(),h=v(f);w(p=>E(h,p),[()=>M("services.pid",{pid:e.row.service.pid})]),C(u,f)};W(l,u=>{e.row.service.pid!==void 0&&u(c)})}w(()=>{Pe(o,1,`badge ${d(r)??""}`,"svelte-1ugk9ic"),E(a,d(i))}),C(t,s),We()}var KN=N('<div class="compact-details svelte-gqtyao"><!> <!></div>'),YN=N('<strong> </strong><small class="svelte-gqtyao"> </small> <!>',1);function XN(t,e){Ze(e,!0);var n=YN(),r=tt(n),i=v(r),s=S(r),o=v(s),a=S(s,2);{var l=c=>{var u=KN(),f=v(u);r_(f,{get row(){return e.row}});var h=S(f,2);n_(h,{get row(){return e.row},get onToggle(){return e.onToggle}}),C(c,u)};W(a,c=>{e.row.compact&&c(l)})}w(()=>{E(i,e.row.service.label),E(o,e.row.service.name)}),C(t,n),We()}var JN=N("<mndw-button> </mndw-button>",2),QN=N('<span class="protected-label svelte-2q4dea"><span aria-hidden="true"> </span><span class="mndw-visually-hidden"> </span></span>'),eL=N('<div class="actions svelte-2q4dea"><!> <!></div>');function tL(t,e){Ze(e,!0);const n=[{action:"start",label:"services.start",guardProtected:!1},{action:"stop",label:"services.stop",guardProtected:!0},{action:"restart",label:"services.restart",guardProtected:!0}],r=G(()=>e.row.rowError||e.row.service.state==="unknown"?n:e.row.service.state==="running"?n.filter(({action:l})=>l!=="start"):n.filter(({action:l})=>l==="start"));var i=eL(),s=v(i);Mt(s,17,()=>d(r),({action:l,label:c,guardProtected:u})=>l,(l,c)=>{let u=()=>d(c).action,f=()=>d(c).label,h=()=>d(c).guardProtected;var p=_n(),g=tt(p);{var m=b=>{var _=JN();T(_,"variant","secondary"),w(()=>T(_,"disabled",e.row.busy||h()&&e.row.service.protected)),Pe(_,1,"svelte-2q4dea");var y=v(_);w(R=>E(y,R),[()=>M(f())]),de("click",_,()=>e.onRun(u())),C(b,_)};W(g,b=>{(!h()||!e.row.service.protected)&&b(m)})}C(l,p)});var o=S(s,2);{var a=l=>{var c=QN(),u=v(c),f=v(u),h=S(u),p=v(h);w((g,m,b)=>{Ae(c,"title",g),E(f,m),E(p,b)},[()=>M("services.protected"),()=>M("services.protected-label"),()=>M("services.protected")]),C(l,c)};W(o,l=>{e.row.service.protected&&l(a)})}C(t,i),We()}bt(["click"]);function nL(t){return Js(tL,e=>({onRun:n=>t(n,e.row.service.name)}))}function rL(t){return Js(n_,e=>({onToggle:n=>t(e.row.service,n)}))}var iL=N('<div class="capability svelte-3v3gj2" role="status"><strong class="svelte-3v3gj2"> </strong><span> </span></div>'),sL=N('<div class="mndw-alert mndw-alert--danger services-load-error svelte-3v3gj2" role="alert"><p class="svelte-3v3gj2"> </p> <mndw-button> </mndw-button></div>',2),oL=N('<p role="status"> </p>'),aL=N('<div class="table-wrap svelte-3v3gj2"><mndw-table></mndw-table></div>',2),lL=N('<section class="services-panel svelte-3v3gj2"><div><p class="svelte-3v3gj2"> </p> <mndw-button> </mndw-button></div> <!></section>',2);function cL(t,e){Ze(e,!0);let n=te(pt([])),r,i=te(!1);const s=yn(),o=s.locale.hostT,a=s.serviceClient;let l=te(pt({})),c=te(!1),u=te(!1),f=te(!1),h=te(!1),p=te(pt({})),g=0,m;const b=3,_=G(()=>d(n).map(Y=>({service:Y,busy:d(h),rowError:d(l)[Y.name]??!1,compact:d(i)}))),y=Js(XN,Y=>({onToggle:se=>void Ee(Y.row.service,se)})),R=Qa()(r_),L=rL((Y,se)=>void Ee(Y,se)),P=nL((Y,se)=>void be(Y,se)),A=G(()=>[pi()({id:"service",label:o("services.service"),width:d(i)?"8rem":"10rem",renderer:y}),pi()({id:"state",label:o("services.state"),width:"7.1rem",renderer:R}),pi()({id:"autostart",label:o("services.autostart"),width:"6.7rem",align:"center",renderer:L}),pi()({id:"actions",label:o("services.actions"),width:d(i)?"7rem":"18rem",renderer:P})]);function O(Y,se){k(n,d(n).map(he=>he.name===Y?se:he),!0)}function D(Y){O(Y.name,Y)}async function z(Y,se,he){let Ne=0;const ut=async()=>{for(;Ne<Y.length;){const xt=Y[Ne++];xt!==void 0&&await he(xt)}};await Promise.all(Array.from({length:Math.min(se,Y.length)},()=>ut()))}function B(Y,se,he,Ne){return g===se&&(d(p)[Y]??0)===he&&!Ne.aborted}async function j(Y,se,he){const Ne=d(p)[Y.name]??0;try{const ut=await a.status(Y.name,he);B(Y.name,se,Ne,he)&&D(ut)}catch{B(Y.name,se,Ne,he)&&k(l,{...d(l),[Y.name]:!0},!0)}}async function q(Y,se,he){await z(Y,b,Ne=>j(Ne,se,he))}async function ie(){m==null||m.abort(),m=new AbortController;const Y=++g;k(c,!0),k(u,!1),k(f,!1),k(l,{},!0),k(p,{},!0);try{const se=await a.list();if(g!==Y)return;k(n,se,!0),k(c,!1),await q(se,Y,m.signal)}catch(se){if(g!==Y||m.signal.aborted)return;k(n,[],!0),k(u,se instanceof ld&&se.code==="SERVICE_UNAVAILABLE",!0),k(f,!d(u)),k(c,!1)}finally{g===Y&&k(c,!1)}}async function ve(Y,se){return(await ri(s.hostOverlay,Zo,{title:o("services.confirm-title"),props:{message:Y,confirmLabel:se}}).closed).result===!0}async function pe(Y,se){return ve(o("services.confirm",{action:Y,name:se}),o(`services.${Y}`))}async function ee(Y,se){return ve(o(se?"services.confirm-enable-boot":"services.confirm-disable-boot",{name:Y}),o(se?"services.enable-at-boot":"services.disable-at-boot"))}async function be(Y,se){if(!d(h)&&!((Y==="stop"||Y==="restart")&&!await pe(Y,se))){k(p,{...d(p),[se]:(d(p)[se]??0)+1},!0),k(h,!0);try{const he=await a[Y](se);D(he.service),k(l,{...d(l),[se]:!1},!0)}catch{k(l,{...d(l),[se]:!0},!0)}finally{k(h,!1)}}}async function Ee(Y,se){if(d(h)||Y.protected||Y.autostartPinned)return;const he=Y.name;if(await ee(he,se)){k(p,{...d(p),[he]:(d(p)[he]??0)+1},!0),k(h,!0);try{const Ne=await a.setEnabled(he,se);O(he,Ne.service),k(l,{...d(l),[he]:!1},!0)}catch(Ne){Ne instanceof ld&&Ne.code==="CONFLICT"?(O(he,{...Y,autostartPinned:!0}),k(l,{...d(l),[he]:!1},!0)):k(l,{...d(l),[he]:!0},!0)}finally{k(h,!1)}}}Gn(()=>{ie();const Y=t_(r,se=>{k(i,se,!0)});return()=>{Y(),m==null||m.abort()}});var Me=lL(),$e=v(Me);let ge;var ze=v($e),Je=v(ze),ae=S(ze,2);T(ae,"variant","secondary"),w(()=>T(ae,"disabled",d(c)||d(h)));var Se=v(ae),Te=S($e,2);{var I=Y=>{var se=iL(),he=v(se),Ne=v(he),ut=S(he),xt=v(ut);w((Lt,Dt)=>{E(Ne,Lt),E(xt,Dt)},[()=>o("services.unavailable"),()=>o("services.unavailable-description")]),C(Y,se)},K=Y=>{var se=sL(),he=v(se),Ne=v(he),ut=S(he,2);T(ut,"variant","secondary");var xt=v(ut);w((Lt,Dt)=>{E(Ne,Lt),E(xt,Dt)},[()=>o("services.load-failed"),()=>o("common.retry")]),de("click",ut,()=>void ie()),C(Y,se)},we=Y=>{var se=oL(),he=v(se);w(Ne=>E(he,Ne),[()=>o("packages.loading")]),C(Y,se)},De=Y=>{{let se=G(()=>o("services.empty")),he=G(()=>o("services.empty-next")),Ne=G(()=>({label:o("services.refresh"),onActivate:()=>void ie(),variant:"secondary"}));Zi(Y,{mode:"compact",get title(){return d(se)},get text(){return d(he)},get action(){return d(Ne)}})}},ke=Y=>{var se=aL(),he=v(se);w(()=>T(he,"columns",d(A))),w(()=>T(he,"rows",d(_))),T(he,"rowKey",Ne=>Ne.service.name),w(()=>T(he,"hiddenColumns",d(i)?["state","autostart"]:[])),w(()=>T(he,"min-width",d(i)?"":"42rem")),T(he,"columnMenu",!1),T(he,"rowLabel",Ne=>Ne.service.label),w(()=>T(he,"emptyLabel",o("services.empty"))),Pe(he,1,"svelte-3v3gj2"),C(Y,se)};W(Te,Y=>{d(u)?Y(I):d(f)?Y(K,1):d(c)&&d(n).length===0?Y(we,2):!d(c)&&d(n).length===0?Y(De,3):Y(ke,-1)})}Br(Me,Y=>r=Y,()=>r),w((Y,se)=>{Ae(Me,"data-locale",V.locale),ge=Pe($e,1,"header-row mndw-table-controls svelte-3v3gj2",null,ge,{compact:d(i)}),E(Je,Y),E(Se,se)},[()=>o("services.description"),()=>o("services.refresh")]),de("click",ae,()=>void ie()),C(t,Me),We()}bt(["click"]);function hd(t){return t==="services"?gt.packageServices:gt.packages}function uL(t){const e=t.replace(/\/+$/,"")||"/";return e===gt.packages?"packages":e===gt.packageServices?"services":null}const Zp=[{id:"packages",path:hd("packages"),labelKey:"packages.tab"},{id:"services",path:hd("services"),labelKey:"services.tab"}];var dL=N("<mndw-tab> </mndw-tab>",2),fL=N('<div class="package-manager svelte-1qomr7d"><h1 class="page-title svelte-1qomr7d"> </h1> <mndw-tabs><!> <mndw-tab-panel><!></mndw-tab-panel> <mndw-tab-panel><!></mndw-tab-panel></mndw-tabs></div>',2);function hL(t,e){Ze(e,!0);const n=yn(),r=n.locale.hostT,i=G(()=>{var y;const _=((y=n.router.current)==null?void 0:y.route.pathname)??globalThis.location.pathname;return uL(_)??"packages"});function s(_){const y=Zp.find(L=>L.id===_.detail.value),R=n.router.current;y!==void 0&&R!==void 0&&R.navigate(hd(y.id))}var o=fL(),a=v(o),l=v(a),c=S(a,2);Pe(c,1,"mndw-table-controls"),w(()=>T(c,"value",d(i)));var u=v(c);Mt(u,17,()=>Zp,_=>_.id,(_,y)=>{var R=dL();w(()=>T(R,"id",d(y).id));var L=v(R);w(P=>E(L,P),[()=>r(d(y).labelKey)]),C(_,R)});var f=S(u,2);T(f,"for","packages");var h=v(f);{var p=_=>{VN(_,{})};W(h,_=>{d(i)==="packages"&&_(p)})}var g=S(f,2);T(g,"for","services");var m=v(g);{var b=_=>{cL(_,{})};W(m,_=>{d(i)==="services"&&_(b)})}w(_=>{Ae(o,"data-locale",V.locale),E(l,_)},[()=>r("nav.package-manager")]),Pt("mndwchange",c,s),C(t,o),We()}function Wp(t){hL(t,{})}const qp=4096,Kp=[{title:"mndwd diagnostics",path:"/api/mndw/diagnostics/export",method:"POST"},{title:"persistent rci-session capability",path:"/api/mndw/rci-session/capability"}],pL=[/(["']?(?:password|passwd|token|secret|authorization|cookie|x-ndma-tkn)["']?\s*:\s*)("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[^,\s}\]]+)/gi,/(\b(?:password|passwd|token|secret|authorization|cookie|x-ndma-tkn)\s*[=:]\s*)("[^"\r\n]*"|'[^'\r\n]*'|[^\s,;&]+)/gi],gL={createObjectURL:t=>globalThis.URL.createObjectURL(t),revokeObjectURL:t=>{globalThis.URL.revokeObjectURL(t)},createAnchor:()=>document.createElement("a"),appendAnchor:t=>{document.body.appendChild(t)},removeAnchor:t=>{t.remove()}},mL={request:bo,now:()=>new Date,browser:gL};async function vL(t=mL){const n=(await Promise.allSettled(Kp.map(async c=>{const u={};return"method"in c?u.method=c.method:u.csrf=!0,await _a(t.request,(h,p,g,m)=>new ba(h,p,g,m)).request(c.path,u)}))).map((c,u)=>{const f=Kp[u];return c.status==="fulfilled"?{title:f.title,value:c.value}:{title:f.title,error:_L(c.reason)}}),r=t.now(),i=bL(n,r),s=new Blob([i],{type:"text/plain;charset=utf-8"}),o=t.browser.createObjectURL(s);let a,l=!1;try{a=t.browser.createAnchor(),a.href=o,a.download=`mndw-diagnostics-${yL(r)}.txt`,a.hidden=!0,t.browser.appendAnchor(a),l=!0,a.click()}finally{a!==void 0&&l&&t.browser.removeAnchor(a),t.browser.revokeObjectURL(o)}}function bL(t,e){const n=["MNDW diagnostics",`Generated at: ${e.toISOString()}`,""];for(const r of t){if(n.push(`## ${r.title}`),r.error!==void 0)n.push(`request failed: ${pd(r.error)}`);else{const i=JSON.stringify(r.value,null,2);n.push(i===void 0?"undefined":i)}n.push("")}return wL(n.join(`
89
+ `))}function _L(t){return t instanceof Error?pd(t.message):pd(String(t))}function pd(t){return t.length>qp?`${t.slice(0,qp)}…`:t}function wL(t){let e=t;for(const n of pL)e=e.replace(n,"$1[REDACTED]");return e}function yL(t){const e=n=>String(n).padStart(2,"0");return`${t.getUTCFullYear()}${e(t.getUTCMonth()+1)}${e(t.getUTCDate())}-${e(t.getUTCHours())}${e(t.getUTCMinutes())}${e(t.getUTCSeconds())}`}var kL=N('<section class="mndw-diagnostics-settings svelte-np0xnl"><h3 class="svelte-np0xnl"> </h3> <p class="svelte-np0xnl"> </p> <mndw-button> </mndw-button></section>',2);function EL(t,e){Ze(e,!0);const n="settings.diagnostics.download";let r=te(!1),i=!1;si(()=>{i=!0});async function s(){k(r,!0);try{if(await vL(),i)return;Xe.dismissKey(n)}catch{if(i)return;Xe.error(M("settings.diagnostics-failed"),{key:n})}finally{i||k(r,!1)}}var o=kL(),a=v(o),l=v(a),c=S(a,2),u=v(c),f=S(c,2);T(f,"variant","secondary"),w(()=>T(f,"disabled",d(r)));var h=v(f);w((p,g,m,b)=>{Ae(o,"data-locale",V.locale),Ae(o,"aria-label",p),E(l,g),E(u,m),E(h,b)},[()=>M("settings.diagnostics-tab"),()=>M("settings.diagnostics-tab"),()=>M("settings.diagnostics-description"),()=>d(r)?M("settings.downloading"):M("settings.download-diagnostics")]),de("click",f,()=>void s()),C(t,o),We()}bt(["click"]);var SL=N("<mndw-button> </mndw-button>",2);function TL(t,e){Ze(e,!0);function n(){const s=new Blob([JSON.stringify(e.read(),null,2)],{type:"application/json"}),o=URL.createObjectURL(s),a=document.createElement("a");a.href=o,a.download="mndw-palette.json",a.click(),URL.revokeObjectURL(o)}var r=SL();T(r,"variant","secondary"),w(()=>T(r,"disabled",e.disabled));var i=v(r);w(s=>E(i,s),[()=>M("settings.palette.export")]),de("click",r,n),C(t,r),We()}bt(["click"]);var xL=N('<label class="mndw-palette-import svelte-q9ugi0"><input accept=".json,application/json" type="file" class="svelte-q9ugi0"/> <span> </span></label>');function CL(t,e){Ze(e,!0);async function n(u){let f;try{f=await u.text()}catch(g){console.error("[mndw] Could not read palette file:",g),e.onErrors([M("settings.palette.read-failed")]);return}let h;try{h=JSON.parse(f)}catch(g){console.error("[mndw] Could not parse palette JSON:",g),e.onErrors([M("settings.palette.invalid-json")]);return}const p=Wv(h);if(p.palette===null){console.error("[mndw] Imported palette is invalid:",p.structuralErrors),e.onErrors([M("settings.palette.invalid-structure")]);return}e.onPreview(p.palette,p.contrastWarnings)}function r(u){e.disabled||(e.onImportStart(),n(u))}function i(u){var p;const f=u.currentTarget,h=(p=f.files)==null?void 0:p[0];h&&r(h),f.value=""}function s(u){var h;u.preventDefault();const f=(h=u.dataTransfer)==null?void 0:h.files[0];f&&r(f)}var o=xL(),a=v(o),l=S(a,2),c=v(l);w((u,f)=>{Ae(a,"aria-label",u),a.disabled=e.disabled,E(c,f)},[()=>M("settings.palette-import-aria-label"),()=>M("settings.palette.drop")]),Pt("dragover",o,u=>u.preventDefault()),Pt("drop",o,s),de("change",a,i),C(t,o),We()}bt(["change"]);var PL=N('<li class="svelte-1cguif5"><span class="mndw-palette-preview__chip svelte-1cguif5"></span> </li>'),RL=N('<div><h4> </h4> <ul class="mndw-palette-preview__swatches svelte-1cguif5"></ul></div>'),AL=N("<li> </li>"),OL=N('<div class="mndw-palette-preview__warnings svelte-1cguif5"><h4> </h4> <ul></ul></div>'),ML=N('<div class="mndw-alert mndw-alert--danger" role="alert"> </div>'),NL=N('<div class="mndw-palette-preview svelte-1cguif5"><p> </p> <!> <!> <!> <div class="mndw-palette-preview__actions svelte-1cguif5"><mndw-button> </mndw-button> <mndw-button> </mndw-button></div></div>',2);function LL(t,e){Ze(e,!0);const n=["dark","light"];let r=G(()=>n.map(_=>({theme:_,entries:e.warnings.filter(y=>y.theme===_)})));function i(_){return M(_==="dark"?"settings.palette.theme-dark":"settings.palette.theme-light")}var s=NL(),o=v(s),a=v(o),l=S(o,2);Mt(l,16,()=>n,_=>_,(_,y)=>{var R=RL(),L=v(R),P=v(L),A=S(L,2);Mt(A,21,()=>Kd,O=>O.token,(O,D)=>{var z=PL(),B=v(z),j=S(B);w(()=>{cl(B,`background: ${e.palette[y][d(D).token]??""}`),E(j,` ${d(D).token??""}`)}),C(O,z)}),w(O=>E(P,O),[()=>i(y)]),C(_,R)});var c=S(l,2);Mt(c,17,()=>d(r),_=>_.theme,(_,y)=>{var R=_n(),L=tt(R);{var P=A=>{var O=OL(),D=v(O),z=v(D),B=S(D,2);Mt(B,21,()=>d(y).entries,j=>j.pair,(j,q)=>{var ie=AL(),ve=v(ie);w(pe=>E(ve,pe),[()=>M("settings.palette.warning-item",{pair:d(q).pair,ratio:d(q).ratio,min:d(q).min})]),C(j,ie)}),w(j=>E(z,j),[()=>M("settings.palette.contrast-warnings",{theme:i(d(y).theme)})]),C(A,O)};W(L,A=>{d(y).entries.length>0&&A(P)})}C(_,R)});var u=S(c,2);{var f=_=>{var y=ML(),R=v(y);w(()=>E(R,e.error)),C(_,y)};W(u,_=>{e.error&&_(f)})}var h=S(u,2),p=v(h);T(p,"variant","primary"),w(()=>T(p,"disabled",e.busy));var g=v(p),m=S(p,2);T(m,"variant","ghost"),w(()=>T(m,"disabled",e.busy));var b=v(m);w((_,y,R)=>{E(a,_),E(g,y),E(b,R)},[()=>M("settings.palette.preview-note"),()=>M("settings.palette.confirm"),()=>M("settings.palette.discard")]),de("click",p,function(..._){var y;(y=e.onConfirm)==null||y.apply(this,_)}),de("click",m,function(..._){var y;(y=e.onDiscard)==null||y.apply(this,_)}),C(t,s),We()}bt(["click"]);var IL=N("<p> </p> <mndw-button> </mndw-button> <mndw-button> </mndw-button>",3),zL=N("<mndw-button> </mndw-button>",2),DL=N('<div class="mndw-palette-reset svelte-16mndpw"><!></div>');function HL(t,e){Ze(e,!0);let n=te(!1);function r(){e.busy||e.disabled||k(n,!0)}function i(){k(n,!1),e.onReset()}var s=DL(),o=v(s);{var a=c=>{var u=IL(),f=tt(u),h=v(f),p=S(f,2);T(p,"variant","danger"),w(()=>T(p,"disabled",e.busy||e.disabled));var g=v(p),m=S(p,2);T(m,"variant","secondary"),w(()=>T(m,"disabled",e.busy||e.disabled));var b=v(m);w((_,y,R)=>{E(h,_),E(g,y),E(b,R)},[()=>M("settings.palette.reset-confirmation"),()=>M("settings.palette.reset-confirm"),()=>M("common.cancel")]),de("click",p,i),de("click",m,()=>k(n,!1)),C(c,u)},l=c=>{var u=zL();T(u,"variant","danger"),w(()=>T(u,"disabled",e.busy||e.disabled));var f=v(u);w(h=>E(f,`${h??""}${e.busy?"…":""}`),[()=>M("settings.palette.reset")]),de("click",u,r),C(c,u)};W(o,c=>{d(n)?c(a):c(l,-1)})}C(t,s),We()}bt(["click"]);function Ll(t){return`${fm/1048576} ${t("settings.plugin-manager.upload-limit-unit")}`}var BL=N('<div class="mndw-alert mndw-alert--danger" role="alert"> <mndw-button> </mndw-button> <mndw-button> </mndw-button></div>',2),Yp=N('<p role="status"> </p>'),UL=N("<li> </li>"),jL=N('<div class="mndw-alert mndw-alert--danger" role="alert"><ul></ul> <mndw-button> </mndw-button></div>',2),$L=N('<!> <!> <!> <div class="mndw-palette-manager__actions svelte-1adkxr0"><!> <!></div>',1),FL=N('<section class="mndw-palette-manager svelte-1adkxr0"><h3> </h3> <!> <!> <!></section>');function GL(t,e){Ze(e,!0);const n="settings.palette.commit",r="settings.palette.reset";let i=te("loading");const s=yn(),o=s.palette,a=s.locale.hostT;let l=te(""),c=te(pt([])),u=te(""),f=te(null),h=te(pt([])),p=!1;si(()=>{p=!0});let g=G(()=>d(i)==="loading"||d(i)==="importing"||d(i)==="previewing"||d(i)==="committing"||d(i)==="resetting"),m=G(()=>d(i)!=="idle"),b=G(()=>d(i)!=="idle");function _(ge,ze){const Je=vf(ge,a,()=>Ll(a));return ge instanceof Error&&Je===ge.message?(console.error("[mndw] Palette operation failed:",ge),a(ze)):Je}async function y(){if(!(d(i)!=="loading"&&d(i)!=="idle")){k(i,"loading");try{if(await o.refreshPalette(),p)return;k(l,"")}catch(ge){if(p)return;k(l,_(ge,"settings.palette.load-failed"),!0)}finally{p||k(i,"idle")}}}function R(){k(l,"")}Gn(()=>{y()});function L(){k(c,[],!0),k(u,""),k(i,"importing")}function P(ge,ze){k(c,[],!0),k(u,""),k(f,ge,!0),k(h,ze,!0),o.previewOverride(ge),k(i,"previewing")}function A(ge){k(c,ge,!0),k(i,"importError")}function O(){k(c,[],!0),k(i,"idle")}async function D(){if(d(f)!==null){k(i,"committing"),k(u,"");try{if(await o.commitOverride(d(f)),p)return;k(f,null),k(h,[],!0),Xe.success(a("settings.palette.saved"),{key:n}),k(i,"idle")}catch(ge){if(p)return;k(u,_(ge,"settings.palette.operation-failed"),!0),k(i,"previewing")}}}function z(){o.discardPreview(),k(f,null),k(h,[],!0),k(u,""),k(i,"idle")}async function B(){k(i,"resetting");try{if(await o.resetToDefault(),p)return;Xe.dismissKey(r)}catch(ge){if(p)return;Xe.error(_(ge,"settings.palette.operation-failed"),{key:r})}finally{p||k(i,"idle")}}var j=FL(),q=v(j),ie=v(q),ve=S(q,2);{var pe=ge=>{var ze=BL(),Je=v(ze),ae=S(Je);T(ae,"variant","secondary"),w(()=>T(ae,"disabled",d(i)!=="idle"));var Se=v(ae),Te=S(ae,2);T(Te,"variant","ghost");var I=v(Te);w((K,we)=>{E(Je,`${d(l)??""} `),E(Se,K),E(I,we)},[()=>a("common.retry"),()=>a("settings.plugin-manager.dismiss")]),de("click",ae,()=>void y()),de("click",Te,R),C(ge,ze)};W(ve,ge=>{d(l)&&ge(pe)})}var ee=S(ve,2);{var be=ge=>{var ze=Yp(),Je=v(ze);w(ae=>E(Je,ae),[()=>a("settings.palette.loading")]),C(ge,ze)};W(ee,ge=>{d(i)==="loading"&&ge(be)})}var Ee=S(ee,2);{var Me=ge=>{var ze=_n(),Je=tt(ze);{var ae=Se=>{{let Te=G(()=>d(i)==="committing");LL(Se,{get busy(){return d(Te)},get error(){return d(u)},onConfirm:()=>void D(),onDiscard:z,get palette(){return d(f)},get warnings(){return d(h)}})}};W(Je,Se=>{d(f)&&Se(ae)})}C(ge,ze)},$e=ge=>{var ze=$L(),Je=tt(ze);{var ae=ke=>{var Y=Yp(),se=v(Y);w(he=>E(se,he),[()=>a("settings.palette.reading")]),C(ke,Y)};W(Je,ke=>{d(i)==="importing"&&ke(ae)})}var Se=S(Je,2);CL(Se,{get disabled(){return d(g)},onErrors:A,onImportStart:L,onPreview:P});var Te=S(Se,2);{var I=ke=>{var Y=jL(),se=v(Y);Mt(se,20,()=>d(c),ut=>ut,(ut,xt)=>{var Lt=UL(),Dt=v(Lt);w(()=>E(Dt,xt)),C(ut,Lt)});var he=S(se,2);T(he,"variant","ghost");var Ne=v(he);w(ut=>E(Ne,ut),[()=>a("settings.plugin-manager.dismiss")]),de("click",he,O),C(ke,Y)};W(Te,ke=>{d(i)==="importError"&&ke(I)})}var K=S(Te,2),we=v(K);TL(we,{get disabled(){return d(m)},get read(){return o.getExportable}});var De=S(we,2);{let ke=G(()=>d(i)==="resetting");HL(De,{get busy(){return d(ke)},get disabled(){return d(b)},onReset:()=>void B()})}C(ge,ze)};W(Ee,ge=>{d(i)==="previewing"||d(i)==="committing"?ge(Me):ge($e,-1)})}w(ge=>E(ie,ge),[()=>a("settings.palette.title")]),C(t,j),We()}bt(["click"]);var VL=N("<mndw-option>Pseudo (en-XA)</mndw-option>",2),ZL=N('<span role="status"> </span>'),WL=N("<ul><li><strong> </strong> </li> <li><strong> </strong> </li> <li><strong> </strong> </li></ul>"),qL=N("<p> </p>"),Ha=N('<p role="status"> </p>'),Xp=N('<div class="mndw-alert mndw-alert--danger" role="alert"><p> </p> <mndw-button> </mndw-button></div>',2),KL=N("<mndw-field><mndw-switch></mndw-switch></mndw-field> <p> </p>",3),YL=N('<p role="alert"> </p>'),XL=N("<mndw-button> </mndw-button>",2),JL=N('<p class="unsupported-banner svelte-1vnn4f1" role="alert"> </p>'),QL=N('<mndw-field><mndw-input></mndw-input></mndw-field> <p id="mndw-controller-token-hint" class="persistent-rci-hint svelte-1vnn4f1"> </p> <div class="persistent-rci-actions svelte-1vnn4f1"><mndw-button> </mndw-button> <mndw-button> </mndw-button> <!></div> <!>',3),eI=N("<mndw-field><mndw-switch></mndw-switch></mndw-field> <!> <!> <!>",3),tI=N("<span> </span>"),nI=N("<li> <!></li>"),rI=N("<ul></ul>"),iI=N('<details class="persistent-rci-extenders svelte-1vnn4f1"><summary class="svelte-1vnn4f1"><!> <!></summary> <!></details>'),sI=N("<!> <!>",1),oI=N('<p> <a href="#mndw-background-router-access"> </a></p>'),aI=N('<div class="mndw-general-settings svelte-1vnn4f1"><section><h3> </h3> <mndw-field><mndw-switch></mndw-switch></mndw-field> <mndw-field><mndw-select><mndw-option> </mndw-option> <mndw-option> </mndw-option> <!></mndw-select> <!></mndw-field></section> <!> <section><h3> </h3> <!></section> <section id="mndw-background-router-access" tabindex="-1"><h3> </h3> <p> </p> <!></section> <section id="mndw-telemetry"><h3> </h3> <mndw-field><mndw-switch></mndw-switch></mndw-field> <p> </p> <!> <p> </p> <!></section></div>',2);function lI(t,e){Ze(e,!0);const n="settings.telemetry.save",r="settings.router-access.toggle",i="settings.controller.test",s="settings.controller.save",o="settings.controller.clear",a=yn(),l=a.locale,c=a.persistentRci,u=l.hostT;let f=te(null),h=G(()=>{var J;return((J=d(f))==null?void 0:J.controller.auth)??"unknown"}),p=G(()=>{var fe;const J=(fe=d(f))==null?void 0:fe.controller.support;return J==="supported"||J==="invalid"}),g=G(()=>d(p)?u("settings.controller-token-set-placeholder"):""),m=te(!1),b=te(!0),_=te(!1),y=te(""),R=te(null),L=null,P=!1,A=te(!1),O=te(!0),D=te(""),z=G(()=>{var fe,xe;const J=(fe=d(f))==null?void 0:fe.controller.support;return((xe=d(f))==null?void 0:xe.controller.enabled)===!0&&(J==="supported"||J==="invalid")}),B=G(()=>{var J;return((J=d(f))==null?void 0:J.controller.support)==="supported"?d(f).extenders:[]}),j=G(()=>d(B).filter(J=>!J.eligible||J.state!=="live").length);Qn(()=>{var J;e.onCapabilityStateChange({visible:d(h)!=="unknown",available:((J=d(f))==null?void 0:J.controller.support)==="supported"})}),Gn(()=>{q(),ie()}),si(()=>{P=!0,k(y,""),L==null||L.abort(),L=null});async function q(){k(b,!0);try{const J=await c.getCapability();if(P)return;k(f,J,!0),k(m,d(f).controller.enabled||d(f).controller.support==="needs-token",!0),Se()}catch{if(P)return;k(f,null),k(m,!1)}finally{P||k(b,!1)}}async function ie(){k(O,!0),k(D,"");try{const J=await a.mgmtClient.getTelemetry();if(P)return;k(A,J.enabled,!0)}catch{if(P)return;k(D,u("settings.telemetry-error"),!0)}finally{P||k(O,!1)}}function ve(J){const fe=J.detail.checked??J.detail.value??!1,xe=d(A);k(A,fe,!0),k(D,""),k(O,!0),a.mgmtClient.setTelemetry(fe).then(()=>{P||(a.telemetryGathering.report(fe),Xe.dismissKey(n))}).catch(()=>{P||(k(A,xe,!0),Xe.error(u("settings.telemetry-error"),{key:n}))}).finally(()=>{P||k(O,!1)})}function pe(J){k(m,J.detail.checked??J.detail.value??!1,!0),k(R,null),d(m)||(k(y,""),L==null||L.abort(),L=null)}async function ee(J){var rt;const fe=J.detail.checked??J.detail.value??!1,xe=((rt=d(f))==null?void 0:rt.controller.enabled)??!1;k(_,!0),d(f)&&k(f,{...d(f),controller:{...d(f).controller,enabled:fe}},!0);try{if(await c.setEnabled(fe),P||(await q(),P))return;Xe.dismissKey(r)}catch(mt){if(P||(d(f)&&k(f,{...d(f),controller:{...d(f).controller,enabled:xe}},!0),await q(),P))return;Xe.error(Ee(mt),{key:r})}finally{P||k(_,!1)}}function be(J){k(y,J.detail.value,!0)}function Ee(J){if(J instanceof Ar){if(J.code==="RCI_TOKEN_INVALID")return u("settings.controller-token-rejected");if(J.code==="RCI_FIRMWARE_UNSUPPORTED")return u("settings.firmware-unsupported");if(J.code==="RCI_DEVICE_UNREACHABLE")return u("settings.device-unreachable")}return u("settings.persistent-request-failed")}async function Me(){k(_,!0),k(R,null);try{const J=await c.testController(d(y));if(P)return;ze(J,i)}catch(J){P||Xe.error(Ee(J),{key:i})}finally{P||k(_,!1)}}async function $e(){k(_,!0),k(R,null);try{const J=await c.saveController(d(y));if(P)return;ze(J,s),k(y,""),await q()}catch(J){P||Xe.error(Ee(J),{key:s})}finally{P||(k(y,""),k(_,!1))}}async function ge(){const fe=await ri(a.hostOverlay,Zo,{title:u("settings.clear-controller-session-title"),props:{message:u("settings.clear-controller-session-confirm"),confirmLabel:u("settings.clear-controller-session")}}).closed;if(!(P||fe.result!==!0)){k(_,!0);try{if(await c.clearController(),P||(k(m,!1),k(y,""),k(R,null),await q(),P))return;Xe.dismissKey(o)}catch(xe){P||Xe.error(Ee(xe),{key:o})}finally{P||k(_,!1)}}}function ze(J,fe){k(R,J,!0),J.result==="valid"?Xe.success(u("settings.controller-token-valid"),{key:fe}):J.result==="unreachable"?Xe.error(u("settings.device-unreachable"),{key:fe}):Xe.dismissKey(fe)}function Je(J){V.localeSwitchPending||l.setLocale(J.detail.value).catch(()=>{})}function ae(J){J.preventDefault();const fe=document.getElementById("mndw-background-router-access");fe&&(fe.scrollIntoView({behavior:"smooth",block:"start"}),fe.focus({preventScroll:!0}))}function Se(){if(L==null||L.abort(),!d(f)||!Te(d(f))){L=null;return}const J=new AbortController;L=J,I(J.signal)}function Te(J){return J.controller.support==="invalid"||J.extenders.some(fe=>fe.state==="establishing"||fe.state==="dead")}async function I(J){let fe=null;for(;!J.aborted&&d(f)&&Te(d(f));){if(d(f).extenders.some(xe=>xe.state==="establishing"))fe=null;else if(fe===null)fe=Date.now();else if(Date.now()-fe>=6e4)return;if(await new Promise(xe=>{const rt=window.setTimeout(xe,2e3);J.addEventListener("abort",()=>{window.clearTimeout(rt),xe()},{once:!0})}),J.aborted)return;try{k(f,await c.getCapability(),!0)}catch{}}}var K=aI(),we=v(K),De=v(we),ke=v(De),Y=S(De,2);w(()=>T(Y,"label",u("settings.dark-theme"))),Pe(Y,1,"svelte-1vnn4f1");var se=v(Y);T(se,"id","mndw-theme-switch"),w(()=>T(se,"checked",V.theme==="dark"));var he=S(Y,2);w(()=>T(he,"label",u("settings.language.label"))),Pe(he,1,"svelte-1vnn4f1");var Ne=v(he);w(()=>T(Ne,"value",V.locale)),w(()=>T(Ne,"aria-busy",String(V.localeSwitchPending)));var ut=v(Ne);T(ut,"value","en");var xt=v(ut),Lt=S(ut,2);T(Lt,"value","ru");var Dt=v(Lt),At=S(Lt,2);{var He=J=>{var fe=VL();T(fe,"value","en-XA"),C(J,fe)},ft=G(()=>l.getAvailableLocales().includes("en-XA"));W(At,J=>{d(ft)&&J(He)})}var yt=S(Ne,2);{var Zt=J=>{var fe=ZL(),xe=v(fe);w(rt=>E(xe,rt),[()=>u("settings.language.pending")]),C(J,fe)};W(yt,J=>{V.localeSwitchPending&&J(Zt)})}var $t=S(we,2);GL($t,{});var kn=S($t,2),Wt=v(kn),qt=v(Wt),an=S(Wt,2);{var En=J=>{var fe=WL(),xe=v(fe),rt=v(xe),mt=v(rt),It=S(rt),Kt=S(xe,2),en=v(Kt),H=v(en),oe=S(en),ye=S(Kt,2),Ge=v(ye),qe=v(Ge),_t=S(Ge);w((je,tn,Pr)=>{E(mt,je),E(It,` ${V.deviceInfo.deviceName??""}`),E(H,tn),E(oe,` ${V.deviceInfo.vendor??""}`),E(qe,Pr),E(_t,` ${V.deviceInfo.firmwareVersion??""}`)},[()=>u("settings.name"),()=>u("settings.vendor"),()=>u("settings.firmware")]),C(J,fe)},Rn=J=>{var fe=qL(),xe=v(fe);w(rt=>E(xe,rt),[()=>u("settings.device-unavailable")]),C(J,fe)};W(an,J=>{V.deviceInfo?J(En):J(Rn,-1)})}var Sn=S(kn,2),F=v(Sn),ne=v(F),re=S(F,2),Q=v(re),Fe=S(re,2);{var nt=J=>{var fe=Ha(),xe=v(fe);w(rt=>E(xe,rt),[()=>u("settings.persistent-loading")]),C(J,fe)},Ot=J=>{var fe=sI(),xe=tt(fe);{var rt=H=>{var oe=Xp(),ye=v(oe),Ge=v(ye),qe=S(ye,2);T(qe,"variant","secondary");var _t=v(qe);w((je,tn)=>{E(Ge,je),E(_t,tn)},[()=>u("settings.persistent-state-unavailable"),()=>u("common.retry")]),de("click",qe,()=>void q()),C(H,oe)},mt=H=>{var oe=KL(),ye=tt(oe);w(()=>T(ye,"label",u("settings.persistent-tokenless-toggle"))),Pe(ye,1,"svelte-1vnn4f1");var Ge=v(ye);T(Ge,"id","mndw-persistent-rci-enabled"),w(()=>{var je;return T(Ge,"checked",((je=d(f))==null?void 0:je.controller.enabled)??!1)}),w(()=>T(Ge,"disabled",d(_)));var qe=S(ye,2),_t=v(qe);w(je=>E(_t,je),[()=>u("settings.persistent-tokenless-description")]),Pt("mndwchange",Ge,je=>void ee(je)),C(H,oe)},It=H=>{var oe=eI(),ye=tt(oe);w(()=>T(ye,"label",u("settings.configure-persistent"))),Pe(ye,1,"svelte-1vnn4f1");var Ge=v(ye);T(Ge,"id","mndw-persistent-rci-enabled"),w(()=>T(Ge,"checked",d(m))),w(()=>T(Ge,"disabled",d(b)||d(_)));var qe=S(ye,2);{var _t=Tt=>{var et=Ha(),st=v(et);w(Ft=>E(st,Ft),[()=>u("settings.persistent-storage-disabled")]),C(Tt,et)},je=Tt=>{var et=YL(),st=v(et);w(Ft=>E(st,Ft),[()=>u("settings.persistent-storage-decrypt-failed")]),C(Tt,et)};W(qe,Tt=>{var et,st;((et=d(f))==null?void 0:et.store.state)==="disabled"?Tt(_t):((st=d(f))==null?void 0:st.store.state)==="decrypt-failed"&&Tt(je,1)})}var tn=S(qe,2);{var Pr=Tt=>{var et=Ha(),st=v(et);w(Ft=>E(st,Ft),[()=>u("settings.persistent-needs-token")]),C(Tt,et)};W(tn,Tt=>{var et;((et=d(f))==null?void 0:et.controller.support)==="needs-token"&&Tt(Pr)})}var Qs=S(tn,2);{var Vt=Tt=>{var et=QL(),st=tt(et);w(()=>T(st,"label",u("settings.controller-token"))),Pe(st,1,"svelte-1vnn4f1");var Ft=v(st);T(Ft,"type","password"),T(Ft,"autocomplete","off"),T(Ft,"aria-describedby","mndw-controller-token-hint"),w(()=>T(Ft,"placeholder",d(g))),w(()=>T(Ft,"value",d(y))),w(()=>T(Ft,"disabled",d(_)));var nn=S(st,2),mc=v(nn),wa=S(nn,2),Oi=v(wa);T(Oi,"variant","secondary"),w(()=>T(Oi,"disabled",d(_)||d(y)===""));var li=v(Oi),hr=S(Oi,2);T(hr,"variant","primary"),w(()=>T(hr,"disabled",d(_)||d(y)===""));var eo=v(hr),a_=S(hr,2);{var l_=jr=>{var Rr=XL();T(Rr,"variant","danger"),w(()=>T(Rr,"disabled",d(_)));var to=v(Rr);w(vc=>E(to,vc),[()=>u("settings.clear-controller-session")]),de("click",Rr,()=>void ge()),C(jr,Rr)};W(a_,jr=>{d(p)&&jr(l_)})}var c_=S(wa,2);{var u_=jr=>{var Rr=_n(),to=tt(Rr);{var vc=Qi=>{var no=Ha(),bc=v(no);w(_c=>E(bc,_c),[()=>u("settings.update-firmware-persistent")]),C(Qi,no)},d_=Qi=>{var no=JL(),bc=v(no);w(_c=>E(bc,_c),[()=>u("settings.controller-token-rejected")]),C(Qi,no)};W(to,Qi=>{d(R).result==="unsupported-firmware"?Qi(vc):d(R).result==="invalid-token"&&Qi(d_,1)})}C(jr,Rr)};W(c_,jr=>{d(R)&&jr(u_)})}w((jr,Rr,to)=>{E(mc,jr),E(li,Rr),E(eo,to)},[()=>u("settings.controller-token-hint"),()=>u("settings.test"),()=>u("settings.save")]),Pt("mndwinput",Ft,be),de("click",Oi,()=>void Me()),de("click",hr,()=>void $e()),C(Tt,et)};W(Qs,Tt=>{var et;(d(m)||((et=d(f))==null?void 0:et.controller.support)==="needs-token")&&Tt(Vt)})}Pt("mndwchange",Ge,pe),C(H,oe)};W(xe,H=>{d(h)==="unknown"?H(rt):d(h)==="none"?H(mt,1):H(It,-1)})}var Kt=S(xe,2);{var en=H=>{var oe=iI(),ye=v(oe),Ge=v(ye);{var qe=Vt=>{var Tt=ka();w(et=>E(Tt,et),[()=>u("settings.persistent-extenders-summary-problems",{count:d(B).length,problems:d(j)})]),C(Vt,Tt)},_t=Vt=>{var Tt=ka();w(et=>E(Tt,et),[()=>u("settings.persistent-extenders-summary",{count:d(B).length})]),C(Vt,Tt)};W(Ge,Vt=>{d(j)>0?Vt(qe):Vt(_t,-1)})}var je=S(Ge,2);{var tn=Vt=>{var Tt=tI(),et=v(Tt);w(st=>E(et,`— ${st??""}`),[()=>u("settings.persistent-enumeration-stale")]),C(Vt,Tt)};W(je,Vt=>{d(f).stale&&Vt(tn)})}var Pr=S(ye,2);{var Qs=Vt=>{var Tt=rI();Mt(Tt,21,()=>d(B),et=>et.identity,(et,st)=>{var Ft=nI(),nn=v(Ft),mc=S(nn);{var wa=li=>{var hr=ka();w(eo=>E(hr,eo),[()=>u(`settings.extender-reason-${d(st).reason}`)]),C(li,hr)},Oi=li=>{var hr=ka();w(eo=>E(hr,eo),[()=>u(`settings.extender-state-${d(st).state??"establishing"}`)]),C(li,hr)};W(mc,li=>{d(st).eligible?li(Oi,-1):li(wa)})}w(()=>E(nn,`${(d(st).name||d(st).identity)??""}: `)),C(et,Ft)}),C(Vt,Tt)};W(Pr,Vt=>{d(B).length>0&&Vt(Qs)})}C(H,oe)};W(Kt,H=>{var oe;((oe=d(f))==null?void 0:oe.controller.support)==="supported"&&H(en)})}C(J,fe)};W(Fe,J=>{d(b)?J(nt):J(Ot,-1)})}var $=S(Sn,2),le=v($),Ie=v(le),at=S(le,2);w(()=>T(at,"label",u("settings.telemetry-toggle"))),Pe(at,1,"svelte-1vnn4f1");var Zn=v(at);T(Zn,"id","mndw-telemetry-enabled"),w(()=>T(Zn,"checked",d(A))),w(()=>T(Zn,"disabled",d(O)||!d(z)));var Wn=S(at,2),fr=v(Wn),ue=S(Wn,2);{var Re=J=>{var fe=oI(),xe=v(fe),rt=S(xe),mt=v(rt);w((It,Kt)=>{E(xe,`${It??""} `),E(mt,Kt)},[()=>u("settings.telemetry-session-note"),()=>u("settings.telemetry-session-link")]),de("click",rt,ae),C(J,fe)};W(ue,J=>{d(z)||J(Re)})}var it=S(ue,2),dt=v(it),ln=S(it,2);{var hn=J=>{var fe=Xp(),xe=v(fe),rt=v(xe),mt=S(xe,2);T(mt,"variant","secondary");var It=v(mt);w(Kt=>{E(rt,d(D)),E(It,Kt)},[()=>u("common.retry")]),de("click",mt,()=>void ie()),C(J,fe)};W(ln,J=>{d(D)&&J(hn)})}w((J,fe,xe,rt,mt,It,Kt,en,H,oe,ye)=>{Ae(K,"data-locale",V.locale),E(ke,J),E(xt,fe),E(Dt,xe),E(qt,rt),Ae(Sn,"aria-label",mt),E(ne,It),E(Q,Kt),Ae($,"aria-label",en),E(Ie,H),E(fr,oe),E(dt,ye)},[()=>u("settings.appearance"),()=>u("settings.language.english"),()=>u("settings.language.russian"),()=>u("settings.device"),()=>u("settings.persistent-rci-title"),()=>u("settings.persistent-rci-title"),()=>u("settings.persistent-rci-description"),()=>u("settings.telemetry-label"),()=>u("settings.telemetry-label"),()=>u("settings.telemetry-description"),()=>u("settings.telemetry-wear-note")]),Pt("mndwchange",se,function(...J){var fe;(fe=a.theme.toggleTheme)==null||fe.apply(this,J)}),Pt("mndwchange",Ne,Je),Pt("mndwchange",Zn,ve),C(t,K),We()}bt(["click"]);var cI=N('<span class="mndw-installed__description svelte-egoe9l"> </span>'),uI=N('<span class="mndw-installed__builtin svelte-egoe9l"> </span>'),dI=N('<span class="mndw-installed__deps-badge svelte-egoe9l"> </span>'),fI=N('<span class="mndw-installed__deps-badge mndw-installed__deps-badge--failed svelte-egoe9l"> </span>'),hI=N('<span class="mndw-installed__deps-badge mndw-installed__deps-badge--failed mndw-installed__load-failed-badge svelte-egoe9l"> </span>'),Jp=N('<span class="mndw-installed__version-badge svelte-egoe9l"> </span>'),pI=N('<p class="mndw-installed__load-failed-reason svelte-egoe9l"> </p>'),gI=N('<!> <div class="mndw-installed__actions svelte-egoe9l"><mndw-button> </mndw-button></div>',3),Qp=N('<p class="mndw-installed__version-warning svelte-egoe9l"> </p>'),mI=N('<p class="mndw-installed__backend svelte-egoe9l"> </p>'),vI=N("<mndw-field><mndw-switch></mndw-switch></mndw-field>",2),bI=N("<mndw-button> </mndw-button> <mndw-button> </mndw-button>",3),_I=N('<div><span class="svelte-egoe9l"> </span> <!></div>'),eg=N("<mndw-button> </mndw-button>",2),wI=N('<div class="mndw-installed__confirmation svelte-egoe9l"><p class="svelte-egoe9l"> </p> <mndw-button> </mndw-button> <mndw-button> </mndw-button></div>',2),yI=N("<!> <!>",1),kI=N('<p class="mndw-installed__runtime svelte-egoe9l"> </p>'),EI=N('<li class="mndw-installed__item svelte-egoe9l"><div class="mndw-installed__identity svelte-egoe9l"><strong class="svelte-egoe9l"> </strong> <!></div> <div class="mndw-installed__metadata svelte-egoe9l"><span> </span> <span> </span> <!> <!> <!> <!> <!></div> <!> <!> <!> <!> <!> <!> <div class="mndw-installed__actions svelte-egoe9l"><mndw-button> </mndw-button> <!></div> <!></li>',2),SI=N('<ul class="mndw-installed__list svelte-egoe9l"></ul>'),TI=N('<section class="mndw-installed svelte-egoe9l" aria-labelledby="mndw-installed-title"><h3 id="mndw-installed-title" class="svelte-egoe9l"> </h3> <!></section>');function xI(t,e){Ze(e,!0);function n(A){const O=[],D=Object.values(A.routes??{}),z=D.filter(j=>j.transport==="http").length,B=D.filter(j=>j.transport==="websocket").length;return z>0&&O.push(M("settings.plugin-manager.endpoint",{count:z})),B>0&&O.push(M("settings.plugin-manager.websocket",{count:B})),O}function r(A){switch(A){case"timeout":return M("settings.plugin-manager.plugin-load-timeout",{seconds:Rb/1e3});case"error":return M("settings.plugin-manager.plugin-load-error")}}function i(A,O){var D;return((D=A.capabilityGrants)==null?void 0:D[O])??!1}function s(A){return A.endsWith(":write")?M("settings.plugin-manager.persistent-rci-write"):M("settings.plugin-manager.persistent-rci-read")}function o(A){if(A===void 0)return;const O=Sb(A).find(D=>D.kind==="sdk-major");if(O!==void 0)return M("settings.plugin-manager.version-warning.sdk-major",{pluginVersion:O.pluginVersion,hostVersion:O.hostVersion})}function a(A){switch(A){case"stopped":return M("settings.plugin-manager.runtime-state-stopped");case"capacity_blocked":return M("settings.plugin-manager.runtime-state-capacity-blocked");case"starting":return M("settings.plugin-manager.runtime-state-starting");case"ready":return M("settings.plugin-manager.runtime-state-ready");case"backoff":return M("settings.plugin-manager.runtime-state-backoff");case"failed":return M("settings.plugin-manager.runtime-state-failed")}}let l=Tn(e,"rowStateFor",3,()=>{}),c=Tn(e,"capabilityVisible",3,!1),u=Tn(e,"capabilityAvailable",3,!1),f=Tn(e,"onRestart",3,()=>{}),h=Tn(e,"onRefresh",3,()=>{}),p=Tn(e,"onKeepNotice",3,()=>{}),g=pt({});function m(A){var D;const O=(D=mn(A))==null?void 0:D.failureKind;O===void 0||g[A]!==void 0||(g[A]=O,Ki(A).catch(()=>!1).finally(()=>{delete g[A]}))}var b=TI(),_=v(b),y=v(_),R=S(_,2);{var L=A=>{{let O=G(()=>M("settings.plugin-manager.no-installed")),D=G(()=>M("settings.plugin-manager.no-installed-next")),z=G(()=>({label:M("settings.upload-plugin-zip"),href:"#mndw-plugin-upload"}));Zi(A,{mode:"compact",get title(){return d(O)},get text(){return d(D)},get action(){return d(z)}})}},P=A=>{var O=SI();Mt(O,21,()=>e.items,D=>D.name,(D,z)=>{const B=G(()=>n(d(z).backend)),j=G(()=>GR(d(z).name)),q=G(()=>o(d(z).lock)),ie=G(()=>uc(d(z).name)),ve=G(()=>l()(d(z).name)),pe=G(()=>{var ue,Re;return((ue=d(ve))==null?void 0:ue.state)==="error"?"danger":((Re=d(ve))==null?void 0:Re.state)==="notice-rejected"?"warning":"info"}),ee=G(()=>{var ue;return((ue=d(ve))==null?void 0:ue.state)==="error"?"alert":"status"}),be=G(()=>{var ue,Re;return((ue=d(ve))==null?void 0:ue.state)==="working"||((Re=d(ve))==null?void 0:Re.state)==="reconciling"}),Ee=G(()=>mn(d(z).name)),Me=G(()=>{var ue;return zn(d(z),(ue=d(Ee))==null?void 0:ue.catalog,V.locale)}),$e=G(()=>{var ue;return d(z).enabled&&d(z).approval==="approved"&&((ue=d(Ee))==null?void 0:ue.runnable)===!0}),ge=G(()=>{var ue;return d($e)&&((ue=d(Ee))==null?void 0:ue.status)==="failed"}),ze=G(()=>g[d(z).name]!==void 0),Je=G(()=>d($e)&&(d(ge)||d(ze))),ae=G(()=>{var ue;return d(ge)?(ue=d(Ee))==null?void 0:ue.failureKind:g[d(z).name]}),Se=G(()=>d(ae)===void 0?void 0:r(d(ae)));var Te=EI(),I=v(Te),K=v(I),we=v(K),De=S(K,2);{var ke=ue=>{var Re=cI(),it=v(Re);w(()=>E(it,d(Me).description)),C(ue,Re)};W(De,ue=>{d(Me).description!==void 0&&ue(ke)})}var Y=S(I,2),se=v(Y),he=v(se),Ne=S(se,2),ut=v(Ne),xt=S(Ne,2);{var Lt=ue=>{var Re=uI(),it=v(Re);w(dt=>E(it,dt),[()=>M(d(z).source==="builtin"?"settings.plugin-manager.builtin":"settings.plugin-manager.uploaded")]),C(ue,Re)};W(xt,ue=>{(d(z).source==="builtin"||d(z).source==="upload")&&ue(Lt)})}var Dt=S(xt,2);{var At=ue=>{var Re=dI(),it=v(Re);w(dt=>E(it,dt),[()=>M("settings.plugin-manager.installing-dependencies")]),C(ue,Re)},He=ue=>{var Re=fI(),it=v(Re);w(dt=>E(it,dt),[()=>M("settings.plugin-manager.dependency-install-failed")]),C(ue,Re)};W(Dt,ue=>{d(ie)==="installing"?ue(At):d(ie)==="failed"&&ue(He,1)})}var ft=S(Dt,2);{var yt=ue=>{var Re=hI(),it=v(Re);w(dt=>E(it,dt),[()=>M("settings.plugin-manager.plugin-load-failed")]),C(ue,Re)};W(ft,ue=>{d(Je)&&ue(yt)})}var Zt=S(ft,2);{var $t=ue=>{var Re=Jp(),it=v(Re);w(dt=>E(it,dt),[()=>M("settings.plugin-manager.version-mismatch")]),C(ue,Re)};W(Zt,ue=>{d(j).length>0&&ue($t)})}var kn=S(Zt,2);{var Wt=ue=>{var Re=Jp(),it=v(Re);w(dt=>E(it,dt),[()=>M("settings.plugin-manager.sdk-major-badge")]),C(ue,Re)};W(kn,ue=>{d(q)!==void 0&&ue(Wt)})}var qt=S(Y,2);{var an=ue=>{var Re=gI(),it=tt(Re);{var dt=fe=>{var xe=pI(),rt=v(xe);w(()=>E(rt,d(Se))),C(fe,xe)};W(it,fe=>{d(Se)!==void 0&&fe(dt)})}var ln=S(it,2),hn=v(ln);Pe(hn,1,"mndw-installed__load-retry"),T(hn,"variant","secondary"),w(()=>T(hn,"disabled",d(ze))),w(()=>T(hn,"aria-busy",d(ze)));var J=v(hn);w(fe=>E(J,fe),[()=>M("settings.plugin-manager.retry")]),de("click",hn,()=>m(d(z).name)),C(ue,Re)};W(qt,ue=>{d(Je)&&ue(an)})}var En=S(qt,2);{var Rn=ue=>{var Re=Qp(),it=v(Re);w(dt=>E(it,dt),[()=>M("settings.plugin-manager.load-version-warning",{versions:d(j).join(", ")})]),C(ue,Re)};W(En,ue=>{d(j).length>0&&ue(Rn)})}var Sn=S(En,2);{var F=ue=>{var Re=Qp(),it=v(Re);w(()=>E(it,d(q))),C(ue,Re)};W(Sn,ue=>{d(q)!==void 0&&ue(F)})}var ne=S(Sn,2);{var re=ue=>{var Re=mI(),it=v(Re);w(dt=>E(it,dt),[()=>d(B).join(", ")]),C(ue,Re)};W(ne,ue=>{d(B).length>0&&ue(re)})}var Q=S(ne,2);{var Fe=ue=>{var Re=_n(),it=tt(Re);Mt(it,16,()=>qd,dt=>dt,(dt,ln)=>{var hn=_n(),J=tt(hn);{var fe=rt=>{var mt=vI();Pe(mt,1,"mndw-installed__capability-switch"),w(()=>T(mt,"label",s(ln)));var It=v(mt);w(()=>T(It,"checked",i(d(z),ln))),w(()=>T(It,"disabled",d(be)||!i(d(z),ln)&&!u())),Pt("mndwchange",It,Kt=>e.onCapabilityChange(d(z).name,ln,Kt.detail.checked)),C(rt,mt)},xe=G(()=>{var rt;return(rt=d(z).capabilities)==null?void 0:rt.includes(ln)});W(J,rt=>{d(xe)&&rt(fe)})}C(dt,hn)}),C(ue,Re)};W(Q,ue=>{c()&&ue(Fe)})}var nt=S(Q,2);{var Ot=ue=>{var Re=_I(),it=v(Re),dt=v(it),ln=S(it,2);{var hn=J=>{var fe=bI(),xe=tt(fe);Pe(xe,1,"mndw-installed__refresh"),T(xe,"variant","ghost");var rt=v(xe),mt=S(xe,2);Pe(mt,1,"mndw-installed__keep"),T(mt,"variant","ghost");var It=v(mt);w((Kt,en)=>{E(rt,Kt),E(It,en)},[()=>M("settings.plugin-manager.refresh"),()=>M("settings.plugin-manager.keep-notice")]),de("click",xe,function(...Kt){var en;(en=h())==null||en.apply(this,Kt)}),de("click",mt,()=>p()(d(z).name)),C(J,fe)};W(ln,J=>{(d(ve).state==="notice-finishing"||d(ve).state==="outcome-unknown")&&J(hn)})}w(()=>{Pe(Re,1,`mndw-alert mndw-alert--${d(pe)??""}`,"svelte-egoe9l"),Ae(Re,"role",d(ee)),E(dt,d(ve).message)}),C(ue,Re)};W(nt,ue=>{var Re;d(ve)!==void 0&&((Re=d(ve))==null?void 0:Re.message)!==""&&ue(Ot)})}var $=S(nt,2),le=v($);Pe(le,1,"mndw-installed__toggle"),w(()=>T(le,"variant",d(z).enabled?"secondary":"primary")),w(()=>T(le,"disabled",d(be)));var Ie=v(le),at=S(le,2);{var Zn=ue=>{var Re=yI(),it=tt(Re);{var dt=fe=>{var xe=eg();Pe(xe,1,"mndw-installed__restart"),T(xe,"variant","secondary"),w(()=>T(xe,"disabled",d(be)));var rt=v(xe);w(mt=>E(rt,mt),[()=>M("settings.plugin-manager.restart-backend")]),de("click",xe,()=>f()(d(z).name)),C(fe,xe)};W(it,fe=>{d(z).runtime&&d(z).runtime.state!=="stopped"&&fe(dt)})}var ln=S(it,2);{var hn=fe=>{var xe=wI(),rt=v(xe),mt=v(rt),It=S(rt,2);Pe(It,1,"mndw-installed__cancel"),T(It,"variant","ghost"),w(()=>T(It,"disabled",d(be)));var Kt=v(It),en=S(It,2);Pe(en,1,"mndw-installed__confirm"),T(en,"variant","danger"),w(()=>T(en,"disabled",d(be)));var H=v(en);w((oe,ye,Ge)=>{E(mt,oe),E(Kt,ye),E(H,Ge)},[()=>M("settings.plugin-manager.delete-confirmation",{label:d(Me).label}),()=>M("settings.plugin-manager.cancel"),()=>M("settings.plugin-manager.delete-plugin")]),de("click",It,function(...oe){var ye;(ye=e.onCancelConfirm)==null||ye.apply(this,oe)}),de("click",en,()=>e.onDelete(d(z).name)),C(fe,xe)},J=fe=>{var xe=eg();Pe(xe,1,"mndw-installed__delete"),T(xe,"variant","danger"),w(()=>T(xe,"disabled",d(be)));var rt=v(xe);w(mt=>E(rt,mt),[()=>M("settings.plugin-manager.delete")]),de("click",xe,()=>e.onRequestConfirm(d(z).name)),C(fe,xe)};W(ln,fe=>{e.confirmingName===d(z).name?fe(hn):fe(J,-1)})}C(ue,Re)};W(at,ue=>{d(z).source!=="builtin"&&ue(Zn)})}var Wn=S($,2);{var fr=ue=>{var Re=kI(),it=v(Re);w((dt,ln)=>E(it,`${dt??""}: ${ln??""}`),[()=>M("settings.plugin-manager.backend"),()=>a(d(z).runtime.state)]),C(ue,Re)};W(Wn,ue=>{d(z).runtime&&ue(fr)})}w((ue,Re,it)=>{E(we,d(Me).label),E(he,`${ue??""}: ${d(z).version??""}`),E(ut,Re),E(Ie,it)},[()=>M("settings.plugin-manager.version"),()=>M(d(z).type==="widget"?"settings.plugin-manager.type-widget":"settings.plugin-manager.type-page"),()=>d(z).enabled?M("settings.plugin-manager.disable"):M("settings.plugin-manager.enable")]),de("click",le,()=>d(z).enabled?e.onDisable(d(z).name):e.onEnable(d(z).name)),C(D,Te)}),C(A,O)};W(R,A=>{e.items.length===0?A(L):A(P,-1)})}w(A=>E(y,A),[()=>M("settings.plugin-manager.installed-title")]),C(t,b),We()}bt(["click"]);var CI=N("<li> </li>"),PI=N('<section class="mndw-version-warning svelte-fld8qa" role="note"><h4 class="svelte-fld8qa"> </h4> <ul class="svelte-fld8qa"></ul> <p class="svelte-fld8qa"> </p></section>');function i_(t,e){Ze(e,!0);let n=G(()=>e.lock===void 0?[]:Sb(e.lock));function r(a){return a.kind==="sdk-major"?M("settings.plugin-manager.version-warning.sdk-major",{pluginVersion:a.pluginVersion,hostVersion:a.hostVersion}):a.kind==="sdk-newer-minor"?M("settings.plugin-manager.version-warning.sdk-newer-minor",{pluginVersion:a.pluginVersion,hostVersion:a.hostVersion}):M("settings.plugin-manager.version-warning.shared-major",{name:a.name,pluginVersion:a.pluginVersion,hostVersion:a.hostVersion})}var i=_n(),s=tt(i);{var o=a=>{var l=PI(),c=v(l),u=v(c),f=S(c,2);Mt(f,21,()=>d(n),g=>`${g.kind}:${g.name}`,(g,m)=>{var b=CI(),_=v(b);w(y=>E(_,y),[()=>r(d(m))]),C(g,b)});var h=S(f,2),p=v(h);w((g,m)=>{E(u,g),E(p,m)},[()=>M("settings.plugin-manager.version-warning.title"),()=>M("settings.plugin-manager.version-warning.install-anyway")]),C(a,l)};W(s,a=>{d(n).length>0&&a(o)})}C(t,i),We()}var RI=N('<p class="mndw-cap__kind svelte-14iyjl4"> </p>'),oo=N("<li> </li>"),ao=N('<section class="mndw-cap__section svelte-14iyjl4"><h4 class="svelte-14iyjl4"> </h4> <ul class="svelte-14iyjl4"></ul></section>'),AI=N('<div class="mndw-cap svelte-14iyjl4"><!> <!> <!> <!> <!> <!> <!></div>');function s_(t,e){Ze(e,!0);let n=G(()=>Object.entries(e.entry.backend.routes??{})),r=G(()=>{var P;return((P=e.entry.review)==null?void 0:P.packages)??[]}),i=G(()=>{var P;return((P=e.entry.review)==null?void 0:P.args)??[]}),s=G(()=>{var P;return((P=e.entry.review)==null?void 0:P.publicRoutes)??[]}),o=G(()=>e.entry.capabilities??[]);var a=AI(),l=v(a);i_(l,{get lock(){return e.entry.lock}});var c=S(l,2);{var u=P=>{var A=RI(),O=v(A);w(D=>E(O,D),[()=>M(e.entry.review.kind==="service"?"settings.plugin-manager.backend-kind-service":"settings.plugin-manager.backend-kind-exec")]),C(P,A)};W(c,P=>{e.entry.review!==void 0&&P(u)})}var f=S(c,2);{var h=P=>{var A=ao(),O=v(A),D=v(O),z=S(O,2);Mt(z,20,()=>d(r),B=>B,(B,j)=>{var q=oo(),ie=v(q);w(()=>E(ie,j)),C(B,q)}),w(B=>E(D,B),[()=>M("settings.plugin-manager.packages")]),C(P,A)};W(f,P=>{d(r).length>0&&P(h)})}var p=S(f,2);{var g=P=>{var A=ao(),O=v(A),D=v(O),z=S(O,2);Mt(z,23,()=>d(i),(B,j)=>`${j}:${B}`,(B,j)=>{var q=oo(),ie=v(q);w(()=>E(ie,d(j))),C(B,q)}),w(B=>E(D,B),[()=>M("settings.plugin-manager.service-args")]),C(P,A)};W(p,P=>{d(i).length>0&&P(g)})}var m=S(p,2);{var b=P=>{var A=ao(),O=v(A),D=v(O),z=S(O,2);Mt(z,21,()=>d(n),([B,j])=>B,(B,j)=>{var q=G(()=>F_(d(j),2));let ie=()=>d(q)[0],ve=()=>d(q)[1];var pe=oo(),ee=v(pe);w(be=>E(ee,`${ie()??""}: ${ve().transport==="http"?`${ve().method??"GET"} `:""}${ve().path??""}${be??""}`),[()=>{var be;return(be=ve().protocols)!=null&&be.length?` (${ve().protocols.join(", ")})`:""}]),C(B,pe)}),w(B=>E(D,B),[()=>M("settings.plugin-manager.routes")]),C(P,A)};W(m,P=>{d(n).length>0&&P(b)})}var _=S(m,2);{var y=P=>{var A=ao(),O=v(A),D=v(O),z=S(O,2);Mt(z,20,()=>d(s),B=>B,(B,j)=>{var q=oo(),ie=v(q);w(()=>E(ie,j)),C(B,q)}),w(B=>E(D,B),[()=>M("settings.plugin-manager.public-routes")]),C(P,A)};W(_,P=>{d(s).length>0&&P(y)})}var R=S(_,2);{var L=P=>{var A=ao(),O=v(A),D=v(O),z=S(O,2);Mt(z,20,()=>d(o),B=>B,(B,j)=>{var q=oo(),ie=v(q);w(()=>E(ie,j)),C(B,q)}),w(B=>E(D,B),[()=>M("settings.plugin-manager.capabilities")]),C(P,A)};W(R,P=>{d(o).length>0&&P(L)})}C(t,a),We()}var OI=N("<mndw-button> </mndw-button> <mndw-button> </mndw-button>",3),MI=N('<div><span class="svelte-1mbpuk3"> </span> <!></div>'),NI=N('<div class="mndw-pending__confirmation svelte-1mbpuk3"><p class="svelte-1mbpuk3"> </p> <div class="mndw-pending__actions svelte-1mbpuk3"><mndw-button> </mndw-button> <mndw-button> </mndw-button></div></div>',2),LI=N('<div class="mndw-pending__actions svelte-1mbpuk3"><mndw-button> </mndw-button> <mndw-button> </mndw-button></div>',2),II=N('<li class="mndw-pending__item svelte-1mbpuk3"><div class="mndw-pending__identity svelte-1mbpuk3"><strong class="svelte-1mbpuk3"> </strong> <span class="svelte-1mbpuk3"> </span></div> <!> <!> <!></li>'),zI=N('<section class="mndw-pending svelte-1mbpuk3" aria-labelledby="mndw-pending-title"><h3 id="mndw-pending-title" class="svelte-1mbpuk3"> </h3> <ul class="mndw-pending__list svelte-1mbpuk3"></ul></section>');function DI(t,e){Ze(e,!0);let n=Tn(e,"rowStateFor",3,()=>{}),r=Tn(e,"onRefresh",3,()=>{}),i=Tn(e,"onKeepNotice",3,()=>{});var s=zI(),o=v(s),a=v(o),l=S(o,2);Mt(l,21,()=>e.items,c=>c.name,(c,u)=>{const f=G(()=>n()(d(u).name)),h=G(()=>{var j,q;return((j=d(f))==null?void 0:j.state)==="error"?"danger":((q=d(f))==null?void 0:q.state)==="notice-rejected"?"warning":"info"}),p=G(()=>{var j;return((j=d(f))==null?void 0:j.state)==="error"?"alert":"status"}),g=G(()=>{var j,q;return((j=d(f))==null?void 0:j.state)==="working"||((q=d(f))==null?void 0:q.state)==="reconciling"});var m=II(),b=v(m),_=v(b),y=v(_),R=S(_,2),L=v(R),P=S(b,2);s_(P,{get entry(){return d(u)}});var A=S(P,2);{var O=j=>{var q=MI(),ie=v(q),ve=v(ie),pe=S(ie,2);{var ee=be=>{var Ee=OI(),Me=tt(Ee);Pe(Me,1,"mndw-pending__refresh"),T(Me,"variant","ghost");var $e=v(Me),ge=S(Me,2);Pe(ge,1,"mndw-pending__keep"),T(ge,"variant","ghost");var ze=v(ge);w((Je,ae)=>{E($e,Je),E(ze,ae)},[()=>M("settings.plugin-manager.refresh"),()=>M("settings.plugin-manager.keep-notice")]),de("click",Me,function(...Je){var ae;(ae=r())==null||ae.apply(this,Je)}),de("click",ge,()=>i()(d(u).name)),C(be,Ee)};W(pe,be=>{(d(f).state==="notice-finishing"||d(f).state==="outcome-unknown")&&be(ee)})}w(()=>{Pe(q,1,`mndw-alert mndw-alert--${d(h)??""}`,"svelte-1mbpuk3"),Ae(q,"role",d(p)),E(ve,d(f).message)}),C(j,q)};W(A,j=>{d(f)!==void 0&&d(f).message!==""&&j(O)})}var D=S(A,2);{var z=j=>{var q=NI(),ie=v(q),ve=v(ie),pe=S(ie,2),ee=v(pe);Pe(ee,1,"mndw-pending__cancel"),T(ee,"variant","ghost");var be=v(ee),Ee=S(ee,2);Pe(Ee,1,"mndw-pending__confirm"),T(Ee,"variant","danger"),w(()=>T(Ee,"disabled",d(g)));var Me=v(Ee);w(($e,ge,ze)=>{E(ve,$e),E(be,ge),E(Me,ze)},[()=>M("settings.plugin-manager.deny-confirmation",{label:d(u).label}),()=>M("settings.plugin-manager.cancel"),()=>M("settings.plugin-manager.deny-plugin")]),de("click",ee,function(...$e){var ge;(ge=e.onCancelConfirm)==null||ge.apply(this,$e)}),de("click",Ee,()=>e.onDeny(d(u).name)),C(j,q)},B=j=>{var q=LI(),ie=v(q);Pe(ie,1,"mndw-pending__deny"),T(ie,"variant","danger"),w(()=>T(ie,"disabled",d(g)));var ve=v(ie),pe=S(ie,2);Pe(pe,1,"mndw-pending__approve"),T(pe,"variant","primary"),w(()=>T(pe,"disabled",d(g)));var ee=v(pe);w((be,Ee)=>{E(ve,be),E(ee,Ee)},[()=>M("settings.plugin-manager.deny"),()=>M("settings.plugin-manager.approve")]),de("click",ie,()=>e.onRequestConfirm(d(u).name)),de("click",pe,()=>e.onApprove(d(u).name)),C(j,q)};W(D,j=>{e.confirmingName===d(u).name?j(z):j(B,-1)})}w(()=>{E(y,d(u).label),E(L,d(u).name)}),C(c,m)}),w(c=>E(a,c),[()=>M("settings.plugin-manager.pending-title")]),C(t,s),We()}bt(["click"]);var HI=N('<div class="mndw-approval svelte-s4a91i"><p class="mndw-approval__declaration svelte-s4a91i"><strong> </strong> </p> <div class="mndw-alert mndw-alert--warning mndw-plugin-risk-warning svelte-s4a91i" role="note"><p class="svelte-s4a91i"> </p> <p class="svelte-s4a91i"> </p> <p class="svelte-s4a91i"> </p></div> <!> <div class="mndw-approval__actions svelte-s4a91i"><mndw-button> </mndw-button> <mndw-button> </mndw-button></div></div>',2);function BI(t,e){Ze(e,!0);var n=HI(),r=v(n),i=v(r),s=v(i),o=S(i),a=S(r,2),l=v(a),c=v(l),u=S(l,2),f=v(u),h=S(u,2),p=v(h),g=S(a,2);s_(g,{get entry(){return e.entry}});var m=S(g,2),b=v(m);Pe(b,1,"mndw-approval__deny"),T(b,"variant","danger");var _=v(b),y=S(b,2);Pe(y,1,"mndw-approval__approve"),T(y,"variant","primary");var R=v(y);w((L,P,A,O,D,z)=>{E(s,e.entry.label),E(o,` (${e.entry.name??""}) ${L??""}`),E(c,P),E(f,A),E(p,O),E(_,D),E(R,z)},[()=>M("settings.backend-approval-declaration"),()=>M("settings.plugin-risk-warning-intro"),()=>M("settings.plugin-risk-warning-page"),()=>M("settings.plugin-risk-warning-trust"),()=>M("settings.backend-approval-deny"),()=>M("settings.backend-approval-approve")]),de("click",b,()=>e.close("deny")),de("click",y,()=>e.close("approve")),C(t,n),We()}bt(["click"]);async function UI(t,e,n){if(n!=null&&n.aborted)return;const r=ri(t.hostOverlay,BI,{title:t.locale.hostT("settings.backend-approval-title",{label:e.label}),props:{entry:e}}),i=()=>r.close(void 0);n==null||n.addEventListener("abort",i,{once:!0});try{return(await r.closed).result}finally{n==null||n.removeEventListener("abort",i)}}const jI={"ping-widget-aarch64.zip":"aarch64","ping-widget-mips.zip":"mips","ping-widget-mipsel.zip":"mipsel"};function $I(t){switch(t){case"aarch64":return"aarch64";case"mips":return"mips";case"mipsel":return"mipsel";default:return}}function FI(t,e){const n=$I(e),r=jI[t];if(!(n===void 0||r===void 0||n===r))return{filename:t,archiveTarget:r,deviceTarget:n}}var tg=N('<p class="mndw-upload__status svelte-1mqre4o" role="status"> </p>'),GI=N('<div class="mndw-alert mndw-alert--danger" role="alert"> </div>'),VI=N('<div class="mndw-upload svelte-1mqre4o"><div class="mndw-alert mndw-alert--warning mndw-plugin-risk-warning svelte-1mqre4o" role="note"><p class="svelte-1mqre4o"> </p> <p class="svelte-1mqre4o"> </p> <p class="svelte-1mqre4o"> </p></div> <label id="mndw-plugin-upload" class="mndw-upload__zone svelte-1mqre4o"><input accept=".zip" type="file" class="svelte-1mqre4o"/> <span> </span></label> <!></div>');function ZI(t,e){Ze(e,!0);const n="settings.plugin-manager.install",r="settings.plugin-manager.approval",i=yn(),s=i.locale.hostT;function o(ae,Se){return e.openApproval?e.openApproval(ae,Se):UI(i,ae,Se)}function a(ae){return vf(ae,s,()=>Ll(s))}let l=te("idle"),c=te(""),u=te(null),f,h=!1;si(()=>{h=!0,f==null||f.abort()});function p(ae){if(!ae.name.toLowerCase().endsWith(".zip"))return s("settings.plugin-manager.choose-zip");if(ae.size===0)return s("settings.plugin-manager.empty-zip");if(ae.size>fm)return s("settings.plugin-manager.zip-too-large",{limit:Ll(s)})}function g(ae){return s("settings.plugin-manager.upload-target-mismatch",{filename:ae.filename,archiveTarget:ae.archiveTarget,deviceTarget:ae.deviceTarget})}function m(ae){const Se=p(ae);if(Se)return Se;const Te=FI(ae.name,e.architecture);if(Te!==void 0)return g(Te)}function b(ae){k(c,ae,!0),k(l,"error")}function _(ae){k(u,ae,!0),Xe.success(s("settings.plugin-manager.installed-success",{label:ae.label}),{key:n}),k(l,"success"),e.onInstalled()}async function y(ae){const Se=new AbortController;f=Se;try{return{decision:await o(ae,Se.signal),aborted:Se.signal.aborted}}finally{f===Se&&(f=void 0)}}async function R(ae,Se){if(!h)if(Se==="approve"){const Te=await e.onApprove(ae.name);if(h)return;if(!Te){k(l,"idle");return}Xe.success(s("settings.plugin-manager.approved-success",{label:ae.label}),{key:r}),k(l,"success")}else if(Se==="deny"){if(await e.onDeny(ae.name),h)return;k(l,"idle")}else{if(h)return;e.onDismiss(),k(l,"idle")}}async function L(ae){if(d(l)==="uploading"||d(l)==="busy")return;const Se=m(ae);if(Se){b(Se);return}k(c,""),k(l,"uploading");let Te;try{Te=await e.uploadFile(ae)}catch(K){if(h)return;b(a(K));return}if(h)return;if(Te.status==="installed"){_(Te.entry);return}k(l,"busy");let I;try{I=await y(Te.entry)}catch(K){if(h)return;b(a(K));return}h||I.aborted||await R(Te.entry,I.decision)}function P(ae){var I;const Se=ae.currentTarget,Te=(I=Se.files)==null?void 0:I[0];Se.value="",Te&&L(Te)}function A(ae){var Te;ae.preventDefault();const Se=(Te=ae.dataTransfer)==null?void 0:Te.files[0];Se&&L(Se)}var O=VI(),D=v(O),z=v(D),B=v(z),j=S(z,2),q=v(j),ie=S(j,2),ve=v(ie),pe=S(D,2),ee=v(pe),be=S(ee,2),Ee=v(be),Me=S(pe,2);{var $e=ae=>{var Se=tg(),Te=v(Se);w(I=>E(Te,I),[()=>s("settings.plugin-manager.uploading")]),C(ae,Se)},ge=ae=>{var Se=tg(),Te=v(Se);w(I=>E(Te,I),[()=>s("settings.plugin-manager.waiting-approval")]),C(ae,Se)},ze=ae=>{var Se=_n(),Te=tt(Se);{var I=K=>{i_(K,{get lock(){return d(u).lock}})};W(Te,K=>{d(u)&&K(I)})}C(ae,Se)},Je=ae=>{var Se=GI(),Te=v(Se);w(()=>E(Te,d(c))),C(ae,Se)};W(Me,ae=>{d(l)==="uploading"?ae($e):d(l)==="busy"?ae(ge,1):d(l)==="success"?ae(ze,2):d(l)==="error"&&ae(Je,3)})}w((ae,Se,Te,I,K)=>{E(B,ae),E(q,Se),E(ve,Te),Ae(ee,"aria-label",I),ee.disabled=d(l)==="uploading"||d(l)==="busy",E(Ee,K)},[()=>s("settings.plugin-risk-warning-intro"),()=>s("settings.plugin-risk-warning-page"),()=>s("settings.plugin-risk-warning-trust"),()=>s("settings.upload-plugin-zip"),()=>s("settings.plugin-manager.upload-drop")]),Pt("dragover",pe,ae=>ae.preventDefault()),Pt("drop",pe,A),de("change",ee,P),C(t,O),We()}bt(["change"]);function o_(t,e,n){var i;const r=n.find(s=>s.name===e);switch(t.kind){case"delete":case"deny":return r===void 0;case"enable":return(r==null?void 0:r.enabled)===!0;case"disable":return(r==null?void 0:r.enabled)===!1;case"approve":return(r==null?void 0:r.approval)==="approved";case"restart":return!1;case"capability":return((i=r==null?void 0:r.capabilityGrants)==null?void 0:i[t.capability])===t.enabled}}async function WI(t,e,n,r){if(t.kind==="restart")return"outcome-unknown";for(let i=0;i<r.polls;i+=1){const s=await n();if(o_(t,e,s))return"ok";i+1<r.polls&&r.intervalMs>0&&await new Promise(o=>window.setTimeout(o,r.intervalMs))}return"notice-finishing"}var qI=N('<div class="mndw-reload svelte-1hlmyjs" role="status"><span> </span> <mndw-button> </mndw-button> <mndw-button> </mndw-button></div>',2),KI=N('<p class="mndw-plugin-manager__loading svelte-1hlmyjs" role="status"> </p>'),YI=N('<div class="mndw-alert mndw-alert--danger mndw-plugin-manager__notice svelte-1hlmyjs" role="alert"><p class="svelte-1hlmyjs"> </p> <mndw-button> </mndw-button></div>',2),XI=N('<div class="mndw-alert mndw-alert--danger mndw-plugin-manager__notice svelte-1hlmyjs" role="alert"><span> </span> <mndw-button> </mndw-button> <mndw-button> </mndw-button></div>',2),JI=N('<section class="svelte-1hlmyjs"><strong> </strong> <span> </span> <span> </span> <span> </span> <span> </span></section>'),QI=N('<p class="svelte-1hlmyjs"> </p>'),Ba=N("<span> </span>"),e3=N('<section class="mndw-plugin-diagnostics__item svelte-1hlmyjs"><strong> </strong> <!> <!> <!> <!></section>'),t3=N('<!> <details class="mndw-plugin-diagnostics svelte-1hlmyjs"><summary class="svelte-1hlmyjs"> </summary> <!> <!></details> <!> <!>',1),n3=N('<section class="mndw-plugin-manager svelte-1hlmyjs"><h3 class="svelte-1hlmyjs"> </h3> <!> <!> <!></section>');function r3(t,e){Ze(e,!0);let n=Tn(e,"capabilityVisible",3,!1),r=Tn(e,"capabilityAvailable",3,!1);const i=yn(),s=G(()=>e.client??i.mgmtClient),o=i.registry,a=i.locale.hostT;function l(I){return vf(I,a,()=>Ll(a))}let c=te(pt([])),u=te(null),f=te(""),h=te(!0),p=te(""),g=te(""),m=te(null),b=te(!1),_=0;const y=new Ti,R={polls:3,intervalMs:1e3};let L=G(()=>d(c).filter(I=>I.approval==="approved")),P=G(()=>d(c).filter(I=>I.approval==="pending"));function A(I){return y.get(I)}function O(I){return I.some(K=>{if(!K.enabled||K.approval!=="approved")return!1;const we=o.get(K.name);return we!==void 0&&we.entry.version!==K.version})}function D(I){for(const[K,we]of y)we.state==="notice-finishing"&&we.operation!==void 0&&o_(we.operation,K,I)&&y.delete(K)}async function z(){const I=++_;k(h,!0),k(p,"");try{const K=await d(s).listPlugins();I===_&&(k(c,K,!0),k(b,d(b)||O(K),!0),k(g,""),D(K))}catch(K){I===_&&k(p,l(K),!0)}finally{I===_&&k(h,!1)}}async function B(){const I=++_;let K=!1;try{const we=await d(s).listPlugins();if(I===_){k(c,we,!0),k(p,""),k(g,""),k(h,!1),D(we);const De=rA(we);i.router.refresh(i.registry),K=await De,k(b,d(b)||K||O(we),!0),i.router.refresh(i.registry)}}catch(we){I===_&&(k(g,l(we),!0),k(h,!1))}return q(),K}async function j(){await B()&&k(b,!0)}async function q(){try{k(u,await d(s).getRuntime(),!0),k(f,"")}catch(I){k(f,l(I),!0)}}async function ie(I,K,we){const De=y.get(I);if((De==null?void 0:De.state)==="working"||(De==null?void 0:De.state)==="reconciling")return!1;y.set(I,{state:"working",message:"",operation:K});let ke=!1;try{await we(),ke=!0,y.delete(I),await j()}catch(Y){const se=UA(Y);if(se==="rejected-maintenance")y.set(I,{state:"notice-rejected",message:a("settings.plugin-manager.maintenance-busy"),operation:K});else if(se==="ambiguous"){y.set(I,{state:"reconciling",message:a("settings.plugin-manager.confirming-state"),operation:K});try{const he=await WI(K,I,()=>d(s).listPlugins(),R);he==="ok"?(y.delete(I),ke=!0,await j()):he==="notice-finishing"?y.set(I,{state:"notice-finishing",message:a("settings.plugin-manager.operation-finishing"),operation:K}):y.set(I,{state:"outcome-unknown",message:a("settings.plugin-manager.outcome-unknown"),operation:K})}catch(he){y.set(I,{state:"outcome-unknown",message:l(he),operation:K})}}else y.set(I,{state:"error",message:l(Y),operation:K}),await B()}finally{k(m,null)}return ke}function ve(){j()}function pe(){j()}function ee(I){y.delete(I)}Gn(()=>{z(),q()});var be=n3(),Ee=v(be),Me=v(Ee),$e=S(Ee,2);{var ge=I=>{var K=qI(),we=v(K),De=v(we),ke=S(we,2);T(ke,"variant","primary");var Y=v(ke),se=S(ke,2);T(se,"variant","ghost");var he=v(se);w((Ne,ut,xt)=>{E(De,Ne),E(Y,ut),E(he,xt)},[()=>a("settings.plugin-manager.plugin-updated-notice"),()=>a("settings.plugin-manager.reload-now"),()=>a("settings.plugin-manager.later")]),de("click",ke,()=>window.location.reload()),de("click",se,()=>k(b,!1)),C(I,K)};W($e,I=>{d(b)&&I(ge)})}var ze=S($e,2);{let I=G(()=>{var K;return(K=V.deviceInfo)==null?void 0:K.architecture});ZI(ze,{get architecture(){return d(I)},uploadFile:K=>d(s).uploadPlugin(K),onInstalled:ve,onApprove:K=>ie(K,{kind:"approve"},()=>d(s).approvePlugin(K)),onDeny:K=>ie(K,{kind:"deny"},()=>d(s).denyPlugin(K)),onDismiss:pe})}var Je=S(ze,2);{var ae=I=>{var K=KI(),we=v(K);w(De=>E(we,De),[()=>a("settings.plugin-manager.loading")]),C(I,K)},Se=I=>{var K=YI(),we=v(K),De=v(we),ke=S(we,2);T(ke,"variant","secondary");var Y=v(ke);w(se=>{E(De,d(p)),E(Y,se)},[()=>a("settings.plugin-manager.retry")]),de("click",ke,()=>void z()),C(I,K)},Te=I=>{var K=t3(),we=tt(K);{var De=He=>{var ft=XI(),yt=v(ft),Zt=v(yt),$t=S(yt,2);T($t,"variant","secondary");var kn=v($t),Wt=S($t,2);T(Wt,"variant","ghost");var qt=v(Wt);w((an,En)=>{E(Zt,d(g)),E(kn,an),E(qt,En)},[()=>a("settings.plugin-manager.retry"),()=>a("settings.plugin-manager.dismiss")]),de("click",$t,()=>void B()),de("click",Wt,()=>k(g,"")),C(He,ft)};W(we,He=>{d(g)&&He(De)})}var ke=S(we,2),Y=v(ke),se=v(Y),he=S(Y,2);{var Ne=He=>{var ft=JI(),yt=v(ft),Zt=v(yt),$t=S(yt,2),kn=v($t),Wt=S($t,2),qt=v(Wt),an=S(Wt,2),En=v(an),Rn=S(an,2),Sn=v(Rn);w((F,ne,re,Q,Fe,nt,Ot)=>{Ae(ft,"aria-label",F),E(Zt,ne),E(kn,`${re??""}:
90
+ ${d(u).currentExec??""}/${d(u).maxConcurrentExecTotal??""}`),E(qt,`${Q??""}:
91
+ ${d(u).reservedServices??""}/${d(u).maxSupervisedServices??""}`),E(En,`${Fe??""}:
92
+ ${d(u).maxConcurrentExecPerPlugin??""}`),E(Sn,`${nt??""}:
93
+ ${Ot??""}`)},[()=>a("settings.backend-capacity"),()=>a("settings.backend-capacity"),()=>a("settings.plugin-manager.exec"),()=>a("settings.plugin-manager.services"),()=>a("settings.plugin-manager.per-plugin-exec-limit"),()=>a("settings.plugin-manager.service-protocols"),()=>d(u).supportedServiceProtocols.join(", ")]),C(He,ft)},ut=He=>{var ft=QI(),yt=v(ft);w(Zt=>E(yt,Zt),[()=>a("settings.plugin-manager.runtime-status-unavailable",{error:d(f)})]),C(He,ft)};W(he,He=>{d(u)?He(Ne):d(f)&&He(ut,1)})}var xt=S(he,2);Mt(xt,17,()=>d(L).filter(He=>He.runtime!==void 0),He=>He.name,(He,ft)=>{const yt=G(()=>d(ft).runtime);var Zt=e3(),$t=v(Zt),kn=v($t),Wt=S($t,2);{var qt=re=>{var Q=Ba(),Fe=v(Q);w(nt=>E(Fe,`${nt??""}: ${d(yt).requiredProtocol??""}`),[()=>a("settings.plugin-manager.protocol")]),C(re,Q)};W(Wt,re=>{var Q;((Q=d(yt))==null?void 0:Q.requiredProtocol)!==void 0&&re(qt)})}var an=S(Wt,2);{var En=re=>{var Q=Ba(),Fe=v(Q);w(nt=>E(Fe,nt),[()=>a("settings.plugin-manager.incompatible")]),C(re,Q)};W(an,re=>{var Q;((Q=d(yt))==null?void 0:Q.compatible)===!1&&re(En)})}var Rn=S(an,2);{var Sn=re=>{var Q=Ba(),Fe=v(Q);w(nt=>E(Fe,`${nt??""}: ${d(yt).lastError??""}`),[()=>a("settings.plugin-manager.last-error")]),C(re,Q)};W(Rn,re=>{var Q;(Q=d(yt))!=null&&Q.lastError&&re(Sn)})}var F=S(Rn,2);{var ne=re=>{var Q=Ba(),Fe=v(Q);w((nt,Ot)=>E(Fe,`${nt??""}:
94
+ ${Ot??""}`),[()=>a("settings.plugin-manager.supported-service-protocols"),()=>d(yt).supportedProtocols.join(", ")]),C(re,Q)};W(F,re=>{var Q;((Q=d(yt))==null?void 0:Q.compatible)===!1&&d(yt).supportedProtocols&&re(ne)})}w(()=>E(kn,d(ft).name)),C(He,Zt)});var Lt=S(ke,2);{var Dt=He=>{DI(He,{get items(){return d(P)},get confirmingName(){return d(m)},rowStateFor:A,onApprove:ft=>ie(ft,{kind:"approve"},()=>d(s).approvePlugin(ft)),onDeny:ft=>ie(ft,{kind:"deny"},()=>d(s).denyPlugin(ft)),onRequestConfirm:ft=>k(m,ft,!0),onCancelConfirm:()=>k(m,null),onRefresh:()=>void B(),onKeepNotice:ee})};W(Lt,He=>{d(P).length>0&&He(Dt)})}var At=S(Lt,2);xI(At,{get items(){return d(L)},get confirmingName(){return d(m)},rowStateFor:A,get capabilityVisible(){return n()},get capabilityAvailable(){return r()},onEnable:He=>ie(He,{kind:"enable"},()=>d(s).enablePlugin(He)),onDisable:He=>ie(He,{kind:"disable"},()=>d(s).disablePlugin(He)),onCapabilityChange:(He,ft,yt)=>ie(He,{kind:"capability",capability:ft,enabled:yt},()=>d(s).setPluginCapability(He,ft,yt)),onRestart:He=>ie(He,{kind:"restart"},()=>d(s).restartPlugin(He)),onDelete:He=>ie(He,{kind:"delete"},()=>d(s).deletePlugin(He)),onRequestConfirm:He=>k(m,He,!0),onCancelConfirm:()=>k(m,null),onRefresh:()=>void B(),onKeepNotice:ee}),w(He=>E(se,He),[()=>a("settings.plugin-manager.diagnostics")]),C(I,K)};W(Je,I=>{d(h)?I(ae):d(p)?I(Se,1):I(Te,-1)})}w(I=>E(Me,I),[()=>a("settings.plugin-manager.title")]),C(t,be),We()}bt(["click"]);var i3=N('<section class="mndw-plugin-settings"><!></section>');function s3(t,e){var n=i3(),r=v(n);r3(r,{get capabilityVisible(){return e.capabilityVisible},get capabilityAvailable(){return e.capabilityAvailable}}),C(t,n)}var o3=N("<mndw-button> </mndw-button>",2),a3=N('<div class="mndw-self-update-progress-modal svelte-1khkewm"><p role="status" class="svelte-1khkewm"> </p> <!></div>');function l3(t,e){Ze(e,!0);const n=G(()=>e.progress.phase==="preparing"?M("settings.self-update-preparing"):e.progress.phase==="unconfirmed"?M("settings.self-update-unconfirmed-modal"):e.progress.operation==="revert"?M("settings.self-update-reverting",{version:e.progress.targetVersion}):M("settings.self-update-updating",{version:e.progress.targetVersion}));var r=a3(),i=v(r),s=v(i),o=S(i,2);{var a=l=>{var c=o3();T(c,"variant","secondary"),Pe(c,1,"svelte-1khkewm");var u=v(c);w(f=>E(u,f),[()=>M("common.close")]),de("click",c,()=>e.close("close")),C(l,c)};W(o,l=>{e.progress.phase==="unconfirmed"&&l(a)})}w(()=>E(s,d(n))),C(t,r),We()}bt(["click"]);var gu=N('<p class="svelte-1ffuaq9"> </p>'),Ua=N('<p role="status" class="svelte-1ffuaq9"> </p>'),ng=N('<p role="alert" class="svelte-1ffuaq9"> </p>'),c3=N('<section class="mndw-self-update-settings svelte-1ffuaq9"><h3 class="svelte-1ffuaq9"> </h3> <p class="svelte-1ffuaq9"> </p> <!> <!> <!> <!> <div class="mndw-self-update-actions svelte-1ffuaq9"><mndw-button> </mndw-button> <mndw-button> </mndw-button> <mndw-button> </mndw-button></div></section>',2);function u3(t,e){Ze(e,!0);let n=Tn(e,"pollIntervalMs",3,2e3),r=Tn(e,"pollAttempts",3,90);const i="settings.self-update.check",s="settings.self-update.apply",o="settings.self-update.revert",a="settings.self-update.status",l=yn(),c=l.locale.hostT;let u=G(()=>e.client??l.selfUpdateClient),f=te(null),h=te(null),p=te(""),g=te(""),m=te("idle"),b=te(""),_=te(!1),y=null,R=0,L=0,P=!1,A=!1,O=te(null),D=null;Gn(()=>{j()}),si(()=>{P=!0,z(),$e()});function z(){R+=1,y!==null&&(window.clearTimeout(y),y=null)}function B($){k(f,$,!0),$.state==="failed"?(k(b,$.failureCode??"unknown",!0),k(m,"failure"),A=!1,$e()):$.state==="idle"&&A?(A=!1,k(m,"idle"),Xe.success(c("settings.self-update-success",{version:$.version}),{key:be(d(g))}),$e()):$.state==="in-progress"&&(k(m,"idle"),d(O)!==null&&(d(O).phase="running",d(O).targetVersion=$.targetVersion??d(O).targetVersion,$.operation!==void 0&&(d(O).operation=$.operation)))}async function j(){k(_,!0);try{const $=await d(u).status();if(P)return;B($),$.state==="in-progress"&&(A=!0,q())}catch{k(m,"error")}finally{k(_,!1)}}function q(){if(z(),L=Math.max(0,r()),L===0){ve();return}ie(R)}function ie($){P||$!==R||L<=0||(y=window.setTimeout(()=>{y=null,pe($)},n()))}function ve(){z(),k(m,"unconfirmed"),d(O)!==null&&(d(O).phase="unconfirmed")}async function pe($){if(!(P||$!==R)){L-=1;try{const le=await d(u).status();if(P||$!==R)return;B(le),le.state==="in-progress"?L<=0?ve():ie($):z()}catch{if(L<=0){ve();return}ie($)}}}function ee($){return $ instanceof Ib?$.code:"UNKNOWN"}function be($){return $==="update"?s:$==="revert"?o:a}async function Ee($,le){const Ie=$==="update";return(await ri(l.hostOverlay,Zo,{title:c(Ie?"settings.self-update-confirm-update-title":"settings.self-update-confirm-revert-title"),props:{message:c(Ie?"settings.self-update-confirm-update":"settings.self-update-confirm-revert",{version:le}),confirmLabel:c(Ie?"settings.self-update-apply":"settings.self-update-revert")}}).closed).result===!0}function Me($){k(O,{operation:$,phase:"preparing",targetVersion:""},!0);const Ie=d(O);if(Ie===null)return;const at=ri(l.hostOverlay,l3,{title:c("settings.self-update-progress-title"),showCloseButton:!1,closeOnEscape:!1,props:{progress:Ie}});D=at,at.closed.then(()=>{D===at&&(D=null,k(O,null))})}function $e(){D==null||D.close(void 0,"api")}async function ge($){try{const le=await d(u).status();if(P)return;B(le),le.state==="in-progress"?(A=!0,q()):(k(m,"idle"),Xe.info(c("settings.self-update-busy"),{key:$}))}catch{if(P)return;k(m,"idle"),Xe.info(c("settings.self-update-busy"),{key:$})}}async function ze(){z(),A=!1,k(_,!0),k(m,"checking"),k(b,"");try{const $=await d(u).check();if(P)return;k(h,$,!0),k(m,"idle"),$.updateAvailable?Xe.dismissKey(i):Xe.info(c("settings.self-update-no-update"),{key:i})}catch($){if(P)return;k(h,null),ee($)==="OPKG_BUSY"?await ge(i):(k(m,"idle"),Xe.error(c("settings.self-update-failure-generic"),{key:i}))}finally{P||k(_,!1)}}async function Je(){const $=d(h);$===null||!$.updateAvailable||$.targetVersion===void 0||await Ee("update",$.targetVersion)&&(P||await K("update",()=>d(u).apply()))}async function ae(){d(Y)!==""&&await Ee("revert",d(Y))&&(P||await K("revert",()=>d(u).revert()))}function Se($){z(),k(h,null),k(p,""),k(g,$,!0),k(b,""),k(_,!0),k(m,"preparing"),A=!1}async function Te($){const le=await $();P||(k(p,le.targetVersion,!0),k(g,le.operation,!0),d(O)!==null&&(d(O).phase="running",d(O).targetVersion=le.targetVersion),k(m,"idle"),A=!0,q())}async function I($,le){if(P)return;const Ie=be(le);switch($e(),ee($)){case"OPKG_BUSY":await ge(Ie);return;case"SELF_UPDATE_NOT_AVAILABLE":Xe.info(c("settings.self-update-no-update"),{key:Ie});break;case"SELF_UPDATE_ROLLBACK_UNAVAILABLE":Xe.info(c("settings.self-update-rollback-unavailable"),{key:Ie});break;default:Xe.error(c("settings.self-update-failure-generic"),{key:Ie})}k(b,""),k(m,"idle")}async function K($,le){Se($),Me($);try{await Te(le)}catch(Ie){await I(Ie,$)}finally{P||k(_,!1)}}function we($){return c({"update-missing":"settings.self-update-failure-update-missing","opkg-install-failed":"settings.self-update-failure-opkg-install-failed","opkg-revert-failed":"settings.self-update-failure-opkg-revert-failed","rollback-missing":"settings.self-update-failure-rollback-missing","helper-exited":"settings.self-update-failure-helper-exited","unexpected-version":"settings.self-update-failure-unexpected-version","state-corrupt":"settings.self-update-failure-state-corrupt"}[$]??"settings.self-update-failure-generic")}const De=G(()=>{var $;return(($=d(f))==null?void 0:$.version)??""}),ke=G(()=>{var $,le;return(($=d(f))==null?void 0:$.state)==="in-progress"?d(p)||d(f).targetVersion||"":((le=d(h))==null?void 0:le.targetVersion)||""}),Y=G(()=>{var $,le;return(($=d(h))==null?void 0:$.rollbackVersion)||((le=d(f))==null?void 0:le.rollbackVersion)||""}),se=G(()=>{var $;return(($=d(h))==null?void 0:$.updateAvailable)===!0&&!d(_)}),he=G(()=>{var $,le;return((($=d(h))==null?void 0:$.rollbackAvailable)===!0||!!((le=d(f))!=null&&le.rollbackVersion))&&!d(_)});var Ne=c3(),ut=v(Ne),xt=v(ut),Lt=S(ut,2),Dt=v(Lt),At=S(Lt,2);{var He=$=>{var le=gu(),Ie=v(le);w(at=>E(Ie,at),[()=>c("settings.self-update-current",{version:d(De)})]),C($,le)};W(At,$=>{d(De)&&$(He)})}var ft=S(At,2);{var yt=$=>{var le=gu(),Ie=v(le);w(at=>E(Ie,at),[()=>c("settings.self-update-rollback",{version:d(Y)})]),C($,le)};W(ft,$=>{d(Y)&&$(yt)})}var Zt=S(ft,2);{var $t=$=>{var le=Ua(),Ie=v(le);w(at=>E(Ie,at),[()=>c("settings.self-update-checking")]),C($,le)},kn=$=>{var le=Ua(),Ie=v(le);w(at=>E(Ie,at),[()=>c("settings.self-update-preparing")]),C($,le)},Wt=$=>{var le=Ua(),Ie=v(le);w(at=>E(Ie,at),[()=>c(d(g)==="revert"||d(f).operation==="revert"?"settings.self-update-reverting":"settings.self-update-updating",{version:d(ke)})]),C($,le)},qt=$=>{var le=ng(),Ie=v(le);w(at=>E(Ie,at),[()=>we(d(b))]),C($,le)},an=$=>{var le=Ua(),Ie=v(le);w(at=>E(Ie,at),[()=>c("settings.self-update-unconfirmed")]),C($,le)},En=$=>{var le=ng(),Ie=v(le);w(at=>E(Ie,at),[()=>c("settings.self-update-failure-generic")]),C($,le)};W(Zt,$=>{var le;d(m)==="checking"?$($t):d(m)==="preparing"?$(kn,1):((le=d(f))==null?void 0:le.state)==="in-progress"&&d(m)!=="unconfirmed"?$(Wt,2):d(m)==="failure"?$(qt,3):d(m)==="unconfirmed"&&d(O)===null?$(an,4):d(m)==="error"&&$(En,5)})}var Rn=S(Zt,2);{var Sn=$=>{var le=gu(),Ie=v(le);w(at=>E(Ie,at),[()=>c("settings.self-update-available",{version:d(h).targetVersion})]),C($,le)};W(Rn,$=>{d(h)!==null&&d(h).updateAvailable&&d(h).targetVersion!==void 0&&$(Sn)})}var F=S(Rn,2),ne=v(F);T(ne,"variant","secondary"),w(()=>T(ne,"disabled",d(_)));var re=v(ne),Q=S(ne,2);T(Q,"variant","primary"),w(()=>T(Q,"disabled",!d(se)));var Fe=v(Q),nt=S(Q,2);T(nt,"variant","secondary"),w(()=>T(nt,"disabled",!d(he)));var Ot=v(nt);w(($,le,Ie,at,Zn,Wn)=>{Ae(Ne,"data-locale",V.locale),Ae(Ne,"aria-label",$),E(xt,le),E(Dt,Ie),E(re,at),E(Fe,Zn),E(Ot,Wn)},[()=>c("settings.self-update-tab"),()=>c("settings.self-update-tab"),()=>c("settings.self-update-description"),()=>d(m)==="checking"?c("settings.self-update-checking"):c("settings.self-update-check"),()=>c("settings.self-update-apply"),()=>c("settings.self-update-revert")]),de("click",ne,()=>void ze()),de("click",Q,()=>void Je()),de("click",nt,()=>void ae()),C(t,Ne),We()}bt(["click"]);const Il=[{id:"general",route:gt.settingsTab.general,labelKey:"settings.general-tab",icon:"settings"},{id:"diagnostics",route:gt.settingsTab.diagnostics,labelKey:"settings.diagnostics-tab",icon:"diagnostics"},{id:"plugins",route:gt.settingsTab.plugins,labelKey:"settings.plugins-tab",icon:"plugins"},{id:"self-update",route:gt.settingsTab["self-update"],labelKey:"settings.self-update-tab",icon:"refresh"}],rg="general";function ig(t){var e;return((e=Il.find(n=>n.id===t))==null?void 0:e.route)??gt.settingsTab[t]}function d3(t){const e=t.length>1&&t.endsWith("/")?t.slice(0,-1):t;for(const n of Il)if(e===n.route)return n.id;return null}var f3=N("<mndw-tab> </mndw-tab>",2),h3=N('<div class="mndw-settings"><h2> </h2> <mndw-tabs><!> <mndw-tab-panel><!></mndw-tab-panel> <mndw-tab-panel><!></mndw-tab-panel> <mndw-tab-panel><!></mndw-tab-panel> <mndw-tab-panel><!></mndw-tab-panel></mndw-tabs></div>',2);function sg(t,e){Ze(e,!0);let n=te(!1),r=te(!1);const i=yn().router,s=G(()=>{var A;const P=((A=i.current)==null?void 0:A.route.pathname)??globalThis.location.pathname;return d3(P)??rg});Gn(()=>{const P=i.current;(P==null?void 0:P.route.pathname)===gt.settings&&P.navigate(ig(rg),{replace:!0})});function o(P){const A=Il.find(D=>D.id===P.detail.value),O=i.current;A===void 0||O===void 0||O.navigate(ig(A.id))}function a(P){k(n,P.visible,!0),k(r,P.available,!0)}var l=h3(),c=v(l),u=v(c),f=S(c,2);w(()=>T(f,"value",d(s)));var h=v(f);Mt(h,17,()=>Il,P=>P.id,(P,A)=>{var O=f3();w(()=>T(O,"id",d(A).id)),w(()=>T(O,"data-icon",d(A).icon));var D=v(O);w(z=>E(D,z),[()=>M(d(A).labelKey)]),C(P,O)});var p=S(h,2);T(p,"for","general");var g=v(p);lI(g,{onCapabilityStateChange:a});var m=S(p,2);T(m,"for","diagnostics");var b=v(m);EL(b,{});var _=S(m,2);T(_,"for","plugins");var y=v(_);s3(y,{get capabilityVisible(){return d(n)},get capabilityAvailable(){return d(r)}});var R=S(_,2);T(R,"for","self-update");var L=v(R);u3(L,{}),w(P=>{Ae(l,"data-locale",V.locale),E(u,P)},[()=>M("settings.title")]),Pt("mndwchange",f,o),C(t,l),We()}function _s(t){return(t.length>1&&t.endsWith("/")?t.slice(0,-1):t).toLowerCase()}function p3(t,e){if(!/^\/[^/?#*]+\/?$/.test(t)||_s(t)==="/")throw new Error(`Page plugin "${e}" must declare a single-segment route; received "${t}"`)}function g3(t,e){if(qm(t))throw new Error(`Page plugin "${e}" route "${t}" conflicts with a reserved static route`)}function og(t){const e=Pf(t),n={},r=new Map;for(const o of e){const{name:a,route:l}=o;p3(l,a),g3(_s(l),a);const c=_s(l),u=`${c}/*child`,f=r.get(c);if(f!==void 0)throw new Error(`Page route collision: plugin "${a}" route "${l}" conflicts with plugin "${f}" route "${c}"`);n[c]=Fp,n[u]=Fp,r.set(c,a)}const i=new Map;for(const[o,a]of r)i.set(a,o);return{routes:n,pageTable:{baseRouteOf(o){return i.get(o)},pluginNameOf(o){return r.get(_s(o))}}}}function m3(t,e){return Pf(t).flatMap(n=>{const r=e.baseRouteOf(n.name);return r===void 0?[]:[{route:r,name:n.name}]})}function ag(t){return{[gt.dashboard]:fu,[gt.login]:fu,[gt.packages]:Wp,[gt.packageServices]:Wp,[gt.settings]:sg,...Object.fromEntries(Object.values(gt.settingsTab).map(e=>[e,sg])),...t,"*":fu}}function v3(t){return t.length>1&&t.endsWith("/")?t.slice(0,-1):t}function Rf(t,e){var a;const n=v3(t),r=n.indexOf("/",1),i=r===-1?n:n.slice(0,r);let s;if("pluginNameOf"in e?s=e.pluginNameOf(i):s=(a=e.find(l=>_s(l.route)===_s(i)))==null?void 0:a.name,s===void 0)return null;const o=n.slice(i.length);return{name:s,childPath:o==="/"?"":o}}function b3(t){const e=globalThis.location.pathname,n=Rf(e,t.pluginPages);if(n!==null)try{decodeURIComponent(e)}catch{const i=t.pluginPages.baseRouteOf(n.name);if(i===void 0)return;globalThis.history.replaceState(globalThis.history.state,"",`${i}${globalThis.location.search}${globalThis.location.hash}`)}}function _3(){let t,e,n;return{get current(){return t},create:s=>{const{routes:o,pageTable:a}=og(s),l=ag(o),c={layout:iN,...l},u={[gt.dashboard]:c},f=Ny(u);return e=a,n=c,t=Object.defineProperty(f,"pluginPages",{configurable:!0,enumerable:!0,get:()=>{if(e===void 0)throw new Error("Plugin page table is unavailable before router creation");return e}}),b3(t),t},refresh:s=>{if(n===void 0||t===void 0||e===void 0)return;const o=e,a=Rf(t.route.pathname,o),{routes:l,pageTable:c}=og(s),u=ag(l);for(const f of Object.keys(n))f!=="layout"&&delete n[f];Object.assign(n,u),e=c,a!==null&&c.baseRouteOf(a.name)===void 0&&t.navigate(gt.dashboard)},navigation:()=>{const s=t;if(s!==void 0)return{pageTable:s.pluginPages,navigate:o=>s.navigate(o)}},pageRouteDefinitions:s=>{const o=e;return o===void 0?[]:m3(s,o)}}}function w3(t={}){const e=t.fetch??globalThis.fetch,n=jA(e),r=zR({now:t.now}),i=VA({mgmtClient:n,document:t.document}),s=XP({catalog:r,storage:t.storage,document:t.document,setUiLocale:t.setUiLocale}),o=sO({catalog:r}),a=NO(),l=FO(),c=GO(l),u=_f("@host","@host",l).service;return Object.freeze({mgmtClient:n,palette:i,catalog:r,locale:s,registry:o,router:_3(),opkgClient:JA(e),serviceClient:eO(e),selfUpdateClient:rO(e),persistentRci:hO(),rci:vO(),telemetry:bO(e),telemetryGathering:IO({getTelemetry:()=>n.getTelemetry(),eventStream:a}),eventStream:a,theme:zO({storage:t.storage,document:t.document}),tickerPool:HO(),pluginStylesheets:new BO,overlayRuntime:l,overlay:c,hostOverlay:u})}const ui=w3();function ja(t){return t?t.includes("/plugins/")||t.includes("/user-plugins/"):!1}function y3(){window.addEventListener("error",t=>{const e=typeof t.message=="string"?t.message:"",n=typeof t.filename=="string"?t.filename:"",r=t.error instanceof Error?t.error.stack:"";(ja(n)||ja(r)||ja(e))&&(console.error("[mndw] Plugin runtime error:",t.error||t.message),t.preventDefault())}),window.addEventListener("unhandledrejection",t=>{const e=t.reason,n=e instanceof Error?e.stack:String(e);ja(n)&&(console.error("[mndw] Plugin unhandled rejection:",e),t.preventDefault())})}function k3(){const t=document.getElementById("app");if(t===null)throw new Error("Missing #app mount target");Vl(NA,{target:t,props:{services:ui}})}async function E3(){const t=ui.rci.isAuthenticated().pipe(ug(5e3));return md(t)}function S3(t){ui.rci.authError$.subscribe(t)}async function T3(){y3(),await LA({initLocale:()=>ui.locale.initLocale(),defineUi:t=>k_({overlay:ui.overlay,initialLocale:t,iconSpriteUrl:D_}),initTheme:()=>ui.theme.initTheme(),initPalette:()=>ui.palette.initPalette(),checkAuthenticated:E3,setAuthenticated:t=>{V.authenticated=t},initAuthenticated:()=>mf(ui),getAuthRunGeneration:Ur,subscribeAuthErrors:S3,resetToLogin:dc,mountApp:k3})}T3();export{fA as s};