@feedmepos/mf-report 5.27.13 → 5.27.14-beta.0

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