@feedmepos/mf-inventory-portal 0.0.17-dev.8 → 0.0.18-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 (63) hide show
  1. package/dist/ApprovalView-DyazMoIY.js +118 -0
  2. package/dist/{BindingsDialog-DS7lMkEA.js → BindingsDialog-D-p9eOMP.js} +2 -2
  3. package/dist/{BindingsPicker-Cy9WuCSS.js → BindingsPicker-C_kuxqQI.js} +2 -2
  4. package/dist/BindingsTable-jgL5-FZc.js +147 -0
  5. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DLc1nCIY.js +268 -0
  6. package/dist/{FmMultiselectDialog.vue_vue_type_script_setup_true_lang-BtovUKzb.js → FmMultiselectDialog.vue_vue_type_script_setup_true_lang-D2Cg0s16.js} +2 -2
  7. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-Bjc23m-U.js → FmUnitInput.vue_vue_type_script_setup_true_lang-FMI-Bp6y.js} +12 -12
  8. package/dist/{IngredientsView-D8xhcF7w.js → IngredientsView-DnIHe3Gj.js} +639 -629
  9. package/dist/{IntegrationView-C3zmrMpE.js → IntegrationView-CgYnK7JB.js} +260 -266
  10. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-svRwQNr1.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-BObjqgU-.js} +6 -6
  11. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-NtrraPyQ.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DClJGGeY.js} +1 -1
  12. package/dist/{PurchaseOrderPrintPreview-WSetqLLT.js → PurchaseOrderPrintPreview-Vbmche3y.js} +1 -1
  13. package/dist/ReceiveRequestView-CpRdJQuN.js +1394 -0
  14. package/dist/{RecipeView-95YCqNqL.js → RecipeView-Do3LgdfI.js} +182 -190
  15. package/dist/StockView-C16AHdmT.js +1862 -0
  16. package/dist/SupplierView-DGQXU4Ha.js +796 -0
  17. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-Dw94RCtz.js → TransferDetails.vue_vue_type_script_setup_true_lang-DK5gzjwS.js} +21 -20
  18. package/dist/{UnitView-BsqSIZug.js → UnitView-AfEMV9Qr.js} +129 -133
  19. package/dist/{WarehouseView-Op_5Qk3F.js → WarehouseView-Cph8wrcF.js} +260 -264
  20. package/dist/api/inventory.d.ts +3 -0
  21. package/dist/app-UpgZo4xX.js +66113 -0
  22. package/dist/app.js +1 -1
  23. package/dist/array-AvWd53LI.js +30 -0
  24. package/dist/components/FmInventoryTableToolbar.vue.d.ts +53 -0
  25. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +1 -0
  26. package/dist/components/shell/inventory/binding-ui.vue.d.ts +1 -0
  27. package/dist/date2-BfOl_Gio.js +95 -0
  28. package/dist/dayjs.min-r5rPIQFX.js +282 -0
  29. package/dist/{decimal-Db6V5YuK.js → decimal-CTa5OWKK.js} +1 -1
  30. package/dist/extensions/array.d.ts +1 -0
  31. package/dist/{fuzzy-W0aq7cB9.js → fuzzy-0FMA9raY.js} +1 -1
  32. package/dist/{dayjs.min-uQtxxLfb.js → index-D9a9wXgJ.js} +3627 -3377
  33. package/dist/{layout-DJ9o2NRD.js → layout-DxcK0DGS.js} +1 -1
  34. package/dist/number-BSqhQaRy.js +97 -0
  35. package/dist/{rules-CkxtFlBm.js → rules-7WxBNkDE.js} +16 -15
  36. package/dist/stock-estimate-hfECAKZK.js +122 -0
  37. package/dist/stores/inventory.d.ts +4 -0
  38. package/dist/{supplier-CCKg4iLI.js → supplier-Dg3f6Ybw.js} +1 -1
  39. package/dist/tsconfig.app.tsbuildinfo +1 -1
  40. package/dist/{use-inventory-binding-dialog-CMw2fESH.js → use-inventory-binding-dialog-NLy01qAo.js} +2 -2
  41. package/dist/views/ingredients/IngredientsView.vue.d.ts +1 -0
  42. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +2 -0
  43. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +1 -0
  44. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +5 -0
  45. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +4 -0
  46. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +12 -0
  47. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +4 -2
  48. package/dist/views/stock/helper/compute-summary-total.d.ts +2 -2
  49. package/dist/{xlsx-DZh41VsU.js → xlsx-qSY56eID.js} +1 -1
  50. package/dist/{xlsx.util-CiVxc4oN.js → xlsx.util-DL8p0Kzi.js} +2 -2
  51. package/package.json +5 -4
  52. package/dist/ApprovalView-aWF8FbAj.js +0 -134
  53. package/dist/BindingsTable-Dp5U_jYF.js +0 -121
  54. package/dist/ChangeLocationComponent.vue_vue_type_script_setup_true_lang-BY83bHSG.js +0 -97
  55. package/dist/ReceiveRequestView-VEZl69h8.js +0 -1435
  56. package/dist/SingleColumnLayout.vue_vue_type_script_setup_true_lang-Dov3Uq2z.js +0 -64
  57. package/dist/StockView-Ca9rtp7i.js +0 -1960
  58. package/dist/SupplierView-CHW93HW1.js +0 -804
  59. package/dist/app-BShd7PJF.js +0 -42889
  60. package/dist/components/FmTableToolbar.vue.d.ts +0 -49
  61. package/dist/date2-Cj6ya-vU.js +0 -189
  62. package/dist/init-date-range-D4tmP_jf.js +0 -21
  63. package/dist/stock-estimate-kcRPsgG_.js +0 -145
@@ -1,40 +1,42 @@
1
- import { ref as T, defineComponent as oe, computed as F, resolveComponent as M, openBlock as g, createBlock as B, withCtx as $, createVNode as y, createElementBlock as E, Fragment as Z, createElementVNode as u, createCommentVNode as W, onMounted as Ge, watch as Te, unref as w, normalizeClass as G, createTextVNode as Pe, toDisplayString as q, renderList as ce, isRef as we, renderSlot as ve, createSlots as qe, normalizeStyle as Ke, Teleport as Me, normalizeProps as Je, guardReactiveProps as Qe } from "vue";
2
- import { u as ne, c as Be, S as Xe, g as ge, F as J, d as Ie, a as Le, C as _e, b as $e, e as Ze, _ as et, f as tt } from "./app-BShd7PJF.js";
3
- import { useDialog as ze, useSnackbar as be, useProxiedModel as Re, useDialogChild as ot, useBreakpoints as nt } from "@feedmepos/ui-library";
1
+ import { ref as P, defineComponent as oe, computed as k, resolveComponent as $, openBlock as g, createBlock as B, withCtx as I, createVNode as y, createElementBlock as E, Fragment as ee, createElementVNode as u, createCommentVNode as z, onMounted as qe, watch as Pe, unref as w, normalizeClass as K, createTextVNode as Te, toDisplayString as G, renderList as me, isRef as we, renderSlot as ve, createSlots as Be, normalizeStyle as Ke, Teleport as Me, normalizeProps as Je, guardReactiveProps as Qe } from "vue";
2
+ import { u as ne, c as Le, S as Xe, g as ge, F as Q, d as $e, a as ze, C as be, b as Ie, e as Ze, _ as et, f as tt } from "./app-UpgZo4xX.js";
3
+ import { useDialog as Ne, useSnackbar as he, useProxiedModel as Ue, useDialogChild as ot, useBreakpoints as nt } from "@feedmepos/ui-library";
4
4
  import { i as lt, _ as at } from "./is-linked-ingredient-error-C6AghEwR.js";
