@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
@@ -1,1476 +0,0 @@
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-Cb5s4jMu.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-Ckn5ra3z.js";
7
- import { u as Rt } from "./netsuite-Bev0OtQT.js";
8
- import { u as Je } from "./useNavigationMenu-CSinmNCY.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-CI2KTzDs.js";
12
- import { F as Ft } from "./decimal-Df6a50Ld.js";
13
- import { t as Pt, a as Tt } from "./date2-BPhD_1Of.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
- };