statezero 0.9.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # statezero
2
2
 
3
3
  [![npm version](https://badge.fury.io/js/statezero.svg)](https://www.npmjs.com/package/statezero)
4
- [![CI](https://github.com/andornaut/statezero/workflows/CI/badge.svg)](https://github.com/andornaut/statezero/actions)
4
+ [![CI](https://github.com/andornaut/statezero/actions/workflows/release.yml/badge.svg)](https://github.com/andornaut/statezero/actions/workflows/release.yml)
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
6
 
7
7
  Small, simple, functional JavaScript library for managing immutable state.
@@ -202,13 +202,13 @@ but if you want the callbacks to be invoked synchronously, then you can use `sub
202
202
 
203
203
  Getters are analogous to "computed properties" (see, for example,
204
204
  [computed properties in Vuex](https://vuex.vuejs.org/guide/state.html#getting-vuex-state-into-vue-components)).
205
- Getters are defined by calling `defineGetter(fn, path)`, where "fn" is a function that you define, which should return
206
- the value of the property, and "path" is the
205
+ Getters are defined by calling `defineGetter(path, fn, enumerable)`, where "path" is the
207
206
  [dot notation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors)
208
207
  path of the
209
- [getter Property](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects#Defining_getters_and_setters)
210
- that you wish to define. Any non-existent ancestors in the "path" will be created as empty objects. Note that you should
211
- avoid [cycles](https://en.wikipedia.org/wiki/Circular_dependency) in getters.
208
+ [getter property](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects#Defining_getters_and_setters)
209
+ that you wish to define, "fn" is a function that returns the computed value, and "enumerable" (optional, defaults to
210
+ false) determines whether the property shows up during enumeration. Any non-existent ancestors in the "path" will be
211
+ created as empty objects. Note that you should avoid [cycles](https://en.wikipedia.org/wiki/Circular_dependency) in getters.
212
212
 
213
213
  The function that you pass to `defineGetter()` is itself passed two arguments by statezero: `parent` and `root`.
214
214
  `parent` corresponds to the object on which the getter was defined; in the case of a top-level getter, this is the
@@ -238,7 +238,10 @@ subscribe(console.log, "nested.countTimesTwo");
238
238
  Getter functions are called with the root state as the second argument.
239
239
 
240
240
  ```javascript
241
- defineGetter("nested.countTimesTwoTimesRootCount", (parent, root) => parent.count * 2 * root.count);
241
+ defineGetter(
242
+ "nested.countTimesTwoTimesRootCount",
243
+ (parent, root) => parent.count * 2 * root.count,
244
+ );
242
245
 
243
246
  subscribe(console.log, "nested.countTimesTwoTimesRootCount");
244
247
 
@@ -251,7 +254,10 @@ Getters can be
251
254
  ```javascript
252
255
  // The last argument defaults to `false`
253
256
  defineGetter("nested.property", () => null, true);
254
- const { enumerable } = Object.getOwnPropertyDescriptor(getState().nested, "property");
257
+ const { enumerable } = Object.getOwnPropertyDescriptor(
258
+ getState().nested,
259
+ "property",
260
+ );
255
261
  console.log(enumerable);
256
262
 
257
263
  // Prints "true"
@@ -285,3 +291,21 @@ npm run lint # ESLint with zero-warning policy
285
291
  npm run test # Run tests with Jest
286
292
  npm run test:watch # Run tests in watch mode
287
293
  ```
294
+
295
+ ## Publishing
296
+
297
+ ```bash
298
+ npm version minor # or major/patch - updates package.json and creates git tag
299
+ git push && git push --tags
300
+ ```
301
+
302
+ Pushing the tag is the whole release. The Release workflow runs the checks,
303
+ cuts the GitHub release, and publishes to npm. `npm publish` is not run by
304
+ hand.
305
+
306
+ Nothing here holds an npm token. The workflow authenticates with a short-lived
307
+ credential minted from its own OIDC claim, against a trusted publisher
308
+ registered on npm that names this repository and
309
+ `.github/workflows/release.yml`. Renaming that file stops publishing until the
310
+ trusted publisher is updated to match. Publishing this way also attests
311
+ provenance, which is why no `--provenance` flag appears anywhere.
package/dist/index.d.ts CHANGED
@@ -1,100 +1,222 @@
1
1
  // TypeScript definitions for statezero
2
2
 
3
- export type Selector<T = any> = string | string[] | ((state: any) => T) | undefined;
3
+ /**
4
+ * The root state type. Users can override this via module augmentation:
5
+ * @example
6
+ * declare module 'statezero' {
7
+ * interface StateSchema {
8
+ * count: number;
9
+ * user: { name: string };
10
+ * }
11
+ * }
12
+ */
13
+ export interface StateSchema {
14
+ [key: string]: unknown;
15
+ }
4
16
 
5
- export interface ActionContext {
6
- commit: (nextState: Record<string, any>) => void;
7
- state: Record<string, any>;
17
+ /**
18
+ * A selector for selecting a portion of state.
19
+ * Can be a dot-notation path, array of paths, selector function, or undefined for full state.
20
+ */
21
+ export type Selector<TState = StateSchema, TSelected = unknown> =
22
+ string | string[] | ((state: TState) => TSelected) | undefined;
23
+
24
+ /**
25
+ * Context provided to action functions
26
+ */
27
+ export interface ActionContext<TState = StateSchema> {
28
+ /** Commits the modified state, triggering subscriptions */
29
+ commit: (nextState: TState) => void;
30
+ /** A mutable clone of the current state */
31
+ state: TState;
8
32
  }
9
33
 
10
- export type ActionFunction<TArgs extends any[] = any[], TReturn = void> = (
11
- context: ActionContext,
34
+ /**
35
+ * Function signature for action definitions
36
+ */
37
+ export type ActionFunction<
38
+ TState = StateSchema,
39
+ TArgs extends unknown[] = unknown[],
40
+ TReturn = void,
41
+ > = (context: ActionContext<TState>, ...args: TArgs) => TReturn;
42
+
43
+ /**
44
+ * The callable action returned by action()
45
+ */
46
+ export type Action<TArgs extends unknown[] = unknown[], TReturn = void> = (
12
47
  ...args: TArgs
13
48
  ) => TReturn;
14
49
 
15
- export type Action<TArgs extends any[] = any[], TReturn = void> = (...args: TArgs) => TReturn;
16
-
17
- export type SubscriberCallback<T = any> = (
18
- nextState: T,
19
- prevState: T,
20
- nextRootState: any
50
+ /**
51
+ * Callback function for state change subscriptions
52
+ */
53
+ export type SubscriberCallback<TSelected = unknown, TState = StateSchema> = (
54
+ nextState: TSelected,
55
+ prevState: TSelected,
56
+ nextRootState: TState,
21
57
  ) => void;
22
58
 
23
- export type Subscription = SubscriberCallback;
59
+ /**
60
+ * A subscription handle returned by subscribe functions, used for unsubscribing
61
+ */
62
+ export type Subscription<
63
+ TSelected = unknown,
64
+ TState = StateSchema,
65
+ > = SubscriberCallback<TSelected, TState>;
24
66
 
25
- export type GetterFunction = (parent: any, root: any) => any;
67
+ /**
68
+ * Function signature for getters (computed properties)
69
+ * @param parent - The parent object on which the getter is defined
70
+ * @param root - The root state object
71
+ */
72
+ export type GetterFunction<TState = StateSchema, TReturn = unknown> = (
73
+ parent: unknown,
74
+ root: TState,
75
+ ) => TReturn;
26
76
 
27
77
  /**
28
- * Create an action that can modify state
78
+ * Log entry for state change differences
29
79
  */
30
- export function action<TArgs extends any[] = any[], TReturn = void>(
31
- fn: ActionFunction<TArgs, TReturn>
80
+ export interface LogDiffEntry {
81
+ changeType: "New" | "Changed" | "Deleted" | "Array changed";
82
+ from: unknown;
83
+ to: unknown;
84
+ }
85
+
86
+ /**
87
+ * Properties passed to the logger function
88
+ */
89
+ export type LogProperties = Record<string, LogDiffEntry>;
90
+
91
+ /**
92
+ * Logger function signature for startLogging
93
+ */
94
+ export type LoggerFunction = (
95
+ properties: LogProperties,
96
+ columns: ["changeType", "from", "to"],
97
+ ) => void;
98
+
99
+ /**
100
+ * Create an action that can modify state.
101
+ * Actions receive a context with a mutable state clone and a commit function.
102
+ *
103
+ * @example
104
+ * const incrementCount = action(({ commit, state }) => {
105
+ * state.count = (state.count || 0) + 1;
106
+ * commit(state);
107
+ * });
108
+ */
109
+ export function action<TArgs extends unknown[] = unknown[], TReturn = void>(
110
+ fn: ActionFunction<StateSchema, TArgs, TReturn>,
32
111
  ): Action<TArgs, TReturn>;
33
112
 
34
113
  /**
35
- * Get the current state or a subset of it
114
+ * Get the current state or a subset of it.
115
+ *
116
+ * @example
117
+ * getState(); // returns full state
118
+ * getState('user.name'); // returns state.user.name
119
+ * getState(['count', 'user.name']); // returns [state.count, state.user.name]
120
+ * getState(state => state.count * 2); // returns computed value
36
121
  */
37
- export function getState(): any;
38
- export function getState<T = any>(selector: string): T;
39
- export function getState<T = any>(selector: string[]): T[];
40
- export function getState<T = any>(selector: (state: any) => T): T;
122
+ export function getState(): StateSchema;
123
+ export function getState<T = unknown>(selector: string): T;
124
+ export function getState<T = unknown>(selector: string[]): T[];
125
+ export function getState<T = unknown>(selector: (state: StateSchema) => T): T;
41
126
 
42
127
  /**
43
- * Set state at the given selector path
128
+ * Set state at the given selector path.
129
+ * If selector is undefined, null, or empty string, replaces the entire state.
130
+ *
131
+ * @example
132
+ * setState('count', 1);
133
+ * setState('user.name', 'Alice');
134
+ * setState('', { count: 0 }); // replaces entire state
44
135
  */
45
- export const setState: Action<[selector: string | undefined | null, value: any], void>;
136
+ export const setState: Action<
137
+ [selector: string | undefined | null, value: unknown],
138
+ void
139
+ >;
46
140
 
47
141
  /**
48
- * Set immutable state at the given selector path
142
+ * Set immutable state at the given selector path.
143
+ * Immutable objects can be replaced or deleted, but not mutated.
144
+ * Attempting to mutate an immutable object will throw an error.
145
+ *
146
+ * @param selector - A non-empty dot-notation path string
147
+ * @param obj - A plain object to store as immutable
49
148
  */
50
- export function setImmutableState(selector: string, obj: Record<string, any>): void;
149
+ export function setImmutableState(
150
+ selector: string,
151
+ obj: Record<string, unknown>,
152
+ ): void;
51
153
 
52
154
  /**
53
- * Subscribe to state changes
155
+ * Subscribe to state changes.
156
+ * Returns a subscription handle for unsubscribing.
157
+ *
158
+ * @param callback - Function called when selected state changes
159
+ * @param selector - Optional selector to filter which state changes trigger the callback
160
+ * @param isSync - If true, callback is called synchronously; otherwise debounced to next tick
161
+ *
162
+ * @example
163
+ * const subscription = subscribe((count) => console.log(count), 'count');
164
+ * unsubscribe(subscription);
54
165
  */
55
- export function subscribe<T = any>(
166
+ export function subscribe<T = unknown>(
56
167
  callback: SubscriberCallback<T>,
57
- selector?: Selector<T>,
58
- isSync?: boolean
59
- ): Subscription;
168
+ selector?: Selector<StateSchema, T>,
169
+ isSync?: boolean,
170
+ ): Subscription<T>;
60
171
 
61
172
  /**
62
- * Subscribe to state changes synchronously
173
+ * Subscribe to state changes synchronously.
174
+ * Callbacks are invoked immediately on each state change.
63
175
  */
64
- export function subscribeSync<T = any>(
176
+ export function subscribeSync<T = unknown>(
65
177
  callback: SubscriberCallback<T>,
66
- selector?: Selector<T>
67
- ): Subscription;
178
+ selector?: Selector<StateSchema, T>,
179
+ ): Subscription<T>;
68
180
 
69
181
  /**
70
- * Subscribe to a single state change
182
+ * Subscribe to a single state change, then automatically unsubscribe.
71
183
  */
72
- export function subscribeOnce<T = any>(
184
+ export function subscribeOnce<T = unknown>(
73
185
  callback: SubscriberCallback<T>,
74
- selector?: Selector<T>,
75
- isSync?: boolean
76
- ): Subscription;
186
+ selector?: Selector<StateSchema, T>,
187
+ isSync?: boolean,
188
+ ): Subscription<T>;
77
189
 
78
190
  /**
79
- * Subscribe to a single state change synchronously
191
+ * Subscribe to a single state change synchronously, then automatically unsubscribe.
80
192
  */
81
- export function subscribeOnceSync<T = any>(
193
+ export function subscribeOnceSync<T = unknown>(
82
194
  callback: SubscriberCallback<T>,
83
- selector?: Selector<T>
84
- ): Subscription;
195
+ selector?: Selector<StateSchema, T>,
196
+ ): Subscription<T>;
85
197
 
86
198
  /**
87
- * Unsubscribe from state changes
199
+ * Unsubscribe from state changes.
200
+ * Pass the subscription handle returned by subscribe functions.
88
201
  */
89
202
  export function unsubscribe(subscription: Subscription): void;
90
203
 
91
204
  /**
92
- * Unsubscribe all subscribers
205
+ * Unsubscribe all subscribers (both async and sync).
93
206
  */
94
207
  export function unsubscribeAll(): void;
95
208
 
96
209
  /**
97
- * Define a getter (computed property) on the state
210
+ * Define a getter (computed property) on the state.
211
+ * Getters are re-evaluated on each access.
212
+ *
213
+ * @param path - Dot-notation path or array path for the getter
214
+ * @param fn - Function that computes the getter value
215
+ * @param enumerable - Whether the property shows up during enumeration (default: false)
216
+ *
217
+ * @example
218
+ * defineGetter('countTimesTwo', (parent) => parent.count * 2);
219
+ * defineGetter('nested.computed', (parent, root) => parent.value + root.count);
98
220
  */
99
221
  export const defineGetter: Action<
100
222
  [path: string | string[], fn: GetterFunction, enumerable?: boolean],
@@ -102,24 +224,28 @@ export const defineGetter: Action<
102
224
  >;
103
225
 
104
226
  /**
105
- * Start logging state changes
227
+ * Start logging state changes to the console.
228
+ * Uses console.table by default to display a diff of changes.
229
+ *
230
+ * @param selector - Optional selector to filter which changes are logged
231
+ * @param logger - Optional custom logger function (default: console.table)
106
232
  */
107
233
  export function startLogging(
108
234
  selector?: Selector,
109
- logger?: (properties: any, columns: string[]) => void
235
+ logger?: LoggerFunction,
110
236
  ): void;
111
237
 
112
238
  /**
113
- * Stop logging state changes
239
+ * Stop logging state changes.
114
240
  */
115
241
  export function stopLogging(): void;
116
242
 
117
243
  /**
118
- * Async subscribers set
244
+ * Set of async subscribers (debounced to next tick)
119
245
  */
120
246
  export const subscribersAsync: Set<SubscriberCallback>;
121
247
 
122
248
  /**
123
- * Sync subscribers set
249
+ * Set of sync subscribers (called immediately)
124
250
  */
125
251
  export const subscribersSync: Set<SubscriberCallback>;
@@ -1 +1 @@
1
- import{get as H,set as U}from"lodash-es";var x="__statezero__root";function b(t){return t?t[x]:void 0}function d(t,e){Object.defineProperty(t,x,{enumerable:!1,value:e})}import{get as P,isPlainObject as _,set as J}from"lodash-es";import I from"simple-deep-freeze";import{cloneDeepWith as z,isPlainObject as R}from"lodash-es";var A="__statezero_immutable";function y(t){return t&&t[A]===!0}function O(t){Object.defineProperty(t,A,{enumerable:!1,value:!0})}var j=(t,e)=>typeof e=="object"?z(e,t):e,E=t=>{let e=new WeakMap,r,i=n=>{if(n instanceof Element||typeof n=="function"||y(n))return n;if(!R(n))return;let o=e.get(n);if(o)return o;if(o={},e.set(n,o),r||(r=o),!b(n)){for(let s of Object.getOwnPropertyNames(n))s.startsWith("__statezero")||s.startsWith("$jscomp")||(o[s]=j(i,n[s]));return o}d(o,r);for(let[s,c]of Object.entries(Object.getOwnPropertyDescriptors(n)))if(!(s.startsWith("__statezero")||s.startsWith("$jscomp"))){if(c.get){Object.defineProperty(o,s,c);continue}c.enumerable&&(o[s]=j(i,c.value))}return o};return z(t,i)};import{get as N,isEqualWith as D}from"lodash-es";var p=new Set,m=new Set,W=(t,e)=>y(t)?t===e:void 0,$=(t,e)=>(r,i)=>{let n=e(r),o=e(i);D(n,o,W)||t(n,o,r)},T=t=>(e,r)=>{t(e,r,e)},F=t=>e=>t.map(r=>N(e,r)),L=t=>e=>N(e,t),g=(t,e,r=!1)=>{if(typeof e=="string"?e=L(e):Array.isArray(e)&&(e=F(e)),typeof e=="function")t=$(t,e);else if(e===void 0)t=T(t);else{let i=typeof e=="object"?JSON.stringify(e):e;throw new Error(`statezero: subscribe() must be called with an Array/Function/String/undefined selector; not ${i}`)}return r?m.add(t):p.add(t),t},ot=(t,e)=>g(t,e,!0),C=(t,e,r=!1)=>{let n=g((...o)=>{t(...o),h(n)},e,r);return n},nt=(t,e)=>C(t,e,!0),h=t=>{p.delete(t),m.delete(t)},it=()=>{p.clear(),m.clear()};var f=I({}),l,M=t=>{l===void 0&&(l=t,setTimeout(()=>{let e=l;l=void 0;for(let r of p)r(f,e)}))},q=t=>{for(let e of m)e(f,t)},G=t=>{if(!_(t))throw new Error(`statezero: commit() must be called with a plain object "nextState" argument; not: ${t}`);let e=f;f=I(t),M(e),q(e)},w=t=>(...e)=>t({commit:G,state:E(f)},...e),at=t=>{if(t===void 0)return f;if(typeof t=="string")return P(f,t);if(Array.isArray(t))return t.map(r=>P(f,r));if(typeof t=="function")return t(f);let e=typeof t=="object"?JSON.stringify(t):t;throw new Error(`statezero: getState() must be called with an Array/Function/String/undefined selector; not ${e}`)},B=w(({commit:t,state:e},r,i)=>{if(r==null||r==="")e=i;else if(typeof r=="string")J(e,r,i);else{let n=typeof r=="object"?JSON.stringify(r):r;throw new Error(`statezero: setState() must be called with an String/undefined "selector" argument; not ${n}`)}t(e)}),bt=(t,e)=>{if(!t)throw new Error('statezero: setImmutableState() must be called with a non-empty String "selector" argument');if(!_(e))throw new Error(`statezero: setImmutableState() must be called with a plain object "obj" argument; not: ${e}`);O(e),B(t,e)};var St=w(({commit:t,state:e},r,i,n=!1)=>{let o=Array.isArray(r)?r:r.split("."),s=o.length-1,c=o[s],S=o.slice(0,s),a=e;S.length&&(a=H(e,S,{}),U(e,S,a)),Object.defineProperty(a,c,{get(){return i.call(this,this,b(this))},enumerable:n}),d(a,e),t(e)});import Y from"deep-diff";var u,K={A:"Array changed",D:"Deleted",E:"Changed",N:"New"},Q=t=>(e,r)=>{let i={},n=Y(r,e);if(n!==void 0){for(let o of n){let{path:s}=o;i[s]={changeType:K[o.kind],from:o.lhs,to:o.rhs}}t(i,["changeType","from","to"])}},At=(t,e)=>{u||(u=g(Q(e||console.table),t))},Ot=()=>{u&&(h(u),u=null)};export{w as action,St as defineGetter,at as getState,bt as setImmutableState,B as setState,At as startLogging,Ot as stopLogging,g as subscribe,C as subscribeOnce,nt as subscribeOnceSync,ot as subscribeSync,p as subscribersAsync,m as subscribersSync,h as unsubscribe,it as unsubscribeAll};
1
+ import{get as B,set as H}from"lodash-es";var x="__statezero_root";function b(t){return t?t[x]:void 0}function d(t,e){Object.defineProperty(t,x,{enumerable:!1,value:e})}import{get as P,isPlainObject as _,set as J}from"lodash-es";import I from"simple-deep-freeze";import{cloneDeepWith as z,isPlainObject as R}from"lodash-es";var A="__statezero_immutable";function l(t){return t&&t[A]===!0}function O(t){Object.defineProperty(t,A,{enumerable:!1,value:!0})}var j=(t,e)=>typeof e=="object"?z(e,t):e,E=t=>{let e=new WeakMap,r,i=o=>{if(o instanceof Element||typeof o=="function"||l(o))return o;if(!R(o))return;let n=e.get(o);if(n)return n;if(n={},e.set(o,n),r||(r=n),!b(o)){for(let s of Object.getOwnPropertyNames(o))s.startsWith("__statezero")||s.startsWith("$jscomp")||(n[s]=j(i,o[s]));return n}d(n,r);for(let[s,f]of Object.entries(Object.getOwnPropertyDescriptors(o)))if(!(s.startsWith("__statezero")||s.startsWith("$jscomp"))){if(f.get){Object.defineProperty(n,s,f);continue}f.enumerable&&(n[s]=j(i,f.value))}return n};return z(t,i)};import{get as N,isEqualWith as D}from"lodash-es";var p=new Set,a=new Set,W=(t,e)=>l(t)?t===e:void 0,$=(t,e)=>(r,i)=>{let o=e(r),n=e(i);D(o,n,W)||t(o,n,r)},T=t=>(e,r)=>{t(e,r,e)},F=t=>e=>t.map(r=>N(e,r)),L=t=>e=>N(e,t),y=(t,e,r=!1)=>{let i=e;typeof e=="string"?i=L(e):Array.isArray(e)&&(i=F(e));let o;if(typeof i=="function")o=$(t,i);else if(i===void 0)o=T(t);else{let n=typeof e=="object"?JSON.stringify(e):e;throw new Error(`statezero: subscribe() must be called with an Array/Function/String/undefined selector; not ${n}`)}return r?a.add(o):p.add(o),o},ot=(t,e)=>y(t,e,!0),C=(t,e,r=!1)=>{let o=y((...n)=>{t(...n),h(o)},e,r);return o},nt=(t,e)=>C(t,e,!0),h=t=>{p.delete(t),a.delete(t)},it=()=>{p.clear(),a.clear()};var c=I({}),g,M=t=>{g===void 0&&(g=t,setTimeout(()=>{let e=g;g=void 0;for(let r of p)r(c,e)}))},k=t=>{for(let e of a)e(c,t)},q=t=>{if(!_(t))throw new Error(`statezero: commit() must be called with a plain object "nextState" argument; not: ${t}`);let e=c;c=I(t),M(e),k(e)},w=t=>(...e)=>t({commit:q,state:E(c)},...e),ut=t=>{if(t===void 0)return c;if(typeof t=="string")return P(c,t);if(Array.isArray(t))return t.map(r=>P(c,r));if(typeof t=="function")return t(c);let e=typeof t=="object"?JSON.stringify(t):t;throw new Error(`statezero: getState() must be called with an Array/Function/String/undefined selector; not ${e}`)},G=w(({commit:t,state:e},r,i)=>{let o=e;if(r==null||r==="")o=i;else if(typeof r=="string")J(e,r,i);else{let n=typeof r=="object"?JSON.stringify(r):r;throw new Error(`statezero: setState() must be called with an String/undefined "selector" argument; not ${n}`)}t(o)}),bt=(t,e)=>{if(!t)throw new Error('statezero: setImmutableState() must be called with a non-empty String "selector" argument');if(!_(e))throw new Error(`statezero: setImmutableState() must be called with a plain object "obj" argument; not: ${e}`);O(e),G(t,e)};var St=w(({commit:t,state:e},r,i,o=!1)=>{let n=Array.isArray(r)?r:r.split("."),s=n.length-1,f=n[s],S=n.slice(0,s),u=e;S.length&&(u=B(e,S,{}),H(e,S,u)),Object.defineProperty(u,f,{enumerable:o,get(){return i.call(this,this,b(this))}}),d(u,e),t(e)});import U from"deep-diff";var m,Y={A:"Array changed",D:"Deleted",E:"Changed",N:"New"},K=t=>(e,r)=>{let i={},o=U(r,e);if(o!==void 0){for(let n of o){let{path:s}=n;i[s]={changeType:Y[n.kind],from:n.lhs,to:n.rhs}}t(i,["changeType","from","to"])}},At=(t,e)=>{m||(m=y(K(e||console.table),t))},Ot=()=>{m&&(h(m),m=null)};export{w as action,St as defineGetter,ut as getState,bt as setImmutableState,G as setState,At as startLogging,Ot as stopLogging,y as subscribe,C as subscribeOnce,nt as subscribeOnceSync,ot as subscribeSync,p as subscribersAsync,a as subscribersSync,h as unsubscribe,it as unsubscribeAll};
package/dist/statezero.js CHANGED
@@ -1,11 +1,11 @@
1
- var statezero=(()=>{var qo=Object.create;var Ee=Object.defineProperty;var $o=Object.getOwnPropertyDescriptor;var Jo=Object.getOwnPropertyNames;var Yo=Object.getPrototypeOf,Xo=Object.prototype.hasOwnProperty;var _t=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Zo=(e,t)=>{for(var r in t)Ee(e,r,{get:t[r],enumerable:!0})},wt=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of Jo(t))!Xo.call(e,p)&&p!==r&&Ee(e,p,{get:()=>t[p],enumerable:!(o=$o(t,p))||o.enumerable});return e};var St=(e,t,r)=>(r=e!=null?qo(Yo(e)):{},wt(t||!e||!e.__esModule?Ee(r,"default",{value:e,enumerable:!0}):r,e)),Vo=e=>wt(Ee({},"__esModule",{value:!0}),e);var No=_t((Yy,Lo)=>{"use strict";Lo.exports=function e(t){try{return t}catch{}if(Object.isFrozen(t))return t;if(!Array.isArray(t)&&Object.getPrototypeOf(t)!==Object.getPrototypeOf({}))throw new Error("simpleDeepFreeze only supports plain objects, arrays, and primitives");return Object.freeze(t),Object.keys(t).forEach(function(r){e(t[r])}),t}});var zo=_t((vt,Wo)=>{(function(e,t){var r=t(e);if(typeof define=="function"&&define.amd)define("DeepDiff",function(){return r});else if(typeof vt=="object"||typeof navigator=="object"&&navigator.product.match(/ReactNative/i))Wo.exports=r;else{var o=e.DeepDiff;r.noConflict=function(){return e.DeepDiff===r&&(e.DeepDiff=o),r},e.DeepDiff=r}})(vt,function(e){var t=["N","E","A","D"];function r(f,i){f.super_=i,f.prototype=Object.create(i.prototype,{constructor:{value:f,enumerable:!1,writable:!0,configurable:!0}})}function o(f,i){Object.defineProperty(this,"kind",{value:f,enumerable:!0}),i&&i.length&&Object.defineProperty(this,"path",{value:i,enumerable:!0})}function p(f,i,a){p.super_.call(this,"E",f),Object.defineProperty(this,"lhs",{value:i,enumerable:!0}),Object.defineProperty(this,"rhs",{value:a,enumerable:!0})}r(p,o);function n(f,i){n.super_.call(this,"N",f),Object.defineProperty(this,"rhs",{value:i,enumerable:!0})}r(n,o);function u(f,i){u.super_.call(this,"D",f),Object.defineProperty(this,"lhs",{value:i,enumerable:!0})}r(u,o);function m(f,i,a){m.super_.call(this,"A",f),Object.defineProperty(this,"index",{value:i,enumerable:!0}),Object.defineProperty(this,"item",{value:a,enumerable:!0})}r(m,o);function d(f,i,a){var s=f.slice((a||i)+1||f.length);return f.length=i<0?f.length+i:i,f.push.apply(f,s),f}function c(f){var i=typeof f;return i!=="object"?i:f===Math?"math":f===null?"null":Array.isArray(f)?"array":Object.prototype.toString.call(f)==="[object Date]"?"date":typeof f.toString=="function"&&/^\/.*\//.test(f.toString())?"regexp":"object"}function O(f){var i=0;if(f.length===0)return i;for(var a=0;a<f.length;a++){var s=f.charCodeAt(a);i=(i<<5)-i+s,i=i&i}return i}function b(f){var i=0,a=c(f);if(a==="array"){f.forEach(function(X){i+=b(X)});var s="[type: array, hash: "+i+"]";return i+O(s)}if(a==="object"){for(var l in f)if(f.hasOwnProperty(l)){var y="[ type: object, key: "+l+", value hash: "+b(f[l])+"]";i+=O(y)}return i}var x="[ type: "+a+" ; value: "+f+"]";return i+O(x)}function g(f,i,a,s,l,y,x,X){a=a||[],l=l||[],x=x||[];var E=l.slice(0);if(typeof y<"u"&&y!==null){if(s){if(typeof s=="function"&&s(E,y))return;if(typeof s=="object"){if(s.prefilter&&s.prefilter(E,y))return;if(s.normalize){var pt=s.normalize(E,y,f,i);pt&&(f=pt[0],i=pt[1])}}}E.push(y)}c(f)==="regexp"&&c(i)==="regexp"&&(f=f.toString(),i=i.toString());var st=typeof f,Ho=typeof i,A,Ae,R,Oe,At=st!=="undefined"||x&&x.length>0&&x[x.length-1].lhs&&Object.getOwnPropertyDescriptor(x[x.length-1].lhs,y),Ot=Ho!=="undefined"||x&&x.length>0&&x[x.length-1].rhs&&Object.getOwnPropertyDescriptor(x[x.length-1].rhs,y);if(!At&&Ot)a.push(new n(E,i));else if(!Ot&&At)a.push(new u(E,f));else if(c(f)!==c(i))a.push(new p(E,f,i));else if(c(f)==="date"&&f-i!==0)a.push(new p(E,f,i));else if(st==="object"&&f!==null&&i!==null){for(A=x.length-1;A>-1;--A)if(x[A].lhs===f){Oe=!0;break}if(Oe)f!==i&&a.push(new p(E,f,i));else{if(x.push({lhs:f,rhs:i}),Array.isArray(f)){for(X&&(f.sort(function(ut,lt){return b(ut)-b(lt)}),i.sort(function(ut,lt){return b(ut)-b(lt)})),A=i.length-1,Ae=f.length-1;A>Ae;)a.push(new m(E,A,new n(void 0,i[A--])));for(;Ae>A;)a.push(new m(E,Ae,new u(void 0,f[Ae--])));for(;A>=0;--A)g(f[A],i[A],a,s,E,A,x,X)}else{var Tt=Object.keys(f),Ie=Object.keys(i);for(A=0;A<Tt.length;++A)R=Tt[A],Oe=Ie.indexOf(R),Oe>=0?(g(f[R],i[R],a,s,E,R,x,X),Ie[Oe]=null):g(f[R],void 0,a,s,E,R,x,X);for(A=0;A<Ie.length;++A)R=Ie[A],R&&g(void 0,i[R],a,s,E,R,x,X)}x.length=x.length-1}}else f!==i&&(st==="number"&&isNaN(f)&&isNaN(i)||a.push(new p(E,f,i)))}function j(f,i,a,s,l){var y=[];if(g(f,i,y,s,null,null,null,l),a)for(var x=0;x<y.length;++x)a(y[x]);return y}function I(f,i,a,s,l,y,x){return g(f,i,a,s,l,y,x,!0)}function T(f,i,a,s){var l=s?function(x){x&&s.push(x)}:void 0,y=j(f,i,l,a);return s||(y.length?y:void 0)}function w(f,i,a,s){var l=s?function(x){x&&s.push(x)}:void 0,y=j(f,i,l,a,!0);return s||(y.length?y:void 0)}function S(f,i,a){if(a.path&&a.path.length){var s=f[i],l,y=a.path.length-1;for(l=0;l<y;l++)s=s[a.path[l]];switch(a.kind){case"A":S(s[a.path[l]],a.index,a.item);break;case"D":delete s[a.path[l]];break;case"E":case"N":s[a.path[l]]=a.rhs;break}}else switch(a.kind){case"A":S(f[i],a.index,a.item);break;case"D":f=d(f,i);break;case"E":case"N":f[i]=a.rhs;break}return f}function B(f,i,a){if(typeof a>"u"&&i&&~t.indexOf(i.kind)&&(a=i),f&&a&&a.kind){for(var s=f,l=-1,y=a.path?a.path.length-1:0;++l<y;)typeof s[a.path[l]]>"u"&&(s[a.path[l]]=typeof a.path[l+1]<"u"&&typeof a.path[l+1]=="number"?[]:{}),s=s[a.path[l]];switch(a.kind){case"A":a.path&&typeof s[a.path[l]]>"u"&&(s[a.path[l]]=[]),S(a.path?s[a.path[l]]:s,a.index,a.item);break;case"D":delete s[a.path[l]];break;case"E":case"N":s[a.path[l]]=a.rhs;break}}}function k(f,i,a){if(a.path&&a.path.length){var s=f[i],l,y=a.path.length-1;for(l=0;l<y;l++)s=s[a.path[l]];switch(a.kind){case"A":k(s[a.path[l]],a.index,a.item);break;case"D":s[a.path[l]]=a.lhs;break;case"E":s[a.path[l]]=a.lhs;break;case"N":delete s[a.path[l]];break}}else switch(a.kind){case"A":k(f[i],a.index,a.item);break;case"D":f[i]=a.lhs;break;case"E":f[i]=a.lhs;break;case"N":f=d(f,i);break}return f}function ee(f,i,a){if(f&&i&&a&&a.kind){var s=f,l,y;for(y=a.path.length-1,l=0;l<y;l++)typeof s[a.path[l]]>"u"&&(s[a.path[l]]={}),s=s[a.path[l]];switch(a.kind){case"A":k(s[a.path[l]],a.index,a.item);break;case"D":s[a.path[l]]=a.lhs;break;case"E":s[a.path[l]]=a.lhs;break;case"N":delete s[a.path[l]];break}}}function te(f,i,a){if(f&&i){var s=function(l){(!a||a(f,i,l))&&B(f,i,l)};j(f,i,s)}}return Object.defineProperties(T,{diff:{value:T,enumerable:!0},orderIndependentDiff:{value:w,enumerable:!0},observableDiff:{value:j,enumerable:!0},orderIndependentObservableDiff:{value:I,enumerable:!0},orderIndepHash:{value:b,enumerable:!0},applyDiff:{value:te,enumerable:!0},applyChange:{value:B,enumerable:!0},revertChange:{value:ee,enumerable:!0},isConflict:{value:function(){return typeof $conflict<"u"},enumerable:!0}}),T.DeepDiff=T,e&&(e.DeepDiff=T),T})});var zs={};Zo(zs,{action:()=>it,defineGetter:()=>Bs,getState:()=>Ms,setImmutableState:()=>Rs,setState:()=>Uo,startLogging:()=>Us,stopLogging:()=>Ws,subscribe:()=>je,subscribeOnce:()=>Go,subscribeOnceSync:()=>Es,subscribeSync:()=>Is,subscribersAsync:()=>he,subscribersSync:()=>ve,unsubscribe:()=>ft,unsubscribeAll:()=>Cs});var Qo=typeof global=="object"&&global&&global.Object===Object&&global,Ce=Qo;var ko=typeof self=="object"&&self&&self.Object===Object&&self,ea=Ce||ko||Function("return this")(),_=ea;var ta=_.Symbol,C=ta;var jt=Object.prototype,ra=jt.hasOwnProperty,oa=jt.toString,Te=C?C.toStringTag:void 0;function aa(e){var t=ra.call(e,Te),r=e[Te];try{e[Te]=void 0;var o=!0}catch{}var p=oa.call(e);return o&&(t?e[Te]=r:delete e[Te]),p}var Pt=aa;var fa=Object.prototype,na=fa.toString;function ia(e){return na.call(e)}var It=ia;var pa="[object Null]",sa="[object Undefined]",Et=C?C.toStringTag:void 0;function ua(e){return e==null?e===void 0?sa:pa:Et&&Et in Object(e)?Pt(e):It(e)}var N=ua;function la(e){return e!=null&&typeof e=="object"}var P=la;var ma="[object Symbol]";function da(e){return typeof e=="symbol"||P(e)&&N(e)==ma}var re=da;function ca(e,t){for(var r=-1,o=e==null?0:e.length,p=Array(o);++r<o;)p[r]=t(e[r],r,e);return p}var Ct=ca;var xa=Array.isArray,D=xa;var ya=1/0,Dt=C?C.prototype:void 0,Lt=Dt?Dt.toString:void 0;function Nt(e){if(typeof e=="string")return e;if(D(e))return Ct(e,Nt)+"";if(re(e))return Lt?Lt.call(e):"";var t=e+"";return t=="0"&&1/e==-ya?"-0":t}var Mt=Nt;function ba(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var M=ba;var ga="[object AsyncFunction]",ha="[object Function]",va="[object GeneratorFunction]",Aa="[object Proxy]";function Oa(e){if(!M(e))return!1;var t=N(e);return t==ha||t==va||t==ga||t==Aa}var De=Oa;var Ta=_["__core-js_shared__"],Le=Ta;var Rt=(function(){var e=/[^.]+$/.exec(Le&&Le.keys&&Le.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})();function _a(e){return!!Rt&&Rt in e}var Bt=_a;var wa=Function.prototype,Sa=wa.toString;function ja(e){if(e!=null){try{return Sa.call(e)}catch{}try{return e+""}catch{}}return""}var F=ja;var Pa=/[\\^$.*+?()[\]{}|]/g,Ia=/^\[object .+?Constructor\]$/,Ea=Function.prototype,Ca=Object.prototype,Da=Ea.toString,La=Ca.hasOwnProperty,Na=RegExp("^"+Da.call(La).replace(Pa,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ma(e){if(!M(e)||Bt(e))return!1;var t=De(e)?Na:Ia;return t.test(F(e))}var Ft=Ma;function Ra(e,t){return e?.[t]}var Gt=Ra;function Ba(e,t){var r=Gt(e,t);return Ft(r)?r:void 0}var L=Ba;var Fa=L(_,"WeakMap"),Ne=Fa;var Ut=Object.create,Ga=(function(){function e(){}return function(t){if(!M(t))return{};if(Ut)return Ut(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}})(),Wt=Ga;function Ua(e,t){var r=-1,o=e.length;for(t||(t=Array(o));++r<o;)t[r]=e[r];return t}var zt=Ua;var Wa=(function(){try{var e=L(Object,"defineProperty");return e({},"",{}),e}catch{}})(),mt=Wa;function za(e,t){for(var r=-1,o=e==null?0:e.length;++r<o&&t(e[r],r,e)!==!1;);return e}var Kt=za;var Ka=9007199254740991,Ha=/^(?:0|[1-9]\d*)$/;function qa(e,t){var r=typeof e;return t=t??Ka,!!t&&(r=="number"||r!="symbol"&&Ha.test(e))&&e>-1&&e%1==0&&e<t}var Me=qa;function $a(e,t,r){t=="__proto__"&&mt?mt(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}var Re=$a;function Ja(e,t){return e===t||e!==e&&t!==t}var oe=Ja;var Ya=Object.prototype,Xa=Ya.hasOwnProperty;function Za(e,t,r){var o=e[t];(!(Xa.call(e,t)&&oe(o,r))||r===void 0&&!(t in e))&&Re(e,t,r)}var ae=Za;function Va(e,t,r,o){var p=!r;r||(r={});for(var n=-1,u=t.length;++n<u;){var m=t[n],d=o?o(r[m],e[m],m,r,e):void 0;d===void 0&&(d=e[m]),p?Re(r,m,d):ae(r,m,d)}return r}var H=Va;var Qa=9007199254740991;function ka(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Qa}var Be=ka;function ef(e){return e!=null&&Be(e.length)&&!De(e)}var Fe=ef;var tf=Object.prototype;function rf(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||tf;return e===r}var fe=rf;function of(e,t){for(var r=-1,o=Array(e);++r<e;)o[r]=t(r);return o}var Ht=of;var af="[object Arguments]";function ff(e){return P(e)&&N(e)==af}var dt=ff;var qt=Object.prototype,nf=qt.hasOwnProperty,pf=qt.propertyIsEnumerable,sf=dt((function(){return arguments})())?dt:function(e){return P(e)&&nf.call(e,"callee")&&!pf.call(e,"callee")},$t=sf;function uf(){return!1}var Jt=uf;var Zt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Yt=Zt&&typeof module=="object"&&module&&!module.nodeType&&module,lf=Yt&&Yt.exports===Zt,Xt=lf?_.Buffer:void 0,mf=Xt?Xt.isBuffer:void 0,df=mf||Jt,Z=df;var cf="[object Arguments]",xf="[object Array]",yf="[object Boolean]",bf="[object Date]",gf="[object Error]",hf="[object Function]",vf="[object Map]",Af="[object Number]",Of="[object Object]",Tf="[object RegExp]",_f="[object Set]",wf="[object String]",Sf="[object WeakMap]",jf="[object ArrayBuffer]",Pf="[object DataView]",If="[object Float32Array]",Ef="[object Float64Array]",Cf="[object Int8Array]",Df="[object Int16Array]",Lf="[object Int32Array]",Nf="[object Uint8Array]",Mf="[object Uint8ClampedArray]",Rf="[object Uint16Array]",Bf="[object Uint32Array]",v={};v[If]=v[Ef]=v[Cf]=v[Df]=v[Lf]=v[Nf]=v[Mf]=v[Rf]=v[Bf]=!0;v[cf]=v[xf]=v[jf]=v[yf]=v[Pf]=v[bf]=v[gf]=v[hf]=v[vf]=v[Af]=v[Of]=v[Tf]=v[_f]=v[wf]=v[Sf]=!1;function Ff(e){return P(e)&&Be(e.length)&&!!v[N(e)]}var Vt=Ff;function Gf(e){return function(t){return e(t)}}var ne=Gf;var Qt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,_e=Qt&&typeof module=="object"&&module&&!module.nodeType&&module,Uf=_e&&_e.exports===Qt,ct=Uf&&Ce.process,Wf=(function(){try{var e=_e&&_e.require&&_e.require("util").types;return e||ct&&ct.binding&&ct.binding("util")}catch{}})(),G=Wf;var kt=G&&G.isTypedArray,zf=kt?ne(kt):Vt,Ge=zf;var Kf=Object.prototype,Hf=Kf.hasOwnProperty;function qf(e,t){var r=D(e),o=!r&&$t(e),p=!r&&!o&&Z(e),n=!r&&!o&&!p&&Ge(e),u=r||o||p||n,m=u?Ht(e.length,String):[],d=m.length;for(var c in e)(t||Hf.call(e,c))&&!(u&&(c=="length"||p&&(c=="offset"||c=="parent")||n&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Me(c,d)))&&m.push(c);return m}var Ue=qf;function $f(e,t){return function(r){return e(t(r))}}var We=$f;var Jf=We(Object.keys,Object),er=Jf;var Yf=Object.prototype,Xf=Yf.hasOwnProperty;function Zf(e){if(!fe(e))return er(e);var t=[];for(var r in Object(e))Xf.call(e,r)&&r!="constructor"&&t.push(r);return t}var tr=Zf;function Vf(e){return Fe(e)?Ue(e):tr(e)}var ie=Vf;function Qf(e){var t=[];if(e!=null)for(var r in Object(e))t.push(r);return t}var rr=Qf;var kf=Object.prototype,en=kf.hasOwnProperty;function tn(e){if(!M(e))return rr(e);var t=fe(e),r=[];for(var o in e)o=="constructor"&&(t||!en.call(e,o))||r.push(o);return r}var or=tn;function rn(e){return Fe(e)?Ue(e,!0):or(e)}var pe=rn;var on=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,an=/^\w*$/;function fn(e,t){if(D(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||re(e)?!0:an.test(e)||!on.test(e)||t!=null&&e in Object(t)}var ar=fn;var nn=L(Object,"create"),U=nn;function pn(){this.__data__=U?U(null):{},this.size=0}var fr=pn;function sn(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var nr=sn;var un="__lodash_hash_undefined__",ln=Object.prototype,mn=ln.hasOwnProperty;function dn(e){var t=this.__data__;if(U){var r=t[e];return r===un?void 0:r}return mn.call(t,e)?t[e]:void 0}var ir=dn;var cn=Object.prototype,xn=cn.hasOwnProperty;function yn(e){var t=this.__data__;return U?t[e]!==void 0:xn.call(t,e)}var pr=yn;var bn="__lodash_hash_undefined__";function gn(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=U&&t===void 0?bn:t,this}var sr=gn;function se(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var o=e[t];this.set(o[0],o[1])}}se.prototype.clear=fr;se.prototype.delete=nr;se.prototype.get=ir;se.prototype.has=pr;se.prototype.set=sr;var xt=se;function hn(){this.__data__=[],this.size=0}var ur=hn;function vn(e,t){for(var r=e.length;r--;)if(oe(e[r][0],t))return r;return-1}var q=vn;var An=Array.prototype,On=An.splice;function Tn(e){var t=this.__data__,r=q(t,e);if(r<0)return!1;var o=t.length-1;return r==o?t.pop():On.call(t,r,1),--this.size,!0}var lr=Tn;function _n(e){var t=this.__data__,r=q(t,e);return r<0?void 0:t[r][1]}var mr=_n;function wn(e){return q(this.__data__,e)>-1}var dr=wn;function Sn(e,t){var r=this.__data__,o=q(r,e);return o<0?(++this.size,r.push([e,t])):r[o][1]=t,this}var cr=Sn;function ue(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var o=e[t];this.set(o[0],o[1])}}ue.prototype.clear=ur;ue.prototype.delete=lr;ue.prototype.get=mr;ue.prototype.has=dr;ue.prototype.set=cr;var $=ue;var jn=L(_,"Map"),J=jn;function Pn(){this.size=0,this.__data__={hash:new xt,map:new(J||$),string:new xt}}var xr=Pn;function In(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var yr=In;function En(e,t){var r=e.__data__;return yr(t)?r[typeof t=="string"?"string":"hash"]:r.map}var Y=En;function Cn(e){var t=Y(this,e).delete(e);return this.size-=t?1:0,t}var br=Cn;function Dn(e){return Y(this,e).get(e)}var gr=Dn;function Ln(e){return Y(this,e).has(e)}var hr=Ln;function Nn(e,t){var r=Y(this,e),o=r.size;return r.set(e,t),this.size+=r.size==o?0:1,this}var vr=Nn;function le(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var o=e[t];this.set(o[0],o[1])}}le.prototype.clear=xr;le.prototype.delete=br;le.prototype.get=gr;le.prototype.has=hr;le.prototype.set=vr;var V=le;var Mn="Expected a function";function yt(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(Mn);var r=function(){var o=arguments,p=t?t.apply(this,o):o[0],n=r.cache;if(n.has(p))return n.get(p);var u=e.apply(this,o);return r.cache=n.set(p,u)||n,u};return r.cache=new(yt.Cache||V),r}yt.Cache=V;var Ar=yt;var Rn=500;function Bn(e){var t=Ar(e,function(o){return r.size===Rn&&r.clear(),o}),r=t.cache;return t}var Or=Bn;var Fn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Gn=/\\(\\)?/g,Un=Or(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Fn,function(r,o,p,n){t.push(p?n.replace(Gn,"$1"):o||r)}),t}),Tr=Un;function Wn(e){return e==null?"":Mt(e)}var _r=Wn;function zn(e,t){return D(e)?e:ar(e,t)?[e]:Tr(_r(e))}var ze=zn;var Kn=1/0;function Hn(e){if(typeof e=="string"||re(e))return e;var t=e+"";return t=="0"&&1/e==-Kn?"-0":t}var Ke=Hn;function qn(e,t){t=ze(t,e);for(var r=0,o=t.length;e!=null&&r<o;)e=e[Ke(t[r++])];return r&&r==o?e:void 0}var wr=qn;function $n(e,t,r){var o=e==null?void 0:wr(e,t);return o===void 0?r:o}var W=$n;function Jn(e,t){for(var r=-1,o=t.length,p=e.length;++r<o;)e[p+r]=t[r];return e}var He=Jn;var Yn=We(Object.getPrototypeOf,Object),me=Yn;var Xn="[object Object]",Zn=Function.prototype,Vn=Object.prototype,Sr=Zn.toString,Qn=Vn.hasOwnProperty,kn=Sr.call(Object);function ei(e){if(!P(e)||N(e)!=Xn)return!1;var t=me(e);if(t===null)return!0;var r=Qn.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Sr.call(r)==kn}var de=ei;function ti(){this.__data__=new $,this.size=0}var jr=ti;function ri(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var Pr=ri;function oi(e){return this.__data__.get(e)}var Ir=oi;function ai(e){return this.__data__.has(e)}var Er=ai;var fi=200;function ni(e,t){var r=this.__data__;if(r instanceof $){var o=r.__data__;if(!J||o.length<fi-1)return o.push([e,t]),this.size=++r.size,this;r=this.__data__=new V(o)}return r.set(e,t),this.size=r.size,this}var Cr=ni;function ce(e){var t=this.__data__=new $(e);this.size=t.size}ce.prototype.clear=jr;ce.prototype.delete=Pr;ce.prototype.get=Ir;ce.prototype.has=Er;ce.prototype.set=Cr;var xe=ce;function ii(e,t){return e&&H(t,ie(t),e)}var Dr=ii;function pi(e,t){return e&&H(t,pe(t),e)}var Lr=pi;var Br=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Nr=Br&&typeof module=="object"&&module&&!module.nodeType&&module,si=Nr&&Nr.exports===Br,Mr=si?_.Buffer:void 0,Rr=Mr?Mr.allocUnsafe:void 0;function ui(e,t){if(t)return e.slice();var r=e.length,o=Rr?Rr(r):new e.constructor(r);return e.copy(o),o}var Fr=ui;function li(e,t){for(var r=-1,o=e==null?0:e.length,p=0,n=[];++r<o;){var u=e[r];t(u,r,e)&&(n[p++]=u)}return n}var Gr=li;function mi(){return[]}var qe=mi;var di=Object.prototype,ci=di.propertyIsEnumerable,Ur=Object.getOwnPropertySymbols,xi=Ur?function(e){return e==null?[]:(e=Object(e),Gr(Ur(e),function(t){return ci.call(e,t)}))}:qe,ye=xi;function yi(e,t){return H(e,ye(e),t)}var Wr=yi;var bi=Object.getOwnPropertySymbols,gi=bi?function(e){for(var t=[];e;)He(t,ye(e)),e=me(e);return t}:qe,$e=gi;function hi(e,t){return H(e,$e(e),t)}var zr=hi;function vi(e,t,r){var o=t(e);return D(e)?o:He(o,r(e))}var Je=vi;function Ai(e){return Je(e,ie,ye)}var we=Ai;function Oi(e){return Je(e,pe,$e)}var Kr=Oi;var Ti=L(_,"DataView"),Ye=Ti;var _i=L(_,"Promise"),Xe=_i;var wi=L(_,"Set"),Ze=wi;var Hr="[object Map]",Si="[object Object]",qr="[object Promise]",$r="[object Set]",Jr="[object WeakMap]",Yr="[object DataView]",ji=F(Ye),Pi=F(J),Ii=F(Xe),Ei=F(Ze),Ci=F(Ne),Q=N;(Ye&&Q(new Ye(new ArrayBuffer(1)))!=Yr||J&&Q(new J)!=Hr||Xe&&Q(Xe.resolve())!=qr||Ze&&Q(new Ze)!=$r||Ne&&Q(new Ne)!=Jr)&&(Q=function(e){var t=N(e),r=t==Si?e.constructor:void 0,o=r?F(r):"";if(o)switch(o){case ji:return Yr;case Pi:return Hr;case Ii:return qr;case Ei:return $r;case Ci:return Jr}return t});var z=Q;var Di=Object.prototype,Li=Di.hasOwnProperty;function Ni(e){var t=e.length,r=new e.constructor(t);return t&&typeof e[0]=="string"&&Li.call(e,"index")&&(r.index=e.index,r.input=e.input),r}var Xr=Ni;var Mi=_.Uint8Array,be=Mi;function Ri(e){var t=new e.constructor(e.byteLength);return new be(t).set(new be(e)),t}var ge=Ri;function Bi(e,t){var r=t?ge(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}var Zr=Bi;var Fi=/\w*$/;function Gi(e){var t=new e.constructor(e.source,Fi.exec(e));return t.lastIndex=e.lastIndex,t}var Vr=Gi;var Qr=C?C.prototype:void 0,kr=Qr?Qr.valueOf:void 0;function Ui(e){return kr?Object(kr.call(e)):{}}var eo=Ui;function Wi(e,t){var r=t?ge(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}var to=Wi;var zi="[object Boolean]",Ki="[object Date]",Hi="[object Map]",qi="[object Number]",$i="[object RegExp]",Ji="[object Set]",Yi="[object String]",Xi="[object Symbol]",Zi="[object ArrayBuffer]",Vi="[object DataView]",Qi="[object Float32Array]",ki="[object Float64Array]",ep="[object Int8Array]",tp="[object Int16Array]",rp="[object Int32Array]",op="[object Uint8Array]",ap="[object Uint8ClampedArray]",fp="[object Uint16Array]",np="[object Uint32Array]";function ip(e,t,r){var o=e.constructor;switch(t){case Zi:return ge(e);case zi:case Ki:return new o(+e);case Vi:return Zr(e,r);case Qi:case ki:case ep:case tp:case rp:case op:case ap:case fp:case np:return to(e,r);case Hi:return new o;case qi:case Yi:return new o(e);case $i:return Vr(e);case Ji:return new o;case Xi:return eo(e)}}var ro=ip;function pp(e){return typeof e.constructor=="function"&&!fe(e)?Wt(me(e)):{}}var oo=pp;var sp="[object Map]";function up(e){return P(e)&&z(e)==sp}var ao=up;var fo=G&&G.isMap,lp=fo?ne(fo):ao,no=lp;var mp="[object Set]";function dp(e){return P(e)&&z(e)==mp}var io=dp;var po=G&&G.isSet,cp=po?ne(po):io,so=cp;var xp=1,yp=2,bp=4,uo="[object Arguments]",gp="[object Array]",hp="[object Boolean]",vp="[object Date]",Ap="[object Error]",lo="[object Function]",Op="[object GeneratorFunction]",Tp="[object Map]",_p="[object Number]",mo="[object Object]",wp="[object RegExp]",Sp="[object Set]",jp="[object String]",Pp="[object Symbol]",Ip="[object WeakMap]",Ep="[object ArrayBuffer]",Cp="[object DataView]",Dp="[object Float32Array]",Lp="[object Float64Array]",Np="[object Int8Array]",Mp="[object Int16Array]",Rp="[object Int32Array]",Bp="[object Uint8Array]",Fp="[object Uint8ClampedArray]",Gp="[object Uint16Array]",Up="[object Uint32Array]",h={};h[uo]=h[gp]=h[Ep]=h[Cp]=h[hp]=h[vp]=h[Dp]=h[Lp]=h[Np]=h[Mp]=h[Rp]=h[Tp]=h[_p]=h[mo]=h[wp]=h[Sp]=h[jp]=h[Pp]=h[Bp]=h[Fp]=h[Gp]=h[Up]=!0;h[Ap]=h[lo]=h[Ip]=!1;function Ve(e,t,r,o,p,n){var u,m=t&xp,d=t&yp,c=t&bp;if(r&&(u=p?r(e,o,p,n):r(e)),u!==void 0)return u;if(!M(e))return e;var O=D(e);if(O){if(u=Xr(e),!m)return zt(e,u)}else{var b=z(e),g=b==lo||b==Op;if(Z(e))return Fr(e,m);if(b==mo||b==uo||g&&!p){if(u=d||g?{}:oo(e),!m)return d?zr(e,Lr(u,e)):Wr(e,Dr(u,e))}else{if(!h[b])return p?e:{};u=ro(e,b,m)}}n||(n=new xe);var j=n.get(e);if(j)return j;n.set(e,u),so(e)?e.forEach(function(w){u.add(Ve(w,t,r,w,e,n))}):no(e)&&e.forEach(function(w,S){u.set(S,Ve(w,t,r,S,e,n))});var I=c?d?Kr:we:d?pe:ie,T=O?void 0:I(e);return Kt(T||e,function(w,S){T&&(S=w,w=e[S]),ae(u,S,Ve(w,t,r,S,e,n))}),u}var co=Ve;var Wp=1,zp=4;function Kp(e,t){return t=typeof t=="function"?t:void 0,co(e,Wp|zp,t)}var Qe=Kp;var Hp="__lodash_hash_undefined__";function qp(e){return this.__data__.set(e,Hp),this}var xo=qp;function $p(e){return this.__data__.has(e)}var yo=$p;function ke(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new V;++t<r;)this.add(e[t])}ke.prototype.add=ke.prototype.push=xo;ke.prototype.has=yo;var bo=ke;function Jp(e,t){for(var r=-1,o=e==null?0:e.length;++r<o;)if(t(e[r],r,e))return!0;return!1}var go=Jp;function Yp(e,t){return e.has(t)}var ho=Yp;var Xp=1,Zp=2;function Vp(e,t,r,o,p,n){var u=r&Xp,m=e.length,d=t.length;if(m!=d&&!(u&&d>m))return!1;var c=n.get(e),O=n.get(t);if(c&&O)return c==t&&O==e;var b=-1,g=!0,j=r&Zp?new bo:void 0;for(n.set(e,t),n.set(t,e);++b<m;){var I=e[b],T=t[b];if(o)var w=u?o(T,I,b,t,e,n):o(I,T,b,e,t,n);if(w!==void 0){if(w)continue;g=!1;break}if(j){if(!go(t,function(S,B){if(!ho(j,B)&&(I===S||p(I,S,r,o,n)))return j.push(B)})){g=!1;break}}else if(!(I===T||p(I,T,r,o,n))){g=!1;break}}return n.delete(e),n.delete(t),g}var et=Vp;function Qp(e){var t=-1,r=Array(e.size);return e.forEach(function(o,p){r[++t]=[p,o]}),r}var vo=Qp;function kp(e){var t=-1,r=Array(e.size);return e.forEach(function(o){r[++t]=o}),r}var Ao=kp;var es=1,ts=2,rs="[object Boolean]",os="[object Date]",as="[object Error]",fs="[object Map]",ns="[object Number]",is="[object RegExp]",ps="[object Set]",ss="[object String]",us="[object Symbol]",ls="[object ArrayBuffer]",ms="[object DataView]",Oo=C?C.prototype:void 0,bt=Oo?Oo.valueOf:void 0;function ds(e,t,r,o,p,n,u){switch(r){case ms:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case ls:return!(e.byteLength!=t.byteLength||!n(new be(e),new be(t)));case rs:case os:case ns:return oe(+e,+t);case as:return e.name==t.name&&e.message==t.message;case is:case ss:return e==t+"";case fs:var m=vo;case ps:var d=o&es;if(m||(m=Ao),e.size!=t.size&&!d)return!1;var c=u.get(e);if(c)return c==t;o|=ts,u.set(e,t);var O=et(m(e),m(t),o,p,n,u);return u.delete(e),O;case us:if(bt)return bt.call(e)==bt.call(t)}return!1}var To=ds;var cs=1,xs=Object.prototype,ys=xs.hasOwnProperty;function bs(e,t,r,o,p,n){var u=r&cs,m=we(e),d=m.length,c=we(t),O=c.length;if(d!=O&&!u)return!1;for(var b=d;b--;){var g=m[b];if(!(u?g in t:ys.call(t,g)))return!1}var j=n.get(e),I=n.get(t);if(j&&I)return j==t&&I==e;var T=!0;n.set(e,t),n.set(t,e);for(var w=u;++b<d;){g=m[b];var S=e[g],B=t[g];if(o)var k=u?o(B,S,g,t,e,n):o(S,B,g,e,t,n);if(!(k===void 0?S===B||p(S,B,r,o,n):k)){T=!1;break}w||(w=g=="constructor")}if(T&&!w){var ee=e.constructor,te=t.constructor;ee!=te&&"constructor"in e&&"constructor"in t&&!(typeof ee=="function"&&ee instanceof ee&&typeof te=="function"&&te instanceof te)&&(T=!1)}return n.delete(e),n.delete(t),T}var _o=bs;var gs=1,wo="[object Arguments]",So="[object Array]",tt="[object Object]",hs=Object.prototype,jo=hs.hasOwnProperty;function vs(e,t,r,o,p,n){var u=D(e),m=D(t),d=u?So:z(e),c=m?So:z(t);d=d==wo?tt:d,c=c==wo?tt:c;var O=d==tt,b=c==tt,g=d==c;if(g&&Z(e)){if(!Z(t))return!1;u=!0,O=!1}if(g&&!O)return n||(n=new xe),u||Ge(e)?et(e,t,r,o,p,n):To(e,t,d,r,o,p,n);if(!(r&gs)){var j=O&&jo.call(e,"__wrapped__"),I=b&&jo.call(t,"__wrapped__");if(j||I){var T=j?e.value():e,w=I?t.value():t;return n||(n=new xe),p(T,w,r,o,n)}}return g?(n||(n=new xe),_o(e,t,r,o,p,n)):!1}var Po=vs;function Io(e,t,r,o,p){return e===t?!0:e==null||t==null||!P(e)&&!P(t)?e!==e&&t!==t:Po(e,t,r,o,Io,p)}var Eo=Io;function As(e,t,r){r=typeof r=="function"?r:void 0;var o=r?r(e,t):void 0;return o===void 0?Eo(e,t,void 0,r):!!o}var gt=As;function Os(e,t,r,o){if(!M(e))return e;t=ze(t,e);for(var p=-1,n=t.length,u=n-1,m=e;m!=null&&++p<n;){var d=Ke(t[p]),c=r;if(d==="__proto__"||d==="constructor"||d==="prototype")return e;if(p!=u){var O=m[d];c=o?o(O,d,m):void 0,c===void 0&&(c=M(O)?O:Me(t[p+1])?[]:{})}ae(m,d,c),m=m[d]}return e}var Co=Os;function Ts(e,t,r){return e==null?e:Co(e,t,r)}var Se=Ts;var Do="__statezero__root";function rt(e){return e?e[Do]:void 0}function ot(e,t){Object.defineProperty(e,Do,{enumerable:!1,value:t})}var ht=St(No());var Mo="__statezero_immutable";function at(e){return e&&e[Mo]===!0}function Ro(e){Object.defineProperty(e,Mo,{enumerable:!1,value:!0})}var Bo=(e,t)=>typeof t=="object"?Qe(t,e):t,Fo=e=>{let t=new WeakMap,r,o=p=>{if(p instanceof Element||typeof p=="function"||at(p))return p;if(!de(p))return;let n=t.get(p);if(n)return n;if(n={},t.set(p,n),r||(r=n),!rt(p)){for(let u of Object.getOwnPropertyNames(p))u.startsWith("__statezero")||u.startsWith("$jscomp")||(n[u]=Bo(o,p[u]));return n}ot(n,r);for(let[u,m]of Object.entries(Object.getOwnPropertyDescriptors(p)))if(!(u.startsWith("__statezero")||u.startsWith("$jscomp"))){if(m.get){Object.defineProperty(n,u,m);continue}m.enumerable&&(n[u]=Bo(o,m.value))}return n};return Qe(e,o)};var he=new Set,ve=new Set,_s=(e,t)=>at(e)?e===t:void 0,ws=(e,t)=>(r,o)=>{let p=t(r),n=t(o);gt(p,n,_s)||e(p,n,r)},Ss=e=>(t,r)=>{e(t,r,t)},js=e=>t=>e.map(r=>W(t,r)),Ps=e=>t=>W(t,e),je=(e,t,r=!1)=>{if(typeof t=="string"?t=Ps(t):Array.isArray(t)&&(t=js(t)),typeof t=="function")e=ws(e,t);else if(t===void 0)e=Ss(e);else{let o=typeof t=="object"?JSON.stringify(t):t;throw new Error(`statezero: subscribe() must be called with an Array/Function/String/undefined selector; not ${o}`)}return r?ve.add(e):he.add(e),e},Is=(e,t)=>je(e,t,!0),Go=(e,t,r=!1)=>{let p=je((...n)=>{e(...n),ft(p)},t,r);return p},Es=(e,t)=>Go(e,t,!0),ft=e=>{he.delete(e),ve.delete(e)},Cs=()=>{he.clear(),ve.clear()};var K=(0,ht.default)({}),nt,Ds=e=>{nt===void 0&&(nt=e,setTimeout(()=>{let t=nt;nt=void 0;for(let r of he)r(K,t)}))},Ls=e=>{for(let t of ve)t(K,e)},Ns=e=>{if(!de(e))throw new Error(`statezero: commit() must be called with a plain object "nextState" argument; not: ${e}`);let t=K;K=(0,ht.default)(e),Ds(t),Ls(t)},it=e=>(...t)=>e({commit:Ns,state:Fo(K)},...t),Ms=e=>{if(e===void 0)return K;if(typeof e=="string")return W(K,e);if(Array.isArray(e))return e.map(r=>W(K,r));if(typeof e=="function")return e(K);let t=typeof e=="object"?JSON.stringify(e):e;throw new Error(`statezero: getState() must be called with an Array/Function/String/undefined selector; not ${t}`)},Uo=it(({commit:e,state:t},r,o)=>{if(r==null||r==="")t=o;else if(typeof r=="string")Se(t,r,o);else{let p=typeof r=="object"?JSON.stringify(r):r;throw new Error(`statezero: setState() must be called with an String/undefined "selector" argument; not ${p}`)}e(t)}),Rs=(e,t)=>{if(!e)throw new Error('statezero: setImmutableState() must be called with a non-empty String "selector" argument');if(!de(t))throw new Error(`statezero: setImmutableState() must be called with a plain object "obj" argument; not: ${t}`);Ro(t),Uo(e,t)};var Bs=it(({commit:e,state:t},r,o,p=!1)=>{let n=Array.isArray(r)?r:r.split("."),u=n.length-1,m=n[u],d=n.slice(0,u),c=t;d.length&&(c=W(t,d,{}),Se(t,d,c)),Object.defineProperty(c,m,{get(){return o.call(this,this,rt(this))},enumerable:p}),ot(c,t),e(t)});var Ko=St(zo());var Pe,Fs={A:"Array changed",D:"Deleted",E:"Changed",N:"New"},Gs=e=>(t,r)=>{let o={},p=(0,Ko.default)(r,t);if(p!==void 0){for(let n of p){let{path:u}=n;o[u]={changeType:Fs[n.kind],from:n.lhs,to:n.rhs}}e(o,["changeType","from","to"])}},Us=(e,t)=>{Pe||(Pe=je(Gs(t||console.table),e))},Ws=()=>{Pe&&(ft(Pe),Pe=null)};return Vo(zs);})();
1
+ var statezero=(()=>{var qo=Object.create;var Ee=Object.defineProperty;var $o=Object.getOwnPropertyDescriptor;var Jo=Object.getOwnPropertyNames;var Yo=Object.getPrototypeOf,Xo=Object.prototype.hasOwnProperty;var _t=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},Zo=(e,t)=>{for(var r in t)Ee(e,r,{get:t[r],enumerable:!0})},wt=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of Jo(t))!Xo.call(e,p)&&p!==r&&Ee(e,p,{get:()=>t[p],enumerable:!(o=$o(t,p))||o.enumerable});return e};var St=(e,t,r)=>(r=e!=null?qo(Yo(e)):{},wt(t||!e||!e.__esModule?Ee(r,"default",{value:e,enumerable:!0}):r,e)),Vo=e=>wt(Ee({},"__esModule",{value:!0}),e);var No=_t((Yy,Lo)=>{"use strict";Lo.exports=function e(t){try{return t}catch{}if(Object.isFrozen(t))return t;if(!Array.isArray(t)&&Object.getPrototypeOf(t)!==Object.getPrototypeOf({}))throw new Error("simpleDeepFreeze only supports plain objects, arrays, and primitives");return Object.freeze(t),Object.keys(t).forEach(function(r){e(t[r])}),t}});var zo=_t((vt,Wo)=>{(function(e,t){var r=t(e);if(typeof define=="function"&&define.amd)define("DeepDiff",function(){return r});else if(typeof vt=="object"||typeof navigator=="object"&&navigator.product.match(/ReactNative/i))Wo.exports=r;else{var o=e.DeepDiff;r.noConflict=function(){return e.DeepDiff===r&&(e.DeepDiff=o),r},e.DeepDiff=r}})(vt,function(e){var t=["N","E","A","D"];function r(f,i){f.super_=i,f.prototype=Object.create(i.prototype,{constructor:{value:f,enumerable:!1,writable:!0,configurable:!0}})}function o(f,i){Object.defineProperty(this,"kind",{value:f,enumerable:!0}),i&&i.length&&Object.defineProperty(this,"path",{value:i,enumerable:!0})}function p(f,i,a){p.super_.call(this,"E",f),Object.defineProperty(this,"lhs",{value:i,enumerable:!0}),Object.defineProperty(this,"rhs",{value:a,enumerable:!0})}r(p,o);function n(f,i){n.super_.call(this,"N",f),Object.defineProperty(this,"rhs",{value:i,enumerable:!0})}r(n,o);function u(f,i){u.super_.call(this,"D",f),Object.defineProperty(this,"lhs",{value:i,enumerable:!0})}r(u,o);function m(f,i,a){m.super_.call(this,"A",f),Object.defineProperty(this,"index",{value:i,enumerable:!0}),Object.defineProperty(this,"item",{value:a,enumerable:!0})}r(m,o);function d(f,i,a){var s=f.slice((a||i)+1||f.length);return f.length=i<0?f.length+i:i,f.push.apply(f,s),f}function c(f){var i=typeof f;return i!=="object"?i:f===Math?"math":f===null?"null":Array.isArray(f)?"array":Object.prototype.toString.call(f)==="[object Date]"?"date":typeof f.toString=="function"&&/^\/.*\//.test(f.toString())?"regexp":"object"}function O(f){var i=0;if(f.length===0)return i;for(var a=0;a<f.length;a++){var s=f.charCodeAt(a);i=(i<<5)-i+s,i=i&i}return i}function b(f){var i=0,a=c(f);if(a==="array"){f.forEach(function(X){i+=b(X)});var s="[type: array, hash: "+i+"]";return i+O(s)}if(a==="object"){for(var l in f)if(f.hasOwnProperty(l)){var y="[ type: object, key: "+l+", value hash: "+b(f[l])+"]";i+=O(y)}return i}var x="[ type: "+a+" ; value: "+f+"]";return i+O(x)}function g(f,i,a,s,l,y,x,X){a=a||[],l=l||[],x=x||[];var E=l.slice(0);if(typeof y<"u"&&y!==null){if(s){if(typeof s=="function"&&s(E,y))return;if(typeof s=="object"){if(s.prefilter&&s.prefilter(E,y))return;if(s.normalize){var pt=s.normalize(E,y,f,i);pt&&(f=pt[0],i=pt[1])}}}E.push(y)}c(f)==="regexp"&&c(i)==="regexp"&&(f=f.toString(),i=i.toString());var st=typeof f,Ho=typeof i,A,Ae,R,Oe,At=st!=="undefined"||x&&x.length>0&&x[x.length-1].lhs&&Object.getOwnPropertyDescriptor(x[x.length-1].lhs,y),Ot=Ho!=="undefined"||x&&x.length>0&&x[x.length-1].rhs&&Object.getOwnPropertyDescriptor(x[x.length-1].rhs,y);if(!At&&Ot)a.push(new n(E,i));else if(!Ot&&At)a.push(new u(E,f));else if(c(f)!==c(i))a.push(new p(E,f,i));else if(c(f)==="date"&&f-i!==0)a.push(new p(E,f,i));else if(st==="object"&&f!==null&&i!==null){for(A=x.length-1;A>-1;--A)if(x[A].lhs===f){Oe=!0;break}if(Oe)f!==i&&a.push(new p(E,f,i));else{if(x.push({lhs:f,rhs:i}),Array.isArray(f)){for(X&&(f.sort(function(ut,lt){return b(ut)-b(lt)}),i.sort(function(ut,lt){return b(ut)-b(lt)})),A=i.length-1,Ae=f.length-1;A>Ae;)a.push(new m(E,A,new n(void 0,i[A--])));for(;Ae>A;)a.push(new m(E,Ae,new u(void 0,f[Ae--])));for(;A>=0;--A)g(f[A],i[A],a,s,E,A,x,X)}else{var Tt=Object.keys(f),Ie=Object.keys(i);for(A=0;A<Tt.length;++A)R=Tt[A],Oe=Ie.indexOf(R),Oe>=0?(g(f[R],i[R],a,s,E,R,x,X),Ie[Oe]=null):g(f[R],void 0,a,s,E,R,x,X);for(A=0;A<Ie.length;++A)R=Ie[A],R&&g(void 0,i[R],a,s,E,R,x,X)}x.length=x.length-1}}else f!==i&&(st==="number"&&isNaN(f)&&isNaN(i)||a.push(new p(E,f,i)))}function j(f,i,a,s,l){var y=[];if(g(f,i,y,s,null,null,null,l),a)for(var x=0;x<y.length;++x)a(y[x]);return y}function I(f,i,a,s,l,y,x){return g(f,i,a,s,l,y,x,!0)}function T(f,i,a,s){var l=s?function(x){x&&s.push(x)}:void 0,y=j(f,i,l,a);return s||(y.length?y:void 0)}function w(f,i,a,s){var l=s?function(x){x&&s.push(x)}:void 0,y=j(f,i,l,a,!0);return s||(y.length?y:void 0)}function S(f,i,a){if(a.path&&a.path.length){var s=f[i],l,y=a.path.length-1;for(l=0;l<y;l++)s=s[a.path[l]];switch(a.kind){case"A":S(s[a.path[l]],a.index,a.item);break;case"D":delete s[a.path[l]];break;case"E":case"N":s[a.path[l]]=a.rhs;break}}else switch(a.kind){case"A":S(f[i],a.index,a.item);break;case"D":f=d(f,i);break;case"E":case"N":f[i]=a.rhs;break}return f}function B(f,i,a){if(typeof a>"u"&&i&&~t.indexOf(i.kind)&&(a=i),f&&a&&a.kind){for(var s=f,l=-1,y=a.path?a.path.length-1:0;++l<y;)typeof s[a.path[l]]>"u"&&(s[a.path[l]]=typeof a.path[l+1]<"u"&&typeof a.path[l+1]=="number"?[]:{}),s=s[a.path[l]];switch(a.kind){case"A":a.path&&typeof s[a.path[l]]>"u"&&(s[a.path[l]]=[]),S(a.path?s[a.path[l]]:s,a.index,a.item);break;case"D":delete s[a.path[l]];break;case"E":case"N":s[a.path[l]]=a.rhs;break}}}function k(f,i,a){if(a.path&&a.path.length){var s=f[i],l,y=a.path.length-1;for(l=0;l<y;l++)s=s[a.path[l]];switch(a.kind){case"A":k(s[a.path[l]],a.index,a.item);break;case"D":s[a.path[l]]=a.lhs;break;case"E":s[a.path[l]]=a.lhs;break;case"N":delete s[a.path[l]];break}}else switch(a.kind){case"A":k(f[i],a.index,a.item);break;case"D":f[i]=a.lhs;break;case"E":f[i]=a.lhs;break;case"N":f=d(f,i);break}return f}function ee(f,i,a){if(f&&i&&a&&a.kind){var s=f,l,y;for(y=a.path.length-1,l=0;l<y;l++)typeof s[a.path[l]]>"u"&&(s[a.path[l]]={}),s=s[a.path[l]];switch(a.kind){case"A":k(s[a.path[l]],a.index,a.item);break;case"D":s[a.path[l]]=a.lhs;break;case"E":s[a.path[l]]=a.lhs;break;case"N":delete s[a.path[l]];break}}}function te(f,i,a){if(f&&i){var s=function(l){(!a||a(f,i,l))&&B(f,i,l)};j(f,i,s)}}return Object.defineProperties(T,{diff:{value:T,enumerable:!0},orderIndependentDiff:{value:w,enumerable:!0},observableDiff:{value:j,enumerable:!0},orderIndependentObservableDiff:{value:I,enumerable:!0},orderIndepHash:{value:b,enumerable:!0},applyDiff:{value:te,enumerable:!0},applyChange:{value:B,enumerable:!0},revertChange:{value:ee,enumerable:!0},isConflict:{value:function(){return typeof $conflict<"u"},enumerable:!0}}),T.DeepDiff=T,e&&(e.DeepDiff=T),T})});var zs={};Zo(zs,{action:()=>it,defineGetter:()=>Bs,getState:()=>Ms,setImmutableState:()=>Rs,setState:()=>Uo,startLogging:()=>Us,stopLogging:()=>Ws,subscribe:()=>je,subscribeOnce:()=>Go,subscribeOnceSync:()=>Es,subscribeSync:()=>Is,subscribersAsync:()=>he,subscribersSync:()=>ve,unsubscribe:()=>ft,unsubscribeAll:()=>Cs});var Qo=typeof global=="object"&&global&&global.Object===Object&&global,Ce=Qo;var ko=typeof self=="object"&&self&&self.Object===Object&&self,ea=Ce||ko||Function("return this")(),_=ea;var ta=_.Symbol,C=ta;var jt=Object.prototype,ra=jt.hasOwnProperty,oa=jt.toString,Te=C?C.toStringTag:void 0;function aa(e){var t=ra.call(e,Te),r=e[Te];try{e[Te]=void 0;var o=!0}catch{}var p=oa.call(e);return o&&(t?e[Te]=r:delete e[Te]),p}var Pt=aa;var fa=Object.prototype,na=fa.toString;function ia(e){return na.call(e)}var It=ia;var pa="[object Null]",sa="[object Undefined]",Et=C?C.toStringTag:void 0;function ua(e){return e==null?e===void 0?sa:pa:Et&&Et in Object(e)?Pt(e):It(e)}var N=ua;function la(e){return e!=null&&typeof e=="object"}var P=la;var ma="[object Symbol]";function da(e){return typeof e=="symbol"||P(e)&&N(e)==ma}var re=da;function ca(e,t){for(var r=-1,o=e==null?0:e.length,p=Array(o);++r<o;)p[r]=t(e[r],r,e);return p}var Ct=ca;var xa=Array.isArray,D=xa;var ya=1/0,Dt=C?C.prototype:void 0,Lt=Dt?Dt.toString:void 0;function Nt(e){if(typeof e=="string")return e;if(D(e))return Ct(e,Nt)+"";if(re(e))return Lt?Lt.call(e):"";var t=e+"";return t=="0"&&1/e==-ya?"-0":t}var Mt=Nt;function ba(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var M=ba;var ga="[object AsyncFunction]",ha="[object Function]",va="[object GeneratorFunction]",Aa="[object Proxy]";function Oa(e){if(!M(e))return!1;var t=N(e);return t==ha||t==va||t==ga||t==Aa}var De=Oa;var Ta=_["__core-js_shared__"],Le=Ta;var Rt=(function(){var e=/[^.]+$/.exec(Le&&Le.keys&&Le.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})();function _a(e){return!!Rt&&Rt in e}var Bt=_a;var wa=Function.prototype,Sa=wa.toString;function ja(e){if(e!=null){try{return Sa.call(e)}catch{}try{return e+""}catch{}}return""}var F=ja;var Pa=/[\\^$.*+?()[\]{}|]/g,Ia=/^\[object .+?Constructor\]$/,Ea=Function.prototype,Ca=Object.prototype,Da=Ea.toString,La=Ca.hasOwnProperty,Na=RegExp("^"+Da.call(La).replace(Pa,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ma(e){if(!M(e)||Bt(e))return!1;var t=De(e)?Na:Ia;return t.test(F(e))}var Ft=Ma;function Ra(e,t){return e?.[t]}var Gt=Ra;function Ba(e,t){var r=Gt(e,t);return Ft(r)?r:void 0}var L=Ba;var Fa=L(_,"WeakMap"),Ne=Fa;var Ut=Object.create,Ga=(function(){function e(){}return function(t){if(!M(t))return{};if(Ut)return Ut(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}})(),Wt=Ga;function Ua(e,t){var r=-1,o=e.length;for(t||(t=Array(o));++r<o;)t[r]=e[r];return t}var zt=Ua;var Wa=(function(){try{var e=L(Object,"defineProperty");return e({},"",{}),e}catch{}})(),mt=Wa;function za(e,t){for(var r=-1,o=e==null?0:e.length;++r<o&&t(e[r],r,e)!==!1;);return e}var Kt=za;var Ka=9007199254740991,Ha=/^(?:0|[1-9]\d*)$/;function qa(e,t){var r=typeof e;return t=t??Ka,!!t&&(r=="number"||r!="symbol"&&Ha.test(e))&&e>-1&&e%1==0&&e<t}var Me=qa;function $a(e,t,r){t=="__proto__"&&mt?mt(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}var Re=$a;function Ja(e,t){return e===t||e!==e&&t!==t}var oe=Ja;var Ya=Object.prototype,Xa=Ya.hasOwnProperty;function Za(e,t,r){var o=e[t];(!(Xa.call(e,t)&&oe(o,r))||r===void 0&&!(t in e))&&Re(e,t,r)}var ae=Za;function Va(e,t,r,o){var p=!r;r||(r={});for(var n=-1,u=t.length;++n<u;){var m=t[n],d=o?o(r[m],e[m],m,r,e):void 0;d===void 0&&(d=e[m]),p?Re(r,m,d):ae(r,m,d)}return r}var H=Va;var Qa=9007199254740991;function ka(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Qa}var Be=ka;function ef(e){return e!=null&&Be(e.length)&&!De(e)}var Fe=ef;var tf=Object.prototype;function rf(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||tf;return e===r}var fe=rf;function of(e,t){for(var r=-1,o=Array(e);++r<e;)o[r]=t(r);return o}var Ht=of;var af="[object Arguments]";function ff(e){return P(e)&&N(e)==af}var dt=ff;var qt=Object.prototype,nf=qt.hasOwnProperty,pf=qt.propertyIsEnumerable,sf=dt((function(){return arguments})())?dt:function(e){return P(e)&&nf.call(e,"callee")&&!pf.call(e,"callee")},$t=sf;function uf(){return!1}var Jt=uf;var Zt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Yt=Zt&&typeof module=="object"&&module&&!module.nodeType&&module,lf=Yt&&Yt.exports===Zt,Xt=lf?_.Buffer:void 0,mf=Xt?Xt.isBuffer:void 0,df=mf||Jt,Z=df;var cf="[object Arguments]",xf="[object Array]",yf="[object Boolean]",bf="[object Date]",gf="[object Error]",hf="[object Function]",vf="[object Map]",Af="[object Number]",Of="[object Object]",Tf="[object RegExp]",_f="[object Set]",wf="[object String]",Sf="[object WeakMap]",jf="[object ArrayBuffer]",Pf="[object DataView]",If="[object Float32Array]",Ef="[object Float64Array]",Cf="[object Int8Array]",Df="[object Int16Array]",Lf="[object Int32Array]",Nf="[object Uint8Array]",Mf="[object Uint8ClampedArray]",Rf="[object Uint16Array]",Bf="[object Uint32Array]",v={};v[If]=v[Ef]=v[Cf]=v[Df]=v[Lf]=v[Nf]=v[Mf]=v[Rf]=v[Bf]=!0;v[cf]=v[xf]=v[jf]=v[yf]=v[Pf]=v[bf]=v[gf]=v[hf]=v[vf]=v[Af]=v[Of]=v[Tf]=v[_f]=v[wf]=v[Sf]=!1;function Ff(e){return P(e)&&Be(e.length)&&!!v[N(e)]}var Vt=Ff;function Gf(e){return function(t){return e(t)}}var ne=Gf;var Qt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,_e=Qt&&typeof module=="object"&&module&&!module.nodeType&&module,Uf=_e&&_e.exports===Qt,ct=Uf&&Ce.process,Wf=(function(){try{var e=_e&&_e.require&&_e.require("util").types;return e||ct&&ct.binding&&ct.binding("util")}catch{}})(),G=Wf;var kt=G&&G.isTypedArray,zf=kt?ne(kt):Vt,Ge=zf;var Kf=Object.prototype,Hf=Kf.hasOwnProperty;function qf(e,t){var r=D(e),o=!r&&$t(e),p=!r&&!o&&Z(e),n=!r&&!o&&!p&&Ge(e),u=r||o||p||n,m=u?Ht(e.length,String):[],d=m.length;for(var c in e)(t||Hf.call(e,c))&&!(u&&(c=="length"||p&&(c=="offset"||c=="parent")||n&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Me(c,d)))&&m.push(c);return m}var Ue=qf;function $f(e,t){return function(r){return e(t(r))}}var We=$f;var Jf=We(Object.keys,Object),er=Jf;var Yf=Object.prototype,Xf=Yf.hasOwnProperty;function Zf(e){if(!fe(e))return er(e);var t=[];for(var r in Object(e))Xf.call(e,r)&&r!="constructor"&&t.push(r);return t}var tr=Zf;function Vf(e){return Fe(e)?Ue(e):tr(e)}var ie=Vf;function Qf(e){var t=[];if(e!=null)for(var r in Object(e))t.push(r);return t}var rr=Qf;var kf=Object.prototype,en=kf.hasOwnProperty;function tn(e){if(!M(e))return rr(e);var t=fe(e),r=[];for(var o in e)o=="constructor"&&(t||!en.call(e,o))||r.push(o);return r}var or=tn;function rn(e){return Fe(e)?Ue(e,!0):or(e)}var pe=rn;var on=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,an=/^\w*$/;function fn(e,t){if(D(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||re(e)?!0:an.test(e)||!on.test(e)||t!=null&&e in Object(t)}var ar=fn;var nn=L(Object,"create"),U=nn;function pn(){this.__data__=U?U(null):{},this.size=0}var fr=pn;function sn(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var nr=sn;var un="__lodash_hash_undefined__",ln=Object.prototype,mn=ln.hasOwnProperty;function dn(e){var t=this.__data__;if(U){var r=t[e];return r===un?void 0:r}return mn.call(t,e)?t[e]:void 0}var ir=dn;var cn=Object.prototype,xn=cn.hasOwnProperty;function yn(e){var t=this.__data__;return U?t[e]!==void 0:xn.call(t,e)}var pr=yn;var bn="__lodash_hash_undefined__";function gn(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=U&&t===void 0?bn:t,this}var sr=gn;function se(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var o=e[t];this.set(o[0],o[1])}}se.prototype.clear=fr;se.prototype.delete=nr;se.prototype.get=ir;se.prototype.has=pr;se.prototype.set=sr;var xt=se;function hn(){this.__data__=[],this.size=0}var ur=hn;function vn(e,t){for(var r=e.length;r--;)if(oe(e[r][0],t))return r;return-1}var q=vn;var An=Array.prototype,On=An.splice;function Tn(e){var t=this.__data__,r=q(t,e);if(r<0)return!1;var o=t.length-1;return r==o?t.pop():On.call(t,r,1),--this.size,!0}var lr=Tn;function _n(e){var t=this.__data__,r=q(t,e);return r<0?void 0:t[r][1]}var mr=_n;function wn(e){return q(this.__data__,e)>-1}var dr=wn;function Sn(e,t){var r=this.__data__,o=q(r,e);return o<0?(++this.size,r.push([e,t])):r[o][1]=t,this}var cr=Sn;function ue(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var o=e[t];this.set(o[0],o[1])}}ue.prototype.clear=ur;ue.prototype.delete=lr;ue.prototype.get=mr;ue.prototype.has=dr;ue.prototype.set=cr;var $=ue;var jn=L(_,"Map"),J=jn;function Pn(){this.size=0,this.__data__={hash:new xt,map:new(J||$),string:new xt}}var xr=Pn;function In(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var yr=In;function En(e,t){var r=e.__data__;return yr(t)?r[typeof t=="string"?"string":"hash"]:r.map}var Y=En;function Cn(e){var t=Y(this,e).delete(e);return this.size-=t?1:0,t}var br=Cn;function Dn(e){return Y(this,e).get(e)}var gr=Dn;function Ln(e){return Y(this,e).has(e)}var hr=Ln;function Nn(e,t){var r=Y(this,e),o=r.size;return r.set(e,t),this.size+=r.size==o?0:1,this}var vr=Nn;function le(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var o=e[t];this.set(o[0],o[1])}}le.prototype.clear=xr;le.prototype.delete=br;le.prototype.get=gr;le.prototype.has=hr;le.prototype.set=vr;var V=le;var Mn="Expected a function";function yt(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(Mn);var r=function(){var o=arguments,p=t?t.apply(this,o):o[0],n=r.cache;if(n.has(p))return n.get(p);var u=e.apply(this,o);return r.cache=n.set(p,u)||n,u};return r.cache=new(yt.Cache||V),r}yt.Cache=V;var Ar=yt;var Rn=500;function Bn(e){var t=Ar(e,function(o){return r.size===Rn&&r.clear(),o}),r=t.cache;return t}var Or=Bn;var Fn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Gn=/\\(\\)?/g,Un=Or(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Fn,function(r,o,p,n){t.push(p?n.replace(Gn,"$1"):o||r)}),t}),Tr=Un;function Wn(e){return e==null?"":Mt(e)}var _r=Wn;function zn(e,t){return D(e)?e:ar(e,t)?[e]:Tr(_r(e))}var ze=zn;var Kn=1/0;function Hn(e){if(typeof e=="string"||re(e))return e;var t=e+"";return t=="0"&&1/e==-Kn?"-0":t}var Ke=Hn;function qn(e,t){t=ze(t,e);for(var r=0,o=t.length;e!=null&&r<o;)e=e[Ke(t[r++])];return r&&r==o?e:void 0}var wr=qn;function $n(e,t,r){var o=e==null?void 0:wr(e,t);return o===void 0?r:o}var W=$n;function Jn(e,t){for(var r=-1,o=t.length,p=e.length;++r<o;)e[p+r]=t[r];return e}var He=Jn;var Yn=We(Object.getPrototypeOf,Object),me=Yn;var Xn="[object Object]",Zn=Function.prototype,Vn=Object.prototype,Sr=Zn.toString,Qn=Vn.hasOwnProperty,kn=Sr.call(Object);function ei(e){if(!P(e)||N(e)!=Xn)return!1;var t=me(e);if(t===null)return!0;var r=Qn.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Sr.call(r)==kn}var de=ei;function ti(){this.__data__=new $,this.size=0}var jr=ti;function ri(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var Pr=ri;function oi(e){return this.__data__.get(e)}var Ir=oi;function ai(e){return this.__data__.has(e)}var Er=ai;var fi=200;function ni(e,t){var r=this.__data__;if(r instanceof $){var o=r.__data__;if(!J||o.length<fi-1)return o.push([e,t]),this.size=++r.size,this;r=this.__data__=new V(o)}return r.set(e,t),this.size=r.size,this}var Cr=ni;function ce(e){var t=this.__data__=new $(e);this.size=t.size}ce.prototype.clear=jr;ce.prototype.delete=Pr;ce.prototype.get=Ir;ce.prototype.has=Er;ce.prototype.set=Cr;var xe=ce;function ii(e,t){return e&&H(t,ie(t),e)}var Dr=ii;function pi(e,t){return e&&H(t,pe(t),e)}var Lr=pi;var Br=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Nr=Br&&typeof module=="object"&&module&&!module.nodeType&&module,si=Nr&&Nr.exports===Br,Mr=si?_.Buffer:void 0,Rr=Mr?Mr.allocUnsafe:void 0;function ui(e,t){if(t)return e.slice();var r=e.length,o=Rr?Rr(r):new e.constructor(r);return e.copy(o),o}var Fr=ui;function li(e,t){for(var r=-1,o=e==null?0:e.length,p=0,n=[];++r<o;){var u=e[r];t(u,r,e)&&(n[p++]=u)}return n}var Gr=li;function mi(){return[]}var qe=mi;var di=Object.prototype,ci=di.propertyIsEnumerable,Ur=Object.getOwnPropertySymbols,xi=Ur?function(e){return e==null?[]:(e=Object(e),Gr(Ur(e),function(t){return ci.call(e,t)}))}:qe,ye=xi;function yi(e,t){return H(e,ye(e),t)}var Wr=yi;var bi=Object.getOwnPropertySymbols,gi=bi?function(e){for(var t=[];e;)He(t,ye(e)),e=me(e);return t}:qe,$e=gi;function hi(e,t){return H(e,$e(e),t)}var zr=hi;function vi(e,t,r){var o=t(e);return D(e)?o:He(o,r(e))}var Je=vi;function Ai(e){return Je(e,ie,ye)}var we=Ai;function Oi(e){return Je(e,pe,$e)}var Kr=Oi;var Ti=L(_,"DataView"),Ye=Ti;var _i=L(_,"Promise"),Xe=_i;var wi=L(_,"Set"),Ze=wi;var Hr="[object Map]",Si="[object Object]",qr="[object Promise]",$r="[object Set]",Jr="[object WeakMap]",Yr="[object DataView]",ji=F(Ye),Pi=F(J),Ii=F(Xe),Ei=F(Ze),Ci=F(Ne),Q=N;(Ye&&Q(new Ye(new ArrayBuffer(1)))!=Yr||J&&Q(new J)!=Hr||Xe&&Q(Xe.resolve())!=qr||Ze&&Q(new Ze)!=$r||Ne&&Q(new Ne)!=Jr)&&(Q=function(e){var t=N(e),r=t==Si?e.constructor:void 0,o=r?F(r):"";if(o)switch(o){case ji:return Yr;case Pi:return Hr;case Ii:return qr;case Ei:return $r;case Ci:return Jr}return t});var z=Q;var Di=Object.prototype,Li=Di.hasOwnProperty;function Ni(e){var t=e.length,r=new e.constructor(t);return t&&typeof e[0]=="string"&&Li.call(e,"index")&&(r.index=e.index,r.input=e.input),r}var Xr=Ni;var Mi=_.Uint8Array,be=Mi;function Ri(e){var t=new e.constructor(e.byteLength);return new be(t).set(new be(e)),t}var ge=Ri;function Bi(e,t){var r=t?ge(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}var Zr=Bi;var Fi=/\w*$/;function Gi(e){var t=new e.constructor(e.source,Fi.exec(e));return t.lastIndex=e.lastIndex,t}var Vr=Gi;var Qr=C?C.prototype:void 0,kr=Qr?Qr.valueOf:void 0;function Ui(e){return kr?Object(kr.call(e)):{}}var eo=Ui;function Wi(e,t){var r=t?ge(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}var to=Wi;var zi="[object Boolean]",Ki="[object Date]",Hi="[object Map]",qi="[object Number]",$i="[object RegExp]",Ji="[object Set]",Yi="[object String]",Xi="[object Symbol]",Zi="[object ArrayBuffer]",Vi="[object DataView]",Qi="[object Float32Array]",ki="[object Float64Array]",ep="[object Int8Array]",tp="[object Int16Array]",rp="[object Int32Array]",op="[object Uint8Array]",ap="[object Uint8ClampedArray]",fp="[object Uint16Array]",np="[object Uint32Array]";function ip(e,t,r){var o=e.constructor;switch(t){case Zi:return ge(e);case zi:case Ki:return new o(+e);case Vi:return Zr(e,r);case Qi:case ki:case ep:case tp:case rp:case op:case ap:case fp:case np:return to(e,r);case Hi:return new o;case qi:case Yi:return new o(e);case $i:return Vr(e);case Ji:return new o;case Xi:return eo(e)}}var ro=ip;function pp(e){return typeof e.constructor=="function"&&!fe(e)?Wt(me(e)):{}}var oo=pp;var sp="[object Map]";function up(e){return P(e)&&z(e)==sp}var ao=up;var fo=G&&G.isMap,lp=fo?ne(fo):ao,no=lp;var mp="[object Set]";function dp(e){return P(e)&&z(e)==mp}var io=dp;var po=G&&G.isSet,cp=po?ne(po):io,so=cp;var xp=1,yp=2,bp=4,uo="[object Arguments]",gp="[object Array]",hp="[object Boolean]",vp="[object Date]",Ap="[object Error]",lo="[object Function]",Op="[object GeneratorFunction]",Tp="[object Map]",_p="[object Number]",mo="[object Object]",wp="[object RegExp]",Sp="[object Set]",jp="[object String]",Pp="[object Symbol]",Ip="[object WeakMap]",Ep="[object ArrayBuffer]",Cp="[object DataView]",Dp="[object Float32Array]",Lp="[object Float64Array]",Np="[object Int8Array]",Mp="[object Int16Array]",Rp="[object Int32Array]",Bp="[object Uint8Array]",Fp="[object Uint8ClampedArray]",Gp="[object Uint16Array]",Up="[object Uint32Array]",h={};h[uo]=h[gp]=h[Ep]=h[Cp]=h[hp]=h[vp]=h[Dp]=h[Lp]=h[Np]=h[Mp]=h[Rp]=h[Tp]=h[_p]=h[mo]=h[wp]=h[Sp]=h[jp]=h[Pp]=h[Bp]=h[Fp]=h[Gp]=h[Up]=!0;h[Ap]=h[lo]=h[Ip]=!1;function Ve(e,t,r,o,p,n){var u,m=t&xp,d=t&yp,c=t&bp;if(r&&(u=p?r(e,o,p,n):r(e)),u!==void 0)return u;if(!M(e))return e;var O=D(e);if(O){if(u=Xr(e),!m)return zt(e,u)}else{var b=z(e),g=b==lo||b==Op;if(Z(e))return Fr(e,m);if(b==mo||b==uo||g&&!p){if(u=d||g?{}:oo(e),!m)return d?zr(e,Lr(u,e)):Wr(e,Dr(u,e))}else{if(!h[b])return p?e:{};u=ro(e,b,m)}}n||(n=new xe);var j=n.get(e);if(j)return j;n.set(e,u),so(e)?e.forEach(function(w){u.add(Ve(w,t,r,w,e,n))}):no(e)&&e.forEach(function(w,S){u.set(S,Ve(w,t,r,S,e,n))});var I=c?d?Kr:we:d?pe:ie,T=O?void 0:I(e);return Kt(T||e,function(w,S){T&&(S=w,w=e[S]),ae(u,S,Ve(w,t,r,S,e,n))}),u}var co=Ve;var Wp=1,zp=4;function Kp(e,t){return t=typeof t=="function"?t:void 0,co(e,Wp|zp,t)}var Qe=Kp;var Hp="__lodash_hash_undefined__";function qp(e){return this.__data__.set(e,Hp),this}var xo=qp;function $p(e){return this.__data__.has(e)}var yo=$p;function ke(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new V;++t<r;)this.add(e[t])}ke.prototype.add=ke.prototype.push=xo;ke.prototype.has=yo;var bo=ke;function Jp(e,t){for(var r=-1,o=e==null?0:e.length;++r<o;)if(t(e[r],r,e))return!0;return!1}var go=Jp;function Yp(e,t){return e.has(t)}var ho=Yp;var Xp=1,Zp=2;function Vp(e,t,r,o,p,n){var u=r&Xp,m=e.length,d=t.length;if(m!=d&&!(u&&d>m))return!1;var c=n.get(e),O=n.get(t);if(c&&O)return c==t&&O==e;var b=-1,g=!0,j=r&Zp?new bo:void 0;for(n.set(e,t),n.set(t,e);++b<m;){var I=e[b],T=t[b];if(o)var w=u?o(T,I,b,t,e,n):o(I,T,b,e,t,n);if(w!==void 0){if(w)continue;g=!1;break}if(j){if(!go(t,function(S,B){if(!ho(j,B)&&(I===S||p(I,S,r,o,n)))return j.push(B)})){g=!1;break}}else if(!(I===T||p(I,T,r,o,n))){g=!1;break}}return n.delete(e),n.delete(t),g}var et=Vp;function Qp(e){var t=-1,r=Array(e.size);return e.forEach(function(o,p){r[++t]=[p,o]}),r}var vo=Qp;function kp(e){var t=-1,r=Array(e.size);return e.forEach(function(o){r[++t]=o}),r}var Ao=kp;var es=1,ts=2,rs="[object Boolean]",os="[object Date]",as="[object Error]",fs="[object Map]",ns="[object Number]",is="[object RegExp]",ps="[object Set]",ss="[object String]",us="[object Symbol]",ls="[object ArrayBuffer]",ms="[object DataView]",Oo=C?C.prototype:void 0,bt=Oo?Oo.valueOf:void 0;function ds(e,t,r,o,p,n,u){switch(r){case ms:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case ls:return!(e.byteLength!=t.byteLength||!n(new be(e),new be(t)));case rs:case os:case ns:return oe(+e,+t);case as:return e.name==t.name&&e.message==t.message;case is:case ss:return e==t+"";case fs:var m=vo;case ps:var d=o&es;if(m||(m=Ao),e.size!=t.size&&!d)return!1;var c=u.get(e);if(c)return c==t;o|=ts,u.set(e,t);var O=et(m(e),m(t),o,p,n,u);return u.delete(e),O;case us:if(bt)return bt.call(e)==bt.call(t)}return!1}var To=ds;var cs=1,xs=Object.prototype,ys=xs.hasOwnProperty;function bs(e,t,r,o,p,n){var u=r&cs,m=we(e),d=m.length,c=we(t),O=c.length;if(d!=O&&!u)return!1;for(var b=d;b--;){var g=m[b];if(!(u?g in t:ys.call(t,g)))return!1}var j=n.get(e),I=n.get(t);if(j&&I)return j==t&&I==e;var T=!0;n.set(e,t),n.set(t,e);for(var w=u;++b<d;){g=m[b];var S=e[g],B=t[g];if(o)var k=u?o(B,S,g,t,e,n):o(S,B,g,e,t,n);if(!(k===void 0?S===B||p(S,B,r,o,n):k)){T=!1;break}w||(w=g=="constructor")}if(T&&!w){var ee=e.constructor,te=t.constructor;ee!=te&&"constructor"in e&&"constructor"in t&&!(typeof ee=="function"&&ee instanceof ee&&typeof te=="function"&&te instanceof te)&&(T=!1)}return n.delete(e),n.delete(t),T}var _o=bs;var gs=1,wo="[object Arguments]",So="[object Array]",tt="[object Object]",hs=Object.prototype,jo=hs.hasOwnProperty;function vs(e,t,r,o,p,n){var u=D(e),m=D(t),d=u?So:z(e),c=m?So:z(t);d=d==wo?tt:d,c=c==wo?tt:c;var O=d==tt,b=c==tt,g=d==c;if(g&&Z(e)){if(!Z(t))return!1;u=!0,O=!1}if(g&&!O)return n||(n=new xe),u||Ge(e)?et(e,t,r,o,p,n):To(e,t,d,r,o,p,n);if(!(r&gs)){var j=O&&jo.call(e,"__wrapped__"),I=b&&jo.call(t,"__wrapped__");if(j||I){var T=j?e.value():e,w=I?t.value():t;return n||(n=new xe),p(T,w,r,o,n)}}return g?(n||(n=new xe),_o(e,t,r,o,p,n)):!1}var Po=vs;function Io(e,t,r,o,p){return e===t?!0:e==null||t==null||!P(e)&&!P(t)?e!==e&&t!==t:Po(e,t,r,o,Io,p)}var Eo=Io;function As(e,t,r){r=typeof r=="function"?r:void 0;var o=r?r(e,t):void 0;return o===void 0?Eo(e,t,void 0,r):!!o}var gt=As;function Os(e,t,r,o){if(!M(e))return e;t=ze(t,e);for(var p=-1,n=t.length,u=n-1,m=e;m!=null&&++p<n;){var d=Ke(t[p]),c=r;if(d==="__proto__"||d==="constructor"||d==="prototype")return e;if(p!=u){var O=m[d];c=o?o(O,d,m):void 0,c===void 0&&(c=M(O)?O:Me(t[p+1])?[]:{})}ae(m,d,c),m=m[d]}return e}var Co=Os;function Ts(e,t,r){return e==null?e:Co(e,t,r)}var Se=Ts;var Do="__statezero_root";function rt(e){return e?e[Do]:void 0}function ot(e,t){Object.defineProperty(e,Do,{enumerable:!1,value:t})}var ht=St(No());var Mo="__statezero_immutable";function at(e){return e&&e[Mo]===!0}function Ro(e){Object.defineProperty(e,Mo,{enumerable:!1,value:!0})}var Bo=(e,t)=>typeof t=="object"?Qe(t,e):t,Fo=e=>{let t=new WeakMap,r,o=p=>{if(p instanceof Element||typeof p=="function"||at(p))return p;if(!de(p))return;let n=t.get(p);if(n)return n;if(n={},t.set(p,n),r||(r=n),!rt(p)){for(let u of Object.getOwnPropertyNames(p))u.startsWith("__statezero")||u.startsWith("$jscomp")||(n[u]=Bo(o,p[u]));return n}ot(n,r);for(let[u,m]of Object.entries(Object.getOwnPropertyDescriptors(p)))if(!(u.startsWith("__statezero")||u.startsWith("$jscomp"))){if(m.get){Object.defineProperty(n,u,m);continue}m.enumerable&&(n[u]=Bo(o,m.value))}return n};return Qe(e,o)};var he=new Set,ve=new Set,_s=(e,t)=>at(e)?e===t:void 0,ws=(e,t)=>(r,o)=>{let p=t(r),n=t(o);gt(p,n,_s)||e(p,n,r)},Ss=e=>(t,r)=>{e(t,r,t)},js=e=>t=>e.map(r=>W(t,r)),Ps=e=>t=>W(t,e),je=(e,t,r=!1)=>{let o=t;typeof t=="string"?o=Ps(t):Array.isArray(t)&&(o=js(t));let p;if(typeof o=="function")p=ws(e,o);else if(o===void 0)p=Ss(e);else{let n=typeof t=="object"?JSON.stringify(t):t;throw new Error(`statezero: subscribe() must be called with an Array/Function/String/undefined selector; not ${n}`)}return r?ve.add(p):he.add(p),p},Is=(e,t)=>je(e,t,!0),Go=(e,t,r=!1)=>{let p=je((...n)=>{e(...n),ft(p)},t,r);return p},Es=(e,t)=>Go(e,t,!0),ft=e=>{he.delete(e),ve.delete(e)},Cs=()=>{he.clear(),ve.clear()};var K=(0,ht.default)({}),nt,Ds=e=>{nt===void 0&&(nt=e,setTimeout(()=>{let t=nt;nt=void 0;for(let r of he)r(K,t)}))},Ls=e=>{for(let t of ve)t(K,e)},Ns=e=>{if(!de(e))throw new Error(`statezero: commit() must be called with a plain object "nextState" argument; not: ${e}`);let t=K;K=(0,ht.default)(e),Ds(t),Ls(t)},it=e=>(...t)=>e({commit:Ns,state:Fo(K)},...t),Ms=e=>{if(e===void 0)return K;if(typeof e=="string")return W(K,e);if(Array.isArray(e))return e.map(r=>W(K,r));if(typeof e=="function")return e(K);let t=typeof e=="object"?JSON.stringify(e):e;throw new Error(`statezero: getState() must be called with an Array/Function/String/undefined selector; not ${t}`)},Uo=it(({commit:e,state:t},r,o)=>{let p=t;if(r==null||r==="")p=o;else if(typeof r=="string")Se(t,r,o);else{let n=typeof r=="object"?JSON.stringify(r):r;throw new Error(`statezero: setState() must be called with an String/undefined "selector" argument; not ${n}`)}e(p)}),Rs=(e,t)=>{if(!e)throw new Error('statezero: setImmutableState() must be called with a non-empty String "selector" argument');if(!de(t))throw new Error(`statezero: setImmutableState() must be called with a plain object "obj" argument; not: ${t}`);Ro(t),Uo(e,t)};var Bs=it(({commit:e,state:t},r,o,p=!1)=>{let n=Array.isArray(r)?r:r.split("."),u=n.length-1,m=n[u],d=n.slice(0,u),c=t;d.length&&(c=W(t,d,{}),Se(t,d,c)),Object.defineProperty(c,m,{enumerable:p,get(){return o.call(this,this,rt(this))}}),ot(c,t),e(t)});var Ko=St(zo());var Pe,Fs={A:"Array changed",D:"Deleted",E:"Changed",N:"New"},Gs=e=>(t,r)=>{let o={},p=(0,Ko.default)(r,t);if(p!==void 0){for(let n of p){let{path:u}=n;o[u]={changeType:Fs[n.kind],from:n.lhs,to:n.rhs}}e(o,["changeType","from","to"])}},Us=(e,t)=>{Pe||(Pe=je(Gs(t||console.table),e))},Ws=()=>{Pe&&(ft(Pe),Pe=null)};return Vo(zs);})();
2
2
  /*! Bundled license information:
3
3
 
4
4
  lodash-es/lodash.js:
5
5
  (**
6
6
  * @license
7
7
  * Lodash (Custom Build) <https://lodash.com/>
8
- * Build: `lodash modularize exports="es" -o ./`
8
+ * Build: `lodash modularize exports="es" --repo lodash/lodash#4.18.1 -o ./`
9
9
  * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
10
10
  * Released under MIT license <https://lodash.com/license>
11
11
  * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "statezero",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "author": "andornaut",
5
5
  "description": "Small, simple, functional JavaScript library for managing immutable state",
6
6
  "keywords": [
@@ -38,7 +38,7 @@
38
38
  "src"
39
39
  ],
40
40
  "engines": {
41
- "node": ">=18"
41
+ "node": ">=20"
42
42
  },
43
43
  "repository": {
44
44
  "type": "git",
@@ -48,31 +48,33 @@
48
48
  "bugs": "https://github.com/andornaut/statezero/issues",
49
49
  "dependencies": {
50
50
  "deep-diff": "^1.0.2",
51
- "lodash-es": "^4.17.23",
51
+ "lodash-es": "^4.18.1",
52
52
  "simple-deep-freeze": "^0.0.2"
53
53
  },
54
54
  "devDependencies": {
55
- "@babel/core": "^7.29.0",
56
- "@babel/preset-env": "^7.29.0",
57
- "esbuild": "^0.27.3",
58
- "eslint": "^8.57.1",
59
- "eslint-plugin-simple-import-sort": "^12.1.1",
55
+ "@babel/core": "^8.0.1",
56
+ "@babel/preset-env": "^8.0.2",
57
+ "@eslint/js": "^10.0.1",
58
+ "@size-limit/preset-small-lib": "^13.0.1",
59
+ "esbuild": "^0.28.0",
60
+ "eslint": "^10.1.0",
61
+ "eslint-plugin-simple-import-sort": "^14.0.0",
60
62
  "eslint-plugin-sort-destructure-keys": "^3.0.0",
63
+ "globals": "^17.6.0",
61
64
  "husky": "^9.1.7",
62
- "jest": "^30.0.2",
63
- "jest-environment-jsdom": "^30.0.2",
64
- "lint-staged": "^16.2.7",
65
- "prettier-eslint-cli": "^8.0.1",
66
- "@size-limit/preset-small-lib": "^11.1.7",
67
- "size-limit": "^11.1.7"
65
+ "jest": "^30.3.0",
66
+ "jest-environment-jsdom": "^30.3.0",
67
+ "lint-staged": "^17.3.0",
68
+ "prettier": "^3.9.6",
69
+ "size-limit": "^13.0.1"
68
70
  },
69
71
  "scripts": {
70
72
  "build": "npm run build:esm && npm run build:umd",
71
73
  "build:esm": "esbuild src/index.js --bundle --format=esm --packages=external --outfile=dist/statezero.esm.js",
72
74
  "build:production": "npm run build:esm -- --minify && npm run build:umd -- --minify",
73
75
  "build:umd": "esbuild src/index.js --bundle --format=iife --global-name=statezero --outfile=dist/statezero.js",
74
- "format": "prettier-eslint --write \"${PWD}/{src/**,/test/**/,./}*.{css,js,json,jsx,md}\"",
75
- "lint": "eslint --max-warnings 0 {src,test}/**/*.js",
76
+ "format": "prettier --write . && eslint --fix .",
77
+ "lint": "prettier --check . && eslint --max-warnings 0 .",
76
78
  "prepare": "husky",
77
79
  "prepublishOnly": "npm run test && npm run build:production",
78
80
  "size": "size-limit",
package/src/clone.js CHANGED
@@ -3,7 +3,8 @@ import { cloneDeepWith, isPlainObject } from "lodash-es";
3
3
  import { isImmutable } from "./immutable";
4
4
  import { getRoot, setRoot } from "./root";
5
5
 
6
- const cloneProp = (customizer, value) => (typeof value === "object" ? cloneDeepWith(value, customizer) : value);
6
+ const cloneProp = (customizer, value) =>
7
+ typeof value === "object" ? cloneDeepWith(value, customizer) : value;
7
8
 
8
9
  /* Deep clone the given object.
9
10
  *
@@ -20,7 +21,11 @@ export const clone = (obj) => {
20
21
  let root;
21
22
 
22
23
  const customizer = (value) => {
23
- if (value instanceof Element || typeof value === "function" || isImmutable(value)) {
24
+ if (
25
+ value instanceof Element ||
26
+ typeof value === "function" ||
27
+ isImmutable(value)
28
+ ) {
24
29
  // Do not attempt to clone DOM nodes, immutable objects, or Function, but don't replace them with {} either, which
25
30
  // is what lodash would usually do. Leave them as is instead.
26
31
  return value;
@@ -48,7 +53,10 @@ export const clone = (obj) => {
48
53
  // We know that there are no getters if there is no ROOT, b/c defineGetters sets ROOT.
49
54
  // Even `cloned[ROOT] = root;` is costly, so we avoid that here too.
50
55
  for (const propName of Object.getOwnPropertyNames(value)) {
51
- if (propName.startsWith("__statezero") || propName.startsWith("$jscomp")) {
56
+ if (
57
+ propName.startsWith("__statezero") ||
58
+ propName.startsWith("$jscomp")
59
+ ) {
52
60
  continue;
53
61
  }
54
62
  cloned[propName] = cloneProp(customizer, value[propName]);
@@ -58,8 +66,13 @@ export const clone = (obj) => {
58
66
 
59
67
  setRoot(cloned, root);
60
68
 
61
- for (const [propName, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(value))) {
62
- if (propName.startsWith("__statezero") || propName.startsWith("$jscomp")) {
69
+ for (const [propName, descriptor] of Object.entries(
70
+ Object.getOwnPropertyDescriptors(value),
71
+ )) {
72
+ if (
73
+ propName.startsWith("__statezero") ||
74
+ propName.startsWith("$jscomp")
75
+ ) {
63
76
  continue;
64
77
  }
65
78
  if (descriptor.get) {
package/src/getters.js CHANGED
@@ -11,25 +11,27 @@ import { action } from "./state";
11
11
  * @param fn: A function which takes state as its only parameter and returns a value.
12
12
  * @param enumerable: A boolean which determine whether this property shows up during enumeration.
13
13
  */
14
- export const defineGetter = action(({ commit, state }, path, fn, enumerable = false) => {
15
- const pathArray = Array.isArray(path) ? path : path.split(".");
16
- const lastIdx = pathArray.length - 1;
17
- const propName = pathArray[lastIdx];
18
- const parentPath = pathArray.slice(0, lastIdx);
14
+ export const defineGetter = action(
15
+ ({ commit, state }, path, fn, enumerable = false) => {
16
+ const pathArray = Array.isArray(path) ? path : path.split(".");
17
+ const lastIdx = pathArray.length - 1;
18
+ const propName = pathArray[lastIdx];
19
+ const parentPath = pathArray.slice(0, lastIdx);
19
20
 
20
- let obj = state;
21
- if (parentPath.length) {
22
- obj = get(state, parentPath, {});
23
- // Set parentPath in case it didn't exist (the default case of get() above).
24
- set(state, parentPath, obj);
25
- }
21
+ let obj = state;
22
+ if (parentPath.length) {
23
+ obj = get(state, parentPath, {});
24
+ // Set parentPath in case it didn't exist (the default case of get() above).
25
+ set(state, parentPath, obj);
26
+ }
26
27
 
27
- Object.defineProperty(obj, propName, {
28
- get() {
29
- return fn.call(this, this, getRoot(this));
30
- },
31
- enumerable,
32
- });
33
- setRoot(obj, state);
34
- commit(state);
35
- });
28
+ Object.defineProperty(obj, propName, {
29
+ enumerable,
30
+ get() {
31
+ return fn.call(this, this, getRoot(this));
32
+ },
33
+ });
34
+ setRoot(obj, state);
35
+ commit(state);
36
+ },
37
+ );
package/src/logger.js CHANGED
@@ -34,7 +34,6 @@ export const startLogging = (selector, logger) => {
34
34
  return;
35
35
  }
36
36
 
37
- // eslint-disable-next-line no-console
38
37
  subscription = subscribe(createDiffLogger(logger || console.table), selector);
39
38
  };
40
39
 
package/src/root.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // Keep track of the top-level state object during cloning so that getters can access it later
2
- const ROOT = "__statezero__root";
2
+ const ROOT = "__statezero_root";
3
3
 
4
4
  export function getRoot(obj) {
5
5
  return obj ? obj[ROOT] : undefined;
package/src/state.js CHANGED
@@ -32,7 +32,9 @@ const notifySync = (prevState) => {
32
32
 
33
33
  const commit = (nextState) => {
34
34
  if (!isPlainObject(nextState)) {
35
- throw new Error(`statezero: commit() must be called with a plain object "nextState" argument; not: ${nextState}`);
35
+ throw new Error(
36
+ `statezero: commit() must be called with a plain object "nextState" argument; not: ${nextState}`,
37
+ );
36
38
  }
37
39
  const prevState = state;
38
40
  state = simpleDeepFreeze(nextState);
@@ -58,33 +60,41 @@ export const getState = (selector) => {
58
60
  if (typeof selector === "function") {
59
61
  return selector(state);
60
62
  }
61
- const selectorStr = typeof selector === "object" ? JSON.stringify(selector) : selector;
63
+ const selectorStr =
64
+ typeof selector === "object" ? JSON.stringify(selector) : selector;
62
65
  throw new Error(
63
66
  `statezero: getState() must be called with an Array/Function/String/undefined selector; not ${selectorStr}`,
64
67
  );
65
68
  };
66
69
 
67
- // eslint-disable-next-line no-shadow
68
70
  export const setState = action(({ commit, state }, selector, value) => {
71
+ // Replacing the root commits `value` itself; a nested selector mutates the
72
+ // state object in place and commits that.
73
+ let next = state;
69
74
  if (selector === undefined || selector === null || selector === "") {
70
- state = value;
75
+ next = value;
71
76
  } else if (typeof selector === "string") {
72
77
  set(state, selector, value);
73
78
  } else {
74
- const selectorStr = typeof selector === "object" ? JSON.stringify(selector) : selector;
79
+ const selectorStr =
80
+ typeof selector === "object" ? JSON.stringify(selector) : selector;
75
81
  throw new Error(
76
82
  `statezero: setState() must be called with an String/undefined "selector" argument; not ${selectorStr}`,
77
83
  );
78
84
  }
79
- commit(state);
85
+ commit(next);
80
86
  });
81
87
 
82
88
  export const setImmutableState = (selector, obj) => {
83
89
  if (!selector) {
84
- throw new Error('statezero: setImmutableState() must be called with a non-empty String "selector" argument');
90
+ throw new Error(
91
+ 'statezero: setImmutableState() must be called with a non-empty String "selector" argument',
92
+ );
85
93
  }
86
94
  if (!isPlainObject(obj)) {
87
- throw new Error(`statezero: setImmutableState() must be called with a plain object "obj" argument; not: ${obj}`);
95
+ throw new Error(
96
+ `statezero: setImmutableState() must be called with a plain object "obj" argument; not: ${obj}`,
97
+ );
88
98
  }
89
99
  markImmutable(obj);
90
100
  setState(selector, obj);
@@ -7,7 +7,8 @@ export const subscribersSync = new Set();
7
7
 
8
8
  // When customizer returns undefined, comparisons are handled by lodash
9
9
  // https://lodash.com/docs/4.17.15#isEqualWith
10
- const isEqualCustomizer = (value, othValue) => (isImmutable(value) ? value === othValue : undefined);
10
+ const isEqualCustomizer = (value, othValue) =>
11
+ isImmutable(value) ? value === othValue : undefined;
11
12
 
12
13
  const applySelector = (callback, selector) => (nextState, prevState) => {
13
14
  const selectedNextState = selector(nextState);
@@ -21,7 +22,8 @@ const applyRootState = (callback) => (nextState, prevState) => {
21
22
  callback(nextState, prevState, nextState);
22
23
  };
23
24
 
24
- const createArraySelector = (paths) => (_state) => paths.map((path) => get(_state, path));
25
+ const createArraySelector = (paths) => (_state) =>
26
+ paths.map((path) => get(_state, path));
25
27
 
26
28
  const createStringSelector = (path) => (_state) => get(_state, path);
27
29
 
@@ -38,39 +40,43 @@ const createStringSelector = (path) => (_state) => get(_state, path);
38
40
  */
39
41
  export const subscribe = (callback, selector, isSync = false) => {
40
42
  // Convert an array or string selector into a function.
43
+ let select = selector;
41
44
  if (typeof selector === "string") {
42
- selector = createStringSelector(selector);
45
+ select = createStringSelector(selector);
43
46
  } else if (Array.isArray(selector)) {
44
- selector = createArraySelector(selector);
47
+ select = createArraySelector(selector);
45
48
  }
46
49
 
47
- if (typeof selector === "function") {
48
- callback = applySelector(callback, selector);
49
- } else if (selector === undefined) {
50
- callback = applyRootState(callback);
50
+ // Every branch below assigns it or throws.
51
+ let notify;
52
+ if (typeof select === "function") {
53
+ notify = applySelector(callback, select);
54
+ } else if (select === undefined) {
55
+ notify = applyRootState(callback);
51
56
  } else {
52
- const selectorStr = typeof selector === "object" ? JSON.stringify(selector) : selector;
57
+ const selectorStr =
58
+ typeof selector === "object" ? JSON.stringify(selector) : selector;
53
59
  throw new Error(
54
60
  `statezero: subscribe() must be called with an Array/Function/String/undefined selector; not ${selectorStr}`,
55
61
  );
56
62
  }
57
63
 
58
64
  if (isSync) {
59
- subscribersSync.add(callback);
65
+ subscribersSync.add(notify);
60
66
  } else {
61
- subscribersAsync.add(callback);
67
+ subscribersAsync.add(notify);
62
68
  }
63
69
 
64
70
  // If a `selector` was provided, then the caller will need to use the returned `callback` in order to `unsubscribe()`.
65
- return callback;
71
+ return notify;
66
72
  };
67
73
 
68
- export const subscribeSync = (callback, selector) => subscribe(callback, selector, true);
74
+ export const subscribeSync = (callback, selector) =>
75
+ subscribe(callback, selector, true);
69
76
 
70
77
  export const subscribeOnce = (callback, selector, isSync = false) => {
71
78
  const wrapper = (...args) => {
72
79
  callback(...args);
73
- // eslint-disable-next-line no-use-before-define
74
80
  unsubscribe(subscription);
75
81
  };
76
82
 
@@ -78,7 +84,8 @@ export const subscribeOnce = (callback, selector, isSync = false) => {
78
84
  return subscription;
79
85
  };
80
86
 
81
- export const subscribeOnceSync = (callback, selector) => subscribeOnce(callback, selector, true);
87
+ export const subscribeOnceSync = (callback, selector) =>
88
+ subscribeOnce(callback, selector, true);
82
89
 
83
90
  export const unsubscribe = (callback) => {
84
91
  subscribersAsync.delete(callback);