@feedmepos/mf-connect 0.1.122-dev → 0.1.122-prod

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 (148) hide show
  1. package/dist/{App-Otfhp3H1.js → App-BKnL7b6M.js} +493 -502
  2. package/dist/{Bin-B5aee7-4.js → Bin-BqqQF1h_.js} +8 -8
  3. package/dist/{Broadcast-BAQl4nEs.js → Broadcast-U5rJmhdd.js} +21 -22
  4. package/dist/{CampaignAnalytic-mc0rWnt4.js → CampaignAnalytic-ClwXxxzE.js} +7 -7
  5. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-C06IzthB.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-DyeoWFcd.js} +9 -8
  6. package/dist/{Card-CoeclAye.js → Card-DKikDYES.js} +22 -22
  7. package/dist/{Collections-DIamDQDK.js → Collections-CD0xjFqI.js} +185 -197
  8. package/dist/{Credit-CoIPdhRy.js → Credit-BWcvFlb2.js} +20 -21
  9. package/dist/{DateRangeChip.vue_vue_type_script_setup_true_lang-nI2oXZiR.js → DateRangeChip.vue_vue_type_script_setup_true_lang-B2RizWP8.js} +1 -1
  10. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-D38JB0FV.js +3493 -0
  11. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-BZ42IxXy.js → EffectSheet.vue_vue_type_style_index_0_lang-Hr10pgqD.js} +16 -16
  12. package/dist/{Experience-bJSkl9Xm.js → Experience-dqXYj1Fv.js} +31 -32
  13. package/dist/{FileSaver.min-CFKCOdNt.js → FileSaver.min-DdJMn696.js} +1 -1
  14. package/dist/{Game-DMoyicRl.js → Game-BGQXqzck.js} +18 -19
  15. package/dist/{GiftCardSetup-B28jebxX.js → GiftCardSetup-C3MR25fp.js} +31 -31
  16. package/dist/{GoalPickerPanel.vue_vue_type_script_setup_true_lang-il1_TmfZ.js → GoalPickerPanel.vue_vue_type_script_setup_true_lang-9dL1kVPG.js} +7 -7
  17. package/dist/{Goals-B9XRX-to.js → Goals-DA2jHEZa.js} +4 -4
  18. package/dist/{ImageInput.vue_vue_type_script_setup_true_lang-BZH5In2V.js → ImageInput.vue_vue_type_script_setup_true_lang-_rlsNocb.js} +1 -1
  19. package/dist/{Index-BgGZBhf8.js → Index-WOvryalE.js} +10 -10
  20. package/dist/{LocationPicker.vue_vue_type_script_setup_true_lang-M6eRk_nC.js → LocationPicker.vue_vue_type_script_setup_true_lang-Bu1DjV9M.js} +1 -1
  21. package/dist/{LottieAnimation.vue_vue_type_script_setup_true_lang-DQCpH8dV.js → LottieAnimation.vue_vue_type_script_setup_true_lang-DiLtSIXt.js} +1 -1
  22. package/dist/{LoyaltyDashboard-B-vMpAdx.js → LoyaltyDashboard-BKN2vBqc.js} +15 -15
  23. package/dist/{MainLayout-rv2xd7Yc.js → MainLayout-DizL-dxl.js} +1 -1
  24. package/dist/{MainLayout.vue_vue_type_script_setup_true_lang-BMwNt98l.js → MainLayout.vue_vue_type_script_setup_true_lang-El0YeLnE.js} +3 -3
  25. package/dist/{Marketing-Wu2M2xPV.js → Marketing-B77EoiCf.js} +4 -4
  26. package/dist/{MarketingMaterialEdit-C5s0grZF.js → MarketingMaterialEdit-C_qFEur7.js} +211 -214
  27. package/dist/{Member-D02_98Yo.js → Member-TYDrU3Tk.js} +7 -7
  28. package/dist/{MemberDetailSheet.vue_vue_type_script_setup_true_lang-DGVDww0P.js → MemberDetailSheet.vue_vue_type_script_setup_true_lang-BuzMeXR9.js} +47 -39
  29. package/dist/{MemberImportHistory-ZqjppSHQ.js → MemberImportHistory-l7dVJdEH.js} +7 -7
  30. package/dist/{MemberList-DpWX6mT9.js → MemberList-DiuyeJx_.js} +105 -103
  31. package/dist/{MemberTransactions-BiE7FtKT.js → MemberTransactions-BJ27Gd5P.js} +1 -1
  32. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-DUtNRTNB.js → MessageInput.vue_vue_type_script_setup_true_lang-so7LWtlv.js} +12 -12
  33. package/dist/{MetricInfoTooltip.vue_vue_type_script_setup_true_lang-DD5GkLoA.js → MetricInfoTooltip.vue_vue_type_script_setup_true_lang-DgE7HPsT.js} +1 -1
  34. package/dist/{Mission-D3uyaxrt.js → Mission-C63hh8Ra.js} +21 -22
  35. package/dist/{Overview-C80up9Cz.js → Overview-CVdvQK6q.js} +20 -20
  36. package/dist/{Overview-Dzs2l9dt.js → Overview-DP-4Kpuj.js} +144 -145
  37. package/dist/{Point-CtyqLefg.js → Point-DXH4kJNQ.js} +21 -22
  38. package/dist/{Promotion-C1pB_Mup.js → Promotion-Cn-wAx6m.js} +131 -137
  39. package/dist/{Queue-DkmBLRMM.js → Queue-CEEUE-UT.js} +45 -45
  40. package/dist/{Record-B5onEmZr.js → Record-BFIjLKJD.js} +9 -9
  41. package/dist/{Review-fkpAgnWl.js → Review-BMRfKri0.js} +2 -2
  42. package/dist/ReviewFacebookCallback-CPYIC3RS.js +238 -0
  43. package/dist/{ReviewGoogleCallback-Cj9zmCme.js → ReviewGoogleCallback-Cflqv5Z5.js} +5 -5
  44. package/dist/{Reward-BNt4rJXG.js → Reward-C-qGtzpu.js} +16 -16
  45. package/dist/{RewardGroup.vue_vue_type_script_setup_true_lang-CJbD7izQ.js → RewardGroup.vue_vue_type_script_setup_true_lang-kxJ5i8xe.js} +13 -13
  46. package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-BlRmshrE.js +1884 -0
  47. package/dist/{Segment-9weq5m6d.js → Segment-Bx1pfw4Q.js} +306 -303
  48. package/dist/{SendCollectionSheet.vue_vue_type_script_setup_true_lang-j_DlD4Uz.js → SendCollectionSheet.vue_vue_type_script_setup_true_lang-vuH9xdOi.js} +14 -14
  49. package/dist/{SendVoucherSheet.vue_vue_type_script_setup_true_lang-Bq1XKmWl.js → SendVoucherSheet.vue_vue_type_script_setup_true_lang-CZHpyimI.js} +4 -4
  50. package/dist/Setting-CEcpuE_O.js +578 -0
  51. package/dist/{SettingAdvertisements-BdXfSnNM.js → SettingAdvertisements-CZlIQ5m_.js} +12 -12
  52. package/dist/Settings-CPLibjQy.js +179 -0
  53. package/dist/{Store-D3cAsGJ6.js → Store-BhZulzuc.js} +28 -28
  54. package/dist/{StoreRewards-C2y1M4Ps.js → StoreRewards-CvYgJVFU.js} +15 -15
  55. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-Dqj5zIgi.js +1297 -0
  56. package/dist/TargetLocationInput.vue_vue_type_script_setup_true_lang--Ii9ejFG.js +142 -0
  57. package/dist/{Tier-Dci8VbpH.js → Tier-BPPSaEe0.js} +687 -2575
  58. package/dist/{Title-D4BpqJPQ.js → Title-CccRUVZV.js} +94 -95
  59. package/dist/{Transaction-1biUZvIt.js → Transaction-ULzAt-u7.js} +2 -2
  60. package/dist/Upselling-D2tSUTkE.js +200 -0
  61. package/dist/{UserRuleGroup.vue_vue_type_script_setup_true_lang-D7W1cxlp.js → UserRuleGroup.vue_vue_type_script_setup_true_lang-CoqrSuWu.js} +26 -26
  62. package/dist/{Voucher-DSygKr_u.js → Voucher-Cz7IMRNl.js} +19 -19
  63. package/dist/{VoucherEditor.vue_vue_type_script_setup_true_lang-JL1V_LbU.js → VoucherEditor.vue_vue_type_script_setup_true_lang-BaxHZN76.js} +12 -12
  64. package/dist/{WhatsappAccount-CZ-js350.js → WhatsappAccount-BsxVHiZZ.js} +6 -6
  65. package/dist/{WhatsappAccountStatusLabel.vue_vue_type_script_setup_true_lang-DBiqtHgs.js → WhatsappAccountStatusLabel.vue_vue_type_script_setup_true_lang-DJnkGMF1.js} +1 -1
  66. package/dist/{WhatsappBot-Bygdlech.js → WhatsappBot-sd6erVZk.js} +6 -6
  67. package/dist/{WhatsappBotLogs-BFLRYeQf.js → WhatsappBotLogs-DNbGWyOY.js} +6 -6
  68. package/dist/{WhatsappBotSettings-COZEGQxT.js → WhatsappBotSettings-DXa_e7-a.js} +4 -4
  69. package/dist/{WhatsappLayout-DEzbS1SP.js → WhatsappLayout-DvBPIB5f.js} +3 -3
  70. package/dist/{WhatsappNotificationGroupDialog.vue_vue_type_script_setup_true_lang-DUX8zJnw.js → WhatsappNotificationGroupDialog.vue_vue_type_script_setup_true_lang-CRDouGvj.js} +3 -3
  71. package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-BJFYIRZl.js → ZodTextField.vue_vue_type_script_setup_true_lang-B6BvSACt.js} +2 -2
  72. package/dist/{app-gGao9t7Z.js → app-4x06ItoL.js} +15017 -14861
  73. package/dist/app.js +3 -4
  74. package/dist/{base.export-cVWgL6vy.js → base.export-DS0xThWi.js} +2 -2
  75. package/dist/{business-DbDh-BxN.js → business-D0I7G-5H.js} +1 -1
  76. package/dist/{campaign-B9tq1vZv.js → campaign-BuJCjEH-.js} +94 -121
  77. package/dist/{campaign-D8jV7hA8.js → campaign-CC9U7rkr.js} +28 -34
  78. package/dist/{campaign.enum-Dx-Zo68Q.js → campaign.enum-BqekIiiN.js} +1 -2
  79. package/dist/campaign.fn-CLUOgMgc.js +776 -0
  80. package/dist/{collection.fn-DBfMa_P2.js → collection.fn-CUifllLR.js} +2 -2
  81. package/dist/{currency-SZSbDgAr.js → currency-BPhBDOpt.js} +1 -1
  82. package/dist/{effect-CVTuOMbk.js → effect-DKHOR-B3.js} +1 -1
  83. package/dist/{email-addresses-DpVS_e0D.js → email-addresses-B-VEReRV.js} +25 -25
  84. package/dist/{feature-flag-orm4I4-0.js → feature-flag-Cjl6gaO5.js} +185 -171
  85. package/dist/google-C3S8u0mT.js +4 -0
  86. package/dist/{helper-Ct1_-IEp.js → helper-CBLh1PWR.js} +1 -1
  87. package/dist/{index-Clg5CVmr.js → index-BBsqcXfJ.js} +1 -1
  88. package/dist/{index-NN_GXe7Q.js → index-B_iKSOXp.js} +1 -1
  89. package/dist/{index-BeGbQvrb.js → index-BwgjSrwa.js} +2 -2
  90. package/dist/{index-DW5cDL7l.js → index-BzKKNuLc.js} +2 -2
  91. package/dist/{index-Bz2GhZNd.js → index-C1QA2M4I.js} +10 -10
  92. package/dist/{index-uIOAK7Yt.js → index-CGcWs8B5.js} +462 -533
  93. package/dist/{index-CrluLS6Q.js → index-CWJi_hw-.js} +2 -2
  94. package/dist/{index-BUDFQtMG.js → index-D3B392A3.js} +3 -3
  95. package/dist/{index-CONIxgEK.js → index-DL_UYO4J.js} +234 -380
  96. package/dist/{index-B6hbCvzb.js → index-DenQ8DV4.js} +1 -1
  97. package/dist/{index-BOoNJIJh.js → index-Djf4TpYV.js} +23 -23
  98. package/dist/{index-DBpHsVZR.js → index-EpqQFMu2.js} +2614 -2699
  99. package/dist/{index-MlhU8ucu.js → index-Ob5I-Sex.js} +1 -1
  100. package/dist/{index-BXXLVdgj.js → index-RMsQnHez.js} +1 -1
  101. package/dist/{index-COAgKj0v.js → index-ZTC5k9Jb.js} +6 -19
  102. package/dist/{index-B2GJ653R.js → index-bc7bIIVP.js} +197 -197
  103. package/dist/{index-DFePTLAw.js → index-kClA31M9.js} +10 -10
  104. package/dist/{index-vfdh50L9.js → index-nnmfOPuw.js} +4 -4
  105. package/dist/{index-DCuUA8EI.js → index-umYXnOWc.js} +251 -608
  106. package/dist/{index-DwofBI5n.js → index-vqUiCeKb.js} +1 -1
  107. package/dist/{index.esm2017-ZSQn8C-d.js → index.esm2017-DMKkHR06.js} +111 -111
  108. package/dist/{loading-B-xDCOdo.js → loading-Cb4RgEo7.js} +1 -1
  109. package/dist/{lodash-DFW9UbwC.js → lodash-CMazTe9d.js} +1 -1
  110. package/dist/{member-import-J0fm9uzH.js → member-import-Df1y7FvX.js} +1 -1
  111. package/dist/{membership-B8KWhxBD.js → membership-yvDb2HS8.js} +2 -2
  112. package/dist/{money-CSIA5h2F.js → money-rs9shyUy.js} +1 -1
  113. package/dist/{number-mHKvdu_x.js → number-Ecq6MjRx.js} +1 -1
  114. package/dist/objectid-BVri-Vim.js +145 -0
  115. package/dist/{onboarding-CbvpduVK.js → onboarding-DugmLfNG.js} +36 -36
  116. package/dist/{onboardingSetup-pQHr4ATi.js → onboardingSetup-DMzNxJC4.js} +2 -2
  117. package/dist/{plugins-D_LhWxFb.js → plugins-CvhBJQEK.js} +3 -3
  118. package/dist/{reward-CFEIG_Fc.js → reward-BGUOUKZn.js} +1 -1
  119. package/dist/{rule-Dqxm0TiU.js → rule-C87YbT3F.js} +492 -572
  120. package/dist/rule-builder-lzMi7irV.js +102 -0
  121. package/dist/style.css +1 -1
  122. package/dist/template-BfFSbH04.js +275 -0
  123. package/dist/{timezone-CijbubTV.js → timezone-uP_heouv.js} +1 -1
  124. package/dist/{transaction.fn-Bg5w0js6.js → transaction.fn-CiGhIgzP.js} +2 -2
  125. package/dist/{trigger-Z2ynsa7k.js → trigger-dOOSh-Yp.js} +9 -9
  126. package/dist/{useMarketingMaterialActions-Dgm-u9Nu.js → useMarketingMaterialActions-BRenBblP.js} +4 -4
  127. package/dist/{usePagination-Dlw4BUF1.js → usePagination-DNOc8GFS.js} +1 -1
  128. package/dist/{user-BRNDlg4h.js → user-DTAGYy-F.js} +1 -1
  129. package/dist/vue-i18n-D8wuxuA4.js +2365 -0
  130. package/dist/{xlsx-CnlrcvXS.js → xlsx-BU0bDwTF.js} +1 -1
  131. package/dist/{zod-DPWT8J03.js → zod-mPFqdty8.js} +1 -1
  132. package/package.json +3 -7
  133. package/dist/AuditLogs-C4DQ624f.js +0 -2016
  134. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-CXNf6M-7.js +0 -4439
  135. package/dist/Grab-CNXLDEKx.js +0 -301
  136. package/dist/ReviewFacebookCallback-CLeQP52t.js +0 -225
  137. package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-ie0okvmi.js +0 -1923
  138. package/dist/Setting-DadiBCUq.js +0 -574
  139. package/dist/Settings-SF-Ai88W.js +0 -286
  140. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-DX8nrBZd.js +0 -1319
  141. package/dist/TargetLocationInput.vue_vue_type_script_setup_true_lang-CjBucvpJ.js +0 -7007
  142. package/dist/Upselling-BTqqiZlc.js +0 -1032
  143. package/dist/campaign.fn-DiQIanat.js +0 -776
  144. package/dist/duplicateCampaign-3K1VYqMD.js +0 -51
  145. package/dist/google-BQK68wbe.js +0 -5
  146. package/dist/objectid-BVNgDFLu.js +0 -145
  147. package/dist/template-BKPcMDwU.js +0 -227
  148. package/dist/vue-i18n-h2H0nxj-.js +0 -2365
