@feedmepos/mf-menu 0.32.17 → 0.32.18-dev.1

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 (82) hide show
  1. package/dist/App-Cfl37TTw.js +152661 -0
  2. package/dist/{Catalog-ChlP8Cid.js → Catalog-Yxsb-D33.js} +47 -52
  3. package/dist/{Category-CHs96ibF.js → Category-0vJH8Ct0.js} +86 -92
  4. package/dist/{Category-B1tAJpNd.js → Category-qp0wI14I.js} +25 -26
  5. package/dist/{CookingGuide-mEvca-0v.js → CookingGuide-EpAr5F5U.js} +139 -143
  6. package/dist/{CustomAttributeChip.vue_vue_type_script_setup_true_lang-Bk26jQI7.js → CustomAttributeChip.vue_vue_type_script_setup_true_lang-CkyD0sdI.js} +14 -16
  7. package/dist/{Group-Ye2IIY52.js → Group-B3W9iSbO.js} +5 -5
  8. package/dist/{Group-Co2Vf4Lw.js → Group-DLCh0fDU.js} +1 -1
  9. package/dist/{Group.vue_vue_type_script_setup_true_lang-BcxSbvJS.js → Group.vue_vue_type_script_setup_true_lang-Bzy_hXDv.js} +176 -186
  10. package/dist/{GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-D1f8VG-n.js → GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-BFaAXp7r.js} +81 -88
  11. package/dist/{ImportProductDialog.vue_vue_type_script_setup_true_lang-Jv6iJlg9.js → ImportProductDialog.vue_vue_type_script_setup_true_lang-CxP8lDD0.js} +2502 -2508
  12. package/dist/{Ingredient-BgnW8sWo.js → Ingredient-CVLMr_YB.js} +102 -105
  13. package/dist/{InventoryBinding.vue_vue_type_script_setup_true_lang-8ziHcUiK.js → InventoryBinding.vue_vue_type_script_setup_true_lang-CdTC5ykI.js} +1058 -1059
  14. package/dist/{MenuSetting-GEngjeC8.js → MenuSetting-Blpi1vSd.js} +58 -61
  15. package/dist/{PrintRoute-BSlUQT7g.js → PrintRoute-BS7PPPkE.js} +49 -52
  16. package/dist/{Product-DNg_BUuV.js → Product-DDeNKQ7u.js} +1 -1
  17. package/dist/{Product.vue_vue_type_script_setup_true_lang-Cehy2oy-.js → Product.vue_vue_type_script_setup_true_lang-rmv8m4_D.js} +286 -298
  18. package/dist/{ProductInternalTools-B5A67yxH.js → ProductInternalTools-CVuothk9.js} +45 -46
  19. package/dist/{Products-DCsxmTPB.js → Products-BIvsHKEt.js} +111 -116
  20. package/dist/{Publish-Cst0Ll6T.js → Publish-CDADU3Pp.js} +154 -159
  21. package/dist/{Recipe-DupS3SQT.js → Recipe-CMhW7e_z.js} +40 -43
  22. package/dist/{Scheduler-BcThU1M6.js → Scheduler-BpxunKBV.js} +7 -7
  23. package/dist/{ServingSequence-CT3THBH6.js → ServingSequence-BQVuYyAB.js} +54 -58
  24. package/dist/{Setting-Dxh8E3no.js → Setting-Dj0yyP37.js} +63 -66
  25. package/dist/{Subcategory-DhJEzofz.js → Subcategory-BH4DDZM4.js} +72 -76
  26. package/dist/{Takeaway-DSC7U4Jk.js → Takeaway-CGJBZ_sJ.js} +1 -1
  27. package/dist/{Takeaway-B8BSSKNj.js → Takeaway-DifOudVE.js} +20 -21
  28. package/dist/{Takeaway.vue_vue_type_script_setup_true_lang-BLpiJlk2.js → Takeaway.vue_vue_type_script_setup_true_lang-D-R5_S5G.js} +59 -64
  29. package/dist/{Unit-joU7vZZu.js → Unit-DXDox2Ut.js} +8 -8
  30. package/dist/{Variant-D8YjRJ6N.js → Variant-DbJVwgm5.js} +75 -78
  31. package/dist/{_id_-Bd9uo1WW.js → _id_-RFYwWjbM.js} +34 -38
  32. package/dist/{app-BNrAos5Z.js → app-Z0KWH9-d.js} +74 -335
  33. package/dist/app.js +4 -5
  34. package/dist/apps/mf-menu/src/app.d.ts +1 -2
  35. package/dist/apps/mf-menu/src/helper/import-export-utils.d.ts +1 -0
  36. package/dist/apps/mf-menu/tsconfig.app.tsbuildinfo +1 -1
  37. package/dist/assets/{linked-status-DbjzbFTw.js → linked-status-CkmoJAm-.js} +2 -2
  38. package/dist/assets/{menu-export-D_oNY_wi.js → menu-export-DcINiK28.js} +3 -3
  39. package/dist/assets/{override-menu-CIU7U1_4.js → override-menu-PUKiu-df.js} +2 -2
  40. package/dist/assets/{validate-menu-kuOxuwG9.js → validate-menu-CcqiRhNT.js} +2 -2
  41. package/dist/{catalogSetting-BHgsBDTl.js → catalogSetting-Bf66H-j7.js} +1 -1
  42. package/dist/dayjs.min-DNPTnUFp.js +6 -0
  43. package/dist/{jszip.min-7SsHzD5O.js → jszip.min-CO2_Gf69.js} +545 -545
  44. package/dist/{menu-Cd4NbFVq.js → menu-Brxar171.js} +1 -1
  45. package/dist/mf-menu.css +1 -1
  46. package/dist/{scheduler-B6OokVIA.js → scheduler-CqdIiE8G.js} +56 -60
  47. package/dist/{toExcel-BZkbXlHv.js → toExcel-CRJIU0NC.js} +2 -2
  48. package/dist/{unit-D6QOkMoM.js → unit-wYPYkm33.js} +98 -105
  49. package/package.json +1 -1
  50. package/dist/App-BiSEuDkd.js +0 -13484
  51. package/dist/ApplyProduct.vue_vue_type_script_setup_true_lang-C_SjdLpO.js +0 -161
  52. package/dist/FormItem.vue_vue_type_script_setup_true_lang-BmPAVphe.js +0 -26
  53. package/dist/LinkProductSideSheet-DFDYEUBh.js +0 -687
  54. package/dist/MenuSelector.vue_vue_type_script_setup_true_lang-K6Z0QJBl.js +0 -69
  55. package/dist/RuleView.vue_vue_type_script_setup_true_lang-BeesK2ym.js +0 -3285
  56. package/dist/TextChip.vue_vue_type_script_setup_true_lang-8frWuZFL.js +0 -20
  57. package/dist/Thumbnail.vue_vue_type_script_setup_true_lang-C3qXnZlz.js +0 -399
  58. package/dist/TreeEditorOpenner.vue_vue_type_script_setup_true_lang-CMe76XvZ.js +0 -6011
  59. package/dist/_plugin-vue_export-helper-CHgC5LLL.js +0 -9
  60. package/dist/app-5fxKLAzS.js +0 -8163
  61. package/dist/app-nTzkERJW.js +0 -68
  62. package/dist/catalog-BO2nXwe5.js +0 -199
  63. package/dist/category-CuG3DsGL.js +0 -156
  64. package/dist/check-C9mY6LiX.js +0 -9
  65. package/dist/createComponentProgrammatically-Bt2rn1IQ.js +0 -11
  66. package/dist/currency-DxC5zyZB.js +0 -7
  67. package/dist/dayjs.min-BvFUSPWD.js +0 -6
  68. package/dist/discardConfirm-BHni0LNu.js +0 -28
  69. package/dist/index-B0nhvuxR.js +0 -273
  70. package/dist/index-C2zPvt64.js +0 -239
  71. package/dist/index-C36JQix-.js +0 -246
  72. package/dist/index-CisutoS9.js +0 -156
  73. package/dist/index.vue_vue_type_script_setup_true_lang-DCBYExNb.js +0 -109064
  74. package/dist/item-K01xd1Z0.js +0 -6868
  75. package/dist/menuV2-DKE-xanq.js +0 -1052
  76. package/dist/object-DVUNCr7w.js +0 -16
  77. package/dist/priceTier-Beavb91W.js +0 -87
  78. package/dist/search-BAPEUu1R.js +0 -15
  79. package/dist/string-DpfFixWH.js +0 -4
  80. package/dist/subcategory-DnslmmRD.js +0 -148
  81. package/dist/tooltip-B5BiPMx9.js +0 -32
  82. package/dist/vuedraggable-CK8z7qA8.js +0 -1728
