import{R as O}from"./vendor-react-BUCujlKS.js";const R=t=>{let e;const n=new Set,o=(v,s)=>{const m=typeof v=="function"?v(e):v;if(!Object.is(m,e)){const b=e;e=s??(typeof m!="object"||m===null)?m:Object.assign({},e,m),n.forEach(d=>d(e,b))}},r=()=>e,u={setState:o,getState:r,getInitialState:()=>S,subscribe:v=>(n.add(v),()=>n.delete(v))},S=e=t(o,r,u);return u},P=(t=>t?R(t):R),L=t=>t;function F(t,e=L){const n=O.useSyncExternalStore(t.subscribe,O.useCallback(()=>e(t.getState()),[t,e]),O.useCallback(()=>e(t.getInitialState()),[t,e]));return O.useDebugValue(n),n}const C=t=>{const e=P(t),n=o=>F(e,o);return Object.assign(n,e),n},q=(t=>t?C(t):C),x={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},k=t=>!!t.dispatchFromDevtools&&typeof t.dispatch=="function",I=new Map,w=t=>{const e=I.get(t);return e?Object.fromEntries(Object.entries(e.stores).map(([n,o])=>[n,o.getState()])):{}},U=(t,e,n)=>{if(t===void 0)return{type:"untracked",connection:e.connect(n)};const o=I.get(n.name);if(o)return{type:"tracked",store:t,...o};const r={connection:e.connect(n),stores:{}};return I.set(n.name,r),{type:"tracked",store:t,...r}},H=(t,e)=>{if(e===void 0)return;const n=I.get(t);n&&(delete n.stores[e],Object.keys(n.stores).length===0&&I.delete(t))},z=t=>{var e,n;if(!t)return;const o=t.split(`
`),r=o.findIndex(y=>y.includes("api.setState"));if(r<0)return;const i=((e=o[r+1])==null?void 0:e.trim())||"";return(n=/.+ (.+) .+/.exec(i))==null?void 0:n[1]},$=(t,e={})=>(n,o,r)=>{const{enabled:i,anonymousActionType:y,store:u,...S}=e;let v;try{v=(i??(x?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!v)return t(n,o,r);const{connection:s,...m}=U(u,v,S);let b=!0;r.setState=((l,a,c)=>{const f=n(l,a);if(!b)return f;const _=c===void 0?{type:y||z(new Error().stack)||"anonymous"}:typeof c=="string"?{type:c}:c;return u===void 0?(s?.send(_,o()),f):(s?.send({..._,type:`${u}/${_.type}`},{...w(S.name),[u]:r.getState()}),f)}),r.devtools={cleanup:()=>{s&&typeof s.unsubscribe=="function"&&s.unsubscribe(),H(S.name,u)}};const d=(...l)=>{const a=b;b=!1,n(...l),b=a},h=t(r.setState,o,r);if(m.type==="untracked"?s?.init(h):(m.stores[m.store]=r,s?.init(Object.fromEntries(Object.entries(m.stores).map(([l,a])=>[l,l===m.store?h:a.getState()])))),k(r)){let l=!1;const a=r.dispatch;r.dispatch=(...c)=>{(x?"production":void 0)!=="production"&&c[0].type==="__setState"&&!l&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),l=!0),a(...c)}}return s.subscribe(l=>{var a;switch(l.type){case"ACTION":if(typeof l.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return j(l.payload,c=>{if(c.type==="__setState"){if(u===void 0){d(c.state);return}Object.keys(c.state).length!==1&&console.error(`
                    [zustand devtools middleware] Unsupported __setState action format.
                    When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
                    and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
                    `);const f=c.state[u];if(f==null)return;JSON.stringify(r.getState())!==JSON.stringify(f)&&d(f);return}k(r)&&r.dispatch(c)});case"DISPATCH":switch(l.payload.type){case"RESET":return d(h),u===void 0?s?.init(r.getState()):s?.init(w(S.name));case"COMMIT":if(u===void 0){s?.init(r.getState());return}return s?.init(w(S.name));case"ROLLBACK":return j(l.state,c=>{if(u===void 0){d(c),s?.init(r.getState());return}d(c[u]),s?.init(w(S.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return j(l.state,c=>{if(u===void 0){d(c);return}JSON.stringify(r.getState())!==JSON.stringify(c[u])&&d(c[u])});case"IMPORT_STATE":{const{nextLiftedState:c}=l.payload,f=(a=c.computedStates.slice(-1)[0])==null?void 0:a.state;if(!f)return;d(u===void 0?f:f[u]),s?.send(null,c);return}case"PAUSE_RECORDING":return b=!b}return}}),h},Q=$,j=(t,e)=>{let n;try{n=JSON.parse(t)}catch(o){console.error("[zustand devtools middleware] Could not parse the received json",o)}n!==void 0&&e(n)};function A(t,e){let n;try{n=t()}catch{return}return{getItem:r=>{var i;const y=S=>S===null?null:JSON.parse(S,void 0),u=(i=n.getItem(r))!=null?i:null;return u instanceof Promise?u.then(y):y(u)},setItem:(r,i)=>n.setItem(r,JSON.stringify(i,void 0)),removeItem:r=>n.removeItem(r)}}const T=t=>e=>{try{const n=t(e);return n instanceof Promise?n:{then(o){return T(o)(n)},catch(o){return this}}}catch(n){return{then(o){return this},catch(o){return T(o)(n)}}}},W=(t,e)=>(n,o,r)=>{let i={storage:A(()=>window.localStorage),partialize:a=>a,version:0,merge:(a,c)=>({...c,...a}),...e},y=!1,u=0;const S=new Set,v=new Set;let s=i.storage;if(!s)return t((...a)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...a)},o,r);const m=()=>{const a=i.partialize({...o()});return s.setItem(i.name,{state:a,version:i.version})},b=r.setState;r.setState=(a,c)=>(b(a,c),m());const d=t((...a)=>(n(...a),m()),o,r);r.getInitialState=()=>d;let h;const l=()=>{var a,c;if(!s)return;const f=++u;y=!1,S.forEach(p=>{var g;return p((g=o())!=null?g:d)});const _=((c=i.onRehydrateStorage)==null?void 0:c.call(i,(a=o())!=null?a:d))||void 0;return T(s.getItem.bind(s))(i.name).then(p=>{if(p)if(typeof p.version=="number"&&p.version!==i.version){if(i.migrate){const g=i.migrate(p.state,p.version);return g instanceof Promise?g.then(E=>[!0,E]):[!0,g]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,p.state];return[!1,void 0]}).then(p=>{var g;if(f!==u)return;const[E,M]=p;if(h=i.merge(M,(g=o())!=null?g:d),n(h,!0),E)return m()}).then(()=>{f===u&&(_?.(h,void 0),h=o(),y=!0,v.forEach(p=>p(h)))}).catch(p=>{f===u&&_?.(void 0,p)})};return r.persist={setOptions:a=>{i={...i,...a},a.storage&&(s=a.storage)},clearStorage:()=>{s?.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>l(),hasHydrated:()=>y,onHydrate:a=>(S.add(a),()=>{S.delete(a)}),onFinishHydration:a=>(v.add(a),()=>{v.delete(a)})},i.skipHydration||l(),h||d},V=W,D=t=>Symbol.iterator in t,N=t=>"entries"in t,J=(t,e)=>{const n=t instanceof Map?t:new Map(t.entries()),o=e instanceof Map?e:new Map(e.entries());if(n.size!==o.size)return!1;for(const[r,i]of n)if(!o.has(r)||!Object.is(i,o.get(r)))return!1;return!0},X=(t,e)=>{const n=t[Symbol.iterator](),o=e[Symbol.iterator]();let r=n.next(),i=o.next();for(;!r.done&&!i.done;){if(!Object.is(r.value,i.value))return!1;r=n.next(),i=o.next()}return!!r.done&&!!i.done};function G(t,e){return Object.is(t,e)?!0:typeof t!="object"||t===null||typeof e!="object"||e===null||Object.getPrototypeOf(t)!==Object.getPrototypeOf(e)?!1:D(t)&&D(e)?N(t)&&N(e)?J(t,e):X(t,e):J({entries:()=>Object.entries(t)},{entries:()=>Object.entries(e)})}function Y(t){const e=O.useRef(void 0);return n=>{const o=t(n);return G(e.current,o)?e.current:e.current=o}}export{A as a,F as b,q as c,Q as d,V as p,Y as u};
