@lcap/axios-fixed 1.13.2

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