@feedmepos/mf-report 5.27.54 → 5.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/{App-C6xpf-Q0.js → App-BDhSFQX_.js} +45 -44
  2. package/dist/DateRangeSelect-CRsKMi0U.js +437 -0
  3. package/dist/{Default.vue_vue_type_script_setup_true_lang-BwPZXC_d.js → Default.vue_vue_type_script_setup_true_lang-WGOOX2b8.js} +12 -11
  4. package/dist/{DynamicWidget.vue_vue_type_script_setup_true_lang-BpgXiPBY.js → DynamicWidget.vue_vue_type_script_setup_true_lang-CQM-l5Rk.js} +182 -181
  5. package/dist/{GlobalFilterSelect.vue_vue_type_script_setup_true_lang-CVShUWJC.js → GlobalFilterSelect.vue_vue_type_script_setup_true_lang-CMioHpn1.js} +5091 -5717
  6. package/dist/{InsightView-BYW66Wrv.js → InsightView-lnOobZAr.js} +17 -15
  7. package/dist/{Integration-DQPJBE-0.js → Integration-D5ssimUg.js} +27 -25
  8. package/dist/{Integrations-BW4H9lUS.js → Integrations-CaqGvkzI.js} +8 -7
  9. package/dist/{Layout-CMlh08aB.js → Layout-DS0XCT_E.js} +1 -1
  10. package/dist/LocationSelect.vue_vue_type_script_setup_true_lang-DC9QYJk-.js +8055 -0
  11. package/dist/{MenuTab.vue_vue_type_script_setup_true_lang-BUvD1_b0.js → MenuTab.vue_vue_type_script_setup_true_lang-nOukNXp3.js} +11 -10
  12. package/dist/{NavigationTab.vue_vue_type_script_setup_true_lang-TpeQ_Wm1.js → NavigationTab.vue_vue_type_script_setup_true_lang-DXNbt08D.js} +9636 -17677
  13. package/dist/{OverviewView-BtGpQkBY.js → OverviewView-BkIozvMs.js} +5 -5
  14. package/dist/{Report-CJ9myNLK.js → Report-HiSGRNhn.js} +27 -25
  15. package/dist/ReportCanvasView-ILVhB1KL.js +448 -0
  16. package/dist/{ReportEditor-DtnTBbY1.js → ReportEditor-B4tyVB8s.js} +30 -28
  17. package/dist/{ReportView-Ci8nFyI9.js → ReportView-CIQQHvWT.js} +14 -13
  18. package/dist/ReportViewRoute-B3KwVB0v.js +18 -0
  19. package/dist/{SelectComponent.vue_vue_type_script_setup_true_lang-Ckn2p74A.js → SelectComponent.vue_vue_type_script_setup_true_lang-DW7Dk7iQ.js} +1 -1
  20. package/dist/{Setting-QSiMSAQk.js → Setting-CvToMUKq.js} +5 -5
  21. package/dist/{Template-CAPlAQO9.js → Template-BBQEaHrM.js} +10 -9
  22. package/dist/{TileEditor-e7ZCWMU9.js → TileEditor-Cqy98LmJ.js} +19 -17
  23. package/dist/{TilePageStack.vue_vue_type_script_setup_true_lang-B4g3YPzM.js → TilePageStack.vue_vue_type_script_setup_true_lang-CzggUdfI.js} +3 -3
  24. package/dist/{TransitionFade-DqIazHHG.js → TransitionFade-D-8BYs6T.js} +36 -33
  25. package/dist/{_plugin-vue_export-helper-kkiiQoKl.js → _plugin-vue_export-helper-C6QDExPN.js} +276 -291
  26. package/dist/{app-BAgs-zHf.js → app-Bjt_JuJi.js} +670 -567
  27. package/dist/app.js +1 -1
  28. package/dist/assets/{formatChartData.worker-epD1fsTW.js → formatChartData.worker-BeBGCyYW.js} +1 -1
  29. package/dist/assets/{processTableData.worker-BJZ_Z45H.js → processTableData.worker-frTYV0ok.js} +39 -39
  30. package/dist/global-loader-BuxFfehu.js +19 -0
  31. package/dist/index-CtZE4sab.js +82 -0
  32. package/dist/report-DjGDWvm3.js +635 -0
  33. package/dist/report-canvas-frame.html +888 -0
  34. package/dist/report-canvas-libs/chart.js-4.js +14 -0
  35. package/dist/report-canvas-libs/fm-ui-1.js +904 -0
  36. package/dist/style.css +1 -1
  37. package/dist/{useRestaurantPermission-ChYMJfXG.js → useRestaurantPermission-Dkbh_cv8.js} +4 -4
  38. package/package.json +1 -1
  39. package/dist/DateRangeSelect-DYVOvSCA.js +0 -517
