@feedmepos/mf-menu 0.31.33-beta.7 → 0.31.33-beta.8

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 (85) hide show
  1. package/dist/{App-CZEABsQj.js → App-BAMi-a9P.js} +6 -6
  2. package/dist/{ApplyProduct.vue_vue_type_script_setup_true_lang-D_ak48OL.js → ApplyProduct.vue_vue_type_script_setup_true_lang-BWgnvXjy.js} +20 -20
  3. package/dist/{Catalog-DS7IAwCI.js → Catalog-DiPY42vz.js} +6 -6
  4. package/dist/{Category-DKes4JxR.js → Category-B9jnFDvG.js} +14 -14
  5. package/dist/{Category-Bi3vbTgq.js → Category-ClrACB2e.js} +19 -19
  6. package/dist/{CookingGuide-Cl-JvfNC.js → CookingGuide-1553FWRH.js} +4 -4
  7. package/dist/{CustomAttributeChip.vue_vue_type_script_setup_true_lang-C01PGALf.js → CustomAttributeChip.vue_vue_type_script_setup_true_lang-DWNx15iJ.js} +1 -1
  8. package/dist/{Group-CDmNdtn6.js → Group-DLahX8qi.js} +3 -3
  9. package/dist/{Group-CPd33rHj.js → Group-l_-qZSyF.js} +1 -1
  10. package/dist/{Group.vue_vue_type_script_setup_true_lang-DLhPMn7r.js → Group.vue_vue_type_script_setup_true_lang-PNpEgEGB.js} +9 -9
  11. package/dist/GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-DoVyIdTN.js +364 -0
  12. package/dist/{ImportProductDialog.vue_vue_type_script_setup_true_lang-DZgnCsAY.js → ImportProductDialog.vue_vue_type_script_setup_true_lang-DSspLK4i.js} +12597 -12946
  13. package/dist/{Ingredient-C5iKMG5S.js → Ingredient-SsBtwYjB.js} +3 -3
  14. package/dist/{InventoryBinding.vue_vue_type_script_setup_true_lang-CYb8p8df.js → InventoryBinding.vue_vue_type_script_setup_true_lang-DqnVkfjW.js} +2 -2
  15. package/dist/LinkProductSideSheet-CncbzDh3.js +335 -0
  16. package/dist/{MenuSetting-DeLFW5Q0.js → MenuSetting-D28a3uD4.js} +4 -4
  17. package/dist/{PrintRoute-BptA-_Yt.js → PrintRoute-BdlT0DDr.js} +89 -88
  18. package/dist/{Product-D5WYsf9P.js → Product-s5Q4wV8i.js} +1 -1
  19. package/dist/Product.vue_vue_type_script_setup_true_lang-C6iDgQEU.js +1575 -0
  20. package/dist/{ProductInternalTools-_ml77R5u.js → ProductInternalTools-DjSkvzw2.js} +5 -5
  21. package/dist/Products-B3tF_gCa.js +283 -0
  22. package/dist/{Publish-BB_8J3PJ.js → Publish-G4bwUpme.js} +3 -3
  23. package/dist/{Recipe-Dc7mD-Mu.js → Recipe-BxgHUzb5.js} +4 -4
  24. package/dist/{Scheduler-H2mx0WJm.js → Scheduler-DJSKWS-9.js} +3 -3
  25. package/dist/{ServingSequence-GYdFh7RK.js → ServingSequence-_cmuGKlV.js} +3 -3
  26. package/dist/{Setting-B_-Bv8NR.js → Setting-Dx7ycxAn.js} +5 -5
  27. package/dist/{Subcategory-CHcCMqcS.js → Subcategory-25AzJQYt.js} +4 -4
  28. package/dist/{Takeaway-BeDox-sK.js → Takeaway-Bmm9d5PO.js} +1 -1
  29. package/dist/{Takeaway-BaDz1y8l.js → Takeaway-CcFK-Y2z.js} +4 -4
  30. package/dist/{Takeaway.vue_vue_type_script_setup_true_lang-CwWyzrey.js → Takeaway.vue_vue_type_script_setup_true_lang-Bl5OAG3c.js} +5 -5
  31. package/dist/Thumbnail.vue_vue_type_script_setup_true_lang-B3-ypwE7.js +431 -0
  32. package/dist/TreeEditorOpenner.vue_vue_type_script_setup_true_lang-D2gzS8Q_.js +5990 -0
  33. package/dist/{Unit-D4uSc8lg.js → Unit-Cs1EOuyg.js} +2 -2
  34. package/dist/{Variant-MVe8LhBc.js → Variant-BTCkw4RC.js} +3 -3
  35. package/dist/_id_-C9b2WHzy.js +202 -0
  36. package/dist/{app-BbIBgy7D.js → app-BhI1mPRh.js} +1 -1
  37. package/dist/{app-B0ogzdm0.js → app-CU2frfPB.js} +24 -24
  38. package/dist/app.js +1 -1
  39. package/dist/apps/mf-menu/src/components/feature/RestaurantAttributesSelector.vue.d.ts +33 -0
  40. package/dist/apps/mf-menu/src/components/feature/TreeEditor/composable/catalog.d.ts +2 -0
  41. package/dist/apps/mf-menu/src/components/feature/TreeEditor/store/menuV2.d.ts +3 -1
  42. package/dist/apps/mf-menu/src/composable/customAttributes.d.ts +8 -0
  43. package/dist/apps/mf-menu/src/composable/linkProducts.d.ts +1276 -0
  44. package/dist/apps/mf-menu/src/types/linkProducts.d.ts +21 -0
  45. package/dist/apps/mf-menu/src/views/PrintRoute/PrintDepartmentDialog.vue.d.ts +5 -3
  46. package/dist/apps/mf-menu/tsconfig.app.tsbuildinfo +1 -1
  47. package/dist/assets/{linked-status-DepVvcGX.js → linked-status-r8YcmOs7.js} +2 -2
  48. package/dist/assets/{override-menu-Cb7cvOj9.js → override-menu-CDLCS1zK.js} +2 -2
  49. package/dist/assets/{validate-menu-Hc7m9hHC.js → validate-menu-B-FxrVmM.js} +2 -2
  50. package/dist/{catalog-_R7Bi_aW.js → catalog-BudDGPc1.js} +1 -1
  51. package/dist/{catalogSetting-Bnr55VnE.js → catalogSetting-Bk1QEBg5.js} +1 -1
  52. package/dist/{category-C0kozMAs.js → category-UDpJb7Yh.js} +1 -1
  53. package/dist/{currency-DFA-7C9k.js → currency-BQIQArxm.js} +1 -1
  54. package/dist/{dayjs.min-BzOsbxFW.js → dayjs.min-D0EjAkx4.js} +1 -1
  55. package/dist/{index-asthzgeW.js → index-B_V5s58T.js} +1 -1
  56. package/dist/{index-LrL2OIsF.js → index-CirrSmpA.js} +3 -3
  57. package/dist/index-DRuDRGm-.js +213 -0
  58. package/dist/{index-y3TkmTDS.js → index-Dy-u7imh.js} +3 -3
  59. package/dist/{item-BHFMgTjL.js → item-C45Oe5Un.js} +196 -194
  60. package/dist/{jszip.min-BYCWga7V.js → jszip.min-BR_8QNuk.js} +245 -245
  61. package/dist/{menu-7YBc_V0y.js → menu-D52oU1sw.js} +1 -1
  62. package/dist/{menu-UNNs3oeu.js → menu-DTlhFcnq.js} +1079 -1070
  63. package/dist/menuV2-DQtEtGVV.js +707 -0
  64. package/dist/mf-menu.css +1 -1
  65. package/dist/{priceTier-I7O5kuz-.js → priceTier-CDyccedV.js} +1 -1
  66. package/dist/{scheduler-c0cSXqeD.js → scheduler-DHjrtU8G.js} +16 -17
  67. package/dist/subcategory-0ajMWsb2.js +148 -0
  68. package/dist/{toExcel-C8d-m0RH.js → toExcel-BNKDwOzQ.js} +2 -2
  69. package/dist/{unit-B0Bl56gY.js → unit-CBe6cpyB.js} +5 -4
  70. package/package.json +2 -2
  71. package/dist/FormItem.vue_vue_type_script_setup_true_lang-BmPAVphe.js +0 -26
  72. package/dist/GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-DW1ET8Ys.js +0 -372
  73. package/dist/LinkProductSideSheet-QUllj_xC.js +0 -112
  74. package/dist/Product.vue_vue_type_script_setup_true_lang-TwmxZaik.js +0 -1644
  75. package/dist/Products-BA-G2Yya.js +0 -270
  76. package/dist/Thumbnail.vue_vue_type_script_setup_true_lang-DzQ8_6Bi.js +0 -71
  77. package/dist/TreeEditorOpenner.vue_vue_type_script_setup_true_lang-Dp2eaieu.js +0 -6149
  78. package/dist/_id_-CoMVzmjC.js +0 -178
  79. package/dist/apps/mf-menu/src/components/feature/AttributesSelector.vue.d.ts +0 -2
  80. package/dist/apps/mf-menu/src/components/feature/LinkProduct/LinkProductSideSheet.vue.d.ts +0 -70
  81. package/dist/apps/mf-menu/src/components/feature/LinkProduct/LinkProductUnifiedSideSheet.vue.d.ts +0 -12
  82. package/dist/customAttributes-C1FljtXt.js +0 -33
  83. package/dist/index-Ce4v8o7D.js +0 -106
  84. package/dist/subcategory-YHkkwrLj.js +0 -817
  85. /package/dist/{app-DvG3mOom.js → LinkProductSideSheet.vue_vue_type_style_index_0_scoped_7d7fe73f_lang-DvG3mOom.js} +0 -0
