@feedmepos/mf-inventory-portal 0.0.22-dev.5 → 0.0.22-dev.50

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 (144) hide show
  1. package/dist/ApprovalView-CyIOcyG5.js +140 -0
  2. package/dist/{BindingsDialog-DQJhC3Mo.js → BindingsDialog-BXePN5iL.js} +10 -10
  3. package/dist/{BindingsPicker-YfbPb_dG.js → BindingsPicker-Bd_qb0aO.js} +15 -15
  4. package/dist/{BindingsTable-D3MVcHXZ.js → BindingsTable-BV-nP9HU.js} +4 -4
  5. package/dist/ClosingTemplateView-CSvWLccZ.js +1829 -0
  6. package/dist/FmDroppableField-DwZ6ujPh.js +154 -0
  7. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DpCoW_-F.js +266 -0
  8. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BpzreBHD.js +435 -0
  9. package/dist/IngredientBindedItem.vue_vue_type_script_setup_true_lang-C8k7pSPT.js +51 -0
  10. package/dist/IngredientGroupView-C0hPeD41.js +608 -0
  11. package/dist/IngredientsView-CpwVIGXd.js +1608 -0
  12. package/dist/IntegrationView-Bt8pGAHS.js +1225 -0
  13. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-wsBLYBpB.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-yA-qJUUz.js} +1 -1
  14. package/dist/PremiumBadge.vue_vue_type_script_setup_true_lang-BqcqoKyN.js +116 -0
  15. package/dist/{PurchaseOrderPrintPreview-BcAmgmD8.js → PurchaseOrderPrintPreview-D3ugzCW_.js} +7 -7
  16. package/dist/ReceiveRequestView-D14YTEEe.js +4073 -0
  17. package/dist/RecipeView-D0WsMfKm.js +594 -0
  18. package/dist/Standalone.vue.d.ts +2 -0
  19. package/dist/StockView-sxI0L6MP.js +7770 -0
  20. package/dist/SupplierView-clAkARuW.js +1468 -0
  21. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-C9NU1m6S.js +1150 -0
  22. package/dist/TransferTemplateView-DpI6kVqX.js +1258 -0
  23. package/dist/{UnitView-B95q8Xrj.js → UnitView-CneJsDum.js} +18 -18
  24. package/dist/{WarehouseView-CHGXvyeS.js → WarehouseView-DYbFWTlh.js} +176 -177
  25. package/dist/api/bill.d.ts +84 -238
  26. package/dist/api/closing-template.d.ts +6 -4
  27. package/dist/api/inventory.d.ts +282 -91
  28. package/dist/api/netsuite.d.ts +71 -0
  29. package/dist/api/purchase-order-template.d.ts +4 -6
  30. package/dist/api/supplier.d.ts +1 -0
  31. package/dist/{app-CfXF4jdF.js → app-B4pi48sM.js} +26414 -24985
  32. package/dist/app.d.ts +88 -3
  33. package/dist/app.js +3 -3
  34. package/dist/components/FmFilterableMenuOptions.vue.d.ts +54 -0
  35. package/dist/components/FmMinMaxInputRules.d.ts +2 -0
  36. package/dist/components/FmMultiselectDialog.vue.d.ts +3 -9
  37. package/dist/components/FmMultiselectDialogProps.d.ts +0 -2
  38. package/dist/components/FmUnitInputRules.d.ts +2 -0
  39. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +5 -5
  40. package/dist/components/map/GoogleMap.vue.d.ts +4 -4
  41. package/dist/components/shell/inventory/binding-dialog.vue.d.ts +2 -2
  42. package/dist/components/shell/inventory/binding-ui.vue.d.ts +2 -2
  43. package/dist/{decimal-BZ7tX47r.js → decimal-C8O2p3Sg.js} +1 -1
  44. package/dist/defineDeepModel-BXP1vLGf.js +13 -0
  45. package/dist/extensions/array.d.ts +1 -0
  46. package/dist/format-time-from-id-DgW7OJL_.js +15 -0
  47. package/dist/format-unit-display-BP4O0Pym.js +1195 -0
  48. package/dist/helper/rules.d.ts +7 -0
  49. package/dist/helper/rules.spec.d.ts +1 -0
  50. package/dist/helper/xlsx.util.d.ts +7 -0
  51. package/dist/router/name.d.ts +1 -0
  52. package/dist/stores/api.d.ts +1 -0
  53. package/dist/stores/feature.d.ts +0 -1
  54. package/dist/stores/helper/core-store-proxy.d.ts +3 -0
  55. package/dist/stores/helper/generate-backend-urls.d.ts +1 -0
  56. package/dist/stores/integration/foodmarkethub.d.ts +391 -0
  57. package/dist/stores/integration/index.d.ts +7 -0
  58. package/dist/stores/integration/netsuite.d.ts +102 -0
  59. package/dist/stores/inventory.d.ts +294 -9
  60. package/dist/stores/location.d.ts +508 -503
  61. package/dist/stores/supplier.d.ts +124 -4
  62. package/dist/style.css +1 -1
  63. package/dist/supplier-D-8XhuF_.js +77 -0
  64. package/dist/tsconfig.app.tsbuildinfo +1 -1
  65. package/dist/use-template-enabled-locations-2-C2E4j3k-.js +85 -0
  66. package/dist/views/closing-template/closing-template-import/ClosingTemplateImport.vue.d.ts +2 -0
  67. package/dist/views/closing-template/closing-template-import/ClosingTemplateImportItem.vue.d.ts +12 -0
  68. package/dist/views/closing-template/closing-template-import/ClosingTemplateImportItemProps.d.ts +7 -0
  69. package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-items.d.ts +1 -1
  70. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +877 -1038
  71. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +882 -1049
  72. package/dist/views/closing-template/helpers/import-export.helper.d.ts +58 -0
  73. package/dist/views/ingredient-group/IngredientGroupView.vue.d.ts +3 -0
  74. package/dist/views/ingredient-group/components/ingredient-group-dialog/IngredientGroupDialog.vue.d.ts +31 -0
  75. package/dist/views/ingredient-group/components/ingredient-group-dialog/IngredientGroupDialogProps.d.ts +12 -0
  76. package/dist/views/ingredient-group/components/ingredient-group-form/IngredientGroupForm.vue.d.ts +20 -0
  77. package/dist/views/ingredient-group/components/ingredient-group-form/IngredientGroupFormProps.d.ts +12 -0
  78. package/dist/views/ingredient-group/composables/use-ingredient-group-actions.d.ts +24 -0
  79. package/dist/views/ingredient-group/composables/use-ingredient-group-table.d.ts +215 -0
  80. package/dist/views/ingredients/components/convert/ConvertForm.vue.d.ts +2 -2
  81. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +2 -2
  82. package/dist/views/ingredients/components/inventory-binding/InventoryBindingForm.vue.d.ts +5 -5
  83. package/dist/views/ingredients/composables/use-ingredient-form.d.ts +2 -2
  84. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +1 -1
  85. package/dist/views/integration/FoodMarketHub.vue.d.ts +2 -0
  86. package/dist/views/integration/NetSuite.vue.d.ts +2 -0
  87. package/dist/views/integration/components/ApplyProductDialog.vue.d.ts +7 -7
  88. package/dist/views/integration/components/ApplyProductDialogV4.vue.d.ts +7 -7
  89. package/dist/views/receive-request/components/transfer-details/TransferDetailsProps.d.ts +1 -0
  90. package/dist/views/receive-request/components/transfer-form/NetSuiteField.vue.d.ts +49 -0
  91. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +1961 -87
  92. package/dist/views/receive-request/components/transfer-form/TransferFormProps.d.ts +1 -0
  93. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +2 -2
  94. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +1 -1
  95. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +2377 -292
  96. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +2329 -244
  97. package/dist/views/recipe/components/recipe-form/RecipeForm.vue.d.ts +2 -2
  98. package/dist/views/recipe/composables/use-recipe-form.d.ts +2 -2
  99. package/dist/views/stock/components/StockRecordCard.vue.d.ts +42 -119
  100. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +32 -2
  101. package/dist/views/stock/composables/use-stock-action.d.ts +2 -2
  102. package/dist/views/supplier/components/supplier-import/SupplierImport.vue.d.ts +2 -0
  103. package/dist/views/supplier/components/supplier-import/SupplierImportItem.vue.d.ts +12 -0
  104. package/dist/views/supplier/components/supplier-import/SupplierImportItemProps.d.ts +6 -0
  105. package/dist/views/supplier/composables/use-supplier-actions.d.ts +10 -0
  106. package/dist/views/supplier/helpers/import-export.helper.d.ts +50 -0
  107. package/dist/views/transfer-template/components/transfer-template-details/TransferTemplateDetails.vue.d.ts +0 -2
  108. package/dist/views/transfer-template/components/transfer-template-details/TransferTemplateDetailsProps.d.ts +0 -1
  109. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations-2.d.ts +13 -0
  110. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations.d.ts +71 -85
  111. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-locations.d.ts +39 -2
  112. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +1 -1
  113. package/dist/views/transfer-template/components/transfer-template-import/TransferTemplateImport.vue.d.ts +2 -0
  114. package/dist/views/transfer-template/components/transfer-template-import/TransferTemplateImportItem.vue.d.ts +12 -0
  115. package/dist/views/transfer-template/components/transfer-template-import/TransferTemplateImportItemProps.d.ts +9 -0
  116. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +1277 -1478
  117. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +1697 -906
  118. package/dist/views/transfer-template/helpers/import-export.helper.d.ts +76 -0
  119. package/dist/views/transfer-template/helpers/remove-deleted-skus.helper.d.ts +1 -247
  120. package/dist/views/transfer-template/helpers/template-item.error.helper.d.ts +1 -0
  121. package/dist/views/unit/composables/use-unit-form.d.ts +2 -2
  122. package/dist/{xlsx-BtP1Qjj6.js → xlsx-Dsy-fxZw.js} +1525 -1525
  123. package/dist/xlsx.util-CxGmvsp9.js +78 -0
  124. package/package.json +10 -7
  125. package/dist/ApprovalView-BdaNwUBc.js +0 -129
  126. package/dist/ClosingTemplateView-BpErgepi.js +0 -1030
  127. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-D3B7kOlU.js +0 -372
  128. package/dist/IngredientsView-GqrkpCm5.js +0 -1758
  129. package/dist/IntegrationView-7c3MpUzS.js +0 -1141
  130. package/dist/PremiumBadge.vue_vue_type_script_setup_true_lang-BIwdObb1.js +0 -88
  131. package/dist/ReceiveRequestView-BAuXvzQW.js +0 -215
  132. package/dist/RecipeView-C6tZPQ-K.js +0 -581
  133. package/dist/StockView-4uXHYz4E.js +0 -1892
  134. package/dist/SupplierView-CuWvKCWY.js +0 -827
  135. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CTQ9HIqf.js +0 -740
  136. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang--6JoXOLD.js +0 -1409
  137. package/dist/TransferTemplateView-D1Lfi3aW.js +0 -1230
  138. package/dist/defineDeepModel-BKAs9qN6.js +0 -13
  139. package/dist/format-time-from-id-B7ZE4sdX.js +0 -15
  140. package/dist/id-to-date-D1lOqIir.js +0 -30
  141. package/dist/purchase-order-transaction-type-tZ7cj1dz.js +0 -702
  142. package/dist/supplier-BIDBk5S6.js +0 -69
  143. package/dist/use-template-enabled-locations-DlMnS9WJ.js +0 -57
  144. package/dist/xlsx.util-BKFiH-ig.js +0 -109
