@feedmepos/mf-report 5.27.35 → 5.27.36

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 (32) hide show
  1. package/dist/{App-4_GHdc0c.js → App-CHT3iF-7.js} +4 -4
  2. package/dist/{DateRangeSelect-Cvxqh6KE.js → DateRangeSelect-D2772bgT.js} +1 -1
  3. package/dist/{Default.vue_vue_type_script_setup_true_lang-FvTBswXI.js → Default.vue_vue_type_script_setup_true_lang-CArSG8Z_.js} +1 -1
  4. package/dist/{DynamicWidget.vue_vue_type_script_setup_true_lang-PhthswCX.js → DynamicWidget.vue_vue_type_script_setup_true_lang-RABMoQ3F.js} +949 -879
  5. package/dist/{GlobalFilterSelect.vue_vue_type_script_setup_true_lang-CoI3PFYF.js → GlobalFilterSelect.vue_vue_type_script_setup_true_lang-DzZP-ANz.js} +3886 -3841
  6. package/dist/InsightView-KYbGpFKj.js +689 -0
  7. package/dist/{Integration-BmtzVBU8.js → Integration-CocbSCYz.js} +3 -3
  8. package/dist/{Integrations-FKTHYjkY.js → Integrations-DaKi0pnt.js} +2 -2
  9. package/dist/{Layout-Dn9c-gMi.js → Layout-p1hYeFa3.js} +1 -1
  10. package/dist/{MenuTab.vue_vue_type_script_setup_true_lang-H1iroFEV.js → MenuTab.vue_vue_type_script_setup_true_lang-DG-9RjS_.js} +49 -46
  11. package/dist/{NavigationTab.vue_vue_type_script_setup_true_lang-cPTLcF06.js → NavigationTab.vue_vue_type_script_setup_true_lang-By2GxyK2.js} +3 -3
  12. package/dist/{OverviewView-DQs-PWBo.js → OverviewView-CfmhSHLj.js} +4 -4
  13. package/dist/{Report-gLUTNmHm.js → Report-tUyaWEtI.js} +3 -3
  14. package/dist/ReportEditor-BUXYZXMs.js +2032 -0
  15. package/dist/ReportView-BwrLb4jX.js +331 -0
  16. package/dist/{Setting-zldr38s7.js → Setting-DApgIt2e.js} +11 -11
  17. package/dist/{Template-nAGq9Il6.js → Template-Cte2kk4J.js} +3 -3
  18. package/dist/TileEditor-DPUludYa.js +4154 -0
  19. package/dist/TileGrid.vue_vue_type_script_setup_true_lang-CC-xGpBd.js +257 -0
  20. package/dist/{TransitionFade-Cq7jxuTO.js → TransitionFade-DszPGM-J.js} +4 -4
  21. package/dist/{app-L5Gs2RN0.js → app-CwM9HM2R.js} +3577 -3371
  22. package/dist/app.js +1 -1
  23. package/dist/assets/{formatChartData.worker-GhwszhPe.js → formatChartData.worker-Ci7ZpIYk.js} +6 -6
  24. package/dist/assets/{processTableData.worker-C4hgpe0l.js → processTableData.worker-C2Ubh_e0.js} +6 -6
  25. package/dist/style.css +1 -1
  26. package/dist/{useRestaurantPermission-D9GFgNLW.js → useRestaurantPermission-BQ0MKNOz.js} +1 -1
  27. package/package.json +2 -2
  28. package/dist/InsightView-D8Jpwge7.js +0 -664
  29. package/dist/ReportEditor-kp63cCQT.js +0 -1831
  30. package/dist/ReportView-0m23WbFa.js +0 -311
  31. package/dist/TileEditor-CcwBUuaS.js +0 -4093
  32. package/dist/TileGrid.vue_vue_type_script_setup_true_lang-707n8i-y.js +0 -154
