@feedmepos/mf-inventory-portal 0.0.23-dev.3 → 0.0.23-dev.31

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