@camstack/addon-pipeline-orchestrator 0.1.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/@mf-types/compiled-types/widgets/PipelineQuickStats.d.ts +3 -0
- package/dist/@mf-types/compiled-types/widgets/PipelineQuickStats.d.ts.map +1 -0
- package/dist/@mf-types/compiled-types/widgets/ZoneEditor.d.ts +17 -0
- package/dist/@mf-types/compiled-types/widgets/ZoneEditor.d.ts.map +1 -0
- package/dist/@mf-types/compiled-types/widgets/ZonesTab.d.ts +7 -0
- package/dist/@mf-types/compiled-types/widgets/ZonesTab.d.ts.map +1 -0
- package/dist/@mf-types/compiled-types/widgets/index.d.ts +13 -0
- package/dist/@mf-types/compiled-types/widgets/index.d.ts.map +1 -0
- package/dist/@mf-types/compiled-types/widgets/zone-editor/ZoneCanvas.d.ts +60 -0
- package/dist/@mf-types/compiled-types/widgets/zone-editor/ZoneCanvas.d.ts.map +1 -0
- package/dist/@mf-types/compiled-types/widgets/zone-editor/ZoneForm.d.ts +23 -0
- package/dist/@mf-types/compiled-types/widgets/zone-editor/ZoneForm.d.ts.map +1 -0
- package/dist/@mf-types/compiled-types/widgets/zone-editor/ZoneList.d.ts +15 -0
- package/dist/@mf-types/compiled-types/widgets/zone-editor/ZoneList.d.ts.map +1 -0
- package/dist/@mf-types/compiled-types/widgets/zone-editor/ZoneOverlay.d.ts +19 -0
- package/dist/@mf-types/compiled-types/widgets/zone-editor/ZoneOverlay.d.ts.map +1 -0
- package/dist/@mf-types/compiled-types/widgets/zone-editor/ZoneRulesEditor.d.ts +9 -0
- package/dist/@mf-types/compiled-types/widgets/zone-editor/ZoneRulesEditor.d.ts.map +1 -0
- package/dist/@mf-types/widgets.d.ts +2 -0
- package/dist/@mf-types.d.ts +3 -0
- package/dist/@mf-types.zip +0 -0
- package/dist/__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_sdk__loadShare__.mjs-CCBTZBOa.mjs +12 -0
- package/dist/__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.mjs-CvusB3VY.mjs +17 -0
- package/dist/__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.mjs-BrYYwKk_.mjs +34 -0
- package/dist/__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-DoWbefqS.mjs +104 -0
- package/dist/__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_trpc_mf_1_client__loadShare__.mjs-D4eEXltm.mjs +85 -0
- package/dist/__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs-CVrnrGED.mjs +62 -0
- package/dist/__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react__loadShare__.mjs-B848Fc_m.mjs +88 -0
- package/dist/__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react__loadShare__.mjs_commonjs-proxy-B-q1guKT.mjs +29 -0
- package/dist/__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.mjs-Cg6QsnjR.mjs +36 -0
- package/dist/__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react_mf_2_dom__loadShare__.mjs-Dp8hqYOB.mjs +45 -0
- package/dist/__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-CeGb2_QF.mjs +6 -0
- package/dist/__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs-BBmNf5hf.mjs +34 -0
- package/dist/_stub.js +16268 -0
- package/dist/_virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_orchestrator_widgets-C5Dbnljh.mjs +157 -0
- package/dist/client-BkQItW6e.mjs +9836 -0
- package/dist/getErrorShape-BPSzUA7W-TlK8ipWe.mjs +211 -0
- package/dist/hostInit-xzBPWUz0.mjs +168 -0
- package/dist/index-BI-_eQhe.mjs +185 -0
- package/dist/index-BJzn4K_R.mjs +2603 -0
- package/dist/index-BZ6YICSw.mjs +17936 -0
- package/dist/index-Bj470a3A.mjs +725 -0
- package/dist/index-C3iAUQqS.mjs +533 -0
- package/dist/index-CWkKuNLr.mjs +232 -0
- package/dist/index-Cj-UePAd.mjs +435 -0
- package/dist/index-D0dNM7_R.mjs +2892 -0
- package/dist/index-DNWfP1gi.mjs +2464 -0
- package/dist/index-DnFVXz0U.mjs +14162 -0
- package/dist/index-xncRG7-x.mjs +2713 -0
- package/dist/index.d.mts +907 -0
- package/dist/index.d.ts +907 -0
- package/dist/index.js +18670 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +18668 -0
- package/dist/index.mjs.map +1 -0
- package/dist/jsx-runtime-CJ4xYF4l.mjs +55 -0
- package/dist/remoteEntry.js +85 -0
- package/dist/virtualExposes-8FzWTdq3.mjs +42 -0
- package/package.json +95 -0
|
@@ -0,0 +1,2603 @@
|
|
|
1
|
+
import { j as nt, e as M, h as at, d as W, c as Ct, n as j, m as _, l as J } from "./__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react__loadShare__.mjs-B848Fc_m.mjs";
|
|
2
|
+
import { _ as Qt } from "./__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.mjs-Cg6QsnjR.mjs";
|
|
3
|
+
var I = class {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
|
|
6
|
+
}
|
|
7
|
+
subscribe(t) {
|
|
8
|
+
return this.listeners.add(t), this.onSubscribe(), () => {
|
|
9
|
+
this.listeners.delete(t), this.onUnsubscribe();
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
hasListeners() {
|
|
13
|
+
return this.listeners.size > 0;
|
|
14
|
+
}
|
|
15
|
+
onSubscribe() {
|
|
16
|
+
}
|
|
17
|
+
onUnsubscribe() {
|
|
18
|
+
}
|
|
19
|
+
}, Vt = class extends I {
|
|
20
|
+
#e;
|
|
21
|
+
#t;
|
|
22
|
+
#s;
|
|
23
|
+
constructor() {
|
|
24
|
+
super(), this.#s = (t) => {
|
|
25
|
+
if (typeof window < "u" && window.addEventListener) {
|
|
26
|
+
const e = () => t();
|
|
27
|
+
return window.addEventListener("visibilitychange", e, !1), () => {
|
|
28
|
+
window.removeEventListener("visibilitychange", e);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
onSubscribe() {
|
|
34
|
+
this.#t || this.setEventListener(this.#s);
|
|
35
|
+
}
|
|
36
|
+
onUnsubscribe() {
|
|
37
|
+
this.hasListeners() || (this.#t?.(), this.#t = void 0);
|
|
38
|
+
}
|
|
39
|
+
setEventListener(t) {
|
|
40
|
+
this.#s = t, this.#t?.(), this.#t = t((e) => {
|
|
41
|
+
typeof e == "boolean" ? this.setFocused(e) : this.onFocus();
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
setFocused(t) {
|
|
45
|
+
this.#e !== t && (this.#e = t, this.onFocus());
|
|
46
|
+
}
|
|
47
|
+
onFocus() {
|
|
48
|
+
const t = this.isFocused();
|
|
49
|
+
this.listeners.forEach((e) => {
|
|
50
|
+
e(t);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
isFocused() {
|
|
54
|
+
return typeof this.#e == "boolean" ? this.#e : globalThis.document?.visibilityState !== "hidden";
|
|
55
|
+
}
|
|
56
|
+
}, ot = new Vt(), Jt = {
|
|
57
|
+
// We need the wrapper function syntax below instead of direct references to
|
|
58
|
+
// global setTimeout etc.
|
|
59
|
+
//
|
|
60
|
+
// BAD: `setTimeout: setTimeout`
|
|
61
|
+
// GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`
|
|
62
|
+
//
|
|
63
|
+
// If we use direct references here, then anything that wants to spy on or
|
|
64
|
+
// replace the global setTimeout (like tests) won't work since we'll already
|
|
65
|
+
// have a hard reference to the original implementation at the time when this
|
|
66
|
+
// file was imported.
|
|
67
|
+
setTimeout: (t, e) => setTimeout(t, e),
|
|
68
|
+
clearTimeout: (t) => clearTimeout(t),
|
|
69
|
+
setInterval: (t, e) => setInterval(t, e),
|
|
70
|
+
clearInterval: (t) => clearInterval(t)
|
|
71
|
+
}, Zt = class {
|
|
72
|
+
// We cannot have TimeoutManager<T> as we must instantiate it with a concrete
|
|
73
|
+
// type at app boot; and if we leave that type, then any new timer provider
|
|
74
|
+
// would need to support the default provider's concrete timer ID, which is
|
|
75
|
+
// infeasible across environments.
|
|
76
|
+
//
|
|
77
|
+
// We settle for type safety for the TimeoutProvider type, and accept that
|
|
78
|
+
// this class is unsafe internally to allow for extension.
|
|
79
|
+
#e = Jt;
|
|
80
|
+
#t = !1;
|
|
81
|
+
setTimeoutProvider(t) {
|
|
82
|
+
this.#e = t;
|
|
83
|
+
}
|
|
84
|
+
setTimeout(t, e) {
|
|
85
|
+
return this.#e.setTimeout(t, e);
|
|
86
|
+
}
|
|
87
|
+
clearTimeout(t) {
|
|
88
|
+
this.#e.clearTimeout(t);
|
|
89
|
+
}
|
|
90
|
+
setInterval(t, e) {
|
|
91
|
+
return this.#e.setInterval(t, e);
|
|
92
|
+
}
|
|
93
|
+
clearInterval(t) {
|
|
94
|
+
this.#e.clearInterval(t);
|
|
95
|
+
}
|
|
96
|
+
}, D = new Zt();
|
|
97
|
+
function Xt(t) {
|
|
98
|
+
setTimeout(t, 0);
|
|
99
|
+
}
|
|
100
|
+
var Yt = typeof window > "u" || "Deno" in globalThis;
|
|
101
|
+
function O() {
|
|
102
|
+
}
|
|
103
|
+
function te(t, e) {
|
|
104
|
+
return typeof t == "function" ? t(e) : t;
|
|
105
|
+
}
|
|
106
|
+
function Z(t) {
|
|
107
|
+
return typeof t == "number" && t >= 0 && t !== 1 / 0;
|
|
108
|
+
}
|
|
109
|
+
function Et(t, e) {
|
|
110
|
+
return Math.max(t + (e || 0) - Date.now(), 0);
|
|
111
|
+
}
|
|
112
|
+
function F(t, e) {
|
|
113
|
+
return typeof t == "function" ? t(e) : t;
|
|
114
|
+
}
|
|
115
|
+
function S(t, e) {
|
|
116
|
+
return typeof t == "function" ? t(e) : t;
|
|
117
|
+
}
|
|
118
|
+
function pt(t, e) {
|
|
119
|
+
const {
|
|
120
|
+
type: s = "all",
|
|
121
|
+
exact: r,
|
|
122
|
+
fetchStatus: i,
|
|
123
|
+
predicate: n,
|
|
124
|
+
queryKey: a,
|
|
125
|
+
stale: u
|
|
126
|
+
} = t;
|
|
127
|
+
if (a) {
|
|
128
|
+
if (r) {
|
|
129
|
+
if (e.queryHash !== ut(a, e.options))
|
|
130
|
+
return !1;
|
|
131
|
+
} else if (!q(e.queryKey, a))
|
|
132
|
+
return !1;
|
|
133
|
+
}
|
|
134
|
+
if (s !== "all") {
|
|
135
|
+
const o = e.isActive();
|
|
136
|
+
if (s === "active" && !o || s === "inactive" && o)
|
|
137
|
+
return !1;
|
|
138
|
+
}
|
|
139
|
+
return !(typeof u == "boolean" && e.isStale() !== u || i && i !== e.state.fetchStatus || n && !n(e));
|
|
140
|
+
}
|
|
141
|
+
function yt(t, e) {
|
|
142
|
+
const { exact: s, status: r, predicate: i, mutationKey: n } = t;
|
|
143
|
+
if (n) {
|
|
144
|
+
if (!e.options.mutationKey)
|
|
145
|
+
return !1;
|
|
146
|
+
if (s) {
|
|
147
|
+
if (T(e.options.mutationKey) !== T(n))
|
|
148
|
+
return !1;
|
|
149
|
+
} else if (!q(e.options.mutationKey, n))
|
|
150
|
+
return !1;
|
|
151
|
+
}
|
|
152
|
+
return !(r && e.state.status !== r || i && !i(e));
|
|
153
|
+
}
|
|
154
|
+
function ut(t, e) {
|
|
155
|
+
return (e?.queryKeyHashFn || T)(t);
|
|
156
|
+
}
|
|
157
|
+
function T(t) {
|
|
158
|
+
return JSON.stringify(
|
|
159
|
+
t,
|
|
160
|
+
(e, s) => X(s) ? Object.keys(s).sort().reduce((r, i) => (r[i] = s[i], r), {}) : s
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
function q(t, e) {
|
|
164
|
+
return t === e ? !0 : typeof t != typeof e ? !1 : t && e && typeof t == "object" && typeof e == "object" ? Object.keys(e).every((s) => q(t[s], e[s])) : !1;
|
|
165
|
+
}
|
|
166
|
+
var ee = Object.prototype.hasOwnProperty;
|
|
167
|
+
function $(t, e, s = 0) {
|
|
168
|
+
if (t === e)
|
|
169
|
+
return t;
|
|
170
|
+
if (s > 500) return e;
|
|
171
|
+
const r = vt(t) && vt(e);
|
|
172
|
+
if (!r && !(X(t) && X(e))) return e;
|
|
173
|
+
const n = (r ? t : Object.keys(t)).length, a = r ? e : Object.keys(e), u = a.length, o = r ? new Array(u) : {};
|
|
174
|
+
let c = 0;
|
|
175
|
+
for (let h = 0; h < u; h++) {
|
|
176
|
+
const f = r ? h : a[h], l = t[f], y = e[f];
|
|
177
|
+
if (l === y) {
|
|
178
|
+
o[f] = l, (r ? h < n : ee.call(t, f)) && c++;
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (l === null || y === null || typeof l != "object" || typeof y != "object") {
|
|
182
|
+
o[f] = y;
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
const m = $(l, y, s + 1);
|
|
186
|
+
o[f] = m, m === l && c++;
|
|
187
|
+
}
|
|
188
|
+
return n === u && c === n ? t : o;
|
|
189
|
+
}
|
|
190
|
+
function x(t, e) {
|
|
191
|
+
if (!e || Object.keys(t).length !== Object.keys(e).length)
|
|
192
|
+
return !1;
|
|
193
|
+
for (const s in t)
|
|
194
|
+
if (t[s] !== e[s])
|
|
195
|
+
return !1;
|
|
196
|
+
return !0;
|
|
197
|
+
}
|
|
198
|
+
function vt(t) {
|
|
199
|
+
return Array.isArray(t) && t.length === Object.keys(t).length;
|
|
200
|
+
}
|
|
201
|
+
function X(t) {
|
|
202
|
+
if (!mt(t))
|
|
203
|
+
return !1;
|
|
204
|
+
const e = t.constructor;
|
|
205
|
+
if (e === void 0)
|
|
206
|
+
return !0;
|
|
207
|
+
const s = e.prototype;
|
|
208
|
+
return !(!mt(s) || !s.hasOwnProperty("isPrototypeOf") || Object.getPrototypeOf(t) !== Object.prototype);
|
|
209
|
+
}
|
|
210
|
+
function mt(t) {
|
|
211
|
+
return Object.prototype.toString.call(t) === "[object Object]";
|
|
212
|
+
}
|
|
213
|
+
function se(t) {
|
|
214
|
+
return new Promise((e) => {
|
|
215
|
+
D.setTimeout(e, t);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
function Y(t, e, s) {
|
|
219
|
+
return typeof s.structuralSharing == "function" ? s.structuralSharing(t, e) : s.structuralSharing !== !1 ? $(t, e) : e;
|
|
220
|
+
}
|
|
221
|
+
function Te(t) {
|
|
222
|
+
return t;
|
|
223
|
+
}
|
|
224
|
+
function Ft(t, e, s = 0) {
|
|
225
|
+
const r = [...t, e];
|
|
226
|
+
return s && r.length > s ? r.slice(1) : r;
|
|
227
|
+
}
|
|
228
|
+
function re(t, e, s = 0) {
|
|
229
|
+
const r = [e, ...t];
|
|
230
|
+
return s && r.length > s ? r.slice(0, -1) : r;
|
|
231
|
+
}
|
|
232
|
+
var ht = /* @__PURE__ */ Symbol();
|
|
233
|
+
function Mt(t, e) {
|
|
234
|
+
return !t.queryFn && e?.initialPromise ? () => e.initialPromise : !t.queryFn || t.queryFn === ht ? () => Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)) : t.queryFn;
|
|
235
|
+
}
|
|
236
|
+
function ct(t, e) {
|
|
237
|
+
return typeof t == "function" ? t(...e) : !!t;
|
|
238
|
+
}
|
|
239
|
+
function Dt(t, e, s) {
|
|
240
|
+
let r = !1, i;
|
|
241
|
+
return Object.defineProperty(t, "signal", {
|
|
242
|
+
enumerable: !0,
|
|
243
|
+
get: () => (i ??= e(), r || (r = !0, i.aborted ? s() : i.addEventListener("abort", s, { once: !0 })), i)
|
|
244
|
+
}), t;
|
|
245
|
+
}
|
|
246
|
+
var U = /* @__PURE__ */ (() => {
|
|
247
|
+
let t = () => Yt;
|
|
248
|
+
return {
|
|
249
|
+
/**
|
|
250
|
+
* Returns whether the current runtime should be treated as a server environment.
|
|
251
|
+
*/
|
|
252
|
+
isServer() {
|
|
253
|
+
return t();
|
|
254
|
+
},
|
|
255
|
+
/**
|
|
256
|
+
* Overrides the server check globally.
|
|
257
|
+
*/
|
|
258
|
+
setIsServer(e) {
|
|
259
|
+
t = e;
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
})();
|
|
263
|
+
function tt() {
|
|
264
|
+
let t, e;
|
|
265
|
+
const s = new Promise((i, n) => {
|
|
266
|
+
t = i, e = n;
|
|
267
|
+
});
|
|
268
|
+
s.status = "pending", s.catch(() => {
|
|
269
|
+
});
|
|
270
|
+
function r(i) {
|
|
271
|
+
Object.assign(s, i), delete s.resolve, delete s.reject;
|
|
272
|
+
}
|
|
273
|
+
return s.resolve = (i) => {
|
|
274
|
+
r({
|
|
275
|
+
status: "fulfilled",
|
|
276
|
+
value: i
|
|
277
|
+
}), t(i);
|
|
278
|
+
}, s.reject = (i) => {
|
|
279
|
+
r({
|
|
280
|
+
status: "rejected",
|
|
281
|
+
reason: i
|
|
282
|
+
}), e(i);
|
|
283
|
+
}, s;
|
|
284
|
+
}
|
|
285
|
+
function ie(t) {
|
|
286
|
+
let e;
|
|
287
|
+
if (t.then((s) => (e = s, s), O)?.catch(O), e !== void 0)
|
|
288
|
+
return { data: e };
|
|
289
|
+
}
|
|
290
|
+
function Tt(t) {
|
|
291
|
+
return t;
|
|
292
|
+
}
|
|
293
|
+
function ne(t) {
|
|
294
|
+
return {
|
|
295
|
+
mutationKey: t.options.mutationKey,
|
|
296
|
+
state: t.state,
|
|
297
|
+
...t.options.scope && { scope: t.options.scope },
|
|
298
|
+
...t.meta && { meta: t.meta }
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
function ae(t, e, s) {
|
|
302
|
+
const r = () => {
|
|
303
|
+
const i = t.promise?.then(e).catch((n) => s(n) ? Promise.reject(new Error("redacted")) : Promise.reject(n));
|
|
304
|
+
return i?.catch(O), i;
|
|
305
|
+
};
|
|
306
|
+
return {
|
|
307
|
+
dehydratedAt: Date.now(),
|
|
308
|
+
state: {
|
|
309
|
+
...t.state,
|
|
310
|
+
...t.state.data !== void 0 && {
|
|
311
|
+
data: e(t.state.data)
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
queryKey: t.queryKey,
|
|
315
|
+
queryHash: t.queryHash,
|
|
316
|
+
...t.state.status === "pending" && {
|
|
317
|
+
promise: r()
|
|
318
|
+
},
|
|
319
|
+
...t.meta && { meta: t.meta },
|
|
320
|
+
...t.queryType && { queryType: t.queryType }
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
function oe(t) {
|
|
324
|
+
return t.state.isPaused;
|
|
325
|
+
}
|
|
326
|
+
function ue(t) {
|
|
327
|
+
return t.state.status === "success";
|
|
328
|
+
}
|
|
329
|
+
function he(t) {
|
|
330
|
+
return !0;
|
|
331
|
+
}
|
|
332
|
+
function Ie(t, e = {}) {
|
|
333
|
+
const s = e.shouldDehydrateMutation ?? t.getDefaultOptions().dehydrate?.shouldDehydrateMutation ?? oe, r = t.getMutationCache().getAll().flatMap(
|
|
334
|
+
(o) => s(o) ? [ne(o)] : []
|
|
335
|
+
), i = e.shouldDehydrateQuery ?? t.getDefaultOptions().dehydrate?.shouldDehydrateQuery ?? ue, n = e.shouldRedactErrors ?? t.getDefaultOptions().dehydrate?.shouldRedactErrors ?? he, a = e.serializeData ?? t.getDefaultOptions().dehydrate?.serializeData ?? Tt, u = t.getQueryCache().getAll().flatMap(
|
|
336
|
+
(o) => i(o) ? [ae(o, a, n)] : []
|
|
337
|
+
);
|
|
338
|
+
return { mutations: r, queries: u };
|
|
339
|
+
}
|
|
340
|
+
function gt(t, e, s) {
|
|
341
|
+
if (typeof e != "object" || e === null)
|
|
342
|
+
return;
|
|
343
|
+
const r = t.getMutationCache(), i = t.getQueryCache(), n = s?.defaultOptions?.deserializeData ?? t.getDefaultOptions().hydrate?.deserializeData ?? Tt, a = e.mutations || [], u = e.queries || [];
|
|
344
|
+
a.forEach(({ state: o, ...c }) => {
|
|
345
|
+
r.build(
|
|
346
|
+
t,
|
|
347
|
+
{
|
|
348
|
+
...t.getDefaultOptions().hydrate?.mutations,
|
|
349
|
+
...s?.defaultOptions?.mutations,
|
|
350
|
+
...c
|
|
351
|
+
},
|
|
352
|
+
o
|
|
353
|
+
);
|
|
354
|
+
}), u.forEach(
|
|
355
|
+
({
|
|
356
|
+
queryKey: o,
|
|
357
|
+
state: c,
|
|
358
|
+
queryHash: h,
|
|
359
|
+
meta: f,
|
|
360
|
+
promise: l,
|
|
361
|
+
dehydratedAt: y,
|
|
362
|
+
queryType: m
|
|
363
|
+
}) => {
|
|
364
|
+
const d = l ? ie(l) : void 0, p = c.data === void 0 ? d?.data : c.data, v = p === void 0 ? p : n(p);
|
|
365
|
+
let b = i.get(h);
|
|
366
|
+
const P = b?.state.status === "pending", R = b?.state.fetchStatus === "fetching";
|
|
367
|
+
if (b) {
|
|
368
|
+
const Q = d && // We only need this undefined check to handle older dehydration
|
|
369
|
+
// payloads that might not have dehydratedAt
|
|
370
|
+
y !== void 0 && y > b.state.dataUpdatedAt;
|
|
371
|
+
if (c.dataUpdatedAt > b.state.dataUpdatedAt || Q) {
|
|
372
|
+
const { fetchStatus: K, ...C } = c;
|
|
373
|
+
b.setState({
|
|
374
|
+
...C,
|
|
375
|
+
data: v,
|
|
376
|
+
// If the query was pending at the moment of dehydration, but resolved to have data
|
|
377
|
+
// before hydration, we can assume the query should be hydrated as successful.
|
|
378
|
+
//
|
|
379
|
+
// Since you can opt into dehydrating failed queries, and those can have data from
|
|
380
|
+
// previous successful fetches, we make sure we only do this for pending queries.
|
|
381
|
+
...c.status === "pending" && v !== void 0 && {
|
|
382
|
+
status: "success",
|
|
383
|
+
// Preserve existing fetchStatus if the existing query is actively fetching.
|
|
384
|
+
...!R && {
|
|
385
|
+
fetchStatus: "idle"
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
} else
|
|
391
|
+
b = i.build(
|
|
392
|
+
t,
|
|
393
|
+
{
|
|
394
|
+
...t.getDefaultOptions().hydrate?.queries,
|
|
395
|
+
...s?.defaultOptions?.queries,
|
|
396
|
+
queryKey: o,
|
|
397
|
+
queryHash: h,
|
|
398
|
+
meta: f,
|
|
399
|
+
_type: m
|
|
400
|
+
},
|
|
401
|
+
// Reset fetch status to idle to avoid
|
|
402
|
+
// query being stuck in fetching state upon hydration
|
|
403
|
+
{
|
|
404
|
+
...c,
|
|
405
|
+
data: v,
|
|
406
|
+
fetchStatus: "idle",
|
|
407
|
+
// Like above, if the query was pending at the moment of dehydration but has data,
|
|
408
|
+
// we can assume it should be hydrated as successful.
|
|
409
|
+
status: c.status === "pending" && v !== void 0 ? "success" : c.status
|
|
410
|
+
}
|
|
411
|
+
);
|
|
412
|
+
l && // If the data was synchronously available, there is no need to set up
|
|
413
|
+
// a retryer and thus no reason to call fetch
|
|
414
|
+
!d && !P && !R && // Only hydrate if dehydration is newer than any existing data,
|
|
415
|
+
// this is always true for new queries
|
|
416
|
+
(y === void 0 || y > b.state.dataUpdatedAt) && b.fetch(void 0, {
|
|
417
|
+
// RSC transformed promises are not thenable
|
|
418
|
+
initialPromise: Promise.resolve(l).then(n)
|
|
419
|
+
}).catch(O);
|
|
420
|
+
}
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
var ce = Xt;
|
|
424
|
+
function le() {
|
|
425
|
+
let t = [], e = 0, s = (u) => {
|
|
426
|
+
u();
|
|
427
|
+
}, r = (u) => {
|
|
428
|
+
u();
|
|
429
|
+
}, i = ce;
|
|
430
|
+
const n = (u) => {
|
|
431
|
+
e ? t.push(u) : i(() => {
|
|
432
|
+
s(u);
|
|
433
|
+
});
|
|
434
|
+
}, a = () => {
|
|
435
|
+
const u = t;
|
|
436
|
+
t = [], u.length && i(() => {
|
|
437
|
+
r(() => {
|
|
438
|
+
u.forEach((o) => {
|
|
439
|
+
s(o);
|
|
440
|
+
});
|
|
441
|
+
});
|
|
442
|
+
});
|
|
443
|
+
};
|
|
444
|
+
return {
|
|
445
|
+
batch: (u) => {
|
|
446
|
+
let o;
|
|
447
|
+
e++;
|
|
448
|
+
try {
|
|
449
|
+
o = u();
|
|
450
|
+
} finally {
|
|
451
|
+
e--, e || a();
|
|
452
|
+
}
|
|
453
|
+
return o;
|
|
454
|
+
},
|
|
455
|
+
/**
|
|
456
|
+
* All calls to the wrapped function will be batched.
|
|
457
|
+
*/
|
|
458
|
+
batchCalls: (u) => (...o) => {
|
|
459
|
+
n(() => {
|
|
460
|
+
u(...o);
|
|
461
|
+
});
|
|
462
|
+
},
|
|
463
|
+
schedule: n,
|
|
464
|
+
/**
|
|
465
|
+
* Use this method to set a custom notify function.
|
|
466
|
+
* This can be used to for example wrap notifications with `React.act` while running tests.
|
|
467
|
+
*/
|
|
468
|
+
setNotifyFunction: (u) => {
|
|
469
|
+
s = u;
|
|
470
|
+
},
|
|
471
|
+
/**
|
|
472
|
+
* Use this method to set a custom function to batch notifications together into a single tick.
|
|
473
|
+
* By default React Query will use the batch function provided by ReactDOM or React Native.
|
|
474
|
+
*/
|
|
475
|
+
setBatchNotifyFunction: (u) => {
|
|
476
|
+
r = u;
|
|
477
|
+
},
|
|
478
|
+
setScheduler: (u) => {
|
|
479
|
+
i = u;
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
var g = le(), de = class extends I {
|
|
484
|
+
#e = !0;
|
|
485
|
+
#t;
|
|
486
|
+
#s;
|
|
487
|
+
constructor() {
|
|
488
|
+
super(), this.#s = (t) => {
|
|
489
|
+
if (typeof window < "u" && window.addEventListener) {
|
|
490
|
+
const e = () => t(!0), s = () => t(!1);
|
|
491
|
+
return window.addEventListener("online", e, !1), window.addEventListener("offline", s, !1), () => {
|
|
492
|
+
window.removeEventListener("online", e), window.removeEventListener("offline", s);
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
onSubscribe() {
|
|
498
|
+
this.#t || this.setEventListener(this.#s);
|
|
499
|
+
}
|
|
500
|
+
onUnsubscribe() {
|
|
501
|
+
this.hasListeners() || (this.#t?.(), this.#t = void 0);
|
|
502
|
+
}
|
|
503
|
+
setEventListener(t) {
|
|
504
|
+
this.#s = t, this.#t?.(), this.#t = t(this.setOnline.bind(this));
|
|
505
|
+
}
|
|
506
|
+
setOnline(t) {
|
|
507
|
+
this.#e !== t && (this.#e = t, this.listeners.forEach((s) => {
|
|
508
|
+
s(t);
|
|
509
|
+
}));
|
|
510
|
+
}
|
|
511
|
+
isOnline() {
|
|
512
|
+
return this.#e;
|
|
513
|
+
}
|
|
514
|
+
}, z = new de();
|
|
515
|
+
function fe(t) {
|
|
516
|
+
return Math.min(1e3 * 2 ** t, 3e4);
|
|
517
|
+
}
|
|
518
|
+
function It(t) {
|
|
519
|
+
return (t ?? "online") === "online" ? z.isOnline() : !0;
|
|
520
|
+
}
|
|
521
|
+
var G = class extends Error {
|
|
522
|
+
constructor(t) {
|
|
523
|
+
super("CancelledError"), this.revert = t?.revert, this.silent = t?.silent;
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
function _e(t) {
|
|
527
|
+
return t instanceof G;
|
|
528
|
+
}
|
|
529
|
+
function _t(t) {
|
|
530
|
+
let e = !1, s = 0, r;
|
|
531
|
+
const i = tt(), n = () => i.status !== "pending", a = (d) => {
|
|
532
|
+
if (!n()) {
|
|
533
|
+
const p = new G(d);
|
|
534
|
+
l(p), t.onCancel?.(p);
|
|
535
|
+
}
|
|
536
|
+
}, u = () => {
|
|
537
|
+
e = !0;
|
|
538
|
+
}, o = () => {
|
|
539
|
+
e = !1;
|
|
540
|
+
}, c = () => ot.isFocused() && (t.networkMode === "always" || z.isOnline()) && t.canRun(), h = () => It(t.networkMode) && t.canRun(), f = (d) => {
|
|
541
|
+
n() || (r?.(), i.resolve(d));
|
|
542
|
+
}, l = (d) => {
|
|
543
|
+
n() || (r?.(), i.reject(d));
|
|
544
|
+
}, y = () => new Promise((d) => {
|
|
545
|
+
r = (p) => {
|
|
546
|
+
(n() || c()) && d(p);
|
|
547
|
+
}, t.onPause?.();
|
|
548
|
+
}).then(() => {
|
|
549
|
+
r = void 0, n() || t.onContinue?.();
|
|
550
|
+
}), m = () => {
|
|
551
|
+
if (n())
|
|
552
|
+
return;
|
|
553
|
+
let d;
|
|
554
|
+
const p = s === 0 ? t.initialPromise : void 0;
|
|
555
|
+
try {
|
|
556
|
+
d = p ?? t.fn();
|
|
557
|
+
} catch (v) {
|
|
558
|
+
d = Promise.reject(v);
|
|
559
|
+
}
|
|
560
|
+
Promise.resolve(d).then(f).catch((v) => {
|
|
561
|
+
if (n())
|
|
562
|
+
return;
|
|
563
|
+
const b = t.retry ?? (U.isServer() ? 0 : 3), P = t.retryDelay ?? fe, R = typeof P == "function" ? P(s, v) : P, Q = b === !0 || typeof b == "number" && s < b || typeof b == "function" && b(s, v);
|
|
564
|
+
if (e || !Q) {
|
|
565
|
+
l(v);
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
s++, t.onFail?.(s, v), se(R).then(() => c() ? void 0 : y()).then(() => {
|
|
569
|
+
e ? l(v) : m();
|
|
570
|
+
});
|
|
571
|
+
});
|
|
572
|
+
};
|
|
573
|
+
return {
|
|
574
|
+
promise: i,
|
|
575
|
+
status: () => i.status,
|
|
576
|
+
cancel: a,
|
|
577
|
+
continue: () => (r?.(), i),
|
|
578
|
+
cancelRetry: u,
|
|
579
|
+
continueRetry: o,
|
|
580
|
+
canStart: h,
|
|
581
|
+
start: () => (h() ? m() : y().then(m), i)
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
var At = class {
|
|
585
|
+
#e;
|
|
586
|
+
destroy() {
|
|
587
|
+
this.clearGcTimeout();
|
|
588
|
+
}
|
|
589
|
+
scheduleGc() {
|
|
590
|
+
this.clearGcTimeout(), Z(this.gcTime) && (this.#e = D.setTimeout(() => {
|
|
591
|
+
this.optionalRemove();
|
|
592
|
+
}, this.gcTime));
|
|
593
|
+
}
|
|
594
|
+
updateGcTime(t) {
|
|
595
|
+
this.gcTime = Math.max(
|
|
596
|
+
this.gcTime || 0,
|
|
597
|
+
t ?? (U.isServer() ? 1 / 0 : 300 * 1e3)
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
clearGcTimeout() {
|
|
601
|
+
this.#e !== void 0 && (D.clearTimeout(this.#e), this.#e = void 0);
|
|
602
|
+
}
|
|
603
|
+
};
|
|
604
|
+
function pe(t) {
|
|
605
|
+
return {
|
|
606
|
+
onFetch: (e, s) => {
|
|
607
|
+
const r = e.options, i = e.fetchOptions?.meta?.fetchMore?.direction, n = e.state.data?.pages || [], a = e.state.data?.pageParams || [];
|
|
608
|
+
let u = { pages: [], pageParams: [] }, o = 0;
|
|
609
|
+
const c = async () => {
|
|
610
|
+
let h = !1;
|
|
611
|
+
const f = (m) => {
|
|
612
|
+
Dt(
|
|
613
|
+
m,
|
|
614
|
+
() => e.signal,
|
|
615
|
+
() => h = !0
|
|
616
|
+
);
|
|
617
|
+
}, l = Mt(e.options, e.fetchOptions), y = async (m, d, p) => {
|
|
618
|
+
if (h)
|
|
619
|
+
return Promise.reject(e.signal.reason);
|
|
620
|
+
if (d == null && m.pages.length)
|
|
621
|
+
return Promise.resolve(m);
|
|
622
|
+
const b = (() => {
|
|
623
|
+
const K = {
|
|
624
|
+
client: e.client,
|
|
625
|
+
queryKey: e.queryKey,
|
|
626
|
+
pageParam: d,
|
|
627
|
+
direction: p ? "backward" : "forward",
|
|
628
|
+
meta: e.options.meta
|
|
629
|
+
};
|
|
630
|
+
return f(K), K;
|
|
631
|
+
})(), P = await l(b), { maxPages: R } = e.options, Q = p ? re : Ft;
|
|
632
|
+
return {
|
|
633
|
+
pages: Q(m.pages, P, R),
|
|
634
|
+
pageParams: Q(m.pageParams, d, R)
|
|
635
|
+
};
|
|
636
|
+
};
|
|
637
|
+
if (i && n.length) {
|
|
638
|
+
const m = i === "backward", d = m ? qt : et, p = {
|
|
639
|
+
pages: n,
|
|
640
|
+
pageParams: a
|
|
641
|
+
}, v = d(r, p);
|
|
642
|
+
u = await y(p, v, m);
|
|
643
|
+
} else {
|
|
644
|
+
const m = t ?? n.length;
|
|
645
|
+
do {
|
|
646
|
+
const d = o === 0 ? a[0] ?? r.initialPageParam : et(r, u);
|
|
647
|
+
if (o > 0 && d == null)
|
|
648
|
+
break;
|
|
649
|
+
u = await y(u, d), o++;
|
|
650
|
+
} while (o < m);
|
|
651
|
+
}
|
|
652
|
+
return u;
|
|
653
|
+
};
|
|
654
|
+
e.options.persister ? e.fetchFn = () => e.options.persister?.(
|
|
655
|
+
c,
|
|
656
|
+
{
|
|
657
|
+
client: e.client,
|
|
658
|
+
queryKey: e.queryKey,
|
|
659
|
+
meta: e.options.meta,
|
|
660
|
+
signal: e.signal
|
|
661
|
+
},
|
|
662
|
+
s
|
|
663
|
+
) : e.fetchFn = c;
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
function et(t, { pages: e, pageParams: s }) {
|
|
668
|
+
const r = e.length - 1;
|
|
669
|
+
return e.length > 0 ? t.getNextPageParam(
|
|
670
|
+
e[r],
|
|
671
|
+
e,
|
|
672
|
+
s[r],
|
|
673
|
+
s
|
|
674
|
+
) : void 0;
|
|
675
|
+
}
|
|
676
|
+
function qt(t, { pages: e, pageParams: s }) {
|
|
677
|
+
return e.length > 0 ? t.getPreviousPageParam?.(e[0], e, s[0], s) : void 0;
|
|
678
|
+
}
|
|
679
|
+
function ye(t, e) {
|
|
680
|
+
return e ? et(t, e) != null : !1;
|
|
681
|
+
}
|
|
682
|
+
function ve(t, e) {
|
|
683
|
+
return !e || !t.getPreviousPageParam ? !1 : qt(t, e) != null;
|
|
684
|
+
}
|
|
685
|
+
var me = class extends At {
|
|
686
|
+
#e;
|
|
687
|
+
#t;
|
|
688
|
+
#s;
|
|
689
|
+
#r;
|
|
690
|
+
#i;
|
|
691
|
+
#n;
|
|
692
|
+
#o;
|
|
693
|
+
#a;
|
|
694
|
+
constructor(t) {
|
|
695
|
+
super(), this.#a = !1, this.#o = t.defaultOptions, this.setOptions(t.options), this.observers = [], this.#i = t.client, this.#r = this.#i.getQueryCache(), this.queryKey = t.queryKey, this.queryHash = t.queryHash, this.#t = Ot(this.options), this.state = t.state ?? this.#t, this.scheduleGc();
|
|
696
|
+
}
|
|
697
|
+
get meta() {
|
|
698
|
+
return this.options.meta;
|
|
699
|
+
}
|
|
700
|
+
get queryType() {
|
|
701
|
+
return this.#e;
|
|
702
|
+
}
|
|
703
|
+
get promise() {
|
|
704
|
+
return this.#n?.promise;
|
|
705
|
+
}
|
|
706
|
+
setOptions(t) {
|
|
707
|
+
if (this.options = { ...this.#o, ...t }, t?._type && (this.#e = t._type), this.updateGcTime(this.options.gcTime), this.state && this.state.data === void 0) {
|
|
708
|
+
const e = Ot(this.options);
|
|
709
|
+
e.data !== void 0 && (this.setState(
|
|
710
|
+
bt(e.data, e.dataUpdatedAt)
|
|
711
|
+
), this.#t = e);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
optionalRemove() {
|
|
715
|
+
!this.observers.length && this.state.fetchStatus === "idle" && this.#r.remove(this);
|
|
716
|
+
}
|
|
717
|
+
setData(t, e) {
|
|
718
|
+
const s = Y(this.state.data, t, this.options);
|
|
719
|
+
return this.#u({
|
|
720
|
+
data: s,
|
|
721
|
+
type: "success",
|
|
722
|
+
dataUpdatedAt: e?.updatedAt,
|
|
723
|
+
manual: e?.manual
|
|
724
|
+
}), s;
|
|
725
|
+
}
|
|
726
|
+
setState(t) {
|
|
727
|
+
this.#u({ type: "setState", state: t });
|
|
728
|
+
}
|
|
729
|
+
cancel(t) {
|
|
730
|
+
const e = this.#n?.promise;
|
|
731
|
+
return this.#n?.cancel(t), e ? e.then(O).catch(O) : Promise.resolve();
|
|
732
|
+
}
|
|
733
|
+
destroy() {
|
|
734
|
+
super.destroy(), this.cancel({ silent: !0 });
|
|
735
|
+
}
|
|
736
|
+
get resetState() {
|
|
737
|
+
return this.#t;
|
|
738
|
+
}
|
|
739
|
+
reset() {
|
|
740
|
+
this.destroy(), this.setState(this.resetState);
|
|
741
|
+
}
|
|
742
|
+
isActive() {
|
|
743
|
+
return this.observers.some(
|
|
744
|
+
(t) => S(t.options.enabled, this) !== !1
|
|
745
|
+
);
|
|
746
|
+
}
|
|
747
|
+
isDisabled() {
|
|
748
|
+
return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === ht || !this.isFetched();
|
|
749
|
+
}
|
|
750
|
+
isFetched() {
|
|
751
|
+
return this.state.dataUpdateCount + this.state.errorUpdateCount > 0;
|
|
752
|
+
}
|
|
753
|
+
isStatic() {
|
|
754
|
+
return this.getObserversCount() > 0 ? this.observers.some(
|
|
755
|
+
(t) => F(t.options.staleTime, this) === "static"
|
|
756
|
+
) : !1;
|
|
757
|
+
}
|
|
758
|
+
isStale() {
|
|
759
|
+
return this.getObserversCount() > 0 ? this.observers.some(
|
|
760
|
+
(t) => t.getCurrentResult().isStale
|
|
761
|
+
) : this.state.data === void 0 || this.state.isInvalidated;
|
|
762
|
+
}
|
|
763
|
+
isStaleByTime(t = 0) {
|
|
764
|
+
return this.state.data === void 0 ? !0 : t === "static" ? !1 : this.state.isInvalidated ? !0 : !Et(this.state.dataUpdatedAt, t);
|
|
765
|
+
}
|
|
766
|
+
onFocus() {
|
|
767
|
+
this.observers.find((e) => e.shouldFetchOnWindowFocus())?.refetch({ cancelRefetch: !1 }), this.#n?.continue();
|
|
768
|
+
}
|
|
769
|
+
onOnline() {
|
|
770
|
+
this.observers.find((e) => e.shouldFetchOnReconnect())?.refetch({ cancelRefetch: !1 }), this.#n?.continue();
|
|
771
|
+
}
|
|
772
|
+
addObserver(t) {
|
|
773
|
+
this.observers.includes(t) || (this.observers.push(t), this.clearGcTimeout(), this.#r.notify({ type: "observerAdded", query: this, observer: t }));
|
|
774
|
+
}
|
|
775
|
+
removeObserver(t) {
|
|
776
|
+
this.observers.includes(t) && (this.observers = this.observers.filter((e) => e !== t), this.observers.length || (this.#n && (this.#a || this.#c() ? this.#n.cancel({ revert: !0 }) : this.#n.cancelRetry()), this.scheduleGc()), this.#r.notify({ type: "observerRemoved", query: this, observer: t }));
|
|
777
|
+
}
|
|
778
|
+
getObserversCount() {
|
|
779
|
+
return this.observers.length;
|
|
780
|
+
}
|
|
781
|
+
#c() {
|
|
782
|
+
return this.state.fetchStatus === "paused" && this.state.status === "pending";
|
|
783
|
+
}
|
|
784
|
+
invalidate() {
|
|
785
|
+
this.state.isInvalidated || this.#u({ type: "invalidate" });
|
|
786
|
+
}
|
|
787
|
+
async fetch(t, e) {
|
|
788
|
+
if (this.state.fetchStatus !== "idle" && // If the promise in the retryer is already rejected, we have to definitely
|
|
789
|
+
// re-start the fetch; there is a chance that the query is still in a
|
|
790
|
+
// pending state when that happens
|
|
791
|
+
this.#n?.status() !== "rejected") {
|
|
792
|
+
if (this.state.data !== void 0 && e?.cancelRefetch)
|
|
793
|
+
this.cancel({ silent: !0 });
|
|
794
|
+
else if (this.#n)
|
|
795
|
+
return this.#n.continueRetry(), this.#n.promise;
|
|
796
|
+
}
|
|
797
|
+
if (t && this.setOptions(t), !this.options.queryFn) {
|
|
798
|
+
const o = this.observers.find((c) => c.options.queryFn);
|
|
799
|
+
o && this.setOptions(o.options);
|
|
800
|
+
}
|
|
801
|
+
const s = new AbortController(), r = (o) => {
|
|
802
|
+
Object.defineProperty(o, "signal", {
|
|
803
|
+
enumerable: !0,
|
|
804
|
+
get: () => (this.#a = !0, s.signal)
|
|
805
|
+
});
|
|
806
|
+
}, i = () => {
|
|
807
|
+
const o = Mt(this.options, e), h = (() => {
|
|
808
|
+
const f = {
|
|
809
|
+
client: this.#i,
|
|
810
|
+
queryKey: this.queryKey,
|
|
811
|
+
meta: this.meta
|
|
812
|
+
};
|
|
813
|
+
return r(f), f;
|
|
814
|
+
})();
|
|
815
|
+
return this.#a = !1, this.options.persister ? this.options.persister(
|
|
816
|
+
o,
|
|
817
|
+
h,
|
|
818
|
+
this
|
|
819
|
+
) : o(h);
|
|
820
|
+
}, a = (() => {
|
|
821
|
+
const o = {
|
|
822
|
+
fetchOptions: e,
|
|
823
|
+
options: this.options,
|
|
824
|
+
queryKey: this.queryKey,
|
|
825
|
+
client: this.#i,
|
|
826
|
+
state: this.state,
|
|
827
|
+
fetchFn: i
|
|
828
|
+
};
|
|
829
|
+
return r(o), o;
|
|
830
|
+
})();
|
|
831
|
+
(this.#e === "infinite" ? pe(
|
|
832
|
+
this.options.pages
|
|
833
|
+
) : this.options.behavior)?.onFetch(a, this), this.#s = this.state, (this.state.fetchStatus === "idle" || this.state.fetchMeta !== a.fetchOptions?.meta) && this.#u({ type: "fetch", meta: a.fetchOptions?.meta }), this.#n = _t({
|
|
834
|
+
initialPromise: e?.initialPromise,
|
|
835
|
+
fn: a.fetchFn,
|
|
836
|
+
onCancel: (o) => {
|
|
837
|
+
o instanceof G && o.revert && this.setState({
|
|
838
|
+
...this.#s,
|
|
839
|
+
fetchStatus: "idle"
|
|
840
|
+
}), s.abort();
|
|
841
|
+
},
|
|
842
|
+
onFail: (o, c) => {
|
|
843
|
+
this.#u({ type: "failed", failureCount: o, error: c });
|
|
844
|
+
},
|
|
845
|
+
onPause: () => {
|
|
846
|
+
this.#u({ type: "pause" });
|
|
847
|
+
},
|
|
848
|
+
onContinue: () => {
|
|
849
|
+
this.#u({ type: "continue" });
|
|
850
|
+
},
|
|
851
|
+
retry: a.options.retry,
|
|
852
|
+
retryDelay: a.options.retryDelay,
|
|
853
|
+
networkMode: a.options.networkMode,
|
|
854
|
+
canRun: () => !0
|
|
855
|
+
});
|
|
856
|
+
try {
|
|
857
|
+
const o = await this.#n.start();
|
|
858
|
+
if (o === void 0)
|
|
859
|
+
throw new Error(`${this.queryHash} data is undefined`);
|
|
860
|
+
return this.setData(o), this.#r.config.onSuccess?.(o, this), this.#r.config.onSettled?.(
|
|
861
|
+
o,
|
|
862
|
+
this.state.error,
|
|
863
|
+
this
|
|
864
|
+
), o;
|
|
865
|
+
} catch (o) {
|
|
866
|
+
if (o instanceof G) {
|
|
867
|
+
if (o.silent)
|
|
868
|
+
return this.#n.promise;
|
|
869
|
+
if (o.revert) {
|
|
870
|
+
if (this.state.data === void 0)
|
|
871
|
+
throw o;
|
|
872
|
+
return this.state.data;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
throw this.#u({
|
|
876
|
+
type: "error",
|
|
877
|
+
error: o
|
|
878
|
+
}), this.#r.config.onError?.(
|
|
879
|
+
o,
|
|
880
|
+
this
|
|
881
|
+
), this.#r.config.onSettled?.(
|
|
882
|
+
this.state.data,
|
|
883
|
+
o,
|
|
884
|
+
this
|
|
885
|
+
), o;
|
|
886
|
+
} finally {
|
|
887
|
+
this.scheduleGc();
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
#u(t) {
|
|
891
|
+
const e = (s) => {
|
|
892
|
+
switch (t.type) {
|
|
893
|
+
case "failed":
|
|
894
|
+
return {
|
|
895
|
+
...s,
|
|
896
|
+
fetchFailureCount: t.failureCount,
|
|
897
|
+
fetchFailureReason: t.error
|
|
898
|
+
};
|
|
899
|
+
case "pause":
|
|
900
|
+
return {
|
|
901
|
+
...s,
|
|
902
|
+
fetchStatus: "paused"
|
|
903
|
+
};
|
|
904
|
+
case "continue":
|
|
905
|
+
return {
|
|
906
|
+
...s,
|
|
907
|
+
fetchStatus: "fetching"
|
|
908
|
+
};
|
|
909
|
+
case "fetch":
|
|
910
|
+
return {
|
|
911
|
+
...s,
|
|
912
|
+
...xt(s.data, this.options),
|
|
913
|
+
fetchMeta: t.meta ?? null
|
|
914
|
+
};
|
|
915
|
+
case "success":
|
|
916
|
+
const r = {
|
|
917
|
+
...s,
|
|
918
|
+
...bt(t.data, t.dataUpdatedAt),
|
|
919
|
+
dataUpdateCount: s.dataUpdateCount + 1,
|
|
920
|
+
...!t.manual && {
|
|
921
|
+
fetchStatus: "idle",
|
|
922
|
+
fetchFailureCount: 0,
|
|
923
|
+
fetchFailureReason: null
|
|
924
|
+
}
|
|
925
|
+
};
|
|
926
|
+
return this.#s = t.manual ? r : void 0, r;
|
|
927
|
+
case "error":
|
|
928
|
+
const i = t.error;
|
|
929
|
+
return {
|
|
930
|
+
...s,
|
|
931
|
+
error: i,
|
|
932
|
+
errorUpdateCount: s.errorUpdateCount + 1,
|
|
933
|
+
errorUpdatedAt: Date.now(),
|
|
934
|
+
fetchFailureCount: s.fetchFailureCount + 1,
|
|
935
|
+
fetchFailureReason: i,
|
|
936
|
+
fetchStatus: "idle",
|
|
937
|
+
status: "error",
|
|
938
|
+
// flag existing data as invalidated if we get a background error
|
|
939
|
+
// note that "no data" always means stale so we can set unconditionally here
|
|
940
|
+
isInvalidated: !0
|
|
941
|
+
};
|
|
942
|
+
case "invalidate":
|
|
943
|
+
return {
|
|
944
|
+
...s,
|
|
945
|
+
isInvalidated: !0
|
|
946
|
+
};
|
|
947
|
+
case "setState":
|
|
948
|
+
return {
|
|
949
|
+
...s,
|
|
950
|
+
...t.state
|
|
951
|
+
};
|
|
952
|
+
}
|
|
953
|
+
};
|
|
954
|
+
this.state = e(this.state), g.batch(() => {
|
|
955
|
+
this.observers.forEach((s) => {
|
|
956
|
+
s.onQueryUpdate();
|
|
957
|
+
}), this.#r.notify({ query: this, type: "updated", action: t });
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
};
|
|
961
|
+
function xt(t, e) {
|
|
962
|
+
return {
|
|
963
|
+
fetchFailureCount: 0,
|
|
964
|
+
fetchFailureReason: null,
|
|
965
|
+
fetchStatus: It(e.networkMode) ? "fetching" : "paused",
|
|
966
|
+
...t === void 0 && {
|
|
967
|
+
error: null,
|
|
968
|
+
status: "pending"
|
|
969
|
+
}
|
|
970
|
+
};
|
|
971
|
+
}
|
|
972
|
+
function bt(t, e) {
|
|
973
|
+
return {
|
|
974
|
+
data: t,
|
|
975
|
+
dataUpdatedAt: e ?? Date.now(),
|
|
976
|
+
error: null,
|
|
977
|
+
isInvalidated: !1,
|
|
978
|
+
status: "success"
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
function Ot(t) {
|
|
982
|
+
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;
|
|
983
|
+
return {
|
|
984
|
+
data: e,
|
|
985
|
+
dataUpdateCount: 0,
|
|
986
|
+
dataUpdatedAt: s ? r ?? Date.now() : 0,
|
|
987
|
+
error: null,
|
|
988
|
+
errorUpdateCount: 0,
|
|
989
|
+
errorUpdatedAt: 0,
|
|
990
|
+
fetchFailureCount: 0,
|
|
991
|
+
fetchFailureReason: null,
|
|
992
|
+
fetchMeta: null,
|
|
993
|
+
isInvalidated: !1,
|
|
994
|
+
status: s ? "success" : "pending",
|
|
995
|
+
fetchStatus: "idle"
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
var k = class extends I {
|
|
999
|
+
constructor(t, e) {
|
|
1000
|
+
super(), this.options = e, this.#e = t, this.#a = null, this.#o = tt(), this.bindMethods(), this.setOptions(e);
|
|
1001
|
+
}
|
|
1002
|
+
#e;
|
|
1003
|
+
#t = void 0;
|
|
1004
|
+
#s = void 0;
|
|
1005
|
+
#r = void 0;
|
|
1006
|
+
#i;
|
|
1007
|
+
#n;
|
|
1008
|
+
#o;
|
|
1009
|
+
#a;
|
|
1010
|
+
#c;
|
|
1011
|
+
#u;
|
|
1012
|
+
// This property keeps track of the last query with defined data.
|
|
1013
|
+
// It will be used to pass the previous data and query to the placeholder function between renders.
|
|
1014
|
+
#f;
|
|
1015
|
+
#l;
|
|
1016
|
+
#p;
|
|
1017
|
+
#h;
|
|
1018
|
+
#y = /* @__PURE__ */ new Set();
|
|
1019
|
+
bindMethods() {
|
|
1020
|
+
this.refetch = this.refetch.bind(this);
|
|
1021
|
+
}
|
|
1022
|
+
onSubscribe() {
|
|
1023
|
+
this.listeners.size === 1 && (this.#t.addObserver(this), St(this.#t, this.options) ? this.#d() : this.updateResult(), this.#b());
|
|
1024
|
+
}
|
|
1025
|
+
onUnsubscribe() {
|
|
1026
|
+
this.hasListeners() || this.destroy();
|
|
1027
|
+
}
|
|
1028
|
+
shouldFetchOnReconnect() {
|
|
1029
|
+
return st(
|
|
1030
|
+
this.#t,
|
|
1031
|
+
this.options,
|
|
1032
|
+
this.options.refetchOnReconnect
|
|
1033
|
+
);
|
|
1034
|
+
}
|
|
1035
|
+
shouldFetchOnWindowFocus() {
|
|
1036
|
+
return st(
|
|
1037
|
+
this.#t,
|
|
1038
|
+
this.options,
|
|
1039
|
+
this.options.refetchOnWindowFocus
|
|
1040
|
+
);
|
|
1041
|
+
}
|
|
1042
|
+
destroy() {
|
|
1043
|
+
this.listeners = /* @__PURE__ */ new Set(), this.#O(), this.#S(), this.#t.removeObserver(this);
|
|
1044
|
+
}
|
|
1045
|
+
setOptions(t) {
|
|
1046
|
+
const e = this.options, s = this.#t;
|
|
1047
|
+
if (this.options = this.#e.defaultQueryOptions(t), this.options.enabled !== void 0 && typeof this.options.enabled != "boolean" && typeof this.options.enabled != "function" && typeof S(this.options.enabled, this.#t) != "boolean")
|
|
1048
|
+
throw new Error(
|
|
1049
|
+
"Expected enabled to be a boolean or a callback that returns a boolean"
|
|
1050
|
+
);
|
|
1051
|
+
this.#w(), this.#t.setOptions(this.options), e._defaulted && !x(this.options, e) && this.#e.getQueryCache().notify({
|
|
1052
|
+
type: "observerOptionsUpdated",
|
|
1053
|
+
query: this.#t,
|
|
1054
|
+
observer: this
|
|
1055
|
+
});
|
|
1056
|
+
const r = this.hasListeners();
|
|
1057
|
+
r && wt(
|
|
1058
|
+
this.#t,
|
|
1059
|
+
s,
|
|
1060
|
+
this.options,
|
|
1061
|
+
e
|
|
1062
|
+
) && this.#d(), this.updateResult(), r && (this.#t !== s || S(this.options.enabled, this.#t) !== S(e.enabled, this.#t) || F(this.options.staleTime, this.#t) !== F(e.staleTime, this.#t)) && this.#v();
|
|
1063
|
+
const i = this.#m();
|
|
1064
|
+
r && (this.#t !== s || S(this.options.enabled, this.#t) !== S(e.enabled, this.#t) || i !== this.#h) && this.#g(i);
|
|
1065
|
+
}
|
|
1066
|
+
getOptimisticResult(t) {
|
|
1067
|
+
const e = this.#e.getQueryCache().build(this.#e, t), s = this.createResult(e, t);
|
|
1068
|
+
return be(this, s) && (this.#r = s, this.#n = this.options, this.#i = this.#t.state), s;
|
|
1069
|
+
}
|
|
1070
|
+
getCurrentResult() {
|
|
1071
|
+
return this.#r;
|
|
1072
|
+
}
|
|
1073
|
+
trackResult(t, e) {
|
|
1074
|
+
return new Proxy(t, {
|
|
1075
|
+
get: (s, r) => (this.trackProp(r), e?.(r), r === "promise" && (this.trackProp("data"), !this.options.experimental_prefetchInRender && this.#o.status === "pending" && this.#o.reject(
|
|
1076
|
+
new Error(
|
|
1077
|
+
"experimental_prefetchInRender feature flag is not enabled"
|
|
1078
|
+
)
|
|
1079
|
+
)), Reflect.get(s, r))
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
trackProp(t) {
|
|
1083
|
+
this.#y.add(t);
|
|
1084
|
+
}
|
|
1085
|
+
getCurrentQuery() {
|
|
1086
|
+
return this.#t;
|
|
1087
|
+
}
|
|
1088
|
+
refetch({ ...t } = {}) {
|
|
1089
|
+
return this.fetch({
|
|
1090
|
+
...t
|
|
1091
|
+
});
|
|
1092
|
+
}
|
|
1093
|
+
fetchOptimistic(t) {
|
|
1094
|
+
const e = this.#e.defaultQueryOptions(t), s = this.#e.getQueryCache().build(this.#e, e);
|
|
1095
|
+
return s.fetch().then(() => this.createResult(s, e));
|
|
1096
|
+
}
|
|
1097
|
+
fetch(t) {
|
|
1098
|
+
return this.#d({
|
|
1099
|
+
...t,
|
|
1100
|
+
cancelRefetch: t.cancelRefetch ?? !0
|
|
1101
|
+
}).then(() => (this.updateResult(), this.#r));
|
|
1102
|
+
}
|
|
1103
|
+
#d(t) {
|
|
1104
|
+
this.#w();
|
|
1105
|
+
let e = this.#t.fetch(
|
|
1106
|
+
this.options,
|
|
1107
|
+
t
|
|
1108
|
+
);
|
|
1109
|
+
return t?.throwOnError || (e = e.catch(O)), e;
|
|
1110
|
+
}
|
|
1111
|
+
#v() {
|
|
1112
|
+
this.#O();
|
|
1113
|
+
const t = F(
|
|
1114
|
+
this.options.staleTime,
|
|
1115
|
+
this.#t
|
|
1116
|
+
);
|
|
1117
|
+
if (U.isServer() || this.#r.isStale || !Z(t))
|
|
1118
|
+
return;
|
|
1119
|
+
const s = Et(this.#r.dataUpdatedAt, t) + 1;
|
|
1120
|
+
this.#l = D.setTimeout(() => {
|
|
1121
|
+
this.#r.isStale || this.updateResult();
|
|
1122
|
+
}, s);
|
|
1123
|
+
}
|
|
1124
|
+
#m() {
|
|
1125
|
+
return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(this.#t) : this.options.refetchInterval) ?? !1;
|
|
1126
|
+
}
|
|
1127
|
+
#g(t) {
|
|
1128
|
+
this.#S(), this.#h = t, !(U.isServer() || S(this.options.enabled, this.#t) === !1 || !Z(this.#h) || this.#h === 0) && (this.#p = D.setInterval(() => {
|
|
1129
|
+
(this.options.refetchIntervalInBackground || ot.isFocused()) && this.#d();
|
|
1130
|
+
}, this.#h));
|
|
1131
|
+
}
|
|
1132
|
+
#b() {
|
|
1133
|
+
this.#v(), this.#g(this.#m());
|
|
1134
|
+
}
|
|
1135
|
+
#O() {
|
|
1136
|
+
this.#l !== void 0 && (D.clearTimeout(this.#l), this.#l = void 0);
|
|
1137
|
+
}
|
|
1138
|
+
#S() {
|
|
1139
|
+
this.#p !== void 0 && (D.clearInterval(this.#p), this.#p = void 0);
|
|
1140
|
+
}
|
|
1141
|
+
createResult(t, e) {
|
|
1142
|
+
const s = this.#t, r = this.options, i = this.#r, n = this.#i, a = this.#n, o = t !== s ? t.state : this.#s, { state: c } = t;
|
|
1143
|
+
let h = { ...c }, f = !1, l;
|
|
1144
|
+
if (e._optimisticResults) {
|
|
1145
|
+
const w = this.hasListeners(), A = !w && St(t, e), L = w && wt(t, s, e, r);
|
|
1146
|
+
(A || L) && (h = {
|
|
1147
|
+
...h,
|
|
1148
|
+
...xt(c.data, t.options)
|
|
1149
|
+
}), e._optimisticResults === "isRestoring" && (h.fetchStatus = "idle");
|
|
1150
|
+
}
|
|
1151
|
+
let { error: y, errorUpdatedAt: m, status: d } = h;
|
|
1152
|
+
l = h.data;
|
|
1153
|
+
let p = !1;
|
|
1154
|
+
if (e.placeholderData !== void 0 && l === void 0 && d === "pending") {
|
|
1155
|
+
let w;
|
|
1156
|
+
i?.isPlaceholderData && e.placeholderData === a?.placeholderData ? (w = i.data, p = !0) : w = typeof e.placeholderData == "function" ? e.placeholderData(
|
|
1157
|
+
this.#f?.state.data,
|
|
1158
|
+
this.#f
|
|
1159
|
+
) : e.placeholderData, w !== void 0 && (d = "success", l = Y(
|
|
1160
|
+
i?.data,
|
|
1161
|
+
w,
|
|
1162
|
+
e
|
|
1163
|
+
), f = !0);
|
|
1164
|
+
}
|
|
1165
|
+
if (e.select && l !== void 0 && !p)
|
|
1166
|
+
if (i && l === n?.data && e.select === this.#c)
|
|
1167
|
+
l = this.#u;
|
|
1168
|
+
else
|
|
1169
|
+
try {
|
|
1170
|
+
this.#c = e.select, l = e.select(l), l = Y(i?.data, l, e), this.#u = l, this.#a = null;
|
|
1171
|
+
} catch (w) {
|
|
1172
|
+
this.#a = w;
|
|
1173
|
+
}
|
|
1174
|
+
this.#a && (y = this.#a, l = this.#u, m = Date.now(), d = "error");
|
|
1175
|
+
const v = h.fetchStatus === "fetching", b = d === "pending", P = d === "error", R = b && v, Q = l !== void 0, C = {
|
|
1176
|
+
status: d,
|
|
1177
|
+
fetchStatus: h.fetchStatus,
|
|
1178
|
+
isPending: b,
|
|
1179
|
+
isSuccess: d === "success",
|
|
1180
|
+
isError: P,
|
|
1181
|
+
isInitialLoading: R,
|
|
1182
|
+
isLoading: R,
|
|
1183
|
+
data: l,
|
|
1184
|
+
dataUpdatedAt: h.dataUpdatedAt,
|
|
1185
|
+
error: y,
|
|
1186
|
+
errorUpdatedAt: m,
|
|
1187
|
+
failureCount: h.fetchFailureCount,
|
|
1188
|
+
failureReason: h.fetchFailureReason,
|
|
1189
|
+
errorUpdateCount: h.errorUpdateCount,
|
|
1190
|
+
isFetched: t.isFetched(),
|
|
1191
|
+
isFetchedAfterMount: h.dataUpdateCount > o.dataUpdateCount || h.errorUpdateCount > o.errorUpdateCount,
|
|
1192
|
+
isFetching: v,
|
|
1193
|
+
isRefetching: v && !b,
|
|
1194
|
+
isLoadingError: P && !Q,
|
|
1195
|
+
isPaused: h.fetchStatus === "paused",
|
|
1196
|
+
isPlaceholderData: f,
|
|
1197
|
+
isRefetchError: P && Q,
|
|
1198
|
+
isStale: lt(t, e),
|
|
1199
|
+
refetch: this.refetch,
|
|
1200
|
+
promise: this.#o,
|
|
1201
|
+
isEnabled: S(e.enabled, t) !== !1
|
|
1202
|
+
};
|
|
1203
|
+
if (this.options.experimental_prefetchInRender) {
|
|
1204
|
+
const w = C.data !== void 0, A = C.status === "error" && !w, L = (H) => {
|
|
1205
|
+
A ? H.reject(C.error) : w && H.resolve(C.data);
|
|
1206
|
+
}, ft = () => {
|
|
1207
|
+
const H = this.#o = C.promise = tt();
|
|
1208
|
+
L(H);
|
|
1209
|
+
}, N = this.#o;
|
|
1210
|
+
switch (N.status) {
|
|
1211
|
+
case "pending":
|
|
1212
|
+
t.queryHash === s.queryHash && L(N);
|
|
1213
|
+
break;
|
|
1214
|
+
case "fulfilled":
|
|
1215
|
+
(A || C.data !== N.value) && ft();
|
|
1216
|
+
break;
|
|
1217
|
+
case "rejected":
|
|
1218
|
+
(!A || C.error !== N.reason) && ft();
|
|
1219
|
+
break;
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
return C;
|
|
1223
|
+
}
|
|
1224
|
+
updateResult() {
|
|
1225
|
+
const t = this.#r, e = this.createResult(this.#t, this.options);
|
|
1226
|
+
if (this.#i = this.#t.state, this.#n = this.options, this.#i.data !== void 0 && (this.#f = this.#t), x(e, t))
|
|
1227
|
+
return;
|
|
1228
|
+
this.#r = e;
|
|
1229
|
+
const s = () => {
|
|
1230
|
+
if (!t)
|
|
1231
|
+
return !0;
|
|
1232
|
+
const { notifyOnChangeProps: r } = this.options, i = typeof r == "function" ? r() : r;
|
|
1233
|
+
if (i === "all" || !i && !this.#y.size)
|
|
1234
|
+
return !0;
|
|
1235
|
+
const n = new Set(
|
|
1236
|
+
i ?? this.#y
|
|
1237
|
+
);
|
|
1238
|
+
return this.options.throwOnError && n.add("error"), Object.keys(this.#r).some((a) => {
|
|
1239
|
+
const u = a;
|
|
1240
|
+
return this.#r[u] !== t[u] && n.has(u);
|
|
1241
|
+
});
|
|
1242
|
+
};
|
|
1243
|
+
this.#P({ listeners: s() });
|
|
1244
|
+
}
|
|
1245
|
+
#w() {
|
|
1246
|
+
const t = this.#e.getQueryCache().build(this.#e, this.options);
|
|
1247
|
+
if (t === this.#t)
|
|
1248
|
+
return;
|
|
1249
|
+
const e = this.#t;
|
|
1250
|
+
this.#t = t, this.#s = t.state, this.hasListeners() && (e?.removeObserver(this), t.addObserver(this));
|
|
1251
|
+
}
|
|
1252
|
+
onQueryUpdate() {
|
|
1253
|
+
this.updateResult(), this.hasListeners() && this.#b();
|
|
1254
|
+
}
|
|
1255
|
+
#P(t) {
|
|
1256
|
+
g.batch(() => {
|
|
1257
|
+
t.listeners && this.listeners.forEach((e) => {
|
|
1258
|
+
e(this.#r);
|
|
1259
|
+
}), this.#e.getQueryCache().notify({
|
|
1260
|
+
query: this.#t,
|
|
1261
|
+
type: "observerResultsUpdated"
|
|
1262
|
+
});
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
};
|
|
1266
|
+
function ge(t, e) {
|
|
1267
|
+
return S(e.enabled, t) !== !1 && t.state.data === void 0 && !(t.state.status === "error" && S(e.retryOnMount, t) === !1);
|
|
1268
|
+
}
|
|
1269
|
+
function St(t, e) {
|
|
1270
|
+
return ge(t, e) || t.state.data !== void 0 && st(t, e, e.refetchOnMount);
|
|
1271
|
+
}
|
|
1272
|
+
function st(t, e, s) {
|
|
1273
|
+
if (S(e.enabled, t) !== !1 && F(e.staleTime, t) !== "static") {
|
|
1274
|
+
const r = typeof s == "function" ? s(t) : s;
|
|
1275
|
+
return r === "always" || r !== !1 && lt(t, e);
|
|
1276
|
+
}
|
|
1277
|
+
return !1;
|
|
1278
|
+
}
|
|
1279
|
+
function wt(t, e, s, r) {
|
|
1280
|
+
return (t !== e || S(r.enabled, t) === !1) && (!s.suspense || t.state.status !== "error") && lt(t, s);
|
|
1281
|
+
}
|
|
1282
|
+
function lt(t, e) {
|
|
1283
|
+
return S(e.enabled, t) !== !1 && t.isStaleByTime(F(e.staleTime, t));
|
|
1284
|
+
}
|
|
1285
|
+
function be(t, e) {
|
|
1286
|
+
return !x(t.getCurrentResult(), e);
|
|
1287
|
+
}
|
|
1288
|
+
var Ut = class extends k {
|
|
1289
|
+
constructor(t, e) {
|
|
1290
|
+
super(t, e);
|
|
1291
|
+
}
|
|
1292
|
+
bindMethods() {
|
|
1293
|
+
super.bindMethods(), this.fetchNextPage = this.fetchNextPage.bind(this), this.fetchPreviousPage = this.fetchPreviousPage.bind(this);
|
|
1294
|
+
}
|
|
1295
|
+
setOptions(t) {
|
|
1296
|
+
t._type = "infinite", super.setOptions(t);
|
|
1297
|
+
}
|
|
1298
|
+
getOptimisticResult(t) {
|
|
1299
|
+
return t._type = "infinite", super.getOptimisticResult(t);
|
|
1300
|
+
}
|
|
1301
|
+
fetchNextPage(t) {
|
|
1302
|
+
return this.fetch({
|
|
1303
|
+
...t,
|
|
1304
|
+
meta: {
|
|
1305
|
+
fetchMore: { direction: "forward" }
|
|
1306
|
+
}
|
|
1307
|
+
});
|
|
1308
|
+
}
|
|
1309
|
+
fetchPreviousPage(t) {
|
|
1310
|
+
return this.fetch({
|
|
1311
|
+
...t,
|
|
1312
|
+
meta: {
|
|
1313
|
+
fetchMore: { direction: "backward" }
|
|
1314
|
+
}
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
createResult(t, e) {
|
|
1318
|
+
const { state: s } = t, r = super.createResult(t, e), { isFetching: i, isRefetching: n, isError: a, isRefetchError: u } = r, o = s.fetchMeta?.fetchMore?.direction, c = a && o === "forward", h = i && o === "forward", f = a && o === "backward", l = i && o === "backward";
|
|
1319
|
+
return {
|
|
1320
|
+
...r,
|
|
1321
|
+
fetchNextPage: this.fetchNextPage,
|
|
1322
|
+
fetchPreviousPage: this.fetchPreviousPage,
|
|
1323
|
+
hasNextPage: ye(e, s.data),
|
|
1324
|
+
hasPreviousPage: ve(e, s.data),
|
|
1325
|
+
isFetchNextPageError: c,
|
|
1326
|
+
isFetchingNextPage: h,
|
|
1327
|
+
isFetchPreviousPageError: f,
|
|
1328
|
+
isFetchingPreviousPage: l,
|
|
1329
|
+
isRefetchError: u && !c && !f,
|
|
1330
|
+
isRefetching: n && !h && !l
|
|
1331
|
+
};
|
|
1332
|
+
}
|
|
1333
|
+
}, Oe = class extends At {
|
|
1334
|
+
#e;
|
|
1335
|
+
#t;
|
|
1336
|
+
#s;
|
|
1337
|
+
#r;
|
|
1338
|
+
constructor(t) {
|
|
1339
|
+
super(), this.#e = t.client, this.mutationId = t.mutationId, this.#s = t.mutationCache, this.#t = [], this.state = t.state || jt(), this.setOptions(t.options), this.scheduleGc();
|
|
1340
|
+
}
|
|
1341
|
+
setOptions(t) {
|
|
1342
|
+
this.options = t, this.updateGcTime(this.options.gcTime);
|
|
1343
|
+
}
|
|
1344
|
+
get meta() {
|
|
1345
|
+
return this.options.meta;
|
|
1346
|
+
}
|
|
1347
|
+
addObserver(t) {
|
|
1348
|
+
this.#t.includes(t) || (this.#t.push(t), this.clearGcTimeout(), this.#s.notify({
|
|
1349
|
+
type: "observerAdded",
|
|
1350
|
+
mutation: this,
|
|
1351
|
+
observer: t
|
|
1352
|
+
}));
|
|
1353
|
+
}
|
|
1354
|
+
removeObserver(t) {
|
|
1355
|
+
this.#t = this.#t.filter((e) => e !== t), this.scheduleGc(), this.#s.notify({
|
|
1356
|
+
type: "observerRemoved",
|
|
1357
|
+
mutation: this,
|
|
1358
|
+
observer: t
|
|
1359
|
+
});
|
|
1360
|
+
}
|
|
1361
|
+
optionalRemove() {
|
|
1362
|
+
this.#t.length || (this.state.status === "pending" ? this.scheduleGc() : this.#s.remove(this));
|
|
1363
|
+
}
|
|
1364
|
+
continue() {
|
|
1365
|
+
return this.#r?.continue() ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
|
|
1366
|
+
this.execute(this.state.variables);
|
|
1367
|
+
}
|
|
1368
|
+
async execute(t) {
|
|
1369
|
+
const e = () => {
|
|
1370
|
+
this.#i({ type: "continue" });
|
|
1371
|
+
}, s = {
|
|
1372
|
+
client: this.#e,
|
|
1373
|
+
meta: this.options.meta,
|
|
1374
|
+
mutationKey: this.options.mutationKey
|
|
1375
|
+
};
|
|
1376
|
+
this.#r = _t({
|
|
1377
|
+
fn: () => this.options.mutationFn ? this.options.mutationFn(t, s) : Promise.reject(new Error("No mutationFn found")),
|
|
1378
|
+
onFail: (n, a) => {
|
|
1379
|
+
this.#i({ type: "failed", failureCount: n, error: a });
|
|
1380
|
+
},
|
|
1381
|
+
onPause: () => {
|
|
1382
|
+
this.#i({ type: "pause" });
|
|
1383
|
+
},
|
|
1384
|
+
onContinue: e,
|
|
1385
|
+
retry: this.options.retry ?? 0,
|
|
1386
|
+
retryDelay: this.options.retryDelay,
|
|
1387
|
+
networkMode: this.options.networkMode,
|
|
1388
|
+
canRun: () => this.#s.canRun(this)
|
|
1389
|
+
});
|
|
1390
|
+
const r = this.state.status === "pending", i = !this.#r.canStart();
|
|
1391
|
+
try {
|
|
1392
|
+
if (r)
|
|
1393
|
+
e();
|
|
1394
|
+
else {
|
|
1395
|
+
this.#i({ type: "pending", variables: t, isPaused: i }), this.#s.config.onMutate && await this.#s.config.onMutate(
|
|
1396
|
+
t,
|
|
1397
|
+
this,
|
|
1398
|
+
s
|
|
1399
|
+
);
|
|
1400
|
+
const a = await this.options.onMutate?.(
|
|
1401
|
+
t,
|
|
1402
|
+
s
|
|
1403
|
+
);
|
|
1404
|
+
a !== this.state.context && this.#i({
|
|
1405
|
+
type: "pending",
|
|
1406
|
+
context: a,
|
|
1407
|
+
variables: t,
|
|
1408
|
+
isPaused: i
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1411
|
+
const n = await this.#r.start();
|
|
1412
|
+
return await this.#s.config.onSuccess?.(
|
|
1413
|
+
n,
|
|
1414
|
+
t,
|
|
1415
|
+
this.state.context,
|
|
1416
|
+
this,
|
|
1417
|
+
s
|
|
1418
|
+
), await this.options.onSuccess?.(
|
|
1419
|
+
n,
|
|
1420
|
+
t,
|
|
1421
|
+
this.state.context,
|
|
1422
|
+
s
|
|
1423
|
+
), await this.#s.config.onSettled?.(
|
|
1424
|
+
n,
|
|
1425
|
+
null,
|
|
1426
|
+
this.state.variables,
|
|
1427
|
+
this.state.context,
|
|
1428
|
+
this,
|
|
1429
|
+
s
|
|
1430
|
+
), await this.options.onSettled?.(
|
|
1431
|
+
n,
|
|
1432
|
+
null,
|
|
1433
|
+
t,
|
|
1434
|
+
this.state.context,
|
|
1435
|
+
s
|
|
1436
|
+
), this.#i({ type: "success", data: n }), n;
|
|
1437
|
+
} catch (n) {
|
|
1438
|
+
try {
|
|
1439
|
+
await this.#s.config.onError?.(
|
|
1440
|
+
n,
|
|
1441
|
+
t,
|
|
1442
|
+
this.state.context,
|
|
1443
|
+
this,
|
|
1444
|
+
s
|
|
1445
|
+
);
|
|
1446
|
+
} catch (a) {
|
|
1447
|
+
Promise.reject(a);
|
|
1448
|
+
}
|
|
1449
|
+
try {
|
|
1450
|
+
await this.options.onError?.(
|
|
1451
|
+
n,
|
|
1452
|
+
t,
|
|
1453
|
+
this.state.context,
|
|
1454
|
+
s
|
|
1455
|
+
);
|
|
1456
|
+
} catch (a) {
|
|
1457
|
+
Promise.reject(a);
|
|
1458
|
+
}
|
|
1459
|
+
try {
|
|
1460
|
+
await this.#s.config.onSettled?.(
|
|
1461
|
+
void 0,
|
|
1462
|
+
n,
|
|
1463
|
+
this.state.variables,
|
|
1464
|
+
this.state.context,
|
|
1465
|
+
this,
|
|
1466
|
+
s
|
|
1467
|
+
);
|
|
1468
|
+
} catch (a) {
|
|
1469
|
+
Promise.reject(a);
|
|
1470
|
+
}
|
|
1471
|
+
try {
|
|
1472
|
+
await this.options.onSettled?.(
|
|
1473
|
+
void 0,
|
|
1474
|
+
n,
|
|
1475
|
+
t,
|
|
1476
|
+
this.state.context,
|
|
1477
|
+
s
|
|
1478
|
+
);
|
|
1479
|
+
} catch (a) {
|
|
1480
|
+
Promise.reject(a);
|
|
1481
|
+
}
|
|
1482
|
+
throw this.#i({ type: "error", error: n }), n;
|
|
1483
|
+
} finally {
|
|
1484
|
+
this.#s.runNext(this);
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
#i(t) {
|
|
1488
|
+
const e = (s) => {
|
|
1489
|
+
switch (t.type) {
|
|
1490
|
+
case "failed":
|
|
1491
|
+
return {
|
|
1492
|
+
...s,
|
|
1493
|
+
failureCount: t.failureCount,
|
|
1494
|
+
failureReason: t.error
|
|
1495
|
+
};
|
|
1496
|
+
case "pause":
|
|
1497
|
+
return {
|
|
1498
|
+
...s,
|
|
1499
|
+
isPaused: !0
|
|
1500
|
+
};
|
|
1501
|
+
case "continue":
|
|
1502
|
+
return {
|
|
1503
|
+
...s,
|
|
1504
|
+
isPaused: !1
|
|
1505
|
+
};
|
|
1506
|
+
case "pending":
|
|
1507
|
+
return {
|
|
1508
|
+
...s,
|
|
1509
|
+
context: t.context,
|
|
1510
|
+
data: void 0,
|
|
1511
|
+
failureCount: 0,
|
|
1512
|
+
failureReason: null,
|
|
1513
|
+
error: null,
|
|
1514
|
+
isPaused: t.isPaused,
|
|
1515
|
+
status: "pending",
|
|
1516
|
+
variables: t.variables,
|
|
1517
|
+
submittedAt: Date.now()
|
|
1518
|
+
};
|
|
1519
|
+
case "success":
|
|
1520
|
+
return {
|
|
1521
|
+
...s,
|
|
1522
|
+
data: t.data,
|
|
1523
|
+
failureCount: 0,
|
|
1524
|
+
failureReason: null,
|
|
1525
|
+
error: null,
|
|
1526
|
+
status: "success",
|
|
1527
|
+
isPaused: !1
|
|
1528
|
+
};
|
|
1529
|
+
case "error":
|
|
1530
|
+
return {
|
|
1531
|
+
...s,
|
|
1532
|
+
data: void 0,
|
|
1533
|
+
error: t.error,
|
|
1534
|
+
failureCount: s.failureCount + 1,
|
|
1535
|
+
failureReason: t.error,
|
|
1536
|
+
isPaused: !1,
|
|
1537
|
+
status: "error"
|
|
1538
|
+
};
|
|
1539
|
+
}
|
|
1540
|
+
};
|
|
1541
|
+
this.state = e(this.state), g.batch(() => {
|
|
1542
|
+
this.#t.forEach((s) => {
|
|
1543
|
+
s.onMutationUpdate(t);
|
|
1544
|
+
}), this.#s.notify({
|
|
1545
|
+
mutation: this,
|
|
1546
|
+
type: "updated",
|
|
1547
|
+
action: t
|
|
1548
|
+
});
|
|
1549
|
+
});
|
|
1550
|
+
}
|
|
1551
|
+
};
|
|
1552
|
+
function jt() {
|
|
1553
|
+
return {
|
|
1554
|
+
context: void 0,
|
|
1555
|
+
data: void 0,
|
|
1556
|
+
error: null,
|
|
1557
|
+
failureCount: 0,
|
|
1558
|
+
failureReason: null,
|
|
1559
|
+
isPaused: !1,
|
|
1560
|
+
status: "idle",
|
|
1561
|
+
variables: void 0,
|
|
1562
|
+
submittedAt: 0
|
|
1563
|
+
};
|
|
1564
|
+
}
|
|
1565
|
+
var Se = class extends I {
|
|
1566
|
+
constructor(t = {}) {
|
|
1567
|
+
super(), this.config = t, this.#e = /* @__PURE__ */ new Set(), this.#t = /* @__PURE__ */ new Map(), this.#s = 0;
|
|
1568
|
+
}
|
|
1569
|
+
#e;
|
|
1570
|
+
#t;
|
|
1571
|
+
#s;
|
|
1572
|
+
build(t, e, s) {
|
|
1573
|
+
const r = new Oe({
|
|
1574
|
+
client: t,
|
|
1575
|
+
mutationCache: this,
|
|
1576
|
+
mutationId: ++this.#s,
|
|
1577
|
+
options: t.defaultMutationOptions(e),
|
|
1578
|
+
state: s
|
|
1579
|
+
});
|
|
1580
|
+
return this.add(r), r;
|
|
1581
|
+
}
|
|
1582
|
+
add(t) {
|
|
1583
|
+
this.#e.add(t);
|
|
1584
|
+
const e = B(t);
|
|
1585
|
+
if (typeof e == "string") {
|
|
1586
|
+
const s = this.#t.get(e);
|
|
1587
|
+
s ? s.push(t) : this.#t.set(e, [t]);
|
|
1588
|
+
}
|
|
1589
|
+
this.notify({ type: "added", mutation: t });
|
|
1590
|
+
}
|
|
1591
|
+
remove(t) {
|
|
1592
|
+
if (this.#e.delete(t)) {
|
|
1593
|
+
const e = B(t);
|
|
1594
|
+
if (typeof e == "string") {
|
|
1595
|
+
const s = this.#t.get(e);
|
|
1596
|
+
if (s)
|
|
1597
|
+
if (s.length > 1) {
|
|
1598
|
+
const r = s.indexOf(t);
|
|
1599
|
+
r !== -1 && s.splice(r, 1);
|
|
1600
|
+
} else s[0] === t && this.#t.delete(e);
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
this.notify({ type: "removed", mutation: t });
|
|
1604
|
+
}
|
|
1605
|
+
canRun(t) {
|
|
1606
|
+
const e = B(t);
|
|
1607
|
+
if (typeof e == "string") {
|
|
1608
|
+
const r = this.#t.get(e)?.find(
|
|
1609
|
+
(i) => i.state.status === "pending"
|
|
1610
|
+
);
|
|
1611
|
+
return !r || r === t;
|
|
1612
|
+
} else
|
|
1613
|
+
return !0;
|
|
1614
|
+
}
|
|
1615
|
+
runNext(t) {
|
|
1616
|
+
const e = B(t);
|
|
1617
|
+
return typeof e == "string" ? this.#t.get(e)?.find((r) => r !== t && r.state.isPaused)?.continue() ?? Promise.resolve() : Promise.resolve();
|
|
1618
|
+
}
|
|
1619
|
+
clear() {
|
|
1620
|
+
g.batch(() => {
|
|
1621
|
+
this.#e.forEach((t) => {
|
|
1622
|
+
this.notify({ type: "removed", mutation: t });
|
|
1623
|
+
}), this.#e.clear(), this.#t.clear();
|
|
1624
|
+
});
|
|
1625
|
+
}
|
|
1626
|
+
getAll() {
|
|
1627
|
+
return Array.from(this.#e);
|
|
1628
|
+
}
|
|
1629
|
+
find(t) {
|
|
1630
|
+
const e = { exact: !0, ...t };
|
|
1631
|
+
return this.getAll().find(
|
|
1632
|
+
(s) => yt(e, s)
|
|
1633
|
+
);
|
|
1634
|
+
}
|
|
1635
|
+
findAll(t = {}) {
|
|
1636
|
+
return this.getAll().filter((e) => yt(t, e));
|
|
1637
|
+
}
|
|
1638
|
+
notify(t) {
|
|
1639
|
+
g.batch(() => {
|
|
1640
|
+
this.listeners.forEach((e) => {
|
|
1641
|
+
e(t);
|
|
1642
|
+
});
|
|
1643
|
+
});
|
|
1644
|
+
}
|
|
1645
|
+
resumePausedMutations() {
|
|
1646
|
+
const t = this.getAll().filter((e) => e.state.isPaused);
|
|
1647
|
+
return g.batch(
|
|
1648
|
+
() => Promise.all(
|
|
1649
|
+
t.map((e) => e.continue().catch(O))
|
|
1650
|
+
)
|
|
1651
|
+
);
|
|
1652
|
+
}
|
|
1653
|
+
};
|
|
1654
|
+
function B(t) {
|
|
1655
|
+
return t.options.scope?.id;
|
|
1656
|
+
}
|
|
1657
|
+
var we = class extends I {
|
|
1658
|
+
#e;
|
|
1659
|
+
#t = void 0;
|
|
1660
|
+
#s;
|
|
1661
|
+
#r;
|
|
1662
|
+
constructor(t, e) {
|
|
1663
|
+
super(), this.#e = t, this.setOptions(e), this.bindMethods(), this.#i();
|
|
1664
|
+
}
|
|
1665
|
+
bindMethods() {
|
|
1666
|
+
this.mutate = this.mutate.bind(this), this.reset = this.reset.bind(this);
|
|
1667
|
+
}
|
|
1668
|
+
setOptions(t) {
|
|
1669
|
+
const e = this.options;
|
|
1670
|
+
this.options = this.#e.defaultMutationOptions(t), x(this.options, e) || this.#e.getMutationCache().notify({
|
|
1671
|
+
type: "observerOptionsUpdated",
|
|
1672
|
+
mutation: this.#s,
|
|
1673
|
+
observer: this
|
|
1674
|
+
}), e?.mutationKey && this.options.mutationKey && T(e.mutationKey) !== T(this.options.mutationKey) ? this.reset() : this.#s?.state.status === "pending" && this.#s.setOptions(this.options);
|
|
1675
|
+
}
|
|
1676
|
+
onUnsubscribe() {
|
|
1677
|
+
this.hasListeners() || this.#s?.removeObserver(this);
|
|
1678
|
+
}
|
|
1679
|
+
onMutationUpdate(t) {
|
|
1680
|
+
this.#i(), this.#n(t);
|
|
1681
|
+
}
|
|
1682
|
+
getCurrentResult() {
|
|
1683
|
+
return this.#t;
|
|
1684
|
+
}
|
|
1685
|
+
reset() {
|
|
1686
|
+
this.#s?.removeObserver(this), this.#s = void 0, this.#i(), this.#n();
|
|
1687
|
+
}
|
|
1688
|
+
mutate(t, e) {
|
|
1689
|
+
return this.#r = e, this.#s?.removeObserver(this), this.#s = this.#e.getMutationCache().build(this.#e, this.options), this.#s.addObserver(this), this.#s.execute(t);
|
|
1690
|
+
}
|
|
1691
|
+
#i() {
|
|
1692
|
+
const t = this.#s?.state ?? jt();
|
|
1693
|
+
this.#t = {
|
|
1694
|
+
...t,
|
|
1695
|
+
isPending: t.status === "pending",
|
|
1696
|
+
isSuccess: t.status === "success",
|
|
1697
|
+
isError: t.status === "error",
|
|
1698
|
+
isIdle: t.status === "idle",
|
|
1699
|
+
mutate: this.mutate,
|
|
1700
|
+
reset: this.reset
|
|
1701
|
+
};
|
|
1702
|
+
}
|
|
1703
|
+
#n(t) {
|
|
1704
|
+
g.batch(() => {
|
|
1705
|
+
if (this.#r && this.hasListeners()) {
|
|
1706
|
+
const e = this.#t.variables, s = this.#t.context, r = {
|
|
1707
|
+
client: this.#e,
|
|
1708
|
+
meta: this.options.meta,
|
|
1709
|
+
mutationKey: this.options.mutationKey
|
|
1710
|
+
};
|
|
1711
|
+
if (t?.type === "success") {
|
|
1712
|
+
try {
|
|
1713
|
+
this.#r.onSuccess?.(
|
|
1714
|
+
t.data,
|
|
1715
|
+
e,
|
|
1716
|
+
s,
|
|
1717
|
+
r
|
|
1718
|
+
);
|
|
1719
|
+
} catch (i) {
|
|
1720
|
+
Promise.reject(i);
|
|
1721
|
+
}
|
|
1722
|
+
try {
|
|
1723
|
+
this.#r.onSettled?.(
|
|
1724
|
+
t.data,
|
|
1725
|
+
null,
|
|
1726
|
+
e,
|
|
1727
|
+
s,
|
|
1728
|
+
r
|
|
1729
|
+
);
|
|
1730
|
+
} catch (i) {
|
|
1731
|
+
Promise.reject(i);
|
|
1732
|
+
}
|
|
1733
|
+
} else if (t?.type === "error") {
|
|
1734
|
+
try {
|
|
1735
|
+
this.#r.onError?.(
|
|
1736
|
+
t.error,
|
|
1737
|
+
e,
|
|
1738
|
+
s,
|
|
1739
|
+
r
|
|
1740
|
+
);
|
|
1741
|
+
} catch (i) {
|
|
1742
|
+
Promise.reject(i);
|
|
1743
|
+
}
|
|
1744
|
+
try {
|
|
1745
|
+
this.#r.onSettled?.(
|
|
1746
|
+
void 0,
|
|
1747
|
+
t.error,
|
|
1748
|
+
e,
|
|
1749
|
+
s,
|
|
1750
|
+
r
|
|
1751
|
+
);
|
|
1752
|
+
} catch (i) {
|
|
1753
|
+
Promise.reject(i);
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
this.listeners.forEach((e) => {
|
|
1758
|
+
e(this.#t);
|
|
1759
|
+
});
|
|
1760
|
+
});
|
|
1761
|
+
}
|
|
1762
|
+
};
|
|
1763
|
+
function Pt(t, e) {
|
|
1764
|
+
const s = new Set(e);
|
|
1765
|
+
return t.filter((r) => !s.has(r));
|
|
1766
|
+
}
|
|
1767
|
+
function Pe(t, e, s) {
|
|
1768
|
+
const r = t.slice(0);
|
|
1769
|
+
return r[e] = s, r;
|
|
1770
|
+
}
|
|
1771
|
+
var Re = class extends I {
|
|
1772
|
+
#e;
|
|
1773
|
+
#t;
|
|
1774
|
+
#s;
|
|
1775
|
+
#r;
|
|
1776
|
+
#i;
|
|
1777
|
+
#n;
|
|
1778
|
+
#o;
|
|
1779
|
+
#a;
|
|
1780
|
+
#c;
|
|
1781
|
+
#u = [];
|
|
1782
|
+
constructor(t, e, s) {
|
|
1783
|
+
super(), this.#e = t, this.#r = s, this.#s = [], this.#i = [], this.#t = [], this.setQueries(e);
|
|
1784
|
+
}
|
|
1785
|
+
onSubscribe() {
|
|
1786
|
+
this.listeners.size === 1 && this.#i.forEach((t) => {
|
|
1787
|
+
t.subscribe((e) => {
|
|
1788
|
+
this.#y(t, e);
|
|
1789
|
+
});
|
|
1790
|
+
});
|
|
1791
|
+
}
|
|
1792
|
+
onUnsubscribe() {
|
|
1793
|
+
this.listeners.size || this.destroy();
|
|
1794
|
+
}
|
|
1795
|
+
destroy() {
|
|
1796
|
+
this.listeners = /* @__PURE__ */ new Set(), this.#i.forEach((t) => {
|
|
1797
|
+
t.destroy();
|
|
1798
|
+
});
|
|
1799
|
+
}
|
|
1800
|
+
setQueries(t, e) {
|
|
1801
|
+
this.#s = t, this.#r = e, g.batch(() => {
|
|
1802
|
+
const s = this.#i, r = this.#h(this.#s);
|
|
1803
|
+
r.forEach(
|
|
1804
|
+
(h) => h.observer.setOptions(h.defaultedQueryOptions)
|
|
1805
|
+
);
|
|
1806
|
+
const i = r.map((h) => h.observer), n = i.map(
|
|
1807
|
+
(h) => h.getCurrentResult()
|
|
1808
|
+
), a = s.length !== i.length, u = i.some(
|
|
1809
|
+
(h, f) => h !== s[f]
|
|
1810
|
+
), o = a || u, c = o ? !0 : n.some((h, f) => {
|
|
1811
|
+
const l = this.#t[f];
|
|
1812
|
+
return !l || !x(h, l);
|
|
1813
|
+
});
|
|
1814
|
+
!o && !c || (o && (this.#u = r, this.#i = i), this.#t = n, this.hasListeners() && (o && (Pt(s, i).forEach((h) => {
|
|
1815
|
+
h.destroy();
|
|
1816
|
+
}), Pt(i, s).forEach((h) => {
|
|
1817
|
+
h.subscribe((f) => {
|
|
1818
|
+
this.#y(h, f);
|
|
1819
|
+
});
|
|
1820
|
+
})), this.#d()));
|
|
1821
|
+
});
|
|
1822
|
+
}
|
|
1823
|
+
getCurrentResult() {
|
|
1824
|
+
return this.#t;
|
|
1825
|
+
}
|
|
1826
|
+
getQueries() {
|
|
1827
|
+
return this.#i.map((t) => t.getCurrentQuery());
|
|
1828
|
+
}
|
|
1829
|
+
getObservers() {
|
|
1830
|
+
return this.#i;
|
|
1831
|
+
}
|
|
1832
|
+
getOptimisticResult(t, e) {
|
|
1833
|
+
const s = this.#h(t), r = s.map(
|
|
1834
|
+
(n) => n.observer.getOptimisticResult(n.defaultedQueryOptions)
|
|
1835
|
+
), i = s.map(
|
|
1836
|
+
(n) => n.defaultedQueryOptions.queryHash
|
|
1837
|
+
);
|
|
1838
|
+
return [
|
|
1839
|
+
r,
|
|
1840
|
+
(n) => this.#l(n ?? r, e, i),
|
|
1841
|
+
() => this.#f(r, s)
|
|
1842
|
+
];
|
|
1843
|
+
}
|
|
1844
|
+
#f(t, e) {
|
|
1845
|
+
return e.map((s, r) => {
|
|
1846
|
+
const i = t[r];
|
|
1847
|
+
return s.defaultedQueryOptions.notifyOnChangeProps ? i : s.observer.trackResult(i, (n) => {
|
|
1848
|
+
e.forEach((a) => {
|
|
1849
|
+
a.observer.trackProp(n);
|
|
1850
|
+
});
|
|
1851
|
+
});
|
|
1852
|
+
});
|
|
1853
|
+
}
|
|
1854
|
+
#l(t, e, s) {
|
|
1855
|
+
if (e) {
|
|
1856
|
+
const r = this.#c, i = s !== void 0 && r !== void 0 && (r.length !== s.length || s.some((n, a) => n !== r[a]));
|
|
1857
|
+
return (!this.#n || this.#t !== this.#a || i || e !== this.#o) && (this.#o = e, this.#a = this.#t, s !== void 0 && (this.#c = s), this.#n = $(
|
|
1858
|
+
this.#n,
|
|
1859
|
+
e(t)
|
|
1860
|
+
)), this.#n;
|
|
1861
|
+
}
|
|
1862
|
+
return t;
|
|
1863
|
+
}
|
|
1864
|
+
#p() {
|
|
1865
|
+
return this.#r?.combine !== void 0 && this.#i.some((t, e) => t.options.suspense && this.#t[e]?.data === void 0);
|
|
1866
|
+
}
|
|
1867
|
+
#h(t) {
|
|
1868
|
+
const e = /* @__PURE__ */ new Map();
|
|
1869
|
+
this.#i.forEach((r) => {
|
|
1870
|
+
const i = r.options.queryHash;
|
|
1871
|
+
if (!i) return;
|
|
1872
|
+
const n = e.get(i);
|
|
1873
|
+
n ? n.push(r) : e.set(i, [r]);
|
|
1874
|
+
});
|
|
1875
|
+
const s = [];
|
|
1876
|
+
return t.forEach((r) => {
|
|
1877
|
+
const i = this.#e.defaultQueryOptions(r), a = e.get(i.queryHash)?.shift() ?? new k(this.#e, i);
|
|
1878
|
+
s.push({
|
|
1879
|
+
defaultedQueryOptions: i,
|
|
1880
|
+
observer: a
|
|
1881
|
+
});
|
|
1882
|
+
}), s;
|
|
1883
|
+
}
|
|
1884
|
+
#y(t, e) {
|
|
1885
|
+
const s = this.#i.indexOf(t);
|
|
1886
|
+
s !== -1 && (this.#t = Pe(this.#t, s, e), this.#d());
|
|
1887
|
+
}
|
|
1888
|
+
#d() {
|
|
1889
|
+
if (this.hasListeners()) {
|
|
1890
|
+
const t = this.#f(this.#t, this.#u), e = this.#p(), s = this.#n, r = e ? s : this.#l(t, this.#r?.combine);
|
|
1891
|
+
(e || s !== r) && g.batch(() => {
|
|
1892
|
+
this.listeners.forEach((i) => {
|
|
1893
|
+
i(this.#t);
|
|
1894
|
+
});
|
|
1895
|
+
});
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
}, Ce = class extends I {
|
|
1899
|
+
constructor(t = {}) {
|
|
1900
|
+
super(), this.config = t, this.#e = /* @__PURE__ */ new Map();
|
|
1901
|
+
}
|
|
1902
|
+
#e;
|
|
1903
|
+
build(t, e, s) {
|
|
1904
|
+
const r = e.queryKey, i = e.queryHash ?? ut(r, e);
|
|
1905
|
+
let n = this.get(i);
|
|
1906
|
+
return n || (n = new me({
|
|
1907
|
+
client: t,
|
|
1908
|
+
queryKey: r,
|
|
1909
|
+
queryHash: i,
|
|
1910
|
+
options: t.defaultQueryOptions(e),
|
|
1911
|
+
state: s,
|
|
1912
|
+
defaultOptions: t.getQueryDefaults(r)
|
|
1913
|
+
}), this.add(n)), n;
|
|
1914
|
+
}
|
|
1915
|
+
add(t) {
|
|
1916
|
+
this.#e.has(t.queryHash) || (this.#e.set(t.queryHash, t), this.notify({
|
|
1917
|
+
type: "added",
|
|
1918
|
+
query: t
|
|
1919
|
+
}));
|
|
1920
|
+
}
|
|
1921
|
+
remove(t) {
|
|
1922
|
+
const e = this.#e.get(t.queryHash);
|
|
1923
|
+
e && (t.destroy(), e === t && this.#e.delete(t.queryHash), this.notify({ type: "removed", query: t }));
|
|
1924
|
+
}
|
|
1925
|
+
clear() {
|
|
1926
|
+
g.batch(() => {
|
|
1927
|
+
this.getAll().forEach((t) => {
|
|
1928
|
+
this.remove(t);
|
|
1929
|
+
});
|
|
1930
|
+
});
|
|
1931
|
+
}
|
|
1932
|
+
get(t) {
|
|
1933
|
+
return this.#e.get(t);
|
|
1934
|
+
}
|
|
1935
|
+
getAll() {
|
|
1936
|
+
return [...this.#e.values()];
|
|
1937
|
+
}
|
|
1938
|
+
find(t) {
|
|
1939
|
+
const e = { exact: !0, ...t };
|
|
1940
|
+
return this.getAll().find(
|
|
1941
|
+
(s) => pt(e, s)
|
|
1942
|
+
);
|
|
1943
|
+
}
|
|
1944
|
+
findAll(t = {}) {
|
|
1945
|
+
const e = this.getAll();
|
|
1946
|
+
return Object.keys(t).length > 0 ? e.filter((s) => pt(t, s)) : e;
|
|
1947
|
+
}
|
|
1948
|
+
notify(t) {
|
|
1949
|
+
g.batch(() => {
|
|
1950
|
+
this.listeners.forEach((e) => {
|
|
1951
|
+
e(t);
|
|
1952
|
+
});
|
|
1953
|
+
});
|
|
1954
|
+
}
|
|
1955
|
+
onFocus() {
|
|
1956
|
+
g.batch(() => {
|
|
1957
|
+
this.getAll().forEach((t) => {
|
|
1958
|
+
t.onFocus();
|
|
1959
|
+
});
|
|
1960
|
+
});
|
|
1961
|
+
}
|
|
1962
|
+
onOnline() {
|
|
1963
|
+
g.batch(() => {
|
|
1964
|
+
this.getAll().forEach((t) => {
|
|
1965
|
+
t.onOnline();
|
|
1966
|
+
});
|
|
1967
|
+
});
|
|
1968
|
+
}
|
|
1969
|
+
}, Ae = class {
|
|
1970
|
+
#e;
|
|
1971
|
+
#t;
|
|
1972
|
+
#s;
|
|
1973
|
+
#r;
|
|
1974
|
+
#i;
|
|
1975
|
+
#n;
|
|
1976
|
+
#o;
|
|
1977
|
+
#a;
|
|
1978
|
+
constructor(t = {}) {
|
|
1979
|
+
this.#e = t.queryCache || new Ce(), this.#t = t.mutationCache || new Se(), this.#s = t.defaultOptions || {}, this.#r = /* @__PURE__ */ new Map(), this.#i = /* @__PURE__ */ new Map(), this.#n = 0;
|
|
1980
|
+
}
|
|
1981
|
+
mount() {
|
|
1982
|
+
this.#n++, this.#n === 1 && (this.#o = ot.subscribe(async (t) => {
|
|
1983
|
+
t && (await this.resumePausedMutations(), this.#e.onFocus());
|
|
1984
|
+
}), this.#a = z.subscribe(async (t) => {
|
|
1985
|
+
t && (await this.resumePausedMutations(), this.#e.onOnline());
|
|
1986
|
+
}));
|
|
1987
|
+
}
|
|
1988
|
+
unmount() {
|
|
1989
|
+
this.#n--, this.#n === 0 && (this.#o?.(), this.#o = void 0, this.#a?.(), this.#a = void 0);
|
|
1990
|
+
}
|
|
1991
|
+
isFetching(t) {
|
|
1992
|
+
return this.#e.findAll({ ...t, fetchStatus: "fetching" }).length;
|
|
1993
|
+
}
|
|
1994
|
+
isMutating(t) {
|
|
1995
|
+
return this.#t.findAll({ ...t, status: "pending" }).length;
|
|
1996
|
+
}
|
|
1997
|
+
/**
|
|
1998
|
+
* Imperative (non-reactive) way to retrieve data for a QueryKey.
|
|
1999
|
+
* Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.
|
|
2000
|
+
*
|
|
2001
|
+
* Hint: Do not use this function inside a component, because it won't receive updates.
|
|
2002
|
+
* Use `useQuery` to create a `QueryObserver` that subscribes to changes.
|
|
2003
|
+
*/
|
|
2004
|
+
getQueryData(t) {
|
|
2005
|
+
const e = this.defaultQueryOptions({ queryKey: t });
|
|
2006
|
+
return this.#e.get(e.queryHash)?.state.data;
|
|
2007
|
+
}
|
|
2008
|
+
ensureQueryData(t) {
|
|
2009
|
+
const e = this.defaultQueryOptions(t), s = this.#e.build(this, e), r = s.state.data;
|
|
2010
|
+
return r === void 0 ? this.fetchQuery(t) : (t.revalidateIfStale && s.isStaleByTime(F(e.staleTime, s)) && this.prefetchQuery(e), Promise.resolve(r));
|
|
2011
|
+
}
|
|
2012
|
+
getQueriesData(t) {
|
|
2013
|
+
return this.#e.findAll(t).map(({ queryKey: e, state: s }) => {
|
|
2014
|
+
const r = s.data;
|
|
2015
|
+
return [e, r];
|
|
2016
|
+
});
|
|
2017
|
+
}
|
|
2018
|
+
setQueryData(t, e, s) {
|
|
2019
|
+
const r = this.defaultQueryOptions({ queryKey: t }), n = this.#e.get(
|
|
2020
|
+
r.queryHash
|
|
2021
|
+
)?.state.data, a = te(e, n);
|
|
2022
|
+
if (a !== void 0)
|
|
2023
|
+
return this.#e.build(this, r).setData(a, { ...s, manual: !0 });
|
|
2024
|
+
}
|
|
2025
|
+
setQueriesData(t, e, s) {
|
|
2026
|
+
return g.batch(
|
|
2027
|
+
() => this.#e.findAll(t).map(({ queryKey: r }) => [
|
|
2028
|
+
r,
|
|
2029
|
+
this.setQueryData(r, e, s)
|
|
2030
|
+
])
|
|
2031
|
+
);
|
|
2032
|
+
}
|
|
2033
|
+
getQueryState(t) {
|
|
2034
|
+
const e = this.defaultQueryOptions({ queryKey: t });
|
|
2035
|
+
return this.#e.get(
|
|
2036
|
+
e.queryHash
|
|
2037
|
+
)?.state;
|
|
2038
|
+
}
|
|
2039
|
+
removeQueries(t) {
|
|
2040
|
+
const e = this.#e;
|
|
2041
|
+
g.batch(() => {
|
|
2042
|
+
e.findAll(t).forEach((s) => {
|
|
2043
|
+
e.remove(s);
|
|
2044
|
+
});
|
|
2045
|
+
});
|
|
2046
|
+
}
|
|
2047
|
+
resetQueries(t, e) {
|
|
2048
|
+
const s = this.#e;
|
|
2049
|
+
return g.batch(() => (s.findAll(t).forEach((r) => {
|
|
2050
|
+
r.reset();
|
|
2051
|
+
}), this.refetchQueries(
|
|
2052
|
+
{
|
|
2053
|
+
type: "active",
|
|
2054
|
+
...t
|
|
2055
|
+
},
|
|
2056
|
+
e
|
|
2057
|
+
)));
|
|
2058
|
+
}
|
|
2059
|
+
cancelQueries(t, e = {}) {
|
|
2060
|
+
const s = { revert: !0, ...e }, r = g.batch(
|
|
2061
|
+
() => this.#e.findAll(t).map((i) => i.cancel(s))
|
|
2062
|
+
);
|
|
2063
|
+
return Promise.all(r).then(O).catch(O);
|
|
2064
|
+
}
|
|
2065
|
+
invalidateQueries(t, e = {}) {
|
|
2066
|
+
return g.batch(() => (this.#e.findAll(t).forEach((s) => {
|
|
2067
|
+
s.invalidate();
|
|
2068
|
+
}), t?.refetchType === "none" ? Promise.resolve() : this.refetchQueries(
|
|
2069
|
+
{
|
|
2070
|
+
...t,
|
|
2071
|
+
type: t?.refetchType ?? t?.type ?? "active"
|
|
2072
|
+
},
|
|
2073
|
+
e
|
|
2074
|
+
)));
|
|
2075
|
+
}
|
|
2076
|
+
refetchQueries(t, e = {}) {
|
|
2077
|
+
const s = {
|
|
2078
|
+
...e,
|
|
2079
|
+
cancelRefetch: e.cancelRefetch ?? !0
|
|
2080
|
+
}, r = g.batch(
|
|
2081
|
+
() => this.#e.findAll(t).filter((i) => !i.isDisabled() && !i.isStatic()).map((i) => {
|
|
2082
|
+
let n = i.fetch(void 0, s);
|
|
2083
|
+
return s.throwOnError || (n = n.catch(O)), i.state.fetchStatus === "paused" ? Promise.resolve() : n;
|
|
2084
|
+
})
|
|
2085
|
+
);
|
|
2086
|
+
return Promise.all(r).then(O);
|
|
2087
|
+
}
|
|
2088
|
+
fetchQuery(t) {
|
|
2089
|
+
const e = this.defaultQueryOptions(t);
|
|
2090
|
+
e.retry === void 0 && (e.retry = !1);
|
|
2091
|
+
const s = this.#e.build(this, e);
|
|
2092
|
+
return s.isStaleByTime(
|
|
2093
|
+
F(e.staleTime, s)
|
|
2094
|
+
) ? s.fetch(e) : Promise.resolve(s.state.data);
|
|
2095
|
+
}
|
|
2096
|
+
prefetchQuery(t) {
|
|
2097
|
+
return this.fetchQuery(t).then(O).catch(O);
|
|
2098
|
+
}
|
|
2099
|
+
fetchInfiniteQuery(t) {
|
|
2100
|
+
return t._type = "infinite", this.fetchQuery(t);
|
|
2101
|
+
}
|
|
2102
|
+
prefetchInfiniteQuery(t) {
|
|
2103
|
+
return this.fetchInfiniteQuery(t).then(O).catch(O);
|
|
2104
|
+
}
|
|
2105
|
+
ensureInfiniteQueryData(t) {
|
|
2106
|
+
return t._type = "infinite", this.ensureQueryData(t);
|
|
2107
|
+
}
|
|
2108
|
+
resumePausedMutations() {
|
|
2109
|
+
return z.isOnline() ? this.#t.resumePausedMutations() : Promise.resolve();
|
|
2110
|
+
}
|
|
2111
|
+
getQueryCache() {
|
|
2112
|
+
return this.#e;
|
|
2113
|
+
}
|
|
2114
|
+
getMutationCache() {
|
|
2115
|
+
return this.#t;
|
|
2116
|
+
}
|
|
2117
|
+
getDefaultOptions() {
|
|
2118
|
+
return this.#s;
|
|
2119
|
+
}
|
|
2120
|
+
setDefaultOptions(t) {
|
|
2121
|
+
this.#s = t;
|
|
2122
|
+
}
|
|
2123
|
+
setQueryDefaults(t, e) {
|
|
2124
|
+
this.#r.set(T(t), {
|
|
2125
|
+
queryKey: t,
|
|
2126
|
+
defaultOptions: e
|
|
2127
|
+
});
|
|
2128
|
+
}
|
|
2129
|
+
getQueryDefaults(t) {
|
|
2130
|
+
const e = [...this.#r.values()], s = {};
|
|
2131
|
+
return e.forEach((r) => {
|
|
2132
|
+
q(t, r.queryKey) && Object.assign(s, r.defaultOptions);
|
|
2133
|
+
}), s;
|
|
2134
|
+
}
|
|
2135
|
+
setMutationDefaults(t, e) {
|
|
2136
|
+
this.#i.set(T(t), {
|
|
2137
|
+
mutationKey: t,
|
|
2138
|
+
defaultOptions: e
|
|
2139
|
+
});
|
|
2140
|
+
}
|
|
2141
|
+
getMutationDefaults(t) {
|
|
2142
|
+
const e = [...this.#i.values()], s = {};
|
|
2143
|
+
return e.forEach((r) => {
|
|
2144
|
+
q(t, r.mutationKey) && Object.assign(s, r.defaultOptions);
|
|
2145
|
+
}), s;
|
|
2146
|
+
}
|
|
2147
|
+
defaultQueryOptions(t) {
|
|
2148
|
+
if (t._defaulted)
|
|
2149
|
+
return t;
|
|
2150
|
+
const e = {
|
|
2151
|
+
...this.#s.queries,
|
|
2152
|
+
...this.getQueryDefaults(t.queryKey),
|
|
2153
|
+
...t,
|
|
2154
|
+
_defaulted: !0
|
|
2155
|
+
};
|
|
2156
|
+
return e.queryHash || (e.queryHash = ut(
|
|
2157
|
+
e.queryKey,
|
|
2158
|
+
e
|
|
2159
|
+
)), e.refetchOnReconnect === void 0 && (e.refetchOnReconnect = e.networkMode !== "always"), e.throwOnError === void 0 && (e.throwOnError = !!e.suspense), !e.networkMode && e.persister && (e.networkMode = "offlineFirst"), e.queryFn === ht && (e.enabled = !1), e;
|
|
2160
|
+
}
|
|
2161
|
+
defaultMutationOptions(t) {
|
|
2162
|
+
return t?._defaulted ? t : {
|
|
2163
|
+
...this.#s.mutations,
|
|
2164
|
+
...t?.mutationKey && this.getMutationDefaults(t.mutationKey),
|
|
2165
|
+
...t,
|
|
2166
|
+
_defaulted: !0
|
|
2167
|
+
};
|
|
2168
|
+
}
|
|
2169
|
+
clear() {
|
|
2170
|
+
this.#e.clear(), this.#t.clear();
|
|
2171
|
+
}
|
|
2172
|
+
};
|
|
2173
|
+
function qe({
|
|
2174
|
+
streamFn: t,
|
|
2175
|
+
refetchMode: e = "reset",
|
|
2176
|
+
reducer: s = (i, n) => Ft(i, n),
|
|
2177
|
+
initialValue: r = []
|
|
2178
|
+
}) {
|
|
2179
|
+
return async (i) => {
|
|
2180
|
+
const n = i.client.getQueryCache().find({ queryKey: i.queryKey, exact: !0 }), a = !!n && n.isFetched();
|
|
2181
|
+
a && e === "reset" && n.setState({
|
|
2182
|
+
...n.resetState,
|
|
2183
|
+
fetchStatus: "fetching"
|
|
2184
|
+
});
|
|
2185
|
+
let u = r, o = !1;
|
|
2186
|
+
const c = Dt(
|
|
2187
|
+
{
|
|
2188
|
+
client: i.client,
|
|
2189
|
+
meta: i.meta,
|
|
2190
|
+
queryKey: i.queryKey,
|
|
2191
|
+
pageParam: i.pageParam,
|
|
2192
|
+
direction: i.direction
|
|
2193
|
+
},
|
|
2194
|
+
() => i.signal,
|
|
2195
|
+
() => o = !0
|
|
2196
|
+
), h = await t(c), f = a && e === "replace";
|
|
2197
|
+
for await (const l of h) {
|
|
2198
|
+
if (o)
|
|
2199
|
+
break;
|
|
2200
|
+
f ? u = s(u, l) : i.client.setQueryData(
|
|
2201
|
+
i.queryKey,
|
|
2202
|
+
(y) => s(y === void 0 ? r : y, l)
|
|
2203
|
+
);
|
|
2204
|
+
}
|
|
2205
|
+
return f && !o && i.client.setQueryData(i.queryKey, u), i.client.getQueryData(i.queryKey) ?? r;
|
|
2206
|
+
};
|
|
2207
|
+
}
|
|
2208
|
+
var xe = /* @__PURE__ */ Symbol("dataTagSymbol"), Ue = /* @__PURE__ */ Symbol("dataTagErrorSymbol"), je = /* @__PURE__ */ Symbol("unsetMarker"), kt = nt(
|
|
2209
|
+
void 0
|
|
2210
|
+
), E = (t) => {
|
|
2211
|
+
const e = at(kt);
|
|
2212
|
+
if (t)
|
|
2213
|
+
return t;
|
|
2214
|
+
if (!e)
|
|
2215
|
+
throw new Error("No QueryClient set, use QueryClientProvider to set one");
|
|
2216
|
+
return e;
|
|
2217
|
+
}, ke = ({
|
|
2218
|
+
client: t,
|
|
2219
|
+
children: e
|
|
2220
|
+
}) => (M(() => (t.mount(), () => {
|
|
2221
|
+
t.unmount();
|
|
2222
|
+
}), [t]), /* @__PURE__ */ Qt(kt.Provider, { value: t, children: e })), Kt = nt(!1), Lt = () => at(Kt), Ke = Kt.Provider;
|
|
2223
|
+
function Nt() {
|
|
2224
|
+
let t = !1;
|
|
2225
|
+
return {
|
|
2226
|
+
clearReset: () => {
|
|
2227
|
+
t = !1;
|
|
2228
|
+
},
|
|
2229
|
+
reset: () => {
|
|
2230
|
+
t = !0;
|
|
2231
|
+
},
|
|
2232
|
+
isReset: () => t
|
|
2233
|
+
};
|
|
2234
|
+
}
|
|
2235
|
+
var Ht = nt(Nt()), Bt = () => at(Ht), Le = ({
|
|
2236
|
+
children: t
|
|
2237
|
+
}) => {
|
|
2238
|
+
const [e] = W(() => Nt());
|
|
2239
|
+
return /* @__PURE__ */ Qt(Ht.Provider, { value: e, children: typeof t == "function" ? t(e) : t });
|
|
2240
|
+
}, zt = (t, e, s) => {
|
|
2241
|
+
const r = s?.state.error && typeof t.throwOnError == "function" ? ct(t.throwOnError, [s.state.error, s]) : t.throwOnError;
|
|
2242
|
+
(t.suspense || t.experimental_prefetchInRender || r) && (e.isReset() || (t.retryOnMount = !1));
|
|
2243
|
+
}, Gt = (t) => {
|
|
2244
|
+
M(() => {
|
|
2245
|
+
t.clearReset();
|
|
2246
|
+
}, [t]);
|
|
2247
|
+
}, Wt = ({
|
|
2248
|
+
result: t,
|
|
2249
|
+
errorResetBoundary: e,
|
|
2250
|
+
throwOnError: s,
|
|
2251
|
+
query: r,
|
|
2252
|
+
suspense: i
|
|
2253
|
+
}) => t.isError && !e.isReset() && !t.isFetching && r && (i && t.data === void 0 || ct(s, [t.error, r])), dt = (t, e) => e.state.data === void 0, $t = (t) => {
|
|
2254
|
+
if (t.suspense) {
|
|
2255
|
+
const s = (i) => i === "static" ? i : Math.max(i ?? 1e3, 1e3), r = t.staleTime;
|
|
2256
|
+
t.staleTime = typeof r == "function" ? (...i) => s(r(...i)) : s(r), typeof t.gcTime == "number" && (t.gcTime = Math.max(
|
|
2257
|
+
t.gcTime,
|
|
2258
|
+
1e3
|
|
2259
|
+
));
|
|
2260
|
+
}
|
|
2261
|
+
}, Qe = (t, e) => t.isLoading && t.isFetching && !e, rt = (t, e) => t?.suspense && e.isPending, it = (t, e, s) => e.fetchOptimistic(t).catch(() => {
|
|
2262
|
+
s.clearReset();
|
|
2263
|
+
});
|
|
2264
|
+
function Ee({
|
|
2265
|
+
queries: t,
|
|
2266
|
+
...e
|
|
2267
|
+
}, s) {
|
|
2268
|
+
const r = E(s), i = Lt(), n = Bt(), a = Ct(
|
|
2269
|
+
() => t.map((d) => {
|
|
2270
|
+
const p = r.defaultQueryOptions(
|
|
2271
|
+
d
|
|
2272
|
+
);
|
|
2273
|
+
return p._optimisticResults = i ? "isRestoring" : "optimistic", p;
|
|
2274
|
+
}),
|
|
2275
|
+
[t, r, i]
|
|
2276
|
+
);
|
|
2277
|
+
a.forEach((d) => {
|
|
2278
|
+
$t(d);
|
|
2279
|
+
const p = r.getQueryCache().get(d.queryHash);
|
|
2280
|
+
zt(d, n, p);
|
|
2281
|
+
}), Gt(n);
|
|
2282
|
+
const [u] = W(
|
|
2283
|
+
() => new Re(
|
|
2284
|
+
r,
|
|
2285
|
+
a,
|
|
2286
|
+
e
|
|
2287
|
+
)
|
|
2288
|
+
), [o, c, h] = u.getOptimisticResult(
|
|
2289
|
+
a,
|
|
2290
|
+
e.combine
|
|
2291
|
+
), f = !i && e.subscribed !== !1;
|
|
2292
|
+
j(
|
|
2293
|
+
_(
|
|
2294
|
+
(d) => f ? u.subscribe(g.batchCalls(d)) : O,
|
|
2295
|
+
[u, f]
|
|
2296
|
+
),
|
|
2297
|
+
() => u.getCurrentResult(),
|
|
2298
|
+
() => u.getCurrentResult()
|
|
2299
|
+
), M(() => {
|
|
2300
|
+
u.setQueries(
|
|
2301
|
+
a,
|
|
2302
|
+
e
|
|
2303
|
+
);
|
|
2304
|
+
}, [a, e, u]);
|
|
2305
|
+
const y = o.some(
|
|
2306
|
+
(d, p) => rt(a[p], d)
|
|
2307
|
+
) ? o.flatMap((d, p) => {
|
|
2308
|
+
const v = a[p];
|
|
2309
|
+
if (v && rt(v, d)) {
|
|
2310
|
+
const b = new k(r, v);
|
|
2311
|
+
return it(v, b, n);
|
|
2312
|
+
}
|
|
2313
|
+
return [];
|
|
2314
|
+
}) : [];
|
|
2315
|
+
if (y.length > 0)
|
|
2316
|
+
throw Promise.all(y);
|
|
2317
|
+
const m = o.find(
|
|
2318
|
+
(d, p) => {
|
|
2319
|
+
const v = a[p];
|
|
2320
|
+
return v && Wt({
|
|
2321
|
+
result: d,
|
|
2322
|
+
errorResetBoundary: n,
|
|
2323
|
+
throwOnError: v.throwOnError,
|
|
2324
|
+
query: r.getQueryCache().get(v.queryHash),
|
|
2325
|
+
suspense: v.suspense
|
|
2326
|
+
});
|
|
2327
|
+
}
|
|
2328
|
+
);
|
|
2329
|
+
if (m?.error)
|
|
2330
|
+
throw m.error;
|
|
2331
|
+
return c(h());
|
|
2332
|
+
}
|
|
2333
|
+
function V(t, e, s) {
|
|
2334
|
+
const r = Lt(), i = Bt(), n = E(s), a = n.defaultQueryOptions(t);
|
|
2335
|
+
n.getDefaultOptions().queries?._experimental_beforeQuery?.(
|
|
2336
|
+
a
|
|
2337
|
+
);
|
|
2338
|
+
const u = n.getQueryCache().get(a.queryHash);
|
|
2339
|
+
a._optimisticResults = r ? "isRestoring" : "optimistic", $t(a), zt(a, i, u), Gt(i);
|
|
2340
|
+
const o = !n.getQueryCache().get(a.queryHash), [c] = W(
|
|
2341
|
+
() => new e(
|
|
2342
|
+
n,
|
|
2343
|
+
a
|
|
2344
|
+
)
|
|
2345
|
+
), h = c.getOptimisticResult(a), f = !r && t.subscribed !== !1;
|
|
2346
|
+
if (j(
|
|
2347
|
+
_(
|
|
2348
|
+
(l) => {
|
|
2349
|
+
const y = f ? c.subscribe(g.batchCalls(l)) : O;
|
|
2350
|
+
return c.updateResult(), y;
|
|
2351
|
+
},
|
|
2352
|
+
[c, f]
|
|
2353
|
+
),
|
|
2354
|
+
() => c.getCurrentResult(),
|
|
2355
|
+
() => c.getCurrentResult()
|
|
2356
|
+
), M(() => {
|
|
2357
|
+
c.setOptions(a);
|
|
2358
|
+
}, [a, c]), rt(a, h))
|
|
2359
|
+
throw it(a, c, i);
|
|
2360
|
+
if (Wt({
|
|
2361
|
+
result: h,
|
|
2362
|
+
errorResetBoundary: i,
|
|
2363
|
+
throwOnError: a.throwOnError,
|
|
2364
|
+
query: u,
|
|
2365
|
+
suspense: a.suspense
|
|
2366
|
+
}))
|
|
2367
|
+
throw h.error;
|
|
2368
|
+
return n.getDefaultOptions().queries?._experimental_afterQuery?.(
|
|
2369
|
+
a,
|
|
2370
|
+
h
|
|
2371
|
+
), a.experimental_prefetchInRender && !U.isServer() && Qe(h, r) && (o ? (
|
|
2372
|
+
// Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
|
|
2373
|
+
it(a, c, i)
|
|
2374
|
+
) : (
|
|
2375
|
+
// subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
|
|
2376
|
+
u?.promise
|
|
2377
|
+
))?.catch(O).finally(() => {
|
|
2378
|
+
c.updateResult();
|
|
2379
|
+
}), a.notifyOnChangeProps ? h : c.trackResult(h);
|
|
2380
|
+
}
|
|
2381
|
+
function Ne(t, e) {
|
|
2382
|
+
return V(t, k, e);
|
|
2383
|
+
}
|
|
2384
|
+
function He(t, e) {
|
|
2385
|
+
return V(
|
|
2386
|
+
{
|
|
2387
|
+
...t,
|
|
2388
|
+
enabled: !0,
|
|
2389
|
+
suspense: !0,
|
|
2390
|
+
throwOnError: dt,
|
|
2391
|
+
placeholderData: void 0
|
|
2392
|
+
},
|
|
2393
|
+
k,
|
|
2394
|
+
e
|
|
2395
|
+
);
|
|
2396
|
+
}
|
|
2397
|
+
function Be(t, e) {
|
|
2398
|
+
return V(
|
|
2399
|
+
{
|
|
2400
|
+
...t,
|
|
2401
|
+
enabled: !0,
|
|
2402
|
+
suspense: !0,
|
|
2403
|
+
throwOnError: dt
|
|
2404
|
+
},
|
|
2405
|
+
Ut,
|
|
2406
|
+
e
|
|
2407
|
+
);
|
|
2408
|
+
}
|
|
2409
|
+
function ze(t, e) {
|
|
2410
|
+
return Ee(
|
|
2411
|
+
{
|
|
2412
|
+
...t,
|
|
2413
|
+
queries: t.queries.map((s) => ({
|
|
2414
|
+
...s,
|
|
2415
|
+
suspense: !0,
|
|
2416
|
+
throwOnError: dt,
|
|
2417
|
+
enabled: !0,
|
|
2418
|
+
placeholderData: void 0
|
|
2419
|
+
}))
|
|
2420
|
+
},
|
|
2421
|
+
e
|
|
2422
|
+
);
|
|
2423
|
+
}
|
|
2424
|
+
function Ge(t, e) {
|
|
2425
|
+
const s = E(e);
|
|
2426
|
+
s.getQueryState(t.queryKey) || s.prefetchQuery(t);
|
|
2427
|
+
}
|
|
2428
|
+
function We(t, e) {
|
|
2429
|
+
const s = E(e);
|
|
2430
|
+
s.getQueryState(t.queryKey) || s.prefetchInfiniteQuery(t);
|
|
2431
|
+
}
|
|
2432
|
+
function $e(t) {
|
|
2433
|
+
return t;
|
|
2434
|
+
}
|
|
2435
|
+
function Ve(t) {
|
|
2436
|
+
return t;
|
|
2437
|
+
}
|
|
2438
|
+
var Je = ({
|
|
2439
|
+
children: t,
|
|
2440
|
+
options: e = {},
|
|
2441
|
+
state: s,
|
|
2442
|
+
queryClient: r
|
|
2443
|
+
}) => {
|
|
2444
|
+
const i = E(r), n = J(e);
|
|
2445
|
+
M(() => {
|
|
2446
|
+
n.current = e;
|
|
2447
|
+
});
|
|
2448
|
+
const a = Ct(() => {
|
|
2449
|
+
if (s) {
|
|
2450
|
+
if (typeof s != "object")
|
|
2451
|
+
return;
|
|
2452
|
+
const u = i.getQueryCache(), o = s.queries || [], c = [], h = [];
|
|
2453
|
+
for (const f of o) {
|
|
2454
|
+
const l = u.get(f.queryHash);
|
|
2455
|
+
l ? (f.state.dataUpdatedAt > l.state.dataUpdatedAt || f.promise && l.state.status !== "pending" && l.state.fetchStatus !== "fetching" && f.dehydratedAt !== void 0 && f.dehydratedAt > l.state.dataUpdatedAt) && h.push(f) : c.push(f);
|
|
2456
|
+
}
|
|
2457
|
+
if (c.length > 0 && gt(i, { queries: c }, n.current), h.length > 0)
|
|
2458
|
+
return h;
|
|
2459
|
+
}
|
|
2460
|
+
}, [i, s]);
|
|
2461
|
+
return M(() => {
|
|
2462
|
+
a && gt(i, { queries: a }, n.current);
|
|
2463
|
+
}, [i, a]), t;
|
|
2464
|
+
};
|
|
2465
|
+
function Ze(t, e) {
|
|
2466
|
+
const s = E(e), r = s.getQueryCache();
|
|
2467
|
+
return j(
|
|
2468
|
+
_(
|
|
2469
|
+
(i) => r.subscribe(g.batchCalls(i)),
|
|
2470
|
+
[r]
|
|
2471
|
+
),
|
|
2472
|
+
() => s.isFetching(t),
|
|
2473
|
+
() => s.isFetching(t)
|
|
2474
|
+
);
|
|
2475
|
+
}
|
|
2476
|
+
function Xe(t, e) {
|
|
2477
|
+
const s = E(e);
|
|
2478
|
+
return Fe(
|
|
2479
|
+
{ filters: { ...t, status: "pending" } },
|
|
2480
|
+
s
|
|
2481
|
+
).length;
|
|
2482
|
+
}
|
|
2483
|
+
function Rt(t, e) {
|
|
2484
|
+
return t.findAll(e.filters).map(
|
|
2485
|
+
(s) => e.select ? e.select(s) : s.state
|
|
2486
|
+
);
|
|
2487
|
+
}
|
|
2488
|
+
function Fe(t = {}, e) {
|
|
2489
|
+
const s = E(e).getMutationCache(), r = J(t), i = J(null);
|
|
2490
|
+
return i.current === null && (i.current = Rt(s, t)), M(() => {
|
|
2491
|
+
r.current = t;
|
|
2492
|
+
}), j(
|
|
2493
|
+
_(
|
|
2494
|
+
(n) => s.subscribe(() => {
|
|
2495
|
+
const a = $(
|
|
2496
|
+
i.current,
|
|
2497
|
+
Rt(s, r.current)
|
|
2498
|
+
);
|
|
2499
|
+
i.current !== a && (i.current = a, g.schedule(n));
|
|
2500
|
+
}),
|
|
2501
|
+
[s]
|
|
2502
|
+
),
|
|
2503
|
+
() => i.current,
|
|
2504
|
+
() => i.current
|
|
2505
|
+
);
|
|
2506
|
+
}
|
|
2507
|
+
function Ye(t, e) {
|
|
2508
|
+
const s = E(e), [r] = W(
|
|
2509
|
+
() => new we(
|
|
2510
|
+
s,
|
|
2511
|
+
t
|
|
2512
|
+
)
|
|
2513
|
+
);
|
|
2514
|
+
M(() => {
|
|
2515
|
+
r.setOptions(t);
|
|
2516
|
+
}, [r, t]);
|
|
2517
|
+
const i = j(
|
|
2518
|
+
_(
|
|
2519
|
+
(a) => r.subscribe(g.batchCalls(a)),
|
|
2520
|
+
[r]
|
|
2521
|
+
),
|
|
2522
|
+
() => r.getCurrentResult(),
|
|
2523
|
+
() => r.getCurrentResult()
|
|
2524
|
+
), n = _(
|
|
2525
|
+
(a, u) => {
|
|
2526
|
+
r.mutate(a, u).catch(O);
|
|
2527
|
+
},
|
|
2528
|
+
[r]
|
|
2529
|
+
);
|
|
2530
|
+
if (i.error && ct(r.options.throwOnError, [i.error]))
|
|
2531
|
+
throw i.error;
|
|
2532
|
+
return { ...i, mutate: n, mutateAsync: i.mutate };
|
|
2533
|
+
}
|
|
2534
|
+
function ts(t) {
|
|
2535
|
+
return t;
|
|
2536
|
+
}
|
|
2537
|
+
function es(t, e) {
|
|
2538
|
+
return V(
|
|
2539
|
+
t,
|
|
2540
|
+
Ut,
|
|
2541
|
+
e
|
|
2542
|
+
);
|
|
2543
|
+
}
|
|
2544
|
+
export {
|
|
2545
|
+
G as CancelledError,
|
|
2546
|
+
Je as HydrationBoundary,
|
|
2547
|
+
Ut as InfiniteQueryObserver,
|
|
2548
|
+
Ke as IsRestoringProvider,
|
|
2549
|
+
Oe as Mutation,
|
|
2550
|
+
Se as MutationCache,
|
|
2551
|
+
we as MutationObserver,
|
|
2552
|
+
Re as QueriesObserver,
|
|
2553
|
+
me as Query,
|
|
2554
|
+
Ce as QueryCache,
|
|
2555
|
+
Ae as QueryClient,
|
|
2556
|
+
kt as QueryClientContext,
|
|
2557
|
+
ke as QueryClientProvider,
|
|
2558
|
+
Le as QueryErrorResetBoundary,
|
|
2559
|
+
k as QueryObserver,
|
|
2560
|
+
Ue as dataTagErrorSymbol,
|
|
2561
|
+
xe as dataTagSymbol,
|
|
2562
|
+
ce as defaultScheduler,
|
|
2563
|
+
oe as defaultShouldDehydrateMutation,
|
|
2564
|
+
ue as defaultShouldDehydrateQuery,
|
|
2565
|
+
Ie as dehydrate,
|
|
2566
|
+
U as environmentManager,
|
|
2567
|
+
qe as experimental_streamedQuery,
|
|
2568
|
+
ot as focusManager,
|
|
2569
|
+
T as hashKey,
|
|
2570
|
+
gt as hydrate,
|
|
2571
|
+
Ve as infiniteQueryOptions,
|
|
2572
|
+
_e as isCancelledError,
|
|
2573
|
+
Yt as isServer,
|
|
2574
|
+
Te as keepPreviousData,
|
|
2575
|
+
yt as matchMutation,
|
|
2576
|
+
pt as matchQuery,
|
|
2577
|
+
ts as mutationOptions,
|
|
2578
|
+
O as noop,
|
|
2579
|
+
g as notifyManager,
|
|
2580
|
+
z as onlineManager,
|
|
2581
|
+
q as partialMatchKey,
|
|
2582
|
+
$e as queryOptions,
|
|
2583
|
+
$ as replaceEqualDeep,
|
|
2584
|
+
ct as shouldThrowError,
|
|
2585
|
+
ht as skipToken,
|
|
2586
|
+
D as timeoutManager,
|
|
2587
|
+
je as unsetMarker,
|
|
2588
|
+
es as useInfiniteQuery,
|
|
2589
|
+
Ze as useIsFetching,
|
|
2590
|
+
Xe as useIsMutating,
|
|
2591
|
+
Lt as useIsRestoring,
|
|
2592
|
+
Ye as useMutation,
|
|
2593
|
+
Fe as useMutationState,
|
|
2594
|
+
We as usePrefetchInfiniteQuery,
|
|
2595
|
+
Ge as usePrefetchQuery,
|
|
2596
|
+
Ee as useQueries,
|
|
2597
|
+
Ne as useQuery,
|
|
2598
|
+
E as useQueryClient,
|
|
2599
|
+
Bt as useQueryErrorResetBoundary,
|
|
2600
|
+
Be as useSuspenseInfiniteQuery,
|
|
2601
|
+
ze as useSuspenseQueries,
|
|
2602
|
+
He as useSuspenseQuery
|
|
2603
|
+
};
|