zudoku 0.30.1 → 0.31.1

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 (71) hide show
  1. package/dist/config/loader.js +4 -1
  2. package/dist/config/loader.js.map +1 -1
  3. package/dist/config/validators/common.d.ts +97 -12
  4. package/dist/config/validators/common.js +16 -1
  5. package/dist/config/validators/common.js.map +1 -1
  6. package/dist/config/validators/validate.d.ts +33 -6
  7. package/dist/lib/components/ThemeSwitch.js +8 -5
  8. package/dist/lib/components/ThemeSwitch.js.map +1 -1
  9. package/dist/lib/components/context/ZudokuContext.js +8 -2
  10. package/dist/lib/components/context/ZudokuContext.js.map +1 -1
  11. package/dist/lib/core/RouteGuard.js +6 -2
  12. package/dist/lib/core/RouteGuard.js.map +1 -1
  13. package/dist/lib/oas/parser/upgrade/index.js +2 -1
  14. package/dist/lib/oas/parser/upgrade/index.js.map +1 -1
  15. package/dist/lib/util/useLatest.d.ts +1 -0
  16. package/dist/lib/util/useLatest.js +15 -0
  17. package/dist/lib/util/useLatest.js.map +1 -0
  18. package/dist/vite/api/schema-codegen.js +2 -2
  19. package/dist/vite/api/schema-codegen.js.map +1 -1
  20. package/dist/vite/config.js +25 -12
  21. package/dist/vite/config.js.map +1 -1
  22. package/dist/vite/plugin-api.js +26 -10
  23. package/dist/vite/plugin-api.js.map +1 -1
  24. package/dist/vite/plugin-mdx.js +31 -26
  25. package/dist/vite/plugin-mdx.js.map +1 -1
  26. package/dist/vite/prerender/worker.js +2 -1
  27. package/dist/vite/prerender/worker.js.map +1 -1
  28. package/lib/{AuthenticationPlugin-DeEA69mE.js → AuthenticationPlugin-DjnQ5hs7.js} +2 -2
  29. package/lib/{AuthenticationPlugin-DeEA69mE.js.map → AuthenticationPlugin-DjnQ5hs7.js.map} +1 -1
  30. package/lib/{MdxPage-BalfwlsD.js → MdxPage-ZX2oquWw.js} +3 -3
  31. package/lib/{MdxPage-BalfwlsD.js.map → MdxPage-ZX2oquWw.js.map} +1 -1
  32. package/lib/{OpenApiRoute-ULLXjfro.js → OpenApiRoute-BP9kzG5k.js} +2 -2
  33. package/lib/{OpenApiRoute-ULLXjfro.js.map → OpenApiRoute-BP9kzG5k.js.map} +1 -1
  34. package/lib/{OperationList-CnYOgwBj.js → OperationList-c72qPMtm.js} +6 -7
  35. package/lib/{OperationList-CnYOgwBj.js.map → OperationList-c72qPMtm.js.map} +1 -1
  36. package/lib/{Select-BcAbBUmk.js → Select-NSz0gku6.js} +3 -3
  37. package/lib/{Select-BcAbBUmk.js.map → Select-NSz0gku6.js.map} +1 -1
  38. package/lib/{createServer-E3cXjB0P.js → createServer-ZDNGmPfQ.js} +2 -2
  39. package/lib/{createServer-E3cXjB0P.js.map → createServer-ZDNGmPfQ.js.map} +1 -1
  40. package/lib/hook-Dnj3SwPC.js +1455 -0
  41. package/lib/hook-Dnj3SwPC.js.map +1 -0
  42. package/lib/{index-CnKeVT2S.js → index-CZjcfK-H.js} +28 -30
  43. package/lib/{index-CnKeVT2S.js.map → index-CZjcfK-H.js.map} +1 -1
  44. package/lib/{hook-NIpDSpau.js → mutation-ByGtmi0-.js} +46 -65
  45. package/lib/mutation-ByGtmi0-.js.map +1 -0
  46. package/lib/{useScrollToAnchor-BVCQSeKB.js → useScrollToAnchor-DkVfWsxe.js} +2 -2
  47. package/lib/{useScrollToAnchor-BVCQSeKB.js.map → useScrollToAnchor-DkVfWsxe.js.map} +1 -1
  48. package/lib/zudoku.auth-auth0.js +1 -1
  49. package/lib/zudoku.auth-clerk.js +2 -2
  50. package/lib/zudoku.auth-openid.js +4 -5
  51. package/lib/zudoku.auth-openid.js.map +1 -1
  52. package/lib/zudoku.components.js +519 -489
  53. package/lib/zudoku.components.js.map +1 -1
  54. package/lib/zudoku.plugin-api-catalog.js +15 -16
  55. package/lib/zudoku.plugin-api-catalog.js.map +1 -1
  56. package/lib/zudoku.plugin-api-keys.js +12 -13
  57. package/lib/zudoku.plugin-api-keys.js.map +1 -1
  58. package/lib/zudoku.plugin-markdown.js +1 -1
  59. package/lib/zudoku.plugin-openapi.js +2 -2
  60. package/package.json +3 -1
  61. package/src/app/main.css +2 -1
  62. package/src/lib/components/ThemeSwitch.tsx +28 -8
  63. package/src/lib/components/context/ZudokuContext.ts +13 -2
  64. package/src/lib/core/RouteGuard.tsx +6 -2
  65. package/src/lib/oas/parser/upgrade/index.ts +2 -1
  66. package/src/lib/util/useLatest.ts +18 -0
  67. package/lib/ZudokuContext-dUyBGMap.js +0 -1229
  68. package/lib/ZudokuContext-dUyBGMap.js.map +0 -1
  69. package/lib/hook-NIpDSpau.js.map +0 -1
  70. package/lib/state-bfQxaDxU.js +0 -211
  71. package/lib/state-bfQxaDxU.js.map +0 -1
