lgsso-sdk 1.0.98 → 1.1.0

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