import{d as m,p as A}from"./useEvent-WUlsM6MC.js";import{t as h}from"./compiler-runtime-B3qBwwSJ.js";import{m as s}from"./useEventListener-CjXriKgk.js";var $=h();function v(i,c){return{reducer:(o,e)=>(o||(o=i()),e.type in c?c[e.type](o,e.payload):(s.error(`Action type ${e.type} is not defined in reducers.`),o)),createActions:o=>{let e={};for(let a in c)e[a]=u=>{o({type:a,payload:u})};return e}}}function w(i,c,o){let{reducer:e,createActions:a}=v(i,c),u=(n,r)=>{try{let t=e(n,r);if(o)for(let f of o)try{f(n,t,r)}catch(d){s.error(`Error in middleware for action ${r.type}:`,d)}return t}catch(t){return s.error(`Error in reducer for action ${r.type}:`,t),n}},l=A(i()),p=new WeakMap;function y(){let n=(0,$.c)(2),r=m(l);p.has(r)||p.set(r,a(f=>{r(d=>u(d,f))}));let t;return n[0]===r?t=n[1]:(t=p.get(r),n[0]=r,n[1]=t),t}return{reducer:u,createActions:a,valueAtom:l,useActions:y}}export{w as t};
