@lx-frontend/multi-ajax 0.2.4 → 0.2.5

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.
@@ -0,0 +1,2966 @@
1
+ // Axios v1.3.4 Copyright (c) 2023 Matt Zabriskie and contributors
2
+ (function (global, factory) {
3
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
+ typeof define === 'function' && define.amd ? define(factory) :
5
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.axios = factory());
6
+ })(this, (function () { 'use strict';
7
+
8
+ function _typeof(obj) {
9
+ "@babel/helpers - typeof";
10
+
11
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
12
+ return typeof obj;
13
+ } : function (obj) {
14
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
15
+ }, _typeof(obj);
16
+ }
17
+ function _classCallCheck(instance, Constructor) {
18
+ if (!(instance instanceof Constructor)) {
19
+ throw new TypeError("Cannot call a class as a function");
20
+ }
21
+ }
22
+ function _defineProperties(target, props) {
23
+ for (var i = 0; i < props.length; i++) {
24
+ var descriptor = props[i];
25
+ descriptor.enumerable = descriptor.enumerable || false;
26
+ descriptor.configurable = true;
27
+ if ("value" in descriptor) descriptor.writable = true;
28
+ Object.defineProperty(target, descriptor.key, descriptor);
29
+ }
30
+ }
31
+ function _createClass(Constructor, protoProps, staticProps) {
32
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
33
+ if (staticProps) _defineProperties(Constructor, staticProps);
34
+ Object.defineProperty(Constructor, "prototype", {
35
+ writable: false
36
+ });
37
+ return Constructor;
38
+ }
39
+ function _slicedToArray(arr, i) {
40
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
41
+ }
42
+ function _arrayWithHoles(arr) {
43
+ if (Array.isArray(arr)) return arr;
44
+ }
45
+ function _iterableToArrayLimit(arr, i) {
46
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
47
+ if (_i == null) return;
48
+ var _arr = [];
49
+ var _n = true;
50
+ var _d = false;
51
+ var _s, _e;
52
+ try {
53
+ for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
54
+ _arr.push(_s.value);
55
+ if (i && _arr.length === i) break;
56
+ }
57
+ } catch (err) {
58
+ _d = true;
59
+ _e = err;
60
+ } finally {
61
+ try {
62
+ if (!_n && _i["return"] != null) _i["return"]();
63
+ } finally {
64
+ if (_d) throw _e;
65
+ }
66
+ }
67
+ return _arr;
68
+ }
69
+ function _unsupportedIterableToArray(o, minLen) {
70
+ if (!o) return;
71
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
72
+ var n = Object.prototype.toString.call(o).slice(8, -1);
73
+ if (n === "Object" && o.constructor) n = o.constructor.name;
74
+ if (n === "Map" || n === "Set") return Array.from(o);
75
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
76
+ }
77
+ function _arrayLikeToArray(arr, len) {
78
+ if (len == null || len > arr.length) len = arr.length;
79
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
80
+ return arr2;
81
+ }
82
+ function _nonIterableRest() {
83
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
84
+ }
85
+
86
+ function bind(fn, thisArg) {
87
+ return function wrap() {
88
+ return fn.apply(thisArg, arguments);
89
+ };
90
+ }
91
+
92
+ // utils is a library of generic helper functions non-specific to axios
93
+
94
+ var toString = Object.prototype.toString;
95
+ var getPrototypeOf = Object.getPrototypeOf;
96
+ var kindOf = function (cache) {
97
+ return function (thing) {
98
+ var str = toString.call(thing);
99
+ return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
100
+ };
101
+ }(Object.create(null));
102
+ var kindOfTest = function kindOfTest(type) {
103
+ type = type.toLowerCase();
104
+ return function (thing) {
105
+ return kindOf(thing) === type;
106
+ };
107
+ };
108
+ var typeOfTest = function typeOfTest(type) {
109
+ return function (thing) {
110
+ return _typeof(thing) === type;
111
+ };
112
+ };
113
+
114
+ /**
115
+ * Determine if a value is an Array
116
+ *
117
+ * @param {Object} val The value to test
118
+ *
119
+ * @returns {boolean} True if value is an Array, otherwise false
120
+ */
121
+ var isArray = Array.isArray;
122
+
123
+ /**
124
+ * Determine if a value is undefined
125
+ *
126
+ * @param {*} val The value to test
127
+ *
128
+ * @returns {boolean} True if the value is undefined, otherwise false
129
+ */
130
+ var isUndefined = typeOfTest('undefined');
131
+
132
+ /**
133
+ * Determine if a value is a Buffer
134
+ *
135
+ * @param {*} val The value to test
136
+ *
137
+ * @returns {boolean} True if value is a Buffer, otherwise false
138
+ */
139
+ function isBuffer(val) {
140
+ return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
141
+ }
142
+
143
+ /**
144
+ * Determine if a value is an ArrayBuffer
145
+ *
146
+ * @param {*} val The value to test
147
+ *
148
+ * @returns {boolean} True if value is an ArrayBuffer, otherwise false
149
+ */
150
+ var isArrayBuffer = kindOfTest('ArrayBuffer');
151
+
152
+ /**
153
+ * Determine if a value is a view on an ArrayBuffer
154
+ *
155
+ * @param {*} val The value to test
156
+ *
157
+ * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
158
+ */
159
+ function isArrayBufferView(val) {
160
+ var result;
161
+ if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
162
+ result = ArrayBuffer.isView(val);
163
+ } else {
164
+ result = val && val.buffer && isArrayBuffer(val.buffer);
165
+ }
166
+ return result;
167
+ }
168
+
169
+ /**
170
+ * Determine if a value is a String
171
+ *
172
+ * @param {*} val The value to test
173
+ *
174
+ * @returns {boolean} True if value is a String, otherwise false
175
+ */
176
+ var isString = typeOfTest('string');
177
+
178
+ /**
179
+ * Determine if a value is a Function
180
+ *
181
+ * @param {*} val The value to test
182
+ * @returns {boolean} True if value is a Function, otherwise false
183
+ */
184
+ var isFunction = typeOfTest('function');
185
+
186
+ /**
187
+ * Determine if a value is a Number
188
+ *
189
+ * @param {*} val The value to test
190
+ *
191
+ * @returns {boolean} True if value is a Number, otherwise false
192
+ */
193
+ var isNumber = typeOfTest('number');
194
+
195
+ /**
196
+ * Determine if a value is an Object
197
+ *
198
+ * @param {*} thing The value to test
199
+ *
200
+ * @returns {boolean} True if value is an Object, otherwise false
201
+ */
202
+ var isObject = function isObject(thing) {
203
+ return thing !== null && _typeof(thing) === 'object';
204
+ };
205
+
206
+ /**
207
+ * Determine if a value is a Boolean
208
+ *
209
+ * @param {*} thing The value to test
210
+ * @returns {boolean} True if value is a Boolean, otherwise false
211
+ */
212
+ var isBoolean = function isBoolean(thing) {
213
+ return thing === true || thing === false;
214
+ };
215
+
216
+ /**
217
+ * Determine if a value is a plain Object
218
+ *
219
+ * @param {*} val The value to test
220
+ *
221
+ * @returns {boolean} True if value is a plain Object, otherwise false
222
+ */
223
+ var isPlainObject = function isPlainObject(val) {
224
+ if (kindOf(val) !== 'object') {
225
+ return false;
226
+ }
227
+ var prototype = getPrototypeOf(val);
228
+ return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
229
+ };
230
+
231
+ /**
232
+ * Determine if a value is a Date
233
+ *
234
+ * @param {*} val The value to test
235
+ *
236
+ * @returns {boolean} True if value is a Date, otherwise false
237
+ */
238
+ var isDate = kindOfTest('Date');
239
+
240
+ /**
241
+ * Determine if a value is a File
242
+ *
243
+ * @param {*} val The value to test
244
+ *
245
+ * @returns {boolean} True if value is a File, otherwise false
246
+ */
247
+ var isFile = kindOfTest('File');
248
+
249
+ /**
250
+ * Determine if a value is a Blob
251
+ *
252
+ * @param {*} val The value to test
253
+ *
254
+ * @returns {boolean} True if value is a Blob, otherwise false
255
+ */
256
+ var isBlob = kindOfTest('Blob');
257
+
258
+ /**
259
+ * Determine if a value is a FileList
260
+ *
261
+ * @param {*} val The value to test
262
+ *
263
+ * @returns {boolean} True if value is a File, otherwise false
264
+ */
265
+ var isFileList = kindOfTest('FileList');
266
+
267
+ /**
268
+ * Determine if a value is a Stream
269
+ *
270
+ * @param {*} val The value to test
271
+ *
272
+ * @returns {boolean} True if value is a Stream, otherwise false
273
+ */
274
+ var isStream = function isStream(val) {
275
+ return isObject(val) && isFunction(val.pipe);
276
+ };
277
+
278
+ /**
279
+ * Determine if a value is a FormData
280
+ *
281
+ * @param {*} thing The value to test
282
+ *
283
+ * @returns {boolean} True if value is an FormData, otherwise false
284
+ */
285
+ var isFormData = function isFormData(thing) {
286
+ var pattern = '[object FormData]';
287
+ return thing && (typeof FormData === 'function' && thing instanceof FormData || toString.call(thing) === pattern || isFunction(thing.toString) && thing.toString() === pattern);
288
+ };
289
+
290
+ /**
291
+ * Determine if a value is a URLSearchParams object
292
+ *
293
+ * @param {*} val The value to test
294
+ *
295
+ * @returns {boolean} True if value is a URLSearchParams object, otherwise false
296
+ */
297
+ var isURLSearchParams = kindOfTest('URLSearchParams');
298
+
299
+ /**
300
+ * Trim excess whitespace off the beginning and end of a string
301
+ *
302
+ * @param {String} str The String to trim
303
+ *
304
+ * @returns {String} The String freed of excess whitespace
305
+ */
306
+ var trim = function trim(str) {
307
+ return str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
308
+ };
309
+
310
+ /**
311
+ * Iterate over an Array or an Object invoking a function for each item.
312
+ *
313
+ * If `obj` is an Array callback will be called passing
314
+ * the value, index, and complete array for each item.
315
+ *
316
+ * If 'obj' is an Object callback will be called passing
317
+ * the value, key, and complete object for each property.
318
+ *
319
+ * @param {Object|Array} obj The object to iterate
320
+ * @param {Function} fn The callback to invoke for each item
321
+ *
322
+ * @param {Boolean} [allOwnKeys = false]
323
+ * @returns {any}
324
+ */
325
+ function forEach(obj, fn) {
326
+ var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
327
+ _ref$allOwnKeys = _ref.allOwnKeys,
328
+ allOwnKeys = _ref$allOwnKeys === void 0 ? false : _ref$allOwnKeys;
329
+ // Don't bother if no value provided
330
+ if (obj === null || typeof obj === 'undefined') {
331
+ return;
332
+ }
333
+ var i;
334
+ var l;
335
+
336
+ // Force an array if not already something iterable
337
+ if (_typeof(obj) !== 'object') {
338
+ /*eslint no-param-reassign:0*/
339
+ obj = [obj];
340
+ }
341
+ if (isArray(obj)) {
342
+ // Iterate over array values
343
+ for (i = 0, l = obj.length; i < l; i++) {
344
+ fn.call(null, obj[i], i, obj);
345
+ }
346
+ } else {
347
+ // Iterate over object keys
348
+ var keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
349
+ var len = keys.length;
350
+ var key;
351
+ for (i = 0; i < len; i++) {
352
+ key = keys[i];
353
+ fn.call(null, obj[key], key, obj);
354
+ }
355
+ }
356
+ }
357
+ function findKey(obj, key) {
358
+ key = key.toLowerCase();
359
+ var keys = Object.keys(obj);
360
+ var i = keys.length;
361
+ var _key;
362
+ while (i-- > 0) {
363
+ _key = keys[i];
364
+ if (key === _key.toLowerCase()) {
365
+ return _key;
366
+ }
367
+ }
368
+ return null;
369
+ }
370
+ var _global = function () {
371
+ /*eslint no-undef:0*/
372
+ if (typeof globalThis !== "undefined") return globalThis;
373
+ return typeof self !== "undefined" ? self : typeof window !== 'undefined' ? window : global;
374
+ }();
375
+ var isContextDefined = function isContextDefined(context) {
376
+ return !isUndefined(context) && context !== _global;
377
+ };
378
+
379
+ /**
380
+ * Accepts varargs expecting each argument to be an object, then
381
+ * immutably merges the properties of each object and returns result.
382
+ *
383
+ * When multiple objects contain the same key the later object in
384
+ * the arguments list will take precedence.
385
+ *
386
+ * Example:
387
+ *
388
+ * ```js
389
+ * var result = merge({foo: 123}, {foo: 456});
390
+ * console.log(result.foo); // outputs 456
391
+ * ```
392
+ *
393
+ * @param {Object} obj1 Object to merge
394
+ *
395
+ * @returns {Object} Result of all merge properties
396
+ */
397
+ function /* obj1, obj2, obj3, ... */
398
+ merge() {
399
+ var _ref2 = isContextDefined(this) && this || {},
400
+ caseless = _ref2.caseless;
401
+ var result = {};
402
+ var assignValue = function assignValue(val, key) {
403
+ var targetKey = caseless && findKey(result, key) || key;
404
+ if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
405
+ result[targetKey] = merge(result[targetKey], val);
406
+ } else if (isPlainObject(val)) {
407
+ result[targetKey] = merge({}, val);
408
+ } else if (isArray(val)) {
409
+ result[targetKey] = val.slice();
410
+ } else {
411
+ result[targetKey] = val;
412
+ }
413
+ };
414
+ for (var i = 0, l = arguments.length; i < l; i++) {
415
+ arguments[i] && forEach(arguments[i], assignValue);
416
+ }
417
+ return result;
418
+ }
419
+
420
+ /**
421
+ * Extends object a by mutably adding to it the properties of object b.
422
+ *
423
+ * @param {Object} a The object to be extended
424
+ * @param {Object} b The object to copy properties from
425
+ * @param {Object} thisArg The object to bind function to
426
+ *
427
+ * @param {Boolean} [allOwnKeys]
428
+ * @returns {Object} The resulting value of object a
429
+ */
430
+ var extend = function extend(a, b, thisArg) {
431
+ var _ref3 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
432
+ allOwnKeys = _ref3.allOwnKeys;
433
+ forEach(b, function (val, key) {
434
+ if (thisArg && isFunction(val)) {
435
+ a[key] = bind(val, thisArg);
436
+ } else {
437
+ a[key] = val;
438
+ }
439
+ }, {
440
+ allOwnKeys: allOwnKeys
441
+ });
442
+ return a;
443
+ };
444
+
445
+ /**
446
+ * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
447
+ *
448
+ * @param {string} content with BOM
449
+ *
450
+ * @returns {string} content value without BOM
451
+ */
452
+ var stripBOM = function stripBOM(content) {
453
+ if (content.charCodeAt(0) === 0xFEFF) {
454
+ content = content.slice(1);
455
+ }
456
+ return content;
457
+ };
458
+
459
+ /**
460
+ * Inherit the prototype methods from one constructor into another
461
+ * @param {function} constructor
462
+ * @param {function} superConstructor
463
+ * @param {object} [props]
464
+ * @param {object} [descriptors]
465
+ *
466
+ * @returns {void}
467
+ */
468
+ var inherits = function inherits(constructor, superConstructor, props, descriptors) {
469
+ constructor.prototype = Object.create(superConstructor.prototype, descriptors);
470
+ constructor.prototype.constructor = constructor;
471
+ Object.defineProperty(constructor, 'super', {
472
+ value: superConstructor.prototype
473
+ });
474
+ props && Object.assign(constructor.prototype, props);
475
+ };
476
+
477
+ /**
478
+ * Resolve object with deep prototype chain to a flat object
479
+ * @param {Object} sourceObj source object
480
+ * @param {Object} [destObj]
481
+ * @param {Function|Boolean} [filter]
482
+ * @param {Function} [propFilter]
483
+ *
484
+ * @returns {Object}
485
+ */
486
+ var toFlatObject = function toFlatObject(sourceObj, destObj, filter, propFilter) {
487
+ var props;
488
+ var i;
489
+ var prop;
490
+ var merged = {};
491
+ destObj = destObj || {};
492
+ // eslint-disable-next-line no-eq-null,eqeqeq
493
+ if (sourceObj == null) return destObj;
494
+ do {
495
+ props = Object.getOwnPropertyNames(sourceObj);
496
+ i = props.length;
497
+ while (i-- > 0) {
498
+ prop = props[i];
499
+ if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
500
+ destObj[prop] = sourceObj[prop];
501
+ merged[prop] = true;
502
+ }
503
+ }
504
+ sourceObj = filter !== false && getPrototypeOf(sourceObj);
505
+ } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
506
+ return destObj;
507
+ };
508
+
509
+ /**
510
+ * Determines whether a string ends with the characters of a specified string
511
+ *
512
+ * @param {String} str
513
+ * @param {String} searchString
514
+ * @param {Number} [position= 0]
515
+ *
516
+ * @returns {boolean}
517
+ */
518
+ var endsWith = function endsWith(str, searchString, position) {
519
+ str = String(str);
520
+ if (position === undefined || position > str.length) {
521
+ position = str.length;
522
+ }
523
+ position -= searchString.length;
524
+ var lastIndex = str.indexOf(searchString, position);
525
+ return lastIndex !== -1 && lastIndex === position;
526
+ };
527
+
528
+ /**
529
+ * Returns new array from array like object or null if failed
530
+ *
531
+ * @param {*} [thing]
532
+ *
533
+ * @returns {?Array}
534
+ */
535
+ var toArray = function toArray(thing) {
536
+ if (!thing) return null;
537
+ if (isArray(thing)) return thing;
538
+ var i = thing.length;
539
+ if (!isNumber(i)) return null;
540
+ var arr = new Array(i);
541
+ while (i-- > 0) {
542
+ arr[i] = thing[i];
543
+ }
544
+ return arr;
545
+ };
546
+
547
+ /**
548
+ * Checking if the Uint8Array exists and if it does, it returns a function that checks if the
549
+ * thing passed in is an instance of Uint8Array
550
+ *
551
+ * @param {TypedArray}
552
+ *
553
+ * @returns {Array}
554
+ */
555
+ // eslint-disable-next-line func-names
556
+ var isTypedArray = function (TypedArray) {
557
+ // eslint-disable-next-line func-names
558
+ return function (thing) {
559
+ return TypedArray && thing instanceof TypedArray;
560
+ };
561
+ }(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
562
+
563
+ /**
564
+ * For each entry in the object, call the function with the key and value.
565
+ *
566
+ * @param {Object<any, any>} obj - The object to iterate over.
567
+ * @param {Function} fn - The function to call for each entry.
568
+ *
569
+ * @returns {void}
570
+ */
571
+ var forEachEntry = function forEachEntry(obj, fn) {
572
+ var generator = obj && obj[Symbol.iterator];
573
+ var iterator = generator.call(obj);
574
+ var result;
575
+ while ((result = iterator.next()) && !result.done) {
576
+ var pair = result.value;
577
+ fn.call(obj, pair[0], pair[1]);
578
+ }
579
+ };
580
+
581
+ /**
582
+ * It takes a regular expression and a string, and returns an array of all the matches
583
+ *
584
+ * @param {string} regExp - The regular expression to match against.
585
+ * @param {string} str - The string to search.
586
+ *
587
+ * @returns {Array<boolean>}
588
+ */
589
+ var matchAll = function matchAll(regExp, str) {
590
+ var matches;
591
+ var arr = [];
592
+ while ((matches = regExp.exec(str)) !== null) {
593
+ arr.push(matches);
594
+ }
595
+ return arr;
596
+ };
597
+
598
+ /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
599
+ var isHTMLForm = kindOfTest('HTMLFormElement');
600
+ var toCamelCase = function toCamelCase(str) {
601
+ return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
602
+ return p1.toUpperCase() + p2;
603
+ });
604
+ };
605
+
606
+ /* Creating a function that will check if an object has a property. */
607
+ var hasOwnProperty = function (_ref4) {
608
+ var hasOwnProperty = _ref4.hasOwnProperty;
609
+ return function (obj, prop) {
610
+ return hasOwnProperty.call(obj, prop);
611
+ };
612
+ }(Object.prototype);
613
+
614
+ /**
615
+ * Determine if a value is a RegExp object
616
+ *
617
+ * @param {*} val The value to test
618
+ *
619
+ * @returns {boolean} True if value is a RegExp object, otherwise false
620
+ */
621
+ var isRegExp = kindOfTest('RegExp');
622
+ var reduceDescriptors = function reduceDescriptors(obj, reducer) {
623
+ var descriptors = Object.getOwnPropertyDescriptors(obj);
624
+ var reducedDescriptors = {};
625
+ forEach(descriptors, function (descriptor, name) {
626
+ if (reducer(descriptor, name, obj) !== false) {
627
+ reducedDescriptors[name] = descriptor;
628
+ }
629
+ });
630
+ Object.defineProperties(obj, reducedDescriptors);
631
+ };
632
+
633
+ /**
634
+ * Makes all methods read-only
635
+ * @param {Object} obj
636
+ */
637
+
638
+ var freezeMethods = function freezeMethods(obj) {
639
+ reduceDescriptors(obj, function (descriptor, name) {
640
+ // skip restricted props in strict mode
641
+ if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
642
+ return false;
643
+ }
644
+ var value = obj[name];
645
+ if (!isFunction(value)) return;
646
+ descriptor.enumerable = false;
647
+ if ('writable' in descriptor) {
648
+ descriptor.writable = false;
649
+ return;
650
+ }
651
+ if (!descriptor.set) {
652
+ descriptor.set = function () {
653
+ throw Error('Can not rewrite read-only method \'' + name + '\'');
654
+ };
655
+ }
656
+ });
657
+ };
658
+ var toObjectSet = function toObjectSet(arrayOrString, delimiter) {
659
+ var obj = {};
660
+ var define = function define(arr) {
661
+ arr.forEach(function (value) {
662
+ obj[value] = true;
663
+ });
664
+ };
665
+ isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
666
+ return obj;
667
+ };
668
+ var noop = function noop() {};
669
+ var toFiniteNumber = function toFiniteNumber(value, defaultValue) {
670
+ value = +value;
671
+ return Number.isFinite(value) ? value : defaultValue;
672
+ };
673
+ var ALPHA = 'abcdefghijklmnopqrstuvwxyz';
674
+ var DIGIT = '0123456789';
675
+ var ALPHABET = {
676
+ DIGIT: DIGIT,
677
+ ALPHA: ALPHA,
678
+ ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
679
+ };
680
+ var generateString = function generateString() {
681
+ var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 16;
682
+ var alphabet = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ALPHABET.ALPHA_DIGIT;
683
+ var str = '';
684
+ var length = alphabet.length;
685
+ while (size--) {
686
+ str += alphabet[Math.random() * length | 0];
687
+ }
688
+ return str;
689
+ };
690
+
691
+ /**
692
+ * If the thing is a FormData object, return true, otherwise return false.
693
+ *
694
+ * @param {unknown} thing - The thing to check.
695
+ *
696
+ * @returns {boolean}
697
+ */
698
+ function isSpecCompliantForm(thing) {
699
+ return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
700
+ }
701
+ var toJSONObject = function toJSONObject(obj) {
702
+ var stack = new Array(10);
703
+ var visit = function visit(source, i) {
704
+ if (isObject(source)) {
705
+ if (stack.indexOf(source) >= 0) {
706
+ return;
707
+ }
708
+ if (!('toJSON' in source)) {
709
+ stack[i] = source;
710
+ var target = isArray(source) ? [] : {};
711
+ forEach(source, function (value, key) {
712
+ var reducedValue = visit(value, i + 1);
713
+ !isUndefined(reducedValue) && (target[key] = reducedValue);
714
+ });
715
+ stack[i] = undefined;
716
+ return target;
717
+ }
718
+ }
719
+ return source;
720
+ };
721
+ return visit(obj, 0);
722
+ };
723
+ var utils = {
724
+ isArray: isArray,
725
+ isArrayBuffer: isArrayBuffer,
726
+ isBuffer: isBuffer,
727
+ isFormData: isFormData,
728
+ isArrayBufferView: isArrayBufferView,
729
+ isString: isString,
730
+ isNumber: isNumber,
731
+ isBoolean: isBoolean,
732
+ isObject: isObject,
733
+ isPlainObject: isPlainObject,
734
+ isUndefined: isUndefined,
735
+ isDate: isDate,
736
+ isFile: isFile,
737
+ isBlob: isBlob,
738
+ isRegExp: isRegExp,
739
+ isFunction: isFunction,
740
+ isStream: isStream,
741
+ isURLSearchParams: isURLSearchParams,
742
+ isTypedArray: isTypedArray,
743
+ isFileList: isFileList,
744
+ forEach: forEach,
745
+ merge: merge,
746
+ extend: extend,
747
+ trim: trim,
748
+ stripBOM: stripBOM,
749
+ inherits: inherits,
750
+ toFlatObject: toFlatObject,
751
+ kindOf: kindOf,
752
+ kindOfTest: kindOfTest,
753
+ endsWith: endsWith,
754
+ toArray: toArray,
755
+ forEachEntry: forEachEntry,
756
+ matchAll: matchAll,
757
+ isHTMLForm: isHTMLForm,
758
+ hasOwnProperty: hasOwnProperty,
759
+ hasOwnProp: hasOwnProperty,
760
+ // an alias to avoid ESLint no-prototype-builtins detection
761
+ reduceDescriptors: reduceDescriptors,
762
+ freezeMethods: freezeMethods,
763
+ toObjectSet: toObjectSet,
764
+ toCamelCase: toCamelCase,
765
+ noop: noop,
766
+ toFiniteNumber: toFiniteNumber,
767
+ findKey: findKey,
768
+ global: _global,
769
+ isContextDefined: isContextDefined,
770
+ ALPHABET: ALPHABET,
771
+ generateString: generateString,
772
+ isSpecCompliantForm: isSpecCompliantForm,
773
+ toJSONObject: toJSONObject
774
+ };
775
+
776
+ /**
777
+ * Create an Error with the specified message, config, error code, request and response.
778
+ *
779
+ * @param {string} message The error message.
780
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
781
+ * @param {Object} [config] The config.
782
+ * @param {Object} [request] The request.
783
+ * @param {Object} [response] The response.
784
+ *
785
+ * @returns {Error} The created error.
786
+ */
787
+ function AxiosError(message, code, config, request, response) {
788
+ Error.call(this);
789
+ if (Error.captureStackTrace) {
790
+ Error.captureStackTrace(this, this.constructor);
791
+ } else {
792
+ this.stack = new Error().stack;
793
+ }
794
+ this.message = message;
795
+ this.name = 'AxiosError';
796
+ code && (this.code = code);
797
+ config && (this.config = config);
798
+ request && (this.request = request);
799
+ response && (this.response = response);
800
+ }
801
+ utils.inherits(AxiosError, Error, {
802
+ toJSON: function toJSON() {
803
+ return {
804
+ // Standard
805
+ message: this.message,
806
+ name: this.name,
807
+ // Microsoft
808
+ description: this.description,
809
+ number: this.number,
810
+ // Mozilla
811
+ fileName: this.fileName,
812
+ lineNumber: this.lineNumber,
813
+ columnNumber: this.columnNumber,
814
+ stack: this.stack,
815
+ // Axios
816
+ config: utils.toJSONObject(this.config),
817
+ code: this.code,
818
+ status: this.response && this.response.status ? this.response.status : null
819
+ };
820
+ }
821
+ });
822
+ var prototype$1 = AxiosError.prototype;
823
+ var descriptors = {};
824
+ ['ERR_BAD_OPTION_VALUE', 'ERR_BAD_OPTION', 'ECONNABORTED', 'ETIMEDOUT', 'ERR_NETWORK', 'ERR_FR_TOO_MANY_REDIRECTS', 'ERR_DEPRECATED', 'ERR_BAD_RESPONSE', 'ERR_BAD_REQUEST', 'ERR_CANCELED', 'ERR_NOT_SUPPORT', 'ERR_INVALID_URL'
825
+ // eslint-disable-next-line func-names
826
+ ].forEach(function (code) {
827
+ descriptors[code] = {
828
+ value: code
829
+ };
830
+ });
831
+ Object.defineProperties(AxiosError, descriptors);
832
+ Object.defineProperty(prototype$1, 'isAxiosError', {
833
+ value: true
834
+ });
835
+
836
+ // eslint-disable-next-line func-names
837
+ AxiosError.from = function (error, code, config, request, response, customProps) {
838
+ var axiosError = Object.create(prototype$1);
839
+ utils.toFlatObject(error, axiosError, function filter(obj) {
840
+ return obj !== Error.prototype;
841
+ }, function (prop) {
842
+ return prop !== 'isAxiosError';
843
+ });
844
+ AxiosError.call(axiosError, error.message, code, config, request, response);
845
+ axiosError.cause = error;
846
+ axiosError.name = error.name;
847
+ customProps && Object.assign(axiosError, customProps);
848
+ return axiosError;
849
+ };
850
+
851
+ // eslint-disable-next-line strict
852
+ var httpAdapter = null;
853
+
854
+ /**
855
+ * Determines if the given thing is a array or js object.
856
+ *
857
+ * @param {string} thing - The object or array to be visited.
858
+ *
859
+ * @returns {boolean}
860
+ */
861
+ function isVisitable(thing) {
862
+ return utils.isPlainObject(thing) || utils.isArray(thing);
863
+ }
864
+
865
+ /**
866
+ * It removes the brackets from the end of a string
867
+ *
868
+ * @param {string} key - The key of the parameter.
869
+ *
870
+ * @returns {string} the key without the brackets.
871
+ */
872
+ function removeBrackets(key) {
873
+ return utils.endsWith(key, '[]') ? key.slice(0, -2) : key;
874
+ }
875
+
876
+ /**
877
+ * It takes a path, a key, and a boolean, and returns a string
878
+ *
879
+ * @param {string} path - The path to the current key.
880
+ * @param {string} key - The key of the current object being iterated over.
881
+ * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
882
+ *
883
+ * @returns {string} The path to the current key.
884
+ */
885
+ function renderKey(path, key, dots) {
886
+ if (!path) return key;
887
+ return path.concat(key).map(function each(token, i) {
888
+ // eslint-disable-next-line no-param-reassign
889
+ token = removeBrackets(token);
890
+ return !dots && i ? '[' + token + ']' : token;
891
+ }).join(dots ? '.' : '');
892
+ }
893
+
894
+ /**
895
+ * If the array is an array and none of its elements are visitable, then it's a flat array.
896
+ *
897
+ * @param {Array<any>} arr - The array to check
898
+ *
899
+ * @returns {boolean}
900
+ */
901
+ function isFlatArray(arr) {
902
+ return utils.isArray(arr) && !arr.some(isVisitable);
903
+ }
904
+ var predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
905
+ return /^is[A-Z]/.test(prop);
906
+ });
907
+
908
+ /**
909
+ * Convert a data object to FormData
910
+ *
911
+ * @param {Object} obj
912
+ * @param {?Object} [formData]
913
+ * @param {?Object} [options]
914
+ * @param {Function} [options.visitor]
915
+ * @param {Boolean} [options.metaTokens = true]
916
+ * @param {Boolean} [options.dots = false]
917
+ * @param {?Boolean} [options.indexes = false]
918
+ *
919
+ * @returns {Object}
920
+ **/
921
+
922
+ /**
923
+ * It converts an object into a FormData object
924
+ *
925
+ * @param {Object<any, any>} obj - The object to convert to form data.
926
+ * @param {string} formData - The FormData object to append to.
927
+ * @param {Object<string, any>} options
928
+ *
929
+ * @returns
930
+ */
931
+ function toFormData(obj, formData, options) {
932
+ if (!utils.isObject(obj)) {
933
+ throw new TypeError('target must be an object');
934
+ }
935
+
936
+ // eslint-disable-next-line no-param-reassign
937
+ formData = formData || new (FormData)();
938
+
939
+ // eslint-disable-next-line no-param-reassign
940
+ options = utils.toFlatObject(options, {
941
+ metaTokens: true,
942
+ dots: false,
943
+ indexes: false
944
+ }, false, function defined(option, source) {
945
+ // eslint-disable-next-line no-eq-null,eqeqeq
946
+ return !utils.isUndefined(source[option]);
947
+ });
948
+ var metaTokens = options.metaTokens;
949
+ // eslint-disable-next-line no-use-before-define
950
+ var visitor = options.visitor || defaultVisitor;
951
+ var dots = options.dots;
952
+ var indexes = options.indexes;
953
+ var _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
954
+ var useBlob = _Blob && utils.isSpecCompliantForm(formData);
955
+ if (!utils.isFunction(visitor)) {
956
+ throw new TypeError('visitor must be a function');
957
+ }
958
+ function convertValue(value) {
959
+ if (value === null) return '';
960
+ if (utils.isDate(value)) {
961
+ return value.toISOString();
962
+ }
963
+ if (!useBlob && utils.isBlob(value)) {
964
+ throw new AxiosError('Blob is not supported. Use a Buffer instead.');
965
+ }
966
+ if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
967
+ return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
968
+ }
969
+ return value;
970
+ }
971
+
972
+ /**
973
+ * Default visitor.
974
+ *
975
+ * @param {*} value
976
+ * @param {String|Number} key
977
+ * @param {Array<String|Number>} path
978
+ * @this {FormData}
979
+ *
980
+ * @returns {boolean} return true to visit the each prop of the value recursively
981
+ */
982
+ function defaultVisitor(value, key, path) {
983
+ var arr = value;
984
+ if (value && !path && _typeof(value) === 'object') {
985
+ if (utils.endsWith(key, '{}')) {
986
+ // eslint-disable-next-line no-param-reassign
987
+ key = metaTokens ? key : key.slice(0, -2);
988
+ // eslint-disable-next-line no-param-reassign
989
+ value = JSON.stringify(value);
990
+ } else if (utils.isArray(value) && isFlatArray(value) || (utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value))) {
991
+ // eslint-disable-next-line no-param-reassign
992
+ key = removeBrackets(key);
993
+ arr.forEach(function each(el, index) {
994
+ !(utils.isUndefined(el) || el === null) && formData.append(
995
+ // eslint-disable-next-line no-nested-ternary
996
+ indexes === true ? renderKey([key], index, dots) : indexes === null ? key : key + '[]', convertValue(el));
997
+ });
998
+ return false;
999
+ }
1000
+ }
1001
+ if (isVisitable(value)) {
1002
+ return true;
1003
+ }
1004
+ formData.append(renderKey(path, key, dots), convertValue(value));
1005
+ return false;
1006
+ }
1007
+ var stack = [];
1008
+ var exposedHelpers = Object.assign(predicates, {
1009
+ defaultVisitor: defaultVisitor,
1010
+ convertValue: convertValue,
1011
+ isVisitable: isVisitable
1012
+ });
1013
+ function build(value, path) {
1014
+ if (utils.isUndefined(value)) return;
1015
+ if (stack.indexOf(value) !== -1) {
1016
+ throw Error('Circular reference detected in ' + path.join('.'));
1017
+ }
1018
+ stack.push(value);
1019
+ utils.forEach(value, function each(el, key) {
1020
+ var result = !(utils.isUndefined(el) || el === null) && visitor.call(formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers);
1021
+ if (result === true) {
1022
+ build(el, path ? path.concat(key) : [key]);
1023
+ }
1024
+ });
1025
+ stack.pop();
1026
+ }
1027
+ if (!utils.isObject(obj)) {
1028
+ throw new TypeError('data must be an object');
1029
+ }
1030
+ build(obj);
1031
+ return formData;
1032
+ }
1033
+
1034
+ /**
1035
+ * It encodes a string by replacing all characters that are not in the unreserved set with
1036
+ * their percent-encoded equivalents
1037
+ *
1038
+ * @param {string} str - The string to encode.
1039
+ *
1040
+ * @returns {string} The encoded string.
1041
+ */
1042
+ function encode$1(str) {
1043
+ var charMap = {
1044
+ '!': '%21',
1045
+ "'": '%27',
1046
+ '(': '%28',
1047
+ ')': '%29',
1048
+ '~': '%7E',
1049
+ '%20': '+',
1050
+ '%00': '\x00'
1051
+ };
1052
+ return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
1053
+ return charMap[match];
1054
+ });
1055
+ }
1056
+
1057
+ /**
1058
+ * It takes a params object and converts it to a FormData object
1059
+ *
1060
+ * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
1061
+ * @param {Object<string, any>} options - The options object passed to the Axios constructor.
1062
+ *
1063
+ * @returns {void}
1064
+ */
1065
+ function AxiosURLSearchParams(params, options) {
1066
+ this._pairs = [];
1067
+ params && toFormData(params, this, options);
1068
+ }
1069
+ var prototype = AxiosURLSearchParams.prototype;
1070
+ prototype.append = function append(name, value) {
1071
+ this._pairs.push([name, value]);
1072
+ };
1073
+ prototype.toString = function toString(encoder) {
1074
+ var _encode = encoder ? function (value) {
1075
+ return encoder.call(this, value, encode$1);
1076
+ } : encode$1;
1077
+ return this._pairs.map(function each(pair) {
1078
+ return _encode(pair[0]) + '=' + _encode(pair[1]);
1079
+ }, '').join('&');
1080
+ };
1081
+
1082
+ /**
1083
+ * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
1084
+ * URI encoded counterparts
1085
+ *
1086
+ * @param {string} val The value to be encoded.
1087
+ *
1088
+ * @returns {string} The encoded value.
1089
+ */
1090
+ function encode(val) {
1091
+ return encodeURIComponent(val).replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+').replace(/%5B/gi, '[').replace(/%5D/gi, ']');
1092
+ }
1093
+
1094
+ /**
1095
+ * Build a URL by appending params to the end
1096
+ *
1097
+ * @param {string} url The base of the url (e.g., http://www.google.com)
1098
+ * @param {object} [params] The params to be appended
1099
+ * @param {?object} options
1100
+ *
1101
+ * @returns {string} The formatted url
1102
+ */
1103
+ function buildURL(url, params, options) {
1104
+ /*eslint no-param-reassign:0*/
1105
+ if (!params) {
1106
+ return url;
1107
+ }
1108
+ var _encode = options && options.encode || encode;
1109
+ var serializeFn = options && options.serialize;
1110
+ var serializedParams;
1111
+ if (serializeFn) {
1112
+ serializedParams = serializeFn(params, options);
1113
+ } else {
1114
+ serializedParams = utils.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, options).toString(_encode);
1115
+ }
1116
+ if (serializedParams) {
1117
+ var hashmarkIndex = url.indexOf("#");
1118
+ if (hashmarkIndex !== -1) {
1119
+ url = url.slice(0, hashmarkIndex);
1120
+ }
1121
+ url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
1122
+ }
1123
+ return url;
1124
+ }
1125
+
1126
+ var InterceptorManager = /*#__PURE__*/function () {
1127
+ function InterceptorManager() {
1128
+ _classCallCheck(this, InterceptorManager);
1129
+ this.handlers = [];
1130
+ }
1131
+
1132
+ /**
1133
+ * Add a new interceptor to the stack
1134
+ *
1135
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
1136
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
1137
+ *
1138
+ * @return {Number} An ID used to remove interceptor later
1139
+ */
1140
+ _createClass(InterceptorManager, [{
1141
+ key: "use",
1142
+ value: function use(fulfilled, rejected, options) {
1143
+ this.handlers.push({
1144
+ fulfilled: fulfilled,
1145
+ rejected: rejected,
1146
+ synchronous: options ? options.synchronous : false,
1147
+ runWhen: options ? options.runWhen : null
1148
+ });
1149
+ return this.handlers.length - 1;
1150
+ }
1151
+
1152
+ /**
1153
+ * Remove an interceptor from the stack
1154
+ *
1155
+ * @param {Number} id The ID that was returned by `use`
1156
+ *
1157
+ * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
1158
+ */
1159
+ }, {
1160
+ key: "eject",
1161
+ value: function eject(id) {
1162
+ if (this.handlers[id]) {
1163
+ this.handlers[id] = null;
1164
+ }
1165
+ }
1166
+
1167
+ /**
1168
+ * Clear all interceptors from the stack
1169
+ *
1170
+ * @returns {void}
1171
+ */
1172
+ }, {
1173
+ key: "clear",
1174
+ value: function clear() {
1175
+ if (this.handlers) {
1176
+ this.handlers = [];
1177
+ }
1178
+ }
1179
+
1180
+ /**
1181
+ * Iterate over all the registered interceptors
1182
+ *
1183
+ * This method is particularly useful for skipping over any
1184
+ * interceptors that may have become `null` calling `eject`.
1185
+ *
1186
+ * @param {Function} fn The function to call for each interceptor
1187
+ *
1188
+ * @returns {void}
1189
+ */
1190
+ }, {
1191
+ key: "forEach",
1192
+ value: function forEach(fn) {
1193
+ utils.forEach(this.handlers, function forEachHandler(h) {
1194
+ if (h !== null) {
1195
+ fn(h);
1196
+ }
1197
+ });
1198
+ }
1199
+ }]);
1200
+ return InterceptorManager;
1201
+ }();
1202
+ var InterceptorManager$1 = InterceptorManager;
1203
+
1204
+ var transitionalDefaults = {
1205
+ silentJSONParsing: true,
1206
+ forcedJSONParsing: true,
1207
+ clarifyTimeoutError: false
1208
+ };
1209
+
1210
+ var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
1211
+
1212
+ var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
1213
+
1214
+ var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
1215
+
1216
+ /**
1217
+ * Determine if we're running in a standard browser environment
1218
+ *
1219
+ * This allows axios to run in a web worker, and react-native.
1220
+ * Both environments support XMLHttpRequest, but not fully standard globals.
1221
+ *
1222
+ * web workers:
1223
+ * typeof window -> undefined
1224
+ * typeof document -> undefined
1225
+ *
1226
+ * react-native:
1227
+ * navigator.product -> 'ReactNative'
1228
+ * nativescript
1229
+ * navigator.product -> 'NativeScript' or 'NS'
1230
+ *
1231
+ * @returns {boolean}
1232
+ */
1233
+ var isStandardBrowserEnv = function () {
1234
+ // 针对微信小程序环境打补丁
1235
+ if (typeof wx !== 'undefined' && typeof wx.request === 'function') return false
1236
+ var product;
1237
+ if (typeof navigator !== 'undefined' && ((product = navigator.product) === 'ReactNative' || product === 'NativeScript' || product === 'NS')) {
1238
+ return false;
1239
+ }
1240
+ return typeof window !== 'undefined' && typeof document !== 'undefined';
1241
+ }();
1242
+
1243
+ /**
1244
+ * Determine if we're running in a standard browser webWorker environment
1245
+ *
1246
+ * Although the `isStandardBrowserEnv` method indicates that
1247
+ * `allows axios to run in a web worker`, the WebWorker will still be
1248
+ * filtered out due to its judgment standard
1249
+ * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
1250
+ * This leads to a problem when axios post `FormData` in webWorker
1251
+ */
1252
+ var isStandardBrowserWebWorkerEnv = function () {
1253
+ return typeof WorkerGlobalScope !== 'undefined' &&
1254
+ // eslint-disable-next-line no-undef
1255
+ self instanceof WorkerGlobalScope && typeof self.importScripts === 'function';
1256
+ }();
1257
+ var platform = {
1258
+ isBrowser: true,
1259
+ classes: {
1260
+ URLSearchParams: URLSearchParams$1,
1261
+ FormData: FormData$1,
1262
+ Blob: Blob$1
1263
+ },
1264
+ isStandardBrowserEnv: isStandardBrowserEnv,
1265
+ isStandardBrowserWebWorkerEnv: isStandardBrowserWebWorkerEnv,
1266
+ protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
1267
+ };
1268
+
1269
+ function toURLEncodedForm(data, options) {
1270
+ return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
1271
+ visitor: function visitor(value, key, path, helpers) {
1272
+ if (platform.isNode && utils.isBuffer(value)) {
1273
+ this.append(key, value.toString('base64'));
1274
+ return false;
1275
+ }
1276
+ return helpers.defaultVisitor.apply(this, arguments);
1277
+ }
1278
+ }, options));
1279
+ }
1280
+
1281
+ /**
1282
+ * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
1283
+ *
1284
+ * @param {string} name - The name of the property to get.
1285
+ *
1286
+ * @returns An array of strings.
1287
+ */
1288
+ function parsePropPath(name) {
1289
+ // foo[x][y][z]
1290
+ // foo.x.y.z
1291
+ // foo-x-y-z
1292
+ // foo x y z
1293
+ return utils.matchAll(/\w+|\[(\w*)]/g, name).map(function (match) {
1294
+ return match[0] === '[]' ? '' : match[1] || match[0];
1295
+ });
1296
+ }
1297
+
1298
+ /**
1299
+ * Convert an array to an object.
1300
+ *
1301
+ * @param {Array<any>} arr - The array to convert to an object.
1302
+ *
1303
+ * @returns An object with the same keys and values as the array.
1304
+ */
1305
+ function arrayToObject(arr) {
1306
+ var obj = {};
1307
+ var keys = Object.keys(arr);
1308
+ var i;
1309
+ var len = keys.length;
1310
+ var key;
1311
+ for (i = 0; i < len; i++) {
1312
+ key = keys[i];
1313
+ obj[key] = arr[key];
1314
+ }
1315
+ return obj;
1316
+ }
1317
+
1318
+ /**
1319
+ * It takes a FormData object and returns a JavaScript object
1320
+ *
1321
+ * @param {string} formData The FormData object to convert to JSON.
1322
+ *
1323
+ * @returns {Object<string, any> | null} The converted object.
1324
+ */
1325
+ function formDataToJSON(formData) {
1326
+ function buildPath(path, value, target, index) {
1327
+ var name = path[index++];
1328
+ var isNumericKey = Number.isFinite(+name);
1329
+ var isLast = index >= path.length;
1330
+ name = !name && utils.isArray(target) ? target.length : name;
1331
+ if (isLast) {
1332
+ if (utils.hasOwnProp(target, name)) {
1333
+ target[name] = [target[name], value];
1334
+ } else {
1335
+ target[name] = value;
1336
+ }
1337
+ return !isNumericKey;
1338
+ }
1339
+ if (!target[name] || !utils.isObject(target[name])) {
1340
+ target[name] = [];
1341
+ }
1342
+ var result = buildPath(path, value, target[name], index);
1343
+ if (result && utils.isArray(target[name])) {
1344
+ target[name] = arrayToObject(target[name]);
1345
+ }
1346
+ return !isNumericKey;
1347
+ }
1348
+ if (utils.isFormData(formData) && utils.isFunction(formData.entries)) {
1349
+ var obj = {};
1350
+ utils.forEachEntry(formData, function (name, value) {
1351
+ buildPath(parsePropPath(name), value, obj, 0);
1352
+ });
1353
+ return obj;
1354
+ }
1355
+ return null;
1356
+ }
1357
+
1358
+ var DEFAULT_CONTENT_TYPE = {
1359
+ 'Content-Type': undefined
1360
+ };
1361
+
1362
+ /**
1363
+ * It takes a string, tries to parse it, and if it fails, it returns the stringified version
1364
+ * of the input
1365
+ *
1366
+ * @param {any} rawValue - The value to be stringified.
1367
+ * @param {Function} parser - A function that parses a string into a JavaScript object.
1368
+ * @param {Function} encoder - A function that takes a value and returns a string.
1369
+ *
1370
+ * @returns {string} A stringified version of the rawValue.
1371
+ */
1372
+ function stringifySafely(rawValue, parser, encoder) {
1373
+ if (utils.isString(rawValue)) {
1374
+ try {
1375
+ (parser || JSON.parse)(rawValue);
1376
+ return utils.trim(rawValue);
1377
+ } catch (e) {
1378
+ if (e.name !== 'SyntaxError') {
1379
+ throw e;
1380
+ }
1381
+ }
1382
+ }
1383
+ return (encoder || JSON.stringify)(rawValue);
1384
+ }
1385
+ var defaults = {
1386
+ transitional: transitionalDefaults,
1387
+ adapter: ['xhr', 'http'],
1388
+ transformRequest: [function transformRequest(data, headers) {
1389
+ var contentType = headers.getContentType() || '';
1390
+ var hasJSONContentType = contentType.indexOf('application/json') > -1;
1391
+ var isObjectPayload = utils.isObject(data);
1392
+ if (isObjectPayload && utils.isHTMLForm(data)) {
1393
+ data = new FormData(data);
1394
+ }
1395
+ var isFormData = utils.isFormData(data);
1396
+ if (isFormData) {
1397
+ if (!hasJSONContentType) {
1398
+ return data;
1399
+ }
1400
+ return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
1401
+ }
1402
+ if (utils.isArrayBuffer(data) || utils.isBuffer(data) || utils.isStream(data) || utils.isFile(data) || utils.isBlob(data)) {
1403
+ return data;
1404
+ }
1405
+ if (utils.isArrayBufferView(data)) {
1406
+ return data.buffer;
1407
+ }
1408
+ if (utils.isURLSearchParams(data)) {
1409
+ headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
1410
+ return data.toString();
1411
+ }
1412
+ var isFileList;
1413
+ if (isObjectPayload) {
1414
+ if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
1415
+ return toURLEncodedForm(data, this.formSerializer).toString();
1416
+ }
1417
+ if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
1418
+ var _FormData = this.env && this.env.FormData;
1419
+ return toFormData(isFileList ? {
1420
+ 'files[]': data
1421
+ } : data, _FormData && new _FormData(), this.formSerializer);
1422
+ }
1423
+ }
1424
+ if (isObjectPayload || hasJSONContentType) {
1425
+ headers.setContentType('application/json', false);
1426
+ return stringifySafely(data);
1427
+ }
1428
+ return data;
1429
+ }],
1430
+ transformResponse: [function transformResponse(data) {
1431
+ var transitional = this.transitional || defaults.transitional;
1432
+ var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1433
+ var JSONRequested = this.responseType === 'json';
1434
+ if (data && utils.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
1435
+ var silentJSONParsing = transitional && transitional.silentJSONParsing;
1436
+ var strictJSONParsing = !silentJSONParsing && JSONRequested;
1437
+ try {
1438
+ return JSON.parse(data);
1439
+ } catch (e) {
1440
+ if (strictJSONParsing) {
1441
+ if (e.name === 'SyntaxError') {
1442
+ throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
1443
+ }
1444
+ throw e;
1445
+ }
1446
+ }
1447
+ }
1448
+ return data;
1449
+ }],
1450
+ /**
1451
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
1452
+ * timeout is not created.
1453
+ */
1454
+ timeout: 0,
1455
+ xsrfCookieName: 'XSRF-TOKEN',
1456
+ xsrfHeaderName: 'X-XSRF-TOKEN',
1457
+ maxContentLength: -1,
1458
+ maxBodyLength: -1,
1459
+ env: {
1460
+ FormData: platform.classes.FormData,
1461
+ Blob: platform.classes.Blob
1462
+ },
1463
+ validateStatus: function validateStatus(status) {
1464
+ return status >= 200 && status < 300;
1465
+ },
1466
+ headers: {
1467
+ common: {
1468
+ 'Accept': 'application/json, text/plain, */*'
1469
+ }
1470
+ }
1471
+ };
1472
+ utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
1473
+ defaults.headers[method] = {};
1474
+ });
1475
+ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
1476
+ defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
1477
+ });
1478
+ var defaults$1 = defaults;
1479
+
1480
+ // RawAxiosHeaders whose duplicates are ignored by node
1481
+ // c.f. https://nodejs.org/api/http.html#http_message_headers
1482
+ var ignoreDuplicateOf = utils.toObjectSet(['age', 'authorization', 'content-length', 'content-type', 'etag', 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', 'last-modified', 'location', 'max-forwards', 'proxy-authorization', 'referer', 'retry-after', 'user-agent']);
1483
+
1484
+ /**
1485
+ * Parse headers into an object
1486
+ *
1487
+ * ```
1488
+ * Date: Wed, 27 Aug 2014 08:58:49 GMT
1489
+ * Content-Type: application/json
1490
+ * Connection: keep-alive
1491
+ * Transfer-Encoding: chunked
1492
+ * ```
1493
+ *
1494
+ * @param {String} rawHeaders Headers needing to be parsed
1495
+ *
1496
+ * @returns {Object} Headers parsed into an object
1497
+ */
1498
+ var parseHeaders = (function (rawHeaders) {
1499
+ var parsed = {};
1500
+ var key;
1501
+ var val;
1502
+ var i;
1503
+ rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
1504
+ i = line.indexOf(':');
1505
+ key = line.substring(0, i).trim().toLowerCase();
1506
+ val = line.substring(i + 1).trim();
1507
+ if (!key || parsed[key] && ignoreDuplicateOf[key]) {
1508
+ return;
1509
+ }
1510
+ if (key === 'set-cookie') {
1511
+ if (parsed[key]) {
1512
+ parsed[key].push(val);
1513
+ } else {
1514
+ parsed[key] = [val];
1515
+ }
1516
+ } else {
1517
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1518
+ }
1519
+ });
1520
+ return parsed;
1521
+ });
1522
+
1523
+ var $internals = Symbol('internals');
1524
+ function normalizeHeader(header) {
1525
+ return header && String(header).trim().toLowerCase();
1526
+ }
1527
+ function normalizeValue(value) {
1528
+ if (value === false || value == null) {
1529
+ return value;
1530
+ }
1531
+ return utils.isArray(value) ? value.map(normalizeValue) : String(value);
1532
+ }
1533
+ function parseTokens(str) {
1534
+ var tokens = Object.create(null);
1535
+ var tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
1536
+ var match;
1537
+ while (match = tokensRE.exec(str)) {
1538
+ tokens[match[1]] = match[2];
1539
+ }
1540
+ return tokens;
1541
+ }
1542
+ function isValidHeaderName(str) {
1543
+ return /^[-_a-zA-Z]+$/.test(str.trim());
1544
+ }
1545
+ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
1546
+ if (utils.isFunction(filter)) {
1547
+ return filter.call(this, value, header);
1548
+ }
1549
+ if (isHeaderNameFilter) {
1550
+ value = header;
1551
+ }
1552
+ if (!utils.isString(value)) return;
1553
+ if (utils.isString(filter)) {
1554
+ return value.indexOf(filter) !== -1;
1555
+ }
1556
+ if (utils.isRegExp(filter)) {
1557
+ return filter.test(value);
1558
+ }
1559
+ }
1560
+ function formatHeader(header) {
1561
+ return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, function (w, _char, str) {
1562
+ return _char.toUpperCase() + str;
1563
+ });
1564
+ }
1565
+ function buildAccessors(obj, header) {
1566
+ var accessorName = utils.toCamelCase(' ' + header);
1567
+ ['get', 'set', 'has'].forEach(function (methodName) {
1568
+ Object.defineProperty(obj, methodName + accessorName, {
1569
+ value: function value(arg1, arg2, arg3) {
1570
+ return this[methodName].call(this, header, arg1, arg2, arg3);
1571
+ },
1572
+ configurable: true
1573
+ });
1574
+ });
1575
+ }
1576
+ var AxiosHeaders = /*#__PURE__*/function (_Symbol$iterator, _Symbol$toStringTag) {
1577
+ function AxiosHeaders(headers) {
1578
+ _classCallCheck(this, AxiosHeaders);
1579
+ headers && this.set(headers);
1580
+ }
1581
+ _createClass(AxiosHeaders, [{
1582
+ key: "set",
1583
+ value: function set(header, valueOrRewrite, rewrite) {
1584
+ var self = this;
1585
+ function setHeader(_value, _header, _rewrite) {
1586
+ var lHeader = normalizeHeader(_header);
1587
+ if (!lHeader) {
1588
+ throw new Error('header name must be a non-empty string');
1589
+ }
1590
+ var key = utils.findKey(self, lHeader);
1591
+ if (!key || self[key] === undefined || _rewrite === true || _rewrite === undefined && self[key] !== false) {
1592
+ self[key || _header] = normalizeValue(_value);
1593
+ }
1594
+ }
1595
+ var setHeaders = function setHeaders(headers, _rewrite) {
1596
+ return utils.forEach(headers, function (_value, _header) {
1597
+ return setHeader(_value, _header, _rewrite);
1598
+ });
1599
+ };
1600
+ if (utils.isPlainObject(header) || header instanceof this.constructor) {
1601
+ setHeaders(header, valueOrRewrite);
1602
+ } else if (utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1603
+ setHeaders(parseHeaders(header), valueOrRewrite);
1604
+ } else {
1605
+ header != null && setHeader(valueOrRewrite, header, rewrite);
1606
+ }
1607
+ return this;
1608
+ }
1609
+ }, {
1610
+ key: "get",
1611
+ value: function get(header, parser) {
1612
+ header = normalizeHeader(header);
1613
+ if (header) {
1614
+ var key = utils.findKey(this, header);
1615
+ if (key) {
1616
+ var value = this[key];
1617
+ if (!parser) {
1618
+ return value;
1619
+ }
1620
+ if (parser === true) {
1621
+ return parseTokens(value);
1622
+ }
1623
+ if (utils.isFunction(parser)) {
1624
+ return parser.call(this, value, key);
1625
+ }
1626
+ if (utils.isRegExp(parser)) {
1627
+ return parser.exec(value);
1628
+ }
1629
+ throw new TypeError('parser must be boolean|regexp|function');
1630
+ }
1631
+ }
1632
+ }
1633
+ }, {
1634
+ key: "has",
1635
+ value: function has(header, matcher) {
1636
+ header = normalizeHeader(header);
1637
+ if (header) {
1638
+ var key = utils.findKey(this, header);
1639
+ return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1640
+ }
1641
+ return false;
1642
+ }
1643
+ }, {
1644
+ key: "delete",
1645
+ value: function _delete(header, matcher) {
1646
+ var self = this;
1647
+ var deleted = false;
1648
+ function deleteHeader(_header) {
1649
+ _header = normalizeHeader(_header);
1650
+ if (_header) {
1651
+ var key = utils.findKey(self, _header);
1652
+ if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
1653
+ delete self[key];
1654
+ deleted = true;
1655
+ }
1656
+ }
1657
+ }
1658
+ if (utils.isArray(header)) {
1659
+ header.forEach(deleteHeader);
1660
+ } else {
1661
+ deleteHeader(header);
1662
+ }
1663
+ return deleted;
1664
+ }
1665
+ }, {
1666
+ key: "clear",
1667
+ value: function clear(matcher) {
1668
+ var keys = Object.keys(this);
1669
+ var i = keys.length;
1670
+ var deleted = false;
1671
+ while (i--) {
1672
+ var key = keys[i];
1673
+ if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
1674
+ delete this[key];
1675
+ deleted = true;
1676
+ }
1677
+ }
1678
+ return deleted;
1679
+ }
1680
+ }, {
1681
+ key: "normalize",
1682
+ value: function normalize(format) {
1683
+ var self = this;
1684
+ var headers = {};
1685
+ utils.forEach(this, function (value, header) {
1686
+ var key = utils.findKey(headers, header);
1687
+ if (key) {
1688
+ self[key] = normalizeValue(value);
1689
+ delete self[header];
1690
+ return;
1691
+ }
1692
+ var normalized = format ? formatHeader(header) : String(header).trim();
1693
+ if (normalized !== header) {
1694
+ delete self[header];
1695
+ }
1696
+ self[normalized] = normalizeValue(value);
1697
+ headers[normalized] = true;
1698
+ });
1699
+ return this;
1700
+ }
1701
+ }, {
1702
+ key: "concat",
1703
+ value: function concat() {
1704
+ var _this$constructor;
1705
+ for (var _len = arguments.length, targets = new Array(_len), _key = 0; _key < _len; _key++) {
1706
+ targets[_key] = arguments[_key];
1707
+ }
1708
+ return (_this$constructor = this.constructor).concat.apply(_this$constructor, [this].concat(targets));
1709
+ }
1710
+ }, {
1711
+ key: "toJSON",
1712
+ value: function toJSON(asStrings) {
1713
+ var obj = Object.create(null);
1714
+ utils.forEach(this, function (value, header) {
1715
+ value != null && value !== false && (obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value);
1716
+ });
1717
+ return obj;
1718
+ }
1719
+ }, {
1720
+ key: _Symbol$iterator,
1721
+ value: function value() {
1722
+ return Object.entries(this.toJSON())[Symbol.iterator]();
1723
+ }
1724
+ }, {
1725
+ key: "toString",
1726
+ value: function toString() {
1727
+ return Object.entries(this.toJSON()).map(function (_ref) {
1728
+ var _ref2 = _slicedToArray(_ref, 2),
1729
+ header = _ref2[0],
1730
+ value = _ref2[1];
1731
+ return header + ': ' + value;
1732
+ }).join('\n');
1733
+ }
1734
+ }, {
1735
+ key: _Symbol$toStringTag,
1736
+ get: function get() {
1737
+ return 'AxiosHeaders';
1738
+ }
1739
+ }], [{
1740
+ key: "from",
1741
+ value: function from(thing) {
1742
+ return thing instanceof this ? thing : new this(thing);
1743
+ }
1744
+ }, {
1745
+ key: "concat",
1746
+ value: function concat(first) {
1747
+ var computed = new this(first);
1748
+ for (var _len2 = arguments.length, targets = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
1749
+ targets[_key2 - 1] = arguments[_key2];
1750
+ }
1751
+ targets.forEach(function (target) {
1752
+ return computed.set(target);
1753
+ });
1754
+ return computed;
1755
+ }
1756
+ }, {
1757
+ key: "accessor",
1758
+ value: function accessor(header) {
1759
+ var internals = this[$internals] = this[$internals] = {
1760
+ accessors: {}
1761
+ };
1762
+ var accessors = internals.accessors;
1763
+ var prototype = this.prototype;
1764
+ function defineAccessor(_header) {
1765
+ var lHeader = normalizeHeader(_header);
1766
+ if (!accessors[lHeader]) {
1767
+ buildAccessors(prototype, _header);
1768
+ accessors[lHeader] = true;
1769
+ }
1770
+ }
1771
+ utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
1772
+ return this;
1773
+ }
1774
+ }]);
1775
+ return AxiosHeaders;
1776
+ }(Symbol.iterator, Symbol.toStringTag);
1777
+ AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
1778
+ utils.freezeMethods(AxiosHeaders.prototype);
1779
+ utils.freezeMethods(AxiosHeaders);
1780
+ var AxiosHeaders$1 = AxiosHeaders;
1781
+
1782
+ /**
1783
+ * Transform the data for a request or a response
1784
+ *
1785
+ * @param {Array|Function} fns A single function or Array of functions
1786
+ * @param {?Object} response The response object
1787
+ *
1788
+ * @returns {*} The resulting transformed data
1789
+ */
1790
+ function transformData(fns, response) {
1791
+ var config = this || defaults$1;
1792
+ var context = response || config;
1793
+ var headers = AxiosHeaders$1.from(context.headers);
1794
+ var data = context.data;
1795
+ utils.forEach(fns, function transform(fn) {
1796
+ data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
1797
+ });
1798
+ headers.normalize();
1799
+ return data;
1800
+ }
1801
+
1802
+ function isCancel(value) {
1803
+ return !!(value && value.__CANCEL__);
1804
+ }
1805
+
1806
+ /**
1807
+ * A `CanceledError` is an object that is thrown when an operation is canceled.
1808
+ *
1809
+ * @param {string=} message The message.
1810
+ * @param {Object=} config The config.
1811
+ * @param {Object=} request The request.
1812
+ *
1813
+ * @returns {CanceledError} The created error.
1814
+ */
1815
+ function CanceledError(message, config, request) {
1816
+ // eslint-disable-next-line no-eq-null,eqeqeq
1817
+ AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
1818
+ this.name = 'CanceledError';
1819
+ }
1820
+ utils.inherits(CanceledError, AxiosError, {
1821
+ __CANCEL__: true
1822
+ });
1823
+
1824
+ /**
1825
+ * Resolve or reject a Promise based on response status.
1826
+ *
1827
+ * @param {Function} resolve A function that resolves the promise.
1828
+ * @param {Function} reject A function that rejects the promise.
1829
+ * @param {object} response The response.
1830
+ *
1831
+ * @returns {object} The response.
1832
+ */
1833
+ function settle(resolve, reject, response) {
1834
+ var validateStatus = response.config.validateStatus;
1835
+ if (!response.status || !validateStatus || validateStatus(response.status)) {
1836
+ resolve(response);
1837
+ } else {
1838
+ reject(new AxiosError('Request failed with status code ' + response.status, [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4], response.config, response.request, response));
1839
+ }
1840
+ }
1841
+
1842
+ var cookies = platform.isStandardBrowserEnv ?
1843
+ // Standard browser envs support document.cookie
1844
+ function standardBrowserEnv() {
1845
+ return {
1846
+ write: function write(name, value, expires, path, domain, secure) {
1847
+ var cookie = [];
1848
+ cookie.push(name + '=' + encodeURIComponent(value));
1849
+ if (utils.isNumber(expires)) {
1850
+ cookie.push('expires=' + new Date(expires).toGMTString());
1851
+ }
1852
+ if (utils.isString(path)) {
1853
+ cookie.push('path=' + path);
1854
+ }
1855
+ if (utils.isString(domain)) {
1856
+ cookie.push('domain=' + domain);
1857
+ }
1858
+ if (secure === true) {
1859
+ cookie.push('secure');
1860
+ }
1861
+ document.cookie = cookie.join('; ');
1862
+ },
1863
+ read: function read(name) {
1864
+ var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
1865
+ return match ? decodeURIComponent(match[3]) : null;
1866
+ },
1867
+ remove: function remove(name) {
1868
+ this.write(name, '', Date.now() - 86400000);
1869
+ }
1870
+ };
1871
+ }() :
1872
+ // Non standard browser env (web workers, react-native) lack needed support.
1873
+ function nonStandardBrowserEnv() {
1874
+ return {
1875
+ write: function write() {},
1876
+ read: function read() {
1877
+ return null;
1878
+ },
1879
+ remove: function remove() {}
1880
+ };
1881
+ }();
1882
+
1883
+ /**
1884
+ * Determines whether the specified URL is absolute
1885
+ *
1886
+ * @param {string} url The URL to test
1887
+ *
1888
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
1889
+ */
1890
+ function isAbsoluteURL(url) {
1891
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
1892
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
1893
+ // by any combination of letters, digits, plus, period, or hyphen.
1894
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
1895
+ }
1896
+
1897
+ /**
1898
+ * Creates a new URL by combining the specified URLs
1899
+ *
1900
+ * @param {string} baseURL The base URL
1901
+ * @param {string} relativeURL The relative URL
1902
+ *
1903
+ * @returns {string} The combined URL
1904
+ */
1905
+ function combineURLs(baseURL, relativeURL) {
1906
+ return relativeURL ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') : baseURL;
1907
+ }
1908
+
1909
+ /**
1910
+ * Creates a new URL by combining the baseURL with the requestedURL,
1911
+ * only when the requestedURL is not already an absolute URL.
1912
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
1913
+ *
1914
+ * @param {string} baseURL The base URL
1915
+ * @param {string} requestedURL Absolute or relative URL to combine
1916
+ *
1917
+ * @returns {string} The combined full path
1918
+ */
1919
+ function buildFullPath(baseURL, requestedURL) {
1920
+ if (baseURL && !isAbsoluteURL(requestedURL)) {
1921
+ return combineURLs(baseURL, requestedURL);
1922
+ }
1923
+ return requestedURL;
1924
+ }
1925
+
1926
+ var isURLSameOrigin = platform.isStandardBrowserEnv ?
1927
+ // Standard browser envs have full support of the APIs needed to test
1928
+ // whether the request URL is of the same origin as current location.
1929
+ function standardBrowserEnv() {
1930
+ var msie = /(msie|trident)/i.test(navigator.userAgent);
1931
+ var urlParsingNode = document.createElement('a');
1932
+ var originURL;
1933
+
1934
+ /**
1935
+ * Parse a URL to discover it's components
1936
+ *
1937
+ * @param {String} url The URL to be parsed
1938
+ * @returns {Object}
1939
+ */
1940
+ function resolveURL(url) {
1941
+ var href = url;
1942
+ if (msie) {
1943
+ // IE needs attribute set twice to normalize properties
1944
+ urlParsingNode.setAttribute('href', href);
1945
+ href = urlParsingNode.href;
1946
+ }
1947
+ urlParsingNode.setAttribute('href', href);
1948
+
1949
+ // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
1950
+ return {
1951
+ href: urlParsingNode.href,
1952
+ protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
1953
+ host: urlParsingNode.host,
1954
+ search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
1955
+ hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
1956
+ hostname: urlParsingNode.hostname,
1957
+ port: urlParsingNode.port,
1958
+ pathname: urlParsingNode.pathname.charAt(0) === '/' ? urlParsingNode.pathname : '/' + urlParsingNode.pathname
1959
+ };
1960
+ }
1961
+ originURL = resolveURL(window.location.href);
1962
+
1963
+ /**
1964
+ * Determine if a URL shares the same origin as the current location
1965
+ *
1966
+ * @param {String} requestURL The URL to test
1967
+ * @returns {boolean} True if URL shares the same origin, otherwise false
1968
+ */
1969
+ return function isURLSameOrigin(requestURL) {
1970
+ var parsed = utils.isString(requestURL) ? resolveURL(requestURL) : requestURL;
1971
+ return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
1972
+ };
1973
+ }() :
1974
+ // Non standard browser envs (web workers, react-native) lack needed support.
1975
+ function nonStandardBrowserEnv() {
1976
+ return function isURLSameOrigin() {
1977
+ return true;
1978
+ };
1979
+ }();
1980
+
1981
+ function parseProtocol(url) {
1982
+ var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
1983
+ return match && match[1] || '';
1984
+ }
1985
+
1986
+ /**
1987
+ * Calculate data maxRate
1988
+ * @param {Number} [samplesCount= 10]
1989
+ * @param {Number} [min= 1000]
1990
+ * @returns {Function}
1991
+ */
1992
+ function speedometer(samplesCount, min) {
1993
+ samplesCount = samplesCount || 10;
1994
+ var bytes = new Array(samplesCount);
1995
+ var timestamps = new Array(samplesCount);
1996
+ var head = 0;
1997
+ var tail = 0;
1998
+ var firstSampleTS;
1999
+ min = min !== undefined ? min : 1000;
2000
+ return function push(chunkLength) {
2001
+ var now = Date.now();
2002
+ var startedAt = timestamps[tail];
2003
+ if (!firstSampleTS) {
2004
+ firstSampleTS = now;
2005
+ }
2006
+ bytes[head] = chunkLength;
2007
+ timestamps[head] = now;
2008
+ var i = tail;
2009
+ var bytesCount = 0;
2010
+ while (i !== head) {
2011
+ bytesCount += bytes[i++];
2012
+ i = i % samplesCount;
2013
+ }
2014
+ head = (head + 1) % samplesCount;
2015
+ if (head === tail) {
2016
+ tail = (tail + 1) % samplesCount;
2017
+ }
2018
+ if (now - firstSampleTS < min) {
2019
+ return;
2020
+ }
2021
+ var passed = startedAt && now - startedAt;
2022
+ return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
2023
+ };
2024
+ }
2025
+
2026
+ function progressEventReducer(listener, isDownloadStream) {
2027
+ var bytesNotified = 0;
2028
+ var _speedometer = speedometer(50, 250);
2029
+ return function (e) {
2030
+ var loaded = e.loaded;
2031
+ var total = e.lengthComputable ? e.total : undefined;
2032
+ var progressBytes = loaded - bytesNotified;
2033
+ var rate = _speedometer(progressBytes);
2034
+ var inRange = loaded <= total;
2035
+ bytesNotified = loaded;
2036
+ var data = {
2037
+ loaded: loaded,
2038
+ total: total,
2039
+ progress: total ? loaded / total : undefined,
2040
+ bytes: progressBytes,
2041
+ rate: rate ? rate : undefined,
2042
+ estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
2043
+ event: e
2044
+ };
2045
+ data[isDownloadStream ? 'download' : 'upload'] = true;
2046
+ listener(data);
2047
+ };
2048
+ }
2049
+ var isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
2050
+ var xhrAdapter = isXHRAdapterSupported && function (config) {
2051
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
2052
+ var requestData = config.data;
2053
+ var requestHeaders = AxiosHeaders$1.from(config.headers).normalize();
2054
+ var responseType = config.responseType;
2055
+ var onCanceled;
2056
+ function done() {
2057
+ if (config.cancelToken) {
2058
+ config.cancelToken.unsubscribe(onCanceled);
2059
+ }
2060
+ if (config.signal) {
2061
+ config.signal.removeEventListener('abort', onCanceled);
2062
+ }
2063
+ }
2064
+ if (utils.isFormData(requestData) && (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv)) {
2065
+ requestHeaders.setContentType(false); // Let the browser set it
2066
+ }
2067
+
2068
+ var request = new XMLHttpRequest();
2069
+
2070
+ // HTTP basic authentication
2071
+ if (config.auth) {
2072
+ var username = config.auth.username || '';
2073
+ var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
2074
+ requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));
2075
+ }
2076
+ var fullPath = buildFullPath(config.baseURL, config.url);
2077
+ request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
2078
+
2079
+ // Set the request timeout in MS
2080
+ request.timeout = config.timeout;
2081
+ function onloadend() {
2082
+ if (!request) {
2083
+ return;
2084
+ }
2085
+ // Prepare the response
2086
+ var responseHeaders = AxiosHeaders$1.from('getAllResponseHeaders' in request && request.getAllResponseHeaders());
2087
+ var responseData = !responseType || responseType === 'text' || responseType === 'json' ? request.responseText : request.response;
2088
+ var response = {
2089
+ data: responseData,
2090
+ status: request.status,
2091
+ statusText: request.statusText,
2092
+ headers: responseHeaders,
2093
+ config: config,
2094
+ request: request
2095
+ };
2096
+ settle(function _resolve(value) {
2097
+ resolve(value);
2098
+ done();
2099
+ }, function _reject(err) {
2100
+ reject(err);
2101
+ done();
2102
+ }, response);
2103
+
2104
+ // Clean up request
2105
+ request = null;
2106
+ }
2107
+ if ('onloadend' in request) {
2108
+ // Use onloadend if available
2109
+ request.onloadend = onloadend;
2110
+ } else {
2111
+ // Listen for ready state to emulate onloadend
2112
+ request.onreadystatechange = function handleLoad() {
2113
+ if (!request || request.readyState !== 4) {
2114
+ return;
2115
+ }
2116
+
2117
+ // The request errored out and we didn't get a response, this will be
2118
+ // handled by onerror instead
2119
+ // With one exception: request that using file: protocol, most browsers
2120
+ // will return status as 0 even though it's a successful request
2121
+ if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
2122
+ return;
2123
+ }
2124
+ // readystate handler is calling before onerror or ontimeout handlers,
2125
+ // so we should call onloadend on the next 'tick'
2126
+ setTimeout(onloadend);
2127
+ };
2128
+ }
2129
+
2130
+ // Handle browser request cancellation (as opposed to a manual cancellation)
2131
+ request.onabort = function handleAbort() {
2132
+ if (!request) {
2133
+ return;
2134
+ }
2135
+ reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
2136
+
2137
+ // Clean up request
2138
+ request = null;
2139
+ };
2140
+
2141
+ // Handle low level network errors
2142
+ request.onerror = function handleError() {
2143
+ // Real errors are hidden from us by the browser
2144
+ // onerror should only fire if it's a network error
2145
+ reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
2146
+
2147
+ // Clean up request
2148
+ request = null;
2149
+ };
2150
+
2151
+ // Handle timeout
2152
+ request.ontimeout = function handleTimeout() {
2153
+ var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
2154
+ var transitional = config.transitional || transitionalDefaults;
2155
+ if (config.timeoutErrorMessage) {
2156
+ timeoutErrorMessage = config.timeoutErrorMessage;
2157
+ }
2158
+ reject(new AxiosError(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED, config, request));
2159
+
2160
+ // Clean up request
2161
+ request = null;
2162
+ };
2163
+
2164
+ // Add xsrf header
2165
+ // This is only done if running in a standard browser environment.
2166
+ // Specifically not if we're in a web worker, or react-native.
2167
+ if (platform.isStandardBrowserEnv) {
2168
+ // Add xsrf header
2169
+ var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
2170
+ if (xsrfValue) {
2171
+ requestHeaders.set(config.xsrfHeaderName, xsrfValue);
2172
+ }
2173
+ }
2174
+
2175
+ // Remove Content-Type if data is undefined
2176
+ requestData === undefined && requestHeaders.setContentType(null);
2177
+
2178
+ // Add headers to the request
2179
+ if ('setRequestHeader' in request) {
2180
+ utils.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
2181
+ request.setRequestHeader(key, val);
2182
+ });
2183
+ }
2184
+
2185
+ // Add withCredentials to request if needed
2186
+ if (!utils.isUndefined(config.withCredentials)) {
2187
+ request.withCredentials = !!config.withCredentials;
2188
+ }
2189
+
2190
+ // Add responseType to request if needed
2191
+ if (responseType && responseType !== 'json') {
2192
+ request.responseType = config.responseType;
2193
+ }
2194
+
2195
+ // Handle progress if needed
2196
+ if (typeof config.onDownloadProgress === 'function') {
2197
+ request.addEventListener('progress', progressEventReducer(config.onDownloadProgress, true));
2198
+ }
2199
+
2200
+ // Not all browsers support upload events
2201
+ if (typeof config.onUploadProgress === 'function' && request.upload) {
2202
+ request.upload.addEventListener('progress', progressEventReducer(config.onUploadProgress));
2203
+ }
2204
+ if (config.cancelToken || config.signal) {
2205
+ // Handle cancellation
2206
+ // eslint-disable-next-line func-names
2207
+ onCanceled = function onCanceled(cancel) {
2208
+ if (!request) {
2209
+ return;
2210
+ }
2211
+ reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
2212
+ request.abort();
2213
+ request = null;
2214
+ };
2215
+ config.cancelToken && config.cancelToken.subscribe(onCanceled);
2216
+ if (config.signal) {
2217
+ config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
2218
+ }
2219
+ }
2220
+ var protocol = parseProtocol(fullPath);
2221
+ if (protocol && platform.protocols.indexOf(protocol) === -1) {
2222
+ reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
2223
+ return;
2224
+ }
2225
+
2226
+ // Send the request
2227
+ request.send(requestData || null);
2228
+ });
2229
+ };
2230
+
2231
+ var knownAdapters = {
2232
+ http: httpAdapter,
2233
+ xhr: xhrAdapter
2234
+ };
2235
+ utils.forEach(knownAdapters, function (fn, value) {
2236
+ if (fn) {
2237
+ try {
2238
+ Object.defineProperty(fn, 'name', {
2239
+ value: value
2240
+ });
2241
+ } catch (e) {
2242
+ // eslint-disable-next-line no-empty
2243
+ }
2244
+ Object.defineProperty(fn, 'adapterName', {
2245
+ value: value
2246
+ });
2247
+ }
2248
+ });
2249
+ var adapters = {
2250
+ getAdapter: function getAdapter(adapters) {
2251
+ adapters = utils.isArray(adapters) ? adapters : [adapters];
2252
+ var _adapters = adapters,
2253
+ length = _adapters.length;
2254
+ var nameOrAdapter;
2255
+ var adapter;
2256
+ for (var i = 0; i < length; i++) {
2257
+ nameOrAdapter = adapters[i];
2258
+ if (adapter = utils.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter) {
2259
+ break;
2260
+ }
2261
+ }
2262
+ if (!adapter) {
2263
+ if (adapter === false) {
2264
+ throw new AxiosError("Adapter ".concat(nameOrAdapter, " is not supported by the environment"), 'ERR_NOT_SUPPORT');
2265
+ }
2266
+ throw new Error(utils.hasOwnProp(knownAdapters, nameOrAdapter) ? "Adapter '".concat(nameOrAdapter, "' is not available in the build") : "Unknown adapter '".concat(nameOrAdapter, "'"));
2267
+ }
2268
+ if (!utils.isFunction(adapter)) {
2269
+ throw new TypeError('adapter is not a function');
2270
+ }
2271
+ return adapter;
2272
+ },
2273
+ adapters: knownAdapters
2274
+ };
2275
+
2276
+ /**
2277
+ * Throws a `CanceledError` if cancellation has been requested.
2278
+ *
2279
+ * @param {Object} config The config that is to be used for the request
2280
+ *
2281
+ * @returns {void}
2282
+ */
2283
+ function throwIfCancellationRequested(config) {
2284
+ if (config.cancelToken) {
2285
+ config.cancelToken.throwIfRequested();
2286
+ }
2287
+ if (config.signal && config.signal.aborted) {
2288
+ throw new CanceledError(null, config);
2289
+ }
2290
+ }
2291
+
2292
+ /**
2293
+ * Dispatch a request to the server using the configured adapter.
2294
+ *
2295
+ * @param {object} config The config that is to be used for the request
2296
+ *
2297
+ * @returns {Promise} The Promise to be fulfilled
2298
+ */
2299
+ function dispatchRequest(config) {
2300
+ throwIfCancellationRequested(config);
2301
+ config.headers = AxiosHeaders$1.from(config.headers);
2302
+
2303
+ // Transform request data
2304
+ config.data = transformData.call(config, config.transformRequest);
2305
+ if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
2306
+ config.headers.setContentType('application/x-www-form-urlencoded', false);
2307
+ }
2308
+ var adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
2309
+ return adapter(config).then(function onAdapterResolution(response) {
2310
+ throwIfCancellationRequested(config);
2311
+
2312
+ // Transform response data
2313
+ response.data = transformData.call(config, config.transformResponse, response);
2314
+ response.headers = AxiosHeaders$1.from(response.headers);
2315
+ return response;
2316
+ }, function onAdapterRejection(reason) {
2317
+ if (!isCancel(reason)) {
2318
+ throwIfCancellationRequested(config);
2319
+
2320
+ // Transform response data
2321
+ if (reason && reason.response) {
2322
+ reason.response.data = transformData.call(config, config.transformResponse, reason.response);
2323
+ reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
2324
+ }
2325
+ }
2326
+ return Promise.reject(reason);
2327
+ });
2328
+ }
2329
+
2330
+ var headersToObject = function headersToObject(thing) {
2331
+ return thing instanceof AxiosHeaders$1 ? thing.toJSON() : thing;
2332
+ };
2333
+
2334
+ /**
2335
+ * Config-specific merge-function which creates a new config-object
2336
+ * by merging two configuration objects together.
2337
+ *
2338
+ * @param {Object} config1
2339
+ * @param {Object} config2
2340
+ *
2341
+ * @returns {Object} New object resulting from merging config2 to config1
2342
+ */
2343
+ function mergeConfig(config1, config2) {
2344
+ // eslint-disable-next-line no-param-reassign
2345
+ config2 = config2 || {};
2346
+ var config = {};
2347
+ function getMergedValue(target, source, caseless) {
2348
+ if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
2349
+ return utils.merge.call({
2350
+ caseless: caseless
2351
+ }, target, source);
2352
+ } else if (utils.isPlainObject(source)) {
2353
+ return utils.merge({}, source);
2354
+ } else if (utils.isArray(source)) {
2355
+ return source.slice();
2356
+ }
2357
+ return source;
2358
+ }
2359
+
2360
+ // eslint-disable-next-line consistent-return
2361
+ function mergeDeepProperties(a, b, caseless) {
2362
+ if (!utils.isUndefined(b)) {
2363
+ return getMergedValue(a, b, caseless);
2364
+ } else if (!utils.isUndefined(a)) {
2365
+ return getMergedValue(undefined, a, caseless);
2366
+ }
2367
+ }
2368
+
2369
+ // eslint-disable-next-line consistent-return
2370
+ function valueFromConfig2(a, b) {
2371
+ if (!utils.isUndefined(b)) {
2372
+ return getMergedValue(undefined, b);
2373
+ }
2374
+ }
2375
+
2376
+ // eslint-disable-next-line consistent-return
2377
+ function defaultToConfig2(a, b) {
2378
+ if (!utils.isUndefined(b)) {
2379
+ return getMergedValue(undefined, b);
2380
+ } else if (!utils.isUndefined(a)) {
2381
+ return getMergedValue(undefined, a);
2382
+ }
2383
+ }
2384
+
2385
+ // eslint-disable-next-line consistent-return
2386
+ function mergeDirectKeys(a, b, prop) {
2387
+ if (prop in config2) {
2388
+ return getMergedValue(a, b);
2389
+ } else if (prop in config1) {
2390
+ return getMergedValue(undefined, a);
2391
+ }
2392
+ }
2393
+ var mergeMap = {
2394
+ url: valueFromConfig2,
2395
+ method: valueFromConfig2,
2396
+ data: valueFromConfig2,
2397
+ baseURL: defaultToConfig2,
2398
+ transformRequest: defaultToConfig2,
2399
+ transformResponse: defaultToConfig2,
2400
+ paramsSerializer: defaultToConfig2,
2401
+ timeout: defaultToConfig2,
2402
+ timeoutMessage: defaultToConfig2,
2403
+ withCredentials: defaultToConfig2,
2404
+ adapter: defaultToConfig2,
2405
+ responseType: defaultToConfig2,
2406
+ xsrfCookieName: defaultToConfig2,
2407
+ xsrfHeaderName: defaultToConfig2,
2408
+ onUploadProgress: defaultToConfig2,
2409
+ onDownloadProgress: defaultToConfig2,
2410
+ decompress: defaultToConfig2,
2411
+ maxContentLength: defaultToConfig2,
2412
+ maxBodyLength: defaultToConfig2,
2413
+ beforeRedirect: defaultToConfig2,
2414
+ transport: defaultToConfig2,
2415
+ httpAgent: defaultToConfig2,
2416
+ httpsAgent: defaultToConfig2,
2417
+ cancelToken: defaultToConfig2,
2418
+ socketPath: defaultToConfig2,
2419
+ responseEncoding: defaultToConfig2,
2420
+ validateStatus: mergeDirectKeys,
2421
+ headers: function headers(a, b) {
2422
+ return mergeDeepProperties(headersToObject(a), headersToObject(b), true);
2423
+ }
2424
+ };
2425
+ utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
2426
+ var merge = mergeMap[prop] || mergeDeepProperties;
2427
+ var configValue = merge(config1[prop], config2[prop], prop);
2428
+ utils.isUndefined(configValue) && merge !== mergeDirectKeys || (config[prop] = configValue);
2429
+ });
2430
+ return config;
2431
+ }
2432
+
2433
+ var VERSION = "1.3.4";
2434
+
2435
+ var validators$1 = {};
2436
+
2437
+ // eslint-disable-next-line func-names
2438
+ ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function (type, i) {
2439
+ validators$1[type] = function validator(thing) {
2440
+ return _typeof(thing) === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
2441
+ };
2442
+ });
2443
+ var deprecatedWarnings = {};
2444
+
2445
+ /**
2446
+ * Transitional option validator
2447
+ *
2448
+ * @param {function|boolean?} validator - set to false if the transitional option has been removed
2449
+ * @param {string?} version - deprecated version / removed since version
2450
+ * @param {string?} message - some message with additional info
2451
+ *
2452
+ * @returns {function}
2453
+ */
2454
+ validators$1.transitional = function transitional(validator, version, message) {
2455
+ function formatMessage(opt, desc) {
2456
+ return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
2457
+ }
2458
+
2459
+ // eslint-disable-next-line func-names
2460
+ return function (value, opt, opts) {
2461
+ if (validator === false) {
2462
+ throw new AxiosError(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')), AxiosError.ERR_DEPRECATED);
2463
+ }
2464
+ if (version && !deprecatedWarnings[opt]) {
2465
+ deprecatedWarnings[opt] = true;
2466
+ // eslint-disable-next-line no-console
2467
+ console.warn(formatMessage(opt, ' has been deprecated since v' + version + ' and will be removed in the near future'));
2468
+ }
2469
+ return validator ? validator(value, opt, opts) : true;
2470
+ };
2471
+ };
2472
+
2473
+ /**
2474
+ * Assert object's properties type
2475
+ *
2476
+ * @param {object} options
2477
+ * @param {object} schema
2478
+ * @param {boolean?} allowUnknown
2479
+ *
2480
+ * @returns {object}
2481
+ */
2482
+
2483
+ function assertOptions(options, schema, allowUnknown) {
2484
+ if (_typeof(options) !== 'object') {
2485
+ throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
2486
+ }
2487
+ var keys = Object.keys(options);
2488
+ var i = keys.length;
2489
+ while (i-- > 0) {
2490
+ var opt = keys[i];
2491
+ var validator = schema[opt];
2492
+ if (validator) {
2493
+ var value = options[opt];
2494
+ var result = value === undefined || validator(value, opt, options);
2495
+ if (result !== true) {
2496
+ throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
2497
+ }
2498
+ continue;
2499
+ }
2500
+ if (allowUnknown !== true) {
2501
+ throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
2502
+ }
2503
+ }
2504
+ }
2505
+ var validator = {
2506
+ assertOptions: assertOptions,
2507
+ validators: validators$1
2508
+ };
2509
+
2510
+ var validators = validator.validators;
2511
+
2512
+ /**
2513
+ * Create a new instance of Axios
2514
+ *
2515
+ * @param {Object} instanceConfig The default config for the instance
2516
+ *
2517
+ * @return {Axios} A new instance of Axios
2518
+ */
2519
+ var Axios = /*#__PURE__*/function () {
2520
+ function Axios(instanceConfig) {
2521
+ _classCallCheck(this, Axios);
2522
+ this.defaults = instanceConfig;
2523
+ this.interceptors = {
2524
+ request: new InterceptorManager$1(),
2525
+ response: new InterceptorManager$1()
2526
+ };
2527
+ }
2528
+
2529
+ /**
2530
+ * Dispatch a request
2531
+ *
2532
+ * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
2533
+ * @param {?Object} config
2534
+ *
2535
+ * @returns {Promise} The Promise to be fulfilled
2536
+ */
2537
+ _createClass(Axios, [{
2538
+ key: "request",
2539
+ value: function request(configOrUrl, config) {
2540
+ /*eslint no-param-reassign:0*/
2541
+ // Allow for axios('example/url'[, config]) a la fetch API
2542
+ if (typeof configOrUrl === 'string') {
2543
+ config = config || {};
2544
+ config.url = configOrUrl;
2545
+ } else {
2546
+ config = configOrUrl || {};
2547
+ }
2548
+ config = mergeConfig(this.defaults, config);
2549
+ var _config = config,
2550
+ transitional = _config.transitional,
2551
+ paramsSerializer = _config.paramsSerializer,
2552
+ headers = _config.headers;
2553
+ if (transitional !== undefined) {
2554
+ validator.assertOptions(transitional, {
2555
+ silentJSONParsing: validators.transitional(validators["boolean"]),
2556
+ forcedJSONParsing: validators.transitional(validators["boolean"]),
2557
+ clarifyTimeoutError: validators.transitional(validators["boolean"])
2558
+ }, false);
2559
+ }
2560
+ if (paramsSerializer !== undefined) {
2561
+ validator.assertOptions(paramsSerializer, {
2562
+ encode: validators["function"],
2563
+ serialize: validators["function"]
2564
+ }, true);
2565
+ }
2566
+
2567
+ // Set config.method
2568
+ config.method = (config.method || this.defaults.method || 'get').toLowerCase();
2569
+ var contextHeaders;
2570
+
2571
+ // Flatten headers
2572
+ contextHeaders = headers && utils.merge(headers.common, headers[config.method]);
2573
+ contextHeaders && utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], function (method) {
2574
+ delete headers[method];
2575
+ });
2576
+ config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
2577
+
2578
+ // filter out skipped interceptors
2579
+ var requestInterceptorChain = [];
2580
+ var synchronousRequestInterceptors = true;
2581
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
2582
+ if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
2583
+ return;
2584
+ }
2585
+ synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
2586
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
2587
+ });
2588
+ var responseInterceptorChain = [];
2589
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
2590
+ responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
2591
+ });
2592
+ var promise;
2593
+ var i = 0;
2594
+ var len;
2595
+ if (!synchronousRequestInterceptors) {
2596
+ var chain = [dispatchRequest.bind(this), undefined];
2597
+ chain.unshift.apply(chain, requestInterceptorChain);
2598
+ chain.push.apply(chain, responseInterceptorChain);
2599
+ len = chain.length;
2600
+ promise = Promise.resolve(config);
2601
+ while (i < len) {
2602
+ promise = promise.then(chain[i++], chain[i++]);
2603
+ }
2604
+ return promise;
2605
+ }
2606
+ len = requestInterceptorChain.length;
2607
+ var newConfig = config;
2608
+ i = 0;
2609
+ while (i < len) {
2610
+ var onFulfilled = requestInterceptorChain[i++];
2611
+ var onRejected = requestInterceptorChain[i++];
2612
+ try {
2613
+ newConfig = onFulfilled(newConfig);
2614
+ } catch (error) {
2615
+ onRejected.call(this, error);
2616
+ break;
2617
+ }
2618
+ }
2619
+ try {
2620
+ promise = dispatchRequest.call(this, newConfig);
2621
+ } catch (error) {
2622
+ return Promise.reject(error);
2623
+ }
2624
+ i = 0;
2625
+ len = responseInterceptorChain.length;
2626
+ while (i < len) {
2627
+ promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
2628
+ }
2629
+ return promise;
2630
+ }
2631
+ }, {
2632
+ key: "getUri",
2633
+ value: function getUri(config) {
2634
+ config = mergeConfig(this.defaults, config);
2635
+ var fullPath = buildFullPath(config.baseURL, config.url);
2636
+ return buildURL(fullPath, config.params, config.paramsSerializer);
2637
+ }
2638
+ }]);
2639
+ return Axios;
2640
+ }(); // Provide aliases for supported request methods
2641
+ utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
2642
+ /*eslint func-names:0*/
2643
+ Axios.prototype[method] = function (url, config) {
2644
+ return this.request(mergeConfig(config || {}, {
2645
+ method: method,
2646
+ url: url,
2647
+ data: (config || {}).data
2648
+ }));
2649
+ };
2650
+ });
2651
+ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
2652
+ /*eslint func-names:0*/
2653
+
2654
+ function generateHTTPMethod(isForm) {
2655
+ return function httpMethod(url, data, config) {
2656
+ return this.request(mergeConfig(config || {}, {
2657
+ method: method,
2658
+ headers: isForm ? {
2659
+ 'Content-Type': 'multipart/form-data'
2660
+ } : {},
2661
+ url: url,
2662
+ data: data
2663
+ }));
2664
+ };
2665
+ }
2666
+ Axios.prototype[method] = generateHTTPMethod();
2667
+ Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
2668
+ });
2669
+ var Axios$1 = Axios;
2670
+
2671
+ /**
2672
+ * A `CancelToken` is an object that can be used to request cancellation of an operation.
2673
+ *
2674
+ * @param {Function} executor The executor function.
2675
+ *
2676
+ * @returns {CancelToken}
2677
+ */
2678
+ var CancelToken = /*#__PURE__*/function () {
2679
+ function CancelToken(executor) {
2680
+ _classCallCheck(this, CancelToken);
2681
+ if (typeof executor !== 'function') {
2682
+ throw new TypeError('executor must be a function.');
2683
+ }
2684
+ var resolvePromise;
2685
+ this.promise = new Promise(function promiseExecutor(resolve) {
2686
+ resolvePromise = resolve;
2687
+ });
2688
+ var token = this;
2689
+
2690
+ // eslint-disable-next-line func-names
2691
+ this.promise.then(function (cancel) {
2692
+ if (!token._listeners) return;
2693
+ var i = token._listeners.length;
2694
+ while (i-- > 0) {
2695
+ token._listeners[i](cancel);
2696
+ }
2697
+ token._listeners = null;
2698
+ });
2699
+
2700
+ // eslint-disable-next-line func-names
2701
+ this.promise.then = function (onfulfilled) {
2702
+ var _resolve;
2703
+ // eslint-disable-next-line func-names
2704
+ var promise = new Promise(function (resolve) {
2705
+ token.subscribe(resolve);
2706
+ _resolve = resolve;
2707
+ }).then(onfulfilled);
2708
+ promise.cancel = function reject() {
2709
+ token.unsubscribe(_resolve);
2710
+ };
2711
+ return promise;
2712
+ };
2713
+ executor(function cancel(message, config, request) {
2714
+ if (token.reason) {
2715
+ // Cancellation has already been requested
2716
+ return;
2717
+ }
2718
+ token.reason = new CanceledError(message, config, request);
2719
+ resolvePromise(token.reason);
2720
+ });
2721
+ }
2722
+
2723
+ /**
2724
+ * Throws a `CanceledError` if cancellation has been requested.
2725
+ */
2726
+ _createClass(CancelToken, [{
2727
+ key: "throwIfRequested",
2728
+ value: function throwIfRequested() {
2729
+ if (this.reason) {
2730
+ throw this.reason;
2731
+ }
2732
+ }
2733
+
2734
+ /**
2735
+ * Subscribe to the cancel signal
2736
+ */
2737
+ }, {
2738
+ key: "subscribe",
2739
+ value: function subscribe(listener) {
2740
+ if (this.reason) {
2741
+ listener(this.reason);
2742
+ return;
2743
+ }
2744
+ if (this._listeners) {
2745
+ this._listeners.push(listener);
2746
+ } else {
2747
+ this._listeners = [listener];
2748
+ }
2749
+ }
2750
+
2751
+ /**
2752
+ * Unsubscribe from the cancel signal
2753
+ */
2754
+ }, {
2755
+ key: "unsubscribe",
2756
+ value: function unsubscribe(listener) {
2757
+ if (!this._listeners) {
2758
+ return;
2759
+ }
2760
+ var index = this._listeners.indexOf(listener);
2761
+ if (index !== -1) {
2762
+ this._listeners.splice(index, 1);
2763
+ }
2764
+ }
2765
+
2766
+ /**
2767
+ * Returns an object that contains a new `CancelToken` and a function that, when called,
2768
+ * cancels the `CancelToken`.
2769
+ */
2770
+ }], [{
2771
+ key: "source",
2772
+ value: function source() {
2773
+ var cancel;
2774
+ var token = new CancelToken(function executor(c) {
2775
+ cancel = c;
2776
+ });
2777
+ return {
2778
+ token: token,
2779
+ cancel: cancel
2780
+ };
2781
+ }
2782
+ }]);
2783
+ return CancelToken;
2784
+ }();
2785
+ var CancelToken$1 = CancelToken;
2786
+
2787
+ /**
2788
+ * Syntactic sugar for invoking a function and expanding an array for arguments.
2789
+ *
2790
+ * Common use case would be to use `Function.prototype.apply`.
2791
+ *
2792
+ * ```js
2793
+ * function f(x, y, z) {}
2794
+ * var args = [1, 2, 3];
2795
+ * f.apply(null, args);
2796
+ * ```
2797
+ *
2798
+ * With `spread` this example can be re-written.
2799
+ *
2800
+ * ```js
2801
+ * spread(function(x, y, z) {})([1, 2, 3]);
2802
+ * ```
2803
+ *
2804
+ * @param {Function} callback
2805
+ *
2806
+ * @returns {Function}
2807
+ */
2808
+ function spread(callback) {
2809
+ return function wrap(arr) {
2810
+ return callback.apply(null, arr);
2811
+ };
2812
+ }
2813
+
2814
+ /**
2815
+ * Determines whether the payload is an error thrown by Axios
2816
+ *
2817
+ * @param {*} payload The value to test
2818
+ *
2819
+ * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
2820
+ */
2821
+ function isAxiosError(payload) {
2822
+ return utils.isObject(payload) && payload.isAxiosError === true;
2823
+ }
2824
+
2825
+ var HttpStatusCode = {
2826
+ Continue: 100,
2827
+ SwitchingProtocols: 101,
2828
+ Processing: 102,
2829
+ EarlyHints: 103,
2830
+ Ok: 200,
2831
+ Created: 201,
2832
+ Accepted: 202,
2833
+ NonAuthoritativeInformation: 203,
2834
+ NoContent: 204,
2835
+ ResetContent: 205,
2836
+ PartialContent: 206,
2837
+ MultiStatus: 207,
2838
+ AlreadyReported: 208,
2839
+ ImUsed: 226,
2840
+ MultipleChoices: 300,
2841
+ MovedPermanently: 301,
2842
+ Found: 302,
2843
+ SeeOther: 303,
2844
+ NotModified: 304,
2845
+ UseProxy: 305,
2846
+ Unused: 306,
2847
+ TemporaryRedirect: 307,
2848
+ PermanentRedirect: 308,
2849
+ BadRequest: 400,
2850
+ Unauthorized: 401,
2851
+ PaymentRequired: 402,
2852
+ Forbidden: 403,
2853
+ NotFound: 404,
2854
+ MethodNotAllowed: 405,
2855
+ NotAcceptable: 406,
2856
+ ProxyAuthenticationRequired: 407,
2857
+ RequestTimeout: 408,
2858
+ Conflict: 409,
2859
+ Gone: 410,
2860
+ LengthRequired: 411,
2861
+ PreconditionFailed: 412,
2862
+ PayloadTooLarge: 413,
2863
+ UriTooLong: 414,
2864
+ UnsupportedMediaType: 415,
2865
+ RangeNotSatisfiable: 416,
2866
+ ExpectationFailed: 417,
2867
+ ImATeapot: 418,
2868
+ MisdirectedRequest: 421,
2869
+ UnprocessableEntity: 422,
2870
+ Locked: 423,
2871
+ FailedDependency: 424,
2872
+ TooEarly: 425,
2873
+ UpgradeRequired: 426,
2874
+ PreconditionRequired: 428,
2875
+ TooManyRequests: 429,
2876
+ RequestHeaderFieldsTooLarge: 431,
2877
+ UnavailableForLegalReasons: 451,
2878
+ InternalServerError: 500,
2879
+ NotImplemented: 501,
2880
+ BadGateway: 502,
2881
+ ServiceUnavailable: 503,
2882
+ GatewayTimeout: 504,
2883
+ HttpVersionNotSupported: 505,
2884
+ VariantAlsoNegotiates: 506,
2885
+ InsufficientStorage: 507,
2886
+ LoopDetected: 508,
2887
+ NotExtended: 510,
2888
+ NetworkAuthenticationRequired: 511
2889
+ };
2890
+ Object.entries(HttpStatusCode).forEach(function (_ref) {
2891
+ var _ref2 = _slicedToArray(_ref, 2),
2892
+ key = _ref2[0],
2893
+ value = _ref2[1];
2894
+ HttpStatusCode[value] = key;
2895
+ });
2896
+ var HttpStatusCode$1 = HttpStatusCode;
2897
+
2898
+ /**
2899
+ * Create an instance of Axios
2900
+ *
2901
+ * @param {Object} defaultConfig The default config for the instance
2902
+ *
2903
+ * @returns {Axios} A new instance of Axios
2904
+ */
2905
+ function createInstance(defaultConfig) {
2906
+ var context = new Axios$1(defaultConfig);
2907
+ var instance = bind(Axios$1.prototype.request, context);
2908
+
2909
+ // Copy axios.prototype to instance
2910
+ utils.extend(instance, Axios$1.prototype, context, {
2911
+ allOwnKeys: true
2912
+ });
2913
+
2914
+ // Copy context to instance
2915
+ utils.extend(instance, context, null, {
2916
+ allOwnKeys: true
2917
+ });
2918
+
2919
+ // Factory for creating new instances
2920
+ instance.create = function create(instanceConfig) {
2921
+ return createInstance(mergeConfig(defaultConfig, instanceConfig));
2922
+ };
2923
+ return instance;
2924
+ }
2925
+
2926
+ // Create the default instance to be exported
2927
+ var axios = createInstance(defaults$1);
2928
+
2929
+ // Expose Axios class to allow class inheritance
2930
+ axios.Axios = Axios$1;
2931
+
2932
+ // Expose Cancel & CancelToken
2933
+ axios.CanceledError = CanceledError;
2934
+ axios.CancelToken = CancelToken$1;
2935
+ axios.isCancel = isCancel;
2936
+ axios.VERSION = VERSION;
2937
+ axios.toFormData = toFormData;
2938
+
2939
+ // Expose AxiosError class
2940
+ axios.AxiosError = AxiosError;
2941
+
2942
+ // alias for CanceledError for backward compatibility
2943
+ axios.Cancel = axios.CanceledError;
2944
+
2945
+ // Expose all/spread
2946
+ axios.all = function all(promises) {
2947
+ return Promise.all(promises);
2948
+ };
2949
+ axios.spread = spread;
2950
+
2951
+ // Expose isAxiosError
2952
+ axios.isAxiosError = isAxiosError;
2953
+
2954
+ // Expose mergeConfig
2955
+ axios.mergeConfig = mergeConfig;
2956
+ axios.AxiosHeaders = AxiosHeaders$1;
2957
+ axios.formToJSON = function (thing) {
2958
+ return formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
2959
+ };
2960
+ axios.HttpStatusCode = HttpStatusCode$1;
2961
+ axios["default"] = axios;
2962
+
2963
+ return axios;
2964
+
2965
+ }));
2966
+ //# sourceMappingURL=axios.js.map