@feedmepos/mf-inventory-portal 1.7.14 → 1.7.15-dev.0

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