@feedmepos/mf-menu 0.32.56 → 0.32.57-dev.2
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.
- package/dist/{App-BUePFRjb.js → App-CE5s0l9A.js} +5 -5
- package/dist/{ApplyProduct.vue_vue_type_script_setup_true_lang-oPq3AcV2.js → ApplyProduct.vue_vue_type_script_setup_true_lang-DZ5sZWpU.js} +3 -3
- package/dist/{ApplyProductDialog.vue_vue_type_script_setup_true_lang-r2W9cuVe.js → ApplyProductDialog.vue_vue_type_script_setup_true_lang-B0POr6JV.js} +2 -2
- package/dist/{Catalog-uo0vO8uy.js → Catalog-CY6RvjyS.js} +6 -6
- package/dist/{Category-CHN6aSPS.js → Category-BoVnd_-a.js} +10 -10
- package/dist/{Category-BvetZzck.js → Category-DIpJlX_N.js} +13 -13
- package/dist/{CookingGuide-DU8D0T0w.js → CookingGuide-CHzasZA9.js} +4 -4
- package/dist/{CustomAttributeChip.vue_vue_type_script_setup_true_lang-DIxKLpe8.js → CustomAttributeChip.vue_vue_type_script_setup_true_lang-DIhsGYRl.js} +1 -1
- package/dist/{Group-Cd1OoALN.js → Group-CwBojMky.js} +1 -1
- package/dist/{Group-BFGFyGhC.js → Group-SUmVQxSU.js} +3 -3
- package/dist/{Group.vue_vue_type_script_setup_true_lang-Dyb9On55.js → Group.vue_vue_type_script_setup_true_lang-BBqXiV3r.js} +57 -58
- package/dist/{GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-XcNt0ZBv.js → GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-CcQdvzMy.js} +5 -5
- package/dist/{ImportProductDialog.vue_vue_type_script_setup_true_lang-Dw3IXPUL.js → ImportProductDialog.vue_vue_type_script_setup_true_lang-C8VMeXoW.js} +193 -190
- package/dist/{Ingredient-CXU04qIu.js → Ingredient-DmsJNTi3.js} +3 -3
- package/dist/{InventoryBinding.vue_vue_type_script_setup_true_lang-q9DVgfMD.js → InventoryBinding.vue_vue_type_script_setup_true_lang-CZ3Ti5o-.js} +2 -2
- package/dist/{LinkProductSideSheet-CaFKMMSd.js → LinkProductSideSheet-D8Dvdhk0.js} +3 -3
- package/dist/{MenuSetting-EeJdFNfx.js → MenuSetting-CmFx4CKw.js} +6 -6
- package/dist/{OrderPacing-Db4P-2ea.js → OrderPacing-CFuteZjm.js} +5 -5
- package/dist/{PrintRoute-CSScKjFa.js → PrintRoute-CeHNsLcv.js} +4 -4
- package/dist/{Product-tvbYvK5u.js → Product-bJfbi1yz.js} +1 -1
- package/dist/{Product.vue_vue_type_script_setup_true_lang-BQ_PgMDP.js → Product.vue_vue_type_script_setup_true_lang-kvqrUjei.js} +66 -66
- package/dist/{ProductInternalTools-D2rmgEby.js → ProductInternalTools-BkKbXFdG.js} +16 -16
- package/dist/{Products-WPvLY_wr.js → Products-Bv9gINb8.js} +24 -24
- package/dist/{Publish-BJ9rz75C.js → Publish-CSMkGRiV.js} +3 -3
- package/dist/{Recipe-BMRTd58L.js → Recipe-CDK1f07t.js} +4 -4
- package/dist/{RestaurantAttributesSelector.vue_vue_type_script_setup_true_lang-BefgcG34.js → RestaurantAttributesSelector.vue_vue_type_script_setup_true_lang-hYs_2e94.js} +1 -1
- package/dist/{RuleView.vue_vue_type_script_setup_true_lang-DlzIboPc.js → RuleView.vue_vue_type_script_setup_true_lang-DdSe-i8f.js} +187 -187
- package/dist/{Scheduler-CHQ5YcBq.js → Scheduler-Ce6qK5xo.js} +3 -3
- package/dist/{ServingSequence-BtXSEzfn.js → ServingSequence-BSX_g50j.js} +3 -3
- package/dist/{Setting-BnXj1uTa.js → Setting-BNS9ggtX.js} +5 -5
- package/dist/{Subcategory-miGPIoku.js → Subcategory-62g1JEwl.js} +5 -5
- package/dist/{Takeaway-DtVvfRQy.js → Takeaway-DR0Ax44B.js} +1 -1
- package/dist/{Takeaway-zaChLDgt.js → Takeaway-f4VO0ZJ-.js} +4 -4
- package/dist/{Takeaway.vue_vue_type_script_setup_true_lang-BFnbiGsG.js → Takeaway.vue_vue_type_script_setup_true_lang-B3UE1p7X.js} +5 -5
- package/dist/{Thumbnail.vue_vue_type_script_setup_true_lang-CNYxe969.js → Thumbnail.vue_vue_type_script_setup_true_lang-CTw2lKns.js} +4 -4
- package/dist/{TranslationFieldSection.vue_vue_type_script_setup_true_lang-D4fWF46n.js → TranslationFieldSection.vue_vue_type_script_setup_true_lang-hd6JGri0.js} +1 -1
- package/dist/{TranslationSideSheet.vue_vue_type_script_setup_true_lang-DLqeQRkH.js → TranslationSideSheet.vue_vue_type_script_setup_true_lang-BRXHWG5s.js} +2 -2
- package/dist/TreeEditorOpenner.vue_vue_type_script_setup_true_lang-ClDRf-88.js +5986 -0
- package/dist/{Unit-BaLVANd9.js → Unit-DnrLxe1V.js} +2 -2
- package/dist/{Variant-Bnb4SllS.js → Variant-DM2r3Of9.js} +3 -3
- package/dist/{_id_-btH88hnV.js → _id_-BhFeSJIu.js} +9 -9
- package/dist/{app-D1a9CqKF.js → app-CO3nuOc3.js} +1 -1
- package/dist/{app-BO16t-ps.js → app-DH7q5VuL.js} +32 -32
- package/dist/app.js +1 -1
- package/dist/apps/mf-menu/src/helper/import-export-utils.d.ts +2 -0
- package/dist/apps/mf-menu/src/manager/menu/circularLink.d.ts +3 -0
- package/dist/apps/mf-menu/src/manager/menu/item.d.ts +1 -2
- package/dist/apps/mf-menu/tsconfig.app.tsbuildinfo +1 -1
- package/dist/assets/{linked-status-zxrRiX3x.js → linked-status-BR-paOgW.js} +2 -2
- package/dist/assets/{menu-export-DXB8Py6r.js → menu-export-Dwpl4c_S.js} +4 -4
- package/dist/assets/{override-menu-CEIJGR_x.js → override-menu-BS1DhRTo.js} +2 -2
- package/dist/assets/{validate-menu-DN3P-OR7.js → validate-menu-B-YCNUDR.js} +2 -2
- package/dist/{catalog-COu1SO_p.js → catalog-DN1unMjl.js} +1 -1
- package/dist/{catalogSetting-D34fLwdB.js → catalogSetting-CI8dXYw5.js} +1 -1
- package/dist/{currency-DlfcFoj5.js → currency-BFqLFFOP.js} +1 -1
- package/dist/{dayjs.min-xM9KAjrx.js → dayjs.min-BXDB3ec6.js} +2 -2
- package/dist/{index-B5d_uvVc.js → index-CCKQLhW1.js} +4 -4
- package/dist/{index-ByEp1JD0.js → index-CYexEfd8.js} +5 -5
- package/dist/{index.vue_vue_type_script_setup_true_lang-DAJSG8i1.js → index.vue_vue_type_script_setup_true_lang-BbQF5cdO.js} +5 -5
- package/dist/{item-CtfWra_w.js → item-eua4dBDT.js} +516 -488
- package/dist/{jszip.min-CNLaYb3p.js → jszip.min-C10zcIsO.js} +3 -3
- package/dist/{memberPricing-DSqwOAgM.js → memberPricing-BlITNLhE.js} +1 -1
- package/dist/{menu-DUsES-YM.js → menu-C4vsCvFL.js} +1 -1
- package/dist/menuV2-DB-VttRA.js +1023 -0
- package/dist/{order_pacing-B5a8Fch-.js → order_pacing-CDQ6wUL_.js} +5 -5
- package/dist/{priceTier-bxvu4c84.js → priceTier-pJMZysfK.js} +1 -1
- package/dist/{rules-CTd3QZhN.js → rules-BScEYhiY.js} +3 -3
- package/dist/{scheduler-DIl9SPsA.js → scheduler-BTiyl-EY.js} +4 -4
- package/dist/{toExcel-CUAEPhEv.js → toExcel-CSdnEWqk.js} +2 -2
- package/dist/{unit-DThoovpF.js → unit-BcPS3VM3.js} +2 -2
- package/package.json +1 -1
- package/dist/TreeEditorOpenner.vue_vue_type_script_setup_true_lang-DUxEgL0r.js +0 -5974
- package/dist/menuV2-BaY8Z_1c.js +0 -1055
|
@@ -0,0 +1,1023 @@
|
|
|
1
|
+
var We = Object.defineProperty;
|
|
2
|
+
var ze = (e, t, n) => t in e ? We(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var ne = (e, t, n) => ze(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { I as ae, G as I, A as T, U as ue, ax as re, J as q, H as ie, aj as x, c as z, a0 as V, au as oe, ay as Le, az as Be, z as qe, am as He, aA as Ge, aB as Je, ah as Ye } from "./index.vue_vue_type_script_setup_true_lang-BbQF5cdO.js";
|
|
5
|
+
import { defineStore as Qe } from "pinia";
|
|
6
|
+
import { shallowRef as j, ref as H, computed as S, shallowReactive as Xe, effectScope as Ze, watch as et } from "vue";
|
|
7
|
+
import { useCoreStore as se } from "@feedmepos/mf-common";
|
|
8
|
+
import { useSnackbar as tt } from "@feedmepos/ui-library";
|
|
9
|
+
const nt = "/assets/linked-status-BR-paOgW.js", rt = "/assets/override-menu-BS1DhRTo.js";
|
|
10
|
+
function ot(e) {
|
|
11
|
+
var s;
|
|
12
|
+
const t = I(e), n = (s = t.variant) == null ? void 0 : s.variantCombinations;
|
|
13
|
+
return delete t.variant, delete t.thumbnail, [t, ...n || []];
|
|
14
|
+
}
|
|
15
|
+
function st(e, t, n, s) {
|
|
16
|
+
const o = I(t), u = n ? o.modules.catalog.find((f) => f._id === n) : null, l = s ? o.modules.scheduler.find((f) => f._id === s) : null, a = u ? I(u) : void 0, d = n ? o.modules.catalog.filter((f) => f._id !== n) : [], c = l ? I(l) : void 0, g = e.reduce((f, v) => (f[v._id] = ot(v), f), {});
|
|
17
|
+
function y(f = []) {
|
|
18
|
+
const v = e.map((h) => h._id);
|
|
19
|
+
return [
|
|
20
|
+
...f.filter((h) => !v.includes(h._id)),
|
|
21
|
+
...Object.values(g).flatMap((h) => h)
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
return a && s ? (a.override.scheduler = {
|
|
25
|
+
...a.override.scheduler,
|
|
26
|
+
[s]: {
|
|
27
|
+
...a.override.scheduler[s],
|
|
28
|
+
_id: s,
|
|
29
|
+
items: y(c == null ? void 0 : c.items).map((f) => ({
|
|
30
|
+
...f,
|
|
31
|
+
orderFrom: ue.enum.ALL
|
|
32
|
+
}))
|
|
33
|
+
}
|
|
34
|
+
}, o.modules.catalog = [...d, a], o) : a ? (a.override.items = {
|
|
35
|
+
...a.override.items,
|
|
36
|
+
...g
|
|
37
|
+
}, o.modules.catalog = [...d, a], o) : c ? (c.items = y(c.items), o.modules.scheduler = [
|
|
38
|
+
...o.modules.scheduler.filter((f) => f._id !== s),
|
|
39
|
+
c
|
|
40
|
+
], o) : {
|
|
41
|
+
...re(),
|
|
42
|
+
modules: {
|
|
43
|
+
...re().modules,
|
|
44
|
+
catalog: o.modules.catalog,
|
|
45
|
+
item: o.modules.item,
|
|
46
|
+
group: o.modules.group,
|
|
47
|
+
scheduler: o.modules.scheduler
|
|
48
|
+
},
|
|
49
|
+
_id: o._id
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function F(e, t, n) {
|
|
53
|
+
var u;
|
|
54
|
+
if (n >= 3) return e;
|
|
55
|
+
const s = t.modules.item.find((l) => l._id === e._id);
|
|
56
|
+
if (!s)
|
|
57
|
+
throw new Error(`_insertItemOverriders - Item not found - ${e._id}`);
|
|
58
|
+
const o = (u = s.groups) == null ? void 0 : u.map((l) => {
|
|
59
|
+
var c, g, y;
|
|
60
|
+
const a = (c = e == null ? void 0 : e.groups) == null ? void 0 : c.find((f) => f._id === l._id);
|
|
61
|
+
let d;
|
|
62
|
+
return a ? d = ((g = l.items) == null ? void 0 : g.map((f) => {
|
|
63
|
+
var h;
|
|
64
|
+
const v = (h = a.items) == null ? void 0 : h.find(
|
|
65
|
+
(b) => b._id === f._id && b.combinationKey === f.combinationKey
|
|
66
|
+
);
|
|
67
|
+
return F(v || f, t, n + 1);
|
|
68
|
+
})) ?? [] : d = ((y = l.items) == null ? void 0 : y.map((f) => F(f, t, n + 1))) ?? [], {
|
|
69
|
+
...l,
|
|
70
|
+
items: d
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
return {
|
|
74
|
+
_id: s._id,
|
|
75
|
+
name: e.name || s.name,
|
|
76
|
+
code: e.code || s.code,
|
|
77
|
+
combinationKey: e.combinationKey,
|
|
78
|
+
groups: o
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function at(e, t) {
|
|
82
|
+
const n = e.groups.map((u) => {
|
|
83
|
+
const l = t.modules.group.find((d) => d._id === u._id), a = ((l == null ? void 0 : l.items) || []).map((d) => {
|
|
84
|
+
var y;
|
|
85
|
+
const c = (y = u.items) == null ? void 0 : y.find(
|
|
86
|
+
(f) => f._id === d._id && f.combinationKey === d.combinationKey
|
|
87
|
+
);
|
|
88
|
+
if (c)
|
|
89
|
+
return F(c, t, 1);
|
|
90
|
+
const g = {
|
|
91
|
+
...T.generator.initMenuV4ItemOverrider(),
|
|
92
|
+
_id: d._id,
|
|
93
|
+
combinationKey: d.combinationKey
|
|
94
|
+
};
|
|
95
|
+
return F(g, t, 1);
|
|
96
|
+
});
|
|
97
|
+
return { ...u, items: a };
|
|
98
|
+
}), s = e.variant ? e.variant.variantCombinations.map((u) => F(u, t, 1)) : [], o = {
|
|
99
|
+
...T.generator.initMenuV4ItemOverrider(),
|
|
100
|
+
_id: e._id,
|
|
101
|
+
name: e.name,
|
|
102
|
+
code: e.code,
|
|
103
|
+
groups: n
|
|
104
|
+
};
|
|
105
|
+
return [...s, o];
|
|
106
|
+
}
|
|
107
|
+
function G(e, t) {
|
|
108
|
+
var s;
|
|
109
|
+
if (!t)
|
|
110
|
+
return e;
|
|
111
|
+
const n = { ...e, code: t.code };
|
|
112
|
+
return n.groups = (s = n.groups) == null ? void 0 : s.map((o) => {
|
|
113
|
+
var l, a;
|
|
114
|
+
const u = (l = t.groups) == null ? void 0 : l.find((d) => d._id === o._id);
|
|
115
|
+
return o.items = (a = o.items) == null ? void 0 : a.map((d) => {
|
|
116
|
+
var g;
|
|
117
|
+
const c = (g = u == null ? void 0 : u.items) == null ? void 0 : g.find(
|
|
118
|
+
(y) => y._id === d._id && y.combinationKey === d.combinationKey
|
|
119
|
+
);
|
|
120
|
+
return G(d, c);
|
|
121
|
+
}), o;
|
|
122
|
+
}), n;
|
|
123
|
+
}
|
|
124
|
+
function ut(e, t) {
|
|
125
|
+
const n = e.items[t._id];
|
|
126
|
+
t.variant && (t.variant = {
|
|
127
|
+
...t.variant,
|
|
128
|
+
variantCombinations: t.variant.variantCombinations.map((o) => {
|
|
129
|
+
const u = n.find(
|
|
130
|
+
(l) => l._id === o._id && l.combinationKey === o.combinationKey
|
|
131
|
+
);
|
|
132
|
+
if (!u)
|
|
133
|
+
throw new Error(`Item overrider not found - ${o._id} - ${o.combinationKey}`);
|
|
134
|
+
return G(u, o);
|
|
135
|
+
})
|
|
136
|
+
});
|
|
137
|
+
const s = n.find((o) => !o.combinationKey);
|
|
138
|
+
if (!s)
|
|
139
|
+
throw new Error(`Base item overrider not found - ${t._id}`);
|
|
140
|
+
return t.groups = (s.groups || []).map((o) => {
|
|
141
|
+
var l;
|
|
142
|
+
const u = t.groups.find((a) => a._id === o._id);
|
|
143
|
+
return o.items = (l = o.items) == null ? void 0 : l.map((a) => {
|
|
144
|
+
var c;
|
|
145
|
+
const d = (c = u == null ? void 0 : u.items) == null ? void 0 : c.find(
|
|
146
|
+
(g) => g._id === a._id && g.combinationKey === a.combinationKey
|
|
147
|
+
);
|
|
148
|
+
return G(a, d);
|
|
149
|
+
}), o;
|
|
150
|
+
}), {
|
|
151
|
+
...t,
|
|
152
|
+
price: (s == null ? void 0 : s.price) || t.price
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
async function Dt(e, t, n, s, o, u = !0) {
|
|
156
|
+
const l = I(n), a = u ? st(t, l, s, o) : l, d = t.reduce((y, f) => (y[f._id] = a.modules.item.find((v) => v._id === f._id), y), {}), c = t.reduce((y, f) => {
|
|
157
|
+
const v = f._id;
|
|
158
|
+
return y[v] = at(d[v], e), y;
|
|
159
|
+
}, {}), g = T.getFallbackPrices({
|
|
160
|
+
rawMenu: a,
|
|
161
|
+
items: c,
|
|
162
|
+
catalogId: s || void 0,
|
|
163
|
+
schedulerId: o
|
|
164
|
+
});
|
|
165
|
+
return t.map((y) => {
|
|
166
|
+
const f = y._id, v = d[f];
|
|
167
|
+
return {
|
|
168
|
+
...ut(g, v),
|
|
169
|
+
category: s || o ? v == null ? void 0 : v.category : null
|
|
170
|
+
};
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
function Vt(e, t) {
|
|
174
|
+
if (e.length === 0) return "";
|
|
175
|
+
const n = e == null ? void 0 : e.split("variant");
|
|
176
|
+
return ((n == null ? void 0 : n.reduce((o, u) => {
|
|
177
|
+
if (u && u.length > 0) {
|
|
178
|
+
const l = `variant${u.split("/")[0]}`, a = u.split("/")[1], c = t.find(
|
|
179
|
+
({ _id: g }) => g === l
|
|
180
|
+
).options.find(({ _id: g }) => g === a);
|
|
181
|
+
o.push(((c == null ? void 0 : c.name) || "").trim());
|
|
182
|
+
}
|
|
183
|
+
return o;
|
|
184
|
+
}, [])) || []).join(" / ");
|
|
185
|
+
}
|
|
186
|
+
const L = /* @__PURE__ */ new Map();
|
|
187
|
+
async function Tt(e, t) {
|
|
188
|
+
const n = `${e._id}-${e.updatedAt}-${t}`;
|
|
189
|
+
if (L.has(n))
|
|
190
|
+
return L.get(n);
|
|
191
|
+
const s = await ae(
|
|
192
|
+
nt,
|
|
193
|
+
JSON.stringify({
|
|
194
|
+
menu: e,
|
|
195
|
+
itemId: t
|
|
196
|
+
})
|
|
197
|
+
);
|
|
198
|
+
return L.set(n, s), s;
|
|
199
|
+
}
|
|
200
|
+
async function ce(e, t, n) {
|
|
201
|
+
return await ae(rt, {
|
|
202
|
+
menu: e,
|
|
203
|
+
catalogId: t,
|
|
204
|
+
schedulerId: n
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
const B = /* @__PURE__ */ new Map();
|
|
208
|
+
async function it(e, t, n) {
|
|
209
|
+
const s = `${e._id}-${e.updatedAt}-${t || "null"}-${n || "null"}`;
|
|
210
|
+
if (B.has(s))
|
|
211
|
+
return B.get(s);
|
|
212
|
+
const o = await ce(e, t, n);
|
|
213
|
+
return B.set(s, o), o;
|
|
214
|
+
}
|
|
215
|
+
async function Kt(e, t, n) {
|
|
216
|
+
var l, a;
|
|
217
|
+
const s = await it(e, t, null), o = [], u = (d, c) => {
|
|
218
|
+
const g = I(d);
|
|
219
|
+
for (const y in c)
|
|
220
|
+
c[y] && (g[y] = c[y]);
|
|
221
|
+
return g;
|
|
222
|
+
};
|
|
223
|
+
for (const d of s.modules.group) {
|
|
224
|
+
const c = (l = d.items) == null ? void 0 : l.find((y) => y._id === n && !y.combinationKey), g = e.modules.item.find((y) => y._id === n);
|
|
225
|
+
if (c) {
|
|
226
|
+
const y = (a = d.items) == null ? void 0 : a.filter((v) => v._id === n && v.combinationKey), f = [c, ...y].map((v) => {
|
|
227
|
+
var w, C;
|
|
228
|
+
const h = v.combinationKey ? (C = (w = g == null ? void 0 : g.variant) == null ? void 0 : w.variantCombinations) == null ? void 0 : C.find(
|
|
229
|
+
(E) => E.combinationKey === v.combinationKey
|
|
230
|
+
) : g, b = h && g ? u(g, h) : v;
|
|
231
|
+
return u(b, v);
|
|
232
|
+
});
|
|
233
|
+
o.push({
|
|
234
|
+
group: d,
|
|
235
|
+
items: f
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return o;
|
|
240
|
+
}
|
|
241
|
+
const M = 0, K = 3;
|
|
242
|
+
function ct(e) {
|
|
243
|
+
const t = /^\/(.*)\/([gimyu]*)$/.exec(e.toString());
|
|
244
|
+
if (!t)
|
|
245
|
+
throw new Error("Invalid RegExp");
|
|
246
|
+
return new RegExp(t[1] ?? "", t[2]);
|
|
247
|
+
}
|
|
248
|
+
function O(e) {
|
|
249
|
+
if (typeof e != "object")
|
|
250
|
+
return e;
|
|
251
|
+
if (e === null)
|
|
252
|
+
return null;
|
|
253
|
+
if (Array.isArray(e))
|
|
254
|
+
return e.map(O);
|
|
255
|
+
if (e instanceof Date)
|
|
256
|
+
return new Date(e.getTime());
|
|
257
|
+
if (e instanceof RegExp)
|
|
258
|
+
return ct(e);
|
|
259
|
+
const t = {};
|
|
260
|
+
for (const n in e)
|
|
261
|
+
Object.prototype.hasOwnProperty.call(e, n) && (t[n] = O(e[n]));
|
|
262
|
+
return t;
|
|
263
|
+
}
|
|
264
|
+
function $(e) {
|
|
265
|
+
return e instanceof RegExp ? e.toString() : e;
|
|
266
|
+
}
|
|
267
|
+
function k(e) {
|
|
268
|
+
return typeof e == "object" && e !== null && !Array.isArray(e) && !(e instanceof Date) && !(e instanceof RegExp);
|
|
269
|
+
}
|
|
270
|
+
function P(e, t) {
|
|
271
|
+
if (e === t) return !0;
|
|
272
|
+
if (typeof e != typeof t) return !1;
|
|
273
|
+
if (e instanceof Date && t instanceof Date)
|
|
274
|
+
return e.getTime() === t.getTime();
|
|
275
|
+
if (e instanceof RegExp && t instanceof RegExp)
|
|
276
|
+
return e.toString() === t.toString();
|
|
277
|
+
if (Array.isArray(e) && Array.isArray(t)) {
|
|
278
|
+
if (e.length !== t.length) return !1;
|
|
279
|
+
for (let n = 0; n < e.length; n++)
|
|
280
|
+
if (!P(e[n], t[n])) return !1;
|
|
281
|
+
return !0;
|
|
282
|
+
}
|
|
283
|
+
if (k(e) && k(t)) {
|
|
284
|
+
const n = Object.keys(e), s = Object.keys(t);
|
|
285
|
+
if (n.length !== s.length) return !1;
|
|
286
|
+
for (const o of n)
|
|
287
|
+
if (!Object.prototype.hasOwnProperty.call(t, o) || !P(e[o], t[o])) return !1;
|
|
288
|
+
return !0;
|
|
289
|
+
}
|
|
290
|
+
return !1;
|
|
291
|
+
}
|
|
292
|
+
function lt(e, t, n) {
|
|
293
|
+
const s = e.length, o = t.length, u = /* @__PURE__ */ new Map();
|
|
294
|
+
for (let d = 0; d < o; d++) {
|
|
295
|
+
const c = n ? n(t[d]) : JSON.stringify(t[d]);
|
|
296
|
+
u.has(c) || u.set(c, []), u.get(c).push(d);
|
|
297
|
+
}
|
|
298
|
+
const l = [], a = /* @__PURE__ */ new Set();
|
|
299
|
+
for (let d = 0; d < s; d++) {
|
|
300
|
+
const c = e[d], g = n ? n(c) : JSON.stringify(c), y = u.get(g);
|
|
301
|
+
if (y) {
|
|
302
|
+
for (const f of y)
|
|
303
|
+
if (!a.has(f) && P(c, t[f])) {
|
|
304
|
+
l.push({ leftIndex: d, rightIndex: f }), a.add(f);
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return l;
|
|
310
|
+
}
|
|
311
|
+
function dt(e, t, n) {
|
|
312
|
+
var f, v;
|
|
313
|
+
if (P(e, t)) return;
|
|
314
|
+
const s = { _t: "a" }, o = ((f = n == null ? void 0 : n.arrays) == null ? void 0 : f.detectMove) !== !1, u = ((v = n == null ? void 0 : n.arrays) == null ? void 0 : v.includeValueOnMove) === !0, l = n == null ? void 0 : n.objectHash;
|
|
315
|
+
let a = o ? lt(e, t, l) : [];
|
|
316
|
+
if (!l && e.length === t.length && e.length > 0 && a.length < e.length) {
|
|
317
|
+
const h = k(e[0]) || Array.isArray(e[0]), b = a.length > 0;
|
|
318
|
+
if (h || b) {
|
|
319
|
+
a = [];
|
|
320
|
+
for (let w = 0; w < e.length; w++)
|
|
321
|
+
a.push({ leftIndex: w, rightIndex: w });
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
new Set(a.map((h) => h.leftIndex));
|
|
325
|
+
const d = new Set(a.map((h) => h.rightIndex)), c = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map();
|
|
326
|
+
for (const h of a)
|
|
327
|
+
c.set(h.leftIndex, h.rightIndex), g.set(h.rightIndex, h.leftIndex);
|
|
328
|
+
for (let h = 0; h < e.length; h++) {
|
|
329
|
+
const b = c.get(h);
|
|
330
|
+
if (b !== void 0) {
|
|
331
|
+
const w = J(e[h], t[b], n);
|
|
332
|
+
if (w !== void 0 && (s[b] = w), o && b !== h) {
|
|
333
|
+
const C = `_${h}`, E = u ? [e[h], b, K] : ["", b, K];
|
|
334
|
+
s[C] = E;
|
|
335
|
+
}
|
|
336
|
+
} else {
|
|
337
|
+
const w = `_${h}`;
|
|
338
|
+
s[w] = [e[h], M, M];
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
for (let h = 0; h < t.length; h++)
|
|
342
|
+
d.has(h) || (s[h] = [t[h]]);
|
|
343
|
+
const y = Object.keys(s);
|
|
344
|
+
if (!(y.length === 1 && y[0] === "_t"))
|
|
345
|
+
return s;
|
|
346
|
+
}
|
|
347
|
+
function mt(e, t, n) {
|
|
348
|
+
if (P(e, t)) return;
|
|
349
|
+
const s = {}, o = Object.keys(e), u = Object.keys(t), l = /* @__PURE__ */ new Set([...o, ...u]);
|
|
350
|
+
for (const a of l) {
|
|
351
|
+
if (n != null && n.propertyFilter && !n.propertyFilter(a, { left: e, right: t }))
|
|
352
|
+
continue;
|
|
353
|
+
const d = Object.prototype.hasOwnProperty.call(e, a), c = Object.prototype.hasOwnProperty.call(t, a);
|
|
354
|
+
if (d && c) {
|
|
355
|
+
const g = J(e[a], t[a], n);
|
|
356
|
+
g !== void 0 && (s[a] = g);
|
|
357
|
+
} else if (d && !c) {
|
|
358
|
+
const g = n != null && n.omitRemovedValues ? 0 : e[a];
|
|
359
|
+
s[a] = [g, M, M];
|
|
360
|
+
} else !d && c && (s[a] = [t[a]]);
|
|
361
|
+
}
|
|
362
|
+
return Object.keys(s).length > 0 ? s : void 0;
|
|
363
|
+
}
|
|
364
|
+
function J(e, t, n) {
|
|
365
|
+
if (P(e, t)) return;
|
|
366
|
+
if (e === void 0 && t !== void 0) {
|
|
367
|
+
const a = n != null && n.cloneDiffValues ? O(t) : t;
|
|
368
|
+
return [$(a)];
|
|
369
|
+
}
|
|
370
|
+
if (typeof e !== typeof t || e instanceof Date != t instanceof Date || e instanceof RegExp != t instanceof RegExp || Array.isArray(e) !== Array.isArray(t)) {
|
|
371
|
+
const a = n != null && n.cloneDiffValues ? O(e) : e, d = n != null && n.cloneDiffValues ? O(t) : t;
|
|
372
|
+
return [$(a), $(d)];
|
|
373
|
+
}
|
|
374
|
+
if (Array.isArray(e) && Array.isArray(t))
|
|
375
|
+
return dt(e, t, n);
|
|
376
|
+
if (k(e) && k(t))
|
|
377
|
+
return mt(e, t, n);
|
|
378
|
+
const u = n != null && n.cloneDiffValues ? O(e) : e, l = n != null && n.cloneDiffValues ? O(t) : t;
|
|
379
|
+
return [$(u), $(l)];
|
|
380
|
+
}
|
|
381
|
+
function ft(e, t, n) {
|
|
382
|
+
return J(e, t, n);
|
|
383
|
+
}
|
|
384
|
+
function vt(e, t, n) {
|
|
385
|
+
const s = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Map();
|
|
386
|
+
for (const a in t) {
|
|
387
|
+
if (a === "_t" || !a.startsWith("_")) continue;
|
|
388
|
+
const d = parseInt(a.slice(1)), c = t[a];
|
|
389
|
+
Array.isArray(c) && (c.length === 3 && c[2] === M ? s.add(d) : c.length === 3 && c[2] === K && o.set(d, c[1]));
|
|
390
|
+
}
|
|
391
|
+
const u = [];
|
|
392
|
+
let l = 0;
|
|
393
|
+
for (let a = 0; ; a++) {
|
|
394
|
+
const d = a.toString(), c = t[d];
|
|
395
|
+
if (c !== void 0)
|
|
396
|
+
if (Array.isArray(c) && c.length === 1)
|
|
397
|
+
u.push(c[0]);
|
|
398
|
+
else {
|
|
399
|
+
for (; l < e.length && s.has(l); )
|
|
400
|
+
l++;
|
|
401
|
+
l < e.length && (u.push(Y(e[l], c)), l++);
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
404
|
+
let g = !1;
|
|
405
|
+
for (const [y, f] of o.entries())
|
|
406
|
+
if (f === a) {
|
|
407
|
+
u.push(e[y]), g = !0;
|
|
408
|
+
break;
|
|
409
|
+
}
|
|
410
|
+
if (!g) {
|
|
411
|
+
for (; l < e.length && (s.has(l) || o.has(l)); )
|
|
412
|
+
l++;
|
|
413
|
+
if (l < e.length)
|
|
414
|
+
u.push(e[l]), l++;
|
|
415
|
+
else
|
|
416
|
+
break;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
return u;
|
|
421
|
+
}
|
|
422
|
+
function yt(e, t, n) {
|
|
423
|
+
const s = { ...e };
|
|
424
|
+
for (const o in t) {
|
|
425
|
+
const u = t[o];
|
|
426
|
+
Array.isArray(u) ? u.length === 1 ? s[o] = u[0] : u.length === 3 && u[2] === M ? delete s[o] : u.length === 2 && (s[o] = u[1]) : s[o] = Y(s[o], u);
|
|
427
|
+
}
|
|
428
|
+
return s;
|
|
429
|
+
}
|
|
430
|
+
function Y(e, t, n) {
|
|
431
|
+
if (t === void 0) return e;
|
|
432
|
+
if (Array.isArray(t)) {
|
|
433
|
+
if (t.length === 1)
|
|
434
|
+
return t[0];
|
|
435
|
+
if (t.length === 2)
|
|
436
|
+
return t[1];
|
|
437
|
+
if (t.length === 3 && t[2] === M)
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
return k(t) && t._t === "a" ? vt(e, t) : k(t) && k(e) ? yt(e, t) : e;
|
|
441
|
+
}
|
|
442
|
+
function le(e, t, n) {
|
|
443
|
+
return Y(e, t);
|
|
444
|
+
}
|
|
445
|
+
function gt(e) {
|
|
446
|
+
const t = { _t: "a" };
|
|
447
|
+
for (const n in e)
|
|
448
|
+
if (n !== "_t")
|
|
449
|
+
if (n.startsWith("_")) {
|
|
450
|
+
const s = parseInt(n.slice(1)), o = e[n];
|
|
451
|
+
if (Array.isArray(o)) {
|
|
452
|
+
if (o.length === 3 && o[2] === M)
|
|
453
|
+
t[s] = [o[0]];
|
|
454
|
+
else if (o.length === 3 && o[2] === K) {
|
|
455
|
+
const u = o[1];
|
|
456
|
+
t[`_${u}`] = [o[0], s, K];
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
} else {
|
|
460
|
+
const s = parseInt(n), o = e[n];
|
|
461
|
+
if (Array.isArray(o) && o.length === 1)
|
|
462
|
+
t[`_${s}`] = [o[0], M, M];
|
|
463
|
+
else {
|
|
464
|
+
const u = Q(o);
|
|
465
|
+
u !== void 0 && (t[n] = u);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
return t;
|
|
469
|
+
}
|
|
470
|
+
function ht(e) {
|
|
471
|
+
const t = {};
|
|
472
|
+
for (const n in e) {
|
|
473
|
+
const s = e[n];
|
|
474
|
+
if (Array.isArray(s))
|
|
475
|
+
s.length === 1 ? t[n] = [s[0], M, M] : s.length === 3 && s[2] === M ? t[n] = [s[0]] : s.length === 2 && (t[n] = [s[1], s[0]]);
|
|
476
|
+
else {
|
|
477
|
+
const o = Q(s);
|
|
478
|
+
o !== void 0 && (t[n] = o);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
return t;
|
|
482
|
+
}
|
|
483
|
+
function Q(e) {
|
|
484
|
+
if (e !== void 0) {
|
|
485
|
+
if (Array.isArray(e)) {
|
|
486
|
+
if (e.length === 1)
|
|
487
|
+
return [e[0], M, M];
|
|
488
|
+
if (e.length === 2)
|
|
489
|
+
return [e[1], e[0]];
|
|
490
|
+
if (e.length === 3 && e[2] === M)
|
|
491
|
+
return [e[0]];
|
|
492
|
+
if (e.length === 3 && e[2] === K)
|
|
493
|
+
return e;
|
|
494
|
+
}
|
|
495
|
+
return k(e) && e._t === "a" ? gt(e) : k(e) ? ht(e) : e;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
function de(e) {
|
|
499
|
+
return Q(e);
|
|
500
|
+
}
|
|
501
|
+
function pt(e, t, n) {
|
|
502
|
+
const s = de(t);
|
|
503
|
+
return le(e, s);
|
|
504
|
+
}
|
|
505
|
+
class _t {
|
|
506
|
+
constructor(t) {
|
|
507
|
+
ne(this, "options");
|
|
508
|
+
this.options = t || {};
|
|
509
|
+
}
|
|
510
|
+
diff(t, n) {
|
|
511
|
+
return ft(t, n, this.options);
|
|
512
|
+
}
|
|
513
|
+
patch(t, n) {
|
|
514
|
+
return le(t, n, this.options);
|
|
515
|
+
}
|
|
516
|
+
reverse(t) {
|
|
517
|
+
return de(t);
|
|
518
|
+
}
|
|
519
|
+
unpatch(t, n) {
|
|
520
|
+
return pt(t, n, this.options);
|
|
521
|
+
}
|
|
522
|
+
clone(t) {
|
|
523
|
+
return O(t);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
function St(e) {
|
|
527
|
+
return new _t(e);
|
|
528
|
+
}
|
|
529
|
+
function bt({
|
|
530
|
+
maxHistorySize: e = 10
|
|
531
|
+
}) {
|
|
532
|
+
const t = St({
|
|
533
|
+
objectHash: (v) => v._id || v.id,
|
|
534
|
+
arrays: {
|
|
535
|
+
detectMove: !0,
|
|
536
|
+
includeValueOnMove: !1
|
|
537
|
+
},
|
|
538
|
+
cloneDiffValues: !1
|
|
539
|
+
}), n = j(null), s = j([]), o = H(-1), u = j(null), l = S(() => o.value > 0), a = S(() => o.value < s.value.length - 1);
|
|
540
|
+
function d(v) {
|
|
541
|
+
if (n.value === null) {
|
|
542
|
+
n.value = I(v), u.value = I(v), s.value = [{ delta: null }], o.value = 0;
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
const h = t.diff(u.value, v);
|
|
546
|
+
if (o.value < s.value.length - 1 && (s.value = s.value.slice(0, o.value + 1)), s.value.push({ delta: h }), o.value++, u.value = I(v), s.value.length > e) {
|
|
547
|
+
const b = s.value[1].delta;
|
|
548
|
+
b && n.value && (n.value = t.patch(I(n.value), b)), s.value.shift(), o.value--;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
function c(v) {
|
|
552
|
+
if (!n.value || v < 0 || v >= s.value.length)
|
|
553
|
+
return;
|
|
554
|
+
let h = I(n.value);
|
|
555
|
+
for (let b = 1; b <= v; b++) {
|
|
556
|
+
const w = s.value[b];
|
|
557
|
+
w.delta && (h = t.patch(h, w.delta));
|
|
558
|
+
}
|
|
559
|
+
return h;
|
|
560
|
+
}
|
|
561
|
+
function g() {
|
|
562
|
+
if (l.value) {
|
|
563
|
+
o.value--;
|
|
564
|
+
const v = c(o.value);
|
|
565
|
+
return v && (u.value = I(v)), v;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
function y() {
|
|
569
|
+
if (a.value) {
|
|
570
|
+
o.value++;
|
|
571
|
+
const v = c(o.value);
|
|
572
|
+
return v && (u.value = I(v)), v;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
function f() {
|
|
576
|
+
n.value = null, u.value = null, s.value = [], o.value = -1;
|
|
577
|
+
}
|
|
578
|
+
return {
|
|
579
|
+
push: d,
|
|
580
|
+
canUndo: l,
|
|
581
|
+
canRedo: a,
|
|
582
|
+
undo: g,
|
|
583
|
+
redo: y,
|
|
584
|
+
clear: f
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
const wt = {
|
|
588
|
+
async updateMenuModule(e, t) {
|
|
589
|
+
const n = q.RequestRunner.operation(t, e.modules);
|
|
590
|
+
if (n.validateError.length > 0)
|
|
591
|
+
throw new Error(n.validateError.join(`
|
|
592
|
+
`));
|
|
593
|
+
const s = {
|
|
594
|
+
...e,
|
|
595
|
+
modules: n.result || e.modules,
|
|
596
|
+
_rev: n.id ?? ""
|
|
597
|
+
};
|
|
598
|
+
return ie.cloneDeep({ menu: s, updateId: n.id ?? null });
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
function me() {
|
|
602
|
+
return {
|
|
603
|
+
_id: "",
|
|
604
|
+
masterCatalogSetting: { inclusiveTaxes: [] },
|
|
605
|
+
modules: {
|
|
606
|
+
catalog: [],
|
|
607
|
+
category: [],
|
|
608
|
+
group: [],
|
|
609
|
+
item: [],
|
|
610
|
+
printDepartment: [],
|
|
611
|
+
scheduler: [],
|
|
612
|
+
takeaway: [],
|
|
613
|
+
variant: [],
|
|
614
|
+
sku: [],
|
|
615
|
+
recipe: [],
|
|
616
|
+
unit: [],
|
|
617
|
+
cookingGuide: [],
|
|
618
|
+
serveSequence: [],
|
|
619
|
+
subCategory: []
|
|
620
|
+
},
|
|
621
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
function Mt() {
|
|
625
|
+
return {
|
|
626
|
+
restaurants: [],
|
|
627
|
+
menu: { ...me(), _rev: "" },
|
|
628
|
+
currentCatalogId: null,
|
|
629
|
+
currentCategoryIds: null,
|
|
630
|
+
currentSchedulerId: "",
|
|
631
|
+
currentRestaurantAttrParams: {
|
|
632
|
+
restaurantCustomAttributes: null,
|
|
633
|
+
restaurantAttributes: null
|
|
634
|
+
}
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
const Pt = Qe(
|
|
638
|
+
"mf-menu-store-v2",
|
|
639
|
+
() => {
|
|
640
|
+
const e = Xe(Mt()), t = se(), n = tt(), s = S(() => e.menu.modules.serveSequence ? x(e.menu.modules.serveSequence, {
|
|
641
|
+
selector: "position"
|
|
642
|
+
}) : []), o = S(() => {
|
|
643
|
+
var r;
|
|
644
|
+
return ((r = t.currentBusiness.value) == null ? void 0 : r.menuVersion) || z.F_MENU_VERSION.v3;
|
|
645
|
+
}), u = S(() => o.value === z.F_MENU_VERSION.v4), l = S(() => {
|
|
646
|
+
const r = e.menu.modules.catalog;
|
|
647
|
+
return x(r, { selector: "name" });
|
|
648
|
+
}), a = S(() => {
|
|
649
|
+
var i;
|
|
650
|
+
let r = e.menu.modules.catalog.find(
|
|
651
|
+
(m) => m._id === e.currentCatalogId
|
|
652
|
+
);
|
|
653
|
+
return r && ((i = r.linkItemRules) != null && i.length) && (r = T.populateCatalog({
|
|
654
|
+
catalog: r,
|
|
655
|
+
ruleGroupSettings: e.menu.ruleGroupSettings,
|
|
656
|
+
items: e.menu.modules.item,
|
|
657
|
+
...e.currentRestaurantAttrParams ?? {}
|
|
658
|
+
})), r;
|
|
659
|
+
}), d = S(() => x(y.value.modules.scheduler, { selector: "name" })), c = S(() => e.menu.modules.scheduler.find(
|
|
660
|
+
(r) => r._id === e.currentSchedulerId
|
|
661
|
+
));
|
|
662
|
+
function g(r, i = !0) {
|
|
663
|
+
e.menu = { ...r, _rev: e.menu._rev }, i && D.push(e.menu);
|
|
664
|
+
}
|
|
665
|
+
const y = j(me()), f = H(!1), v = H(1);
|
|
666
|
+
async function h() {
|
|
667
|
+
var m;
|
|
668
|
+
f.value = !0;
|
|
669
|
+
let r = e.menu.modules.catalog;
|
|
670
|
+
if (a.value && ((m = a.value.linkItemRules) != null && m.length)) {
|
|
671
|
+
const p = T.populateCatalog({
|
|
672
|
+
catalog: a.value,
|
|
673
|
+
ruleGroupSettings: e.menu.ruleGroupSettings,
|
|
674
|
+
items: e.menu.modules.item,
|
|
675
|
+
...e.currentRestaurantAttrParams ?? {}
|
|
676
|
+
});
|
|
677
|
+
r = e.menu.modules.catalog.map((_) => _._id === (p == null ? void 0 : p._id) ? p : _);
|
|
678
|
+
}
|
|
679
|
+
const i = await ce(
|
|
680
|
+
{
|
|
681
|
+
...e.menu,
|
|
682
|
+
modules: {
|
|
683
|
+
...e.menu.modules,
|
|
684
|
+
catalog: r
|
|
685
|
+
}
|
|
686
|
+
},
|
|
687
|
+
e.currentCatalogId,
|
|
688
|
+
e.currentSchedulerId
|
|
689
|
+
);
|
|
690
|
+
if (e.currentSchedulerId != null) {
|
|
691
|
+
const p = e.menu.modules.catalog.find(
|
|
692
|
+
(R) => R._id === e.currentCatalogId
|
|
693
|
+
), _ = p ? p.override.scheduler[e.currentSchedulerId] : e.menu.modules.scheduler.find(
|
|
694
|
+
(R) => R._id === e.currentSchedulerId
|
|
695
|
+
), A = new Set(((_ == null ? void 0 : _.items) || []).map((R) => R._id));
|
|
696
|
+
i.modules.item = i.modules.item.filter((R) => A.has(R._id));
|
|
697
|
+
}
|
|
698
|
+
return y.value = i, f.value = !1, v.value = v.value + 1, i;
|
|
699
|
+
}
|
|
700
|
+
const w = ie.debounce(h, 200);
|
|
701
|
+
let C = null, E = null;
|
|
702
|
+
function X() {
|
|
703
|
+
E && (E(), E = null), C && C.stop(), C = Ze(!0), E = C.run(() => et(
|
|
704
|
+
() => [e.menu, e.currentCatalogId, e.currentSchedulerId],
|
|
705
|
+
() => {
|
|
706
|
+
f.value || w();
|
|
707
|
+
}
|
|
708
|
+
)) || null;
|
|
709
|
+
}
|
|
710
|
+
X();
|
|
711
|
+
const fe = S(() => [
|
|
712
|
+
{
|
|
713
|
+
label: "Main",
|
|
714
|
+
value: null
|
|
715
|
+
},
|
|
716
|
+
...l.value.map((r) => ({
|
|
717
|
+
label: r.name,
|
|
718
|
+
value: r._id
|
|
719
|
+
}))
|
|
720
|
+
]), Z = S(() => {
|
|
721
|
+
const r = y.value.modules.category;
|
|
722
|
+
return [
|
|
723
|
+
...U.value.item.addon ? [
|
|
724
|
+
{
|
|
725
|
+
_id: e.currentCatalogId ? "" : null,
|
|
726
|
+
name: "Addon",
|
|
727
|
+
position: 0
|
|
728
|
+
}
|
|
729
|
+
] : [],
|
|
730
|
+
...V(r, (i) => i.name)
|
|
731
|
+
];
|
|
732
|
+
}), ve = S(() => {
|
|
733
|
+
const r = y.value.modules.subCategory || [];
|
|
734
|
+
return V(r, (i) => i.name);
|
|
735
|
+
}), ee = S(() => {
|
|
736
|
+
var i;
|
|
737
|
+
let r = y.value.modules.item;
|
|
738
|
+
if (a.value) {
|
|
739
|
+
const m = (i = a.value) == null ? void 0 : i.override.items;
|
|
740
|
+
r = r.filter((p) => {
|
|
741
|
+
var A;
|
|
742
|
+
const _ = (A = m == null ? void 0 : m[p._id]) == null ? void 0 : A.find(
|
|
743
|
+
(R) => !R.combinationKey
|
|
744
|
+
);
|
|
745
|
+
return (_ == null ? void 0 : _.orderFrom) !== ue.enum.NONE;
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
return V(r, (m) => m.code || m.name);
|
|
749
|
+
}), ye = S(() => {
|
|
750
|
+
const r = e.menu.modules.category, i = V(r, (p) => p.name).reduce(
|
|
751
|
+
(p, _, A) => (p[_._id] = A, p),
|
|
752
|
+
{ "": 0 }
|
|
753
|
+
), m = e.menu.modules.item;
|
|
754
|
+
return V(
|
|
755
|
+
m,
|
|
756
|
+
(p) => p.code || p.name
|
|
757
|
+
).reduce((p, _, A) => (p[_._id] = A + i[_.category || ""], p), {});
|
|
758
|
+
}), ge = S(() => oe(N.value, Z.value, ee.value)), he = S(() => {
|
|
759
|
+
const r = U.value.item.addon ? [
|
|
760
|
+
{
|
|
761
|
+
_id: e.currentCatalogId ? "" : null,
|
|
762
|
+
name: "Addon",
|
|
763
|
+
position: 0
|
|
764
|
+
},
|
|
765
|
+
...e.menu.modules.category
|
|
766
|
+
] : e.menu.modules.category;
|
|
767
|
+
return oe(
|
|
768
|
+
e.menu.modules.variant,
|
|
769
|
+
r,
|
|
770
|
+
e.menu.modules.item
|
|
771
|
+
);
|
|
772
|
+
}), N = S(() => {
|
|
773
|
+
const r = y.value.modules.variant;
|
|
774
|
+
return x(r, { selector: "name" });
|
|
775
|
+
});
|
|
776
|
+
function pe(r = []) {
|
|
777
|
+
const i = r.map((p) => N.value.find((_) => _._id === p)).filter((p) => !!p);
|
|
778
|
+
return T.fullVariantCombination(i).reduce((p, _) => (p[_.combinationKey] = _.selectionName.join(" / "), p), {});
|
|
779
|
+
}
|
|
780
|
+
const _e = S(() => V(y.value.modules.group, (r) => r.name)), Se = S(() => x(y.value.modules.takeaway, { selector: "name" })), be = S(() => x(e.menu.modules.printDepartment || [], {
|
|
781
|
+
selector: "name"
|
|
782
|
+
})), we = S(() => x(e.menu.modules.unit, { selector: "name" })), Me = S(() => x(Le(e.menu.modules.recipe, e.menu.modules.sku), {
|
|
783
|
+
selector: "name"
|
|
784
|
+
})), Ae = S(() => e.menu.modules.cookingGuide), Ie = S(() => {
|
|
785
|
+
const r = Be(e.menu.modules.sku);
|
|
786
|
+
return x(r, { selector: "code" });
|
|
787
|
+
}), Ce = S(() => {
|
|
788
|
+
const r = /* @__PURE__ */ new Map();
|
|
789
|
+
return e.menu.modules.item.forEach((i) => {
|
|
790
|
+
var m, p;
|
|
791
|
+
i.code && r.set(i.code, (r.get(i.code) || 0) + 1), (p = (m = i.variant) == null ? void 0 : m.variantCombinations) == null || p.forEach((_) => {
|
|
792
|
+
_.code && r.set(_.code, (r.get(_.code) || 0) + 1);
|
|
793
|
+
});
|
|
794
|
+
}), r;
|
|
795
|
+
}), U = S(() => {
|
|
796
|
+
const r = !e.currentCatalogId, i = o.value === z.F_MENU_VERSION.v4, m = !e.currentSchedulerId, p = {
|
|
797
|
+
create: r && m,
|
|
798
|
+
edit: r && m,
|
|
799
|
+
delete: r && m
|
|
800
|
+
};
|
|
801
|
+
return {
|
|
802
|
+
item: {
|
|
803
|
+
...p,
|
|
804
|
+
edit: i || m,
|
|
805
|
+
sort: i && r && m,
|
|
806
|
+
addon: i,
|
|
807
|
+
code: m,
|
|
808
|
+
name: r && m,
|
|
809
|
+
description: r && m,
|
|
810
|
+
category: m,
|
|
811
|
+
thumbnail: r && m,
|
|
812
|
+
orderFrom: (i || r) && m,
|
|
813
|
+
orderFromNone: r,
|
|
814
|
+
orderFromActiveOnly: !i,
|
|
815
|
+
openPrice: r && m,
|
|
816
|
+
unit: r && m,
|
|
817
|
+
price: r,
|
|
818
|
+
editPrice: r,
|
|
819
|
+
minPrice: i && m,
|
|
820
|
+
costing: i && r && m,
|
|
821
|
+
tax: r && m,
|
|
822
|
+
variant: r && m,
|
|
823
|
+
maxVariant: i ? 4 : 2,
|
|
824
|
+
group: r && m,
|
|
825
|
+
overrideProductGroup: i && m,
|
|
826
|
+
inventory: (i || r) && m,
|
|
827
|
+
bindToVariant: i,
|
|
828
|
+
print: r && m,
|
|
829
|
+
toRoot: i && m,
|
|
830
|
+
takeaway: (_) => !!_ && (i || r) && m,
|
|
831
|
+
serveDelay: i && r && m,
|
|
832
|
+
multiScheduler: i,
|
|
833
|
+
canRearrange: i,
|
|
834
|
+
printConfig: i,
|
|
835
|
+
takeawayConfig: i
|
|
836
|
+
},
|
|
837
|
+
category: {
|
|
838
|
+
...p,
|
|
839
|
+
sort: r,
|
|
840
|
+
overrideSequence: i
|
|
841
|
+
},
|
|
842
|
+
group: {
|
|
843
|
+
...p,
|
|
844
|
+
edit: i || m,
|
|
845
|
+
sort: r,
|
|
846
|
+
applyProduct: r,
|
|
847
|
+
showAppliedProduct: m,
|
|
848
|
+
type: !i,
|
|
849
|
+
insertRawItems: !i,
|
|
850
|
+
multiScheduler: i,
|
|
851
|
+
linkAddonName: i
|
|
852
|
+
},
|
|
853
|
+
scheduler: {
|
|
854
|
+
override: i
|
|
855
|
+
},
|
|
856
|
+
takeaway: {
|
|
857
|
+
...p,
|
|
858
|
+
edit: (i || r) && m,
|
|
859
|
+
name: r
|
|
860
|
+
},
|
|
861
|
+
catalog: {
|
|
862
|
+
name: !r,
|
|
863
|
+
defaultOrderFrom: i,
|
|
864
|
+
markup: i
|
|
865
|
+
}
|
|
866
|
+
};
|
|
867
|
+
});
|
|
868
|
+
function W(r) {
|
|
869
|
+
return `${r.systemCode}/${r.taxCode}`;
|
|
870
|
+
}
|
|
871
|
+
function Ee(r) {
|
|
872
|
+
const [i, m] = r.split("/");
|
|
873
|
+
return { systemCode: i, taxCode: m };
|
|
874
|
+
}
|
|
875
|
+
function ke(r, i, m) {
|
|
876
|
+
return (r ?? i ?? []).map((p) => W(p)).find((p) => m.some((_) => _.value === p));
|
|
877
|
+
}
|
|
878
|
+
const Re = S(() => {
|
|
879
|
+
var p;
|
|
880
|
+
const r = ["SV5", "SV10"], i = qe.Country.getCountryFlattenTaxes(
|
|
881
|
+
se().currentCountry.value
|
|
882
|
+
), m = i.filter((_) => u.value || !r.includes(_.taxCode)).map((_) => ({
|
|
883
|
+
label: `${_.name} (${He(_.rate)}%)`,
|
|
884
|
+
value: W(_),
|
|
885
|
+
meta: {
|
|
886
|
+
rate: _.rate
|
|
887
|
+
}
|
|
888
|
+
}));
|
|
889
|
+
return m.sort((_, A) => _.label.localeCompare(A.label, void 0, { numeric: !0 })), {
|
|
890
|
+
systemCode: (p = i[0]) == null ? void 0 : p.systemCode,
|
|
891
|
+
countryTaxOptions: m
|
|
892
|
+
};
|
|
893
|
+
}), xe = async () => {
|
|
894
|
+
const r = await Ye.readMenu();
|
|
895
|
+
e.menu = r ?? e.menu, te(null);
|
|
896
|
+
}, Oe = async () => {
|
|
897
|
+
const { fetchAllRestaurants: r } = Je();
|
|
898
|
+
await r({
|
|
899
|
+
onBatchEnd: (i) => {
|
|
900
|
+
e.restaurants = i;
|
|
901
|
+
}
|
|
902
|
+
});
|
|
903
|
+
}, te = (r) => {
|
|
904
|
+
e.currentCatalogId = r;
|
|
905
|
+
}, De = (r) => {
|
|
906
|
+
e.currentSchedulerId = r;
|
|
907
|
+
}, Ve = (r) => {
|
|
908
|
+
e.currentCategoryIds = r;
|
|
909
|
+
}, Te = (r) => {
|
|
910
|
+
e.currentRestaurantAttrParams = r;
|
|
911
|
+
}, Ke = async (r, i) => {
|
|
912
|
+
const m = Array.isArray(r) ? r : [r];
|
|
913
|
+
if (!m.length) return;
|
|
914
|
+
const p = m.map((_) => ({
|
|
915
|
+
..._,
|
|
916
|
+
_id: e.menu._id,
|
|
917
|
+
_rev: e.menu._rev
|
|
918
|
+
}));
|
|
919
|
+
try {
|
|
920
|
+
if (i || p.some(
|
|
921
|
+
(A) => [q.F_OPERATION_TYPE.delete, q.F_OPERATION_TYPE.deleteMany].includes(A.operation)
|
|
922
|
+
)) {
|
|
923
|
+
const A = await Ge(p, e.menu.modules);
|
|
924
|
+
if (A !== !0) throw new Error(A);
|
|
925
|
+
}
|
|
926
|
+
const _ = await wt.updateMenuModule(e.menu, p);
|
|
927
|
+
return g(_.menu), _;
|
|
928
|
+
} catch (_) {
|
|
929
|
+
n.open({
|
|
930
|
+
type: "error",
|
|
931
|
+
title: "Failed to update menu",
|
|
932
|
+
message: _
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
}, Pe = async (r) => {
|
|
936
|
+
const i = {
|
|
937
|
+
...e.menu,
|
|
938
|
+
masterCatalogSetting: r.masterCatalogSetting,
|
|
939
|
+
lowStockThreshold: r.lowStockThreshold,
|
|
940
|
+
priceTierSettings: r.priceTierSettings
|
|
941
|
+
};
|
|
942
|
+
return g(i), i;
|
|
943
|
+
}, D = bt({ maxHistorySize: 50 }), $e = S(() => D.canUndo.value), Fe = S(() => D.canRedo.value), je = () => {
|
|
944
|
+
const r = D.undo();
|
|
945
|
+
r && g(r, !1);
|
|
946
|
+
}, Ne = () => {
|
|
947
|
+
const r = D.redo();
|
|
948
|
+
r && g(r, !1);
|
|
949
|
+
}, Ue = () => {
|
|
950
|
+
D.clear();
|
|
951
|
+
};
|
|
952
|
+
return {
|
|
953
|
+
state: e,
|
|
954
|
+
// loading state
|
|
955
|
+
workerIsComputing: f,
|
|
956
|
+
mergedMenuChangeId: v,
|
|
957
|
+
// async computed state
|
|
958
|
+
mergedMenu: y,
|
|
959
|
+
// Computed
|
|
960
|
+
version: o,
|
|
961
|
+
isV4: u,
|
|
962
|
+
serveSequence: s,
|
|
963
|
+
catalogs: l,
|
|
964
|
+
currentCatalog: a,
|
|
965
|
+
schedulers: d,
|
|
966
|
+
currentScheduler: c,
|
|
967
|
+
catalogOptions: fe,
|
|
968
|
+
categories: Z,
|
|
969
|
+
subcategories: ve,
|
|
970
|
+
items: ee,
|
|
971
|
+
sortedItems: ye,
|
|
972
|
+
itemCodeMap: Ce,
|
|
973
|
+
categorizedItems: ge,
|
|
974
|
+
categorizedRawMenuItems: he,
|
|
975
|
+
variants: N,
|
|
976
|
+
groups: _e,
|
|
977
|
+
takeaways: Se,
|
|
978
|
+
printDepartments: be,
|
|
979
|
+
units: we,
|
|
980
|
+
recipes: Me,
|
|
981
|
+
cookingGuide: Ae,
|
|
982
|
+
skus: Ie,
|
|
983
|
+
rules: U,
|
|
984
|
+
taxSetting: Re,
|
|
985
|
+
// Action
|
|
986
|
+
setMenu: g,
|
|
987
|
+
readMenu: xe,
|
|
988
|
+
readRestaurants: Oe,
|
|
989
|
+
selectCatalog: te,
|
|
990
|
+
selectScheduler: De,
|
|
991
|
+
selectCategory: Ve,
|
|
992
|
+
setRestaurantAttrParams: Te,
|
|
993
|
+
updateMenu: Ke,
|
|
994
|
+
updateMenuSetting: Pe,
|
|
995
|
+
computeMergedMenu: h,
|
|
996
|
+
// helper
|
|
997
|
+
encodeTax: W,
|
|
998
|
+
decodeTax: Ee,
|
|
999
|
+
getSelectedTax: ke,
|
|
1000
|
+
mapVariant: pe,
|
|
1001
|
+
// history
|
|
1002
|
+
canUndoHistory: $e,
|
|
1003
|
+
canRedoHistory: Fe,
|
|
1004
|
+
undoHistory: je,
|
|
1005
|
+
redoHistory: Ne,
|
|
1006
|
+
// cleanup
|
|
1007
|
+
$dispose: () => {
|
|
1008
|
+
w.cancel(), E && (E(), E = null), C && (C.stop(), C = null), Ue();
|
|
1009
|
+
},
|
|
1010
|
+
$reinitialize: () => {
|
|
1011
|
+
X();
|
|
1012
|
+
}
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
);
|
|
1016
|
+
export {
|
|
1017
|
+
Tt as a,
|
|
1018
|
+
Kt as f,
|
|
1019
|
+
Vt as g,
|
|
1020
|
+
Dt as m,
|
|
1021
|
+
it as o,
|
|
1022
|
+
Pt as u
|
|
1023
|
+
};
|