@@ -1,1032 +0,0 @@
1
- import { defineComponent as me, computed as B, ref as $, watch as G, reactive as ke, onMounted as Ce, onBeforeUnmount as ce, openBlock as p, createElementBlock as w, unref as u, createElementVNode as g, toDisplayString as b, createCommentVNode as _, createBlock as ne, createVNode as se, createTextVNode as $e, Fragment as ie, renderList as ue, withCtx as Te, normalizeClass as xe, normalizeStyle as Re, shallowRef as je, TransitionGroup as Le } from "vue";
2
- import { onBeforeRouteLeave as Me } from "vue-router";
3
- import { useCoreStore as he } from "@feedmepos/mf-common";
4
- import { components as Se } from "@feedmepos/ui-library";
5
- import { z as c } from "./app-gGao9t7Z.js";
6
- import { S as Ue, a as _e } from "./index-Bz2GhZNd.js";
7
- import { f as Ne } from "./currency-SZSbDgAr.js";
8
- const We = {
9
- title: "Upselling settings",
10
- description: "Adjust product weight. Higher weight gives a product more priority in recommendations.",
11
- businessDefault: "Business defaults",
12
- restaurantOverride: "Restaurant override",
13
- inherited: "Using business defaults. Saving creates a restaurant override.",
14
- reset: "Use business defaults",
15
- save: "Save",
16
- apply: "Apply",
17
- applyTo: "Apply changes to",
18
- applyBusiness: "Business default",
19
- applyOutlets: "Selected outlets",
20
- selectAll: "Select all outlets",
21
- cancel: "Cancel",
22
- close: "Close",
23
- applyHint: "Only matching product IDs will be applied. Existing outlet overrides are not removed when you update the business default.",
24
- skippedHint: "These products are not in this outlet’s catalog, so they will not be applied here. Open that outlet’s upselling settings and apply weights separately to products from its own catalog. Existing settings are not deleted.",
25
- product: "product",
26
- productPlural: "products",
27
- matched: "will be applied",
28
- skipped: "will not be applied",
29
- applyFailed: "Could not apply. Reload and review this destination before retrying.",
30
- applyLoadFailed: "Could not load destinations and catalogs. Nothing has been applied.",
31
- applyDone: "Applied",
32
- saving: "Saving...",
33
- discard: "Discard",
34
- search: "Search products",
35
- products: "Products",
36
- editingScope: "Editing scope",
37
- editingBusinessHint: "Apply updates business defaults. Existing outlet overrides are kept.",
38
- editingOutletHint: "Only this outlet’s catalog is shown. Apply saves its settings.",
39
- adjust: "Adjust weight",
40
- weight: "Weight",
41
- automatic: "AI ranking",
42
- strongest: "Strongest recommendation",
43
- excluded: "Do not recommend",
44
- weak: "Weak",
45
- normal: "Normal",
46
- strong: "Strong",
47
- custom: "Custom weight",
48
- hint: "Turn on the switch to adjust a product. 0% excludes it. 100% gives it the strongest preference, not a guaranteed place.",
49
- loading: "Loading products and settings...",
50
- loadError: "Could not load upselling settings. Please try again.",
51
- saveError: "Could not save. Your changes are still here. Please try again.",
52
- saved: "Changes saved successfully",
53
- dirty: "You have unsaved changes",
54
- retry: "Try again",
55
- empty: "No products available for this location.",
56
- noMatches: "No products match your search.",
57
- missingPhoto: "No photo",
58
- unavailable: "Unavailable product",
59
- unavailableHint: "Not in the current product list. Saved settings are kept.",
60
- leave: "Discard unsaved upselling changes and leave?",
61
- chooseRestaurant: "Select a business to edit upselling settings.",
62
- preview: "Customer preview",
63
- previewOutlet: "Preview outlet",
64
- previewRestaurant: "Restaurant recommendations",
65
- previewTopSelling: "Top-selling items",
66
- previewWeightOnly: "Weight-based suggestions — no matching sales history",
67
- previewWeightsOn: "Weight on",
68
- previewWeightsOff: "Weight off",
69
- previewRelevanceOn: "Relevance available",
70
- previewRelevanceOff: "No relevance",
71
- previewNoData: "No historical recommendations or positive weights are available.",
72
- previewCartQuantities: "Recommendations use products in the cart, not quantities.",
73
- previewCartBased: "Cart recommendations",
74
- previewAdd: "Add to test cart",
75
- previewRemove: "Remove",
76
- previewQuantity: "Quantity",
77
- previewCartEmpty: "Add one or more items to the test cart to preview cart recommendations.",
78
- previewUnavailable: "Live recommendation preview is not connected yet.",
79
- previewLoadError: "Could not load this preview. Try again.",
80
- previewChooseOutlet: "Select an available outlet to preview recommendations.",
81
- previewLoading: "Loading recommendations...",
82
- previewSaved: "Before (current)",
83
- previewDraft: "After",
84
- previewItem: "After adding an item",
85
- previewCart: "Before checkout",
86
- previewOrder: "Add products to test cart",
87
- previewTogether: "Always purchase together",
88
- previewMeal: "Picked for you",
89
- previewEmpty: "No recommendations returned."
90
- }, re = (e) => e.map((t) => ({ ...t })), de = (e) => JSON.stringify(
91
- [...e].sort((t, s) => t.productId.localeCompare(s.productId))
92
- );
93
- function Be(e) {
94
- const t = je([]), s = $([]), l = $([]), m = $(!1), I = $(!1), k = $(!1), r = $(null), P = $(!1), a = $(!1), O = B(() => de(s.value) !== de(l.value)), A = ke(/* @__PURE__ */ new Map()), S = B(() => O.value || A.size > 0), N = (x) => JSON.stringify([x.businessId, x.restaurantId]);
95
- let M = "", T = 0;
96
- const W = B(() => new Map(s.value.map((x) => [x.productId, x]))), J = B(() => {
97
- const x = new Set(t.value.map((E) => E.productId));
98
- return [
99
- ...t.value.map((E) => ({ ...E, unavailable: !1 })),
100
- ...s.value.filter((E) => !x.has(E.productId)).map((E) => ({
101
- productId: E.productId,
102
- name: E.productId,
103
- unavailable: !0
104
- }))
105
- ];
106
- });
107
- function q() {
108
- M && k.value && (O.value ? A.set(M, { items: re(s.value), baseline: re(l.value) }) : A.delete(M));
109
- }
110
- async function D() {
111
- q();
112
- const x = ++T, E = { businessId: e.businessId, restaurantId: e.restaurantId || void 0 };
113
- if (M = N(E), s.value = [], l.value = [], t.value = [], k.value = !1, I.value = !1, r.value = null, P.value = !1, a.value = !1, m.value = !!E.businessId, !!m.value)
114
- try {
115
- const [j, V] = await Promise.all([e.api.get(E), e.loadProducts(E)]);
116
- if (x !== T) return;
117
- if (j.businessId !== E.businessId || (j.restaurantId || void 0) !== E.restaurantId)
118
- throw new Error("Settings scope mismatch");
119
- const L = A.get(M);
120
- l.value = re((L == null ? void 0 : L.baseline) ?? j.items), s.value = re((L == null ? void 0 : L.items) ?? j.items), a.value = j.inherited === !0, t.value = V, k.value = !0;
121
- } catch {
122
- x === T && (r.value = "load");
123
- } finally {
124
- x === T && (m.value = !1);
125
- }
126
- }
127
- function F(x, E) {
128
- if (!k.value || I.value) return;
129
- const j = W.value.get(x);
130
- j ? Object.assign(j, E) : s.value.push({ productId: x, adjustWeight: !1, weight: 0.5, ...E }), r.value = null, P.value = !1;
131
- }
132
- function Q() {
133
- I.value || (s.value = re(l.value), A.delete(M), r.value = null, P.value = !1);
134
- }
135
- async function U(x = !1) {
136
- if (!k.value || I.value || !x && !O.value) return;
137
- const E = T, j = M, V = { businessId: e.businessId, restaurantId: e.restaurantId || void 0 };
138
- if (x && (!V.restaurantId || !e.api.reset) || N(V) !== j) return;
139
- const L = re(s.value);
140
- I.value = !0, P.value = !1, r.value = null;
141
- try {
142
- const z = x ? await e.api.reset(V) : await e.api.save(V, L);
143
- if (z.businessId !== V.businessId || (z.restaurantId || void 0) !== V.restaurantId)
144
- throw new Error("Settings scope mismatch");
145
- if (E !== T) {
146
- const K = A.get(j);
147
- j !== M && K && de(K.items) === de(L) && A.delete(j);
148
- return;
149
- }
150
- return s.value = re(z.items), l.value = re(z.items), a.value = z.inherited === !0, A.delete(j), P.value = !0, z;
151
- } catch {
152
- E === T && (r.value = "save");
153
- } finally {
154
- E === T && (I.value = !1);
155
- }
156
- }
157
- return G(() => [e.businessId, e.restaurantId, e.api, e.loadProducts], D, { immediate: !0, flush: "sync" }), ce(() => {
158
- T++;
159
- }), { hasUnsaved: S, items: s, baseline: l, itemMap: W, rows: J, loaded: k, loading: m, saving: I, dirty: O, error: r, saved: P, inherited: a, load: D, save: () => U(), reset: () => U(!0), change: F, discard: Q };
160
- }
161
- function ve(e, t = 5) {
162
- const s = e.filter((m) => !m.unit && !m.perXUnit && !m.isOutOfStocked), l = Math.min(s.length, 5, Math.max(0, Math.floor(t)));
163
- return s.slice(0, l % 2 === 0 ? Math.max(0, l - 1) : l);
164
- }
165
- const fe = (e) => JSON.stringify([e.businessId, e.restaurantId || void 0]), De = (e, t) => (e == null ? void 0 : e.adjustWeight) === t.adjustWeight && (e == null ? void 0 : e.weight) === t.weight;
166
- function Fe(e, t) {
167
- const s = new Map(e.map((l) => [l.productId, l]));
168
- return t.filter((l) => !De(s.get(l.productId), l)).map((l) => ({ ...l }));
169
- }
170
- function Ve(e, t) {
171
- const s = new Map(e.map((l) => [l.productId, { ...l }]));
172
- for (const l of t) s.set(l.productId, { ...l });
173
- return [...s.values()];
174
- }
175
- const He = ["aria-label"], qe = { class: "upsell-preview-header" }, ze = { class: "fm-typo-en-body-lg-600" }, Je = ["aria-label"], Qe = ["aria-pressed", "onClick"], Ye = {
176
- key: 0,
177
- class: "upsell-preview-context"
178
- }, Xe = { class: "upsell-preview-cart" }, Ge = ["data-cart-product"], Ke = { class: "upsell-preview-quantity" }, Ze = { class: "upsell-sr-only" }, et = ["value", "onChange"], tt = ["aria-label", "title", "onClick"], at = { class: "upsell-preview-cart-note" }, rt = {
179
- key: 1,
180
- class: "upsell-sr-only",
181
- role: "status"
182
- }, lt = ["aria-busy"], st = ["data-preview"], nt = { class: "upsell-preview-panel-label" }, ot = { class: "fm-typo-en-body-md-600" }, it = { class: "upsell-preview-touchpoint" }, ut = {
183
- key: 0,
184
- class: "upsell-preview-signals"
185
- }, dt = ["data-active"], ct = ["data-active"], pt = ["role"], vt = {
186
- key: 2,
187
- class: "upsell-preview-none"
188
- }, mt = ["data-preview-product"], ht = ["src", "onError"], gt = {
189
- key: 1,
190
- class: "upsell-preview-photo"
191
- }, wt = { key: 0 }, yt = /* @__PURE__ */ me({
192
- __name: "UpsellPreview",
193
- props: {
194
- host: {},
195
- products: {},
196
- savedItems: {},
197
- draftItems: {},
198
- text: {},
199
- touchpoints: {}
200
- },
201
- setup(e) {
202
- const t = e, { FmSelect: s, FmButton: l } = Se, m = $([]), I = $(""), k = $("restaurant"), r = $([]), P = $(!1), a = $(!1), O = $(!1), A = $(/* @__PURE__ */ new Set()), S = $(null);
203
- let N = 0, M = "", T, W, J = !1, q;
204
- ce(() => {
205
- J = !0, N++, clearTimeout(q);
206
- });
207
- const D = B(() => m.value.find((h) => h.scope.restaurantId === I.value)), F = B(() => {
208
- var h;
209
- return ((h = D.value) == null ? void 0 : h.products) ?? [];
210
- }), Q = B(() => F.value.filter((h) => !r.value.some((C) => C.productId === h.productId)).map((h) => ({ value: h.productId, label: h.name }))), U = B(() => m.value.map((h) => ({ value: h.scope.restaurantId, label: h.name }))), x = B(() => [
211
- { value: "restaurant", label: t.text.previewRestaurant },
212
- { value: "cart", label: t.text.previewCartBased }
213
- ]), E = B(() => {
214
- var h, C, v, y, o, R;
215
- return [
216
- { id: "saved", title: t.text.previewSaved, products: ((h = S.value) == null ? void 0 : h.saved.products) ?? [], source: (C = S.value) == null ? void 0 : C.saved.source, weightsEnabled: (v = S.value) == null ? void 0 : v.saved.weightsEnabled },
217
- { id: "draft", title: t.text.previewDraft, products: ((y = S.value) == null ? void 0 : y.draft.products) ?? [], source: (o = S.value) == null ? void 0 : o.draft.source, weightsEnabled: (R = S.value) == null ? void 0 : R.draft.weightsEnabled }
218
- ];
219
- }), j = B(() => {
220
- var h;
221
- return O.value || a.value ? t.text.previewLoadError : D.value ? k.value === "cart" && !r.value.length ? t.text.previewCartEmpty : (h = t.host) != null && h.loadPreview ? P.value && !S.value ? t.text.previewLoading : "" : t.text.previewUnavailable : t.text.previewChooseOutlet;
222
- });
223
- async function V() {
224
- var h, C;
225
- O.value = !1;
226
- try {
227
- const v = t.host;
228
- let y = [];
229
- if (v != null && v.loadApplyTargets ? y = await v.loadApplyTargets(v.businessId) : v != null && v.restaurantId && (y = [{ scope: { businessId: v.businessId, restaurantId: v.restaurantId }, name: v.restaurantName ?? v.restaurantId, products: t.products }]), J) return;
230
- m.value = y.filter((o) => (!(v != null && v.restaurantId) || o.scope.restaurantId === v.restaurantId) && o.scope.restaurantId && o.scope.businessId === (v == null ? void 0 : v.businessId) && !o.unavailableReason), I.value = ((h = m.value.find((o) => o.scope.restaurantId === (v == null ? void 0 : v.restaurantId))) == null ? void 0 : h.scope.restaurantId) ?? ((C = m.value[0]) == null ? void 0 : C.scope.restaurantId) ?? "";
231
- } catch {
232
- J || (O.value = !0);
233
- }
234
- }
235
- Ce(V), G(I, () => {
236
- r.value = [], A.value = /* @__PURE__ */ new Set();
237
- });
238
- function L(h) {
239
- Q.value.some((C) => C.value === h) && (r.value = [...r.value, { productId: h, quantity: 1 }]);
240
- }
241
- function z(h, C) {
242
- const v = Number(C.target.value), y = r.value.find((o) => o.productId === h);
243
- y && (y.quantity = Number.isInteger(v) && v >= 1 && v <= 99 ? v : 1), C.target.value = String((y == null ? void 0 : y.quantity) ?? 1);
244
- }
245
- function K(h, C) {
246
- if (!h || !["historical", "weight_only", "no_data", "unknown"].includes(h.source) || !Array.isArray(h.products)) throw new Error("Invalid preview products");
247
- const v = h.products.map((y) => y.productId);
248
- if (v.some((y) => !C.has(y)) || new Set(v).size !== v.length) throw new Error("Invalid preview products");
249
- }
250
- async function Z(h = !0) {
251
- h && (T = void 0, W = void 0), clearTimeout(q);
252
- const C = ++N;
253
- a.value = !1, P.value = !1;
254
- const v = t.host, y = D.value, o = `${v == null ? void 0 : v.businessId}:${y == null ? void 0 : y.scope.restaurantId}:${k.value}`;
255
- if (o !== M && (S.value = null), M = o, !(v != null && v.loadPreview) || !(y != null && y.scope.restaurantId) || k.value === "cart" && !r.value.length) {
256
- S.value = null;
257
- return;
258
- }
259
- const R = { businessId: v.businessId, restaurantId: y.scope.restaurantId }, ee = k.value, X = ee === "cart" ? r.value.map((Y) => ({ ...Y })) : [], te = new Set(y.products.map((Y) => Y.productId)), H = Fe(t.savedItems, t.draftItems).filter((Y) => te.has(Y.productId)), ae = v.loadPreview;
260
- P.value = !0;
261
- try {
262
- const Y = await (T ?? (T = v.api.get(R)));
263
- if (C !== N) return;
264
- if (fe(Y) !== fe(R)) throw new Error("Preview scope mismatch");
265
- const oe = (f) => ({ ...R, catalog: y.products, recommendationType: ee, cart: X.map((le) => ({ ...le })), items: f.filter((le) => te.has(le.productId)).map((le) => ({ ...le })), limit: 5 }), i = v.restaurantId || Y.inherited === !0 ? H : [], d = [{ ...oe(Y.items), mode: "current" }, { ...oe(Ve(Y.items, i)), mode: "preview" }];
266
- W ?? (W = ae(d[0]));
267
- const n = await Promise.all([W, ae(d[1])]);
268
- if (C !== N) return;
269
- n.forEach((f) => K(f, te)), S.value = { saved: { ...n[0], weightsEnabled: d[0].items.some((f) => f.adjustWeight), products: ve(n[0].products) }, draft: { ...n[1], weightsEnabled: d[1].items.some((f) => f.adjustWeight), products: ve(n[1].products) } };
270
- } catch {
271
- C === N && (T = void 0, W = void 0, S.value = null, a.value = !0);
272
- } finally {
273
- C === N && (P.value = !1);
274
- }
275
- }
276
- return G(() => {
277
- var h, C, v, y;
278
- return [D.value, k.value, r.value, t.savedItems, (h = t.host) == null ? void 0 : h.loadPreview, (C = t.host) == null ? void 0 : C.api, (v = t.host) == null ? void 0 : v.businessId, (y = t.host) == null ? void 0 : y.restaurantId];
279
- }, () => Z(), { deep: !0, flush: "post" }), G(() => t.draftItems, () => {
280
- var h;
281
- N++, a.value = !1, P.value = !!((h = t.host) != null && h.loadPreview), clearTimeout(q), q = setTimeout(() => Z(!1), 250);
282
- }, { deep: !0 }), (h, C) => {
283
- var v, y;
284
- return ((v = e.touchpoints) == null ? void 0 : v.length) !== 0 ? (p(), w("section", {
285
- key: 0,
286
- class: "upsell-preview",
287
- "aria-label": e.text.preview
288
- }, [
289
- g("header", qe, [
290
- g("h2", ze, b(e.text.preview), 1),
291
- (y = e.host) != null && y.restaurantId ? _("", !0) : (p(), ne(u(s), {
292
- key: 0,
293
- modelValue: I.value,
294
- "onUpdate:modelValue": C[0] || (C[0] = (o) => I.value = o),
295
- label: e.text.previewOutlet,
296
- items: U.value
297
- }, null, 8, ["modelValue", "label", "items"])),
298
- g("div", {
299
- class: "upsell-preview-tabs",
300
- role: "group",
301
- "aria-label": e.text.preview
302
- }, [
303
- (p(!0), w(ie, null, ue(x.value, (o) => (p(), w("button", {
304
- key: o.value,
305
- type: "button",
306
- "aria-pressed": k.value === o.value,
307
- onClick: (R) => k.value = o.value
308
- }, b(o.label), 9, Qe))), 128))
309
- ], 8, Je)
310
- ]),
311
- k.value === "cart" ? (p(), w("div", Ye, [
312
- se(u(s), {
313
- "model-value": "",
314
- label: e.text.previewOrder,
315
- items: Q.value,
316
- "onUpdate:modelValue": L
317
- }, null, 8, ["label", "items"]),
318
- g("ul", Xe, [
319
- (p(!0), w(ie, null, ue(r.value, (o) => {
320
- var R, ee, X, te;
321
- return p(), w("li", {
322
- key: o.productId,
323
- "data-cart-product": o.productId
324
- }, [
325
- g("span", null, b((R = F.value.find((H) => H.productId === o.productId)) == null ? void 0 : R.name), 1),
326
- g("label", Ke, [
327
- g("span", Ze, b(e.text.previewQuantity) + ": " + b((ee = F.value.find((H) => H.productId === o.productId)) == null ? void 0 : ee.name), 1),
328
- C[2] || (C[2] = g("span", { "aria-hidden": "true" }, "×", -1)),
329
- g("input", {
330
- type: "number",
331
- min: "1",
332
- max: "99",
333
- value: o.quantity,
334
- onChange: (H) => z(o.productId, H)
335
- }, null, 40, et)
336
- ]),
337
- g("button", {
338
- type: "button",
339
- class: "upsell-preview-remove",
340
- "aria-label": `${e.text.previewRemove} ${(X = F.value.find((H) => H.productId === o.productId)) == null ? void 0 : X.name}`,
341
- title: `${e.text.previewRemove} ${(te = F.value.find((H) => H.productId === o.productId)) == null ? void 0 : te.name}`,
342
- onClick: (H) => r.value = r.value.filter((ae) => ae.productId !== o.productId)
343
- }, [...C[3] || (C[3] = [
344
- g("svg", {
345
- width: "16",
346
- height: "16",
347
- viewBox: "0 0 24 24",
348
- fill: "none",
349
- "aria-hidden": "true"
350
- }, [
351
- g("path", {
352
- d: "m6 6 12 12M18 6 6 18",
353
- stroke: "currentColor",
354
- "stroke-width": "1.8",
355
- "stroke-linecap": "round"
356
- })
357
- ], -1)
358
- ])], 8, tt)
359
- ], 8, Ge);
360
- }), 128))
361
- ]),
362
- g("p", at, b(e.text.previewCartQuantities), 1)
363
- ])) : _("", !0),
364
- P.value && S.value ? (p(), w("p", rt, b(e.text.previewLoading), 1)) : _("", !0),
365
- g("div", {
366
- class: "upsell-preview-panels",
367
- "aria-busy": P.value
368
- }, [
369
- (p(!0), w(ie, null, ue(E.value, (o) => (p(), w("article", {
370
- key: o.id,
371
- "data-preview": o.id,
372
- class: "upsell-preview-panel"
373
- }, [
374
- g("div", nt, [
375
- g("h3", ot, b(o.title), 1)
376
- ]),
377
- g("div", it, [
378
- o.source && o.source !== "unknown" ? (p(), w("div", ut, [
379
- g("span", {
380
- "data-active": o.weightsEnabled
381
- }, b(o.weightsEnabled ? e.text.previewWeightsOn : e.text.previewWeightsOff), 9, dt),
382
- g("span", {
383
- "data-active": o.source === "historical"
384
- }, b(o.source === "historical" ? e.text.previewRelevanceOn : e.text.previewRelevanceOff), 9, ct)
385
- ])) : _("", !0),
386
- j.value ? (p(), w("p", {
387
- key: 1,
388
- class: xe(["upsell-preview-none", { "upsell-error": a.value || O.value }]),
389
- role: a.value || O.value ? "alert" : "status"
390
- }, b(j.value), 11, pt)) : S.value && !o.products.length ? (p(), w("p", vt, b(o.source === "no_data" ? e.text.previewNoData : e.text.previewEmpty), 1)) : (p(), ne(Le, {
391
- key: 3,
392
- tag: "ul",
393
- name: "upsell-suggestion",
394
- "aria-label": o.source === "unknown" ? o.title : `${o.title}: ${o.weightsEnabled ? e.text.previewWeightsOn : e.text.previewWeightsOff}, ${o.source === "historical" ? e.text.previewRelevanceOn : e.text.previewRelevanceOff}`
395
- }, {
396
- default: Te(() => [
397
- (p(!0), w(ie, null, ue(o.products, (R) => (p(), w("li", {
398
- key: R.productId,
399
- "data-preview-product": R.productId
400
- }, [
401
- R.imageUrl && !A.value.has(R.productId) ? (p(), w("img", {
402
- key: 0,
403
- src: R.imageUrl,
404
- alt: "",
405
- loading: "lazy",
406
- onError: (ee) => A.value.add(R.productId)
407
- }, null, 40, ht)) : (p(), w("span", gt, b(e.text.missingPhoto), 1)),
408
- g("div", null, [
409
- g("h4", null, b(R.name), 1),
410
- R.priceLabel ? (p(), w("p", wt, b(R.priceLabel), 1)) : _("", !0)
411
- ])
412
- ], 8, mt))), 128))
413
- ]),
414
- _: 2
415
- }, 1032, ["aria-label"]))
416
- ])
417
- ], 8, st))), 128))
418
- ], 8, lt),
419
- a.value || O.value ? (p(), ne(u(l), {
420
- key: 2,
421
- label: e.text.retry,
422
- variant: "secondary",
423
- onClick: C[1] || (C[1] = (o) => O.value ? V() : Z())
424
- }, null, 8, ["label"])) : _("", !0)
425
- ], 8, He)) : _("", !0);
426
- };
427
- }
428
- }), ft = ["aria-label", "aria-busy"], bt = { class: "upsell-header" }, It = {
429
- key: 0,
430
- class: "upsell-eyebrow"
431
- }, kt = {
432
- key: 1,
433
- class: "upsell-eyebrow"
434
- }, Ct = { class: "upsell-actions" }, Tt = { class: "upsell-note" }, xt = {
435
- key: 0,
436
- class: "upsell-scope"
437
- }, St = { class: "upsell-description" }, Ut = {
438
- key: 0,
439
- class: "upsell-error",
440
- role: "alert"
441
- }, Pt = {
442
- key: 1,
443
- class: "upsell-description"
444
- }, Et = {
445
- class: "upsell-feedback",
446
- "aria-live": "polite"
447
- }, Ot = {
448
- key: 0,
449
- role: "alert",
450
- class: "upsell-error"
451
- }, At = {
452
- key: 1,
453
- class: "upsell-success"
454
- }, $t = { key: 2 }, Rt = {
455
- key: 2,
456
- class: "upsell-empty"
457
- }, jt = {
458
- key: 3,
459
- class: "upsell-empty",
460
- role: "status"
461
- }, Lt = {
462
- key: 4,
463
- class: "upsell-empty"
464
- }, Mt = {
465
- key: 5,
466
- class: "upsell-editor"
467
- }, _t = { class: "upsell-editor-products" }, Nt = { class: "upsell-toolbar" }, Wt = { class: "upsell-search" }, Bt = {
468
- key: 0,
469
- class: "upsell-empty"
470
- }, Dt = {
471
- key: 1,
472
- class: "upsell-empty"
473
- }, Ft = {
474
- key: 2,
475
- class: "upsell-products"
476
- }, Vt = ["data-product-id"], Ht = { class: "upsell-product" }, qt = ["src", "onError"], zt = {
477
- key: 1,
478
- class: "upsell-photo upsell-no-photo"
479
- }, Jt = { key: 0 }, Qt = { key: 1 }, Yt = {
480
- key: 2,
481
- class: "upsell-unavailable"
482
- }, Xt = { class: "upsell-switch" }, Gt = { class: "upsell-sr-only" }, Kt = { class: "upsell-weight-heading" }, Zt = { key: 0 }, ea = ["aria-label"], ta = ["value", "aria-label", "aria-valuetext", "disabled", "data-boosted", "onInput", "onPointermove", "onPointerup", "onPointercancel", "onLostpointercapture"], aa = /* @__PURE__ */ me({
483
- __name: "UpsellingSettings",
484
- props: {
485
- loadPreview: { type: Function },
486
- loadApplyTargets: { type: Function },
487
- restaurantName: {},
488
- messages: {},
489
- previewTouchpoints: {},
490
- api: {},
491
- loadProducts: { type: Function },
492
- businessId: {},
493
- restaurantId: {}
494
- },
495
- emits: ["dirty-change", "busy-change", "saved"],
496
- setup(e, { expose: t, emit: s }) {
497
- const { FmButton: l, FmSwitch: m, FmTextField: I, FmSelect: k } = Se, r = e, P = s, a = B(() => ({ ...We, ...r.messages })), O = $(""), A = $(/* @__PURE__ */ new Set()), S = $(r.restaurantId ?? ""), N = $([]), M = $(!1), T = $(!1);
498
- let W = 0;
499
- const J = B(() => {
500
- const i = r.businessId, d = r.loadApplyTargets;
501
- let n;
502
- return () => n ?? (n = d(i).catch((f) => {
503
- throw n = void 0, f;
504
- }));
505
- }), q = B(() => {
506
- const i = J.value;
507
- return async (d) => {
508
- const n = (await i()).find((f) => f.scope.businessId === d.businessId && f.scope.restaurantId === d.restaurantId);
509
- if (!n || n.unavailableReason) throw new Error("Catalog unavailable for editing scope");
510
- return n.products;
511
- };
512
- });
513
- G(() => [r.businessId, r.restaurantId], () => {
514
- S.value = r.restaurantId ?? "";
515
- }, { flush: "sync" });
516
- async function D() {
517
- const i = ++W;
518
- N.value = [], T.value = !1, M.value = !!r.loadApplyTargets;
519
- try {
520
- const d = r.loadApplyTargets ? await J.value() : [];
521
- i === W && (N.value = d.filter((n) => n.scope.businessId === r.businessId));
522
- } catch {
523
- i === W && (T.value = !0);
524
- } finally {
525
- i === W && (M.value = !1);
526
- }
527
- }
528
- G(() => [r.businessId, r.loadApplyTargets], D, { immediate: !0 });
529
- const F = B(() => [
530
- { value: "", label: a.value.businessDefault },
531
- ...N.value.filter((i) => i.scope.restaurantId && !i.unavailableReason).map((i) => ({ value: i.scope.restaurantId, label: i.name }))
532
- ]), Q = ke({
533
- get businessId() {
534
- return r.businessId;
535
- },
536
- get restaurantId() {
537
- return S.value || void 0;
538
- },
539
- get restaurantName() {
540
- var i;
541
- return ((i = N.value.find((d) => d.scope.restaurantId === S.value)) == null ? void 0 : i.name) ?? r.restaurantName;
542
- },
543
- get api() {
544
- return r.api;
545
- },
546
- get loadProducts() {
547
- return r.loadApplyTargets ? q.value : r.loadProducts;
548
- },
549
- get loadApplyTargets() {
550
- return r.loadApplyTargets ? J.value : void 0;
551
- },
552
- get loadPreview() {
553
- return r.loadPreview;
554
- }
555
- }), U = Be(Q), { hasUnsaved: x } = U;
556
- async function E() {
557
- await Promise.all([D(), U.load()]);
558
- }
559
- const { itemMap: j, loading: V, saving: L, loaded: z, error: K, dirty: Z, saved: h, inherited: C } = U, v = B(() => {
560
- const i = O.value.trim().toLocaleLowerCase();
561
- return U.rows.value.filter((d) => !d.unavailable).filter((d) => `${d.name} ${d.category ?? ""} ${d.productId}`.toLocaleLowerCase().includes(i));
562
- });
563
- function y(i) {
564
- var d;
565
- return ((d = j.value.get(i)) == null ? void 0 : d.weight) ?? 0.5;
566
- }
567
- function o(i) {
568
- var d;
569
- return ((d = j.value.get(i)) == null ? void 0 : d.adjustWeight) ?? !1;
570
- }
571
- function R(i) {
572
- return o(i) ? y(i) === 0 ? a.value.excluded : y(i) < 0.4 ? a.value.weak : y(i) < 0.6 ? a.value.normal : y(i) < 0.8 ? a.value.strong : a.value.strongest : a.value.automatic;
573
- }
574
- function ee(i, d) {
575
- const n = Number(d.target.value);
576
- U.change(i, { weight: n / 100 });
577
- }
578
- const X = /* @__PURE__ */ new WeakMap();
579
- function te(i) {
580
- const d = i.currentTarget;
581
- d.disabled || i.button !== 0 || (i.preventDefault(), d.focus({ preventScroll: !0 }), X.set(d, { pointerId: i.pointerId, x: i.clientX, value: Number(d.value), width: d.clientWidth || 1 }), d.setPointerCapture(i.pointerId), d.dataset.dragging = "true");
582
- }
583
- function H(i, d) {
584
- const n = d.currentTarget, f = X.get(n);
585
- if (!f || f.pointerId !== d.pointerId) return;
586
- const le = d.clientX - f.x, we = f.value + le / f.width * 100, ye = Math.max(0, Math.min(100, we)), Ae = Math.round(ye);
587
- U.change(i, { weight: Ae / 100 });
588
- const pe = (we - ye) / 100 * f.width;
589
- pe !== 0 && n.style.setProperty("--upsell-origin", pe > 0 ? "left center" : "right center"), n.style.setProperty("--upsell-stretch", `${1 + 10 * Math.tanh(Math.abs(pe) / 90) / f.width}`);
590
- }
591
- function ae(i, d) {
592
- var n;
593
- const f = d.currentTarget;
594
- ((n = X.get(f)) == null ? void 0 : n.pointerId) === d.pointerId && (X.delete(f), delete f.dataset.dragging, d.type === "pointerup" && U.change(i, { weight: Math.round(y(i) * 20) / 20 }), f.style.removeProperty("--upsell-stretch"), f.hasPointerCapture(d.pointerId) && f.releasePointerCapture(d.pointerId));
595
- }
596
- async function Y() {
597
- const i = await U.save();
598
- i && P("saved", i);
599
- }
600
- function oe(i) {
601
- (x.value || L.value) && (i.preventDefault(), i.returnValue = "");
602
- }
603
- return G(x, (i) => P("dirty-change", i), { immediate: !0 }), G(() => L.value, (i) => P("busy-change", i), { immediate: !0 }), G(() => [r.businessId, S.value], () => {
604
- O.value = "", A.value = /* @__PURE__ */ new Set();
605
- }), Ce(() => window.addEventListener("beforeunload", oe)), ce(() => {
606
- W++;
607
- }), ce(() => window.removeEventListener("beforeunload", oe)), t({ dirty: x, saving: L, discard: U.discard }), (i, d) => (p(), w("section", {
608
- class: "fm-upselling",
609
- "aria-label": a.value.title,
610
- "aria-busy": u(V) || u(L)
611
- }, [
612
- g("header", bt, [
613
- g("div", null, [
614
- !e.loadApplyTargets && e.restaurantName ? (p(), w("p", It, b(e.restaurantName), 1)) : _("", !0),
615
- e.loadApplyTargets ? _("", !0) : (p(), w("p", kt, b(e.restaurantId ? a.value.restaurantOverride : a.value.businessDefault), 1)),
616
- g("h1", null, b(a.value.title), 1)
617
- ]),
618
- g("div", Ct, [
619
- S.value && e.api.reset ? (p(), ne(u(l), {
620
- key: 0,
621
- variant: "secondary",
622
- label: a.value.reset,
623
- disabled: u(L) || !u(z) || u(C) && !u(Z),
624
- onClick: u(U).reset
625
- }, null, 8, ["label", "disabled", "onClick"])) : _("", !0),
626
- se(u(l), {
627
- variant: "secondary",
628
- label: a.value.discard,
629
- disabled: !u(Z) || u(L) || !u(z),
630
- onClick: u(U).discard
631
- }, null, 8, ["label", "disabled", "onClick"]),
632
- se(u(l), {
633
- label: u(L) ? a.value.saving : e.loadApplyTargets ? a.value.apply : a.value.save,
634
- loading: u(L),
635
- disabled: !u(Z) || u(L) || M.value || T.value || !u(z),
636
- onClick: Y
637
- }, null, 8, ["label", "loading", "disabled"])
638
- ])
639
- ]),
640
- g("p", Tt, b(a.value.hint), 1),
641
- e.loadApplyTargets ? (p(), w("div", xt, [
642
- se(u(k), {
643
- modelValue: S.value,
644
- "onUpdate:modelValue": d[0] || (d[0] = (n) => S.value = n),
645
- label: a.value.editingScope,
646
- items: F.value,
647
- disabled: u(L) || M.value || T.value
648
- }, null, 8, ["modelValue", "label", "items", "disabled"]),
649
- g("p", St, b(S.value ? a.value.editingOutletHint : a.value.editingBusinessHint), 1),
650
- T.value ? (p(), w("p", Ut, b(a.value.loadError), 1)) : _("", !0),
651
- T.value ? (p(), ne(u(l), {
652
- key: 1,
653
- variant: "secondary",
654
- label: a.value.retry,
655
- onClick: E
656
- }, null, 8, ["label"])) : _("", !0)
657
- ])) : _("", !0),
658
- S.value && u(C) ? (p(), w("p", Pt, b(a.value.inherited), 1)) : _("", !0),
659
- g("div", Et, [
660
- u(K) ? (p(), w("p", Ot, b(u(K) === "load" ? a.value.loadError : a.value.saveError), 1)) : u(h) ? (p(), w("p", At, b(a.value.saved), 1)) : u(Z) ? (p(), w("p", $t, b(a.value.dirty), 1)) : _("", !0)
661
- ]),
662
- e.businessId ? u(V) ? (p(), w("p", jt, b(a.value.loading), 1)) : u(K) === "load" ? (p(), w("div", Lt, [
663
- se(u(l), {
664
- variant: "secondary",
665
- label: a.value.retry,
666
- onClick: u(U).load
667
- }, null, 8, ["label", "onClick"])
668
- ])) : u(z) ? (p(), w("div", Mt, [
669
- g("div", _t, [
670
- g("div", Nt, [
671
- g("h2", null, [
672
- $e(b(a.value.products) + " ", 1),
673
- g("span", null, b(u(U).rows.value.filter((n) => !n.unavailable).length), 1)
674
- ]),
675
- g("div", Wt, [
676
- se(u(I), {
677
- modelValue: O.value,
678
- "onUpdate:modelValue": d[1] || (d[1] = (n) => O.value = n),
679
- label: a.value.search,
680
- placeholder: a.value.search
681
- }, null, 8, ["modelValue", "label", "placeholder"])
682
- ])
683
- ]),
684
- u(U).rows.value.some((n) => !n.unavailable) ? v.value.length ? (p(), w("ul", Ft, [
685
- (p(!0), w(ie, null, ue(v.value, (n) => (p(), w("li", {
686
- key: n.productId,
687
- class: "upsell-row",
688
- "data-product-id": n.productId
689
- }, [
690
- g("div", Ht, [
691
- n.imageUrl && !A.value.has(n.productId) ? (p(), w("img", {
692
- key: 0,
693
- src: n.imageUrl,
694
- alt: "",
695
- class: "upsell-photo",
696
- loading: "lazy",
697
- onError: (f) => A.value.add(n.productId)
698
- }, null, 40, qt)) : (p(), w("span", zt, b(a.value.missingPhoto), 1)),
699
- g("div", null, [
700
- g("h3", null, b(n.unavailable ? a.value.unavailable : n.name), 1),
701
- n.unavailable ? (p(), w("p", Jt, b(n.productId), 1)) : (p(), w("p", Qt, b([n.category, n.priceLabel].filter(Boolean).join(" · ")), 1)),
702
- n.unavailable ? (p(), w("p", Yt, b(a.value.unavailableHint), 1)) : _("", !0)
703
- ])
704
- ]),
705
- g("div", Xt, [
706
- se(u(m), {
707
- "model-value": o(n.productId),
708
- disabled: u(L),
709
- "onUpdate:modelValue": (f) => u(U).change(n.productId, { adjustWeight: f })
710
- }, {
711
- label: Te(() => [
712
- g("span", Gt, b(a.value.adjust) + ": " + b(n.name), 1)
713
- ]),
714
- _: 2
715
- }, 1032, ["model-value", "disabled", "onUpdate:modelValue"])
716
- ]),
717
- g("div", {
718
- class: xe(["upsell-weight", { "upsell-weight-auto": !o(n.productId) }])
719
- }, [
720
- g("div", Kt, [
721
- o(n.productId) ? (p(), w("span", Zt, b(R(n.productId)), 1)) : _("", !0),
722
- g("output", {
723
- "aria-label": `${a.value.weight}: ${n.name}`
724
- }, b(o(n.productId) ? `${Math.round(y(n.productId) * 100)}%` : a.value.automatic), 9, ea)
725
- ]),
726
- g("input", {
727
- type: "range",
728
- min: "0",
729
- max: "100",
730
- step: "1",
731
- value: Math.round(y(n.productId) * 100),
732
- "aria-label": `${a.value.weight}: ${n.name}`,
733
- "aria-valuetext": `${Math.round(y(n.productId) * 100)}% — ${R(n.productId)}`,
734
- disabled: !o(n.productId) || u(L),
735
- "data-boosted": o(n.productId) && y(n.productId) >= 0.8,
736
- style: Re({ "--upsell-fill": `${o(n.productId) ? y(n.productId) * 100 : 0}%` }),
737
- onInput: (f) => ee(n.productId, f),
738
- onPointerdown: te,
739
- onPointermove: (f) => H(n.productId, f),
740
- onPointerup: (f) => ae(n.productId, f),
741
- onPointercancel: (f) => ae(n.productId, f),
742
- onLostpointercapture: (f) => ae(n.productId, f)
743
- }, null, 44, ta)
744
- ], 2)
745
- ], 8, Vt))), 128))
746
- ])) : (p(), w("p", Dt, b(a.value.noMatches), 1)) : (p(), w("p", Bt, b(a.value.empty), 1))
747
- ]),
748
- (p(), ne(yt, {
749
- host: Q,
750
- key: JSON.stringify([e.businessId, S.value]),
751
- products: u(U).rows.value.filter((n) => !n.unavailable),
752
- "saved-items": u(U).baseline.value,
753
- "draft-items": u(U).items.value,
754
- text: a.value,
755
- touchpoints: e.previewTouchpoints
756
- }, null, 8, ["host", "products", "saved-items", "draft-items", "text", "touchpoints"]))
757
- ])) : _("", !0) : (p(), w("p", Rt, b(a.value.chooseRestaurant), 1))
758
- ], 8, ft));
759
- }
760
- });
761
- function ra(e) {
762
- const t = new URL(e.baseUrl);
763
- if (t.protocol !== "https:" && !(t.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(t.hostname)))
764
- throw new Error("Use HTTPS for report-service, or HTTP on localhost.");
765
- if (t.username || t.password || t.search || t.hash)
766
- throw new Error("Report-service URL must not contain credentials, query parameters or a fragment.");
767
- async function s(l, m, I = m === void 0 ? "GET" : "PUT") {
768
- const k = await e.getToken();
769
- if (!k) throw new Error("Sign in to Portal to load upselling settings.");
770
- const r = await fetch(`${t.href.replace(/\/$/, "")}${l}`, {
771
- method: I,
772
- headers: { Authorization: `Bearer ${k}`, ...m === void 0 ? {} : { "Content-Type": "application/json" } },
773
- body: m === void 0 ? void 0 : JSON.stringify(m),
774
- cache: "no-store",
775
- redirect: "error"
776
- });
777
- if (!r.ok) throw new Error(`Unable to ${m === void 0 ? "load" : "save"} upselling settings (${r.status}).`);
778
- return { data: await r.json() };
779
- }
780
- return la({ get: (l) => s(l), put: (l, m) => s(l, m), delete: (l) => s(l, void 0, "DELETE") });
781
- }
782
- function la(e) {
783
- const t = ({ businessId: s, restaurantId: l }) => `/${encodeURIComponent(s)}${l ? `/${encodeURIComponent(l)}` : ""}/upsell-settings`;
784
- return {
785
- async get(s) {
786
- return (await e.get(t(s))).data;
787
- },
788
- async save(s, l) {
789
- const m = { items: l.map(({ productId: I, adjustWeight: k, weight: r }) => ({ productId: I, adjustWeight: k, weight: r })) };
790
- return (await e.put(t(s), m)).data;
791
- },
792
- ...e.delete ? { async reset(s) {
793
- if (!s.restaurantId) throw new Error("Only restaurant overrides can be reset");
794
- return (await e.delete(t(s))).data;
795
- } } : {}
796
- };
797
- }
798
- function sa(e) {
799
- const t = new URL(e), s = ["localhost", "127.0.0.1", "[::1]"].includes(t.hostname);
800
- if (t.protocol !== "https:" && !(t.protocol === "http:" && s))
801
- throw new Error("Use HTTPS for recommendations, or HTTP on localhost.");
802
- if (t.username || t.password || t.search || t.hash)
803
- throw new Error("Recommendation URL must not contain credentials, query parameters or a fragment.");
804
- return t.href.replace(/\/$/, "");
805
- }
806
- function na(e, t) {
807
- if (!e || typeof e != "object") return !1;
808
- const s = e;
809
- if (s.restaurant_id !== t.restaurantId || t.mode === "current" && !["restaurant", "business", "none"].includes(s.source ?? "")) return !1;
810
- const l = s.product_id, m = s.score;
811
- return Array.isArray(l) && Array.isArray(m) && l.length === m.length && l.every((I) => typeof I == "string" && I.length > 0) && m.every((I) => typeof I == "number" && Number.isFinite(I)) && new Set(l).size === l.length;
812
- }
813
- function oa(e) {
814
- const t = sa(e.baseUrl);
815
- return async (s) => {
816
- const l = await e.getToken();
817
- if (!l) throw new Error("Authentication required for preview");
818
- const m = e.fetch ?? fetch, I = s.mode ?? "preview", k = await m(`${t}/recommendation/${encodeURIComponent(s.businessId)}/${I}`, {
819
- method: "POST",
820
- cache: "no-store",
821
- redirect: "error",
822
- signal: AbortSignal.timeout(15e3),
823
- headers: { "Content-Type": "application/json", Authorization: `Bearer ${l}` },
824
- body: JSON.stringify({
825
- restaurant_id: s.restaurantId,
826
- type: s.recommendationType === "cart" ? "cart" : "whats_hot",
827
- ...s.recommendationType === "cart" ? { cart_item: [...new Set(s.cart.map((a) => a.productId))] } : {},
828
- ...I === "preview" ? { items: s.items.map(({ productId: a, adjustWeight: O, weight: A }) => ({ productId: a, adjustWeight: O, weight: A })) } : {}
829
- })
830
- });
831
- if (!k.ok) throw new Error(`Recommendation preview failed (${k.status})`);
832
- const r = await k.json();
833
- if (!na(r, s)) throw new Error("Preview response is not supported");
834
- const P = new Map((s.catalog ?? await e.loadProducts({ businessId: s.businessId, restaurantId: s.restaurantId })).map((a) => [a.productId, a]));
835
- return { products: ve(r.product_id.flatMap((a) => P.has(a) ? [P.get(a)] : []), s.limit), source: "unknown" };
836
- };
837
- }
838
- const be = c.object({
839
- catalog: c.array(
840
- c.object({
841
- _id: c.string(),
842
- override: c.object({
843
- items: c.record(
844
- c.array(
845
- c.object({
846
- combinationKey: c.string().nullish(),
847
- orderFrom: c.string().nullish(),
848
- category: c.string().nullish()
849
- })
850
- )
851
- ).optional()
852
- }).passthrough()
853
- })
854
- ).default([]),
855
- category: c.array(c.object({ _id: c.string(), name: c.string() })),
856
- item: c.array(
857
- c.object({
858
- _id: c.string().min(1),
859
- name: c.string(),
860
- orderFrom: c.string().nullish(),
861
- unit: c.string().nullish(),
862
- perXUnit: c.coerce.number().nullish(),
863
- isOutOfStocked: c.boolean().optional(),
864
- thumbnail: c.string().nullish(),
865
- category: c.string().nullish(),
866
- price: c.object({
867
- currency: c.string(),
868
- amount: c.number(),
869
- precision: c.number()
870
- }).nullish()
871
- })
872
- )
873
- }), Pe = c.object({
874
- _id: c.string().min(1),
875
- menuMode: c.enum(["businessLevel", "restaurantLevel"]).optional(),
876
- modules: be.nullish(),
877
- restaurants: c.array(
878
- c.object({
879
- restaurantId: c.string(),
880
- modules: be.nullish()
881
- })
882
- ).nullish()
883
- });
884
- function ge() {
885
- const e = he();
886
- if (e.namespace.value !== "dev" || e.currentCountry.value !== "MY")
887
- throw new Error("Upselling is available in MY dev only.");
888
- }
889
- function ia() {
890
- return ra({
891
- baseUrl: "https://query-engine.feedmeapidev.com",
892
- getToken: () => (ge(), Ue.getIdToken() ?? "")
893
- });
894
- }
895
- function ua(e) {
896
- const t = new URL(e), s = t.protocol === "http:" && ["127.0.0.1", "localhost"].includes(t.hostname), l = t.origin === "https://public-query-engine.feedmeapidev.com";
897
- if (!s && !l || t.username || t.password || t.search || t.hash || t.pathname !== "/")
898
- throw new Error(
899
- "Use a local or MY dev recommendation backend for preview."
900
- );
901
- return oa({
902
- baseUrl: t.origin,
903
- getToken: () => (ge(), Ue.getIdToken() ?? ""),
904
- loadProducts: Ee
905
- });
906
- }
907
- function Ie(e, t) {
908
- var I, k;
909
- const s = Pe.parse(e), l = s.restaurants || s.menuMode === "restaurantLevel" ? (k = (I = s.restaurants) == null ? void 0 : I.find((r) => r.restaurantId === t)) == null ? void 0 : k.modules : s.modules;
910
- if (!l) return [];
911
- const m = new Map(
912
- l.category.map((r) => [r._id, r.name])
913
- );
914
- return l.item.map((r) => ({
915
- productId: r._id,
916
- name: r.name,
917
- ...r.unit != null ? { unit: r.unit } : {},
918
- ...r.perXUnit != null ? { perXUnit: r.perXUnit } : {},
919
- ...r.isOutOfStocked != null ? { isOutOfStocked: r.isOutOfStocked } : {},
920
- imageUrl: r.thumbnail ?? void 0,
921
- category: m.get(r.category ?? ""),
922
- priceLabel: r.price ? Ne(r.price) : void 0
923
- }));
924
- }
925
- const Ee = async ({
926
- businessId: e,
927
- restaurantId: t
928
- }) => {
929
- const l = (await Oe(e)).find((m) => m.scope.restaurantId === t);
930
- if (!l)
931
- throw new Error("This outlet is not available in the current business.");
932
- if (l.unavailableReason) throw new Error(l.unavailableReason);
933
- return l.products;
934
- }, da = c.array(
935
- c.object({
936
- _id: c.string(),
937
- businessId: c.string(),
938
- profile: c.object({ name: c.string().optional() }).passthrough().optional(),
939
- catalogId: c.string().nullish(),
940
- additionalCatalogs: c.array(c.string()).nullish(),
941
- takeaway: c.object({ catalogId: c.string().nullish() }).passthrough().nullish(),
942
- pickup: c.object({ catalogId: c.string().nullish() }).passthrough().nullish()
943
- }).passthrough()
944
- ), Oe = async (e) => {
945
- var P, a, O, A, S, N, M;
946
- ge();
947
- const t = he(), s = da.parse(t.restaurants.value).filter((T) => T.businessId === e), l = c.object({ menuVersion: c.enum(["v3", "v4"]).nullish() }).parse(t.currentBusiness.value).menuVersion, m = await _e(
948
- `menu-v4/businesses/${encodeURIComponent(
949
- e
950
- )}/menu-v4/effective-menu?modules=item,category,catalog`
951
- ).get(""), I = Pe.parse(m.data), k = I.menuMode === "restaurantLevel", r = [
952
- {
953
- name: "Business default",
954
- scope: { businessId: e },
955
- products: k ? [] : Ie(m.data),
956
- ...k ? {
957
- unavailableReason: "This business uses separate outlet menus. Apply to selected outlets instead; product IDs cannot be combined into one shared catalog."
958
- } : {}
959
- }
960
- ];
961
- for (const T of s) {
962
- const W = k ? (a = (P = I.restaurants) == null ? void 0 : P.find((D) => D.restaurantId === T._id)) == null ? void 0 : a.modules : I.modules, J = /* @__PURE__ */ new Set();
963
- let q;
964
- if (!W) q = "No menu is available for this outlet.";
965
- else if (l !== "v3" && l !== "v4")
966
- q = "Menu version could not be verified. Nothing will be applied.";
967
- else {
968
- const D = [
969
- T.catalogId ?? null,
970
- ...T.additionalCatalogs ?? [],
971
- (O = T.takeaway) == null ? void 0 : O.catalogId,
972
- (A = T.pickup) == null ? void 0 : A.catalogId
973
- ].filter((F) => F !== void 0);
974
- for (const F of D) {
975
- const Q = F ? W.catalog.find((U) => U._id === F) : void 0;
976
- if (F && !Q) {
977
- q = "An assigned catalog is unavailable. Reload this outlet’s menu before applying.";
978
- break;
979
- }
980
- for (const U of W.item) {
981
- const x = (N = (S = Q == null ? void 0 : Q.override.items) == null ? void 0 : S[U._id]) == null ? void 0 : N.find(
982
- (j) => !j.combinationKey
983
- );
984
- ((x == null ? void 0 : x.orderFrom) ?? U.orderFrom) !== "NONE" && (l === "v4" || (x == null ? void 0 : x.category) !== "") && J.add(U._id);
985
- }
986
- }
987
- }
988
- r.push({
989
- name: ((M = T.profile) == null ? void 0 : M.name) ?? T._id,
990
- scope: { businessId: e, restaurantId: T._id },
991
- products: Ie(m.data, T._id).filter(
992
- (D) => J.has(D.productId)
993
- ),
994
- unavailableReason: q
995
- });
996
- }
997
- return r;
998
- };
999
- var ca = { mode: "development", appMode: "mf" };
1000
- const fa = /* @__PURE__ */ me({
1001
- __name: "Upselling",
1002
- setup(e) {
1003
- const t = he(), s = ia(), l = ua(
1004
- "https://public-query-engine.feedmeapidev.com"
1005
- ), m = $(!1), I = $(!1), k = B(
1006
- () => ca.mode === "development" && t.namespace.value === "dev" && t.currentCountry.value === "MY"
1007
- ), r = B(
1008
- () => {
1009
- var P;
1010
- return `${t.namespace.value}:${t.currentCountry.value}:${(P = t.sessionUser.value) == null ? void 0 : P.id}`;
1011
- }
1012
- );
1013
- return Me(
1014
- () => !I.value && (!m.value || window.confirm("Discard unsaved changes?"))
1015
- ), (P, a) => {
1016
- var O;
1017
- return k.value ? (p(), ne(u(aa), {
1018
- key: r.value,
1019
- "business-id": ((O = u(t).currentBusiness.value) == null ? void 0 : O._id) ?? "",
1020
- api: u(s),
1021
- "load-products": u(Ee),
1022
- "load-apply-targets": u(Oe),
1023
- "load-preview": u(l),
1024
- onDirtyChange: a[0] || (a[0] = (A) => m.value = A),
1025
- onBusyChange: a[1] || (a[1] = (A) => I.value = A)
1026
- }, null, 8, ["business-id", "api", "load-products", "load-apply-targets", "load-preview"])) : _("", !0);
1027
- };
1028
- }
1029
- });
1030
- export {
1031
- fa as default
1032
- };