@feedmepos/mf-inventory-portal 0.0.25-dev.9 → 0.0.26-dev.1

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