@acrool/react-fetcher 0.0.5 → 0.0.6

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,107 +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, d = ((p = o == null ? void 0 : o.headers) == null ? void 0 : p.contentType) ?? n(s.toUpperCase()), l = {
89
- url: t.url,
90
- method: s,
91
- params: c,
92
- data: Qt(d, i),
93
- ...o,
94
- headers: {
95
- ...o == null ? void 0 : o.headers,
96
- "Content-Type": d
97
- }
98
- }, [u] = await Promise.all([
99
- e(l),
100
- dt((o == null ? void 0 : o.leastTime) ?? pt)
101
- ]);
102
- 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;
103
129
  };
104
- 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 = {};
105
158
  /**
106
159
  * @license React
107
160
  * react-jsx-runtime.production.js
@@ -111,29 +164,35 @@ var ce = { exports: {} }, Z = {};
111
164
  * This source code is licensed under the MIT license found in the
112
165
  * LICENSE file in the root directory of this source tree.
113
166
  */
114
- var Ve;
115
- function tn() {
116
- if (Ve) return Z;
117
- Ve = 1;
118
- var e = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
119
- function n(r, s, o) {
120
- var i = null;
121
- if (o !== void 0 && (i = "" + o), s.key !== void 0 && (i = "" + s.key), "key" in s) {
122
- o = {};
123
- for (var c in s)
124
- c !== "key" && (o[c] = s[c]);
125
- } else o = s;
126
- return s = o.ref, {
127
- $$typeof: e,
128
- type: r,
129
- key: i,
130
- ref: s !== void 0 ? s : null,
131
- 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
132
188
  };
133
189
  }
134
- 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;
135
194
  }
136
- var Q = {};
195
+ var reactJsxRuntime_development = {};
137
196
  /**
138
197
  * @license React
139
198
  * react-jsx-runtime.development.js
@@ -143,435 +202,445 @@ var Q = {};
143
202
  * This source code is licensed under the MIT license found in the
144
203
  * LICENSE file in the root directory of this source tree.
145
204
  */
