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

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