@feedmepos/mf-menu 0.31.33 → 0.31.34-alpha

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 (101) hide show
  1. package/dist/{App-DNDOc3bV.js → App-CaKDbV0S.js} +6 -6
  2. package/dist/{ApplyProduct.vue_vue_type_script_setup_true_lang-BvrfcWHU.js → ApplyProduct.vue_vue_type_script_setup_true_lang-gY18sRMg.js} +20 -20
  3. package/dist/{Catalog-Zhi-3W6T.js → Catalog-B0zMoi7e.js} +80 -80
  4. package/dist/{Category-BU0bkAGd.js → Category-Dyou6Q17.js} +31 -27
  5. package/dist/{Category-CE9ixFkD.js → Category-rMN8037Q.js} +19 -19
  6. package/dist/{CookingGuide-eghVaeEY.js → CookingGuide-DT2XxaWa.js} +4 -4
  7. package/dist/CustomAttributeChip.vue_vue_type_script_setup_true_lang-Cv9LNAfi.js +113 -0
  8. package/dist/{Group-DWrtP9Au.js → Group-CYSIOe3D.js} +1 -1
  9. package/dist/{Group-DDZPf6LY.js → Group-M4WPAAYz.js} +3 -3
  10. package/dist/Group.vue_vue_type_script_setup_true_lang-B-BH-2WN.js +686 -0
  11. package/dist/GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-TQWka93A.js +367 -0
  12. package/dist/{ImportProductDialog.vue_vue_type_script_setup_true_lang-Cus0YKUt.js → ImportProductDialog.vue_vue_type_script_setup_true_lang-DgSO7SQW.js} +4982 -5081
  13. package/dist/{Ingredient-BJgvOyV9.js → Ingredient-DNvr30pW.js} +3 -3
  14. package/dist/{InventoryBinding.vue_vue_type_script_setup_true_lang-CF99abLi.js → InventoryBinding.vue_vue_type_script_setup_true_lang-G44luws0.js} +1052 -1052
  15. package/dist/LinkProductSideSheet-Cp0HFoP2.js +297 -0
  16. package/dist/LinkProductSideSheet.vue_vue_type_style_index_0_scoped_97fa9d58_lang-DvG3mOom.js +8024 -0
  17. package/dist/{MenuSetting-gkwORUX0.js → MenuSetting-UeQ2NyVm.js} +4 -4
  18. package/dist/{PrintRoute-Cda6sFlL.js → PrintRoute-5uX9ymJY.js} +89 -88
  19. package/dist/{Product-61AAh5L-.js → Product-Dxqf8_iq.js} +1 -1
  20. package/dist/Product.vue_vue_type_script_setup_true_lang-DUtGVRCH.js +1578 -0
  21. package/dist/{ProductInternalTools-o8cVZXCT.js → ProductInternalTools-BCF9q0i_.js} +5 -5
  22. package/dist/Products--adhOQ8n.js +283 -0
  23. package/dist/{Publish-BRgJUzoA.js → Publish-CRaoaFxc.js} +3 -3
  24. package/dist/{Recipe-CV8lvryp.js → Recipe-DPkzZMJi.js} +4 -4
  25. package/dist/{Scheduler-B_ptvb82.js → Scheduler-BuwjNHHj.js} +3 -3
  26. package/dist/{ServingSequence-DABGnLbT.js → ServingSequence-Cdf_Zmat.js} +3 -3
  27. package/dist/Setting-Vr3Thttm.js +259 -0
  28. package/dist/{Subcategory-BiqlAvMs.js → Subcategory-DoXmjcg1.js} +4 -4
  29. package/dist/{Takeaway-BBdkzEiP.js → Takeaway-BRTQu8VT.js} +1 -1
  30. package/dist/{Takeaway-nIjrDu5C.js → Takeaway-t3il54Bd.js} +4 -4
  31. package/dist/{Takeaway.vue_vue_type_script_setup_true_lang-D_M2PFO-.js → Takeaway.vue_vue_type_script_setup_true_lang-DtHABSgp.js} +6 -6
  32. package/dist/Thumbnail.vue_vue_type_script_setup_true_lang-D_ACNj_Z.js +431 -0
  33. package/dist/TreeEditorOpenner.vue_vue_type_script_setup_true_lang-DAoGiRV-.js +5990 -0
  34. package/dist/{Unit-Di5sUbhV.js → Unit-C_QY3IX_.js} +2 -2
  35. package/dist/{Variant-CiZCtZk9.js → Variant-CR4IEm-Q.js} +3 -3
  36. package/dist/_id_-DOU7ieGB.js +202 -0
  37. package/dist/{app-B63V5b4I.js → app--fRC3N4C.js} +1 -1
  38. package/dist/{app-DuD_IPou.js → app-CrXLAKdw.js} +95 -97
  39. package/dist/app.js +6 -7
  40. package/dist/apps/mf-menu/src/app.d.ts +62 -3
  41. package/dist/apps/mf-menu/src/components/feature/PriceTier/LinkPriceTierSection.vue.d.ts +24 -0
  42. package/dist/apps/mf-menu/src/components/feature/PriceTier/PriceTierRuleEditor.vue.d.ts +30 -0
  43. package/dist/apps/mf-menu/src/components/feature/RestaurantAttributesSelector.vue.d.ts +33 -0
  44. package/dist/apps/mf-menu/src/components/feature/TreeEditor/composable/catalog.d.ts +2 -0
  45. package/dist/apps/mf-menu/src/components/feature/TreeEditor/store/menuV2.d.ts +80 -1
  46. package/dist/apps/mf-menu/src/composable/linkProducts.d.ts +1276 -0
  47. package/dist/apps/mf-menu/src/helper/import-export.d.ts +77 -0
  48. package/dist/apps/mf-menu/src/helper/menu.d.ts +77 -0
  49. package/dist/apps/mf-menu/src/helper/setting/catalogSetting.d.ts +11 -2
  50. package/dist/apps/mf-menu/src/manager/menu/item.d.ts +77 -0
  51. package/dist/apps/mf-menu/src/router/shared.d.ts +0 -1
  52. package/dist/apps/mf-menu/src/stores/manager/catalog.d.ts +2 -0
  53. package/dist/apps/mf-menu/src/stores/menu.d.ts +79 -0
  54. package/dist/apps/mf-menu/src/types/linkProducts.d.ts +21 -0
  55. package/dist/apps/mf-menu/src/views/PrintRoute/PrintDepartmentDialog.vue.d.ts +5 -3
  56. package/dist/apps/mf-menu/src/views/Publish/UpdateCatalogDialog.vue.d.ts +82 -0
  57. package/dist/apps/mf-menu/tsconfig.app.tsbuildinfo +1 -1
  58. package/dist/assets/linked-status-BTF_dm9R.js +24 -0
  59. package/dist/assets/override-menu-BPu7TVCy.js +24 -0
  60. package/dist/assets/validate-menu-BQpDfHbr.js +24 -0
  61. package/dist/{catalog-DfYSMjLc.js → catalog-BGiDWODL.js} +1 -1
  62. package/dist/catalogSetting-C34kIcYn.js +71 -0
  63. package/dist/{category-mmjX_QdF.js → category-CayMSpUc.js} +1 -1
  64. package/dist/{currency-3ugQtBPt.js → currency-BggoZpJv.js} +1 -1
  65. package/dist/{dayjs.min-CkV4mNm8.js → dayjs.min-BKDTLohL.js} +1 -1
  66. package/dist/{index-Cztb2LVZ.js → index-BPcRbiW0.js} +3 -3
  67. package/dist/{index-BboaHtmY.js → index-CLFhXi0y.js} +3 -3
  68. package/dist/index-D7yR1j9C.js +215 -0
  69. package/dist/{index-BZaKuDcN.js → index-f9kzXNPD.js} +28 -28
  70. package/dist/{item-CVnDeXhJ.js → item-C51o9ejv.js} +547 -545
  71. package/dist/{jszip.min-GxfcHBC5.js → jszip.min-m57vowh9.js} +353 -353
  72. package/dist/{menu-sGVv4bhQ.js → menu-DHfLxvzU.js} +4 -4
  73. package/dist/menu-DK7wG3S5.js +133287 -0
  74. package/dist/menuV2-B-0V65cx.js +707 -0
  75. package/dist/mf-menu.css +1 -1
  76. package/dist/{priceTier-CHTA0ZEb.js → priceTier-DD-24pkj.js} +1 -1
  77. package/dist/{scheduler-CaMxCHZ0.js → scheduler-NjDv_P4c.js} +16 -17
  78. package/dist/subcategory-DLdBwjHV.js +148 -0
  79. package/dist/{toExcel-WorodvP1.js → toExcel-coJ5igRV.js} +15 -15
  80. package/dist/{unit-DtKZZYL6.js → unit-C7XUV0EW.js} +5 -4
  81. package/package.json +5 -5
  82. package/dist/CustomAttributeChip.vue_vue_type_script_setup_true_lang-BiF8rW4M.js +0 -7949
  83. package/dist/FormItem.vue_vue_type_script_setup_true_lang-BmPAVphe.js +0 -26
  84. package/dist/Group.vue_vue_type_script_setup_true_lang-DyqGsRAW.js +0 -698
  85. package/dist/GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-BmRUg94d.js +0 -206
  86. package/dist/LinkProductSideSheet-CTT4oGUY.js +0 -112
  87. package/dist/Product.vue_vue_type_script_setup_true_lang-Cy4uok1E.js +0 -1560
  88. package/dist/Products-D0rrANT6.js +0 -270
  89. package/dist/Setting-3ISlMXOA.js +0 -258
  90. package/dist/Thumbnail.vue_vue_type_script_setup_true_lang-DzQ8_6Bi.js +0 -71
  91. package/dist/TreeEditorOpenner.vue_vue_type_script_setup_true_lang-y0n5hTLk.js +0 -6149
  92. package/dist/_id_-DY8himeL.js +0 -200
  93. package/dist/apps/mf-menu/src/components/feature/LinkProduct/LinkProductSideSheet.vue.d.ts +0 -70
  94. package/dist/assets/linked-status-CkBKnMXs.js +0 -24
  95. package/dist/assets/override-menu-XZ7XfcfS.js +0 -24
  96. package/dist/assets/validate-menu-Bomogq01.js +0 -24
  97. package/dist/catalogSetting-_4Z0s3_Q.js +0 -65
  98. package/dist/index-Ce4v8o7D.js +0 -106
  99. package/dist/menu-IGORh0Ik.js +0 -108039
  100. package/dist/subcategory-CmVttqlG.js +0 -817
  101. /package/dist/{apps/mf-menu/src/components → packages/shared/src/components/info}/CustomAttributeChip.vue.d.ts +0 -0
