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