@@ -1,1831 +0,0 @@
1
- import { defineComponent as xe, mergeModels as Se, useModel as De, ref as z, computed as f, resolveComponent as F, createBlock as S, openBlock as d, withCtx as _, createElementVNode as h, createVNode as i, unref as o, normalizeClass as Ue, createTextVNode as ze, toDisplayString as E, createElementBlock as R, Fragment as Fe, renderSlot as ct, createCommentVNode as U, watch as be, renderList as Be, onMounted as pt, onUnmounted as Vt, resolveDynamicComponent as Tt, isRef as vt, normalizeStyle as et } from "vue";
2
- import { W as $t, g as St, _ as Dt, a as Ot, e as Ie, d as ft, b as gt, S as Ae, T as Nt, c as It } from "./TransitionFade-Cq7jxuTO.js";
3
- import { C as Te, D as oe, d as Re, g as Rt, u as lt, M as bt, r as Mt, e as rt, n as Bt, f as Ut, h as qt, i as Et, j as Pt, a as zt, b as it, k as Qe, m as Lt, Q as We, o as Gt, l as At, c as st, p as Wt } from "./GlobalFilterSelect.vue_vue_type_script_setup_true_lang-CoI3PFYF.js";
4
- import { storeToRefs as Me } from "pinia";
5
- import { useRouter as ot, useRoute as at } from "vue-router";
6
- import { useBreakpoints as He, useSnackbar as yt, FmButtonColorThemeVariant as $e } from "@feedmepos/ui-library";
7
- import { u as nt } from "./message-dialog-UoMWOnil.js";
8
- import { u as qe, a as Ht } from "./_plugin-vue_export-helper-onplcgja.js";
9
- import { r as Le } from "./i18n-CI_sQ5d_.js";
10
- import { _ as Ye } from "./TileGrid.vue_vue_type_script_setup_true_lang-707n8i-y.js";
11
- import { a as Xe, _ as Ze } from "./SelectComponent.vue_vue_type_script_setup_true_lang-CGbb3b5G.js";
12
- import { i as jt } from "./DynamicWidget.vue_vue_type_script_setup_true_lang-PhthswCX.js";
13
- import { useCoreStore as Jt } from "@feedmepos/mf-common";
14
- import { u as Kt, a as Qt } from "./app-L5Gs2RN0.js";
15
- import { d as Yt } from "./DateRangeSelect-Cvxqh6KE.js";
16
- const Xt = /* @__PURE__ */ xe({
17
- __name: "WidgetDialog",
18
- props: /* @__PURE__ */ Se({
19
- isOpen: { type: Boolean }
20
- }, {
21
- modelValue: {},
22
- modelModifiers: {}
23
- }),
24
- emits: /* @__PURE__ */ Se(["update:isOpen"], ["update:modelValue"]),
25
- setup(M, { emit: u }) {
26
- const { t: a } = qe(), { breakpoints: c } = He(), v = De(M, "modelValue"), g = M, B = u;
27
- function Y() {
28
- B("update:isOpen", !1);
29
- }
30
- function k() {
31
- y.value && (v.value = y.value, y.value = void 0, B("update:isOpen", !1));
32
- }
33
- const y = z(), x = f(() => !y.value);
34
- return (O, G) => {
35
- const D = F("FmButton"), T = F("FmDialog");
36
- return d(), S(T, {
37
- "model-value": g.isOpen
38
- }, {
39
- "dialog-header": _(() => [
40
- ze(E(o(a)("report.widget.type")), 1)
41
- ]),
42
- default: _(() => [
43
- i($t, {
44
- modelValue: y.value,
45
- "onUpdate:modelValue": G[0] || (G[0] = ($) => y.value = $),
46
- class: Ue(`grid ${o(c).lg || o(c).md ? "grid-cols-3 gap-3" : "grid-cols-2 gap-3"}`),
47
- "child-class": "p-[8px] flex flex-col"
48
- }, null, 8, ["modelValue", "class"])
49
- ]),
50
- "dialog-footer": _(() => [
51
- G[1] || (G[1] = h("div", { class: "grow" }, null, -1)),
52
- i(D, {
53
- label: o(a)("report.common.cancel"),
54
- variant: "tertiary",
55
- onClick: Y
56
- }, null, 8, ["label"]),
57
- i(D, {
58
- label: o(a)("report.common.confirm"),
59
- disabled: x.value,
60
- onClick: k
61
- }, null, 8, ["label", "disabled"])
62
- ]),
63
- _: 1
64
- }, 8, ["model-value"]);
65
- };
66
- }
67
- }), Zt = { class: "fm-typo-en-body-lg-600" }, tt = /* @__PURE__ */ xe({
68
- __name: "ReportEditorTabHeader",
69
- props: /* @__PURE__ */ Se({
70
- icon: {
71
- type: String,
72
- required: !0
73
- }
74
- }, {
75
- modelValue: { type: Boolean, required: !0, default: !1 },
76
- modelModifiers: {}
77
- }),
78
- emits: ["update:modelValue"],
79
- setup(M) {
80
- const { t: u } = qe(), a = De(M, "modelValue"), c = M;
81
- return (v, g) => {
82
- const B = F("FmIcon");
83
- return d(), R("div", {
84
- class: "px-6 py-16 flex items-center gap-2 bg-fm-color-neutral-white border cursor-pointer",
85
- onClick: g[0] || (g[0] = (Y) => a.value = !a.value)
86
- }, [
87
- h("p", Zt, E(o(u)("report.editor.customizeReport")), 1),
88
- g[1] || (g[1] = h("div", { class: "grow" }, null, -1)),
89
- i(B, {
90
- name: c.icon
91
- }, null, 8, ["name"])
92
- ]);
93
- };
94
- }
95
- }), el = /* @__PURE__ */ xe({
96
- __name: "ReportEditorTabDesktop",
97
- props: {
98
- modelValue: { required: !0, default: !1 },
99
- modelModifiers: {}
100
- },
101
- emits: ["update:modelValue"],
102
- setup(M) {
103
- const u = De(M, "modelValue");
104
- return (a, c) => (d(), R(Fe, null, [
105
- i(tt, {
106
- modelValue: u.value,
107
- "onUpdate:modelValue": c[0] || (c[0] = (v) => u.value = v),
108
- icon: "keyboard_double_arrow_left"
109
- }, null, 8, ["modelValue"]),
110
- ct(a.$slots, "default")
111
- ], 64));
112
- }
113
- }), tl = /* @__PURE__ */ xe({
114
- __name: "ReportEditorTabMobile",
115
- props: {
116
- modelValue: { required: !0, default: !1 },
117
- modelModifiers: {}
118
- },
119
- emits: ["update:modelValue"],
120
- setup(M) {
121
- const u = De(M, "modelValue");
122
- return (a, c) => {
123
- const v = F("FmTopSheet"), g = F("FmCard");
124
- return d(), S(g, { class: "fixed bottom-0 w-full" }, {
125
- default: _(() => [
126
- i(tt, {
127
- modelValue: u.value,
128
- "onUpdate:modelValue": c[0] || (c[0] = (B) => u.value = B),
129
- icon: "keyboard_double_arrow_up"
130
- }, null, 8, ["modelValue"]),
131
- i(v, {
132
- modelValue: u.value,
133
- "onUpdate:modelValue": c[2] || (c[2] = (B) => u.value = B),
134
- "fullscreen-size": "sm"
135
- }, {
136
- default: _(() => [
137
- i(tt, {
138
- modelValue: u.value,
139
- "onUpdate:modelValue": c[1] || (c[1] = (B) => u.value = B),
140
- icon: "keyboard_double_arrow_down"
141
- }, null, 8, ["modelValue"]),
142
- u.value ? ct(a.$slots, "default", { key: 0 }) : U("", !0)
143
- ]),
144
- _: 3
145
- }, 8, ["modelValue"])
146
- ]),
147
- _: 3
148
- });
149
- };
150
- }
151
- }), ll = {
152
- key: 2,
153
- class: "flex flex-col gap-3 mt-2 border border-neutral-300 p-3"
154
- }, ol = { class: "grid grid-cols-1 gap-2 rounded-md border border-neutral-300 p-2 sm:grid-cols-[1.3fr_1fr_1fr_auto] sm:items-end" }, al = {
155
- key: 0,
156
- class: "flex justify-end sm:pb-[2px]"
157
- }, nl = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, rl = { class: "pl-1" }, il = {
158
- key: 0,
159
- class: "flex justify-end sm:pb-[2px]"
160
- }, sl = {
161
- key: 3,
162
- class: "flex flex-col gap-2"
163
- }, ul = /* @__PURE__ */ xe({
164
- __name: "GlobalFilterDialog",
165
- props: /* @__PURE__ */ Se({
166
- schemas: {
167
- type: Array,
168
- default: () => []
169
- },
170
- tiles: {
171
- type: Array,
172
- required: !0
173
- }
174
- }, {
175
- globalFilter: {
176
- default: () => null
177
- },
178
- globalFilterModifiers: {},
179
- isOpen: { type: Boolean, default: () => !1, required: !0 },
180
- isOpenModifiers: {}
181
- }),
182
- emits: ["update:globalFilter", "update:isOpen"],
183
- setup(M) {
184
- const { t: u, te: a } = qe(), c = De(M, "globalFilter"), v = De(M, "isOpen"), g = yt(), B = M, Y = z(""), k = z(), y = z(), x = z(), O = z([]), G = z([]), D = z(!1), T = z([]), $ = z([]), X = z(Te.Equal);
185
- function ae(l) {
186
- return JSON.parse(JSON.stringify(l));
187
- }
188
- function Ce(l, e) {
189
- return { hour: l, minute: e };
190
- }
191
- function ue(l) {
192
- return l ? `${String(l.hour).padStart(2, "0")}:${String(l.minute).padStart(2, "0")}` : null;
193
- }
194
- function J(l) {
195
- if (!l) return null;
196
- const [e, s] = l.split(":").map(Number);
197
- return Number.isNaN(e) || Number.isNaN(s) ? null : { hour: e, minute: s };
198
- }
199
- const w = f(() => y.value ? !(y.value.type === oe.Timestamp && x.value === Re.DateTime) : !1), ee = f(
200
- () => {
201
- var l;
202
- return ((l = y.value) == null ? void 0 : l.type) === oe.Timestamp && x.value === Re.TimeOfDay;
203
- }
204
- ), ne = f(() => {
205
- var l;
206
- return (((l = y.value) == null ? void 0 : l.filterOperators) ?? []).filter((e) => e !== Te.And && e !== Te.Or).map((e) => ({
207
- label: u(`report.section.comparisonOperator.${e}`),
208
- value: e
209
- }));
210
- });
211
- function le() {
212
- var e;
213
- const l = (e = ne.value[0]) == null ? void 0 : e.value;
214
- return l || (y.value ? H(
215
- y.value.type,
216
- x.value ?? null
217
- ) : Te.Equal);
218
- }
219
- function re(l) {
220
- if (y.value)
221
- return Rt({
222
- operator: l ?? le(),
223
- dataType: y.value.type,
224
- dimensionOption: y.value.type === oe.Timestamp ? x.value ?? null : null,
225
- t: u
226
- });
227
- }
228
- function pe(l, e) {
229
- if (typeof (e == null ? void 0 : e.default) == "boolean" || l.length > 0 && l.every((C) => typeof C == "boolean")) {
230
- const C = l.reduce((I, j) => (typeof j == "boolean" && I.push(j), I), []);
231
- if (e)
232
- for (e.fixed && C.splice(e.count); C.length < e.count; )
233
- C.push(typeof e.default == "boolean" ? e.default : !1);
234
- return C;
235
- }
236
- const p = l.reduce((C, I) => (typeof I == "string" && C.push(I), C), []);
237
- if (e)
238
- for (e.fixed && p.splice(e.count); p.length < e.count; )
239
- p.push(typeof e.default == "string" ? e.default : "");
240
- return p;
241
- }
242
- function ve(l = X.value) {
243
- const e = re(l), s = pe(
244
- e ? Array(e.count).fill(e.default) : [],
245
- e
246
- );
247
- return {
248
- label: "",
249
- operator: l,
250
- values: s
251
- };
252
- }
253
- function q() {
254
- return {
255
- name: "",
256
- startTime: Ce(0, 0),
257
- endTime: Ce(23, 59)
258
- };
259
- }
260
- function L() {
261
- if (!(!w.value || !D.value)) {
262
- if (ee.value) {
263
- $.value.length === 0 && ($.value = [q()]);
264
- return;
265
- }
266
- T.value.length === 0 && (T.value = [ve()]);
267
- }
268
- }
269
- function K() {
270
- var s, p, C;
271
- const l = ae(((s = c.value) == null ? void 0 : s.customOptions) ?? []), e = ae(((p = c.value) == null ? void 0 : p.customTimeRanges) ?? []);
272
- X.value = ((C = l[0]) == null ? void 0 : C.operator) ?? le(), D.value = l.length > 0 || e.length > 0, T.value = l, $.value = e, L();
273
- }
274
- function fe(l) {
275
- X.value = l, T.value = T.value.map((e, s) => {
276
- const p = T.value[s];
277
- if (!p)
278
- return ve(l);
279
- const C = re(l), I = pe(
280
- Array.isArray(p.values) ? [...p.values] : [],
281
- C
282
- );
283
- return {
284
- ...p,
285
- operator: l,
286
- values: I
287
- };
288
- });
289
- }
290
- function ye() {
291
- T.value = [...T.value, ve()];
292
- }
293
- function Q(l) {
294
- T.value.length <= 1 || (T.value = T.value.filter((e, s) => s !== l));
295
- }
296
- function ke() {
297
- $.value = [...$.value, q()];
298
- }
299
- function ie(l) {
300
- $.value.length <= 1 || ($.value = $.value.filter(
301
- (e, s) => s !== l
302
- ));
303
- }
304
- function ge(l, e, s) {
305
- const p = $.value[l];
306
- p && ($.value[l] = {
307
- ...p,
308
- [e]: J(s)
309
- });
310
- }
311
- function Ve(l) {
312
- return l.length === 0 || l.some((e) => e === "");
313
- }
314
- function Oe() {
315
- if (!D.value) return !0;
316
- if (ee.value) {
317
- const s = $.value.map((C) => C.name.trim()).filter(Boolean);
318
- return $.value.some(
319
- (C) => !C.name.trim() || !C.startTime || !C.endTime
320
- ) ? (g.open({
321
- message: u("report.section.filter.invalidCustomTimeRange"),
322
- type: "error"
323
- }), !1) : new Set(s).size !== s.length ? (g.open({
324
- message: u("report.section.filter.customTimeRangeNamesMustBeUnique"),
325
- type: "error"
326
- }), !1) : !0;
327
- }
328
- const l = T.value.map((s) => s.label.trim()).filter(Boolean);
329
- return T.value.some(
330
- (s) => !s.label.trim() || Ve(s.values)
331
- ) ? (g.open({ message: u("report.section.filter.invalidCustomOption"), type: "error" }), !1) : new Set(l).size !== l.length ? (g.open({
332
- message: u("report.section.filter.customOptionLabelsMustBeUnique"),
333
- type: "error"
334
- }), !1) : !0;
335
- }
336
- be(v, (l) => {
337
- var e, s, p, C, I;
338
- l && (Y.value = ((e = c.value) == null ? void 0 : e.label) || "", k.value = B.schemas.find(
339
- (j) => {
340
- var Z;
341
- return j.name === ((Z = c.value) == null ? void 0 : Z.schemaName);
342
- }
343
- ), y.value = (s = _e.value.find(
344
- (j) => {
345
- var Z;
346
- return j.value.name === ((Z = c.value) == null ? void 0 : Z.name);
347
- }
348
- )) == null ? void 0 : s.value, x.value = (p = c.value) == null ? void 0 : p.option, O.value = ((C = c.value) == null ? void 0 : C.tileIds) || [], G.value = ((I = c.value) == null ? void 0 : I.filters) || [], K());
349
- }), be(D, (l) => {
350
- var e;
351
- l && (X.value = ((e = T.value[0]) == null ? void 0 : e.operator) ?? le(), L());
352
- }), be(w, (l) => {
353
- if (!l) {
354
- D.value = !1, T.value = [], $.value = [];
355
- return;
356
- }
357
- L();
358
- }), be(ee, () => {
359
- L();
360
- }), be(ne, (l) => {
361
- var s;
362
- const e = (s = l[0]) == null ? void 0 : s.value;
363
- e && (l.some((p) => p.value === X.value) || fe(e));
364
- });
365
- const he = f(
366
- () => B.schemas.map((l) => ({
367
- label: l.label || l.name,
368
- value: l
369
- }))
370
- ), _e = f(() => {
371
- var l;
372
- return (((l = k.value) == null ? void 0 : l.fields) || []).filter((e) => e.type !== oe.Numeric).map((e) => ({
373
- label: e.label || e.name,
374
- value: e
375
- }));
376
- }), Ee = f(() => {
377
- var l;
378
- return ((l = y.value) == null ? void 0 : l.type) !== oe.Timestamp ? [] : St(u);
379
- }), n = f(() => B.tiles.reduce((l, e, s) => {
380
- var I, j, Z, ce, we;
381
- const p = ((I = e.widget) == null ? void 0 : I.config.schemaNames) ?? [], C = (((j = e.widget) == null ? void 0 : j.config.joinDatasources) ?? []).flatMap(
382
- (Ne) => Ne.schemaNames ?? []
383
- );
384
- return [...p, ...C].includes(((Z = k.value) == null ? void 0 : Z.name) || "") && l.push({
385
- label: (we = (ce = e.widget) == null ? void 0 : ce.title) != null && we.trim() ? e.widget.title : `Widget ${s + 1}`,
386
- value: e.id
387
- }), l;
388
- }, [])), m = f(
389
- () => B.schemas.flatMap(
390
- (l) => (l.fields ?? []).map((e) => ({
391
- ...e,
392
- labels: [
393
- Le(u, a, l.label, "schema"),
394
- Le(u, a, e.label || e.name, "other")
395
- ]
396
- }))
397
- )
398
- );
399
- function P(l) {
400
- var e;
401
- l.name !== ((e = k.value) == null ? void 0 : e.name) && (k.value = l, y.value = void 0, X.value = Te.Equal, D.value = !1, T.value = [], $.value = []);
402
- }
403
- function te(l) {
404
- y.value = l, x.value = l.type === oe.Timestamp ? Re.DateTime : void 0, X.value = le(), D.value = !1, T.value = [], $.value = [];
405
- }
406
- function H(l, e) {
407
- switch (l) {
408
- case oe.Timestamp:
409
- return e === Re.DateTime || e === Re.TimeOfDay ? Te.Between : Te.Equal;
410
- case oe.Bool:
411
- case oe.String:
412
- case oe.Numeric:
413
- return Te.Equal;
414
- default:
415
- throw new Error(`Unsupported data type: ${l}`);
416
- }
417
- }
418
- function A() {
419
- if (!k.value) {
420
- g.open({ message: u("report.section.filter.invalidSchema"), type: "error" });
421
- return;
422
- }
423
- if (!y.value) {
424
- g.open({ message: u("report.section.filter.invalidDimension"), type: "error" });
425
- return;
426
- }
427
- const l = G.value.filter((p) => p ? !he.value.some((I) => I.value.name === p.schemaName) : !0);
428
- if (l.length > 0) {
429
- const p = l.filter((I) => !!I).map((I) => I.schemaName), C = l.some((I) => !I) ? `, ${u("report.section.filter.unknownFilters")}` : "";
430
- g.open({
431
- message: u("report.section.filter.invalidFiltersSchemaNotFound", {
432
- schemas: p.join(", "),
433
- unknownFiltersSuffix: C
434
- }),
435
- type: "error"
436
- });
437
- return;
438
- }
439
- if (!Oe())
440
- return;
441
- const e = D.value && !ee.value ? T.value.map((p) => ({
442
- label: p.label.trim(),
443
- operator: p.operator ?? le(),
444
- values: pe(
445
- [...p.values],
446
- re(p.operator)
447
- )
448
- })) : void 0, s = D.value && ee.value ? $.value.map((p) => ({
449
- name: p.name.trim(),
450
- startTime: p.startTime,
451
- endTime: p.endTime
452
- })) : void 0;
453
- c.value = {
454
- schemaName: k.value.name,
455
- name: y.value.name,
456
- label: Y.value,
457
- operator: H(
458
- y.value.type,
459
- y.value.type === oe.Timestamp ? x.value ?? Re.DateTime : null
460
- ),
461
- option: y.value.type === oe.Timestamp ? x.value : null,
462
- values: [],
463
- tileIds: [...O.value],
464
- filters: ae(G.value),
465
- customOptions: e,
466
- customTimeRanges: s
467
- }, v.value = !1;
468
- }
469
- function W() {
470
- v.value = !1;
471
- }
472
- const se = f(() => {
473
- var l;
474
- return [
475
- (l = k.value) == null ? void 0 : l.name,
476
- ...G.value.map((e) => e.schemaName)
477
- ];
478
- });
479
- function de(l) {
480
- var V;
481
- const e = B.tiles.find((b) => b.id === l.value);
482
- if (!e || !k.value || !y.value) return null;
483
- const s = (V = e == null ? void 0 : e.widget) == null ? void 0 : V.config, p = (s == null ? void 0 : s.schemaNames) ?? [], C = ((s == null ? void 0 : s.joinDatasources) ?? []).flatMap(
484
- (b) => b.schemaNames ?? []
485
- ), I = [...p, ...C], j = se.value.filter((b) => !!b).some((b) => !I.includes(b)), Z = y.value.type === oe.Timestamp;
486
- if (j)
487
- return u(
488
- Z ? "report.section.filter.missingFilterSchema" : "report.section.filter.missingFilterSchemaOrDimension"
489
- );
490
- if (Z) return null;
491
- const ce = ((s == null ? void 0 : s.dimensions) ?? []).map((b) => ({
492
- schemaName: b.schemaName,
493
- name: b.name
494
- })), we = ((s == null ? void 0 : s.joinDatasources) ?? []).flatMap(
495
- (b) => (b.dimensions ?? []).map((me) => ({
496
- schemaName: me.schemaName,
497
- name: me.name
498
- }))
499
- ), Ne = [...ce, ...we], Pe = k.value.name, r = y.value.name;
500
- return Ne.some(
501
- (b) => b.schemaName === Pe && b.name === r
502
- ) ? null : u("report.section.filter.missingFilterSchemaOrDimension");
503
- }
504
- return (l, e) => {
505
- const s = F("FmTextField"), p = F("FmSelect"), C = F("FmCheckbox"), I = F("FmTimePicker"), j = F("FmButton"), Z = F("FmLabel"), ce = F("FmIcon"), we = F("FmTooltip"), Ne = F("FmForm"), Pe = F("FmDialog");
506
- return d(), S(Pe, {
507
- modelValue: v.value,
508
- "onUpdate:modelValue": e[9] || (e[9] = (r) => v.value = r),
509
- overlay: !0,
510
- "z-index": 10
511
- }, {
512
- "dialog-header": _(() => [
513
- ze(E(o(u)("report.section.filter.globalFilter")), 1)
514
- ]),
515
- default: _(() => [
516
- i(Ne, {
517
- ref: "form",
518
- class: "flex flex-col gap-2 w-[490px]"
519
- }, {
520
- default: _(() => {
521
- var r;
522
- return [
523
- i(s, {
524
- modelValue: Y.value,
525
- "onUpdate:modelValue": e[0] || (e[0] = (t) => Y.value = t),
526
- placeholder: o(u)("report.section.filter.displayName"),
527
- label: o(u)("report.section.filter.displayName"),
528
- class: "mb-2"
529
- }, null, 8, ["modelValue", "placeholder", "label"]),
530
- i(Xe, {
531
- "model-value": k.value,
532
- items: he.value,
533
- placeholder: o(u)("report.section.schema.title"),
534
- label: o(u)("report.section.schema.title"),
535
- "onUpdate:modelValue": e[1] || (e[1] = (t) => P(t))
536
- }, null, 8, ["model-value", "items", "placeholder", "label"]),
537
- i(Xe, {
538
- "model-value": y.value,
539
- items: _e.value,
540
- placeholder: o(u)("report.section.dimension.title"),
541
- label: o(u)("report.section.dimension.title"),
542
- "onUpdate:modelValue": e[2] || (e[2] = (t) => te(t))
543
- }, null, 8, ["model-value", "items", "placeholder", "label"]),
544
- ((r = y.value) == null ? void 0 : r.type) === o(oe).Timestamp ? (d(), S(p, {
545
- key: 0,
546
- modelValue: x.value,
547
- "onUpdate:modelValue": e[3] || (e[3] = (t) => x.value = t),
548
- items: Ee.value,
549
- placeholder: o(u)("report.section.filter.timeFormatter"),
550
- label: o(u)("report.section.filter.timeFormatter")
551
- }, null, 8, ["modelValue", "items", "placeholder", "label"])) : U("", !0),
552
- w.value ? (d(), S(C, {
553
- key: 1,
554
- modelValue: D.value,
555
- "onUpdate:modelValue": e[4] || (e[4] = (t) => D.value = t),
556
- label: o(u)("report.section.filter.customOptions"),
557
- value: !0
558
- }, null, 8, ["modelValue", "label"])) : U("", !0),
559
- w.value && D.value ? (d(), R("div", ll, [
560
- ee.value ? (d(!0), R(Fe, { key: 0 }, Be($.value, (t, V) => (d(), R("div", {
561
- key: `custom-time-range-${V}`,
562
- class: "flex flex-col gap-2"
563
- }, [
564
- h("div", ol, [
565
- i(s, {
566
- modelValue: t.name,
567
- "onUpdate:modelValue": (b) => t.name = b,
568
- label: o(u)("report.section.filter.label")
569
- }, null, 8, ["modelValue", "onUpdate:modelValue", "label"]),
570
- i(I, {
571
- "model-value": ue(t.startTime),
572
- label: o(u)("report.date.startingTime"),
573
- "onUpdate:modelValue": (b) => ge(V, "startTime", b)
574
- }, null, 8, ["model-value", "label", "onUpdate:modelValue"]),
575
- i(I, {
576
- "model-value": ue(t.endTime),
577
- label: o(u)("report.date.endingTime"),
578
- "onUpdate:modelValue": (b) => ge(V, "endTime", b)
579
- }, null, 8, ["model-value", "label", "onUpdate:modelValue"]),
580
- $.value.length > 1 ? (d(), R("div", al, [
581
- i(j, {
582
- icon: "delete",
583
- variant: "tertiary",
584
- onClick: (b) => ie(V)
585
- }, null, 8, ["onClick"])
586
- ])) : U("", !0)
587
- ])
588
- ]))), 128)) : (d(), R(Fe, { key: 1 }, [
589
- h("p", nl, E(o(u)("report.section.filter.operator")), 1),
590
- ne.value.length > 0 ? (d(), S(Xe, {
591
- key: 0,
592
- "model-value": X.value,
593
- items: ne.value,
594
- placeholder: o(u)("report.section.filter.operator"),
595
- "onUpdate:modelValue": e[5] || (e[5] = (t) => fe(t))
596
- }, null, 8, ["model-value", "items", "placeholder"])) : U("", !0),
597
- (d(!0), R(Fe, null, Be(T.value, (t, V) => (d(), R("div", {
598
- key: `custom-option-${V}`,
599
- class: "flex flex-col gap-2"
600
- }, [
601
- h("div", {
602
- class: Ue(["grid grid-cols-1 gap-2 p-2 sm:items-end text-fm-color-typo-primary fm-typo-en-body-lg-600 border-neutral-300 rounded-md border", "sm:grid-cols-[1fr_1.6fr_auto]"])
603
- }, [
604
- h("span", rl, E(o(u)("report.section.filter.label")), 1),
605
- i(s, {
606
- modelValue: t.label,
607
- "onUpdate:modelValue": (b) => t.label = b
608
- }, null, 8, ["modelValue", "onUpdate:modelValue"]),
609
- (d(), S(Dt, {
610
- key: `custom-option-value-${V}-${t.operator ?? ""}-${x.value ?? ""}`,
611
- modelValue: t.values,
612
- "onUpdate:modelValue": (b) => t.values = b,
613
- config: re(t.operator),
614
- option: x.value
615
- }, null, 8, ["modelValue", "onUpdate:modelValue", "config", "option"])),
616
- T.value.length > 1 ? (d(), R("div", il, [
617
- i(j, {
618
- icon: "delete",
619
- variant: "tertiary",
620
- onClick: (b) => Q(V)
621
- }, null, 8, ["onClick"])
622
- ])) : U("", !0)
623
- ])
624
- ]))), 128))
625
- ], 64)),
626
- i(j, {
627
- class: "w-full",
628
- variant: "primary",
629
- icon: "add",
630
- "icon-position": "prepend",
631
- onClick: e[6] || (e[6] = (t) => ee.value ? ke() : ye())
632
- })
633
- ])) : U("", !0),
634
- i(Ot, {
635
- modelValue: G.value,
636
- "onUpdate:modelValue": e[7] || (e[7] = (t) => G.value = t),
637
- options: m.value
638
- }, null, 8, ["modelValue", "options"]),
639
- i(Z, { class: "mt-2 fm-typo-en-body-lg-600" }, {
640
- default: _(() => [
641
- ze(E(o(u)("report.section.filter.applyWidget")), 1)
642
- ]),
643
- _: 1
644
- }),
645
- M.tiles.length > 0 ? (d(), R("div", sl, [
646
- (d(!0), R(Fe, null, Be(n.value, (t) => (d(), R("div", {
647
- key: t.value,
648
- class: "flex items-center"
649
- }, [
650
- i(C, {
651
- modelValue: O.value,
652
- "onUpdate:modelValue": e[8] || (e[8] = (V) => O.value = V),
653
- label: t.label,
654
- value: t.value
655
- }, null, 8, ["modelValue", "label", "value"]),
656
- de(t) ? (d(), S(we, {
657
- key: 0,
658
- content: de(t) ?? void 0,
659
- "z-index": 99,
660
- class: "ml-2"
661
- }, {
662
- default: _(() => [
663
- i(ce, {
664
- name: "warning",
665
- class: "text-fm-color-system-error-300"
666
- })
667
- ]),
668
- _: 2
669
- }, 1032, ["content"])) : U("", !0)
670
- ]))), 128))
671
- ])) : (d(), S(Z, {
672
- key: 4,
673
- class: "fm-typo-en-body-lg-400",
674
- label: o(u)("report.section.filter.noWidget")
675
- }, null, 8, ["label"]))
676
- ];
677
- }),
678
- _: 1
679
- }, 512)
680
- ]),
681
- "dialog-footer": _(() => [
682
- e[10] || (e[10] = h("div", { class: "grow" }, null, -1)),
683
- i(j, {
684
- label: o(u)("report.common.cancel"),
685
- variant: "tertiary",
686
- onClick: W
687
- }, null, 8, ["label"]),
688
- i(j, {
689
- label: o(u)("report.common.confirm"),
690
- onClick: A
691
- }, null, 8, ["label"])
692
- ]),
693
- _: 1
694
- }, 8, ["modelValue"]);
695
- };
696
- }
697
- }), dl = 8.4375, ml = 1024 ** 4, cl = {
698
- MY: { rate: 4, currency: "MYR", symbol: "RM" },
699
- TH: { rate: 33, currency: "THB", symbol: "฿" },
700
- SG: { rate: 1.29, currency: "SGD", symbol: "S$" },
701
- ID: { rate: 17900, currency: "IDR", symbol: "Rp" }
702
- }, pl = { rate: 1, currency: "USD", symbol: "$" };
703
- function ut(M, u) {
704
- const a = M / ml * dl, { rate: c, currency: v, symbol: g } = cl[u] ?? pl;
705
- return {
706
- amount: a * c,
707
- currency: v,
708
- symbol: g,
709
- costUsd: a
710
- };
711
- }
712
- function dt(M, u) {
713
- return M < 0.01 ? `< ${u}0.01` : `${u}${M.toFixed(2)}`;
714
- }
715
- const vl = { class: "flex flex-col gap-16" }, fl = {
716
- key: 0,
717
- class: "flex flex-col gap-8"
718
- }, gl = { class: "flex items-center gap-4 pb-8 border-b border-neutral-300" }, bl = ["title"], yl = {
719
- key: 1,
720
- class: "rounded-md border border-dashed border-neutral-300 p-12 text-center fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
721
- }, hl = ["onClick"], _l = ["title"], wl = {
722
- key: 0,
723
- class: "text-fm-color-typo-secondary"
724
- }, Fl = { class: "text-fm-color-system-error-300" }, xl = { class: "w-full text-left" }, Cl = /* @__PURE__ */ xe({
725
- __name: "TileDrillPanel",
726
- props: {
727
- report: {}
728
- },
729
- emits: ["add-widget"],
730
- setup(M, { emit: u }) {
731
- const a = M, c = u, { t: v, te: g } = qe(), B = ot(), Y = at(), { promptMessage: k } = nt(), y = lt(), x = f(() => {
732
- const n = [];
733
- let m = a.report.tiles;
734
- for (const P of Ie.value) {
735
- const te = m.find((H) => H.id === P);
736
- if (!te) break;
737
- n.push(te), m = te.tiles ?? [];
738
- }
739
- return n;
740
- });
741
- be(x, (n) => {
742
- n.length !== Ie.value.length && (Ie.value = n.map((m) => m.id));
743
- });
744
- const O = f(() => x.value[x.value.length - 1] ?? null), G = f(() => x.value[x.value.length - 2] ?? null), D = f(
745
- () => O.value ? O.value.tiles ?? [] : a.report.tiles
746
- ), T = f(() => {
747
- var n;
748
- return ((n = O.value) == null ? void 0 : n.id) ?? null;
749
- }), $ = f(() => x.value.length === 0), X = f(() => {
750
- var n;
751
- return ((n = O.value) == null ? void 0 : n.tab) === !0;
752
- }), ae = f(() => {
753
- var n;
754
- return ((n = G.value) == null ? void 0 : n.tab) === !0;
755
- }), Ce = f(
756
- () => x.value.reduce((n, m) => m.tab ? n : n + 1, 1)
757
- ), ue = f(() => !X.value && Ce.value < bt), J = f(() => $.value);
758
- function w(n) {
759
- n.widget || (Ie.value = [...Ie.value, n.id]);
760
- }
761
- function ee() {
762
- Ie.value = Ie.value.slice(0, -1);
763
- }
764
- function ne(n) {
765
- if (!n) return "";
766
- const m = `report.widget.types.${n.toLowerCase()}`;
767
- return g(m) ? v(m) : Le(v, g, n, "other");
768
- }
769
- function le(n, m) {
770
- return n.widget ? n.widget.title ? ne(n.widget.title) : v("report.editor.widget", { index: m + 1 }) : n.tabTitle !== void 0 ? n.tabTitle || v("report.editor.tab", { index: m + 1 }) : n.tab ? v("report.editor.tabGroup") : v("report.editor.group");
771
- }
772
- function re(n, m) {
773
- return !n.widget && X.value ? n.tabTitle || v("report.editor.tab", { index: m + 1 }) : le(n, m);
774
- }
775
- function pe(n) {
776
- var m;
777
- return ((m = n.tiles) == null ? void 0 : m.length) ?? 0;
778
- }
779
- const ve = f(
780
- () => x.value.map((n, m) => le(n, m)).join(" › ")
781
- );
782
- function q(n, m) {
783
- gt.value = T.value, y.editingTileIndex = m, y.editingTile = JSON.parse(JSON.stringify(n)), B.push({ name: "tileEditor", query: Y.query });
784
- }
785
- function L(n, m) {
786
- D.value.splice(m + 1, 0, Mt(n));
787
- }
788
- async function K(n, m) {
789
- var H;
790
- if (!await k({
791
- title: v("report.editor.deleteWidget"),
792
- message: v("report.editor.deleteWidgetConfirm", { title: re(n, m) })
793
- })) return;
794
- const te = rt(n);
795
- D.value.splice(m, 1), (H = a.report.globalFilters) == null || H.forEach((A) => {
796
- var W;
797
- A.tileIds = (W = A.tileIds) == null ? void 0 : W.filter((se) => !te.includes(se));
798
- });
799
- }
800
- function fe() {
801
- O.value && (O.value.tiles || (O.value.tiles = []), O.value.tiles.push(Bt(O.value.tiles.length + 1)));
802
- }
803
- function ye() {
804
- D.value.push(Ut());
805
- }
806
- function Q() {
807
- D.value.push(qt());
808
- }
809
- function ke(n) {
810
- var P;
811
- const m = Number((P = n.size) == null ? void 0 : P.width);
812
- n.size || (n.size = { width: 12, height: 12 }), !Number.isFinite(m) || m < 1 ? n.size.width = 1 : m > 12 && (n.size.width = 12);
813
- }
814
- function ie(n) {
815
- var P;
816
- const m = Number((P = n.size) == null ? void 0 : P.height);
817
- n.size || (n.size = { width: 12, height: 12 }), !Number.isFinite(m) || m < 1 ? n.size.height = 1 : m > 12 && (n.size.height = 12);
818
- }
819
- const ge = z(!1), Ve = z(null), Oe = z([]);
820
- function he(n) {
821
- const m = [
822
- { parentId: null, label: v("report.editor.topLevel"), level: 1 }
823
- ], P = (H, A, W) => {
824
- let se = 0;
825
- H.forEach((de) => {
826
- var l;
827
- if (!de.widget)
828
- if (de.tab) {
829
- const e = `${W}${v("report.editor.tabGroup")}`;
830
- (l = de.tiles) == null || l.forEach((s, p) => {
831
- const C = `${e} › ${s.tabTitle || v("report.editor.tab", { index: p + 1 })}`;
832
- m.push({ parentId: s.id, label: C, level: A + 1 }), P(s.tiles ?? [], A + 1, `${C} › `);
833
- });
834
- } else {
835
- se += 1;
836
- const e = `${W}${v("report.editor.group")} ${se}`;
837
- m.push({ parentId: de.id, label: e, level: A + 1 }), P(de.tiles ?? [], A + 1, `${e} › `);
838
- }
839
- });
840
- };
841
- P(a.report.tiles, 1, "");
842
- const te = new Set(rt(n));
843
- return m.filter(
844
- (H) => H.parentId !== T.value && !(H.parentId && te.has(H.parentId)) && Pt(n, H.level)
845
- );
846
- }
847
- function _e(n) {
848
- Ve.value = n, Oe.value = he(n), ge.value = !0;
849
- }
850
- function Ee(n) {
851
- const m = Ve.value;
852
- if (!m) return;
853
- const P = D.value.indexOf(m);
854
- P >= 0 && D.value.splice(P, 1), Et(a.report.tiles, n.parentId).push(m), ge.value = !1, Ve.value = null;
855
- }
856
- return (n, m) => {
857
- const P = F("FmButton"), te = F("FmTextField"), H = F("FmIcon"), A = F("FmMenuItem"), W = F("FmMenu"), se = F("FmList"), de = F("FmListItem"), l = F("FmDialog");
858
- return d(), R("div", vl, [
859
- $.value ? U("", !0) : (d(), R("div", fl, [
860
- h("div", gl, [
861
- i(P, {
862
- icon: "arrow_back",
863
- variant: "tertiary",
864
- class: "-ml-8",
865
- onClick: ee
866
- }),
867
- h("p", {
868
- class: "fm-typo-en-body-md-600 line-clamp-1 overflow-hidden break-all min-w-0 grow text-left",
869
- title: ve.value
870
- }, E(ve.value), 9, bl)
871
- ]),
872
- ae.value && O.value ? (d(), S(te, {
873
- key: 0,
874
- modelValue: O.value.tabTitle,
875
- "onUpdate:modelValue": m[0] || (m[0] = (e) => O.value.tabTitle = e),
876
- label: o(v)("report.editor.tabName"),
877
- placeholder: o(v)("report.editor.tabName")
878
- }, null, 8, ["modelValue", "label", "placeholder"])) : U("", !0),
879
- !ae.value && O.value ? (d(), S(te, {
880
- key: 1,
881
- modelValue: O.value.size.width,
882
- "onUpdate:modelValue": m[1] || (m[1] = (e) => O.value.size.width = e),
883
- modelModifiers: { number: !0 },
884
- type: "number",
885
- label: o(v)("report.editor.width"),
886
- onBlur: m[2] || (m[2] = (e) => ke(O.value))
887
- }, null, 8, ["modelValue", "label"])) : U("", !0),
888
- !ae.value && O.value ? (d(), S(te, {
889
- key: 2,
890
- modelValue: O.value.size.height,
891
- "onUpdate:modelValue": m[3] || (m[3] = (e) => O.value.size.height = e),
892
- modelModifiers: { number: !0 },
893
- type: "number",
894
- label: o(v)("report.editor.height"),
895
- onBlur: m[4] || (m[4] = (e) => ie(O.value))
896
- }, null, 8, ["modelValue", "label"])) : U("", !0)
897
- ])),
898
- D.value.length === 0 ? (d(), R("div", yl, E(o(v)("report.editor.emptyLevel")), 1)) : (d(), S(se, { key: 2 }, {
899
- default: _(() => [
900
- i(o(ft), {
901
- list: D.value,
902
- "item-key": "id",
903
- class: "flex flex-col gap-2 cursor-grab",
904
- handle: ".handle"
905
- }, {
906
- item: _(({ element: e, index: s }) => [
907
- h("div", {
908
- class: Ue(["flex items-center gap-8 px-12 py-8 border rounded-md border-neutral-300 hover:bg-fm-color-opacity-sm", e.widget ? "cursor-grab" : "cursor-pointer"]),
909
- onClick: (p) => w(e)
910
- }, [
911
- i(H, {
912
- name: "drag_handle",
913
- class: "handle shrink-0 !cursor-grab"
914
- }),
915
- h("p", {
916
- class: "flex-1 min-w-0 truncate text-left fm-typo-en-body-lg-400",
917
- title: re(e, s)
918
- }, [
919
- ze(E(re(e, s)) + " ", 1),
920
- e.widget ? U("", !0) : (d(), R("span", wl, " · " + E(pe(e)), 1))
921
- ], 8, _l),
922
- e.widget ? U("", !0) : (d(), S(H, {
923
- key: 0,
924
- name: "chevron_right",
925
- class: "shrink-0"
926
- })),
927
- i(W, {
928
- trigger: "click",
929
- shift: !0,
930
- "stop-click-propagation": !0,
931
- class: "shrink-0"
932
- }, {
933
- "menu-button": _(() => [
934
- i(P, {
935
- "append-icon": "more_vert",
936
- variant: "tertiary"
937
- })
938
- ]),
939
- default: _(() => [
940
- e.widget ? (d(), S(A, {
941
- key: 0,
942
- label: o(v)("report.common.edit"),
943
- onClick: (p) => q(e, s)
944
- }, null, 8, ["label", "onClick"])) : U("", !0),
945
- e.tab ? U("", !0) : (d(), S(A, {
946
- key: 1,
947
- label: o(v)("report.editor.moveTo"),
948
- onClick: (p) => _e(e)
949
- }, null, 8, ["label", "onClick"])),
950
- i(A, {
951
- label: o(v)("report.common.duplicate"),
952
- onClick: (p) => L(e, s)
953
- }, null, 8, ["label", "onClick"]),
954
- i(A, {
955
- onClick: (p) => K(e, s)
956
- }, {
957
- label: _(() => [
958
- h("p", Fl, E(o(v)("report.common.remove")), 1)
959
- ]),
960
- _: 2
961
- }, 1032, ["onClick"])
962
- ]),
963
- _: 2
964
- }, 1024)
965
- ], 10, hl)
966
- ]),
967
- _: 1
968
- }, 8, ["list"])
969
- ]),
970
- _: 1
971
- })),
972
- X.value ? (d(), S(P, {
973
- key: 3,
974
- label: o(v)("report.editor.addTab"),
975
- variant: "secondary",
976
- icon: "add",
977
- "icon-position": "prepend",
978
- "border-color": o($e).ColorPrimary,
979
- "text-color": o($e).ColorPrimary,
980
- onClick: fe
981
- }, null, 8, ["label", "border-color", "text-color"])) : (d(), S(W, {
982
- key: 4,
983
- trigger: "click",
984
- shift: !0
985
- }, {
986
- "menu-button": _(() => [
987
- i(P, {
988
- label: o(v)("report.common.add"),
989
- variant: "secondary",
990
- icon: "add",
991
- "icon-position": "prepend",
992
- class: "w-full",
993
- "border-color": o($e).ColorPrimary,
994
- "text-color": o($e).ColorPrimary
995
- }, null, 8, ["label", "border-color", "text-color"])
996
- ]),
997
- default: _(() => [
998
- i(A, {
999
- label: o(v)("report.editor.addWidget"),
1000
- onClick: m[5] || (m[5] = (e) => c("add-widget", T.value))
1001
- }, null, 8, ["label"]),
1002
- ue.value ? (d(), S(A, {
1003
- key: 0,
1004
- label: o(v)("report.editor.addGroup"),
1005
- onClick: ye
1006
- }, null, 8, ["label"])) : U("", !0),
1007
- J.value ? (d(), S(A, {
1008
- key: 1,
1009
- label: o(v)("report.editor.addTabGroup"),
1010
- onClick: Q
1011
- }, null, 8, ["label"])) : U("", !0)
1012
- ]),
1013
- _: 1
1014
- })),
1015
- i(l, {
1016
- modelValue: ge.value,
1017
- "onUpdate:modelValue": m[6] || (m[6] = (e) => ge.value = e),
1018
- overlay: !0,
1019
- "z-index": 10
1020
- }, {
1021
- "dialog-header": _(() => [
1022
- ze(E(o(v)("report.editor.moveTo")), 1)
1023
- ]),
1024
- default: _(() => [
1025
- i(se, null, {
1026
- default: _(() => [
1027
- (d(!0), R(Fe, null, Be(Oe.value, (e) => (d(), S(de, {
1028
- key: e.parentId ?? "root",
1029
- onClick: (s) => Ee(e)
1030
- }, {
1031
- default: _(() => [
1032
- h("p", xl, E(e.label), 1)
1033
- ]),
1034
- _: 2
1035
- }, 1032, ["onClick"]))), 128))
1036
- ]),
1037
- _: 1
1038
- })
1039
- ]),
1040
- _: 1
1041
- }, 8, ["modelValue"])
1042
- ]);
1043
- };
1044
- }
1045
- }), kl = { class: "flex flex-col gap-24 top-0 bg-fm-color-neutral-white z-10" }, Vl = { class: "flex flex-col gap-24 top-0 bg-fm-color-neutral-white z-10" }, Tl = { class: "flex items-center gap-8" }, $l = {
1046
- key: 2,
1047
- class: "flex flex-col gap-8 rounded-md border border-fm-color-border px-16 py-12"
1048
- }, Sl = { class: "fm-typo-en-body-sm-400" }, Dl = { class: "fm-typo-en-body-sm-400 font-bold" }, Ol = { class: "space-y-1 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Nl = { class: "flex flex-col gap-24 top-0 bg-fm-color-neutral-white z-10" }, Il = { class: "flex items-center gap-1 max-w-[195px] w-[195px]" }, Rl = { class: "line-clamp-2 overflow-hidden max-w-[195px] w-[195px]" }, mt = /* @__PURE__ */ xe({
1049
- __name: "ReportEditorTab",
1050
- props: /* @__PURE__ */ Se({
1051
- hideConfiguration: {
1052
- type: Boolean,
1053
- default: !1
1054
- }
1055
- }, {
1056
- modelValue: { required: !0 },
1057
- modelModifiers: {}
1058
- }),
1059
- emits: /* @__PURE__ */ Se(["hideConfiguration"], ["update:modelValue"]),
1060
- setup(M, { emit: u }) {
1061
- const a = De(M, "modelValue"), { breakpoints: c } = He(), v = M, g = u, B = ot(), Y = at(), k = z(), {
1062
- currentSelectWidgetType: y,
1063
- categories: x,
1064
- editingTile: O,
1065
- editingTileIndex: G,
1066
- editingGlobalFilter: D,
1067
- editingGlobalFilterIndex: T
1068
- } = Me(lt()), { schemas: $ } = Me(zt()), { globalFilters: X } = Me(it()), { getGlobalFilterLabel: ae } = it(), { promptMessage: Ce } = nt(), ue = z(!1), J = z(!1), { t: w, te: ee, locale: ne } = qe(), le = z(void 0), re = f(() => {
1069
- const r = Qe(a.value.tiles).flatMap((t) => {
1070
- var me;
1071
- const V = t.widget.config.schemaNames ?? [], b = ((me = t.widget.config.joinDatasources) == null ? void 0 : me.flatMap((Ge) => Ge.schemaNames ?? [])) ?? [];
1072
- return [...V, ...b];
1073
- });
1074
- return [...new Set(r)].reduce((t, V) => {
1075
- const b = $.value.find((me) => me.name === V);
1076
- return b && t.push(b), t;
1077
- }, []);
1078
- }), pe = z(null);
1079
- function ve(r) {
1080
- pe.value = r, J.value = !0;
1081
- }
1082
- be(
1083
- () => y.value,
1084
- () => {
1085
- y.value !== void 0 && (le.value = jt(y.value), O.value = le.value, G.value = -1, gt.value = pe.value, B.push({
1086
- name: "tileEditor",
1087
- query: Y.query
1088
- }));
1089
- },
1090
- { immediate: !0 }
1091
- ), be(
1092
- () => a.value.tiles,
1093
- (r) => {
1094
- Lt(r);
1095
- },
1096
- { immediate: !0, deep: !0 }
1097
- );
1098
- const q = [
1099
- {
1100
- label: "report.common.edit",
1101
- selected: !1,
1102
- variant: "tertiary",
1103
- onClick: (r) => {
1104
- var t;
1105
- T.value = r, D.value = JSON.parse(JSON.stringify((t = a.value.globalFilters) == null ? void 0 : t[r])), ue.value = !0;
1106
- }
1107
- },
1108
- {
1109
- label: "report.common.duplicate",
1110
- selected: !1,
1111
- variant: "tertiary",
1112
- onClick: (r) => {
1113
- var b;
1114
- const t = (b = a.value.globalFilters) == null ? void 0 : b[r];
1115
- if (!t) return;
1116
- const V = JSON.parse(JSON.stringify(t));
1117
- a.value.globalFilters || (a.value.globalFilters = []), a.value.globalFilters.push(V);
1118
- }
1119
- },
1120
- {
1121
- label: "report.common.remove",
1122
- selected: !1,
1123
- variant: "destructive",
1124
- onClick: async (r) => {
1125
- var b, me;
1126
- const t = (b = a.value.globalFilters) == null ? void 0 : b[r];
1127
- if (!t) return;
1128
- await Ce({
1129
- title: w("report.editor.deleteWidget"),
1130
- message: w("report.editor.deleteWidgetConfirm", {
1131
- title: ae(t)
1132
- })
1133
- }) && ((me = a.value.globalFilters) == null || me.splice(r, 1));
1134
- }
1135
- }
1136
- ], L = f(() => x.value.map((r) => ({
1137
- label: w(`report.category.${r.name}`),
1138
- value: r.id
1139
- }))), { sessionUser: K } = Jt(), fe = f(
1140
- () => {
1141
- var r, t, V, b;
1142
- return ((t = (r = K.value) == null ? void 0 : r.role) == null ? void 0 : t.isAdmin) === !0 || ((b = (V = K.value) == null ? void 0 : V.role) == null ? void 0 : b.isStaff) === !0;
1143
- }
1144
- ), ye = f({
1145
- get: () => a.value.queryVersion === "v2",
1146
- set: (r) => {
1147
- a.value.queryVersion = r ? "v2" : "v1", r ? a.value.queryDatasource = a.value.queryDatasource ?? We.Postgres : a.value.queryDatasource = void 0;
1148
- }
1149
- }), Q = [
1150
- { label: w("report.common.postgresql"), value: We.Postgres },
1151
- { label: w("report.common.bigquery"), value: We.BigQuery }
1152
- ], ke = [
1153
- { label: w("report.common.noBatch"), value: "none" },
1154
- { label: w("report.common.days"), value: "days" },
1155
- { label: w("report.common.locations"), value: "locations" }
1156
- ], ie = f({
1157
- get: () => {
1158
- var r, t;
1159
- return (r = a.value.batch) != null && r.days ? "days" : (t = a.value.batch) != null && t.locations ? "locations" : "none";
1160
- },
1161
- set: (r) => {
1162
- var t, V;
1163
- r === "none" ? a.value.batch = void 0 : r === "days" ? a.value.batch = { days: ((t = a.value.batch) == null ? void 0 : t.days) || 1 } : r === "locations" && (a.value.batch = { locations: ((V = a.value.batch) == null ? void 0 : V.locations) || 10 });
1164
- }
1165
- }), ge = f({
1166
- get: () => {
1167
- var r, t;
1168
- if (ie.value === "days") return ((r = a.value.batch) == null ? void 0 : r.days) ?? 1;
1169
- if (ie.value === "locations") return ((t = a.value.batch) == null ? void 0 : t.locations) ?? 1;
1170
- },
1171
- set: (r) => {
1172
- r && (ie.value === "days" ? a.value.batch = { days: r } : ie.value === "locations" && (a.value.batch = { locations: r }));
1173
- }
1174
- }), Ve = f({
1175
- get: () => Le(w, ee, a.value.name, "other"),
1176
- set: (r) => {
1177
- a.value.name = r;
1178
- }
1179
- }), { country: Oe } = Me(Kt()), {
1180
- dateRange: he,
1181
- compareDateRange: _e,
1182
- timeRange: Ee,
1183
- selectedLocationIds: n,
1184
- businessDataVersion: m,
1185
- restaurants: P,
1186
- warehouses: te
1187
- } = Me(Qt()), H = f(
1188
- () => a.value.queryVersion === "v2" && a.value.queryDatasource === We.BigQuery
1189
- ), A = f(() => H.value && fe.value), W = z(null), se = z(!1), de = f(() => {
1190
- const r = he.value.startDate ?? he.value.endDate;
1191
- return r ? {
1192
- startDate: r,
1193
- endDate: r
1194
- } : he.value;
1195
- }), l = f(() => {
1196
- const r = _e.value.startDate ?? _e.value.endDate;
1197
- return r ? {
1198
- startDate: r,
1199
- endDate: r
1200
- } : _e.value;
1201
- }), e = f(() => {
1202
- const r = a.value.batch;
1203
- if (!r) return 1;
1204
- if (r.locations) {
1205
- const t = P.value.length + te.value.length;
1206
- return Math.max(1, Math.ceil(t / r.locations));
1207
- }
1208
- return 1;
1209
- }), s = f(() => {
1210
- if (W.value == null || W.value === 0) return null;
1211
- const r = W.value * e.value;
1212
- return ut(r, Oe.value);
1213
- }), p = f(() => W.value == null || W.value === 0 ? null : ut(W.value, Oe.value)), C = f(() => s.value ? dt(s.value.amount, s.value.symbol) : ""), I = f(() => p.value ? dt(p.value.amount, p.value.symbol) : ""), j = f(() => e.value === 1 ? w("report.common.estimatedCostBatchSingular") : w("report.common.estimatedCostBatchPlural")), Z = f(() => se.value ? "..." : !C.value || !I.value ? "--" : w("report.common.estimatedCostFormula", {
1214
- batchCount: e.value,
1215
- batchLabel: j.value,
1216
- baseCost: I.value,
1217
- totalCost: C.value
1218
- }));
1219
- let ce = [];
1220
- const we = Yt(async () => {
1221
- if (!A.value) return;
1222
- const r = Qe(a.value.tiles).filter(
1223
- (t) => {
1224
- var V;
1225
- return ((V = t.widget.config.schemaNames) == null ? void 0 : V.length) > 0;
1226
- }
1227
- );
1228
- if (r.length === 0) {
1229
- W.value = null;
1230
- return;
1231
- }
1232
- se.value = !0, ce.forEach((t) => t.abort()), ce = [];
1233
- try {
1234
- const t = await Promise.all(
1235
- r.map((V) => {
1236
- const b = new AbortController();
1237
- return ce.push(b), Gt({
1238
- widget: V.widget,
1239
- signal: b.signal,
1240
- tileId: V.id,
1241
- scopedDateRange: de.value,
1242
- scopedCompareDateRange: l.value
1243
- });
1244
- })
1245
- );
1246
- W.value = t.reduce((V, b) => V + (b.totalBytesProcessed ?? 0), 0);
1247
- } catch (t) {
1248
- t.code !== "ERR_CANCELED" && (W.value = null);
1249
- } finally {
1250
- se.value = !1;
1251
- }
1252
- }, 1e3);
1253
- be(
1254
- [
1255
- () => a.value.tiles,
1256
- () => a.value.queryVersion,
1257
- () => a.value.queryDatasource,
1258
- () => a.value.batch,
1259
- () => he.value,
1260
- () => Ee.value,
1261
- () => _e.value,
1262
- () => n.value,
1263
- () => m.value
1264
- ],
1265
- () => {
1266
- we();
1267
- },
1268
- { deep: !0 }
1269
- ), pt(() => {
1270
- we();
1271
- }), Vt(() => {
1272
- ce.forEach((r) => r.abort());
1273
- });
1274
- function Ne(r) {
1275
- var t;
1276
- return !((t = r.tileIds) != null && t.length);
1277
- }
1278
- function Pe(r) {
1279
- return !re.value.find((t) => t.name === r.schemaName);
1280
- }
1281
- return be(
1282
- () => a.value.globalFilters,
1283
- (r) => {
1284
- X.value = JSON.parse(JSON.stringify(r || []));
1285
- },
1286
- { deep: !0, immediate: !0 }
1287
- ), (r, t) => {
1288
- const V = F("FmTextField"), b = F("FmSelect"), me = F("FmSwitch"), Ge = F("FmButton"), je = F("FmIcon"), Je = F("FmTooltip"), ht = F("FmMenuItem"), _t = F("FmMenu"), wt = F("FmListItem"), Ft = F("FmList"), xt = F("FmForm");
1289
- return d(), S(Tt(o(c).lg || o(c).md ? el : tl), {
1290
- "model-value": v.hideConfiguration,
1291
- "onUpdate:modelValue": t[12] || (t[12] = (N) => g("hideConfiguration", N))
1292
- }, {
1293
- default: _(() => [
1294
- i(ul, {
1295
- "is-open": ue.value,
1296
- "onUpdate:isOpen": t[0] || (t[0] = (N) => ue.value = N),
1297
- "global-filter": o(D),
1298
- tiles: o(Qe)(a.value.tiles),
1299
- schemas: re.value,
1300
- "onUpdate:globalFilter": t[1] || (t[1] = (N) => {
1301
- N && (a.value.globalFilters || (a.value.globalFilters = []), typeof o(T) == "number" && o(T) >= 0 ? a.value.globalFilters[o(T)] = N : a.value.globalFilters.push(N));
1302
- })
1303
- }, null, 8, ["is-open", "global-filter", "tiles", "schemas"]),
1304
- i(Xt, {
1305
- modelValue: o(y),
1306
- "onUpdate:modelValue": t[2] || (t[2] = (N) => vt(y) ? y.value = N : null),
1307
- "is-open": J.value,
1308
- "onUpdate:isOpen": t[3] || (t[3] = (N) => J.value = N)
1309
- }, null, 8, ["modelValue", "is-open"]),
1310
- i(xt, {
1311
- ref_key: "form",
1312
- ref: k,
1313
- class: "px-6 py-16 flex flex-col gap-24 overflow-y-auto overflow-x-hidden"
1314
- }, {
1315
- default: _(() => [
1316
- i(Ae, { class: "border-solid" }, {
1317
- header: _(() => [
1318
- h("p", null, E(o(w)("report.editor.reportInfo")), 1),
1319
- t[13] || (t[13] = h("div", { class: "grow" }, null, -1))
1320
- ]),
1321
- content: _(() => [
1322
- h("div", kl, [
1323
- i(V, {
1324
- modelValue: Ve.value,
1325
- "onUpdate:modelValue": t[4] || (t[4] = (N) => Ve.value = N),
1326
- label: o(w)("report.common.name"),
1327
- placeholder: o(w)("report.common.name")
1328
- }, null, 8, ["modelValue", "label", "placeholder"]),
1329
- (d(), S(b, {
1330
- key: `category-${o(ne)}`,
1331
- modelValue: a.value.category,
1332
- "onUpdate:modelValue": t[5] || (t[5] = (N) => a.value.category = N),
1333
- label: o(w)("report.common.category"),
1334
- items: L.value
1335
- }, null, 8, ["modelValue", "label", "items"])),
1336
- i(V, {
1337
- modelValue: a.value.description,
1338
- "onUpdate:modelValue": t[6] || (t[6] = (N) => a.value.description = N),
1339
- label: o(w)("report.common.description"),
1340
- placeholder: o(w)("report.common.description")
1341
- }, null, 8, ["modelValue", "label", "placeholder"])
1342
- ])
1343
- ]),
1344
- _: 1
1345
- }),
1346
- i(Ae, {
1347
- class: "border-solid",
1348
- "is-open": !1
1349
- }, {
1350
- header: _(() => [
1351
- h("p", null, E(o(w)("report.editor.advancedUsage")), 1),
1352
- t[14] || (t[14] = h("div", { class: "grow" }, null, -1))
1353
- ]),
1354
- content: _(() => [
1355
- h("div", Vl, [
1356
- h("div", Tl, [
1357
- t[15] || (t[15] = h("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, "V2", -1)),
1358
- i(me, {
1359
- modelValue: ye.value,
1360
- "onUpdate:modelValue": t[7] || (t[7] = (N) => ye.value = N)
1361
- }, null, 8, ["modelValue"])
1362
- ]),
1363
- ye.value && fe.value ? (d(), S(b, {
1364
- key: 0,
1365
- modelValue: a.value.queryDatasource,
1366
- "onUpdate:modelValue": t[8] || (t[8] = (N) => a.value.queryDatasource = N),
1367
- label: o(w)("report.common.queryDatasource"),
1368
- items: Q
1369
- }, null, 8, ["modelValue", "label"])) : U("", !0),
1370
- i(b, {
1371
- modelValue: ie.value,
1372
- "onUpdate:modelValue": t[9] || (t[9] = (N) => ie.value = N),
1373
- label: o(w)("report.common.batch"),
1374
- items: ke
1375
- }, null, 8, ["modelValue", "label"]),
1376
- ie.value !== "none" ? (d(), S(V, {
1377
- key: 1,
1378
- modelValue: ge.value,
1379
- "onUpdate:modelValue": t[10] || (t[10] = (N) => ge.value = N),
1380
- modelModifiers: { number: !0 },
1381
- label: ie.value === "days" ? o(w)("report.common.days") : o(w)("report.common.locations"),
1382
- type: "number"
1383
- }, null, 8, ["modelValue", "label"])) : U("", !0),
1384
- A.value ? (d(), R("div", $l, [
1385
- h("span", Sl, E(o(w)("report.common.estimatedBqCost")), 1),
1386
- h("p", Dl, E(Z.value), 1),
1387
- h("div", Ol, [
1388
- h("div", null, "* " + E(o(w)("report.common.estimatedCostGuidelineBigQuery")), 1),
1389
- h("div", null, "* " + E(o(w)("report.common.estimatedCostGuidelineDateRange")), 1),
1390
- h("div", null, "* " + E(o(w)("report.common.estimatedCostGuidelineLocationBatch")), 1)
1391
- ])
1392
- ])) : U("", !0)
1393
- ])
1394
- ]),
1395
- _: 1
1396
- }),
1397
- i(Ae, {
1398
- class: "border-solid",
1399
- "is-open": !1
1400
- }, {
1401
- header: _(() => [
1402
- h("p", null, E(o(w)("report.section.filter.globalFilter")), 1),
1403
- t[16] || (t[16] = h("div", { class: "grow" }, null, -1))
1404
- ]),
1405
- content: _(() => [
1406
- h("div", Nl, [
1407
- i(Ge, {
1408
- label: o(w)("report.section.filter.addGlobalFilter"),
1409
- variant: "secondary",
1410
- icon: "add",
1411
- "icon-position": "prepend",
1412
- "border-color": o($e).ColorPrimary,
1413
- "text-color": o($e).ColorPrimary,
1414
- onClick: t[11] || (t[11] = () => {
1415
- T.value = null, D.value = null, ue.value = !0;
1416
- })
1417
- }, null, 8, ["label", "border-color", "text-color"]),
1418
- i(Ft, null, {
1419
- default: _(() => [
1420
- i(o(ft), {
1421
- list: a.value.globalFilters,
1422
- "item-key": "`${element.schemaName}-${element.name}`",
1423
- class: "flex flex-col gap-2 cursor-grab",
1424
- handle: ".handle"
1425
- }, {
1426
- item: _(({ element: N, index: Ct }) => [
1427
- i(wt, { class: "!cursor-grab border rounded-md border-neutral-300" }, {
1428
- default: _(() => [
1429
- i(je, {
1430
- name: "drag_handle",
1431
- class: "handle"
1432
- }),
1433
- h("div", Il, [
1434
- i(Je, {
1435
- "z-index": 99,
1436
- content: o(ae)(N),
1437
- class: "handle"
1438
- }, {
1439
- default: _(() => [
1440
- h("p", Rl, E(o(ae)(N)), 1)
1441
- ]),
1442
- _: 2
1443
- }, 1032, ["content"]),
1444
- Pe(N) ? (d(), S(Je, {
1445
- key: 0,
1446
- content: o(w)("report.section.filter.missingSchema"),
1447
- "z-index": 99
1448
- }, {
1449
- default: _(() => [
1450
- i(je, {
1451
- name: "warning",
1452
- class: "text-fm-color-system-error-300"
1453
- })
1454
- ]),
1455
- _: 1
1456
- }, 8, ["content"])) : Ne(N) ? (d(), S(Je, {
1457
- key: 1,
1458
- content: o(w)("report.section.filter.missingTileIds"),
1459
- "z-index": 99
1460
- }, {
1461
- default: _(() => [
1462
- i(je, {
1463
- name: "warning",
1464
- class: "text-fm-color-system-warning-300"
1465
- })
1466
- ]),
1467
- _: 1
1468
- }, 8, ["content"])) : U("", !0)
1469
- ]),
1470
- t[17] || (t[17] = h("div", { class: "grow" }, null, -1)),
1471
- i(_t, {
1472
- trigger: "click",
1473
- shift: !0,
1474
- "stop-click-propagation": !0
1475
- }, {
1476
- "menu-button": _(() => [
1477
- i(Ge, {
1478
- "append-icon": "more_vert",
1479
- variant: "tertiary"
1480
- })
1481
- ]),
1482
- default: _(() => [
1483
- (d(), R(Fe, null, Be(q, (Ke, kt) => i(ht, {
1484
- key: kt,
1485
- onClick: (Ql) => Ke.onClick(Ct)
1486
- }, {
1487
- label: _(() => [
1488
- h("p", {
1489
- class: Ue(
1490
- Ke.variant === "destructive" ? " text-fm-color-system-error-300" : ""
1491
- )
1492
- }, E(o(w)(Ke.label)), 3)
1493
- ]),
1494
- _: 2
1495
- }, 1032, ["onClick"])), 64))
1496
- ]),
1497
- _: 2
1498
- }, 1024)
1499
- ]),
1500
- _: 2
1501
- }, 1024)
1502
- ]),
1503
- _: 1
1504
- }, 8, ["list"])
1505
- ]),
1506
- _: 1
1507
- })
1508
- ])
1509
- ]),
1510
- _: 1
1511
- }),
1512
- i(Ae, { class: "border-solid" }, {
1513
- header: _(() => [
1514
- h("p", null, E(o(w)("report.editor.widgets")), 1),
1515
- t[18] || (t[18] = h("div", { class: "grow" }, null, -1))
1516
- ]),
1517
- content: _(() => [
1518
- i(Cl, {
1519
- report: a.value,
1520
- onAddWidget: ve
1521
- }, null, 8, ["report"])
1522
- ]),
1523
- _: 1
1524
- })
1525
- ]),
1526
- _: 1
1527
- }, 512)
1528
- ]),
1529
- _: 1
1530
- }, 8, ["model-value"]);
1531
- };
1532
- }
1533
- }), Ml = { class: "h-full w-full overflow-x-hidden" }, Bl = { class: "flex flex-col bg-fm-color-neutral-white w-[400px]" }, Ul = { class: "flex bg-fm-color-neutral-white w-[88px]" }, ql = {
1534
- key: 1,
1535
- class: "w-full overflow-y-auto"
1536
- }, El = {
1537
- key: 0,
1538
- class: "w-full grid grid-cols-12 gap-[24px] p-24"
1539
- }, Pl = { class: "col-span-12 mb-4 flex flex-wrap gap-2 pb-2" }, zl = { key: 2 }, Ll = {
1540
- key: 0,
1541
- class: "grid grid-cols-12 gap-[16px]"
1542
- }, Gl = { class: "col-span-12 mb-4 flex flex-wrap gap-2 pb-2" }, Al = {
1543
- key: 3,
1544
- class: "h-full w-full flex items-start justify-center bg-fm-color-neutral-white py-24",
1545
- style: { backgroundColor: "#F6F8FC" }
1546
- }, Wl = {
1547
- key: 0,
1548
- class: "w-full grid grid-cols-12 gap-[24px] p-24"
1549
- }, Hl = /* @__PURE__ */ xe({
1550
- __name: "ReportEditorViewport",
1551
- props: /* @__PURE__ */ Se({
1552
- hideConfiguration: { type: Boolean, required: !1, default: !1 },
1553
- previewWidth: { type: Number, required: !0 },
1554
- previewHeight: { type: Number, required: !0 },
1555
- previewScale: { type: Number, required: !0 }
1556
- }, {
1557
- modelValue: { required: !0, default: () => {
1558
- } },
1559
- modelModifiers: {}
1560
- }),
1561
- emits: /* @__PURE__ */ Se(["hideConfiguration"], ["update:modelValue"]),
1562
- setup(M, { emit: u }) {
1563
- const { breakpoints: a } = He(), c = De(M, "modelValue"), v = f(() => {
1564
- var y;
1565
- return At((y = c.value) == null ? void 0 : y.tiles);
1566
- }), g = M, B = f(() => g.previewWidth > 0 && g.previewHeight > 0), Y = f(() => a.value.sm || a.value.xs), k = u;
1567
- return (y, x) => {
1568
- const O = F("FmCircularProgress"), G = F("FmButton"), D = F("FmMenuDivider"), T = F("FmCard");
1569
- return d(), R("div", Ml, [
1570
- c.value ? (d(), R(Fe, { key: 1 }, [
1571
- B.value ? U("", !0) : (d(), S(Nt, {
1572
- key: 0,
1573
- "model-value": !g.hideConfiguration
1574
- }, {
1575
- right: _(() => [
1576
- h("div", Bl, [
1577
- c.value ? (d(), S(mt, {
1578
- key: 0,
1579
- modelValue: c.value,
1580
- "onUpdate:modelValue": x[0] || (x[0] = ($) => c.value = $),
1581
- "hide-configuration": g.hideConfiguration,
1582
- onHideConfiguration: x[1] || (x[1] = ($) => k("hideConfiguration", $))
1583
- }, null, 8, ["modelValue", "hide-configuration"])) : U("", !0)
1584
- ])
1585
- ]),
1586
- left: _(() => [
1587
- h("div", Ul, [
1588
- i(G, {
1589
- variant: "secondary",
1590
- icon: "keyboard_double_arrow_right",
1591
- "border-color": o($e).ColorPrimary,
1592
- "text-color": o($e).ColorPrimary,
1593
- class: "m-24 my-16",
1594
- size: "md",
1595
- onClick: x[2] || (x[2] = ($) => k("hideConfiguration", !g.hideConfiguration))
1596
- }, null, 8, ["border-color", "text-color"])
1597
- ])
1598
- ]),
1599
- _: 1
1600
- }, 8, ["model-value"])),
1601
- i(D, {
1602
- vertical: "",
1603
- style: { margin: "0px" }
1604
- }),
1605
- !Y.value && !B.value ? (d(), R("div", ql, [
1606
- c.value.tiles.length > 0 ? (d(), R("div", El, [
1607
- h("div", Pl, [
1608
- i(st)
1609
- ]),
1610
- i(Ye, {
1611
- tiles: c.value.tiles,
1612
- "report-id": c.value.id || "editing",
1613
- "leaf-index-by-id": v.value,
1614
- "hide-export": !0
1615
- }, null, 8, ["tiles", "report-id", "leaf-index-by-id"])
1616
- ])) : (d(), S(Ze, { key: 1 }))
1617
- ])) : Y.value && !B.value ? (d(), R("div", zl, [
1618
- i(T, { class: "px-5 pb-28" }, {
1619
- default: _(() => [
1620
- c.value.tiles.length > 0 ? (d(), R("div", Ll, [
1621
- h("div", Gl, [
1622
- i(st)
1623
- ]),
1624
- i(Ye, {
1625
- tiles: c.value.tiles,
1626
- "report-id": c.value.id || "editing",
1627
- "leaf-index-by-id": v.value,
1628
- "hide-export": !0
1629
- }, null, 8, ["tiles", "report-id", "leaf-index-by-id"])
1630
- ])) : (d(), S(Ze, { key: 1 }))
1631
- ]),
1632
- _: 1
1633
- }),
1634
- c.value ? (d(), S(mt, {
1635
- key: 0,
1636
- modelValue: c.value,
1637
- "onUpdate:modelValue": x[3] || (x[3] = ($) => c.value = $),
1638
- "hide-configuration": g.hideConfiguration,
1639
- onHideConfiguration: x[4] || (x[4] = ($) => {
1640
- k("hideConfiguration", $);
1641
- })
1642
- }, null, 8, ["modelValue", "hide-configuration"])) : U("", !0)
1643
- ])) : (d(), R("div", Al, [
1644
- h("div", {
1645
- style: et({
1646
- transformOrigin: "top center",
1647
- transform: `scale(${g.previewScale})`
1648
- })
1649
- }, [
1650
- h("div", {
1651
- class: "overflow-y-auto bg-white rounded-lg",
1652
- style: et({
1653
- width: g.previewWidth + "px",
1654
- height: g.previewHeight + "px"
1655
- })
1656
- }, [
1657
- c.value.tiles.length > 0 ? (d(), R("div", Wl, [
1658
- i(Ye, {
1659
- tiles: c.value.tiles,
1660
- "report-id": c.value.id || "editing",
1661
- "leaf-index-by-id": v.value,
1662
- "hide-export": !0,
1663
- "custom-screen-width": g.previewWidth
1664
- }, null, 8, ["tiles", "report-id", "leaf-index-by-id", "custom-screen-width"])
1665
- ])) : (d(), S(Ze, { key: 1 }))
1666
- ], 4)
1667
- ], 4)
1668
- ]))
1669
- ], 64)) : (d(), S(O, { key: 0 }))
1670
- ]);
1671
- };
1672
- }
1673
- }), jl = { class: "flex items-center gap-4" }, Jl = { class: "flex justify-center items-center gap-2 w-full" }, Kl = { class: "flex gap-4" }, po = /* @__PURE__ */ xe({
1674
- __name: "ReportEditor",
1675
- setup(M) {
1676
- const u = ot(), a = at(), c = lt(), { promptLoader: v } = Ht(), { t: g, te: B } = qe(), { currentReport: Y, editingReport: k } = Me(c), { breakpoints: y } = He(), x = f(() => {
1677
- var q;
1678
- return !((q = k.value) != null && q.editable);
1679
- }), O = f(() => {
1680
- var q;
1681
- return ((q = k.value) == null ? void 0 : q.name) ?? g("report.editor.newReport");
1682
- }), G = f(() => Le(g, B, O.value, "other")), D = yt(), { promptMessage: T } = nt(), $ = z(!1), X = f(() => [
1683
- { label: g("report.common.cancel"), value: "cancel", isPrimary: !1 },
1684
- { label: g("report.common.save"), value: "save", isPrimary: !0, prependIcon: "download" }
1685
- ]);
1686
- async function ae() {
1687
- if (!k.value || k.value.tiles.length === 0) {
1688
- D.open({ message: g("report.messages.noWidget"), type: "error" });
1689
- return;
1690
- }
1691
- if (Wt(k.value.tiles) > bt) {
1692
- D.open({ message: g("report.messages.tooDeepNesting"), type: "error" });
1693
- return;
1694
- }
1695
- const q = x.value ? g("report.common.clone") : g("report.common.save");
1696
- if (await T({
1697
- title: `${g("report.messages.saveReport")}`,
1698
- message: g("report.messages.confirmAction", { action: q, name: G.value })
1699
- }))
1700
- try {
1701
- await v(async () => {
1702
- if (x.value) {
1703
- const K = JSON.parse(JSON.stringify(k.value));
1704
- K.editable = !0, K.id = "", K.name = `${K.name} ${g("report.common.duplicate")}`, K.isDefault = !1, await c.createOrUpdateReport(K);
1705
- } else
1706
- k.value && await c.createOrUpdateReport(k.value);
1707
- u.push({
1708
- name: "reportView",
1709
- query: a.query
1710
- });
1711
- });
1712
- } catch (K) {
1713
- console.log(K), D.open({
1714
- message: g("report.messages.failedToAction", { action: q }),
1715
- type: "error"
1716
- });
1717
- }
1718
- }
1719
- async function Ce() {
1720
- var L;
1721
- if (!k.value) return;
1722
- await T({
1723
- title: g("report.common.report", 1),
1724
- message: g("report.editor.notSaved", { name: (L = k.value) == null ? void 0 : L.name })
1725
- }) && (k.value = JSON.parse(JSON.stringify(Y.value)), u.back());
1726
- }
1727
- pt(() => {
1728
- k.value || u.push({ name: "reports" });
1729
- });
1730
- const ue = [
1731
- {
1732
- labelKey: "report.common.default",
1733
- width: void 0,
1734
- height: void 0
1735
- },
1736
- {
1737
- labelKey: "report.editor.devices.desktop",
1738
- width: 1920,
1739
- height: 1080
1740
- },
1741
- {
1742
- labelKey: "report.editor.devices.tablet",
1743
- width: 820,
1744
- height: 1180
1745
- },
1746
- {
1747
- labelKey: "report.editor.devices.phone",
1748
- width: 390,
1749
- height: 859
1750
- }
1751
- ], J = z(ue[0]), w = z(!1), ee = f(() => w.value ? Math.max(J.value.width || 0, J.value.height || 0) : Math.min(J.value.width || 0, J.value.height || 0)), ne = f(() => w.value ? Math.min(J.value.width || 0, J.value.height || 0) : Math.max(J.value.width || 0, J.value.height || 0)), le = f(() => window.innerHeight - 72 - 56), re = f(() => {
1752
- if (!ee.value) return 1;
1753
- let q = (le.value - 48) / ee.value, L = ne.value * q;
1754
- return L > window.innerWidth && (q = window.innerWidth / ne.value, L = ne.value * q), q > 1 ? 1 : q;
1755
- });
1756
- function pe(q) {
1757
- J.value = q;
1758
- }
1759
- function ve() {
1760
- w.value = !w.value;
1761
- }
1762
- return (q, L) => {
1763
- const K = F("FmTooltip"), fe = F("FmButton"), ye = F("FmPageHead");
1764
- return d(), S(It, null, {
1765
- default: _(() => [
1766
- i(ye, {
1767
- "data-editor-header": "true",
1768
- actions: X.value,
1769
- "onClick:action": L[0] || (L[0] = (Q) => {
1770
- Q === "cancel" && Ce(), Q === "save" && ae();
1771
- })
1772
- }, {
1773
- title: _(() => [
1774
- h("div", jl, [
1775
- i(K, {
1776
- content: G.value,
1777
- placement: "bottom"
1778
- }, {
1779
- default: _(() => [
1780
- h("p", {
1781
- class: Ue(`${o(y).sm || o(y).xs ? "hidden" : ""} text-ellipsis overflow-hidden text-nowrap fm-typo-en-title-md-600 w-[250px]`)
1782
- }, E(G.value), 3)
1783
- ]),
1784
- _: 1
1785
- }, 8, ["content"]),
1786
- h("div", Jl, [
1787
- h("div", Kl, [
1788
- (d(), R(Fe, null, Be(ue, (Q) => {
1789
- var ke;
1790
- return i(fe, {
1791
- key: Q.labelKey,
1792
- label: o(g)(Q.labelKey),
1793
- variant: ((ke = J.value) == null ? void 0 : ke.labelKey) === Q.labelKey ? "primary" : "secondary",
1794
- size: "md",
1795
- onClick: (ie) => pe(Q)
1796
- }, null, 8, ["label", "variant", "onClick"]);
1797
- }), 64))
1798
- ]),
1799
- i(fe, {
1800
- icon: "screen_rotation",
1801
- variant: "tertiary",
1802
- size: "md",
1803
- class: "text-fm-color-typo-primary",
1804
- onClick: ve
1805
- })
1806
- ])
1807
- ])
1808
- ]),
1809
- _: 1
1810
- }, 8, ["actions"]),
1811
- o(k) ? (d(), S(Hl, {
1812
- key: 0,
1813
- modelValue: o(k),
1814
- "onUpdate:modelValue": L[1] || (L[1] = (Q) => vt(k) ? k.value = Q : null),
1815
- style: et({ height: le.value + "px" }),
1816
- class: Ue(o(y).lg || o(y).md ? "flex" : ""),
1817
- "hide-configuration": $.value,
1818
- "preview-width": ne.value,
1819
- "preview-height": ee.value,
1820
- "preview-scale": re.value,
1821
- onHideConfiguration: L[2] || (L[2] = (Q) => $.value = Q)
1822
- }, null, 8, ["modelValue", "style", "class", "hide-configuration", "preview-width", "preview-height", "preview-scale"])) : U("", !0)
1823
- ]),
1824
- _: 1
1825
- });
1826
- };
1827
- }
1828
- });
1829
- export {
1830
- po as default
1831
- };