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