146
- var Ye;
147
- function nn() {
148
- return Ye || (Ye = 1, process.env.NODE_ENV !== "production" && function() {
149
- function e(f) {
150
- if (f == null) return null;
151
- if (typeof f == "function")
152
- return f.$$typeof === V ? null : f.displayName || f.name || null;
153
- if (typeof f == "string") return f;
154
- switch (f) {
155
- 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:
156
217
  return "Fragment";
157
- case S:
218
+ case REACT_PROFILER_TYPE:
158
219
  return "Profiler";
159
- case m:
220
+ case REACT_STRICT_MODE_TYPE:
160
221
  return "StrictMode";
161
- case g:
222
+ case REACT_SUSPENSE_TYPE:
162
223
  return "Suspense";
163
- case x:
224
+ case REACT_SUSPENSE_LIST_TYPE:
164
225
  return "SuspenseList";
165
- case j:
226
+ case REACT_ACTIVITY_TYPE:
166
227
  return "Activity";
167
228
  }
168
- if (typeof f == "object")
169
- switch (typeof f.tag == "number" && console.error(
229
+ if ("object" === typeof type)
230
+ switch ("number" === typeof type.tag && console.error(
170
231
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
171
- ), f.$$typeof) {
172
- case h:
232
+ ), type.$$typeof) {
233
+ case REACT_PORTAL_TYPE:
173
234
  return "Portal";
174
- case E:
175
- return (f.displayName || "Context") + ".Provider";
176
- case A:
177
- return (f._context.displayName || "Context") + ".Consumer";
178
- case O:
179
- var w = f.render;
180
- return f = f.displayName, f || (f = w.displayName || w.name || "", f = f !== "" ? "ForwardRef(" + f + ")" : "ForwardRef"), f;
181
- case N:
182
- return w = f.displayName || null, w !== null ? w : e(f.type) || "Memo";
183
- case B:
184
- 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;
185
249
  try {
186
- return e(f(w));
187
- } catch {
250
+ return getComponentNameFromType(type(innerType));
251
+ } catch (x) {
188
252
  }
189
253
  }
190
254
  return null;
191
255
  }
192
- function t(f) {
193
- return "" + f;
256
+ function testStringCoercion(value) {
257
+ return "" + value;
194
258
  }
195
- function n(f) {
259
+ function checkKeyStringCoercion(value) {
196
260
  try {
197
- t(f);
198
- var w = !1;
199
- } catch {
200
- w = !0;
261
+ testStringCoercion(value);
262
+ var JSCompiler_inline_result = false;
263
+ } catch (e2) {
264
+ JSCompiler_inline_result = true;
201
265
  }
202
- if (w) {
203
- w = console;
204
- var _ = w.error, C = typeof Symbol == "function" && Symbol.toStringTag && f[Symbol.toStringTag] || f.constructor.name || "Object";
205
- return _.call(
206
- 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,
207
272
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
208
- C
209
- ), t(f);
273
+ JSCompiler_inline_result$jscomp$0
274
+ );
275
+ return testStringCoercion(value);
210
276
  }
211
277
  }
212
- function r(f) {
213
- if (f === R) return "<>";
214
- 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)
215
281
  return "<...>";
216
282
  try {
217
- var w = e(f);
218
- return w ? "<" + w + ">" : "<...>";
219
- } catch {
283
+ var name = getComponentNameFromType(type);
284
+ return name ? "<" + name + ">" : "<...>";
285
+ } catch (x) {
220
286
  return "<...>";
221
287
  }
222
288
  }
223
- function s() {
224
- var f = H.A;
225
- return f === null ? null : f.getOwner();
289
+ function getOwner() {
290
+ var dispatcher = ReactSharedInternals.A;
291
+ return null === dispatcher ? null : dispatcher.getOwner();
226
292
  }
227
- function o() {
293
+ function UnknownOwner() {
228
294
  return Error("react-stack-top-frame");
229
295
  }
230
- function i(f) {
231
- if (Ie.call(f, "key")) {
232
- var w = Object.getOwnPropertyDescriptor(f, "key").get;
233
- 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;
234
300
  }
235
- return f.key !== void 0;
301
+ return void 0 !== config.key;
236
302
  }
237
- function c(f, w) {
238
- function _() {
239
- $e || ($e = !0, console.error(
303
+ function defineKeyPropWarningGetter(props, displayName) {
304
+ function warnAboutAccessingKey() {
305
+ specialPropKeyWarningShown || (specialPropKeyWarningShown = true, console.error(
240
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)",
241
- w
307
+ displayName
242
308
  ));
243
309
  }
244
- _.isReactWarning = !0, Object.defineProperty(f, "key", {
245
- get: _,
246
- configurable: !0
310
+ warnAboutAccessingKey.isReactWarning = true;
311
+ Object.defineProperty(props, "key", {
312
+ get: warnAboutAccessingKey,
313
+ configurable: true
247
314
  });
248
315
  }
249
- function d() {
250
- var f = e(this.type);
251
- 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(
252
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."
253
- )), f = this.props.ref, f !== void 0 ? f : null;
254
- }
255
- function l(f, w, _, C, M, q, Se, Oe) {
256
- return _ = q.ref, f = {
257
- $$typeof: T,
258
- type: f,
259
- key: w,
260
- props: q,
261
- _owner: M
262
- }, (_ !== void 0 ? _ : null) !== null ? Object.defineProperty(f, "ref", {
263
- enumerable: !1,
264
- get: d
265
- }) : Object.defineProperty(f, "ref", { enumerable: !1, value: null }), f._store = {}, Object.defineProperty(f._store, "validated", {
266
- configurable: !1,
267
- enumerable: !1,
268
- 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,
269
342
  value: 0
270
- }), Object.defineProperty(f, "_debugInfo", {
271
- configurable: !1,
272
- enumerable: !1,
273
- writable: !0,
343
+ });
344
+ Object.defineProperty(type, "_debugInfo", {
345
+ configurable: false,
346
+ enumerable: false,
347
+ writable: true,
274
348
  value: null
275
- }), Object.defineProperty(f, "_debugStack", {
276
- configurable: !1,
277
- enumerable: !1,
278
- writable: !0,
279
- value: Se
280
- }), Object.defineProperty(f, "_debugTask", {
281
- configurable: !1,
282
- enumerable: !1,
283
- writable: !0,
284
- value: Oe
285
- }), Object.freeze && (Object.freeze(f.props), Object.freeze(f)), f;
286
- }
287
- function u(f, w, _, C, M, q, Se, Oe) {
288
- var k = w.children;
289
- if (k !== void 0)
290
- if (C)
291
- if (Mt(k)) {
292
- for (C = 0; C < k.length; C++)
293
- p(k[C]);
294
- 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);
295
373
  } else
296
374
  console.error(
297
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."
298
376
  );
299
- else p(k);
300
- if (Ie.call(w, "key")) {
301
- k = e(f);
302
- var Y = Object.keys(w).filter(function(Ht) {
303
- 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;
304
382
  });
305
- C = 0 < Y.length ? "{key: someKey, " + Y.join(": ..., ") + ": ...}" : "{key: someKey}", Je[k + C] || (Y = 0 < Y.length ? "{" + Y.join(": ..., ") + ": ...}" : "{}", console.error(
306
- `A props object containing a "key" prop is being spread into JSX:
307
- let props = %s;
308
- <%s {...props} />
309
- React keys must be passed directly to JSX without using spread:
310
- let props = %s;
311
- <%s key={someKey} {...props} />`,
312
- C,
313
- k,
314
- Y,
315
- k
316
- ), 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);
317
391
  }
318
- if (k = null, _ !== void 0 && (n(_), k = "" + _), i(w) && (n(w.key), k = "" + w.key), "key" in w) {
319
- _ = {};
320
- for (var Ae in w)
321
- Ae !== "key" && (_[Ae] = w[Ae]);
322
- } else _ = w;
323
- return k && c(
324
- _,
325
- typeof f == "function" ? f.displayName || f.name || "Unknown" : f
326
- ), l(
327
- f,
328
- k,
329
- q,
330
- M,
331
- s(),
332
- _,
333
- Se,
334
- 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
335
413
  );
336
414
  }
337
- function p(f) {
338
- 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);
339
417
  }
340
- 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() {
341
420
  return null;
342
421
  };
343
- y = {
344
- "react-stack-bottom-frame": function(f) {
345
- return f();
422
+ React = {
423
+ "react-stack-bottom-frame": function(callStackForError) {
424
+ return callStackForError();
346
425
  }
347
426
  };
348
- var $e, Me = {}, He = y["react-stack-bottom-frame"].bind(
349
- y,
350
- o
351
- )(), ze = ge(r(o)), Je = {};
352
- Q.Fragment = R, Q.jsx = function(f, w, _, C, M) {
353
- var q = 1e4 > H.recentlyCreatedOwnerStacks++;
354
- return u(
355
- f,
356
- w,
357
- _,
358
- !1,
359
- C,
360
- M,
361
- q ? Error("react-stack-top-frame") : He,
362
- 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
363
447
  );
364
- }, Q.jsxs = function(f, w, _, C, M) {
365
- var q = 1e4 > H.recentlyCreatedOwnerStacks++;
366
- return u(
367
- f,
368
- w,
369
- _,
370
- !0,
371
- C,
372
- M,
373
- q ? Error("react-stack-top-frame") : He,
374
- 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
375
460
  );
376
461
  };
377
- }()), Q;
462
+ }();
463
+ return reactJsxRuntime_development;
378
464
  }
379
- var Ke;
380
- function rn() {
381
- 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;
382
475
  }
383
- var mt = rn();
384
- const re = [
476
+ var jsxRuntimeExports = requireJsxRuntime();
477
+ const s = [
385
478
  "color: #fff",
386
479
  "display: inline-block",
387
480
  "font-size: 11px",
388
481
  "line-height: 20px",
389
482
  "padding-right: 8px",
390
483
  "border-radius: 4px"
391
- ], se = {
484
+ ], t = {
392
485
  primary: "#0055a9",
393
486
  success: "#009422",
394
487
  info: "#17a2b8",
395
488
  warning: "#d7a000",
396
489
  danger: "#ec2127"
397
490
  };
398
- function oe(e, t, ...n) {
399
- console.log(`%c ${e}`, t, ...n);
491
+ function a(n, o, ...c) {
492
+ console.log(`%c ${n}`, o, ...c);
400
493
  }
401
- function sn(e, ...t) {
402
- const n = re.concat([
403
- `background-color: ${se.primary}`
494
+ function i(n, ...o) {
495
+ const c = s.concat([
496
+ `background-color: ${t.primary}`
404
497
  ]).join(";");
405
- oe(e, n, ...t);
498
+ a(n, c, ...o);
406
499
  }
407
- function on(e, ...t) {
408
- const n = re.concat([
409
- `background-color: ${se.success}`
500
+ function r(n, ...o) {
501
+ const c = s.concat([
502
+ `background-color: ${t.success}`
410
503
  ]).join(";");
411
- oe(e, n, ...t);
504
+ a(n, c, ...o);
412
505
  }
413
- function an(e, ...t) {
414
- const n = re.concat([
415
- `background-color: ${se.info}`
506
+ function e(n, ...o) {
507
+ const c = s.concat([
508
+ `background-color: ${t.info}`
416
509
  ]).join(";");
417
- oe(e, n, ...t);
510
+ a(n, c, ...o);
418
511
  }
419
- function cn(e, ...t) {
420
- const n = re.concat([
421
- `background-color: ${se.warning}`
512
+ function l(n, ...o) {
513
+ const c = s.concat([
514
+ `background-color: ${t.warning}`
422
515
  ]).join(";");
423
- oe(e, n, ...t);
516
+ a(n, c, ...o);
424
517
  }
425
- function ln(e, ...t) {
426
- const n = re.concat([
427
- `background-color: ${se.danger}`
518
+ function g(n, ...o) {
519
+ const c = s.concat([
520
+ `background-color: ${t.danger}`
428
521
  ]).join(";");
429
- oe(e, n, ...t);
522
+ a(n, c, ...o);
430
523
  }
431
- const v = {
432
- primary: sn,
433
- success: on,
434
- info: an,
435
- warning: cn,
436
- danger: ln
524
+ const u = {
525
+ primary: i,
526
+ success: r,
527
+ info: e,
528
+ warning: l,
529
+ danger: g
437
530
  };
438
- function Ue(e, t) {
439
- const n = {
440
- isZero: (t == null ? void 0 : t.isZero) ?? !0,
441
- 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
442
535
  };
443
- 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;
444
537
  }
445
- function Xe(e, t) {
446
- return !Ue(e, {
447
- isZero: !0,
448
- isFalse: !0
449
- });
538
+ function D(e2, t2) {
539
+ const r2 = {
540
+ isZero: true,
541
+ isFalse: true
542
+ };
543
+ return !w(e2, r2);
450
544
  }
451
- class K extends Error {
452
- constructor(n) {
453
- super(n.message);
454
- $(this, "code");
455
- $(this, "devInfo");
456
- $(this, "args");
457
- $(this, "path");
458
- this.response = n, this.code = n.code, this.args = n.args, this.path = n.path, this.initName();
459
- }
460
- 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;
461
555
  this.name = this.constructor.name;
462
- }
463
- getInfo() {
464
- return {
465
- message: this.response.message,
466
- code: this.response.code,
467
- args: this.response.args,
468
- path: this.response.path
469
- };
556
+ Object.setPrototypeOf(this, FetcherException.prototype);
470
557
  }
471
558
  }
472
- const Rt = ft({
559
+ const AuthStateContext = createContext({
473
560
  lastUpdateTimestamp: 0,
474
- isAuth: !1,
475
- getTokens: () => (v.warning("AuthStateContext", "getTokens not yet ready"), null),
476
- updateTokens: () => v.warning("AuthStateContext", "updateTokens not yet ready"),
477
- forceLogout: () => v.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"),
478
568
  refreshTokens: async () => {
479
- v.warning("AuthStateContext", "refreshToken not yet ready");
480
- }
481
- }), un = () => Vt(Rt), Yr = ({
482
- children: e,
483
- onGetTokens: t,
484
- onSetTokens: n,
485
- onRefreshTokens: r,
486
- onForceLogout: s,
487
- 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
488
581
  }) => {
489
- const [i, c] = We(0), [d, l] = We(() => Xe(t())), u = (T) => {
490
- let h;
491
- typeof T == "function" ? h = T(t()) : h = T, n(h), l(Xe(h)), c(Date.now());
492
- }, p = () => {
493
- u(null), s && s();
494
- }, y = async () => {
495
- var h;
496
- const T = (h = t()) == null ? void 0 : h.refreshToken;
497
- if (!T || !r)
498
- throw o && v.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
+ }
499
610
  try {
500
- const R = await r(T);
501
- if (Ue(R))
502
- throw o && v.danger("[AuthStateProvider] handleOnRefreshTokens", "new refresh token fail"), new K({ message: "new refresh token fail", code: "NEW_REFRESH_TOKEN_EMPTY" });
503
- 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);
504
617
  return;
505
- } catch {
506
- 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" });
507
621
  }
508
622
  };
509
- return /* @__PURE__ */ mt.jsx(Rt.Provider, { value: {
510
- lastUpdateTimestamp: i,
511
- isAuth: d,
512
- getTokens: t,
513
- updateTokens: u,
514
- refreshTokens: y,
515
- forceLogout: p
516
- }, children: e });
517
- }, Ge = {
518
- "en-US": {
519
- 400: "The requested parameter is wrong",
520
- 401: "Please login before continuing",
521
- 404: "Request Not Found/Route",
522
- 413: "The request/file sent exceeds the server limit size",
523
- 500: "Internal Server Error",
524
- 503: "System under maintenance",
525
- 504: "Please check your network and try again",
526
- 511: "Area not available",
527
- CANCEL_ERROR: "Request has been cancelled. Only possible if `cancelToken` is provided in config, see axios `Cancellation`",
528
- CLIENT_ERROR: "Any non-specific 400 series error",
529
- CONNECTION_ERROR: "Server not available, bad dns",
530
- NETWORK_ERROR: "Your mobile network connection is unstable. Please check your network connection status and try again.",
531
- SERVER_ERROR: "Any 500 series error",
532
- TIMEOUT_ERROR: "The server has not responded for more than {sec} seconds. Please confirm your network connection status or contact customer service"
533
- },
534
- "zh-TW": {
535
- 400: "請求的參數錯誤",
536
- 401: "請先登入再繼續",
537
- 404: "請求未找到/路由錯誤",
538
- 413: "請求/發送的檔案超出伺服器限制大小",
539
- 500: "內部伺服器錯誤",
540
- 503: "系統維護",
541
- 504: "請檢查網路後重試",
542
- 511: "區域不可用",
543
- CANCEL_ERROR: "請求已取消。僅在配置中提供 `cancelToken` 時可能發生,請參閱 axios 的 `Cancellation`",
544
- CLIENT_ERROR: "任意非特定的400系列錯誤",
545
- CONNECTION_ERROR: "伺服器不可用,DNS錯誤",
546
- NETWORK_ERROR: "您的行動網路連線不穩定。請檢查網路連線後重試。 ",
547
- SERVER_ERROR: "任意500系列錯誤",
548
- TIMEOUT_ERROR: "伺服器已超過 {sec} 秒未回應。請確認您的網路連線狀態或聯絡客服"
549
- },
550
- "zh-CN": {
551
- 400: "请求的参数错误",
552
- 401: "请先登录再继续",
553
- 404: "请求未找到/路由错误",
554
- 413: "请求/发送的文件超出服务器限制大小",
555
- 500: "内部服务器错误",
556
- 503: "系统维护中",
557
- 504: "请检查网络后重试",
558
- 511: "区域不可用",
559
- CANCEL_ERROR: "请求已取消。仅当配置中提供 `cancelToken` 时可能发生,请参阅 axios 的 `Cancellation`",
560
- CLIENT_ERROR: "任意非特定的400系列错误",
561
- CONNECTION_ERROR: "服务器不可用,DNS错误",
562
- NETWORK_ERROR: "您的移动网络连接不稳定。请检查网络连接后重试。",
563
- SERVER_ERROR: "任意500系列错误",
564
- TIMEOUT_ERROR: "服务器已超过 {sec} 秒未响应。请确认您的网络连接状态或联系客服"
565
- }
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 });
566
631
  };
567
- class fn extends Error {
568
- constructor(n) {
569
- super(n.message);
570
- $(this, "code");
571
- $(this, "devInfo");
572
- $(this, "args");
573
- $(this, "path");
574
- 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();
575
644
  }
576
645
  initName() {
577
646
  this.name = this.constructor.name;
@@ -585,320 +654,550 @@ class fn extends Error {
585
654
  };
586
655
  }
587
656
  }
588
- const Kr = (e) => {
589
- var t, n, r, s;
590
- 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 {
591
670
  message: "Axios error",
592
671
  code: "ERR_SYS_BAD_RESPONSE"
593
672
  };
594
- }, dn = (e) => e != null && e.data ? e == null ? void 0 : e.data : {
595
- message: "Axios error",
596
- code: "ERR_SYS_BAD_RESPONSE"
597
673
  };
598
- let ee = !1, _e = [];
599
- const pn = ft(null), Xr = ({
600
- children: e,
601
- axiosInstance: t,
602
- locale: n = "en-US",
603
- getResponseFormatError: r = dn,
604
- onError: s,
605
- checkIsRefreshTokenRequest: o,
606
- authorizationPrefix: i = "Bearer",
607
- i18nDict: c,
608
- 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
609
703
  }) => {
610
704
  const {
611
- getTokens: l,
612
- updateTokens: u,
613
- refreshTokens: p,
614
- forceLogout: y
615
- } = un();
616
- Yt(() => {
617
- 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);
618
713
  return () => {
619
- t.interceptors.request.eject(E), t.interceptors.response.eject(O);
714
+ axiosInstance.interceptors.request.eject(interceptorReq);
715
+ axiosInstance.interceptors.response.eject(interceptorRes);
620
716
  };
621
- }, [l, p, u, y]);
622
- const T = (E) => {
623
- d && v.warning("[FetcherProvider] runPendingRequest", { isSuccess: E }), ee = !1;
624
- for (const O of _e)
625
- O(E);
626
- _e = [];
627
- }, h = (E, O) => (g) => {
628
- d && v.info("[FetcherProvider] Request add pending queue", { originConfig: g }), _e.push((x) => {
629
- x ? (g.pendingRequest = !0, E(t(g))) : O(new K({
630
- message: S(401),
631
- code: "UNAUTHORIZED",
632
- path: "AxiosClientProvider.pushPendingRequestQueues"
633
- }));
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);
634
762
  });
635
- }, R = (E) => new Promise((O, g) => {
636
- var j, V;
637
- E.headers["Accept-Language"] = n;
638
- const x = (j = l()) == null ? void 0 : j.accessToken;
639
- 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) {
640
- h(O, g)(E), g(new fn({
641
- message: "Token refreshing, so request save queues not send",
642
- code: "REFRESHING_TOKEN"
643
- }));
644
- 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 && originalConfig.ignoreErrorCallback !== true) {
775
+ onError(responseFirstError);
645
776
  }
646
- O(E);
647
- }), m = (E) => (d && v.info("[FetcherProvider] interceptorsResponseSuccess", { response: E }), E), S = (E) => {
648
- const O = (c == null ? void 0 : c[n]) || Ge[n] || Ge["en-US"];
649
- return (O == null ? void 0 : O[E]) || `Error: ${E}`;
650
- }, A = (E) => {
651
- const O = E.response, g = E.config, x = E.status, N = r(O);
652
- d && v.warning("[FetcherProvider] interceptorsResponseError", { status: x, responseFirstError: N }), s && s(N);
653
- const B = g && o ? o(g) : !1;
654
- if (O && g && (x === 401 || N.code === "UNAUTHENTICATED")) {
655
- const j = l();
656
- return d && v.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 && v.warning("[FetcherProvider] no refreshToken/refreshAPI|pendingRequest fail, force logout"), y(), Promise.reject(new K(N))) : (ee || (ee = !0, d && v.warning("[FetcherProvider] refreshTokens"), p().then(() => {
657
- d && v.info("[FetcherProvider] refreshTokens success"), T(!0);
658
- }).catch(() => {
659
- d && v.danger("[FetcherProvider] refreshTokens fail"), T(!1);
660
- })), new Promise((V, H) => {
661
- h(V, H)(g);
662
- }));
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
+ }
663
803
  }
664
- return Promise.reject(new K(N));
804
+ return Promise.reject(new FetcherException(responseFirstError));
665
805
  };
666
- return /* @__PURE__ */ mt.jsx(
667
- pn.Provider,
806
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
807
+ AxiosClientContext.Provider,
668
808
  {
669
- value: t,
670
- children: e
809
+ value: axiosInstance,
810
+ children
671
811
  }
672
812
  );
673
813
  };
674
- function Et(e, t) {
675
- return function() {
676
- return e.apply(t, arguments);
814
+ function bind(fn, thisArg) {
815
+ return function wrap() {
816
+ return fn.apply(thisArg, arguments);
677
817
  };
678
818
  }
679
- const { toString: hn } = Object.prototype, { getPrototypeOf: De } = Object, { iterator: me, toStringTag: bt } = Symbol, Re = /* @__PURE__ */ ((e) => (t) => {
680
- const n = hn.call(t);
681
- return e[n] || (e[n] = n.slice(8, -1).toLowerCase());
682
- })(/* @__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");
683
- function mn(e) {
684
- 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);
685
835
  }
686
- const yt = D("ArrayBuffer");
687
- function Rn(e) {
688
- let t;
689
- 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;
690
845
  }
691
- 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) => {
692
- if (Re(e) !== "object")
693
- return !1;
694
- const t = De(e);
695
- return (t === null || t === Object.prototype || Object.getPrototypeOf(t) === null) && !(bt in e) && !(me in e);
696
- }, yn = D("Date"), wn = D("File"), Tn = D("Blob"), gn = D("FileList"), Sn = (e) => be(e) && L(e.pipe), On = (e) => {
697
- let t;
698
- return e && (typeof FormData == "function" && e instanceof FormData || L(e.append) && ((t = Re(e)) === "formdata" || // detect form-data instance
699
- t === "object" && L(e.toString) && e.toString() === "[object FormData]"));
700
- }, 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, "");
701
- function ie(e, t, { allOwnKeys: n = !1 } = {}) {
702
- 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") {
703
873
  return;
704
- let r, s;
705
- if (typeof e != "object" && (e = [e]), X(e))
706
- for (r = 0, s = e.length; r < s; r++)
707
- t.call(null, e[r], r, e);
708
- else {
709
- const o = n ? Object.getOwnPropertyNames(e) : Object.keys(e), i = o.length;
710
- let c;
711
- for (r = 0; r < i; r++)
712
- 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
+ }
713
892
  }
714
893
  }
715
- function Tt(e, t) {
716
- t = t.toLowerCase();
717
- const n = Object.keys(e);
718
- let r = n.length, s;
719
- for (; r-- > 0; )
720
- if (s = n[r], t === s.toLowerCase())
721
- 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
+ }
722
905
  return null;
723
906
  }
724
- const z = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global, gt = (e) => !ne(e) && e !== z;
725
- function Ce() {
726
- const { caseless: e } = gt(this) && this || {}, t = {}, n = (r, s) => {
727
- const o = e && Tt(t, s) || s;
728
- 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
+ }
729
926
  };
730
- for (let r = 0, s = arguments.length; r < s; r++)
731
- arguments[r] && ie(arguments[r], n);
732
- return t;
927
+ for (let i2 = 0, l2 = arguments.length; i2 < l2; i2++) {
928
+ arguments[i2] && forEach(arguments[i2], assignValue);
929
+ }
930
+ return result;
733
931
  }
734
- const kn = (e, t, n, { allOwnKeys: r } = {}) => (ie(t, (s, o) => {
735
- n && L(s) ? e[o] = Et(s, n) : e[o] = s;
736
- }, { allOwnKeys: r }), e), Fn = (e) => (e.charCodeAt(0) === 65279 && (e = e.slice(1)), e), vn = (e, t, n, r) => {
737
- e.prototype = Object.create(t.prototype, r), e.prototype.constructor = e, Object.defineProperty(e, "super", {
738
- value: t.prototype
739
- }), n && Object.assign(e.prototype, n);
740
- }, jn = (e, t, n, r) => {
741
- let s, o, i;
742
- const c = {};
743
- 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;
744
963
  do {
745
- for (s = Object.getOwnPropertyNames(e), o = s.length; o-- > 0; )
746
- i = s[o], (!r || r(i, e, t)) && !c[i] && (t[i] = e[i], c[i] = !0);
747
- e = n !== !1 && De(e);
748
- } while (e && (!n || n(e, t)) && e !== Object.prototype);
749
- return t;
750
- }, Ln = (e, t, n) => {
751
- e = String(e), (n === void 0 || n > e.length) && (n = e.length), n -= t.length;
752
- const r = e.indexOf(t, n);
753
- return r !== -1 && r === n;
754
- }, Un = (e) => {
755
- if (!e) return null;
756
- if (X(e)) return e;
757
- let t = e.length;
758
- if (!wt(t)) return null;
759
- const n = new Array(t);
760
- for (; t-- > 0; )
761
- n[t] = e[t];
762
- return n;
763
- }, Dn = /* @__PURE__ */ ((e) => (t) => e && t instanceof e)(typeof Uint8Array < "u" && De(Uint8Array)), Bn = (e, t) => {
764
- const r = (e && e[me]).call(e);
765
- let s;
766
- for (; (s = r.next()) && !s.done; ) {
767
- const o = s.value;
768
- t.call(e, o[0], o[1]);
769
- }
770
- }, qn = (e, t) => {
771
- let n;
772
- const r = [];
773
- for (; (n = e.exec(t)) !== null; )
774
- r.push(n);
775
- return r;
776
- }, In = D("HTMLFormElement"), $n = (e) => e.toLowerCase().replace(
777
- /[-_\s]([a-z\d])(\w*)/g,
778
- function(n, r, s) {
779
- return r.toUpperCase() + s;
780
- }
781
- ), Ze = (({ hasOwnProperty: e }) => (t, n) => e.call(t, n))(Object.prototype), Mn = D("RegExp"), St = (e, t) => {
782
- const n = Object.getOwnPropertyDescriptors(e), r = {};
783
- ie(n, (s, o) => {
784
- let i;
785
- (i = t(s, o, e)) !== !1 && (r[o] = i || s);
786
- }), Object.defineProperties(e, r);
787
- }, Hn = (e) => {
788
- St(e, (t, n) => {
789
- if (L(e) && ["arguments", "caller", "callee"].indexOf(n) !== -1)
790
- return !1;
791
- const r = e[n];
792
- if (L(r)) {
793
- if (t.enumerable = !1, "writable" in t) {
794
- t.writable = !1;
795
- 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;
796
971
  }
797
- t.set || (t.set = () => {
798
- throw Error("Can not rewrite read-only method '" + n + "'");
799
- });
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
+ };
800
1057
  }
801
1058
  });
802
- }, zn = (e, t) => {
803
- const n = {}, r = (s) => {
804
- s.forEach((o) => {
805
- n[o] = !0;
1059
+ };
1060
+ const toObjectSet = (arrayOrString, delimiter) => {
1061
+ const obj = {};
1062
+ const define = (arr) => {
1063
+ arr.forEach((value) => {
1064
+ obj[value] = true;
806
1065
  });
807
1066
  };
808
- return X(e) ? r(e) : r(String(e).split(t)), n;
809
- }, Jn = () => {
810
- }, Wn = (e, t) => e != null && Number.isFinite(e = +e) ? e : t;
811
- function Vn(e) {
812
- 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]);
813
1077
  }
814
- const Yn = (e) => {
815
- const t = new Array(10), n = (r, s) => {
816
- if (be(r)) {
817
- 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) {
818
1083
  return;
819
- if (!("toJSON" in r)) {
820
- t[s] = r;
821
- const o = X(r) ? [] : {};
822
- return ie(r, (i, c) => {
823
- const d = n(i, s + 1);
824
- !ne(d) && (o[c] = d);
825
- }), 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;
826
1094
  }
827
1095
  }
828
- return r;
1096
+ return source;
829
1097
  };
830
- return n(e, 0);
831
- }, 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 }) => {
832
- s === z && o === n && r.length && r.shift()();
833
- }, !1), (s) => {
834
- r.push(s), z.postMessage(n, "*");
835
- }))(`axios@${Math.random()}`, []) : (n) => setTimeout(n))(
836
- typeof setImmediate == "function",
837
- L(z.postMessage)
838
- ), Gn = typeof queueMicrotask < "u" ? queueMicrotask.bind(z) : typeof process < "u" && process.nextTick || Ot, Zn = (e) => e != null && L(e[me]), a = {
839
- isArray: X,
840
- isArrayBuffer: yt,
841
- isBuffer: mn,
842
- isFormData: On,
843
- isArrayBufferView: Rn,
844
- isString: En,
845
- isNumber: wt,
846
- isBoolean: bn,
847
- isObject: be,
848
- isPlainObject: le,
849
- isReadableStream: _n,
850
- isRequest: Pn,
851
- isResponse: xn,
852
- isHeaders: Nn,
853
- isUndefined: ne,
854
- isDate: yn,
855
- isFile: wn,
856
- isBlob: Tn,
857
- isRegExp: Mn,
858
- isFunction: L,
859
- isStream: Sn,
860
- isURLSearchParams: An,
861
- isTypedArray: Dn,
862
- isFileList: gn,
863
- forEach: ie,
864
- merge: Ce,
865
- extend: kn,
866
- trim: Cn,
867
- stripBOM: Fn,
868
- inherits: vn,
869
- toFlatObject: jn,
870
- kindOf: Re,
871
- kindOfTest: D,
872
- endsWith: Ln,
873
- toArray: Un,
874
- forEachEntry: Bn,
875
- matchAll: qn,
876
- isHTMLForm: In,
877
- hasOwnProperty: Ze,
878
- 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,
879
1164
  // an alias to avoid ESLint no-prototype-builtins detection
880
- reduceDescriptors: St,
881
- freezeMethods: Hn,
882
- toObjectSet: zn,
883
- toCamelCase: $n,
884
- noop: Jn,
885
- toFiniteNumber: Wn,
886
- findKey: Tt,
887
- global: z,
888
- isContextDefined: gt,
889
- isSpecCompliantForm: Vn,
890
- toJSONObject: Yn,
891
- isAsyncFn: Kn,
892
- isThenable: Xn,
893
- setImmediate: Ot,
894
- asap: Gn,
895
- 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
896
1181
  };
897
- function b(e, t, n, r, s) {
898
- 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
+ }
899
1198
  }
900
- a.inherits(b, Error, {
901
- toJSON: function() {
1199
+ utils$1.inherits(AxiosError$1, Error, {
1200
+ toJSON: function toJSON() {
902
1201
  return {
903
1202
  // Standard
904
1203
  message: this.message,
@@ -912,13 +1211,14 @@ a.inherits(b, Error, {
912
1211
  columnNumber: this.columnNumber,
913
1212
  stack: this.stack,
914
1213
  // Axios
915
- config: a.toJSONObject(this.config),
1214
+ config: utils$1.toJSONObject(this.config),
916
1215
  code: this.code,
917
1216
  status: this.status
918
1217
  };
919
1218
  }
920
1219
  });
921
- const At = b.prototype, _t = {};
1220
+ const prototype$1 = AxiosError$1.prototype;
1221
+ const descriptors = {};
922
1222
  [
923
1223
  "ERR_BAD_OPTION_VALUE",
924
1224
  "ERR_BAD_OPTION",
@@ -933,98 +1233,136 @@ const At = b.prototype, _t = {};
933
1233
  "ERR_NOT_SUPPORT",
934
1234
  "ERR_INVALID_URL"
935
1235
  // eslint-disable-next-line func-names
936
- ].forEach((e) => {
937
- _t[e] = { value: e };
1236
+ ].forEach((code) => {
1237
+ descriptors[code] = { value: code };
938
1238
  });
939
- Object.defineProperties(b, _t);
940
- Object.defineProperty(At, "isAxiosError", { value: !0 });
941
- b.from = (e, t, n, r, s, o) => {
942
- const i = Object.create(At);
943
- return a.toFlatObject(e, i, function(d) {
944
- return d !== Error.prototype;
945
- }, (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;
946
1253
  };
947
- const Qn = null;
948
- function ke(e) {
949
- 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);
950
1257
  }
951
- function Pt(e) {
952
- return a.endsWith(e, "[]") ? e.slice(0, -2) : e;
1258
+ function removeBrackets(key) {
1259
+ return utils$1.endsWith(key, "[]") ? key.slice(0, -2) : key;
953
1260
  }
954
- function Qe(e, t, n) {
955
- return e ? e.concat(t).map(function(s, o) {
956
- return s = Pt(s), !n && o ? "[" + s + "]" : s;
957
- }).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 ? "." : "");
958
1267
  }
959
- function er(e) {
960
- return a.isArray(e) && !e.some(ke);
1268
+ function isFlatArray(arr) {
1269
+ return utils$1.isArray(arr) && !arr.some(isVisitable);
961
1270
  }
962
- const tr = a.toFlatObject(a, {}, null, function(t) {
963
- 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);
964
1273
  });
965
- function ye(e, t, n) {
966
- if (!a.isObject(e))
1274
+ function toFormData$1(obj, formData, options) {
1275
+ if (!utils$1.isObject(obj)) {
967
1276
  throw new TypeError("target must be an object");
968
- t = t || new FormData(), n = a.toFlatObject(n, {
969
- metaTokens: !0,
970
- dots: !1,
971
- indexes: !1
972
- }, !1, function(R, m) {
973
- 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]);
974
1285
  });
975
- const r = n.metaTokens, s = n.visitor || u, o = n.dots, i = n.indexes, d = (n.Blob || typeof Blob < "u" && Blob) && a.isSpecCompliantForm(t);
976
- 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)) {
977
1293
  throw new TypeError("visitor must be a function");
978
- function l(h) {
979
- if (h === null) return "";
980
- if (a.isDate(h))
981
- return h.toISOString();
982
- if (!d && a.isBlob(h))
983
- throw new b("Blob is not supported. Use a Buffer instead.");
984
- return a.isArrayBuffer(h) || a.isTypedArray(h) ? d && typeof Blob == "function" ? new Blob([h]) : Buffer.from(h) : h;
985
- }
986
- function u(h, R, m) {
987
- let S = h;
988
- if (h && !m && typeof h == "object") {
989
- if (a.endsWith(R, "{}"))
990
- R = r ? R : R.slice(0, -2), h = JSON.stringify(h);
991
- else if (a.isArray(h) && er(h) || (a.isFileList(h) || a.endsWith(R, "[]")) && (S = a.toArray(h)))
992
- return R = Pt(R), S.forEach(function(E, O) {
993
- !(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(
994
1318
  // eslint-disable-next-line no-nested-ternary
995
- i === !0 ? Qe([R], O, o) : i === null ? R : R + "[]",
996
- l(E)
1319
+ indexes === true ? renderKey([key], index, dots) : indexes === null ? key : key + "[]",
1320
+ convertValue(el)
997
1321
  );
998
- }), !1;
1322
+ });
1323
+ return false;
1324
+ }
999
1325
  }
1000
- return ke(h) ? !0 : (t.append(Qe(m, R, o), l(h)), !1);
1001
- }
1002
- const p = [], y = Object.assign(tr, {
1003
- defaultVisitor: u,
1004
- convertValue: l,
1005
- 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
1006
1337
  });
1007
- function T(h, R) {
1008
- if (!a.isUndefined(h)) {
1009
- if (p.indexOf(h) !== -1)
1010
- throw Error("Circular reference detected in " + R.join("."));
1011
- p.push(h), a.forEach(h, function(S, A) {
1012
- (!(a.isUndefined(S) || S === null) && s.call(
1013
- t,
1014
- S,
1015
- a.isString(A) ? A.trim() : A,
1016
- R,
1017
- y
1018
- )) === !0 && T(S, R ? R.concat(A) : [A]);
1019
- }), p.pop();
1020
- }
1021
- }
1022
- 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)) {
1023
1359
  throw new TypeError("data must be an object");
1024
- return T(e), t;
1360
+ }
1361
+ build(obj);
1362
+ return formData;
1025
1363
  }
1026
- function et(e) {
1027
- const t = {
1364
+ function encode$1(str) {
1365
+ const charMap = {
1028
1366
  "!": "%21",
1029
1367
  "'": "%27",
1030
1368
  "(": "%28",
@@ -1033,44 +1371,56 @@ function et(e) {
1033
1371
  "%20": "+",
1034
1372
  "%00": "\0"
1035
1373
  };
1036
- return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g, function(r) {
1037
- return t[r];
1374
+ return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
1375
+ return charMap[match];
1038
1376
  });
1039
1377
  }
1040
- function Be(e, t) {
1041
- this._pairs = [], e && ye(e, this, t);
1378
+ function AxiosURLSearchParams(params, options) {
1379
+ this._pairs = [];
1380
+ params && toFormData$1(params, this, options);
1042
1381
  }
1043
- const xt = Be.prototype;
1044
- xt.append = function(t, n) {
1045
- this._pairs.push([t, n]);
1382
+ const prototype = AxiosURLSearchParams.prototype;
1383
+ prototype.append = function append(name, value) {
1384
+ this._pairs.push([name, value]);
1046
1385
  };
1047
- xt.toString = function(t) {
1048
- const n = t ? function(r) {
1049
- return t.call(this, r, et);
1050
- } : et;
1051
- return this._pairs.map(function(s) {
1052
- 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]);
1053
1392
  }, "").join("&");
1054
1393
  };
1055
- function nr(e) {
1056
- 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, "]");
1057
1396
  }
1058
- function Nt(e, t, n) {
1059
- if (!t)
1060
- return e;
1061
- const r = n && n.encode || nr;
1062
- a.isFunction(n) && (n = {
1063
- serialize: n
1064
- });
1065
- const s = n && n.serialize;
1066
- let o;
1067
- if (s ? o = s(t, n) : o = a.isURLSearchParams(t) ? t.toString() : new Be(t, n).toString(r), o) {
1068
- const i = e.indexOf("#");
1069
- 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
+ };
1070
1406
  }
1071
- 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;
1072
1422
  }
1073
- class tt {
1423
+ class InterceptorManager {
1074
1424
  constructor() {
1075
1425
  this.handlers = [];
1076
1426
  }
@@ -1082,13 +1432,14 @@ class tt {
1082
1432
  *
1083
1433
  * @return {Number} An ID used to remove interceptor later
1084
1434
  */
1085
- use(t, n, r) {
1086
- return this.handlers.push({
1087
- fulfilled: t,
1088
- rejected: n,
1089
- synchronous: r ? r.synchronous : !1,
1090
- runWhen: r ? r.runWhen : null
1091
- }), 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;
1092
1443
  }
1093
1444
  /**
1094
1445
  * Remove an interceptor from the stack
@@ -1097,8 +1448,10 @@ class tt {
1097
1448
  *
1098
1449
  * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
1099
1450
  */
1100
- eject(t) {
1101
- this.handlers[t] && (this.handlers[t] = null);
1451
+ eject(id) {
1452
+ if (this.handlers[id]) {
1453
+ this.handlers[id] = null;
1454
+ }
1102
1455
  }
1103
1456
  /**
1104
1457
  * Clear all interceptors from the stack
@@ -1106,7 +1459,9 @@ class tt {
1106
1459
  * @returns {void}
1107
1460
  */
1108
1461
  clear() {
1109
- this.handlers && (this.handlers = []);
1462
+ if (this.handlers) {
1463
+ this.handlers = [];
1464
+ }
1110
1465
  }
1111
1466
  /**
1112
1467
  * Iterate over all the registered interceptors
@@ -1118,122 +1473,191 @@ class tt {
1118
1473
  *
1119
1474
  * @returns {void}
1120
1475
  */
1121
- forEach(t) {
1122
- a.forEach(this.handlers, function(r) {
1123
- r !== null && t(r);
1476
+ forEach(fn) {
1477
+ utils$1.forEach(this.handlers, function forEachHandler(h) {
1478
+ if (h !== null) {
1479
+ fn(h);
1480
+ }
1124
1481
  });
1125
1482
  }
1126
1483
  }
1127
- const Ct = {
1128
- silentJSONParsing: !0,
1129
- forcedJSONParsing: !0,
1130
- clarifyTimeoutError: !1
1131
- }, rr = typeof URLSearchParams < "u" ? URLSearchParams : Be, sr = typeof FormData < "u" ? FormData : null, or = typeof Blob < "u" ? Blob : null, ir = {
1132
- 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,
1133
1494
  classes: {
1134
- URLSearchParams: rr,
1135
- FormData: sr,
1136
- Blob: or
1495
+ URLSearchParams: URLSearchParams$1,
1496
+ FormData: FormData$1,
1497
+ Blob: Blob$1
1137
1498
  },
1138
1499
  protocols: ["http", "https", "file", "blob", "url", "data"]
1139
- }, qe = typeof window < "u" && typeof document < "u", Fe = typeof navigator == "object" && navigator || void 0, ar = qe && (!Fe || ["ReactNative", "NativeScript", "NS"].indexOf(Fe.product) < 0), cr = typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef
1140
- 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({
1141
1510
  __proto__: null,
1142
- hasBrowserEnv: qe,
1143
- hasStandardBrowserEnv: ar,
1144
- hasStandardBrowserWebWorkerEnv: cr,
1145
- navigator: Fe,
1146
- origin: lr
1147
- }, Symbol.toStringTag, { value: "Module" })), F = {
1148
- ...ur,
1149
- ...ir
1511
+ hasBrowserEnv,
1512
+ hasStandardBrowserEnv,
1513
+ hasStandardBrowserWebWorkerEnv,
1514
+ navigator: _navigator,
1515
+ origin
1516
+ });
1517
+ const platform = {
1518
+ ...utils,
1519
+ ...platform$1
1150
1520
  };
1151
- function fr(e, t) {
1152
- return ye(e, new F.classes.URLSearchParams(), Object.assign({
1153
- visitor: function(n, r, s, o) {
1154
- return F.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);
1155
1529
  }
1156
- }, t));
1530
+ }, options));
1157
1531
  }
1158
- function dr(e) {
1159
- 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
+ });
1160
1536
  }
1161
- function pr(e) {
1162
- const t = {}, n = Object.keys(e);
1163
- let r;
1164
- const s = n.length;
1165
- let o;
1166
- for (r = 0; r < s; r++)
1167
- o = n[r], t[o] = e[o];
1168
- 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;
1169
1548
  }
1170
- function kt(e) {
1171
- function t(n, r, s, o) {
1172
- let i = n[o++];
1173
- if (i === "__proto__") return !0;
1174
- const c = Number.isFinite(+i), d = o >= n.length;
1175
- 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);
1176
- }
1177
- if (a.isFormData(e) && a.isFunction(e.entries)) {
1178
- const n = {};
1179
- return a.forEachEntry(e, (r, s) => {
1180
- t(dr(r), s, n, 0);
1181
- }), 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;
1182
1579
  }
1183
1580
  return null;
1184
1581
  }
1185
- function hr(e, t, n) {
1186
- if (a.isString(e))
1582
+ function stringifySafely(rawValue, parser, encoder) {
1583
+ if (utils$1.isString(rawValue)) {
1187
1584
  try {
1188
- return (t || JSON.parse)(e), a.trim(e);
1189
- } catch (r) {
1190
- if (r.name !== "SyntaxError")
1191
- 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
+ }
1192
1591
  }
1193
- return (n || JSON.stringify)(e);
1592
+ }
1593
+ return (encoder || JSON.stringify)(rawValue);
1194
1594
  }
1195
- const ae = {
1196
- transitional: Ct,
1595
+ const defaults = {
1596
+ transitional: transitionalDefaults,
1197
1597
  adapter: ["xhr", "http", "fetch"],
1198
- transformRequest: [function(t, n) {
1199
- const r = n.getContentType() || "", s = r.indexOf("application/json") > -1, o = a.isObject(t);
1200
- if (o && a.isHTMLForm(t) && (t = new FormData(t)), a.isFormData(t))
1201
- return s ? JSON.stringify(kt(t)) : t;
1202
- if (a.isArrayBuffer(t) || a.isBuffer(t) || a.isStream(t) || a.isFile(t) || a.isBlob(t) || a.isReadableStream(t))
1203
- return t;
1204
- if (a.isArrayBufferView(t))
1205
- return t.buffer;
1206
- if (a.isURLSearchParams(t))
1207
- return n.setContentType("application/x-www-form-urlencoded;charset=utf-8", !1), t.toString();
1208
- let c;
1209
- if (o) {
1210
- if (r.indexOf("application/x-www-form-urlencoded") > -1)
1211
- return fr(t, this.formSerializer).toString();
1212
- if ((c = a.isFileList(t)) || r.indexOf("multipart/form-data") > -1) {
1213
- const d = this.env && this.env.FormData;
1214
- return ye(
1215
- c ? { "files[]": t } : t,
1216
- 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(),
1217
1629
  this.formSerializer
1218
1630
  );
1219
1631
  }
1220
1632
  }
1221
- 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;
1222
1638
  }],
1223
- transformResponse: [function(t) {
1224
- const n = this.transitional || ae.transitional, r = n && n.forcedJSONParsing, s = this.responseType === "json";
1225
- if (a.isResponse(t) || a.isReadableStream(t))
1226
- return t;
1227
- if (t && a.isString(t) && (r && !this.responseType || s)) {
1228
- 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;
1229
1649
  try {
1230
- return JSON.parse(t);
1231
- } catch (c) {
1232
- if (i)
1233
- 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
+ }
1234
1658
  }
1235
1659
  }
1236
- return t;
1660
+ return data;
1237
1661
  }],
1238
1662
  /**
1239
1663
  * A timeout in milliseconds to abort a request. If set to 0 (default) a
@@ -1245,23 +1669,23 @@ const ae = {
1245
1669
  maxContentLength: -1,
1246
1670
  maxBodyLength: -1,
1247
1671
  env: {
1248
- FormData: F.classes.FormData,
1249
- Blob: F.classes.Blob
1672
+ FormData: platform.classes.FormData,
1673
+ Blob: platform.classes.Blob
1250
1674
  },
1251
- validateStatus: function(t) {
1252
- return t >= 200 && t < 300;
1675
+ validateStatus: function validateStatus(status) {
1676
+ return status >= 200 && status < 300;
1253
1677
  },
1254
1678
  headers: {
1255
1679
  common: {
1256
- Accept: "application/json, text/plain, */*",
1680
+ "Accept": "application/json, text/plain, */*",
1257
1681
  "Content-Type": void 0
1258
1682
  }
1259
1683
  }
1260
1684
  };
1261
- a.forEach(["delete", "get", "head", "post", "put", "patch"], (e) => {
1262
- ae.headers[e] = {};
1685
+ utils$1.forEach(["delete", "get", "head", "post", "put", "patch"], (method) => {
1686
+ defaults.headers[method] = {};
1263
1687
  });
1264
- const mr = a.toObjectSet([
1688
+ const ignoreDuplicateOf = utils$1.toObjectSet([
1265
1689
  "age",
1266
1690
  "authorization",
1267
1691
  "content-length",
@@ -1279,153 +1703,214 @@ const mr = a.toObjectSet([
1279
1703
  "referer",
1280
1704
  "retry-after",
1281
1705
  "user-agent"
1282
- ]), Rr = (e) => {
1283
- const t = {};
1284
- let n, r, s;
1285
- return e && e.split(`
1286
- `).forEach(function(i) {
1287
- 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);
1288
- }), t;
1289
- }, nt = Symbol("internals");
1290
- function te(e) {
1291
- 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();
1292
1734
  }
1293
- function ue(e) {
1294
- 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);
1295
1740
  }
1296
- function Er(e) {
1297
- const t = /* @__PURE__ */ Object.create(null), n = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
1298
- let r;
1299
- for (; r = n.exec(e); )
1300
- t[r[1]] = r[2];
1301
- 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;
1302
1749
  }
1303
- const br = (e) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());
1304
- function Pe(e, t, n, r, s) {
1305
- if (a.isFunction(r))
1306
- return r.call(this, t, n);
1307
- if (s && (t = n), !!a.isString(t)) {
1308
- if (a.isString(r))
1309
- return t.indexOf(r) !== -1;
1310
- if (a.isRegExp(r))
1311
- 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);
1312
1764
  }
1313
1765
  }
1314
- function yr(e) {
1315
- 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
+ });
1316
1770
  }
1317
- function wr(e, t) {
1318
- const n = a.toCamelCase(" " + t);
1319
- ["get", "set", "has"].forEach((r) => {
1320
- Object.defineProperty(e, r + n, {
1321
- value: function(s, o, i) {
1322
- 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);
1323
1777
  },
1324
- configurable: !0
1778
+ configurable: true
1325
1779
  });
1326
1780
  });
1327
1781
  }
1328
- let U = class {
1329
- constructor(t) {
1330
- t && this.set(t);
1331
- }
1332
- set(t, n, r) {
1333
- const s = this;
1334
- function o(c, d, l) {
1335
- const u = te(d);
1336
- 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) {
1337
1791
  throw new Error("header name must be a non-empty string");
1338
- const p = a.findKey(s, u);
1339
- (!p || s[p] === void 0 || l === !0 || l === void 0 && s[p] !== !1) && (s[p || d] = ue(c));
1340
- }
1341
- const i = (c, d) => a.forEach(c, (l, u) => o(l, u, d));
1342
- if (a.isPlainObject(t) || t instanceof this.constructor)
1343
- i(t, n);
1344
- else if (a.isString(t) && (t = t.trim()) && !br(t))
1345
- i(Rr(t), n);
1346
- else if (a.isObject(t) && a.isIterable(t)) {
1347
- let c = {}, d, l;
1348
- for (const u of t) {
1349
- 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)) {
1350
1807
  throw TypeError("Object iterator must return a key-value pair");
1351
- 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];
1352
1810
  }
1353
- i(c, n);
1354
- } else
1355
- t != null && o(n, t, r);
1811
+ setHeaders(obj, valueOrRewrite);
1812
+ } else {
1813
+ header != null && setHeader(valueOrRewrite, header, rewrite);
1814
+ }
1356
1815
  return this;
1357
1816
  }
1358
- get(t, n) {
1359
- if (t = te(t), t) {
1360
- const r = a.findKey(this, t);
1361
- if (r) {
1362
- const s = this[r];
1363
- if (!n)
1364
- return s;
1365
- if (n === !0)
1366
- return Er(s);
1367
- if (a.isFunction(n))
1368
- return n.call(this, s, r);
1369
- if (a.isRegExp(n))
1370
- 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
+ }
1371
1835
  throw new TypeError("parser must be boolean|regexp|function");
1372
1836
  }
1373
1837
  }
1374
1838
  }
1375
- has(t, n) {
1376
- if (t = te(t), t) {
1377
- const r = a.findKey(this, t);
1378
- 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)));
1379
1844
  }
1380
- return !1;
1381
- }
1382
- delete(t, n) {
1383
- const r = this;
1384
- let s = !1;
1385
- function o(i) {
1386
- if (i = te(i), i) {
1387
- const c = a.findKey(r, i);
1388
- 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
+ }
1389
1858
  }
1390
1859
  }
1391
- return a.isArray(t) ? t.forEach(o) : o(t), s;
1392
- }
1393
- clear(t) {
1394
- const n = Object.keys(this);
1395
- let r = n.length, s = !1;
1396
- for (; r--; ) {
1397
- const o = n[r];
1398
- (!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);
1399
1864
  }
1400
- return s;
1401
- }
1402
- normalize(t) {
1403
- const n = this, r = {};
1404
- return a.forEach(this, (s, o) => {
1405
- const i = a.findKey(r, o);
1406
- if (i) {
1407
- 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];
1408
1888
  return;
1409
1889
  }
1410
- const c = t ? yr(o) : String(o).trim();
1411
- c !== o && delete n[o], n[c] = ue(s), r[c] = !0;
1412
- }), 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;
1413
1898
  }
1414
- concat(...t) {
1415
- return this.constructor.concat(this, ...t);
1899
+ concat(...targets) {
1900
+ return this.constructor.concat(this, ...targets);
1416
1901
  }
1417
- toJSON(t) {
1418
- const n = /* @__PURE__ */ Object.create(null);
1419
- return a.forEach(this, (r, s) => {
1420
- r != null && r !== !1 && (n[s] = t && a.isArray(r) ? r.join(", ") : r);
1421
- }), 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;
1422
1908
  }
1423
1909
  [Symbol.iterator]() {
1424
1910
  return Object.entries(this.toJSON())[Symbol.iterator]();
1425
1911
  }
1426
1912
  toString() {
1427
- return Object.entries(this.toJSON()).map(([t, n]) => t + ": " + n).join(`
1428
- `);
1913
+ return Object.entries(this.toJSON()).map(([header, value]) => header + ": " + value).join("\n");
1429
1914
  }
1430
1915
  getSetCookie() {
1431
1916
  return this.get("set-cookie") || [];
@@ -1433,135 +1918,203 @@ let U = class {
1433
1918
  get [Symbol.toStringTag]() {
1434
1919
  return "AxiosHeaders";
1435
1920
  }
1436
- static from(t) {
1437
- return t instanceof this ? t : new this(t);
1921
+ static from(thing) {
1922
+ return thing instanceof this ? thing : new this(thing);
1438
1923
  }
1439
- static concat(t, ...n) {
1440
- const r = new this(t);
1441
- 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;
1442
1928
  }
1443
- static accessor(t) {
1444
- const r = (this[nt] = this[nt] = {
1929
+ static accessor(header) {
1930
+ const internals = this[$internals] = this[$internals] = {
1445
1931
  accessors: {}
1446
- }).accessors, s = this.prototype;
1447
- function o(i) {
1448
- const c = te(i);
1449
- 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
+ }
1450
1941
  }
1451
- return a.isArray(t) ? t.forEach(o) : o(t), this;
1942
+ utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
1943
+ return this;
1452
1944
  }
1453
1945
  };
1454
- U.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]);
1455
- a.reduceDescriptors(U.prototype, ({ value: e }, t) => {
1456
- 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);
1457
1949
  return {
1458
- get: () => e,
1459
- set(r) {
1460
- this[n] = r;
1950
+ get: () => value,
1951
+ set(headerValue) {
1952
+ this[mapped] = headerValue;
1461
1953
  }
1462
1954
  };
1463
1955
  });
1464
- a.freezeMethods(U);
1465
- function xe(e, t) {
1466
- const n = this || ae, r = t || n, s = U.from(r.headers);
1467
- let o = r.data;
1468
- return a.forEach(e, function(c) {
1469
- o = c.call(n, o, s.normalize(), t ? t.status : void 0);
1470
- }), 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;
1471
1967
  }
1472
- function Ft(e) {
1473
- return !!(e && e.__CANCEL__);
1968
+ function isCancel$1(value) {
1969
+ return !!(value && value.__CANCEL__);
1474
1970
  }
1475
- function G(e, t, n) {
1476
- 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";
1477
1974
  }
1478
- a.inherits(G, b, {
1479
- __CANCEL__: !0
1975
+ utils$1.inherits(CanceledError$1, AxiosError$1, {
1976
+ __CANCEL__: true
1480
1977
  });
1481
- function vt(e, t, n) {
1482
- const r = n.config.validateStatus;
1483
- !n.status || !r || r(n.status) ? e(n) : t(new b(
1484
- "Request failed with status code " + n.status,
1485
- [b.ERR_BAD_REQUEST, b.ERR_BAD_RESPONSE][Math.floor(n.status / 100) - 4],
1486
- n.config,
1487
- n.request,
1488
- n
1489
- ));
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
+ }
1490
1991
  }
1491
- function Tr(e) {
1492
- const t = /^([-+\w]{1,25})(:?\/\/|:)/.exec(e);
1493
- return t && t[1] || "";
1992
+ function parseProtocol(url) {
1993
+ const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
1994
+ return match && match[1] || "";
1494
1995
  }
1495
- function gr(e, t) {
1496
- e = e || 10;
1497
- const n = new Array(e), r = new Array(e);
1498
- let s = 0, o = 0, i;
1499
- return t = t !== void 0 ? t : 1e3, function(d) {
1500
- const l = Date.now(), u = r[o];
1501
- i || (i = l), n[s] = d, r[s] = l;
1502
- let p = o, y = 0;
1503
- for (; p !== s; )
1504
- y += n[p++], p = p % e;
1505
- 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) {
1506
2023
  return;
1507
- const T = u && l - u;
1508
- 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;
1509
2027
  };
1510
2028
  }
1511
- function Sr(e, t) {
1512
- let n = 0, r = 1e3 / t, s, o;
1513
- const i = (l, u = Date.now()) => {
1514
- 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
+ }
1515
2057
  };
1516
- return [(...l) => {
1517
- const u = Date.now(), p = u - n;
1518
- p >= r ? i(l, u) : (s = l, o || (o = setTimeout(() => {
1519
- o = null, i(s);
1520
- }, r - p)));
1521
- }, () => s && i(s)];
2058
+ const flush = () => lastArgs && invoke(lastArgs);
2059
+ return [throttled, flush];
1522
2060
  }
1523
- const pe = (e, t, n = 3) => {
1524
- let r = 0;
1525
- const s = gr(50, 250);
1526
- return Sr((o) => {
1527
- const i = o.loaded, c = o.lengthComputable ? o.total : void 0, d = i - r, l = s(d), u = i <= c;
1528
- r = i;
1529
- const p = {
1530
- loaded: i,
1531
- total: c,
1532
- progress: c ? i / c : void 0,
1533
- bytes: d,
1534
- rate: l || void 0,
1535
- estimated: l && c && u ? (c - i) / l : void 0,
1536
- event: o,
1537
- lengthComputable: c != null,
1538
- [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
1539
2081
  };
1540
- e(p);
1541
- }, n);
1542
- }, rt = (e, t) => {
1543
- const n = e != null;
1544
- return [(r) => t[0]({
1545
- lengthComputable: n,
1546
- total: e,
1547
- loaded: r
1548
- }), t[1]];
1549
- }, st = (e) => (...t) => a.asap(() => e(...t)), Or = F.hasStandardBrowserEnv ? /* @__PURE__ */ ((e, t) => (n) => (n = new URL(n, F.origin), e.protocol === n.protocol && e.host === n.host && (t || e.port === n.port)))(
1550
- new URL(F.origin),
1551
- F.navigator && /(msie|trident)/i.test(F.navigator.userAgent)
1552
- ) : () => !0, Ar = F.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 ? (
1553
2102
  // Standard browser envs support document.cookie
1554
2103
  {
1555
- write(e, t, n, r, s, o) {
1556
- const i = [e + "=" + encodeURIComponent(t)];
1557
- 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("; ");
1558
2111
  },
1559
- read(e) {
1560
- const t = document.cookie.match(new RegExp("(^|;\\s*)(" + e + ")=([^;]*)"));
1561
- 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;
1562
2115
  },
1563
- remove(e) {
1564
- this.write(e, "", Date.now() - 864e5);
2116
+ remove(name) {
2117
+ this.write(name, "", Date.now() - 864e5);
1565
2118
  }
1566
2119
  }
1567
2120
  ) : (
@@ -1576,488 +2129,688 @@ const pe = (e, t, n = 3) => {
1576
2129
  }
1577
2130
  }
1578
2131
  );
1579
- function _r(e) {
1580
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(e);
2132
+ function isAbsoluteURL(url) {
2133
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
1581
2134
  }
1582
- function Pr(e, t) {
1583
- return t ? e.replace(/\/?\/$/, "") + "/" + t.replace(/^\/+/, "") : e;
2135
+ function combineURLs(baseURL, relativeURL) {
2136
+ return relativeURL ? baseURL.replace(/\/?\/$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
1584
2137
  }
1585
- function jt(e, t, n) {
1586
- let r = !_r(t);
1587
- 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;
1588
2144
  }
1589
- const ot = (e) => e instanceof U ? { ...e } : e;
1590
- function W(e, t) {
1591
- t = t || {};
1592
- const n = {};
1593
- function r(l, u, p, y) {
1594
- 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;
1595
- }
1596
- function s(l, u, p, y) {
1597
- if (a.isUndefined(u)) {
1598
- if (!a.isUndefined(l))
1599
- return r(void 0, l, p, y);
1600
- } else return r(l, u, p, y);
1601
- }
1602
- function o(l, u) {
1603
- if (!a.isUndefined(u))
1604
- return r(void 0, u);
1605
- }
1606
- function i(l, u) {
1607
- if (a.isUndefined(u)) {
1608
- if (!a.isUndefined(l))
1609
- return r(void 0, l);
1610
- } else return r(void 0, u);
1611
- }
1612
- function c(l, u, p) {
1613
- if (p in t)
1614
- return r(l, u);
1615
- if (p in e)
1616
- return r(void 0, l);
1617
- }
1618
- const d = {
1619
- url: o,
1620
- method: o,
1621
- data: o,
1622
- baseURL: i,
1623
- transformRequest: i,
1624
- transformResponse: i,
1625
- paramsSerializer: i,
1626
- timeout: i,
1627
- timeoutMessage: i,
1628
- withCredentials: i,
1629
- withXSRFToken: i,
1630
- adapter: i,
1631
- responseType: i,
1632
- xsrfCookieName: i,
1633
- xsrfHeaderName: i,
1634
- onUploadProgress: i,
1635
- onDownloadProgress: i,
1636
- decompress: i,
1637
- maxContentLength: i,
1638
- maxBodyLength: i,
1639
- beforeRedirect: i,
1640
- transport: i,
1641
- httpAgent: i,
1642
- httpsAgent: i,
1643
- cancelToken: i,
1644
- socketPath: i,
1645
- responseEncoding: i,
1646
- validateStatus: c,
1647
- 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)
1648
2215
  };
1649
- return a.forEach(Object.keys(Object.assign({}, e, t)), function(u) {
1650
- const p = d[u] || s, y = p(e[u], t[u], u);
1651
- a.isUndefined(y) && p !== c || (n[u] = y);
1652
- }), 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;
1653
2222
  }
1654
- const Lt = (e) => {
1655
- const t = W({}, e);
1656
- let { data: n, withXSRFToken: r, xsrfHeaderName: s, xsrfCookieName: o, headers: i, auth: c } = t;
1657
- t.headers = i = U.from(i), t.url = Nt(jt(t.baseURL, t.url, t.allowAbsoluteUrls), e.params, e.paramsSerializer), c && i.set(
1658
- "Authorization",
1659
- "Basic " + btoa((c.username || "") + ":" + (c.password ? unescape(encodeURIComponent(c.password)) : ""))
1660
- );
1661
- let d;
1662
- if (a.isFormData(n)) {
1663
- if (F.hasStandardBrowserEnv || F.hasStandardBrowserWebWorkerEnv)
1664
- i.setContentType(void 0);
1665
- else if ((d = i.getContentType()) !== !1) {
1666
- const [l, ...u] = d ? d.split(";").map((p) => p.trim()).filter(Boolean) : [];
1667
- i.setContentType([l || "multipart/form-data", ...u].join("; "));
1668
- }
1669
- }
1670
- if (F.hasStandardBrowserEnv && (r && a.isFunction(r) && (r = r(t)), r || r !== !1 && Or(t.url))) {
1671
- const l = s && o && Ar.read(o);
1672
- l && i.set(s, l);
1673
- }
1674
- return t;
1675
- }, xr = typeof XMLHttpRequest < "u", Nr = xr && function(e) {
1676
- return new Promise(function(n, r) {
1677
- const s = Lt(e);
1678
- let o = s.data;
1679
- const i = U.from(s.headers).normalize();
1680
- let { responseType: c, onUploadProgress: d, onDownloadProgress: l } = s, u, p, y, T, h;
1681
- function R() {
1682
- T && T(), h && h(), s.cancelToken && s.cancelToken.unsubscribe(u), s.signal && s.signal.removeEventListener("abort", u);
1683
- }
1684
- let m = new XMLHttpRequest();
1685
- m.open(s.method.toUpperCase(), s.url, !0), m.timeout = s.timeout;
1686
- function S() {
1687
- 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) {
1688
2275
  return;
1689
- const E = U.from(
1690
- "getAllResponseHeaders" in m && m.getAllResponseHeaders()
1691
- ), g = {
1692
- data: !c || c === "text" || c === "json" ? m.responseText : m.response,
1693
- status: m.status,
1694
- statusText: m.statusText,
1695
- headers: E,
1696
- config: e,
1697
- 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);
1698
2309
  };
1699
- vt(function(N) {
1700
- n(N), R();
1701
- }, function(N) {
1702
- r(N), R();
1703
- }, g), m = null;
1704
- }
1705
- "onloadend" in m ? m.onloadend = S : m.onreadystatechange = function() {
1706
- !m || m.readyState !== 4 || m.status === 0 && !(m.responseURL && m.responseURL.indexOf("file:") === 0) || setTimeout(S);
1707
- }, m.onabort = function() {
1708
- m && (r(new b("Request aborted", b.ECONNABORTED, e, m)), m = null);
1709
- }, m.onerror = function() {
1710
- r(new b("Network Error", b.ERR_NETWORK, e, m)), m = null;
1711
- }, m.ontimeout = function() {
1712
- let O = s.timeout ? "timeout of " + s.timeout + "ms exceeded" : "timeout exceeded";
1713
- const g = s.transitional || Ct;
1714
- s.timeoutErrorMessage && (O = s.timeoutErrorMessage), r(new b(
1715
- O,
1716
- g.clarifyTimeoutError ? b.ETIMEDOUT : b.ECONNABORTED,
1717
- e,
1718
- m
1719
- )), m = null;
1720
- }, o === void 0 && i.setContentType(null), "setRequestHeader" in m && a.forEach(i.toJSON(), function(O, g) {
1721
- m.setRequestHeader(g, O);
1722
- }), 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) => {
1723
- m && (r(!E || E.type ? new G(null, e, m) : E), m.abort(), m = null);
1724
- }, s.cancelToken && s.cancelToken.subscribe(u), s.signal && (s.signal.aborted ? u() : s.signal.addEventListener("abort", u)));
1725
- const A = Tr(s.url);
1726
- if (A && F.protocols.indexOf(A) === -1) {
1727
- 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));
1728
2374
  return;
1729
2375
  }
1730
- m.send(o || null);
2376
+ request.send(requestData || null);
1731
2377
  });
1732
- }, Cr = (e, t) => {
1733
- const { length: n } = e = e ? e.filter(Boolean) : [];
1734
- if (t || n) {
1735
- let r = new AbortController(), s;
1736
- const o = function(l) {
1737
- if (!s) {
1738
- s = !0, c();
1739
- const u = l instanceof Error ? l : this.reason;
1740
- 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));
1741
2390
  }
1742
2391
  };
1743
- let i = t && setTimeout(() => {
1744
- i = null, o(new b(`timeout ${t} of ms exceeded`, b.ETIMEDOUT));
1745
- }, t);
1746
- const c = () => {
1747
- e && (i && clearTimeout(i), i = null, e.forEach((l) => {
1748
- l.unsubscribe ? l.unsubscribe(o) : l.removeEventListener("abort", o);
1749
- }), 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
+ }
1750
2405
  };
1751
- e.forEach((l) => l.addEventListener("abort", o));
1752
- const { signal: d } = r;
1753
- return d.unsubscribe = () => a.asap(c), d;
1754
- }
1755
- }, kr = function* (e, t) {
1756
- let n = e.byteLength;
1757
- if (n < t) {
1758
- 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;
1759
2416
  return;
1760
2417
  }
1761
- let r = 0, s;
1762
- for (; r < n; )
1763
- s = r + t, yield e.slice(r, s), r = s;
1764
- }, Fr = async function* (e, t) {
1765
- for await (const n of vr(e))
1766
- yield* kr(n, t);
1767
- }, vr = async function* (e) {
1768
- if (e[Symbol.asyncIterator]) {
1769
- 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;
1770
2434
  return;
1771
2435
  }
1772
- const t = e.getReader();
2436
+ const reader = stream.getReader();
1773
2437
  try {
1774
2438
  for (; ; ) {
1775
- const { done: n, value: r } = await t.read();
1776
- if (n)
2439
+ const { done, value } = await reader.read();
2440
+ if (done) {
1777
2441
  break;
1778
- yield r;
2442
+ }
2443
+ yield value;
1779
2444
  }
1780
2445
  } finally {
1781
- await t.cancel();
2446
+ await reader.cancel();
1782
2447
  }
1783
- }, it = (e, t, n, r) => {
1784
- const s = Fr(e, t);
1785
- let o = 0, i, c = (d) => {
1786
- 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
+ }
1787
2458
  };
1788
2459
  return new ReadableStream({
1789
- async pull(d) {
2460
+ async pull(controller) {
1790
2461
  try {
1791
- const { done: l, value: u } = await s.next();
1792
- if (l) {
1793
- c(), d.close();
2462
+ const { done: done2, value } = await iterator2.next();
2463
+ if (done2) {
2464
+ _onFinish();
2465
+ controller.close();
1794
2466
  return;
1795
2467
  }
1796
- let p = u.byteLength;
1797
- if (n) {
1798
- let y = o += p;
1799
- n(y);
2468
+ let len = value.byteLength;
2469
+ if (onProgress) {
2470
+ let loadedBytes = bytes += len;
2471
+ onProgress(loadedBytes);
1800
2472
  }
1801
- d.enqueue(new Uint8Array(u));
1802
- } catch (l) {
1803
- throw c(l), l;
2473
+ controller.enqueue(new Uint8Array(value));
2474
+ } catch (err) {
2475
+ _onFinish(err);
2476
+ throw err;
1804
2477
  }
1805
2478
  },
1806
- cancel(d) {
1807
- return c(d), s.return();
2479
+ cancel(reason) {
2480
+ _onFinish(reason);
2481
+ return iterator2.return();
1808
2482
  }
1809
2483
  }, {
1810
2484
  highWaterMark: 2
1811
2485
  });
1812
- }, 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) => {
1813
2491
  try {
1814
- return !!e(...t);
1815
- } catch {
1816
- return !1;
2492
+ return !!fn(...args);
2493
+ } catch (e2) {
2494
+ return false;
1817
2495
  }
1818
- }, Lr = Ut && Dt(() => {
1819
- let e = !1;
1820
- const t = new Request(F.origin, {
2496
+ };
2497
+ const supportsRequestStream = isReadableStreamSupported && test(() => {
2498
+ let duplexAccessed = false;
2499
+ const hasContentType = new Request(platform.origin, {
1821
2500
  body: new ReadableStream(),
1822
2501
  method: "POST",
1823
2502
  get duplex() {
1824
- return e = !0, "half";
2503
+ duplexAccessed = true;
2504
+ return "half";
1825
2505
  }
1826
2506
  }).headers.has("Content-Type");
1827
- return e && !t;
1828
- }), at = 64 * 1024, ve = Ut && Dt(() => a.isReadableStream(new Response("").body)), he = {
1829
- stream: ve && ((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)
1830
2513
  };
1831
- we && ((e) => {
1832
- ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((t) => {
1833
- !he[t] && (he[t] = a.isFunction(e[t]) ? (n) => n[t]() : (n, r) => {
1834
- 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);
1835
2518
  });
1836
2519
  });
1837
2520
  })(new Response());
1838
- const Ur = async (e) => {
1839
- if (e == null)
2521
+ const getBodyLength = async (body) => {
2522
+ if (body == null) {
1840
2523
  return 0;
1841
- if (a.isBlob(e))
1842
- return e.size;
1843
- if (a.isSpecCompliantForm(e))
1844
- return (await new Request(F.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, {
1845
2530
  method: "POST",
1846
- body: e
1847
- }).arrayBuffer()).byteLength;
1848
- if (a.isArrayBufferView(e) || a.isArrayBuffer(e))
1849
- return e.byteLength;
1850
- if (a.isURLSearchParams(e) && (e = e + ""), a.isString(e))
1851
- return (await jr(e)).byteLength;
1852
- }, Dr = async (e, t) => {
1853
- const n = a.toFiniteNumber(e.getContentLength());
1854
- return n ?? Ur(t);
1855
- }, 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) => {
1856
2550
  let {
1857
- url: t,
1858
- method: n,
1859
- data: r,
1860
- signal: s,
1861
- cancelToken: o,
1862
- timeout: i,
1863
- onDownloadProgress: c,
1864
- onUploadProgress: d,
1865
- responseType: l,
1866
- headers: u,
1867
- withCredentials: p = "same-origin",
1868
- fetchOptions: y
1869
- } = Lt(e);
1870
- l = l ? (l + "").toLowerCase() : "text";
1871
- let T = Cr([s, o && o.toAbortSignal()], i), h;
1872
- const R = T && T.unsubscribe && (() => {
1873
- 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();
1874
2569
  });
1875
- let m;
2570
+ let requestContentLength;
1876
2571
  try {
1877
- if (d && Lr && n !== "get" && n !== "head" && (m = await Dr(u, r)) !== 0) {
1878
- 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, {
1879
2574
  method: "POST",
1880
- body: r,
2575
+ body: data,
1881
2576
  duplex: "half"
1882
- }), x;
1883
- if (a.isFormData(r) && (x = g.headers.get("content-type")) && u.setContentType(x), g.body) {
1884
- const [N, B] = rt(
1885
- m,
1886
- 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))
1887
2586
  );
1888
- r = it(g.body, at, N, B);
2587
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
1889
2588
  }
1890
2589
  }
1891
- a.isString(p) || (p = p ? "include" : "omit");
1892
- const S = "credentials" in Request.prototype;
1893
- h = new Request(t, {
1894
- ...y,
1895
- signal: T,
1896
- method: n.toUpperCase(),
1897
- headers: u.normalize().toJSON(),
1898
- 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,
1899
2600
  duplex: "half",
1900
- credentials: S ? p : void 0
2601
+ credentials: isCredentialsSupported ? withCredentials : void 0
1901
2602
  });
1902
- let A = await fetch(h);
1903
- const E = ve && (l === "stream" || l === "response");
1904
- if (ve && (c || E && R)) {
1905
- const g = {};
1906
- ["status", "statusText", "headers"].forEach((j) => {
1907
- 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];
1908
2609
  });
1909
- const x = a.toFiniteNumber(A.headers.get("content-length")), [N, B] = c && rt(
1910
- x,
1911
- 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)
1912
2614
  ) || [];
1913
- A = new Response(
1914
- it(A.body, at, N, () => {
1915
- B && B(), R && R();
2615
+ response = new Response(
2616
+ trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
2617
+ flush && flush();
2618
+ unsubscribe && unsubscribe();
1916
2619
  }),
1917
- g
2620
+ options
1918
2621
  );
1919
2622
  }
1920
- l = l || "text";
1921
- let O = await he[a.findKey(he, l) || "text"](A, e);
1922
- return !E && R && R(), await new Promise((g, x) => {
1923
- vt(g, x, {
1924
- data: O,
1925
- headers: U.from(A.headers),
1926
- status: A.status,
1927
- statusText: A.statusText,
1928
- config: e,
1929
- 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
1930
2634
  });
1931
2635
  });
1932
- } catch (S) {
1933
- throw R && R(), S && S.name === "TypeError" && /Load failed|fetch/i.test(S.message) ? Object.assign(
1934
- new b("Network Error", b.ERR_NETWORK, e, h),
1935
- {
1936
- cause: S.cause || S
1937
- }
1938
- ) : 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);
1939
2647
  }
1940
- }), je = {
1941
- http: Qn,
1942
- xhr: Nr,
1943
- fetch: Br
2648
+ });
2649
+ const knownAdapters = {
2650
+ http: httpAdapter,
2651
+ xhr: xhrAdapter,
2652
+ fetch: fetchAdapter
1944
2653
  };
