vue-hooks-plus
Version:
Vue hooks library
1,734 lines • 190 kB
JavaScript
var Lu = Object.defineProperty;
var ku = (e, t, n) => t in e ? Lu(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
var W = (e, t, n) => (ku(e, typeof t != "symbol" ? t + "" : t, n), n);
import { ref as E, watchEffect as B, unref as w, watch as $, onScopeDispose as Pe, computed as x, onUnmounted as Re, inject as Nu, reactive as ht, isRef as fe, toRefs as en, provide as Uu, shallowReadonly as _o, readonly as V, markRaw as po, onMounted as _t, onBeforeUnmount as $u, nextTick as Bu, getCurrentScope as Vu, defineComponent as vo, isVNode as Mu, cloneVNode as ju } from "vue";
const mo = (e, { manual: t, ready: n = !0, refreshDeps: r = [], refreshDepsAction: o }) => {
const u = E(!1);
return B(() => {
!t && e.options.refreshDeps !== !0 && (u.value = w(n));
}), r instanceof Array ? $(
[u, ...r],
([a]) => {
!a || !t && a && (o ? o() : e.refresh());
},
{
deep: !0,
immediate: !1
}
) : $(u, (a) => {
!t && a && (o ? o() : e.refresh());
}), {
name: "autoRunPlugin",
onBefore: () => {
if (!w(n))
return {
stopNow: !0
};
}
};
};
mo.onInit = ({ ready: e = !0, manual: t }) => ({
loading: !t && w(e)
});
const we = /* @__PURE__ */ new Map(), Hu = (e, t, n) => {
const r = we.get(e);
r != null && r.timer && clearTimeout(r.timer);
let o;
t > -1 && (o = setTimeout(() => {
we.delete(e);
}, t)), we.set(e, {
...n,
timer: o
});
}, zu = (e) => we.get(e), pg = (e) => {
e ? (Array.isArray(e) ? e : [e]).forEach((n) => we.delete(n)) : we.clear();
}, at = /* @__PURE__ */ new Map(), Ku = (e) => at.get(e), qu = (e, t) => {
at.set(e, t), t.then((n) => (at.delete(e), n)).catch((n) => {
throw at.delete(e), n;
});
}, le = {}, Gu = [], Wu = (e, t) => {
le[e] && (le[e].forEach((n) => n(t)), Gu.forEach((n) => n({
type: e,
data: t
})));
}, Ot = (e, t) => (le[e] || (le[e] = []), le[e].push(t), function() {
const r = le[e].indexOf(t);
le[e].splice(r, 1);
}), Yu = (e, {
cacheKey: t,
cacheTime: n = 5 * 60 * 1e3,
staleTime: r = 0,
setCache: o,
getCache: u
}) => {
const a = E(), s = E(), i = (f, l) => {
o ? o(l) : Hu(f, n, l), Wu(f, l.data);
}, c = (f, l = []) => u ? u(l) : zu(f);
return B(() => {
if (!t)
return;
const f = c(t);
f && Object.hasOwnProperty.call(f, "data") && (e.state.data = f.data, e.state.params = f.params, (r === -1 || new Date().getTime() - f.time <= r) && (e.state.loading = !1)), a.value = Ot(t, (l) => {
e.setState({ data: l });
});
}), Pe(() => {
var f;
(f = a.value) == null || f.call(a);
}), t ? {
name: "cachePlugin",
onBefore: (f) => {
const l = c(t, f);
return !l || !Object.hasOwnProperty.call(l, "data") ? {} : r === -1 || new Date().getTime() - l.time <= r ? {
loading: !1,
data: l == null ? void 0 : l.data,
returnNow: !0
} : {
data: l == null ? void 0 : l.data
};
},
onRequest: (f, l) => {
let g = Ku(t);
return g && g !== s.value ? { servicePromise: g } : (g = f(...l), s.value = g, qu(t, g), { servicePromise: g });
},
onSuccess: (f, l) => {
var g;
t && ((g = a.value) == null || g.call(a), i(t, {
data: f,
params: l,
time: new Date().getTime()
}), a.value = Ot(t, (d) => {
e.setState({ data: d });
}));
},
onMutate: (f) => {
var l;
t && ((l = a.value) == null || l.call(a), i(t, {
data: f,
params: e.state.params,
time: new Date().getTime()
}), a.value = Ot(t, (g) => {
e.setState({ data: g });
}));
}
} : {};
};
function q(e) {
var t = typeof e;
return e != null && (t == "object" || t == "function");
}
var Xu = typeof global == "object" && global && global.Object === Object && global;
const Eo = Xu;
var Zu = typeof self == "object" && self && self.Object === Object && self, Ju = Eo || Zu || Function("return this")();
const Y = Ju;
var Qu = function() {
return Y.Date.now();
};
const wt = Qu;
var ea = /\s/;
function ta(e) {
for (var t = e.length; t-- && ea.test(e.charAt(t)); )
;
return t;
}
var na = /^\s+/;
function ra(e) {
return e && e.slice(0, ta(e) + 1).replace(na, "");
}
var oa = Y.Symbol;
const oe = oa;
var yo = Object.prototype, ua = yo.hasOwnProperty, aa = yo.toString, ke = oe ? oe.toStringTag : void 0;
function sa(e) {
var t = ua.call(e, ke), n = e[ke];
try {
e[ke] = void 0;
var r = !0;
} catch {
}
var o = aa.call(e);
return r && (t ? e[ke] = n : delete e[ke]), o;
}
var ia = Object.prototype, la = ia.toString;
function ca(e) {
return la.call(e);
}
var fa = "[object Null]", da = "[object Undefined]", In = oe ? oe.toStringTag : void 0;
function _e(e) {
return e == null ? e === void 0 ? da : fa : In && In in Object(e) ? sa(e) : ca(e);
}
function ee(e) {
return e != null && typeof e == "object";
}
var ga = "[object Symbol]";
function ha(e) {
return typeof e == "symbol" || ee(e) && _e(e) == ga;
}
var Pn = 0 / 0, _a = /^[-+]0x[0-9a-f]+$/i, pa = /^0b[01]+$/i, va = /^0o[0-7]+$/i, ma = parseInt;
function Rn(e) {
if (typeof e == "number")
return e;
if (ha(e))
return Pn;
if (q(e)) {
var t = typeof e.valueOf == "function" ? e.valueOf() : e;
e = q(t) ? t + "" : t;
}
if (typeof e != "string")
return e === 0 ? e : +e;
e = ra(e);
var n = pa.test(e);
return n || va.test(e) ? ma(e.slice(2), n ? 2 : 8) : _a.test(e) ? Pn : +e;
}
var Ea = "Expected a function", ya = Math.max, ba = Math.min;
function tn(e, t, n) {
var r, o, u, a, s, i, c = 0, f = !1, l = !1, g = !0;
if (typeof e != "function")
throw new TypeError(Ea);
t = Rn(t) || 0, q(n) && (f = !!n.leading, l = "maxWait" in n, u = l ? ya(Rn(n.maxWait) || 0, t) : u, g = "trailing" in n ? !!n.trailing : g);
function d(O) {
var L = r, k = o;
return r = o = void 0, c = O, a = e.apply(k, L), a;
}
function h(O) {
return c = O, s = setTimeout(p, t), f ? d(O) : a;
}
function v(O) {
var L = O - i, k = O - c, M = t - L;
return l ? ba(M, u - k) : M;
}
function _(O) {
var L = O - i, k = O - c;
return i === void 0 || L >= t || L < 0 || l && k >= u;
}
function p() {
var O = wt();
if (_(O))
return b(O);
s = setTimeout(p, v(O));
}
function b(O) {
return s = void 0, g && r ? d(O) : (r = o = void 0, a);
}
function T() {
s !== void 0 && clearTimeout(s), c = 0, r = i = o = s = void 0;
}
function S() {
return s === void 0 ? a : b(wt());
}
function A() {
var O = wt(), L = _(O);
if (r = arguments, o = this, i = O, L) {
if (s === void 0)
return h(i);
if (l)
return clearTimeout(s), s = setTimeout(p, t), d(i);
}
return s === void 0 && (s = setTimeout(p, t)), a;
}
return A.cancel = T, A.flush = S, A;
}
const Ta = (e, { debounceWait: t, debounceLeading: n, debounceTrailing: r, debounceMaxWait: o }) => {
const u = E(), a = x(() => {
const s = {}, i = w(n), c = w(r), f = w(o);
return i !== void 0 && (s.leading = i), c !== void 0 && (s.trailing = c), f !== void 0 && (s.maxWait = f), s;
});
return B((s) => {
if (w(t)) {
const i = e.runAsync.bind(e);
u.value = tn(
(c) => {
c();
},
w(t),
a.value
), e.runAsync = (...c) => new Promise((f, l) => {
var g;
(g = u.value) == null || g.call(u, () => {
i(...c).then(f).catch(l);
});
}), s(() => {
var c;
(c = u.value) == null || c.cancel(), e.runAsync = i;
});
}
}), w(t) ? {
name: "debouncePlugin",
onCancel: () => {
var s;
(s = u.value) == null || s.cancel();
}
} : {};
};
function Aa(e) {
const n = e.toString().match(/^function\s+([^\s(]+)/);
return n ? n[1] : "";
}
function Oa(e) {
const t = e.toString(), n = /([a-zA-Z$_][a-zA-Z0-9$_]*)\s*\(/, r = t.match(n);
return r ? r[1].trim() : "";
}
function wa(e) {
return e === "pending" ? 16747520 : e === "done" ? 6586111 : e === "error" ? 16724736 : e === "cancel" ? 10500409 : e === "mutate" ? 27647 : 4873398;
}
class Sa {
constructor() {
W(this, "requestInstances", /* @__PURE__ */ new Map());
W(this, "listeners", []);
}
emit(t) {
this.listeners.forEach((n) => n(t));
}
subscribe(t) {
return this.listeners.push(t), () => {
const n = this.listeners.indexOf(t);
this.listeners.splice(n, 1);
};
}
insert(t, n) {
this.requestInstances.set(t, { ...n }), this.emit({
key: t,
...n
});
}
update(t, n) {
this.has(t) && this.requestInstances.set(t, { ...this.requestInstances.get(t), ...n });
}
has(t) {
return this.requestInstances.has(t);
}
reset(t) {
if (this.requestInstances.has(t)) {
const n = this.requestInstances.get(t);
this.requestInstances.clear(), this.insert(t, n);
} else
this.requestInstances.clear();
}
getAll() {
return this.requestInstances;
}
}
const N = new Sa(), Ca = (e, { ready: t = !0, debugKey: n, ...r }) => {
const o = () => {
if (n && !N.has(n)) {
const a = e.serviceRef.value.toString().includes("function") ? Aa(e.serviceRef.value.toString()) : Oa(e.serviceRef.value.toString());
N.insert(n, {
instance: e,
requestName: a,
time: Date.now()
});
}
}, u = x(
() => Object.fromEntries(
Object.entries({ ready: t, ...r }).map(([a, s]) => [a, w(s)])
)
);
return B(() => {
n && N.has(n) && N.emit({
...e,
options: { ...e.options, ...u.value }
});
}), {
name: "devtoolsPlugin",
onBefore: (a) => {
o(), n && N.has(n) && N.emit({
...e.state,
key: n,
params: a,
loading: !0,
time: Date.now(),
type: "pending"
});
},
onSuccess(a, s) {
o(), n && N.has(n) && N.emit({
...e.state,
key: n,
data: a,
params: s,
loading: !1,
time: Date.now(),
type: "done"
});
},
onCancel() {
o(), n && N.has(n) && N.emit({
...e.state,
key: n,
loading: !1,
time: Date.now(),
type: "cancel"
});
},
onError(a, s) {
o(), n && N.has(n) && N.emit({
...e.state,
key: n,
params: s,
loading: !1,
error: a,
time: Date.now(),
type: "error"
});
},
onMutate(a) {
o(), n && N.has(n) && N.emit({
...e.state,
key: n,
data: a,
loading: !1,
time: Date.now(),
type: "mutate"
});
}
};
}, Da = (e, { loadingDelay: t }) => {
const n = E(), r = () => {
n.value && (clearTimeout(w(n.value)), n.value = void 0);
};
return {
name: "loadingDelayPlugin",
onFinally: () => {
r();
const o = w(t);
o && (e.setState({
loading: !0
}), n.value = setTimeout(() => {
e.setState({
loading: !1
});
}, o));
},
onError: () => {
r();
}
};
};
function nn() {
return !!(typeof window < "u" && window.document && window.document.createElement);
}
const Ia = !!(typeof window < "u" && window.document && window.document.createElement);
function rn() {
return nn() ? document.visibilityState !== "hidden" : !0;
}
const $e = [];
function Pa(e) {
return $e.push(e), function() {
const n = $e.indexOf(e);
$e.splice(n, 1);
};
}
if (nn()) {
const e = () => {
if (!!rn())
for (let t = 0; t < $e.length; t++) {
const n = $e[t];
n();
}
};
window.addEventListener("visibilitychange", e, !1);
}
const Ra = (e, { pollingInterval: t, pollingWhenHidden: n = !0, pollingErrorRetryCount: r = -1 }) => {
let o;
const u = E(), a = E(0), s = () => {
var i;
o && clearTimeout(o), (i = u.value) == null || i.call(u);
};
return B(() => {
w(t) || s();
}), w(t) ? {
name: "pollingPlugin",
onBefore: () => {
s();
},
onError: () => {
a.value += 1;
},
onSuccess: () => {
a.value = 0;
},
onFinally: () => {
r === -1 || r !== -1 && a.value <= r ? o = setTimeout(() => {
!n && !rn() ? u.value = Pa(() => {
e.refresh();
}) : e.refresh();
}, w(t)) : a.value = 0;
},
onCancel: () => {
s();
}
} : {};
};
function xa(e, t) {
let n = !1;
return (...r) => {
n || (n = !0, e(...r), setTimeout(() => {
n = !1;
}, t));
};
}
function Fa() {
return nn() && typeof navigator.onLine < "u" ? navigator.onLine : !0;
}
const Be = [];
function La(e) {
return Be.push(e), function() {
const n = Be.indexOf(e);
n > -1 && Be.splice(n, 1);
};
}
if (Ia) {
const e = () => {
if (!(!rn() || !Fa()))
for (let t = 0; t < Be.length; t++) {
const n = Be[t];
n();
}
};
window.addEventListener("visibilitychange", e, !1), window.addEventListener("focus", e, !1);
}
const ka = (e, { refreshOnWindowFocus: t, focusTimespan: n = 5e3 }) => {
const r = E(), o = () => {
var u;
(u = r.value) == null || u.call(r);
};
return B((u) => {
if (w(t)) {
const a = xa(
e.refresh.bind(e),
w(n)
);
r.value = La(() => {
a();
});
}
u(() => {
o();
});
}), Pe(() => {
o();
}), {
name: "refreshOnWindowFocusPlugin"
};
}, Na = (e, { retryInterval: t, retryCount: n }) => {
const r = E(), o = E(0), u = E(!1);
return n ? {
name: "retryPlugin",
onBefore: () => {
u.value || (o.value = 0), u.value = !1, r.value && clearTimeout(r.value);
},
onSuccess: () => {
o.value = 0;
},
onError: () => {
if (o.value += 1, n === -1 || o.value <= n) {
const a = t != null ? t : Math.min(1e3 * 2 ** o.value, 3e4);
r.value = setTimeout(() => {
u.value = !0, e.refresh();
}, a);
} else
o.value = 0;
},
onCancel: () => {
o.value = 0, r.value && clearTimeout(r.value);
}
} : {};
};
var Ua = Array.isArray;
const de = Ua;
function bo(e) {
return e;
}
var $a = "[object AsyncFunction]", Ba = "[object Function]", Va = "[object GeneratorFunction]", Ma = "[object Proxy]";
function on(e) {
if (!q(e))
return !1;
var t = _e(e);
return t == Ba || t == Va || t == $a || t == Ma;
}
var ja = Y["__core-js_shared__"];
const St = ja;
var xn = function() {
var e = /[^.]+$/.exec(St && St.keys && St.keys.IE_PROTO || "");
return e ? "Symbol(src)_1." + e : "";
}();
function Ha(e) {
return !!xn && xn in e;
}
var za = Function.prototype, Ka = za.toString;
function pe(e) {
if (e != null) {
try {
return Ka.call(e);
} catch {
}
try {
return e + "";
} catch {
}
}
return "";
}
var qa = /[\\^$.*+?()[\]{}|]/g, Ga = /^\[object .+?Constructor\]$/, Wa = Function.prototype, Ya = Object.prototype, Xa = Wa.toString, Za = Ya.hasOwnProperty, Ja = RegExp(
"^" + Xa.call(Za).replace(qa, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
);
function Qa(e) {
if (!q(e) || Ha(e))
return !1;
var t = on(e) ? Ja : Ga;
return t.test(pe(e));
}
function es(e, t) {
return e == null ? void 0 : e[t];
}
function ve(e, t) {
var n = es(e, t);
return Qa(n) ? n : void 0;
}
var ts = ve(Y, "WeakMap");
const kt = ts;
var Fn = Object.create, ns = function() {
function e() {
}
return function(t) {
if (!q(t))
return {};
if (Fn)
return Fn(t);
e.prototype = t;
var n = new e();
return e.prototype = void 0, n;
};
}();
const rs = ns;
function os(e, t, n) {
switch (n.length) {
case 0:
return e.call(t);
case 1:
return e.call(t, n[0]);
case 2:
return e.call(t, n[0], n[1]);
case 3:
return e.call(t, n[0], n[1], n[2]);
}
return e.apply(t, n);
}
function To(e, t) {
var n = -1, r = e.length;
for (t || (t = Array(r)); ++n < r; )
t[n] = e[n];
return t;
}
var us = 800, as = 16, ss = Date.now;
function is(e) {
var t = 0, n = 0;
return function() {
var r = ss(), o = as - (r - n);
if (n = r, o > 0) {
if (++t >= us)
return arguments[0];
} else
t = 0;
return e.apply(void 0, arguments);
};
}
function ls(e) {
return function() {
return e;
};
}
var cs = function() {
try {
var e = ve(Object, "defineProperty");
return e({}, "", {}), e;
} catch {
}
}();
const ct = cs;
var fs = ct ? function(e, t) {
return ct(e, "toString", {
configurable: !0,
enumerable: !1,
value: ls(t),
writable: !0
});
} : bo;
const ds = fs;
var gs = is(ds);
const hs = gs;
function _s(e, t) {
for (var n = -1, r = e == null ? 0 : e.length; ++n < r && t(e[n], n, e) !== !1; )
;
return e;
}
var ps = 9007199254740991, vs = /^(?:0|[1-9]\d*)$/;
function Ao(e, t) {
var n = typeof e;
return t = t == null ? ps : t, !!t && (n == "number" || n != "symbol" && vs.test(e)) && e > -1 && e % 1 == 0 && e < t;
}
function un(e, t, n) {
t == "__proto__" && ct ? ct(e, t, {
configurable: !0,
enumerable: !0,
value: n,
writable: !0
}) : e[t] = n;
}
function Je(e, t) {
return e === t || e !== e && t !== t;
}
var ms = Object.prototype, Es = ms.hasOwnProperty;
function Oo(e, t, n) {
var r = e[t];
(!(Es.call(e, t) && Je(r, n)) || n === void 0 && !(t in e)) && un(e, t, n);
}
function Qe(e, t, n, r) {
var o = !n;
n || (n = {});
for (var u = -1, a = t.length; ++u < a; ) {
var s = t[u], i = r ? r(n[s], e[s], s, n, e) : void 0;
i === void 0 && (i = e[s]), o ? un(n, s, i) : Oo(n, s, i);
}
return n;
}
var Ln = Math.max;
function ys(e, t, n) {
return t = Ln(t === void 0 ? e.length - 1 : t, 0), function() {
for (var r = arguments, o = -1, u = Ln(r.length - t, 0), a = Array(u); ++o < u; )
a[o] = r[t + o];
o = -1;
for (var s = Array(t + 1); ++o < t; )
s[o] = r[o];
return s[t] = n(a), os(e, this, s);
};
}
function bs(e, t) {
return hs(ys(e, t, bo), e + "");
}
var Ts = 9007199254740991;
function wo(e) {
return typeof e == "number" && e > -1 && e % 1 == 0 && e <= Ts;
}
function pt(e) {
return e != null && wo(e.length) && !on(e);
}
function As(e, t, n) {
if (!q(n))
return !1;
var r = typeof t;
return (r == "number" ? pt(n) && Ao(t, n.length) : r == "string" && t in n) ? Je(n[t], e) : !1;
}
function Os(e) {
return bs(function(t, n) {
var r = -1, o = n.length, u = o > 1 ? n[o - 1] : void 0, a = o > 2 ? n[2] : void 0;
for (u = e.length > 3 && typeof u == "function" ? (o--, u) : void 0, a && As(n[0], n[1], a) && (u = o < 3 ? void 0 : u, o = 1), t = Object(t); ++r < o; ) {
var s = n[r];
s && e(t, s, r, u);
}
return t;
});
}
var ws = Object.prototype;
function an(e) {
var t = e && e.constructor, n = typeof t == "function" && t.prototype || ws;
return e === n;
}
function Ss(e, t) {
for (var n = -1, r = Array(e); ++n < e; )
r[n] = t(n);
return r;
}
var Cs = "[object Arguments]";
function kn(e) {
return ee(e) && _e(e) == Cs;
}
var So = Object.prototype, Ds = So.hasOwnProperty, Is = So.propertyIsEnumerable, Ps = kn(function() {
return arguments;
}()) ? kn : function(e) {
return ee(e) && Ds.call(e, "callee") && !Is.call(e, "callee");
};
const Nt = Ps;
function Rs() {
return !1;
}
var Co = typeof exports == "object" && exports && !exports.nodeType && exports, Nn = Co && typeof module == "object" && module && !module.nodeType && module, xs = Nn && Nn.exports === Co, Un = xs ? Y.Buffer : void 0, Fs = Un ? Un.isBuffer : void 0, Ls = Fs || Rs;
const He = Ls;
var ks = "[object Arguments]", Ns = "[object Array]", Us = "[object Boolean]", $s = "[object Date]", Bs = "[object Error]", Vs = "[object Function]", Ms = "[object Map]", js = "[object Number]", Hs = "[object Object]", zs = "[object RegExp]", Ks = "[object Set]", qs = "[object String]", Gs = "[object WeakMap]", Ws = "[object ArrayBuffer]", Ys = "[object DataView]", Xs = "[object Float32Array]", Zs = "[object Float64Array]", Js = "[object Int8Array]", Qs = "[object Int16Array]", ei = "[object Int32Array]", ti = "[object Uint8Array]", ni = "[object Uint8ClampedArray]", ri = "[object Uint16Array]", oi = "[object Uint32Array]", P = {};
P[Xs] = P[Zs] = P[Js] = P[Qs] = P[ei] = P[ti] = P[ni] = P[ri] = P[oi] = !0;
P[ks] = P[Ns] = P[Ws] = P[Us] = P[Ys] = P[$s] = P[Bs] = P[Vs] = P[Ms] = P[js] = P[Hs] = P[zs] = P[Ks] = P[qs] = P[Gs] = !1;
function ui(e) {
return ee(e) && wo(e.length) && !!P[_e(e)];
}
function sn(e) {
return function(t) {
return e(t);
};
}
var Do = typeof exports == "object" && exports && !exports.nodeType && exports, Ve = Do && typeof module == "object" && module && !module.nodeType && module, ai = Ve && Ve.exports === Do, Ct = ai && Eo.process, si = function() {
try {
var e = Ve && Ve.require && Ve.require("util").types;
return e || Ct && Ct.binding && Ct.binding("util");
} catch {
}
}();
const Se = si;
var $n = Se && Se.isTypedArray, ii = $n ? sn($n) : ui;
const ln = ii;
var li = Object.prototype, ci = li.hasOwnProperty;
function Io(e, t) {
var n = de(e), r = !n && Nt(e), o = !n && !r && He(e), u = !n && !r && !o && ln(e), a = n || r || o || u, s = a ? Ss(e.length, String) : [], i = s.length;
for (var c in e)
(t || ci.call(e, c)) && !(a && (c == "length" || o && (c == "offset" || c == "parent") || u && (c == "buffer" || c == "byteLength" || c == "byteOffset") || Ao(c, i))) && s.push(c);
return s;
}
function Po(e, t) {
return function(n) {
return e(t(n));
};
}
var fi = Po(Object.keys, Object);
const di = fi;
var gi = Object.prototype, hi = gi.hasOwnProperty;
function _i(e) {
if (!an(e))
return di(e);
var t = [];
for (var n in Object(e))
hi.call(e, n) && n != "constructor" && t.push(n);
return t;
}
function cn(e) {
return pt(e) ? Io(e) : _i(e);
}
function pi(e) {
var t = [];
if (e != null)
for (var n in Object(e))
t.push(n);
return t;
}
var vi = Object.prototype, mi = vi.hasOwnProperty;
function Ei(e) {
if (!q(e))
return pi(e);
var t = an(e), n = [];
for (var r in e)
r == "constructor" && (t || !mi.call(e, r)) || n.push(r);
return n;
}
function et(e) {
return pt(e) ? Io(e, !0) : Ei(e);
}
var yi = ve(Object, "create");
const ze = yi;
function bi() {
this.__data__ = ze ? ze(null) : {}, this.size = 0;
}
function Ti(e) {
var t = this.has(e) && delete this.__data__[e];
return this.size -= t ? 1 : 0, t;
}
var Ai = "__lodash_hash_undefined__", Oi = Object.prototype, wi = Oi.hasOwnProperty;
function Si(e) {
var t = this.__data__;
if (ze) {
var n = t[e];
return n === Ai ? void 0 : n;
}
return wi.call(t, e) ? t[e] : void 0;
}
var Ci = Object.prototype, Di = Ci.hasOwnProperty;
function Ii(e) {
var t = this.__data__;
return ze ? t[e] !== void 0 : Di.call(t, e);
}
var Pi = "__lodash_hash_undefined__";
function Ri(e, t) {
var n = this.__data__;
return this.size += this.has(e) ? 0 : 1, n[e] = ze && t === void 0 ? Pi : t, this;
}
function ge(e) {
var t = -1, n = e == null ? 0 : e.length;
for (this.clear(); ++t < n; ) {
var r = e[t];
this.set(r[0], r[1]);
}
}
ge.prototype.clear = bi;
ge.prototype.delete = Ti;
ge.prototype.get = Si;
ge.prototype.has = Ii;
ge.prototype.set = Ri;
function xi() {
this.__data__ = [], this.size = 0;
}
function vt(e, t) {
for (var n = e.length; n--; )
if (Je(e[n][0], t))
return n;
return -1;
}
var Fi = Array.prototype, Li = Fi.splice;
function ki(e) {
var t = this.__data__, n = vt(t, e);
if (n < 0)
return !1;
var r = t.length - 1;
return n == r ? t.pop() : Li.call(t, n, 1), --this.size, !0;
}
function Ni(e) {
var t = this.__data__, n = vt(t, e);
return n < 0 ? void 0 : t[n][1];
}
function Ui(e) {
return vt(this.__data__, e) > -1;
}
function $i(e, t) {
var n = this.__data__, r = vt(n, e);
return r < 0 ? (++this.size, n.push([e, t])) : n[r][1] = t, this;
}
function ne(e) {
var t = -1, n = e == null ? 0 : e.length;
for (this.clear(); ++t < n; ) {
var r = e[t];
this.set(r[0], r[1]);
}
}
ne.prototype.clear = xi;
ne.prototype.delete = ki;
ne.prototype.get = Ni;
ne.prototype.has = Ui;
ne.prototype.set = $i;
var Bi = ve(Y, "Map");
const Ke = Bi;
function Vi() {
this.size = 0, this.__data__ = {
hash: new ge(),
map: new (Ke || ne)(),
string: new ge()
};
}
function Mi(e) {
var t = typeof e;
return t == "string" || t == "number" || t == "symbol" || t == "boolean" ? e !== "__proto__" : e === null;
}
function mt(e, t) {
var n = e.__data__;
return Mi(t) ? n[typeof t == "string" ? "string" : "hash"] : n.map;
}
function ji(e) {
var t = mt(this, e).delete(e);
return this.size -= t ? 1 : 0, t;
}
function Hi(e) {
return mt(this, e).get(e);
}
function zi(e) {
return mt(this, e).has(e);
}
function Ki(e, t) {
var n = mt(this, e), r = n.size;
return n.set(e, t), this.size += n.size == r ? 0 : 1, this;
}
function me(e) {
var t = -1, n = e == null ? 0 : e.length;
for (this.clear(); ++t < n; ) {
var r = e[t];
this.set(r[0], r[1]);
}
}
me.prototype.clear = Vi;
me.prototype.delete = ji;
me.prototype.get = Hi;
me.prototype.has = zi;
me.prototype.set = Ki;
function Ro(e, t) {
for (var n = -1, r = t.length, o = e.length; ++n < r; )
e[o + n] = t[n];
return e;
}
var qi = Po(Object.getPrototypeOf, Object);
const fn = qi;
var Gi = "[object Object]", Wi = Function.prototype, Yi = Object.prototype, xo = Wi.toString, Xi = Yi.hasOwnProperty, Zi = xo.call(Object);
function Ji(e) {
if (!ee(e) || _e(e) != Gi)
return !1;
var t = fn(e);
if (t === null)
return !0;
var n = Xi.call(t, "constructor") && t.constructor;
return typeof n == "function" && n instanceof n && xo.call(n) == Zi;
}
function Qi() {
this.__data__ = new ne(), this.size = 0;
}
function el(e) {
var t = this.__data__, n = t.delete(e);
return this.size = t.size, n;
}
function tl(e) {
return this.__data__.get(e);
}
function nl(e) {
return this.__data__.has(e);
}
var rl = 200;
function ol(e, t) {
var n = this.__data__;
if (n instanceof ne) {
var r = n.__data__;
if (!Ke || r.length < rl - 1)
return r.push([e, t]), this.size = ++n.size, this;
n = this.__data__ = new me(r);
}
return n.set(e, t), this.size = n.size, this;
}
function Q(e) {
var t = this.__data__ = new ne(e);
this.size = t.size;
}
Q.prototype.clear = Qi;
Q.prototype.delete = el;
Q.prototype.get = tl;
Q.prototype.has = nl;
Q.prototype.set = ol;
function ul(e, t) {
return e && Qe(t, cn(t), e);
}
function al(e, t) {
return e && Qe(t, et(t), e);
}
var Fo = typeof exports == "object" && exports && !exports.nodeType && exports, Bn = Fo && typeof module == "object" && module && !module.nodeType && module, sl = Bn && Bn.exports === Fo, Vn = sl ? Y.Buffer : void 0, Mn = Vn ? Vn.allocUnsafe : void 0;
function Lo(e, t) {
if (t)
return e.slice();
var n = e.length, r = Mn ? Mn(n) : new e.constructor(n);
return e.copy(r), r;
}
function il(e, t) {
for (var n = -1, r = e == null ? 0 : e.length, o = 0, u = []; ++n < r; ) {
var a = e[n];
t(a, n, e) && (u[o++] = a);
}
return u;
}
function ko() {
return [];
}
var ll = Object.prototype, cl = ll.propertyIsEnumerable, jn = Object.getOwnPropertySymbols, fl = jn ? function(e) {
return e == null ? [] : (e = Object(e), il(jn(e), function(t) {
return cl.call(e, t);
}));
} : ko;
const dn = fl;
function dl(e, t) {
return Qe(e, dn(e), t);
}
var gl = Object.getOwnPropertySymbols, hl = gl ? function(e) {
for (var t = []; e; )
Ro(t, dn(e)), e = fn(e);
return t;
} : ko;
const No = hl;
function _l(e, t) {
return Qe(e, No(e), t);
}
function Uo(e, t, n) {
var r = t(e);
return de(e) ? r : Ro(r, n(e));
}
function Ut(e) {
return Uo(e, cn, dn);
}
function pl(e) {
return Uo(e, et, No);
}
var vl = ve(Y, "DataView");
const $t = vl;
var ml = ve(Y, "Promise");
const Bt = ml;
var El = ve(Y, "Set");
const Vt = El;
var Hn = "[object Map]", yl = "[object Object]", zn = "[object Promise]", Kn = "[object Set]", qn = "[object WeakMap]", Gn = "[object DataView]", bl = pe($t), Tl = pe(Ke), Al = pe(Bt), Ol = pe(Vt), wl = pe(kt), ie = _e;
($t && ie(new $t(new ArrayBuffer(1))) != Gn || Ke && ie(new Ke()) != Hn || Bt && ie(Bt.resolve()) != zn || Vt && ie(new Vt()) != Kn || kt && ie(new kt()) != qn) && (ie = function(e) {
var t = _e(e), n = t == yl ? e.constructor : void 0, r = n ? pe(n) : "";
if (r)
switch (r) {
case bl:
return Gn;
case Tl:
return Hn;
case Al:
return zn;
case Ol:
return Kn;
case wl:
return qn;
}
return t;
});
const qe = ie;
var Sl = Object.prototype, Cl = Sl.hasOwnProperty;
function Dl(e) {
var t = e.length, n = new e.constructor(t);
return t && typeof e[0] == "string" && Cl.call(e, "index") && (n.index = e.index, n.input = e.input), n;
}
var Il = Y.Uint8Array;
const ft = Il;
function gn(e) {
var t = new e.constructor(e.byteLength);
return new ft(t).set(new ft(e)), t;
}
function Pl(e, t) {
var n = t ? gn(e.buffer) : e.buffer;
return new e.constructor(n, e.byteOffset, e.byteLength);
}
var Rl = /\w*$/;
function xl(e) {
var t = new e.constructor(e.source, Rl.exec(e));
return t.lastIndex = e.lastIndex, t;
}
var Wn = oe ? oe.prototype : void 0, Yn = Wn ? Wn.valueOf : void 0;
function Fl(e) {
return Yn ? Object(Yn.call(e)) : {};
}
function $o(e, t) {
var n = t ? gn(e.buffer) : e.buffer;
return new e.constructor(n, e.byteOffset, e.length);
}
var Ll = "[object Boolean]", kl = "[object Date]", Nl = "[object Map]", Ul = "[object Number]", $l = "[object RegExp]", Bl = "[object Set]", Vl = "[object String]", Ml = "[object Symbol]", jl = "[object ArrayBuffer]", Hl = "[object DataView]", zl = "[object Float32Array]", Kl = "[object Float64Array]", ql = "[object Int8Array]", Gl = "[object Int16Array]", Wl = "[object Int32Array]", Yl = "[object Uint8Array]", Xl = "[object Uint8ClampedArray]", Zl = "[object Uint16Array]", Jl = "[object Uint32Array]";
function Ql(e, t, n) {
var r = e.constructor;
switch (t) {
case jl:
return gn(e);
case Ll:
case kl:
return new r(+e);
case Hl:
return Pl(e, n);
case zl:
case Kl:
case ql:
case Gl:
case Wl:
case Yl:
case Xl:
case Zl:
case Jl:
return $o(e, n);
case Nl:
return new r();
case Ul:
case Vl:
return new r(e);
case $l:
return xl(e);
case Bl:
return new r();
case Ml:
return Fl(e);
}
}
function Bo(e) {
return typeof e.constructor == "function" && !an(e) ? rs(fn(e)) : {};
}
var ec = "[object Map]";
function tc(e) {
return ee(e) && qe(e) == ec;
}
var Xn = Se && Se.isMap, nc = Xn ? sn(Xn) : tc;
const rc = nc;
var oc = "[object Set]";
function uc(e) {
return ee(e) && qe(e) == oc;
}
var Zn = Se && Se.isSet, ac = Zn ? sn(Zn) : uc;
const sc = ac;
var ic = 1, lc = 2, cc = 4, Vo = "[object Arguments]", fc = "[object Array]", dc = "[object Boolean]", gc = "[object Date]", hc = "[object Error]", Mo = "[object Function]", _c = "[object GeneratorFunction]", pc = "[object Map]", vc = "[object Number]", jo = "[object Object]", mc = "[object RegExp]", Ec = "[object Set]", yc = "[object String]", bc = "[object Symbol]", Tc = "[object WeakMap]", Ac = "[object ArrayBuffer]", Oc = "[object DataView]", wc = "[object Float32Array]", Sc = "[object Float64Array]", Cc = "[object Int8Array]", Dc = "[object Int16Array]", Ic = "[object Int32Array]", Pc = "[object Uint8Array]", Rc = "[object Uint8ClampedArray]", xc = "[object Uint16Array]", Fc = "[object Uint32Array]", D = {};
D[Vo] = D[fc] = D[Ac] = D[Oc] = D[dc] = D[gc] = D[wc] = D[Sc] = D[Cc] = D[Dc] = D[Ic] = D[pc] = D[vc] = D[jo] = D[mc] = D[Ec] = D[yc] = D[bc] = D[Pc] = D[Rc] = D[xc] = D[Fc] = !0;
D[hc] = D[Mo] = D[Tc] = !1;
function st(e, t, n, r, o, u) {
var a, s = t & ic, i = t & lc, c = t & cc;
if (n && (a = o ? n(e, r, o, u) : n(e)), a !== void 0)
return a;
if (!q(e))
return e;
var f = de(e);
if (f) {
if (a = Dl(e), !s)
return To(e, a);
} else {
var l = qe(e), g = l == Mo || l == _c;
if (He(e))
return Lo(e, s);
if (l == jo || l == Vo || g && !o) {
if (a = i || g ? {} : Bo(e), !s)
return i ? _l(e, al(a, e)) : dl(e, ul(a, e));
} else {
if (!D[l])
return o ? e : {};
a = Ql(e, l, s);
}
}
u || (u = new Q());
var d = u.get(e);
if (d)
return d;
u.set(e, a), sc(e) ? e.forEach(function(_) {
a.add(st(_, t, n, _, e, u));
}) : rc(e) && e.forEach(function(_, p) {
a.set(p, st(_, t, n, p, e, u));
});
var h = c ? i ? pl : Ut : i ? et : cn, v = f ? void 0 : h(e);
return _s(v || e, function(_, p) {
v && (p = _, _ = e[p]), Oo(a, p, st(_, t, n, p, e, u));
}), a;
}
var Lc = 1, kc = 4;
function Jn(e) {
return st(e, Lc | kc);
}
var Nc = "__lodash_hash_undefined__";
function Uc(e) {
return this.__data__.set(e, Nc), this;
}
function $c(e) {
return this.__data__.has(e);
}
function dt(e) {
var t = -1, n = e == null ? 0 : e.length;
for (this.__data__ = new me(); ++t < n; )
this.add(e[t]);
}
dt.prototype.add = dt.prototype.push = Uc;
dt.prototype.has = $c;
function Bc(e, t) {
for (var n = -1, r = e == null ? 0 : e.length; ++n < r; )
if (t(e[n], n, e))
return !0;
return !1;
}
function Vc(e, t) {
return e.has(t);
}
var Mc = 1, jc = 2;
function Ho(e, t, n, r, o, u) {
var a = n & Mc, s = e.length, i = t.length;
if (s != i && !(a && i > s))
return !1;
var c = u.get(e), f = u.get(t);
if (c && f)
return c == t && f == e;
var l = -1, g = !0, d = n & jc ? new dt() : void 0;
for (u.set(e, t), u.set(t, e); ++l < s; ) {
var h = e[l], v = t[l];
if (r)
var _ = a ? r(v, h, l, t, e, u) : r(h, v, l, e, t, u);
if (_ !== void 0) {
if (_)
continue;
g = !1;
break;
}
if (d) {
if (!Bc(t, function(p, b) {
if (!Vc(d, b) && (h === p || o(h, p, n, r, u)))
return d.push(b);
})) {
g = !1;
break;
}
} else if (!(h === v || o(h, v, n, r, u))) {
g = !1;
break;
}
}
return u.delete(e), u.delete(t), g;
}
function Hc(e) {
var t = -1, n = Array(e.size);
return e.forEach(function(r, o) {
n[++t] = [o, r];
}), n;
}
function zc(e) {
var t = -1, n = Array(e.size);
return e.forEach(function(r) {
n[++t] = r;
}), n;
}
var Kc = 1, qc = 2, Gc = "[object Boolean]", Wc = "[object Date]", Yc = "[object Error]", Xc = "[object Map]", Zc = "[object Number]", Jc = "[object RegExp]", Qc = "[object Set]", ef = "[object String]", tf = "[object Symbol]", nf = "[object ArrayBuffer]", rf = "[object DataView]", Qn = oe ? oe.prototype : void 0, Dt = Qn ? Qn.valueOf : void 0;
function of(e, t, n, r, o, u, a) {
switch (n) {
case rf:
if (e.byteLength != t.byteLength || e.byteOffset != t.byteOffset)
return !1;
e = e.buffer, t = t.buffer;
case nf:
return !(e.byteLength != t.byteLength || !u(new ft(e), new ft(t)));
case Gc:
case Wc:
case Zc:
return Je(+e, +t);
case Yc:
return e.name == t.name && e.message == t.message;
case Jc:
case ef:
return e == t + "";
case Xc:
var s = Hc;
case Qc:
var i = r & Kc;
if (s || (s = zc), e.size != t.size && !i)
return !1;
var c = a.get(e);
if (c)
return c == t;
r |= qc, a.set(e, t);
var f = Ho(s(e), s(t), r, o, u, a);
return a.delete(e), f;
case tf:
if (Dt)
return Dt.call(e) == Dt.call(t);
}
return !1;
}
var uf = 1, af = Object.prototype, sf = af.hasOwnProperty;
function lf(e, t, n, r, o, u) {
var a = n & uf, s = Ut(e), i = s.length, c = Ut(t), f = c.length;
if (i != f && !a)
return !1;
for (var l = i; l--; ) {
var g = s[l];
if (!(a ? g in t : sf.call(t, g)))
return !1;
}
var d = u.get(e), h = u.get(t);
if (d && h)
return d == t && h == e;
var v = !0;
u.set(e, t), u.set(t, e);
for (var _ = a; ++l < i; ) {
g = s[l];
var p = e[g], b = t[g];
if (r)
var T = a ? r(b, p, g, t, e, u) : r(p, b, g, e, t, u);
if (!(T === void 0 ? p === b || o(p, b, n, r, u) : T)) {
v = !1;
break;
}
_ || (_ = g == "constructor");
}
if (v && !_) {
var S = e.constructor, A = t.constructor;
S != A && "constructor" in e && "constructor" in t && !(typeof S == "function" && S instanceof S && typeof A == "function" && A instanceof A) && (v = !1);
}
return u.delete(e), u.delete(t), v;
}
var cf = 1, er = "[object Arguments]", tr = "[object Array]", rt = "[object Object]", ff = Object.prototype, nr = ff.hasOwnProperty;
function df(e, t, n, r, o, u) {
var a = de(e), s = de(t), i = a ? tr : qe(e), c = s ? tr : qe(t);
i = i == er ? rt : i, c = c == er ? rt : c;
var f = i == rt, l = c == rt, g = i == c;
if (g && He(e)) {
if (!He(t))
return !1;
a = !0, f = !1;
}
if (g && !f)
return u || (u = new Q()), a || ln(e) ? Ho(e, t, n, r, o, u) : of(e, t, i, n, r, o, u);
if (!(n & cf)) {
var d = f && nr.call(e, "__wrapped__"), h = l && nr.call(t, "__wrapped__");
if (d || h) {
var v = d ? e.value() : e, _ = h ? t.value() : t;
return u || (u = new Q()), o(v, _, n, r, u);
}
}
return g ? (u || (u = new Q()), lf(e, t, n, r, o, u)) : !1;
}
function zo(e, t, n, r, o) {
return e === t ? !0 : e == null || t == null || !ee(e) && !ee(t) ? e !== e && t !== t : df(e, t, n, r, zo, o);
}
function gf(e) {
return function(t, n, r) {
for (var o = -1, u = Object(t), a = r(t), s = a.length; s--; ) {
var i = a[e ? s : ++o];
if (n(u[i], i, u) === !1)
break;
}
return t;
};
}
var hf = gf();
const _f = hf;
function Mt(e, t, n) {
(n !== void 0 && !Je(e[t], n) || n === void 0 && !(t in e)) && un(e, t, n);
}
function pf(e) {
return ee(e) && pt(e);
}
function jt(e, t) {
if (!(t === "constructor" && typeof e[t] == "function") && t != "__proto__")
return e[t];
}
function vf(e) {
return Qe(e, et(e));
}
function mf(e, t, n, r, o, u, a) {
var s = jt(e, n), i = jt(t, n), c = a.get(i);
if (c) {
Mt(e, n, c);
return;
}
var f = u ? u(s, i, n + "", e, t, a) : void 0, l = f === void 0;
if (l) {
var g = de(i), d = !g && He(i), h = !g && !d && ln(i);
f = i, g || d || h ? de(s) ? f = s : pf(s) ? f = To(s) : d ? (l = !1, f = Lo(i, !0)) : h ? (l = !1, f = $o(i, !0)) : f = [] : Ji(i) || Nt(i) ? (f = s, Nt(s) ? f = vf(s) : (!q(s) || on(s)) && (f = Bo(i))) : l = !1;
}
l && (a.set(i, f), o(f, i, r, u, a), a.delete(i)), Mt(e, n, f);
}
function Ko(e, t, n, r, o) {
e !== t && _f(t, function(u, a) {
if (o || (o = new Q()), q(u))
mf(e, t, a, n, Ko, r, o);
else {
var s = r ? r(jt(e, a), u, a + "", e, t, o) : void 0;
s === void 0 && (s = u), Mt(e, a, s);
}
}, et);
}
function qo(e, t) {
return zo(e, t);
}
var Ef = Os(function(e, t, n) {
Ko(e, t, n);
});
const yf = Ef;
var bf = "Expected a function";
function Go(e, t, n) {
var r = !0, o = !0;
if (typeof e != "function")
throw new TypeError(bf);
return q(n) && (r = "leading" in n ? !!n.leading : r, o = "trailing" in n ? !!n.trailing : o), tn(e, t, {
leading: r,
maxWait: t,
trailing: o
});
}
const Tf = (e, { throttleWait: t, throttleLeading: n, throttleTrailing: r }) => {
let o = null;
const u = x(() => {
const c = {};
return w(n) !== void 0 && (c.leading = w(n)), w(r) !== void 0 && (c.trailing = w(r)), c;
}), a = e.runAsync.bind(e), s = E(), i = x(() => w(t));
return $([i, u], (c) => {
o && (o.cancel(), e.runAsync = a);
const [f, l] = c, g = Go(
(d) => {
d();
},
w(f),
l
);
o = g, s.value = g, e.runAsync = (...d) => new Promise((h, v) => {
var _;
(_ = s.value) == null || _.call(s, () => {
a(...d).then(h).catch(v);
});
});
}, {
immediate: !0
}), w(t) ? (Re(() => {
var c;
(c = s.value) == null || c.cancel();
}), {
name: "throttlePlugin",
onCancel: () => {
var c;
(c = s.value) == null || c.cancel();
}
}) : {};
}, rr = (e) => typeof e == "function", Af = (e) => typeof e == "boolean";
class Of {
constructor(t, n, r, o = {}) {
W(this, "pluginImpls");
W(this, "count", 0);
W(this, "state", {
loading: !1,
params: void 0,
data: void 0,
error: void 0
});
W(this, "previousValidData");
this.serviceRef = t, this.options = n, this.setUpdateData = r, this.initState = o, this.state = {
...this.state,
loading: !n.manual,
...o
};
}
setState(t = {}) {
this.state = {
...this.state,
...t
}, this.setUpdateData(this.state);
}
setData(t, n) {
console.warn("Please use 'setFetchState' instead of 'setData'"), n instanceof Array ? n.forEach((r) => {
this.state[r] = t, this.setUpdateData(t, r);
}) : (this.state[n] = t, this.setUpdateData(t, n));
}
setFetchState(t, n) {
n instanceof Array ? n.forEach((r) => {
this.state[r] = t, this.setUpdateData(t, r);
}) : (this.state[n] = t, this.setUpdateData(t, n));
}
runPluginHandler(t, ...n) {
var o, u, a;
const r = (a = (u = (o = this.pluginImpls) == null ? void 0 : o.map((s) => {
var i;
return (i = s[t]) == null ? void 0 : i.call(s, ...n);
})) != null ? u : []) == null ? void 0 : a.filter(Boolean);
return Object.assign({}, ...r);
}
async runAsync(...t) {
var a, s, i, c, f, l, g, d, h, v, _;
this.count += 1;
const n = this.count, { stopNow: r = !1, returnNow: o = !1, ...u } = this.runPluginHandler(
"onBefore",
t
);
if (r)
return new Promise(() => {
});
if (this.setState({
loading: !0,
params: t,
...u
}), o)
return Promise.resolve(u.data);
try {
(s = (a = this.options).onBefore) == null || s.call(a, t);
} catch (p) {
return this.setState({
error: p,
loading: !1
}), (c = (i = this.options).onError) == null || c.call(i, p, t), this.runPluginHandler("onError", p, t), new Promise(() => {
});
}
try {
let { servicePromise: p } = this.runPluginHandler("onRequest", this.serviceRef.value, t);
const b = (S) => {
var L, k, M, R;
if (!this.options.concurrent && n !== this.count)
return new Promise(() => {
});
const A = this.options.formatResult ? this.options.formatResult(S) : S, O = {
data: S
};
return this.setState({
data: A,
error: void 0,
loading: !1
}), (k = (L = this.options).onSuccess) == null || k.call(L, A, t), this.runPluginHandler("onSuccess", A, t, O), this.previousValidData = A, (R = (M = this.options).onFinally) == null || R.call(M, t, A, void 0), (this.options.concurrent || n === this.count) && this.runPluginHandler("onFinally", t, A, void 0), A;
};
p || (p = this.serviceRef.value(...t));
const T = await p;
return b(T);
} catch (p) {
if (!this.options.concurrent && n !== this.count)
return new Promise(() => {
});
throw this.setState({
error: p,
loading: !1
}), (l = (f = this.options).onError) == null || l.call(f, p, t), this.runPluginHandler("onError", p, t), (rr((g = this.options) == null ? void 0 : g.rollbackOnError) && ((d = this.options) == null ? void 0 : d.rollbackOnError(t)) || Af((h = this.options) == null ? void 0 : h.rollbackOnError) && this.options.rollbackOnError) && this.setState({
data: this.previousValidData
}), (_ = (v = this.options).onFinally) == null || _.call(v, t, void 0, p), (this.options.concurrent || n === this.count) && this.runPluginHandler("onFinally", t, void 0, p), p;
}
}
run(...t) {
this.runAsync(...t).catch((n) => {
this.options.onError || console.error(n);
});
}
cancel() {
this.count += 1, this.setState({
loading: !1
}), this.runPluginHandler("onCancel");
}
refresh() {
this.run(...this.state.params || []);
}
refreshAsync() {
return this.runAsync(...this.state.params || []);
}
mutate(t) {
const n = rr(t) ? t(this.state.data) : t;
this.runPluginHandler("onMutate", n), this.setState({
data: n
});
}
}
const Wo = Symbol(
"USEREQUEST_GLOBAL_OPTIONS_PROVIDE_KEY"
);
function wf(e) {
return Object.keys(e).filter((n) => ["data", "loading", "params", "error"].includes(n)).length === 4;
}
function Sf(e, t = {}, n = []) {
const r = Nu(
Wo,
{}
), { initialData: o = void 0, manual: u = !1, ready: a = !0, ...s } = {
...r != null ? r : {},
...t != null ? t : {}
}, i = {
manual: u,
ready: a,
initialData: o,
...s
}, c = E(e), f = ht({
data: o,
loading: !1,
params: void 0,
error: void 0
}), l = (v, _) => {
_ ? f[_] = v : wf(v) && (f.data = v.data, f.loading = v.loading, f.error = v.error, f.params = v.params);
}, g = n.map((v) => {
var _;
return (_ = v == null ? void 0 : v.onInit) == null ? void 0 : _.call(v, i);
}).filter(Boolean), d = new Of(
c,
i,
l,
Object.assign({}, ...g, f)
);
d.options = i, d.pluginImpls = n.map((v) => v(d, i));
const h = x(() => fe(a) ? a.value : a);
if (B(() => {
if (!u) {
const v = d.state.params || t.defaultParams || [];
h.value && d.options.refreshDeps === !0 && !!c.value && d.run(...v);
}
}), !u && d.options.refreshDeps !== !0) {
const v = d.state.params || t.defaultParams || [];
w(a) && d.run(...v);
}
return Pe(() => {
d.cancel();
}), {
...en(f),
cancel: d.cancel.bind(d),
refresh: d.refresh.bind(d),
refreshAsync: d.refreshAsync.bind(d),
run: d.run.bind(d),
runAsync: d.runAsync.bind(d),
mutate: d.mutate.bind(d)
};
}
const Cf = (e, t) => function(r, o = {}, u = []) {
let a = e;
const s = t || [];
for (let i = s.length; i--; )
a = s[i](a);
return a(r, o, u);
};
function hn(e, t, n) {
const r = [
process.env.NODE_ENV === "development" ? Ca : null,
Ta,
Da,
Ra,
ka,
Tf,
mo,
Yu,
Na
].filter(Boolean);
return Cf(Sf, t == null ? void 0 : t.use)(
e,
t,
[...n || [], ...r]
);
}
function vg(e) {
Uu(Wo, e);
}
var Df = Object.create, Yo = Object.defineProperty, If = Object.getOwnPropertyDescriptor, _n = Object.getOwnPropertyNames, Pf = Object.getPrototypeOf, Rf = Object.prototype.hasOwnProperty, xf = (e, t) => function() {
return e && (t = (0, e[_n(e)[0]])(e = 0)), t;
}, Ff = (e, t) => function() {
return t || (0, e[_n(e)[0]])((t = { exports: {} }).exports, t), t.exports;
}, Lf = (e, t, n, r) => {
if (t && typeof t == "object" || typeof t == "function")
for (let o of _n(t))
!Rf.call(e, o) && o !== n && Yo(e, o, { get: () => t[o], enumerable: !(r = If(t, o)) || r.enumerable });
return e;
}, kf = (e, t, n) => (n = e != null ? Df(Pf(e)) : {}, Lf(
t || !e || !e.__esModule ? Yo(n, "default", { value: e, enumerable: !0 }) : n,
e
)), tt = xf({
"../../node_modules/.pnpm/tsup@8.3.5_@microsoft+api-extractor@7.48.1_@types+node@22.10.5__jiti@2.4.2_postcss@8.4.49_tsx_s7k37zks4wtn7x2grzma6lrsfa/node_modules/tsup/assets/esm_shims.js"() {
}
}), Nf = Ff({
"../../node_modules/.pnpm/rfdc@1.4.1/node_modules/rfdc/index.js"(e, t) {
tt(), t.exports = r;
function n(u) {
return u instanceof Buffer ? Buffer.from(u) : new u.constructor(u.buffer.slice(), u.byteOffset, u.length);
}
function r(u) {
if (u = u || {}, u.circles)
return o(u);
const a = /* @__PURE__ */ new Map();
if (a.set(Date, (l) => new Date(l)), a.set(Map, (l, g) => new Map(i(Array.from(l), g))), a.set(Set, (l, g) => new Set(i(Array.from(l), g))), u.constructorHandlers)
for (const l of u.constructorHandlers)
a.set(l[0], l[1]);
let s = null;
return u.proto ? f : c;
function i(l, g) {
const d = Object.keys(l), h = new Array(d.length);
for (let v = 0; v < d.length; v++) {
const _ = d[v], p = l[_];
typeof p != "object" || p === null ? h[_] = p : p.constructor !== Object && (s = a.get(p.constructor)) ? h[_] = s(p, g) : ArrayBuffer.isView(p) ? h[_] = n(p) : h[_] = g(p);
}
return h;
}
function c(l) {
if (typeof l != "object" || l === null)
return l;
if (Array.isArray(l))
return i(l, c);
if (l.constructor !== Object && (s = a.get(l.constructor)))
return s(l, c);
const g = {};
for (const d in l) {
if (Object.hasOwnProperty.call(l, d) === !1)
continue;
const h = l[d];
typeof h != "object" || h === null ? g[d] = h : h.constructor !== Object && (s = a.get(h.constructor)) ? g[d] = s(h, c) : ArrayBuffer.isView(h) ? g[d] = n(h) : g[d] = c(h);
}
return g;
}
function f(l) {
if (typeof l != "object" || l === null)
return l;
if (Array.isArray(l))
return i(l, f);
if (l.constructor !== Object && (s = a.get(l.constructor)))
return s(l, f);
const g = {};
for (const d in l) {
const h = l[d];
typeof h != "object" || h === null ? g[d] = h : h.constructor !== Object && (s = a.get(h.constructor)) ? g[d] = s(h, f) : ArrayBuffer.isView(h) ? g[d] = n(h) : g[d] = f(h);
}
return g;
}
}
function o(u) {
const a = [], s = [], i = /* @__PURE__ */ new Map();
if (i.set(Date, (d) => new Date(d)), i.set(Map, (d, h) => new Map(f(Array.from(d), h))), i.set(Set, (d, h) => new Set(f(Array.from(d), h))), u.constructorHandlers)
for (const d of u.constructorHandlers)
i.set(d[0], d[1]);
let c = null;
return u.proto ? g : l;
function f(d, h) {
const v = Object.keys(d),