@feedmepos/mf-inventory-portal 0.0.25-dev.4 → 0.0.25-dev.41

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