@feedmepos/mf-report 5.4.36-beta.0 → 5.5.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1004 @@
1
+ import { defineComponent as H, useModel as O, computed as s, ref as F, resolveComponent as w, createElementBlock as L, openBlock as h, Fragment as W, renderSlot as G, createVNode as S, createElementVNode as k, toDisplayString as Z, unref as j, withCtx as B, createBlock as $, createCommentVNode as K, normalizeClass as le, normalizeStyle as _e, h as ge, renderList as Ce, mergeModels as Ee, watch as ae, onMounted as ze, onUnmounted as We, resolveDynamicComponent as He, withDirectives as Oe, vShow as qe } from "vue";
2
+ import { W as i, v as te, R as Ue, g as je, d as Ge, q as Je } from "./v4-BDHq16P_.js";
3
+ import { u as ie, b as xe, a as ue } from "./global-loader-BqFQzk46.js";
4
+ import { d as be } from "./index-Cmh079Bh.js";
5
+ import { storeToRefs as se } from "pinia";
6
+ import { _ as Ke } from "./_plugin-vue_export-helper-CHgC5LLL.js";
7
+ import { _ as ye } from "./NoData.vue_vue_type_script_setup_true_lang-DI4X_DSc.js";
8
+ import { useBreakpoints as Qe, useSnackbar as Ze } from "@feedmepos/ui-library";
9
+ var re = /* @__PURE__ */ ((t) => (t.line = "LINE", t.bar = "BAR", t))(re || {}), M = /* @__PURE__ */ ((t) => (t.top = "TOP", t.bottom = "BOTTOM", t))(M || {});
10
+ i.Circular, i.Table, i.BarChart, i.LineChart, i.StackBarChart, i.StackLineChart, i.Scorecard, i.Spacer;
11
+ const Xe = [
12
+ {
13
+ type: i.Circular,
14
+ showLabel: !1,
15
+ // TODO: temporarily removed show label as it has no function
16
+ showDrillDimension: !0,
17
+ showRollup: !1,
18
+ showSearchBar: !1
19
+ },
20
+ {
21
+ type: i.Table,
22
+ showLabel: !1,
23
+ showDrillDimension: !0,
24
+ showRollup: !0,
25
+ showSearchBar: !0
26
+ },
27
+ {
28
+ type: i.BarChart,
29
+ showLabel: !1,
30
+ // TODO: temporarily removed show label as it has no function
31
+ showDrillDimension: !0,
32
+ showRollup: !1,
33
+ showSearchBar: !1
34
+ },
35
+ {
36
+ type: i.LineChart,
37
+ showLabel: !1,
38
+ // TODO: temporarily removed show label as it has no function
39
+ showDrillDimension: !0,
40
+ showRollup: !0,
41
+ showSearchBar: !1
42
+ },
43
+ {
44
+ type: i.StackBarChart,
45
+ showLabel: !1,
46
+ // TODO: temporarily removed show label as it has no function
47
+ showDrillDimension: !0,
48
+ showRollup: !0,
49
+ showSearchBar: !1
50
+ },
51
+ {
52
+ type: i.StackLineChart,
53
+ showLabel: !1,
54
+ // TODO: temporarily removed show label as it has no function
55
+ showDrillDimension: !0,
56
+ showRollup: !0,
57
+ showSearchBar: !1
58
+ },
59
+ {
60
+ type: i.Scorecard,
61
+ showLabel: !1,
62
+ showDrillDimension: !1,
63
+ showRollup: !1,
64
+ showSearchBar: !1
65
+ },
66
+ {
67
+ type: i.Spacer,
68
+ showLabel: !1,
69
+ showDrillDimension: !1,
70
+ showRollup: !1,
71
+ showSearchBar: !1
72
+ }
73
+ ];
74
+ function oe(t) {
75
+ const e = [t.schemaName, t.name];
76
+ return "option" in t && t.option && e.push(t.option), "aggregation" in t && t.aggregation && e.push(t.aggregation), e.push(t.label.replace(/[^a-zA-Z0-9]/g, "")), e.join("_").toLowerCase();
77
+ }
78
+ function Ye(t, e) {
79
+ switch (t) {
80
+ case i.BarChart:
81
+ case i.LineChart:
82
+ case i.StackBarChart:
83
+ case i.StackLineChart:
84
+ return Array.isArray(e == null ? void 0 : e.datasets) && Array.isArray(e == null ? void 0 : e.xAxis) && e.datasets.length > 0 && e.xAxis.length > 0;
85
+ case i.Table:
86
+ return Array.isArray(e == null ? void 0 : e.rows) && Array.isArray(e == null ? void 0 : e.columns) && e.rows.length > 0 && e.columns.length > 0;
87
+ case i.Circular:
88
+ return Array.isArray(e == null ? void 0 : e.datasets) && e.datasets.length > 0;
89
+ case i.Scorecard:
90
+ return !0;
91
+ case i.Spacer:
92
+ return !0;
93
+ }
94
+ }
95
+ const we = [
96
+ "54, 162, 235",
97
+ //8CE6D7
98
+ "0, 123, 167",
99
+ //007BA7
100
+ "255, 93, 83",
101
+ //FF5D53
102
+ "115, 200, 230",
103
+ //73C8E6
104
+ "252, 162, 62",
105
+ //FCA23E
106
+ "240, 155, 190",
107
+ //F09BBE
108
+ "255, 210, 50",
109
+ //FFD232
110
+ "80, 190, 155",
111
+ //50BE9B
112
+ "131, 88, 212",
113
+ //8358D4
114
+ "155, 80, 70"
115
+ //9B5046
116
+ ];
117
+ function X({
118
+ index: t,
119
+ isCompare: e,
120
+ opacity: n
121
+ }) {
122
+ let p = typeof n == "number" ? n : 1;
123
+ return e && (p = p * 0.6), `rgba(${we[t % we.length]}, ${p})`;
124
+ }
125
+ function ke(t, e, n) {
126
+ if (t === "" || e === "")
127
+ return null;
128
+ let p = (o) => o == null ? void 0 : o.replace(/,/g, "");
129
+ n === "ID" && (p = (o) => o == null ? void 0 : o.replace(/\./g, "").replace(/,/g, "."));
130
+ const g = Number(p(t)), v = Number(p(e));
131
+ if (isNaN(g) || isNaN(v))
132
+ return null;
133
+ let u = 0;
134
+ v === 0 ? g === 0 ? u = 0 : u = 1 : u = (g - v) / v;
135
+ const l = ea(u);
136
+ return {
137
+ value: isNaN(u) ? "" : `${(u * 100).toFixed(0)}%`,
138
+ icon: l
139
+ };
140
+ }
141
+ function ea(t) {
142
+ return t > 0 ? {
143
+ name: "moving",
144
+ color: "#1F7735",
145
+ tailwind: "fm-color-system-success-100"
146
+ } : t < 0 ? {
147
+ name: "trending_down",
148
+ color: "#99231D",
149
+ tailwind: "fm-color-system-error-100"
150
+ } : {
151
+ name: "equal",
152
+ color: "#C7C7CC",
153
+ tailwind: "fm-color-neutral-gray-100"
154
+ };
155
+ }
156
+ const aa = /* @__PURE__ */ H({
157
+ __name: "WidgetBarchart",
158
+ props: {
159
+ modelValue: { required: !0 },
160
+ modelModifiers: {}
161
+ },
162
+ emits: ["update:modelValue"],
163
+ setup(t) {
164
+ const e = O(t, "modelValue"), n = s(() => {
165
+ var o;
166
+ return ((o = e.value.data) == null ? void 0 : o.xAxis) ?? [];
167
+ }), p = s(() => {
168
+ var o;
169
+ return ((o = e.value.data) == null ? void 0 : o.datasets) ?? [];
170
+ }), g = s(() => e.value.isTransposed ?? void 0), v = s(() => e.value.showLabel ?? void 0), u = F(null), l = s(() => p.value.length > 0 ? [
171
+ ...p.value.map((o, m) => ({
172
+ label: o.name,
173
+ data: o.values,
174
+ dash: !!o.isCompare,
175
+ backgroundColor: X({ index: m, isCompare: o.isCompare })
176
+ }))
177
+ ] : []);
178
+ return (o, m) => {
179
+ const R = w("FmBarChart");
180
+ return h(), L(W, null, [
181
+ G(o.$slots, "menu"),
182
+ S(R, {
183
+ ref_key: "chartRef",
184
+ ref: u,
185
+ class: "bar-chart",
186
+ datasets: l.value,
187
+ "x-axis": { categories: n.value },
188
+ transpose: g.value,
189
+ legend: {
190
+ display: !1,
191
+ position: "bottom",
192
+ maxHeight: 54,
193
+ labels: {
194
+ usePointStyle: !0
195
+ }
196
+ },
197
+ datalabels: { display: v.value, align: "end", anchor: "end" },
198
+ "maintain-aspect-ratio": !1
199
+ }, null, 8, ["datasets", "x-axis", "transpose", "datalabels"])
200
+ ], 64);
201
+ };
202
+ }
203
+ }), ta = /* @__PURE__ */ H({
204
+ __name: "WidgetCircular",
205
+ props: {
206
+ modelValue: { required: !0 },
207
+ modelModifiers: {}
208
+ },
209
+ emits: ["update:modelValue"],
210
+ setup(t) {
211
+ const e = O(t, "modelValue"), n = s(() => e.value.showLabel ?? void 0), p = s(() => {
212
+ let g = [];
213
+ return e.value.data.datasets && e.value.data.metrics && e.value.data.datasets.length > 0 && e.value.data.metrics.length > 0 && (g = [
214
+ {
215
+ label: e.value.data.metrics[0],
216
+ data: e.value.data.datasets.map((v) => v.value),
217
+ backgroundColor: e.value.data.datasets.map((v, u) => X({ index: u }))
218
+ }
219
+ ]), g;
220
+ });
221
+ return (g, v) => {
222
+ const u = w("FmPieChart");
223
+ return h(), L(W, null, [
224
+ G(g.$slots, "menu"),
225
+ S(u, {
226
+ class: "circular",
227
+ percentage: "70%",
228
+ datasets: p.value,
229
+ metrics: e.value.data.datasets.map((l) => l.name),
230
+ variant: "doughnut",
231
+ legend: {
232
+ display: !0,
233
+ position: "top",
234
+ maxHeight: 54,
235
+ labels: {
236
+ usePointStyle: !0
237
+ }
238
+ },
239
+ datalabels: { display: n.value, align: "end", anchor: "end" },
240
+ "maintain-aspect-ratio": !1
241
+ }, null, 8, ["datasets", "metrics", "datalabels"])
242
+ ], 64);
243
+ };
244
+ }
245
+ }), la = { class: "flex flex-col gap-1" }, na = { class: "fm-typo-en-title-sm-600" }, oa = { class: "flex gap-2" }, sa = { key: 0 }, ra = { key: 1 }, ia = /* @__PURE__ */ H({
246
+ __name: "WidgetScorecard",
247
+ props: {
248
+ modelValue: { required: !0 },
249
+ modelModifiers: {}
250
+ },
251
+ emits: ["update:modelValue"],
252
+ setup(t) {
253
+ const e = O(t, "modelValue"), { t: n } = ie(), { compareDateRange: p, defaultDateSetting: g } = se(xe()), { country: v } = ue(), u = s(() => {
254
+ var y;
255
+ return ((y = e.value.data) == null ? void 0 : y.value) || "";
256
+ }), l = s(() => {
257
+ const { data: y } = e.value;
258
+ return y != null && y.comparison ? ke(u.value, y.comparison, v) : null;
259
+ });
260
+ function o(y) {
261
+ switch (y) {
262
+ case re.bar:
263
+ return "bar";
264
+ case re.line:
265
+ return "line";
266
+ default:
267
+ return "line";
268
+ }
269
+ }
270
+ const m = s(() => {
271
+ var y;
272
+ return (y = e.value.data) == null ? void 0 : y.sparkline;
273
+ }), R = s(() => m.value.datasets.map((y) => ({
274
+ label: y.name,
275
+ data: y.values,
276
+ fill: !0,
277
+ color: "#36a2eb"
278
+ })));
279
+ return (y, T) => {
280
+ var c;
281
+ const J = w("FmIcon"), I = w("FmChip"), D = w("FmTooltip"), a = w("FmLineChart");
282
+ return h(), L("div", la, [
283
+ G(y.$slots, "menu"),
284
+ k("p", na, Z(u.value), 1),
285
+ k("div", oa, [
286
+ S(D, {
287
+ content: `vs. ${(c = j(g).defaultCompareType) == null ? void 0 : c.split("_").join(" ")}`,
288
+ placement: "right",
289
+ "hide-arrow": "",
290
+ variant: "plain"
291
+ }, {
292
+ default: B(() => [
293
+ l.value ? (h(), $(I, {
294
+ key: 0,
295
+ icon: l.value.icon.name,
296
+ class: le(`bg-${l.value.icon.tailwind}`),
297
+ compact: ""
298
+ }, {
299
+ default: B(() => [
300
+ S(J, {
301
+ name: l.value.icon.name,
302
+ color: l.value.icon.color
303
+ }, null, 8, ["name", "color"]),
304
+ k("p", {
305
+ class: "fm-typo-en-body-md-600",
306
+ style: _e({ color: l.value.icon.color })
307
+ }, Z(l.value.value), 5)
308
+ ]),
309
+ _: 1
310
+ }, 8, ["icon", "class"])) : K("", !0),
311
+ j(p).endDate !== null && j(p).startDate !== null && l.value === null ? (h(), $(I, {
312
+ key: 1,
313
+ compact: ""
314
+ }, {
315
+ default: B(() => [
316
+ S(J, {
317
+ name: "arrow_upward",
318
+ color: "#C7C7CC"
319
+ }),
320
+ T[0] || (T[0] = k("p", { class: "fm-typo-en-body-md-600 text-fm-color-typo-disabled" }, "N/A", -1))
321
+ ]),
322
+ _: 1
323
+ })) : K("", !0)
324
+ ]),
325
+ _: 1
326
+ }, 8, ["content"])
327
+ ]),
328
+ m.value ? (h(), L("div", sa, [
329
+ o(m.value.type) === "line" ? (h(), $(a, {
330
+ key: 0,
331
+ class: "sparkline",
332
+ datasets: R.value,
333
+ "hide-x-axis": !0,
334
+ "hide-y-axis": !0,
335
+ legend: {
336
+ display: !1
337
+ },
338
+ "x-axis": { categories: m.value.dimensions },
339
+ "maintain-aspect-ratio": !1
340
+ }, null, 8, ["datasets", "x-axis"])) : K("", !0)
341
+ ])) : (h(), L("div", ra, T[1] || (T[1] = [
342
+ k("div", { class: "sparkline" }, [
343
+ k("div", { class: "flex flex-col gap-8" }, [
344
+ k("div"),
345
+ k("div")
346
+ ]),
347
+ k("div", { class: "grow" })
348
+ ], -1)
349
+ ])))
350
+ ]);
351
+ };
352
+ }
353
+ }), ua = {};
354
+ function ca(t, e) {
355
+ const n = w("FmMenuDivider");
356
+ return h(), $(n);
357
+ }
358
+ const da = /* @__PURE__ */ Ke(ua, [["render", ca]]), ma = { class: "my-4" }, pa = {
359
+ class: "border-b border-fm-color-neutral-gray-100 hover:bg-fm-color-opacity-sm",
360
+ style: { backgroundColor: "#f9f9f9" }
361
+ }, va = { class: "font-bold" }, fa = { class: "text-fm-color-neutral-gray-300" }, ha = /* @__PURE__ */ H({
362
+ __name: "WidgetTable",
363
+ props: {
364
+ modelValue: { required: !0 },
365
+ modelModifiers: {}
366
+ },
367
+ emits: ["update:modelValue"],
368
+ setup(t) {
369
+ const { t: e } = ie(), n = O(t, "modelValue"), { country: p } = ue(), g = F(null), v = s(() => {
370
+ var a;
371
+ return ((a = n.value.data) == null ? void 0 : a.columns) || [{ label: "", key: "" }];
372
+ }), u = s(() => {
373
+ var a;
374
+ return ((a = n.value.data) == null ? void 0 : a.rows) || [];
375
+ }), l = s(() => n.value.filterText), o = s(() => {
376
+ var a, c;
377
+ if (!(l.value && l.value.trim().length > 0 || !((a = u.value[0]) != null && a.isRollup) && !((c = u.value[u.value.length - 1]) != null && c.isRollup))) {
378
+ if (n.value.rollupPosition === M.top || n.value.rollupPosition === void 0)
379
+ return M.top;
380
+ if (n.value.rollupPosition === M.bottom)
381
+ return M.bottom;
382
+ }
383
+ }), m = s(() => {
384
+ const d = o.value !== void 0 ? 1 : 0, x = (g.value ? g.value.$el.offsetHeight : 0) - 48;
385
+ return Math.floor((x - 34.5 - 32) / 48) - d;
386
+ }), R = s(() => {
387
+ var c, b;
388
+ let a = [];
389
+ switch (o.value) {
390
+ case M.top:
391
+ a = [...((c = u.value[0]) == null ? void 0 : c.cells) || []].map((d, x) => {
392
+ var _;
393
+ return {
394
+ main: d,
395
+ comparison: (_ = u.value[0]) == null ? void 0 : _.comparisonCells[x],
396
+ rowType: v.value[x].type
397
+ };
398
+ });
399
+ break;
400
+ case M.bottom:
401
+ a = [...((b = u.value[u.value.length - 1]) == null ? void 0 : b.cells) || []].map((d, x) => {
402
+ var _;
403
+ return {
404
+ main: d,
405
+ comparison: (_ = u.value[0]) == null ? void 0 : _.comparisonCells[x],
406
+ rowType: v.value[x].type
407
+ };
408
+ });
409
+ break;
410
+ }
411
+ return a.length > 0 && a[0].main === "" && (a[0].main = "Grand total"), a;
412
+ });
413
+ function y(a) {
414
+ const c = {};
415
+ for (let b = 0; b < v.value.length; b++)
416
+ if (v.value[b].key !== "") {
417
+ const d = a.comparisonCells[b];
418
+ c[v.value[b].key] = {
419
+ main: a.cells[b],
420
+ comparison: d
421
+ }, c.isRollup = a.isRollup;
422
+ }
423
+ return c;
424
+ }
425
+ function T(a) {
426
+ return [...new Array(a < 0 ? 0 : a)].map(() => {
427
+ var b;
428
+ const c = {};
429
+ if ((b = n.value.data) != null && b.columns)
430
+ for (let d = 0; d < n.value.data.columns.length; d++)
431
+ c[n.value.data.columns[d].key] = void 0;
432
+ return c;
433
+ });
434
+ }
435
+ function J(a) {
436
+ let c = (a == null ? void 0 : a.main) || "";
437
+ return c.includes("#") && !c.startsWith("#") && (c = c.split("#")[0]), !a || a.main === "" || a.comparison === "" ? {
438
+ main: c
439
+ } : {
440
+ main: c,
441
+ comparison: a == null ? void 0 : a.comparison,
442
+ difference: ke(a.main, a.comparison, p)
443
+ };
444
+ }
445
+ const I = s(() => {
446
+ var x, _, N;
447
+ let a = ((x = n.value.data) == null ? void 0 : x.rows) || [];
448
+ switch (o.value) {
449
+ case M.bottom:
450
+ a = (_ = a[a.length - 1]) != null && _.isRollup ? a.slice(0, -1) : a;
451
+ break;
452
+ case M.top:
453
+ a = (N = a[0]) != null && N.isRollup ? a.slice(1, a.length) : a;
454
+ break;
455
+ }
456
+ const c = a.filter((P) => !(l.value !== "" && (P.isRollup === !0 || !P.cells.some(
457
+ (E) => {
458
+ var q;
459
+ return ((E == null ? void 0 : E.toLowerCase()) || "").includes((q = l.value) == null ? void 0 : q.toLowerCase());
460
+ }
461
+ )))).map((P) => y(P)), b = c.length % m.value;
462
+ let d = 0;
463
+ return b > 0 ? d = Math.abs(b - m.value) : c.length === 0 && (d = m.value), c.push(...T(d)), c;
464
+ }), D = s(() => {
465
+ var c;
466
+ let a = [];
467
+ return (c = n.value.data) != null && c.columns && (a = [...n.value.data.columns.map((d) => {
468
+ const x = d.label;
469
+ return {
470
+ accessorKey: d.key,
471
+ header: () => ge(
472
+ "p",
473
+ {
474
+ class: `min-w-[110px] w-full text-nowrap ${d.type === "NUMERIC" ? "text-right" : ""}`
475
+ },
476
+ x
477
+ ),
478
+ cell: (_) => {
479
+ var E, q;
480
+ const N = J(_.getValue()), P = (q = (E = _ == null ? void 0 : _.row) == null ? void 0 : E.original) == null ? void 0 : q.isRollup;
481
+ return ge(
482
+ "div",
483
+ {
484
+ class: `${P ? "fm-typo-en-body-md-600 text-fm-color-typo-secondary" : "fm-typo-en-body-md-400"} ${d.type === "NUMERIC" ? "text-right" : ""} text-nowrap whitespace-pre`
485
+ },
486
+ [N.main]
487
+ );
488
+ },
489
+ meta: () => ({
490
+ cellClass: "subtotal-row"
491
+ }),
492
+ enableSorting: !1
493
+ };
494
+ })]), a;
495
+ });
496
+ return (a, c) => {
497
+ const b = w("FmTable");
498
+ return h(), L(W, null, [
499
+ k("div", ma, [
500
+ G(a.$slots, "menu")
501
+ ]),
502
+ S(b, {
503
+ ref_key: "table",
504
+ ref: g,
505
+ "column-defs": D.value,
506
+ "row-data": I.value,
507
+ "search-value": l.value,
508
+ "page-size": m.value,
509
+ "shrink-at": !1,
510
+ "force-mobile-footer": !0,
511
+ class: "scrollbar-hide-table"
512
+ }, {
513
+ "pin-top": B(() => [
514
+ k("tbody", null, [
515
+ k("tr", pa, [
516
+ (h(!0), L(W, null, Ce(R.value, (d, x) => (h(), L("td", {
517
+ key: `${j(te)()}_${x}`,
518
+ class: "h-[48px] text-fm-color-typo-primary px-16"
519
+ }, [
520
+ k("span", {
521
+ class: le(`items-center text-fm-color-typo-secondary gap-2 line-clamp-2 text-ellipsis ${d.rowType === "NUMERIC" ? "text-right" : ""}`)
522
+ }, [
523
+ k("p", va, Z(d.main), 1),
524
+ k("p", fa, Z(d.comparison ? `(${d.comparison})` : ""), 1)
525
+ ], 2)
526
+ ]))), 128))
527
+ ])
528
+ ])
529
+ ]),
530
+ _: 1
531
+ }, 8, ["column-defs", "row-data", "search-value", "page-size"])
532
+ ], 64);
533
+ };
534
+ }
535
+ }), ga = /* @__PURE__ */ H({
536
+ __name: "WidgetStackBarChart",
537
+ props: {
538
+ modelValue: { required: !0 },
539
+ modelModifiers: {}
540
+ },
541
+ emits: ["update:modelValue"],
542
+ setup(t) {
543
+ const e = O(t, "modelValue"), n = s(() => {
544
+ var m;
545
+ return ((m = e.value.data) == null ? void 0 : m.xAxis) || [];
546
+ }), p = s(() => {
547
+ var o;
548
+ return ((o = e.value.data) == null ? void 0 : o.datasets) ?? [];
549
+ }), g = s(() => e.value.isTransposed ?? void 0), v = s(() => e.value.showLabel ?? void 0), u = F(null), l = s(() => p.value.length > 0 ? [
550
+ ...p.value.map((o, m) => {
551
+ let R = o.values;
552
+ return {
553
+ label: o.name,
554
+ data: R,
555
+ dash: !!o.isCompare,
556
+ backgroundColor: X({ index: m, isCompare: o.isCompare })
557
+ };
558
+ })
559
+ ] : []);
560
+ return (o, m) => {
561
+ const R = w("FmBarChart");
562
+ return h(), L(W, null, [
563
+ G(o.$slots, "menu"),
564
+ S(R, {
565
+ ref_key: "chartRef",
566
+ ref: u,
567
+ class: "bar-chart",
568
+ datasets: l.value,
569
+ "x-axis": { categories: n.value },
570
+ transpose: g.value,
571
+ stacked: !0,
572
+ legend: {
573
+ display: !1,
574
+ position: "bottom",
575
+ maxHeight: 54,
576
+ labels: {
577
+ usePointStyle: !0
578
+ }
579
+ },
580
+ datalabels: { display: v.value, align: "end", anchor: "end", rotation: 0 },
581
+ "maintain-aspect-ratio": !1
582
+ }, null, 8, ["datasets", "x-axis", "transpose", "datalabels"])
583
+ ], 64);
584
+ };
585
+ }
586
+ }), ba = /* @__PURE__ */ H({
587
+ __name: "WidgetStackLineChart",
588
+ props: {
589
+ modelValue: { required: !0 },
590
+ modelModifiers: {}
591
+ },
592
+ emits: ["update:modelValue"],
593
+ setup(t) {
594
+ const e = O(t, "modelValue"), n = s(() => {
595
+ var l;
596
+ return ((l = e.value.data) == null ? void 0 : l.xAxis) ?? [];
597
+ }), p = s(() => {
598
+ var l;
599
+ return ((l = e.value.data) == null ? void 0 : l.datasets) ?? [];
600
+ }), g = s(() => e.value.isTransposed ?? void 0), v = s(() => e.value.showLabel ?? void 0), u = s(() => p.value.length > 0 ? [
601
+ ...p.value.map((l, o) => {
602
+ let m = l.values;
603
+ return {
604
+ label: l.name,
605
+ data: m,
606
+ dash: l.isCompare,
607
+ fill: !1,
608
+ color: X({ index: o, isCompare: l.isCompare })
609
+ };
610
+ })
611
+ ] : []);
612
+ return (l, o) => {
613
+ const m = w("FmLineChart");
614
+ return h(), L(W, null, [
615
+ G(l.$slots, "menu"),
616
+ S(m, {
617
+ class: "line-chart",
618
+ datasets: u.value,
619
+ "x-axis": { categories: n.value },
620
+ transpose: g.value,
621
+ legend: {
622
+ display: !1,
623
+ position: "bottom",
624
+ maxHeight: 54,
625
+ labels: {
626
+ usePointStyle: !0
627
+ }
628
+ },
629
+ stacked: !0,
630
+ datalabels: { display: v.value, align: "end", anchor: "end", rotation: 0 },
631
+ "maintain-aspect-ratio": !1
632
+ }, null, 8, ["datasets", "x-axis", "transpose", "datalabels"])
633
+ ], 64);
634
+ };
635
+ }
636
+ }), Q = [
637
+ "col-span-1",
638
+ "col-span-2",
639
+ "col-span-3",
640
+ "col-span-4",
641
+ "col-span-5",
642
+ "col-span-6",
643
+ "col-span-7",
644
+ "col-span-8",
645
+ "col-span-9",
646
+ "col-span-10",
647
+ "col-span-11",
648
+ "col-span-12"
649
+ ];
650
+ function ya(t) {
651
+ return t < 12 ? Q[t - 1] : Q[11];
652
+ }
653
+ function wa(t) {
654
+ return t < 12 ? Q[Math.min(11, t * 2 - 1)] : Q[11];
655
+ }
656
+ function _a(t) {
657
+ return t < 12 ? Q[Math.min(11, t * 3 - 1)] : Q[11];
658
+ }
659
+ const Ca = /* @__PURE__ */ H({
660
+ __name: "WidgetLinechart",
661
+ props: {
662
+ modelValue: { required: !0 },
663
+ modelModifiers: {}
664
+ },
665
+ emits: ["update:modelValue"],
666
+ setup(t) {
667
+ const e = O(t, "modelValue"), n = s(() => {
668
+ var l;
669
+ return ((l = e.value.data) == null ? void 0 : l.xAxis) ?? [];
670
+ }), p = s(() => {
671
+ var l;
672
+ return ((l = e.value.data) == null ? void 0 : l.datasets) ?? [];
673
+ }), g = s(() => e.value.isTransposed ?? void 0), v = s(() => e.value.showLabel ?? void 0), u = s(() => p.value.length > 0 ? [
674
+ ...p.value.map((l, o) => ({
675
+ label: l.name,
676
+ data: l.values,
677
+ dash: !!l.isCompare,
678
+ fill: !1,
679
+ color: X({ index: o, isCompare: l.isCompare })
680
+ }))
681
+ ] : []);
682
+ return (l, o) => {
683
+ const m = w("FmLineChart");
684
+ return h(), L(W, null, [
685
+ G(l.$slots, "menu"),
686
+ S(m, {
687
+ class: "line-chart",
688
+ datasets: u.value,
689
+ "x-axis": { categories: n.value },
690
+ transpose: g.value,
691
+ legend: {
692
+ display: !1,
693
+ position: "bottom",
694
+ maxHeight: 54,
695
+ labels: {
696
+ usePointStyle: !0
697
+ }
698
+ },
699
+ datalabels: { display: v.value, align: "end", anchor: "end", rotation: 0 },
700
+ "maintain-aspect-ratio": !1
701
+ }, null, 8, ["datasets", "x-axis", "transpose", "datalabels"])
702
+ ], 64);
703
+ };
704
+ }
705
+ }), xa = {
706
+ key: 1,
707
+ class: "grow"
708
+ }, ka = {
709
+ key: 2,
710
+ class: "flex"
711
+ }, Ba = /* @__PURE__ */ H({
712
+ __name: "DynamicWidget",
713
+ props: /* @__PURE__ */ Ee({
714
+ index: {
715
+ type: Number,
716
+ default: 0
717
+ },
718
+ hideExport: {
719
+ type: Boolean,
720
+ default: !1
721
+ }
722
+ }, {
723
+ modelValue: { required: !0, default: () => {
724
+ } },
725
+ modelModifiers: {}
726
+ }),
727
+ emits: ["update:modelValue"],
728
+ setup(t) {
729
+ const e = F(!0), n = O(t, "modelValue"), { t: p } = ie(), g = t, v = F(null), u = F(n.value.widget.config.rollup), l = F(te()), o = F(n.value.widget.config.drillDimension), m = s(() => {
730
+ if (U.value.length > 0) {
731
+ const r = U.value.findIndex(
732
+ (f) => f.value === o.value
733
+ );
734
+ return r >= 0 ? r : 0;
735
+ } else
736
+ return -1;
737
+ }), R = s(() => m.value !== 0), y = s(
738
+ () => m.value != U.value.length - 1
739
+ ), T = F(n.value.widget.config.showLabel ?? !1), J = s(() => n.value.widget.config.showSearchBar), I = F(""), { breakpoints: D } = Qe(), a = F(), c = s(() => D.value.lg || D.value.md ? ya(n.value.size.width) : D.value.sm ? wa(n.value.size.width) : _a(n.value.size.width)), b = s(
740
+ () => Xe.find((r) => r.type === n.value.widget.type)
741
+ ), d = be(() => {
742
+ var r;
743
+ a.value = Le((r = v.value) == null ? void 0 : r.$el.offsetWidth), l.value = te();
744
+ }), x = s(() => {
745
+ if (Ye(C.value.type, _.value))
746
+ switch (n.value.widget.type) {
747
+ case i.BarChart:
748
+ return aa;
749
+ case i.StackBarChart:
750
+ return ga;
751
+ case i.LineChart:
752
+ return Ca;
753
+ case i.StackLineChart:
754
+ return ba;
755
+ case i.Circular:
756
+ return ta;
757
+ case i.Scorecard:
758
+ return ia;
759
+ case i.Spacer:
760
+ return da;
761
+ case i.Table:
762
+ return ha;
763
+ default:
764
+ return ye;
765
+ }
766
+ else
767
+ return ye;
768
+ }), _ = F(null), { selectedLocationIds: N, dateRange: P, compareDateRange: E, timeRange: q } = se(xe()), { businessId: Se } = se(ue()), C = s(() => {
769
+ const r = JSON.parse(JSON.stringify(n.value.widget));
770
+ return {
771
+ ...r,
772
+ config: {
773
+ ...r.config,
774
+ rollup: u.value,
775
+ drillDimension: o.value,
776
+ showGrandTotal: !1
777
+ }
778
+ };
779
+ }), ce = s(() => {
780
+ let r, f, V, z;
781
+ switch (C.value.type) {
782
+ case i.Table:
783
+ V = I.value, z = C.value.config.rollupPosition;
784
+ break;
785
+ case i.BarChart:
786
+ case i.LineChart:
787
+ case i.StackBarChart:
788
+ case i.StackLineChart:
789
+ case i.Circular:
790
+ r = T.value, f = C.value.config.isTransposed;
791
+ break;
792
+ }
793
+ return {
794
+ data: _.value,
795
+ showLabel: r,
796
+ isTransposed: f,
797
+ rollupPosition: z,
798
+ filterText: V
799
+ };
800
+ }), de = s(() => {
801
+ const { config: r } = n.value.widget;
802
+ if (r.rollup != null) {
803
+ const f = [...r.dimensions].filter((V) => !V.hide);
804
+ return f.sort(
805
+ (V, z) => (r.rowIds || []).indexOf(oe(V)) - (r.rowIds || []).indexOf(oe(z))
806
+ ), [
807
+ { label: "None", value: null },
808
+ { label: "Grand Total", value: 0 },
809
+ ...[...f].slice(0, f.length - 1).map((V, z) => ({ label: V.label, value: z + 1 }))
810
+ ];
811
+ }
812
+ return [];
813
+ }), U = s(() => {
814
+ const { config: r } = C.value;
815
+ return r.isDrillable ? r.dimensions.map((f) => ({
816
+ label: f.label,
817
+ value: oe(f)
818
+ })) : [];
819
+ });
820
+ ae(n.value, (r) => {
821
+ u.value = r.widget.config.rollup, T.value = r.widget.config.showLabel ?? !1;
822
+ }), ae([() => u.value], () => {
823
+ u.value !== null && (n.value.widget.config.rollup = u.value);
824
+ }), ae(
825
+ [
826
+ () => C.value,
827
+ () => P.value,
828
+ () => q.value,
829
+ () => E.value,
830
+ () => N.value,
831
+ () => Se.value
832
+ ],
833
+ () => {
834
+ var r;
835
+ N.value && ((r = N.value) == null ? void 0 : r.length) > 0 && pe();
836
+ },
837
+ {
838
+ deep: !0
839
+ }
840
+ ), ae(
841
+ [() => n.value.size],
842
+ () => {
843
+ d();
844
+ },
845
+ { deep: !0 }
846
+ ), ze(() => {
847
+ d(), D.value.sm || D.value.md || D.value.xs ? (console.log("Ignoring resize event due to keyboard"), addEventListener("change", d)) : addEventListener("resize", d), pe();
848
+ }), We(() => {
849
+ D.value.sm || D.value.md || D.value.xs ? (console.log("Ignoring resize event due to keyboard"), removeEventListener("change", d)) : removeEventListener("resize", d);
850
+ });
851
+ const me = Ze();
852
+ let Y;
853
+ const pe = be(async function() {
854
+ if (C.value.config.schemaNames.length <= 0 && !(C.value.config.dimensions.length <= 0 || C.value.config.metrics.length <= 0)) {
855
+ me.open({
856
+ message: "schema must not be empty and dimension or metrics must have at least 1 column",
857
+ type: "info"
858
+ }), e.value = !1;
859
+ return;
860
+ }
861
+ try {
862
+ e.value = !0, Y && Y.abort(), Y = new AbortController();
863
+ const f = Y.signal;
864
+ _.value = await Je(C.value, f), l.value = te(), e.value = !1;
865
+ } catch (f) {
866
+ _.value = null, f.code !== "ERR_CANCELED" && (me.open({ message: `Invalid chart ${C.value.type}`, type: "error" }), console.log(f), e.value = !1);
867
+ }
868
+ });
869
+ function Le(r) {
870
+ switch (n.value.widget.type) {
871
+ case "SPACER":
872
+ return;
873
+ case "SCORECARD":
874
+ return;
875
+ case "TABLE":
876
+ return `${n.value.size.height * 100 + (J.value ? 72 : 0) + 96.5}px`;
877
+ }
878
+ return `${Math.max(r / n.value.size.width, 90) * n.value.size.height}px`;
879
+ }
880
+ function De() {
881
+ const r = m.value - 1;
882
+ r >= 0 && (o.value = U.value[r].value);
883
+ }
884
+ function Fe() {
885
+ const r = m.value + 1;
886
+ r >= 0 && r < U.value.length && (o.value = U.value[r].value);
887
+ }
888
+ const Re = Object.values(Ue).map((r) => ({
889
+ label: je(r),
890
+ value: r,
891
+ onClick: async () => {
892
+ await Ge(r, g.index);
893
+ }
894
+ })), Te = C.value.type === i.Spacer ? "flat" : "outlined", $e = C.value.type === i.Spacer ? "p-0" : "p-16";
895
+ return (r, f) => {
896
+ const V = w("FmTooltip"), z = w("FmSearch"), Ve = w("FmCheckbox"), ne = w("FmButton"), Be = w("FmSelect"), Ae = w("FmMenuItem"), Me = w("FmMenu"), Ie = w("FmForm"), Ne = w("FmCircularProgress"), Pe = w("FmCard");
897
+ return h(), $(Pe, {
898
+ ref_key: "tileCard",
899
+ ref: v,
900
+ class: le(`${c.value} ${j($e)}`),
901
+ variant: j(Te)
902
+ }, {
903
+ default: B(() => [
904
+ e.value ? (h(), $(Ne, { key: 1 })) : (h(), L("div", {
905
+ key: 0,
906
+ style: _e({ height: a.value })
907
+ }, [
908
+ (h(), $(He(x.value), {
909
+ key: l.value,
910
+ modelValue: ce.value,
911
+ "onUpdate:modelValue": f[3] || (f[3] = (ee) => ce.value = ee)
912
+ }, {
913
+ menu: B(() => [
914
+ S(Ie, { class: "flex items-center gap-2" }, {
915
+ default: B(() => {
916
+ var ee, ve, fe, he;
917
+ return [
918
+ S(V, {
919
+ variant: "plain",
920
+ placement: "right",
921
+ content: C.value.description,
922
+ "hide-arrow": !0,
923
+ disabled: !C.value.description
924
+ }, {
925
+ default: B(() => [
926
+ k("p", {
927
+ class: le(["fm-typo-en-body-md-400 line-clamp-1 text-fm-color-typo-secondary", `${C.value.description ? "border-b-2 border-dashed border-gray-300" : ""}`])
928
+ }, Z(C.value.title || " "), 3)
929
+ ]),
930
+ _: 1
931
+ }, 8, ["content", "disabled"]),
932
+ (ee = b.value) != null && ee.showSearchBar ? (h(), $(z, {
933
+ key: 0,
934
+ modelValue: I.value,
935
+ "onUpdate:modelValue": f[0] || (f[0] = (A) => I.value = A),
936
+ class: "grow"
937
+ }, null, 8, ["modelValue"])) : (h(), L("div", xa)),
938
+ Oe(S(Ve, {
939
+ modelValue: T.value,
940
+ "onUpdate:modelValue": f[1] || (f[1] = (A) => T.value = A),
941
+ label: "Label",
942
+ value: !1
943
+ }, null, 8, ["modelValue"]), [
944
+ [qe, (ve = b.value) == null ? void 0 : ve.showLabel]
945
+ ]),
946
+ (fe = b.value) != null && fe.showDrillDimension && U.value.length > 0 ? (h(), L("div", ka, [
947
+ S(ne, {
948
+ icon: "arrow_upward",
949
+ variant: "tertiary",
950
+ disabled: !R.value,
951
+ onClick: De
952
+ }, null, 8, ["disabled"]),
953
+ S(ne, {
954
+ icon: "arrow_downward",
955
+ variant: "tertiary",
956
+ disabled: !y.value,
957
+ onClick: Fe
958
+ }, null, 8, ["disabled"])
959
+ ])) : K("", !0),
960
+ (he = b.value) != null && he.showRollup && de.value.length > 0 ? (h(), $(Be, {
961
+ key: 3,
962
+ modelValue: u.value,
963
+ "onUpdate:modelValue": f[2] || (f[2] = (A) => u.value = A),
964
+ class: "w-[150px]",
965
+ items: de.value
966
+ }, null, 8, ["modelValue", "items"])) : K("", !0),
967
+ g.hideExport ? K("", !0) : (h(), $(Me, {
968
+ key: 4,
969
+ shift: !0
970
+ }, {
971
+ "menu-button": B(() => [
972
+ S(ne, {
973
+ icon: "more_vert",
974
+ variant: "tertiary"
975
+ })
976
+ ]),
977
+ default: B(() => [
978
+ (h(!0), L(W, null, Ce(j(Re), (A) => (h(), $(Ae, {
979
+ key: A.value,
980
+ label: A.label,
981
+ onClick: A.onClick
982
+ }, null, 8, ["label", "onClick"]))), 128))
983
+ ]),
984
+ _: 1
985
+ }))
986
+ ];
987
+ }),
988
+ _: 1
989
+ })
990
+ ]),
991
+ _: 1
992
+ }, 8, ["modelValue"]))
993
+ ], 4))
994
+ ]),
995
+ _: 1
996
+ }, 8, ["class", "variant"]);
997
+ };
998
+ }
999
+ });
1000
+ export {
1001
+ M as R,
1002
+ Ba as _,
1003
+ oe as g
1004
+ };