@luzmo/analytics-components-kit 1.0.1-alpha.39 → 1.0.1-alpha.40

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.
Files changed (57) hide show
  1. package/components/bliss-DQej6Odb.cjs +20 -0
  2. package/components/bliss-Da17RL_E.js +80 -0
  3. package/components/classic-CW66MgMj.cjs +20 -0
  4. package/components/classic-DSp70wnP.js +86 -0
  5. package/components/classic-dark-DCtf8kpl.cjs +20 -0
  6. package/components/classic-dark-o89nk6Bo.js +77 -0
  7. package/components/default-DBxqR7y5.js +84 -0
  8. package/components/default-DcRD5JRU.cjs +20 -0
  9. package/components/default-dark-1299UcUs.cjs +20 -0
  10. package/components/default-dark-IedybpaJ.js +84 -0
  11. package/components/draggable-data-item-level/index.cjs +1 -1
  12. package/components/draggable-data-item-level/index.js +1 -1
  13. package/components/droppable-slot/index.cjs +1 -1
  14. package/components/droppable-slot/index.js +1 -1
  15. package/components/filter-item/index.cjs +1 -1
  16. package/components/filter-item/index.js +1 -1
  17. package/components/filter-value-picker-hierarchy/index.cjs +1 -1
  18. package/components/filter-value-picker-hierarchy/index.js +1 -2
  19. package/components/filter-value-picker-numeric/index.cjs +1 -1
  20. package/components/filter-value-picker-numeric/index.js +1 -1
  21. package/components/grid/grid.d.ts +5 -1
  22. package/components/grid/index.cjs +46 -45
  23. package/components/grid/index.js +1217 -1193
  24. package/components/index.cjs +1 -1
  25. package/components/index.js +7 -6
  26. package/components/orion-CfUR1e5D.cjs +20 -0
  27. package/components/orion-DiAhsMdg.js +74 -0
  28. package/components/pinky-Cb0md2xU.js +72 -0
  29. package/components/pinky-DptTgIM4.cjs +20 -0
  30. package/components/radiant-C6fqp6jv.js +75 -0
  31. package/components/radiant-Dv7GVveL.cjs +20 -0
  32. package/components/royale-CmXiODck.js +66 -0
  33. package/components/royale-Ooq8M7Ef.cjs +20 -0
  34. package/components/seasonal-9pbLR3XJ.js +80 -0
  35. package/components/seasonal-OSKpFyta.cjs +20 -0
  36. package/components/slot-menu-list/index.cjs +1 -1
  37. package/components/slot-menu-list/index.js +3 -3
  38. package/components/urban-BLQl5Oye.cjs +20 -0
  39. package/components/urban-CZ4PAlar.js +77 -0
  40. package/components/utils-B1rr30GZ.js +60 -0
  41. package/components/utils-CvCeHVBQ.cjs +20 -0
  42. package/components/utils.cjs +1 -1
  43. package/components/utils.js +9 -8
  44. package/components/vivid-B-cgSae_.js +76 -0
  45. package/components/vivid-BpRn83MR.cjs +20 -0
  46. package/item-definitions/marker-map/marker-map-options.config.d.ts +1 -1
  47. package/package.json +1 -1
  48. package/utils/index.d.ts +1 -1
  49. package/utils/themes/index.d.ts +3 -508
  50. package/utils/themes/utils.d.ts +1 -0
  51. package/components/get-css-variable-BEYG097C.js +0 -1446
  52. package/components/get-css-variable-BZxY4IOa.cjs +0 -35
  53. package/components/grid/default-actions.d.ts +0 -14
  54. package/components/index-CcLRp9ao.js +0 -1685
  55. package/components/index-CpGRysX_.js +0 -691
  56. package/components/index-DFHExzGq.cjs +0 -20
  57. package/components/index-GgkqKtE6.cjs +0 -20
