@feedmepos/mf-inventory-portal 1.7.9-dev.0 → 1.7.9-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/dist/App-BYCW0L94.js +1403 -0
  2. package/dist/{ApprovalView-Bc6xo-gg.js → ApprovalView-pmI_SFo7.js} +9 -9
  3. package/dist/{BindingsDialog-BbTkoM05.js → BindingsDialog-D902flPr.js} +2 -2
  4. package/dist/{BindingsPicker-CkK79U9V.js → BindingsPicker-JEKsY59b.js} +2 -2
  5. package/dist/{BindingsTable-CmdCc1mG.js → BindingsTable-DqlzOIxF.js} +4 -4
  6. package/dist/{BulkReceiveRequestView-BOt07CYr.js → BulkReceiveRequestView-Chw7ma2k.js} +19 -19
  7. package/dist/{ChangeLocationComponent.vue_vue_type_script_setup_true_lang-YMRGpkS4.js → ChangeLocationComponent.vue_vue_type_script_setup_true_lang-Cct8Ko19.js} +1 -1
  8. package/dist/{ClosingDraftView-Dec1xuFQ.js → ClosingDraftView-D1ymRsd2.js} +19 -19
  9. package/dist/{ClosingHistoryView-DuX0UpLC.js → ClosingHistoryView-5yr_itIV.js} +5 -5
  10. package/dist/{ClosingTemplateView-DBPGxWt2.js → ClosingTemplateView-MDl5Zq-g.js} +16 -16
  11. package/dist/{CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-DWfblvtV.js → CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-BcG0gWV4.js} +1 -1
  12. package/dist/{DefaultView-D_XfvHrs.js → DefaultView-dOfbL3iF.js} +2 -2
  13. package/dist/{DeliveryOrderPrintPreview-DfAAAfCJ.js → DeliveryOrderPrintPreview-BfVgQOx8.js} +2 -2
  14. package/dist/{EmailDialog.vue_vue_type_script_setup_true_lang-CdcBrUHW.js → EmailDialog.vue_vue_type_script_setup_true_lang-DHspOJQW.js} +2250 -2250
  15. package/dist/{FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-lge1DZ4v.js → FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-B7NLu0us.js} +1 -1
  16. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DjYAwlg9.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-C0nunKjx.js} +2 -2
  17. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-vwp2n9KL.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CMst9tkA.js} +2 -2
  18. package/dist/{FmMultiselectDialog-BTVaIESZ.js → FmMultiselectDialog-BjBx94pY.js} +1 -1
  19. package/dist/{FmMultiselectDialog-C-kDJtv_.js → FmMultiselectDialog-Dt54hvqw.js} +2 -2
  20. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-Mo-hF_cA.js → FmUnitInput.vue_vue_type_script_setup_true_lang-DtG9Ieo_.js} +6 -6
  21. package/dist/{ImportView-CRAFZVSk.js → ImportView-CdZN8k_Y.js} +6 -6
  22. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-CuEDzJ0s.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-iCpYEneM.js} +1 -1
  23. package/dist/{IngredientGroupView-OeeBfJau.js → IngredientGroupView-BBVS1mKn.js} +5 -5
  24. package/dist/{IngredientsView-BHX3xUDm.js → IngredientsView-BGOaAUzR.js} +17 -16
  25. package/dist/{IntegrationExplorerView-BwxSGD2N.js → IntegrationExplorerView-UUBCmqdR.js} +4 -4
  26. package/dist/{IntegrationView-CevJNVqG.js → IntegrationView-B2YowH-i.js} +14 -14
  27. package/dist/{InventoryBindingForm-wE--IP2D.js → InventoryBindingForm-kDx6Mvhn.js} +1 -1
  28. package/dist/InventoryBindingForm.vue_vue_type_script_setup_true_lang-C8bktmYH.js +563 -0
  29. package/dist/{InventoryBindingSummary-BQ-U7tHs.js → InventoryBindingSummary-DJrBTa8_.js} +1 -1
  30. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-jnXbX2lS.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DHk9uEAP.js} +1 -1
  31. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-BNMCbrIo.js → PremiumBadge.vue_vue_type_script_setup_true_lang-Dx1VktdW.js} +1 -1
  32. package/dist/{ProductionView-CvU9N_mb.js → ProductionView-CxUcsRBP.js} +7 -7
  33. package/dist/{PublishView-BNnxGtEQ.js → PublishView-DtP-Ms7q.js} +3 -3
  34. package/dist/{PurchaseOrderPrintPreview-Bq9kMWdx.js → PurchaseOrderPrintPreview-C_qC2KF5.js} +2 -2
  35. package/dist/{ReceiveRequestView-zUSU0Uvq.js → ReceiveRequestView-Dy3BpqsP.js} +14 -14
  36. package/dist/RecipeView-DeR7pqj8.js +3625 -0
  37. package/dist/{SettingsView-CPgsU8Kr.js → SettingsView-C7ZXmatO.js} +4 -4
  38. package/dist/{StockView-D-TJzHhP.js → StockView-wFLnNSRr.js} +21 -21
  39. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-B6ez4H3Z.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-Fxh3-Nqi.js} +1 -1
  40. package/dist/{SupplierView-D-rODe-B.js → SupplierView-CeTDNDDK.js} +12 -12
  41. package/dist/{SurchargeView-C88KTCML.js → SurchargeView-BQJnCdPA.js} +6 -6
  42. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-CFIK8eEl.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-D1zxuH66.js} +2 -2
  43. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-BNjjTYtk.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-BFkh3Ubb.js} +1 -1
  44. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-E0FeDPFB.js → TransferDetails.vue_vue_type_script_setup_true_lang-CZVDhXNz.js} +20 -20
  45. package/dist/{TransferTemplateView-f9A4-wEL.js → TransferTemplateView-XaI2T5fa.js} +20 -20
  46. package/dist/{UnitCostHistoryView-D26St5yl.js → UnitCostHistoryView-DTNW7-mk.js} +4 -4
  47. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-D2z5vabu.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-vRsEjVJc.js} +4 -4
  48. package/dist/{UnitView-algS_4rD.js → UnitView-DXnyzkj3.js} +7 -7
  49. package/dist/{WarehouseView-BRM-euG4.js → WarehouseView-iEHFgIqh.js} +5 -5
  50. package/dist/{WastageTemplateView-BWPYvTMC.js → WastageTemplateView-CGDUCPbr.js} +14 -14
  51. package/dist/api/changelog.d.ts +69 -1
  52. package/dist/{app-BI1fLJ8H.js → app-BIXJtvvD.js} +35 -23
  53. package/dist/app.d.ts +26 -8
  54. package/dist/app.js +1 -1
  55. package/dist/{closing-template-DRQ-A04S.js → closing-template-CLY-r6Cf.js} +1 -1
  56. package/dist/{date2-paxg81i_.js → date2-DbYQycSa.js} +1 -1
  57. package/dist/{dayjs.min-CqWwbKI1.js → dayjs.min-Dv7-fEed.js} +1 -1
  58. package/dist/{decimal-tY0JrFld.js → decimal-B8YR17QC.js} +2 -2
  59. package/dist/{defineDeepModel-CaP78Goh.js → defineDeepModel-C5ncgNxj.js} +1 -1
  60. package/dist/{duplicate-template-pTXXQ0VS.js → duplicate-template-CAlG1nzV.js} +1 -1
  61. package/dist/{feature-B2r32qOO.js → feature-BLSNLI5y.js} +2 -2
  62. package/dist/{format-time-from-id-DXMYus4N.js → format-time-from-id-D5DcWpHS.js} +1 -1
  63. package/dist/{format-unit-display-5hlsZBY2.js → format-unit-display-Ch97dVXx.js} +12 -12
  64. package/dist/{import-export.helper-BiC2Ghbl.js → import-export.helper-CvUFSOa1.js} +6 -6
  65. package/dist/{index-rqdAWR69.js → index-Bk8DOv4n.js} +3306 -3232
  66. package/dist/{index-KP2-U9x_.js → index-CXzVUrJS.js} +3 -3
  67. package/dist/{index-B7eouqPa.js → index-rRPErzP4.js} +1 -1
  68. package/dist/{inventory-core-dart.default-ClRRaGtG.js → inventory-core-dart.default-Cj7CxnpK.js} +1 -1
  69. package/dist/{lz-string-CAl-OrXa.js → lz-string-DWkGPESZ.js} +1 -1
  70. package/dist/{netsuite-cH4OybGV.js → netsuite-Cn0y1rH3.js} +2 -2
  71. package/dist/{number-BzmDQm_s.js → number-CxbQxQwj.js} +3 -3
  72. package/dist/{predefined-templates-Baz8GEGx.js → predefined-templates-CrSoG3R9.js} +1 -1
  73. package/dist/{purchase-order-template-0So3c2iS.js → purchase-order-template-BmQQnrEl.js} +1 -1
  74. package/dist/{recalculationUtils-DJlz5mJL.js → recalculationUtils-CSnowXma.js} +1 -1
  75. package/dist/{rules-BKdtla9-.js → rules-CurdOAcA.js} +2 -2
  76. package/dist/{stock-D8M5e53w.js → stock-BdDR_L8p.js} +1 -1
  77. package/dist/{stock-HCSCwSH0.js → stock-BiqEgcgU.js} +3 -3
  78. package/dist/style.css +1 -1
  79. package/dist/{supplier-1mbcQSiQ.js → supplier-CsjbmP_P.js} +2 -2
  80. package/dist/{surcharge-DuxYBaWV.js → surcharge--kBjIIst.js} +1 -1
  81. package/dist/tsconfig.app.tsbuildinfo +1 -1
  82. package/dist/{uom-rules-Dkbgtow8.js → uom-rules-D8UPS06O.js} +1 -1
  83. package/dist/{use-ingredient-select-dialog-BXvBvELI.js → use-ingredient-select-dialog-BZdrpLOE.js} +2 -2
  84. package/dist/{use-inventory-binding-dialog-2lrzHWdQ.js → use-inventory-binding-dialog-CkNxixT2.js} +2 -2
  85. package/dist/{use-template-enabled-locations-CrDuAaCj.js → use-template-enabled-locations-Dkl1_1F-.js} +2 -2
  86. package/dist/{use-transfer-locations-C4oTuW_f.js → use-transfer-locations-Bmj4zTJj.js} +2 -2
  87. package/dist/{useHrmPermission-CxeYlUgA.js → useHrmPermission-DcBe_-Q6.js} +1 -1
  88. package/dist/{useNavigationMenu-BWgwgA4U.js → useNavigationMenu-CsRbtAc7.js} +2 -2
  89. package/dist/{useSseClient-DPA1zg96.js → useSseClient-hl2SQF5b.js} +1 -1
  90. package/dist/views/changelog/components/ChangelogPanel.spec.d.ts +1 -0
  91. package/dist/views/changelog/components/ChangelogPanel.vue.d.ts +2 -0
  92. package/dist/views/changelog/composables/use-changelog.d.ts +54 -2
  93. package/dist/views/changelog/composables/use-inventory-record-commits.d.ts +97 -0
  94. package/dist/views/changelog/composables/use-inventory-record-commits.spec.d.ts +1 -0
  95. package/dist/views/changelog/composables/use-snapshot-diff.d.ts +29 -0
  96. package/dist/views/changelog/composables/use-snapshot-diff.spec.d.ts +1 -0
  97. package/dist/views/changelog/composables/value-tree.d.ts +14 -0
  98. package/dist/views/changelog/composables/value-tree.spec.d.ts +1 -0
  99. package/dist/views/ingredients/components/inventory-binding/InventoryBindingForm.vue.d.ts +2 -0
  100. package/dist/views/ingredients/components/inventory-binding/RecipeBindingBreakdown.vue.d.ts +25 -0
  101. package/dist/views/ingredients/components/inventory-binding/composables/recipe-breakdown.d.ts +34 -0
  102. package/dist/views/ingredients/components/inventory-binding/composables/recipe-breakdown.spec.d.ts +1 -0
  103. package/dist/views/ingredients/components/inventory-binding/v2/InventoryBindingFormV2.vue.d.ts +2 -0
  104. package/dist/views/ingredients/components/inventory-binding/v2/components/InventoryRecipeBindingV2Field.vue.d.ts +4 -0
  105. package/dist/views/recipe/composables/use-recipe-table.d.ts +11 -0
  106. package/dist/{vue-i18n-BSfpVmaF.js → vue-i18n-yL99yI4f.js} +169 -169
  107. package/dist/{xlsx.util-DSA9o0Zu.js → xlsx.util-B8azJxkS.js} +2 -2
  108. package/package.json +2 -2
  109. package/dist/App-DvBMEcuJ.js +0 -1155
  110. package/dist/InventoryBindingForm.vue_vue_type_script_setup_true_lang-O5IbSGWu.js +0 -441
  111. package/dist/RecipeView-DkXOK1Iy.js +0 -3584
