@feedmepos/mf-inventory-portal 1.8.0-dev.1 → 1.8.0-dev.3

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 (156) hide show
  1. package/dist/App-DRXADP0k.js +1498 -0
  2. package/dist/{ApprovalView-C8_ax05b.js → ApprovalView-hV1msz5Y.js} +9 -9
  3. package/dist/{BindingsDialog-t0ZY9eh5.js → BindingsDialog-BX1Lopf0.js} +2 -2
  4. package/dist/{BindingsPicker-C0Qblmml.js → BindingsPicker-BNKW8-XY.js} +2 -2
  5. package/dist/{BindingsTable-CsqUBbRA.js → BindingsTable-DiLDsL83.js} +4 -4
  6. package/dist/{BulkReceiveRequestView-DAG-TMox.js → BulkReceiveRequestView-oQh6kFLc.js} +20 -20
  7. package/dist/ChangeLocationComponent.vue_vue_type_script_setup_true_lang-BaMcGU-x.js +151 -0
  8. package/dist/{ClosingDraftView-CdKp4Ny6.js → ClosingDraftView-sgLoaSf4.js} +20 -20
  9. package/dist/{ClosingHistoryView-Blyq9-BS.js → ClosingHistoryView-BnE9HrzA.js} +5 -5
  10. package/dist/{ClosingTemplateView-C326DL4q.js → ClosingTemplateView-BD3Pa11r.js} +302 -291
  11. package/dist/{CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-CXjubRbj.js → CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-DlbyxkMQ.js} +1 -1
  12. package/dist/{DefaultView-CsIMmQAY.js → DefaultView-CuzvVkfE.js} +5 -5
  13. package/dist/{DeliveryOrderPrintPreview-eTrMvJzA.js → DeliveryOrderPrintPreview-w-1aAOY1.js} +2 -2
  14. package/dist/DeprecateSoonWarningDialog.vue_vue_type_script_setup_true_lang-Bp8bjDU1.js +58 -0
  15. package/dist/{EmailDialog.vue_vue_type_script_setup_true_lang-B7nBbxMo.js → EmailDialog.vue_vue_type_script_setup_true_lang-CxD12Qct.js} +1668 -1671
  16. package/dist/FeatureCapabilityBadge.vue_vue_type_script_setup_true_lang-CMoQKl_a.js +308 -0
  17. package/dist/{FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-CI2KTzDs.js → FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-BqCh_vTP.js} +1 -1
  18. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-Db_FiSRe.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CAXnmdUy.js} +2 -2
  19. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-NhOdW33O.js +120 -0
  20. package/dist/{FmMultiselectDialog-BAw-gp5K.js → FmMultiselectDialog-BqZgHP8s.js} +1 -1
  21. package/dist/{FmMultiselectDialog-CYUxtxnS.js → FmMultiselectDialog-CULwA_hi.js} +2 -2
  22. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-DOkV11NN.js → FmUnitInput.vue_vue_type_script_setup_true_lang-CI3Y9kDl.js} +6 -6
  23. package/dist/{ImportView-BmotFC-3.js → ImportView-DqQG673_.js} +6 -6
  24. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-DVCCpvS4.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-DfvNUu80.js} +1 -1
  25. package/dist/IngredientGroupView-CyngKxPo.js +1000 -0
  26. package/dist/{IngredientsView-CZ6E7cXf.js → IngredientsView-pzpP6oXT.js} +309 -296
  27. package/dist/{IntegrationExplorerView-B15ND4Fg.js → IntegrationExplorerView-C5aAhB6e.js} +4 -4
  28. package/dist/{IntegrationView-hkNhsqx2.js → IntegrationView-Bqun7nX0.js} +2403 -2408
  29. package/dist/{InventoryBindingForm-SfuUF0_O.js → InventoryBindingForm-r_Ua1C4a.js} +1 -1
  30. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-Zq81p_MF.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-CYDuu4kU.js} +5 -5
  31. package/dist/{InventoryBindingSummary-DUcukkyJ.js → InventoryBindingSummary-BQuZLohR.js} +1 -1
  32. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BmfROiLM.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-7r-QcJdU.js} +1 -1
  33. package/dist/{ProductionRunDetailView-BwgRX-14.js → ProductionRunDetailView-95fu_CfH.js} +4 -4
  34. package/dist/{ProductionRunLifecycleDialogs.vue_vue_type_script_setup_true_lang-BbNXNhpr.js → ProductionRunLifecycleDialogs.vue_vue_type_script_setup_true_lang-CdOca1tV.js} +7 -7
  35. package/dist/{ProductionRunView-CZU7LY9-.js → ProductionRunView-DIjor_Ix.js} +3 -3
  36. package/dist/{PublishView-DS2FZ66p.js → PublishView-DYObyHQq.js} +3 -3
  37. package/dist/{PurchaseOrderPrintPreview-CZa0MVAs.js → PurchaseOrderPrintPreview-C0jCmI9L.js} +2 -2
  38. package/dist/{ReceiveRequestView-Bk5b3nVB.js → ReceiveRequestView-i7ibPfIE.js} +14 -14
  39. package/dist/{RecipeView-DvI6X-uN.js → RecipeView-C5VO7yr3.js} +18 -18
  40. package/dist/SettingsView-CdBloj9k.js +983 -0
  41. package/dist/{StockView-Z9wGihT7.js → StockView-g_6eJ62R.js} +327 -322
  42. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-DdZg9T4n.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-C1rKc7MA.js} +1 -1
  43. package/dist/{SupplierView-D8q6siZW.js → SupplierView-DkYp_Frj.js} +451 -447
  44. package/dist/{SurchargeView-Db_5YFoR.js → SurchargeView-CfkV4Y3y.js} +7 -7
  45. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-WOVs4Fr1.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-2MtN1p5t.js} +2 -2
  46. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-BtoP4XgE.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CYMjKXq4.js} +1 -1
  47. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-Bljc4Vuy.js → TransferDetails.vue_vue_type_script_setup_true_lang-D0zNr_vQ.js} +21 -21
  48. package/dist/{TransferTemplateView-DtsJzmUr.js → TransferTemplateView-Ne2gYUSn.js} +21 -21
  49. package/dist/{UnitCostHistoryView-BqDiQ4IE.js → UnitCostHistoryView-Db0_otOb.js} +4 -4
  50. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-BjSmg5LX.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-BzO1lq7j.js} +4 -4
  51. package/dist/{UnitView-CM695-VI.js → UnitView-CiCeQ63i.js} +8 -8
  52. package/dist/{WarehouseView-BdidU4p6.js → WarehouseView-BcuJSOMF.js} +193 -189
  53. package/dist/{WastageTemplateView-DdhwdXT6.js → WastageTemplateView-CPQmtOKQ.js} +15 -15
  54. package/dist/api/feature-flags.d.ts +10 -0
  55. package/dist/api/inventory.d.ts +9 -9
  56. package/dist/api/license.d.ts +9 -0
  57. package/dist/{app-Cb5s4jMu.js → app-DqJp3dcI.js} +146 -108
  58. package/dist/app.d.ts +36 -0
  59. package/dist/app.js +1 -1
  60. package/dist/{closing-template-DnqnpXxn.js → closing-template-BNlgZviN.js} +1 -1
  61. package/dist/components/ChangeLocationComponent.vue.d.ts +21 -14
  62. package/dist/components/DeprecateSoonWarningDialog.vue.d.ts +22 -0
  63. package/dist/components/FeatureCapabilityBadge.vue.d.ts +29 -0
  64. package/dist/components/{PreviewBadge.vue.d.ts → FeatureCapabilityGate.vue.d.ts} +10 -7
  65. package/dist/components/MultiLocationSelector.vue.d.ts +6 -6
  66. package/dist/components/{PremiumBadge.vue.d.ts → PlanTierBadge.vue.d.ts} +5 -13
  67. package/dist/components/PlanUpgradeDialog.vue.d.ts +30 -0
  68. package/dist/composable/useNavigationMenu.d.ts +2 -1
  69. package/dist/{inventory-core-dart.default-DDRxXXnt.js → core-Js7d-3Pv.js} +121 -118
  70. package/dist/{date2-BPhD_1Of.js → date2-Ci7521dn.js} +1 -1
  71. package/dist/{dayjs.min-Zbd6-uVD.js → dayjs.min-Cyp32v4J.js} +1 -1
  72. package/dist/{decimal-Df6a50Ld.js → decimal-BGdm5R3A.js} +2 -2
  73. package/dist/{defineDeepModel-Brbsikbi.js → defineDeepModel-B2cJ-rtd.js} +1 -1
  74. package/dist/{duplicate-template-B9kuShaF.js → duplicate-template-By5WeKZ0.js} +1 -1
  75. package/dist/feature-fG7d73oi.js +371 -0
  76. package/dist/feature-flags/core.d.ts +27 -0
  77. package/dist/feature-flags/core.spec.d.ts +1 -0
  78. package/dist/feature-flags/navigation-capabilities.d.ts +23 -0
  79. package/dist/feature-flags/navigation-capabilities.spec.d.ts +1 -0
  80. package/dist/feature-flags/plan-tier.d.ts +6 -0
  81. package/dist/feature-flags/plan-tier.spec.d.ts +1 -0
  82. package/dist/feature-flags/portal-feature-catalog.d.ts +24 -0
  83. package/dist/feature-flags/vue.d.ts +14 -0
  84. package/dist/{format-time-from-id-DmUjUcVj.js → format-time-from-id-Q8C2P96H.js} +1 -1
  85. package/dist/{format-unit-display-CsQA0SQd.js → format-unit-display-CICrmm8r.js} +13 -13
  86. package/dist/id-to-date-DeN5x0LR.js +67 -0
  87. package/dist/{import-export.helper-DCQ6oX9s.js → import-export.helper-BOTQWxr6.js} +28 -28
  88. package/dist/{index-C-mazZwS.js → index-BbbqCCfp.js} +3 -3
  89. package/dist/{index-BXaIMGnI.js → index-Cxm3Sgfv.js} +1 -1
  90. package/dist/index-Dqf27vLH.js +841 -0
  91. package/dist/{index-UmM6gHJ1.js → index-tCYhLCKP.js} +1 -1
  92. package/dist/{lz-string-Bibw5D_6.js → lz-string-Dy4Pg8mh.js} +1 -1
  93. package/dist/{netsuite-Bev0OtQT.js → netsuite-BaJjkDM8.js} +2 -2
  94. package/dist/{number-y_W4pn_d.js → number-CB36d2PQ.js} +3 -3
  95. package/dist/{predefined-templates-BHvUnTk_.js → predefined-templates-DLm93Bpx.js} +1 -1
  96. package/dist/{purchase-order-template-DgOKEzhS.js → purchase-order-template-CDhn9ZIF.js} +1 -1
  97. package/dist/{recalculationUtils-Dv__DzZh.js → recalculationUtils-Cqvefakh.js} +1 -1
  98. package/dist/{row-action.enum-ncgDYAjP.js → row-action.enum-NTfVmGY8.js} +2 -2
  99. package/dist/{rules-CZTBvenw.js → rules-C8dfM84-.js} +2 -2
  100. package/dist/{stock-XINW8JOM.js → stock-BGB0Siue.js} +3 -3
  101. package/dist/{stock-CxCRZo_D.js → stock-Qu5IiN2_.js} +1 -1
  102. package/dist/stores/feature.d.ts +12 -0
  103. package/dist/stores/integration/netsuite.d.ts +2 -2
  104. package/dist/stores/location.d.ts +42 -42
  105. package/dist/stores/supplier.d.ts +48 -48
  106. package/dist/stores/warehouse.d.ts +1 -1
  107. package/dist/{supplier-CkZdeMcl.js → supplier-CZdNOSMN.js} +17 -17
  108. package/dist/{surcharge-FRSFqjGl.js → surcharge-Cm40oJvU.js} +1 -1
  109. package/dist/tsconfig.app.tsbuildinfo +1 -1
  110. package/dist/{uom-rules-Cm1styDr.js → uom-rules-L-IW4Nwk.js} +1 -1
  111. package/dist/{use-ingredient-select-dialog-ntAqHX04.js → use-ingredient-select-dialog-B2TDVJM6.js} +2 -2
  112. package/dist/{use-inventory-binding-dialog-DVIJO8Cl.js → use-inventory-binding-dialog-BJ00hl5f.js} +2 -2
  113. package/dist/{use-template-enabled-locations-CIZqw-Z8.js → use-template-enabled-locations-DYAPMvo9.js} +2 -2
  114. package/dist/{use-transfer-locations-CM5vNttA.js → use-transfer-locations-w-9tymYS.js} +2 -2
  115. package/dist/{useHrmPermission-CslLuBoP.js → useHrmPermission-BFCIo5sA.js} +1 -1
  116. package/dist/useNavigationMenu-BPHAH5sJ.js +352 -0
  117. package/dist/{useSseClient-CCV4mPzD.js → useSseClient-CWjRacRs.js} +1 -1
  118. package/dist/views/adjustment-template/wastage-template/actions.d.ts +36 -36
  119. package/dist/views/adjustment-template/wastage-template/table.d.ts +36 -36
  120. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftApprovalDialog.vue.d.ts +6 -6
  121. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +12 -12
  122. package/dist/views/closing-draft/components/closing-draft-groups/ClosingGroupDetailSideSheet.vue.d.ts +6 -6
  123. package/dist/views/closing-draft/composables/use-closing-draft-import.d.ts +3 -3
  124. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +18 -18
  125. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +45 -45
  126. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +36 -36
  127. package/dist/views/integration/components/IntegrationCard.vue.d.ts +38 -0
  128. package/dist/views/integration/components/netsuite/business/AddLocationDialog.vue.d.ts +36 -36
  129. package/dist/views/integration/components/netsuite/business/AddVendorDialog.vue.d.ts +24 -24
  130. package/dist/views/receive-request/components/transfer-form/TransferFormWithController.vue.d.ts +5 -5
  131. package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +5 -5
  132. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +39 -39
  133. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +35 -35
  134. package/dist/views/receive-request-bulk/composables/use-bulk-receive-request-form.d.ts +34 -34
  135. package/dist/views/receive-request-bulk/composables/use-bulk-receive-request-table.d.ts +6 -6
  136. package/dist/views/settings/FeatureFlagView.vue.d.ts +2 -0
  137. package/dist/views/supplier/components/SupplierForm.vue.d.ts +4 -4
  138. package/dist/views/supplier/composables/use-supplier-table.d.ts +2 -2
  139. package/dist/views/transfer-template/components/transfer-template-dialog/TransferTemplateDialog.vue.d.ts +8 -8
  140. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-locations.d.ts +4 -4
  141. package/dist/views/transfer-template/composables/use-template-item-bulk-editor.d.ts +24 -24
  142. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +48 -48
  143. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +48 -48
  144. package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +2 -2
  145. package/dist/{vue-i18n-C5j4EQhi.js → vue-i18n-S4YQ9w6a.js} +295 -295
  146. package/dist/{xlsx.util-B50OvX4z.js → xlsx.util-CP8_VajN.js} +2 -2
  147. package/package.json +5 -5
  148. package/dist/App-BXgpGzGR.js +0 -1476
  149. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-zcEv1Swg.js +0 -243
  150. package/dist/IngredientGroupView-qrR9ksEn.js +0 -985
  151. package/dist/PremiumBadge.vue_vue_type_script_setup_true_lang-3e3kDsbN.js +0 -93
  152. package/dist/PreviewBadge.vue_vue_type_script_setup_true_lang-DX2MJqL4.js +0 -29
  153. package/dist/SettingsView-sThYErMz.js +0 -698
  154. package/dist/feature-Ckn5ra3z.js +0 -1136
  155. package/dist/useNavigationMenu-CSinmNCY.js +0 -172
  156. /package/dist/components/{FmFeatureFlagDialog.vue.d.ts → DeprecateSoonPill.vue.d.ts} +0 -0
