@eodash/eodash 5.6.1 → 5.7.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 (81) hide show
  1. package/core/client/components/DashboardLayout.vue +1 -1
  2. package/core/client/composables/index.js +6 -2
  3. package/core/client/eodashSTAC/EodashCollection.js +5 -25
  4. package/core/client/eodashSTAC/createLayers.js +23 -9
  5. package/core/client/eodashSTAC/helpers.js +33 -0
  6. package/core/client/types.ts +8 -1
  7. package/core/client/utils/index.js +4 -0
  8. package/dist/client/{DashboardLayout-CqMb7OXc.js → DashboardLayout-kRsmsNW5.js} +5 -5
  9. package/dist/client/{DynamicWebComponent-DqKqTf7l.js → DynamicWebComponent-CnKhYo0K.js} +1 -1
  10. package/dist/client/{EodashChart-PkUQfH0k.js → EodashChart-CLDqE93C.js} +4 -4
  11. package/dist/client/{EodashDatePicker-DLJGdTtX.js → EodashDatePicker-CMPDT-ce.js} +3 -3
  12. package/dist/client/{EodashItemFilter-Dk8KjFcX.js → EodashItemFilter-BpdA8QQa.js} +1 -1
  13. package/dist/client/{EodashLayerControl-CC1Cogrn.js → EodashLayerControl-BHpDA4_0.js} +25 -7
  14. package/dist/client/{EodashLayoutSwitcher-5WZYd6rr.js → EodashLayoutSwitcher-B1fRUt7G.js} +3 -3
  15. package/dist/client/EodashMapBtns-Cpned0tc.js +478 -0
  16. package/dist/client/{EodashStacInfo-B90wobPc.js → EodashStacInfo-BQspAHKH.js} +1 -1
  17. package/dist/client/{EodashTools-CGZtTh45.js → EodashTools-1zHz26gv.js} +4 -4
  18. package/dist/client/{ExportState-Ce0ZnrX_.js → ExportState-DbOm8hBI.js} +4 -4
  19. package/dist/client/{Footer-CnZqEiop.js → Footer-BKg-VVkj.js} +1 -1
  20. package/dist/client/{Header-Dr5PBIm8.js → Header-DCrwCvmY.js} +2 -2
  21. package/dist/client/MobileLayout-vWSHpluo.js +118 -0
  22. package/dist/client/{PopUp-DjvE_71e.js → PopUp-9uimfK49.js} +2 -2
  23. package/dist/client/{ProcessList-kf3olI7W.js → ProcessList-CTTIZa06.js} +4 -4
  24. package/dist/client/{VImg-Bj6uWt6j.js → VImg-CrmB76ZY.js} +2 -2
  25. package/dist/client/{VMain-Cm0UmKGi.js → VMain-OKZNpcEG.js} +1 -1
  26. package/dist/client/{VTooltip-DbBu-ky3.js → VTooltip-CJw2FyWk.js} +2 -2
  27. package/dist/client/{WidgetsContainer-CfLnd44U.js → WidgetsContainer-BaWOnE5R.js} +1 -1
  28. package/dist/client/{asWebComponent-DfULAbpq.js → asWebComponent-BHWpMuE3.js} +47 -39
  29. package/dist/client/{async-CIbKXEEe.js → async-DSKj6g1f.js} +21 -10
  30. package/dist/client/create-layers-config-CBoYedqB.js +182 -0
  31. package/dist/client/eo-dash.js +1 -1
  32. package/dist/client/{forwardRefs-yj3VWOK5.js → forwardRefs-DH51zPUr.js} +2 -2
  33. package/dist/client/{handling-s8xt2JwF.js → handling-BrcDDlgS.js} +123 -85
  34. package/dist/client/{helpers-DAVGYl_f.js → helpers-DjZVl_WF.js} +2273 -1500
  35. package/dist/client/{index-4TrjfJ32.js → index-1JKE68n3.js} +49 -194
  36. package/dist/client/{index-CugS__t5.js → index-5Jhsa8Xe.js} +3 -3
  37. package/dist/client/index-CSG_JoOA.js +436 -0
  38. package/dist/client/{index-CYz6dT7K.js → index-CUjl-ZsI.js} +2 -2
  39. package/dist/client/{index-Bu8BMA9q.js → index-Cu3-13Xg.js} +69 -83
  40. package/dist/client/material-symbols-outlined.woff2 +0 -0
  41. package/dist/client/material-symbols-rounded.woff2 +0 -0
  42. package/dist/client/material-symbols-sharp.woff2 +0 -0
  43. package/dist/client/material-symbols-subset.woff2 +0 -0
  44. package/dist/client/templates.js +1 -1
  45. package/dist/client/{transition-DaOsiD4u.js → transition-OHcz5Qq1.js} +1 -1
  46. package/dist/node/cli.js +1 -1
  47. package/dist/types/core/client/composables/index.d.ts +1 -3
  48. package/dist/types/core/client/eodashSTAC/EodashCollection.d.ts +6 -7
  49. package/dist/types/core/client/eodashSTAC/createLayers.d.ts +3 -3
  50. package/dist/types/core/client/eodashSTAC/helpers.d.ts +1 -0
  51. package/dist/types/core/client/types.d.ts +8 -1
  52. package/dist/types/templates/baseConfig.d.ts +12 -0
  53. package/dist/types/widgets/EodashLayerControl.vue.d.ts +1 -1
  54. package/dist/types/widgets/EodashMap/EodashMapBtns.vue.d.ts +9 -0
  55. package/dist/types/widgets/EodashMap/index.vue.d.ts +7 -0
  56. package/dist/types/widgets/EodashMap/methods/create-layers-config.d.ts +1 -8
  57. package/dist/types/widgets/EodashProcess/methods/composables.d.ts +1 -1
  58. package/dist/types/widgets/EodashProcess/methods/handling.d.ts +13 -8
  59. package/dist/types/widgets/EodashTimeSlider/index.vue.d.ts +34 -0
  60. package/dist/types/widgets/EodashTimeSlider/methods/index.d.ts +39 -0
  61. package/dist/types/widgets/EodashTimeSlider/types.d.ts +62 -0
  62. package/package.json +32 -32
  63. package/widgets/EodashLayerControl.vue +22 -3
  64. package/widgets/EodashMap/EodashMapBtns.vue +46 -1
  65. package/widgets/EodashMap/index.vue +17 -5
  66. package/widgets/EodashMap/methods/create-layers-config.js +2 -0
  67. package/widgets/EodashMap/methods/index.js +23 -5
  68. package/widgets/EodashProcess/index.vue +1 -1
  69. package/widgets/EodashProcess/methods/async.js +19 -8
  70. package/widgets/EodashProcess/methods/composables.js +63 -77
  71. package/widgets/EodashProcess/methods/custom-endpoints/chart/sentinelhub-endpoint.js +9 -5
  72. package/widgets/EodashProcess/methods/custom-endpoints/chart/veda-endpoint.js +7 -4
  73. package/widgets/EodashProcess/methods/handling.js +105 -72
  74. package/widgets/EodashTimeSlider/index.vue +152 -0
  75. package/widgets/EodashTimeSlider/methods/index.js +279 -0
  76. package/widgets/EodashTimeSlider/types.ts +64 -0
  77. package/dist/client/EodashMapBtns-BHrSDNoC.js +0 -435
  78. package/dist/client/EodashTimeSlider-5vm7F3ju.js +0 -53
  79. package/dist/client/MobileLayout-DyMjaeif.js +0 -118
  80. package/dist/types/widgets/EodashTimeSlider.vue.d.ts +0 -15
  81. package/widgets/EodashTimeSlider.vue +0 -40
