@queuedash/ui
Version:
A stunning, sleek dashboard for Bull, BullMQ, and Bee-Queue
1,612 lines • 828 kB
JavaScript
var Qu = (e) => {
throw TypeError(e);
};
var ts = (e, t, n) => t.has(e) || Qu("Cannot " + n);
var C = (e, t, n) => (ts(e, t, "read from private field"), n ? n.call(e) : t.get(e)), Y = (e, t, n) => t.has(e) ? Qu("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), V = (e, t, n, r) => (ts(e, t, "write to private field"), r ? r.call(e, n) : t.set(e, n), n), ee = (e, t, n) => (ts(e, t, "access private method"), n);
var vi = (e, t, n, r) => ({
set _(o) {
V(e, t, o, n);
},
get _() {
return C(e, t, r);
}
});
import * as E from "react";
import w, { forwardRef as ce, createElement as Q, createContext as ae, useState as J, useRef as z, useCallback as se, useContext as ue, useEffect as te, useMemo as ge, useReducer as Yg, cloneElement as xf, isValidElement as Xg, memo as Ql } from "react";
import Yl, { flushSync as wf, createPortal as Zg } from "react-dom";
function Cf(e) {
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
var $f = { exports: {} }, Ra = {};
/**
* @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 Jg = Symbol.for("react.transitional.element"), em = Symbol.for("react.fragment");
function Sf(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 o in t)
o !== "key" && (n[o] = t[o]);
} else n = t;
return t = n.ref, {
$$typeof: Jg,
type: e,
key: r,
ref: t !== void 0 ? t : null,
props: n
};
}
Ra.Fragment = em;
Ra.jsx = Sf;
Ra.jsxs = Sf;
$f.exports = Ra;
var b = $f.exports, nr = 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() {
}
}, tm = {
// We need the wrapper function syntax below instead of direct references to
// global setTimeout etc.
//
// BAD: `setTimeout: setTimeout`
// GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`
//
// If we use direct references here, then anything that wants to spy on or
// replace the global setTimeout (like tests) won't work since we'll already
// have a hard reference to the original implementation at the time when this
// file was imported.
setTimeout: (e, t) => setTimeout(e, t),
clearTimeout: (e) => clearTimeout(e),
setInterval: (e, t) => setInterval(e, t),
clearInterval: (e) => clearInterval(e)
}, un, Gl, lf, nm = (lf = class {
constructor() {
// We cannot have TimeoutManager<T> as we must instantiate it with a concrete
// type at app boot; and if we leave that type, then any new timer provider
// would need to support ReturnType<typeof setTimeout>, which is infeasible.
//
// We settle for type safety for the TimeoutProvider type, and accept that
// this class is unsafe internally to allow for extension.
Y(this, un, tm);
Y(this, Gl, !1);
}
setTimeoutProvider(e) {
V(this, un, e);
}
setTimeout(e, t) {
return C(this, un).setTimeout(e, t);
}
clearTimeout(e) {
C(this, un).clearTimeout(e);
}
setInterval(e, t) {
return C(this, un).setInterval(e, t);
}
clearInterval(e) {
C(this, un).clearInterval(e);
}
}, un = new WeakMap(), Gl = new WeakMap(), lf), Kn = new nm();
function rm(e) {
setTimeout(e, 0);
}
var Xn = typeof window > "u" || "Deno" in globalThis;
function Ue() {
}
function om(e, t) {
return typeof e == "function" ? e(t) : e;
}
function Hs(e) {
return typeof e == "number" && e >= 0 && e !== 1 / 0;
}
function Ef(e, t) {
return Math.max(e + (t || 0) - Date.now(), 0);
}
function Cn(e, t) {
return typeof e == "function" ? e(t) : e;
}
function bt(e, t) {
return typeof e == "function" ? e(t) : e;
}
function Yu(e, t) {
const {
type: n = "all",
exact: r,
fetchStatus: o,
predicate: i,
queryKey: a,
stale: s
} = e;
if (a) {
if (r) {
if (t.queryHash !== Xl(a, t.options))
return !1;
} else if (!Do(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 || o && o !== t.state.fetchStatus || i && !i(t));
}
function Xu(e, t) {
const { exact: n, status: r, predicate: o, mutationKey: i } = e;
if (i) {
if (!t.options.mutationKey)
return !1;
if (n) {
if (Pn(t.options.mutationKey) !== Pn(i))
return !1;
} else if (!Do(t.options.mutationKey, i))
return !1;
}
return !(r && t.state.status !== r || o && !o(t));
}
function Xl(e, t) {
return ((t == null ? void 0 : t.queryKeyHashFn) || Pn)(e);
}
function Pn(e) {
return JSON.stringify(
e,
(t, n) => Vs(n) ? Object.keys(n).sort().reduce((r, o) => (r[o] = n[o], r), {}) : n
);
}
function Do(e, t) {
return e === t ? !0 : typeof e != typeof t ? !1 : e && t && typeof e == "object" && typeof t == "object" ? Object.keys(t).every((n) => Do(e[n], t[n])) : !1;
}
var im = Object.prototype.hasOwnProperty;
function Zl(e, t) {
if (e === t)
return e;
const n = Zu(e) && Zu(t);
if (!n && !(Vs(e) && Vs(t))) return t;
const o = (n ? e : Object.keys(e)).length, i = n ? t : Object.keys(t), a = i.length, s = n ? new Array(a) : {};
let l = 0;
for (let u = 0; u < a; u++) {
const f = n ? u : i[u], c = e[f], h = t[f];
if (c === h) {
s[f] = c, (n ? u < o : im.call(e, f)) && l++;
continue;
}
if (c === null || h === null || typeof c != "object" || typeof h != "object") {
s[f] = h;
continue;
}
const d = Zl(c, h);
s[f] = d, d === c && l++;
}
return o === a && l === o ? e : s;
}
function _o(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 Zu(e) {
return Array.isArray(e) && e.length === Object.keys(e).length;
}
function Vs(e) {
if (!Ju(e))
return !1;
const t = e.constructor;
if (t === void 0)
return !0;
const n = t.prototype;
return !(!Ju(n) || !n.hasOwnProperty("isPrototypeOf") || Object.getPrototypeOf(e) !== Object.prototype);
}
function Ju(e) {
return Object.prototype.toString.call(e) === "[object Object]";
}
function am(e) {
return new Promise((t) => {
Kn.setTimeout(t, e);
});
}
function zs(e, t, n) {
return typeof n.structuralSharing == "function" ? n.structuralSharing(e, t) : n.structuralSharing !== !1 ? Zl(e, t) : t;
}
function sm(e, t, n = 0) {
const r = [...e, t];
return n && r.length > n ? r.slice(1) : r;
}
function lm(e, t, n = 0) {
const r = [t, ...e];
return n && r.length > n ? r.slice(0, -1) : r;
}
var ut = Symbol();
function Pf(e, t) {
return !e.queryFn && (t != null && t.initialPromise) ? () => t.initialPromise : !e.queryFn || e.queryFn === ut ? () => Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)) : e.queryFn;
}
function Rf(e, t) {
return typeof e == "function" ? e(...t) : !!e;
}
var Hn, cn, Rr, uf, um = (uf = class extends nr {
constructor() {
super();
Y(this, Hn);
Y(this, cn);
Y(this, Rr);
V(this, Rr, (t) => {
if (!Xn && window.addEventListener) {
const n = () => t();
return window.addEventListener("visibilitychange", n, !1), () => {
window.removeEventListener("visibilitychange", n);
};
}
});
}
onSubscribe() {
C(this, cn) || this.setEventListener(C(this, Rr));
}
onUnsubscribe() {
var t;
this.hasListeners() || ((t = C(this, cn)) == null || t.call(this), V(this, cn, void 0));
}
setEventListener(t) {
var n;
V(this, Rr, t), (n = C(this, cn)) == null || n.call(this), V(this, cn, t((r) => {
typeof r == "boolean" ? this.setFocused(r) : this.onFocus();
}));
}
setFocused(t) {
C(this, Hn) !== t && (V(this, Hn, t), this.onFocus());
}
onFocus() {
const t = this.isFocused();
this.listeners.forEach((n) => {
n(t);
});
}
isFocused() {
var t;
return typeof C(this, Hn) == "boolean" ? C(this, Hn) : ((t = globalThis.document) == null ? void 0 : t.visibilityState) !== "hidden";
}
}, Hn = new WeakMap(), cn = new WeakMap(), Rr = new WeakMap(), uf), Jl = new um();
function Us() {
let e, t;
const n = new Promise((o, i) => {
e = o, t = i;
});
n.status = "pending", n.catch(() => {
});
function r(o) {
Object.assign(n, o), delete n.resolve, delete n.reject;
}
return n.resolve = (o) => {
r({
status: "fulfilled",
value: o
}), e(o);
}, n.reject = (o) => {
r({
status: "rejected",
reason: o
}), t(o);
}, n;
}
var cm = rm;
function dm() {
let e = [], t = 0, n = (s) => {
s();
}, r = (s) => {
s();
}, o = cm;
const i = (s) => {
t ? e.push(s) : o(() => {
n(s);
});
}, a = () => {
const s = e;
e = [], s.length && o(() => {
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) => {
i(() => {
s(...l);
});
},
schedule: i,
/**
* 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) => {
o = s;
}
};
}
var Re = dm(), kr, dn, Mr, cf, fm = (cf = class extends nr {
constructor() {
super();
Y(this, kr, !0);
Y(this, dn);
Y(this, Mr);
V(this, Mr, (t) => {
if (!Xn && 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, dn) || this.setEventListener(C(this, Mr));
}
onUnsubscribe() {
var t;
this.hasListeners() || ((t = C(this, dn)) == null || t.call(this), V(this, dn, void 0));
}
setEventListener(t) {
var n;
V(this, Mr, t), (n = C(this, dn)) == null || n.call(this), V(this, dn, t(this.setOnline.bind(this)));
}
setOnline(t) {
C(this, kr) !== t && (V(this, kr, t), this.listeners.forEach((r) => {
r(t);
}));
}
isOnline() {
return C(this, kr);
}
}, kr = new WeakMap(), dn = new WeakMap(), Mr = new WeakMap(), cf), Xi = new fm();
function hm(e) {
return Math.min(1e3 * 2 ** e, 3e4);
}
function kf(e) {
return (e ?? "online") === "online" ? Xi.isOnline() : !0;
}
var qs = class extends Error {
constructor(e) {
super("CancelledError"), this.revert = e == null ? void 0 : e.revert, this.silent = e == null ? void 0 : e.silent;
}
};
function Mf(e) {
let t = !1, n = 0, r;
const o = Us(), i = () => o.status !== "pending", a = (g) => {
var m;
if (!i()) {
const v = new qs(g);
h(v), (m = e.onCancel) == null || m.call(e, v);
}
}, s = () => {
t = !0;
}, l = () => {
t = !1;
}, u = () => Jl.isFocused() && (e.networkMode === "always" || Xi.isOnline()) && e.canRun(), f = () => kf(e.networkMode) && e.canRun(), c = (g) => {
i() || (r == null || r(), o.resolve(g));
}, h = (g) => {
i() || (r == null || r(), o.reject(g));
}, d = () => new Promise((g) => {
var m;
r = (v) => {
(i() || u()) && g(v);
}, (m = e.onPause) == null || m.call(e);
}).then(() => {
var g;
r = void 0, i() || (g = e.onContinue) == null || g.call(e);
}), p = () => {
if (i())
return;
let g;
const m = n === 0 ? e.initialPromise : void 0;
try {
g = m ?? e.fn();
} catch (v) {
g = Promise.reject(v);
}
Promise.resolve(g).then(c).catch((v) => {
var P;
if (i())
return;
const y = e.retry ?? (Xn ? 0 : 3), x = e.retryDelay ?? hm, S = typeof x == "function" ? x(n, v) : x, k = y === !0 || typeof y == "number" && n < y || typeof y == "function" && y(n, v);
if (t || !k) {
h(v);
return;
}
n++, (P = e.onFail) == null || P.call(e, n, v), am(S).then(() => u() ? void 0 : d()).then(() => {
t ? h(v) : p();
});
});
};
return {
promise: o,
status: () => o.status,
cancel: a,
continue: () => (r == null || r(), o),
cancelRetry: s,
continueRetry: l,
canStart: f,
start: () => (f() ? p() : d().then(p), o)
};
}
var Vn, df, Of = (df = class {
constructor() {
Y(this, Vn);
}
destroy() {
this.clearGcTimeout();
}
scheduleGc() {
this.clearGcTimeout(), Hs(this.gcTime) && V(this, Vn, Kn.setTimeout(() => {
this.optionalRemove();
}, this.gcTime));
}
updateGcTime(e) {
this.gcTime = Math.max(
this.gcTime || 0,
e ?? (Xn ? 1 / 0 : 5 * 60 * 1e3)
);
}
clearGcTimeout() {
C(this, Vn) && (Kn.clearTimeout(C(this, Vn)), V(this, Vn, void 0));
}
}, Vn = new WeakMap(), df), zn, Or, mt, Un, Ie, Wo, qn, kt, Ut, ff, pm = (ff = class extends Of {
constructor(t) {
super();
Y(this, kt);
Y(this, zn);
Y(this, Or);
Y(this, mt);
Y(this, Un);
Y(this, Ie);
Y(this, Wo);
Y(this, qn);
V(this, qn, !1), V(this, Wo, t.defaultOptions), this.setOptions(t.options), this.observers = [], V(this, Un, t.client), V(this, mt, C(this, Un).getQueryCache()), this.queryKey = t.queryKey, this.queryHash = t.queryHash, V(this, zn, tc(this.options)), this.state = t.state ?? C(this, zn), this.scheduleGc();
}
get meta() {
return this.options.meta;
}
get promise() {
var t;
return (t = C(this, Ie)) == null ? void 0 : t.promise;
}
setOptions(t) {
if (this.options = { ...C(this, Wo), ...t }, this.updateGcTime(this.options.gcTime), this.state && this.state.data === void 0) {
const n = tc(this.options);
n.data !== void 0 && (this.setState(
ec(n.data, n.dataUpdatedAt)
), V(this, zn, n));
}
}
optionalRemove() {
!this.observers.length && this.state.fetchStatus === "idle" && C(this, mt).remove(this);
}
setData(t, n) {
const r = zs(this.state.data, t, this.options);
return ee(this, kt, Ut).call(this, {
data: r,
type: "success",
dataUpdatedAt: n == null ? void 0 : n.updatedAt,
manual: n == null ? void 0 : n.manual
}), r;
}
setState(t, n) {
ee(this, kt, Ut).call(this, { type: "setState", state: t, setStateOptions: n });
}
cancel(t) {
var r, o;
const n = (r = C(this, Ie)) == null ? void 0 : r.promise;
return (o = C(this, Ie)) == null || o.cancel(t), n ? n.then(Ue).catch(Ue) : Promise.resolve();
}
destroy() {
super.destroy(), this.cancel({ silent: !0 });
}
reset() {
this.destroy(), this.setState(C(this, zn));
}
isActive() {
return this.observers.some(
(t) => bt(t.options.enabled, this) !== !1
);
}
isDisabled() {
return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === ut || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
}
isStatic() {
return this.getObserversCount() > 0 ? this.observers.some(
(t) => Cn(t.options.staleTime, this) === "static"
) : !1;
}
isStale() {
return this.getObserversCount() > 0 ? this.observers.some(
(t) => t.getCurrentResult().isStale
) : this.state.data === void 0 || this.state.isInvalidated;
}
isStaleByTime(t = 0) {
return this.state.data === void 0 ? !0 : t === "static" ? !1 : this.state.isInvalidated ? !0 : !Ef(this.state.dataUpdatedAt, t);
}
onFocus() {
var n;
const t = this.observers.find((r) => r.shouldFetchOnWindowFocus());
t == null || t.refetch({ cancelRefetch: !1 }), (n = C(this, Ie)) == null || n.continue();
}
onOnline() {
var n;
const t = this.observers.find((r) => r.shouldFetchOnReconnect());
t == null || t.refetch({ cancelRefetch: !1 }), (n = C(this, Ie)) == null || n.continue();
}
addObserver(t) {
this.observers.includes(t) || (this.observers.push(t), this.clearGcTimeout(), C(this, mt).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, Ie) && (C(this, qn) ? C(this, Ie).cancel({ revert: !0 }) : C(this, Ie).cancelRetry()), this.scheduleGc()), C(this, mt).notify({ type: "observerRemoved", query: this, observer: t }));
}
getObserversCount() {
return this.observers.length;
}
invalidate() {
this.state.isInvalidated || ee(this, kt, Ut).call(this, { type: "invalidate" });
}
async fetch(t, n) {
var l, u, f, c, h, d, p, g, m, v, y, x;
if (this.state.fetchStatus !== "idle" && // If the promise in the retyer is already rejected, we have to definitely
// re-start the fetch; there is a chance that the query is still in a
// pending state when that happens
((l = C(this, Ie)) == null ? void 0 : l.status()) !== "rejected") {
if (this.state.data !== void 0 && (n != null && n.cancelRefetch))
this.cancel({ silent: !0 });
else if (C(this, Ie))
return C(this, Ie).continueRetry(), C(this, Ie).promise;
}
if (t && this.setOptions(t), !this.options.queryFn) {
const S = this.observers.find((k) => k.options.queryFn);
S && this.setOptions(S.options);
}
const r = new AbortController(), o = (S) => {
Object.defineProperty(S, "signal", {
enumerable: !0,
get: () => (V(this, qn, !0), r.signal)
});
}, i = () => {
const S = Pf(this.options, n), P = (() => {
const R = {
client: C(this, Un),
queryKey: this.queryKey,
meta: this.meta
};
return o(R), R;
})();
return V(this, qn, !1), this.options.persister ? this.options.persister(
S,
P,
this
) : S(P);
}, s = (() => {
const S = {
fetchOptions: n,
options: this.options,
queryKey: this.queryKey,
client: C(this, Un),
state: this.state,
fetchFn: i
};
return o(S), S;
})();
(u = this.options.behavior) == null || u.onFetch(s, this), V(this, Or, this.state), (this.state.fetchStatus === "idle" || this.state.fetchMeta !== ((f = s.fetchOptions) == null ? void 0 : f.meta)) && ee(this, kt, Ut).call(this, { type: "fetch", meta: (c = s.fetchOptions) == null ? void 0 : c.meta }), V(this, Ie, Mf({
initialPromise: n == null ? void 0 : n.initialPromise,
fn: s.fetchFn,
onCancel: (S) => {
S instanceof qs && S.revert && this.setState({
...C(this, Or),
fetchStatus: "idle"
}), r.abort();
},
onFail: (S, k) => {
ee(this, kt, Ut).call(this, { type: "failed", failureCount: S, error: k });
},
onPause: () => {
ee(this, kt, Ut).call(this, { type: "pause" });
},
onContinue: () => {
ee(this, kt, Ut).call(this, { type: "continue" });
},
retry: s.options.retry,
retryDelay: s.options.retryDelay,
networkMode: s.options.networkMode,
canRun: () => !0
}));
try {
const S = await C(this, Ie).start();
if (S === void 0)
throw new Error(`${this.queryHash} data is undefined`);
return this.setData(S), (d = (h = C(this, mt).config).onSuccess) == null || d.call(h, S, this), (g = (p = C(this, mt).config).onSettled) == null || g.call(
p,
S,
this.state.error,
this
), S;
} catch (S) {
if (S instanceof qs) {
if (S.silent)
return C(this, Ie).promise;
if (S.revert) {
if (this.state.data === void 0)
throw S;
return this.state.data;
}
}
throw ee(this, kt, Ut).call(this, {
type: "error",
error: S
}), (v = (m = C(this, mt).config).onError) == null || v.call(
m,
S,
this
), (x = (y = C(this, mt).config).onSettled) == null || x.call(
y,
this.state.data,
S,
this
), S;
} finally {
this.scheduleGc();
}
}
}, zn = new WeakMap(), Or = new WeakMap(), mt = new WeakMap(), Un = new WeakMap(), Ie = new WeakMap(), Wo = new WeakMap(), qn = new WeakMap(), kt = new WeakSet(), Ut = 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,
...Tf(r.data, this.options),
fetchMeta: t.meta ?? null
};
case "success":
const o = {
...r,
...ec(t.data, t.dataUpdatedAt),
dataUpdateCount: r.dataUpdateCount + 1,
...!t.manual && {
fetchStatus: "idle",
fetchFailureCount: 0,
fetchFailureReason: null
}
};
return V(this, Or, t.manual ? o : void 0), o;
case "error":
const i = t.error;
return {
...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), Re.batch(() => {
this.observers.forEach((r) => {
r.onQueryUpdate();
}), C(this, mt).notify({ query: this, type: "updated", action: t });
});
}, ff);
function Tf(e, t) {
return {
fetchFailureCount: 0,
fetchFailureReason: null,
fetchStatus: kf(t.networkMode) ? "fetching" : "paused",
...e === void 0 && {
error: null,
status: "pending"
}
};
}
function ec(e, t) {
return {
data: e,
dataUpdatedAt: t ?? Date.now(),
error: null,
isInvalidated: !1,
status: "success"
};
}
function tc(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 Ze, de, Go, We, Wn, Tr, Wt, fn, Qo, Dr, _r, Gn, Qn, hn, Lr, ye, bo, Ws, Gs, Qs, Ys, Xs, Zs, Js, Df, hf, ti = (hf = class extends nr {
constructor(t, n) {
super();
Y(this, ye);
Y(this, Ze);
Y(this, de);
Y(this, Go);
Y(this, We);
Y(this, Wn);
Y(this, Tr);
Y(this, Wt);
Y(this, fn);
Y(this, Qo);
Y(this, Dr);
// 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.
Y(this, _r);
Y(this, Gn);
Y(this, Qn);
Y(this, hn);
Y(this, Lr, /* @__PURE__ */ new Set());
this.options = n, V(this, Ze, t), V(this, fn, null), V(this, Wt, Us()), this.bindMethods(), this.setOptions(n);
}
bindMethods() {
this.refetch = this.refetch.bind(this);
}
onSubscribe() {
this.listeners.size === 1 && (C(this, de).addObserver(this), nc(C(this, de), this.options) ? ee(this, ye, bo).call(this) : this.updateResult(), ee(this, ye, Ys).call(this));
}
onUnsubscribe() {
this.hasListeners() || this.destroy();
}
shouldFetchOnReconnect() {
return el(
C(this, de),
this.options,
this.options.refetchOnReconnect
);
}
shouldFetchOnWindowFocus() {
return el(
C(this, de),
this.options,
this.options.refetchOnWindowFocus
);
}
destroy() {
this.listeners = /* @__PURE__ */ new Set(), ee(this, ye, Xs).call(this), ee(this, ye, Zs).call(this), C(this, de).removeObserver(this);
}
setOptions(t) {
const n = this.options, r = C(this, de);
if (this.options = C(this, Ze).defaultQueryOptions(t), this.options.enabled !== void 0 && typeof this.options.enabled != "boolean" && typeof this.options.enabled != "function" && typeof bt(this.options.enabled, C(this, de)) != "boolean")
throw new Error(
"Expected enabled to be a boolean or a callback that returns a boolean"
);
ee(this, ye, Js).call(this), C(this, de).setOptions(this.options), n._defaulted && !_o(this.options, n) && C(this, Ze).getQueryCache().notify({
type: "observerOptionsUpdated",
query: C(this, de),
observer: this
});
const o = this.hasListeners();
o && rc(
C(this, de),
r,
this.options,
n
) && ee(this, ye, bo).call(this), this.updateResult(), o && (C(this, de) !== r || bt(this.options.enabled, C(this, de)) !== bt(n.enabled, C(this, de)) || Cn(this.options.staleTime, C(this, de)) !== Cn(n.staleTime, C(this, de))) && ee(this, ye, Ws).call(this);
const i = ee(this, ye, Gs).call(this);
o && (C(this, de) !== r || bt(this.options.enabled, C(this, de)) !== bt(n.enabled, C(this, de)) || i !== C(this, hn)) && ee(this, ye, Qs).call(this, i);
}
getOptimisticResult(t) {
const n = C(this, Ze).getQueryCache().build(C(this, Ze), t), r = this.createResult(n, t);
return mm(this, r) && (V(this, We, r), V(this, Tr, this.options), V(this, Wn, C(this, de).state)), r;
}
getCurrentResult() {
return C(this, We);
}
trackResult(t, n) {
return new Proxy(t, {
get: (r, o) => (this.trackProp(o), n == null || n(o), o === "promise" && (this.trackProp("data"), !this.options.experimental_prefetchInRender && C(this, Wt).status === "pending" && C(this, Wt).reject(
new Error(
"experimental_prefetchInRender feature flag is not enabled"
)
)), Reflect.get(r, o))
});
}
trackProp(t) {
C(this, Lr).add(t);
}
getCurrentQuery() {
return C(this, de);
}
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 ee(this, ye, bo).call(this, {
...t,
cancelRefetch: t.cancelRefetch ?? !0
}).then(() => (this.updateResult(), C(this, We)));
}
createResult(t, n) {
var _;
const r = C(this, de), o = this.options, i = C(this, We), a = C(this, Wn), s = C(this, Tr), u = t !== r ? t.state : C(this, Go), { state: f } = t;
let c = { ...f }, h = !1, d;
if (n._optimisticResults) {
const D = this.hasListeners(), j = !D && nc(t, n), K = D && rc(t, r, n, o);
(j || K) && (c = {
...c,
...Tf(f.data, t.options)
}), n._optimisticResults === "isRestoring" && (c.fetchStatus = "idle");
}
let { error: p, errorUpdatedAt: g, status: m } = c;
d = c.data;
let v = !1;
if (n.placeholderData !== void 0 && d === void 0 && m === "pending") {
let D;
i != null && i.isPlaceholderData && n.placeholderData === (s == null ? void 0 : s.placeholderData) ? (D = i.data, v = !0) : D = typeof n.placeholderData == "function" ? n.placeholderData(
(_ = C(this, _r)) == null ? void 0 : _.state.data,
C(this, _r)
) : n.placeholderData, D !== void 0 && (m = "success", d = zs(
i == null ? void 0 : i.data,
D,
n
), h = !0);
}
if (n.select && d !== void 0 && !v)
if (i && d === (a == null ? void 0 : a.data) && n.select === C(this, Qo))
d = C(this, Dr);
else
try {
V(this, Qo, n.select), d = n.select(d), d = zs(i == null ? void 0 : i.data, d, n), V(this, Dr, d), V(this, fn, null);
} catch (D) {
V(this, fn, D);
}
C(this, fn) && (p = C(this, fn), d = C(this, Dr), g = Date.now(), m = "error");
const y = c.fetchStatus === "fetching", x = m === "pending", S = m === "error", k = x && y, P = d !== void 0, M = {
status: m,
fetchStatus: c.fetchStatus,
isPending: x,
isSuccess: m === "success",
isError: S,
isInitialLoading: k,
isLoading: k,
data: d,
dataUpdatedAt: c.dataUpdatedAt,
error: p,
errorUpdatedAt: g,
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 && !x,
isLoadingError: S && !P,
isPaused: c.fetchStatus === "paused",
isPlaceholderData: h,
isRefetchError: S && P,
isStale: eu(t, n),
refetch: this.refetch,
promise: C(this, Wt),
isEnabled: bt(n.enabled, t) !== !1
};
if (this.options.experimental_prefetchInRender) {
const D = (I) => {
M.status === "error" ? I.reject(M.error) : M.data !== void 0 && I.resolve(M.data);
}, j = () => {
const I = V(this, Wt, M.promise = Us());
D(I);
}, K = C(this, Wt);
switch (K.status) {
case "pending":
t.queryHash === r.queryHash && D(K);
break;
case "fulfilled":
(M.status === "error" || M.data !== K.value) && j();
break;
case "rejected":
(M.status !== "error" || M.error !== K.reason) && j();
break;
}
}
return M;
}
updateResult() {
const t = C(this, We), n = this.createResult(C(this, de), this.options);
if (V(this, Wn, C(this, de).state), V(this, Tr, this.options), C(this, Wn).data !== void 0 && V(this, _r, C(this, de)), _o(n, t))
return;
V(this, We, n);
const r = () => {
if (!t)
return !0;
const { notifyOnChangeProps: o } = this.options, i = typeof o == "function" ? o() : o;
if (i === "all" || !i && !C(this, Lr).size)
return !0;
const a = new Set(
i ?? C(this, Lr)
);
return this.options.throwOnError && a.add("error"), Object.keys(C(this, We)).some((s) => {
const l = s;
return C(this, We)[l] !== t[l] && a.has(l);
});
};
ee(this, ye, Df).call(this, { listeners: r() });
}
onQueryUpdate() {
this.updateResult(), this.hasListeners() && ee(this, ye, Ys).call(this);
}
}, Ze = new WeakMap(), de = new WeakMap(), Go = new WeakMap(), We = new WeakMap(), Wn = new WeakMap(), Tr = new WeakMap(), Wt = new WeakMap(), fn = new WeakMap(), Qo = new WeakMap(), Dr = new WeakMap(), _r = new WeakMap(), Gn = new WeakMap(), Qn = new WeakMap(), hn = new WeakMap(), Lr = new WeakMap(), ye = new WeakSet(), bo = function(t) {
ee(this, ye, Js).call(this);
let n = C(this, de).fetch(
this.options,
t
);
return t != null && t.throwOnError || (n = n.catch(Ue)), n;
}, Ws = function() {
ee(this, ye, Xs).call(this);
const t = Cn(
this.options.staleTime,
C(this, de)
);
if (Xn || C(this, We).isStale || !Hs(t))
return;
const r = Ef(C(this, We).dataUpdatedAt, t) + 1;
V(this, Gn, Kn.setTimeout(() => {
C(this, We).isStale || this.updateResult();
}, r));
}, Gs = function() {
return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(C(this, de)) : this.options.refetchInterval) ?? !1;
}, Qs = function(t) {
ee(this, ye, Zs).call(this), V(this, hn, t), !(Xn || bt(this.options.enabled, C(this, de)) === !1 || !Hs(C(this, hn)) || C(this, hn) === 0) && V(this, Qn, Kn.setInterval(() => {
(this.options.refetchIntervalInBackground || Jl.isFocused()) && ee(this, ye, bo).call(this);
}, C(this, hn)));
}, Ys = function() {
ee(this, ye, Ws).call(this), ee(this, ye, Qs).call(this, ee(this, ye, Gs).call(this));
}, Xs = function() {
C(this, Gn) && (Kn.clearTimeout(C(this, Gn)), V(this, Gn, void 0));
}, Zs = function() {
C(this, Qn) && (Kn.clearInterval(C(this, Qn)), V(this, Qn, void 0));
}, Js = function() {
const t = C(this, Ze).getQueryCache().build(C(this, Ze), this.options);
if (t === C(this, de))
return;
const n = C(this, de);
V(this, de, t), V(this, Go, t.state), this.hasListeners() && (n == null || n.removeObserver(this), t.addObserver(this));
}, Df = function(t) {
Re.batch(() => {
t.listeners && this.listeners.forEach((n) => {
n(C(this, We));
}), C(this, Ze).getQueryCache().notify({
query: C(this, de),
type: "observerResultsUpdated"
});
});
}, hf);
function gm(e, t) {
return bt(t.enabled, e) !== !1 && e.state.data === void 0 && !(e.state.status === "error" && t.retryOnMount === !1);
}
function nc(e, t) {
return gm(e, t) || e.state.data !== void 0 && el(e, t, t.refetchOnMount);
}
function el(e, t, n) {
if (bt(t.enabled, e) !== !1 && Cn(t.staleTime, e) !== "static") {
const r = typeof n == "function" ? n(e) : n;
return r === "always" || r !== !1 && eu(e, t);
}
return !1;
}
function rc(e, t, n, r) {
return (e !== t || bt(r.enabled, e) === !1) && (!n.suspense || e.state.status !== "error") && eu(e, n);
}
function eu(e, t) {
return bt(t.enabled, e) !== !1 && e.isStaleByTime(Cn(t.staleTime, e));
}
function mm(e, t) {
return !_o(e.getCurrentResult(), t);
}
function Zi(e) {
return {
onFetch: (t, n) => {
var f, c, h, d, p;
const r = t.options, o = (h = (c = (f = t.fetchOptions) == null ? void 0 : f.meta) == null ? void 0 : c.fetchMore) == null ? void 0 : h.direction, i = ((d = t.state.data) == null ? void 0 : d.pages) || [], a = ((p = t.state.data) == null ? void 0 : p.pageParams) || [];
let s = { pages: [], pageParams: [] }, l = 0;
const u = async () => {
let g = !1;
const m = (x) => {
Object.defineProperty(x, "signal", {
enumerable: !0,
get: () => (t.signal.aborted ? g = !0 : t.signal.addEventListener("abort", () => {
g = !0;
}), t.signal)
});
}, v = Pf(t.options, t.fetchOptions), y = async (x, S, k) => {
if (g)
return Promise.reject();
if (S == null && x.pages.length)
return Promise.resolve(x);
const R = (() => {
const j = {
client: t.client,
queryKey: t.queryKey,
pageParam: S,
direction: k ? "backward" : "forward",
meta: t.options.meta
};
return m(j), j;
})(), M = await v(R), { maxPages: _ } = t.options, D = k ? lm : sm;
return {
pages: D(x.pages, M, _),
pageParams: D(x.pageParams, S, _)
};
};
if (o && i.length) {
const x = o === "backward", S = x ? _f : tl, k = {
pages: i,
pageParams: a
}, P = S(r, k);
s = await y(k, P, x);
} else {
const x = e ?? i.length;
do {
const S = l === 0 ? a[0] ?? r.initialPageParam : tl(r, s);
if (l > 0 && S == null)
break;
s = await y(s, S), l++;
} while (l < x);
}
return s;
};
t.options.persister ? t.fetchFn = () => {
var g, m;
return (m = (g = t.options).persister) == null ? void 0 : m.call(
g,
u,
{
client: t.client,
queryKey: t.queryKey,
meta: t.options.meta,
signal: t.signal
},
n
);
} : t.fetchFn = u;
}
};
}
function tl(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 _f(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 vm(e, t) {
return t ? tl(e, t) != null : !1;
}
function bm(e, t) {
return !t || !e.getPreviousPageParam ? !1 : _f(e, t) != null;
}
var Lf = class extends ti {
constructor(e, t) {
super(e, t);
}
bindMethods() {
super.bindMethods(), this.fetchNextPage = this.fetchNextPage.bind(this), this.fetchPreviousPage = this.fetchPreviousPage.bind(this);
}
setOptions(e) {
super.setOptions({
...e,
behavior: Zi()
});
}
getOptimisticResult(e) {
return e.behavior = Zi(), super.getOptimisticResult(e);
}
fetchNextPage(e) {
return this.fetch({
...e,
meta: {
fetchMore: { direction: "forward" }
}
});
}
fetchPreviousPage(e) {
return this.fetch({
...e,
meta: {
fetchMore: { direction: "backward" }
}
});
}
createResult(e, t) {
var p, g;
const { state: n } = e, r = super.createResult(e, t), { isFetching: o, isRefetching: i, isError: a, isRefetchError: s } = r, l = (g = (p = n.fetchMeta) == null ? void 0 : p.fetchMore) == null ? void 0 : g.direction, u = a && l === "forward", f = o && l === "forward", c = a && l === "backward", h = o && l === "backward";
return {
...r,
fetchNextPage: this.fetchNextPage,
fetchPreviousPage: this.fetchPreviousPage,
hasNextPage: vm(t, n.data),
hasPreviousPage: bm(t, n.data),
isFetchNextPageError: u,
isFetchingNextPage: f,
isFetchPreviousPageError: c,
isFetchingPreviousPage: h,
isRefetchError: s && !u && !c,
isRefetching: i && !f && !h
};
}
}, Yo, Nt, Ge, Yn, At, sn, pf, ym = (pf = class extends Of {
constructor(t) {
super();
Y(this, At);
Y(this, Yo);
Y(this, Nt);
Y(this, Ge);
Y(this, Yn);
V(this, Yo, t.client), this.mutationId = t.mutationId, V(this, Ge, t.mutationCache), V(this, Nt, []), this.state = t.state || Ff(), 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, Nt).includes(t) || (C(this, Nt).push(t), this.clearGcTimeout(), C(this, Ge).notify({
type: "observerAdded",
mutation: this,
observer: t
}));
}
removeObserver(t) {
V(this, Nt, C(this, Nt).filter((n) => n !== t)), this.scheduleGc(), C(this, Ge).notify({
type: "observerRemoved",
mutation: this,
observer: t
});
}
optionalRemove() {
C(this, Nt).length || (this.state.status === "pending" ? this.scheduleGc() : C(this, Ge).remove(this));
}
continue() {
var t;
return ((t = C(this, Yn)) == 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 a, s, l, u, f, c, h, d, p, g, m, v, y, x, S, k, P, R, M, _;
const n = () => {
ee(this, At, sn).call(this, { type: "continue" });
}, r = {
client: C(this, Yo),
meta: this.options.meta,
mutationKey: this.options.mutationKey
};
V(this, Yn, Mf({
fn: () => this.options.mutationFn ? this.options.mutationFn(t, r) : Promise.reject(new Error("No mutationFn found")),
onFail: (D, j) => {
ee(this, At, sn).call(this, { type: "failed", failureCount: D, error: j });
},
onPause: () => {
ee(this, At, sn).call(this, { type: "pause" });
},
onContinue: n,
retry: this.options.retry ?? 0,
retryDelay: this.options.retryDelay,
networkMode: this.options.networkMode,
canRun: () => C(this, Ge).canRun(this)
}));
const o = this.state.status === "pending", i = !C(this, Yn).canStart();
try {
if (o)
n();
else {
ee(this, At, sn).call(this, { type: "pending", variables: t, isPaused: i }), await ((s = (a = C(this, Ge).config).onMutate) == null ? void 0 : s.call(
a,
t,
this,
r
));
const j = await ((u = (l = this.options).onMutate) == null ? void 0 : u.call(
l,
t,
r
));
j !== this.state.context && ee(this, At, sn).call(this, {
type: "pending",
context: j,
variables: t,
isPaused: i
});
}
const D = await C(this, Yn).start();
return await ((c = (f = C(this, Ge).config).onSuccess) == null ? void 0 : c.call(
f,
D,
t,
this.state.context,
this,
r
)), await ((d = (h = this.options).onSuccess) == null ? void 0 : d.call(
h,
D,
t,
this.state.context,
r
)), await ((g = (p = C(this, Ge).config).onSettled) == null ? void 0 : g.call(
p,
D,
null,
this.state.variables,
this.state.context,
this,
r
)), await ((v = (m = this.options).onSettled) == null ? void 0 : v.call(
m,
D,
null,
t,
this.state.context,
r
)), ee(this, At, sn).call(this, { type: "success", data: D }), D;
} catch (D) {
try {
throw await ((x = (y = C(this, Ge).config).onError) == null ? void 0 : x.call(
y,
D,
t,
this.state.context,
this,
r
)), await ((k = (S = this.options).onError) == null ? void 0 : k.call(
S,
D,
t,
this.state.context,
r
)), await ((R = (P = C(this, Ge).config).onSettled) == null ? void 0 : R.call(
P,
void 0,
D,
this.state.variables,
this.state.context,
this,
r
)), await ((_ = (M = this.options).onSettled) == null ? void 0 : _.call(
M,
void 0,
D,
t,
this.state.context,
r
)), D;
} finally {
ee(this, At, sn).call(this, { type: "error", error: D });
}
} finally {
C(this, Ge).runNext(this);
}
}
}, Yo = new WeakMap(), Nt = new WeakMap(), Ge = new WeakMap(), Yn = new WeakMap(), At = new WeakSet(), sn = 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), Re.batch(() => {
C(this, Nt).forEach((r) => {
r.onMutationUpdate(t);
}), C(this, Ge).notify({
mutation: this,
type: "updated",
action: t
});
});
}, pf);
function Ff() {
return {
context: void 0,
data: void 0,
error: null,
failureCount: 0,
failureReason: null,
isPaused: !1,
status: "idle",
variables: void 0,
submittedAt: 0
};
}
var Gt, Mt, Xo, gf, xm = (gf = class extends nr {
constructor(t = {}) {
super();
Y(this, Gt);
Y(this, Mt);
Y(this, Xo);
this.config = t, V(this, Gt, /* @__PURE__ */ new Set()), V(this, Mt, /* @__PURE__ */ new Map()), V(this, Xo, 0);
}
build(t, n, r) {
const o = new ym({
client: t,
mutationCache: this,
mutationId: ++vi(this, Xo)._,
options: t.defaultMutationOptions(n),
state: r
});
return this.add(o), o;
}
add(t) {
C(this, Gt).add(t);
const n = bi(t);
if (typeof n == "string") {
const r = C(this, Mt).get(n);
r ? r.push(t) : C(this, Mt).set(n, [t]);
}
this.notify({ type: "added", mutation: t });
}
remove(t) {
if (C(this, Gt).delete(t)) {
const n = bi(t);
if (typeof n == "string") {
const r = C(this, Mt).get(n);
if (r)
if (r.length > 1) {
const o = r.indexOf(t);
o !== -1 && r.splice(o, 1);
} else r[0] === t && C(this, Mt).delete(n);
}
}
this.notify({ type: "removed", mutation: t });
}
canRun(t) {
const n = bi(t);
if (typeof n == "string") {
const r = C(this, Mt).get(n), o = r == null ? void 0 : r.find(
(i) => i.state.status === "pending"
);
return !o || o === t;
} else
return !0;
}
runNext(t) {
var r;
const n = bi(t);
if (typeof n == "string") {
const o = (r = C(this, Mt).get(n)) == null ? void 0 : r.find((i) => i !== t && i.state.isPaused);
return (o == null ? void 0 : o.continue()) ?? Promise.resolve();
} else
return Promise.resolve();
}
clear() {
Re.batch(() => {
C(this, Gt).forEach((t) => {
this.notify({ type: "removed", mutation: t });
}), C(this, Gt).clear(), C(this, Mt).clear();
});
}
getAll() {
return Array.from(C(this, Gt));
}
find(t) {
const n = { exact: !0, ...t };
return this.getAll().find(
(r) => Xu(n, r)
);
}
findAll(t = {}) {
return this.getAll().filter((n) => Xu(t, n));
}
notify(t) {
Re.batch(() => {
this.listeners.forEach((n) => {
n(t);
});
});
}
resumePausedMutations() {
const t = this.getAll().filter((n) => n.state.isPaused);
return Re.batch(
() => Promise.all(
t.map((n) => n.continue().catch(Ue))
)
);
}
}, Gt = new WeakMap(), Mt = new WeakMap(), Xo = new WeakMap(), gf);
function bi(e) {
var t;
return (t = e.options.scope) == null ? void 0 : t.id;
}
var Qt, pn, Je, Yt, Zt, Vi, nl, mf, wm = (mf = class extends nr {
constructor(n, r) {
super();
Y(this, Zt);
Y(this, Qt);
Y(this, pn);
Y(this, Je);
Y(this, Yt);
V(this, Qt, n), this.setOptions(r), this.bindMethods(), ee(this, Zt, Vi).call(this);
}
bindMethods() {
this.mutate = this.mutate.bind(this), this.reset = this.reset.bind(this);
}
setOptions(n) {
var o;
const r = this.options;
this.options = C(this, Qt).defaultMutationOptions(n), _o(this.options, r) || C(this, Qt).getMutationCache().notify({
type: "observerOptionsUpdated",
mutation: C(this, Je),
observer: this
}), r != null && r.mutationKey && this.options.mutationKey && Pn(r.mutationKey) !== Pn(this.options.mutationKey) ? this.reset() : ((o = C(this, Je)) == null ? void 0 : o.state.status) === "pending" && C(this, Je).setOptions(this.options);
}
onUnsubscribe() {
var n;
this.hasListeners() || (n = C(this, Je)) == null || n.removeObserver(this);
}
onMutationUpdate(n) {
ee(this, Zt, Vi).call(this), ee(this, Zt, nl).call(this, n);
}
getCurrentResult() {
return C(this, pn);
}
reset() {
var n;
(n = C(this, Je)) == null || n.removeObserver(this), V(this, Je, void 0), ee(this, Zt, Vi).call(this), ee(this, Zt, nl).call(this);
}
mutate(n, r) {
var o;
return V(this, Yt, r), (o = C(this, Je)) == null || o.removeObserver(this), V(this, Je, C(this, Qt).getMutationCache().build(C(this, Qt), this.options)), C(this, Je).addObserver(this), C(this, Je).execute(n);
}
}, Qt = new WeakMap(), pn = new WeakMap(), Je = new WeakMap(), Yt = new WeakMap(), Zt = new WeakSet(), Vi = function() {
var r;
const n = ((r = C(this, Je)) == null ? void 0 : r.state) ?? Ff();
V(this, pn, {
...n,
isPending: n.status === "pending",
isSuccess: n.status === "success",
isError: n.status === "error",
isIdle: n.status === "idle",
mutate: this.mutate,
reset: this.reset
});
}, nl = function(n) {
Re.batch(() => {
var r, o, i, a, s, l, u, f;
if (C(this, Yt) && this.hasListeners()) {
const c = C(this, pn).variables, h = C(this, pn).context, d = {
client: C(this, Qt),
meta: this.options.meta,
mutationKey: this.options.mutationKey
};
(n == null ? void 0 : n.type) === "success" ? ((o = (r = C(this, Y