import{R as e,u as t}from"./vendor-react-AXa6hZO5.js";const n=e=>{let t;const n=new Set,r=(e,r)=>{const o="function"==typeof e?e(t):e;if(!Object.is(o,t)){const e=t;t=(null!=r?r:"object"!=typeof o||null===o)?o:Object.assign({},t,o),n.forEach(n=>n(t,e))}},o=()=>t,s={setState:r,getState:o,getInitialState:()=>a,subscribe:e=>(n.add(e),()=>n.delete(e))},a=t=e(r,o,s);return s},r=e=>e?n(e):n,o=e=>e;function s(t,n=o){const r=e.useSyncExternalStore(t.subscribe,e.useCallback(()=>n(t.getState()),[t,n]),e.useCallback(()=>n(t.getInitialState()),[t,n]));return e.useDebugValue(r),r}const a=e=>{const t=r(e),n=e=>s(t,e);return Object.assign(n,t),n},i=e=>e?a(e):a,c=e=>Symbol.iterator in e,u=e=>"entries"in e,l=(e,t)=>{const n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(const[o,s]of n)if(!Object.is(s,r.get(o)))return!1;return!0};function d(e,t){return!!Object.is(e,t)||"object"==typeof e&&null!==e&&"object"==typeof t&&null!==t&&(Object.getPrototypeOf(e)===Object.getPrototypeOf(t)&&(c(e)&&c(t)?u(e)&&u(t)?l(e,t):((e,t)=>{const n=e[Symbol.iterator](),r=t[Symbol.iterator]();let o=n.next(),s=r.next();for(;!o.done&&!s.done;){if(!Object.is(o.value,s.value))return!1;o=n.next(),s=r.next()}return!!o.done&&!!s.done})(e,t):l({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})))}function f(t){const n=e.useRef(void 0);return e=>{const r=t(e);return d(n.current,r)?n.current:n.current=r}}const b=e=>(t,n,r)=>{const o=r.subscribe;r.subscribe=(e,t,n)=>{let s=e;if(t){const o=(null==n?void 0:n.equalityFn)||Object.is;let a=e(r.getState());s=n=>{const r=e(n);if(!o(a,r)){const e=a;t(a=r,e)}},(null==n?void 0:n.fireImmediately)&&t(a,a)}return o(s)};return e(t,n,r)};function g(e,t){let n;try{n=e()}catch(r){return}return{getItem:e=>{var t;const r=e=>null===e?null:JSON.parse(e,void 0),o=null!=(t=n.getItem(e))?t:null;return o instanceof Promise?o.then(r):r(o)},setItem:(e,t)=>n.setItem(e,JSON.stringify(t,void 0)),removeItem:e=>n.removeItem(e)}}const m=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then:e=>m(e)(n),catch(e){return this}}}catch(n){return{then(e){return this},catch:e=>m(e)(n)}}},v=(e,t)=>(n,r,o)=>{let s={storage:g(()=>localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},a=!1;const i=new Set,c=new Set;let u=s.storage;if(!u)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...e)},r,o);const l=()=>{const e=s.partialize({...r()});return u.setItem(s.name,{state:e,version:s.version})},d=o.setState;o.setState=(e,t)=>{d(e,t),l()};const f=e((...e)=>{n(...e),l()},r,o);let b;o.getInitialState=()=>f;const v=()=>{var e,t;if(!u)return;a=!1,i.forEach(e=>{var t;return e(null!=(t=r())?t:f)});const o=(null==(t=s.onRehydrateStorage)?void 0:t.call(s,null!=(e=r())?e:f))||void 0;return m(u.getItem.bind(u))(s.name).then(e=>{if(e){if("number"!=typeof e.version||e.version===s.version)return[!1,e.state];if(s.migrate){const t=s.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}return[!1,void 0]}).then(e=>{var t;const[o,a]=e;if(b=s.merge(a,null!=(t=r())?t:f),n(b,!0),o)return l()}).then(()=>{null==o||o(b,void 0),b=r(),a=!0,c.forEach(e=>e(b))}).catch(e=>{null==o||o(void 0,e)})};return o.persist={setOptions:e=>{s={...s,...e},e.storage&&(u=e.storage)},clearStorage:()=>{null==u||u.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>v(),hasHydrated:()=>a,onHydrate:e=>(i.add(e),()=>{i.delete(e)}),onFinishHydration:e=>(c.add(e),()=>{c.delete(e)})},s.skipHydration||v(),b||f},{useSyncExternalStoreWithSelector:S}=t,p=e=>e;function y(t,n=p,r){const o=S(t.subscribe,t.getState,t.getInitialState,n,r);return e.useDebugValue(o),o}export{g as a,r as b,i as c,s as d,y as e,d as f,v as p,b as s,f as u};