@@ -1,3584 +0,0 @@
1
- import { defineComponent as le, ref as W, onMounted as pt, resolveComponent as G, createElementBlock as V, openBlock as v, Fragment as X, createElementVNode as f, toDisplayString as U, createVNode as x, createCommentVNode as T, computed as R, watch as ue, unref as n, normalizeClass as Ce, withCtx as J, h as de, createBlock as Y, renderList as me, isRef as De, mergeProps as we, createTextVNode as mt, withModifiers as ft, normalizeStyle as vt, Teleport as yt, normalizeProps as bt, guardReactiveProps as gt } from "vue";
2
- import { a as ne, c as Oe, S as _t, F as be, u as tt, t as kt, v as ht, j as Je } from "./app-BI1fLJ8H.js";
3
- import { useDialog as je, useSnackbar as Le, components as _e, useProxiedModel as Ge, useBreakpoints as xt } from "@feedmepos/ui-library";
4
- import { i as $t, _ as It, m as wt } from "./menu-usage-module-BdjYEk3s.js";
5
- import { F as se } from "./form-mode.enum-BKiNVH6A.js";
6
- import { _ as nt } from "./IngredientBindedItem.vue_vue_type_script_setup_true_lang-CuEDzJ0s.js";
7
- import { defineStore as ot, storeToRefs as Et } from "pinia";
8
- import { D as He, R as Ve } from "./row-action.enum-ncgDYAjP.js";
9
- import { c as Vt } from "./component-BmLAdDiY.js";
10
- import { a as Q, c as Ke } from "./number-BzmDQm_s.js";
11
- import { useI18n as ie, useCoreStore as St } from "@feedmepos/mf-common";
12
- import { u as Ct, _ as Bt } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-DwrLsWX_.js";
13
- import { b as it, c as qe, I as Ft, A as Ne, U as lt, R as Rt } from "./rules-BKdtla9-.js";
14
- import { _ as At } from "./InventoryBindingForm.vue_vue_type_script_setup_true_lang-O5IbSGWu.js";
15
- import { a as Pe } from "./FmMultiselectDialog-C-kDJtv_.js";
16
- import { d as rt } from "./defineDeepModel-CaP78Goh.js";
17
- import { L as Tt, P as Ut, D as Pt } from "./app-C39bYJmq.js";
18
- import { _ as Be, c as Mt, d as Dt, e as ye } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-Mo-hF_cA.js";
19
- import { u as Gt } from "./FmMultiselectDialog-BTVaIESZ.js";
20
- import { u as Nt } from "./vue-i18n-BSfpVmaF.js";
21
- import { F as zt } from "./inventory-core-dart.default-ClRRaGtG.js";
22
- import { _ as Ot } from "./FmCustomAttribute.vue_vue_type_script_setup_true_lang-CG1m-B2p.js";
23
- import { u as We } from "./feature-B2r32qOO.js";
24
- import { F as he } from "./decimal-tY0JrFld.js";
25
- import { _ as Fe } from "./FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DjYAwlg9.js";
26
- import { b as at, d as st } from "./xlsx.util-DSA9o0Zu.js";
27
- import { f as dt } from "./date2-paxg81i_.js";
28
- import { _ as jt, F as Qe } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DAMpuZ1X.js";
29
- import { _ as Lt } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-vwp2n9KL.js";
30
- const Kt = {
31
- key: 0,
32
- class: "flex flex-col items-center w-full h-full gap-24"
33
- }, qt = { key: 1 }, Wt = { key: 0 }, Yt = /* @__PURE__ */ le({
34
- __name: "DeleteDialog",
35
- props: {
36
- type: {},
37
- data: {},
38
- message: {},
39
- bindedItems: {}
40
- },
41
- setup(p) {
42
- const d = p, l = W(d.bindedItems || []), t = W(!1);
43
- pt(() => {
44
- i();
45
- });
46
- async function i() {
47
- var r, $;
48
- !t.value && ((r = d.data) != null && r._id) && (t.value = !0, l.value = await ne().getAffectedMenu(($ = d.data) == null ? void 0 : $._id), t.value = !1);
49
- }
50
- return (r, $) => {
51
- const u = G("FmSpacer"), o = G("FmCircularProgress");
52
- return v(), V(X, null, [
53
- f("p", null, U(r.message), 1),
54
- t.value ? (v(), V("div", Kt, [
55
- x(u),
56
- f("div", null, [
57
- x(o, { size: "xl" })
58
- ]),
59
- $[0] || ($[0] = f("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary pl-8" }, "Loading...", -1)),
60
- x(u)
61
- ])) : (v(), V("div", qt, [
62
- $[2] || ($[2] = f("br", null, null, -1)),
63
- l.value.length > 0 ? (v(), V("div", Wt, [
64
- $[1] || ($[1] = f("p", { class: "fm-typo-en-body-lg-600" }, "Affected menu items:", -1)),
65
- x(nt, {
66
- name: "Menu",
67
- bindings: l.value
68
- }, null, 8, ["bindings"])
69
- ])) : T("", !0)
70
- ]))
71
- ], 64);
72
- };
73
- }
74
- }), ze = ot("recipeForm", function() {
75
- const d = je(), l = Le(), t = ne(), i = W(!1), r = W();
76
- function $() {
77
- const a = {
78
- recipe: {},
79
- mode: se.CREATE,
80
- show: !0,
81
- "onUpdate:show"(g) {
82
- r.value.show = g;
83
- }
84
- };
85
- r.value = a;
86
- }
87
- async function u(a) {
88
- const g = {
89
- recipe: Oe(a),
90
- mode: se.UPDATE,
91
- show: !0,
92
- "onUpdate:show"(h) {
93
- r.value.show = h;
94
- }
95
- };
96
- r.value = g;
97
- }
98
- async function o(a) {
99
- i.value = !0;
100
- try {
101
- await t.deleteRecipe(a), l.open({
102
- title: "Success",
103
- message: `Deleted ${a.name}`,
104
- type: "success"
105
- });
106
- } catch (g) {
107
- if (g instanceof _t && $t(g)) {
108
- d.open({
109
- title: "Cannot delete recipe",
110
- contentComponent: It,
111
- contentComponentProps: {
112
- subject: (a == null ? void 0 : a.name) ?? "",
113
- items: g.errorResponse.errors.map((h) => {
114
- var C;
115
- return {
116
- chain: [
117
- {
118
- itemName: h.name,
119
- moduleKey: (C = h.message) != null && C.startsWith("modules.") ? wt(h.message) : h.module
120
- }
121
- ]
122
- };
123
- })
124
- },
125
- secondaryActions: {
126
- text: "Close",
127
- close: !0
128
- }
129
- });
130
- return;
131
- }
132
- l.open({
133
- title: `Cannot delete ${a == null ? void 0 : a.name}`,
134
- message: "Please try again.",
135
- type: "error"
136
- }), console.error("failed to delete recipe", g);
137
- } finally {
138
- i.value = !1;
139
- }
140
- }
141
- function s(a) {
142
- d.open({
143
- title: `Delete ${(a == null ? void 0 : a.name) ?? "recipe"}?`,
144
- closeButton: !1,
145
- primaryActions: {
146
- text: "Delete",
147
- close: !0,
148
- variant: "destructive"
149
- },
150
- secondaryActions: {
151
- text: "Cancel",
152
- close: !0
153
- },
154
- contentComponent: Yt,
155
- contentComponentProps: {
156
- type: "menu",
157
- data: a,
158
- message: "You may not be able to delete this recipe if it is linked in any of the inventory modules."
159
- }
160
- }).onPrimary(() => o(a));
161
- }
162
- return {
163
- createRecipe: $,
164
- updateRecipe: u,
165
- deleteRecipe: s,
166
- recipeDialogProps: r,
167
- recipeViewLoading: i
168
- };
169
- });
170
- function Jt() {
171
- const { updateRecipe: p, deleteRecipe: d } = ze(), l = ne(), { t } = ie();
172
- async function i(o, s) {
173
- const a = Oe(s);
174
- if (o === Ve.Edit) {
175
- await p(a);
176
- return;
177
- }
178
- if (o === Ve.Delete) {
179
- await d(a);
180
- return;
181
- }
182
- }
183
- function r(o, s) {
184
- const a = o.filter((C) => C.type === be.enum.SKU), g = o.filter(
185
- (C) => C.type === be.enum.SKU_GROUP
186
- ), h = o.filter((C) => C.type === be.enum.RECIPE);
187
- return [
188
- ...a.map((C) => ({ ...C, recipeIds: [...s] })),
189
- ...g.map((C) => ({ ...C, isGroup: !0, recipeIds: [...s] })),
190
- ...h.filter((C) => l.recipeById[C.id] && !s.has(C.id)).flatMap(
191
- (C) => r(l.recipeById[C.id].contains, /* @__PURE__ */ new Set([...s, C.id]))
192
- )
193
- ];
194
- }
195
- const $ = [
196
- {
197
- accessorKey: "recipe",
198
- header: () => t("inventory.recipe.name"),
199
- size: 400
200
- },
201
- {
202
- accessorKey: "ingredients",
203
- header: () => t("inventory.recipe.ingredients"),
204
- size: "auto"
205
- },
206
- {
207
- id: "action",
208
- header: "",
209
- cell(o) {
210
- return Vt(
211
- [He[Ve.Edit], He[Ve.Delete]],
212
- (s) => {
213
- i(s, o.row.original.original);
214
- }
215
- );
216
- },
217
- enableSorting: !1,
218
- size: 40,
219
- meta: {
220
- cellClass: "",
221
- headerClass: ""
222
- }
223
- }
224
- ];
225
- function u(o) {
226
- const s = ne();
227
- return o.map((a) => ({
228
- recipe: a.name,
229
- ingredients: r(a.contains, /* @__PURE__ */ new Set([a._id])).map((g) => {
230
- var C, I, m, _, w, y;
231
- if (g.isGroup) {
232
- const e = s.skuGroupById[g.id];
233
- return g.recipeIds.slice(1).length ? `(${(C = s.recipeById[g.recipeIds.at(-1) ?? ""]) == null ? void 0 : C.name}) ${e.name} (x ${Q(g.amount)})` : `${e.name} (x${Q(g.amount)})`;
234
- }
235
- const h = s.skuById[g.id];
236
- return h ? g.recipeIds.slice(1).length ? `(${(I = s.recipeById[g.recipeIds.at(-1) ?? ""]) == null ? void 0 : I.name}) ${h.name} (${Q(g.amount)}${((m = g.measurement) == null ? void 0 : m.abbrev) ?? ((_ = h == null ? void 0 : h.unit) == null ? void 0 : _.abbrev)})` : `${h.name} (${Q(g.amount)}${((w = g.measurement) == null ? void 0 : w.abbrev) ?? ((y = h == null ? void 0 : h.unit) == null ? void 0 : y.abbrev)})` : null;
237
- }).filter((g) => g).join(", "),
238
- original: a
239
- }));
240
- }
241
- return { columnDefs: $, formatRowData: u };
242
- }
243
- function Ht() {
244
- const p = ne(), d = je();
245
- async function l(r, $, u, o = []) {
246
- var I, m;
247
- const s = r.filter((_) => _.type === "SKU"), a = r.filter((_) => _.type !== "SKU"), g = /* @__PURE__ */ new Set();
248
- if (u)
249
- for (const _ of p.skus)
250
- !o.some((y) => y === _._id) && _._id !== u && !((m = (I = _.convert) == null ? void 0 : I.inventoryBindings) != null && m.some((y) => y.id === u)) || g.add(_._id);
251
- const h = p.skus.map((_) => ({
252
- label: _.name,
253
- sublabel: `${_.code}${g.has(_._id) ? " (Cannot bind, will cause recursive binding)" : ""}`,
254
- value: _,
255
- disabled: g.has(_._id)
256
- })), C = h.filter(
257
- (_) => s.find((w) => w.id === _.value._id) && !g.has(_.value._id)
258
- ).map((_) => _.value);
259
- d.open({
260
- title: "Select ingredients",
261
- contentComponent: Pe,
262
- contentComponentProps: {
263
- items: h,
264
- modelValue: C,
265
- virtualScroll: !0
266
- },
267
- primaryActions: {
268
- text: "Confirm",
269
- close: !0
270
- },
271
- secondaryActions: {
272
- text: "Close",
273
- close: !0,
274
- variant: "tertiary"
275
- }
276
- }).onPrimary((_) => {
277
- const w = [
278
- ...a,
279
- ...r.filter((y) => _.find((e) => e._id === y.id)),
280
- ..._.filter((y) => !r.find((e) => e.id === y._id)).map((y) => ({
281
- type: "SKU",
282
- id: y._id,
283
- amount: {
284
- amount: 1,
285
- precision: 0
286
- }
287
- }))
288
- ];
289
- $(w);
290
- });
291
- }
292
- async function t(r, $, u = []) {
293
- var C;
294
- const o = r.filter((I) => I.type === "RECIPE"), s = r.filter((I) => I.type !== "RECIPE"), a = /* @__PURE__ */ new Set();
295
- if (u.length)
296
- for (const I of p.recipes) {
297
- const m = ((C = p.recipeBindingFlattenCache[I._id]) == null ? void 0 : C.inventoryBindings) ?? [], _ = m.some(
298
- (e) => e.bindingPaths.some((S) => u.some((c) => c === S.id))
299
- ), w = m.some(
300
- (e) => "success" in e && u.includes(e.ingredient._id)
301
- );
302
- (u.some((e) => e === I._id) || _ || w) && a.add(I._id);
303
- }
304
- const g = p.recipes.filter((I) => !u.includes(I._id)).map((I) => ({
305
- label: I.name,
306
- sublabel: a.has(I._id) ? "(Cannot bind, will cause recursive binding)" : `${I.contains.length} inventory bindings`,
307
- value: I,
308
- disabled: a.has(I._id)
309
- })), h = g.filter(
310
- (I) => o.find((m) => m.id === I.value._id) && !a.has(I.value._id)
311
- ).map((I) => I.value);
312
- d.open({
313
- title: "Select recipes",
314
- contentComponent: Pe,
315
- contentComponentProps: {
316
- items: g,
317
- modelValue: h,
318
- virtualScroll: !0
319
- },
320
- primaryActions: {
321
- text: "Confirm",
322
- close: !0
323
- },
324
- secondaryActions: {
325
- text: "Close",
326
- close: !0,
327
- variant: "tertiary"
328
- }
329
- }).onPrimary((I) => {
330
- const m = [
331
- ...r.filter((_) => I.find((w) => w._id === _.id)),
332
- ...I.filter((_) => !r.find((w) => w.id === _._id)).map((_) => ({
333
- type: "RECIPE",
334
- id: _._id,
335
- amount: {
336
- amount: 1,
337
- precision: 0
338
- }
339
- })),
340
- ...s
341
- ];
342
- $(m);
343
- });
344
- }
345
- async function i(r, $, u = []) {
346
- const o = r.filter((h) => h.type === "SKU_GROUP"), s = r.filter((h) => h.type !== "SKU_GROUP"), a = p.skuGroups.filter((h) => !u.includes(h._id)).map((h) => ({
347
- label: h.name,
348
- value: h
349
- })), g = a.filter((h) => o.find((C) => C.id === h.value._id)).map((h) => h.value);
350
- d.open({
351
- title: "Select ingredient group",
352
- contentComponent: Pe,
353
- contentComponentProps: {
354
- items: a,
355
- modelValue: g,
356
- virtualScroll: !0
357
- },
358
- primaryActions: {
359
- text: "Confirm",
360
- close: !0
361
- },
362
- secondaryActions: {
363
- text: "Close",
364
- close: !0,
365
- variant: "tertiary"
366
- }
367
- }).onPrimary((h) => {
368
- const C = [
369
- ...r.filter((I) => h.find((m) => m._id === I.id)),
370
- ...h.filter((I) => !r.find((m) => m.id === I._id)).map((I) => ({
371
- type: "SKU_GROUP",
372
- id: I._id,
373
- amount: {
374
- amount: 1,
375
- precision: 0
376
- }
377
- })),
378
- ...s
379
- ];
380
- $(C);
381
- });
382
- }
383
- return {
384
- promptIngredientsBinding: l,
385
- promptRecipesBinding: t,
386
- promptIngredientGroupsBinding: i
387
- };
388
- }
389
- const Qt = { class: "flex flex-col" }, Xt = { class: "flex flex-col gap-4" }, Re = /* @__PURE__ */ le({
390
- __name: "InventoryBindingRule",
391
- props: {
392
- disabled: { type: Boolean },
393
- modelValue: {},
394
- minCount: {},
395
- maxCount: {}
396
- },
397
- emits: ["update:modelValue"],
398
- setup(p, { emit: d }) {
399
- const l = p, t = d, { t: i } = ie(), r = St(), $ = tt(), u = R(() => {
400
- var I;
401
- const h = /* @__PURE__ */ new Map(), C = r.restaurants.value.map((m) => m.customAttributes ?? {});
402
- for (const m of C)
403
- for (const [_, w] of Object.entries(m))
404
- h.has(_) || h.set(_, /* @__PURE__ */ new Set()), w && ((I = h.get(_)) == null || I.add(w));
405
- return h;
406
- }), o = R(
407
- () => r.restaurants.value.filter((h) => {
408
- var C;
409
- return (C = h.profile) == null ? void 0 : C.code;
410
- }).map((h) => ({ value: h.profile.code, label: `${h.profile.name} (${h.profile.code})` }))
411
- ), s = R(() => [
412
- ...[...u.value.entries()].map(([C, I]) => ({
413
- type: "string",
414
- key: C,
415
- entity: "restaurant",
416
- values: [...I]
417
- })),
418
- {
419
- type: "string",
420
- key: "state",
421
- entity: "restaurant",
422
- values: [
423
- ...new Set($.locations.map((C) => C.doc.profile.address.state).filter(Boolean))
424
- ]
425
- },
426
- ...o.value.length > 0 ? [
427
- {
428
- type: "string",
429
- key: "outlet",
430
- entity: "restaurant",
431
- options: o.value
432
- }
433
- ] : []
434
- ]), a = W(null);
435
- let g = null;
436
- return ue(
437
- () => l.modelValue,
438
- (h) => {
439
- JSON.stringify(h) !== JSON.stringify(g) && (a.value = h ? Tt.build(h) : null);
440
- },
441
- { immediate: !0 }
442
- ), ue(
443
- a,
444
- (h) => {
445
- g = h ? Ut.build(h) : null, t("update:modelValue", g);
446
- },
447
- { deep: !0 }
448
- ), (h, C) => {
449
- const I = G("FmLabel"), m = G("FmFormGroup");
450
- return v(), V("div", Qt, [
451
- f("div", Xt, [
452
- x(I, {
453
- label: n(i)("inventory.ingredientGroup.form.rules.title"),
454
- required: h.minCount != null && h.minCount > 0
455
- }, null, 8, ["label", "required"]),
456
- x(n(Pt), {
457
- modelValue: a.value,
458
- "onUpdate:modelValue": C[0] || (C[0] = (_) => a.value = _),
459
- attributes: s.value
460
- }, null, 8, ["modelValue", "attributes"])
461
- ]),
462
- x(m, {
463
- "model-value": a.value,
464
- rules: [
465
- (_) => {
466
- const w = _ ? 1 : 0;
467
- return l.minCount !== void 0 && w < l.minCount ? n(i)("inventory.ingredientGroup.form.rules.validation.minCount", {
468
- count: l.minCount
469
- }) : l.maxCount !== void 0 && w > l.maxCount ? n(i)("inventory.ingredientGroup.form.rules.validation.maxCount", {
470
- count: l.maxCount
471
- }) : !0;
472
- }
473
- ]
474
- }, null, 8, ["model-value", "rules"])
475
- ]);
476
- };
477
- }
478
- }), Zt = { class: "border-1 mx-3 my-1 rounded-md" }, en = { class: "flex flex-col w-full border-b border-fm-color-neutral-gray-100" }, tn = {
479
- class: "flex items-center",
480
- style: { "min-height": "48px" }
481
- }, nn = { class: "flex-1 fm-typo-en-body-md-400 py-8 px-12" }, on = { class: "flex flex-col" }, ln = { class: "line-clamp-1" }, rn = { class: "w-[200px]" }, an = {
482
- key: 0,
483
- class: "w-[52px]"
484
- }, sn = {
485
- key: 0,
486
- class: "flex gap-4 text-fm-color-system-error-400 fm-typo-en-body-sm-400 px-8"
487
- }, dn = { class: "px-12 pb-4" }, un = /* @__PURE__ */ le({
488
- __name: "InventoryRecipeBindingV2Field",
489
- props: {
490
- disabled: { type: Boolean },
491
- readonly: { type: Boolean },
492
- modelValue: {},
493
- displayName: {},
494
- showError: { type: Boolean }
495
- },
496
- emits: ["update:modelValue", "delete", "settings"],
497
- setup(p, { emit: d }) {
498
- const l = d, { t } = ie(), i = rt("modelValue"), r = W(""), $ = R(() => +Q(i.amount));
499
- ue(
500
- () => i.amount,
501
- (s) => {
502
- const a = Q(s);
503
- r.value !== a && (r.value = a);
504
- },
505
- { immediate: !0 }
506
- );
507
- let u = null;
508
- function o(s) {
509
- r.value = s, u && clearTimeout(u), u = setTimeout(() => {
510
- const a = +s;
511
- s.length > 0 && isFinite(a) ? i.amount = Ke(a) : i.amount = { amount: 0, precision: 0 };
512
- }, 300);
513
- }
514
- return (s, a) => {
515
- const g = G("FmTooltip"), h = G("FmTextField"), C = G("FmButton"), I = G("FmIcon"), m = G("FmFormGroup");
516
- return v(), V("div", Zt, [
517
- x(m, {
518
- class: Ce(["mb-2"]),
519
- disabled: s.disabled,
520
- modelValue: $.value,
521
- rules: [n(it)(0), n(qe)(-1)]
522
- }, {
523
- default: J(({ invalid: _ }) => [
524
- f("div", en, [
525
- f("div", tn, [
526
- f("div", nn, [
527
- f("div", on, [
528
- x(g, {
529
- zIndex: 51,
530
- variant: "plain",
531
- placement: "top",
532
- content: s.displayName
533
- }, {
534
- default: J(() => [
535
- f("span", ln, U(s.displayName), 1)
536
- ]),
537
- _: 1
538
- }, 8, ["content"])
539
- ])
540
- ]),
541
- f("div", rn, [
542
- x(h, {
543
- class: "w-full",
544
- disabled: s.disabled,
545
- modelValue: r.value,
546
- "onUpdate:modelValue": a[0] || (a[0] = (w) => o(w)),
547
- invalid: _
548
- }, null, 8, ["disabled", "modelValue", "invalid"])
549
- ]),
550
- s.readonly ? T("", !0) : (v(), V("div", an, [
551
- x(C, {
552
- disabled: s.disabled,
553
- type: "button",
554
- variant: "plain",
555
- icon: "delete",
556
- "icon-color": "#000000",
557
- onClick: a[1] || (a[1] = () => l("delete", n(i).id))
558
- }, null, 8, ["disabled"])
559
- ]))
560
- ]),
561
- s.showError ? (v(), V("div", sn, [
562
- x(I, {
563
- name: "error",
564
- color: "system-error-300",
565
- size: "sm"
566
- }),
567
- f("div", null, U(n(t)("inventory.inventoryBindings.circularError")), 1)
568
- ])) : T("", !0)
569
- ])
570
- ]),
571
- _: 1
572
- }, 8, ["disabled", "modelValue", "rules"]),
573
- f("div", dn, [
574
- x(Re, {
575
- modelValue: n(i).rules,
576
- "onUpdate:modelValue": a[2] || (a[2] = (_) => n(i).rules = _),
577
- disabled: s.disabled
578
- }, null, 8, ["modelValue", "disabled"])
579
- ])
580
- ]);
581
- };
582
- }
583
- });
584
- function cn(p) {
585
- const d = Gt(), { t: l } = Nt(), t = ne(), i = R(() => [
586
- {
587
- id: "delete",
588
- header: "",
589
- cell(u) {
590
- const o = u.row.original;
591
- return de(
592
- "div",
593
- { class: "w-full flex justify-end" },
594
- de(_e.FmButton, {
595
- class: "delete-button",
596
- key: o._id,
597
- type: "button",
598
- icon: "delete",
599
- variant: "tertiary",
600
- size: "md",
601
- disabled: p.disabled ?? !1,
602
- onClick: () => {
603
- p.bindingAlternatives = p.bindingAlternatives.filter(
604
- (s) => s._id !== o._id
605
- );
606
- }
607
- })
608
- );
609
- },
610
- enableSorting: !1,
611
- size: 40,
612
- meta: {
613
- cellClass: "",
614
- headerClass: ""
615
- }
616
- },
617
- {
618
- id: "alternative",
619
- header: () => l("inventory.inventoryBindings.alternativeTable.ingredient"),
620
- accessorFn: (u) => {
621
- var o, s;
622
- return `${((o = t.skuById[u._id]) == null ? void 0 : o.name) ?? ""} (${((s = t.skuById[u._id]) == null ? void 0 : s.code) ?? ""})`;
623
- },
624
- cell: ({ row: u }) => {
625
- const o = t.skuById[u.original._id];
626
- return de(
627
- "div",
628
- {
629
- class: "w-full flex flex-col"
630
- },
631
- [
632
- de("div", { class: "fm-typo-en-body-lg-400 line-clamp-1" }, o.name),
633
- de(
634
- "div",
635
- { class: "fm-typo-en-body-md-400 line-clamp-1 text-fm-color-typo-secondary" },
636
- o.code
637
- )
638
- ]
639
- );
640
- },
641
- size: "auto",
642
- enableSorting: !1
643
- },
644
- {
645
- id: "unit",
646
- header: () => l("inventory.inventoryBindings.alternativeTable.unit"),
647
- accessorFn: (u) => {
648
- const o = t.skuById[u._id];
649
- return o.unit.measurements.computeFirst(
650
- (s) => s.id === u.trackingMeasurement ? s.name : null
651
- ) ?? o.unit.name;
652
- },
653
- enableSorting: !1
654
- },
655
- {
656
- id: "unitOption",
657
- header: () => l("inventory.inventoryBindings.alternativeTable.unit"),
658
- accessorKey: "trackingMeasurement",
659
- cell(u) {
660
- const o = t.skuById[u.row.original._id];
661
- if (!o) return null;
662
- const s = [
663
- {
664
- label: o.unit.name,
665
- sublabel: o.unit.abbrev,
666
- value: null
667
- },
668
- ...o.unit.measurements.map((a) => ({
669
- label: `${a.name} (${a.abbrev})`,
670
- sublabel: l("inventory.inventoryBindings.alternativeTable.measurementOption"),
671
- value: a.id
672
- }))
673
- ].filter((a) => !a.label.toLowerCase().includes("inactive"));
674
- return de(_e.FmSelect, {
675
- modelValue: u.row.original.trackingMeasurement ?? null,
676
- items: s,
677
- disabled: p.disabled ?? !1,
678
- "onUpdate:modelValue": (a) => {
679
- p.bindingAlternatives = p.bindingAlternatives.map((g) => g._id === u.row.original._id ? { ...g, trackingMeasurement: a } : g);
680
- }
681
- });
682
- },
683
- enableSorting: !1
684
- },
685
- {
686
- id: "priority",
687
- header: () => l("inventory.inventoryBindings.alternativeTable.priority"),
688
- accessorKey: "priority",
689
- enableSorting: !0,
690
- cell(u) {
691
- const o = u.row.original;
692
- return de(_e.FmTextField, {
693
- modelValue: o.priority ?? u.row.index + 1,
694
- rules: [
695
- Ft(),
696
- Ne(1),
697
- lt(
698
- p.bindingAlternatives.filter((s) => s._id !== o._id).map((s) => {
699
- const a = t.skuById[s._id];
700
- return {
701
- label: a == null ? void 0 : a.name,
702
- value: s.priority
703
- };
704
- })
705
- )
706
- ],
707
- "onUpdate:modelValue": (s) => {
708
- const a = Number(s);
709
- isNaN(a) || (p.bindingAlternatives = p.bindingAlternatives.map((g) => g._id === u.row.original._id ? { ...g, priority: a } : g));
710
- }
711
- });
712
- }
713
- },
714
- {
715
- id: "default",
716
- header: () => "",
717
- accessorKey: "default",
718
- cell(u) {
719
- const o = t.skuById[u.row.original._id];
720
- return o ? de(_e.FmCheckbox, {
721
- modelValue: u.row.original.default ?? !1,
722
- value: o._id,
723
- disabled: p.disabled ?? !1,
724
- "onUpdate:modelValue": () => {
725
- p.bindingAlternatives = p.bindingAlternatives.map((s) => s._id === u.row.original._id ? { ...s, default: !0 } : { ...s, default: !1 });
726
- }
727
- }) : null;
728
- },
729
- enableSorting: !1,
730
- size: 40,
731
- meta: {
732
- cellClass: "",
733
- headerClass: ""
734
- }
735
- },
736
- {
737
- id: "move",
738
- header: "",
739
- cell(u) {
740
- const o = u.row.original;
741
- return de("div", { class: "w-full flex justify-end" }, [
742
- de(_e.FmButton, {
743
- key: o._id,
744
- type: "button",
745
- icon: "keyboard_arrow_up",
746
- variant: "tertiary",
747
- size: "md",
748
- disabled: p.disabled ?? !1,
749
- onClick: () => {
750
- const s = [...p.bindingAlternatives], a = s.findIndex((g) => g._id === o._id);
751
- if (a > 0) {
752
- const g = s[a - 1];
753
- s[a - 1] = o, s[a] = g;
754
- }
755
- p.bindingAlternatives = [...s];
756
- }
757
- }),
758
- de(_e.FmButton, {
759
- key: o._id,
760
- type: "button",
761
- icon: "keyboard_arrow_down",
762
- variant: "tertiary",
763
- size: "md",
764
- disabled: p.disabled ?? !1,
765
- onClick: () => {
766
- const s = [...p.bindingAlternatives], a = s.findIndex((g) => g._id === o._id);
767
- if (a < s.length - 1) {
768
- const g = s[a + 1];
769
- s[a + 1] = o, s[a] = g;
770
- }
771
- p.bindingAlternatives = [...s];
772
- }
773
- })
774
- ]);
775
- },
776
- enableSorting: !1,
777
- size: 40,
778
- meta: {
779
- cellClass: "",
780
- headerClass: ""
781
- }
782
- }
783
- ]);
784
- return {
785
- get columnDefs() {
786
- return i.value;
787
- },
788
- promptAddIngredient: async ($) => {
789
- const u = [];
790
- for (const a of t.skus)
791
- $.includes(a._id) || u.push({
792
- label: a.name,
793
- sublabel: a.code,
794
- value: a._id,
795
- disabled: $.includes(a._id)
796
- });
797
- const o = (p.bindingAlternatives ?? []).map((a) => a._id), s = await d.multiSelect(u, o, (a) => {
798
- var h, C, I, m, _, w;
799
- const g = (h = p.bindingAlternatives) == null ? void 0 : h.findIndex((y) => y._id === a);
800
- return {
801
- _id: a,
802
- trackingMeasurement: typeof g != "number" || g == -1 ? (C = t.skuById[a]) == null ? void 0 : C.trackingMeasurement : (m = (I = p.bindingAlternatives) == null ? void 0 : I[g]) == null ? void 0 : m.trackingMeasurement,
803
- priority: ((w = (_ = p.bindingAlternatives) == null ? void 0 : _[g]) == null ? void 0 : w.priority) ?? p.bindingAlternatives.length,
804
- default: !1
805
- };
806
- });
807
- p.bindingAlternatives = s ?? p.bindingAlternatives;
808
- },
809
- columnVisibility: {
810
- delete: !0,
811
- unit: !1,
812
- unitOption: !0,
813
- default: !1,
814
- // previous demo: sort priority by moving sku element in the array,
815
- // new demo: sort priority using priority field.
816
- // can reenable if this use case is requested to be restored
817
- move: !1
818
- }
819
- };
820
- }
821
- const pn = { class: "flex flex-col gap-16" }, mn = { class: "flex flex-col" }, fn = { class: "flex justify-between items-center px-2" }, Se = /* @__PURE__ */ le({
822
- __name: "InventoryBindingAlternative",
823
- props: {
824
- disabled: { type: Boolean },
825
- modelValue: {},
826
- filterIngredientIds: {}
827
- },
828
- emits: ["update:modelValue"],
829
- setup(p, { emit: d }) {
830
- const l = p, t = d, { t: i } = ie(), r = cn({
831
- get disabled() {
832
- return l.disabled ?? !1;
833
- },
834
- get bindingAlternatives() {
835
- return l.modelValue ?? [];
836
- },
837
- set bindingAlternatives(o) {
838
- t("update:modelValue", o);
839
- }
840
- }), $ = (o) => o && o.some((s) => l.filterIngredientIds.includes(s._id)) ? "Contains invalid ingredient" : !0, u = (o) => o && o.length > 5 ? i("inventory.binding.alternative.maximumExceeded", { max: 5 }) : !0;
841
- return (o, s) => {
842
- var I;
843
- const a = G("FmLabel"), g = G("FmButton"), h = G("FmFormGroup"), C = G("FmTable");
844
- return v(), V("div", pn, [
845
- f("div", mn, [
846
- f("div", fn, [
847
- x(a, {
848
- label: n(i)("inventory.alternatives")
849
- }, null, 8, ["label"]),
850
- x(g, {
851
- disabled: o.disabled,
852
- "prepend-icon": "link",
853
- variant: "primary",
854
- class: "border-1 rounded-lg border-fm-color-primary",
855
- onClick: s[0] || (s[0] = (m) => n(r).promptAddIngredient(o.filterIngredientIds)),
856
- size: "md"
857
- }, null, 8, ["disabled"])
858
- ]),
859
- x(h, {
860
- "model-value": o.modelValue,
861
- rules: [$, u]
862
- }, null, 8, ["model-value", "rules"])
863
- ]),
864
- x(C, {
865
- "row-data": o.modelValue ?? [],
866
- "column-defs": n(r).columnDefs,
867
- "page-size": ((I = o.modelValue) == null ? void 0 : I.length) || 0,
868
- "shrink-at": 9999,
869
- "column-visibility": n(r).columnVisibility,
870
- "hide-footer": ""
871
- }, null, 8, ["row-data", "column-defs", "page-size", "column-visibility"])
872
- ]);
873
- };
874
- }
875
- }), vn = { class: "border-1 mx-3 my-1 rounded-md" }, yn = { class: "flex flex-col border-b border-fm-color-neutral-gray-100" }, bn = {
876
- class: "flex items-center w-full",
877
- style: { "min-height": "48px" }
878
- }, gn = { class: "flex-1 fm-typo-en-body-md-400 py-8 px-12" }, _n = { class: "line-clamp-1 w-full" }, kn = { class: "w-[150px]" }, hn = {
879
- key: 0,
880
- class: "w-[52px]"
881
- }, xn = { class: "flex flex-col px-12 pb-4" }, $n = /* @__PURE__ */ le({
882
- __name: "InventorySkuBindingV2Field",
883
- props: {
884
- disabled: { type: Boolean },
885
- readonly: { type: Boolean },
886
- modelValue: {},
887
- displayName: {},
888
- unit: {},
889
- showError: { type: Boolean },
890
- ableToConfigureAlternative: { type: Boolean },
891
- ableToApplyRules: { type: Boolean }
892
- },
893
- emits: ["update:modelValue", "delete", "settings"],
894
- setup(p, { emit: d }) {
895
- const l = d, { t } = ie(), i = rt("modelValue");
896
- function r(u) {
897
- u && (i.amount = u.amount, i.measurement = u.measurement);
898
- }
899
- function $() {
900
- return {
901
- modelValue: {
902
- amount: i.amount,
903
- measurement: i.measurement
904
- },
905
- amountAsString: zt.toFormatString({
906
- value: i.amount
907
- })
908
- };
909
- }
910
- return (u, o) => {
911
- const s = G("FmTooltip"), a = G("FmButton"), g = G("FmFormGroup");
912
- return v(), V("div", vn, [
913
- f("div", yn, [
914
- f("div", bn, [
915
- f("div", gn, [
916
- x(s, {
917
- zIndex: 51,
918
- variant: "plain",
919
- placement: "top",
920
- content: u.displayName
921
- }, {
922
- default: J(() => [
923
- f("span", _n, U(u.displayName), 1)
924
- ]),
925
- _: 1
926
- }, 8, ["content"])
927
- ]),
928
- f("div", kn, [
929
- x(Be, {
930
- "model-value": { amount: n(i).amount, measurement: n(i).measurement },
931
- "onUpdate:modelValue": r,
932
- unit: u.unit,
933
- placement: "bottom",
934
- "convert-amount-on-change-unit": "",
935
- disabled: u.readonly
936
- }, null, 8, ["model-value", "unit", "disabled"])
937
- ]),
938
- u.readonly ? T("", !0) : (v(), V("div", hn, [
939
- x(a, {
940
- disabled: u.disabled,
941
- type: "button",
942
- variant: "tertiary",
943
- icon: "delete",
944
- onClick: o[0] || (o[0] = () => l("delete", n(i).id))
945
- }, null, 8, ["disabled"])
946
- ]))
947
- ]),
948
- f("div", xn, [
949
- x(g, {
950
- modelValue: n(i).amount,
951
- rules: [n(qe)(0)]
952
- }, null, 8, ["modelValue", "rules"]),
953
- x(g, {
954
- modelValue: $(),
955
- rules: [
956
- n(Mt)(),
957
- n(Dt)(u.unit),
958
- () => u.showError ? n(t)("inventory.inventoryBindings.invalidWarning") : !0
959
- ]
960
- }, null, 8, ["modelValue", "rules"])
961
- ]),
962
- u.ableToApplyRules ? (v(), Y(Re, {
963
- key: 0,
964
- modelValue: n(i).rules,
965
- "onUpdate:modelValue": o[1] || (o[1] = (h) => n(i).rules = h),
966
- disabled: u.disabled
967
- }, null, 8, ["modelValue", "disabled"])) : T("", !0),
968
- u.ableToConfigureAlternative ? (v(), Y(Se, {
969
- key: 1,
970
- modelValue: n(i).alternatives,
971
- "onUpdate:modelValue": o[2] || (o[2] = (h) => n(i).alternatives = h),
972
- disabled: u.disabled,
973
- filterIngredientIds: [n(i).id]
974
- }, null, 8, ["modelValue", "disabled", "filterIngredientIds"])) : T("", !0)
975
- ])
976
- ]);
977
- };
978
- }
979
- });
980
- exports.FfCalculator;
981
- const In = { class: "flex flex-col gap-24" }, wn = {
982
- key: 0,
983
- class: "flex flex-col gap-16"
984
- }, En = { class: "flex items-center" }, Vn = { class: "flex-1 fm-typo-en-title-sm-600" }, Sn = { class: "flex flex-col" }, Cn = { class: "flex py-8 px-12 border-b border-fm-color-neutral-gray-200 bg-fm-color-neutral-gray-100 h-[44px] items-center" }, Bn = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, Fn = {
985
- key: 0,
986
- class: "w-[52px]"
987
- }, Rn = {
988
- key: 1,
989
- class: "w-[52px]"
990
- }, An = {
991
- key: 1,
992
- class: "flex flex-col gap-16"
993
- }, Tn = { class: "flex items-center" }, Un = { class: "flex-1 fm-typo-en-title-sm-600" }, Pn = { class: "flex flex-col" }, Mn = { class: "flex py-8 px-12 border-b border-fm-color-neutral-gray-200 bg-fm-color-neutral-gray-100 h-[44px] items-center" }, Dn = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, Gn = { class: "flex flex-col w-full border-b border-fm-color-neutral-gray-100" }, Nn = {
994
- key: 0,
995
- class: "flex gap-4 text-fm-color-system-error-400 fm-typo-en-body-sm-400"
996
- }, zn = {
997
- class: "flex items-center",
998
- style: { "min-height": "48px" }
999
- }, On = { class: "flex-1 fm-typo-en-body-md-400 py-8 px-12" }, jn = { class: "flex flex-col" }, Ln = { class: "w-[200px]" }, Kn = {
1000
- key: 0,
1001
- class: "w-[52px]"
1002
- }, qn = { class: "flex flex-col gap-16" }, Wn = { class: "flex items-center" }, Yn = { class: "flex-1 fm-typo-en-title-sm-600" }, Jn = { class: "flex flex-col" }, Hn = { class: "flex py-8 px-12 border-b border-fm-color-neutral-gray-200 bg-fm-color-neutral-gray-100 h-[44px] items-center" }, Qn = { class: "flex-1 fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, Xn = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary w-[150px] px-16" }, Zn = {
1003
- key: 0,
1004
- class: "w-[52px]"
1005
- }, eo = {
1006
- key: 0,
1007
- class: "flex flex-col border-b border-fm-color-neutral-gray-100"
1008
- }, to = {
1009
- class: "flex items-center w-full",
1010
- style: { "min-height": "48px" }
1011
- }, no = { class: "flex-1 fm-typo-en-body-md-400 py-8 px-12 text-fm-color-typo-secondary line-clamp-1" }, oo = {
1012
- key: 0,
1013
- class: "w-[52px]"
1014
- }, io = { class: "flex gap-4 text-fm-color-system-error-400 fm-typo-en-body-sm-400 px-12 pb-4" }, lo = /* @__PURE__ */ le({
1015
- __name: "InventoryBindingFormV2",
1016
- props: {
1017
- id: {},
1018
- modelValue: { default: () => [] },
1019
- excludeBindingId: {},
1020
- rules: { default: () => [] },
1021
- iframeMode: { type: Boolean },
1022
- disabled: { type: Boolean },
1023
- readonly: { type: Boolean },
1024
- recipeBindingConfig: { default: () => ({ enabled: !0, ableToApplyRules: !1 }) },
1025
- skuBindingConfig: { default: () => ({
1026
- enabled: !0,
1027
- ableToApplyRules: !1,
1028
- ableToConfigureAlternative: !1
1029
- }) },
1030
- enableIngredientGroup: { type: Boolean }
1031
- },
1032
- emits: ["update:modelValue", "click:pick-inventory-bindings"],
1033
- setup(p, { emit: d }) {
1034
- const { t: l } = ie(), t = ne(), i = R(() => t.recipeById), r = R(() => t.skuById), $ = R(() => t.skuGroupById), u = p, o = d, s = R(() => kt({
1035
- parentId: u.id,
1036
- bindings: u.modelValue,
1037
- recipes: t.recipes.map((F) => F._id === u.id ? {
1038
- ...F,
1039
- contains: u.modelValue
1040
- } : F),
1041
- skus: t.skus.map((F) => F._id === u.id ? {
1042
- ...F,
1043
- convert: {
1044
- inventoryBindings: u.modelValue
1045
- }
1046
- } : F),
1047
- skuGroups: t.skuGroups
1048
- }).inventoryBindings.filter((F) => "error" in F && F.error).map((F) => F).filter((F) => F.reason === ht.enum.circularDependency)), a = R(
1049
- () => new Set(s.value.map((b) => {
1050
- var B;
1051
- return (B = b.bindingPaths[0]) == null ? void 0 : B.id;
1052
- }))
1053
- ), g = R(() => u.modelValue.filter((b) => b.type === "RECIPE")), { promptIngredientsBinding: h, promptRecipesBinding: C, promptIngredientGroupsBinding: I } = Ht();
1054
- async function m() {
1055
- if (u.iframeMode) {
1056
- o("click:pick-inventory-bindings", "RECIPE");
1057
- return;
1058
- }
1059
- C(
1060
- u.modelValue,
1061
- (b) => o("update:modelValue", b),
1062
- u.id ? [u.id] : []
1063
- );
1064
- }
1065
- const _ = R(() => u.modelValue.filter((b) => b.type === "SKU_GROUP"));
1066
- async function w() {
1067
- I(
1068
- u.modelValue,
1069
- (b) => o("update:modelValue", b),
1070
- u.id ? [u.id] : []
1071
- );
1072
- }
1073
- function y(b, B, F) {
1074
- const A = +B;
1075
- let P = F;
1076
- B.length > 0 && isFinite(A) ? P = F.map((K) => (K.id !== b || (K.amount = Ke(A)), K)) : P = F.map((K) => (K.id !== b || (K.amount = { amount: 0, precision: 0 }), K)), o("update:modelValue", P);
1077
- }
1078
- const e = R(() => u.modelValue.filter((b) => b.type === "SKU") ?? []);
1079
- async function S() {
1080
- if (u.iframeMode) {
1081
- o("click:pick-inventory-bindings", "SKU");
1082
- return;
1083
- }
1084
- h(
1085
- u.modelValue,
1086
- (b) => o("update:modelValue", b),
1087
- u.excludeBindingId,
1088
- u.id ? [u.id] : []
1089
- );
1090
- }
1091
- function c(b) {
1092
- const B = u.modelValue.map((F) => F.id === b.id ? b : F);
1093
- o("update:modelValue", B);
1094
- }
1095
- function k(b) {
1096
- const B = u.modelValue.filter((F) => F.id !== b);
1097
- o("update:modelValue", B);
1098
- }
1099
- function N(b) {
1100
- var F, A;
1101
- if (b.type !== be.enum.SKU)
1102
- throw new Error("Non-SKU binding does not have unit");
1103
- if (!((F = r.value[b.id]) == null ? void 0 : F.unit))
1104
- throw new Error(`Cannot find ingredient: ${b.id}`);
1105
- return (A = r.value[b.id]) == null ? void 0 : A.unit;
1106
- }
1107
- function z(b) {
1108
- return !r.value[b.id];
1109
- }
1110
- return (b, B) => {
1111
- var H, ee, O;
1112
- const F = G("FmFormGroup"), A = G("FmButton"), P = G("FmIcon"), K = G("FmTextField");
1113
- return v(), V("div", In, [
1114
- x(F, {
1115
- disabled: b.disabled,
1116
- "model-value": b.modelValue,
1117
- rules: [
1118
- ...b.rules,
1119
- () => s.value.length ? "There is a binding error in your configuration" : !0
1120
- ]
1121
- }, {
1122
- label: J(() => B[4] || (B[4] = [
1123
- f("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Define the inventory bindings for this recipe or ingredient. ", -1)
1124
- ])),
1125
- _: 1
1126
- }, 8, ["disabled", "model-value", "rules"]),
1127
- ((H = b.recipeBindingConfig) == null ? void 0 : H.enabled) !== !1 ? (v(), V("div", wn, [
1128
- f("div", En, [
1129
- f("div", Vn, U(n(l)("inventory.inventoryBindings.recipe")), 1),
1130
- b.readonly ? T("", !0) : (v(), Y(A, {
1131
- key: 0,
1132
- variant: "secondary",
1133
- "text-color": "primary",
1134
- "border-color": "primary",
1135
- label: n(l)("inventory.inventoryBindings.linkRecipe"),
1136
- "prepend-icon": "link",
1137
- onClick: m
1138
- }, null, 8, ["label"]))
1139
- ]),
1140
- f("div", Sn, [
1141
- f("div", Cn, [
1142
- f("div", Bn, U(n(l)("inventory.inventoryBindings.recipe")), 1),
1143
- B[5] || (B[5] = f("div", { class: "w-[200px]" }, null, -1)),
1144
- b.recipeBindingConfig.ableToApplyRules ? (v(), V("div", Fn)) : T("", !0),
1145
- b.readonly ? T("", !0) : (v(), V("div", Rn))
1146
- ]),
1147
- (v(!0), V(X, null, me(g.value, (M) => {
1148
- var j;
1149
- return v(), Y(un, {
1150
- key: M.id,
1151
- "model-value": M,
1152
- "display-name": (j = i.value[M.id]) == null ? void 0 : j.name,
1153
- "show-error": a.value.has(M.id),
1154
- readonly: b.readonly,
1155
- disabled: b.disabled,
1156
- "onUpdate:modelValue": B[0] || (B[0] = (q) => c(q)),
1157
- onDelete: B[1] || (B[1] = (q) => k(q))
1158
- }, null, 8, ["model-value", "display-name", "show-error", "readonly", "disabled"]);
1159
- }), 128))
1160
- ])
1161
- ])) : T("", !0),
1162
- b.enableIngredientGroup ? (v(), V("div", An, [
1163
- f("div", Tn, [
1164
- f("div", Un, U(n(l)("inventory.inventoryBindings.ingredientGroup")), 1),
1165
- b.readonly ? T("", !0) : (v(), Y(A, {
1166
- key: 0,
1167
- variant: "secondary",
1168
- "text-color": "primary",
1169
- "border-color": "primary",
1170
- label: n(l)("inventory.inventoryBindings.linkIngredientGroup"),
1171
- "prepend-icon": "link",
1172
- onClick: w
1173
- }, null, 8, ["label"]))
1174
- ]),
1175
- f("div", Pn, [
1176
- f("div", Mn, [
1177
- f("div", Dn, U(n(l)("inventory.inventoryBindings.ingredientGroup")), 1),
1178
- B[6] || (B[6] = f("div", { class: "w-[200px]" }, null, -1)),
1179
- B[7] || (B[7] = f("div", { class: "w-[52px]" }, null, -1))
1180
- ]),
1181
- (v(!0), V(X, null, me(_.value, (M) => (v(), Y(F, {
1182
- key: M.id,
1183
- disabled: b.disabled,
1184
- modelValue: +n(Q)(M.amount ?? { amount: 1, precision: 0 }),
1185
- rules: [n(it)(0), n(qe)(0)]
1186
- }, {
1187
- default: J(({ invalid: j }) => {
1188
- var q;
1189
- return [
1190
- f("div", Gn, [
1191
- a.value.has(M.id) ? (v(), V("div", Nn, [
1192
- x(P, {
1193
- name: "error",
1194
- color: "system-error-300",
1195
- size: "sm"
1196
- }),
1197
- f("div", null, U(n(l)("inventory.inventoryBindings.circularError")), 1)
1198
- ])) : T("", !0),
1199
- f("div", zn, [
1200
- f("div", On, [
1201
- f("div", jn, U((q = $.value[M.id]) == null ? void 0 : q.name), 1)
1202
- ]),
1203
- f("div", Ln, [
1204
- x(K, {
1205
- class: "w-full",
1206
- disabled: b.disabled,
1207
- modelValue: +n(Q)(M.amount ?? { amount: 1, precision: 0 }),
1208
- "onUpdate:modelValue": (oe) => y(M.id, oe, b.modelValue),
1209
- invalid: j
1210
- }, null, 8, ["disabled", "modelValue", "onUpdate:modelValue", "invalid"])
1211
- ]),
1212
- b.readonly ? T("", !0) : (v(), V("div", Kn, [
1213
- x(A, {
1214
- disabled: b.disabled,
1215
- type: "button",
1216
- variant: "plain",
1217
- icon: "delete",
1218
- "icon-color": "#000000",
1219
- onClick: (oe) => k(M.id)
1220
- }, null, 8, ["disabled", "onClick"])
1221
- ]))
1222
- ])
1223
- ])
1224
- ];
1225
- }),
1226
- _: 2
1227
- }, 1032, ["disabled", "modelValue", "rules"]))), 128))
1228
- ])
1229
- ])) : T("", !0),
1230
- f("div", qn, [
1231
- f("div", Wn, [
1232
- f("div", Yn, U(n(l)("inventory.inventoryBindings.ingredient")), 1),
1233
- b.readonly ? T("", !0) : (v(), Y(A, {
1234
- key: 0,
1235
- variant: "secondary",
1236
- "text-color": "primary",
1237
- "border-color": "primary",
1238
- label: n(l)("inventory.inventoryBindings.linkIngredient"),
1239
- "prepend-icon": "link",
1240
- onClick: S
1241
- }, null, 8, ["label"]))
1242
- ]),
1243
- f("div", Jn, [
1244
- f("div", Hn, [
1245
- f("div", Qn, U(n(l)("inventory.inventoryBindings.ingredient")), 1),
1246
- f("div", Xn, U(n(l)("inventory.inventoryBindings.amount")), 1),
1247
- B[8] || (B[8] = f("div", { class: "w-[52px]" }, null, -1)),
1248
- (ee = b.skuBindingConfig) != null && ee.ableToApplyRules || (O = b.skuBindingConfig) != null && O.ableToConfigureAlternative ? (v(), V("div", Zn)) : T("", !0)
1249
- ]),
1250
- (v(!0), V(X, null, me(e.value, (M) => {
1251
- var j, q, oe;
1252
- return v(), V(X, {
1253
- key: M.id
1254
- }, [
1255
- z(M) ? (v(), V("div", eo, [
1256
- f("div", to, [
1257
- f("div", no, U(M.id), 1),
1258
- b.readonly ? T("", !0) : (v(), V("div", oo, [
1259
- x(A, {
1260
- disabled: b.disabled,
1261
- type: "button",
1262
- variant: "tertiary",
1263
- icon: "delete",
1264
- onClick: () => k(M.id)
1265
- }, null, 8, ["disabled", "onClick"])
1266
- ]))
1267
- ]),
1268
- f("div", io, [
1269
- x(P, {
1270
- name: "error",
1271
- color: "system-error-300",
1272
- size: "sm"
1273
- }),
1274
- f("div", null, U(n(l)("inventory.inventoryBindings.missingIngredient")), 1)
1275
- ])
1276
- ])) : (v(), Y($n, {
1277
- key: 1,
1278
- "model-value": M,
1279
- "display-name": (j = r.value[M.id]) == null ? void 0 : j.name,
1280
- unit: N(M),
1281
- "show-error": a.value.has(M.id),
1282
- "able-to-apply-rules": ((q = b.skuBindingConfig) == null ? void 0 : q.ableToApplyRules) === !0,
1283
- "able-to-configure-alternative": ((oe = b.skuBindingConfig) == null ? void 0 : oe.ableToConfigureAlternative) === !0,
1284
- readonly: b.readonly,
1285
- disabled: b.disabled,
1286
- "onUpdate:modelValue": B[2] || (B[2] = (Z) => c(Z)),
1287
- onDelete: B[3] || (B[3] = (Z) => k(Z))
1288
- }, null, 8, ["model-value", "display-name", "unit", "show-error", "able-to-apply-rules", "able-to-configure-alternative", "readonly", "disabled"]))
1289
- ], 64);
1290
- }), 128))
1291
- ])
1292
- ])
1293
- ]);
1294
- };
1295
- }
1296
- }), ro = { class: "flex flex-col gap-40" }, ao = {
1297
- key: 0,
1298
- class: "flex flex-col gap-16"
1299
- }, so = {
1300
- key: 0,
1301
- class: "col-span-2 mt-16 border-1 border-fm-color-neutral-gray-200 fm-corner-radius-lg flex flex-col p-16 gap-16"
1302
- }, uo = {
1303
- key: 0,
1304
- class: "flex flex-col items-center w-full h-full gap-24"
1305
- }, co = { key: 1 }, po = { class: "mt-32" }, mo = /* @__PURE__ */ le({
1306
- __name: "RecipeForm",
1307
- props: {
1308
- mode: {},
1309
- modelValue: {},
1310
- disabled: { type: Boolean }
1311
- },
1312
- emits: ["update:modelValue", "click:submit"],
1313
- setup(p, { expose: d, emit: l }) {
1314
- const t = p, i = l, r = We(), { t: $ } = ie(), u = R({
1315
- get() {
1316
- var c;
1317
- return ((c = t.modelValue) == null ? void 0 : c.name) ?? "";
1318
- },
1319
- set(c) {
1320
- const k = t.modelValue ?? {};
1321
- k.name = c, i("update:modelValue", k);
1322
- }
1323
- }), o = R({
1324
- get() {
1325
- var c;
1326
- return ((c = t.modelValue) == null ? void 0 : c.contains) ?? [];
1327
- },
1328
- set(c) {
1329
- const k = t.modelValue ?? {};
1330
- k.contains = c, i("update:modelValue", k);
1331
- }
1332
- }), s = R({
1333
- get() {
1334
- var c;
1335
- return ((c = t.modelValue) == null ? void 0 : c.customAttributes) ?? {};
1336
- },
1337
- set(c) {
1338
- const k = t.modelValue ? {
1339
- ...t.modelValue
1340
- } : {};
1341
- k.customAttributes = c, i("update:modelValue", k);
1342
- }
1343
- }), a = R({
1344
- get() {
1345
- var c;
1346
- return ((c = t.modelValue) == null ? void 0 : c.version) ?? null;
1347
- },
1348
- set(c) {
1349
- const k = t.modelValue ? { ...t.modelValue } : {};
1350
- k.version = c, i("update:modelValue", k);
1351
- }
1352
- }), g = R({
1353
- get() {
1354
- return a.value === "v2";
1355
- },
1356
- set(c) {
1357
- a.value = c ? "v2" : null;
1358
- }
1359
- });
1360
- function h() {
1361
- i("click:submit");
1362
- }
1363
- const C = W();
1364
- d({
1365
- validateInputs: () => {
1366
- var c, k;
1367
- (k = (c = C.value) == null ? void 0 : c.validateInputs) == null || k.call(c);
1368
- },
1369
- resetInputsValidation: () => {
1370
- var c, k;
1371
- (k = (c = C.value) == null ? void 0 : c.resetInputsValidation) == null || k.call(c);
1372
- },
1373
- resetInputs: () => {
1374
- var c, k;
1375
- (k = (c = C.value) == null ? void 0 : c.resetInputs) == null || k.call(c);
1376
- }
1377
- });
1378
- const I = ne(), m = W([]), _ = W(!1), w = W(!1);
1379
- ue(_, async (c) => {
1380
- y(c);
1381
- });
1382
- async function y(c) {
1383
- var k, N;
1384
- c && !w.value && ((k = t.modelValue) != null && k._id) && (w.value = !0, m.value = await I.getAffectedMenu((N = t.modelValue) == null ? void 0 : N._id).delayed(500), w.value = !1);
1385
- }
1386
- const e = R(
1387
- () => I.recipes.map((c) => ({ label: c.name, value: c.name }))
1388
- ), S = R(() => {
1389
- var c;
1390
- return ((c = t.modelValue) == null ? void 0 : c.name) ?? "";
1391
- });
1392
- return (c, k) => {
1393
- const N = G("FmTextField"), z = G("FmSwitch"), b = G("FmCard"), B = G("FmSpacer"), F = G("FmCircularProgress"), A = G("FmForm");
1394
- return v(), Y(A, {
1395
- ref_key: "formRef",
1396
- ref: C,
1397
- onValidationSuccess: h
1398
- }, {
1399
- default: J(() => [
1400
- f("div", ro, [
1401
- x(N, {
1402
- disabled: c.disabled,
1403
- label: n($)("inventory.recipe.name"),
1404
- "model-value": u.value,
1405
- "onUpdate:modelValue": k[0] || (k[0] = (P) => u.value = P),
1406
- rules: [
1407
- n(Rt)(),
1408
- n(lt)(e.value, S.value, (P) => `[${P.value}] already exists`)
1409
- ],
1410
- "label-mark": "required"
1411
- }, null, 8, ["disabled", "label", "model-value", "rules"]),
1412
- n(r).enableRecipeV2 ? (v(), V("div", ao, [
1413
- x(z, {
1414
- modelValue: g.value,
1415
- "onUpdate:modelValue": k[1] || (k[1] = (P) => g.value = P),
1416
- value: !0,
1417
- label: n($)("inventory.recipe.enableRecipeV2"),
1418
- "label-placement": "right",
1419
- disabled: c.disabled,
1420
- sublabel: n($)("inventory.recipe.recipeV2Warning")
1421
- }, null, 8, ["modelValue", "label", "disabled", "sublabel"])
1422
- ])) : T("", !0),
1423
- x(b, {
1424
- variant: "outlined",
1425
- class: "p-16"
1426
- }, {
1427
- default: J(() => {
1428
- var P, K;
1429
- return [
1430
- n(r).enableRecipeV2 ? (v(), Y(lo, {
1431
- key: 0,
1432
- id: (P = c.modelValue) == null ? void 0 : P._id,
1433
- disabled: c.disabled,
1434
- "model-value": o.value,
1435
- "onUpdate:modelValue": k[2] || (k[2] = (H) => o.value = H),
1436
- rules: [n(Ne)(1)],
1437
- "enable-ingredient-group": n(r).enableIngredientGroup,
1438
- "recipe-binding-config": { enabled: !g.value, ableToApplyRules: g.value },
1439
- "sku-binding-config": {
1440
- ableToConfigureAlternative: g.value
1441
- }
1442
- }, null, 8, ["id", "disabled", "model-value", "rules", "enable-ingredient-group", "recipe-binding-config", "sku-binding-config"])) : (v(), Y(At, {
1443
- key: 1,
1444
- id: (K = c.modelValue) == null ? void 0 : K._id,
1445
- disabled: c.disabled,
1446
- "model-value": o.value,
1447
- "onUpdate:modelValue": k[3] || (k[3] = (H) => o.value = H),
1448
- rules: [n(Ne)(1)],
1449
- "enable-ingredient-group": n(r).enableIngredientGroup
1450
- }, null, 8, ["id", "disabled", "model-value", "rules", "enable-ingredient-group"]))
1451
- ];
1452
- }),
1453
- _: 1
1454
- })
1455
- ]),
1456
- c.mode !== n(se).CREATE ? (v(), V("div", so, [
1457
- x(z, {
1458
- label: "Show binded items",
1459
- modelValue: _.value,
1460
- "onUpdate:modelValue": k[4] || (k[4] = (P) => _.value = P),
1461
- "label-placement": "right",
1462
- disabled: w.value
1463
- }, null, 8, ["modelValue", "disabled"]),
1464
- w.value ? (v(), V("div", uo, [
1465
- x(B),
1466
- f("div", null, [
1467
- x(F, { size: "xl" })
1468
- ]),
1469
- k[6] || (k[6] = f("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary pl-8" }, "Loading...", -1)),
1470
- x(B)
1471
- ])) : _.value && m.value.length ? (v(), V("div", co, [
1472
- x(nt, {
1473
- name: "Menu",
1474
- bindings: m.value
1475
- }, null, 8, ["bindings"])
1476
- ])) : T("", !0)
1477
- ])) : T("", !0),
1478
- f("div", po, [
1479
- x(Ot, {
1480
- entity: "inventoryRecipe",
1481
- modelValue: s.value,
1482
- "onUpdate:modelValue": k[5] || (k[5] = (P) => s.value = P)
1483
- }, null, 8, ["modelValue"])
1484
- ])
1485
- ]),
1486
- _: 1
1487
- }, 512);
1488
- };
1489
- }
1490
- }), fo = { class: "flex gap-4" }, vo = /* @__PURE__ */ le({
1491
- __name: "RecipeDialog",
1492
- props: {
1493
- show: { type: Boolean },
1494
- recipe: {},
1495
- mode: { default: se.READ }
1496
- },
1497
- emits: ["update:show"],
1498
- setup(p) {
1499
- const d = p, l = ne(), t = Le(), { t: i } = ie(), r = Ge(d, "show"), $ = Ge(d, "recipe"), u = R(() => {
1500
- switch (d.mode) {
1501
- case se.READ:
1502
- return "";
1503
- case se.UPDATE:
1504
- return i("inventory.recipe.update.title");
1505
- case se.CREATE:
1506
- return i("inventory.recipe.create.title");
1507
- }
1508
- return "";
1509
- }), o = R(() => {
1510
- switch (d.mode) {
1511
- case se.READ:
1512
- return "";
1513
- case se.UPDATE:
1514
- return i("common.save");
1515
- case se.CREATE:
1516
- return i("common.add");
1517
- }
1518
- return "";
1519
- }), s = W(), a = W(!1);
1520
- async function g() {
1521
- a.value = !0;
1522
- try {
1523
- const m = Oe($.value);
1524
- m.precision ?? (m.precision = 0), m.measurements ?? (m.measurements = []), await l.createRecipe(m), r.value = !1, t.open({
1525
- title: i("inventory.common.success"),
1526
- message: i("inventory.recipe.create.success", { name: $.value.name }),
1527
- type: "success"
1528
- });
1529
- } catch (m) {
1530
- m instanceof Je || t.open({
1531
- title: i("inventory.recipe.create.error.title"),
1532
- message: i("inventory.recipe.create.error.message"),
1533
- type: "error"
1534
- });
1535
- } finally {
1536
- a.value = !1;
1537
- }
1538
- }
1539
- async function h() {
1540
- a.value = !0;
1541
- try {
1542
- await l.updateRecipe($.value), r.value = !1, t.open({
1543
- title: i("inventory.common.success"),
1544
- message: i("inventory.recipe.update.success", { name: $.value.name }),
1545
- type: "success"
1546
- });
1547
- } catch (m) {
1548
- m instanceof Je || t.open({
1549
- title: i("inventory.recipe.update.error.title"),
1550
- message: i("inventory.recipe.update.error.message"),
1551
- type: "error"
1552
- });
1553
- } finally {
1554
- a.value = !1;
1555
- }
1556
- }
1557
- function C() {
1558
- var m, _;
1559
- (_ = (m = s.value) == null ? void 0 : m.validateInputs) == null || _.call(m);
1560
- }
1561
- function I() {
1562
- switch (d.mode) {
1563
- case se.READ:
1564
- return;
1565
- case se.UPDATE:
1566
- return h();
1567
- case se.CREATE:
1568
- return g();
1569
- }
1570
- }
1571
- return (m, _) => {
1572
- const w = G("FmButton"), y = G("FmSideSheet");
1573
- return v(), Y(y, {
1574
- "model-value": n(r),
1575
- "onUpdate:modelValue": _[3] || (_[3] = (e) => De(r) ? r.value = e : null),
1576
- header: u.value,
1577
- "close-button": "",
1578
- "dismiss-away": "",
1579
- "max-width": 800
1580
- }, {
1581
- "side-sheet-footer": J(() => [
1582
- f("div", fo, [
1583
- x(w, {
1584
- loading: a.value,
1585
- label: o.value,
1586
- onClick: C
1587
- }, null, 8, ["loading", "label"]),
1588
- x(w, {
1589
- disabled: a.value,
1590
- label: n(i)("common.close"),
1591
- variant: "tertiary",
1592
- onClick: _[2] || (_[2] = (e) => r.value = !1)
1593
- }, null, 8, ["disabled", "label"])
1594
- ])
1595
- ]),
1596
- default: J(() => [
1597
- x(mo, {
1598
- class: "w-full",
1599
- ref_key: "hasValidationExpose",
1600
- ref: s,
1601
- modelValue: n($),
1602
- "onUpdate:modelValue": _[0] || (_[0] = (e) => De($) ? $.value = e : null),
1603
- mode: m.mode,
1604
- disabled: a.value,
1605
- "onClick:submit": _[1] || (_[1] = (e) => I())
1606
- }, null, 8, ["modelValue", "mode", "disabled"])
1607
- ]),
1608
- _: 1
1609
- }, 8, ["model-value", "header"]);
1610
- };
1611
- }
1612
- });
1613
- function ke(p, d, l) {
1614
- const t = [];
1615
- for (const i of p)
1616
- if (i.type === be.enum.SKU)
1617
- t.push({ ...i, recipeIds: [...d] });
1618
- else if (i.type === be.enum.SKU_GROUP)
1619
- t.push({ ...i, isGroup: !0, recipeIds: [...d] });
1620
- else if (i.type === be.enum.RECIPE) {
1621
- const r = l[i.id];
1622
- r && !d.has(i.id) && t.push(
1623
- ...ke(r.contains, /* @__PURE__ */ new Set([...d, i.id]), l)
1624
- );
1625
- }
1626
- return t;
1627
- }
1628
- function yo(p, d) {
1629
- return he.equal(p, d);
1630
- }
1631
- function Ae(p) {
1632
- if (p == null) return null;
1633
- const d = p.$and, l = p.$or;
1634
- return Array.isArray(d) && d.length === 0 || Array.isArray(l) && l.length === 0 || Object.keys(p).length === 0 ? null : JSON.stringify(p);
1635
- }
1636
- function Te(p) {
1637
- const d = (p ?? []).map((l) => ({
1638
- _id: l._id,
1639
- trackingMeasurement: l.trackingMeasurement ?? null,
1640
- priority: l.priority ?? null,
1641
- default: l.default ?? null
1642
- })).sort((l, t) => l._id.localeCompare(t._id));
1643
- return JSON.stringify(d);
1644
- }
1645
- function Xe(p) {
1646
- return p.measurement ? he.multiplyDecimal(p.amount, p.measurement.conversion) : p.amount;
1647
- }
1648
- function Me(p, d) {
1649
- var i, r;
1650
- if (p.type !== d.type || p.id !== d.id || !yo(Xe(p), Xe(d))) return !1;
1651
- const l = ((i = p.measurement) == null ? void 0 : i.id) ?? null, t = ((r = d.measurement) == null ? void 0 : r.id) ?? null;
1652
- return !(l !== t || Ae(p.rules) !== Ae(d.rules) || Te(p.alternatives) !== Te(d.alternatives));
1653
- }
1654
- function Ze(p, d) {
1655
- return p.type === d.type && p.id === d.id;
1656
- }
1657
- function bo(p, d) {
1658
- const l = [];
1659
- let t = [...p.contains];
1660
- for (const r of d)
1661
- switch (r.type) {
1662
- case "remove-binding": {
1663
- const $ = t.findIndex(
1664
- (u) => u.type === r.target.type && u.id === r.target.id
1665
- );
1666
- $ === -1 ? l.push({ change: r, outcome: "ignored", reason: "Source binding not found in target" }) : (t = [...t.slice(0, $), ...t.slice($ + 1)], l.push({ change: r, outcome: "applied" }));
1667
- break;
1668
- }
1669
- case "add-binding": {
1670
- if (t.find((o) => Me(o, r.binding))) {
1671
- l.push({ change: r, outcome: "already-satisfied", reason: "Exact binding already present" });
1672
- break;
1673
- }
1674
- if (t.find((o) => Ze(o, r.binding))) {
1675
- l.push({ change: r, outcome: "blocked", reason: "A similar but non-exact binding already exists" });
1676
- break;
1677
- }
1678
- if (p.version === "v2" && r.binding.type === "RECIPE") {
1679
- l.push({ change: r, outcome: "blocked", reason: "Cannot add RECIPE binding to a V2 recipe" });
1680
- break;
1681
- }
1682
- if (p.version !== "v2" && (r.binding.alternatives ?? []).length > 0) {
1683
- l.push({ change: r, outcome: "blocked", reason: "Cannot add a binding with alternatives to a non-V2 recipe" });
1684
- break;
1685
- }
1686
- t = [...t, r.binding], l.push({ change: r, outcome: "applied" });
1687
- break;
1688
- }
1689
- case "replace-binding": {
1690
- const $ = t.findIndex(
1691
- (s) => s.type === r.from.type && s.id === r.from.id
1692
- ), u = t.find((s) => Me(s, r.to)), o = t.find((s, a) => a !== $ && Ze(s, r.to) && !Me(s, r.to));
1693
- if ($ === -1) {
1694
- u ? l.push({ change: r, outcome: "already-satisfied", reason: "Target already has exact replacement" }) : l.push({ change: r, outcome: "ignored", reason: "Source binding not found in target" });
1695
- break;
1696
- }
1697
- if (p.version === "v2" && r.to.type === "RECIPE") {
1698
- l.push({ change: r, outcome: "blocked", reason: "Cannot add RECIPE binding to a V2 recipe" });
1699
- break;
1700
- }
1701
- if (p.version !== "v2" && (r.to.alternatives ?? []).length > 0) {
1702
- l.push({ change: r, outcome: "blocked", reason: "Cannot apply a binding with alternatives to a non-V2 recipe" });
1703
- break;
1704
- }
1705
- if (o) {
1706
- l.push({ change: r, outcome: "blocked", reason: "A similar but non-exact replacement binding already exists" });
1707
- break;
1708
- }
1709
- u ? (t = [...t.slice(0, $), ...t.slice($ + 1)], l.push({ change: r, outcome: "applied", reason: "Source removed; replacement already present" })) : (t = [
1710
- ...t.slice(0, $),
1711
- r.to,
1712
- ...t.slice($ + 1)
1713
- ], l.push({ change: r, outcome: "applied" }));
1714
- break;
1715
- }
1716
- case "update-binding-rule": {
1717
- const $ = t.findIndex(
1718
- (a) => a.type === r.target.type && a.id === r.target.id
1719
- );
1720
- if ($ === -1) {
1721
- l.push({ change: r, outcome: "ignored", reason: "Binding not found in target" });
1722
- break;
1723
- }
1724
- const u = t[$], o = u.rules ?? null, s = r.rule ?? null;
1725
- if (Ae(o) === Ae(s)) {
1726
- l.push({ change: r, outcome: "already-satisfied", reason: "Rule already matches" });
1727
- break;
1728
- }
1729
- t = [
1730
- ...t.slice(0, $),
1731
- { ...u, rules: s },
1732
- ...t.slice($ + 1)
1733
- ], l.push({ change: r, outcome: "applied" });
1734
- break;
1735
- }
1736
- case "update-alternatives": {
1737
- if (p.version !== "v2") {
1738
- l.push({ change: r, outcome: "blocked", reason: "Cannot update alternatives on a non-V2 recipe" });
1739
- break;
1740
- }
1741
- const $ = t.findIndex(
1742
- (a) => a.type === r.target.type && a.id === r.target.id
1743
- );
1744
- if ($ === -1) {
1745
- l.push({ change: r, outcome: "ignored", reason: "Binding not found in target" });
1746
- break;
1747
- }
1748
- const u = t[$], o = Te(u.alternatives), s = Te(r.alternatives);
1749
- if (o === s) {
1750
- l.push({ change: r, outcome: "already-satisfied", reason: "Alternatives already match" });
1751
- break;
1752
- }
1753
- t = [
1754
- ...t.slice(0, $),
1755
- { ...u, alternatives: r.alternatives },
1756
- ...t.slice($ + 1)
1757
- ], l.push({ change: r, outcome: "applied" });
1758
- break;
1759
- }
1760
- }
1761
- return { projected: { ...p, contains: t }, results: l };
1762
- }
1763
- function et(p) {
1764
- switch (p.type) {
1765
- case "add-binding":
1766
- return p.binding.id !== "";
1767
- case "remove-binding":
1768
- return p.target.id !== "";
1769
- case "replace-binding":
1770
- return p.from.id !== "" && p.to.id !== "";
1771
- case "update-binding-rule":
1772
- return p.target.id !== "";
1773
- case "update-alternatives":
1774
- return p.target.id !== "";
1775
- }
1776
- }
1777
- function go(p) {
1778
- if (p.length === 0) return "no-applicable-changes";
1779
- let d = 0, l = 0, t = 0, i = 0;
1780
- for (const r of p)
1781
- r.outcome === "applied" ? d++ : r.outcome === "blocked" ? l++ : r.outcome === "ignored" ? t++ : r.outcome === "already-satisfied" && i++;
1782
- return l > 0 && d === 0 ? "blocked" : i === p.length ? "already-satisfied" : d > 0 && (t > 0 || l > 0) ? "partially-ignored" : d > 0 ? "will-update" : "no-applicable-changes";
1783
- }
1784
- let _o = 0;
1785
- function ko(p = null) {
1786
- return {
1787
- id: String(++_o),
1788
- type: p,
1789
- itemId: null,
1790
- amountModel: ye()
1791
- };
1792
- }
1793
- function ut(p, d, l, t) {
1794
- for (const i of p)
1795
- if (i.type === "RECIPE") {
1796
- if (i.id === d) return !0;
1797
- if (!l.has(i.id)) {
1798
- const r = t[i.id];
1799
- if (r && ut(r.contains, d, /* @__PURE__ */ new Set([...l, i.id]), t))
1800
- return !0;
1801
- }
1802
- }
1803
- return !1;
1804
- }
1805
- const ge = ot("recipeBulkEditor", function() {
1806
- const d = ne(), l = Le(), { t } = ie(), i = W(!1), r = W(1), $ = W(null), u = W(/* @__PURE__ */ new Set()), o = W([]), s = W({}), a = W(!1), g = W(/* @__PURE__ */ new Map()), h = W(""), C = W([]), I = R(() => {
1807
- let O = d.recipes;
1808
- const M = $.value;
1809
- if (M != null && M.nameSearch) {
1810
- const j = M.nameSearch.trim().toLowerCase();
1811
- j && (O = O.filter((q) => q.name.toLowerCase().includes(j)));
1812
- }
1813
- if (M != null && M.filters && M.filters.length > 0) {
1814
- const j = /* @__PURE__ */ new Map();
1815
- for (const q of O)
1816
- j.set(
1817
- q._id,
1818
- ke(q.contains, /* @__PURE__ */ new Set([q._id]), d.recipeById)
1819
- );
1820
- for (const q of M.filters)
1821
- if (q.type === "ingredient") {
1822
- const { itemId: oe, amount: Z, measurementId: ae } = q;
1823
- O = O.filter((fe) => (j.get(fe._id) ?? []).some((re) => {
1824
- var ce;
1825
- if (re.type !== "SKU" || re.id !== oe) return !1;
1826
- if (re.recipeIds.length === 1) {
1827
- if (Z != null) {
1828
- const Ue = re.measurement ? he.multiplyDecimal(re.amount, re.measurement.conversion) : re.amount;
1829
- if (!he.equal(Ue, Z)) return !1;
1830
- }
1831
- if (ae != null && (((ce = re.measurement) == null ? void 0 : ce.id) ?? null) !== ae)
1832
- return !1;
1833
- }
1834
- return !0;
1835
- }));
1836
- } else if (q.type === "recipe") {
1837
- const oe = q.itemId;
1838
- O = O.filter(
1839
- (Z) => ut(Z.contains, oe, /* @__PURE__ */ new Set([Z._id]), d.recipeById)
1840
- );
1841
- }
1842
- }
1843
- return O;
1844
- }), m = R(
1845
- () => I.value.filter((O) => !u.value.has(O._id))
1846
- ), _ = R(() => m.value.length > 0), w = R(() => {
1847
- const O = o.value.filter(et);
1848
- if (O.length === 0) {
1849
- const j = {};
1850
- for (const q of m.value)
1851
- j[q._id] = {
1852
- recipeId: q._id,
1853
- recipeName: q.name,
1854
- original: q,
1855
- projected: null,
1856
- status: "no-applicable-changes",
1857
- changes: [],
1858
- counts: { applied: 0, ignored: 0, blocked: 0, satisfied: 0 }
1859
- };
1860
- return j;
1861
- }
1862
- const M = {};
1863
- for (const j of m.value) {
1864
- const q = JSON.parse(JSON.stringify(j)), { projected: oe, results: Z } = bo(q, O), ae = go(Z);
1865
- let fe = 0, xe = 0, re = 0, ve = 0;
1866
- for (const ce of Z)
1867
- ce.outcome === "applied" ? fe++ : ce.outcome === "ignored" ? xe++ : ce.outcome === "blocked" ? re++ : ce.outcome === "already-satisfied" && ve++;
1868
- M[j._id] = {
1869
- recipeId: j._id,
1870
- recipeName: j.name,
1871
- original: q,
1872
- projected: ae === "will-update" || ae === "partially-ignored" ? oe : null,
1873
- status: ae,
1874
- changes: Z,
1875
- counts: { applied: fe, ignored: xe, blocked: re, satisfied: ve }
1876
- };
1877
- }
1878
- return M;
1879
- }), y = R(() => o.value.some(et) ? Object.values(w.value).some(
1880
- (O) => O.status === "will-update" || O.status === "partially-ignored"
1881
- ) : !1);
1882
- function e() {
1883
- c(), i.value = !0;
1884
- }
1885
- function S() {
1886
- i.value = !1;
1887
- }
1888
- function c() {
1889
- r.value = 1, $.value = null, u.value = /* @__PURE__ */ new Set(), o.value = [], s.value = {}, a.value = !1, g.value = /* @__PURE__ */ new Map(), h.value = "", C.value = [];
1890
- }
1891
- function k(O) {
1892
- $.value = O;
1893
- }
1894
- function N(O) {
1895
- const M = new Set(u.value);
1896
- M.add(O), u.value = M;
1897
- }
1898
- function z() {
1899
- u.value = /* @__PURE__ */ new Set();
1900
- }
1901
- function b(O) {
1902
- o.value = [...o.value, O];
1903
- }
1904
- function B(O, M) {
1905
- const j = [...o.value];
1906
- j[O] = M, o.value = j;
1907
- }
1908
- function F(O) {
1909
- o.value = o.value.filter((M, j) => j !== O);
1910
- }
1911
- function A(O, M) {
1912
- const j = [...o.value], [q] = j.splice(O, 1);
1913
- j.splice(M, 0, q), o.value = j;
1914
- }
1915
- function P() {
1916
- s.value = { ...w.value }, r.value = 3;
1917
- }
1918
- function K() {
1919
- s.value = {}, r.value = 2;
1920
- }
1921
- function H() {
1922
- return Object.values(s.value).filter(
1923
- (O) => (O.status === "will-update" || O.status === "partially-ignored") && O.projected != null
1924
- ).map((O) => O.projected);
1925
- }
1926
- async function ee() {
1927
- if (!a.value) {
1928
- a.value = !0, g.value = /* @__PURE__ */ new Map();
1929
- try {
1930
- const O = H(), M = await d.importRecipes({
1931
- create: [],
1932
- update: O
1933
- }), j = (M == null ? void 0 : M.errors) ?? [];
1934
- if (j.length > 0) {
1935
- const q = /* @__PURE__ */ new Map();
1936
- for (const { data: oe, error: Z } of j) {
1937
- const ae = typeof Z == "string" ? Z : (Z == null ? void 0 : Z.message) ?? t("inventory.recipe.bulkEditor.step3.unknownError");
1938
- q.set(oe._id, ae);
1939
- }
1940
- g.value = q, l.open({
1941
- title: t("inventory.recipe.bulkEditor.step3.partialErrorTitle"),
1942
- message: t("inventory.recipe.bulkEditor.step3.partialErrorMessage", {
1943
- count: j.length
1944
- }),
1945
- type: "warning"
1946
- });
1947
- } else
1948
- l.open({
1949
- title: t("inventory.recipe.bulkEditor.step3.successTitle"),
1950
- message: t("inventory.recipe.bulkEditor.step3.successMessage", {
1951
- count: O.length
1952
- }),
1953
- type: "success"
1954
- }), i.value = !1, c();
1955
- } catch (O) {
1956
- l.open({
1957
- title: t("inventory.recipe.bulkEditor.step3.errorTitle"),
1958
- message: t("inventory.recipe.bulkEditor.step3.errorMessage"),
1959
- type: "error"
1960
- }), console.error("confirmAndApply failed", O);
1961
- } finally {
1962
- a.value = !1;
1963
- }
1964
- }
1965
- }
1966
- return {
1967
- // state
1968
- show: i,
1969
- currentStep: r,
1970
- query: $,
1971
- excludedRecipeIds: u,
1972
- modifications: o,
1973
- entries: s,
1974
- isSaving: a,
1975
- applyErrors: g,
1976
- nameSearch: h,
1977
- filterRows: C,
1978
- // computed
1979
- matchedRecipes: I,
1980
- selectedRecipes: m,
1981
- livePreviewEntries: w,
1982
- canGoToStep2: _,
1983
- canGoToStep3: y,
1984
- // actions
1985
- openDialog: e,
1986
- closeDialog: S,
1987
- reset: c,
1988
- updateQuery: k,
1989
- removeRecipe: N,
1990
- restoreAllRecipes: z,
1991
- addModification: b,
1992
- updateModification: B,
1993
- removeModification: F,
1994
- reorderModification: A,
1995
- goToStep3: P,
1996
- backToStep2: K,
1997
- buildPayload: H,
1998
- confirmAndApply: ee
1999
- };
2000
- }), ho = { class: "flex flex-col h-full" }, xo = { class: "px-16 pt-16 pb-8 shrink-0 flex items-center justify-between" }, $o = { class: "fm-typo-en-heading-sm-700 text-fm-color-typo-primary" }, Io = { class: "px-16 pt-12 pb-16 border-b border-fm-color-border-default bg-fm-color-surface-default flex flex-col gap-12 shrink-0" }, wo = {
2001
- key: 0,
2002
- class: "flex flex-wrap items-center gap-8"
2003
- }, Eo = {
2004
- type: "button",
2005
- class: "inline-flex items-center gap-4 h-[30px] pl-8 pr-6 rounded-l-md border border-r-0 border-fm-color-border-default bg-fm-color-surface-secondary hover:bg-fm-color-surface-hover cursor-pointer select-none transition-colors"
2006
- }, Vo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-primary" }, So = { class: "flex flex-col gap-8 p-12 min-w-[260px]" }, Co = { class: "fm-typo-en-body-sm-600 text-fm-color-typo-secondary" }, Bo = {
2007
- key: 0,
2008
- class: "flex flex-col gap-4"
2009
- }, Fo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ro = { class: "text-fm-color-typo-placeholder ml-4" }, Ao = ["title", "onClick"], To = { class: "flex-1 overflow-y-auto" }, Uo = {
2010
- key: 0,
2011
- class: "flex flex-col items-center justify-center h-full gap-8 px-24 text-center"
2012
- }, Po = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Mo = {
2013
- key: 1,
2014
- class: "divide-y divide-fm-color-border-default"
2015
- }, Do = { class: "flex-1 min-w-0" }, Go = { class: "fm-typo-en-body-md-600 text-fm-color-typo-primary truncate" }, No = {
2016
- key: 0,
2017
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary mt-1 whitespace-normal break-words"
2018
- }, zo = { class: "flex items-center gap-4 mt-2" }, Oo = /* @__PURE__ */ le({
2019
- __name: "RecipeBulkEditorStep1",
2020
- setup(p) {
2021
- const { t: d } = ie(), l = ne(), t = ge(), i = R({
2022
- get: () => t.nameSearch,
2023
- set: (y) => {
2024
- t.nameSearch = y;
2025
- }
2026
- }), r = R(() => t.filterRows), $ = W({});
2027
- function u(y) {
2028
- return $.value[y] ?? !1;
2029
- }
2030
- function o(y, e) {
2031
- $.value = { ...$.value, [y]: e };
2032
- }
2033
- const s = R(
2034
- () => l.skus.map((y) => ({
2035
- label: y.name,
2036
- sublabel: y.code,
2037
- value: y._id
2038
- }))
2039
- ), a = R(
2040
- () => l.recipes.map((y) => ({
2041
- label: y.name,
2042
- value: y._id
2043
- }))
2044
- );
2045
- function g(y) {
2046
- return y.type !== "ingredient" || !y.itemId ? null : l.skuById[y.itemId] ?? null;
2047
- }
2048
- function h(y) {
2049
- var e;
2050
- if (!y.type) return d("inventory.recipe.bulkEditor.step1.filter");
2051
- if (y.type === "ingredient") {
2052
- if (!y.itemId) return d("inventory.recipe.bulkEditor.step1.filterTypeIngredient");
2053
- const S = l.skuById[y.itemId];
2054
- if (!S) return d("inventory.recipe.bulkEditor.step1.filterTypeIngredient");
2055
- const { amount: c, measurement: k } = y.amountModel;
2056
- if (!(c != null && c.amount > 0)) return S.name;
2057
- const z = (k == null ? void 0 : k.abbrev) ?? ((e = S.unit) == null ? void 0 : e.abbrev) ?? "", b = Q(c);
2058
- return `${S.name} (${b}${z})`;
2059
- }
2060
- if (y.type === "recipe") {
2061
- if (!y.itemId) return d("inventory.recipe.bulkEditor.step1.filterTypeRecipe");
2062
- const S = l.recipeById[y.itemId];
2063
- return S ? S.name : d("inventory.recipe.bulkEditor.step1.filterTypeRecipe");
2064
- }
2065
- return "";
2066
- }
2067
- function C(y) {
2068
- const e = ko(y);
2069
- t.filterRows.push(e), o(e.id, !0);
2070
- }
2071
- function I(y) {
2072
- t.filterRows = t.filterRows.filter((S) => S.id !== y);
2073
- const e = { ...$.value };
2074
- delete e[y], $.value = e;
2075
- }
2076
- function m(y) {
2077
- y.amountModel = ye(), o(y.id, !0);
2078
- }
2079
- ue(
2080
- [i, r],
2081
- () => {
2082
- const y = [];
2083
- for (const c of r.value)
2084
- if (!(!c.type || !c.itemId))
2085
- if (c.type === "ingredient") {
2086
- const k = g(c), { amount: N, measurement: z } = c.amountModel, b = N != null && N.amount > 0;
2087
- let B, F;
2088
- k && b && (B = z ? he.multiplyDecimal(N, z.conversion) : N, F = (z == null ? void 0 : z.id) ?? null), y.push({
2089
- id: c.id,
2090
- type: "ingredient",
2091
- itemId: c.itemId,
2092
- amount: B ?? null,
2093
- measurementId: F
2094
- });
2095
- } else c.type === "recipe" && y.push({
2096
- id: c.id,
2097
- type: "recipe",
2098
- itemId: c.itemId
2099
- });
2100
- t.updateQuery({
2101
- nameSearch: i.value,
2102
- filters: y
2103
- });
2104
- const e = i.value.trim().length > 0, S = y.length > 0;
2105
- !e && !S && t.restoreAllRecipes();
2106
- },
2107
- { deep: !0, immediate: !0 }
2108
- );
2109
- function _(y) {
2110
- var k, N, z, b;
2111
- if (y.isGroup) {
2112
- const B = l.skuGroupById[y.id];
2113
- if (!B) return null;
2114
- const F = `x${Q(y.amount)}`;
2115
- return y.recipeIds.slice(1).length ? `(${((k = l.recipeById[y.recipeIds.at(-1) ?? ""]) == null ? void 0 : k.name) ?? ""}) ${B.name} (${F})` : `${B.name} (${F})`;
2116
- }
2117
- const e = l.skuById[y.id];
2118
- if (!e) return null;
2119
- const S = ((N = y.measurement) == null ? void 0 : N.abbrev) ?? ((z = e.unit) == null ? void 0 : z.abbrev) ?? "", c = `${Q(y.amount)}${S}`;
2120
- return y.recipeIds.slice(1).length ? `(${((b = l.recipeById[y.recipeIds.at(-1) ?? ""]) == null ? void 0 : b.name) ?? ""}) ${e.name} (${c})` : `${e.name} (${c})`;
2121
- }
2122
- function w(y) {
2123
- return ke(y.contains, /* @__PURE__ */ new Set([y._id]), l.recipeById).map(_).filter((e) => e !== null).join(", ");
2124
- }
2125
- return (y, e) => {
2126
- const S = G("FmButton"), c = G("FmSearch"), k = G("FmSelect"), N = G("FmPopover"), z = G("FmIcon"), b = G("FmMenuItem"), B = G("FmMenu"), F = G("FmChip");
2127
- return v(), V("div", ho, [
2128
- f("div", xo, [
2129
- f("span", $o, U(n(d)("inventory.recipe.bulkEditor.step1.selectedCount", {
2130
- count: n(t).selectedRecipes.length
2131
- })), 1),
2132
- n(t).excludedRecipeIds.size > 0 ? (v(), Y(S, {
2133
- key: 0,
2134
- label: n(d)("inventory.recipe.bulkEditor.step1.restoreAll"),
2135
- variant: "tertiary",
2136
- size: "md",
2137
- onClick: e[0] || (e[0] = (A) => n(t).restoreAllRecipes())
2138
- }, null, 8, ["label"])) : T("", !0)
2139
- ]),
2140
- f("div", Io, [
2141
- x(c, {
2142
- modelValue: i.value,
2143
- "onUpdate:modelValue": e[1] || (e[1] = (A) => i.value = A),
2144
- placeholder: n(d)("inventory.recipe.bulkEditor.query.nameSearchPlaceholder")
2145
- }, null, 8, ["modelValue", "placeholder"]),
2146
- r.value.length > 0 ? (v(), V("div", wo, [
2147
- (v(!0), V(X, null, me(r.value, (A) => (v(), V("div", {
2148
- key: A.id,
2149
- class: "flex items-center"
2150
- }, [
2151
- x(N, {
2152
- "show-popover": u(A.id),
2153
- "exclude-el-from-click-outside": ["fm-menu"],
2154
- placement: "bottom-start",
2155
- onPopoverChanged: (P) => o(A.id, P)
2156
- }, {
2157
- "popover-button": J(() => [
2158
- f("button", Eo, [
2159
- f("span", Vo, U(h(A)), 1)
2160
- ])
2161
- ]),
2162
- default: J(() => [
2163
- f("div", So, [
2164
- f("p", Co, U(A.type === "ingredient" ? n(d)("inventory.recipe.bulkEditor.step1.filterTypeIngredient") : n(d)("inventory.recipe.bulkEditor.step1.filterTypeRecipe")), 1),
2165
- A.type === "ingredient" ? (v(), V(X, { key: 0 }, [
2166
- x(k, {
2167
- modelValue: A.itemId,
2168
- "onUpdate:modelValue": [(P) => A.itemId = P, (P) => m(A)],
2169
- items: s.value,
2170
- placeholder: n(d)("inventory.recipe.bulkEditor.step1.selectIngredient"),
2171
- clearable: ""
2172
- }, {
2173
- "menu-wrapper": J((P) => [
2174
- x(Fe, we({ ref_for: !0 }, P, {
2175
- items: s.value,
2176
- "model-value": A.itemId
2177
- }), null, 16, ["items", "model-value"])
2178
- ]),
2179
- _: 2
2180
- }, 1032, ["modelValue", "onUpdate:modelValue", "items", "placeholder"]),
2181
- g(A) ? (v(), V("div", Bo, [
2182
- f("span", Fo, [
2183
- mt(U(n(d)("inventory.recipe.bulkEditor.step1.amountLabel")) + " ", 1),
2184
- f("span", Ro, U(n(d)("inventory.recipe.bulkEditor.step1.amountOptional")), 1)
2185
- ]),
2186
- x(Be, {
2187
- modelValue: A.amountModel,
2188
- "onUpdate:modelValue": (P) => A.amountModel = P,
2189
- unit: g(A).unit,
2190
- placeholder: n(d)("inventory.recipe.bulkEditor.step1.amountPlaceholder"),
2191
- "convert-amount-on-change-unit": ""
2192
- }, null, 8, ["modelValue", "onUpdate:modelValue", "unit", "placeholder"])
2193
- ])) : T("", !0)
2194
- ], 64)) : A.type === "recipe" ? (v(), Y(k, {
2195
- key: 1,
2196
- modelValue: A.itemId,
2197
- "onUpdate:modelValue": [(P) => A.itemId = P, (P) => m(A)],
2198
- items: a.value,
2199
- placeholder: n(d)("inventory.recipe.bulkEditor.step1.selectRecipe"),
2200
- clearable: ""
2201
- }, {
2202
- "menu-wrapper": J((P) => [
2203
- x(Fe, we({ ref_for: !0 }, P, {
2204
- items: a.value,
2205
- "model-value": A.itemId
2206
- }), null, 16, ["items", "model-value"])
2207
- ]),
2208
- _: 2
2209
- }, 1032, ["modelValue", "onUpdate:modelValue", "items", "placeholder"])) : T("", !0)
2210
- ])
2211
- ]),
2212
- _: 2
2213
- }, 1032, ["show-popover", "onPopoverChanged"]),
2214
- f("button", {
2215
- type: "button",
2216
- class: "inline-flex items-center justify-center h-[30px] w-[26px] rounded-r-md border border-l-0 border-fm-color-border-default bg-fm-color-surface-secondary hover:bg-fm-color-surface-hover text-fm-color-typo-secondary hover:text-fm-color-typo-primary cursor-pointer transition-colors",
2217
- title: n(d)("inventory.recipe.bulkEditor.step1.removeFilter"),
2218
- onClick: (P) => I(A.id)
2219
- }, [
2220
- x(z, {
2221
- name: "close",
2222
- size: "sm"
2223
- })
2224
- ], 8, Ao)
2225
- ]))), 128))
2226
- ])) : T("", !0),
2227
- x(B, {
2228
- "close-on-click": !0,
2229
- placement: "bottom-start"
2230
- }, {
2231
- "menu-button": J(() => [
2232
- x(S, {
2233
- label: n(d)("inventory.recipe.bulkEditor.step1.filter"),
2234
- variant: "secondary",
2235
- size: "md",
2236
- "prepend-icon": "add",
2237
- class: "self-start"
2238
- }, null, 8, ["label"])
2239
- ]),
2240
- default: J(() => [
2241
- x(b, {
2242
- label: n(d)("inventory.recipe.bulkEditor.step1.filterTypeIngredient"),
2243
- icon: "inventory_2",
2244
- onClick: e[2] || (e[2] = (A) => C("ingredient"))
2245
- }, null, 8, ["label"]),
2246
- x(b, {
2247
- label: n(d)("inventory.recipe.bulkEditor.step1.filterTypeRecipe"),
2248
- icon: "restaurant_menu",
2249
- onClick: e[3] || (e[3] = (A) => C("recipe"))
2250
- }, null, 8, ["label"])
2251
- ]),
2252
- _: 1
2253
- })
2254
- ]),
2255
- f("div", To, [
2256
- n(t).selectedRecipes.length === 0 ? (v(), V("div", Uo, [
2257
- x(z, {
2258
- name: "search_off",
2259
- size: "lg",
2260
- class: "text-fm-color-typo-placeholder"
2261
- }),
2262
- f("p", Po, U(n(d)("inventory.recipe.bulkEditor.query.noResults")), 1)
2263
- ])) : (v(), V("div", Mo, [
2264
- (v(!0), V(X, null, me(n(t).selectedRecipes, (A) => (v(), V("div", {
2265
- key: A._id,
2266
- class: "flex items-center gap-12 px-16 py-12 hover:bg-fm-color-surface-hover transition-colors"
2267
- }, [
2268
- f("div", Do, [
2269
- f("div", Go, U(A.name), 1),
2270
- A.contains.length > 0 ? (v(), V("div", No, U(w(A)), 1)) : T("", !0),
2271
- f("div", zo, [
2272
- A.version === "v2" ? (v(), Y(F, {
2273
- key: 0,
2274
- size: "sm",
2275
- label: "V2",
2276
- variant: "info"
2277
- })) : T("", !0)
2278
- ])
2279
- ]),
2280
- x(S, {
2281
- variant: "tertiary",
2282
- icon: "do_not_disturb_on",
2283
- title: n(d)("inventory.recipe.bulkEditor.step1.removeRecipeTooltip"),
2284
- onClick: (P) => n(t).removeRecipe(A._id)
2285
- }, null, 8, ["title", "onClick"])
2286
- ]))), 128))
2287
- ]))
2288
- ])
2289
- ]);
2290
- };
2291
- }
2292
- }), jo = { class: "flex flex-col gap-0 rounded-lg border border-fm-color-border-default bg-fm-color-surface-default overflow-hidden" }, Lo = { class: "flex items-start gap-12 px-16 py-12" }, Ko = { class: "flex-1" }, qo = { class: "flex-1" }, Wo = {
2293
- key: 0,
2294
- class: "border-t border-fm-color-border-default px-16 py-10 flex items-center gap-10"
2295
- }, Yo = {
2296
- key: 1,
2297
- class: "border-t border-fm-color-border-default px-16 py-10 flex items-start gap-8 bg-fm-color-surface-warning"
2298
- }, Jo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-warning" }, Ho = {
2299
- key: 2,
2300
- class: "border-t border-fm-color-border-default px-16 py-12 flex flex-col gap-12"
2301
- }, Qo = { class: "fm-typo-en-body-sm-600 text-fm-color-typo-secondary -mb-4" }, Xo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Zo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, ei = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-warning" }, ti = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary -mt-8" }, ni = { class: "fm-typo-en-body-sm-600 text-fm-color-typo-secondary -mb-4" }, oi = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, ii = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, li = /* @__PURE__ */ le({
2302
- __name: "ModificationCard",
2303
- props: {
2304
- modelValue: {},
2305
- livePreviewEntries: {}
2306
- },
2307
- emits: ["update:modelValue"],
2308
- setup(p, { emit: d }) {
2309
- const l = p, t = d, { t: i } = ie(), r = ne(), $ = We();
2310
- function u(E) {
2311
- const D = E.type === "replace-binding" ? E.from.type : E.type === "remove-binding" || E.type === "update-binding-rule" || E.type === "update-alternatives" ? E.target.type : E.type === "add-binding" ? E.binding.type : null;
2312
- return D ? D === "RECIPE" ? "recipe" : "ingredient" : null;
2313
- }
2314
- function o(E) {
2315
- return E.type === "update-alternatives" ? !0 : E.type === "add-binding" ? (E.binding.alternatives ?? []).length > 0 : E.type === "replace-binding" ? (E.to.alternatives ?? []).length > 0 : !1;
2316
- }
2317
- function s(E) {
2318
- switch (E.type) {
2319
- case "add-binding":
2320
- return "link";
2321
- case "replace-binding":
2322
- return E.from.id === E.to.id ? "update" : null;
2323
- case "remove-binding":
2324
- return "remove";
2325
- case "update-binding-rule":
2326
- return null;
2327
- case "update-alternatives":
2328
- return "alts";
2329
- }
2330
- }
2331
- function a(E) {
2332
- return E.type === "replace-binding" ? E.from.id || null : (E.type === "remove-binding" || E.type === "update-binding-rule" || E.type === "update-alternatives") && E.target.id || null;
2333
- }
2334
- function g(E) {
2335
- return E.type === "add-binding" && E.binding.id || null;
2336
- }
2337
- function h(E) {
2338
- const D = E.type === "replace-binding" ? E.to : E.type === "add-binding" ? E.binding : null;
2339
- return D ? { amount: D.amount, measurement: D.measurement ?? null } : ye();
2340
- }
2341
- function C(E) {
2342
- return E.type === "replace-binding" ? E.to.rules ?? null : E.type === "add-binding" ? E.binding.rules ?? null : null;
2343
- }
2344
- function I(E) {
2345
- return E.type === "update-alternatives" ? E.alternatives ?? [] : E.type === "add-binding" ? E.binding.alternatives ?? [] : [];
2346
- }
2347
- const m = W(u(l.modelValue)), _ = W(s(l.modelValue)), w = W(o(l.modelValue)), y = W(a(l.modelValue)), e = W(g(l.modelValue)), S = W(h(l.modelValue)), c = W(C(l.modelValue)), k = W(I(l.modelValue)), N = W(
2348
- (() => {
2349
- const E = h(l.modelValue);
2350
- return E.amount ? Q(E.amount) : "";
2351
- })()
2352
- );
2353
- let z = null;
2354
- function b(E) {
2355
- N.value = E, z && clearTimeout(z), z = setTimeout(() => {
2356
- const D = +E;
2357
- S.value = {
2358
- amount: E.length > 0 && isFinite(D) ? Ke(D) : { amount: 0, precision: 0 },
2359
- measurement: null
2360
- };
2361
- }, 300);
2362
- }
2363
- ue(m, () => {
2364
- _.value = null, w.value = !1, y.value = null, e.value = null, S.value = ye(), c.value = null, k.value = [], N.value = "";
2365
- }), ue(_, () => {
2366
- y.value = null, e.value = null, S.value = ye(), c.value = null, k.value = [], N.value = "";
2367
- }), ue(w, (E) => {
2368
- E || (k.value = [], _.value === "alts" && (_.value = null));
2369
- });
2370
- const B = R(() => [
2371
- { label: i("inventory.recipe.bulkEditor.step2.fieldIngredient"), value: "ingredient" },
2372
- { label: i("inventory.recipe.bulkEditor.step2.fieldRecipe"), value: "recipe" }
2373
- ]), F = R(() => {
2374
- const E = [
2375
- { label: i("inventory.recipe.bulkEditor.step2.actionLink"), value: "link" },
2376
- { label: i("inventory.recipe.bulkEditor.step2.actionUpdate"), value: "update" },
2377
- { label: i("inventory.recipe.bulkEditor.step2.actionRemove"), value: "remove" }
2378
- ];
2379
- return m.value === "ingredient" && w.value && $.enableRecipeV2 && E.push({ label: i("inventory.recipe.bulkEditor.step2.actionAlts"), value: "alts" }), E;
2380
- }), A = R(() => m.value !== null && _.value !== null), P = R(
2381
- () => _.value === "update" || _.value === "remove" || _.value === "alts"
2382
- ), K = R(
2383
- () => _.value === "link"
2384
- ), H = R(
2385
- () => _.value === "update" && y.value !== null
2386
- ), ee = R(
2387
- () => m.value === "ingredient" && w.value && $.enableRecipeV2
2388
- ), O = R(
2389
- () => r.skus.map((E) => ({ label: E.name, sublabel: E.code, value: E._id }))
2390
- ), M = R(
2391
- () => r.recipes.map((E) => ({ label: E.name, value: E._id }))
2392
- ), j = R(() => m.value === "recipe" ? M.value : O.value), q = R(() => m.value === "recipe" ? M.value : O.value), oe = R(() => m.value !== "ingredient" || !e.value ? null : r.skuById[e.value] ?? null), Z = R(() => m.value !== "ingredient" || !y.value ? null : r.skuById[y.value] ?? null), ae = R(() => {
2393
- const E = y.value ?? e.value;
2394
- return E ? [E] : [];
2395
- }), fe = R(() => ee.value ? Object.values(l.livePreviewEntries).filter(
2396
- (E) => E.original.version !== "v2"
2397
- ).length : 0), xe = R(() => Object.values(l.livePreviewEntries).length);
2398
- ue(
2399
- () => [_.value, y.value],
2400
- ([E, D], [te, pe]) => {
2401
- if (E !== "alts" || D === pe) return;
2402
- if (!D) {
2403
- k.value = [];
2404
- return;
2405
- }
2406
- const $e = Object.values(l.livePreviewEntries).find(
2407
- (L) => L.original.version === "v2" && L.original.contains.some((Ie) => Ie.type === "SKU" && Ie.id === D)
2408
- );
2409
- if ($e) {
2410
- const L = $e.original.contains.find((Ie) => Ie.type === "SKU" && Ie.id === D);
2411
- k.value = L != null && L.alternatives ? [...L.alternatives] : [];
2412
- } else
2413
- k.value = [];
2414
- }
2415
- );
2416
- const re = R(() => _.value !== "alts" || !y.value ? 0 : Object.values(l.livePreviewEntries).filter(
2417
- (E) => E.original.version === "v2" && E.original.contains.some((D) => D.type === "SKU" && D.id === y.value)
2418
- ).length);
2419
- function ve() {
2420
- return m.value === "recipe" ? "RECIPE" : "SKU";
2421
- }
2422
- function ce() {
2423
- const E = ve(), D = ye().amount, te = {
2424
- type: E,
2425
- id: "",
2426
- amount: D,
2427
- measurement: null,
2428
- rules: null,
2429
- alternatives: []
2430
- };
2431
- switch (_.value) {
2432
- case "update":
2433
- return { type: "replace-binding", from: { type: E, id: "" }, to: te };
2434
- case "remove":
2435
- return { type: "remove-binding", target: { type: E, id: "" } };
2436
- case "alts":
2437
- return { type: "update-alternatives", target: { type: E, id: "" }, alternatives: [] };
2438
- case "link":
2439
- default:
2440
- return { type: "add-binding", binding: te };
2441
- }
2442
- }
2443
- function Ue() {
2444
- return y.value ? { type: ve(), id: y.value } : null;
2445
- }
2446
- function Ye(E = !1) {
2447
- const D = E ? y.value : e.value;
2448
- if (!D) return null;
2449
- const { amount: te, measurement: pe } = S.value, Ee = pe ? he.multiplyDecimal(te, pe.conversion) : te;
2450
- return {
2451
- type: ve(),
2452
- id: D,
2453
- amount: Ee,
2454
- measurement: pe ?? null,
2455
- rules: m.value === "recipe" ? c.value ?? null : null,
2456
- alternatives: ee.value ? k.value : []
2457
- };
2458
- }
2459
- function ct() {
2460
- if (!m.value) return;
2461
- if (!_.value) {
2462
- t("update:modelValue", ce());
2463
- return;
2464
- }
2465
- const E = Ue(), D = Ye(!1);
2466
- let te = null;
2467
- switch (_.value) {
2468
- case "link":
2469
- D && (te = { type: "add-binding", binding: D });
2470
- break;
2471
- case "update": {
2472
- const pe = Ye(!0);
2473
- E && pe && (te = { type: "replace-binding", from: E, to: pe });
2474
- break;
2475
- }
2476
- case "remove":
2477
- E && (te = { type: "remove-binding", target: E });
2478
- break;
2479
- case "alts":
2480
- E && (te = { type: "update-alternatives", target: E, alternatives: k.value });
2481
- break;
2482
- }
2483
- t("update:modelValue", te ?? ce());
2484
- }
2485
- return ue(
2486
- [m, _, w, y, e, S, c, k],
2487
- () => ct(),
2488
- { deep: !0 }
2489
- ), (E, D) => {
2490
- const te = G("FmSelect"), pe = G("FmSwitch"), Ee = G("FmIcon"), $e = G("FmTextField");
2491
- return v(), V("div", jo, [
2492
- f("div", Lo, [
2493
- f("div", Ko, [
2494
- x(te, {
2495
- modelValue: m.value,
2496
- "onUpdate:modelValue": D[0] || (D[0] = (L) => m.value = L),
2497
- items: B.value,
2498
- label: n(i)("inventory.recipe.bulkEditor.step2.sectionField"),
2499
- placeholder: n(i)("inventory.recipe.bulkEditor.step2.sectionField")
2500
- }, null, 8, ["modelValue", "items", "label", "placeholder"])
2501
- ]),
2502
- f("div", qo, [
2503
- x(te, {
2504
- modelValue: _.value,
2505
- "onUpdate:modelValue": D[1] || (D[1] = (L) => _.value = L),
2506
- items: F.value,
2507
- label: n(i)("inventory.recipe.bulkEditor.step2.sectionAction"),
2508
- placeholder: n(i)("inventory.recipe.bulkEditor.step2.sectionAction")
2509
- }, null, 8, ["modelValue", "items", "label", "placeholder"])
2510
- ])
2511
- ]),
2512
- m.value === "ingredient" && n($).enableRecipeV2 ? (v(), V("div", Wo, [
2513
- x(pe, {
2514
- modelValue: w.value,
2515
- "onUpdate:modelValue": D[2] || (D[2] = (L) => w.value = L),
2516
- label: n(i)("inventory.recipe.bulkEditor.step2.includeAlternativesToggle")
2517
- }, null, 8, ["modelValue", "label"])
2518
- ])) : T("", !0),
2519
- ee.value && fe.value > 0 ? (v(), V("div", Yo, [
2520
- x(Ee, {
2521
- name: "warning",
2522
- size: "sm",
2523
- class: "text-fm-color-typo-warning mt-1 shrink-0"
2524
- }),
2525
- f("p", Jo, U(n(i)("inventory.recipe.bulkEditor.step2.v1AlternativesWarning", {
2526
- v1Count: fe.value,
2527
- total: xe.value
2528
- })), 1)
2529
- ])) : T("", !0),
2530
- A.value ? (v(), V("div", Ho, [
2531
- P.value ? (v(), V(X, { key: 0 }, [
2532
- f("p", Qo, U(n(i)("inventory.recipe.bulkEditor.addModification.targetLabel")), 1),
2533
- x(te, {
2534
- modelValue: y.value,
2535
- "onUpdate:modelValue": D[3] || (D[3] = (L) => y.value = L),
2536
- items: j.value,
2537
- placeholder: m.value === "recipe" ? n(i)("inventory.recipe.bulkEditor.addModification.recipePlaceholder") : n(i)("inventory.recipe.bulkEditor.addModification.skuPlaceholder"),
2538
- clearable: ""
2539
- }, {
2540
- "menu-wrapper": J((L) => [
2541
- x(Fe, we(L, {
2542
- items: j.value,
2543
- "model-value": y.value
2544
- }), null, 16, ["items", "model-value"])
2545
- ]),
2546
- _: 1
2547
- }, 8, ["modelValue", "items", "placeholder"]),
2548
- H.value ? (v(), V(X, { key: 0 }, [
2549
- m.value === "ingredient" && Z.value ? (v(), Y(Be, {
2550
- key: 0,
2551
- modelValue: S.value,
2552
- "onUpdate:modelValue": D[4] || (D[4] = (L) => S.value = L),
2553
- unit: Z.value.unit,
2554
- placeholder: n(i)("inventory.recipe.bulkEditor.query.amountPlaceholder"),
2555
- "convert-amount-on-change-unit": ""
2556
- }, null, 8, ["modelValue", "unit", "placeholder"])) : m.value === "recipe" ? (v(), Y($e, {
2557
- key: 1,
2558
- "model-value": N.value,
2559
- label: n(i)("inventory.recipe.bulkEditor.addModification.amountLabel"),
2560
- type: "number",
2561
- "onUpdate:modelValue": D[5] || (D[5] = (L) => b(L))
2562
- }, null, 8, ["model-value", "label"])) : T("", !0),
2563
- m.value === "recipe" ? (v(), V(X, { key: 2 }, [
2564
- f("p", Xo, U(n(i)("inventory.recipe.bulkEditor.addModification.optionalRuleLabel")), 1),
2565
- x(Re, {
2566
- modelValue: c.value,
2567
- "onUpdate:modelValue": D[6] || (D[6] = (L) => c.value = L)
2568
- }, null, 8, ["modelValue"])
2569
- ], 64)) : T("", !0),
2570
- ee.value ? (v(), V(X, { key: 3 }, [
2571
- f("p", Zo, U(n(i)("inventory.recipe.bulkEditor.addModification.optionalAlternativesLabel")), 1),
2572
- x(Se, {
2573
- modelValue: k.value,
2574
- "onUpdate:modelValue": D[7] || (D[7] = (L) => k.value = L),
2575
- "filter-ingredient-ids": ae.value
2576
- }, null, 8, ["modelValue", "filter-ingredient-ids"])
2577
- ], 64)) : T("", !0)
2578
- ], 64)) : T("", !0),
2579
- _.value === "alts" && y.value ? (v(), V(X, { key: 1 }, [
2580
- f("p", ei, U(re.value > 0 ? n(i)("inventory.recipe.bulkEditor.addModification.altsOverwriteWarning", { count: re.value }) : n(i)("inventory.recipe.bulkEditor.addModification.altsNotFoundWarning")), 1),
2581
- f("p", ti, U(n(i)("inventory.recipe.bulkEditor.addModification.altsClearNote")), 1),
2582
- x(Se, {
2583
- modelValue: k.value,
2584
- "onUpdate:modelValue": D[8] || (D[8] = (L) => k.value = L),
2585
- "filter-ingredient-ids": ae.value
2586
- }, null, 8, ["modelValue", "filter-ingredient-ids"])
2587
- ], 64)) : T("", !0)
2588
- ], 64)) : T("", !0),
2589
- K.value ? (v(), V(X, { key: 1 }, [
2590
- f("p", ni, U(n(i)("inventory.recipe.bulkEditor.addModification.bindingLabel")), 1),
2591
- x(te, {
2592
- modelValue: e.value,
2593
- "onUpdate:modelValue": D[9] || (D[9] = (L) => e.value = L),
2594
- items: q.value,
2595
- placeholder: m.value === "recipe" ? n(i)("inventory.recipe.bulkEditor.addModification.recipePlaceholder") : n(i)("inventory.recipe.bulkEditor.addModification.skuPlaceholder"),
2596
- clearable: ""
2597
- }, {
2598
- "menu-wrapper": J((L) => [
2599
- x(Fe, we(L, {
2600
- items: q.value,
2601
- "model-value": e.value
2602
- }), null, 16, ["items", "model-value"])
2603
- ]),
2604
- _: 1
2605
- }, 8, ["modelValue", "items", "placeholder"]),
2606
- e.value ? (v(), V(X, { key: 0 }, [
2607
- m.value === "ingredient" && oe.value ? (v(), Y(Be, {
2608
- key: 0,
2609
- modelValue: S.value,
2610
- "onUpdate:modelValue": D[10] || (D[10] = (L) => S.value = L),
2611
- unit: oe.value.unit,
2612
- placeholder: n(i)("inventory.recipe.bulkEditor.query.amountPlaceholder"),
2613
- "convert-amount-on-change-unit": ""
2614
- }, null, 8, ["modelValue", "unit", "placeholder"])) : m.value === "recipe" ? (v(), Y($e, {
2615
- key: 1,
2616
- "model-value": N.value,
2617
- label: n(i)("inventory.recipe.bulkEditor.addModification.amountLabel"),
2618
- type: "number",
2619
- "onUpdate:modelValue": D[11] || (D[11] = (L) => b(L))
2620
- }, null, 8, ["model-value", "label"])) : T("", !0),
2621
- m.value === "recipe" ? (v(), V(X, { key: 2 }, [
2622
- f("p", oi, U(n(i)("inventory.recipe.bulkEditor.addModification.optionalRuleLabel")), 1),
2623
- x(Re, {
2624
- modelValue: c.value,
2625
- "onUpdate:modelValue": D[12] || (D[12] = (L) => c.value = L)
2626
- }, null, 8, ["modelValue"])
2627
- ], 64)) : T("", !0),
2628
- ee.value ? (v(), V(X, { key: 3 }, [
2629
- f("p", ii, U(n(i)("inventory.recipe.bulkEditor.addModification.optionalAlternativesLabel")), 1),
2630
- x(Se, {
2631
- modelValue: k.value,
2632
- "onUpdate:modelValue": D[13] || (D[13] = (L) => k.value = L),
2633
- "filter-ingredient-ids": ae.value
2634
- }, null, 8, ["modelValue", "filter-ingredient-ids"])
2635
- ], 64)) : T("", !0)
2636
- ], 64)) : T("", !0)
2637
- ], 64)) : T("", !0)
2638
- ])) : T("", !0)
2639
- ]);
2640
- };
2641
- }
2642
- }), ri = { class: "flex flex-col gap-8" }, ai = { class: "flex flex-wrap items-center gap-12 px-4" }, si = {
2643
- key: 0,
2644
- class: "flex items-center gap-6"
2645
- }, di = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, ui = {
2646
- key: 1,
2647
- class: "flex items-center gap-6"
2648
- }, ci = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, pi = {
2649
- key: 2,
2650
- class: "flex items-center gap-6"
2651
- }, mi = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, fi = { class: "rounded-lg border border-fm-color-border-default overflow-hidden" }, vi = {
2652
- key: 0,
2653
- class: "px-16 py-12 text-center fm-typo-en-body-sm-400 text-fm-color-typo-placeholder"
2654
- }, yi = {
2655
- key: 1,
2656
- class: "divide-y divide-fm-color-border-default"
2657
- }, bi = { class: "flex items-center gap-12" }, gi = { class: "flex-1 fm-typo-en-body-sm-600 text-fm-color-typo-primary truncate" }, _i = {
2658
- key: 0,
2659
- class: "flex flex-col gap-4 pl-8"
2660
- }, ki = { class: "flex-1 fm-typo-en-body-xs-400 text-fm-color-typo-secondary font-mono truncate" }, hi = /* @__PURE__ */ le({
2661
- __name: "LivePreviewTable",
2662
- setup(p) {
2663
- const { t: d } = ie(), l = ge(), t = ne(), i = {
2664
- "will-update": 0,
2665
- "partially-ignored": 1,
2666
- "already-satisfied": 2,
2667
- blocked: 3,
2668
- "no-applicable-changes": 4
2669
- }, r = R(
2670
- () => Object.values(l.livePreviewEntries).sort(
2671
- (e, S) => i[e.status] - i[S.status]
2672
- )
2673
- ), $ = R(
2674
- () => r.value.filter((e) => e.status === "will-update").length
2675
- ), u = R(
2676
- () => r.value.filter((e) => e.status === "partially-ignored").length
2677
- ), o = R(
2678
- () => r.value.filter((e) => e.status === "already-satisfied").length
2679
- ), s = R(
2680
- () => r.value.filter((e) => e.status === "blocked").length
2681
- );
2682
- function a(e) {
2683
- switch (e) {
2684
- case "will-update":
2685
- return d("inventory.recipe.bulkEditor.status.willUpdate");
2686
- case "already-satisfied":
2687
- return d("inventory.recipe.bulkEditor.status.alreadySatisfied");
2688
- case "partially-ignored":
2689
- return d("inventory.recipe.bulkEditor.status.partiallyIgnored");
2690
- case "blocked":
2691
- return d("inventory.recipe.bulkEditor.status.blocked");
2692
- case "no-applicable-changes":
2693
- return d("inventory.recipe.bulkEditor.status.noApplicableChanges");
2694
- default:
2695
- return "";
2696
- }
2697
- }
2698
- function g(e) {
2699
- switch (e) {
2700
- case "will-update":
2701
- return "success";
2702
- case "already-satisfied":
2703
- return "info";
2704
- case "partially-ignored":
2705
- return "warning";
2706
- case "blocked":
2707
- return "critical";
2708
- case "no-applicable-changes":
2709
- return "neutral";
2710
- default:
2711
- return "neutral";
2712
- }
2713
- }
2714
- function h(e, S) {
2715
- var c, k, N;
2716
- return e === "SKU" ? ((c = t.skuById[S]) == null ? void 0 : c.name) ?? S : e === "SKU_GROUP" ? ((k = t.skuGroupById[S]) == null ? void 0 : k.name) ?? S : e === "RECIPE" ? ((N = t.recipeById[S]) == null ? void 0 : N.name) ?? S : S;
2717
- }
2718
- function C(e) {
2719
- var c, k;
2720
- const S = h(e.type, e.id);
2721
- if (e.type === "SKU") {
2722
- const N = t.skuById[e.id], z = ((c = e.measurement) == null ? void 0 : c.abbrev) ?? ((k = N == null ? void 0 : N.unit) == null ? void 0 : k.abbrev) ?? "";
2723
- return `${S} (${Q(e.amount)} ${z})`.trim();
2724
- }
2725
- return e.type === "RECIPE" ? `${S} ×${Q(e.amount)}` : S;
2726
- }
2727
- function I(e) {
2728
- return h(e.type, e.id);
2729
- }
2730
- function m(e, S) {
2731
- const c = S.contains.find((k) => k.type === e.type && k.id === e.id);
2732
- return c ? C(c) : I(e);
2733
- }
2734
- function _(e, S) {
2735
- switch (e.type) {
2736
- case "add-binding":
2737
- return `+ ${C(e.binding)}`;
2738
- case "remove-binding":
2739
- return `− ${I(e.target)}`;
2740
- case "replace-binding":
2741
- return `${m(e.from, S)} → ${C(e.to)}`;
2742
- case "update-binding-rule":
2743
- return `Rule: ${I(e.target)}`;
2744
- case "update-alternatives":
2745
- return `Alternatives: ${I(e.target)}`;
2746
- }
2747
- }
2748
- function w(e) {
2749
- switch (e) {
2750
- case "applied":
2751
- return "success";
2752
- case "already-satisfied":
2753
- return "info";
2754
- case "ignored":
2755
- return "neutral";
2756
- case "blocked":
2757
- return "critical";
2758
- default:
2759
- return "neutral";
2760
- }
2761
- }
2762
- function y(e) {
2763
- switch (e) {
2764
- case "applied":
2765
- return d("inventory.recipe.bulkEditor.livePreview.outcomeApplied");
2766
- case "already-satisfied":
2767
- return d("inventory.recipe.bulkEditor.livePreview.outcomeAlreadySatisfied");
2768
- case "ignored":
2769
- return d("inventory.recipe.bulkEditor.livePreview.outcomeIgnored");
2770
- case "blocked":
2771
- return d("inventory.recipe.bulkEditor.livePreview.outcomeBlocked");
2772
- default:
2773
- return e;
2774
- }
2775
- }
2776
- return (e, S) => {
2777
- const c = G("FmChip");
2778
- return v(), V("div", ri, [
2779
- f("div", ai, [
2780
- $.value + u.value > 0 ? (v(), V("div", si, [
2781
- x(c, {
2782
- size: "sm",
2783
- label: String($.value + u.value),
2784
- variant: "success"
2785
- }, null, 8, ["label"]),
2786
- f("span", di, U(n(d)("inventory.recipe.bulkEditor.livePreview.willUpdate")), 1)
2787
- ])) : T("", !0),
2788
- o.value > 0 ? (v(), V("div", ui, [
2789
- x(c, {
2790
- size: "sm",
2791
- label: String(o.value),
2792
- variant: "info"
2793
- }, null, 8, ["label"]),
2794
- f("span", ci, U(n(d)("inventory.recipe.bulkEditor.livePreview.alreadySatisfied")), 1)
2795
- ])) : T("", !0),
2796
- s.value > 0 ? (v(), V("div", pi, [
2797
- x(c, {
2798
- size: "sm",
2799
- label: String(s.value),
2800
- variant: "critical"
2801
- }, null, 8, ["label"]),
2802
- f("span", mi, U(n(d)("inventory.recipe.bulkEditor.livePreview.blocked")), 1)
2803
- ])) : T("", !0)
2804
- ]),
2805
- f("div", fi, [
2806
- r.value.length === 0 ? (v(), V("div", vi, U(n(d)("inventory.recipe.bulkEditor.livePreview.noRecipes")), 1)) : (v(), V("div", yi, [
2807
- (v(!0), V(X, null, me(r.value, (k) => (v(), V("div", {
2808
- key: k.recipeId,
2809
- class: "flex flex-col gap-6 px-16 py-10"
2810
- }, [
2811
- f("div", bi, [
2812
- f("span", gi, U(k.recipeName), 1),
2813
- x(c, {
2814
- size: "sm",
2815
- label: a(k.status),
2816
- variant: g(k.status)
2817
- }, null, 8, ["label", "variant"])
2818
- ]),
2819
- k.changes.length > 0 ? (v(), V("div", _i, [
2820
- (v(!0), V(X, null, me(k.changes, (N, z) => (v(), V("div", {
2821
- key: z,
2822
- class: "flex items-center gap-8"
2823
- }, [
2824
- f("span", ki, U(_(N.change, k.original)), 1),
2825
- x(c, {
2826
- size: "sm",
2827
- label: y(N.outcome),
2828
- variant: w(N.outcome)
2829
- }, null, 8, ["label", "variant"])
2830
- ]))), 128))
2831
- ])) : T("", !0)
2832
- ]))), 128))
2833
- ]))
2834
- ])
2835
- ]);
2836
- };
2837
- }
2838
- }), xi = { class: "flex flex-col h-full overflow-hidden" }, $i = { class: "flex flex-col min-h-0 shrink-0" }, Ii = { class: "flex items-center gap-8 px-16 pt-12 border-b border-fm-color-border-default" }, wi = { class: "flex-1 overflow-x-auto min-w-0" }, Ei = {
2839
- class: "px-16 py-14 overflow-y-auto",
2840
- style: { "max-height": "45vh" }
2841
- }, Vi = {
2842
- key: 0,
2843
- class: "flex flex-col items-center justify-center py-40 gap-8 text-center rounded-lg border border-dashed border-fm-color-border-default"
2844
- }, Si = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ci = { class: "flex-1 overflow-y-auto px-16 py-14 flex flex-col gap-12 min-h-0" }, Bi = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary shrink-0" }, Fi = /* @__PURE__ */ le({
2845
- __name: "RecipeBulkEditorStep2",
2846
- setup(p) {
2847
- const { t: d } = ie(), l = ge(), t = W(null);
2848
- ue(
2849
- () => l.modifications.length,
2850
- (o) => {
2851
- o === 0 ? t.value = null : (t.value === null || t.value >= o) && (t.value = o - 1);
2852
- },
2853
- { immediate: !0 }
2854
- );
2855
- function i(o, s) {
2856
- const a = o.type === "replace-binding" ? o.from.type : o.type === "remove-binding" || o.type === "update-binding-rule" || o.type === "update-alternatives" ? o.target.type : o.type === "add-binding" ? o.binding.type : null;
2857
- return a === "RECIPE" ? d("inventory.recipe.bulkEditor.step2.fieldRecipe") : a === "SKU" || a === "SKU_GROUP" ? d("inventory.recipe.bulkEditor.step2.fieldIngredient") : d("inventory.recipe.bulkEditor.step2.tabLabel", { n: s + 1 });
2858
- }
2859
- const r = R(
2860
- () => l.modifications.map((o, s) => ({
2861
- label: i(o, s),
2862
- value: s
2863
- }))
2864
- );
2865
- function $() {
2866
- const s = {
2867
- type: "add-binding",
2868
- binding: {
2869
- type: "SKU",
2870
- id: "",
2871
- amount: ye().amount,
2872
- measurement: null,
2873
- rules: null,
2874
- alternatives: []
2875
- }
2876
- };
2877
- l.addModification(s), t.value = l.modifications.length - 1;
2878
- }
2879
- function u(o) {
2880
- l.removeModification(o);
2881
- }
2882
- return (o, s) => {
2883
- const a = G("FmButton"), g = G("FmTab"), h = G("FmTabs"), C = G("FmIcon");
2884
- return v(), V("div", xi, [
2885
- f("div", $i, [
2886
- f("div", Ii, [
2887
- f("div", wi, [
2888
- r.value.length > 0 ? (v(), Y(h, {
2889
- key: 0,
2890
- "model-value": t.value,
2891
- items: r.value,
2892
- "onUpdate:modelValue": s[1] || (s[1] = (I) => t.value = I)
2893
- }, {
2894
- default: J((I) => [
2895
- x(g, we(I, {
2896
- "model-value": t.value,
2897
- "onUpdate:modelValue": s[0] || (s[0] = (m) => t.value = m)
2898
- }), {
2899
- append: J(() => [
2900
- x(a, {
2901
- variant: "tertiary",
2902
- icon: "close",
2903
- size: "md",
2904
- onClick: ft((m) => u(I.value), ["stop"])
2905
- }, null, 8, ["onClick"])
2906
- ]),
2907
- _: 2
2908
- }, 1040, ["model-value"])
2909
- ]),
2910
- _: 1
2911
- }, 8, ["model-value", "items"])) : T("", !0)
2912
- ]),
2913
- x(a, {
2914
- label: n(d)("inventory.recipe.bulkEditor.step2.addModification"),
2915
- variant: "secondary",
2916
- size: "md",
2917
- "prepend-icon": "add",
2918
- class: "shrink-0",
2919
- onClick: $
2920
- }, null, 8, ["label"])
2921
- ]),
2922
- f("div", Ei, [
2923
- n(l).modifications.length === 0 ? (v(), V("div", Vi, [
2924
- x(C, {
2925
- name: "edit_note",
2926
- size: "lg",
2927
- class: "text-fm-color-typo-placeholder"
2928
- }),
2929
- f("p", Si, U(n(d)("inventory.recipe.bulkEditor.step2.emptyState")), 1)
2930
- ])) : t.value !== null && n(l).modifications[t.value] ? (v(), Y(li, {
2931
- key: t.value,
2932
- "model-value": n(l).modifications[t.value],
2933
- "live-preview-entries": n(l).livePreviewEntries,
2934
- "onUpdate:modelValue": s[2] || (s[2] = (I) => n(l).updateModification(t.value, I))
2935
- }, null, 8, ["model-value", "live-preview-entries"])) : T("", !0)
2936
- ])
2937
- ]),
2938
- s[3] || (s[3] = f("div", { class: "border-t border-fm-color-border-default shrink-0" }, null, -1)),
2939
- f("div", Ci, [
2940
- f("span", Bi, U(n(d)("inventory.recipe.bulkEditor.step2.livePreviewTitle")), 1),
2941
- x(hi)
2942
- ])
2943
- ]);
2944
- };
2945
- }
2946
- });
2947
- function Ri(p) {
2948
- return !p || Object.keys(p).length === 0 ? "" : Object.entries(p).map(([d, l]) => `${d}: ${l}`).join(", ");
2949
- }
2950
- function Ai() {
2951
- const p = ne(), d = ge(), l = p.skuById, t = p.recipeById, i = p.skuGroupById, $ = Object.values(d.entries).filter(
2952
- (s) => s.status === "will-update" || s.status === "partially-ignored"
2953
- ).flatMap((s, a) => {
2954
- var C;
2955
- const g = s.projected ?? s.original, h = Ri(g.customAttributes);
2956
- if ((C = g.contains) != null && C.length) {
2957
- const I = g.contains.filter((w) => w.type === "RECIPE"), m = g.contains.filter((w) => w.type === "SKU"), _ = g.contains.filter((w) => w.type === "SKU_GROUP");
2958
- return [
2959
- ...a === 0 ? [] : [["", "", "", "", "", "", ""]],
2960
- ...I.map(
2961
- (w, y) => {
2962
- var e;
2963
- return [
2964
- y === 0 ? g.name : "",
2965
- "RECIPE",
2966
- "",
2967
- ((e = t[w.id]) == null ? void 0 : e.name) ?? w.id,
2968
- Q(w.amount),
2969
- "UNIT",
2970
- y === 0 ? h : ""
2971
- ];
2972
- }
2973
- ),
2974
- ...m.map(
2975
- (w, y) => {
2976
- var e, S, c, k;
2977
- return [
2978
- !I.length && y === 0 ? g.name : "",
2979
- "INGREDIENT",
2980
- ((e = l[w.id]) == null ? void 0 : e.code) ?? "",
2981
- ((S = l[w.id]) == null ? void 0 : S.name) ?? w.id,
2982
- Q(w.amount),
2983
- w.measurement ? w.measurement.abbrev : ((k = (c = l[w.id]) == null ? void 0 : c.unit) == null ? void 0 : k.abbrev) ?? "",
2984
- !I.length && y === 0 ? h : ""
2985
- ];
2986
- }
2987
- ),
2988
- ..._.map(
2989
- (w, y) => {
2990
- var e, S;
2991
- return [
2992
- I.length === 0 && m.length === 0 && y === 0 ? g.name : "",
2993
- "SKU_GROUP",
2994
- ((e = i[w.id]) == null ? void 0 : e.ref) ?? "",
2995
- ((S = i[w.id]) == null ? void 0 : S.name) ?? w.id,
2996
- Q(w.amount),
2997
- "UNIT",
2998
- I.length === 0 && m.length === 0 && y === 0 ? h : ""
2999
- ];
3000
- }
3001
- )
3002
- ];
3003
- }
3004
- return [
3005
- ...a === 0 ? [] : [["", "", "", "", "", "", ""]],
3006
- [g.name, "No bindings", "", "", "", "", h]
3007
- ];
3008
- }), o = at($, ["Name", "Type", "Code", "Item", "Amount", "Unit", "Custom Attributes"]);
3009
- st(o, `RECIPE_BULK_EDIT_${dt(/* @__PURE__ */ new Date(), "-", "-")}.xlsx`);
3010
- }
3011
- const Ti = { class: "flex flex-col gap-16" }, Ui = { class: "rounded-lg border border-fm-color-border-default bg-fm-color-surface-secondary p-16" }, Pi = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary mb-8" }, Mi = { class: "flex flex-wrap gap-12" }, Di = { class: "flex items-center gap-6" }, Gi = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ni = {
3012
- key: 0,
3013
- class: "flex items-center gap-6"
3014
- }, zi = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Oi = {
3015
- key: 1,
3016
- class: "flex items-center gap-6"
3017
- }, ji = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Li = {
3018
- key: 2,
3019
- class: "flex items-center gap-6"
3020
- }, Ki = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, qi = {
3021
- key: 3,
3022
- class: "flex items-center gap-6"
3023
- }, Wi = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Yi = { class: "mt-12" }, Ji = ["onClick"], Hi = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary flex-1 truncate" }, Qi = {
3024
- key: 0,
3025
- class: "px-12 py-8 border-b border-fm-color-border-default"
3026
- }, Xi = { class: "px-12 py-10 leading-relaxed" }, Zi = {
3027
- key: 2,
3028
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-placeholder italic"
3029
- }, el = { class: "flex items-center gap-12 px-12 py-8 border-t border-fm-color-border-default bg-fm-color-surface-secondary text-fm-color-typo-secondary fm-typo-en-body-xs-400" }, tl = { key: 0 }, nl = { key: 1 }, ol = {
3030
- key: 2,
3031
- class: "text-fm-color-warning"
3032
- }, il = {
3033
- key: 3,
3034
- class: "text-fm-color-error"
3035
- }, ll = {
3036
- key: 4,
3037
- class: "text-fm-color-typo-placeholder"
3038
- }, rl = /* @__PURE__ */ le({
3039
- __name: "RecipeBulkEditorSummaryStep",
3040
- setup(p) {
3041
- const { t: d } = ie(), l = ne(), t = ge(), i = R(() => Object.values(t.entries)), r = R(
3042
- () => i.value.filter((e) => e.status === "will-update").length
3043
- ), $ = R(
3044
- () => i.value.filter((e) => e.status === "partially-ignored").length
3045
- ), u = R(
3046
- () => i.value.filter((e) => e.status === "already-satisfied").length
3047
- ), o = R(
3048
- () => i.value.filter((e) => e.status === "blocked").length
3049
- ), s = R(
3050
- () => i.value.filter((e) => e.status === "no-applicable-changes").length
3051
- ), a = W(/* @__PURE__ */ new Set());
3052
- function g(e) {
3053
- return a.value.has(e);
3054
- }
3055
- function h(e) {
3056
- const S = new Set(a.value);
3057
- S.has(e) ? S.delete(e) : S.add(e), a.value = S;
3058
- }
3059
- function C(e) {
3060
- var k, N, z;
3061
- const S = [], c = ke(e.contains, /* @__PURE__ */ new Set([e._id]), l.recipeById);
3062
- for (let b = 0; b < c.length; b++) {
3063
- const B = c[b], F = B.recipeIds.slice(1).length > 0, A = F ? ((k = l.recipeById[B.recipeIds.at(-1) ?? ""]) == null ? void 0 : k.name) ?? "" : "";
3064
- let P;
3065
- if (B.isGroup) {
3066
- const K = l.skuGroupById[B.id];
3067
- if (!K) continue;
3068
- const H = `x${Q(B.amount)}`;
3069
- P = F ? `(${A}) ${K.name} (${H})` : `${K.name} (${H})`;
3070
- } else {
3071
- const K = l.skuById[B.id];
3072
- if (!K) continue;
3073
- const H = ((N = B.measurement) == null ? void 0 : N.abbrev) ?? ((z = K.unit) == null ? void 0 : z.abbrev) ?? "", ee = `${Q(B.amount)}${H}`;
3074
- P = F ? `(${A}) ${K.name} (${ee})` : `${K.name} (${ee})`;
3075
- }
3076
- b > 0 && S.push({ text: ", " }), S.push({ text: P });
3077
- }
3078
- return S;
3079
- }
3080
- function I(e) {
3081
- var b, B, F, A;
3082
- if (e.isGroup) {
3083
- const P = l.skuGroupById[e.id];
3084
- if (!P) return "";
3085
- const K = e.recipeIds.slice(1).length > 0, H = K ? ((b = l.recipeById[e.recipeIds.at(-1) ?? ""]) == null ? void 0 : b.name) ?? "" : "", ee = `x${Q(e.amount)}`;
3086
- return K ? `(${H}) ${P.name} (${ee})` : `${P.name} (${ee})`;
3087
- }
3088
- const S = l.skuById[e.id];
3089
- if (!S) return "";
3090
- const c = e.recipeIds.slice(1).length > 0, k = c ? ((B = l.recipeById[e.recipeIds.at(-1) ?? ""]) == null ? void 0 : B.name) ?? "" : "", N = ((F = e.measurement) == null ? void 0 : F.abbrev) ?? ((A = S.unit) == null ? void 0 : A.abbrev) ?? "", z = `${Q(e.amount)}${N}`;
3091
- return c ? `(${k}) ${S.name} (${z})` : `${S.name} (${z})`;
3092
- }
3093
- function m(e) {
3094
- if (!e.projected) return [];
3095
- const S = ke(e.original.contains, /* @__PURE__ */ new Set([e.recipeId]), l.recipeById), c = ke(e.projected.contains, /* @__PURE__ */ new Set([e.recipeId]), l.recipeById), k = /* @__PURE__ */ new Map();
3096
- for (const F of S) k.set(`${F.type}:${F.id}`, F);
3097
- const N = /* @__PURE__ */ new Map();
3098
- for (const F of c) N.set(`${F.type}:${F.id}`, F);
3099
- const z = [];
3100
- let b = !0;
3101
- function B(F, A) {
3102
- A && (b || z.push({ kind: "unchanged", text: ", " }), z.push({ kind: F, text: A }), b = !1);
3103
- }
3104
- for (const [F, A] of k) {
3105
- const P = N.get(F);
3106
- if (!P)
3107
- B("removed", I(A));
3108
- else {
3109
- const K = I(A), H = I(P);
3110
- K === H ? B("unchanged", K) : (B("removed", K), B("added", H));
3111
- }
3112
- }
3113
- for (const [F, A] of N)
3114
- k.has(F) || B("added", I(A));
3115
- return z;
3116
- }
3117
- const _ = R(() => {
3118
- const e = /* @__PURE__ */ new Map();
3119
- for (const S of i.value)
3120
- e.set(S.recipeId, m(S));
3121
- return e;
3122
- });
3123
- function w(e) {
3124
- switch (e) {
3125
- case "will-update":
3126
- return d("inventory.recipe.bulkEditor.status.willUpdate");
3127
- case "already-satisfied":
3128
- return d("inventory.recipe.bulkEditor.status.alreadySatisfied");
3129
- case "partially-ignored":
3130
- return d("inventory.recipe.bulkEditor.status.partiallyIgnored");
3131
- case "blocked":
3132
- return d("inventory.recipe.bulkEditor.status.blocked");
3133
- case "no-applicable-changes":
3134
- return d("inventory.recipe.bulkEditor.status.noApplicableChanges");
3135
- default:
3136
- return "";
3137
- }
3138
- }
3139
- function y(e) {
3140
- switch (e) {
3141
- case "will-update":
3142
- return "success";
3143
- case "already-satisfied":
3144
- return "info";
3145
- case "partially-ignored":
3146
- return "warning";
3147
- case "blocked":
3148
- return "critical";
3149
- case "no-applicable-changes":
3150
- return "neutral";
3151
- default:
3152
- return "neutral";
3153
- }
3154
- }
3155
- return (e, S) => {
3156
- const c = G("FmChip"), k = G("FmButton"), N = G("FmBanner"), z = G("FmIcon");
3157
- return v(), V("div", Ti, [
3158
- f("div", Ui, [
3159
- f("p", Pi, U(n(d)("inventory.recipe.bulkEditor.summary.title")), 1),
3160
- f("div", Mi, [
3161
- f("div", Di, [
3162
- x(c, {
3163
- size: "sm",
3164
- label: String(r.value),
3165
- variant: "success"
3166
- }, null, 8, ["label"]),
3167
- f("span", Gi, U(n(d)("inventory.recipe.bulkEditor.summary.countWillUpdate")), 1)
3168
- ]),
3169
- $.value > 0 ? (v(), V("div", Ni, [
3170
- x(c, {
3171
- size: "sm",
3172
- label: String($.value),
3173
- variant: "warning"
3174
- }, null, 8, ["label"]),
3175
- f("span", zi, U(n(d)("inventory.recipe.bulkEditor.summary.countPartiallyIgnored")), 1)
3176
- ])) : T("", !0),
3177
- u.value > 0 ? (v(), V("div", Oi, [
3178
- x(c, {
3179
- size: "sm",
3180
- label: String(u.value),
3181
- variant: "info"
3182
- }, null, 8, ["label"]),
3183
- f("span", ji, U(n(d)("inventory.recipe.bulkEditor.summary.countAlreadySatisfied")), 1)
3184
- ])) : T("", !0),
3185
- o.value > 0 ? (v(), V("div", Li, [
3186
- x(c, {
3187
- size: "sm",
3188
- label: String(o.value),
3189
- variant: "critical"
3190
- }, null, 8, ["label"]),
3191
- f("span", Ki, U(n(d)("inventory.recipe.bulkEditor.summary.countBlocked")), 1)
3192
- ])) : T("", !0),
3193
- s.value > 0 ? (v(), V("div", qi, [
3194
- x(c, {
3195
- size: "sm",
3196
- label: String(s.value),
3197
- variant: "neutral"
3198
- }, null, 8, ["label"]),
3199
- f("span", Wi, U(n(d)("inventory.recipe.bulkEditor.summary.countNoChanges")), 1)
3200
- ])) : T("", !0)
3201
- ]),
3202
- f("div", Yi, [
3203
- x(k, {
3204
- label: n(d)("common.export"),
3205
- variant: "secondary",
3206
- size: "md",
3207
- onClick: n(Ai)
3208
- }, null, 8, ["label", "onClick"])
3209
- ]),
3210
- r.value === 0 && $.value === 0 ? (v(), Y(N, {
3211
- key: 0,
3212
- class: "mt-12",
3213
- type: "warning",
3214
- message: n(d)("inventory.recipe.bulkEditor.summary.nothingToSubmit")
3215
- }, null, 8, ["message"])) : T("", !0)
3216
- ]),
3217
- (v(!0), V(X, null, me(i.value, (b) => (v(), V("div", {
3218
- key: b.recipeId,
3219
- class: "rounded-lg border border-fm-color-border-default overflow-hidden"
3220
- }, [
3221
- f("button", {
3222
- type: "button",
3223
- class: Ce(["w-full flex items-center gap-8 px-12 py-10 bg-fm-color-surface-secondary border-b border-fm-color-border-default text-left cursor-pointer", { "border-b-0": !g(b.recipeId) }]),
3224
- onClick: (B) => h(b.recipeId)
3225
- }, [
3226
- x(z, {
3227
- name: g(b.recipeId) ? "expand_less" : "expand_more",
3228
- size: "sm",
3229
- class: "text-fm-color-typo-secondary flex-shrink-0"
3230
- }, null, 8, ["name"]),
3231
- f("span", Hi, U(b.recipeName), 1),
3232
- b.original.version === "v2" ? (v(), Y(c, {
3233
- key: 0,
3234
- size: "sm",
3235
- label: "V2",
3236
- variant: "info"
3237
- })) : T("", !0),
3238
- x(c, {
3239
- size: "sm",
3240
- label: w(b.status),
3241
- variant: y(b.status)
3242
- }, null, 8, ["label", "variant"])
3243
- ], 10, Ji),
3244
- g(b.recipeId) ? (v(), V(X, { key: 0 }, [
3245
- n(t).applyErrors.has(b.recipeId) ? (v(), V("div", Qi, [
3246
- x(N, {
3247
- type: "error",
3248
- message: n(t).applyErrors.get(b.recipeId)
3249
- }, null, 8, ["message"])
3250
- ])) : T("", !0),
3251
- f("div", Xi, [
3252
- b.projected ? (_.value.get(b.recipeId) ?? []).length > 0 ? (v(!0), V(X, { key: 1 }, me(_.value.get(b.recipeId), (B, F) => (v(), V("span", {
3253
- key: F,
3254
- class: Ce(["fm-typo-en-body-sm-400", {
3255
- "text-fm-color-typo-secondary": B.kind === "unchanged",
3256
- "line-through text-fm-color-error font-medium": B.kind === "removed",
3257
- "text-fm-color-success font-medium": B.kind === "added"
3258
- }])
3259
- }, U(B.text), 3))), 128)) : (v(), V("span", Zi, U(n(d)("inventory.recipe.bulkEditor.summary.emptyBindings")), 1)) : (v(!0), V(X, { key: 0 }, me(C(b.original), (B, F) => (v(), V("span", {
3260
- key: F,
3261
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-placeholder"
3262
- }, U(B.text), 1))), 128))
3263
- ]),
3264
- f("div", el, [
3265
- b.counts.applied > 0 ? (v(), V("span", tl, U(n(d)("inventory.recipe.bulkEditor.summary.footerApplied", { count: b.counts.applied })), 1)) : T("", !0),
3266
- b.counts.satisfied > 0 ? (v(), V("span", nl, U(n(d)("inventory.recipe.bulkEditor.summary.footerSatisfied", { count: b.counts.satisfied })), 1)) : T("", !0),
3267
- b.counts.ignored > 0 ? (v(), V("span", ol, U(n(d)("inventory.recipe.bulkEditor.summary.footerIgnored", { count: b.counts.ignored })), 1)) : T("", !0),
3268
- b.counts.blocked > 0 ? (v(), V("span", il, U(n(d)("inventory.recipe.bulkEditor.summary.footerBlocked", { count: b.counts.blocked })), 1)) : T("", !0),
3269
- b.counts.applied === 0 && b.counts.satisfied === 0 && b.counts.ignored === 0 && b.counts.blocked === 0 ? (v(), V("span", ll, U(n(d)("inventory.recipe.bulkEditor.summary.noChangesDetail")), 1)) : T("", !0)
3270
- ])
3271
- ], 64)) : T("", !0)
3272
- ]))), 128))
3273
- ]);
3274
- };
3275
- }
3276
- }), al = { class: "flex items-center gap-12" }, sl = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, dl = {
3277
- key: 0,
3278
- class: "h-[calc(98vh-120px)] overflow-hidden flex flex-col"
3279
- }, ul = {
3280
- key: 1,
3281
- class: "h-[calc(98vh-120px)] overflow-hidden flex flex-col"
3282
- }, cl = {
3283
- key: 2,
3284
- class: "h-[calc(98vh-120px)] overflow-y-auto px-24 py-20"
3285
- }, pl = {
3286
- key: 0,
3287
- class: "flex items-center gap-8 px-4"
3288
- }, ml = {
3289
- key: 1,
3290
- class: "flex items-center gap-8 px-4"
3291
- }, fl = {
3292
- key: 2,
3293
- class: "flex items-center gap-8 px-4"
3294
- }, vl = /* @__PURE__ */ le({
3295
- __name: "RecipeBulkEditorDialog",
3296
- props: {
3297
- show: { type: Boolean }
3298
- },
3299
- emits: ["update:show"],
3300
- setup(p, { emit: d }) {
3301
- const l = p, { t } = ie(), i = ge(), r = Ge(l, "show"), $ = je(), u = R(() => i.currentStep === 1), o = R(() => i.currentStep === 2), s = R(() => i.currentStep === 3);
3302
- function a() {
3303
- i.currentStep = 2;
3304
- }
3305
- function g() {
3306
- i.currentStep = 1;
3307
- }
3308
- function h() {
3309
- i.goToStep3();
3310
- }
3311
- function C() {
3312
- i.backToStep2();
3313
- }
3314
- function I() {
3315
- $.open({
3316
- title: t("inventory.recipe.bulkEditor.step3.confirmTitle"),
3317
- message: t("inventory.recipe.bulkEditor.step3.confirmMessage"),
3318
- primaryActions: {
3319
- text: t("inventory.recipe.bulkEditor.step3.confirmButton"),
3320
- variant: "primary",
3321
- close: !0
3322
- },
3323
- secondaryActions: {
3324
- text: t("common.cancel"),
3325
- close: !0
3326
- }
3327
- }).onPrimary(async () => {
3328
- await i.confirmAndApply();
3329
- });
3330
- }
3331
- function m() {
3332
- r.value = !1, i.reset();
3333
- }
3334
- return (_, w) => {
3335
- const y = G("FmChip"), e = G("FmButton"), S = G("FmDialog");
3336
- return v(), Y(S, {
3337
- modelValue: n(r),
3338
- "onUpdate:modelValue": [
3339
- w[0] || (w[0] = (c) => De(r) ? r.value = c : null),
3340
- w[1] || (w[1] = (c) => {
3341
- c || n(i).reset();
3342
- })
3343
- ],
3344
- overlay: !0,
3345
- "close-button": "",
3346
- "max-width": "98vw",
3347
- "max-height": "98vh"
3348
- }, {
3349
- "dialog-header": J(() => [
3350
- f("div", al, [
3351
- f("span", sl, U(n(t)("inventory.recipe.bulkEditor.title")), 1),
3352
- x(y, {
3353
- size: "sm",
3354
- label: n(t)("inventory.recipe.bulkEditor.stepIndicator", { step: n(i).currentStep, total: 3 }),
3355
- variant: "neutral"
3356
- }, null, 8, ["label"])
3357
- ])
3358
- ]),
3359
- "dialog-footer": J(() => [
3360
- u.value ? (v(), V("div", pl, [
3361
- x(e, {
3362
- label: n(t)("common.next"),
3363
- disabled: !n(i).canGoToStep2,
3364
- onClick: a
3365
- }, null, 8, ["label", "disabled"]),
3366
- x(e, {
3367
- label: n(t)("common.close"),
3368
- variant: "tertiary",
3369
- onClick: m
3370
- }, null, 8, ["label"])
3371
- ])) : o.value ? (v(), V("div", ml, [
3372
- x(e, {
3373
- label: n(t)("inventory.recipe.bulkEditor.step2.reviewButton"),
3374
- disabled: !n(i).canGoToStep3,
3375
- onClick: h
3376
- }, null, 8, ["label", "disabled"]),
3377
- x(e, {
3378
- label: n(t)("common.back"),
3379
- variant: "secondary",
3380
- onClick: g
3381
- }, null, 8, ["label"]),
3382
- x(e, {
3383
- label: n(t)("common.close"),
3384
- variant: "tertiary",
3385
- onClick: m
3386
- }, null, 8, ["label"])
3387
- ])) : s.value ? (v(), V("div", fl, [
3388
- x(e, {
3389
- label: n(t)("inventory.recipe.bulkEditor.step3.confirmButton"),
3390
- disabled: n(i).isSaving,
3391
- loading: n(i).isSaving,
3392
- onClick: I
3393
- }, null, 8, ["label", "disabled", "loading"]),
3394
- x(e, {
3395
- label: n(t)("common.back"),
3396
- variant: "secondary",
3397
- disabled: n(i).isSaving,
3398
- onClick: C
3399
- }, null, 8, ["label", "disabled"]),
3400
- x(e, {
3401
- label: n(t)("common.close"),
3402
- variant: "tertiary",
3403
- disabled: n(i).isSaving,
3404
- onClick: m
3405
- }, null, 8, ["label", "disabled"])
3406
- ])) : T("", !0)
3407
- ]),
3408
- default: J(() => [
3409
- u.value ? (v(), V("div", dl, [
3410
- x(Oo)
3411
- ])) : o.value ? (v(), V("div", ul, [
3412
- x(Fi)
3413
- ])) : s.value ? (v(), V("div", cl, [
3414
- x(rl)
3415
- ])) : T("", !0)
3416
- ]),
3417
- _: 1
3418
- }, 8, ["modelValue"]);
3419
- };
3420
- }
3421
- });
3422
- function yl(p) {
3423
- return !p || Object.keys(p).length === 0 ? "" : Object.entries(p).map(([d, l]) => `${d}: ${l}`).join(", ");
3424
- }
3425
- function bl() {
3426
- const p = ne(), d = p.recipes, l = p.recipeById, t = p.skuById, i = p.skuGroupById, r = d.flatMap((o, s) => {
3427
- var g;
3428
- const a = yl(o.customAttributes);
3429
- if ((g = o.contains) != null && g.length) {
3430
- const h = o.contains.filter((m) => m.type === "RECIPE"), C = o.contains.filter((m) => m.type === "SKU"), I = o.contains.filter((m) => m.type === "SKU_GROUP");
3431
- return [
3432
- ...s === 0 ? [] : [["", "", "", "", "", "", ""]],
3433
- ...h.map(
3434
- (m, _) => {
3435
- var w;
3436
- return [
3437
- _ === 0 ? o.name : "",
3438
- "RECIPE",
3439
- "",
3440
- (w = l[m.id]) == null ? void 0 : w.name,
3441
- Q(m.amount),
3442
- "UNIT",
3443
- _ === 0 ? a : ""
3444
- ];
3445
- }
3446
- ),
3447
- ...C.map(
3448
- (m, _) => {
3449
- var w, y, e, S;
3450
- return [
3451
- !h.length && _ === 0 ? o.name : "",
3452
- "INGREDIENT",
3453
- (w = t[m.id]) == null ? void 0 : w.code,
3454
- (y = t[m.id]) == null ? void 0 : y.name,
3455
- Q(m.amount),
3456
- m.measurement ? m.measurement.abbrev : (S = (e = t[m.id]) == null ? void 0 : e.unit) == null ? void 0 : S.abbrev,
3457
- !h.length && _ === 0 ? a : ""
3458
- ];
3459
- }
3460
- ),
3461
- ...I.map(
3462
- (m, _) => {
3463
- var w, y;
3464
- return [
3465
- h.length === 0 && C.length === 0 && _ === 0 ? o.name : "",
3466
- "SKU_GROUP",
3467
- ((w = i[m.id]) == null ? void 0 : w.ref) || "",
3468
- (y = i[m.id]) == null ? void 0 : y.name,
3469
- Q(m.amount),
3470
- "UNIT",
3471
- h.length === 0 && C.length === 0 && _ === 0 ? a : ""
3472
- ];
3473
- }
3474
- )
3475
- ];
3476
- }
3477
- return [
3478
- ...s === 0 ? [] : [["", "", "", "", "", "", ""]],
3479
- [o.name, "No bindings", "", "", "", "", a]
3480
- ];
3481
- }), u = at(r, ["Name", "Type", "Code", "Item", "Amount", "Unit", "Custom Attributes"]);
3482
- st(u, `RECIPE_${dt(/* @__PURE__ */ new Date(), "-", "-")}.xlsx`);
3483
- }
3484
- const gl = { class: "flex flex-col py-8" }, _l = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, kl = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Hl = /* @__PURE__ */ le({
3485
- __name: "RecipeView",
3486
- setup(p) {
3487
- const d = ne(), l = R(() => d.recipes), t = tt(), { createRecipe: i, updateRecipe: r } = ze(), { recipeDialogProps: $, recipeViewLoading: u } = Et(ze()), { columnDefs: o, formatRowData: s } = Jt(), a = R(() => s(l.value)), g = ge(), h = We();
3488
- W(!1);
3489
- function C(c) {
3490
- if (c === "add")
3491
- return i();
3492
- if (c === "export")
3493
- return bl();
3494
- c === "bulk-edit" && g.openDialog();
3495
- }
3496
- const I = W(""), m = R(() => u.value), { breakpoints: _ } = xt(), w = R(() => _.value.xs || _.value.sm), y = R(() => w.value ? 10 : 20), e = Ct(), { t: S } = ie();
3497
- return (c, k) => {
3498
- const N = G("FmTable");
3499
- return v(), Y(Bt, {
3500
- title: n(S)("inventory.recipe.title"),
3501
- actions: [
3502
- {
3503
- label: n(S)("inventory.recipe.create.title"),
3504
- value: "add",
3505
- isPrimary: !0,
3506
- prependIcon: "add"
3507
- },
3508
- ...n(h).enableBulkEditRecipes ? [{ label: n(S)("inventory.recipe.bulkEditor.title"), value: "bulk-edit", isPrimary: !1 }] : [],
3509
- { label: n(S)("common.export"), value: "export", isPrimary: !1 }
3510
- ],
3511
- "onClick:action": C
3512
- }, {
3513
- default: J(() => [
3514
- f("div", {
3515
- class: Ce([
3516
- "relative flex flex-col gap-8 max-h-full",
3517
- {
3518
- "p-0": w.value,
3519
- "px-24 ": !w.value
3520
- }
3521
- ])
3522
- }, [
3523
- x(Lt, {
3524
- searchable: "",
3525
- search: I.value,
3526
- "onUpdate:search": k[0] || (k[0] = (z) => I.value = z)
3527
- }, null, 8, ["search"]),
3528
- (v(), Y(N, {
3529
- style: vt(n(e).tableHeight),
3530
- "column-defs": n(o),
3531
- "row-data": a.value,
3532
- "search-value": I.value,
3533
- loading: !n(t)._currentLocation || m.value,
3534
- onRowClick: k[1] || (k[1] = (z) => n(r)(z.original.original)),
3535
- key: l.value.length,
3536
- "page-size": y.value
3537
- }, {
3538
- "list-row": J((z) => [
3539
- x(jt, {
3540
- row: z,
3541
- onRowClick: (b) => n(r)(b.original)
3542
- }, {
3543
- default: J((b) => {
3544
- var B, F, A, P, K, H, ee, O, M, j;
3545
- return [
3546
- f("div", gl, [
3547
- f("div", _l, [
3548
- x(n(Qe), {
3549
- render: (A = (F = (B = b.recipe) == null ? void 0 : B.column) == null ? void 0 : F.columnDef) == null ? void 0 : A.cell,
3550
- props: (K = (P = b.recipe) == null ? void 0 : P.getContext) == null ? void 0 : K.call(P)
3551
- }, null, 8, ["render", "props"])
3552
- ]),
3553
- f("div", kl, [
3554
- x(n(Qe), {
3555
- render: (O = (ee = (H = b.ingredients) == null ? void 0 : H.column) == null ? void 0 : ee.columnDef) == null ? void 0 : O.cell,
3556
- props: (j = (M = b.ingredients) == null ? void 0 : M.getContext) == null ? void 0 : j.call(M)
3557
- }, null, 8, ["render", "props"])
3558
- ])
3559
- ])
3560
- ];
3561
- }),
3562
- _: 2
3563
- }, 1032, ["row", "onRowClick"])
3564
- ]),
3565
- _: 1
3566
- }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
3567
- ], 2),
3568
- (v(), Y(yt, { to: "body" }, [
3569
- x(vo, bt(gt(n($))), null, 16),
3570
- n(h).enableBulkEditRecipes ? (v(), Y(vl, {
3571
- key: 0,
3572
- show: n(g).show,
3573
- "onUpdate:show": k[2] || (k[2] = (z) => n(g).show = z)
3574
- }, null, 8, ["show"])) : T("", !0)
3575
- ]))
3576
- ]),
3577
- _: 1
3578
- }, 8, ["title", "actions"]);
3579
- };
3580
- }
3581
- });
3582
- export {
3583
- Hl as default
3584
- };