1945
- a.forEach(je, (e, t) => {
1946
- if (e) {
2654
+ utils$1.forEach(knownAdapters, (fn, value) => {
2655
+ if (fn) {
1947
2656
  try {
1948
- Object.defineProperty(e, "name", { value: t });
1949
- } catch {
2657
+ Object.defineProperty(fn, "name", { value });
2658
+ } catch (e2) {
1950
2659
  }
1951
- Object.defineProperty(e, "adapterName", { value: t });
2660
+ Object.defineProperty(fn, "adapterName", { value });
1952
2661
  }
1953
2662
  });
1954
- const ct = (e) => `- ${e}`, qr = (e) => a.isFunction(e) || e === null || e === !1, Bt = {
1955
- getAdapter: (e) => {
1956
- e = a.isArray(e) ? e : [e];
1957
- const { length: t } = e;
1958
- let n, r;
1959
- const s = {};
1960
- for (let o = 0; o < t; o++) {
1961
- n = e[o];
1962
- let i;
1963
- if (r = n, !qr(n) && (r = je[(i = String(n)).toLowerCase()], r === void 0))
1964
- throw new b(`Unknown adapter '${i}'`);
1965
- 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) {
1966
2683
  break;
1967
- s[i || "#" + o] = r;
2684
+ }
2685
+ rejectedReasons[id || "#" + i2] = adapter;
1968
2686
  }
1969
- if (!r) {
1970
- const o = Object.entries(s).map(
1971
- ([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")
1972
2690
  );
1973
- let i = t ? o.length > 1 ? `since :
1974
- ` + o.map(ct).join(`
1975
- `) : " " + ct(o[0]) : "as no adapter specified";
1976
- throw new b(
1977
- "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,
1978
2694
  "ERR_NOT_SUPPORT"
1979
2695
  );
1980
2696
  }
1981
- return r;
2697
+ return adapter;
1982
2698
  },
1983
- adapters: je
2699
+ adapters: knownAdapters
1984
2700
  };
1985
- function Ne(e) {
1986
- if (e.cancelToken && e.cancelToken.throwIfRequested(), e.signal && e.signal.aborted)
1987
- 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
+ }
1988
2708
  }
1989
- function lt(e) {
1990
- return Ne(e), e.headers = U.from(e.headers), e.data = xe.call(
1991
- e,
1992
- e.transformRequest
1993
- ), ["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) {
1994
- return Ne(e), r.data = xe.call(
1995
- e,
1996
- e.transformResponse,
1997
- r
1998
- ), r.headers = U.from(r.headers), r;
1999
- }, function(r) {
2000
- return Ft(r) || (Ne(e), r && r.response && (r.response.data = xe.call(
2001
- e,
2002
- e.transformResponse,
2003
- r.response
2004
- ), 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);
2005
2742
  });
2006
2743
  }
2007
- const qt = "1.9.0", Te = {};
2008
- ["object", "boolean", "number", "function", "string", "symbol"].forEach((e, t) => {
2009
- Te[e] = function(r) {
2010
- 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;
2011
2749
  };
2012
2750
  });
2013
- const ut = {};
2014
- Te.transitional = function(t, n, r) {
2015
- function s(o, i) {
2016
- return "[Axios v" + qt + "] Transitional option '" + o + "'" + i + (r ? ". " + r : "");
2017
- }
2018
- return (o, i, c) => {
2019
- if (t === !1)
2020
- throw new b(
2021
- s(i, " has been removed" + (n ? " in " + n : "")),
2022
- 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
2023
2761
  );
2024
- return n && !ut[i] && (ut[i] = !0, console.warn(
2025
- s(
2026
- i,
2027
- " has been deprecated since v" + n + " and will be removed in the near future"
2028
- )
2029
- )), 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;
2030
2773
  };
2031
2774
  };
2032
- Te.spelling = function(t) {
2033
- 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
+ };
2034
2780
  };
2035
- function Ir(e, t, n) {
2036
- if (typeof e != "object")
2037
- throw new b("options must be an object", b.ERR_BAD_OPTION_VALUE);
2038
- const r = Object.keys(e);
2039
- let s = r.length;
2040
- for (; s-- > 0; ) {
2041
- const o = r[s], i = t[o];
2042
- if (i) {
2043
- const c = e[o], d = c === void 0 || i(c, o, e);
2044
- if (d !== !0)
2045
- 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
+ }
2046
2796
  continue;
2047
2797
  }
2048
- if (n !== !0)
2049
- 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
+ }
2050
2801
  }
2051
2802
  }
