@gaddario98/react-core 2.0.4 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
- import {atomStateGenerator as atomStateGenerator$1,storage as storage$1}from'@gaddario98/react-state';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import*as React from'react';import React__default,{useReducer,useEffect,useDebugValue,useCallback,useContext,createContext,useRef,useState,memo,useMemo,useLayoutEffect}from'react';import {useApiValues as useApiValues$1,useApiConfigValue as useApiConfigValue$1,useApi as useApi$1,queriesAtom as queriesAtom$1}from'@gaddario98/react-queries';import {c}from'react/compiler-runtime';import equal from'fast-deep-equal';import {useFormValues as useFormValues$1,useFormManager as useFormManager$1}from'@gaddario98/react-form';import {useSyncExternalStoreWithSelector}from'use-sync-external-store/shim/with-selector.js';const {
1
+ import {atomStateGenerator as atomStateGenerator$1,storage as storage$1}from'@gaddario98/react-state';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import*as React from'react';import React__default,{useReducer,useEffect,useDebugValue,useCallback,useContext,createContext,useRef,useState,memo,useMemo,useLayoutEffect}from'react';import {useApiValues as useApiValues$1,useApiConfigValue as useApiConfigValue$1,useApi as useApi$1,queriesAtom as queriesAtom$1,useApiConfigState as useApiConfigState$1}from'@gaddario98/react-queries';import {c}from'react/compiler-runtime';import equal from'fast-deep-equal';import {useFormValues as useFormValues$1,useFormManager as useFormManager$1,useFormConfigState as useFormConfigState$1}from'@gaddario98/react-form';import {useSyncExternalStoreWithSelector}from'use-sync-external-store/shim/with-selector.js';import {useTranslation as useTranslation$1,useLocalizationConfigState as useLocalizationConfigState$1}from'@gaddario98/react-localization';import {usePageConfigState as usePageConfigState$1}from'@gaddario98/react-pages';const {
2
2
  atom: authAtom,
3
3
  useValue: useAuthValue,
4
4
  useState: useAuthState
5
5
  } = atomStateGenerator$1({
6
6
  defaultValue: null,
7
- key: 'reactAuthStore',
7
+ key: "reactAuthStore",
8
8
  persist: true
9
9
  });/******************************************************************************
10
10
  Copyright (c) Microsoft Corporation.
@@ -33,16 +33,16 @@ function __rest(s, e) {
33
33
  typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
34
34
  var e = new Error(message);
35
35
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
36
- };function hasInitialValue$1(atom) {
36
+ };function hasInitialValue(atom) {
37
37
  return "init" in atom;
38
38
  }
39
- function isActuallyWritableAtom$1(atom) {
39
+ function isActuallyWritableAtom(atom) {
40
40
  return !!atom.write;
41
41
  }
42
- function isAtomStateInitialized$1(atomState) {
42
+ function isAtomStateInitialized(atomState) {
43
43
  return "v" in atomState || "e" in atomState;
44
44
  }
45
- function returnAtomValue$1(atomState) {
45
+ function returnAtomValue(atomState) {
46
46
  if ("e" in atomState) {
47
47
  throw atomState.e;
48
48
  }
@@ -51,23 +51,23 @@ function returnAtomValue$1(atomState) {
51
51
  }
52
52
  return atomState.v;
53
53
  }
54
- const promiseStateMap$1 = /* @__PURE__ */ new WeakMap();
55
- function isPendingPromise$1(value) {
54
+ const promiseStateMap = /* @__PURE__ */ new WeakMap();
55
+ function isPendingPromise(value) {
56
56
  var _a;
57
- return isPromiseLike$4(value) && !!((_a = promiseStateMap$1.get(value)) == null ? void 0 : _a[0]);
57
+ return isPromiseLike$1(value) && !!((_a = promiseStateMap.get(value)) == null ? void 0 : _a[0]);
58
58
  }
59
- function abortPromise$1(promise) {
60
- const promiseState = promiseStateMap$1.get(promise);
59
+ function abortPromise(promise) {
60
+ const promiseState = promiseStateMap.get(promise);
61
61
  if (promiseState == null ? void 0 : promiseState[0]) {
62
62
  promiseState[0] = false;
63
63
  promiseState[1].forEach((fn) => fn());
64
64
  }
65
65
  }
66
- function registerAbortHandler$1(promise, abortHandler) {
67
- let promiseState = promiseStateMap$1.get(promise);
66
+ function registerAbortHandler(promise, abortHandler) {
67
+ let promiseState = promiseStateMap.get(promise);
68
68
  if (!promiseState) {
69
69
  promiseState = [true, /* @__PURE__ */ new Set()];
70
- promiseStateMap$1.set(promise, promiseState);
70
+ promiseStateMap.set(promise, promiseState);
71
71
  const settle = () => {
72
72
  promiseState[0] = false;
73
73
  };
@@ -75,17 +75,17 @@ function registerAbortHandler$1(promise, abortHandler) {
75
75
  }
76
76
  promiseState[1].add(abortHandler);
77
77
  }
78
- function isPromiseLike$4(p) {
78
+ function isPromiseLike$1(p) {
79
79
  return typeof (p == null ? void 0 : p.then) === "function";
80
80
  }
81
- function addPendingPromiseToDependency$1(atom, promise, dependencyAtomState) {
81
+ function addPendingPromiseToDependency(atom, promise, dependencyAtomState) {
82
82
  if (!dependencyAtomState.p.has(atom)) {
83
83
  dependencyAtomState.p.add(atom);
84
84
  const cleanup = () => dependencyAtomState.p.delete(atom);
85
85
  promise.then(cleanup, cleanup);
86
86
  }
87
87
  }
88
- function getMountedOrPendingDependents$1(atom, atomState, mountedMap) {
88
+ function getMountedOrPendingDependents(atom, atomState, mountedMap) {
89
89
  var _a;
90
90
  const dependents = /* @__PURE__ */ new Set();
91
91
  for (const a of ((_a = mountedMap.get(atom)) == null ? void 0 : _a.t) || []) {
@@ -96,29 +96,22 @@ function getMountedOrPendingDependents$1(atom, atomState, mountedMap) {
96
96
  }
97
97
  return dependents;
98
98
  }
99
- const atomRead$1 = (_store, atom, ...params) => atom.read(...params);
100
- const atomWrite$1 = (_store, atom, ...params) => atom.write(...params);
101
- const atomOnInit$1 = (store, atom) => {
102
- if (atom.INTERNAL_onInit) {
103
- return atom.INTERNAL_onInit(store);
104
- }
105
- if (atom.unstable_onInit) {
106
- console.warn(
107
- "[DEPRECATED] atom.unstable_onInit is renamed to atom.INTERNAL_onInit."
108
- );
109
- return atom.unstable_onInit(store);
110
- }
99
+ const BUILDING_BLOCK_atomRead = (_store, atom, ...params) => atom.read(...params);
100
+ const BUILDING_BLOCK_atomWrite = (_store, atom, ...params) => atom.write(...params);
101
+ const BUILDING_BLOCK_atomOnInit = (store, atom) => {
102
+ var _a;
103
+ return (_a = atom.INTERNAL_onInit) == null ? void 0 : _a.call(atom, store);
111
104
  };
112
- const atomOnMount$1 = (_store, atom, setAtom) => {
105
+ const BUILDING_BLOCK_atomOnMount = (_store, atom, setAtom) => {
113
106
  var _a;
114
107
  return (_a = atom.onMount) == null ? void 0 : _a.call(atom, setAtom);
115
108
  };
116
- const ensureAtomState$1 = (store, atom) => {
109
+ const BUILDING_BLOCK_ensureAtomState = (store, atom) => {
117
110
  var _a;
118
- const buildingBlocks = getInternalBuildingBlocks$1(store);
111
+ const buildingBlocks = getInternalBuildingBlocks(store);
119
112
  const atomStateMap = buildingBlocks[0];
120
113
  const storeHooks = buildingBlocks[6];
121
- const atomOnInit2 = buildingBlocks[9];
114
+ const atomOnInit = buildingBlocks[9];
122
115
  if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production" && !atom) {
123
116
  throw new Error("Atom is undefined or null");
124
117
  }
@@ -127,18 +120,18 @@ const ensureAtomState$1 = (store, atom) => {
127
120
  atomState = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 };
128
121
  atomStateMap.set(atom, atomState);
129
122
  (_a = storeHooks.i) == null ? void 0 : _a.call(storeHooks, atom);
130
- atomOnInit2 == null ? void 0 : atomOnInit2(store, atom);
123
+ atomOnInit == null ? void 0 : atomOnInit(store, atom);
131
124
  }
132
125
  return atomState;
133
126
  };
134
- const flushCallbacks$1 = (store) => {
135
- const buildingBlocks = getInternalBuildingBlocks$1(store);
127
+ const BUILDING_BLOCK_flushCallbacks = (store) => {
128
+ const buildingBlocks = getInternalBuildingBlocks(store);
136
129
  const mountedMap = buildingBlocks[1];
137
130
  const changedAtoms = buildingBlocks[3];
138
131
  const mountCallbacks = buildingBlocks[4];
139
132
  const unmountCallbacks = buildingBlocks[5];
140
133
  const storeHooks = buildingBlocks[6];
141
- const recomputeInvalidatedAtoms2 = buildingBlocks[13];
134
+ const recomputeInvalidatedAtoms = buildingBlocks[13];
142
135
  const errors = [];
143
136
  const call = (fn) => {
144
137
  try {
@@ -164,28 +157,28 @@ const flushCallbacks$1 = (store) => {
164
157
  mountCallbacks.clear();
165
158
  callbacks.forEach(call);
166
159
  if (changedAtoms.size) {
167
- recomputeInvalidatedAtoms2(store);
160
+ recomputeInvalidatedAtoms(store);
168
161
  }
169
162
  } while (changedAtoms.size || unmountCallbacks.size || mountCallbacks.size);
170
163
  if (errors.length) {
171
164
  throw new AggregateError(errors);
172
165
  }
173
166
  };
174
- const recomputeInvalidatedAtoms$1 = (store) => {
175
- const buildingBlocks = getInternalBuildingBlocks$1(store);
167
+ const BUILDING_BLOCK_recomputeInvalidatedAtoms = (store) => {
168
+ const buildingBlocks = getInternalBuildingBlocks(store);
176
169
  const mountedMap = buildingBlocks[1];
177
170
  const invalidatedAtoms = buildingBlocks[2];
178
171
  const changedAtoms = buildingBlocks[3];
179
- const ensureAtomState2 = buildingBlocks[11];
180
- const readAtomState2 = buildingBlocks[14];
181
- const mountDependencies2 = buildingBlocks[17];
172
+ const ensureAtomState = buildingBlocks[11];
173
+ const readAtomState = buildingBlocks[14];
174
+ const mountDependencies = buildingBlocks[17];
182
175
  const topSortedReversed = [];
183
176
  const visiting = /* @__PURE__ */ new WeakSet();
184
177
  const visited = /* @__PURE__ */ new WeakSet();
185
178
  const stack = Array.from(changedAtoms);
186
179
  while (stack.length) {
187
180
  const a = stack[stack.length - 1];
188
- const aState = ensureAtomState2(store, a);
181
+ const aState = ensureAtomState(store, a);
189
182
  if (visited.has(a)) {
190
183
  stack.pop();
191
184
  continue;
@@ -201,7 +194,7 @@ const recomputeInvalidatedAtoms$1 = (store) => {
201
194
  continue;
202
195
  }
203
196
  visiting.add(a);
204
- for (const d of getMountedOrPendingDependents$1(a, aState, mountedMap)) {
197
+ for (const d of getMountedOrPendingDependents(a, aState, mountedMap)) {
205
198
  if (!visiting.has(d)) {
206
199
  stack.push(d);
207
200
  }
@@ -217,35 +210,36 @@ const recomputeInvalidatedAtoms$1 = (store) => {
217
210
  }
218
211
  }
219
212
  if (hasChangedDeps) {
220
- readAtomState2(store, a);
221
- mountDependencies2(store, a);
213
+ readAtomState(store, a);
214
+ mountDependencies(store, a);
222
215
  }
223
216
  invalidatedAtoms.delete(a);
224
217
  }
225
218
  };
226
219
  const storeMutationSet = /* @__PURE__ */ new WeakSet();
227
- const readAtomState$1 = (store, atom) => {
220
+ const BUILDING_BLOCK_readAtomState = (store, atom) => {
228
221
  var _a, _b;
229
- const buildingBlocks = getInternalBuildingBlocks$1(store);
222
+ const buildingBlocks = getInternalBuildingBlocks(store);
230
223
  const mountedMap = buildingBlocks[1];
231
224
  const invalidatedAtoms = buildingBlocks[2];
232
225
  const changedAtoms = buildingBlocks[3];
233
226
  const storeHooks = buildingBlocks[6];
234
- const atomRead2 = buildingBlocks[7];
235
- const ensureAtomState2 = buildingBlocks[11];
236
- const flushCallbacks2 = buildingBlocks[12];
237
- const recomputeInvalidatedAtoms2 = buildingBlocks[13];
238
- const readAtomState2 = buildingBlocks[14];
239
- const writeAtomState2 = buildingBlocks[16];
240
- const mountDependencies2 = buildingBlocks[17];
241
- const atomState = ensureAtomState2(store, atom);
242
- if (isAtomStateInitialized$1(atomState)) {
227
+ const atomRead = buildingBlocks[7];
228
+ const ensureAtomState = buildingBlocks[11];
229
+ const flushCallbacks = buildingBlocks[12];
230
+ const recomputeInvalidatedAtoms = buildingBlocks[13];
231
+ const readAtomState = buildingBlocks[14];
232
+ const writeAtomState = buildingBlocks[16];
233
+ const mountDependencies = buildingBlocks[17];
234
+ const setAtomStateValueOrPromise = buildingBlocks[20];
235
+ const atomState = ensureAtomState(store, atom);
236
+ if (isAtomStateInitialized(atomState)) {
243
237
  if (mountedMap.has(atom) && invalidatedAtoms.get(atom) !== atomState.n) {
244
238
  return atomState;
245
239
  }
246
240
  let hasChangedDeps = false;
247
241
  for (const [a, n] of atomState.d) {
248
- if (readAtomState2(store, a).n !== n) {
242
+ if (readAtomState(store, a).n !== n) {
249
243
  hasChangedDeps = true;
250
244
  break;
251
245
  }
@@ -258,31 +252,31 @@ const readAtomState$1 = (store, atom) => {
258
252
  let isSync = true;
259
253
  function mountDependenciesIfAsync() {
260
254
  if (mountedMap.has(atom)) {
261
- mountDependencies2(store, atom);
262
- recomputeInvalidatedAtoms2(store);
263
- flushCallbacks2(store);
255
+ mountDependencies(store, atom);
256
+ recomputeInvalidatedAtoms(store);
257
+ flushCallbacks(store);
264
258
  }
265
259
  }
266
260
  function getter(a) {
267
261
  var _a2;
268
262
  if (a === atom) {
269
- const aState2 = ensureAtomState2(store, a);
270
- if (!isAtomStateInitialized$1(aState2)) {
271
- if (hasInitialValue$1(a)) {
272
- setAtomStateValueOrPromise$1(store, a, a.init);
263
+ const aState2 = ensureAtomState(store, a);
264
+ if (!isAtomStateInitialized(aState2)) {
265
+ if (hasInitialValue(a)) {
266
+ setAtomStateValueOrPromise(store, a, a.init);
273
267
  } else {
274
268
  throw new Error("no atom init");
275
269
  }
276
270
  }
277
- return returnAtomValue$1(aState2);
271
+ return returnAtomValue(aState2);
278
272
  }
279
- const aState = readAtomState2(store, a);
273
+ const aState = readAtomState(store, a);
280
274
  try {
281
- return returnAtomValue$1(aState);
275
+ return returnAtomValue(aState);
282
276
  } finally {
283
277
  atomState.d.set(a, aState.n);
284
- if (isPendingPromise$1(atomState.v)) {
285
- addPendingPromiseToDependency$1(atom, atomState.v, aState);
278
+ if (isPendingPromise(atomState.v)) {
279
+ addPendingPromiseToDependency(atom, atomState.v, aState);
286
280
  }
287
281
  if (mountedMap.has(atom)) {
288
282
  (_a2 = mountedMap.get(a)) == null ? void 0 : _a2.t.add(atom);
@@ -302,20 +296,25 @@ const readAtomState$1 = (store, atom) => {
302
296
  return controller.signal;
303
297
  },
304
298
  get setSelf() {
305
- if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production" && !isActuallyWritableAtom$1(atom)) {
299
+ if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production") {
300
+ console.warn(
301
+ "[DEPRECATED] setSelf is deprecated and will be removed in v3."
302
+ );
303
+ }
304
+ if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production" && !isActuallyWritableAtom(atom)) {
306
305
  console.warn("setSelf function cannot be used with read-only atom");
307
306
  }
308
- if (!setSelf && isActuallyWritableAtom$1(atom)) {
307
+ if (!setSelf && isActuallyWritableAtom(atom)) {
309
308
  setSelf = (...args) => {
310
309
  if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production" && isSync) {
311
310
  console.warn("setSelf function cannot be called in sync");
312
311
  }
313
312
  if (!isSync) {
314
313
  try {
315
- return writeAtomState2(store, atom, ...args);
314
+ return writeAtomState(store, atom, ...args);
316
315
  } finally {
317
- recomputeInvalidatedAtoms2(store);
318
- flushCallbacks2(store);
316
+ recomputeInvalidatedAtoms(store);
317
+ flushCallbacks(store);
319
318
  }
320
319
  }
321
320
  };
@@ -328,15 +327,15 @@ const readAtomState$1 = (store, atom) => {
328
327
  if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production") {
329
328
  storeMutationSet.delete(store);
330
329
  }
331
- const valueOrPromise = atomRead2(store, atom, getter, options);
330
+ const valueOrPromise = atomRead(store, atom, getter, options);
332
331
  if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production" && storeMutationSet.has(store)) {
333
332
  console.warn(
334
333
  "Detected store mutation during atom read. This is not supported."
335
334
  );
336
335
  }
337
- setAtomStateValueOrPromise$1(store, atom, valueOrPromise);
338
- if (isPromiseLike$4(valueOrPromise)) {
339
- registerAbortHandler$1(valueOrPromise, () => controller == null ? void 0 : controller.abort());
336
+ setAtomStateValueOrPromise(store, atom, valueOrPromise);
337
+ if (isPromiseLike$1(valueOrPromise)) {
338
+ registerAbortHandler(valueOrPromise, () => controller == null ? void 0 : controller.abort());
340
339
  valueOrPromise.then(mountDependenciesIfAsync, mountDependenciesIfAsync);
341
340
  }
342
341
  (_a = storeHooks.r) == null ? void 0 : _a.call(storeHooks, atom);
@@ -355,41 +354,43 @@ const readAtomState$1 = (store, atom) => {
355
354
  }
356
355
  }
357
356
  };
358
- const invalidateDependents$1 = (store, atom) => {
359
- const buildingBlocks = getInternalBuildingBlocks$1(store);
357
+ const BUILDING_BLOCK_invalidateDependents = (store, atom) => {
358
+ const buildingBlocks = getInternalBuildingBlocks(store);
360
359
  const mountedMap = buildingBlocks[1];
361
360
  const invalidatedAtoms = buildingBlocks[2];
362
- const ensureAtomState2 = buildingBlocks[11];
361
+ const ensureAtomState = buildingBlocks[11];
363
362
  const stack = [atom];
364
363
  while (stack.length) {
365
364
  const a = stack.pop();
366
- const aState = ensureAtomState2(store, a);
367
- for (const d of getMountedOrPendingDependents$1(a, aState, mountedMap)) {
368
- const dState = ensureAtomState2(store, d);
365
+ const aState = ensureAtomState(store, a);
366
+ for (const d of getMountedOrPendingDependents(a, aState, mountedMap)) {
367
+ const dState = ensureAtomState(store, d);
369
368
  invalidatedAtoms.set(d, dState.n);
370
369
  stack.push(d);
371
370
  }
372
371
  }
373
372
  };
374
- const writeAtomState$1 = (store, atom, ...args) => {
375
- const buildingBlocks = getInternalBuildingBlocks$1(store);
373
+ const BUILDING_BLOCK_writeAtomState = (store, atom, ...args) => {
374
+ const buildingBlocks = getInternalBuildingBlocks(store);
376
375
  const changedAtoms = buildingBlocks[3];
377
376
  const storeHooks = buildingBlocks[6];
378
- const atomWrite2 = buildingBlocks[8];
379
- const ensureAtomState2 = buildingBlocks[11];
380
- const flushCallbacks2 = buildingBlocks[12];
381
- const recomputeInvalidatedAtoms2 = buildingBlocks[13];
382
- const readAtomState2 = buildingBlocks[14];
383
- const invalidateDependents2 = buildingBlocks[15];
384
- const mountDependencies2 = buildingBlocks[17];
377
+ const atomWrite = buildingBlocks[8];
378
+ const ensureAtomState = buildingBlocks[11];
379
+ const flushCallbacks = buildingBlocks[12];
380
+ const recomputeInvalidatedAtoms = buildingBlocks[13];
381
+ const readAtomState = buildingBlocks[14];
382
+ const invalidateDependents = buildingBlocks[15];
383
+ const writeAtomState = buildingBlocks[16];
384
+ const mountDependencies = buildingBlocks[17];
385
+ const setAtomStateValueOrPromise = buildingBlocks[20];
385
386
  let isSync = true;
386
- const getter = (a) => returnAtomValue$1(readAtomState2(store, a));
387
+ const getter = (a) => returnAtomValue(readAtomState(store, a));
387
388
  const setter = (a, ...args2) => {
388
389
  var _a;
389
- const aState = ensureAtomState2(store, a);
390
+ const aState = ensureAtomState(store, a);
390
391
  try {
391
392
  if (a === atom) {
392
- if (!hasInitialValue$1(a)) {
393
+ if (!hasInitialValue(a)) {
393
394
  throw new Error("atom not writable");
394
395
  }
395
396
  if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production") {
@@ -397,52 +398,52 @@ const writeAtomState$1 = (store, atom, ...args) => {
397
398
  }
398
399
  const prevEpochNumber = aState.n;
399
400
  const v = args2[0];
400
- setAtomStateValueOrPromise$1(store, a, v);
401
- mountDependencies2(store, a);
401
+ setAtomStateValueOrPromise(store, a, v);
402
+ mountDependencies(store, a);
402
403
  if (prevEpochNumber !== aState.n) {
403
404
  changedAtoms.add(a);
404
- invalidateDependents2(store, a);
405
+ invalidateDependents(store, a);
405
406
  (_a = storeHooks.c) == null ? void 0 : _a.call(storeHooks, a);
406
407
  }
407
408
  return void 0;
408
409
  } else {
409
- return writeAtomState$1(store, a, ...args2);
410
+ return writeAtomState(store, a, ...args2);
410
411
  }
411
412
  } finally {
412
413
  if (!isSync) {
413
- recomputeInvalidatedAtoms2(store);
414
- flushCallbacks2(store);
414
+ recomputeInvalidatedAtoms(store);
415
+ flushCallbacks(store);
415
416
  }
416
417
  }
417
418
  };
418
419
  try {
419
- return atomWrite2(store, atom, getter, setter, ...args);
420
+ return atomWrite(store, atom, getter, setter, ...args);
420
421
  } finally {
421
422
  isSync = false;
422
423
  }
423
424
  };
424
- const mountDependencies$1 = (store, atom) => {
425
+ const BUILDING_BLOCK_mountDependencies = (store, atom) => {
425
426
  var _a;
426
- const buildingBlocks = getInternalBuildingBlocks$1(store);
427
+ const buildingBlocks = getInternalBuildingBlocks(store);
427
428
  const mountedMap = buildingBlocks[1];
428
429
  const changedAtoms = buildingBlocks[3];
429
430
  const storeHooks = buildingBlocks[6];
430
- const ensureAtomState2 = buildingBlocks[11];
431
- const invalidateDependents2 = buildingBlocks[15];
432
- const mountAtom2 = buildingBlocks[18];
433
- const unmountAtom2 = buildingBlocks[19];
434
- const atomState = ensureAtomState2(store, atom);
431
+ const ensureAtomState = buildingBlocks[11];
432
+ const invalidateDependents = buildingBlocks[15];
433
+ const mountAtom = buildingBlocks[18];
434
+ const unmountAtom = buildingBlocks[19];
435
+ const atomState = ensureAtomState(store, atom);
435
436
  const mounted = mountedMap.get(atom);
436
- if (mounted && !isPendingPromise$1(atomState.v)) {
437
+ if (mounted && !isPendingPromise(atomState.v)) {
437
438
  for (const [a, n] of atomState.d) {
438
439
  if (!mounted.d.has(a)) {
439
- const aState = ensureAtomState2(store, a);
440
- const aMounted = mountAtom2(store, a);
440
+ const aState = ensureAtomState(store, a);
441
+ const aMounted = mountAtom(store, a);
441
442
  aMounted.t.add(atom);
442
443
  mounted.d.add(a);
443
444
  if (n !== aState.n) {
444
445
  changedAtoms.add(a);
445
- invalidateDependents2(store, a);
446
+ invalidateDependents(store, a);
446
447
  (_a = storeHooks.c) == null ? void 0 : _a.call(storeHooks, a);
447
448
  }
448
449
  }
@@ -450,30 +451,31 @@ const mountDependencies$1 = (store, atom) => {
450
451
  for (const a of mounted.d) {
451
452
  if (!atomState.d.has(a)) {
452
453
  mounted.d.delete(a);
453
- const aMounted = unmountAtom2(store, a);
454
+ const aMounted = unmountAtom(store, a);
454
455
  aMounted == null ? void 0 : aMounted.t.delete(atom);
455
456
  }
456
457
  }
457
458
  }
458
459
  };
459
- const mountAtom$1 = (store, atom) => {
460
+ const BUILDING_BLOCK_mountAtom = (store, atom) => {
460
461
  var _a;
461
- const buildingBlocks = getInternalBuildingBlocks$1(store);
462
+ const buildingBlocks = getInternalBuildingBlocks(store);
462
463
  const mountedMap = buildingBlocks[1];
463
464
  const mountCallbacks = buildingBlocks[4];
464
465
  const storeHooks = buildingBlocks[6];
465
- const atomOnMount2 = buildingBlocks[10];
466
- const ensureAtomState2 = buildingBlocks[11];
467
- const flushCallbacks2 = buildingBlocks[12];
468
- const recomputeInvalidatedAtoms2 = buildingBlocks[13];
469
- const readAtomState2 = buildingBlocks[14];
470
- const writeAtomState2 = buildingBlocks[16];
471
- const atomState = ensureAtomState2(store, atom);
466
+ const atomOnMount = buildingBlocks[10];
467
+ const ensureAtomState = buildingBlocks[11];
468
+ const flushCallbacks = buildingBlocks[12];
469
+ const recomputeInvalidatedAtoms = buildingBlocks[13];
470
+ const readAtomState = buildingBlocks[14];
471
+ const writeAtomState = buildingBlocks[16];
472
+ const mountAtom = buildingBlocks[18];
473
+ const atomState = ensureAtomState(store, atom);
472
474
  let mounted = mountedMap.get(atom);
473
475
  if (!mounted) {
474
- readAtomState2(store, atom);
476
+ readAtomState(store, atom);
475
477
  for (const a of atomState.d.keys()) {
476
- const aMounted = mountAtom$1(store, a);
478
+ const aMounted = mountAtom(store, a);
477
479
  aMounted.t.add(atom);
478
480
  }
479
481
  mounted = {
@@ -482,21 +484,21 @@ const mountAtom$1 = (store, atom) => {
482
484
  t: /* @__PURE__ */ new Set()
483
485
  };
484
486
  mountedMap.set(atom, mounted);
485
- if (isActuallyWritableAtom$1(atom)) {
487
+ if (isActuallyWritableAtom(atom)) {
486
488
  const processOnMount = () => {
487
489
  let isSync = true;
488
490
  const setAtom = (...args) => {
489
491
  try {
490
- return writeAtomState2(store, atom, ...args);
492
+ return writeAtomState(store, atom, ...args);
491
493
  } finally {
492
494
  if (!isSync) {
493
- recomputeInvalidatedAtoms2(store);
494
- flushCallbacks2(store);
495
+ recomputeInvalidatedAtoms(store);
496
+ flushCallbacks(store);
495
497
  }
496
498
  }
497
499
  };
498
500
  try {
499
- const onUnmount = atomOnMount2(store, atom, setAtom);
501
+ const onUnmount = atomOnMount(store, atom, setAtom);
500
502
  if (onUnmount) {
501
503
  mounted.u = () => {
502
504
  isSync = true;
@@ -517,15 +519,15 @@ const mountAtom$1 = (store, atom) => {
517
519
  }
518
520
  return mounted;
519
521
  };
520
- const unmountAtom$1 = (store, atom) => {
522
+ const BUILDING_BLOCK_unmountAtom = (store, atom) => {
521
523
  var _a, _b;
522
- const buildingBlocks = getInternalBuildingBlocks$1(store);
524
+ const buildingBlocks = getInternalBuildingBlocks(store);
523
525
  const mountedMap = buildingBlocks[1];
524
526
  const unmountCallbacks = buildingBlocks[5];
525
527
  const storeHooks = buildingBlocks[6];
526
- const ensureAtomState2 = buildingBlocks[11];
527
- const unmountAtom2 = buildingBlocks[19];
528
- const atomState = ensureAtomState2(store, atom);
528
+ const ensureAtomState = buildingBlocks[11];
529
+ const unmountAtom = buildingBlocks[19];
530
+ const atomState = ensureAtomState(store, atom);
529
531
  let mounted = mountedMap.get(atom);
530
532
  if (!mounted || mounted.l.size) {
531
533
  return mounted;
@@ -544,7 +546,7 @@ const unmountAtom$1 = (store, atom) => {
544
546
  mounted = void 0;
545
547
  mountedMap.delete(atom);
546
548
  for (const a of atomState.d.keys()) {
547
- const aMounted = unmountAtom2(store, a);
549
+ const aMounted = unmountAtom(store, a);
548
550
  aMounted == null ? void 0 : aMounted.t.delete(atom);
549
551
  }
550
552
  (_b = storeHooks.u) == null ? void 0 : _b.call(storeHooks, atom);
@@ -552,17 +554,17 @@ const unmountAtom$1 = (store, atom) => {
552
554
  }
553
555
  return mounted;
554
556
  };
555
- const setAtomStateValueOrPromise$1 = (store, atom, valueOrPromise) => {
556
- const ensureAtomState2 = getInternalBuildingBlocks$1(store)[11];
557
- const atomState = ensureAtomState2(store, atom);
557
+ const BUILDING_BLOCK_setAtomStateValueOrPromise = (store, atom, valueOrPromise) => {
558
+ const ensureAtomState = getInternalBuildingBlocks(store)[11];
559
+ const atomState = ensureAtomState(store, atom);
558
560
  const hasPrevValue = "v" in atomState;
559
561
  const prevValue = atomState.v;
560
- if (isPromiseLike$4(valueOrPromise)) {
562
+ if (isPromiseLike$1(valueOrPromise)) {
561
563
  for (const a of atomState.d.keys()) {
562
- addPendingPromiseToDependency$1(
564
+ addPendingPromiseToDependency(
563
565
  atom,
564
566
  valueOrPromise,
565
- ensureAtomState2(store, a)
567
+ ensureAtomState(store, a)
566
568
  );
567
569
  }
568
570
  }
@@ -570,45 +572,45 @@ const setAtomStateValueOrPromise$1 = (store, atom, valueOrPromise) => {
570
572
  delete atomState.e;
571
573
  if (!hasPrevValue || !Object.is(prevValue, atomState.v)) {
572
574
  ++atomState.n;
573
- if (isPromiseLike$4(prevValue)) {
574
- abortPromise$1(prevValue);
575
+ if (isPromiseLike$1(prevValue)) {
576
+ abortPromise(prevValue);
575
577
  }
576
578
  }
577
579
  };
578
- const storeGet$1 = (store, atom) => {
579
- const readAtomState2 = getInternalBuildingBlocks$1(store)[14];
580
- return returnAtomValue$1(readAtomState2(store, atom));
580
+ const BUILDING_BLOCK_storeGet = (store, atom) => {
581
+ const readAtomState = getInternalBuildingBlocks(store)[14];
582
+ return returnAtomValue(readAtomState(store, atom));
581
583
  };
582
- const storeSet$1 = (store, atom, ...args) => {
583
- const buildingBlocks = getInternalBuildingBlocks$1(store);
584
- const flushCallbacks2 = buildingBlocks[12];
585
- const recomputeInvalidatedAtoms2 = buildingBlocks[13];
586
- const writeAtomState2 = buildingBlocks[16];
584
+ const BUILDING_BLOCK_storeSet = (store, atom, ...args) => {
585
+ const buildingBlocks = getInternalBuildingBlocks(store);
586
+ const flushCallbacks = buildingBlocks[12];
587
+ const recomputeInvalidatedAtoms = buildingBlocks[13];
588
+ const writeAtomState = buildingBlocks[16];
587
589
  try {
588
- return writeAtomState2(store, atom, ...args);
590
+ return writeAtomState(store, atom, ...args);
589
591
  } finally {
590
- recomputeInvalidatedAtoms2(store);
591
- flushCallbacks2(store);
592
+ recomputeInvalidatedAtoms(store);
593
+ flushCallbacks(store);
592
594
  }
593
595
  };
594
- const storeSub$1 = (store, atom, listener) => {
595
- const buildingBlocks = getInternalBuildingBlocks$1(store);
596
- const flushCallbacks2 = buildingBlocks[12];
597
- const mountAtom2 = buildingBlocks[18];
598
- const unmountAtom2 = buildingBlocks[19];
599
- const mounted = mountAtom2(store, atom);
596
+ const BUILDING_BLOCK_storeSub = (store, atom, listener) => {
597
+ const buildingBlocks = getInternalBuildingBlocks(store);
598
+ const flushCallbacks = buildingBlocks[12];
599
+ const mountAtom = buildingBlocks[18];
600
+ const unmountAtom = buildingBlocks[19];
601
+ const mounted = mountAtom(store, atom);
600
602
  const listeners = mounted.l;
601
603
  listeners.add(listener);
602
- flushCallbacks2(store);
604
+ flushCallbacks(store);
603
605
  return () => {
604
606
  listeners.delete(listener);
605
- unmountAtom2(store, atom);
606
- flushCallbacks2(store);
607
+ unmountAtom(store, atom);
608
+ flushCallbacks(store);
607
609
  };
608
610
  };
609
- const buildingBlockMap$1 = /* @__PURE__ */ new WeakMap();
610
- const getInternalBuildingBlocks$1 = (store) => {
611
- const buildingBlocks = buildingBlockMap$1.get(store);
611
+ const buildingBlockMap = /* @__PURE__ */ new WeakMap();
612
+ const getInternalBuildingBlocks = (store) => {
613
+ const buildingBlocks = buildingBlockMap.get(store);
612
614
  if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production" && !buildingBlocks) {
613
615
  throw new Error(
614
616
  "Store must be created by buildStore to read its building blocks"
@@ -616,19 +618,19 @@ const getInternalBuildingBlocks$1 = (store) => {
616
618
  }
617
619
  return buildingBlocks;
618
620
  };
619
- function buildStore$1(...buildArgs) {
621
+ function buildStore(...buildArgs) {
620
622
  const store = {
621
623
  get(atom) {
622
- const storeGet2 = getInternalBuildingBlocks$1(store)[21];
623
- return storeGet2(store, atom);
624
+ const storeGet = getInternalBuildingBlocks(store)[21];
625
+ return storeGet(store, atom);
624
626
  },
625
627
  set(atom, ...args) {
626
- const storeSet2 = getInternalBuildingBlocks$1(store)[22];
627
- return storeSet2(store, atom, ...args);
628
+ const storeSet = getInternalBuildingBlocks(store)[22];
629
+ return storeSet(store, atom, ...args);
628
630
  },
629
631
  sub(atom, listener) {
630
- const storeSub2 = getInternalBuildingBlocks$1(store)[23];
631
- return storeSub2(store, atom, listener);
632
+ const storeSub = getInternalBuildingBlocks(store)[23];
633
+ return storeSub(store, atom, listener);
632
634
  }
633
635
  };
634
636
  const buildingBlocks = [
@@ -648,31 +650,31 @@ function buildStore$1(...buildArgs) {
648
650
  {},
649
651
  // storeHooks
650
652
  // atom interceptors
651
- atomRead$1,
652
- atomWrite$1,
653
- atomOnInit$1,
654
- atomOnMount$1,
653
+ BUILDING_BLOCK_atomRead,
654
+ BUILDING_BLOCK_atomWrite,
655
+ BUILDING_BLOCK_atomOnInit,
656
+ BUILDING_BLOCK_atomOnMount,
655
657
  // building-block functions
656
- ensureAtomState$1,
657
- flushCallbacks$1,
658
- recomputeInvalidatedAtoms$1,
659
- readAtomState$1,
660
- invalidateDependents$1,
661
- writeAtomState$1,
662
- mountDependencies$1,
663
- mountAtom$1,
664
- unmountAtom$1,
665
- setAtomStateValueOrPromise$1,
666
- storeGet$1,
667
- storeSet$1,
668
- storeSub$1,
658
+ BUILDING_BLOCK_ensureAtomState,
659
+ BUILDING_BLOCK_flushCallbacks,
660
+ BUILDING_BLOCK_recomputeInvalidatedAtoms,
661
+ BUILDING_BLOCK_readAtomState,
662
+ BUILDING_BLOCK_invalidateDependents,
663
+ BUILDING_BLOCK_writeAtomState,
664
+ BUILDING_BLOCK_mountDependencies,
665
+ BUILDING_BLOCK_mountAtom,
666
+ BUILDING_BLOCK_unmountAtom,
667
+ BUILDING_BLOCK_setAtomStateValueOrPromise,
668
+ BUILDING_BLOCK_storeGet,
669
+ BUILDING_BLOCK_storeSet,
670
+ BUILDING_BLOCK_storeSub,
669
671
  void 0
670
672
  ].map((fn, i) => buildArgs[i] || fn);
671
- buildingBlockMap$1.set(store, Object.freeze(buildingBlocks));
673
+ buildingBlockMap.set(store, Object.freeze(buildingBlocks));
672
674
  return store;
673
- }let keyCount$1 = 0;
674
- function atom$1(read, write) {
675
- const key = `atom${++keyCount$1}`;
675
+ }let keyCount = 0;
676
+ function atom(read, write) {
677
+ const key = `atom${++keyCount}`;
676
678
  const config = {
677
679
  toString() {
678
680
  return (import.meta.env ? import.meta.env.MODE : void 0) !== "production" && this.debugLabel ? key + ":" + this.debugLabel : key;
@@ -682,50 +684,50 @@ function atom$1(read, write) {
682
684
  config.read = read;
683
685
  } else {
684
686
  config.init = read;
685
- config.read = defaultRead$1;
686
- config.write = defaultWrite$1;
687
+ config.read = defaultRead;
688
+ config.write = defaultWrite;
687
689
  }
688
690
  if (write) {
689
691
  config.write = write;
690
692
  }
691
693
  return config;
692
694
  }
693
- function defaultRead$1(get) {
695
+ function defaultRead(get) {
694
696
  return get(this);
695
697
  }
696
- function defaultWrite$1(get, set, arg) {
698
+ function defaultWrite(get, set, arg) {
697
699
  return set(
698
700
  this,
699
701
  typeof arg === "function" ? arg(get(this)) : arg
700
702
  );
701
703
  }
702
- function createStore$1() {
703
- return buildStore$1();
704
+ function createStore() {
705
+ return buildStore();
704
706
  }
705
- let defaultStore$1;
706
- function getDefaultStore$1() {
707
- if (!defaultStore$1) {
708
- defaultStore$1 = createStore$1();
707
+ let defaultStore;
708
+ function getDefaultStore() {
709
+ if (!defaultStore) {
710
+ defaultStore = createStore();
709
711
  if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production") {
710
- globalThis.__JOTAI_DEFAULT_STORE__ || (globalThis.__JOTAI_DEFAULT_STORE__ = defaultStore$1);
711
- if (globalThis.__JOTAI_DEFAULT_STORE__ !== defaultStore$1) {
712
+ globalThis.__JOTAI_DEFAULT_STORE__ || (globalThis.__JOTAI_DEFAULT_STORE__ = defaultStore);
713
+ if (globalThis.__JOTAI_DEFAULT_STORE__ !== defaultStore) {
712
714
  console.warn(
713
715
  "Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"
714
716
  );
715
717
  }
716
718
  }
717
719
  }
718
- return defaultStore$1;
719
- }const StoreContext$1 = createContext(
720
+ return defaultStore;
721
+ }const StoreContext = createContext(
720
722
  void 0
721
723
  );
722
- function useStore$2(options) {
723
- const store = useContext(StoreContext$1);
724
- return store || getDefaultStore$1();
724
+ function useStore$1(options) {
725
+ const store = useContext(StoreContext);
726
+ return store || getDefaultStore();
725
727
  }
726
728
 
727
- const isPromiseLike$2 = (x) => typeof (x == null ? void 0 : x.then) === "function";
728
- const attachPromiseStatus$1 = (promise) => {
729
+ const isPromiseLike = (x) => typeof (x == null ? void 0 : x.then) === "function";
730
+ const attachPromiseStatus = (promise) => {
729
731
  if (!promise.status) {
730
732
  promise.status = "pending";
731
733
  promise.then(
@@ -740,7 +742,7 @@ const attachPromiseStatus$1 = (promise) => {
740
742
  );
741
743
  }
742
744
  };
743
- const use$1 = React__default.use || // A shim for older React versions
745
+ const use = React__default.use || // A shim for older React versions
744
746
  ((promise) => {
745
747
  if (promise.status === "pending") {
746
748
  throw promise;
@@ -749,13 +751,13 @@ const use$1 = React__default.use || // A shim for older React versions
749
751
  } else if (promise.status === "rejected") {
750
752
  throw promise.reason;
751
753
  } else {
752
- attachPromiseStatus$1(promise);
754
+ attachPromiseStatus(promise);
753
755
  throw promise;
754
756
  }
755
757
  });
756
- const continuablePromiseMap$1 = /* @__PURE__ */ new WeakMap();
757
- const createContinuablePromise$1 = (promise, getValue) => {
758
- let continuablePromise = continuablePromiseMap$1.get(promise);
758
+ const continuablePromiseMap = /* @__PURE__ */ new WeakMap();
759
+ const createContinuablePromise = (promise, getValue) => {
760
+ let continuablePromise = continuablePromiseMap.get(promise);
759
761
  if (!continuablePromise) {
760
762
  continuablePromise = new Promise((resolve, reject) => {
761
763
  let curr = promise;
@@ -772,11 +774,11 @@ const createContinuablePromise$1 = (promise, getValue) => {
772
774
  const onAbort = () => {
773
775
  try {
774
776
  const nextValue = getValue();
775
- if (isPromiseLike$2(nextValue)) {
776
- continuablePromiseMap$1.set(nextValue, continuablePromise);
777
+ if (isPromiseLike(nextValue)) {
778
+ continuablePromiseMap.set(nextValue, continuablePromise);
777
779
  curr = nextValue;
778
780
  nextValue.then(onFulfilled(nextValue), onRejected(nextValue));
779
- registerAbortHandler$1(nextValue, onAbort);
781
+ registerAbortHandler(nextValue, onAbort);
780
782
  } else {
781
783
  resolve(nextValue);
782
784
  }
@@ -785,15 +787,15 @@ const createContinuablePromise$1 = (promise, getValue) => {
785
787
  }
786
788
  };
787
789
  promise.then(onFulfilled(promise), onRejected(promise));
788
- registerAbortHandler$1(promise, onAbort);
790
+ registerAbortHandler(promise, onAbort);
789
791
  });
790
- continuablePromiseMap$1.set(promise, continuablePromise);
792
+ continuablePromiseMap.set(promise, continuablePromise);
791
793
  }
792
794
  return continuablePromise;
793
795
  };
794
- function useAtomValue$1(atom, options) {
796
+ function useAtomValue(atom, options) {
795
797
  const { delay, unstable_promiseStatus: promiseStatus = !React__default.use } = {};
796
- const store = useStore$2();
798
+ const store = useStore$1();
797
799
  const [[valueFromReducer, storeFromReducer, atomFromReducer], rerender] = useReducer(
798
800
  (prev) => {
799
801
  const nextValue = store.get(atom);
@@ -815,9 +817,9 @@ function useAtomValue$1(atom, options) {
815
817
  if (promiseStatus) {
816
818
  try {
817
819
  const value2 = store.get(atom);
818
- if (isPromiseLike$2(value2)) {
819
- attachPromiseStatus$1(
820
- createContinuablePromise$1(value2, () => store.get(atom))
820
+ if (isPromiseLike(value2)) {
821
+ attachPromiseStatus(
822
+ createContinuablePromise(value2, () => store.get(atom))
821
823
  );
822
824
  }
823
825
  } catch (e) {
@@ -833,18 +835,18 @@ function useAtomValue$1(atom, options) {
833
835
  return unsub;
834
836
  }, [store, atom, delay, promiseStatus]);
835
837
  useDebugValue(value);
836
- if (isPromiseLike$2(value)) {
837
- const promise = createContinuablePromise$1(value, () => store.get(atom));
838
+ if (isPromiseLike(value)) {
839
+ const promise = createContinuablePromise(value, () => store.get(atom));
838
840
  if (promiseStatus) {
839
- attachPromiseStatus$1(promise);
841
+ attachPromiseStatus(promise);
840
842
  }
841
- return use$1(promise);
843
+ return use(promise);
842
844
  }
843
845
  return value;
844
846
  }
845
847
 
846
- function useSetAtom$1(atom, options) {
847
- const store = useStore$2();
848
+ function useSetAtom(atom, options) {
849
+ const store = useStore$1();
848
850
  const setAtom = useCallback(
849
851
  (...args) => {
850
852
  if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production" && !("write" in atom)) {
@@ -857,11 +859,11 @@ function useSetAtom$1(atom, options) {
857
859
  return setAtom;
858
860
  }
859
861
 
860
- function useAtom$1(atom, options) {
862
+ function useAtom(atom, options) {
861
863
  return [
862
- useAtomValue$1(atom),
864
+ useAtomValue(atom),
863
865
  // We do wrong type assertion here, which results in throwing an error.
864
- useSetAtom$1(atom)
866
+ useSetAtom(atom)
865
867
  ];
866
868
  }/* eslint-disable @typescript-eslint/no-explicit-any */
867
869
  /**
@@ -1043,12 +1045,12 @@ function memoize(fn, cacheKeyFn) {
1043
1045
  }
1044
1046
  };
1045
1047
  return createAtom;
1046
- }const pageVariablesAtomFamily = atomFamily(_pageId => atom$1({}));
1048
+ }const pageVariablesAtomFamily = atomFamily(_pageId => atom({}));
1047
1049
  /**
1048
1050
  * Global atom storing all page variables.
1049
1051
  * Key format: "scopeId:pageId"
1050
1052
  */
1051
- const pageVariablesAtom = atom$1({});
1053
+ const pageVariablesAtom = atom({});
1052
1054
  /**
1053
1055
  * Helper to generate composite keys for page variables.
1054
1056
  */
@@ -1056,7 +1058,7 @@ const getPageVariablesCompositeKey = (scopeId, key) => `${scopeId}:${key}`;
1056
1058
  /**
1057
1059
  * Creates a derived atom for accessing page variables of a specific scope.
1058
1060
  */
1059
- const createScopePageVariablesAtom = scopeId => atom$1(get => {
1061
+ const createScopePageVariablesAtom = scopeId => atom(get => {
1060
1062
  const allPageVariables = get(pageVariablesAtom);
1061
1063
  const prefix = `${scopeId}:`;
1062
1064
  const scopePageVariables = {};
@@ -1110,7 +1112,7 @@ const usePageValues = ({
1110
1112
  });
1111
1113
  const subscriptions = useRef(new Map());
1112
1114
  const [trigger, setTrigger] = useState(0);
1113
- const [pageVariables, setPageVariables] = useAtom$1(pageVariablesAtomFamily(pageId));
1115
+ const [pageVariables, setPageVariables] = useAtom(pageVariablesAtomFamily(pageId));
1114
1116
  const initialized = useRef(false);
1115
1117
  useEffect(() => {
1116
1118
  if (!initialized.current && initialValues) {
@@ -2570,10 +2572,11 @@ function partialMatchKey(a, b) {
2570
2572
  return false;
2571
2573
  }
2572
2574
  var hasOwn = Object.prototype.hasOwnProperty;
2573
- function replaceEqualDeep(a, b) {
2575
+ function replaceEqualDeep(a, b, depth = 0) {
2574
2576
  if (a === b) {
2575
2577
  return a;
2576
2578
  }
2579
+ if (depth > 500) return b;
2577
2580
  const array = isPlainArray(a) && isPlainArray(b);
2578
2581
  if (!array && !(isPlainObject$1(a) && isPlainObject$1(b))) return b;
2579
2582
  const aItems = array ? a : Object.keys(a);
@@ -2595,7 +2598,7 @@ function replaceEqualDeep(a, b) {
2595
2598
  copy[key] = bItem;
2596
2599
  continue;
2597
2600
  }
2598
- const v = replaceEqualDeep(aItem, bItem);
2601
+ const v = replaceEqualDeep(aItem, bItem, depth + 1);
2599
2602
  copy[key] = v;
2600
2603
  if (v === aItem) equalItems++;
2601
2604
  }
@@ -2667,7 +2670,7 @@ function addToStart(items, item, max = 0) {
2667
2670
  const newItems = [item, ...items];
2668
2671
  return max && newItems.length > max ? newItems.slice(0, -1) : newItems;
2669
2672
  }
2670
- var skipToken = Symbol();
2673
+ var skipToken = /* @__PURE__ */Symbol();
2671
2674
  function ensureQueryFn(options, fetchOptions) {
2672
2675
  if (process.env.NODE_ENV !== "production") {
2673
2676
  if (options.queryFn === skipToken) {
@@ -2687,6 +2690,29 @@ function shouldThrowError(throwOnError, params) {
2687
2690
  return throwOnError(...params);
2688
2691
  }
2689
2692
  return !!throwOnError;
2693
+ }
2694
+ function addConsumeAwareSignal(object, getSignal, onCancelled) {
2695
+ let consumed = false;
2696
+ let signal;
2697
+ Object.defineProperty(object, "signal", {
2698
+ enumerable: true,
2699
+ get: () => {
2700
+ signal ??= getSignal();
2701
+ if (consumed) {
2702
+ return signal;
2703
+ }
2704
+ consumed = true;
2705
+ if (signal.aborted) {
2706
+ onCancelled();
2707
+ } else {
2708
+ signal.addEventListener("abort", onCancelled, {
2709
+ once: true
2710
+ });
2711
+ }
2712
+ return signal;
2713
+ }
2714
+ });
2715
+ return object;
2690
2716
  }// src/focusManager.ts
2691
2717
  var FocusManager = class extends Subscribable {
2692
2718
  #focused;
@@ -2807,16 +2833,19 @@ function dehydrateMutation(mutation) {
2807
2833
  };
2808
2834
  }
2809
2835
  function dehydrateQuery(query, serializeData, shouldRedactErrors) {
2810
- const promise = query.promise?.then(serializeData).catch(error => {
2811
- if (!shouldRedactErrors(error)) {
2812
- return Promise.reject(error);
2813
- }
2814
- if (process.env.NODE_ENV !== "production") {
2815
- console.error(`A query that was dehydrated as pending ended up rejecting. [${query.queryHash}]: ${error}; The error will be redacted in production builds`);
2816
- }
2817
- return Promise.reject(new Error("redacted"));
2818
- });
2819
- promise?.catch(noop$1);
2836
+ const dehydratePromise = () => {
2837
+ const promise = query.promise?.then(serializeData).catch(error => {
2838
+ if (!shouldRedactErrors(error)) {
2839
+ return Promise.reject(error);
2840
+ }
2841
+ if (process.env.NODE_ENV !== "production") {
2842
+ console.error(`A query that was dehydrated as pending ended up rejecting. [${query.queryHash}]: ${error}; The error will be redacted in production builds`);
2843
+ }
2844
+ return Promise.reject(new Error("redacted"));
2845
+ });
2846
+ promise?.catch(noop$1);
2847
+ return promise;
2848
+ };
2820
2849
  return {
2821
2850
  dehydratedAt: Date.now(),
2822
2851
  state: {
@@ -2828,7 +2857,7 @@ function dehydrateQuery(query, serializeData, shouldRedactErrors) {
2828
2857
  queryKey: query.queryKey,
2829
2858
  queryHash: query.queryHash,
2830
2859
  ...(query.state.status === "pending" && {
2831
- promise
2860
+ promise: dehydratePromise()
2832
2861
  }),
2833
2862
  ...(query.meta && {
2834
2863
  meta: query.meta
@@ -3372,7 +3401,7 @@ var Query = class extends Removable {
3372
3401
  }
3373
3402
  async fetch(options, fetchOptions) {
3374
3403
  if (this.state.fetchStatus !== "idle" &&
3375
- // If the promise in the retyer is already rejected, we have to definitely
3404
+ // If the promise in the retryer is already rejected, we have to definitely
3376
3405
  // re-start the fetch; there is a chance that the query is still in a
3377
3406
  // pending state when that happens
3378
3407
  this.#retryer?.status() !== "rejected") {
@@ -3564,7 +3593,10 @@ var Query = class extends Removable {
3564
3593
  fetchFailureCount: state.fetchFailureCount + 1,
3565
3594
  fetchFailureReason: error,
3566
3595
  fetchStatus: "idle",
3567
- status: "error"
3596
+ status: "error",
3597
+ // flag existing data as invalidated if we get a background error
3598
+ // note that "no data" always means stale so we can set unconditionally here
3599
+ isInvalidated: true
3568
3600
  };
3569
3601
  case "invalidate":
3570
3602
  return {
@@ -3932,10 +3964,12 @@ var QueryObserver = class extends Subscribable {
3932
3964
  };
3933
3965
  const nextResult = result;
3934
3966
  if (this.options.experimental_prefetchInRender) {
3967
+ const hasResultData = nextResult.data !== void 0;
3968
+ const isErrorWithoutData = nextResult.status === "error" && !hasResultData;
3935
3969
  const finalizeThenableIfPossible = thenable => {
3936
- if (nextResult.status === "error") {
3970
+ if (isErrorWithoutData) {
3937
3971
  thenable.reject(nextResult.error);
3938
- } else if (nextResult.data !== void 0) {
3972
+ } else if (hasResultData) {
3939
3973
  thenable.resolve(nextResult.data);
3940
3974
  }
3941
3975
  };
@@ -3951,12 +3985,12 @@ var QueryObserver = class extends Subscribable {
3951
3985
  }
3952
3986
  break;
3953
3987
  case "fulfilled":
3954
- if (nextResult.status === "error" || nextResult.data !== prevThenable.value) {
3988
+ if (isErrorWithoutData || nextResult.data !== prevThenable.value) {
3955
3989
  recreateThenable();
3956
3990
  }
3957
3991
  break;
3958
3992
  case "rejected":
3959
- if (nextResult.status !== "error" || nextResult.error !== prevThenable.reason) {
3993
+ if (!isErrorWithoutData || nextResult.error !== prevThenable.reason) {
3960
3994
  recreateThenable();
3961
3995
  }
3962
3996
  break;
@@ -4074,19 +4108,7 @@ function infiniteQueryBehavior(pages) {
4074
4108
  const fetchFn = async () => {
4075
4109
  let cancelled = false;
4076
4110
  const addSignalProperty = object => {
4077
- Object.defineProperty(object, "signal", {
4078
- enumerable: true,
4079
- get: () => {
4080
- if (context.signal.aborted) {
4081
- cancelled = true;
4082
- } else {
4083
- context.signal.addEventListener("abort", () => {
4084
- cancelled = true;
4085
- });
4086
- }
4087
- return context.signal;
4088
- }
4089
- });
4111
+ addConsumeAwareSignal(object, () => context.signal, () => cancelled = true);
4090
4112
  };
4091
4113
  const queryFn = ensureQueryFn(context.options, context.fetchOptions);
4092
4114
  const fetchPage = async (data, param, previous) => {
@@ -4271,7 +4293,9 @@ var Mutation = class extends Removable {
4271
4293
  variables,
4272
4294
  isPaused
4273
4295
  });
4274
- await this.#mutationCache.config.onMutate?.(variables, this, mutationFnContext);
4296
+ if (this.#mutationCache.config.onMutate) {
4297
+ await this.#mutationCache.config.onMutate(variables, this, mutationFnContext);
4298
+ }
4275
4299
  const context = await this.options.onMutate?.(variables, mutationFnContext);
4276
4300
  if (context !== this.state.context) {
4277
4301
  this.#dispatch({
@@ -4295,16 +4319,29 @@ var Mutation = class extends Removable {
4295
4319
  } catch (error) {
4296
4320
  try {
4297
4321
  await this.#mutationCache.config.onError?.(error, variables, this.state.context, this, mutationFnContext);
4322
+ } catch (e) {
4323
+ void Promise.reject(e);
4324
+ }
4325
+ try {
4298
4326
  await this.options.onError?.(error, variables, this.state.context, mutationFnContext);
4327
+ } catch (e) {
4328
+ void Promise.reject(e);
4329
+ }
4330
+ try {
4299
4331
  await this.#mutationCache.config.onSettled?.(void 0, error, this.state.variables, this.state.context, this, mutationFnContext);
4332
+ } catch (e) {
4333
+ void Promise.reject(e);
4334
+ }
4335
+ try {
4300
4336
  await this.options.onSettled?.(void 0, error, variables, this.state.context, mutationFnContext);
4301
- throw error;
4302
- } finally {
4303
- this.#dispatch({
4304
- type: "error",
4305
- error
4306
- });
4337
+ } catch (e) {
4338
+ void Promise.reject(e);
4307
4339
  }
4340
+ this.#dispatch({
4341
+ type: "error",
4342
+ error
4343
+ });
4344
+ throw error;
4308
4345
  } finally {
4309
4346
  this.#mutationCache.runNext(this);
4310
4347
  }
@@ -4588,11 +4625,27 @@ var MutationObserver = class extends Subscribable {
4588
4625
  mutationKey: this.options.mutationKey
4589
4626
  };
4590
4627
  if (action?.type === "success") {
4591
- this.#mutateOptions.onSuccess?.(action.data, variables, onMutateResult, context);
4592
- this.#mutateOptions.onSettled?.(action.data, null, variables, onMutateResult, context);
4628
+ try {
4629
+ this.#mutateOptions.onSuccess?.(action.data, variables, onMutateResult, context);
4630
+ } catch (e) {
4631
+ void Promise.reject(e);
4632
+ }
4633
+ try {
4634
+ this.#mutateOptions.onSettled?.(action.data, null, variables, onMutateResult, context);
4635
+ } catch (e) {
4636
+ void Promise.reject(e);
4637
+ }
4593
4638
  } else if (action?.type === "error") {
4594
- this.#mutateOptions.onError?.(action.error, variables, onMutateResult, context);
4595
- this.#mutateOptions.onSettled?.(void 0, action.error, variables, onMutateResult, context);
4639
+ try {
4640
+ this.#mutateOptions.onError?.(action.error, variables, onMutateResult, context);
4641
+ } catch (e) {
4642
+ void Promise.reject(e);
4643
+ }
4644
+ try {
4645
+ this.#mutateOptions.onSettled?.(void 0, action.error, variables, onMutateResult, context);
4646
+ } catch (e) {
4647
+ void Promise.reject(e);
4648
+ }
4596
4649
  }
4597
4650
  }
4598
4651
  this.listeners.forEach(listener => {
@@ -4619,6 +4672,7 @@ var QueriesObserver = class extends Subscribable {
4619
4672
  #combinedResult;
4620
4673
  #lastCombine;
4621
4674
  #lastResult;
4675
+ #lastQueryHashes;
4622
4676
  #observerMatches = [];
4623
4677
  constructor(client, queries, options) {
4624
4678
  super();
@@ -4661,7 +4715,6 @@ var QueriesObserver = class extends Subscribable {
4661
4715
  notifyManager.batch(() => {
4662
4716
  const prevObservers = this.#observers;
4663
4717
  const newObserverMatches = this.#findMatchingObservers(this.#queries);
4664
- this.#observerMatches = newObserverMatches;
4665
4718
  newObserverMatches.forEach(match => match.observer.setOptions(match.defaultedQueryOptions));
4666
4719
  const newObservers = newObserverMatches.map(match => match.observer);
4667
4720
  const newResult = newObservers.map(observer => observer.getCurrentResult());
@@ -4674,6 +4727,7 @@ var QueriesObserver = class extends Subscribable {
4674
4727
  });
4675
4728
  if (!hasStructuralChange && !hasResultChange) return;
4676
4729
  if (hasStructuralChange) {
4730
+ this.#observerMatches = newObserverMatches;
4677
4731
  this.#observers = newObservers;
4678
4732
  }
4679
4733
  this.#result = newResult;
@@ -4703,8 +4757,9 @@ var QueriesObserver = class extends Subscribable {
4703
4757
  getOptimisticResult(queries, combine) {
4704
4758
  const matches = this.#findMatchingObservers(queries);
4705
4759
  const result = matches.map(match => match.observer.getOptimisticResult(match.defaultedQueryOptions));
4760
+ const queryHashes = matches.map(match => match.defaultedQueryOptions.queryHash);
4706
4761
  return [result, r => {
4707
- return this.#combineResult(r ?? result, combine);
4762
+ return this.#combineResult(r ?? result, combine, queryHashes);
4708
4763
  }, () => {
4709
4764
  return this.#trackResult(result, matches);
4710
4765
  }];
@@ -4719,11 +4774,16 @@ var QueriesObserver = class extends Subscribable {
4719
4774
  }) : observerResult;
4720
4775
  });
4721
4776
  }
4722
- #combineResult(input, combine) {
4777
+ #combineResult(input, combine, queryHashes) {
4723
4778
  if (combine) {
4724
- if (!this.#combinedResult || this.#result !== this.#lastResult || combine !== this.#lastCombine) {
4779
+ const lastHashes = this.#lastQueryHashes;
4780
+ const queryHashesChanged = queryHashes !== void 0 && lastHashes !== void 0 && (lastHashes.length !== queryHashes.length || queryHashes.some((hash, i) => hash !== lastHashes[i]));
4781
+ if (!this.#combinedResult || this.#result !== this.#lastResult || queryHashesChanged || combine !== this.#lastCombine) {
4725
4782
  this.#lastCombine = combine;
4726
4783
  this.#lastResult = this.#result;
4784
+ if (queryHashes !== void 0) {
4785
+ this.#lastQueryHashes = queryHashes;
4786
+ }
4727
4787
  this.#combinedResult = replaceEqualDeep(this.#combinedResult, combine(input));
4728
4788
  }
4729
4789
  return this.#combinedResult;
@@ -4731,22 +4791,26 @@ var QueriesObserver = class extends Subscribable {
4731
4791
  return input;
4732
4792
  }
4733
4793
  #findMatchingObservers(queries) {
4734
- const prevObserversMap = new Map(this.#observers.map(observer => [observer.options.queryHash, observer]));
4794
+ const prevObserversMap = /* @__PURE__ */new Map();
4795
+ this.#observers.forEach(observer => {
4796
+ const key = observer.options.queryHash;
4797
+ if (!key) return;
4798
+ const previousObservers = prevObserversMap.get(key);
4799
+ if (previousObservers) {
4800
+ previousObservers.push(observer);
4801
+ } else {
4802
+ prevObserversMap.set(key, [observer]);
4803
+ }
4804
+ });
4735
4805
  const observers = [];
4736
4806
  queries.forEach(options => {
4737
4807
  const defaultedOptions = this.#client.defaultQueryOptions(options);
4738
- const match = prevObserversMap.get(defaultedOptions.queryHash);
4739
- if (match) {
4740
- observers.push({
4741
- defaultedQueryOptions: defaultedOptions,
4742
- observer: match
4743
- });
4744
- } else {
4745
- observers.push({
4746
- defaultedQueryOptions: defaultedOptions,
4747
- observer: new QueryObserver(this.#client, defaultedOptions)
4748
- });
4749
- }
4808
+ const match = prevObserversMap.get(defaultedOptions.queryHash)?.shift();
4809
+ const observer = match ?? new QueryObserver(this.#client, defaultedOptions);
4810
+ observers.push({
4811
+ defaultedQueryOptions: defaultedOptions,
4812
+ observer
4813
+ });
4750
4814
  });
4751
4815
  return observers;
4752
4816
  }
@@ -5191,8 +5255,9 @@ function createValue() {
5191
5255
  }
5192
5256
  var QueryErrorResetBoundaryContext = React.createContext(createValue());
5193
5257
  var useQueryErrorResetBoundary = () => React.useContext(QueryErrorResetBoundaryContext);// src/errorBoundaryUtils.ts
5194
- var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => {
5195
- if (options.suspense || options.throwOnError || options.experimental_prefetchInRender) {
5258
+ var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary, query) => {
5259
+ const throwOnError = query?.state.error && typeof options.throwOnError === "function" ? shouldThrowError(options.throwOnError, [query.state.error, query]) : options.throwOnError;
5260
+ if (options.suspense || options.experimental_prefetchInRender || throwOnError) {
5196
5261
  if (!errorResetBoundary.isReset()) {
5197
5262
  options.retryOnMount = false;
5198
5263
  }
@@ -5248,9 +5313,10 @@ function useQueries({
5248
5313
  }),
5249
5314
  [queries, client, isRestoring]
5250
5315
  );
5251
- defaultedQueries.forEach((query) => {
5252
- ensureSuspenseTimers(query);
5253
- ensurePreventErrorBoundaryRetry(query, errorResetBoundary);
5316
+ defaultedQueries.forEach((queryOptions) => {
5317
+ ensureSuspenseTimers(queryOptions);
5318
+ const query = client.getQueryCache().get(queryOptions.queryHash);
5319
+ ensurePreventErrorBoundaryRetry(queryOptions, errorResetBoundary, query);
5254
5320
  });
5255
5321
  useClearResetErrorBoundary(errorResetBoundary);
5256
5322
  const [observer] = React.useState(
@@ -5329,6 +5395,7 @@ function useBaseQuery(options, Observer, queryClient) {
5329
5395
  client.getDefaultOptions().queries?._experimental_beforeQuery?.(
5330
5396
  defaultedOptions
5331
5397
  );
5398
+ const query = client.getQueryCache().get(defaultedOptions.queryHash);
5332
5399
  if (process.env.NODE_ENV !== "production") {
5333
5400
  if (!defaultedOptions.queryFn) {
5334
5401
  console.error(
@@ -5338,7 +5405,7 @@ function useBaseQuery(options, Observer, queryClient) {
5338
5405
  }
5339
5406
  defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
5340
5407
  ensureSuspenseTimers(defaultedOptions);
5341
- ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);
5408
+ ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary, query);
5342
5409
  useClearResetErrorBoundary(errorResetBoundary);
5343
5410
  const isNewCacheEntry = !client.getQueryCache().get(defaultedOptions.queryHash);
5344
5411
  const [observer] = React.useState(
@@ -5371,7 +5438,7 @@ function useBaseQuery(options, Observer, queryClient) {
5371
5438
  result,
5372
5439
  errorResetBoundary,
5373
5440
  throwOnError: defaultedOptions.throwOnError,
5374
- query: client.getQueryCache().get(defaultedOptions.queryHash),
5441
+ query,
5375
5442
  suspense: defaultedOptions.suspense
5376
5443
  })) {
5377
5444
  throw result.error;
@@ -5386,7 +5453,7 @@ function useBaseQuery(options, Observer, queryClient) {
5386
5453
  fetchOptimistic(defaultedOptions, observer, errorResetBoundary)
5387
5454
  ) : (
5388
5455
  // subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
5389
- client.getQueryCache().get(defaultedOptions.queryHash)?.promise
5456
+ query?.promise
5390
5457
  );
5391
5458
  promise?.catch(noop$1).finally(() => {
5392
5459
  observer.updateResult();
@@ -5893,7 +5960,7 @@ const MetadataManager = MetadataManagerImpl;const PageGenerator = _a => {
5893
5960
  return (_a_3 = mappedViewSettings.pageContainerProps) !== null && _a_3 !== void 0 ? _a_3 : {};
5894
5961
  }, [mappedViewSettings.pageContainerProps]);
5895
5962
  const layoutBody = useMemo(() => body, [body]);
5896
- const store = useStore$2();
5963
+ const store = useStore$1();
5897
5964
  const refreshQueries = useCallback(() => {
5898
5965
  const val = store.get(queriesAtom$1);
5899
5966
  Object.values(val).forEach(query => {
@@ -8204,7 +8271,17 @@ class FormApi {
8204
8271
  };
8205
8272
  this.validateField = (field, cause) => {
8206
8273
  const fieldInstance = this.fieldInfo[field]?.instance;
8207
- if (!fieldInstance) return [];
8274
+ if (!fieldInstance) {
8275
+ const {
8276
+ hasErrored
8277
+ } = this.validateSync(cause);
8278
+ if (hasErrored && !this.options.asyncAlways) {
8279
+ return this.getFieldMeta(field)?.errors ?? [];
8280
+ }
8281
+ return this.validateAsync(cause).then(() => {
8282
+ return this.getFieldMeta(field)?.errors ?? [];
8283
+ });
8284
+ }
8208
8285
  if (!fieldInstance.state.meta.isTouched) {
8209
8286
  fieldInstance.setMeta(prev => ({
8210
8287
  ...prev,
@@ -8891,7 +8968,7 @@ class FormApi {
8891
8968
  if (!prevBaseMeta || currBaseMeta.errorMap !== prevBaseMeta.errorMap) {
8892
8969
  fieldErrors = Object.values(currBaseMeta.errorMap ?? {}).filter(val => val !== void 0);
8893
8970
  const fieldInstance = this.getFieldInfo(fieldName)?.instance;
8894
- if (fieldInstance && !fieldInstance.options.disableErrorFlat) {
8971
+ if (!fieldInstance || !fieldInstance.options.disableErrorFlat) {
8895
8972
  fieldErrors = fieldErrors.flat(1);
8896
8973
  }
8897
8974
  }
@@ -9629,7 +9706,7 @@ function getErrorMapKey(cause) {
9629
9706
  default:
9630
9707
  return "onChange";
9631
9708
  }
9632
- }function useStore$1(store, selector = (d) => d, options = {}) {
9709
+ }function useStore(store, selector = (d) => d, options = {}) {
9633
9710
  const equal = options.equal ?? shallow;
9634
9711
  const slice = useSyncExternalStoreWithSelector(
9635
9712
  store.subscribe,
@@ -9698,31 +9775,31 @@ function getOwnKeys(obj) {
9698
9775
  );
9699
9776
  setPrevOptions({ form: opts.form, name: opts.name });
9700
9777
  }
9701
- const reactiveStateValue = useStore$1(
9778
+ const reactiveStateValue = useStore(
9702
9779
  fieldApi.store,
9703
9780
  opts.mode === "array" ? (state) => Object.keys(state.value ?? []).length : (state) => state.value
9704
9781
  );
9705
- const reactiveMetaIsTouched = useStore$1(
9782
+ const reactiveMetaIsTouched = useStore(
9706
9783
  fieldApi.store,
9707
9784
  (state) => state.meta.isTouched
9708
9785
  );
9709
- const reactiveMetaIsBlurred = useStore$1(
9786
+ const reactiveMetaIsBlurred = useStore(
9710
9787
  fieldApi.store,
9711
9788
  (state) => state.meta.isBlurred
9712
9789
  );
9713
- const reactiveMetaIsDirty = useStore$1(
9790
+ const reactiveMetaIsDirty = useStore(
9714
9791
  fieldApi.store,
9715
9792
  (state) => state.meta.isDirty
9716
9793
  );
9717
- const reactiveMetaErrorMap = useStore$1(
9794
+ const reactiveMetaErrorMap = useStore(
9718
9795
  fieldApi.store,
9719
9796
  (state) => state.meta.errorMap
9720
9797
  );
9721
- const reactiveMetaErrorSourceMap = useStore$1(
9798
+ const reactiveMetaErrorSourceMap = useStore(
9722
9799
  fieldApi.store,
9723
9800
  (state) => state.meta.errorSourceMap
9724
9801
  );
9725
- const reactiveMetaIsValidating = useStore$1(
9802
+ const reactiveMetaIsValidating = useStore(
9726
9803
  fieldApi.store,
9727
9804
  (state) => state.meta.isValidating
9728
9805
  );
@@ -9785,7 +9862,7 @@ const Field = (({
9785
9862
  selector,
9786
9863
  children
9787
9864
  }) {
9788
- const data = useStore$1(form.store, selector);
9865
+ const data = useStore(form.store, selector);
9789
9866
  return /* @__PURE__ */ jsx(Fragment, { children: functionalUpdate(children, data) });
9790
9867
  }
9791
9868
  function useForm(opts) {
@@ -9907,7 +9984,7 @@ function useJotaiForm(formOptions) {
9907
9984
  return jsx(FormFieldContainer, {
9908
9985
  children: config.component(baseProps)
9909
9986
  });
9910
- };const RESET$1 = /* @__PURE__ */ Symbol(
9987
+ };const RESET = /* @__PURE__ */ Symbol(
9911
9988
  (import.meta.env ? import.meta.env.MODE : void 0) !== "production" ? "RESET" : ""
9912
9989
  );
9913
9990
 
@@ -9929,7 +10006,7 @@ function selectAtom(anAtom, selector, equalityFn = Object.is) {
9929
10006
  const slice = selector(value, prevSlice);
9930
10007
  return equalityFn(prevSlice, slice) ? prevSlice : slice;
9931
10008
  };
9932
- const derivedAtom = atom$1((get) => {
10009
+ const derivedAtom = atom((get) => {
9933
10010
  const prev = get(derivedAtom);
9934
10011
  const value = get(anAtom);
9935
10012
  return selectValue([value, prev]);
@@ -9943,8 +10020,8 @@ function selectAtom(anAtom, selector, equalityFn = Object.is) {
9943
10020
  );
9944
10021
  }
9945
10022
 
9946
- const isPromiseLike$3$1 = (x) => typeof (x == null ? void 0 : x.then) === "function";
9947
- function createJSONStorage$1(getStringStorage = () => {
10023
+ const isPromiseLike$2 = (x) => typeof (x == null ? void 0 : x.then) === "function";
10024
+ function createJSONStorage(getStringStorage = () => {
9948
10025
  try {
9949
10026
  return window.localStorage;
9950
10027
  } catch (e) {
@@ -9975,7 +10052,7 @@ function createJSONStorage$1(getStringStorage = () => {
9975
10052
  return lastValue;
9976
10053
  };
9977
10054
  const str = (_b = (_a2 = getStringStorage()) == null ? void 0 : _a2.getItem(key)) != null ? _b : null;
9978
- if (isPromiseLike$3$1(str)) {
10055
+ if (isPromiseLike$2(str)) {
9979
10056
  return str.then(parse);
9980
10057
  }
9981
10058
  return parse(str);
@@ -10028,10 +10105,10 @@ function createJSONStorage$1(getStringStorage = () => {
10028
10105
  }
10029
10106
  return storage;
10030
10107
  }
10031
- const defaultStorage$1 = createJSONStorage$1();
10032
- function atomWithStorage$1(key, initialValue, storage = defaultStorage$1, options) {
10108
+ const defaultStorage = createJSONStorage();
10109
+ function atomWithStorage(key, initialValue, storage = defaultStorage, options) {
10033
10110
  const getOnInit = options == null ? void 0 : options.getOnInit;
10034
- const baseAtom = atom$1(
10111
+ const baseAtom = atom(
10035
10112
  getOnInit ? storage.getItem(key, initialValue) : initialValue
10036
10113
  );
10037
10114
  if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production") {
@@ -10045,15 +10122,15 @@ function atomWithStorage$1(key, initialValue, storage = defaultStorage$1, option
10045
10122
  }
10046
10123
  return unsub;
10047
10124
  };
10048
- const anAtom = atom$1(
10125
+ const anAtom = atom(
10049
10126
  (get) => get(baseAtom),
10050
10127
  (get, set, update) => {
10051
10128
  const nextValue = typeof update === "function" ? update(get(baseAtom)) : update;
10052
- if (nextValue === RESET$1) {
10129
+ if (nextValue === RESET) {
10053
10130
  set(baseAtom, initialValue);
10054
10131
  return storage.removeItem(key);
10055
10132
  }
10056
- if (isPromiseLike$3$1(nextValue)) {
10133
+ if (isPromiseLike$2(nextValue)) {
10057
10134
  return nextValue.then((resolvedValue) => {
10058
10135
  set(baseAtom, resolvedValue);
10059
10136
  return storage.setItem(key, resolvedValue);
@@ -10072,7 +10149,7 @@ function atomWithStorage$1(key, initialValue, storage = defaultStorage$1, option
10072
10149
  * Global atom storing all form state.
10073
10150
  * Key format: "scopeId:formId" or just "formId" for backward compatibility.
10074
10151
  */
10075
- const formAtom = atom$1({});
10152
+ const formAtom = atom({});
10076
10153
  /**
10077
10154
  * Helper to generate composite keys for forms.
10078
10155
  */
@@ -10080,7 +10157,7 @@ const getFormCompositeKey = (scopeId, key) => `${scopeId}:${key}`;
10080
10157
  /**
10081
10158
  * Creates a derived atom for accessing forms of a specific scope.
10082
10159
  */
10083
- const createScopeFormsAtom = scopeId => atom$1(get => {
10160
+ const createScopeFormsAtom = scopeId => atom(get => {
10084
10161
  const allForms = get(formAtom);
10085
10162
  const prefix = `${scopeId}:`;
10086
10163
  const scopeForms = {};
@@ -10121,13 +10198,13 @@ const useFormValue = formId => {
10121
10198
  t0 = $[1];
10122
10199
  }
10123
10200
  const selectorAtom = t0;
10124
- return useAtomValue$1(selectorAtom);
10201
+ return useAtomValue(selectorAtom);
10125
10202
  };
10126
10203
  const useFormState = () => {
10127
- return useAtom$1(formAtom);
10204
+ return useAtom(formAtom);
10128
10205
  };
10129
10206
  const useSetFormState = formId => {
10130
- const setForms = useSetAtom$1(formAtom);
10207
+ const setForms = useSetAtom(formAtom);
10131
10208
  return useCallback(val => {
10132
10209
  setForms(prev => {
10133
10210
  var _a;
@@ -11010,14 +11087,14 @@ const DEFAULT_MUTATION_ENTRY = Object.freeze({
11010
11087
  * Global atom storing all query results.
11011
11088
  * Key format: "scopeId:queryKey"
11012
11089
  */
11013
- const queriesAtom = atomWithStorage$1('queries-atom', {}, createJSONStorage$1(() => storage$1), {
11090
+ const queriesAtom = atomWithStorage('queries-atom', {}, createJSONStorage(() => storage$1), {
11014
11091
  getOnInit: true
11015
11092
  });
11016
11093
  /**
11017
11094
  * Global atom storing all mutation results.
11018
11095
  * Key format: "scopeId:mutationKey"
11019
11096
  */
11020
- const mutationsAtom = atom$1({});
11097
+ const mutationsAtom = atom({});
11021
11098
  // ============================================================================
11022
11099
  // Helper to generate composite keys
11023
11100
  // ============================================================================
@@ -11028,7 +11105,7 @@ const getCompositeKey = (scopeId, key) => `${scopeId}:${key}`;
11028
11105
  /**
11029
11106
  * Creates a derived atom for accessing queries of a specific scope.
11030
11107
  */
11031
- const createScopeQueriesAtom = scopeId => atom$1(get => {
11108
+ const createScopeQueriesAtom = scopeId => atom(get => {
11032
11109
  const allQueries = get(queriesAtom);
11033
11110
  const prefix = `${scopeId}:`;
11034
11111
  const scopeQueries = {};
@@ -11057,7 +11134,7 @@ const createScopeQueriesAtom = scopeId => atom$1(get => {
11057
11134
  /**
11058
11135
  * Creates a derived atom for accessing mutations of a specific scope.
11059
11136
  */
11060
- const createScopeMutationsAtom = scopeId => atom$1(get => {
11137
+ const createScopeMutationsAtom = scopeId => atom(get => {
11061
11138
  const allMutations = get(mutationsAtom);
11062
11139
  const prefix = `${scopeId}:`;
11063
11140
  const scopeMutations = {};
@@ -11356,10 +11433,11 @@ const trim = str => str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uF
11356
11433
  * If 'obj' is an Object callback will be called passing
11357
11434
  * the value, key, and complete object for each property.
11358
11435
  *
11359
- * @param {Object|Array} obj The object to iterate
11436
+ * @param {Object|Array<unknown>} obj The object to iterate
11360
11437
  * @param {Function} fn The callback to invoke for each item
11361
11438
  *
11362
- * @param {Boolean} [allOwnKeys = false]
11439
+ * @param {Object} [options]
11440
+ * @param {Boolean} [options.allOwnKeys = false]
11363
11441
  * @returns {any}
11364
11442
  */
11365
11443
  function forEach(obj, fn, {
@@ -11431,7 +11509,7 @@ const isContextDefined = context => !isUndefined(context) && context !== _global
11431
11509
  * Example:
11432
11510
  *
11433
11511
  * ```js
11434
- * var result = merge({foo: 123}, {foo: 456});
11512
+ * const result = merge({foo: 123}, {foo: 456});
11435
11513
  * console.log(result.foo); // outputs 456
11436
11514
  * ```
11437
11515
  *
@@ -11471,7 +11549,8 @@ function merge(/* obj1, obj2, obj3, ... */
11471
11549
  * @param {Object} b The object to copy properties from
11472
11550
  * @param {Object} thisArg The object to bind function to
11473
11551
  *
11474
- * @param {Boolean} [allOwnKeys]
11552
+ * @param {Object} [options]
11553
+ * @param {Boolean} [options.allOwnKeys]
11475
11554
  * @returns {Object} The resulting value of object a
11476
11555
  */
11477
11556
  const extend = (a, b, thisArg, {
@@ -11479,9 +11558,19 @@ const extend = (a, b, thisArg, {
11479
11558
  } = {}) => {
11480
11559
  forEach(b, (val, key) => {
11481
11560
  if (thisArg && isFunction$1(val)) {
11482
- a[key] = bind(val, thisArg);
11561
+ Object.defineProperty(a, key, {
11562
+ value: bind(val, thisArg),
11563
+ writable: true,
11564
+ enumerable: true,
11565
+ configurable: true
11566
+ });
11483
11567
  } else {
11484
- a[key] = val;
11568
+ Object.defineProperty(a, key, {
11569
+ value: val,
11570
+ writable: true,
11571
+ enumerable: true,
11572
+ configurable: true
11573
+ });
11485
11574
  }
11486
11575
  }, {
11487
11576
  allOwnKeys
@@ -11514,7 +11603,12 @@ const stripBOM = content => {
11514
11603
  */
11515
11604
  const inherits = (constructor, superConstructor, props, descriptors) => {
11516
11605
  constructor.prototype = Object.create(superConstructor.prototype, descriptors);
11517
- constructor.prototype.constructor = constructor;
11606
+ Object.defineProperty(constructor.prototype, 'constructor', {
11607
+ value: constructor,
11608
+ writable: true,
11609
+ enumerable: false,
11610
+ configurable: true
11611
+ });
11518
11612
  Object.defineProperty(constructor, 'super', {
11519
11613
  value: superConstructor.prototype
11520
11614
  });
@@ -11841,36 +11935,39 @@ var utils$1 = {
11841
11935
  setImmediate: _setImmediate,
11842
11936
  asap,
11843
11937
  isIterable
11844
- };/**
11845
- * Create an Error with the specified message, config, error code, request and response.
11846
- *
11847
- * @param {string} message The error message.
11848
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
11849
- * @param {Object} [config] The config.
11850
- * @param {Object} [request] The request.
11851
- * @param {Object} [response] The response.
11852
- *
11853
- * @returns {Error} The created error.
11854
- */
11855
- function AxiosError(message, code, config, request, response) {
11856
- Error.call(this);
11857
- if (Error.captureStackTrace) {
11858
- Error.captureStackTrace(this, this.constructor);
11859
- } else {
11860
- this.stack = new Error().stack;
11938
+ };class AxiosError extends Error {
11939
+ static from(error, code, config, request, response, customProps) {
11940
+ const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
11941
+ axiosError.cause = error;
11942
+ axiosError.name = error.name;
11943
+ customProps && Object.assign(axiosError, customProps);
11944
+ return axiosError;
11861
11945
  }
11862
- this.message = message;
11863
- this.name = 'AxiosError';
11864
- code && (this.code = code);
11865
- config && (this.config = config);
11866
- request && (this.request = request);
11867
- if (response) {
11868
- this.response = response;
11869
- this.status = response.status ? response.status : null;
11870
- }
11871
- }
11872
- utils$1.inherits(AxiosError, Error, {
11873
- toJSON: function toJSON() {
11946
+
11947
+ /**
11948
+ * Create an Error with the specified message, config, error code, request and response.
11949
+ *
11950
+ * @param {string} message The error message.
11951
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
11952
+ * @param {Object} [config] The config.
11953
+ * @param {Object} [request] The request.
11954
+ * @param {Object} [response] The response.
11955
+ *
11956
+ * @returns {Error} The created error.
11957
+ */
11958
+ constructor(message, code, config, request, response) {
11959
+ super(message);
11960
+ this.name = 'AxiosError';
11961
+ this.isAxiosError = true;
11962
+ code && (this.code = code);
11963
+ config && (this.config = config);
11964
+ request && (this.request = request);
11965
+ if (response) {
11966
+ this.response = response;
11967
+ this.status = response.status;
11968
+ }
11969
+ }
11970
+ toJSON() {
11874
11971
  return {
11875
11972
  // Standard
11876
11973
  message: this.message,
@@ -11889,46 +11986,21 @@ utils$1.inherits(AxiosError, Error, {
11889
11986
  status: this.status
11890
11987
  };
11891
11988
  }
11892
- });
11893
- const prototype$1 = AxiosError.prototype;
11894
- const descriptors = {};
11895
- ['ERR_BAD_OPTION_VALUE', 'ERR_BAD_OPTION', 'ECONNABORTED', 'ETIMEDOUT', 'ERR_NETWORK', 'ERR_FR_TOO_MANY_REDIRECTS', 'ERR_DEPRECATED', 'ERR_BAD_RESPONSE', 'ERR_BAD_REQUEST', 'ERR_CANCELED', 'ERR_NOT_SUPPORT', 'ERR_INVALID_URL'
11896
- // eslint-disable-next-line func-names
11897
- ].forEach(code => {
11898
- descriptors[code] = {
11899
- value: code
11900
- };
11901
- });
11902
- Object.defineProperties(AxiosError, descriptors);
11903
- Object.defineProperty(prototype$1, 'isAxiosError', {
11904
- value: true
11905
- });
11906
-
11907
- // eslint-disable-next-line func-names
11908
- AxiosError.from = (error, code, config, request, response, customProps) => {
11909
- const axiosError = Object.create(prototype$1);
11910
- utils$1.toFlatObject(error, axiosError, function filter(obj) {
11911
- return obj !== Error.prototype;
11912
- }, prop => {
11913
- return prop !== 'isAxiosError';
11914
- });
11915
- const msg = error && error.message ? error.message : 'Error';
11916
-
11917
- // Prefer explicit code; otherwise copy the low-level error's code (e.g. ECONNREFUSED)
11918
- const errCode = code == null && error ? error.code : code;
11919
- AxiosError.call(axiosError, msg, errCode, config, request, response);
11989
+ }
11920
11990
 
11921
- // Chain the original error on the standard field; non-enumerable to avoid JSON noise
11922
- if (error && axiosError.cause == null) {
11923
- Object.defineProperty(axiosError, 'cause', {
11924
- value: error,
11925
- configurable: true
11926
- });
11927
- }
11928
- axiosError.name = error && error.name || 'Error';
11929
- customProps && Object.assign(axiosError, customProps);
11930
- return axiosError;
11931
- };// eslint-disable-next-line strict
11991
+ // This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
11992
+ AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
11993
+ AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
11994
+ AxiosError.ECONNABORTED = 'ECONNABORTED';
11995
+ AxiosError.ETIMEDOUT = 'ETIMEDOUT';
11996
+ AxiosError.ERR_NETWORK = 'ERR_NETWORK';
11997
+ AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
11998
+ AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
11999
+ AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
12000
+ AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
12001
+ AxiosError.ERR_CANCELED = 'ERR_CANCELED';
12002
+ AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
12003
+ AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';// eslint-disable-next-line strict
11932
12004
  var httpAdapter = null;/**
11933
12005
  * Determines if the given thing is a array or js object.
11934
12006
  *
@@ -12178,22 +12250,19 @@ function encode(val) {
12178
12250
  * @returns {string} The formatted url
12179
12251
  */
12180
12252
  function buildURL(url, params, options) {
12181
- /*eslint no-param-reassign:0*/
12182
12253
  if (!params) {
12183
12254
  return url;
12184
12255
  }
12185
12256
  const _encode = options && options.encode || encode;
12186
- if (utils$1.isFunction(options)) {
12187
- options = {
12188
- serialize: options
12189
- };
12190
- }
12191
- const serializeFn = options && options.serialize;
12257
+ const _options = utils$1.isFunction(options) ? {
12258
+ serialize: options
12259
+ } : options;
12260
+ const serializeFn = _options && _options.serialize;
12192
12261
  let serializedParams;
12193
12262
  if (serializeFn) {
12194
- serializedParams = serializeFn(params, options);
12263
+ serializedParams = serializeFn(params, _options);
12195
12264
  } else {
12196
- serializedParams = utils$1.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, options).toString(_encode);
12265
+ serializedParams = utils$1.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, _options).toString(_encode);
12197
12266
  }
12198
12267
  if (serializedParams) {
12199
12268
  const hashmarkIndex = url.indexOf("#");
@@ -12213,6 +12282,7 @@ function buildURL(url, params, options) {
12213
12282
  *
12214
12283
  * @param {Function} fulfilled The function to handle `then` for a `Promise`
12215
12284
  * @param {Function} rejected The function to handle `reject` for a `Promise`
12285
+ * @param {Object} options The options for the interceptor, synchronous and runWhen
12216
12286
  *
12217
12287
  * @return {Number} An ID used to remove interceptor later
12218
12288
  */
@@ -12811,23 +12881,22 @@ function transformData(fns, response) {
12811
12881
  return data;
12812
12882
  }function isCancel(value) {
12813
12883
  return !!(value && value.__CANCEL__);
12884
+ }class CanceledError extends AxiosError {
12885
+ /**
12886
+ * A `CanceledError` is an object that is thrown when an operation is canceled.
12887
+ *
12888
+ * @param {string=} message The message.
12889
+ * @param {Object=} config The config.
12890
+ * @param {Object=} request The request.
12891
+ *
12892
+ * @returns {CanceledError} The created error.
12893
+ */
12894
+ constructor(message, config, request) {
12895
+ super(message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
12896
+ this.name = 'CanceledError';
12897
+ this.__CANCEL__ = true;
12898
+ }
12814
12899
  }/**
12815
- * A `CanceledError` is an object that is thrown when an operation is canceled.
12816
- *
12817
- * @param {string=} message The message.
12818
- * @param {Object=} config The config.
12819
- * @param {Object=} request The request.
12820
- *
12821
- * @returns {CanceledError} The created error.
12822
- */
12823
- function CanceledError(message, config, request) {
12824
- // eslint-disable-next-line no-eq-null,eqeqeq
12825
- AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
12826
- this.name = 'CanceledError';
12827
- }
12828
- utils$1.inherits(CanceledError, AxiosError, {
12829
- __CANCEL__: true
12830
- });/**
12831
12900
  * Resolve or reject a Promise based on response status.
12832
12901
  *
12833
12902
  * @param {Function} resolve A function that resolves the promise.
@@ -13062,8 +13131,6 @@ function mergeConfig(config1, config2) {
13062
13131
  }
13063
13132
  return source;
13064
13133
  }
13065
-
13066
- // eslint-disable-next-line consistent-return
13067
13134
  function mergeDeepProperties(a, b, prop, caseless) {
13068
13135
  if (!utils$1.isUndefined(b)) {
13069
13136
  return getMergedValue(a, b, prop, caseless);
@@ -13370,7 +13437,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
13370
13437
  };
13371
13438
  let timer = timeout && setTimeout(() => {
13372
13439
  timer = null;
13373
- onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
13440
+ onabort(new AxiosError(`timeout of ${timeout}ms exceeded`, AxiosError.ETIMEDOUT));
13374
13441
  }, timeout);
13375
13442
  const unsubscribe = () => {
13376
13443
  if (signals) {
@@ -13835,7 +13902,7 @@ function dispatchRequest(config) {
13835
13902
  }
13836
13903
  return Promise.reject(reason);
13837
13904
  });
13838
- }const VERSION = "1.13.1";const validators$1 = {};
13905
+ }const VERSION = "1.13.4";const validators$1 = {};
13839
13906
 
13840
13907
  // eslint-disable-next-line func-names
13841
13908
  ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => {
@@ -14228,7 +14295,7 @@ class CancelToken {
14228
14295
  *
14229
14296
  * ```js
14230
14297
  * function f(x, y, z) {}
14231
- * var args = [1, 2, 3];
14298
+ * const args = [1, 2, 3];
14232
14299
  * f.apply(null, args);
14233
14300
  * ```
14234
14301
  *
@@ -14580,7 +14647,7 @@ const {
14580
14647
  (_b = (_a = ref.current).onDataChanged) === null || _b === void 0 ? void 0 : _b.call(_a, result.data);
14581
14648
  }, [result.data]);
14582
14649
  // Sync to Jotai atom for persistence
14583
- const setQueriesAtom = useSetAtom$1(queriesAtom);
14650
+ const setQueriesAtom = useSetAtom(queriesAtom);
14584
14651
  const queryKeyStr = queryKey.join('-');
14585
14652
  const compositeKey = getCompositeKey(id, queryKeyStr);
14586
14653
  useEffect(() => {
@@ -14719,7 +14786,7 @@ const {
14719
14786
  }
14720
14787
  }));
14721
14788
  // Sync to Jotai atom for persistence
14722
- const setMutationsAtom = useSetAtom$1(mutationsAtom);
14789
+ const setMutationsAtom = useSetAtom(mutationsAtom);
14723
14790
  const mutationKey = (_b_1 = (_a_2 = restOptions.mutationKey) === null || _a_2 === void 0 ? void 0 : _a_2.join('-')) !== null && _b_1 !== void 0 ? _b_1 : fullEndpoint;
14724
14791
  const compositeKey = getCompositeKey(id, mutationKey);
14725
14792
  useEffect(() => {
@@ -15259,8 +15326,8 @@ const useMultipleMutation = configs => {
15259
15326
  persistToAtoms = true
15260
15327
  } = options;
15261
15328
  // Global atom setters
15262
- const setQueriesAtom = useSetAtom$1(queriesAtom);
15263
- const setMutationsAtom = useSetAtom$1(mutationsAtom);
15329
+ const setQueriesAtom = useSetAtom(queriesAtom);
15330
+ const setMutationsAtom = useSetAtom(mutationsAtom);
15264
15331
  // Update a single query in the global atom
15265
15332
  const updateQueryAtom = useCallback((key, state) => {
15266
15333
  const compositeKey = getCompositeKey(scopeId, key);
@@ -15461,7 +15528,7 @@ function useJotaiQueries(options) {
15461
15528
  const {
15462
15529
  scopeId
15463
15530
  } = options;
15464
- const allQueries = useAtomValue$1(queriesAtom);
15531
+ const allQueries = useAtomValue(queriesAtom);
15465
15532
  const prefix = `${scopeId}:`;
15466
15533
  let scopeQueries;
15467
15534
  if ($[0] !== allQueries || $[1] !== prefix) {
@@ -15487,7 +15554,7 @@ function useJotaiMutations(options) {
15487
15554
  const {
15488
15555
  scopeId
15489
15556
  } = options;
15490
- const allMutations = useAtomValue$1(mutationsAtom);
15557
+ const allMutations = useAtomValue(mutationsAtom);
15491
15558
  const prefix = `${scopeId}:`;
15492
15559
  let scopeMutations;
15493
15560
  if ($[0] !== allMutations || $[1] !== prefix) {
@@ -16770,931 +16837,7 @@ const baseStorage = {
16770
16837
  let storage = createCompressedStorage(baseStorage);
16771
16838
  const setCustomStorage = newStorage => {
16772
16839
  storage = newStorage;
16773
- };function hasInitialValue(atom) {
16774
- return "init" in atom;
16775
- }
16776
- function isActuallyWritableAtom(atom) {
16777
- return !!atom.write;
16778
- }
16779
- function isAtomStateInitialized(atomState) {
16780
- return "v" in atomState || "e" in atomState;
16781
- }
16782
- function returnAtomValue(atomState) {
16783
- if ("e" in atomState) {
16784
- throw atomState.e;
16785
- }
16786
- if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production" && !("v" in atomState)) {
16787
- throw new Error("[Bug] atom state is not initialized");
16788
- }
16789
- return atomState.v;
16790
- }
16791
- const promiseStateMap = /* @__PURE__ */ new WeakMap();
16792
- function isPendingPromise(value) {
16793
- var _a;
16794
- return isPromiseLike$1(value) && !!((_a = promiseStateMap.get(value)) == null ? void 0 : _a[0]);
16795
- }
16796
- function abortPromise(promise) {
16797
- const promiseState = promiseStateMap.get(promise);
16798
- if (promiseState == null ? void 0 : promiseState[0]) {
16799
- promiseState[0] = false;
16800
- promiseState[1].forEach((fn) => fn());
16801
- }
16802
- }
16803
- function registerAbortHandler(promise, abortHandler) {
16804
- let promiseState = promiseStateMap.get(promise);
16805
- if (!promiseState) {
16806
- promiseState = [true, /* @__PURE__ */ new Set()];
16807
- promiseStateMap.set(promise, promiseState);
16808
- const settle = () => {
16809
- promiseState[0] = false;
16810
- };
16811
- promise.then(settle, settle);
16812
- }
16813
- promiseState[1].add(abortHandler);
16814
- }
16815
- function isPromiseLike$1(p) {
16816
- return typeof (p == null ? void 0 : p.then) === "function";
16817
- }
16818
- function addPendingPromiseToDependency(atom, promise, dependencyAtomState) {
16819
- if (!dependencyAtomState.p.has(atom)) {
16820
- dependencyAtomState.p.add(atom);
16821
- const cleanup = () => dependencyAtomState.p.delete(atom);
16822
- promise.then(cleanup, cleanup);
16823
- }
16824
- }
16825
- function getMountedOrPendingDependents(atom, atomState, mountedMap) {
16826
- var _a;
16827
- const dependents = /* @__PURE__ */ new Set();
16828
- for (const a of ((_a = mountedMap.get(atom)) == null ? void 0 : _a.t) || []) {
16829
- if (mountedMap.has(a)) {
16830
- dependents.add(a);
16831
- }
16832
- }
16833
- for (const atomWithPendingPromise of atomState.p) {
16834
- dependents.add(atomWithPendingPromise);
16835
- }
16836
- return dependents;
16837
- }
16838
- const atomRead = (_store, atom, ...params) => atom.read(...params);
16839
- const atomWrite = (_store, atom, ...params) => atom.write(...params);
16840
- const atomOnInit = (store, atom) => {
16841
- var _a;
16842
- return (_a = atom.unstable_onInit) == null ? void 0 : _a.call(atom, store);
16843
- };
16844
- const atomOnMount = (_store, atom, setAtom) => {
16845
- var _a;
16846
- return (_a = atom.onMount) == null ? void 0 : _a.call(atom, setAtom);
16847
- };
16848
- const ensureAtomState = (store, atom) => {
16849
- const buildingBlocks = getInternalBuildingBlocks(store);
16850
- const atomStateMap = buildingBlocks[0];
16851
- const atomOnInit2 = buildingBlocks[9];
16852
- if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production" && !atom) {
16853
- throw new Error("Atom is undefined or null");
16854
- }
16855
- let atomState = atomStateMap.get(atom);
16856
- if (!atomState) {
16857
- atomState = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 };
16858
- atomStateMap.set(atom, atomState);
16859
- atomOnInit2 == null ? void 0 : atomOnInit2(store, atom);
16860
- }
16861
- return atomState;
16862
- };
16863
- const flushCallbacks = (store) => {
16864
- const buildingBlocks = getInternalBuildingBlocks(store);
16865
- const mountedMap = buildingBlocks[1];
16866
- const changedAtoms = buildingBlocks[3];
16867
- const mountCallbacks = buildingBlocks[4];
16868
- const unmountCallbacks = buildingBlocks[5];
16869
- const storeHooks = buildingBlocks[6];
16870
- const recomputeInvalidatedAtoms2 = buildingBlocks[13];
16871
- const errors = [];
16872
- const call = (fn) => {
16873
- try {
16874
- fn();
16875
- } catch (e) {
16876
- errors.push(e);
16877
- }
16878
- };
16879
- do {
16880
- if (storeHooks.f) {
16881
- call(storeHooks.f);
16882
- }
16883
- const callbacks = /* @__PURE__ */ new Set();
16884
- const add = callbacks.add.bind(callbacks);
16885
- changedAtoms.forEach((atom) => {
16886
- var _a;
16887
- return (_a = mountedMap.get(atom)) == null ? void 0 : _a.l.forEach(add);
16888
- });
16889
- changedAtoms.clear();
16890
- unmountCallbacks.forEach(add);
16891
- unmountCallbacks.clear();
16892
- mountCallbacks.forEach(add);
16893
- mountCallbacks.clear();
16894
- callbacks.forEach(call);
16895
- if (changedAtoms.size) {
16896
- recomputeInvalidatedAtoms2(store);
16897
- }
16898
- } while (changedAtoms.size || unmountCallbacks.size || mountCallbacks.size);
16899
- if (errors.length) {
16900
- throw new AggregateError(errors);
16901
- }
16902
- };
16903
- const recomputeInvalidatedAtoms = (store) => {
16904
- const buildingBlocks = getInternalBuildingBlocks(store);
16905
- const mountedMap = buildingBlocks[1];
16906
- const invalidatedAtoms = buildingBlocks[2];
16907
- const changedAtoms = buildingBlocks[3];
16908
- const ensureAtomState2 = buildingBlocks[11];
16909
- const readAtomState2 = buildingBlocks[14];
16910
- const mountDependencies2 = buildingBlocks[17];
16911
- const topSortedReversed = [];
16912
- const visiting = /* @__PURE__ */ new WeakSet();
16913
- const visited = /* @__PURE__ */ new WeakSet();
16914
- const stack = Array.from(changedAtoms);
16915
- while (stack.length) {
16916
- const a = stack[stack.length - 1];
16917
- const aState = ensureAtomState2(store, a);
16918
- if (visited.has(a)) {
16919
- stack.pop();
16920
- continue;
16921
- }
16922
- if (visiting.has(a)) {
16923
- if (invalidatedAtoms.get(a) === aState.n) {
16924
- topSortedReversed.push([a, aState]);
16925
- } else if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production" && invalidatedAtoms.has(a)) {
16926
- throw new Error("[Bug] invalidated atom exists");
16927
- }
16928
- visited.add(a);
16929
- stack.pop();
16930
- continue;
16931
- }
16932
- visiting.add(a);
16933
- for (const d of getMountedOrPendingDependents(a, aState, mountedMap)) {
16934
- if (!visiting.has(d)) {
16935
- stack.push(d);
16936
- }
16937
- }
16938
- }
16939
- for (let i = topSortedReversed.length - 1; i >= 0; --i) {
16940
- const [a, aState] = topSortedReversed[i];
16941
- let hasChangedDeps = false;
16942
- for (const dep of aState.d.keys()) {
16943
- if (dep !== a && changedAtoms.has(dep)) {
16944
- hasChangedDeps = true;
16945
- break;
16946
- }
16947
- }
16948
- if (hasChangedDeps) {
16949
- readAtomState2(store, a);
16950
- mountDependencies2(store, a);
16951
- }
16952
- invalidatedAtoms.delete(a);
16953
- }
16954
- };
16955
- const readAtomState = (store, atom) => {
16956
- var _a, _b;
16957
- const buildingBlocks = getInternalBuildingBlocks(store);
16958
- const mountedMap = buildingBlocks[1];
16959
- const invalidatedAtoms = buildingBlocks[2];
16960
- const changedAtoms = buildingBlocks[3];
16961
- const storeHooks = buildingBlocks[6];
16962
- const atomRead2 = buildingBlocks[7];
16963
- const ensureAtomState2 = buildingBlocks[11];
16964
- const flushCallbacks2 = buildingBlocks[12];
16965
- const recomputeInvalidatedAtoms2 = buildingBlocks[13];
16966
- const readAtomState2 = buildingBlocks[14];
16967
- const writeAtomState2 = buildingBlocks[16];
16968
- const mountDependencies2 = buildingBlocks[17];
16969
- const atomState = ensureAtomState2(store, atom);
16970
- if (isAtomStateInitialized(atomState)) {
16971
- if (mountedMap.has(atom) && invalidatedAtoms.get(atom) !== atomState.n) {
16972
- return atomState;
16973
- }
16974
- if (Array.from(atomState.d).every(
16975
- ([a, n]) => (
16976
- // Recursively, read the atom state of the dependency, and
16977
- // check if the atom epoch number is unchanged
16978
- readAtomState2(store, a).n === n
16979
- )
16980
- )) {
16981
- return atomState;
16982
- }
16983
- }
16984
- atomState.d.clear();
16985
- let isSync = true;
16986
- function mountDependenciesIfAsync() {
16987
- if (mountedMap.has(atom)) {
16988
- mountDependencies2(store, atom);
16989
- recomputeInvalidatedAtoms2(store);
16990
- flushCallbacks2(store);
16991
- }
16992
- }
16993
- function getter(a) {
16994
- var _a2;
16995
- if (a === atom) {
16996
- const aState2 = ensureAtomState2(store, a);
16997
- if (!isAtomStateInitialized(aState2)) {
16998
- if (hasInitialValue(a)) {
16999
- setAtomStateValueOrPromise(store, a, a.init);
17000
- } else {
17001
- throw new Error("no atom init");
17002
- }
17003
- }
17004
- return returnAtomValue(aState2);
17005
- }
17006
- const aState = readAtomState2(store, a);
17007
- try {
17008
- return returnAtomValue(aState);
17009
- } finally {
17010
- atomState.d.set(a, aState.n);
17011
- if (isPendingPromise(atomState.v)) {
17012
- addPendingPromiseToDependency(atom, atomState.v, aState);
17013
- }
17014
- (_a2 = mountedMap.get(a)) == null ? void 0 : _a2.t.add(atom);
17015
- if (!isSync) {
17016
- mountDependenciesIfAsync();
17017
- }
17018
- }
17019
- }
17020
- let controller;
17021
- let setSelf;
17022
- const options = {
17023
- get signal() {
17024
- if (!controller) {
17025
- controller = new AbortController();
17026
- }
17027
- return controller.signal;
17028
- },
17029
- get setSelf() {
17030
- if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production" && !isActuallyWritableAtom(atom)) {
17031
- console.warn("setSelf function cannot be used with read-only atom");
17032
- }
17033
- if (!setSelf && isActuallyWritableAtom(atom)) {
17034
- setSelf = (...args) => {
17035
- if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production" && isSync) {
17036
- console.warn("setSelf function cannot be called in sync");
17037
- }
17038
- if (!isSync) {
17039
- try {
17040
- return writeAtomState2(store, atom, ...args);
17041
- } finally {
17042
- recomputeInvalidatedAtoms2(store);
17043
- flushCallbacks2(store);
17044
- }
17045
- }
17046
- };
17047
- }
17048
- return setSelf;
17049
- }
17050
- };
17051
- const prevEpochNumber = atomState.n;
17052
- try {
17053
- const valueOrPromise = atomRead2(store, atom, getter, options);
17054
- setAtomStateValueOrPromise(store, atom, valueOrPromise);
17055
- if (isPromiseLike$1(valueOrPromise)) {
17056
- registerAbortHandler(valueOrPromise, () => controller == null ? void 0 : controller.abort());
17057
- valueOrPromise.then(mountDependenciesIfAsync, mountDependenciesIfAsync);
17058
- }
17059
- (_a = storeHooks.r) == null ? void 0 : _a.call(storeHooks, atom);
17060
- return atomState;
17061
- } catch (error) {
17062
- delete atomState.v;
17063
- atomState.e = error;
17064
- ++atomState.n;
17065
- return atomState;
17066
- } finally {
17067
- isSync = false;
17068
- if (prevEpochNumber !== atomState.n && invalidatedAtoms.get(atom) === prevEpochNumber) {
17069
- invalidatedAtoms.set(atom, atomState.n);
17070
- changedAtoms.add(atom);
17071
- (_b = storeHooks.c) == null ? void 0 : _b.call(storeHooks, atom);
17072
- }
17073
- }
17074
- };
17075
- const invalidateDependents = (store, atom) => {
17076
- const buildingBlocks = getInternalBuildingBlocks(store);
17077
- const mountedMap = buildingBlocks[1];
17078
- const invalidatedAtoms = buildingBlocks[2];
17079
- const ensureAtomState2 = buildingBlocks[11];
17080
- const stack = [atom];
17081
- while (stack.length) {
17082
- const a = stack.pop();
17083
- const aState = ensureAtomState2(store, a);
17084
- for (const d of getMountedOrPendingDependents(a, aState, mountedMap)) {
17085
- const dState = ensureAtomState2(store, d);
17086
- invalidatedAtoms.set(d, dState.n);
17087
- stack.push(d);
17088
- }
17089
- }
17090
- };
17091
- const writeAtomState = (store, atom, ...args) => {
17092
- const buildingBlocks = getInternalBuildingBlocks(store);
17093
- const changedAtoms = buildingBlocks[3];
17094
- const storeHooks = buildingBlocks[6];
17095
- const atomWrite2 = buildingBlocks[8];
17096
- const ensureAtomState2 = buildingBlocks[11];
17097
- const flushCallbacks2 = buildingBlocks[12];
17098
- const recomputeInvalidatedAtoms2 = buildingBlocks[13];
17099
- const readAtomState2 = buildingBlocks[14];
17100
- const invalidateDependents2 = buildingBlocks[15];
17101
- const mountDependencies2 = buildingBlocks[17];
17102
- let isSync = true;
17103
- const getter = (a) => returnAtomValue(readAtomState2(store, a));
17104
- const setter = (a, ...args2) => {
17105
- var _a;
17106
- const aState = ensureAtomState2(store, a);
17107
- try {
17108
- if (a === atom) {
17109
- if (!hasInitialValue(a)) {
17110
- throw new Error("atom not writable");
17111
- }
17112
- const prevEpochNumber = aState.n;
17113
- const v = args2[0];
17114
- setAtomStateValueOrPromise(store, a, v);
17115
- mountDependencies2(store, a);
17116
- if (prevEpochNumber !== aState.n) {
17117
- changedAtoms.add(a);
17118
- (_a = storeHooks.c) == null ? void 0 : _a.call(storeHooks, a);
17119
- invalidateDependents2(store, a);
17120
- }
17121
- return void 0;
17122
- } else {
17123
- return writeAtomState(store, a, ...args2);
17124
- }
17125
- } finally {
17126
- if (!isSync) {
17127
- recomputeInvalidatedAtoms2(store);
17128
- flushCallbacks2(store);
17129
- }
17130
- }
17131
- };
17132
- try {
17133
- return atomWrite2(store, atom, getter, setter, ...args);
17134
- } finally {
17135
- isSync = false;
17136
- }
17137
- };
17138
- const mountDependencies = (store, atom) => {
17139
- var _a;
17140
- const buildingBlocks = getInternalBuildingBlocks(store);
17141
- const mountedMap = buildingBlocks[1];
17142
- const changedAtoms = buildingBlocks[3];
17143
- const storeHooks = buildingBlocks[6];
17144
- const ensureAtomState2 = buildingBlocks[11];
17145
- const invalidateDependents2 = buildingBlocks[15];
17146
- const mountAtom2 = buildingBlocks[18];
17147
- const unmountAtom2 = buildingBlocks[19];
17148
- const atomState = ensureAtomState2(store, atom);
17149
- const mounted = mountedMap.get(atom);
17150
- if (mounted && !isPendingPromise(atomState.v)) {
17151
- for (const [a, n] of atomState.d) {
17152
- if (!mounted.d.has(a)) {
17153
- const aState = ensureAtomState2(store, a);
17154
- const aMounted = mountAtom2(store, a);
17155
- aMounted.t.add(atom);
17156
- mounted.d.add(a);
17157
- if (n !== aState.n) {
17158
- changedAtoms.add(a);
17159
- (_a = storeHooks.c) == null ? void 0 : _a.call(storeHooks, a);
17160
- invalidateDependents2(store, a);
17161
- }
17162
- }
17163
- }
17164
- for (const a of mounted.d || []) {
17165
- if (!atomState.d.has(a)) {
17166
- mounted.d.delete(a);
17167
- const aMounted = unmountAtom2(store, a);
17168
- aMounted == null ? void 0 : aMounted.t.delete(atom);
17169
- }
17170
- }
17171
- }
17172
- };
17173
- const mountAtom = (store, atom) => {
17174
- var _a;
17175
- const buildingBlocks = getInternalBuildingBlocks(store);
17176
- const mountedMap = buildingBlocks[1];
17177
- const mountCallbacks = buildingBlocks[4];
17178
- const storeHooks = buildingBlocks[6];
17179
- const atomOnMount2 = buildingBlocks[10];
17180
- const ensureAtomState2 = buildingBlocks[11];
17181
- const flushCallbacks2 = buildingBlocks[12];
17182
- const recomputeInvalidatedAtoms2 = buildingBlocks[13];
17183
- const readAtomState2 = buildingBlocks[14];
17184
- const writeAtomState2 = buildingBlocks[16];
17185
- const atomState = ensureAtomState2(store, atom);
17186
- let mounted = mountedMap.get(atom);
17187
- if (!mounted) {
17188
- readAtomState2(store, atom);
17189
- for (const a of atomState.d.keys()) {
17190
- const aMounted = mountAtom(store, a);
17191
- aMounted.t.add(atom);
17192
- }
17193
- mounted = {
17194
- l: /* @__PURE__ */ new Set(),
17195
- d: new Set(atomState.d.keys()),
17196
- t: /* @__PURE__ */ new Set()
17197
- };
17198
- mountedMap.set(atom, mounted);
17199
- (_a = storeHooks.m) == null ? void 0 : _a.call(storeHooks, atom);
17200
- if (isActuallyWritableAtom(atom)) {
17201
- const processOnMount = () => {
17202
- let isSync = true;
17203
- const setAtom = (...args) => {
17204
- try {
17205
- return writeAtomState2(store, atom, ...args);
17206
- } finally {
17207
- if (!isSync) {
17208
- recomputeInvalidatedAtoms2(store);
17209
- flushCallbacks2(store);
17210
- }
17211
- }
17212
- };
17213
- try {
17214
- const onUnmount = atomOnMount2(store, atom, setAtom);
17215
- if (onUnmount) {
17216
- mounted.u = () => {
17217
- isSync = true;
17218
- try {
17219
- onUnmount();
17220
- } finally {
17221
- isSync = false;
17222
- }
17223
- };
17224
- }
17225
- } finally {
17226
- isSync = false;
17227
- }
17228
- };
17229
- mountCallbacks.add(processOnMount);
17230
- }
17231
- }
17232
- return mounted;
17233
- };
17234
- const unmountAtom = (store, atom) => {
17235
- var _a;
17236
- const buildingBlocks = getInternalBuildingBlocks(store);
17237
- const mountedMap = buildingBlocks[1];
17238
- const unmountCallbacks = buildingBlocks[5];
17239
- const storeHooks = buildingBlocks[6];
17240
- const ensureAtomState2 = buildingBlocks[11];
17241
- const unmountAtom2 = buildingBlocks[19];
17242
- const atomState = ensureAtomState2(store, atom);
17243
- let mounted = mountedMap.get(atom);
17244
- if (mounted && !mounted.l.size && !Array.from(mounted.t).some((a) => {
17245
- var _a2;
17246
- return (_a2 = mountedMap.get(a)) == null ? void 0 : _a2.d.has(atom);
17247
- })) {
17248
- if (mounted.u) {
17249
- unmountCallbacks.add(mounted.u);
17250
- }
17251
- mounted = void 0;
17252
- mountedMap.delete(atom);
17253
- (_a = storeHooks.u) == null ? void 0 : _a.call(storeHooks, atom);
17254
- for (const a of atomState.d.keys()) {
17255
- const aMounted = unmountAtom2(store, a);
17256
- aMounted == null ? void 0 : aMounted.t.delete(atom);
17257
- }
17258
- return void 0;
17259
- }
17260
- return mounted;
17261
- };
17262
- const setAtomStateValueOrPromise = (store, atom, valueOrPromise) => {
17263
- const ensureAtomState2 = getInternalBuildingBlocks(store)[11];
17264
- const atomState = ensureAtomState2(store, atom);
17265
- const hasPrevValue = "v" in atomState;
17266
- const prevValue = atomState.v;
17267
- if (isPromiseLike$1(valueOrPromise)) {
17268
- for (const a of atomState.d.keys()) {
17269
- addPendingPromiseToDependency(
17270
- atom,
17271
- valueOrPromise,
17272
- ensureAtomState2(store, a)
17273
- );
17274
- }
17275
- }
17276
- atomState.v = valueOrPromise;
17277
- delete atomState.e;
17278
- if (!hasPrevValue || !Object.is(prevValue, atomState.v)) {
17279
- ++atomState.n;
17280
- if (isPromiseLike$1(prevValue)) {
17281
- abortPromise(prevValue);
17282
- }
17283
- }
17284
- };
17285
- const storeGet = (store, atom) => {
17286
- const readAtomState2 = getInternalBuildingBlocks(store)[14];
17287
- return returnAtomValue(readAtomState2(store, atom));
17288
- };
17289
- const storeSet = (store, atom, ...args) => {
17290
- const buildingBlocks = getInternalBuildingBlocks(store);
17291
- const flushCallbacks2 = buildingBlocks[12];
17292
- const recomputeInvalidatedAtoms2 = buildingBlocks[13];
17293
- const writeAtomState2 = buildingBlocks[16];
17294
- try {
17295
- return writeAtomState2(store, atom, ...args);
17296
- } finally {
17297
- recomputeInvalidatedAtoms2(store);
17298
- flushCallbacks2(store);
17299
- }
17300
- };
17301
- const storeSub = (store, atom, listener) => {
17302
- const buildingBlocks = getInternalBuildingBlocks(store);
17303
- const flushCallbacks2 = buildingBlocks[12];
17304
- const mountAtom2 = buildingBlocks[18];
17305
- const unmountAtom2 = buildingBlocks[19];
17306
- const mounted = mountAtom2(store, atom);
17307
- const listeners = mounted.l;
17308
- listeners.add(listener);
17309
- flushCallbacks2(store);
17310
- return () => {
17311
- listeners.delete(listener);
17312
- unmountAtom2(store, atom);
17313
- flushCallbacks2(store);
17314
- };
17315
- };
17316
- const buildingBlockMap = /* @__PURE__ */ new WeakMap();
17317
- const getInternalBuildingBlocks = (store) => {
17318
- const buildingBlocks = buildingBlockMap.get(store);
17319
- if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production" && !buildingBlocks) {
17320
- throw new Error(
17321
- "Store must be created by buildStore to read its building blocks"
17322
- );
17323
- }
17324
- return buildingBlocks;
17325
- };
17326
- function buildStore(...buildArgs) {
17327
- const store = {
17328
- get(atom) {
17329
- const storeGet2 = getInternalBuildingBlocks(store)[21];
17330
- return storeGet2(store, atom);
17331
- },
17332
- set(atom, ...args) {
17333
- const storeSet2 = getInternalBuildingBlocks(store)[22];
17334
- return storeSet2(store, atom, ...args);
17335
- },
17336
- sub(atom, listener) {
17337
- const storeSub2 = getInternalBuildingBlocks(store)[23];
17338
- return storeSub2(store, atom, listener);
17339
- }
17340
- };
17341
- const buildingBlocks = [
17342
- // store state
17343
- /* @__PURE__ */ new WeakMap(),
17344
- // atomStateMap
17345
- /* @__PURE__ */ new WeakMap(),
17346
- // mountedMap
17347
- /* @__PURE__ */ new WeakMap(),
17348
- // invalidatedAtoms
17349
- /* @__PURE__ */ new Set(),
17350
- // changedAtoms
17351
- /* @__PURE__ */ new Set(),
17352
- // mountCallbacks
17353
- /* @__PURE__ */ new Set(),
17354
- // unmountCallbacks
17355
- {},
17356
- // storeHooks
17357
- // atom interceptors
17358
- atomRead,
17359
- atomWrite,
17360
- atomOnInit,
17361
- atomOnMount,
17362
- // building-block functions
17363
- ensureAtomState,
17364
- flushCallbacks,
17365
- recomputeInvalidatedAtoms,
17366
- readAtomState,
17367
- invalidateDependents,
17368
- writeAtomState,
17369
- mountDependencies,
17370
- mountAtom,
17371
- unmountAtom,
17372
- setAtomStateValueOrPromise,
17373
- storeGet,
17374
- storeSet,
17375
- storeSub,
17376
- void 0
17377
- ].map((fn, i) => buildArgs[i] || fn);
17378
- buildingBlockMap.set(store, Object.freeze(buildingBlocks));
17379
- return store;
17380
- }let keyCount = 0;
17381
- function atom(read, write) {
17382
- const key = `atom${++keyCount}`;
17383
- const config = {
17384
- toString() {
17385
- return (import.meta.env ? import.meta.env.MODE : void 0) !== "production" && this.debugLabel ? key + ":" + this.debugLabel : key;
17386
- }
17387
- };
17388
- if (typeof read === "function") {
17389
- config.read = read;
17390
- } else {
17391
- config.init = read;
17392
- config.read = defaultRead;
17393
- config.write = defaultWrite;
17394
- }
17395
- if (write) {
17396
- config.write = write;
17397
- }
17398
- return config;
17399
- }
17400
- function defaultRead(get) {
17401
- return get(this);
17402
- }
17403
- function defaultWrite(get, set, arg) {
17404
- return set(
17405
- this,
17406
- typeof arg === "function" ? arg(get(this)) : arg
17407
- );
17408
- }
17409
- function createStore() {
17410
- return buildStore();
17411
- }
17412
- let defaultStore;
17413
- function getDefaultStore() {
17414
- if (!defaultStore) {
17415
- defaultStore = createStore();
17416
- if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production") {
17417
- globalThis.__JOTAI_DEFAULT_STORE__ || (globalThis.__JOTAI_DEFAULT_STORE__ = defaultStore);
17418
- if (globalThis.__JOTAI_DEFAULT_STORE__ !== defaultStore) {
17419
- console.warn(
17420
- "Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"
17421
- );
17422
- }
17423
- }
17424
- }
17425
- return defaultStore;
17426
- }const StoreContext = createContext(
17427
- void 0
17428
- );
17429
- function useStore(options) {
17430
- const store = useContext(StoreContext);
17431
- return store || getDefaultStore();
17432
- }
17433
-
17434
- const isPromiseLike = (x) => typeof (x == null ? void 0 : x.then) === "function";
17435
- const attachPromiseStatus = (promise) => {
17436
- if (!promise.status) {
17437
- promise.status = "pending";
17438
- promise.then(
17439
- (v) => {
17440
- promise.status = "fulfilled";
17441
- promise.value = v;
17442
- },
17443
- (e) => {
17444
- promise.status = "rejected";
17445
- promise.reason = e;
17446
- }
17447
- );
17448
- }
17449
- };
17450
- const use = React__default.use || // A shim for older React versions
17451
- ((promise) => {
17452
- if (promise.status === "pending") {
17453
- throw promise;
17454
- } else if (promise.status === "fulfilled") {
17455
- return promise.value;
17456
- } else if (promise.status === "rejected") {
17457
- throw promise.reason;
17458
- } else {
17459
- attachPromiseStatus(promise);
17460
- throw promise;
17461
- }
17462
- });
17463
- const continuablePromiseMap = /* @__PURE__ */ new WeakMap();
17464
- const createContinuablePromise = (promise, getValue) => {
17465
- let continuablePromise = continuablePromiseMap.get(promise);
17466
- if (!continuablePromise) {
17467
- continuablePromise = new Promise((resolve, reject) => {
17468
- let curr = promise;
17469
- const onFulfilled = (me) => (v) => {
17470
- if (curr === me) {
17471
- resolve(v);
17472
- }
17473
- };
17474
- const onRejected = (me) => (e) => {
17475
- if (curr === me) {
17476
- reject(e);
17477
- }
17478
- };
17479
- const onAbort = () => {
17480
- try {
17481
- const nextValue = getValue();
17482
- if (isPromiseLike(nextValue)) {
17483
- continuablePromiseMap.set(nextValue, continuablePromise);
17484
- curr = nextValue;
17485
- nextValue.then(onFulfilled(nextValue), onRejected(nextValue));
17486
- registerAbortHandler(nextValue, onAbort);
17487
- } else {
17488
- resolve(nextValue);
17489
- }
17490
- } catch (e) {
17491
- reject(e);
17492
- }
17493
- };
17494
- promise.then(onFulfilled(promise), onRejected(promise));
17495
- registerAbortHandler(promise, onAbort);
17496
- });
17497
- continuablePromiseMap.set(promise, continuablePromise);
17498
- }
17499
- return continuablePromise;
17500
- };
17501
- function useAtomValue(atom, options) {
17502
- const { delay, unstable_promiseStatus: promiseStatus = !React__default.use } = {};
17503
- const store = useStore();
17504
- const [[valueFromReducer, storeFromReducer, atomFromReducer], rerender] = useReducer(
17505
- (prev) => {
17506
- const nextValue = store.get(atom);
17507
- if (Object.is(prev[0], nextValue) && prev[1] === store && prev[2] === atom) {
17508
- return prev;
17509
- }
17510
- return [nextValue, store, atom];
17511
- },
17512
- void 0,
17513
- () => [store.get(atom), store, atom]
17514
- );
17515
- let value = valueFromReducer;
17516
- if (storeFromReducer !== store || atomFromReducer !== atom) {
17517
- rerender();
17518
- value = store.get(atom);
17519
- }
17520
- useEffect(() => {
17521
- const unsub = store.sub(atom, () => {
17522
- if (promiseStatus) {
17523
- try {
17524
- const value2 = store.get(atom);
17525
- if (isPromiseLike(value2)) {
17526
- attachPromiseStatus(
17527
- createContinuablePromise(value2, () => store.get(atom))
17528
- );
17529
- }
17530
- } catch (e) {
17531
- }
17532
- }
17533
- if (typeof delay === "number") {
17534
- setTimeout(rerender, delay);
17535
- return;
17536
- }
17537
- rerender();
17538
- });
17539
- rerender();
17540
- return unsub;
17541
- }, [store, atom, delay, promiseStatus]);
17542
- useDebugValue(value);
17543
- if (isPromiseLike(value)) {
17544
- const promise = createContinuablePromise(value, () => store.get(atom));
17545
- if (promiseStatus) {
17546
- attachPromiseStatus(promise);
17547
- }
17548
- return use(promise);
17549
- }
17550
- return value;
17551
- }
17552
-
17553
- function useSetAtom(atom, options) {
17554
- const store = useStore();
17555
- const setAtom = useCallback(
17556
- (...args) => {
17557
- if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production" && !("write" in atom)) {
17558
- throw new Error("not writable atom");
17559
- }
17560
- return store.set(atom, ...args);
17561
- },
17562
- [store, atom]
17563
- );
17564
- return setAtom;
17565
- }
17566
-
17567
- function useAtom(atom, options) {
17568
- return [
17569
- useAtomValue(atom),
17570
- // We do wrong type assertion here, which results in throwing an error.
17571
- useSetAtom(atom)
17572
- ];
17573
- }const RESET = Symbol(
17574
- (import.meta.env ? import.meta.env.MODE : void 0) !== "production" ? "RESET" : ""
17575
- );
17576
-
17577
- const isPromiseLike$3 = (x) => typeof (x == null ? void 0 : x.then) === "function";
17578
- function createJSONStorage(getStringStorage = () => {
17579
- try {
17580
- return window.localStorage;
17581
- } catch (e) {
17582
- if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production") {
17583
- if (typeof window !== "undefined") {
17584
- console.warn(e);
17585
- }
17586
- }
17587
- return void 0;
17588
- }
17589
- }, options) {
17590
- var _a;
17591
- let lastStr;
17592
- let lastValue;
17593
- const storage = {
17594
- getItem: (key, initialValue) => {
17595
- var _a2, _b;
17596
- const parse = (str2) => {
17597
- str2 = str2 || "";
17598
- if (lastStr !== str2) {
17599
- try {
17600
- lastValue = JSON.parse(str2, void 0 );
17601
- } catch (e) {
17602
- return initialValue;
17603
- }
17604
- lastStr = str2;
17605
- }
17606
- return lastValue;
17607
- };
17608
- const str = (_b = (_a2 = getStringStorage()) == null ? void 0 : _a2.getItem(key)) != null ? _b : null;
17609
- if (isPromiseLike$3(str)) {
17610
- return str.then(parse);
17611
- }
17612
- return parse(str);
17613
- },
17614
- setItem: (key, newValue) => {
17615
- var _a2;
17616
- return (_a2 = getStringStorage()) == null ? void 0 : _a2.setItem(
17617
- key,
17618
- JSON.stringify(newValue, void 0 )
17619
- );
17620
- },
17621
- removeItem: (key) => {
17622
- var _a2;
17623
- return (_a2 = getStringStorage()) == null ? void 0 : _a2.removeItem(key);
17624
- }
17625
- };
17626
- const createHandleSubscribe = (subscriber2) => (key, callback, initialValue) => subscriber2(key, (v) => {
17627
- let newValue;
17628
- try {
17629
- newValue = JSON.parse(v || "");
17630
- } catch (e) {
17631
- newValue = initialValue;
17632
- }
17633
- callback(newValue);
17634
- });
17635
- let subscriber;
17636
- try {
17637
- subscriber = (_a = getStringStorage()) == null ? void 0 : _a.subscribe;
17638
- } catch (e) {
17639
- }
17640
- if (!subscriber && typeof window !== "undefined" && typeof window.addEventListener === "function" && window.Storage) {
17641
- subscriber = (key, callback) => {
17642
- if (!(getStringStorage() instanceof window.Storage)) {
17643
- return () => {
17644
- };
17645
- }
17646
- const storageEventCallback = (e) => {
17647
- if (e.storageArea === getStringStorage() && e.key === key) {
17648
- callback(e.newValue);
17649
- }
17650
- };
17651
- window.addEventListener("storage", storageEventCallback);
17652
- return () => {
17653
- window.removeEventListener("storage", storageEventCallback);
17654
- };
17655
- };
17656
- }
17657
- if (subscriber) {
17658
- storage.subscribe = createHandleSubscribe(subscriber);
17659
- }
17660
- return storage;
17661
- }
17662
- const defaultStorage = createJSONStorage();
17663
- function atomWithStorage(key, initialValue, storage = defaultStorage, options) {
17664
- const baseAtom = atom(
17665
- initialValue
17666
- );
17667
- if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production") {
17668
- baseAtom.debugPrivate = true;
17669
- }
17670
- baseAtom.onMount = (setAtom) => {
17671
- setAtom(storage.getItem(key, initialValue));
17672
- let unsub;
17673
- if (storage.subscribe) {
17674
- unsub = storage.subscribe(key, setAtom, initialValue);
17675
- }
17676
- return unsub;
17677
- };
17678
- const anAtom = atom(
17679
- (get) => get(baseAtom),
17680
- (get, set, update) => {
17681
- const nextValue = typeof update === "function" ? update(get(baseAtom)) : update;
17682
- if (nextValue === RESET) {
17683
- set(baseAtom, initialValue);
17684
- return storage.removeItem(key);
17685
- }
17686
- if (isPromiseLike$3(nextValue)) {
17687
- return nextValue.then((resolvedValue) => {
17688
- set(baseAtom, resolvedValue);
17689
- return storage.setItem(key, resolvedValue);
17690
- });
17691
- }
17692
- set(baseAtom, nextValue);
17693
- return storage.setItem(key, nextValue);
17694
- }
17695
- );
17696
- return anAtom;
17697
- }// Implementazione
16840
+ };// Implementazione
17698
16841
  function atomStateGenerator({
17699
16842
  key,
17700
16843
  defaultValue,
@@ -17746,7 +16889,36 @@ function atomStateGenerator({
17746
16889
  useState,
17747
16890
  useReset
17748
16891
  };
17749
- }function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}const CLASS_PART_SEPARATOR = '-';
16892
+ }function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}/**
16893
+ * Concatenates two arrays faster than the array spread operator.
16894
+ */
16895
+ const concatArrays = (array1, array2) => {
16896
+ // Pre-allocate for better V8 optimization
16897
+ const combinedArray = new Array(array1.length + array2.length);
16898
+ for (let i = 0; i < array1.length; i++) {
16899
+ combinedArray[i] = array1[i];
16900
+ }
16901
+ for (let i = 0; i < array2.length; i++) {
16902
+ combinedArray[array1.length + i] = array2[i];
16903
+ }
16904
+ return combinedArray;
16905
+ };
16906
+
16907
+ // Factory function ensures consistent object shapes
16908
+ const createClassValidatorObject = (classGroupId, validator) => ({
16909
+ classGroupId,
16910
+ validator
16911
+ });
16912
+ // Factory ensures consistent ClassPartObject shape
16913
+ const createClassPartObject = (nextPart = new Map(), validators = null, classGroupId) => ({
16914
+ nextPart,
16915
+ validators,
16916
+ classGroupId
16917
+ });
16918
+ const CLASS_PART_SEPARATOR = '-';
16919
+ const EMPTY_CONFLICTS = [];
16920
+ // I use two dots here because one dot is used as prefix for class groups in plugins
16921
+ const ARBITRARY_PROPERTY_PREFIX = 'arbitrary..';
17750
16922
  const createClassGroupUtils = config => {
17751
16923
  const classMap = createClassMap(config);
17752
16924
  const {
@@ -17754,54 +16926,73 @@ const createClassGroupUtils = config => {
17754
16926
  conflictingClassGroupModifiers
17755
16927
  } = config;
17756
16928
  const getClassGroupId = className => {
17757
- const classParts = className.split(CLASS_PART_SEPARATOR);
17758
- // Classes like `-inset-1` produce an empty string as first classPart. We assume that classes for negative values are used correctly and remove it from classParts.
17759
- if (classParts[0] === '' && classParts.length !== 1) {
17760
- classParts.shift();
16929
+ if (className.startsWith('[') && className.endsWith(']')) {
16930
+ return getGroupIdForArbitraryProperty(className);
17761
16931
  }
17762
- return getGroupRecursive(classParts, classMap) || getGroupIdForArbitraryProperty(className);
16932
+ const classParts = className.split(CLASS_PART_SEPARATOR);
16933
+ // Classes like `-inset-1` produce an empty string as first classPart. We assume that classes for negative values are used correctly and skip it.
16934
+ const startIndex = classParts[0] === '' && classParts.length > 1 ? 1 : 0;
16935
+ return getGroupRecursive(classParts, startIndex, classMap);
17763
16936
  };
17764
16937
  const getConflictingClassGroupIds = (classGroupId, hasPostfixModifier) => {
17765
- const conflicts = conflictingClassGroups[classGroupId] || [];
17766
- if (hasPostfixModifier && conflictingClassGroupModifiers[classGroupId]) {
17767
- return [...conflicts, ...conflictingClassGroupModifiers[classGroupId]];
16938
+ if (hasPostfixModifier) {
16939
+ const modifierConflicts = conflictingClassGroupModifiers[classGroupId];
16940
+ const baseConflicts = conflictingClassGroups[classGroupId];
16941
+ if (modifierConflicts) {
16942
+ if (baseConflicts) {
16943
+ // Merge base conflicts with modifier conflicts
16944
+ return concatArrays(baseConflicts, modifierConflicts);
16945
+ }
16946
+ // Only modifier conflicts
16947
+ return modifierConflicts;
16948
+ }
16949
+ // Fall back to without postfix if no modifier conflicts
16950
+ return baseConflicts || EMPTY_CONFLICTS;
17768
16951
  }
17769
- return conflicts;
16952
+ return conflictingClassGroups[classGroupId] || EMPTY_CONFLICTS;
17770
16953
  };
17771
16954
  return {
17772
16955
  getClassGroupId,
17773
16956
  getConflictingClassGroupIds
17774
16957
  };
17775
16958
  };
17776
- const getGroupRecursive = (classParts, classPartObject) => {
17777
- if (classParts.length === 0) {
16959
+ const getGroupRecursive = (classParts, startIndex, classPartObject) => {
16960
+ const classPathsLength = classParts.length - startIndex;
16961
+ if (classPathsLength === 0) {
17778
16962
  return classPartObject.classGroupId;
17779
16963
  }
17780
- const currentClassPart = classParts[0];
16964
+ const currentClassPart = classParts[startIndex];
17781
16965
  const nextClassPartObject = classPartObject.nextPart.get(currentClassPart);
17782
- const classGroupFromNextClassPart = nextClassPartObject ? getGroupRecursive(classParts.slice(1), nextClassPartObject) : undefined;
17783
- if (classGroupFromNextClassPart) {
17784
- return classGroupFromNextClassPart;
16966
+ if (nextClassPartObject) {
16967
+ const result = getGroupRecursive(classParts, startIndex + 1, nextClassPartObject);
16968
+ if (result) return result;
17785
16969
  }
17786
- if (classPartObject.validators.length === 0) {
16970
+ const validators = classPartObject.validators;
16971
+ if (validators === null) {
17787
16972
  return undefined;
17788
16973
  }
17789
- const classRest = classParts.join(CLASS_PART_SEPARATOR);
17790
- return classPartObject.validators.find(({
17791
- validator
17792
- }) => validator(classRest))?.classGroupId;
17793
- };
17794
- const arbitraryPropertyRegex = /^\[(.+)\]$/;
17795
- const getGroupIdForArbitraryProperty = className => {
17796
- if (arbitraryPropertyRegex.test(className)) {
17797
- const arbitraryPropertyClassName = arbitraryPropertyRegex.exec(className)[1];
17798
- const property = arbitraryPropertyClassName?.substring(0, arbitraryPropertyClassName.indexOf(':'));
17799
- if (property) {
17800
- // I use two dots here because one dot is used as prefix for class groups in plugins
17801
- return 'arbitrary..' + property;
16974
+ // Build classRest string efficiently by joining from startIndex onwards
16975
+ const classRest = startIndex === 0 ? classParts.join(CLASS_PART_SEPARATOR) : classParts.slice(startIndex).join(CLASS_PART_SEPARATOR);
16976
+ const validatorsLength = validators.length;
16977
+ for (let i = 0; i < validatorsLength; i++) {
16978
+ const validatorObj = validators[i];
16979
+ if (validatorObj.validator(classRest)) {
16980
+ return validatorObj.classGroupId;
17802
16981
  }
17803
16982
  }
16983
+ return undefined;
17804
16984
  };
16985
+ /**
16986
+ * Get the class group ID for an arbitrary property.
16987
+ *
16988
+ * @param className - The class name to get the group ID for. Is expected to be string starting with `[` and ending with `]`.
16989
+ */
16990
+ const getGroupIdForArbitraryProperty = className => className.slice(1, -1).indexOf(':') === -1 ? undefined : (() => {
16991
+ const content = className.slice(1, -1);
16992
+ const colonIndex = content.indexOf(':');
16993
+ const property = content.slice(0, colonIndex);
16994
+ return property ? ARBITRARY_PROPERTY_PREFIX + property : undefined;
16995
+ })();
17805
16996
  /**
17806
16997
  * Exported for testing only
17807
16998
  */
@@ -17810,54 +17001,77 @@ const createClassMap = config => {
17810
17001
  theme,
17811
17002
  classGroups
17812
17003
  } = config;
17813
- const classMap = {
17814
- nextPart: new Map(),
17815
- validators: []
17816
- };
17004
+ return processClassGroups(classGroups, theme);
17005
+ };
17006
+ // Split into separate functions to maintain monomorphic call sites
17007
+ const processClassGroups = (classGroups, theme) => {
17008
+ const classMap = createClassPartObject();
17817
17009
  for (const classGroupId in classGroups) {
17818
- processClassesRecursively(classGroups[classGroupId], classMap, classGroupId, theme);
17010
+ const group = classGroups[classGroupId];
17011
+ processClassesRecursively(group, classMap, classGroupId, theme);
17819
17012
  }
17820
17013
  return classMap;
17821
17014
  };
17822
17015
  const processClassesRecursively = (classGroup, classPartObject, classGroupId, theme) => {
17823
- classGroup.forEach(classDefinition => {
17824
- if (typeof classDefinition === 'string') {
17825
- const classPartObjectToEdit = classDefinition === '' ? classPartObject : getPart(classPartObject, classDefinition);
17826
- classPartObjectToEdit.classGroupId = classGroupId;
17827
- return;
17828
- }
17829
- if (typeof classDefinition === 'function') {
17830
- if (isThemeGetter(classDefinition)) {
17831
- processClassesRecursively(classDefinition(theme), classPartObject, classGroupId, theme);
17832
- return;
17833
- }
17834
- classPartObject.validators.push({
17835
- validator: classDefinition,
17836
- classGroupId
17837
- });
17838
- return;
17839
- }
17840
- Object.entries(classDefinition).forEach(([key, classGroup]) => {
17841
- processClassesRecursively(classGroup, getPart(classPartObject, key), classGroupId, theme);
17842
- });
17843
- });
17016
+ const len = classGroup.length;
17017
+ for (let i = 0; i < len; i++) {
17018
+ const classDefinition = classGroup[i];
17019
+ processClassDefinition(classDefinition, classPartObject, classGroupId, theme);
17020
+ }
17021
+ };
17022
+ // Split into separate functions for each type to maintain monomorphic call sites
17023
+ const processClassDefinition = (classDefinition, classPartObject, classGroupId, theme) => {
17024
+ if (typeof classDefinition === 'string') {
17025
+ processStringDefinition(classDefinition, classPartObject, classGroupId);
17026
+ return;
17027
+ }
17028
+ if (typeof classDefinition === 'function') {
17029
+ processFunctionDefinition(classDefinition, classPartObject, classGroupId, theme);
17030
+ return;
17031
+ }
17032
+ processObjectDefinition(classDefinition, classPartObject, classGroupId, theme);
17033
+ };
17034
+ const processStringDefinition = (classDefinition, classPartObject, classGroupId) => {
17035
+ const classPartObjectToEdit = classDefinition === '' ? classPartObject : getPart(classPartObject, classDefinition);
17036
+ classPartObjectToEdit.classGroupId = classGroupId;
17037
+ };
17038
+ const processFunctionDefinition = (classDefinition, classPartObject, classGroupId, theme) => {
17039
+ if (isThemeGetter(classDefinition)) {
17040
+ processClassesRecursively(classDefinition(theme), classPartObject, classGroupId, theme);
17041
+ return;
17042
+ }
17043
+ if (classPartObject.validators === null) {
17044
+ classPartObject.validators = [];
17045
+ }
17046
+ classPartObject.validators.push(createClassValidatorObject(classGroupId, classDefinition));
17047
+ };
17048
+ const processObjectDefinition = (classDefinition, classPartObject, classGroupId, theme) => {
17049
+ const entries = Object.entries(classDefinition);
17050
+ const len = entries.length;
17051
+ for (let i = 0; i < len; i++) {
17052
+ const [key, value] = entries[i];
17053
+ processClassesRecursively(value, getPart(classPartObject, key), classGroupId, theme);
17054
+ }
17844
17055
  };
17845
17056
  const getPart = (classPartObject, path) => {
17846
- let currentClassPartObject = classPartObject;
17847
- path.split(CLASS_PART_SEPARATOR).forEach(pathPart => {
17848
- if (!currentClassPartObject.nextPart.has(pathPart)) {
17849
- currentClassPartObject.nextPart.set(pathPart, {
17850
- nextPart: new Map(),
17851
- validators: []
17852
- });
17853
- }
17854
- currentClassPartObject = currentClassPartObject.nextPart.get(pathPart);
17855
- });
17856
- return currentClassPartObject;
17057
+ let current = classPartObject;
17058
+ const parts = path.split(CLASS_PART_SEPARATOR);
17059
+ const len = parts.length;
17060
+ for (let i = 0; i < len; i++) {
17061
+ const part = parts[i];
17062
+ let next = current.nextPart.get(part);
17063
+ if (!next) {
17064
+ next = createClassPartObject();
17065
+ current.nextPart.set(part, next);
17066
+ }
17067
+ current = next;
17068
+ }
17069
+ return current;
17857
17070
  };
17858
- const isThemeGetter = func => func.isThemeGetter;
17071
+ // Type guard maintains monomorphic check
17072
+ const isThemeGetter = func => 'isThemeGetter' in func && func.isThemeGetter === true;
17859
17073
 
17860
- // LRU cache inspired from hashlru (https://github.com/dominictarr/hashlru/blob/v1.0.4/index.js) but object replaced with Map to improve performance
17074
+ // LRU cache implementation using plain objects for simplicity
17861
17075
  const createLruCache = maxCacheSize => {
17862
17076
  if (maxCacheSize < 1) {
17863
17077
  return {
@@ -17866,31 +17080,31 @@ const createLruCache = maxCacheSize => {
17866
17080
  };
17867
17081
  }
17868
17082
  let cacheSize = 0;
17869
- let cache = new Map();
17870
- let previousCache = new Map();
17083
+ let cache = Object.create(null);
17084
+ let previousCache = Object.create(null);
17871
17085
  const update = (key, value) => {
17872
- cache.set(key, value);
17086
+ cache[key] = value;
17873
17087
  cacheSize++;
17874
17088
  if (cacheSize > maxCacheSize) {
17875
17089
  cacheSize = 0;
17876
17090
  previousCache = cache;
17877
- cache = new Map();
17091
+ cache = Object.create(null);
17878
17092
  }
17879
17093
  };
17880
17094
  return {
17881
17095
  get(key) {
17882
- let value = cache.get(key);
17096
+ let value = cache[key];
17883
17097
  if (value !== undefined) {
17884
17098
  return value;
17885
17099
  }
17886
- if ((value = previousCache.get(key)) !== undefined) {
17100
+ if ((value = previousCache[key]) !== undefined) {
17887
17101
  update(key, value);
17888
17102
  return value;
17889
17103
  }
17890
17104
  },
17891
17105
  set(key, value) {
17892
- if (cache.has(key)) {
17893
- cache.set(key, value);
17106
+ if (key in cache) {
17107
+ cache[key] = value;
17894
17108
  } else {
17895
17109
  update(key, value);
17896
17110
  }
@@ -17899,7 +17113,15 @@ const createLruCache = maxCacheSize => {
17899
17113
  };
17900
17114
  const IMPORTANT_MODIFIER = '!';
17901
17115
  const MODIFIER_SEPARATOR = ':';
17902
- const MODIFIER_SEPARATOR_LENGTH = MODIFIER_SEPARATOR.length;
17116
+ const EMPTY_MODIFIERS = [];
17117
+ // Pre-allocated result object shape for consistency
17118
+ const createResultObject = (modifiers, hasImportantModifier, baseClassName, maybePostfixModifierPosition, isExternal) => ({
17119
+ modifiers,
17120
+ hasImportantModifier,
17121
+ baseClassName,
17122
+ maybePostfixModifierPosition,
17123
+ isExternal
17124
+ });
17903
17125
  const createParseClassName = config => {
17904
17126
  const {
17905
17127
  prefix,
@@ -17912,17 +17134,19 @@ const createParseClassName = config => {
17912
17134
  * @see https://github.com/tailwindlabs/tailwindcss/blob/v3.2.2/src/util/splitAtTopLevelOnly.js
17913
17135
  */
17914
17136
  let parseClassName = className => {
17137
+ // Use simple array with push for better performance
17915
17138
  const modifiers = [];
17916
17139
  let bracketDepth = 0;
17917
17140
  let parenDepth = 0;
17918
17141
  let modifierStart = 0;
17919
17142
  let postfixModifierPosition;
17920
- for (let index = 0; index < className.length; index++) {
17921
- let currentCharacter = className[index];
17143
+ const len = className.length;
17144
+ for (let index = 0; index < len; index++) {
17145
+ const currentCharacter = className[index];
17922
17146
  if (bracketDepth === 0 && parenDepth === 0) {
17923
17147
  if (currentCharacter === MODIFIER_SEPARATOR) {
17924
17148
  modifiers.push(className.slice(modifierStart, index));
17925
- modifierStart = index + MODIFIER_SEPARATOR_LENGTH;
17149
+ modifierStart = index + 1;
17926
17150
  continue;
17927
17151
  }
17928
17152
  if (currentCharacter === '/') {
@@ -17930,37 +17154,31 @@ const createParseClassName = config => {
17930
17154
  continue;
17931
17155
  }
17932
17156
  }
17933
- if (currentCharacter === '[') {
17934
- bracketDepth++;
17935
- } else if (currentCharacter === ']') {
17936
- bracketDepth--;
17937
- } else if (currentCharacter === '(') {
17938
- parenDepth++;
17939
- } else if (currentCharacter === ')') {
17940
- parenDepth--;
17941
- }
17157
+ if (currentCharacter === '[') bracketDepth++;else if (currentCharacter === ']') bracketDepth--;else if (currentCharacter === '(') parenDepth++;else if (currentCharacter === ')') parenDepth--;
17158
+ }
17159
+ const baseClassNameWithImportantModifier = modifiers.length === 0 ? className : className.slice(modifierStart);
17160
+ // Inline important modifier check
17161
+ let baseClassName = baseClassNameWithImportantModifier;
17162
+ let hasImportantModifier = false;
17163
+ if (baseClassNameWithImportantModifier.endsWith(IMPORTANT_MODIFIER)) {
17164
+ baseClassName = baseClassNameWithImportantModifier.slice(0, -1);
17165
+ hasImportantModifier = true;
17166
+ } else if (
17167
+ /**
17168
+ * In Tailwind CSS v3 the important modifier was at the start of the base class name. This is still supported for legacy reasons.
17169
+ * @see https://github.com/dcastil/tailwind-merge/issues/513#issuecomment-2614029864
17170
+ */
17171
+ baseClassNameWithImportantModifier.startsWith(IMPORTANT_MODIFIER)) {
17172
+ baseClassName = baseClassNameWithImportantModifier.slice(1);
17173
+ hasImportantModifier = true;
17942
17174
  }
17943
- const baseClassNameWithImportantModifier = modifiers.length === 0 ? className : className.substring(modifierStart);
17944
- const baseClassName = stripImportantModifier(baseClassNameWithImportantModifier);
17945
- const hasImportantModifier = baseClassName !== baseClassNameWithImportantModifier;
17946
17175
  const maybePostfixModifierPosition = postfixModifierPosition && postfixModifierPosition > modifierStart ? postfixModifierPosition - modifierStart : undefined;
17947
- return {
17948
- modifiers,
17949
- hasImportantModifier,
17950
- baseClassName,
17951
- maybePostfixModifierPosition
17952
- };
17176
+ return createResultObject(modifiers, hasImportantModifier, baseClassName, maybePostfixModifierPosition);
17953
17177
  };
17954
17178
  if (prefix) {
17955
17179
  const fullPrefix = prefix + MODIFIER_SEPARATOR;
17956
17180
  const parseClassNameOriginal = parseClassName;
17957
- parseClassName = className => className.startsWith(fullPrefix) ? parseClassNameOriginal(className.substring(fullPrefix.length)) : {
17958
- isExternal: true,
17959
- modifiers: [],
17960
- hasImportantModifier: false,
17961
- baseClassName: className,
17962
- maybePostfixModifierPosition: undefined
17963
- };
17181
+ parseClassName = className => className.startsWith(fullPrefix) ? parseClassNameOriginal(className.slice(fullPrefix.length)) : createResultObject(EMPTY_MODIFIERS, false, className, undefined, true);
17964
17182
  }
17965
17183
  if (experimentalParseClassName) {
17966
17184
  const parseClassNameOriginal = parseClassName;
@@ -17971,19 +17189,6 @@ const createParseClassName = config => {
17971
17189
  }
17972
17190
  return parseClassName;
17973
17191
  };
17974
- const stripImportantModifier = baseClassName => {
17975
- if (baseClassName.endsWith(IMPORTANT_MODIFIER)) {
17976
- return baseClassName.substring(0, baseClassName.length - 1);
17977
- }
17978
- /**
17979
- * In Tailwind CSS v3 the important modifier was at the start of the base class name. This is still supported for legacy reasons.
17980
- * @see https://github.com/dcastil/tailwind-merge/issues/513#issuecomment-2614029864
17981
- */
17982
- if (baseClassName.startsWith(IMPORTANT_MODIFIER)) {
17983
- return baseClassName.substring(1);
17984
- }
17985
- return baseClassName;
17986
- };
17987
17192
 
17988
17193
  /**
17989
17194
  * Sorts modifiers according to following schema:
@@ -17991,26 +17196,41 @@ const stripImportantModifier = baseClassName => {
17991
17196
  * - When an arbitrary variant appears, it must be preserved which modifiers are before and after it
17992
17197
  */
17993
17198
  const createSortModifiers = config => {
17994
- const orderSensitiveModifiers = Object.fromEntries(config.orderSensitiveModifiers.map(modifier => [modifier, true]));
17995
- const sortModifiers = modifiers => {
17996
- if (modifiers.length <= 1) {
17997
- return modifiers;
17998
- }
17999
- const sortedModifiers = [];
18000
- let unsortedModifiers = [];
18001
- modifiers.forEach(modifier => {
18002
- const isPositionSensitive = modifier[0] === '[' || orderSensitiveModifiers[modifier];
18003
- if (isPositionSensitive) {
18004
- sortedModifiers.push(...unsortedModifiers.sort(), modifier);
18005
- unsortedModifiers = [];
17199
+ // Pre-compute weights for all known modifiers for O(1) comparison
17200
+ const modifierWeights = new Map();
17201
+ // Assign weights to sensitive modifiers (highest priority, but preserve order)
17202
+ config.orderSensitiveModifiers.forEach((mod, index) => {
17203
+ modifierWeights.set(mod, 1000000 + index); // High weights for sensitive mods
17204
+ });
17205
+ return modifiers => {
17206
+ const result = [];
17207
+ let currentSegment = [];
17208
+ // Process modifiers in one pass
17209
+ for (let i = 0; i < modifiers.length; i++) {
17210
+ const modifier = modifiers[i];
17211
+ // Check if modifier is sensitive (starts with '[' or in orderSensitiveModifiers)
17212
+ const isArbitrary = modifier[0] === '[';
17213
+ const isOrderSensitive = modifierWeights.has(modifier);
17214
+ if (isArbitrary || isOrderSensitive) {
17215
+ // Sort and flush current segment alphabetically
17216
+ if (currentSegment.length > 0) {
17217
+ currentSegment.sort();
17218
+ result.push(...currentSegment);
17219
+ currentSegment = [];
17220
+ }
17221
+ result.push(modifier);
18006
17222
  } else {
18007
- unsortedModifiers.push(modifier);
17223
+ // Regular modifier - add to current segment for batch sorting
17224
+ currentSegment.push(modifier);
18008
17225
  }
18009
- });
18010
- sortedModifiers.push(...unsortedModifiers.sort());
18011
- return sortedModifiers;
17226
+ }
17227
+ // Sort and add any remaining segment items
17228
+ if (currentSegment.length > 0) {
17229
+ currentSegment.sort();
17230
+ result.push(...currentSegment);
17231
+ }
17232
+ return result;
18012
17233
  };
18013
- return sortModifiers;
18014
17234
  };
18015
17235
  const createConfigUtils = config => ({
18016
17236
  cache: createLruCache(config.cacheSize),
@@ -18065,10 +17285,11 @@ const mergeClassList = (classList, configUtils) => {
18065
17285
  }
18066
17286
  hasPostfixModifier = false;
18067
17287
  }
18068
- const variantModifier = sortModifiers(modifiers).join(':');
17288
+ // Fast path: skip sorting for empty or single modifier
17289
+ const variantModifier = modifiers.length === 0 ? '' : modifiers.length === 1 ? modifiers[0] : sortModifiers(modifiers).join(':');
18069
17290
  const modifierId = hasImportantModifier ? variantModifier + IMPORTANT_MODIFIER : variantModifier;
18070
17291
  const classId = modifierId + classGroupId;
18071
- if (classGroupsInConflict.includes(classId)) {
17292
+ if (classGroupsInConflict.indexOf(classId) > -1) {
18072
17293
  // Tailwind class omitted due to conflict
18073
17294
  continue;
18074
17295
  }
@@ -18093,13 +17314,13 @@ const mergeClassList = (classList, configUtils) => {
18093
17314
  *
18094
17315
  * Original code has MIT license: Copyright (c) Luke Edwards <luke.edwards05@gmail.com> (lukeed.com)
18095
17316
  */
18096
- function twJoin() {
17317
+ const twJoin = (...classLists) => {
18097
17318
  let index = 0;
18098
17319
  let argument;
18099
17320
  let resolvedValue;
18100
17321
  let string = '';
18101
- while (index < arguments.length) {
18102
- if (argument = arguments[index++]) {
17322
+ while (index < classLists.length) {
17323
+ if (argument = classLists[index++]) {
18103
17324
  if (resolvedValue = toValue(argument)) {
18104
17325
  string && (string += ' ');
18105
17326
  string += resolvedValue;
@@ -18107,8 +17328,9 @@ function twJoin() {
18107
17328
  }
18108
17329
  }
18109
17330
  return string;
18110
- }
17331
+ };
18111
17332
  const toValue = mix => {
17333
+ // Fast path for strings
18112
17334
  if (typeof mix === 'string') {
18113
17335
  return mix;
18114
17336
  }
@@ -18124,20 +17346,20 @@ const toValue = mix => {
18124
17346
  }
18125
17347
  return string;
18126
17348
  };
18127
- function createTailwindMerge(createConfigFirst, ...createConfigRest) {
17349
+ const createTailwindMerge = (createConfigFirst, ...createConfigRest) => {
18128
17350
  let configUtils;
18129
17351
  let cacheGet;
18130
17352
  let cacheSet;
18131
- let functionToCall = initTailwindMerge;
18132
- function initTailwindMerge(classList) {
17353
+ let functionToCall;
17354
+ const initTailwindMerge = classList => {
18133
17355
  const config = createConfigRest.reduce((previousConfig, createConfigCurrent) => createConfigCurrent(previousConfig), createConfigFirst());
18134
17356
  configUtils = createConfigUtils(config);
18135
17357
  cacheGet = configUtils.cache.get;
18136
17358
  cacheSet = configUtils.cache.set;
18137
17359
  functionToCall = tailwindMerge;
18138
17360
  return tailwindMerge(classList);
18139
- }
18140
- function tailwindMerge(classList) {
17361
+ };
17362
+ const tailwindMerge = classList => {
18141
17363
  const cachedResult = cacheGet(classList);
18142
17364
  if (cachedResult) {
18143
17365
  return cachedResult;
@@ -18145,13 +17367,13 @@ function createTailwindMerge(createConfigFirst, ...createConfigRest) {
18145
17367
  const result = mergeClassList(classList, configUtils);
18146
17368
  cacheSet(classList, result);
18147
17369
  return result;
18148
- }
18149
- return function callTailwindMerge() {
18150
- return functionToCall(twJoin.apply(null, arguments));
18151
17370
  };
18152
- }
17371
+ functionToCall = initTailwindMerge;
17372
+ return (...args) => functionToCall(twJoin(...args));
17373
+ };
17374
+ const fallbackThemeArr = [];
18153
17375
  const fromTheme = key => {
18154
- const themeGetter = theme => theme[key] || [];
17376
+ const themeGetter = theme => theme[key] || fallbackThemeArr;
18155
17377
  themeGetter.isThemeGetter = true;
18156
17378
  return themeGetter;
18157
17379
  };
@@ -20718,4 +19940,136 @@ function createExtractor(allData, cache, usedKeys) {
20718
19940
  */
20719
19941
  function withMemo(Component, propsAreEqual) {
20720
19942
  return memo(Component, propsAreEqual);
20721
- }export{AppProviders,DEFAULT_FORM_ENTRY,DEFAULT_MUTATION_ENTRY,DEFAULT_QUERY_ENTRY,DefaultContainer,DefaultFormContainer,FormField,FormManager,MemoizationCache,MetadataStoreProvider,PageGenerator,QueriesProvider,RenderComponents,ab2str,algorithm,apiConfigAtom,apiRequest,applyMetadataToDom,atomStateGenerator,authAtom,buildArticleJsonLd,buildBreadcrumbListJsonLd,buildFAQPageJsonLd,buildOrganizationJsonLd,buildProductJsonLd,buildWebSiteJsonLd,clearMetadataLog,cn,collectMetadataToHtml,createExtractor,createFormSelector,createMetadataStore,createMutationSelector,createQuerySelector,createScopeFormsAtom,createScopeMutationsAtom,createScopePageVariablesAtom,createScopeQueriesAtom,createServerTranslator,decryptData,deepEqual,encryptData,fetchRequest,formAtom,formConfigAtom,generateLlmsFullTxt,generateLlmsTxt,generateRobotsTxt,generateSitemapEntries,generateSitemapXml,getCompositeKey,getFormCompositeKey,getMetadata,getMetadataLog,getPageConfig,getPageVariablesCompositeKey,importKey,isStableValue,localizationConfigAtom,logMetadata,memoPropsComparator,memoize,mutationsAtom,optimizeDeps,pageConfigAtom,pageToMarkdown,pageVariablesAtom,pageVariablesAtomFamily,queriesAtom,resetMetadata,resolveMetadata,resolveTranslation,setCustomStorage,setDefaultFormContainer,setMetadata,setMetadataLogging,shallowEqual,storage,str2ab,toNextHeadTags,toNextMetadata,useApi,useApiConfigReset,useApiConfigState,useApiConfigValue,useApiValues,useApplyMetadata,useAuthState,useAuthValue,useFormConfigReset,useFormConfigState,useFormConfigValue,useFormData,useFormManager,useFormState,useFormValue,useFormValues,useGenerateContent,useGenerateContentRender,useInvalidateQueries,useJotaiForm,useJotaiMutations,useJotaiQueries,useLocalizationActions,useLocalizationConfigReset,useLocalizationConfigState,useLocalizationConfigValue,useMetadata,useMetadataStore,useMultipleMutation,useMultipleQuery,useMultipleWebSocket,useMutateApi,usePageConfig,usePageConfigReset,usePageConfigState,usePageConfigValue,useQueryApi,useSetFormState,useTranslatedText,useTranslation,useViewSettings,useWebSocket,withMemo};//# sourceMappingURL=index.mjs.map
19943
+ }const {
19944
+ useState: useNotificationState
19945
+ } = atomStateGenerator$1({
19946
+ defaultValue: null,
19947
+ key: 'reactNotificationAtom',
19948
+ persist: false
19949
+ });const useNotificationSet = () => {
19950
+ const [, setValue] = useNotificationState();
19951
+ return setValue;
19952
+ };
19953
+ const useNotification = t0 => {
19954
+ const $ = c(10);
19955
+ const ns = "notifications" ;
19956
+ const setNotification = useNotificationSet();
19957
+ let t1;
19958
+ if ($[0] !== ns || $[1] !== setNotification) {
19959
+ t1 = {
19960
+ setNotification,
19961
+ ns
19962
+ };
19963
+ $[0] = ns;
19964
+ $[1] = setNotification;
19965
+ $[2] = t1;
19966
+ } else {
19967
+ t1 = $[2];
19968
+ }
19969
+ const ref = useRef(t1);
19970
+ let t2;
19971
+ let t3;
19972
+ if ($[3] !== ns || $[4] !== setNotification) {
19973
+ t2 = () => {
19974
+ ref.current = {
19975
+ setNotification,
19976
+ ns
19977
+ };
19978
+ };
19979
+ t3 = [setNotification, ns];
19980
+ $[3] = ns;
19981
+ $[4] = setNotification;
19982
+ $[5] = t2;
19983
+ $[6] = t3;
19984
+ } else {
19985
+ t2 = $[5];
19986
+ t3 = $[6];
19987
+ }
19988
+ useEffect(t2, t3);
19989
+ let t4;
19990
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
19991
+ t4 = notification => {
19992
+ ref.current.setNotification(Object.assign(Object.assign({
19993
+ ns: ref.current.ns
19994
+ }, notification), {
19995
+ id: Date.now().toString()
19996
+ }));
19997
+ };
19998
+ $[7] = t4;
19999
+ } else {
20000
+ t4 = $[7];
20001
+ }
20002
+ const showNotification = t4;
20003
+ let t5;
20004
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
20005
+ t5 = () => {
20006
+ ref.current.setNotification(null);
20007
+ };
20008
+ $[8] = t5;
20009
+ } else {
20010
+ t5 = $[8];
20011
+ }
20012
+ const clearNotification = t5;
20013
+ let t6;
20014
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
20015
+ t6 = {
20016
+ showNotification,
20017
+ clearNotification
20018
+ };
20019
+ $[9] = t6;
20020
+ } else {
20021
+ t6 = $[9];
20022
+ }
20023
+ return t6;
20024
+ };/**
20025
+ * Hook per accedere a tutte le configurazioni dei plugin di core
20026
+ * Fornisce un'interfaccia centralizzata per le impostazioni dell'applicazione
20027
+ */
20028
+ const isLogged = authState => !!(authState === null || authState === void 0 ? void 0 : authState.id) && !!authState.isLogged;
20029
+ const useCoreConfig = ({
20030
+ form,
20031
+ localization,
20032
+ pages,
20033
+ apiConfig
20034
+ }) => {
20035
+ const auth = useAuthValue();
20036
+ const {
20037
+ t: translateText
20038
+ } = useTranslation$1();
20039
+ const {
20040
+ showNotification
20041
+ } = useNotification();
20042
+ const [currentFormConfig, setFormConfig] = useFormConfigState$1();
20043
+ const [currentLocalizationConfig, setLocalizationConfig] = useLocalizationConfigState$1();
20044
+ const [currentPageConfig, setPageConfig] = usePageConfigState$1();
20045
+ const [currentApiConfig, setApiConfig] = useApiConfigState$1();
20046
+ useEffect(() => {
20047
+ setFormConfig(Object.assign(Object.assign({
20048
+ translateText,
20049
+ showNotification
20050
+ }, currentFormConfig), form));
20051
+ // eslint-disable-next-line react-hooks/exhaustive-deps
20052
+ }, [translateText, showNotification, form]);
20053
+ useEffect(() => {
20054
+ setLocalizationConfig(Object.assign(Object.assign({}, currentLocalizationConfig), localization));
20055
+ // eslint-disable-next-line react-hooks/exhaustive-deps
20056
+ }, [JSON.stringify(localization)]);
20057
+ useEffect(() => {
20058
+ setPageConfig(Object.assign(Object.assign(Object.assign({
20059
+ authValues: auth
20060
+ }, currentPageConfig), pages), {
20061
+ isLogged
20062
+ }));
20063
+ // eslint-disable-next-line react-hooks/exhaustive-deps
20064
+ }, [pages, JSON.stringify(auth)]);
20065
+ useEffect(() => {
20066
+ setApiConfig(Object.assign(Object.assign({
20067
+ defaultHeaders: {
20068
+ Authorization: (auth === null || auth === void 0 ? void 0 : auth.token) ? `Bearer ${auth.token}` : ""
20069
+ },
20070
+ showNotification,
20071
+ validateAuthFn: () => !!(auth === null || auth === void 0 ? void 0 : auth.isLogged)
20072
+ }, currentApiConfig), apiConfig));
20073
+ // eslint-disable-next-line react-hooks/exhaustive-deps
20074
+ }, [apiConfig, showNotification, JSON.stringify(auth)]);
20075
+ };export{AppProviders,DEFAULT_FORM_ENTRY,DEFAULT_MUTATION_ENTRY,DEFAULT_QUERY_ENTRY,DefaultContainer,DefaultFormContainer,FormField,FormManager,MemoizationCache,MetadataStoreProvider,PageGenerator,QueriesProvider,RenderComponents,ab2str,algorithm,apiConfigAtom,apiRequest,applyMetadataToDom,atomStateGenerator,authAtom,buildArticleJsonLd,buildBreadcrumbListJsonLd,buildFAQPageJsonLd,buildOrganizationJsonLd,buildProductJsonLd,buildWebSiteJsonLd,clearMetadataLog,cn,collectMetadataToHtml,createExtractor,createFormSelector,createMetadataStore,createMutationSelector,createQuerySelector,createScopeFormsAtom,createScopeMutationsAtom,createScopePageVariablesAtom,createScopeQueriesAtom,createServerTranslator,decryptData,deepEqual,encryptData,fetchRequest,formAtom,formConfigAtom,generateLlmsFullTxt,generateLlmsTxt,generateRobotsTxt,generateSitemapEntries,generateSitemapXml,getCompositeKey,getFormCompositeKey,getMetadata,getMetadataLog,getPageConfig,getPageVariablesCompositeKey,importKey,isStableValue,localizationConfigAtom,logMetadata,memoPropsComparator,memoize,mutationsAtom,optimizeDeps,pageConfigAtom,pageToMarkdown,pageVariablesAtom,pageVariablesAtomFamily,queriesAtom,resetMetadata,resolveMetadata,resolveTranslation,setCustomStorage,setDefaultFormContainer,setMetadata,setMetadataLogging,shallowEqual,storage,str2ab,toNextHeadTags,toNextMetadata,useApi,useApiConfigReset,useApiConfigState,useApiConfigValue,useApiValues,useApplyMetadata,useAuthState,useAuthValue,useCoreConfig,useFormConfigReset,useFormConfigState,useFormConfigValue,useFormData,useFormManager,useFormState,useFormValue,useFormValues,useGenerateContent,useGenerateContentRender,useInvalidateQueries,useJotaiForm,useJotaiMutations,useJotaiQueries,useLocalizationActions,useLocalizationConfigReset,useLocalizationConfigState,useLocalizationConfigValue,useMetadata,useMetadataStore,useMultipleMutation,useMultipleQuery,useMultipleWebSocket,useMutateApi,usePageConfig,usePageConfigReset,usePageConfigState,usePageConfigValue,useQueryApi,useSetFormState,useTranslatedText,useTranslation,useViewSettings,useWebSocket,withMemo};//# sourceMappingURL=index.mjs.map