@feedmepos/mf-inventory-portal 0.0.22-dev.4 → 0.0.22-dev.40

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 (106) hide show
  1. package/dist/{ApprovalView-xF73Z1jN.js → ApprovalView-JOsQBu1z.js} +25 -26
  2. package/dist/{BindingsDialog-CCSAxGT4.js → BindingsDialog-DG2ZolH1.js} +9 -9
  3. package/dist/{BindingsPicker-ErFH0uEQ.js → BindingsPicker-B7h_iST8.js} +22 -22
  4. package/dist/{BindingsTable-D8ffJgIJ.js → BindingsTable-BToh6gcG.js} +1 -1
  5. package/dist/ClosingTemplateView-BwMJAxuz.js +1688 -0
  6. package/dist/FmDroppableField-CJNAT3h2.js +152 -0
  7. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-4NHQdjz7.js +266 -0
  8. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-Cc_P0kss.js +364 -0
  9. package/dist/IngredientBindedItem.vue_vue_type_script_setup_true_lang-DMOalXUS.js +51 -0
  10. package/dist/IngredientsView-ChnCqdWi.js +1611 -0
  11. package/dist/{IntegrationView-54yz2EqS.js → IntegrationView-NWkc9PLW.js} +71 -71
  12. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CKvKlCk-.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BQW6HYyD.js} +1 -1
  13. package/dist/PremiumBadge.vue_vue_type_script_setup_true_lang-BQqcpZIJ.js +116 -0
  14. package/dist/{PurchaseOrderPrintPreview-pcpWSfl4.js → PurchaseOrderPrintPreview-BvED8ZbQ.js} +7 -7
  15. package/dist/ReceiveRequestView-DdxBaqmU.js +4069 -0
  16. package/dist/RecipeView-YdSRy_yP.js +591 -0
  17. package/dist/Standalone.vue.d.ts +2 -0
  18. package/dist/StockView-WF5z4dTF.js +7762 -0
  19. package/dist/{SupplierView-TYCkPXan.js → SupplierView-H2Vi5lSs.js} +111 -111
  20. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-D48gSqHW.js +1137 -0
  21. package/dist/TransferTemplateView-DeT32cat.js +2054 -0
  22. package/dist/{UnitView-B9yE4-rc.js → UnitView-qD9JSdHT.js} +18 -18
  23. package/dist/{WarehouseView-DUtVLTjb.js → WarehouseView-C19Dd53y.js} +176 -177
  24. package/dist/api/bill.d.ts +84 -238
  25. package/dist/api/closing-template.d.ts +6 -4
  26. package/dist/api/inventory.d.ts +72 -85
  27. package/dist/api/netsuite.d.ts +47 -0
  28. package/dist/api/purchase-order-template.d.ts +4 -6
  29. package/dist/{app-w8TOQVZc.js → app-DKE_n9Mo.js} +24520 -23671
  30. package/dist/app.d.ts +7 -0
  31. package/dist/app.js +3 -3
  32. package/dist/components/FmFilterableMenuOptions.vue.d.ts +54 -0
  33. package/dist/components/FmMinMaxInputRules.d.ts +2 -0
  34. package/dist/components/FmUnitInputRules.d.ts +2 -0
  35. package/dist/components/map/GoogleMap.vue.d.ts +4 -4
  36. package/dist/{decimal-C4q7UMfr.js → decimal-veoPLYim.js} +1 -1
  37. package/dist/defineDeepModel-u6t3hXU9.js +13 -0
  38. package/dist/format-time-from-id-8gjg5B98.js +15 -0
  39. package/dist/helper/rules.d.ts +7 -0
  40. package/dist/helper/rules.spec.d.ts +1 -0
  41. package/dist/helper/xlsx.util.d.ts +7 -0
  42. package/dist/purchase-order-transaction-type-CIDEpjJB.js +348 -0
  43. package/dist/stores/api.d.ts +1 -0
  44. package/dist/stores/feature.d.ts +0 -1
  45. package/dist/stores/helper/core-store-proxy.d.ts +3 -0
  46. package/dist/stores/helper/generate-backend-urls.d.ts +1 -0
  47. package/dist/stores/inventory.d.ts +85 -0
  48. package/dist/stores/location.d.ts +508 -503
  49. package/dist/stores/netsuite.d.ts +69 -0
  50. package/dist/stores/route.d.ts +0 -5
  51. package/dist/stores/supplier.d.ts +120 -3
  52. package/dist/style.css +1 -1
  53. package/dist/supplier-DLcmVScz.js +70 -0
  54. package/dist/tsconfig.app.tsbuildinfo +1 -1
  55. package/dist/use-template-enabled-locations-2-CdJVJikY.js +85 -0
  56. package/dist/views/closing-template/closing-template-import/ClosingTemplateImportItem.vue.d.ts +12 -0
  57. package/dist/views/closing-template/closing-template-import/ClosingTemplateImportItemProps.d.ts +7 -0
  58. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +1093 -1026
  59. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +1098 -1037
  60. package/dist/views/closing-template/helpers/import-export.helper.d.ts +58 -0
  61. package/dist/views/ingredients/composables/use-ingredient-form.d.ts +2 -2
  62. package/dist/views/receive-request/components/transfer-details/TransferDetailsProps.d.ts +1 -0
  63. package/dist/views/receive-request/components/transfer-form/NetSuiteField.vue.d.ts +45 -0
  64. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +1944 -82
  65. package/dist/views/receive-request/components/transfer-form/TransferFormProps.d.ts +1 -0
  66. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +2351 -284
  67. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +2300 -233
  68. package/dist/views/recipe/composables/use-recipe-form.d.ts +2 -2
  69. package/dist/views/stock/components/StockRecordCard.vue.d.ts +42 -119
  70. package/dist/views/stock/composables/use-stock-action.d.ts +2 -2
  71. package/dist/views/transfer-template/components/transfer-template-details/TransferTemplateDetails.vue.d.ts +0 -2
  72. package/dist/views/transfer-template/components/transfer-template-details/TransferTemplateDetailsProps.d.ts +0 -1
  73. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations-2.d.ts +13 -0
  74. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations.d.ts +71 -85
  75. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-locations.d.ts +39 -2
  76. package/dist/views/transfer-template/components/transfer-template-import/TransferTemplateImport.vue.d.ts +2 -0
  77. package/dist/views/transfer-template/components/transfer-template-import/TransferTemplateImportItem.vue.d.ts +12 -0
  78. package/dist/views/transfer-template/components/transfer-template-import/TransferTemplateImportItemProps.d.ts +9 -0
  79. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +1263 -1466
  80. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +1688 -897
  81. package/dist/views/transfer-template/helpers/import-export.helper.d.ts +76 -0
  82. package/dist/views/transfer-template/helpers/remove-deleted-skus.helper.d.ts +1 -0
  83. package/dist/views/transfer-template/helpers/template-item.error.helper.d.ts +1 -0
  84. package/dist/views/unit/composables/use-unit-form.d.ts +2 -2
  85. package/dist/{xlsx-BggStaH1.js → xlsx-CrKrCGZz.js} +1525 -1525
  86. package/dist/xlsx.util-Bcpkvw1Z.js +78 -0
  87. package/package.json +5 -5
  88. package/dist/ClosingTemplateView-DdZlX1ug.js +0 -1030
  89. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-ZYtBNoaE.js +0 -372
  90. package/dist/IngredientsView-DnwwQJTN.js +0 -1758
  91. package/dist/PremiumBadge.vue_vue_type_script_setup_true_lang-Bom_KvXW.js +0 -88
  92. package/dist/ReceiveRequestView-D5HXMY4Z.js +0 -215
  93. package/dist/RecipeView-BHkTgm5H.js +0 -581
  94. package/dist/StockView-iczCFYxn.js +0 -1892
  95. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-EN3JgHKF.js +0 -740
  96. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-DC0Ss5hi.js +0 -1409
  97. package/dist/TransferTemplateView-Bbvpuys7.js +0 -1230
  98. package/dist/defineDeepModel-BOApqV24.js +0 -13
  99. package/dist/format-time-from-id-Cafjo8fn.js +0 -15
  100. package/dist/id-to-date-CtSHSVJF.js +0 -30
  101. package/dist/layout/layout-routes.d.ts +0 -6
  102. package/dist/purchase-order-transaction-type-CIC5h-6x.js +0 -712
  103. package/dist/supplier-CM-vZ4bQ.js +0 -69
  104. package/dist/use-template-enabled-locations-Bm00vEzC.js +0 -57
  105. package/dist/xlsx.util-CqlYZLKW.js +0 -109
  106. /package/dist/{layout/InventoryLayout.vue.d.ts → views/closing-template/closing-template-import/ClosingTemplateImport.vue.d.ts} +0 -0