@@ -0,0 +1,1498 @@
1
+ import { ref as k, onUnmounted as mt, computed as R, defineComponent as ce, watch as Z, onMounted as Ve, resolveComponent as Y, createElementBlock as c, openBlock as i, createBlock as pe, createCommentVNode as N, unref as $, createVNode as V, createElementVNode as h, toDisplayString as y, Fragment as j, renderList as oe, withKeys as Me, normalizeClass as ae, withModifiers as pt, withCtx as le, createTextVNode as ie, h as vt, onBeforeUnmount as gt, nextTick as yt, Teleport as ht, normalizeStyle as _t, mergeModels as bt, useModel as xt } from "vue";
2
+ import { _ as wt } from "./empty-placeholder-B0QU467o.js";
3
+ import { u as Ee, a as He, R as ue, d as kt, S as St, b as $t } from "./app-DqJp3dcI.js";
4
+ import { useCoreStore as ve, useI18n as he } from "@feedmepos/mf-common";
5
+ import { useRouter as Ne, useRoute as Ct } from "vue-router";
6
+ import { useFeatureStore as Je } from "./feature-fG7d73oi.js";
7
+ import { u as Lt } from "./netsuite-BaJjkDM8.js";
8
+ import { u as Ye, n as Rt, e as Dt } from "./useNavigationMenu-BPHAH5sJ.js";
9
+ import { useBreakpoints as It } from "@feedmepos/ui-library";
10
+ import { F as We } from "./FmAdminBadge-DlplQOHb.js";
11
+ import { i as Vt, _ as Et } from "./FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-BqCh_vTP.js";
12
+ import { F as Nt } from "./decimal-BGdm5R3A.js";
13
+ import { t as Pt, a as Tt } from "./date2-Ci7521dn.js";
14
+ import { _ as Bt } from "./_plugin-vue_export-helper-CHgC5LLL.js";
15
+ import { u as Ut } from "./useTabStorage-BkIVScW_.js";
16
+ import { _ as Ft, g as Oe } from "./FeatureCapabilityBadge.vue_vue_type_script_setup_true_lang-CMoQKl_a.js";
17
+ import { _ as At } from "./DeprecateSoonWarningDialog.vue_vue_type_script_setup_true_lang-Bp8bjDU1.js";
18
+ import { u as Mt } from "./googlemap-D9vA7GsS.js";
19
+ function Ot() {
20
+ return {
21
+ loadingHookInstalled: !1,
22
+ isLoading: !1
23
+ };
24
+ }
25
+ const me = k(Ot());
26
+ function Kt() {
27
+ const o = Ne();
28
+ if (!me.value.loadingHookInstalled) {
29
+ me.value.loadingHookInstalled = !0;
30
+ const e = o.beforeEach(() => {
31
+ me.value.isLoading = !0;
32
+ }), t = o.afterEach(() => {
33
+ me.value.isLoading = !1;
34
+ });
35
+ mt(() => {
36
+ me.value.loadingHookInstalled = !1, e(), t();
37
+ });
38
+ }
39
+ return {
40
+ get isLoading() {
41
+ return me.value.isLoading;
42
+ }
43
+ };
44
+ }
45
+ function Gt() {
46
+ const { firstAccessibleRouteName: o } = Ye();
47
+ return { hasAnyAccessibleInventoryRoute: R(() => o.value !== null) };
48
+ }
49
+ const zt = {
50
+ key: 0,
51
+ class: "flex flex-col items-center w-full h-full gap-24"
52
+ }, jt = {
53
+ key: 1,
54
+ class: "flex flex-col pt-[200px] gap-32 items-center"
55
+ }, Ht = { class: "flex flex-col gap-12 items-center text-center px-24 max-w-[600px]" }, Jt = { class: "fm-typo-en-title-lg-600" }, Yt = { class: "text-fm-color-typo-secondary fm-typo-en-body-md-400" }, Wt = {
56
+ key: 2,
57
+ class: "flex flex-col pt-[200px] gap-32 items-center"
58
+ }, Xt = { class: "flex flex-col gap-12 items-center text-center px-24 max-w-[1000px]" }, qt = { class: "fm-typo-en-title-lg-600" }, Zt = { class: "text-fm-color-typo-secondary fm-typo-en-body-md-400" }, Qt = { class: "flex gap-16" }, en = { href: "https://feedme.ai/product/inventory/features?tab=plans_%26_prices" }, tn = { href: "https://feedme.ai/form" }, nn = /* @__PURE__ */ ce({
59
+ __name: "InventoryView",
60
+ setup(o) {
61
+ const e = Ee(), t = He(), l = Lt(), a = ve(), s = Ne(), r = Kt(), u = Je(), { t: v } = he(), { hasAnyAccessibleInventoryRoute: p } = Gt();
62
+ Z(
63
+ [() => a.sessionUser.value, () => a.currentBusiness.value],
64
+ ([O, C]) => {
65
+ I(O, C);
66
+ }
67
+ ), Ve(async () => {
68
+ await u.init(), await a.readBusinesses();
69
+ const O = a.sessionUser.value, C = a.currentBusiness.value;
70
+ I(O, C);
71
+ });
72
+ function I(O, C) {
73
+ !O || !C || E();
74
+ }
75
+ async function E() {
76
+ return await e.init(), await l.readSetting().catch((O) => {
77
+ console.error("[all] error on reading netsuite store", O);
78
+ }), await t.init();
79
+ }
80
+ const P = R(() => s.currentRoute.value.name === ue.TRANSFER_TEMPLATE ? u.enablePoTemplate : s.currentRoute.value.name === ue.INGREDIENT_GROUP ? u.enableIngredientGroup : !0), F = R(
81
+ () => s.currentRoute.value.matched.some((O) => {
82
+ var L;
83
+ const C = O.meta, H = C == null ? void 0 : C.validationManifest;
84
+ return (((L = H == null ? void 0 : H.requiredCaslPermissions) == null ? void 0 : L.length) ?? 0) > 0;
85
+ })
86
+ ), Q = R(() => {
87
+ if (!a.sessionUser.value) return !1;
88
+ if (e._locations !== null && e.locations.length === 0) return !0;
89
+ if (!u.isLoaded) return !1;
90
+ const H = s.currentRoute.value.name === ue.LOADING;
91
+ return !p.value && (H || F.value);
92
+ });
93
+ return (O, C) => {
94
+ const H = Y("FmSpacer"), L = Y("FmCircularProgress"), _ = Y("FmButton"), w = Y("RouterView");
95
+ return i(), c("div", null, [
96
+ $(r).isLoading ? (i(), c("div", zt, [
97
+ V(H),
98
+ h("div", null, [
99
+ V(L, { size: "xl" })
100
+ ]),
101
+ C[0] || (C[0] = h("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary pl-8" }, "Loading page...", -1)),
102
+ V(H)
103
+ ])) : Q.value ? (i(), c("div", jt, [
104
+ C[1] || (C[1] = h("img", {
105
+ src: wt,
106
+ alt: "No permission",
107
+ class: "w-[200px] h-[200px]"
108
+ }, null, -1)),
109
+ h("div", Ht, [
110
+ h("div", Jt, y($(v)("inventory.common.noPermission.title")), 1),
111
+ h("div", Yt, y($(v)("inventory.common.noPermission.description")), 1)
112
+ ])
113
+ ])) : P.value ? $(a).sessionUser.value ? (i(), pe(w, { key: 3 })) : N("", !0) : (i(), c("div", Wt, [
114
+ h("div", Xt, [
115
+ h("div", qt, y($(v)("inventory.common.proPlan.title")), 1),
116
+ h("div", Zt, y($(v)("inventory.common.proPlan.subtitle")), 1)
117
+ ]),
118
+ h("div", Qt, [
119
+ h("a", en, [
120
+ V(_, {
121
+ label: $(v)("inventory.common.proPlan.comparePlans"),
122
+ variant: "secondary"
123
+ }, null, 8, ["label"])
124
+ ]),
125
+ h("a", tn, [
126
+ V(_, {
127
+ label: $(v)("inventory.common.proPlan.callUs"),
128
+ "prepend-icon": "call"
129
+ }, null, 8, ["label"])
130
+ ])
131
+ ])
132
+ ]))
133
+ ]);
134
+ };
135
+ }
136
+ }), Le = {
137
+ // Template/PO item rows carry no id of their own — the embedded sku's _id is
138
+ // the element identity, and kit names the element from that object's name
139
+ // field, so an item change reads "Items › <sku name> › …" instead of a bare
140
+ // index. Arrays where the key isn't usable (an element without sku._id, or
141
+ // duplicates) fall back to identity_fields, then positional — unchanged.
142
+ array_keys: { items: "sku._id" },
143
+ identity_fields: ["_id", "id"],
144
+ name_fields: ["name", "code"],
145
+ ignored_fields: [
146
+ "_id",
147
+ "_rev",
148
+ "_deleted",
149
+ "__v",
150
+ "updatedAt",
151
+ "createdAt",
152
+ "updatedBy",
153
+ "createdBy"
154
+ ],
155
+ label_keys: {
156
+ prefix: "inventory.changelog.label.",
157
+ fields: [
158
+ "abbrev",
159
+ "alternatives",
160
+ "amount",
161
+ "code",
162
+ "contains",
163
+ "conversion",
164
+ "convert",
165
+ "costPerUnit",
166
+ "customAttributes",
167
+ "default",
168
+ "defaultCost",
169
+ "defaultRemark",
170
+ "disabledMeasurements",
171
+ "groups",
172
+ "inventoryBindings",
173
+ "isInactive",
174
+ "items",
175
+ "locations",
176
+ "low",
177
+ "measurement",
178
+ "measurements",
179
+ "mid",
180
+ "name",
181
+ "operationalGroup",
182
+ "position",
183
+ "precision",
184
+ "priority",
185
+ "recipe",
186
+ "ref",
187
+ "rules",
188
+ "sku",
189
+ "skuId",
190
+ "thresholds",
191
+ "trackingMeasurement",
192
+ "type",
193
+ "unit",
194
+ "valuation",
195
+ "version"
196
+ ]
197
+ }
198
+ }, Re = {
199
+ ...Le,
200
+ array_keys: {
201
+ measurements: "id",
202
+ "unit.measurements": "id",
203
+ "convert.inventoryBindings": "id",
204
+ "convert.inventoryBindings.alternatives": "_id",
205
+ contains: "id",
206
+ "contains.alternatives": "_id"
207
+ }
208
+ };
209
+ function on(o) {
210
+ return o instanceof St && o.errorResponse.statusCode === 409;
211
+ }
212
+ const _e = kt((o, e) => ({
213
+ /**
214
+ * Commits for one record. recordId is the changelog docId, `${dbName}/${id}`.
215
+ * The dbName scopes the (access-checked) backend route; only the bare id is
216
+ * sent — the backend rebuilds the docId server-side.
217
+ */
218
+ async getRecordChangelog(t, l, a, s) {
219
+ const r = t.indexOf("/");
220
+ if (r < 0) return [];
221
+ const u = t.slice(0, r), v = t.slice(r + 1), p = new URLSearchParams({ id: v });
222
+ l != null && p.set("limit", String(l)), s && p.set("before", s), a && (p.set("explain", "1"), p.set("schema", JSON.stringify(a)));
223
+ const I = `${o.inventoryBackendUrl}/${u}/changelog?${p.toString()}`;
224
+ return await e.get(I);
225
+ },
226
+ /**
227
+ * Purchase orders in a date range, each with when it last changed. The
228
+ * backend joins the orders to their newest commit, so no ids travel and the
229
+ * browser makes one request instead of list-then-ask-for-timestamps.
230
+ */
231
+ async listPurchaseOrders(t, l, a) {
232
+ if (!t) return [];
233
+ const s = new URLSearchParams({ start: l, end: a }), r = `${o.inventoryBackendUrl}/${t}/changelog/purchase-order?${s}`;
234
+ return await e.get(r);
235
+ },
236
+ /**
237
+ * Closing drafts created in a date range, each with when it last changed.
238
+ * Closing groups come back as rows of their own — their submit/approve/
239
+ * reject is recorded against the group document, not its parent.
240
+ */
241
+ async listClosingDrafts(t, l, a) {
242
+ if (!t) return [];
243
+ const s = new URLSearchParams({ start: l, end: a }), r = `${o.inventoryBackendUrl}/${t}/changelog/closing-draft?${s}`;
244
+ return await e.get(r);
245
+ },
246
+ /**
247
+ * A kit-dialect record's whole document, at HEAD or as of (and including)
248
+ * commit `at`. Same dbName/id split as getRecordChangelog. Rejects with a
249
+ * 409 (see isStateConflict) when the record's history predates the kit
250
+ * write path — the backend passthrough for kit httpapi's GET /api/state.
251
+ */
252
+ async getState(t, l, a) {
253
+ const s = new URLSearchParams({ id: l });
254
+ a && s.set("at", a);
255
+ const r = `${o.inventoryBackendUrl}/${t}/changelog/state?${s.toString()}`;
256
+ return await e.get(r);
257
+ },
258
+ /**
259
+ * The domains the browser lists generically, declared in
260
+ * changelog-domains-pkg and served by the backend — a new browsable domain
261
+ * becomes a tab without a portal change. Backends predating the route
262
+ * yield an error the caller treats as "no extra domains".
263
+ */
264
+ async listDomains(t) {
265
+ if (!t) return [];
266
+ const l = `${o.inventoryBackendUrl}/business_${t}/changelog/domains`;
267
+ return await e.get(l);
268
+ },
269
+ /**
270
+ * One generic domain's records, each with when it last changed. Business-
271
+ * scoped: the generic domains are configuration documents of the business
272
+ * db, not of a location.
273
+ */
274
+ async listDomainRecords(t, l) {
275
+ if (!t) return [];
276
+ const a = `${o.inventoryBackendUrl}/business_${t}/changelog/domain/${encodeURIComponent(l)}`;
277
+ return await e.get(a);
278
+ },
279
+ /**
280
+ * One inventory module's records, each with when it last changed. Business-
281
+ * scoped, so the db is `business_<id>` — the same prefixed name the record's
282
+ * own changelog docId carries.
283
+ */
284
+ async listInventory(t, l) {
285
+ if (!t) return [];
286
+ const a = `${o.inventoryBackendUrl}/business_${t}/changelog/inventory?module=${l}`;
287
+ return await e.get(a);
288
+ }
289
+ })), Se = 50;
290
+ function an() {
291
+ const o = _e(), e = k([]), t = k(!1), l = k(!1);
292
+ let a = null, s = 0;
293
+ async function r(v, p, I) {
294
+ const E = ++s;
295
+ if (a = null, l.value = !1, !v) {
296
+ e.value = [];
297
+ return;
298
+ }
299
+ t.value = !0;
300
+ try {
301
+ const P = p ?? Se, F = await o.getRecordChangelog(v, P, I);
302
+ if (E !== s) return;
303
+ e.value = F, p == null && (a = { recordId: v, explain: I }, l.value = F.length === P);
304
+ } catch (P) {
305
+ throw E === s && (e.value = []), P;
306
+ } finally {
307
+ E === s && (t.value = !1);
308
+ }
309
+ }
310
+ async function u() {
311
+ const v = e.value[e.value.length - 1];
312
+ if (!a || !v || t.value || !l.value) return;
313
+ const p = s;
314
+ t.value = !0;
315
+ try {
316
+ const I = await o.getRecordChangelog(a.recordId, Se, a.explain, v.id);
317
+ if (p !== s) return;
318
+ e.value = [...e.value, ...I], l.value = I.length === Se;
319
+ } finally {
320
+ p === s && (t.value = !1);
321
+ }
322
+ }
323
+ return { commits: e, isLoading: t, hasMore: l, load: r, loadMore: u };
324
+ }
325
+ const Xe = 1e3;
326
+ function Ke(o) {
327
+ const e = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(?:\.(\d+))?/.exec(o);
328
+ return e ? `${e[1]}.${(e[2] ?? "").padEnd(9, "0").slice(0, 9)}` : o;
329
+ }
330
+ function sn(o, e) {
331
+ return [...o, ...e].sort(
332
+ (t, l) => Ke(l.at).localeCompare(Ke(t.at)) || l.id.localeCompare(t.id)
333
+ );
334
+ }
335
+ function ln() {
336
+ const o = _e(), e = k([]);
337
+ async function t(l) {
338
+ if (e.value = [], !!l)
339
+ try {
340
+ e.value = await o.getRecordChangelog(
341
+ l,
342
+ Xe,
343
+ Re
344
+ );
345
+ } catch (a) {
346
+ console.error("changelog per-entity load failed", a);
347
+ }
348
+ }
349
+ return { commits: e, load: t };
350
+ }
351
+ function qe(o) {
352
+ if (!o) return null;
353
+ try {
354
+ const e = JSON.parse(o);
355
+ return typeof (e == null ? void 0 : e.changelogLabelKey) == "string" && typeof (e == null ? void 0 : e.verb) == "string" ? {
356
+ labelKey: e.changelogLabelKey,
357
+ verb: e.verb,
358
+ ...typeof e.name == "string" ? { name: e.name } : {}
359
+ } : null;
360
+ } catch {
361
+ return null;
362
+ }
363
+ }
364
+ function Ze(o) {
365
+ return o.startsWith("inventory.changelog.");
366
+ }
367
+ const Qe = "";
368
+ function De(o) {
369
+ const e = o.indexOf(Qe);
370
+ return e === -1 ? { raw: o, human: o } : { raw: o.slice(0, e), human: o.slice(e + 1) };
371
+ }
372
+ const rn = [
373
+ "inventory.changelog.label.recipe",
374
+ "inventory.changelog.label.sku",
375
+ "inventory.changelog.label.unit"
376
+ ], un = [...rn, "Recipe", "Ingredient", "Unit"];
377
+ function cn(o) {
378
+ const { human: e } = De(o);
379
+ if (!e) return { type: "Document", name: "", field: [] };
380
+ const t = e.split(" › ");
381
+ return t.length >= 2 && un.includes(t[0]) ? { type: t[0], name: t[1], field: t.slice(2) } : { type: "Document", name: "", field: t };
382
+ }
383
+ const Ge = 800;
384
+ function et(o, e, t = 2) {
385
+ const l = ze(o), a = ze(e);
386
+ if (!l || !a) return null;
387
+ let s = 0;
388
+ for (; s < l.length && s < a.length && l[s] === a[s]; ) s++;
389
+ let r = 0;
390
+ for (; r < l.length - s && r < a.length - s && l[l.length - 1 - r] === a[a.length - 1 - r]; )
391
+ r++;
392
+ const u = l.slice(s, l.length - r), v = a.slice(s, a.length - r);
393
+ if (u.length > Ge || v.length > Ge) return null;
394
+ const p = (I) => ({ type: "same", text: I });
395
+ return fn(
396
+ [...l.slice(0, s).map(p), ...dn(u, v), ...l.slice(l.length - r).map(p)],
397
+ t
398
+ );
399
+ }
400
+ function ze(o) {
401
+ try {
402
+ const e = JSON.parse(o);
403
+ return e === null || typeof e != "object" ? null : JSON.stringify(e, null, 2).split(`
404
+ `);
405
+ } catch {
406
+ return null;
407
+ }
408
+ }
409
+ function dn(o, e) {
410
+ const t = o.length, l = e.length, a = Array.from({ length: t + 1 }, () => new Uint32Array(l + 1));
411
+ for (let v = t - 1; v >= 0; v--)
412
+ for (let p = l - 1; p >= 0; p--)
413
+ a[v][p] = o[v] === e[p] ? a[v + 1][p + 1] + 1 : Math.max(a[v + 1][p], a[v][p + 1]);
414
+ const s = [];
415
+ let r = 0, u = 0;
416
+ for (; r < t && u < l; )
417
+ o[r] === e[u] ? (s.push({ type: "same", text: o[r] }), r++, u++) : a[r + 1][u] >= a[r][u + 1] ? (s.push({ type: "del", text: o[r] }), r++) : (s.push({ type: "add", text: e[u] }), u++);
418
+ for (; r < t; ) s.push({ type: "del", text: o[r++] });
419
+ for (; u < l; ) s.push({ type: "add", text: e[u++] });
420
+ return s;
421
+ }
422
+ function fn(o, e) {
423
+ const t = o.map(() => !1);
424
+ o.forEach((s, r) => {
425
+ if (s.type !== "same")
426
+ for (let u = Math.max(0, r - e); u <= Math.min(o.length - 1, r + e); u++)
427
+ t[u] = !0;
428
+ });
429
+ const l = [];
430
+ let a = !1;
431
+ return o.forEach((s, r) => {
432
+ t[r] ? (l.push(s), a = !1) : a || (l.push({ type: "skip", text: "⋯" }), a = !0);
433
+ }), l;
434
+ }
435
+ function mn(o, e) {
436
+ let t;
437
+ try {
438
+ t = JSON.parse(o);
439
+ } catch {
440
+ return o;
441
+ }
442
+ return t === null ? "—" : typeof t == "number" ? t.toLocaleString() : typeof t == "boolean" ? e(t ? "inventory.changelog.yes" : "inventory.changelog.no") : String(t);
443
+ }
444
+ function Ie(o, e, t = 0, l) {
445
+ var p;
446
+ const a = o.label == null ? void 0 : Ze(o.label) ? e(o.label) : o.label, s = a != null || o.value != null || o.display != null, r = !((p = o.kids) != null && p.length), u = [];
447
+ s && u.push({
448
+ depth: t,
449
+ // A bare array index says nothing a reader needs — a leaf list entry
450
+ // shows just its value. Branch nodes keep the index as their header.
451
+ label: a != null && r && /^\d+$/.test(a) ? void 0 : a,
452
+ text: r ? pn(o, e, l) : void 0,
453
+ bookkeeping: !!o.bookkeeping
454
+ });
455
+ const v = s ? t + 1 : t;
456
+ for (const I of o.kids ?? [])
457
+ u.push(...Ie(I, e, v, l));
458
+ return u;
459
+ }
460
+ function pn(o, e, t) {
461
+ if (o.value == null) return o.display || void 0;
462
+ const l = mn(o.value, e);
463
+ return (t == null ? void 0 : t(l)) ?? o.display ?? l;
464
+ }
465
+ function $e(o, e) {
466
+ return JSON.stringify(o, null, 2).split(`
467
+ `).map((t) => ({ type: e, text: t }));
468
+ }
469
+ function vn() {
470
+ const o = _e(), e = /* @__PURE__ */ new Map(), t = k(!1), l = k(null);
471
+ async function a(s) {
472
+ const r = e.get(s.id);
473
+ if (r) {
474
+ l.value = r;
475
+ return;
476
+ }
477
+ t.value = !0;
478
+ try {
479
+ const u = s.doc_id.indexOf("/"), v = s.doc_id.slice(0, u), p = s.doc_id.slice(u + 1), [I, E] = await Promise.all([
480
+ s.parent ? o.getState(v, p, s.parent) : Promise.resolve({}),
481
+ o.getState(v, p, s.id)
482
+ ]), F = { diff: s.parent ? et(JSON.stringify(I), JSON.stringify(E)) ?? [
483
+ ...$e(I, "del"),
484
+ ...$e(E, "add")
485
+ ] : $e(E, "add"), conflict: !1 };
486
+ e.set(s.id, F), l.value = F;
487
+ } catch (u) {
488
+ if (!on(u))
489
+ throw l.value = null, u;
490
+ const v = { diff: null, conflict: !0 };
491
+ e.set(s.id, v), l.value = v;
492
+ } finally {
493
+ t.value = !1;
494
+ }
495
+ }
496
+ return { isLoading: t, result: l, load: a };
497
+ }
498
+ const gn = {
499
+ key: 0,
500
+ class: "flex justify-center p-16"
501
+ }, yn = {
502
+ key: 1,
503
+ class: "p-16 text-center text-gray-500"
504
+ }, hn = {
505
+ key: 2,
506
+ class: "flex h-full min-h-0 gap-8"
507
+ }, _n = { class: "w-1/3 shrink-0 overflow-y-auto border-r border-gray-200 pr-4" }, bn = ["onClick", "onKeydown"], xn = { class: "fm-typo-en-body-md-600" }, wn = { class: "text-xs text-gray-500" }, kn = {
508
+ key: 0,
509
+ class: "flex-1 overflow-y-auto pl-4"
510
+ }, Sn = { class: "mb-12 flex flex-col gap-2 border-b border-gray-200 pb-8" }, $n = { class: "flex flex-wrap items-center gap-8" }, Cn = { class: "fm-typo-en-body-lg-600" }, Ln = {
511
+ key: 0,
512
+ class: "rounded-full bg-gray-100 px-8 text-xs text-gray-500"
513
+ }, Rn = { class: "text-xs text-gray-500" }, Dn = { class: "mb-12" }, In = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary pl-8" }, Vn = {
514
+ key: 0,
515
+ class: "mb-12"
516
+ }, En = {
517
+ key: 1,
518
+ class: "text-sm text-gray-400"
519
+ }, Nn = {
520
+ key: 2,
521
+ class: "w-full overflow-x-auto rounded border border-gray-200 py-4 font-mono text-xs"
522
+ }, Pn = {
523
+ key: 0,
524
+ class: "text-xs text-gray-400"
525
+ }, Tn = { class: "fm-typo-en-body-md-600" }, Bn = { class: "flex flex-col gap-6" }, Un = {
526
+ key: 0,
527
+ class: "text-gray-700"
528
+ }, Fn = { class: "min-w-[120px] shrink-0 text-gray-500" }, An = {
529
+ key: 0,
530
+ class: "flex w-full flex-col gap-4"
531
+ }, Mn = {
532
+ key: 0,
533
+ class: "w-full overflow-x-auto rounded border border-gray-200 py-4 font-mono text-xs"
534
+ }, On = { key: 0 }, Kn = { key: 1 }, Gn = {
535
+ key: 1,
536
+ class: "w-full overflow-x-auto rounded border border-gray-200 py-4 font-mono text-xs"
537
+ }, zn = { key: 0 }, jn = { key: 1 }, Hn = {
538
+ key: 1,
539
+ class: "w-full overflow-x-auto rounded border border-gray-200 py-4 font-mono text-xs"
540
+ }, Jn = {
541
+ key: 2,
542
+ class: "flex w-full flex-wrap items-baseline gap-4"
543
+ }, Yn = {
544
+ key: 0,
545
+ class: "rounded bg-red-50 px-4 text-red-700"
546
+ }, Wn = {
547
+ key: 1,
548
+ class: "text-gray-400"
549
+ }, Xn = {
550
+ key: 2,
551
+ class: "rounded bg-green-50 px-4 text-green-700"
552
+ }, qn = {
553
+ key: 1,
554
+ class: "text-sm text-gray-500"
555
+ }, Zn = {
556
+ key: 2,
557
+ class: "mt-16 break-all border-t border-gray-200 pt-8 font-mono text-xs text-gray-400"
558
+ }, Qn = { key: 0 }, eo = "capture baseline", to = /* @__PURE__ */ ce({
559
+ __name: "ChangelogPanel",
560
+ props: {
561
+ commits: {},
562
+ isLoading: { type: Boolean },
563
+ resolveName: { type: Function }
564
+ },
565
+ setup(o) {
566
+ const e = o, { t } = he(), l = k(null), a = R(
567
+ () => e.commits.find((f) => f.id === l.value)
568
+ ), s = /* @__PURE__ */ new Set(["updatedAt", "createdAt", "updatedBy", "createdBy", "_rev"]), r = R(() => {
569
+ var b;
570
+ return (((b = a.value) == null ? void 0 : b.changes) ?? []).filter((M) => {
571
+ const { raw: A } = De(M.path);
572
+ return A === "@payload" || M.from == null && M.to == null ? !1 : !A.split(".").some((X) => s.has(X));
573
+ });
574
+ });
575
+ Z(
576
+ () => e.commits,
577
+ (f) => {
578
+ var b;
579
+ f.find((M) => M.id === l.value) || (l.value = ((b = f[0]) == null ? void 0 : b.id) ?? null);
580
+ },
581
+ { immediate: !0 }
582
+ );
583
+ const u = k(!1), { isLoading: v, result: p, load: I } = vn();
584
+ Z([u, a], ([f, b]) => {
585
+ p.value = null, !(!f || !b) && I(b).catch((M) => {
586
+ console.error("changelog snapshot load failed", M), u.value = !1;
587
+ });
588
+ });
589
+ function E(f) {
590
+ return f ? f.slice(0, 8) : "";
591
+ }
592
+ function P(f) {
593
+ return f ? new Date(f).toLocaleString() : "";
594
+ }
595
+ function F(f) {
596
+ if (f == null) return "";
597
+ let b;
598
+ try {
599
+ b = JSON.parse(f);
600
+ } catch {
601
+ return f;
602
+ }
603
+ return b === null ? "—" : typeof b == "string" ? b : typeof b == "number" ? b.toLocaleString() : typeof b == "boolean" ? t(b ? "inventory.changelog.yes" : "inventory.changelog.no") : JSON.stringify(b, null, 2);
604
+ }
605
+ function Q(f) {
606
+ return (f.authors || []).join(", ") || t("inventory.changelog.unknownActor");
607
+ }
608
+ function O(f) {
609
+ if (f.message === eo) return t("inventory.changelog.captureBaseline");
610
+ const b = qe(f.message);
611
+ if (!b) return f.message || t("inventory.changelog.noMessage");
612
+ const M = C(b.labelKey);
613
+ return b.name ? t(`inventory.changelog.message.${b.verb}`, { module: M, name: b.name }) : t(`inventory.changelog.message.${b.verb}NoName`, { module: M });
614
+ }
615
+ function C(f) {
616
+ return Ze(f) ? t(f) : f;
617
+ }
618
+ const H = (f) => /[^a-zA-Z]/.test(f);
619
+ function L(f, b) {
620
+ return f == null || b == null ? null : et(f, b);
621
+ }
622
+ function _(f) {
623
+ if (!(!f.to_value && !f.from_value))
624
+ return {
625
+ toTree: f.to_value ? Ie(f.to_value, t, 0, e.resolveName) : void 0,
626
+ fromTree: f.from_value ? Ie(f.from_value, t, 0, e.resolveName) : void 0
627
+ };
628
+ }
629
+ function w(f) {
630
+ return f === "add" ? "bg-green-50 text-green-700" : f === "del" ? "bg-red-50 text-red-700" : f === "skip" ? "text-gray-400" : "text-gray-600";
631
+ }
632
+ function B(f) {
633
+ return f.type === "skip" ? f.text : (f.type === "add" ? "+ " : f.type === "del" ? "- " : " ") + f.text;
634
+ }
635
+ const K = R(() => {
636
+ const f = /* @__PURE__ */ new Map(), b = [], M = (g, m) => {
637
+ let T = f.get(g);
638
+ return T || (T = m(), f.set(g, T), b.push(T)), T;
639
+ }, A = () => M("@doc", () => ({ header: "", lines: [] })), X = (g, m) => {
640
+ var U;
641
+ if (g == null) return m;
642
+ let T;
643
+ try {
644
+ T = JSON.parse(g);
645
+ } catch {
646
+ T = g;
647
+ }
648
+ return (typeof T == "string" ? (U = e.resolveName) == null ? void 0 : U.call(e, T) : void 0) ?? m;
649
+ }, J = (g, m, T) => {
650
+ var U, W, ee, te;
651
+ const x = _(m);
652
+ x ? g.lines.push({ label: T, ...x }) : m.from != null && m.to != null ? g.lines.push({
653
+ label: T,
654
+ from: m.from,
655
+ to: m.to,
656
+ diff: L(m.from, m.to),
657
+ fromDisplay: X(m.from, (U = m.display) == null ? void 0 : U.from),
658
+ toDisplay: X(m.to, (W = m.display) == null ? void 0 : W.to)
659
+ }) : m.to != null ? g.lines.push({ label: T, to: m.to, toDisplay: X(m.to, (ee = m.display) == null ? void 0 : ee.to) }) : g.lines.push({ label: T, from: m.from, fromDisplay: X(m.from, (te = m.display) == null ? void 0 : te.from) });
660
+ }, D = (g) => {
661
+ var T;
662
+ const m = g.element;
663
+ if (m) {
664
+ const x = M(`kit:${(m.trail ?? []).join(".")}:${m.id ?? ""}`, () => ({
665
+ kind: (m.trail ?? []).map(C).join(" › "),
666
+ header: m.name || m.id || "",
667
+ lines: []
668
+ }));
669
+ if ((T = g.field) != null && T.length)
670
+ J(x, g, g.field.map(C).join(" › "));
671
+ else {
672
+ x.badge = g.to != null ? "added" : "removed";
673
+ const U = _(g);
674
+ U && x.lines.push(U);
675
+ }
676
+ return;
677
+ }
678
+ J(A(), g, (g.field ?? []).map(C).join(" › "));
679
+ };
680
+ for (const g of r.value) {
681
+ const { raw: m, human: T } = De(g.path);
682
+ if (g.kind === "create" && !m) {
683
+ const ee = _(g);
684
+ A().lines.push(
685
+ ee ? { label: t("inventory.changelog.kind.created"), ...ee } : { text: t("inventory.changelog.kind.created") }
686
+ );
687
+ continue;
688
+ }
689
+ if (!g.path.includes(Qe) && (g.field || g.element)) {
690
+ D(g);
691
+ continue;
692
+ }
693
+ const x = m ? m.split(".") : [], U = T ? T.split(" › ") : [], W = x.findIndex((ee, te) => te > 0 && H(ee));
694
+ if (W > 0 && U.length === x.length) {
695
+ const ee = U[W], te = M(x.slice(0, W + 1).join("."), () => ({
696
+ kind: U.slice(0, W).map(C).join(" › "),
697
+ header: ee,
698
+ lines: []
699
+ })), re = U.slice(W + 1).map(C).join(" › ");
700
+ if (re) J(te, g, re);
701
+ else if (g.from != null && g.to != null) J(te, g, ee);
702
+ else {
703
+ te.badge = g.to != null ? "added" : "removed";
704
+ const de = _(g);
705
+ de && te.lines.push(de);
706
+ }
707
+ continue;
708
+ }
709
+ J(A(), g, U.map(C).join(" › "));
710
+ }
711
+ return b;
712
+ });
713
+ return (f, b) => {
714
+ var X, J;
715
+ const M = Y("FmCircularProgress"), A = Y("FmSwitch");
716
+ return f.isLoading ? (i(), c("div", gn, [
717
+ V(M)
718
+ ])) : f.commits.length ? (i(), c("div", hn, [
719
+ h("ol", _n, [
720
+ (i(!0), c(j, null, oe(f.commits, (D) => (i(), c("li", {
721
+ key: D.id,
722
+ role: "button",
723
+ tabindex: "0",
724
+ class: ae([
725
+ "cursor-pointer border-l-2 py-8 pl-12",
726
+ D.id === l.value ? "border-fm-color-primary bg-fm-color-primary-50" : "border-gray-200 hover:bg-gray-50"
727
+ ]),
728
+ onClick: (g) => l.value = D.id,
729
+ onKeydown: [
730
+ Me((g) => l.value = D.id, ["enter"]),
731
+ Me(pt((g) => l.value = D.id, ["prevent"]), ["space"])
732
+ ]
733
+ }, [
734
+ h("div", xn, y(O(D)), 1),
735
+ h("div", wn, y(Q(D)) + " · " + y(P(D.at)) + " · " + y(E(D.id)), 1)
736
+ ], 42, bn))), 128))
737
+ ]),
738
+ a.value ? (i(), c("div", kn, [
739
+ h("div", Sn, [
740
+ h("div", $n, [
741
+ h("div", Cn, y(O(a.value)), 1),
742
+ a.value.parent ? N("", !0) : (i(), c("span", Ln, y($(t)("inventory.changelog.rootCommit")), 1))
743
+ ]),
744
+ h("div", Rn, y(Q(a.value)) + " · " + y(P(a.value.at)), 1)
745
+ ]),
746
+ h("div", Dn, [
747
+ V(We, null, {
748
+ default: le(() => [
749
+ h("span", In, y($(t)("inventory.changelog.dataDiff")), 1),
750
+ V(A, {
751
+ modelValue: u.value,
752
+ "onUpdate:modelValue": b[0] || (b[0] = (D) => u.value = D)
753
+ }, null, 8, ["modelValue"])
754
+ ]),
755
+ _: 1
756
+ })
757
+ ]),
758
+ u.value ? (i(), c("div", Vn, [
759
+ $(v) ? (i(), pe(M, { key: 0 })) : (X = $(p)) != null && X.conflict ? (i(), c("div", En, y($(t)("inventory.changelog.snapshotUnavailable")), 1)) : (J = $(p)) != null && J.diff ? (i(), c("div", Nn, [
760
+ (i(!0), c(j, null, oe($(p).diff, (D, g) => (i(), c("div", {
761
+ key: g,
762
+ class: ae(["whitespace-pre px-4", w(D.type)])
763
+ }, y(B(D)), 3))), 128))
764
+ ])) : N("", !0)
765
+ ])) : N("", !0),
766
+ (i(!0), c(j, null, oe(K.value, (D, g) => (i(), c("div", {
767
+ key: g,
768
+ class: "mb-12 rounded-lg border border-gray-200 p-12"
769
+ }, [
770
+ D.kind || D.header || D.badge ? (i(), c("div", {
771
+ key: 0,
772
+ class: ae(["flex flex-wrap items-baseline gap-8", D.lines.length ? "mb-8" : ""])
773
+ }, [
774
+ D.kind ? (i(), c("span", Pn, y(D.kind), 1)) : N("", !0),
775
+ h("span", Tn, y(D.header), 1),
776
+ D.badge ? (i(), c("span", {
777
+ key: 1,
778
+ class: ae(["rounded-full px-8 text-xs", D.badge === "added" ? "bg-green-100 text-green-700" : "bg-red-100 text-red-700"])
779
+ }, y(D.badge === "added" ? $(t)("inventory.changelog.added") : $(t)("inventory.changelog.kind.removed")), 3)) : N("", !0)
780
+ ], 2)) : N("", !0),
781
+ h("ul", Bn, [
782
+ (i(!0), c(j, null, oe(D.lines, (m, T) => (i(), c("li", {
783
+ key: T,
784
+ class: "flex flex-wrap items-baseline gap-8 text-sm"
785
+ }, [
786
+ m.text ? (i(), c("span", Un, y(m.text), 1)) : (i(), c(j, { key: 1 }, [
787
+ h("span", Fn, y(m.label), 1),
788
+ m.toTree || m.fromTree ? (i(), c("div", An, [
789
+ m.fromTree ? (i(), c("div", Mn, [
790
+ (i(!0), c(j, null, oe(m.fromTree, (x, U) => (i(), c("div", {
791
+ key: U,
792
+ class: ae(["flex items-baseline gap-4 px-4", x.bookkeeping ? "text-gray-400" : "text-red-700"])
793
+ }, [
794
+ (i(!0), c(j, null, oe(x.depth, (W) => (i(), c("span", {
795
+ key: W,
796
+ class: "inline-block w-16"
797
+ }))), 128)),
798
+ x.label ? (i(), c("span", On, [
799
+ ie(y(x.label), 1),
800
+ x.text ? (i(), c(j, { key: 0 }, [
801
+ ie(":")
802
+ ], 64)) : N("", !0)
803
+ ])) : N("", !0),
804
+ x.text ? (i(), c("span", Kn, y(x.text), 1)) : N("", !0)
805
+ ], 2))), 128))
806
+ ])) : N("", !0),
807
+ m.toTree ? (i(), c("div", Gn, [
808
+ (i(!0), c(j, null, oe(m.toTree, (x, U) => (i(), c("div", {
809
+ key: U,
810
+ class: ae(["flex items-baseline gap-4 px-4", x.bookkeeping ? "text-gray-400" : "text-green-700"])
811
+ }, [
812
+ (i(!0), c(j, null, oe(x.depth, (W) => (i(), c("span", {
813
+ key: W,
814
+ class: "inline-block w-16"
815
+ }))), 128)),
816
+ x.label ? (i(), c("span", zn, [
817
+ ie(y(x.label), 1),
818
+ x.text ? (i(), c(j, { key: 0 }, [
819
+ ie(":")
820
+ ], 64)) : N("", !0)
821
+ ])) : N("", !0),
822
+ x.text ? (i(), c("span", jn, y(x.text), 1)) : N("", !0)
823
+ ], 2))), 128))
824
+ ])) : N("", !0)
825
+ ])) : m.diff ? (i(), c("div", Hn, [
826
+ (i(!0), c(j, null, oe(m.diff, (x, U) => (i(), c("div", {
827
+ key: U,
828
+ class: ae(["whitespace-pre px-4", w(x.type)])
829
+ }, y(B(x)), 3))), 128))
830
+ ])) : (i(), c("span", Jn, [
831
+ m.from != null ? (i(), c("span", Yn, y(m.fromDisplay ?? F(m.from)), 1)) : N("", !0),
832
+ m.from != null && m.to != null ? (i(), c("span", Wn, "→")) : N("", !0),
833
+ m.to != null ? (i(), c("span", Xn, y(m.toDisplay ?? F(m.to)), 1)) : N("", !0)
834
+ ]))
835
+ ], 64))
836
+ ]))), 128))
837
+ ])
838
+ ]))), 128)),
839
+ K.value.length ? N("", !0) : (i(), c("div", qn, y($(t)("inventory.changelog.empty")), 1)),
840
+ u.value ? (i(), c("div", Zn, [
841
+ ie(y(a.value.id) + " ", 1),
842
+ a.value.parent ? (i(), c("span", Qn, "← " + y(a.value.parent), 1)) : N("", !0)
843
+ ])) : N("", !0)
844
+ ])) : N("", !0)
845
+ ])) : (i(), c("div", yn, y($(t)("inventory.changelog.empty")), 1));
846
+ };
847
+ }
848
+ }), no = { class: "flex flex-col gap-8" }, oo = { class: "flex flex-wrap items-center gap-16" }, ao = { class: "fm-typo-en-heading-lg-600" }, so = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, lo = { class: "flex h-full min-h-0 flex-col gap-12 p-16" }, ro = { class: "flex flex-wrap items-center gap-12" }, io = { class: "flex shrink-0 items-center gap-8" }, uo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, co = { class: "flex flex-wrap items-center gap-12" }, fo = {
849
+ key: 0,
850
+ class: "fm-typo-en-body-md-600"
851
+ }, mo = { class: "fm-typo-en-heading-md-600" }, po = {
852
+ key: 0,
853
+ class: "flex justify-center py-8"
854
+ }, Ce = "inventory.changelog.label.", vo = /* @__PURE__ */ ce({
855
+ __name: "ChangelogDialog",
856
+ props: {
857
+ modelValue: { type: Boolean }
858
+ },
859
+ emits: ["update:modelValue"],
860
+ setup(o, { emit: e }) {
861
+ const t = o, l = e, a = R({
862
+ get: () => t.modelValue,
863
+ set: (n) => l("update:modelValue", n)
864
+ }), { t: s } = he(), r = ve(), u = He(), v = Ee(), p = _e(), { breakpoints: I } = It(), E = R(() => I.value.xs || I.value.sm), P = R(() => E.value ? "98vw" : "72vw"), { commits: F, isLoading: Q, hasMore: O, load: C, loadMore: H } = an();
865
+ function L() {
866
+ H().catch((n) => console.error("changelog load more failed", n));
867
+ }
868
+ function _(n) {
869
+ return n ? new Date(n).toLocaleString() : "—";
870
+ }
871
+ function w(n) {
872
+ return [...n].sort((d, S) => (S.lastUpdate ?? "").localeCompare(d.lastUpdate ?? ""));
873
+ }
874
+ function B(n, d, S) {
875
+ C(n, d, S).catch((G) => console.error("changelog load failed", G));
876
+ }
877
+ const K = k([]);
878
+ async function f() {
879
+ var d;
880
+ const n = (d = r.currentBusiness.value) == null ? void 0 : d._id;
881
+ if (n)
882
+ try {
883
+ K.value = await p.listDomains(n);
884
+ } catch (S) {
885
+ console.error("changelog domain list load failed", S), K.value = [];
886
+ }
887
+ }
888
+ const b = R(() => [
889
+ { label: s("inventory.changelog.label.purchaseOrder"), value: "purchaseOrder" },
890
+ { label: s("inventory.changelog.label.closingDraft"), value: "closingDraft" },
891
+ { label: s("inventory.changelog.domainInventory"), value: "inventory" },
892
+ ...K.value.map((n) => ({ label: s(n.labelKey), value: n.domain }))
893
+ ]), M = k(b.value[0]), A = R(() => {
894
+ var n;
895
+ return ((n = M.value) == null ? void 0 : n.value) ?? "purchaseOrder";
896
+ }), X = R(
897
+ () => K.value.some((n) => n.domain === A.value)
898
+ ), J = k(!1), D = R(
899
+ () => ["sku", "recipe", "unit"].map((n) => ({
900
+ label: s(Ce + n),
901
+ value: n
902
+ }))
903
+ ), g = k(D.value[0]), m = R(() => {
904
+ var n;
905
+ return ((n = g.value) == null ? void 0 : n.value) ?? "sku";
906
+ }), T = k(""), x = k(null), U = k(!1), W = R(() => {
907
+ var S;
908
+ const n = (S = r.currentBusiness.value) == null ? void 0 : S._id, d = u.inventory._id;
909
+ return n && d ? `business_${n}/${d}` : "";
910
+ }), ee = R(() => {
911
+ const n = /* @__PURE__ */ new Map(), d = u.inventory;
912
+ for (const S of [d.sku, d.recipe, d.unit, d.skuGroup])
913
+ for (const G of S ?? [])
914
+ G._id && G.name && n.set(G._id, G.name);
915
+ for (const S of d.unit ?? [])
916
+ for (const G of S.measurements ?? []) {
917
+ if (!G.id) continue;
918
+ const q = G.abbrev || G.name;
919
+ if (!q) continue;
920
+ const ne = Nt.toDouble(G.conversion);
921
+ n.set(G.id, ne ? `${q} (1 ${q} = ${ne} ${S.abbrev})` : q);
922
+ }
923
+ return n;
924
+ }), te = (n) => ee.value.get(n), re = k([]), de = k(!1);
925
+ async function Pe() {
926
+ var d;
927
+ const n = (d = r.currentBusiness.value) == null ? void 0 : d._id;
928
+ if (n) {
929
+ de.value = !0;
930
+ try {
931
+ re.value = w(
932
+ await p.listInventory(n, m.value)
933
+ );
934
+ } catch (S) {
935
+ console.error("changelog inventory list load failed", S), re.value = [];
936
+ } finally {
937
+ de.value = !1;
938
+ }
939
+ }
940
+ }
941
+ const tt = R(
942
+ () => U.value ? re.value : re.value.filter((n) => !n.deleted)
943
+ ), nt = R(() => [
944
+ { accessorKey: "id", header: () => s("inventory.closing.draft.table.id"), size: 320 },
945
+ {
946
+ id: "name",
947
+ header: () => s("inventory.common.name"),
948
+ accessorFn: (n) => n.name,
949
+ // Deleted records sit in the same list as live ones, so the row says which
950
+ // it is; nothing else distinguishes them.
951
+ cell: ({ row: n }) => n.original.deleted ? vt(
952
+ "span",
953
+ { "data-deleted": "" },
954
+ `${n.original.name} (${s("inventory.changelog.deleted")})`
955
+ ) : n.original.name
956
+ },
957
+ {
958
+ id: "lastUpdate",
959
+ header: () => s("inventory.changelog.column.lastUpdate"),
960
+ size: 200,
961
+ // Raw ISO is the sort key — clicking the header on formatted dates would
962
+ // order them lexicographically by locale string. Formatted only to display.
963
+ accessorFn: (n) => n.lastUpdate ?? "",
964
+ cell: ({ getValue: n }) => _(n() || void 0)
965
+ }
966
+ ]), { commits: ot, load: at } = ln();
967
+ function st(n) {
968
+ x.value = n, J.value = !0, B(W.value, Xe, Re), n.id && at(`${W.value}/${m.value}/${n.id}`).catch(
969
+ (d) => console.error("changelog per-entity load failed", d)
970
+ );
971
+ }
972
+ function lt(n, d) {
973
+ const S = qe(n.message);
974
+ return S && S.labelKey === Ce + m.value && S.name === d.name ? !0 : (n.changes ?? []).some((G) => {
975
+ const q = cn(G.path);
976
+ return q.type === Ce + m.value && q.name === d.name;
977
+ });
978
+ }
979
+ const rt = R(() => {
980
+ const n = x.value;
981
+ if (!n) return [];
982
+ const d = F.value.filter((S) => lt(S, n));
983
+ return sn(d, ot.value);
984
+ }), be = k([]), xe = k(!1), we = k(null);
985
+ async function it() {
986
+ var d;
987
+ const n = (d = r.currentBusiness.value) == null ? void 0 : d._id;
988
+ if (n) {
989
+ xe.value = !0;
990
+ try {
991
+ be.value = w(
992
+ await p.listDomainRecords(n, A.value)
993
+ );
994
+ } catch (S) {
995
+ console.error("changelog domain records load failed", S), be.value = [];
996
+ } finally {
997
+ xe.value = !1;
998
+ }
999
+ }
1000
+ }
1001
+ function ut(n) {
1002
+ var S;
1003
+ const d = (S = r.currentBusiness.value) == null ? void 0 : S._id;
1004
+ d && (we.value = n, J.value = !0, B(`business_${d}/${n.id}`, void 0, Le));
1005
+ }
1006
+ const ge = k(Vt()), ye = k([]), ke = k(!1), fe = k(null), Te = R(() => {
1007
+ const n = v._currentLocation;
1008
+ return n ? `${n.name} (${n.doc.profile.code ?? "--"})` : "";
1009
+ }), Be = R(() => [
1010
+ { accessorKey: "id", header: () => s("inventory.closing.draft.table.id"), size: 320 },
1011
+ {
1012
+ accessorKey: "name",
1013
+ header: () => A.value === "purchaseOrder" ? s("inventory.changelog.column.seq") : s("inventory.common.name"),
1014
+ size: 240
1015
+ },
1016
+ {
1017
+ id: "lastUpdate",
1018
+ header: () => s("inventory.changelog.column.lastUpdate"),
1019
+ size: 200,
1020
+ // Raw ISO is the sort key; see the note on the inventory table.
1021
+ accessorFn: (n) => n.lastUpdate ?? "",
1022
+ cell: ({ getValue: n }) => _(n() || void 0)
1023
+ }
1024
+ ]);
1025
+ async function Ue() {
1026
+ var G;
1027
+ const n = (G = v._currentLocation) == null ? void 0 : G.dbName;
1028
+ if (!n) return;
1029
+ const d = Pt(new Date(ge.value.startDate)).toISOString(), S = Tt(new Date(ge.value.endDate)).toISOString();
1030
+ ke.value = !0;
1031
+ try {
1032
+ ye.value = w(
1033
+ A.value === "purchaseOrder" ? await p.listPurchaseOrders(n, d, S) : await p.listClosingDrafts(n, d, S)
1034
+ );
1035
+ } catch (q) {
1036
+ console.error("changelog location list load failed", q), ye.value = [];
1037
+ } finally {
1038
+ ke.value = !1;
1039
+ }
1040
+ fe.value && !ye.value.find((q) => {
1041
+ var ne;
1042
+ return q.id === ((ne = fe.value) == null ? void 0 : ne.id);
1043
+ }) && (fe.value = null, B(""));
1044
+ }
1045
+ function ct(n) {
1046
+ fe.value = n, J.value = !0, B(`${v.currentLocationDBName}/${n.id}`, void 0, Le);
1047
+ }
1048
+ const dt = R(() => {
1049
+ var n, d, S;
1050
+ return A.value === "inventory" ? ((n = x.value) == null ? void 0 : n.name) ?? "" : X.value ? ((d = we.value) == null ? void 0 : d.name) ?? "" : ((S = fe.value) == null ? void 0 : S.name) ?? "";
1051
+ });
1052
+ function Fe() {
1053
+ J.value = !1, A.value === "inventory" ? (x.value = null, U.value = !1, B(""), Pe().catch(
1054
+ (n) => console.error("changelog inventory list failed", n)
1055
+ )) : X.value ? (we.value = null, B(""), it().catch(
1056
+ (n) => console.error("changelog domain records failed", n)
1057
+ )) : (fe.value = null, B(""), Ue().catch((n) => console.error("changelog location list failed", n)));
1058
+ }
1059
+ return Z(a, (n) => {
1060
+ n && (f().catch((d) => console.error("changelog domain list failed", d)), Fe());
1061
+ }), Z(A, () => {
1062
+ a.value && Fe();
1063
+ }), Z(ge, () => {
1064
+ a.value && A.value !== "inventory" && !X.value && Ue().catch((n) => console.error("changelog location list failed", n));
1065
+ }), Z(U, (n) => {
1066
+ var d;
1067
+ !n && ((d = x.value) != null && d.deleted) && (x.value = null, J.value = !1);
1068
+ }), Z(m, () => {
1069
+ x.value = null, J.value = !1, a.value && A.value === "inventory" && Pe().catch(
1070
+ (n) => console.error("changelog inventory list failed", n)
1071
+ );
1072
+ }), Z(W, (n) => {
1073
+ x.value = null, a.value && A.value === "inventory" && B(n, void 0, Re);
1074
+ }), (n, d) => {
1075
+ const S = Y("FmButtonGroup"), G = Y("FmSearch"), q = Y("FmSwitch"), ne = Y("FmTable"), Ae = Y("FmDialog"), ft = Y("FmButton");
1076
+ return i(), c(j, null, [
1077
+ V(Ae, {
1078
+ modelValue: a.value,
1079
+ "onUpdate:modelValue": d[8] || (d[8] = (z) => a.value = z),
1080
+ "close-button": "",
1081
+ "dismiss-away": "",
1082
+ "min-width": "98vw",
1083
+ "max-width": "98vw",
1084
+ "max-height": "94vh",
1085
+ "content-class": "!p-0 h-[86vh]"
1086
+ }, {
1087
+ "dialog-header": le(() => [
1088
+ h("div", no, [
1089
+ h("div", oo, [
1090
+ h("div", ao, y($(s)("inventory.changelog.title")), 1),
1091
+ V(S, {
1092
+ modelValue: M.value,
1093
+ "onUpdate:modelValue": d[0] || (d[0] = (z) => M.value = z),
1094
+ items: b.value
1095
+ }, null, 8, ["modelValue", "items"])
1096
+ ]),
1097
+ h("div", so, y($(s)("inventory.changelog.scopeDescription")), 1)
1098
+ ])
1099
+ ]),
1100
+ default: le(() => [
1101
+ h("div", lo, [
1102
+ A.value === "inventory" ? (i(), c(j, { key: 0 }, [
1103
+ h("div", ro, [
1104
+ V(S, {
1105
+ modelValue: g.value,
1106
+ "onUpdate:modelValue": d[1] || (d[1] = (z) => g.value = z),
1107
+ items: D.value
1108
+ }, null, 8, ["modelValue", "items"]),
1109
+ V(G, {
1110
+ modelValue: T.value,
1111
+ "onUpdate:modelValue": d[2] || (d[2] = (z) => T.value = z),
1112
+ class: "flex-1",
1113
+ placeholder: $(s)("inventory.changelog.searchInventory")
1114
+ }, null, 8, ["modelValue", "placeholder"]),
1115
+ h("div", io, [
1116
+ h("span", uo, y($(s)("inventory.changelog.includeDeleted")), 1),
1117
+ V(q, {
1118
+ modelValue: U.value,
1119
+ "onUpdate:modelValue": d[3] || (d[3] = (z) => U.value = z)
1120
+ }, null, 8, ["modelValue"])
1121
+ ])
1122
+ ]),
1123
+ V(ne, {
1124
+ class: "min-h-0 flex-1",
1125
+ "row-data": tt.value,
1126
+ "column-defs": nt.value,
1127
+ "search-value": T.value,
1128
+ loading: de.value,
1129
+ "page-size": 20,
1130
+ onRowClick: d[4] || (d[4] = (z) => st(z.original))
1131
+ }, null, 8, ["row-data", "column-defs", "search-value", "loading"])
1132
+ ], 64)) : X.value ? (i(), pe(ne, {
1133
+ key: 1,
1134
+ class: "min-h-0 flex-1",
1135
+ "row-data": be.value,
1136
+ "column-defs": Be.value,
1137
+ loading: xe.value,
1138
+ "page-size": 20,
1139
+ onRowClick: d[5] || (d[5] = (z) => ut(z.original))
1140
+ }, null, 8, ["row-data", "column-defs", "loading"])) : (i(), c(j, { key: 2 }, [
1141
+ h("div", co, [
1142
+ V(Et, {
1143
+ modelValue: ge.value,
1144
+ "onUpdate:modelValue": d[6] || (d[6] = (z) => ge.value = z)
1145
+ }, null, 8, ["modelValue"]),
1146
+ Te.value ? (i(), c("span", fo, y(Te.value), 1)) : N("", !0)
1147
+ ]),
1148
+ V(ne, {
1149
+ class: "min-h-0 flex-1",
1150
+ "row-data": ye.value,
1151
+ "column-defs": Be.value,
1152
+ loading: ke.value,
1153
+ "page-size": 20,
1154
+ onRowClick: d[7] || (d[7] = (z) => ct(z.original))
1155
+ }, null, 8, ["row-data", "column-defs", "loading"])
1156
+ ], 64))
1157
+ ])
1158
+ ]),
1159
+ _: 1
1160
+ }, 8, ["modelValue"]),
1161
+ V(Ae, {
1162
+ modelValue: J.value,
1163
+ "onUpdate:modelValue": d[9] || (d[9] = (z) => J.value = z),
1164
+ "close-button": "",
1165
+ "dismiss-away": "",
1166
+ "min-width": P.value,
1167
+ "max-width": P.value,
1168
+ "max-height": "86vh"
1169
+ }, {
1170
+ "dialog-header": le(() => [
1171
+ h("div", mo, y(dt.value), 1)
1172
+ ]),
1173
+ default: le(() => [
1174
+ V(to, {
1175
+ commits: A.value === "inventory" ? rt.value : $(F),
1176
+ "is-loading": $(Q),
1177
+ "resolve-name": te
1178
+ }, null, 8, ["commits", "is-loading"]),
1179
+ A.value !== "inventory" && $(O) ? (i(), c("div", po, [
1180
+ V(ft, {
1181
+ label: $(s)("inventory.changelog.loadMore"),
1182
+ variant: "secondary",
1183
+ disabled: $(Q),
1184
+ onClick: L
1185
+ }, null, 8, ["label", "disabled"])
1186
+ ])) : N("", !0)
1187
+ ]),
1188
+ _: 1
1189
+ }, 8, ["modelValue", "min-width", "max-width"])
1190
+ ], 64);
1191
+ };
1192
+ }
1193
+ }), go = /* @__PURE__ */ Bt(vo, [["__scopeId", "data-v-ae9bd171"]]), se = 8;
1194
+ function yo(o, e) {
1195
+ return { x: se, y: Math.max(se, e - o - se) };
1196
+ }
1197
+ const ho = ["title"], je = 48, _o = 8, bo = /* @__PURE__ */ ce({
1198
+ __name: "ChangelogFloatingButton",
1199
+ setup(o) {
1200
+ const { t: e } = he(), t = ve(), l = R(() => {
1201
+ var L;
1202
+ return !!((L = t.sessionUser.value) != null && L.role.isAdmin);
1203
+ }), a = k(!1), s = k(null);
1204
+ function r() {
1205
+ var L, _;
1206
+ return {
1207
+ width: ((L = s.value) == null ? void 0 : L.offsetWidth) ?? je,
1208
+ height: ((_ = s.value) == null ? void 0 : _.offsetHeight) ?? je
1209
+ };
1210
+ }
1211
+ const u = k({ x: 0, y: 0 });
1212
+ function v(L, _, w) {
1213
+ return Math.min(Math.max(L, _), w);
1214
+ }
1215
+ function p() {
1216
+ const { width: L, height: _ } = r(), w = Math.max(se, window.innerWidth - L - se - _o), B = Math.max(se, window.innerHeight - _ - se), K = u.value.x + L / 2;
1217
+ u.value = {
1218
+ x: K < window.innerWidth / 2 ? se : w,
1219
+ y: v(u.value.y, se, B)
1220
+ };
1221
+ }
1222
+ function I() {
1223
+ u.value = yo(r().height, window.innerHeight);
1224
+ }
1225
+ Ve(() => {
1226
+ I(), window.addEventListener("resize", p), window.addEventListener("orientationchange", p);
1227
+ }), gt(() => {
1228
+ window.removeEventListener("resize", p), window.removeEventListener("orientationchange", p);
1229
+ }), Z(l, async (L) => {
1230
+ L && (await yt(), I());
1231
+ });
1232
+ const E = k(!1);
1233
+ let P = null, F = !1;
1234
+ function Q(L) {
1235
+ P = { x: L.clientX, y: L.clientY, px: u.value.x, py: u.value.y }, E.value = !0, F = !1, L.currentTarget.setPointerCapture(L.pointerId);
1236
+ }
1237
+ function O(L) {
1238
+ if (!P) return;
1239
+ const _ = L.clientX - P.x, w = L.clientY - P.y;
1240
+ Math.abs(_) + Math.abs(w) > 3 && (F = !0);
1241
+ const { width: B, height: K } = r();
1242
+ u.value = {
1243
+ x: v(P.px + _, 0, window.innerWidth - B),
1244
+ y: v(P.py + w, 0, window.innerHeight - K)
1245
+ };
1246
+ }
1247
+ function C() {
1248
+ P = null, E.value = !1, p();
1249
+ }
1250
+ function H() {
1251
+ P && (C(), F || (a.value = !0));
1252
+ }
1253
+ return (L, _) => {
1254
+ const w = Y("FmIcon");
1255
+ return i(), pe(ht, { to: "body" }, [
1256
+ l.value ? (i(), c(j, { key: 0 }, [
1257
+ h("div", {
1258
+ ref_key: "wrapperRef",
1259
+ ref: s,
1260
+ class: ae(["fixed z-50 cursor-grab touch-none", E.value ? "" : "transition-[left,top] duration-200 ease-out"]),
1261
+ style: _t({ left: `${u.value.x}px`, top: `${u.value.y}px` })
1262
+ }, [
1263
+ V(We, null, {
1264
+ default: le(() => [
1265
+ h("button", {
1266
+ type: "button",
1267
+ title: $(e)("inventory.changelog.title"),
1268
+ class: ae(["fm-typo-en-body-sm-600 flex h-48 items-center gap-8 whitespace-nowrap rounded-full border border-gray-200 bg-white px-16 shadow-lg hover:bg-gray-50", E.value ? "cursor-grabbing" : "cursor-grab"]),
1269
+ onPointerdown: Q,
1270
+ onPointermove: O,
1271
+ onPointerup: H,
1272
+ onPointercancel: C
1273
+ }, [
1274
+ V(w, {
1275
+ name: "history",
1276
+ size: "md",
1277
+ outline: ""
1278
+ }),
1279
+ h("span", null, y($(e)("inventory.changelog.fabLabel")), 1)
1280
+ ], 42, ho)
1281
+ ]),
1282
+ _: 1
1283
+ })
1284
+ ], 6),
1285
+ V(go, {
1286
+ modelValue: a.value,
1287
+ "onUpdate:modelValue": _[0] || (_[0] = (B) => a.value = B)
1288
+ }, null, 8, ["modelValue"])
1289
+ ], 64)) : N("", !0)
1290
+ ]);
1291
+ };
1292
+ }
1293
+ }), xo = { class: "flex items-center gap-8" }, wo = { class: "flex flex-col gap-12 text-fm-color-typo-secondary" }, ko = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary" }, So = { class: "fm-typo-en-body-sm-400" }, $o = {
1294
+ key: 0,
1295
+ class: "fm-typo-en-body-sm-400"
1296
+ }, Co = {
1297
+ key: 0,
1298
+ href: "https://feedme.ai/product/inventory/features?tab=plans_%26_prices",
1299
+ target: "_blank",
1300
+ rel: "noopener"
1301
+ }, Lo = /* @__PURE__ */ ce({
1302
+ __name: "PlanUpgradeDialog",
1303
+ props: /* @__PURE__ */ bt({
1304
+ capability: {},
1305
+ result: {}
1306
+ }, {
1307
+ modelValue: { type: Boolean, required: !0 },
1308
+ modelModifiers: {}
1309
+ }),
1310
+ emits: ["update:modelValue"],
1311
+ setup(o) {
1312
+ const e = o, t = xt(o, "modelValue"), l = R(() => {
1313
+ var r;
1314
+ return ((r = e.capability) == null ? void 0 : r.tier) ?? "premium";
1315
+ }), a = R(() => {
1316
+ var r;
1317
+ return ((r = e.result) == null ? void 0 : r.stage) === "off";
1318
+ }), s = R(() => a.value ? "Feature unavailable" : `Upgrade to ${l.value} plan`);
1319
+ return (r, u) => {
1320
+ const v = Y("FmSpacer"), p = Y("FmButton"), I = Y("FmDialog");
1321
+ return i(), pe(I, {
1322
+ modelValue: t.value,
1323
+ "onUpdate:modelValue": u[1] || (u[1] = (E) => t.value = E),
1324
+ overlay: !0,
1325
+ "close-button": "",
1326
+ dismissAway: "",
1327
+ "max-width": "520px"
1328
+ }, {
1329
+ "dialog-header": le(() => [
1330
+ h("div", xo, [
1331
+ h("span", null, y(s.value), 1),
1332
+ V(Ft, { tier: l.value }, null, 8, ["tier"])
1333
+ ])
1334
+ ]),
1335
+ "dialog-footer": le(() => [
1336
+ V(v, { class: "sm:hidden xs:hidden" }),
1337
+ V(p, {
1338
+ variant: "tertiary",
1339
+ label: "Not now",
1340
+ onClick: u[0] || (u[0] = (E) => t.value = !1)
1341
+ }),
1342
+ a.value ? N("", !0) : (i(), c("a", Co, [
1343
+ V(p, { label: "Compare plans" })
1344
+ ]))
1345
+ ]),
1346
+ default: le(() => {
1347
+ var E, P, F;
1348
+ return [
1349
+ h("div", wo, [
1350
+ h("p", ko, [
1351
+ a.value ? (i(), c(j, { key: 0 }, [
1352
+ ie(y((E = r.result) == null ? void 0 : E.reason), 1)
1353
+ ], 64)) : (i(), c(j, { key: 1 }, [
1354
+ ie(y((P = r.capability) == null ? void 0 : P.module) + " is available on the " + y(l.value) + " plan. ", 1)
1355
+ ], 64))
1356
+ ]),
1357
+ h("p", So, y((F = r.capability) == null ? void 0 : F.description), 1),
1358
+ a.value ? N("", !0) : (i(), c("p", $o, " Upgrade your plan to unlock this functionality for your business. "))
1359
+ ])
1360
+ ];
1361
+ }),
1362
+ _: 1
1363
+ }, 8, ["modelValue"]);
1364
+ };
1365
+ }
1366
+ });
1367
+ function Ro() {
1368
+ const o = Je(), e = ve(), t = Ee();
1369
+ return R(() => {
1370
+ var l, a;
1371
+ return {
1372
+ planTier: o.planTier,
1373
+ businessId: (l = e.currentBusiness.value) == null ? void 0 : l._id,
1374
+ locationId: (a = t._currentLocation) == null ? void 0 : a.doc._id
1375
+ };
1376
+ });
1377
+ }
1378
+ const Do = { class: "h-full flex flex-col overflow-auto py-16 gap-2" }, Io = /* @__PURE__ */ ce({
1379
+ __name: "NavigationTab",
1380
+ setup(o) {
1381
+ const e = Ct(), t = Ne(), l = ve(), a = Ro(), s = Ut(), r = k(!1), u = k(null), v = k(null), p = k(!1), I = k(null), E = k(null), P = R(
1382
+ () => {
1383
+ var _, w;
1384
+ return (w = Oe(((_ = I.value) == null ? void 0 : _.featureKey) ?? "")) == null ? void 0 : w.label;
1385
+ }
1386
+ ), { menuItems: F } = Ye();
1387
+ Z([() => l.currentBusiness.value, () => e.name], ([_, w]) => {
1388
+ (_ == null ? void 0 : _.menuVersion) === "v3" && (w === ue.INGREDIENTS || w === ue.RECIPE || w === ue.UNIT) && t.push({ name: ue.STOCK });
1389
+ });
1390
+ const Q = R({
1391
+ get() {
1392
+ if (e.name)
1393
+ return String(e.name);
1394
+ },
1395
+ set(_) {
1396
+ var f;
1397
+ if (!_) return;
1398
+ const w = String(_), B = Rt.find((b) => b.route === w), K = Dt(w, a.value);
1399
+ if ((f = Oe((B == null ? void 0 : B.featureKey) ?? "")) != null && f.deprecateSoon) {
1400
+ I.value = B ?? null, E.value = w, p.value = !0;
1401
+ return;
1402
+ }
1403
+ if (B && K.disabled) {
1404
+ u.value = B, v.value = K, r.value = !0;
1405
+ return;
1406
+ }
1407
+ t.push({ name: w });
1408
+ }
1409
+ });
1410
+ function O() {
1411
+ E.value && (t.push({ name: E.value }), E.value = null);
1412
+ }
1413
+ const C = R(
1414
+ () => {
1415
+ var _;
1416
+ return `NavigationTab.${(_ = l.currentBusiness.value) == null ? void 0 : _._id}`;
1417
+ }
1418
+ ), H = k(!1), L = R({
1419
+ get() {
1420
+ return H.value;
1421
+ },
1422
+ set(_) {
1423
+ H.value = _, _ || s.setItem(C.value, "true");
1424
+ }
1425
+ });
1426
+ return Z([() => C.value], () => {
1427
+ H.value = !1, setTimeout(() => {
1428
+ L.value = !s.getItem(C.value);
1429
+ }, 2e3);
1430
+ }), (_, w) => {
1431
+ const B = Y("FmCollapsibleTabs");
1432
+ return i(), c("div", Do, [
1433
+ V(B, {
1434
+ modelValue: Q.value,
1435
+ "onUpdate:modelValue": w[0] || (w[0] = (K) => Q.value = K),
1436
+ items: $(F)
1437
+ }, null, 8, ["modelValue", "items"]),
1438
+ V(Lo, {
1439
+ modelValue: r.value,
1440
+ "onUpdate:modelValue": w[1] || (w[1] = (K) => r.value = K),
1441
+ capability: u.value,
1442
+ result: v.value
1443
+ }, null, 8, ["modelValue", "capability", "result"]),
1444
+ V(At, {
1445
+ modelValue: p.value,
1446
+ "onUpdate:modelValue": w[2] || (w[2] = (K) => p.value = K),
1447
+ "feature-name": P.value,
1448
+ onProceed: O
1449
+ }, null, 8, ["modelValue", "feature-name"])
1450
+ ]);
1451
+ };
1452
+ }
1453
+ });
1454
+ typeof Promise.withResolvers > "u" && (Promise.withResolvers = () => {
1455
+ let o, e;
1456
+ return { promise: new Promise((l, a) => {
1457
+ o = l, e = a;
1458
+ }), resolve: o, reject: e };
1459
+ });
1460
+ typeof Promise.prototype.delayed > "u" && (Promise.prototype.delayed = async function(o) {
1461
+ return await new Promise((e) => setTimeout(e, o)), Promise.resolve(this);
1462
+ });
1463
+ const Vo = {
1464
+ key: 0,
1465
+ class: "flex h-5 items-center justify-center bg-amber-100 px-12 text-xs font-medium text-amber-800 shadow-sm"
1466
+ }, Xo = /* @__PURE__ */ ce({
1467
+ __name: "App",
1468
+ setup(o) {
1469
+ const e = ve(), t = Mt(), l = $t(), a = window.location.href.includes("print-preview");
1470
+ Ve(() => {
1471
+ if (window.location.href.includes("print-preview")) {
1472
+ e.setEmbedded(!0), document.body.classList.add("print-mode");
1473
+ return;
1474
+ }
1475
+ e.registerSidebarComponent(Io), t.initGoogleMap(l.appApi.googleMap).catch(() => {
1476
+ console.error("Google map cannot be loaded");
1477
+ });
1478
+ }), Z([() => e.currentCountry.value], () => {
1479
+ s();
1480
+ });
1481
+ async function s() {
1482
+ var r;
1483
+ try {
1484
+ await e.readBusinesses(), e.currentBusiness.value = (r = e.businesses.value) == null ? void 0 : r.find((u) => u);
1485
+ } catch (u) {
1486
+ console.error("error when trying to reset businesses:", u);
1487
+ }
1488
+ }
1489
+ return (r, u) => (i(), c(j, null, [
1490
+ $(l).isDev && !$(a) ? (i(), c("div", Vo, " Non-production environment ")) : N("", !0),
1491
+ V(nn),
1492
+ $(a) ? N("", !0) : (i(), pe(bo, { key: 1 }))
1493
+ ], 64));
1494
+ }
1495
+ });
1496
+ export {
1497
+ Xo as default
1498
+ };