2052
- const fe = {
2053
- assertOptions: Ir,
2054
- validators: Te
2055
- }, I = fe.validators;
2056
- let J = class {
2057
- constructor(t) {
2058
- this.defaults = t || {}, this.interceptors = {
2059
- request: new tt(),
2060
- 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()
2061
2814
  };
2062
2815
  }
2063
2816
  /**
@@ -2068,197 +2821,263 @@ let J = class {
2068
2821
  *
2069
2822
  * @returns {Promise} The Promise to be fulfilled
2070
2823
  */
2071
- async request(t, n) {
2824
+ async request(configOrUrl, config) {
2072
2825
  try {
2073
- return await this._request(t, n);
2074
- } catch (r) {
2075
- if (r instanceof Error) {
2076
- let s = {};
2077
- Error.captureStackTrace ? Error.captureStackTrace(s) : s = new Error();
2078
- 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/, "") : "";
2079
2832
  try {
2080
- r.stack ? o && !String(r.stack).endsWith(o.replace(/^.+\n.+\n/, "")) && (r.stack += `
2081
- ` + o) : r.stack = o;
2082
- } 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) {
2083
2839
  }
2084
2840
  }
2085
- throw r;
2086
- }
2087
- }
2088
- _request(t, n) {
2089
- typeof t == "string" ? (n = n || {}, n.url = t) : n = t || {}, n = W(this.defaults, n);
2090
- const { transitional: r, paramsSerializer: s, headers: o } = n;
2091
- r !== void 0 && fe.assertOptions(r, {
2092
- silentJSONParsing: I.transitional(I.boolean),
2093
- forcedJSONParsing: I.transitional(I.boolean),
2094
- clarifyTimeoutError: I.transitional(I.boolean)
2095
- }, !1), s != null && (a.isFunction(s) ? n.paramsSerializer = {
2096
- serialize: s
2097
- } : fe.assertOptions(s, {
2098
- encode: I.function,
2099
- serialize: I.function
2100
- }, !0)), n.allowAbsoluteUrls !== void 0 || (this.defaults.allowAbsoluteUrls !== void 0 ? n.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls : n.allowAbsoluteUrls = !0), fe.assertOptions(n, {
2101
- baseUrl: I.spelling("baseURL"),
2102
- withXsrfToken: I.spelling("withXSRFToken")
2103
- }, !0), n.method = (n.method || this.defaults.method || "get").toLowerCase();
2104
- let i = o && a.merge(
2105
- o.common,
2106
- 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]
2107
2886
  );