@@ -1,1052 +0,0 @@
1
- var We = Object.defineProperty;
2
- var Le = (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) => Le(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { K as ae, I as C, D as T, A as ue, ap as re, M as G, J as ie, ad as x, a as L, Z as V, an as oe, aq as qe, ar as ze, B as Ge, af as Be, as as He, at as Je, ac as Ye } from "./index.vue_vue_type_script_setup_true_lang-DCBYExNb.js";
5
- import { defineStore as Ze } from "pinia";
6
- import { shallowRef as j, ref as B, computed as S, shallowReactive as Qe, effectScope as Xe, 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-DbjzbFTw.js", rt = "/assets/override-menu-CIU7U1_4.js";
10
- function ot(e) {
11
- var o;
12
- const t = C(e), n = (o = t.variant) == null ? void 0 : o.variantCombinations;
13
- return delete t.variant, delete t.thumbnail, [t, ...n || []];
14
- }
15
- function st(e, t, n, o) {
16
- const r = C(t), u = n ? r.modules.catalog.find((v) => v._id === n) : null, l = o ? r.modules.scheduler.find((v) => v._id === o) : null, a = u ? C(u) : void 0, c = n ? r.modules.catalog.filter((v) => v._id !== n) : [], i = l ? C(l) : void 0, f = e.reduce((v, y) => (v[y._id] = ot(y), v), {});
17
- function p(v = []) {
18
- const y = e.map((h) => h._id);
19
- return [
20
- ...v.filter((h) => !y.includes(h._id)),
21
- ...Object.values(f).flatMap((h) => h)
22
- ];
23
- }
24
- return a && o ? (a.override.scheduler = {
25
- ...a.override.scheduler,
26
- [o]: {
27
- ...a.override.scheduler[o],
28
- _id: o,
29
- items: p(i == null ? void 0 : i.items).map((v) => ({
30
- ...v,
31
- orderFrom: ue.F_ORDER_FROM.enum.ALL
32
- }))
33
- }
34
- }, r.modules.catalog = [...c, a], r) : a ? (a.override.items = {
35
- ...a.override.items,
36
- ...f
37
- }, r.modules.catalog = [...c, a], r) : i ? (i.items = p(i.items), r.modules.scheduler = [
38
- ...r.modules.scheduler.filter((v) => v._id !== o),
39
- i
40
- ], r) : {
41
- ...re(),
42
- modules: {
43
- ...re().modules,
44
- catalog: r.modules.catalog,
45
- item: r.modules.item,
46
- group: r.modules.group,
47
- scheduler: r.modules.scheduler
48
- },
49
- _id: r._id
50
- };
51
- }
52
- function $(e, t, n) {
53
- var u;
54
- if (n >= 3) return e;
55
- const o = t.modules.item.find((l) => l._id === e._id);
56
- if (!o)
57
- throw new Error(`_insertItemOverriders - Item not found - ${e._id}`);
58
- const r = (u = o.groups) == null ? void 0 : u.map((l) => {
59
- var i, f, p;
60
- const a = (i = e == null ? void 0 : e.groups) == null ? void 0 : i.find((v) => v._id === l._id);
61
- let c;
62
- return a ? c = ((f = l.items) == null ? void 0 : f.map((v) => {
63
- var h;
64
- const y = (h = a.items) == null ? void 0 : h.find(
65
- (b) => b._id === v._id && b.combinationKey === v.combinationKey
66
- );
67
- return $(y || v, t, n + 1);
68
- })) ?? [] : c = ((p = l.items) == null ? void 0 : p.map((v) => $(v, t, n + 1))) ?? [], {
69
- ...l,
70
- items: c
71
- };
72
- });
73
- return {
74
- _id: o._id,
75
- name: e.name || o.name,
76
- code: e.code || o.code,
77
- combinationKey: e.combinationKey,
78
- groups: r
79
- };
80
- }
81
- function at(e, t) {
82
- const n = e.groups.map((u) => {
83
- const l = t.modules.group.find((c) => c._id === u._id), a = ((l == null ? void 0 : l.items) || []).map((c) => {
84
- var p;
85
- const i = (p = u.items) == null ? void 0 : p.find(
86
- (v) => v._id === c._id && v.combinationKey === c.combinationKey
87
- );
88
- if (i)
89
- return $(i, t, 1);
90
- const f = {
91
- ...T.generator.initMenuV4ItemOverrider(),
92
- _id: c._id,
93
- combinationKey: c.combinationKey
94
- };
95
- return $(f, t, 1);
96
- });
97
- return { ...u, items: a };
98
- }), o = e.variant ? e.variant.variantCombinations.map((u) => $(u, t, 1)) : [], r = {
99
- ...T.generator.initMenuV4ItemOverrider(),
100
- _id: e._id,
101
- name: e.name,
102
- code: e.code,
103
- groups: n
104
- };
105
- return [...o, r];
106
- }
107
- function H(e, t) {
108
- var o;
109
- if (!t)
110
- return e;
111
- const n = { ...e, code: t.code };
112
- return n.groups = (o = n.groups) == null ? void 0 : o.map((r) => {
113
- var l, a;
114
- const u = (l = t.groups) == null ? void 0 : l.find((c) => c._id === r._id);
115
- return r.items = (a = r.items) == null ? void 0 : a.map((c) => {
116
- var f;
117
- const i = (f = u == null ? void 0 : u.items) == null ? void 0 : f.find(
118
- (p) => p._id === c._id && p.combinationKey === c.combinationKey
119
- );
120
- return H(c, i);
121
- }), r;
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((r) => {
129
- const u = n.find(
130
- (l) => l._id === r._id && l.combinationKey === r.combinationKey
131
- );
132
- if (!u)
133
- throw new Error(`Item overrider not found - ${r._id} - ${r.combinationKey}`);
134
- return H(u, r);
135
- })
136
- });
137
- const o = n.find((r) => !r.combinationKey);
138
- if (!o)
139
- throw new Error(`Base item overrider not found - ${t._id}`);
140
- return t.groups = (o.groups || []).map((r) => {
141
- var l;
142
- const u = t.groups.find((a) => a._id === r._id);
143
- return r.items = (l = r.items) == null ? void 0 : l.map((a) => {
144
- var i;
145
- const c = (i = u == null ? void 0 : u.items) == null ? void 0 : i.find(
146
- (f) => f._id === a._id && f.combinationKey === a.combinationKey
147
- );
148
- return H(a, c);
149
- }), r;
150
- }), {
151
- ...t,
152
- price: (o == null ? void 0 : o.price) || t.price
153
- };
154
- }
155
- async function Dt(e, t, n, o, r, u = !0) {
156
- const l = C(n), a = u ? st(t, l, o, r) : l, c = t.reduce((p, v) => (p[v._id] = a.modules.item.find((y) => y._id === v._id), p), {}), i = t.reduce((p, v) => {
157
- const y = v._id;
158
- return p[y] = at(c[y], e), p;
159
- }, {}), f = T.getFallbackPrices({
160
- rawMenu: a,
161
- items: i,
162
- catalogId: o || void 0,
163
- schedulerId: r
164
- });
165
- return t.map((p) => {
166
- const v = p._id, y = c[v];
167
- return {
168
- ...ut(f, y),
169
- category: o || r ? y == null ? void 0 : y.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((r, u) => {
177
- if (u && u.length > 0) {
178
- const l = `variant${u.split("/")[0]}`, a = u.split("/")[1], i = t.find(
179
- ({ _id: f }) => f === l
180
- ).options.find(({ _id: f }) => f === a);
181
- r.push(((i == null ? void 0 : i.name) || "").trim());
182
- }
183
- return r;
184
- }, [])) || []).join(" / ");
185
- }
186
- const q = /* @__PURE__ */ new Map();
187
- async function Tt(e, t) {
188
- const n = `${e._id}-${e.updatedAt}-${t}`;
189
- if (q.has(n))
190
- return q.get(n);
191
- const o = await ae(
192
- nt,
193
- JSON.stringify({
194
- menu: e,
195
- itemId: t
196
- })
197
- );
198
- return q.set(n, o), o;
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
- function Ft(e, t, n) {
208
- const o = /* @__PURE__ */ new Set();
209
- function r(u, l) {
210
- if (!e || !u || !l || o.has(l)) return !1;
211
- o.add(l);
212
- const a = e.modules.item.find((c) => c._id === l);
213
- return !a || !a.groups ? !1 : a.groups.some((c) => c._id === u) ? !0 : a.groups.some((c) => {
214
- const i = e.modules.group.find((f) => f._id === c._id);
215
- for (const f of (i == null ? void 0 : i.items) || [])
216
- if (r(u, f._id)) return !0;
217
- return !1;
218
- });
219
- }
220
- return r(t, n);
221
- }
222
- function Kt(e, t, n) {
223
- const o = /* @__PURE__ */ new Set();
224
- function r(u, l) {
225
- if (!e || !u || !l || o.has(u)) return !1;
226
- o.add(u);
227
- const a = e.modules.group.find((c) => c._id === u);
228
- return !a || !a.items ? !1 : a.items.some((c) => c._id === l) ? !0 : a.items.some((c) => {
229
- const i = e.modules.item.find((f) => f._id === c._id);
230
- for (const f of (i == null ? void 0 : i.groups) || [])
231
- if (r(f._id, l)) return !0;
232
- return !1;
233
- });
234
- }
235
- return r(t, n);
236
- }
237
- const z = /* @__PURE__ */ new Map();
238
- async function it(e, t, n) {
239
- const o = `${e._id}-${e.updatedAt}-${t || "null"}-${n || "null"}`;
240
- if (z.has(o))
241
- return z.get(o);
242
- const r = await ce(e, t, n);
243
- return z.set(o, r), r;
244
- }
245
- async function Pt(e, t, n) {
246
- var l, a;
247
- const o = await it(e, t, null), r = [], u = (c, i) => {
248
- const f = C(c);
249
- for (const p in i)
250
- i[p] && (f[p] = i[p]);
251
- return f;
252
- };
253
- for (const c of o.modules.group) {
254
- const i = (l = c.items) == null ? void 0 : l.find((p) => p._id === n && !p.combinationKey), f = e.modules.item.find((p) => p._id === n);
255
- if (i) {
256
- const p = (a = c.items) == null ? void 0 : a.filter((y) => y._id === n && y.combinationKey), v = [i, ...p].map((y) => {
257
- var w, I;
258
- const h = y.combinationKey ? (I = (w = f == null ? void 0 : f.variant) == null ? void 0 : w.variantCombinations) == null ? void 0 : I.find(
259
- (E) => E.combinationKey === y.combinationKey
260
- ) : f, b = h && f ? u(f, h) : y;
261
- return u(b, y);
262
- });
263
- r.push({
264
- group: c,
265
- items: v
266
- });
267
- }
268
- }
269
- return r;
270
- }
271
- const M = 0, F = 3;
272
- function ct(e) {
273
- const t = /^\/(.*)\/([gimyu]*)$/.exec(e.toString());
274
- if (!t)
275
- throw new Error("Invalid RegExp");
276
- return new RegExp(t[1] ?? "", t[2]);
277
- }
278
- function O(e) {
279
- if (typeof e != "object")
280
- return e;
281
- if (e === null)
282
- return null;
283
- if (Array.isArray(e))
284
- return e.map(O);
285
- if (e instanceof Date)
286
- return new Date(e.getTime());
287
- if (e instanceof RegExp)
288
- return ct(e);
289
- const t = {};
290
- for (const n in e)
291
- Object.prototype.hasOwnProperty.call(e, n) && (t[n] = O(e[n]));
292
- return t;
293
- }
294
- function P(e) {
295
- return e instanceof RegExp ? e.toString() : e;
296
- }
297
- function R(e) {
298
- return typeof e == "object" && e !== null && !Array.isArray(e) && !(e instanceof Date) && !(e instanceof RegExp);
299
- }
300
- function K(e, t) {
301
- if (e === t) return !0;
302
- if (typeof e != typeof t) return !1;
303
- if (e instanceof Date && t instanceof Date)
304
- return e.getTime() === t.getTime();
305
- if (e instanceof RegExp && t instanceof RegExp)
306
- return e.toString() === t.toString();
307
- if (Array.isArray(e) && Array.isArray(t)) {
308
- if (e.length !== t.length) return !1;
309
- for (let n = 0; n < e.length; n++)
310
- if (!K(e[n], t[n])) return !1;
311
- return !0;
312
- }
313
- if (R(e) && R(t)) {
314
- const n = Object.keys(e), o = Object.keys(t);
315
- if (n.length !== o.length) return !1;
316
- for (const r of n)
317
- if (!Object.prototype.hasOwnProperty.call(t, r) || !K(e[r], t[r])) return !1;
318
- return !0;
319
- }
320
- return !1;
321
- }
322
- function lt(e, t, n) {
323
- const o = e.length, r = t.length, u = /* @__PURE__ */ new Map();
324
- for (let c = 0; c < r; c++) {
325
- const i = n ? n(t[c]) : JSON.stringify(t[c]);
326
- u.has(i) || u.set(i, []), u.get(i).push(c);
327
- }
328
- const l = [], a = /* @__PURE__ */ new Set();
329
- for (let c = 0; c < o; c++) {
330
- const i = e[c], f = n ? n(i) : JSON.stringify(i), p = u.get(f);
331
- if (p) {
332
- for (const v of p)
333
- if (!a.has(v) && K(i, t[v])) {
334
- l.push({ leftIndex: c, rightIndex: v }), a.add(v);
335
- break;
336
- }
337
- }
338
- }
339
- return l;
340
- }
341
- function dt(e, t, n) {
342
- var v, y;
343
- if (K(e, t)) return;
344
- const o = { _t: "a" }, r = ((v = n == null ? void 0 : n.arrays) == null ? void 0 : v.detectMove) !== !1, u = ((y = n == null ? void 0 : n.arrays) == null ? void 0 : y.includeValueOnMove) === !0, l = n == null ? void 0 : n.objectHash;
345
- let a = r ? lt(e, t, l) : [];
346
- if (!l && e.length === t.length && e.length > 0 && a.length < e.length) {
347
- const h = R(e[0]) || Array.isArray(e[0]), b = a.length > 0;
348
- if (h || b) {
349
- a = [];
350
- for (let w = 0; w < e.length; w++)
351
- a.push({ leftIndex: w, rightIndex: w });
352
- }
353
- }
354
- new Set(a.map((h) => h.leftIndex));
355
- const c = new Set(a.map((h) => h.rightIndex)), i = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
356
- for (const h of a)
357
- i.set(h.leftIndex, h.rightIndex), f.set(h.rightIndex, h.leftIndex);
358
- for (let h = 0; h < e.length; h++) {
359
- const b = i.get(h);
360
- if (b !== void 0) {
361
- const w = J(e[h], t[b], n);
362
- if (w !== void 0 && (o[b] = w), r && b !== h) {
363
- const I = `_${h}`, E = u ? [e[h], b, F] : ["", b, F];
364
- o[I] = E;
365
- }
366
- } else {
367
- const w = `_${h}`;
368
- o[w] = [e[h], M, M];
369
- }
370
- }
371
- for (let h = 0; h < t.length; h++)
372
- c.has(h) || (o[h] = [t[h]]);
373
- const p = Object.keys(o);
374
- if (!(p.length === 1 && p[0] === "_t"))
375
- return o;
376
- }
377
- function ft(e, t, n) {
378
- if (K(e, t)) return;
379
- const o = {}, r = Object.keys(e), u = Object.keys(t), l = /* @__PURE__ */ new Set([...r, ...u]);
380
- for (const a of l) {
381
- if (n != null && n.propertyFilter && !n.propertyFilter(a, { left: e, right: t }))
382
- continue;
383
- const c = Object.prototype.hasOwnProperty.call(e, a), i = Object.prototype.hasOwnProperty.call(t, a);
384
- if (c && i) {
385
- const f = J(e[a], t[a], n);
386
- f !== void 0 && (o[a] = f);
387
- } else if (c && !i) {
388
- const f = n != null && n.omitRemovedValues ? 0 : e[a];
389
- o[a] = [f, M, M];
390
- } else !c && i && (o[a] = [t[a]]);
391
- }
392
- return Object.keys(o).length > 0 ? o : void 0;
393
- }
394
- function J(e, t, n) {
395
- if (K(e, t)) return;
396
- if (e === void 0 && t !== void 0) {
397
- const a = n != null && n.cloneDiffValues ? O(t) : t;
398
- return [P(a)];
399
- }
400
- if (typeof e !== typeof t || e instanceof Date != t instanceof Date || e instanceof RegExp != t instanceof RegExp || Array.isArray(e) !== Array.isArray(t)) {
401
- const a = n != null && n.cloneDiffValues ? O(e) : e, c = n != null && n.cloneDiffValues ? O(t) : t;
402
- return [P(a), P(c)];
403
- }
404
- if (Array.isArray(e) && Array.isArray(t))
405
- return dt(e, t, n);
406
- if (R(e) && R(t))
407
- return ft(e, t, n);
408
- const u = n != null && n.cloneDiffValues ? O(e) : e, l = n != null && n.cloneDiffValues ? O(t) : t;
409
- return [P(u), P(l)];
410
- }
411
- function mt(e, t, n) {
412
- return J(e, t, n);
413
- }
414
- function vt(e, t, n) {
415
- const o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map();
416
- for (const a in t) {
417
- if (a === "_t" || !a.startsWith("_")) continue;
418
- const c = parseInt(a.slice(1)), i = t[a];
419
- Array.isArray(i) && (i.length === 3 && i[2] === M ? o.add(c) : i.length === 3 && i[2] === F && r.set(c, i[1]));
420
- }
421
- const u = [];
422
- let l = 0;
423
- for (let a = 0; ; a++) {
424
- const c = a.toString(), i = t[c];
425
- if (i !== void 0)
426
- if (Array.isArray(i) && i.length === 1)
427
- u.push(i[0]);
428
- else {
429
- for (; l < e.length && o.has(l); )
430
- l++;
431
- l < e.length && (u.push(Y(e[l], i)), l++);
432
- }
433
- else {
434
- let f = !1;
435
- for (const [p, v] of r.entries())
436
- if (v === a) {
437
- u.push(e[p]), f = !0;
438
- break;
439
- }
440
- if (!f) {
441
- for (; l < e.length && (o.has(l) || r.has(l)); )
442
- l++;
443
- if (l < e.length)
444
- u.push(e[l]), l++;
445
- else
446
- break;
447
- }
448
- }
449
- }
450
- return u;
451
- }
452
- function yt(e, t, n) {
453
- const o = { ...e };
454
- for (const r in t) {
455
- const u = t[r];
456
- Array.isArray(u) ? u.length === 1 ? o[r] = u[0] : u.length === 3 && u[2] === M ? delete o[r] : u.length === 2 && (o[r] = u[1]) : o[r] = Y(o[r], u);
457
- }
458
- return o;
459
- }
460
- function Y(e, t, n) {
461
- if (t === void 0) return e;
462
- if (Array.isArray(t)) {
463
- if (t.length === 1)
464
- return t[0];
465
- if (t.length === 2)
466
- return t[1];
467
- if (t.length === 3 && t[2] === M)
468
- return;
469
- }
470
- return R(t) && t._t === "a" ? vt(e, t) : R(t) && R(e) ? yt(e, t) : e;
471
- }
472
- function le(e, t, n) {
473
- return Y(e, t);
474
- }
475
- function pt(e) {
476
- const t = { _t: "a" };
477
- for (const n in e)
478
- if (n !== "_t")
479
- if (n.startsWith("_")) {
480
- const o = parseInt(n.slice(1)), r = e[n];
481
- if (Array.isArray(r)) {
482
- if (r.length === 3 && r[2] === M)
483
- t[o] = [r[0]];
484
- else if (r.length === 3 && r[2] === F) {
485
- const u = r[1];
486
- t[`_${u}`] = [r[0], o, F];
487
- }
488
- }
489
- } else {
490
- const o = parseInt(n), r = e[n];
491
- if (Array.isArray(r) && r.length === 1)
492
- t[`_${o}`] = [r[0], M, M];
493
- else {
494
- const u = Z(r);
495
- u !== void 0 && (t[n] = u);
496
- }
497
- }
498
- return t;
499
- }
500
- function ht(e) {
501
- const t = {};
502
- for (const n in e) {
503
- const o = e[n];
504
- if (Array.isArray(o))
505
- o.length === 1 ? t[n] = [o[0], M, M] : o.length === 3 && o[2] === M ? t[n] = [o[0]] : o.length === 2 && (t[n] = [o[1], o[0]]);
506
- else {
507
- const r = Z(o);
508
- r !== void 0 && (t[n] = r);
509
- }
510
- }
511
- return t;
512
- }
513
- function Z(e) {
514
- if (e !== void 0) {
515
- if (Array.isArray(e)) {
516
- if (e.length === 1)
517
- return [e[0], M, M];
518
- if (e.length === 2)
519
- return [e[1], e[0]];
520
- if (e.length === 3 && e[2] === M)
521
- return [e[0]];
522
- if (e.length === 3 && e[2] === F)
523
- return e;
524
- }
525
- return R(e) && e._t === "a" ? pt(e) : R(e) ? ht(e) : e;
526
- }
527
- }
528
- function de(e) {
529
- return Z(e);
530
- }
531
- function gt(e, t, n) {
532
- const o = de(t);
533
- return le(e, o);
534
- }
535
- class _t {
536
- constructor(t) {
537
- ne(this, "options");
538
- this.options = t || {};
539
- }
540
- diff(t, n) {
541
- return mt(t, n, this.options);
542
- }
543
- patch(t, n) {
544
- return le(t, n, this.options);
545
- }
546
- reverse(t) {
547
- return de(t);
548
- }
549
- unpatch(t, n) {
550
- return gt(t, n, this.options);
551
- }
552
- clone(t) {
553
- return O(t);
554
- }
555
- }
556
- function St(e) {
557
- return new _t(e);
558
- }
559
- function bt({
560
- maxHistorySize: e = 10
561
- }) {
562
- const t = St({
563
- objectHash: (y) => y._id || y.id,
564
- arrays: {
565
- detectMove: !0,
566
- includeValueOnMove: !1
567
- },
568
- cloneDiffValues: !1
569
- }), n = j(null), o = j([]), r = B(-1), u = j(null), l = S(() => r.value > 0), a = S(() => r.value < o.value.length - 1);
570
- function c(y) {
571
- if (n.value === null) {
572
- n.value = C(y), u.value = C(y), o.value = [{ delta: null }], r.value = 0;
573
- return;
574
- }
575
- const h = t.diff(u.value, y);
576
- if (r.value < o.value.length - 1 && (o.value = o.value.slice(0, r.value + 1)), o.value.push({ delta: h }), r.value++, u.value = C(y), o.value.length > e) {
577
- const b = o.value[1].delta;
578
- b && n.value && (n.value = t.patch(C(n.value), b)), o.value.shift(), r.value--;
579
- }
580
- }
581
- function i(y) {
582
- if (!n.value || y < 0 || y >= o.value.length)
583
- return;
584
- let h = C(n.value);
585
- for (let b = 1; b <= y; b++) {
586
- const w = o.value[b];
587
- w.delta && (h = t.patch(h, w.delta));
588
- }
589
- return h;
590
- }
591
- function f() {
592
- if (l.value) {
593
- r.value--;
594
- const y = i(r.value);
595
- return y && (u.value = C(y)), y;
596
- }
597
- }
598
- function p() {
599
- if (a.value) {
600
- r.value++;
601
- const y = i(r.value);
602
- return y && (u.value = C(y)), y;
603
- }
604
- }
605
- function v() {
606
- n.value = null, u.value = null, o.value = [], r.value = -1;
607
- }
608
- return {
609
- push: c,
610
- canUndo: l,
611
- canRedo: a,
612
- undo: f,
613
- redo: p,
614
- clear: v
615
- };
616
- }
617
- const wt = {
618
- async updateMenuModule(e, t) {
619
- const n = G.RequestRunner.operation(t, e.modules);
620
- if (n.validateError.length > 0)
621
- throw new Error(n.validateError.join(`
622
- `));
623
- const o = {
624
- ...e,
625
- modules: n.result || e.modules,
626
- _rev: n.id ?? ""
627
- };
628
- return ie.cloneDeep({ menu: o, updateId: n.id ?? null });
629
- }
630
- };
631
- function fe() {
632
- return {
633
- _id: "",
634
- masterCatalogSetting: { inclusiveTaxes: [] },
635
- modules: {
636
- catalog: [],
637
- category: [],
638
- group: [],
639
- item: [],
640
- printDepartment: [],
641
- scheduler: [],
642
- takeaway: [],
643
- variant: [],
644
- sku: [],
645
- recipe: [],
646
- unit: [],
647
- cookingGuide: [],
648
- serveSequence: [],
649
- subCategory: []
650
- },
651
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
652
- };
653
- }
654
- function Mt() {
655
- return {
656
- restaurants: [],
657
- menu: { ...fe(), _rev: "" },
658
- currentCatalogId: null,
659
- currentCategoryIds: null,
660
- currentSchedulerId: "",
661
- currentRestaurantAttrParams: {
662
- restaurantCustomAttributes: null,
663
- restaurantAttributes: null
664
- }
665
- };
666
- }
667
- const $t = Ze(
668
- "mf-menu-store-v2",
669
- () => {
670
- const e = Qe(Mt()), t = se(), n = tt(), o = S(() => e.menu.modules.serveSequence ? x(e.menu.modules.serveSequence, {
671
- selector: "position"
672
- }) : []), r = S(() => {
673
- var s;
674
- return ((s = t.currentBusiness.value) == null ? void 0 : s.menuVersion) || L.F_MENU_VERSION.v3;
675
- }), u = S(() => r.value === L.F_MENU_VERSION.v4), l = S(() => {
676
- const s = e.menu.modules.catalog;
677
- return x(s, { selector: "name" });
678
- }), a = S(() => {
679
- var d;
680
- let s = e.menu.modules.catalog.find(
681
- (m) => m._id === e.currentCatalogId
682
- );
683
- return s && ((d = s.linkItemRules) != null && d.length) && (s = T.populateCatalog({
684
- catalog: s,
685
- ruleGroupSettings: e.menu.ruleGroupSettings,
686
- items: e.menu.modules.item,
687
- ...e.currentRestaurantAttrParams ?? {}
688
- })), s;
689
- }), c = S(() => x(p.value.modules.scheduler, { selector: "name" })), i = S(() => e.menu.modules.scheduler.find(
690
- (s) => s._id === e.currentSchedulerId
691
- ));
692
- function f(s, d = !0) {
693
- e.menu = { ...s, _rev: e.menu._rev }, d && D.push(e.menu);
694
- }
695
- const p = j(fe()), v = B(!1), y = B(1);
696
- async function h() {
697
- var m;
698
- v.value = !0;
699
- let s = e.menu.modules.catalog;
700
- if (a.value && ((m = a.value.linkItemRules) != null && m.length)) {
701
- const g = T.populateCatalog({
702
- catalog: a.value,
703
- ruleGroupSettings: e.menu.ruleGroupSettings,
704
- items: e.menu.modules.item,
705
- ...e.currentRestaurantAttrParams ?? {}
706
- });
707
- s = e.menu.modules.catalog.map((_) => _._id === (g == null ? void 0 : g._id) ? g : _);
708
- }
709
- const d = await ce(
710
- {
711
- ...e.menu,
712
- modules: {
713
- ...e.menu.modules,
714
- catalog: s
715
- }
716
- },
717
- e.currentCatalogId,
718
- e.currentSchedulerId
719
- );
720
- if (e.currentSchedulerId != null) {
721
- const g = e.menu.modules.catalog.find(
722
- (k) => k._id === e.currentCatalogId
723
- ), _ = g ? g.override.scheduler[e.currentSchedulerId] : e.menu.modules.scheduler.find(
724
- (k) => k._id === e.currentSchedulerId
725
- ), A = new Set(((_ == null ? void 0 : _.items) || []).map((k) => k._id));
726
- d.modules.item = d.modules.item.filter((k) => A.has(k._id));
727
- }
728
- return p.value = d, v.value = !1, y.value = y.value + 1, d;
729
- }
730
- const w = ie.debounce(h, 200);
731
- let I = null, E = null;
732
- function Q() {
733
- E && (E(), E = null), I && I.stop(), I = Xe(!0), E = I.run(() => et(
734
- () => [e.menu, e.currentCatalogId, e.currentSchedulerId],
735
- () => {
736
- v.value || w();
737
- }
738
- )) || null;
739
- }
740
- Q();
741
- const me = S(() => [
742
- {
743
- label: "Main",
744
- value: null
745
- },
746
- ...l.value.map((s) => ({
747
- label: s.name,
748
- value: s._id
749
- }))
750
- ]), X = S(() => {
751
- const s = p.value.modules.category;
752
- return [
753
- ...U.value.item.addon ? [
754
- {
755
- _id: e.currentCatalogId ? "" : null,
756
- name: "Addon",
757
- position: 0
758
- }
759
- ] : [],
760
- ...V(s, (d) => d.name)
761
- ];
762
- }), ve = S(() => {
763
- const s = p.value.modules.subCategory || [];
764
- return V(s, (d) => d.name);
765
- }), ee = S(() => {
766
- var d;
767
- let s = p.value.modules.item;
768
- if (a.value) {
769
- const m = (d = a.value) == null ? void 0 : d.override.items;
770
- s = s.filter((g) => {
771
- var A;
772
- const _ = (A = m == null ? void 0 : m[g._id]) == null ? void 0 : A.find(
773
- (k) => !k.combinationKey
774
- );
775
- return (_ == null ? void 0 : _.orderFrom) !== ue.F_ORDER_FROM.enum.NONE;
776
- });
777
- }
778
- return V(s, (m) => m.code || m.name);
779
- }), ye = S(() => {
780
- const s = e.menu.modules.category, d = V(s, (g) => g.name).reduce(
781
- (g, _, A) => (g[_._id] = A, g),
782
- { "": 0 }
783
- ), m = e.menu.modules.item;
784
- return V(
785
- m,
786
- (g) => g.code || g.name
787
- ).reduce((g, _, A) => (g[_._id] = A + d[_.category || ""], g), {});
788
- }), pe = S(() => oe(N.value, X.value, ee.value)), he = S(() => {
789
- const s = U.value.item.addon ? [
790
- {
791
- _id: e.currentCatalogId ? "" : null,
792
- name: "Addon",
793
- position: 0
794
- },
795
- ...e.menu.modules.category
796
- ] : e.menu.modules.category;
797
- return oe(
798
- e.menu.modules.variant,
799
- s,
800
- e.menu.modules.item
801
- );
802
- }), N = S(() => {
803
- const s = p.value.modules.variant;
804
- return x(s, { selector: "name" });
805
- });
806
- function ge(s = []) {
807
- const d = s.map((g) => N.value.find((_) => _._id === g)).filter((g) => !!g);
808
- return T.fullVariantCombination(d).reduce((g, _) => (g[_.combinationKey] = _.selectionName.join(" / "), g), {});
809
- }
810
- const _e = S(() => V(p.value.modules.group, (s) => s.name)), Se = S(() => x(p.value.modules.takeaway, { selector: "name" })), be = S(() => x(e.menu.modules.printDepartment || [], {
811
- selector: "name"
812
- })), we = S(() => x(e.menu.modules.unit, { selector: "name" })), Me = S(() => x(qe(e.menu.modules.recipe, e.menu.modules.sku), {
813
- selector: "name"
814
- })), Ae = S(() => e.menu.modules.cookingGuide), Ce = S(() => {
815
- const s = ze(e.menu.modules.sku);
816
- return x(s, { selector: "code" });
817
- }), Ie = S(() => {
818
- const s = /* @__PURE__ */ new Map();
819
- return e.menu.modules.item.forEach((d) => {
820
- var m, g;
821
- d.code && s.set(d.code, (s.get(d.code) || 0) + 1), (g = (m = d.variant) == null ? void 0 : m.variantCombinations) == null || g.forEach((_) => {
822
- _.code && s.set(_.code, (s.get(_.code) || 0) + 1);
823
- });
824
- }), s;
825
- }), U = S(() => {
826
- const s = !e.currentCatalogId, d = r.value === L.F_MENU_VERSION.v4, m = !e.currentSchedulerId, g = {
827
- create: s && m,
828
- edit: s && m,
829
- delete: s && m
830
- };
831
- return {
832
- item: {
833
- ...g,
834
- edit: d || m,
835
- sort: d && s && m,
836
- addon: d,
837
- code: m,
838
- name: s && m,
839
- description: s && m,
840
- category: m,
841
- thumbnail: s && m,
842
- orderFrom: (d || s) && m,
843
- orderFromNone: s,
844
- orderFromActiveOnly: !d,
845
- openPrice: s && m,
846
- unit: s && m,
847
- price: s,
848
- editPrice: s,
849
- minPrice: d && m,
850
- costing: d && s && m,
851
- tax: s && m,
852
- variant: s && m,
853
- maxVariant: d ? 4 : 2,
854
- group: s && m,
855
- overrideProductGroup: d && m,
856
- inventory: (d || s) && m,
857
- bindToVariant: d,
858
- print: s && m,
859
- toRoot: d && m,
860
- takeaway: (_) => !!_ && (d || s) && m,
861
- multiScheduler: d,
862
- canRearrange: d,
863
- printConfig: d
864
- },
865
- category: {
866
- ...g,
867
- sort: s,
868
- overrideSequence: d
869
- },
870
- group: {
871
- ...g,
872
- edit: d || m,
873
- sort: s,
874
- applyProduct: s,
875
- showAppliedProduct: m,
876
- type: !d,
877
- insertRawItems: !d,
878
- multiScheduler: d
879
- },
880
- scheduler: {
881
- override: d
882
- },
883
- takeaway: {
884
- ...g,
885
- edit: (d || s) && m,
886
- name: s
887
- },
888
- catalog: {
889
- name: !s,
890
- defaultOrderFrom: d,
891
- markup: d
892
- }
893
- };
894
- });
895
- function W(s) {
896
- return `${s.systemCode}/${s.taxCode}`;
897
- }
898
- function Ee(s) {
899
- const [d, m] = s.split("/");
900
- return { systemCode: d, taxCode: m };
901
- }
902
- function Re(s, d, m) {
903
- return (s ?? d ?? []).map((g) => W(g)).find((g) => m.some((_) => _.value === g));
904
- }
905
- const ke = S(() => {
906
- var g;
907
- const s = ["SV5", "SV10"], d = Ge.Country.getCountryFlattenTaxes(
908
- se().currentCountry.value
909
- ), m = d.filter((_) => u.value || !s.includes(_.taxCode)).map((_) => ({
910
- label: `${_.name} (${Be(_.rate)}%)`,
911
- value: W(_),
912
- meta: {
913
- rate: _.rate
914
- }
915
- }));
916
- return m.sort((_, A) => _.label.localeCompare(A.label, void 0, { numeric: !0 })), {
917
- systemCode: (g = d[0]) == null ? void 0 : g.systemCode,
918
- countryTaxOptions: m
919
- };
920
- }), xe = async () => {
921
- const s = await Ye.readMenu();
922
- e.menu = s ?? e.menu, te(null);
923
- }, Oe = async () => {
924
- const { fetchAllRestaurants: s } = Je();
925
- await s({
926
- onBatchEnd: (d) => {
927
- e.restaurants = d;
928
- }
929
- });
930
- }, te = (s) => {
931
- e.currentCatalogId = s;
932
- }, De = (s) => {
933
- e.currentSchedulerId = s;
934
- }, Ve = (s) => {
935
- e.currentCategoryIds = s;
936
- }, Te = (s) => {
937
- e.currentRestaurantAttrParams = s;
938
- }, Fe = async (s, d) => {
939
- const m = Array.isArray(s) ? s : [s];
940
- if (!m.length) return;
941
- const g = m.map((_) => ({
942
- ..._,
943
- _id: e.menu._id,
944
- _rev: e.menu._rev
945
- }));
946
- try {
947
- if (d || g.some(
948
- (A) => [G.F_OPERATION_TYPE.delete, G.F_OPERATION_TYPE.deleteMany].includes(A.operation)
949
- )) {
950
- const A = await He(g, e.menu.modules);
951
- if (A !== !0) throw new Error(A);
952
- }
953
- const _ = await wt.updateMenuModule(e.menu, g);
954
- return f(_.menu), _;
955
- } catch (_) {
956
- n.open({
957
- type: "error",
958
- title: "Failed to update menu",
959
- message: _
960
- });
961
- }
962
- }, Ke = async (s) => {
963
- const d = {
964
- ...e.menu,
965
- masterCatalogSetting: s.masterCatalogSetting,
966
- lowStockThreshold: s.lowStockThreshold,
967
- priceTierSettings: s.priceTierSettings
968
- };
969
- return f(d), d;
970
- }, D = bt({ maxHistorySize: 50 }), Pe = S(() => D.canUndo.value), $e = S(() => D.canRedo.value), je = () => {
971
- const s = D.undo();
972
- s && f(s, !1);
973
- }, Ne = () => {
974
- const s = D.redo();
975
- s && f(s, !1);
976
- }, Ue = () => {
977
- D.clear();
978
- };
979
- return {
980
- state: e,
981
- // loading state
982
- workerIsComputing: v,
983
- mergedMenuChangeId: y,
984
- // async computed state
985
- mergedMenu: p,
986
- // Computed
987
- version: r,
988
- isV4: u,
989
- serveSequence: o,
990
- catalogs: l,
991
- currentCatalog: a,
992
- schedulers: c,
993
- currentScheduler: i,
994
- catalogOptions: me,
995
- categories: X,
996
- subcategories: ve,
997
- items: ee,
998
- sortedItems: ye,
999
- itemCodeMap: Ie,
1000
- categorizedItems: pe,
1001
- categorizedRawMenuItems: he,
1002
- variants: N,
1003
- groups: _e,
1004
- takeaways: Se,
1005
- printDepartments: be,
1006
- units: we,
1007
- recipes: Me,
1008
- cookingGuide: Ae,
1009
- skus: Ce,
1010
- rules: U,
1011
- taxSetting: ke,
1012
- // Action
1013
- setMenu: f,
1014
- readMenu: xe,
1015
- readRestaurants: Oe,
1016
- selectCatalog: te,
1017
- selectScheduler: De,
1018
- selectCategory: Ve,
1019
- setRestaurantAttrParams: Te,
1020
- updateMenu: Fe,
1021
- updateMenuSetting: Ke,
1022
- computeMergedMenu: h,
1023
- // helper
1024
- encodeTax: W,
1025
- decodeTax: Ee,
1026
- getSelectedTax: Re,
1027
- mapVariant: ge,
1028
- // history
1029
- canUndoHistory: Pe,
1030
- canRedoHistory: $e,
1031
- undoHistory: je,
1032
- redoHistory: Ne,
1033
- // cleanup
1034
- $dispose: () => {
1035
- w.cancel(), E && (E(), E = null), I && (I.stop(), I = null), Ue();
1036
- },
1037
- $reinitialize: () => {
1038
- Q();
1039
- }
1040
- };
1041
- }
1042
- );
1043
- export {
1044
- Tt as a,
1045
- Ft as b,
1046
- Kt as c,
1047
- Pt as f,
1048
- Vt as g,
1049
- Dt as m,
1050
- it as o,
1051
- $t as u
1052
- };