@@ -1,1229 +0,0 @@
1
- var Ke = (t) => {
2
- throw TypeError(t);
3
- };
4
- var me = (t, e, s) => e.has(t) || Ke("Cannot " + s);
5
- var n = (t, e, s) => (me(t, e, "read from private field"), s ? s.call(t) : e.get(t)), f = (t, e, s) => e.has(t) ? Ke("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, s), h = (t, e, s, r) => (me(t, e, "write to private field"), r ? r.call(t, s) : e.set(t, s), s), m = (t, e, s) => (me(t, e, "access private method"), s);
6
- import * as T from "react";
7
- import { createContext as pt, useContext as bt } from "react";
8
- import { j as mt } from "./jsx-runtime-Bdg6XQ1m.js";
9
- import { u as pe, m as vt } from "./chunk-SYFQ2XB5-QijJrSf0.js";
10
- var Ae = class {
11
- constructor() {
12
- this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
13
- }
14
- subscribe(t) {
15
- return this.listeners.add(t), this.onSubscribe(), () => {
16
- this.listeners.delete(t), this.onUnsubscribe();
17
- };
18
- }
19
- hasListeners() {
20
- return this.listeners.size > 0;
21
- }
22
- onSubscribe() {
23
- }
24
- onUnsubscribe() {
25
- }
26
- }, V = typeof window > "u" || "Deno" in globalThis;
27
- function ge() {
28
- }
29
- function Wt(t, e) {
30
- return typeof t == "function" ? t(e) : t;
31
- }
32
- function Se(t) {
33
- return typeof t == "number" && t >= 0 && t !== 1 / 0;
34
- }
35
- function et(t, e) {
36
- return Math.max(t + (e || 0) - Date.now(), 0);
37
- }
38
- function fe(t, e) {
39
- return typeof t == "function" ? t(e) : t;
40
- }
41
- function x(t, e) {
42
- return typeof t == "function" ? t(e) : t;
43
- }
44
- function Jt(t, e) {
45
- const {
46
- type: s = "all",
47
- exact: r,
48
- fetchStatus: i,
49
- predicate: o,
50
- queryKey: a,
51
- stale: u
52
- } = t;
53
- if (a) {
54
- if (r) {
55
- if (e.queryHash !== gt(a, e.options))
56
- return !1;
57
- } else if (!Qe(e.queryKey, a))
58
- return !1;
59
- }
60
- if (s !== "all") {
61
- const l = e.isActive();
62
- if (s === "active" && !l || s === "inactive" && l)
63
- return !1;
64
- }
65
- return !(typeof u == "boolean" && e.isStale() !== u || i && i !== e.state.fetchStatus || o && !o(e));
66
- }
67
- function Yt(t, e) {
68
- const { exact: s, status: r, predicate: i, mutationKey: o } = t;
69
- if (o) {
70
- if (!e.options.mutationKey)
71
- return !1;
72
- if (s) {
73
- if (Ce(e.options.mutationKey) !== Ce(o))
74
- return !1;
75
- } else if (!Qe(e.options.mutationKey, o))
76
- return !1;
77
- }
78
- return !(r && e.state.status !== r || i && !i(e));
79
- }
80
- function gt(t, e) {
81
- return ((e == null ? void 0 : e.queryKeyHashFn) || Ce)(t);
82
- }
83
- function Ce(t) {
84
- return JSON.stringify(
85
- t,
86
- (e, s) => Ee(s) ? Object.keys(s).sort().reduce((r, i) => (r[i] = s[i], r), {}) : s
87
- );
88
- }
89
- function Qe(t, e) {
90
- return t === e ? !0 : typeof t != typeof e ? !1 : t && e && typeof t == "object" && typeof e == "object" ? !Object.keys(e).some((s) => !Qe(t[s], e[s])) : !1;
91
- }
92
- function Re(t, e) {
93
- if (t === e)
94
- return t;
95
- const s = He(t) && He(e);
96
- if (s || Ee(t) && Ee(e)) {
97
- const r = s ? t : Object.keys(t), i = r.length, o = s ? e : Object.keys(e), a = o.length, u = s ? [] : {};
98
- let l = 0;
99
- for (let S = 0; S < a; S++) {
100
- const v = s ? S : o[S];
101
- (!s && r.includes(v) || s) && t[v] === void 0 && e[v] === void 0 ? (u[v] = void 0, l++) : (u[v] = Re(t[v], e[v]), u[v] === t[v] && t[v] !== void 0 && l++);
102
- }
103
- return i === a && l === i ? t : u;
104
- }
105
- return e;
106
- }
107
- function we(t, e) {
108
- if (!e || Object.keys(t).length !== Object.keys(e).length)
109
- return !1;
110
- for (const s in t)
111
- if (t[s] !== e[s])
112
- return !1;
113
- return !0;
114
- }
115
- function He(t) {
116
- return Array.isArray(t) && t.length === Object.keys(t).length;
117
- }
118
- function Ee(t) {
119
- if (!Be(t))
120
- return !1;
121
- const e = t.constructor;
122
- if (e === void 0)
123
- return !0;
124
- const s = e.prototype;
125
- return !(!Be(s) || !s.hasOwnProperty("isPrototypeOf") || Object.getPrototypeOf(t) !== Object.prototype);
126
- }
127
- function Be(t) {
128
- return Object.prototype.toString.call(t) === "[object Object]";
129
- }
130
- function St(t) {
131
- return new Promise((e) => {
132
- setTimeout(e, t);
133
- });
134
- }
135
- function Oe(t, e, s) {
136
- if (typeof s.structuralSharing == "function")
137
- return s.structuralSharing(t, e);
138
- if (s.structuralSharing !== !1) {
139
- if (process.env.NODE_ENV !== "production")
140
- try {
141
- return Re(t, e);
142
- } catch (r) {
143
- console.error(
144
- `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${s.queryHash}]: ${r}`
145
- );
146
- }
147
- return Re(t, e);
148
- }
149
- return e;
150
- }
151
- function Xt(t, e, s = 0) {
152
- const r = [...t, e];
153
- return s && r.length > s ? r.slice(1) : r;
154
- }
155
- function es(t, e, s = 0) {
156
- const r = [e, ...t];
157
- return s && r.length > s ? r.slice(0, -1) : r;
158
- }
159
- var ye = Symbol();
160
- function Ct(t, e) {
161
- return process.env.NODE_ENV !== "production" && t.queryFn === ye && console.error(
162
- `Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${t.queryHash}'`
163
- ), !t.queryFn && (e != null && e.initialPromise) ? () => e.initialPromise : !t.queryFn || t.queryFn === ye ? () => Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)) : t.queryFn;
164
- }
165
- var _, Q, J, Ze, Rt = (Ze = class extends Ae {
166
- constructor() {
167
- super();
168
- f(this, _);
169
- f(this, Q);
170
- f(this, J);
171
- h(this, J, (e) => {
172
- if (!V && window.addEventListener) {
173
- const s = () => e();
174
- return window.addEventListener("visibilitychange", s, !1), () => {
175
- window.removeEventListener("visibilitychange", s);
176
- };
177
- }
178
- });
179
- }
180
- onSubscribe() {
181
- n(this, Q) || this.setEventListener(n(this, J));
182
- }
183
- onUnsubscribe() {
184
- var e;
185
- this.hasListeners() || ((e = n(this, Q)) == null || e.call(this), h(this, Q, void 0));
186
- }
187
- setEventListener(e) {
188
- var s;
189
- h(this, J, e), (s = n(this, Q)) == null || s.call(this), h(this, Q, e((r) => {
190
- typeof r == "boolean" ? this.setFocused(r) : this.onFocus();
191
- }));
192
- }
193
- setFocused(e) {
194
- n(this, _) !== e && (h(this, _, e), this.onFocus());
195
- }
196
- onFocus() {
197
- const e = this.isFocused();
198
- this.listeners.forEach((s) => {
199
- s(e);
200
- });
201
- }
202
- isFocused() {
203
- var e;
204
- return typeof n(this, _) == "boolean" ? n(this, _) : ((e = globalThis.document) == null ? void 0 : e.visibilityState) !== "hidden";
205
- }
206
- }, _ = new WeakMap(), Q = new WeakMap(), J = new WeakMap(), Ze), tt = new Rt(), Y, U, X, We, wt = (We = class extends Ae {
207
- constructor() {
208
- super();
209
- f(this, Y, !0);
210
- f(this, U);
211
- f(this, X);
212
- h(this, X, (e) => {
213
- if (!V && window.addEventListener) {
214
- const s = () => e(!0), r = () => e(!1);
215
- return window.addEventListener("online", s, !1), window.addEventListener("offline", r, !1), () => {
216
- window.removeEventListener("online", s), window.removeEventListener("offline", r);
217
- };
218
- }
219
- });
220
- }
221
- onSubscribe() {
222
- n(this, U) || this.setEventListener(n(this, X));
223
- }
224
- onUnsubscribe() {
225
- var e;
226
- this.hasListeners() || ((e = n(this, U)) == null || e.call(this), h(this, U, void 0));
227
- }
228
- setEventListener(e) {
229
- var s;
230
- h(this, X, e), (s = n(this, U)) == null || s.call(this), h(this, U, e(this.setOnline.bind(this)));
231
- }
232
- setOnline(e) {
233
- n(this, Y) !== e && (h(this, Y, e), this.listeners.forEach((r) => {
234
- r(e);
235
- }));
236
- }
237
- isOnline() {
238
- return n(this, Y);
239
- }
240
- }, Y = new WeakMap(), U = new WeakMap(), X = new WeakMap(), We), st = new wt();
241
- function Fe() {
242
- let t, e;
243
- const s = new Promise((i, o) => {
244
- t = i, e = o;
245
- });
246
- s.status = "pending", s.catch(() => {
247
- });
248
- function r(i) {
249
- Object.assign(s, i), delete s.resolve, delete s.reject;
250
- }
251
- return s.resolve = (i) => {
252
- r({
253
- status: "fulfilled",
254
- value: i
255
- }), t(i);
256
- }, s.reject = (i) => {
257
- r({
258
- status: "rejected",
259
- reason: i
260
- }), e(i);
261
- }, s;
262
- }
263
- function Et(t) {
264
- return Math.min(1e3 * 2 ** t, 3e4);
265
- }
266
- function rt(t) {
267
- return (t ?? "online") === "online" ? st.isOnline() : !0;
268
- }
269
- var nt = class extends Error {
270
- constructor(t) {
271
- super("CancelledError"), this.revert = t == null ? void 0 : t.revert, this.silent = t == null ? void 0 : t.silent;
272
- }
273
- };
274
- function ve(t) {
275
- return t instanceof nt;
276
- }
277
- function Ot(t) {
278
- let e = !1, s = 0, r = !1, i;
279
- const o = Fe(), a = (b) => {
280
- var p;
281
- r || (C(new nt(b)), (p = t.abort) == null || p.call(t));
282
- }, u = () => {
283
- e = !0;
284
- }, l = () => {
285
- e = !1;
286
- }, S = () => tt.isFocused() && (t.networkMode === "always" || st.isOnline()) && t.canRun(), v = () => rt(t.networkMode) && t.canRun(), c = (b) => {
287
- var p;
288
- r || (r = !0, (p = t.onSuccess) == null || p.call(t, b), i == null || i(), o.resolve(b));
289
- }, C = (b) => {
290
- var p;
291
- r || (r = !0, (p = t.onError) == null || p.call(t, b), i == null || i(), o.reject(b));
292
- }, g = () => new Promise((b) => {
293
- var p;
294
- i = (E) => {
295
- (r || S()) && b(E);
296
- }, (p = t.onPause) == null || p.call(t);
297
- }).then(() => {
298
- var b;
299
- i = void 0, r || (b = t.onContinue) == null || b.call(t);
300
- }), w = () => {
301
- if (r)
302
- return;
303
- let b;
304
- const p = s === 0 ? t.initialPromise : void 0;
305
- try {
306
- b = p ?? t.fn();
307
- } catch (E) {
308
- b = Promise.reject(E);
309
- }
310
- Promise.resolve(b).then(c).catch((E) => {
311
- var be;
312
- if (r)
313
- return;
314
- const q = t.retry ?? (V ? 0 : 3), N = t.retryDelay ?? Et, he = typeof N == "function" ? N(s, E) : N, le = q === !0 || typeof q == "number" && s < q || typeof q == "function" && q(s, E);
315
- if (e || !le) {
316
- C(E);
317
- return;
318
- }
319
- s++, (be = t.onFail) == null || be.call(t, s, E), St(he).then(() => S() ? void 0 : g()).then(() => {
320
- e ? C(E) : w();
321
- });
322
- });
323
- };
324
- return {
325
- promise: o,
326
- cancel: a,
327
- continue: () => (i == null || i(), o),
328
- cancelRetry: u,
329
- continueRetry: l,
330
- canStart: v,
331
- start: () => (v() ? w() : g().then(w), o)
332
- };
333
- }
334
- function Ft() {
335
- let t = [], e = 0, s = (u) => {
336
- u();
337
- }, r = (u) => {
338
- u();
339
- }, i = (u) => setTimeout(u, 0);
340
- const o = (u) => {
341
- e ? t.push(u) : i(() => {
342
- s(u);
343
- });
344
- }, a = () => {
345
- const u = t;
346
- t = [], u.length && i(() => {
347
- r(() => {
348
- u.forEach((l) => {
349
- s(l);
350
- });
351
- });
352
- });
353
- };
354
- return {
355
- batch: (u) => {
356
- let l;
357
- e++;
358
- try {
359
- l = u();
360
- } finally {
361
- e--, e || a();
362
- }
363
- return l;
364
- },
365
- /**
366
- * All calls to the wrapped function will be batched.
367
- */
368
- batchCalls: (u) => (...l) => {
369
- o(() => {
370
- u(...l);
371
- });
372
- },
373
- schedule: o,
374
- /**
375
- * Use this method to set a custom notify function.
376
- * This can be used to for example wrap notifications with `React.act` while running tests.
377
- */
378
- setNotifyFunction: (u) => {
379
- s = u;
380
- },
381
- /**
382
- * Use this method to set a custom function to batch notifications together into a single tick.
383
- * By default React Query will use the batch function provided by ReactDOM or React Native.
384
- */
385
- setBatchNotifyFunction: (u) => {
386
- r = u;
387
- },
388
- setScheduler: (u) => {
389
- i = u;
390
- }
391
- };
392
- }
393
- var Ue = Ft(), K, Je, It = (Je = class {
394
- constructor() {
395
- f(this, K);
396
- }
397
- destroy() {
398
- this.clearGcTimeout();
399
- }
400
- scheduleGc() {
401
- this.clearGcTimeout(), Se(this.gcTime) && h(this, K, setTimeout(() => {
402
- this.optionalRemove();
403
- }, this.gcTime));
404
- }
405
- updateGcTime(t) {
406
- this.gcTime = Math.max(
407
- this.gcTime || 0,
408
- t ?? (V ? 1 / 0 : 5 * 60 * 1e3)
409
- );
410
- }
411
- clearGcTimeout() {
412
- n(this, K) && (clearTimeout(n(this, K)), h(this, K, void 0));
413
- }
414
- }, K = new WeakMap(), Je), ee, te, P, R, ue, H, D, A, Ye, ts = (Ye = class extends It {
415
- constructor(e) {
416
- super();
417
- f(this, D);
418
- f(this, ee);
419
- f(this, te);
420
- f(this, P);
421
- f(this, R);
422
- f(this, ue);
423
- f(this, H);
424
- h(this, H, !1), h(this, ue, e.defaultOptions), this.setOptions(e.options), this.observers = [], h(this, P, e.cache), this.queryKey = e.queryKey, this.queryHash = e.queryHash, h(this, ee, Pt(this.options)), this.state = e.state ?? n(this, ee), this.scheduleGc();
425
- }
426
- get meta() {
427
- return this.options.meta;
428
- }
429
- get promise() {
430
- var e;
431
- return (e = n(this, R)) == null ? void 0 : e.promise;
432
- }
433
- setOptions(e) {
434
- this.options = { ...n(this, ue), ...e }, this.updateGcTime(this.options.gcTime);
435
- }
436
- optionalRemove() {
437
- !this.observers.length && this.state.fetchStatus === "idle" && n(this, P).remove(this);
438
- }
439
- setData(e, s) {
440
- const r = Oe(this.state.data, e, this.options);
441
- return m(this, D, A).call(this, {
442
- data: r,
443
- type: "success",
444
- dataUpdatedAt: s == null ? void 0 : s.updatedAt,
445
- manual: s == null ? void 0 : s.manual
446
- }), r;
447
- }
448
- setState(e, s) {
449
- m(this, D, A).call(this, { type: "setState", state: e, setStateOptions: s });
450
- }
451
- cancel(e) {
452
- var r, i;
453
- const s = (r = n(this, R)) == null ? void 0 : r.promise;
454
- return (i = n(this, R)) == null || i.cancel(e), s ? s.then(ge).catch(ge) : Promise.resolve();
455
- }
456
- destroy() {
457
- super.destroy(), this.cancel({ silent: !0 });
458
- }
459
- reset() {
460
- this.destroy(), this.setState(n(this, ee));
461
- }
462
- isActive() {
463
- return this.observers.some(
464
- (e) => x(e.options.enabled, this) !== !1
465
- );
466
- }
467
- isDisabled() {
468
- return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === ye || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
469
- }
470
- isStale() {
471
- return this.state.isInvalidated ? !0 : this.getObserversCount() > 0 ? this.observers.some(
472
- (e) => e.getCurrentResult().isStale
473
- ) : this.state.data === void 0;
474
- }
475
- isStaleByTime(e = 0) {
476
- return this.state.isInvalidated || this.state.data === void 0 || !et(this.state.dataUpdatedAt, e);
477
- }
478
- onFocus() {
479
- var s;
480
- const e = this.observers.find((r) => r.shouldFetchOnWindowFocus());
481
- e == null || e.refetch({ cancelRefetch: !1 }), (s = n(this, R)) == null || s.continue();
482
- }
483
- onOnline() {
484
- var s;
485
- const e = this.observers.find((r) => r.shouldFetchOnReconnect());
486
- e == null || e.refetch({ cancelRefetch: !1 }), (s = n(this, R)) == null || s.continue();
487
- }
488
- addObserver(e) {
489
- this.observers.includes(e) || (this.observers.push(e), this.clearGcTimeout(), n(this, P).notify({ type: "observerAdded", query: this, observer: e }));
490
- }
491
- removeObserver(e) {
492
- this.observers.includes(e) && (this.observers = this.observers.filter((s) => s !== e), this.observers.length || (n(this, R) && (n(this, H) ? n(this, R).cancel({ revert: !0 }) : n(this, R).cancelRetry()), this.scheduleGc()), n(this, P).notify({ type: "observerRemoved", query: this, observer: e }));
493
- }
494
- getObserversCount() {
495
- return this.observers.length;
496
- }
497
- invalidate() {
498
- this.state.isInvalidated || m(this, D, A).call(this, { type: "invalidate" });
499
- }
500
- fetch(e, s) {
501
- var l, S, v;
502
- if (this.state.fetchStatus !== "idle") {
503
- if (this.state.data !== void 0 && (s != null && s.cancelRefetch))
504
- this.cancel({ silent: !0 });
505
- else if (n(this, R))
506
- return n(this, R).continueRetry(), n(this, R).promise;
507
- }
508
- if (e && this.setOptions(e), !this.options.queryFn) {
509
- const c = this.observers.find((C) => C.options.queryFn);
510
- c && this.setOptions(c.options);
511
- }
512
- process.env.NODE_ENV !== "production" && (Array.isArray(this.options.queryKey) || console.error(
513
- "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']"
514
- ));
515
- const r = new AbortController(), i = (c) => {
516
- Object.defineProperty(c, "signal", {
517
- enumerable: !0,
518
- get: () => (h(this, H, !0), r.signal)
519
- });
520
- }, o = () => {
521
- const c = Ct(this.options, s), C = {
522
- queryKey: this.queryKey,
523
- meta: this.meta
524
- };
525
- return i(C), h(this, H, !1), this.options.persister ? this.options.persister(
526
- c,
527
- C,
528
- this
529
- ) : c(C);
530
- }, a = {
531
- fetchOptions: s,
532
- options: this.options,
533
- queryKey: this.queryKey,
534
- state: this.state,
535
- fetchFn: o
536
- };
537
- i(a), (l = this.options.behavior) == null || l.onFetch(
538
- a,
539
- this
540
- ), h(this, te, this.state), (this.state.fetchStatus === "idle" || this.state.fetchMeta !== ((S = a.fetchOptions) == null ? void 0 : S.meta)) && m(this, D, A).call(this, { type: "fetch", meta: (v = a.fetchOptions) == null ? void 0 : v.meta });
541
- const u = (c) => {
542
- var C, g, w, b;
543
- ve(c) && c.silent || m(this, D, A).call(this, {
544
- type: "error",
545
- error: c
546
- }), ve(c) || ((g = (C = n(this, P).config).onError) == null || g.call(
547
- C,
548
- c,
549
- this
550
- ), (b = (w = n(this, P).config).onSettled) == null || b.call(
551
- w,
552
- this.state.data,
553
- c,
554
- this
555
- )), this.scheduleGc();
556
- };
557
- return h(this, R, Ot({
558
- initialPromise: s == null ? void 0 : s.initialPromise,
559
- fn: a.fetchFn,
560
- abort: r.abort.bind(r),
561
- onSuccess: (c) => {
562
- var C, g, w, b;
563
- if (c === void 0) {
564
- process.env.NODE_ENV !== "production" && console.error(
565
- `Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
566
- ), u(new Error(`${this.queryHash} data is undefined`));
567
- return;
568
- }
569
- try {
570
- this.setData(c);
571
- } catch (p) {
572
- u(p);
573
- return;
574
- }
575
- (g = (C = n(this, P).config).onSuccess) == null || g.call(C, c, this), (b = (w = n(this, P).config).onSettled) == null || b.call(
576
- w,
577
- c,
578
- this.state.error,
579
- this
580
- ), this.scheduleGc();
581
- },
582
- onError: u,
583
- onFail: (c, C) => {
584
- m(this, D, A).call(this, { type: "failed", failureCount: c, error: C });
585
- },
586
- onPause: () => {
587
- m(this, D, A).call(this, { type: "pause" });
588
- },
589
- onContinue: () => {
590
- m(this, D, A).call(this, { type: "continue" });
591
- },
592
- retry: a.options.retry,
593
- retryDelay: a.options.retryDelay,
594
- networkMode: a.options.networkMode,
595
- canRun: () => !0
596
- })), n(this, R).start();
597
- }
598
- }, ee = new WeakMap(), te = new WeakMap(), P = new WeakMap(), R = new WeakMap(), ue = new WeakMap(), H = new WeakMap(), D = new WeakSet(), A = function(e) {
599
- const s = (r) => {
600
- switch (e.type) {
601
- case "failed":
602
- return {
603
- ...r,
604
- fetchFailureCount: e.failureCount,
605
- fetchFailureReason: e.error
606
- };
607
- case "pause":
608
- return {
609
- ...r,
610
- fetchStatus: "paused"
611
- };
612
- case "continue":
613
- return {
614
- ...r,
615
- fetchStatus: "fetching"
616
- };
617
- case "fetch":
618
- return {
619
- ...r,
620
- ...it(r.data, this.options),
621
- fetchMeta: e.meta ?? null
622
- };
623
- case "success":
624
- return {
625
- ...r,
626
- data: e.data,
627
- dataUpdateCount: r.dataUpdateCount + 1,
628
- dataUpdatedAt: e.dataUpdatedAt ?? Date.now(),
629
- error: null,
630
- isInvalidated: !1,
631
- status: "success",
632
- ...!e.manual && {
633
- fetchStatus: "idle",
634
- fetchFailureCount: 0,
635
- fetchFailureReason: null
636
- }
637
- };
638
- case "error":
639
- const i = e.error;
640
- return ve(i) && i.revert && n(this, te) ? { ...n(this, te), fetchStatus: "idle" } : {
641
- ...r,
642
- error: i,
643
- errorUpdateCount: r.errorUpdateCount + 1,
644
- errorUpdatedAt: Date.now(),
645
- fetchFailureCount: r.fetchFailureCount + 1,
646
- fetchFailureReason: i,
647
- fetchStatus: "idle",
648
- status: "error"
649
- };
650
- case "invalidate":
651
- return {
652
- ...r,
653
- isInvalidated: !0
654
- };
655
- case "setState":
656
- return {
657
- ...r,
658
- ...e.state
659
- };
660
- }
661
- };
662
- this.state = s(this.state), Ue.batch(() => {
663
- this.observers.forEach((r) => {
664
- r.onQueryUpdate();
665
- }), n(this, P).notify({ query: this, type: "updated", action: e });
666
- });
667
- }, Ye);
668
- function it(t, e) {
669
- return {
670
- fetchFailureCount: 0,
671
- fetchFailureReason: null,
672
- fetchStatus: rt(e.networkMode) ? "fetching" : "paused",
673
- ...t === void 0 && {
674
- error: null,
675
- status: "pending"
676
- }
677
- };
678
- }
679
- function Pt(t) {
680
- const e = typeof t.initialData == "function" ? t.initialData() : t.initialData, s = e !== void 0, r = s ? typeof t.initialDataUpdatedAt == "function" ? t.initialDataUpdatedAt() : t.initialDataUpdatedAt : 0;
681
- return {
682
- data: e,
683
- dataUpdateCount: 0,
684
- dataUpdatedAt: s ? r ?? Date.now() : 0,
685
- error: null,
686
- errorUpdateCount: 0,
687
- errorUpdatedAt: 0,
688
- fetchFailureCount: 0,
689
- fetchFailureReason: null,
690
- fetchMeta: null,
691
- isInvalidated: !1,
692
- status: s ? "success" : "pending",
693
- fetchStatus: "idle"
694
- };
695
- }
696
- var I, d, oe, F, B, se, M, k, ce, re, ne, G, z, L, ie, y, ae, Ie, Pe, Te, De, xe, je, ke, ut, Xe, at = (Xe = class extends Ae {
697
- constructor(e, s) {
698
- super();
699
- f(this, y);
700
- f(this, I);
701
- f(this, d);
702
- f(this, oe);
703
- f(this, F);
704
- f(this, B);
705
- f(this, se);
706
- f(this, M);
707
- f(this, k);
708
- f(this, ce);
709
- f(this, re);
710
- // This property keeps track of the last query with defined data.
711
- // It will be used to pass the previous data and query to the placeholder function between renders.
712
- f(this, ne);
713
- f(this, G);
714
- f(this, z);
715
- f(this, L);
716
- f(this, ie, /* @__PURE__ */ new Set());
717
- this.options = s, h(this, I, e), h(this, k, null), h(this, M, Fe()), this.options.experimental_prefetchInRender || n(this, M).reject(
718
- new Error("experimental_prefetchInRender feature flag is not enabled")
719
- ), this.bindMethods(), this.setOptions(s);
720
- }
721
- bindMethods() {
722
- this.refetch = this.refetch.bind(this);
723
- }
724
- onSubscribe() {
725
- this.listeners.size === 1 && (n(this, d).addObserver(this), Ge(n(this, d), this.options) ? m(this, y, ae).call(this) : this.updateResult(), m(this, y, De).call(this));
726
- }
727
- onUnsubscribe() {
728
- this.hasListeners() || this.destroy();
729
- }
730
- shouldFetchOnReconnect() {
731
- return qe(
732
- n(this, d),
733
- this.options,
734
- this.options.refetchOnReconnect
735
- );
736
- }
737
- shouldFetchOnWindowFocus() {
738
- return qe(
739
- n(this, d),
740
- this.options,
741
- this.options.refetchOnWindowFocus
742
- );
743
- }
744
- destroy() {
745
- this.listeners = /* @__PURE__ */ new Set(), m(this, y, xe).call(this), m(this, y, je).call(this), n(this, d).removeObserver(this);
746
- }
747
- setOptions(e, s) {
748
- const r = this.options, i = n(this, d);
749
- if (this.options = n(this, I).defaultQueryOptions(e), this.options.enabled !== void 0 && typeof this.options.enabled != "boolean" && typeof this.options.enabled != "function" && typeof x(this.options.enabled, n(this, d)) != "boolean")
750
- throw new Error(
751
- "Expected enabled to be a boolean or a callback that returns a boolean"
752
- );
753
- m(this, y, ke).call(this), n(this, d).setOptions(this.options), r._defaulted && !we(this.options, r) && n(this, I).getQueryCache().notify({
754
- type: "observerOptionsUpdated",
755
- query: n(this, d),
756
- observer: this
757
- });
758
- const o = this.hasListeners();
759
- o && ze(
760
- n(this, d),
761
- i,
762
- this.options,
763
- r
764
- ) && m(this, y, ae).call(this), this.updateResult(s), o && (n(this, d) !== i || x(this.options.enabled, n(this, d)) !== x(r.enabled, n(this, d)) || fe(this.options.staleTime, n(this, d)) !== fe(r.staleTime, n(this, d))) && m(this, y, Ie).call(this);
765
- const a = m(this, y, Pe).call(this);
766
- o && (n(this, d) !== i || x(this.options.enabled, n(this, d)) !== x(r.enabled, n(this, d)) || a !== n(this, L)) && m(this, y, Te).call(this, a);
767
- }
768
- getOptimisticResult(e) {
769
- const s = n(this, I).getQueryCache().build(n(this, I), e), r = this.createResult(s, e);
770
- return Dt(this, r) && (h(this, F, r), h(this, se, this.options), h(this, B, n(this, d).state)), r;
771
- }
772
- getCurrentResult() {
773
- return n(this, F);
774
- }
775
- trackResult(e, s) {
776
- const r = {};
777
- return Object.keys(e).forEach((i) => {
778
- Object.defineProperty(r, i, {
779
- configurable: !1,
780
- enumerable: !0,
781
- get: () => (this.trackProp(i), s == null || s(i), e[i])
782
- });
783
- }), r;
784
- }
785
- trackProp(e) {
786
- n(this, ie).add(e);
787
- }
788
- getCurrentQuery() {
789
- return n(this, d);
790
- }
791
- refetch({ ...e } = {}) {
792
- return this.fetch({
793
- ...e
794
- });
795
- }
796
- fetchOptimistic(e) {
797
- const s = n(this, I).defaultQueryOptions(e), r = n(this, I).getQueryCache().build(n(this, I), s);
798
- return r.fetch().then(() => this.createResult(r, s));
799
- }
800
- fetch(e) {
801
- return m(this, y, ae).call(this, {
802
- ...e,
803
- cancelRefetch: e.cancelRefetch ?? !0
804
- }).then(() => (this.updateResult(), n(this, F)));
805
- }
806
- createResult(e, s) {
807
- var _e;
808
- const r = n(this, d), i = this.options, o = n(this, F), a = n(this, B), u = n(this, se), S = e !== r ? e.state : n(this, oe), { state: v } = e;
809
- let c = { ...v }, C = !1, g;
810
- if (s._optimisticResults) {
811
- const O = this.hasListeners(), Z = !O && Ge(e, s), W = O && ze(e, r, s, i);
812
- (Z || W) && (c = {
813
- ...c,
814
- ...it(v.data, e.options)
815
- }), s._optimisticResults === "isRestoring" && (c.fetchStatus = "idle");
816
- }
817
- let { error: w, errorUpdatedAt: b, status: p } = c;
818
- if (s.select && c.data !== void 0)
819
- if (o && c.data === (a == null ? void 0 : a.data) && s.select === n(this, ce))
820
- g = n(this, re);
821
- else
822
- try {
823
- h(this, ce, s.select), g = s.select(c.data), g = Oe(o == null ? void 0 : o.data, g, s), h(this, re, g), h(this, k, null);
824
- } catch (O) {
825
- h(this, k, O);
826
- }
827
- else
828
- g = c.data;
829
- if (s.placeholderData !== void 0 && g === void 0 && p === "pending") {
830
- let O;
831
- if (o != null && o.isPlaceholderData && s.placeholderData === (u == null ? void 0 : u.placeholderData))
832
- O = o.data;
833
- else if (O = typeof s.placeholderData == "function" ? s.placeholderData(
834
- (_e = n(this, ne)) == null ? void 0 : _e.state.data,
835
- n(this, ne)
836
- ) : s.placeholderData, s.select && O !== void 0)
837
- try {
838
- O = s.select(O), h(this, k, null);
839
- } catch (Z) {
840
- h(this, k, Z);
841
- }
842
- O !== void 0 && (p = "success", g = Oe(
843
- o == null ? void 0 : o.data,
844
- O,
845
- s
846
- ), C = !0);
847
- }
848
- n(this, k) && (w = n(this, k), g = n(this, re), b = Date.now(), p = "error");
849
- const E = c.fetchStatus === "fetching", q = p === "pending", N = p === "error", he = q && E, le = g !== void 0, j = {
850
- status: p,
851
- fetchStatus: c.fetchStatus,
852
- isPending: q,
853
- isSuccess: p === "success",
854
- isError: N,
855
- isInitialLoading: he,
856
- isLoading: he,
857
- data: g,
858
- dataUpdatedAt: c.dataUpdatedAt,
859
- error: w,
860
- errorUpdatedAt: b,
861
- failureCount: c.fetchFailureCount,
862
- failureReason: c.fetchFailureReason,
863
- errorUpdateCount: c.errorUpdateCount,
864
- isFetched: c.dataUpdateCount > 0 || c.errorUpdateCount > 0,
865
- isFetchedAfterMount: c.dataUpdateCount > S.dataUpdateCount || c.errorUpdateCount > S.errorUpdateCount,
866
- isFetching: E,
867
- isRefetching: E && !q,
868
- isLoadingError: N && !le,
869
- isPaused: c.fetchStatus === "paused",
870
- isPlaceholderData: C,
871
- isRefetchError: N && le,
872
- isStale: Me(e, s),
873
- refetch: this.refetch,
874
- promise: n(this, M)
875
- };
876
- if (this.options.experimental_prefetchInRender) {
877
- const O = (de) => {
878
- j.status === "error" ? de.reject(j.error) : j.data !== void 0 && de.resolve(j.data);
879
- }, Z = () => {
880
- const de = h(this, M, j.promise = Fe());
881
- O(de);
882
- }, W = n(this, M);
883
- switch (W.status) {
884
- case "pending":
885
- e.queryHash === r.queryHash && O(W);
886
- break;
887
- case "fulfilled":
888
- (j.status === "error" || j.data !== W.value) && Z();
889
- break;
890
- case "rejected":
891
- (j.status !== "error" || j.error !== W.reason) && Z();
892
- break;
893
- }
894
- }
895
- return j;
896
- }
897
- updateResult(e) {
898
- const s = n(this, F), r = this.createResult(n(this, d), this.options);
899
- if (h(this, B, n(this, d).state), h(this, se, this.options), n(this, B).data !== void 0 && h(this, ne, n(this, d)), we(r, s))
900
- return;
901
- h(this, F, r);
902
- const i = {}, o = () => {
903
- if (!s)
904
- return !0;
905
- const { notifyOnChangeProps: a } = this.options, u = typeof a == "function" ? a() : a;
906
- if (u === "all" || !u && !n(this, ie).size)
907
- return !0;
908
- const l = new Set(
909
- u ?? n(this, ie)
910
- );
911
- return this.options.throwOnError && l.add("error"), Object.keys(n(this, F)).some((S) => {
912
- const v = S;
913
- return n(this, F)[v] !== s[v] && l.has(v);
914
- });
915
- };
916
- (e == null ? void 0 : e.listeners) !== !1 && o() && (i.listeners = !0), m(this, y, ut).call(this, { ...i, ...e });
917
- }
918
- onQueryUpdate() {
919
- this.updateResult(), this.hasListeners() && m(this, y, De).call(this);
920
- }
921
- }, I = new WeakMap(), d = new WeakMap(), oe = new WeakMap(), F = new WeakMap(), B = new WeakMap(), se = new WeakMap(), M = new WeakMap(), k = new WeakMap(), ce = new WeakMap(), re = new WeakMap(), ne = new WeakMap(), G = new WeakMap(), z = new WeakMap(), L = new WeakMap(), ie = new WeakMap(), y = new WeakSet(), ae = function(e) {
922
- m(this, y, ke).call(this);
923
- let s = n(this, d).fetch(
924
- this.options,
925
- e
926
- );
927
- return e != null && e.throwOnError || (s = s.catch(ge)), s;
928
- }, Ie = function() {
929
- m(this, y, xe).call(this);
930
- const e = fe(
931
- this.options.staleTime,
932
- n(this, d)
933
- );
934
- if (V || n(this, F).isStale || !Se(e))
935
- return;
936
- const r = et(n(this, F).dataUpdatedAt, e) + 1;
937
- h(this, G, setTimeout(() => {
938
- n(this, F).isStale || this.updateResult();
939
- }, r));
940
- }, Pe = function() {
941
- return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(n(this, d)) : this.options.refetchInterval) ?? !1;
942
- }, Te = function(e) {
943
- m(this, y, je).call(this), h(this, L, e), !(V || x(this.options.enabled, n(this, d)) === !1 || !Se(n(this, L)) || n(this, L) === 0) && h(this, z, setInterval(() => {
944
- (this.options.refetchIntervalInBackground || tt.isFocused()) && m(this, y, ae).call(this);
945
- }, n(this, L)));
946
- }, De = function() {
947
- m(this, y, Ie).call(this), m(this, y, Te).call(this, m(this, y, Pe).call(this));
948
- }, xe = function() {
949
- n(this, G) && (clearTimeout(n(this, G)), h(this, G, void 0));
950
- }, je = function() {
951
- n(this, z) && (clearInterval(n(this, z)), h(this, z, void 0));
952
- }, ke = function() {
953
- const e = n(this, I).getQueryCache().build(n(this, I), this.options);
954
- if (e === n(this, d))
955
- return;
956
- const s = n(this, d);
957
- h(this, d, e), h(this, oe, e.state), this.hasListeners() && (s == null || s.removeObserver(this), e.addObserver(this));
958
- }, ut = function(e) {
959
- Ue.batch(() => {
960
- e.listeners && this.listeners.forEach((s) => {
961
- s(n(this, F));
962
- }), n(this, I).getQueryCache().notify({
963
- query: n(this, d),
964
- type: "observerResultsUpdated"
965
- });
966
- });
967
- }, Xe);
968
- function Tt(t, e) {
969
- return x(e.enabled, t) !== !1 && t.state.data === void 0 && !(t.state.status === "error" && e.retryOnMount === !1);
970
- }
971
- function Ge(t, e) {
972
- return Tt(t, e) || t.state.data !== void 0 && qe(t, e, e.refetchOnMount);
973
- }
974
- function qe(t, e, s) {
975
- if (x(e.enabled, t) !== !1) {
976
- const r = typeof s == "function" ? s(t) : s;
977
- return r === "always" || r !== !1 && Me(t, e);
978
- }
979
- return !1;
980
- }
981
- function ze(t, e, s, r) {
982
- return (t !== e || x(r.enabled, t) === !1) && (!s.suspense || t.state.status !== "error") && Me(t, s);
983
- }
984
- function Me(t, e) {
985
- return x(e.enabled, t) !== !1 && t.isStaleByTime(fe(e.staleTime, t));
986
- }
987
- function Dt(t, e) {
988
- return !we(t.getCurrentResult(), e);
989
- }
990
- var ot = T.createContext(
991
- void 0
992
- ), ct = (t) => {
993
- const e = T.useContext(ot);
994
- if (t)
995
- return t;
996
- if (!e)
997
- throw new Error("No QueryClient set, use QueryClientProvider to set one");
998
- return e;
999
- }, ss = ({
1000
- client: t,
1001
- children: e
1002
- }) => (T.useEffect(() => (t.mount(), () => {
1003
- t.unmount();
1004
- }), [t]), /* @__PURE__ */ mt.jsx(ot.Provider, { value: t, children: e })), ht = T.createContext(!1), xt = () => T.useContext(ht);
1005
- ht.Provider;
1006
- function jt() {
1007
- let t = !1;
1008
- return {
1009
- clearReset: () => {
1010
- t = !1;
1011
- },
1012
- reset: () => {
1013
- t = !0;
1014
- },
1015
- isReset: () => t
1016
- };
1017
- }
1018
- var kt = T.createContext(jt()), qt = () => T.useContext(kt);
1019
- function At(t, e) {
1020
- return typeof t == "function" ? t(...e) : !!t;
1021
- }
1022
- function Ve() {
1023
- }
1024
- var Qt = (t, e) => {
1025
- (t.suspense || t.throwOnError || t.experimental_prefetchInRender) && (e.isReset() || (t.retryOnMount = !1));
1026
- }, Ut = (t) => {
1027
- T.useEffect(() => {
1028
- t.clearReset();
1029
- }, [t]);
1030
- }, Mt = ({
1031
- result: t,
1032
- errorResetBoundary: e,
1033
- throwOnError: s,
1034
- query: r
1035
- }) => t.isError && !e.isReset() && !t.isFetching && r && At(s, [t.error, r]), Lt = (t, e) => e.state.data === void 0, Nt = (t) => {
1036
- const e = t.staleTime;
1037
- t.suspense && (t.staleTime = typeof e == "function" ? (...s) => Math.max(e(...s), 1e3) : Math.max(e ?? 1e3, 1e3), typeof t.gcTime == "number" && (t.gcTime = Math.max(t.gcTime, 1e3)));
1038
- }, _t = (t, e) => t.isLoading && t.isFetching && !e, Kt = (t, e) => (t == null ? void 0 : t.suspense) && e.isPending, $e = (t, e, s) => e.fetchOptimistic(t).catch(() => {
1039
- s.clearReset();
1040
- });
1041
- function lt(t, e, s) {
1042
- var c, C, g, w, b;
1043
- if (process.env.NODE_ENV !== "production" && (typeof t != "object" || Array.isArray(t)))
1044
- throw new Error(
1045
- 'Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object'
1046
- );
1047
- const r = ct(s), i = xt(), o = qt(), a = r.defaultQueryOptions(t);
1048
- (C = (c = r.getDefaultOptions().queries) == null ? void 0 : c._experimental_beforeQuery) == null || C.call(
1049
- c,
1050
- a
1051
- ), a._optimisticResults = i ? "isRestoring" : "optimistic", Nt(a), Qt(a, o), Ut(o);
1052
- const u = !r.getQueryCache().get(a.queryHash), [l] = T.useState(
1053
- () => new e(
1054
- r,
1055
- a
1056
- )
1057
- ), S = l.getOptimisticResult(a), v = !i && t.subscribed !== !1;
1058
- if (T.useSyncExternalStore(
1059
- T.useCallback(
1060
- (p) => {
1061
- const E = v ? l.subscribe(Ue.batchCalls(p)) : Ve;
1062
- return l.updateResult(), E;
1063
- },
1064
- [l, v]
1065
- ),
1066
- () => l.getCurrentResult(),
1067
- () => l.getCurrentResult()
1068
- ), T.useEffect(() => {
1069
- l.setOptions(a, { listeners: !1 });
1070
- }, [a, l]), Kt(a, S))
1071
- throw $e(a, l, o);
1072
- if (Mt({
1073
- result: S,
1074
- errorResetBoundary: o,
1075
- throwOnError: a.throwOnError,
1076
- query: r.getQueryCache().get(a.queryHash)
1077
- }))
1078
- throw S.error;
1079
- if ((w = (g = r.getDefaultOptions().queries) == null ? void 0 : g._experimental_afterQuery) == null || w.call(
1080
- g,
1081
- a,
1082
- S
1083
- ), a.experimental_prefetchInRender && !V && _t(S, i)) {
1084
- const p = u ? (
1085
- // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
1086
- $e(a, l, o)
1087
- ) : (
1088
- // subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
1089
- (b = r.getQueryCache().get(a.queryHash)) == null ? void 0 : b.promise
1090
- );
1091
- p == null || p.catch(Ve).finally(() => {
1092
- l.updateResult();
1093
- });
1094
- }
1095
- return a.notifyOnChangeProps ? S : l.trackResult(S);
1096
- }
1097
- function Ht(t, e) {
1098
- return lt(t, at, e);
1099
- }
1100
- function Bt(t, e) {
1101
- return process.env.NODE_ENV !== "production" && t.queryFn === ye && console.error("skipToken is not allowed for useSuspenseQuery"), lt(
1102
- {
1103
- ...t,
1104
- enabled: !0,
1105
- suspense: !0,
1106
- throwOnError: Lt,
1107
- placeholderData: void 0
1108
- },
1109
- at,
1110
- e
1111
- );
1112
- }
1113
- const $ = (...t) => {
1114
- const e = t.filter((s) => !!s).map((s) => s.replace(/(^\/+|\/+$)/g, "")).join("/").replace(/(^\/+|\/+$)/g, "");
1115
- return e ? `/${e}` : "/";
1116
- }, dt = Object.freeze({
1117
- API_IDENTITIES: ["api-identities"]
1118
- }), rs = () => {
1119
- const t = ct();
1120
- return {
1121
- invalidateCache: async (e) => {
1122
- await t.invalidateQueries({ queryKey: dt[e] });
1123
- }
1124
- };
1125
- }, Le = (t, e) => {
1126
- for (const s of t) {
1127
- const r = Ne(s, e);
1128
- if (r !== void 0) return r;
1129
- }
1130
- }, Ne = (t, e, s = []) => {
1131
- const r = e(t, s);
1132
- if (r !== void 0) return r;
1133
- if (t.type === "category")
1134
- for (const i of t.items) {
1135
- const o = Ne(i, e, [
1136
- ...s,
1137
- t
1138
- ]);
1139
- if (o !== void 0) return o;
1140
- }
1141
- }, ns = () => {
1142
- const t = pe(), s = yt().sidebar;
1143
- return Le(s, (r) => {
1144
- if (r.type === "doc" && $(r.id) === t.pathname)
1145
- return r;
1146
- });
1147
- }, is = (t) => {
1148
- const e = pe();
1149
- return Ne(t, (s) => {
1150
- if (s.type === "category" && s.link && $(s.link.id) === e.pathname || s.type === "doc" && $(s.id) === e.pathname)
1151
- return !0;
1152
- });
1153
- }, as = () => {
1154
- const t = pe().pathname, s = yt().sidebar;
1155
- let r, i, o = !1;
1156
- return Le(s, (a) => {
1157
- const u = a.type === "doc" ? $(a.id) : a.type === "category" && a.link ? $(a.link.id) : void 0;
1158
- if (u) {
1159
- if (o)
1160
- return i = { label: a.label, id: u }, !0;
1161
- t === u ? o = !0 : r = { label: a.label, id: u };
1162
- }
1163
- }), { prev: r, next: i };
1164
- }, Gt = pt(
1165
- void 0
1166
- ), ft = () => {
1167
- const t = bt(Gt);
1168
- if (!t)
1169
- throw new Error("useZudoku must be used within a ZudokuProvider.");
1170
- return t;
1171
- }, us = () => {
1172
- const { getApiIdentities: t } = ft();
1173
- return Ht({
1174
- queryFn: t,
1175
- queryKey: [dt.API_IDENTITIES]
1176
- });
1177
- }, yt = () => {
1178
- const { getPluginSidebar: t, sidebars: e, topNavigation: s } = ft(), r = pe(), i = Object.entries(e).find(([, u]) => Le(u, (l) => {
1179
- if ((l.type === "doc" ? $(l.id) : l.type === "category" && l.link ? $(l.link.id) : void 0) === r.pathname)
1180
- return l;
1181
- })), o = s.find((u) => u.id === (i == null ? void 0 : i[0])) ?? s.find((u) => vt(u.id, r.pathname)), { data: a } = Bt({
1182
- queryFn: () => t(r.pathname),
1183
- queryKey: ["plugin-sidebar", r.pathname]
1184
- });
1185
- return {
1186
- sidebar: [...i ? i[1] : [], ...a],
1187
- topNavItem: o
1188
- };
1189
- };
1190
- export {
1191
- Qe as A,
1192
- ye as B,
1193
- ss as C,
1194
- yt as D,
1195
- Le as E,
1196
- rs as F,
1197
- dt as G,
1198
- ts as Q,
1199
- It as R,
1200
- Ae as S,
1201
- Gt as Z,
1202
- ft as a,
1203
- ns as b,
1204
- Ot as c,
1205
- as as d,
1206
- ct as e,
1207
- Ve as f,
1208
- At as g,
1209
- Ce as h,
1210
- is as i,
1211
- $ as j,
1212
- Ht as k,
1213
- us as l,
1214
- gt as m,
1215
- Ue as n,
1216
- Jt as o,
1217
- Yt as p,
1218
- ge as q,
1219
- Ct as r,
1220
- we as s,
1221
- es as t,
1222
- Bt as u,
1223
- Xt as v,
1224
- tt as w,
1225
- st as x,
1226
- fe as y,
1227
- Wt as z
1228
- };
1229
- //# sourceMappingURL=ZudokuContext-dUyBGMap.js.map