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