@@ -1,11 +1,11 @@
1
1
  import { defineComponent as g, computed as s, resolveComponent as w, createBlock as l, openBlock as i, withCtx as y, createVNode as p, createElementVNode as c, unref as e, normalizeStyle as k, normalizeClass as b } from "vue";
2
- import { _ as h } from "./TilePageStack.vue_vue_type_script_setup_true_lang-B4g3YPzM.js";
3
- import { u as I, l as $ } from "./GlobalFilterSelect.vue_vue_type_script_setup_true_lang-CVShUWJC.js";
4
- import { _ as C } from "./Default.vue_vue_type_script_setup_true_lang-BwPZXC_d.js";
2
+ import { _ as h } from "./TilePageStack.vue_vue_type_script_setup_true_lang-CzggUdfI.js";
3
+ import { u as I, l as $ } from "./report-DjGDWvm3.js";
4
+ import { _ as C } from "./Default.vue_vue_type_script_setup_true_lang-WGOOX2b8.js";
5
5
  import { storeToRefs as B } from "pinia";
6
- import { _ as z } from "./SelectComponent.vue_vue_type_script_setup_true_lang-Ckn2p74A.js";
6
+ import { _ as z } from "./SelectComponent.vue_vue_type_script_setup_true_lang-DW7Dk7iQ.js";
7
7
  import { useBreakpoints as P } from "@feedmepos/ui-library";
8
- import { _ as R } from "./MenuTab.vue_vue_type_script_setup_true_lang-BUvD1_b0.js";
8
+ import { _ as R } from "./MenuTab.vue_vue_type_script_setup_true_lang-nOukNXp3.js";
9
9
  import { useI18n as S } from "@feedmepos/mf-common";
10
10
  import { r as V } from "./i18n-DbyciK4x.js";
