@vritti/quantum-ui 0.2.8 → 0.2.10

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