@@ -0,0 +1,1608 @@
1
+ import { ref as N, defineComponent as ae, computed as C, resolveComponent as U, openBlock as g, createBlock as D, withCtx as S, createVNode as p, unref as u, createElementBlock as T, Fragment as q, createElementVNode as d, createCommentVNode as O, onMounted as nt, watch as ze, normalizeClass as Z, createTextVNode as He, toDisplayString as B, renderList as ee, isRef as Ee, createSlots as Oe, normalizeStyle as ot, Teleport as Re, normalizeProps as lt, guardReactiveProps as rt } from "vue";
2
+ import { u as te, c as je, S as at, _ as st, A as ge, a as Ye, g as be, t as Ge, F as de, R as xe, U as it, M as ut, d as Ae, b as qe, C as Ve, e as De, f as dt, h as mt, I as ct, i as pt } from "./app-B4pi48sM.js";
3
+ import { useDialog as We, useSnackbar as he, useProxiedModel as Te, useDialogChild as vt, useBreakpoints as ft } from "@feedmepos/ui-library";
4
+ import { i as yt, _ as gt } from "./is-linked-ingredient-error-fJ2TJb3z.js";
5
+ import { F as j, D as Pe, R as ye } from "./row-action.enum-PMKMRrZR.js";
6
+ import { useI18n as ne, useCoreStore as me } from "@feedmepos/mf-common";
7
+ import { defineStore as bt, storeToRefs as ht } from "pinia";
8
+ import { c as _t, _ as xt, F as Be } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js";
9
+ import { u as Vt, _ as kt, a as Ct } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BpzreBHD.js";
10
+ import { g as wt, _ as ke, S as Ce } from "./StockForecast.vue_vue_type_style_index_0_lang-KLXSWvo5.js";
11
+ import { _ as we } from "./IngredientBindedItem.vue_vue_type_script_setup_true_lang-C8k7pSPT.js";
12
+ import { _ as Se } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
13
+ import { t as Ke, d as Je, s as St, r as Ft } from "./xlsx.util-CxGmvsp9.js";
14
+ import { F as Mt } from "./FmDroppableField-DwZ6ujPh.js";
15
+ const Fe = bt("ingredientForm", function() {
16
+ const a = We(), f = he(), s = te(), n = N(!1), { t: l } = ne(), o = N();
17
+ function c() {
18
+ const b = {
19
+ unit: {},
20
+ mode: j.CREATE,
21
+ show: !0,
22
+ "onUpdate:show"(i) {
23
+ o.value.show = i;
24
+ }
25
+ };
26
+ o.value = b;
27
+ }
28
+ async function y(b) {
29
+ const i = {
30
+ unit: je(b),
31
+ mode: j.UPDATE,
32
+ show: !0,
33
+ "onUpdate:show"(_) {
34
+ o.value.show = _;
35
+ }
36
+ };
37
+ o.value = i;
38
+ }
39
+ async function h(b) {
40
+ n.value = !0;
41
+ try {
42
+ await s.deleteSku(b), f.open({
43
+ title: "Success",
44
+ message: `Deleted ${b.name}`,
45
+ type: "success"
46
+ });
47
+ } catch (i) {
48
+ i instanceof at && yt(i) ? a.open({
49
+ title: "Cannot delete ingredient",
50
+ contentComponent: gt,
51
+ contentComponentProps: {
52
+ subject: (b == null ? void 0 : b.name) ?? "",
53
+ items: i.errorResponse.message
54
+ },
55
+ secondaryActions: {
56
+ text: "Close",
57
+ close: !0
58
+ }
59
+ }) : console.log("unable to delete ingredient", i), f.open({
60
+ title: `Cannot delete ${b.name}`,
61
+ message: "Please try again.",
62
+ type: "error"
63
+ }), console.error("failed to delete ingredient", i);
64
+ } finally {
65
+ n.value = !1;
66
+ }
67
+ }
68
+ function v(b) {
69
+ a.open({
70
+ title: l("inventory.ingredient.delete.title", [(b == null ? void 0 : b.name) ?? ""]),
71
+ closeButton: !1,
72
+ message: l("inventory.ingredient.delete.message"),
73
+ primaryActions: {
74
+ text: l("common.delete"),
75
+ close: !0,
76
+ variant: "destructive"
77
+ },
78
+ secondaryActions: {
79
+ text: l("common.cancel"),
80
+ close: !0
81
+ }
82
+ }).onPrimary(() => h(b));
83
+ }
84
+ return {
85
+ createIngredient: c,
86
+ updateIngredient: y,
87
+ deleteIngredient: v,
88
+ ingredientDialogProps: o,
89
+ ingredientViewLoading: n
90
+ };
91
+ });
92
+ function It() {
93
+ const { updateIngredient: r, deleteIngredient: a } = Fe(), { t: f } = ne();
94
+ async function s(l, o) {
95
+ const c = je(o);
96
+ if (l === ye.Edit) {
97
+ await r(c);
98
+ return;
99
+ }
100
+ if (l === ye.Delete) {
101
+ await a(c);
102
+ return;
103
+ }
104
+ }
105
+ return { columnDefs: [
106
+ {
107
+ accessorKey: "code",
108
+ header: () => f("inventory.ingredient.code"),
109
+ enableSorting: !0,
110
+ size: 300
111
+ },
112
+ {
113
+ accessorKey: "name",
114
+ header: () => f("inventory.ingredient.name"),
115
+ enableSorting: !0,
116
+ size: 300
117
+ },
118
+ {
119
+ id: "unit",
120
+ header: () => f("inventory.ingredient.unit"),
121
+ cell(l) {
122
+ var c;
123
+ const o = l.row.original;
124
+ if (o.trackingMeasurement) {
125
+ const y = (c = o.unit.measurements) == null ? void 0 : c.find(
126
+ (h) => h.id === o.trackingMeasurement
127
+ );
128
+ if (y)
129
+ return `${y.name} (${y.abbrev})`;
130
+ }
131
+ return `${o.unit.name} (${o.unit.abbrev})`;
132
+ },
133
+ enableSorting: !1,
134
+ size: "auto"
135
+ },
136
+ {
137
+ id: "action",
138
+ header: "",
139
+ cell(l) {
140
+ return _t(
141
+ [Pe[ye.Edit], Pe[ye.Delete]],
142
+ (o) => {
143
+ s(o, l.row.original);
144
+ }
145
+ );
146
+ },
147
+ enableSorting: !1,
148
+ size: 40,
149
+ meta: {
150
+ cellClass: "",
151
+ headerClass: ""
152
+ }
153
+ }
154
+ ] };
155
+ }
156
+ const Ut = /* @__PURE__ */ ae({
157
+ __name: "ConvertForm",
158
+ props: {
159
+ modelValue: {},
160
+ rootValue: {},
161
+ disabled: { type: Boolean }
162
+ },
163
+ emits: ["update:modelValue"],
164
+ setup(r, { emit: a }) {
165
+ const f = r, s = C(() => {
166
+ var i;
167
+ return (i = f.rootValue) == null ? void 0 : i.unit;
168
+ }), n = C(() => {
169
+ var i;
170
+ return (i = f.rootValue) == null ? void 0 : i._id;
171
+ }), l = a, { t: o } = ne(), c = C({
172
+ get() {
173
+ return !!f.modelValue;
174
+ },
175
+ set(i) {
176
+ i ? l("update:modelValue", {
177
+ measurement: null,
178
+ inventoryBindings: []
179
+ }) : l("update:modelValue", null);
180
+ }
181
+ }), y = C(() => wt(s.value));
182
+ function h(i) {
183
+ const _ = f.modelValue ?? {};
184
+ _.measurement = i ? `${i}` : null, l("update:modelValue", _);
185
+ }
186
+ function v(i) {
187
+ const _ = f.modelValue ?? {};
188
+ _.inventoryBindings = i, l("update:modelValue", _);
189
+ }
190
+ const b = C(() => {
191
+ if (!f.modelValue) return null;
192
+ const i = f.modelValue;
193
+ return i.measurement ? y.value.find((_) => _.value === i.measurement) ?? null : y.value.find((_) => _.value === null) ?? null;
194
+ });
195
+ return (i, _) => {
196
+ const R = U("FmSwitch"), V = U("FmSelect"), F = U("FmCard");
197
+ return g(), D(F, {
198
+ variant: "outlined",
199
+ class: "p-16 flex flex-col gap-16"
200
+ }, {
201
+ default: S(() => {
202
+ var w, I;
203
+ return [
204
+ p(R, {
205
+ value: "",
206
+ "model-value": c.value,
207
+ "onUpdate:modelValue": _[0] || (_[0] = (z) => c.value = z),
208
+ label: u(o)("inventory.ingredient.convertible.title"),
209
+ sublabel: u(o)("inventory.ingredient.convertible.subtitle"),
210
+ labelPlacement: "right"
211
+ }, null, 8, ["model-value", "label", "sublabel"]),
212
+ c.value ? (g(), T(q, { key: 0 }, [
213
+ d("div", null, [
214
+ p(V, {
215
+ label: u(o)("inventory.ingredient.convertible.convertTo"),
216
+ modelValue: (w = b.value) == null ? void 0 : w.value,
217
+ "onUpdate:modelValue": h,
218
+ items: y.value
219
+ }, null, 8, ["label", "modelValue", "items"])
220
+ ]),
221
+ p(st, {
222
+ id: n.value,
223
+ "model-value": ((I = i.modelValue) == null ? void 0 : I.inventoryBindings) ?? [],
224
+ "onUpdate:modelValue": v,
225
+ "exclude-binding-id": n.value,
226
+ rules: [u(ge)(1)]
227
+ }, null, 8, ["id", "model-value", "exclude-binding-id", "rules"])
228
+ ], 64)) : O("", !0)
229
+ ];
230
+ }),
231
+ _: 1
232
+ });
233
+ };
234
+ }
235
+ });
236
+ function re() {
237
+ return {
238
+ low: 6,
239
+ mid: 14
240
+ };
241
+ }
242
+ const $t = { class: "flex gap-8" }, Et = { class: "flex-1" }, Rt = { class: "flex-1" }, At = { class: "text-fm-color-typo-secondary" }, Dt = { class: "text-fm-color-typo-secondary whitespace-nowrap" }, Tt = {
243
+ type: "button",
244
+ class: "inline-flex h-32 items-center"
245
+ }, Pt = {
246
+ key: 2,
247
+ class: "border-1 border-fm-color-neutral-gray-200 fm-corner-radius-lg flex flex-col p-16 gap-16"
248
+ }, Bt = { class: "flex flex-col gap-12" }, Lt = { class: "flex flex-col gap-4" }, Nt = { class: "fm-typo-en-title-sm-800" }, zt = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ht = { class: "flex flex-col gap-4" }, Ot = { class: "flex fm-corner-radius-md border-1 border-fm-color-neutral-gray-200" }, jt = { class: "flex-1 p-12 flex flex-col gap-8" }, Yt = { class: "mx-auto" }, Gt = { class: "flex flex-col" }, qt = { class: "fm-typo-en-body-sm-600 translate-y-4" }, Wt = { class: "flex-1 p-12 flex flex-col gap-8" }, Kt = { class: "mx-auto" }, Jt = { class: "flex flex-col" }, Qt = { class: "fm-typo-en-body-sm-600 translate-y-4" }, Xt = { class: "flex-1 p-12 flex flex-col gap-8" }, Zt = { class: "mx-auto" }, en = { class: "flex flex-col" }, tn = { class: "fm-typo-en-body-sm-600 translate-y-4" };
249
+ var Me = /* @__PURE__ */ ((r) => (r.Daily = "Daily", r.Consumables = "Consumables", r.ShortTerm = "Short term", r.Kitchen = "Kitchen", r))(Me || {});
250
+ const nn = /* @__PURE__ */ ae({
251
+ __name: "IngredientForm",
252
+ props: {
253
+ mode: {},
254
+ modelValue: {},
255
+ disabled: { type: Boolean }
256
+ },
257
+ emits: ["update:modelValue", "click:submit"],
258
+ setup(r, { expose: a, emit: f }) {
259
+ var X;
260
+ const { t: s } = ne(), n = r, l = f, o = te(), c = me(), y = qe();
261
+ function h(e) {
262
+ if (e.length === 0) return;
263
+ const t = e[0], m = n.modelValue ?? {
264
+ unit: o.units.find((x) => x)
265
+ };
266
+ m.unit || (m.unit = t, l("update:modelValue", m));
267
+ }
268
+ nt(() => {
269
+ h(o.units);
270
+ }), ze([() => o.units], ([e]) => {
271
+ h(e);
272
+ });
273
+ function v() {
274
+ l("click:submit");
275
+ }
276
+ const b = C({
277
+ get() {
278
+ var e;
279
+ return ((e = n.modelValue) == null ? void 0 : e.code) ?? "";
280
+ },
281
+ set(e) {
282
+ const t = n.modelValue ? {
283
+ ...n.modelValue
284
+ } : {};
285
+ t.code = e, l("update:modelValue", t);
286
+ }
287
+ }), i = C({
288
+ get() {
289
+ var e;
290
+ return ((e = n.modelValue) == null ? void 0 : e.name) ?? "";
291
+ },
292
+ set(e) {
293
+ const t = n.modelValue ? {
294
+ ...n.modelValue
295
+ } : {};
296
+ t.name = e, l("update:modelValue", t);
297
+ }
298
+ }), _ = C({
299
+ get() {
300
+ var t, m;
301
+ const e = (m = (t = n.modelValue) == null ? void 0 : t.defaultCost) == null ? void 0 : m.costPerUnit;
302
+ return e ? +Ye(e) : 0;
303
+ },
304
+ set(e) {
305
+ var m, x, $, M;
306
+ const t = n.modelValue ? {
307
+ ...n.modelValue
308
+ } : {};
309
+ t.defaultCost ?? (t.defaultCost = {
310
+ costPerUnit: {
311
+ amount: 0,
312
+ precision: 2,
313
+ currency: ((m = be(c.currentCountry.value)) == null ? void 0 : m.currency) ?? "MYR"
314
+ },
315
+ measurement: (M = ($ = (x = n.modelValue) == null ? void 0 : x.unit) == null ? void 0 : $.measurements) == null ? void 0 : M.find(
316
+ (G) => {
317
+ var Y;
318
+ return G.id === ((Y = n.modelValue) == null ? void 0 : Y.trackingMeasurement);
319
+ }
320
+ )
321
+ }), t.defaultCost.costPerUnit = {
322
+ ...t.defaultCost.costPerUnit,
323
+ ...Ge(+e, 4)
324
+ }, l("update:modelValue", t);
325
+ }
326
+ }), R = C(() => {
327
+ var t, m, x;
328
+ const e = ((t = n.modelValue) == null ? void 0 : t.unit) ?? o.units.find(($) => $);
329
+ return e ? {
330
+ _id: e._id,
331
+ measurement: (m = n.modelValue) == null ? void 0 : m.trackingMeasurement,
332
+ name: ((x = e.measurements.find(($) => {
333
+ var M;
334
+ return $.id === ((M = n.modelValue) == null ? void 0 : M.trackingMeasurement);
335
+ })) == null ? void 0 : x.name) ?? e.name
336
+ } : null;
337
+ }), V = C({
338
+ get() {
339
+ var e;
340
+ return ((e = n.modelValue) == null ? void 0 : e.operationalGroup) ?? null;
341
+ },
342
+ set(e) {
343
+ const t = n.modelValue ? {
344
+ ...n.modelValue
345
+ } : {};
346
+ t.operationalGroup = e, l("update:modelValue", t);
347
+ }
348
+ }), F = C(
349
+ () => [
350
+ ...new Set(
351
+ o.skus.map((e) => e.operationalGroup ?? "").filter((e) => e && !Object.values(Me).includes(e))
352
+ )
353
+ ].sort()
354
+ ), w = C({
355
+ get() {
356
+ return V.value !== null;
357
+ },
358
+ set(e) {
359
+ e ? V.value = "" : V.value = null;
360
+ }
361
+ }), I = C(
362
+ () => o.units.flatMap(({ name: e, _id: t, abbrev: m, measurements: x }) => [
363
+ {
364
+ label: `${e}`,
365
+ value: null,
366
+ displayAsSection: !0
367
+ },
368
+ {
369
+ label: `${e} (${m})`,
370
+ value: { _id: t },
371
+ displayAsSection: !1
372
+ },
373
+ ...x.map(({ id: $, name: M, abbrev: G }) => ({
374
+ label: `${M} (${G})`,
375
+ value: { _id: t, measurement: $ },
376
+ displayAsSection: !1
377
+ }))
378
+ ])
379
+ );
380
+ function z(e) {
381
+ var t, m, x, $, M;
382
+ return ((m = (t = n.modelValue) == null ? void 0 : t.unit) == null ? void 0 : m._id) === ((x = e.value) == null ? void 0 : x._id) && (($ = n.modelValue) == null ? void 0 : $.trackingMeasurement) === ((M = e.value) == null ? void 0 : M.measurement);
383
+ }
384
+ function se(e) {
385
+ var G, Y;
386
+ if (!e) return;
387
+ const { _id: t, measurement: m } = e, x = m || void 0, $ = o.units.find((le) => le._id === t);
388
+ if (!$)
389
+ return;
390
+ const M = n.modelValue ?? {};
391
+ M.unit = $, M.trackingMeasurement = x, M.convert && (M.convert.measurement = x || null), y.enableTotalCost && (M.defaultCost = {
392
+ measurement: $.measurements.find((le) => le.id === x),
393
+ costPerUnit: {
394
+ ...((G = M.defaultCost) == null ? void 0 : G.costPerUnit) ?? {
395
+ amount: 0,
396
+ precision: 2,
397
+ currency: ((Y = be(c.currentCountry.value)) == null ? void 0 : Y.currency) ?? "MYR"
398
+ }
399
+ }
400
+ }), l("update:modelValue", M);
401
+ }
402
+ const ce = C({
403
+ get() {
404
+ var e;
405
+ return ((e = n.modelValue) == null ? void 0 : e.convert) ?? null;
406
+ },
407
+ set(e) {
408
+ const t = n.modelValue ? {
409
+ ...n.modelValue
410
+ } : {};
411
+ e ? t.convert = e : t.convert = null, l("update:modelValue", t);
412
+ }
413
+ }), _e = C(() => de.options.filter(
414
+ (e) => e === de.enum.FIFO || e === de.enum.WAVG
415
+ ).map((e) => ({
416
+ label: s(`inventory.ingredient.valuationMethod.${e}`),
417
+ value: e
418
+ }))), pe = C({
419
+ get() {
420
+ var e;
421
+ return ((e = n.modelValue) == null ? void 0 : e.valuation) ?? "WAVG";
422
+ },
423
+ set(e) {
424
+ const t = n.modelValue ? {
425
+ ...n.modelValue
426
+ } : {};
427
+ t.valuation = e, l("update:modelValue", t);
428
+ }
429
+ }), J = N();
430
+ a({
431
+ validateInputs: () => {
432
+ var e, t;
433
+ (t = (e = J.value) == null ? void 0 : e.validateInputs) == null || t.call(e);
434
+ },
435
+ resetInputsValidation: () => {
436
+ var e, t;
437
+ (t = (e = J.value) == null ? void 0 : e.resetInputsValidation) == null || t.call(e);
438
+ },
439
+ resetInputs: () => {
440
+ var e, t;
441
+ (t = (e = J.value) == null ? void 0 : e.resetInputs) == null || t.call(e);
442
+ }
443
+ });
444
+ const W = N(!1), ve = C(
445
+ () => {
446
+ var e, t, m;
447
+ return (e = n.modelValue) != null && e._id ? ((m = o.menu.bindedBySkuId[(t = n.modelValue) == null ? void 0 : t._id]) == null ? void 0 : m.filter(
448
+ (x) => x.from === "INGREDIENT"
449
+ )) ?? [] : [];
450
+ }
451
+ ), A = C(
452
+ () => {
453
+ var e, t, m;
454
+ return (e = n.modelValue) != null && e._id ? ((m = o.menu.bindedBySkuId[(t = n.modelValue) == null ? void 0 : t._id]) == null ? void 0 : m.filter(
455
+ (x) => x.from === "RECIPE"
456
+ )) ?? [] : [];
457
+ }
458
+ ), E = C(
459
+ () => {
460
+ var e, t, m;
461
+ return (e = n.modelValue) != null && e._id ? ((m = o.menu.bindedBySkuId[(t = n.modelValue) == null ? void 0 : t._id]) == null ? void 0 : m.filter((x) => x.from === "MENU")) ?? [] : [];
462
+ }
463
+ ), ie = C(
464
+ () => o.skus.map((e) => ({ label: e.name, value: e.code }))
465
+ ), oe = N((X = n.modelValue) == null ? void 0 : X.code);
466
+ function ue(e) {
467
+ var m;
468
+ const t = e.el;
469
+ t && ((m = t.querySelector("[x-should-scroll-into=true]")) == null || m.scrollIntoView());
470
+ }
471
+ function P(e) {
472
+ switch (e) {
473
+ case Ve.MY:
474
+ return "MYR";
475
+ case Ve.SG:
476
+ return "SGD";
477
+ case Ve.ID:
478
+ return "IDR";
479
+ default:
480
+ return "MYR";
481
+ }
482
+ }
483
+ const H = C(
484
+ () => {
485
+ var e, t, m, x, $, M;
486
+ return ((x = (m = (t = (e = n.modelValue) == null ? void 0 : e.unit) == null ? void 0 : t.measurements) == null ? void 0 : m.find(
487
+ (G) => {
488
+ var Y;
489
+ return G.id === ((Y = n.modelValue) == null ? void 0 : Y.trackingMeasurement);
490
+ }
491
+ )) == null ? void 0 : x.abbrev) ?? ((M = ($ = n.modelValue) == null ? void 0 : $.unit) == null ? void 0 : M.abbrev);
492
+ }
493
+ ), Q = C({
494
+ get() {
495
+ var e, t;
496
+ return ((t = (e = n.modelValue) == null ? void 0 : e.thresholds) == null ? void 0 : t.low) ?? re().low;
497
+ },
498
+ set(e) {
499
+ var x;
500
+ const t = ((x = n.modelValue) == null ? void 0 : x.thresholds) ?? re();
501
+ t.low = e;
502
+ const m = n.modelValue ? {
503
+ ...n.modelValue
504
+ } : {};
505
+ m.thresholds = t, l("update:modelValue", m);
506
+ }
507
+ }), K = C({
508
+ get() {
509
+ var e, t;
510
+ return ((t = (e = n.modelValue) == null ? void 0 : e.thresholds) == null ? void 0 : t.mid) ?? re().mid;
511
+ },
512
+ set(e) {
513
+ var x;
514
+ const t = ((x = n.modelValue) == null ? void 0 : x.thresholds) ?? re();
515
+ t.mid = e;
516
+ const m = n.modelValue ? {
517
+ ...n.modelValue
518
+ } : {};
519
+ m.thresholds = t, l("update:modelValue", m);
520
+ }
521
+ });
522
+ function fe() {
523
+ return function(t) {
524
+ return typeof (t == null ? void 0 : t.low) != "number" || typeof (t == null ? void 0 : t.mid) != "number" ? "Required" : t.low >= t.mid ? "Days for red indicator should be less than yellow indicator." : !0;
525
+ };
526
+ }
527
+ return (e, t) => {
528
+ const m = U("FmTextField"), x = U("FmLabel"), $ = U("FmField"), M = U("FmMenuHeader"), G = U("FmMenuDivider"), Y = U("FmMenuItem"), le = U("FmMenu"), Ie = U("FmFormGroup"), Xe = U("FmSelect"), Ue = U("FmSwitch"), Ze = U("FmIcon"), et = U("FmCard"), $e = U("FmStepperField"), tt = U("FmForm");
529
+ return g(), D(tt, {
530
+ disabled: e.disabled,
531
+ ref_key: "formRef",
532
+ ref: J,
533
+ class: "flex flex-col gap-32",
534
+ onValidationSuccess: v
535
+ }, {
536
+ default: S(() => [
537
+ d("div", $t, [
538
+ d("div", Et, [
539
+ p(m, {
540
+ label: u(s)("inventory.ingredient.code"),
541
+ "model-value": b.value,
542
+ "onUpdate:modelValue": t[0] || (t[0] = (k) => b.value = k),
543
+ rules: [u(xe)(), u(it)(ie.value, oe.value)],
544
+ "label-mark": "required"
545
+ }, null, 8, ["label", "model-value", "rules"])
546
+ ]),
547
+ d("div", Rt, [
548
+ p(m, {
549
+ label: u(s)("inventory.ingredient.name"),
550
+ "model-value": i.value,
551
+ "onUpdate:modelValue": t[1] || (t[1] = (k) => i.value = k),
552
+ rules: [u(xe)()],
553
+ "label-mark": "required"
554
+ }, null, 8, ["label", "model-value", "rules"])
555
+ ])
556
+ ]),
557
+ p(Ie, {
558
+ "model-value": R.value,
559
+ rules: [u(xe)()],
560
+ "label-mark": "required"
561
+ }, {
562
+ label: S(() => [
563
+ p(x, {
564
+ label: u(s)("inventory.ingredient.unit")
565
+ }, null, 8, ["label"])
566
+ ]),
567
+ default: S(({ invalid: k }) => [
568
+ p(le, null, {
569
+ "menu-button": S(() => [
570
+ p($, {
571
+ class: Z([
572
+ "fm-typo-en-body-lg-400",
573
+ {
574
+ "text-fm-color-typo-primary": !e.disabled,
575
+ "text-fm-color-typo-disabled": e.disabled
576
+ }
577
+ ]),
578
+ invalid: k,
579
+ "append-icon": "expand_more"
580
+ }, {
581
+ default: S(() => {
582
+ var L;
583
+ return [
584
+ He(B((L = R.value) == null ? void 0 : L.name), 1)
585
+ ];
586
+ }),
587
+ _: 2
588
+ }, 1032, ["class", "invalid"])
589
+ ]),
590
+ default: S(() => [
591
+ d("div", {
592
+ class: "overflow-x-hidden overflow-y-auto max-h-[300px]",
593
+ onVnodeMounted: ue
594
+ }, [
595
+ (g(!0), T(q, null, ee(I.value, (L) => (g(), T(q, {
596
+ key: L.label
597
+ }, [
598
+ L.displayAsSection ? (g(), T(q, { key: 0 }, [
599
+ p(M, {
600
+ label: L.label
601
+ }, null, 8, ["label"]),
602
+ p(G)
603
+ ], 64)) : (g(), D(Y, {
604
+ key: 1,
605
+ label: L.label,
606
+ "model-value": z(L),
607
+ onClick: (Rn) => se(L.value),
608
+ "x-should-scroll-into": `${z(L)}`
609
+ }, null, 8, ["label", "model-value", "onClick", "x-should-scroll-into"]))
610
+ ], 64))), 128))
611
+ ], 512)
612
+ ]),
613
+ _: 2
614
+ }, 1024)
615
+ ]),
616
+ _: 1
617
+ }, 8, ["model-value", "rules"]),
618
+ u(y).enableTotalCost ? (g(), D(Xe, {
619
+ key: 0,
620
+ class: "col-span-1",
621
+ "model-value": pe.value,
622
+ "onUpdate:modelValue": t[2] || (t[2] = (k) => pe.value = k),
623
+ items: _e.value
624
+ }, {
625
+ label: S(() => [
626
+ p(Se, { "z-index": 50 }, {
627
+ default: S(() => [
628
+ p(x, {
629
+ label: u(s)("inventory.ingredient.valuationMethod.title")
630
+ }, null, 8, ["label"])
631
+ ]),
632
+ _: 1
633
+ })
634
+ ]),
635
+ _: 1
636
+ }, 8, ["model-value", "items"])) : O("", !0),
637
+ u(y).enableTotalCost ? (g(), D(m, {
638
+ key: 1,
639
+ "model-value": _.value,
640
+ "onUpdate:modelValue": t[3] || (t[3] = (k) => _.value = k),
641
+ rules: [u(ge)(0), u(ut)(4)]
642
+ }, {
643
+ label: S(() => [
644
+ p(Se, { "z-index": 50 }, {
645
+ default: S(() => [
646
+ p(x, {
647
+ label: u(s)("inventory.ingredient.pricePerUnit")
648
+ }, null, 8, ["label"])
649
+ ]),
650
+ _: 1
651
+ })
652
+ ]),
653
+ prepend: S(() => {
654
+ var k, L;
655
+ return [
656
+ d("div", At, B(P(((k = u(c).currentCountry) == null ? void 0 : k.value) ?? u(Ae)) === "MYR" ? "RM" : P(((L = u(c).currentCountry) == null ? void 0 : L.value) ?? u(Ae))), 1)
657
+ ];
658
+ }),
659
+ append: S(() => [
660
+ d("div", Dt, " / " + B(H.value), 1)
661
+ ]),
662
+ _: 1
663
+ }, 8, ["model-value", "rules"])) : O("", !0),
664
+ p(et, {
665
+ variant: "outlined",
666
+ class: "p-16 flex flex-col gap-16"
667
+ }, {
668
+ default: S(() => [
669
+ p(Ue, {
670
+ value: "",
671
+ "model-value": w.value,
672
+ "onUpdate:modelValue": t[4] || (t[4] = (k) => w.value = k),
673
+ label: u(s)("inventory.ingredient.operational.applyOperationalGroup"),
674
+ sublabel: u(s)("inventory.ingredient.operational.subtitle"),
675
+ labelPlacement: "right"
676
+ }, null, 8, ["model-value", "label", "sublabel"]),
677
+ w.value ? (g(), D(le, { key: 0 }, {
678
+ "menu-button": S(() => [
679
+ p(m, {
680
+ label: "Operational label",
681
+ modelValue: V.value,
682
+ "onUpdate:modelValue": t[5] || (t[5] = (k) => V.value = k),
683
+ placeholder: "Input text or select preset"
684
+ }, {
685
+ append: S(() => [
686
+ d("button", Tt, [
687
+ p(Ze, { name: "expand_more" })
688
+ ])
689
+ ]),
690
+ _: 1
691
+ }, 8, ["modelValue"])
692
+ ]),
693
+ default: S(() => [
694
+ p(M, { label: "Preset" }),
695
+ (g(!0), T(q, null, ee(Object.values(Me), (k) => (g(), D(Y, {
696
+ key: k,
697
+ label: k,
698
+ "model-value": V.value === k,
699
+ onClick: (L) => V.value = k
700
+ }, null, 8, ["label", "model-value", "onClick"]))), 128)),
701
+ F.value.length ? (g(), D(M, {
702
+ key: 0,
703
+ label: "Custom"
704
+ })) : O("", !0),
705
+ (g(!0), T(q, null, ee(F.value, (k) => (g(), D(Y, {
706
+ key: k,
707
+ label: k,
708
+ "model-value": V.value === k,
709
+ onClick: (L) => V.value = k
710
+ }, null, 8, ["label", "model-value", "onClick"]))), 128))
711
+ ]),
712
+ _: 1
713
+ })) : O("", !0)
714
+ ]),
715
+ _: 1
716
+ }),
717
+ p(Ut, {
718
+ "model-value": ce.value,
719
+ "onUpdate:modelValue": t[6] || (t[6] = (k) => ce.value = k),
720
+ "root-value": e.modelValue
721
+ }, null, 8, ["model-value", "root-value"]),
722
+ e.mode !== u(j).CREATE ? (g(), T("div", Pt, [
723
+ d("div", null, [
724
+ p(Ue, {
725
+ label: u(s)("inventory.ingredient.bindedItems.title"),
726
+ modelValue: W.value,
727
+ "onUpdate:modelValue": t[7] || (t[7] = (k) => W.value = k),
728
+ "label-placement": "right"
729
+ }, null, 8, ["label", "modelValue"])
730
+ ]),
731
+ W.value && ve.value.length ? (g(), D(we, {
732
+ key: 0,
733
+ name: u(s)("inventory.ingredient.bindedItems.ingredient"),
734
+ bindings: ve.value
735
+ }, null, 8, ["name", "bindings"])) : O("", !0),
736
+ W.value && A.value.length ? (g(), D(we, {
737
+ key: 1,
738
+ name: u(s)("inventory.ingredient.bindedItems.recipe"),
739
+ bindings: A.value
740
+ }, null, 8, ["name", "bindings"])) : O("", !0),
741
+ W.value && E.value.length ? (g(), D(we, {
742
+ key: 2,
743
+ name: u(s)("inventory.ingredient.bindedItems.menu"),
744
+ bindings: E.value
745
+ }, null, 8, ["name", "bindings"])) : O("", !0)
746
+ ])) : O("", !0),
747
+ d("div", Bt, [
748
+ d("div", Lt, [
749
+ p(Se, null, {
750
+ default: S(() => [
751
+ d("div", Nt, B(u(s)("inventory.ingredient.threshold.title")), 1)
752
+ ]),
753
+ _: 1
754
+ }),
755
+ d("div", zt, B(u(s)("inventory.ingredient.threshold.subtitle")), 1)
756
+ ]),
757
+ d("div", Ht, [
758
+ p(Ie, {
759
+ "model-value": { low: Q.value, mid: K.value },
760
+ rules: [fe()]
761
+ }, null, 8, ["model-value", "rules"]),
762
+ d("div", Ot, [
763
+ d("div", jt, [
764
+ d("div", Yt, [
765
+ p(ke, {
766
+ days: Q.value,
767
+ level: u(Ce).low
768
+ }, null, 8, ["days", "level"])
769
+ ]),
770
+ d("div", Gt, [
771
+ d("div", qt, B(u(s)("inventory.ingredient.threshold.whenRemaining")), 1),
772
+ p($e, {
773
+ modelValue: Q.value,
774
+ "onUpdate:modelValue": t[8] || (t[8] = (k) => Q.value = k),
775
+ rules: [u(ge)(0)]
776
+ }, {
777
+ append: S(() => t[10] || (t[10] = [
778
+ d("div", {
779
+ class: "text-fm-color-typo-secondary",
780
+ style: { "padding-right": "32px" }
781
+ }, "days", -1)
782
+ ])),
783
+ _: 1
784
+ }, 8, ["modelValue", "rules"])
785
+ ])
786
+ ]),
787
+ t[12] || (t[12] = d("div", {
788
+ class: "h-full bg-fm-color-neutral-gray-200 relative",
789
+ style: { width: "1px" }
790
+ }, [
791
+ d("div", {
792
+ class: "absolute bg-white",
793
+ style: { transform: "translate(-50%, -50%)", left: "50%", top: "24px" }
794
+ }, " < ")
795
+ ], -1)),
796
+ d("div", Wt, [
797
+ d("div", Kt, [
798
+ p(ke, {
799
+ days: K.value,
800
+ level: u(Ce).mid
801
+ }, null, 8, ["days", "level"])
802
+ ]),
803
+ d("div", Jt, [
804
+ d("div", Qt, B(u(s)("inventory.ingredient.threshold.whenRemaining")), 1),
805
+ p($e, {
806
+ modelValue: K.value,
807
+ "onUpdate:modelValue": t[9] || (t[9] = (k) => K.value = k),
808
+ rules: [u(ge)(0)]
809
+ }, {
810
+ append: S(() => t[11] || (t[11] = [
811
+ d("div", {
812
+ class: "text-fm-color-typo-secondary",
813
+ style: { "padding-right": "32px" }
814
+ }, "days", -1)
815
+ ])),
816
+ _: 1
817
+ }, 8, ["modelValue", "rules"])
818
+ ])
819
+ ]),
820
+ t[13] || (t[13] = d("div", {
821
+ class: "h-full bg-fm-color-neutral-gray-200 relative",
822
+ style: { width: "1px" }
823
+ }, [
824
+ d("div", {
825
+ class: "absolute bg-white",
826
+ style: { transform: "translate(-50%, -50%)", left: "50%", top: "24px" }
827
+ }, " < ")
828
+ ], -1)),
829
+ d("div", Xt, [
830
+ d("div", Zt, [
831
+ p(ke, {
832
+ days: K.value + 1,
833
+ level: u(Ce).high
834
+ }, null, 8, ["days", "level"])
835
+ ]),
836
+ d("div", en, [
837
+ d("div", tn, B(u(s)("inventory.ingredient.threshold.stockIsStaple")), 1)
838
+ ])
839
+ ])
840
+ ])
841
+ ])
842
+ ])
843
+ ]),
844
+ _: 1
845
+ }, 8, ["disabled"]);
846
+ };
847
+ }
848
+ }), on = { class: "flex gap-4" }, ln = /* @__PURE__ */ ae({
849
+ __name: "IngredientDialog",
850
+ props: {
851
+ show: { type: Boolean },
852
+ unit: {},
853
+ mode: { default: j.READ }
854
+ },
855
+ emits: ["update:show"],
856
+ setup(r) {
857
+ const a = r, f = te(), s = he(), { t: n } = ne(), l = Te(a, "show"), o = Te(a, "unit"), c = C(() => {
858
+ switch (a.mode) {
859
+ case j.READ:
860
+ return "";
861
+ case j.UPDATE:
862
+ return n("inventory.ingredient.update.title");
863
+ case j.CREATE:
864
+ return n("inventory.ingredient.create.title");
865
+ }
866
+ return "";
867
+ }), y = C(() => {
868
+ switch (a.mode) {
869
+ case j.READ:
870
+ return "";
871
+ case j.UPDATE:
872
+ return n("common.save");
873
+ case j.CREATE:
874
+ return n("common.add");
875
+ }
876
+ return "";
877
+ }), h = N(), v = N(!1);
878
+ async function b() {
879
+ v.value = !0;
880
+ try {
881
+ await f.createSku(o.value), l.value = !1, s.open({
882
+ title: n("inventory.common.success"),
883
+ message: n("inventory.ingredient.create.success", { name: o.value.name }),
884
+ type: "success"
885
+ });
886
+ } catch (V) {
887
+ V instanceof De || s.open({
888
+ title: n("inventory.ingredient.create.error.title"),
889
+ message: n("inventory.ingredient.create.error.message"),
890
+ type: "error"
891
+ });
892
+ } finally {
893
+ v.value = !1;
894
+ }
895
+ }
896
+ async function i() {
897
+ v.value = !0;
898
+ try {
899
+ await f.updateSku(o.value), v.value = !1, l.value = !1, s.open({
900
+ title: n("inventory.common.success"),
901
+ message: n("inventory.ingredient.update.success", { name: o.value.name }),
902
+ type: "success"
903
+ });
904
+ } catch (V) {
905
+ V instanceof De || s.open({
906
+ title: n("inventory.ingredient.update.error.title"),
907
+ message: n("inventory.ingredient.update.error.message"),
908
+ type: "error"
909
+ });
910
+ } finally {
911
+ v.value = !1;
912
+ }
913
+ }
914
+ function _() {
915
+ var V, F;
916
+ (F = (V = h.value) == null ? void 0 : V.validateInputs) == null || F.call(V);
917
+ }
918
+ function R() {
919
+ switch (a.mode) {
920
+ case j.READ:
921
+ return;
922
+ case j.UPDATE:
923
+ return i();
924
+ case j.CREATE:
925
+ return b();
926
+ }
927
+ }
928
+ return (V, F) => {
929
+ const w = U("FmButton"), I = U("FmSideSheet");
930
+ return g(), D(I, {
931
+ "model-value": u(l),
932
+ "onUpdate:modelValue": F[3] || (F[3] = (z) => Ee(l) ? l.value = z : null),
933
+ header: c.value,
934
+ "close-button": "",
935
+ "dismiss-away": "",
936
+ "max-width": 500
937
+ }, {
938
+ "side-sheet-footer": S(() => [
939
+ d("div", on, [
940
+ p(w, {
941
+ loading: v.value,
942
+ label: y.value,
943
+ onClick: _
944
+ }, null, 8, ["loading", "label"]),
945
+ p(w, {
946
+ disabled: v.value,
947
+ label: u(n)("common.close"),
948
+ variant: "tertiary",
949
+ onClick: F[2] || (F[2] = (z) => l.value = !1)
950
+ }, null, 8, ["disabled", "label"])
951
+ ])
952
+ ]),
953
+ default: S(() => [
954
+ p(nn, {
955
+ class: "w-full",
956
+ ref_key: "hasValidationExpose",
957
+ ref: h,
958
+ modelValue: u(o),
959
+ "onUpdate:modelValue": F[0] || (F[0] = (z) => Ee(o) ? o.value = z : null),
960
+ mode: V.mode,
961
+ disabled: v.value,
962
+ "onClick:submit": F[1] || (F[1] = (z) => R())
963
+ }, null, 8, ["modelValue", "mode", "disabled"])
964
+ ]),
965
+ _: 1
966
+ }, 8, ["model-value", "header"]);
967
+ };
968
+ }
969
+ });
970
+ function* rn(r) {
971
+ for (; ; )
972
+ yield r[Math.floor(Math.random() * r.length)];
973
+ }
974
+ function an(r = 4, a = rn("qwertyuiopasdfghjklzxcvbnm".split(""))) {
975
+ return Array.from({ length: r }).map(() => a.next().value).join("");
976
+ }
977
+ function sn() {
978
+ return `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${an()}`;
979
+ }
980
+ const un = {
981
+ _id: "",
982
+ name: "",
983
+ abbrev: "",
984
+ precision: 0,
985
+ measurements: []
986
+ };
987
+ function dn(r) {
988
+ var f, s, n, l, o;
989
+ return {
990
+ code: r.code,
991
+ name: r.name,
992
+ unit: ((f = r.unit.measurements.find((c) => c.id === r.trackingMeasurement)) == null ? void 0 : f.abbrev) ?? r.unit.abbrev,
993
+ baseUnit: r.unit.abbrev,
994
+ valuationMethod: r.valuation ?? "WAVG",
995
+ pricePerUnit: (s = r.defaultCost) != null && s.costPerUnit ? +Ye((n = r.defaultCost) == null ? void 0 : n.costPerUnit) : 0,
996
+ thresholdLow: ((l = r.thresholds) == null ? void 0 : l.low) ?? re().low,
997
+ thresholdMid: ((o = r.thresholds) == null ? void 0 : o.mid) ?? re().mid
998
+ };
999
+ }
1000
+ function Qe() {
1001
+ var n;
1002
+ const r = [
1003
+ {
1004
+ id: "code",
1005
+ name: "Code"
1006
+ },
1007
+ {
1008
+ id: "name",
1009
+ name: "Name"
1010
+ },
1011
+ {
1012
+ id: "unit",
1013
+ name: "Unit"
1014
+ },
1015
+ {
1016
+ id: "baseUnit",
1017
+ name: "Base unit"
1018
+ }
1019
+ ], a = qe(), f = me(), s = be(f.currentCountry.value);
1020
+ return a.enableTotalCost && r.push(
1021
+ {
1022
+ id: "valuationMethod",
1023
+ name: "Valuation method"
1024
+ },
1025
+ {
1026
+ id: "pricePerUnit",
1027
+ name: `Price per unit (${s == null ? void 0 : s.currency})`
1028
+ }
1029
+ ), ((n = f.currentBusiness.value) == null ? void 0 : n.menuVersion) === "v4" && r.push(
1030
+ {
1031
+ id: "thresholdLow",
1032
+ name: "Show RED when remaining"
1033
+ },
1034
+ {
1035
+ id: "thresholdMid",
1036
+ name: "Show YELLOW when remaining"
1037
+ }
1038
+ ), r;
1039
+ }
1040
+ function mn() {
1041
+ const a = te().skus.map(dn), s = me().currentBusiness.value, n = Qe(), l = [
1042
+ ["Business name:", s == null ? void 0 : s.name],
1043
+ ["Business ID:", s == null ? void 0 : s._id],
1044
+ ["Menu version", s == null ? void 0 : s.menuVersion],
1045
+ [],
1046
+ n.map((h) => h.name),
1047
+ ...a.map((h) => n.map((v) => h[v.id]))
1048
+ ], o = n.map((h) => `system:${h.id}`), c = Ke(l, o), y = `${s == null ? void 0 : s.name} ingredients (${dt(/* @__PURE__ */ new Date())}).xlsx`;
1049
+ return Je(c, y), y;
1050
+ }
1051
+ function cn() {
1052
+ const a = me().currentBusiness.value, f = Qe(), s = [
1053
+ ["Business name:", a == null ? void 0 : a.name],
1054
+ ["Business ID:", a == null ? void 0 : a._id],
1055
+ ["Menu version", a == null ? void 0 : a.menuVersion],
1056
+ [],
1057
+ f.map((c) => c.name)
1058
+ ], n = f.map((c) => `system:${c.id}`), l = Ke(s, n), o = "FeedMe ingredients template.xlsx";
1059
+ return Je(l, o), o;
1060
+ }
1061
+ function pn(r) {
1062
+ const [
1063
+ a,
1064
+ f,
1065
+ s,
1066
+ n,
1067
+ l,
1068
+ o,
1069
+ ...c
1070
+ ] = St(r);
1071
+ if (!a || !a.length || a.some((i) => i.length && !i.startsWith("system:")))
1072
+ throw new Error("Missing meta header. Excel file does not come from the template.");
1073
+ const y = a.map((i) => i.split(":")[1]), v = ["code", "name", "unit", "baseUnit"].filter((i) => !y.includes(i));
1074
+ if (v.length)
1075
+ throw new Error(
1076
+ `Missing meta headers (${v.join()}). Excel file does not come from the template.`
1077
+ );
1078
+ return c.map((i, _) => {
1079
+ const R = {};
1080
+ for (const V in y) {
1081
+ const F = y[V];
1082
+ Object.assign(R, { [F]: i[V] });
1083
+ }
1084
+ return {
1085
+ index: _,
1086
+ data: R
1087
+ };
1088
+ });
1089
+ }
1090
+ function Le(r, a, f) {
1091
+ var w;
1092
+ const n = te().units, l = new Array(), o = f.filter((I) => I.data.code === r.code);
1093
+ o.length > 1 && l.push(
1094
+ `Code ${r.code} is already used in row ${o.map((I) => I.index + 6).join()}.`
1095
+ );
1096
+ const c = n.find((I) => I.abbrev === r.baseUnit), y = c == null ? void 0 : c.measurements.find((I) => I.abbrev === r.unit);
1097
+ if (!c)
1098
+ l.push(`Cannot find base unit of symbol ${r.baseUnit}.`);
1099
+ else if (r.baseUnit !== r.unit && !y) {
1100
+ const I = `Cannot find unit conversion for ${r.baseUnit} with symbol ${r.unit || "[empty]"}.`;
1101
+ l.push(I);
1102
+ }
1103
+ const h = de.options.find(
1104
+ (I) => I === r.valuationMethod
1105
+ );
1106
+ r.valuationMethod && !h && l.push(
1107
+ `Expected valuation method to be one of ${de.options.join()} but got ${r.valuationMethod} instead.`
1108
+ );
1109
+ const b = me().currentCountry.value, i = (I) => `${I}`.length && ct()(I) === !0, _ = i(`${r.pricePerUnit}`) === !0 ? {
1110
+ costPerUnit: {
1111
+ ...Ge(Number(r.pricePerUnit) || 0),
1112
+ currency: ((w = be(b)) == null ? void 0 : w.currency) ?? "MYR"
1113
+ },
1114
+ measurement: y
1115
+ } : void 0, R = i(`${r.thresholdLow}`) && i(`${r.thresholdMid}`) ? {
1116
+ low: Number(r.thresholdLow) || 0,
1117
+ mid: Number(r.thresholdMid) || 0
1118
+ } : void 0;
1119
+ return {
1120
+ type: "create",
1121
+ sku: {
1122
+ _id: sn(),
1123
+ code: r.code,
1124
+ name: r.name,
1125
+ unit: c ?? n.find((I) => I) ?? un,
1126
+ trackingMeasurement: y == null ? void 0 : y.id,
1127
+ valuation: h,
1128
+ defaultCost: _,
1129
+ thresholds: R
1130
+ },
1131
+ errors: l,
1132
+ excelRowNumber: a + 6
1133
+ };
1134
+ }
1135
+ function vn(r) {
1136
+ try {
1137
+ const a = pn(r).filter((h) => h.data.code), s = te().skus, n = mt(s, "code"), l = a.filter((h) => !n[h.data.code]), o = a.filter((h) => n[h.data.code]), c = l.map(
1138
+ (h) => Le(h.data, h.index, a)
1139
+ ), y = o.map((h) => {
1140
+ const v = Le(h.data, h.index, a), b = n[h.data.code];
1141
+ return {
1142
+ ...v,
1143
+ type: "update",
1144
+ original: b,
1145
+ sku: {
1146
+ // to maintain original props not in the import excel, e.g. inventory binding, etc...
1147
+ ...b,
1148
+ code: v.sku.code || b.code,
1149
+ name: v.sku.name || b.name,
1150
+ unit: v.sku.unit || b.unit,
1151
+ trackingMeasurement: v.sku.trackingMeasurement || b.trackingMeasurement,
1152
+ valuation: v.sku.valuation || b.valuation,
1153
+ defaultCost: v.sku.defaultCost || b.defaultCost,
1154
+ thresholds: v.sku.thresholds || b.thresholds
1155
+ }
1156
+ };
1157
+ });
1158
+ return {
1159
+ invalidExcel: !1,
1160
+ importCreateResult: c,
1161
+ importUpdateResult: y
1162
+ };
1163
+ } catch (a) {
1164
+ return {
1165
+ invalidExcel: !0,
1166
+ invalidExcelMessage: (a == null ? void 0 : a.message) ?? "Invalid excel",
1167
+ importCreateResult: [],
1168
+ importUpdateResult: []
1169
+ };
1170
+ }
1171
+ }
1172
+ const fn = { class: "flex items-center gap-12 pl-8" }, yn = { class: "flex flex-col" }, gn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, bn = {
1173
+ key: 0,
1174
+ class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
1175
+ }, hn = { key: 0 }, Ne = /* @__PURE__ */ ae({
1176
+ __name: "ImportIngredientItem",
1177
+ props: {
1178
+ type: {},
1179
+ code: {},
1180
+ name: {},
1181
+ errors: {}
1182
+ },
1183
+ setup(r) {
1184
+ return (a, f) => {
1185
+ const s = U("FmIcon"), n = U("FmTooltip");
1186
+ return g(), T("div", fn, [
1187
+ f[0] || (f[0] = d("div", null, "•", -1)),
1188
+ d("div", yn, [
1189
+ d("div", gn, [
1190
+ d("div", {
1191
+ class: Z({
1192
+ "text-fm-color-system-error-300": a.errors.length
1193
+ })
1194
+ }, [
1195
+ He(B(a.name) + " ", 1),
1196
+ a.type === "create" ? (g(), T("span", bn, "(new)")) : O("", !0)
1197
+ ], 2),
1198
+ a.errors.length ? (g(), T("div", hn, [
1199
+ p(n, { "z-index": 50 }, {
1200
+ content: S(() => [
1201
+ d("ol", null, [
1202
+ (g(!0), T(q, null, ee(a.errors, (l, o) => (g(), T("li", { key: o }, B(l), 1))), 128))
1203
+ ])
1204
+ ]),
1205
+ default: S(() => [
1206
+ p(s, {
1207
+ name: "error",
1208
+ size: "sm",
1209
+ color: "system-error-300"
1210
+ })
1211
+ ]),
1212
+ _: 1
1213
+ })
1214
+ ])) : O("", !0)
1215
+ ]),
1216
+ d("div", {
1217
+ class: Z([
1218
+ "fm-typo-en-body-sm-400",
1219
+ {
1220
+ "text-fm-color-system-error-200": a.errors.length,
1221
+ "text-fm-color-typo-secondary": !a.errors.length
1222
+ }
1223
+ ])
1224
+ }, B(a.code), 3)
1225
+ ])
1226
+ ]);
1227
+ };
1228
+ }
1229
+ }), _n = { class: "flex flex-col gap-24" }, xn = { class: "fm-typo-en-body-md-400" }, Vn = { class: "flex flex-col gap-8" }, kn = { class: "line-clamp-2 text-ellipsis break-all" }, Cn = {
1230
+ key: 2,
1231
+ class: "shrink-0"
1232
+ }, wn = {
1233
+ key: 0,
1234
+ class: "flex flex-col"
1235
+ }, Sn = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, Fn = {
1236
+ key: 0,
1237
+ class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
1238
+ }, Mn = { class: "fm-typo-en-body-lg-600" }, In = /* @__PURE__ */ ae({
1239
+ __name: "ImportIngredients",
1240
+ setup(r) {
1241
+ const a = N(null), f = vt(), s = he(), n = N(!1), l = N(new Array()), o = N([]), c = N([]), y = C(
1242
+ () => !!l.value.length || o.value.some((i) => i.errors.length) || c.value.some((i) => i.errors.length)
1243
+ ), h = C(
1244
+ () => !!o.value.length || !!c.value.length
1245
+ ), { t: v } = ne();
1246
+ async function b(i) {
1247
+ l.value = [], o.value = [], c.value = [];
1248
+ try {
1249
+ n.value = !0;
1250
+ const [_] = await Promise.all([
1251
+ Ft(i),
1252
+ // fake buffer
1253
+ new Promise((F) => setTimeout(F, 1e3))
1254
+ ]), R = _.SheetNames.find((F) => F);
1255
+ if (!R) {
1256
+ l.value.push(v("inventory.ingredient.import.fileError.noSheet"));
1257
+ return;
1258
+ }
1259
+ const V = vn(_.Sheets[R]);
1260
+ if (V.invalidExcel) {
1261
+ l.value.push(V.invalidExcelMessage ?? v("inventory.ingredient.import.fileError.invalidExcel"));
1262
+ return;
1263
+ }
1264
+ if (o.value = V.importCreateResult, c.value = V.importUpdateResult, !o.value.length && !c.value.length) {
1265
+ l.value.push(v("inventory.ingredient.import.fileError.noData"));
1266
+ return;
1267
+ }
1268
+ f.emitData(V);
1269
+ } catch (_) {
1270
+ s.open({
1271
+ title: v("inventory.ingredient.import.fileError.unableToRead"),
1272
+ message: _ == null ? void 0 : _.message,
1273
+ type: "error"
1274
+ }), console.error("Error in reading file", _);
1275
+ } finally {
1276
+ l.value.length && s.open({
1277
+ title: v("inventory.ingredient.import.fileError.invalidExcel"),
1278
+ type: "error"
1279
+ }), n.value = !1;
1280
+ }
1281
+ }
1282
+ return ze(a, (i) => {
1283
+ i && b(i);
1284
+ }), (i, _) => {
1285
+ const R = U("FmCircularProgress"), V = U("FmIcon"), F = U("FmButton");
1286
+ return g(), T("div", _n, [
1287
+ d("div", xn, B(u(v)("inventory.ingredient.import.uploadDescription")), 1),
1288
+ p(Mt, {
1289
+ class: Z({
1290
+ "w-full": !0,
1291
+ "h-[200px]": !a.value
1292
+ }),
1293
+ accept: ".xlsx",
1294
+ onFileUpload: _[0] || (_[0] = (w) => a.value = w),
1295
+ label: u(v)("inventory.ingredient.import.uploadTemplate"),
1296
+ "button-label": u(v)("inventory.ingredient.import.selectFile")
1297
+ }, Oe({ _: 2 }, [
1298
+ a.value ? {
1299
+ name: "default",
1300
+ fn: S(({ openFileDialog: w }) => [
1301
+ d("div", Vn, [
1302
+ d("div", {
1303
+ class: Z([
1304
+ "fm-corner-radius-md p-16 flex items-center gap-16",
1305
+ {
1306
+ "border border-fm-color-neutral-gray-100": n.value,
1307
+ "border border-fm-color-neutral-gray-200": !n.value && !y.value,
1308
+ "border border-fm-color-system-error-200": y.value
1309
+ }
1310
+ ])
1311
+ }, [
1312
+ n.value ? (g(), D(R, {
1313
+ key: 0,
1314
+ size: "md",
1315
+ color: "neutral-gray-200"
1316
+ })) : (g(), D(V, {
1317
+ key: 1,
1318
+ name: y.value ? "error" : "attach_file",
1319
+ outline: "",
1320
+ color: y.value ? "system-error-300" : void 0
1321
+ }, null, 8, ["name", "color"])),
1322
+ d("div", {
1323
+ class: Z([
1324
+ "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
1325
+ {
1326
+ "text-fm-color-typo-disabled": n.value,
1327
+ "text-fm-color-typo-primary": !n.value
1328
+ }
1329
+ ])
1330
+ }, [
1331
+ d("div", kn, B(a.value.name), 1)
1332
+ ], 2),
1333
+ n.value ? O("", !0) : (g(), T("div", Cn, [
1334
+ p(F, {
1335
+ label: u(v)("inventory.ingredient.import.replaceFile"),
1336
+ variant: y.value ? "destructive" : "secondary",
1337
+ "prepend-icon": y.value ? void 0 : "autorenew",
1338
+ onClick: w
1339
+ }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
1340
+ ]))
1341
+ ], 2),
1342
+ l.value.length ? (g(), T("div", wn, [
1343
+ (g(!0), T(q, null, ee(l.value, (I, z) => (g(), T("div", {
1344
+ key: z,
1345
+ class: "flex gap-8 items-center"
1346
+ }, [
1347
+ p(V, {
1348
+ name: "error",
1349
+ size: "sm",
1350
+ color: "system-error-300"
1351
+ }),
1352
+ d("div", Sn, B(I), 1)
1353
+ ]))), 128))
1354
+ ])) : O("", !0)
1355
+ ])
1356
+ ]),
1357
+ key: "0"
1358
+ } : void 0
1359
+ ]), 1032, ["class", "label", "button-label"]),
1360
+ h.value ? (g(), T("div", Fn, [
1361
+ d("div", Mn, B(u(v)("inventory.ingredient.import.summary")), 1),
1362
+ (g(!0), T(q, null, ee(o.value, (w) => (g(), D(Ne, {
1363
+ key: w.sku._id,
1364
+ code: w.sku.code,
1365
+ name: w.sku.name,
1366
+ errors: w.errors,
1367
+ type: "create"
1368
+ }, null, 8, ["code", "name", "errors"]))), 128)),
1369
+ (g(!0), T(q, null, ee(c.value, (w) => (g(), D(Ne, {
1370
+ key: w.sku._id,
1371
+ code: w.sku.code,
1372
+ name: w.sku.name,
1373
+ errors: w.errors,
1374
+ type: "update"
1375
+ }, null, 8, ["code", "name", "errors"]))), 128))
1376
+ ])) : O("", !0)
1377
+ ]);
1378
+ };
1379
+ }
1380
+ }), Un = { class: "flex flex-col py-8" }, $n = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, En = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Wn = /* @__PURE__ */ ae({
1381
+ __name: "IngredientsView",
1382
+ setup(r) {
1383
+ const a = te(), f = C(() => a.skus), s = pt(), n = We(), l = he(), { t: o } = ne(), { createIngredient: c, updateIngredient: y } = Fe(), { ingredientDialogProps: h, ingredientViewLoading: v } = ht(Fe()), { columnDefs: b } = It();
1384
+ function i(A) {
1385
+ switch (A) {
1386
+ case "add":
1387
+ return c();
1388
+ case "import":
1389
+ return W();
1390
+ case "export":
1391
+ return J();
1392
+ }
1393
+ }
1394
+ const _ = N(""), R = N(!1), V = C(() => R.value || v.value), { breakpoints: F } = ft(), w = C(() => F.value.xs || F.value.sm), I = C(() => w.value ? 10 : 20), z = Vt(), se = N(!1), ce = [
1395
+ {
1396
+ value: "import",
1397
+ label: o("common.import")
1398
+ },
1399
+ {
1400
+ value: "export",
1401
+ label: o("common.export")
1402
+ }
1403
+ ];
1404
+ function _e(A) {
1405
+ switch (se.value = !1, A) {
1406
+ case "import":
1407
+ return W();
1408
+ case "export":
1409
+ return J();
1410
+ }
1411
+ }
1412
+ const pe = C(() => [
1413
+ {
1414
+ label: o("inventory.ingredient.create.title"),
1415
+ value: "add",
1416
+ isPrimary: !0,
1417
+ prependIcon: "add"
1418
+ },
1419
+ { label: o("common.import"), value: "import" },
1420
+ { label: o("common.export"), value: "export" }
1421
+ ]);
1422
+ function J() {
1423
+ const A = mn();
1424
+ l.open({
1425
+ title: o("inventory.ingredient.export.success"),
1426
+ message: o("inventory.ingredient.export.filename", [A]),
1427
+ type: "success"
1428
+ });
1429
+ }
1430
+ function W() {
1431
+ n.open({
1432
+ title: o("inventory.ingredient.import.title"),
1433
+ contentComponent: In,
1434
+ overlay: !0,
1435
+ closeButton: !0,
1436
+ primaryActions: {
1437
+ text: o("common.import"),
1438
+ close: !1
1439
+ },
1440
+ secondaryActions: {
1441
+ text: o("common.close"),
1442
+ close: !0
1443
+ },
1444
+ tertiaryActions: {
1445
+ text: o("inventory.ingredient.import.actions.downloadTemplate"),
1446
+ close: !1,
1447
+ variant: "plain"
1448
+ }
1449
+ }).onPrimary((A) => {
1450
+ if (!A) {
1451
+ l.open({
1452
+ title: o("inventory.ingredient.import.error.noData"),
1453
+ type: "error"
1454
+ });
1455
+ return;
1456
+ }
1457
+ if (!A.importCreateResult.length && !A.importUpdateResult.length) {
1458
+ l.open({
1459
+ title: o("inventory.ingredient.import.error.invalidContent"),
1460
+ message: o("inventory.ingredient.import.error.noImportData"),
1461
+ type: "error"
1462
+ });
1463
+ return;
1464
+ }
1465
+ if (A.importCreateResult.some((E) => E.errors.length) || A.importUpdateResult.some((E) => E.errors.length)) {
1466
+ l.open({
1467
+ title: o("inventory.ingredient.import.error.invalidContent"),
1468
+ message: o("inventory.ingredient.import.error.hasErrors"),
1469
+ type: "error"
1470
+ });
1471
+ return;
1472
+ }
1473
+ n.close(), ve(A);
1474
+ }).onTertiary(cn);
1475
+ }
1476
+ async function ve(A) {
1477
+ R.value = !0;
1478
+ try {
1479
+ const E = [
1480
+ ...A.importCreateResult.map(({ sku: P }) => ({ type: "create", sku: P })),
1481
+ ...A.importUpdateResult.map(({ sku: P }) => ({ type: "update", sku: P }))
1482
+ ], ie = 100;
1483
+ let oe = 0;
1484
+ const ue = () => {
1485
+ oe += ie, l.open({
1486
+ title: o("inventory.ingredient.import.progress", [
1487
+ Math.min(oe, E.length),
1488
+ E.length
1489
+ ])
1490
+ });
1491
+ };
1492
+ for (const P of E.chunk(100))
1493
+ ue(), await a.importSkus({
1494
+ create: P.filter((H) => H.type === "create").map((H) => H.sku),
1495
+ update: P.filter((H) => H.type === "update").map((H) => H.sku)
1496
+ });
1497
+ l.open({
1498
+ title: o("inventory.ingredient.import.success"),
1499
+ type: "success"
1500
+ });
1501
+ } catch (E) {
1502
+ l.open({
1503
+ title: o("inventory.ingredient.import.error.failed"),
1504
+ message: o("inventory.ingredient.import.error.systemMessage", [E == null ? void 0 : E.message]),
1505
+ type: "error"
1506
+ }), console.error("Error in importing skus", A, E);
1507
+ } finally {
1508
+ R.value = !1;
1509
+ }
1510
+ }
1511
+ return (A, E) => {
1512
+ const ie = U("FmTable"), oe = U("FmCollapsibleTabs"), ue = U("FmBottomSheet");
1513
+ return g(), D(kt, {
1514
+ title: u(o)("inventory.ingredient.title"),
1515
+ actions: pe.value,
1516
+ "onClick:action": i
1517
+ }, {
1518
+ default: S(() => [
1519
+ d("div", {
1520
+ class: Z([
1521
+ "flex flex-col gap-8 max-h-full",
1522
+ {
1523
+ "p-0": w.value,
1524
+ "px-24 ": !w.value
1525
+ }
1526
+ ])
1527
+ }, [
1528
+ p(Ct, {
1529
+ searchable: "",
1530
+ search: _.value,
1531
+ "onUpdate:search": E[0] || (E[0] = (P) => _.value = P)
1532
+ }, null, 8, ["search"]),
1533
+ p(ie, {
1534
+ style: ot(u(z).tableHeight),
1535
+ "column-defs": u(b),
1536
+ "row-data": f.value,
1537
+ "search-value": _.value,
1538
+ loading: !u(s)._currentLocation || V.value,
1539
+ "loading-text": "Loading",
1540
+ onRowClick: E[1] || (E[1] = (P) => u(y)(P.original)),
1541
+ "page-size": I.value
1542
+ }, {
1543
+ "list-row": S((P) => [
1544
+ p(xt, {
1545
+ row: P,
1546
+ onRowClick: u(y)
1547
+ }, Oe({
1548
+ default: S((H) => {
1549
+ var Q, K, fe, X, e, t, m, x, $, M;
1550
+ return [
1551
+ d("div", Un, [
1552
+ d("div", $n, [
1553
+ p(u(Be), {
1554
+ render: (fe = (K = (Q = H.code) == null ? void 0 : Q.column) == null ? void 0 : K.columnDef) == null ? void 0 : fe.cell,
1555
+ props: (e = (X = H.code) == null ? void 0 : X.getContext) == null ? void 0 : e.call(X)
1556
+ }, null, 8, ["render", "props"])
1557
+ ]),
1558
+ d("div", En, [
1559
+ p(u(Be), {
1560
+ render: (x = (m = (t = H.name) == null ? void 0 : t.column) == null ? void 0 : m.columnDef) == null ? void 0 : x.cell,
1561
+ props: (M = ($ = H.name) == null ? void 0 : $.getContext) == null ? void 0 : M.call($)
1562
+ }, null, 8, ["render", "props"])
1563
+ ])
1564
+ ])
1565
+ ];
1566
+ }),
1567
+ _: 2
1568
+ }, [
1569
+ R.value ? {
1570
+ name: "loading-text",
1571
+ fn: S(() => [
1572
+ d("div", null, B(u(o)("inventory.ingredient.table.importing")), 1)
1573
+ ]),
1574
+ key: "0"
1575
+ } : void 0
1576
+ ]), 1032, ["row", "onRowClick"])
1577
+ ]),
1578
+ _: 1
1579
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
1580
+ ], 2),
1581
+ (g(), D(Re, { to: "body" }, [
1582
+ p(ln, lt(rt(u(h))), null, 16)
1583
+ ])),
1584
+ (g(), D(Re, { to: "body" }, [
1585
+ p(ue, {
1586
+ "dismiss-away": "",
1587
+ modelValue: se.value,
1588
+ "onUpdate:modelValue": E[3] || (E[3] = (P) => se.value = P)
1589
+ }, {
1590
+ default: S(() => [
1591
+ p(oe, {
1592
+ class: "pb-8",
1593
+ items: ce,
1594
+ "onUpdate:modelValue": E[2] || (E[2] = (P) => _e(P))
1595
+ })
1596
+ ]),
1597
+ _: 1
1598
+ }, 8, ["modelValue"])
1599
+ ]))
1600
+ ]),
1601
+ _: 1
1602
+ }, 8, ["title", "actions"]);
1603
+ };
1604
+ }
1605
+ });
1606
+ export {
1607
+ Wn as default
1608
+ };