@acrool/react-fetcher 0.0.4 → 0.0.6-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,109 +1,160 @@
1
- var zt = Object.defineProperty;
2
- var Jt = (e, t, n) => t in e ? zt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var $ = (e, t, n) => Jt(e, typeof t != "symbol" ? t + "" : t, n);
4
- import Wt, { createContext as ft, useContext as Vt, useState as We, useLayoutEffect as Yt } from "react";
5
- function dt(e) {
6
- return new Promise((t) => {
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ import require$$0, { createContext, useContext, useState, useLayoutEffect } from "react";
5
+ function r$1(e2) {
6
+ return new Promise((t2) => {
7
7
  setTimeout(() => {
8
- t(!0);
9
- }, e);
8
+ t2(true);
9
+ }, e2);
10
10
  });
11
11
  }
12
- const pt = 400, Kt = (e) => "File" in window && e instanceof File, Xt = (e) => "Blob" in window && e instanceof Blob, ht = (e, t = ["variables"]) => e && Object.keys(e).reduce((n, r) => {
13
- const s = e[r];
14
- if (Kt(s) || Xt(s))
12
+ const fetcherLeastTime = 400;
13
+ const isFile$1 = (input) => "File" in window && input instanceof File;
14
+ const isBlob$1 = (input) => "Blob" in window && input instanceof Blob;
15
+ const getVariablesFileMap = (originVariables, parentKey = ["variables"]) => {
16
+ return originVariables && Object.keys(originVariables).reduce((curr, key) => {
17
+ const row = originVariables[key];
18
+ if (isFile$1(row) || isBlob$1(row)) {
19
+ return {
20
+ variables: { ...curr.variables, [key]: null },
21
+ map: [...curr.map, parentKey.concat(key).join(".")],
22
+ values: [...curr.values, row]
23
+ };
24
+ } else if (row && typeof row === "object") {
25
+ const children = getVariablesFileMap(row, parentKey.concat(key));
26
+ return {
27
+ variables: { ...curr.variables, [key]: children.variables },
28
+ map: [...curr.map, ...children.map],
29
+ values: [...curr.values, ...children.values]
30
+ };
31
+ }
15
32
  return {
16
- variables: { ...n.variables, [r]: null },
17
- map: [...n.map, t.concat(r).join(".")],
18
- values: [...n.values, s]
33
+ ...curr,
34
+ variables: { ...curr.variables, [key]: row },
35
+ values: curr.values
19
36
  };
20
- if (s && typeof s == "object") {
21
- const o = ht(s, t.concat(r));
22
- return {
23
- variables: { ...n.variables, [r]: o.variables },
24
- map: [...n.map, ...o.map],
25
- values: [...n.values, ...o.values]
37
+ }, { variables: {}, map: [], values: [] });
38
+ };
39
+ const createGraphQLFetcher = (axiosInstance, query) => {
40
+ return async (args) => {
41
+ let data = void 0;
42
+ let contentType = void 0;
43
+ const options = args == null ? void 0 : args.fetchOptions;
44
+ const variables = args == null ? void 0 : args.variables;
45
+ let isMultipartFormData = false;
46
+ if (variables) {
47
+ const varOptions = getVariablesFileMap(variables);
48
+ isMultipartFormData = varOptions.values.length > 0;
49
+ if (isMultipartFormData) {
50
+ contentType = "multipart/form-data";
51
+ const operations = JSON.stringify({
52
+ query,
53
+ variables: varOptions.variables
54
+ });
55
+ const fileMapObj = varOptions.map.reduce((acc, val, index) => {
56
+ acc[index] = [val];
57
+ return acc;
58
+ }, {});
59
+ const graphqlFormOptions = [
60
+ { name: "operations", value: operations },
61
+ { name: "map", value: JSON.stringify(fileMapObj) },
62
+ ...varOptions.values.map((row, index) => {
63
+ return { name: index, value: row };
64
+ })
65
+ ];
66
+ data = new FormData();
67
+ graphqlFormOptions.forEach((row) => {
68
+ data.append(row.name.toString(), row.value);
69
+ });
70
+ }
71
+ }
72
+ if (!isMultipartFormData) {
73
+ contentType = "application/json";
74
+ data = JSON.stringify({ query, variables });
75
+ }
76
+ const endpoint = "";
77
+ const headers = {
78
+ "Content-Type": contentType,
79
+ "Apollo-Require-Preflight": "true",
80
+ "X-Requested-With": "XMLHttpRequest",
81
+ ...options == null ? void 0 : options.headers
26
82
  };
27
- }
28
- return {
29
- ...n,
30
- variables: { ...n.variables, [r]: s },
31
- values: n.values
83
+ const [res] = await Promise.all([
84
+ axiosInstance.post(endpoint, data, {
85
+ ...options,
86
+ headers
87
+ }),
88
+ r$1((options == null ? void 0 : options.leastTime) ?? fetcherLeastTime)
89
+ ]);
90
+ return res.data.data;
32
91
  };
33
- }, { variables: {}, map: [], values: [] }), Wr = (e, t) => async (n) => {
34
- let r, s;
35
- const o = n == null ? void 0 : n.fetchOptions, i = n == null ? void 0 : n.variables;
36
- let c = !1;
37
- if (i) {
38
- const p = ht(i);
39
- if (c = p.values.length > 0, c) {
40
- s = "multipart/form-data";
41
- const y = JSON.stringify({
42
- query: t,
43
- variables: p.variables
44
- }), T = p.map.reduce((R, m, S) => (R[S] = [m], R), {}), h = [
45
- { name: "operations", value: y },
46
- { name: "map", value: JSON.stringify(T) },
47
- ...p.values.map((R, m) => ({ name: m, value: R }))
48
- ];
49
- r = new FormData(), h.forEach((R) => {
50
- r.append(R.name.toString(), R.value);
51
- });
52
- }
53
- }
54
- c || (s = "application/json", r = JSON.stringify({ query: t, variables: i }));
55
- const d = "", l = {
56
- "Content-Type": s,
57
- "Apollo-Require-Preflight": "true",
58
- "X-Requested-With": "XMLHttpRequest",
59
- ...o == null ? void 0 : o.headers
60
- }, [u] = await Promise.all([
61
- e.post(d, r, {
62
- ...o,
63
- headers: l
64
- }),
65
- dt((o == null ? void 0 : o.leastTime) ?? pt)
66
- ]);
67
- return u.data.data;
68
92
  };
69
- function Gt(e) {
70
- const t = new FormData(), n = (r, s = "") => {
71
- for (const [o, i] of Object.entries(r)) {
72
- const c = s ? `${s}[${o}]` : o;
73
- if (i instanceof File)
74
- t.append(c, i);
75
- else if (i instanceof Blob) {
76
- const d = i.type.split("/")[1] || "bin", l = `${o}.${d}`;
77
- t.append(c, i, l);
78
- } else Array.isArray(i) ? i.forEach((d, l) => {
79
- typeof d == "object" && d !== null ? n(d, `${c}[${l}]`) : t.append(`${c}[${l}]`, d);
80
- }) : typeof i == "object" && i !== null ? n(i, c) : i != null && t.append(c, i);
93
+ function $(t2) {
94
+ const n = new FormData(), e2 = (s2, r2 = "") => {
95
+ for (const [a2, o] of Object.entries(s2)) {
96
+ const i2 = r2 ? `${r2}[${a2}]` : a2;
97
+ if (o instanceof File)
98
+ n.append(i2, o);
99
+ else if (o instanceof Blob) {
100
+ const l2 = o.type.split("/")[1] || "bin", u2 = `${a2}.${l2}`;
101
+ n.append(i2, o, u2);
102
+ } else Array.isArray(o) ? o.forEach((c, l2) => {
103
+ typeof c == "object" && c !== null ? e2(c, `${i2}[${l2}]`) : n.append(`${i2}[${l2}]`, c);
104
+ }) : typeof o == "object" && o !== null ? e2(o, i2) : o != null && n.append(i2, o);
81
105
  }
82
106
  };
83
- return n(e), t;
107
+ return e2(t2), n;
84
108
  }
85
- var de = /* @__PURE__ */ ((e) => (e.formData = "multipart/form-data", e.formUrlDecode = "application/x-www-form-urlencoded", e.json = "application/json", e))(de || {}), Zt = /* @__PURE__ */ ((e) => (e.GET = "GET", e.POST = "POST", e.PUT = "PUT", e.DELETE = "DELETE", e.PATCH = "PATCH", e))(Zt || {});
86
- const Qt = (e, t = {}) => [de.formData, de.formUrlDecode].includes(e) ? Gt(t) : JSON.stringify(t), en = (e) => de.json, Vr = (e, t, n = en) => async (r) => {
87
- var p;
88
- const s = (t == null ? void 0 : t.method) || "", o = r == null ? void 0 : r.fetchOptions, i = typeof r == "object" && r !== null && "body" in r ? r.body : void 0, c = typeof r == "object" && r !== null && "params" in r ? r.params : void 0;
89
- console.log("variables", r);
90
- const d = ((p = o == null ? void 0 : o.headers) == null ? void 0 : p.contentType) ?? n(s.toUpperCase()), l = {
91
- url: t.url,
92
- method: s,
93
- params: c,
94
- data: Qt(d, i),
95
- ...o,
96
- headers: {
97
- ...o == null ? void 0 : o.headers,
98
- "Content-Type": d
99
- }
100
- }, [u] = await Promise.all([
101
- e(l),
102
- dt((o == null ? void 0 : o.leastTime) ?? pt)
103
- ]);
104
- return u.data;
109
+ var ERequestContentType = /* @__PURE__ */ ((ERequestContentType2) => {
110
+ ERequestContentType2["formData"] = "multipart/form-data";
111
+ ERequestContentType2["formUrlDecode"] = "application/x-www-form-urlencoded";
112
+ ERequestContentType2["json"] = "application/json";
113
+ return ERequestContentType2;
114
+ })(ERequestContentType || {});
115
+ var ERequestMethod = /* @__PURE__ */ ((ERequestMethod2) => {
116
+ ERequestMethod2["GET"] = "GET";
117
+ ERequestMethod2["POST"] = "POST";
118
+ ERequestMethod2["PUT"] = "PUT";
119
+ ERequestMethod2["DELETE"] = "DELETE";
120
+ ERequestMethod2["PATCH"] = "PATCH";
121
+ return ERequestMethod2;
122
+ })(ERequestMethod || {});
123
+ const getDataWithContentType = (contentType, data = {}) => {
124
+ if ([ERequestContentType.formData, ERequestContentType.formUrlDecode].includes(contentType)) return $(data);
125
+ return JSON.stringify(data);
126
+ };
127
+ const getContentTypeWithMethod = (method) => {
128
+ return ERequestContentType.json;
105
129
  };
106
- var ce = { exports: {} }, Z = {};
130
+ const createRestFulFetcher = (axiosInstance, document2, contentTypeResolver = getContentTypeWithMethod) => {
131
+ return async (args) => {
132
+ var _a;
133
+ const method = (document2 == null ? void 0 : document2.method) || "";
134
+ const options = args == null ? void 0 : args.fetchOptions;
135
+ const body = typeof args === "object" && args !== null && "body" in args ? args.body : void 0;
136
+ const params = typeof args === "object" && args !== null && "params" in args ? args.params : void 0;
137
+ const contentType = ((_a = options == null ? void 0 : options.headers) == null ? void 0 : _a.contentType) ?? contentTypeResolver(method.toUpperCase());
138
+ const config = {
139
+ url: document2.url,
140
+ method,
141
+ params,
142
+ data: getDataWithContentType(contentType, body),
143
+ ...options,
144
+ headers: {
145
+ ...options == null ? void 0 : options.headers,
146
+ "Content-Type": contentType
147
+ }
148
+ };
149
+ const [res] = await Promise.all([
150
+ axiosInstance(config),
151
+ r$1((options == null ? void 0 : options.leastTime) ?? fetcherLeastTime)
152
+ ]);
153
+ return res.data;
154
+ };
155
+ };
156
+ var jsxRuntime = { exports: {} };
157
+ var reactJsxRuntime_production = {};
107
158
  /**
108
159
  * @license React
109
160
  * react-jsx-runtime.production.js
@@ -113,29 +164,35 @@ var ce = { exports: {} }, Z = {};
113
164
  * This source code is licensed under the MIT license found in the
114
165
  * LICENSE file in the root directory of this source tree.
115
166
  */
116
- var Ve;
117
- function tn() {
118
- if (Ve) return Z;
119
- Ve = 1;
120
- var e = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
121
- function n(r, s, o) {
122
- var i = null;
123
- if (o !== void 0 && (i = "" + o), s.key !== void 0 && (i = "" + s.key), "key" in s) {
124
- o = {};
125
- for (var c in s)
126
- c !== "key" && (o[c] = s[c]);
127
- } else o = s;
128
- return s = o.ref, {
129
- $$typeof: e,
130
- type: r,
131
- key: i,
132
- ref: s !== void 0 ? s : null,
133
- props: o
167
+ var hasRequiredReactJsxRuntime_production;
168
+ function requireReactJsxRuntime_production() {
169
+ if (hasRequiredReactJsxRuntime_production) return reactJsxRuntime_production;
170
+ hasRequiredReactJsxRuntime_production = 1;
171
+ var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
172
+ function jsxProd(type, config, maybeKey) {
173
+ var key = null;
174
+ void 0 !== maybeKey && (key = "" + maybeKey);
175
+ void 0 !== config.key && (key = "" + config.key);
176
+ if ("key" in config) {
177
+ maybeKey = {};
178
+ for (var propName in config)
179
+ "key" !== propName && (maybeKey[propName] = config[propName]);
180
+ } else maybeKey = config;
181
+ config = maybeKey.ref;
182
+ return {
183
+ $$typeof: REACT_ELEMENT_TYPE,
184
+ type,
185
+ key,
186
+ ref: void 0 !== config ? config : null,
187
+ props: maybeKey
134
188
  };
135
189
  }
136
- return Z.Fragment = t, Z.jsx = n, Z.jsxs = n, Z;
190
+ reactJsxRuntime_production.Fragment = REACT_FRAGMENT_TYPE;
191
+ reactJsxRuntime_production.jsx = jsxProd;
192
+ reactJsxRuntime_production.jsxs = jsxProd;
193
+ return reactJsxRuntime_production;
137
194
  }
138
- var Q = {};
195
+ var reactJsxRuntime_development = {};
139
196
  /**
140
197
  * @license React
141
198
  * react-jsx-runtime.development.js
@@ -145,435 +202,445 @@ var Q = {};
145
202
  * This source code is licensed under the MIT license found in the
146
203
  * LICENSE file in the root directory of this source tree.
147
204
  */
148
- var Ye;
149
- function nn() {
150
- return Ye || (Ye = 1, process.env.NODE_ENV !== "production" && function() {
151
- function e(f) {
152
- if (f == null) return null;
153
- if (typeof f == "function")
154
- return f.$$typeof === V ? null : f.displayName || f.name || null;
155
- if (typeof f == "string") return f;
156
- switch (f) {
157
- case R:
205
+ var hasRequiredReactJsxRuntime_development;
206
+ function requireReactJsxRuntime_development() {
207
+ if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
208
+ hasRequiredReactJsxRuntime_development = 1;
209
+ "production" !== process.env.NODE_ENV && function() {
210
+ function getComponentNameFromType(type) {
211
+ if (null == type) return null;
212
+ if ("function" === typeof type)
213
+ return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
214
+ if ("string" === typeof type) return type;
215
+ switch (type) {
216
+ case REACT_FRAGMENT_TYPE:
158
217
  return "Fragment";
159
- case S:
218
+ case REACT_PROFILER_TYPE:
160
219
  return "Profiler";
161
- case m:
220
+ case REACT_STRICT_MODE_TYPE:
162
221
  return "StrictMode";
163
- case g:
222
+ case REACT_SUSPENSE_TYPE:
164
223
  return "Suspense";
165
- case x:
224
+ case REACT_SUSPENSE_LIST_TYPE:
166
225
  return "SuspenseList";
167
- case j:
226
+ case REACT_ACTIVITY_TYPE:
168
227
  return "Activity";
169
228
  }
170
- if (typeof f == "object")
171
- switch (typeof f.tag == "number" && console.error(
229
+ if ("object" === typeof type)
230
+ switch ("number" === typeof type.tag && console.error(
172
231
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
173
- ), f.$$typeof) {
174
- case h:
232
+ ), type.$$typeof) {
233
+ case REACT_PORTAL_TYPE:
175
234
  return "Portal";
176
- case E:
177
- return (f.displayName || "Context") + ".Provider";
178
- case A:
179
- return (f._context.displayName || "Context") + ".Consumer";
180
- case O:
181
- var w = f.render;
182
- return f = f.displayName, f || (f = w.displayName || w.name || "", f = f !== "" ? "ForwardRef(" + f + ")" : "ForwardRef"), f;
183
- case N:
184
- return w = f.displayName || null, w !== null ? w : e(f.type) || "Memo";
185
- case B:
186
- w = f._payload, f = f._init;
235
+ case REACT_CONTEXT_TYPE:
236
+ return (type.displayName || "Context") + ".Provider";
237
+ case REACT_CONSUMER_TYPE:
238
+ return (type._context.displayName || "Context") + ".Consumer";
239
+ case REACT_FORWARD_REF_TYPE:
240
+ var innerType = type.render;
241
+ type = type.displayName;
242
+ type || (type = innerType.displayName || innerType.name || "", type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef");
243
+ return type;
244
+ case REACT_MEMO_TYPE:
245
+ return innerType = type.displayName || null, null !== innerType ? innerType : getComponentNameFromType(type.type) || "Memo";
246
+ case REACT_LAZY_TYPE:
247
+ innerType = type._payload;
248
+ type = type._init;
187
249
  try {
188
- return e(f(w));
189
- } catch {
250
+ return getComponentNameFromType(type(innerType));
251
+ } catch (x) {
190
252
  }
191
253
  }
192
254
  return null;
193
255
  }
194
- function t(f) {
195
- return "" + f;
256
+ function testStringCoercion(value) {
257
+ return "" + value;
196
258
  }
197
- function n(f) {
259
+ function checkKeyStringCoercion(value) {
198
260
  try {
199
- t(f);
200
- var w = !1;
201
- } catch {
202
- w = !0;
261
+ testStringCoercion(value);
262
+ var JSCompiler_inline_result = false;
263
+ } catch (e2) {
264
+ JSCompiler_inline_result = true;
203
265
  }
204
- if (w) {
205
- w = console;
206
- var _ = w.error, C = typeof Symbol == "function" && Symbol.toStringTag && f[Symbol.toStringTag] || f.constructor.name || "Object";
207
- return _.call(
208
- w,
266
+ if (JSCompiler_inline_result) {
267
+ JSCompiler_inline_result = console;
268
+ var JSCompiler_temp_const = JSCompiler_inline_result.error;
269
+ var JSCompiler_inline_result$jscomp$0 = "function" === typeof Symbol && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
270
+ JSCompiler_temp_const.call(
271
+ JSCompiler_inline_result,
209
272
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
210
- C
211
- ), t(f);
273
+ JSCompiler_inline_result$jscomp$0
274
+ );
275
+ return testStringCoercion(value);
212
276
  }
213
277
  }
214
- function r(f) {
215
- if (f === R) return "<>";
216
- if (typeof f == "object" && f !== null && f.$$typeof === B)
278
+ function getTaskName(type) {
279
+ if (type === REACT_FRAGMENT_TYPE) return "<>";
280
+ if ("object" === typeof type && null !== type && type.$$typeof === REACT_LAZY_TYPE)
217
281
  return "<...>";
218
282
  try {
219
- var w = e(f);
220
- return w ? "<" + w + ">" : "<...>";
221
- } catch {
283
+ var name = getComponentNameFromType(type);
284
+ return name ? "<" + name + ">" : "<...>";
285
+ } catch (x) {
222
286
  return "<...>";
223
287
  }
224
288
  }
225
- function s() {
226
- var f = H.A;
227
- return f === null ? null : f.getOwner();
289
+ function getOwner() {
290
+ var dispatcher = ReactSharedInternals.A;
291
+ return null === dispatcher ? null : dispatcher.getOwner();
228
292
  }
229
- function o() {
293
+ function UnknownOwner() {
230
294
  return Error("react-stack-top-frame");
231
295
  }
232
- function i(f) {
233
- if (Ie.call(f, "key")) {
234
- var w = Object.getOwnPropertyDescriptor(f, "key").get;
235
- if (w && w.isReactWarning) return !1;
296
+ function hasValidKey(config) {
297
+ if (hasOwnProperty2.call(config, "key")) {
298
+ var getter = Object.getOwnPropertyDescriptor(config, "key").get;
299
+ if (getter && getter.isReactWarning) return false;
236
300
  }
237
- return f.key !== void 0;
301
+ return void 0 !== config.key;
238
302
  }
239
- function c(f, w) {
240
- function _() {
241
- $e || ($e = !0, console.error(
303
+ function defineKeyPropWarningGetter(props, displayName) {
304
+ function warnAboutAccessingKey() {
305
+ specialPropKeyWarningShown || (specialPropKeyWarningShown = true, console.error(
242
306
  "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
243
- w
307
+ displayName
244
308
  ));
245
309
  }
246
- _.isReactWarning = !0, Object.defineProperty(f, "key", {
247
- get: _,
248
- configurable: !0
310
+ warnAboutAccessingKey.isReactWarning = true;
311
+ Object.defineProperty(props, "key", {
312
+ get: warnAboutAccessingKey,
313
+ configurable: true
249
314
  });
250
315
  }
251
- function d() {
252
- var f = e(this.type);
253
- return Me[f] || (Me[f] = !0, console.error(
316
+ function elementRefGetterWithDeprecationWarning() {
317
+ var componentName = getComponentNameFromType(this.type);
318
+ didWarnAboutElementRef[componentName] || (didWarnAboutElementRef[componentName] = true, console.error(
254
319
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
255
- )), f = this.props.ref, f !== void 0 ? f : null;
256
- }
257
- function l(f, w, _, C, M, q, Se, Oe) {
258
- return _ = q.ref, f = {
259
- $$typeof: T,
260
- type: f,
261
- key: w,
262
- props: q,
263
- _owner: M
264
- }, (_ !== void 0 ? _ : null) !== null ? Object.defineProperty(f, "ref", {
265
- enumerable: !1,
266
- get: d
267
- }) : Object.defineProperty(f, "ref", { enumerable: !1, value: null }), f._store = {}, Object.defineProperty(f._store, "validated", {
268
- configurable: !1,
269
- enumerable: !1,
270
- writable: !0,
320
+ ));
321
+ componentName = this.props.ref;
322
+ return void 0 !== componentName ? componentName : null;
323
+ }
324
+ function ReactElement(type, key, self2, source, owner, props, debugStack, debugTask) {
325
+ self2 = props.ref;
326
+ type = {
327
+ $$typeof: REACT_ELEMENT_TYPE,
328
+ type,
329
+ key,
330
+ props,
331
+ _owner: owner
332
+ };
333
+ null !== (void 0 !== self2 ? self2 : null) ? Object.defineProperty(type, "ref", {
334
+ enumerable: false,
335
+ get: elementRefGetterWithDeprecationWarning
336
+ }) : Object.defineProperty(type, "ref", { enumerable: false, value: null });
337
+ type._store = {};
338
+ Object.defineProperty(type._store, "validated", {
339
+ configurable: false,
340
+ enumerable: false,
341
+ writable: true,
271
342
  value: 0
272
- }), Object.defineProperty(f, "_debugInfo", {
273
- configurable: !1,
274
- enumerable: !1,
275
- writable: !0,
343
+ });
344
+ Object.defineProperty(type, "_debugInfo", {
345
+ configurable: false,
346
+ enumerable: false,
347
+ writable: true,
276
348
  value: null
277
- }), Object.defineProperty(f, "_debugStack", {
278
- configurable: !1,
279
- enumerable: !1,
280
- writable: !0,
281
- value: Se
282
- }), Object.defineProperty(f, "_debugTask", {
283
- configurable: !1,
284
- enumerable: !1,
285
- writable: !0,
286
- value: Oe
287
- }), Object.freeze && (Object.freeze(f.props), Object.freeze(f)), f;
288
- }
289
- function u(f, w, _, C, M, q, Se, Oe) {
290
- var k = w.children;
291
- if (k !== void 0)
292
- if (C)
293
- if (Mt(k)) {
294
- for (C = 0; C < k.length; C++)
295
- p(k[C]);
296
- Object.freeze && Object.freeze(k);
349
+ });
350
+ Object.defineProperty(type, "_debugStack", {
351
+ configurable: false,
352
+ enumerable: false,
353
+ writable: true,
354
+ value: debugStack
355
+ });
356
+ Object.defineProperty(type, "_debugTask", {
357
+ configurable: false,
358
+ enumerable: false,
359
+ writable: true,
360
+ value: debugTask
361
+ });
362
+ Object.freeze && (Object.freeze(type.props), Object.freeze(type));
363
+ return type;
364
+ }
365
+ function jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self2, debugStack, debugTask) {
366
+ var children = config.children;
367
+ if (void 0 !== children)
368
+ if (isStaticChildren)
369
+ if (isArrayImpl(children)) {
370
+ for (isStaticChildren = 0; isStaticChildren < children.length; isStaticChildren++)
371
+ validateChildKeys(children[isStaticChildren]);
372
+ Object.freeze && Object.freeze(children);
297
373
  } else
298
374
  console.error(
299
375
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
300
376
  );
301
- else p(k);
302
- if (Ie.call(w, "key")) {
303
- k = e(f);
304
- var Y = Object.keys(w).filter(function(Ht) {
305
- return Ht !== "key";
377
+ else validateChildKeys(children);
378
+ if (hasOwnProperty2.call(config, "key")) {
379
+ children = getComponentNameFromType(type);
380
+ var keys = Object.keys(config).filter(function(k) {
381
+ return "key" !== k;
306
382
  });
307
- C = 0 < Y.length ? "{key: someKey, " + Y.join(": ..., ") + ": ...}" : "{key: someKey}", Je[k + C] || (Y = 0 < Y.length ? "{" + Y.join(": ..., ") + ": ...}" : "{}", console.error(
308
- `A props object containing a "key" prop is being spread into JSX:
309
- let props = %s;
310
- <%s {...props} />
311
- React keys must be passed directly to JSX without using spread:
312
- let props = %s;
313
- <%s key={someKey} {...props} />`,
314
- C,
315
- k,
316
- Y,
317
- k
318
- ), Je[k + C] = !0);
383
+ isStaticChildren = 0 < keys.length ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" : "{key: someKey}";
384
+ didWarnAboutKeySpread[children + isStaticChildren] || (keys = 0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}", console.error(
385
+ 'A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',
386
+ isStaticChildren,
387
+ children,
388
+ keys,
389
+ children
390
+ ), didWarnAboutKeySpread[children + isStaticChildren] = true);
319
391
  }
320
- if (k = null, _ !== void 0 && (n(_), k = "" + _), i(w) && (n(w.key), k = "" + w.key), "key" in w) {
321
- _ = {};
322
- for (var Ae in w)
323
- Ae !== "key" && (_[Ae] = w[Ae]);
324
- } else _ = w;
325
- return k && c(
326
- _,
327
- typeof f == "function" ? f.displayName || f.name || "Unknown" : f
328
- ), l(
329
- f,
330
- k,
331
- q,
332
- M,
333
- s(),
334
- _,
335
- Se,
336
- Oe
392
+ children = null;
393
+ void 0 !== maybeKey && (checkKeyStringCoercion(maybeKey), children = "" + maybeKey);
394
+ hasValidKey(config) && (checkKeyStringCoercion(config.key), children = "" + config.key);
395
+ if ("key" in config) {
396
+ maybeKey = {};
397
+ for (var propName in config)
398
+ "key" !== propName && (maybeKey[propName] = config[propName]);
399
+ } else maybeKey = config;
400
+ children && defineKeyPropWarningGetter(
401
+ maybeKey,
402
+ "function" === typeof type ? type.displayName || type.name || "Unknown" : type
403
+ );
404
+ return ReactElement(
405
+ type,
406
+ children,
407
+ self2,
408
+ source,
409
+ getOwner(),
410
+ maybeKey,
411
+ debugStack,
412
+ debugTask
337
413
  );
338
414
  }
339
- function p(f) {
340
- typeof f == "object" && f !== null && f.$$typeof === T && f._store && (f._store.validated = 1);
415
+ function validateChildKeys(node) {
416
+ "object" === typeof node && null !== node && node.$$typeof === REACT_ELEMENT_TYPE && node._store && (node._store.validated = 1);
341
417
  }
342
- var y = Wt, T = Symbol.for("react.transitional.element"), h = Symbol.for("react.portal"), R = Symbol.for("react.fragment"), m = Symbol.for("react.strict_mode"), S = Symbol.for("react.profiler"), A = Symbol.for("react.consumer"), E = Symbol.for("react.context"), O = Symbol.for("react.forward_ref"), g = Symbol.for("react.suspense"), x = Symbol.for("react.suspense_list"), N = Symbol.for("react.memo"), B = Symbol.for("react.lazy"), j = Symbol.for("react.activity"), V = Symbol.for("react.client.reference"), H = y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Ie = Object.prototype.hasOwnProperty, Mt = Array.isArray, ge = console.createTask ? console.createTask : function() {
418
+ var React = require$$0, REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = Symbol.for("react.profiler");
419
+ var REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy"), REACT_ACTIVITY_TYPE = Symbol.for("react.activity"), REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"), ReactSharedInternals = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, hasOwnProperty2 = Object.prototype.hasOwnProperty, isArrayImpl = Array.isArray, createTask = console.createTask ? console.createTask : function() {
343
420
  return null;
344
421
  };
345
- y = {
346
- "react-stack-bottom-frame": function(f) {
347
- return f();
422
+ React = {
423
+ "react-stack-bottom-frame": function(callStackForError) {
424
+ return callStackForError();
348
425
  }
349
426
  };
350
- var $e, Me = {}, He = y["react-stack-bottom-frame"].bind(
351
- y,
352
- o
353
- )(), ze = ge(r(o)), Je = {};
354
- Q.Fragment = R, Q.jsx = function(f, w, _, C, M) {
355
- var q = 1e4 > H.recentlyCreatedOwnerStacks++;
356
- return u(
357
- f,
358
- w,
359
- _,
360
- !1,
361
- C,
362
- M,
363
- q ? Error("react-stack-top-frame") : He,
364
- q ? ge(r(f)) : ze
427
+ var specialPropKeyWarningShown;
428
+ var didWarnAboutElementRef = {};
429
+ var unknownOwnerDebugStack = React["react-stack-bottom-frame"].bind(
430
+ React,
431
+ UnknownOwner
432
+ )();
433
+ var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
434
+ var didWarnAboutKeySpread = {};
435
+ reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
436
+ reactJsxRuntime_development.jsx = function(type, config, maybeKey, source, self2) {
437
+ var trackActualOwner = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
438
+ return jsxDEVImpl(
439
+ type,
440
+ config,
441
+ maybeKey,
442
+ false,
443
+ source,
444
+ self2,
445
+ trackActualOwner ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
446
+ trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
365
447
  );
366
- }, Q.jsxs = function(f, w, _, C, M) {
367
- var q = 1e4 > H.recentlyCreatedOwnerStacks++;
368
- return u(
369
- f,
370
- w,
371
- _,
372
- !0,
373
- C,
374
- M,
375
- q ? Error("react-stack-top-frame") : He,
376
- q ? ge(r(f)) : ze
448
+ };
449
+ reactJsxRuntime_development.jsxs = function(type, config, maybeKey, source, self2) {
450
+ var trackActualOwner = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
451
+ return jsxDEVImpl(
452
+ type,
453
+ config,
454
+ maybeKey,
455
+ true,
456
+ source,
457
+ self2,
458
+ trackActualOwner ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
459
+ trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
377
460
  );
378
461
  };
379
- }()), Q;
462
+ }();
463
+ return reactJsxRuntime_development;
380
464
  }
381
- var Ke;
382
- function rn() {
383
- return Ke || (Ke = 1, process.env.NODE_ENV === "production" ? ce.exports = tn() : ce.exports = nn()), ce.exports;
465
+ var hasRequiredJsxRuntime;
466
+ function requireJsxRuntime() {
467
+ if (hasRequiredJsxRuntime) return jsxRuntime.exports;
468
+ hasRequiredJsxRuntime = 1;
469
+ if (process.env.NODE_ENV === "production") {
470
+ jsxRuntime.exports = requireReactJsxRuntime_production();
471
+ } else {
472
+ jsxRuntime.exports = requireReactJsxRuntime_development();
473
+ }
474
+ return jsxRuntime.exports;
384
475
  }
385
- var mt = rn();
386
- const re = [
476
+ var jsxRuntimeExports = requireJsxRuntime();
477
+ const s = [
387
478
  "color: #fff",
388
479
  "display: inline-block",
389
480
  "font-size: 11px",
390
481
  "line-height: 20px",
391
482
  "padding-right: 8px",
392
483
  "border-radius: 4px"
393
- ], se = {
484
+ ], t = {
394
485
  primary: "#0055a9",
395
486
  success: "#009422",
396
487
  info: "#17a2b8",
397
488
  warning: "#d7a000",
398
489
  danger: "#ec2127"
399
490
  };
400
- function oe(e, t, ...n) {
401
- console.log(`%c ${e}`, t, ...n);
491
+ function a(n, o, ...c) {
492
+ console.log(`%c ${n}`, o, ...c);
402
493
  }
403
- function sn(e, ...t) {
404
- const n = re.concat([
405
- `background-color: ${se.primary}`
494
+ function i(n, ...o) {
495
+ const c = s.concat([
496
+ `background-color: ${t.primary}`
406
497
  ]).join(";");
407
- oe(e, n, ...t);
498
+ a(n, c, ...o);
408
499
  }
409
- function on(e, ...t) {
410
- const n = re.concat([
411
- `background-color: ${se.success}`
500
+ function r(n, ...o) {
501
+ const c = s.concat([
502
+ `background-color: ${t.success}`
412
503
  ]).join(";");
413
- oe(e, n, ...t);
504
+ a(n, c, ...o);
414
505
  }
415
- function an(e, ...t) {
416
- const n = re.concat([
417
- `background-color: ${se.info}`
506
+ function e(n, ...o) {
507
+ const c = s.concat([
508
+ `background-color: ${t.info}`
418
509
  ]).join(";");
419
- oe(e, n, ...t);
510
+ a(n, c, ...o);
420
511
  }
421
- function cn(e, ...t) {
422
- const n = re.concat([
423
- `background-color: ${se.warning}`
512
+ function l(n, ...o) {
513
+ const c = s.concat([
514
+ `background-color: ${t.warning}`
424
515
  ]).join(";");
425
- oe(e, n, ...t);
516
+ a(n, c, ...o);
426
517
  }
427
- function ln(e, ...t) {
428
- const n = re.concat([
429
- `background-color: ${se.danger}`
518
+ function g(n, ...o) {
519
+ const c = s.concat([
520
+ `background-color: ${t.danger}`
430
521
  ]).join(";");
431
- oe(e, n, ...t);
522
+ a(n, c, ...o);
432
523
  }
433
- const F = {
434
- primary: sn,
435
- success: on,
436
- info: an,
437
- warning: cn,
438
- danger: ln
524
+ const u = {
525
+ primary: i,
526
+ success: r,
527
+ info: e,
528
+ warning: l,
529
+ danger: g
439
530
  };
440
- function Ue(e, t) {
441
- const n = {
442
- isZero: (t == null ? void 0 : t.isZero) ?? !0,
443
- isFalse: (t == null ? void 0 : t.isFalse) ?? !0
531
+ function w(e2, t2) {
532
+ const r2 = {
533
+ isZero: (t2 == null ? void 0 : t2.isZero) ?? true,
534
+ isFalse: (t2 == null ? void 0 : t2.isFalse) ?? true
444
535
  };
445
- return e == null || n.isFalse && (e === !1 || e === "false") || n.isZero && (e === 0 || e === "0") || !(e instanceof Date) && typeof e == "object" && Object.keys(e).length === 0 || typeof e == "string" && e.trim().length === 0;
536
+ return e2 == null || r2.isFalse && (e2 === false || e2 === "false") || r2.isZero && (e2 === 0 || e2 === "0") || !(e2 instanceof Date) && typeof e2 == "object" && Object.keys(e2).length === 0 || typeof e2 == "string" && e2.trim().length === 0;
446
537
  }
447
- function Xe(e, t) {
448
- return !Ue(e, {
449
- isZero: !0,
450
- isFalse: !0
451
- });
538
+ function D(e2, t2) {
539
+ const r2 = {
540
+ isZero: true,
541
+ isFalse: true
542
+ };
543
+ return !w(e2, r2);
452
544
  }
453
- class K extends Error {
454
- constructor(n) {
455
- super(n.message);
456
- $(this, "code");
457
- $(this, "devInfo");
458
- $(this, "args");
459
- $(this, "path");
460
- this.response = n, this.code = n.code, this.args = n.args, this.path = n.path, this.initName();
461
- }
462
- initName() {
545
+ class FetcherException extends Error {
546
+ constructor(response) {
547
+ super(response.message);
548
+ __publicField(this, "code");
549
+ __publicField(this, "args");
550
+ __publicField(this, "path");
551
+ this.response = response;
552
+ this.code = response.code;
553
+ this.args = response.args;
554
+ this.path = response.path;
463
555
  this.name = this.constructor.name;
464
- }
465
- getInfo() {
466
- return {
467
- message: this.response.message,
468
- code: this.response.code,
469
- args: this.response.args,
470
- path: this.response.path
471
- };
556
+ Object.setPrototypeOf(this, FetcherException.prototype);
472
557
  }
473
558
  }
474
- const Rt = ft({
559
+ const AuthStateContext = createContext({
475
560
  lastUpdateTimestamp: 0,
476
- isAuth: !1,
477
- getTokens: () => (F.warning("AuthStateContext", "getTokens not yet ready"), null),
478
- updateTokens: () => F.warning("AuthStateContext", "updateTokens not yet ready"),
479
- forceLogout: () => F.warning("AuthStateContext", "forceLogout not yet ready"),
561
+ isAuth: false,
562
+ getTokens: () => {
563
+ u.warning("AuthStateContext", "getTokens not yet ready");
564
+ return null;
565
+ },
566
+ updateTokens: () => u.warning("AuthStateContext", "updateTokens not yet ready"),
567
+ forceLogout: () => u.warning("AuthStateContext", "forceLogout not yet ready"),
480
568
  refreshTokens: async () => {
481
- F.warning("AuthStateContext", "refreshToken not yet ready");
482
- }
483
- }), un = () => Vt(Rt), Yr = ({
484
- children: e,
485
- onGetTokens: t,
486
- onSetTokens: n,
487
- onRefreshTokens: r,
488
- onForceLogout: s,
489
- isDebug: o = !1
569
+ u.warning("AuthStateContext", "refreshToken not yet ready");
570
+ return void 0;
571
+ }
572
+ });
573
+ const useAuthState = () => useContext(AuthStateContext);
574
+ const AuthStateProvider = ({
575
+ children,
576
+ onGetTokens,
577
+ onSetTokens,
578
+ onRefreshTokens,
579
+ onForceLogout,
580
+ isDebug = false
490
581
  }) => {
491
- const [i, c] = We(0), [d, l] = We(() => Xe(t())), u = (T) => {
492
- let h;
493
- typeof T == "function" ? h = T(t()) : h = T, n(h), l(Xe(h)), c(Date.now());
494
- }, p = () => {
495
- u(null), s && s();
496
- }, y = async () => {
497
- var h;
498
- const T = (h = t()) == null ? void 0 : h.refreshToken;
499
- if (!T || !r)
500
- throw o && F.danger("[AuthStateProvider] handleOnRefreshTokens", "refreshToken|onRefreshTokens empty"), new K({ message: "refreshToken|onRefreshTokens empty", code: "REFRESH_TOKEN_EMPTY" });
582
+ const [lastUpdateTimestamp, setLastUpdateTimestamp] = useState(0);
583
+ const [isAuth, setIsAuth] = useState(() => {
584
+ return D(onGetTokens());
585
+ });
586
+ const updateTokens = (tokensOrUpdater) => {
587
+ let nextTokens;
588
+ if (typeof tokensOrUpdater === "function") {
589
+ nextTokens = tokensOrUpdater(onGetTokens());
590
+ } else {
591
+ nextTokens = tokensOrUpdater;
592
+ }
593
+ onSetTokens(nextTokens);
594
+ setIsAuth(D(nextTokens));
595
+ setLastUpdateTimestamp(Date.now());
596
+ };
597
+ const handleOnForceLogout = () => {
598
+ updateTokens(null);
599
+ if (onForceLogout) {
600
+ onForceLogout();
601
+ }
602
+ };
603
+ const handleOnRefreshTokens = async () => {
604
+ var _a;
605
+ const refreshToken = (_a = onGetTokens()) == null ? void 0 : _a.refreshToken;
606
+ if (!refreshToken || !onRefreshTokens) {
607
+ if (isDebug) u.danger("[AuthStateProvider] handleOnRefreshTokens", "refreshToken|onRefreshTokens empty");
608
+ throw new FetcherException({ message: "refreshToken|onRefreshTokens empty", code: "REFRESH_TOKEN_EMPTY" });
609
+ }
501
610
  try {
502
- const R = await r(T);
503
- if (Ue(R))
504
- throw o && F.danger("[AuthStateProvider] handleOnRefreshTokens", "new refresh token fail"), new K({ message: "new refresh token fail", code: "NEW_REFRESH_TOKEN_EMPTY" });
505
- u(R);
611
+ const authTokens = await onRefreshTokens(refreshToken);
612
+ if (w(authTokens)) {
613
+ if (isDebug) u.danger("[AuthStateProvider] handleOnRefreshTokens", "new refresh token fail");
614
+ throw new FetcherException({ message: "new refresh token fail", code: "NEW_REFRESH_TOKEN_EMPTY" });
615
+ }
616
+ updateTokens(authTokens);
506
617
  return;
507
- } catch {
508
- throw p(), new K({ message: "refresh token fail", code: "REFRESH_TOKEN_CATCH" });
618
+ } catch (err) {
619
+ handleOnForceLogout();
620
+ throw new FetcherException({ message: "refresh token fail", code: "REFRESH_TOKEN_CATCH" });
509
621
  }
510
622
  };
511
- return /* @__PURE__ */ mt.jsx(Rt.Provider, { value: {
512
- lastUpdateTimestamp: i,
513
- isAuth: d,
514
- getTokens: t,
515
- updateTokens: u,
516
- refreshTokens: y,
517
- forceLogout: p
518
- }, children: e });
519
- }, Ge = {
520
- "en-US": {
521
- 400: "The requested parameter is wrong",
522
- 401: "Please login before continuing",
523
- 404: "Request Not Found/Route",
524
- 413: "The request/file sent exceeds the server limit size",
525
- 500: "Internal Server Error",
526
- 503: "System under maintenance",
527
- 504: "Please check your network and try again",
528
- 511: "Area not available",
529
- CANCEL_ERROR: "Request has been cancelled. Only possible if `cancelToken` is provided in config, see axios `Cancellation`",
530
- CLIENT_ERROR: "Any non-specific 400 series error",
531
- CONNECTION_ERROR: "Server not available, bad dns",
532
- NETWORK_ERROR: "Your mobile network connection is unstable. Please check your network connection status and try again.",
533
- SERVER_ERROR: "Any 500 series error",
534
- TIMEOUT_ERROR: "The server has not responded for more than {sec} seconds. Please confirm your network connection status or contact customer service"
535
- },
536
- "zh-TW": {
537
- 400: "請求的參數錯誤",
538
- 401: "請先登入再繼續",
539
- 404: "請求未找到/路由錯誤",
540
- 413: "請求/發送的檔案超出伺服器限制大小",
541
- 500: "內部伺服器錯誤",
542
- 503: "系統維護",
543
- 504: "請檢查網路後重試",
544
- 511: "區域不可用",
545
- CANCEL_ERROR: "請求已取消。僅在配置中提供 `cancelToken` 時可能發生,請參閱 axios 的 `Cancellation`",
546
- CLIENT_ERROR: "任意非特定的400系列錯誤",
547
- CONNECTION_ERROR: "伺服器不可用,DNS錯誤",
548
- NETWORK_ERROR: "您的行動網路連線不穩定。請檢查網路連線後重試。 ",
549
- SERVER_ERROR: "任意500系列錯誤",
550
- TIMEOUT_ERROR: "伺服器已超過 {sec} 秒未回應。請確認您的網路連線狀態或聯絡客服"
551
- },
552
- "zh-CN": {
553
- 400: "请求的参数错误",
554
- 401: "请先登录再继续",
555
- 404: "请求未找到/路由错误",
556
- 413: "请求/发送的文件超出服务器限制大小",
557
- 500: "内部服务器错误",
558
- 503: "系统维护中",
559
- 504: "请检查网络后重试",
560
- 511: "区域不可用",
561
- CANCEL_ERROR: "请求已取消。仅当配置中提供 `cancelToken` 时可能发生,请参阅 axios 的 `Cancellation`",
562
- CLIENT_ERROR: "任意非特定的400系列错误",
563
- CONNECTION_ERROR: "服务器不可用,DNS错误",
564
- NETWORK_ERROR: "您的移动网络连接不稳定。请检查网络连接后重试。",
565
- SERVER_ERROR: "任意500系列错误",
566
- TIMEOUT_ERROR: "服务器已超过 {sec} 秒未响应。请确认您的网络连接状态或联系客服"
567
- }
623
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(AuthStateContext.Provider, { value: {
624
+ lastUpdateTimestamp,
625
+ isAuth,
626
+ getTokens: onGetTokens,
627
+ updateTokens,
628
+ refreshTokens: handleOnRefreshTokens,
629
+ forceLogout: handleOnForceLogout
630
+ }, children });
568
631
  };
569
- class fn extends Error {
570
- constructor(n) {
571
- super(n.message);
572
- $(this, "code");
573
- $(this, "devInfo");
574
- $(this, "args");
575
- $(this, "path");
576
- this.response = n, this.code = n.code, this.args = n.args, this.path = n.path, this.initName();
632
+ class AxiosCancelException extends Error {
633
+ constructor(response) {
634
+ super(response.message);
635
+ __publicField(this, "code");
636
+ __publicField(this, "devInfo");
637
+ __publicField(this, "args");
638
+ __publicField(this, "path");
639
+ this.response = response;
640
+ this.code = response.code;
641
+ this.args = response.args;
642
+ this.path = response.path;
643
+ this.initName();
577
644
  }
578
645
  initName() {
579
646
  this.name = this.constructor.name;
@@ -587,320 +654,550 @@ class fn extends Error {
587
654
  };
588
655
  }
589
656
  }
590
- const Kr = (e) => {
591
- var t, n, r, s;
592
- return (n = (t = e == null ? void 0 : e.data) == null ? void 0 : t.errors) != null && n[0] ? (s = (r = e == null ? void 0 : e.data) == null ? void 0 : r.errors) == null ? void 0 : s[0] : {
657
+ const getGraphQLResponseFormatError = (axiosError) => {
658
+ var _a, _b, _c;
659
+ const responseData = (_a = axiosError == null ? void 0 : axiosError.response) == null ? void 0 : _a.data;
660
+ if ((_b = responseData.errors) == null ? void 0 : _b[0]) {
661
+ return (_c = responseData.errors) == null ? void 0 : _c[0];
662
+ }
663
+ if (axiosError == null ? void 0 : axiosError.isAxiosError) {
664
+ return {
665
+ message: axiosError.message,
666
+ code: axiosError.code
667
+ };
668
+ }
669
+ return {
593
670
  message: "Axios error",
594
671
  code: "ERR_SYS_BAD_RESPONSE"
595
672
  };
596
- }, dn = (e) => e != null && e.data ? e == null ? void 0 : e.data : {
597
- message: "Axios error",
598
- code: "ERR_SYS_BAD_RESPONSE"
599
673
  };
600
- let ee = !1, _e = [];
601
- const pn = ft(null), Xr = ({
602
- children: e,
603
- axiosInstance: t,
604
- locale: n = "en-US",
605
- getResponseFormatError: r = dn,
606
- onError: s,
607
- checkIsRefreshTokenRequest: o,
608
- authorizationPrefix: i = "Bearer",
609
- i18nDict: c,
610
- isDebug: d = !1
674
+ const getRestFulResponseFormatError = (axiosError) => {
675
+ var _a;
676
+ const responseData = (_a = axiosError == null ? void 0 : axiosError.response) == null ? void 0 : _a.data;
677
+ if (responseData) {
678
+ return responseData;
679
+ }
680
+ if (axiosError == null ? void 0 : axiosError.isAxiosError) {
681
+ return {
682
+ message: axiosError.message,
683
+ code: axiosError.code
684
+ };
685
+ }
686
+ return {
687
+ message: "Axios error",
688
+ code: "ERR_SYS_BAD_RESPONSE"
689
+ };
690
+ };
691
+ let isTokenRefreshing = false;
692
+ let pendingRequestQueues = [];
693
+ const AxiosClientContext = createContext(null);
694
+ const FetcherProvider = ({
695
+ children,
696
+ axiosInstance,
697
+ locale = "en-US",
698
+ getResponseFormatError = getRestFulResponseFormatError,
699
+ onError,
700
+ checkIsRefreshTokenRequest,
701
+ authorizationPrefix = "Bearer",
702
+ isDebug = false
611
703
  }) => {
612
704
  const {
613
- getTokens: l,
614
- updateTokens: u,
615
- refreshTokens: p,
616
- forceLogout: y
617
- } = un();
618
- Yt(() => {
619
- const E = t.interceptors.request.use(R), O = t.interceptors.response.use(m, A);
705
+ getTokens,
706
+ updateTokens,
707
+ refreshTokens,
708
+ forceLogout
709
+ } = useAuthState();
710
+ useLayoutEffect(() => {
711
+ const interceptorReq = axiosInstance.interceptors.request.use(interceptorsRequest);
712
+ const interceptorRes = axiosInstance.interceptors.response.use(interceptorsResponseSuccess, interceptorsResponseError);
620
713
  return () => {
621
- t.interceptors.request.eject(E), t.interceptors.response.eject(O);
714
+ axiosInstance.interceptors.request.eject(interceptorReq);
715
+ axiosInstance.interceptors.response.eject(interceptorRes);
622
716
  };
623
- }, [l, p, u, y]);
624
- const T = (E) => {
625
- d && F.warning("[FetcherProvider] runPendingRequest", { isSuccess: E }), ee = !1;
626
- for (const O of _e)
627
- O(E);
628
- _e = [];
629
- }, h = (E, O) => (g) => {
630
- d && F.info("[FetcherProvider] Request add pending queue", { originConfig: g }), _e.push((x) => {
631
- x ? (g.pendingRequest = !0, E(t(g))) : O(new K({
632
- message: S(401),
633
- code: "UNAUTHORIZED",
634
- path: "AxiosClientProvider.pushPendingRequestQueues"
635
- }));
717
+ }, [getTokens, refreshTokens, updateTokens, forceLogout]);
718
+ const runPendingRequest = (isSuccess) => {
719
+ if (isDebug) u.warning("[FetcherProvider] runPendingRequest", { isSuccess });
720
+ isTokenRefreshing = false;
721
+ for (const cb of pendingRequestQueues) {
722
+ cb(isSuccess);
723
+ }
724
+ pendingRequestQueues = [];
725
+ };
726
+ const pushPendingRequestQueues = (resolve, reject) => {
727
+ return (originConfig) => {
728
+ if (isDebug) u.info("[FetcherProvider] Request add pending queue", { originConfig });
729
+ pendingRequestQueues.push((isTokenRefreshOK) => {
730
+ if (isTokenRefreshOK) {
731
+ originConfig.pendingRequest = true;
732
+ resolve(axiosInstance(originConfig));
733
+ } else {
734
+ reject(new FetcherException({
735
+ message: "Please login before continuing",
736
+ code: "UNAUTHORIZED",
737
+ path: "AxiosClientProvider.pushPendingRequestQueues"
738
+ }));
739
+ }
740
+ });
741
+ };
742
+ };
743
+ const interceptorsRequest = (originConfig) => {
744
+ return new Promise((resolve, reject) => {
745
+ var _a, _b;
746
+ originConfig.headers["Accept-Language"] = locale;
747
+ const accessTokens = (_a = getTokens()) == null ? void 0 : _a.accessToken;
748
+ const forceGuest = (_b = originConfig.fetchOptions) == null ? void 0 : _b.forceGuest;
749
+ if (!forceGuest && accessTokens) {
750
+ originConfig.headers["Authorization"] = [authorizationPrefix, accessTokens].filter((str) => str).join(" ");
751
+ }
752
+ const isRefreshTokenAPI = originConfig && checkIsRefreshTokenRequest ? checkIsRefreshTokenRequest(originConfig) : false;
753
+ if (!isRefreshTokenAPI && isTokenRefreshing) {
754
+ pushPendingRequestQueues(resolve, reject)(originConfig);
755
+ reject(new AxiosCancelException({
756
+ message: "Token refreshing, so request save queues not send",
757
+ code: "REFRESHING_TOKEN"
758
+ }));
759
+ return;
760
+ }
761
+ resolve(originConfig);
636
762
  });
637
- }, R = (E) => new Promise((O, g) => {
638
- var j, V;
639
- E.headers["Accept-Language"] = n;
640
- const x = (j = l()) == null ? void 0 : j.accessToken;
641
- if (!((V = E.fetchOptions) == null ? void 0 : V.forceGuest) && x && (E.headers.Authorization = [i, x].filter((H) => H).join(" ")), !(E && o ? o(E) : !1) && ee) {
642
- h(O, g)(E), g(new fn({
643
- message: "Token refreshing, so request save queues not send",
644
- code: "REFRESHING_TOKEN"
645
- }));
646
- return;
763
+ };
764
+ const interceptorsResponseSuccess = (response) => {
765
+ if (isDebug) u.info("[FetcherProvider] interceptorsResponseSuccess", { response });
766
+ return response;
767
+ };
768
+ const interceptorsResponseError = (axiosError) => {
769
+ const response = axiosError.response;
770
+ const originalConfig = axiosError.config;
771
+ const status = axiosError.status;
772
+ const responseFirstError = getResponseFormatError(axiosError);
773
+ if (isDebug) u.warning("[FetcherProvider] interceptorsResponseError", { status, responseFirstError });
774
+ if (onError) {
775
+ onError(responseFirstError);
647
776
  }
648
- O(E);
649
- }), m = (E) => (d && F.info("[FetcherProvider] interceptorsResponseSuccess", { response: E }), E), S = (E) => {
650
- const O = (c == null ? void 0 : c[n]) || Ge[n] || Ge["en-US"];
651
- return (O == null ? void 0 : O[E]) || `Error: ${E}`;
652
- }, A = (E) => {
653
- const O = E.response, g = E.config, x = E.status, N = r(O);
654
- d && F.warning("[FetcherProvider] interceptorsResponseError", { status: x, responseFirstError: N }), s && s(N);
655
- const B = g && o ? o(g) : !1;
656
- if (O && g && (x === 401 || N.code === "UNAUTHENTICATED")) {
657
- const j = l();
658
- return d && F.warning("[FetcherProvider] enter refresh token flow", { refreshToken: j == null ? void 0 : j.refreshToken }), Ue(j == null ? void 0 : j.refreshToken) || B || g.pendingRequest ? (ee = !1, d && F.warning("[FetcherProvider] no refreshToken/refreshAPI|pendingRequest fail, force logout"), y(), Promise.reject(new K(N))) : (ee || (ee = !0, d && F.warning("[FetcherProvider] refreshTokens"), p().then(() => {
659
- d && F.info("[FetcherProvider] refreshTokens success"), T(!0);
660
- }).catch(() => {
661
- d && F.danger("[FetcherProvider] refreshTokens fail"), T(!1);
662
- })), new Promise((V, H) => {
663
- h(V, H)(g);
664
- }));
777
+ const isRefresh = originalConfig && checkIsRefreshTokenRequest ? checkIsRefreshTokenRequest(originalConfig) : false;
778
+ if (response && originalConfig) {
779
+ if (status === 401 || responseFirstError.code === "UNAUTHENTICATED") {
780
+ const tokens = getTokens();
781
+ if (isDebug) u.warning("[FetcherProvider] enter refresh token flow", { refreshToken: tokens == null ? void 0 : tokens.refreshToken });
782
+ if (w(tokens == null ? void 0 : tokens.refreshToken) || isRefresh || originalConfig.pendingRequest) {
783
+ isTokenRefreshing = false;
784
+ if (isDebug) u.warning("[FetcherProvider] no refreshToken/refreshAPI|pendingRequest fail, force logout");
785
+ forceLogout();
786
+ return Promise.reject(new FetcherException(responseFirstError));
787
+ }
788
+ if (!isTokenRefreshing) {
789
+ isTokenRefreshing = true;
790
+ if (isDebug) u.warning("[FetcherProvider] refreshTokens");
791
+ refreshTokens().then(() => {
792
+ if (isDebug) u.info("[FetcherProvider] refreshTokens success");
793
+ runPendingRequest(true);
794
+ }).catch(() => {
795
+ if (isDebug) u.danger("[FetcherProvider] refreshTokens fail");
796
+ runPendingRequest(false);
797
+ });
798
+ }
799
+ return new Promise((resolve, reject) => {
800
+ pushPendingRequestQueues(resolve, reject)(originalConfig);
801
+ });
802
+ }
665
803
  }
666
- return Promise.reject(new K(N));
804
+ return Promise.reject(new FetcherException(responseFirstError));
667
805
  };
668
- return /* @__PURE__ */ mt.jsx(
669
- pn.Provider,
806
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
807
+ AxiosClientContext.Provider,
670
808
  {
671
- value: t,
672
- children: e
809
+ value: axiosInstance,
810
+ children
673
811
  }
674
812
  );
675
813
  };
676
- function Et(e, t) {
677
- return function() {
678
- return e.apply(t, arguments);
814
+ function bind(fn, thisArg) {
815
+ return function wrap() {
816
+ return fn.apply(thisArg, arguments);
679
817
  };
680
818
  }
681
- const { toString: hn } = Object.prototype, { getPrototypeOf: De } = Object, { iterator: me, toStringTag: bt } = Symbol, Re = /* @__PURE__ */ ((e) => (t) => {
682
- const n = hn.call(t);
683
- return e[n] || (e[n] = n.slice(8, -1).toLowerCase());
684
- })(/* @__PURE__ */ Object.create(null)), D = (e) => (e = e.toLowerCase(), (t) => Re(t) === e), Ee = (e) => (t) => typeof t === e, { isArray: X } = Array, ne = Ee("undefined");
685
- function mn(e) {
686
- return e !== null && !ne(e) && e.constructor !== null && !ne(e.constructor) && L(e.constructor.isBuffer) && e.constructor.isBuffer(e);
819
+ const { toString } = Object.prototype;
820
+ const { getPrototypeOf } = Object;
821
+ const { iterator, toStringTag } = Symbol;
822
+ const kindOf = /* @__PURE__ */ ((cache) => (thing) => {
823
+ const str = toString.call(thing);
824
+ return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
825
+ })(/* @__PURE__ */ Object.create(null));
826
+ const kindOfTest = (type) => {
827
+ type = type.toLowerCase();
828
+ return (thing) => kindOf(thing) === type;
829
+ };
830
+ const typeOfTest = (type) => (thing) => typeof thing === type;
831
+ const { isArray } = Array;
832
+ const isUndefined = typeOfTest("undefined");
833
+ function isBuffer(val) {
834
+ return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
687
835
  }
688
- const yt = D("ArrayBuffer");
689
- function Rn(e) {
690
- let t;
691
- return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? t = ArrayBuffer.isView(e) : t = e && e.buffer && yt(e.buffer), t;
836
+ const isArrayBuffer = kindOfTest("ArrayBuffer");
837
+ function isArrayBufferView(val) {
838
+ let result;
839
+ if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
840
+ result = ArrayBuffer.isView(val);
841
+ } else {
842
+ result = val && val.buffer && isArrayBuffer(val.buffer);
843
+ }
844
+ return result;
692
845
  }
693
- const En = Ee("string"), L = Ee("function"), wt = Ee("number"), be = (e) => e !== null && typeof e == "object", bn = (e) => e === !0 || e === !1, le = (e) => {
694
- if (Re(e) !== "object")
695
- return !1;
696
- const t = De(e);
697
- return (t === null || t === Object.prototype || Object.getPrototypeOf(t) === null) && !(bt in e) && !(me in e);
698
- }, yn = D("Date"), wn = D("File"), Tn = D("Blob"), gn = D("FileList"), Sn = (e) => be(e) && L(e.pipe), On = (e) => {
699
- let t;
700
- return e && (typeof FormData == "function" && e instanceof FormData || L(e.append) && ((t = Re(e)) === "formdata" || // detect form-data instance
701
- t === "object" && L(e.toString) && e.toString() === "[object FormData]"));
702
- }, An = D("URLSearchParams"), [_n, Pn, xn, Nn] = ["ReadableStream", "Request", "Response", "Headers"].map(D), Cn = (e) => e.trim ? e.trim() : e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
703
- function ie(e, t, { allOwnKeys: n = !1 } = {}) {
704
- if (e === null || typeof e > "u")
846
+ const isString = typeOfTest("string");
847
+ const isFunction = typeOfTest("function");
848
+ const isNumber = typeOfTest("number");
849
+ const isObject = (thing) => thing !== null && typeof thing === "object";
850
+ const isBoolean = (thing) => thing === true || thing === false;
851
+ const isPlainObject = (val) => {
852
+ if (kindOf(val) !== "object") {
853
+ return false;
854
+ }
855
+ const prototype2 = getPrototypeOf(val);
856
+ return (prototype2 === null || prototype2 === Object.prototype || Object.getPrototypeOf(prototype2) === null) && !(toStringTag in val) && !(iterator in val);
857
+ };
858
+ const isDate = kindOfTest("Date");
859
+ const isFile = kindOfTest("File");
860
+ const isBlob = kindOfTest("Blob");
861
+ const isFileList = kindOfTest("FileList");
862
+ const isStream = (val) => isObject(val) && isFunction(val.pipe);
863
+ const isFormData = (thing) => {
864
+ let kind;
865
+ return thing && (typeof FormData === "function" && thing instanceof FormData || isFunction(thing.append) && ((kind = kindOf(thing)) === "formdata" || // detect form-data instance
866
+ kind === "object" && isFunction(thing.toString) && thing.toString() === "[object FormData]"));
867
+ };
868
+ const isURLSearchParams = kindOfTest("URLSearchParams");
869
+ const [isReadableStream, isRequest, isResponse, isHeaders] = ["ReadableStream", "Request", "Response", "Headers"].map(kindOfTest);
870
+ const trim = (str) => str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
871
+ function forEach(obj, fn, { allOwnKeys = false } = {}) {
872
+ if (obj === null || typeof obj === "undefined") {
705
873
  return;
706
- let r, s;
707
- if (typeof e != "object" && (e = [e]), X(e))
708
- for (r = 0, s = e.length; r < s; r++)
709
- t.call(null, e[r], r, e);
710
- else {
711
- const o = n ? Object.getOwnPropertyNames(e) : Object.keys(e), i = o.length;
712
- let c;
713
- for (r = 0; r < i; r++)
714
- c = o[r], t.call(null, e[c], c, e);
874
+ }
875
+ let i2;
876
+ let l2;
877
+ if (typeof obj !== "object") {
878
+ obj = [obj];
879
+ }
880
+ if (isArray(obj)) {
881
+ for (i2 = 0, l2 = obj.length; i2 < l2; i2++) {
882
+ fn.call(null, obj[i2], i2, obj);
883
+ }
884
+ } else {
885
+ const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
886
+ const len = keys.length;
887
+ let key;
888
+ for (i2 = 0; i2 < len; i2++) {
889
+ key = keys[i2];
890
+ fn.call(null, obj[key], key, obj);
891
+ }
715
892
  }
716
893
  }
717
- function Tt(e, t) {
718
- t = t.toLowerCase();
719
- const n = Object.keys(e);
720
- let r = n.length, s;
721
- for (; r-- > 0; )
722
- if (s = n[r], t === s.toLowerCase())
723
- return s;
894
+ function findKey(obj, key) {
895
+ key = key.toLowerCase();
896
+ const keys = Object.keys(obj);
897
+ let i2 = keys.length;
898
+ let _key;
899
+ while (i2-- > 0) {
900
+ _key = keys[i2];
901
+ if (key === _key.toLowerCase()) {
902
+ return _key;
903
+ }
904
+ }
724
905
  return null;
725
906
  }
726
- const z = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global, gt = (e) => !ne(e) && e !== z;
727
- function Ce() {
728
- const { caseless: e } = gt(this) && this || {}, t = {}, n = (r, s) => {
729
- const o = e && Tt(t, s) || s;
730
- le(t[o]) && le(r) ? t[o] = Ce(t[o], r) : le(r) ? t[o] = Ce({}, r) : X(r) ? t[o] = r.slice() : t[o] = r;
907
+ const _global = (() => {
908
+ if (typeof globalThis !== "undefined") return globalThis;
909
+ return typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : global;
910
+ })();
911
+ const isContextDefined = (context) => !isUndefined(context) && context !== _global;
912
+ function merge() {
913
+ const { caseless } = isContextDefined(this) && this || {};
914
+ const result = {};
915
+ const assignValue = (val, key) => {
916
+ const targetKey = caseless && findKey(result, key) || key;
917
+ if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
918
+ result[targetKey] = merge(result[targetKey], val);
919
+ } else if (isPlainObject(val)) {
920
+ result[targetKey] = merge({}, val);
921
+ } else if (isArray(val)) {
922
+ result[targetKey] = val.slice();
923
+ } else {
924
+ result[targetKey] = val;
925
+ }
731
926
  };
732
- for (let r = 0, s = arguments.length; r < s; r++)
733
- arguments[r] && ie(arguments[r], n);
734
- return t;
927
+ for (let i2 = 0, l2 = arguments.length; i2 < l2; i2++) {
928
+ arguments[i2] && forEach(arguments[i2], assignValue);
929
+ }
930
+ return result;
735
931
  }
736
- const kn = (e, t, n, { allOwnKeys: r } = {}) => (ie(t, (s, o) => {
737
- n && L(s) ? e[o] = Et(s, n) : e[o] = s;
738
- }, { allOwnKeys: r }), e), vn = (e) => (e.charCodeAt(0) === 65279 && (e = e.slice(1)), e), Fn = (e, t, n, r) => {
739
- e.prototype = Object.create(t.prototype, r), e.prototype.constructor = e, Object.defineProperty(e, "super", {
740
- value: t.prototype
741
- }), n && Object.assign(e.prototype, n);
742
- }, jn = (e, t, n, r) => {
743
- let s, o, i;
744
- const c = {};
745
- if (t = t || {}, e == null) return t;
932
+ const extend = (a2, b, thisArg, { allOwnKeys } = {}) => {
933
+ forEach(b, (val, key) => {
934
+ if (thisArg && isFunction(val)) {
935
+ a2[key] = bind(val, thisArg);
936
+ } else {
937
+ a2[key] = val;
938
+ }
939
+ }, { allOwnKeys });
940
+ return a2;
941
+ };
942
+ const stripBOM = (content) => {
943
+ if (content.charCodeAt(0) === 65279) {
944
+ content = content.slice(1);
945
+ }
946
+ return content;
947
+ };
948
+ const inherits = (constructor, superConstructor, props, descriptors2) => {
949
+ constructor.prototype = Object.create(superConstructor.prototype, descriptors2);
950
+ constructor.prototype.constructor = constructor;
951
+ Object.defineProperty(constructor, "super", {
952
+ value: superConstructor.prototype
953
+ });
954
+ props && Object.assign(constructor.prototype, props);
955
+ };
956
+ const toFlatObject = (sourceObj, destObj, filter2, propFilter) => {
957
+ let props;
958
+ let i2;
959
+ let prop;
960
+ const merged = {};
961
+ destObj = destObj || {};
962
+ if (sourceObj == null) return destObj;
746
963
  do {
747
- for (s = Object.getOwnPropertyNames(e), o = s.length; o-- > 0; )
748
- i = s[o], (!r || r(i, e, t)) && !c[i] && (t[i] = e[i], c[i] = !0);
749
- e = n !== !1 && De(e);
750
- } while (e && (!n || n(e, t)) && e !== Object.prototype);
751
- return t;
752
- }, Ln = (e, t, n) => {
753
- e = String(e), (n === void 0 || n > e.length) && (n = e.length), n -= t.length;
754
- const r = e.indexOf(t, n);
755
- return r !== -1 && r === n;
756
- }, Un = (e) => {
757
- if (!e) return null;
758
- if (X(e)) return e;
759
- let t = e.length;
760
- if (!wt(t)) return null;
761
- const n = new Array(t);
762
- for (; t-- > 0; )
763
- n[t] = e[t];
764
- return n;
765
- }, Dn = /* @__PURE__ */ ((e) => (t) => e && t instanceof e)(typeof Uint8Array < "u" && De(Uint8Array)), Bn = (e, t) => {
766
- const r = (e && e[me]).call(e);
767
- let s;
768
- for (; (s = r.next()) && !s.done; ) {
769
- const o = s.value;
770
- t.call(e, o[0], o[1]);
771
- }
772
- }, qn = (e, t) => {
773
- let n;
774
- const r = [];
775
- for (; (n = e.exec(t)) !== null; )
776
- r.push(n);
777
- return r;
778
- }, In = D("HTMLFormElement"), $n = (e) => e.toLowerCase().replace(
779
- /[-_\s]([a-z\d])(\w*)/g,
780
- function(n, r, s) {
781
- return r.toUpperCase() + s;
782
- }
783
- ), Ze = (({ hasOwnProperty: e }) => (t, n) => e.call(t, n))(Object.prototype), Mn = D("RegExp"), St = (e, t) => {
784
- const n = Object.getOwnPropertyDescriptors(e), r = {};
785
- ie(n, (s, o) => {
786
- let i;
787
- (i = t(s, o, e)) !== !1 && (r[o] = i || s);
788
- }), Object.defineProperties(e, r);
789
- }, Hn = (e) => {
790
- St(e, (t, n) => {
791
- if (L(e) && ["arguments", "caller", "callee"].indexOf(n) !== -1)
792
- return !1;
793
- const r = e[n];
794
- if (L(r)) {
795
- if (t.enumerable = !1, "writable" in t) {
796
- t.writable = !1;
797
- return;
964
+ props = Object.getOwnPropertyNames(sourceObj);
965
+ i2 = props.length;
966
+ while (i2-- > 0) {
967
+ prop = props[i2];
968
+ if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
969
+ destObj[prop] = sourceObj[prop];
970
+ merged[prop] = true;
798
971
  }
799
- t.set || (t.set = () => {
800
- throw Error("Can not rewrite read-only method '" + n + "'");
801
- });
972
+ }
973
+ sourceObj = filter2 !== false && getPrototypeOf(sourceObj);
974
+ } while (sourceObj && (!filter2 || filter2(sourceObj, destObj)) && sourceObj !== Object.prototype);
975
+ return destObj;
976
+ };
977
+ const endsWith = (str, searchString, position) => {
978
+ str = String(str);
979
+ if (position === void 0 || position > str.length) {
980
+ position = str.length;
981
+ }
982
+ position -= searchString.length;
983
+ const lastIndex = str.indexOf(searchString, position);
984
+ return lastIndex !== -1 && lastIndex === position;
985
+ };
986
+ const toArray = (thing) => {
987
+ if (!thing) return null;
988
+ if (isArray(thing)) return thing;
989
+ let i2 = thing.length;
990
+ if (!isNumber(i2)) return null;
991
+ const arr = new Array(i2);
992
+ while (i2-- > 0) {
993
+ arr[i2] = thing[i2];
994
+ }
995
+ return arr;
996
+ };
997
+ const isTypedArray = /* @__PURE__ */ ((TypedArray) => {
998
+ return (thing) => {
999
+ return TypedArray && thing instanceof TypedArray;
1000
+ };
1001
+ })(typeof Uint8Array !== "undefined" && getPrototypeOf(Uint8Array));
1002
+ const forEachEntry = (obj, fn) => {
1003
+ const generator = obj && obj[iterator];
1004
+ const _iterator = generator.call(obj);
1005
+ let result;
1006
+ while ((result = _iterator.next()) && !result.done) {
1007
+ const pair = result.value;
1008
+ fn.call(obj, pair[0], pair[1]);
1009
+ }
1010
+ };
1011
+ const matchAll = (regExp, str) => {
1012
+ let matches;
1013
+ const arr = [];
1014
+ while ((matches = regExp.exec(str)) !== null) {
1015
+ arr.push(matches);
1016
+ }
1017
+ return arr;
1018
+ };
1019
+ const isHTMLForm = kindOfTest("HTMLFormElement");
1020
+ const toCamelCase = (str) => {
1021
+ return str.toLowerCase().replace(
1022
+ /[-_\s]([a-z\d])(\w*)/g,
1023
+ function replacer(m, p1, p2) {
1024
+ return p1.toUpperCase() + p2;
1025
+ }
1026
+ );
1027
+ };
1028
+ const hasOwnProperty = (({ hasOwnProperty: hasOwnProperty2 }) => (obj, prop) => hasOwnProperty2.call(obj, prop))(Object.prototype);
1029
+ const isRegExp = kindOfTest("RegExp");
1030
+ const reduceDescriptors = (obj, reducer) => {
1031
+ const descriptors2 = Object.getOwnPropertyDescriptors(obj);
1032
+ const reducedDescriptors = {};
1033
+ forEach(descriptors2, (descriptor, name) => {
1034
+ let ret;
1035
+ if ((ret = reducer(descriptor, name, obj)) !== false) {
1036
+ reducedDescriptors[name] = ret || descriptor;
1037
+ }
1038
+ });
1039
+ Object.defineProperties(obj, reducedDescriptors);
1040
+ };
1041
+ const freezeMethods = (obj) => {
1042
+ reduceDescriptors(obj, (descriptor, name) => {
1043
+ if (isFunction(obj) && ["arguments", "caller", "callee"].indexOf(name) !== -1) {
1044
+ return false;
1045
+ }
1046
+ const value = obj[name];
1047
+ if (!isFunction(value)) return;
1048
+ descriptor.enumerable = false;
1049
+ if ("writable" in descriptor) {
1050
+ descriptor.writable = false;
1051
+ return;
1052
+ }
1053
+ if (!descriptor.set) {
1054
+ descriptor.set = () => {
1055
+ throw Error("Can not rewrite read-only method '" + name + "'");
1056
+ };
802
1057
  }
803
1058
  });
804
- }, zn = (e, t) => {
805
- const n = {}, r = (s) => {
806
- s.forEach((o) => {
807
- n[o] = !0;
1059
+ };
1060
+ const toObjectSet = (arrayOrString, delimiter) => {
1061
+ const obj = {};
1062
+ const define = (arr) => {
1063
+ arr.forEach((value) => {
1064
+ obj[value] = true;
808
1065
  });
809
1066
  };
810
- return X(e) ? r(e) : r(String(e).split(t)), n;
811
- }, Jn = () => {
812
- }, Wn = (e, t) => e != null && Number.isFinite(e = +e) ? e : t;
813
- function Vn(e) {
814
- return !!(e && L(e.append) && e[bt] === "FormData" && e[me]);
1067
+ isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
1068
+ return obj;
1069
+ };
1070
+ const noop = () => {
1071
+ };
1072
+ const toFiniteNumber = (value, defaultValue) => {
1073
+ return value != null && Number.isFinite(value = +value) ? value : defaultValue;
1074
+ };
1075
+ function isSpecCompliantForm(thing) {
1076
+ return !!(thing && isFunction(thing.append) && thing[toStringTag] === "FormData" && thing[iterator]);
815
1077
  }
816
- const Yn = (e) => {
817
- const t = new Array(10), n = (r, s) => {
818
- if (be(r)) {
819
- if (t.indexOf(r) >= 0)
1078
+ const toJSONObject = (obj) => {
1079
+ const stack = new Array(10);
1080
+ const visit = (source, i2) => {
1081
+ if (isObject(source)) {
1082
+ if (stack.indexOf(source) >= 0) {
820
1083
  return;
821
- if (!("toJSON" in r)) {
822
- t[s] = r;
823
- const o = X(r) ? [] : {};
824
- return ie(r, (i, c) => {
825
- const d = n(i, s + 1);
826
- !ne(d) && (o[c] = d);
827
- }), t[s] = void 0, o;
1084
+ }
1085
+ if (!("toJSON" in source)) {
1086
+ stack[i2] = source;
1087
+ const target = isArray(source) ? [] : {};
1088
+ forEach(source, (value, key) => {
1089
+ const reducedValue = visit(value, i2 + 1);
1090
+ !isUndefined(reducedValue) && (target[key] = reducedValue);
1091
+ });
1092
+ stack[i2] = void 0;
1093
+ return target;
828
1094
  }
829
1095
  }
830
- return r;
1096
+ return source;
831
1097
  };
832
- return n(e, 0);
833
- }, Kn = D("AsyncFunction"), Xn = (e) => e && (be(e) || L(e)) && L(e.then) && L(e.catch), Ot = ((e, t) => e ? setImmediate : t ? ((n, r) => (z.addEventListener("message", ({ source: s, data: o }) => {
834
- s === z && o === n && r.length && r.shift()();
835
- }, !1), (s) => {
836
- r.push(s), z.postMessage(n, "*");
837
- }))(`axios@${Math.random()}`, []) : (n) => setTimeout(n))(
838
- typeof setImmediate == "function",
839
- L(z.postMessage)
840
- ), Gn = typeof queueMicrotask < "u" ? queueMicrotask.bind(z) : typeof process < "u" && process.nextTick || Ot, Zn = (e) => e != null && L(e[me]), a = {
841
- isArray: X,
842
- isArrayBuffer: yt,
843
- isBuffer: mn,
844
- isFormData: On,
845
- isArrayBufferView: Rn,
846
- isString: En,
847
- isNumber: wt,
848
- isBoolean: bn,
849
- isObject: be,
850
- isPlainObject: le,
851
- isReadableStream: _n,
852
- isRequest: Pn,
853
- isResponse: xn,
854
- isHeaders: Nn,
855
- isUndefined: ne,
856
- isDate: yn,
857
- isFile: wn,
858
- isBlob: Tn,
859
- isRegExp: Mn,
860
- isFunction: L,
861
- isStream: Sn,
862
- isURLSearchParams: An,
863
- isTypedArray: Dn,
864
- isFileList: gn,
865
- forEach: ie,
866
- merge: Ce,
867
- extend: kn,
868
- trim: Cn,
869
- stripBOM: vn,
870
- inherits: Fn,
871
- toFlatObject: jn,
872
- kindOf: Re,
873
- kindOfTest: D,
874
- endsWith: Ln,
875
- toArray: Un,
876
- forEachEntry: Bn,
877
- matchAll: qn,
878
- isHTMLForm: In,
879
- hasOwnProperty: Ze,
880
- hasOwnProp: Ze,
1098
+ return visit(obj, 0);
1099
+ };
1100
+ const isAsyncFn = kindOfTest("AsyncFunction");
1101
+ const isThenable = (thing) => thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
1102
+ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
1103
+ if (setImmediateSupported) {
1104
+ return setImmediate;
1105
+ }
1106
+ return postMessageSupported ? ((token, callbacks) => {
1107
+ _global.addEventListener("message", ({ source, data }) => {
1108
+ if (source === _global && data === token) {
1109
+ callbacks.length && callbacks.shift()();
1110
+ }
1111
+ }, false);
1112
+ return (cb) => {
1113
+ callbacks.push(cb);
1114
+ _global.postMessage(token, "*");
1115
+ };
1116
+ })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
1117
+ })(
1118
+ typeof setImmediate === "function",
1119
+ isFunction(_global.postMessage)
1120
+ );
1121
+ const asap = typeof queueMicrotask !== "undefined" ? queueMicrotask.bind(_global) : typeof process !== "undefined" && process.nextTick || _setImmediate;
1122
+ const isIterable = (thing) => thing != null && isFunction(thing[iterator]);
1123
+ const utils$1 = {
1124
+ isArray,
1125
+ isArrayBuffer,
1126
+ isBuffer,
1127
+ isFormData,
1128
+ isArrayBufferView,
1129
+ isString,
1130
+ isNumber,
1131
+ isBoolean,
1132
+ isObject,
1133
+ isPlainObject,
1134
+ isReadableStream,
1135
+ isRequest,
1136
+ isResponse,
1137
+ isHeaders,
1138
+ isUndefined,
1139
+ isDate,
1140
+ isFile,
1141
+ isBlob,
1142
+ isRegExp,
1143
+ isFunction,
1144
+ isStream,
1145
+ isURLSearchParams,
1146
+ isTypedArray,
1147
+ isFileList,
1148
+ forEach,
1149
+ merge,
1150
+ extend,
1151
+ trim,
1152
+ stripBOM,
1153
+ inherits,
1154
+ toFlatObject,
1155
+ kindOf,
1156
+ kindOfTest,
1157
+ endsWith,
1158
+ toArray,
1159
+ forEachEntry,
1160
+ matchAll,
1161
+ isHTMLForm,
1162
+ hasOwnProperty,
1163
+ hasOwnProp: hasOwnProperty,
881
1164
  // an alias to avoid ESLint no-prototype-builtins detection
882
- reduceDescriptors: St,
883
- freezeMethods: Hn,
884
- toObjectSet: zn,
885
- toCamelCase: $n,
886
- noop: Jn,
887
- toFiniteNumber: Wn,
888
- findKey: Tt,
889
- global: z,
890
- isContextDefined: gt,
891
- isSpecCompliantForm: Vn,
892
- toJSONObject: Yn,
893
- isAsyncFn: Kn,
894
- isThenable: Xn,
895
- setImmediate: Ot,
896
- asap: Gn,
897
- isIterable: Zn
1165
+ reduceDescriptors,
1166
+ freezeMethods,
1167
+ toObjectSet,
1168
+ toCamelCase,
1169
+ noop,
1170
+ toFiniteNumber,
1171
+ findKey,
1172
+ global: _global,
1173
+ isContextDefined,
1174
+ isSpecCompliantForm,
1175
+ toJSONObject,
1176
+ isAsyncFn,
1177
+ isThenable,
1178
+ setImmediate: _setImmediate,
1179
+ asap,
1180
+ isIterable
898
1181
  };
899
- function b(e, t, n, r, s) {
900
- Error.call(this), Error.captureStackTrace ? Error.captureStackTrace(this, this.constructor) : this.stack = new Error().stack, this.message = e, this.name = "AxiosError", t && (this.code = t), n && (this.config = n), r && (this.request = r), s && (this.response = s, this.status = s.status ? s.status : null);
1182
+ function AxiosError$1(message, code, config, request, response) {
1183
+ Error.call(this);
1184
+ if (Error.captureStackTrace) {
1185
+ Error.captureStackTrace(this, this.constructor);
1186
+ } else {
1187
+ this.stack = new Error().stack;
1188
+ }
1189
+ this.message = message;
1190
+ this.name = "AxiosError";
1191
+ code && (this.code = code);
1192
+ config && (this.config = config);
1193
+ request && (this.request = request);
1194
+ if (response) {
1195
+ this.response = response;
1196
+ this.status = response.status ? response.status : null;
1197
+ }
901
1198
  }
902
- a.inherits(b, Error, {
903
- toJSON: function() {
1199
+ utils$1.inherits(AxiosError$1, Error, {
1200
+ toJSON: function toJSON() {
904
1201
  return {
905
1202
  // Standard
906
1203
  message: this.message,
@@ -914,13 +1211,14 @@ a.inherits(b, Error, {
914
1211
  columnNumber: this.columnNumber,
915
1212
  stack: this.stack,
916
1213
  // Axios
917
- config: a.toJSONObject(this.config),
1214
+ config: utils$1.toJSONObject(this.config),
918
1215
  code: this.code,
919
1216
  status: this.status
920
1217
  };
921
1218
  }
922
1219
  });
923
- const At = b.prototype, _t = {};
1220
+ const prototype$1 = AxiosError$1.prototype;
1221
+ const descriptors = {};
924
1222
  [
925
1223
  "ERR_BAD_OPTION_VALUE",
926
1224
  "ERR_BAD_OPTION",
@@ -935,98 +1233,136 @@ const At = b.prototype, _t = {};
935
1233
  "ERR_NOT_SUPPORT",
936
1234
  "ERR_INVALID_URL"
937
1235
  // eslint-disable-next-line func-names
938
- ].forEach((e) => {
939
- _t[e] = { value: e };
1236
+ ].forEach((code) => {
1237
+ descriptors[code] = { value: code };
940
1238
  });
941
- Object.defineProperties(b, _t);
942
- Object.defineProperty(At, "isAxiosError", { value: !0 });
943
- b.from = (e, t, n, r, s, o) => {
944
- const i = Object.create(At);
945
- return a.toFlatObject(e, i, function(d) {
946
- return d !== Error.prototype;
947
- }, (c) => c !== "isAxiosError"), b.call(i, e.message, t, n, r, s), i.cause = e, i.name = e.name, o && Object.assign(i, o), i;
1239
+ Object.defineProperties(AxiosError$1, descriptors);
1240
+ Object.defineProperty(prototype$1, "isAxiosError", { value: true });
1241
+ AxiosError$1.from = (error, code, config, request, response, customProps) => {
1242
+ const axiosError = Object.create(prototype$1);
1243
+ utils$1.toFlatObject(error, axiosError, function filter2(obj) {
1244
+ return obj !== Error.prototype;
1245
+ }, (prop) => {
1246
+ return prop !== "isAxiosError";
1247
+ });
1248
+ AxiosError$1.call(axiosError, error.message, code, config, request, response);
1249
+ axiosError.cause = error;
1250
+ axiosError.name = error.name;
1251
+ customProps && Object.assign(axiosError, customProps);
1252
+ return axiosError;
948
1253
  };
949
- const Qn = null;
950
- function ke(e) {
951
- return a.isPlainObject(e) || a.isArray(e);
1254
+ const httpAdapter = null;
1255
+ function isVisitable(thing) {
1256
+ return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
952
1257
  }
953
- function Pt(e) {
954
- return a.endsWith(e, "[]") ? e.slice(0, -2) : e;
1258
+ function removeBrackets(key) {
1259
+ return utils$1.endsWith(key, "[]") ? key.slice(0, -2) : key;
955
1260
  }
956
- function Qe(e, t, n) {
957
- return e ? e.concat(t).map(function(s, o) {
958
- return s = Pt(s), !n && o ? "[" + s + "]" : s;
959
- }).join(n ? "." : "") : t;
1261
+ function renderKey(path, key, dots) {
1262
+ if (!path) return key;
1263
+ return path.concat(key).map(function each(token, i2) {
1264
+ token = removeBrackets(token);
1265
+ return !dots && i2 ? "[" + token + "]" : token;
1266
+ }).join(dots ? "." : "");
960
1267
  }
961
- function er(e) {
962
- return a.isArray(e) && !e.some(ke);
1268
+ function isFlatArray(arr) {
1269
+ return utils$1.isArray(arr) && !arr.some(isVisitable);
963
1270
  }
964
- const tr = a.toFlatObject(a, {}, null, function(t) {
965
- return /^is[A-Z]/.test(t);
1271
+ const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
1272
+ return /^is[A-Z]/.test(prop);
966
1273
  });
967
- function ye(e, t, n) {
968
- if (!a.isObject(e))
1274
+ function toFormData$1(obj, formData, options) {
1275
+ if (!utils$1.isObject(obj)) {
969
1276
  throw new TypeError("target must be an object");
970
- t = t || new FormData(), n = a.toFlatObject(n, {
971
- metaTokens: !0,
972
- dots: !1,
973
- indexes: !1
974
- }, !1, function(R, m) {
975
- return !a.isUndefined(m[R]);
1277
+ }
1278
+ formData = formData || new FormData();
1279
+ options = utils$1.toFlatObject(options, {
1280
+ metaTokens: true,
1281
+ dots: false,
1282
+ indexes: false
1283
+ }, false, function defined(option, source) {
1284
+ return !utils$1.isUndefined(source[option]);
976
1285
  });
977
- const r = n.metaTokens, s = n.visitor || u, o = n.dots, i = n.indexes, d = (n.Blob || typeof Blob < "u" && Blob) && a.isSpecCompliantForm(t);
978
- if (!a.isFunction(s))
1286
+ const metaTokens = options.metaTokens;
1287
+ const visitor = options.visitor || defaultVisitor;
1288
+ const dots = options.dots;
1289
+ const indexes = options.indexes;
1290
+ const _Blob = options.Blob || typeof Blob !== "undefined" && Blob;
1291
+ const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
1292
+ if (!utils$1.isFunction(visitor)) {
979
1293
  throw new TypeError("visitor must be a function");
980
- function l(h) {
981
- if (h === null) return "";
982
- if (a.isDate(h))
983
- return h.toISOString();
984
- if (!d && a.isBlob(h))
985
- throw new b("Blob is not supported. Use a Buffer instead.");
986
- return a.isArrayBuffer(h) || a.isTypedArray(h) ? d && typeof Blob == "function" ? new Blob([h]) : Buffer.from(h) : h;
987
- }
988
- function u(h, R, m) {
989
- let S = h;
990
- if (h && !m && typeof h == "object") {
991
- if (a.endsWith(R, "{}"))
992
- R = r ? R : R.slice(0, -2), h = JSON.stringify(h);
993
- else if (a.isArray(h) && er(h) || (a.isFileList(h) || a.endsWith(R, "[]")) && (S = a.toArray(h)))
994
- return R = Pt(R), S.forEach(function(E, O) {
995
- !(a.isUndefined(E) || E === null) && t.append(
1294
+ }
1295
+ function convertValue(value) {
1296
+ if (value === null) return "";
1297
+ if (utils$1.isDate(value)) {
1298
+ return value.toISOString();
1299
+ }
1300
+ if (!useBlob && utils$1.isBlob(value)) {
1301
+ throw new AxiosError$1("Blob is not supported. Use a Buffer instead.");
1302
+ }
1303
+ if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
1304
+ return useBlob && typeof Blob === "function" ? new Blob([value]) : Buffer.from(value);
1305
+ }
1306
+ return value;
1307
+ }
1308
+ function defaultVisitor(value, key, path) {
1309
+ let arr = value;
1310
+ if (value && !path && typeof value === "object") {
1311
+ if (utils$1.endsWith(key, "{}")) {
1312
+ key = metaTokens ? key : key.slice(0, -2);
1313
+ value = JSON.stringify(value);
1314
+ } else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, "[]")) && (arr = utils$1.toArray(value))) {
1315
+ key = removeBrackets(key);
1316
+ arr.forEach(function each(el, index) {
1317
+ !(utils$1.isUndefined(el) || el === null) && formData.append(
996
1318
  // eslint-disable-next-line no-nested-ternary
997
- i === !0 ? Qe([R], O, o) : i === null ? R : R + "[]",
998
- l(E)
1319
+ indexes === true ? renderKey([key], index, dots) : indexes === null ? key : key + "[]",
1320
+ convertValue(el)
999
1321
  );
1000
- }), !1;
1322
+ });
1323
+ return false;
1324
+ }
1001
1325
  }
1002
- return ke(h) ? !0 : (t.append(Qe(m, R, o), l(h)), !1);
1003
- }
1004
- const p = [], y = Object.assign(tr, {
1005
- defaultVisitor: u,
1006
- convertValue: l,
1007
- isVisitable: ke
1326
+ if (isVisitable(value)) {
1327
+ return true;
1328
+ }
1329
+ formData.append(renderKey(path, key, dots), convertValue(value));
1330
+ return false;
1331
+ }
1332
+ const stack = [];
1333
+ const exposedHelpers = Object.assign(predicates, {
1334
+ defaultVisitor,
1335
+ convertValue,
1336
+ isVisitable
1008
1337
  });
1009
- function T(h, R) {
1010
- if (!a.isUndefined(h)) {
1011
- if (p.indexOf(h) !== -1)
1012
- throw Error("Circular reference detected in " + R.join("."));
1013
- p.push(h), a.forEach(h, function(S, A) {
1014
- (!(a.isUndefined(S) || S === null) && s.call(
1015
- t,
1016
- S,
1017
- a.isString(A) ? A.trim() : A,
1018
- R,
1019
- y
1020
- )) === !0 && T(S, R ? R.concat(A) : [A]);
1021
- }), p.pop();
1022
- }
1023
- }
1024
- if (!a.isObject(e))
1338
+ function build(value, path) {
1339
+ if (utils$1.isUndefined(value)) return;
1340
+ if (stack.indexOf(value) !== -1) {
1341
+ throw Error("Circular reference detected in " + path.join("."));
1342
+ }
1343
+ stack.push(value);
1344
+ utils$1.forEach(value, function each(el, key) {
1345
+ const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
1346
+ formData,
1347
+ el,
1348
+ utils$1.isString(key) ? key.trim() : key,
1349
+ path,
1350
+ exposedHelpers
1351
+ );
1352
+ if (result === true) {
1353
+ build(el, path ? path.concat(key) : [key]);
1354
+ }
1355
+ });
1356
+ stack.pop();
1357
+ }
1358
+ if (!utils$1.isObject(obj)) {
1025
1359
  throw new TypeError("data must be an object");
1026
- return T(e), t;
1360
+ }
1361
+ build(obj);
1362
+ return formData;
1027
1363
  }
1028
- function et(e) {
1029
- const t = {
1364
+ function encode$1(str) {
1365
+ const charMap = {
1030
1366
  "!": "%21",
1031
1367
  "'": "%27",
1032
1368
  "(": "%28",
@@ -1035,44 +1371,56 @@ function et(e) {
1035
1371
  "%20": "+",
1036
1372
  "%00": "\0"
1037
1373
  };
1038
- return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g, function(r) {
1039
- return t[r];
1374
+ return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
1375
+ return charMap[match];
1040
1376
  });
1041
1377
  }
1042
- function Be(e, t) {
1043
- this._pairs = [], e && ye(e, this, t);
1378
+ function AxiosURLSearchParams(params, options) {
1379
+ this._pairs = [];
1380
+ params && toFormData$1(params, this, options);
1044
1381
  }
1045
- const xt = Be.prototype;
1046
- xt.append = function(t, n) {
1047
- this._pairs.push([t, n]);
1382
+ const prototype = AxiosURLSearchParams.prototype;
1383
+ prototype.append = function append(name, value) {
1384
+ this._pairs.push([name, value]);
1048
1385
  };
1049
- xt.toString = function(t) {
1050
- const n = t ? function(r) {
1051
- return t.call(this, r, et);
1052
- } : et;
1053
- return this._pairs.map(function(s) {
1054
- return n(s[0]) + "=" + n(s[1]);
1386
+ prototype.toString = function toString2(encoder) {
1387
+ const _encode = encoder ? function(value) {
1388
+ return encoder.call(this, value, encode$1);
1389
+ } : encode$1;
1390
+ return this._pairs.map(function each(pair) {
1391
+ return _encode(pair[0]) + "=" + _encode(pair[1]);
1055
1392
  }, "").join("&");
1056
1393
  };
1057
- function nr(e) {
1058
- return encodeURIComponent(e).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
1394
+ function encode(val) {
1395
+ return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
1059
1396
  }
1060
- function Nt(e, t, n) {
1061
- if (!t)
1062
- return e;
1063
- const r = n && n.encode || nr;
1064
- a.isFunction(n) && (n = {
1065
- serialize: n
1066
- });
1067
- const s = n && n.serialize;
1068
- let o;
1069
- if (s ? o = s(t, n) : o = a.isURLSearchParams(t) ? t.toString() : new Be(t, n).toString(r), o) {
1070
- const i = e.indexOf("#");
1071
- i !== -1 && (e = e.slice(0, i)), e += (e.indexOf("?") === -1 ? "?" : "&") + o;
1397
+ function buildURL(url, params, options) {
1398
+ if (!params) {
1399
+ return url;
1400
+ }
1401
+ const _encode = options && options.encode || encode;
1402
+ if (utils$1.isFunction(options)) {
1403
+ options = {
1404
+ serialize: options
1405
+ };
1072
1406
  }
1073
- return e;
1407
+ const serializeFn = options && options.serialize;
1408
+ let serializedParams;
1409
+ if (serializeFn) {
1410
+ serializedParams = serializeFn(params, options);
1411
+ } else {
1412
+ serializedParams = utils$1.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, options).toString(_encode);
1413
+ }
1414
+ if (serializedParams) {
1415
+ const hashmarkIndex = url.indexOf("#");
1416
+ if (hashmarkIndex !== -1) {
1417
+ url = url.slice(0, hashmarkIndex);
1418
+ }
1419
+ url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
1420
+ }
1421
+ return url;
1074
1422
  }
1075
- class tt {
1423
+ class InterceptorManager {
1076
1424
  constructor() {
1077
1425
  this.handlers = [];
1078
1426
  }
@@ -1084,13 +1432,14 @@ class tt {
1084
1432
  *
1085
1433
  * @return {Number} An ID used to remove interceptor later
1086
1434
  */
1087
- use(t, n, r) {
1088
- return this.handlers.push({
1089
- fulfilled: t,
1090
- rejected: n,
1091
- synchronous: r ? r.synchronous : !1,
1092
- runWhen: r ? r.runWhen : null
1093
- }), this.handlers.length - 1;
1435
+ use(fulfilled, rejected, options) {
1436
+ this.handlers.push({
1437
+ fulfilled,
1438
+ rejected,
1439
+ synchronous: options ? options.synchronous : false,
1440
+ runWhen: options ? options.runWhen : null
1441
+ });
1442
+ return this.handlers.length - 1;
1094
1443
  }
1095
1444
  /**
1096
1445
  * Remove an interceptor from the stack
@@ -1099,8 +1448,10 @@ class tt {
1099
1448
  *
1100
1449
  * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
1101
1450
  */
1102
- eject(t) {
1103
- this.handlers[t] && (this.handlers[t] = null);
1451
+ eject(id) {
1452
+ if (this.handlers[id]) {
1453
+ this.handlers[id] = null;
1454
+ }
1104
1455
  }
1105
1456
  /**
1106
1457
  * Clear all interceptors from the stack
@@ -1108,7 +1459,9 @@ class tt {
1108
1459
  * @returns {void}
1109
1460
  */
1110
1461
  clear() {
1111
- this.handlers && (this.handlers = []);
1462
+ if (this.handlers) {
1463
+ this.handlers = [];
1464
+ }
1112
1465
  }
1113
1466
  /**
1114
1467
  * Iterate over all the registered interceptors
@@ -1120,122 +1473,191 @@ class tt {
1120
1473
  *
1121
1474
  * @returns {void}
1122
1475
  */
1123
- forEach(t) {
1124
- a.forEach(this.handlers, function(r) {
1125
- r !== null && t(r);
1476
+ forEach(fn) {
1477
+ utils$1.forEach(this.handlers, function forEachHandler(h) {
1478
+ if (h !== null) {
1479
+ fn(h);
1480
+ }
1126
1481
  });
1127
1482
  }
1128
1483
  }
1129
- const Ct = {
1130
- silentJSONParsing: !0,
1131
- forcedJSONParsing: !0,
1132
- clarifyTimeoutError: !1
1133
- }, rr = typeof URLSearchParams < "u" ? URLSearchParams : Be, sr = typeof FormData < "u" ? FormData : null, or = typeof Blob < "u" ? Blob : null, ir = {
1134
- isBrowser: !0,
1484
+ const transitionalDefaults = {
1485
+ silentJSONParsing: true,
1486
+ forcedJSONParsing: true,
1487
+ clarifyTimeoutError: false
1488
+ };
1489
+ const URLSearchParams$1 = typeof URLSearchParams !== "undefined" ? URLSearchParams : AxiosURLSearchParams;
1490
+ const FormData$1 = typeof FormData !== "undefined" ? FormData : null;
1491
+ const Blob$1 = typeof Blob !== "undefined" ? Blob : null;
1492
+ const platform$1 = {
1493
+ isBrowser: true,
1135
1494
  classes: {
1136
- URLSearchParams: rr,
1137
- FormData: sr,
1138
- Blob: or
1495
+ URLSearchParams: URLSearchParams$1,
1496
+ FormData: FormData$1,
1497
+ Blob: Blob$1
1139
1498
  },
1140
1499
  protocols: ["http", "https", "file", "blob", "url", "data"]
1141
- }, qe = typeof window < "u" && typeof document < "u", ve = typeof navigator == "object" && navigator || void 0, ar = qe && (!ve || ["ReactNative", "NativeScript", "NS"].indexOf(ve.product) < 0), cr = typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef
1142
- self instanceof WorkerGlobalScope && typeof self.importScripts == "function", lr = qe && window.location.href || "http://localhost", ur = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1500
+ };
1501
+ const hasBrowserEnv = typeof window !== "undefined" && typeof document !== "undefined";
1502
+ const _navigator = typeof navigator === "object" && navigator || void 0;
1503
+ const hasStandardBrowserEnv = hasBrowserEnv && (!_navigator || ["ReactNative", "NativeScript", "NS"].indexOf(_navigator.product) < 0);
1504
+ const hasStandardBrowserWebWorkerEnv = (() => {
1505
+ return typeof WorkerGlobalScope !== "undefined" && // eslint-disable-next-line no-undef
1506
+ self instanceof WorkerGlobalScope && typeof self.importScripts === "function";
1507
+ })();
1508
+ const origin = hasBrowserEnv && window.location.href || "http://localhost";
1509
+ const utils = /* @__PURE__ */ Object.freeze({
1143
1510
  __proto__: null,
1144
- hasBrowserEnv: qe,
1145
- hasStandardBrowserEnv: ar,
1146
- hasStandardBrowserWebWorkerEnv: cr,
1147
- navigator: ve,
1148
- origin: lr
1149
- }, Symbol.toStringTag, { value: "Module" })), v = {
1150
- ...ur,
1151
- ...ir
1511
+ hasBrowserEnv,
1512
+ hasStandardBrowserEnv,
1513
+ hasStandardBrowserWebWorkerEnv,
1514
+ navigator: _navigator,
1515
+ origin
1516
+ });
1517
+ const platform = {
1518
+ ...utils,
1519
+ ...platform$1
1152
1520
  };
1153
- function fr(e, t) {
1154
- return ye(e, new v.classes.URLSearchParams(), Object.assign({
1155
- visitor: function(n, r, s, o) {
1156
- return v.isNode && a.isBuffer(n) ? (this.append(r, n.toString("base64")), !1) : o.defaultVisitor.apply(this, arguments);
1521
+ function toURLEncodedForm(data, options) {
1522
+ return toFormData$1(data, new platform.classes.URLSearchParams(), Object.assign({
1523
+ visitor: function(value, key, path, helpers) {
1524
+ if (platform.isNode && utils$1.isBuffer(value)) {
1525
+ this.append(key, value.toString("base64"));
1526
+ return false;
1527
+ }
1528
+ return helpers.defaultVisitor.apply(this, arguments);
1157
1529
  }
1158
- }, t));
1530
+ }, options));
1159
1531
  }
1160
- function dr(e) {
1161
- return a.matchAll(/\w+|\[(\w*)]/g, e).map((t) => t[0] === "[]" ? "" : t[1] || t[0]);
1532
+ function parsePropPath(name) {
1533
+ return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
1534
+ return match[0] === "[]" ? "" : match[1] || match[0];
1535
+ });
1162
1536
  }
1163
- function pr(e) {
1164
- const t = {}, n = Object.keys(e);
1165
- let r;
1166
- const s = n.length;
1167
- let o;
1168
- for (r = 0; r < s; r++)
1169
- o = n[r], t[o] = e[o];
1170
- return t;
1537
+ function arrayToObject(arr) {
1538
+ const obj = {};
1539
+ const keys = Object.keys(arr);
1540
+ let i2;
1541
+ const len = keys.length;
1542
+ let key;
1543
+ for (i2 = 0; i2 < len; i2++) {
1544
+ key = keys[i2];
1545
+ obj[key] = arr[key];
1546
+ }
1547
+ return obj;
1171
1548
  }
1172
- function kt(e) {
1173
- function t(n, r, s, o) {
1174
- let i = n[o++];
1175
- if (i === "__proto__") return !0;
1176
- const c = Number.isFinite(+i), d = o >= n.length;
1177
- return i = !i && a.isArray(s) ? s.length : i, d ? (a.hasOwnProp(s, i) ? s[i] = [s[i], r] : s[i] = r, !c) : ((!s[i] || !a.isObject(s[i])) && (s[i] = []), t(n, r, s[i], o) && a.isArray(s[i]) && (s[i] = pr(s[i])), !c);
1178
- }
1179
- if (a.isFormData(e) && a.isFunction(e.entries)) {
1180
- const n = {};
1181
- return a.forEachEntry(e, (r, s) => {
1182
- t(dr(r), s, n, 0);
1183
- }), n;
1549
+ function formDataToJSON(formData) {
1550
+ function buildPath(path, value, target, index) {
1551
+ let name = path[index++];
1552
+ if (name === "__proto__") return true;
1553
+ const isNumericKey = Number.isFinite(+name);
1554
+ const isLast = index >= path.length;
1555
+ name = !name && utils$1.isArray(target) ? target.length : name;
1556
+ if (isLast) {
1557
+ if (utils$1.hasOwnProp(target, name)) {
1558
+ target[name] = [target[name], value];
1559
+ } else {
1560
+ target[name] = value;
1561
+ }
1562
+ return !isNumericKey;
1563
+ }
1564
+ if (!target[name] || !utils$1.isObject(target[name])) {
1565
+ target[name] = [];
1566
+ }
1567
+ const result = buildPath(path, value, target[name], index);
1568
+ if (result && utils$1.isArray(target[name])) {
1569
+ target[name] = arrayToObject(target[name]);
1570
+ }
1571
+ return !isNumericKey;
1572
+ }
1573
+ if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
1574
+ const obj = {};
1575
+ utils$1.forEachEntry(formData, (name, value) => {
1576
+ buildPath(parsePropPath(name), value, obj, 0);
1577
+ });
1578
+ return obj;
1184
1579
  }
1185
1580
  return null;
1186
1581
  }
1187
- function hr(e, t, n) {
1188
- if (a.isString(e))
1582
+ function stringifySafely(rawValue, parser, encoder) {
1583
+ if (utils$1.isString(rawValue)) {
1189
1584
  try {
1190
- return (t || JSON.parse)(e), a.trim(e);
1191
- } catch (r) {
1192
- if (r.name !== "SyntaxError")
1193
- throw r;
1585
+ (parser || JSON.parse)(rawValue);
1586
+ return utils$1.trim(rawValue);
1587
+ } catch (e2) {
1588
+ if (e2.name !== "SyntaxError") {
1589
+ throw e2;
1590
+ }
1194
1591
  }
1195
- return (n || JSON.stringify)(e);
1592
+ }
1593
+ return (encoder || JSON.stringify)(rawValue);
1196
1594
  }
1197
- const ae = {
1198
- transitional: Ct,
1595
+ const defaults = {
1596
+ transitional: transitionalDefaults,
1199
1597
  adapter: ["xhr", "http", "fetch"],
1200
- transformRequest: [function(t, n) {
1201
- const r = n.getContentType() || "", s = r.indexOf("application/json") > -1, o = a.isObject(t);
1202
- if (o && a.isHTMLForm(t) && (t = new FormData(t)), a.isFormData(t))
1203
- return s ? JSON.stringify(kt(t)) : t;
1204
- if (a.isArrayBuffer(t) || a.isBuffer(t) || a.isStream(t) || a.isFile(t) || a.isBlob(t) || a.isReadableStream(t))
1205
- return t;
1206
- if (a.isArrayBufferView(t))
1207
- return t.buffer;
1208
- if (a.isURLSearchParams(t))
1209
- return n.setContentType("application/x-www-form-urlencoded;charset=utf-8", !1), t.toString();
1210
- let c;
1211
- if (o) {
1212
- if (r.indexOf("application/x-www-form-urlencoded") > -1)
1213
- return fr(t, this.formSerializer).toString();
1214
- if ((c = a.isFileList(t)) || r.indexOf("multipart/form-data") > -1) {
1215
- const d = this.env && this.env.FormData;
1216
- return ye(
1217
- c ? { "files[]": t } : t,
1218
- d && new d(),
1598
+ transformRequest: [function transformRequest(data, headers) {
1599
+ const contentType = headers.getContentType() || "";
1600
+ const hasJSONContentType = contentType.indexOf("application/json") > -1;
1601
+ const isObjectPayload = utils$1.isObject(data);
1602
+ if (isObjectPayload && utils$1.isHTMLForm(data)) {
1603
+ data = new FormData(data);
1604
+ }
1605
+ const isFormData2 = utils$1.isFormData(data);
1606
+ if (isFormData2) {
1607
+ return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
1608
+ }
1609
+ if (utils$1.isArrayBuffer(data) || utils$1.isBuffer(data) || utils$1.isStream(data) || utils$1.isFile(data) || utils$1.isBlob(data) || utils$1.isReadableStream(data)) {
1610
+ return data;
1611
+ }
1612
+ if (utils$1.isArrayBufferView(data)) {
1613
+ return data.buffer;
1614
+ }
1615
+ if (utils$1.isURLSearchParams(data)) {
1616
+ headers.setContentType("application/x-www-form-urlencoded;charset=utf-8", false);
1617
+ return data.toString();
1618
+ }
1619
+ let isFileList2;
1620
+ if (isObjectPayload) {
1621
+ if (contentType.indexOf("application/x-www-form-urlencoded") > -1) {
1622
+ return toURLEncodedForm(data, this.formSerializer).toString();
1623
+ }
1624
+ if ((isFileList2 = utils$1.isFileList(data)) || contentType.indexOf("multipart/form-data") > -1) {
1625
+ const _FormData = this.env && this.env.FormData;
1626
+ return toFormData$1(
1627
+ isFileList2 ? { "files[]": data } : data,
1628
+ _FormData && new _FormData(),
1219
1629
  this.formSerializer
1220
1630
  );
1221
1631
  }
1222
1632
  }
1223
- return o || s ? (n.setContentType("application/json", !1), hr(t)) : t;
1633
+ if (isObjectPayload || hasJSONContentType) {
1634
+ headers.setContentType("application/json", false);
1635
+ return stringifySafely(data);
1636
+ }
1637
+ return data;
1224
1638
  }],
1225
- transformResponse: [function(t) {
1226
- const n = this.transitional || ae.transitional, r = n && n.forcedJSONParsing, s = this.responseType === "json";
1227
- if (a.isResponse(t) || a.isReadableStream(t))
1228
- return t;
1229
- if (t && a.isString(t) && (r && !this.responseType || s)) {
1230
- const i = !(n && n.silentJSONParsing) && s;
1639
+ transformResponse: [function transformResponse(data) {
1640
+ const transitional2 = this.transitional || defaults.transitional;
1641
+ const forcedJSONParsing = transitional2 && transitional2.forcedJSONParsing;
1642
+ const JSONRequested = this.responseType === "json";
1643
+ if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
1644
+ return data;
1645
+ }
1646
+ if (data && utils$1.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
1647
+ const silentJSONParsing = transitional2 && transitional2.silentJSONParsing;
1648
+ const strictJSONParsing = !silentJSONParsing && JSONRequested;
1231
1649
  try {
1232
- return JSON.parse(t);
1233
- } catch (c) {
1234
- if (i)
1235
- throw c.name === "SyntaxError" ? b.from(c, b.ERR_BAD_RESPONSE, this, null, this.response) : c;
1650
+ return JSON.parse(data);
1651
+ } catch (e2) {
1652
+ if (strictJSONParsing) {
1653
+ if (e2.name === "SyntaxError") {
1654
+ throw AxiosError$1.from(e2, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
1655
+ }
1656
+ throw e2;
1657
+ }
1236
1658
  }
1237
1659
  }
1238
- return t;
1660
+ return data;
1239
1661
  }],
1240
1662
  /**
1241
1663
  * A timeout in milliseconds to abort a request. If set to 0 (default) a
@@ -1247,23 +1669,23 @@ const ae = {
1247
1669
  maxContentLength: -1,
1248
1670
  maxBodyLength: -1,
1249
1671
  env: {
1250
- FormData: v.classes.FormData,
1251
- Blob: v.classes.Blob
1672
+ FormData: platform.classes.FormData,
1673
+ Blob: platform.classes.Blob
1252
1674
  },
1253
- validateStatus: function(t) {
1254
- return t >= 200 && t < 300;
1675
+ validateStatus: function validateStatus(status) {
1676
+ return status >= 200 && status < 300;
1255
1677
  },
1256
1678
  headers: {
1257
1679
  common: {
1258
- Accept: "application/json, text/plain, */*",
1680
+ "Accept": "application/json, text/plain, */*",
1259
1681
  "Content-Type": void 0
1260
1682
  }
1261
1683
  }
1262
1684
  };
1263
- a.forEach(["delete", "get", "head", "post", "put", "patch"], (e) => {
1264
- ae.headers[e] = {};
1685
+ utils$1.forEach(["delete", "get", "head", "post", "put", "patch"], (method) => {
1686
+ defaults.headers[method] = {};
1265
1687
  });
1266
- const mr = a.toObjectSet([
1688
+ const ignoreDuplicateOf = utils$1.toObjectSet([
1267
1689
  "age",
1268
1690
  "authorization",
1269
1691
  "content-length",
@@ -1281,153 +1703,214 @@ const mr = a.toObjectSet([
1281
1703
  "referer",
1282
1704
  "retry-after",
1283
1705
  "user-agent"
1284
- ]), Rr = (e) => {
1285
- const t = {};
1286
- let n, r, s;
1287
- return e && e.split(`
1288
- `).forEach(function(i) {
1289
- s = i.indexOf(":"), n = i.substring(0, s).trim().toLowerCase(), r = i.substring(s + 1).trim(), !(!n || t[n] && mr[n]) && (n === "set-cookie" ? t[n] ? t[n].push(r) : t[n] = [r] : t[n] = t[n] ? t[n] + ", " + r : r);
1290
- }), t;
1291
- }, nt = Symbol("internals");
1292
- function te(e) {
1293
- return e && String(e).trim().toLowerCase();
1706
+ ]);
1707
+ const parseHeaders = (rawHeaders) => {
1708
+ const parsed = {};
1709
+ let key;
1710
+ let val;
1711
+ let i2;
1712
+ rawHeaders && rawHeaders.split("\n").forEach(function parser(line) {
1713
+ i2 = line.indexOf(":");
1714
+ key = line.substring(0, i2).trim().toLowerCase();
1715
+ val = line.substring(i2 + 1).trim();
1716
+ if (!key || parsed[key] && ignoreDuplicateOf[key]) {
1717
+ return;
1718
+ }
1719
+ if (key === "set-cookie") {
1720
+ if (parsed[key]) {
1721
+ parsed[key].push(val);
1722
+ } else {
1723
+ parsed[key] = [val];
1724
+ }
1725
+ } else {
1726
+ parsed[key] = parsed[key] ? parsed[key] + ", " + val : val;
1727
+ }
1728
+ });
1729
+ return parsed;
1730
+ };
1731
+ const $internals = Symbol("internals");
1732
+ function normalizeHeader(header) {
1733
+ return header && String(header).trim().toLowerCase();
1294
1734
  }
1295
- function ue(e) {
1296
- return e === !1 || e == null ? e : a.isArray(e) ? e.map(ue) : String(e);
1735
+ function normalizeValue(value) {
1736
+ if (value === false || value == null) {
1737
+ return value;
1738
+ }
1739
+ return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
1297
1740
  }
1298
- function Er(e) {
1299
- const t = /* @__PURE__ */ Object.create(null), n = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
1300
- let r;
1301
- for (; r = n.exec(e); )
1302
- t[r[1]] = r[2];
1303
- return t;
1741
+ function parseTokens(str) {
1742
+ const tokens = /* @__PURE__ */ Object.create(null);
1743
+ const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
1744
+ let match;
1745
+ while (match = tokensRE.exec(str)) {
1746
+ tokens[match[1]] = match[2];
1747
+ }
1748
+ return tokens;
1304
1749
  }
1305
- const br = (e) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());
1306
- function Pe(e, t, n, r, s) {
1307
- if (a.isFunction(r))
1308
- return r.call(this, t, n);
1309
- if (s && (t = n), !!a.isString(t)) {
1310
- if (a.isString(r))
1311
- return t.indexOf(r) !== -1;
1312
- if (a.isRegExp(r))
1313
- return r.test(t);
1750
+ const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
1751
+ function matchHeaderValue(context, value, header, filter2, isHeaderNameFilter) {
1752
+ if (utils$1.isFunction(filter2)) {
1753
+ return filter2.call(this, value, header);
1754
+ }
1755
+ if (isHeaderNameFilter) {
1756
+ value = header;
1757
+ }
1758
+ if (!utils$1.isString(value)) return;
1759
+ if (utils$1.isString(filter2)) {
1760
+ return value.indexOf(filter2) !== -1;
1761
+ }
1762
+ if (utils$1.isRegExp(filter2)) {
1763
+ return filter2.test(value);
1314
1764
  }
1315
1765
  }
1316
- function yr(e) {
1317
- return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (t, n, r) => n.toUpperCase() + r);
1766
+ function formatHeader(header) {
1767
+ return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (w2, char, str) => {
1768
+ return char.toUpperCase() + str;
1769
+ });
1318
1770
  }
1319
- function wr(e, t) {
1320
- const n = a.toCamelCase(" " + t);
1321
- ["get", "set", "has"].forEach((r) => {
1322
- Object.defineProperty(e, r + n, {
1323
- value: function(s, o, i) {
1324
- return this[r].call(this, t, s, o, i);
1771
+ function buildAccessors(obj, header) {
1772
+ const accessorName = utils$1.toCamelCase(" " + header);
1773
+ ["get", "set", "has"].forEach((methodName) => {
1774
+ Object.defineProperty(obj, methodName + accessorName, {
1775
+ value: function(arg1, arg2, arg3) {
1776
+ return this[methodName].call(this, header, arg1, arg2, arg3);
1325
1777
  },
1326
- configurable: !0
1778
+ configurable: true
1327
1779
  });
1328
1780
  });
1329
1781
  }
1330
- let U = class {
1331
- constructor(t) {
1332
- t && this.set(t);
1333
- }
1334
- set(t, n, r) {
1335
- const s = this;
1336
- function o(c, d, l) {
1337
- const u = te(d);
1338
- if (!u)
1782
+ let AxiosHeaders$1 = class AxiosHeaders {
1783
+ constructor(headers) {
1784
+ headers && this.set(headers);
1785
+ }
1786
+ set(header, valueOrRewrite, rewrite) {
1787
+ const self2 = this;
1788
+ function setHeader(_value, _header, _rewrite) {
1789
+ const lHeader = normalizeHeader(_header);
1790
+ if (!lHeader) {
1339
1791
  throw new Error("header name must be a non-empty string");
1340
- const p = a.findKey(s, u);
1341
- (!p || s[p] === void 0 || l === !0 || l === void 0 && s[p] !== !1) && (s[p || d] = ue(c));
1342
- }
1343
- const i = (c, d) => a.forEach(c, (l, u) => o(l, u, d));
1344
- if (a.isPlainObject(t) || t instanceof this.constructor)
1345
- i(t, n);
1346
- else if (a.isString(t) && (t = t.trim()) && !br(t))
1347
- i(Rr(t), n);
1348
- else if (a.isObject(t) && a.isIterable(t)) {
1349
- let c = {}, d, l;
1350
- for (const u of t) {
1351
- if (!a.isArray(u))
1792
+ }
1793
+ const key = utils$1.findKey(self2, lHeader);
1794
+ if (!key || self2[key] === void 0 || _rewrite === true || _rewrite === void 0 && self2[key] !== false) {
1795
+ self2[key || _header] = normalizeValue(_value);
1796
+ }
1797
+ }
1798
+ const setHeaders = (headers, _rewrite) => utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
1799
+ if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
1800
+ setHeaders(header, valueOrRewrite);
1801
+ } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1802
+ setHeaders(parseHeaders(header), valueOrRewrite);
1803
+ } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
1804
+ let obj = {}, dest, key;
1805
+ for (const entry of header) {
1806
+ if (!utils$1.isArray(entry)) {
1352
1807
  throw TypeError("Object iterator must return a key-value pair");
1353
- c[l = u[0]] = (d = c[l]) ? a.isArray(d) ? [...d, u[1]] : [d, u[1]] : u[1];
1808
+ }
1809
+ obj[key = entry[0]] = (dest = obj[key]) ? utils$1.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]] : entry[1];
1354
1810
  }
1355
- i(c, n);
1356
- } else
1357
- t != null && o(n, t, r);
1811
+ setHeaders(obj, valueOrRewrite);
1812
+ } else {
1813
+ header != null && setHeader(valueOrRewrite, header, rewrite);
1814
+ }
1358
1815
  return this;
1359
1816
  }
1360
- get(t, n) {
1361
- if (t = te(t), t) {
1362
- const r = a.findKey(this, t);
1363
- if (r) {
1364
- const s = this[r];
1365
- if (!n)
1366
- return s;
1367
- if (n === !0)
1368
- return Er(s);
1369
- if (a.isFunction(n))
1370
- return n.call(this, s, r);
1371
- if (a.isRegExp(n))
1372
- return n.exec(s);
1817
+ get(header, parser) {
1818
+ header = normalizeHeader(header);
1819
+ if (header) {
1820
+ const key = utils$1.findKey(this, header);
1821
+ if (key) {
1822
+ const value = this[key];
1823
+ if (!parser) {
1824
+ return value;
1825
+ }
1826
+ if (parser === true) {
1827
+ return parseTokens(value);
1828
+ }
1829
+ if (utils$1.isFunction(parser)) {
1830
+ return parser.call(this, value, key);
1831
+ }
1832
+ if (utils$1.isRegExp(parser)) {
1833
+ return parser.exec(value);
1834
+ }
1373
1835
  throw new TypeError("parser must be boolean|regexp|function");
1374
1836
  }
1375
1837
  }
1376
1838
  }
1377
- has(t, n) {
1378
- if (t = te(t), t) {
1379
- const r = a.findKey(this, t);
1380
- return !!(r && this[r] !== void 0 && (!n || Pe(this, this[r], r, n)));
1839
+ has(header, matcher) {
1840
+ header = normalizeHeader(header);
1841
+ if (header) {
1842
+ const key = utils$1.findKey(this, header);
1843
+ return !!(key && this[key] !== void 0 && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1381
1844
  }
1382
- return !1;
1383
- }
1384
- delete(t, n) {
1385
- const r = this;
1386
- let s = !1;
1387
- function o(i) {
1388
- if (i = te(i), i) {
1389
- const c = a.findKey(r, i);
1390
- c && (!n || Pe(r, r[c], c, n)) && (delete r[c], s = !0);
1845
+ return false;
1846
+ }
1847
+ delete(header, matcher) {
1848
+ const self2 = this;
1849
+ let deleted = false;
1850
+ function deleteHeader(_header) {
1851
+ _header = normalizeHeader(_header);
1852
+ if (_header) {
1853
+ const key = utils$1.findKey(self2, _header);
1854
+ if (key && (!matcher || matchHeaderValue(self2, self2[key], key, matcher))) {
1855
+ delete self2[key];
1856
+ deleted = true;
1857
+ }
1391
1858
  }
1392
1859
  }
1393
- return a.isArray(t) ? t.forEach(o) : o(t), s;
1394
- }
1395
- clear(t) {
1396
- const n = Object.keys(this);
1397
- let r = n.length, s = !1;
1398
- for (; r--; ) {
1399
- const o = n[r];
1400
- (!t || Pe(this, this[o], o, t, !0)) && (delete this[o], s = !0);
1860
+ if (utils$1.isArray(header)) {
1861
+ header.forEach(deleteHeader);
1862
+ } else {
1863
+ deleteHeader(header);
1401
1864
  }
1402
- return s;
1403
- }
1404
- normalize(t) {
1405
- const n = this, r = {};
1406
- return a.forEach(this, (s, o) => {
1407
- const i = a.findKey(r, o);
1408
- if (i) {
1409
- n[i] = ue(s), delete n[o];
1865
+ return deleted;
1866
+ }
1867
+ clear(matcher) {
1868
+ const keys = Object.keys(this);
1869
+ let i2 = keys.length;
1870
+ let deleted = false;
1871
+ while (i2--) {
1872
+ const key = keys[i2];
1873
+ if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
1874
+ delete this[key];
1875
+ deleted = true;
1876
+ }
1877
+ }
1878
+ return deleted;
1879
+ }
1880
+ normalize(format) {
1881
+ const self2 = this;
1882
+ const headers = {};
1883
+ utils$1.forEach(this, (value, header) => {
1884
+ const key = utils$1.findKey(headers, header);
1885
+ if (key) {
1886
+ self2[key] = normalizeValue(value);
1887
+ delete self2[header];
1410
1888
  return;
1411
1889
  }
1412
- const c = t ? yr(o) : String(o).trim();
1413
- c !== o && delete n[o], n[c] = ue(s), r[c] = !0;
1414
- }), this;
1890
+ const normalized = format ? formatHeader(header) : String(header).trim();
1891
+ if (normalized !== header) {
1892
+ delete self2[header];
1893
+ }
1894
+ self2[normalized] = normalizeValue(value);
1895
+ headers[normalized] = true;
1896
+ });
1897
+ return this;
1415
1898
  }
1416
- concat(...t) {
1417
- return this.constructor.concat(this, ...t);
1899
+ concat(...targets) {
1900
+ return this.constructor.concat(this, ...targets);
1418
1901
  }
1419
- toJSON(t) {
1420
- const n = /* @__PURE__ */ Object.create(null);
1421
- return a.forEach(this, (r, s) => {
1422
- r != null && r !== !1 && (n[s] = t && a.isArray(r) ? r.join(", ") : r);
1423
- }), n;
1902
+ toJSON(asStrings) {
1903
+ const obj = /* @__PURE__ */ Object.create(null);
1904
+ utils$1.forEach(this, (value, header) => {
1905
+ value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(", ") : value);
1906
+ });
1907
+ return obj;
1424
1908
  }
1425
1909
  [Symbol.iterator]() {
1426
1910
  return Object.entries(this.toJSON())[Symbol.iterator]();
1427
1911
  }
1428
1912
  toString() {
1429
- return Object.entries(this.toJSON()).map(([t, n]) => t + ": " + n).join(`
1430
- `);
1913
+ return Object.entries(this.toJSON()).map(([header, value]) => header + ": " + value).join("\n");
1431
1914
  }
1432
1915
  getSetCookie() {
1433
1916
  return this.get("set-cookie") || [];
@@ -1435,135 +1918,203 @@ let U = class {
1435
1918
  get [Symbol.toStringTag]() {
1436
1919
  return "AxiosHeaders";
1437
1920
  }
1438
- static from(t) {
1439
- return t instanceof this ? t : new this(t);
1921
+ static from(thing) {
1922
+ return thing instanceof this ? thing : new this(thing);
1440
1923
  }
1441
- static concat(t, ...n) {
1442
- const r = new this(t);
1443
- return n.forEach((s) => r.set(s)), r;
1924
+ static concat(first, ...targets) {
1925
+ const computed = new this(first);
1926
+ targets.forEach((target) => computed.set(target));
1927
+ return computed;
1444
1928
  }
1445
- static accessor(t) {
1446
- const r = (this[nt] = this[nt] = {
1929
+ static accessor(header) {
1930
+ const internals = this[$internals] = this[$internals] = {
1447
1931
  accessors: {}
1448
- }).accessors, s = this.prototype;
1449
- function o(i) {
1450
- const c = te(i);
1451
- r[c] || (wr(s, i), r[c] = !0);
1932
+ };
1933
+ const accessors = internals.accessors;
1934
+ const prototype2 = this.prototype;
1935
+ function defineAccessor(_header) {
1936
+ const lHeader = normalizeHeader(_header);
1937
+ if (!accessors[lHeader]) {
1938
+ buildAccessors(prototype2, _header);
1939
+ accessors[lHeader] = true;
1940
+ }
1452
1941
  }
1453
- return a.isArray(t) ? t.forEach(o) : o(t), this;
1942
+ utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
1943
+ return this;
1454
1944
  }
1455
1945
  };
1456
- U.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]);
1457
- a.reduceDescriptors(U.prototype, ({ value: e }, t) => {
1458
- let n = t[0].toUpperCase() + t.slice(1);
1946
+ AxiosHeaders$1.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]);
1947
+ utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({ value }, key) => {
1948
+ let mapped = key[0].toUpperCase() + key.slice(1);
1459
1949
  return {
1460
- get: () => e,
1461
- set(r) {
1462
- this[n] = r;
1950
+ get: () => value,
1951
+ set(headerValue) {
1952
+ this[mapped] = headerValue;
1463
1953
  }
1464
1954
  };
1465
1955
  });
1466
- a.freezeMethods(U);
1467
- function xe(e, t) {
1468
- const n = this || ae, r = t || n, s = U.from(r.headers);
1469
- let o = r.data;
1470
- return a.forEach(e, function(c) {
1471
- o = c.call(n, o, s.normalize(), t ? t.status : void 0);
1472
- }), s.normalize(), o;
1956
+ utils$1.freezeMethods(AxiosHeaders$1);
1957
+ function transformData(fns, response) {
1958
+ const config = this || defaults;
1959
+ const context = response || config;
1960
+ const headers = AxiosHeaders$1.from(context.headers);
1961
+ let data = context.data;
1962
+ utils$1.forEach(fns, function transform(fn) {
1963
+ data = fn.call(config, data, headers.normalize(), response ? response.status : void 0);
1964
+ });
1965
+ headers.normalize();
1966
+ return data;
1473
1967
  }
1474
- function vt(e) {
1475
- return !!(e && e.__CANCEL__);
1968
+ function isCancel$1(value) {
1969
+ return !!(value && value.__CANCEL__);
1476
1970
  }
1477
- function G(e, t, n) {
1478
- b.call(this, e ?? "canceled", b.ERR_CANCELED, t, n), this.name = "CanceledError";
1971
+ function CanceledError$1(message, config, request) {
1972
+ AxiosError$1.call(this, message == null ? "canceled" : message, AxiosError$1.ERR_CANCELED, config, request);
1973
+ this.name = "CanceledError";
1479
1974
  }
1480
- a.inherits(G, b, {
1481
- __CANCEL__: !0
1975
+ utils$1.inherits(CanceledError$1, AxiosError$1, {
1976
+ __CANCEL__: true
1482
1977
  });
1483
- function Ft(e, t, n) {
1484
- const r = n.config.validateStatus;
1485
- !n.status || !r || r(n.status) ? e(n) : t(new b(
1486
- "Request failed with status code " + n.status,
1487
- [b.ERR_BAD_REQUEST, b.ERR_BAD_RESPONSE][Math.floor(n.status / 100) - 4],
1488
- n.config,
1489
- n.request,
1490
- n
1491
- ));
1978
+ function settle(resolve, reject, response) {
1979
+ const validateStatus2 = response.config.validateStatus;
1980
+ if (!response.status || !validateStatus2 || validateStatus2(response.status)) {
1981
+ resolve(response);
1982
+ } else {
1983
+ reject(new AxiosError$1(
1984
+ "Request failed with status code " + response.status,
1985
+ [AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
1986
+ response.config,
1987
+ response.request,
1988
+ response
1989
+ ));
1990
+ }
1492
1991
  }
1493
- function Tr(e) {
1494
- const t = /^([-+\w]{1,25})(:?\/\/|:)/.exec(e);
1495
- return t && t[1] || "";
1992
+ function parseProtocol(url) {
1993
+ const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
1994
+ return match && match[1] || "";
1496
1995
  }
1497
- function gr(e, t) {
1498
- e = e || 10;
1499
- const n = new Array(e), r = new Array(e);
1500
- let s = 0, o = 0, i;
1501
- return t = t !== void 0 ? t : 1e3, function(d) {
1502
- const l = Date.now(), u = r[o];
1503
- i || (i = l), n[s] = d, r[s] = l;
1504
- let p = o, y = 0;
1505
- for (; p !== s; )
1506
- y += n[p++], p = p % e;
1507
- if (s = (s + 1) % e, s === o && (o = (o + 1) % e), l - i < t)
1996
+ function speedometer(samplesCount, min) {
1997
+ samplesCount = samplesCount || 10;
1998
+ const bytes = new Array(samplesCount);
1999
+ const timestamps = new Array(samplesCount);
2000
+ let head = 0;
2001
+ let tail = 0;
2002
+ let firstSampleTS;
2003
+ min = min !== void 0 ? min : 1e3;
2004
+ return function push(chunkLength) {
2005
+ const now = Date.now();
2006
+ const startedAt = timestamps[tail];
2007
+ if (!firstSampleTS) {
2008
+ firstSampleTS = now;
2009
+ }
2010
+ bytes[head] = chunkLength;
2011
+ timestamps[head] = now;
2012
+ let i2 = tail;
2013
+ let bytesCount = 0;
2014
+ while (i2 !== head) {
2015
+ bytesCount += bytes[i2++];
2016
+ i2 = i2 % samplesCount;
2017
+ }
2018
+ head = (head + 1) % samplesCount;
2019
+ if (head === tail) {
2020
+ tail = (tail + 1) % samplesCount;
2021
+ }
2022
+ if (now - firstSampleTS < min) {
1508
2023
  return;
1509
- const T = u && l - u;
1510
- return T ? Math.round(y * 1e3 / T) : void 0;
2024
+ }
2025
+ const passed = startedAt && now - startedAt;
2026
+ return passed ? Math.round(bytesCount * 1e3 / passed) : void 0;
1511
2027
  };
1512
2028
  }
1513
- function Sr(e, t) {
1514
- let n = 0, r = 1e3 / t, s, o;
1515
- const i = (l, u = Date.now()) => {
1516
- n = u, s = null, o && (clearTimeout(o), o = null), e.apply(null, l);
2029
+ function throttle(fn, freq) {
2030
+ let timestamp = 0;
2031
+ let threshold = 1e3 / freq;
2032
+ let lastArgs;
2033
+ let timer;
2034
+ const invoke = (args, now = Date.now()) => {
2035
+ timestamp = now;
2036
+ lastArgs = null;
2037
+ if (timer) {
2038
+ clearTimeout(timer);
2039
+ timer = null;
2040
+ }
2041
+ fn.apply(null, args);
2042
+ };
2043
+ const throttled = (...args) => {
2044
+ const now = Date.now();
2045
+ const passed = now - timestamp;
2046
+ if (passed >= threshold) {
2047
+ invoke(args, now);
2048
+ } else {
2049
+ lastArgs = args;
2050
+ if (!timer) {
2051
+ timer = setTimeout(() => {
2052
+ timer = null;
2053
+ invoke(lastArgs);
2054
+ }, threshold - passed);
2055
+ }
2056
+ }
1517
2057
  };
1518
- return [(...l) => {
1519
- const u = Date.now(), p = u - n;
1520
- p >= r ? i(l, u) : (s = l, o || (o = setTimeout(() => {
1521
- o = null, i(s);
1522
- }, r - p)));
1523
- }, () => s && i(s)];
2058
+ const flush = () => lastArgs && invoke(lastArgs);
2059
+ return [throttled, flush];
1524
2060
  }
1525
- const pe = (e, t, n = 3) => {
1526
- let r = 0;
1527
- const s = gr(50, 250);
1528
- return Sr((o) => {
1529
- const i = o.loaded, c = o.lengthComputable ? o.total : void 0, d = i - r, l = s(d), u = i <= c;
1530
- r = i;
1531
- const p = {
1532
- loaded: i,
1533
- total: c,
1534
- progress: c ? i / c : void 0,
1535
- bytes: d,
1536
- rate: l || void 0,
1537
- estimated: l && c && u ? (c - i) / l : void 0,
1538
- event: o,
1539
- lengthComputable: c != null,
1540
- [t ? "download" : "upload"]: !0
2061
+ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
2062
+ let bytesNotified = 0;
2063
+ const _speedometer = speedometer(50, 250);
2064
+ return throttle((e2) => {
2065
+ const loaded = e2.loaded;
2066
+ const total = e2.lengthComputable ? e2.total : void 0;
2067
+ const progressBytes = loaded - bytesNotified;
2068
+ const rate = _speedometer(progressBytes);
2069
+ const inRange = loaded <= total;
2070
+ bytesNotified = loaded;
2071
+ const data = {
2072
+ loaded,
2073
+ total,
2074
+ progress: total ? loaded / total : void 0,
2075
+ bytes: progressBytes,
2076
+ rate: rate ? rate : void 0,
2077
+ estimated: rate && total && inRange ? (total - loaded) / rate : void 0,
2078
+ event: e2,
2079
+ lengthComputable: total != null,
2080
+ [isDownloadStream ? "download" : "upload"]: true
1541
2081
  };
1542
- e(p);
1543
- }, n);
1544
- }, rt = (e, t) => {
1545
- const n = e != null;
1546
- return [(r) => t[0]({
1547
- lengthComputable: n,
1548
- total: e,
1549
- loaded: r
1550
- }), t[1]];
1551
- }, st = (e) => (...t) => a.asap(() => e(...t)), Or = v.hasStandardBrowserEnv ? /* @__PURE__ */ ((e, t) => (n) => (n = new URL(n, v.origin), e.protocol === n.protocol && e.host === n.host && (t || e.port === n.port)))(
1552
- new URL(v.origin),
1553
- v.navigator && /(msie|trident)/i.test(v.navigator.userAgent)
1554
- ) : () => !0, Ar = v.hasStandardBrowserEnv ? (
2082
+ listener(data);
2083
+ }, freq);
2084
+ };
2085
+ const progressEventDecorator = (total, throttled) => {
2086
+ const lengthComputable = total != null;
2087
+ return [(loaded) => throttled[0]({
2088
+ lengthComputable,
2089
+ total,
2090
+ loaded
2091
+ }), throttled[1]];
2092
+ };
2093
+ const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
2094
+ const isURLSameOrigin = platform.hasStandardBrowserEnv ? /* @__PURE__ */ ((origin2, isMSIE) => (url) => {
2095
+ url = new URL(url, platform.origin);
2096
+ return origin2.protocol === url.protocol && origin2.host === url.host && (isMSIE || origin2.port === url.port);
2097
+ })(
2098
+ new URL(platform.origin),
2099
+ platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
2100
+ ) : () => true;
2101
+ const cookies = platform.hasStandardBrowserEnv ? (
1555
2102
  // Standard browser envs support document.cookie
1556
2103
  {
1557
- write(e, t, n, r, s, o) {
1558
- const i = [e + "=" + encodeURIComponent(t)];
1559
- a.isNumber(n) && i.push("expires=" + new Date(n).toGMTString()), a.isString(r) && i.push("path=" + r), a.isString(s) && i.push("domain=" + s), o === !0 && i.push("secure"), document.cookie = i.join("; ");
2104
+ write(name, value, expires, path, domain, secure) {
2105
+ const cookie = [name + "=" + encodeURIComponent(value)];
2106
+ utils$1.isNumber(expires) && cookie.push("expires=" + new Date(expires).toGMTString());
2107
+ utils$1.isString(path) && cookie.push("path=" + path);
2108
+ utils$1.isString(domain) && cookie.push("domain=" + domain);
2109
+ secure === true && cookie.push("secure");
2110
+ document.cookie = cookie.join("; ");
1560
2111
  },
1561
- read(e) {
1562
- const t = document.cookie.match(new RegExp("(^|;\\s*)(" + e + ")=([^;]*)"));
1563
- return t ? decodeURIComponent(t[3]) : null;
2112
+ read(name) {
2113
+ const match = document.cookie.match(new RegExp("(^|;\\s*)(" + name + ")=([^;]*)"));
2114
+ return match ? decodeURIComponent(match[3]) : null;
1564
2115
  },
1565
- remove(e) {
1566
- this.write(e, "", Date.now() - 864e5);
2116
+ remove(name) {
2117
+ this.write(name, "", Date.now() - 864e5);
1567
2118
  }
1568
2119
  }
1569
2120
  ) : (
@@ -1578,488 +2129,688 @@ const pe = (e, t, n = 3) => {
1578
2129
  }
1579
2130
  }
1580
2131
  );
1581
- function _r(e) {
1582
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(e);
2132
+ function isAbsoluteURL(url) {
2133
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
1583
2134
  }
1584
- function Pr(e, t) {
1585
- return t ? e.replace(/\/?\/$/, "") + "/" + t.replace(/^\/+/, "") : e;
2135
+ function combineURLs(baseURL, relativeURL) {
2136
+ return relativeURL ? baseURL.replace(/\/?\/$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
1586
2137
  }
1587
- function jt(e, t, n) {
1588
- let r = !_r(t);
1589
- return e && (r || n == !1) ? Pr(e, t) : t;
2138
+ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
2139
+ let isRelativeUrl = !isAbsoluteURL(requestedURL);
2140
+ if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
2141
+ return combineURLs(baseURL, requestedURL);
2142
+ }
2143
+ return requestedURL;
1590
2144
  }
1591
- const ot = (e) => e instanceof U ? { ...e } : e;
1592
- function W(e, t) {
1593
- t = t || {};
1594
- const n = {};
1595
- function r(l, u, p, y) {
1596
- return a.isPlainObject(l) && a.isPlainObject(u) ? a.merge.call({ caseless: y }, l, u) : a.isPlainObject(u) ? a.merge({}, u) : a.isArray(u) ? u.slice() : u;
1597
- }
1598
- function s(l, u, p, y) {
1599
- if (a.isUndefined(u)) {
1600
- if (!a.isUndefined(l))
1601
- return r(void 0, l, p, y);
1602
- } else return r(l, u, p, y);
1603
- }
1604
- function o(l, u) {
1605
- if (!a.isUndefined(u))
1606
- return r(void 0, u);
1607
- }
1608
- function i(l, u) {
1609
- if (a.isUndefined(u)) {
1610
- if (!a.isUndefined(l))
1611
- return r(void 0, l);
1612
- } else return r(void 0, u);
1613
- }
1614
- function c(l, u, p) {
1615
- if (p in t)
1616
- return r(l, u);
1617
- if (p in e)
1618
- return r(void 0, l);
1619
- }
1620
- const d = {
1621
- url: o,
1622
- method: o,
1623
- data: o,
1624
- baseURL: i,
1625
- transformRequest: i,
1626
- transformResponse: i,
1627
- paramsSerializer: i,
1628
- timeout: i,
1629
- timeoutMessage: i,
1630
- withCredentials: i,
1631
- withXSRFToken: i,
1632
- adapter: i,
1633
- responseType: i,
1634
- xsrfCookieName: i,
1635
- xsrfHeaderName: i,
1636
- onUploadProgress: i,
1637
- onDownloadProgress: i,
1638
- decompress: i,
1639
- maxContentLength: i,
1640
- maxBodyLength: i,
1641
- beforeRedirect: i,
1642
- transport: i,
1643
- httpAgent: i,
1644
- httpsAgent: i,
1645
- cancelToken: i,
1646
- socketPath: i,
1647
- responseEncoding: i,
1648
- validateStatus: c,
1649
- headers: (l, u, p) => s(ot(l), ot(u), p, !0)
2145
+ const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
2146
+ function mergeConfig$1(config1, config2) {
2147
+ config2 = config2 || {};
2148
+ const config = {};
2149
+ function getMergedValue(target, source, prop, caseless) {
2150
+ if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
2151
+ return utils$1.merge.call({ caseless }, target, source);
2152
+ } else if (utils$1.isPlainObject(source)) {
2153
+ return utils$1.merge({}, source);
2154
+ } else if (utils$1.isArray(source)) {
2155
+ return source.slice();
2156
+ }
2157
+ return source;
2158
+ }
2159
+ function mergeDeepProperties(a2, b, prop, caseless) {
2160
+ if (!utils$1.isUndefined(b)) {
2161
+ return getMergedValue(a2, b, prop, caseless);
2162
+ } else if (!utils$1.isUndefined(a2)) {
2163
+ return getMergedValue(void 0, a2, prop, caseless);
2164
+ }
2165
+ }
2166
+ function valueFromConfig2(a2, b) {
2167
+ if (!utils$1.isUndefined(b)) {
2168
+ return getMergedValue(void 0, b);
2169
+ }
2170
+ }
2171
+ function defaultToConfig2(a2, b) {
2172
+ if (!utils$1.isUndefined(b)) {
2173
+ return getMergedValue(void 0, b);
2174
+ } else if (!utils$1.isUndefined(a2)) {
2175
+ return getMergedValue(void 0, a2);
2176
+ }
2177
+ }
2178
+ function mergeDirectKeys(a2, b, prop) {
2179
+ if (prop in config2) {
2180
+ return getMergedValue(a2, b);
2181
+ } else if (prop in config1) {
2182
+ return getMergedValue(void 0, a2);
2183
+ }
2184
+ }
2185
+ const mergeMap = {
2186
+ url: valueFromConfig2,
2187
+ method: valueFromConfig2,
2188
+ data: valueFromConfig2,
2189
+ baseURL: defaultToConfig2,
2190
+ transformRequest: defaultToConfig2,
2191
+ transformResponse: defaultToConfig2,
2192
+ paramsSerializer: defaultToConfig2,
2193
+ timeout: defaultToConfig2,
2194
+ timeoutMessage: defaultToConfig2,
2195
+ withCredentials: defaultToConfig2,
2196
+ withXSRFToken: defaultToConfig2,
2197
+ adapter: defaultToConfig2,
2198
+ responseType: defaultToConfig2,
2199
+ xsrfCookieName: defaultToConfig2,
2200
+ xsrfHeaderName: defaultToConfig2,
2201
+ onUploadProgress: defaultToConfig2,
2202
+ onDownloadProgress: defaultToConfig2,
2203
+ decompress: defaultToConfig2,
2204
+ maxContentLength: defaultToConfig2,
2205
+ maxBodyLength: defaultToConfig2,
2206
+ beforeRedirect: defaultToConfig2,
2207
+ transport: defaultToConfig2,
2208
+ httpAgent: defaultToConfig2,
2209
+ httpsAgent: defaultToConfig2,
2210
+ cancelToken: defaultToConfig2,
2211
+ socketPath: defaultToConfig2,
2212
+ responseEncoding: defaultToConfig2,
2213
+ validateStatus: mergeDirectKeys,
2214
+ headers: (a2, b, prop) => mergeDeepProperties(headersToObject(a2), headersToObject(b), prop, true)
1650
2215
  };
1651
- return a.forEach(Object.keys(Object.assign({}, e, t)), function(u) {
1652
- const p = d[u] || s, y = p(e[u], t[u], u);
1653
- a.isUndefined(y) && p !== c || (n[u] = y);
1654
- }), n;
2216
+ utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
2217
+ const merge2 = mergeMap[prop] || mergeDeepProperties;
2218
+ const configValue = merge2(config1[prop], config2[prop], prop);
2219
+ utils$1.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config[prop] = configValue);
2220
+ });
2221
+ return config;
1655
2222
  }
1656
- const Lt = (e) => {
1657
- const t = W({}, e);
1658
- let { data: n, withXSRFToken: r, xsrfHeaderName: s, xsrfCookieName: o, headers: i, auth: c } = t;
1659
- t.headers = i = U.from(i), t.url = Nt(jt(t.baseURL, t.url, t.allowAbsoluteUrls), e.params, e.paramsSerializer), c && i.set(
1660
- "Authorization",
1661
- "Basic " + btoa((c.username || "") + ":" + (c.password ? unescape(encodeURIComponent(c.password)) : ""))
1662
- );
1663
- let d;
1664
- if (a.isFormData(n)) {
1665
- if (v.hasStandardBrowserEnv || v.hasStandardBrowserWebWorkerEnv)
1666
- i.setContentType(void 0);
1667
- else if ((d = i.getContentType()) !== !1) {
1668
- const [l, ...u] = d ? d.split(";").map((p) => p.trim()).filter(Boolean) : [];
1669
- i.setContentType([l || "multipart/form-data", ...u].join("; "));
1670
- }
1671
- }
1672
- if (v.hasStandardBrowserEnv && (r && a.isFunction(r) && (r = r(t)), r || r !== !1 && Or(t.url))) {
1673
- const l = s && o && Ar.read(o);
1674
- l && i.set(s, l);
1675
- }
1676
- return t;
1677
- }, xr = typeof XMLHttpRequest < "u", Nr = xr && function(e) {
1678
- return new Promise(function(n, r) {
1679
- const s = Lt(e);
1680
- let o = s.data;
1681
- const i = U.from(s.headers).normalize();
1682
- let { responseType: c, onUploadProgress: d, onDownloadProgress: l } = s, u, p, y, T, h;
1683
- function R() {
1684
- T && T(), h && h(), s.cancelToken && s.cancelToken.unsubscribe(u), s.signal && s.signal.removeEventListener("abort", u);
1685
- }
1686
- let m = new XMLHttpRequest();
1687
- m.open(s.method.toUpperCase(), s.url, !0), m.timeout = s.timeout;
1688
- function S() {
1689
- if (!m)
2223
+ const resolveConfig = (config) => {
2224
+ const newConfig = mergeConfig$1({}, config);
2225
+ let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
2226
+ newConfig.headers = headers = AxiosHeaders$1.from(headers);
2227
+ newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
2228
+ if (auth) {
2229
+ headers.set(
2230
+ "Authorization",
2231
+ "Basic " + btoa((auth.username || "") + ":" + (auth.password ? unescape(encodeURIComponent(auth.password)) : ""))
2232
+ );
2233
+ }
2234
+ let contentType;
2235
+ if (utils$1.isFormData(data)) {
2236
+ if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
2237
+ headers.setContentType(void 0);
2238
+ } else if ((contentType = headers.getContentType()) !== false) {
2239
+ const [type, ...tokens] = contentType ? contentType.split(";").map((token) => token.trim()).filter(Boolean) : [];
2240
+ headers.setContentType([type || "multipart/form-data", ...tokens].join("; "));
2241
+ }
2242
+ }
2243
+ if (platform.hasStandardBrowserEnv) {
2244
+ withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
2245
+ if (withXSRFToken || withXSRFToken !== false && isURLSameOrigin(newConfig.url)) {
2246
+ const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
2247
+ if (xsrfValue) {
2248
+ headers.set(xsrfHeaderName, xsrfValue);
2249
+ }
2250
+ }
2251
+ }
2252
+ return newConfig;
2253
+ };
2254
+ const isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
2255
+ const xhrAdapter = isXHRAdapterSupported && function(config) {
2256
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
2257
+ const _config = resolveConfig(config);
2258
+ let requestData = _config.data;
2259
+ const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
2260
+ let { responseType, onUploadProgress, onDownloadProgress } = _config;
2261
+ let onCanceled;
2262
+ let uploadThrottled, downloadThrottled;
2263
+ let flushUpload, flushDownload;
2264
+ function done() {
2265
+ flushUpload && flushUpload();
2266
+ flushDownload && flushDownload();
2267
+ _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
2268
+ _config.signal && _config.signal.removeEventListener("abort", onCanceled);
2269
+ }
2270
+ let request = new XMLHttpRequest();
2271
+ request.open(_config.method.toUpperCase(), _config.url, true);
2272
+ request.timeout = _config.timeout;
2273
+ function onloadend() {
2274
+ if (!request) {
1690
2275
  return;
1691
- const E = U.from(
1692
- "getAllResponseHeaders" in m && m.getAllResponseHeaders()
1693
- ), g = {
1694
- data: !c || c === "text" || c === "json" ? m.responseText : m.response,
1695
- status: m.status,
1696
- statusText: m.statusText,
1697
- headers: E,
1698
- config: e,
1699
- request: m
2276
+ }
2277
+ const responseHeaders = AxiosHeaders$1.from(
2278
+ "getAllResponseHeaders" in request && request.getAllResponseHeaders()
2279
+ );
2280
+ const responseData = !responseType || responseType === "text" || responseType === "json" ? request.responseText : request.response;
2281
+ const response = {
2282
+ data: responseData,
2283
+ status: request.status,
2284
+ statusText: request.statusText,
2285
+ headers: responseHeaders,
2286
+ config,
2287
+ request
2288
+ };
2289
+ settle(function _resolve(value) {
2290
+ resolve(value);
2291
+ done();
2292
+ }, function _reject(err) {
2293
+ reject(err);
2294
+ done();
2295
+ }, response);
2296
+ request = null;
2297
+ }
2298
+ if ("onloadend" in request) {
2299
+ request.onloadend = onloadend;
2300
+ } else {
2301
+ request.onreadystatechange = function handleLoad() {
2302
+ if (!request || request.readyState !== 4) {
2303
+ return;
2304
+ }
2305
+ if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf("file:") === 0)) {
2306
+ return;
2307
+ }
2308
+ setTimeout(onloadend);
1700
2309
  };
1701
- Ft(function(N) {
1702
- n(N), R();
1703
- }, function(N) {
1704
- r(N), R();
1705
- }, g), m = null;
1706
- }
1707
- "onloadend" in m ? m.onloadend = S : m.onreadystatechange = function() {
1708
- !m || m.readyState !== 4 || m.status === 0 && !(m.responseURL && m.responseURL.indexOf("file:") === 0) || setTimeout(S);
1709
- }, m.onabort = function() {
1710
- m && (r(new b("Request aborted", b.ECONNABORTED, e, m)), m = null);
1711
- }, m.onerror = function() {
1712
- r(new b("Network Error", b.ERR_NETWORK, e, m)), m = null;
1713
- }, m.ontimeout = function() {
1714
- let O = s.timeout ? "timeout of " + s.timeout + "ms exceeded" : "timeout exceeded";
1715
- const g = s.transitional || Ct;
1716
- s.timeoutErrorMessage && (O = s.timeoutErrorMessage), r(new b(
1717
- O,
1718
- g.clarifyTimeoutError ? b.ETIMEDOUT : b.ECONNABORTED,
1719
- e,
1720
- m
1721
- )), m = null;
1722
- }, o === void 0 && i.setContentType(null), "setRequestHeader" in m && a.forEach(i.toJSON(), function(O, g) {
1723
- m.setRequestHeader(g, O);
1724
- }), a.isUndefined(s.withCredentials) || (m.withCredentials = !!s.withCredentials), c && c !== "json" && (m.responseType = s.responseType), l && ([y, h] = pe(l, !0), m.addEventListener("progress", y)), d && m.upload && ([p, T] = pe(d), m.upload.addEventListener("progress", p), m.upload.addEventListener("loadend", T)), (s.cancelToken || s.signal) && (u = (E) => {
1725
- m && (r(!E || E.type ? new G(null, e, m) : E), m.abort(), m = null);
1726
- }, s.cancelToken && s.cancelToken.subscribe(u), s.signal && (s.signal.aborted ? u() : s.signal.addEventListener("abort", u)));
1727
- const A = Tr(s.url);
1728
- if (A && v.protocols.indexOf(A) === -1) {
1729
- r(new b("Unsupported protocol " + A + ":", b.ERR_BAD_REQUEST, e));
2310
+ }
2311
+ request.onabort = function handleAbort() {
2312
+ if (!request) {
2313
+ return;
2314
+ }
2315
+ reject(new AxiosError$1("Request aborted", AxiosError$1.ECONNABORTED, config, request));
2316
+ request = null;
2317
+ };
2318
+ request.onerror = function handleError() {
2319
+ reject(new AxiosError$1("Network Error", AxiosError$1.ERR_NETWORK, config, request));
2320
+ request = null;
2321
+ };
2322
+ request.ontimeout = function handleTimeout() {
2323
+ let timeoutErrorMessage = _config.timeout ? "timeout of " + _config.timeout + "ms exceeded" : "timeout exceeded";
2324
+ const transitional2 = _config.transitional || transitionalDefaults;
2325
+ if (_config.timeoutErrorMessage) {
2326
+ timeoutErrorMessage = _config.timeoutErrorMessage;
2327
+ }
2328
+ reject(new AxiosError$1(
2329
+ timeoutErrorMessage,
2330
+ transitional2.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
2331
+ config,
2332
+ request
2333
+ ));
2334
+ request = null;
2335
+ };
2336
+ requestData === void 0 && requestHeaders.setContentType(null);
2337
+ if ("setRequestHeader" in request) {
2338
+ utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
2339
+ request.setRequestHeader(key, val);
2340
+ });
2341
+ }
2342
+ if (!utils$1.isUndefined(_config.withCredentials)) {
2343
+ request.withCredentials = !!_config.withCredentials;
2344
+ }
2345
+ if (responseType && responseType !== "json") {
2346
+ request.responseType = _config.responseType;
2347
+ }
2348
+ if (onDownloadProgress) {
2349
+ [downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
2350
+ request.addEventListener("progress", downloadThrottled);
2351
+ }
2352
+ if (onUploadProgress && request.upload) {
2353
+ [uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress);
2354
+ request.upload.addEventListener("progress", uploadThrottled);
2355
+ request.upload.addEventListener("loadend", flushUpload);
2356
+ }
2357
+ if (_config.cancelToken || _config.signal) {
2358
+ onCanceled = (cancel) => {
2359
+ if (!request) {
2360
+ return;
2361
+ }
2362
+ reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
2363
+ request.abort();
2364
+ request = null;
2365
+ };
2366
+ _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
2367
+ if (_config.signal) {
2368
+ _config.signal.aborted ? onCanceled() : _config.signal.addEventListener("abort", onCanceled);
2369
+ }
2370
+ }
2371
+ const protocol = parseProtocol(_config.url);
2372
+ if (protocol && platform.protocols.indexOf(protocol) === -1) {
2373
+ reject(new AxiosError$1("Unsupported protocol " + protocol + ":", AxiosError$1.ERR_BAD_REQUEST, config));
1730
2374
  return;
1731
2375
  }
1732
- m.send(o || null);
2376
+ request.send(requestData || null);
1733
2377
  });
1734
- }, Cr = (e, t) => {
1735
- const { length: n } = e = e ? e.filter(Boolean) : [];
1736
- if (t || n) {
1737
- let r = new AbortController(), s;
1738
- const o = function(l) {
1739
- if (!s) {
1740
- s = !0, c();
1741
- const u = l instanceof Error ? l : this.reason;
1742
- r.abort(u instanceof b ? u : new G(u instanceof Error ? u.message : u));
2378
+ };
2379
+ const composeSignals = (signals, timeout) => {
2380
+ const { length } = signals = signals ? signals.filter(Boolean) : [];
2381
+ if (timeout || length) {
2382
+ let controller = new AbortController();
2383
+ let aborted;
2384
+ const onabort = function(reason) {
2385
+ if (!aborted) {
2386
+ aborted = true;
2387
+ unsubscribe();
2388
+ const err = reason instanceof Error ? reason : this.reason;
2389
+ controller.abort(err instanceof AxiosError$1 ? err : new CanceledError$1(err instanceof Error ? err.message : err));
1743
2390
  }
1744
2391
  };
1745
- let i = t && setTimeout(() => {
1746
- i = null, o(new b(`timeout ${t} of ms exceeded`, b.ETIMEDOUT));
1747
- }, t);
1748
- const c = () => {
1749
- e && (i && clearTimeout(i), i = null, e.forEach((l) => {
1750
- l.unsubscribe ? l.unsubscribe(o) : l.removeEventListener("abort", o);
1751
- }), e = null);
2392
+ let timer = timeout && setTimeout(() => {
2393
+ timer = null;
2394
+ onabort(new AxiosError$1(`timeout ${timeout} of ms exceeded`, AxiosError$1.ETIMEDOUT));
2395
+ }, timeout);
2396
+ const unsubscribe = () => {
2397
+ if (signals) {
2398
+ timer && clearTimeout(timer);
2399
+ timer = null;
2400
+ signals.forEach((signal2) => {
2401
+ signal2.unsubscribe ? signal2.unsubscribe(onabort) : signal2.removeEventListener("abort", onabort);
2402
+ });
2403
+ signals = null;
2404
+ }
1752
2405
  };
1753
- e.forEach((l) => l.addEventListener("abort", o));
1754
- const { signal: d } = r;
1755
- return d.unsubscribe = () => a.asap(c), d;
1756
- }
1757
- }, kr = function* (e, t) {
1758
- let n = e.byteLength;
1759
- if (n < t) {
1760
- yield e;
2406
+ signals.forEach((signal2) => signal2.addEventListener("abort", onabort));
2407
+ const { signal } = controller;
2408
+ signal.unsubscribe = () => utils$1.asap(unsubscribe);
2409
+ return signal;
2410
+ }
2411
+ };
2412
+ const streamChunk = function* (chunk, chunkSize) {
2413
+ let len = chunk.byteLength;
2414
+ if (len < chunkSize) {
2415
+ yield chunk;
1761
2416
  return;
1762
2417
  }
1763
- let r = 0, s;
1764
- for (; r < n; )
1765
- s = r + t, yield e.slice(r, s), r = s;
1766
- }, vr = async function* (e, t) {
1767
- for await (const n of Fr(e))
1768
- yield* kr(n, t);
1769
- }, Fr = async function* (e) {
1770
- if (e[Symbol.asyncIterator]) {
1771
- yield* e;
2418
+ let pos = 0;
2419
+ let end;
2420
+ while (pos < len) {
2421
+ end = pos + chunkSize;
2422
+ yield chunk.slice(pos, end);
2423
+ pos = end;
2424
+ }
2425
+ };
2426
+ const readBytes = async function* (iterable, chunkSize) {
2427
+ for await (const chunk of readStream(iterable)) {
2428
+ yield* streamChunk(chunk, chunkSize);
2429
+ }
2430
+ };
2431
+ const readStream = async function* (stream) {
2432
+ if (stream[Symbol.asyncIterator]) {
2433
+ yield* stream;
1772
2434
  return;
1773
2435
  }
1774
- const t = e.getReader();
2436
+ const reader = stream.getReader();
1775
2437
  try {
1776
2438
  for (; ; ) {
1777
- const { done: n, value: r } = await t.read();
1778
- if (n)
2439
+ const { done, value } = await reader.read();
2440
+ if (done) {
1779
2441
  break;
1780
- yield r;
2442
+ }
2443
+ yield value;
1781
2444
  }
1782
2445
  } finally {
1783
- await t.cancel();
2446
+ await reader.cancel();
1784
2447
  }
1785
- }, it = (e, t, n, r) => {
1786
- const s = vr(e, t);
1787
- let o = 0, i, c = (d) => {
1788
- i || (i = !0, r && r(d));
2448
+ };
2449
+ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
2450
+ const iterator2 = readBytes(stream, chunkSize);
2451
+ let bytes = 0;
2452
+ let done;
2453
+ let _onFinish = (e2) => {
2454
+ if (!done) {
2455
+ done = true;
2456
+ onFinish && onFinish(e2);
2457
+ }
1789
2458
  };
1790
2459
  return new ReadableStream({
1791
- async pull(d) {
2460
+ async pull(controller) {
1792
2461
  try {
1793
- const { done: l, value: u } = await s.next();
1794
- if (l) {
1795
- c(), d.close();
2462
+ const { done: done2, value } = await iterator2.next();
2463
+ if (done2) {
2464
+ _onFinish();
2465
+ controller.close();
1796
2466
  return;
1797
2467
  }
1798
- let p = u.byteLength;
1799
- if (n) {
1800
- let y = o += p;
1801
- n(y);
2468
+ let len = value.byteLength;
2469
+ if (onProgress) {
2470
+ let loadedBytes = bytes += len;
2471
+ onProgress(loadedBytes);
1802
2472
  }
1803
- d.enqueue(new Uint8Array(u));
1804
- } catch (l) {
1805
- throw c(l), l;
2473
+ controller.enqueue(new Uint8Array(value));
2474
+ } catch (err) {
2475
+ _onFinish(err);
2476
+ throw err;
1806
2477
  }
1807
2478
  },
1808
- cancel(d) {
1809
- return c(d), s.return();
2479
+ cancel(reason) {
2480
+ _onFinish(reason);
2481
+ return iterator2.return();
1810
2482
  }
1811
2483
  }, {
1812
2484
  highWaterMark: 2
1813
2485
  });
1814
- }, we = typeof fetch == "function" && typeof Request == "function" && typeof Response == "function", Ut = we && typeof ReadableStream == "function", jr = we && (typeof TextEncoder == "function" ? /* @__PURE__ */ ((e) => (t) => e.encode(t))(new TextEncoder()) : async (e) => new Uint8Array(await new Response(e).arrayBuffer())), Dt = (e, ...t) => {
2486
+ };
2487
+ const isFetchSupported = typeof fetch === "function" && typeof Request === "function" && typeof Response === "function";
2488
+ const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === "function";
2489
+ const encodeText = isFetchSupported && (typeof TextEncoder === "function" ? /* @__PURE__ */ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) : async (str) => new Uint8Array(await new Response(str).arrayBuffer()));
2490
+ const test = (fn, ...args) => {
1815
2491
  try {
1816
- return !!e(...t);
1817
- } catch {
1818
- return !1;
2492
+ return !!fn(...args);
2493
+ } catch (e2) {
2494
+ return false;
1819
2495
  }
1820
- }, Lr = Ut && Dt(() => {
1821
- let e = !1;
1822
- const t = new Request(v.origin, {
2496
+ };
2497
+ const supportsRequestStream = isReadableStreamSupported && test(() => {
2498
+ let duplexAccessed = false;
2499
+ const hasContentType = new Request(platform.origin, {
1823
2500
  body: new ReadableStream(),
1824
2501
  method: "POST",
1825
2502
  get duplex() {
1826
- return e = !0, "half";
2503
+ duplexAccessed = true;
2504
+ return "half";
1827
2505
  }
1828
2506
  }).headers.has("Content-Type");
1829
- return e && !t;
1830
- }), at = 64 * 1024, Fe = Ut && Dt(() => a.isReadableStream(new Response("").body)), he = {
1831
- stream: Fe && ((e) => e.body)
2507
+ return duplexAccessed && !hasContentType;
2508
+ });
2509
+ const DEFAULT_CHUNK_SIZE = 64 * 1024;
2510
+ const supportsResponseStream = isReadableStreamSupported && test(() => utils$1.isReadableStream(new Response("").body));
2511
+ const resolvers = {
2512
+ stream: supportsResponseStream && ((res) => res.body)
1832
2513
  };
1833
- we && ((e) => {
1834
- ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((t) => {
1835
- !he[t] && (he[t] = a.isFunction(e[t]) ? (n) => n[t]() : (n, r) => {
1836
- throw new b(`Response type '${t}' is not supported`, b.ERR_NOT_SUPPORT, r);
2514
+ isFetchSupported && ((res) => {
2515
+ ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((type) => {
2516
+ !resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res2) => res2[type]() : (_, config) => {
2517
+ throw new AxiosError$1(`Response type '${type}' is not supported`, AxiosError$1.ERR_NOT_SUPPORT, config);
1837
2518
  });
1838
2519
  });
1839
2520
  })(new Response());
1840
- const Ur = async (e) => {
1841
- if (e == null)
2521
+ const getBodyLength = async (body) => {
2522
+ if (body == null) {
1842
2523
  return 0;
1843
- if (a.isBlob(e))
1844
- return e.size;
1845
- if (a.isSpecCompliantForm(e))
1846
- return (await new Request(v.origin, {
2524
+ }
2525
+ if (utils$1.isBlob(body)) {
2526
+ return body.size;
2527
+ }
2528
+ if (utils$1.isSpecCompliantForm(body)) {
2529
+ const _request = new Request(platform.origin, {
1847
2530
  method: "POST",
1848
- body: e
1849
- }).arrayBuffer()).byteLength;
1850
- if (a.isArrayBufferView(e) || a.isArrayBuffer(e))
1851
- return e.byteLength;
1852
- if (a.isURLSearchParams(e) && (e = e + ""), a.isString(e))
1853
- return (await jr(e)).byteLength;
1854
- }, Dr = async (e, t) => {
1855
- const n = a.toFiniteNumber(e.getContentLength());
1856
- return n ?? Ur(t);
1857
- }, Br = we && (async (e) => {
2531
+ body
2532
+ });
2533
+ return (await _request.arrayBuffer()).byteLength;
2534
+ }
2535
+ if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
2536
+ return body.byteLength;
2537
+ }
2538
+ if (utils$1.isURLSearchParams(body)) {
2539
+ body = body + "";
2540
+ }
2541
+ if (utils$1.isString(body)) {
2542
+ return (await encodeText(body)).byteLength;
2543
+ }
2544
+ };
2545
+ const resolveBodyLength = async (headers, body) => {
2546
+ const length = utils$1.toFiniteNumber(headers.getContentLength());
2547
+ return length == null ? getBodyLength(body) : length;
2548
+ };
2549
+ const fetchAdapter = isFetchSupported && (async (config) => {
1858
2550
  let {
1859
- url: t,
1860
- method: n,
1861
- data: r,
1862
- signal: s,
1863
- cancelToken: o,
1864
- timeout: i,
1865
- onDownloadProgress: c,
1866
- onUploadProgress: d,
1867
- responseType: l,
1868
- headers: u,
1869
- withCredentials: p = "same-origin",
1870
- fetchOptions: y
1871
- } = Lt(e);
1872
- l = l ? (l + "").toLowerCase() : "text";
1873
- let T = Cr([s, o && o.toAbortSignal()], i), h;
1874
- const R = T && T.unsubscribe && (() => {
1875
- T.unsubscribe();
2551
+ url,
2552
+ method,
2553
+ data,
2554
+ signal,
2555
+ cancelToken,
2556
+ timeout,
2557
+ onDownloadProgress,
2558
+ onUploadProgress,
2559
+ responseType,
2560
+ headers,
2561
+ withCredentials = "same-origin",
2562
+ fetchOptions
2563
+ } = resolveConfig(config);
2564
+ responseType = responseType ? (responseType + "").toLowerCase() : "text";
2565
+ let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
2566
+ let request;
2567
+ const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
2568
+ composedSignal.unsubscribe();
1876
2569
  });
1877
- let m;
2570
+ let requestContentLength;
1878
2571
  try {
1879
- if (d && Lr && n !== "get" && n !== "head" && (m = await Dr(u, r)) !== 0) {
1880
- let g = new Request(t, {
2572
+ if (onUploadProgress && supportsRequestStream && method !== "get" && method !== "head" && (requestContentLength = await resolveBodyLength(headers, data)) !== 0) {
2573
+ let _request = new Request(url, {
1881
2574
  method: "POST",
1882
- body: r,
2575
+ body: data,
1883
2576
  duplex: "half"
1884
- }), x;
1885
- if (a.isFormData(r) && (x = g.headers.get("content-type")) && u.setContentType(x), g.body) {
1886
- const [N, B] = rt(
1887
- m,
1888
- pe(st(d))
2577
+ });
2578
+ let contentTypeHeader;
2579
+ if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get("content-type"))) {
2580
+ headers.setContentType(contentTypeHeader);
2581
+ }
2582
+ if (_request.body) {
2583
+ const [onProgress, flush] = progressEventDecorator(
2584
+ requestContentLength,
2585
+ progressEventReducer(asyncDecorator(onUploadProgress))
1889
2586
  );
1890
- r = it(g.body, at, N, B);
2587
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
1891
2588
  }
1892
2589
  }
1893
- a.isString(p) || (p = p ? "include" : "omit");
1894
- const S = "credentials" in Request.prototype;
1895
- h = new Request(t, {
1896
- ...y,
1897
- signal: T,
1898
- method: n.toUpperCase(),
1899
- headers: u.normalize().toJSON(),
1900
- body: r,
2590
+ if (!utils$1.isString(withCredentials)) {
2591
+ withCredentials = withCredentials ? "include" : "omit";
2592
+ }
2593
+ const isCredentialsSupported = "credentials" in Request.prototype;
2594
+ request = new Request(url, {
2595
+ ...fetchOptions,
2596
+ signal: composedSignal,
2597
+ method: method.toUpperCase(),
2598
+ headers: headers.normalize().toJSON(),
2599
+ body: data,
1901
2600
  duplex: "half",
1902
- credentials: S ? p : void 0
2601
+ credentials: isCredentialsSupported ? withCredentials : void 0
1903
2602
  });
1904
- let A = await fetch(h);
1905
- const E = Fe && (l === "stream" || l === "response");
1906
- if (Fe && (c || E && R)) {
1907
- const g = {};
1908
- ["status", "statusText", "headers"].forEach((j) => {
1909
- g[j] = A[j];
2603
+ let response = await fetch(request);
2604
+ const isStreamResponse = supportsResponseStream && (responseType === "stream" || responseType === "response");
2605
+ if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
2606
+ const options = {};
2607
+ ["status", "statusText", "headers"].forEach((prop) => {
2608
+ options[prop] = response[prop];
1910
2609
  });
1911
- const x = a.toFiniteNumber(A.headers.get("content-length")), [N, B] = c && rt(
1912
- x,
1913
- pe(st(c), !0)
2610
+ const responseContentLength = utils$1.toFiniteNumber(response.headers.get("content-length"));
2611
+ const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
2612
+ responseContentLength,
2613
+ progressEventReducer(asyncDecorator(onDownloadProgress), true)
1914
2614
  ) || [];
1915
- A = new Response(
1916
- it(A.body, at, N, () => {
1917
- B && B(), R && R();
2615
+ response = new Response(
2616
+ trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
2617
+ flush && flush();
2618
+ unsubscribe && unsubscribe();
1918
2619
  }),
1919
- g
2620
+ options
1920
2621
  );
1921
2622
  }
1922
- l = l || "text";
1923
- let O = await he[a.findKey(he, l) || "text"](A, e);
1924
- return !E && R && R(), await new Promise((g, x) => {
1925
- Ft(g, x, {
1926
- data: O,
1927
- headers: U.from(A.headers),
1928
- status: A.status,
1929
- statusText: A.statusText,
1930
- config: e,
1931
- request: h
2623
+ responseType = responseType || "text";
2624
+ let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || "text"](response, config);
2625
+ !isStreamResponse && unsubscribe && unsubscribe();
2626
+ return await new Promise((resolve, reject) => {
2627
+ settle(resolve, reject, {
2628
+ data: responseData,
2629
+ headers: AxiosHeaders$1.from(response.headers),
2630
+ status: response.status,
2631
+ statusText: response.statusText,
2632
+ config,
2633
+ request
1932
2634
  });
1933
2635
  });
1934
- } catch (S) {
1935
- throw R && R(), S && S.name === "TypeError" && /Load failed|fetch/i.test(S.message) ? Object.assign(
1936
- new b("Network Error", b.ERR_NETWORK, e, h),
1937
- {
1938
- cause: S.cause || S
1939
- }
1940
- ) : b.from(S, S && S.code, e, h);
2636
+ } catch (err) {
2637
+ unsubscribe && unsubscribe();
2638
+ if (err && err.name === "TypeError" && /Load failed|fetch/i.test(err.message)) {
2639
+ throw Object.assign(
2640
+ new AxiosError$1("Network Error", AxiosError$1.ERR_NETWORK, config, request),
2641
+ {
2642
+ cause: err.cause || err
2643
+ }
2644
+ );
2645
+ }
2646
+ throw AxiosError$1.from(err, err && err.code, config, request);
1941
2647
  }
1942
- }), je = {
1943
- http: Qn,
1944
- xhr: Nr,
1945
- fetch: Br
2648
+ });
2649
+ const knownAdapters = {
2650
+ http: httpAdapter,
2651
+ xhr: xhrAdapter,
2652
+ fetch: fetchAdapter
1946
2653
  };
1947
- a.forEach(je, (e, t) => {
1948
- if (e) {
2654
+ utils$1.forEach(knownAdapters, (fn, value) => {
2655
+ if (fn) {
1949
2656
  try {
1950
- Object.defineProperty(e, "name", { value: t });
1951
- } catch {
2657
+ Object.defineProperty(fn, "name", { value });
2658
+ } catch (e2) {
1952
2659
  }
1953
- Object.defineProperty(e, "adapterName", { value: t });
2660
+ Object.defineProperty(fn, "adapterName", { value });
1954
2661
  }
1955
2662
  });
1956
- const ct = (e) => `- ${e}`, qr = (e) => a.isFunction(e) || e === null || e === !1, Bt = {
1957
- getAdapter: (e) => {
1958
- e = a.isArray(e) ? e : [e];
1959
- const { length: t } = e;
1960
- let n, r;
1961
- const s = {};
1962
- for (let o = 0; o < t; o++) {
1963
- n = e[o];
1964
- let i;
1965
- if (r = n, !qr(n) && (r = je[(i = String(n)).toLowerCase()], r === void 0))
1966
- throw new b(`Unknown adapter '${i}'`);
1967
- if (r)
2663
+ const renderReason = (reason) => `- ${reason}`;
2664
+ const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
2665
+ const adapters = {
2666
+ getAdapter: (adapters2) => {
2667
+ adapters2 = utils$1.isArray(adapters2) ? adapters2 : [adapters2];
2668
+ const { length } = adapters2;
2669
+ let nameOrAdapter;
2670
+ let adapter;
2671
+ const rejectedReasons = {};
2672
+ for (let i2 = 0; i2 < length; i2++) {
2673
+ nameOrAdapter = adapters2[i2];
2674
+ let id;
2675
+ adapter = nameOrAdapter;
2676
+ if (!isResolvedHandle(nameOrAdapter)) {
2677
+ adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
2678
+ if (adapter === void 0) {
2679
+ throw new AxiosError$1(`Unknown adapter '${id}'`);
2680
+ }
2681
+ }
2682
+ if (adapter) {
1968
2683
  break;
1969
- s[i || "#" + o] = r;
2684
+ }
2685
+ rejectedReasons[id || "#" + i2] = adapter;
1970
2686
  }
1971
- if (!r) {
1972
- const o = Object.entries(s).map(
1973
- ([c, d]) => `adapter ${c} ` + (d === !1 ? "is not supported by the environment" : "is not available in the build")
2687
+ if (!adapter) {
2688
+ const reasons = Object.entries(rejectedReasons).map(
2689
+ ([id, state]) => `adapter ${id} ` + (state === false ? "is not supported by the environment" : "is not available in the build")
1974
2690
  );
1975
- let i = t ? o.length > 1 ? `since :
1976
- ` + o.map(ct).join(`
1977
- `) : " " + ct(o[0]) : "as no adapter specified";
1978
- throw new b(
1979
- "There is no suitable adapter to dispatch the request " + i,
2691
+ let s2 = length ? reasons.length > 1 ? "since :\n" + reasons.map(renderReason).join("\n") : " " + renderReason(reasons[0]) : "as no adapter specified";
2692
+ throw new AxiosError$1(
2693
+ `There is no suitable adapter to dispatch the request ` + s2,
1980
2694
  "ERR_NOT_SUPPORT"
1981
2695
  );
1982
2696
  }
1983
- return r;
2697
+ return adapter;
1984
2698
  },
1985
- adapters: je
2699
+ adapters: knownAdapters
1986
2700
  };
1987
- function Ne(e) {
1988
- if (e.cancelToken && e.cancelToken.throwIfRequested(), e.signal && e.signal.aborted)
1989
- throw new G(null, e);
2701
+ function throwIfCancellationRequested(config) {
2702
+ if (config.cancelToken) {
2703
+ config.cancelToken.throwIfRequested();
2704
+ }
2705
+ if (config.signal && config.signal.aborted) {
2706
+ throw new CanceledError$1(null, config);
2707
+ }
1990
2708
  }
1991
- function lt(e) {
1992
- return Ne(e), e.headers = U.from(e.headers), e.data = xe.call(
1993
- e,
1994
- e.transformRequest
1995
- ), ["post", "put", "patch"].indexOf(e.method) !== -1 && e.headers.setContentType("application/x-www-form-urlencoded", !1), Bt.getAdapter(e.adapter || ae.adapter)(e).then(function(r) {
1996
- return Ne(e), r.data = xe.call(
1997
- e,
1998
- e.transformResponse,
1999
- r
2000
- ), r.headers = U.from(r.headers), r;
2001
- }, function(r) {
2002
- return vt(r) || (Ne(e), r && r.response && (r.response.data = xe.call(
2003
- e,
2004
- e.transformResponse,
2005
- r.response
2006
- ), r.response.headers = U.from(r.response.headers))), Promise.reject(r);
2709
+ function dispatchRequest(config) {
2710
+ throwIfCancellationRequested(config);
2711
+ config.headers = AxiosHeaders$1.from(config.headers);
2712
+ config.data = transformData.call(
2713
+ config,
2714
+ config.transformRequest
2715
+ );
2716
+ if (["post", "put", "patch"].indexOf(config.method) !== -1) {
2717
+ config.headers.setContentType("application/x-www-form-urlencoded", false);
2718
+ }
2719
+ const adapter = adapters.getAdapter(config.adapter || defaults.adapter);
2720
+ return adapter(config).then(function onAdapterResolution(response) {
2721
+ throwIfCancellationRequested(config);
2722
+ response.data = transformData.call(
2723
+ config,
2724
+ config.transformResponse,
2725
+ response
2726
+ );
2727
+ response.headers = AxiosHeaders$1.from(response.headers);
2728
+ return response;
2729
+ }, function onAdapterRejection(reason) {
2730
+ if (!isCancel$1(reason)) {
2731
+ throwIfCancellationRequested(config);
2732
+ if (reason && reason.response) {
2733
+ reason.response.data = transformData.call(
2734
+ config,
2735
+ config.transformResponse,
2736
+ reason.response
2737
+ );
2738
+ reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
2739
+ }
2740
+ }
2741
+ return Promise.reject(reason);
2007
2742
  });
2008
2743
  }
2009
- const qt = "1.9.0", Te = {};
2010
- ["object", "boolean", "number", "function", "string", "symbol"].forEach((e, t) => {
2011
- Te[e] = function(r) {
2012
- return typeof r === e || "a" + (t < 1 ? "n " : " ") + e;
2744
+ const VERSION$1 = "1.9.0";
2745
+ const validators$1 = {};
2746
+ ["object", "boolean", "number", "function", "string", "symbol"].forEach((type, i2) => {
2747
+ validators$1[type] = function validator2(thing) {
2748
+ return typeof thing === type || "a" + (i2 < 1 ? "n " : " ") + type;
2013
2749
  };
2014
2750
  });
2015
- const ut = {};
2016
- Te.transitional = function(t, n, r) {
2017
- function s(o, i) {
2018
- return "[Axios v" + qt + "] Transitional option '" + o + "'" + i + (r ? ". " + r : "");
2019
- }
2020
- return (o, i, c) => {
2021
- if (t === !1)
2022
- throw new b(
2023
- s(i, " has been removed" + (n ? " in " + n : "")),
2024
- b.ERR_DEPRECATED
2751
+ const deprecatedWarnings = {};
2752
+ validators$1.transitional = function transitional(validator2, version, message) {
2753
+ function formatMessage(opt, desc) {
2754
+ return "[Axios v" + VERSION$1 + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
2755
+ }
2756
+ return (value, opt, opts) => {
2757
+ if (validator2 === false) {
2758
+ throw new AxiosError$1(
2759
+ formatMessage(opt, " has been removed" + (version ? " in " + version : "")),
2760
+ AxiosError$1.ERR_DEPRECATED
2025
2761
  );
2026
- return n && !ut[i] && (ut[i] = !0, console.warn(
2027
- s(
2028
- i,
2029
- " has been deprecated since v" + n + " and will be removed in the near future"
2030
- )
2031
- )), t ? t(o, i, c) : !0;
2762
+ }
2763
+ if (version && !deprecatedWarnings[opt]) {
2764
+ deprecatedWarnings[opt] = true;
2765
+ console.warn(
2766
+ formatMessage(
2767
+ opt,
2768
+ " has been deprecated since v" + version + " and will be removed in the near future"
2769
+ )
2770
+ );
2771
+ }
2772
+ return validator2 ? validator2(value, opt, opts) : true;
2032
2773
  };
2033
2774
  };
2034
- Te.spelling = function(t) {
2035
- return (n, r) => (console.warn(`${r} is likely a misspelling of ${t}`), !0);
2775
+ validators$1.spelling = function spelling(correctSpelling) {
2776
+ return (value, opt) => {
2777
+ console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
2778
+ return true;
2779
+ };
2036
2780
  };
2037
- function Ir(e, t, n) {
2038
- if (typeof e != "object")
2039
- throw new b("options must be an object", b.ERR_BAD_OPTION_VALUE);
2040
- const r = Object.keys(e);
2041
- let s = r.length;
2042
- for (; s-- > 0; ) {
2043
- const o = r[s], i = t[o];
2044
- if (i) {
2045
- const c = e[o], d = c === void 0 || i(c, o, e);
2046
- if (d !== !0)
2047
- throw new b("option " + o + " must be " + d, b.ERR_BAD_OPTION_VALUE);
2781
+ function assertOptions(options, schema, allowUnknown) {
2782
+ if (typeof options !== "object") {
2783
+ throw new AxiosError$1("options must be an object", AxiosError$1.ERR_BAD_OPTION_VALUE);
2784
+ }
2785
+ const keys = Object.keys(options);
2786
+ let i2 = keys.length;
2787
+ while (i2-- > 0) {
2788
+ const opt = keys[i2];
2789
+ const validator2 = schema[opt];
2790
+ if (validator2) {
2791
+ const value = options[opt];
2792
+ const result = value === void 0 || validator2(value, opt, options);
2793
+ if (result !== true) {
2794
+ throw new AxiosError$1("option " + opt + " must be " + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
2795
+ }
2048
2796
  continue;
2049
2797
  }
2050
- if (n !== !0)
2051
- throw new b("Unknown option " + o, b.ERR_BAD_OPTION);
2798
+ if (allowUnknown !== true) {
2799
+ throw new AxiosError$1("Unknown option " + opt, AxiosError$1.ERR_BAD_OPTION);
2800
+ }
2052
2801
  }
2053
2802
  }
2054
- const fe = {
2055
- assertOptions: Ir,
2056
- validators: Te
2057
- }, I = fe.validators;
2058
- let J = class {
2059
- constructor(t) {
2060
- this.defaults = t || {}, this.interceptors = {
2061
- request: new tt(),
2062
- response: new tt()
2803
+ const validator = {
2804
+ assertOptions,
2805
+ validators: validators$1
2806
+ };
2807
+ const validators = validator.validators;
2808
+ let Axios$1 = class Axios {
2809
+ constructor(instanceConfig) {
2810
+ this.defaults = instanceConfig || {};
2811
+ this.interceptors = {
2812
+ request: new InterceptorManager(),
2813
+ response: new InterceptorManager()
2063
2814
  };
2064
2815
  }
2065
2816
  /**
@@ -2070,197 +2821,263 @@ let J = class {
2070
2821
  *
2071
2822
  * @returns {Promise} The Promise to be fulfilled
2072
2823
  */
2073
- async request(t, n) {
2824
+ async request(configOrUrl, config) {
2074
2825
  try {
2075
- return await this._request(t, n);
2076
- } catch (r) {
2077
- if (r instanceof Error) {
2078
- let s = {};
2079
- Error.captureStackTrace ? Error.captureStackTrace(s) : s = new Error();
2080
- const o = s.stack ? s.stack.replace(/^.+\n/, "") : "";
2826
+ return await this._request(configOrUrl, config);
2827
+ } catch (err) {
2828
+ if (err instanceof Error) {
2829
+ let dummy = {};
2830
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
2831
+ const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, "") : "";
2081
2832
  try {
2082
- r.stack ? o && !String(r.stack).endsWith(o.replace(/^.+\n.+\n/, "")) && (r.stack += `
2083
- ` + o) : r.stack = o;
2084
- } catch {
2833
+ if (!err.stack) {
2834
+ err.stack = stack;
2835
+ } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ""))) {
2836
+ err.stack += "\n" + stack;
2837
+ }
2838
+ } catch (e2) {
2085
2839
  }
2086
2840
  }
2087
- throw r;
2088
- }
2089
- }
2090
- _request(t, n) {
2091
- typeof t == "string" ? (n = n || {}, n.url = t) : n = t || {}, n = W(this.defaults, n);
2092
- const { transitional: r, paramsSerializer: s, headers: o } = n;
2093
- r !== void 0 && fe.assertOptions(r, {
2094
- silentJSONParsing: I.transitional(I.boolean),
2095
- forcedJSONParsing: I.transitional(I.boolean),
2096
- clarifyTimeoutError: I.transitional(I.boolean)
2097
- }, !1), s != null && (a.isFunction(s) ? n.paramsSerializer = {
2098
- serialize: s
2099
- } : fe.assertOptions(s, {
2100
- encode: I.function,
2101
- serialize: I.function
2102
- }, !0)), n.allowAbsoluteUrls !== void 0 || (this.defaults.allowAbsoluteUrls !== void 0 ? n.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls : n.allowAbsoluteUrls = !0), fe.assertOptions(n, {
2103
- baseUrl: I.spelling("baseURL"),
2104
- withXsrfToken: I.spelling("withXSRFToken")
2105
- }, !0), n.method = (n.method || this.defaults.method || "get").toLowerCase();
2106
- let i = o && a.merge(
2107
- o.common,
2108
- o[n.method]
2841
+ throw err;
2842
+ }
2843
+ }
2844
+ _request(configOrUrl, config) {
2845
+ if (typeof configOrUrl === "string") {
2846
+ config = config || {};
2847
+ config.url = configOrUrl;
2848
+ } else {
2849
+ config = configOrUrl || {};
2850
+ }
2851
+ config = mergeConfig$1(this.defaults, config);
2852
+ const { transitional: transitional2, paramsSerializer, headers } = config;
2853
+ if (transitional2 !== void 0) {
2854
+ validator.assertOptions(transitional2, {
2855
+ silentJSONParsing: validators.transitional(validators.boolean),
2856
+ forcedJSONParsing: validators.transitional(validators.boolean),
2857
+ clarifyTimeoutError: validators.transitional(validators.boolean)
2858
+ }, false);
2859
+ }
2860
+ if (paramsSerializer != null) {
2861
+ if (utils$1.isFunction(paramsSerializer)) {
2862
+ config.paramsSerializer = {
2863
+ serialize: paramsSerializer
2864
+ };
2865
+ } else {
2866
+ validator.assertOptions(paramsSerializer, {
2867
+ encode: validators.function,
2868
+ serialize: validators.function
2869
+ }, true);
2870
+ }
2871
+ }
2872
+ if (config.allowAbsoluteUrls !== void 0) ;
2873
+ else if (this.defaults.allowAbsoluteUrls !== void 0) {
2874
+ config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
2875
+ } else {
2876
+ config.allowAbsoluteUrls = true;
2877
+ }
2878
+ validator.assertOptions(config, {
2879
+ baseUrl: validators.spelling("baseURL"),
2880
+ withXsrfToken: validators.spelling("withXSRFToken")
2881
+ }, true);
2882
+ config.method = (config.method || this.defaults.method || "get").toLowerCase();
2883
+ let contextHeaders = headers && utils$1.merge(
2884
+ headers.common,
2885
+ headers[config.method]
2109
2886
  );
2110
- o && a.forEach(
2887
+ headers && utils$1.forEach(
2111
2888
  ["delete", "get", "head", "post", "put", "patch", "common"],
2112
- (h) => {
2113
- delete o[h];
2889
+ (method) => {
2890
+ delete headers[method];
2891
+ }
2892
+ );
2893
+ config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
2894
+ const requestInterceptorChain = [];
2895
+ let synchronousRequestInterceptors = true;
2896
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
2897
+ if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config) === false) {
2898
+ return;
2114
2899
  }
2115
- ), n.headers = U.concat(i, o);
2116
- const c = [];
2117
- let d = !0;
2118
- this.interceptors.request.forEach(function(R) {
2119
- typeof R.runWhen == "function" && R.runWhen(n) === !1 || (d = d && R.synchronous, c.unshift(R.fulfilled, R.rejected));
2900
+ synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
2901
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
2120
2902
  });
2121
- const l = [];
2122
- this.interceptors.response.forEach(function(R) {
2123
- l.push(R.fulfilled, R.rejected);
2903
+ const responseInterceptorChain = [];
2904
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
2905
+ responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
2124
2906
  });
2125
- let u, p = 0, y;
2126
- if (!d) {
2127
- const h = [lt.bind(this), void 0];
2128
- for (h.unshift.apply(h, c), h.push.apply(h, l), y = h.length, u = Promise.resolve(n); p < y; )
2129
- u = u.then(h[p++], h[p++]);
2130
- return u;
2131
- }
2132
- y = c.length;
2133
- let T = n;
2134
- for (p = 0; p < y; ) {
2135
- const h = c[p++], R = c[p++];
2907
+ let promise;
2908
+ let i2 = 0;
2909
+ let len;
2910
+ if (!synchronousRequestInterceptors) {
2911
+ const chain = [dispatchRequest.bind(this), void 0];
2912
+ chain.unshift.apply(chain, requestInterceptorChain);
2913
+ chain.push.apply(chain, responseInterceptorChain);
2914
+ len = chain.length;
2915
+ promise = Promise.resolve(config);
2916
+ while (i2 < len) {
2917
+ promise = promise.then(chain[i2++], chain[i2++]);
2918
+ }
2919
+ return promise;
2920
+ }
2921
+ len = requestInterceptorChain.length;
2922
+ let newConfig = config;
2923
+ i2 = 0;
2924
+ while (i2 < len) {
2925
+ const onFulfilled = requestInterceptorChain[i2++];
2926
+ const onRejected = requestInterceptorChain[i2++];
2136
2927
  try {
2137
- T = h(T);
2138
- } catch (m) {
2139
- R.call(this, m);
2928
+ newConfig = onFulfilled(newConfig);
2929
+ } catch (error) {
2930
+ onRejected.call(this, error);
2140
2931
  break;
2141
2932
  }
2142
2933
  }
2143
2934
  try {
2144
- u = lt.call(this, T);
2145
- } catch (h) {
2146
- return Promise.reject(h);
2935
+ promise = dispatchRequest.call(this, newConfig);
2936
+ } catch (error) {
2937
+ return Promise.reject(error);
2147
2938
  }
2148
- for (p = 0, y = l.length; p < y; )
2149
- u = u.then(l[p++], l[p++]);
2150
- return u;
2939
+ i2 = 0;
2940
+ len = responseInterceptorChain.length;
2941
+ while (i2 < len) {
2942
+ promise = promise.then(responseInterceptorChain[i2++], responseInterceptorChain[i2++]);
2943
+ }
2944
+ return promise;
2151
2945
  }
2152
- getUri(t) {
2153
- t = W(this.defaults, t);
2154
- const n = jt(t.baseURL, t.url, t.allowAbsoluteUrls);
2155
- return Nt(n, t.params, t.paramsSerializer);
2946
+ getUri(config) {
2947
+ config = mergeConfig$1(this.defaults, config);
2948
+ const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
2949
+ return buildURL(fullPath, config.params, config.paramsSerializer);
2156
2950
  }
2157
2951
  };
2158
- a.forEach(["delete", "get", "head", "options"], function(t) {
2159
- J.prototype[t] = function(n, r) {
2160
- return this.request(W(r || {}, {
2161
- method: t,
2162
- url: n,
2163
- data: (r || {}).data
2952
+ utils$1.forEach(["delete", "get", "head", "options"], function forEachMethodNoData(method) {
2953
+ Axios$1.prototype[method] = function(url, config) {
2954
+ return this.request(mergeConfig$1(config || {}, {
2955
+ method,
2956
+ url,
2957
+ data: (config || {}).data
2164
2958
  }));
2165
2959
  };
2166
2960
  });
2167
- a.forEach(["post", "put", "patch"], function(t) {
2168
- function n(r) {
2169
- return function(o, i, c) {
2170
- return this.request(W(c || {}, {
2171
- method: t,
2172
- headers: r ? {
2961
+ utils$1.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
2962
+ function generateHTTPMethod(isForm) {
2963
+ return function httpMethod(url, data, config) {
2964
+ return this.request(mergeConfig$1(config || {}, {
2965
+ method,
2966
+ headers: isForm ? {
2173
2967
  "Content-Type": "multipart/form-data"
2174
2968
  } : {},
2175
- url: o,
2176
- data: i
2969
+ url,
2970
+ data
2177
2971
  }));
2178
2972
  };
2179
2973
  }
2180
- J.prototype[t] = n(), J.prototype[t + "Form"] = n(!0);
2974
+ Axios$1.prototype[method] = generateHTTPMethod();
2975
+ Axios$1.prototype[method + "Form"] = generateHTTPMethod(true);
2181
2976
  });
2182
- let $r = class It {
2183
- constructor(t) {
2184
- if (typeof t != "function")
2977
+ let CancelToken$1 = class CancelToken {
2978
+ constructor(executor) {
2979
+ if (typeof executor !== "function") {
2185
2980
  throw new TypeError("executor must be a function.");
2186
- let n;
2187
- this.promise = new Promise(function(o) {
2188
- n = o;
2981
+ }
2982
+ let resolvePromise;
2983
+ this.promise = new Promise(function promiseExecutor(resolve) {
2984
+ resolvePromise = resolve;
2189
2985
  });
2190
- const r = this;
2191
- this.promise.then((s) => {
2192
- if (!r._listeners) return;
2193
- let o = r._listeners.length;
2194
- for (; o-- > 0; )
2195
- r._listeners[o](s);
2196
- r._listeners = null;
2197
- }), this.promise.then = (s) => {
2198
- let o;
2199
- const i = new Promise((c) => {
2200
- r.subscribe(c), o = c;
2201
- }).then(s);
2202
- return i.cancel = function() {
2203
- r.unsubscribe(o);
2204
- }, i;
2205
- }, t(function(o, i, c) {
2206
- r.reason || (r.reason = new G(o, i, c), n(r.reason));
2986
+ const token = this;
2987
+ this.promise.then((cancel) => {
2988
+ if (!token._listeners) return;
2989
+ let i2 = token._listeners.length;
2990
+ while (i2-- > 0) {
2991
+ token._listeners[i2](cancel);
2992
+ }
2993
+ token._listeners = null;
2994
+ });
2995
+ this.promise.then = (onfulfilled) => {
2996
+ let _resolve;
2997
+ const promise = new Promise((resolve) => {
2998
+ token.subscribe(resolve);
2999
+ _resolve = resolve;
3000
+ }).then(onfulfilled);
3001
+ promise.cancel = function reject() {
3002
+ token.unsubscribe(_resolve);
3003
+ };
3004
+ return promise;
3005
+ };
3006
+ executor(function cancel(message, config, request) {
3007
+ if (token.reason) {
3008
+ return;
3009
+ }
3010
+ token.reason = new CanceledError$1(message, config, request);
3011
+ resolvePromise(token.reason);
2207
3012
  });
2208
3013
  }
2209
3014
  /**
2210
3015
  * Throws a `CanceledError` if cancellation has been requested.
2211
3016
  */
2212
3017
  throwIfRequested() {
2213
- if (this.reason)
3018
+ if (this.reason) {
2214
3019
  throw this.reason;
3020
+ }
2215
3021
  }
2216
3022
  /**
2217
3023
  * Subscribe to the cancel signal
2218
3024
  */
2219
- subscribe(t) {
3025
+ subscribe(listener) {
2220
3026
  if (this.reason) {
2221
- t(this.reason);
3027
+ listener(this.reason);
2222
3028
  return;
2223
3029
  }
2224
- this._listeners ? this._listeners.push(t) : this._listeners = [t];
3030
+ if (this._listeners) {
3031
+ this._listeners.push(listener);
3032
+ } else {
3033
+ this._listeners = [listener];
3034
+ }
2225
3035
  }
2226
3036
  /**
2227
3037
  * Unsubscribe from the cancel signal
2228
3038
  */
2229
- unsubscribe(t) {
2230
- if (!this._listeners)
3039
+ unsubscribe(listener) {
3040
+ if (!this._listeners) {
2231
3041
  return;
2232
- const n = this._listeners.indexOf(t);
2233
- n !== -1 && this._listeners.splice(n, 1);
3042
+ }
3043
+ const index = this._listeners.indexOf(listener);
3044
+ if (index !== -1) {
3045
+ this._listeners.splice(index, 1);
3046
+ }
2234
3047
  }
2235
3048
  toAbortSignal() {
2236
- const t = new AbortController(), n = (r) => {
2237
- t.abort(r);
3049
+ const controller = new AbortController();
3050
+ const abort = (err) => {
3051
+ controller.abort(err);
2238
3052
  };
2239
- return this.subscribe(n), t.signal.unsubscribe = () => this.unsubscribe(n), t.signal;
3053
+ this.subscribe(abort);
3054
+ controller.signal.unsubscribe = () => this.unsubscribe(abort);
3055
+ return controller.signal;
2240
3056
  }
2241
3057
  /**
2242
3058
  * Returns an object that contains a new `CancelToken` and a function that, when called,
2243
3059
  * cancels the `CancelToken`.
2244
3060
  */
2245
3061
  static source() {
2246
- let t;
3062
+ let cancel;
3063
+ const token = new CancelToken(function executor(c) {
3064
+ cancel = c;
3065
+ });
2247
3066
  return {
2248
- token: new It(function(s) {
2249
- t = s;
2250
- }),
2251
- cancel: t
3067
+ token,
3068
+ cancel
2252
3069
  };
2253
3070
  }
2254
3071
  };
2255
- function Mr(e) {
2256
- return function(n) {
2257
- return e.apply(null, n);
3072
+ function spread$1(callback) {
3073
+ return function wrap(arr) {
3074
+ return callback.apply(null, arr);
2258
3075
  };
2259
3076
  }
2260
- function Hr(e) {
2261
- return a.isObject(e) && e.isAxiosError === !0;
3077
+ function isAxiosError$1(payload) {
3078
+ return utils$1.isObject(payload) && payload.isAxiosError === true;
2262
3079
  }
2263
- const Le = {
3080
+ const HttpStatusCode$1 = {
2264
3081
  Continue: 100,
2265
3082
  SwitchingProtocols: 101,
2266
3083
  Processing: 102,
@@ -2325,65 +3142,74 @@ const Le = {
2325
3142
  NotExtended: 510,
2326
3143
  NetworkAuthenticationRequired: 511
2327
3144
  };
2328
- Object.entries(Le).forEach(([e, t]) => {
2329
- Le[t] = e;
3145
+ Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
3146
+ HttpStatusCode$1[value] = key;
2330
3147
  });
2331
- function $t(e) {
2332
- const t = new J(e), n = Et(J.prototype.request, t);
2333
- return a.extend(n, J.prototype, t, { allOwnKeys: !0 }), a.extend(n, t, null, { allOwnKeys: !0 }), n.create = function(s) {
2334
- return $t(W(e, s));
2335
- }, n;
3148
+ function createInstance(defaultConfig) {
3149
+ const context = new Axios$1(defaultConfig);
3150
+ const instance = bind(Axios$1.prototype.request, context);
3151
+ utils$1.extend(instance, Axios$1.prototype, context, { allOwnKeys: true });
3152
+ utils$1.extend(instance, context, null, { allOwnKeys: true });
3153
+ instance.create = function create(instanceConfig) {
3154
+ return createInstance(mergeConfig$1(defaultConfig, instanceConfig));
3155
+ };
3156
+ return instance;
2336
3157
  }
2337
- const P = $t(ae);
2338
- P.Axios = J;
2339
- P.CanceledError = G;
2340
- P.CancelToken = $r;
2341
- P.isCancel = vt;
2342
- P.VERSION = qt;
2343
- P.toFormData = ye;
2344
- P.AxiosError = b;
2345
- P.Cancel = P.CanceledError;
2346
- P.all = function(t) {
2347
- return Promise.all(t);
3158
+ const axios = createInstance(defaults);
3159
+ axios.Axios = Axios$1;
3160
+ axios.CanceledError = CanceledError$1;
3161
+ axios.CancelToken = CancelToken$1;
3162
+ axios.isCancel = isCancel$1;
3163
+ axios.VERSION = VERSION$1;
3164
+ axios.toFormData = toFormData$1;
3165
+ axios.AxiosError = AxiosError$1;
3166
+ axios.Cancel = axios.CanceledError;
3167
+ axios.all = function all(promises) {
3168
+ return Promise.all(promises);
2348
3169
  };
2349
- P.spread = Mr;
2350
- P.isAxiosError = Hr;
2351
- P.mergeConfig = W;
2352
- P.AxiosHeaders = U;
2353
- P.formToJSON = (e) => kt(a.isHTMLForm(e) ? new FormData(e) : e);
2354
- P.getAdapter = Bt.getAdapter;
2355
- P.HttpStatusCode = Le;
2356
- P.default = P;
3170
+ axios.spread = spread$1;
3171
+ axios.isAxiosError = isAxiosError$1;
3172
+ axios.mergeConfig = mergeConfig$1;
3173
+ axios.AxiosHeaders = AxiosHeaders$1;
3174
+ axios.formToJSON = (thing) => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
3175
+ axios.getAdapter = adapters.getAdapter;
3176
+ axios.HttpStatusCode = HttpStatusCode$1;
3177
+ axios.default = axios;
2357
3178
  const {
2358
- Axios: Qr,
2359
- AxiosError: es,
2360
- CanceledError: ts,
2361
- isCancel: ns,
2362
- CancelToken: rs,
2363
- VERSION: ss,
2364
- all: os,
2365
- Cancel: is,
2366
- isAxiosError: as,
2367
- spread: cs,
2368
- toFormData: ls,
2369
- AxiosHeaders: us,
2370
- HttpStatusCode: fs,
2371
- formToJSON: ds,
2372
- getAdapter: ps,
2373
- mergeConfig: hs
2374
- } = P, ms = (e) => P.create({
2375
- timeout: 2 * 60 * 1e3,
2376
- ...e
2377
- });
3179
+ Axios: Axios2,
3180
+ AxiosError,
3181
+ CanceledError,
3182
+ isCancel,
3183
+ CancelToken: CancelToken2,
3184
+ VERSION,
3185
+ all: all2,
3186
+ Cancel,
3187
+ isAxiosError,
3188
+ spread,
3189
+ toFormData,
3190
+ AxiosHeaders: AxiosHeaders2,
3191
+ HttpStatusCode,
3192
+ formToJSON,
3193
+ getAdapter,
3194
+ mergeConfig
3195
+ } = axios;
3196
+ const createAxiosInstance = (config) => {
3197
+ return axios.create({
3198
+ timeout: 2 * 60 * 1e3,
3199
+ ...config
3200
+ });
3201
+ };
2378
3202
  export {
2379
- Yr as AuthStateProvider,
2380
- de as ERequestContentType,
2381
- Zt as ERequestMethod,
2382
- Xr as FetcherProvider,
2383
- ms as createAxiosInstance,
2384
- Wr as createGraphQLFetcher,
2385
- Vr as createRestFulFetcher,
2386
- Kr as getGraphQLResponseFormatError,
2387
- dn as getRestFulResponseFormatError,
2388
- un as useAuthState
3203
+ AuthStateProvider,
3204
+ ERequestContentType,
3205
+ ERequestMethod,
3206
+ FetcherException,
3207
+ FetcherProvider,
3208
+ createAxiosInstance,
3209
+ createGraphQLFetcher,
3210
+ createRestFulFetcher,
3211
+ getGraphQLResponseFormatError,
3212
+ getRestFulResponseFormatError,
3213
+ useAuthState
2389
3214
  };
3215
+ //# sourceMappingURL=acrool-react-fetcher.es.js.map