5
- import { F as Y, D as Ue, R as ye } from "./row-action.enum-BwQbURNh.js";
6
- import { c as st, _ as rt, F as Ee, u as it } from "./layout-DJ9o2NRD.js";
7
- import { _ as ut } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-Dov3Uq2z.js";
8
- import { R as xe, U as dt, A as Ve, M as ct, I as mt } from "./rules-CkxtFlBm.js";
9
- import { g as pt, _ as ke, S as Fe } from "./StockForecast.vue_vue_type_style_index_0_lang-B5EK101t.js";
10
- import { _ as ft } from "./InventoryBindingForm.vue_vue_type_script_setup_true_lang-svRwQNr1.js";
11
- import { _ as Ce, t as Ne, d as Oe, s as vt, r as yt } from "./xlsx.util-CiVxc4oN.js";
12
- import { a as He, t as je, f as gt } from "./date2-Cj6ya-vU.js";
13
- import { useCoreStore as me } from "@feedmepos/mf-common";
14
- import { _ as Se } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-BvadeWUz.js";
5
+ import { F as W, D as Re, R as ye } from "./row-action.enum-BwQbURNh.js";
6
+ import { c as st, _ as rt, F as Ee, u as it } from "./layout-DxcK0DGS.js";
7
+ import { _ as ut, a as dt } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DLc1nCIY.js";
8
+ import { R as _e, U as ct, A as xe, M as mt, I as pt } from "./rules-7WxBNkDE.js";
9
+ import { g as ft, _ as Ve, S as ke } from "./StockForecast.vue_vue_type_style_index_0_lang-B5EK101t.js";
10
+ import { _ as vt } from "./InventoryBindingForm.vue_vue_type_script_setup_true_lang-BObjqgU-.js";
11
+ import { _ as Fe, t as Oe, d as He, s as yt, r as gt } from "./xlsx.util-DL8p0Kzi.js";
12
+ import { a as je, t as Ye } from "./number-BSqhQaRy.js";
13
+ import { useCoreStore as pe } from "@feedmepos/mf-common";
14
+ import { _ as Ce } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-BvadeWUz.js";
15
+ import { f as ht } from "./date2-BfOl_Gio.js";
16
+ import "./array-AvWd53LI.js";
15
17
  function bt() {
16
- const r = ze(), a = be(), p = ne(), o = T(!1), n = T();
18
+ const r = Ne(), a = he(), p = ne(), o = P(!1), n = P();
17
19
  function l() {
18
20
  const i = {
19
21
  unit: {},
20
- mode: Y.CREATE,
22
+ mode: W.CREATE,
21
23
  show: !0,
22
- "onUpdate:show"(h) {
23
- n.value.show = h;
24
+ "onUpdate:show"(b) {
25
+ n.value.show = b;
24
26
  }
25
27
  };
26
28
  n.value = i;
27
29
  }
28
30
  async function d(i) {
29
- const h = {
30
- unit: Be(i),
31
- mode: Y.UPDATE,
31
+ const b = {
32
+ unit: Le(i),
33
+ mode: W.UPDATE,
32
34
  show: !0,
33
35
  "onUpdate:show"(c) {
34
36
  n.value.show = c;
35
37
  }
36
38
  };
37
- n.value = h;
39
+ n.value = b;
38
40
  }
39
41
  async function v(i) {
40
42
  o.value = !0;
@@ -44,23 +46,23 @@ function bt() {
44
46
  message: `Deleted ${i.name}`,
45
47
  type: "success"
46
48
  });
47
- } catch (h) {
48
- h instanceof Xe && lt(h) ? r.open({
49
+ } catch (b) {
50
+ b instanceof Xe && lt(b) ? r.open({
49
51
  title: "Cannot delete ingredient",
50
52
  contentComponent: at,
51
53
  contentComponentProps: {
52
54
  subject: (i == null ? void 0 : i.name) ?? "",
53
- items: h.errorResponse.message
55
+ items: b.errorResponse.message
54
56
  },
55
57
  secondaryActions: {
56
58
  text: "Close",
57
59
  close: !0
58
60
  }
59
- }) : console.log("unable to delete ingredient", h), a.open({
61
+ }) : console.log("unable to delete ingredient", b), a.open({
60
62
  title: `Cannot delete ${i.name}`,
61
63
  message: "Please try again.",
62
64
  type: "error"
63
- }), console.error("failed to delete ingredient", h);
65
+ }), console.error("failed to delete ingredient", b);
64
66
  } finally {
65
67
  o.value = !1;
66
68
  }
@@ -89,12 +91,12 @@ function bt() {
89
91
  ingredientViewLoading: o
90
92
  };
91
93
  }
92
- function ht({
94
+ function _t({
93
95
  updateIngredient: r,
94
96
  deleteIngredient: a
95
97
  }) {
96
98
  async function p(n, l) {
97
- const d = Be(l);
99
+ const d = Le(l);
98
100
  if (n === ye.Edit) {
99
101
  await r(d);
100
102
  return;
@@ -138,7 +140,7 @@ function ht({
138
140
  header: "",
139
141
  cell(n) {
140
142
  return st(
141
- [Ue[ye.Edit], Ue[ye.Delete]],
143
+ [Re[ye.Edit], Re[ye.Delete]],
142
144
  (l) => {
143
145
  p(l, n.row.original);
144
146
  }
@@ -153,7 +155,7 @@ function ht({
153
155
  }
154
156
  ] };
155
157
  }
156
- const _t = /* @__PURE__ */ oe({
158
+ const xt = /* @__PURE__ */ oe({
157
159
  __name: "ConvertForm",
158
160
  props: {
159
161
  modelValue: {},
@@ -162,13 +164,13 @@ const _t = /* @__PURE__ */ oe({
162
164
  },
163
165
  emits: ["update:modelValue"],
164
166
  setup(r, { emit: a }) {
165
- const p = r, o = F(() => {
167
+ const p = r, o = k(() => {
166
168
  var c;
167
169
  return (c = p.rootValue) == null ? void 0 : c.unit;
168
- }), n = F(() => {
170
+ }), n = k(() => {
169
171
  var c;
170
172
  return (c = p.rootValue) == null ? void 0 : c._id;
171
- }), l = a, d = F({
173
+ }), l = a, d = k({
172
174
  get() {
173
175
  return !!p.modelValue;
174
176
  },
@@ -178,7 +180,7 @@ const _t = /* @__PURE__ */ oe({
178
180
  inventoryBindings: []
179
181
  }) : l("update:modelValue", null);
180
182
  }
181
- }), v = F(() => pt(o.value));
183
+ }), v = k(() => ft(o.value));
182
184
  function _(c) {
183
185
  const f = p.modelValue ?? {};
184
186
  f.measurement = c ? `${c}` : null, l("update:modelValue", f);
@@ -187,44 +189,44 @@ const _t = /* @__PURE__ */ oe({
187
189
  const f = p.modelValue ?? {};
188
190
  f.inventoryBindings = c, l("update:modelValue", f);
189
191
  }
190
- const h = F(() => {
192
+ const b = k(() => {
191
193
  if (!p.modelValue) return null;
192
194
  const c = p.modelValue;
193
195
  return c.measurement ? v.value.find((f) => f.value === c.measurement) ?? null : v.value.find((f) => f.value === null) ?? null;
194
196
  });
195
197
  return (c, f) => {
196
- const A = M("FmSwitch"), V = M("FmSelect"), C = M("FmCard");
197
- return g(), B(C, {
198
+ const D = $("FmSwitch"), x = $("FmSelect"), F = $("FmCard");
199
+ return g(), B(F, {
198
200
  variant: "outlined",
199
201
  class: "p-16 flex flex-col gap-16"
200
202
  }, {
201
- default: $(() => {
202
- var S, P;
203
+ default: I(() => {
204
+ var C, T;
203
205
  return [
204
- y(A, {
206
+ y(D, {
205
207
  value: "",
206
208
  "model-value": d.value,
207
- "onUpdate:modelValue": f[0] || (f[0] = (k) => d.value = k),
209
+ "onUpdate:modelValue": f[0] || (f[0] = (V) => d.value = V),
208
210
  label: "Convertible",
209
211
  sublabel: "Convertible from other recipe or ingredients",
210
212
  labelPlacement: "right"
211
213
  }, null, 8, ["model-value"]),
212
- d.value ? (g(), E(Z, { key: 0 }, [
214
+ d.value ? (g(), E(ee, { key: 0 }, [
213
215
  u("div", null, [
214
- y(V, {
216
+ y(x, {
215
217
  label: "Recipes and ingredients convert to",
216
- modelValue: (S = h.value) == null ? void 0 : S.value,
218
+ modelValue: (C = b.value) == null ? void 0 : C.value,
217
219
  "onUpdate:modelValue": _,
218
220
  items: v.value
219
221
  }, null, 8, ["modelValue", "items"])
220
222
  ]),
221
- y(ft, {
223
+ y(vt, {
222
224
  id: n.value,
223
- "model-value": ((P = c.modelValue) == null ? void 0 : P.inventoryBindings) ?? [],
225
+ "model-value": ((T = c.modelValue) == null ? void 0 : T.inventoryBindings) ?? [],
224
226
  "onUpdate:modelValue": i,
225
227
  "exclude-binding-id": n.value
226
228
  }, null, 8, ["id", "model-value", "exclude-binding-id"])
227
- ], 64)) : W("", !0)
229
+ ], 64)) : z("", !0)
228
230
  ];
229
231
  }),
230
232
  _: 1
@@ -232,16 +234,16 @@ const _t = /* @__PURE__ */ oe({
232
234
  };
233
235
  }
234
236
  });
235
- function re() {
237
+ function ue() {
236
238
  return {
237
239
  low: 6,
238
240
  mid: 14
239
241
  };
240
242
  }
241
- const xt = { class: "text-fm-color-typo-secondary" }, Vt = { class: "text-fm-color-typo-secondary whitespace-nowrap" }, kt = { class: "col-span-2 mt-16" }, Ft = {
242
- key: 1,
243
+ const Vt = { class: "text-fm-color-typo-secondary" }, kt = { class: "text-fm-color-typo-secondary whitespace-nowrap" }, Ft = { class: "col-span-2 mt-16" }, Ct = {
244
+ key: 2,
243
245
  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"
244
- }, Ct = { class: "col-span-2 flex flex-col gap-12" }, St = { class: "flex flex-col gap-4" }, wt = /* @__PURE__ */ u("div", { class: "fm-typo-en-title-sm-800" }, "Alert threshold", -1), Mt = /* @__PURE__ */ u("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Configure threshold for days remaining indicator in the stock balance page. ", -1), It = { class: "col-span-2 flex flex-col gap-4" }, $t = { class: "flex fm-corner-radius-md border-1 border-fm-color-neutral-gray-200" }, Rt = { class: "flex-1 p-12 flex flex-col gap-8" }, Ut = { class: "mx-auto" }, Et = { class: "flex flex-col" }, At = /* @__PURE__ */ u("div", { class: "fm-typo-en-body-sm-600 translate-y-4" }, "When remaining", -1), Dt = /* @__PURE__ */ u("div", {
246
+ }, St = { class: "col-span-2 flex flex-col gap-12" }, wt = { class: "flex flex-col gap-4" }, Mt = /* @__PURE__ */ u("div", { class: "fm-typo-en-title-sm-800" }, "Alert threshold", -1), $t = /* @__PURE__ */ u("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Configure threshold for days remaining indicator in the stock balance page. ", -1), It = { class: "col-span-2 flex flex-col gap-4" }, Ut = { class: "flex fm-corner-radius-md border-1 border-fm-color-neutral-gray-200" }, Rt = { class: "flex-1 p-12 flex flex-col gap-8" }, Et = { class: "mx-auto" }, Dt = { class: "flex flex-col" }, At = /* @__PURE__ */ u("div", { class: "fm-typo-en-body-sm-600 translate-y-4" }, "When remaining", -1), Pt = /* @__PURE__ */ u("div", {
245
247
  class: "text-fm-color-typo-secondary",
246
248
  style: { "padding-right": "32px" }
247
249
  }, "days", -1), Tt = /* @__PURE__ */ u("div", {
@@ -252,10 +254,10 @@ const xt = { class: "text-fm-color-typo-secondary" }, Vt = { class: "text-fm-col
252
254
  class: "absolute bg-white",
253
255
  style: { transform: "translate(-50%, -50%)", left: "50%", top: "20%" }
254
256
  }, " < ")
255
- ], -1), Pt = { class: "flex-1 p-12 flex flex-col gap-8" }, Bt = { class: "mx-auto" }, Lt = { class: "flex flex-col" }, zt = /* @__PURE__ */ u("div", { class: "fm-typo-en-body-sm-600 translate-y-4" }, "When remaining", -1), Nt = /* @__PURE__ */ u("div", {
257
+ ], -1), Bt = { class: "flex-1 p-12 flex flex-col gap-8" }, Lt = { class: "mx-auto" }, zt = { class: "flex flex-col" }, Nt = /* @__PURE__ */ u("div", { class: "fm-typo-en-body-sm-600 translate-y-4" }, "When remaining", -1), Ot = /* @__PURE__ */ u("div", {
256
258
  class: "text-fm-color-typo-secondary",
257
259
  style: { "padding-right": "32px" }
258
- }, "days", -1), Ot = /* @__PURE__ */ u("div", {
260
+ }, "days", -1), Ht = /* @__PURE__ */ u("div", {
259
261
  class: "h-full bg-fm-color-neutral-gray-200 relative",
260
262
  style: { width: "1px" }
261
263
  }, [
@@ -263,9 +265,9 @@ const xt = { class: "text-fm-color-typo-secondary" }, Vt = { class: "text-fm-col
263
265
  class: "absolute bg-white",
264
266
  style: { transform: "translate(-50%, -50%)", left: "50%", top: "20%" }
265
267
  }, " < ")
266
- ], -1), Ht = { class: "flex-1 p-12 flex flex-col gap-8" }, jt = { class: "mx-auto" }, Yt = /* @__PURE__ */ u("div", { class: "flex flex-col" }, [
268
+ ], -1), jt = { class: "flex-1 p-12 flex flex-col gap-8" }, Yt = { class: "mx-auto" }, Wt = /* @__PURE__ */ u("div", { class: "flex flex-col" }, [
267
269
  /* @__PURE__ */ u("div", { class: "fm-typo-en-body-sm-600 translate-y-4" }, "Stock is staple")
268
- ], -1), Wt = /* @__PURE__ */ oe({
270
+ ], -1), Gt = /* @__PURE__ */ oe({
269
271
  __name: "IngredientForm",
270
272
  props: {
271
273
  mode: {},
@@ -274,356 +276,340 @@ const xt = { class: "text-fm-color-typo-secondary" }, Vt = { class: "text-fm-col
274
276
  },
275
277
  emits: ["update:modelValue", "click:submit"],
276
278
  setup(r, { expose: a, emit: p }) {
277
- var pe;
278
- const o = r, n = p, l = ne(), d = me(), v = Le();
279
- function _(t) {
280
- if (t.length === 0) return;
281
- const e = t[0], m = o.modelValue ?? {
282
- unit: l.units.find((b) => b)
279
+ var re;
280
+ const o = r, n = p, l = ne(), d = pe(), v = ze();
281
+ function _(e) {
282
+ if (e.length === 0) return;
283
+ const t = e[0], m = o.modelValue ?? {
284
+ unit: l.units.find((h) => h)
283
285
  };
284
- m.unit || (m.unit = e, n("update:modelValue", m));
286
+ m.unit || (m.unit = t, n("update:modelValue", m));
285
287
  }
286
- Ge(() => {
288
+ qe(() => {
287
289
  _(l.units);
288
- }), Te([() => l.units], ([t]) => {
289
- _(t);
290
+ }), Pe([() => l.units], ([e]) => {
291
+ _(e);
290
292
  });
291
293
  function i() {
292
294
  n("click:submit");
293
295
  }
294
- const h = F({
296
+ const b = k({
295
297
  get() {
296
- var t;
297
- return ((t = o.modelValue) == null ? void 0 : t.code) ?? "";
298
+ var e;
299
+ return ((e = o.modelValue) == null ? void 0 : e.code) ?? "";
298
300
  },
299
- set(t) {
300
- const e = o.modelValue ? {
301
+ set(e) {
302
+ const t = o.modelValue ? {
301
303
  ...o.modelValue
302
304
  } : {};
303
- e.code = t, n("update:modelValue", e);
305
+ t.code = e, n("update:modelValue", t);
304
306
  }
305
- }), c = F({
307
+ }), c = k({
306
308
  get() {
307
- var t;
308
- return ((t = o.modelValue) == null ? void 0 : t.name) ?? "";
309
+ var e;
310
+ return ((e = o.modelValue) == null ? void 0 : e.name) ?? "";
309
311
  },
310
- set(t) {
311
- const e = o.modelValue ? {
312
+ set(e) {
313
+ const t = o.modelValue ? {
312
314
  ...o.modelValue
313
315
  } : {};
314
- e.name = t, n("update:modelValue", e);
316
+ t.name = e, n("update:modelValue", t);
315
317
  }
316
- }), f = F({
318
+ }), f = k({
317
319
  get() {
318
- var e, m;
319
- const t = (m = (e = o.modelValue) == null ? void 0 : e.defaultCost) == null ? void 0 : m.costPerUnit;
320
- return t ? +He(t) : 0;
320
+ var t, m;
321
+ const e = (m = (t = o.modelValue) == null ? void 0 : t.defaultCost) == null ? void 0 : m.costPerUnit;
322
+ return e ? +je(e) : 0;
321
323
  },
322
- set(t) {
323
- var m, b, U, I;
324
- const e = o.modelValue ? {
324
+ set(e) {
325
+ var m, h, R, S;
326
+ const t = o.modelValue ? {
325
327
  ...o.modelValue
326
328
  } : {};
327
- e.defaultCost ?? (e.defaultCost = {
329
+ t.defaultCost ?? (t.defaultCost = {
328
330
  costPerUnit: {
329
331
  amount: 0,
330
332
  precision: 2,
331
333
  currency: ((m = ge(d.currentCountry.value)) == null ? void 0 : m.currency) ?? "MYR"
332
334
  },
333
- measurement: (I = (U = (b = o.modelValue) == null ? void 0 : b.unit) == null ? void 0 : U.measurements) == null ? void 0 : I.find(
334
- (L) => {
335
- var H;
336
- return L.id === ((H = o.modelValue) == null ? void 0 : H.trackingMeasurement);
335
+ measurement: (S = (R = (h = o.modelValue) == null ? void 0 : h.unit) == null ? void 0 : R.measurements) == null ? void 0 : S.find(
336
+ (H) => {
337
+ var j;
338
+ return H.id === ((j = o.modelValue) == null ? void 0 : j.trackingMeasurement);
337
339
  }
338
340
  )
339
- }), e.defaultCost.costPerUnit = {
340
- ...e.defaultCost.costPerUnit,
341
- ...je(+t, 4)
342
- }, n("update:modelValue", e);
341
+ }), t.defaultCost.costPerUnit = {
342
+ ...t.defaultCost.costPerUnit,
343
+ ...Ye(+e, 4)
344
+ }, n("update:modelValue", t);
343
345
  }
344
- }), A = F(() => {
345
- var e, m, b;
346
- const t = ((e = o.modelValue) == null ? void 0 : e.unit) ?? l.units.find((U) => U);
347
- return t ? {
348
- _id: t._id,
346
+ }), D = k(() => {
347
+ var t, m, h;
348
+ const e = ((t = o.modelValue) == null ? void 0 : t.unit) ?? l.units.find((R) => R);
349
+ return e ? {
350
+ _id: e._id,
349
351
  measurement: (m = o.modelValue) == null ? void 0 : m.trackingMeasurement,
350
- name: ((b = t.measurements.find((U) => {
351
- var I;
352
- return U.id === ((I = o.modelValue) == null ? void 0 : I.trackingMeasurement);
353
- })) == null ? void 0 : b.name) ?? t.name
352
+ name: ((h = e.measurements.find((R) => {
353
+ var S;
354
+ return R.id === ((S = o.modelValue) == null ? void 0 : S.trackingMeasurement);
355
+ })) == null ? void 0 : h.name) ?? e.name
354
356
  } : null;
355
- }), V = F(
356
- () => l.units.flatMap(({ name: t, _id: e, abbrev: m, measurements: b }) => [
357
+ }), x = k(
358
+ () => l.units.flatMap(({ name: e, _id: t, abbrev: m, measurements: h }) => [
357
359
  {
358
- label: `${t}`,
360
+ label: `${e}`,
359
361
  value: null,
360
362
  displayAsSection: !0
361
363
  },
362
364
  {
363
- label: `${t} (${m})`,
364
- value: { _id: e },
365
+ label: `${e} (${m})`,
366
+ value: { _id: t },
365
367
  displayAsSection: !1
366
368
  },
367
- ...b.map(({ id: U, name: I, abbrev: L }) => ({
368
- label: `${I} (${L})`,
369
- value: { _id: e, measurement: U },
369
+ ...h.map(({ id: R, name: S, abbrev: H }) => ({
370
+ label: `${S} (${H})`,
371
+ value: { _id: t, measurement: R },
370
372
  displayAsSection: !1
371
373
  }))
372
374
  ])
373
375
  );
374
- function C(t) {
375
- var e, m, b, U, I;
376
- return ((m = (e = o.modelValue) == null ? void 0 : e.unit) == null ? void 0 : m._id) === ((b = t.value) == null ? void 0 : b._id) && ((U = o.modelValue) == null ? void 0 : U.trackingMeasurement) === ((I = t.value) == null ? void 0 : I.measurement);
376
+ function F(e) {
377
+ var t, m, h, R, S;
378
+ return ((m = (t = o.modelValue) == null ? void 0 : t.unit) == null ? void 0 : m._id) === ((h = e.value) == null ? void 0 : h._id) && ((R = o.modelValue) == null ? void 0 : R.trackingMeasurement) === ((S = e.value) == null ? void 0 : S.measurement);
377
379
  }
378
- function S(t) {
379
- var L, H;
380
- if (!t) return;
381
- const { _id: e, measurement: m } = t, b = m || void 0, U = l.units.find((X) => X._id === e);
382
- if (!U)
380
+ function C(e) {
381
+ var H, j;
382
+ if (!e) return;
383
+ const { _id: t, measurement: m } = e, h = m || void 0, R = l.units.find((Z) => Z._id === t);
384
+ if (!R)
383
385
  return;
384
- const I = o.modelValue ?? {};
385
- I.unit = U, I.trackingMeasurement = b, I.convert && (I.convert.measurement = b || null), v.enableTotalCost && (I.defaultCost = {
386
- measurement: U.measurements.find((X) => X.id === b),
386
+ const S = o.modelValue ?? {};
387
+ S.unit = R, S.trackingMeasurement = h, S.convert && (S.convert.measurement = h || null), v.enableTotalCost && (S.defaultCost = {
388
+ measurement: R.measurements.find((Z) => Z.id === h),
387
389
  costPerUnit: {
388
- ...((L = I.defaultCost) == null ? void 0 : L.costPerUnit) ?? {
390
+ ...((H = S.defaultCost) == null ? void 0 : H.costPerUnit) ?? {
389
391
  amount: 0,
390
392
  precision: 2,
391
- currency: ((H = ge(d.currentCountry.value)) == null ? void 0 : H.currency) ?? "MYR"
393
+ currency: ((j = ge(d.currentCountry.value)) == null ? void 0 : j.currency) ?? "MYR"
392
394
  }
393
395
  }
394
- }), n("update:modelValue", I);
396
+ }), n("update:modelValue", S);
395
397
  }
396
- const P = F({
398
+ const T = k({
397
399
  get() {
398
- var t;
399
- return ((t = o.modelValue) == null ? void 0 : t.convert) ?? null;
400
+ var e;
401
+ return ((e = o.modelValue) == null ? void 0 : e.convert) ?? null;
400
402
  },
401
- set(t) {
402
- const e = o.modelValue ? {
403
+ set(e) {
404
+ const t = o.modelValue ? {
403
405
  ...o.modelValue
404
406
  } : {};
405
- t ? e.convert = t : e.convert = null, n("update:modelValue", e);
407
+ e ? t.convert = e : t.convert = null, n("update:modelValue", t);
406
408
  }
407
- }), k = F(() => J.options.filter(
408
- (t) => t === J.enum.FIFO || t === J.enum.WAVG
409
- ).map((t) => {
410
- function e(m) {
409
+ }), V = k(() => Q.options.filter(
410
+ (e) => e === Q.enum.FIFO || e === Q.enum.WAVG
411
+ ).map((e) => {
412
+ function t(m) {
411
413
  switch (m) {
412
- case J.enum.WAVG:
414
+ case Q.enum.WAVG:
413
415
  return "Weighted Average (WAVG)";
414
- case J.enum.FIFO:
416
+ case Q.enum.FIFO:
415
417
  return "First In First Out (FIFO)";
416
- case J.enum.LIFO:
418
+ case Q.enum.LIFO:
417
419
  return "Last In First Out (LIFO)";
418
- case J.enum.FEFO:
420
+ case Q.enum.FEFO:
419
421
  return "First Expired First Out (FEFO)";
420
422
  }
421
423
  return "";
422
424
  }
423
425
  return {
424
- label: e(t),
425
- value: t
426
+ label: t(e),
427
+ value: e
426
428
  };
427
- })), le = F({
429
+ })), le = k({
428
430
  get() {
429
- var t;
430
- return ((t = o.modelValue) == null ? void 0 : t.valuation) ?? "WAVG";
431
+ var e;
432
+ return ((e = o.modelValue) == null ? void 0 : e.valuation) ?? "WAVG";
431
433
  },
432
- set(t) {
433
- const e = o.modelValue ? {
434
+ set(e) {
435
+ const t = o.modelValue ? {
434
436
  ...o.modelValue
435
437
  } : {};
436
- e.valuation = t, n("update:modelValue", e);
438
+ t.valuation = e, n("update:modelValue", t);
437
439
  }
438
- }), O = T();
440
+ }), N = P();
439
441
  a({
440
442
  validateInputs: () => {
441
- var t, e;
442
- (e = (t = O.value) == null ? void 0 : t.validateInputs) == null || e.call(t);
443
+ var e, t;
444
+ (t = (e = N.value) == null ? void 0 : e.validateInputs) == null || t.call(e);
443
445
  },
444
446
  resetInputsValidation: () => {
445
- var t, e;
446
- (e = (t = O.value) == null ? void 0 : t.resetInputsValidation) == null || e.call(t);
447
+ var e, t;
448
+ (t = (e = N.value) == null ? void 0 : e.resetInputsValidation) == null || t.call(e);
447
449
  },
448
450
  resetInputs: () => {
449
- var t, e;
450
- (e = (t = O.value) == null ? void 0 : t.resetInputs) == null || e.call(t);
451
+ var e, t;
452
+ (t = (e = N.value) == null ? void 0 : e.resetInputs) == null || t.call(e);
451
453
  }
452
454
  });
453
- const K = T(!1), ae = F(
455
+ const q = P(!1), ae = k(
454
456
  () => {
455
- var t, e, m;
456
- return (t = o.modelValue) != null && t._id ? ((m = l.menu.bindedBySkuId[(e = o.modelValue) == null ? void 0 : e._id]) == null ? void 0 : m.filter(
457
- (b) => b.from === "INGREDIENT"
457
+ var e, t, m;
458
+ return (e = o.modelValue) != null && e._id ? ((m = l.menu.bindedBySkuId[(t = o.modelValue) == null ? void 0 : t._id]) == null ? void 0 : m.filter(
459
+ (h) => h.from === "INGREDIENT"
458
460
  )) ?? [] : [];
459
461
  }
460
- ), Q = F(
462
+ ), X = k(
461
463
  () => {
462
- var t, e, m;
463
- return (t = o.modelValue) != null && t._id ? ((m = l.menu.bindedBySkuId[(e = o.modelValue) == null ? void 0 : e._id]) == null ? void 0 : m.filter(
464
- (b) => b.from === "RECIPE"
464
+ var e, t, m;
465
+ return (e = o.modelValue) != null && e._id ? ((m = l.menu.bindedBySkuId[(t = o.modelValue) == null ? void 0 : t._id]) == null ? void 0 : m.filter(
466
+ (h) => h.from === "RECIPE"
465
467
  )) ?? [] : [];
466
468
  }
467
- ), s = F(
469
+ ), s = k(
468
470
  () => {
469
- var t, e, m;
470
- return (t = o.modelValue) != null && t._id ? ((m = l.menu.bindedBySkuId[(e = o.modelValue) == null ? void 0 : e._id]) == null ? void 0 : m.filter((b) => b.from === "MENU")) ?? [] : [];
471
+ var e, t, m;
472
+ return (e = o.modelValue) != null && e._id ? ((m = l.menu.bindedBySkuId[(t = o.modelValue) == null ? void 0 : t._id]) == null ? void 0 : m.filter((h) => h.from === "MENU")) ?? [] : [];
471
473
  }
472
- ), z = F(
473
- () => l.skus.map((t) => ({ label: t.name, value: t.code }))
474
- ), N = T((pe = o.modelValue) == null ? void 0 : pe.code);
475
- function ie(t) {
474
+ ), L = k(
475
+ () => l.skus.map((e) => ({ label: e.name, value: e.code }))
476
+ ), O = P((re = o.modelValue) == null ? void 0 : re.code);
477
+ function de(e) {
476
478
  var m;
477
- const e = t.el;
478
- e && ((m = e.querySelector("[x-should-scroll-into=true]")) == null || m.scrollIntoView());
479
+ const t = e.el;
480
+ t && ((m = t.querySelector("[x-should-scroll-into=true]")) == null || m.scrollIntoView());
479
481
  }
480
- function ee(t) {
481
- switch (t) {
482
- case _e.MY:
482
+ function te(e) {
483
+ switch (e) {
484
+ case be.MY:
483
485
  return "MYR";
484
- case _e.SG:
486
+ case be.SG:
485
487
  return "SGD";
486
- case _e.ID:
488
+ case be.ID:
487
489
  return "IDR";
488
490
  default:
489
491
  return "MYR";
490
492
  }
491
493
  }
492
- const R = F(
494
+ const U = k(
493
495
  () => {
494
- var t, e, m, b, U, I;
495
- return ((b = (m = (e = (t = o.modelValue) == null ? void 0 : t.unit) == null ? void 0 : e.measurements) == null ? void 0 : m.find(
496
- (L) => {
497
- var H;
498
- return L.id === ((H = o.modelValue) == null ? void 0 : H.trackingMeasurement);
496
+ var e, t, m, h, R, S;
497
+ return ((h = (m = (t = (e = o.modelValue) == null ? void 0 : e.unit) == null ? void 0 : t.measurements) == null ? void 0 : m.find(
498
+ (H) => {
499
+ var j;
500
+ return H.id === ((j = o.modelValue) == null ? void 0 : j.trackingMeasurement);
499
501
  }
500
- )) == null ? void 0 : b.abbrev) ?? ((I = (U = o.modelValue) == null ? void 0 : U.unit) == null ? void 0 : I.abbrev);
502
+ )) == null ? void 0 : h.abbrev) ?? ((S = (R = o.modelValue) == null ? void 0 : R.unit) == null ? void 0 : S.abbrev);
501
503
  }
502
- ), x = F({
504
+ ), M = k({
503
505
  get() {
504
- var t, e;
505
- return ((e = (t = o.modelValue) == null ? void 0 : t.thresholds) == null ? void 0 : e.low) ?? re().low;
506
+ var e, t;
507
+ return ((t = (e = o.modelValue) == null ? void 0 : e.thresholds) == null ? void 0 : t.low) ?? ue().low;
506
508
  },
507
- set(t) {
508
- var b;
509
- const e = ((b = o.modelValue) == null ? void 0 : b.thresholds) ?? re();
510
- e.low = t;
509
+ set(e) {
510
+ var h;
511
+ const t = ((h = o.modelValue) == null ? void 0 : h.thresholds) ?? ue();
512
+ t.low = e;
511
513
  const m = o.modelValue ? {
512
514
  ...o.modelValue
513
515
  } : {};
514
- m.thresholds = e, n("update:modelValue", m);
516
+ m.thresholds = t, n("update:modelValue", m);
515
517
  }
516
- }), te = F({
518
+ }), J = k({
517
519
  get() {
518
- var t, e;
519
- return ((e = (t = o.modelValue) == null ? void 0 : t.thresholds) == null ? void 0 : e.mid) ?? re().mid;
520
+ var e, t;
521
+ return ((t = (e = o.modelValue) == null ? void 0 : e.thresholds) == null ? void 0 : t.mid) ?? ue().mid;
520
522
  },
521
- set(t) {
522
- var b;
523
- const e = ((b = o.modelValue) == null ? void 0 : b.thresholds) ?? re();
524
- e.mid = t;
523
+ set(e) {
524
+ var h;
525
+ const t = ((h = o.modelValue) == null ? void 0 : h.thresholds) ?? ue();
526
+ t.mid = e;
525
527
  const m = o.modelValue ? {
526
528
  ...o.modelValue
527
529
  } : {};
528
- m.thresholds = e, n("update:modelValue", m);
530
+ m.thresholds = t, n("update:modelValue", m);
529
531
  }
530
532
  });
531
- function he() {
532
- return function(e) {
533
- return typeof (e == null ? void 0 : e.low) != "number" || typeof (e == null ? void 0 : e.mid) != "number" ? "Required" : e.low >= e.mid ? "Days for red indicator should be less than yellow indicator." : !0;
533
+ function se() {
534
+ return function(t) {
535
+ 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;
534
536
  };
535
537
  }
536
- return (t, e) => {
537
- const m = M("FmTextField"), b = M("FmLabel"), U = M("FmSelect"), I = M("FmField"), L = M("FmMenuHeader"), H = M("FmMenuDivider"), X = M("FmMenuItem"), fe = M("FmMenu"), ue = M("FmFormGroup"), se = M("FmSwitch"), de = M("FmStepperField"), We = M("FmForm");
538
- return g(), B(We, {
539
- disabled: t.disabled,
538
+ return (e, t) => {
539
+ const m = $("FmTextField"), h = $("FmLabel"), R = $("FmField"), S = $("FmMenuHeader"), H = $("FmMenuDivider"), j = $("FmMenuItem"), Z = $("FmMenu"), ce = $("FmFormGroup"), ie = $("FmSelect"), fe = $("FmSwitch"), Se = $("FmStepperField"), Ge = $("FmForm");
540
+ return g(), B(Ge, {
541
+ disabled: e.disabled,
540
542
  ref_key: "formRef",
541
- ref: O,
543
+ ref: N,
542
544
  class: "grid grid-cols-2 gap-24",
543
545
  onValidationSuccess: i
544
546
  }, {
545
- default: $(() => [
547
+ default: I(() => [
546
548
  y(m, {
547
549
  label: "Code",
548
- "model-value": h.value,
549
- "onUpdate:modelValue": e[0] || (e[0] = (D) => h.value = D),
550
- rules: [w(xe)(), w(dt)(z.value, N.value)],
550
+ "model-value": b.value,
551
+ "onUpdate:modelValue": t[0] || (t[0] = (A) => b.value = A),
552
+ rules: [w(_e)(), w(ct)(L.value, O.value)],
551
553
  "label-mark": "required"
552
554
  }, null, 8, ["model-value", "rules"]),
553
555
  y(m, {
554
556
  label: "Name",
555
557
  "model-value": c.value,
556
- "onUpdate:modelValue": e[1] || (e[1] = (D) => c.value = D),
557
- rules: [w(xe)()],
558
+ "onUpdate:modelValue": t[1] || (t[1] = (A) => c.value = A),
559
+ rules: [w(_e)()],
558
560
  "label-mark": "required"
559
561
  }, null, 8, ["model-value", "rules"]),
560
- y(U, {
562
+ y(ce, {
561
563
  class: "col-span-2",
562
- "model-value": le.value,
563
- "onUpdate:modelValue": e[2] || (e[2] = (D) => le.value = D),
564
- items: k.value
565
- }, {
566
- label: $(() => [
567
- y(Se, { "z-index": 50 }, {
568
- default: $(() => [
569
- y(b, { label: "Valuation Method" })
570
- ]),
571
- _: 1
572
- })
573
- ]),
574
- _: 1
575
- }, 8, ["model-value", "items"]),
576
- y(ue, {
577
- class: G([w(v).enableTotalCost ? "col-span-1" : "col-span-2"]),
578
- "model-value": A.value,
579
- rules: [w(xe)()],
564
+ "model-value": D.value,
565
+ rules: [w(_e)()],
580
566
  "label-mark": "required"
581
567
  }, {
582
- label: $(() => [
583
- y(b, { label: "Unit" })
568
+ label: I(() => [
569
+ y(h, { label: "Unit" })
584
570
  ]),
585
- default: $(({ invalid: D }) => [
586
- y(fe, null, {
587
- "menu-button": $(() => [
588
- y(I, {
589
- class: G([
571
+ default: I(({ invalid: A }) => [
572
+ y(Z, null, {
573
+ "menu-button": I(() => [
574
+ y(R, {
575
+ class: K([
590
576
  "fm-typo-en-body-lg-400",
591
577
  {
592
- "text-fm-color-typo-primary": !t.disabled,
593
- "text-fm-color-typo-disabled": t.disabled
578
+ "text-fm-color-typo-primary": !e.disabled,
579
+ "text-fm-color-typo-disabled": e.disabled
594
580
  }
595
581
  ]),
596
- invalid: D,
582
+ invalid: A,
597
583
  "append-icon": "expand_more"
598
584
  }, {
599
- default: $(() => {
600
- var j;
585
+ default: I(() => {
586
+ var Y;
601
587
  return [
602
- Pe(q((j = A.value) == null ? void 0 : j.name), 1)
588
+ Te(G((Y = D.value) == null ? void 0 : Y.name), 1)
603
589
  ];
604
590
  }),
605
591
  _: 2
606
592
  }, 1032, ["class", "invalid"])
607
593
  ]),
608
- default: $(() => [
594
+ default: I(() => [
609
595
  u("div", {
610
596
  class: "overflow-x-hidden overflow-y-auto max-h-[300px]",
611
- onVnodeMounted: ie
597
+ onVnodeMounted: de
612
598
  }, [
613
- (g(!0), E(Z, null, ce(V.value, (j) => (g(), E(Z, {
614
- key: j.label
599
+ (g(!0), E(ee, null, me(x.value, (Y) => (g(), E(ee, {
600
+ key: Y.label
615
601
  }, [
616
- j.displayAsSection ? (g(), E(Z, { key: 0 }, [
617
- y(L, {
618
- label: j.label
602
+ Y.displayAsSection ? (g(), E(ee, { key: 0 }, [
603
+ y(S, {
604
+ label: Y.label
619
605
  }, null, 8, ["label"]),
620
606
  y(H)
621
- ], 64)) : (g(), B(X, {
607
+ ], 64)) : (g(), B(j, {
622
608
  key: 1,
623
- label: j.label,
624
- "model-value": C(j),
625
- onClick: (Eo) => S(j.value),
626
- "x-should-scroll-into": `${C(j)}`
609
+ label: Y.label,
610
+ "model-value": F(Y),
611
+ onClick: (Eo) => C(Y.value),
612
+ "x-should-scroll-into": `${F(Y)}`
627
613
  }, null, 8, ["label", "model-value", "onClick", "x-should-scroll-into"]))
628
614
  ], 64))), 128))
629
615
  ], 512)
@@ -632,132 +618,149 @@ const xt = { class: "text-fm-color-typo-secondary" }, Vt = { class: "text-fm-col
632
618
  }, 1024)
633
619
  ]),
634
620
  _: 1
635
- }, 8, ["class", "model-value", "rules"]),
636
- w(v).enableTotalCost ? (g(), B(m, {
621
+ }, 8, ["model-value", "rules"]),
622
+ w(v).enableTotalCost ? (g(), B(ie, {
637
623
  key: 0,
624
+ class: "col-span-1",
625
+ "model-value": le.value,
626
+ "onUpdate:modelValue": t[2] || (t[2] = (A) => le.value = A),
627
+ items: V.value
628
+ }, {
629
+ label: I(() => [
630
+ y(Ce, { "z-index": 50 }, {
631
+ default: I(() => [
632
+ y(h, { label: "Valuation Method" })
633
+ ]),
634
+ _: 1
635
+ })
636
+ ]),
637
+ _: 1
638
+ }, 8, ["model-value", "items"])) : z("", !0),
639
+ w(v).enableTotalCost ? (g(), B(m, {
640
+ key: 1,
638
641
  "model-value": f.value,
639
- "onUpdate:modelValue": e[3] || (e[3] = (D) => f.value = D),
640
- rules: [w(Ve)(0), w(ct)(2)]
642
+ "onUpdate:modelValue": t[3] || (t[3] = (A) => f.value = A),
643
+ rules: [w(xe)(0), w(mt)(2)]
641
644
  }, {
642
- label: $(() => [
643
- y(Se, { "z-index": 50 }, {
644
- default: $(() => [
645
- y(b, { label: "Price per unit" })
645
+ label: I(() => [
646
+ y(Ce, { "z-index": 50 }, {
647
+ default: I(() => [
648
+ y(h, { label: "Price per unit" })
646
649
  ]),
647
650
  _: 1
648
651
  })
649
652
  ]),
650
- prepend: $(() => {
651
- var D, j;
653
+ prepend: I(() => {
654
+ var A, Y;
652
655
  return [
653
- u("div", xt, q(ee(((D = w(d).currentCountry) == null ? void 0 : D.value) ?? w(Ie)) === "MYR" ? "RM" : ee(((j = w(d).currentCountry) == null ? void 0 : j.value) ?? w(Ie))), 1)
656
+ u("div", Vt, G(te(((A = w(d).currentCountry) == null ? void 0 : A.value) ?? w($e)) === "MYR" ? "RM" : te(((Y = w(d).currentCountry) == null ? void 0 : Y.value) ?? w($e))), 1)
654
657
  ];
655
658
  }),
656
- append: $(() => [
657
- u("div", Vt, " / " + q(R.value), 1)
659
+ append: I(() => [
660
+ u("div", kt, " / " + G(U.value), 1)
658
661
  ]),
659
662
  _: 1
660
- }, 8, ["model-value", "rules"])) : W("", !0),
661
- u("div", kt, [
662
- y(_t, {
663
- "model-value": P.value,
664
- "onUpdate:modelValue": e[4] || (e[4] = (D) => P.value = D),
665
- "root-value": t.modelValue
663
+ }, 8, ["model-value", "rules"])) : z("", !0),
664
+ u("div", Ft, [
665
+ y(xt, {
666
+ "model-value": T.value,
667
+ "onUpdate:modelValue": t[4] || (t[4] = (A) => T.value = A),
668
+ "root-value": e.modelValue
666
669
  }, null, 8, ["model-value", "root-value"])
667
670
  ]),
668
- t.mode !== w(Y).CREATE ? (g(), E("div", Ft, [
671
+ e.mode !== w(W).CREATE ? (g(), E("div", Ct, [
669
672
  u("div", null, [
670
- y(se, {
673
+ y(fe, {
671
674
  label: "Show binded items",
672
- modelValue: K.value,
673
- "onUpdate:modelValue": e[5] || (e[5] = (D) => K.value = D),
675
+ modelValue: q.value,
676
+ "onUpdate:modelValue": t[5] || (t[5] = (A) => q.value = A),
674
677
  "label-placement": "right"
675
678
  }, null, 8, ["modelValue"])
676
679
  ]),
677
- K.value && ae.value.length ? (g(), B(Ce, {
680
+ q.value && ae.value.length ? (g(), B(Fe, {
678
681
  key: 0,
679
682
  name: "Ingredient",
680
683
  bindings: ae.value
681
- }, null, 8, ["bindings"])) : W("", !0),
682
- K.value && Q.value.length ? (g(), B(Ce, {
684
+ }, null, 8, ["bindings"])) : z("", !0),
685
+ q.value && X.value.length ? (g(), B(Fe, {
683
686
  key: 1,
684
687
  name: "Recipe",
685
- bindings: Q.value
686
- }, null, 8, ["bindings"])) : W("", !0),
687
- K.value && s.value.length ? (g(), B(Ce, {
688
+ bindings: X.value
689
+ }, null, 8, ["bindings"])) : z("", !0),
690
+ q.value && s.value.length ? (g(), B(Fe, {
688
691
  key: 2,
689
692
  name: "Menu",
690
693
  bindings: s.value
691
- }, null, 8, ["bindings"])) : W("", !0)
692
- ])) : W("", !0),
693
- u("div", Ct, [
694
- u("div", St, [
695
- y(Se, null, {
696
- default: $(() => [
697
- wt
694
+ }, null, 8, ["bindings"])) : z("", !0)
695
+ ])) : z("", !0),
696
+ u("div", St, [
697
+ u("div", wt, [
698
+ y(Ce, null, {
699
+ default: I(() => [
700
+ Mt
698
701
  ]),
699
702
  _: 1
700
703
  }),
701
- Mt
704
+ $t
702
705
  ]),
703
706
  u("div", It, [
704
- y(ue, {
705
- "model-value": { low: x.value, mid: te.value },
706
- rules: [he()]
707
+ y(ce, {
708
+ "model-value": { low: M.value, mid: J.value },
709
+ rules: [se()]
707
710
  }, null, 8, ["model-value", "rules"]),
708
- u("div", $t, [
711
+ u("div", Ut, [
709
712
  u("div", Rt, [
710
- u("div", Ut, [
711
- y(ke, {
712
- days: x.value,
713
- level: w(Fe).low
713
+ u("div", Et, [
714
+ y(Ve, {
715
+ days: M.value,
716
+ level: w(ke).low
714
717
  }, null, 8, ["days", "level"])
715
718
  ]),
716
- u("div", Et, [
719
+ u("div", Dt, [
717
720
  At,
718
- y(de, {
719
- modelValue: x.value,
720
- "onUpdate:modelValue": e[6] || (e[6] = (D) => x.value = D),
721
- rules: [w(Ve)(0)]
721
+ y(Se, {
722
+ modelValue: M.value,
723
+ "onUpdate:modelValue": t[6] || (t[6] = (A) => M.value = A),
724
+ rules: [w(xe)(0)]
722
725
  }, {
723
- append: $(() => [
724
- Dt
726
+ append: I(() => [
727
+ Pt
725
728
  ]),
726
729
  _: 1
727
730
  }, 8, ["modelValue", "rules"])
728
731
  ])
729
732
  ]),
730
733
  Tt,
731
- u("div", Pt, [
732
- u("div", Bt, [
733
- y(ke, {
734
- days: te.value,
735
- level: w(Fe).mid
734
+ u("div", Bt, [
735
+ u("div", Lt, [
736
+ y(Ve, {
737
+ days: J.value,
738
+ level: w(ke).mid
736
739
  }, null, 8, ["days", "level"])
737
740
  ]),
738
- u("div", Lt, [
739
- zt,
740
- y(de, {
741
- modelValue: te.value,
742
- "onUpdate:modelValue": e[7] || (e[7] = (D) => te.value = D),
743
- rules: [w(Ve)(0)]
741
+ u("div", zt, [
742
+ Nt,
743
+ y(Se, {
744
+ modelValue: J.value,
745
+ "onUpdate:modelValue": t[7] || (t[7] = (A) => J.value = A),
746
+ rules: [w(xe)(0)]
744
747
  }, {
745
- append: $(() => [
746
- Nt
748
+ append: I(() => [
749
+ Ot
747
750
  ]),
748
751
  _: 1
749
752
  }, 8, ["modelValue", "rules"])
750
753
  ])
751
754
  ]),
752
- Ot,
753
- u("div", Ht, [
754
- u("div", jt, [
755
- y(ke, {
756
- days: te.value + 1,
757
- level: w(Fe).high
755
+ Ht,
756
+ u("div", jt, [
757
+ u("div", Yt, [
758
+ y(Ve, {
759
+ days: J.value + 1,
760
+ level: w(ke).high
758
761
  }, null, 8, ["days", "level"])
759
762
  ]),
760
- Yt
763
+ Wt
761
764
  ])
762
765
  ])
763
766
  ])
@@ -767,37 +770,37 @@ const xt = { class: "text-fm-color-typo-secondary" }, Vt = { class: "text-fm-col
767
770
  }, 8, ["disabled"]);
768
771
  };
769
772
  }
770
- }), Gt = { class: "flex gap-4" }, qt = /* @__PURE__ */ oe({
773
+ }), qt = { class: "flex gap-4" }, Kt = /* @__PURE__ */ oe({
771
774
  __name: "IngredientDialog",
772
775
  props: {
773
776
  show: { type: Boolean },
774
777
  unit: {},
775
- mode: { default: Y.READ }
778
+ mode: { default: W.READ }
776
779
  },
777
780
  emits: ["update:show"],
778
781
  setup(r) {
779
- const a = r, p = ne(), o = be(), n = Re(a, "show"), l = Re(a, "unit"), d = F(() => {
782
+ const a = r, p = ne(), o = he(), n = Ue(a, "show"), l = Ue(a, "unit"), d = k(() => {
780
783
  switch (a.mode) {
781
- case Y.READ:
784
+ case W.READ:
782
785
  return "View ingredient";
783
- case Y.UPDATE:
786
+ case W.UPDATE:
784
787
  return "Edit ingredient";
785
- case Y.CREATE:
788
+ case W.CREATE:
786
789
  return "Add ingredient";
787
790
  }
788
791
  return "";
789
- }), v = F(() => {
792
+ }), v = k(() => {
790
793
  switch (a.mode) {
791
- case Y.READ:
794
+ case W.READ:
792
795
  return "";
793
- case Y.UPDATE:
796
+ case W.UPDATE:
794
797
  return "Save";
795
- case Y.CREATE:
798
+ case W.CREATE:
796
799
  return "Add";
797
800
  }
798
801
  return "";
799
- }), _ = T(), i = T(!1);
800
- async function h() {
802
+ }), _ = P(), i = P(!1);
803
+ async function b() {
801
804
  i.value = !0;
802
805
  try {
803
806
  await p.createSku(l.value), n.value = !1, o.open({
@@ -805,8 +808,8 @@ const xt = { class: "text-fm-color-typo-secondary" }, Vt = { class: "text-fm-col
805
808
  message: "Created " + l.value.name,
806
809
  type: "success"
807
810
  });
808
- } catch (V) {
809
- V instanceof $e || o.open({
811
+ } catch (x) {
812
+ x instanceof Ie || o.open({
810
813
  title: "Failed to create ingredient",
811
814
  message: "Please try again",
812
815
  type: "error"
@@ -823,8 +826,8 @@ const xt = { class: "text-fm-color-typo-secondary" }, Vt = { class: "text-fm-col
823
826
  message: "Updated " + l.value.name,
824
827
  type: "success"
825
828
  });
826
- } catch (V) {
827
- V instanceof $e || o.open({
829
+ } catch (x) {
830
+ x instanceof Ie || o.open({
828
831
  title: "Failed to update ingredient",
829
832
  message: "Please try again",
830
833
  type: "error"
@@ -834,54 +837,54 @@ const xt = { class: "text-fm-color-typo-secondary" }, Vt = { class: "text-fm-col
834
837
  }
835
838
  }
836
839
  function f() {
837
- var V, C;
838
- (C = (V = _.value) == null ? void 0 : V.validateInputs) == null || C.call(V);
840
+ var x, F;
841
+ (F = (x = _.value) == null ? void 0 : x.validateInputs) == null || F.call(x);
839
842
  }
840
- function A() {
843
+ function D() {
841
844
  switch (a.mode) {
842
- case Y.READ:
845
+ case W.READ:
843
846
  return;
844
- case Y.UPDATE:
847
+ case W.UPDATE:
845
848
  return c();
846
- case Y.CREATE:
847
- return h();
849
+ case W.CREATE:
850
+ return b();
848
851
  }
849
852
  }
850
- return (V, C) => {
851
- const S = M("FmButton"), P = M("FmSideSheet");
852
- return g(), B(P, {
853
+ return (x, F) => {
854
+ const C = $("FmButton"), T = $("FmSideSheet");
855
+ return g(), B(T, {
853
856
  "model-value": w(n),
854
- "onUpdate:modelValue": C[3] || (C[3] = (k) => we(n) ? n.value = k : null),
857
+ "onUpdate:modelValue": F[3] || (F[3] = (V) => we(n) ? n.value = V : null),
855
858
  header: d.value,
856
859
  "close-button": "",
857
860
  "dismiss-away": "",
858
861
  "max-width": 500
859
862
  }, {
860
- "side-sheet-footer": $(() => [
861
- u("div", Gt, [
862
- y(S, {
863
+ "side-sheet-footer": I(() => [
864
+ u("div", qt, [
865
+ y(C, {
863
866
  loading: i.value,
864
867
  label: v.value,
865
868
  onClick: f
866
869
  }, null, 8, ["loading", "label"]),
867
- y(S, {
870
+ y(C, {
868
871
  disabled: i.value,
869
872
  label: "Close",
870
873
  variant: "tertiary",
871
- onClick: C[2] || (C[2] = (k) => n.value = !1)
874
+ onClick: F[2] || (F[2] = (V) => n.value = !1)
872
875
  }, null, 8, ["disabled"])
873
876
  ])
874
877
  ]),
875
- default: $(() => [
876
- y(Wt, {
878
+ default: I(() => [
879
+ y(Gt, {
877
880
  class: "w-full",
878
881
  ref_key: "hasValidationExpose",
879
882
  ref: _,
880
883
  modelValue: w(l),
881
- "onUpdate:modelValue": C[0] || (C[0] = (k) => we(l) ? l.value = k : null),
882
- mode: V.mode,
884
+ "onUpdate:modelValue": F[0] || (F[0] = (V) => we(l) ? l.value = V : null),
885
+ mode: x.mode,
883
886
  disabled: i.value,
884
- "onClick:submit": C[1] || (C[1] = (k) => A())
887
+ "onClick:submit": F[1] || (F[1] = (V) => D())
885
888
  }, null, 8, ["modelValue", "mode", "disabled"])
886
889
  ]),
887
890
  _: 1
@@ -889,24 +892,24 @@ const xt = { class: "text-fm-color-typo-secondary" }, Vt = { class: "text-fm-col
889
892
  };
890
893
  }
891
894
  });
892
- function* Kt(r) {
895
+ function* Jt(r) {
893
896
  for (; ; )
894
897
  yield r[Math.floor(Math.random() * r.length)];
895
898
  }
896
- function Jt(r = 4, a = Kt("qwertyuiopasdfghjklzxcvbnm".split(""))) {
899
+ function Qt(r = 4, a = Jt("qwertyuiopasdfghjklzxcvbnm".split(""))) {
897
900
  return Array.from({ length: r }).map(() => a.next().value).join("");
898
901
  }
899
- function Qt() {
900
- return `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${Jt()}`;
902
+ function Xt() {
903
+ return `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${Qt()}`;
901
904
  }
902
- const Xt = {
905
+ const Zt = {
903
906
  _id: "",
904
907
  name: "",
905
908
  abbrev: "",
906
909
  precision: 0,
907
910
  measurements: []
908
911
  };
909
- function Zt(r) {
912
+ function eo(r) {
910
913
  var p, o, n, l, d;
911
914
  return {
912
915
  code: r.code,
@@ -914,12 +917,12 @@ function Zt(r) {
914
917
  unit: ((p = r.unit.measurements.find((v) => v.id === r.trackingMeasurement)) == null ? void 0 : p.abbrev) ?? r.unit.abbrev,
915
918
  baseUnit: r.unit.abbrev,
916
919
  valuationMethod: r.valuation ?? "WAVG",
917
- pricePerUnit: (o = r.defaultCost) != null && o.costPerUnit ? +He((n = r.defaultCost) == null ? void 0 : n.costPerUnit) : 0,
918
- thresholdLow: ((l = r.thresholds) == null ? void 0 : l.low) ?? re().low,
919
- thresholdMid: ((d = r.thresholds) == null ? void 0 : d.mid) ?? re().mid
920
+ pricePerUnit: (o = r.defaultCost) != null && o.costPerUnit ? +je((n = r.defaultCost) == null ? void 0 : n.costPerUnit) : 0,
921
+ thresholdLow: ((l = r.thresholds) == null ? void 0 : l.low) ?? ue().low,
922
+ thresholdMid: ((d = r.thresholds) == null ? void 0 : d.mid) ?? ue().mid
920
923
  };
921
924
  }
922
- function Ye() {
925
+ function We() {
923
926
  var n;
924
927
  const r = [
925
928
  {
@@ -938,7 +941,7 @@ function Ye() {
938
941
  id: "baseUnit",
939
942
  name: "Base unit"
940
943
  }
941
- ], a = Le(), p = me(), o = ge(p.currentCountry.value);
944
+ ], a = ze(), p = pe(), o = ge(p.currentCountry.value);
942
945
  return a.enableTotalCost && r.push(
943
946
  {
944
947
  id: "valuationMethod",
@@ -959,28 +962,28 @@ function Ye() {
959
962
  }
960
963
  ), r;
961
964
  }
962
- function eo() {
963
- const a = ne().skus.map(Zt), o = me().currentBusiness.value, n = Ye(), l = [
965
+ function to() {
966
+ const a = ne().skus.map(eo), o = pe().currentBusiness.value, n = We(), l = [
964
967
  ["Business name:", o == null ? void 0 : o.name],
965
968
  ["Business ID:", o == null ? void 0 : o._id],
966
969
  ["Menu version", o == null ? void 0 : o.menuVersion],
967
970
  [],
968
971
  n.map((i) => i.name),
969
- ...a.map((i) => n.map((h) => i[h.id]))
970
- ], d = n.map((i) => `system:${i.id}`), v = Ne(l, d), _ = `${o == null ? void 0 : o.name} ingredients (${gt(/* @__PURE__ */ new Date())}).xlsx`;
971
- return Oe(v, _), _;
972
+ ...a.map((i) => n.map((b) => i[b.id]))
973
+ ], d = n.map((i) => `system:${i.id}`), v = Oe(l, d), _ = `${o == null ? void 0 : o.name} ingredients (${ht(/* @__PURE__ */ new Date())}).xlsx`;
974
+ return He(v, _), _;
972
975
  }
973
- function to() {
974
- const a = me().currentBusiness.value, p = Ye(), o = [
976
+ function oo() {
977
+ const a = pe().currentBusiness.value, p = We(), o = [
975
978
  ["Business name:", a == null ? void 0 : a.name],
976
979
  ["Business ID:", a == null ? void 0 : a._id],
977
980
  ["Menu version", a == null ? void 0 : a.menuVersion],
978
981
  [],
979
982
  p.map((v) => v.name)
980
- ], n = p.map((v) => `system:${v.id}`), l = Ne(o, n), d = "FeedMe ingredients template.xlsx";
981
- return Oe(l, d), d;
983
+ ], n = p.map((v) => `system:${v.id}`), l = Oe(o, n), d = "FeedMe ingredients template.xlsx";
984
+ return He(l, d), d;
982
985
  }
983
- function oo(r) {
986
+ function no(r) {
984
987
  const [
985
988
  a,
986
989
  p,
@@ -989,91 +992,91 @@ function oo(r) {
989
992
  l,
990
993
  d,
991
994
  ...v
992
- ] = vt(r);
995
+ ] = yt(r);
993
996
  if (!a || !a.length || a.some((f) => f.length && !f.startsWith("system:")))
994
997
  throw new Error("Missing meta header. Excel file does not come from the template.");
995
- const _ = a.map((f) => f.split(":")[1]), h = ["code", "name", "unit", "baseUnit"].filter((f) => !_.includes(f));
996
- if (h.length)
998
+ const _ = a.map((f) => f.split(":")[1]), b = ["code", "name", "unit", "baseUnit"].filter((f) => !_.includes(f));
999
+ if (b.length)
997
1000
  throw new Error(
998
- `Missing meta headers (${h.join()}). Excel file does not come from the template.`
1001
+ `Missing meta headers (${b.join()}). Excel file does not come from the template.`
999
1002
  );
1000
- return v.map((f, A) => {
1001
- const V = {};
1002
- for (const C in _) {
1003
- const S = _[C];
1004
- Object.assign(V, { [S]: f[C] });
1003
+ return v.map((f, D) => {
1004
+ const x = {};
1005
+ for (const F in _) {
1006
+ const C = _[F];
1007
+ Object.assign(x, { [C]: f[F] });
1005
1008
  }
1006
1009
  return {
1007
- index: A,
1008
- data: V
1010
+ index: D,
1011
+ data: x
1009
1012
  };
1010
1013
  });
1011
1014
  }
1012
- function Ae(r, a, p) {
1013
- var P;
1014
- const n = ne().units, l = new Array(), d = p.filter((k) => k.data.code === r.code);
1015
+ function De(r, a, p) {
1016
+ var T;
1017
+ const n = ne().units, l = new Array(), d = p.filter((V) => V.data.code === r.code);
1015
1018
  d.length > 1 && l.push(
1016
- `Code ${r.code} is already used in row ${d.map((k) => k.index + 6).join()}.`
1019
+ `Code ${r.code} is already used in row ${d.map((V) => V.index + 6).join()}.`
1017
1020
  );
1018
- const v = n.find((k) => k.abbrev === r.baseUnit), _ = v == null ? void 0 : v.measurements.find((k) => k.abbrev === r.unit);
1021
+ const v = n.find((V) => V.abbrev === r.baseUnit), _ = v == null ? void 0 : v.measurements.find((V) => V.abbrev === r.unit);
1019
1022
  if (!v)
1020
1023
  l.push(`Cannot find base unit of symbol ${r.baseUnit}.`);
1021
1024
  else if (r.baseUnit !== r.unit && !_) {
1022
- const k = `Cannot find unit conversion for ${r.baseUnit} with symbol ${r.unit || "[empty]"}.`;
1023
- l.push(k);
1025
+ const V = `Cannot find unit conversion for ${r.baseUnit} with symbol ${r.unit || "[empty]"}.`;
1026
+ l.push(V);
1024
1027
  }
1025
- const i = J.options.find(
1026
- (k) => k === r.valuationMethod
1028
+ const i = Q.options.find(
1029
+ (V) => V === r.valuationMethod
1027
1030
  );
1028
1031
  r.valuationMethod && !i && l.push(
1029
- `Expected valuation method to be one of ${J.options.join()} but got ${r.valuationMethod} instead.`
1032
+ `Expected valuation method to be one of ${Q.options.join()} but got ${r.valuationMethod} instead.`
1030
1033
  );
1031
- const c = me().currentCountry.value, f = (k) => `${k}`.length && mt()(k) === !0, A = f(`${r.pricePerUnit}`) === !0 ? {
1034
+ const c = pe().currentCountry.value, f = (V) => `${V}`.length && pt()(V) === !0, D = f(`${r.pricePerUnit}`) === !0 ? {
1032
1035
  costPerUnit: {
1033
- ...je(Number(r.pricePerUnit) || 0),
1034
- currency: ((P = ge(c)) == null ? void 0 : P.currency) ?? "MYR"
1036
+ ...Ye(Number(r.pricePerUnit) || 0),
1037
+ currency: ((T = ge(c)) == null ? void 0 : T.currency) ?? "MYR"
1035
1038
  },
1036
1039
  measurement: _
1037
- } : void 0, V = f(`${r.thresholdLow}`) && f(`${r.thresholdMid}`) ? {
1040
+ } : void 0, x = f(`${r.thresholdLow}`) && f(`${r.thresholdMid}`) ? {
1038
1041
  low: Number(r.thresholdLow) || 0,
1039
1042
  mid: Number(r.thresholdMid) || 0
1040
1043
  } : void 0;
1041
1044
  return {
1042
1045
  type: "create",
1043
1046
  sku: {
1044
- _id: Qt(),
1047
+ _id: Xt(),
1045
1048
  code: r.code,
1046
1049
  name: r.name,
1047
- unit: v ?? n.find((k) => k) ?? Xt,
1050
+ unit: v ?? n.find((V) => V) ?? Zt,
1048
1051
  trackingMeasurement: _ == null ? void 0 : _.id,
1049
1052
  valuation: i,
1050
- defaultCost: A,
1051
- thresholds: V
1053
+ defaultCost: D,
1054
+ thresholds: x
1052
1055
  },
1053
1056
  errors: l,
1054
1057
  excelRowNumber: a + 6
1055
1058
  };
1056
1059
  }
1057
- function no(r) {
1060
+ function lo(r) {
1058
1061
  try {
1059
- const a = oo(r).filter((i) => i.data.code), o = ne().skus, n = Ze(o, "code"), l = a.filter((i) => !n[i.data.code]), d = a.filter((i) => n[i.data.code]), v = l.map(
1060
- (i) => Ae(i.data, i.index, a)
1062
+ const a = no(r).filter((i) => i.data.code), o = ne().skus, n = Ze(o, "code"), l = a.filter((i) => !n[i.data.code]), d = a.filter((i) => n[i.data.code]), v = l.map(
1063
+ (i) => De(i.data, i.index, a)
1061
1064
  ), _ = d.map((i) => {
1062
- const h = Ae(i.data, i.index, a), c = n[i.data.code];
1065
+ const b = De(i.data, i.index, a), c = n[i.data.code];
1063
1066
  return {
1064
- ...h,
1067
+ ...b,
1065
1068
  type: "update",
1066
1069
  original: c,
1067
1070
  sku: {
1068
1071
  // to maintain original props not in the import excel, e.g. inventory binding, etc...
1069
1072
  ...c,
1070
- code: h.sku.code || c.code,
1071
- name: h.sku.name || c.name,
1072
- unit: h.sku.unit || c.unit,
1073
- trackingMeasurement: h.sku.trackingMeasurement || c.trackingMeasurement,
1074
- valuation: h.sku.valuation || c.valuation,
1075
- defaultCost: h.sku.defaultCost || c.defaultCost,
1076
- thresholds: h.sku.thresholds || c.thresholds
1073
+ code: b.sku.code || c.code,
1074
+ name: b.sku.name || c.name,
1075
+ unit: b.sku.unit || c.unit,
1076
+ trackingMeasurement: b.sku.trackingMeasurement || c.trackingMeasurement,
1077
+ valuation: b.sku.valuation || c.valuation,
1078
+ defaultCost: b.sku.defaultCost || c.defaultCost,
1079
+ thresholds: b.sku.thresholds || c.thresholds
1077
1080
  }
1078
1081
  };
1079
1082
  });
@@ -1091,10 +1094,10 @@ function no(r) {
1091
1094
  };
1092
1095
  }
1093
1096
  }
1094
- const lo = {
1097
+ const ao = {
1095
1098
  key: 0,
1096
1099
  class: "relative"
1097
- }, ao = ["accept", "disabled"], so = { class: "flex flex-col gap-8" }, ro = ["accept", "disabled"], io = /* @__PURE__ */ oe({
1100
+ }, so = ["accept", "disabled"], ro = { class: "flex flex-col gap-8" }, io = ["accept", "disabled"], uo = /* @__PURE__ */ oe({
1098
1101
  __name: "FmDroppableField",
1099
1102
  props: {
1100
1103
  buttonLabel: {},
@@ -1106,108 +1109,108 @@ const lo = {
1106
1109
  },
1107
1110
  emits: ["file-upload", "file-rejected"],
1108
1111
  setup(r, { emit: a }) {
1109
- const p = r, o = a, n = T(!1), l = T(null), d = T(null), v = T(), _ = (s) => {
1112
+ const p = r, o = a, n = P(!1), l = P(null), d = P(null), v = P(), _ = (s) => {
1110
1113
  p.disabled || (s.stopPropagation(), s.preventDefault());
1111
1114
  }, i = (s) => {
1112
1115
  p.disabled || (s.stopPropagation(), s.preventDefault(), n.value = !0);
1113
- }, h = (s) => {
1116
+ }, b = (s) => {
1114
1117
  p.disabled || (s.stopPropagation(), s.preventDefault(), n.value = !1);
1115
1118
  }, c = (s) => {
1116
- var z;
1117
- p.disabled || (s.stopPropagation(), s.preventDefault(), n.value = !1, f((z = s.dataTransfer) == null ? void 0 : z.files));
1119
+ var L;
1120
+ p.disabled || (s.stopPropagation(), s.preventDefault(), n.value = !1, f((L = s.dataTransfer) == null ? void 0 : L.files));
1118
1121
  };
1119
1122
  function f(s) {
1120
1123
  if (s)
1121
- if (v.value = s, l.value = V(s[0]), d.value = C(s[0]), l.value && d.value)
1124
+ if (v.value = s, l.value = x(s[0]), d.value = F(s[0]), l.value && d.value)
1122
1125
  o("file-upload", s[0]);
1123
1126
  else {
1124
- const z = A();
1127
+ const L = D();
1125
1128
  o("file-rejected", [
1126
1129
  {
1127
1130
  file: s[0],
1128
- reason: z
1131
+ reason: L
1129
1132
  }
1130
1133
  ]);
1131
1134
  }
1132
1135
  }
1133
- const A = () => {
1136
+ const D = () => {
1134
1137
  const s = new Array();
1135
1138
  return l.value || s.push("invalid-type"), d.value || s.push("invalid-size"), s;
1136
- }, V = (s) => {
1139
+ }, x = (s) => {
1137
1140
  if (!p.accept) return !0;
1138
- const z = p.accept.split(",").map((N) => N.trim());
1139
- for (const N of z)
1140
- if (S(N)) {
1141
- if (k(N) === k(s.type)) return !0;
1142
- } else if (P(s) === N || s.type === N) return !0;
1141
+ const L = p.accept.split(",").map((O) => O.trim());
1142
+ for (const O of L)
1143
+ if (C(O)) {
1144
+ if (V(O) === V(s.type)) return !0;
1145
+ } else if (T(s) === O || s.type === O) return !0;
1143
1146
  return !1;
1144
- }, C = (s) => s.size <= p.maxFileSize, S = (s) => s.indexOf("*") !== -1, P = (s) => "." + s.name.split(".").pop(), k = (s) => s.substring(0, s.indexOf("/")), le = F(() => {
1147
+ }, F = (s) => s.size <= p.maxFileSize, C = (s) => s.indexOf("*") !== -1, T = (s) => "." + s.name.split(".").pop(), V = (s) => s.substring(0, s.indexOf("/")), le = k(() => {
1145
1148
  if (n.value) return "Drop file to upload";
1146
1149
  if (l.value) {
1147
1150
  if (!d.value) return `File size exceeds ${p.maxFileSize * 1e-6}mb`;
1148
1151
  } else return "File type is not valid";
1149
1152
  return "";
1150
- }), O = F(() => v.value ? !l.value || !d.value : !1), K = (s) => {
1151
- const z = s.target;
1152
- f(z.files);
1153
- }, ae = F(() => {
1153
+ }), N = k(() => v.value ? !l.value || !d.value : !1), q = (s) => {
1154
+ const L = s.target;
1155
+ f(L.files);
1156
+ }, ae = k(() => {
1154
1157
  var s;
1155
1158
  return (s = v.value) == null ? void 0 : s.item(0);
1156
- }), Q = T();
1157
- return (s, z) => {
1158
- const N = M("FmLabel"), ie = M("FmButton");
1159
+ }), X = P();
1160
+ return (s, L) => {
1161
+ const O = $("FmLabel"), de = $("FmButton");
1159
1162
  return g(), E("label", {
1160
1163
  class: "fm-droppable-field",
1161
1164
  ref_key: "fmButtonRef",
1162
- ref: Q
1165
+ ref: X
1163
1166
  }, [
1164
- s.$slots.default ? (g(), E("div", lo, [
1167
+ s.$slots.default ? (g(), E("div", ao, [
1165
1168
  u("input", {
1166
1169
  accept: s.accept,
1167
1170
  disabled: s.disabled,
1168
1171
  class: "fm-droppable-field__input",
1169
1172
  type: "file",
1170
- onChange: K
1171
- }, null, 40, ao)
1172
- ])) : W("", !0),
1173
+ onChange: q
1174
+ }, null, 40, so)
1175
+ ])) : z("", !0),
1173
1176
  ve(s.$slots, "default", {
1174
1177
  isDragging: n.value,
1175
1178
  isValidFileType: l.value,
1176
1179
  isValidFileSize: d.value,
1177
1180
  singleValidFile: ae.value,
1178
1181
  openFileDialog: () => {
1179
- var ee;
1180
- return console.log("click", Q.value), (ee = Q.value) == null ? void 0 : ee.click();
1182
+ var te;
1183
+ return console.log("click", X.value), (te = X.value) == null ? void 0 : te.click();
1181
1184
  }
1182
1185
  }, () => [
1183
- u("div", so, [
1184
- s.$slots.label ? ve(s.$slots, "label", { key: 0 }, void 0, !0) : (g(), B(N, {
1186
+ u("div", ro, [
1187
+ s.$slots.label ? ve(s.$slots, "label", { key: 0 }, void 0, !0) : (g(), B(O, {
1185
1188
  key: 1,
1186
1189
  label: s.label
1187
1190
  }, null, 8, ["label"]))
1188
1191
  ]),
1189
1192
  u("div", {
1190
- class: G([[
1193
+ class: K([[
1191
1194
  s.contentClass ? s.contentClass : "w-full h-full",
1192
1195
  {
1193
1196
  "fm-droppable-field__container--dragging": n.value,
1194
- "fm-droppable-field__container--invalid": O.value && !s.disabled,
1197
+ "fm-droppable-field__container--invalid": N.value && !s.disabled,
1195
1198
  "fm-droppable-field__container--disabled": s.disabled
1196
1199
  }
1197
1200
  ], "fm-droppable-field__container"]),
1198
1201
  onDragenter: _,
1199
- onDragleave: h,
1202
+ onDragleave: b,
1200
1203
  onDragover: i,
1201
1204
  onDrop: c
1202
1205
  }, [
1203
- (n.value || O.value) && !s.disabled ? (g(), E("div", {
1206
+ (n.value || N.value) && !s.disabled ? (g(), E("div", {
1204
1207
  key: 0,
1205
- class: G({
1208
+ class: K({
1206
1209
  "fm-typo-en-body-lg-600": !0,
1207
1210
  "text-fm-color-primary": n.value,
1208
- "text-fm-color-typo-error": O.value
1211
+ "text-fm-color-typo-error": N.value
1209
1212
  })
1210
- }, q(le.value), 3)) : (g(), B(ie, {
1213
+ }, G(le.value), 3)) : (g(), B(de, {
1211
1214
  key: 1,
1212
1215
  disabled: s.disabled,
1213
1216
  label: s.buttonLabel ?? "Add files",
@@ -1217,30 +1220,30 @@ const lo = {
1217
1220
  ve(s.$slots, "accept-text", {}, () => [
1218
1221
  p.accept ? (g(), E("div", {
1219
1222
  key: 0,
1220
- class: G([[s.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"], "fm-typo-en-body-md-400"])
1221
- }, q(`Accepts ${p.accept}`), 3)) : W("", !0)
1223
+ class: K([[s.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"], "fm-typo-en-body-md-400"])
1224
+ }, G(`Accepts ${p.accept}`), 3)) : z("", !0)
1222
1225
  ], !0),
1223
1226
  u("input", {
1224
1227
  accept: s.accept,
1225
1228
  disabled: s.disabled,
1226
1229
  class: "fm-droppable-field__input",
1227
1230
  type: "file",
1228
- onChange: K
1229
- }, null, 40, ro)
1231
+ onChange: q
1232
+ }, null, 40, io)
1230
1233
  ], 34),
1231
1234
  ve(s.$slots, "helper-text", {}, () => [
1232
1235
  u("div", {
1233
- class: G([[s.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"], "fm-typo-en-body-sm-400"])
1234
- }, q(`Max size ${p.maxFileSize * 1e-6}mb`), 3)
1236
+ class: K([[s.disabled ? "text-fm-color-typo-disabled" : "text-fm-color-typo-secondary"], "fm-typo-en-body-sm-400"])
1237
+ }, G(`Max size ${p.maxFileSize * 1e-6}mb`), 3)
1235
1238
  ], !0)
1236
1239
  ], !0)
1237
1240
  ], 512);
1238
1241
  };
1239
1242
  }
1240
- }), uo = /* @__PURE__ */ et(io, [["__scopeId", "data-v-311b22a0"]]), co = { class: "flex items-center gap-12 pl-8" }, mo = /* @__PURE__ */ u("div", null, "•", -1), po = { class: "flex flex-col" }, fo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, vo = {
1243
+ }), co = /* @__PURE__ */ et(uo, [["__scopeId", "data-v-311b22a0"]]), mo = { class: "flex items-center gap-12 pl-8" }, po = /* @__PURE__ */ u("div", null, "•", -1), fo = { class: "flex flex-col" }, vo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, yo = {
1241
1244
  key: 0,
1242
1245
  class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
1243
- }, yo = { key: 0 }, De = /* @__PURE__ */ oe({
1246
+ }, go = { key: 0 }, Ae = /* @__PURE__ */ oe({
1244
1247
  __name: "ImportIngredientItem",
1245
1248
  props: {
1246
1249
  type: {},
@@ -1250,27 +1253,27 @@ const lo = {
1250
1253
  },
1251
1254
  setup(r) {
1252
1255
  return (a, p) => {
1253
- const o = M("FmIcon"), n = M("FmTooltip");
1254
- return g(), E("div", co, [
1255
- mo,
1256
- u("div", po, [
1257
- u("div", fo, [
1256
+ const o = $("FmIcon"), n = $("FmTooltip");
1257
+ return g(), E("div", mo, [
1258
+ po,
1259
+ u("div", fo, [
1260
+ u("div", vo, [
1258
1261
  u("div", {
1259
- class: G({
1262
+ class: K({
1260
1263
  "text-fm-color-system-error-300": a.errors.length
1261
1264
  })
1262
1265
  }, [
1263
- Pe(q(a.name) + " ", 1),
1264
- a.type === "create" ? (g(), E("span", vo, "(new)")) : W("", !0)
1266
+ Te(G(a.name) + " ", 1),
1267
+ a.type === "create" ? (g(), E("span", yo, "(new)")) : z("", !0)
1265
1268
  ], 2),
1266
- a.errors.length ? (g(), E("div", yo, [
1269
+ a.errors.length ? (g(), E("div", go, [
1267
1270
  y(n, { "z-index": 50 }, {
1268
- content: $(() => [
1271
+ content: I(() => [
1269
1272
  u("ol", null, [
1270
- (g(!0), E(Z, null, ce(a.errors, (l, d) => (g(), E("li", { key: d }, q(l), 1))), 128))
1273
+ (g(!0), E(ee, null, me(a.errors, (l, d) => (g(), E("li", { key: d }, G(l), 1))), 128))
1271
1274
  ])
1272
1275
  ]),
1273
- default: $(() => [
1276
+ default: I(() => [
1274
1277
  y(o, {
1275
1278
  name: "error",
1276
1279
  size: "sm",
@@ -1279,61 +1282,61 @@ const lo = {
1279
1282
  ]),
1280
1283
  _: 1
1281
1284
  })
1282
- ])) : W("", !0)
1285
+ ])) : z("", !0)
1283
1286
  ]),
1284
1287
  u("div", {
1285
- class: G([
1288
+ class: K([
1286
1289
  "fm-typo-en-body-sm-400",
1287
1290
  {
1288
1291
  "text-fm-color-system-error-200": a.errors.length,
1289
1292
  "text-fm-color-typo-secondary": !a.errors.length
1290
1293
  }
1291
1294
  ])
1292
- }, q(a.code), 3)
1295
+ }, G(a.code), 3)
1293
1296
  ])
1294
1297
  ]);
1295
1298
  };
1296
1299
  }
1297
- }), go = { class: "flex flex-col gap-24" }, bo = /* @__PURE__ */ u("div", { class: "fm-typo-en-body-md-400" }, " Import ingredients from your Excel file and apply changes to your business. ", -1), ho = { class: "flex flex-col gap-8" }, _o = { class: "line-clamp-2 text-ellipsis break-all" }, xo = {
1300
+ }), ho = { class: "flex flex-col gap-24" }, bo = /* @__PURE__ */ u("div", { class: "fm-typo-en-body-md-400" }, " Import ingredients from your Excel file and apply changes to your business. ", -1), _o = { class: "flex flex-col gap-8" }, xo = { class: "line-clamp-2 text-ellipsis break-all" }, Vo = {
1298
1301
  key: 2,
1299
1302
  class: "shrink-0"
1300
- }, Vo = {
1303
+ }, ko = {
1301
1304
  key: 0,
1302
1305
  class: "flex flex-col"
1303
- }, ko = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, Fo = {
1306
+ }, Fo = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, Co = {
1304
1307
  key: 0,
1305
1308
  class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
1306
- }, Co = /* @__PURE__ */ u("div", { class: "fm-typo-en-body-lg-600" }, "Summary", -1), So = /* @__PURE__ */ oe({
1309
+ }, So = /* @__PURE__ */ u("div", { class: "fm-typo-en-body-lg-600" }, "Summary", -1), wo = /* @__PURE__ */ oe({
1307
1310
  __name: "ImportIngredients",
1308
1311
  setup(r) {
1309
- const a = T(null), p = ot(), o = be(), n = T(!1), l = T(new Array()), d = T([]), v = T([]), _ = F(
1312
+ const a = P(null), p = ot(), o = he(), n = P(!1), l = P(new Array()), d = P([]), v = P([]), _ = k(
1310
1313
  () => !!l.value.length || d.value.some((c) => c.errors.length) || v.value.some((c) => c.errors.length)
1311
- ), i = F(
1314
+ ), i = k(
1312
1315
  () => !!d.value.length || !!v.value.length
1313
1316
  );
1314
- async function h(c) {
1317
+ async function b(c) {
1315
1318
  l.value = [], d.value = [], v.value = [];
1316
1319
  try {
1317
1320
  n.value = !0;
1318
1321
  const [f] = await Promise.all([
1319
- yt(c),
1322
+ gt(c),
1320
1323
  // fake buffer
1321
- new Promise((C) => setTimeout(C, 1e3))
1322
- ]), A = f.SheetNames.find((C) => C);
1323
- if (!A) {
1324
+ new Promise((F) => setTimeout(F, 1e3))
1325
+ ]), D = f.SheetNames.find((F) => F);
1326
+ if (!D) {
1324
1327
  l.value.push("No sheet is found in the excel file.");
1325
1328
  return;
1326
1329
  }
1327
- const V = no(f.Sheets[A]);
1328
- if (V.invalidExcel) {
1329
- l.value.push(V.invalidExcelMessage ?? "Invalid excel");
1330
+ const x = lo(f.Sheets[D]);
1331
+ if (x.invalidExcel) {
1332
+ l.value.push(x.invalidExcelMessage ?? "Invalid excel");
1330
1333
  return;
1331
1334
  }
1332
- if (d.value = V.importCreateResult, v.value = V.importUpdateResult, !d.value.length && !v.value.length) {
1335
+ if (d.value = x.importCreateResult, v.value = x.importUpdateResult, !d.value.length && !v.value.length) {
1333
1336
  l.value.push("No import data is available in the excel file.");
1334
1337
  return;
1335
1338
  }
1336
- p.emitData(V);
1339
+ p.emitData(x);
1337
1340
  } catch (f) {
1338
1341
  o.open({
1339
1342
  title: "Unable to read file",
@@ -1347,28 +1350,28 @@ const lo = {
1347
1350
  }), n.value = !1;
1348
1351
  }
1349
1352
  }
1350
- return Te(a, (c) => {
1351
- c && h(c);
1353
+ return Pe(a, (c) => {
1354
+ c && b(c);
1352
1355
  }), (c, f) => {
1353
- const A = M("FmCircularProgress"), V = M("FmIcon"), C = M("FmButton");
1354
- return g(), E("div", go, [
1356
+ const D = $("FmCircularProgress"), x = $("FmIcon"), F = $("FmButton");
1357
+ return g(), E("div", ho, [
1355
1358
  bo,
1356
- y(uo, {
1357
- class: G({
1359
+ y(co, {
1360
+ class: K({
1358
1361
  "w-full": !0,
1359
1362
  "h-[200px]": !a.value
1360
1363
  }),
1361
1364
  accept: ".xlsx",
1362
- onFileUpload: f[0] || (f[0] = (S) => a.value = S),
1365
+ onFileUpload: f[0] || (f[0] = (C) => a.value = C),
1363
1366
  label: "Upload template",
1364
1367
  "button-label": "Select file"
1365
- }, qe({ _: 2 }, [
1368
+ }, Be({ _: 2 }, [
1366
1369
  a.value ? {
1367
1370
  name: "default",
1368
- fn: $(({ openFileDialog: S }) => [
1369
- u("div", ho, [
1371
+ fn: I(({ openFileDialog: C }) => [
1372
+ u("div", _o, [
1370
1373
  u("div", {
1371
- class: G([
1374
+ class: K([
1372
1375
  "fm-corner-radius-md p-16 flex items-center gap-16",
1373
1376
  {
1374
1377
  "border border-fm-color-neutral-gray-100": n.value,
@@ -1377,18 +1380,18 @@ const lo = {
1377
1380
  }
1378
1381
  ])
1379
1382
  }, [
1380
- n.value ? (g(), B(A, {
1383
+ n.value ? (g(), B(D, {
1381
1384
  key: 0,
1382
1385
  size: "md",
1383
1386
  color: "neutral-gray-200"
1384
- })) : (g(), B(V, {
1387
+ })) : (g(), B(x, {
1385
1388
  key: 1,
1386
1389
  name: _.value ? "error" : "attach_file",
1387
1390
  outline: "",
1388
1391
  color: _.value ? "system-error-300" : void 0
1389
1392
  }, null, 8, ["name", "color"])),
1390
1393
  u("div", {
1391
- class: G([
1394
+ class: K([
1392
1395
  "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
1393
1396
  {
1394
1397
  "text-fm-color-typo-disabled": n.value,
@@ -1396,74 +1399,74 @@ const lo = {
1396
1399
  }
1397
1400
  ])
1398
1401
  }, [
1399
- u("div", _o, q(a.value.name), 1)
1402
+ u("div", xo, G(a.value.name), 1)
1400
1403
  ], 2),
1401
- n.value ? W("", !0) : (g(), E("div", xo, [
1402
- y(C, {
1404
+ n.value ? z("", !0) : (g(), E("div", Vo, [
1405
+ y(F, {
1403
1406
  label: "Replace file",
1404
1407
  variant: _.value ? "destructive" : "secondary",
1405
1408
  "prepend-icon": _.value ? void 0 : "autorenew",
1406
- onClick: S
1409
+ onClick: C
1407
1410
  }, null, 8, ["variant", "prepend-icon", "onClick"])
1408
1411
  ]))
1409
1412
  ], 2),
1410
- l.value.length ? (g(), E("div", Vo, [
1411
- (g(!0), E(Z, null, ce(l.value, (P, k) => (g(), E("div", {
1412
- key: k,
1413
+ l.value.length ? (g(), E("div", ko, [
1414
+ (g(!0), E(ee, null, me(l.value, (T, V) => (g(), E("div", {
1415
+ key: V,
1413
1416
  class: "flex gap-8 items-center"
1414
1417
  }, [
1415
- y(V, {
1418
+ y(x, {
1416
1419
  name: "error",
1417
1420
  size: "sm",
1418
1421
  color: "system-error-300"
1419
1422
  }),
1420
- u("div", ko, q(P), 1)
1423
+ u("div", Fo, G(T), 1)
1421
1424
  ]))), 128))
1422
- ])) : W("", !0)
1425
+ ])) : z("", !0)
1423
1426
  ])
1424
1427
  ]),
1425
1428
  key: "0"
1426
1429
  } : void 0
1427
1430
  ]), 1032, ["class"]),
1428
- i.value ? (g(), E("div", Fo, [
1429
- Co,
1430
- (g(!0), E(Z, null, ce(d.value, (S) => (g(), B(De, {
1431
- key: S.sku._id,
1432
- code: S.sku.code,
1433
- name: S.sku.name,
1434
- errors: S.errors,
1431
+ i.value ? (g(), E("div", Co, [
1432
+ So,
1433
+ (g(!0), E(ee, null, me(d.value, (C) => (g(), B(Ae, {
1434
+ key: C.sku._id,
1435
+ code: C.sku.code,
1436
+ name: C.sku.name,
1437
+ errors: C.errors,
1435
1438
  type: "create"
1436
1439
  }, null, 8, ["code", "name", "errors"]))), 128)),
1437
- (g(!0), E(Z, null, ce(v.value, (S) => (g(), B(De, {
1438
- key: S.sku._id,
1439
- code: S.sku.code,
1440
- name: S.sku.name,
1441
- errors: S.errors,
1440
+ (g(!0), E(ee, null, me(v.value, (C) => (g(), B(Ae, {
1441
+ key: C.sku._id,
1442
+ code: C.sku.code,
1443
+ name: C.sku.name,
1444
+ errors: C.errors,
1442
1445
  type: "update"
1443
1446
  }, null, 8, ["code", "name", "errors"]))), 128))
1444
- ])) : W("", !0)
1447
+ ])) : z("", !0)
1445
1448
  ]);
1446
1449
  };
1447
1450
  }
1448
- }), wo = { class: "px-24 xs:p-0 sm:p-0 flex flex-col gap-8 max-h-full" }, Mo = { class: "px-8 flex items-center xs:gap-0 xs:flex-col-reverse sm:gap-0 sm:flex-col-reverse" }, Io = { class: "flex-1 w-full" }, $o = { class: "flex flex-col py-8" }, Ro = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Uo = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, qo = /* @__PURE__ */ oe({
1451
+ }), Mo = { class: "px-24 xs:p-0 sm:p-0 flex flex-col gap-8 max-h-full" }, $o = { class: "flex flex-col py-8" }, Io = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Uo = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Ro = /* @__PURE__ */ u("div", null, "Importing...", -1), Jo = /* @__PURE__ */ oe({
1449
1452
  __name: "IngredientsView",
1450
1453
  setup(r) {
1451
- const a = ne(), p = F(() => a.skus), o = tt(), n = ze(), l = be(), {
1454
+ const a = ne(), p = k(() => a.skus), o = tt(), n = Ne(), l = he(), {
1452
1455
  createIngredient: d,
1453
1456
  updateIngredient: v,
1454
1457
  deleteIngredient: _,
1455
1458
  ingredientDialogProps: i,
1456
- ingredientViewLoading: h
1457
- } = bt(), { columnDefs: c } = ht({ updateIngredient: v, deleteIngredient: _ });
1458
- function f(R) {
1459
- switch (R) {
1459
+ ingredientViewLoading: b
1460
+ } = bt(), { columnDefs: c } = _t({ updateIngredient: v, deleteIngredient: _ });
1461
+ function f(U) {
1462
+ switch (U) {
1460
1463
  case "add":
1461
1464
  return d();
1462
1465
  case "import":
1463
- return N();
1466
+ return O();
1464
1467
  }
1465
1468
  }
1466
- const A = T(""), V = T(!1), C = F(() => V.value || h.value), { breakpoints: S } = nt(), P = F(() => S.value.xs || S.value.sm), k = F(() => P.value ? 10 : 20), le = it(), O = T(!1), K = [
1469
+ const D = P(""), x = P(!1), F = k(() => x.value || b.value), { breakpoints: C } = nt(), T = k(() => C.value.xs || C.value.sm), V = k(() => T.value ? 10 : 20), le = it(), N = P(!1), q = [
1467
1470
  {
1468
1471
  value: "import",
1469
1472
  label: "Import"
@@ -1473,36 +1476,32 @@ const lo = {
1473
1476
  label: "Export"
1474
1477
  }
1475
1478
  ];
1476
- function ae(R) {
1477
- switch (O.value = !1, R) {
1479
+ function ae(U) {
1480
+ switch (N.value = !1, U) {
1478
1481
  case "import":
1479
- return N();
1482
+ return O();
1480
1483
  case "export":
1481
- return z();
1484
+ return L();
1482
1485
  }
1483
1486
  }
1484
- const Q = F(() => P.value ? [
1485
- { label: "More", icon: "more_vert", key: "more" }
1486
- ] : [
1487
- { label: "Export", icon: "ios_share", key: "export" }
1488
- ]), s = F(() => {
1489
- const R = [
1487
+ const X = k(() => T.value ? [{ icon: "more_vert", onClick: te }] : [{ icon: "ios_share", onClick: L }]), s = k(() => {
1488
+ const U = [
1490
1489
  { label: "Add ingredient", value: "add", isPrimary: !0, prependIcon: "add" }
1491
1490
  ];
1492
- return P.value ? R : [...R, { label: "Import", value: "import" }];
1491
+ return T.value ? U : [...U, { label: "Import", value: "import" }];
1493
1492
  });
1494
- function z() {
1495
- const R = eo();
1493
+ function L() {
1494
+ const U = to();
1496
1495
  l.open({
1497
1496
  title: "Ingredients exported",
1498
- message: `Filename: ${R}`,
1497
+ message: `Filename: ${U}`,
1499
1498
  type: "success"
1500
1499
  });
1501
1500
  }
1502
- function N() {
1501
+ function O() {
1503
1502
  n.open({
1504
1503
  title: "Import ingredients",
1505
- contentComponent: So,
1504
+ contentComponent: wo,
1506
1505
  overlay: !0,
1507
1506
  closeButton: !0,
1508
1507
  primaryActions: {
@@ -1518,15 +1517,15 @@ const lo = {
1518
1517
  close: !1,
1519
1518
  variant: "plain"
1520
1519
  }
1521
- }).onPrimary((R) => {
1522
- if (!R) {
1520
+ }).onPrimary((U) => {
1521
+ if (!U) {
1523
1522
  l.open({
1524
1523
  title: "No import data received",
1525
1524
  type: "error"
1526
1525
  });
1527
1526
  return;
1528
1527
  }
1529
- if (!R.importCreateResult.length && !R.importUpdateResult.length) {
1528
+ if (!U.importCreateResult.length && !U.importUpdateResult.length) {
1530
1529
  l.open({
1531
1530
  title: "Invalid content",
1532
1531
  message: "No import data in the excel file",
@@ -1534,7 +1533,7 @@ const lo = {
1534
1533
  });
1535
1534
  return;
1536
1535
  }
1537
- if (R.importCreateResult.some((x) => x.errors.length) || R.importUpdateResult.some((x) => x.errors.length)) {
1536
+ if (U.importCreateResult.some((M) => M.errors.length) || U.importUpdateResult.some((M) => M.errors.length)) {
1538
1537
  l.open({
1539
1538
  title: "Invalid content",
1540
1539
  message: "There is error in the import data.",
@@ -1542,110 +1541,121 @@ const lo = {
1542
1541
  });
1543
1542
  return;
1544
1543
  }
1545
- n.close(), ie(R);
1546
- }).onTertiary(to);
1544
+ n.close(), de(U);
1545
+ }).onTertiary(oo);
1547
1546
  }
1548
- async function ie(R) {
1549
- V.value = !0;
1547
+ async function de(U) {
1548
+ x.value = !0;
1550
1549
  try {
1551
- await Promise.all([
1552
- a.importSkus({
1553
- create: R.importCreateResult.map((x) => x.sku),
1554
- update: R.importUpdateResult.map((x) => x.sku)
1555
- }),
1556
- new Promise((x) => setTimeout(x, 2e3))
1557
- ]), l.open({
1550
+ const M = [
1551
+ ...U.importCreateResult.map(({ sku: e }) => ({ type: "create", sku: e })),
1552
+ ...U.importUpdateResult.map(({ sku: e }) => ({ type: "update", sku: e }))
1553
+ ], J = 100;
1554
+ let se = 0;
1555
+ const re = () => {
1556
+ se += J, l.open({
1557
+ title: `Uploading ${Math.min(se, M.length)}/${M.length} ingredients`
1558
+ });
1559
+ };
1560
+ for (const e of M.chunk(100))
1561
+ re(), await a.importSkus({
1562
+ create: e.filter((t) => t.type === "create").map((t) => t.sku),
1563
+ update: e.filter((t) => t.type === "update").map((t) => t.sku)
1564
+ });
1565
+ l.open({
1558
1566
  title: "Ingredients successfully imported",
1559
1567
  type: "success"
1560
1568
  });
1561
- } catch (x) {
1569
+ } catch (M) {
1562
1570
  l.open({
1563
1571
  title: "Failed to import ingredients",
1564
- message: `System message: ${x == null ? void 0 : x.message}`,
1572
+ message: `System message: ${M == null ? void 0 : M.message}`,
1565
1573
  type: "error"
1566
- }), console.error("Error in importing skus", R, x);
1574
+ }), console.error("Error in importing skus", U, M);
1567
1575
  } finally {
1568
- V.value = !1;
1576
+ x.value = !1;
1569
1577
  }
1570
1578
  }
1571
- function ee() {
1572
- O.value = !0;
1579
+ function te() {
1580
+ N.value = !0;
1573
1581
  }
1574
- return (R, x) => {
1575
- const te = M("FmTableToolbar"), he = M("FmTable"), pe = M("FmCollapsibleTabs"), t = M("FmBottomSheet");
1582
+ return (U, M) => {
1583
+ const J = $("FmTable"), se = $("FmCollapsibleTabs"), re = $("FmBottomSheet");
1576
1584
  return g(), B(ut, {
1577
1585
  title: "Ingredient",
1578
1586
  actions: s.value,
1579
1587
  "onClick:action": f
1580
1588
  }, {
1581
- default: $(() => [
1582
- u("div", wo, [
1583
- u("div", Mo, [
1584
- u("div", Io, [
1585
- y(te, {
1586
- searchable: "",
1587
- "search-model": A.value,
1588
- "onUpdate:searchModel": x[0] || (x[0] = (e) => A.value = e),
1589
- actions: Q.value,
1590
- "onClick:actionExport": x[1] || (x[1] = () => z()),
1591
- "onClick:actionImport": x[2] || (x[2] = () => N()),
1592
- "onClick:actionMore": x[3] || (x[3] = () => ee())
1593
- }, null, 8, ["search-model", "actions"])
1594
- ])
1595
- ]),
1596
- y(he, {
1589
+ default: I(() => [
1590
+ u("div", Mo, [
1591
+ y(dt, {
1592
+ searchable: "",
1593
+ search: D.value,
1594
+ "onUpdate:search": M[0] || (M[0] = (e) => D.value = e),
1595
+ actions: X.value
1596
+ }, null, 8, ["search", "actions"]),
1597
+ y(J, {
1597
1598
  style: Ke(w(le).tableHeight),
1598
1599
  "column-defs": w(c),
1599
1600
  "row-data": p.value,
1600
- "search-value": A.value,
1601
- loading: !w(o)._currentLocation || C.value,
1602
- onRowClick: x[4] || (x[4] = (e) => w(v)(e.original)),
1603
- "page-size": k.value
1601
+ "search-value": D.value,
1602
+ loading: !w(o)._currentLocation || F.value,
1603
+ "loading-text": "Loading",
1604
+ onRowClick: M[1] || (M[1] = (e) => w(v)(e.original)),
1605
+ "page-size": V.value
1604
1606
  }, {
1605
- "list-row": $((e) => [
1607
+ "list-row": I((e) => [
1606
1608
  y(rt, {
1607
1609
  row: e,
1608
1610
  onRowClick: w(v)
1609
- }, {
1610
- default: $((m) => {
1611
- var b, U, I, L, H, X, fe, ue, se, de;
1611
+ }, Be({
1612
+ default: I((t) => {
1613
+ var m, h, R, S, H, j, Z, ce, ie, fe;
1612
1614
  return [
1613
1615
  u("div", $o, [
1614
- u("div", Ro, [
1616
+ u("div", Io, [
1615
1617
  y(w(Ee), {
1616
- render: (I = (U = (b = m.code) == null ? void 0 : b.column) == null ? void 0 : U.columnDef) == null ? void 0 : I.cell,
1617
- props: (H = (L = m.code) == null ? void 0 : L.getContext) == null ? void 0 : H.call(L)
1618
+ render: (R = (h = (m = t.code) == null ? void 0 : m.column) == null ? void 0 : h.columnDef) == null ? void 0 : R.cell,
1619
+ props: (H = (S = t.code) == null ? void 0 : S.getContext) == null ? void 0 : H.call(S)
1618
1620
  }, null, 8, ["render", "props"])
1619
1621
  ]),
1620
1622
  u("div", Uo, [
1621
1623
  y(w(Ee), {
1622
- render: (ue = (fe = (X = m.name) == null ? void 0 : X.column) == null ? void 0 : fe.columnDef) == null ? void 0 : ue.cell,
1623
- props: (de = (se = m.name) == null ? void 0 : se.getContext) == null ? void 0 : de.call(se)
1624
+ render: (ce = (Z = (j = t.name) == null ? void 0 : j.column) == null ? void 0 : Z.columnDef) == null ? void 0 : ce.cell,
1625
+ props: (fe = (ie = t.name) == null ? void 0 : ie.getContext) == null ? void 0 : fe.call(ie)
1624
1626
  }, null, 8, ["render", "props"])
1625
1627
  ])
1626
1628
  ])
1627
1629
  ];
1628
1630
  }),
1629
1631
  _: 2
1630
- }, 1032, ["row", "onRowClick"])
1632
+ }, [
1633
+ x.value ? {
1634
+ name: "loading-text",
1635
+ fn: I(() => [
1636
+ Ro
1637
+ ]),
1638
+ key: "0"
1639
+ } : void 0
1640
+ ]), 1032, ["row", "onRowClick"])
1631
1641
  ]),
1632
1642
  _: 1
1633
1643
  }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
1634
1644
  ]),
1635
1645
  (g(), B(Me, { to: "body" }, [
1636
- y(qt, Je(Qe(w(i))), null, 16)
1646
+ y(Kt, Je(Qe(w(i))), null, 16)
1637
1647
  ])),
1638
1648
  (g(), B(Me, { to: "body" }, [
1639
- y(t, {
1649
+ y(re, {
1640
1650
  "dismiss-away": "",
1641
- modelValue: O.value,
1642
- "onUpdate:modelValue": x[6] || (x[6] = (e) => O.value = e)
1651
+ modelValue: N.value,
1652
+ "onUpdate:modelValue": M[3] || (M[3] = (e) => N.value = e)
1643
1653
  }, {
1644
- default: $(() => [
1645
- y(pe, {
1654
+ default: I(() => [
1655
+ y(se, {
1646
1656
  class: "pb-8",
1647
- items: K,
1648
- "onUpdate:modelValue": x[5] || (x[5] = (e) => ae(e))
1657
+ items: q,
1658
+ "onUpdate:modelValue": M[2] || (M[2] = (e) => ae(e))
1649
1659
  })
1650
1660
  ]),
1651
1661
  _: 1
@@ -1658,5 +1668,5 @@ const lo = {
1658
1668
  }
1659
1669
  });
1660
1670
  export {
1661
- qo as default
1671
+ Jo as default
1662
1672
  };