@storesjs/stores 0.10.0 → 0.11.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/dist/createBaseStore.d.ts +2 -2
- package/dist/createQueryStore.d.ts +7 -13
- package/dist/internal/derivedStore/deriveProxy.d.ts +2 -2
- package/dist/internal/queryStore/queryParams.d.ts +18 -0
- package/dist/internal/runtime.d.ts +0 -1
- package/dist/internal/types/internalSubscribeTypes.d.ts +16 -0
- package/dist/native/index.js +1 -1
- package/dist/native/index.mjs +1 -1
- package/dist/queryStore/classes/SubscriptionManager.d.ts +3 -31
- package/dist/queryStore/queryKey.d.ts +9 -2
- package/dist/queryStore/queryParam.d.ts +37 -0
- package/dist/queryStore/types.d.ts +10 -52
- package/dist/{vanilla/internal/derivedStore → store}/cascadeScheduler.d.ts +13 -5
- package/dist/types/subscribe.d.ts +4 -5
- package/dist/types.d.ts +10 -8
- package/dist/utils/createMicrotaskScheduler.d.ts +2 -1
- package/dist/vanilla/createBaseStore.d.ts +2 -2
- package/dist/vanilla/createQueryStore.d.ts +7 -13
- package/dist/vanilla/index.js +1 -1
- package/dist/vanilla/index.mjs +1 -1
- package/dist/vanilla/internal/derivedStore/deriveProxy.d.ts +2 -2
- package/dist/vanilla/internal/queryStore/queryParams.d.ts +17 -0
- package/dist/vanilla/internal/runtime.d.ts +0 -1
- package/dist/vanilla/internal/types/internalSubscribeTypes.d.ts +15 -0
- package/dist/vanilla/queryStore/classes/SubscriptionManager.d.ts +3 -31
- package/dist/vanilla/queryStore/queryKey.d.ts +9 -2
- package/dist/vanilla/queryStore/queryParam.d.ts +36 -0
- package/dist/vanilla/queryStore/types.d.ts +10 -52
- package/dist/{internal/derivedStore → vanilla/store}/cascadeScheduler.d.ts +12 -6
- package/dist/vanilla/types/subscribe.d.ts +4 -5
- package/dist/vanilla/types.d.ts +10 -8
- package/dist/vanilla/utils/createMicrotaskScheduler.d.ts +2 -1
- package/dist/web/chrome.js +1 -1
- package/dist/web/chrome.mjs +1 -1
- package/dist/web/chunk-FENSEQ3V.mjs +1 -0
- package/dist/web/chunk-FPYZVFBM.mjs +1 -0
- package/dist/web/chunk-PLDNKWGX.mjs +1 -0
- package/dist/web/index.js +1 -1
- package/dist/web/index.mjs +1 -1
- package/dist/web/internal/runtime.js +1 -1
- package/dist/web/internal/runtime.mjs +1 -1
- package/package.json +1 -1
- package/dist/internal/signal.d.ts +0 -12
- package/dist/queryStore/signalTypes.d.ts +0 -14
- package/dist/vanilla/internal/signal.d.ts +0 -11
- package/dist/vanilla/queryStore/signalTypes.d.ts +0 -13
- package/dist/web/chunk-QJLWBD7M.mjs +0 -1
- package/dist/web/chunk-V4LHP7LR.mjs +0 -1
|
@@ -11,14 +11,14 @@ export declare function createBaseStore<S>(createState: StateCreator<S>): Store<
|
|
|
11
11
|
* @param options - The configuration options for persistence and sync.
|
|
12
12
|
* @returns A store with the specified state and persistence.
|
|
13
13
|
*/
|
|
14
|
-
export declare function createBaseStore<S, PersistedState extends Partial<S> = Partial<S>, PersistReturn extends void = void>(createState: StateCreator<S>, options: BaseStoreOptions<S, PersistedState, PersistReturn>): Store<S, PersistedState, PersistReturn
|
|
14
|
+
export declare function createBaseStore<S, PersistedState extends Partial<S> = Partial<S>, PersistReturn extends void = void>(createState: StateCreator<S>, options: BaseStoreOptions<S, PersistedState, PersistReturn>): Store<S, PersistedState, PersistReturn>;
|
|
15
15
|
/**
|
|
16
16
|
* Creates a base store with async persistence.
|
|
17
17
|
* @param createState - The state creator function for the base store.
|
|
18
18
|
* @param options - The configuration options for persistence and sync.
|
|
19
19
|
* @returns A store with the specified state and persistence.
|
|
20
20
|
*/
|
|
21
|
-
export declare function createBaseStore<S, PersistedState extends Partial<S> = Partial<S>, PersistReturn extends Promise<void> = Promise<void>>(createState: StateCreator<S>, options: BaseStoreOptions<S, PersistedState, PersistReturn>): Store<S, PersistedState, PersistReturn
|
|
21
|
+
export declare function createBaseStore<S, PersistedState extends Partial<S> = Partial<S>, PersistReturn extends Promise<void> = Promise<void>>(createState: StateCreator<S>, options: BaseStoreOptions<S, PersistedState, PersistReturn>): Store<S, PersistedState, PersistReturn>;
|
|
22
22
|
/**
|
|
23
23
|
* Creates a base store with optional persistence.
|
|
24
24
|
* @param createState - The state creator function for the base store.
|
|
@@ -2,6 +2,9 @@ import { defaultRetryDelay } from './internal/runtime';
|
|
|
2
2
|
import type { QueryStoreConfig, QueryStoreState } from './queryStore/types';
|
|
3
3
|
import type { BaseStoreOptions, OptionallyPersistedStore, PersistedStore, StateCreator, Store } from './types';
|
|
4
4
|
export { defaultRetryDelay };
|
|
5
|
+
export { getQueryKey, parseQueryKey } from './queryStore/queryKey';
|
|
6
|
+
export { queryParam } from './queryStore/queryParam';
|
|
7
|
+
export type { QueryParam, QueryParamConfig, QueryParamKey, ReactiveParam } from './queryStore/queryParam';
|
|
5
8
|
/**
|
|
6
9
|
* Creates a persisted, query-enabled store with data fetching capabilities (sync storage).
|
|
7
10
|
*
|
|
@@ -10,7 +13,7 @@ export { defaultRetryDelay };
|
|
|
10
13
|
* @template TData - The transformed data type, if applicable (defaults to `TQueryFnData`)
|
|
11
14
|
* @template PersistedState - The persisted state type, if a stricter type than `Partial<CustomState>` is desired
|
|
12
15
|
*/
|
|
13
|
-
export declare function createQueryStore<TQueryFnData, TParams extends Record<string, unknown> = Record<string, never>, TData = TQueryFnData, PersistedState extends Partial<QueryStoreState<TData, TParams>> = Partial<QueryStoreState<TData, TParams>>, PersistReturn extends void = void>(config: QueryStoreConfig<TQueryFnData, TParams, TData>, options: BaseStoreOptions<QueryStoreState<TData, TParams>, PersistedState, PersistReturn>): PersistedStore<QueryStoreState<TData, TParams>, PersistedState, PersistReturn
|
|
16
|
+
export declare function createQueryStore<TQueryFnData, TParams extends Record<string, unknown> = Record<string, never>, TData = TQueryFnData, PersistedState extends Partial<QueryStoreState<TData, TParams>> = Partial<QueryStoreState<TData, TParams>>, PersistReturn extends void = void>(config: QueryStoreConfig<TQueryFnData, TParams, TData>, options: BaseStoreOptions<QueryStoreState<TData, TParams>, PersistedState, PersistReturn>): PersistedStore<QueryStoreState<TData, TParams>, PersistedState, PersistReturn>;
|
|
14
17
|
/**
|
|
15
18
|
* Creates a persisted, query-enabled store with data fetching capabilities (async storage).
|
|
16
19
|
*
|
|
@@ -19,7 +22,7 @@ export declare function createQueryStore<TQueryFnData, TParams extends Record<st
|
|
|
19
22
|
* @template TData - The transformed data type, if applicable (defaults to `TQueryFnData`)
|
|
20
23
|
* @template PersistedState - The persisted state type, if a stricter type than `Partial<CustomState>` is desired
|
|
21
24
|
*/
|
|
22
|
-
export declare function createQueryStore<TQueryFnData, TParams extends Record<string, unknown> = Record<string, never>, TData = TQueryFnData, PersistedState extends Partial<QueryStoreState<TData, TParams>> = Partial<QueryStoreState<TData, TParams>>, PersistReturn extends Promise<void> = Promise<void>>(config: QueryStoreConfig<TQueryFnData, TParams, TData>, options: BaseStoreOptions<QueryStoreState<TData, TParams>, PersistedState, PersistReturn>): PersistedStore<QueryStoreState<TData, TParams>, PersistedState, PersistReturn
|
|
25
|
+
export declare function createQueryStore<TQueryFnData, TParams extends Record<string, unknown> = Record<string, never>, TData = TQueryFnData, PersistedState extends Partial<QueryStoreState<TData, TParams>> = Partial<QueryStoreState<TData, TParams>>, PersistReturn extends Promise<void> = Promise<void>>(config: QueryStoreConfig<TQueryFnData, TParams, TData>, options: BaseStoreOptions<QueryStoreState<TData, TParams>, PersistedState, PersistReturn>): PersistedStore<QueryStoreState<TData, TParams>, PersistedState, PersistReturn>;
|
|
23
26
|
/**
|
|
24
27
|
* Creates a persisted, query-enabled store with data fetching capabilities (sync storage).
|
|
25
28
|
*
|
|
@@ -29,7 +32,7 @@ export declare function createQueryStore<TQueryFnData, TParams extends Record<st
|
|
|
29
32
|
* @template TData - The transformed data type, if applicable (defaults to `TQueryFnData`)
|
|
30
33
|
* @template PersistedState - The persisted state type, if a stricter type than `Partial<CustomState>` is desired
|
|
31
34
|
*/
|
|
32
|
-
export declare function createQueryStore<TQueryFnData, TParams extends Record<string, unknown> = Record<string, never>, CustomState = unknown, TData = TQueryFnData, PersistedState extends Partial<QueryStoreState<TData, TParams, CustomState>> = Partial<QueryStoreState<TData, TParams, CustomState>>, PersistReturn extends void = void>(config: QueryStoreConfig<TQueryFnData, TParams, TData, CustomState>, stateCreator: StateCreator<QueryStoreState<TData, TParams, CustomState>, CustomState>, options: BaseStoreOptions<QueryStoreState<TData, TParams, CustomState>, PersistedState, PersistReturn>): PersistedStore<QueryStoreState<TData, TParams, CustomState>, PersistedState, PersistReturn
|
|
35
|
+
export declare function createQueryStore<TQueryFnData, TParams extends Record<string, unknown> = Record<string, never>, CustomState = unknown, TData = TQueryFnData, PersistedState extends Partial<QueryStoreState<TData, TParams, CustomState>> = Partial<QueryStoreState<TData, TParams, CustomState>>, PersistReturn extends void = void>(config: QueryStoreConfig<TQueryFnData, TParams, TData, CustomState>, stateCreator: StateCreator<QueryStoreState<TData, TParams, CustomState>, CustomState>, options: BaseStoreOptions<QueryStoreState<TData, TParams, CustomState>, PersistedState, PersistReturn>): PersistedStore<QueryStoreState<TData, TParams, CustomState>, PersistedState, PersistReturn>;
|
|
33
36
|
/**
|
|
34
37
|
* Creates a persisted, query-enabled store with data fetching capabilities (async storage).
|
|
35
38
|
*
|
|
@@ -39,7 +42,7 @@ export declare function createQueryStore<TQueryFnData, TParams extends Record<st
|
|
|
39
42
|
* @template TData - The transformed data type, if applicable (defaults to `TQueryFnData`)
|
|
40
43
|
* @template PersistedState - The persisted state type, if a stricter type than `Partial<CustomState>` is desired
|
|
41
44
|
*/
|
|
42
|
-
export declare function createQueryStore<TQueryFnData, TParams extends Record<string, unknown> = Record<string, never>, CustomState = unknown, TData = TQueryFnData, PersistedState extends Partial<QueryStoreState<TData, TParams, CustomState>> = Partial<QueryStoreState<TData, TParams, CustomState>>, PersistReturn extends Promise<void> = Promise<void>>(config: QueryStoreConfig<TQueryFnData, TParams, TData, CustomState>, stateCreator: StateCreator<QueryStoreState<TData, TParams, CustomState>, CustomState>, options: BaseStoreOptions<QueryStoreState<TData, TParams, CustomState>, PersistedState, PersistReturn>): PersistedStore<QueryStoreState<TData, TParams, CustomState>, PersistedState, PersistReturn
|
|
45
|
+
export declare function createQueryStore<TQueryFnData, TParams extends Record<string, unknown> = Record<string, never>, CustomState = unknown, TData = TQueryFnData, PersistedState extends Partial<QueryStoreState<TData, TParams, CustomState>> = Partial<QueryStoreState<TData, TParams, CustomState>>, PersistReturn extends Promise<void> = Promise<void>>(config: QueryStoreConfig<TQueryFnData, TParams, TData, CustomState>, stateCreator: StateCreator<QueryStoreState<TData, TParams, CustomState>, CustomState>, options: BaseStoreOptions<QueryStoreState<TData, TParams, CustomState>, PersistedState, PersistReturn>): PersistedStore<QueryStoreState<TData, TParams, CustomState>, PersistedState, PersistReturn>;
|
|
43
46
|
/**
|
|
44
47
|
* Creates a query-enabled store with data fetching capabilities.
|
|
45
48
|
*
|
|
@@ -105,13 +108,4 @@ export declare function createQueryStore<TQueryFnData, TParams extends Record<st
|
|
|
105
108
|
* @template PersistedState - The persisted state type, if a stricter type than `Partial<CustomState>` is desired
|
|
106
109
|
*/
|
|
107
110
|
export declare function createQueryStore<TQueryFnData, TParams extends Record<string, unknown> = Record<string, never>, TData = TQueryFnData, PersistedState extends Partial<QueryStoreState<TData, TParams>> = Partial<QueryStoreState<TData, TParams>>, PersistReturn extends Promise<void> = Promise<void>>(config: QueryStoreConfig<TQueryFnData, TParams, TData>, options: BaseStoreOptions<QueryStoreState<TData, TParams>, PersistedState, PersistReturn> | undefined): OptionallyPersistedStore<QueryStoreState<TData, TParams>, PersistedState, PersistReturn>;
|
|
108
|
-
/**
|
|
109
|
-
* Generates a deterministic query store `queryKey` from the given parameters,
|
|
110
|
-
* consistent with internally generated keys.
|
|
111
|
-
*/
|
|
112
|
-
export declare function getQueryKey<TParams extends Record<string, unknown>>(params: TParams): string;
|
|
113
|
-
/**
|
|
114
|
-
* Parses a query store `queryKey` into the corresponding parameters.
|
|
115
|
-
*/
|
|
116
|
-
export declare function parseQueryKey<TParams extends Record<string, unknown>>(queryKey: string): TParams;
|
|
117
111
|
//# sourceMappingURL=createQueryStore.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { StoreApi } from '../../store/types';
|
|
2
2
|
import { TrackPathFn } from './pathFinder';
|
|
3
3
|
/**
|
|
4
4
|
* Gets or creates a lightweight tracking proxy that records path access and store
|
|
5
5
|
* method invocations via proxy traps. Used to auto-generate selectors that point
|
|
6
6
|
* to either the accessed path or the value returned by an invoked store method.
|
|
7
7
|
*/
|
|
8
|
-
export declare function getOrCreateProxy<S>(store:
|
|
8
|
+
export declare function getOrCreateProxy<S>(store: StoreApi<S>, rootProxyCache: WeakMap<object, unknown>, trackPath: TrackPathFn): S;
|
|
9
9
|
/**
|
|
10
10
|
* Strips tracking proxies from published values to ensure
|
|
11
11
|
* proxies remain confined to internal tracking contexts.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { QueryParam, ReactiveParam } from '../../queryStore/queryParam';
|
|
2
|
+
import type { StoreApi } from '../../store/types';
|
|
3
|
+
import type { InternalUnsubscribeFn } from '../types/internalSubscribeTypes';
|
|
4
|
+
export type TrackedValue<T> = {
|
|
5
|
+
readonly initialValue: T;
|
|
6
|
+
subscribe(listener: (value: T) => void): InternalUnsubscribeFn;
|
|
7
|
+
};
|
|
8
|
+
export type QueryParams<TParams extends Record<string, unknown>> = {
|
|
9
|
+
buildKey(params?: TParams): string;
|
|
10
|
+
complete(params: Partial<TParams> | undefined): TParams;
|
|
11
|
+
get(): TParams;
|
|
12
|
+
subscribe(onChange: (key: keyof TParams, oldValue: unknown, newValue: unknown) => void): InternalUnsubscribeFn;
|
|
13
|
+
};
|
|
14
|
+
export declare function createQueryParams<TParams extends Record<string, unknown>, State>(params: {
|
|
15
|
+
[K in keyof TParams]: QueryParam<TParams[K], State>;
|
|
16
|
+
} | undefined, store: StoreApi<State>, requiredKeys: (keyof TParams)[]): QueryParams<TParams>;
|
|
17
|
+
export declare function trackQueryValue<T, State>(getValue: ReactiveParam<T, State>, ownerStore: StoreApi<State>): TrackedValue<T>;
|
|
18
|
+
//# sourceMappingURL=queryParams.d.ts.map
|
|
@@ -2,7 +2,6 @@ export { configureStores } from './config';
|
|
|
2
2
|
export { StoresError } from './errors';
|
|
3
3
|
export { QueryStatuses } from '../queryStore/types';
|
|
4
4
|
export { defaultRetryDelay } from './queryStore/queryStoreDefaults';
|
|
5
|
-
export { getQueryKey, parseQueryKey } from '../queryStore/queryKey';
|
|
6
5
|
export { applyStateUpdate } from '../store/stateUpdate';
|
|
7
6
|
export { replacer, reviver } from '../utils/serialization';
|
|
8
7
|
export { destroyStore, destroyStores, getStoreName, hasGetSnapshot, isDerivedStore, isPersistedStore, isQueryStore, isVirtualStore, } from './storeUtils';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Listener, ListenerArgs, Selector, SubscribeOptions } from '../../types/subscribe';
|
|
2
|
+
export type InternalSubscribeOptions<Selected> = SubscribeOptions<Selected> & {
|
|
3
|
+
isCascadeParticipant?: boolean;
|
|
4
|
+
};
|
|
5
|
+
export type InternalSelectorArgs<S, Selected> = [
|
|
6
|
+
selector: Selector<S, Selected>,
|
|
7
|
+
listener: Listener<Selected>,
|
|
8
|
+
options?: InternalSubscribeOptions<Selected>
|
|
9
|
+
];
|
|
10
|
+
export type InternalSubscribeArgs<S, Selected = unknown> = ListenerArgs<S> | InternalSelectorArgs<S, Selected>;
|
|
11
|
+
export type InternalUnsubscribeFn = (skipAbortFetch?: boolean) => void;
|
|
12
|
+
export type InternalSubscribeOverloads<S> = {
|
|
13
|
+
(...args: ListenerArgs<S>): InternalUnsubscribeFn;
|
|
14
|
+
<Selected>(...args: InternalSelectorArgs<S, Selected>): InternalUnsubscribeFn;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=internalSubscribeTypes.d.ts.map
|
package/dist/native/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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};
|
|
1
|
+
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(){return{__proto__:null}}function a(){}Object.freeze(Object.create(null));var u=Symbol("empty selection"),l=Object.is;function f(e,t){return n=>(function(e){e.committedEqualityFn=e.equalityFn,e.committedSelector=e.selector,e.committedSource=e.source,e.committedValue=e.value===u?d(e):e.value}(e),t(r=>{e.latestSnapshot=r,e.latestSource=t;const o=e.committedValue;if(o===u||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===l?l(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===u)return;const a=e.selector(r),f=e.equalityFn(c,a);e.committedEqualityFn=e.equalityFn,e.committedSelector=e.selector,e.committedValue=p(e,r,f?c:a),f||n()}))}function d(e){const t=function(e){if(e.latestSource===e.source&&e.latestSnapshot!==u)return e.latestSnapshot;const t=e.getStoreSnapshot();return e.latestSnapshot=t,e.latestSource=e.source,t}(e);return y(e,t)}function y(e,t){const n=e.value;if(n!==u&&l(e.valueSnapshot,t)&&e.valueSelector===e.selector&&e.valueEqualityFn===e.equalityFn)return n;const r=e.selector(t);if(n!==u&&(e.equalityFn===l?l(n,r):e.equalityFn(n,r)))return p(e,t,n);const o=e.committedValue;return o!==u&&o!==n&&e.committedSource===e.source&&(e.equalityFn===l?l(o,r):e.equalityFn(o,r))?p(e,t,o):p(e,t,r)}function p(e,t,n){return e.value=n,e.valueEqualityFn=e.equalityFn,e.valueSelector=e.selector,e.valueSnapshot=t,n}function h(t,n,r,o){return Object.assign(function(i,s){return function(t,n,r,o,i=l){const s=e.useRef(null);let c=t,p=n,h=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:u,equalityFn:o,getSelectedServerSnapshot:()=>function(e){return y(e,(e.getServerStoreSnapshot??e.getStoreSnapshot)())}(i),getSelectedSnapshot:()=>d(i),getServerStoreSnapshot:n,getStoreSnapshot:t,latestSnapshot:u,latestSource:u,selector:r,selectedSource:e,selectedSubscribe:()=>a,source:e,value:u,valueEqualityFn:o,valueSelector:r,valueSnapshot:u};return i.selectedSubscribe=f(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=u),e.source=t,e.getStoreSnapshot=n,e.getServerStoreSnapshot=r,e.selector=o,e.equalityFn=i,e.selectedSource!==t&&(e.selectedSource=t,e.selectedSubscribe=f(e,t))}(e,t,n,r,o,i),c=e.selectedSubscribe,p=e.getSelectedSnapshot,h=void 0===r?void 0:e.getSelectedServerSnapshot}const g=e.useSyncExternalStore(c,p,h);return e.useDebugValue(g),g}(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 b={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)}},m=Object.prototype.hasOwnProperty;function S(e,t){return m.call(e,t)}function v(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function w(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}var O=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 q(e){return e instanceof Error?e:new Error(String(e))}var j,F,_,k=class{destroy(){}publish(){}},A=class{constructor(){this.sessionId="noop"}register(e){return new k}},I=!1;function C(){return _??(_=z(void 0))}function x(){I=!0}function z(e){return{storage:e?.storage??g(e?.storageKeyPrefix??"stores:"),syncEngine:e?.syncEngine??(j||(j=new A),j)}}var E,T={Error:"error",Idle:"idle",Loading:"loading",Success:"success"},P={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??P.seconds(5),r=t?.maxDelay??P.minutes(5);return Math.min(n*Math.pow(2,e),r)}function D(e,t){return!0===t[1]?e(t[0],!0):e(t[0])}function K(e,t,n){if(!0===n)return R(t)?t(e):t;const r=R(t)?t(e):t;return Object.is(r,e)?e:w(e)&&w(r)?{...e,...r}:r}function R(e){return"function"==typeof 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}var N=Object.freeze({QueryStore:Symbol("queryStore"),VirtualStore:Symbol("virtualStore")});function V(e,t){W(e)?e.getState().reset(t?.clearQueryCache):function(e){return"destroy"in e}(e)&&e.destroy()}function H(e){return"getSnapshot"in e}function W(e){return N.QueryStore in e}function U(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 Q(e,t){return"function"==typeof e[t]}function G(e,t){const n=Object.prototype.hasOwnProperty;function r(e,t){for(const n of e.keys())if(G(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--&&G(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(!G(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)||!G(e[r],t[r]))return!1}return Object.keys(t).length===i}}return e!=e&&t!=t}var X=t.unstable_batchedUpdates,Y=!1,Z=!1,ee=!1,te=new Set,ne=new Map,re=new Map,oe=null,ie=1/0;function se(){return Y}function ce(){return oe}function ae(){Y||(Y=!0,ee||(ee=!0,queueMicrotask(()=>{ee=!1,ue()})))}function ue(){if(Y)if(Z)fe();else{Z=!0;try{X(fe)}finally{pe()}}}function le(e){Y&&te.add(e)}function fe(){for(;ne.size>0||te.size>0;)de(),ye()}function de(){for(;ne.size>0;){const e=ie,t=re.get(e);if(t){re.delete(e);for(const e of t)ne.delete(e);oe=e;for(const e of t)e();oe=null,ie=1/0;for(const e of re.keys())e<ie&&(ie=e)}else{ie=1/0;for(const e of re.keys())e<ie&&(ie=e)}}}function ye(){for(const e of te)te.delete(e),e()}function pe(){Y=!1,Z=!1,oe=null,te.clear(),ne.clear(),re.clear(),ie=1/0}function he(e){let t;const n=new Set;let r;function o(...e){const o=K(t,...e);if(Object.is(o,t))return;const i=t;if(t=o,r)for(const e of r)e(t,i);n.size&&ue();for(const e of n)e(t,i)}function i(){return t}const s={getInitialState:function(){return c},getState:i,setState:o,subscribe:function(...e){return 1===e.length?a(e[0]):function(e,n,o){const i=o?.equalityFn??Object.is,s=o?.isCascadeParticipant??!1;let c=e(t);function u(t){const r=e(t);if(i(c,r))return;const o=c;c=r,s&&ae(),n(r,o)}return o?.fireImmediately&&n(c,c),s?function(e){return(r??(r=new Set)).add(e),()=>{r?.delete(e),0===r?.size&&(r=void 0)}}(u):a(u)}(e[0],e[1],e[2])}},c=t=e(o,i,s);return s;function a(e){return n.add(e),()=>{n.delete(e)}}}function ge(e){return!!e&&"object"==typeof e&&"then"in e&&"function"==typeof e.then}function be(e){return{...e,merge:e.merge??me,skipHydration:e.skipHydration??!1}}function me(e,t){return void 0===e?t:{...t,...e}}function Se(){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 ve=Math.max,we=Math.min;function Oe(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=qe();if(p(e))return g(e);c=setTimeout(h,function(e){const n=t-(e-(a??0));return f&&void 0!==i?we(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=qe(),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=je(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?ve(je(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(qe())},b}function qe(){return"undefined"!=typeof performance&&"function"==typeof performance.now?performance.now():Date.now()}function je(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 Fe(e){if(!v(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 _e=i?0:P.seconds(r?3:5);function ke(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??Fe,c=t.deserializer??e.deserializer??Ie(o),a=t.serializer??e.serializer??Ce(o);function u(t,n,o){try{if(Te(r))return;const c={state:s(n),version:o},u=ze(r,i,c),l=a(c);try{e.set(t,l),Ee(r,u)}catch(e){b.error(new O("[createBaseStore]: Failed to persist store data",e))}}catch(e){b.error(new O("[createBaseStore]: Failed to persist store data",e))}}const l=void 0!==n?Oe(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){b.error(new O("[createBaseStore]: Failed to delete persisted store data",e))}}}}function Ae(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??Fe,c=t.deserializer??e.deserializer??Ie(o),a=t.serializer??e.serializer??Ce(o);async function u(t,n,o){try{if(Te(r))return;const c={state:s(n),version:o},u=ze(r,i,c),l=a(c);try{await e.set(t,l),Ee(r,u)}catch(e){b.error(new O("[createBaseStore]: Failed to persist store data",e))}}catch(e){b.error(new O("[createBaseStore]: Failed to serialize persisted store data",e))}}const l=void 0!==n?Oe(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){b.error(new O("[createBaseStore]: Failed to delete persisted store data",e))}}}}function Ie(e){return t=>{if("string"!=typeof t)throw new O("[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 b.error(new O("[createBaseStore]: Failed to deserialize persisted store data",e)),e}}(t,e)}}function Ce(e){return t=>function(e,t){try{return JSON.stringify(e,t?$:void 0)}catch(e){throw b.error(new O("[createBaseStore]: Failed to serialize store data",e)),e}}(t,e)}var xe=Object.freeze({shouldClear:!1});function ze(e,t,n){if(!t||!e)return xe;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 Ee(e,t){e&&t.shouldClear&&t.fieldSnapshot&&Object.keys(t.fieldSnapshot).length&&e.clearFieldTimestamps(t.fieldSnapshot)}function Te(e){return!!e&&!!e.getIsApplyingRemote()}var[Pe,Me]=[0,1];function De(e,t,n){if(!e)return!0;const r=e[Pe],o=e[Me];return!(t<r)&&(t>r||n>o)}function Ke(e,t){return Object.prototype.hasOwnProperty.call(t,e)}function Re(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 $e(e){if(null===e)return"null";const t=typeof e;return"object"===t?Object.prototype.toString.call(e):t}function Le(e,t){if(x(),!t)return he(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 O("[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,h=null,g=[],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 w(e,t){if(d||!h)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=K(r,e,t);for(const e of g)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 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 ge(u)?u.finally(b):(b(),u)}const q=c.setState;c.setState=w;const j=e(w,s,c);if(g=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),!g.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 g)Ke(t,e.values)||De(a.get(t),i,e.sessionId)&&(c??(c=[])).push(t);for(const o of g){if(!Ke(o,e.values))continue;if(!h?.has(o))continue;if(!De(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(!Re(u,l))return void b.error(new O(`[sync] Merge function for field "${String(o)}" returned ${$e(u)} but expected ${$e(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(h=new Set(g),f=r.register({apply:e=>{S?_(e):u.push(e)},fields:g,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 k(){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 A(){S=!0,function(){if(!u.length)return;const e=u.slice();u.length=0;for(const t of e)_(t)}()}return n?(o.onHydrationComplete=k,o.onHydrationFlushEnd=A):f.onHydrated?(f.onHydrated(k),A()):(k(),A()),j},syncContext:o}}(e,i,o?.async??!1):void 0,c=s?.stateCreator??e;if(!r)return he(c);const a=function(e,t,n){const r=t??e.storage??C().storage,o=(e.sync?void 0:e.persistThrottleMs??_e)||void 0,i=e.version??0;return r.async?{async:!0,persistStorage:Ae(r,e,o,n),version:i}:{async:!1,persistStorage:ke(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=Se()),t.promise),stateCreator:(n,i,s)=>{let c;return r=()=>{if(c?.length){for(const e of c)D(s.setState,e);c=void 0}},e(function(...e){return o?D(n,e):(t||(t=Se()),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(q(i)):t?.complete(),s?.(e,i)}}}}(c):void 0,l=u?u.wrapOnRehydrateStorage(t.onRehydrateStorage,s?.syncContext):t.onRehydrateStorage,f=he(function(e,t){return(n,r,o)=>{let i,s,c,a=be(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 D(d,e),f()};const y=e(function(...e){return D(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 ge(n)?n.then(n=>h(e,n,t)).catch(n=>m(e,t,n)):h(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=be({...a,...e,storage:e.storage??a.storage})}}}),a.skipHydration||p(),i??y;function h(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 ge(n)?n.then(e=>({migrated:!0,state:e})):{migrated:!0,state:n}}(a,t);return ge(r)?r.then(t=>g(e,t,n)).catch(t=>m(e,n,t)):g(e,r,n)}function g(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(ge(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 Ne(e,t,n="s"){return 1===t?e:`${e}${n}`}var Ve=Symbol("stores.deriveProxy.unwrap");function He(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?We(e,r,t,n,new WeakSet,new WeakMap):(n(t,r,!0),e)}(H(e)?e.getSnapshot():e.getState(),e,n);return t.set(e,o),o}function We(e,t,n,r,o,i){return new Proxy(e,{get(s,c,a){if(c===Ve)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,We(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 Ue(e,t){if(!e||"object"!=typeof e)return e;const n=function(e){const t=Reflect.get(e,Ve);return t&&"object"==typeof t?t:void 0}(e);return n||(Array.isArray(e)?function(e,t){const n=Be(e,t);if(n)for(let t=0;t<e.length;t++)Je(e,String(t),n)}(e,t):v(e)&&function(e,t){const n=Be(e,t);if(n)for(const t of Reflect.ownKeys(e))Je(e,t,n)}(e,t),e)}function Je(e,t,n){const r=Reflect.getOwnPropertyDescriptor(e,t);if(!r||!("value"in r))return;const o=Ue(r.value,n);o!==r.value&&(r.value=o,Reflect.defineProperty(e,t,r))}function Be(e,t){const n=t??new WeakSet;return n.has(e)?null:(n.add(e),n)}var Qe=Object.freeze([]);function Ge(){const e=new Map;return{buildProxySubscriptions(t,n,r,o){const i=new Set;for(const t of e)Ye(t[1],t[0],[],0,i,r);!1!==o?.(i)&&function(e,t,n){for(const n of e){const e=n.invocation?nt(n.path,n.invocation):tt(n.path);t(n.store,e,n.path)}n&&function(e){const t=e.size;console.log(`[📡 ${t} ${Ne("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}_${Ne("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)),Xe(i,n,0,r,o)}}}function Xe(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(Ze(n,t))return;const r=e.extraInvocations;if(r){for(let e=0;e<r.length;e++)if(Ze(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),Xe(s,t,n+1,r,o)}function Ye(e,t,n,r,o,i=2){const s=e.children;if(!s)return void et(e,t,n,o);const c=Object.keys(s),a=c.length;if(0!==a)if(e.isLeaf||r>=i&&a>1){et(e,t,n,o);for(const e of c){const c=s[e];c.invocation&&Ye(c,t,[...n,e],r+1,o,i)}}else if(r<i&&a>1&&!e.isLeaf)for(const e of c)Ye(s[e],t,[...n,e],r+1,o,i);else{if(1===a){const e=c[0];return void Ye(s[e],t,[...n,e],r+1,o,i)}et(e,t,n,o)}else et(e,t,n,o)}function Ze(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 et(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 tt(e){return t=>rt(t,e)}function nt(e,t){const n=e.slice(0,-1),r=e[e.length-1];return e=>{const o=rt(e,n),i=o&&"object"==typeof o?Reflect.get(o,r):void 0;return"function"==typeof i?Reflect.apply(i,o,t.args??Qe):void 0}}function rt(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 ot=Symbol(),it=Object.freeze({equalityFn:Object.is,isCascadeParticipant:!0});function st(e,t=Object.is){const{debounceOptions:n,debugMode:r,equalityFn:i,keepAlive:c,lockDependencies:a}="function"==typeof(l=t)?{debounceOptions:void 0,debugMode:!1,equalityFn:l,keepAlive:!1,lockDependencies:!1}:{debounceOptions:l.debounce,debugMode:(o&&l.debugMode)??!1,equalityFn:l.equalityFn??Object.is,keepAlive:l.keepAlive??!1,lockDependencies:l.lockDependencies??!1},u=new Set;var l;c&&u.add(ct);const f=new Set;let d,y,p=ot,h=!1,g=!1,b=!0,m=!0,S=0,v=!1,w=null,O=ot;function q(e,t,n){if(!m||!u.size)return(t??s)(e.getState());if(!t)return d||(d=new WeakMap),y||(y=Ge()),He(e,d,y.trackPath);const r=n?{equalityFn:n,isCascadeParticipant:!0}:it;return f.add(e.subscribe(t,T,r)),t(H(e)?e.getSnapshot():e.getState())}function j(e){for(const t of f)t(e);f.clear()}let F=!0;function _(){if(!b&&at(p))return p;b=!1,m&&j(!0);const t=p,n=at(t);g=!0;try{p=function(t){F=!0;const n=p,o=e(t),s=y?Ue(o):o;return at(n)&&i(n,s)?(r&&console.log("[🥷 Derive Complete 🥷]: No change detected"),F=!1,n):s}(q)}finally{g=!1}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=f.size;console.log(`[🎯 ${e} ${Ne("Selector Subscription",e)} 🎯]`)}return y&&m&&(y.buildProxySubscriptions((e,t)=>{f.add(e.subscribe(t,T,it))},o),d=void 0,y.reset(),a&&(y=void 0)),F&&n&&function(e,t){const n=function(){const e=u.has(ct)?u.size-1:u.size;return S>0&&S<e}(),o=(!S||n)&&(n||null!==ce()||se());n&&ae(),r&&console.log(`[📻 Derive Complete 📻]: Notifying ${u.size} ${Ne("watcher",u.size)}`);for(const t of u){if("function"==typeof t||!t.isCascadeParticipant)continue;const n=t.selector(e);if(!t.equalityFn(t.currentSlice,n)){const e=t.currentSlice;t.currentSlice=n,t.listener(n,e)}}if(o)return at(O)||(O=t),void(v||(v=!0,le(A)));k(e,t)}(p,t),a&&(m=!1),p}function k(e,t){for(const n of u)if("function"==typeof n)n(e,t);else if(!n.isCascadeParticipant){const t=n.selector(e);if(!n.equalityFn(n.currentSlice,t)){const e=n.currentSlice;n.currentSlice=t,n.listener(t,e)}}}function A(){u.size&&b&&!S&&_();const e=O;v=!1,O=ot,u.size&&at(p)&&at(e)&&k(p,e)}const I=n?Oe(x,"number"==typeof n?n:n.delay,"number"==typeof n?{leading:!1,maxWait:n,trailing:!0}:n):void 0,C=I??(()=>{h||(h=!0,queueMicrotask(x))});function x(){h=!1,u.size?b&&_():D()}function z(e){e||I&&b?queueMicrotask(()=>{u.size||D()}):D()}function E(){x(),w=null}function T(){if(!g&&!b){if(b=!0,!I){if(S){ae();const e=ce(),t=null===e?0:e+1;if(null!==w&&t<=w)return;return w=t,void function(e,t){if(!Y)return;const n=t<0?0:0|t,r=ne.get(e);if(void 0===r){ne.set(e,n);let t=re.get(n);return t||(t=new Set,re.set(n,t)),t.add(e),void(n<ie&&(ie=n))}if(n>r){const t=re.get(r);if(t&&(t.delete(e),0===t.size&&(re.delete(r),r===ie))){ie=1/0;for(const e of re.keys())e<ie&&(ie=e)}ne.set(e,n);let o=re.get(n);o||(o=new Set,re.set(n,o)),o.add(e),n<ie&&(ie=n)}}(E,t)}if(se())return void(v||(v=!0,le(A)))}w=null,C()}}function P(e){u.add(ct);try{return e()}finally{u.delete(ct)}}function M(){return se()&&function(){if(Y)if(Z)null===oe&&de();else{Z=!0;try{de()}catch(e){throw pe(),e}finally{Z=!1,oe=null}}}(),b||!at(p)?u.size>0?_():e(q):p}function D(e=!0){c&&e||(I?.cancel(),j(),u.clear(),S=0,y=void 0,d=void 0,m=!0,h=!1,g=!1,b=!0,p=ot,v=!1,O=ot,w=null)}return{destroy:()=>D(!1),flushUpdates:function(){u.size&&(I?I.flush():b&&_())},getSnapshot:function(){return at(p)?(h&&x(),p):u.size?_():P(_)},getState:M,subscribe:function(...e){if(1===e.length){const t=e[0];return u.add(t),at(p)||M(),()=>{u.delete(t),u.size||z(!1)}}const[t,n,r]=e,o=r?.equalityFn??Object.is,i=r?.isCascadeParticipant??!1,s=function(e){return e(u.size?M():P(M))}(t),c={currentSlice:s,equalityFn:o,isCascadeParticipant:i,listener:n,selector:t};return u.add(c),i&&(S+=1),r?.fireImmediately&&n(s,s),()=>{u.delete(c),i&&(S-=1),u.size||z(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.")}}}function ct(){}function at(e){return e!==ot}var ut=class{constructor(e){this.count=0,this.lastSubscriptionTime=null,this.fetchThrottleMs=null,this.onSubscribe=null,this.onLastUnsubscribe=null,e&&(this.fetchThrottleMs=P.seconds(5))}init({onSubscribe:e,onLastUnsubscribe:t}){this.onSubscribe=e,this.onLastUnsubscribe=t}hasSubscribers(){return this.count>0}subscribe(){const e=0===this.count,t=null!==this.fetchThrottleMs,n=t&&null!==this.lastSubscriptionTime&&!e&&Date.now()-this.lastSubscriptionTime<=this.fetchThrottleMs;return this.count+=1,this.onSubscribe?.(e,n),t&&(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)}}},lt=Symbol("stores.queryParamConfig");function ft(e){return JSON.stringify(dt(e))}function dt(e){return"object"!=typeof e||null===e?e:Object.keys(e).sort().reduce((t,n)=>{const r=e[n];return t[n]=v(r)?dt(r):r,t},{__proto__:null})}var yt=Object.freeze({equalityFn:Object.is,isCascadeParticipant:!0});function pt(e,t,n){const r={__proto__:null};let o=null,i=!1;if(e)for(const n in e){if(!S(e,n))continue;const s=ht(r,e[n],n,t);s&&((o??(o=c()))[n]=s,void 0!==s.key&&(i=!0))}return{buildKey:(e=r)=>ft(i?function(e,t){const n={__proto__:null};for(const r in t){if(!S(t,r))continue;const o=e?.[r];if(!1===o?.key)continue;const i=t[r];n[r]=o?.key?o.key(i):i}return n}(o,e):e),complete:e=>e?function(e,t){for(const n of t)if(!(n in e))return!1;return!0}(e,n)?e:{...r,...e}:mt(r),get:()=>mt(r),subscribe:e=>function(e,t,n){if(!e)return a;let r;for(const o in e){const i=e[o]?.tracked;i&&(r??(r=[])).push(i.subscribe(e=>{const r=t[o];G(r,e)||(t[o]=e,n(o,r,e))}))}return r?e=>{for(const t of r)t(e)}:a}(o,r,e)}}function ht(e,t,n,r){return(o=t)&&"object"==typeof o&< in o?bt(e,t.value,n,r,t.key):bt(e,t,n,r);var o}function gt(e,t){const n=[];let r,o;function i(e,t=s){return t(St(e))}const c=e(function(e,t,i){return t?(n.push(n=>e.subscribe(t,n,function(e){return e?{equalityFn:e,isCascadeParticipant:!0}:yt}(i))),t(St(e))):(r??(r=Ge()),o??(o=new WeakMap),He(e,o,r.trackPath))},t),a=r?Ue(c):c;return r&&(r.buildProxySubscriptions((e,t)=>{n.push(n=>e.subscribe(t,n,yt))},!1),r.reset()),o=void 0,{initialValue:a,subscribe(r){const o=()=>r(e(i,t)),s=n.map(e=>e(o));return e=>{for(const t of s)t(e)}}}}function bt(e,t,n,r,o){if(function(e){return"function"==typeof e}(t)){const i=gt(t,r);return e[n]=i.initialValue,void 0===o?{tracked:i}:{key:o,tracked:i}}return e[n]=t,void 0===o?null:{key:o}}function mt(e){const t={__proto__:null};for(const n in e)S(e,n)&&(t[n]=e[n]);return t}function St(e){return H(e)?e.getSnapshot():e.getState()}var vt={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},wt=Object.freeze({force:!0}),Ot=Object.freeze({once:!0}),qt=new Set,jt=!1;function Ft(e){qt.add(e),jt||(jt=!0,queueMicrotask(()=>{jt=!1,X(_t)}))}function _t(){for(const e of qt)qt.delete(e),e()}function kt(e,t){return n=>{const r={...n},o={__proto__:null};for(const e in r)S(r,e)&&e in vt&&(vt[e]&&(o[e]=r[e]),delete r[e]);return{...t?t(r):Fe(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(!S(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 It(){return Object.create(null)}function Ct(e,t,n){return new O(`[createQueryStore: ${e}]: ${t} failed`,n)}function xt(e){return function(...t){return!0===t[1]?e().setState(t[0],!0):e().setState(t[0])}}var zt=Symbol(),Et=Object.freeze({debugMode:!1,enabled:!0,equalityFn:Object.is,fireImmediately:!1}),Tt=Object.freeze({fireImmediately:!1,forceResubscribe:!1});function Pt(e,t,n=Tt){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=Tt)=>Pt(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 Mt(e){return"function"==typeof e?{equalityFn:e}:e??Et}var Dt=Symbol();exports.QueryStatuses=T,exports.StoresError=O,exports.applyStateUpdate=K,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,b=t),F??(F=function(e){return e?.queryStoreDefaults?{queryStoreDefaults:e.queryStoreDefaults}:void 0}(e)),_??(_=z(e))},exports.createBaseStore=function(e,t){const n=Le(e,t);return h(n,n.getState,n.getInitialState,Object.is)},exports.createDerivedStore=function(e,t=Object.is){const n=st(e,t);return h(n,n.getSnapshot)},exports.createQueryStore=function(e,t,n){const r=function(e,t,n){x();const r="function"==typeof t?t:It,s="object"==typeof t?t:n,c=function(e){return"string"==typeof e?.storageKey}(s)?s:void 0,a=E??(E=function(){const e={abortInterruptedFetches:!0,cacheTime:P.days(7),debugMode:!1,disableAutoRefetching:!1,keepPreviousData:!1,maxRetries:5,minStaleTime:!1,paramChangeThrottle:!1,retryDelay:M,staleTime:P.minutes(2),suppressStaleTimeWarning:!1},t=function(){if(F)return F}()?.queryStoreDefaults;return t?{...e,...t}:e}()),u=a.minStaleTime,{fetcher:l,onError:f,onFetched:d,setData:y,transform:p,abortInterruptedFetches:h=a.abortInterruptedFetches,cacheTime:g=a.cacheTime,debugMode:m=a.debugMode,disableAutoRefetching:S=a.disableAutoRefetching,disableCache:v=!1,enabled:w=!0,keepPreviousData:j=a.keepPreviousData,maxRetries:_=a.maxRetries,paramChangeThrottle:k=a.paramChangeThrottle,params:A,retryDelay:I=a.retryDelay,staleTime:C=a.staleTime,suppressStaleTimeWarning:z=a.suppressStaleTimeWarning}=e;let D="function"==typeof C?a.staleTime:C;o&&!1!==u&&!S&&!z&&D<u&&console.warn(`[createQueryStore${c?.storageKey?`: ${c.storageKey}`:""}] ❌ Stale times under ${u/1e3} seconds are not recommended. Provided staleTime: ${D/1e3} seconds`);const K=new Error("[createQueryStore: AbortError] Fetch interrupted"),R="function"==typeof g,$=o&&m,L=e.params?Object.keys(e.params):[];let V,H=!1,W=[],U=null,J=null,B=null,Q=null,G=null,X=null,Y=null;const Z={enabled:"function"!=typeof w&&w,error:null,lastFetchedAt:null,queryCache:{},queryKey:"",status:T.Idle},ee=new ut(S);function te(){B&&(Q=null,B.abort(),B=null)}function ne(){G&&(clearTimeout(G),G=null)}function re(e,t,n){const o=n.setState;function i(e){const t="function"==typeof e;if(t||void 0!==e.enabled){let n;const r=o(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,t&&ee.hasSubscribers()?queueMicrotask(()=>a.fetch(void 0,void 0,!0)):(G||h)&&(h&&te(),ne()))}(r.enabled,i)),o});return n?.(),r}return o(e)}function s(e){if(S||D<=0||D===1/0)return;if(!ee.hasSubscribers())return;ne();const n=t();if(!n.enabled)return;const r=V.buildKey(e),o=(v?X===r&&n.lastFetchedAt:n.queryCache[r]?.lastFetchedAt)||null,i=o?D-(Date.now()-o):D;G=setTimeout(()=>{t().enabled&&a.fetch(e,wt,!0)},i)}n.setState=i,ee.init({onSubscribe:(n,r)=>{const o=t();if(o.enabled)if(n){const t=V.get(),n=V.buildKey(t);o.queryKey!==n&&e({queryKey:n}),o.isStale()?a.fetch(t,void 0,!0):s(t)}else S&&!r&&a.fetch(void 0,void 0,!0)},onLastUnsubscribe:e=>{ne(),h&&!e&&te()}});const a={...r(i,t,n),...Z,async fetch(n,r,o=!1){const u=!!r?.skipStoreUpdates,m=t();if(!u){if(!m.enabled&&!r?.force)return null;if(o&&!ee.hasSubscribers())return null}const S=m.error,w=m.queryKey,F=m.status===T.Loading,k=V.complete(n),A=V.buildKey(k);if(F&&Q?.promise&&Q.key===A)return $&&console.log("[🔄 Using Active Fetch 🔄] for params:",JSON.stringify(k)),Q.promise;const C=r?.staleTime??D,x="boolean"==typeof r?.updateQueryKey?r.updateQueryKey:!!o&&j,z=(o||w===A||x)&&!u,E=null!==Q;if(h&&z&&te(),!r?.force){const t=m.lastFetchedAt,n=m.queryCache[A],r=n?.lastFetchedAt,o=n?.errorInfo,i=o&&o.retryCount>=_,c=(v?X===A&&t:r)||null;if(c&&!(Date.now()-c>=C)&&(!o||i||u))return z&&!G&&0!==D&&D!==1/0&&s(k),x&&e(e=>e.queryKey!==A?{queryKey:A}:e),$&&console.log("[💾 Returning Cached Data 💾] for params:",JSON.stringify(k)),n?.data??null}const P=z?{key:A}:null,M=r?.cacheTime??(R?g(k):g);async function N(){const m=c?.storageKey||A;try{$&&(!o&&n&&L.some(e=>!(e in n))?console.log("[🔄 Fetching with Partial Params 🔄]\n","- Provided params:",`${JSON.stringify(n)}\n`,"- Filled in params:",`${JSON.stringify(Object.fromEntries(Object.keys(k).filter(e=>!(e in n)).map(e=>[e,k[e]])))}`):console.log("[🔄 Fetching 🔄] for params:",JSON.stringify(k)));const t=await(h&&z?async function(e){const t=new AbortController;B=t;try{return await new Promise((n,r)=>{t.signal.addEventListener("abort",()=>r(K),Ot),Promise.resolve(l(e,t)).then(n,r)})}finally{B===t&&(B=null)}}(k):l(k,null)),c=Date.now();let f;$&&console.log("[✅ Fetch Successful ✅] for params:",JSON.stringify(k));try{f=function(e,t,n){return n?n(e,t):e}(t,k,p)}catch(e){throw Ct(m,"transform",e)}if(u)return $&&console.log("[🥷 Successful Parallel Fetch 🥷] for params:",JSON.stringify(k)),"withCache"===r.skipStoreUpdates&&e(e=>{if(!y)return v?e:{queryCache:{...e.queryCache,[A]:{cacheTime:M,data:f,errorInfo:null,lastFetchedAt:c}}};let t=e;const n=t.queryCache[A];try{y({data:f,params:k,queryKey:A,set:e=>{t="function"==typeof e?{...t,...e(t)}:{...t,...e}}})}catch(e){throw Ct(m,"setData",e)}return!v&&Object.is(n,t.queryCache[A])&&(t={...t,queryCache:{...t.queryCache,[A]:{cacheTime:M,data:null,errorInfo:null,lastFetchedAt:c}}}),t}),f;if((y?i:e)(e=>{let t={...e,error:null,lastFetchedAt:c,queryKey:x?A:e.queryKey,status:T.Success};if(y||v){if(y){$&&console.log("[💾 Setting Data 💾] for params:",JSON.stringify(k));const e=t.queryCache[A];try{y({data:f,params:k,queryKey:A,set:e=>{t="function"==typeof e?{...t,...e(t)}:{...t,...e}}})}catch(e){throw Ct(m,"setData",e)}!v&&Object.is(e,t.queryCache[A])&&(t.queryCache={...t.queryCache,[A]:{cacheTime:M,data:null,errorInfo:null,lastFetchedAt:c}})}}else $&&console.log("[💾 Setting Cache 💾] for params:",JSON.stringify(k),"| Has previous data?:",!!t.queryCache[A]?.data),t.queryCache={...t.queryCache,[A]:{cacheTime:M,data:f,errorInfo:null,lastFetchedAt:c}};return v||g===1/0?t:At(j,A,t)}),z&&(X=A,s(k)),d)try{d({data:f,fetch:a.fetch,params:k,set:i})}catch(e){b.error(Ct(m,"onFetched callback",e))}return f??null}catch(n){if(n===K)return $&&console.log("[❌ Fetch Aborted ❌] for params:",JSON.stringify(k)),null;const i=!o&&!0===r?.throwOnError,s=q(n);if(s instanceof O&&b.error(s),!z){if(i)throw s;return null}const c=v?void 0:t().queryCache[A],u=c?.errorInfo?.retryCount??0,l=u+1;try{f?.(s,u)}catch(e){b.error(Ct(m,"onError callback",e))}if(u<_){if(t().enabled&&ee.hasSubscribers()){const e="function"==typeof I?I(l,s):I;e!==1/0&&(ne(),G=setTimeout(()=>{t().enabled&&a.fetch(k,wt,!0)},e))}e(e=>({error:s,queryCache:{...e.queryCache,[A]:{cacheTime:c?.cacheTime??M,data:c?.data??null,lastFetchedAt:c?.lastFetchedAt??null,errorInfo:{error:s,lastFailedAt:Date.now(),retryCount:l}}},queryKey:x?A:e.queryKey,status:T.Error}))}else e(e=>({error:s,queryCache:{...e.queryCache,[A]:{cacheTime:c?.cacheTime??M,data:c?.data??null,lastFetchedAt:c?.lastFetchedAt??null,errorInfo:{error:s,lastFailedAt:Date.now(),retryCount:_}}},queryKey:x?A:e.queryKey,status:T.Error}));if(i)throw s;return null}finally{Q===P&&(Q=null)}}return P&&(ne(),x&&!E&&null===m.lastFetchedAt&&w!==A?e({error:null,queryKey:A,status:T.Loading}):!S&&F||e({error:null,status:T.Loading}),Q=P),P?(P.promise=N(),P.promise):N()},getCacheEntry(e){if(v)return null;const n=t(),r=e?"string"==typeof e?e:V.buildKey(V.complete(e)):n.queryKey;return n.queryCache[r]??null},getData(e){if(v)return null;const n=t().getCacheEntry(e);return n&&null!==n.data?j?n.data:n.lastFetchedAt&&Date.now()-n.lastFetchedAt>=n.cacheTime?null:n.data:null},getStatus:function(e){const n=t(),r=n.status;switch(e){case"isIdle":return r===T.Idle;case"isLoading":return r===T.Loading;case"isError":case"isInitialLoad":case"isSuccess":case void 0:{const t=n.queryKey,o=n.queryCache[t],i=v?r===T.Error:"number"==typeof o?.errorInfo?.lastFailedAt;if("isError"===e)return i;const s=null!==((v?X===t&&n.lastFetchedAt:o?.lastFetchedAt)||null),c=!s&&!i&&n.enabled;if("isInitialLoad"===e)return c;const a=s&&!i;return"isSuccess"===e?a:{isError:i,isIdle:r===T.Idle,isLoading:r===T.Loading,isInitialLoad:c,isSuccess:a}}}},isDataExpired(e){const n=t(),r=n.queryCache[n.queryKey],o=n.queryKey,i=n.lastFetchedAt,s=(v?X===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 n=t(),r=n.queryKey,o=(v?X===r&&n.lastFetchedAt:n.queryCache[r]?.lastFetchedAt)||null;if(!o)return!0;const i=e??D;return Date.now()-o>=i},reset(t=!1){for(const e of W)e();W=[],V=pt(void 0,oe,L),U=null,J=null,te(),ne(),Q=null,X=null,t&&e(Z)}},u=n.subscribe;return n.subscribe=(...e)=>{const t=H?void 0:ee.subscribe(),n=1===e.length?u(e[0]):u(e[0],e[1],e[2]);return e=>{t?.(e),n()}},a}const oe=c?.storageKey?Le(re,(ie=c,void 0===(se={partialize:kt(j,c.partialize)})?Object.assign({__proto__:null},ie):Object.assign({__proto__:null},ie,se))):s&&!("storageKey"in s)?Le(re,s):Le(re);var ie,se;const ce=oe.getState(),ae=ce.error,ue=ce.enabled,le=ce.queryKey,fe=ce.fetch;le&&!ae&&(X=le),H=!0,V=pt(A,oe,L),"function"==typeof w&&(U=gt(w,oe)),"function"==typeof e.staleTime&&(J=gt(e.staleTime,oe),D=J.initialValue);const de=function(e,t=queueMicrotask){let n,r=!1;function o(){r=!1,e(...n)}return function(...e){n=e,r||(r=!0,t(o))}}(e=>{fe(e,void 0,!0)},Ft);function ye(){if(j)de(void 0);else{const e=V.get();oe.setState({queryKey:V.buildKey(e)}),de(e)}}const pe=i||!k?void 0:Oe(ye,"number"==typeof k?k:k.delay,"number"==typeof k?{leading:!1,maxWait:k,trailing:!0}:k);if(W.push(V.subscribe((e,t,n)=>{$&&console.log("[🌀 Param Change 🌀] -",e,"- [Old]:",`${t?.toString()},`,"[New]:",n?.toString()),function(){if(ne(),pe){const e=oe.getState();return void(j&&Q?.key===e.queryKey&&null===e.lastFetchedAt?ye():pe())}ye()}()})),J){let e=J.initialValue;$&&console.log("[🌀 StaleTime Subscription 🌀] Initial value:",e),W.push(J.subscribe(t=>{t!==e&&($&&console.log("[🌀 StaleTime Change 🌀] - [Old]:",`${e},`,"[New]:",t),e=t,D=t,ne(),fe(void 0,void 0,!0))}))}let he;if(U){let e=U.initialValue;ue!==e&&((he??(he={})).enabled=e),$&&console.log("[🌀 Enabled Subscription 🌀] Initial value:",e),W.push(U.subscribe(t=>{t!==e&&($&&console.log("[🌀 Enabled Change 🌀] - [Old]:",`${e},`,"[New]:",t),e=t,oe.setState({enabled:t}))}))}else ue!==Z.enabled&&((he??(he={})).enabled=Z.enabled);const ge=V.buildKey();return ge!==le&&((he??(he={})).queryKey=ge),he&&oe.setState(he),H=!1,be=oe,me=N.QueryStore,Object.assign(be,{[me]:!0});var be,me}(e,t,n);return h(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)Q(t,n)&&(r[n]=B(e,n));else for(const e in t)Q(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;let c;function u(e,t,n,r){l(e,t,n,r)&&ae()}function l(e,t,n,r){e.unsubscribe();const o=e.args;if(1===o.length){const i=o[0],s=t.subscribe(i);e.unsubscribe=s;const c=!Object.is(r,n);return c&&i(r,n),c}const i=o[0],s=o[1];let c=o[2];c?.fireImmediately&&(c={...c,fireImmediately:!1});const a=i(n),u=i(r),l=t.subscribe(i,s,c);return e.unsubscribe=l,!(c?.equalityFn??Object.is)(a,u)&&(s(u,a),!0)}function f(e,t){!function(e,t){const n=e.getState(),r=t.getState();if(c)for(const e of c)u(e,t,n,r);s.size&&ue();for(const e of s)l(e,t,n,r)}(t,e),V(t)}const d=st(e,{debugMode:i?.debugMode??!1,lockDependencies:i?.lockDependencies??!0});let y;function p(){return y??(y=d.subscribe(f)),d.getState()}const h=Object.assign({[N.VirtualStore]:!0,destroy:()=>{y?.(),y=void 0,d.destroy()},getInitialState:()=>p().getInitialState(),getState:()=>p().getState(),persist:(g=p,{clearStorage:()=>g().persist?.clearStorage(),getOptions:()=>g().persist?.getOptions()??{},hasHydrated:()=>g().persist?.hasHydrated()??!0,hydrationPromise:()=>g().persist?.hydrationPromise?.()??Promise.resolve(),onFinishHydration:e=>g().persist?.onFinishHydration(e)??a,onHydrate:e=>g().persist?.onHydrate(e)??a,rehydrate:()=>g().persist?.rehydrate(),setOptions:e=>g().persist?.setOptions(e)}),setState:xt(p),subscribe:function(...e){const t=p(),n={args:e,unsubscribe:1===e.length?t.subscribe(e[0]):t.subscribe(e[0],e[1],e[2])},r=e[2]?.isCascadeParticipant??!1;return r?(c??(c=new Set)).add(n):s.add(n),()=>{n.unsubscribe(),r?c?.delete(n)&&0===c.size&&(c=void 0):s.delete(n)}}},o?.(p));var g;return h}(e,t,n);return h(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=V,exports.destroyStores=function(e,t){for(const n of Array.isArray(e)?e:Object.values(e))n&&!t?.skipDestroy?.(n)&&V(n,t)},exports.getQueryKey=ft,exports.getStoreName=function(e){const t="function"==typeof(n=e)?n.name:"";var n;return U(e)?e.persist.getOptions().name??t:t},exports.hasGetSnapshot=H,exports.identity=s,exports.isDerivedStore=function(e){return"flushUpdates"in e},exports.isPersistedStore=U,exports.isQueryStore=W,exports.isVirtualStore=J,exports.nullObject=c,exports.parseQueryKey=function(e){return JSON.parse(e)},exports.queryParam=function(e,t){return{[lt]:!0,key:t.key,value: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=P,exports.useListen=function(t,n,r,o=Et){const i=function(){const t=e.useRef(zt);return t.current===zt&&(t.current=function(e,t,n){return{selector:e,react:t,isActive:!1,options:Mt(n),resubscribe:a,unsubscribe:a}}(n,r,o)),t}(),s=function(e){return"function"==typeof e?Et.enabled:e?.enabled??Et.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??Et)}(i,o),e.useLayoutEffect(()=>{if(s)return Pt(t,i),()=>function(e){e.current.options.debugMode&&console.log("[🗑️ useListen 🗑️] Detaching listener"),e.current.resubscribe=a,e.current.unsubscribe(),e.current.unsubscribe=a,e.current.isActive=!1}(i)},[s,t]),i},exports.useStableValue=function(t){const n=e.useRef(Dt);return n.current===Dt&&(n.current=t()),n.current};
|