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