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