import{Ir as e,Rr as t}from"./i18n-CsN8OUP9.js";var n=5,r=6,i=10,a=(e,t,n,r)=>(e.events=e.events||{},e.events[n+i]||(e.events[n+i]=r(t=>{e.events[n].reduceRight((e,t)=>(t(e),e),{shared:{},...t})})),e.events[n]=e.events[n]||[],e.events[n].push(t),()=>{let r=e.events[n],a=r.indexOf(t);r.splice(a,1),r.length||(delete e.events[n],e.events[n+i](),delete e.events[n+i])}),o=1e3,s=(e,t)=>a(e,n=>{let i=t(n);i&&e.events[r].push(i)},n,t=>{let n=e.listen;e.listen=(...r)=>(!e.lc&&!e.active&&(e.active=!0,t()),n(...r));let i=e.off;return e.events[r]=[],e.off=()=>{i(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let t of e.events[r])t();e.events[r]=[]}},o)},()=>{e.listen=n,e.off=i}}),c=(n,r,i)=>{Array.isArray(n)||(n=[n]);let a,o,c=()=>{if(o===t.epoch)return;o=t.epoch;let e=n.map(e=>e.get());if(!a||e.some((e,t)=>e!==a[t])){a=e;let n=r(...e);n&&n.then&&n.t?n.then(t=>{a===e&&l.set(t)}):(l.set(n),o=t.epoch)}},l=e(void 0),u=l.get;l.get=()=>(c(),u());let d,f=i?()=>{clearTimeout(d),d=setTimeout(c)}:c;return s(l,()=>{let e=n.map(e=>e.listen(f));return c(),()=>{for(let t of e)t()}}),l},l=(e,t)=>c(e,t),u=new Set;function d(e){for(let t of u)t(e)}function f(e){let t=null;try{t=window.localStorage.getItem(e)}catch{}return d({key:e,op:`read`,value:t}),t}function p(e,t){try{t===null?window.localStorage.removeItem(e):window.localStorage.setItem(e,t)}catch{}d({key:e,op:t===null?`remove`:`write`,value:t})}function m(e){let t=f(e);if(t===null)return null;try{return JSON.parse(t)}catch{return null}}function h(e,t){p(e,t===null?null:JSON.stringify(t))}function g(e,t){let n=f(e);return n===null?t:n===`true`}function _(e,t){p(e,String(t))}function v(e){return f(e)}function y(e,t){p(e,t)}function b(e){let t=f(e);if(!t)return[];try{let e=JSON.parse(t);return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.length>0):[]}catch{return[]}}function x(e,t){p(e,t.length===0?null:JSON.stringify(t))}function S(e){let t=f(e);if(!t)return{};try{let e=JSON.parse(t);return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`string`))}catch{return{}}}function C(e,t){p(e,JSON.stringify(t))}function w(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function T(e,t,n){let r=e.filter(e=>e!==t),i=Math.min(Math.max(n,0),r.length);return r.splice(i,0,t),r}var E=e(0),D=Object.freeze([]),O=new class{byArea=new Map;snapshot=new Map;areaListeners=new Map;globalListeners=new Set;register=e=>this.registerMany([e]);registerMany=e=>(e.forEach(e=>this.put(e)),this.invalidate(e.map(e=>e.area)),()=>this.removeMany(e.map(e=>({area:e.area,id:e.id}))));getArea=e=>{let t=this.snapshot.get(e);if(t)return t;let n=this.byArea.get(e),r=!n||n.length===0?D:n.filter(e=>e.enabled!==!1&&(!e.when||e.when())).sort((e,t)=>(e.order??0)-(t.order??0));return this.snapshot.set(e,r),r};subscribe=e=>(this.globalListeners.add(e),()=>{this.globalListeners.delete(e)});subscribeArea=(e,t)=>{let n=this.areaListeners.get(e)??new Set;return n.add(t),this.areaListeners.set(e,n),()=>{n.delete(t),n.size===0&&this.areaListeners.delete(e)}};removeMany(e){let t=[];for(let{area:n,id:r}of e)this.take(n,r)&&t.push(n);t.length&&this.invalidate(t)}put(e){let t=this.byArea.get(e.area)??[];this.byArea.set(e.area,[...t.filter(t=>t.id!==e.id),e])}take(e,t){let n=this.byArea.get(e);if(!n)return!1;let r=n.filter(e=>e.id!==t);return r.length!==n.length&&(r.length?this.byArea.set(e,r):this.byArea.delete(e),!0)}invalidate(e){let t=new Set(e);for(let e of t){this.snapshot.delete(e);let t=this.areaListeners.get(e);t&&t.forEach(e=>e())}this.globalListeners.forEach(e=>e()),E.set(E.get()+1)}};export{l as _,_ as a,C as c,g as d,v as f,p as g,h,T as i,m as l,S as m,O as n,y as o,b as p,w as r,x as s,E as t,f as u};