@@ -0,0 +1,436 @@
1
+ import { useTemplateRef, ref, computed, onMounted, openBlock, createElementBlock, unref, createElementVNode, createCommentVNode } from 'vue';
2
+ import { a0 as removeLayers, Q as sanitizeBbox, d as axios, i as mapEl, v as getLayers, A as datetime } from './helpers-DjZVl_WF.js';
3
+ import { L as eodashCollections, _ as _export_sfc, H as useSTAcStore } from './asWebComponent-BHWpMuE3.js';
4
+ import '@eox/timecontrol';
5
+ import '@eox/itemfilter';
6
+ import { storeToRefs } from 'pinia';
7
+ import { c as createLayersConfig } from './create-layers-config-CBoYedqB.js';
8
+
9
+ /**
10
+ * @param {string} stacEndpoint
11
+ * @param {[string, string]} selectedRange
12
+ * @param {import("../types").TimelineExportEventDetail["selectedRangeItems"]} selectedRangeItems
13
+ * @param {import("vue").Ref<import("stac-ts").StacCollection|null>} selectedStac
14
+ * @param {Record<string, import("../types").Filter>} filters
15
+ */
16
+ async function createAnimationLayers(
17
+ stacEndpoint,
18
+ selectedRange,
19
+ selectedRangeItems,
20
+ selectedStac,
21
+ filters,
22
+ ) {
23
+ if (eodashCollections[0].isAPI) {
24
+ return await createAPILayers(
25
+ stacEndpoint,
26
+ { min: selectedRange[0], max: selectedRange[1] },
27
+ mapEl.value?.lonLatExtent,
28
+ selectedStac,
29
+ filters,
30
+ );
31
+ }
32
+ const { collections: hiddenCollections, layers: hiddenLayers } =
33
+ getHiddenLayers([...getLayers()]);
34
+
35
+ return await Promise.all(
36
+ Object.values(selectedRangeItems).flatMap(async (itemSet) => {
37
+ /** @type {Array<{ layers: Record<string, any>[]; date: string }>} */
38
+ const mapLayersArr = [];
39
+ for (const dateItem of itemSet) {
40
+ await createLayersConfig(
41
+ selectedStac.value,
42
+ eodashCollections.filter(
43
+ (collection) =>
44
+ !hiddenCollections.includes(collection.collectionStac?.id ?? ""),
45
+ ),
46
+ dateItem.originalDate,
47
+ ).then((layers) => {
48
+ //@ts-expect-error createLayersConfig is not typed strictly
49
+ layers = removeLayers(layers, hiddenLayers);
50
+ //@ts-expect-error createLayersConfig is not typed strictly
51
+ layers = restoreLayersVisibility(layers);
52
+ layers = anonimizeLayersCORS(layers);
53
+ mapLayersArr.push({
54
+ layers,
55
+ date: dateItem.originalDate,
56
+ });
57
+ });
58
+ }
59
+ return mapLayersArr;
60
+ }),
61
+ ).then((results) => results.flat());
62
+ }
63
+ /**
64
+ *
65
+ * @param {string} stacEndpoint
66
+ * @param {{min: string, max: string}} date
67
+ * @param {number[] | undefined} bbox
68
+ * @param {import("vue").Ref<import("stac-ts").StacCollection|null>} selectedStac
69
+ * @param {Record<string, import("../types").Filter>} filters
70
+ * @return {Promise<Array<{ layers: Record<string, any>[]; date: string }>>}
71
+ */
72
+ async function createAPILayers(
73
+ stacEndpoint,
74
+ date = { min: "", max: "" },
75
+ bbox,
76
+ selectedStac,
77
+ filters,
78
+ ) {
79
+ if (!bbox) {
80
+ return [];
81
+ }
82
+ const url = new URL(stacEndpoint + "/search");
83
+ url.searchParams.set("limit", "100");
84
+ url.searchParams.set("collections", selectedStac.value?.id ?? "");
85
+ url.searchParams.set(
86
+ "datetime",
87
+ `${new Date(date.min).toISOString()}/${new Date(date.max).toISOString()}`,
88
+ );
89
+ url.searchParams.set("bbox", sanitizeBbox(bbox).join(","));
90
+
91
+ const stacFilter = buildStacFilters(filters);
92
+ if (stacFilter) {
93
+ url.searchParams.set("filter", stacFilter);
94
+ }
95
+
96
+ /** @type {import("stac-ts").StacItem[]} */
97
+ const items = await axios
98
+ .get(url.href)
99
+ .then((res) => res.data.features)
100
+ .catch((err) => {
101
+ console.error("[eodash] Error fetching items for animation:", err);
102
+ return [];
103
+ });
104
+ if (!items || !items.length) {
105
+ console.warn("[eodash] No items found for animation.");
106
+ return [];
107
+ }
108
+ const { collections: hiddenCollections, layers: hiddenLayers } =
109
+ getHiddenLayers([...getLayers()]);
110
+ return await Promise.all(
111
+ items.map(async (item) => {
112
+ /** @type {Array<{ layers: Record<string, any>[]; date: string }>} */
113
+ const mapLayersArr = [];
114
+ await createLayersConfig(
115
+ selectedStac.value,
116
+ eodashCollections.filter(
117
+ (collection) =>
118
+ !hiddenCollections.includes(collection.collectionStac?.id ?? ""),
119
+ ),
120
+ item,
121
+ ).then((layers) => {
122
+ //@ts-expect-error createLayersConfig is not typed strictly
123
+ layers = removeLayers(layers, hiddenLayers);
124
+ //@ts-expect-error createLayersConfig is not typed strictly
125
+ layers = restoreLayersVisibility(layers);
126
+ layers = anonimizeLayersCORS(layers);
127
+ mapLayersArr.push({
128
+ layers,
129
+ date: /** @type {string} */ (item.properties.datetime),
130
+ });
131
+ return mapLayersArr;
132
+ });
133
+ return mapLayersArr;
134
+ }),
135
+ ).then((results) => results.flat());
136
+ }
137
+ /**
138
+ *
139
+ * @param {Record<string, any>[]} layers
140
+ * @returns {Record<string, any>[]}
141
+ */
142
+ function anonimizeLayersCORS(layers) {
143
+ return layers.map((layer) => {
144
+ if (layer.type === "Group") {
145
+ layer.layers = anonimizeLayersCORS(layer.layers);
146
+ return layer;
147
+ }
148
+ if (layer.source) {
149
+ layer.source.crossOrigin = "anonymous";
150
+ }
151
+ return layer;
152
+ });
153
+ }
154
+ /**
155
+ * returns the list of layers that has visibility hidden
156
+ * @param {import("@eox/map").EoxLayer[]} layers
157
+ * @returns {{ collections: string[]; layers: string[] }}
158
+ */
159
+ function getHiddenLayers(layers) {
160
+ /** @type {{ collections: string[]; layers: string[] }} */
161
+ const result = { collections: [], layers: [] };
162
+
163
+ for (const layer of layers) {
164
+ // check inner layers if it's a group layer first
165
+ if (layer.type === "Group" && Array.isArray(layer.layers)) {
166
+ const childResult = getHiddenLayers(layer.layers);
167
+ for (const col of childResult.collections) {
168
+ if (!result.collections.includes(col)) {
169
+ result.collections.push(col);
170
+ }
171
+ }
172
+ for (const lyr of childResult.layers) {
173
+ if (!result.layers.includes(lyr)) {
174
+ result.layers.push(lyr);
175
+ }
176
+ }
177
+ }
178
+
179
+ if (!layer.properties?.id) {
180
+ continue;
181
+ }
182
+
183
+ const olLayer = mapEl.value?.getLayerById(layer.properties?.id);
184
+ if (!olLayer) {
185
+ continue;
186
+ }
187
+
188
+ if (olLayer.getVisible() === false) {
189
+ const refId = layer.properties.id;
190
+ if (refId) {
191
+ if (refId.includes(";:;")) {
192
+ // Check if this looks like a typical eodash collection ID with separator
193
+ const parts = refId.split(";:;");
194
+ if (parts.length > 2) {
195
+ const prefix = parts[0];
196
+ if (!result.collections.includes(prefix)) {
197
+ result.collections.push(prefix);
198
+ }
199
+ } else {
200
+ // It has a separator but might just be a base layer like `layerId;:;EPSG`
201
+ if (!result.layers.includes(refId)) {
202
+ result.layers.push(refId);
203
+ }
204
+ }
205
+ } else {
206
+ if (!result.layers.includes(refId)) {
207
+ result.layers.push(refId);
208
+ }
209
+ }
210
+ }
211
+ }
212
+ }
213
+
214
+ return result;
215
+ }
216
+
217
+ /**
218
+ * Iterates through a list of layers and updates layer.properties.visible to true
219
+ * if it is set to false
220
+ * @param {import("@eox/map").EoxLayer[]} layers
221
+ * @returns {import("@eox/map").EoxLayer[]}
222
+ */
223
+ function restoreLayersVisibility(layers) {
224
+ for (const layer of layers) {
225
+ if (layer.properties && layer.properties.visible === false) {
226
+ layer.properties.visible = true;
227
+ }
228
+
229
+ if (layer.type === "Group" && Array.isArray(layer.layers)) {
230
+ restoreLayersVisibility(layer.layers);
231
+ }
232
+ }
233
+ return layers;
234
+ }
235
+
236
+ /**
237
+ * Build STAC API filter string from TimeSlider filters
238
+ * @param {Record<string, import("../types").Filter>} filters
239
+ * @returns {string}
240
+ */
241
+ function buildStacFilters(filters) {
242
+ if (!filters) return "";
243
+
244
+ /** @type {string[]} */
245
+ const stacFilters = [];
246
+
247
+ Object.values(filters).forEach((filter) => {
248
+ if (!filter || !filter.key) return;
249
+
250
+ // strip 'properties.' from key if present
251
+ const propName = filter.key.startsWith("properties.")
252
+ ? filter.key.replace("properties.", "")
253
+ : filter.key;
254
+
255
+ if (filter.type === "range" && filter.state) {
256
+ if (
257
+ filter.state.min !== undefined &&
258
+ filter.state.min > (filter.min ?? -Infinity)
259
+ ) {
260
+ stacFilters.push(`${propName}>=${filter.state.min}`);
261
+ }
262
+ if (
263
+ filter.state.max !== undefined &&
264
+ filter.state.max < (filter.max ?? Infinity)
265
+ ) {
266
+ stacFilters.push(`${propName}<=${filter.state.max}`);
267
+ }
268
+ } else if (filter.type === "multiselect" && filter.stringifiedState) {
269
+ if (filter.stringifiedState.length > 0) {
270
+ stacFilters.push(`${propName} IN (${filter.stringifiedState})`);
271
+ }
272
+ } else if (filter.type === "select" && filter.stringifiedState) {
273
+ if (filter.stringifiedState) {
274
+ stacFilters.push(`${propName}='${filter.stringifiedState}'`);
275
+ }
276
+ }
277
+ });
278
+
279
+ return stacFilters.join(" AND ");
280
+ }
281
+
282
+ const _style_0 = "eox-itemfilter[data-v-2fc72058]{--inline-container-height: 40px}";
283
+
284
+ const _hoisted_1 = [".for", ".animate"];
285
+ const _hoisted_2 = { class: "d-flex g-10 align-center" };
286
+ const _hoisted_3 = [".filterProperties"];
287
+
288
+
289
+ const _sfc_main = {
290
+ __name: 'index',
291
+ props: {
292
+ filters: {
293
+ /** @type {import("vue").PropType<import("@eox/itemfilter").EOxItemFilter["filterProperties"]>} */
294
+ type: Array,
295
+ default: () => [],
296
+ },
297
+ animate: {
298
+ type: Boolean,
299
+ default: true,
300
+ },
301
+ },
302
+ setup(__props) {
303
+
304
+
305
+
306
+ /** @type {import("vue").ShallowRef<HTMLElement>} */
307
+ const timesliderEl = useTemplateRef("eoxTimecontrol");
308
+
309
+ const startDate = new Date(datetime.value);
310
+ const endDate = new Date(startDate.getTime() + 24 * 60 * 60 * 1000);
311
+
312
+ const selectedRange = /** @type {import("vue").Ref<[string, string]>} */ (
313
+ ref([startDate, endDate].map((d) => d.toISOString()))
314
+ );
315
+ const initDate = [startDate.toISOString().split("T")[0]];
316
+
317
+ const hasMultipleItems = computed(() => {
318
+ return eodashCollections.some((ec) => {
319
+ const itemLinks = ec.collectionStac?.links.filter((l) => l.rel === "item");
320
+ const itemsLink = ec.collectionStac?.links.some((l) => l.rel === "items");
321
+ return (itemLinks && itemLinks.length > 1) || itemsLink;
322
+ });
323
+ });
324
+
325
+ /**
326
+ * Handles the selection event from the time control component.
327
+ * It finds the closest item to the "from" selected date
328
+ * and updates the global datetime state with that item's original date.
329
+ *
330
+ * @param {CustomEvent<import("./types").TimelineSelectionEventDetail>} e
331
+ */
332
+ const onSelect = (e) => {
333
+ const { selectedItems, date } = e.detail;
334
+ // Update the selected range with the new dates
335
+ selectedRange.value = date;
336
+
337
+ const allItems = Object.keys(selectedItems ?? {}).flatMap(
338
+ (id) => selectedItems[id],
339
+ );
340
+ if (!allItems.length) {
341
+ return;
342
+ }
343
+ const [from] = date;
344
+ const fromDate = new Date(from).getTime();
345
+
346
+ const closestItem = allItems.reduce((prev, curr) => {
347
+ const prevDiff = Math.abs(new Date(prev.originalDate).getTime() - fromDate);
348
+ const currDiff = Math.abs(new Date(curr.originalDate).getTime() - fromDate);
349
+ return currDiff < prevDiff ? curr : prev;
350
+ });
351
+
352
+ if (closestItem) {
353
+ datetime.value = closestItem.originalDate;
354
+ }
355
+ };
356
+
357
+ const { selectedStac, stacEndpoint } = storeToRefs(useSTAcStore());
358
+
359
+ /**
360
+ *
361
+ * @param {CustomEvent<import("./types").TimelineExportEventDetail>} evt
362
+ */
363
+ const onExport = async (evt) => {
364
+ const { generate, selectedRangeItems, filters } = evt.detail;
365
+
366
+ if (!stacEndpoint.value) {
367
+ return;
368
+ }
369
+
370
+ const mapLayers = await createAnimationLayers(
371
+ stacEndpoint.value,
372
+ selectedRange.value,
373
+ selectedRangeItems,
374
+ selectedStac,
375
+ filters,
376
+ );
377
+
378
+ if (!mapLayers?.length) {
379
+ console.warn("[eodash] No map layers generated for the animation.");
380
+ return;
381
+ }
382
+
383
+ generate({
384
+ mapLayers,
385
+ });
386
+ };
387
+
388
+ onMounted(() => {
389
+ const parentDiv = timesliderEl.value?.parentElement;
390
+ const layoutItem = parentDiv?.parentElement;
391
+ if (parentDiv && layoutItem && __props.animate) {
392
+ parentDiv.style.overflow = "visible";
393
+ layoutItem.style.overflow = "visible";
394
+ }
395
+ });
396
+
397
+ return (_ctx, _cache) => {
398
+ return (hasMultipleItems.value)
399
+ ? (openBlock(), createElementBlock("eox-timecontrol", {
400
+ key: unref(unref(mapEl)),
401
+ ref: "eoxTimecontrol",
402
+ ".for": unref(mapEl),
403
+ onSelect: onSelect,
404
+ titleKey: "title",
405
+ ".externalMapRendering": true,
406
+ ".animate": __props.animate,
407
+ ".initDate": initDate
408
+ }, [
409
+ createElementVNode("div", _hoisted_2, [
410
+ _cache[0] || (_cache[0] = createElementVNode("eox-timecontrol-date", { class: "flex-grow-1" }, null, -1 /* CACHED */)),
411
+ createElementVNode("eox-timecontrol-picker", {
412
+ ".range": false,
413
+ ".showDots": true,
414
+ ".showItems": true,
415
+ ".popup": true
416
+ }, null, 32 /* NEED_HYDRATION */),
417
+ (__props.filters.length)
418
+ ? (openBlock(), createElementBlock("eox-itemfilter", {
419
+ key: 0,
420
+ ".inlineMode": true,
421
+ showResults: false,
422
+ ".filterProperties": __props.filters
423
+ }, null, 40 /* PROPS, NEED_HYDRATION */, _hoisted_3))
424
+ : createCommentVNode("v-if", true),
425
+ createElementVNode("eox-timecontrol-timelapse", { onExport: onExport }, null, 32 /* NEED_HYDRATION */)
426
+ ]),
427
+ _cache[1] || (_cache[1] = createElementVNode("eox-timecontrol-timeline", { class: "mt-2" }, null, -1 /* CACHED */))
428
+ ], 40 /* PROPS, NEED_HYDRATION */, _hoisted_1))
429
+ : createCommentVNode("v-if", true)
430
+ }
431
+ }
432
+
433
+ };
434
+ const index = /*#__PURE__*/_export_sfc(_sfc_main, [['styles',[_style_0]],['__scopeId',"data-v-2fc72058"]]);
435
+
436
+ export { index as default };
@@ -1,6 +1,6 @@
1
1
  import { resolveComponent, render, h, mergeProps } from 'vue';
