import{r as c}from"./index.2yJIXLcc.js";function f(e,t,u){let r=new Set([...t,void 0]);return e.listen((i,l,n)=>{r.has(n)&&u(i,l,n)})}let s=(e,t)=>u=>{e.current!==u&&(e.current=u,t())};function a(e,{keys:t,deps:u=[e,t]}={}){let r=c.useRef();r.current=e.get();let i=c.useCallback(n=>(s(r,n)(e.value),t?.length>0?f(e,t,s(r,n)):e.listen(s(r,n))),u),l=()=>r.current;return c.useSyncExternalStore(i,l,l)}export{a as u};
