@queuedash/ui
Version:
A stunning, sleek dashboard for Bull, BullMQ, and Bee-Queue
1,633 lines • 778 kB
JavaScript
var wu = (e) => {
throw TypeError(e);
};
var Da = (e, t, n) => t.has(e) || wu("Cannot " + n);
var C = (e, t, n) => (Da(e, t, "read from private field"), n ? n.call(e) : t.get(e)), W = (e, t, n) => t.has(e) ? wu("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), B = (e, t, n, r) => (Da(e, t, "write to private field"), r ? r.call(e, n) : t.set(e, n), n), Y = (e, t, n) => (Da(e, t, "access private method"), n);
var Gi = (e, t, n, r) => ({
set _(i) {
B(e, t, i, n);
},
get _() {
return C(e, t, r);
}
});
import * as S from "react";
import x, { forwardRef as oe, createElement as U, createContext as re, useRef as H, useCallback as se, useState as ee, useContext as ne, useEffect as X, useMemo as ce, cloneElement as Jg, memo as vl } from "react";
import yl, { flushSync as Ud, createPortal as ep } from "react-dom";
function Wd(e) {
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
var qd = { exports: {} }, ia = {};
/**
* @license React
* react-jsx-runtime.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var tp = Symbol.for("react.transitional.element"), np = Symbol.for("react.fragment");
function Gd(e, t, n) {
var r = null;
if (n !== void 0 && (r = "" + n), t.key !== void 0 && (r = "" + t.key), "key" in t) {
n = {};
for (var i in t)
i !== "key" && (n[i] = t[i]);
} else n = t;
return t = n.ref, {
$$typeof: tp,
type: e,
key: r,
ref: t !== void 0 ? t : null,
props: n
};
}
ia.Fragment = np;
ia.jsx = Gd;
ia.jsxs = Gd;
qd.exports = ia;
var v = qd.exports, Gn = class {
constructor() {
this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
}
subscribe(e) {
return this.listeners.add(e), this.onSubscribe(), () => {
this.listeners.delete(e), this.onUnsubscribe();
};
}
hasListeners() {
return this.listeners.size > 0;
}
onSubscribe() {
}
onUnsubscribe() {
}
}, Vn = typeof window > "u" || "Deno" in globalThis;
function _e() {
}
function rp(e, t) {
return typeof e == "function" ? e(t) : e;
}
function hs(e) {
return typeof e == "number" && e >= 0 && e !== 1 / 0;
}
function Qd(e, t) {
return Math.max(e + (t || 0) - Date.now(), 0);
}
function gr(e, t) {
return typeof e == "function" ? e(t) : e;
}
function $t(e, t) {
return typeof e == "function" ? e(t) : e;
}
function xu(e, t) {
const {
type: n = "all",
exact: r,
fetchStatus: i,
predicate: o,
queryKey: a,
stale: s
} = e;
if (a) {
if (r) {
if (t.queryHash !== wl(a, t.options))
return !1;
} else if (!mi(t.queryKey, a))
return !1;
}
if (n !== "all") {
const l = t.isActive();
if (n === "active" && !l || n === "inactive" && l)
return !1;
}
return !(typeof s == "boolean" && t.isStale() !== s || i && i !== t.state.fetchStatus || o && !o(t));
}
function Cu(e, t) {
const { exact: n, status: r, predicate: i, mutationKey: o } = e;
if (o) {
if (!t.options.mutationKey)
return !1;
if (n) {
if (yn(t.options.mutationKey) !== yn(o))
return !1;
} else if (!mi(t.options.mutationKey, o))
return !1;
}
return !(r && t.state.status !== r || i && !i(t));
}
function wl(e, t) {
return ((t == null ? void 0 : t.queryKeyHashFn) || yn)(e);
}
function yn(e) {
return JSON.stringify(
e,
(t, n) => gs(n) ? Object.keys(n).sort().reduce((r, i) => (r[i] = n[i], r), {}) : n
);
}
function mi(e, t) {
return e === t ? !0 : typeof e != typeof t ? !1 : e && t && typeof e == "object" && typeof t == "object" ? Object.keys(t).every((n) => mi(e[n], t[n])) : !1;
}
function xl(e, t) {
if (e === t)
return e;
const n = $u(e) && $u(t);
if (n || gs(e) && gs(t)) {
const r = n ? e : Object.keys(e), i = r.length, o = n ? t : Object.keys(t), a = o.length, s = n ? [] : {};
let l = 0;
for (let u = 0; u < a; u++) {
const h = n ? u : o[u];
(!n && r.includes(h) || n) && e[h] === void 0 && t[h] === void 0 ? (s[h] = void 0, l++) : (s[h] = xl(e[h], t[h]), s[h] === e[h] && e[h] !== void 0 && l++);
}
return i === a && l === i ? e : s;
}
return t;
}
function Eo(e, t) {
if (!t || Object.keys(e).length !== Object.keys(t).length)
return !1;
for (const n in e)
if (e[n] !== t[n])
return !1;
return !0;
}
function $u(e) {
return Array.isArray(e) && e.length === Object.keys(e).length;
}
function gs(e) {
if (!Su(e))
return !1;
const t = e.constructor;
if (t === void 0)
return !0;
const n = t.prototype;
return !(!Su(n) || !n.hasOwnProperty("isPrototypeOf") || Object.getPrototypeOf(e) !== Object.prototype);
}
function Su(e) {
return Object.prototype.toString.call(e) === "[object Object]";
}
function ip(e) {
return new Promise((t) => {
setTimeout(t, e);
});
}
function ps(e, t, n) {
return typeof n.structuralSharing == "function" ? n.structuralSharing(e, t) : n.structuralSharing !== !1 ? xl(e, t) : t;
}
function op(e, t, n = 0) {
const r = [...e, t];
return n && r.length > n ? r.slice(1) : r;
}
function ap(e, t, n = 0) {
const r = [t, ...e];
return n && r.length > n ? r.slice(0, -1) : r;
}
var et = Symbol();
function Yd(e, t) {
return !e.queryFn && (t != null && t.initialPromise) ? () => t.initialPromise : !e.queryFn || e.queryFn === et ? () => Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)) : e.queryFn;
}
function Xd(e, t) {
return typeof e == "function" ? e(...t) : !!e;
}
var Ln, tn, yr, Rd, sp = (Rd = class extends Gn {
constructor() {
super();
W(this, Ln);
W(this, tn);
W(this, yr);
B(this, yr, (t) => {
if (!Vn && window.addEventListener) {
const n = () => t();
return window.addEventListener("visibilitychange", n, !1), () => {
window.removeEventListener("visibilitychange", n);
};
}
});
}
onSubscribe() {
C(this, tn) || this.setEventListener(C(this, yr));
}
onUnsubscribe() {
var t;
this.hasListeners() || ((t = C(this, tn)) == null || t.call(this), B(this, tn, void 0));
}
setEventListener(t) {
var n;
B(this, yr, t), (n = C(this, tn)) == null || n.call(this), B(this, tn, t((r) => {
typeof r == "boolean" ? this.setFocused(r) : this.onFocus();
}));
}
setFocused(t) {
C(this, Ln) !== t && (B(this, Ln, t), this.onFocus());
}
onFocus() {
const t = this.isFocused();
this.listeners.forEach((n) => {
n(t);
});
}
isFocused() {
var t;
return typeof C(this, Ln) == "boolean" ? C(this, Ln) : ((t = globalThis.document) == null ? void 0 : t.visibilityState) !== "hidden";
}
}, Ln = new WeakMap(), tn = new WeakMap(), yr = new WeakMap(), Rd), Cl = new sp(), wr, nn, xr, Md, lp = (Md = class extends Gn {
constructor() {
super();
W(this, wr, !0);
W(this, nn);
W(this, xr);
B(this, xr, (t) => {
if (!Vn && window.addEventListener) {
const n = () => t(!0), r = () => t(!1);
return window.addEventListener("online", n, !1), window.addEventListener("offline", r, !1), () => {
window.removeEventListener("online", n), window.removeEventListener("offline", r);
};
}
});
}
onSubscribe() {
C(this, nn) || this.setEventListener(C(this, xr));
}
onUnsubscribe() {
var t;
this.hasListeners() || ((t = C(this, nn)) == null || t.call(this), B(this, nn, void 0));
}
setEventListener(t) {
var n;
B(this, xr, t), (n = C(this, nn)) == null || n.call(this), B(this, nn, t(this.setOnline.bind(this)));
}
setOnline(t) {
C(this, wr) !== t && (B(this, wr, t), this.listeners.forEach((r) => {
r(t);
}));
}
isOnline() {
return C(this, wr);
}
}, wr = new WeakMap(), nn = new WeakMap(), xr = new WeakMap(), Md), Po = new lp();
function ms() {
let e, t;
const n = new Promise((i, o) => {
e = i, t = o;
});
n.status = "pending", n.catch(() => {
});
function r(i) {
Object.assign(n, i), delete n.resolve, delete n.reject;
}
return n.resolve = (i) => {
r({
status: "fulfilled",
value: i
}), e(i);
}, n.reject = (i) => {
r({
status: "rejected",
reason: i
}), t(i);
}, n;
}
function up(e) {
return Math.min(1e3 * 2 ** e, 3e4);
}
function Zd(e) {
return (e ?? "online") === "online" ? Po.isOnline() : !0;
}
var Jd = class extends Error {
constructor(e) {
super("CancelledError"), this.revert = e == null ? void 0 : e.revert, this.silent = e == null ? void 0 : e.silent;
}
};
function Ta(e) {
return e instanceof Jd;
}
function ef(e) {
let t = !1, n = 0, r = !1, i;
const o = ms(), a = (p) => {
var m;
r || (f(new Jd(p)), (m = e.abort) == null || m.call(e));
}, s = () => {
t = !0;
}, l = () => {
t = !1;
}, u = () => Cl.isFocused() && (e.networkMode === "always" || Po.isOnline()) && e.canRun(), h = () => Zd(e.networkMode) && e.canRun(), c = (p) => {
var m;
r || (r = !0, (m = e.onSuccess) == null || m.call(e, p), i == null || i(), o.resolve(p));
}, f = (p) => {
var m;
r || (r = !0, (m = e.onError) == null || m.call(e, p), i == null || i(), o.reject(p));
}, d = () => new Promise((p) => {
var m;
i = (b) => {
(r || u()) && p(b);
}, (m = e.onPause) == null || m.call(e);
}).then(() => {
var p;
i = void 0, r || (p = e.onContinue) == null || p.call(e);
}), g = () => {
if (r)
return;
let p;
const m = n === 0 ? e.initialPromise : void 0;
try {
p = m ?? e.fn();
} catch (b) {
p = Promise.reject(b);
}
Promise.resolve(p).then(c).catch((b) => {
var R;
if (r)
return;
const y = e.retry ?? (Vn ? 0 : 3), w = e.retryDelay ?? up, k = typeof w == "function" ? w(n, b) : w, $ = y === !0 || typeof y == "number" && n < y || typeof y == "function" && y(n, b);
if (t || !$) {
f(b);
return;
}
n++, (R = e.onFail) == null || R.call(e, n, b), ip(k).then(() => u() ? void 0 : d()).then(() => {
t ? f(b) : g();
});
});
};
return {
promise: o,
cancel: a,
continue: () => (i == null || i(), o),
cancelRetry: s,
continueRetry: l,
canStart: h,
start: () => (h() ? g() : d().then(g), o)
};
}
var cp = (e) => setTimeout(e, 0);
function dp() {
let e = [], t = 0, n = (s) => {
s();
}, r = (s) => {
s();
}, i = cp;
const o = (s) => {
t ? e.push(s) : i(() => {
n(s);
});
}, a = () => {
const s = e;
e = [], s.length && i(() => {
r(() => {
s.forEach((l) => {
n(l);
});
});
});
};
return {
batch: (s) => {
let l;
t++;
try {
l = s();
} finally {
t--, t || a();
}
return l;
},
/**
* All calls to the wrapped function will be batched.
*/
batchCalls: (s) => (...l) => {
o(() => {
s(...l);
});
},
schedule: o,
/**
* Use this method to set a custom notify function.
* This can be used to for example wrap notifications with `React.act` while running tests.
*/
setNotifyFunction: (s) => {
n = s;
},
/**
* Use this method to set a custom function to batch notifications together into a single tick.
* By default React Query will use the batch function provided by ReactDOM or React Native.
*/
setBatchNotifyFunction: (s) => {
r = s;
},
setScheduler: (s) => {
i = s;
}
};
}
var $e = dp(), In, kd, tf = (kd = class {
constructor() {
W(this, In);
}
destroy() {
this.clearGcTimeout();
}
scheduleGc() {
this.clearGcTimeout(), hs(this.gcTime) && B(this, In, setTimeout(() => {
this.optionalRemove();
}, this.gcTime));
}
updateGcTime(e) {
this.gcTime = Math.max(
this.gcTime || 0,
e ?? (Vn ? 1 / 0 : 5 * 60 * 1e3)
);
}
clearGcTimeout() {
C(this, In) && (clearTimeout(C(this, In)), B(this, In, void 0));
}
}, In = new WeakMap(), kd), Cr, $r, ct, Nn, Ae, ki, An, wt, Ht, Od, fp = (Od = class extends tf {
constructor(t) {
super();
W(this, wt);
W(this, Cr);
W(this, $r);
W(this, ct);
W(this, Nn);
W(this, Ae);
W(this, ki);
W(this, An);
B(this, An, !1), B(this, ki, t.defaultOptions), this.setOptions(t.options), this.observers = [], B(this, Nn, t.client), B(this, ct, C(this, Nn).getQueryCache()), this.queryKey = t.queryKey, this.queryHash = t.queryHash, B(this, Cr, hp(this.options)), this.state = t.state ?? C(this, Cr), this.scheduleGc();
}
get meta() {
return this.options.meta;
}
get promise() {
var t;
return (t = C(this, Ae)) == null ? void 0 : t.promise;
}
setOptions(t) {
this.options = { ...C(this, ki), ...t }, this.updateGcTime(this.options.gcTime);
}
optionalRemove() {
!this.observers.length && this.state.fetchStatus === "idle" && C(this, ct).remove(this);
}
setData(t, n) {
const r = ps(this.state.data, t, this.options);
return Y(this, wt, Ht).call(this, {
data: r,
type: "success",
dataUpdatedAt: n == null ? void 0 : n.updatedAt,
manual: n == null ? void 0 : n.manual
}), r;
}
setState(t, n) {
Y(this, wt, Ht).call(this, { type: "setState", state: t, setStateOptions: n });
}
cancel(t) {
var r, i;
const n = (r = C(this, Ae)) == null ? void 0 : r.promise;
return (i = C(this, Ae)) == null || i.cancel(t), n ? n.then(_e).catch(_e) : Promise.resolve();
}
destroy() {
super.destroy(), this.cancel({ silent: !0 });
}
reset() {
this.destroy(), this.setState(C(this, Cr));
}
isActive() {
return this.observers.some(
(t) => $t(t.options.enabled, this) !== !1
);
}
isDisabled() {
return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === et || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
}
isStale() {
return this.state.isInvalidated ? !0 : this.getObserversCount() > 0 ? this.observers.some(
(t) => t.getCurrentResult().isStale
) : this.state.data === void 0;
}
isStaleByTime(t = 0) {
return this.state.isInvalidated || this.state.data === void 0 || !Qd(this.state.dataUpdatedAt, t);
}
onFocus() {
var n;
const t = this.observers.find((r) => r.shouldFetchOnWindowFocus());
t == null || t.refetch({ cancelRefetch: !1 }), (n = C(this, Ae)) == null || n.continue();
}
onOnline() {
var n;
const t = this.observers.find((r) => r.shouldFetchOnReconnect());
t == null || t.refetch({ cancelRefetch: !1 }), (n = C(this, Ae)) == null || n.continue();
}
addObserver(t) {
this.observers.includes(t) || (this.observers.push(t), this.clearGcTimeout(), C(this, ct).notify({ type: "observerAdded", query: this, observer: t }));
}
removeObserver(t) {
this.observers.includes(t) && (this.observers = this.observers.filter((n) => n !== t), this.observers.length || (C(this, Ae) && (C(this, An) ? C(this, Ae).cancel({ revert: !0 }) : C(this, Ae).cancelRetry()), this.scheduleGc()), C(this, ct).notify({ type: "observerRemoved", query: this, observer: t }));
}
getObserversCount() {
return this.observers.length;
}
invalidate() {
this.state.isInvalidated || Y(this, wt, Ht).call(this, { type: "invalidate" });
}
fetch(t, n) {
var l, u, h;
if (this.state.fetchStatus !== "idle") {
if (this.state.data !== void 0 && (n != null && n.cancelRefetch))
this.cancel({ silent: !0 });
else if (C(this, Ae))
return C(this, Ae).continueRetry(), C(this, Ae).promise;
}
if (t && this.setOptions(t), !this.options.queryFn) {
const c = this.observers.find((f) => f.options.queryFn);
c && this.setOptions(c.options);
}
const r = new AbortController(), i = (c) => {
Object.defineProperty(c, "signal", {
enumerable: !0,
get: () => (B(this, An, !0), r.signal)
});
}, o = () => {
const c = Yd(this.options, n), f = {
client: C(this, Nn),
queryKey: this.queryKey,
meta: this.meta
};
return i(f), B(this, An, !1), this.options.persister ? this.options.persister(
c,
f,
this
) : c(f);
}, a = {
fetchOptions: n,
options: this.options,
queryKey: this.queryKey,
client: C(this, Nn),
state: this.state,
fetchFn: o
};
i(a), (l = this.options.behavior) == null || l.onFetch(
a,
this
), B(this, $r, this.state), (this.state.fetchStatus === "idle" || this.state.fetchMeta !== ((u = a.fetchOptions) == null ? void 0 : u.meta)) && Y(this, wt, Ht).call(this, { type: "fetch", meta: (h = a.fetchOptions) == null ? void 0 : h.meta });
const s = (c) => {
var f, d, g, p;
Ta(c) && c.silent || Y(this, wt, Ht).call(this, {
type: "error",
error: c
}), Ta(c) || ((d = (f = C(this, ct).config).onError) == null || d.call(
f,
c,
this
), (p = (g = C(this, ct).config).onSettled) == null || p.call(
g,
this.state.data,
c,
this
)), this.scheduleGc();
};
return B(this, Ae, ef({
initialPromise: n == null ? void 0 : n.initialPromise,
fn: a.fetchFn,
abort: r.abort.bind(r),
onSuccess: (c) => {
var f, d, g, p;
if (c === void 0) {
s(new Error(`${this.queryHash} data is undefined`));
return;
}
try {
this.setData(c);
} catch (m) {
s(m);
return;
}
(d = (f = C(this, ct).config).onSuccess) == null || d.call(f, c, this), (p = (g = C(this, ct).config).onSettled) == null || p.call(
g,
c,
this.state.error,
this
), this.scheduleGc();
},
onError: s,
onFail: (c, f) => {
Y(this, wt, Ht).call(this, { type: "failed", failureCount: c, error: f });
},
onPause: () => {
Y(this, wt, Ht).call(this, { type: "pause" });
},
onContinue: () => {
Y(this, wt, Ht).call(this, { type: "continue" });
},
retry: a.options.retry,
retryDelay: a.options.retryDelay,
networkMode: a.options.networkMode,
canRun: () => !0
})), C(this, Ae).start();
}
}, Cr = new WeakMap(), $r = new WeakMap(), ct = new WeakMap(), Nn = new WeakMap(), Ae = new WeakMap(), ki = new WeakMap(), An = new WeakMap(), wt = new WeakSet(), Ht = function(t) {
const n = (r) => {
switch (t.type) {
case "failed":
return {
...r,
fetchFailureCount: t.failureCount,
fetchFailureReason: t.error
};
case "pause":
return {
...r,
fetchStatus: "paused"
};
case "continue":
return {
...r,
fetchStatus: "fetching"
};
case "fetch":
return {
...r,
...nf(r.data, this.options),
fetchMeta: t.meta ?? null
};
case "success":
return {
...r,
data: t.data,
dataUpdateCount: r.dataUpdateCount + 1,
dataUpdatedAt: t.dataUpdatedAt ?? Date.now(),
error: null,
isInvalidated: !1,
status: "success",
...!t.manual && {
fetchStatus: "idle",
fetchFailureCount: 0,
fetchFailureReason: null
}
};
case "error":
const i = t.error;
return Ta(i) && i.revert && C(this, $r) ? { ...C(this, $r), fetchStatus: "idle" } : {
...r,
error: i,
errorUpdateCount: r.errorUpdateCount + 1,
errorUpdatedAt: Date.now(),
fetchFailureCount: r.fetchFailureCount + 1,
fetchFailureReason: i,
fetchStatus: "idle",
status: "error"
};
case "invalidate":
return {
...r,
isInvalidated: !0
};
case "setState":
return {
...r,
...t.state
};
}
};
this.state = n(this.state), $e.batch(() => {
this.observers.forEach((r) => {
r.onQueryUpdate();
}), C(this, ct).notify({ query: this, type: "updated", action: t });
});
}, Od);
function nf(e, t) {
return {
fetchFailureCount: 0,
fetchFailureReason: null,
fetchStatus: Zd(t.networkMode) ? "fetching" : "paused",
...e === void 0 && {
error: null,
status: "pending"
}
};
}
function hp(e) {
const t = typeof e.initialData == "function" ? e.initialData() : e.initialData, n = t !== void 0, r = n ? typeof e.initialDataUpdatedAt == "function" ? e.initialDataUpdatedAt() : e.initialDataUpdatedAt : 0;
return {
data: t,
dataUpdateCount: 0,
dataUpdatedAt: n ? r ?? Date.now() : 0,
error: null,
errorUpdateCount: 0,
errorUpdatedAt: 0,
fetchFailureCount: 0,
fetchFailureReason: null,
fetchMeta: null,
isInvalidated: !1,
status: n ? "success" : "pending",
fetchStatus: "idle"
};
}
var Ft, Dd, gp = (Dd = class extends Gn {
constructor(t = {}) {
super();
W(this, Ft);
this.config = t, B(this, Ft, /* @__PURE__ */ new Map());
}
build(t, n, r) {
const i = n.queryKey, o = n.queryHash ?? wl(i, n);
let a = this.get(o);
return a || (a = new fp({
client: t,
queryKey: i,
queryHash: o,
options: t.defaultQueryOptions(n),
state: r,
defaultOptions: t.getQueryDefaults(i)
}), this.add(a)), a;
}
add(t) {
C(this, Ft).has(t.queryHash) || (C(this, Ft).set(t.queryHash, t), this.notify({
type: "added",
query: t
}));
}
remove(t) {
const n = C(this, Ft).get(t.queryHash);
n && (t.destroy(), n === t && C(this, Ft).delete(t.queryHash), this.notify({ type: "removed", query: t }));
}
clear() {
$e.batch(() => {
this.getAll().forEach((t) => {
this.remove(t);
});
});
}
get(t) {
return C(this, Ft).get(t);
}
getAll() {
return [...C(this, Ft).values()];
}
find(t) {
const n = { exact: !0, ...t };
return this.getAll().find(
(r) => xu(n, r)
);
}
findAll(t = {}) {
const n = this.getAll();
return Object.keys(t).length > 0 ? n.filter((r) => xu(t, r)) : n;
}
notify(t) {
$e.batch(() => {
this.listeners.forEach((n) => {
n(t);
});
});
}
onFocus() {
$e.batch(() => {
this.getAll().forEach((t) => {
t.onFocus();
});
});
}
onOnline() {
$e.batch(() => {
this.getAll().forEach((t) => {
t.onOnline();
});
});
}
}, Ft = new WeakMap(), Dd), Lt, je, _n, It, Jt, Td, pp = (Td = class extends tf {
constructor(t) {
super();
W(this, It);
W(this, Lt);
W(this, je);
W(this, _n);
this.mutationId = t.mutationId, B(this, je, t.mutationCache), B(this, Lt, []), this.state = t.state || rf(), this.setOptions(t.options), this.scheduleGc();
}
setOptions(t) {
this.options = t, this.updateGcTime(this.options.gcTime);
}
get meta() {
return this.options.meta;
}
addObserver(t) {
C(this, Lt).includes(t) || (C(this, Lt).push(t), this.clearGcTimeout(), C(this, je).notify({
type: "observerAdded",
mutation: this,
observer: t
}));
}
removeObserver(t) {
B(this, Lt, C(this, Lt).filter((n) => n !== t)), this.scheduleGc(), C(this, je).notify({
type: "observerRemoved",
mutation: this,
observer: t
});
}
optionalRemove() {
C(this, Lt).length || (this.state.status === "pending" ? this.scheduleGc() : C(this, je).remove(this));
}
continue() {
var t;
return ((t = C(this, _n)) == null ? void 0 : t.continue()) ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
this.execute(this.state.variables);
}
async execute(t) {
var o, a, s, l, u, h, c, f, d, g, p, m, b, y, w, k, $, R, P, I;
const n = () => {
Y(this, It, Jt).call(this, { type: "continue" });
};
B(this, _n, ef({
fn: () => this.options.mutationFn ? this.options.mutationFn(t) : Promise.reject(new Error("No mutationFn found")),
onFail: (D, L) => {
Y(this, It, Jt).call(this, { type: "failed", failureCount: D, error: L });
},
onPause: () => {
Y(this, It, Jt).call(this, { type: "pause" });
},
onContinue: n,
retry: this.options.retry ?? 0,
retryDelay: this.options.retryDelay,
networkMode: this.options.networkMode,
canRun: () => C(this, je).canRun(this)
}));
const r = this.state.status === "pending", i = !C(this, _n).canStart();
try {
if (r)
n();
else {
Y(this, It, Jt).call(this, { type: "pending", variables: t, isPaused: i }), await ((a = (o = C(this, je).config).onMutate) == null ? void 0 : a.call(
o,
t,
this
));
const L = await ((l = (s = this.options).onMutate) == null ? void 0 : l.call(s, t));
L !== this.state.context && Y(this, It, Jt).call(this, {
type: "pending",
context: L,
variables: t,
isPaused: i
});
}
const D = await C(this, _n).start();
return await ((h = (u = C(this, je).config).onSuccess) == null ? void 0 : h.call(
u,
D,
t,
this.state.context,
this
)), await ((f = (c = this.options).onSuccess) == null ? void 0 : f.call(c, D, t, this.state.context)), await ((g = (d = C(this, je).config).onSettled) == null ? void 0 : g.call(
d,
D,
null,
this.state.variables,
this.state.context,
this
)), await ((m = (p = this.options).onSettled) == null ? void 0 : m.call(p, D, null, t, this.state.context)), Y(this, It, Jt).call(this, { type: "success", data: D }), D;
} catch (D) {
try {
throw await ((y = (b = C(this, je).config).onError) == null ? void 0 : y.call(
b,
D,
t,
this.state.context,
this
)), await ((k = (w = this.options).onError) == null ? void 0 : k.call(
w,
D,
t,
this.state.context
)), await ((R = ($ = C(this, je).config).onSettled) == null ? void 0 : R.call(
$,
void 0,
D,
this.state.variables,
this.state.context,
this
)), await ((I = (P = this.options).onSettled) == null ? void 0 : I.call(
P,
void 0,
D,
t,
this.state.context
)), D;
} finally {
Y(this, It, Jt).call(this, { type: "error", error: D });
}
} finally {
C(this, je).runNext(this);
}
}
}, Lt = new WeakMap(), je = new WeakMap(), _n = new WeakMap(), It = new WeakSet(), Jt = function(t) {
const n = (r) => {
switch (t.type) {
case "failed":
return {
...r,
failureCount: t.failureCount,
failureReason: t.error
};
case "pause":
return {
...r,
isPaused: !0
};
case "continue":
return {
...r,
isPaused: !1
};
case "pending":
return {
...r,
context: t.context,
data: void 0,
failureCount: 0,
failureReason: null,
error: null,
isPaused: t.isPaused,
status: "pending",
variables: t.variables,
submittedAt: Date.now()
};
case "success":
return {
...r,
data: t.data,
failureCount: 0,
failureReason: null,
error: null,
status: "success",
isPaused: !1
};
case "error":
return {
...r,
data: void 0,
error: t.error,
failureCount: r.failureCount + 1,
failureReason: t.error,
isPaused: !1,
status: "error"
};
}
};
this.state = n(this.state), $e.batch(() => {
C(this, Lt).forEach((r) => {
r.onMutationUpdate(t);
}), C(this, je).notify({
mutation: this,
type: "updated",
action: t
});
});
}, Td);
function rf() {
return {
context: void 0,
data: void 0,
error: null,
failureCount: 0,
failureReason: null,
isPaused: !1,
status: "idle",
variables: void 0,
submittedAt: 0
};
}
var zt, xt, Oi, Fd, mp = (Fd = class extends Gn {
constructor(t = {}) {
super();
W(this, zt);
W(this, xt);
W(this, Oi);
this.config = t, B(this, zt, /* @__PURE__ */ new Set()), B(this, xt, /* @__PURE__ */ new Map()), B(this, Oi, 0);
}
build(t, n, r) {
const i = new pp({
mutationCache: this,
mutationId: ++Gi(this, Oi)._,
options: t.defaultMutationOptions(n),
state: r
});
return this.add(i), i;
}
add(t) {
C(this, zt).add(t);
const n = Qi(t);
if (typeof n == "string") {
const r = C(this, xt).get(n);
r ? r.push(t) : C(this, xt).set(n, [t]);
}
this.notify({ type: "added", mutation: t });
}
remove(t) {
if (C(this, zt).delete(t)) {
const n = Qi(t);
if (typeof n == "string") {
const r = C(this, xt).get(n);
if (r)
if (r.length > 1) {
const i = r.indexOf(t);
i !== -1 && r.splice(i, 1);
} else r[0] === t && C(this, xt).delete(n);
}
}
this.notify({ type: "removed", mutation: t });
}
canRun(t) {
const n = Qi(t);
if (typeof n == "string") {
const r = C(this, xt).get(n), i = r == null ? void 0 : r.find(
(o) => o.state.status === "pending"
);
return !i || i === t;
} else
return !0;
}
runNext(t) {
var r;
const n = Qi(t);
if (typeof n == "string") {
const i = (r = C(this, xt).get(n)) == null ? void 0 : r.find((o) => o !== t && o.state.isPaused);
return (i == null ? void 0 : i.continue()) ?? Promise.resolve();
} else
return Promise.resolve();
}
clear() {
$e.batch(() => {
C(this, zt).forEach((t) => {
this.notify({ type: "removed", mutation: t });
}), C(this, zt).clear(), C(this, xt).clear();
});
}
getAll() {
return Array.from(C(this, zt));
}
find(t) {
const n = { exact: !0, ...t };
return this.getAll().find(
(r) => Cu(n, r)
);
}
findAll(t = {}) {
return this.getAll().filter((n) => Cu(t, n));
}
notify(t) {
$e.batch(() => {
this.listeners.forEach((n) => {
n(t);
});
});
}
resumePausedMutations() {
const t = this.getAll().filter((n) => n.state.isPaused);
return $e.batch(
() => Promise.all(
t.map((n) => n.continue().catch(_e))
)
);
}
}, zt = new WeakMap(), xt = new WeakMap(), Oi = new WeakMap(), Fd);
function Qi(e) {
var t;
return (t = e.options.scope) == null ? void 0 : t.id;
}
function Ro(e) {
return {
onFetch: (t, n) => {
var h, c, f, d, g;
const r = t.options, i = (f = (c = (h = t.fetchOptions) == null ? void 0 : h.meta) == null ? void 0 : c.fetchMore) == null ? void 0 : f.direction, o = ((d = t.state.data) == null ? void 0 : d.pages) || [], a = ((g = t.state.data) == null ? void 0 : g.pageParams) || [];
let s = { pages: [], pageParams: [] }, l = 0;
const u = async () => {
let p = !1;
const m = (w) => {
Object.defineProperty(w, "signal", {
enumerable: !0,
get: () => (t.signal.aborted ? p = !0 : t.signal.addEventListener("abort", () => {
p = !0;
}), t.signal)
});
}, b = Yd(t.options, t.fetchOptions), y = async (w, k, $) => {
if (p)
return Promise.reject();
if (k == null && w.pages.length)
return Promise.resolve(w);
const R = {
client: t.client,
queryKey: t.queryKey,
pageParam: k,
direction: $ ? "backward" : "forward",
meta: t.options.meta
};
m(R);
const P = await b(
R
), { maxPages: I } = t.options, D = $ ? ap : op;
return {
pages: D(w.pages, P, I),
pageParams: D(w.pageParams, k, I)
};
};
if (i && o.length) {
const w = i === "backward", k = w ? of : bs, $ = {
pages: o,
pageParams: a
}, R = k(r, $);
s = await y($, R, w);
} else {
const w = e ?? o.length;
do {
const k = l === 0 ? a[0] ?? r.initialPageParam : bs(r, s);
if (l > 0 && k == null)
break;
s = await y(s, k), l++;
} while (l < w);
}
return s;
};
t.options.persister ? t.fetchFn = () => {
var p, m;
return (m = (p = t.options).persister) == null ? void 0 : m.call(
p,
u,
{
client: t.client,
queryKey: t.queryKey,
meta: t.options.meta,
signal: t.signal
},
n
);
} : t.fetchFn = u;
}
};
}
function bs(e, { pages: t, pageParams: n }) {
const r = t.length - 1;
return t.length > 0 ? e.getNextPageParam(
t[r],
t,
n[r],
n
) : void 0;
}
function of(e, { pages: t, pageParams: n }) {
var r;
return t.length > 0 ? (r = e.getPreviousPageParam) == null ? void 0 : r.call(e, t[0], t, n[0], n) : void 0;
}
function bp(e, t) {
return t ? bs(e, t) != null : !1;
}
function vp(e, t) {
return !t || !e.getPreviousPageParam ? !1 : of(e, t) != null;
}
var Ce, rn, on, Sr, Er, an, Pr, Rr, Ld, yp = (Ld = class {
constructor(e = {}) {
W(this, Ce);
W(this, rn);
W(this, on);
W(this, Sr);
W(this, Er);
W(this, an);
W(this, Pr);
W(this, Rr);
B(this, Ce, e.queryCache || new gp()), B(this, rn, e.mutationCache || new mp()), B(this, on, e.defaultOptions || {}), B(this, Sr, /* @__PURE__ */ new Map()), B(this, Er, /* @__PURE__ */ new Map()), B(this, an, 0);
}
mount() {
Gi(this, an)._++, C(this, an) === 1 && (B(this, Pr, Cl.subscribe(async (e) => {
e && (await this.resumePausedMutations(), C(this, Ce).onFocus());
})), B(this, Rr, Po.subscribe(async (e) => {
e && (await this.resumePausedMutations(), C(this, Ce).onOnline());
})));
}
unmount() {
var e, t;
Gi(this, an)._--, C(this, an) === 0 && ((e = C(this, Pr)) == null || e.call(this), B(this, Pr, void 0), (t = C(this, Rr)) == null || t.call(this), B(this, Rr, void 0));
}
isFetching(e) {
return C(this, Ce).findAll({ ...e, fetchStatus: "fetching" }).length;
}
isMutating(e) {
return C(this, rn).findAll({ ...e, status: "pending" }).length;
}
/**
* Imperative (non-reactive) way to retrieve data for a QueryKey.
* Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.
*
* Hint: Do not use this function inside a component, because it won't receive updates.
* Use `useQuery` to create a `QueryObserver` that subscribes to changes.
*/
getQueryData(e) {
var n;
const t = this.defaultQueryOptions({ queryKey: e });
return (n = C(this, Ce).get(t.queryHash)) == null ? void 0 : n.state.data;
}
ensureQueryData(e) {
const t = this.defaultQueryOptions(e), n = C(this, Ce).build(this, t), r = n.state.data;
return r === void 0 ? this.fetchQuery(e) : (e.revalidateIfStale && n.isStaleByTime(gr(t.staleTime, n)) && this.prefetchQuery(t), Promise.resolve(r));
}
getQueriesData(e) {
return C(this, Ce).findAll(e).map(({ queryKey: t, state: n }) => {
const r = n.data;
return [t, r];
});
}
setQueryData(e, t, n) {
const r = this.defaultQueryOptions({ queryKey: e }), i = C(this, Ce).get(
r.queryHash
), o = i == null ? void 0 : i.state.data, a = rp(t, o);
if (a !== void 0)
return C(this, Ce).build(this, r).setData(a, { ...n, manual: !0 });
}
setQueriesData(e, t, n) {
return $e.batch(
() => C(this, Ce).findAll(e).map(({ queryKey: r }) => [
r,
this.setQueryData(r, t, n)
])
);
}
getQueryState(e) {
var n;
const t = this.defaultQueryOptions({ queryKey: e });
return (n = C(this, Ce).get(
t.queryHash
)) == null ? void 0 : n.state;
}
removeQueries(e) {
const t = C(this, Ce);
$e.batch(() => {
t.findAll(e).forEach((n) => {
t.remove(n);
});
});
}
resetQueries(e, t) {
const n = C(this, Ce);
return $e.batch(() => (n.findAll(e).forEach((r) => {
r.reset();
}), this.refetchQueries(
{
type: "active",
...e
},
t
)));
}
cancelQueries(e, t = {}) {
const n = { revert: !0, ...t }, r = $e.batch(
() => C(this, Ce).findAll(e).map((i) => i.cancel(n))
);
return Promise.all(r).then(_e).catch(_e);
}
invalidateQueries(e, t = {}) {
return $e.batch(() => (C(this, Ce).findAll(e).forEach((n) => {
n.invalidate();
}), (e == null ? void 0 : e.refetchType) === "none" ? Promise.resolve() : this.refetchQueries(
{
...e,
type: (e == null ? void 0 : e.refetchType) ?? (e == null ? void 0 : e.type) ?? "active"
},
t
)));
}
refetchQueries(e, t = {}) {
const n = {
...t,
cancelRefetch: t.cancelRefetch ?? !0
}, r = $e.batch(
() => C(this, Ce).findAll(e).filter((i) => !i.isDisabled()).map((i) => {
let o = i.fetch(void 0, n);
return n.throwOnError || (o = o.catch(_e)), i.state.fetchStatus === "paused" ? Promise.resolve() : o;
})
);
return Promise.all(r).then(_e);
}
fetchQuery(e) {
const t = this.defaultQueryOptions(e);
t.retry === void 0 && (t.retry = !1);
const n = C(this, Ce).build(this, t);
return n.isStaleByTime(
gr(t.staleTime, n)
) ? n.fetch(t) : Promise.resolve(n.state.data);
}
prefetchQuery(e) {
return this.fetchQuery(e).then(_e).catch(_e);
}
fetchInfiniteQuery(e) {
return e.behavior = Ro(e.pages), this.fetchQuery(e);
}
prefetchInfiniteQuery(e) {
return this.fetchInfiniteQuery(e).then(_e).catch(_e);
}
ensureInfiniteQueryData(e) {
return e.behavior = Ro(e.pages), this.ensureQueryData(e);
}
resumePausedMutations() {
return Po.isOnline() ? C(this, rn).resumePausedMutations() : Promise.resolve();
}
getQueryCache() {
return C(this, Ce);
}
getMutationCache() {
return C(this, rn);
}
getDefaultOptions() {
return C(this, on);
}
setDefaultOptions(e) {
B(this, on, e);
}
setQueryDefaults(e, t) {
C(this, Sr).set(yn(e), {
queryKey: e,
defaultOptions: t
});
}
getQueryDefaults(e) {
const t = [...C(this, Sr).values()], n = {};
return t.forEach((r) => {
mi(e, r.queryKey) && Object.assign(n, r.defaultOptions);
}), n;
}
setMutationDefaults(e, t) {
C(this, Er).set(yn(e), {
mutationKey: e,
defaultOptions: t
});
}
getMutationDefaults(e) {
const t = [...C(this, Er).values()], n = {};
return t.forEach((r) => {
mi(e, r.mutationKey) && Object.assign(n, r.defaultOptions);
}), n;
}
defaultQueryOptions(e) {
if (e._defaulted)
return e;
const t = {
...C(this, on).queries,
...this.getQueryDefaults(e.queryKey),
...e,
_defaulted: !0
};
return t.queryHash || (t.queryHash = wl(
t.queryKey,
t
)), t.refetchOnReconnect === void 0 && (t.refetchOnReconnect = t.networkMode !== "always"), t.throwOnError === void 0 && (t.throwOnError = !!t.suspense), !t.networkMode && t.persister && (t.networkMode = "offlineFirst"), t.queryFn === et && (t.enabled = !1), t;
}
defaultMutationOptions(e) {
return e != null && e._defaulted ? e : {
...C(this, on).mutations,
...(e == null ? void 0 : e.mutationKey) && this.getMutationDefaults(e.mutationKey),
...e,
_defaulted: !0
};
}
clear() {
C(this, Ce).clear(), C(this, rn).clear();
}
}, Ce = new WeakMap(), rn = new WeakMap(), on = new WeakMap(), Sr = new WeakMap(), Er = new WeakMap(), an = new WeakMap(), Pr = new WeakMap(), Rr = new WeakMap(), Ld), ze, ae, Di, Ke, jn, Mr, sn, ln, Ti, kr, Or, Kn, Bn, un, Dr, he, ai, vs, ys, ws, xs, Cs, $s, Ss, af, Id, Ni = (Id = class extends Gn {
constructor(t, n) {
super();
W(this, he);
W(this, ze);
W(this, ae);
W(this, Di);
W(this, Ke);
W(this, jn);
W(this, Mr);
W(this, sn);
W(this, ln);
W(this, Ti);
W(this, kr);
// This property keeps track of the last query with defined data.
// It will be used to pass the previous data and query to the placeholder function between renders.
W(this, Or);
W(this, Kn);
W(this, Bn);
W(this, un);
W(this, Dr, /* @__PURE__ */ new Set());
this.options = n, B(this, ze, t), B(this, ln, null), B(this, sn, ms()), this.options.experimental_prefetchInRender || C(this, sn).reject(
new Error("experimental_prefetchInRender feature flag is not enabled")
), this.bindMethods(), this.setOptions(n);
}
bindMethods() {
this.refetch = this.refetch.bind(this);
}
onSubscribe() {
this.listeners.size === 1 && (C(this, ae).addObserver(this), Eu(C(this, ae), this.options) ? Y(this, he, ai).call(this) : this.updateResult(), Y(this, he, xs).call(this));
}
onUnsubscribe() {
this.hasListeners() || this.destroy();
}
shouldFetchOnReconnect() {
return Es(
C(this, ae),
this.options,
this.options.refetchOnReconnect
);
}
shouldFetchOnWindowFocus() {
return Es(
C(this, ae),
this.options,
this.options.refetchOnWindowFocus
);
}
destroy() {
this.listeners = /* @__PURE__ */ new Set(), Y(this, he, Cs).call(this), Y(this, he, $s).call(this), C(this, ae).removeObserver(this);
}
setOptions(t) {
const n = this.options, r = C(this, ae);
if (this.options = C(this, ze).defaultQueryOptions(t), this.options.enabled !== void 0 && typeof this.options.enabled != "boolean" && typeof this.options.enabled != "function" && typeof $t(this.options.enabled, C(this, ae)) != "boolean")
throw new Error(
"Expected enabled to be a boolean or a callback that returns a boolean"
);
Y(this, he, Ss).call(this), C(this, ae).setOptions(this.options), n._defaulted && !Eo(this.options, n) && C(this, ze).getQueryCache().notify({
type: "observerOptionsUpdated",
query: C(this, ae),
observer: this
});
const i = this.hasListeners();
i && Pu(
C(this, ae),
r,
this.options,
n
) && Y(this, he, ai).call(this), this.updateResult(), i && (C(this, ae) !== r || $t(this.options.enabled, C(this, ae)) !== $t(n.enabled, C(this, ae)) || gr(this.options.staleTime, C(this, ae)) !== gr(n.staleTime, C(this, ae))) && Y(this, he, vs).call(this);
const o = Y(this, he, ys).call(this);
i && (C(this, ae) !== r || $t(this.options.enabled, C(this, ae)) !== $t(n.enabled, C(this, ae)) || o !== C(this, un)) && Y(this, he, ws).call(this, o);
}
getOptimisticResult(t) {
const n = C(this, ze).getQueryCache().build(C(this, ze), t), r = this.createResult(n, t);
return xp(this, r) && (B(this, Ke, r), B(this, Mr, this.options), B(this, jn, C(this, ae).state)), r;
}
getCurrentResult() {
return C(this, Ke);
}
trackResult(t, n) {
return new Proxy(t, {
get: (r, i) => (this.trackProp(i), n == null || n(i), Reflect.get(r, i))
});
}
trackProp(t) {
C(this, Dr).add(t);
}
getCurrentQuery() {
return C(this, ae);
}
refetch({ ...t } = {}) {
return this.fetch({
...t
});
}
fetchOptimistic(t) {
const n = C(this, ze).defaultQueryOptions(t), r = C(this, ze).getQueryCache().build(C(this, ze), n);
return r.fetch().then(() => this.createResult(r, n));
}
fetch(t) {
return Y(this, he, ai).call(this, {
...t,
cancelRefetch: t.cancelRefetch ?? !0
}).then(() => (this.updateResult(), C(this, Ke)));
}
createResult(t, n) {
var D;
const r = C(this, ae), i = this.options, o = C(this, Ke), a = C(this, jn), s = C(this, Mr), u = t !== r ? t.state : C(this, Di), { state: h } = t;
let c = { ...h }, f = !1, d;
if (n._optimisticResults) {
const L = this.hasListeners(), E = !L && Eu(t, n), N = L && Pu(t, r, n, i);
(E || N) && (c = {
...c,
...nf(h.data, t.options)
}), n._optimisticResults === "isRestoring" && (c.fetchStatus = "idle");
}
let { error: g, errorUpdatedAt: p, status: m } = c;
d = c.data;
let b = !1;
if (n.placeholderData !== void 0 && d === void 0 && m === "pending") {
let L;
o != null && o.isPlaceholderData && n.placeholderData === (s == null ? void 0 : s.placeholderData) ? (L = o.data, b = !0) : L = typeof n.placeholderData == "function" ? n.placeholderData(
(D = C(this, Or)) == null ? void 0 : D.state.data,
C(this, Or)
) : n.placeholderData, L !== void 0 && (m = "success", d = ps(
o == null ? void 0 : o.data,
L,
n
), f = !0);
}
if (n.select && d !== void 0 && !b)
if (o && d === (a == null ? void 0 : a.data) && n.select === C(this, Ti))
d = C(this, kr);
else
try {
B(this, Ti, n.select), d = n.select(d), d = ps(o == null ? void 0 : o.data, d, n), B(this, kr, d), B(this, ln, null);
} catch (L) {
B(this, ln, L);
}
C(this, ln) && (g = C(this, ln), d = C(this, kr), p = Date.now(), m = "error");
const y = c.fetchStatus === "fetching", w = m === "pending", k = m === "error", $ = w && y, R = d !== void 0, I = {
status: m,
fetchStatus: c.fetchStatus,
isPending: w,
isSuccess: m === "success",
isError: k,
isInitialLoading: $,
isLoading: $,
data: d,
dataUpdatedAt: c.dataUpdatedAt,
error: g,
errorUpdatedAt: p,
failureCount: c.fetchFailureCount,
failureReason: c.fetchFailureReason,
errorUpdateCount: c.errorUpdateCount,
isFetched: c.dataUpdateCount > 0 || c.errorUpdateCount > 0,
isFetchedAfterMount: c.dataUpdateCount > u.dataUpdateCount || c.errorUpdateCount > u.errorUpdateCount,
isFetching: y,
isRefetching: y && !w,
isLoadingError: k && !R,
isPaused: c.fetchStatus === "paused",
isPlaceholderData: f,
isRefetchError: k && R,
isStale: $l(t, n),
refetch: this.refetch,
promise: C(this, sn)
};
if (this.options.experimental_prefetchInRender) {
const L = (_) => {
I.status === "error" ? _.reject(I.error) : I.data !== void 0 && _.resolve(I.data);
}, E = () => {
const _ = B(this, sn, I.promise = ms());
L(_);
}, N = C(this, sn);
switch (N.status) {
case "pending":
t.queryHash === r.queryHash && L(N);
break;
case "fulfilled":
(I.status === "error" || I.data !== N.value) && E();
break;
case "rejected":
(I.status !== "error" || I.error !== N.reason) && E();
break;
}
}
return I;
}
updateResult() {
const t = C(this, Ke), n = this.createResult(C(this, ae), this.options);
if (B(this, jn, C(this, ae).state), B(this, Mr, this.options), C(this, jn).data !== void 0 && B(this, Or, C(this, ae)), Eo(n, t))
return;
B(this, Ke, n);
const r = () => {
if (!t)
return !0;
const { notifyOnChangeProps: i } = this.options, o = typeof i == "function" ? i() : i;
if (o === "all" || !o && !C(this, Dr).size)
return !0;
const a = new Set(
o ?? C(this, Dr)
);
return this.options.throwOnError && a.add("error"), Object.keys(C(this, Ke)).some((s) => {
const l = s;
return C(this, Ke)[l] !== t[l] && a.has(l);
});
};
Y(this, he, af).call(this, { listeners: r() });
}
onQueryUpdate() {
this.updateResult(), this.hasListeners() && Y(this, he, xs).call(this);
}
}, ze = new WeakMap(), ae = new WeakMap(), Di = new WeakMap(), Ke = new WeakMap(), jn = new WeakMap(), Mr = new WeakMap(), sn = new WeakMap(), ln = new WeakMap(), Ti = new WeakMap(), kr = new WeakMap(), Or = new WeakMap(), Kn = new WeakMap(), Bn = new WeakMap(), un = new WeakMap(), Dr = new WeakMap(), he = new WeakSet(), ai = function(t) {
Y(this, he, Ss).call(this);
let n = C(this, ae).fetch(
this.options,
t
);
return t != null && t.throwOnError || (n = n.catch(_e)), n;
}, vs = function() {
Y(this, he, Cs).call(this);
const t = gr(
this.options.staleTime,
C(this, ae)
);
if (Vn || C(this, Ke).isStale || !hs(t))
return;
const r = Qd(C(this, Ke).dataUpdatedAt, t) + 1;
B(this, Kn, setTimeout(() => {
C(this, Ke).isStale || this.updateResult();
}, r));
}, ys = function() {
return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(C(this, ae)) : this.options.refetchInterval) ?? !1;
}, ws = function(t) {
Y(this, he, $s).call(this), B(this, un, t), !(Vn || $t(this.options.enabled, C(this, ae)) === !1 || !hs(C(this, un)) || C(this, un) === 0) && B(this, Bn, setInterval(() => {
(this.options.refetchIntervalInBackground || Cl.isFocused()) && Y(this, he, ai).call(this);
}, C(this, un)));
}, xs = function() {
Y(this, he, vs).call(this), Y(this, he, ws).call(this, Y(this, he, ys).call(this));
}, Cs = function() {
C(this, Kn) && (clearTimeout(C(this, Kn)), B(this, Kn, void 0));
}, $s = function() {
C(this, Bn) && (clearInterval(C(this, Bn)), B(this, Bn, void 0));
}, Ss = function() {
const t = C(this, ze).getQueryCache().build(C(this, ze), this.options);
if (t === C(th