openx-js-sdk 0.0.1

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.
package/app.js ADDED
@@ -0,0 +1,4907 @@
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if(typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory();
4
+ else if(typeof define === 'function' && define.amd)
5
+ define("openxAxios", [], factory);
6
+ else if(typeof exports === 'object')
7
+ exports["openxAxios"] = factory();
8
+ else
9
+ root["openxAxios"] = factory();
10
+ })(this, () => {
11
+ return /******/ (() => { // webpackBootstrap
12
+ /******/ var __webpack_modules__ = ({
13
+
14
+ /***/ 384:
15
+ /***/ ((__unused_webpack_module, exports) => {
16
+
17
+ "use strict";
18
+
19
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
20
+ exports.removeCookie = exports.setCookie = exports.getCookie = void 0;
21
+ var getCookie = function (name) {
22
+ var reg = new RegExp('(^| )' + name + '=([^;]*)' +
23
+ '(;|$)');
24
+ var match = document.cookie.match(reg);
25
+ if (match) {
26
+ return decodeURIComponent(match[2]);
27
+ }
28
+ else {
29
+ return null;
30
+ }
31
+ };
32
+ exports.getCookie = getCookie;
33
+ var setCookie = function (name, value, expiresInSeconds, domain) {
34
+ var expires = '';
35
+ if (expiresInSeconds && expiresInSeconds !== 0) {
36
+ var date = new Date();
37
+ date.setTime(date.getTime() + (expiresInSeconds * 1000));
38
+ expires = "; expires=".concat(date.toUTCString());
39
+ }
40
+ document.cookie = "".concat(name, "=").concat(value).concat(expires, "; path=/; domain=").concat(domain || '');
41
+ };
42
+ exports.setCookie = setCookie;
43
+ var removeCookie = function (name) {
44
+ setCookie(name, '', -1);
45
+ setCookie(name, '', -1, 'cnki.net');
46
+ };
47
+ exports.removeCookie = removeCookie;
48
+
49
+
50
+ /***/ }),
51
+
52
+ /***/ 478:
53
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
54
+
55
+ "use strict";
56
+
57
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
58
+ if (k2 === undefined) k2 = k;
59
+ var desc = Object.getOwnPropertyDescriptor(m, k);
60
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
61
+ desc = { enumerable: true, get: function() { return m[k]; } };
62
+ }
63
+ Object.defineProperty(o, k2, desc);
64
+ }) : (function(o, m, k, k2) {
65
+ if (k2 === undefined) k2 = k;
66
+ o[k2] = m[k];
67
+ }));
68
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
69
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
70
+ }) : function(o, v) {
71
+ o["default"] = v;
72
+ });
73
+ var __importStar = (this && this.__importStar) || (function () {
74
+ var ownKeys = function(o) {
75
+ ownKeys = Object.getOwnPropertyNames || function (o) {
76
+ var ar = [];
77
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
78
+ return ar;
79
+ };
80
+ return ownKeys(o);
81
+ };
82
+ return function (mod) {
83
+ if (mod && mod.__esModule) return mod;
84
+ var result = {};
85
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
86
+ __setModuleDefault(result, mod);
87
+ return result;
88
+ };
89
+ })();
90
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
91
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
92
+ return new (P || (P = Promise))(function (resolve, reject) {
93
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
94
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
95
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
96
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
97
+ });
98
+ };
99
+ var __generator = (this && this.__generator) || function (thisArg, body) {
100
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
101
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
102
+ function verb(n) { return function (v) { return step([n, v]); }; }
103
+ function step(op) {
104
+ if (f) throw new TypeError("Generator is already executing.");
105
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
106
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
107
+ if (y = 0, t) op = [op[0] & 2, t.value];
108
+ switch (op[0]) {
109
+ case 0: case 1: t = op; break;
110
+ case 4: _.label++; return { value: op[1], done: false };
111
+ case 5: _.label++; y = op[1]; op = [0]; continue;
112
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
113
+ default:
114
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
115
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
116
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
117
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
118
+ if (t[2]) _.ops.pop();
119
+ _.trys.pop(); continue;
120
+ }
121
+ op = body.call(thisArg, _);
122
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
123
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
124
+ }
125
+ };
126
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
127
+ exports.getRefreshToken = void 0;
128
+ var cookie_1 = __webpack_require__(384);
129
+ var index_1 = __webpack_require__(740);
130
+ var ip_1 = __webpack_require__(767);
131
+ var cnki_x_jwt_1 = __webpack_require__(537);
132
+ var store_1 = __importStar(__webpack_require__(489));
133
+ /**
134
+ * 获取或刷新 JWT Token
135
+ * @returns {Promise<{ code: number; content?: string; message?: string }>}
136
+ */
137
+ var getRefreshToken = function () { return __awaiter(void 0, void 0, void 0, function () {
138
+ var _store, jwtKey, LID, cachedJwt, clientIp, payload, res, _a, JwtToken, ExpireIn, err_1;
139
+ return __generator(this, function (_b) {
140
+ switch (_b.label) {
141
+ case 0:
142
+ _store = store_1.default.getOptions();
143
+ jwtKey = (0, store_1.getJwtKey)();
144
+ LID = (0, cookie_1.getCookie)('LID');
145
+ if (!LID) {
146
+ return [2 /*return*/, {
147
+ code: 9001,
148
+ message: '无法获取 LID,请重新登录'
149
+ }];
150
+ }
151
+ cachedJwt = (0, cnki_x_jwt_1.getJwt)(jwtKey);
152
+ if (cachedJwt) {
153
+ return [2 /*return*/, {
154
+ code: 0,
155
+ content: cachedJwt,
156
+ message: 'JWT 已缓存,无需刷新'
157
+ }];
158
+ }
159
+ _b.label = 1;
160
+ case 1:
161
+ _b.trys.push([1, 4, , 5]);
162
+ return [4 /*yield*/, (0, ip_1.getUserIp)()];
163
+ case 2:
164
+ clientIp = _b.sent();
165
+ payload = {
166
+ AppId: _store.appid,
167
+ ClientId: (0, cookie_1.getCookie)('Ecp_ClientId') || '9240617191000011664',
168
+ ClientIp: clientIp,
169
+ EcpToken: LID
170
+ };
171
+ // 请求之前优先移除
172
+ (0, cnki_x_jwt_1.removeJwt)(jwtKey);
173
+ return [4 /*yield*/, (0, index_1.postAction)('/proxy-sdk-jwt/JwtToken/ecptoken', payload, { withCredentials: false })];
174
+ case 3:
175
+ res = _b.sent();
176
+ if (res.Success && res.Content) {
177
+ _a = res.Content, JwtToken = _a.JwtToken, ExpireIn = _a.ExpireIn;
178
+ (0, cnki_x_jwt_1.addJwt)(jwtKey, JwtToken, ExpireIn);
179
+ return [2 /*return*/, {
180
+ code: 0,
181
+ content: JwtToken,
182
+ message: 'JWT 刷新成功'
183
+ }];
184
+ }
185
+ if (res.Code === 5014) {
186
+ return [2 /*return*/, {
187
+ code: 9001,
188
+ message: res.Message || 'Token 刷新失败'
189
+ }];
190
+ }
191
+ return [2 /*return*/, {
192
+ code: -1,
193
+ message: res.Message || 'Token 刷新失败'
194
+ }];
195
+ case 4:
196
+ err_1 = _b.sent();
197
+ return [2 /*return*/, {
198
+ code: 500,
199
+ message: 'Token 刷新异常,请稍后重试'
200
+ }];
201
+ case 5: return [2 /*return*/];
202
+ }
203
+ });
204
+ }); };
205
+ exports.getRefreshToken = getRefreshToken;
206
+ /**
207
+ * 最大重试次数
208
+ */
209
+ var MAX_ERROR_COUNT = 2;
210
+ /**
211
+ * 当前已重试次数
212
+ */
213
+ var currentCount = 0;
214
+ /**
215
+ * 刷新中的状态
216
+ */
217
+ var isRefreshing = false;
218
+ /**
219
+ * 请求等待队列(在刷新 token 期间等待)
220
+ */
221
+ var requestQueue = [];
222
+ /**
223
+ * 刷新 Token 并重试原请求
224
+ * @param service Axios 实例
225
+ * @param response Axios 响应对象
226
+ * @returns Promise<AxiosResponse>
227
+ */
228
+ var refreshToken = function (service, response) { return __awaiter(void 0, void 0, void 0, function () {
229
+ var e_1;
230
+ return __generator(this, function (_a) {
231
+ switch (_a.label) {
232
+ case 0:
233
+ if (!!isRefreshing) return [3 /*break*/, 6];
234
+ isRefreshing = true;
235
+ if (currentCount >= MAX_ERROR_COUNT) {
236
+ isRefreshing = false;
237
+ return [2 /*return*/, Promise.reject('超出最大重试次数,已登出')];
238
+ }
239
+ currentCount += 1;
240
+ _a.label = 1;
241
+ case 1:
242
+ _a.trys.push([1, 3, 4, 5]);
243
+ return [4 /*yield*/, (0, exports.getRefreshToken)()
244
+ // 执行任务队列中等待的请求
245
+ ];
246
+ case 2:
247
+ _a.sent();
248
+ // 执行任务队列中等待的请求
249
+ requestQueue.forEach(function (cb) { return cb(); });
250
+ requestQueue = [];
251
+ // 返回重试结果
252
+ return [2 /*return*/, service(response.config)];
253
+ case 3:
254
+ e_1 = _a.sent();
255
+ return [2 /*return*/, Promise.reject(e_1)];
256
+ case 4:
257
+ isRefreshing = false;
258
+ return [7 /*endfinally*/];
259
+ case 5: return [3 /*break*/, 7];
260
+ case 6: return [2 /*return*/, new Promise(function (resolve) {
261
+ requestQueue.push(function () {
262
+ resolve(service(response.config));
263
+ });
264
+ })];
265
+ case 7: return [2 /*return*/];
266
+ }
267
+ });
268
+ }); };
269
+ exports["default"] = refreshToken;
270
+
271
+
272
+ /***/ }),
273
+
274
+ /***/ 489:
275
+ /***/ (function(__unused_webpack_module, exports) {
276
+
277
+ "use strict";
278
+
279
+ var __assign = (this && this.__assign) || function () {
280
+ __assign = Object.assign || function(t) {
281
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
282
+ s = arguments[i];
283
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
284
+ t[p] = s[p];
285
+ }
286
+ return t;
287
+ };
288
+ return __assign.apply(this, arguments);
289
+ };
290
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
291
+ exports.getJwtKey = exports.store = void 0;
292
+ var Store = /** @class */ (function () {
293
+ function Store() {
294
+ this.options = {
295
+ appid: '',
296
+ env: '',
297
+ platForm: '',
298
+ response: function () { }
299
+ };
300
+ }
301
+ Store.getInstance = function () {
302
+ if (!this.instance)
303
+ this.instance = new Store();
304
+ return this.instance;
305
+ };
306
+ /** 初始化或整体替换配置 */
307
+ Store.prototype.config = function (opts) {
308
+ this.options = __assign(__assign({}, this.options), opts);
309
+ };
310
+ /** 获取完整配置 */
311
+ Store.prototype.getOptions = function () {
312
+ return __assign({}, this.options); // 返回副本防止外部污染
313
+ };
314
+ /** 获取 JWT key */
315
+ Store.prototype.getJwtKey = function () {
316
+ var _a = this.options, platForm = _a.platForm, appid = _a.appid;
317
+ return platForm ? "".concat(platForm, "_").concat(appid) : appid;
318
+ };
319
+ /** 可注册响应钩子 */
320
+ Store.prototype.setResponseHandler = function (fn) {
321
+ this.options.response = fn;
322
+ };
323
+ return Store;
324
+ }());
325
+ exports.store = Store.getInstance();
326
+ var getJwtKey = function () { return exports.store.getJwtKey(); };
327
+ exports.getJwtKey = getJwtKey;
328
+ exports["default"] = exports.store;
329
+
330
+
331
+ /***/ }),
332
+
333
+ /***/ 537:
334
+ /***/ ((module) => {
335
+
336
+ !function (t, e) {
337
+ true ? module.exports = e() : 0;
338
+ }(self, () => (() => {
339
+ "use strict";
340
+
341
+ var t = {};
342
+ return {
343
+ 60: function (t, e) {
344
+ var r = this && this.__assign || function () {
345
+ return r = Object.assign || function (t) {
346
+ for (var e, r = 1, n = arguments.length; r < n; r++) for (var o in e = arguments[r]) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
347
+ return t;
348
+ }, r.apply(this, arguments);
349
+ },
350
+ n = this && this.__values || function (t) {
351
+ var e = "function" == typeof Symbol && Symbol.iterator,
352
+ r = e && t[e],
353
+ n = 0;
354
+ if (r) return r.call(t);
355
+ if (t && "number" == typeof t.length) return {
356
+ next: function () {
357
+ return t && n >= t.length && (t = void 0), {
358
+ value: t && t[n++],
359
+ done: !t
360
+ };
361
+ }
362
+ };
363
+ throw new TypeError(e ? "Object is not iterable." : "Symbol.iterator is not defined.");
364
+ },
365
+ o = this && this.__read || function (t, e) {
366
+ var r = "function" == typeof Symbol && t[Symbol.iterator];
367
+ if (!r) return t;
368
+ var n,
369
+ o,
370
+ i = r.call(t),
371
+ a = [];
372
+ try {
373
+ for (; (void 0 === e || e-- > 0) && !(n = i.next()).done;) a.push(n.value);
374
+ } catch (t) {
375
+ o = {
376
+ error: t
377
+ };
378
+ } finally {
379
+ try {
380
+ n && !n.done && (r = i.return) && r.call(i);
381
+ } finally {
382
+ if (o) throw o.error;
383
+ }
384
+ }
385
+ return a;
386
+ },
387
+ i = this && this.__spreadArray || function (t, e, r) {
388
+ if (r || 2 === arguments.length) for (var n, o = 0, i = e.length; o < i; o++) !n && o in e || (n || (n = Array.prototype.slice.call(e, 0, o)), n[o] = e[o]);
389
+ return t.concat(n || Array.prototype.slice.call(e));
390
+ };
391
+ Object.defineProperty(e, "__esModule", {
392
+ value: !0
393
+ }), e.removeAllJwt = e.removeJwt = e.getJwt = e.addJwt = e.initJwtManager = e.getURLParams = void 0;
394
+ var a = function (t) {
395
+ var e = new RegExp("(^| )" + t + "=([^;]*)(;|$)"),
396
+ r = document.cookie.match(e);
397
+ return r ? decodeURIComponent(r[2]) : null;
398
+ };
399
+ e.getURLParams = function (t) {
400
+ var e,
401
+ r,
402
+ i = new URLSearchParams(window.location.search),
403
+ a = {};
404
+ try {
405
+ for (var l = n(i.entries()), u = l.next(); !u.done; u = l.next()) {
406
+ var s = o(u.value, 2),
407
+ f = s[0],
408
+ c = s[1];
409
+ a[f] = c;
410
+ }
411
+ } catch (t) {
412
+ e = {
413
+ error: t
414
+ };
415
+ } finally {
416
+ try {
417
+ u && !u.done && (r = l.return) && r.call(l);
418
+ } finally {
419
+ if (e) throw e.error;
420
+ }
421
+ }
422
+ return t ? a[t] : a;
423
+ };
424
+ var l = function () {
425
+ function t(t) {
426
+ this.STORAGE_KEY = (null == t ? void 0 : t.storageKey) || "X_JWT_LIST", this.MAX_COUNT = (null == t ? void 0 : t.maxCount) || 20, this.POP_DELETE_COUNT = (null == t ? void 0 : t.popDeleteCount) || 5;
427
+ }
428
+ return t.prototype.addJwt = function (t, n, o) {
429
+ if (!t || "" === t.trim()) throw new Error("JWT name cannot be empty");
430
+ if (!n || "" === n.trim()) throw new Error("JWT token cannot be empty");
431
+ if (!o || isNaN(o) || o <= 0) throw new Error("expiresIn must be a valid positive number");
432
+ var i = Date.now(),
433
+ l = this.getJwtList(),
434
+ u = l.findIndex(function (e) {
435
+ return e.name === t;
436
+ }),
437
+ s = {
438
+ name: t,
439
+ expireIn: i + 1e3 * (o - 300),
440
+ createdAt: i,
441
+ jwtToken: n,
442
+ source: a("LID") || (0, e.getURLParams)("LID") || ""
443
+ };
444
+ u >= 0 ? l[u] = r(r({}, l[u]), s) : (l.length >= this.MAX_COUNT && l.splice(0, this.POP_DELETE_COUNT), l.push(s)), this.saveJWTList(l);
445
+ }, t.prototype.getJwt = function (t) {
446
+ if (!t || "" === t.trim()) throw new Error("JWT name cannot be empty");
447
+ var r = this.getJwtList().find(function (e) {
448
+ return e.name === t;
449
+ }),
450
+ n = a("LID") || (0, e.getURLParams)("LID") || "";
451
+ if (r && r.source) {
452
+ if (!n) return this.removeAllJwt(), null;
453
+ if (r.source !== n) return null;
454
+ }
455
+ return r ? r.jwtToken : null;
456
+ }, t.prototype.removeJwt = function (t) {
457
+ if (!t || "" === t.trim()) throw new Error("JWT name cannot be empty");
458
+ var e = this.getJwtList().filter(function (e) {
459
+ return e.name !== t;
460
+ });
461
+ this.saveJWTList(e);
462
+ }, t.prototype.removeAllJwt = function () {
463
+ localStorage.removeItem(this.STORAGE_KEY);
464
+ }, t.prototype.saveJWTList = function (t) {
465
+ localStorage.setItem(this.STORAGE_KEY, JSON.stringify(t));
466
+ }, t.prototype.removeExpired = function (t) {
467
+ var e = Date.now(),
468
+ r = t.filter(function (t) {
469
+ return t.expireIn > e;
470
+ });
471
+ return this.saveJWTList(r), r;
472
+ }, t.prototype.getJwtList = function () {
473
+ var t = localStorage.getItem(this.STORAGE_KEY);
474
+ if (!t) return [];
475
+ try {
476
+ var e = JSON.parse(t);
477
+ return this.removeExpired(Array.isArray(e) ? e : []);
478
+ } catch (t) {
479
+ return console.warn("[XJwtManager] getJwtList JSON parse error:", t), [];
480
+ }
481
+ }, t;
482
+ }(),
483
+ u = new l();
484
+ e.initJwtManager = function (t) {
485
+ u = new l(t);
486
+ };
487
+ e.addJwt = function () {
488
+ for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
489
+ return u.addJwt.apply(u, i([], o(t), !1));
490
+ };
491
+ e.getJwt = function () {
492
+ for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
493
+ return u.getJwt.apply(u, i([], o(t), !1));
494
+ };
495
+ e.removeJwt = function () {
496
+ for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
497
+ return u.removeJwt.apply(u, i([], o(t), !1));
498
+ };
499
+ e.removeAllJwt = function () {
500
+ return u.removeAllJwt();
501
+ }, e.default = {
502
+ addJwt: e.addJwt,
503
+ getJwt: e.getJwt,
504
+ removeJwt: e.removeJwt,
505
+ removeAllJwt: e.removeAllJwt,
506
+ initJwtManager: e.initJwtManager
507
+ };
508
+ }
509
+ }[60].call(t, 0, t), t = t.default;
510
+ })());
511
+
512
+ /***/ }),
513
+
514
+ /***/ 637:
515
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
516
+
517
+ "use strict";
518
+ /*! Axios v1.12.2 Copyright (c) 2025 Matt Zabriskie and contributors */
519
+
520
+
521
+ function bind(fn, thisArg) {
522
+ return function wrap() {
523
+ return fn.apply(thisArg, arguments);
524
+ };
525
+ }
526
+
527
+ // utils is a library of generic helper functions non-specific to axios
528
+
529
+ const {toString} = Object.prototype;
530
+ const {getPrototypeOf} = Object;
531
+ const {iterator, toStringTag} = Symbol;
532
+
533
+ const kindOf = (cache => thing => {
534
+ const str = toString.call(thing);
535
+ return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
536
+ })(Object.create(null));
537
+
538
+ const kindOfTest = (type) => {
539
+ type = type.toLowerCase();
540
+ return (thing) => kindOf(thing) === type
541
+ };
542
+
543
+ const typeOfTest = type => thing => typeof thing === type;
544
+
545
+ /**
546
+ * Determine if a value is an Array
547
+ *
548
+ * @param {Object} val The value to test
549
+ *
550
+ * @returns {boolean} True if value is an Array, otherwise false
551
+ */
552
+ const {isArray} = Array;
553
+
554
+ /**
555
+ * Determine if a value is undefined
556
+ *
557
+ * @param {*} val The value to test
558
+ *
559
+ * @returns {boolean} True if the value is undefined, otherwise false
560
+ */
561
+ const isUndefined = typeOfTest('undefined');
562
+
563
+ /**
564
+ * Determine if a value is a Buffer
565
+ *
566
+ * @param {*} val The value to test
567
+ *
568
+ * @returns {boolean} True if value is a Buffer, otherwise false
569
+ */
570
+ function isBuffer(val) {
571
+ return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
572
+ && isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
573
+ }
574
+
575
+ /**
576
+ * Determine if a value is an ArrayBuffer
577
+ *
578
+ * @param {*} val The value to test
579
+ *
580
+ * @returns {boolean} True if value is an ArrayBuffer, otherwise false
581
+ */
582
+ const isArrayBuffer = kindOfTest('ArrayBuffer');
583
+
584
+
585
+ /**
586
+ * Determine if a value is a view on an ArrayBuffer
587
+ *
588
+ * @param {*} val The value to test
589
+ *
590
+ * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
591
+ */
592
+ function isArrayBufferView(val) {
593
+ let result;
594
+ if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
595
+ result = ArrayBuffer.isView(val);
596
+ } else {
597
+ result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
598
+ }
599
+ return result;
600
+ }
601
+
602
+ /**
603
+ * Determine if a value is a String
604
+ *
605
+ * @param {*} val The value to test
606
+ *
607
+ * @returns {boolean} True if value is a String, otherwise false
608
+ */
609
+ const isString = typeOfTest('string');
610
+
611
+ /**
612
+ * Determine if a value is a Function
613
+ *
614
+ * @param {*} val The value to test
615
+ * @returns {boolean} True if value is a Function, otherwise false
616
+ */
617
+ const isFunction$1 = typeOfTest('function');
618
+
619
+ /**
620
+ * Determine if a value is a Number
621
+ *
622
+ * @param {*} val The value to test
623
+ *
624
+ * @returns {boolean} True if value is a Number, otherwise false
625
+ */
626
+ const isNumber = typeOfTest('number');
627
+
628
+ /**
629
+ * Determine if a value is an Object
630
+ *
631
+ * @param {*} thing The value to test
632
+ *
633
+ * @returns {boolean} True if value is an Object, otherwise false
634
+ */
635
+ const isObject = (thing) => thing !== null && typeof thing === 'object';
636
+
637
+ /**
638
+ * Determine if a value is a Boolean
639
+ *
640
+ * @param {*} thing The value to test
641
+ * @returns {boolean} True if value is a Boolean, otherwise false
642
+ */
643
+ const isBoolean = thing => thing === true || thing === false;
644
+
645
+ /**
646
+ * Determine if a value is a plain Object
647
+ *
648
+ * @param {*} val The value to test
649
+ *
650
+ * @returns {boolean} True if value is a plain Object, otherwise false
651
+ */
652
+ const isPlainObject = (val) => {
653
+ if (kindOf(val) !== 'object') {
654
+ return false;
655
+ }
656
+
657
+ const prototype = getPrototypeOf(val);
658
+ return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
659
+ };
660
+
661
+ /**
662
+ * Determine if a value is an empty object (safely handles Buffers)
663
+ *
664
+ * @param {*} val The value to test
665
+ *
666
+ * @returns {boolean} True if value is an empty object, otherwise false
667
+ */
668
+ const isEmptyObject = (val) => {
669
+ // Early return for non-objects or Buffers to prevent RangeError
670
+ if (!isObject(val) || isBuffer(val)) {
671
+ return false;
672
+ }
673
+
674
+ try {
675
+ return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
676
+ } catch (e) {
677
+ // Fallback for any other objects that might cause RangeError with Object.keys()
678
+ return false;
679
+ }
680
+ };
681
+
682
+ /**
683
+ * Determine if a value is a Date
684
+ *
685
+ * @param {*} val The value to test
686
+ *
687
+ * @returns {boolean} True if value is a Date, otherwise false
688
+ */
689
+ const isDate = kindOfTest('Date');
690
+
691
+ /**
692
+ * Determine if a value is a File
693
+ *
694
+ * @param {*} val The value to test
695
+ *
696
+ * @returns {boolean} True if value is a File, otherwise false
697
+ */
698
+ const isFile = kindOfTest('File');
699
+
700
+ /**
701
+ * Determine if a value is a Blob
702
+ *
703
+ * @param {*} val The value to test
704
+ *
705
+ * @returns {boolean} True if value is a Blob, otherwise false
706
+ */
707
+ const isBlob = kindOfTest('Blob');
708
+
709
+ /**
710
+ * Determine if a value is a FileList
711
+ *
712
+ * @param {*} val The value to test
713
+ *
714
+ * @returns {boolean} True if value is a File, otherwise false
715
+ */
716
+ const isFileList = kindOfTest('FileList');
717
+
718
+ /**
719
+ * Determine if a value is a Stream
720
+ *
721
+ * @param {*} val The value to test
722
+ *
723
+ * @returns {boolean} True if value is a Stream, otherwise false
724
+ */
725
+ const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
726
+
727
+ /**
728
+ * Determine if a value is a FormData
729
+ *
730
+ * @param {*} thing The value to test
731
+ *
732
+ * @returns {boolean} True if value is an FormData, otherwise false
733
+ */
734
+ const isFormData = (thing) => {
735
+ let kind;
736
+ return thing && (
737
+ (typeof FormData === 'function' && thing instanceof FormData) || (
738
+ isFunction$1(thing.append) && (
739
+ (kind = kindOf(thing)) === 'formdata' ||
740
+ // detect form-data instance
741
+ (kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
742
+ )
743
+ )
744
+ )
745
+ };
746
+
747
+ /**
748
+ * Determine if a value is a URLSearchParams object
749
+ *
750
+ * @param {*} val The value to test
751
+ *
752
+ * @returns {boolean} True if value is a URLSearchParams object, otherwise false
753
+ */
754
+ const isURLSearchParams = kindOfTest('URLSearchParams');
755
+
756
+ const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest);
757
+
758
+ /**
759
+ * Trim excess whitespace off the beginning and end of a string
760
+ *
761
+ * @param {String} str The String to trim
762
+ *
763
+ * @returns {String} The String freed of excess whitespace
764
+ */
765
+ const trim = (str) => str.trim ?
766
+ str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
767
+
768
+ /**
769
+ * Iterate over an Array or an Object invoking a function for each item.
770
+ *
771
+ * If `obj` is an Array callback will be called passing
772
+ * the value, index, and complete array for each item.
773
+ *
774
+ * If 'obj' is an Object callback will be called passing
775
+ * the value, key, and complete object for each property.
776
+ *
777
+ * @param {Object|Array} obj The object to iterate
778
+ * @param {Function} fn The callback to invoke for each item
779
+ *
780
+ * @param {Boolean} [allOwnKeys = false]
781
+ * @returns {any}
782
+ */
783
+ function forEach(obj, fn, {allOwnKeys = false} = {}) {
784
+ // Don't bother if no value provided
785
+ if (obj === null || typeof obj === 'undefined') {
786
+ return;
787
+ }
788
+
789
+ let i;
790
+ let l;
791
+
792
+ // Force an array if not already something iterable
793
+ if (typeof obj !== 'object') {
794
+ /*eslint no-param-reassign:0*/
795
+ obj = [obj];
796
+ }
797
+
798
+ if (isArray(obj)) {
799
+ // Iterate over array values
800
+ for (i = 0, l = obj.length; i < l; i++) {
801
+ fn.call(null, obj[i], i, obj);
802
+ }
803
+ } else {
804
+ // Buffer check
805
+ if (isBuffer(obj)) {
806
+ return;
807
+ }
808
+
809
+ // Iterate over object keys
810
+ const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
811
+ const len = keys.length;
812
+ let key;
813
+
814
+ for (i = 0; i < len; i++) {
815
+ key = keys[i];
816
+ fn.call(null, obj[key], key, obj);
817
+ }
818
+ }
819
+ }
820
+
821
+ function findKey(obj, key) {
822
+ if (isBuffer(obj)){
823
+ return null;
824
+ }
825
+
826
+ key = key.toLowerCase();
827
+ const keys = Object.keys(obj);
828
+ let i = keys.length;
829
+ let _key;
830
+ while (i-- > 0) {
831
+ _key = keys[i];
832
+ if (key === _key.toLowerCase()) {
833
+ return _key;
834
+ }
835
+ }
836
+ return null;
837
+ }
838
+
839
+ const _global = (() => {
840
+ /*eslint no-undef:0*/
841
+ if (typeof globalThis !== "undefined") return globalThis;
842
+ return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : __webpack_require__.g)
843
+ })();
844
+
845
+ const isContextDefined = (context) => !isUndefined(context) && context !== _global;
846
+
847
+ /**
848
+ * Accepts varargs expecting each argument to be an object, then
849
+ * immutably merges the properties of each object and returns result.
850
+ *
851
+ * When multiple objects contain the same key the later object in
852
+ * the arguments list will take precedence.
853
+ *
854
+ * Example:
855
+ *
856
+ * ```js
857
+ * var result = merge({foo: 123}, {foo: 456});
858
+ * console.log(result.foo); // outputs 456
859
+ * ```
860
+ *
861
+ * @param {Object} obj1 Object to merge
862
+ *
863
+ * @returns {Object} Result of all merge properties
864
+ */
865
+ function merge(/* obj1, obj2, obj3, ... */) {
866
+ const {caseless, skipUndefined} = isContextDefined(this) && this || {};
867
+ const result = {};
868
+ const assignValue = (val, key) => {
869
+ const targetKey = caseless && findKey(result, key) || key;
870
+ if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
871
+ result[targetKey] = merge(result[targetKey], val);
872
+ } else if (isPlainObject(val)) {
873
+ result[targetKey] = merge({}, val);
874
+ } else if (isArray(val)) {
875
+ result[targetKey] = val.slice();
876
+ } else if (!skipUndefined || !isUndefined(val)) {
877
+ result[targetKey] = val;
878
+ }
879
+ };
880
+
881
+ for (let i = 0, l = arguments.length; i < l; i++) {
882
+ arguments[i] && forEach(arguments[i], assignValue);
883
+ }
884
+ return result;
885
+ }
886
+
887
+ /**
888
+ * Extends object a by mutably adding to it the properties of object b.
889
+ *
890
+ * @param {Object} a The object to be extended
891
+ * @param {Object} b The object to copy properties from
892
+ * @param {Object} thisArg The object to bind function to
893
+ *
894
+ * @param {Boolean} [allOwnKeys]
895
+ * @returns {Object} The resulting value of object a
896
+ */
897
+ const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
898
+ forEach(b, (val, key) => {
899
+ if (thisArg && isFunction$1(val)) {
900
+ a[key] = bind(val, thisArg);
901
+ } else {
902
+ a[key] = val;
903
+ }
904
+ }, {allOwnKeys});
905
+ return a;
906
+ };
907
+
908
+ /**
909
+ * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
910
+ *
911
+ * @param {string} content with BOM
912
+ *
913
+ * @returns {string} content value without BOM
914
+ */
915
+ const stripBOM = (content) => {
916
+ if (content.charCodeAt(0) === 0xFEFF) {
917
+ content = content.slice(1);
918
+ }
919
+ return content;
920
+ };
921
+
922
+ /**
923
+ * Inherit the prototype methods from one constructor into another
924
+ * @param {function} constructor
925
+ * @param {function} superConstructor
926
+ * @param {object} [props]
927
+ * @param {object} [descriptors]
928
+ *
929
+ * @returns {void}
930
+ */
931
+ const inherits = (constructor, superConstructor, props, descriptors) => {
932
+ constructor.prototype = Object.create(superConstructor.prototype, descriptors);
933
+ constructor.prototype.constructor = constructor;
934
+ Object.defineProperty(constructor, 'super', {
935
+ value: superConstructor.prototype
936
+ });
937
+ props && Object.assign(constructor.prototype, props);
938
+ };
939
+
940
+ /**
941
+ * Resolve object with deep prototype chain to a flat object
942
+ * @param {Object} sourceObj source object
943
+ * @param {Object} [destObj]
944
+ * @param {Function|Boolean} [filter]
945
+ * @param {Function} [propFilter]
946
+ *
947
+ * @returns {Object}
948
+ */
949
+ const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
950
+ let props;
951
+ let i;
952
+ let prop;
953
+ const merged = {};
954
+
955
+ destObj = destObj || {};
956
+ // eslint-disable-next-line no-eq-null,eqeqeq
957
+ if (sourceObj == null) return destObj;
958
+
959
+ do {
960
+ props = Object.getOwnPropertyNames(sourceObj);
961
+ i = props.length;
962
+ while (i-- > 0) {
963
+ prop = props[i];
964
+ if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
965
+ destObj[prop] = sourceObj[prop];
966
+ merged[prop] = true;
967
+ }
968
+ }
969
+ sourceObj = filter !== false && getPrototypeOf(sourceObj);
970
+ } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
971
+
972
+ return destObj;
973
+ };
974
+
975
+ /**
976
+ * Determines whether a string ends with the characters of a specified string
977
+ *
978
+ * @param {String} str
979
+ * @param {String} searchString
980
+ * @param {Number} [position= 0]
981
+ *
982
+ * @returns {boolean}
983
+ */
984
+ const endsWith = (str, searchString, position) => {
985
+ str = String(str);
986
+ if (position === undefined || position > str.length) {
987
+ position = str.length;
988
+ }
989
+ position -= searchString.length;
990
+ const lastIndex = str.indexOf(searchString, position);
991
+ return lastIndex !== -1 && lastIndex === position;
992
+ };
993
+
994
+
995
+ /**
996
+ * Returns new array from array like object or null if failed
997
+ *
998
+ * @param {*} [thing]
999
+ *
1000
+ * @returns {?Array}
1001
+ */
1002
+ const toArray = (thing) => {
1003
+ if (!thing) return null;
1004
+ if (isArray(thing)) return thing;
1005
+ let i = thing.length;
1006
+ if (!isNumber(i)) return null;
1007
+ const arr = new Array(i);
1008
+ while (i-- > 0) {
1009
+ arr[i] = thing[i];
1010
+ }
1011
+ return arr;
1012
+ };
1013
+
1014
+ /**
1015
+ * Checking if the Uint8Array exists and if it does, it returns a function that checks if the
1016
+ * thing passed in is an instance of Uint8Array
1017
+ *
1018
+ * @param {TypedArray}
1019
+ *
1020
+ * @returns {Array}
1021
+ */
1022
+ // eslint-disable-next-line func-names
1023
+ const isTypedArray = (TypedArray => {
1024
+ // eslint-disable-next-line func-names
1025
+ return thing => {
1026
+ return TypedArray && thing instanceof TypedArray;
1027
+ };
1028
+ })(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
1029
+
1030
+ /**
1031
+ * For each entry in the object, call the function with the key and value.
1032
+ *
1033
+ * @param {Object<any, any>} obj - The object to iterate over.
1034
+ * @param {Function} fn - The function to call for each entry.
1035
+ *
1036
+ * @returns {void}
1037
+ */
1038
+ const forEachEntry = (obj, fn) => {
1039
+ const generator = obj && obj[iterator];
1040
+
1041
+ const _iterator = generator.call(obj);
1042
+
1043
+ let result;
1044
+
1045
+ while ((result = _iterator.next()) && !result.done) {
1046
+ const pair = result.value;
1047
+ fn.call(obj, pair[0], pair[1]);
1048
+ }
1049
+ };
1050
+
1051
+ /**
1052
+ * It takes a regular expression and a string, and returns an array of all the matches
1053
+ *
1054
+ * @param {string} regExp - The regular expression to match against.
1055
+ * @param {string} str - The string to search.
1056
+ *
1057
+ * @returns {Array<boolean>}
1058
+ */
1059
+ const matchAll = (regExp, str) => {
1060
+ let matches;
1061
+ const arr = [];
1062
+
1063
+ while ((matches = regExp.exec(str)) !== null) {
1064
+ arr.push(matches);
1065
+ }
1066
+
1067
+ return arr;
1068
+ };
1069
+
1070
+ /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
1071
+ const isHTMLForm = kindOfTest('HTMLFormElement');
1072
+
1073
+ const toCamelCase = str => {
1074
+ return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
1075
+ function replacer(m, p1, p2) {
1076
+ return p1.toUpperCase() + p2;
1077
+ }
1078
+ );
1079
+ };
1080
+
1081
+ /* Creating a function that will check if an object has a property. */
1082
+ const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
1083
+
1084
+ /**
1085
+ * Determine if a value is a RegExp object
1086
+ *
1087
+ * @param {*} val The value to test
1088
+ *
1089
+ * @returns {boolean} True if value is a RegExp object, otherwise false
1090
+ */
1091
+ const isRegExp = kindOfTest('RegExp');
1092
+
1093
+ const reduceDescriptors = (obj, reducer) => {
1094
+ const descriptors = Object.getOwnPropertyDescriptors(obj);
1095
+ const reducedDescriptors = {};
1096
+
1097
+ forEach(descriptors, (descriptor, name) => {
1098
+ let ret;
1099
+ if ((ret = reducer(descriptor, name, obj)) !== false) {
1100
+ reducedDescriptors[name] = ret || descriptor;
1101
+ }
1102
+ });
1103
+
1104
+ Object.defineProperties(obj, reducedDescriptors);
1105
+ };
1106
+
1107
+ /**
1108
+ * Makes all methods read-only
1109
+ * @param {Object} obj
1110
+ */
1111
+
1112
+ const freezeMethods = (obj) => {
1113
+ reduceDescriptors(obj, (descriptor, name) => {
1114
+ // skip restricted props in strict mode
1115
+ if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
1116
+ return false;
1117
+ }
1118
+
1119
+ const value = obj[name];
1120
+
1121
+ if (!isFunction$1(value)) return;
1122
+
1123
+ descriptor.enumerable = false;
1124
+
1125
+ if ('writable' in descriptor) {
1126
+ descriptor.writable = false;
1127
+ return;
1128
+ }
1129
+
1130
+ if (!descriptor.set) {
1131
+ descriptor.set = () => {
1132
+ throw Error('Can not rewrite read-only method \'' + name + '\'');
1133
+ };
1134
+ }
1135
+ });
1136
+ };
1137
+
1138
+ const toObjectSet = (arrayOrString, delimiter) => {
1139
+ const obj = {};
1140
+
1141
+ const define = (arr) => {
1142
+ arr.forEach(value => {
1143
+ obj[value] = true;
1144
+ });
1145
+ };
1146
+
1147
+ isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
1148
+
1149
+ return obj;
1150
+ };
1151
+
1152
+ const noop = () => {};
1153
+
1154
+ const toFiniteNumber = (value, defaultValue) => {
1155
+ return value != null && Number.isFinite(value = +value) ? value : defaultValue;
1156
+ };
1157
+
1158
+
1159
+
1160
+ /**
1161
+ * If the thing is a FormData object, return true, otherwise return false.
1162
+ *
1163
+ * @param {unknown} thing - The thing to check.
1164
+ *
1165
+ * @returns {boolean}
1166
+ */
1167
+ function isSpecCompliantForm(thing) {
1168
+ return !!(thing && isFunction$1(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
1169
+ }
1170
+
1171
+ const toJSONObject = (obj) => {
1172
+ const stack = new Array(10);
1173
+
1174
+ const visit = (source, i) => {
1175
+
1176
+ if (isObject(source)) {
1177
+ if (stack.indexOf(source) >= 0) {
1178
+ return;
1179
+ }
1180
+
1181
+ //Buffer check
1182
+ if (isBuffer(source)) {
1183
+ return source;
1184
+ }
1185
+
1186
+ if(!('toJSON' in source)) {
1187
+ stack[i] = source;
1188
+ const target = isArray(source) ? [] : {};
1189
+
1190
+ forEach(source, (value, key) => {
1191
+ const reducedValue = visit(value, i + 1);
1192
+ !isUndefined(reducedValue) && (target[key] = reducedValue);
1193
+ });
1194
+
1195
+ stack[i] = undefined;
1196
+
1197
+ return target;
1198
+ }
1199
+ }
1200
+
1201
+ return source;
1202
+ };
1203
+
1204
+ return visit(obj, 0);
1205
+ };
1206
+
1207
+ const isAsyncFn = kindOfTest('AsyncFunction');
1208
+
1209
+ const isThenable = (thing) =>
1210
+ thing && (isObject(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
1211
+
1212
+ // original code
1213
+ // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
1214
+
1215
+ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
1216
+ if (setImmediateSupported) {
1217
+ return setImmediate;
1218
+ }
1219
+
1220
+ return postMessageSupported ? ((token, callbacks) => {
1221
+ _global.addEventListener("message", ({source, data}) => {
1222
+ if (source === _global && data === token) {
1223
+ callbacks.length && callbacks.shift()();
1224
+ }
1225
+ }, false);
1226
+
1227
+ return (cb) => {
1228
+ callbacks.push(cb);
1229
+ _global.postMessage(token, "*");
1230
+ }
1231
+ })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
1232
+ })(
1233
+ typeof setImmediate === 'function',
1234
+ isFunction$1(_global.postMessage)
1235
+ );
1236
+
1237
+ const asap = typeof queueMicrotask !== 'undefined' ?
1238
+ queueMicrotask.bind(_global) : ( typeof process !== 'undefined' && process.nextTick || _setImmediate);
1239
+
1240
+ // *********************
1241
+
1242
+
1243
+ const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
1244
+
1245
+
1246
+ var utils$1 = {
1247
+ isArray,
1248
+ isArrayBuffer,
1249
+ isBuffer,
1250
+ isFormData,
1251
+ isArrayBufferView,
1252
+ isString,
1253
+ isNumber,
1254
+ isBoolean,
1255
+ isObject,
1256
+ isPlainObject,
1257
+ isEmptyObject,
1258
+ isReadableStream,
1259
+ isRequest,
1260
+ isResponse,
1261
+ isHeaders,
1262
+ isUndefined,
1263
+ isDate,
1264
+ isFile,
1265
+ isBlob,
1266
+ isRegExp,
1267
+ isFunction: isFunction$1,
1268
+ isStream,
1269
+ isURLSearchParams,
1270
+ isTypedArray,
1271
+ isFileList,
1272
+ forEach,
1273
+ merge,
1274
+ extend,
1275
+ trim,
1276
+ stripBOM,
1277
+ inherits,
1278
+ toFlatObject,
1279
+ kindOf,
1280
+ kindOfTest,
1281
+ endsWith,
1282
+ toArray,
1283
+ forEachEntry,
1284
+ matchAll,
1285
+ isHTMLForm,
1286
+ hasOwnProperty,
1287
+ hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection
1288
+ reduceDescriptors,
1289
+ freezeMethods,
1290
+ toObjectSet,
1291
+ toCamelCase,
1292
+ noop,
1293
+ toFiniteNumber,
1294
+ findKey,
1295
+ global: _global,
1296
+ isContextDefined,
1297
+ isSpecCompliantForm,
1298
+ toJSONObject,
1299
+ isAsyncFn,
1300
+ isThenable,
1301
+ setImmediate: _setImmediate,
1302
+ asap,
1303
+ isIterable
1304
+ };
1305
+
1306
+ /**
1307
+ * Create an Error with the specified message, config, error code, request and response.
1308
+ *
1309
+ * @param {string} message The error message.
1310
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
1311
+ * @param {Object} [config] The config.
1312
+ * @param {Object} [request] The request.
1313
+ * @param {Object} [response] The response.
1314
+ *
1315
+ * @returns {Error} The created error.
1316
+ */
1317
+ function AxiosError(message, code, config, request, response) {
1318
+ Error.call(this);
1319
+
1320
+ if (Error.captureStackTrace) {
1321
+ Error.captureStackTrace(this, this.constructor);
1322
+ } else {
1323
+ this.stack = (new Error()).stack;
1324
+ }
1325
+
1326
+ this.message = message;
1327
+ this.name = 'AxiosError';
1328
+ code && (this.code = code);
1329
+ config && (this.config = config);
1330
+ request && (this.request = request);
1331
+ if (response) {
1332
+ this.response = response;
1333
+ this.status = response.status ? response.status : null;
1334
+ }
1335
+ }
1336
+
1337
+ utils$1.inherits(AxiosError, Error, {
1338
+ toJSON: function toJSON() {
1339
+ return {
1340
+ // Standard
1341
+ message: this.message,
1342
+ name: this.name,
1343
+ // Microsoft
1344
+ description: this.description,
1345
+ number: this.number,
1346
+ // Mozilla
1347
+ fileName: this.fileName,
1348
+ lineNumber: this.lineNumber,
1349
+ columnNumber: this.columnNumber,
1350
+ stack: this.stack,
1351
+ // Axios
1352
+ config: utils$1.toJSONObject(this.config),
1353
+ code: this.code,
1354
+ status: this.status
1355
+ };
1356
+ }
1357
+ });
1358
+
1359
+ const prototype$1 = AxiosError.prototype;
1360
+ const descriptors = {};
1361
+
1362
+ [
1363
+ 'ERR_BAD_OPTION_VALUE',
1364
+ 'ERR_BAD_OPTION',
1365
+ 'ECONNABORTED',
1366
+ 'ETIMEDOUT',
1367
+ 'ERR_NETWORK',
1368
+ 'ERR_FR_TOO_MANY_REDIRECTS',
1369
+ 'ERR_DEPRECATED',
1370
+ 'ERR_BAD_RESPONSE',
1371
+ 'ERR_BAD_REQUEST',
1372
+ 'ERR_CANCELED',
1373
+ 'ERR_NOT_SUPPORT',
1374
+ 'ERR_INVALID_URL'
1375
+ // eslint-disable-next-line func-names
1376
+ ].forEach(code => {
1377
+ descriptors[code] = {value: code};
1378
+ });
1379
+
1380
+ Object.defineProperties(AxiosError, descriptors);
1381
+ Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
1382
+
1383
+ // eslint-disable-next-line func-names
1384
+ AxiosError.from = (error, code, config, request, response, customProps) => {
1385
+ const axiosError = Object.create(prototype$1);
1386
+
1387
+ utils$1.toFlatObject(error, axiosError, function filter(obj) {
1388
+ return obj !== Error.prototype;
1389
+ }, prop => {
1390
+ return prop !== 'isAxiosError';
1391
+ });
1392
+
1393
+ const msg = error && error.message ? error.message : 'Error';
1394
+
1395
+ // Prefer explicit code; otherwise copy the low-level error's code (e.g. ECONNREFUSED)
1396
+ const errCode = code == null && error ? error.code : code;
1397
+ AxiosError.call(axiosError, msg, errCode, config, request, response);
1398
+
1399
+ // Chain the original error on the standard field; non-enumerable to avoid JSON noise
1400
+ if (error && axiosError.cause == null) {
1401
+ Object.defineProperty(axiosError, 'cause', { value: error, configurable: true });
1402
+ }
1403
+
1404
+ axiosError.name = (error && error.name) || 'Error';
1405
+
1406
+ customProps && Object.assign(axiosError, customProps);
1407
+
1408
+ return axiosError;
1409
+ };
1410
+
1411
+ // eslint-disable-next-line strict
1412
+ var httpAdapter = null;
1413
+
1414
+ /**
1415
+ * Determines if the given thing is a array or js object.
1416
+ *
1417
+ * @param {string} thing - The object or array to be visited.
1418
+ *
1419
+ * @returns {boolean}
1420
+ */
1421
+ function isVisitable(thing) {
1422
+ return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
1423
+ }
1424
+
1425
+ /**
1426
+ * It removes the brackets from the end of a string
1427
+ *
1428
+ * @param {string} key - The key of the parameter.
1429
+ *
1430
+ * @returns {string} the key without the brackets.
1431
+ */
1432
+ function removeBrackets(key) {
1433
+ return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
1434
+ }
1435
+
1436
+ /**
1437
+ * It takes a path, a key, and a boolean, and returns a string
1438
+ *
1439
+ * @param {string} path - The path to the current key.
1440
+ * @param {string} key - The key of the current object being iterated over.
1441
+ * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
1442
+ *
1443
+ * @returns {string} The path to the current key.
1444
+ */
1445
+ function renderKey(path, key, dots) {
1446
+ if (!path) return key;
1447
+ return path.concat(key).map(function each(token, i) {
1448
+ // eslint-disable-next-line no-param-reassign
1449
+ token = removeBrackets(token);
1450
+ return !dots && i ? '[' + token + ']' : token;
1451
+ }).join(dots ? '.' : '');
1452
+ }
1453
+
1454
+ /**
1455
+ * If the array is an array and none of its elements are visitable, then it's a flat array.
1456
+ *
1457
+ * @param {Array<any>} arr - The array to check
1458
+ *
1459
+ * @returns {boolean}
1460
+ */
1461
+ function isFlatArray(arr) {
1462
+ return utils$1.isArray(arr) && !arr.some(isVisitable);
1463
+ }
1464
+
1465
+ const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
1466
+ return /^is[A-Z]/.test(prop);
1467
+ });
1468
+
1469
+ /**
1470
+ * Convert a data object to FormData
1471
+ *
1472
+ * @param {Object} obj
1473
+ * @param {?Object} [formData]
1474
+ * @param {?Object} [options]
1475
+ * @param {Function} [options.visitor]
1476
+ * @param {Boolean} [options.metaTokens = true]
1477
+ * @param {Boolean} [options.dots = false]
1478
+ * @param {?Boolean} [options.indexes = false]
1479
+ *
1480
+ * @returns {Object}
1481
+ **/
1482
+
1483
+ /**
1484
+ * It converts an object into a FormData object
1485
+ *
1486
+ * @param {Object<any, any>} obj - The object to convert to form data.
1487
+ * @param {string} formData - The FormData object to append to.
1488
+ * @param {Object<string, any>} options
1489
+ *
1490
+ * @returns
1491
+ */
1492
+ function toFormData(obj, formData, options) {
1493
+ if (!utils$1.isObject(obj)) {
1494
+ throw new TypeError('target must be an object');
1495
+ }
1496
+
1497
+ // eslint-disable-next-line no-param-reassign
1498
+ formData = formData || new (FormData)();
1499
+
1500
+ // eslint-disable-next-line no-param-reassign
1501
+ options = utils$1.toFlatObject(options, {
1502
+ metaTokens: true,
1503
+ dots: false,
1504
+ indexes: false
1505
+ }, false, function defined(option, source) {
1506
+ // eslint-disable-next-line no-eq-null,eqeqeq
1507
+ return !utils$1.isUndefined(source[option]);
1508
+ });
1509
+
1510
+ const metaTokens = options.metaTokens;
1511
+ // eslint-disable-next-line no-use-before-define
1512
+ const visitor = options.visitor || defaultVisitor;
1513
+ const dots = options.dots;
1514
+ const indexes = options.indexes;
1515
+ const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
1516
+ const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
1517
+
1518
+ if (!utils$1.isFunction(visitor)) {
1519
+ throw new TypeError('visitor must be a function');
1520
+ }
1521
+
1522
+ function convertValue(value) {
1523
+ if (value === null) return '';
1524
+
1525
+ if (utils$1.isDate(value)) {
1526
+ return value.toISOString();
1527
+ }
1528
+
1529
+ if (utils$1.isBoolean(value)) {
1530
+ return value.toString();
1531
+ }
1532
+
1533
+ if (!useBlob && utils$1.isBlob(value)) {
1534
+ throw new AxiosError('Blob is not supported. Use a Buffer instead.');
1535
+ }
1536
+
1537
+ if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
1538
+ return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
1539
+ }
1540
+
1541
+ return value;
1542
+ }
1543
+
1544
+ /**
1545
+ * Default visitor.
1546
+ *
1547
+ * @param {*} value
1548
+ * @param {String|Number} key
1549
+ * @param {Array<String|Number>} path
1550
+ * @this {FormData}
1551
+ *
1552
+ * @returns {boolean} return true to visit the each prop of the value recursively
1553
+ */
1554
+ function defaultVisitor(value, key, path) {
1555
+ let arr = value;
1556
+
1557
+ if (value && !path && typeof value === 'object') {
1558
+ if (utils$1.endsWith(key, '{}')) {
1559
+ // eslint-disable-next-line no-param-reassign
1560
+ key = metaTokens ? key : key.slice(0, -2);
1561
+ // eslint-disable-next-line no-param-reassign
1562
+ value = JSON.stringify(value);
1563
+ } else if (
1564
+ (utils$1.isArray(value) && isFlatArray(value)) ||
1565
+ ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
1566
+ )) {
1567
+ // eslint-disable-next-line no-param-reassign
1568
+ key = removeBrackets(key);
1569
+
1570
+ arr.forEach(function each(el, index) {
1571
+ !(utils$1.isUndefined(el) || el === null) && formData.append(
1572
+ // eslint-disable-next-line no-nested-ternary
1573
+ indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
1574
+ convertValue(el)
1575
+ );
1576
+ });
1577
+ return false;
1578
+ }
1579
+ }
1580
+
1581
+ if (isVisitable(value)) {
1582
+ return true;
1583
+ }
1584
+
1585
+ formData.append(renderKey(path, key, dots), convertValue(value));
1586
+
1587
+ return false;
1588
+ }
1589
+
1590
+ const stack = [];
1591
+
1592
+ const exposedHelpers = Object.assign(predicates, {
1593
+ defaultVisitor,
1594
+ convertValue,
1595
+ isVisitable
1596
+ });
1597
+
1598
+ function build(value, path) {
1599
+ if (utils$1.isUndefined(value)) return;
1600
+
1601
+ if (stack.indexOf(value) !== -1) {
1602
+ throw Error('Circular reference detected in ' + path.join('.'));
1603
+ }
1604
+
1605
+ stack.push(value);
1606
+
1607
+ utils$1.forEach(value, function each(el, key) {
1608
+ const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
1609
+ formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers
1610
+ );
1611
+
1612
+ if (result === true) {
1613
+ build(el, path ? path.concat(key) : [key]);
1614
+ }
1615
+ });
1616
+
1617
+ stack.pop();
1618
+ }
1619
+
1620
+ if (!utils$1.isObject(obj)) {
1621
+ throw new TypeError('data must be an object');
1622
+ }
1623
+
1624
+ build(obj);
1625
+
1626
+ return formData;
1627
+ }
1628
+
1629
+ /**
1630
+ * It encodes a string by replacing all characters that are not in the unreserved set with
1631
+ * their percent-encoded equivalents
1632
+ *
1633
+ * @param {string} str - The string to encode.
1634
+ *
1635
+ * @returns {string} The encoded string.
1636
+ */
1637
+ function encode$1(str) {
1638
+ const charMap = {
1639
+ '!': '%21',
1640
+ "'": '%27',
1641
+ '(': '%28',
1642
+ ')': '%29',
1643
+ '~': '%7E',
1644
+ '%20': '+',
1645
+ '%00': '\x00'
1646
+ };
1647
+ return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
1648
+ return charMap[match];
1649
+ });
1650
+ }
1651
+
1652
+ /**
1653
+ * It takes a params object and converts it to a FormData object
1654
+ *
1655
+ * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
1656
+ * @param {Object<string, any>} options - The options object passed to the Axios constructor.
1657
+ *
1658
+ * @returns {void}
1659
+ */
1660
+ function AxiosURLSearchParams(params, options) {
1661
+ this._pairs = [];
1662
+
1663
+ params && toFormData(params, this, options);
1664
+ }
1665
+
1666
+ const prototype = AxiosURLSearchParams.prototype;
1667
+
1668
+ prototype.append = function append(name, value) {
1669
+ this._pairs.push([name, value]);
1670
+ };
1671
+
1672
+ prototype.toString = function toString(encoder) {
1673
+ const _encode = encoder ? function(value) {
1674
+ return encoder.call(this, value, encode$1);
1675
+ } : encode$1;
1676
+
1677
+ return this._pairs.map(function each(pair) {
1678
+ return _encode(pair[0]) + '=' + _encode(pair[1]);
1679
+ }, '').join('&');
1680
+ };
1681
+
1682
+ /**
1683
+ * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
1684
+ * URI encoded counterparts
1685
+ *
1686
+ * @param {string} val The value to be encoded.
1687
+ *
1688
+ * @returns {string} The encoded value.
1689
+ */
1690
+ function encode(val) {
1691
+ return encodeURIComponent(val).
1692
+ replace(/%3A/gi, ':').
1693
+ replace(/%24/g, '$').
1694
+ replace(/%2C/gi, ',').
1695
+ replace(/%20/g, '+');
1696
+ }
1697
+
1698
+ /**
1699
+ * Build a URL by appending params to the end
1700
+ *
1701
+ * @param {string} url The base of the url (e.g., http://www.google.com)
1702
+ * @param {object} [params] The params to be appended
1703
+ * @param {?(object|Function)} options
1704
+ *
1705
+ * @returns {string} The formatted url
1706
+ */
1707
+ function buildURL(url, params, options) {
1708
+ /*eslint no-param-reassign:0*/
1709
+ if (!params) {
1710
+ return url;
1711
+ }
1712
+
1713
+ const _encode = options && options.encode || encode;
1714
+
1715
+ if (utils$1.isFunction(options)) {
1716
+ options = {
1717
+ serialize: options
1718
+ };
1719
+ }
1720
+
1721
+ const serializeFn = options && options.serialize;
1722
+
1723
+ let serializedParams;
1724
+
1725
+ if (serializeFn) {
1726
+ serializedParams = serializeFn(params, options);
1727
+ } else {
1728
+ serializedParams = utils$1.isURLSearchParams(params) ?
1729
+ params.toString() :
1730
+ new AxiosURLSearchParams(params, options).toString(_encode);
1731
+ }
1732
+
1733
+ if (serializedParams) {
1734
+ const hashmarkIndex = url.indexOf("#");
1735
+
1736
+ if (hashmarkIndex !== -1) {
1737
+ url = url.slice(0, hashmarkIndex);
1738
+ }
1739
+ url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
1740
+ }
1741
+
1742
+ return url;
1743
+ }
1744
+
1745
+ class InterceptorManager {
1746
+ constructor() {
1747
+ this.handlers = [];
1748
+ }
1749
+
1750
+ /**
1751
+ * Add a new interceptor to the stack
1752
+ *
1753
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
1754
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
1755
+ *
1756
+ * @return {Number} An ID used to remove interceptor later
1757
+ */
1758
+ use(fulfilled, rejected, options) {
1759
+ this.handlers.push({
1760
+ fulfilled,
1761
+ rejected,
1762
+ synchronous: options ? options.synchronous : false,
1763
+ runWhen: options ? options.runWhen : null
1764
+ });
1765
+ return this.handlers.length - 1;
1766
+ }
1767
+
1768
+ /**
1769
+ * Remove an interceptor from the stack
1770
+ *
1771
+ * @param {Number} id The ID that was returned by `use`
1772
+ *
1773
+ * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
1774
+ */
1775
+ eject(id) {
1776
+ if (this.handlers[id]) {
1777
+ this.handlers[id] = null;
1778
+ }
1779
+ }
1780
+
1781
+ /**
1782
+ * Clear all interceptors from the stack
1783
+ *
1784
+ * @returns {void}
1785
+ */
1786
+ clear() {
1787
+ if (this.handlers) {
1788
+ this.handlers = [];
1789
+ }
1790
+ }
1791
+
1792
+ /**
1793
+ * Iterate over all the registered interceptors
1794
+ *
1795
+ * This method is particularly useful for skipping over any
1796
+ * interceptors that may have become `null` calling `eject`.
1797
+ *
1798
+ * @param {Function} fn The function to call for each interceptor
1799
+ *
1800
+ * @returns {void}
1801
+ */
1802
+ forEach(fn) {
1803
+ utils$1.forEach(this.handlers, function forEachHandler(h) {
1804
+ if (h !== null) {
1805
+ fn(h);
1806
+ }
1807
+ });
1808
+ }
1809
+ }
1810
+
1811
+ var InterceptorManager$1 = InterceptorManager;
1812
+
1813
+ var transitionalDefaults = {
1814
+ silentJSONParsing: true,
1815
+ forcedJSONParsing: true,
1816
+ clarifyTimeoutError: false
1817
+ };
1818
+
1819
+ var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
1820
+
1821
+ var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
1822
+
1823
+ var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
1824
+
1825
+ var platform$1 = {
1826
+ isBrowser: true,
1827
+ classes: {
1828
+ URLSearchParams: URLSearchParams$1,
1829
+ FormData: FormData$1,
1830
+ Blob: Blob$1
1831
+ },
1832
+ protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
1833
+ };
1834
+
1835
+ const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
1836
+
1837
+ const _navigator = typeof navigator === 'object' && navigator || undefined;
1838
+
1839
+ /**
1840
+ * Determine if we're running in a standard browser environment
1841
+ *
1842
+ * This allows axios to run in a web worker, and react-native.
1843
+ * Both environments support XMLHttpRequest, but not fully standard globals.
1844
+ *
1845
+ * web workers:
1846
+ * typeof window -> undefined
1847
+ * typeof document -> undefined
1848
+ *
1849
+ * react-native:
1850
+ * navigator.product -> 'ReactNative'
1851
+ * nativescript
1852
+ * navigator.product -> 'NativeScript' or 'NS'
1853
+ *
1854
+ * @returns {boolean}
1855
+ */
1856
+ const hasStandardBrowserEnv = hasBrowserEnv &&
1857
+ (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
1858
+
1859
+ /**
1860
+ * Determine if we're running in a standard browser webWorker environment
1861
+ *
1862
+ * Although the `isStandardBrowserEnv` method indicates that
1863
+ * `allows axios to run in a web worker`, the WebWorker will still be
1864
+ * filtered out due to its judgment standard
1865
+ * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
1866
+ * This leads to a problem when axios post `FormData` in webWorker
1867
+ */
1868
+ const hasStandardBrowserWebWorkerEnv = (() => {
1869
+ return (
1870
+ typeof WorkerGlobalScope !== 'undefined' &&
1871
+ // eslint-disable-next-line no-undef
1872
+ self instanceof WorkerGlobalScope &&
1873
+ typeof self.importScripts === 'function'
1874
+ );
1875
+ })();
1876
+
1877
+ const origin = hasBrowserEnv && window.location.href || 'http://localhost';
1878
+
1879
+ var utils = /*#__PURE__*/Object.freeze({
1880
+ __proto__: null,
1881
+ hasBrowserEnv: hasBrowserEnv,
1882
+ hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
1883
+ hasStandardBrowserEnv: hasStandardBrowserEnv,
1884
+ navigator: _navigator,
1885
+ origin: origin
1886
+ });
1887
+
1888
+ var platform = {
1889
+ ...utils,
1890
+ ...platform$1
1891
+ };
1892
+
1893
+ function toURLEncodedForm(data, options) {
1894
+ return toFormData(data, new platform.classes.URLSearchParams(), {
1895
+ visitor: function(value, key, path, helpers) {
1896
+ if (platform.isNode && utils$1.isBuffer(value)) {
1897
+ this.append(key, value.toString('base64'));
1898
+ return false;
1899
+ }
1900
+
1901
+ return helpers.defaultVisitor.apply(this, arguments);
1902
+ },
1903
+ ...options
1904
+ });
1905
+ }
1906
+
1907
+ /**
1908
+ * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
1909
+ *
1910
+ * @param {string} name - The name of the property to get.
1911
+ *
1912
+ * @returns An array of strings.
1913
+ */
1914
+ function parsePropPath(name) {
1915
+ // foo[x][y][z]
1916
+ // foo.x.y.z
1917
+ // foo-x-y-z
1918
+ // foo x y z
1919
+ return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
1920
+ return match[0] === '[]' ? '' : match[1] || match[0];
1921
+ });
1922
+ }
1923
+
1924
+ /**
1925
+ * Convert an array to an object.
1926
+ *
1927
+ * @param {Array<any>} arr - The array to convert to an object.
1928
+ *
1929
+ * @returns An object with the same keys and values as the array.
1930
+ */
1931
+ function arrayToObject(arr) {
1932
+ const obj = {};
1933
+ const keys = Object.keys(arr);
1934
+ let i;
1935
+ const len = keys.length;
1936
+ let key;
1937
+ for (i = 0; i < len; i++) {
1938
+ key = keys[i];
1939
+ obj[key] = arr[key];
1940
+ }
1941
+ return obj;
1942
+ }
1943
+
1944
+ /**
1945
+ * It takes a FormData object and returns a JavaScript object
1946
+ *
1947
+ * @param {string} formData The FormData object to convert to JSON.
1948
+ *
1949
+ * @returns {Object<string, any> | null} The converted object.
1950
+ */
1951
+ function formDataToJSON(formData) {
1952
+ function buildPath(path, value, target, index) {
1953
+ let name = path[index++];
1954
+
1955
+ if (name === '__proto__') return true;
1956
+
1957
+ const isNumericKey = Number.isFinite(+name);
1958
+ const isLast = index >= path.length;
1959
+ name = !name && utils$1.isArray(target) ? target.length : name;
1960
+
1961
+ if (isLast) {
1962
+ if (utils$1.hasOwnProp(target, name)) {
1963
+ target[name] = [target[name], value];
1964
+ } else {
1965
+ target[name] = value;
1966
+ }
1967
+
1968
+ return !isNumericKey;
1969
+ }
1970
+
1971
+ if (!target[name] || !utils$1.isObject(target[name])) {
1972
+ target[name] = [];
1973
+ }
1974
+
1975
+ const result = buildPath(path, value, target[name], index);
1976
+
1977
+ if (result && utils$1.isArray(target[name])) {
1978
+ target[name] = arrayToObject(target[name]);
1979
+ }
1980
+
1981
+ return !isNumericKey;
1982
+ }
1983
+
1984
+ if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
1985
+ const obj = {};
1986
+
1987
+ utils$1.forEachEntry(formData, (name, value) => {
1988
+ buildPath(parsePropPath(name), value, obj, 0);
1989
+ });
1990
+
1991
+ return obj;
1992
+ }
1993
+
1994
+ return null;
1995
+ }
1996
+
1997
+ /**
1998
+ * It takes a string, tries to parse it, and if it fails, it returns the stringified version
1999
+ * of the input
2000
+ *
2001
+ * @param {any} rawValue - The value to be stringified.
2002
+ * @param {Function} parser - A function that parses a string into a JavaScript object.
2003
+ * @param {Function} encoder - A function that takes a value and returns a string.
2004
+ *
2005
+ * @returns {string} A stringified version of the rawValue.
2006
+ */
2007
+ function stringifySafely(rawValue, parser, encoder) {
2008
+ if (utils$1.isString(rawValue)) {
2009
+ try {
2010
+ (parser || JSON.parse)(rawValue);
2011
+ return utils$1.trim(rawValue);
2012
+ } catch (e) {
2013
+ if (e.name !== 'SyntaxError') {
2014
+ throw e;
2015
+ }
2016
+ }
2017
+ }
2018
+
2019
+ return (encoder || JSON.stringify)(rawValue);
2020
+ }
2021
+
2022
+ const defaults = {
2023
+
2024
+ transitional: transitionalDefaults,
2025
+
2026
+ adapter: ['xhr', 'http', 'fetch'],
2027
+
2028
+ transformRequest: [function transformRequest(data, headers) {
2029
+ const contentType = headers.getContentType() || '';
2030
+ const hasJSONContentType = contentType.indexOf('application/json') > -1;
2031
+ const isObjectPayload = utils$1.isObject(data);
2032
+
2033
+ if (isObjectPayload && utils$1.isHTMLForm(data)) {
2034
+ data = new FormData(data);
2035
+ }
2036
+
2037
+ const isFormData = utils$1.isFormData(data);
2038
+
2039
+ if (isFormData) {
2040
+ return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
2041
+ }
2042
+
2043
+ if (utils$1.isArrayBuffer(data) ||
2044
+ utils$1.isBuffer(data) ||
2045
+ utils$1.isStream(data) ||
2046
+ utils$1.isFile(data) ||
2047
+ utils$1.isBlob(data) ||
2048
+ utils$1.isReadableStream(data)
2049
+ ) {
2050
+ return data;
2051
+ }
2052
+ if (utils$1.isArrayBufferView(data)) {
2053
+ return data.buffer;
2054
+ }
2055
+ if (utils$1.isURLSearchParams(data)) {
2056
+ headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
2057
+ return data.toString();
2058
+ }
2059
+
2060
+ let isFileList;
2061
+
2062
+ if (isObjectPayload) {
2063
+ if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
2064
+ return toURLEncodedForm(data, this.formSerializer).toString();
2065
+ }
2066
+
2067
+ if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
2068
+ const _FormData = this.env && this.env.FormData;
2069
+
2070
+ return toFormData(
2071
+ isFileList ? {'files[]': data} : data,
2072
+ _FormData && new _FormData(),
2073
+ this.formSerializer
2074
+ );
2075
+ }
2076
+ }
2077
+
2078
+ if (isObjectPayload || hasJSONContentType ) {
2079
+ headers.setContentType('application/json', false);
2080
+ return stringifySafely(data);
2081
+ }
2082
+
2083
+ return data;
2084
+ }],
2085
+
2086
+ transformResponse: [function transformResponse(data) {
2087
+ const transitional = this.transitional || defaults.transitional;
2088
+ const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
2089
+ const JSONRequested = this.responseType === 'json';
2090
+
2091
+ if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
2092
+ return data;
2093
+ }
2094
+
2095
+ if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
2096
+ const silentJSONParsing = transitional && transitional.silentJSONParsing;
2097
+ const strictJSONParsing = !silentJSONParsing && JSONRequested;
2098
+
2099
+ try {
2100
+ return JSON.parse(data, this.parseReviver);
2101
+ } catch (e) {
2102
+ if (strictJSONParsing) {
2103
+ if (e.name === 'SyntaxError') {
2104
+ throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
2105
+ }
2106
+ throw e;
2107
+ }
2108
+ }
2109
+ }
2110
+
2111
+ return data;
2112
+ }],
2113
+
2114
+ /**
2115
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
2116
+ * timeout is not created.
2117
+ */
2118
+ timeout: 0,
2119
+
2120
+ xsrfCookieName: 'XSRF-TOKEN',
2121
+ xsrfHeaderName: 'X-XSRF-TOKEN',
2122
+
2123
+ maxContentLength: -1,
2124
+ maxBodyLength: -1,
2125
+
2126
+ env: {
2127
+ FormData: platform.classes.FormData,
2128
+ Blob: platform.classes.Blob
2129
+ },
2130
+
2131
+ validateStatus: function validateStatus(status) {
2132
+ return status >= 200 && status < 300;
2133
+ },
2134
+
2135
+ headers: {
2136
+ common: {
2137
+ 'Accept': 'application/json, text/plain, */*',
2138
+ 'Content-Type': undefined
2139
+ }
2140
+ }
2141
+ };
2142
+
2143
+ utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
2144
+ defaults.headers[method] = {};
2145
+ });
2146
+
2147
+ var defaults$1 = defaults;
2148
+
2149
+ // RawAxiosHeaders whose duplicates are ignored by node
2150
+ // c.f. https://nodejs.org/api/http.html#http_message_headers
2151
+ const ignoreDuplicateOf = utils$1.toObjectSet([
2152
+ 'age', 'authorization', 'content-length', 'content-type', 'etag',
2153
+ 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
2154
+ 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
2155
+ 'referer', 'retry-after', 'user-agent'
2156
+ ]);
2157
+
2158
+ /**
2159
+ * Parse headers into an object
2160
+ *
2161
+ * ```
2162
+ * Date: Wed, 27 Aug 2014 08:58:49 GMT
2163
+ * Content-Type: application/json
2164
+ * Connection: keep-alive
2165
+ * Transfer-Encoding: chunked
2166
+ * ```
2167
+ *
2168
+ * @param {String} rawHeaders Headers needing to be parsed
2169
+ *
2170
+ * @returns {Object} Headers parsed into an object
2171
+ */
2172
+ var parseHeaders = rawHeaders => {
2173
+ const parsed = {};
2174
+ let key;
2175
+ let val;
2176
+ let i;
2177
+
2178
+ rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
2179
+ i = line.indexOf(':');
2180
+ key = line.substring(0, i).trim().toLowerCase();
2181
+ val = line.substring(i + 1).trim();
2182
+
2183
+ if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
2184
+ return;
2185
+ }
2186
+
2187
+ if (key === 'set-cookie') {
2188
+ if (parsed[key]) {
2189
+ parsed[key].push(val);
2190
+ } else {
2191
+ parsed[key] = [val];
2192
+ }
2193
+ } else {
2194
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
2195
+ }
2196
+ });
2197
+
2198
+ return parsed;
2199
+ };
2200
+
2201
+ const $internals = Symbol('internals');
2202
+
2203
+ function normalizeHeader(header) {
2204
+ return header && String(header).trim().toLowerCase();
2205
+ }
2206
+
2207
+ function normalizeValue(value) {
2208
+ if (value === false || value == null) {
2209
+ return value;
2210
+ }
2211
+
2212
+ return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
2213
+ }
2214
+
2215
+ function parseTokens(str) {
2216
+ const tokens = Object.create(null);
2217
+ const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
2218
+ let match;
2219
+
2220
+ while ((match = tokensRE.exec(str))) {
2221
+ tokens[match[1]] = match[2];
2222
+ }
2223
+
2224
+ return tokens;
2225
+ }
2226
+
2227
+ const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
2228
+
2229
+ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
2230
+ if (utils$1.isFunction(filter)) {
2231
+ return filter.call(this, value, header);
2232
+ }
2233
+
2234
+ if (isHeaderNameFilter) {
2235
+ value = header;
2236
+ }
2237
+
2238
+ if (!utils$1.isString(value)) return;
2239
+
2240
+ if (utils$1.isString(filter)) {
2241
+ return value.indexOf(filter) !== -1;
2242
+ }
2243
+
2244
+ if (utils$1.isRegExp(filter)) {
2245
+ return filter.test(value);
2246
+ }
2247
+ }
2248
+
2249
+ function formatHeader(header) {
2250
+ return header.trim()
2251
+ .toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
2252
+ return char.toUpperCase() + str;
2253
+ });
2254
+ }
2255
+
2256
+ function buildAccessors(obj, header) {
2257
+ const accessorName = utils$1.toCamelCase(' ' + header);
2258
+
2259
+ ['get', 'set', 'has'].forEach(methodName => {
2260
+ Object.defineProperty(obj, methodName + accessorName, {
2261
+ value: function(arg1, arg2, arg3) {
2262
+ return this[methodName].call(this, header, arg1, arg2, arg3);
2263
+ },
2264
+ configurable: true
2265
+ });
2266
+ });
2267
+ }
2268
+
2269
+ class AxiosHeaders {
2270
+ constructor(headers) {
2271
+ headers && this.set(headers);
2272
+ }
2273
+
2274
+ set(header, valueOrRewrite, rewrite) {
2275
+ const self = this;
2276
+
2277
+ function setHeader(_value, _header, _rewrite) {
2278
+ const lHeader = normalizeHeader(_header);
2279
+
2280
+ if (!lHeader) {
2281
+ throw new Error('header name must be a non-empty string');
2282
+ }
2283
+
2284
+ const key = utils$1.findKey(self, lHeader);
2285
+
2286
+ if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
2287
+ self[key || _header] = normalizeValue(_value);
2288
+ }
2289
+ }
2290
+
2291
+ const setHeaders = (headers, _rewrite) =>
2292
+ utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
2293
+
2294
+ if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
2295
+ setHeaders(header, valueOrRewrite);
2296
+ } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
2297
+ setHeaders(parseHeaders(header), valueOrRewrite);
2298
+ } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
2299
+ let obj = {}, dest, key;
2300
+ for (const entry of header) {
2301
+ if (!utils$1.isArray(entry)) {
2302
+ throw TypeError('Object iterator must return a key-value pair');
2303
+ }
2304
+
2305
+ obj[key = entry[0]] = (dest = obj[key]) ?
2306
+ (utils$1.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]]) : entry[1];
2307
+ }
2308
+
2309
+ setHeaders(obj, valueOrRewrite);
2310
+ } else {
2311
+ header != null && setHeader(valueOrRewrite, header, rewrite);
2312
+ }
2313
+
2314
+ return this;
2315
+ }
2316
+
2317
+ get(header, parser) {
2318
+ header = normalizeHeader(header);
2319
+
2320
+ if (header) {
2321
+ const key = utils$1.findKey(this, header);
2322
+
2323
+ if (key) {
2324
+ const value = this[key];
2325
+
2326
+ if (!parser) {
2327
+ return value;
2328
+ }
2329
+
2330
+ if (parser === true) {
2331
+ return parseTokens(value);
2332
+ }
2333
+
2334
+ if (utils$1.isFunction(parser)) {
2335
+ return parser.call(this, value, key);
2336
+ }
2337
+
2338
+ if (utils$1.isRegExp(parser)) {
2339
+ return parser.exec(value);
2340
+ }
2341
+
2342
+ throw new TypeError('parser must be boolean|regexp|function');
2343
+ }
2344
+ }
2345
+ }
2346
+
2347
+ has(header, matcher) {
2348
+ header = normalizeHeader(header);
2349
+
2350
+ if (header) {
2351
+ const key = utils$1.findKey(this, header);
2352
+
2353
+ return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
2354
+ }
2355
+
2356
+ return false;
2357
+ }
2358
+
2359
+ delete(header, matcher) {
2360
+ const self = this;
2361
+ let deleted = false;
2362
+
2363
+ function deleteHeader(_header) {
2364
+ _header = normalizeHeader(_header);
2365
+
2366
+ if (_header) {
2367
+ const key = utils$1.findKey(self, _header);
2368
+
2369
+ if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
2370
+ delete self[key];
2371
+
2372
+ deleted = true;
2373
+ }
2374
+ }
2375
+ }
2376
+
2377
+ if (utils$1.isArray(header)) {
2378
+ header.forEach(deleteHeader);
2379
+ } else {
2380
+ deleteHeader(header);
2381
+ }
2382
+
2383
+ return deleted;
2384
+ }
2385
+
2386
+ clear(matcher) {
2387
+ const keys = Object.keys(this);
2388
+ let i = keys.length;
2389
+ let deleted = false;
2390
+
2391
+ while (i--) {
2392
+ const key = keys[i];
2393
+ if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
2394
+ delete this[key];
2395
+ deleted = true;
2396
+ }
2397
+ }
2398
+
2399
+ return deleted;
2400
+ }
2401
+
2402
+ normalize(format) {
2403
+ const self = this;
2404
+ const headers = {};
2405
+
2406
+ utils$1.forEach(this, (value, header) => {
2407
+ const key = utils$1.findKey(headers, header);
2408
+
2409
+ if (key) {
2410
+ self[key] = normalizeValue(value);
2411
+ delete self[header];
2412
+ return;
2413
+ }
2414
+
2415
+ const normalized = format ? formatHeader(header) : String(header).trim();
2416
+
2417
+ if (normalized !== header) {
2418
+ delete self[header];
2419
+ }
2420
+
2421
+ self[normalized] = normalizeValue(value);
2422
+
2423
+ headers[normalized] = true;
2424
+ });
2425
+
2426
+ return this;
2427
+ }
2428
+
2429
+ concat(...targets) {
2430
+ return this.constructor.concat(this, ...targets);
2431
+ }
2432
+
2433
+ toJSON(asStrings) {
2434
+ const obj = Object.create(null);
2435
+
2436
+ utils$1.forEach(this, (value, header) => {
2437
+ value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
2438
+ });
2439
+
2440
+ return obj;
2441
+ }
2442
+
2443
+ [Symbol.iterator]() {
2444
+ return Object.entries(this.toJSON())[Symbol.iterator]();
2445
+ }
2446
+
2447
+ toString() {
2448
+ return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
2449
+ }
2450
+
2451
+ getSetCookie() {
2452
+ return this.get("set-cookie") || [];
2453
+ }
2454
+
2455
+ get [Symbol.toStringTag]() {
2456
+ return 'AxiosHeaders';
2457
+ }
2458
+
2459
+ static from(thing) {
2460
+ return thing instanceof this ? thing : new this(thing);
2461
+ }
2462
+
2463
+ static concat(first, ...targets) {
2464
+ const computed = new this(first);
2465
+
2466
+ targets.forEach((target) => computed.set(target));
2467
+
2468
+ return computed;
2469
+ }
2470
+
2471
+ static accessor(header) {
2472
+ const internals = this[$internals] = (this[$internals] = {
2473
+ accessors: {}
2474
+ });
2475
+
2476
+ const accessors = internals.accessors;
2477
+ const prototype = this.prototype;
2478
+
2479
+ function defineAccessor(_header) {
2480
+ const lHeader = normalizeHeader(_header);
2481
+
2482
+ if (!accessors[lHeader]) {
2483
+ buildAccessors(prototype, _header);
2484
+ accessors[lHeader] = true;
2485
+ }
2486
+ }
2487
+
2488
+ utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
2489
+
2490
+ return this;
2491
+ }
2492
+ }
2493
+
2494
+ AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
2495
+
2496
+ // reserved names hotfix
2497
+ utils$1.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
2498
+ let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
2499
+ return {
2500
+ get: () => value,
2501
+ set(headerValue) {
2502
+ this[mapped] = headerValue;
2503
+ }
2504
+ }
2505
+ });
2506
+
2507
+ utils$1.freezeMethods(AxiosHeaders);
2508
+
2509
+ var AxiosHeaders$1 = AxiosHeaders;
2510
+
2511
+ /**
2512
+ * Transform the data for a request or a response
2513
+ *
2514
+ * @param {Array|Function} fns A single function or Array of functions
2515
+ * @param {?Object} response The response object
2516
+ *
2517
+ * @returns {*} The resulting transformed data
2518
+ */
2519
+ function transformData(fns, response) {
2520
+ const config = this || defaults$1;
2521
+ const context = response || config;
2522
+ const headers = AxiosHeaders$1.from(context.headers);
2523
+ let data = context.data;
2524
+
2525
+ utils$1.forEach(fns, function transform(fn) {
2526
+ data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
2527
+ });
2528
+
2529
+ headers.normalize();
2530
+
2531
+ return data;
2532
+ }
2533
+
2534
+ function isCancel(value) {
2535
+ return !!(value && value.__CANCEL__);
2536
+ }
2537
+
2538
+ /**
2539
+ * A `CanceledError` is an object that is thrown when an operation is canceled.
2540
+ *
2541
+ * @param {string=} message The message.
2542
+ * @param {Object=} config The config.
2543
+ * @param {Object=} request The request.
2544
+ *
2545
+ * @returns {CanceledError} The created error.
2546
+ */
2547
+ function CanceledError(message, config, request) {
2548
+ // eslint-disable-next-line no-eq-null,eqeqeq
2549
+ AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
2550
+ this.name = 'CanceledError';
2551
+ }
2552
+
2553
+ utils$1.inherits(CanceledError, AxiosError, {
2554
+ __CANCEL__: true
2555
+ });
2556
+
2557
+ /**
2558
+ * Resolve or reject a Promise based on response status.
2559
+ *
2560
+ * @param {Function} resolve A function that resolves the promise.
2561
+ * @param {Function} reject A function that rejects the promise.
2562
+ * @param {object} response The response.
2563
+ *
2564
+ * @returns {object} The response.
2565
+ */
2566
+ function settle(resolve, reject, response) {
2567
+ const validateStatus = response.config.validateStatus;
2568
+ if (!response.status || !validateStatus || validateStatus(response.status)) {
2569
+ resolve(response);
2570
+ } else {
2571
+ reject(new AxiosError(
2572
+ 'Request failed with status code ' + response.status,
2573
+ [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
2574
+ response.config,
2575
+ response.request,
2576
+ response
2577
+ ));
2578
+ }
2579
+ }
2580
+
2581
+ function parseProtocol(url) {
2582
+ const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
2583
+ return match && match[1] || '';
2584
+ }
2585
+
2586
+ /**
2587
+ * Calculate data maxRate
2588
+ * @param {Number} [samplesCount= 10]
2589
+ * @param {Number} [min= 1000]
2590
+ * @returns {Function}
2591
+ */
2592
+ function speedometer(samplesCount, min) {
2593
+ samplesCount = samplesCount || 10;
2594
+ const bytes = new Array(samplesCount);
2595
+ const timestamps = new Array(samplesCount);
2596
+ let head = 0;
2597
+ let tail = 0;
2598
+ let firstSampleTS;
2599
+
2600
+ min = min !== undefined ? min : 1000;
2601
+
2602
+ return function push(chunkLength) {
2603
+ const now = Date.now();
2604
+
2605
+ const startedAt = timestamps[tail];
2606
+
2607
+ if (!firstSampleTS) {
2608
+ firstSampleTS = now;
2609
+ }
2610
+
2611
+ bytes[head] = chunkLength;
2612
+ timestamps[head] = now;
2613
+
2614
+ let i = tail;
2615
+ let bytesCount = 0;
2616
+
2617
+ while (i !== head) {
2618
+ bytesCount += bytes[i++];
2619
+ i = i % samplesCount;
2620
+ }
2621
+
2622
+ head = (head + 1) % samplesCount;
2623
+
2624
+ if (head === tail) {
2625
+ tail = (tail + 1) % samplesCount;
2626
+ }
2627
+
2628
+ if (now - firstSampleTS < min) {
2629
+ return;
2630
+ }
2631
+
2632
+ const passed = startedAt && now - startedAt;
2633
+
2634
+ return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
2635
+ };
2636
+ }
2637
+
2638
+ /**
2639
+ * Throttle decorator
2640
+ * @param {Function} fn
2641
+ * @param {Number} freq
2642
+ * @return {Function}
2643
+ */
2644
+ function throttle(fn, freq) {
2645
+ let timestamp = 0;
2646
+ let threshold = 1000 / freq;
2647
+ let lastArgs;
2648
+ let timer;
2649
+
2650
+ const invoke = (args, now = Date.now()) => {
2651
+ timestamp = now;
2652
+ lastArgs = null;
2653
+ if (timer) {
2654
+ clearTimeout(timer);
2655
+ timer = null;
2656
+ }
2657
+ fn(...args);
2658
+ };
2659
+
2660
+ const throttled = (...args) => {
2661
+ const now = Date.now();
2662
+ const passed = now - timestamp;
2663
+ if ( passed >= threshold) {
2664
+ invoke(args, now);
2665
+ } else {
2666
+ lastArgs = args;
2667
+ if (!timer) {
2668
+ timer = setTimeout(() => {
2669
+ timer = null;
2670
+ invoke(lastArgs);
2671
+ }, threshold - passed);
2672
+ }
2673
+ }
2674
+ };
2675
+
2676
+ const flush = () => lastArgs && invoke(lastArgs);
2677
+
2678
+ return [throttled, flush];
2679
+ }
2680
+
2681
+ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
2682
+ let bytesNotified = 0;
2683
+ const _speedometer = speedometer(50, 250);
2684
+
2685
+ return throttle(e => {
2686
+ const loaded = e.loaded;
2687
+ const total = e.lengthComputable ? e.total : undefined;
2688
+ const progressBytes = loaded - bytesNotified;
2689
+ const rate = _speedometer(progressBytes);
2690
+ const inRange = loaded <= total;
2691
+
2692
+ bytesNotified = loaded;
2693
+
2694
+ const data = {
2695
+ loaded,
2696
+ total,
2697
+ progress: total ? (loaded / total) : undefined,
2698
+ bytes: progressBytes,
2699
+ rate: rate ? rate : undefined,
2700
+ estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
2701
+ event: e,
2702
+ lengthComputable: total != null,
2703
+ [isDownloadStream ? 'download' : 'upload']: true
2704
+ };
2705
+
2706
+ listener(data);
2707
+ }, freq);
2708
+ };
2709
+
2710
+ const progressEventDecorator = (total, throttled) => {
2711
+ const lengthComputable = total != null;
2712
+
2713
+ return [(loaded) => throttled[0]({
2714
+ lengthComputable,
2715
+ total,
2716
+ loaded
2717
+ }), throttled[1]];
2718
+ };
2719
+
2720
+ const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
2721
+
2722
+ var isURLSameOrigin = platform.hasStandardBrowserEnv ? ((origin, isMSIE) => (url) => {
2723
+ url = new URL(url, platform.origin);
2724
+
2725
+ return (
2726
+ origin.protocol === url.protocol &&
2727
+ origin.host === url.host &&
2728
+ (isMSIE || origin.port === url.port)
2729
+ );
2730
+ })(
2731
+ new URL(platform.origin),
2732
+ platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
2733
+ ) : () => true;
2734
+
2735
+ var cookies = platform.hasStandardBrowserEnv ?
2736
+
2737
+ // Standard browser envs support document.cookie
2738
+ {
2739
+ write(name, value, expires, path, domain, secure) {
2740
+ const cookie = [name + '=' + encodeURIComponent(value)];
2741
+
2742
+ utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
2743
+
2744
+ utils$1.isString(path) && cookie.push('path=' + path);
2745
+
2746
+ utils$1.isString(domain) && cookie.push('domain=' + domain);
2747
+
2748
+ secure === true && cookie.push('secure');
2749
+
2750
+ document.cookie = cookie.join('; ');
2751
+ },
2752
+
2753
+ read(name) {
2754
+ const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
2755
+ return (match ? decodeURIComponent(match[3]) : null);
2756
+ },
2757
+
2758
+ remove(name) {
2759
+ this.write(name, '', Date.now() - 86400000);
2760
+ }
2761
+ }
2762
+
2763
+ :
2764
+
2765
+ // Non-standard browser env (web workers, react-native) lack needed support.
2766
+ {
2767
+ write() {},
2768
+ read() {
2769
+ return null;
2770
+ },
2771
+ remove() {}
2772
+ };
2773
+
2774
+ /**
2775
+ * Determines whether the specified URL is absolute
2776
+ *
2777
+ * @param {string} url The URL to test
2778
+ *
2779
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
2780
+ */
2781
+ function isAbsoluteURL(url) {
2782
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
2783
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
2784
+ // by any combination of letters, digits, plus, period, or hyphen.
2785
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
2786
+ }
2787
+
2788
+ /**
2789
+ * Creates a new URL by combining the specified URLs
2790
+ *
2791
+ * @param {string} baseURL The base URL
2792
+ * @param {string} relativeURL The relative URL
2793
+ *
2794
+ * @returns {string} The combined URL
2795
+ */
2796
+ function combineURLs(baseURL, relativeURL) {
2797
+ return relativeURL
2798
+ ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
2799
+ : baseURL;
2800
+ }
2801
+
2802
+ /**
2803
+ * Creates a new URL by combining the baseURL with the requestedURL,
2804
+ * only when the requestedURL is not already an absolute URL.
2805
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
2806
+ *
2807
+ * @param {string} baseURL The base URL
2808
+ * @param {string} requestedURL Absolute or relative URL to combine
2809
+ *
2810
+ * @returns {string} The combined full path
2811
+ */
2812
+ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
2813
+ let isRelativeUrl = !isAbsoluteURL(requestedURL);
2814
+ if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
2815
+ return combineURLs(baseURL, requestedURL);
2816
+ }
2817
+ return requestedURL;
2818
+ }
2819
+
2820
+ const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
2821
+
2822
+ /**
2823
+ * Config-specific merge-function which creates a new config-object
2824
+ * by merging two configuration objects together.
2825
+ *
2826
+ * @param {Object} config1
2827
+ * @param {Object} config2
2828
+ *
2829
+ * @returns {Object} New object resulting from merging config2 to config1
2830
+ */
2831
+ function mergeConfig(config1, config2) {
2832
+ // eslint-disable-next-line no-param-reassign
2833
+ config2 = config2 || {};
2834
+ const config = {};
2835
+
2836
+ function getMergedValue(target, source, prop, caseless) {
2837
+ if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
2838
+ return utils$1.merge.call({caseless}, target, source);
2839
+ } else if (utils$1.isPlainObject(source)) {
2840
+ return utils$1.merge({}, source);
2841
+ } else if (utils$1.isArray(source)) {
2842
+ return source.slice();
2843
+ }
2844
+ return source;
2845
+ }
2846
+
2847
+ // eslint-disable-next-line consistent-return
2848
+ function mergeDeepProperties(a, b, prop , caseless) {
2849
+ if (!utils$1.isUndefined(b)) {
2850
+ return getMergedValue(a, b, prop , caseless);
2851
+ } else if (!utils$1.isUndefined(a)) {
2852
+ return getMergedValue(undefined, a, prop , caseless);
2853
+ }
2854
+ }
2855
+
2856
+ // eslint-disable-next-line consistent-return
2857
+ function valueFromConfig2(a, b) {
2858
+ if (!utils$1.isUndefined(b)) {
2859
+ return getMergedValue(undefined, b);
2860
+ }
2861
+ }
2862
+
2863
+ // eslint-disable-next-line consistent-return
2864
+ function defaultToConfig2(a, b) {
2865
+ if (!utils$1.isUndefined(b)) {
2866
+ return getMergedValue(undefined, b);
2867
+ } else if (!utils$1.isUndefined(a)) {
2868
+ return getMergedValue(undefined, a);
2869
+ }
2870
+ }
2871
+
2872
+ // eslint-disable-next-line consistent-return
2873
+ function mergeDirectKeys(a, b, prop) {
2874
+ if (prop in config2) {
2875
+ return getMergedValue(a, b);
2876
+ } else if (prop in config1) {
2877
+ return getMergedValue(undefined, a);
2878
+ }
2879
+ }
2880
+
2881
+ const mergeMap = {
2882
+ url: valueFromConfig2,
2883
+ method: valueFromConfig2,
2884
+ data: valueFromConfig2,
2885
+ baseURL: defaultToConfig2,
2886
+ transformRequest: defaultToConfig2,
2887
+ transformResponse: defaultToConfig2,
2888
+ paramsSerializer: defaultToConfig2,
2889
+ timeout: defaultToConfig2,
2890
+ timeoutMessage: defaultToConfig2,
2891
+ withCredentials: defaultToConfig2,
2892
+ withXSRFToken: defaultToConfig2,
2893
+ adapter: defaultToConfig2,
2894
+ responseType: defaultToConfig2,
2895
+ xsrfCookieName: defaultToConfig2,
2896
+ xsrfHeaderName: defaultToConfig2,
2897
+ onUploadProgress: defaultToConfig2,
2898
+ onDownloadProgress: defaultToConfig2,
2899
+ decompress: defaultToConfig2,
2900
+ maxContentLength: defaultToConfig2,
2901
+ maxBodyLength: defaultToConfig2,
2902
+ beforeRedirect: defaultToConfig2,
2903
+ transport: defaultToConfig2,
2904
+ httpAgent: defaultToConfig2,
2905
+ httpsAgent: defaultToConfig2,
2906
+ cancelToken: defaultToConfig2,
2907
+ socketPath: defaultToConfig2,
2908
+ responseEncoding: defaultToConfig2,
2909
+ validateStatus: mergeDirectKeys,
2910
+ headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
2911
+ };
2912
+
2913
+ utils$1.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
2914
+ const merge = mergeMap[prop] || mergeDeepProperties;
2915
+ const configValue = merge(config1[prop], config2[prop], prop);
2916
+ (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
2917
+ });
2918
+
2919
+ return config;
2920
+ }
2921
+
2922
+ var resolveConfig = (config) => {
2923
+ const newConfig = mergeConfig({}, config);
2924
+
2925
+ let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
2926
+
2927
+ newConfig.headers = headers = AxiosHeaders$1.from(headers);
2928
+
2929
+ newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
2930
+
2931
+ // HTTP basic authentication
2932
+ if (auth) {
2933
+ headers.set('Authorization', 'Basic ' +
2934
+ btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : ''))
2935
+ );
2936
+ }
2937
+
2938
+ if (utils$1.isFormData(data)) {
2939
+ if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
2940
+ headers.setContentType(undefined); // browser handles it
2941
+ } else if (utils$1.isFunction(data.getHeaders)) {
2942
+ // Node.js FormData (like form-data package)
2943
+ const formHeaders = data.getHeaders();
2944
+ // Only set safe headers to avoid overwriting security headers
2945
+ const allowedHeaders = ['content-type', 'content-length'];
2946
+ Object.entries(formHeaders).forEach(([key, val]) => {
2947
+ if (allowedHeaders.includes(key.toLowerCase())) {
2948
+ headers.set(key, val);
2949
+ }
2950
+ });
2951
+ }
2952
+ }
2953
+
2954
+ // Add xsrf header
2955
+ // This is only done if running in a standard browser environment.
2956
+ // Specifically not if we're in a web worker, or react-native.
2957
+
2958
+ if (platform.hasStandardBrowserEnv) {
2959
+ withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
2960
+
2961
+ if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
2962
+ // Add xsrf header
2963
+ const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
2964
+
2965
+ if (xsrfValue) {
2966
+ headers.set(xsrfHeaderName, xsrfValue);
2967
+ }
2968
+ }
2969
+ }
2970
+
2971
+ return newConfig;
2972
+ };
2973
+
2974
+ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
2975
+
2976
+ var xhrAdapter = isXHRAdapterSupported && function (config) {
2977
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
2978
+ const _config = resolveConfig(config);
2979
+ let requestData = _config.data;
2980
+ const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
2981
+ let {responseType, onUploadProgress, onDownloadProgress} = _config;
2982
+ let onCanceled;
2983
+ let uploadThrottled, downloadThrottled;
2984
+ let flushUpload, flushDownload;
2985
+
2986
+ function done() {
2987
+ flushUpload && flushUpload(); // flush events
2988
+ flushDownload && flushDownload(); // flush events
2989
+
2990
+ _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
2991
+
2992
+ _config.signal && _config.signal.removeEventListener('abort', onCanceled);
2993
+ }
2994
+
2995
+ let request = new XMLHttpRequest();
2996
+
2997
+ request.open(_config.method.toUpperCase(), _config.url, true);
2998
+
2999
+ // Set the request timeout in MS
3000
+ request.timeout = _config.timeout;
3001
+
3002
+ function onloadend() {
3003
+ if (!request) {
3004
+ return;
3005
+ }
3006
+ // Prepare the response
3007
+ const responseHeaders = AxiosHeaders$1.from(
3008
+ 'getAllResponseHeaders' in request && request.getAllResponseHeaders()
3009
+ );
3010
+ const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
3011
+ request.responseText : request.response;
3012
+ const response = {
3013
+ data: responseData,
3014
+ status: request.status,
3015
+ statusText: request.statusText,
3016
+ headers: responseHeaders,
3017
+ config,
3018
+ request
3019
+ };
3020
+
3021
+ settle(function _resolve(value) {
3022
+ resolve(value);
3023
+ done();
3024
+ }, function _reject(err) {
3025
+ reject(err);
3026
+ done();
3027
+ }, response);
3028
+
3029
+ // Clean up request
3030
+ request = null;
3031
+ }
3032
+
3033
+ if ('onloadend' in request) {
3034
+ // Use onloadend if available
3035
+ request.onloadend = onloadend;
3036
+ } else {
3037
+ // Listen for ready state to emulate onloadend
3038
+ request.onreadystatechange = function handleLoad() {
3039
+ if (!request || request.readyState !== 4) {
3040
+ return;
3041
+ }
3042
+
3043
+ // The request errored out and we didn't get a response, this will be
3044
+ // handled by onerror instead
3045
+ // With one exception: request that using file: protocol, most browsers
3046
+ // will return status as 0 even though it's a successful request
3047
+ if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
3048
+ return;
3049
+ }
3050
+ // readystate handler is calling before onerror or ontimeout handlers,
3051
+ // so we should call onloadend on the next 'tick'
3052
+ setTimeout(onloadend);
3053
+ };
3054
+ }
3055
+
3056
+ // Handle browser request cancellation (as opposed to a manual cancellation)
3057
+ request.onabort = function handleAbort() {
3058
+ if (!request) {
3059
+ return;
3060
+ }
3061
+
3062
+ reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
3063
+
3064
+ // Clean up request
3065
+ request = null;
3066
+ };
3067
+
3068
+ // Handle low level network errors
3069
+ request.onerror = function handleError(event) {
3070
+ // Browsers deliver a ProgressEvent in XHR onerror
3071
+ // (message may be empty; when present, surface it)
3072
+ // See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
3073
+ const msg = event && event.message ? event.message : 'Network Error';
3074
+ const err = new AxiosError(msg, AxiosError.ERR_NETWORK, config, request);
3075
+ // attach the underlying event for consumers who want details
3076
+ err.event = event || null;
3077
+ reject(err);
3078
+ request = null;
3079
+ };
3080
+
3081
+ // Handle timeout
3082
+ request.ontimeout = function handleTimeout() {
3083
+ let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
3084
+ const transitional = _config.transitional || transitionalDefaults;
3085
+ if (_config.timeoutErrorMessage) {
3086
+ timeoutErrorMessage = _config.timeoutErrorMessage;
3087
+ }
3088
+ reject(new AxiosError(
3089
+ timeoutErrorMessage,
3090
+ transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
3091
+ config,
3092
+ request));
3093
+
3094
+ // Clean up request
3095
+ request = null;
3096
+ };
3097
+
3098
+ // Remove Content-Type if data is undefined
3099
+ requestData === undefined && requestHeaders.setContentType(null);
3100
+
3101
+ // Add headers to the request
3102
+ if ('setRequestHeader' in request) {
3103
+ utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
3104
+ request.setRequestHeader(key, val);
3105
+ });
3106
+ }
3107
+
3108
+ // Add withCredentials to request if needed
3109
+ if (!utils$1.isUndefined(_config.withCredentials)) {
3110
+ request.withCredentials = !!_config.withCredentials;
3111
+ }
3112
+
3113
+ // Add responseType to request if needed
3114
+ if (responseType && responseType !== 'json') {
3115
+ request.responseType = _config.responseType;
3116
+ }
3117
+
3118
+ // Handle progress if needed
3119
+ if (onDownloadProgress) {
3120
+ ([downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true));
3121
+ request.addEventListener('progress', downloadThrottled);
3122
+ }
3123
+
3124
+ // Not all browsers support upload events
3125
+ if (onUploadProgress && request.upload) {
3126
+ ([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
3127
+
3128
+ request.upload.addEventListener('progress', uploadThrottled);
3129
+
3130
+ request.upload.addEventListener('loadend', flushUpload);
3131
+ }
3132
+
3133
+ if (_config.cancelToken || _config.signal) {
3134
+ // Handle cancellation
3135
+ // eslint-disable-next-line func-names
3136
+ onCanceled = cancel => {
3137
+ if (!request) {
3138
+ return;
3139
+ }
3140
+ reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
3141
+ request.abort();
3142
+ request = null;
3143
+ };
3144
+
3145
+ _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
3146
+ if (_config.signal) {
3147
+ _config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
3148
+ }
3149
+ }
3150
+
3151
+ const protocol = parseProtocol(_config.url);
3152
+
3153
+ if (protocol && platform.protocols.indexOf(protocol) === -1) {
3154
+ reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
3155
+ return;
3156
+ }
3157
+
3158
+
3159
+ // Send the request
3160
+ request.send(requestData || null);
3161
+ });
3162
+ };
3163
+
3164
+ const composeSignals = (signals, timeout) => {
3165
+ const {length} = (signals = signals ? signals.filter(Boolean) : []);
3166
+
3167
+ if (timeout || length) {
3168
+ let controller = new AbortController();
3169
+
3170
+ let aborted;
3171
+
3172
+ const onabort = function (reason) {
3173
+ if (!aborted) {
3174
+ aborted = true;
3175
+ unsubscribe();
3176
+ const err = reason instanceof Error ? reason : this.reason;
3177
+ controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
3178
+ }
3179
+ };
3180
+
3181
+ let timer = timeout && setTimeout(() => {
3182
+ timer = null;
3183
+ onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
3184
+ }, timeout);
3185
+
3186
+ const unsubscribe = () => {
3187
+ if (signals) {
3188
+ timer && clearTimeout(timer);
3189
+ timer = null;
3190
+ signals.forEach(signal => {
3191
+ signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
3192
+ });
3193
+ signals = null;
3194
+ }
3195
+ };
3196
+
3197
+ signals.forEach((signal) => signal.addEventListener('abort', onabort));
3198
+
3199
+ const {signal} = controller;
3200
+
3201
+ signal.unsubscribe = () => utils$1.asap(unsubscribe);
3202
+
3203
+ return signal;
3204
+ }
3205
+ };
3206
+
3207
+ var composeSignals$1 = composeSignals;
3208
+
3209
+ const streamChunk = function* (chunk, chunkSize) {
3210
+ let len = chunk.byteLength;
3211
+
3212
+ if (!chunkSize || len < chunkSize) {
3213
+ yield chunk;
3214
+ return;
3215
+ }
3216
+
3217
+ let pos = 0;
3218
+ let end;
3219
+
3220
+ while (pos < len) {
3221
+ end = pos + chunkSize;
3222
+ yield chunk.slice(pos, end);
3223
+ pos = end;
3224
+ }
3225
+ };
3226
+
3227
+ const readBytes = async function* (iterable, chunkSize) {
3228
+ for await (const chunk of readStream(iterable)) {
3229
+ yield* streamChunk(chunk, chunkSize);
3230
+ }
3231
+ };
3232
+
3233
+ const readStream = async function* (stream) {
3234
+ if (stream[Symbol.asyncIterator]) {
3235
+ yield* stream;
3236
+ return;
3237
+ }
3238
+
3239
+ const reader = stream.getReader();
3240
+ try {
3241
+ for (;;) {
3242
+ const {done, value} = await reader.read();
3243
+ if (done) {
3244
+ break;
3245
+ }
3246
+ yield value;
3247
+ }
3248
+ } finally {
3249
+ await reader.cancel();
3250
+ }
3251
+ };
3252
+
3253
+ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
3254
+ const iterator = readBytes(stream, chunkSize);
3255
+
3256
+ let bytes = 0;
3257
+ let done;
3258
+ let _onFinish = (e) => {
3259
+ if (!done) {
3260
+ done = true;
3261
+ onFinish && onFinish(e);
3262
+ }
3263
+ };
3264
+
3265
+ return new ReadableStream({
3266
+ async pull(controller) {
3267
+ try {
3268
+ const {done, value} = await iterator.next();
3269
+
3270
+ if (done) {
3271
+ _onFinish();
3272
+ controller.close();
3273
+ return;
3274
+ }
3275
+
3276
+ let len = value.byteLength;
3277
+ if (onProgress) {
3278
+ let loadedBytes = bytes += len;
3279
+ onProgress(loadedBytes);
3280
+ }
3281
+ controller.enqueue(new Uint8Array(value));
3282
+ } catch (err) {
3283
+ _onFinish(err);
3284
+ throw err;
3285
+ }
3286
+ },
3287
+ cancel(reason) {
3288
+ _onFinish(reason);
3289
+ return iterator.return();
3290
+ }
3291
+ }, {
3292
+ highWaterMark: 2
3293
+ })
3294
+ };
3295
+
3296
+ const DEFAULT_CHUNK_SIZE = 64 * 1024;
3297
+
3298
+ const {isFunction} = utils$1;
3299
+
3300
+ const globalFetchAPI = (({Request, Response}) => ({
3301
+ Request, Response
3302
+ }))(utils$1.global);
3303
+
3304
+ const {
3305
+ ReadableStream: ReadableStream$1, TextEncoder
3306
+ } = utils$1.global;
3307
+
3308
+
3309
+ const test = (fn, ...args) => {
3310
+ try {
3311
+ return !!fn(...args);
3312
+ } catch (e) {
3313
+ return false
3314
+ }
3315
+ };
3316
+
3317
+ const factory = (env) => {
3318
+ env = utils$1.merge.call({
3319
+ skipUndefined: true
3320
+ }, globalFetchAPI, env);
3321
+
3322
+ const {fetch: envFetch, Request, Response} = env;
3323
+ const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
3324
+ const isRequestSupported = isFunction(Request);
3325
+ const isResponseSupported = isFunction(Response);
3326
+
3327
+ if (!isFetchSupported) {
3328
+ return false;
3329
+ }
3330
+
3331
+ const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
3332
+
3333
+ const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
3334
+ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
3335
+ async (str) => new Uint8Array(await new Request(str).arrayBuffer())
3336
+ );
3337
+
3338
+ const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
3339
+ let duplexAccessed = false;
3340
+
3341
+ const hasContentType = new Request(platform.origin, {
3342
+ body: new ReadableStream$1(),
3343
+ method: 'POST',
3344
+ get duplex() {
3345
+ duplexAccessed = true;
3346
+ return 'half';
3347
+ },
3348
+ }).headers.has('Content-Type');
3349
+
3350
+ return duplexAccessed && !hasContentType;
3351
+ });
3352
+
3353
+ const supportsResponseStream = isResponseSupported && isReadableStreamSupported &&
3354
+ test(() => utils$1.isReadableStream(new Response('').body));
3355
+
3356
+ const resolvers = {
3357
+ stream: supportsResponseStream && ((res) => res.body)
3358
+ };
3359
+
3360
+ isFetchSupported && ((() => {
3361
+ ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
3362
+ !resolvers[type] && (resolvers[type] = (res, config) => {
3363
+ let method = res && res[type];
3364
+
3365
+ if (method) {
3366
+ return method.call(res);
3367
+ }
3368
+
3369
+ throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
3370
+ });
3371
+ });
3372
+ })());
3373
+
3374
+ const getBodyLength = async (body) => {
3375
+ if (body == null) {
3376
+ return 0;
3377
+ }
3378
+
3379
+ if (utils$1.isBlob(body)) {
3380
+ return body.size;
3381
+ }
3382
+
3383
+ if (utils$1.isSpecCompliantForm(body)) {
3384
+ const _request = new Request(platform.origin, {
3385
+ method: 'POST',
3386
+ body,
3387
+ });
3388
+ return (await _request.arrayBuffer()).byteLength;
3389
+ }
3390
+
3391
+ if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
3392
+ return body.byteLength;
3393
+ }
3394
+
3395
+ if (utils$1.isURLSearchParams(body)) {
3396
+ body = body + '';
3397
+ }
3398
+
3399
+ if (utils$1.isString(body)) {
3400
+ return (await encodeText(body)).byteLength;
3401
+ }
3402
+ };
3403
+
3404
+ const resolveBodyLength = async (headers, body) => {
3405
+ const length = utils$1.toFiniteNumber(headers.getContentLength());
3406
+
3407
+ return length == null ? getBodyLength(body) : length;
3408
+ };
3409
+
3410
+ return async (config) => {
3411
+ let {
3412
+ url,
3413
+ method,
3414
+ data,
3415
+ signal,
3416
+ cancelToken,
3417
+ timeout,
3418
+ onDownloadProgress,
3419
+ onUploadProgress,
3420
+ responseType,
3421
+ headers,
3422
+ withCredentials = 'same-origin',
3423
+ fetchOptions
3424
+ } = resolveConfig(config);
3425
+
3426
+ let _fetch = envFetch || fetch;
3427
+
3428
+ responseType = responseType ? (responseType + '').toLowerCase() : 'text';
3429
+
3430
+ let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
3431
+
3432
+ let request = null;
3433
+
3434
+ const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
3435
+ composedSignal.unsubscribe();
3436
+ });
3437
+
3438
+ let requestContentLength;
3439
+
3440
+ try {
3441
+ if (
3442
+ onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
3443
+ (requestContentLength = await resolveBodyLength(headers, data)) !== 0
3444
+ ) {
3445
+ let _request = new Request(url, {
3446
+ method: 'POST',
3447
+ body: data,
3448
+ duplex: "half"
3449
+ });
3450
+
3451
+ let contentTypeHeader;
3452
+
3453
+ if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
3454
+ headers.setContentType(contentTypeHeader);
3455
+ }
3456
+
3457
+ if (_request.body) {
3458
+ const [onProgress, flush] = progressEventDecorator(
3459
+ requestContentLength,
3460
+ progressEventReducer(asyncDecorator(onUploadProgress))
3461
+ );
3462
+
3463
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
3464
+ }
3465
+ }
3466
+
3467
+ if (!utils$1.isString(withCredentials)) {
3468
+ withCredentials = withCredentials ? 'include' : 'omit';
3469
+ }
3470
+
3471
+ // Cloudflare Workers throws when credentials are defined
3472
+ // see https://github.com/cloudflare/workerd/issues/902
3473
+ const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
3474
+
3475
+ const resolvedOptions = {
3476
+ ...fetchOptions,
3477
+ signal: composedSignal,
3478
+ method: method.toUpperCase(),
3479
+ headers: headers.normalize().toJSON(),
3480
+ body: data,
3481
+ duplex: "half",
3482
+ credentials: isCredentialsSupported ? withCredentials : undefined
3483
+ };
3484
+
3485
+ request = isRequestSupported && new Request(url, resolvedOptions);
3486
+
3487
+ let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions));
3488
+
3489
+ const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
3490
+
3491
+ if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
3492
+ const options = {};
3493
+
3494
+ ['status', 'statusText', 'headers'].forEach(prop => {
3495
+ options[prop] = response[prop];
3496
+ });
3497
+
3498
+ const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
3499
+
3500
+ const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
3501
+ responseContentLength,
3502
+ progressEventReducer(asyncDecorator(onDownloadProgress), true)
3503
+ ) || [];
3504
+
3505
+ response = new Response(
3506
+ trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
3507
+ flush && flush();
3508
+ unsubscribe && unsubscribe();
3509
+ }),
3510
+ options
3511
+ );
3512
+ }
3513
+
3514
+ responseType = responseType || 'text';
3515
+
3516
+ let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
3517
+
3518
+ !isStreamResponse && unsubscribe && unsubscribe();
3519
+
3520
+ return await new Promise((resolve, reject) => {
3521
+ settle(resolve, reject, {
3522
+ data: responseData,
3523
+ headers: AxiosHeaders$1.from(response.headers),
3524
+ status: response.status,
3525
+ statusText: response.statusText,
3526
+ config,
3527
+ request
3528
+ });
3529
+ })
3530
+ } catch (err) {
3531
+ unsubscribe && unsubscribe();
3532
+
3533
+ if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
3534
+ throw Object.assign(
3535
+ new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
3536
+ {
3537
+ cause: err.cause || err
3538
+ }
3539
+ )
3540
+ }
3541
+
3542
+ throw AxiosError.from(err, err && err.code, config, request);
3543
+ }
3544
+ }
3545
+ };
3546
+
3547
+ const seedCache = new Map();
3548
+
3549
+ const getFetch = (config) => {
3550
+ let env = config ? config.env : {};
3551
+ const {fetch, Request, Response} = env;
3552
+ const seeds = [
3553
+ Request, Response, fetch
3554
+ ];
3555
+
3556
+ let len = seeds.length, i = len,
3557
+ seed, target, map = seedCache;
3558
+
3559
+ while (i--) {
3560
+ seed = seeds[i];
3561
+ target = map.get(seed);
3562
+
3563
+ target === undefined && map.set(seed, target = (i ? new Map() : factory(env)));
3564
+
3565
+ map = target;
3566
+ }
3567
+
3568
+ return target;
3569
+ };
3570
+
3571
+ getFetch();
3572
+
3573
+ const knownAdapters = {
3574
+ http: httpAdapter,
3575
+ xhr: xhrAdapter,
3576
+ fetch: {
3577
+ get: getFetch,
3578
+ }
3579
+ };
3580
+
3581
+ utils$1.forEach(knownAdapters, (fn, value) => {
3582
+ if (fn) {
3583
+ try {
3584
+ Object.defineProperty(fn, 'name', {value});
3585
+ } catch (e) {
3586
+ // eslint-disable-next-line no-empty
3587
+ }
3588
+ Object.defineProperty(fn, 'adapterName', {value});
3589
+ }
3590
+ });
3591
+
3592
+ const renderReason = (reason) => `- ${reason}`;
3593
+
3594
+ const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
3595
+
3596
+ var adapters = {
3597
+ getAdapter: (adapters, config) => {
3598
+ adapters = utils$1.isArray(adapters) ? adapters : [adapters];
3599
+
3600
+ const {length} = adapters;
3601
+ let nameOrAdapter;
3602
+ let adapter;
3603
+
3604
+ const rejectedReasons = {};
3605
+
3606
+ for (let i = 0; i < length; i++) {
3607
+ nameOrAdapter = adapters[i];
3608
+ let id;
3609
+
3610
+ adapter = nameOrAdapter;
3611
+
3612
+ if (!isResolvedHandle(nameOrAdapter)) {
3613
+ adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
3614
+
3615
+ if (adapter === undefined) {
3616
+ throw new AxiosError(`Unknown adapter '${id}'`);
3617
+ }
3618
+ }
3619
+
3620
+ if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
3621
+ break;
3622
+ }
3623
+
3624
+ rejectedReasons[id || '#' + i] = adapter;
3625
+ }
3626
+
3627
+ if (!adapter) {
3628
+
3629
+ const reasons = Object.entries(rejectedReasons)
3630
+ .map(([id, state]) => `adapter ${id} ` +
3631
+ (state === false ? 'is not supported by the environment' : 'is not available in the build')
3632
+ );
3633
+
3634
+ let s = length ?
3635
+ (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
3636
+ 'as no adapter specified';
3637
+
3638
+ throw new AxiosError(
3639
+ `There is no suitable adapter to dispatch the request ` + s,
3640
+ 'ERR_NOT_SUPPORT'
3641
+ );
3642
+ }
3643
+
3644
+ return adapter;
3645
+ },
3646
+ adapters: knownAdapters
3647
+ };
3648
+
3649
+ /**
3650
+ * Throws a `CanceledError` if cancellation has been requested.
3651
+ *
3652
+ * @param {Object} config The config that is to be used for the request
3653
+ *
3654
+ * @returns {void}
3655
+ */
3656
+ function throwIfCancellationRequested(config) {
3657
+ if (config.cancelToken) {
3658
+ config.cancelToken.throwIfRequested();
3659
+ }
3660
+
3661
+ if (config.signal && config.signal.aborted) {
3662
+ throw new CanceledError(null, config);
3663
+ }
3664
+ }
3665
+
3666
+ /**
3667
+ * Dispatch a request to the server using the configured adapter.
3668
+ *
3669
+ * @param {object} config The config that is to be used for the request
3670
+ *
3671
+ * @returns {Promise} The Promise to be fulfilled
3672
+ */
3673
+ function dispatchRequest(config) {
3674
+ throwIfCancellationRequested(config);
3675
+
3676
+ config.headers = AxiosHeaders$1.from(config.headers);
3677
+
3678
+ // Transform request data
3679
+ config.data = transformData.call(
3680
+ config,
3681
+ config.transformRequest
3682
+ );
3683
+
3684
+ if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
3685
+ config.headers.setContentType('application/x-www-form-urlencoded', false);
3686
+ }
3687
+
3688
+ const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter, config);
3689
+
3690
+ return adapter(config).then(function onAdapterResolution(response) {
3691
+ throwIfCancellationRequested(config);
3692
+
3693
+ // Transform response data
3694
+ response.data = transformData.call(
3695
+ config,
3696
+ config.transformResponse,
3697
+ response
3698
+ );
3699
+
3700
+ response.headers = AxiosHeaders$1.from(response.headers);
3701
+
3702
+ return response;
3703
+ }, function onAdapterRejection(reason) {
3704
+ if (!isCancel(reason)) {
3705
+ throwIfCancellationRequested(config);
3706
+
3707
+ // Transform response data
3708
+ if (reason && reason.response) {
3709
+ reason.response.data = transformData.call(
3710
+ config,
3711
+ config.transformResponse,
3712
+ reason.response
3713
+ );
3714
+ reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
3715
+ }
3716
+ }
3717
+
3718
+ return Promise.reject(reason);
3719
+ });
3720
+ }
3721
+
3722
+ const VERSION = "1.12.2";
3723
+
3724
+ const validators$1 = {};
3725
+
3726
+ // eslint-disable-next-line func-names
3727
+ ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => {
3728
+ validators$1[type] = function validator(thing) {
3729
+ return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
3730
+ };
3731
+ });
3732
+
3733
+ const deprecatedWarnings = {};
3734
+
3735
+ /**
3736
+ * Transitional option validator
3737
+ *
3738
+ * @param {function|boolean?} validator - set to false if the transitional option has been removed
3739
+ * @param {string?} version - deprecated version / removed since version
3740
+ * @param {string?} message - some message with additional info
3741
+ *
3742
+ * @returns {function}
3743
+ */
3744
+ validators$1.transitional = function transitional(validator, version, message) {
3745
+ function formatMessage(opt, desc) {
3746
+ return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
3747
+ }
3748
+
3749
+ // eslint-disable-next-line func-names
3750
+ return (value, opt, opts) => {
3751
+ if (validator === false) {
3752
+ throw new AxiosError(
3753
+ formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
3754
+ AxiosError.ERR_DEPRECATED
3755
+ );
3756
+ }
3757
+
3758
+ if (version && !deprecatedWarnings[opt]) {
3759
+ deprecatedWarnings[opt] = true;
3760
+ // eslint-disable-next-line no-console
3761
+ console.warn(
3762
+ formatMessage(
3763
+ opt,
3764
+ ' has been deprecated since v' + version + ' and will be removed in the near future'
3765
+ )
3766
+ );
3767
+ }
3768
+
3769
+ return validator ? validator(value, opt, opts) : true;
3770
+ };
3771
+ };
3772
+
3773
+ validators$1.spelling = function spelling(correctSpelling) {
3774
+ return (value, opt) => {
3775
+ // eslint-disable-next-line no-console
3776
+ console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
3777
+ return true;
3778
+ }
3779
+ };
3780
+
3781
+ /**
3782
+ * Assert object's properties type
3783
+ *
3784
+ * @param {object} options
3785
+ * @param {object} schema
3786
+ * @param {boolean?} allowUnknown
3787
+ *
3788
+ * @returns {object}
3789
+ */
3790
+
3791
+ function assertOptions(options, schema, allowUnknown) {
3792
+ if (typeof options !== 'object') {
3793
+ throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
3794
+ }
3795
+ const keys = Object.keys(options);
3796
+ let i = keys.length;
3797
+ while (i-- > 0) {
3798
+ const opt = keys[i];
3799
+ const validator = schema[opt];
3800
+ if (validator) {
3801
+ const value = options[opt];
3802
+ const result = value === undefined || validator(value, opt, options);
3803
+ if (result !== true) {
3804
+ throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
3805
+ }
3806
+ continue;
3807
+ }
3808
+ if (allowUnknown !== true) {
3809
+ throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
3810
+ }
3811
+ }
3812
+ }
3813
+
3814
+ var validator = {
3815
+ assertOptions,
3816
+ validators: validators$1
3817
+ };
3818
+
3819
+ const validators = validator.validators;
3820
+
3821
+ /**
3822
+ * Create a new instance of Axios
3823
+ *
3824
+ * @param {Object} instanceConfig The default config for the instance
3825
+ *
3826
+ * @return {Axios} A new instance of Axios
3827
+ */
3828
+ class Axios {
3829
+ constructor(instanceConfig) {
3830
+ this.defaults = instanceConfig || {};
3831
+ this.interceptors = {
3832
+ request: new InterceptorManager$1(),
3833
+ response: new InterceptorManager$1()
3834
+ };
3835
+ }
3836
+
3837
+ /**
3838
+ * Dispatch a request
3839
+ *
3840
+ * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
3841
+ * @param {?Object} config
3842
+ *
3843
+ * @returns {Promise} The Promise to be fulfilled
3844
+ */
3845
+ async request(configOrUrl, config) {
3846
+ try {
3847
+ return await this._request(configOrUrl, config);
3848
+ } catch (err) {
3849
+ if (err instanceof Error) {
3850
+ let dummy = {};
3851
+
3852
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
3853
+
3854
+ // slice off the Error: ... line
3855
+ const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
3856
+ try {
3857
+ if (!err.stack) {
3858
+ err.stack = stack;
3859
+ // match without the 2 top stack lines
3860
+ } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
3861
+ err.stack += '\n' + stack;
3862
+ }
3863
+ } catch (e) {
3864
+ // ignore the case where "stack" is an un-writable property
3865
+ }
3866
+ }
3867
+
3868
+ throw err;
3869
+ }
3870
+ }
3871
+
3872
+ _request(configOrUrl, config) {
3873
+ /*eslint no-param-reassign:0*/
3874
+ // Allow for axios('example/url'[, config]) a la fetch API
3875
+ if (typeof configOrUrl === 'string') {
3876
+ config = config || {};
3877
+ config.url = configOrUrl;
3878
+ } else {
3879
+ config = configOrUrl || {};
3880
+ }
3881
+
3882
+ config = mergeConfig(this.defaults, config);
3883
+
3884
+ const {transitional, paramsSerializer, headers} = config;
3885
+
3886
+ if (transitional !== undefined) {
3887
+ validator.assertOptions(transitional, {
3888
+ silentJSONParsing: validators.transitional(validators.boolean),
3889
+ forcedJSONParsing: validators.transitional(validators.boolean),
3890
+ clarifyTimeoutError: validators.transitional(validators.boolean)
3891
+ }, false);
3892
+ }
3893
+
3894
+ if (paramsSerializer != null) {
3895
+ if (utils$1.isFunction(paramsSerializer)) {
3896
+ config.paramsSerializer = {
3897
+ serialize: paramsSerializer
3898
+ };
3899
+ } else {
3900
+ validator.assertOptions(paramsSerializer, {
3901
+ encode: validators.function,
3902
+ serialize: validators.function
3903
+ }, true);
3904
+ }
3905
+ }
3906
+
3907
+ // Set config.allowAbsoluteUrls
3908
+ if (config.allowAbsoluteUrls !== undefined) ; else if (this.defaults.allowAbsoluteUrls !== undefined) {
3909
+ config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
3910
+ } else {
3911
+ config.allowAbsoluteUrls = true;
3912
+ }
3913
+
3914
+ validator.assertOptions(config, {
3915
+ baseUrl: validators.spelling('baseURL'),
3916
+ withXsrfToken: validators.spelling('withXSRFToken')
3917
+ }, true);
3918
+
3919
+ // Set config.method
3920
+ config.method = (config.method || this.defaults.method || 'get').toLowerCase();
3921
+
3922
+ // Flatten headers
3923
+ let contextHeaders = headers && utils$1.merge(
3924
+ headers.common,
3925
+ headers[config.method]
3926
+ );
3927
+
3928
+ headers && utils$1.forEach(
3929
+ ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
3930
+ (method) => {
3931
+ delete headers[method];
3932
+ }
3933
+ );
3934
+
3935
+ config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
3936
+
3937
+ // filter out skipped interceptors
3938
+ const requestInterceptorChain = [];
3939
+ let synchronousRequestInterceptors = true;
3940
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
3941
+ if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
3942
+ return;
3943
+ }
3944
+
3945
+ synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
3946
+
3947
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
3948
+ });
3949
+
3950
+ const responseInterceptorChain = [];
3951
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
3952
+ responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
3953
+ });
3954
+
3955
+ let promise;
3956
+ let i = 0;
3957
+ let len;
3958
+
3959
+ if (!synchronousRequestInterceptors) {
3960
+ const chain = [dispatchRequest.bind(this), undefined];
3961
+ chain.unshift(...requestInterceptorChain);
3962
+ chain.push(...responseInterceptorChain);
3963
+ len = chain.length;
3964
+
3965
+ promise = Promise.resolve(config);
3966
+
3967
+ while (i < len) {
3968
+ promise = promise.then(chain[i++], chain[i++]);
3969
+ }
3970
+
3971
+ return promise;
3972
+ }
3973
+
3974
+ len = requestInterceptorChain.length;
3975
+
3976
+ let newConfig = config;
3977
+
3978
+ while (i < len) {
3979
+ const onFulfilled = requestInterceptorChain[i++];
3980
+ const onRejected = requestInterceptorChain[i++];
3981
+ try {
3982
+ newConfig = onFulfilled(newConfig);
3983
+ } catch (error) {
3984
+ onRejected.call(this, error);
3985
+ break;
3986
+ }
3987
+ }
3988
+
3989
+ try {
3990
+ promise = dispatchRequest.call(this, newConfig);
3991
+ } catch (error) {
3992
+ return Promise.reject(error);
3993
+ }
3994
+
3995
+ i = 0;
3996
+ len = responseInterceptorChain.length;
3997
+
3998
+ while (i < len) {
3999
+ promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
4000
+ }
4001
+
4002
+ return promise;
4003
+ }
4004
+
4005
+ getUri(config) {
4006
+ config = mergeConfig(this.defaults, config);
4007
+ const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
4008
+ return buildURL(fullPath, config.params, config.paramsSerializer);
4009
+ }
4010
+ }
4011
+
4012
+ // Provide aliases for supported request methods
4013
+ utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
4014
+ /*eslint func-names:0*/
4015
+ Axios.prototype[method] = function(url, config) {
4016
+ return this.request(mergeConfig(config || {}, {
4017
+ method,
4018
+ url,
4019
+ data: (config || {}).data
4020
+ }));
4021
+ };
4022
+ });
4023
+
4024
+ utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
4025
+ /*eslint func-names:0*/
4026
+
4027
+ function generateHTTPMethod(isForm) {
4028
+ return function httpMethod(url, data, config) {
4029
+ return this.request(mergeConfig(config || {}, {
4030
+ method,
4031
+ headers: isForm ? {
4032
+ 'Content-Type': 'multipart/form-data'
4033
+ } : {},
4034
+ url,
4035
+ data
4036
+ }));
4037
+ };
4038
+ }
4039
+
4040
+ Axios.prototype[method] = generateHTTPMethod();
4041
+
4042
+ Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
4043
+ });
4044
+
4045
+ var Axios$1 = Axios;
4046
+
4047
+ /**
4048
+ * A `CancelToken` is an object that can be used to request cancellation of an operation.
4049
+ *
4050
+ * @param {Function} executor The executor function.
4051
+ *
4052
+ * @returns {CancelToken}
4053
+ */
4054
+ class CancelToken {
4055
+ constructor(executor) {
4056
+ if (typeof executor !== 'function') {
4057
+ throw new TypeError('executor must be a function.');
4058
+ }
4059
+
4060
+ let resolvePromise;
4061
+
4062
+ this.promise = new Promise(function promiseExecutor(resolve) {
4063
+ resolvePromise = resolve;
4064
+ });
4065
+
4066
+ const token = this;
4067
+
4068
+ // eslint-disable-next-line func-names
4069
+ this.promise.then(cancel => {
4070
+ if (!token._listeners) return;
4071
+
4072
+ let i = token._listeners.length;
4073
+
4074
+ while (i-- > 0) {
4075
+ token._listeners[i](cancel);
4076
+ }
4077
+ token._listeners = null;
4078
+ });
4079
+
4080
+ // eslint-disable-next-line func-names
4081
+ this.promise.then = onfulfilled => {
4082
+ let _resolve;
4083
+ // eslint-disable-next-line func-names
4084
+ const promise = new Promise(resolve => {
4085
+ token.subscribe(resolve);
4086
+ _resolve = resolve;
4087
+ }).then(onfulfilled);
4088
+
4089
+ promise.cancel = function reject() {
4090
+ token.unsubscribe(_resolve);
4091
+ };
4092
+
4093
+ return promise;
4094
+ };
4095
+
4096
+ executor(function cancel(message, config, request) {
4097
+ if (token.reason) {
4098
+ // Cancellation has already been requested
4099
+ return;
4100
+ }
4101
+
4102
+ token.reason = new CanceledError(message, config, request);
4103
+ resolvePromise(token.reason);
4104
+ });
4105
+ }
4106
+
4107
+ /**
4108
+ * Throws a `CanceledError` if cancellation has been requested.
4109
+ */
4110
+ throwIfRequested() {
4111
+ if (this.reason) {
4112
+ throw this.reason;
4113
+ }
4114
+ }
4115
+
4116
+ /**
4117
+ * Subscribe to the cancel signal
4118
+ */
4119
+
4120
+ subscribe(listener) {
4121
+ if (this.reason) {
4122
+ listener(this.reason);
4123
+ return;
4124
+ }
4125
+
4126
+ if (this._listeners) {
4127
+ this._listeners.push(listener);
4128
+ } else {
4129
+ this._listeners = [listener];
4130
+ }
4131
+ }
4132
+
4133
+ /**
4134
+ * Unsubscribe from the cancel signal
4135
+ */
4136
+
4137
+ unsubscribe(listener) {
4138
+ if (!this._listeners) {
4139
+ return;
4140
+ }
4141
+ const index = this._listeners.indexOf(listener);
4142
+ if (index !== -1) {
4143
+ this._listeners.splice(index, 1);
4144
+ }
4145
+ }
4146
+
4147
+ toAbortSignal() {
4148
+ const controller = new AbortController();
4149
+
4150
+ const abort = (err) => {
4151
+ controller.abort(err);
4152
+ };
4153
+
4154
+ this.subscribe(abort);
4155
+
4156
+ controller.signal.unsubscribe = () => this.unsubscribe(abort);
4157
+
4158
+ return controller.signal;
4159
+ }
4160
+
4161
+ /**
4162
+ * Returns an object that contains a new `CancelToken` and a function that, when called,
4163
+ * cancels the `CancelToken`.
4164
+ */
4165
+ static source() {
4166
+ let cancel;
4167
+ const token = new CancelToken(function executor(c) {
4168
+ cancel = c;
4169
+ });
4170
+ return {
4171
+ token,
4172
+ cancel
4173
+ };
4174
+ }
4175
+ }
4176
+
4177
+ var CancelToken$1 = CancelToken;
4178
+
4179
+ /**
4180
+ * Syntactic sugar for invoking a function and expanding an array for arguments.
4181
+ *
4182
+ * Common use case would be to use `Function.prototype.apply`.
4183
+ *
4184
+ * ```js
4185
+ * function f(x, y, z) {}
4186
+ * var args = [1, 2, 3];
4187
+ * f.apply(null, args);
4188
+ * ```
4189
+ *
4190
+ * With `spread` this example can be re-written.
4191
+ *
4192
+ * ```js
4193
+ * spread(function(x, y, z) {})([1, 2, 3]);
4194
+ * ```
4195
+ *
4196
+ * @param {Function} callback
4197
+ *
4198
+ * @returns {Function}
4199
+ */
4200
+ function spread(callback) {
4201
+ return function wrap(arr) {
4202
+ return callback.apply(null, arr);
4203
+ };
4204
+ }
4205
+
4206
+ /**
4207
+ * Determines whether the payload is an error thrown by Axios
4208
+ *
4209
+ * @param {*} payload The value to test
4210
+ *
4211
+ * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
4212
+ */
4213
+ function isAxiosError(payload) {
4214
+ return utils$1.isObject(payload) && (payload.isAxiosError === true);
4215
+ }
4216
+
4217
+ const HttpStatusCode = {
4218
+ Continue: 100,
4219
+ SwitchingProtocols: 101,
4220
+ Processing: 102,
4221
+ EarlyHints: 103,
4222
+ Ok: 200,
4223
+ Created: 201,
4224
+ Accepted: 202,
4225
+ NonAuthoritativeInformation: 203,
4226
+ NoContent: 204,
4227
+ ResetContent: 205,
4228
+ PartialContent: 206,
4229
+ MultiStatus: 207,
4230
+ AlreadyReported: 208,
4231
+ ImUsed: 226,
4232
+ MultipleChoices: 300,
4233
+ MovedPermanently: 301,
4234
+ Found: 302,
4235
+ SeeOther: 303,
4236
+ NotModified: 304,
4237
+ UseProxy: 305,
4238
+ Unused: 306,
4239
+ TemporaryRedirect: 307,
4240
+ PermanentRedirect: 308,
4241
+ BadRequest: 400,
4242
+ Unauthorized: 401,
4243
+ PaymentRequired: 402,
4244
+ Forbidden: 403,
4245
+ NotFound: 404,
4246
+ MethodNotAllowed: 405,
4247
+ NotAcceptable: 406,
4248
+ ProxyAuthenticationRequired: 407,
4249
+ RequestTimeout: 408,
4250
+ Conflict: 409,
4251
+ Gone: 410,
4252
+ LengthRequired: 411,
4253
+ PreconditionFailed: 412,
4254
+ PayloadTooLarge: 413,
4255
+ UriTooLong: 414,
4256
+ UnsupportedMediaType: 415,
4257
+ RangeNotSatisfiable: 416,
4258
+ ExpectationFailed: 417,
4259
+ ImATeapot: 418,
4260
+ MisdirectedRequest: 421,
4261
+ UnprocessableEntity: 422,
4262
+ Locked: 423,
4263
+ FailedDependency: 424,
4264
+ TooEarly: 425,
4265
+ UpgradeRequired: 426,
4266
+ PreconditionRequired: 428,
4267
+ TooManyRequests: 429,
4268
+ RequestHeaderFieldsTooLarge: 431,
4269
+ UnavailableForLegalReasons: 451,
4270
+ InternalServerError: 500,
4271
+ NotImplemented: 501,
4272
+ BadGateway: 502,
4273
+ ServiceUnavailable: 503,
4274
+ GatewayTimeout: 504,
4275
+ HttpVersionNotSupported: 505,
4276
+ VariantAlsoNegotiates: 506,
4277
+ InsufficientStorage: 507,
4278
+ LoopDetected: 508,
4279
+ NotExtended: 510,
4280
+ NetworkAuthenticationRequired: 511,
4281
+ };
4282
+
4283
+ Object.entries(HttpStatusCode).forEach(([key, value]) => {
4284
+ HttpStatusCode[value] = key;
4285
+ });
4286
+
4287
+ var HttpStatusCode$1 = HttpStatusCode;
4288
+
4289
+ /**
4290
+ * Create an instance of Axios
4291
+ *
4292
+ * @param {Object} defaultConfig The default config for the instance
4293
+ *
4294
+ * @returns {Axios} A new instance of Axios
4295
+ */
4296
+ function createInstance(defaultConfig) {
4297
+ const context = new Axios$1(defaultConfig);
4298
+ const instance = bind(Axios$1.prototype.request, context);
4299
+
4300
+ // Copy axios.prototype to instance
4301
+ utils$1.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
4302
+
4303
+ // Copy context to instance
4304
+ utils$1.extend(instance, context, null, {allOwnKeys: true});
4305
+
4306
+ // Factory for creating new instances
4307
+ instance.create = function create(instanceConfig) {
4308
+ return createInstance(mergeConfig(defaultConfig, instanceConfig));
4309
+ };
4310
+
4311
+ return instance;
4312
+ }
4313
+
4314
+ // Create the default instance to be exported
4315
+ const axios = createInstance(defaults$1);
4316
+
4317
+ // Expose Axios class to allow class inheritance
4318
+ axios.Axios = Axios$1;
4319
+
4320
+ // Expose Cancel & CancelToken
4321
+ axios.CanceledError = CanceledError;
4322
+ axios.CancelToken = CancelToken$1;
4323
+ axios.isCancel = isCancel;
4324
+ axios.VERSION = VERSION;
4325
+ axios.toFormData = toFormData;
4326
+
4327
+ // Expose AxiosError class
4328
+ axios.AxiosError = AxiosError;
4329
+
4330
+ // alias for CanceledError for backward compatibility
4331
+ axios.Cancel = axios.CanceledError;
4332
+
4333
+ // Expose all/spread
4334
+ axios.all = function all(promises) {
4335
+ return Promise.all(promises);
4336
+ };
4337
+
4338
+ axios.spread = spread;
4339
+
4340
+ // Expose isAxiosError
4341
+ axios.isAxiosError = isAxiosError;
4342
+
4343
+ // Expose mergeConfig
4344
+ axios.mergeConfig = mergeConfig;
4345
+
4346
+ axios.AxiosHeaders = AxiosHeaders$1;
4347
+
4348
+ axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
4349
+
4350
+ axios.getAdapter = adapters.getAdapter;
4351
+
4352
+ axios.HttpStatusCode = HttpStatusCode$1;
4353
+
4354
+ axios.default = axios;
4355
+
4356
+ module.exports = axios;
4357
+ //# sourceMappingURL=axios.cjs.map
4358
+
4359
+
4360
+ /***/ }),
4361
+
4362
+ /***/ 740:
4363
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
4364
+
4365
+ "use strict";
4366
+
4367
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4368
+ if (k2 === undefined) k2 = k;
4369
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4370
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
4371
+ desc = { enumerable: true, get: function() { return m[k]; } };
4372
+ }
4373
+ Object.defineProperty(o, k2, desc);
4374
+ }) : (function(o, m, k, k2) {
4375
+ if (k2 === undefined) k2 = k;
4376
+ o[k2] = m[k];
4377
+ }));
4378
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
4379
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
4380
+ }) : function(o, v) {
4381
+ o["default"] = v;
4382
+ });
4383
+ var __importStar = (this && this.__importStar) || (function () {
4384
+ var ownKeys = function(o) {
4385
+ ownKeys = Object.getOwnPropertyNames || function (o) {
4386
+ var ar = [];
4387
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
4388
+ return ar;
4389
+ };
4390
+ return ownKeys(o);
4391
+ };
4392
+ return function (mod) {
4393
+ if (mod && mod.__esModule) return mod;
4394
+ var result = {};
4395
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
4396
+ __setModuleDefault(result, mod);
4397
+ return result;
4398
+ };
4399
+ })();
4400
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4401
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4402
+ return new (P || (P = Promise))(function (resolve, reject) {
4403
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
4404
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
4405
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
4406
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
4407
+ });
4408
+ };
4409
+ var __generator = (this && this.__generator) || function (thisArg, body) {
4410
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
4411
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
4412
+ function verb(n) { return function (v) { return step([n, v]); }; }
4413
+ function step(op) {
4414
+ if (f) throw new TypeError("Generator is already executing.");
4415
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
4416
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
4417
+ if (y = 0, t) op = [op[0] & 2, t.value];
4418
+ switch (op[0]) {
4419
+ case 0: case 1: t = op; break;
4420
+ case 4: _.label++; return { value: op[1], done: false };
4421
+ case 5: _.label++; y = op[1]; op = [0]; continue;
4422
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
4423
+ default:
4424
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
4425
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
4426
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
4427
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
4428
+ if (t[2]) _.ops.pop();
4429
+ _.trys.pop(); continue;
4430
+ }
4431
+ op = body.call(thisArg, _);
4432
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
4433
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
4434
+ }
4435
+ };
4436
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4437
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4438
+ };
4439
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
4440
+ exports.postAction = exports.getAction = void 0;
4441
+ var axios_1 = __importDefault(__webpack_require__(637));
4442
+ var cnki_x_jwt_1 = __webpack_require__(537);
4443
+ var refreshToken_1 = __importDefault(__webpack_require__(478));
4444
+ var proxy_1 = __webpack_require__(887);
4445
+ var store_1 = __importStar(__webpack_require__(489));
4446
+ var service = axios_1.default.create({
4447
+ timeout: 5000,
4448
+ withCredentials: false
4449
+ });
4450
+ service.interceptors.request.use(function (config) {
4451
+ var jwt = (0, cnki_x_jwt_1.getJwt)((0, store_1.getJwtKey)());
4452
+ if (jwt && config.headers) {
4453
+ config.headers.Authorization = "Bearer ".concat(jwt);
4454
+ }
4455
+ return config;
4456
+ }, function (error) {
4457
+ console.error('请求错误:', error);
4458
+ return Promise.reject(error);
4459
+ });
4460
+ service.interceptors.response.use(function (response) { return __awaiter(void 0, void 0, void 0, function () {
4461
+ var handler, result, code;
4462
+ var _a, _b, _c;
4463
+ return __generator(this, function (_d) {
4464
+ switch (_d.label) {
4465
+ case 0:
4466
+ handler = (_a = store_1.default.getOptions()) === null || _a === void 0 ? void 0 : _a.response;
4467
+ if (!(typeof handler === 'function')) return [3 /*break*/, 2];
4468
+ return [4 /*yield*/, handler(response)];
4469
+ case 1:
4470
+ result = _d.sent();
4471
+ if (result !== undefined) {
4472
+ return [2 /*return*/, result];
4473
+ }
4474
+ _d.label = 2;
4475
+ case 2:
4476
+ code = ((_b = response.data) === null || _b === void 0 ? void 0 : _b.code) || ((_c = response.data) === null || _c === void 0 ? void 0 : _c.Code) || 200;
4477
+ // 5014: 登录失效 → 登出
4478
+ if ([5014].includes(code)) {
4479
+ return [2 /*return*/, Promise.resolve(response)];
4480
+ }
4481
+ if (![5013].includes(code)) return [3 /*break*/, 4];
4482
+ return [4 /*yield*/, (0, refreshToken_1.default)(service, response)];
4483
+ case 3:
4484
+ _d.sent();
4485
+ _d.label = 4;
4486
+ case 4: return [2 /*return*/, Promise.resolve(response)];
4487
+ }
4488
+ });
4489
+ }); }, function (error) {
4490
+ var _a;
4491
+ if ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('timeout')) {
4492
+ console.error('请求超时,请检查网络连接');
4493
+ }
4494
+ return Promise.reject(error);
4495
+ });
4496
+ var fetch = function (method, url, data, config) {
4497
+ if (data === void 0) { data = {}; }
4498
+ var cfg = config || {};
4499
+ cfg.method = method;
4500
+ cfg.url = (0, proxy_1.getBaseUrl)(url);
4501
+ switch (method.toLowerCase()) {
4502
+ case 'get':
4503
+ cfg.params = data;
4504
+ break;
4505
+ default:
4506
+ cfg.data = data;
4507
+ }
4508
+ return service(cfg).then(function (res) { return res.data; });
4509
+ };
4510
+ var getAction = function (url, data, config) {
4511
+ return fetch('get', url, data, config);
4512
+ };
4513
+ exports.getAction = getAction;
4514
+ var postAction = function (url, data, config) {
4515
+ return fetch('post', url, data, config);
4516
+ };
4517
+ exports.postAction = postAction;
4518
+
4519
+
4520
+ /***/ }),
4521
+
4522
+ /***/ 747:
4523
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
4524
+
4525
+ "use strict";
4526
+
4527
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4528
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4529
+ };
4530
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
4531
+ exports.getEnv = void 0;
4532
+ var store_1 = __importDefault(__webpack_require__(489));
4533
+ var getEnv = function () { return store_1.default.getOptions().env; };
4534
+ exports.getEnv = getEnv;
4535
+
4536
+
4537
+ /***/ }),
4538
+
4539
+ /***/ 767:
4540
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
4541
+
4542
+ "use strict";
4543
+
4544
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4545
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4546
+ return new (P || (P = Promise))(function (resolve, reject) {
4547
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
4548
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
4549
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
4550
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
4551
+ });
4552
+ };
4553
+ var __generator = (this && this.__generator) || function (thisArg, body) {
4554
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
4555
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
4556
+ function verb(n) { return function (v) { return step([n, v]); }; }
4557
+ function step(op) {
4558
+ if (f) throw new TypeError("Generator is already executing.");
4559
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
4560
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
4561
+ if (y = 0, t) op = [op[0] & 2, t.value];
4562
+ switch (op[0]) {
4563
+ case 0: case 1: t = op; break;
4564
+ case 4: _.label++; return { value: op[1], done: false };
4565
+ case 5: _.label++; y = op[1]; op = [0]; continue;
4566
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
4567
+ default:
4568
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
4569
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
4570
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
4571
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
4572
+ if (t[2]) _.ops.pop();
4573
+ _.trys.pop(); continue;
4574
+ }
4575
+ op = body.call(thisArg, _);
4576
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
4577
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
4578
+ }
4579
+ };
4580
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
4581
+ exports.getUserIp = void 0;
4582
+ var cookie_1 = __webpack_require__(384);
4583
+ var env_1 = __webpack_require__(747);
4584
+ var api = {
4585
+ getUserIp: {
4586
+ test: 'https://xtest.cnki.net/ip/client',
4587
+ development: '/proxy-sdk-ip/client',
4588
+ production: 'https://x.cnki.net/ip/client'
4589
+ }
4590
+ };
4591
+ var getUserIp = function () { return __awaiter(void 0, void 0, void 0, function () {
4592
+ var cache, frs, content, e_1;
4593
+ return __generator(this, function (_a) {
4594
+ switch (_a.label) {
4595
+ case 0:
4596
+ _a.trys.push([0, 4, , 5]);
4597
+ cache = (0, cookie_1.getCookie)('yxIP');
4598
+ if (!((cache !== null && cache !== void 0 ? cache : '') === '')) return [3 /*break*/, 3];
4599
+ return [4 /*yield*/, fetch(api.getUserIp[(0, env_1.getEnv)()], {
4600
+ method: 'GET'
4601
+ })];
4602
+ case 1:
4603
+ frs = _a.sent();
4604
+ return [4 /*yield*/, frs.json()];
4605
+ case 2:
4606
+ content = (_a.sent()).content;
4607
+ (0, cookie_1.setCookie)('yxIP', content);
4608
+ return [2 /*return*/, Promise.resolve(content)];
4609
+ case 3: return [2 /*return*/, Promise.resolve(cache)];
4610
+ case 4:
4611
+ e_1 = _a.sent();
4612
+ return [2 /*return*/, Promise.resolve('')];
4613
+ case 5: return [2 /*return*/];
4614
+ }
4615
+ });
4616
+ }); };
4617
+ exports.getUserIp = getUserIp;
4618
+
4619
+
4620
+ /***/ }),
4621
+
4622
+ /***/ 792:
4623
+ /***/ ((__unused_webpack_module, exports) => {
4624
+
4625
+ "use strict";
4626
+
4627
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
4628
+ var proxy = {
4629
+ '/proxy-sdk-jwt': {
4630
+ open: false,
4631
+ ws: false,
4632
+ target: 'https://gateway.cnki.net/aamsapi/api',
4633
+ changeOrigin: true, //
4634
+ pathRewrite: { '^/proxy-sdk-jwt': '/' }
4635
+ },
4636
+ '/proxy-sdk-ip': {
4637
+ open: false,
4638
+ ws: false,
4639
+ target: 'https://x.cnki.net/ip',
4640
+ changeOrigin: true,
4641
+ pathRewrite: { '^/proxy-sdk-ip': '/' },
4642
+ headers: {
4643
+ origin: 'https://x.cnki.net',
4644
+ referer: 'https://x.cnki.net'
4645
+ }
4646
+ }
4647
+ };
4648
+ exports["default"] = proxy;
4649
+
4650
+
4651
+ /***/ }),
4652
+
4653
+ /***/ 811:
4654
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
4655
+
4656
+ "use strict";
4657
+
4658
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4659
+ if (k2 === undefined) k2 = k;
4660
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4661
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
4662
+ desc = { enumerable: true, get: function() { return m[k]; } };
4663
+ }
4664
+ Object.defineProperty(o, k2, desc);
4665
+ }) : (function(o, m, k, k2) {
4666
+ if (k2 === undefined) k2 = k;
4667
+ o[k2] = m[k];
4668
+ }));
4669
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
4670
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
4671
+ }) : function(o, v) {
4672
+ o["default"] = v;
4673
+ });
4674
+ var __importStar = (this && this.__importStar) || (function () {
4675
+ var ownKeys = function(o) {
4676
+ ownKeys = Object.getOwnPropertyNames || function (o) {
4677
+ var ar = [];
4678
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
4679
+ return ar;
4680
+ };
4681
+ return ownKeys(o);
4682
+ };
4683
+ return function (mod) {
4684
+ if (mod && mod.__esModule) return mod;
4685
+ var result = {};
4686
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
4687
+ __setModuleDefault(result, mod);
4688
+ return result;
4689
+ };
4690
+ })();
4691
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4692
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4693
+ return new (P || (P = Promise))(function (resolve, reject) {
4694
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
4695
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
4696
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
4697
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
4698
+ });
4699
+ };
4700
+ var __generator = (this && this.__generator) || function (thisArg, body) {
4701
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
4702
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
4703
+ function verb(n) { return function (v) { return step([n, v]); }; }
4704
+ function step(op) {
4705
+ if (f) throw new TypeError("Generator is already executing.");
4706
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
4707
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
4708
+ if (y = 0, t) op = [op[0] & 2, t.value];
4709
+ switch (op[0]) {
4710
+ case 0: case 1: t = op; break;
4711
+ case 4: _.label++; return { value: op[1], done: false };
4712
+ case 5: _.label++; y = op[1]; op = [0]; continue;
4713
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
4714
+ default:
4715
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
4716
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
4717
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
4718
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
4719
+ if (t[2]) _.ops.pop();
4720
+ _.trys.pop(); continue;
4721
+ }
4722
+ op = body.call(thisArg, _);
4723
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
4724
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
4725
+ }
4726
+ };
4727
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
4728
+ exports.removeCookie = exports.setCookie = exports.getCookie = void 0;
4729
+ var store_1 = __importStar(__webpack_require__(489));
4730
+ var index_1 = __webpack_require__(740);
4731
+ var refreshToken_1 = __webpack_require__(478);
4732
+ var cnki_x_jwt_1 = __webpack_require__(537);
4733
+ var cookie_1 = __webpack_require__(384);
4734
+ Object.defineProperty(exports, "getCookie", ({ enumerable: true, get: function () { return cookie_1.getCookie; } }));
4735
+ Object.defineProperty(exports, "setCookie", ({ enumerable: true, get: function () { return cookie_1.setCookie; } }));
4736
+ Object.defineProperty(exports, "removeCookie", ({ enumerable: true, get: function () { return cookie_1.removeCookie; } }));
4737
+ var App = /** @class */ (function () {
4738
+ function App() {
4739
+ this.getAction = index_1.getAction;
4740
+ this.postAction = index_1.postAction;
4741
+ this.getJwt = function () { return (0, cnki_x_jwt_1.getJwt)((0, store_1.getJwtKey)()); };
4742
+ this.removeJwt = function () { return (0, cnki_x_jwt_1.removeJwt)((0, store_1.getJwtKey)()); };
4743
+ }
4744
+ App.getInstance = function () {
4745
+ if (!this.instance)
4746
+ this.instance = new App();
4747
+ return this.instance;
4748
+ };
4749
+ App.prototype.config = function (options) {
4750
+ store_1.default.config(options);
4751
+ return this;
4752
+ };
4753
+ App.prototype.ready = function () {
4754
+ return __awaiter(this, void 0, void 0, function () {
4755
+ return __generator(this, function (_a) {
4756
+ switch (_a.label) {
4757
+ case 0: return [4 /*yield*/, (0, refreshToken_1.getRefreshToken)()];
4758
+ case 1: return [2 /*return*/, _a.sent()];
4759
+ }
4760
+ });
4761
+ });
4762
+ };
4763
+ App.instance = null;
4764
+ return App;
4765
+ }());
4766
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
4767
+ // @ts-ignore
4768
+ exports["default"] = App.getInstance();
4769
+
4770
+
4771
+ /***/ }),
4772
+
4773
+ /***/ 887:
4774
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
4775
+
4776
+ "use strict";
4777
+
4778
+ var __assign = (this && this.__assign) || function () {
4779
+ __assign = Object.assign || function(t) {
4780
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4781
+ s = arguments[i];
4782
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
4783
+ t[p] = s[p];
4784
+ }
4785
+ return t;
4786
+ };
4787
+ return __assign.apply(this, arguments);
4788
+ };
4789
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4790
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4791
+ };
4792
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
4793
+ exports.getBaseUrl = void 0;
4794
+ var test_1 = __importDefault(__webpack_require__(931));
4795
+ var test_2 = __importDefault(__webpack_require__(931));
4796
+ var production_1 = __importDefault(__webpack_require__(792));
4797
+ var store_1 = __importDefault(__webpack_require__(489));
4798
+ var env_1 = __webpack_require__(747);
4799
+ var proxyMap = {
4800
+ development: test_1.default,
4801
+ test: test_2.default,
4802
+ production: production_1.default
4803
+ };
4804
+ var getBaseUrl = function (url) {
4805
+ var _store = store_1.default.getOptions();
4806
+ var env = (0, env_1.getEnv)();
4807
+ var proxy = _store.proxy ? __assign(__assign({}, _store.proxy), proxyMap[env]) : env === 'development' ? test_2.default : proxyMap[env];
4808
+ var finalUrl = url;
4809
+ if (env !== 'development') {
4810
+ Object.keys(proxy).forEach(function (key) {
4811
+ if (url.includes(key)) {
4812
+ finalUrl = finalUrl.replace(key, proxy[key].target);
4813
+ }
4814
+ });
4815
+ }
4816
+ return finalUrl;
4817
+ };
4818
+ exports.getBaseUrl = getBaseUrl;
4819
+
4820
+
4821
+ /***/ }),
4822
+
4823
+ /***/ 931:
4824
+ /***/ ((__unused_webpack_module, exports) => {
4825
+
4826
+ "use strict";
4827
+
4828
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
4829
+ var proxy = {
4830
+ '/proxy-sdk-jwt': {
4831
+ open: false,
4832
+ ws: false,
4833
+ target: 'https://xtest.cnki.net/api/api',
4834
+ changeOrigin: true,
4835
+ pathRewrite: { '^/proxy-sdk-jwt': '/' },
4836
+ headers: {
4837
+ origin: 'https://x.cnki.net',
4838
+ referer: 'https://x.cnki.net'
4839
+ }
4840
+ },
4841
+ '/proxy-sdk-ip': {
4842
+ open: false,
4843
+ ws: false,
4844
+ target: 'https://xtest.cnki.net/ip',
4845
+ changeOrigin: true,
4846
+ pathRewrite: { '^/proxy-sdk-ip': '/' },
4847
+ headers: {
4848
+ origin: 'https://x.cnki.net',
4849
+ referer: 'https://x.cnki.net'
4850
+ }
4851
+ }
4852
+ };
4853
+ exports["default"] = proxy;
4854
+
4855
+
4856
+ /***/ })
4857
+
4858
+ /******/ });
4859
+ /************************************************************************/
4860
+ /******/ // The module cache
4861
+ /******/ var __webpack_module_cache__ = {};
4862
+ /******/
4863
+ /******/ // The require function
4864
+ /******/ function __webpack_require__(moduleId) {
4865
+ /******/ // Check if module is in cache
4866
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
4867
+ /******/ if (cachedModule !== undefined) {
4868
+ /******/ return cachedModule.exports;
4869
+ /******/ }
4870
+ /******/ // Create a new module (and put it into the cache)
4871
+ /******/ var module = __webpack_module_cache__[moduleId] = {
4872
+ /******/ // no module.id needed
4873
+ /******/ // no module.loaded needed
4874
+ /******/ exports: {}
4875
+ /******/ };
4876
+ /******/
4877
+ /******/ // Execute the module function
4878
+ /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
4879
+ /******/
4880
+ /******/ // Return the exports of the module
4881
+ /******/ return module.exports;
4882
+ /******/ }
4883
+ /******/
4884
+ /************************************************************************/
4885
+ /******/ /* webpack/runtime/global */
4886
+ /******/ (() => {
4887
+ /******/ __webpack_require__.g = (function() {
4888
+ /******/ if (typeof globalThis === 'object') return globalThis;
4889
+ /******/ try {
4890
+ /******/ return this || new Function('return this')();
4891
+ /******/ } catch (e) {
4892
+ /******/ if (typeof window === 'object') return window;
4893
+ /******/ }
4894
+ /******/ })();
4895
+ /******/ })();
4896
+ /******/
4897
+ /************************************************************************/
4898
+ /******/
4899
+ /******/ // startup
4900
+ /******/ // Load entry module and return exports
4901
+ /******/ // This entry module is referenced by other modules so it can't be inlined
4902
+ /******/ var __webpack_exports__ = __webpack_require__(811);
4903
+ /******/
4904
+ /******/ return __webpack_exports__;
4905
+ /******/ })()
4906
+ ;
4907
+ });