11
11
  const D = { class: "sticky top-0 z-10 bg-white" }, K = /* @__PURE__ */ g({
@@ -1,28 +1,28 @@
1
- import { defineComponent as Ie, ref as Q, watch as de, computed as h, h as d, withModifiers as Fe, resolveComponent as x, createBlock as W, openBlock as J, withCtx as m, createVNode as i, createElementVNode as g, unref as e, normalizeStyle as Oe, normalizeClass as y, withDirectives as fe, createElementBlock as Pe, Fragment as Le, renderList as Ne, toDisplayString as _, createTextVNode as Ve, vShow as ye } from "vue";
1
+ import { defineComponent as Ie, ref as Q, watch as de, computed as h, h as d, withModifiers as Fe, resolveComponent as x, createBlock as W, openBlock as T, withCtx as m, createVNode as i, createElementVNode as g, unref as e, normalizeStyle as Oe, normalizeClass as y, withDirectives as fe, createElementBlock as Pe, Fragment as Le, renderList as Ne, toDisplayString as _, createTextVNode as Ve, vShow as ye } from "vue";
2
2
  import { storeToRefs as ve } from "pinia";
3
- import { u as Ae } from "./GlobalFilterSelect.vue_vue_type_script_setup_true_lang-CVShUWJC.js";
4
- import { _ as Je } from "./Default.vue_vue_type_script_setup_true_lang-BwPZXC_d.js";
5
- import { u as ze } from "./message-dialog-UoMWOnil.js";
6
- import { a as Be } from "./_plugin-vue_export-helper-kkiiQoKl.js";
7
- import { useSnackbar as Te, useBreakpoints as Ue, components as Ee, FmButtonColorThemeVariant as Ke } from "@feedmepos/ui-library";
8
- import { _ as Me } from "./SelectComponent.vue_vue_type_script_setup_true_lang-Ckn2p74A.js";
9
- import { c as Ye, a as ge, h as qe } from "./app-BAgs-zHf.js";
3
+ import { u as Ae } from "./report-DjGDWvm3.js";
4
+ import { _ as Te } from "./Default.vue_vue_type_script_setup_true_lang-WGOOX2b8.js";
5
+ import { u as Je } from "./message-dialog-UoMWOnil.js";
6
+ import { u as ze } from "./global-loader-BuxFfehu.js";
7
+ import { useSnackbar as Be, useBreakpoints as Ue, components as Ee, FmButtonColorThemeVariant as Ke } from "@feedmepos/ui-library";
8
+ import { _ as Me } from "./SelectComponent.vue_vue_type_script_setup_true_lang-DW7Dk7iQ.js";
9
+ import { c as Ye, a as ge, h as qe } from "./app-Bjt_JuJi.js";
10
10
  import { useRouter as je, useRoute as Ge, onBeforeRouteLeave as He } from "vue-router";
11
11
  import { useI18n as Qe } from "@feedmepos/mf-common";
12
12
  import { r as X } from "./i18n-DbyciK4x.js";
13
13
  const We = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Xe = { class: "w-[343px]" }, Ze = { class: "fm-typo-en-body-md-600" }, dt = /* @__PURE__ */ Ie({
14
14
  __name: "Report",
15
15
  setup(et) {
16
- const { t: a, te: z } = Qe(), Z = je(), ee = Ge(), f = Ae(), be = Ye(), { business: we } = ve(ge()), {
16
+ const { t: a, te: J } = Qe(), Z = je(), ee = Ge(), f = Ae(), be = Ye(), { business: we } = ve(ge()), {
17
17
  reports: p,
18
- overviewReport: B,
18
+ overviewReport: z,
19
19
  categories: $,
20
20
  pinReport: I,
21
21
  isOpenAddReportDialog: Re,
22
22
  scrollPositionY: te,
23
23
  customReportQuota: F,
24
24
  canCreateCustomReport: oe
25
- } = ve(f), { promptMessage: ae } = ze(), { promptLoader: T } = Be(), c = Te(), { breakpoints: u } = Ue(), { canRead: re, canUpdate: ne, canDuplicate: se, canDelete: U, canCreateReport: he } = qe(), b = Q();
25
+ } = ve(f), { promptMessage: ae } = Je(), { promptLoader: B } = ze(), c = Be(), { breakpoints: u } = Ue(), { canRead: re, canUpdate: ne, canDuplicate: se, canDelete: U, canCreateReport: he } = qe(), b = Q();
26
26
  He(() => {
27
27
  b.value && (te.value = b.value.$el.children[0].scrollTop);
28
28
  }), de(b, () => {
@@ -53,7 +53,7 @@ const We = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Xe
53
53
  ...E.value.map((t) => {
54
54
  const r = $.value.find((l) => l.id === t.category);
55
55
  return {
56
- name: X(a, z, t.name, "other"),
56
+ name: X(a, J, t.name, "other"),
57
57
  categoryId: (r == null ? void 0 : r.id) ?? "",
58
58
  category: r != null && r.name ? a(`report.category.${r.name}`) : a("report.common.uncategorized"),
59
59
  reportId: t.id,
@@ -61,13 +61,14 @@ const We = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Xe
61
61
  description: t.description || "",
62
62
  pin: !0,
63
63
  canUpdate: ne(t),
64
- canRead: re(t)
64
+ canRead: re(t),
65
+ reportType: t.reportType
65
66
  };
66
67
  }),
67
68
  ...le.value.map((t) => {
68
69
  const r = $.value.find((l) => l.id === t.category);
69
70
  return {
70
- name: X(a, z, t.name, "other"),
71
+ name: X(a, J, t.name, "other"),
71
72
  categoryId: (r == null ? void 0 : r.id) ?? "",
72
73
  category: r != null && r.name ? a(`report.category.${r.name}`) : a("report.common.uncategorized"),
73
74
  reportId: t.id,
@@ -75,7 +76,8 @@ const We = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Xe
75
76
  description: t.description || "",
76
77
  pin: !1,
77
78
  canUpdate: ne(t),
78
- canRead: re(t)
79
+ canRead: re(t),
80
+ reportType: t.reportType
79
81
  };
80
82
  })
81
83
  ].filter((t) => O.value.value && t.categoryId !== O.value.value ? !1 : `${(t == null ? void 0 : t.name) || ""}${(t == null ? void 0 : t.description) || ""}`.toLowerCase().indexOf(q.value.toLowerCase()) !== -1)), Se = h(
@@ -133,7 +135,7 @@ const We = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Xe
133
135
  },
134
136
  cell: (o) => {
135
137
  var w;
136
- const t = o.row.original, r = t.reportId, l = p.value.find((s) => s.id === r), H = r === ((w = B.value) == null ? void 0 : w.id), V = !t.canRead, D = l ? se(l) : !1, A = l ? U(l) : !1, n = [
138
+ const t = o.row.original, r = t.reportId, l = p.value.find((s) => s.id === r), H = r === ((w = z.value) == null ? void 0 : w.id), V = !t.canRead, D = l ? se(l) : !1, A = l ? U(l) : !1, n = [
137
139
  {
138
140
  label: a("report.common.duplicate"),
139
141
  onClick: () => {
@@ -239,10 +241,10 @@ const We = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Xe
239
241
  }
240
242
  ]);
241
243
  async function ie(o) {
242
- await T(async () => {
244
+ await B(async () => {
243
245
  var t;
244
246
  try {
245
- const r = o.id === ((t = B.value) == null ? void 0 : t.id);
247
+ const r = o.id === ((t = z.value) == null ? void 0 : t.id);
246
248
  await f.updateDefaultReport(r ? null : o.id), c.open({
247
249
  message: `Successfully ${r ? "unset" : "set"} ${o.name} as Overview`,
248
250
  type: "success"
@@ -261,7 +263,7 @@ const We = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Xe
261
263
  })
262
264
  })) {
263
265
  const r = JSON.parse(JSON.stringify(o));
264
- r.editable = !0, r.id = "", r.name = `${r.name} ${a("report.common.duplicate")}`, r.isDefault = !1, T(async () => {
266
+ r.editable = !0, r.id = "", r.name = `${r.name} ${a("report.common.duplicate")}`, r.isDefault = !1, B(async () => {
265
267
  try {
266
268
  await f.createOrUpdateReport(r), c.open({
267
269
  message: `${a("report.messages.duplicateSuccess", { name: r.name })}`,
@@ -292,7 +294,7 @@ const We = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Xe
292
294
  await ae({
293
295
  title: a("report.messages.deleteReport"),
294
296
  message: a("report.messages.confirmDelete", { name: o.name })
295
- }) && T(async () => {
297
+ }) && B(async () => {
296
298
  try {
297
299
  await f.removeReport(o), c.open({
298
300
  message: a("report.messages.deleteSuccess", { name: o.name }),
@@ -333,7 +335,7 @@ const We = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Xe
333
335
  }
334
336
  }
335
337
  function pe(o) {
336
- const t = X(a, z, o.name, "other") ?? "";
338
+ const t = X(a, J, o.name, "other") ?? "";
337
339
  I.value && I.value.includes(o.id) ? (c.open({
338
340
  message: `${a("report.common.unpin")} ${t} ${a("report.common.successful")}`,
339
341
  type: "success"
@@ -348,7 +350,7 @@ const We = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Xe
348
350
  const { selectedLocationIds: k, dateRange: P, compareDateRange: L, timeRange: v, locations: $e } = ge(), N = h(() => k.length === $e.length);
349
351
  return (o, t) => {
350
352
  const r = x("FmPageHead"), l = x("FmSearch"), H = x("FmForm"), V = x("FmListItem"), D = x("FmList"), A = x("FmTable");
351
- return J(), W(Je, null, {
353
+ return T(), W(Te, null, {
352
354
  default: m(() => [
353
355
  i(r, {
354
356
  title: e(a)("report.common.report", 1),
@@ -382,7 +384,7 @@ const We = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Xe
382
384
  })
383
385
  ]),
384
386
  default: m(() => [
385
- (J(!0), Pe(Le, null, Ne(ce.value, (n, w) => (J(), W(e(C), {
387
+ (T(!0), Pe(Le, null, Ne(ce.value, (n, w) => (T(), W(e(C), {
386
388
  key: w,
387
389
  label: e(a)(`report.category.${n.label}`),
388
390
  onClick: () => _e(n)
@@ -406,7 +408,7 @@ const We = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Xe
406
408
  ]),
407
409
  _: 1
408
410
  }, 8, ["class"]),
409
- fe((J(), W(A, {
411
+ fe((T(), W(A, {
410
412
  key: Se.value,
411
413
  ref_key: "table",
412
414
  ref: b,
@@ -524,7 +526,7 @@ const We = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Xe
524
526
  }, null, 8, ["label", "disabled", "class", "onClick"]),
525
527
  i(e(C), {
526
528
  label: e(a)(
527
- n.reportId === ((w = e(B)) == null ? void 0 : w.id) ? "report.common.unsetAsOverview" : "report.common.setAsOverview"
529
+ n.reportId === ((w = e(z)) == null ? void 0 : w.id) ? "report.common.unsetAsOverview" : "report.common.setAsOverview"
528
530
  ),
529
531
  onClick: () => {
530
532
  const s = e(p).find(
@@ -0,0 +1,448 @@
1
+ import { ref as N, shallowRef as ne, onMounted as G, onBeforeUnmount as oe, defineComponent as re, watch as L, computed as ae, createElementBlock as U, openBlock as A, createElementVNode as V, createCommentVNode as J, withDirectives as se, createVNode as F, unref as C, isRef as H, withCtx as ie, toDisplayString as Y, vShow as ue } from "vue";
2
+ import { useRoute as ce } from "vue-router";
3
+ import { u as le } from "./_plugin-vue_export-helper-C6QDExPN.js";
4
+ import { storeToRefs as x } from "pinia";
5
+ import { _ as de } from "./LocationSelect.vue_vue_type_script_setup_true_lang-DC9QYJk-.js";
6
+ import { D as fe } from "./DateRangeSelect-CRsKMi0U.js";
7
+ import { F as B, r as j, u as W, a as X, a0 as me } from "./app-Bjt_JuJi.js";
8
+ function K(o) {
9
+ const { businessId: c } = x(W());
10
+ if (!c.value) throw new Error("Business Id is not defined");
11
+ return `/${c.value}/report-canvas/${o}`;
12
+ }
13
+ const pe = (o) => {
14
+ const c = {
15
+ fetchType: B.Get,
16
+ url: K(o)
17
+ };
18
+ return j.fetch(c);
19
+ }, ve = (o, c, l, s) => {
20
+ const p = {
21
+ fetchType: B.Post,
22
+ url: `${K(o)}/query/${c}`,
23
+ data: { params: l, timezone: s }
24
+ };
25
+ return j.fetch(p);
26
+ }, ye = (o, c, l) => {
27
+ const s = {
28
+ fetchType: B.Post,
29
+ url: `${K(o)}/section/${c}/ack`,
30
+ data: l
31
+ };
32
+ return j.fetch(s);
33
+ }, he = ["@from", "@to", "@locationIds", "@timezone"], we = ["@from", "@to", "@locationIds"], ge = 1, Se = 1500;
34
+ function Re(o) {
35
+ if (!(!(o instanceof me) || o.status !== 429))
36
+ return Math.min(Math.max(o.retryAfterMs ?? Se, 500), 5e3);
37
+ }
38
+ const be = {
39
+ MY: "MYR",
40
+ SG: "SGD",
41
+ TH: "THB",
42
+ ID: "IDR",
43
+ PH: "PHP",
44
+ VN: "VND",
45
+ BN: "BND",
46
+ KH: "KHR",
47
+ MM: "MMK",
48
+ AE: "AED",
49
+ MO: "MOP",
50
+ MV: "MVR",
51
+ AU: "AUD",
52
+ JP: "JPY",
53
+ TW: "TWD",
54
+ HK: "HKD"
55
+ };
56
+ function q(o) {
57
+ return o == null ? !0 : Array.isArray(o) ? o.length === 0 : o === "";
58
+ }
59
+ function _e(o) {
60
+ const c = X(), { dateRange: l, selectedLocationIds: s, locations: p, timezone: v } = x(c), { country: _ } = x(W()), r = N({}), i = ne({}), R = N([]), I = [], g = {}, y = {};
61
+ function O(e) {
62
+ I.push(e);
63
+ }
64
+ function k(e) {
65
+ i.value = { ...i.value, [e.queryId]: e }, I.forEach((n) => n(e));
66
+ }
67
+ function T(e) {
68
+ const n = {};
69
+ for (const m of e.params)
70
+ n[m.name] = m.default ?? null;
71
+ n["@from"] = l.value.startDate ?? null, n["@to"] = l.value.endDate ?? null, n["@timezone"] = v.value, n["@locationIds"] = s.value.length ? [...s.value] : p.value.map((m) => m.id), r.value = n;
72
+ }
73
+ function a() {
74
+ return {
75
+ locations: p.value.map((e) => ({
76
+ id: e.id,
77
+ name: e.name || e.id,
78
+ code: e.code
79
+ })),
80
+ timezone: v.value,
81
+ locale: navigator.language || "en-US",
82
+ currency: be[(_.value || "").toUpperCase()] ?? ""
83
+ };
84
+ }
85
+ function h(e) {
86
+ return JSON.stringify(e.dependsOn.map((n) => r.value[n] ?? null));
87
+ }
88
+ function S(e) {
89
+ return !!e.lazy && e.dependsOn.some((n) => q(r.value[n] ?? null));
90
+ }
91
+ function D() {
92
+ return !we.some((e) => e in r.value && q(r.value[e] ?? null));
93
+ }
94
+ async function E(e) {
95
+ var m;
96
+ const n = (g[e.id] ?? 0) + 1;
97
+ g[e.id] = n, k({
98
+ queryId: e.id,
99
+ runId: n,
100
+ status: "loading",
101
+ rows: ((m = i.value[e.id]) == null ? void 0 : m.rows) ?? [],
102
+ truncated: !1
103
+ });
104
+ for (let b = 0; ; b++)
105
+ try {
106
+ const w = await ve(
107
+ o,
108
+ e.id,
109
+ r.value,
110
+ v.value
111
+ );
112
+ if (g[e.id] !== n) return;
113
+ k({
114
+ queryId: e.id,
115
+ runId: n,
116
+ status: "ok",
117
+ rows: w.rows ?? [],
118
+ truncated: !!w.truncated
119
+ });
120
+ return;
121
+ } catch (w) {
122
+ if (g[e.id] !== n) return;
123
+ const f = Re(w);
124
+ if (f !== void 0 && b < ge) {
125
+ if (await new Promise((u) => setTimeout(u, f)), g[e.id] !== n) return;
126
+ continue;
127
+ }
128
+ k({
129
+ queryId: e.id,
130
+ runId: n,
131
+ status: "error",
132
+ rows: [],
133
+ truncated: !1,
134
+ error: w instanceof Error ? w.message : String(w)
135
+ });
136
+ return;
137
+ }
138
+ }
139
+ function M(e = {}) {
140
+ var m, b, w;
141
+ const n = !D();
142
+ for (const f of R.value) {
143
+ if (S(f)) {
144
+ delete y[f.id], ((m = i.value[f.id]) == null ? void 0 : m.status) !== "idle" && k({
145
+ queryId: f.id,
146
+ runId: g[f.id] ?? 0,
147
+ status: "idle",
148
+ rows: [],
149
+ truncated: !1
150
+ });
151
+ continue;
152
+ }
153
+ if (n) {
154
+ ((b = i.value[f.id]) == null ? void 0 : b.status) !== "loading" && k({
155
+ queryId: f.id,
156
+ runId: g[f.id] ?? 0,
157
+ status: "loading",
158
+ rows: ((w = i.value[f.id]) == null ? void 0 : w.rows) ?? [],
159
+ truncated: !1
160
+ });
161
+ continue;
162
+ }
163
+ const u = h(f);
164
+ !e.force && y[f.id] === u || (y[f.id] = u, E(f));
165
+ }
166
+ }
167
+ function P(e) {
168
+ const n = { ...r.value };
169
+ let m = !1;
170
+ for (const [b, w] of Object.entries(e))
171
+ b in n && JSON.stringify(n[b] ?? null) !== JSON.stringify(w ?? null) && (n[b] = w, m = !0);
172
+ return m ? (r.value = n, M(), !0) : !1;
173
+ }
174
+ function t(e) {
175
+ R.value = e.queries, i.value = {};
176
+ for (const n of Object.keys(g)) delete g[n];
177
+ for (const n of Object.keys(y)) delete y[n];
178
+ T(e), M();
179
+ }
180
+ function d(e, n = []) {
181
+ R.value = e.queries;
182
+ const m = JSON.stringify(r.value), b = {};
183
+ for (const u of e.params)
184
+ b[u.name] = u.name in r.value ? r.value[u.name] : u.default ?? null;
185
+ r.value = b;
186
+ const w = new Set(e.queries.map((u) => u.id));
187
+ for (const u of Object.keys(g)) w.has(u) || delete g[u];
188
+ for (const u of Object.keys(y)) w.has(u) || delete y[u];
189
+ const f = Object.keys(i.value).filter((u) => !w.has(u));
190
+ if (f.length) {
191
+ const u = { ...i.value };
192
+ for (const te of f) delete u[te];
193
+ i.value = u;
194
+ }
195
+ for (const u of n) delete y[u];
196
+ return M(), JSON.stringify(r.value) !== m;
197
+ }
198
+ return {
199
+ params: r,
200
+ results: i,
201
+ queries: R,
202
+ env: a,
203
+ load: t,
204
+ applyCanvas: d,
205
+ run: M,
206
+ setParams: P,
207
+ onResult: O,
208
+ RESERVED: he
209
+ };
210
+ }
211
+ function Z(o) {
212
+ const c = o.replace(/^\//, "");
213
+ try {
214
+ const l = new URL(import.meta.url);
215
+ if (typeof location < "u" && location.hostname !== l.hostname)
216
+ return new URL(c, l).href;
217
+ } catch {
218
+ }
219
+ return `${"/".replace(/\/$/, "")}/${c}`;
220
+ }
221
+ const ee = {
222
+ "chart.js@4": "chart.js-4.js",
223
+ "fm-ui@1": "fm-ui-1.js"
224
+ }, $ = /* @__PURE__ */ new Map();
225
+ function Ee(o) {
226
+ return Z(`report-canvas-libs/${ee[o]}`);
227
+ }
228
+ async function z(o) {
229
+ const c = [...new Set(o)].filter((s) => ee[s]), l = {};
230
+ return await Promise.all(
231
+ c.map(async (s) => {
232
+ if (!$.has(s)) {
233
+ const v = await fetch(Ee(s));
234
+ if (!v.ok) return;
235
+ $.set(s, await v.text());
236
+ }
237
+ const p = $.get(s);
238
+ p && (l[s] = p);
239
+ })
240
+ ), l;
241
+ }
242
+ const Ie = Z("report-canvas-frame.html"), Q = 8e3;
243
+ function ke(o, c) {
244
+ const l = N(!1);
245
+ let s = null;
246
+ const p = /* @__PURE__ */ new Map();
247
+ let v;
248
+ const _ = /* @__PURE__ */ new Map();
249
+ function r() {
250
+ var t;
251
+ return ((t = o.value) == null ? void 0 : t.contentWindow) ?? null;
252
+ }
253
+ function i(t) {
254
+ var d;
255
+ (d = r()) == null || d.postMessage(JSON.parse(JSON.stringify(t)), "*");
256
+ }
257
+ function R(t) {
258
+ const d = r();
259
+ if (!d || t.source !== d) return;
260
+ const e = t.data;
261
+ if (!(!e || typeof e != "object"))
262
+ switch (e.type) {
263
+ case "ready":
264
+ if (l.value) return;
265
+ v = e.nonce, l.value = !0, s == null || s(), s = null, D();
266
+ break;
267
+ case "setParams":
268
+ c.onSetParams(e.values ?? {});
269
+ break;
270
+ case "rendered":
271
+ if (!I(e)) return;
272
+ y(e.sectionId, e.version), c.onSectionRendered(e.sectionId, e.version);
273
+ break;
274
+ case "error":
275
+ if (!I(e)) return;
276
+ y(e.sectionId, e.version), c.onSectionError(e.sectionId, e.version, e.message);
277
+ break;
278
+ }
279
+ }
280
+ function I(t) {
281
+ return !v || t.nonce === v ? !0 : (console.warn("[report-canvas] dropped a render outcome without the shell nonce"), !1);
282
+ }
283
+ function g(t, d) {
284
+ return `${t}@${d}`;
285
+ }
286
+ function y(t, d) {
287
+ if (d === void 0) return;
288
+ const e = g(t, d), n = _.get(e);
289
+ n !== void 0 && (clearTimeout(n), _.delete(e));
290
+ }
291
+ function O() {
292
+ _.forEach((t) => clearTimeout(t)), _.clear();
293
+ }
294
+ function k(t) {
295
+ for (const d of t) {
296
+ const e = g(d.id, d.version);
297
+ _.has(e) || _.set(
298
+ e,
299
+ setTimeout(() => {
300
+ _.delete(e), c.onSectionError(
301
+ d.id,
302
+ d.version,
303
+ `the section did not report a render within ${Q}ms`
304
+ );
305
+ }, Q)
306
+ );
307
+ }
308
+ }
309
+ async function T(t, d, e) {
310
+ const n = await z(t.flatMap((b) => b.libs ?? [])), m = () => {
311
+ i({ type: "init", sections: t, params: d, libs: n, env: e }), O(), k(t);
312
+ };
313
+ l.value ? m() : s = m;
314
+ }
315
+ async function a(t) {
316
+ const d = await z(t.flatMap((e) => e.libs ?? []));
317
+ i({ type: "sections", sections: t, libs: d }), k(t);
318
+ }
319
+ function h(t) {
320
+ i({ type: "params", values: t });
321
+ }
322
+ function S(t) {
323
+ i({ type: "env", env: t });
324
+ }
325
+ function D() {
326
+ const t = [...p.values()];
327
+ p.clear(), t.forEach(E);
328
+ }
329
+ function E(t) {
330
+ i({
331
+ type: "rows",
332
+ queryId: t.queryId,
333
+ runId: t.runId,
334
+ rows: t.rows,
335
+ status: t.status,
336
+ truncated: t.truncated,
337
+ error: t.error
338
+ });
339
+ }
340
+ function M(t) {
341
+ if (!l.value) {
342
+ p.set(t.queryId, t);
343
+ return;
344
+ }
345
+ E(t);
346
+ }
347
+ G(() => window.addEventListener("message", R)), oe(() => {
348
+ window.removeEventListener("message", R), O();
349
+ });
350
+ function P() {
351
+ l.value = !1, s = null, v = void 0, p.clear(), O();
352
+ }
353
+ return { ready: l, init: T, swapSections: a, pushParams: h, pushEnv: S, pushRows: M, reset: P };
354
+ }
355
+ const Me = { class: "flex h-full min-h-0 w-full" }, Oe = { class: "flex min-w-0 grow flex-col" }, Pe = { class: "flex items-start overflow-x-auto border-b border-fm-color-border-secondary px-16 py-8 scrollbar-hide" }, Ce = {
356
+ key: 0,
357
+ class: "fm-typo-en-body-xs-400 border-b border-fm-color-border-secondary bg-fm-color-system-warning-100 px-16 py-8"
358
+ }, Ne = {
359
+ key: 1,
360
+ class: "fm-typo-en-body-sm-400 p-16 text-fm-color-typo-error"
361
+ }, Te = ["src", "title"], je = /* @__PURE__ */ re({
362
+ __name: "ReportCanvasView",
363
+ setup(o) {
364
+ const c = ce(), { t: l } = le(), s = String(c.query.reportId ?? ""), p = N(), v = N(""), _ = N(), r = _e(s), { dateRange: i, selectedLocationIds: R, locations: I, timezone: g } = x(X()), y = ke(_, {
365
+ onSetParams: (a) => {
366
+ r.setParams(a) && y.pushParams(r.params.value);
367
+ },
368
+ onSectionRendered: (a, h) => void O(a, h, "ok"),
369
+ onSectionError: (a, h, S) => {
370
+ console.warn("[report-canvas] section failed", { reportId: s, sectionId: a, message: S }), O(a, h, "error", S);
371
+ }
372
+ });
373
+ r.onResult((a) => y.pushRows(a));
374
+ async function O(a, h, S, D) {
375
+ var P;
376
+ const E = (P = p.value) == null ? void 0 : P.sections.find((t) => t.id === a);
377
+ if (!E || h !== E.version) return;
378
+ const M = S === "error" ? D ?? "the section failed to render" : void 0;
379
+ if (!(E.status === S && E.error === M)) {
380
+ E.status = S, E.error = M;
381
+ try {
382
+ await ye(s, a, { version: h, status: S, error: M });
383
+ } catch (t) {
384
+ console.warn("[report-canvas] ack failed", { reportId: s, sectionId: a, err: t });
385
+ }
386
+ }
387
+ }
388
+ async function k() {
389
+ try {
390
+ v.value = "";
391
+ const a = await pe(s);
392
+ p.value = a, r.load(a), await y.init(a.sections, r.params.value, r.env());
393
+ } catch (a) {
394
+ v.value = a instanceof Error ? a.message : String(a);
395
+ }
396
+ }
397
+ L([i, R, I], () => {
398
+ if (!p.value) return;
399
+ r.setParams({
400
+ "@from": i.value.startDate ?? null,
401
+ "@to": i.value.endDate ?? null,
402
+ "@locationIds": R.value.length ? [...R.value] : I.value.map((h) => h.id)
403
+ }) && y.pushParams(r.params.value);
404
+ }), L([I, g], () => {
405
+ p.value && y.pushEnv(r.env());
406
+ });
407
+ const T = ae(
408
+ () => Object.values(r.results.value).some((a) => a.truncated)
409
+ );
410
+ return G(async () => {
411
+ await k();
412
+ }), (a, h) => (A(), U("div", Me, [
413
+ V("div", Oe, [
414
+ V("div", Pe, [
415
+ F(de, {
416
+ modelValue: C(R),
417
+ "onUpdate:modelValue": h[1] || (h[1] = (S) => H(R) ? R.value = S : null),
418
+ options: C(I)
419
+ }, {
420
+ default: ie(() => [
421
+ F(fe, {
422
+ "date-range": C(i),
423
+ "onUpdate:dateRange": h[0] || (h[0] = (S) => H(i) ? i.value = S : null)
424
+ }, null, 8, ["date-range"])
425
+ ]),
426
+ _: 1
427
+ }, 8, ["modelValue", "options"])
428
+ ]),
429
+ T.value ? (A(), U("div", Ce, Y(C(l)("reportV5.reportCanvas.canvas.truncated")), 1)) : J("", !0),
430
+ v.value ? (A(), U("p", Ne, Y(v.value), 1)) : J("", !0),
431
+ se(V("iframe", {
432
+ ref_key: "frame",
433
+ ref: _,
434
+ "data-testid": "report-canvas-frame",
435
+ class: "min-h-0 grow border-0",
436
+ src: C(Ie),
437
+ sandbox: "allow-scripts",
438
+ title: C(l)("reportV5.reportCanvas.canvas.title")
439
+ }, null, 8, Te), [
440
+ [ue, !v.value]
441
+ ])
442
+ ])
443
+ ]));
444
+ }
445
+ });
446
+ export {
447
+ je as default
448
+ };