@eodash/eodash 5.0.0 → 5.2.0

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