@feedmepos/mf-report 5.21.2-beta.0 → 5.21.3-beta.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.
@@ -0,0 +1,2426 @@
1
+ import { computed as x, defineComponent as Le, mergeModels as Ie, useModel as Me, ref as f, onMounted as Ue, nextTick as we, watch as he, resolveComponent as H, createElementBlock as te, openBlock as $, Fragment as be, renderSlot as Ne, createVNode as B, normalizeStyle as Ee, unref as s, createElementVNode as O, toDisplayString as Te, withCtx as oe, createBlock as re, createCommentVNode as Fe, normalizeClass as qe, h as st, renderList as nt, toRaw as fl, markRaw as vl, createTextVNode as ht, onUnmounted as gl, resolveDynamicComponent as yl, withDirectives as bl, vShow as wl, withModifiers as ct } from "vue";
2
+ import { W as A, e as et, f as xl, S as Be, v as ot, g as Sl, h as dt, i as Bt, q as Ht, R as je, j as Cl, D as ze, c as pe, C as Ce, a as kl, b as _l, _ as Tl } from "./BaseDialog.vue_vue_type_script_setup_true_lang-Ccrz29qZ.js";
3
+ import { u as tt, b as Qe, a as St, d as Je, i as Fl } from "./vue-i18n-BJW_sJot.js";
4
+ import { d as Mt, _ as Ll, a as Dl, b as Rl, c as Vl } from "./DateRangeSelect.vue_vue_type_script_setup_true_lang-BeBr4VIF.js";
5
+ import { storeToRefs as $e, defineStore as Ot } from "pinia";
6
+ import { useBreakpoints as qt, useSnackbar as Ct, components as zl } from "@feedmepos/ui-library";
7
+ import { a as $l } from "./SelectComponent.vue_vue_type_script_setup_true_lang-BcQEW5MO.js";
8
+ import { r as He } from "./i18n-DQxDgiLO.js";
9
+ import { _ as ft } from "./NoData.vue_vue_type_script_setup_true_lang-CtN7oqXx.js";
10
+ var vt = /* @__PURE__ */ ((e) => (e.line = "LINE", e.bar = "BAR", e))(vt || {}), Pe = /* @__PURE__ */ ((e) => (e.top = "TOP", e.bottom = "BOTTOM", e))(Pe || {}), gt = /* @__PURE__ */ ((e) => (e.start = "start", e.center = "center", e.end = "end", e))(gt || {}), yt = /* @__PURE__ */ ((e) => (e.start = "start", e.center = "center", e.end = "end", e.left = "left", e.right = "right", e.top = "top", e.bottom = "bottom", e))(yt || {}), bt = /* @__PURE__ */ ((e) => (e.top = "top", e.bottom = "bottom", e))(bt || {}), wt = /* @__PURE__ */ ((e) => (e.right = "right", e.left = "left", e))(wt || {}), xt = /* @__PURE__ */ ((e) => (e.top = "top", e.bottom = "bottom", e.right = "right", e.left = "left", e.chartArea = "chartArea", e))(xt || {});
11
+ A.Circular, A.Table, A.BarChart, A.LineChart, A.StackBarChart, A.StackLineChart, A.Scorecard, A.Spacer;
12
+ const Al = [
13
+ {
14
+ type: A.Circular,
15
+ showLabel: !1,
16
+ // TODO: temporarily removed show label as it has no function
17
+ showDrillDimension: !0,
18
+ showRollup: !1,
19
+ showSearchBar: !1
20
+ },
21
+ {
22
+ type: A.Table,
23
+ showLabel: !1,
24
+ showDrillDimension: !0,
25
+ showRollup: !0,
26
+ showSearchBar: !0
27
+ },
28
+ {
29
+ type: A.BarChart,
30
+ showLabel: !1,
31
+ // TODO: temporarily removed show label as it has no function
32
+ showDrillDimension: !0,
33
+ showRollup: !1,
34
+ showSearchBar: !1
35
+ },
36
+ {
37
+ type: A.LineChart,
38
+ showLabel: !1,
39
+ // TODO: temporarily removed show label as it has no function
40
+ showDrillDimension: !0,
41
+ showRollup: !0,
42
+ showSearchBar: !1
43
+ },
44
+ {
45
+ type: A.StackBarChart,
46
+ showLabel: !1,
47
+ // TODO: temporarily removed show label as it has no function
48
+ showDrillDimension: !0,
49
+ showRollup: !0,
50
+ showSearchBar: !1
51
+ },
52
+ {
53
+ type: A.StackLineChart,
54
+ showLabel: !1,
55
+ // TODO: temporarily removed show label as it has no function
56
+ showDrillDimension: !0,
57
+ showRollup: !0,
58
+ showSearchBar: !1
59
+ },
60
+ {
61
+ type: A.Scorecard,
62
+ showLabel: !1,
63
+ showDrillDimension: !1,
64
+ showRollup: !1,
65
+ showSearchBar: !1
66
+ },
67
+ {
68
+ type: A.Spacer,
69
+ showLabel: !1,
70
+ showDrillDimension: !1,
71
+ showRollup: !1,
72
+ showSearchBar: !1
73
+ }
74
+ ];
75
+ function mt(e) {
76
+ const a = [e.schemaName, e.name];
77
+ return "option" in e && e.option && a.push(e.option), "aggregation" in e && e.aggregation && a.push(e.aggregation), a.push(e.label.replace(/[^a-zA-Z0-9]/g, "")), a.join("_").toLowerCase();
78
+ }
79
+ function El(e, a) {
80
+ switch (e) {
81
+ case A.BarChart:
82
+ case A.LineChart:
83
+ case A.StackBarChart:
84
+ case A.StackLineChart:
85
+ return Array.isArray(a == null ? void 0 : a.datasets) && Array.isArray(a == null ? void 0 : a.xAxis) && a.datasets.length > 0 && a.xAxis.length > 0;
86
+ case A.Table:
87
+ return Array.isArray(a == null ? void 0 : a.rows) && Array.isArray(a == null ? void 0 : a.columns) && a.rows.length > 0 && a.columns.length > 0;
88
+ case A.Circular:
89
+ return Array.isArray(a == null ? void 0 : a.datasets) && a.datasets.length > 0;
90
+ case A.Scorecard:
91
+ return !0;
92
+ case A.Spacer:
93
+ return !0;
94
+ }
95
+ }
96
+ const It = [
97
+ "54, 162, 235",
98
+ //8CE6D7
99
+ "0, 123, 167",
100
+ //007BA7
101
+ "255, 93, 83",
102
+ //FF5D53
103
+ "115, 200, 230",
104
+ //73C8E6
105
+ "252, 162, 62",
106
+ //FCA23E
107
+ "240, 155, 190",
108
+ //F09BBE
109
+ "255, 210, 50",
110
+ //FFD232
111
+ "80, 190, 155",
112
+ //50BE9B
113
+ "131, 88, 212",
114
+ //8358D4
115
+ "155, 80, 70"
116
+ //9B5046
117
+ ];
118
+ function Ae({
119
+ index: e,
120
+ isCompare: a,
121
+ opacity: n
122
+ }) {
123
+ let l = typeof n == "number" ? n : 1;
124
+ return a && (l = l * 0.6), `rgba(${It[e % It.length]}, ${l})`;
125
+ }
126
+ function Ut(e, a, n) {
127
+ if (e === "" || a === "")
128
+ return null;
129
+ let l = (D) => D == null ? void 0 : D.replace(/,/g, "");
130
+ n === "ID" && (l = (D) => D == null ? void 0 : D.replace(/\./g, "").replace(/,/g, "."));
131
+ const y = Number(l(e)), S = Number(l(a));
132
+ if (isNaN(y) || isNaN(S))
133
+ return null;
134
+ let R = 0;
135
+ S === 0 ? y === 0 ? R = 0 : R = 1 : R = (y - S) / S;
136
+ const V = Ml(R);
137
+ return {
138
+ value: isNaN(R) ? "" : `${(R * 100).toFixed(0)}%`,
139
+ icon: V
140
+ };
141
+ }
142
+ function Ml(e) {
143
+ return e > 0 ? {
144
+ name: "moving",
145
+ color: "#1F7735",
146
+ tailwind: "fm-color-system-success-100"
147
+ } : e < 0 ? {
148
+ name: "trending_down",
149
+ color: "#99231D",
150
+ tailwind: "fm-color-system-error-100"
151
+ } : {
152
+ name: "equal",
153
+ color: "#C7C7CC",
154
+ tailwind: "fm-color-neutral-gray-100"
155
+ };
156
+ }
157
+ function lt(e) {
158
+ function a(i, c, m) {
159
+ if (i.measureText(c).width <= m) return c;
160
+ const d = "…";
161
+ let _ = 0, F = c.length;
162
+ for (; _ < F; ) {
163
+ const C = Math.floor((_ + F) / 2), g = c.slice(0, C) + d;
164
+ i.measureText(g).width <= m ? _ = C + 1 : F = C;
165
+ }
166
+ return c.slice(0, _ - 1) + d;
167
+ }
168
+ const n = x(() => ({
169
+ display: e.showLabel,
170
+ align: e.labelAlign,
171
+ anchor: e.labelAnchor,
172
+ rotation: e.labelRotation,
173
+ offset: e.labelOffset,
174
+ font: {
175
+ size: e.labelFontSize
176
+ },
177
+ color: (i) => {
178
+ const c = i.chart.data.datasets[i.datasetIndex];
179
+ return c.borderColor ? Array.isArray(c.borderColor) ? c.borderColor[i.dataIndex] : c.borderColor : c.backgroundColor ? Array.isArray(c.backgroundColor) ? c.backgroundColor[i.dataIndex] : c.backgroundColor : "#000";
180
+ },
181
+ formatter: (i) => i === 0 ? "" : i.toLocaleString("en-US")
182
+ })), l = x(() => ({
183
+ display: e.showX,
184
+ position: e.xPosition,
185
+ grid: {
186
+ display: e.showXGrid
187
+ },
188
+ ticks: {
189
+ display: e.showXTick,
190
+ callback: function(i) {
191
+ if ((e == null ? void 0 : e.isTransposed) === !0) return String(i);
192
+ let m = String(i);
193
+ const d = this;
194
+ d && typeof d.getLabelForValue == "function" && (m = d.getLabelForValue(i));
195
+ const _ = d == null ? void 0 : d.chart, F = d == null ? void 0 : d.ctx, C = _.height * 0.25;
196
+ if (F && C > 0) {
197
+ F.save();
198
+ const W = F.measureText(m).width > C ? a(F, m, C) : m;
199
+ return F.restore(), W;
200
+ }
201
+ return m;
202
+ },
203
+ font: {
204
+ size: e.xTickFontSize
205
+ }
206
+ },
207
+ title: {
208
+ display: e.showXTitle,
209
+ text: e.xTitle,
210
+ font: {
211
+ size: e.xTitleFontSize
212
+ }
213
+ },
214
+ afterBuildTicks: (i) => {
215
+ const c = Array.isArray(i == null ? void 0 : i.ticks) ? i.ticks : [];
216
+ if (c.length === 0) return;
217
+ const m = i.getLabelForValue(c[0].value), d = !isNaN(Number(m));
218
+ i.options.ticks.minRotation = d || c.length < 10 ? 0 : 90;
219
+ },
220
+ afterFit: (i) => {
221
+ if (!(e != null && e.isTransposed)) {
222
+ const c = i.chart.height * 0.4;
223
+ i.height > c && (i.height = c);
224
+ }
225
+ }
226
+ })), y = x(() => ({
227
+ display: e.showY,
228
+ position: e.yPosition,
229
+ grid: {
230
+ display: e.showYGrid
231
+ },
232
+ ticks: {
233
+ display: e.showYTick,
234
+ font: {
235
+ size: e.yTickFontSize
236
+ },
237
+ callback: function(i) {
238
+ if (!((e == null ? void 0 : e.isTransposed) === !0)) return String(i);
239
+ let m = String(i);
240
+ const d = this;
241
+ d && typeof d.getLabelForValue == "function" && (m = d.getLabelForValue(i));
242
+ const _ = d == null ? void 0 : d.chart, F = d == null ? void 0 : d.ctx, C = _.width * 0.4;
243
+ if (F && C > 0) {
244
+ F.save();
245
+ const W = F.measureText(m).width > C ? a(F, m, C) : m;
246
+ return F.restore(), W;
247
+ }
248
+ return m;
249
+ }
250
+ },
251
+ title: {
252
+ display: e.showYTitle,
253
+ text: e.yTitle,
254
+ font: {
255
+ size: e.yTitleFontSize
256
+ }
257
+ }
258
+ })), S = x(() => ({
259
+ display: e.showLegend,
260
+ position: e.legendPosition,
261
+ usePointStyle: e.usePointStyle,
262
+ maxHeight: e.legendMaxHeight,
263
+ maxWidth: e.legendMaxWidth,
264
+ labels: {
265
+ usePointStyle: e.usePointStyle ?? !0,
266
+ generateLabels: (i) => {
267
+ var m;
268
+ const c = ((m = i == null ? void 0 : i.data) == null ? void 0 : m.datasets) || [];
269
+ if (c.length === 0) return [];
270
+ if (c.length === 1 && Array.isArray(c[0].backgroundColor) && c[0].backgroundColor.length > 1 && Array.isArray(c[0].data)) {
271
+ const d = c[0];
272
+ return i.data.labels.map((F, C) => {
273
+ const g = d.backgroundColor[C];
274
+ return {
275
+ text: F,
276
+ fontColor: "#6b6b6b",
277
+ fillStyle: g,
278
+ strokeStyle: g,
279
+ datasetIndex: 0,
280
+ index: C,
281
+ hidden: i.getDataVisibility ? !i.getDataVisibility(C) : !1
282
+ };
283
+ });
284
+ }
285
+ return i.data.datasets.map((d, _) => {
286
+ const F = d.borderColor || d.backgroundColor;
287
+ return {
288
+ text: d.label,
289
+ fontColor: "#6b6b6b",
290
+ fillStyle: F,
291
+ strokeStyle: F,
292
+ datasetIndex: _,
293
+ hidden: !i.isDatasetVisible(_)
294
+ };
295
+ });
296
+ }
297
+ }
298
+ })), R = x(() => e.isTransposed), V = x(() => e.chartWidth), D = x(() => e.chartHeight);
299
+ return { datalabels: n, xCfg: l, yCfg: y, isTransposed: R, legend: S, chartWidth: V, chartHeight: D };
300
+ }
301
+ const Il = /* @__PURE__ */ Le({
302
+ __name: "WidgetBarchart",
303
+ props: /* @__PURE__ */ Ie({
304
+ tileIndex: {}
305
+ }, {
306
+ modelValue: { required: !0 },
307
+ modelModifiers: {}
308
+ }),
309
+ emits: ["update:modelValue"],
310
+ setup(e) {
311
+ const a = e, n = Me(e, "modelValue"), l = f(null), y = x(() => {
312
+ var g;
313
+ return ((g = n.value.data) == null ? void 0 : g.xAxis) ?? [];
314
+ }), S = x(() => {
315
+ var g;
316
+ return ((g = n.value.data) == null ? void 0 : g.datasets) ?? [];
317
+ }), { datalabels: R, xCfg: V, yCfg: D, isTransposed: i, legend: c, chartWidth: m, chartHeight: d } = lt(
318
+ n.value
319
+ ), _ = x(() => S.value.length > 0 ? [
320
+ ...S.value.map((g, W) => ({
321
+ label: g.name,
322
+ data: g.values,
323
+ dash: !!g.isCompare,
324
+ backgroundColor: Ae({ index: W, isCompare: g.isCompare })
325
+ }))
326
+ ] : []), F = et();
327
+ function C() {
328
+ return F.extractChartSize(l.value, a.tileIndex) || { width: 0, height: 0 };
329
+ }
330
+ return Ue(() => {
331
+ we(() => {
332
+ C();
333
+ });
334
+ }), he([_], () => {
335
+ we(() => C());
336
+ }), (g, W) => {
337
+ const v = H("FmBarChart");
338
+ return $(), te(be, null, [
339
+ Ne(g.$slots, "menu"),
340
+ B(v, {
341
+ ref_key: "chartRef",
342
+ ref: l,
343
+ class: "bar-chart",
344
+ datasets: _.value,
345
+ "x-axis": { categories: y.value },
346
+ "x-cfg": s(V),
347
+ "y-cfg": s(D),
348
+ transpose: s(i),
349
+ legend: {
350
+ display: s(c).display ?? !1,
351
+ position: s(c).position,
352
+ maxHeight: s(c).maxHeight,
353
+ maxWidth: s(c).maxWidth,
354
+ labels: s(c).labels
355
+ },
356
+ datalabels: s(R),
357
+ "maintain-aspect-ratio": !1,
358
+ style: Ee({
359
+ "--chart-width": s(m) !== void 0 ? s(m) + "px" : "100%",
360
+ "--chart-height": s(d) !== void 0 ? s(d) + "px" : "calc(100% - 36px)"
361
+ })
362
+ }, null, 8, ["datasets", "x-axis", "x-cfg", "y-cfg", "transpose", "legend", "datalabels", "style"])
363
+ ], 64);
364
+ };
365
+ }
366
+ }), Nl = /* @__PURE__ */ Le({
367
+ __name: "WidgetCircular",
368
+ props: /* @__PURE__ */ Ie({
369
+ tileIndex: {}
370
+ }, {
371
+ modelValue: { required: !0 },
372
+ modelModifiers: {}
373
+ }),
374
+ emits: ["update:modelValue"],
375
+ setup(e) {
376
+ const a = e, n = Me(e, "modelValue"), { breakpoints: l } = qt(), y = f(null), { datalabels: S, legend: R, chartWidth: V, chartHeight: D } = lt(n.value), i = x(() => {
377
+ let _ = [];
378
+ return n.value.data.datasets && n.value.data.metrics && n.value.data.datasets.length > 0 && n.value.data.metrics.length > 0 && (_ = [
379
+ {
380
+ label: n.value.data.metrics[0],
381
+ data: n.value.data.datasets.map((F) => F.value),
382
+ backgroundColor: n.value.data.datasets.map((F, C) => Ae({ index: C }))
383
+ }
384
+ ]), _;
385
+ }), c = et();
386
+ function m() {
387
+ return c.extractChartSize(y.value, a.tileIndex) || { width: 0, height: 0 };
388
+ }
389
+ Ue(() => {
390
+ we(() => {
391
+ m();
392
+ });
393
+ }), he([i], () => {
394
+ we(() => m());
395
+ });
396
+ const d = x(() => l.value.lg ? 12 : 8);
397
+ return (_, F) => {
398
+ const C = H("FmPieChart");
399
+ return $(), te(be, null, [
400
+ Ne(_.$slots, "menu"),
401
+ B(C, {
402
+ ref_key: "chartRef",
403
+ ref: y,
404
+ class: "circular",
405
+ percentage: "70%",
406
+ datasets: i.value,
407
+ metrics: n.value.data.datasets.map((g) => g.name),
408
+ variant: "doughnut",
409
+ legend: {
410
+ display: s(R).display ?? !0,
411
+ position: s(R).position ?? "top",
412
+ maxHeight: s(R).maxHeight,
413
+ maxWidth: s(R).maxWidth,
414
+ labels: {
415
+ ...s(R).labels,
416
+ font: {
417
+ size: d.value
418
+ }
419
+ }
420
+ },
421
+ datalabels: s(S),
422
+ "maintain-aspect-ratio": !1,
423
+ style: Ee({
424
+ "--chart-width": s(V) !== void 0 ? s(V) + "px" : "100%",
425
+ "--chart-height": s(D) !== void 0 ? s(D) + "px" : "calc(100% - 36px)"
426
+ })
427
+ }, null, 8, ["datasets", "metrics", "legend", "datalabels", "style"])
428
+ ], 64);
429
+ };
430
+ }
431
+ }), Wl = { class: "flex flex-col gap-1" }, Pl = { class: "fm-typo-en-title-sm-600" }, Bl = { class: "flex gap-2" }, Hl = { key: 0 }, Ol = { key: 1 }, ql = /* @__PURE__ */ Le({
432
+ __name: "WidgetScorecard",
433
+ props: {
434
+ modelValue: { required: !0 },
435
+ modelModifiers: {}
436
+ },
437
+ emits: ["update:modelValue"],
438
+ setup(e) {
439
+ const a = Me(e, "modelValue"), { t: n } = tt(), { compareDateRange: l, defaultDateSetting: y } = $e(Qe()), { country: S } = St(), R = x(() => {
440
+ var m;
441
+ return ((m = a.value.data) == null ? void 0 : m.value) || "";
442
+ }), V = x(() => {
443
+ const { data: m } = a.value;
444
+ return m != null && m.comparison ? Ut(R.value, m.comparison, S) : null;
445
+ });
446
+ function D(m) {
447
+ switch (m) {
448
+ case vt.bar:
449
+ return "bar";
450
+ case vt.line:
451
+ return "line";
452
+ default:
453
+ return "line";
454
+ }
455
+ }
456
+ const i = x(() => {
457
+ var m;
458
+ return (m = a.value.data) == null ? void 0 : m.sparkline;
459
+ }), c = x(() => i.value.datasets.map((m) => ({
460
+ label: m.name,
461
+ data: m.values,
462
+ fill: !0,
463
+ color: "#36a2eb"
464
+ })));
465
+ return (m, d) => {
466
+ var W;
467
+ const _ = H("FmIcon"), F = H("FmChip"), C = H("FmTooltip"), g = H("FmLineChart");
468
+ return $(), te("div", Wl, [
469
+ Ne(m.$slots, "menu"),
470
+ O("p", Pl, Te(R.value), 1),
471
+ O("div", Bl, [
472
+ B(C, {
473
+ content: `vs. ${(W = s(y).defaultCompareType) == null ? void 0 : W.split("_").join(" ")}`,
474
+ placement: "right",
475
+ "hide-arrow": "",
476
+ variant: "plain"
477
+ }, {
478
+ default: oe(() => [
479
+ V.value ? ($(), re(F, {
480
+ key: 0,
481
+ icon: V.value.icon.name,
482
+ class: qe(`bg-${V.value.icon.tailwind}`),
483
+ compact: ""
484
+ }, {
485
+ default: oe(() => [
486
+ B(_, {
487
+ name: V.value.icon.name,
488
+ color: V.value.icon.color
489
+ }, null, 8, ["name", "color"]),
490
+ O("p", {
491
+ class: "fm-typo-en-body-md-600",
492
+ style: Ee({ color: V.value.icon.color })
493
+ }, Te(V.value.value), 5)
494
+ ]),
495
+ _: 1
496
+ }, 8, ["icon", "class"])) : Fe("", !0),
497
+ s(l).endDate !== null && s(l).startDate !== null && V.value === null ? ($(), re(F, {
498
+ key: 1,
499
+ compact: ""
500
+ }, {
501
+ default: oe(() => [
502
+ B(_, {
503
+ name: "arrow_upward",
504
+ color: "#C7C7CC"
505
+ }),
506
+ d[0] || (d[0] = O("p", { class: "fm-typo-en-body-md-600 text-fm-color-typo-disabled" }, "N/A", -1))
507
+ ]),
508
+ _: 1
509
+ })) : Fe("", !0)
510
+ ]),
511
+ _: 1
512
+ }, 8, ["content"])
513
+ ]),
514
+ i.value ? ($(), te("div", Hl, [
515
+ D(i.value.type) === "line" ? ($(), re(g, {
516
+ key: 0,
517
+ class: "sparkline",
518
+ datasets: c.value,
519
+ legend: {
520
+ display: !1
521
+ },
522
+ datalabels: { display: !1 },
523
+ "x-axis": { categories: i.value.dimensions },
524
+ "y-cfg": { display: !1 },
525
+ "x-cfg": { display: !1 },
526
+ "maintain-aspect-ratio": !1
527
+ }, null, 8, ["datasets", "x-axis"])) : Fe("", !0)
528
+ ])) : ($(), te("div", Ol, d[1] || (d[1] = [
529
+ O("div", { class: "sparkline" }, [
530
+ O("div", { class: "flex flex-col gap-8" }, [
531
+ O("div"),
532
+ O("div")
533
+ ]),
534
+ O("div", { class: "grow" })
535
+ ], -1)
536
+ ])))
537
+ ]);
538
+ };
539
+ }
540
+ }), Ul = {};
541
+ function Gl(e, a) {
542
+ const n = H("FmMenuDivider");
543
+ return $(), re(n);
544
+ }
545
+ const Yl = /* @__PURE__ */ $l(Ul, [["render", Gl]]), Xl = "mf-reporttable-dimension", Nt = Ot(Xl, () => {
546
+ const e = f(0), a = f([]), n = f(!1), l = (v, o) => {
547
+ e.value = v, S(v, o);
548
+ }, y = (v, o, k, p) => {
549
+ a[v] = o, a.value = [...a.value], R(v, o, k, p);
550
+ }, S = (v, o) => {
551
+ const k = (o == null ? void 0 : o.querySelectorAll("thead tr")) ?? [], p = (o == null ? void 0 : o.querySelectorAll("tbody tr")) ?? [];
552
+ [...k, ...p].forEach((U) => {
553
+ const J = U;
554
+ J && (J.style.height = `${v}px`);
555
+ });
556
+ }, R = (v, o, k, p = !1) => {
557
+ const L = (k == null ? void 0 : k.querySelectorAll("th")) ?? [];
558
+ if (v === void 0) return;
559
+ const U = L[v], J = p ? a[v] : o;
560
+ if (!U || J === void 0) return;
561
+ const ee = () => {
562
+ U.style.width = `${J}px`;
563
+ };
564
+ p ? requestAnimationFrame(ee) : ee();
565
+ }, V = () => {
566
+ const v = document.querySelectorAll("th"), o = document.querySelectorAll("td"), k = document.querySelector("table");
567
+ k == null || k.classList.add("table-fixed"), v.forEach((p) => p.classList.add("toggleEditResize")), o.forEach((p) => p.classList.add("toggleEditResize")), n.value = !0;
568
+ }, D = () => {
569
+ const v = document.querySelectorAll("th"), o = document.querySelectorAll("td"), k = document.querySelectorAll(".col-resize-handle"), p = document.querySelectorAll(".row-resize-handle");
570
+ v.forEach((L) => L.classList.remove("toggleEditResize")), o.forEach((L) => L.classList.remove("toggleEditResize")), k.forEach((L) => L.remove()), p.forEach((L) => L.remove()), n.value = !1;
571
+ }, i = () => {
572
+ e.value = 0, a.value = [];
573
+ }, c = (v, o) => {
574
+ if (o) {
575
+ const k = document.querySelectorAll(`thead th:nth-child(${v + 1})`), p = document.querySelectorAll(`tbody td:nth-child(${v + 1})`);
576
+ [...k, ...p].forEach((L) => {
577
+ L.classList.add("highlight-hover-col");
578
+ });
579
+ } else
580
+ document.querySelectorAll(
581
+ `thead th:nth-child(${v + 1}), tbody td:nth-child(${v + 1})`
582
+ ).forEach((k) => k.classList.add("highlight-col"));
583
+ }, m = (v) => {
584
+ const o = document.querySelectorAll("thead tr"), k = document.querySelectorAll("tbody tr"), p = [...o, ...k];
585
+ for (const L of p)
586
+ v ? L.classList.add("highlight-hover-row") : L.classList.add("highlight-row");
587
+ }, d = (v) => {
588
+ const o = v ? ".highlight-hover-row" : ".highlight-row", k = document.querySelectorAll(o);
589
+ for (const p of k)
590
+ p.classList.remove(o.slice(1));
591
+ }, _ = (v) => {
592
+ v ? document.querySelectorAll(".highlight-hover-col").forEach((o) => {
593
+ o.classList.remove("highlight-hover-col");
594
+ }) : document.querySelectorAll(".highlight-col").forEach((o) => o.classList.remove("highlight-col"));
595
+ }, F = (v, o) => {
596
+ const k = /* @__PURE__ */ new Map(), p = v.clientX, L = v.target.closest("table"), U = L == null ? void 0 : L.querySelectorAll("th")[o], J = U == null ? void 0 : U.getBoundingClientRect().width, ee = k.get(o) ? a[o.toString()] || 60 : (k.set(o, !0), J || a[o.toString()] || 60), se = U == null ? void 0 : U.querySelector("p");
597
+ if (!se) return;
598
+ const ke = se.textContent || "", ve = window.getComputedStyle(se), _e = `${ve.fontWeight} ${ve.fontSize} ${ve.fontFamily}`, fe = document.createElement("canvas").getContext("2d");
599
+ if (!fe) return;
600
+ fe.font = _e;
601
+ const b = fe.measureText(ke), z = window.getComputedStyle(U), G = parseFloat(z.paddingLeft || "0"), P = parseFloat(z.paddingRight || "0"), I = b.width + G + P;
602
+ c(o, !1);
603
+ const M = (xe) => {
604
+ const Se = xe.clientX - p, ge = Math.max(I, ee + Se);
605
+ if (L) {
606
+ y(o, ge, L, !0);
607
+ let t = 0;
608
+ L.querySelectorAll("th").forEach((w, N) => {
609
+ t += N === o ? ge : a[N] || w.getBoundingClientRect().width;
610
+ }), L.classList.remove("w-full"), L.style.width = `${t}px`;
611
+ const T = L == null ? void 0 : L.parentElement;
612
+ if (T) {
613
+ const w = T.scrollWidth, N = T.scrollLeft;
614
+ T.offsetWidth + N >= w - 100 && (T.scrollLeft = w);
615
+ }
616
+ }
617
+ }, ie = () => {
618
+ const xe = (L == null ? void 0 : L.querySelectorAll("th")) ?? [], Se = [...a.value];
619
+ xe.forEach((ge, t) => {
620
+ const h = ge.getBoundingClientRect().width;
621
+ a[t] = h, Se[t] = h;
622
+ }), a.value = Se, _(!1), document.removeEventListener("mousemove", M), document.removeEventListener("mouseup", ie);
623
+ };
624
+ document.addEventListener("mousemove", M), document.addEventListener("mouseup", ie);
625
+ }, C = (v) => {
626
+ const o = v.clientY, k = v.target.closest("table"), p = e.value || 48;
627
+ m(!1);
628
+ const L = (J) => {
629
+ const ee = Math.max(30, p + (J.clientY - o));
630
+ k && l(ee, k);
631
+ }, U = () => {
632
+ d(!1), document.removeEventListener("mousemove", L), document.removeEventListener("mouseup", U);
633
+ };
634
+ document.addEventListener("mousemove", L), document.addEventListener("mouseup", U);
635
+ };
636
+ return {
637
+ rowHeight: e,
638
+ colWidths: a,
639
+ isEditing: n,
640
+ updateRowHeight: l,
641
+ updateColWidth: y,
642
+ setRowHeights: S,
643
+ setColWidths: R,
644
+ enableEditMode: V,
645
+ disableEditMode: D,
646
+ resetStore: i,
647
+ highlightCol: c,
648
+ highlightRows: m,
649
+ removeRowHighlight: d,
650
+ removeColHighlight: _,
651
+ resizeCol: F,
652
+ resizeRow: C,
653
+ enableCellResizing: () => {
654
+ const v = document.querySelector("thead"), o = document.querySelectorAll("thead tr"), k = document.querySelectorAll("tbody tr"), p = [...o, ...k];
655
+ v && v.classList.remove("sticky");
656
+ const L = (U, J) => {
657
+ const ee = document.createElement("div");
658
+ return ee.className = `${U}-resize-handle`, U === "col" ? (ee.addEventListener("mouseenter", () => c(J, !0)), ee.addEventListener("mouseleave", () => _(!0)), ee.addEventListener("mousedown", (se) => {
659
+ se.stopPropagation(), F(se, J);
660
+ })) : (ee.addEventListener("mouseenter", () => m(!0)), ee.addEventListener("mouseleave", () => d(!0)), ee.addEventListener("mousedown", (se) => {
661
+ se.stopPropagation(), C(se);
662
+ })), ee;
663
+ };
664
+ p.forEach((U) => {
665
+ const J = U.closest("thead") !== null;
666
+ U.querySelectorAll(J ? "th" : "td").forEach((se, ke) => {
667
+ const ve = L("col", ke), _e = L("row", ke);
668
+ se.appendChild(ve), se.appendChild(_e);
669
+ });
670
+ }), V();
671
+ },
672
+ cancelResizingChanges: () => {
673
+ D();
674
+ }
675
+ };
676
+ });
677
+ function pt(e) {
678
+ if (e == null || e === "")
679
+ return "";
680
+ const a = String(e), n = Number(a);
681
+ if (isNaN(n)) return a;
682
+ const [l, y] = a.split("."), S = new Intl.NumberFormat("en-US").format(Number(l));
683
+ return y !== void 0 ? `${S}.${y}` : S;
684
+ }
685
+ const jl = "/assets/processTableData.worker-B_-FBESg.js", Jl = { class: "my-4" }, Kl = {
686
+ class: "border-b border-fm-color-neutral-gray-100 hover:bg-fm-color-opacity-sm",
687
+ style: { backgroundColor: "#f9f9f9" }
688
+ }, Zl = { class: "font-bold" }, Ql = { class: "text-fm-color-neutral-gray-300" }, ea = /* @__PURE__ */ Le({
689
+ __name: "WidgetTable",
690
+ props: /* @__PURE__ */ Ie({
691
+ tileIndex: {}
692
+ }, {
693
+ modelValue: { required: !0 },
694
+ modelModifiers: {}
695
+ }),
696
+ emits: ["update:modelValue"],
697
+ setup(e) {
698
+ const { t: a, te: n } = tt(), l = Me(e, "modelValue"), { country: y } = St(), { clearTileSorts: S, setTileSorts: R } = xl(), V = Ct(), D = e, i = f([]), { isEditing: c, colWidths: m, rowHeight: d } = $e(Nt()), { setColWidths: _, setRowHeights: F, enableCellResizing: C } = Nt(), g = f(null), W = x(() => {
699
+ var b;
700
+ return ((b = l.value.data) == null ? void 0 : b.columns) || [{ label: "", key: "" }];
701
+ }), v = x(() => {
702
+ var b;
703
+ return ((b = l.value.data) == null ? void 0 : b.rows) || [];
704
+ }), o = x(() => l.value.filterText), k = x(() => {
705
+ var b, z;
706
+ if (!(o.value && o.value.trim().length > 0 || !((b = v.value[0]) != null && b.isRollup) && !((z = v.value[v.value.length - 1]) != null && z.isRollup))) {
707
+ if (l.value.rollupPosition === Pe.top || l.value.rollupPosition === void 0)
708
+ return Pe.top;
709
+ if (l.value.rollupPosition === Pe.bottom)
710
+ return Pe.bottom;
711
+ }
712
+ }), p = x(() => {
713
+ const P = k.value !== void 0 ? 1 : 0, I = (g.value ? g.value.$el.offsetHeight : 0) - 48;
714
+ return Math.floor((I - 34.5 - 32) / 48) - P;
715
+ }), L = x(() => {
716
+ var z, G;
717
+ let b = [];
718
+ switch (k.value) {
719
+ case Pe.top:
720
+ b = [...((z = v.value[0]) == null ? void 0 : z.cells) || []].map((P, I) => {
721
+ var M;
722
+ return {
723
+ main: P,
724
+ comparison: (M = v.value[0]) == null ? void 0 : M.comparisonCells[I],
725
+ rowType: W.value[I].type
726
+ };
727
+ });
728
+ break;
729
+ case Pe.bottom:
730
+ b = [...((G = v.value[v.value.length - 1]) == null ? void 0 : G.cells) || []].map((P, I) => {
731
+ var M;
732
+ return {
733
+ main: P,
734
+ comparison: (M = v.value[0]) == null ? void 0 : M.comparisonCells[I],
735
+ rowType: W.value[I].type
736
+ };
737
+ });
738
+ break;
739
+ }
740
+ return b.length > 0 && b[0].main === "" && (b[0].main = He(a, n, "Grand Total", "other")), b;
741
+ });
742
+ function U(b) {
743
+ let z = (b == null ? void 0 : b.main) || "";
744
+ return z.includes("#") && !z.startsWith("#") && (z = z.split("#")[0]), !b || b.main === "" || b.comparison === "" ? {
745
+ main: z
746
+ } : {
747
+ main: z,
748
+ comparison: b == null ? void 0 : b.comparison,
749
+ difference: Ut(b.main, b.comparison, y)
750
+ };
751
+ }
752
+ Ue(() => {
753
+ S();
754
+ });
755
+ const J = f([]);
756
+ let ee = 0, se;
757
+ function ke() {
758
+ var I;
759
+ if (!((I = l.value) != null && I.data)) {
760
+ J.value = [];
761
+ return;
762
+ }
763
+ const b = ++ee, z = (l.value.data.rows || []).map((M) => ({
764
+ isRollup: M.isRollup,
765
+ cells: Array.isArray(M.cells) ? [...M.cells] : [],
766
+ comparisonCells: Array.isArray(M.comparisonCells) ? [...M.comparisonCells] : []
767
+ })), G = (l.value.data.columns || []).map((M) => ({
768
+ key: M.key,
769
+ type: M.type,
770
+ label: M.label
771
+ })), P = {
772
+ rows: z,
773
+ columns: G,
774
+ filter: o.value ?? "",
775
+ globalSorts: fl(i.value).map((M) => ({
776
+ key: M.key,
777
+ type: M.type
778
+ })),
779
+ grandTotalPosition: k.value,
780
+ pageSize: p.value
781
+ };
782
+ Sl(jl, P).then((M) => {
783
+ b === ee && (M != null && M.error ? (V.open({ message: "Failed to process table data. Please retry.", type: "error" }), console.log(M.error), J.value = []) : J.value = vl(M.data || []));
784
+ });
785
+ }
786
+ he(
787
+ () => i.value,
788
+ (b) => {
789
+ D.tileIndex === void 0 || D.tileIndex === null || R(D.tileIndex, b);
790
+ },
791
+ { immediate: !0, deep: !0 }
792
+ );
793
+ const ve = x(() => {
794
+ var G, P;
795
+ const b = ((G = l.value.data) == null ? void 0 : G.rows) || [], z = ((P = l.value.data) == null ? void 0 : P.columns) || [];
796
+ return JSON.stringify({
797
+ rowsLength: b.length,
798
+ columns: z.map((I) => ({ key: I.key, type: I.type, label: I.label })),
799
+ filter: o.value ?? "",
800
+ globalSorts: i.value.map((I) => ({ key: I.key, type: I.type })),
801
+ grandTotalPosition: k.value,
802
+ pageSize: p.value
803
+ });
804
+ });
805
+ he(
806
+ () => ve.value,
807
+ () => {
808
+ clearTimeout(se), se = setTimeout(ke, 200);
809
+ },
810
+ { immediate: !0 }
811
+ );
812
+ function _e(b) {
813
+ const z = i.value.find((G) => G.key === b);
814
+ if (!z) {
815
+ i.value.push({ key: b, type: Be.Asc });
816
+ return;
817
+ }
818
+ z.type === Be.Asc ? z.type = Be.Desc : z.type === Be.Desc && (i.value = i.value.filter((G) => G.key !== b));
819
+ }
820
+ const De = x(
821
+ () => {
822
+ var b;
823
+ return (((b = l.value.colWidths) == null ? void 0 : b.length) ?? 0) > 0 || m.value.length > 0;
824
+ }
825
+ ), fe = x(() => {
826
+ var b;
827
+ return (b = l.value.data) != null && b.columns ? l.value.data.columns.map((z) => {
828
+ const G = He(a, n, z.label, "other"), P = i.value.find((ie) => ie.key === z.key), I = !!P, M = I ? P.type === Be.Asc ? "arrow_upward" : "arrow_downward" : "unfold_more";
829
+ return {
830
+ accessorKey: z.key,
831
+ header: () => {
832
+ const ie = H("FmIcon");
833
+ return st(
834
+ "button",
835
+ {
836
+ type: "button",
837
+ class: `w-full flex items-center gap-1 group/select-header select-none ${z.type === "NUMERIC" ? "justify-end" : "justify-start"} ${I ? "text-fm-color-typo-primary" : "text-fm-color-neutral-gray-400"}`,
838
+ onClick: () => _e(z.key)
839
+ },
840
+ [
841
+ st(
842
+ "span",
843
+ { class: `${z.type === "NUMERIC" ? "text-right" : ""} whitespace-nowrap` },
844
+ G
845
+ ),
846
+ st(ie, {
847
+ name: M,
848
+ color: I ? "primary" : "neutral-gray-400",
849
+ size: "sm",
850
+ class: "transition-transform",
851
+ style: M === "arrow_upward" ? "transform: translateY(-1px);" : ""
852
+ })
853
+ ]
854
+ );
855
+ },
856
+ cell: (ie) => {
857
+ var ge, t;
858
+ const xe = U(ie.getValue()), Se = (t = (ge = ie == null ? void 0 : ie.row) == null ? void 0 : ge.original) == null ? void 0 : t.isRollup;
859
+ return st(
860
+ "div",
861
+ {
862
+ class: [
863
+ Se ? "fm-typo-en-body-md-600 text-fm-color-typo-secondary" : "fm-typo-en-body-md-400",
864
+ z.type === "NUMERIC" ? "text-right" : "",
865
+ De.value ? "whitespace-normal break-words line-clamp-6" : "whitespace-nowrap"
866
+ ].join(" ")
867
+ },
868
+ [z.type === "NUMERIC" ? pt(xe.main) : xe.main]
869
+ );
870
+ },
871
+ enableSorting: !1
872
+ };
873
+ }) : [];
874
+ });
875
+ return he(
876
+ () => m.value.length > 0,
877
+ async (b) => {
878
+ b && c.value && (await we(), C());
879
+ }
880
+ ), he(
881
+ [() => fe.value],
882
+ async () => {
883
+ var I;
884
+ await we();
885
+ const b = (I = g.value) == null ? void 0 : I.$el;
886
+ if (!b) return;
887
+ const z = b.querySelector("table");
888
+ if (!z) return;
889
+ z.classList.add(De.value ? "table-fixed" : "table-auto");
890
+ let G, P;
891
+ c.value ? (C(), G = m.value, P = d.value) : (P = l.value.rowHeight, G = l.value.colWidths), typeof P == "number" && F(P, b), G == null || G.forEach((M, ie) => {
892
+ _(ie, M, b);
893
+ });
894
+ },
895
+ { immediate: !0 }
896
+ ), (b, z) => {
897
+ const G = H("FmTable");
898
+ return $(), te(be, null, [
899
+ O("div", Jl, [
900
+ Ne(b.$slots, "menu")
901
+ ]),
902
+ B(G, {
903
+ ref_key: "table",
904
+ ref: g,
905
+ "column-defs": fe.value,
906
+ "row-data": J.value,
907
+ "search-value": o.value,
908
+ "page-size": p.value,
909
+ "shrink-at": !1,
910
+ "force-mobile-footer": !0,
911
+ class: "scrollbar-hide-table"
912
+ }, {
913
+ "pin-top": oe(() => [
914
+ O("tbody", null, [
915
+ O("tr", Kl, [
916
+ ($(!0), te(be, null, nt(L.value, (P, I) => ($(), te("td", {
917
+ key: `${s(ot)()}_${I}`,
918
+ class: "h-[48px] text-fm-color-typo-primary px-16"
919
+ }, [
920
+ O("span", {
921
+ class: qe([
922
+ "items-center text-fm-color-typo-secondary gap-2",
923
+ P.rowType === "NUMERIC" ? "text-right" : "",
924
+ De.value ? "whitespace-normal break-words line-clamp-6" : "whitespace-nowrap"
925
+ ])
926
+ }, [
927
+ O("p", Zl, Te(P.rowType === "NUMERIC" ? s(pt)(P.main) : P.main), 1),
928
+ O("p", Ql, Te(P.comparison ? P.rowType === "NUMERIC" ? `(${s(pt)(P.comparison)})` : `(${P.comparison})` : ""), 1)
929
+ ], 2)
930
+ ]))), 128))
931
+ ])
932
+ ])
933
+ ]),
934
+ _: 1
935
+ }, 8, ["column-defs", "row-data", "search-value", "page-size"])
936
+ ], 64);
937
+ };
938
+ }
939
+ }), ta = /* @__PURE__ */ Le({
940
+ __name: "WidgetStackBarChart",
941
+ props: /* @__PURE__ */ Ie({
942
+ tileIndex: {}
943
+ }, {
944
+ modelValue: { required: !0 },
945
+ modelModifiers: {}
946
+ }),
947
+ emits: ["update:modelValue"],
948
+ setup(e) {
949
+ const a = e, n = Me(e, "modelValue"), l = f(null), y = x(() => {
950
+ var W;
951
+ return ((W = n.value.data) == null ? void 0 : W.xAxis) || [];
952
+ }), S = x(() => {
953
+ var g;
954
+ return ((g = n.value.data) == null ? void 0 : g.datasets) ?? [];
955
+ }), { datalabels: R, xCfg: V, yCfg: D, isTransposed: i, legend: c, chartWidth: m, chartHeight: d } = lt(
956
+ n.value
957
+ ), _ = x(() => S.value.length > 0 ? [
958
+ ...S.value.map((g, W) => {
959
+ let v = g.values;
960
+ return {
961
+ label: g.name,
962
+ data: v,
963
+ dash: !!g.isCompare,
964
+ backgroundColor: Ae({ index: W, isCompare: g.isCompare })
965
+ };
966
+ })
967
+ ] : []), F = et();
968
+ function C() {
969
+ return F.extractChartSize(l.value, a.tileIndex) || { width: 0, height: 0 };
970
+ }
971
+ return Ue(() => {
972
+ we(() => {
973
+ C();
974
+ });
975
+ }), he([_], () => {
976
+ we(() => C());
977
+ }), (g, W) => {
978
+ const v = H("FmBarChart");
979
+ return $(), te(be, null, [
980
+ Ne(g.$slots, "menu"),
981
+ B(v, {
982
+ ref_key: "chartRef",
983
+ ref: l,
984
+ class: "bar-chart",
985
+ datasets: _.value,
986
+ "x-axis": { categories: y.value },
987
+ "x-cfg": s(V),
988
+ "y-cfg": s(D),
989
+ transpose: s(i),
990
+ stacked: !0,
991
+ legend: {
992
+ display: s(c).display ?? !1,
993
+ position: s(c).position,
994
+ maxHeight: s(c).maxHeight,
995
+ maxWidth: s(c).maxWidth,
996
+ labels: s(c).labels
997
+ },
998
+ datalabels: s(R),
999
+ "maintain-aspect-ratio": !1,
1000
+ style: Ee({
1001
+ "--chart-width": s(m) !== void 0 ? s(m) + "px" : "100%",
1002
+ "--chart-height": s(d) !== void 0 ? s(d) + "px" : "calc(100% - 36px)"
1003
+ })
1004
+ }, null, 8, ["datasets", "x-axis", "x-cfg", "y-cfg", "transpose", "legend", "datalabels", "style"])
1005
+ ], 64);
1006
+ };
1007
+ }
1008
+ }), la = /* @__PURE__ */ Le({
1009
+ __name: "WidgetStackLineChart",
1010
+ props: /* @__PURE__ */ Ie({
1011
+ tileIndex: {}
1012
+ }, {
1013
+ modelValue: { required: !0 },
1014
+ modelModifiers: {}
1015
+ }),
1016
+ emits: ["update:modelValue"],
1017
+ setup(e) {
1018
+ var v;
1019
+ const a = e, n = Me(e, "modelValue"), l = ((v = n.value.data) == null ? void 0 : v.xAxis) ?? [], y = x(
1020
+ () => l.length === 1 && V.value.length > 0 && V.value.every((o) => o.values.length === 1)
1021
+ ), S = x(() => y.value ? ["", l[0], ""] : l), R = f(null), V = x(() => {
1022
+ var o;
1023
+ return ((o = n.value.data) == null ? void 0 : o.datasets) ?? [];
1024
+ }), { datalabels: D, xCfg: i, yCfg: c, isTransposed: m, legend: d, chartWidth: _, chartHeight: F } = lt(
1025
+ n.value
1026
+ ), C = x(() => V.value.length > 0 ? [
1027
+ ...V.value.map((o, k) => {
1028
+ let p = o.values;
1029
+ return y.value && (p = [NaN, p[0], NaN]), {
1030
+ label: o.name,
1031
+ data: p,
1032
+ dash: o.isCompare,
1033
+ fill: !1,
1034
+ color: Ae({ index: k, isCompare: o.isCompare }),
1035
+ pointRadius: y.value ? 4 : void 0,
1036
+ pointHoverRadius: y.value ? 6 : void 0,
1037
+ pointBackgroundColor: y.value ? Ae({ index: k, isCompare: o.isCompare }) : void 0,
1038
+ pointBorderColor: y.value ? Ae({ index: k, isCompare: o.isCompare }) : void 0,
1039
+ pointBorderWidth: y.value ? 2 : void 0
1040
+ };
1041
+ })
1042
+ ] : []), g = et();
1043
+ function W() {
1044
+ return g.extractChartSize(R.value, a.tileIndex) || { width: 0, height: 0 };
1045
+ }
1046
+ return Ue(() => {
1047
+ we(() => {
1048
+ W();
1049
+ });
1050
+ }), he([C], () => {
1051
+ we(() => W());
1052
+ }), (o, k) => {
1053
+ const p = H("FmLineChart");
1054
+ return $(), te(be, null, [
1055
+ Ne(o.$slots, "menu"),
1056
+ B(p, {
1057
+ ref_key: "chartRef",
1058
+ ref: R,
1059
+ class: "line-chart",
1060
+ datasets: C.value,
1061
+ "x-axis": { categories: S.value },
1062
+ "x-cfg": s(i),
1063
+ "y-cfg": s(c),
1064
+ transpose: s(m),
1065
+ legend: {
1066
+ display: s(d).display ?? !1,
1067
+ position: s(d).position,
1068
+ maxHeight: s(d).maxHeight,
1069
+ maxWidth: s(d).maxWidth,
1070
+ labels: s(d).labels
1071
+ },
1072
+ stacked: !0,
1073
+ datalabels: s(D),
1074
+ "maintain-aspect-ratio": !1,
1075
+ style: Ee({
1076
+ "--chart-width": s(_) !== void 0 ? s(_) + "px" : "100%",
1077
+ "--chart-height": s(F) !== void 0 ? s(F) + "px" : "calc(100% - 36px)"
1078
+ })
1079
+ }, null, 8, ["datasets", "x-axis", "x-cfg", "y-cfg", "transpose", "legend", "datalabels", "style"])
1080
+ ], 64);
1081
+ };
1082
+ }
1083
+ }), Ke = [
1084
+ "col-span-1",
1085
+ "col-span-2",
1086
+ "col-span-3",
1087
+ "col-span-4",
1088
+ "col-span-5",
1089
+ "col-span-6",
1090
+ "col-span-7",
1091
+ "col-span-8",
1092
+ "col-span-9",
1093
+ "col-span-10",
1094
+ "col-span-11",
1095
+ "col-span-12"
1096
+ ];
1097
+ function aa(e) {
1098
+ return e < 12 ? Ke[e - 1] : Ke[11];
1099
+ }
1100
+ function sa(e) {
1101
+ return e < 12 ? Ke[Math.min(11, e * 2 - 1)] : Ke[11];
1102
+ }
1103
+ function oa(e) {
1104
+ return e < 12 ? Ke[Math.min(11, e * 3 - 1)] : Ke[11];
1105
+ }
1106
+ const na = /* @__PURE__ */ Le({
1107
+ __name: "WidgetLinechart",
1108
+ props: /* @__PURE__ */ Ie({
1109
+ tileIndex: {}
1110
+ }, {
1111
+ modelValue: { required: !0 },
1112
+ modelModifiers: {}
1113
+ }),
1114
+ emits: ["update:modelValue"],
1115
+ setup(e) {
1116
+ var v;
1117
+ const a = e, n = Me(e, "modelValue"), l = ((v = n.value.data) == null ? void 0 : v.xAxis) ?? [], y = x(
1118
+ () => l.length === 1 && V.value.length > 0 && V.value.every((o) => o.values.length === 1)
1119
+ ), S = x(() => y.value ? ["", l[0], ""] : l), R = f(null), V = x(() => {
1120
+ var o;
1121
+ return ((o = n.value.data) == null ? void 0 : o.datasets) ?? [];
1122
+ }), { datalabels: D, xCfg: i, yCfg: c, isTransposed: m, legend: d, chartWidth: _, chartHeight: F } = lt(
1123
+ n.value
1124
+ ), C = x(() => V.value.length > 0 ? [
1125
+ ...V.value.map((o, k) => {
1126
+ let p = o.values;
1127
+ return y.value && (p = [NaN, p[0], NaN]), {
1128
+ label: o.name,
1129
+ data: p,
1130
+ dash: !!o.isCompare,
1131
+ fill: !1,
1132
+ color: Ae({ index: k, isCompare: o.isCompare }),
1133
+ pointRadius: y.value ? 4 : void 0,
1134
+ pointHoverRadius: y.value ? 6 : void 0,
1135
+ pointBackgroundColor: y.value ? Ae({ index: k, isCompare: o.isCompare }) : void 0,
1136
+ pointBorderColor: y.value ? Ae({ index: k, isCompare: o.isCompare }) : void 0,
1137
+ pointBorderWidth: y.value ? 2 : void 0
1138
+ };
1139
+ })
1140
+ ] : []), g = et();
1141
+ function W() {
1142
+ return g.extractChartSize(R.value, a.tileIndex) || { width: 0, height: 0 };
1143
+ }
1144
+ return Ue(() => {
1145
+ we(() => {
1146
+ W();
1147
+ });
1148
+ }), he([C], () => {
1149
+ we(() => W());
1150
+ }), (o, k) => {
1151
+ const p = H("FmLineChart");
1152
+ return $(), te(be, null, [
1153
+ Ne(o.$slots, "menu"),
1154
+ B(p, {
1155
+ ref_key: "chartRef",
1156
+ ref: R,
1157
+ class: "line-chart",
1158
+ datasets: C.value,
1159
+ "x-axis": { categories: S.value },
1160
+ "x-cfg": s(i),
1161
+ "y-cfg": s(c),
1162
+ transpose: s(m),
1163
+ legend: {
1164
+ display: s(d).display ?? !1,
1165
+ position: s(d).position,
1166
+ maxHeight: s(d).maxHeight,
1167
+ maxWidth: s(d).maxWidth,
1168
+ labels: s(d).labels
1169
+ },
1170
+ datalabels: s(D),
1171
+ "maintain-aspect-ratio": !1,
1172
+ style: Ee({
1173
+ "--chart-width": s(_) !== void 0 ? s(_) + "px" : "100%",
1174
+ "--chart-height": s(F) !== void 0 ? s(F) + "px" : "calc(100% - 36px)"
1175
+ })
1176
+ }, null, 8, ["datasets", "x-axis", "x-cfg", "y-cfg", "transpose", "legend", "datalabels", "style"])
1177
+ ], 64);
1178
+ };
1179
+ }
1180
+ }), ra = { class: "flex flex-col gap-16" }, ia = { class: "flex flex-row" }, ua = /* @__PURE__ */ Le({
1181
+ __name: "PdfOrientationDialog",
1182
+ props: /* @__PURE__ */ Ie({
1183
+ reportType: {},
1184
+ index: {}
1185
+ }, {
1186
+ modelValue: { type: Boolean, required: !0 },
1187
+ modelModifiers: {}
1188
+ }),
1189
+ emits: ["update:modelValue"],
1190
+ setup(e) {
1191
+ const { t: a } = tt(), { FmForm: n } = zl, l = e, y = f(), S = Me(e, "modelValue"), R = f(!0), V = f(!1), D = Ct(), { selectedLocationIds: i, dateRange: c, timeRange: m } = $e(Qe()), d = f(dt.PORTRAIT);
1192
+ function _() {
1193
+ var C;
1194
+ (C = y.value) == null || C.validateInputs();
1195
+ }
1196
+ async function F() {
1197
+ V.value = !0;
1198
+ try {
1199
+ l.index != null && await Bt({
1200
+ reportType: l.reportType,
1201
+ index: l.index,
1202
+ orientationTypes: [d.value],
1203
+ isCombinedLocationLayout: R.value,
1204
+ timeRange: m.value,
1205
+ dateRange: c.value,
1206
+ locationIds: i.value
1207
+ });
1208
+ } catch (C) {
1209
+ D.open({ message: C.message, type: "error" });
1210
+ } finally {
1211
+ V.value = !1;
1212
+ }
1213
+ }
1214
+ return (C, g) => {
1215
+ const W = H("FmRadio"), v = H("FmRadioGroup"), o = H("FmButton"), k = H("FmDialog");
1216
+ return $(), re(k, {
1217
+ modelValue: S.value,
1218
+ "onUpdate:modelValue": g[2] || (g[2] = (p) => S.value = p),
1219
+ overlay: !0,
1220
+ "z-index": 10
1221
+ }, {
1222
+ "dialog-header": oe(() => g[3] || (g[3] = [
1223
+ ht("Select Orientation")
1224
+ ])),
1225
+ default: oe(() => [
1226
+ B(s(n), {
1227
+ ref_key: "form",
1228
+ ref: y,
1229
+ onValidationSuccess: F
1230
+ }, {
1231
+ default: oe(() => [
1232
+ O("div", ra, [
1233
+ B(v, {
1234
+ modelValue: d.value,
1235
+ "onUpdate:modelValue": g[0] || (g[0] = (p) => d.value = p)
1236
+ }, {
1237
+ default: oe(() => [
1238
+ B(W, {
1239
+ value: s(dt).PORTRAIT,
1240
+ label: s(a)("report.common.portrait")
1241
+ }, null, 8, ["value", "label"]),
1242
+ B(W, {
1243
+ value: s(dt).LANDSCAPE,
1244
+ label: s(a)("report.common.landscape")
1245
+ }, null, 8, ["value", "label"])
1246
+ ]),
1247
+ _: 1
1248
+ }, 8, ["modelValue"])
1249
+ ]),
1250
+ O("div", ia, [
1251
+ g[4] || (g[4] = O("div", { class: "grow" }, null, -1)),
1252
+ B(o, {
1253
+ label: s(a)("report.common.cancel"),
1254
+ variant: "tertiary",
1255
+ onClick: g[1] || (g[1] = (p) => S.value = !1)
1256
+ }, null, 8, ["label"]),
1257
+ O("div", null, [
1258
+ B(o, {
1259
+ label: s(a)("report.common.download"),
1260
+ loading: V.value,
1261
+ onClick: _
1262
+ }, null, 8, ["label", "loading"])
1263
+ ])
1264
+ ])
1265
+ ]),
1266
+ _: 1
1267
+ }, 512)
1268
+ ]),
1269
+ _: 1
1270
+ }, 8, ["modelValue"]);
1271
+ };
1272
+ }
1273
+ }), ca = {
1274
+ key: 1,
1275
+ class: "grow"
1276
+ }, da = {
1277
+ key: 2,
1278
+ class: "flex"
1279
+ }, Pa = /* @__PURE__ */ Le({
1280
+ __name: "DynamicWidget",
1281
+ props: /* @__PURE__ */ Ie({
1282
+ index: {
1283
+ type: Number,
1284
+ default: 0
1285
+ },
1286
+ hideExport: {
1287
+ type: Boolean,
1288
+ default: !1
1289
+ },
1290
+ customScreenWidth: {
1291
+ type: Number,
1292
+ required: !1,
1293
+ default: void 0
1294
+ }
1295
+ }, {
1296
+ modelValue: { required: !0, default: () => {
1297
+ } },
1298
+ modelModifiers: {}
1299
+ }),
1300
+ emits: ["update:modelValue"],
1301
+ setup(e) {
1302
+ const a = f(!0), n = Me(e, "modelValue"), l = n.value.widget.config, { t: y, te: S } = tt(), R = e, V = f(null), D = f(l.rollup), i = f(ot()), c = f(l.drillDimension), m = x(() => {
1303
+ if (We.value.length > 0) {
1304
+ const r = We.value.findIndex(
1305
+ (Q) => Q.value === c.value
1306
+ );
1307
+ return r >= 0 ? r : 0;
1308
+ } else
1309
+ return -1;
1310
+ }), d = x(() => m.value !== 0), _ = x(
1311
+ () => m.value != We.value.length - 1
1312
+ ), F = f(l.showTitle ?? !0), C = f(l.titleFontSize ?? 14), g = f(l.titleBold ?? !1), W = f(l.titleItalic ?? !1), v = f(l.titleUnderline ?? !1), o = f(l.chartWidth ?? void 0), k = f(l.chartHeight ?? void 0), p = f(l.showLabel ?? !1), L = f(l.labelAlign ?? yt.center), U = f(l.labelAnchor ?? gt.center), J = f(l.labelRotation ?? 0), ee = f(l.labelOffset ?? 0), se = f(l.labelFontSize ?? 12), ke = x(() => l.showSearchBar), ve = f(l.showX ?? !0), _e = f(l.xPosition ?? bt.bottom), De = f(l.showXGrid ?? !1), fe = f(l.showXTick ?? !0), b = f(l.xTickFontSize ?? 12), z = f(l.showXTitle ?? !1), G = f(l.xTitle ?? ""), P = f(l.xTitleFontSize ?? 12), I = f(l.showY ?? !0), M = f(l.yPosition ?? wt.left), ie = f(l.showYGrid ?? !1), xe = f(l.showYTick ?? !0), Se = f(l.yTickFontSize ?? 12), ge = f(l.showYTitle ?? !1), t = f(l.yTitle ?? ""), h = f(l.yTitleFontSize ?? 12), T = f(l.showLegend ?? void 0), w = f(l.legendPosition ?? xt.top), N = f(l.usePointStyle ?? !0), le = f(l.legendMaxHeight), de = f(l.legendMaxWidth), me = f(l.rowHeight ?? 0), K = f(l.colWidths ?? []), E = f(!1), u = f(""), { breakpoints: X, getBreakpointsBoundary: j } = qt(), Z = f(), q = x(
1313
+ () => R.customScreenWidth === void 0 ? window.innerWidth : R.customScreenWidth
1314
+ ), ne = x(
1315
+ () => (q == null ? void 0 : q.value) > j("xs")[1] && (q == null ? void 0 : q.value) <= j("sm")[1]
1316
+ ), ae = x(
1317
+ () => (q == null ? void 0 : q.value) > j("sm")[1] && (q == null ? void 0 : q.value) <= j("md")[1]
1318
+ ), ye = x(() => (q == null ? void 0 : q.value) > j("md")[1]), ue = x(() => {
1319
+ const r = n.value.size.width;
1320
+ return ye.value || ae.value ? aa(r) : ne.value ? sa(r) : oa(r);
1321
+ }), Ge = x(
1322
+ () => Al.find((r) => r.type === n.value.widget.type)
1323
+ ), Y = Mt(() => {
1324
+ var r;
1325
+ Z.value = ll((r = V.value) == null ? void 0 : r.$el.offsetWidth), i.value = ot();
1326
+ }), Yt = x(() => {
1327
+ if (El(ce.value.type, Ye.value))
1328
+ switch (n.value.widget.type) {
1329
+ case A.BarChart:
1330
+ return Il;
1331
+ case A.StackBarChart:
1332
+ return ta;
1333
+ case A.LineChart:
1334
+ return na;
1335
+ case A.StackLineChart:
1336
+ return la;
1337
+ case A.Circular:
1338
+ return Nl;
1339
+ case A.Scorecard:
1340
+ return ql;
1341
+ case A.Spacer:
1342
+ return Yl;
1343
+ case A.Table:
1344
+ return ea;
1345
+ default:
1346
+ return ft;
1347
+ }
1348
+ else
1349
+ return ft;
1350
+ }), Ye = f(null), {
1351
+ selectedLocationIds: rt,
1352
+ dateRange: kt,
1353
+ compareDateRange: Xt,
1354
+ timeRange: _t,
1355
+ globalFilters: jt,
1356
+ isGlobalFiltersLoading: Tt
1357
+ } = $e(Qe()), { businessId: Jt } = $e(St()), { businessLoadedId: Kt, businessDataVersion: it } = $e(Qe());
1358
+ x(() => Kt.value === Jt.value && rt.value.length > 0 && !Tt.value);
1359
+ const Zt = f(!0), ce = x(() => {
1360
+ const r = JSON.parse(JSON.stringify(n.value.widget));
1361
+ return {
1362
+ ...r,
1363
+ config: {
1364
+ ...r.config,
1365
+ rollup: D.value,
1366
+ drillDimension: c.value,
1367
+ showGrandTotal: !1
1368
+ }
1369
+ };
1370
+ });
1371
+ function Qt() {
1372
+ return {
1373
+ data: Ye.value,
1374
+ showTitle: F.value,
1375
+ titleFontSize: C.value,
1376
+ titleBold: g.value,
1377
+ titleItalic: W.value,
1378
+ titleUnderline: v.value,
1379
+ chartHeight: k.value,
1380
+ chartWidth: o.value,
1381
+ showLabel: p.value,
1382
+ labelAnchor: U.value,
1383
+ labelAlign: L.value,
1384
+ labelRotation: J.value,
1385
+ labelOffset: ee.value,
1386
+ labelFontSize: se.value,
1387
+ showX: ve.value,
1388
+ xPosition: _e.value,
1389
+ showXGrid: De.value,
1390
+ showXTick: fe.value,
1391
+ xTickFontSize: b.value,
1392
+ showXTitle: z.value,
1393
+ xTitle: G.value,
1394
+ xTitleFontSize: P.value,
1395
+ showY: I.value,
1396
+ yPosition: M.value,
1397
+ showYGrid: ie.value,
1398
+ showYTick: xe.value,
1399
+ yTitle: t.value,
1400
+ showYTitle: ge.value,
1401
+ yTitleFontSize: h.value,
1402
+ yTickFontSize: Se.value,
1403
+ isTransposed: ce.value.config.isTransposed,
1404
+ showLegend: T.value,
1405
+ legendPosition: w.value,
1406
+ usePointStyle: N.value,
1407
+ legendMaxHeight: le.value,
1408
+ legendMaxWidth: de.value
1409
+ };
1410
+ }
1411
+ function el() {
1412
+ return {
1413
+ data: Ye.value,
1414
+ filterText: u.value,
1415
+ rollupPosition: ce.value.config.rollupPosition,
1416
+ rowHeight: me.value,
1417
+ colWidths: K.value
1418
+ };
1419
+ }
1420
+ const Ft = x(() => {
1421
+ switch (ce.value.type) {
1422
+ case A.Table:
1423
+ return el();
1424
+ case A.BarChart:
1425
+ case A.LineChart:
1426
+ case A.StackBarChart:
1427
+ case A.StackLineChart:
1428
+ case A.Circular:
1429
+ return Qt();
1430
+ default:
1431
+ return { data: Ye.value };
1432
+ }
1433
+ }), Lt = x(() => {
1434
+ const { config: r } = n.value.widget;
1435
+ if (r.rollup != null) {
1436
+ const Q = [...r.dimensions].filter((Re) => !Re.hide);
1437
+ return Q.sort(
1438
+ (Re, Ze) => (r.rowIds || []).indexOf(mt(Re)) - (r.rowIds || []).indexOf(mt(Ze))
1439
+ ), [
1440
+ { label: He(y, S, "None", "other"), value: "none" },
1441
+ { label: He(y, S, "Grand Total", "other"), value: 0 },
1442
+ ...[...Q].slice(0, Q.length - 1).map((Re, Ze) => ({
1443
+ label: He(y, S, Re.label, "other"),
1444
+ value: Ze + 1
1445
+ }))
1446
+ ];
1447
+ }
1448
+ return [];
1449
+ }), We = x(() => {
1450
+ const { config: r } = ce.value;
1451
+ return r.isDrillable ? r.dimensions.map((Q) => ({
1452
+ label: He(y, S, Q.label, "other"),
1453
+ value: mt(Q)
1454
+ })) : [];
1455
+ }), tl = x(() => {
1456
+ const r = n.value.id;
1457
+ return (jt.value || []).filter(
1458
+ (Q) => Array.isArray(Q.tileIds) && Q.tileIds.includes(r)
1459
+ );
1460
+ });
1461
+ he(
1462
+ () => n.value.widget.config,
1463
+ (r) => {
1464
+ D.value = r.rollup, F.value = r.showTitle ?? !0, C.value = r.titleFontSize ?? 14, g.value = r.titleBold ?? !1, W.value = r.titleItalic ?? !1, v.value = r.titleUnderline ?? !1, k.value = r.chartHeight ?? void 0, o.value = r.chartWidth ?? void 0, p.value = r.showLabel ?? !1, L.value = r.labelAlign ?? yt.center, U.value = r.labelAnchor ?? gt.center, J.value = r.labelRotation ?? 0, ee.value = r.labelOffset ?? 0, se.value = r.labelFontSize ?? 12, ve.value = r.showX ?? !0, _e.value = r.xPosition ?? bt.bottom, De.value = r.showXGrid ?? !1, fe.value = r.showXTick ?? !0, b.value = r.xTickFontSize ?? 12, z.value = r.showXTitle ?? !1, G.value = r.xTitle ?? "", P.value = r.xTitleFontSize ?? 12, I.value = r.showY ?? !0, M.value = r.yPosition ?? wt.left, ie.value = r.showYGrid ?? !1, xe.value = r.showYTick ?? !0, Se.value = r.yTickFontSize ?? 12, ge.value = r.showYTitle ?? !1, t.value = r.yTitle ?? "", h.value = r.yTitleFontSize ?? 12, T.value = r.showLegend ?? void 0, w.value = r.legendPosition ?? xt.top, N.value = r.usePointStyle ?? !0, le.value = r.legendMaxHeight, de.value = r.legendMaxWidth, me.value = r.rowHeight ?? 0, K.value = r.colWidths ?? [];
1465
+ },
1466
+ { deep: !0 }
1467
+ ), he([() => D.value], () => {
1468
+ D.value !== null && (n.value.widget.config.rollup = D.value);
1469
+ }), he(
1470
+ [
1471
+ () => ce.value,
1472
+ () => kt.value,
1473
+ () => _t.value,
1474
+ () => Xt.value,
1475
+ () => rt.value,
1476
+ () => tl.value,
1477
+ () => it.value
1478
+ ],
1479
+ () => {
1480
+ Rt();
1481
+ },
1482
+ { deep: !0 }
1483
+ ), he(
1484
+ [() => n.value.size],
1485
+ () => {
1486
+ Y();
1487
+ },
1488
+ { deep: !0 }
1489
+ ), Ue(() => {
1490
+ Y(), X.value.sm || X.value.md || X.value.xs ? (console.log("Ignoring resize event due to keyboard"), addEventListener("change", Y)) : addEventListener("resize", Y), Rt();
1491
+ }), gl(() => {
1492
+ X.value.sm || X.value.md || X.value.xs ? (console.log("Ignoring resize event due to keyboard"), removeEventListener("change", Y)) : removeEventListener("resize", Y);
1493
+ });
1494
+ const Dt = Ct();
1495
+ let at;
1496
+ async function Rt() {
1497
+ if (ce.value.config.schemaNames.length <= 0 && !(ce.value.config.dimensions.length <= 0 || ce.value.config.metrics.length <= 0)) {
1498
+ Dt.open({
1499
+ message: "schema must not be empty and dimension or metrics must have at least 1 column",
1500
+ type: "info"
1501
+ }), a.value = !1;
1502
+ return;
1503
+ }
1504
+ try {
1505
+ a.value = !0, at && at.abort(), at = new AbortController();
1506
+ const r = at.signal, Q = it.value, Re = await Mt(Ht, 500)(ce.value, r, n.value.id);
1507
+ it.value === Q && (Ye.value = Re, i.value = ot()), a.value = !1;
1508
+ } catch (r) {
1509
+ r.code !== "ERR_CANCELED" && (Ye.value = null, Dt.open({ message: `Invalid chart ${ce.value.type}`, type: "error" }), console.log(r), a.value = !1);
1510
+ }
1511
+ }
1512
+ function ll(r) {
1513
+ switch (n.value.widget.type) {
1514
+ case "SPACER":
1515
+ return;
1516
+ case "SCORECARD":
1517
+ return;
1518
+ case "TABLE":
1519
+ return `${n.value.size.height * 100 + (ke.value ? 72 : 0) + 96.5}px`;
1520
+ }
1521
+ return `${Math.max(r / n.value.size.width, 90) * n.value.size.height}px`;
1522
+ }
1523
+ function al() {
1524
+ const r = m.value - 1;
1525
+ r >= 0 && (c.value = We.value[r].value);
1526
+ }
1527
+ function sl() {
1528
+ const r = m.value + 1;
1529
+ r >= 0 && r < We.value.length && (c.value = We.value[r].value);
1530
+ }
1531
+ const Vt = f(je.EXCEL), zt = f(), ol = Object.values(je).map((r) => ({
1532
+ label: Cl(r),
1533
+ value: r,
1534
+ onClick: async () => {
1535
+ r === je.EXCEL || r === je.PDFFULLSIZE || r === je.PDFRECEIPT ? await Bt({
1536
+ reportType: r,
1537
+ index: R.index,
1538
+ isCombinedLocationLayout: Zt.value,
1539
+ timeRange: _t.value,
1540
+ dateRange: kt.value,
1541
+ locationIds: rt.value
1542
+ }) : r === je.PDF && (Vt.value = r, zt.value = R.index, E.value = !0);
1543
+ }
1544
+ })), nl = ce.value.type === A.Spacer ? "flat" : "outlined", rl = ce.value.type === A.Spacer ? "p-0" : "p-16";
1545
+ return (r, Q) => {
1546
+ const Re = H("FmTooltip"), Ze = H("FmSearch"), il = H("FmCheckbox"), ut = H("FmButton"), ul = H("FmSelect"), cl = H("FmMenuItem"), dl = H("FmMenu"), ml = H("FmForm"), pl = H("FmCircularProgress"), hl = H("FmCard");
1547
+ return $(), re(hl, {
1548
+ ref_key: "tileCard",
1549
+ ref: V,
1550
+ class: qe(`${ue.value} ${s(rl)}`),
1551
+ variant: s(nl)
1552
+ }, {
1553
+ default: oe(() => [
1554
+ B(ua, {
1555
+ modelValue: E.value,
1556
+ "onUpdate:modelValue": Q[0] || (Q[0] = (Xe) => E.value = Xe),
1557
+ "report-type": Vt.value,
1558
+ index: zt.value
1559
+ }, null, 8, ["modelValue", "report-type", "index"]),
1560
+ !a.value && !s(Tt) ? ($(), te("div", {
1561
+ key: 0,
1562
+ style: Ee({ height: Z.value })
1563
+ }, [
1564
+ ($(), re(yl(Yt.value), {
1565
+ key: i.value,
1566
+ modelValue: Ft.value,
1567
+ "onUpdate:modelValue": Q[4] || (Q[4] = (Xe) => Ft.value = Xe),
1568
+ "tile-index": R.index
1569
+ }, {
1570
+ menu: oe(() => [
1571
+ B(ml, { class: "flex items-center gap-2" }, {
1572
+ default: oe(() => {
1573
+ var Xe, $t, At, Et;
1574
+ return [
1575
+ B(Re, {
1576
+ variant: "plain",
1577
+ placement: "right",
1578
+ content: ce.value.description,
1579
+ "hide-arrow": !0,
1580
+ disabled: !ce.value.description
1581
+ }, {
1582
+ default: oe(() => [
1583
+ F.value !== !1 ? ($(), te("p", {
1584
+ key: 0,
1585
+ style: Ee({
1586
+ fontSize: C.value + "px",
1587
+ fontWeight: g.value ? "bold" : "normal",
1588
+ fontStyle: W.value ? "italic" : "normal",
1589
+ textDecoration: v.value ? "underline" : "none"
1590
+ }),
1591
+ class: qe(["text-fm-color-typo-secondary line-clamp-1", [
1592
+ C.value <= 18 ? "fm-typo-en-body-md-400" : "",
1593
+ ce.value.description ? "border-b-2 border-dashed border-gray-300" : ""
1594
+ ]])
1595
+ }, Te(s(He)(s(y), s(S), ce.value.title, "other")), 7)) : Fe("", !0)
1596
+ ]),
1597
+ _: 1
1598
+ }, 8, ["content", "disabled"]),
1599
+ (Xe = Ge.value) != null && Xe.showSearchBar ? ($(), re(Ze, {
1600
+ key: 0,
1601
+ modelValue: u.value,
1602
+ "onUpdate:modelValue": Q[1] || (Q[1] = (Ve) => u.value = Ve),
1603
+ class: "grow"
1604
+ }, null, 8, ["modelValue"])) : ($(), te("div", ca)),
1605
+ bl(B(il, {
1606
+ modelValue: p.value,
1607
+ "onUpdate:modelValue": Q[2] || (Q[2] = (Ve) => p.value = Ve),
1608
+ label: "Label",
1609
+ value: !1
1610
+ }, null, 8, ["modelValue"]), [
1611
+ [wl, ($t = Ge.value) == null ? void 0 : $t.showLabel]
1612
+ ]),
1613
+ (At = Ge.value) != null && At.showDrillDimension && We.value.length > 0 ? ($(), te("div", da, [
1614
+ B(ut, {
1615
+ icon: "arrow_upward",
1616
+ variant: "tertiary",
1617
+ disabled: !d.value,
1618
+ onClick: al
1619
+ }, null, 8, ["disabled"]),
1620
+ B(ut, {
1621
+ icon: "arrow_downward",
1622
+ variant: "tertiary",
1623
+ disabled: !_.value,
1624
+ onClick: sl
1625
+ }, null, 8, ["disabled"])
1626
+ ])) : Fe("", !0),
1627
+ (Et = Ge.value) != null && Et.showRollup && Lt.value.length > 0 ? ($(), re(ul, {
1628
+ key: 3,
1629
+ modelValue: D.value,
1630
+ "onUpdate:modelValue": Q[3] || (Q[3] = (Ve) => D.value = Ve),
1631
+ class: "w-[150px]",
1632
+ items: Lt.value
1633
+ }, null, 8, ["modelValue", "items"])) : Fe("", !0),
1634
+ R.hideExport ? Fe("", !0) : ($(), re(dl, {
1635
+ key: 4,
1636
+ shift: !0
1637
+ }, {
1638
+ "menu-button": oe(() => [
1639
+ B(ut, {
1640
+ icon: "more_vert",
1641
+ variant: "tertiary"
1642
+ })
1643
+ ]),
1644
+ default: oe(() => [
1645
+ ($(!0), te(be, null, nt(s(ol), (Ve) => ($(), re(cl, {
1646
+ key: Ve.value,
1647
+ label: Ve.label,
1648
+ onClick: Ve.onClick
1649
+ }, null, 8, ["label", "onClick"]))), 128))
1650
+ ]),
1651
+ _: 1
1652
+ }))
1653
+ ];
1654
+ }),
1655
+ _: 1
1656
+ })
1657
+ ]),
1658
+ _: 1
1659
+ }, 8, ["modelValue", "tile-index"]))
1660
+ ], 4)) : ($(), re(pl, { key: 1 }))
1661
+ ]),
1662
+ _: 1
1663
+ }, 8, ["class", "variant"]);
1664
+ };
1665
+ }
1666
+ });
1667
+ var Oe = /* @__PURE__ */ ((e) => (e.Select = "Select", e.TextField = "TextField", e.Timestamp = "Timestamp", e))(Oe || {});
1668
+ function ma(e) {
1669
+ let a = !1, n = 1;
1670
+ switch (e) {
1671
+ case Ce.Equal:
1672
+ case Ce.NotEqual:
1673
+ case Ce.Like:
1674
+ case Ce.NotLike:
1675
+ a = !1, n = 1;
1676
+ break;
1677
+ case Ce.GreaterThan:
1678
+ case Ce.GreaterThanOrEqual:
1679
+ case Ce.LessThan:
1680
+ case Ce.LessThanOrEqual:
1681
+ a = !0, n = 1;
1682
+ break;
1683
+ case Ce.Between:
1684
+ a = !0, n = 2;
1685
+ break;
1686
+ }
1687
+ return {
1688
+ fixed: a,
1689
+ count: n
1690
+ };
1691
+ }
1692
+ function Ba({
1693
+ operator: e,
1694
+ dimensionOption: a,
1695
+ dataType: n,
1696
+ t: l
1697
+ }) {
1698
+ const { fixed: y, count: S } = ma(e);
1699
+ switch (n) {
1700
+ case ze.String:
1701
+ return {
1702
+ type: "TextField",
1703
+ fixed: y,
1704
+ count: S,
1705
+ dataType: void 0,
1706
+ default: ""
1707
+ };
1708
+ case ze.Numeric:
1709
+ return {
1710
+ type: "TextField",
1711
+ fixed: y,
1712
+ count: S,
1713
+ dataType: "number",
1714
+ default: 0
1715
+ };
1716
+ case ze.Bool:
1717
+ return {
1718
+ type: "Select",
1719
+ fixed: y,
1720
+ count: S,
1721
+ options: [
1722
+ { label: l("report.common.yes"), value: !0 },
1723
+ { label: l("report.common.no"), value: !1 }
1724
+ ],
1725
+ default: !0
1726
+ };
1727
+ case ze.Timestamp:
1728
+ return Gt({
1729
+ dimensionOption: a,
1730
+ fixed: y,
1731
+ count: S,
1732
+ t: l
1733
+ });
1734
+ }
1735
+ return {
1736
+ type: "TextField",
1737
+ fixed: y,
1738
+ count: S,
1739
+ dataType: void 0,
1740
+ default: ""
1741
+ };
1742
+ }
1743
+ function Ha(e) {
1744
+ switch (e) {
1745
+ case pe.HourOfDay:
1746
+ return 0;
1747
+ case pe.DayOfMonth:
1748
+ return 1;
1749
+ default:
1750
+ return;
1751
+ }
1752
+ }
1753
+ function Oa(e) {
1754
+ switch (e) {
1755
+ case pe.HourOfDay:
1756
+ return 23;
1757
+ case pe.DayOfMonth:
1758
+ return 31;
1759
+ default:
1760
+ return;
1761
+ }
1762
+ }
1763
+ function Gt({
1764
+ dimensionOption: e,
1765
+ fixed: a,
1766
+ count: n,
1767
+ t: l
1768
+ }) {
1769
+ switch (e) {
1770
+ case pe.HourOfDay:
1771
+ return {
1772
+ type: Oe.Select,
1773
+ fixed: a,
1774
+ count: n,
1775
+ options: Array.from({ length: 24 }, (y, S) => ({
1776
+ label: S.toString().padStart(2, "0"),
1777
+ value: S.toString()
1778
+ })),
1779
+ default: "0"
1780
+ };
1781
+ case pe.DayOfWeek:
1782
+ return {
1783
+ type: Oe.Select,
1784
+ fixed: a,
1785
+ count: n,
1786
+ options: [
1787
+ { label: l("report.days.sunday"), value: "1" },
1788
+ { label: l("report.days.monday"), value: "2" },
1789
+ { label: l("report.days.tuesday"), value: "3" },
1790
+ { label: l("report.days.wednesday"), value: "4" },
1791
+ { label: l("report.days.thursday"), value: "5" },
1792
+ { label: l("report.days.friday"), value: "6" },
1793
+ { label: l("report.days.saturday"), value: "7" }
1794
+ ],
1795
+ default: "1"
1796
+ };
1797
+ case pe.DayOfMonth:
1798
+ return {
1799
+ type: Oe.Select,
1800
+ fixed: a,
1801
+ count: n,
1802
+ options: Array.from({ length: 31 }, (y, S) => ({
1803
+ label: (S + 1).toString(),
1804
+ value: (S + 1).toString()
1805
+ })),
1806
+ default: "1"
1807
+ };
1808
+ case pe.MonthOfYear:
1809
+ return {
1810
+ type: Oe.Select,
1811
+ fixed: a,
1812
+ count: n,
1813
+ options: [
1814
+ { label: l("report.months.january"), value: "1" },
1815
+ { label: l("report.months.february"), value: "2" },
1816
+ { label: l("report.months.march"), value: "3" },
1817
+ { label: l("report.months.april"), value: "4" },
1818
+ { label: l("report.months.may"), value: "5" },
1819
+ { label: l("report.months.june"), value: "6" },
1820
+ { label: l("report.months.july"), value: "7" },
1821
+ { label: l("report.months.august"), value: "8" },
1822
+ { label: l("report.months.september"), value: "9" },
1823
+ { label: l("report.months.october"), value: "10" },
1824
+ { label: l("report.months.november"), value: "11" },
1825
+ { label: l("report.months.december"), value: "12" }
1826
+ ],
1827
+ default: "1"
1828
+ };
1829
+ default:
1830
+ return {
1831
+ type: Oe.Timestamp,
1832
+ fixed: a,
1833
+ count: n,
1834
+ default: (/* @__PURE__ */ new Date()).toISOString()
1835
+ };
1836
+ }
1837
+ }
1838
+ function Wt({
1839
+ dimensionOption: e,
1840
+ t: a
1841
+ }) {
1842
+ const n = Gt({
1843
+ dimensionOption: e,
1844
+ fixed: !1,
1845
+ count: 1,
1846
+ t: a
1847
+ });
1848
+ return n.type === Oe.Select ? n.options : [];
1849
+ }
1850
+ const pa = "mf-reportglobalFilter";
1851
+ function Pt(e, a) {
1852
+ var n;
1853
+ return [
1854
+ a,
1855
+ e.schemaName,
1856
+ e.name,
1857
+ e.operator ?? "",
1858
+ e.option ?? "",
1859
+ e.dataFormula ?? "",
1860
+ ((n = e.tileIds) == null ? void 0 : n.join(",")) ?? ""
1861
+ ].join("|");
1862
+ }
1863
+ const ha = Ot(pa, () => {
1864
+ const e = f({}), a = f(!1), n = () => ({
1865
+ search: "",
1866
+ selectedValues: [],
1867
+ keepSelection: !1,
1868
+ showAdvanced: !1,
1869
+ visibleCount: 50
1870
+ });
1871
+ function l(D, i) {
1872
+ const c = Pt(D, i);
1873
+ return e.value[c] || (e.value[c] = n()), e.value[c];
1874
+ }
1875
+ function y(D, i, c, m) {
1876
+ l(D, i)[c] = m;
1877
+ }
1878
+ function S(D, i, c = 50) {
1879
+ l(D, i).visibleCount += c;
1880
+ }
1881
+ function R(D) {
1882
+ a.value = D;
1883
+ }
1884
+ return {
1885
+ allStates: x(() => e.value),
1886
+ getGlobalFilter: l,
1887
+ setGlobalFilter: y,
1888
+ showMore: S,
1889
+ includeUnavailable: a,
1890
+ setIncludeUnavailable: R,
1891
+ getKey: Pt
1892
+ };
1893
+ }), fa = { class: "flex flex-row flex-wrap gap-2" }, va = { class: "inline-flex max-w-[460px]" }, ga = {
1894
+ key: 0,
1895
+ class: "flex justify-center my-2"
1896
+ }, ya = { class: "px-2 pb-8" }, ba = { class: "flex-1 overflow-y-auto overflow-x-hidden" }, wa = { class: "px-2 pb-8" }, xa = { class: "flex items-start w-full" }, Sa = ["onClick"], Ca = { class: "fm-typo-en-body-md-400" }, ka = { key: 0 }, _a = { class: "px-12 py-3" }, Ta = { class: "flex items-center justify-between" }, Fa = ["onClick"], La = { class: "fm-typo-en-body-md-400" }, Da = { class: "text-xs max-w-[200px]" }, Ra = { class: "px-4 py-3 flex flex-row justify-end gap-2 bg-white" }, qa = /* @__PURE__ */ Le({
1897
+ __name: "FilterSelector",
1898
+ setup(e) {
1899
+ const { t: a, locale: n } = tt(), { currentReport: l, editingTile: y } = $e(kl());
1900
+ let { globalFilters: S, isGlobalFiltersLoading: R, timeRange: V, dateRange: D, selectedLocationIds: i } = $e(Qe()), { schemas: c } = $e(_l()), {
1901
+ showMore: m,
1902
+ getGlobalFilter: d,
1903
+ setGlobalFilter: _,
1904
+ setIncludeUnavailable: F,
1905
+ getKey: C,
1906
+ isMenuOpen: g,
1907
+ openMenu: W,
1908
+ closeMenu: v
1909
+ } = ha(), o = null;
1910
+ const k = f(!1), p = x(() => {
1911
+ var t;
1912
+ return ((t = l.value) == null ? void 0 : t.id) ?? "";
1913
+ }), L = f([]);
1914
+ function U(t) {
1915
+ const T = d(t.filter, p.value).selectedValues;
1916
+ t.selectedValues = t.keepSelection ? T : t.options.map((w) => w.value), t.filter.values = [...t.selectedValues], _(t.filter, p.value, "selectedValues", t.selectedValues);
1917
+ }
1918
+ he(
1919
+ () => ({
1920
+ reportId: p.value,
1921
+ globalFilters: S.value
1922
+ }),
1923
+ () => {
1924
+ L.value = (S.value || []).map((t) => {
1925
+ const h = d(t, p.value), T = h.selectedValues.length ? [...h.selectedValues] : [...t.values ?? []];
1926
+ return {
1927
+ id: C(t, p.value),
1928
+ filter: t,
1929
+ search: h.search,
1930
+ options: [],
1931
+ type: J(t),
1932
+ selectedValues: T,
1933
+ visibleCount: h.visibleCount,
1934
+ keepSelection: h.keepSelection,
1935
+ showAdvanced: h.showAdvanced
1936
+ };
1937
+ }), fe();
1938
+ },
1939
+ { immediate: !0 }
1940
+ ), he(
1941
+ [V, D, i],
1942
+ async () => {
1943
+ await fe();
1944
+ },
1945
+ { deep: !0, immediate: !0 }
1946
+ ), he(
1947
+ [() => y.value],
1948
+ async () => {
1949
+ L.value.forEach((t) => {
1950
+ t.options = [];
1951
+ }), await fe();
1952
+ },
1953
+ { deep: !0 }
1954
+ );
1955
+ function J(t) {
1956
+ var T;
1957
+ const h = (T = c.value.find((w) => w.name === t.schemaName)) == null ? void 0 : T.fields.find((w) => w.name === t.name);
1958
+ return h == null ? void 0 : h.type;
1959
+ }
1960
+ function ee(t) {
1961
+ var me;
1962
+ if (!l.value && !y.value) return [];
1963
+ const h = y.value ? [y.value] : [...((me = l.value) == null ? void 0 : me.tiles) ?? []], { name: T = "", schemaName: w = "" } = t, N = h.filter((K) => {
1964
+ var Z, q;
1965
+ const E = (Z = K == null ? void 0 : K.widget) == null ? void 0 : Z.config;
1966
+ if (!E || (q = t.tileIds) != null && q.length && !t.tileIds.includes(K.id)) return !1;
1967
+ const u = (E.dimensions ?? []).some(
1968
+ (ne) => ne.schemaName === w && ne.name === T
1969
+ ), X = (E.joinDatasources ?? []).some(
1970
+ (ne) => (ne.dimensions ?? []).some((ae) => ae.schemaName === w && ae.name === T)
1971
+ ), j = (E.schemaNames ?? []).includes(w);
1972
+ return u || X || j;
1973
+ });
1974
+ if (!N.length) return [];
1975
+ const le = (K, E) => {
1976
+ const u = /* @__PURE__ */ new Map(), X = (j) => {
1977
+ const Z = `${j.schemaName}:${j.name}:${j.operator}`, q = u.get(Z);
1978
+ q ? [Ce.Like, Ce.NotLike].includes(j.operator) ? q.values = Array.from(/* @__PURE__ */ new Set([...q.values ?? [], ...j.values ?? []])) : u.set(Z, { ...j }) : u.set(Z, { ...j });
1979
+ };
1980
+ return K.forEach(X), E.forEach(X), Array.from(u.values());
1981
+ }, de = (K) => {
1982
+ var u;
1983
+ const E = (u = K.dimensions) == null ? void 0 : u.find(
1984
+ (X) => X.schemaName === w && X.name === T
1985
+ );
1986
+ return {
1987
+ name: T,
1988
+ schemaName: w,
1989
+ label: (E == null ? void 0 : E.label) ?? T,
1990
+ hide: !1,
1991
+ option: t.option ?? null,
1992
+ dataFormula: E == null ? void 0 : E.dataFormula
1993
+ };
1994
+ };
1995
+ return N.map((K) => {
1996
+ var ne, ae;
1997
+ const E = (ne = K == null ? void 0 : K.widget) == null ? void 0 : ne.config;
1998
+ if (!E) return null;
1999
+ const u = de(E), X = (E.dimensions ?? []).some((ye) => ye.schemaName === w) || (E.schemaNames ?? []).includes(w), j = le(
2000
+ E.filters ?? [],
2001
+ (t.filters ?? []).filter((ye) => {
2002
+ var ue;
2003
+ return (ue = E.schemaNames) == null ? void 0 : ue.includes(ye.schemaName);
2004
+ })
2005
+ ), Z = (ae = E.joinDatasources) == null ? void 0 : ae.find(
2006
+ (ye) => (ye.schemaNames ?? []).includes(w) || (ye.dimensions ?? []).some((ue) => ue.schemaName === w)
2007
+ ), q = le(
2008
+ (Z == null ? void 0 : Z.filters) ?? [],
2009
+ (t.filters ?? []).filter((ye) => {
2010
+ var ue;
2011
+ return (ue = Z == null ? void 0 : Z.schemaNames) == null ? void 0 : ue.includes(ye.schemaName);
2012
+ })
2013
+ );
2014
+ return {
2015
+ type: A.Table,
2016
+ title: "Global Filter",
2017
+ config: {
2018
+ schemaNames: E.schemaNames,
2019
+ schemas: E.schemas,
2020
+ dimensions: X ? [u] : [],
2021
+ filters: j,
2022
+ sorts: X ? [{ name: T, schemaName: w, type: Be.Asc, aggregation: null, dimensionOption: null }] : [],
2023
+ joinDatasources: !X && Z ? [
2024
+ {
2025
+ ...Z,
2026
+ dimensions: [u],
2027
+ sorts: [
2028
+ {
2029
+ name: T,
2030
+ schemaName: w,
2031
+ type: Be.Asc,
2032
+ aggregation: null,
2033
+ dimensionOption: null
2034
+ }
2035
+ ],
2036
+ filters: q
2037
+ }
2038
+ ] : [],
2039
+ rowIds: [],
2040
+ metrics: [],
2041
+ limit: null,
2042
+ rollup: void 0,
2043
+ drillDimension: void 0,
2044
+ showGrandTotal: !1,
2045
+ breakdownDimension: void 0,
2046
+ sparklineDimension: void 0,
2047
+ isTransposed: !1,
2048
+ isDrillable: !1,
2049
+ isBlend: !1
2050
+ }
2051
+ };
2052
+ }).filter(Boolean);
2053
+ }
2054
+ function se(t) {
2055
+ return t.options.every((h) => {
2056
+ var T;
2057
+ return (T = t.selectedValues) == null ? void 0 : T.includes(h.value);
2058
+ });
2059
+ }
2060
+ function ke(t) {
2061
+ se(t) ? t.selectedValues = ["(EMPTY)"] : t.selectedValues = t.options.map((h) => h.value);
2062
+ }
2063
+ const ve = x(
2064
+ () => L.value.map((t) => {
2065
+ const h = t.options, T = t.search.toLowerCase() ?? "";
2066
+ return h.filter(
2067
+ (N) => N.label.toLowerCase().includes(T.toLowerCase())
2068
+ ).slice(0, t.visibleCount);
2069
+ })
2070
+ );
2071
+ function _e(t) {
2072
+ t.visibleCount += 50, m(t.filter, p.value, 50);
2073
+ }
2074
+ async function De(t, h) {
2075
+ var T;
2076
+ if (!(!t.type && (t.type = J(t.filter), !t.type)))
2077
+ switch (t.type) {
2078
+ case ze.String:
2079
+ try {
2080
+ const w = ee(t.filter);
2081
+ if (!w.length) {
2082
+ t.options = [];
2083
+ return;
2084
+ }
2085
+ const N = [];
2086
+ for (const E of w) {
2087
+ const u = await Ht(E, h);
2088
+ (u == null ? void 0 : u.type) === A.Table && N.push(...u.rows.map((X) => {
2089
+ var j;
2090
+ return ((j = X.cells) == null ? void 0 : j[0]) ?? " ";
2091
+ }));
2092
+ }
2093
+ const le = Array.from(new Set(N)), de = (T = d(t.filter, p.value).selectedValues) != null && T.length ? d(t.filter, p.value).selectedValues : t.selectedValues || [], me = t.keepSelection ? Array.from(/* @__PURE__ */ new Set([...le, ...de])) : le, K = new Set(N);
2094
+ t.options = me.map((E) => ({
2095
+ label: String(E),
2096
+ value: E,
2097
+ available: t.keepSelection ? K.has(E) : new Set(le).has(E)
2098
+ })), U(t);
2099
+ } catch (w) {
2100
+ if ((w == null ? void 0 : w.code) === "ERR_CANCELED" || (w == null ? void 0 : w.name) === "CanceledError")
2101
+ return;
2102
+ throw w;
2103
+ }
2104
+ break;
2105
+ case ze.Bool: {
2106
+ t.options = [
2107
+ { label: "Yes", value: !0 },
2108
+ { label: "No", value: !1 }
2109
+ ], U(t);
2110
+ break;
2111
+ }
2112
+ case ze.Timestamp:
2113
+ if (t.filter.option !== pe.DateTime && t.filter.option !== pe.TimeOfDay) {
2114
+ const w = t.filter.option;
2115
+ t.options = Wt({ dimensionOption: w, t: a }), t.filter.values = t.options.length ? t.options.map((N) => N.value) : ["NULL"];
2116
+ }
2117
+ U(t);
2118
+ break;
2119
+ case ze.Numeric:
2120
+ break;
2121
+ }
2122
+ }
2123
+ async function fe(t = !1) {
2124
+ if (!p.value || !L.value.length) return;
2125
+ o == null || o.abort();
2126
+ const h = new AbortController();
2127
+ o = h;
2128
+ try {
2129
+ t || (R.value = !0), k.value = !0, await Promise.all(
2130
+ L.value.map((T) => De(T, h.signal))
2131
+ );
2132
+ } finally {
2133
+ o === h && (t || (R.value = !1), k.value = !1);
2134
+ }
2135
+ }
2136
+ function b(t, h) {
2137
+ var w;
2138
+ if ((w = t.selectedValues) == null ? void 0 : w.includes(h)) {
2139
+ let N = (t.selectedValues || []).filter((le) => le !== h && le !== "(EMPTY)");
2140
+ t.selectedValues = N.length > 0 ? N : ["(EMPTY)"];
2141
+ } else
2142
+ t.selectedValues = [...(t.selectedValues || []).filter((N) => N !== "(EMPTY)"), h];
2143
+ _(t.filter, p.value, "selectedValues", t.selectedValues);
2144
+ }
2145
+ function z(t, h) {
2146
+ if (h === null)
2147
+ t.values = [];
2148
+ else {
2149
+ const w = Je(h.startDate).startOf("day").utc().toISOString(), N = Je(h.endDate).endOf("day").utc().toISOString();
2150
+ t.values = [w, N];
2151
+ }
2152
+ const T = L.value.find((w) => w.id === C(t, p.value));
2153
+ T && (T.keepSelection = h !== null, _(T.filter, p.value, "keepSelection", T.keepSelection));
2154
+ }
2155
+ function G(t) {
2156
+ const h = (t.selectedValues || []).filter((T) => T !== "(EMPTY)");
2157
+ return `${a("report.section.filter.selectAll")} (${h.length}/${t.options.length})`;
2158
+ }
2159
+ function P(t) {
2160
+ const h = t.options.length, T = a("report.section.filter.search"), w = a("report.common.results", { count: h });
2161
+ return `${T} (${w})`;
2162
+ }
2163
+ function I(t) {
2164
+ var le, de, me, K, E;
2165
+ const h = Fl(t.filter);
2166
+ if (t.type === ze.Timestamp) {
2167
+ const u = ((le = t.filter.values) == null ? void 0 : le.length) === 2;
2168
+ if (t.filter.option === pe.DateTime)
2169
+ return { preview: u ? `${h} is between ${Rl({
2170
+ startDate: ((de = t.filter.values) == null ? void 0 : de[0]) || null,
2171
+ endDate: ((me = t.filter.values) == null ? void 0 : me[1]) || null,
2172
+ locale: n.value
2173
+ })}` : h, suffix: "" };
2174
+ if (t.filter.option === pe.TimeOfDay) {
2175
+ const X = (K = t.filter.values) != null && K[0] ? Je(t.filter.values[0]) : null, j = (E = t.filter.values) != null && E[1] ? Je(t.filter.values[1]) : null, Z = (ne) => ne && ne.isValid() ? { hour: ne.hour(), minute: ne.minute() } : null;
2176
+ return { preview: u ? `${h} is between ${Vl({
2177
+ startTime: Z(X),
2178
+ endTime: Z(j),
2179
+ locale: n.value
2180
+ })}` : h, suffix: "" };
2181
+ }
2182
+ if (t.filter.option !== pe.DateTime && t.filter.option !== pe.TimeOfDay) {
2183
+ const X = Wt({
2184
+ dimensionOption: t.filter.option,
2185
+ t: a
2186
+ }), j = new Map(X.map((ae) => [String(ae.value), ae.label])), q = (t.selectedValues || []).filter((ae) => ae !== "(EMPTY)").map((ae) => j.get(String(ae)) ?? String(ae)), ne = q.map((ae) => ae.length > 20 ? `${ae.slice(0, 20)}…` : ae).join(", ");
2187
+ return q.length ? {
2188
+ preview: `${h}: ${ne}`,
2189
+ suffix: `(${q.length} selected)`
2190
+ } : { preview: h, suffix: "" };
2191
+ }
2192
+ }
2193
+ const w = (t.selectedValues || []).filter((u) => u !== "(EMPTY)").map((u) => u === !0 ? a("report.common.yes") || "Yes" : u === !1 ? a("report.common.no") || "No" : String(u)), N = w.map((u) => u.length > 20 ? `${u.slice(0, 20)}…` : u).join(", ");
2194
+ return w.length ? {
2195
+ preview: `${h}: ${N}`,
2196
+ suffix: `(${w.length} selected)`
2197
+ } : { preview: N, suffix: `${h}` };
2198
+ }
2199
+ function M(t) {
2200
+ t.filter.values = [...t.selectedValues || []], _(t.filter, p.value, "selectedValues", t.selectedValues), v();
2201
+ }
2202
+ function ie(t) {
2203
+ t.showAdvanced = !t.showAdvanced, _(t.filter, p.value, "showAdvanced", t.showAdvanced);
2204
+ }
2205
+ function xe(t) {
2206
+ t.keepSelection = !t.keepSelection, F(t.keepSelection), _(t.filter, p.value, "keepSelection", t.keepSelection), t.options = [], fe(!0);
2207
+ }
2208
+ function Se(t, h) {
2209
+ return t ? t.length > h ? `${t.slice(0, h)}…` : t : "";
2210
+ }
2211
+ function ge(t, h) {
2212
+ var w, N, le, de;
2213
+ if (h === null)
2214
+ t.values = [];
2215
+ else {
2216
+ const me = Je().set("hour", Number((w = h.start) == null ? void 0 : w.hour)).set("minute", Number((N = h.start) == null ? void 0 : N.minute)).toISOString(), K = Je().set("hour", Number((le = h.end) == null ? void 0 : le.hour)).set("minute", Number((de = h.end) == null ? void 0 : de.minute)).toISOString();
2217
+ t.values = [me, K];
2218
+ }
2219
+ const T = L.value.find((me) => me.id === C(t, p.value));
2220
+ T && (T.keepSelection = h !== null, _(T.filter, p.value, "keepSelection", T.keepSelection));
2221
+ }
2222
+ return (t, h) => {
2223
+ const T = H("FmCircularProgress"), w = H("FmTextField"), N = H("FmMenuItem"), le = H("FmTooltip"), de = H("FmIcon"), me = H("FmMenuDivider"), K = H("FmButton"), E = H("FmMenu");
2224
+ return $(), te("div", fa, [
2225
+ ($(!0), te(be, null, nt(L.value, (u, X) => {
2226
+ var j, Z, q, ne, ae, ye;
2227
+ return $(), te("div", {
2228
+ key: `${u.id}`
2229
+ }, [
2230
+ u.filter.option === s(pe).DateTime ? ($(), re(Ll, {
2231
+ key: 0,
2232
+ "model-value": { startDate: (j = u.filter.values) == null ? void 0 : j[0], endDate: (Z = u.filter.values) == null ? void 0 : Z[1] },
2233
+ class: "w-full",
2234
+ label: I(u).preview,
2235
+ removable: ((q = u.filter.values) == null ? void 0 : q.length) === 2,
2236
+ onUpdate: (ue) => z(u.filter, ue),
2237
+ onChipClosed: () => z(u.filter, null)
2238
+ }, null, 8, ["model-value", "label", "removable", "onUpdate", "onChipClosed"])) : u.filter.option === s(pe).TimeOfDay ? ($(), re(Tl, {
2239
+ key: 1,
2240
+ "model-value": { start: (ne = u.filter.values) == null ? void 0 : ne[0], end: (ae = u.filter.values) == null ? void 0 : ae[1] },
2241
+ class: "w-full",
2242
+ label: I(u).preview,
2243
+ removable: ((ye = u.filter.values) == null ? void 0 : ye.length) === 2,
2244
+ onUpdate: (ue) => ge(u.filter, ue),
2245
+ onChipClosed: () => ge(u.filter, null)
2246
+ }, null, 8, ["model-value", "label", "removable", "onUpdate", "onChipClosed"])) : ($(), re(E, {
2247
+ key: 2,
2248
+ "close-on-click": !1,
2249
+ shift: !0,
2250
+ open: s(g)(u.id),
2251
+ onMenuChanged: (ue) => ue ? s(W)(u.id) : s(v)()
2252
+ }, {
2253
+ "menu-button": oe(() => [
2254
+ O("div", va, [
2255
+ B(Dl, {
2256
+ "left-icon": "filter_alt",
2257
+ "trailing-icon": "expand_more",
2258
+ label: I(u).preview,
2259
+ class: "w-full"
2260
+ }, {
2261
+ default: oe(() => [
2262
+ ht(Te(I(u).suffix), 1)
2263
+ ]),
2264
+ _: 2
2265
+ }, 1032, ["label"])
2266
+ ])
2267
+ ]),
2268
+ "menu-wrapper": oe(({ maxHeight: ue, width: Ge }) => [
2269
+ O("div", {
2270
+ class: "flex flex-col bg-fm-color-neutral-white p-2 rounded-lg shadow-light-300",
2271
+ style: Ee({ maxHeight: `${ue}px`, width: Ge })
2272
+ }, [
2273
+ k.value ? ($(), te("div", ga, [
2274
+ B(T)
2275
+ ])) : u.options.length > 0 && !s(R) ? ($(), te(be, { key: 1 }, [
2276
+ O("div", ya, [
2277
+ B(w, {
2278
+ modelValue: u.search,
2279
+ "onUpdate:modelValue": [
2280
+ (Y) => u.search = Y,
2281
+ (Y) => s(_)(u.filter, p.value, "search", Y)
2282
+ ],
2283
+ type: "text",
2284
+ "prepend-icon": "search",
2285
+ placeholder: P(u),
2286
+ class: "border px-2 pb-8 text-sm mb-1 rounded"
2287
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder"])
2288
+ ]),
2289
+ O("div", ba, [
2290
+ O("div", wa, [
2291
+ B(N, {
2292
+ label: G(u),
2293
+ "has-checkbox": !0,
2294
+ "model-value": se(u),
2295
+ indeterminate: !0,
2296
+ onClick: (Y) => ke(u)
2297
+ }, null, 8, ["label", "model-value", "onClick"]),
2298
+ ($(!0), te(be, null, nt(ve.value[X], (Y) => ($(), te(be, {
2299
+ key: Y.value
2300
+ }, [
2301
+ Y.label && Y.label.length > 110 ? ($(), re(le, {
2302
+ key: 0,
2303
+ placement: "right",
2304
+ "hide-arrow": !0,
2305
+ "z-index": 2e3
2306
+ }, {
2307
+ content: oe(() => [
2308
+ ht(Te(Y.label), 1)
2309
+ ]),
2310
+ default: oe(() => [
2311
+ O("div", xa, [
2312
+ B(N, {
2313
+ label: Se(Y.label, 110),
2314
+ "has-checkbox": !0,
2315
+ "model-value": u.selectedValues.includes(Y.value),
2316
+ class: qe([
2317
+ "flex-1 text-left",
2318
+ { "bg-gray-200": Y.available === !1 }
2319
+ ]),
2320
+ onClick: () => b(u, Y.value)
2321
+ }, null, 8, ["label", "model-value", "class", "onClick"])
2322
+ ])
2323
+ ]),
2324
+ _: 2
2325
+ }, 1024)) : ($(), re(N, {
2326
+ key: 1,
2327
+ label: Y.label,
2328
+ "has-checkbox": !0,
2329
+ "model-value": u.selectedValues.includes(Y.value),
2330
+ class: qe(["flex-1 text-left", { "bg-gray-100": Y.available === !1 }]),
2331
+ onClick: () => b(u, Y.value)
2332
+ }, null, 8, ["label", "model-value", "class", "onClick"]))
2333
+ ], 64))), 128)),
2334
+ ve.value[X].length < u.options.length && !u.search ? ($(), re(N, {
2335
+ key: 0,
2336
+ class: "fm-typo-en-body-md-400 -ml-2",
2337
+ label: s(a)("report.section.filter.loadMore"),
2338
+ onClick: ct((Y) => _e(u), ["stop"]),
2339
+ icon: "autorenew"
2340
+ }, null, 8, ["label", "onClick"])) : Fe("", !0)
2341
+ ])
2342
+ ]),
2343
+ O("div", {
2344
+ class: "px-12 py-2 flex items-center gap-2 cursor-pointer hover:bg-fm-color-neutral-50 transition-colors",
2345
+ onClick: (Y) => ie(u)
2346
+ }, [
2347
+ B(de, {
2348
+ name: u.showAdvanced ? "keyboard_arrow_up" : "keyboard_arrow_down",
2349
+ size: "md",
2350
+ class: ""
2351
+ }, null, 8, ["name"]),
2352
+ O("span", Ca, Te(s(a)("report.section.filter.advanced")), 1)
2353
+ ], 8, Sa),
2354
+ B(me),
2355
+ u.showAdvanced ? ($(), te("div", ka, [
2356
+ O("div", _a, [
2357
+ O("div", Ta, [
2358
+ O("div", {
2359
+ class: "flex items-center gap-2 cursor-pointer",
2360
+ onClick: (Y) => xe(u)
2361
+ }, [
2362
+ B(de, {
2363
+ name: u.keepSelection ? "check_box" : "check_box_outline_blank",
2364
+ size: "md",
2365
+ class: qe(
2366
+ u.keepSelection ? "text-fm-color-primary" : "text-fm-color-neutral-gray-400"
2367
+ )
2368
+ }, null, 8, ["name", "class"]),
2369
+ O("span", La, Te(s(a)("report.section.filter.keepSelection")), 1)
2370
+ ], 8, Fa),
2371
+ B(le, {
2372
+ placement: "top",
2373
+ "z-index": 2e3
2374
+ }, {
2375
+ content: oe(() => [
2376
+ O("div", Da, Te(s(a)("report.section.filter.keepSelectionTooltip")), 1)
2377
+ ]),
2378
+ default: oe(() => [
2379
+ B(de, {
2380
+ name: "info",
2381
+ size: "md",
2382
+ class: "text-fm-color-primary"
2383
+ })
2384
+ ]),
2385
+ _: 1
2386
+ })
2387
+ ])
2388
+ ])
2389
+ ])) : Fe("", !0),
2390
+ O("div", Ra, [
2391
+ B(K, {
2392
+ variant: "tertiary",
2393
+ label: s(a)("report.common.cancel"),
2394
+ onClick: h[0] || (h[0] = ct((Y) => s(v)(), ["stop"]))
2395
+ }, null, 8, ["label"]),
2396
+ B(K, {
2397
+ color: "primary",
2398
+ onClick: ct((Y) => M(u), ["stop"]),
2399
+ label: s(a)("report.common.apply")
2400
+ }, null, 8, ["onClick", "label"])
2401
+ ])
2402
+ ], 64)) : s(R) ? Fe("", !0) : ($(), re(ft, { key: 2 }))
2403
+ ], 4)
2404
+ ]),
2405
+ _: 2
2406
+ }, 1032, ["open", "onMenuChanged"]))
2407
+ ]);
2408
+ }), 128)),
2409
+ Ne(t.$slots, "default")
2410
+ ]);
2411
+ };
2412
+ }
2413
+ });
2414
+ export {
2415
+ Oe as I,
2416
+ yt as L,
2417
+ Pe as R,
2418
+ Pa as _,
2419
+ qa as a,
2420
+ gt as b,
2421
+ Ha as c,
2422
+ Oa as d,
2423
+ Ba as e,
2424
+ mt as g,
2425
+ Nt as u
2426
+ };