@storesjs/stores 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -29
- package/dist/createBaseStore.d.ts +6 -6
- package/dist/createDerivedStore.d.ts +9 -17
- package/dist/createQueryStore.d.ts +4 -3
- package/dist/createVirtualStore.d.ts +1 -2
- package/dist/env.native.d.ts +0 -2
- package/dist/env.web.d.ts +0 -1
- package/dist/hooks/useListen.d.ts +2 -2
- package/dist/index.d.ts +1 -16
- package/dist/index.shared.d.ts +14 -0
- package/dist/index.vanilla.d.ts +2 -0
- package/dist/internal/baseStore.d.ts +2 -0
- package/dist/{config.d.ts → internal/config.d.ts} +5 -11
- package/dist/{utils → internal}/createStoreActions.d.ts +4 -5
- package/dist/{derivedStore → internal/derivedStore}/deriveProxy.d.ts +2 -2
- package/dist/{derivedStore → internal/derivedStore}/pathFinder.d.ts +1 -2
- package/dist/internal/derivedStore.d.ts +2 -0
- package/dist/{errors.d.ts → internal/errors.d.ts} +0 -4
- package/dist/{logger.d.ts → internal/logger.d.ts} +0 -2
- package/dist/internal/middleware/createHydrationGate.d.ts +20 -0
- package/dist/internal/queryStore/queryStoreDefaults.d.ts +8 -0
- package/dist/internal/queryStore.d.ts +2 -0
- package/dist/internal/runtime.d.ts +13 -0
- package/dist/internal/signal.d.ts +12 -0
- package/dist/internal/storage/storageCreators.d.ts +12 -0
- package/dist/{utils → internal}/storeUtils.d.ts +3 -21
- package/dist/internal/sync/browserSyncEngine.d.ts +3 -0
- package/dist/internal/sync/noopSyncEngine.d.ts +3 -0
- package/dist/internal/sync/syncEnhancer.d.ts +26 -0
- package/dist/{sync → internal/sync}/syncUtils.d.ts +1 -1
- package/dist/internal/utils/persistUtils.d.ts +9 -0
- package/dist/internal/virtualStore.d.ts +2 -0
- package/dist/native/index.js +1 -1
- package/dist/native/index.mjs +1 -1
- package/dist/queryStore/queryKey.d.ts +3 -0
- package/dist/queryStore/signalTypes.d.ts +4 -3
- package/dist/queryStore/types.d.ts +5 -4
- package/dist/store/attachStoreHook.react.d.ts +5 -0
- package/dist/store/attachStoreHook.vanilla.d.ts +6 -0
- package/dist/store/batchStoreNotifications.native.d.ts +3 -0
- package/dist/store/batchStoreNotifications.web.d.ts +2 -0
- package/dist/store/createStore.d.ts +6 -0
- package/dist/store/persist.d.ts +14 -0
- package/dist/store/stateUpdate.d.ts +10 -0
- package/dist/store/types.d.ts +108 -0
- package/dist/types/setState.d.ts +22 -0
- package/dist/types/subscribe.d.ts +28 -0
- package/dist/types/useStoreCallSignatures.d.ts +2 -0
- package/dist/types/useStoreCallSignatures.react.d.ts +6 -0
- package/dist/types/useStoreCallSignatures.vanilla.d.ts +2 -0
- package/dist/types/utils.d.ts +4 -0
- package/dist/types.d.ts +43 -93
- package/dist/utils/time.d.ts +0 -7
- package/dist/vanilla/createBaseStore.d.ts +35 -0
- package/dist/vanilla/createDerivedStore.d.ts +62 -0
- package/dist/vanilla/createQueryStore.d.ts +116 -0
- package/dist/vanilla/createVirtualStore.d.ts +39 -0
- package/dist/vanilla/env.web.d.ts +6 -0
- package/dist/vanilla/index.d.ts +1 -0
- package/dist/vanilla/index.js +1 -0
- package/dist/vanilla/index.mjs +1 -0
- package/dist/vanilla/index.shared.d.ts +13 -0
- package/dist/vanilla/index.vanilla.d.ts +1 -0
- package/dist/vanilla/internal/baseStore.d.ts +1 -0
- package/dist/vanilla/internal/config.d.ts +63 -0
- package/dist/vanilla/internal/createStoreActions.d.ts +23 -0
- package/dist/vanilla/internal/derivedStore/cascadeScheduler.d.ts +30 -0
- package/dist/vanilla/internal/derivedStore/deriveProxy.d.ts +14 -0
- package/dist/vanilla/internal/derivedStore/pathFinder.d.ts +25 -0
- package/dist/vanilla/internal/derivedStore.d.ts +1 -0
- package/dist/vanilla/internal/errors.d.ts +9 -0
- package/dist/vanilla/internal/logger.d.ts +9 -0
- package/dist/{middleware → vanilla/internal/middleware}/createHydrationGate.d.ts +1 -2
- package/dist/{queryStore → vanilla/internal/queryStore}/queryStoreDefaults.d.ts +1 -2
- package/dist/vanilla/internal/queryStore.d.ts +1 -0
- package/dist/vanilla/internal/runtime.d.ts +12 -0
- package/dist/vanilla/internal/signal.d.ts +11 -0
- package/dist/vanilla/internal/storage/storageCreators.d.ts +11 -0
- package/dist/vanilla/internal/storeUtils.d.ts +45 -0
- package/dist/vanilla/internal/sync/browserSyncEngine.d.ts +2 -0
- package/dist/vanilla/internal/sync/noopSyncEngine.d.ts +2 -0
- package/dist/{sync → vanilla/internal/sync}/syncEnhancer.d.ts +2 -3
- package/dist/{utils → vanilla/internal/utils}/persistUtils.d.ts +1 -2
- package/dist/vanilla/internal/virtualStore.d.ts +1 -0
- package/dist/vanilla/queryStore/classes/SubscriptionManager.d.ts +66 -0
- package/dist/vanilla/queryStore/queryKey.d.ts +2 -0
- package/dist/vanilla/queryStore/signalTypes.d.ts +13 -0
- package/dist/vanilla/queryStore/types.d.ts +402 -0
- package/dist/vanilla/storage/storageTypes.d.ts +12 -0
- package/dist/vanilla/store/attachStoreHook.d.ts +5 -0
- package/dist/vanilla/store/attachStoreHook.vanilla.d.ts +5 -0
- package/dist/vanilla/store/batchStoreNotifications.web.d.ts +1 -0
- package/dist/vanilla/store/createStore.d.ts +5 -0
- package/dist/vanilla/store/persist.d.ts +13 -0
- package/dist/vanilla/store/stateUpdate.d.ts +9 -0
- package/dist/vanilla/store/types.d.ts +107 -0
- package/dist/vanilla/storesStorage.web.d.ts +2 -0
- package/dist/vanilla/sync/types.d.ts +114 -0
- package/dist/vanilla/types/functions.d.ts +23 -0
- package/dist/vanilla/types/objects.d.ts +10 -0
- package/dist/vanilla/types/setState.d.ts +21 -0
- package/dist/vanilla/types/subscribe.d.ts +27 -0
- package/dist/vanilla/types/useStoreCallSignatures.d.ts +1 -0
- package/dist/vanilla/types/useStoreCallSignatures.vanilla.d.ts +1 -0
- package/dist/vanilla/types/utils.d.ts +12 -0
- package/dist/vanilla/types.d.ts +285 -0
- package/dist/vanilla/utils/core.d.ts +25 -0
- package/dist/vanilla/utils/createAsyncMicrotaskScheduler.d.ts +34 -0
- package/dist/vanilla/utils/createMicrotaskScheduler.d.ts +27 -0
- package/dist/vanilla/utils/debounce.d.ts +21 -0
- package/dist/vanilla/utils/equality.d.ts +37 -0
- package/dist/vanilla/utils/hydrationCoordinator.d.ts +12 -0
- package/dist/vanilla/utils/promiseUtils.d.ts +1 -0
- package/dist/vanilla/utils/serialization.d.ts +13 -0
- package/dist/vanilla/utils/stringUtils.d.ts +6 -0
- package/dist/vanilla/utils/time.d.ts +36 -0
- package/dist/web/chrome.js +1 -1
- package/dist/web/chrome.mjs +1 -1
- package/dist/web/chunk-QJLWBD7M.mjs +1 -0
- package/dist/web/chunk-V4LHP7LR.mjs +1 -0
- package/dist/web/index.js +1 -1
- package/dist/web/index.mjs +1 -1
- package/dist/web/internal/runtime.js +1 -0
- package/dist/web/internal/runtime.mjs +1 -0
- package/package.json +13 -11
- package/dist/createStoreWithEqualityFn.d.ts +0 -5
- package/dist/hooks/compareHooks.d.ts +0 -50
- package/dist/signal.d.ts +0 -11
- package/dist/storage/storageCreators.d.ts +0 -22
- package/dist/sync/browserSyncEngine.d.ts +0 -3
- package/dist/sync/noopSyncEngine.d.ts +0 -3
- package/dist/web/chunk-3U5A7HQV.mjs +0 -1
- /package/dist/{derivedStore → internal/derivedStore}/cascadeScheduler.d.ts +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { StorageValue } from '../../storage/storageTypes';
|
|
2
|
+
/**
|
|
3
|
+
* Default partialize function if none is provided. It omits top-level store
|
|
4
|
+
* methods and keeps all other state.
|
|
5
|
+
*/
|
|
6
|
+
export declare function omitStoreMethods<S, PersistedState extends Partial<S> = Partial<S>>(state: S): PersistedState;
|
|
7
|
+
export declare function defaultSerializeState<PersistedState>(storageValue: StorageValue<PersistedState>, shouldUseReplacer: boolean): string;
|
|
8
|
+
export declare function defaultDeserializeState<PersistedState>(serializedState: string, shouldUseReviver: boolean): StorageValue<PersistedState>;
|
|
9
|
+
//# sourceMappingURL=persistUtils.d.ts.map
|
package/dist/native/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=require("react-native"),t=require("zustand/middleware"),n=require("zustand/vanilla"),r=require("react"),o=(e=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(e,{get:(e,t)=>("undefined"!=typeof require?require:e)[t]}):e)(function(e){if("undefined"!=typeof require)return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),i="ios"===e.Platform.OS;e.Platform.OS;var s="development"===process.env.NODE_ENV,c="test"===process.env.NODE_ENV;function a(e){let t;function n(){if(t)return t;try{const n=function(e){const{createMMKV:t,MMKV:n}=o("react-native-mmkv");if("function"==typeof t)return t({id:e});if("function"==typeof n)return new n({id:e});throw new Error("[stores]: react-native-mmkv module does not export MMKV/createMMKV.")}(e);let r;if("function"==typeof n.delete?r=n.delete.bind(n):"function"==typeof n.remove&&(r=n.remove.bind(n)),"function"!=typeof r)throw new Error("[stores]: Storage instance does not conform to expected interface");const i={clearAll:n.clearAll.bind(n),contains:n.contains.bind(n),delete:r,get:n.getString.bind(n),getAllKeys:n.getAllKeys.bind(n),set:n.set.bind(n)};t=i}catch(e){throw new Error("[stores] react-native-mmkv could not be loaded.\n\nPersisted stores require a storage backend. Either:\n - Install MMKV (the default): yarn add react-native-mmkv\n - Or provide a custom adapter via configureStores()\n"+(e instanceof Error?`\n${e.message}`:""))}return function(e){if(!e||"function"!=typeof e.get||"function"!=typeof e.set||"function"!=typeof e.delete||"function"!=typeof e.clearAll)throw new Error("[stores]: Storage instance does not conform to expected interface")}(t),t}return{clearAll:()=>n().clearAll(),contains:e=>n().contains(e),delete:e=>n().delete(e),get:e=>n().get(e),getAllKeys:()=>n().getAllKeys(),set:(e,t)=>n().set(e,t)}}var u={debug:(e,t)=>{s&&console.debug(e,t)},error:(e,t)=>{s&&!c&&console.error(e,t)},info:(e,t)=>{s&&console.info(e,t)},warn:(e,t)=>{s&&console.warn(e,t)}},l=class extends Error{constructor(e,t){super(e),this.name="StoresError",void 0!==t&&Object.defineProperty(this,"cause",{configurable:!0,value:t,writable:!0})}};function f(e){return e instanceof Error?e:new Error(String(e))}var d=Object.prototype.hasOwnProperty;function y(e,t){return d.call(e,t)}function p(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function h(e){return e}function g(){}Object.freeze(Object.create(null));var b,m,S,v=class{destroy(){}publish(){}},w=class{constructor(){this.sessionId="noop"}register(e){return new v}},q=!1;function O(){return S??(S=F(void 0))}function j(){q=!0}function F(e){return{storage:e?.storage??a(e?.storageKeyPrefix??"stores:"),syncEngine:e?.syncEngine??(b||(b=new w),b)}}var _=Symbol("empty selection"),A=Object.is;function C(e,t,n,o,i=A){const s=r.useRef(null);let c=e,a=t,u=n;if(o){let r=s.current;null===r&&(r=function(e,t,n,r,o){const i={committedEqualityFn:o,committedSelector:r,committedSource:e,committedValue:_,equalityFn:o,getSelectedServerSnapshot:()=>function(e){return T(e,(e.getServerStoreSnapshot??e.getStoreSnapshot)())}(i),getSelectedSnapshot:()=>I(i),getServerStoreSnapshot:n,getStoreSnapshot:t,latestSnapshot:_,latestSource:_,selector:r,selectedSource:e,selectedSubscribe:()=>g,source:e,value:_,valueEqualityFn:o,valueSelector:r,valueSnapshot:_};return i.selectedSubscribe=k(i,e),i}(e,t,n,o,i),s.current=r),function(e,t,n,r,o,i){e.source===t&&e.getStoreSnapshot===n||(e.latestSnapshot=_),e.source=t,e.getStoreSnapshot=n,e.getServerStoreSnapshot=r,e.selector=o,e.equalityFn=i,e.selectedSource!==t&&(e.selectedSource=t,e.selectedSubscribe=k(e,t))}(r,e,t,n,o,i),c=r.selectedSubscribe,a=r.getSelectedSnapshot,u=void 0===n?void 0:r.getSelectedServerSnapshot}const l=r.useSyncExternalStore(c,a,u);return r.useDebugValue(l),l}function k(e,t){return n=>(function(e){e.committedEqualityFn=e.equalityFn,e.committedSelector=e.selector,e.committedSource=e.source,e.committedValue=e.value===_?I(e):e.value}(e),t(r=>{e.latestSnapshot=r,e.latestSource=t;const o=e.committedValue;if(o===_||e.committedSource!==t)return void n();const i=e.committedSelector,s=e.committedEqualityFn;if(e.selector===i&&e.equalityFn===s){const t=i(r);if(s===A?A(o,t):s(o,t))return;return e.committedValue=t,e.value=t,e.valueEqualityFn=s,e.valueSelector=i,e.valueSnapshot=r,void n()}if(e.source!==t)return void n();const c=e.value;if(c===_)return;const a=e.selector(r),u=e.equalityFn(c,a);e.committedEqualityFn=e.equalityFn,e.committedSelector=e.selector,e.committedValue=E(e,r,u?c:a),u||n()}))}function I(e){const t=function(e){if(e.latestSource===e.source&&e.latestSnapshot!==_)return e.latestSnapshot;const t=e.getStoreSnapshot();return e.latestSnapshot=t,e.latestSource=e.source,t}(e);return T(e,t)}function T(e,t){const n=e.value;if(n!==_&&A(e.valueSnapshot,t)&&e.valueSelector===e.selector&&e.valueEqualityFn===e.equalityFn)return n;const r=e.selector(t);if(n!==_&&(e.equalityFn===A?A(n,r):e.equalityFn(n,r)))return E(e,t,n);const o=e.committedValue;return o!==_&&o!==n&&e.committedSource===e.source&&(e.equalityFn===A?A(o,r):e.equalityFn(o,r))?E(e,t,o):E(e,t,r)}function E(e,t,n){return e.value=n,e.valueEqualityFn=e.equalityFn,e.valueSelector=e.selector,e.valueSnapshot=t,n}function x(e,t){return(e,t)=>function(e,t){const r=n.createStore(e);return Object.assign(function(e,n){return C(r.subscribe,r.getState,r.getInitialState,e,n??t)},r)}(e,t)}function D(){let e,t,n=!1;return{complete:function(){!n&&e&&(n=!0,e(),e=void 0,t=void 0)},isHydrated:function(){return n},fail:function(r){!n&&t&&(n=!0,t(r),t=void 0,e=void 0)},promise:new Promise((n,r)=>{e=n,t=r})}}var M=Math.max,z=Math.min;function K(e,t=0,n={}){let r,o,i,s,c,a,u=0,l=!1,f=!1,d=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function y(t){const n=r,i=o;return r=o=void 0,u=t,s=n?e.apply(i,n):e.apply(i),s}function p(e){const n=e-(a??0);return void 0===a||n>=t||n<0||f&&void 0!==i&&e-u>=i}function h(){const e=P();if(p(e))return g(e);c=setTimeout(h,function(e){const n=t-(e-(a??0));return f&&void 0!==i?z(n,i-(e-u)):n}(e))}function g(e){return c=void 0,d&&r?y(e):(r=o=void 0,s)}function b(...e){const n=P(),i=p(n);if(r=e,o=this,a=n,i){if(void 0===c)return function(e){return u=e,c=setTimeout(h,t),l?y(e):s}(a);if(f)return clearTimeout(c),c=setTimeout(h,t),y(a)}return void 0===c&&(c=setTimeout(h,t)),s}return t=R(t)||0,function(e){const t=typeof e;return null!==e&&("object"===t||"function"===t)}(n)&&(l=!!n.leading,f="maxWait"in n,i=f?M(R(n.maxWait)||0,t):void 0,d="trailing"in n?!!n.trailing:d),b.cancel=function(){void 0!==c&&clearTimeout(c),u=0,r=a=o=c=void 0},b.flush=function(){return void 0===c?s:g(P())},b}function P(){return"undefined"!=typeof performance&&"function"==typeof performance.now?performance.now():Date.now()}function R(e){if("number"==typeof e)return e;if("symbol"==typeof e||void 0===e)return NaN;if("object"==typeof e&&null!==e){const t="function"==typeof e.valueOf?e.valueOf():e;e="object"==typeof t?t+"":t}return"string"!=typeof e?0===e?e:+e:(e=e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),/^0b[01]+$/i.test(e)?parseInt(e.slice(2),2):/^0o[0-7]+$/i.test(e)?parseInt(e.slice(2),8):/^[-+]0x[0-9a-f]+$/i.test(e)?NaN:+e)}function $(e,t){return t instanceof Map?{__type:"Map",entries:Array.from(t.entries())}:t instanceof Set?{__type:"Set",values:Array.from(t)}:t}function L(e,t){return function(e){return"object"==typeof e&&null!==e&&"__type"in e&&"Map"===e.__type}(t)?new Map(t.entries):function(e){return"object"==typeof e&&null!==e&&"__type"in e&&"Set"===e.__type}(t)?new Set(t.values):t}function V(e){if(!p(e))return e;const t={__proto__:null},n=Object.keys(e);for(let r=0;r<n.length;r++){const o=n[r],i=e[o];"function"!=typeof i&&(t[o]=i)}return t}var N={ms:e=>e,seconds:e=>1e3*e,minutes:e=>6e4*e,hours:e=>36e5*e,days:e=>864e5*e,weeks:e=>6048e5*e,infinity:1/0,zero:0},W=c?0:N.seconds(i?3:5);function U(e){return t=>{if("string"!=typeof t)throw new l("[createBaseStore]: Received non-string serialized state without a custom deserializer. Provide a deserializer on the store or storage adapter.");return function(e,t){try{return JSON.parse(e,t?L:void 0)}catch(e){throw u.error(new l("[createBaseStore]: Failed to deserialize persisted store data",e)),e}}(t,e)}}function H(e){return t=>function(e,t){try{return JSON.stringify(e,t?$:void 0)}catch(e){throw u.error(new l("[createBaseStore]: Failed to serialize store data",e)),e}}(t,e)}var Q=Object.freeze({shouldClear:!1});function B(e,t,n){if(!t||!e)return Q;const r=e.getFieldTimestampSnapshot();return function(e,t){const n=e.getSessionId(),r=e.getTimestamp();void 0!==n&&void 0!==r&&(t.syncMetadata={origin:n,timestamp:r})}(e,n),n.syncMetadata?r&&Object.keys(r).length>0?(n.syncMetadata.fields=r,{fieldSnapshot:r,shouldClear:!0}):(delete n.syncMetadata.fields,{fieldSnapshot:r,shouldClear:!1}):{fieldSnapshot:r,shouldClear:!1}}function J(e,t){e&&t.shouldClear&&t.fieldSnapshot&&Object.keys(t.fieldSnapshot).length&&e.clearFieldTimestamps(t.fieldSnapshot)}function G(e){return!!e&&!!e.getIsApplyingRemote()}var X=Object.freeze({QueryStore:Symbol("queryStore"),VirtualStore:Symbol("virtualStore")});function Y(e,...t){if(!0===t[1])return oe(t[0])?t[0](e):t[0];const n=oe(t[0])?t[0](e):t[0];return function(e){return Array.isArray(e)}(e)?n:{...e,...n}}function Z(e,t){te(e)?e.getState().reset(t?.clearQueryCache):function(e){return"destroy"in e}(e)&&e.destroy()}function ee(e){return"getSnapshot"in e}function te(e){return X.QueryStore in e}function ne(e){return!(!("persist"in e)||!e.persist)&&"string"==typeof e.persist.getOptions().name}function re(e){return X.VirtualStore in e}function oe(e){return"function"==typeof e}var[ie,se]=[0,1];function ce(e,t,n){if(!e)return!0;const r=e[ie],o=e[se];return!(t<r)&&(t>r||n>o)}function ae(e,t){return Object.prototype.hasOwnProperty.call(t,e)}function ue(e,t){if(!s)return!0;if(null===e||null===t)return e===t;const n=typeof e;return n===typeof t&&("object"!==n||Object.prototype.toString.call(e)===Object.prototype.toString.call(t))}function le(e){if(null===e)return"null";const t=typeof e;return"object"===t?Object.prototype.toString.call(e):t}function fe(e,n){j();const r=void 0!==n&&"string"==typeof n.storageKey,o=r?n.storageKey:void 0,i=n?.sync?function(e,t){if(!e)return null;if(!0===e){if(!t)throw new l("[createBaseStore]: sync: true requires a storageKey to inherit the key from");return{key:t}}if("string"==typeof e)return{key:e};const n=e,r=n.key??t;if(!r)throw new l("[createBaseStore]: sync requires either a key in the config or a storageKey to inherit from");return{...n,key:r}}(n.sync,o):void 0,s=r?n.storage??O().storage:void 0,c=i?function(e,t,n){const r=t.engine??O().syncEngine,o=function(e){let t,n,r,o=!1;return{isAsync:e,clearFieldTimestamps:function(e){if(e&&r){for(const t of Object.entries(e)){const e=t[0],n=t[1];r[e]===n&&delete r[e]}Object.keys(r).length||(r=void 0)}},getFieldTimestampSnapshot:function(){if(r)return{...r}},getIsApplyingRemote:()=>o,getSessionId:()=>t,getTimestamp:()=>n,mergeFieldTimestamps:function(e){if(r)for(const t of Object.entries(e)){const e=t[0],n=t[1],o=r[e];(void 0===o||n>o)&&(r[e]=n)}else r={...e}},onHydrationComplete:void 0,onHydrationFlushEnd:void 0,setIsApplyingRemote:e=>o=e,setSessionId:e=>t=e,setTimestamp:e=>n=e,setWithoutPersist:void 0}}(n);return{stateCreator:(i,s,c)=>{const a=new Map,f=[],d=[];let y=null,p=!1,h=!1,g=0,b=null,m=[],S=Promise.resolve(),v=!n;function w(e,t){if(o?.setSessionId&&o?.setTimestamp&&r.sessionId&&(o.setSessionId(r.sessionId),o.setTimestamp(e),o.mergeFieldTimestamps&&t.length>0)){const n={__proto__:null};for(const r of t)n[String(r)]=e;o.mergeFieldTimestamps(n)}}function q(e,t){if(p||!b)return t?i(e,t):i(e);const n=function(){const e=Date.now(),t=e>g?e:g+1;return g=t,t}();let o=[],s={__proto__:null};const c=r=>{const i=Y(r,e,t);for(const e of m)Object.is(i[e],r[e])||(o.push(e),s[e]=i[e]);return o.length&&w(n,o),i},u=t?i(c,!0):i(c);function l(){o.length&&function(e){const t=r.sessionId;for(const n of e.keys)a.set(n,[e.timestamp,t]);y&&h?y.publish?.({replace:e.replace,sessionId:t,timestamp:e.timestamp,values:e.values}):d.push(e)}({keys:o,replace:t??!1,values:s,timestamp:n})}return(f=u)&&"object"==typeof f&&"then"in f&&"function"==typeof f.then?u.finally(l):(l(),u);var f}const O=c.setState;c.setState=q;const j=e(q,s,c);if(m=t.fields??function(e){const t=[];for(const n of Object.entries(e)){if("function"==typeof n[1])continue;const e=n[0];t.push(e)}return t}(j),!m.length)return j;async function F(e){g=Math.max(g,e.timestamp);const n={__proto__:null},r=s(),i=e.timestamp;let c;if(e.replace)for(const t of m)ae(t,e.values)||ce(a.get(t),i,e.sessionId)&&(c??(c=[])).push(t);for(const o of m){if(!ae(o,e.values))continue;if(!b?.has(o))continue;if(!ce(a.get(o),i,e.sessionId))continue;const s=t.merge?.[o];if(s){const t=e.values[o],c=r[o];if(void 0!==t){const f=s(t,c,r,e.values),d=void 0!==c?c:t;if(!ue(f,d))return void u.error(new l(`[sync] Merge function for field "${String(o)}" returned ${le(f)} but expected ${le(d)}`));n[o]=f,a.set(o,[i,e.sessionId])}}else n[o]=e.values[o],a.set(o,[i,e.sessionId])}if(Object.keys(n).length>0||c?.length){p=!0,o&&o.setIsApplyingRemote(!0);try{if(e.replace){const e={...r};let t=!1;if(c?.length){t=!0;for(const t of c)delete e[t],a.delete(t)}for(const r in n){if(!Object.prototype.hasOwnProperty.call(n,r))continue;const o=n[r];void 0!==o&&(Object.is(e[r],o)||(t=!0),e[r]=o)}if(!t)return;await(o.setWithoutPersist??O)(e,!0)}else await(o.setWithoutPersist??O)(n)}finally{p=!1,o&&o.setIsApplyingRemote(!1)}}}function _(e){n?S=S.then(()=>F(e)):F(e)}if(b=new Set(m),y=r.register({apply:e=>{v?_(e):f.push(e)},fields:m,getState:s,key:t.key}),y?.onFirstSubscribe||y?.onLastUnsubscribe){let e=0;const t=c.subscribe;c.subscribe=(...n)=>{e||y.onFirstSubscribe?.(),e+=1;const r=1===n.length?t(n[0]):t(n[0],n[1],n[2]);return()=>{r(),e-=1,e||queueMicrotask(()=>{e||y.onLastUnsubscribe?.()})}}}function A(){h=!0,function(){if(y&&d.length){for(const e of d){const t=r.sessionId;for(const n of e.keys)a.set(n,[e.timestamp,t]);w(e.timestamp,e.keys),y.publish?.({replace:e.replace,sessionId:t,timestamp:e.timestamp,values:e.values})}d.length=0}}()}function C(){v=!0,function(){if(!f.length)return;const e=f.slice();f.length=0;for(const t of e)_(t)}()}return n?(o.onHydrationComplete=A,o.onHydrationFlushEnd=C):y.onHydrated?(y.onHydrated(A),C()):(A(),C()),j},syncContext:o}}(e,i,s?.async??!1):void 0,a=c?.stateCreator??e;if(!r)return x()(t.subscribeWithSelector(a),Object.is);const d=s?.async?function(e){let t,n,r,o=!1;return{hydrationPromise:()=>o?t?.promise??n??(n=Promise.resolve()):(t||(t=D()),t.promise),stateCreator:(n,i,s)=>{let c;return r=()=>{if(c?.length){for(const e of c)e[1]?s.setState(e[0],e[1]):s.setState(e[0]);c=void 0}},e((...e)=>o?!0===e[1]?n(e[0],e[1]):n(e[0]):(t||(t=D()),c||(c=[]),c.push(e),t.promise),i,s)},wrapOnRehydrateStorage:(e,n)=>i=>{const s=e?.(i);return(e,i)=>{o=!0,n?.onHydrationComplete?.(),r&&r(),n?.onHydrationFlushEnd?.(),i?t?.fail(f(i)):t?.complete(),s?.(e,i)}}}}(a):null,y=function(e,t,n){const r=t??e.storage??O().storage,o=(e.sync?void 0:e.persistThrottleMs??W)||void 0,i=e.version??0,s=r.async?function(e,t,n,r){const o=!(t.deserializer||t.serializer||e.deserializer||e.serializer),i="object"==typeof t.sync&&!0===(t.sync.injectStorageMetadata??t.sync.engine?.injectStorageMetadata),s=t.partialize??V,c=t.deserializer??e.deserializer??U(o),a=t.serializer??e.serializer??H(o);async function f(t,n){try{if(G(r))return;n.state,n.state=s(n.state);const o=B(r,i,n),c=a(n);try{await e.set(t,c),J(r,o)}catch(e){u.error(new l("[createBaseStore]: Failed to persist store data",e))}}catch(e){u.error(new l("[createBaseStore]: Failed to serialize persisted store data",e))}}const d=void 0!==n?K(f,n,{leading:!1,maxWait:n,trailing:!0}):function(e){let t,n=null;return function(...r){return t=r,n||(n=new Promise(r=>{queueMicrotask(async()=>{try{await e(...t)}finally{n=null,r()}})})),n}}(f);return{getItem:async t=>{const n=await e.get(t);return void 0===n?null:c(n)},setItem:async(e,t)=>{if(!r?.getIsApplyingRemote())return await d(e,t)},removeItem:async t=>{try{await e.delete(t)}catch(e){u.error(new l("[createBaseStore]: Failed to delete persisted store data",e))}}}}(r,e,o,n):function(e,t,n,r){const o=!(t.deserializer||t.serializer||e.deserializer||e.serializer),i="object"==typeof t.sync&&!0===(t.sync.injectStorageMetadata??t.sync.engine?.injectStorageMetadata),s=t.partialize??V,c=t.deserializer??e.deserializer??U(o),a=t.serializer??e.serializer??H(o);function f(t,n){try{if(G(r))return;n.state,n.state=s(n.state);const o=B(r,i,n),c=a(n);try{e.set(t,c),J(r,o)}catch(e){u.error(new l("[createBaseStore]: Failed to persist store data",e))}}catch(e){u.error(new l("[createBaseStore]: Failed to persist store data",e))}}const d=void 0!==n?K(f,n,{leading:!1,maxWait:n,trailing:!0}):f;return{getItem:t=>{const n=e.get(t);return void 0===n?null:c(n)},setItem:(e,t)=>{r?.getIsApplyingRemote()||d(e,t)},removeItem:t=>{try{e.delete(t)}catch(e){u.error(new l("[createBaseStore]: Failed to delete persisted store data",e))}}}}(r,e,o,n);return{persistStorage:s,version:i}}(n,s,c?.syncContext),p=d?d.wrapOnRehydrateStorage(n.onRehydrateStorage,c?.syncContext):n.onRehydrateStorage,h=d?(e,t,n)=>(c&&(c.syncContext.setWithoutPersist=n.setState),d.stateCreator(e,t,n)):a,g=x()(t.subscribeWithSelector(t.persist(h,function(e,t,n){const r={name:e.storageKey,onRehydrateStorage:n,storage:t.persistStorage,version:t.version};return void 0!==e.merge&&(r.merge=e.merge),void 0!==e.migrate&&(r.migrate=e.migrate),r}(n,y,p))),Object.is);return d?Object.assign(g,{persist:Object.assign(g.persist,{hydrationPromise:d.hydrationPromise})}):g}var de=!1,ye=!1,pe=new Map,he=new Map,ge=new Map,be=null,me=1/0;function Se(){return de}function ve(){return be}function we(){de||(de=!0,ye||(ye=!0,queueMicrotask(()=>{ye=!1,e.unstable_batchedUpdates(()=>{for(;he.size>0;){const e=me,t=ge.get(e);if(t){ge.delete(e);for(const e of t)he.delete(e);be=e;for(const e of t)e();if(be=null,ge.size>0){me=1/0;for(const e of ge.keys())e<me&&(me=e)}else me=1/0}else{me=1/0;for(const e of ge.keys())e<me&&(me=e)}}for(;pe.size>0;){const e=Array.from(pe.values());pe.clear();for(const t of e)t()}}),de=!1,be=null,he.clear(),ge.clear(),me=1/0})))}function qe(e,t){de&&pe.set(e,t)}var Oe=Symbol("stores.deriveProxy.unwrap");function je(e,t,n){const r=t.get(e);if(void 0!==r)return r;const o=function(e,t,n,r=[]){return e&&"object"==typeof e?Fe(e,r,t,n,new WeakSet,new WeakMap):(n(t,r,!0),e)}(ee(e)?e.getSnapshot():e.getState(),e,n);return t.set(e,o),o}function Fe(e,t,n,r,o,i){return new Proxy(e,{get(s,c,a){if(c===Oe)return r(n,t,!0),s;if(o.has(s))return Reflect.get(s,c,a);if("__proto__"===c||"symbol"==typeof c)return c===Symbol.iterator&&(r(n,t,!0),o.add(s)),Reflect.get(s,c,a);const u=Reflect.get(s,c,s),l=String(c),f=t.concat(l);if("function"==typeof u)return Object.prototype.hasOwnProperty.call(s,c)?function(...e){return r(n,f,!0,{method:l,args:e.length?e:void 0}),Reflect.apply(u,s,e)}:(r(n,t,!0),u.bind(e));const d=!!u&&"object"==typeof u;return r(n,f,!d),d?(i.has(u)||i.set(u,Fe(u,f,n,r,o,i)),i.get(u)):u},getOwnPropertyDescriptor:(e,i)=>(r(n,t,!0),o.add(e),Reflect.getOwnPropertyDescriptor(e,i)),has:(e,o)=>(r(n,t,!0),Reflect.has(e,o)),ownKeys:e=>(r(n,t,!0),o.add(e),Reflect.ownKeys(e))})}function _e(e,t){if(!e||"object"!=typeof e)return e;const n=function(e){const t=Reflect.get(e,Oe);return t&&"object"==typeof t?t:void 0}(e);return n||(Array.isArray(e)?function(e,t){const n=Ce(e,t);if(n)for(let t=0;t<e.length;t++)Ae(e,String(t),n)}(e,t):p(e)&&function(e,t){const n=Ce(e,t);if(n)for(const t of Reflect.ownKeys(e))Ae(e,t,n)}(e,t),e)}function Ae(e,t,n){const r=Reflect.getOwnPropertyDescriptor(e,t);if(!r||!("value"in r))return;const o=_e(r.value,n);o!==r.value&&(r.value=o,Reflect.defineProperty(e,t,r))}function Ce(e,t){const n=t??new WeakSet;return n.has(e)?null:(n.add(e),n)}function ke(e,t,n="s"){return 1===t?e:`${e}${n}`}var Ie=Object.freeze([]);function Te(){const e=new Map;return{buildProxySubscriptions(t,n,r,o){const i=new Set;for(const t of e)xe(t[1],t[0],[],0,i,r);!1!==o?.(i)&&function(e,t,n){for(const n of e){const e=n.invocation?Me(n.path,n.invocation):De(n.path);t(n.store,e,n.path)}n&&function(e){const t=e.size;console.log(`[📡 ${t} ${ke("Proxy Subscription",t)} 📡]:`,JSON.stringify(Array.from(e).map(e=>{const t="name"in(n=e.store)&&"string"==typeof n.name?n.name:"store";var n;const r=e.path.join(".");if(!e.invocation)return r?`$(${t}).${r}`:`$(${t})`;const o=e.invocation.args?.length??0;return`$(${t}).${r}${o?`(${o}_${ke("arg",o)})`:"()"}`}),null,2))}(e)}(i,t,n)},reset(){e.clear()},trackPath(t,n,r,o){let i=e.get(t);i||(i={__proto__:null},e.set(t,i)),Ee(i,n,0,r,o)}}}function Ee(e,t,n,r,o){if(n===t.length)return r&&(e.isLeaf=!0),void(o&&(e.invocation=o));e.children||(e.children={__proto__:null});const i=t[n];let s=e.children?.[i];s||(s={__proto__:null},e.children[i]=s),Ee(s,t,n+1,r,o)}function xe(e,t,n,r,o,i=2){const s=e.children;if(!s)return void o.add({store:t,path:n,invocation:e.invocation,isLeaf:e.isLeaf??!1});const c=Object.keys(s),a=c.length;if(0!==a)if(e.isLeaf||r>=i&&a>1){o.add({store:t,path:n,invocation:e.invocation,isLeaf:e.isLeaf??!1});for(const e of c){const c=s[e];c.invocation&&xe(c,t,[...n,e],r+1,o,i)}}else if(r<i&&a>1&&!e.isLeaf)for(const e of c)xe(s[e],t,[...n,e],r+1,o,i);else{if(1===a){const e=c[0];return void xe(s[e],t,[...n,e],r+1,o,i)}o.add({store:t,path:n,invocation:e.invocation,isLeaf:e.isLeaf??!1})}else o.add({store:t,path:n,invocation:e.invocation,isLeaf:e.isLeaf??!1})}function De(e){return t=>ze(t,e)}function Me(e,t){const n=e.slice(0,-1);return e=>{const r=ze(e,n),o=r&&"object"==typeof r?Reflect.get(r,t.method):void 0;return"function"==typeof o?Reflect.apply(o,r,t.args??Ie):void 0}}function ze(e,t){let n=e;for(const e of t){if(!n||"object"!=typeof n)return n;n=Reflect.get(n,e)}return n}function Ke(e,t=Object.is){return n=function(e,t=Object.is){const{debounceOptions:n,debugMode:r,equalityFn:o,keepAlive:i,lockDependencies:c}="function"==typeof(l=t)?{debounceOptions:void 0,debugMode:!1,equalityFn:l,keepAlive:!1,lockDependencies:!1}:{debounceOptions:l.debounce,debugMode:(s&&l.debugMode)??!1,equalityFn:l.equalityFn??Object.is,keepAlive:l.keepAlive??!1,lockDependencies:l.lockDependencies??!1},a=String($e+=1),u=new Set;var l;i&&u.add(Le);const f=new Set;let d,y,p=Pe,g=!1,b=!0,m=!0,S=0,v=!1,w=null,q=Pe;function O(e,t,n){return m&&u.size?t?(f.add(e.subscribe(t,D,n?{equalityFn:n,isDerivedStore:!0}:Re)),t(ee(e)?e.getSnapshot():e.getState())):(d||(d=new WeakMap),y||(y=Te()),je(e,d,y.trackPath)):(t??h)(ee(e)?e.getSnapshot():e.getState())}function j(e){for(const t of f)t(e);f.clear()}let F=!0;function _(){if(!b&&Ve(p))return p;b=!1,m&&j(!0);const t=p,n=Ve(t);p=function(t){F=!0;const n=p,i=e(t),s=y?_e(i):i;return Ve(n)&&o(n,s)?(r&&console.log("[🥷 Derive Complete 🥷]: No change detected"),F=!1,n):s}(O);const i=r&&(!n||"verbose"===r&&m);if(i){n?"verbose"===r&&console.log("[🌀 Rebuilding Subscriptions 🌀]: Created…"):console.log("[🌀 Initial Derive Complete 🌀]: Created…");const e=f.size;console.log(`[🎯 ${e} ${ke("Selector Subscription",e)} 🎯]`)}return y&&m&&(y.buildProxySubscriptions((e,t)=>{f.add(e.subscribe(t,D,Re))},i),d=void 0,y.reset(),c&&(y=void 0)),F&&n&&function(e,t){const n=function(){const e=u.has(Le)?u.size-1:u.size;return S>0&&S<e}(),o=!S||n,i=n||null!==ve()||Se()&&o;n&&we(),r&&console.log(`[📻 Derive Complete 📻]: Notifying ${u.size} ${ke("watcher",u.size)}`);for(const t of u){if("function"==typeof t||!t.isDerivedWatcher)continue;const n=t.selector(e);if(!t.equalityFn(t.currentSlice,n)){const e=t.currentSlice;t.currentSlice=n,t.listener(n,e)}}i?v||(v=!0,Ve(q)||(q=t),qe(a,C)):A(e,t)}(p,t),c&&(m=!1),p}function A(e,t){for(const n of u)if("function"==typeof n)n(e,t);else if(!n.isDerivedWatcher){const t=n.selector(e);if(!n.equalityFn(n.currentSlice,t)){const e=n.currentSlice;n.currentSlice=t,n.listener(t,e)}}}function C(){if(!u.size)return;if(b&&!S&&_(),!Ve(p))return;const e=Ve(q)?q:p;A(p,e),v=!1,q=Pe}const k=n?K(T,"number"==typeof n?n:n.delay,"number"==typeof n?{leading:!1,maxWait:n,trailing:!0}:n):void 0,I=k??(()=>{g||(g=!0,queueMicrotask(T))});function T(){g=!1,u.size?b&&_():z()}function E(e){e||k&&b?queueMicrotask(()=>{u.size||z()}):z()}function x(){T(),w=null}function D(){if(!b){if(b=!0,!k){if(S){we();const e=ve(),t=null===e?0:e+1;if(null!==w&&t<=w)return;return w=t,void function(e,t){if(!de)return;const n=t<0?0:0|t,r=he.get(e);if(void 0===r){he.set(e,n);let t=ge.get(n);return t||(t=new Set,ge.set(n,t)),t.add(e),void(n<me&&(me=n))}if(n>r){const t=ge.get(r);if(t&&(t.delete(e),0===t.size&&(ge.delete(r),r===me))){me=1/0;for(const e of ge.keys())e<me&&(me=e)}he.set(e,n);let o=ge.get(n);o||(o=new Set,ge.set(n,o)),o.add(e),n<me&&(me=n)}}(x,t)}if(Se())return void(v||(v=!0,Ve(p)&&(q=p),qe(a,C)))}w=null,I()}}function M(){return b||!Ve(p)?u.size>0?_():e(O):p}function z(e=!0){i&&e||(k?.cancel(),j(),u.clear(),S=0,y=void 0,d=void 0,m=!0,g=!1,b=!0,p=Pe,v=!1,q=Pe,w=null)}return{destroy:()=>z(!1),flushUpdates:function(){u.size&&(k?k.flush():b&&_())},getSnapshot:function(){if(!Ve(p)){u.add(Le);const e=_();return u.delete(Le),e}return g&&T(),p},getState:M,subscribe:function(...e){if(1===e.length){const t=e[0];return u.add(t),1!==u.size||Ve(p)||M(),()=>{u.delete(t),u.size||E(!1)}}const[t,n,r]=e,o=r?.equalityFn??Object.is,i=r?.isDerivedStore??!1,s={currentSlice:void 0,equalityFn:o,isDerivedWatcher:i,listener:n,selector:t};return u.add(s),s.currentSlice=t(M()),i&&(S+=1),r?.fireImmediately&&n(s.currentSlice,s.currentSlice),()=>{u.delete(s),i&&(S-=1),u.size||E(i)}},getInitialState:()=>{throw new Error("[createDerivedStore]: getInitialState() is not available on derived stores.")},setState:()=>{throw new Error("[createDerivedStore]: setState() is not available on derived stores.")}}}(e,t),Object.assign(function(e=h,t){return C(n.subscribe,n.getSnapshot,void 0,e,t)},n);var n}var Pe=Symbol(),Re=Object.freeze({equalityFn:Object.is,isDerivedStore:!0}),$e=0;function Le(){}function Ve(e){return e!==Pe}var Ne,We=class{constructor({disableAutoRefetching:e,initialEnabled:t}){this.count=0,this.enabled=!1,this.lastSubscriptionTime=null,this.fetchThrottleMs=null,this.onSubscribe=null,this.onLastUnsubscribe=null,this.enabled=t,e&&(this.fetchThrottleMs=N.seconds(5))}init({onSubscribe:e,onLastUnsubscribe:t}){this.onSubscribe=e,this.onLastUnsubscribe=t}get(){return{enabled:this.enabled,lastSubscriptionTime:this.lastSubscriptionTime,subscriptionCount:this.count}}setEnabled(e){this.enabled=e}subscribe(){const e=0===this.count,t=null!==this.fetchThrottleMs&&null!==this.lastSubscriptionTime&&!e&&Date.now()-this.lastSubscriptionTime<=this.fetchThrottleMs;return this.onSubscribe?.(this.enabled,e,t),this.count+=1,this.lastSubscriptionTime=Date.now(),e=>{const t=1===this.count;this.count=Math.max(this.count-1,0),t&&(this.onLastUnsubscribe?.(e),this.lastSubscriptionTime=null)}}};function Ue(e,t){const n=t?.baseDelay??N.seconds(5),r=t?.maxDelay??N.minutes(5);return Math.min(n*Math.pow(2,e),r)}var He={Error:"error",Idle:"idle",Loading:"loading",Success:"success"};function Qe(e,t){const n=Object.prototype.hasOwnProperty;function r(e,t){for(const n of e.keys())if(Qe(n,t))return n}let o,i,s;if(e===t)return!0;if(e&&t&&(o=e.constructor)===t.constructor){if(o===Date)return e.getTime()===t.getTime();if(o===RegExp)return e.toString()===t.toString();if(o===Array){if((i=e.length)===t.length)for(;i--&&Qe(e[i],t[i]););return-1===i}if(o===Set){if(e.size!==t.size)return!1;for(let n of e){if(s=n,s&&"object"==typeof s&&(s=r(t,s),!s))return!1;if(!t.has(s))return!1}return!0}if(o===Map){if(e.size!==t.size)return!1;for(let n of e){if(s=n[0],s&&"object"==typeof s&&(s=r(t,s),!s))return!1;if(!Qe(n[1],t.get(s)))return!1}return!0}if(o===ArrayBuffer)e=new Uint8Array(e),t=new Uint8Array(t);else if(o===DataView){if((i=e.byteLength)===t.byteLength)for(;i--&&e.getInt8(i)===t.getInt8(i););return-1===i}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){const n=e,r=t;if((i=n.byteLength)===r.byteLength)for(;i--&&n[i]===r[i];);return-1===i}if(!o||"object"==typeof e){i=0;for(const r in e){if(n.call(e,r)&&++i&&!n.call(t,r))return!1;if(!(r in t)||!Qe(e[r],t[r]))return!1}return Object.keys(t).length===i}}return e!=e&&t!=t}var Be=new WeakMap,Je=new WeakMap;function Ge(e,t=Xe,n=Qe){return function(e,t,n){let r=Je.get(e);r||(r=new Map,Je.set(e,r));let o=r.get(t);o||(o=new Map,r.set(t,o));const i=o.get(n);if(i)return i;const[s,c,a]=Ze(e,t,n),u=new Map,l=e=>new Proxy({__proto__:null},{get(t,n){if("value"===n){let t=c();const n=e.split(".");for(const e of n)e&&(t=t[e]);return t}const r="string"==typeof n?n:n.toString(),o=e?`${e}.${r}`:r,i=u.get(o);if(i)return i;const a=l(o);return Be.set(a,s),u.set(o,a),a},set(t,n,r){const o=e.split(".");return""===o[0]&&o.shift(),a(o,r),!0}}),f=l("");return s(()=>{}),Be.set(f,s),o.set(n,f),f}(e,t,n)}var Xe=e=>e,Ye=(e,t,n)=>{if(!t.length)return n;const[r,...o]=t,i=e[r],s=Ye(i,o,n);if(Qe(i,s))return e;const c=Array.isArray(e)?e.slice():{...e};return c[r]=s,c},Ze=(e,t,n)=>{const r=new Set,o=ee(e);let i,s=t(o?e.getSnapshot():e.getState());return[c=>(r.size||(i=e.subscribe(t,e=>{s=e,r.forEach(e=>e())},{equalityFn:n,isDerivedStore:o})),r.add(c),()=>{r.delete(c),!r.size&&i&&(i(),i=void 0)}),()=>(r.size||(s=t(e.getState())),s),(n,r)=>{if(t!==Xe)throw new Error("Cannot set a value with a selector");e.setState(e=>Ye(e,n,r),!0)}]};function et(e){return Be.get(e)}var tt={error:!0,lastFetchedAt:!0,queryCache:!0,queryKey:!0,status:!0,enabled:!1,fetch:!1,getCacheEntry:!1,getData:!1,getStatus:!1,isDataExpired:!1,isStale:!1,reset:!1},nt=Object.freeze({force:!0}),rt=Object.freeze({once:!0}),ot=Object.freeze({updateQueryKey:!0});function it(e){return JSON.stringify(st(e))}function st(e){return"object"!=typeof e||null===e?e:Object.keys(e).sort().reduce((t,n)=>{const r=e[n];return t[n]=p(r)?st(r):r,t},{__proto__:null})}function ct(e,t,n,r){return r?ut(r,n)?r:{...at(e,t),...r}:at(e,t)}function at(e,t){const n=Object.assign({__proto__:null},t?.params);for(const t in e?.params){const r=e.params[t];r&&(n[t]=r.value)}return n}function ut(e,t){if(!e)return!1;for(const n of t)if(!(n in e))return!1;return!0}function lt(e){return"function"==typeof e}function ft(e){return!lt(e)}function dt(e,t){return n=>{const r={...n},o={__proto__:null};for(const e in r)y(r,e)&&e in tt&&(tt[e]&&(o[e]=r[e]),delete r[e]);return{...t?t(r):V(r),...yt(e,null,o)}}}function yt(e,t,n){if(!n.queryCache)return n;const r=Date.now(),o=t??(e&&n.queryKey||null),i={__proto__:null};let s=!1;for(const e in n.queryCache){if(!y(n.queryCache,e))continue;const c=n.queryCache[e];c&&(r-(c.lastFetchedAt??c.errorInfo.lastFailedAt)<c.cacheTime||e===o)?!t&&c.errorInfo&&c.errorInfo.retryCount>0?(i[e]={...c,errorInfo:{...c.errorInfo,retryCount:0}},s=!0):i[e]=c:s=!0}return s?{...n,queryCache:i}:n}function pt(){return Object.create(null)}function ht(e,t,n){return new l(`[createQueryStore: ${e}]: ${t} failed`,n)}function gt(e){return function(t,n){return n?e().setState(t,n):e().setState(t)}}var bt=Symbol(),mt=Object.freeze({debugMode:!1,enabled:!0,equalityFn:Object.is,fireImmediately:!1}),St=Object.freeze({fireImmediately:!1,forceResubscribe:!1});function vt(e,t,n=St){if(t.current.isActive){if(!n?.forceResubscribe)return;t.current.unsubscribe()}t.current.options.debugMode&&console.log("[📡 useListen 📡] Attaching listener"),t.current.isActive=!0,t.current.resubscribe=(n=St)=>vt(e,t,n);const r=e.subscribe(e=>t.current.selector(e),(e,n)=>t.current.react(e,n,()=>{r(),t.current.isActive=!1}),n.fireImmediately?{...t.current.options,fireImmediately:!0}:t.current.options);t.current.unsubscribe=()=>{t.current.isActive&&(r(),t.current.isActive=!1)}}function wt(e){return"function"==typeof e?{equalityFn:e}:e??mt}var qt=Symbol();function Ot(e,t){return function(...n){const r=e.getState()[t];if("function"==typeof r)return r(...n);throw new Error(`[createVirtualStoreAction]: Method ${String(t)} is not a function`)}}function jt(e,t){return"function"==typeof e[t]}exports.QueryStatuses=He,exports.StoresError=l,exports.applyStateUpdate=Y,exports.configureStores=function(e){var t;s&&function(){if(q)throw new Error("[stores]: configureStores() called after first store creation. Call it earlier before creating any stores.")}(),e.logger&&(t=e.logger,u=t),m??(m=function(e){return e?.queryStoreDefaults?{queryStoreDefaults:e.queryStoreDefaults}:void 0}(e)),S??(S=F(e))},exports.createBaseStore=fe,exports.createDerivedStore=Ke,exports.createQueryStore=function(e,t,n){j();const r="function"==typeof t?t:pt,o="object"==typeof t?t:n,i=o&&"storageKey"in o?o:void 0,a=Ne??(Ne=function(){const e={abortInterruptedFetches:!0,cacheTime:N.days(7),debugMode:!1,disableAutoRefetching:!1,keepPreviousData:!1,maxRetries:5,minStaleTime:!1,paramChangeThrottle:!1,retryDelay:Ue,staleTime:N.minutes(2),suppressStaleTimeWarning:!1},t=function(){if(m)return m}()?.queryStoreDefaults;return t?{...e,...t}:e}()),d=a.minStaleTime,{fetcher:p,onError:h,onFetched:g,setData:b,transform:S,abortInterruptedFetches:v=a.abortInterruptedFetches,cacheTime:w=a.cacheTime,debugMode:q=a.debugMode,disableAutoRefetching:O=a.disableAutoRefetching,disableCache:F=!1,enabled:_=!0,keepPreviousData:A=a.keepPreviousData,maxRetries:C=a.maxRetries,paramChangeThrottle:k=a.paramChangeThrottle,params:I,retryDelay:T=a.retryDelay,staleTime:E=a.staleTime,suppressStaleTimeWarning:x=a.suppressStaleTimeWarning}=e;let D="function"==typeof E?a.staleTime:E;s&&!1!==d&&!O&&!x&&D<d&&console.warn(`[createQueryStore${i?.storageKey?`: ${i.storageKey}`:""}] ❌ Stale times under ${d/1e3} seconds are not recommended. Provided staleTime: ${D/1e3} seconds`);const M=new Error("[createQueryStore: AbortError] Fetch interrupted"),z="function"==typeof w,P=s&&q,R=e.params?Object.keys(e.params):[];let $=null,L=null,V=null,W=[],U=!1,H=!1,Q=null,B=null,J=null,G=null,Y=null;const Z={enabled:"function"!=typeof _&&_,error:null,lastFetchedAt:null,queryCache:{},queryKey:"",status:He.Idle},ee=new We({disableAutoRefetching:O,initialEnabled:Z.enabled});function te(){Q&&(B=null,Q.abort(),Q=null)}function ne(t,n,o){const s=o.setState;function c(e){const t="function"==typeof e;if(t||void 0!==e.enabled){let n;const r=s(r=>{const o=t?e(r):e,i=void 0!==o.enabled?o.enabled:r.enabled;return i!==r.enabled&&(n=()=>function(e,t){e!==t&&Y!==t&&(Y=t,ee.setEnabled(t),t?queueMicrotask(()=>d.fetch(void 0,ot)):(J||v)&&(v&&te(),J&&(clearTimeout(J),J=null)))}(r.enabled,i)),o});return n?.(),r}return s(e)}function a(e,t){if(O||t?.skipStoreUpdates)return;if(D<=0||D===1/0)return;J&&(clearTimeout(J),J=null);const r=it(e),o=n(),i=(F?G===r&&o.lastFetchedAt:o.queryCache[r]?.lastFetchedAt)||null,s=i?D-(Date.now()-i):D;J=setTimeout(()=>{const t=ee.get();t.enabled&&t.subscriptionCount>0&&d.fetch(e,nt,!0)},s)}o.setState=c,ee.init({onSubscribe:(r,o,i)=>{if(L||$||!I&&"function"!=typeof e.enabled&&"function"!=typeof e.staleTime){if(r)if(o){const e=at($,L),r=it(e),o=n();o.queryKey!==r&&t({queryKey:r}),o.isStale()?d.fetch(e,void 0,!0):a(e,void 0)}else O&&!i&&d.fetch(void 0,void 0,!0)}else U=!0},onLastUnsubscribe:e=>{J&&(clearTimeout(J),J=null),v&&!e&&te()}});const d={...r(c,n,o),...Z,async fetch(e,r,o=!1){const s=ee.get();if(!r?.force&&!r?.skipStoreUpdates&&!s.enabled)return null;const y=n(),m=y.error,q=y.queryKey,O=y.status===He.Loading,j=ct($,L,R,e),_=it(j);if(O&&B?.promise&&B.key===_)return P&&console.log("[🔄 Using Active Fetch 🔄] for params:",JSON.stringify(j)),B.promise;const k=r?.staleTime??D,I=!!r?.skipStoreUpdates,E="boolean"==typeof r?.updateQueryKey?r.updateQueryKey:!!o&&A,x=(o||q===_||E)&&!I;if(v&&x&&te(),!r?.force){const e=y.lastFetchedAt,n=y.queryCache[_],o=n?.lastFetchedAt,i=n?.errorInfo,c=i&&i.retryCount>=C,u=(F?G===_&&e:o)||null;if(u&&!(Date.now()-u>=k)&&(!i||c||I))return x&&!J&&s.subscriptionCount>0&&0!==D&&D!==1/0&&a(j,r),E&&t(e=>e.queryKey!==_?{queryKey:_}:e),P&&console.log("[💾 Returning Cached Data 💾] for params:",JSON.stringify(j)),n?.data??null}x&&(J&&(clearTimeout(J),J=null),!m&&O||t({error:null,status:He.Loading}),B={key:_});const K=r?.cacheTime??(z?w(j):w);async function V(){const s=i?.storageKey||_;try{P&&(o||!e||ut(e,R)?console.log("[🔄 Fetching 🔄] for params:",JSON.stringify(j)):console.log("[🔄 Fetching with Partial Params 🔄]\n","- Provided params:",`${JSON.stringify(e)}\n`,"- Filled in params:",`${JSON.stringify(Object.fromEntries(Object.keys(j).filter(t=>!(t in e)).map(e=>[e,j[e]])))}`));const n=await(v&&x?async function(e){const t=new AbortController;Q=t;try{return await new Promise((n,r)=>{t.signal.addEventListener("abort",()=>r(M),rt),Promise.resolve(p(e,t)).then(n,r)})}finally{Q===t&&(Q=null)}}(j):p(j,null)),i=Date.now();let l;P&&console.log("[✅ Fetch Successful ✅] for params:",JSON.stringify(j));try{l=function(e,t,n){return n?n(e,t):e}(n,j,S)}catch(e){throw ht(s,"transform",e)}if(I)return P&&console.log("[🥷 Successful Parallel Fetch 🥷] for params:",JSON.stringify(j)),"withCache"===r.skipStoreUpdates&&t(e=>{if(!b)return F?e:{queryCache:{...e.queryCache,[_]:{cacheTime:K,data:l,errorInfo:null,lastFetchedAt:i}}};let t=e;const n=t.queryCache[_];try{b({data:l,params:j,queryKey:_,set:e=>{t="function"==typeof e?{...t,...e(t)}:{...t,...e}}})}catch(e){throw ht(s,"setData",e)}return!F&&Object.is(n,t.queryCache[_])&&(t={...t,queryCache:{...t.queryCache,[_]:{cacheTime:K,data:null,errorInfo:null,lastFetchedAt:i}}}),t}),l;if((b?c:t)(e=>{let t={...e,error:null,lastFetchedAt:i,queryKey:E?_:e.queryKey,status:He.Success};if(b||F){if(b){P&&console.log("[💾 Setting Data 💾] for params:",JSON.stringify(j));const e=t.queryCache[_];try{b({data:l,params:j,queryKey:_,set:e=>{t="function"==typeof e?{...t,...e(t)}:{...t,...e}}})}catch(e){throw ht(s,"setData",e)}!F&&Object.is(e,t.queryCache[_])&&(t.queryCache={...t.queryCache,[_]:{cacheTime:K,data:null,errorInfo:null,lastFetchedAt:i}})}}else P&&console.log("[💾 Setting Cache 💾] for params:",JSON.stringify(j),"| Has previous data?:",!!t.queryCache[_]?.data),t.queryCache={...t.queryCache,[_]:{cacheTime:K,data:l,errorInfo:null,lastFetchedAt:i}};return F||w===1/0?t:yt(A,_,t)}),x&&(G=_,a(j,r)),g)try{g({data:l,fetch:d.fetch,params:j,set:c})}catch(e){u.error(ht(s,"onFetched callback",e))}return l??null}catch(i){if(i===M)return P&&console.log("[❌ Fetch Aborted ❌] for params:",JSON.stringify(j)),null;const c=!o&&!0===r?.throwOnError,a=f(i);if(a instanceof l&&u.error(a),!x){if(c)throw a;return null}const y=F?void 0:n().queryCache[_],p=y?.errorInfo?.retryCount??0,g=p+1;try{h?.(a,p)}catch(e){u.error(ht(s,"onError callback",e))}if(p<C){if(ee.get().subscriptionCount>0){const t="function"==typeof T?T(g,a):T;t!==1/0&&(J&&clearTimeout(J),J=setTimeout(()=>{const t=ee.get();t.enabled&&t.subscriptionCount>0&&d.fetch(e,nt,!0)},t))}t(e=>({error:a,queryCache:{...e.queryCache,[_]:{cacheTime:y?.cacheTime??K,data:y?.data??null,lastFetchedAt:y?.lastFetchedAt??null,errorInfo:{error:a,lastFailedAt:Date.now(),retryCount:g}}},queryKey:E?_:e.queryKey,status:He.Error}))}else t(e=>({error:a,queryCache:{...e.queryCache,[_]:{cacheTime:y?.cacheTime??K,data:y?.data??null,lastFetchedAt:y?.lastFetchedAt??null,errorInfo:{error:a,lastFailedAt:Date.now(),retryCount:C}}},queryKey:E?_:e.queryKey,status:He.Error}));if(c)throw a;return null}finally{x&&(B=null)}}return x?(B={key:_,promise:V()}).promise:V()},getCacheEntry(e){if(F)return null;const t=n(),r=e?"string"==typeof e?e:it(ct($,L,R,e)):t.queryKey;return t.queryCache[r]??null},getData(e){if(F)return null;const t=n().getCacheEntry(e);return t&&null!==t.data?A?t.data:t.lastFetchedAt&&Date.now()-t.lastFetchedAt>=t.cacheTime?null:t.data:null},getStatus:function(e){const t=n(),r=t.status;switch(e){case"isIdle":return r===He.Idle;case"isLoading":return r===He.Loading;case"isError":case"isInitialLoad":case"isSuccess":case void 0:{const n=t.queryKey,o=t.queryCache[n],i=F?r===He.Error:"number"==typeof o?.errorInfo?.lastFailedAt;if("isError"===e)return i;const s=null!==((F?G===n&&t.lastFetchedAt:o?.lastFetchedAt)||null),c=!s&&!i&&t.enabled;if("isInitialLoad"===e)return c;const a=s&&!i;return"isSuccess"===e?a:{isError:i,isIdle:r===He.Idle,isLoading:r===He.Loading,isInitialLoad:c,isSuccess:a}}}},isDataExpired(e){const t=n(),r=t.queryCache[t.queryKey],o=t.queryKey,i=t.lastFetchedAt,s=(F?G===o&&i:r?.lastFetchedAt)||null;if(!s)return!0;const c=e??r?.cacheTime;return void 0===c||Date.now()-s>=c},isStale(e){const t=n(),r=t.queryKey,o=(F?G===r&&t.lastFetchedAt:t.queryCache[r]?.lastFetchedAt)||null;if(!o)return!0;const i=e??D;return Date.now()-o>=i},reset(e=!1){for(const e of W)e();W=[],$=null,L=null,V=null,te(),J&&(clearTimeout(J),J=null),B=null,G=null,e&&t(Z)}},y=o.subscribe;return o.subscribe=(...e)=>{const t=H?()=>{}:ee.subscribe(),n=1===e.length?y(e[0]):y(e[0],e[1],e[2]);return e=>{t(e),n()}},d}const re=i?.storageKey?fe(ne,(oe=i,void 0===(ie={partialize:dt(A,i.partialize)})?Object.assign({__proto__:null},oe):Object.assign({__proto__:null},oe,ie))):o&&!("storageKey"in o)?fe(ne,o):fe(ne);var oe,ie;const se=re.getState(),ce=se.error,ae=se.enabled,ue=se.queryKey,le=se.fetch;let de;if(ue&&!ce&&(G=ue),H=!0,I||"function"==typeof e.enabled){const{directValues:e,enabledAttachVal:t,enabledDirectValue:n,attachVals:r}=function(e,t,n){const r={__proto__:null},o={__proto__:null},i={__proto__:null};for(const e in t){if(!y(t,e))continue;const s=t[e];if(lt(s)){const t=s(Ge,n);r[e]=t,i[e]=t.value}else ft(s)&&(o[e]=s,i[e]=s)}let s,c=null,a=null;if(lt(e)){const t=e(Ge,n);s=t.value,c=t}else s=e,a=e;return{attachVals:r,directValues:o,enabledAttachVal:c,enabledDirectValue:a,resolvedEnabled:s,resolvedParams:i}}(_,I,re);$={enabled:t,params:r},L={enabled:n,params:e}}"function"==typeof e.staleTime&&(V=e.staleTime(Ge,re),D=V.value);const ye=Object.freeze({updateQueryKey:A}),pe=function(){let e,t=!1;return function(...n){e=n,t||(t=!0,queueMicrotask(()=>{t=!1,(e=>{le(e??at($,L),ye)})(...e)}))}}();function he(){let e;if(!A){e=at($,L);const t=it(e);re.setState({queryKey:t})}pe(e)}const ge=c||!k?he:K(he,"number"==typeof k?k:k.delay,"number"==typeof k?{leading:!1,maxWait:k,trailing:!0}:k);for(const e in $?.params){const t=$.params[e];if(!t)continue;const n=et(t);if(P&&console.log("[🌀 Param Subscription 🌀] Subscribed to param:",e),n){let r=t.value;const o=n(()=>{const n=t.value;Qe(r,n)||(P&&console.log("[🌀 Param Change 🌀] -",e,"- [Old]:",`${r?.toString()},`,"[New]:",n?.toString()),r=n,ge())});W.push(o)}}if(V){const e=et(V);if(e){const t=V;let n=t.value;P&&console.log("[🌀 StaleTime Subscription 🌀] Initial value:",n);const r=e(()=>{const e=t.value;e!==n&&(P&&console.log("[🌀 StaleTime Change 🌀] - [Old]:",`${n},`,"[New]:",e),n=e,D=e,le())});W.push(r)}}if($?.enabled){const e=$.enabled,t=et(e);if(t){let n=e.value;ae!==n&&((de??(de={})).enabled=n),n&&ee.setEnabled(n),P&&console.log("[🌀 Enabled Subscription 🌀] Initial value:",n);const r=t(()=>{const t=e.value;t!==n&&(P&&console.log("[🌀 Enabled Change 🌀] - [Old]:",`${n},`,"[New]:",t),n=t,re.setState({enabled:t}))});W.push(r)}}else ae!==Z.enabled&&((de??(de={})).enabled=Z.enabled);const be=it(at($,L));return be!==ue&&((de??(de={})).queryKey=be),de&&re.setState(de),H=!1,U&&queueMicrotask(ge),me=re,Se=X.QueryStore,Object.assign(me,{[Se]:!0});var me,Se},exports.createStoreActions=function(e,t){const n=function(e){const t=e.getState(),n={__proto__:null},r=n;if(s&&("object"!=typeof t||null===t))throw new Error("[createStoreActions]: State is not an object");if(re(e))for(const n in t)jt(t,n)&&(r[n]=Ot(e,n));else for(const e in t)jt(t,e)&&(r[e]=t[e]);return n}(e);return t?Object.assign(n,t):n},exports.createVirtualStore=function(e,t,n){const r="function"==typeof t,o=r?t:void 0,i=r?n:t,s=new Set,c=Ke(e,{debugMode:i?.debugMode??!1,equalityFn:function(e,t){const n=Object.is(e,t);return n||(function(e,t){for(const n of s){n.unsubscribe();const r=n.args;if(1===r.length){const o=r[0],i=e.getState(),s=t.getState(),c=t.subscribe(o);n.unsubscribe=c,Object.is(s,i)||o(s,i);continue}const o=r[0],i=r[1];let s=r[2];s?.fireImmediately&&(s={...s,fireImmediately:!1});const c=o(e.getState()),a=o(t.getState()),u=t.subscribe(o,i,s);n.unsubscribe=u,(s?.equalityFn??Object.is)(c,a)||i(a,c)}}(e,t),Z(e)),n},keepAlive:!0,lockDependencies:i?.lockDependencies??!0});return Object.assign(function(e,t){const n=c();return e?n(e,t):n()},{[X.VirtualStore]:!0,destroy:c.destroy,getInitialState:()=>c.getState().getInitialState(),getState:()=>c.getState().getState(),persist:(a=c.getState,{clearStorage:()=>a().persist?.clearStorage(),getOptions:()=>a().persist?.getOptions()??{},hasHydrated:()=>a().persist?.hasHydrated()??!0,hydrationPromise:()=>a().persist?.hydrationPromise?.()??Promise.resolve(),onFinishHydration:e=>a().persist?.onFinishHydration(e)??g,onHydrate:e=>a().persist?.onHydrate(e)??g,rehydrate:()=>a().persist?.rehydrate(),setOptions:e=>a().persist?.setOptions(e)}),setState:gt(c.getState),subscribe:function(...e){const t={args:e,unsubscribe:1===e.length?c.getState().subscribe(e[0]):c.getState().subscribe(e[0],e[1],e[2])};return s.add(t),()=>{t.unsubscribe(),s.delete(t)}}},o?.(c.getState));var a},exports.deepEqual=function e(t,n){if("object"!=typeof t||null==t||"object"!=typeof n||null==n)return t===n;if(Object.is(t,n))return!0;const r=Object.keys(t);if(r.length!==Object.keys(n).length)return!1;for(const o of r)if(!(o in n)||!e(t[o],n[o]))return!1;return!0},exports.defaultRetryDelay=Ue,exports.destroyStore=Z,exports.destroyStores=function(e,t){for(const n of Array.isArray(e)?e:Object.values(e))n&&!t?.skipDestroy?.(n)&&Z(n,t)},exports.getQueryKey=it,exports.getStoreName=function(e){return ne(e)?e.persist.getOptions().name??e.name:e.name},exports.hasGetSnapshot=ee,exports.identity=h,exports.isDerivedStore=function(e){return"flushUpdates"in e},exports.isPersistedStore=ne,exports.isQueryStore=te,exports.isVirtualStore=re,exports.nullObject=function(){return{__proto__:null}},exports.parseQueryKey=function(e){return JSON.parse(e)},exports.replacer=$,exports.reviver=L,exports.shallowEqual=function(e,t){if("object"!=typeof e||null==e||"object"!=typeof t||null==t)return e===t;if(Object.is(e,t))return!0;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.is(e[r],t[r]))return!1;return!0},exports.time=N,exports.useListen=function(e,t,n,o=mt){const i=function(){const e=r.useRef(bt);return e.current===bt&&(e.current=function(e,t,n){return{selector:e,react:t,isActive:!1,options:wt(n),resubscribe:()=>{},unsubscribe:()=>{}}}(t,n,o)),e}(),s=function(e){return"function"==typeof e?mt.enabled:e?.enabled??mt.enabled}(o);return i.current.react=n,i.current.selector=t,function(e,t){"function"==typeof t?e.current.options.equalityFn=t:t&&(e.current.options=t??mt)}(i,o),r.useLayoutEffect(()=>{if(s)return vt(e,i),()=>function(e){e.current.options.debugMode&&console.log("[🗑️ useListen 🗑️] Detaching listener"),e.current.resubscribe=()=>{},e.current.unsubscribe(),e.current.unsubscribe=()=>{},e.current.isActive=!1}(i)},[s,e]),i},exports.useStableValue=function(e){const t=r.useRef(qt);return t.current===qt&&(t.current=e()),t.current};
|
|
1
|
+
"use strict";var e=require("react"),t=require("react-native"),n=(e=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(e,{get:(e,t)=>("undefined"!=typeof require?require:e)[t]}):e)(function(e){if("undefined"!=typeof require)return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),r="ios"===t.Platform.OS;t.Platform.OS;var o="development"===process.env.NODE_ENV,i="test"===process.env.NODE_ENV;function s(e){return e}function c(){}Object.freeze(Object.create(null));var a=Symbol("empty selection"),u=Object.is;function l(e,t){return n=>(function(e){e.committedEqualityFn=e.equalityFn,e.committedSelector=e.selector,e.committedSource=e.source,e.committedValue=e.value===a?f(e):e.value}(e),t(r=>{e.latestSnapshot=r,e.latestSource=t;const o=e.committedValue;if(o===a||e.committedSource!==t)return void n();const i=e.committedSelector,s=e.committedEqualityFn;if(e.selector===i&&e.equalityFn===s){const t=i(r);if(s===u?u(o,t):s(o,t))return;return e.committedValue=t,e.value=t,e.valueEqualityFn=s,e.valueSelector=i,e.valueSnapshot=r,void n()}if(e.source!==t)return void n();const c=e.value;if(c===a)return;const l=e.selector(r),f=e.equalityFn(c,l);e.committedEqualityFn=e.equalityFn,e.committedSelector=e.selector,e.committedValue=y(e,r,f?c:l),f||n()}))}function f(e){const t=function(e){if(e.latestSource===e.source&&e.latestSnapshot!==a)return e.latestSnapshot;const t=e.getStoreSnapshot();return e.latestSnapshot=t,e.latestSource=e.source,t}(e);return d(e,t)}function d(e,t){const n=e.value;if(n!==a&&u(e.valueSnapshot,t)&&e.valueSelector===e.selector&&e.valueEqualityFn===e.equalityFn)return n;const r=e.selector(t);if(n!==a&&(e.equalityFn===u?u(n,r):e.equalityFn(n,r)))return y(e,t,n);const o=e.committedValue;return o!==a&&o!==n&&e.committedSource===e.source&&(e.equalityFn===u?u(o,r):e.equalityFn(o,r))?y(e,t,o):y(e,t,r)}function y(e,t,n){return e.value=n,e.valueEqualityFn=e.equalityFn,e.valueSelector=e.selector,e.valueSnapshot=t,n}function p(t,n,r,o){return Object.assign(function(i,s){return function(t,n,r,o,i=u){const s=e.useRef(null);let y=t,p=n,g=r;if(o){let e=s.current;null===e&&(e=function(e,t,n,r,o){const i={committedEqualityFn:o,committedSelector:r,committedSource:e,committedValue:a,equalityFn:o,getSelectedServerSnapshot:()=>function(e){return d(e,(e.getServerStoreSnapshot??e.getStoreSnapshot)())}(i),getSelectedSnapshot:()=>f(i),getServerStoreSnapshot:n,getStoreSnapshot:t,latestSnapshot:a,latestSource:a,selector:r,selectedSource:e,selectedSubscribe:()=>c,source:e,value:a,valueEqualityFn:o,valueSelector:r,valueSnapshot:a};return i.selectedSubscribe=l(i,e),i}(t,n,r,o,i),s.current=e),function(e,t,n,r,o,i){e.source===t&&e.getStoreSnapshot===n||(e.latestSnapshot=a),e.source=t,e.getStoreSnapshot=n,e.getServerStoreSnapshot=r,e.selector=o,e.equalityFn=i,e.selectedSource!==t&&(e.selectedSource=t,e.selectedSubscribe=l(e,t))}(e,t,n,r,o,i),y=e.selectedSubscribe,p=e.getSelectedSnapshot,g=void 0===r?void 0:e.getSelectedServerSnapshot}const h=e.useSyncExternalStore(y,p,g);return e.useDebugValue(h),h}(t.subscribe,n,r,i,s??o)},t)}function g(e){let t;function r(){if(t)return t;try{const r=function(e){const{createMMKV:t,MMKV:r}=n("react-native-mmkv");if("function"==typeof t)return t({id:e});if("function"==typeof r)return new r({id:e});throw new Error("[stores]: react-native-mmkv module does not export MMKV/createMMKV.")}(e);let o;if("function"==typeof r.delete?o=r.delete.bind(r):"function"==typeof r.remove&&(o=r.remove.bind(r)),"function"!=typeof o)throw new Error("[stores]: Storage instance does not conform to expected interface");const i={clearAll:r.clearAll.bind(r),contains:r.contains.bind(r),delete:o,get:r.getString.bind(r),getAllKeys:r.getAllKeys.bind(r),set:r.set.bind(r)};t=i}catch(e){throw new Error("[stores] react-native-mmkv could not be loaded.\n\nPersisted stores require a storage backend. Either:\n - Install MMKV (the default): yarn add react-native-mmkv\n - Or provide a custom adapter via configureStores()\n"+(e instanceof Error?`\n${e.message}`:""))}return function(e){if(!e||"function"!=typeof e.get||"function"!=typeof e.set||"function"!=typeof e.delete||"function"!=typeof e.clearAll)throw new Error("[stores]: Storage instance does not conform to expected interface")}(t),t}return{clearAll:()=>r().clearAll(),contains:e=>r().contains(e),delete:e=>r().delete(e),get:e=>r().get(e),getAllKeys:()=>r().getAllKeys(),set:(e,t)=>r().set(e,t)}}var h={debug:(e,t)=>{o&&console.debug(e,t)},error:(e,t)=>{o&&!i&&console.error(e,t)},info:(e,t)=>{o&&console.info(e,t)},warn:(e,t)=>{o&&console.warn(e,t)}},b=Object.prototype.hasOwnProperty;function m(e,t){return b.call(e,t)}function S(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function v(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}var w=class extends Error{constructor(e,t){super(e),this.name="StoresError",void 0!==t&&Object.defineProperty(this,"cause",{configurable:!0,value:t,writable:!0})}};function O(e){return e instanceof Error?e:new Error(String(e))}var q,j,F,_=class{destroy(){}publish(){}},A=class{constructor(){this.sessionId="noop"}register(e){return new _}},I=!1;function C(){return F??(F=E(void 0))}function k(){I=!0}function E(e){return{storage:e?.storage??g(e?.storageKeyPrefix??"stores:"),syncEngine:e?.syncEngine??(q||(q=new A),q)}}var T,x={Error:"error",Idle:"idle",Loading:"loading",Success:"success"},D={ms:e=>e,seconds:e=>1e3*e,minutes:e=>6e4*e,hours:e=>36e5*e,days:e=>864e5*e,weeks:e=>6048e5*e,infinity:1/0,zero:0};function M(e,t){const n=t?.baseDelay??D.seconds(5),r=t?.maxDelay??D.minutes(5);return Math.min(n*Math.pow(2,e),r)}function z(e){return JSON.stringify(P(e))}function P(e){return"object"!=typeof e||null===e?e:Object.keys(e).sort().reduce((t,n)=>{const r=e[n];return t[n]=S(r)?P(r):r,t},{__proto__:null})}function K(e,t){return!0===t[1]?e(t[0],!0):e(t[0])}function R(e,t,n){if(!0===n)return $(t)?t(e):t;const r=$(t)?t(e):t;return Object.is(r,e)?e:v(e)&&v(r)?{...e,...r}:r}function $(e){return"function"==typeof e}function L(e,t){return t instanceof Map?{__type:"Map",entries:Array.from(t.entries())}:t instanceof Set?{__type:"Set",values:Array.from(t)}:t}function V(e,t){return function(e){return"object"==typeof e&&null!==e&&"__type"in e&&"Map"===e.__type}(t)?new Map(t.entries):function(e){return"object"==typeof e&&null!==e&&"__type"in e&&"Set"===e.__type}(t)?new Set(t.values):t}var N=Object.freeze({QueryStore:Symbol("queryStore"),VirtualStore:Symbol("virtualStore")});function H(e,t){U(e)?e.getState().reset(t?.clearQueryCache):function(e){return"destroy"in e}(e)&&e.destroy()}function W(e){return"getSnapshot"in e}function U(e){return N.QueryStore in e}function Q(e){return!(!("persist"in e)||!e.persist)&&"string"==typeof e.persist.getOptions().name}function J(e){return N.VirtualStore in e}function B(e,t){return function(...n){const r=e.getState()[t];if("function"==typeof r)return r(...n);throw new Error(`[createVirtualStoreAction]: Method ${String(t)} is not a function`)}}function G(e,t){return"function"==typeof e[t]}function X(e,t){const n=Object.prototype.hasOwnProperty;function r(e,t){for(const n of e.keys())if(X(n,t))return n}let o,i,s;if(e===t)return!0;if(e&&t&&(o=e.constructor)===t.constructor){if(o===Date)return e.getTime()===t.getTime();if(o===RegExp)return e.toString()===t.toString();if(o===Array){if((i=e.length)===t.length)for(;i--&&X(e[i],t[i]););return-1===i}if(o===Set){if(e.size!==t.size)return!1;for(let n of e){if(s=n,s&&"object"==typeof s&&(s=r(t,s),!s))return!1;if(!t.has(s))return!1}return!0}if(o===Map){if(e.size!==t.size)return!1;for(let n of e){if(s=n[0],s&&"object"==typeof s&&(s=r(t,s),!s))return!1;if(!X(n[1],t.get(s)))return!1}return!0}if(o===ArrayBuffer)e=new Uint8Array(e),t=new Uint8Array(t);else if(o===DataView){if((i=e.byteLength)===t.byteLength)for(;i--&&e.getInt8(i)===t.getInt8(i););return-1===i}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){const n=e,r=t;if((i=n.byteLength)===r.byteLength)for(;i--&&n[i]===r[i];);return-1===i}if(!o||"object"==typeof e){i=0;for(const r in e){if(n.call(e,r)&&++i&&!n.call(t,r))return!1;if(!(r in t)||!X(e[r],t[r]))return!1}return Object.keys(t).length===i}}return e!=e&&t!=t}function Y(e){let t;const n=new Set;function r(...e){const r=R(t,...e);if(Object.is(r,t))return;const o=t;t=r,n.forEach(e=>e(t,o))}function o(){return t}const i={getInitialState:function(){return s},getState:o,setState:r,subscribe:function(...e){return 1===e.length?c(e[0]):function(e,n,r){const o=r?.equalityFn??Object.is;let i=e(t);return r?.fireImmediately&&n(i,i),c(function(t){const r=e(t);if(o(i,r))return;const s=i;i=r,n(r,s)})}(e[0],e[1],e[2])}},s=t=e(r,o,i);return i;function c(e){return n.add(e),()=>{n.delete(e)}}}function Z(e){return!!e&&"object"==typeof e&&"then"in e&&"function"==typeof e.then}function ee(e){return{...e,merge:e.merge??te,skipHydration:e.skipHydration??!1}}function te(e,t){return void 0===e?t:{...t,...e}}function ne(){let e,t,n=!1;return{complete:function(){!n&&e&&(n=!0,e(),e=void 0,t=void 0)},isHydrated:function(){return n},fail:function(r){!n&&t&&(n=!0,t(r),t=void 0,e=void 0)},promise:new Promise((n,r)=>{e=n,t=r})}}var re=Math.max,oe=Math.min;function ie(e,t=0,n={}){let r,o,i,s,c,a,u=0,l=!1,f=!1,d=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function y(t){const n=r,i=o;return r=o=void 0,u=t,s=n?e.apply(i,n):e.apply(i),s}function p(e){const n=e-(a??0);return void 0===a||n>=t||n<0||f&&void 0!==i&&e-u>=i}function g(){const e=se();if(p(e))return h(e);c=setTimeout(g,function(e){const n=t-(e-(a??0));return f&&void 0!==i?oe(n,i-(e-u)):n}(e))}function h(e){return c=void 0,d&&r?y(e):(r=o=void 0,s)}function b(...e){const n=se(),i=p(n);if(r=e,o=this,a=n,i){if(void 0===c)return function(e){return u=e,c=setTimeout(g,t),l?y(e):s}(a);if(f)return clearTimeout(c),c=setTimeout(g,t),y(a)}return void 0===c&&(c=setTimeout(g,t)),s}return t=ce(t)||0,function(e){const t=typeof e;return null!==e&&("object"===t||"function"===t)}(n)&&(l=!!n.leading,f="maxWait"in n,i=f?re(ce(n.maxWait)||0,t):void 0,d="trailing"in n?!!n.trailing:d),b.cancel=function(){void 0!==c&&clearTimeout(c),u=0,r=a=o=c=void 0},b.flush=function(){return void 0===c?s:h(se())},b}function se(){return"undefined"!=typeof performance&&"function"==typeof performance.now?performance.now():Date.now()}function ce(e){if("number"==typeof e)return e;if("symbol"==typeof e||void 0===e)return NaN;if("object"==typeof e&&null!==e){const t="function"==typeof e.valueOf?e.valueOf():e;e="object"==typeof t?t+"":t}return"string"!=typeof e?0===e?e:+e:(e=e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),/^0b[01]+$/i.test(e)?parseInt(e.slice(2),2):/^0o[0-7]+$/i.test(e)?parseInt(e.slice(2),8):/^[-+]0x[0-9a-f]+$/i.test(e)?NaN:+e)}function ae(e){if(!S(e))return e;const t={__proto__:null},n=Object.keys(e);for(let r=0;r<n.length;r++){const o=n[r],i=e[o];"function"!=typeof i&&(t[o]=i)}return t}var ue=i?0:D.seconds(r?3:5);function le(e,t,n,r){const o=!(t.deserializer||t.serializer||e.deserializer||e.serializer),i="object"==typeof t.sync&&!0===(t.sync.injectStorageMetadata??t.sync.engine?.injectStorageMetadata),s=t.partialize??ae,c=t.deserializer??e.deserializer??de(o),a=t.serializer??e.serializer??ye(o);function u(t,n,o){try{if(be(r))return;const c={state:s(n),version:o},u=ge(r,i,c),l=a(c);try{e.set(t,l),he(r,u)}catch(e){h.error(new w("[createBaseStore]: Failed to persist store data",e))}}catch(e){h.error(new w("[createBaseStore]: Failed to persist store data",e))}}const l=void 0!==n?ie(u,n,{leading:!1,maxWait:n,trailing:!0}):u;return{getItem:t=>{const n=e.get(t);return void 0===n?null:c(n)},setItem:(e,t,n)=>{r?.getIsApplyingRemote()||l(e,t,n)},removeItem:t=>{try{e.delete(t)}catch(e){h.error(new w("[createBaseStore]: Failed to delete persisted store data",e))}}}}function fe(e,t,n,r){const o=!(t.deserializer||t.serializer||e.deserializer||e.serializer),i="object"==typeof t.sync&&!0===(t.sync.injectStorageMetadata??t.sync.engine?.injectStorageMetadata),s=t.partialize??ae,c=t.deserializer??e.deserializer??de(o),a=t.serializer??e.serializer??ye(o);async function u(t,n,o){try{if(be(r))return;const c={state:s(n),version:o},u=ge(r,i,c),l=a(c);try{await e.set(t,l),he(r,u)}catch(e){h.error(new w("[createBaseStore]: Failed to persist store data",e))}}catch(e){h.error(new w("[createBaseStore]: Failed to serialize persisted store data",e))}}const l=void 0!==n?ie(u,n,{leading:!1,maxWait:n,trailing:!0}):function(e){let t,n=null;return function(...r){return t=r,n||(n=new Promise(r=>{queueMicrotask(async()=>{try{await e(...t)}finally{n=null,r()}})})),n}}(u);return{getItem:async t=>{const n=await e.get(t);return void 0===n?null:c(n)},setItem:async(e,t,n)=>{if(!r?.getIsApplyingRemote())return await l(e,t,n)},removeItem:async t=>{try{await e.delete(t)}catch(e){h.error(new w("[createBaseStore]: Failed to delete persisted store data",e))}}}}function de(e){return t=>{if("string"!=typeof t)throw new w("[createBaseStore]: Received non-string serialized state without a custom deserializer. Provide a deserializer on the store or storage adapter.");return function(e,t){try{return JSON.parse(e,t?V:void 0)}catch(e){throw h.error(new w("[createBaseStore]: Failed to deserialize persisted store data",e)),e}}(t,e)}}function ye(e){return t=>function(e,t){try{return JSON.stringify(e,t?L:void 0)}catch(e){throw h.error(new w("[createBaseStore]: Failed to serialize store data",e)),e}}(t,e)}var pe=Object.freeze({shouldClear:!1});function ge(e,t,n){if(!t||!e)return pe;const r=e.getFieldTimestampSnapshot();return function(e,t){const n=e.getSessionId(),r=e.getTimestamp();void 0!==n&&void 0!==r&&(t.syncMetadata={origin:n,timestamp:r})}(e,n),n.syncMetadata?r&&Object.keys(r).length>0?(n.syncMetadata.fields=r,{fieldSnapshot:r,shouldClear:!0}):(delete n.syncMetadata.fields,{fieldSnapshot:r,shouldClear:!1}):{fieldSnapshot:r,shouldClear:!1}}function he(e,t){e&&t.shouldClear&&t.fieldSnapshot&&Object.keys(t.fieldSnapshot).length&&e.clearFieldTimestamps(t.fieldSnapshot)}function be(e){return!!e&&!!e.getIsApplyingRemote()}var[me,Se]=[0,1];function ve(e,t,n){if(!e)return!0;const r=e[me],o=e[Se];return!(t<r)&&(t>r||n>o)}function we(e,t){return Object.prototype.hasOwnProperty.call(t,e)}function Oe(e,t){if(!o)return!0;if(null===e||null===t)return e===t;const n=typeof e;return n===typeof t&&("object"!==n||Object.prototype.toString.call(e)===Object.prototype.toString.call(t))}function qe(e){if(null===e)return"null";const t=typeof e;return"object"===t?Object.prototype.toString.call(e):t}function je(e,t){if(k(),!t)return Y(e);const n=t.storageKey,r="string"==typeof n,o=r?t.storage??C().storage:void 0,i=function(e,t){if(!e)return null;const n="object"==typeof e,r=n?e.key??t:!0===e?t:e;if(!r)throw new w("[createBaseStore]: sync requires a key to be specified either directly or via storageKey");return n?{...e,key:r}:{key:r}}(t.sync,n),s=i?function(e,t,n){const r=t.engine??C().syncEngine,o=function(e){let t,n,r,o=!1;return{isAsync:e,clearFieldTimestamps:function(e){if(e&&r){for(const t of Object.entries(e)){const e=t[0],n=t[1];r[e]===n&&delete r[e]}Object.keys(r).length||(r=void 0)}},getFieldTimestampSnapshot:function(){if(r)return{...r}},getIsApplyingRemote:()=>o,getSessionId:()=>t,getTimestamp:()=>n,mergeFieldTimestamps:function(e){if(r)for(const t of Object.entries(e)){const e=t[0],n=t[1],o=r[e];(void 0===o||n>o)&&(r[e]=n)}else r={...e}},onHydrationComplete:void 0,onHydrationFlushEnd:void 0,setIsApplyingRemote:e=>o=e,setSessionId:e=>t=e,setTimestamp:e=>n=e,setWithoutPersist:void 0}}(n);return{stateCreator:(i,s,c)=>{const a=new Map,u=[],l=[];let f=null,d=!1,y=!1,p=0,g=null,b=[],m=Promise.resolve(),S=!n;function v(e,t){if(o?.setSessionId&&o?.setTimestamp&&r.sessionId&&(o.setSessionId(r.sessionId),o.setTimestamp(e),o.mergeFieldTimestamps&&t.length>0)){const n={__proto__:null};for(const r of t)n[String(r)]=e;o.mergeFieldTimestamps(n)}}function O(e,t){if(d||!g)return t?i(e,t):i(e);const n=function(){const e=Date.now(),t=e>p?e:p+1;return p=t,t}();let o=[],s={__proto__:null};const c=r=>{const i=R(r,e,t);for(const e of b)Object.is(i[e],r[e])||(o.push(e),s[e]=i[e]);return o.length&&v(n,o),i},u=t?i(c,!0):i(c);function h(){o.length&&function(e){const t=r.sessionId;for(const n of e.keys)a.set(n,[e.timestamp,t]);f&&y?f.publish?.({replace:e.replace,sessionId:t,timestamp:e.timestamp,values:e.values}):l.push(e)}({keys:o,replace:t??!1,values:s,timestamp:n})}return Z(u)?u.finally(h):(h(),u)}const q=c.setState;c.setState=O;const j=e(O,s,c);if(b=t.fields??function(e){const t=[];for(const n of Object.entries(e)){if("function"==typeof n[1])continue;const e=n[0];t.push(e)}return t}(j),!b.length)return j;async function F(e){p=Math.max(p,e.timestamp);const n={__proto__:null},r=s(),i=e.timestamp;let c;if(e.replace)for(const t of b)we(t,e.values)||ve(a.get(t),i,e.sessionId)&&(c??(c=[])).push(t);for(const o of b){if(!we(o,e.values))continue;if(!g?.has(o))continue;if(!ve(a.get(o),i,e.sessionId))continue;const s=t.merge?.[o];if(s){const t=e.values[o],c=r[o];if(void 0!==t){const u=s(t,c,r,e.values),l=void 0!==c?c:t;if(!Oe(u,l))return void h.error(new w(`[sync] Merge function for field "${String(o)}" returned ${qe(u)} but expected ${qe(l)}`));n[o]=u,a.set(o,[i,e.sessionId])}}else n[o]=e.values[o],a.set(o,[i,e.sessionId])}if(Object.keys(n).length>0||c?.length){d=!0,o&&o.setIsApplyingRemote(!0);try{if(e.replace){const e={...r};let t=!1;if(c?.length){t=!0;for(const t of c)delete e[t],a.delete(t)}for(const r in n){if(!Object.prototype.hasOwnProperty.call(n,r))continue;const o=n[r];void 0!==o&&(Object.is(e[r],o)||(t=!0),e[r]=o)}if(!t)return;await(o.setWithoutPersist??q)(e,!0)}else await(o.setWithoutPersist??q)(n)}finally{d=!1,o&&o.setIsApplyingRemote(!1)}}}function _(e){n?m=m.then(()=>F(e)):F(e)}if(g=new Set(b),f=r.register({apply:e=>{S?_(e):u.push(e)},fields:b,getState:s,key:t.key}),f?.onFirstSubscribe||f?.onLastUnsubscribe){let e=0;const t=c.subscribe;c.subscribe=(...n)=>{e||f.onFirstSubscribe?.(),e+=1;const r=1===n.length?t(n[0]):t(n[0],n[1],n[2]);return()=>{r(),e-=1,e||queueMicrotask(()=>{e||f.onLastUnsubscribe?.()})}}}function A(){y=!0,function(){if(f&&l.length){for(const e of l){const t=r.sessionId;for(const n of e.keys)a.set(n,[e.timestamp,t]);v(e.timestamp,e.keys),f.publish?.({replace:e.replace,sessionId:t,timestamp:e.timestamp,values:e.values})}l.length=0}}()}function I(){S=!0,function(){if(!u.length)return;const e=u.slice();u.length=0;for(const t of e)_(t)}()}return n?(o.onHydrationComplete=A,o.onHydrationFlushEnd=I):f.onHydrated?(f.onHydrated(A),I()):(A(),I()),j},syncContext:o}}(e,i,o?.async??!1):void 0,c=s?.stateCreator??e;if(!r)return Y(c);const a=function(e,t,n){const r=t??e.storage??C().storage,o=(e.sync?void 0:e.persistThrottleMs??ue)||void 0,i=e.version??0;return r.async?{async:!0,persistStorage:fe(r,e,o,n),version:i}:{async:!1,persistStorage:le(r,e,o,n),version:i}}(t,o,s?.syncContext),u=a.async?function(e){let t,n,r,o=!1;return{hydrationPromise:()=>o?t?.promise??n??(n=Promise.resolve()):(t||(t=ne()),t.promise),stateCreator:(n,i,s)=>{let c;return r=()=>{if(c?.length){for(const e of c)K(s.setState,e);c=void 0}},e(function(...e){return o?K(n,e):(t||(t=ne()),c||(c=[]),c.push(e),t.promise)},i,s)},wrapOnRehydrateStorage:(e,n)=>i=>{const s=e?.(i);return(e,i)=>{o=!0,n?.onHydrationComplete?.(),r&&r(),n?.onHydrationFlushEnd?.(),i?t?.fail(O(i)):t?.complete(),s?.(e,i)}}}}(c):void 0,l=u?u.wrapOnRehydrateStorage(t.onRehydrateStorage,s?.syncContext):t.onRehydrateStorage,f=Y(function(e,t){return(n,r,o)=>{let i,s,c,a=ee(t),u=!1,l=0;function f(){return a.storage.setItem(a.name,r(),a.version)}const d=o.setState;o.setState=function(...e){return K(d,e),f()};const y=e(function(...e){return K(n,e),f()},r,o);function p(){const e=function(){const e=++l;return u=!1,s?.forEach(e=>e(r()??y)),e}(),t=a.onRehydrateStorage?.(r()??y);try{const n=a.storage.getItem(a.name);return Z(n)?n.then(n=>g(e,n,t)).catch(n=>m(e,t,n)):g(e,n,t)}catch(n){m(e,t,n)}}return o.getInitialState=()=>y,Object.assign(o,{persist:{clearStorage:()=>{a.storage.removeItem(a.name)},getOptions:()=>a,hasHydrated:()=>u,onFinishHydration:e=>(c??(c=new Set),c.add(e),()=>{c?.delete(e),0===c?.size&&(c=void 0)}),onHydrate:e=>(s??(s=new Set),s.add(e),()=>{s?.delete(e),0===s?.size&&(s=void 0)}),rehydrate:p,setOptions:e=>{a=ee({...a,...e,storage:e.storage??a.storage})}}}),a.skipHydration||p(),i??y;function g(e,t,n){const r=function(e,t){if(!t)return{migrated:!1,state:void 0};if("number"!=typeof t.version||t.version===e.version)return{migrated:!1,state:t.state};if(!e.migrate)return console.error("State loaded from storage couldn't be migrated since no migrate function was provided"),{migrated:!1,state:void 0};const n=e.migrate(t.state,t.version);return Z(n)?n.then(e=>({migrated:!0,state:e})):{migrated:!0,state:n}}(a,t);return Z(r)?r.then(t=>h(e,t,n)).catch(t=>m(e,n,t)):h(e,r,n)}function h(e,t,o){const s=function(e,t){if(e!==l)return;const o=a.merge(t.state,r()??y);return i=o,n(o,!0),t.migrated?f():void 0}(e,t);if(Z(s))return s.then(()=>b(e,o));b(e,o)}function b(e,t){if(e!==l)return;t?.(i,void 0);const n=r();i=n,u=!0,c?.forEach(e=>e(n))}function m(e,t,n){e===l&&t?.(void 0,n)}}}(u?(e,t,n)=>(s&&(s.syncContext.setWithoutPersist=n.setState),u.stateCreator(e,t,n)):c,{merge:t.merge,migrate:t.migrate,name:n,onRehydrateStorage:l,storage:a.persistStorage,version:a.version}));return u?Object.assign(f,{persist:Object.assign(f.persist,{hydrationPromise:u.hydrationPromise})}):f}function Fe(e,t,n="s"){return 1===t?e:`${e}${n}`}var _e=t.unstable_batchedUpdates,Ae=!1,Ie=!1,Ce=new Map,ke=new Map,Ee=new Map,Te=null,xe=1/0;function De(){return Ae}function Me(){return Te}function ze(){Ae||(Ae=!0,Ie||(Ie=!0,queueMicrotask(()=>{Ie=!1,_e(()=>{for(;ke.size>0;){const e=xe,t=Ee.get(e);if(t){Ee.delete(e);for(const e of t)ke.delete(e);Te=e;for(const e of t)e();if(Te=null,Ee.size>0){xe=1/0;for(const e of Ee.keys())e<xe&&(xe=e)}else xe=1/0}else{xe=1/0;for(const e of Ee.keys())e<xe&&(xe=e)}}for(;Ce.size>0;){const e=Array.from(Ce.values());Ce.clear();for(const t of e)t()}}),Ae=!1,Te=null,ke.clear(),Ee.clear(),xe=1/0})))}function Pe(e,t){Ae&&Ce.set(e,t)}var Ke=Symbol("stores.deriveProxy.unwrap");function Re(e,t,n){const r=t.get(e);if(void 0!==r)return r;const o=function(e,t,n,r=[]){return e&&"object"==typeof e?$e(e,r,t,n,new WeakSet,new WeakMap):(n(t,r,!0),e)}(W(e)?e.getSnapshot():e.getState(),e,n);return t.set(e,o),o}function $e(e,t,n,r,o,i){return new Proxy(e,{get(s,c,a){if(c===Ke)return r(n,t,!0),s;if(o.has(s))return Reflect.get(s,c,a);if("__proto__"===c||"symbol"==typeof c)return c===Symbol.iterator&&(r(n,t,!0),o.add(s)),Reflect.get(s,c,a);const u=Reflect.get(s,c,s),l=String(c),f=t.concat(l);if("function"==typeof u)return Object.prototype.hasOwnProperty.call(s,c)?function(...e){return r(n,f,!0,{args:e.length?e:void 0}),Reflect.apply(u,s,e)}:(r(n,t,!0),u.bind(e));const d=!!u&&"object"==typeof u;return r(n,f,!d),d?(i.has(u)||i.set(u,$e(u,f,n,r,o,i)),i.get(u)):u},getOwnPropertyDescriptor:(e,i)=>(r(n,t,!0),o.add(e),Reflect.getOwnPropertyDescriptor(e,i)),has:(e,o)=>(r(n,t,!0),Reflect.has(e,o)),ownKeys:e=>(r(n,t,!0),o.add(e),Reflect.ownKeys(e))})}function Le(e,t){if(!e||"object"!=typeof e)return e;const n=function(e){const t=Reflect.get(e,Ke);return t&&"object"==typeof t?t:void 0}(e);return n||(Array.isArray(e)?function(e,t){const n=Ne(e,t);if(n)for(let t=0;t<e.length;t++)Ve(e,String(t),n)}(e,t):S(e)&&function(e,t){const n=Ne(e,t);if(n)for(const t of Reflect.ownKeys(e))Ve(e,t,n)}(e,t),e)}function Ve(e,t,n){const r=Reflect.getOwnPropertyDescriptor(e,t);if(!r||!("value"in r))return;const o=Le(r.value,n);o!==r.value&&(r.value=o,Reflect.defineProperty(e,t,r))}function Ne(e,t){const n=t??new WeakSet;return n.has(e)?null:(n.add(e),n)}var He=Object.freeze([]);function We(){const e=new Map;return{buildProxySubscriptions(t,n,r,o){const i=new Set;for(const t of e)Qe(t[1],t[0],[],0,i,r);!1!==o?.(i)&&function(e,t,n){for(const n of e){const e=n.invocation?Xe(n.path,n.invocation):Ge(n.path);t(n.store,e,n.path)}n&&function(e){const t=e.size;console.log(`[📡 ${t} ${Fe("Proxy Subscription",t)} 📡]:`,JSON.stringify(Array.from(e).map(e=>{const t="name"in(n=e.store)&&"string"==typeof n.name?n.name:"store";var n;const r=e.path.join(".");if(!e.invocation)return r?`$(${t}).${r}`:`$(${t})`;const o=e.invocation.args?.length??0;return`$(${t}).${r}${o?`(${o}_${Fe("arg",o)})`:"()"}`}),null,2))}(e)}(i,t,n)},reset(){e.clear()},trackPath(t,n,r,o){let i=e.get(t);i||(i={__proto__:null},e.set(t,i)),Ue(i,n,0,r,o)}}}function Ue(e,t,n,r,o){if(n===t.length)return r&&(e.isLeaf=!0),void(o&&function(e,t){const n=e.invocation;if(!n)return void(e.invocation=t);if(Je(n,t))return;const r=e.extraInvocations;if(r){for(let e=0;e<r.length;e++)if(Je(r[e],t))return;r.push(t)}else e.extraInvocations=[t]}(e,o));e.children||(e.children={__proto__:null});const i=t[n];let s=e.children?.[i];s||(s={__proto__:null},e.children[i]=s),Ue(s,t,n+1,r,o)}function Qe(e,t,n,r,o,i=2){const s=e.children;if(!s)return void Be(e,t,n,o);const c=Object.keys(s),a=c.length;if(0!==a)if(e.isLeaf||r>=i&&a>1){Be(e,t,n,o);for(const e of c){const c=s[e];c.invocation&&Qe(c,t,[...n,e],r+1,o,i)}}else if(r<i&&a>1&&!e.isLeaf)for(const e of c)Qe(s[e],t,[...n,e],r+1,o,i);else{if(1===a){const e=c[0];return void Qe(s[e],t,[...n,e],r+1,o,i)}Be(e,t,n,o)}else Be(e,t,n,o)}function Je(e,t){const n=e.args,r=t.args,o=n?.length??0;if(o!==(r?.length??0))return!1;if(!n||!r)return!0;for(let e=0;e<o;e++)if(!Object.is(n[e],r[e]))return!1;return!0}function Be(e,t,n,r){const o=e.isLeaf??!1,i=e.invocation;if(!i)return void r.add({store:t,path:n,isLeaf:o});r.add({store:t,path:n,invocation:i,isLeaf:o});const s=e.extraInvocations;if(s)for(let e=0;e<s.length;e++)r.add({store:t,path:n,invocation:s[e],isLeaf:o})}function Ge(e){return t=>Ye(t,e)}function Xe(e,t){const n=e.slice(0,-1),r=e[e.length-1];return e=>{const o=Ye(e,n),i=o&&"object"==typeof o?Reflect.get(o,r):void 0;return"function"==typeof i?Reflect.apply(i,o,t.args??He):void 0}}function Ye(e,t){let n=e;for(const e of t){if(!n||"object"!=typeof n)return n;n=Reflect.get(n,e)}return n}var Ze=Symbol(),et=Object.freeze({equalityFn:Object.is,isDerivedStore:!0});function tt(e,t=Object.is){const{debounceOptions:n,debugMode:r,equalityFn:i,keepAlive:c,lockDependencies:a}="function"==typeof(f=t)?{debounceOptions:void 0,debugMode:!1,equalityFn:f,keepAlive:!1,lockDependencies:!1}:{debounceOptions:f.debounce,debugMode:(o&&f.debugMode)??!1,equalityFn:f.equalityFn??Object.is,keepAlive:f.keepAlive??!1,lockDependencies:f.lockDependencies??!1},u=String(nt+=1),l=new Set;var f;c&&l.add(rt);const d=new Set;let y,p,g=Ze,h=!1,b=!0,m=!0,S=0,v=!1,w=null,O=Ze;function q(e,t,n){return m&&l.size?t?(d.add(e.subscribe(t,D,n?{equalityFn:n,isDerivedStore:!0}:et)),t(W(e)?e.getSnapshot():e.getState())):(y||(y=new WeakMap),p||(p=We()),Re(e,y,p.trackPath)):(t??s)(W(e)?e.getSnapshot():e.getState())}function j(e){for(const t of d)t(e);d.clear()}let F=!0;function _(){if(!b&&ot(g))return g;b=!1,m&&j(!0);const t=g,n=ot(t);g=function(t){F=!0;const n=g,o=e(t),s=p?Le(o):o;return ot(n)&&i(n,s)?(r&&console.log("[🥷 Derive Complete 🥷]: No change detected"),F=!1,n):s}(q);const o=r&&(!n||"verbose"===r&&m);if(o){n?"verbose"===r&&console.log("[🌀 Rebuilding Subscriptions 🌀]: Created…"):console.log("[🌀 Initial Derive Complete 🌀]: Created…");const e=d.size;console.log(`[🎯 ${e} ${Fe("Selector Subscription",e)} 🎯]`)}return p&&m&&(p.buildProxySubscriptions((e,t)=>{d.add(e.subscribe(t,D,et))},o),y=void 0,p.reset(),a&&(p=void 0)),F&&n&&function(e,t){const n=function(){const e=l.has(rt)?l.size-1:l.size;return S>0&&S<e}(),o=!S||n,i=n||null!==Me()||De()&&o;n&&ze(),r&&console.log(`[📻 Derive Complete 📻]: Notifying ${l.size} ${Fe("watcher",l.size)}`);for(const t of l){if("function"==typeof t||!t.isDerivedWatcher)continue;const n=t.selector(e);if(!t.equalityFn(t.currentSlice,n)){const e=t.currentSlice;t.currentSlice=n,t.listener(n,e)}}i?v||(v=!0,ot(O)||(O=t),Pe(u,I)):A(e,t)}(g,t),a&&(m=!1),g}function A(e,t){for(const n of l)if("function"==typeof n)n(e,t);else if(!n.isDerivedWatcher){const t=n.selector(e);if(!n.equalityFn(n.currentSlice,t)){const e=n.currentSlice;n.currentSlice=t,n.listener(t,e)}}}function I(){if(!l.size)return;if(b&&!S&&_(),!ot(g))return;const e=ot(O)?O:g;A(g,e),v=!1,O=Ze}const C=n?ie(E,"number"==typeof n?n:n.delay,"number"==typeof n?{leading:!1,maxWait:n,trailing:!0}:n):void 0,k=C??(()=>{h||(h=!0,queueMicrotask(E))});function E(){h=!1,l.size?b&&_():z()}function T(e){e||C&&b?queueMicrotask(()=>{l.size||z()}):z()}function x(){E(),w=null}function D(){if(!b){if(b=!0,!C){if(S){ze();const e=Me(),t=null===e?0:e+1;if(null!==w&&t<=w)return;return w=t,void function(e,t){if(!Ae)return;const n=t<0?0:0|t,r=ke.get(e);if(void 0===r){ke.set(e,n);let t=Ee.get(n);return t||(t=new Set,Ee.set(n,t)),t.add(e),void(n<xe&&(xe=n))}if(n>r){const t=Ee.get(r);if(t&&(t.delete(e),0===t.size&&(Ee.delete(r),r===xe))){xe=1/0;for(const e of Ee.keys())e<xe&&(xe=e)}ke.set(e,n);let o=Ee.get(n);o||(o=new Set,Ee.set(n,o)),o.add(e),n<xe&&(xe=n)}}(x,t)}if(De())return void(v||(v=!0,ot(g)&&(O=g),Pe(u,I)))}w=null,k()}}function M(){return b||!ot(g)?l.size>0?_():e(q):g}function z(e=!0){c&&e||(C?.cancel(),j(),l.clear(),S=0,p=void 0,y=void 0,m=!0,h=!1,b=!0,g=Ze,v=!1,O=Ze,w=null)}return{destroy:()=>z(!1),flushUpdates:function(){l.size&&(C?C.flush():b&&_())},getSnapshot:function(){if(!ot(g)){l.add(rt);const e=_();return l.delete(rt),e}return h&&E(),g},getState:M,subscribe:function(...e){if(1===e.length){const t=e[0];return l.add(t),1!==l.size||ot(g)||M(),()=>{l.delete(t),l.size||T(!1)}}const[t,n,r]=e,o=r?.equalityFn??Object.is,i=r?.isDerivedStore??!1,s={currentSlice:void 0,equalityFn:o,isDerivedWatcher:i,listener:n,selector:t};return l.add(s),s.currentSlice=t(M()),i&&(S+=1),r?.fireImmediately&&n(s.currentSlice,s.currentSlice),()=>{l.delete(s),i&&(S-=1),l.size||T(i)}},getInitialState:()=>{throw new Error("[createDerivedStore]: getInitialState() is not available on derived stores.")},setState:()=>{throw new Error("[createDerivedStore]: setState() is not available on derived stores.")}}}var nt=0;function rt(){}function ot(e){return e!==Ze}var it=class{constructor({disableAutoRefetching:e,initialEnabled:t}){this.count=0,this.enabled=!1,this.lastSubscriptionTime=null,this.fetchThrottleMs=null,this.onSubscribe=null,this.onLastUnsubscribe=null,this.enabled=t,e&&(this.fetchThrottleMs=D.seconds(5))}init({onSubscribe:e,onLastUnsubscribe:t}){this.onSubscribe=e,this.onLastUnsubscribe=t}get(){return{enabled:this.enabled,lastSubscriptionTime:this.lastSubscriptionTime,subscriptionCount:this.count}}setEnabled(e){this.enabled=e}subscribe(){const e=0===this.count,t=null!==this.fetchThrottleMs&&null!==this.lastSubscriptionTime&&!e&&Date.now()-this.lastSubscriptionTime<=this.fetchThrottleMs;return this.onSubscribe?.(this.enabled,e,t),this.count+=1,this.lastSubscriptionTime=Date.now(),e=>{const t=1===this.count;this.count=Math.max(this.count-1,0),t&&(this.onLastUnsubscribe?.(e),this.lastSubscriptionTime=null)}}},st=new WeakMap,ct=new WeakMap;function at(e,t=ut,n=X){return function(e,t,n){let r=ct.get(e);r||(r=new Map,ct.set(e,r));let o=r.get(t);o||(o=new Map,r.set(t,o));const i=o.get(n);if(i)return i;const[s,c,a]=ft(e,t,n),u=new Map,l=e=>new Proxy({__proto__:null},{get(t,n){if("value"===n){let t=c();const n=e.split(".");for(const e of n)e&&(t=t[e]);return t}const r="string"==typeof n?n:n.toString(),o=e?`${e}.${r}`:r,i=u.get(o);if(i)return i;const a=l(o);return st.set(a,s),u.set(o,a),a},set(t,n,r){const o=e.split(".");return""===o[0]&&o.shift(),a(o,r),!0}}),f=l("");return s(()=>{}),st.set(f,s),o.set(n,f),f}(e,t,n)}var ut=e=>e,lt=(e,t,n)=>{if(!t.length)return n;const[r,...o]=t,i=e[r],s=lt(i,o,n);if(X(i,s))return e;const c=Array.isArray(e)?e.slice():{...e};return c[r]=s,c},ft=(e,t,n)=>{const r=new Set,o=W(e);let i,s=t(o?e.getSnapshot():e.getState());return[c=>(r.size||(i=e.subscribe(t,e=>{s=e,r.forEach(e=>e())},{equalityFn:n,isDerivedStore:o})),r.add(c),()=>{r.delete(c),!r.size&&i&&(i(),i=void 0)}),()=>(r.size||(s=t(e.getState())),s),(n,r)=>{if(t!==ut)throw new Error("Cannot set a value with a selector");e.setState(e=>lt(e,n,r),!0)}]};function dt(e){return st.get(e)}var yt={error:!0,lastFetchedAt:!0,queryCache:!0,queryKey:!0,status:!0,enabled:!1,fetch:!1,getCacheEntry:!1,getData:!1,getStatus:!1,isDataExpired:!1,isStale:!1,reset:!1},pt=Object.freeze({force:!0}),gt=Object.freeze({once:!0}),ht=Object.freeze({updateQueryKey:!0});function bt(e,t,n,r){return r?St(r,n)?r:{...mt(e,t),...r}:mt(e,t)}function mt(e,t){const n=Object.assign({__proto__:null},t?.params);for(const t in e?.params){const r=e.params[t];r&&(n[t]=r.value)}return n}function St(e,t){if(!e)return!1;for(const n of t)if(!(n in e))return!1;return!0}function vt(e){return"function"==typeof e}function wt(e){return!vt(e)}function Ot(e,t){return n=>{const r={...n},o={__proto__:null};for(const e in r)m(r,e)&&e in yt&&(yt[e]&&(o[e]=r[e]),delete r[e]);return{...t?t(r):ae(r),...qt(e,null,o)}}}function qt(e,t,n){if(!n.queryCache)return n;const r=Date.now(),o=t??(e&&n.queryKey||null),i={__proto__:null};let s=!1;for(const e in n.queryCache){if(!m(n.queryCache,e))continue;const c=n.queryCache[e];c&&(r-(c.lastFetchedAt??c.errorInfo.lastFailedAt)<c.cacheTime||e===o)?!t&&c.errorInfo&&c.errorInfo.retryCount>0?(i[e]={...c,errorInfo:{...c.errorInfo,retryCount:0}},s=!0):i[e]=c:s=!0}return s?{...n,queryCache:i}:n}function jt(){return Object.create(null)}function Ft(e,t,n){return new w(`[createQueryStore: ${e}]: ${t} failed`,n)}function _t(e){return function(...t){return!0===t[1]?e().setState(t[0],!0):e().setState(t[0])}}var At=Symbol(),It=Object.freeze({debugMode:!1,enabled:!0,equalityFn:Object.is,fireImmediately:!1}),Ct=Object.freeze({fireImmediately:!1,forceResubscribe:!1});function kt(e,t,n=Ct){if(t.current.isActive){if(!n?.forceResubscribe)return;t.current.unsubscribe()}t.current.options.debugMode&&console.log("[📡 useListen 📡] Attaching listener"),t.current.isActive=!0,t.current.resubscribe=(n=Ct)=>kt(e,t,n);const r=e.subscribe(e=>t.current.selector(e),(e,n)=>t.current.react(e,n,()=>{r(),t.current.isActive=!1}),n.fireImmediately?{...t.current.options,fireImmediately:!0}:t.current.options);t.current.unsubscribe=()=>{t.current.isActive&&(r(),t.current.isActive=!1)}}function Et(e){return"function"==typeof e?{equalityFn:e}:e??It}var Tt=Symbol();exports.QueryStatuses=x,exports.StoresError=w,exports.applyStateUpdate=R,exports.configureStores=function(e){var t;o&&function(){if(I)throw new Error("[stores]: configureStores() called after first store creation. Call it earlier before creating any stores.")}(),e.logger&&(t=e.logger,h=t),j??(j=function(e){return e?.queryStoreDefaults?{queryStoreDefaults:e.queryStoreDefaults}:void 0}(e)),F??(F=E(e))},exports.createBaseStore=function(e,t){const n=je(e,t);return p(n,n.getState,n.getInitialState,Object.is)},exports.createDerivedStore=function(e,t=Object.is){const n=tt(e,t);return p(n,n.getSnapshot)},exports.createQueryStore=function(e,t,n){const r=function(e,t,n){k();const r="function"==typeof t?t:jt,s="object"==typeof t?t:n,c=function(e){return"string"==typeof e?.storageKey}(s)?s:void 0,a=T??(T=function(){const e={abortInterruptedFetches:!0,cacheTime:D.days(7),debugMode:!1,disableAutoRefetching:!1,keepPreviousData:!1,maxRetries:5,minStaleTime:!1,paramChangeThrottle:!1,retryDelay:M,staleTime:D.minutes(2),suppressStaleTimeWarning:!1},t=function(){if(j)return j}()?.queryStoreDefaults;return t?{...e,...t}:e}()),u=a.minStaleTime,{fetcher:l,onError:f,onFetched:d,setData:y,transform:p,abortInterruptedFetches:g=a.abortInterruptedFetches,cacheTime:b=a.cacheTime,debugMode:S=a.debugMode,disableAutoRefetching:v=a.disableAutoRefetching,disableCache:q=!1,enabled:F=!0,keepPreviousData:_=a.keepPreviousData,maxRetries:A=a.maxRetries,paramChangeThrottle:I=a.paramChangeThrottle,params:C,retryDelay:E=a.retryDelay,staleTime:P=a.staleTime,suppressStaleTimeWarning:K=a.suppressStaleTimeWarning}=e;let R="function"==typeof P?a.staleTime:P;o&&!1!==u&&!v&&!K&&R<u&&console.warn(`[createQueryStore${c?.storageKey?`: ${c.storageKey}`:""}] ❌ Stale times under ${u/1e3} seconds are not recommended. Provided staleTime: ${R/1e3} seconds`);const $=new Error("[createQueryStore: AbortError] Fetch interrupted"),L="function"==typeof b,V=o&&S,H=e.params?Object.keys(e.params):[];let W=null,U=null,Q=null,J=[],B=!1,G=!1,Y=null,Z=null,ee=null,te=null,ne=null;const re={enabled:"function"!=typeof F&&F,error:null,lastFetchedAt:null,queryCache:{},queryKey:"",status:x.Idle},oe=new it({disableAutoRefetching:v,initialEnabled:re.enabled});function se(){Y&&(Z=null,Y.abort(),Y=null)}function ce(t,n,o){const i=o.setState;function s(e){const t="function"==typeof e;if(t||void 0!==e.enabled){let n;const r=i(r=>{const o=t?e(r):e,i=void 0!==o.enabled?o.enabled:r.enabled;return i!==r.enabled&&(n=()=>function(e,t){e!==t&&ne!==t&&(ne=t,oe.setEnabled(t),t?queueMicrotask(()=>u.fetch(void 0,ht)):(ee||g)&&(g&&se(),ee&&(clearTimeout(ee),ee=null)))}(r.enabled,i)),o});return n?.(),r}return i(e)}function a(e,t){if(v||t?.skipStoreUpdates)return;if(R<=0||R===1/0)return;ee&&(clearTimeout(ee),ee=null);const r=z(e),o=n(),i=(q?te===r&&o.lastFetchedAt:o.queryCache[r]?.lastFetchedAt)||null,s=i?R-(Date.now()-i):R;ee=setTimeout(()=>{const t=oe.get();t.enabled&&t.subscriptionCount>0&&u.fetch(e,pt,!0)},s)}o.setState=s,oe.init({onSubscribe:(r,o,i)=>{if(U||W||!C&&"function"!=typeof e.enabled&&"function"!=typeof e.staleTime){if(r)if(o){const e=mt(W,U),r=z(e),o=n();o.queryKey!==r&&t({queryKey:r}),o.isStale()?u.fetch(e,void 0,!0):a(e,void 0)}else v&&!i&&u.fetch(void 0,void 0,!0)}else B=!0},onLastUnsubscribe:e=>{ee&&(clearTimeout(ee),ee=null),g&&!e&&se()}});const u={...r(s,n,o),...re,async fetch(e,r,o=!1){const i=oe.get();if(!r?.force&&!r?.skipStoreUpdates&&!i.enabled)return null;const m=n(),S=m.error,v=m.queryKey,j=m.status===x.Loading,F=bt(W,U,H,e),I=z(F);if(j&&Z?.promise&&Z.key===I)return V&&console.log("[🔄 Using Active Fetch 🔄] for params:",JSON.stringify(F)),Z.promise;const C=r?.staleTime??R,k=!!r?.skipStoreUpdates,T="boolean"==typeof r?.updateQueryKey?r.updateQueryKey:!!o&&_,D=(o||v===I||T)&&!k;if(g&&D&&se(),!r?.force){const e=m.lastFetchedAt,n=m.queryCache[I],o=n?.lastFetchedAt,s=n?.errorInfo,c=s&&s.retryCount>=A,u=(q?te===I&&e:o)||null;if(u&&!(Date.now()-u>=C)&&(!s||c||k))return D&&!ee&&i.subscriptionCount>0&&0!==R&&R!==1/0&&a(F,r),T&&t(e=>e.queryKey!==I?{queryKey:I}:e),V&&console.log("[💾 Returning Cached Data 💾] for params:",JSON.stringify(F)),n?.data??null}D&&(ee&&(clearTimeout(ee),ee=null),!S&&j||t({error:null,status:x.Loading}),Z={key:I});const M=r?.cacheTime??(L?b(F):b);async function P(){const i=c?.storageKey||I;try{V&&(o||!e||St(e,H)?console.log("[🔄 Fetching 🔄] for params:",JSON.stringify(F)):console.log("[🔄 Fetching with Partial Params 🔄]\n","- Provided params:",`${JSON.stringify(e)}\n`,"- Filled in params:",`${JSON.stringify(Object.fromEntries(Object.keys(F).filter(t=>!(t in e)).map(e=>[e,F[e]])))}`));const n=await(g&&D?async function(e){const t=new AbortController;Y=t;try{return await new Promise((n,r)=>{t.signal.addEventListener("abort",()=>r($),gt),Promise.resolve(l(e,t)).then(n,r)})}finally{Y===t&&(Y=null)}}(F):l(F,null)),c=Date.now();let f;V&&console.log("[✅ Fetch Successful ✅] for params:",JSON.stringify(F));try{f=function(e,t,n){return n?n(e,t):e}(n,F,p)}catch(e){throw Ft(i,"transform",e)}if(k)return V&&console.log("[🥷 Successful Parallel Fetch 🥷] for params:",JSON.stringify(F)),"withCache"===r.skipStoreUpdates&&t(e=>{if(!y)return q?e:{queryCache:{...e.queryCache,[I]:{cacheTime:M,data:f,errorInfo:null,lastFetchedAt:c}}};let t=e;const n=t.queryCache[I];try{y({data:f,params:F,queryKey:I,set:e=>{t="function"==typeof e?{...t,...e(t)}:{...t,...e}}})}catch(e){throw Ft(i,"setData",e)}return!q&&Object.is(n,t.queryCache[I])&&(t={...t,queryCache:{...t.queryCache,[I]:{cacheTime:M,data:null,errorInfo:null,lastFetchedAt:c}}}),t}),f;if((y?s:t)(e=>{let t={...e,error:null,lastFetchedAt:c,queryKey:T?I:e.queryKey,status:x.Success};if(y||q){if(y){V&&console.log("[💾 Setting Data 💾] for params:",JSON.stringify(F));const e=t.queryCache[I];try{y({data:f,params:F,queryKey:I,set:e=>{t="function"==typeof e?{...t,...e(t)}:{...t,...e}}})}catch(e){throw Ft(i,"setData",e)}!q&&Object.is(e,t.queryCache[I])&&(t.queryCache={...t.queryCache,[I]:{cacheTime:M,data:null,errorInfo:null,lastFetchedAt:c}})}}else V&&console.log("[💾 Setting Cache 💾] for params:",JSON.stringify(F),"| Has previous data?:",!!t.queryCache[I]?.data),t.queryCache={...t.queryCache,[I]:{cacheTime:M,data:f,errorInfo:null,lastFetchedAt:c}};return q||b===1/0?t:qt(_,I,t)}),D&&(te=I,a(F,r)),d)try{d({data:f,fetch:u.fetch,params:F,set:s})}catch(e){h.error(Ft(i,"onFetched callback",e))}return f??null}catch(s){if(s===$)return V&&console.log("[❌ Fetch Aborted ❌] for params:",JSON.stringify(F)),null;const c=!o&&!0===r?.throwOnError,a=O(s);if(a instanceof w&&h.error(a),!D){if(c)throw a;return null}const l=q?void 0:n().queryCache[I],d=l?.errorInfo?.retryCount??0,y=d+1;try{f?.(a,d)}catch(e){h.error(Ft(i,"onError callback",e))}if(d<A){if(oe.get().subscriptionCount>0){const t="function"==typeof E?E(y,a):E;t!==1/0&&(ee&&clearTimeout(ee),ee=setTimeout(()=>{const t=oe.get();t.enabled&&t.subscriptionCount>0&&u.fetch(e,pt,!0)},t))}t(e=>({error:a,queryCache:{...e.queryCache,[I]:{cacheTime:l?.cacheTime??M,data:l?.data??null,lastFetchedAt:l?.lastFetchedAt??null,errorInfo:{error:a,lastFailedAt:Date.now(),retryCount:y}}},queryKey:T?I:e.queryKey,status:x.Error}))}else t(e=>({error:a,queryCache:{...e.queryCache,[I]:{cacheTime:l?.cacheTime??M,data:l?.data??null,lastFetchedAt:l?.lastFetchedAt??null,errorInfo:{error:a,lastFailedAt:Date.now(),retryCount:A}}},queryKey:T?I:e.queryKey,status:x.Error}));if(c)throw a;return null}finally{D&&(Z=null)}}return D?(Z={key:I,promise:P()}).promise:P()},getCacheEntry(e){if(q)return null;const t=n(),r=e?"string"==typeof e?e:z(bt(W,U,H,e)):t.queryKey;return t.queryCache[r]??null},getData(e){if(q)return null;const t=n().getCacheEntry(e);return t&&null!==t.data?_?t.data:t.lastFetchedAt&&Date.now()-t.lastFetchedAt>=t.cacheTime?null:t.data:null},getStatus:function(e){const t=n(),r=t.status;switch(e){case"isIdle":return r===x.Idle;case"isLoading":return r===x.Loading;case"isError":case"isInitialLoad":case"isSuccess":case void 0:{const n=t.queryKey,o=t.queryCache[n],i=q?r===x.Error:"number"==typeof o?.errorInfo?.lastFailedAt;if("isError"===e)return i;const s=null!==((q?te===n&&t.lastFetchedAt:o?.lastFetchedAt)||null),c=!s&&!i&&t.enabled;if("isInitialLoad"===e)return c;const a=s&&!i;return"isSuccess"===e?a:{isError:i,isIdle:r===x.Idle,isLoading:r===x.Loading,isInitialLoad:c,isSuccess:a}}}},isDataExpired(e){const t=n(),r=t.queryCache[t.queryKey],o=t.queryKey,i=t.lastFetchedAt,s=(q?te===o&&i:r?.lastFetchedAt)||null;if(!s)return!0;const c=e??r?.cacheTime;return void 0===c||Date.now()-s>=c},isStale(e){const t=n(),r=t.queryKey,o=(q?te===r&&t.lastFetchedAt:t.queryCache[r]?.lastFetchedAt)||null;if(!o)return!0;const i=e??R;return Date.now()-o>=i},reset(e=!1){for(const e of J)e();J=[],W=null,U=null,Q=null,se(),ee&&(clearTimeout(ee),ee=null),Z=null,te=null,e&&t(re)}},m=o.subscribe;return o.subscribe=(...e)=>{const t=G?()=>{}:oe.subscribe(),n=1===e.length?m(e[0]):m(e[0],e[1],e[2]);return e=>{t(e),n()}},u}const ae=c?.storageKey?je(ce,(ue=c,void 0===(le={partialize:Ot(_,c.partialize)})?Object.assign({__proto__:null},ue):Object.assign({__proto__:null},ue,le))):s&&!("storageKey"in s)?je(ce,s):je(ce);var ue,le;const fe=ae.getState(),de=fe.error,ye=fe.enabled,pe=fe.queryKey,ge=fe.fetch;let he;if(pe&&!de&&(te=pe),G=!0,C||"function"==typeof e.enabled){const{directValues:e,enabledAttachVal:t,enabledDirectValue:n,attachVals:r}=function(e,t,n){const r={__proto__:null},o={__proto__:null},i={__proto__:null};for(const e in t){if(!m(t,e))continue;const s=t[e];if(vt(s)){const t=s(at,n);r[e]=t,i[e]=t.value}else wt(s)&&(o[e]=s,i[e]=s)}let s,c=null,a=null;if(vt(e)){const t=e(at,n);s=t.value,c=t}else s=e,a=e;return{attachVals:r,directValues:o,enabledAttachVal:c,enabledDirectValue:a,resolvedEnabled:s,resolvedParams:i}}(F,C,ae);W={enabled:t,params:r},U={enabled:n,params:e}}"function"==typeof e.staleTime&&(Q=e.staleTime(at,ae),R=Q.value);const be=Object.freeze({updateQueryKey:_}),me=function(){let e,t=!1;return function(...n){e=n,t||(t=!0,queueMicrotask(()=>{t=!1,(e=>{ge(e??mt(W,U),be)})(...e)}))}}();function Se(){let e;if(!_){e=mt(W,U);const t=z(e);ae.setState({queryKey:t})}me(e)}const ve=i||!I?Se:ie(Se,"number"==typeof I?I:I.delay,"number"==typeof I?{leading:!1,maxWait:I,trailing:!0}:I);for(const e in W?.params){const t=W.params[e];if(!t)continue;const n=dt(t);if(V&&console.log("[🌀 Param Subscription 🌀] Subscribed to param:",e),n){let r=t.value;const o=n(()=>{const n=t.value;X(r,n)||(V&&console.log("[🌀 Param Change 🌀] -",e,"- [Old]:",`${r?.toString()},`,"[New]:",n?.toString()),r=n,ve())});J.push(o)}}if(Q){const e=dt(Q);if(e){const t=Q;let n=t.value;V&&console.log("[🌀 StaleTime Subscription 🌀] Initial value:",n);const r=e(()=>{const e=t.value;e!==n&&(V&&console.log("[🌀 StaleTime Change 🌀] - [Old]:",`${n},`,"[New]:",e),n=e,R=e,ge())});J.push(r)}}if(W?.enabled){const e=W.enabled,t=dt(e);if(t){let n=e.value;ye!==n&&((he??(he={})).enabled=n),n&&oe.setEnabled(n),V&&console.log("[🌀 Enabled Subscription 🌀] Initial value:",n);const r=t(()=>{const t=e.value;t!==n&&(V&&console.log("[🌀 Enabled Change 🌀] - [Old]:",`${n},`,"[New]:",t),n=t,ae.setState({enabled:t}))});J.push(r)}}else ye!==re.enabled&&((he??(he={})).enabled=re.enabled);const we=z(mt(W,U));return we!==pe&&((he??(he={})).queryKey=we),he&&ae.setState(he),G=!1,B&&queueMicrotask(ve),Oe=ae,qe=N.QueryStore,Object.assign(Oe,{[qe]:!0});var Oe,qe}(e,t,n);return p(r,r.getState,r.getInitialState,Object.is)},exports.createStoreActions=function(e,t){const n=function(e){const t=e.getState(),n={__proto__:null},r=n;if(o&&("object"!=typeof t||null===t))throw new Error("[createStoreActions]: State is not an object");if(J(e))for(const n in t)G(t,n)&&(r[n]=B(e,n));else for(const e in t)G(t,e)&&(r[e]=t[e]);return n}(e);return t?Object.assign(n,t):n},exports.createVirtualStore=function(e,t,n){const r=function(e,t,n){const r="function"==typeof t,o=r?t:void 0,i=r?n:t,s=new Set,a=tt(e,{debugMode:i?.debugMode??!1,equalityFn:function(e,t){const n=Object.is(e,t);return n||(function(e,t){for(const n of s){n.unsubscribe();const r=n.args;if(1===r.length){const o=r[0],i=e.getState(),s=t.getState(),c=t.subscribe(o);n.unsubscribe=c,Object.is(s,i)||o(s,i);continue}const o=r[0],i=r[1];let s=r[2];s?.fireImmediately&&(s={...s,fireImmediately:!1});const c=o(e.getState()),a=o(t.getState()),u=t.subscribe(o,i,s);n.unsubscribe=u,(s?.equalityFn??Object.is)(c,a)||i(a,c)}}(e,t),H(e)),n},keepAlive:!0,lockDependencies:i?.lockDependencies??!0}),u=Object.assign({[N.VirtualStore]:!0,destroy:a.destroy,getInitialState:()=>a.getState().getInitialState(),getState:()=>a.getState().getState(),persist:(l=a.getState,{clearStorage:()=>l().persist?.clearStorage(),getOptions:()=>l().persist?.getOptions()??{},hasHydrated:()=>l().persist?.hasHydrated()??!0,hydrationPromise:()=>l().persist?.hydrationPromise?.()??Promise.resolve(),onFinishHydration:e=>l().persist?.onFinishHydration(e)??c,onHydrate:e=>l().persist?.onHydrate(e)??c,rehydrate:()=>l().persist?.rehydrate(),setOptions:e=>l().persist?.setOptions(e)}),setState:_t(a.getState),subscribe:function(...e){const t={args:e,unsubscribe:1===e.length?a.getState().subscribe(e[0]):a.getState().subscribe(e[0],e[1],e[2])};return s.add(t),()=>{t.unsubscribe(),s.delete(t)}}},o?.(a.getState));var l;return u}(e,t,n);return p(r,r.getState,r.getInitialState)},exports.deepEqual=function e(t,n){if("object"!=typeof t||null==t||"object"!=typeof n||null==n)return t===n;if(Object.is(t,n))return!0;const r=Object.keys(t);if(r.length!==Object.keys(n).length)return!1;for(const o of r)if(!(o in n)||!e(t[o],n[o]))return!1;return!0},exports.defaultRetryDelay=M,exports.destroyStore=H,exports.destroyStores=function(e,t){for(const n of Array.isArray(e)?e:Object.values(e))n&&!t?.skipDestroy?.(n)&&H(n,t)},exports.getQueryKey=function(e){return z(e)},exports.getStoreName=function(e){const t="function"==typeof(n=e)?n.name:"";var n;return Q(e)?e.persist.getOptions().name??t:t},exports.hasGetSnapshot=W,exports.identity=s,exports.isDerivedStore=function(e){return"flushUpdates"in e},exports.isPersistedStore=Q,exports.isQueryStore=U,exports.isVirtualStore=J,exports.nullObject=function(){return{__proto__:null}},exports.parseQueryKey=function(e){return function(e){return JSON.parse(e)}(e)},exports.replacer=L,exports.reviver=V,exports.shallowEqual=function(e,t){if("object"!=typeof e||null==e||"object"!=typeof t||null==t)return e===t;if(Object.is(e,t))return!0;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.is(e[r],t[r]))return!1;return!0},exports.time=D,exports.useListen=function(t,n,r,o=It){const i=function(){const t=e.useRef(At);return t.current===At&&(t.current=function(e,t,n){return{selector:e,react:t,isActive:!1,options:Et(n),resubscribe:()=>{},unsubscribe:()=>{}}}(n,r,o)),t}(),s=function(e){return"function"==typeof e?It.enabled:e?.enabled??It.enabled}(o);return i.current.react=r,i.current.selector=n,function(e,t){"function"==typeof t?e.current.options.equalityFn=t:t&&(e.current.options=t??It)}(i,o),e.useLayoutEffect(()=>{if(s)return kt(t,i),()=>function(e){e.current.options.debugMode&&console.log("[🗑️ useListen 🗑️] Detaching listener"),e.current.resubscribe=()=>{},e.current.unsubscribe(),e.current.unsubscribe=()=>{},e.current.isActive=!1}(i)},[s,t]),i},exports.useStableValue=function(t){const n=e.useRef(Tt);return n.current===Tt&&(n.current=t()),n.current};
|
package/dist/native/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Platform as e,unstable_batchedUpdates as t}from"react-native";import{subscribeWithSelector as n,persist as r}from"zustand/middleware";import{createStore as o}from"zustand/vanilla";import{useLayoutEffect as i,useRef as s,useSyncExternalStore as c,useDebugValue as a}from"react";var u=(e=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(e,{get:(e,t)=>("undefined"!=typeof require?require:e)[t]}):e)(function(e){if("undefined"!=typeof require)return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),l="ios"===e.OS;e.OS;var f="development"===process.env.NODE_ENV,d="test"===process.env.NODE_ENV;function y(e){let t;function n(){if(t)return t;try{const n=function(e){const{createMMKV:t,MMKV:n}=u("react-native-mmkv");if("function"==typeof t)return t({id:e});if("function"==typeof n)return new n({id:e});throw new Error("[stores]: react-native-mmkv module does not export MMKV/createMMKV.")}(e);let r;if("function"==typeof n.delete?r=n.delete.bind(n):"function"==typeof n.remove&&(r=n.remove.bind(n)),"function"!=typeof r)throw new Error("[stores]: Storage instance does not conform to expected interface");const o={clearAll:n.clearAll.bind(n),contains:n.contains.bind(n),delete:r,get:n.getString.bind(n),getAllKeys:n.getAllKeys.bind(n),set:n.set.bind(n)};t=o}catch(e){throw new Error("[stores] react-native-mmkv could not be loaded.\n\nPersisted stores require a storage backend. Either:\n - Install MMKV (the default): yarn add react-native-mmkv\n - Or provide a custom adapter via configureStores()\n"+(e instanceof Error?`\n${e.message}`:""))}return function(e){if(!e||"function"!=typeof e.get||"function"!=typeof e.set||"function"!=typeof e.delete||"function"!=typeof e.clearAll)throw new Error("[stores]: Storage instance does not conform to expected interface")}(t),t}return{clearAll:()=>n().clearAll(),contains:e=>n().contains(e),delete:e=>n().delete(e),get:e=>n().get(e),getAllKeys:()=>n().getAllKeys(),set:(e,t)=>n().set(e,t)}}var p={debug:(e,t)=>{f&&console.debug(e,t)},error:(e,t)=>{f&&!d&&console.error(e,t)},info:(e,t)=>{f&&console.info(e,t)},warn:(e,t)=>{f&&console.warn(e,t)}},h=class extends Error{constructor(e,t){super(e),this.name="StoresError",void 0!==t&&Object.defineProperty(this,"cause",{configurable:!0,value:t,writable:!0})}};function g(e){return e instanceof Error?e:new Error(String(e))}var b=Object.prototype.hasOwnProperty;function m(e,t){return b.call(e,t)}function S(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function v(e){return e}function w(){return{__proto__:null}}function O(){}Object.freeze(Object.create(null));var q,j,F,_=class{destroy(){}publish(){}},A=class{constructor(){this.sessionId="noop"}register(e){return new _}},C=!1;function k(e){var t;f&&function(){if(C)throw new Error("[stores]: configureStores() called after first store creation. Call it earlier before creating any stores.")}(),e.logger&&(t=e.logger,p=t),j??(j=function(e){return e?.queryStoreDefaults?{queryStoreDefaults:e.queryStoreDefaults}:void 0}(e)),F??(F=E(e))}function I(){return F??(F=E(void 0))}function T(){C=!0}function E(e){return{storage:e?.storage??y(e?.storageKeyPrefix??"stores:"),syncEngine:e?.syncEngine??(q||(q=new A),q)}}var M=Symbol("empty selection"),z=Object.is;function D(e,t,n,r,o=z){const i=s(null);let u=e,l=t,f=n;if(r){let s=i.current;null===s&&(s=function(e,t,n,r,o){const i={committedEqualityFn:o,committedSelector:r,committedSource:e,committedValue:M,equalityFn:o,getSelectedServerSnapshot:()=>function(e){return $(e,(e.getServerStoreSnapshot??e.getStoreSnapshot)())}(i),getSelectedSnapshot:()=>P(i),getServerStoreSnapshot:n,getStoreSnapshot:t,latestSnapshot:M,latestSource:M,selector:r,selectedSource:e,selectedSubscribe:()=>O,source:e,value:M,valueEqualityFn:o,valueSelector:r,valueSnapshot:M};return i.selectedSubscribe=K(i,e),i}(e,t,n,r,o),i.current=s),function(e,t,n,r,o,i){e.source===t&&e.getStoreSnapshot===n||(e.latestSnapshot=M),e.source=t,e.getStoreSnapshot=n,e.getServerStoreSnapshot=r,e.selector=o,e.equalityFn=i,e.selectedSource!==t&&(e.selectedSource=t,e.selectedSubscribe=K(e,t))}(s,e,t,n,r,o),u=s.selectedSubscribe,l=s.getSelectedSnapshot,f=void 0===n?void 0:s.getSelectedServerSnapshot}const d=c(u,l,f);return a(d),d}function K(e,t){return n=>(function(e){e.committedEqualityFn=e.equalityFn,e.committedSelector=e.selector,e.committedSource=e.source,e.committedValue=e.value===M?P(e):e.value}(e),t(r=>{e.latestSnapshot=r,e.latestSource=t;const o=e.committedValue;if(o===M||e.committedSource!==t)return void n();const i=e.committedSelector,s=e.committedEqualityFn;if(e.selector===i&&e.equalityFn===s){const t=i(r);if(s===z?z(o,t):s(o,t))return;return e.committedValue=t,e.value=t,e.valueEqualityFn=s,e.valueSelector=i,e.valueSnapshot=r,void n()}if(e.source!==t)return void n();const c=e.value;if(c===M)return;const a=e.selector(r),u=e.equalityFn(c,a);e.committedEqualityFn=e.equalityFn,e.committedSelector=e.selector,e.committedValue=R(e,r,u?c:a),u||n()}))}function P(e){const t=function(e){if(e.latestSource===e.source&&e.latestSnapshot!==M)return e.latestSnapshot;const t=e.getStoreSnapshot();return e.latestSnapshot=t,e.latestSource=e.source,t}(e);return $(e,t)}function $(e,t){const n=e.value;if(n!==M&&z(e.valueSnapshot,t)&&e.valueSelector===e.selector&&e.valueEqualityFn===e.equalityFn)return n;const r=e.selector(t);if(n!==M&&(e.equalityFn===z?z(n,r):e.equalityFn(n,r)))return R(e,t,n);const o=e.committedValue;return o!==M&&o!==n&&e.committedSource===e.source&&(e.equalityFn===z?z(o,r):e.equalityFn(o,r))?R(e,t,o):R(e,t,r)}function R(e,t,n){return e.value=n,e.valueEqualityFn=e.equalityFn,e.valueSelector=e.selector,e.valueSnapshot=t,n}function x(e,t){return(e,t)=>function(e,t){const n=o(e);return Object.assign(function(e,r){return D(n.subscribe,n.getState,n.getInitialState,e,r??t)},n)}(e,t)}function L(){let e,t,n=!1;return{complete:function(){!n&&e&&(n=!0,e(),e=void 0,t=void 0)},isHydrated:function(){return n},fail:function(r){!n&&t&&(n=!0,t(r),t=void 0,e=void 0)},promise:new Promise((n,r)=>{e=n,t=r})}}var N=Math.max,V=Math.min;function W(e,t=0,n={}){let r,o,i,s,c,a,u=0,l=!1,f=!1,d=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function y(t){const n=r,i=o;return r=o=void 0,u=t,s=n?e.apply(i,n):e.apply(i),s}function p(e){const n=e-(a??0);return void 0===a||n>=t||n<0||f&&void 0!==i&&e-u>=i}function h(){const e=H();if(p(e))return g(e);c=setTimeout(h,function(e){const n=t-(e-(a??0));return f&&void 0!==i?V(n,i-(e-u)):n}(e))}function g(e){return c=void 0,d&&r?y(e):(r=o=void 0,s)}function b(...e){const n=H(),i=p(n);if(r=e,o=this,a=n,i){if(void 0===c)return function(e){return u=e,c=setTimeout(h,t),l?y(e):s}(a);if(f)return clearTimeout(c),c=setTimeout(h,t),y(a)}return void 0===c&&(c=setTimeout(h,t)),s}return t=U(t)||0,function(e){const t=typeof e;return null!==e&&("object"===t||"function"===t)}(n)&&(l=!!n.leading,f="maxWait"in n,i=f?N(U(n.maxWait)||0,t):void 0,d="trailing"in n?!!n.trailing:d),b.cancel=function(){void 0!==c&&clearTimeout(c),u=0,r=a=o=c=void 0},b.flush=function(){return void 0===c?s:g(H())},b}function H(){return"undefined"!=typeof performance&&"function"==typeof performance.now?performance.now():Date.now()}function U(e){if("number"==typeof e)return e;if("symbol"==typeof e||void 0===e)return NaN;if("object"==typeof e&&null!==e){const t="function"==typeof e.valueOf?e.valueOf():e;e="object"==typeof t?t+"":t}return"string"!=typeof e?0===e?e:+e:(e=e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),/^0b[01]+$/i.test(e)?parseInt(e.slice(2),2):/^0o[0-7]+$/i.test(e)?parseInt(e.slice(2),8):/^[-+]0x[0-9a-f]+$/i.test(e)?NaN:+e)}function J(e,t){return t instanceof Map?{__type:"Map",entries:Array.from(t.entries())}:t instanceof Set?{__type:"Set",values:Array.from(t)}:t}function B(e,t){return function(e){return"object"==typeof e&&null!==e&&"__type"in e&&"Map"===e.__type}(t)?new Map(t.entries):function(e){return"object"==typeof e&&null!==e&&"__type"in e&&"Set"===e.__type}(t)?new Set(t.values):t}function Q(e){if(!S(e))return e;const t={__proto__:null},n=Object.keys(e);for(let r=0;r<n.length;r++){const o=n[r],i=e[o];"function"!=typeof i&&(t[o]=i)}return t}var G={ms:e=>e,seconds:e=>1e3*e,minutes:e=>6e4*e,hours:e=>36e5*e,days:e=>864e5*e,weeks:e=>6048e5*e,infinity:1/0,zero:0},X=d?0:G.seconds(l?3:5);function Y(e){return t=>{if("string"!=typeof t)throw new h("[createBaseStore]: Received non-string serialized state without a custom deserializer. Provide a deserializer on the store or storage adapter.");return function(e,t){try{return JSON.parse(e,t?B:void 0)}catch(e){throw p.error(new h("[createBaseStore]: Failed to deserialize persisted store data",e)),e}}(t,e)}}function Z(e){return t=>function(e,t){try{return JSON.stringify(e,t?J:void 0)}catch(e){throw p.error(new h("[createBaseStore]: Failed to serialize store data",e)),e}}(t,e)}var ee=Object.freeze({shouldClear:!1});function te(e,t,n){if(!t||!e)return ee;const r=e.getFieldTimestampSnapshot();return function(e,t){const n=e.getSessionId(),r=e.getTimestamp();void 0!==n&&void 0!==r&&(t.syncMetadata={origin:n,timestamp:r})}(e,n),n.syncMetadata?r&&Object.keys(r).length>0?(n.syncMetadata.fields=r,{fieldSnapshot:r,shouldClear:!0}):(delete n.syncMetadata.fields,{fieldSnapshot:r,shouldClear:!1}):{fieldSnapshot:r,shouldClear:!1}}function ne(e,t){e&&t.shouldClear&&t.fieldSnapshot&&Object.keys(t.fieldSnapshot).length&&e.clearFieldTimestamps(t.fieldSnapshot)}function re(e){return!!e&&!!e.getIsApplyingRemote()}var oe=Object.freeze({QueryStore:Symbol("queryStore"),VirtualStore:Symbol("virtualStore")});function ie(e,...t){if(!0===t[1])return pe(t[0])?t[0](e):t[0];const n=pe(t[0])?t[0](e):t[0];return function(e){return Array.isArray(e)}(e)?n:{...e,...n}}function se(e,t){le(e)?e.getState().reset(t?.clearQueryCache):function(e){return"destroy"in e}(e)&&e.destroy()}function ce(e,t){for(const n of Array.isArray(e)?e:Object.values(e))n&&!t?.skipDestroy?.(n)&&se(n,t)}function ae(e){return de(e)?e.persist.getOptions().name??e.name:e.name}function ue(e){return"getSnapshot"in e}function le(e){return oe.QueryStore in e}function fe(e){return"flushUpdates"in e}function de(e){return!(!("persist"in e)||!e.persist)&&"string"==typeof e.persist.getOptions().name}function ye(e){return oe.VirtualStore in e}function pe(e){return"function"==typeof e}var[he,ge]=[0,1];function be(e,t,n){if(!e)return!0;const r=e[he],o=e[ge];return!(t<r)&&(t>r||n>o)}function me(e,t){return Object.prototype.hasOwnProperty.call(t,e)}function Se(e,t){if(!f)return!0;if(null===e||null===t)return e===t;const n=typeof e;return n===typeof t&&("object"!==n||Object.prototype.toString.call(e)===Object.prototype.toString.call(t))}function ve(e){if(null===e)return"null";const t=typeof e;return"object"===t?Object.prototype.toString.call(e):t}function we(e,t){T();const o=void 0!==t&&"string"==typeof t.storageKey,i=o?t.storageKey:void 0,s=t?.sync?function(e,t){if(!e)return null;if(!0===e){if(!t)throw new h("[createBaseStore]: sync: true requires a storageKey to inherit the key from");return{key:t}}if("string"==typeof e)return{key:e};const n=e,r=n.key??t;if(!r)throw new h("[createBaseStore]: sync requires either a key in the config or a storageKey to inherit from");return{...n,key:r}}(t.sync,i):void 0,c=o?t.storage??I().storage:void 0,a=s?function(e,t,n){const r=t.engine??I().syncEngine,o=function(e){let t,n,r,o=!1;return{isAsync:e,clearFieldTimestamps:function(e){if(e&&r){for(const t of Object.entries(e)){const e=t[0],n=t[1];r[e]===n&&delete r[e]}Object.keys(r).length||(r=void 0)}},getFieldTimestampSnapshot:function(){if(r)return{...r}},getIsApplyingRemote:()=>o,getSessionId:()=>t,getTimestamp:()=>n,mergeFieldTimestamps:function(e){if(r)for(const t of Object.entries(e)){const e=t[0],n=t[1],o=r[e];(void 0===o||n>o)&&(r[e]=n)}else r={...e}},onHydrationComplete:void 0,onHydrationFlushEnd:void 0,setIsApplyingRemote:e=>o=e,setSessionId:e=>t=e,setTimestamp:e=>n=e,setWithoutPersist:void 0}}(n);return{stateCreator:(i,s,c)=>{const a=new Map,u=[],l=[];let f=null,d=!1,y=!1,g=0,b=null,m=[],S=Promise.resolve(),v=!n;function w(e,t){if(o?.setSessionId&&o?.setTimestamp&&r.sessionId&&(o.setSessionId(r.sessionId),o.setTimestamp(e),o.mergeFieldTimestamps&&t.length>0)){const n={__proto__:null};for(const r of t)n[String(r)]=e;o.mergeFieldTimestamps(n)}}function O(e,t){if(d||!b)return t?i(e,t):i(e);const n=function(){const e=Date.now(),t=e>g?e:g+1;return g=t,t}();let o=[],s={__proto__:null};const c=r=>{const i=ie(r,e,t);for(const e of m)Object.is(i[e],r[e])||(o.push(e),s[e]=i[e]);return o.length&&w(n,o),i},u=t?i(c,!0):i(c);function p(){o.length&&function(e){const t=r.sessionId;for(const n of e.keys)a.set(n,[e.timestamp,t]);f&&y?f.publish?.({replace:e.replace,sessionId:t,timestamp:e.timestamp,values:e.values}):l.push(e)}({keys:o,replace:t??!1,values:s,timestamp:n})}return(h=u)&&"object"==typeof h&&"then"in h&&"function"==typeof h.then?u.finally(p):(p(),u);var h}const q=c.setState;c.setState=O;const j=e(O,s,c);if(m=t.fields??function(e){const t=[];for(const n of Object.entries(e)){if("function"==typeof n[1])continue;const e=n[0];t.push(e)}return t}(j),!m.length)return j;async function F(e){g=Math.max(g,e.timestamp);const n={__proto__:null},r=s(),i=e.timestamp;let c;if(e.replace)for(const t of m)me(t,e.values)||be(a.get(t),i,e.sessionId)&&(c??(c=[])).push(t);for(const o of m){if(!me(o,e.values))continue;if(!b?.has(o))continue;if(!be(a.get(o),i,e.sessionId))continue;const s=t.merge?.[o];if(s){const t=e.values[o],c=r[o];if(void 0!==t){const u=s(t,c,r,e.values),l=void 0!==c?c:t;if(!Se(u,l))return void p.error(new h(`[sync] Merge function for field "${String(o)}" returned ${ve(u)} but expected ${ve(l)}`));n[o]=u,a.set(o,[i,e.sessionId])}}else n[o]=e.values[o],a.set(o,[i,e.sessionId])}if(Object.keys(n).length>0||c?.length){d=!0,o&&o.setIsApplyingRemote(!0);try{if(e.replace){const e={...r};let t=!1;if(c?.length){t=!0;for(const t of c)delete e[t],a.delete(t)}for(const r in n){if(!Object.prototype.hasOwnProperty.call(n,r))continue;const o=n[r];void 0!==o&&(Object.is(e[r],o)||(t=!0),e[r]=o)}if(!t)return;await(o.setWithoutPersist??q)(e,!0)}else await(o.setWithoutPersist??q)(n)}finally{d=!1,o&&o.setIsApplyingRemote(!1)}}}function _(e){n?S=S.then(()=>F(e)):F(e)}if(b=new Set(m),f=r.register({apply:e=>{v?_(e):u.push(e)},fields:m,getState:s,key:t.key}),f?.onFirstSubscribe||f?.onLastUnsubscribe){let e=0;const t=c.subscribe;c.subscribe=(...n)=>{e||f.onFirstSubscribe?.(),e+=1;const r=1===n.length?t(n[0]):t(n[0],n[1],n[2]);return()=>{r(),e-=1,e||queueMicrotask(()=>{e||f.onLastUnsubscribe?.()})}}}function A(){y=!0,function(){if(f&&l.length){for(const e of l){const t=r.sessionId;for(const n of e.keys)a.set(n,[e.timestamp,t]);w(e.timestamp,e.keys),f.publish?.({replace:e.replace,sessionId:t,timestamp:e.timestamp,values:e.values})}l.length=0}}()}function C(){v=!0,function(){if(!u.length)return;const e=u.slice();u.length=0;for(const t of e)_(t)}()}return n?(o.onHydrationComplete=A,o.onHydrationFlushEnd=C):f.onHydrated?(f.onHydrated(A),C()):(A(),C()),j},syncContext:o}}(e,s,c?.async??!1):void 0,u=a?.stateCreator??e;if(!o)return x()(n(u),Object.is);const l=c?.async?function(e){let t,n,r,o=!1;return{hydrationPromise:()=>o?t?.promise??n??(n=Promise.resolve()):(t||(t=L()),t.promise),stateCreator:(n,i,s)=>{let c;return r=()=>{if(c?.length){for(const e of c)e[1]?s.setState(e[0],e[1]):s.setState(e[0]);c=void 0}},e((...e)=>o?!0===e[1]?n(e[0],e[1]):n(e[0]):(t||(t=L()),c||(c=[]),c.push(e),t.promise),i,s)},wrapOnRehydrateStorage:(e,n)=>i=>{const s=e?.(i);return(e,i)=>{o=!0,n?.onHydrationComplete?.(),r&&r(),n?.onHydrationFlushEnd?.(),i?t?.fail(g(i)):t?.complete(),s?.(e,i)}}}}(u):null,f=function(e,t,n){const r=t??e.storage??I().storage,o=(e.sync?void 0:e.persistThrottleMs??X)||void 0,i=e.version??0,s=r.async?function(e,t,n,r){const o=!(t.deserializer||t.serializer||e.deserializer||e.serializer),i="object"==typeof t.sync&&!0===(t.sync.injectStorageMetadata??t.sync.engine?.injectStorageMetadata),s=t.partialize??Q,c=t.deserializer??e.deserializer??Y(o),a=t.serializer??e.serializer??Z(o);async function u(t,n){try{if(re(r))return;n.state,n.state=s(n.state);const o=te(r,i,n),c=a(n);try{await e.set(t,c),ne(r,o)}catch(e){p.error(new h("[createBaseStore]: Failed to persist store data",e))}}catch(e){p.error(new h("[createBaseStore]: Failed to serialize persisted store data",e))}}const l=void 0!==n?W(u,n,{leading:!1,maxWait:n,trailing:!0}):function(e){let t,n=null;return function(...r){return t=r,n||(n=new Promise(r=>{queueMicrotask(async()=>{try{await e(...t)}finally{n=null,r()}})})),n}}(u);return{getItem:async t=>{const n=await e.get(t);return void 0===n?null:c(n)},setItem:async(e,t)=>{if(!r?.getIsApplyingRemote())return await l(e,t)},removeItem:async t=>{try{await e.delete(t)}catch(e){p.error(new h("[createBaseStore]: Failed to delete persisted store data",e))}}}}(r,e,o,n):function(e,t,n,r){const o=!(t.deserializer||t.serializer||e.deserializer||e.serializer),i="object"==typeof t.sync&&!0===(t.sync.injectStorageMetadata??t.sync.engine?.injectStorageMetadata),s=t.partialize??Q,c=t.deserializer??e.deserializer??Y(o),a=t.serializer??e.serializer??Z(o);function u(t,n){try{if(re(r))return;n.state,n.state=s(n.state);const o=te(r,i,n),c=a(n);try{e.set(t,c),ne(r,o)}catch(e){p.error(new h("[createBaseStore]: Failed to persist store data",e))}}catch(e){p.error(new h("[createBaseStore]: Failed to persist store data",e))}}const l=void 0!==n?W(u,n,{leading:!1,maxWait:n,trailing:!0}):u;return{getItem:t=>{const n=e.get(t);return void 0===n?null:c(n)},setItem:(e,t)=>{r?.getIsApplyingRemote()||l(e,t)},removeItem:t=>{try{e.delete(t)}catch(e){p.error(new h("[createBaseStore]: Failed to delete persisted store data",e))}}}}(r,e,o,n);return{persistStorage:s,version:i}}(t,c,a?.syncContext),d=l?l.wrapOnRehydrateStorage(t.onRehydrateStorage,a?.syncContext):t.onRehydrateStorage,y=l?(e,t,n)=>(a&&(a.syncContext.setWithoutPersist=n.setState),l.stateCreator(e,t,n)):u,b=x()(n(r(y,function(e,t,n){const r={name:e.storageKey,onRehydrateStorage:n,storage:t.persistStorage,version:t.version};return void 0!==e.merge&&(r.merge=e.merge),void 0!==e.migrate&&(r.migrate=e.migrate),r}(t,f,d))),Object.is);return l?Object.assign(b,{persist:Object.assign(b.persist,{hydrationPromise:l.hydrationPromise})}):b}var Oe=!1,qe=!1,je=new Map,Fe=new Map,_e=new Map,Ae=null,Ce=1/0;function ke(){return Oe}function Ie(){return Ae}function Te(){Oe||(Oe=!0,qe||(qe=!0,queueMicrotask(()=>{qe=!1,t(()=>{for(;Fe.size>0;){const e=Ce,t=_e.get(e);if(t){_e.delete(e);for(const e of t)Fe.delete(e);Ae=e;for(const e of t)e();if(Ae=null,_e.size>0){Ce=1/0;for(const e of _e.keys())e<Ce&&(Ce=e)}else Ce=1/0}else{Ce=1/0;for(const e of _e.keys())e<Ce&&(Ce=e)}}for(;je.size>0;){const e=Array.from(je.values());je.clear();for(const t of e)t()}}),Oe=!1,Ae=null,Fe.clear(),_e.clear(),Ce=1/0})))}function Ee(e,t){Oe&&je.set(e,t)}var Me=Symbol("stores.deriveProxy.unwrap");function ze(e,t,n){const r=t.get(e);if(void 0!==r)return r;const o=function(e,t,n,r=[]){return e&&"object"==typeof e?De(e,r,t,n,new WeakSet,new WeakMap):(n(t,r,!0),e)}(ue(e)?e.getSnapshot():e.getState(),e,n);return t.set(e,o),o}function De(e,t,n,r,o,i){return new Proxy(e,{get(s,c,a){if(c===Me)return r(n,t,!0),s;if(o.has(s))return Reflect.get(s,c,a);if("__proto__"===c||"symbol"==typeof c)return c===Symbol.iterator&&(r(n,t,!0),o.add(s)),Reflect.get(s,c,a);const u=Reflect.get(s,c,s),l=String(c),f=t.concat(l);if("function"==typeof u)return Object.prototype.hasOwnProperty.call(s,c)?function(...e){return r(n,f,!0,{method:l,args:e.length?e:void 0}),Reflect.apply(u,s,e)}:(r(n,t,!0),u.bind(e));const d=!!u&&"object"==typeof u;return r(n,f,!d),d?(i.has(u)||i.set(u,De(u,f,n,r,o,i)),i.get(u)):u},getOwnPropertyDescriptor:(e,i)=>(r(n,t,!0),o.add(e),Reflect.getOwnPropertyDescriptor(e,i)),has:(e,o)=>(r(n,t,!0),Reflect.has(e,o)),ownKeys:e=>(r(n,t,!0),o.add(e),Reflect.ownKeys(e))})}function Ke(e,t){if(!e||"object"!=typeof e)return e;const n=function(e){const t=Reflect.get(e,Me);return t&&"object"==typeof t?t:void 0}(e);return n||(Array.isArray(e)?function(e,t){const n=$e(e,t);if(n)for(let t=0;t<e.length;t++)Pe(e,String(t),n)}(e,t):S(e)&&function(e,t){const n=$e(e,t);if(n)for(const t of Reflect.ownKeys(e))Pe(e,t,n)}(e,t),e)}function Pe(e,t,n){const r=Reflect.getOwnPropertyDescriptor(e,t);if(!r||!("value"in r))return;const o=Ke(r.value,n);o!==r.value&&(r.value=o,Reflect.defineProperty(e,t,r))}function $e(e,t){const n=t??new WeakSet;return n.has(e)?null:(n.add(e),n)}function Re(e,t,n="s"){return 1===t?e:`${e}${n}`}var xe=Object.freeze([]);function Le(){const e=new Map;return{buildProxySubscriptions(t,n,r,o){const i=new Set;for(const t of e)Ve(t[1],t[0],[],0,i,r);!1!==o?.(i)&&function(e,t,n){for(const n of e){const e=n.invocation?He(n.path,n.invocation):We(n.path);t(n.store,e,n.path)}n&&function(e){const t=e.size;console.log(`[📡 ${t} ${Re("Proxy Subscription",t)} 📡]:`,JSON.stringify(Array.from(e).map(e=>{const t="name"in(n=e.store)&&"string"==typeof n.name?n.name:"store";var n;const r=e.path.join(".");if(!e.invocation)return r?`$(${t}).${r}`:`$(${t})`;const o=e.invocation.args?.length??0;return`$(${t}).${r}${o?`(${o}_${Re("arg",o)})`:"()"}`}),null,2))}(e)}(i,t,n)},reset(){e.clear()},trackPath(t,n,r,o){let i=e.get(t);i||(i={__proto__:null},e.set(t,i)),Ne(i,n,0,r,o)}}}function Ne(e,t,n,r,o){if(n===t.length)return r&&(e.isLeaf=!0),void(o&&(e.invocation=o));e.children||(e.children={__proto__:null});const i=t[n];let s=e.children?.[i];s||(s={__proto__:null},e.children[i]=s),Ne(s,t,n+1,r,o)}function Ve(e,t,n,r,o,i=2){const s=e.children;if(!s)return void o.add({store:t,path:n,invocation:e.invocation,isLeaf:e.isLeaf??!1});const c=Object.keys(s),a=c.length;if(0!==a)if(e.isLeaf||r>=i&&a>1){o.add({store:t,path:n,invocation:e.invocation,isLeaf:e.isLeaf??!1});for(const e of c){const c=s[e];c.invocation&&Ve(c,t,[...n,e],r+1,o,i)}}else if(r<i&&a>1&&!e.isLeaf)for(const e of c)Ve(s[e],t,[...n,e],r+1,o,i);else{if(1===a){const e=c[0];return void Ve(s[e],t,[...n,e],r+1,o,i)}o.add({store:t,path:n,invocation:e.invocation,isLeaf:e.isLeaf??!1})}else o.add({store:t,path:n,invocation:e.invocation,isLeaf:e.isLeaf??!1})}function We(e){return t=>Ue(t,e)}function He(e,t){const n=e.slice(0,-1);return e=>{const r=Ue(e,n),o=r&&"object"==typeof r?Reflect.get(r,t.method):void 0;return"function"==typeof o?Reflect.apply(o,r,t.args??xe):void 0}}function Ue(e,t){let n=e;for(const e of t){if(!n||"object"!=typeof n)return n;n=Reflect.get(n,e)}return n}function Je(e,t=Object.is){return n=function(e,t=Object.is){const{debounceOptions:n,debugMode:r,equalityFn:o,keepAlive:i,lockDependencies:s}="function"==typeof(u=t)?{debounceOptions:void 0,debugMode:!1,equalityFn:u,keepAlive:!1,lockDependencies:!1}:{debounceOptions:u.debounce,debugMode:(f&&u.debugMode)??!1,equalityFn:u.equalityFn??Object.is,keepAlive:u.keepAlive??!1,lockDependencies:u.lockDependencies??!1},c=String(Ge+=1),a=new Set;var u;i&&a.add(Xe);const l=new Set;let d,y,p=Be,h=!1,g=!0,b=!0,m=0,S=!1,w=null,O=Be;function q(e,t,n){return b&&a.size?t?(l.add(e.subscribe(t,z,n?{equalityFn:n,isDerivedStore:!0}:Qe)),t(ue(e)?e.getSnapshot():e.getState())):(d||(d=new WeakMap),y||(y=Le()),ze(e,d,y.trackPath)):(t??v)(ue(e)?e.getSnapshot():e.getState())}function j(e){for(const t of l)t(e);l.clear()}let F=!0;function _(){if(!g&&Ye(p))return p;g=!1,b&&j(!0);const t=p,n=Ye(t);p=function(t){F=!0;const n=p,i=e(t),s=y?Ke(i):i;return Ye(n)&&o(n,s)?(r&&console.log("[🥷 Derive Complete 🥷]: No change detected"),F=!1,n):s}(q);const i=r&&(!n||"verbose"===r&&b);if(i){n?"verbose"===r&&console.log("[🌀 Rebuilding Subscriptions 🌀]: Created…"):console.log("[🌀 Initial Derive Complete 🌀]: Created…");const e=l.size;console.log(`[🎯 ${e} ${Re("Selector Subscription",e)} 🎯]`)}return y&&b&&(y.buildProxySubscriptions((e,t)=>{l.add(e.subscribe(t,z,Qe))},i),d=void 0,y.reset(),s&&(y=void 0)),F&&n&&function(e,t){const n=function(){const e=a.has(Xe)?a.size-1:a.size;return m>0&&m<e}(),o=!m||n,i=n||null!==Ie()||ke()&&o;n&&Te(),r&&console.log(`[📻 Derive Complete 📻]: Notifying ${a.size} ${Re("watcher",a.size)}`);for(const t of a){if("function"==typeof t||!t.isDerivedWatcher)continue;const n=t.selector(e);if(!t.equalityFn(t.currentSlice,n)){const e=t.currentSlice;t.currentSlice=n,t.listener(n,e)}}i?S||(S=!0,Ye(O)||(O=t),Ee(c,C)):A(e,t)}(p,t),s&&(b=!1),p}function A(e,t){for(const n of a)if("function"==typeof n)n(e,t);else if(!n.isDerivedWatcher){const t=n.selector(e);if(!n.equalityFn(n.currentSlice,t)){const e=n.currentSlice;n.currentSlice=t,n.listener(t,e)}}}function C(){if(!a.size)return;if(g&&!m&&_(),!Ye(p))return;const e=Ye(O)?O:p;A(p,e),S=!1,O=Be}const k=n?W(T,"number"==typeof n?n:n.delay,"number"==typeof n?{leading:!1,maxWait:n,trailing:!0}:n):void 0,I=k??(()=>{h||(h=!0,queueMicrotask(T))});function T(){h=!1,a.size?g&&_():K()}function E(e){e||k&&g?queueMicrotask(()=>{a.size||K()}):K()}function M(){T(),w=null}function z(){if(!g){if(g=!0,!k){if(m){Te();const e=Ie(),t=null===e?0:e+1;if(null!==w&&t<=w)return;return w=t,void function(e,t){if(!Oe)return;const n=t<0?0:0|t,r=Fe.get(e);if(void 0===r){Fe.set(e,n);let t=_e.get(n);return t||(t=new Set,_e.set(n,t)),t.add(e),void(n<Ce&&(Ce=n))}if(n>r){const t=_e.get(r);if(t&&(t.delete(e),0===t.size&&(_e.delete(r),r===Ce))){Ce=1/0;for(const e of _e.keys())e<Ce&&(Ce=e)}Fe.set(e,n);let o=_e.get(n);o||(o=new Set,_e.set(n,o)),o.add(e),n<Ce&&(Ce=n)}}(M,t)}if(ke())return void(S||(S=!0,Ye(p)&&(O=p),Ee(c,C)))}w=null,I()}}function D(){return g||!Ye(p)?a.size>0?_():e(q):p}function K(e=!0){i&&e||(k?.cancel(),j(),a.clear(),m=0,y=void 0,d=void 0,b=!0,h=!1,g=!0,p=Be,S=!1,O=Be,w=null)}return{destroy:()=>K(!1),flushUpdates:function(){a.size&&(k?k.flush():g&&_())},getSnapshot:function(){if(!Ye(p)){a.add(Xe);const e=_();return a.delete(Xe),e}return h&&T(),p},getState:D,subscribe:function(...e){if(1===e.length){const t=e[0];return a.add(t),1!==a.size||Ye(p)||D(),()=>{a.delete(t),a.size||E(!1)}}const[t,n,r]=e,o=r?.equalityFn??Object.is,i=r?.isDerivedStore??!1,s={currentSlice:void 0,equalityFn:o,isDerivedWatcher:i,listener:n,selector:t};return a.add(s),s.currentSlice=t(D()),i&&(m+=1),r?.fireImmediately&&n(s.currentSlice,s.currentSlice),()=>{a.delete(s),i&&(m-=1),a.size||E(i)}},getInitialState:()=>{throw new Error("[createDerivedStore]: getInitialState() is not available on derived stores.")},setState:()=>{throw new Error("[createDerivedStore]: setState() is not available on derived stores.")}}}(e,t),Object.assign(function(e=v,t){return D(n.subscribe,n.getSnapshot,void 0,e,t)},n);var n}var Be=Symbol(),Qe=Object.freeze({equalityFn:Object.is,isDerivedStore:!0}),Ge=0;function Xe(){}function Ye(e){return e!==Be}var Ze,et=class{constructor({disableAutoRefetching:e,initialEnabled:t}){this.count=0,this.enabled=!1,this.lastSubscriptionTime=null,this.fetchThrottleMs=null,this.onSubscribe=null,this.onLastUnsubscribe=null,this.enabled=t,e&&(this.fetchThrottleMs=G.seconds(5))}init({onSubscribe:e,onLastUnsubscribe:t}){this.onSubscribe=e,this.onLastUnsubscribe=t}get(){return{enabled:this.enabled,lastSubscriptionTime:this.lastSubscriptionTime,subscriptionCount:this.count}}setEnabled(e){this.enabled=e}subscribe(){const e=0===this.count,t=null!==this.fetchThrottleMs&&null!==this.lastSubscriptionTime&&!e&&Date.now()-this.lastSubscriptionTime<=this.fetchThrottleMs;return this.onSubscribe?.(this.enabled,e,t),this.count+=1,this.lastSubscriptionTime=Date.now(),e=>{const t=1===this.count;this.count=Math.max(this.count-1,0),t&&(this.onLastUnsubscribe?.(e),this.lastSubscriptionTime=null)}}};function tt(e,t){const n=t?.baseDelay??G.seconds(5),r=t?.maxDelay??G.minutes(5);return Math.min(n*Math.pow(2,e),r)}var nt={Error:"error",Idle:"idle",Loading:"loading",Success:"success"};function rt(e,t){if("object"!=typeof e||null==e||"object"!=typeof t||null==t)return e===t;if(Object.is(e,t))return!0;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!(r in t)||!rt(e[r],t[r]))return!1;return!0}function ot(e,t){if("object"!=typeof e||null==e||"object"!=typeof t||null==t)return e===t;if(Object.is(e,t))return!0;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.is(e[r],t[r]))return!1;return!0}function it(e,t){const n=Object.prototype.hasOwnProperty;function r(e,t){for(const n of e.keys())if(it(n,t))return n}let o,i,s;if(e===t)return!0;if(e&&t&&(o=e.constructor)===t.constructor){if(o===Date)return e.getTime()===t.getTime();if(o===RegExp)return e.toString()===t.toString();if(o===Array){if((i=e.length)===t.length)for(;i--&&it(e[i],t[i]););return-1===i}if(o===Set){if(e.size!==t.size)return!1;for(let n of e){if(s=n,s&&"object"==typeof s&&(s=r(t,s),!s))return!1;if(!t.has(s))return!1}return!0}if(o===Map){if(e.size!==t.size)return!1;for(let n of e){if(s=n[0],s&&"object"==typeof s&&(s=r(t,s),!s))return!1;if(!it(n[1],t.get(s)))return!1}return!0}if(o===ArrayBuffer)e=new Uint8Array(e),t=new Uint8Array(t);else if(o===DataView){if((i=e.byteLength)===t.byteLength)for(;i--&&e.getInt8(i)===t.getInt8(i););return-1===i}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){const n=e,r=t;if((i=n.byteLength)===r.byteLength)for(;i--&&n[i]===r[i];);return-1===i}if(!o||"object"==typeof e){i=0;for(const r in e){if(n.call(e,r)&&++i&&!n.call(t,r))return!1;if(!(r in t)||!it(e[r],t[r]))return!1}return Object.keys(t).length===i}}return e!=e&&t!=t}var st=new WeakMap,ct=new WeakMap;function at(e,t=ut,n=it){return function(e,t,n){let r=ct.get(e);r||(r=new Map,ct.set(e,r));let o=r.get(t);o||(o=new Map,r.set(t,o));const i=o.get(n);if(i)return i;const[s,c,a]=ft(e,t,n),u=new Map,l=e=>new Proxy({__proto__:null},{get(t,n){if("value"===n){let t=c();const n=e.split(".");for(const e of n)e&&(t=t[e]);return t}const r="string"==typeof n?n:n.toString(),o=e?`${e}.${r}`:r,i=u.get(o);if(i)return i;const a=l(o);return st.set(a,s),u.set(o,a),a},set(t,n,r){const o=e.split(".");return""===o[0]&&o.shift(),a(o,r),!0}}),f=l("");return s(()=>{}),st.set(f,s),o.set(n,f),f}(e,t,n)}var ut=e=>e,lt=(e,t,n)=>{if(!t.length)return n;const[r,...o]=t,i=e[r],s=lt(i,o,n);if(it(i,s))return e;const c=Array.isArray(e)?e.slice():{...e};return c[r]=s,c},ft=(e,t,n)=>{const r=new Set,o=ue(e);let i,s=t(o?e.getSnapshot():e.getState());return[c=>(r.size||(i=e.subscribe(t,e=>{s=e,r.forEach(e=>e())},{equalityFn:n,isDerivedStore:o})),r.add(c),()=>{r.delete(c),!r.size&&i&&(i(),i=void 0)}),()=>(r.size||(s=t(e.getState())),s),(n,r)=>{if(t!==ut)throw new Error("Cannot set a value with a selector");e.setState(e=>lt(e,n,r),!0)}]};function dt(e){return st.get(e)}var yt={error:!0,lastFetchedAt:!0,queryCache:!0,queryKey:!0,status:!0,enabled:!1,fetch:!1,getCacheEntry:!1,getData:!1,getStatus:!1,isDataExpired:!1,isStale:!1,reset:!1},pt=Object.freeze({force:!0}),ht=Object.freeze({once:!0}),gt=Object.freeze({updateQueryKey:!0});function bt(e,t,n){T();const r="function"==typeof t?t:Ct,o="object"==typeof t?t:n,i=o&&"storageKey"in o?o:void 0,s=Ze??(Ze=function(){const e={abortInterruptedFetches:!0,cacheTime:G.days(7),debugMode:!1,disableAutoRefetching:!1,keepPreviousData:!1,maxRetries:5,minStaleTime:!1,paramChangeThrottle:!1,retryDelay:tt,staleTime:G.minutes(2),suppressStaleTimeWarning:!1},t=function(){if(j)return j}()?.queryStoreDefaults;return t?{...e,...t}:e}()),c=s.minStaleTime,{fetcher:a,onError:u,onFetched:l,setData:y,transform:b,abortInterruptedFetches:S=s.abortInterruptedFetches,cacheTime:v=s.cacheTime,debugMode:w=s.debugMode,disableAutoRefetching:O=s.disableAutoRefetching,disableCache:q=!1,enabled:F=!0,keepPreviousData:_=s.keepPreviousData,maxRetries:A=s.maxRetries,paramChangeThrottle:C=s.paramChangeThrottle,params:k,retryDelay:I=s.retryDelay,staleTime:E=s.staleTime,suppressStaleTimeWarning:M=s.suppressStaleTimeWarning}=e;let z="function"==typeof E?s.staleTime:E;f&&!1!==c&&!O&&!M&&z<c&&console.warn(`[createQueryStore${i?.storageKey?`: ${i.storageKey}`:""}] ❌ Stale times under ${c/1e3} seconds are not recommended. Provided staleTime: ${z/1e3} seconds`);const D=new Error("[createQueryStore: AbortError] Fetch interrupted"),K="function"==typeof v,P=f&&w,$=e.params?Object.keys(e.params):[];let R=null,x=null,L=null,N=[],V=!1,H=!1,U=null,J=null,B=null,Q=null,X=null;const Y={enabled:"function"!=typeof F&&F,error:null,lastFetchedAt:null,queryCache:{},queryKey:"",status:nt.Idle},Z=new et({disableAutoRefetching:O,initialEnabled:Y.enabled});function ee(){U&&(J=null,U.abort(),U=null)}function te(t,n,o){const s=o.setState;function c(e){const t="function"==typeof e;if(t||void 0!==e.enabled){let n;const r=s(r=>{const o=t?e(r):e,i=void 0!==o.enabled?o.enabled:r.enabled;return i!==r.enabled&&(n=()=>function(e,t){e!==t&&X!==t&&(X=t,Z.setEnabled(t),t?queueMicrotask(()=>d.fetch(void 0,gt)):(B||S)&&(S&&ee(),B&&(clearTimeout(B),B=null)))}(r.enabled,i)),o});return n?.(),r}return s(e)}function f(e,t){if(O||t?.skipStoreUpdates)return;if(z<=0||z===1/0)return;B&&(clearTimeout(B),B=null);const r=mt(e),o=n(),i=(q?Q===r&&o.lastFetchedAt:o.queryCache[r]?.lastFetchedAt)||null,s=i?z-(Date.now()-i):z;B=setTimeout(()=>{const t=Z.get();t.enabled&&t.subscriptionCount>0&&d.fetch(e,pt,!0)},s)}o.setState=c,Z.init({onSubscribe:(r,o,i)=>{if(x||R||!k&&"function"!=typeof e.enabled&&"function"!=typeof e.staleTime){if(r)if(o){const e=Ot(R,x),r=mt(e),o=n();o.queryKey!==r&&t({queryKey:r}),o.isStale()?d.fetch(e,void 0,!0):f(e,void 0)}else O&&!i&&d.fetch(void 0,void 0,!0)}else V=!0},onLastUnsubscribe:e=>{B&&(clearTimeout(B),B=null),S&&!e&&ee()}});const d={...r(c,n,o),...Y,async fetch(e,r,o=!1){const s=Z.get();if(!r?.force&&!r?.skipStoreUpdates&&!s.enabled)return null;const m=n(),w=m.error,O=m.queryKey,j=m.status===nt.Loading,F=wt(R,x,$,e),C=mt(F);if(j&&J?.promise&&J.key===C)return P&&console.log("[🔄 Using Active Fetch 🔄] for params:",JSON.stringify(F)),J.promise;const k=r?.staleTime??z,T=!!r?.skipStoreUpdates,E="boolean"==typeof r?.updateQueryKey?r.updateQueryKey:!!o&&_,M=(o||O===C||E)&&!T;if(S&&M&&ee(),!r?.force){const e=m.lastFetchedAt,n=m.queryCache[C],o=n?.lastFetchedAt,i=n?.errorInfo,c=i&&i.retryCount>=A,a=(q?Q===C&&e:o)||null;if(a&&!(Date.now()-a>=k)&&(!i||c||T))return M&&!B&&s.subscriptionCount>0&&0!==z&&z!==1/0&&f(F,r),E&&t(e=>e.queryKey!==C?{queryKey:C}:e),P&&console.log("[💾 Returning Cached Data 💾] for params:",JSON.stringify(F)),n?.data??null}M&&(B&&(clearTimeout(B),B=null),!w&&j||t({error:null,status:nt.Loading}),J={key:C});const L=r?.cacheTime??(K?v(F):v);async function N(){const s=i?.storageKey||C;try{P&&(o||!e||qt(e,$)?console.log("[🔄 Fetching 🔄] for params:",JSON.stringify(F)):console.log("[🔄 Fetching with Partial Params 🔄]\n","- Provided params:",`${JSON.stringify(e)}\n`,"- Filled in params:",`${JSON.stringify(Object.fromEntries(Object.keys(F).filter(t=>!(t in e)).map(e=>[e,F[e]])))}`));const n=await(S&&M?async function(e){const t=new AbortController;U=t;try{return await new Promise((n,r)=>{t.signal.addEventListener("abort",()=>r(D),ht),Promise.resolve(a(e,t)).then(n,r)})}finally{U===t&&(U=null)}}(F):a(F,null)),i=Date.now();let u;P&&console.log("[✅ Fetch Successful ✅] for params:",JSON.stringify(F));try{u=function(e,t,n){return n?n(e,t):e}(n,F,b)}catch(e){throw kt(s,"transform",e)}if(T)return P&&console.log("[🥷 Successful Parallel Fetch 🥷] for params:",JSON.stringify(F)),"withCache"===r.skipStoreUpdates&&t(e=>{if(!y)return q?e:{queryCache:{...e.queryCache,[C]:{cacheTime:L,data:u,errorInfo:null,lastFetchedAt:i}}};let t=e;const n=t.queryCache[C];try{y({data:u,params:F,queryKey:C,set:e=>{t="function"==typeof e?{...t,...e(t)}:{...t,...e}}})}catch(e){throw kt(s,"setData",e)}return!q&&Object.is(n,t.queryCache[C])&&(t={...t,queryCache:{...t.queryCache,[C]:{cacheTime:L,data:null,errorInfo:null,lastFetchedAt:i}}}),t}),u;if((y?c:t)(e=>{let t={...e,error:null,lastFetchedAt:i,queryKey:E?C:e.queryKey,status:nt.Success};if(y||q){if(y){P&&console.log("[💾 Setting Data 💾] for params:",JSON.stringify(F));const e=t.queryCache[C];try{y({data:u,params:F,queryKey:C,set:e=>{t="function"==typeof e?{...t,...e(t)}:{...t,...e}}})}catch(e){throw kt(s,"setData",e)}!q&&Object.is(e,t.queryCache[C])&&(t.queryCache={...t.queryCache,[C]:{cacheTime:L,data:null,errorInfo:null,lastFetchedAt:i}})}}else P&&console.log("[💾 Setting Cache 💾] for params:",JSON.stringify(F),"| Has previous data?:",!!t.queryCache[C]?.data),t.queryCache={...t.queryCache,[C]:{cacheTime:L,data:u,errorInfo:null,lastFetchedAt:i}};return q||v===1/0?t:At(_,C,t)}),M&&(Q=C,f(F,r)),l)try{l({data:u,fetch:d.fetch,params:F,set:c})}catch(e){p.error(kt(s,"onFetched callback",e))}return u??null}catch(i){if(i===D)return P&&console.log("[❌ Fetch Aborted ❌] for params:",JSON.stringify(F)),null;const c=!o&&!0===r?.throwOnError,a=g(i);if(a instanceof h&&p.error(a),!M){if(c)throw a;return null}const l=q?void 0:n().queryCache[C],f=l?.errorInfo?.retryCount??0,y=f+1;try{u?.(a,f)}catch(e){p.error(kt(s,"onError callback",e))}if(f<A){if(Z.get().subscriptionCount>0){const t="function"==typeof I?I(y,a):I;t!==1/0&&(B&&clearTimeout(B),B=setTimeout(()=>{const t=Z.get();t.enabled&&t.subscriptionCount>0&&d.fetch(e,pt,!0)},t))}t(e=>({error:a,queryCache:{...e.queryCache,[C]:{cacheTime:l?.cacheTime??L,data:l?.data??null,lastFetchedAt:l?.lastFetchedAt??null,errorInfo:{error:a,lastFailedAt:Date.now(),retryCount:y}}},queryKey:E?C:e.queryKey,status:nt.Error}))}else t(e=>({error:a,queryCache:{...e.queryCache,[C]:{cacheTime:l?.cacheTime??L,data:l?.data??null,lastFetchedAt:l?.lastFetchedAt??null,errorInfo:{error:a,lastFailedAt:Date.now(),retryCount:A}}},queryKey:E?C:e.queryKey,status:nt.Error}));if(c)throw a;return null}finally{M&&(J=null)}}return M?(J={key:C,promise:N()}).promise:N()},getCacheEntry(e){if(q)return null;const t=n(),r=e?"string"==typeof e?e:mt(wt(R,x,$,e)):t.queryKey;return t.queryCache[r]??null},getData(e){if(q)return null;const t=n().getCacheEntry(e);return t&&null!==t.data?_?t.data:t.lastFetchedAt&&Date.now()-t.lastFetchedAt>=t.cacheTime?null:t.data:null},getStatus:function(e){const t=n(),r=t.status;switch(e){case"isIdle":return r===nt.Idle;case"isLoading":return r===nt.Loading;case"isError":case"isInitialLoad":case"isSuccess":case void 0:{const n=t.queryKey,o=t.queryCache[n],i=q?r===nt.Error:"number"==typeof o?.errorInfo?.lastFailedAt;if("isError"===e)return i;const s=null!==((q?Q===n&&t.lastFetchedAt:o?.lastFetchedAt)||null),c=!s&&!i&&t.enabled;if("isInitialLoad"===e)return c;const a=s&&!i;return"isSuccess"===e?a:{isError:i,isIdle:r===nt.Idle,isLoading:r===nt.Loading,isInitialLoad:c,isSuccess:a}}}},isDataExpired(e){const t=n(),r=t.queryCache[t.queryKey],o=t.queryKey,i=t.lastFetchedAt,s=(q?Q===o&&i:r?.lastFetchedAt)||null;if(!s)return!0;const c=e??r?.cacheTime;return void 0===c||Date.now()-s>=c},isStale(e){const t=n(),r=t.queryKey,o=(q?Q===r&&t.lastFetchedAt:t.queryCache[r]?.lastFetchedAt)||null;if(!o)return!0;const i=e??z;return Date.now()-o>=i},reset(e=!1){for(const e of N)e();N=[],R=null,x=null,L=null,ee(),B&&(clearTimeout(B),B=null),J=null,Q=null,e&&t(Y)}},m=o.subscribe;return o.subscribe=(...e)=>{const t=H?()=>{}:Z.subscribe(),n=1===e.length?m(e[0]):m(e[0],e[1],e[2]);return e=>{t(e),n()}},d}const ne=i?.storageKey?we(te,(re=i,void 0===(ie={partialize:_t(_,i.partialize)})?Object.assign({__proto__:null},re):Object.assign({__proto__:null},re,ie))):o&&!("storageKey"in o)?we(te,o):we(te);var re,ie;const se=ne.getState(),ce=se.error,ae=se.enabled,ue=se.queryKey,le=se.fetch;let fe;if(ue&&!ce&&(Q=ue),H=!0,k||"function"==typeof e.enabled){const{directValues:e,enabledAttachVal:t,enabledDirectValue:n,attachVals:r}=function(e,t,n){const r={__proto__:null},o={__proto__:null},i={__proto__:null};for(const e in t){if(!m(t,e))continue;const s=t[e];if(jt(s)){const t=s(at,n);r[e]=t,i[e]=t.value}else Ft(s)&&(o[e]=s,i[e]=s)}let s,c=null,a=null;if(jt(e)){const t=e(at,n);s=t.value,c=t}else s=e,a=e;return{attachVals:r,directValues:o,enabledAttachVal:c,enabledDirectValue:a,resolvedEnabled:s,resolvedParams:i}}(F,k,ne);R={enabled:t,params:r},x={enabled:n,params:e}}"function"==typeof e.staleTime&&(L=e.staleTime(at,ne),z=L.value);const de=Object.freeze({updateQueryKey:_}),ye=function(){let e,t=!1;return function(...n){e=n,t||(t=!0,queueMicrotask(()=>{t=!1,(e=>{le(e??Ot(R,x),de)})(...e)}))}}();function pe(){let e;if(!_){e=Ot(R,x);const t=mt(e);ne.setState({queryKey:t})}ye(e)}const he=d||!C?pe:W(pe,"number"==typeof C?C:C.delay,"number"==typeof C?{leading:!1,maxWait:C,trailing:!0}:C);for(const e in R?.params){const t=R.params[e];if(!t)continue;const n=dt(t);if(P&&console.log("[🌀 Param Subscription 🌀] Subscribed to param:",e),n){let r=t.value;const o=n(()=>{const n=t.value;it(r,n)||(P&&console.log("[🌀 Param Change 🌀] -",e,"- [Old]:",`${r?.toString()},`,"[New]:",n?.toString()),r=n,he())});N.push(o)}}if(L){const e=dt(L);if(e){const t=L;let n=t.value;P&&console.log("[🌀 StaleTime Subscription 🌀] Initial value:",n);const r=e(()=>{const e=t.value;e!==n&&(P&&console.log("[🌀 StaleTime Change 🌀] - [Old]:",`${n},`,"[New]:",e),n=e,z=e,le())});N.push(r)}}if(R?.enabled){const e=R.enabled,t=dt(e);if(t){let n=e.value;ae!==n&&((fe??(fe={})).enabled=n),n&&Z.setEnabled(n),P&&console.log("[🌀 Enabled Subscription 🌀] Initial value:",n);const r=t(()=>{const t=e.value;t!==n&&(P&&console.log("[🌀 Enabled Change 🌀] - [Old]:",`${n},`,"[New]:",t),n=t,ne.setState({enabled:t}))});N.push(r)}}else ae!==Y.enabled&&((fe??(fe={})).enabled=Y.enabled);const ge=mt(Ot(R,x));return ge!==ue&&((fe??(fe={})).queryKey=ge),fe&&ne.setState(fe),H=!1,V&&queueMicrotask(he),be=ne,me=oe.QueryStore,Object.assign(be,{[me]:!0});var be,me}function mt(e){return JSON.stringify(vt(e))}function St(e){return JSON.parse(e)}function vt(e){return"object"!=typeof e||null===e?e:Object.keys(e).sort().reduce((t,n)=>{const r=e[n];return t[n]=S(r)?vt(r):r,t},{__proto__:null})}function wt(e,t,n,r){return r?qt(r,n)?r:{...Ot(e,t),...r}:Ot(e,t)}function Ot(e,t){const n=Object.assign({__proto__:null},t?.params);for(const t in e?.params){const r=e.params[t];r&&(n[t]=r.value)}return n}function qt(e,t){if(!e)return!1;for(const n of t)if(!(n in e))return!1;return!0}function jt(e){return"function"==typeof e}function Ft(e){return!jt(e)}function _t(e,t){return n=>{const r={...n},o={__proto__:null};for(const e in r)m(r,e)&&e in yt&&(yt[e]&&(o[e]=r[e]),delete r[e]);return{...t?t(r):Q(r),...At(e,null,o)}}}function At(e,t,n){if(!n.queryCache)return n;const r=Date.now(),o=t??(e&&n.queryKey||null),i={__proto__:null};let s=!1;for(const e in n.queryCache){if(!m(n.queryCache,e))continue;const c=n.queryCache[e];c&&(r-(c.lastFetchedAt??c.errorInfo.lastFailedAt)<c.cacheTime||e===o)?!t&&c.errorInfo&&c.errorInfo.retryCount>0?(i[e]={...c,errorInfo:{...c.errorInfo,retryCount:0}},s=!0):i[e]=c:s=!0}return s?{...n,queryCache:i}:n}function Ct(){return Object.create(null)}function kt(e,t,n){return new h(`[createQueryStore: ${e}]: ${t} failed`,n)}function It(e,t,n){const r="function"==typeof t,o=r?t:void 0,i=r?n:t,s=new Set,c=Je(e,{debugMode:i?.debugMode??!1,equalityFn:function(e,t){const n=Object.is(e,t);return n||(function(e,t){for(const n of s){n.unsubscribe();const r=n.args;if(1===r.length){const o=r[0],i=e.getState(),s=t.getState(),c=t.subscribe(o);n.unsubscribe=c,Object.is(s,i)||o(s,i);continue}const o=r[0],i=r[1];let s=r[2];s?.fireImmediately&&(s={...s,fireImmediately:!1});const c=o(e.getState()),a=o(t.getState()),u=t.subscribe(o,i,s);n.unsubscribe=u,(s?.equalityFn??Object.is)(c,a)||i(a,c)}}(e,t),se(e)),n},keepAlive:!0,lockDependencies:i?.lockDependencies??!0});return Object.assign(function(e,t){const n=c();return e?n(e,t):n()},{[oe.VirtualStore]:!0,destroy:c.destroy,getInitialState:()=>c.getState().getInitialState(),getState:()=>c.getState().getState(),persist:(a=c.getState,{clearStorage:()=>a().persist?.clearStorage(),getOptions:()=>a().persist?.getOptions()??{},hasHydrated:()=>a().persist?.hasHydrated()??!0,hydrationPromise:()=>a().persist?.hydrationPromise?.()??Promise.resolve(),onFinishHydration:e=>a().persist?.onFinishHydration(e)??O,onHydrate:e=>a().persist?.onHydrate(e)??O,rehydrate:()=>a().persist?.rehydrate(),setOptions:e=>a().persist?.setOptions(e)}),setState:Tt(c.getState),subscribe:function(...e){const t={args:e,unsubscribe:1===e.length?c.getState().subscribe(e[0]):c.getState().subscribe(e[0],e[1],e[2])};return s.add(t),()=>{t.unsubscribe(),s.delete(t)}}},o?.(c.getState));var a}function Tt(e){return function(t,n){return n?e().setState(t,n):e().setState(t)}}var Et=Symbol(),Mt=Object.freeze({debugMode:!1,enabled:!0,equalityFn:Object.is,fireImmediately:!1});function zt(e,t,n,r=Mt){const o=function(){const e=s(Et);return e.current===Et&&(e.current=function(e,t,n){return{selector:e,react:t,isActive:!1,options:Pt(n),resubscribe:()=>{},unsubscribe:()=>{}}}(t,n,r)),e}(),c=function(e){return"function"==typeof e?Mt.enabled:e?.enabled??Mt.enabled}(r);return o.current.react=n,o.current.selector=t,function(e,t){"function"==typeof t?e.current.options.equalityFn=t:t&&(e.current.options=t??Mt)}(o,r),i(()=>{if(c)return Kt(e,o),()=>function(e){e.current.options.debugMode&&console.log("[🗑️ useListen 🗑️] Detaching listener"),e.current.resubscribe=()=>{},e.current.unsubscribe(),e.current.unsubscribe=()=>{},e.current.isActive=!1}(o)},[c,e]),o}var Dt=Object.freeze({fireImmediately:!1,forceResubscribe:!1});function Kt(e,t,n=Dt){if(t.current.isActive){if(!n?.forceResubscribe)return;t.current.unsubscribe()}t.current.options.debugMode&&console.log("[📡 useListen 📡] Attaching listener"),t.current.isActive=!0,t.current.resubscribe=(n=Dt)=>Kt(e,t,n);const r=e.subscribe(e=>t.current.selector(e),(e,n)=>t.current.react(e,n,()=>{r(),t.current.isActive=!1}),n.fireImmediately?{...t.current.options,fireImmediately:!0}:t.current.options);t.current.unsubscribe=()=>{t.current.isActive&&(r(),t.current.isActive=!1)}}function Pt(e){return"function"==typeof e?{equalityFn:e}:e??Mt}var $t=Symbol();function Rt(e){const t=s($t);return t.current===$t&&(t.current=e()),t.current}function xt(e,t){const n=function(e){const t=e.getState(),n={__proto__:null},r=n;if(f&&("object"!=typeof t||null===t))throw new Error("[createStoreActions]: State is not an object");if(ye(e))for(const n in t)Nt(t,n)&&(r[n]=Lt(e,n));else for(const e in t)Nt(t,e)&&(r[e]=t[e]);return n}(e);return t?Object.assign(n,t):n}function Lt(e,t){return function(...n){const r=e.getState()[t];if("function"==typeof r)return r(...n);throw new Error(`[createVirtualStoreAction]: Method ${String(t)} is not a function`)}}function Nt(e,t){return"function"==typeof e[t]}export{nt as QueryStatuses,h as StoresError,ie as applyStateUpdate,k as configureStores,we as createBaseStore,Je as createDerivedStore,bt as createQueryStore,xt as createStoreActions,It as createVirtualStore,rt as deepEqual,tt as defaultRetryDelay,se as destroyStore,ce as destroyStores,mt as getQueryKey,ae as getStoreName,ue as hasGetSnapshot,v as identity,fe as isDerivedStore,de as isPersistedStore,le as isQueryStore,ye as isVirtualStore,w as nullObject,St as parseQueryKey,J as replacer,B as reviver,ot as shallowEqual,G as time,zt as useListen,Rt as useStableValue};
|
|
1
|
+
import{useLayoutEffect as e,useRef as t,useSyncExternalStore as n,useDebugValue as r}from"react";import{Platform as o,unstable_batchedUpdates as i}from"react-native";var s=(e=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(e,{get:(e,t)=>("undefined"!=typeof require?require:e)[t]}):e)(function(e){if("undefined"!=typeof require)return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),c="ios"===o.OS;o.OS;var a="development"===process.env.NODE_ENV,u="test"===process.env.NODE_ENV;function l(e){return e}function f(){return{__proto__:null}}function d(){}Object.freeze(Object.create(null));var y=Symbol("empty selection"),p=Object.is;function g(e,t){return n=>(function(e){e.committedEqualityFn=e.equalityFn,e.committedSelector=e.selector,e.committedSource=e.source,e.committedValue=e.value===y?h(e):e.value}(e),t(r=>{e.latestSnapshot=r,e.latestSource=t;const o=e.committedValue;if(o===y||e.committedSource!==t)return void n();const i=e.committedSelector,s=e.committedEqualityFn;if(e.selector===i&&e.equalityFn===s){const t=i(r);if(s===p?p(o,t):s(o,t))return;return e.committedValue=t,e.value=t,e.valueEqualityFn=s,e.valueSelector=i,e.valueSnapshot=r,void n()}if(e.source!==t)return void n();const c=e.value;if(c===y)return;const a=e.selector(r),u=e.equalityFn(c,a);e.committedEqualityFn=e.equalityFn,e.committedSelector=e.selector,e.committedValue=m(e,r,u?c:a),u||n()}))}function h(e){const t=function(e){if(e.latestSource===e.source&&e.latestSnapshot!==y)return e.latestSnapshot;const t=e.getStoreSnapshot();return e.latestSnapshot=t,e.latestSource=e.source,t}(e);return b(e,t)}function b(e,t){const n=e.value;if(n!==y&&p(e.valueSnapshot,t)&&e.valueSelector===e.selector&&e.valueEqualityFn===e.equalityFn)return n;const r=e.selector(t);if(n!==y&&(e.equalityFn===p?p(n,r):e.equalityFn(n,r)))return m(e,t,n);const o=e.committedValue;return o!==y&&o!==n&&e.committedSource===e.source&&(e.equalityFn===p?p(o,r):e.equalityFn(o,r))?m(e,t,o):m(e,t,r)}function m(e,t,n){return e.value=n,e.valueEqualityFn=e.equalityFn,e.valueSelector=e.selector,e.valueSnapshot=t,n}function S(e,o,i,s){return Object.assign(function(c,a){return function(e,o,i,s,c=p){const a=t(null);let u=e,l=o,f=i;if(s){let t=a.current;null===t&&(t=function(e,t,n,r,o){const i={committedEqualityFn:o,committedSelector:r,committedSource:e,committedValue:y,equalityFn:o,getSelectedServerSnapshot:()=>function(e){return b(e,(e.getServerStoreSnapshot??e.getStoreSnapshot)())}(i),getSelectedSnapshot:()=>h(i),getServerStoreSnapshot:n,getStoreSnapshot:t,latestSnapshot:y,latestSource:y,selector:r,selectedSource:e,selectedSubscribe:()=>d,source:e,value:y,valueEqualityFn:o,valueSelector:r,valueSnapshot:y};return i.selectedSubscribe=g(i,e),i}(e,o,i,s,c),a.current=t),function(e,t,n,r,o,i){e.source===t&&e.getStoreSnapshot===n||(e.latestSnapshot=y),e.source=t,e.getStoreSnapshot=n,e.getServerStoreSnapshot=r,e.selector=o,e.equalityFn=i,e.selectedSource!==t&&(e.selectedSource=t,e.selectedSubscribe=g(e,t))}(t,e,o,i,s,c),u=t.selectedSubscribe,l=t.getSelectedSnapshot,f=void 0===i?void 0:t.getSelectedServerSnapshot}const m=n(u,l,f);return r(m),m}(e.subscribe,o,i,c,a??s)},e)}function v(e){let t;function n(){if(t)return t;try{const n=function(e){const{createMMKV:t,MMKV:n}=s("react-native-mmkv");if("function"==typeof t)return t({id:e});if("function"==typeof n)return new n({id:e});throw new Error("[stores]: react-native-mmkv module does not export MMKV/createMMKV.")}(e);let r;if("function"==typeof n.delete?r=n.delete.bind(n):"function"==typeof n.remove&&(r=n.remove.bind(n)),"function"!=typeof r)throw new Error("[stores]: Storage instance does not conform to expected interface");const o={clearAll:n.clearAll.bind(n),contains:n.contains.bind(n),delete:r,get:n.getString.bind(n),getAllKeys:n.getAllKeys.bind(n),set:n.set.bind(n)};t=o}catch(e){throw new Error("[stores] react-native-mmkv could not be loaded.\n\nPersisted stores require a storage backend. Either:\n - Install MMKV (the default): yarn add react-native-mmkv\n - Or provide a custom adapter via configureStores()\n"+(e instanceof Error?`\n${e.message}`:""))}return function(e){if(!e||"function"!=typeof e.get||"function"!=typeof e.set||"function"!=typeof e.delete||"function"!=typeof e.clearAll)throw new Error("[stores]: Storage instance does not conform to expected interface")}(t),t}return{clearAll:()=>n().clearAll(),contains:e=>n().contains(e),delete:e=>n().delete(e),get:e=>n().get(e),getAllKeys:()=>n().getAllKeys(),set:(e,t)=>n().set(e,t)}}var w={debug:(e,t)=>{a&&console.debug(e,t)},error:(e,t)=>{a&&!u&&console.error(e,t)},info:(e,t)=>{a&&console.info(e,t)},warn:(e,t)=>{a&&console.warn(e,t)}},O=Object.prototype.hasOwnProperty;function q(e,t){return O.call(e,t)}function j(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function F(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}var _=class extends Error{constructor(e,t){super(e),this.name="StoresError",void 0!==t&&Object.defineProperty(this,"cause",{configurable:!0,value:t,writable:!0})}};function A(e){return e instanceof Error?e:new Error(String(e))}var I,C,k,T=class{destroy(){}publish(){}},E=class{constructor(){this.sessionId="noop"}register(e){return new T}},M=!1;function z(e){var t;a&&function(){if(M)throw new Error("[stores]: configureStores() called after first store creation. Call it earlier before creating any stores.")}(),e.logger&&(t=e.logger,w=t),C??(C=function(e){return e?.queryStoreDefaults?{queryStoreDefaults:e.queryStoreDefaults}:void 0}(e)),k??(k=P(e))}function D(){return k??(k=P(void 0))}function K(){M=!0}function P(e){return{storage:e?.storage??v(e?.storageKeyPrefix??"stores:"),syncEngine:e?.syncEngine??(I||(I=new E),I)}}var x,R={Error:"error",Idle:"idle",Loading:"loading",Success:"success"},$={ms:e=>e,seconds:e=>1e3*e,minutes:e=>6e4*e,hours:e=>36e5*e,days:e=>864e5*e,weeks:e=>6048e5*e,infinity:1/0,zero:0};function L(e,t){const n=t?.baseDelay??$.seconds(5),r=t?.maxDelay??$.minutes(5);return Math.min(n*Math.pow(2,e),r)}function N(e){return JSON.stringify(V(e))}function V(e){return"object"!=typeof e||null===e?e:Object.keys(e).sort().reduce((t,n)=>{const r=e[n];return t[n]=j(r)?V(r):r,t},{__proto__:null})}function H(e,t){return!0===t[1]?e(t[0],!0):e(t[0])}function W(e,t,n){if(!0===n)return U(t)?t(e):t;const r=U(t)?t(e):t;return Object.is(r,e)?e:F(e)&&F(r)?{...e,...r}:r}function U(e){return"function"==typeof e}function J(e,t){return t instanceof Map?{__type:"Map",entries:Array.from(t.entries())}:t instanceof Set?{__type:"Set",values:Array.from(t)}:t}function B(e,t){return function(e){return"object"==typeof e&&null!==e&&"__type"in e&&"Map"===e.__type}(t)?new Map(t.entries):function(e){return"object"==typeof e&&null!==e&&"__type"in e&&"Set"===e.__type}(t)?new Set(t.values):t}var Q=Object.freeze({QueryStore:Symbol("queryStore"),VirtualStore:Symbol("virtualStore")});function G(e,t){ee(e)?e.getState().reset(t?.clearQueryCache):function(e){return"destroy"in e}(e)&&e.destroy()}function X(e,t){for(const n of Array.isArray(e)?e:Object.values(e))n&&!t?.skipDestroy?.(n)&&G(n,t)}function Y(e){const t="function"==typeof(n=e)?n.name:"";var n;return ne(e)?e.persist.getOptions().name??t:t}function Z(e){return"getSnapshot"in e}function ee(e){return Q.QueryStore in e}function te(e){return"flushUpdates"in e}function ne(e){return!(!("persist"in e)||!e.persist)&&"string"==typeof e.persist.getOptions().name}function re(e){return Q.VirtualStore in e}function oe(e,t){const n=function(e){const t=e.getState(),n={__proto__:null},r=n;if(a&&("object"!=typeof t||null===t))throw new Error("[createStoreActions]: State is not an object");if(re(e))for(const n in t)se(t,n)&&(r[n]=ie(e,n));else for(const e in t)se(t,e)&&(r[e]=t[e]);return n}(e);return t?Object.assign(n,t):n}function ie(e,t){return function(...n){const r=e.getState()[t];if("function"==typeof r)return r(...n);throw new Error(`[createVirtualStoreAction]: Method ${String(t)} is not a function`)}}function se(e,t){return"function"==typeof e[t]}function ce(e,t){if("object"!=typeof e||null==e||"object"!=typeof t||null==t)return e===t;if(Object.is(e,t))return!0;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!(r in t)||!ce(e[r],t[r]))return!1;return!0}function ae(e,t){if("object"!=typeof e||null==e||"object"!=typeof t||null==t)return e===t;if(Object.is(e,t))return!0;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.is(e[r],t[r]))return!1;return!0}function ue(e,t){const n=Object.prototype.hasOwnProperty;function r(e,t){for(const n of e.keys())if(ue(n,t))return n}let o,i,s;if(e===t)return!0;if(e&&t&&(o=e.constructor)===t.constructor){if(o===Date)return e.getTime()===t.getTime();if(o===RegExp)return e.toString()===t.toString();if(o===Array){if((i=e.length)===t.length)for(;i--&&ue(e[i],t[i]););return-1===i}if(o===Set){if(e.size!==t.size)return!1;for(let n of e){if(s=n,s&&"object"==typeof s&&(s=r(t,s),!s))return!1;if(!t.has(s))return!1}return!0}if(o===Map){if(e.size!==t.size)return!1;for(let n of e){if(s=n[0],s&&"object"==typeof s&&(s=r(t,s),!s))return!1;if(!ue(n[1],t.get(s)))return!1}return!0}if(o===ArrayBuffer)e=new Uint8Array(e),t=new Uint8Array(t);else if(o===DataView){if((i=e.byteLength)===t.byteLength)for(;i--&&e.getInt8(i)===t.getInt8(i););return-1===i}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){const n=e,r=t;if((i=n.byteLength)===r.byteLength)for(;i--&&n[i]===r[i];);return-1===i}if(!o||"object"==typeof e){i=0;for(const r in e){if(n.call(e,r)&&++i&&!n.call(t,r))return!1;if(!(r in t)||!ue(e[r],t[r]))return!1}return Object.keys(t).length===i}}return e!=e&&t!=t}function le(e){let t;const n=new Set;function r(...e){const r=W(t,...e);if(Object.is(r,t))return;const o=t;t=r,n.forEach(e=>e(t,o))}function o(){return t}const i={getInitialState:function(){return s},getState:o,setState:r,subscribe:function(...e){return 1===e.length?c(e[0]):function(e,n,r){const o=r?.equalityFn??Object.is;let i=e(t);return r?.fireImmediately&&n(i,i),c(function(t){const r=e(t);if(o(i,r))return;const s=i;i=r,n(r,s)})}(e[0],e[1],e[2])}},s=t=e(r,o,i);return i;function c(e){return n.add(e),()=>{n.delete(e)}}}function fe(e){return!!e&&"object"==typeof e&&"then"in e&&"function"==typeof e.then}function de(e){return{...e,merge:e.merge??ye,skipHydration:e.skipHydration??!1}}function ye(e,t){return void 0===e?t:{...t,...e}}function pe(){let e,t,n=!1;return{complete:function(){!n&&e&&(n=!0,e(),e=void 0,t=void 0)},isHydrated:function(){return n},fail:function(r){!n&&t&&(n=!0,t(r),t=void 0,e=void 0)},promise:new Promise((n,r)=>{e=n,t=r})}}var ge=Math.max,he=Math.min;function be(e,t=0,n={}){let r,o,i,s,c,a,u=0,l=!1,f=!1,d=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function y(t){const n=r,i=o;return r=o=void 0,u=t,s=n?e.apply(i,n):e.apply(i),s}function p(e){const n=e-(a??0);return void 0===a||n>=t||n<0||f&&void 0!==i&&e-u>=i}function g(){const e=me();if(p(e))return h(e);c=setTimeout(g,function(e){const n=t-(e-(a??0));return f&&void 0!==i?he(n,i-(e-u)):n}(e))}function h(e){return c=void 0,d&&r?y(e):(r=o=void 0,s)}function b(...e){const n=me(),i=p(n);if(r=e,o=this,a=n,i){if(void 0===c)return function(e){return u=e,c=setTimeout(g,t),l?y(e):s}(a);if(f)return clearTimeout(c),c=setTimeout(g,t),y(a)}return void 0===c&&(c=setTimeout(g,t)),s}return t=Se(t)||0,function(e){const t=typeof e;return null!==e&&("object"===t||"function"===t)}(n)&&(l=!!n.leading,f="maxWait"in n,i=f?ge(Se(n.maxWait)||0,t):void 0,d="trailing"in n?!!n.trailing:d),b.cancel=function(){void 0!==c&&clearTimeout(c),u=0,r=a=o=c=void 0},b.flush=function(){return void 0===c?s:h(me())},b}function me(){return"undefined"!=typeof performance&&"function"==typeof performance.now?performance.now():Date.now()}function Se(e){if("number"==typeof e)return e;if("symbol"==typeof e||void 0===e)return NaN;if("object"==typeof e&&null!==e){const t="function"==typeof e.valueOf?e.valueOf():e;e="object"==typeof t?t+"":t}return"string"!=typeof e?0===e?e:+e:(e=e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),/^0b[01]+$/i.test(e)?parseInt(e.slice(2),2):/^0o[0-7]+$/i.test(e)?parseInt(e.slice(2),8):/^[-+]0x[0-9a-f]+$/i.test(e)?NaN:+e)}function ve(e){if(!j(e))return e;const t={__proto__:null},n=Object.keys(e);for(let r=0;r<n.length;r++){const o=n[r],i=e[o];"function"!=typeof i&&(t[o]=i)}return t}var we=u?0:$.seconds(c?3:5);function Oe(e,t,n,r){const o=!(t.deserializer||t.serializer||e.deserializer||e.serializer),i="object"==typeof t.sync&&!0===(t.sync.injectStorageMetadata??t.sync.engine?.injectStorageMetadata),s=t.partialize??ve,c=t.deserializer??e.deserializer??je(o),a=t.serializer??e.serializer??Fe(o);function u(t,n,o){try{if(Ce(r))return;const c={state:s(n),version:o},u=Ae(r,i,c),l=a(c);try{e.set(t,l),Ie(r,u)}catch(e){w.error(new _("[createBaseStore]: Failed to persist store data",e))}}catch(e){w.error(new _("[createBaseStore]: Failed to persist store data",e))}}const l=void 0!==n?be(u,n,{leading:!1,maxWait:n,trailing:!0}):u;return{getItem:t=>{const n=e.get(t);return void 0===n?null:c(n)},setItem:(e,t,n)=>{r?.getIsApplyingRemote()||l(e,t,n)},removeItem:t=>{try{e.delete(t)}catch(e){w.error(new _("[createBaseStore]: Failed to delete persisted store data",e))}}}}function qe(e,t,n,r){const o=!(t.deserializer||t.serializer||e.deserializer||e.serializer),i="object"==typeof t.sync&&!0===(t.sync.injectStorageMetadata??t.sync.engine?.injectStorageMetadata),s=t.partialize??ve,c=t.deserializer??e.deserializer??je(o),a=t.serializer??e.serializer??Fe(o);async function u(t,n,o){try{if(Ce(r))return;const c={state:s(n),version:o},u=Ae(r,i,c),l=a(c);try{await e.set(t,l),Ie(r,u)}catch(e){w.error(new _("[createBaseStore]: Failed to persist store data",e))}}catch(e){w.error(new _("[createBaseStore]: Failed to serialize persisted store data",e))}}const l=void 0!==n?be(u,n,{leading:!1,maxWait:n,trailing:!0}):function(e){let t,n=null;return function(...r){return t=r,n||(n=new Promise(r=>{queueMicrotask(async()=>{try{await e(...t)}finally{n=null,r()}})})),n}}(u);return{getItem:async t=>{const n=await e.get(t);return void 0===n?null:c(n)},setItem:async(e,t,n)=>{if(!r?.getIsApplyingRemote())return await l(e,t,n)},removeItem:async t=>{try{await e.delete(t)}catch(e){w.error(new _("[createBaseStore]: Failed to delete persisted store data",e))}}}}function je(e){return t=>{if("string"!=typeof t)throw new _("[createBaseStore]: Received non-string serialized state without a custom deserializer. Provide a deserializer on the store or storage adapter.");return function(e,t){try{return JSON.parse(e,t?B:void 0)}catch(e){throw w.error(new _("[createBaseStore]: Failed to deserialize persisted store data",e)),e}}(t,e)}}function Fe(e){return t=>function(e,t){try{return JSON.stringify(e,t?J:void 0)}catch(e){throw w.error(new _("[createBaseStore]: Failed to serialize store data",e)),e}}(t,e)}var _e=Object.freeze({shouldClear:!1});function Ae(e,t,n){if(!t||!e)return _e;const r=e.getFieldTimestampSnapshot();return function(e,t){const n=e.getSessionId(),r=e.getTimestamp();void 0!==n&&void 0!==r&&(t.syncMetadata={origin:n,timestamp:r})}(e,n),n.syncMetadata?r&&Object.keys(r).length>0?(n.syncMetadata.fields=r,{fieldSnapshot:r,shouldClear:!0}):(delete n.syncMetadata.fields,{fieldSnapshot:r,shouldClear:!1}):{fieldSnapshot:r,shouldClear:!1}}function Ie(e,t){e&&t.shouldClear&&t.fieldSnapshot&&Object.keys(t.fieldSnapshot).length&&e.clearFieldTimestamps(t.fieldSnapshot)}function Ce(e){return!!e&&!!e.getIsApplyingRemote()}var[ke,Te]=[0,1];function Ee(e,t,n){if(!e)return!0;const r=e[ke],o=e[Te];return!(t<r)&&(t>r||n>o)}function Me(e,t){return Object.prototype.hasOwnProperty.call(t,e)}function ze(e,t){if(!a)return!0;if(null===e||null===t)return e===t;const n=typeof e;return n===typeof t&&("object"!==n||Object.prototype.toString.call(e)===Object.prototype.toString.call(t))}function De(e){if(null===e)return"null";const t=typeof e;return"object"===t?Object.prototype.toString.call(e):t}function Ke(e,t){if(K(),!t)return le(e);const n=t.storageKey,r="string"==typeof n,o=r?t.storage??D().storage:void 0,i=function(e,t){if(!e)return null;const n="object"==typeof e,r=n?e.key??t:!0===e?t:e;if(!r)throw new _("[createBaseStore]: sync requires a key to be specified either directly or via storageKey");return n?{...e,key:r}:{key:r}}(t.sync,n),s=i?function(e,t,n){const r=t.engine??D().syncEngine,o=function(e){let t,n,r,o=!1;return{isAsync:e,clearFieldTimestamps:function(e){if(e&&r){for(const t of Object.entries(e)){const e=t[0],n=t[1];r[e]===n&&delete r[e]}Object.keys(r).length||(r=void 0)}},getFieldTimestampSnapshot:function(){if(r)return{...r}},getIsApplyingRemote:()=>o,getSessionId:()=>t,getTimestamp:()=>n,mergeFieldTimestamps:function(e){if(r)for(const t of Object.entries(e)){const e=t[0],n=t[1],o=r[e];(void 0===o||n>o)&&(r[e]=n)}else r={...e}},onHydrationComplete:void 0,onHydrationFlushEnd:void 0,setIsApplyingRemote:e=>o=e,setSessionId:e=>t=e,setTimestamp:e=>n=e,setWithoutPersist:void 0}}(n);return{stateCreator:(i,s,c)=>{const a=new Map,u=[],l=[];let f=null,d=!1,y=!1,p=0,g=null,h=[],b=Promise.resolve(),m=!n;function S(e,t){if(o?.setSessionId&&o?.setTimestamp&&r.sessionId&&(o.setSessionId(r.sessionId),o.setTimestamp(e),o.mergeFieldTimestamps&&t.length>0)){const n={__proto__:null};for(const r of t)n[String(r)]=e;o.mergeFieldTimestamps(n)}}function v(e,t){if(d||!g)return t?i(e,t):i(e);const n=function(){const e=Date.now(),t=e>p?e:p+1;return p=t,t}();let o=[],s={__proto__:null};const c=r=>{const i=W(r,e,t);for(const e of h)Object.is(i[e],r[e])||(o.push(e),s[e]=i[e]);return o.length&&S(n,o),i},u=t?i(c,!0):i(c);function b(){o.length&&function(e){const t=r.sessionId;for(const n of e.keys)a.set(n,[e.timestamp,t]);f&&y?f.publish?.({replace:e.replace,sessionId:t,timestamp:e.timestamp,values:e.values}):l.push(e)}({keys:o,replace:t??!1,values:s,timestamp:n})}return fe(u)?u.finally(b):(b(),u)}const O=c.setState;c.setState=v;const q=e(v,s,c);if(h=t.fields??function(e){const t=[];for(const n of Object.entries(e)){if("function"==typeof n[1])continue;const e=n[0];t.push(e)}return t}(q),!h.length)return q;async function j(e){p=Math.max(p,e.timestamp);const n={__proto__:null},r=s(),i=e.timestamp;let c;if(e.replace)for(const t of h)Me(t,e.values)||Ee(a.get(t),i,e.sessionId)&&(c??(c=[])).push(t);for(const o of h){if(!Me(o,e.values))continue;if(!g?.has(o))continue;if(!Ee(a.get(o),i,e.sessionId))continue;const s=t.merge?.[o];if(s){const t=e.values[o],c=r[o];if(void 0!==t){const u=s(t,c,r,e.values),l=void 0!==c?c:t;if(!ze(u,l))return void w.error(new _(`[sync] Merge function for field "${String(o)}" returned ${De(u)} but expected ${De(l)}`));n[o]=u,a.set(o,[i,e.sessionId])}}else n[o]=e.values[o],a.set(o,[i,e.sessionId])}if(Object.keys(n).length>0||c?.length){d=!0,o&&o.setIsApplyingRemote(!0);try{if(e.replace){const e={...r};let t=!1;if(c?.length){t=!0;for(const t of c)delete e[t],a.delete(t)}for(const r in n){if(!Object.prototype.hasOwnProperty.call(n,r))continue;const o=n[r];void 0!==o&&(Object.is(e[r],o)||(t=!0),e[r]=o)}if(!t)return;await(o.setWithoutPersist??O)(e,!0)}else await(o.setWithoutPersist??O)(n)}finally{d=!1,o&&o.setIsApplyingRemote(!1)}}}function F(e){n?b=b.then(()=>j(e)):j(e)}if(g=new Set(h),f=r.register({apply:e=>{m?F(e):u.push(e)},fields:h,getState:s,key:t.key}),f?.onFirstSubscribe||f?.onLastUnsubscribe){let e=0;const t=c.subscribe;c.subscribe=(...n)=>{e||f.onFirstSubscribe?.(),e+=1;const r=1===n.length?t(n[0]):t(n[0],n[1],n[2]);return()=>{r(),e-=1,e||queueMicrotask(()=>{e||f.onLastUnsubscribe?.()})}}}function A(){y=!0,function(){if(f&&l.length){for(const e of l){const t=r.sessionId;for(const n of e.keys)a.set(n,[e.timestamp,t]);S(e.timestamp,e.keys),f.publish?.({replace:e.replace,sessionId:t,timestamp:e.timestamp,values:e.values})}l.length=0}}()}function I(){m=!0,function(){if(!u.length)return;const e=u.slice();u.length=0;for(const t of e)F(t)}()}return n?(o.onHydrationComplete=A,o.onHydrationFlushEnd=I):f.onHydrated?(f.onHydrated(A),I()):(A(),I()),q},syncContext:o}}(e,i,o?.async??!1):void 0,c=s?.stateCreator??e;if(!r)return le(c);const a=function(e,t,n){const r=t??e.storage??D().storage,o=(e.sync?void 0:e.persistThrottleMs??we)||void 0,i=e.version??0;return r.async?{async:!0,persistStorage:qe(r,e,o,n),version:i}:{async:!1,persistStorage:Oe(r,e,o,n),version:i}}(t,o,s?.syncContext),u=a.async?function(e){let t,n,r,o=!1;return{hydrationPromise:()=>o?t?.promise??n??(n=Promise.resolve()):(t||(t=pe()),t.promise),stateCreator:(n,i,s)=>{let c;return r=()=>{if(c?.length){for(const e of c)H(s.setState,e);c=void 0}},e(function(...e){return o?H(n,e):(t||(t=pe()),c||(c=[]),c.push(e),t.promise)},i,s)},wrapOnRehydrateStorage:(e,n)=>i=>{const s=e?.(i);return(e,i)=>{o=!0,n?.onHydrationComplete?.(),r&&r(),n?.onHydrationFlushEnd?.(),i?t?.fail(A(i)):t?.complete(),s?.(e,i)}}}}(c):void 0,l=u?u.wrapOnRehydrateStorage(t.onRehydrateStorage,s?.syncContext):t.onRehydrateStorage,f=le(function(e,t){return(n,r,o)=>{let i,s,c,a=de(t),u=!1,l=0;function f(){return a.storage.setItem(a.name,r(),a.version)}const d=o.setState;o.setState=function(...e){return H(d,e),f()};const y=e(function(...e){return H(n,e),f()},r,o);function p(){const e=function(){const e=++l;return u=!1,s?.forEach(e=>e(r()??y)),e}(),t=a.onRehydrateStorage?.(r()??y);try{const n=a.storage.getItem(a.name);return fe(n)?n.then(n=>g(e,n,t)).catch(n=>m(e,t,n)):g(e,n,t)}catch(n){m(e,t,n)}}return o.getInitialState=()=>y,Object.assign(o,{persist:{clearStorage:()=>{a.storage.removeItem(a.name)},getOptions:()=>a,hasHydrated:()=>u,onFinishHydration:e=>(c??(c=new Set),c.add(e),()=>{c?.delete(e),0===c?.size&&(c=void 0)}),onHydrate:e=>(s??(s=new Set),s.add(e),()=>{s?.delete(e),0===s?.size&&(s=void 0)}),rehydrate:p,setOptions:e=>{a=de({...a,...e,storage:e.storage??a.storage})}}}),a.skipHydration||p(),i??y;function g(e,t,n){const r=function(e,t){if(!t)return{migrated:!1,state:void 0};if("number"!=typeof t.version||t.version===e.version)return{migrated:!1,state:t.state};if(!e.migrate)return console.error("State loaded from storage couldn't be migrated since no migrate function was provided"),{migrated:!1,state:void 0};const n=e.migrate(t.state,t.version);return fe(n)?n.then(e=>({migrated:!0,state:e})):{migrated:!0,state:n}}(a,t);return fe(r)?r.then(t=>h(e,t,n)).catch(t=>m(e,n,t)):h(e,r,n)}function h(e,t,o){const s=function(e,t){if(e!==l)return;const o=a.merge(t.state,r()??y);return i=o,n(o,!0),t.migrated?f():void 0}(e,t);if(fe(s))return s.then(()=>b(e,o));b(e,o)}function b(e,t){if(e!==l)return;t?.(i,void 0);const n=r();i=n,u=!0,c?.forEach(e=>e(n))}function m(e,t,n){e===l&&t?.(void 0,n)}}}(u?(e,t,n)=>(s&&(s.syncContext.setWithoutPersist=n.setState),u.stateCreator(e,t,n)):c,{merge:t.merge,migrate:t.migrate,name:n,onRehydrateStorage:l,storage:a.persistStorage,version:a.version}));return u?Object.assign(f,{persist:Object.assign(f.persist,{hydrationPromise:u.hydrationPromise})}):f}function Pe(e,t,n="s"){return 1===t?e:`${e}${n}`}var xe=i,Re=!1,$e=!1,Le=new Map,Ne=new Map,Ve=new Map,He=null,We=1/0;function Ue(){return Re}function Je(){return He}function Be(){Re||(Re=!0,$e||($e=!0,queueMicrotask(()=>{$e=!1,xe(()=>{for(;Ne.size>0;){const e=We,t=Ve.get(e);if(t){Ve.delete(e);for(const e of t)Ne.delete(e);He=e;for(const e of t)e();if(He=null,Ve.size>0){We=1/0;for(const e of Ve.keys())e<We&&(We=e)}else We=1/0}else{We=1/0;for(const e of Ve.keys())e<We&&(We=e)}}for(;Le.size>0;){const e=Array.from(Le.values());Le.clear();for(const t of e)t()}}),Re=!1,He=null,Ne.clear(),Ve.clear(),We=1/0})))}function Qe(e,t){Re&&Le.set(e,t)}var Ge=Symbol("stores.deriveProxy.unwrap");function Xe(e,t,n){const r=t.get(e);if(void 0!==r)return r;const o=function(e,t,n,r=[]){return e&&"object"==typeof e?Ye(e,r,t,n,new WeakSet,new WeakMap):(n(t,r,!0),e)}(Z(e)?e.getSnapshot():e.getState(),e,n);return t.set(e,o),o}function Ye(e,t,n,r,o,i){return new Proxy(e,{get(s,c,a){if(c===Ge)return r(n,t,!0),s;if(o.has(s))return Reflect.get(s,c,a);if("__proto__"===c||"symbol"==typeof c)return c===Symbol.iterator&&(r(n,t,!0),o.add(s)),Reflect.get(s,c,a);const u=Reflect.get(s,c,s),l=String(c),f=t.concat(l);if("function"==typeof u)return Object.prototype.hasOwnProperty.call(s,c)?function(...e){return r(n,f,!0,{args:e.length?e:void 0}),Reflect.apply(u,s,e)}:(r(n,t,!0),u.bind(e));const d=!!u&&"object"==typeof u;return r(n,f,!d),d?(i.has(u)||i.set(u,Ye(u,f,n,r,o,i)),i.get(u)):u},getOwnPropertyDescriptor:(e,i)=>(r(n,t,!0),o.add(e),Reflect.getOwnPropertyDescriptor(e,i)),has:(e,o)=>(r(n,t,!0),Reflect.has(e,o)),ownKeys:e=>(r(n,t,!0),o.add(e),Reflect.ownKeys(e))})}function Ze(e,t){if(!e||"object"!=typeof e)return e;const n=function(e){const t=Reflect.get(e,Ge);return t&&"object"==typeof t?t:void 0}(e);return n||(Array.isArray(e)?function(e,t){const n=tt(e,t);if(n)for(let t=0;t<e.length;t++)et(e,String(t),n)}(e,t):j(e)&&function(e,t){const n=tt(e,t);if(n)for(const t of Reflect.ownKeys(e))et(e,t,n)}(e,t),e)}function et(e,t,n){const r=Reflect.getOwnPropertyDescriptor(e,t);if(!r||!("value"in r))return;const o=Ze(r.value,n);o!==r.value&&(r.value=o,Reflect.defineProperty(e,t,r))}function tt(e,t){const n=t??new WeakSet;return n.has(e)?null:(n.add(e),n)}var nt=Object.freeze([]);function rt(){const e=new Map;return{buildProxySubscriptions(t,n,r,o){const i=new Set;for(const t of e)it(t[1],t[0],[],0,i,r);!1!==o?.(i)&&function(e,t,n){for(const n of e){const e=n.invocation?ut(n.path,n.invocation):at(n.path);t(n.store,e,n.path)}n&&function(e){const t=e.size;console.log(`[📡 ${t} ${Pe("Proxy Subscription",t)} 📡]:`,JSON.stringify(Array.from(e).map(e=>{const t="name"in(n=e.store)&&"string"==typeof n.name?n.name:"store";var n;const r=e.path.join(".");if(!e.invocation)return r?`$(${t}).${r}`:`$(${t})`;const o=e.invocation.args?.length??0;return`$(${t}).${r}${o?`(${o}_${Pe("arg",o)})`:"()"}`}),null,2))}(e)}(i,t,n)},reset(){e.clear()},trackPath(t,n,r,o){let i=e.get(t);i||(i={__proto__:null},e.set(t,i)),ot(i,n,0,r,o)}}}function ot(e,t,n,r,o){if(n===t.length)return r&&(e.isLeaf=!0),void(o&&function(e,t){const n=e.invocation;if(!n)return void(e.invocation=t);if(st(n,t))return;const r=e.extraInvocations;if(r){for(let e=0;e<r.length;e++)if(st(r[e],t))return;r.push(t)}else e.extraInvocations=[t]}(e,o));e.children||(e.children={__proto__:null});const i=t[n];let s=e.children?.[i];s||(s={__proto__:null},e.children[i]=s),ot(s,t,n+1,r,o)}function it(e,t,n,r,o,i=2){const s=e.children;if(!s)return void ct(e,t,n,o);const c=Object.keys(s),a=c.length;if(0!==a)if(e.isLeaf||r>=i&&a>1){ct(e,t,n,o);for(const e of c){const c=s[e];c.invocation&&it(c,t,[...n,e],r+1,o,i)}}else if(r<i&&a>1&&!e.isLeaf)for(const e of c)it(s[e],t,[...n,e],r+1,o,i);else{if(1===a){const e=c[0];return void it(s[e],t,[...n,e],r+1,o,i)}ct(e,t,n,o)}else ct(e,t,n,o)}function st(e,t){const n=e.args,r=t.args,o=n?.length??0;if(o!==(r?.length??0))return!1;if(!n||!r)return!0;for(let e=0;e<o;e++)if(!Object.is(n[e],r[e]))return!1;return!0}function ct(e,t,n,r){const o=e.isLeaf??!1,i=e.invocation;if(!i)return void r.add({store:t,path:n,isLeaf:o});r.add({store:t,path:n,invocation:i,isLeaf:o});const s=e.extraInvocations;if(s)for(let e=0;e<s.length;e++)r.add({store:t,path:n,invocation:s[e],isLeaf:o})}function at(e){return t=>lt(t,e)}function ut(e,t){const n=e.slice(0,-1),r=e[e.length-1];return e=>{const o=lt(e,n),i=o&&"object"==typeof o?Reflect.get(o,r):void 0;return"function"==typeof i?Reflect.apply(i,o,t.args??nt):void 0}}function lt(e,t){let n=e;for(const e of t){if(!n||"object"!=typeof n)return n;n=Reflect.get(n,e)}return n}var ft=Symbol(),dt=Object.freeze({equalityFn:Object.is,isDerivedStore:!0});function yt(e,t=Object.is){const{debounceOptions:n,debugMode:r,equalityFn:o,keepAlive:i,lockDependencies:s}="function"==typeof(f=t)?{debounceOptions:void 0,debugMode:!1,equalityFn:f,keepAlive:!1,lockDependencies:!1}:{debounceOptions:f.debounce,debugMode:(a&&f.debugMode)??!1,equalityFn:f.equalityFn??Object.is,keepAlive:f.keepAlive??!1,lockDependencies:f.lockDependencies??!1},c=String(pt+=1),u=new Set;var f;i&&u.add(gt);const d=new Set;let y,p,g=ft,h=!1,b=!0,m=!0,S=0,v=!1,w=null,O=ft;function q(e,t,n){return m&&u.size?t?(d.add(e.subscribe(t,z,n?{equalityFn:n,isDerivedStore:!0}:dt)),t(Z(e)?e.getSnapshot():e.getState())):(y||(y=new WeakMap),p||(p=rt()),Xe(e,y,p.trackPath)):(t??l)(Z(e)?e.getSnapshot():e.getState())}function j(e){for(const t of d)t(e);d.clear()}let F=!0;function _(){if(!b&&ht(g))return g;b=!1,m&&j(!0);const t=g,n=ht(t);g=function(t){F=!0;const n=g,i=e(t),s=p?Ze(i):i;return ht(n)&&o(n,s)?(r&&console.log("[🥷 Derive Complete 🥷]: No change detected"),F=!1,n):s}(q);const i=r&&(!n||"verbose"===r&&m);if(i){n?"verbose"===r&&console.log("[🌀 Rebuilding Subscriptions 🌀]: Created…"):console.log("[🌀 Initial Derive Complete 🌀]: Created…");const e=d.size;console.log(`[🎯 ${e} ${Pe("Selector Subscription",e)} 🎯]`)}return p&&m&&(p.buildProxySubscriptions((e,t)=>{d.add(e.subscribe(t,z,dt))},i),y=void 0,p.reset(),s&&(p=void 0)),F&&n&&function(e,t){const n=function(){const e=u.has(gt)?u.size-1:u.size;return S>0&&S<e}(),o=!S||n,i=n||null!==Je()||Ue()&&o;n&&Be(),r&&console.log(`[📻 Derive Complete 📻]: Notifying ${u.size} ${Pe("watcher",u.size)}`);for(const t of u){if("function"==typeof t||!t.isDerivedWatcher)continue;const n=t.selector(e);if(!t.equalityFn(t.currentSlice,n)){const e=t.currentSlice;t.currentSlice=n,t.listener(n,e)}}i?v||(v=!0,ht(O)||(O=t),Qe(c,I)):A(e,t)}(g,t),s&&(m=!1),g}function A(e,t){for(const n of u)if("function"==typeof n)n(e,t);else if(!n.isDerivedWatcher){const t=n.selector(e);if(!n.equalityFn(n.currentSlice,t)){const e=n.currentSlice;n.currentSlice=t,n.listener(t,e)}}}function I(){if(!u.size)return;if(b&&!S&&_(),!ht(g))return;const e=ht(O)?O:g;A(g,e),v=!1,O=ft}const C=n?be(T,"number"==typeof n?n:n.delay,"number"==typeof n?{leading:!1,maxWait:n,trailing:!0}:n):void 0,k=C??(()=>{h||(h=!0,queueMicrotask(T))});function T(){h=!1,u.size?b&&_():K()}function E(e){e||C&&b?queueMicrotask(()=>{u.size||K()}):K()}function M(){T(),w=null}function z(){if(!b){if(b=!0,!C){if(S){Be();const e=Je(),t=null===e?0:e+1;if(null!==w&&t<=w)return;return w=t,void function(e,t){if(!Re)return;const n=t<0?0:0|t,r=Ne.get(e);if(void 0===r){Ne.set(e,n);let t=Ve.get(n);return t||(t=new Set,Ve.set(n,t)),t.add(e),void(n<We&&(We=n))}if(n>r){const t=Ve.get(r);if(t&&(t.delete(e),0===t.size&&(Ve.delete(r),r===We))){We=1/0;for(const e of Ve.keys())e<We&&(We=e)}Ne.set(e,n);let o=Ve.get(n);o||(o=new Set,Ve.set(n,o)),o.add(e),n<We&&(We=n)}}(M,t)}if(Ue())return void(v||(v=!0,ht(g)&&(O=g),Qe(c,I)))}w=null,k()}}function D(){return b||!ht(g)?u.size>0?_():e(q):g}function K(e=!0){i&&e||(C?.cancel(),j(),u.clear(),S=0,p=void 0,y=void 0,m=!0,h=!1,b=!0,g=ft,v=!1,O=ft,w=null)}return{destroy:()=>K(!1),flushUpdates:function(){u.size&&(C?C.flush():b&&_())},getSnapshot:function(){if(!ht(g)){u.add(gt);const e=_();return u.delete(gt),e}return h&&T(),g},getState:D,subscribe:function(...e){if(1===e.length){const t=e[0];return u.add(t),1!==u.size||ht(g)||D(),()=>{u.delete(t),u.size||E(!1)}}const[t,n,r]=e,o=r?.equalityFn??Object.is,i=r?.isDerivedStore??!1,s={currentSlice:void 0,equalityFn:o,isDerivedWatcher:i,listener:n,selector:t};return u.add(s),s.currentSlice=t(D()),i&&(S+=1),r?.fireImmediately&&n(s.currentSlice,s.currentSlice),()=>{u.delete(s),i&&(S-=1),u.size||E(i)}},getInitialState:()=>{throw new Error("[createDerivedStore]: getInitialState() is not available on derived stores.")},setState:()=>{throw new Error("[createDerivedStore]: setState() is not available on derived stores.")}}}var pt=0;function gt(){}function ht(e){return e!==ft}var bt=class{constructor({disableAutoRefetching:e,initialEnabled:t}){this.count=0,this.enabled=!1,this.lastSubscriptionTime=null,this.fetchThrottleMs=null,this.onSubscribe=null,this.onLastUnsubscribe=null,this.enabled=t,e&&(this.fetchThrottleMs=$.seconds(5))}init({onSubscribe:e,onLastUnsubscribe:t}){this.onSubscribe=e,this.onLastUnsubscribe=t}get(){return{enabled:this.enabled,lastSubscriptionTime:this.lastSubscriptionTime,subscriptionCount:this.count}}setEnabled(e){this.enabled=e}subscribe(){const e=0===this.count,t=null!==this.fetchThrottleMs&&null!==this.lastSubscriptionTime&&!e&&Date.now()-this.lastSubscriptionTime<=this.fetchThrottleMs;return this.onSubscribe?.(this.enabled,e,t),this.count+=1,this.lastSubscriptionTime=Date.now(),e=>{const t=1===this.count;this.count=Math.max(this.count-1,0),t&&(this.onLastUnsubscribe?.(e),this.lastSubscriptionTime=null)}}},mt=new WeakMap,St=new WeakMap;function vt(e,t=wt,n=ue){return function(e,t,n){let r=St.get(e);r||(r=new Map,St.set(e,r));let o=r.get(t);o||(o=new Map,r.set(t,o));const i=o.get(n);if(i)return i;const[s,c,a]=qt(e,t,n),u=new Map,l=e=>new Proxy({__proto__:null},{get(t,n){if("value"===n){let t=c();const n=e.split(".");for(const e of n)e&&(t=t[e]);return t}const r="string"==typeof n?n:n.toString(),o=e?`${e}.${r}`:r,i=u.get(o);if(i)return i;const a=l(o);return mt.set(a,s),u.set(o,a),a},set(t,n,r){const o=e.split(".");return""===o[0]&&o.shift(),a(o,r),!0}}),f=l("");return s(()=>{}),mt.set(f,s),o.set(n,f),f}(e,t,n)}var wt=e=>e,Ot=(e,t,n)=>{if(!t.length)return n;const[r,...o]=t,i=e[r],s=Ot(i,o,n);if(ue(i,s))return e;const c=Array.isArray(e)?e.slice():{...e};return c[r]=s,c},qt=(e,t,n)=>{const r=new Set,o=Z(e);let i,s=t(o?e.getSnapshot():e.getState());return[c=>(r.size||(i=e.subscribe(t,e=>{s=e,r.forEach(e=>e())},{equalityFn:n,isDerivedStore:o})),r.add(c),()=>{r.delete(c),!r.size&&i&&(i(),i=void 0)}),()=>(r.size||(s=t(e.getState())),s),(n,r)=>{if(t!==wt)throw new Error("Cannot set a value with a selector");e.setState(e=>Ot(e,n,r),!0)}]};function jt(e){return mt.get(e)}var Ft={error:!0,lastFetchedAt:!0,queryCache:!0,queryKey:!0,status:!0,enabled:!1,fetch:!1,getCacheEntry:!1,getData:!1,getStatus:!1,isDataExpired:!1,isStale:!1,reset:!1},_t=Object.freeze({force:!0}),At=Object.freeze({once:!0}),It=Object.freeze({updateQueryKey:!0});function Ct(e,t,n,r){return r?Tt(r,n)?r:{...kt(e,t),...r}:kt(e,t)}function kt(e,t){const n=Object.assign({__proto__:null},t?.params);for(const t in e?.params){const r=e.params[t];r&&(n[t]=r.value)}return n}function Tt(e,t){if(!e)return!1;for(const n of t)if(!(n in e))return!1;return!0}function Et(e){return"function"==typeof e}function Mt(e){return!Et(e)}function zt(e,t){return n=>{const r={...n},o={__proto__:null};for(const e in r)q(r,e)&&e in Ft&&(Ft[e]&&(o[e]=r[e]),delete r[e]);return{...t?t(r):ve(r),...Dt(e,null,o)}}}function Dt(e,t,n){if(!n.queryCache)return n;const r=Date.now(),o=t??(e&&n.queryKey||null),i={__proto__:null};let s=!1;for(const e in n.queryCache){if(!q(n.queryCache,e))continue;const c=n.queryCache[e];c&&(r-(c.lastFetchedAt??c.errorInfo.lastFailedAt)<c.cacheTime||e===o)?!t&&c.errorInfo&&c.errorInfo.retryCount>0?(i[e]={...c,errorInfo:{...c.errorInfo,retryCount:0}},s=!0):i[e]=c:s=!0}return s?{...n,queryCache:i}:n}function Kt(){return Object.create(null)}function Pt(e,t,n){return new _(`[createQueryStore: ${e}]: ${t} failed`,n)}function xt(e){return function(...t){return!0===t[1]?e().setState(t[0],!0):e().setState(t[0])}}function Rt(e,t){const n=Ke(e,t);return S(n,n.getState,n.getInitialState,Object.is)}function $t(e,t=Object.is){const n=yt(e,t);return S(n,n.getSnapshot)}function Lt(e,t,n){const r=function(e,t,n){K();const r="function"==typeof t?t:Kt,o="object"==typeof t?t:n,i=function(e){return"string"==typeof e?.storageKey}(o)?o:void 0,s=x??(x=function(){const e={abortInterruptedFetches:!0,cacheTime:$.days(7),debugMode:!1,disableAutoRefetching:!1,keepPreviousData:!1,maxRetries:5,minStaleTime:!1,paramChangeThrottle:!1,retryDelay:L,staleTime:$.minutes(2),suppressStaleTimeWarning:!1},t=function(){if(C)return C}()?.queryStoreDefaults;return t?{...e,...t}:e}()),c=s.minStaleTime,{fetcher:l,onError:f,onFetched:d,setData:y,transform:p,abortInterruptedFetches:g=s.abortInterruptedFetches,cacheTime:h=s.cacheTime,debugMode:b=s.debugMode,disableAutoRefetching:m=s.disableAutoRefetching,disableCache:S=!1,enabled:v=!0,keepPreviousData:O=s.keepPreviousData,maxRetries:j=s.maxRetries,paramChangeThrottle:F=s.paramChangeThrottle,params:I,retryDelay:k=s.retryDelay,staleTime:T=s.staleTime,suppressStaleTimeWarning:E=s.suppressStaleTimeWarning}=e;let M="function"==typeof T?s.staleTime:T;a&&!1!==c&&!m&&!E&&M<c&&console.warn(`[createQueryStore${i?.storageKey?`: ${i.storageKey}`:""}] ❌ Stale times under ${c/1e3} seconds are not recommended. Provided staleTime: ${M/1e3} seconds`);const z=new Error("[createQueryStore: AbortError] Fetch interrupted"),D="function"==typeof h,P=a&&b,V=e.params?Object.keys(e.params):[];let H=null,W=null,U=null,J=[],B=!1,G=!1,X=null,Y=null,Z=null,ee=null,te=null;const ne={enabled:"function"!=typeof v&&v,error:null,lastFetchedAt:null,queryCache:{},queryKey:"",status:R.Idle},re=new bt({disableAutoRefetching:m,initialEnabled:ne.enabled});function oe(){X&&(Y=null,X.abort(),X=null)}function ie(t,n,o){const s=o.setState;function c(e){const t="function"==typeof e;if(t||void 0!==e.enabled){let n;const r=s(r=>{const o=t?e(r):e,i=void 0!==o.enabled?o.enabled:r.enabled;return i!==r.enabled&&(n=()=>function(e,t){e!==t&&te!==t&&(te=t,re.setEnabled(t),t?queueMicrotask(()=>u.fetch(void 0,It)):(Z||g)&&(g&&oe(),Z&&(clearTimeout(Z),Z=null)))}(r.enabled,i)),o});return n?.(),r}return s(e)}function a(e,t){if(m||t?.skipStoreUpdates)return;if(M<=0||M===1/0)return;Z&&(clearTimeout(Z),Z=null);const r=N(e),o=n(),i=(S?ee===r&&o.lastFetchedAt:o.queryCache[r]?.lastFetchedAt)||null,s=i?M-(Date.now()-i):M;Z=setTimeout(()=>{const t=re.get();t.enabled&&t.subscriptionCount>0&&u.fetch(e,_t,!0)},s)}o.setState=c,re.init({onSubscribe:(r,o,i)=>{if(W||H||!I&&"function"!=typeof e.enabled&&"function"!=typeof e.staleTime){if(r)if(o){const e=kt(H,W),r=N(e),o=n();o.queryKey!==r&&t({queryKey:r}),o.isStale()?u.fetch(e,void 0,!0):a(e,void 0)}else m&&!i&&u.fetch(void 0,void 0,!0)}else B=!0},onLastUnsubscribe:e=>{Z&&(clearTimeout(Z),Z=null),g&&!e&&oe()}});const u={...r(c,n,o),...ne,async fetch(e,r,o=!1){const s=re.get();if(!r?.force&&!r?.skipStoreUpdates&&!s.enabled)return null;const b=n(),m=b.error,v=b.queryKey,q=b.status===R.Loading,F=Ct(H,W,V,e),I=N(F);if(q&&Y?.promise&&Y.key===I)return P&&console.log("[🔄 Using Active Fetch 🔄] for params:",JSON.stringify(F)),Y.promise;const C=r?.staleTime??M,T=!!r?.skipStoreUpdates,E="boolean"==typeof r?.updateQueryKey?r.updateQueryKey:!!o&&O,K=(o||v===I||E)&&!T;if(g&&K&&oe(),!r?.force){const e=b.lastFetchedAt,n=b.queryCache[I],o=n?.lastFetchedAt,i=n?.errorInfo,c=i&&i.retryCount>=j,u=(S?ee===I&&e:o)||null;if(u&&!(Date.now()-u>=C)&&(!i||c||T))return K&&!Z&&s.subscriptionCount>0&&0!==M&&M!==1/0&&a(F,r),E&&t(e=>e.queryKey!==I?{queryKey:I}:e),P&&console.log("[💾 Returning Cached Data 💾] for params:",JSON.stringify(F)),n?.data??null}K&&(Z&&(clearTimeout(Z),Z=null),!m&&q||t({error:null,status:R.Loading}),Y={key:I});const x=r?.cacheTime??(D?h(F):h);async function $(){const s=i?.storageKey||I;try{P&&(o||!e||Tt(e,V)?console.log("[🔄 Fetching 🔄] for params:",JSON.stringify(F)):console.log("[🔄 Fetching with Partial Params 🔄]\n","- Provided params:",`${JSON.stringify(e)}\n`,"- Filled in params:",`${JSON.stringify(Object.fromEntries(Object.keys(F).filter(t=>!(t in e)).map(e=>[e,F[e]])))}`));const n=await(g&&K?async function(e){const t=new AbortController;X=t;try{return await new Promise((n,r)=>{t.signal.addEventListener("abort",()=>r(z),At),Promise.resolve(l(e,t)).then(n,r)})}finally{X===t&&(X=null)}}(F):l(F,null)),i=Date.now();let f;P&&console.log("[✅ Fetch Successful ✅] for params:",JSON.stringify(F));try{f=function(e,t,n){return n?n(e,t):e}(n,F,p)}catch(e){throw Pt(s,"transform",e)}if(T)return P&&console.log("[🥷 Successful Parallel Fetch 🥷] for params:",JSON.stringify(F)),"withCache"===r.skipStoreUpdates&&t(e=>{if(!y)return S?e:{queryCache:{...e.queryCache,[I]:{cacheTime:x,data:f,errorInfo:null,lastFetchedAt:i}}};let t=e;const n=t.queryCache[I];try{y({data:f,params:F,queryKey:I,set:e=>{t="function"==typeof e?{...t,...e(t)}:{...t,...e}}})}catch(e){throw Pt(s,"setData",e)}return!S&&Object.is(n,t.queryCache[I])&&(t={...t,queryCache:{...t.queryCache,[I]:{cacheTime:x,data:null,errorInfo:null,lastFetchedAt:i}}}),t}),f;if((y?c:t)(e=>{let t={...e,error:null,lastFetchedAt:i,queryKey:E?I:e.queryKey,status:R.Success};if(y||S){if(y){P&&console.log("[💾 Setting Data 💾] for params:",JSON.stringify(F));const e=t.queryCache[I];try{y({data:f,params:F,queryKey:I,set:e=>{t="function"==typeof e?{...t,...e(t)}:{...t,...e}}})}catch(e){throw Pt(s,"setData",e)}!S&&Object.is(e,t.queryCache[I])&&(t.queryCache={...t.queryCache,[I]:{cacheTime:x,data:null,errorInfo:null,lastFetchedAt:i}})}}else P&&console.log("[💾 Setting Cache 💾] for params:",JSON.stringify(F),"| Has previous data?:",!!t.queryCache[I]?.data),t.queryCache={...t.queryCache,[I]:{cacheTime:x,data:f,errorInfo:null,lastFetchedAt:i}};return S||h===1/0?t:Dt(O,I,t)}),K&&(ee=I,a(F,r)),d)try{d({data:f,fetch:u.fetch,params:F,set:c})}catch(e){w.error(Pt(s,"onFetched callback",e))}return f??null}catch(i){if(i===z)return P&&console.log("[❌ Fetch Aborted ❌] for params:",JSON.stringify(F)),null;const c=!o&&!0===r?.throwOnError,a=A(i);if(a instanceof _&&w.error(a),!K){if(c)throw a;return null}const l=S?void 0:n().queryCache[I],d=l?.errorInfo?.retryCount??0,y=d+1;try{f?.(a,d)}catch(e){w.error(Pt(s,"onError callback",e))}if(d<j){if(re.get().subscriptionCount>0){const t="function"==typeof k?k(y,a):k;t!==1/0&&(Z&&clearTimeout(Z),Z=setTimeout(()=>{const t=re.get();t.enabled&&t.subscriptionCount>0&&u.fetch(e,_t,!0)},t))}t(e=>({error:a,queryCache:{...e.queryCache,[I]:{cacheTime:l?.cacheTime??x,data:l?.data??null,lastFetchedAt:l?.lastFetchedAt??null,errorInfo:{error:a,lastFailedAt:Date.now(),retryCount:y}}},queryKey:E?I:e.queryKey,status:R.Error}))}else t(e=>({error:a,queryCache:{...e.queryCache,[I]:{cacheTime:l?.cacheTime??x,data:l?.data??null,lastFetchedAt:l?.lastFetchedAt??null,errorInfo:{error:a,lastFailedAt:Date.now(),retryCount:j}}},queryKey:E?I:e.queryKey,status:R.Error}));if(c)throw a;return null}finally{K&&(Y=null)}}return K?(Y={key:I,promise:$()}).promise:$()},getCacheEntry(e){if(S)return null;const t=n(),r=e?"string"==typeof e?e:N(Ct(H,W,V,e)):t.queryKey;return t.queryCache[r]??null},getData(e){if(S)return null;const t=n().getCacheEntry(e);return t&&null!==t.data?O?t.data:t.lastFetchedAt&&Date.now()-t.lastFetchedAt>=t.cacheTime?null:t.data:null},getStatus:function(e){const t=n(),r=t.status;switch(e){case"isIdle":return r===R.Idle;case"isLoading":return r===R.Loading;case"isError":case"isInitialLoad":case"isSuccess":case void 0:{const n=t.queryKey,o=t.queryCache[n],i=S?r===R.Error:"number"==typeof o?.errorInfo?.lastFailedAt;if("isError"===e)return i;const s=null!==((S?ee===n&&t.lastFetchedAt:o?.lastFetchedAt)||null),c=!s&&!i&&t.enabled;if("isInitialLoad"===e)return c;const a=s&&!i;return"isSuccess"===e?a:{isError:i,isIdle:r===R.Idle,isLoading:r===R.Loading,isInitialLoad:c,isSuccess:a}}}},isDataExpired(e){const t=n(),r=t.queryCache[t.queryKey],o=t.queryKey,i=t.lastFetchedAt,s=(S?ee===o&&i:r?.lastFetchedAt)||null;if(!s)return!0;const c=e??r?.cacheTime;return void 0===c||Date.now()-s>=c},isStale(e){const t=n(),r=t.queryKey,o=(S?ee===r&&t.lastFetchedAt:t.queryCache[r]?.lastFetchedAt)||null;if(!o)return!0;const i=e??M;return Date.now()-o>=i},reset(e=!1){for(const e of J)e();J=[],H=null,W=null,U=null,oe(),Z&&(clearTimeout(Z),Z=null),Y=null,ee=null,e&&t(ne)}},b=o.subscribe;return o.subscribe=(...e)=>{const t=G?()=>{}:re.subscribe(),n=1===e.length?b(e[0]):b(e[0],e[1],e[2]);return e=>{t(e),n()}},u}const se=i?.storageKey?Ke(ie,(ce=i,void 0===(ae={partialize:zt(O,i.partialize)})?Object.assign({__proto__:null},ce):Object.assign({__proto__:null},ce,ae))):o&&!("storageKey"in o)?Ke(ie,o):Ke(ie);var ce,ae;const le=se.getState(),fe=le.error,de=le.enabled,ye=le.queryKey,pe=le.fetch;let ge;if(ye&&!fe&&(ee=ye),G=!0,I||"function"==typeof e.enabled){const{directValues:e,enabledAttachVal:t,enabledDirectValue:n,attachVals:r}=function(e,t,n){const r={__proto__:null},o={__proto__:null},i={__proto__:null};for(const e in t){if(!q(t,e))continue;const s=t[e];if(Et(s)){const t=s(vt,n);r[e]=t,i[e]=t.value}else Mt(s)&&(o[e]=s,i[e]=s)}let s,c=null,a=null;if(Et(e)){const t=e(vt,n);s=t.value,c=t}else s=e,a=e;return{attachVals:r,directValues:o,enabledAttachVal:c,enabledDirectValue:a,resolvedEnabled:s,resolvedParams:i}}(v,I,se);H={enabled:t,params:r},W={enabled:n,params:e}}"function"==typeof e.staleTime&&(U=e.staleTime(vt,se),M=U.value);const he=Object.freeze({updateQueryKey:O}),me=function(){let e,t=!1;return function(...n){e=n,t||(t=!0,queueMicrotask(()=>{t=!1,(e=>{pe(e??kt(H,W),he)})(...e)}))}}();function Se(){let e;if(!O){e=kt(H,W);const t=N(e);se.setState({queryKey:t})}me(e)}const ve=u||!F?Se:be(Se,"number"==typeof F?F:F.delay,"number"==typeof F?{leading:!1,maxWait:F,trailing:!0}:F);for(const e in H?.params){const t=H.params[e];if(!t)continue;const n=jt(t);if(P&&console.log("[🌀 Param Subscription 🌀] Subscribed to param:",e),n){let r=t.value;const o=n(()=>{const n=t.value;ue(r,n)||(P&&console.log("[🌀 Param Change 🌀] -",e,"- [Old]:",`${r?.toString()},`,"[New]:",n?.toString()),r=n,ve())});J.push(o)}}if(U){const e=jt(U);if(e){const t=U;let n=t.value;P&&console.log("[🌀 StaleTime Subscription 🌀] Initial value:",n);const r=e(()=>{const e=t.value;e!==n&&(P&&console.log("[🌀 StaleTime Change 🌀] - [Old]:",`${n},`,"[New]:",e),n=e,M=e,pe())});J.push(r)}}if(H?.enabled){const e=H.enabled,t=jt(e);if(t){let n=e.value;de!==n&&((ge??(ge={})).enabled=n),n&&re.setEnabled(n),P&&console.log("[🌀 Enabled Subscription 🌀] Initial value:",n);const r=t(()=>{const t=e.value;t!==n&&(P&&console.log("[🌀 Enabled Change 🌀] - [Old]:",`${n},`,"[New]:",t),n=t,se.setState({enabled:t}))});J.push(r)}}else de!==ne.enabled&&((ge??(ge={})).enabled=ne.enabled);const we=N(kt(H,W));return we!==ye&&((ge??(ge={})).queryKey=we),ge&&se.setState(ge),G=!1,B&&queueMicrotask(ve),Oe=se,qe=Q.QueryStore,Object.assign(Oe,{[qe]:!0});var Oe,qe}(e,t,n);return S(r,r.getState,r.getInitialState,Object.is)}function Nt(e){return N(e)}function Vt(e){return function(e){return JSON.parse(e)}(e)}function Ht(e,t,n){const r=function(e,t,n){const r="function"==typeof t,o=r?t:void 0,i=r?n:t,s=new Set,c=yt(e,{debugMode:i?.debugMode??!1,equalityFn:function(e,t){const n=Object.is(e,t);return n||(function(e,t){for(const n of s){n.unsubscribe();const r=n.args;if(1===r.length){const o=r[0],i=e.getState(),s=t.getState(),c=t.subscribe(o);n.unsubscribe=c,Object.is(s,i)||o(s,i);continue}const o=r[0],i=r[1];let s=r[2];s?.fireImmediately&&(s={...s,fireImmediately:!1});const c=o(e.getState()),a=o(t.getState()),u=t.subscribe(o,i,s);n.unsubscribe=u,(s?.equalityFn??Object.is)(c,a)||i(a,c)}}(e,t),G(e)),n},keepAlive:!0,lockDependencies:i?.lockDependencies??!0}),a=Object.assign({[Q.VirtualStore]:!0,destroy:c.destroy,getInitialState:()=>c.getState().getInitialState(),getState:()=>c.getState().getState(),persist:(u=c.getState,{clearStorage:()=>u().persist?.clearStorage(),getOptions:()=>u().persist?.getOptions()??{},hasHydrated:()=>u().persist?.hasHydrated()??!0,hydrationPromise:()=>u().persist?.hydrationPromise?.()??Promise.resolve(),onFinishHydration:e=>u().persist?.onFinishHydration(e)??d,onHydrate:e=>u().persist?.onHydrate(e)??d,rehydrate:()=>u().persist?.rehydrate(),setOptions:e=>u().persist?.setOptions(e)}),setState:xt(c.getState),subscribe:function(...e){const t={args:e,unsubscribe:1===e.length?c.getState().subscribe(e[0]):c.getState().subscribe(e[0],e[1],e[2])};return s.add(t),()=>{t.unsubscribe(),s.delete(t)}}},o?.(c.getState));var u;return a}(e,t,n);return S(r,r.getState,r.getInitialState)}var Wt=Symbol(),Ut=Object.freeze({debugMode:!1,enabled:!0,equalityFn:Object.is,fireImmediately:!1});function Jt(n,r,o,i=Ut){const s=function(){const e=t(Wt);return e.current===Wt&&(e.current=function(e,t,n){return{selector:e,react:t,isActive:!1,options:Gt(n),resubscribe:()=>{},unsubscribe:()=>{}}}(r,o,i)),e}(),c=function(e){return"function"==typeof e?Ut.enabled:e?.enabled??Ut.enabled}(i);return s.current.react=o,s.current.selector=r,function(e,t){"function"==typeof t?e.current.options.equalityFn=t:t&&(e.current.options=t??Ut)}(s,i),e(()=>{if(c)return Qt(n,s),()=>function(e){e.current.options.debugMode&&console.log("[🗑️ useListen 🗑️] Detaching listener"),e.current.resubscribe=()=>{},e.current.unsubscribe(),e.current.unsubscribe=()=>{},e.current.isActive=!1}(s)},[c,n]),s}var Bt=Object.freeze({fireImmediately:!1,forceResubscribe:!1});function Qt(e,t,n=Bt){if(t.current.isActive){if(!n?.forceResubscribe)return;t.current.unsubscribe()}t.current.options.debugMode&&console.log("[📡 useListen 📡] Attaching listener"),t.current.isActive=!0,t.current.resubscribe=(n=Bt)=>Qt(e,t,n);const r=e.subscribe(e=>t.current.selector(e),(e,n)=>t.current.react(e,n,()=>{r(),t.current.isActive=!1}),n.fireImmediately?{...t.current.options,fireImmediately:!0}:t.current.options);t.current.unsubscribe=()=>{t.current.isActive&&(r(),t.current.isActive=!1)}}function Gt(e){return"function"==typeof e?{equalityFn:e}:e??Ut}var Xt=Symbol();function Yt(e){const n=t(Xt);return n.current===Xt&&(n.current=e()),n.current}export{R as QueryStatuses,_ as StoresError,W as applyStateUpdate,z as configureStores,Rt as createBaseStore,$t as createDerivedStore,Lt as createQueryStore,oe as createStoreActions,Ht as createVirtualStore,ce as deepEqual,L as defaultRetryDelay,G as destroyStore,X as destroyStores,Nt as getQueryKey,Y as getStoreName,Z as hasGetSnapshot,l as identity,te as isDerivedStore,ne as isPersistedStore,ee as isQueryStore,re as isVirtualStore,f as nullObject,Vt as parseQueryKey,J as replacer,B as reviver,ae as shallowEqual,$ as time,Jt as useListen,Yt as useStableValue};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { StoreApi } from '../store/types';
|
|
2
|
+
import type { EqualityFn, Selector } from '../types/subscribe';
|
|
2
3
|
type NestedAttachValue<T> = T extends object ? {
|
|
3
4
|
readonly [K in keyof T]: AttachValue<T[K]>;
|
|
4
5
|
} : Record<string, never>;
|
|
@@ -6,8 +7,8 @@ export type AttachValue<T> = {
|
|
|
6
7
|
readonly value: T;
|
|
7
8
|
} & NestedAttachValue<T>;
|
|
8
9
|
export type SignalFunction = {
|
|
9
|
-
<T>(store:
|
|
10
|
-
<T, S>(store:
|
|
10
|
+
<T>(store: StoreApi<T>): AttachValue<T>;
|
|
11
|
+
<T, S>(store: StoreApi<T>, selector: Selector<T, S>, equalityFn?: EqualityFn<S>): AttachValue<S>;
|
|
11
12
|
};
|
|
12
13
|
export {};
|
|
13
14
|
//# sourceMappingURL=signalTypes.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { AttachValue, SignalFunction } from './signalTypes';
|
|
2
|
-
import {
|
|
1
|
+
import type { AttachValue, SignalFunction } from './signalTypes';
|
|
2
|
+
import type { StoreApi } from '../store/types';
|
|
3
|
+
import type { DebounceOptions, SetPartial, Store } from '../types';
|
|
3
4
|
/**
|
|
4
5
|
* Helper type that represents the store returned by `createQueryStore()`.
|
|
5
6
|
*/
|
|
@@ -172,7 +173,7 @@ export type QueryStoreInternalState<TData, TParams extends Record<string, unknow
|
|
|
172
173
|
* Pass a status key to avoid building the full status object.
|
|
173
174
|
* @example
|
|
174
175
|
* ```ts
|
|
175
|
-
* const isInitialLoad =
|
|
176
|
+
* const isInitialLoad = myQueryStore.getState().getStatus('isInitialLoad');
|
|
176
177
|
* ```
|
|
177
178
|
* @returns The requested status, or the full status object if no key is provided.
|
|
178
179
|
*/
|
|
@@ -341,7 +342,7 @@ export type QueryStoreParams<TParams extends Record<string, unknown>, TData, S e
|
|
|
341
342
|
* - A static value (e.g. `string`, `number`).
|
|
342
343
|
* - A function that returns an `AttachValue<T>` when given a `SignalFunction`.
|
|
343
344
|
*/
|
|
344
|
-
export type ReactiveParam<T, TParams extends Record<string, unknown>, S extends QueryStoreState<TData, TParams>, TData> = T | (($: SignalFunction, store:
|
|
345
|
+
export type ReactiveParam<T, TParams extends Record<string, unknown>, S extends QueryStoreState<TData, TParams>, TData> = T | (($: SignalFunction, store: StoreApi<S>) => AttachValue<T>);
|
|
345
346
|
export type AttachValueParams<TParams extends Record<string, unknown>> = Partial<Record<keyof TParams, AttachValue<TParams[Extract<keyof TParams, string>]>>>;
|
|
346
347
|
/**
|
|
347
348
|
* The result of resolving reactive and static parameter values.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { EqualityFn, SubscribeOverloads, UseStoreCallSignatures } from '../types';
|
|
2
|
+
export declare function attachStoreHook<State, Store extends {
|
|
3
|
+
subscribe: SubscribeOverloads<State>;
|
|
4
|
+
}>(store: Store, getSnapshot: () => State, getServerSnapshot?: () => State, defaultEqualityFn?: EqualityFn): UseStoreCallSignatures<State> & Store;
|
|
5
|
+
//# sourceMappingURL=attachStoreHook.react.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { EqualityFn, SubscribeOverloads } from '../types';
|
|
2
|
+
import type { UseStoreCallSignatures } from '../types/useStoreCallSignatures.vanilla';
|
|
3
|
+
export declare function attachStoreHook<State, Store extends {
|
|
4
|
+
subscribe: SubscribeOverloads<State>;
|
|
5
|
+
}>(store: Store, _getSnapshot: () => State, _getServerSnapshot?: () => State, _defaultEqualityFn?: EqualityFn): UseStoreCallSignatures<State> & Store;
|
|
6
|
+
//# sourceMappingURL=attachStoreHook.vanilla.d.ts.map
|