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