import{j as t,f as e}from"./p-03169580.js";const n=(t,e,n)=>{const s=t.get(e);if(!s){t.set(e,[n])}else if(!s.includes(n)){s.push(n)}};const s=(t,e)=>{let n;return(...s)=>{if(n){clearTimeout(n)}n=setTimeout((()=>{n=0;t(...s)}),e)}};const o=t=>!("isConnected"in t)||t.isConnected;const r=s((t=>{for(let e of t.keys()){t.set(e,t.get(e).filter(o))}}),2e3);const c=()=>{if(typeof t!=="function"){return{}}const s=new Map;return{dispose:()=>s.clear(),get:e=>{const o=t();if(o){n(s,e,o)}},set:t=>{const n=s.get(t);if(n){s.set(t,n.filter(e))}r(s)},reset:()=>{s.forEach((t=>t.forEach(e)));r(s)}}};const i=(t,e=((t,e)=>t!==e))=>{let n=new Map(Object.entries(t!==null&&t!==void 0?t:{}));const s={dispose:[],get:[],set:[],reset:[]};const o=()=>{n=new Map(Object.entries(t!==null&&t!==void 0?t:{}));s.reset.forEach((t=>t()))};const r=()=>{s.dispose.forEach((t=>t()));o()};const c=t=>{s.get.forEach((e=>e(t)));return n.get(t)};const i=(t,o)=>{const r=n.get(t);if(e(o,r,t)){n.set(t,o);s.set.forEach((e=>e(t,o,r)))}};const f=typeof Proxy==="undefined"?{}:new Proxy(t,{get(t,e){return c(e)},ownKeys(t){return Array.from(n.keys())},getOwnPropertyDescriptor(){return{enumerable:true,configurable:true}},has(t,e){return n.has(e)},set(t,e,n){i(e,n);return true}});const p=(t,e)=>{s[t].push(e);return()=>{u(s[t],e)}};const a=(e,n)=>{const s=p("set",((t,s)=>{if(t===e){n(s)}}));const o=p("reset",(()=>n(t[e])));return()=>{s();o()}};const l=(...t)=>{const e=t.reduce(((t,e)=>{if(e.set){t.push(p("set",e.set))}if(e.get){t.push(p("get",e.get))}if(e.reset){t.push(p("reset",e.reset))}if(e.dispose){t.push(p("dispose",e.dispose))}return t}),[]);return()=>e.forEach((t=>t()))};const d=t=>{const e=n.get(t);s.set.forEach((n=>n(t,e,e)))};return{state:f,get:c,set:i,on:p,onChange:a,use:l,dispose:r,reset:o,forceUpdate:d}};const u=(t,e)=>{const n=t.indexOf(e);if(n>=0){t[n]=t[t.length-1];t.length--}};const f=(t,e)=>{const n=i(t,e);n.use(c());return n};export{f as c};
//# sourceMappingURL=p-59c95c5f.js.map