@@ -1,1685 +0,0 @@
1
- /*! * A kit of modern Luzmo Web Components for analytics in your web application.
2
- *
3
- * Copyright © 2025 Luzmo
4
- * All rights reserved.
5
- * Luzmo web components (“Luzmo Web Components”)
6
- * must be used according to the Luzmo Terms of Service.
7
- * This license allows users with a current active Luzmo account
8
- * to use the Luzmo Web Components. This license terminates
9
- * automatically if a user no longer has an active Luzmo account.
10
- * Please view the Luzmo Terms of Service at: https://www.luzmo.com/information-pages/terms-of-use.
11
- *
12
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18
- * SOFTWARE.
19
- * */
20
- var Se = (s) => {
21
- throw TypeError(s);
22
- };
23
- var qe = (s, e, t) => e.has(s) || Se("Cannot " + t);
24
- var i = (s, e, t) => (qe(s, e, "read from private field"), t ? t.call(s) : e.get(s)), l = (s, e, t) => e.has(s) ? Se("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(s) : e.set(s, t), o = (s, e, t, r) => (qe(s, e, "write to private field"), r ? r.call(s, t) : e.set(s, t), t), q = (s, e, t) => (qe(s, e, "access private method"), t);
25
- var pe = (s, e, t, r) => ({
26
- set _(n) {
27
- o(s, e, n, t);
28
- },
29
- get _() {
30
- return i(s, e, r);
31
- }
32
- });
33
- var be = class {
34
- constructor() {
35
- this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
36
- }
37
- subscribe(s) {
38
- return this.listeners.add(s), this.onSubscribe(), () => {
39
- this.listeners.delete(s), this.onUnsubscribe();
40
- };
41
- }
42
- hasListeners() {
43
- return this.listeners.size > 0;
44
- }
45
- onSubscribe() {
46
- }
47
- onUnsubscribe() {
48
- }
49
- }, ge = typeof window > "u" || "Deno" in globalThis;
50
- function T() {
51
- }
52
- function Je(s, e) {
53
- return typeof s == "function" ? s(e) : s;
54
- }
55
- function We(s) {
56
- return typeof s == "number" && s >= 0 && s !== 1 / 0;
57
- }
58
- function _e(s, e) {
59
- return Math.max(s + (e || 0) - Date.now(), 0);
60
- }
61
- function Ae(s, e) {
62
- return typeof s == "function" ? s(e) : s;
63
- }
64
- function Xe(s, e) {
65
- return typeof s == "function" ? s(e) : s;
66
- }
67
- function De(s, e) {
68
- const {
69
- type: t = "all",
70
- exact: r,
71
- fetchStatus: n,
72
- predicate: a,
73
- queryKey: h,
74
- stale: u
75
- } = s;
76
- if (h) {
77
- if (r) {
78
- if (e.queryHash !== Ce(h, e.options))
79
- return !1;
80
- } else if (!ce(e.queryKey, h))
81
- return !1;
82
- }
83
- if (t !== "all") {
84
- const d = e.isActive();
85
- if (t === "active" && !d || t === "inactive" && d)
86
- return !1;
87
- }
88
- return !(typeof u == "boolean" && e.isStale() !== u || n && n !== e.state.fetchStatus || a && !a(e));
89
- }
90
- function Qe(s, e) {
91
- const { exact: t, status: r, predicate: n, mutationKey: a } = s;
92
- if (a) {
93
- if (!e.options.mutationKey)
94
- return !1;
95
- if (t) {
96
- if (oe(e.options.mutationKey) !== oe(a))
97
- return !1;
98
- } else if (!ce(e.options.mutationKey, a))
99
- return !1;
100
- }
101
- return !(r && e.state.status !== r || n && !n(e));
102
- }
103
- function Ce(s, e) {
104
- return ((e == null ? void 0 : e.queryKeyHashFn) || oe)(s);
105
- }
106
- function oe(s) {
107
- return JSON.stringify(
108
- s,
109
- (e, t) => Fe(t) ? Object.keys(t).sort().reduce((r, n) => (r[n] = t[n], r), {}) : t
110
- );
111
- }
112
- function ce(s, e) {
113
- return s === e ? !0 : typeof s != typeof e ? !1 : s && e && typeof s == "object" && typeof e == "object" ? Object.keys(e).every((t) => ce(s[t], e[t])) : !1;
114
- }
115
- function Oe(s, e) {
116
- if (s === e)
117
- return s;
118
- const t = Ee(s) && Ee(e);
119
- if (t || Fe(s) && Fe(e)) {
120
- const r = t ? s : Object.keys(s), n = r.length, a = t ? e : Object.keys(e), h = a.length, u = t ? [] : {};
121
- let d = 0;
122
- for (let g = 0; g < h; g++) {
123
- const m = t ? g : a[g];
124
- (!t && r.includes(m) || t) && s[m] === void 0 && e[m] === void 0 ? (u[m] = void 0, d++) : (u[m] = Oe(s[m], e[m]), u[m] === s[m] && s[m] !== void 0 && d++);
125
- }
126
- return n === h && d === n ? s : u;
127
- }
128
- return e;
129
- }
130
- function Ee(s) {
131
- return Array.isArray(s) && s.length === Object.keys(s).length;
132
- }
133
- function Fe(s) {
134
- if (!Te(s))
135
- return !1;
136
- const e = s.constructor;
137
- if (e === void 0)
138
- return !0;
139
- const t = e.prototype;
140
- return !(!Te(t) || !t.hasOwnProperty("isPrototypeOf") || Object.getPrototypeOf(s) !== Object.prototype);
141
- }
142
- function Te(s) {
143
- return Object.prototype.toString.call(s) === "[object Object]";
144
- }
145
- function Ye(s) {
146
- return new Promise((e) => {
147
- setTimeout(e, s);
148
- });
149
- }
150
- function Ze(s, e, t) {
151
- if (typeof t.structuralSharing == "function")
152
- return t.structuralSharing(s, e);
153
- if (t.structuralSharing !== !1) {
154
- try {
155
- return Oe(s, e);
156
- } catch (r) {
157
- throw console.error(
158
- `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${t.queryHash}]: ${r}`
159
- ), r;
160
- }
161
- return Oe(s, e);
162
- }
163
- return e;
164
- }
165
- function et(s, e, t = 0) {
166
- const r = [...s, e];
167
- return t && r.length > t ? r.slice(1) : r;
168
- }
169
- function tt(s, e, t = 0) {
170
- const r = [e, ...s];
171
- return t && r.length > t ? r.slice(0, -1) : r;
172
- }
173
- var ve = Symbol();
174
- function Ge(s, e) {
175
- return s.queryFn === ve && console.error(
176
- `Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${s.queryHash}'`
177
- ), !s.queryFn && (e != null && e.initialPromise) ? () => e.initialPromise : !s.queryFn || s.queryFn === ve ? () => Promise.reject(new Error(`Missing queryFn: '${s.queryHash}'`)) : s.queryFn;
178
- }
179
- var J, G, Z, Ke, st = (Ke = class extends be {
180
- constructor() {
181
- super();
182
- l(this, J);
183
- l(this, G);
184
- l(this, Z);
185
- o(this, Z, (e) => {
186
- if (!ge && window.addEventListener) {
187
- const t = () => e();
188
- return window.addEventListener("visibilitychange", t, !1), () => {
189
- window.removeEventListener("visibilitychange", t);
190
- };
191
- }
192
- });
193
- }
194
- onSubscribe() {
195
- i(this, G) || this.setEventListener(i(this, Z));
196
- }
197
- onUnsubscribe() {
198
- var e;
199
- this.hasListeners() || ((e = i(this, G)) == null || e.call(this), o(this, G, void 0));
200
- }
201
- setEventListener(e) {
202
- var t;
203
- o(this, Z, e), (t = i(this, G)) == null || t.call(this), o(this, G, e((r) => {
204
- typeof r == "boolean" ? this.setFocused(r) : this.onFocus();
205
- }));
206
- }
207
- setFocused(e) {
208
- i(this, J) !== e && (o(this, J, e), this.onFocus());
209
- }
210
- onFocus() {
211
- const e = this.isFocused();
212
- this.listeners.forEach((t) => {
213
- t(e);
214
- });
215
- }
216
- isFocused() {
217
- var e;
218
- return typeof i(this, J) == "boolean" ? i(this, J) : ((e = globalThis.document) == null ? void 0 : e.visibilityState) !== "hidden";
219
- }
220
- }, J = new WeakMap(), G = new WeakMap(), Z = new WeakMap(), Ke), Ne = new st(), ee, N, te, ke, rt = (ke = class extends be {
221
- constructor() {
222
- super();
223
- l(this, ee, !0);
224
- l(this, N);
225
- l(this, te);
226
- o(this, te, (e) => {
227
- if (!ge && window.addEventListener) {
228
- const t = () => e(!0), r = () => e(!1);
229
- return window.addEventListener("online", t, !1), window.addEventListener("offline", r, !1), () => {
230
- window.removeEventListener("online", t), window.removeEventListener("offline", r);
231
- };
232
- }
233
- });
234
- }
235
- onSubscribe() {
236
- i(this, N) || this.setEventListener(i(this, te));
237
- }
238
- onUnsubscribe() {
239
- var e;
240
- this.hasListeners() || ((e = i(this, N)) == null || e.call(this), o(this, N, void 0));
241
- }
242
- setEventListener(e) {
243
- var t;
244
- o(this, te, e), (t = i(this, N)) == null || t.call(this), o(this, N, e(this.setOnline.bind(this)));
245
- }
246
- setOnline(e) {
247
- i(this, ee) !== e && (o(this, ee, e), this.listeners.forEach((r) => {
248
- r(e);
249
- }));
250
- }
251
- isOnline() {
252
- return i(this, ee);
253
- }
254
- }, ee = new WeakMap(), N = new WeakMap(), te = new WeakMap(), ke), we = new rt();
255
- function it() {
256
- let s, e;
257
- const t = new Promise((n, a) => {
258
- s = n, e = a;
259
- });
260
- t.status = "pending", t.catch(() => {
261
- });
262
- function r(n) {
263
- Object.assign(t, n), delete t.resolve, delete t.reject;
264
- }
265
- return t.resolve = (n) => {
266
- r({
267
- status: "fulfilled",
268
- value: n
269
- }), s(n);
270
- }, t.reject = (n) => {
271
- r({
272
- status: "rejected",
273
- reason: n
274
- }), e(n);
275
- }, t;
276
- }
277
- function nt(s) {
278
- return Math.min(1e3 * 2 ** s, 3e4);
279
- }
280
- function Ve(s) {
281
- return (s ?? "online") === "online" ? we.isOnline() : !0;
282
- }
283
- var $e = class extends Error {
284
- constructor(s) {
285
- super("CancelledError"), this.revert = s == null ? void 0 : s.revert, this.silent = s == null ? void 0 : s.silent;
286
- }
287
- };
288
- function Pe(s) {
289
- return s instanceof $e;
290
- }
291
- function ze(s) {
292
- let e = !1, t = 0, r = !1, n;
293
- const a = it(), h = (c) => {
294
- var p;
295
- r || (y(new $e(c)), (p = s.abort) == null || p.call(s));
296
- }, u = () => {
297
- e = !0;
298
- }, d = () => {
299
- e = !1;
300
- }, g = () => Ne.isFocused() && (s.networkMode === "always" || we.isOnline()) && s.canRun(), m = () => Ve(s.networkMode) && s.canRun(), f = (c) => {
301
- var p;
302
- r || (r = !0, (p = s.onSuccess) == null || p.call(s, c), n == null || n(), a.resolve(c));
303
- }, y = (c) => {
304
- var p;
305
- r || (r = !0, (p = s.onError) == null || p.call(s, c), n == null || n(), a.reject(c));
306
- }, S = () => new Promise((c) => {
307
- var p;
308
- n = (A) => {
309
- (r || g()) && c(A);
310
- }, (p = s.onPause) == null || p.call(s);
311
- }).then(() => {
312
- var c;
313
- n = void 0, r || (c = s.onContinue) == null || c.call(s);
314
- }), O = () => {
315
- if (r)
316
- return;
317
- let c;
318
- const p = t === 0 ? s.initialPromise : void 0;
319
- try {
320
- c = p ?? s.fn();
321
- } catch (A) {
322
- c = Promise.reject(A);
323
- }
324
- Promise.resolve(c).then(f).catch((A) => {
325
- var k;
326
- if (r)
327
- return;
328
- const E = s.retry ?? (ge ? 0 : 3), w = s.retryDelay ?? nt, D = typeof w == "function" ? w(t, A) : w, K = E === !0 || typeof E == "number" && t < E || typeof E == "function" && E(t, A);
329
- if (e || !K) {
330
- y(A);
331
- return;
332
- }
333
- t++, (k = s.onFail) == null || k.call(s, t, A), Ye(D).then(() => g() ? void 0 : S()).then(() => {
334
- e ? y(A) : O();
335
- });
336
- });
337
- };
338
- return {
339
- promise: a,
340
- cancel: h,
341
- continue: () => (n == null || n(), a),
342
- cancelRetry: u,
343
- continueRetry: d,
344
- canStart: m,
345
- start: () => (m() ? O() : S().then(O), a)
346
- };
347
- }
348
- var at = (s) => setTimeout(s, 0);
349
- function ut() {
350
- let s = [], e = 0, t = (u) => {
351
- u();
352
- }, r = (u) => {
353
- u();
354
- }, n = at;
355
- const a = (u) => {
356
- e ? s.push(u) : n(() => {
357
- t(u);
358
- });
359
- }, h = () => {
360
- const u = s;
361
- s = [], u.length && n(() => {
362
- r(() => {
363
- u.forEach((d) => {
364
- t(d);
365
- });
366
- });
367
- });
368
- };
369
- return {
370
- batch: (u) => {
371
- let d;
372
- e++;
373
- try {
374
- d = u();
375
- } finally {
376
- e--, e || h();
377
- }
378
- return d;
379
- },
380
- /**
381
- * All calls to the wrapped function will be batched.
382
- */
383
- batchCalls: (u) => (...d) => {
384
- a(() => {
385
- u(...d);
386
- });
387
- },
388
- schedule: a,
389
- /**
390
- * Use this method to set a custom notify function.
391
- * This can be used to for example wrap notifications with `React.act` while running tests.
392
- */
393
- setNotifyFunction: (u) => {
394
- t = u;
395
- },
396
- /**
397
- * Use this method to set a custom function to batch notifications together into a single tick.
398
- * By default React Query will use the batch function provided by ReactDOM or React Native.
399
- */
400
- setBatchNotifyFunction: (u) => {
401
- r = u;
402
- },
403
- setScheduler: (u) => {
404
- n = u;
405
- }
406
- };
407
- }
408
- var C = ut(), W, Ue, Be = (Ue = class {
409
- constructor() {
410
- l(this, W);
411
- }
412
- destroy() {
413
- this.clearGcTimeout();
414
- }
415
- scheduleGc() {
416
- this.clearGcTimeout(), We(this.gcTime) && o(this, W, setTimeout(() => {
417
- this.optionalRemove();
418
- }, this.gcTime));
419
- }
420
- updateGcTime(s) {
421
- this.gcTime = Math.max(
422
- this.gcTime || 0,
423
- s ?? (ge ? 1 / 0 : 5 * 60 * 1e3)
424
- );
425
- }
426
- clearGcTimeout() {
427
- i(this, W) && (clearTimeout(i(this, W)), o(this, W, void 0));
428
- }
429
- }, W = new WeakMap(), Ue), se, re, Q, _, P, le, X, M, L, je, ht = (je = class extends Be {
430
- constructor(e) {
431
- super();
432
- l(this, M);
433
- l(this, se);
434
- l(this, re);
435
- l(this, Q);
436
- l(this, _);
437
- l(this, P);
438
- l(this, le);
439
- l(this, X);
440
- o(this, X, !1), o(this, le, e.defaultOptions), this.setOptions(e.options), this.observers = [], o(this, _, e.client), o(this, Q, i(this, _).getQueryCache()), this.queryKey = e.queryKey, this.queryHash = e.queryHash, o(this, se, ct(this.options)), this.state = e.state ?? i(this, se), this.scheduleGc();
441
- }
442
- get meta() {
443
- return this.options.meta;
444
- }
445
- get promise() {
446
- var e;
447
- return (e = i(this, P)) == null ? void 0 : e.promise;
448
- }
449
- setOptions(e) {
450
- this.options = { ...i(this, le), ...e }, this.updateGcTime(this.options.gcTime);
451
- }
452
- optionalRemove() {
453
- !this.observers.length && this.state.fetchStatus === "idle" && i(this, Q).remove(this);
454
- }
455
- setData(e, t) {
456
- const r = Ze(this.state.data, e, this.options);
457
- return q(this, M, L).call(this, {
458
- data: r,
459
- type: "success",
460
- dataUpdatedAt: t == null ? void 0 : t.updatedAt,
461
- manual: t == null ? void 0 : t.manual
462
- }), r;
463
- }
464
- setState(e, t) {
465
- q(this, M, L).call(this, { type: "setState", state: e, setStateOptions: t });
466
- }
467
- cancel(e) {
468
- var r, n;
469
- const t = (r = i(this, P)) == null ? void 0 : r.promise;
470
- return (n = i(this, P)) == null || n.cancel(e), t ? t.then(T).catch(T) : Promise.resolve();
471
- }
472
- destroy() {
473
- super.destroy(), this.cancel({ silent: !0 });
474
- }
475
- reset() {
476
- this.destroy(), this.setState(i(this, se));
477
- }
478
- isActive() {
479
- return this.observers.some(
480
- (e) => Xe(e.options.enabled, this) !== !1
481
- );
482
- }
483
- isDisabled() {
484
- return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === ve || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
485
- }
486
- isStale() {
487
- return this.state.isInvalidated ? !0 : this.getObserversCount() > 0 ? this.observers.some(
488
- (e) => e.getCurrentResult().isStale
489
- ) : this.state.data === void 0;
490
- }
491
- isStaleByTime(e = 0) {
492
- return this.state.isInvalidated || this.state.data === void 0 || !_e(this.state.dataUpdatedAt, e);
493
- }
494
- onFocus() {
495
- var t;
496
- const e = this.observers.find((r) => r.shouldFetchOnWindowFocus());
497
- e == null || e.refetch({ cancelRefetch: !1 }), (t = i(this, P)) == null || t.continue();
498
- }
499
- onOnline() {
500
- var t;
501
- const e = this.observers.find((r) => r.shouldFetchOnReconnect());
502
- e == null || e.refetch({ cancelRefetch: !1 }), (t = i(this, P)) == null || t.continue();
503
- }
504
- addObserver(e) {
505
- this.observers.includes(e) || (this.observers.push(e), this.clearGcTimeout(), i(this, Q).notify({ type: "observerAdded", query: this, observer: e }));
506
- }
507
- removeObserver(e) {
508
- this.observers.includes(e) && (this.observers = this.observers.filter((t) => t !== e), this.observers.length || (i(this, P) && (i(this, X) ? i(this, P).cancel({ revert: !0 }) : i(this, P).cancelRetry()), this.scheduleGc()), i(this, Q).notify({ type: "observerRemoved", query: this, observer: e }));
509
- }
510
- getObserversCount() {
511
- return this.observers.length;
512
- }
513
- invalidate() {
514
- this.state.isInvalidated || q(this, M, L).call(this, { type: "invalidate" });
515
- }
516
- fetch(e, t) {
517
- var d, g, m;
518
- if (this.state.fetchStatus !== "idle") {
519
- if (this.state.data !== void 0 && (t != null && t.cancelRefetch))
520
- this.cancel({ silent: !0 });
521
- else if (i(this, P))
522
- return i(this, P).continueRetry(), i(this, P).promise;
523
- }
524
- if (e && this.setOptions(e), !this.options.queryFn) {
525
- const f = this.observers.find((y) => y.options.queryFn);
526
- f && this.setOptions(f.options);
527
- }
528
- Array.isArray(this.options.queryKey) || console.error(
529
- "As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"
530
- );
531
- const r = new AbortController(), n = (f) => {
532
- Object.defineProperty(f, "signal", {
533
- enumerable: !0,
534
- get: () => (o(this, X, !0), r.signal)
535
- });
536
- }, a = () => {
537
- const f = Ge(this.options, t), y = {
538
- client: i(this, _),
539
- queryKey: this.queryKey,
540
- meta: this.meta
541
- };
542
- return n(y), o(this, X, !1), this.options.persister ? this.options.persister(
543
- f,
544
- y,
545
- this
546
- ) : f(y);
547
- }, h = {
548
- fetchOptions: t,
549
- options: this.options,
550
- queryKey: this.queryKey,
551
- client: i(this, _),
552
- state: this.state,
553
- fetchFn: a
554
- };
555
- n(h), (d = this.options.behavior) == null || d.onFetch(
556
- h,
557
- this
558
- ), o(this, re, this.state), (this.state.fetchStatus === "idle" || this.state.fetchMeta !== ((g = h.fetchOptions) == null ? void 0 : g.meta)) && q(this, M, L).call(this, { type: "fetch", meta: (m = h.fetchOptions) == null ? void 0 : m.meta });
559
- const u = (f) => {
560
- var y, S, O, c;
561
- Pe(f) && f.silent || q(this, M, L).call(this, {
562
- type: "error",
563
- error: f
564
- }), Pe(f) || ((S = (y = i(this, Q).config).onError) == null || S.call(
565
- y,
566
- f,
567
- this
568
- ), (c = (O = i(this, Q).config).onSettled) == null || c.call(
569
- O,
570
- this.state.data,
571
- f,
572
- this
573
- )), this.scheduleGc();
574
- };
575
- return o(this, P, ze({
576
- initialPromise: t == null ? void 0 : t.initialPromise,
577
- fn: h.fetchFn,
578
- abort: r.abort.bind(r),
579
- onSuccess: (f) => {
580
- var y, S, O, c;
581
- if (f === void 0) {
582
- console.error(
583
- `Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
584
- ), u(new Error(`${this.queryHash} data is undefined`));
585
- return;
586
- }
587
- try {
588
- this.setData(f);
589
- } catch (p) {
590
- u(p);
591
- return;
592
- }
593
- (S = (y = i(this, Q).config).onSuccess) == null || S.call(y, f, this), (c = (O = i(this, Q).config).onSettled) == null || c.call(
594
- O,
595
- f,
596
- this.state.error,
597
- this
598
- ), this.scheduleGc();
599
- },
600
- onError: u,
601
- onFail: (f, y) => {
602
- q(this, M, L).call(this, { type: "failed", failureCount: f, error: y });
603
- },
604
- onPause: () => {
605
- q(this, M, L).call(this, { type: "pause" });
606
- },
607
- onContinue: () => {
608
- q(this, M, L).call(this, { type: "continue" });
609
- },
610
- retry: h.options.retry,
611
- retryDelay: h.options.retryDelay,
612
- networkMode: h.options.networkMode,
613
- canRun: () => !0
614
- })), i(this, P).start();
615
- }
616
- }, se = new WeakMap(), re = new WeakMap(), Q = new WeakMap(), _ = new WeakMap(), P = new WeakMap(), le = new WeakMap(), X = new WeakMap(), M = new WeakSet(), L = function(e) {
617
- const t = (r) => {
618
- switch (e.type) {
619
- case "failed":
620
- return {
621
- ...r,
622
- fetchFailureCount: e.failureCount,
623
- fetchFailureReason: e.error
624
- };
625
- case "pause":
626
- return {
627
- ...r,
628
- fetchStatus: "paused"
629
- };
630
- case "continue":
631
- return {
632
- ...r,
633
- fetchStatus: "fetching"
634
- };
635
- case "fetch":
636
- return {
637
- ...r,
638
- ...ot(r.data, this.options),
639
- fetchMeta: e.meta ?? null
640
- };
641
- case "success":
642
- return {
643
- ...r,
644
- data: e.data,
645
- dataUpdateCount: r.dataUpdateCount + 1,
646
- dataUpdatedAt: e.dataUpdatedAt ?? Date.now(),
647
- error: null,
648
- isInvalidated: !1,
649
- status: "success",
650
- ...!e.manual && {
651
- fetchStatus: "idle",
652
- fetchFailureCount: 0,
653
- fetchFailureReason: null
654
- }
655
- };
656
- case "error":
657
- const n = e.error;
658
- return Pe(n) && n.revert && i(this, re) ? { ...i(this, re), fetchStatus: "idle" } : {
659
- ...r,
660
- error: n,
661
- errorUpdateCount: r.errorUpdateCount + 1,
662
- errorUpdatedAt: Date.now(),
663
- fetchFailureCount: r.fetchFailureCount + 1,
664
- fetchFailureReason: n,
665
- fetchStatus: "idle",
666
- status: "error"
667
- };
668
- case "invalidate":
669
- return {
670
- ...r,
671
- isInvalidated: !0
672
- };
673
- case "setState":
674
- return {
675
- ...r,
676
- ...e.state
677
- };
678
- }
679
- };
680
- this.state = t(this.state), C.batch(() => {
681
- this.observers.forEach((r) => {
682
- r.onQueryUpdate();
683
- }), i(this, Q).notify({ query: this, type: "updated", action: e });
684
- });
685
- }, je);
686
- function ot(s, e) {
687
- return {
688
- fetchFailureCount: 0,
689
- fetchFailureReason: null,
690
- fetchStatus: Ve(e.networkMode) ? "fetching" : "paused",
691
- ...s === void 0 && {
692
- error: null,
693
- status: "pending"
694
- }
695
- };
696
- }
697
- function ct(s) {
698
- const e = typeof s.initialData == "function" ? s.initialData() : s.initialData, t = e !== void 0, r = t ? typeof s.initialDataUpdatedAt == "function" ? s.initialDataUpdatedAt() : s.initialDataUpdatedAt : 0;
699
- return {
700
- data: e,
701
- dataUpdateCount: 0,
702
- dataUpdatedAt: t ? r ?? Date.now() : 0,
703
- error: null,
704
- errorUpdateCount: 0,
705
- errorUpdatedAt: 0,
706
- fetchFailureCount: 0,
707
- fetchFailureReason: null,
708
- fetchMeta: null,
709
- isInvalidated: !1,
710
- status: t ? "success" : "pending",
711
- fetchStatus: "idle"
712
- };
713
- }
714
- var U, Ie, lt = (Ie = class extends be {
715
- constructor(e = {}) {
716
- super();
717
- l(this, U);
718
- this.config = e, o(this, U, /* @__PURE__ */ new Map());
719
- }
720
- build(e, t, r) {
721
- const n = t.queryKey, a = t.queryHash ?? Ce(n, t);
722
- let h = this.get(a);
723
- return h || (h = new ht({
724
- client: e,
725
- queryKey: n,
726
- queryHash: a,
727
- options: e.defaultQueryOptions(t),
728
- state: r,
729
- defaultOptions: e.getQueryDefaults(n)
730
- }), this.add(h)), h;
731
- }
732
- add(e) {
733
- i(this, U).has(e.queryHash) || (i(this, U).set(e.queryHash, e), this.notify({
734
- type: "added",
735
- query: e
736
- }));
737
- }
738
- remove(e) {
739
- const t = i(this, U).get(e.queryHash);
740
- t && (e.destroy(), t === e && i(this, U).delete(e.queryHash), this.notify({ type: "removed", query: e }));
741
- }
742
- clear() {
743
- C.batch(() => {
744
- this.getAll().forEach((e) => {
745
- this.remove(e);
746
- });
747
- });
748
- }
749
- get(e) {
750
- return i(this, U).get(e);
751
- }
752
- getAll() {
753
- return [...i(this, U).values()];
754
- }
755
- find(e) {
756
- const t = { exact: !0, ...e };
757
- return this.getAll().find(
758
- (r) => De(t, r)
759
- );
760
- }
761
- findAll(e = {}) {
762
- const t = this.getAll();
763
- return Object.keys(e).length > 0 ? t.filter((r) => De(e, r)) : t;
764
- }
765
- notify(e) {
766
- C.batch(() => {
767
- this.listeners.forEach((t) => {
768
- t(e);
769
- });
770
- });
771
- }
772
- onFocus() {
773
- C.batch(() => {
774
- this.getAll().forEach((e) => {
775
- e.onFocus();
776
- });
777
- });
778
- }
779
- onOnline() {
780
- C.batch(() => {
781
- this.getAll().forEach((e) => {
782
- e.onOnline();
783
- });
784
- });
785
- }
786
- }, U = new WeakMap(), Ie), j, F, Y, I, x, Le, dt = (Le = class extends Be {
787
- constructor(e) {
788
- super();
789
- l(this, I);
790
- l(this, j);
791
- l(this, F);
792
- l(this, Y);
793
- this.mutationId = e.mutationId, o(this, F, e.mutationCache), o(this, j, []), this.state = e.state || ft(), this.setOptions(e.options), this.scheduleGc();
794
- }
795
- setOptions(e) {
796
- this.options = e, this.updateGcTime(this.options.gcTime);
797
- }
798
- get meta() {
799
- return this.options.meta;
800
- }
801
- addObserver(e) {
802
- i(this, j).includes(e) || (i(this, j).push(e), this.clearGcTimeout(), i(this, F).notify({
803
- type: "observerAdded",
804
- mutation: this,
805
- observer: e
806
- }));
807
- }
808
- removeObserver(e) {
809
- o(this, j, i(this, j).filter((t) => t !== e)), this.scheduleGc(), i(this, F).notify({
810
- type: "observerRemoved",
811
- mutation: this,
812
- observer: e
813
- });
814
- }
815
- optionalRemove() {
816
- i(this, j).length || (this.state.status === "pending" ? this.scheduleGc() : i(this, F).remove(this));
817
- }
818
- continue() {
819
- var e;
820
- return ((e = i(this, Y)) == null ? void 0 : e.continue()) ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
821
- this.execute(this.state.variables);
822
- }
823
- async execute(e) {
824
- var a, h, u, d, g, m, f, y, S, O, c, p, A, E, w, D, K, k, fe, he;
825
- const t = () => {
826
- q(this, I, x).call(this, { type: "continue" });
827
- };
828
- o(this, Y, ze({
829
- fn: () => this.options.mutationFn ? this.options.mutationFn(e) : Promise.reject(new Error("No mutationFn found")),
830
- onFail: (b, ye) => {
831
- q(this, I, x).call(this, { type: "failed", failureCount: b, error: ye });
832
- },
833
- onPause: () => {
834
- q(this, I, x).call(this, { type: "pause" });
835
- },
836
- onContinue: t,
837
- retry: this.options.retry ?? 0,
838
- retryDelay: this.options.retryDelay,
839
- networkMode: this.options.networkMode,
840
- canRun: () => i(this, F).canRun(this)
841
- }));
842
- const r = this.state.status === "pending", n = !i(this, Y).canStart();
843
- try {
844
- if (r)
845
- t();
846
- else {
847
- q(this, I, x).call(this, { type: "pending", variables: e, isPaused: n }), await ((h = (a = i(this, F).config).onMutate) == null ? void 0 : h.call(
848
- a,
849
- e,
850
- this
851
- ));
852
- const ye = await ((d = (u = this.options).onMutate) == null ? void 0 : d.call(u, e));
853
- ye !== this.state.context && q(this, I, x).call(this, {
854
- type: "pending",
855
- context: ye,
856
- variables: e,
857
- isPaused: n
858
- });
859
- }
860
- const b = await i(this, Y).start();
861
- return await ((m = (g = i(this, F).config).onSuccess) == null ? void 0 : m.call(
862
- g,
863
- b,
864
- e,
865
- this.state.context,
866
- this
867
- )), await ((y = (f = this.options).onSuccess) == null ? void 0 : y.call(f, b, e, this.state.context)), await ((O = (S = i(this, F).config).onSettled) == null ? void 0 : O.call(
868
- S,
869
- b,
870
- null,
871
- this.state.variables,
872
- this.state.context,
873
- this
874
- )), await ((p = (c = this.options).onSettled) == null ? void 0 : p.call(c, b, null, e, this.state.context)), q(this, I, x).call(this, { type: "success", data: b }), b;
875
- } catch (b) {
876
- try {
877
- throw await ((E = (A = i(this, F).config).onError) == null ? void 0 : E.call(
878
- A,
879
- b,
880
- e,
881
- this.state.context,
882
- this
883
- )), await ((D = (w = this.options).onError) == null ? void 0 : D.call(
884
- w,
885
- b,
886
- e,
887
- this.state.context
888
- )), await ((k = (K = i(this, F).config).onSettled) == null ? void 0 : k.call(
889
- K,
890
- void 0,
891
- b,
892
- this.state.variables,
893
- this.state.context,
894
- this
895
- )), await ((he = (fe = this.options).onSettled) == null ? void 0 : he.call(
896
- fe,
897
- void 0,
898
- b,
899
- e,
900
- this.state.context
901
- )), b;
902
- } finally {
903
- q(this, I, x).call(this, { type: "error", error: b });
904
- }
905
- } finally {
906
- i(this, F).runNext(this);
907
- }
908
- }
909
- }, j = new WeakMap(), F = new WeakMap(), Y = new WeakMap(), I = new WeakSet(), x = function(e) {
910
- const t = (r) => {
911
- switch (e.type) {
912
- case "failed":
913
- return {
914
- ...r,
915
- failureCount: e.failureCount,
916
- failureReason: e.error
917
- };
918
- case "pause":
919
- return {
920
- ...r,
921
- isPaused: !0
922
- };
923
- case "continue":
924
- return {
925
- ...r,
926
- isPaused: !1
927
- };
928
- case "pending":
929
- return {
930
- ...r,
931
- context: e.context,
932
- data: void 0,
933
- failureCount: 0,
934
- failureReason: null,
935
- error: null,
936
- isPaused: e.isPaused,
937
- status: "pending",
938
- variables: e.variables,
939
- submittedAt: Date.now()
940
- };
941
- case "success":
942
- return {
943
- ...r,
944
- data: e.data,
945
- failureCount: 0,
946
- failureReason: null,
947
- error: null,
948
- status: "success",
949
- isPaused: !1
950
- };
951
- case "error":
952
- return {
953
- ...r,
954
- data: void 0,
955
- error: e.error,
956
- failureCount: r.failureCount + 1,
957
- failureReason: e.error,
958
- isPaused: !1,
959
- status: "error"
960
- };
961
- }
962
- };
963
- this.state = t(this.state), C.batch(() => {
964
- i(this, j).forEach((r) => {
965
- r.onMutationUpdate(e);
966
- }), i(this, F).notify({
967
- mutation: this,
968
- type: "updated",
969
- action: e
970
- });
971
- });
972
- }, Le);
973
- function ft() {
974
- return {
975
- context: void 0,
976
- data: void 0,
977
- error: null,
978
- failureCount: 0,
979
- failureReason: null,
980
- isPaused: !1,
981
- status: "idle",
982
- variables: void 0,
983
- submittedAt: 0
984
- };
985
- }
986
- var H, R, de, He, yt = (He = class extends be {
987
- constructor(e = {}) {
988
- super();
989
- l(this, H);
990
- l(this, R);
991
- l(this, de);
992
- this.config = e, o(this, H, /* @__PURE__ */ new Set()), o(this, R, /* @__PURE__ */ new Map()), o(this, de, 0);
993
- }
994
- build(e, t, r) {
995
- const n = new dt({
996
- mutationCache: this,
997
- mutationId: ++pe(this, de)._,
998
- options: e.defaultMutationOptions(t),
999
- state: r
1000
- });
1001
- return this.add(n), n;
1002
- }
1003
- add(e) {
1004
- i(this, H).add(e);
1005
- const t = me(e);
1006
- if (typeof t == "string") {
1007
- const r = i(this, R).get(t);
1008
- r ? r.push(e) : i(this, R).set(t, [e]);
1009
- }
1010
- this.notify({ type: "added", mutation: e });
1011
- }
1012
- remove(e) {
1013
- if (i(this, H).delete(e)) {
1014
- const t = me(e);
1015
- if (typeof t == "string") {
1016
- const r = i(this, R).get(t);
1017
- if (r)
1018
- if (r.length > 1) {
1019
- const n = r.indexOf(e);
1020
- n !== -1 && r.splice(n, 1);
1021
- } else r[0] === e && i(this, R).delete(t);
1022
- }
1023
- }
1024
- this.notify({ type: "removed", mutation: e });
1025
- }
1026
- canRun(e) {
1027
- const t = me(e);
1028
- if (typeof t == "string") {
1029
- const r = i(this, R).get(t), n = r == null ? void 0 : r.find(
1030
- (a) => a.state.status === "pending"
1031
- );
1032
- return !n || n === e;
1033
- } else
1034
- return !0;
1035
- }
1036
- runNext(e) {
1037
- var r;
1038
- const t = me(e);
1039
- if (typeof t == "string") {
1040
- const n = (r = i(this, R).get(t)) == null ? void 0 : r.find((a) => a !== e && a.state.isPaused);
1041
- return (n == null ? void 0 : n.continue()) ?? Promise.resolve();
1042
- } else
1043
- return Promise.resolve();
1044
- }
1045
- clear() {
1046
- C.batch(() => {
1047
- i(this, H).forEach((e) => {
1048
- this.notify({ type: "removed", mutation: e });
1049
- }), i(this, H).clear(), i(this, R).clear();
1050
- });
1051
- }
1052
- getAll() {
1053
- return Array.from(i(this, H));
1054
- }
1055
- find(e) {
1056
- const t = { exact: !0, ...e };
1057
- return this.getAll().find(
1058
- (r) => Qe(t, r)
1059
- );
1060
- }
1061
- findAll(e = {}) {
1062
- return this.getAll().filter((t) => Qe(e, t));
1063
- }
1064
- notify(e) {
1065
- C.batch(() => {
1066
- this.listeners.forEach((t) => {
1067
- t(e);
1068
- });
1069
- });
1070
- }
1071
- resumePausedMutations() {
1072
- const e = this.getAll().filter((t) => t.state.isPaused);
1073
- return C.batch(
1074
- () => Promise.all(
1075
- e.map((t) => t.continue().catch(T))
1076
- )
1077
- );
1078
- }
1079
- }, H = new WeakMap(), R = new WeakMap(), de = new WeakMap(), He);
1080
- function me(s) {
1081
- var e;
1082
- return (e = s.options.scope) == null ? void 0 : e.id;
1083
- }
1084
- function Me(s) {
1085
- return {
1086
- onFetch: (e, t) => {
1087
- var m, f, y, S, O;
1088
- const r = e.options, n = (y = (f = (m = e.fetchOptions) == null ? void 0 : m.meta) == null ? void 0 : f.fetchMore) == null ? void 0 : y.direction, a = ((S = e.state.data) == null ? void 0 : S.pages) || [], h = ((O = e.state.data) == null ? void 0 : O.pageParams) || [];
1089
- let u = { pages: [], pageParams: [] }, d = 0;
1090
- const g = async () => {
1091
- let c = !1;
1092
- const p = (w) => {
1093
- Object.defineProperty(w, "signal", {
1094
- enumerable: !0,
1095
- get: () => (e.signal.aborted ? c = !0 : e.signal.addEventListener("abort", () => {
1096
- c = !0;
1097
- }), e.signal)
1098
- });
1099
- }, A = Ge(e.options, e.fetchOptions), E = async (w, D, K) => {
1100
- if (c)
1101
- return Promise.reject();
1102
- if (D == null && w.pages.length)
1103
- return Promise.resolve(w);
1104
- const k = {
1105
- client: e.client,
1106
- queryKey: e.queryKey,
1107
- pageParam: D,
1108
- direction: K ? "backward" : "forward",
1109
- meta: e.options.meta
1110
- };
1111
- p(k);
1112
- const fe = await A(
1113
- k
1114
- ), { maxPages: he } = e.options, b = K ? tt : et;
1115
- return {
1116
- pages: b(w.pages, fe, he),
1117
- pageParams: b(w.pageParams, D, he)
1118
- };
1119
- };
1120
- if (n && a.length) {
1121
- const w = n === "backward", D = w ? pt : Re, K = {
1122
- pages: a,
1123
- pageParams: h
1124
- }, k = D(r, K);
1125
- u = await E(K, k, w);
1126
- } else {
1127
- const w = s ?? a.length;
1128
- do {
1129
- const D = d === 0 ? h[0] ?? r.initialPageParam : Re(r, u);
1130
- if (d > 0 && D == null)
1131
- break;
1132
- u = await E(u, D), d++;
1133
- } while (d < w);
1134
- }
1135
- return u;
1136
- };
1137
- e.options.persister ? e.fetchFn = () => {
1138
- var c, p;
1139
- return (p = (c = e.options).persister) == null ? void 0 : p.call(
1140
- c,
1141
- g,
1142
- {
1143
- client: e.client,
1144
- queryKey: e.queryKey,
1145
- meta: e.options.meta,
1146
- signal: e.signal
1147
- },
1148
- t
1149
- );
1150
- } : e.fetchFn = g;
1151
- }
1152
- };
1153
- }
1154
- function Re(s, { pages: e, pageParams: t }) {
1155
- const r = e.length - 1;
1156
- return e.length > 0 ? s.getNextPageParam(
1157
- e[r],
1158
- e,
1159
- t[r],
1160
- t
1161
- ) : void 0;
1162
- }
1163
- function pt(s, { pages: e, pageParams: t }) {
1164
- var r;
1165
- return e.length > 0 ? (r = s.getPreviousPageParam) == null ? void 0 : r.call(s, e[0], e, t[0], t) : void 0;
1166
- }
1167
- var v, V, $, ie, ne, z, ae, ue, xe, mt = (xe = class {
1168
- constructor(s = {}) {
1169
- l(this, v);
1170
- l(this, V);
1171
- l(this, $);
1172
- l(this, ie);
1173
- l(this, ne);
1174
- l(this, z);
1175
- l(this, ae);
1176
- l(this, ue);
1177
- o(this, v, s.queryCache || new lt()), o(this, V, s.mutationCache || new yt()), o(this, $, s.defaultOptions || {}), o(this, ie, /* @__PURE__ */ new Map()), o(this, ne, /* @__PURE__ */ new Map()), o(this, z, 0);
1178
- }
1179
- mount() {
1180
- pe(this, z)._++, i(this, z) === 1 && (o(this, ae, Ne.subscribe(async (s) => {
1181
- s && (await this.resumePausedMutations(), i(this, v).onFocus());
1182
- })), o(this, ue, we.subscribe(async (s) => {
1183
- s && (await this.resumePausedMutations(), i(this, v).onOnline());
1184
- })));
1185
- }
1186
- unmount() {
1187
- var s, e;
1188
- pe(this, z)._--, i(this, z) === 0 && ((s = i(this, ae)) == null || s.call(this), o(this, ae, void 0), (e = i(this, ue)) == null || e.call(this), o(this, ue, void 0));
1189
- }
1190
- isFetching(s) {
1191
- return i(this, v).findAll({ ...s, fetchStatus: "fetching" }).length;
1192
- }
1193
- isMutating(s) {
1194
- return i(this, V).findAll({ ...s, status: "pending" }).length;
1195
- }
1196
- /**
1197
- * Imperative (non-reactive) way to retrieve data for a QueryKey.
1198
- * Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.
1199
- *
1200
- * Hint: Do not use this function inside a component, because it won't receive updates.
1201
- * Use `useQuery` to create a `QueryObserver` that subscribes to changes.
1202
- */
1203
- getQueryData(s) {
1204
- var t;
1205
- const e = this.defaultQueryOptions({ queryKey: s });
1206
- return (t = i(this, v).get(e.queryHash)) == null ? void 0 : t.state.data;
1207
- }
1208
- ensureQueryData(s) {
1209
- const e = this.defaultQueryOptions(s), t = i(this, v).build(this, e), r = t.state.data;
1210
- return r === void 0 ? this.fetchQuery(s) : (s.revalidateIfStale && t.isStaleByTime(Ae(e.staleTime, t)) && this.prefetchQuery(e), Promise.resolve(r));
1211
- }
1212
- getQueriesData(s) {
1213
- return i(this, v).findAll(s).map(({ queryKey: e, state: t }) => {
1214
- const r = t.data;
1215
- return [e, r];
1216
- });
1217
- }
1218
- setQueryData(s, e, t) {
1219
- const r = this.defaultQueryOptions({ queryKey: s }), n = i(this, v).get(
1220
- r.queryHash
1221
- ), a = n == null ? void 0 : n.state.data, h = Je(e, a);
1222
- if (h !== void 0)
1223
- return i(this, v).build(this, r).setData(h, { ...t, manual: !0 });
1224
- }
1225
- setQueriesData(s, e, t) {
1226
- return C.batch(
1227
- () => i(this, v).findAll(s).map(({ queryKey: r }) => [
1228
- r,
1229
- this.setQueryData(r, e, t)
1230
- ])
1231
- );
1232
- }
1233
- getQueryState(s) {
1234
- var t;
1235
- const e = this.defaultQueryOptions({ queryKey: s });
1236
- return (t = i(this, v).get(
1237
- e.queryHash
1238
- )) == null ? void 0 : t.state;
1239
- }
1240
- removeQueries(s) {
1241
- const e = i(this, v);
1242
- C.batch(() => {
1243
- e.findAll(s).forEach((t) => {
1244
- e.remove(t);
1245
- });
1246
- });
1247
- }
1248
- resetQueries(s, e) {
1249
- const t = i(this, v);
1250
- return C.batch(() => (t.findAll(s).forEach((r) => {
1251
- r.reset();
1252
- }), this.refetchQueries(
1253
- {
1254
- type: "active",
1255
- ...s
1256
- },
1257
- e
1258
- )));
1259
- }
1260
- cancelQueries(s, e = {}) {
1261
- const t = { revert: !0, ...e }, r = C.batch(
1262
- () => i(this, v).findAll(s).map((n) => n.cancel(t))
1263
- );
1264
- return Promise.all(r).then(T).catch(T);
1265
- }
1266
- invalidateQueries(s, e = {}) {
1267
- return C.batch(() => (i(this, v).findAll(s).forEach((t) => {
1268
- t.invalidate();
1269
- }), (s == null ? void 0 : s.refetchType) === "none" ? Promise.resolve() : this.refetchQueries(
1270
- {
1271
- ...s,
1272
- type: (s == null ? void 0 : s.refetchType) ?? (s == null ? void 0 : s.type) ?? "active"
1273
- },
1274
- e
1275
- )));
1276
- }
1277
- refetchQueries(s, e = {}) {
1278
- const t = {
1279
- ...e,
1280
- cancelRefetch: e.cancelRefetch ?? !0
1281
- }, r = C.batch(
1282
- () => i(this, v).findAll(s).filter((n) => !n.isDisabled()).map((n) => {
1283
- let a = n.fetch(void 0, t);
1284
- return t.throwOnError || (a = a.catch(T)), n.state.fetchStatus === "paused" ? Promise.resolve() : a;
1285
- })
1286
- );
1287
- return Promise.all(r).then(T);
1288
- }
1289
- fetchQuery(s) {
1290
- const e = this.defaultQueryOptions(s);
1291
- e.retry === void 0 && (e.retry = !1);
1292
- const t = i(this, v).build(this, e);
1293
- return t.isStaleByTime(
1294
- Ae(e.staleTime, t)
1295
- ) ? t.fetch(e) : Promise.resolve(t.state.data);
1296
- }
1297
- prefetchQuery(s) {
1298
- return this.fetchQuery(s).then(T).catch(T);
1299
- }
1300
- fetchInfiniteQuery(s) {
1301
- return s.behavior = Me(s.pages), this.fetchQuery(s);
1302
- }
1303
- prefetchInfiniteQuery(s) {
1304
- return this.fetchInfiniteQuery(s).then(T).catch(T);
1305
- }
1306
- ensureInfiniteQueryData(s) {
1307
- return s.behavior = Me(s.pages), this.ensureQueryData(s);
1308
- }
1309
- resumePausedMutations() {
1310
- return we.isOnline() ? i(this, V).resumePausedMutations() : Promise.resolve();
1311
- }
1312
- getQueryCache() {
1313
- return i(this, v);
1314
- }
1315
- getMutationCache() {
1316
- return i(this, V);
1317
- }
1318
- getDefaultOptions() {
1319
- return i(this, $);
1320
- }
1321
- setDefaultOptions(s) {
1322
- o(this, $, s);
1323
- }
1324
- setQueryDefaults(s, e) {
1325
- i(this, ie).set(oe(s), {
1326
- queryKey: s,
1327
- defaultOptions: e
1328
- });
1329
- }
1330
- getQueryDefaults(s) {
1331
- const e = [...i(this, ie).values()], t = {};
1332
- return e.forEach((r) => {
1333
- ce(s, r.queryKey) && Object.assign(t, r.defaultOptions);
1334
- }), t;
1335
- }
1336
- setMutationDefaults(s, e) {
1337
- i(this, ne).set(oe(s), {
1338
- mutationKey: s,
1339
- defaultOptions: e
1340
- });
1341
- }
1342
- getMutationDefaults(s) {
1343
- const e = [...i(this, ne).values()], t = {};
1344
- return e.forEach((r) => {
1345
- ce(s, r.mutationKey) && Object.assign(t, r.defaultOptions);
1346
- }), t;
1347
- }
1348
- defaultQueryOptions(s) {
1349
- if (s._defaulted)
1350
- return s;
1351
- const e = {
1352
- ...i(this, $).queries,
1353
- ...this.getQueryDefaults(s.queryKey),
1354
- ...s,
1355
- _defaulted: !0
1356
- };
1357
- return e.queryHash || (e.queryHash = Ce(
1358
- e.queryKey,
1359
- e
1360
- )), e.refetchOnReconnect === void 0 && (e.refetchOnReconnect = e.networkMode !== "always"), e.throwOnError === void 0 && (e.throwOnError = !!e.suspense), !e.networkMode && e.persister && (e.networkMode = "offlineFirst"), e.queryFn === ve && (e.enabled = !1), e;
1361
- }
1362
- defaultMutationOptions(s) {
1363
- return s != null && s._defaulted ? s : {
1364
- ...i(this, $).mutations,
1365
- ...(s == null ? void 0 : s.mutationKey) && this.getMutationDefaults(s.mutationKey),
1366
- ...s,
1367
- _defaulted: !0
1368
- };
1369
- }
1370
- clear() {
1371
- i(this, v).clear(), i(this, V).clear();
1372
- }
1373
- }, v = new WeakMap(), V = new WeakMap(), $ = new WeakMap(), ie = new WeakMap(), ne = new WeakMap(), z = new WeakMap(), ae = new WeakMap(), ue = new WeakMap(), xe);
1374
- class B {
1375
- constructor(e = {}) {
1376
- this.apiUrl = e.apiUrl || "https://api.luzmo.com", this.apiVersion = e.apiVersion || "0.1.0", this.authKey = e.authKey || "", this.authToken = e.authToken || "", this.queryClient = new mt({
1377
- defaultOptions: {
1378
- queries: {
1379
- staleTime: e.staleTime || 5 * 60 * 1e3,
1380
- // 5 minutes
1381
- gcTime: e.gcTime || 10 * 60 * 1e3,
1382
- // 10 minutes
1383
- retry: e.retry || 3,
1384
- retryDelay: e.retryDelay || ((t) => Math.min(1e3 * 2 ** t, 3e4))
1385
- }
1386
- }
1387
- }), this.initNetworkListeners();
1388
- }
1389
- /**
1390
- * Set API configuration
1391
- * @param config - API configuration
1392
- */
1393
- configure(e = {}) {
1394
- if (e.apiVersion && (this.apiVersion = e.apiVersion), e.apiUrl && (this.apiUrl = e.apiUrl), e.authKey && (this.authKey = e.authKey), e.authToken && (this.authToken = e.authToken), e.staleTime || e.gcTime || e.retry) {
1395
- const t = {};
1396
- e.staleTime && (t.staleTime = e.staleTime), e.gcTime && (t.gcTime = e.gcTime), e.retry && (t.retry = e.retry), this.queryClient.setDefaultOptions({
1397
- queries: {
1398
- ...this.queryClient.getDefaultOptions().queries,
1399
- ...t
1400
- }
1401
- });
1402
- }
1403
- }
1404
- /**
1405
- * Initialize network status listeners
1406
- */
1407
- initNetworkListeners() {
1408
- typeof window < "u" && window.addEventListener("online", () => {
1409
- console.warn("Network connection restored, refreshing data..."), this.refreshAll();
1410
- });
1411
- }
1412
- /**
1413
- * Get API headers
1414
- * @param additionalHeaders - Additional headers to include
1415
- * @returns Headers for API requests
1416
- */
1417
- getHeaders(e = {}) {
1418
- return {
1419
- "Content-Type": "application/json",
1420
- ...e
1421
- };
1422
- }
1423
- /**
1424
- * Make API request with advanced error handling
1425
- * Default method is POST and supports an optional JSON body
1426
- * @param endpoint - API endpoint
1427
- * @param jsonBody - Optional JSON body to send with request
1428
- * @param options - Additional fetch options
1429
- * @returns API response
1430
- * @throws {Error} If API request fails
1431
- */
1432
- async fetchApi(e, t, r = {}) {
1433
- const n = `${this.apiUrl}/${this.apiVersion}${e}`, h = {
1434
- method: r.method || "POST",
1435
- headers: this.getHeaders(r.headers),
1436
- mode: "cors",
1437
- ...r
1438
- };
1439
- t !== void 0 && (t.key = this.authKey, t.token = this.authToken, h.body = JSON.stringify(t));
1440
- try {
1441
- const u = await fetch(n, h);
1442
- if (!u.ok) {
1443
- const d = await u.json().catch(() => null);
1444
- throw u.status === 401 || u.status === 403 ? new Error(
1445
- "Authentication failed. Please check your API token."
1446
- ) : u.status === 404 ? new Error(`Resource not found: ${e}`) : u.status === 429 ? new Error("Rate limit exceeded. Please try again later.") : new Error(
1447
- (d == null ? void 0 : d.message) || `API request failed with status ${u.status}`
1448
- );
1449
- }
1450
- return await u.json();
1451
- } catch (u) {
1452
- throw console.error(`API request to ${e} failed:`, u), u instanceof Error && (u.endpoint = e, u.timestamp = (/* @__PURE__ */ new Date()).toISOString()), u;
1453
- }
1454
- }
1455
- /**
1456
- * Fetch all available datasets with pagination support
1457
- * @param options - Pagination options
1458
- * @returns Paginated list of datasets
1459
- */
1460
- async fetchAllDatasets(e = {}) {
1461
- const t = e.offset || 0, r = e.limit || 50, n = ["datasets", t, r];
1462
- return await this.queryClient.fetchQuery({
1463
- queryKey: n,
1464
- queryFn: async () => {
1465
- const a = {
1466
- action: "get",
1467
- version: this.apiVersion,
1468
- find: {
1469
- where: {
1470
- type: "dataset"
1471
- },
1472
- limit: r,
1473
- offset: t
1474
- }
1475
- }, h = await this.fetchApi(
1476
- "/securable",
1477
- a
1478
- );
1479
- return {
1480
- data: (h == null ? void 0 : h.rows) || [],
1481
- pagination: {
1482
- offset: t,
1483
- limit: r,
1484
- total: (h == null ? void 0 : h.count) ?? 0,
1485
- pages: Math.ceil(((h == null ? void 0 : h.count) ?? 0) / r)
1486
- }
1487
- };
1488
- }
1489
- });
1490
- }
1491
- /**
1492
- * Search datasets by name or description
1493
- * @param query - Search query
1494
- * @returns List of matching datasets
1495
- */
1496
- async searchDatasets(e, t) {
1497
- if (!e) return [];
1498
- const r = ["datasets", "search", e, t];
1499
- return await this.queryClient.fetchQuery({
1500
- queryKey: r,
1501
- queryFn: async () => {
1502
- const n = {
1503
- action: "get",
1504
- version: this.apiVersion,
1505
- find: {
1506
- where: {
1507
- type: "dataset"
1508
- }
1509
- }
1510
- };
1511
- (e == null ? void 0 : e.length) > 0 && (n.find.search = {
1512
- match_types: ["name"],
1513
- keyphrase: e
1514
- }), t != null && t.offset && (n.find.offset = t == null ? void 0 : t.offset), t != null && t.limit && (n.find.limit = t == null ? void 0 : t.limit);
1515
- const a = await this.fetchApi(
1516
- "/securable",
1517
- n
1518
- ), h = {
1519
- data: (a == null ? void 0 : a.rows) || []
1520
- };
1521
- return t != null && t.limit && (h.pagination = {
1522
- offset: (t == null ? void 0 : t.offset) ?? 0,
1523
- limit: t == null ? void 0 : t.limit,
1524
- total: (a == null ? void 0 : a.count) ?? 0,
1525
- pages: Math.ceil(((a == null ? void 0 : a.count) ?? 0) / (t == null ? void 0 : t.limit))
1526
- }), h;
1527
- }
1528
- });
1529
- }
1530
- /**
1531
- * Fetch a specific dataset by ID
1532
- * @param datasetId - Dataset ID
1533
- * @returns Dataset details
1534
- */
1535
- async fetchDatasetsWithColumnsAndFormulas(e) {
1536
- if (!e || e.length === 0)
1537
- throw new Error("At least one dataset ID is required");
1538
- const t = ["datasets", e];
1539
- return await this.queryClient.fetchQuery({
1540
- queryKey: t,
1541
- queryFn: async () => {
1542
- const r = {
1543
- action: "get",
1544
- version: this.apiVersion,
1545
- find: {
1546
- where: {
1547
- type: "dataset",
1548
- id: {
1549
- in: e
1550
- }
1551
- },
1552
- attributes: ["name", "id"],
1553
- include: [
1554
- {
1555
- model: "Column",
1556
- attributes: [
1557
- "id",
1558
- "name",
1559
- "description",
1560
- "type",
1561
- "subtype",
1562
- "format",
1563
- "hidden",
1564
- "lowestLevel"
1565
- ]
1566
- },
1567
- {
1568
- model: "Formula",
1569
- attributes: [
1570
- "id",
1571
- "name",
1572
- "description",
1573
- "type",
1574
- "subtype",
1575
- "format",
1576
- "hidden",
1577
- "lowestLevel"
1578
- ]
1579
- }
1580
- ]
1581
- }
1582
- }, n = await this.fetchApi(
1583
- "/securable",
1584
- r
1585
- );
1586
- return (n == null ? void 0 : n.rows) || [];
1587
- }
1588
- });
1589
- }
1590
- /**
1591
- * Fetch a specific dataset by ID
1592
- * @param datasetId - Dataset ID
1593
- * @returns Dataset details
1594
- */
1595
- async fetchDataset(e) {
1596
- if (!e) throw new Error("Dataset ID is required");
1597
- const t = ["dataset", e];
1598
- return await this.queryClient.fetchQuery({
1599
- queryKey: t,
1600
- queryFn: async () => {
1601
- var a;
1602
- const r = {
1603
- action: "get",
1604
- version: this.apiVersion,
1605
- find: {
1606
- where: {
1607
- type: "dataset",
1608
- id: e
1609
- },
1610
- attributes: ["name", "id"],
1611
- include: [
1612
- {
1613
- model: "Column"
1614
- },
1615
- {
1616
- model: "Formula"
1617
- }
1618
- ]
1619
- }
1620
- }, n = await this.fetchApi(
1621
- "/securable",
1622
- r
1623
- );
1624
- return ((a = n == null ? void 0 : n.rows) == null ? void 0 : a[0]) || null;
1625
- }
1626
- });
1627
- }
1628
- /**
1629
- * Fetch data from a dataset with filtering
1630
- * @param datasetId - Dataset ID
1631
- * @param queryParams - Query parameters (filters, sort, etc.)
1632
- * @returns Dataset data
1633
- */
1634
- async fetchData(e) {
1635
- if (!e) throw new Error("Query is required");
1636
- const t = ["data", e];
1637
- return await this.queryClient.fetchQuery({
1638
- queryKey: t,
1639
- queryFn: async () => {
1640
- const r = {
1641
- action: "get",
1642
- version: this.apiVersion,
1643
- find: {
1644
- queries: [e]
1645
- }
1646
- }, n = await this.fetchApi("/data", r);
1647
- return {
1648
- data: (n == null ? void 0 : n.data) || [],
1649
- performance: (n == null ? void 0 : n.performance) || {}
1650
- };
1651
- }
1652
- });
1653
- }
1654
- /**
1655
- * Refresh all queries
1656
- */
1657
- refreshAll() {
1658
- this.queryClient.refetchQueries();
1659
- }
1660
- /**
1661
- * Invalidate cached data for a dataset
1662
- * @param datasetId - Dataset ID (optional)
1663
- */
1664
- invalidateDatasetData(e) {
1665
- e ? (this.queryClient.invalidateQueries({ queryKey: ["dataset", e] }), this.queryClient.invalidateQueries({ queryKey: ["columns", e] })) : this.queryClient.invalidateQueries({ queryKey: ["datasets"] });
1666
- }
1667
- /**
1668
- * Invalidate all cached data
1669
- */
1670
- invalidateAll() {
1671
- this.queryClient.clear();
1672
- }
1673
- /**
1674
- * Create a singleton instance
1675
- * @param config - API configuration
1676
- * @returns Singleton instance
1677
- */
1678
- static getInstance(e = {}) {
1679
- return B.instance ? Object.keys(e).length > 0 && B.instance.configure(e) : B.instance = new B(e), B.instance;
1680
- }
1681
- }
1682
- const wt = B.getInstance();
1683
- export {
1684
- wt as d
1685
- };