@@ -0,0 +1,1578 @@
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-DK7wG3S5.js";
3
+ import { useI18n as Ve, useCoreStore as Me, useCustomAttributes as xt } from "@feedmepos/mf-common";
4
+ import { u as we } from "./menu-DHfLxvzU.js";
5
+ import { _ as be } from "./index.vue_vue_type_script_setup_true_lang-BgqsTzLI.js";
6
+ import { L as Ee } from "./LinkProductSideSheet-Cp0HFoP2.js";
7
+ import { r as Ct, _ as Ge } from "./index-D7yR1j9C.js";
8
+ import { _ as Re, a as Le } from "./CustomAttributeChip.vue_vue_type_script_setup_true_lang-Cv9LNAfi.js";
9
+ import { _ as Ue, u as kt } from "./Thumbnail.vue_vue_type_script_setup_true_lang-D_ACNj_Z.js";
10
+ import { f as wt, o as St, a as Ft, m as Vt } from "./menuV2-B-0V65cx.js";
11
+ import { u as at, C as It } from "./item-C51o9ejv.js";
12
+ import { b as qe, H as $t } from "./LinkProductSideSheet.vue_vue_type_style_index_0_scoped_97fa9d58_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-f9kzXNPD.js";
15
+ import { _ as Oe, u as At } from "./app-CrXLAKdw.js";
16
+ import { _ as Ce } from "./TextChip.vue_vue_type_script_setup_true_lang-8frWuZFL.js";
17
+ import { _ as Rt } from "./index-BPcRbiW0.js";
18
+ import { r as Ut, _ as Mt } from "./ImportProductDialog.vue_vue_type_script_setup_true_lang-DgSO7SQW.js";
19
+ import { c as Ot } from "./check-C9mY6LiX.js";
20
+ import { f as zt } from "./currency-BggoZpJv.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({
863
+ valueSource: q,
864
+ entity: "item"
865
+ }), J = I(""), se = Ct(J, 300), H = h(() => {
866
+ const o = (c) => {
867
+ var x;
868
+ 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());
869
+ }, n = (c) => W.value ? $t(c.customAttributes, W.value) : !0;
870
+ return q.value.filter((c) => o(c) && n(c));
871
+ }), {
872
+ categories: M
873
+ } = we(), V = h(() => t.categories.map((o) => ({
874
+ label: o.name,
875
+ value: o._id || null
876
+ }))), A = (o, n, c) => {
877
+ let v = ge.clone(i.modelValue);
878
+ const x = v[o];
879
+ x && (typeof n == "object" && n !== null ? v[o] = {
880
+ ...x,
881
+ ...n
882
+ } : v[o] = {
883
+ ...x,
884
+ [n]: c
885
+ }, Y("update:model-value", v));
886
+ }, T = bt(() => i.originalValue, () => i.modelValue), X = ge.debounce(A, 300), Q = (o) => (n) => !!n || l("menu.product.table.validation.name_required", {
887
+ field: o
888
+ }), 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(() => {
889
+ const o = t.isV4;
890
+ return gt.setCoreStore(u).taxSetting(o);
891
+ }), fe = h(() => [{
892
+ accessorKey: "thumbnail",
893
+ header: "",
894
+ size: 110,
895
+ meta: {
896
+ cellClass: "px-0",
897
+ headerContentClass: "px-0"
898
+ },
899
+ cell: (o) => {
900
+ var n, c;
901
+ return G(Ue, {
902
+ src: o.getValue(),
903
+ alt: (c = (n = o == null ? void 0 : o.row) == null ? void 0 : n.original) == null ? void 0 : c.name,
904
+ className: "my-8 mx-12",
905
+ size: 72,
906
+ crossorigin: !1
907
+ });
908
+ },
909
+ enableSorting: !1
910
+ }, {
911
+ accessorKey: "code",
912
+ header: () => l("menu.product.table.columns.code"),
913
+ enableSorting: !1,
914
+ size: 100,
915
+ cell: (o) => {
916
+ const n = o.row.original, c = o.getValue() || "--";
917
+ if (!S.value) return d("span", {
918
+ class: "break-all"
919
+ }, [c]);
920
+ const v = $e(n._id);
921
+ return G(le.FmTextField, {
922
+ disabled: !y.value.code,
923
+ modelValue: T(n._id, "code") ?? (v == null ? void 0 : v.code),
924
+ placeholder: i.modelValue[n._id].fallbackCode,
925
+ "onUpdate:modelValue": (x) => {
926
+ X(n._id, "code", x);
927
+ }
928
+ });
929
+ }
930
+ }, {
931
+ accessorKey: "name",
932
+ header: () => l("menu.product.table.columns.name"),
933
+ enableSorting: !1,
934
+ size: 200,
935
+ cell: (o) => {
936
+ const n = o.row.original, c = o.getValue();
937
+ return S.value ? G(le.FmTextField, {
938
+ disabled: !y.value.name,
939
+ modelValue: T(n._id, "name") ?? n.name,
940
+ "onUpdate:modelValue": (v) => {
941
+ X(n._id, "name", v);
942
+ },
943
+ rules: U,
944
+ placeholder: n.fallbackName
945
+ }) : c;
946
+ }
947
+ }, {
948
+ accessorKey: "price",
949
+ header: () => {
950
+ var o;
951
+ return Ye(l("menu.product.table.columns.price", {
952
+ currency: (o = b.value) == null ? void 0 : o.currency.symbol
953
+ }));
954
+ },
955
+ enableSorting: !1,
956
+ size: 140,
957
+ meta: {
958
+ textAlign: "right"
959
+ },
960
+ cell: (o) => {
961
+ var x;
962
+ const n = o.getValue();
963
+ if (!S.value) return ce.Dinero.fromFdoDinero(n).toFormat();
964
+ const c = i.modelValue[o.row.original._id], v = c.fallbackPrice;
965
+ return G(Rt, {
966
+ min: 0,
967
+ disabled: !c.editPrice,
968
+ // @ts-ignore
969
+ placeholder: v ? zt(v, !1) : void 0,
970
+ modelValue: T(c._id, "price") ?? ((x = $e(c._id)) == null ? void 0 : x.price),
971
+ // @ts-ignore
972
+ "onUpdate:modelValue": (F) => {
973
+ A(c._id, "price", F);
974
+ },
975
+ rules: ue()
976
+ });
977
+ }
978
+ }, {
979
+ accessorKey: "taxes",
980
+ header: () => Ye(pe.value.systemCode),
981
+ size: S.value ? 120 : 80,
982
+ enableSorting: !1,
983
+ meta: {
984
+ textAlign: "right"
985
+ },
986
+ cell: (o) => {
987
+ 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);
988
+ if (!S.value)
989
+ return `${F != null && F.meta.rate ? _t(F.meta.rate) : 0}%`;
990
+ const _ = t.getSelectedTax(T(c._id, "taxes") ?? n, c.fallbackTaxes, t.taxSetting.countryTaxOptions);
991
+ return G(le.FmSelect, {
992
+ disabled: !y.value.tax,
993
+ items: t.taxSetting.countryTaxOptions,
994
+ modelValue: _,
995
+ "onUpdate:modelValue": async (oe) => {
996
+ const he = t.decodeTax(oe);
997
+ X(c._id, "taxes", [he]);
998
+ }
999
+ });
1000
+ }
1001
+ }, {
1002
+ accessorKey: "category",
1003
+ header: () => l("menu.product.table.columns.category"),
1004
+ enableSorting: !1,
1005
+ size: 140,
1006
+ cell: (o) => {
1007
+ const n = o.row.original;
1008
+ if (!S.value)
1009
+ return G(He, {
1010
+ categories: Te(M.value, n)
1011
+ });
1012
+ 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), {});
1013
+ return G(It, {
1014
+ shouldShowChips: !1,
1015
+ shouldShowSelectedItemsWithinPlaceholder: !0,
1016
+ modelValue: v.length > 0 ? v : [null],
1017
+ items: V.value,
1018
+ disabled: !!(t.state.currentCatalogId || t.state.currentSchedulerId),
1019
+ "onUpdate:modelValue": async (F) => {
1020
+ const [_, ...oe] = F;
1021
+ X(n._id, {
1022
+ category: _,
1023
+ additionalCategories: oe.map((he) => {
1024
+ const Ne = x == null ? void 0 : x[he];
1025
+ return Ne || {
1026
+ _id: he,
1027
+ position: null
1028
+ };
1029
+ })
1030
+ });
1031
+ }
1032
+ });
1033
+ }
1034
+ }, {
1035
+ id: "tagging",
1036
+ accessorKey: "tagging",
1037
+ header: () => l("menu.product.table.columns.tagging"),
1038
+ enableSorting: !1,
1039
+ size: 140,
1040
+ cell: (o) => {
1041
+ const n = o.row.original;
1042
+ return G(Re, {
1043
+ customAttributes: n.customAttributes
1044
+ });
1045
+ }
1046
+ }, {
1047
+ accessorKey: "orderFrom",
1048
+ header: () => l("menu.product.table.columns.order_from"),
1049
+ enableSorting: !0,
1050
+ sortingFn: (o, n) => {
1051
+ const [c, v] = [o, n].map((x) => j[x.original.orderFrom].sortingIndex);
1052
+ return c - v;
1053
+ },
1054
+ size: 140,
1055
+ cell: (o) => {
1056
+ const n = o.getValue(), c = o.row.original;
1057
+ return S.value ? G(le.FmSelect, {
1058
+ disabled: !y.value.orderFrom,
1059
+ items: Object.values(xe()),
1060
+ modelValue: T(c._id, "orderFrom") ?? n,
1061
+ "onUpdate:modelValue": async (v) => {
1062
+ A(c._id, "orderFrom", v);
1063
+ }
1064
+ }) : G(Se, {
1065
+ orderFrom: n
1066
+ });
1067
+ }
1068
+ }, {
1069
+ id: "actions",
1070
+ size: 100,
1071
+ meta: {
1072
+ cellClass: "pl-16",
1073
+ headerClass: "py-4",
1074
+ textAlign: "right"
1075
+ },
1076
+ header: () => G("div", {
1077
+ class: "w-full px-4 flex justify-end"
1078
+ }, [Dt(G(le.FmButton, {
1079
+ variant: te.Tertiary,
1080
+ textColor: L.NeutralGray400,
1081
+ prependIcon: "edit",
1082
+ class: "flex justify-end",
1083
+ onClick: ne,
1084
+ type: "button"
1085
+ }), "Bulk edit")]),
1086
+ cell: (o) => {
1087
+ const n = o.row.original;
1088
+ return d("div", {
1089
+ class: "px-4 flex justify-end"
1090
+ }, [d(Sl, null, {
1091
+ default: ({
1092
+ trigger: c
1093
+ }) => d(le.FmButton, {
1094
+ icon: "overview",
1095
+ variant: "tertiary",
1096
+ textColor: L.NeutralGray400,
1097
+ onClick: ve(() => {
1098
+ c(n._id);
1099
+ }, ["stop", "prevent"])
1100
+ }, null)
1101
+ }), d(le.FmButton, {
1102
+ icon: "delete",
1103
+ variant: "tertiary",
1104
+ textColor: L.NeutralGray400,
1105
+ onClick: ve(async () => {
1106
+ await f.deleteItem([{
1107
+ _id: n._id,
1108
+ name: n.name,
1109
+ thumbnail: n.thumbnail
1110
+ }]);
1111
+ }, ["stop", "prevent"])
1112
+ }, null)]);
1113
+ }
1114
+ }]);
1115
+ t.taxSetting.systemCode || fe.value.splice(4, 1);
1116
+ const ae = I({}), ee = I([]);
1117
+ ie([() => ae.value, () => H.value], (o) => {
1118
+ let n = [];
1119
+ Object.keys(o[0]).forEach((c) => {
1120
+ const v = o[0][c], x = H.value[parseInt(c)];
1121
+ x && (v ? n.push(x) : ee.value = n.filter((F) => F !== x));
1122
+ }), ee.value = n;
1123
+ }), ie(() => q.value, () => {
1124
+ ae.value = {}, ee.value = [];
1125
+ }), ie(() => S.value, () => {
1126
+ ae.value = {}, ee.value = [];
1127
+ });
1128
+ const rt = () => {
1129
+ ae.value = {};
1130
+ };
1131
+ async function ze() {
1132
+ await Pe();
1133
+ const o = () => !!t.currentCatalog || !!t.state.currentSchedulerId, n = (v) => v === "" || v === null ? o() ? "" : null : v, c = Object.values(i.modelValue).filter((v) => {
1134
+ const x = Object.values(i.originalValue).find((F) => F._id === v._id);
1135
+ return je(x, v);
1136
+ }).map((v) => ({
1137
+ _id: v._id,
1138
+ name: v.name,
1139
+ code: v.code,
1140
+ price: v.price,
1141
+ orderFrom: v.orderFrom ?? null,
1142
+ taxes: v.taxes,
1143
+ category: n(v.category || null),
1144
+ additionalCategories: v.additionalCategories
1145
+ }));
1146
+ await f.updateMany(c), ne(!1);
1147
+ }
1148
+ const st = async () => {
1149
+ await f.deleteItem(ee.value.map((o) => ({
1150
+ _id: o._id,
1151
+ name: o.name,
1152
+ thumbnail: o.thumbnail
1153
+ })));
1154
+ }, ye = () => {
1155
+ Y("reset:model-value");
1156
+ }, Ie = () => {
1157
+ Object.entries(i.modelValue).some(([n, c]) => je(c, i.originalValue[n])) ? s.open({
1158
+ title: "You have unsaved changes!",
1159
+ message: "Are you sure you want to discard? You will lose all the changes if discard edit.",
1160
+ primaryActions: {
1161
+ text: "Discard",
1162
+ close: !0,
1163
+ variant: te.Destructive
1164
+ },
1165
+ secondaryActions: {
1166
+ text: "Cancel",
1167
+ close: !0
1168
+ }
1169
+ }).onPrimary(() => {
1170
+ ye(), ne(!1);
1171
+ }) : (ne(!1), ye());
1172
+ }, ut = h(() => {
1173
+ var o, n;
1174
+ return {
1175
+ thumbnail: !S.value,
1176
+ actions: !S.value,
1177
+ tagging: !S.value && ((n = (o = u.itemAttributeSettings) == null ? void 0 : o.value) == null ? void 0 : n.length) > 0
1178
+ };
1179
+ }), it = (o) => {
1180
+ f.update(o._id);
1181
+ };
1182
+ async function ct(o) {
1183
+ await f.update(o.original._id);
1184
+ }
1185
+ function De(o) {
1186
+ var _;
1187
+ const n = o.price ?? // TODO: fix type error
1188
+ // @ts-ignore
1189
+ o.fallbackPrice ?? ce.Dinero.fromNumber({
1190
+ number: 0
1191
+ }).toObject(), c = o.taxes, v = t.taxSetting.countryTaxOptions, x = ce.Dinero.fromFdoDinero(n).toFormat(), F = (_ = b.value) == null ? void 0 : _.currency.symbol;
1192
+ return t.getSelectedTax(
1193
+ c,
1194
+ // TODO: fix type error
1195
+ // @ts-ignore
1196
+ o.fallbackTaxes,
1197
+ v
1198
+ ), `${F == null ? void 0 : F.toUpperCase()}${x}`;
1199
+ }
1200
+ function $e(o) {
1201
+ var v;
1202
+ const n = t.currentCatalog, c = t.state.currentSchedulerId;
1203
+ if (n && c) {
1204
+ const x = n.override.scheduler[c] ?? {}, F = (v = x == null ? void 0 : x.items) == null ? void 0 : v.filter((_) => _._id === o);
1205
+ return F == null ? void 0 : F[0];
1206
+ } 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);
1207
+ }
1208
+ const dt = ot(), mt = h(() => dt.breakpoints.value.xs), Ke = I(null), pt = At(Ke, Z), vt = h(() => {
1209
+ var n;
1210
+ return {
1211
+ height: `calc(100vh - ${((n = pt.value) == null ? void 0 : n.top) + 24}px)`
1212
+ };
1213
+ });
1214
+ return (o, n) => {
1215
+ const c = z("fm-search"), v = z("fm-button"), x = z("fm-table"), F = z("fm-form");
1216
+ return mt.value ? (m(), C("div", zl, [g("div", Dl, [g("div", Kl, [d(c, {
1217
+ "model-value": J.value,
1218
+ "onUpdate:modelValue": n[5] || (n[5] = (_) => J.value = _),
1219
+ autofocus: "",
1220
+ placeholder: a(l)("menu.product.table.search.placeholder")
1221
+ }, null, 8, ["model-value", "placeholder"])]), n[8] || (n[8] = g("div", {
1222
+ class: "w-full h-[1px] bg-fm-color-neutral-gray-100"
1223
+ }, null, -1)), g("div", Nl, [_e(o.$slots, "filter")]), Z.value ? (m(), C("div", Bl, [d(a(qe), {
1224
+ ref_key: "attributeFilterRef",
1225
+ ref: re,
1226
+ attributes: a(D),
1227
+ modelValue: a(O),
1228
+ "onUpdate:modelValue": n[6] || (n[6] = (_) => Be(O) ? O.value = _ : null)
1229
+ }, null, 8, ["attributes", "modelValue"])])) : R("", !0)]), q.value.length ? (m(), C("div", jl, [(m(!0), C(de, null, ke(H.value, (_) => {
1230
+ var oe;
1231
+ return m(), C("div", {
1232
+ key: _._id,
1233
+ class: "max-w-full py-12 px-16 space-x-16 flex items-center",
1234
+ onClick: () => it(_)
1235
+ }, [g("div", Gl, [d(Ue, {
1236
+ alt: _.name,
1237
+ size: 72,
1238
+ src: _.thumbnail
1239
+ }, null, 8, ["alt", "src"]), g("div", Ll, [g("div", ql, [g("p", Wl, K(_.name), 1), d(Se, {
1240
+ "order-from": _.orderFrom
1241
+ }, 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, {
1242
+ categories: a(Te)(a(M), _)
1243
+ }, null, 8, ["categories"])]), d(Re, {
1244
+ "custom-attributes": _.customAttributes
1245
+ }, null, 8, ["custom-attributes"])])]), d(v, {
1246
+ "text-color": a(L).NeutralGray400,
1247
+ variant: a(te).Tertiary,
1248
+ "prepend-icon": "delete",
1249
+ onClick: ve(() => a(f).deleteItem([{
1250
+ _id: _._id,
1251
+ name: _.name,
1252
+ thumbnail: _.thumbnail
1253
+ }]), ["stop"])
1254
+ }, null, 8, ["text-color", "variant", "onClick"])], 8, El);
1255
+ }), 128))])) : (m(), C("div", Zl, [d(be, {
1256
+ subtitle: a(l)("menu.product.table.empty.subtitle"),
1257
+ title: a(l)("menu.product.table.empty.title")
1258
+ }, {
1259
+ action: P(() => [g("div", Jl, [d(v, {
1260
+ variant: a(te).Primary,
1261
+ label: a(l)("menu.product.table.empty.actions.add"),
1262
+ "prepend-icon": "add",
1263
+ onClick: n[7] || (n[7] = (_) => a(f).create(null))
1264
+ }, null, 8, ["variant", "label"]), d(Qe, null, {
1265
+ default: P(({
1266
+ trigger: _
1267
+ }) => [d(v, {
1268
+ "bg-color": a(L).NeutralGray100,
1269
+ "text-color": a(L).NeutralGray400,
1270
+ variant: a(te).Primary,
1271
+ label: a(l)("menu.product.table.empty.actions.import"),
1272
+ "prepend-icon": "download",
1273
+ onClick: _
1274
+ }, null, 8, ["bg-color", "text-color", "variant", "label", "onClick"])]),
1275
+ _: 1
1276
+ })])]),
1277
+ _: 1
1278
+ }, 8, ["subtitle", "title"])]))])) : (m(), $(F, {
1279
+ key: 0,
1280
+ "blame-form-child-on-validation-failed": "",
1281
+ class: "flex flex-col flex-1 space-y-8 overflow-hidden",
1282
+ onValidationSuccess: ze
1283
+ }, {
1284
+ default: P(() => [g("div", Vl, [g("div", Il, [_e(o.$slots, "filter")]), g("div", $l, [d(c, {
1285
+ "model-value": J.value,
1286
+ "onUpdate:modelValue": n[0] || (n[0] = (_) => J.value = _),
1287
+ autofocus: "",
1288
+ placeholder: a(l)("menu.product.table.search.placeholder")
1289
+ }, null, 8, ["model-value", "placeholder"])])]), Z.value ? (m(), C("div", Tl, [d(a(qe), {
1290
+ ref_key: "attributeFilterRef",
1291
+ ref: re,
1292
+ attributes: a(D),
1293
+ modelValue: a(O),
1294
+ "onUpdate:modelValue": n[1] || (n[1] = (_) => Be(O) ? O.value = _ : null)
1295
+ }, 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", {
1296
+ count: ee.value.length
1297
+ })), 1), d(v, {
1298
+ label: a(l)("menu.product.table.selection.actions.deselect_all"),
1299
+ type: "button",
1300
+ variant: "plain",
1301
+ onClick: rt
1302
+ }, null, 8, ["label"]), d(v, {
1303
+ "border-color": a(L).SystemError300,
1304
+ "text-color": a(L).SystemError300,
1305
+ class: "ml-auto",
1306
+ label: a(l)("menu.product.table.selection.actions.remove"),
1307
+ "prepend-icon": "delete",
1308
+ variant: "secondary",
1309
+ onClick: st
1310
+ }, null, 8, ["border-color", "text-color", "label"])])) : R("", !0), S.value ? (m(), C("div", Ul, [d(v, {
1311
+ variant: a(te).Tertiary,
1312
+ label: a(l)("menu.product.table.bulk_edit.actions.reset_all"),
1313
+ onClick: ye
1314
+ }, null, 8, ["variant", "label"]), d(v, {
1315
+ variant: a(te).Tertiary,
1316
+ label: a(l)("menu.common.actions.cancel"),
1317
+ onClick: Ie
1318
+ }, null, 8, ["variant", "label"]), d(v, {
1319
+ borderColor: a(L).ColorPrimary,
1320
+ textColor: a(L).ColorPrimary,
1321
+ variant: a(te).Secondary,
1322
+ label: a(l)("menu.product.table.bulk_edit.actions.save"),
1323
+ type: "submit"
1324
+ }, null, 8, ["borderColor", "textColor", "variant", "label"])])) : R("", !0), g("div", {
1325
+ ref_key: "tableWrapper",
1326
+ ref: Ke
1327
+ }, [(m(), $(tt(S.value ? Pt : "div"), {
1328
+ ref: "fullWrapper",
1329
+ title: S.value ? a(l)("menu.product.table.bulk_edit.title") : "",
1330
+ show: S.value,
1331
+ "primary-action": {
1332
+ label: a(l)("menu.product.table.bulk_edit.actions.save")
1333
+ },
1334
+ "secondary-actions": [{
1335
+ label: a(l)("menu.product.table.bulk_edit.actions.reset_all"),
1336
+ click: ye
1337
+ }, {
1338
+ label: a(l)("menu.common.actions.cancel"),
1339
+ click: Ie
1340
+ }],
1341
+ class: "overflow-x-scroll",
1342
+ style: ft(vt.value),
1343
+ onOnPrimary: ze,
1344
+ onOnCancel: Ie
1345
+ }, {
1346
+ default: P(() => [d(x, {
1347
+ class: me({
1348
+ "min-w-[1100px]": !0,
1349
+ "mt-24": S.value
1350
+ }),
1351
+ modelValue: ae.value,
1352
+ "onUpdate:modelValue": n[2] || (n[2] = (_) => ae.value = _),
1353
+ "column-defs": fe.value,
1354
+ "column-visibility": ut.value,
1355
+ loading: o.isCalculating,
1356
+ "page-size": H.value.length,
1357
+ "row-data": H.value,
1358
+ "shrink-at": !1,
1359
+ selection: S.value ? void 0 : "multiple",
1360
+ virtual: !0,
1361
+ "virtual-row-height": S.value ? 48 : 91,
1362
+ "hide-footer": "",
1363
+ "pin-header-row": "",
1364
+ onRowClick: n[3] || (n[3] = (_) => S.value ? void 0 : ct(_))
1365
+ }, null, 8, ["class", "modelValue", "column-defs", "column-visibility", "loading", "page-size", "row-data", "selection", "virtual-row-height"])]),
1366
+ _: 1
1367
+ }, 40, ["title", "show", "primary-action", "secondary-actions", "style"]))], 512)])) : (m(), C("div", Ml, [d(be, {
1368
+ subtitle: a(l)("menu.product.table.empty.subtitle"),
1369
+ title: a(l)("menu.product.table.empty.title")
1370
+ }, {
1371
+ action: P(() => [g("div", Ol, [d(v, {
1372
+ variant: a(te).Primary,
1373
+ label: a(l)("menu.product.table.empty.actions.add"),
1374
+ "prepend-icon": "add",
1375
+ onClick: n[4] || (n[4] = (_) => a(f).create(null))
1376
+ }, null, 8, ["variant", "label"]), d(Qe, null, {
1377
+ default: P(({
1378
+ trigger: _
1379
+ }) => [d(v, {
1380
+ "bg-color": a(L).NeutralGray100,
1381
+ "text-color": a(L).NeutralGray400,
1382
+ variant: a(te).Primary,
1383
+ label: a(l)("menu.product.table.empty.actions.import"),
1384
+ "prepend-icon": "download",
1385
+ onClick: _
1386
+ }, null, 8, ["bg-color", "text-color", "variant", "label", "onClick"])]),
1387
+ _: 1
1388
+ })])]),
1389
+ _: 1
1390
+ }, 8, ["subtitle", "title"])]))]),
1391
+ _: 3
1392
+ }));
1393
+ };
1394
+ }
1395
+ }), ea = {
1396
+ key: 0,
1397
+ class: /* @__PURE__ */ me(["flex flex-col", "flex-1", "overflow-hidden"])
1398
+ }, ta = {
1399
+ class: /* @__PURE__ */ me(["pt-16 xs:pt-0", "flex xs:flex-col", "flex-1", "w-full", "overflow-hidden"])
1400
+ }, la = { class: "flex flex-col flex-1 overflow-hidden" }, aa = {
1401
+ key: 1,
1402
+ class: "pt-16 xs:pt-8 space-y-24"
1403
+ }, oa = { class: "flex items-center gap-8 px-16" }, Fa = /* @__PURE__ */ N({
1404
+ __name: "Product",
1405
+ setup(k) {
1406
+ 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(() => {
1407
+ var V, A, T, X;
1408
+ if (l.value && t.value) return;
1409
+ if (t.value) {
1410
+ const Q = (V = e.currentCatalog) == null ? void 0 : V.override.items;
1411
+ return Q ? Object.entries(Q).reduce((B, [U, ue]) => {
1412
+ const j = ue.find((pe) => !pe.combinationKey);
1413
+ return j && (B[U] = j), B;
1414
+ }, {}) : {};
1415
+ }
1416
+ 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), {});
1417
+ }), b = I({}), y = I({}), w = async () => {
1418
+ var X, Q;
1419
+ f.value = !0;
1420
+ const M = !!p.value, V = ge.flatten(Y.value.map((B) => B.items)), A = M && s.value ? await Vt(
1421
+ e.mergedMenu,
1422
+ V,
1423
+ e.state.menu,
1424
+ (X = e.currentCatalog) == null ? void 0 : X._id,
1425
+ (Q = e.currentScheduler) == null ? void 0 : Q._id,
1426
+ !1
1427
+ ) : void 0, T = V.reduce((B, U, ue) => {
1428
+ var pe, fe, ae, ee;
1429
+ const j = (pe = p.value) == null ? void 0 : pe[U._id];
1430
+ return B[U._id] = {
1431
+ _id: U._id,
1432
+ name: U.name,
1433
+ code: M ? j == null ? void 0 : j.code : U == null ? void 0 : U.code,
1434
+ category: U.category,
1435
+ additionalCategories: U.additionalCategories,
1436
+ price: M && u.value.editPrice ? j == null ? void 0 : j.price : U.price,
1437
+ orderFrom: M ? j == null ? void 0 : j.orderFrom : U.orderFrom,
1438
+ taxes: M ? null : U.taxes,
1439
+ thumbnail: U.thumbnail,
1440
+ fallbackPrice: (fe = A == null ? void 0 : A[ue]) == null ? void 0 : fe.price,
1441
+ fallbackName: M ? U.name : void 0,
1442
+ fallbackCode: (ae = A == null ? void 0 : A[ue]) == null ? void 0 : ae.code,
1443
+ fallbackOrder: (ee = A == null ? void 0 : A[ue]) == null ? void 0 : ee.orderFrom,
1444
+ fallbackTaxes: M ? U.taxes : null
1445
+ }, B;
1446
+ }, {});
1447
+ b.value = T, y.value = { ...T }, f.value = !1;
1448
+ }, { categories: q, selectedCategories: Y } = we(), S = I(null);
1449
+ function ne() {
1450
+ S.value && S.value.toggleAttributeFilter();
1451
+ }
1452
+ et(async () => {
1453
+ Y.value && await w();
1454
+ });
1455
+ function Z() {
1456
+ i.create(null);
1457
+ }
1458
+ const re = () => {
1459
+ Y.value && w();
1460
+ }, { t: E } = Ve(), D = h(() => {
1461
+ var M, V;
1462
+ return (V = (M = e.currentCatalog) == null ? void 0 : M.linkItemRules) == null ? void 0 : V.length;
1463
+ }), {
1464
+ menuItems: O,
1465
+ linkItemRules: W,
1466
+ handleSubmit: J,
1467
+ catalogManager: se,
1468
+ schedulerManager: H
1469
+ } = kt(!1);
1470
+ return (M, V) => {
1471
+ const A = z("fm-button");
1472
+ return a(q).length ? (m(), C("div", ea, [
1473
+ g("div", ta, [
1474
+ g("div", la, [
1475
+ a(Y) ? (m(), $(Xl, {
1476
+ key: 0,
1477
+ ref_key: "productTableRef",
1478
+ ref: S,
1479
+ "is-calculating": f.value,
1480
+ "model-value": b.value,
1481
+ "original-value": y.value,
1482
+ "onUpdate:modelValue": V[1] || (V[1] = (T) => b.value = T),
1483
+ "onReset:modelValue": re,
1484
+ "onUpdate:editing": V[2] || (V[2] = (T) => s.value = T)
1485
+ }, {
1486
+ filter: P(() => [
1487
+ d(We, { onToggleAttributeFilter: ne }),
1488
+ u.value.multiScheduler ? (m(), $(Le, { key: 0 })) : R("", !0),
1489
+ D.value ? (m(), $(Ge, {
1490
+ key: 1,
1491
+ "current-restaurant-custom-attributes": a(e).state.currentRestaurantCustomAttributes,
1492
+ onConfirm: V[0] || (V[0] = (T) => a(e).setRestaurantCustomAttributes(T))
1493
+ }, null, 8, ["current-restaurant-custom-attributes"])) : R("", !0)
1494
+ ]),
1495
+ _: 1
1496
+ }, 8, ["is-calculating", "model-value", "original-value"])) : R("", !0)
1497
+ ])
1498
+ ])
1499
+ ])) : (m(), C("div", aa, [
1500
+ g("div", oa, [
1501
+ d(We),
1502
+ u.value.multiScheduler ? (m(), $(Le, { key: 0 })) : R("", !0),
1503
+ D.value ? (m(), $(Ge, {
1504
+ key: 1,
1505
+ "current-restaurant-custom-attributes": a(e).state.currentRestaurantCustomAttributes,
1506
+ onConfirm: V[3] || (V[3] = (T) => a(e).setRestaurantCustomAttributes(T))
1507
+ }, null, 8, ["current-restaurant-custom-attributes"])) : R("", !0)
1508
+ ]),
1509
+ r.value.create ? (m(), $(be, {
1510
+ key: 0,
1511
+ action: {
1512
+ text: a(E)("menu.product.empty.with_create.action"),
1513
+ callback: Z
1514
+ },
1515
+ subtitle: a(E)("menu.product.empty.with_create.subtitle"),
1516
+ title: a(E)("menu.product.empty.with_create.title")
1517
+ }, null, 8, ["action", "subtitle", "title"])) : t.value ? (m(), $(be, {
1518
+ key: 1,
1519
+ subtitle: a(E)("menu.product.empty.no_scheduler.subtitle"),
1520
+ title: a(E)("menu.product.empty.no_scheduler.title")
1521
+ }, {
1522
+ action: P(() => [
1523
+ d(Ee, {
1524
+ "categorized-items": a(se).linkableItems.value,
1525
+ "initial-value": a(se).currentItems.value,
1526
+ "show-variant": !1,
1527
+ "menu-items": a(O),
1528
+ "link-item-rules": a(W),
1529
+ "no-scheduler": t.value,
1530
+ "is-local-only": !0,
1531
+ onSubmit: a(J)
1532
+ }, {
1533
+ default: P(({ trigger: T }) => [
1534
+ d(A, {
1535
+ label: a(E)("menu.common.actions.link_product"),
1536
+ "prepend-icon": "link",
1537
+ onClick: T
1538
+ }, null, 8, ["label", "onClick"])
1539
+ ]),
1540
+ _: 1
1541
+ }, 8, ["categorized-items", "initial-value", "menu-items", "link-item-rules", "no-scheduler", "onSubmit"])
1542
+ ]),
1543
+ _: 1
1544
+ }, 8, ["subtitle", "title"])) : (m(), $(be, {
1545
+ key: 2,
1546
+ subtitle: a(E)("menu.product.empty.with_scheduler.subtitle"),
1547
+ title: a(E)("menu.product.empty.with_scheduler.title")
1548
+ }, {
1549
+ action: P(() => [
1550
+ d(Ee, {
1551
+ "categorized-items": a(H).linkableItems.value,
1552
+ "initial-value": a(H).currentItems.value,
1553
+ "show-variant": !1,
1554
+ "menu-items": a(O),
1555
+ "link-item-rules": a(W),
1556
+ "no-scheduler": t.value,
1557
+ "is-local-only": !0,
1558
+ onSubmit: a(J)
1559
+ }, {
1560
+ default: P(({ trigger: T }) => [
1561
+ d(A, {
1562
+ label: a(E)("menu.common.actions.apply_product"),
1563
+ onClick: T
1564
+ }, null, 8, ["label", "onClick"])
1565
+ ]),
1566
+ _: 1
1567
+ }, 8, ["categorized-items", "initial-value", "menu-items", "link-item-rules", "no-scheduler", "onSubmit"])
1568
+ ]),
1569
+ _: 1
1570
+ }, 8, ["subtitle", "title"]))
1571
+ ]));
1572
+ };
1573
+ }
1574
+ });
1575
+ export {
1576
+ Qe as _,
1577
+ Fa as a
1578
+ };