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