proto-sudoku-wc 0.0.481 → 0.0.482

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