2108
- o && a.forEach(
2887
+ headers && utils$1.forEach(
2109
2888
  ["delete", "get", "head", "post", "put", "patch", "common"],
2110
- (h) => {
2111
- 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;
2112
2899
  }
2113
- ), n.headers = U.concat(i, o);
2114
- const c = [];
2115
- let d = !0;
2116
- this.interceptors.request.forEach(function(R) {
2117
- 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);
2118
2902
  });
2119
- const l = [];
2120
- this.interceptors.response.forEach(function(R) {
2121
- l.push(R.fulfilled, R.rejected);
2903
+ const responseInterceptorChain = [];
2904
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
2905
+ responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
2122
2906
  });
2123
- let u, p = 0, y;
2124
- if (!d) {
2125
- const h = [lt.bind(this), void 0];
2126
- for (h.unshift.apply(h, c), h.push.apply(h, l), y = h.length, u = Promise.resolve(n); p < y; )
2127
- u = u.then(h[p++], h[p++]);
2128
- return u;
2129
- }
2130
- y = c.length;
2131
- let T = n;
2132
- for (p = 0; p < y; ) {
2133
- 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++];
2134
2927
  try {
2135
- T = h(T);
2136
- } catch (m) {
2137
- R.call(this, m);
2928
+ newConfig = onFulfilled(newConfig);
2929
+ } catch (error) {
2930
+ onRejected.call(this, error);
2138
2931
  break;
2139
2932
  }
