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