@@ -0,0 +1,1611 @@
1
+ import { ref as O, defineComponent as le, computed as C, resolveComponent as U, openBlock as g, createBlock as T, withCtx as S, createVNode as p, unref as u, createElementBlock as P, Fragment as q, createElementVNode as d, createCommentVNode as Y, onMounted as nt, watch as ze, normalizeClass as J, createTextVNode as He, toDisplayString as L, renderList as Q, isRef as Ee, createSlots as Oe, normalizeStyle as ot, Teleport as Re, normalizeProps as lt, guardReactiveProps as rt } from "vue";
2
+ import { u as X, c as je, S as at, _ as st, A as ge, a as Ye, g as be, t as Ge, F as ue, 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 ct, I as mt, i as pt } from "./app-DKE_n9Mo.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 G, D as Pe, R as ye } from "./row-action.enum-PMKMRrZR.js";
6
+ import { useI18n as Z, useCoreStore as de } 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-Cc_P0kss.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-DMOalXUS.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-Bcpkvw1Z.js";
14
+ import { F as Mt } from "./FmDroppableField-CJNAT3h2.js";
15
+ const Fe = bt("ingredientForm", function() {
16
+ const a = We(), f = he(), s = X(), n = O(!1), { t: l } = Z(), o = O();
17
+ function m() {
18
+ const b = {
19
+ unit: {},
20
+ mode: G.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: G.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: m,
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 } = Z();
94
+ async function s(l, o) {
95
+ const m = je(o);
96
+ if (l === ye.Edit) {
97
+ await r(m);
98
+ return;
99
+ }
100
+ if (l === ye.Delete) {
101
+ await a(m);
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 m;
123
+ const o = l.row.original;
124
+ if (o.trackingMeasurement) {
125
+ const y = (m = o.unit.measurements) == null ? void 0 : m.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__ */ le({
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 } = Z(), m = 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 A = U("FmSwitch"), V = U("FmSelect"), F = U("FmCard");
197
+ return g(), T(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(A, {
205
+ value: "",
206
+ "model-value": m.value,
207
+ "onUpdate:modelValue": _[0] || (_[0] = (j) => m.value = j),
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
+ m.value ? (g(), P(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)) : Y("", !0)
229
+ ];
230
+ }),
231
+ _: 1
232
+ });
233
+ };
234
+ }
235
+ });
236
+ function oe() {
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__ */ le({
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 ie;
260
+ const { t: s } = Z(), n = r, l = f, o = X(), m = de(), y = qe();
261
+ function h(t) {
262
+ if (t.length === 0) return;
263
+ const e = t[0], c = n.modelValue ?? {
264
+ unit: o.units.find((x) => x)
265
+ };
266
+ c.unit || (c.unit = e, l("update:modelValue", c));
267
+ }
268
+ nt(() => {
269
+ h(o.units);
270
+ }), ze([() => o.units], ([t]) => {
271
+ h(t);
272
+ });
273
+ function v() {
274
+ l("click:submit");
275
+ }
276
+ const b = C({
277
+ get() {
278
+ var t;
279
+ return ((t = n.modelValue) == null ? void 0 : t.code) ?? "";
280
+ },
281
+ set(t) {
282
+ const e = n.modelValue ? {
283
+ ...n.modelValue
284
+ } : {};
285
+ e.code = t, l("update:modelValue", e);
286
+ }
287
+ }), i = C({
288
+ get() {
289
+ var t;
290
+ return ((t = n.modelValue) == null ? void 0 : t.name) ?? "";
291
+ },
292
+ set(t) {
293
+ const e = n.modelValue ? {
294
+ ...n.modelValue
295
+ } : {};
296
+ e.name = t, l("update:modelValue", e);
297
+ }
298
+ }), _ = C({
299
+ get() {
300
+ var e, c;
301
+ const t = (c = (e = n.modelValue) == null ? void 0 : e.defaultCost) == null ? void 0 : c.costPerUnit;
302
+ return t ? +Ye(t) : 0;
303
+ },
304
+ set(t) {
305
+ var c, x, R, M;
306
+ const e = n.modelValue ? {
307
+ ...n.modelValue
308
+ } : {};
309
+ e.defaultCost ?? (e.defaultCost = {
310
+ costPerUnit: {
311
+ amount: 0,
312
+ precision: 2,
313
+ currency: ((c = be(m.currentCountry.value)) == null ? void 0 : c.currency) ?? "MYR"
314
+ },
315
+ measurement: (M = (R = (x = n.modelValue) == null ? void 0 : x.unit) == null ? void 0 : R.measurements) == null ? void 0 : M.find(
316
+ (N) => {
317
+ var z;
318
+ return N.id === ((z = n.modelValue) == null ? void 0 : z.trackingMeasurement);
319
+ }
320
+ )
321
+ }), e.defaultCost.costPerUnit = {
322
+ ...e.defaultCost.costPerUnit,
323
+ ...Ge(+t, 4)
324
+ }, l("update:modelValue", e);
325
+ }
326
+ }), A = C(() => {
327
+ var e, c, x;
328
+ const t = ((e = n.modelValue) == null ? void 0 : e.unit) ?? o.units.find((R) => R);
329
+ return t ? {
330
+ _id: t._id,
331
+ measurement: (c = n.modelValue) == null ? void 0 : c.trackingMeasurement,
332
+ name: ((x = t.measurements.find((R) => {
333
+ var M;
334
+ return R.id === ((M = n.modelValue) == null ? void 0 : M.trackingMeasurement);
335
+ })) == null ? void 0 : x.name) ?? t.name
336
+ } : null;
337
+ }), V = C({
338
+ get() {
339
+ var t;
340
+ return ((t = n.modelValue) == null ? void 0 : t.operationalGroup) ?? null;
341
+ },
342
+ set(t) {
343
+ const e = n.modelValue ? {
344
+ ...n.modelValue
345
+ } : {};
346
+ e.operationalGroup = t, l("update:modelValue", e);
347
+ }
348
+ }), F = C(
349
+ () => [
350
+ ...new Set(
351
+ o.skus.map((t) => t.operationalGroup ?? "").filter((t) => t && !Object.values(Me).includes(t))
352
+ )
353
+ ].sort()
354
+ ), w = C({
355
+ get() {
356
+ return V.value !== null;
357
+ },
358
+ set(t) {
359
+ t ? V.value = "" : V.value = null;
360
+ }
361
+ }), I = C(
362
+ () => o.units.flatMap(({ name: t, _id: e, abbrev: c, measurements: x }) => [
363
+ {
364
+ label: `${t}`,
365
+ value: null,
366
+ displayAsSection: !0
367
+ },
368
+ {
369
+ label: `${t} (${c})`,
370
+ value: { _id: e },
371
+ displayAsSection: !1
372
+ },
373
+ ...x.map(({ id: R, name: M, abbrev: N }) => ({
374
+ label: `${M} (${N})`,
375
+ value: { _id: e, measurement: R },
376
+ displayAsSection: !1
377
+ }))
378
+ ])
379
+ );
380
+ function j(t) {
381
+ var e, c, x, R, M;
382
+ return ((c = (e = n.modelValue) == null ? void 0 : e.unit) == null ? void 0 : c._id) === ((x = t.value) == null ? void 0 : x._id) && ((R = n.modelValue) == null ? void 0 : R.trackingMeasurement) === ((M = t.value) == null ? void 0 : M.measurement);
383
+ }
384
+ function ee(t) {
385
+ var N, z;
386
+ if (!t) return;
387
+ const { _id: e, measurement: c } = t, x = c || void 0, R = o.units.find((ne) => ne._id === e);
388
+ if (!R)
389
+ return;
390
+ const M = n.modelValue ?? {};
391
+ M.unit = R, M.trackingMeasurement = x, M.convert && (M.convert.measurement = x || null), y.enableTotalCost && (M.defaultCost = {
392
+ measurement: R.measurements.find((ne) => ne.id === x),
393
+ costPerUnit: {
394
+ ...((N = M.defaultCost) == null ? void 0 : N.costPerUnit) ?? {
395
+ amount: 0,
396
+ precision: 2,
397
+ currency: ((z = be(m.currentCountry.value)) == null ? void 0 : z.currency) ?? "MYR"
398
+ }
399
+ }
400
+ }), l("update:modelValue", M);
401
+ }
402
+ const ce = C({
403
+ get() {
404
+ var t;
405
+ return ((t = n.modelValue) == null ? void 0 : t.convert) ?? null;
406
+ },
407
+ set(t) {
408
+ const e = n.modelValue ? {
409
+ ...n.modelValue
410
+ } : {};
411
+ t ? e.convert = t : e.convert = null, l("update:modelValue", e);
412
+ }
413
+ }), _e = C(() => ue.options.filter(
414
+ (t) => t === ue.enum.FIFO || t === ue.enum.WAVG
415
+ ).map((t) => ({
416
+ label: s(`inventory.ingredient.valuationMethod.${t}`),
417
+ value: t
418
+ }))), me = C({
419
+ get() {
420
+ var t;
421
+ return ((t = n.modelValue) == null ? void 0 : t.valuation) ?? "WAVG";
422
+ },
423
+ set(t) {
424
+ const e = n.modelValue ? {
425
+ ...n.modelValue
426
+ } : {};
427
+ e.valuation = t, l("update:modelValue", e);
428
+ }
429
+ }), te = O();
430
+ a({
431
+ validateInputs: () => {
432
+ var t, e;
433
+ (e = (t = te.value) == null ? void 0 : t.validateInputs) == null || e.call(t);
434
+ },
435
+ resetInputsValidation: () => {
436
+ var t, e;
437
+ (e = (t = te.value) == null ? void 0 : t.resetInputsValidation) == null || e.call(t);
438
+ },
439
+ resetInputs: () => {
440
+ var t, e;
441
+ (e = (t = te.value) == null ? void 0 : t.resetInputs) == null || e.call(t);
442
+ }
443
+ });
444
+ const W = O(!1), re = C(
445
+ () => {
446
+ var t, e, c;
447
+ return (t = n.modelValue) != null && t._id ? ((c = o.menu.bindedBySkuId[(e = n.modelValue) == null ? void 0 : e._id]) == null ? void 0 : c.filter(
448
+ (x) => x.from === "INGREDIENT"
449
+ )) ?? [] : [];
450
+ }
451
+ ), pe = C(
452
+ () => {
453
+ var t, e, c;
454
+ return (t = n.modelValue) != null && t._id ? ((c = o.menu.bindedBySkuId[(e = n.modelValue) == null ? void 0 : e._id]) == null ? void 0 : c.filter(
455
+ (x) => x.from === "RECIPE"
456
+ )) ?? [] : [];
457
+ }
458
+ ), ve = C(
459
+ () => {
460
+ var t, e, c;
461
+ return (t = n.modelValue) != null && t._id ? ((c = o.menu.bindedBySkuId[(e = n.modelValue) == null ? void 0 : e._id]) == null ? void 0 : c.filter((x) => x.from === "MENU")) ?? [] : [];
462
+ }
463
+ ), E = C(
464
+ () => o.skus.map((t) => ({ label: t.name, value: t.code }))
465
+ ), $ = O((ie = n.modelValue) == null ? void 0 : ie.code);
466
+ function ae(t) {
467
+ var c;
468
+ const e = t.el;
469
+ e && ((c = e.querySelector("[x-should-scroll-into=true]")) == null || c.scrollIntoView());
470
+ }
471
+ function K(t) {
472
+ switch (t) {
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 se = C(
484
+ () => {
485
+ var t, e, c, x, R, M;
486
+ return ((x = (c = (e = (t = n.modelValue) == null ? void 0 : t.unit) == null ? void 0 : e.measurements) == null ? void 0 : c.find(
487
+ (N) => {
488
+ var z;
489
+ return N.id === ((z = n.modelValue) == null ? void 0 : z.trackingMeasurement);
490
+ }
491
+ )) == null ? void 0 : x.abbrev) ?? ((M = (R = n.modelValue) == null ? void 0 : R.unit) == null ? void 0 : M.abbrev);
492
+ }
493
+ ), D = C({
494
+ get() {
495
+ var t, e;
496
+ return ((e = (t = n.modelValue) == null ? void 0 : t.thresholds) == null ? void 0 : e.low) ?? oe().low;
497
+ },
498
+ set(t) {
499
+ var x;
500
+ const e = ((x = n.modelValue) == null ? void 0 : x.thresholds) ?? oe();
501
+ e.low = t;
502
+ const c = n.modelValue ? {
503
+ ...n.modelValue
504
+ } : {};
505
+ c.thresholds = e, l("update:modelValue", c);
506
+ }
507
+ }), B = C({
508
+ get() {
509
+ var t, e;
510
+ return ((e = (t = n.modelValue) == null ? void 0 : t.thresholds) == null ? void 0 : e.mid) ?? oe().mid;
511
+ },
512
+ set(t) {
513
+ var x;
514
+ const e = ((x = n.modelValue) == null ? void 0 : x.thresholds) ?? oe();
515
+ e.mid = t;
516
+ const c = n.modelValue ? {
517
+ ...n.modelValue
518
+ } : {};
519
+ c.thresholds = e, l("update:modelValue", c);
520
+ }
521
+ });
522
+ function fe() {
523
+ return function(e) {
524
+ 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;
525
+ };
526
+ }
527
+ return (t, e) => {
528
+ const c = U("FmTextField"), x = U("FmLabel"), R = U("FmField"), M = U("FmMenuHeader"), N = U("FmMenuDivider"), z = U("FmMenuItem"), ne = 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(), T(tt, {
530
+ disabled: t.disabled,
531
+ ref_key: "formRef",
532
+ ref: te,
533
+ class: "flex flex-col gap-32",
534
+ onValidationSuccess: v
535
+ }, {
536
+ default: S(() => [
537
+ d("div", $t, [
538
+ d("div", Et, [
539
+ p(c, {
540
+ label: u(s)("inventory.ingredient.code"),
541
+ "model-value": b.value,
542
+ "onUpdate:modelValue": e[0] || (e[0] = (k) => b.value = k),
543
+ rules: [u(xe)(), u(it)(E.value, $.value)],
544
+ "label-mark": "required"
545
+ }, null, 8, ["label", "model-value", "rules"])
546
+ ]),
547
+ d("div", Rt, [
548
+ p(c, {
549
+ label: u(s)("inventory.ingredient.name"),
550
+ "model-value": i.value,
551
+ "onUpdate:modelValue": e[1] || (e[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": A.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(ne, null, {
569
+ "menu-button": S(() => [
570
+ p(R, {
571
+ class: J([
572
+ "fm-typo-en-body-lg-400",
573
+ {
574
+ "text-fm-color-typo-primary": !t.disabled,
575
+ "text-fm-color-typo-disabled": t.disabled
576
+ }
577
+ ]),
578
+ invalid: k,
579
+ "append-icon": "expand_more"
580
+ }, {
581
+ default: S(() => {
582
+ var H;
583
+ return [
584
+ He(L((H = A.value) == null ? void 0 : H.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: ae
594
+ }, [
595
+ (g(!0), P(q, null, Q(I.value, (H) => (g(), P(q, {
596
+ key: H.label
597
+ }, [
598
+ H.displayAsSection ? (g(), P(q, { key: 0 }, [
599
+ p(M, {
600
+ label: H.label
601
+ }, null, 8, ["label"]),
602
+ p(N)
603
+ ], 64)) : (g(), T(z, {
604
+ key: 1,
605
+ label: H.label,
606
+ "model-value": j(H),
607
+ onClick: (Rn) => ee(H.value),
608
+ "x-should-scroll-into": `${j(H)}`
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(), T(Xe, {
619
+ key: 0,
620
+ class: "col-span-1",
621
+ "model-value": me.value,
622
+ "onUpdate:modelValue": e[2] || (e[2] = (k) => me.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"])) : Y("", !0),
637
+ u(y).enableTotalCost ? (g(), T(c, {
638
+ key: 1,
639
+ "model-value": _.value,
640
+ "onUpdate:modelValue": e[3] || (e[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, H;
655
+ return [
656
+ d("div", At, L(K(((k = u(m).currentCountry) == null ? void 0 : k.value) ?? u(Ae)) === "MYR" ? "RM" : K(((H = u(m).currentCountry) == null ? void 0 : H.value) ?? u(Ae))), 1)
657
+ ];
658
+ }),
659
+ append: S(() => [
660
+ d("div", Dt, " / " + L(se.value), 1)
661
+ ]),
662
+ _: 1
663
+ }, 8, ["model-value", "rules"])) : Y("", !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": e[4] || (e[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(), T(ne, { key: 0 }, {
678
+ "menu-button": S(() => [
679
+ p(c, {
680
+ label: "Operational label",
681
+ modelValue: V.value,
682
+ "onUpdate:modelValue": e[5] || (e[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), P(q, null, Q(Object.values(Me), (k) => (g(), T(z, {
696
+ key: k,
697
+ label: k,
698
+ "model-value": V.value === k,
699
+ onClick: (H) => V.value = k
700
+ }, null, 8, ["label", "model-value", "onClick"]))), 128)),
701
+ F.value.length ? (g(), T(M, {
702
+ key: 0,
703
+ label: "Custom"
704
+ })) : Y("", !0),
705
+ (g(!0), P(q, null, Q(F.value, (k) => (g(), T(z, {
706
+ key: k,
707
+ label: k,
708
+ "model-value": V.value === k,
709
+ onClick: (H) => V.value = k
710
+ }, null, 8, ["label", "model-value", "onClick"]))), 128))
711
+ ]),
712
+ _: 1
713
+ })) : Y("", !0)
714
+ ]),
715
+ _: 1
716
+ }),
717
+ p(Ut, {
718
+ "model-value": ce.value,
719
+ "onUpdate:modelValue": e[6] || (e[6] = (k) => ce.value = k),
720
+ "root-value": t.modelValue
721
+ }, null, 8, ["model-value", "root-value"]),
722
+ t.mode !== u(G).CREATE ? (g(), P("div", Pt, [
723
+ d("div", null, [
724
+ p(Ue, {
725
+ label: u(s)("inventory.ingredient.bindedItems.title"),
726
+ modelValue: W.value,
727
+ "onUpdate:modelValue": e[7] || (e[7] = (k) => W.value = k),
728
+ "label-placement": "right"
729
+ }, null, 8, ["label", "modelValue"])
730
+ ]),
731
+ W.value && re.value.length ? (g(), T(we, {
732
+ key: 0,
733
+ name: u(s)("inventory.ingredient.bindedItems.ingredient"),
734
+ bindings: re.value
735
+ }, null, 8, ["name", "bindings"])) : Y("", !0),
736
+ W.value && pe.value.length ? (g(), T(we, {
737
+ key: 1,
738
+ name: u(s)("inventory.ingredient.bindedItems.recipe"),
739
+ bindings: pe.value
740
+ }, null, 8, ["name", "bindings"])) : Y("", !0),
741
+ W.value && ve.value.length ? (g(), T(we, {
742
+ key: 2,
743
+ name: u(s)("inventory.ingredient.bindedItems.menu"),
744
+ bindings: ve.value
745
+ }, null, 8, ["name", "bindings"])) : Y("", !0)
746
+ ])) : Y("", !0),
747
+ d("div", Bt, [
748
+ d("div", Lt, [
749
+ p(Se, null, {
750
+ default: S(() => [
751
+ d("div", Nt, L(u(s)("inventory.ingredient.threshold.title")), 1)
752
+ ]),
753
+ _: 1
754
+ }),
755
+ d("div", zt, L(u(s)("inventory.ingredient.threshold.subtitle")), 1)
756
+ ]),
757
+ d("div", Ht, [
758
+ p(Ie, {
759
+ "model-value": { low: D.value, mid: B.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: D.value,
767
+ level: u(Ce).low
768
+ }, null, 8, ["days", "level"])
769
+ ]),
770
+ d("div", Gt, [
771
+ d("div", qt, L(u(s)("inventory.ingredient.threshold.whenRemaining")), 1),
772
+ p($e, {
773
+ modelValue: D.value,
774
+ "onUpdate:modelValue": e[8] || (e[8] = (k) => D.value = k),
775
+ rules: [u(ge)(0)]
776
+ }, {
777
+ append: S(() => e[10] || (e[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
+ e[12] || (e[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: B.value,
800
+ level: u(Ce).mid
801
+ }, null, 8, ["days", "level"])
802
+ ]),
803
+ d("div", Jt, [
804
+ d("div", Qt, L(u(s)("inventory.ingredient.threshold.whenRemaining")), 1),
805
+ p($e, {
806
+ modelValue: B.value,
807
+ "onUpdate:modelValue": e[9] || (e[9] = (k) => B.value = k),
808
+ rules: [u(ge)(0)]
809
+ }, {
810
+ append: S(() => e[11] || (e[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
+ e[13] || (e[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: B.value + 1,
833
+ level: u(Ce).high
834
+ }, null, 8, ["days", "level"])
835
+ ]),
836
+ d("div", en, [
837
+ d("div", tn, L(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__ */ le({
849
+ __name: "IngredientDialog",
850
+ props: {
851
+ show: { type: Boolean },
852
+ unit: {},
853
+ mode: { default: G.READ }
854
+ },
855
+ emits: ["update:show"],
856
+ setup(r) {
857
+ const a = r, f = X(), s = he(), { t: n } = Z(), l = Te(a, "show"), o = Te(a, "unit"), m = C(() => {
858
+ switch (a.mode) {
859
+ case G.READ:
860
+ return "";
861
+ case G.UPDATE:
862
+ return n("inventory.ingredient.update.title");
863
+ case G.CREATE:
864
+ return n("inventory.ingredient.create.title");
865
+ }
866
+ return "";
867
+ }), y = C(() => {
868
+ switch (a.mode) {
869
+ case G.READ:
870
+ return "";
871
+ case G.UPDATE:
872
+ return n("common.save");
873
+ case G.CREATE:
874
+ return n("common.add");
875
+ }
876
+ return "";
877
+ }), h = O(), v = O(!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 A() {
919
+ switch (a.mode) {
920
+ case G.READ:
921
+ return;
922
+ case G.UPDATE:
923
+ return i();
924
+ case G.CREATE:
925
+ return b();
926
+ }
927
+ }
928
+ return (V, F) => {
929
+ const w = U("FmButton"), I = U("FmSideSheet");
930
+ return g(), T(I, {
931
+ "model-value": u(l),
932
+ "onUpdate:modelValue": F[3] || (F[3] = (j) => Ee(l) ? l.value = j : null),
933
+ header: m.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] = (j) => 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] = (j) => Ee(o) ? o.value = j : null),
960
+ mode: V.mode,
961
+ disabled: v.value,
962
+ "onClick:submit": F[1] || (F[1] = (j) => A())
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((m) => m.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) ?? oe().low,
997
+ thresholdMid: ((o = r.thresholds) == null ? void 0 : o.mid) ?? oe().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 = de(), 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 cn() {
1041
+ const a = X().skus.map(dn), s = de().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}`), m = Ke(l, o), y = `${s == null ? void 0 : s.name} ingredients (${dt(/* @__PURE__ */ new Date())}).xlsx`;
1049
+ return Je(m, y), y;
1050
+ }
1051
+ function mn() {
1052
+ const a = de().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((m) => m.name)
1058
+ ], n = f.map((m) => `system:${m.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
+ ...m
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 m.map((i, _) => {
1079
+ const A = {};
1080
+ for (const V in y) {
1081
+ const F = y[V];
1082
+ Object.assign(A, { [F]: i[V] });
1083
+ }
1084
+ return {
1085
+ index: _,
1086
+ data: A
1087
+ };
1088
+ });
1089
+ }
1090
+ function Le(r, a, f) {
1091
+ var w;
1092
+ const n = X().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 m = n.find((I) => I.abbrev === r.baseUnit), y = m == null ? void 0 : m.measurements.find((I) => I.abbrev === r.unit);
1097
+ if (!m)
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 = ue.options.find(
1104
+ (I) => I === r.valuationMethod
1105
+ );
1106
+ r.valuationMethod && !h && l.push(
1107
+ `Expected valuation method to be one of ${ue.options.join()} but got ${r.valuationMethod} instead.`
1108
+ );
1109
+ const b = de().currentCountry.value, i = (I) => `${I}`.length && mt()(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, A = 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: m ?? n.find((I) => I) ?? un,
1126
+ trackingMeasurement: y == null ? void 0 : y.id,
1127
+ valuation: h,
1128
+ defaultCost: _,
1129
+ thresholds: A
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 = X().skus, n = ct(s, "code"), l = a.filter((h) => !n[h.data.code]), o = a.filter((h) => n[h.data.code]), m = 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: m,
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__ */ le({
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(), P("div", fn, [
1187
+ f[0] || (f[0] = d("div", null, "•", -1)),
1188
+ d("div", yn, [
1189
+ d("div", gn, [
1190
+ d("div", {
1191
+ class: J({
1192
+ "text-fm-color-system-error-300": a.errors.length
1193
+ })
1194
+ }, [
1195
+ He(L(a.name) + " ", 1),
1196
+ a.type === "create" ? (g(), P("span", bn, "(new)")) : Y("", !0)
1197
+ ], 2),
1198
+ a.errors.length ? (g(), P("div", hn, [
1199
+ p(n, { "z-index": 50 }, {
1200
+ content: S(() => [
1201
+ d("ol", null, [
1202
+ (g(!0), P(q, null, Q(a.errors, (l, o) => (g(), P("li", { key: o }, L(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
+ ])) : Y("", !0)
1215
+ ]),
1216
+ d("div", {
1217
+ class: J([
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
+ }, L(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__ */ le({
1239
+ __name: "ImportIngredients",
1240
+ setup(r) {
1241
+ const a = O(null), f = vt(), s = he(), n = O(!1), l = O(new Array()), o = O([]), m = O([]), y = C(
1242
+ () => !!l.value.length || o.value.some((i) => i.errors.length) || m.value.some((i) => i.errors.length)
1243
+ ), h = C(
1244
+ () => !!o.value.length || !!m.value.length
1245
+ ), { t: v } = Z();
1246
+ async function b(i) {
1247
+ l.value = [], o.value = [], m.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
+ ]), A = _.SheetNames.find((F) => F);
1255
+ if (!A) {
1256
+ l.value.push(v("inventory.ingredient.import.fileError.noSheet"));
1257
+ return;
1258
+ }
1259
+ const V = vn(_.Sheets[A]);
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, m.value = V.importUpdateResult, !o.value.length && !m.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 A = U("FmCircularProgress"), V = U("FmIcon"), F = U("FmButton");
1286
+ return g(), P("div", _n, [
1287
+ d("div", xn, L(u(v)("inventory.ingredient.import.uploadDescription")), 1),
1288
+ p(Mt, {
1289
+ class: J({
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: J([
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(), T(A, {
1313
+ key: 0,
1314
+ size: "md",
1315
+ color: "neutral-gray-200"
1316
+ })) : (g(), T(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: J([
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, L(a.value.name), 1)
1332
+ ], 2),
1333
+ n.value ? Y("", !0) : (g(), P("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(), P("div", wn, [
1343
+ (g(!0), P(q, null, Q(l.value, (I, j) => (g(), P("div", {
1344
+ key: j,
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, L(I), 1)
1353
+ ]))), 128))
1354
+ ])) : Y("", !0)
1355
+ ])
1356
+ ]),
1357
+ key: "0"
1358
+ } : void 0
1359
+ ]), 1032, ["class", "label", "button-label"]),
1360
+ h.value ? (g(), P("div", Fn, [
1361
+ d("div", Mn, L(u(v)("inventory.ingredient.import.summary")), 1),
1362
+ (g(!0), P(q, null, Q(o.value, (w) => (g(), T(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), P(q, null, Q(m.value, (w) => (g(), T(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
+ ])) : Y("", !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__ */ le({
1381
+ __name: "IngredientsView",
1382
+ setup(r) {
1383
+ const a = X(), f = C(() => a.skus), s = pt(), n = We(), l = he(), { t: o } = Z(), { createIngredient: m, updateIngredient: y } = Fe(), { ingredientDialogProps: h, ingredientViewLoading: v } = ht(Fe()), { columnDefs: b } = It();
1384
+ function i(E) {
1385
+ switch (E) {
1386
+ case "add":
1387
+ return m();
1388
+ case "import":
1389
+ return re();
1390
+ }
1391
+ }
1392
+ const _ = O(""), A = O(!1), V = C(() => A.value || v.value), { breakpoints: F } = ft(), w = C(() => F.value.xs || F.value.sm), I = C(() => w.value ? 10 : 20), j = Vt(), ee = O(!1), ce = [
1393
+ {
1394
+ value: "import",
1395
+ label: o("common.import")
1396
+ },
1397
+ {
1398
+ value: "export",
1399
+ label: o("common.export")
1400
+ }
1401
+ ];
1402
+ function _e(E) {
1403
+ switch (ee.value = !1, E) {
1404
+ case "import":
1405
+ return re();
1406
+ case "export":
1407
+ return W();
1408
+ }
1409
+ }
1410
+ const me = C(() => w.value ? [{ icon: "more_vert", onClick: ve }] : [{ icon: "ios_share", onClick: W }]), te = C(() => {
1411
+ const E = [
1412
+ {
1413
+ label: o("inventory.ingredient.create.title"),
1414
+ value: "add",
1415
+ isPrimary: !0,
1416
+ prependIcon: "add"
1417
+ }
1418
+ ];
1419
+ return w.value ? E : [...E, { label: o("inventory.ingredient.import.title"), value: "import" }];
1420
+ });
1421
+ function W() {
1422
+ const E = cn();
1423
+ l.open({
1424
+ title: o("inventory.ingredient.export.success"),
1425
+ message: o("inventory.ingredient.export.filename", [E]),
1426
+ type: "success"
1427
+ });
1428
+ }
1429
+ function re() {
1430
+ n.open({
1431
+ title: o("inventory.ingredient.import.title"),
1432
+ contentComponent: In,
1433
+ overlay: !0,
1434
+ closeButton: !0,
1435
+ primaryActions: {
1436
+ text: o("common.import"),
1437
+ close: !1
1438
+ },
1439
+ secondaryActions: {
1440
+ text: o("common.close"),
1441
+ close: !0
1442
+ },
1443
+ tertiaryActions: {
1444
+ text: o("inventory.ingredient.import.actions.downloadTemplate"),
1445
+ close: !1,
1446
+ variant: "plain"
1447
+ }
1448
+ }).onPrimary((E) => {
1449
+ if (!E) {
1450
+ l.open({
1451
+ title: o("inventory.ingredient.import.error.noData"),
1452
+ type: "error"
1453
+ });
1454
+ return;
1455
+ }
1456
+ if (!E.importCreateResult.length && !E.importUpdateResult.length) {
1457
+ l.open({
1458
+ title: o("inventory.ingredient.import.error.invalidContent"),
1459
+ message: o("inventory.ingredient.import.error.noImportData"),
1460
+ type: "error"
1461
+ });
1462
+ return;
1463
+ }
1464
+ if (E.importCreateResult.some(($) => $.errors.length) || E.importUpdateResult.some(($) => $.errors.length)) {
1465
+ l.open({
1466
+ title: o("inventory.ingredient.import.error.invalidContent"),
1467
+ message: o("inventory.ingredient.import.error.hasErrors"),
1468
+ type: "error"
1469
+ });
1470
+ return;
1471
+ }
1472
+ n.close(), pe(E);
1473
+ }).onTertiary(mn);
1474
+ }
1475
+ async function pe(E) {
1476
+ A.value = !0;
1477
+ try {
1478
+ const $ = [
1479
+ ...E.importCreateResult.map(({ sku: D }) => ({ type: "create", sku: D })),
1480
+ ...E.importUpdateResult.map(({ sku: D }) => ({ type: "update", sku: D }))
1481
+ ], ae = 100;
1482
+ let K = 0;
1483
+ const se = () => {
1484
+ K += ae, l.open({
1485
+ title: o("inventory.ingredient.import.progress", [
1486
+ Math.min(K, $.length),
1487
+ $.length
1488
+ ])
1489
+ });
1490
+ };
1491
+ for (const D of $.chunk(100))
1492
+ se(), await a.importSkus({
1493
+ create: D.filter((B) => B.type === "create").map((B) => B.sku),
1494
+ update: D.filter((B) => B.type === "update").map((B) => B.sku)
1495
+ });
1496
+ l.open({
1497
+ title: o("inventory.ingredient.import.success"),
1498
+ type: "success"
1499
+ });
1500
+ } catch ($) {
1501
+ l.open({
1502
+ title: o("inventory.ingredient.import.error.failed"),
1503
+ message: o("inventory.ingredient.import.error.systemMessage", [$ == null ? void 0 : $.message]),
1504
+ type: "error"
1505
+ }), console.error("Error in importing skus", E, $);
1506
+ } finally {
1507
+ A.value = !1;
1508
+ }
1509
+ }
1510
+ function ve() {
1511
+ ee.value = !0;
1512
+ }
1513
+ return (E, $) => {
1514
+ const ae = U("FmTable"), K = U("FmCollapsibleTabs"), se = U("FmBottomSheet");
1515
+ return g(), T(kt, {
1516
+ title: u(o)("inventory.ingredient.title"),
1517
+ actions: te.value,
1518
+ "onClick:action": i
1519
+ }, {
1520
+ default: S(() => [
1521
+ d("div", {
1522
+ class: J([
1523
+ "flex flex-col gap-8 max-h-full",
1524
+ {
1525
+ "p-0": w.value,
1526
+ "px-24 ": !w.value
1527
+ }
1528
+ ])
1529
+ }, [
1530
+ p(Ct, {
1531
+ searchable: "",
1532
+ search: _.value,
1533
+ "onUpdate:search": $[0] || ($[0] = (D) => _.value = D),
1534
+ actions: me.value
1535
+ }, null, 8, ["search", "actions"]),
1536
+ p(ae, {
1537
+ style: ot(u(j).tableHeight),
1538
+ "column-defs": u(b),
1539
+ "row-data": f.value,
1540
+ "search-value": _.value,
1541
+ loading: !u(s)._currentLocation || V.value,
1542
+ "loading-text": "Loading",
1543
+ onRowClick: $[1] || ($[1] = (D) => u(y)(D.original)),
1544
+ "page-size": I.value
1545
+ }, {
1546
+ "list-row": S((D) => [
1547
+ p(xt, {
1548
+ row: D,
1549
+ onRowClick: u(y)
1550
+ }, Oe({
1551
+ default: S((B) => {
1552
+ var fe, ie, t, e, c, x, R, M, N, z;
1553
+ return [
1554
+ d("div", Un, [
1555
+ d("div", $n, [
1556
+ p(u(Be), {
1557
+ render: (t = (ie = (fe = B.code) == null ? void 0 : fe.column) == null ? void 0 : ie.columnDef) == null ? void 0 : t.cell,
1558
+ props: (c = (e = B.code) == null ? void 0 : e.getContext) == null ? void 0 : c.call(e)
1559
+ }, null, 8, ["render", "props"])
1560
+ ]),
1561
+ d("div", En, [
1562
+ p(u(Be), {
1563
+ render: (M = (R = (x = B.name) == null ? void 0 : x.column) == null ? void 0 : R.columnDef) == null ? void 0 : M.cell,
1564
+ props: (z = (N = B.name) == null ? void 0 : N.getContext) == null ? void 0 : z.call(N)
1565
+ }, null, 8, ["render", "props"])
1566
+ ])
1567
+ ])
1568
+ ];
1569
+ }),
1570
+ _: 2
1571
+ }, [
1572
+ A.value ? {
1573
+ name: "loading-text",
1574
+ fn: S(() => [
1575
+ d("div", null, L(u(o)("inventory.ingredient.table.importing")), 1)
1576
+ ]),
1577
+ key: "0"
1578
+ } : void 0
1579
+ ]), 1032, ["row", "onRowClick"])
1580
+ ]),
1581
+ _: 1
1582
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
1583
+ ], 2),
1584
+ (g(), T(Re, { to: "body" }, [
1585
+ p(ln, lt(rt(u(h))), null, 16)
1586
+ ])),
1587
+ (g(), T(Re, { to: "body" }, [
1588
+ p(se, {
1589
+ "dismiss-away": "",
1590
+ modelValue: ee.value,
1591
+ "onUpdate:modelValue": $[3] || ($[3] = (D) => ee.value = D)
1592
+ }, {
1593
+ default: S(() => [
1594
+ p(K, {
1595
+ class: "pb-8",
1596
+ items: ce,
1597
+ "onUpdate:modelValue": $[2] || ($[2] = (D) => _e(D))
1598
+ })
1599
+ ]),
1600
+ _: 1
1601
+ }, 8, ["modelValue"])
1602
+ ]))
1603
+ ]),
1604
+ _: 1
1605
+ }, 8, ["title", "actions"]);
1606
+ };
1607
+ }
1608
+ });
1609
+ export {
1610
+ Wn as default
1611
+ };