@@ -0,0 +1,1575 @@
1
+ import { ref as I, computed as h, defineComponent as N, resolveComponent as z, createBlock as $, openBlock as m, withCtx as P, createElementVNode as g, createVNode as d, unref as a, createElementBlock as C, Fragment as de, renderList as ke, createCommentVNode as R, normalizeClass as me, toDisplayString as K, withModifiers as ve, mergeModels as Ze, useModel as Je, renderSlot as _e, watch as ie, createTextVNode as Xe, watchEffect as et, nextTick as Pe, resolveDynamicComponent as tt, onMounted as lt, h as G, isRef as Be, normalizeStyle as ft } from "vue";
2
+ import { u as Fe, Q as xe, A as ce, H as Ae, I as ge, U as gt, aa as bt, ab as _t, ac as Te, ad as yt, P as ht, ae as je } from "./menu-DTlhFcnq.js";
3
+ import { useI18n as Ve, useCoreStore as Me } from "@feedmepos/mf-common";
4
+ import { u as we } from "./menu-D52oU1sw.js";
5
+ import { _ as be } from "./index.vue_vue_type_script_setup_true_lang-BgqsTzLI.js";
6
+ import { u as xt, L as Ee } from "./LinkProductSideSheet-CncbzDh3.js";
7
+ import { r as Ct, _ as Ge } from "./index-DRuDRGm-.js";
8
+ import { _ as Re, a as Le } from "./CustomAttributeChip.vue_vue_type_script_setup_true_lang-DWNx15iJ.js";
9
+ import { _ as Ue, u as kt } from "./Thumbnail.vue_vue_type_script_setup_true_lang-B3-ypwE7.js";
10
+ import { f as wt, o as St, a as Ft, m as Vt } from "./menuV2-DQtEtGVV.js";
11
+ import { u as at, C as It } from "./item-C45Oe5Un.js";
12
+ import { b as qe, H as $t } from "./LinkProductSideSheet.vue_vue_type_style_index_0_scoped_7d7fe73f_lang-DvG3mOom.js";
13
+ import { useBreakpoints as ot, components as le, useDialog as Tt, FmButtonColorThemeVariant as L, FmButtonVariant as te } from "@feedmepos/ui-library";
14
+ import { F as Pt } from "./index-B_V5s58T.js";
15
+ import { _ as Oe, u as At } from "./app-CU2frfPB.js";
16
+ import { _ as Ce } from "./TextChip.vue_vue_type_script_setup_true_lang-8frWuZFL.js";
17
+ import { _ as Rt } from "./index-CirrSmpA.js";
18
+ import { r as Ut, _ as Mt } from "./ImportProductDialog.vue_vue_type_script_setup_true_lang-DSspLK4i.js";
19
+ import { c as Ot } from "./check-C9mY6LiX.js";
20
+ import { f as zt } from "./currency-BQIQArxm.js";
21
+ import { w as Dt } from "./tooltip-B5BiPMx9.js";
22
+ function Kt(k, e) {
23
+ const r = I(!0), i = h(() => {
24
+ var s, f;
25
+ return !r.value && (!e.value || ((s = e.value) == null ? void 0 : s.length) === ((f = k.value) == null ? void 0 : f.length));
26
+ }), l = h(() => {
27
+ var s, f, p, b;
28
+ return !!((s = e.value) != null && s.length && ((f = e.value) == null ? void 0 : f.length) > 0 && ((p = e.value) == null ? void 0 : p.length) < ((b = k.value) == null ? void 0 : b.length));
29
+ });
30
+ return { allCleared: r, allSelected: i, indeterminate: l, toggleAll: () => {
31
+ e.value = void 0, r.value = !r.value;
32
+ }, toggleOption: (s) => {
33
+ var p, b, y;
34
+ let f;
35
+ e.value === void 0 && r.value ? f = [s] : e.value === void 0 && !r.value ? f = (p = k.value.map((w) => w.value)) == null ? void 0 : p.filter((w) => w !== s) : (b = e.value) != null && b.includes(s) ? f = (y = e.value) == null ? void 0 : y.filter((w) => w !== s) : f = [...e.value || [], s], f.length === 0 ? (e.value = void 0, r.value = !0) : f.length === k.value.length ? (e.value = void 0, r.value = !1) : e.value = f;
36
+ } };
37
+ }
38
+ const Nt = { class: "inline-flex items-center" }, Bt = {
39
+ key: 0,
40
+ class: /* @__PURE__ */ me([
41
+ "fm-typo-en-body-md-600 select-none text-ellipsis overflow-hidden whitespace-nowrap",
42
+ "text-fm-color-neutral-gray-400"
43
+ ])
44
+ }, jt = { class: "p-4" }, Et = { class: "flex-1 overflow-y-auto min-h-0" }, We = /* @__PURE__ */ N({
45
+ __name: "CategorySelector",
46
+ emits: ["toggleAttributeFilter"],
47
+ setup(k, { emit: e }) {
48
+ const r = e, i = Fe(), { categories: l, selectedCategories: u } = we(), t = h(() => i.state.currentCategoryIds), s = h(
49
+ () => l.value.map((D) => ({ label: D.name, value: D.id }))
50
+ ), f = h(() => s.value.filter(
51
+ (D) => D.label.toLowerCase().includes(y.value.toLowerCase())
52
+ )), { t: p } = Ve(), b = h(() => {
53
+ var D, O, W;
54
+ return l.value.length === ((D = u.value) == null ? void 0 : D.length) ? p("menu.category.selector.all") : ((O = u.value) == null ? void 0 : O.length) === 1 ? u.value[0].name : `${(W = u.value) == null ? void 0 : W.length}`;
55
+ }), y = I(""), w = h({
56
+ get: () => t.value,
57
+ set: (D) => {
58
+ i.selectCategory(D);
59
+ }
60
+ }), { allSelected: q, toggleAll: Y, toggleOption: S, indeterminate: ne } = Kt(
61
+ s,
62
+ w
63
+ ), Z = Me(), re = h(() => Z.itemAttributeSettings.value.length > 0);
64
+ function E() {
65
+ r("toggleAttributeFilter");
66
+ }
67
+ return (D, O) => {
68
+ const W = z("FmIcon"), J = z("FmChip"), se = z("FmSearch"), H = z("FmMenuItem"), M = z("FmMenu");
69
+ return m(), $(M, {
70
+ "close-on-click": !1,
71
+ width: 220
72
+ }, {
73
+ "menu-button": P(() => [
74
+ g("div", Nt, [
75
+ d(J, null, {
76
+ default: P(() => [
77
+ b.value ? (m(), C("div", Bt, K(a(p)("menu.category.selector.title", { label: b.value })), 1)) : R("", !0),
78
+ d(W, {
79
+ color: "neutral-gray-400",
80
+ name: "expand_more",
81
+ size: "sm"
82
+ }),
83
+ re.value ? (m(), C("div", {
84
+ key: 1,
85
+ class: "pl-8 flex items-center justify-center border-l border-fm-color-neutral-gray-200",
86
+ onClick: ve(E, ["stop"])
87
+ }, [
88
+ d(W, {
89
+ name: "filter_alt",
90
+ outline: "",
91
+ color: "neutral-gray-400",
92
+ size: "sm",
93
+ onClick: O[0] || (O[0] = ve(() => {
94
+ }, ["prevent"]))
95
+ })
96
+ ])) : R("", !0)
97
+ ]),
98
+ _: 1
99
+ })
100
+ ])
101
+ ]),
102
+ default: P(() => [
103
+ g("div", jt, [
104
+ d(se, {
105
+ autofocus: "",
106
+ modelValue: y.value,
107
+ "onUpdate:modelValue": O[1] || (O[1] = (V) => y.value = V),
108
+ placeholder: a(p)("menu.common.actions.search")
109
+ }, null, 8, ["modelValue", "placeholder"])
110
+ ]),
111
+ g("div", Et, [
112
+ d(H, {
113
+ label: "All",
114
+ "has-checkbox": "",
115
+ "model-value": a(q),
116
+ indeterminate: a(ne),
117
+ onClick: a(Y)
118
+ }, null, 8, ["model-value", "indeterminate", "onClick"]),
119
+ (m(!0), C(de, null, ke(f.value, (V) => {
120
+ var A;
121
+ return m(), $(H, {
122
+ key: V.value || "",
123
+ label: V.label,
124
+ "has-checkbox": "",
125
+ "model-value": a(q) || ((A = w.value) == null ? void 0 : A.includes(V.value)),
126
+ onClick: (T) => a(S)(V.value)
127
+ }, null, 8, ["label", "model-value", "onClick"]);
128
+ }), 128))
129
+ ])
130
+ ]),
131
+ _: 1
132
+ });
133
+ };
134
+ }
135
+ }), Gt = { class: "flex flex-wrap gap-8" }, Lt = { class: "py-12 px-16 space-y-12" }, qt = { class: "fm-typo-en-body-md-600 text-fm-color-neutral-gray-600" }, Wt = { class: "flex flex-wrap gap-8" }, Ht = {
136
+ key: 0,
137
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
138
+ }, Qt = { key: 0 }, Yt = {
139
+ key: 1,
140
+ class: "inline-block w-8"
141
+ }, Zt = { key: 0 }, Jt = { key: 1 }, He = /* @__PURE__ */ N({
142
+ __name: "CategoriesChip",
143
+ props: {
144
+ categories: { default: () => [] },
145
+ ellipsis: { type: Boolean, default: !0 }
146
+ },
147
+ setup(k) {
148
+ const e = k, { t: r } = Ve(), i = ot(), l = h(() => i.breakpoints.value.xs), u = h(() => e.ellipsis ? l.value ? 1 : 2 : 1 / 0), t = h(() => e.categories.length <= u.value ? e.categories : e.categories.slice(0, u.value)), s = I(!0), f = h(() => {
149
+ if (s.value) {
150
+ const b = t.value.join(", ");
151
+ return b.length > 20 ? b.slice(0, 20) + "..." : b;
152
+ }
153
+ return e.categories.join(", ");
154
+ });
155
+ return (p, b) => {
156
+ const y = z("FmTooltip");
157
+ return l.value ? (m(), C(de, { key: 1 }, [
158
+ p.categories.length > 0 ? (m(), C("p", Ht, [
159
+ g("span", null, K(a(r)("menu.product.table.columns.category")) + ": ", 1),
160
+ g("span", null, K(f.value), 1),
161
+ s.value ? (m(), C("span", Yt)) : (m(), C("br", Qt)),
162
+ p.categories.length > u.value ? (m(), C("span", {
163
+ key: 2,
164
+ class: "fm-typo-en-body-md-400 text-fm-color-primary cursor-pointer",
165
+ onClick: b[0] || (b[0] = ve((w) => s.value = !s.value, ["stop", "prevent"]))
166
+ }, [
167
+ s.value ? (m(), C("span", Zt, K(a(r)("menu.product.table.category.expand", { count: p.categories.length - u.value })), 1)) : (m(), C("span", Jt, K(a(r)("menu.product.table.category.collapse")), 1))
168
+ ])) : R("", !0)
169
+ ])) : R("", !0)
170
+ ], 64)) : (m(), $(y, {
171
+ key: 0,
172
+ class: "flex",
173
+ variant: "rich",
174
+ placement: "top",
175
+ "z-index": 50
176
+ }, {
177
+ content: P(() => [
178
+ g("div", Lt, [
179
+ g("p", qt, K(a(r)("menu.product.table.category.all")), 1),
180
+ g("div", Wt, [
181
+ (m(!0), C(de, null, ke(e.categories, (w) => (m(), $(Ce, {
182
+ key: w,
183
+ label: w,
184
+ variant: "neutral"
185
+ }, null, 8, ["label"]))), 128))
186
+ ])
187
+ ])
188
+ ]),
189
+ default: P(() => [
190
+ g("div", Gt, [
191
+ (m(!0), C(de, null, ke(t.value, (w) => (m(), $(Ce, {
192
+ key: w,
193
+ label: w,
194
+ variant: "neutral"
195
+ }, null, 8, ["label"]))), 128)),
196
+ p.categories.length > u.value ? (m(), $(Ce, {
197
+ key: 0,
198
+ label: "...",
199
+ variant: "neutral"
200
+ })) : R("", !0)
201
+ ])
202
+ ]),
203
+ _: 1
204
+ }));
205
+ };
206
+ }
207
+ }), Xt = /* @__PURE__ */ N({
208
+ __name: "ProductSearcher",
209
+ props: /* @__PURE__ */ Ze({
210
+ label: {},
211
+ helperText: {},
212
+ menu: {}
213
+ }, {
214
+ modelValue: { required: !0 },
215
+ modelModifiers: {}
216
+ }),
217
+ emits: ["update:modelValue"],
218
+ setup(k) {
219
+ const e = k, r = Je(k, "modelValue"), i = h(() => e.menu.modules.item.map((l) => ({
220
+ label: l.code ? `${l.code} ${l.name}` : l.name,
221
+ value: l._id
222
+ })));
223
+ return (l, u) => {
224
+ const t = z("FmSelect");
225
+ return m(), $(t, {
226
+ modelValue: r.value,
227
+ "onUpdate:modelValue": u[0] || (u[0] = (s) => r.value = s),
228
+ items: i.value,
229
+ searchable: !0,
230
+ "search-target": "label",
231
+ placeholder: "Search by product name or code",
232
+ label: l.label,
233
+ "helper-text": l.helperText
234
+ }, null, 8, ["modelValue", "items", "label", "helper-text"]);
235
+ };
236
+ }
237
+ }), el = { class: "flex" }, tl = { class: "w-[260px] space-y-16 h-full" }, ll = { class: "flex items-center gap-4 px-8" }, al = { class: "fm-typo-en-title-sm-600" }, ol = {
238
+ key: 0,
239
+ class: "bg-fm-color-neutral-gray-100 rounded-md px-8 py-4"
240
+ }, nl = { class: "fm-typo-en-body-md-600" }, rl = { class: "flex-1" }, nt = /* @__PURE__ */ N({
241
+ __name: "ViewLayout",
242
+ props: /* @__PURE__ */ Ze({
243
+ title: {},
244
+ titleBadge: {},
245
+ items: {}
246
+ }, {
247
+ modelValue: { required: !0 },
248
+ modelModifiers: {}
249
+ }),
250
+ emits: ["update:modelValue"],
251
+ setup(k) {
252
+ const e = Je(k, "modelValue");
253
+ return (r, i) => {
254
+ const l = z("FmCollapsibleTabs");
255
+ return m(), C("div", el, [
256
+ g("div", tl, [
257
+ g("div", ll, [
258
+ g("p", al, K(r.title), 1),
259
+ r.titleBadge !== void 0 ? (m(), C("div", ol, [
260
+ g("p", nl, K(r.titleBadge), 1)
261
+ ])) : R("", !0)
262
+ ]),
263
+ d(Oe, null, {
264
+ default: P(() => [
265
+ d(l, {
266
+ modelValue: e.value,
267
+ "onUpdate:modelValue": i[0] || (i[0] = (u) => e.value = u),
268
+ items: r.items
269
+ }, null, 8, ["modelValue", "items"])
270
+ ]),
271
+ _: 1
272
+ })
273
+ ]),
274
+ i[1] || (i[1] = g("div", { class: "w-[1px] min-h-full ml-4 mr-12 bg-fm-color-neutral-gray-100 self-stretch" }, null, -1)),
275
+ g("div", rl, [
276
+ _e(r.$slots, "default")
277
+ ])
278
+ ]);
279
+ };
280
+ }
281
+ }), Se = /* @__PURE__ */ N({
282
+ __name: "OrderFromChip",
283
+ props: {
284
+ orderFrom: {}
285
+ },
286
+ setup(k) {
287
+ const e = k, r = xe();
288
+ return (i, l) => {
289
+ var u, t;
290
+ return m(), $(Ce, {
291
+ label: ((u = a(r)[e.orderFrom]) == null ? void 0 : u.label) || e.orderFrom,
292
+ variant: (t = a(r)[e.orderFrom]) == null ? void 0 : t.variant
293
+ }, null, 8, ["label", "variant"]);
294
+ };
295
+ }
296
+ }), sl = /* @__PURE__ */ N({
297
+ __name: "GroupViewTable",
298
+ props: {
299
+ data: {}
300
+ },
301
+ setup(k) {
302
+ const e = k, r = [{
303
+ accessorKey: "code",
304
+ header: () => "Code",
305
+ enableSorting: !1,
306
+ cell: ({
307
+ row: t
308
+ }) => {
309
+ const s = t.original;
310
+ return s.subRows ? d("div", {
311
+ class: "flex items-center gap-2 fm-typo-en-body-md-600 text-fm-color-typo-secondary"
312
+ }, [d(le.FmButton, {
313
+ icon: "keyboard_arrow_up",
314
+ variant: "tertiary",
315
+ class: ["cursor-pointer", "transition-transform", t.getIsExpanded() ? "transform rotate-180" : ""],
316
+ onClick: t.getToggleExpandedHandler()
317
+ }, null), Xe("Found in group: "), s.groupName]) : s.code;
318
+ },
319
+ meta: {
320
+ colspan: (t) => t.original.subRows ? 5 : 1
321
+ }
322
+ }, {
323
+ accessorKey: "productName",
324
+ header: () => "Product name",
325
+ enableSorting: !1,
326
+ meta: {
327
+ colspan: (t) => t.original.subRows ? 0 : 1
328
+ }
329
+ }, {
330
+ accessorKey: "variant",
331
+ header: () => "Variant",
332
+ enableSorting: !1,
333
+ meta: {
334
+ colspan: (t) => t.original.subRows ? 0 : 1
335
+ }
336
+ }, {
337
+ accessorKey: "price",
338
+ header: () => "Price",
339
+ enableSorting: !1,
340
+ meta: {
341
+ colspan: (t) => t.original.subRows ? 0 : 1
342
+ }
343
+ }, {
344
+ accessorKey: "orderFrom",
345
+ header: () => "Order from",
346
+ enableSorting: !1,
347
+ cell: (t) => {
348
+ const s = t.row.original;
349
+ return d(Se, {
350
+ orderFrom: s.orderFrom ?? ""
351
+ }, null);
352
+ },
353
+ meta: {
354
+ colspan: (t) => t.original.subRows ? 0 : 1
355
+ }
356
+ }], i = I({}), l = (t) => t.subRows;
357
+ function u() {
358
+ i.value = Object.fromEntries(e.data.map((t, s) => [s, !0]));
359
+ }
360
+ return ie(() => e.data, () => {
361
+ u();
362
+ }), (t, s) => {
363
+ const f = z("FmTable");
364
+ return m(), $(Oe, null, {
365
+ default: P(() => [d(f, {
366
+ "column-defs": r,
367
+ "row-data": t.data,
368
+ "hide-footer": !0,
369
+ "page-size": 1e6,
370
+ "get-sub-row": l,
371
+ "expanded-state": i.value,
372
+ "shrink-at": !1,
373
+ "onUpdate:expandedState": s[0] || (s[0] = (p) => i.value = p)
374
+ }, null, 8, ["row-data", "expanded-state"])]),
375
+ _: 1
376
+ });
377
+ };
378
+ }
379
+ }), ul = /* @__PURE__ */ N({
380
+ __name: "GroupView",
381
+ props: {
382
+ itemId: {},
383
+ menu: {}
384
+ },
385
+ setup(k) {
386
+ const e = k, r = I(""), i = h(() => l.value.reduce((p, b) => p + (typeof b.badge == "number" ? b.badge ?? 1 : 0), 0)), l = I([]), u = h(() => {
387
+ const p = l.value.find((y) => y.value === r.value);
388
+ return ((p == null ? void 0 : p.itemInGroup) || []).map((y) => ({
389
+ groupName: y.group.name,
390
+ subRows: y.items.map((w) => ({
391
+ // @ts-ignore
392
+ code: w.code || w.fallbackCode,
393
+ productName: w.combinationKey ? "" : w.name ?? "",
394
+ price: w.price ? ce.Dinero.fromFdoDinero(w.price).toFormat() : "--",
395
+ orderFrom: w.orderFrom ?? void 0,
396
+ variant: w.combinationKey ? w.name ?? "" : void 0
397
+ }))
398
+ }));
399
+ });
400
+ function t() {
401
+ return [{
402
+ label: "Master product",
403
+ value: "",
404
+ catalogId: null,
405
+ data: [],
406
+ disabled: !1,
407
+ badge: void 0,
408
+ itemInGroup: []
409
+ }, ...e.menu.modules.catalog.map((b) => ({
410
+ label: b.name,
411
+ value: b._id,
412
+ catalogId: b._id,
413
+ data: [],
414
+ disabled: !1,
415
+ badge: void 0,
416
+ itemInGroup: []
417
+ }))];
418
+ }
419
+ h(() => l.value.find((p) => p.value === r.value));
420
+ async function s(p) {
421
+ const b = l.value.find((y) => y.catalogId === p);
422
+ if (b) {
423
+ b.badge = () => d(le.FmCircularProgress, {
424
+ size: "md"
425
+ }, null);
426
+ const y = await wt(Ae(e.menu), p, e.itemId);
427
+ b.badge = y.length, b.disabled = y.length <= 0, b.itemInGroup = y;
428
+ }
429
+ }
430
+ function f() {
431
+ l.value = t(), l.value.forEach((p) => {
432
+ s(p.catalogId);
433
+ });
434
+ }
435
+ return ie([() => e.menu, () => e.itemId], () => {
436
+ e.menu && e.itemId && f();
437
+ }, {
438
+ immediate: !0
439
+ }), (p, b) => (m(), $(nt, {
440
+ modelValue: r.value,
441
+ "onUpdate:modelValue": b[0] || (b[0] = (y) => r.value = y),
442
+ items: l.value,
443
+ title: "Catalog",
444
+ "title-badge": i.value
445
+ }, {
446
+ default: P(() => [d(sl, {
447
+ data: u.value
448
+ }, null, 8, ["data"])]),
449
+ _: 1
450
+ }, 8, ["modelValue", "items", "title-badge"]));
451
+ }
452
+ }), il = {
453
+ class: "scroll-x-auto"
454
+ }, cl = /* @__PURE__ */ N({
455
+ __name: "ProductViewTable",
456
+ props: {
457
+ itemId: {},
458
+ menu: {},
459
+ catalogId: {},
460
+ schedulerIds: {}
461
+ },
462
+ setup(k) {
463
+ const e = k, r = [{
464
+ accessorKey: "scheduler",
465
+ header: () => "Scheduler",
466
+ enableSorting: !1,
467
+ cell: (u) => {
468
+ const t = u.row.original, s = t.loading ? d(le.FmCircularProgress, {
469
+ size: "md"
470
+ }, null) : null;
471
+ return d("div", {
472
+ class: "flex items-center gap-2"
473
+ }, [t.scheduler, s]);
474
+ }
475
+ }, {
476
+ accessorKey: "code",
477
+ header: () => "Code",
478
+ enableSorting: !1
479
+ }, {
480
+ accessorKey: "productName",
481
+ header: () => "Product name",
482
+ enableSorting: !1
483
+ }, {
484
+ accessorKey: "price",
485
+ header: () => "Price",
486
+ enableSorting: !1
487
+ }, {
488
+ accessorKey: "orderFrom",
489
+ header: () => "Order from",
490
+ cell: (u) => {
491
+ const t = u.row.original;
492
+ return d(Se, {
493
+ orderFrom: t.orderFrom
494
+ }, null);
495
+ },
496
+ enableSorting: !1
497
+ }], i = I([]);
498
+ function l(u, t) {
499
+ return {
500
+ loading: !0,
501
+ schedulerId: u,
502
+ scheduler: t,
503
+ code: "--",
504
+ productName: "--",
505
+ price: "--",
506
+ orderFrom: "--"
507
+ };
508
+ }
509
+ return ie([() => e.menu, () => e.catalogId, () => e.schedulerIds], async () => {
510
+ i.value = [l(null, "All day"), ...e.schedulerIds.map((u) => {
511
+ var t;
512
+ return l(u, ((t = e.menu.modules.scheduler.find((s) => s._id === u)) == null ? void 0 : t.name) || "Unknown");
513
+ })], i.value.forEach(async (u) => {
514
+ const s = (await St(Ae(e.menu), e.catalogId, u.schedulerId)).modules.item.find((p) => p._id === e.itemId), f = i.value.findIndex((p) => p.schedulerId === u.schedulerId);
515
+ if (s) {
516
+ const p = Ae(i.value);
517
+ p[f].loading = !1, p[f].code = s.code || "--", p[f].productName = s.name || "--", p[f].price = ce.Dinero.fromFdoDinero(s.price).toFormat(), p[f].orderFrom = s.orderFrom || "--", i.value = p;
518
+ }
519
+ });
520
+ }), (u, t) => {
521
+ const s = z("FmTable");
522
+ return m(), $(Oe, null, {
523
+ default: P(() => [g("div", il, [d(s, {
524
+ class: "min-w-[800px]",
525
+ "column-defs": r,
526
+ "row-data": i.value,
527
+ "hide-footer": !0,
528
+ "page-size": i.value.length,
529
+ "shrink-at": !1
530
+ }, null, 8, ["row-data", "page-size"])])]),
531
+ _: 1
532
+ });
533
+ };
534
+ }
535
+ }), dl = /* @__PURE__ */ N({
536
+ __name: "ProductView",
537
+ props: {
538
+ itemId: {},
539
+ menu: {}
540
+ },
541
+ setup(k) {
542
+ const e = k, r = I(null);
543
+ et(async () => {
544
+ r.value = await Ft(e.menu, e.itemId), await Pe(), i.value = l.value[0].value;
545
+ });
546
+ const i = I(""), l = h(() => {
547
+ var f, p;
548
+ const t = {
549
+ label: "Master product",
550
+ value: "",
551
+ catalogId: null,
552
+ badge: (((f = r.value) == null ? void 0 : f.schedulers.length) || 0) + 1,
553
+ schedulerIds: (p = r.value) == null ? void 0 : p.schedulers
554
+ };
555
+ if (!r.value)
556
+ return [t];
557
+ const s = e.menu.modules.catalog.map((b) => {
558
+ const y = r.value.catalogs[b._id];
559
+ return {
560
+ label: b.name,
561
+ value: b._id,
562
+ disabled: !y,
563
+ catalogId: b._id,
564
+ badge: y ? ((y == null ? void 0 : y.schedulers.length) || 0) + 1 : 0,
565
+ schedulerIds: y == null ? void 0 : y.schedulers
566
+ };
567
+ });
568
+ return [t, ...s];
569
+ }), u = h(() => l.value.find((t) => t.value === i.value));
570
+ return (t, s) => (m(), $(nt, {
571
+ modelValue: i.value,
572
+ "onUpdate:modelValue": s[0] || (s[0] = (f) => i.value = f),
573
+ items: l.value,
574
+ title: "Catalog",
575
+ "title-badge": l.value.filter((f) => !f.disabled).length
576
+ }, {
577
+ default: P(() => {
578
+ var f, p;
579
+ return [
580
+ d(cl, {
581
+ menu: t.menu,
582
+ "item-id": t.itemId,
583
+ "catalog-id": ((f = u.value) == null ? void 0 : f.catalogId) || null,
584
+ "scheduler-ids": ((p = u.value) == null ? void 0 : p.schedulerIds) || []
585
+ }, null, 8, ["menu", "item-id", "catalog-id", "scheduler-ids"])
586
+ ];
587
+ }),
588
+ _: 1
589
+ }, 8, ["modelValue", "items", "title-badge"]));
590
+ }
591
+ }), ml = { class: "flex items-center gap-8" }, pl = { class: "space-y-4" }, vl = { class: "fm-typo-en-title-md-600" }, fl = { key: 0 }, gl = { class: "text-fm-color-typo-secondary" }, bl = {
592
+ key: 0,
593
+ class: "text-fm-color-typo-secondary"
594
+ }, _l = { class: "flex items-center gap-4" }, yl = /* @__PURE__ */ N({
595
+ __name: "ProductBaseInfo",
596
+ props: {
597
+ itemId: {},
598
+ menu: {}
599
+ },
600
+ setup(k) {
601
+ const e = k, r = h(() => e.menu.modules.item.find((l) => l._id === e.itemId)), i = h(() => {
602
+ var l;
603
+ return ce.Dinero.fromFdoDinero((l = r.value) == null ? void 0 : l.price).toFormat(!0);
604
+ });
605
+ return (l, u) => {
606
+ var t, s, f, p, b, y, w;
607
+ return m(), C("div", ml, [
608
+ d(Ue, {
609
+ alt: ((t = r.value) == null ? void 0 : t.name) ?? null,
610
+ size: 72,
611
+ src: (s = r.value) == null ? void 0 : s.thumbnail,
612
+ crossorigin: !1
613
+ }, null, 8, ["alt", "src"]),
614
+ g("div", pl, [
615
+ g("p", vl, [
616
+ (f = r.value) != null && f.code ? (m(), C("span", fl, K((p = r.value) == null ? void 0 : p.code) + ", ", 1)) : R("", !0),
617
+ g("span", null, K((b = r.value) == null ? void 0 : b.name), 1)
618
+ ]),
619
+ g("p", gl, "Base price: " + K(i.value), 1),
620
+ (y = r.value) != null && y.customAttributes ? (m(), C("div", bl, [
621
+ g("div", _l, [
622
+ u[0] || (u[0] = g("span", null, "Tagging:", -1)),
623
+ d(Re, {
624
+ ellipsis: !1,
625
+ "custom-attributes": (w = r.value) == null ? void 0 : w.customAttributes
626
+ }, null, 8, ["custom-attributes"])
627
+ ])
628
+ ])) : R("", !0)
629
+ ])
630
+ ]);
631
+ };
632
+ }
633
+ }), hl = { class: "space-y-16" }, xl = /* @__PURE__ */ N({
634
+ __name: "ProductViewer",
635
+ props: {
636
+ itemId: {},
637
+ menu: {}
638
+ },
639
+ setup(k) {
640
+ const e = I("product"), r = h(() => [
641
+ {
642
+ value: "product",
643
+ label: "Product",
644
+ component: dl
645
+ },
646
+ {
647
+ value: "group",
648
+ label: "Group",
649
+ component: ul
650
+ }
651
+ ]);
652
+ return (i, l) => {
653
+ var t;
654
+ const u = z("FmTabs");
655
+ return m(), C("div", hl, [
656
+ d(yl, {
657
+ "item-id": i.itemId,
658
+ menu: i.menu
659
+ }, null, 8, ["item-id", "menu"]),
660
+ g("div", null, [
661
+ d(u, {
662
+ modelValue: e.value,
663
+ "onUpdate:modelValue": l[0] || (l[0] = (s) => e.value = s),
664
+ items: r.value
665
+ }, null, 8, ["modelValue", "items"])
666
+ ]),
667
+ g("div", null, [
668
+ (m(), $(tt((t = r.value.find((s) => s.value === e.value)) == null ? void 0 : t.component), {
669
+ "item-id": i.itemId,
670
+ menu: i.menu
671
+ }, null, 8, ["item-id", "menu"]))
672
+ ])
673
+ ]);
674
+ };
675
+ }
676
+ }), Cl = { class: "space-y-24" }, kl = { key: 0 }, wl = /* @__PURE__ */ N({
677
+ __name: "ProductOverview",
678
+ props: {
679
+ itemId: {},
680
+ showSearch: { type: Boolean, default: !1 }
681
+ },
682
+ setup(k) {
683
+ const e = k, r = Fe(), i = I(null);
684
+ return lt(() => {
685
+ i.value = e.itemId;
686
+ }), (l, u) => (m(), C("div", Cl, [
687
+ l.showSearch ? (m(), C("div", kl, [
688
+ d(Xt, {
689
+ modelValue: i.value,
690
+ "onUpdate:modelValue": u[0] || (u[0] = (t) => i.value = t),
691
+ class: "w-1/2",
692
+ label: "Search and compare prices",
693
+ "helper-text": "Quickly find products and view their prices across different catalogs and schedules.",
694
+ menu: a(r).state.menu
695
+ }, null, 8, ["modelValue", "menu"])
696
+ ])) : R("", !0),
697
+ g("div", null, [
698
+ i.value ? (m(), $(xl, {
699
+ key: 0,
700
+ "item-id": i.value,
701
+ menu: a(r).state.menu
702
+ }, null, 8, ["item-id", "menu"])) : R("", !0)
703
+ ])
704
+ ]));
705
+ }
706
+ }), Sl = /* @__PURE__ */ N({
707
+ __name: "OverviewSheet",
708
+ setup(k) {
709
+ const e = I(null), r = I(!1);
710
+ function i(l) {
711
+ r.value = !r.value, l && (e.value = l);
712
+ }
713
+ return (l, u) => {
714
+ const t = z("FmSideSheet");
715
+ return m(), C(de, null, [
716
+ _e(l.$slots, "default", { trigger: i }),
717
+ d(t, {
718
+ id: "product-overview",
719
+ modelValue: r.value,
720
+ "onUpdate:modelValue": u[0] || (u[0] = (s) => r.value = s),
721
+ "max-width": 1200,
722
+ "dismiss-away": ""
723
+ }, {
724
+ "side-sheet-header": P(() => u[1] || (u[1] = [
725
+ g("p", { class: "fm-typo-en-title-md-600" }, "Product Overview", -1)
726
+ ])),
727
+ default: P(() => [
728
+ g("div", null, [
729
+ r.value && e.value ? (m(), $(wl, {
730
+ key: 0,
731
+ "item-id": e.value
732
+ }, null, 8, ["item-id"])) : R("", !0)
733
+ ])
734
+ ]),
735
+ _: 1
736
+ }, 8, ["modelValue"])
737
+ ], 64);
738
+ };
739
+ }
740
+ });
741
+ var Fl = Ut();
742
+ const Qe = /* @__PURE__ */ N({
743
+ __name: "ImportButton",
744
+ setup(k) {
745
+ const e = I(!1);
746
+ function r() {
747
+ e.value = !e.value;
748
+ }
749
+ const i = Me();
750
+ return lt(() => {
751
+ const l = i.currentCountry.value;
752
+ if (l)
753
+ try {
754
+ Fl.setCountryConfig(l);
755
+ } catch (u) {
756
+ console.log("Unable to set country config", u);
757
+ }
758
+ }), (l, u) => (m(), C(de, null, [
759
+ d(Mt, {
760
+ modelValue: e.value,
761
+ "onUpdate:modelValue": u[0] || (u[0] = (t) => e.value = t)
762
+ }, null, 8, ["modelValue"]),
763
+ _e(l.$slots, "default", { trigger: r })
764
+ ], 64));
765
+ }
766
+ }), Ye = (k) => d("div", {
767
+ class: "flex flex-1 justify-end"
768
+ }, [d("span", null, [k, Xe(" ")])]), Vl = {
769
+ class: "flex justify-between items-center space-x-8"
770
+ }, Il = {
771
+ class: "flex space-x-8 items-center"
772
+ }, $l = {
773
+ class: "w-[320px]"
774
+ }, Tl = {
775
+ key: 0
776
+ }, Pl = {
777
+ key: 1,
778
+ class: /* @__PURE__ */ me(["flex-1 flex flex-col", "divide-y divide-fm-color-neutral-gray-100", "overflow-hidden"])
779
+ }, Al = {
780
+ key: 0,
781
+ class: "flex items-center p-4"
782
+ }, Rl = {
783
+ class: /* @__PURE__ */ me(["mr-8", "fm-typo-en-body-md-400"])
784
+ }, Ul = {
785
+ key: 1,
786
+ class: "px-16 py-4 space-x-8 flex justify-end"
787
+ }, Ml = {
788
+ key: 2
789
+ }, Ol = {
790
+ class: "flex space-x-8"
791
+ }, zl = {
792
+ key: 1,
793
+ class: "pt-8 flex flex-col flex-1 overflow-hidden"
794
+ }, Dl = {
795
+ class: "space-y-8 pb-8"
796
+ }, Kl = {
797
+ class: "w-full px-8"
798
+ }, Nl = {
799
+ class: "flex space-x-8 px-8"
800
+ }, Bl = {
801
+ key: 0,
802
+ class: "px-8"
803
+ }, jl = {
804
+ key: 0,
805
+ class: /* @__PURE__ */ me(["flex flex-col flex-1", "overflow-scroll", "divide-y divide-fm-color-neutral-gray-100", "pb-64"])
806
+ }, El = ["onClick"], Gl = {
807
+ class: "min-w-0 flex flex-1 items-center justify-start space-x-16"
808
+ }, Ll = {
809
+ class: "flex-1 min-w-0"
810
+ }, ql = {
811
+ class: "flex justify-between items-center gap-8 pb-4"
812
+ }, Wl = {
813
+ class: "flex-1 min-w-0 fm-typo-en-body-lg-600 line-clamp-2"
814
+ }, Hl = {
815
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
816
+ }, Ql = {
817
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
818
+ }, Yl = {
819
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
820
+ }, Zl = {
821
+ key: 1
822
+ }, Jl = {
823
+ class: "flex space-x-8"
824
+ }, Xl = /* @__PURE__ */ N({
825
+ __name: "ProductTable",
826
+ props: {
827
+ modelValue: {},
828
+ originalValue: {},
829
+ isCalculating: {
830
+ type: Boolean
831
+ }
832
+ },
833
+ emits: ["update:model-value", "reset:model-value", "update:editing", "update:search-key"],
834
+ setup(k, {
835
+ expose: e,
836
+ emit: r
837
+ }) {
838
+ const i = k, {
839
+ t: l
840
+ } = Ve(), u = Me(), t = Fe(), s = Tt(), f = at(), p = u.currentCountry, b = h(() => p.value ? ce.Country.getCountry(p.value) : null), y = h(() => t.rules.item), {
841
+ selectedCategories: w
842
+ } = we(), q = h(() => {
843
+ const o = ge.flatten(w.value.map((n) => n.items));
844
+ return ge.uniqBy(o, (n) => n._id);
845
+ }), Y = r, S = I(!1);
846
+ ie(() => S.value, (o) => {
847
+ Y("update:editing", o);
848
+ });
849
+ const ne = (o) => {
850
+ Ot.isBoolean(o) ? S.value = o : S.value = !S.value;
851
+ }, Z = I(!1), re = I(null);
852
+ async function E() {
853
+ Z.value = !Z.value, Z.value && (await Pe(), re.value && re.value.toggleProperty(!0));
854
+ }
855
+ e({
856
+ toggleAttributeFilter: E
857
+ });
858
+ const {
859
+ attributes: D,
860
+ filterRule: O,
861
+ mongoQuery: W
862
+ } = xt(q, "item"), J = I(""), se = Ct(J, 300), H = h(() => {
863
+ const o = (c) => {
864
+ var x;
865
+ return !se.value || !se.value.trim() ? !0 : [c.code, c.name, De(c), ...Te(M.value, c), (x = xe()[c.orderFrom]) == null ? void 0 : x.label, Object.values(c.customAttributes ?? {}).join(" ")].join(" ").toLowerCase().includes(se.value.toLowerCase());
866
+ }, n = (c) => W.value ? $t(c.customAttributes, W.value) : !0;
867
+ return q.value.filter((c) => o(c) && n(c));
868
+ }), {
869
+ categories: M
870
+ } = we(), V = h(() => t.categories.map((o) => ({
871
+ label: o.name,
872
+ value: o._id || null
873
+ }))), A = (o, n, c) => {
874
+ let v = ge.clone(i.modelValue);
875
+ const x = v[o];
876
+ x && (typeof n == "object" && n !== null ? v[o] = {
877
+ ...x,
878
+ ...n
879
+ } : v[o] = {
880
+ ...x,
881
+ [n]: c
882
+ }, Y("update:model-value", v));
883
+ }, T = bt(() => i.originalValue, () => i.modelValue), X = ge.debounce(A, 300), Q = (o) => (n) => !!n || l("menu.product.table.validation.name_required", {
884
+ field: o
885
+ }), B = (o) => o >= 0 || l("menu.product.table.validation.price_min"), U = [Q("Name")], ue = () => [(o) => B(typeof o == "number" ? o : Number(o) ?? 0)], j = xe(), pe = h(() => {
886
+ const o = t.isV4;
887
+ return gt.setCoreStore(u).taxSetting(o);
888
+ }), fe = h(() => [{
889
+ accessorKey: "thumbnail",
890
+ header: "",
891
+ size: 110,
892
+ meta: {
893
+ cellClass: "px-0",
894
+ headerContentClass: "px-0"
895
+ },
896
+ cell: (o) => {
897
+ var n, c;
898
+ return G(Ue, {
899
+ src: o.getValue(),
900
+ alt: (c = (n = o == null ? void 0 : o.row) == null ? void 0 : n.original) == null ? void 0 : c.name,
901
+ className: "my-8 mx-12",
902
+ size: 72,
903
+ crossorigin: !1
904
+ });
905
+ },
906
+ enableSorting: !1
907
+ }, {
908
+ accessorKey: "code",
909
+ header: () => l("menu.product.table.columns.code"),
910
+ enableSorting: !1,
911
+ size: 100,
912
+ cell: (o) => {
913
+ const n = o.row.original, c = o.getValue() || "--";
914
+ if (!S.value) return d("span", {
915
+ class: "break-all"
916
+ }, [c]);
917
+ const v = $e(n._id);
918
+ return G(le.FmTextField, {
919
+ disabled: !y.value.code,
920
+ modelValue: T(n._id, "code") ?? (v == null ? void 0 : v.code),
921
+ placeholder: i.modelValue[n._id].fallbackCode,
922
+ "onUpdate:modelValue": (x) => {
923
+ X(n._id, "code", x);
924
+ }
925
+ });
926
+ }
927
+ }, {
928
+ accessorKey: "name",
929
+ header: () => l("menu.product.table.columns.name"),
930
+ enableSorting: !1,
931
+ size: 200,
932
+ cell: (o) => {
933
+ const n = o.row.original, c = o.getValue();
934
+ return S.value ? G(le.FmTextField, {
935
+ disabled: !y.value.name,
936
+ modelValue: T(n._id, "name") ?? n.name,
937
+ "onUpdate:modelValue": (v) => {
938
+ X(n._id, "name", v);
939
+ },
940
+ rules: U,
941
+ placeholder: n.fallbackName
942
+ }) : c;
943
+ }
944
+ }, {
945
+ accessorKey: "price",
946
+ header: () => {
947
+ var o;
948
+ return Ye(l("menu.product.table.columns.price", {
949
+ currency: (o = b.value) == null ? void 0 : o.currency.symbol
950
+ }));
951
+ },
952
+ enableSorting: !1,
953
+ size: 140,
954
+ meta: {
955
+ textAlign: "right"
956
+ },
957
+ cell: (o) => {
958
+ var x;
959
+ const n = o.getValue();
960
+ if (!S.value) return ce.Dinero.fromFdoDinero(n).toFormat();
961
+ const c = i.modelValue[o.row.original._id], v = c.fallbackPrice;
962
+ return G(Rt, {
963
+ min: 0,
964
+ disabled: !c.editPrice,
965
+ // @ts-ignore
966
+ placeholder: v ? zt(v, !1) : void 0,
967
+ modelValue: T(c._id, "price") ?? ((x = $e(c._id)) == null ? void 0 : x.price),
968
+ // @ts-ignore
969
+ "onUpdate:modelValue": (F) => {
970
+ A(c._id, "price", F);
971
+ },
972
+ rules: ue()
973
+ });
974
+ }
975
+ }, {
976
+ accessorKey: "taxes",
977
+ header: () => Ye(pe.value.systemCode),
978
+ size: S.value ? 120 : 80,
979
+ enableSorting: !1,
980
+ meta: {
981
+ textAlign: "right"
982
+ },
983
+ cell: (o) => {
984
+ const n = o.getValue(), c = o.row.original, v = t.taxSetting.countryTaxOptions, x = t.getSelectedTax(n, c.fallbackTaxes, t.taxSetting.countryTaxOptions), F = v.find((oe) => oe.value === x);
985
+ if (!S.value)
986
+ return `${F != null && F.meta.rate ? _t(F.meta.rate) : 0}%`;
987
+ const _ = t.getSelectedTax(T(c._id, "taxes") ?? n, c.fallbackTaxes, t.taxSetting.countryTaxOptions);
988
+ return G(le.FmSelect, {
989
+ disabled: !y.value.tax,
990
+ items: t.taxSetting.countryTaxOptions,
991
+ modelValue: _,
992
+ "onUpdate:modelValue": async (oe) => {
993
+ const he = t.decodeTax(oe);
994
+ X(c._id, "taxes", [he]);
995
+ }
996
+ });
997
+ }
998
+ }, {
999
+ accessorKey: "category",
1000
+ header: () => l("menu.product.table.columns.category"),
1001
+ enableSorting: !1,
1002
+ size: 140,
1003
+ cell: (o) => {
1004
+ const n = o.row.original;
1005
+ if (!S.value)
1006
+ return G(He, {
1007
+ categories: Te(M.value, n)
1008
+ });
1009
+ const c = yt(i.originalValue, i.modelValue, n._id) ?? ht(n), v = (c == null ? void 0 : c.map((F) => F._id)) ?? [], x = c == null ? void 0 : c.reduce((F, _) => (F[_._id] = _, F), {});
1010
+ return G(It, {
1011
+ shouldShowChips: !1,
1012
+ shouldShowSelectedItemsWithinPlaceholder: !0,
1013
+ modelValue: v.length > 0 ? v : [null],
1014
+ items: V.value,
1015
+ disabled: !!(t.state.currentCatalogId || t.state.currentSchedulerId),
1016
+ "onUpdate:modelValue": async (F) => {
1017
+ const [_, ...oe] = F;
1018
+ X(n._id, {
1019
+ category: _,
1020
+ additionalCategories: oe.map((he) => {
1021
+ const Ne = x == null ? void 0 : x[he];
1022
+ return Ne || {
1023
+ _id: he,
1024
+ position: null
1025
+ };
1026
+ })
1027
+ });
1028
+ }
1029
+ });
1030
+ }
1031
+ }, {
1032
+ id: "tagging",
1033
+ accessorKey: "tagging",
1034
+ header: () => l("menu.product.table.columns.tagging"),
1035
+ enableSorting: !1,
1036
+ size: 140,
1037
+ cell: (o) => {
1038
+ const n = o.row.original;
1039
+ return G(Re, {
1040
+ customAttributes: n.customAttributes
1041
+ });
1042
+ }
1043
+ }, {
1044
+ accessorKey: "orderFrom",
1045
+ header: () => l("menu.product.table.columns.order_from"),
1046
+ enableSorting: !0,
1047
+ sortingFn: (o, n) => {
1048
+ const [c, v] = [o, n].map((x) => j[x.original.orderFrom].sortingIndex);
1049
+ return c - v;
1050
+ },
1051
+ size: 140,
1052
+ cell: (o) => {
1053
+ const n = o.getValue(), c = o.row.original;
1054
+ return S.value ? G(le.FmSelect, {
1055
+ disabled: !y.value.orderFrom,
1056
+ items: Object.values(xe()),
1057
+ modelValue: T(c._id, "orderFrom") ?? n,
1058
+ "onUpdate:modelValue": async (v) => {
1059
+ A(c._id, "orderFrom", v);
1060
+ }
1061
+ }) : G(Se, {
1062
+ orderFrom: n
1063
+ });
1064
+ }
1065
+ }, {
1066
+ id: "actions",
1067
+ size: 100,
1068
+ meta: {
1069
+ cellClass: "pl-16",
1070
+ headerClass: "py-4",
1071
+ textAlign: "right"
1072
+ },
1073
+ header: () => G("div", {
1074
+ class: "w-full px-4 flex justify-end"
1075
+ }, [Dt(G(le.FmButton, {
1076
+ variant: te.Tertiary,
1077
+ textColor: L.NeutralGray400,
1078
+ prependIcon: "edit",
1079
+ class: "flex justify-end",
1080
+ onClick: ne,
1081
+ type: "button"
1082
+ }), "Bulk edit")]),
1083
+ cell: (o) => {
1084
+ const n = o.row.original;
1085
+ return d("div", {
1086
+ class: "px-4 flex justify-end"
1087
+ }, [d(Sl, null, {
1088
+ default: ({
1089
+ trigger: c
1090
+ }) => d(le.FmButton, {
1091
+ icon: "overview",
1092
+ variant: "tertiary",
1093
+ textColor: L.NeutralGray400,
1094
+ onClick: ve(() => {
1095
+ c(n._id);
1096
+ }, ["stop", "prevent"])
1097
+ }, null)
1098
+ }), d(le.FmButton, {
1099
+ icon: "delete",
1100
+ variant: "tertiary",
1101
+ textColor: L.NeutralGray400,
1102
+ onClick: ve(async () => {
1103
+ await f.deleteItem([{
1104
+ _id: n._id,
1105
+ name: n.name,
1106
+ thumbnail: n.thumbnail
1107
+ }]);
1108
+ }, ["stop", "prevent"])
1109
+ }, null)]);
1110
+ }
1111
+ }]);
1112
+ t.taxSetting.systemCode || fe.value.splice(4, 1);
1113
+ const ae = I({}), ee = I([]);
1114
+ ie([() => ae.value, () => H.value], (o) => {
1115
+ let n = [];
1116
+ Object.keys(o[0]).forEach((c) => {
1117
+ const v = o[0][c], x = H.value[parseInt(c)];
1118
+ x && (v ? n.push(x) : ee.value = n.filter((F) => F !== x));
1119
+ }), ee.value = n;
1120
+ }), ie(() => q.value, () => {
1121
+ ae.value = {}, ee.value = [];
1122
+ }), ie(() => S.value, () => {
1123
+ ae.value = {}, ee.value = [];
1124
+ });
1125
+ const rt = () => {
1126
+ ae.value = {};
1127
+ };
1128
+ async function ze() {
1129
+ await Pe();
1130
+ const o = () => !!t.currentCatalog || !!t.state.currentSchedulerId, n = (v) => v === "" || v === null ? o() ? "" : null : v, c = Object.values(i.modelValue).filter((v) => {
1131
+ const x = Object.values(i.originalValue).find((F) => F._id === v._id);
1132
+ return je(x, v);
1133
+ }).map((v) => ({
1134
+ _id: v._id,
1135
+ name: v.name,
1136
+ code: v.code,
1137
+ price: v.price,
1138
+ orderFrom: v.orderFrom ?? null,
1139
+ taxes: v.taxes,
1140
+ category: n(v.category || null),
1141
+ additionalCategories: v.additionalCategories
1142
+ }));
1143
+ await f.updateMany(c), ne(!1);
1144
+ }
1145
+ const st = async () => {
1146
+ await f.deleteItem(ee.value.map((o) => ({
1147
+ _id: o._id,
1148
+ name: o.name,
1149
+ thumbnail: o.thumbnail
1150
+ })));
1151
+ }, ye = () => {
1152
+ Y("reset:model-value");
1153
+ }, Ie = () => {
1154
+ Object.entries(i.modelValue).some(([n, c]) => je(c, i.originalValue[n])) ? s.open({
1155
+ title: "You have unsaved changes!",
1156
+ message: "Are you sure you want to discard? You will lose all the changes if discard edit.",
1157
+ primaryActions: {
1158
+ text: "Discard",
1159
+ close: !0,
1160
+ variant: te.Destructive
1161
+ },
1162
+ secondaryActions: {
1163
+ text: "Cancel",
1164
+ close: !0
1165
+ }
1166
+ }).onPrimary(() => {
1167
+ ye(), ne(!1);
1168
+ }) : (ne(!1), ye());
1169
+ }, ut = h(() => {
1170
+ var o, n;
1171
+ return {
1172
+ thumbnail: !S.value,
1173
+ actions: !S.value,
1174
+ tagging: !S.value && ((n = (o = u.itemAttributeSettings) == null ? void 0 : o.value) == null ? void 0 : n.length) > 0
1175
+ };
1176
+ }), it = (o) => {
1177
+ f.update(o._id);
1178
+ };
1179
+ async function ct(o) {
1180
+ await f.update(o.original._id);
1181
+ }
1182
+ function De(o) {
1183
+ var _;
1184
+ const n = o.price ?? // TODO: fix type error
1185
+ // @ts-ignore
1186
+ o.fallbackPrice ?? ce.Dinero.fromNumber({
1187
+ number: 0
1188
+ }).toObject(), c = o.taxes, v = t.taxSetting.countryTaxOptions, x = ce.Dinero.fromFdoDinero(n).toFormat(), F = (_ = b.value) == null ? void 0 : _.currency.symbol;
1189
+ return t.getSelectedTax(
1190
+ c,
1191
+ // TODO: fix type error
1192
+ // @ts-ignore
1193
+ o.fallbackTaxes,
1194
+ v
1195
+ ), `${F == null ? void 0 : F.toUpperCase()}${x}`;
1196
+ }
1197
+ function $e(o) {
1198
+ var v;
1199
+ const n = t.currentCatalog, c = t.state.currentSchedulerId;
1200
+ if (n && c) {
1201
+ const x = n.override.scheduler[c] ?? {}, F = (v = x == null ? void 0 : x.items) == null ? void 0 : v.filter((_) => _._id === o);
1202
+ return F == null ? void 0 : F[0];
1203
+ } else return n ? n.override.items[o][0] : c ? t.schedulers.find((_) => _._id === c).items.filter((_) => _._id === o)[0] : q.value.find((x) => x._id === o);
1204
+ }
1205
+ const dt = ot(), mt = h(() => dt.breakpoints.value.xs), Ke = I(null), pt = At(Ke, Z), vt = h(() => {
1206
+ var n;
1207
+ return {
1208
+ height: `calc(100vh - ${((n = pt.value) == null ? void 0 : n.top) + 24}px)`
1209
+ };
1210
+ });
1211
+ return (o, n) => {
1212
+ const c = z("fm-search"), v = z("fm-button"), x = z("fm-table"), F = z("fm-form");
1213
+ return mt.value ? (m(), C("div", zl, [g("div", Dl, [g("div", Kl, [d(c, {
1214
+ "model-value": J.value,
1215
+ "onUpdate:modelValue": n[5] || (n[5] = (_) => J.value = _),
1216
+ autofocus: "",
1217
+ placeholder: a(l)("menu.product.table.search.placeholder")
1218
+ }, null, 8, ["model-value", "placeholder"])]), n[8] || (n[8] = g("div", {
1219
+ class: "w-full h-[1px] bg-fm-color-neutral-gray-100"
1220
+ }, null, -1)), g("div", Nl, [_e(o.$slots, "filter")]), Z.value ? (m(), C("div", Bl, [d(a(qe), {
1221
+ ref_key: "attributeFilterRef",
1222
+ ref: re,
1223
+ attributes: a(D),
1224
+ modelValue: a(O),
1225
+ "onUpdate:modelValue": n[6] || (n[6] = (_) => Be(O) ? O.value = _ : null)
1226
+ }, null, 8, ["attributes", "modelValue"])])) : R("", !0)]), q.value.length ? (m(), C("div", jl, [(m(!0), C(de, null, ke(H.value, (_) => {
1227
+ var oe;
1228
+ return m(), C("div", {
1229
+ key: _._id,
1230
+ class: "max-w-full py-12 px-16 space-x-16 flex items-center",
1231
+ onClick: () => it(_)
1232
+ }, [g("div", Gl, [d(Ue, {
1233
+ alt: _.name,
1234
+ size: 72,
1235
+ src: _.thumbnail
1236
+ }, null, 8, ["alt", "src"]), g("div", Ll, [g("div", ql, [g("p", Wl, K(_.name), 1), d(Se, {
1237
+ "order-from": _.orderFrom
1238
+ }, null, 8, ["order-from"])]), g("p", Hl, K(De(_)), 1), g("p", Ql, K(a(l)("menu.product.table.columns.code")) + ": " + K(((oe = $e(_._id)) == null ? void 0 : oe.code) || "--"), 1), g("p", Yl, [d(He, {
1239
+ categories: a(Te)(a(M), _)
1240
+ }, null, 8, ["categories"])]), d(Re, {
1241
+ "custom-attributes": _.customAttributes
1242
+ }, null, 8, ["custom-attributes"])])]), d(v, {
1243
+ "text-color": a(L).NeutralGray400,
1244
+ variant: a(te).Tertiary,
1245
+ "prepend-icon": "delete",
1246
+ onClick: ve(() => a(f).deleteItem([{
1247
+ _id: _._id,
1248
+ name: _.name,
1249
+ thumbnail: _.thumbnail
1250
+ }]), ["stop"])
1251
+ }, null, 8, ["text-color", "variant", "onClick"])], 8, El);
1252
+ }), 128))])) : (m(), C("div", Zl, [d(be, {
1253
+ subtitle: a(l)("menu.product.table.empty.subtitle"),
1254
+ title: a(l)("menu.product.table.empty.title")
1255
+ }, {
1256
+ action: P(() => [g("div", Jl, [d(v, {
1257
+ variant: a(te).Primary,
1258
+ label: a(l)("menu.product.table.empty.actions.add"),
1259
+ "prepend-icon": "add",
1260
+ onClick: n[7] || (n[7] = (_) => a(f).create(null))
1261
+ }, null, 8, ["variant", "label"]), d(Qe, null, {
1262
+ default: P(({
1263
+ trigger: _
1264
+ }) => [d(v, {
1265
+ "bg-color": a(L).NeutralGray100,
1266
+ "text-color": a(L).NeutralGray400,
1267
+ variant: a(te).Primary,
1268
+ label: a(l)("menu.product.table.empty.actions.import"),
1269
+ "prepend-icon": "download",
1270
+ onClick: _
1271
+ }, null, 8, ["bg-color", "text-color", "variant", "label", "onClick"])]),
1272
+ _: 1
1273
+ })])]),
1274
+ _: 1
1275
+ }, 8, ["subtitle", "title"])]))])) : (m(), $(F, {
1276
+ key: 0,
1277
+ "blame-form-child-on-validation-failed": "",
1278
+ class: "flex flex-col flex-1 space-y-8 overflow-hidden",
1279
+ onValidationSuccess: ze
1280
+ }, {
1281
+ default: P(() => [g("div", Vl, [g("div", Il, [_e(o.$slots, "filter")]), g("div", $l, [d(c, {
1282
+ "model-value": J.value,
1283
+ "onUpdate:modelValue": n[0] || (n[0] = (_) => J.value = _),
1284
+ autofocus: "",
1285
+ placeholder: a(l)("menu.product.table.search.placeholder")
1286
+ }, null, 8, ["model-value", "placeholder"])])]), Z.value ? (m(), C("div", Tl, [d(a(qe), {
1287
+ ref_key: "attributeFilterRef",
1288
+ ref: re,
1289
+ attributes: a(D),
1290
+ modelValue: a(O),
1291
+ "onUpdate:modelValue": n[1] || (n[1] = (_) => Be(O) ? O.value = _ : null)
1292
+ }, null, 8, ["attributes", "modelValue"])])) : R("", !0), q.value.length ? (m(), C("div", Pl, [ee.value.length && !S.value ? (m(), C("div", Al, [g("p", Rl, K(a(l)("menu.product.table.selection.count", {
1293
+ count: ee.value.length
1294
+ })), 1), d(v, {
1295
+ label: a(l)("menu.product.table.selection.actions.deselect_all"),
1296
+ type: "button",
1297
+ variant: "plain",
1298
+ onClick: rt
1299
+ }, null, 8, ["label"]), d(v, {
1300
+ "border-color": a(L).SystemError300,
1301
+ "text-color": a(L).SystemError300,
1302
+ class: "ml-auto",
1303
+ label: a(l)("menu.product.table.selection.actions.remove"),
1304
+ "prepend-icon": "delete",
1305
+ variant: "secondary",
1306
+ onClick: st
1307
+ }, null, 8, ["border-color", "text-color", "label"])])) : R("", !0), S.value ? (m(), C("div", Ul, [d(v, {
1308
+ variant: a(te).Tertiary,
1309
+ label: a(l)("menu.product.table.bulk_edit.actions.reset_all"),
1310
+ onClick: ye
1311
+ }, null, 8, ["variant", "label"]), d(v, {
1312
+ variant: a(te).Tertiary,
1313
+ label: a(l)("menu.common.actions.cancel"),
1314
+ onClick: Ie
1315
+ }, null, 8, ["variant", "label"]), d(v, {
1316
+ borderColor: a(L).ColorPrimary,
1317
+ textColor: a(L).ColorPrimary,
1318
+ variant: a(te).Secondary,
1319
+ label: a(l)("menu.product.table.bulk_edit.actions.save"),
1320
+ type: "submit"
1321
+ }, null, 8, ["borderColor", "textColor", "variant", "label"])])) : R("", !0), g("div", {
1322
+ ref_key: "tableWrapper",
1323
+ ref: Ke
1324
+ }, [(m(), $(tt(S.value ? Pt : "div"), {
1325
+ ref: "fullWrapper",
1326
+ title: S.value ? a(l)("menu.product.table.bulk_edit.title") : "",
1327
+ show: S.value,
1328
+ "primary-action": {
1329
+ label: a(l)("menu.product.table.bulk_edit.actions.save")
1330
+ },
1331
+ "secondary-actions": [{
1332
+ label: a(l)("menu.product.table.bulk_edit.actions.reset_all"),
1333
+ click: ye
1334
+ }, {
1335
+ label: a(l)("menu.common.actions.cancel"),
1336
+ click: Ie
1337
+ }],
1338
+ class: "overflow-x-scroll",
1339
+ style: ft(vt.value),
1340
+ onOnPrimary: ze,
1341
+ onOnCancel: Ie
1342
+ }, {
1343
+ default: P(() => [d(x, {
1344
+ class: me({
1345
+ "min-w-[1100px]": !0,
1346
+ "mt-24": S.value
1347
+ }),
1348
+ modelValue: ae.value,
1349
+ "onUpdate:modelValue": n[2] || (n[2] = (_) => ae.value = _),
1350
+ "column-defs": fe.value,
1351
+ "column-visibility": ut.value,
1352
+ loading: o.isCalculating,
1353
+ "page-size": H.value.length,
1354
+ "row-data": H.value,
1355
+ "shrink-at": !1,
1356
+ selection: S.value ? void 0 : "multiple",
1357
+ virtual: !0,
1358
+ "virtual-row-height": S.value ? 48 : 91,
1359
+ "hide-footer": "",
1360
+ "pin-header-row": "",
1361
+ onRowClick: n[3] || (n[3] = (_) => S.value ? void 0 : ct(_))
1362
+ }, null, 8, ["class", "modelValue", "column-defs", "column-visibility", "loading", "page-size", "row-data", "selection", "virtual-row-height"])]),
1363
+ _: 1
1364
+ }, 40, ["title", "show", "primary-action", "secondary-actions", "style"]))], 512)])) : (m(), C("div", Ml, [d(be, {
1365
+ subtitle: a(l)("menu.product.table.empty.subtitle"),
1366
+ title: a(l)("menu.product.table.empty.title")
1367
+ }, {
1368
+ action: P(() => [g("div", Ol, [d(v, {
1369
+ variant: a(te).Primary,
1370
+ label: a(l)("menu.product.table.empty.actions.add"),
1371
+ "prepend-icon": "add",
1372
+ onClick: n[4] || (n[4] = (_) => a(f).create(null))
1373
+ }, null, 8, ["variant", "label"]), d(Qe, null, {
1374
+ default: P(({
1375
+ trigger: _
1376
+ }) => [d(v, {
1377
+ "bg-color": a(L).NeutralGray100,
1378
+ "text-color": a(L).NeutralGray400,
1379
+ variant: a(te).Primary,
1380
+ label: a(l)("menu.product.table.empty.actions.import"),
1381
+ "prepend-icon": "download",
1382
+ onClick: _
1383
+ }, null, 8, ["bg-color", "text-color", "variant", "label", "onClick"])]),
1384
+ _: 1
1385
+ })])]),
1386
+ _: 1
1387
+ }, 8, ["subtitle", "title"])]))]),
1388
+ _: 3
1389
+ }));
1390
+ };
1391
+ }
1392
+ }), ea = {
1393
+ key: 0,
1394
+ class: /* @__PURE__ */ me(["flex flex-col", "flex-1", "overflow-hidden"])
1395
+ }, ta = {
1396
+ class: /* @__PURE__ */ me(["pt-16 xs:pt-0", "flex xs:flex-col", "flex-1", "w-full", "overflow-hidden"])
1397
+ }, la = { class: "flex flex-col flex-1 overflow-hidden" }, aa = {
1398
+ key: 1,
1399
+ class: "pt-16 xs:pt-8 space-y-24"
1400
+ }, oa = { class: "flex items-center gap-8 px-16" }, Fa = /* @__PURE__ */ N({
1401
+ __name: "Product",
1402
+ setup(k) {
1403
+ const e = Fe(), r = h(() => e.rules.item), i = at(), l = h(() => !e.state.currentCatalogId), u = h(() => e.rules.item), t = h(() => !e.state.currentSchedulerId), s = I(!1), f = I(!1), p = h(() => {
1404
+ var V, A, T, X;
1405
+ if (l.value && t.value) return;
1406
+ if (t.value) {
1407
+ const Q = (V = e.currentCatalog) == null ? void 0 : V.override.items;
1408
+ return Q ? Object.entries(Q).reduce((B, [U, ue]) => {
1409
+ const j = ue.find((pe) => !pe.combinationKey);
1410
+ return j && (B[U] = j), B;
1411
+ }, {}) : {};
1412
+ }
1413
+ return ((l.value ? (A = e.currentScheduler) == null ? void 0 : A.items : (X = (T = e.currentCatalog) == null ? void 0 : T.override.scheduler[e.state.currentSchedulerId]) == null ? void 0 : X.items) ?? []).reduce((Q, B) => (B.combinationKey || (Q[B._id] = B), Q), {});
1414
+ }), b = I({}), y = I({}), w = async () => {
1415
+ var X, Q;
1416
+ f.value = !0;
1417
+ const M = !!p.value, V = ge.flatten(Y.value.map((B) => B.items)), A = M && s.value ? await Vt(
1418
+ e.mergedMenu,
1419
+ V,
1420
+ e.state.menu,
1421
+ (X = e.currentCatalog) == null ? void 0 : X._id,
1422
+ (Q = e.currentScheduler) == null ? void 0 : Q._id,
1423
+ !1
1424
+ ) : void 0, T = V.reduce((B, U, ue) => {
1425
+ var pe, fe, ae, ee;
1426
+ const j = (pe = p.value) == null ? void 0 : pe[U._id];
1427
+ return B[U._id] = {
1428
+ _id: U._id,
1429
+ name: U.name,
1430
+ code: M ? j == null ? void 0 : j.code : U == null ? void 0 : U.code,
1431
+ category: U.category,
1432
+ additionalCategories: U.additionalCategories,
1433
+ price: M && u.value.editPrice ? j == null ? void 0 : j.price : U.price,
1434
+ orderFrom: M ? j == null ? void 0 : j.orderFrom : U.orderFrom,
1435
+ taxes: M ? null : U.taxes,
1436
+ thumbnail: U.thumbnail,
1437
+ fallbackPrice: (fe = A == null ? void 0 : A[ue]) == null ? void 0 : fe.price,
1438
+ fallbackName: M ? U.name : void 0,
1439
+ fallbackCode: (ae = A == null ? void 0 : A[ue]) == null ? void 0 : ae.code,
1440
+ fallbackOrder: (ee = A == null ? void 0 : A[ue]) == null ? void 0 : ee.orderFrom,
1441
+ fallbackTaxes: M ? U.taxes : null
1442
+ }, B;
1443
+ }, {});
1444
+ b.value = T, y.value = { ...T }, f.value = !1;
1445
+ }, { categories: q, selectedCategories: Y } = we(), S = I(null);
1446
+ function ne() {
1447
+ S.value && S.value.toggleAttributeFilter();
1448
+ }
1449
+ et(async () => {
1450
+ Y.value && await w();
1451
+ });
1452
+ function Z() {
1453
+ i.create(null);
1454
+ }
1455
+ const re = () => {
1456
+ Y.value && w();
1457
+ }, { t: E } = Ve(), D = h(() => {
1458
+ var M, V;
1459
+ return (V = (M = e.currentCatalog) == null ? void 0 : M.linkItemRules) == null ? void 0 : V.length;
1460
+ }), {
1461
+ menuItems: O,
1462
+ linkItemRules: W,
1463
+ handleSubmit: J,
1464
+ catalogManager: se,
1465
+ schedulerManager: H
1466
+ } = kt(!1);
1467
+ return (M, V) => {
1468
+ const A = z("fm-button");
1469
+ return a(q).length ? (m(), C("div", ea, [
1470
+ g("div", ta, [
1471
+ g("div", la, [
1472
+ a(Y) ? (m(), $(Xl, {
1473
+ key: 0,
1474
+ ref_key: "productTableRef",
1475
+ ref: S,
1476
+ "is-calculating": f.value,
1477
+ "model-value": b.value,
1478
+ "original-value": y.value,
1479
+ "onUpdate:modelValue": V[1] || (V[1] = (T) => b.value = T),
1480
+ "onReset:modelValue": re,
1481
+ "onUpdate:editing": V[2] || (V[2] = (T) => s.value = T)
1482
+ }, {
1483
+ filter: P(() => [
1484
+ d(We, { onToggleAttributeFilter: ne }),
1485
+ u.value.multiScheduler ? (m(), $(Le, { key: 0 })) : R("", !0),
1486
+ D.value ? (m(), $(Ge, {
1487
+ key: 1,
1488
+ "current-restaurant-custom-attributes": a(e).state.currentRestaurantCustomAttributes,
1489
+ onConfirm: V[0] || (V[0] = (T) => a(e).setRestaurantCustomAttributes(T))
1490
+ }, null, 8, ["current-restaurant-custom-attributes"])) : R("", !0)
1491
+ ]),
1492
+ _: 1
1493
+ }, 8, ["is-calculating", "model-value", "original-value"])) : R("", !0)
1494
+ ])
1495
+ ])
1496
+ ])) : (m(), C("div", aa, [
1497
+ g("div", oa, [
1498
+ d(We),
1499
+ u.value.multiScheduler ? (m(), $(Le, { key: 0 })) : R("", !0),
1500
+ D.value ? (m(), $(Ge, {
1501
+ key: 1,
1502
+ "current-restaurant-custom-attributes": a(e).state.currentRestaurantCustomAttributes,
1503
+ onConfirm: V[3] || (V[3] = (T) => a(e).setRestaurantCustomAttributes(T))
1504
+ }, null, 8, ["current-restaurant-custom-attributes"])) : R("", !0)
1505
+ ]),
1506
+ r.value.create ? (m(), $(be, {
1507
+ key: 0,
1508
+ action: {
1509
+ text: a(E)("menu.product.empty.with_create.action"),
1510
+ callback: Z
1511
+ },
1512
+ subtitle: a(E)("menu.product.empty.with_create.subtitle"),
1513
+ title: a(E)("menu.product.empty.with_create.title")
1514
+ }, null, 8, ["action", "subtitle", "title"])) : t.value ? (m(), $(be, {
1515
+ key: 1,
1516
+ subtitle: a(E)("menu.product.empty.no_scheduler.subtitle"),
1517
+ title: a(E)("menu.product.empty.no_scheduler.title")
1518
+ }, {
1519
+ action: P(() => [
1520
+ d(Ee, {
1521
+ "categorized-items": a(se).linkableItems.value,
1522
+ "initial-value": a(se).currentItems.value,
1523
+ "show-variant": !1,
1524
+ "menu-items": a(O),
1525
+ "link-item-rules": a(W),
1526
+ "no-scheduler": t.value,
1527
+ "is-local-only": !0,
1528
+ onSubmit: a(J)
1529
+ }, {
1530
+ default: P(({ trigger: T }) => [
1531
+ d(A, {
1532
+ label: a(E)("menu.common.actions.link_product"),
1533
+ "prepend-icon": "link",
1534
+ onClick: T
1535
+ }, null, 8, ["label", "onClick"])
1536
+ ]),
1537
+ _: 1
1538
+ }, 8, ["categorized-items", "initial-value", "menu-items", "link-item-rules", "no-scheduler", "onSubmit"])
1539
+ ]),
1540
+ _: 1
1541
+ }, 8, ["subtitle", "title"])) : (m(), $(be, {
1542
+ key: 2,
1543
+ subtitle: a(E)("menu.product.empty.with_scheduler.subtitle"),
1544
+ title: a(E)("menu.product.empty.with_scheduler.title")
1545
+ }, {
1546
+ action: P(() => [
1547
+ d(Ee, {
1548
+ "categorized-items": a(H).linkableItems.value,
1549
+ "initial-value": a(H).currentItems.value,
1550
+ "show-variant": !1,
1551
+ "menu-items": a(O),
1552
+ "link-item-rules": a(W),
1553
+ "no-scheduler": t.value,
1554
+ "is-local-only": !0,
1555
+ onSubmit: a(J)
1556
+ }, {
1557
+ default: P(({ trigger: T }) => [
1558
+ d(A, {
1559
+ label: a(E)("menu.common.actions.apply_product"),
1560
+ onClick: T
1561
+ }, null, 8, ["label", "onClick"])
1562
+ ]),
1563
+ _: 1
1564
+ }, 8, ["categorized-items", "initial-value", "menu-items", "link-item-rules", "no-scheduler", "onSubmit"])
1565
+ ]),
1566
+ _: 1
1567
+ }, 8, ["subtitle", "title"]))
1568
+ ]));
1569
+ };
1570
+ }
1571
+ });
1572
+ export {
1573
+ Qe as _,
1574
+ Fa as a
1575
+ };