!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react"),require("proxy-compare"),require("use-sync-external-store/shim"),require("valtio/vanilla")):"function"==typeof define&&define.amd?define(["exports","react","proxy-compare","use-sync-external-store/shim","valtio/vanilla"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).valtioReact={},e.React,e.proxyCompare,e.useSyncExternalStoreExports,e.valtioVanilla)}(this,(function(e,r,n,t,a){"use strict";var u=r.use,o=t.useSyncExternalStore,s=new WeakMap;e.useSnapshot=function(e,t){var c=null==t?void 0:t.sync,i=r.useRef(),f=r.useRef(),l=!0,p=o(r.useCallback((function(r){var n=a.subscribe(e,r,c);return r(),n}),[e,c]),(function(){var r=a.snapshot(e,u);try{if(!l&&i.current&&f.current&&!n.isChanged(i.current,r,f.current,new WeakMap))return i.current}catch(e){}return r}),(function(){return a.snapshot(e,u)}));l=!1;var y=new WeakMap;r.useEffect((function(){i.current=p,f.current=y}));var v=r.useMemo((function(){return new WeakMap}),[]);return n.createProxy(p,y,v,s)}}));
