import{l as c,k as b,ae as p,af as d,u as g,J as l,a8 as m}from"./CNYbWU2B.js";function h(n,e,s){if(n==null)return e(void 0),c;const u=b(()=>n.subscribe(e,s));return u.unsubscribe?()=>u.unsubscribe():u}const i=[];function y(n,e=c){let s=null;const u=new Set;function r(o){if(p(n,o)&&(n=o,s)){const f=!i.length;for(const t of u)t[1](),i.push(t,n);if(f){for(let t=0;t<i.length;t+=2)i[t][0](i[t+1]);i.length=0}}}function a(o){r(o(n))}function _(o,f=c){const t=[o,f];return u.add(t),u.size===1&&(s=e(r,a)||c),o(n),()=>{u.delete(t),u.size===0&&s&&(s(),s=null)}}return{set:r,update:a,subscribe:_}}function w(n){let e;return h(n,s=>e=s)(),e}function x(n){l===null&&d(),m&&l.l!==null?k(l).m.push(n):g(()=>{const e=b(n);if(typeof e=="function")return e})}function k(n){var e=n.l;return e.u??(e.u={a:[],b:[],m:[]})}export{w as g,x as o,h as s,y as w};
