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