UNPKG

frappe-react-sdk

Version:
1,424 lines 187 kB
var _i = Object.defineProperty; var vi = (t, e, n) => e in t ? _i(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n; var ze = (t, e, n) => vi(t, typeof e != "symbol" ? e + "" : e, n); import { jsx as Er } from "react/jsx-runtime"; import bt, { createContext as Xr, useContext as Z, useMemo as Kt, useRef as Pe, useEffect as at, useLayoutEffect as Ei, createElement as Si, useCallback as I, useDebugValue as Ri, useState as M } from "react"; var Oi = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, et = {}, pt = {}, Te = {}, Sr; function Yr() { if (Sr) return Te; Sr = 1; var t = Te && Te.__assign || function() { return t = Object.assign || function(o) { for (var c, a = 1, d = arguments.length; a < d; a++) { c = arguments[a]; for (var h in c) Object.prototype.hasOwnProperty.call(c, h) && (o[h] = c[h]); } return o; }, t.apply(this, arguments); }, e = Te && Te.__awaiter || function(o, c, a, d) { function h(f) { return f instanceof a ? f : new a(function(y) { y(f); }); } return new (a || (a = Promise))(function(f, y) { function b(v) { try { m(d.next(v)); } catch (R) { y(R); } } function E(v) { try { m(d.throw(v)); } catch (R) { y(R); } } function m(v) { v.done ? f(v.value) : h(v.value).then(b, E); } m((d = d.apply(o, c || [])).next()); }); }, n = Te && Te.__generator || function(o, c) { var a = { label: 0, sent: function() { if (f[0] & 1) throw f[1]; return f[1]; }, trys: [], ops: [] }, d, h, f, y; return y = { next: b(0), throw: b(1), return: b(2) }, typeof Symbol == "function" && (y[Symbol.iterator] = function() { return this; }), y; function b(m) { return function(v) { return E([m, v]); }; } function E(m) { if (d) throw new TypeError("Generator is already executing."); for (; y && (y = 0, m[0] && (a = 0)), a; ) try { if (d = 1, h && (f = m[0] & 2 ? h.return : m[0] ? h.throw || ((f = h.return) && f.call(h), 0) : h.next) && !(f = f.call(h, m[1])).done) return f; switch (h = 0, f && (m = [m[0] & 2, f.value]), m[0]) { case 0: case 1: f = m; break; case 4: return a.label++, { value: m[1], done: !1 }; case 5: a.label++, h = m[1], m = [0]; continue; case 7: m = a.ops.pop(), a.trys.pop(); continue; default: if (f = a.trys, !(f = f.length > 0 && f[f.length - 1]) && (m[0] === 6 || m[0] === 2)) { a = 0; continue; } if (m[0] === 3 && (!f || m[1] > f[0] && m[1] < f[3])) { a.label = m[1]; break; } if (m[0] === 6 && a.label < f[1]) { a.label = f[1], f = m; break; } if (f && a.label < f[2]) { a.label = f[2], a.ops.push(m); break; } f[2] && a.ops.pop(), a.trys.pop(); continue; } m = c.call(o, a); } catch (v) { m = [6, v], h = 0; } finally { d = f = 0; } if (m[0] & 5) throw m[1]; return { value: m[0] ? m[1] : void 0, done: !0 }; } }; Object.defineProperty(Te, "__esModule", { value: !0 }), Te.FrappeCall = void 0; var r = ( /** @class */ function() { function o(c, a, d, h, f) { this.appURL = c, this.axios = a, this.useToken = d ?? !1, this.token = h, this.tokenType = f; } return o.prototype.get = function(c, a) { return e(this, void 0, void 0, function() { var d; return n(this, function(h) { return d = new URLSearchParams(), a && Object.entries(a).forEach(function(f) { var y = f[0], b = f[1]; if (b != null) { var E = typeof b == "object" ? JSON.stringify(b) : b; d.set(y, E); } }), [2, this.axios.get("/api/method/".concat(c), { params: d }).then(function(f) { return f.data; }).catch(function(f) { var y, b; throw t(t({}, f.response.data), { httpStatus: f.response.status, httpStatusText: f.response.statusText, message: (y = f.response.data.message) !== null && y !== void 0 ? y : "There was an error.", exception: (b = f.response.data.exception) !== null && b !== void 0 ? b : "" }); })]; }); }); }, o.prototype.post = function(c, a) { return e(this, void 0, void 0, function() { return n(this, function(d) { return [2, this.axios.post("/api/method/".concat(c), t({}, a)).then(function(h) { return h.data; }).catch(function(h) { var f, y; throw t(t({}, h.response.data), { httpStatus: h.response.status, httpStatusText: h.response.statusText, message: (f = h.response.data.message) !== null && f !== void 0 ? f : "There was an error.", exception: (y = h.response.data.exception) !== null && y !== void 0 ? y : "" }); })]; }); }); }, o.prototype.put = function(c, a) { return e(this, void 0, void 0, function() { return n(this, function(d) { return [2, this.axios.put("/api/method/".concat(c), t({}, a)).then(function(h) { return h.data; }).catch(function(h) { var f, y; throw t(t({}, h.response.data), { httpStatus: h.response.status, httpStatusText: h.response.statusText, message: (f = h.response.data.message) !== null && f !== void 0 ? f : "There was an error.", exception: (y = h.response.data.exception) !== null && y !== void 0 ? y : "" }); })]; }); }); }, o.prototype.delete = function(c, a) { return e(this, void 0, void 0, function() { return n(this, function(d) { return [2, this.axios.delete("/api/method/".concat(c), { params: a }).then(function(h) { return h.data; }).catch(function(h) { var f, y; throw t(t({}, h.response.data), { httpStatus: h.response.status, httpStatusText: h.response.statusText, message: (f = h.response.data.message) !== null && f !== void 0 ? f : "There was an error.", exception: (y = h.response.data.exception) !== null && y !== void 0 ? y : "" }); })]; }); }); }, o; }() ); return Te.FrappeCall = r, Te; } var xe = {}, Rr; function Qr() { if (Rr) return xe; Rr = 1; var t = xe && xe.__assign || function() { return t = Object.assign || function(o) { for (var c, a = 1, d = arguments.length; a < d; a++) { c = arguments[a]; for (var h in c) Object.prototype.hasOwnProperty.call(c, h) && (o[h] = c[h]); } return o; }, t.apply(this, arguments); }, e = xe && xe.__awaiter || function(o, c, a, d) { function h(f) { return f instanceof a ? f : new a(function(y) { y(f); }); } return new (a || (a = Promise))(function(f, y) { function b(v) { try { m(d.next(v)); } catch (R) { y(R); } } function E(v) { try { m(d.throw(v)); } catch (R) { y(R); } } function m(v) { v.done ? f(v.value) : h(v.value).then(b, E); } m((d = d.apply(o, c || [])).next()); }); }, n = xe && xe.__generator || function(o, c) { var a = { label: 0, sent: function() { if (f[0] & 1) throw f[1]; return f[1]; }, trys: [], ops: [] }, d, h, f, y; return y = { next: b(0), throw: b(1), return: b(2) }, typeof Symbol == "function" && (y[Symbol.iterator] = function() { return this; }), y; function b(m) { return function(v) { return E([m, v]); }; } function E(m) { if (d) throw new TypeError("Generator is already executing."); for (; y && (y = 0, m[0] && (a = 0)), a; ) try { if (d = 1, h && (f = m[0] & 2 ? h.return : m[0] ? h.throw || ((f = h.return) && f.call(h), 0) : h.next) && !(f = f.call(h, m[1])).done) return f; switch (h = 0, f && (m = [m[0] & 2, f.value]), m[0]) { case 0: case 1: f = m; break; case 4: return a.label++, { value: m[1], done: !1 }; case 5: a.label++, h = m[1], m = [0]; continue; case 7: m = a.ops.pop(), a.trys.pop(); continue; default: if (f = a.trys, !(f = f.length > 0 && f[f.length - 1]) && (m[0] === 6 || m[0] === 2)) { a = 0; continue; } if (m[0] === 3 && (!f || m[1] > f[0] && m[1] < f[3])) { a.label = m[1]; break; } if (m[0] === 6 && a.label < f[1]) { a.label = f[1], f = m; break; } if (f && a.label < f[2]) { a.label = f[2], a.ops.push(m); break; } f[2] && a.ops.pop(), a.trys.pop(); continue; } m = c.call(o, a); } catch (v) { m = [6, v], h = 0; } finally { d = f = 0; } if (m[0] & 5) throw m[1]; return { value: m[0] ? m[1] : void 0, done: !0 }; } }; Object.defineProperty(xe, "__esModule", { value: !0 }), xe.FrappeDB = void 0; var r = ( /** @class */ function() { function o(c, a, d, h, f) { this.appURL = c, this.axios = a, this.useToken = d ?? !1, this.token = h, this.tokenType = f; } return o.prototype.getDoc = function(c, a) { return a === void 0 && (a = ""), e(this, void 0, void 0, function() { return n(this, function(d) { return [2, this.axios.get("/api/resource/".concat(c, "/").concat(encodeURIComponent(a))).then(function(h) { return h.data.data; }).catch(function(h) { var f, y; throw t(t({}, h.response.data), { httpStatus: h.response.status, httpStatusText: h.response.statusText, message: "There was an error while fetching the document.", exception: (y = (f = h.response.data.exception) !== null && f !== void 0 ? f : h.response.data.exc_type) !== null && y !== void 0 ? y : "" }); })]; }); }); }, o.prototype.getDocList = function(c, a) { var d; return e(this, void 0, void 0, function() { var h, f, y, b, E, m, v, R, q, x, X; return n(this, function(z) { return h = {}, a && (f = a.fields, y = a.filters, b = a.orFilters, E = a.orderBy, m = a.limit, v = a.limit_start, R = a.groupBy, q = a.asDict, x = q === void 0 ? !0 : q, X = E ? "".concat(String(E == null ? void 0 : E.field), " ").concat((d = E == null ? void 0 : E.order) !== null && d !== void 0 ? d : "asc") : "", h = { fields: f ? JSON.stringify(f) : void 0, filters: y ? JSON.stringify(y) : void 0, or_filters: b ? JSON.stringify(b) : void 0, order_by: X, group_by: R, limit: m, limit_start: v, as_dict: x }), [2, this.axios.get("/api/resource/".concat(c), { params: h }).then(function(H) { return H.data.data; }).catch(function(H) { var U, J; throw t(t({}, H.response.data), { httpStatus: H.response.status, httpStatusText: H.response.statusText, message: "There was an error while fetching the documents.", exception: (J = (U = H.response.data.exception) !== null && U !== void 0 ? U : H.response.data.exc_type) !== null && J !== void 0 ? J : "" }); })]; }); }); }, o.prototype.createDoc = function(c, a) { return e(this, void 0, void 0, function() { return n(this, function(d) { return [2, this.axios.post("/api/resource/".concat(c), t({}, a)).then(function(h) { return h.data.data; }).catch(function(h) { var f, y, b; throw t(t({}, h.response.data), { httpStatus: h.response.status, httpStatusText: h.response.statusText, message: (f = h.response.data.message) !== null && f !== void 0 ? f : "There was an error while creating the document.", exception: (b = (y = h.response.data.exception) !== null && y !== void 0 ? y : h.response.data.exc_type) !== null && b !== void 0 ? b : "" }); })]; }); }); }, o.prototype.updateDoc = function(c, a, d) { return e(this, void 0, void 0, function() { return n(this, function(h) { return [2, this.axios.put("/api/resource/".concat(c, "/").concat(a && encodeURIComponent(a)), t({}, d)).then(function(f) { return f.data.data; }).catch(function(f) { var y, b, E; throw t(t({}, f.response.data), { httpStatus: f.response.status, httpStatusText: f.response.statusText, message: (y = f.response.data.message) !== null && y !== void 0 ? y : "There was an error while updating the document.", exception: (E = (b = f.response.data.exception) !== null && b !== void 0 ? b : f.response.data.exc_type) !== null && E !== void 0 ? E : "" }); })]; }); }); }, o.prototype.deleteDoc = function(c, a) { return e(this, void 0, void 0, function() { return n(this, function(d) { return [2, this.axios.delete("/api/resource/".concat(c, "/").concat(a && encodeURIComponent(a))).then(function(h) { return h.data; }).catch(function(h) { var f, y; throw t(t({}, h.response.data), { httpStatus: h.response.status, httpStatusText: h.response.statusText, message: "There was an error while deleting the document.", exception: (y = (f = h.response.data.exception) !== null && f !== void 0 ? f : h.response.data.exc_type) !== null && y !== void 0 ? y : "" }); })]; }); }); }, o.prototype.getCount = function(c, a, d, h) { return d === void 0 && (d = !1), h === void 0 && (h = !1), e(this, void 0, void 0, function() { var f; return n(this, function(y) { return f = { doctype: c, filters: [] }, d && (f.cache = d), h && (f.debug = h), a && (f.filters = a ? JSON.stringify(a) : void 0), [2, this.axios.get("/api/method/frappe.client.get_count", { params: f }).then(function(b) { return b.data.message; }).catch(function(b) { var E, m; throw t(t({}, b.response.data), { httpStatus: b.response.status, httpStatusText: b.response.statusText, message: "There was an error while getting the count.", exception: (m = (E = b.response.data.exception) !== null && E !== void 0 ? E : b.response.data.exc_type) !== null && m !== void 0 ? m : "" }); })]; }); }); }, o.prototype.getLastDoc = function(c, a) { return e(this, void 0, void 0, function() { var d, h; return n(this, function(f) { switch (f.label) { case 0: return d = { orderBy: { field: "creation", order: "desc" } }, a && (d = t(t({}, d), a)), [4, this.getDocList(c, t(t({}, d), { limit: 1, fields: ["name"] }))]; case 1: return h = f.sent(), h.length > 0 ? [2, this.getDoc(c, h[0].name)] : [2, {}]; } }); }); }, o; }() ); return xe.FrappeDB = r, xe; } var Ae = {}, Ie = {}; /*! Axios v1.8.2 Copyright (c) 2025 Matt Zabriskie and contributors */ var pn, Or; function Ti() { if (Or) return pn; Or = 1; function t(s, i) { return function() { return s.apply(i, arguments); }; } const { toString: e } = Object.prototype, { getPrototypeOf: n } = Object, r = /* @__PURE__ */ ((s) => (i) => { const u = e.call(i); return s[u] || (s[u] = u.slice(8, -1).toLowerCase()); })(/* @__PURE__ */ Object.create(null)), o = (s) => (s = s.toLowerCase(), (i) => r(i) === s), c = (s) => (i) => typeof i === s, { isArray: a } = Array, d = c("undefined"); function h(s) { return s !== null && !d(s) && s.constructor !== null && !d(s.constructor) && E(s.constructor.isBuffer) && s.constructor.isBuffer(s); } const f = o("ArrayBuffer"); function y(s) { let i; return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? i = ArrayBuffer.isView(s) : i = s && s.buffer && f(s.buffer), i; } const b = c("string"), E = c("function"), m = c("number"), v = (s) => s !== null && typeof s == "object", R = (s) => s === !0 || s === !1, q = (s) => { if (r(s) !== "object") return !1; const i = n(s); return (i === null || i === Object.prototype || Object.getPrototypeOf(i) === null) && !(Symbol.toStringTag in s) && !(Symbol.iterator in s); }, x = o("Date"), X = o("File"), z = o("Blob"), H = o("FileList"), U = (s) => v(s) && E(s.pipe), J = (s) => { let i; return s && (typeof FormData == "function" && s instanceof FormData || E(s.append) && ((i = r(s)) === "formdata" || // detect form-data instance i === "object" && E(s.toString) && s.toString() === "[object FormData]")); }, ke = o("URLSearchParams"), [N, pe, V, ce] = ["ReadableStream", "Request", "Response", "Headers"].map(o), be = (s) => s.trim ? s.trim() : s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ""); function G(s, i, { allOwnKeys: u = !1 } = {}) { if (s === null || typeof s > "u") return; let l, p; if (typeof s != "object" && (s = [s]), a(s)) for (l = 0, p = s.length; l < p; l++) i.call(null, s[l], l, s); else { const g = u ? Object.getOwnPropertyNames(s) : Object.keys(s), w = g.length; let S; for (l = 0; l < w; l++) S = g[l], i.call(null, s[S], S, s); } } function ue(s, i) { i = i.toLowerCase(); const u = Object.keys(s); let l = u.length, p; for (; l-- > 0; ) if (p = u[l], i === p.toLowerCase()) return p; return null; } const le = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : Oi, Ne = (s) => !d(s) && s !== le; function Y() { const { caseless: s } = Ne(this) && this || {}, i = {}, u = (l, p) => { const g = s && ue(i, p) || p; q(i[g]) && q(l) ? i[g] = Y(i[g], l) : q(l) ? i[g] = Y({}, l) : a(l) ? i[g] = l.slice() : i[g] = l; }; for (let l = 0, p = arguments.length; l < p; l++) arguments[l] && G(arguments[l], u); return i; } const ge = (s, i, u, { allOwnKeys: l } = {}) => (G(i, (p, g) => { u && E(p) ? s[g] = t(p, u) : s[g] = p; }, { allOwnKeys: l }), s), Me = (s) => (s.charCodeAt(0) === 65279 && (s = s.slice(1)), s), lt = (s, i, u, l) => { s.prototype = Object.create(i.prototype, l), s.prototype.constructor = s, Object.defineProperty(s, "super", { value: i.prototype }), u && Object.assign(s.prototype, u); }, Fe = (s, i, u, l) => { let p, g, w; const S = {}; if (i = i || {}, s == null) return i; do { for (p = Object.getOwnPropertyNames(s), g = p.length; g-- > 0; ) w = p[g], (!l || l(w, s, i)) && !S[w] && (i[w] = s[w], S[w] = !0); s = u !== !1 && n(s); } while (s && (!u || u(s, i)) && s !== Object.prototype); return i; }, re = (s, i, u) => { s = String(s), (u === void 0 || u > s.length) && (u = s.length), u -= i.length; const l = s.indexOf(i, u); return l !== -1 && l === u; }, Ve = (s) => { if (!s) return null; if (a(s)) return s; let i = s.length; if (!m(i)) return null; const u = new Array(i); for (; i-- > 0; ) u[i] = s[i]; return u; }, $e = /* @__PURE__ */ ((s) => (i) => s && i instanceof s)(typeof Uint8Array < "u" && n(Uint8Array)), Ge = (s, i) => { const l = (s && s[Symbol.iterator]).call(s); let p; for (; (p = l.next()) && !p.done; ) { const g = p.value; i.call(s, g[0], g[1]); } }, tt = (s, i) => { let u; const l = []; for (; (u = s.exec(i)) !== null; ) l.push(u); return l; }, Et = o("HTMLFormElement"), en = (s) => s.toLowerCase().replace( /[-_\s]([a-z\d])(\w*)/g, function(u, l, p) { return l.toUpperCase() + p; } ), St = (({ hasOwnProperty: s }) => (i, u) => s.call(i, u))(Object.prototype), Xe = o("RegExp"), ft = (s, i) => { const u = Object.getOwnPropertyDescriptors(s), l = {}; G(u, (p, g) => { let w; (w = i(p, g, s)) !== !1 && (l[g] = w || p); }), Object.defineProperties(s, l); }, Xn = (s) => { ft(s, (i, u) => { if (E(s) && ["arguments", "caller", "callee"].indexOf(u) !== -1) return !1; const l = s[u]; if (E(l)) { if (i.enumerable = !1, "writable" in i) { i.writable = !1; return; } i.set || (i.set = () => { throw Error("Can not rewrite read-only method '" + u + "'"); }); } }); }, $ = (s, i) => { const u = {}, l = (p) => { p.forEach((g) => { u[g] = !0; }); }; return a(s) ? l(s) : l(String(s).split(i)), u; }, j = () => { }, fe = (s, i) => s != null && Number.isFinite(s = +s) ? s : i; function K(s) { return !!(s && E(s.append) && s[Symbol.toStringTag] === "FormData" && s[Symbol.iterator]); } const _e = (s) => { const i = new Array(10), u = (l, p) => { if (v(l)) { if (i.indexOf(l) >= 0) return; if (!("toJSON" in l)) { i[p] = l; const g = a(l) ? [] : {}; return G(l, (w, S) => { const A = u(w, p + 1); !d(A) && (g[S] = A); }), i[p] = void 0, g; } } return l; }; return u(s, 0); }, He = o("AsyncFunction"), se = (s) => s && (v(s) || E(s)) && E(s.then) && E(s.catch), he = ((s, i) => s ? setImmediate : i ? ((u, l) => (le.addEventListener("message", ({ source: p, data: g }) => { p === le && g === u && l.length && l.shift()(); }, !1), (p) => { l.push(p), le.postMessage(u, "*"); }))(`axios@${Math.random()}`, []) : (u) => setTimeout(u))( typeof setImmediate == "function", E(le.postMessage) ), Se = typeof queueMicrotask < "u" ? queueMicrotask.bind(le) : typeof process < "u" && process.nextTick || he; var _ = { isArray: a, isArrayBuffer: f, isBuffer: h, isFormData: J, isArrayBufferView: y, isString: b, isNumber: m, isBoolean: R, isObject: v, isPlainObject: q, isReadableStream: N, isRequest: pe, isResponse: V, isHeaders: ce, isUndefined: d, isDate: x, isFile: X, isBlob: z, isRegExp: Xe, isFunction: E, isStream: U, isURLSearchParams: ke, isTypedArray: $e, isFileList: H, forEach: G, merge: Y, extend: ge, trim: be, stripBOM: Me, inherits: lt, toFlatObject: Fe, kindOf: r, kindOfTest: o, endsWith: re, toArray: Ve, forEachEntry: Ge, matchAll: tt, isHTMLForm: Et, hasOwnProperty: St, hasOwnProp: St, // an alias to avoid ESLint no-prototype-builtins detection reduceDescriptors: ft, freezeMethods: Xn, toObjectSet: $, toCamelCase: en, noop: j, toFiniteNumber: fe, findKey: ue, global: le, isContextDefined: Ne, isSpecCompliantForm: K, toJSONObject: _e, isAsyncFn: He, isThenable: se, setImmediate: he, asap: Se }; function k(s, i, u, l, p) { Error.call(this), Error.captureStackTrace ? Error.captureStackTrace(this, this.constructor) : this.stack = new Error().stack, this.message = s, this.name = "AxiosError", i && (this.code = i), u && (this.config = u), l && (this.request = l), p && (this.response = p, this.status = p.status ? p.status : null); } _.inherits(k, Error, { toJSON: function() { return { // Standard message: this.message, name: this.name, // Microsoft description: this.description, number: this.number, // Mozilla fileName: this.fileName, lineNumber: this.lineNumber, columnNumber: this.columnNumber, stack: this.stack, // Axios config: _.toJSONObject(this.config), code: this.code, status: this.status }; } }); const ht = k.prototype, ye = {}; [ "ERR_BAD_OPTION_VALUE", "ERR_BAD_OPTION", "ECONNABORTED", "ETIMEDOUT", "ERR_NETWORK", "ERR_FR_TOO_MANY_REDIRECTS", "ERR_DEPRECATED", "ERR_BAD_RESPONSE", "ERR_BAD_REQUEST", "ERR_CANCELED", "ERR_NOT_SUPPORT", "ERR_INVALID_URL" // eslint-disable-next-line func-names ].forEach((s) => { ye[s] = { value: s }; }), Object.defineProperties(k, ye), Object.defineProperty(ht, "isAxiosError", { value: !0 }), k.from = (s, i, u, l, p, g) => { const w = Object.create(ht); return _.toFlatObject(s, w, function(A) { return A !== Error.prototype; }, (S) => S !== "isAxiosError"), k.call(w, s.message, i, u, l, p), w.cause = s, w.name = s.name, g && Object.assign(w, g), w; }; var Re = null; function Ye(s) { return _.isPlainObject(s) || _.isArray(s); } function Rt(s) { return _.endsWith(s, "[]") ? s.slice(0, -2) : s; } function nt(s, i, u) { return s ? s.concat(i).map(function(p, g) { return p = Rt(p), !u && g ? "[" + p + "]" : p; }).join(u ? "." : "") : i; } function Cs(s) { return _.isArray(s) && !s.some(Ye); } const Ls = _.toFlatObject(_, {}, null, function(i) { return /^is[A-Z]/.test(i); }); function Ot(s, i, u) { if (!_.isObject(s)) throw new TypeError("target must be an object"); i = i || new FormData(), u = _.toFlatObject(u, { metaTokens: !0, dots: !1, indexes: !1 }, !1, function(F, D) { return !_.isUndefined(D[F]); }); const l = u.metaTokens, p = u.visitor || T, g = u.dots, w = u.indexes, A = (u.Blob || typeof Blob < "u" && Blob) && _.isSpecCompliantForm(i); if (!_.isFunction(p)) throw new TypeError("visitor must be a function"); function O(L) { if (L === null) return ""; if (_.isDate(L)) return L.toISOString(); if (!A && _.isBlob(L)) throw new k("Blob is not supported. Use a Buffer instead."); return _.isArrayBuffer(L) || _.isTypedArray(L) ? A && typeof Blob == "function" ? new Blob([L]) : Buffer.from(L) : L; } function T(L, F, D) { let Q = L; if (L && !D && typeof L == "object") { if (_.endsWith(F, "{}")) F = l ? F : F.slice(0, -2), L = JSON.stringify(L); else if (_.isArray(L) && Cs(L) || (_.isFileList(L) || _.endsWith(F, "[]")) && (Q = _.toArray(L))) return F = Rt(F), Q.forEach(function(de, qe) { !(_.isUndefined(de) || de === null) && i.append( // eslint-disable-next-line no-nested-ternary w === !0 ? nt([F], qe, g) : w === null ? F : F + "[]", O(de) ); }), !1; } return Ye(L) ? !0 : (i.append(nt(D, F, g), O(L)), !1); } const C = [], W = Object.assign(Ls, { defaultVisitor: T, convertValue: O, isVisitable: Ye }); function ie(L, F) { if (!_.isUndefined(L)) { if (C.indexOf(L) !== -1) throw Error("Circular reference detected in " + F.join(".")); C.push(L), _.forEach(L, function(Q, oe) { (!(_.isUndefined(Q) || Q === null) && p.call( i, Q, _.isString(oe) ? oe.trim() : oe, F, W )) === !0 && ie(Q, F ? F.concat(oe) : [oe]); }), C.pop(); } } if (!_.isObject(s)) throw new TypeError("data must be an object"); return ie(s), i; } function Yn(s) { const i = { "!": "%21", "'": "%27", "(": "%28", ")": "%29", "~": "%7E", "%20": "+", "%00": "\0" }; return encodeURIComponent(s).replace(/[!'()~]|%20|%00/g, function(l) { return i[l]; }); } function tn(s, i) { this._pairs = [], s && Ot(s, this, i); } const Qn = tn.prototype; Qn.append = function(i, u) { this._pairs.push([i, u]); }, Qn.toString = function(i) { const u = i ? function(l) { return i.call(this, l, Yn); } : Yn; return this._pairs.map(function(p) { return u(p[0]) + "=" + u(p[1]); }, "").join("&"); }; function Ds(s) { return encodeURIComponent(s).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]"); } function Zn(s, i, u) { if (!i) return s; const l = u && u.encode || Ds; _.isFunction(u) && (u = { serialize: u }); const p = u && u.serialize; let g; if (p ? g = p(i, u) : g = _.isURLSearchParams(i) ? i.toString() : new tn(i, u).toString(l), g) { const w = s.indexOf("#"); w !== -1 && (s = s.slice(0, w)), s += (s.indexOf("?") === -1 ? "?" : "&") + g; } return s; } class ks { constructor() { this.handlers = []; } /** * Add a new interceptor to the stack * * @param {Function} fulfilled The function to handle `then` for a `Promise` * @param {Function} rejected The function to handle `reject` for a `Promise` * * @return {Number} An ID used to remove interceptor later */ use(i, u, l) { return this.handlers.push({ fulfilled: i, rejected: u, synchronous: l ? l.synchronous : !1, runWhen: l ? l.runWhen : null }), this.handlers.length - 1; } /** * Remove an interceptor from the stack * * @param {Number} id The ID that was returned by `use` * * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise */ eject(i) { this.handlers[i] && (this.handlers[i] = null); } /** * Clear all interceptors from the stack * * @returns {void} */ clear() { this.handlers && (this.handlers = []); } /** * Iterate over all the registered interceptors * * This method is particularly useful for skipping over any * interceptors that may have become `null` calling `eject`. * * @param {Function} fn The function to call for each interceptor * * @returns {void} */ forEach(i) { _.forEach(this.handlers, function(l) { l !== null && i(l); }); } } var er = ks, tr = { silentJSONParsing: !0, forcedJSONParsing: !0, clarifyTimeoutError: !1 }, Ns = typeof URLSearchParams < "u" ? URLSearchParams : tn, Fs = typeof FormData < "u" ? FormData : null, Bs = typeof Blob < "u" ? Blob : null, Ps = { isBrowser: !0, classes: { URLSearchParams: Ns, FormData: Fs, Blob: Bs }, protocols: ["http", "https", "file", "blob", "url", "data"] }; const nn = typeof window < "u" && typeof document < "u", rn = typeof navigator == "object" && navigator || void 0, Us = nn && (!rn || ["ReactNative", "NativeScript", "NS"].indexOf(rn.product) < 0), qs = typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef self instanceof WorkerGlobalScope && typeof self.importScripts == "function", Is = nn && window.location.href || "http://localhost"; var js = /* @__PURE__ */ Object.freeze({ __proto__: null, hasBrowserEnv: nn, hasStandardBrowserWebWorkerEnv: qs, hasStandardBrowserEnv: Us, navigator: rn, origin: Is }), me = { ...js, ...Ps }; function Ms(s, i) { return Ot(s, new me.classes.URLSearchParams(), Object.assign({ visitor: function(u, l, p, g) { return me.isNode && _.isBuffer(u) ? (this.append(l, u.toString("base64")), !1) : g.defaultVisitor.apply(this, arguments); } }, i)); } function Vs(s) { return _.matchAll(/\w+|\[(\w*)]/g, s).map((i) => i[0] === "[]" ? "" : i[1] || i[0]); } function $s(s) { const i = {}, u = Object.keys(s); let l; const p = u.length; let g; for (l = 0; l < p; l++) g = u[l], i[g] = s[g]; return i; } function nr(s) { function i(u, l, p, g) { let w = u[g++]; if (w === "__proto__") return !0; const S = Number.isFinite(+w), A = g >= u.length; return w = !w && _.isArray(p) ? p.length : w, A ? (_.hasOwnProp(p, w) ? p[w] = [p[w], l] : p[w] = l, !S) : ((!p[w] || !_.isObject(p[w])) && (p[w] = []), i(u, l, p[w], g) && _.isArray(p[w]) && (p[w] = $s(p[w])), !S); } if (_.isFormData(s) && _.isFunction(s.entries)) { const u = {}; return _.forEachEntry(s, (l, p) => { i(Vs(l), p, u, 0); }), u; } return null; } function Hs(s, i, u) { if (_.isString(s)) try { return (i || JSON.parse)(s), _.trim(s); } catch (l) { if (l.name !== "SyntaxError") throw l; } return (u || JSON.stringify)(s); } const sn = { transitional: tr, adapter: ["xhr", "http", "fetch"], transformRequest: [function(i, u) { const l = u.getContentType() || "", p = l.indexOf("application/json") > -1, g = _.isObject(i); if (g && _.isHTMLForm(i) && (i = new FormData(i)), _.isFormData(i)) return p ? JSON.stringify(nr(i)) : i; if (_.isArrayBuffer(i) || _.isBuffer(i) || _.isStream(i) || _.isFile(i) || _.isBlob(i) || _.isReadableStream(i)) return i; if (_.isArrayBufferView(i)) return i.buffer; if (_.isURLSearchParams(i)) return u.setContentType("application/x-www-form-urlencoded;charset=utf-8", !1), i.toString(); let S; if (g) { if (l.indexOf("application/x-www-form-urlencoded") > -1) return Ms(i, this.formSerializer).toString(); if ((S = _.isFileList(i)) || l.indexOf("multipart/form-data") > -1) { const A = this.env && this.env.FormData; return Ot( S ? { "files[]": i } : i, A && new A(), this.formSerializer ); } } return g || p ? (u.setContentType("application/json", !1), Hs(i)) : i; }], transformResponse: [function(i) { const u = this.transitional || sn.transitional, l = u && u.forcedJSONParsing, p = this.responseType === "json"; if (_.isResponse(i) || _.isReadableStream(i)) return i; if (i && _.isString(i) && (l && !this.responseType || p)) { const w = !(u && u.silentJSONParsing) && p; try { return JSON.parse(i); } catch (S) { if (w) throw S.name === "SyntaxError" ? k.from(S, k.ERR_BAD_RESPONSE, this, null, this.response) : S; } } return i; }], /** * A timeout in milliseconds to abort a request. If set to 0 (default) a * timeout is not created. */ timeout: 0, xsrfCookieName: "XSRF-TOKEN", xsrfHeaderName: "X-XSRF-TOKEN", maxContentLength: -1, maxBodyLength: -1, env: { FormData: me.classes.FormData, Blob: me.classes.Blob }, validateStatus: function(i) { return i >= 200 && i < 300; }, headers: { common: { Accept: "application/json, text/plain, */*", "Content-Type": void 0 } } }; _.forEach(["delete", "get", "head", "post", "put", "patch"], (s) => { sn.headers[s] = {}; }); var on = sn; const Ws = _.toObjectSet([ "age", "authorization", "content-length", "content-type", "etag", "expires", "from", "host", "if-modified-since", "if-unmodified-since", "last-modified", "location", "max-forwards", "proxy-authorization", "referer", "retry-after", "user-agent" ]); var zs = (s) => { const i = {}; let u, l, p; return s && s.split(` `).forEach(function(w) { p = w.indexOf(":"), u = w.substring(0, p).trim().toLowerCase(), l = w.substring(p + 1).trim(), !(!u || i[u] && Ws[u]) && (u === "set-cookie" ? i[u] ? i[u].push(l) : i[u] = [l] : i[u] = i[u] ? i[u] + ", " + l : l); }), i; }; const rr = Symbol("internals"); function dt(s) { return s && String(s).trim().toLowerCase(); } function Tt(s) { return s === !1 || s == null ? s : _.isArray(s) ? s.map(Tt) : String(s); } function Js(s) { const i = /* @__PURE__ */ Object.create(null), u = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g; let l; for (; l = u.exec(s); ) i[l[1]] = l[2]; return i; } const Ks = (s) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(s.trim()); function an(s, i, u, l, p) { if (_.isFunction(l)) return l.call(this, i, u); if (p && (i = u), !!_.isString(i)) { if (_.isString(l)) return i.indexOf(l) !== -1; if (_.isRegExp(l)) return l.test(i); } } function Gs(s) { return s.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (i, u, l) => u.toUpperCase() + l); } function Xs(s, i) { const u = _.toCamelCase(" " + i); ["get", "set", "has"].forEach((l) => { Object.defineProperty(s, l + u, { value: function(p, g, w) { return this[l].call(this, i, p, g, w); }, configurable: !0 }); }); } class xt { constructor(i) { i && this.set(i); } set(i, u, l) { const p = this; function g(S, A, O) { const T = dt(A); if (!T) throw new Error("header name must be a non-empty string"); const C = _.findKey(p, T); (!C || p[C] === void 0 || O === !0 || O === void 0 && p[C] !== !1) && (p[C || A] = Tt(S)); } const w = (S, A) => _.forEach(S, (O, T) => g(O, T, A)); if (_.isPlainObject(i) || i instanceof this.constructor) w(i, u); else if (_.isString(i) && (i = i.trim()) && !Ks(i)) w(zs(i), u); else if (_.isHeaders(i)) for (const [S, A] of i.entries()) g(A, S, l); else i != null && g(u, i, l); return this; } get(i, u) { if (i = dt(i), i) { const l = _.findKey(this, i); if (l) { const p = this[l]; if (!u) return p; if (u === !0) return Js(p); if (_.isFunction(u)) return u.call(this, p, l); if (_.isRegExp(u)) return u.exec(p); throw new TypeError("parser must be boolean|regexp|function"); } } } has(i, u) { if (i = dt(i), i) { const l = _.findKey(this, i); return !!(l && this[l] !== void 0 && (!u || an(this, this[l], l, u))); } return !1; } delete(i, u) { const l = this; let p = !1; function g(w) { if (w = dt(w), w) { const S = _.findKey(l, w); S && (!u || an(l, l[S], S, u)) && (delete l[S], p = !0); } } return _.isArray(i) ? i.forEach(g) : g(i), p; } clear(i) { const u = Object.keys(this); let l = u.length, p = !1; for (; l--; ) { const g = u[l]; (!i || an(this, this[g], g, i, !0)) && (delete this[g], p = !0); } return p; } normalize(i) { const u = this, l = {}; return _.forEach(this, (p, g) => { const w = _.findKey(l, g); if (w) { u[w] = Tt(p), delete u[g]; return; } const S = i ? Gs(g) : String(g).trim(); S !== g && delete u[g], u[S] = Tt(p), l[S] = !0; }), this; } concat(...i) { return this.constructor.concat(this, ...i); } toJSON(i) { const u = /* @__PURE__ */ Object.create(null); return _.forEach(this, (l, p) => { l != null && l !== !1 && (u[p] = i && _.isArray(l) ? l.join(", ") : l); }), u; } [Symbol.iterator]() { return Object.entries(this.toJSON())[Symbol.iterator](); } toString() { return Object.entries(this.toJSON()).map(([i, u]) => i + ": " + u).join(` `); } get [Symbol.toStringTag]() { return "AxiosHeaders"; } static from(i) { return i instanceof this ? i : new this(i); } static concat(i, ...u) { const l = new this(i); return u.forEach((p) => l.set(p)), l; } static accessor(i) { const l = (this[rr] = this[rr] = { accessors: {} }).accessors, p = this.prototype; function g(w) { const S = dt(w); l[S] || (Xs(p, w), l[S] = !0); } return _.isArray(i) ? i.forEach(g) : g(i), this; } } xt.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]), _.reduceDescriptors(xt.prototype, ({ value: s }, i) => { let u = i[0].toUpperCase() + i.slice(1); return { get: () => s, set(l) { this[u] = l; } }; }), _.freezeMethods(xt); var Oe = xt; function cn(s, i) { const u = this || on, l = i || u, p = Oe.from(l.headers); let g = l.data; return _.forEach(s, function(S) { g = S.call(u, g, p.normalize(), i ? i.status : void 0); }), p.normalize(), g; } function sr(s) { return !!(s && s.__CANCEL__); } function rt(s, i, u) { k.call(this, s ?? "canceled", k.ERR_CANCELED, i, u), this.name = "CanceledError"; } _.inherits(rt, k, { __CANCEL__: !0 }); function ir(s, i, u) { const l = u.config.validateStatus; !u.status || !l || l(u.status) ? s(u) : i(new k( "Request failed with status code " + u.status, [k.ERR_BAD_REQUEST, k.ERR_BAD_RESPONSE][Math.floor(u.status / 100) - 4], u.config, u.request, u )); } function Ys(s) { const i = /^([-+\w]{1,25})(:?\/\/|:)/.exec(s); return i && i[1] || ""; } function Qs(s, i) { s = s || 10; const u = new Array(s), l = new Array(s); let p = 0, g = 0, w; return i = i !== void 0 ? i : 1e3, function(A) { const O = Date.now(), T = l[g]; w || (w = O), u[p] = A, l[p] = O; let C = g, W = 0; for (; C !== p; ) W += u[C++], C = C % s; if (p = (p + 1) % s, p === g && (g = (g + 1) % s), O - w < i) return; const ie = T && O - T; return ie ? Math.round(W * 1e3 / ie) : void 0; }; } function Zs(s, i) { let u = 0, l = 1e3 / i, p, g; const w = (O, T = Date.now()) => { u = T, p = null, g && (clearTimeout(g), g = null), s.apply(null, O); }; return [(...O) => { const T = Date.now(), C = T - u; C >= l ? w(O, T) : (p = O, g || (g = setTimeout(() => { g = null, w(p); }, l - C))); }, () => p && w(p)]; } const At = (s, i, u = 3) => { let l = 0; const p = Qs(50, 250); return Zs((g) => { const w = g.loaded, S = g.lengthComputable ? g.total : void 0, A = w - l, O = p(A), T = w <= S; l = w; const C = { loaded: w, total: S, progress: S ? w / S : void 0, bytes: A, rate: O || void 0, estimated: O && S && T ? (S - w) / O : void 0, event: g, lengthComputable: S != null, [i ? "download" : "upload"]: !0 }; s(C); }, u); }, or = (s, i) => { const u = s != null; return [(l) => i[0]({ lengthComputable: u, total: s, loaded: l }), i[1]]; }, ar = (s) => (...i) => _.asap(() => s(...i)); var ei = me.hasStandardBrowserEnv ? /* @__PURE__ */ ((s, i) => (u) => (u = new URL(u, me.origin), s.protocol === u.protocol && s.host === u.host && (i || s.port === u.port)))( new URL(me.origin), me.navigator && /(msie|trident)/i.test(me.navigator.userAgent) ) : () => !0, ti = me.hasStandardBrowserEnv ? ( // Standard browser envs support document.cookie { write(s, i, u, l, p, g) { const w = [s + "=" + encodeURIComponent(i)]; _.isNumber(u) && w.push("expires=" + new Date(u).toGMTString()), _.isString(l) && w.push("path=" + l), _.isString(p) && w.push("domain=" + p), g === !0 && w.push("secure"), document.cookie = w.join("; "); }, read(s) { const i = document.cookie.match(new RegExp("(^|;\\s*)(" + s + ")=([^;]*)")); return i ? decodeURIComponent(i[3]) : null; }, remove(s) { this.write(s, "", Date.now() - 864e5); } } ) : ( // Non-standard browser env (web workers, react-native) lack needed support. { write() { }, read() { return null; }, remove() { } } ); function ni(s) { return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(s); } function ri(s, i) { return i ? s.replace(/\/?\/$/, "") + "/" + i.replace(/^\/+/, "") : s; } function cr(s, i, u) { let l = !ni(i); return s && l || u == !1 ? ri(s, i) : i; } const ur = (s) => s instanceof Oe ? { ...s } : s; function Qe(s, i) { i = i || {}; const u = {}; function l(O, T, C, W) { return _.isPlainObject(O) && _.isPlainObject(T) ? _.merge.call({ caseless: W }, O, T) : _.isPlainObject(T) ? _.merge({}, T) : _.isArray(T) ? T.slice() : T; } function p(O, T, C, W) { if (_.isUndefined(T)) { if (!_.isUndefined(O)) return l(void 0, O, C, W); } else return l(O, T, C, W); } function g(O, T) { if (!_.isUndefined(T)) return l(void 0, T); } function w(O, T) { if (_.isUndefined(T)) { if (!_.isUndefined(O)) return l(void 0, O); } else return l(void 0, T); } function S(O, T, C) { if (C in i) return l(O, T); if (C in s) return l(void 0, O); } const A = { url: g, method: g, data: g, baseURL: w, transformRequest: w, transformResponse: w, paramsSerializer: w, timeout: w, timeoutMessage: w, withCredentials: w, withXSRFToken: w, adapter: w, responseType: w, xsrfCookieName: w, xsrfHeaderName: w, onUploadProgress: w, onDownloadProgress: w, decompress: w, maxContentLength: w, maxBodyLength: w, beforeRedirect: w, transport: w, httpAgent: w, httpsAgent: w, cancelToken: w, socketPath: w, responseEncoding: w, validateStatus: S, headers: (O, T, C) => p(ur(O), ur(T), C, !0) }; return _.forEach(Object.keys(Object.assign({}, s, i)), function(T) { const C = A[T] || p, W = C(s[T], i[T], T); _.isUndefined(W) && C !== S || (u[T] = W); }), u; } var lr = (s) => { const i = Qe({}, s); let { data: u, withXSRFToken: l, xsrfHeaderName: p, xsrfCookieName: g, headers: w, auth: S } = i; i.headers = w = Oe.from(w), i.url = Zn(cr(i.baseURL, i.url), s.params, s.paramsSerializer), S && w.set( "Authorization", "Basic " + btoa((S.username || "") + ":" + (S.password ? unescape(encodeURIComponent(S.password)) : "")) ); let A; if (_.isFormData(u)) { if (me.hasStandardBrowserEnv || me.hasStandardBrowserWebWorkerEnv) w.setContentType(void 0); else if ((A = w.getContentType()) !== !1) { const [O, ...T] = A ? A.split(";").map((C) => C.trim()).filter(Boolean) : []; w.setContentType([O || "multipart/form-data", ...T].join("; ")); } } if (me.hasStandardBrowserEnv && (l && _.isFunction(l) && (l = l(i)), l || l !== !1 && ei(i.url))) { const O = p && g && ti.read(g); O && w.set(p, O); } return i; }, si = typeof XMLHttpRequest < "u" && function(s) { return new Promise(function(u, l) { const p = lr(s); let g = p.data; const w = Oe.from(p.headers).normalize(); let { responseType: S, onUploadProgress: A, onDownloadProgress: O } = p, T, C, W, ie, L; function F() { ie && ie(), L && L(), p.cancelToken && p.cancelToken.unsubscribe(T), p.signal && p.signal.removeEventListener("abort", T); } let D = new XMLHttpRequest(); D.open(p.method.toUpperCase(), p.url, !0), D.timeout = p.timeout; function Q() { if (!D) return; const de = Oe.from( "getAllResponseHeaders" in D && D.getAllResponseHeaders() ), we = { data: !S || S === "text" || S === "json" ? D.responseText : D.response, status: D.status, statusText: D.statusText, headers: de, config: s, request: D }; ir(function(Ze) { u(Ze), F(); }, function(Ze) { l(Ze), F(); }, we), D = null; } "onloadend" in D ? D.onloadend = Q : D.onreadystatechange = function() { !D || D.readyState !== 4 || D.status === 0 && !(D.responseURL && D.responseURL.indexOf("file:") === 0) || setTimeout(Q); }, D.onabort = function() { D && (l(new k("Request aborted", k.ECONNABORTED, s, D)), D = null); }, D.onerror = function() { l(new k("Network Error", k.ERR_NETWORK, s, D)), D = null; }, D.ontimeout = function() { let qe = p.timeout ? "timeout of " + p.timeout + "ms exceeded" : "timeout exceeded"; const we = p.transitional || tr; p.timeoutErrorMessage && (qe = p.timeoutErrorMessage), l(new k( qe, we.clarifyTimeoutError ? k.ETIMEDOUT : k.ECONNABORTED, s, D )), D = null; }, g === void 0 && w.setContentType(null), "setRequestHeader" in D && _.forEach(w.toJSON(), function(qe, we) { D.setRequestHeader(we, qe); }), _.isUndefined(p.withCredentials) || (D.withCredentials = !!p.withCredentials), S && S !== "json" && (D.responseType = p.responseType), O && ([