2
- import { a0 as consoleError, a1 as isObject } from './asWebComponent-DfULAbpq.js';
3
- import { V as VTooltip } from './VTooltip-DbBu-ky3.js';
2
+ import { $ as consoleError, a0 as isObject } from './asWebComponent-BHWpMuE3.js';
3
+ import { V as VTooltip } from './VTooltip-CJw2FyWk.js';
4
4
 
5
5
  // Utilities
6
6
  function useDirectiveComponent(component, props) {
@@ -1,15 +1,14 @@
1
- import { onMounted, watch, nextTick, ref, useTemplateRef, computed, openBlock, createElementBlock, createVNode, unref, createCommentVNode, createBlock, createElementVNode, withCtx, createTextVNode } from 'vue';
1
+ import { onMounted, watch, nextTick, onUnmounted, ref, useTemplateRef, computed, openBlock, createElementBlock, createVNode, unref, createCommentVNode, createBlock, createElementVNode, withCtx, createTextVNode } from 'vue';
2
2
  import '@eox/chart';
3
3
  import '@eox/drawtools';
4
4
  import '@eox/jsonform';
5
- import { U as eoxLayersKey, N as useOnLayersUpdate, _ as _export_sfc, H as useSTAcStore, J as VBtn } from './asWebComponent-DfULAbpq.js';
5
+ import { N as useOnLayersUpdate, _ as _export_sfc, H as useSTAcStore, J as VBtn } from './asWebComponent-BHWpMuE3.js';
6
6
  import { storeToRefs } from 'pinia';
7
- import { P as ProcessList, c as compareJobs, j as jobs } from './ProcessList-kf3olI7W.js';
8
- import EodashChart from './EodashChart-PkUQfH0k.js';
9
- import { i as initProcess, u as updateJsonformIdentifier, h as handleProcesses } from './handling-s8xt2JwF.js';
10
- import { useEventBus } from '@vueuse/core';
11
- import { u as updateJobsStatus, d as download, g as getDrawToolsProperties } from './async-CIbKXEEe.js';
12
- import { I as compareIndicator, F as indicator, S as mapCompareEl, i as mapEl, M as areChartsSeparateLayout, O as compareChartSpec, N as chartSpec } from './helpers-DAVGYl_f.js';
7
+ import { P as ProcessList, c as compareJobs, j as jobs } from './ProcessList-CTTIZa06.js';
8
+ import EodashChart from './EodashChart-CLDqE93C.js';
9
+ import { i as initProcess, u as updateJsonformIdentifier, h as handleProcesses } from './handling-BrcDDlgS.js';
10
+ import { Y as getCompareLayers, v as getLayers, H as compareIndicator, E as indicator, R as mapCompareEl, i as mapEl, L as areChartsSeparateLayout, N as compareChartSpec, M as chartSpec } from './helpers-DjZVl_WF.js';
11
+ import { u as updateJobsStatus, d as download, g as getDrawToolsProperties } from './async-DSKj6g1f.js';
13
12
  import { mdiCogPlayOutline, mdiDownloadCircleOutline } from '@mdi/js';
14
13
 
15
14
  /**
@@ -24,7 +23,7 @@ import { mdiCogPlayOutline, mdiDownloadCircleOutline } from '@mdi/js';
24
23
  * @param {import("vue").Ref<boolean>} params.isProcessed
25
24
  * @param {import("vue").Ref<boolean>} params.loading
26
25
  * @param {import("vue").Ref<boolean>} params.isPolling
27
- * @param {import("@eox/map").EOxMap | null} params.mapElement
26
+ * @param {import("vue").Ref<import("@eox/map").EOxMap | null>} params.mapElement
28
27
  */
29
28
  const useInitProcess = ({
30
29
  selectedStac,
@@ -35,60 +34,45 @@ const useInitProcess = ({
35
34
  isPolling,
36
35
  mapElement,
37
36
  }) => {
38
- const layersEvents = useEventBus(eoxLayersKey);
39
-
40
37
  onMounted(async () => {
41
- // wait for the layers to be rendered
42
- if ((mapElement?.layers.length ?? 0) > 1) {
43
- await initProcess({
44
- enableCompare: mapElement?.id === "compare",
45
- selectedStac,
46
- jsonformSchema,
47
- isProcessed,
48
- processResults,
49
- loading,
50
- isPolling,
51
- });
52
- } else {
53
- layersEvents.once(async () => {
54
- await initProcess({
55
- enableCompare: mapElement?.id === "compare",
56
- selectedStac,
57
- jsonformSchema,
58
- isProcessed,
59
- loading,
60
- processResults,
61
- isPolling,
62
- });
63
- });
64
- }
38
+ await initProcess({
39
+ enableCompare: mapElement.value?.id === "compare",
40
+ selectedStac,
41
+ jsonformSchema,
42
+ isProcessed,
43
+ processResults,
44
+ loading,
45
+ isPolling,
46
+ mapElement: mapElement.value,
47
+ });
65
48
  });
66
- const enableCompare = mapElement?.id === "compare";
67
- const evtKey = enableCompare ? "compareLayers:updated" : "layers:updated";
68
- useOnLayersUpdate(async (evt, _payload) => {
69
- if (
70
- evt == "layertime:updated" ||
71
- evt == "compareLayertime:updated" ||
72
- evt == "time:updated" ||
73
- evt == "compareTime:updated"
74
- ) {
75
- const shouldMainJsonFormUpdate =
76
- ["layertime:updated", "time:updated"].includes(evt) && !enableCompare;
77
- const shouldCompareJsonFormUpdate =
78
- ["compareLayertime:updated", "compareTime:updated"].includes(evt) &&
79
- enableCompare;
80
- // we need to update jsonform on time change in cases when the feature selection layer was time-based, so that it attaches to a correct new layer
81
- if (shouldMainJsonFormUpdate || shouldCompareJsonFormUpdate) {
82
- const newJsonForm = await updateJsonformIdentifier({
83
- jsonformSchema: jsonformSchema.value,
84
- // @ts-expect-error TODO payload coming from time update events is not an object with layers property
85
- newLayers: _payload,
86
- enableCompare,
87
- });
49
+
50
+ useOnLayersUpdate(async (evt) => {
51
+ const enableCompare = mapElement.value?.id === "compare";
52
+ const layerUpdatedKey = enableCompare
53
+ ? "compareLayers:updated"
54
+ : "layers:updated";
55
+ const timeUpdatedKeys = enableCompare
56
+ ? ["compareLayertime:updated", "compareTime:updated"]
57
+ : ["layertime:updated", "time:updated"];
58
+
59
+ if (timeUpdatedKeys.includes(evt)) {
60
+ // we need to update jsonform on time change in cases
61
+ // when the feature selection layer was time-based,
62
+ // so that it attaches to a correct new layer
63
+ const newJsonForm = await updateJsonformIdentifier({
64
+ jsonformSchema: jsonformSchema.value,
65
+ newLayers: enableCompare ? getCompareLayers() : getLayers(),
66
+ enableCompare,
67
+ mapElement: mapElement.value,
68
+ });
69
+
70
+ if (newJsonForm) {
88
71
  jsonformSchema.value = newJsonForm;
89
72
  }
90
73
  }
91
- if (evt !== evtKey) {
74
+
75
+ if (evt !== layerUpdatedKey) {
92
76
  return;
93
77
  }
94
78
  await initProcess({
@@ -99,6 +83,7 @@ const useInitProcess = ({
99
83
  processResults,
100
84
  loading,
101
85
  isPolling,
86
+ mapElement: mapElement.value,
102
87
  });
103
88
  });
104
89
  };
@@ -118,39 +103,40 @@ function useAutoExec(
118
103
  startProcess,
119
104
  ) {
120
105
  /**
121
- * @param {CustomEvent} _e
106
+ * @param {any} _e
122
107
  **/
123
108
  const onJsonFormChange = async (_e) => {
124
109
  await startProcess();
125
110
  };
126
111
 
127
- const addEventListener = async () => {
128
- await nextTick(() => {
129
- //@ts-expect-error TODO
130
- jsonformEl.value?.addEventListener("change", onJsonFormChange);
131
- });
132
- };
133
- const removeEventListener = () => {
134
- //@ts-expect-error TODO
135
- jsonformEl.value?.removeEventListener("change", onJsonFormChange);
136
- };
137
-
138
112
  watch(jsonformSchema, (updatedSchema) => {
139
113
  autoExec.value = updatedSchema?.options?.["execute"] || false;
140
114
  });
141
115
 
142
- onMounted(() => {
143
- watch(
144
- autoExec,
145
- async (exec) => {
146
- if (exec) {
147
- await addEventListener();
148
- } else {
149
- removeEventListener();
150
- }
151
- },
152
- { immediate: true },
153
- );
116
+ // Re-attach listener whenever the element or autoExec changes
117
+ const stop = watch(
118
+ [autoExec, jsonformEl],
119
+ async ([exec, el], [_prevExec, prevEl]) => {
120
+ // Cleanup if previous element existed
121
+ if (prevEl) {
122
+ prevEl.removeEventListener("change", onJsonFormChange);
123
+ }
124
+ // Add if enabled and we have an element
125
+ if (exec && el) {
126
+ // remove listener before adding to avoid duplicates in case of element change
127
+ el.removeEventListener("change", onJsonFormChange);
128
+ await nextTick();
129
+ el.addEventListener("change", onJsonFormChange);
130
+ }
131
+ },
132
+ { immediate: true },
133
+ );
134
+
135
+ onUnmounted(() => {
136
+ if (jsonformEl.value) {
137
+ jsonformEl.value.removeEventListener("change", onJsonFormChange);
138
+ }
139
+ stop();
154
140
  });
155
141
  }
156
142
 
@@ -224,7 +210,7 @@ const jsonformKey = computed(
224
210
 
225
211
  useInitProcess({
226
212
  selectedStac: currentSelectedStac,
227
- mapElement: mapElement.value,
213
+ mapElement,
228
214
  jsonformSchema,
229
215
  isProcessed,
230
216
  processResults,
@@ -1,5 +1,5 @@
1
1
  import { mdiViewDashboardVariant, mdiViewDashboard } from '@mdi/js';
2
- import { P as includesProcess, Q as shouldShowChartWidget } from './helpers-DAVGYl_f.js';
2
+ import { O as includesProcess, P as shouldShowChartWidget } from './helpers-DjZVl_WF.js';
3
3
 
4
4
  /**
5
5
  * Special values that tell deepmerge to perform a certain action.
@@ -1,5 +1,5 @@
1
1
  import { mergeProps, h, TransitionGroup, Transition } from 'vue';
2
- import { p as propsFactory, a1 as isObject, aH as onlyDefinedProps } from './asWebComponent-DfULAbpq.js';
2
+ import { p as propsFactory, a0 as isObject, aH as onlyDefinedProps } from './asWebComponent-BHWpMuE3.js';
3
3
 
4
4
  // Utilities
5
5
  const makeTransitionProps = propsFactory({