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