2140
2933
  }
2141
2934
  try {
2142
- u = lt.call(this, T);
2143
- } catch (h) {
2144
- return Promise.reject(h);
2935
+ promise = dispatchRequest.call(this, newConfig);
2936
+ } catch (error) {
2937
+ return Promise.reject(error);
2145
2938
  }
2146
- for (p = 0, y = l.length; p < y; )
2147
- u = u.then(l[p++], l[p++]);
2148
- 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;
2149
2945
  }
2150
- getUri(t) {
2151
- t = W(this.defaults, t);
2152
- const n = jt(t.baseURL, t.url, t.allowAbsoluteUrls);
2153
- 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);
2154
2950
  }
2155
2951
  };
2156
- a.forEach(["delete", "get", "head", "options"], function(t) {
2157
- J.prototype[t] = function(n, r) {
2158
- return this.request(W(r || {}, {
2159
- method: t,
2160
- url: n,
2161
- 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
2162
2958
  }));
2163
2959
  };
2164
2960
  });
2165
- a.forEach(["post", "put", "patch"], function(t) {
2166
- function n(r) {
2167
- return function(o, i, c) {
2168
- return this.request(W(c || {}, {
2169
- method: t,
2170
- 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 ? {
2171
2967
  "Content-Type": "multipart/form-data"
2172
2968
  } : {},
2173
- url: o,
2174
- data: i
2969
+ url,
2970
+ data
2175
2971
  }));
2176
2972
  };
2177
2973
  }
2178
- J.prototype[t] = n(), J.prototype[t + "Form"] = n(!0);
2974
+ Axios$1.prototype[method] = generateHTTPMethod();
2975
+ Axios$1.prototype[method + "Form"] = generateHTTPMethod(true);
2179
2976
  });
2180
- let $r = class It {
2181
- constructor(t) {
2182
- if (typeof t != "function")
2977
+ let CancelToken$1 = class CancelToken {
2978
+ constructor(executor) {
2979
+ if (typeof executor !== "function") {
2183
2980
  throw new TypeError("executor must be a function.");
2184
- let n;
2185
- this.promise = new Promise(function(o) {
2186
- n = o;
2981
+ }
2982
+ let resolvePromise;
2983
+ this.promise = new Promise(function promiseExecutor(resolve) {
2984
+ resolvePromise = resolve;
2187
2985
  });
2188
- const r = this;
2189
- this.promise.then((s) => {
2190
- if (!r._listeners) return;
2191
- let o = r._listeners.length;
2192
- for (; o-- > 0; )
2193
- r._listeners[o](s);
2194
- r._listeners = null;
2195
- }), this.promise.then = (s) => {
2196
- let o;
2197
- const i = new Promise((c) => {
2198
- r.subscribe(c), o = c;
2199
- }).then(s);
2200
- return i.cancel = function() {
2201
- r.unsubscribe(o);
2202
- }, i;
2203
- }, t(function(o, i, c) {
2204
- 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);
2205
3012
  });
2206
3013
  }
2207
3014
  /**
2208
3015
  * Throws a `CanceledError` if cancellation has been requested.
2209
3016
  */
2210
3017
  throwIfRequested() {
2211
- if (this.reason)
3018
+ if (this.reason) {
2212
3019
  throw this.reason;
3020
+ }
2213
3021
  }
2214
3022
  /**
2215
3023
  * Subscribe to the cancel signal
2216
3024
  */
2217
- subscribe(t) {
3025
+ subscribe(listener) {
2218
3026
  if (this.reason) {
2219
- t(this.reason);
3027
+ listener(this.reason);
2220
3028
  return;
2221
3029
  }
2222
- 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
+ }
2223
3035
  }
2224
3036
  /**
2225
3037
  * Unsubscribe from the cancel signal
2226
3038
  */
2227
- unsubscribe(t) {
2228
- if (!this._listeners)
3039
+ unsubscribe(listener) {
3040
+ if (!this._listeners) {
2229
3041
  return;
2230
- const n = this._listeners.indexOf(t);
2231
- 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
+ }
2232
3047
  }
2233
3048
  toAbortSignal() {
2234
- const t = new AbortController(), n = (r) => {
2235
- t.abort(r);
3049
+ const controller = new AbortController();
3050
+ const abort = (err) => {
3051
+ controller.abort(err);
2236
3052
  };
2237
- 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;
2238
3056
  }
2239
3057
  /**
2240
3058
  * Returns an object that contains a new `CancelToken` and a function that, when called,
2241
3059
  * cancels the `CancelToken`.
2242
3060
  */
2243
3061
  static source() {
2244
- let t;
3062
+ let cancel;
3063
+ const token = new CancelToken(function executor(c) {
3064
+ cancel = c;
3065
+ });
2245
3066
  return {
2246
- token: new It(function(s) {
2247
- t = s;
2248
- }),
2249
- cancel: t
3067
+ token,
3068
+ cancel
2250
3069
  };
2251
3070
  }
2252
3071
  };
2253
- function Mr(e) {
2254
- return function(n) {
2255
- return e.apply(null, n);
3072
+ function spread$1(callback) {
3073
+ return function wrap(arr) {
3074
+ return callback.apply(null, arr);
2256
3075
  };
2257
3076
  }
2258
- function Hr(e) {
2259
- return a.isObject(e) && e.isAxiosError === !0;
3077
+ function isAxiosError$1(payload) {
3078
+ return utils$1.isObject(payload) && payload.isAxiosError === true;
2260
3079
  }
2261
- const Le = {
3080
+ const HttpStatusCode$1 = {
2262
3081
  Continue: 100,
2263
3082
  SwitchingProtocols: 101,
2264
3083
  Processing: 102,
@@ -2323,65 +3142,74 @@ const Le = {
2323
3142
  NotExtended: 510,
2324
3143
  NetworkAuthenticationRequired: 511
2325
3144
  };
2326
- Object.entries(Le).forEach(([e, t]) => {
2327
- Le[t] = e;
3145
+ Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
3146
+ HttpStatusCode$1[value] = key;
2328
3147
  });
2329
- function $t(e) {
2330
- const t = new J(e), n = Et(J.prototype.request, t);
2331
- return a.extend(n, J.prototype, t, { allOwnKeys: !0 }), a.extend(n, t, null, { allOwnKeys: !0 }), n.create = function(s) {
2332
- return $t(W(e, s));
2333
- }, 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;
2334
3157
  }
2335
- const P = $t(ae);
2336
- P.Axios = J;
2337
- P.CanceledError = G;
2338
- P.CancelToken = $r;
2339
- P.isCancel = Ft;
2340
- P.VERSION = qt;
2341
- P.toFormData = ye;
2342
- P.AxiosError = b;
2343
- P.Cancel = P.CanceledError;
2344
- P.all = function(t) {
2345
- 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);
2346
3169
  };
2347
- P.spread = Mr;
2348
- P.isAxiosError = Hr;
2349
- P.mergeConfig = W;
2350
- P.AxiosHeaders = U;
2351
- P.formToJSON = (e) => kt(a.isHTMLForm(e) ? new FormData(e) : e);
2352
- P.getAdapter = Bt.getAdapter;
2353
- P.HttpStatusCode = Le;
2354
- 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;
2355
3178
  const {
2356
- Axios: Qr,
2357
- AxiosError: es,
2358
- CanceledError: ts,
2359
- isCancel: ns,
2360
- CancelToken: rs,
2361
- VERSION: ss,
2362
- all: os,
2363
- Cancel: is,
2364
- isAxiosError: as,
2365
- spread: cs,
2366
- toFormData: ls,
2367
- AxiosHeaders: us,
2368
- HttpStatusCode: fs,
2369
- formToJSON: ds,
2370
- getAdapter: ps,
2371
- mergeConfig: hs
2372
- } = P, ms = (e) => P.create({
2373
- timeout: 2 * 60 * 1e3,
2374
- ...e
2375
- });
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
+ };
2376
3202
  export {
2377
- Yr as AuthStateProvider,
2378
- de as ERequestContentType,
2379
- Zt as ERequestMethod,
2380
- Xr as FetcherProvider,
2381
- ms as createAxiosInstance,
2382
- Wr as createGraphQLFetcher,
2383
- Vr as createRestFulFetcher,
2384
- Kr as getGraphQLResponseFormatError,
2385
- dn as getRestFulResponseFormatError,
2386
- 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
2387
3214
  };
3215
+ //# sourceMappingURL=acrool-react-fetcher.es.js.map