@feedmepos/mf-connect 0.1.118-dev → 0.1.119-dev
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.
- package/dist/{App-CBFNBDb2.js → App-z-u6skb5.js} +103 -99
- package/dist/{AuditLogs-BtSA8b08.js → AuditLogs-J0UJ3HJW.js} +12 -12
- package/dist/{Bin-CjmS_Tfn.js → Bin-Dh9RAgYi.js} +8 -8
- package/dist/{Broadcast-BeePmZa1.js → Broadcast-Dg6azPS8.js} +12 -12
- package/dist/{CampaignAnalytic-CZlnyvOi.js → CampaignAnalytic-CVB4dstO.js} +7 -7
- package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-Du3Ah4HP.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-DYgBeT23.js} +8 -8
- package/dist/{Card-C8SzQQ0z.js → Card-CY736Ul0.js} +22 -22
- package/dist/{Collections-BXNWTSZH.js → Collections-CdTKWkZZ.js} +8 -8
- package/dist/{Credit-CK0-0yD1.js → Credit-CUhEKlMI.js} +12 -12
- package/dist/{DateRangeChip.vue_vue_type_script_setup_true_lang-BXYpYC7Y.js → DateRangeChip.vue_vue_type_script_setup_true_lang-CBwgeTXh.js} +1 -1
- package/dist/{EditCampaignSheet.vue_vue_type_script_setup_true_lang-CdpnNDzR.js → EditCampaignSheet.vue_vue_type_script_setup_true_lang-BC4jTtVY.js} +35 -35
- package/dist/{EffectSheet.vue_vue_type_style_index_0_lang--Oyj3KYg.js → EffectSheet.vue_vue_type_style_index_0_lang-D5-EKqG9.js} +6 -6
- package/dist/{Experience-CWJaj62g.js → Experience-CMp09U-6.js} +13 -13
- package/dist/{FileSaver.min-lV9H82L5.js → FileSaver.min-Bq5McdmK.js} +1 -1
- package/dist/{Game-zBV1LYAg.js → Game-Dv5NvG-q.js} +13 -13
- package/dist/{GiftCardSetup-Cnq9353j.js → GiftCardSetup-SO2Tk5In.js} +10 -10
- package/dist/{GoalPickerPanel.vue_vue_type_script_setup_true_lang-CdgSBdrX.js → GoalPickerPanel.vue_vue_type_script_setup_true_lang-CgG5vHCp.js} +7 -7
- package/dist/{Goals-Utk08egN.js → Goals-BEwQP4cY.js} +4 -4
- package/dist/{Grab-DwMmWmbT.js → Grab-npbL7p7S.js} +9 -9
- package/dist/{ImageInput.vue_vue_type_script_setup_true_lang-CNPeU9xm.js → ImageInput.vue_vue_type_script_setup_true_lang-BDGEqsWE.js} +1 -1
- package/dist/{Index-Bjgs18xf.js → Index-8F2LOWng.js} +10 -10
- package/dist/{LocationPicker.vue_vue_type_script_setup_true_lang-DWnf4lXH.js → LocationPicker.vue_vue_type_script_setup_true_lang-BwAjki7Y.js} +1 -1
- package/dist/{LottieAnimation.vue_vue_type_script_setup_true_lang-Dy_oWJaZ.js → LottieAnimation.vue_vue_type_script_setup_true_lang-DK4C0Y9j.js} +1 -1
- package/dist/{LoyaltyDashboard-DmUfujX_.js → LoyaltyDashboard-rWm0b8cm.js} +15 -15
- package/dist/{MainLayout-DlDZQJfy.js → MainLayout-ezbgp2IQ.js} +1 -1
- package/dist/{MainLayout.vue_vue_type_script_setup_true_lang-yAflY70k.js → MainLayout.vue_vue_type_script_setup_true_lang-1QY5-U5y.js} +3 -3
- package/dist/{Marketing-B0iKlHP-.js → Marketing-DcWF4xVc.js} +4 -4
- package/dist/{MarketingMaterialEdit-BNHxVb8A.js → MarketingMaterialEdit-C1bXj_hU.js} +6 -6
- package/dist/{Member-Bcm3_pWB.js → Member-CgDZqGsV.js} +7 -7
- package/dist/{MemberDetailSheet.vue_vue_type_script_setup_true_lang-CPp4OpOx.js → MemberDetailSheet.vue_vue_type_script_setup_true_lang-Dh1_j06F.js} +23 -23
- package/dist/{MemberImportHistory-AQgLzB3g.js → MemberImportHistory-DT3QJ5se.js} +7 -7
- package/dist/{MemberList-CkMTo2uD.js → MemberList-Bm05jnbk.js} +14 -14
- package/dist/{MemberTransactions-CxLCVjvw.js → MemberTransactions-D90tTpdC.js} +1 -1
- package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-4N20f8Sj.js → MessageInput.vue_vue_type_script_setup_true_lang-jvgjOXXA.js} +10 -10
- package/dist/{MetricInfoTooltip.vue_vue_type_script_setup_true_lang-DghbYpSQ.js → MetricInfoTooltip.vue_vue_type_script_setup_true_lang-CxL-Nh6i.js} +1 -1
- package/dist/{Mission-CQS1CoDN.js → Mission-D_l2eJI3.js} +14 -14
- package/dist/{Overview-NQ287sgq.js → Overview-1AYfTeMD.js} +20 -20
- package/dist/{Overview-UG1IjY7-.js → Overview-BOZBnorP.js} +4 -4
- package/dist/{Point-krMa_mb1.js → Point-Cqy4XzeG.js} +14 -14
- package/dist/{Promotion-vFBmJSti.js → Promotion-9RDNbCgB.js} +14 -14
- package/dist/{Queue-BusxSPt-.js → Queue-D2Eie_np.js} +12 -12
- package/dist/{Record-DjKqn0za.js → Record-e4B--FD8.js} +9 -9
- package/dist/{Review-CqLp8l7U.js → Review-DcUpSvc-.js} +2 -2
- package/dist/{ReviewFacebookCallback-D2kMSVFC.js → ReviewFacebookCallback-BhHdYb4X.js} +5 -5
- package/dist/{ReviewGoogleCallback-B1cHR-o2.js → ReviewGoogleCallback-JPkamgo2.js} +5 -5
- package/dist/{Reward-FeSxgzuS.js → Reward-BQJw-R8V.js} +16 -16
- package/dist/{RewardGroup.vue_vue_type_script_setup_true_lang-CCxVjBsO.js → RewardGroup.vue_vue_type_script_setup_true_lang-D_DSQ8q2.js} +13 -13
- package/dist/{RuleGroup.vue_vue_type_script_setup_true_lang-U403emCF.js → RuleGroup.vue_vue_type_script_setup_true_lang-DfWjXTx3.js} +14 -14
- package/dist/{Segment-Nj59F9Nr.js → Segment-Cjdqsqqg.js} +25 -25
- package/dist/{SendCollectionSheet.vue_vue_type_script_setup_true_lang-Kg9m-0DS.js → SendCollectionSheet.vue_vue_type_script_setup_true_lang-g-CJUZBF.js} +14 -14
- package/dist/{SendVoucherSheet.vue_vue_type_script_setup_true_lang-BLbDApPL.js → SendVoucherSheet.vue_vue_type_script_setup_true_lang-lbH0b170.js} +4 -4
- package/dist/{Setting-CCIzNxv-.js → Setting-B3HK4mtx.js} +14 -14
- package/dist/{SettingAdvertisements-CkPyAg5y.js → SettingAdvertisements-BQFJpdIm.js} +12 -12
- package/dist/{Settings-CYjKGCpa.js → Settings-DKWkiRuA.js} +5 -5
- package/dist/{Store-Bp8Zkzi2.js → Store-mp1LyXwr.js} +26 -26
- package/dist/{StoreRewards-DXW5nVyW.js → StoreRewards-DiSB6d7_.js} +15 -15
- package/dist/{StoreTransactions.vue_vue_type_script_setup_true_lang-BYVezFI2.js → StoreTransactions.vue_vue_type_script_setup_true_lang-BAYKqf-Y.js} +24 -24
- package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-CS6b1cM3.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-be7ksTJw.js} +2 -2
- package/dist/{Tier-B8Utn9Qb.js → Tier-CxaXh96q.js} +26 -26
- package/dist/{Title-CwaNSFer.js → Title-Byz0TGpi.js} +22 -22
- package/dist/{Transaction-ieciAdXP.js → Transaction-CNXulI3o.js} +2 -2
- package/dist/Upselling-Dto64bmE.js +1013 -0
- package/dist/{UserRuleGroup.vue_vue_type_script_setup_true_lang-CMwZl4E6.js → UserRuleGroup.vue_vue_type_script_setup_true_lang-C0bfVZf8.js} +6 -6
- package/dist/{Voucher-BKfujj6r.js → Voucher-CVw3E8Y4.js} +18 -18
- package/dist/{VoucherEditor.vue_vue_type_script_setup_true_lang-CkH-rNqZ.js → VoucherEditor.vue_vue_type_script_setup_true_lang-C0d3ktXA.js} +12 -12
- package/dist/{WhatsappAccount-D73WDP7a.js → WhatsappAccount-5vLzjaIV.js} +6 -6
- package/dist/{WhatsappAccountStatusLabel.vue_vue_type_script_setup_true_lang-C3L7vWZE.js → WhatsappAccountStatusLabel.vue_vue_type_script_setup_true_lang-CwGBRX-Q.js} +1 -1
- package/dist/{WhatsappBot-DTWZAXhi.js → WhatsappBot-BWJbD7Gk.js} +6 -6
- package/dist/{WhatsappBotLogs-DtDcrjs9.js → WhatsappBotLogs-C8gpmZyC.js} +6 -6
- package/dist/{WhatsappBotSettings-7_mH9U4y.js → WhatsappBotSettings-BvPnKHz-.js} +4 -4
- package/dist/{WhatsappLayout-BVpaFJ8H.js → WhatsappLayout-DJXhXeXf.js} +3 -3
- package/dist/{WhatsappNotificationGroupDialog.vue_vue_type_script_setup_true_lang-CMeaNKJt.js → WhatsappNotificationGroupDialog.vue_vue_type_script_setup_true_lang-BxUYjrWQ.js} +3 -3
- package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-BO1zA9AR.js → ZodTextField.vue_vue_type_script_setup_true_lang-CkjzVKif.js} +2 -2
- package/dist/{app-DX7OWVY2.js → app-BF1vds2J.js} +8560 -8537
- package/dist/app.js +1 -1
- package/dist/{base.export-bamzzexi.js → base.export-B7FU8J4P.js} +2 -2
- package/dist/{business-D3U9HSu9.js → business-DkUMhys1.js} +1 -1
- package/dist/{campaign-CKfeN2xN.js → campaign-0AgQP43B.js} +6 -6
- package/dist/{campaign-BqRf2VUO.js → campaign-C9cVkGMF.js} +8 -8
- package/dist/{campaign.fn-DQe5LZuT.js → campaign.fn-N6rJeDUx.js} +227 -227
- package/dist/{collection.fn-BcGqExuE.js → collection.fn-B_QnW0e3.js} +2 -2
- package/dist/{currency-sjMYWoI8.js → currency-XQmondpC.js} +1 -1
- package/dist/{duplicateCampaign-CJF3ZLNd.js → duplicateCampaign-CvQRWP-Z.js} +2 -2
- package/dist/{effect-Cv8ugBR3.js → effect-Mwn1x6qN.js} +1 -1
- package/dist/{email-addresses-CWqtseTn.js → email-addresses-DQQAi6-l.js} +2 -2
- package/dist/{feature-flag-BIh6MM4i.js → feature-flag-B1VMMZMd.js} +1 -1
- package/dist/{helper-WnxOxoRK.js → helper-D1R8vyjc.js} +1 -1
- package/dist/{index-qI1yx02a.js → index-BU6CU5MP.js} +14 -14
- package/dist/{index-ClvaVYkG.js → index-Bm43wR8L.js} +2 -2
- package/dist/{index-B3CkAr-6.js → index-Bym-ZIcv.js} +1 -1
- package/dist/{index-D3yYjyaj.js → index-C9Nbb7wc.js} +2 -2
- package/dist/{index-DzYFQGSw.js → index-CLlGMbnP.js} +1 -1
- package/dist/{index-CeafUn1o.js → index-CPB7j8Wn.js} +5 -5
- package/dist/{index-CDTETsXQ.js → index-CRAuAyO3.js} +1 -1
- package/dist/{index-DOgDR_QH.js → index-Cg8Z5eYT.js} +2 -2
- package/dist/{index-CiSTQhs9.js → index-CzE9ZPDV.js} +1 -1
- package/dist/{index-DqZX-A6e.js → index-D5BwAYuA.js} +3 -3
- package/dist/{index-DxhNNZ-a.js → index-DMfCzjiA.js} +2 -2
- package/dist/{index-iiWxryxo.js → index-DQnCdGWe.js} +4 -4
- package/dist/{index-BoAmM8QH.js → index-DaUhJ6xV.js} +2 -2
- package/dist/{index-BGguMtc0.js → index-P8DDRVa3.js} +1 -1
- package/dist/{index-5TTGGDnF.js → index-Rs75lw-x.js} +1 -1
- package/dist/{index-CnsSd5Dg.js → index-ZYrey0SM.js} +10 -10
- package/dist/{index-Bdg48Cus.js → index-eR9mqPPV.js} +2 -2
- package/dist/{index-B9XVyhtC.js → index-mOGrVzUV.js} +3 -3
- package/dist/{index-DDzi_-Lu.js → index-ug7pxPAX.js} +10 -10
- package/dist/{index-BtmVXdRR.js → index-ytSMcSMt.js} +1 -1
- package/dist/{index.esm2017-GI2alVO5.js → index.esm2017-Gkctw9Mb.js} +72 -72
- package/dist/{loading-Qx5K2WL0.js → loading-kUQqT44G.js} +1 -1
- package/dist/{lodash-CeSjJptg.js → lodash-B4AjV7YZ.js} +1 -1
- package/dist/{member-import-Cq8G7SsW.js → member-import-CwDUG5mj.js} +1 -1
- package/dist/{membership-BbeavSNs.js → membership-BI6U8-eM.js} +2 -2
- package/dist/{money-D8YIFaGA.js → money-Bum-AbB7.js} +1 -1
- package/dist/{number-DAubZ5bt.js → number-uAoNqG-N.js} +1 -1
- package/dist/{objectid-DeXFWDMh.js → objectid-CPTCMH2h.js} +12 -12
- package/dist/{onboarding-SyFxaTJY.js → onboarding-wtYzQipv.js} +20 -20
- package/dist/{onboardingSetup-CLpHlBn8.js → onboardingSetup-DlYM-oqd.js} +2 -2
- package/dist/{plugins-BHuaMEYA.js → plugins-BGyTPNfc.js} +3 -3
- package/dist/{reward-dYWnmAC8.js → reward-D0xtG-bp.js} +1 -1
- package/dist/{rule-BVsfOP2h.js → rule-BAA5-vRj.js} +9 -9
- package/dist/style.css +1 -1
- package/dist/{template-BcdtbhUJ.js → template-DKgW9ul3.js} +6 -6
- package/dist/{timezone-CUc7q5Ii.js → timezone-Bbw2OeEP.js} +1 -1
- package/dist/{transaction.fn-jF9u_cBy.js → transaction.fn-DZdNjP_E.js} +2 -2
- package/dist/{trigger-COlbQlaB.js → trigger-BpotFb7G.js} +7 -7
- package/dist/{useMarketingMaterialActions-Dq6-gsOW.js → useMarketingMaterialActions-CQ1M0N9c.js} +4 -4
- package/dist/{usePagination-BYZB6ORK.js → usePagination-qALFI_Td.js} +1 -1
- package/dist/{user-DK7L8VFR.js → user-X_94TRIK.js} +1 -1
- package/dist/{vue-i18n-CDSTH7g5.js → vue-i18n-CRFpVnMa.js} +162 -162
- package/dist/{xlsx-CKxXlDzD.js → xlsx-DW48eXDT.js} +1 -1
- package/dist/{zod-DjtAaF0U.js → zod-BAP9II5C.js} +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,1013 @@
|
|
|
1
|
+
import { defineComponent as ce, computed as B, ref as $, watch as G, reactive as fe, onMounted as be, onBeforeUnmount as ue, openBlock as v, createElementBlock as w, unref as u, createElementVNode as h, toDisplayString as y, createCommentVNode as L, createBlock as ae, createVNode as te, createTextVNode as Oe, Fragment as se, renderList as ne, withCtx as Ie, normalizeClass as ke, normalizeStyle as Ue, shallowRef as Ae, TransitionGroup as $e } from "vue";
|
|
2
|
+
import { onBeforeRouteLeave as Me } from "vue-router";
|
|
3
|
+
import { useCoreStore as pe } from "@feedmepos/mf-common";
|
|
4
|
+
import { components as Ce } from "@feedmepos/ui-library";
|
|
5
|
+
import { z as c } from "./app-BF1vds2J.js";
|
|
6
|
+
import { S as Te, a as Re } from "./index-CPB7j8Wn.js";
|
|
7
|
+
import { f as Ne } from "./currency-XQmondpC.js";
|
|
8
|
+
const Le = {
|
|
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
|
+
}, Z = (e) => e.map((t) => ({ ...t })), oe = (e) => JSON.stringify(
|
|
91
|
+
[...e].sort((t, s) => t.productId.localeCompare(s.productId))
|
|
92
|
+
);
|
|
93
|
+
function _e(e) {
|
|
94
|
+
const t = Ae([]), s = $([]), r = $([]), g = $(!1), I = $(!1), k = $(!1), l = $(null), S = $(!1), a = $(!1), U = B(() => oe(s.value) !== oe(r.value)), A = fe(/* @__PURE__ */ new Map()), P = B(() => U.value || A.size > 0), _ = (x) => JSON.stringify([x.businessId, x.restaurantId]);
|
|
95
|
+
let N = "", T = 0;
|
|
96
|
+
const j = B(() => new Map(s.value.map((x) => [x.productId, x]))), J = B(() => {
|
|
97
|
+
const x = new Set(t.value.map((f) => f.productId));
|
|
98
|
+
return [
|
|
99
|
+
...t.value.map((f) => ({ ...f, unavailable: !1 })),
|
|
100
|
+
...s.value.filter((f) => !x.has(f.productId)).map((f) => ({
|
|
101
|
+
productId: f.productId,
|
|
102
|
+
name: f.productId,
|
|
103
|
+
unavailable: !0
|
|
104
|
+
}))
|
|
105
|
+
];
|
|
106
|
+
});
|
|
107
|
+
function F() {
|
|
108
|
+
N && k.value && (U.value ? A.set(N, { items: Z(s.value), baseline: Z(r.value) }) : A.delete(N));
|
|
109
|
+
}
|
|
110
|
+
async function D() {
|
|
111
|
+
F();
|
|
112
|
+
const x = ++T, f = { businessId: e.businessId, restaurantId: e.restaurantId || void 0 };
|
|
113
|
+
if (N = _(f), s.value = [], r.value = [], t.value = [], k.value = !1, I.value = !1, l.value = null, S.value = !1, a.value = !1, g.value = !!f.businessId, !!g.value)
|
|
114
|
+
try {
|
|
115
|
+
const [M, V] = await Promise.all([e.api.get(f), e.loadProducts(f)]);
|
|
116
|
+
if (x !== T) return;
|
|
117
|
+
if (M.businessId !== f.businessId || (M.restaurantId || void 0) !== f.restaurantId)
|
|
118
|
+
throw new Error("Settings scope mismatch");
|
|
119
|
+
const H = A.get(N);
|
|
120
|
+
r.value = Z((H == null ? void 0 : H.baseline) ?? M.items), s.value = Z((H == null ? void 0 : H.items) ?? M.items), a.value = M.inherited === !0, t.value = V, k.value = !0;
|
|
121
|
+
} catch {
|
|
122
|
+
x === T && (l.value = "load");
|
|
123
|
+
} finally {
|
|
124
|
+
x === T && (g.value = !1);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function O(x, f) {
|
|
128
|
+
if (!k.value || I.value) return;
|
|
129
|
+
const M = j.value.get(x);
|
|
130
|
+
M ? Object.assign(M, f) : s.value.push({ productId: x, adjustWeight: !1, weight: 0.5, ...f }), l.value = null, S.value = !1;
|
|
131
|
+
}
|
|
132
|
+
function X() {
|
|
133
|
+
I.value || (s.value = Z(r.value), A.delete(N), l.value = null, S.value = !1);
|
|
134
|
+
}
|
|
135
|
+
async function z(x = !1) {
|
|
136
|
+
if (!k.value || I.value || !x && !U.value) return;
|
|
137
|
+
const f = T, M = N, V = { businessId: e.businessId, restaurantId: e.restaurantId || void 0 };
|
|
138
|
+
if (x && (!V.restaurantId || !e.api.reset) || _(V) !== M) return;
|
|
139
|
+
const H = Z(s.value);
|
|
140
|
+
I.value = !0, S.value = !1, l.value = null;
|
|
141
|
+
try {
|
|
142
|
+
const Y = x ? await e.api.reset(V) : await e.api.save(V, H);
|
|
143
|
+
if (Y.businessId !== V.businessId || (Y.restaurantId || void 0) !== V.restaurantId)
|
|
144
|
+
throw new Error("Settings scope mismatch");
|
|
145
|
+
if (f !== T) {
|
|
146
|
+
const p = A.get(M);
|
|
147
|
+
M !== N && p && oe(p.items) === oe(H) && A.delete(M);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
return s.value = Z(Y.items), r.value = Z(Y.items), a.value = Y.inherited === !0, A.delete(M), S.value = !0, Y;
|
|
151
|
+
} catch {
|
|
152
|
+
f === T && (l.value = "save");
|
|
153
|
+
} finally {
|
|
154
|
+
f === T && (I.value = !1);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return G(() => [e.businessId, e.restaurantId, e.api, e.loadProducts], D, { immediate: !0, flush: "sync" }), ue(() => {
|
|
158
|
+
T++;
|
|
159
|
+
}), { hasUnsaved: P, items: s, baseline: r, itemMap: j, rows: J, loaded: k, loading: g, saving: I, dirty: U, error: l, saved: S, inherited: a, load: D, save: () => z(), reset: () => z(!0), change: O, discard: X };
|
|
160
|
+
}
|
|
161
|
+
function de(e, t = 5) {
|
|
162
|
+
const s = e.filter((g) => !g.unit && !g.perXUnit && !g.isOutOfStocked), r = Math.min(s.length, 5, Math.max(0, Math.floor(t)));
|
|
163
|
+
return s.slice(0, r % 2 === 0 ? Math.max(0, r - 1) : r);
|
|
164
|
+
}
|
|
165
|
+
const he = (e) => JSON.stringify([e.businessId, e.restaurantId || void 0]), je = (e, t) => (e == null ? void 0 : e.adjustWeight) === t.adjustWeight && (e == null ? void 0 : e.weight) === t.weight;
|
|
166
|
+
function We(e, t) {
|
|
167
|
+
const s = new Map(e.map((r) => [r.productId, r]));
|
|
168
|
+
return t.filter((r) => !je(s.get(r.productId), r)).map((r) => ({ ...r }));
|
|
169
|
+
}
|
|
170
|
+
function Be(e, t) {
|
|
171
|
+
const s = new Map(e.map((r) => [r.productId, { ...r }]));
|
|
172
|
+
for (const r of t) s.set(r.productId, { ...r });
|
|
173
|
+
return [...s.values()];
|
|
174
|
+
}
|
|
175
|
+
const Fe = ["aria-label"], De = { class: "upsell-preview-header" }, Ve = { class: "fm-typo-en-body-lg-600" }, He = ["aria-label"], qe = ["aria-pressed", "onClick"], ze = {
|
|
176
|
+
key: 0,
|
|
177
|
+
class: "upsell-preview-context"
|
|
178
|
+
}, Je = { class: "upsell-preview-cart" }, Xe = ["data-cart-product"], Ye = { class: "upsell-preview-quantity" }, Ke = { class: "upsell-sr-only" }, Ge = ["value", "onChange"], Qe = ["aria-label", "title", "onClick"], Ze = { class: "upsell-preview-cart-note" }, et = {
|
|
179
|
+
key: 1,
|
|
180
|
+
class: "upsell-sr-only",
|
|
181
|
+
role: "status"
|
|
182
|
+
}, tt = ["aria-busy"], at = ["data-preview"], rt = { class: "upsell-preview-panel-label" }, lt = { class: "fm-typo-en-body-md-600" }, st = { class: "upsell-preview-touchpoint" }, nt = {
|
|
183
|
+
key: 0,
|
|
184
|
+
class: "upsell-preview-signals"
|
|
185
|
+
}, ot = ["data-active"], ut = ["data-active"], it = ["role"], dt = {
|
|
186
|
+
key: 2,
|
|
187
|
+
class: "upsell-preview-none"
|
|
188
|
+
}, ct = ["data-preview-product"], pt = ["src", "onError"], vt = {
|
|
189
|
+
key: 1,
|
|
190
|
+
class: "upsell-preview-photo"
|
|
191
|
+
}, mt = { key: 0 }, gt = /* @__PURE__ */ ce({
|
|
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: r } = Ce, g = $([]), I = $(""), k = $("restaurant"), l = $([]), S = $(!1), a = $(!1), U = $(!1), A = $(/* @__PURE__ */ new Set()), P = $(null);
|
|
203
|
+
let _ = 0, N = "", T = !1, j;
|
|
204
|
+
ue(() => {
|
|
205
|
+
T = !0, _++, clearTimeout(j);
|
|
206
|
+
});
|
|
207
|
+
const J = B(() => g.value.find((p) => p.scope.restaurantId === I.value)), F = B(() => {
|
|
208
|
+
var p;
|
|
209
|
+
return ((p = J.value) == null ? void 0 : p.products) ?? [];
|
|
210
|
+
}), D = B(() => F.value.filter((p) => !l.value.some((C) => C.productId === p.productId)).map((p) => ({ value: p.productId, label: p.name }))), O = B(() => g.value.map((p) => ({ value: p.scope.restaurantId, label: p.name }))), X = B(() => [
|
|
211
|
+
{ value: "restaurant", label: t.text.previewRestaurant },
|
|
212
|
+
{ value: "cart", label: t.text.previewCartBased }
|
|
213
|
+
]), z = B(() => {
|
|
214
|
+
var p, C, i, E, o, R;
|
|
215
|
+
return [
|
|
216
|
+
{ id: "saved", title: t.text.previewSaved, products: ((p = P.value) == null ? void 0 : p.saved.products) ?? [], source: (C = P.value) == null ? void 0 : C.saved.source, weightsEnabled: (i = P.value) == null ? void 0 : i.saved.weightsEnabled },
|
|
217
|
+
{ id: "draft", title: t.text.previewDraft, products: ((E = P.value) == null ? void 0 : E.draft.products) ?? [], source: (o = P.value) == null ? void 0 : o.draft.source, weightsEnabled: (R = P.value) == null ? void 0 : R.draft.weightsEnabled }
|
|
218
|
+
];
|
|
219
|
+
}), x = B(() => {
|
|
220
|
+
var p;
|
|
221
|
+
return U.value || a.value ? t.text.previewLoadError : J.value ? k.value === "cart" && !l.value.length ? t.text.previewCartEmpty : (p = t.host) != null && p.loadPreview ? S.value && !P.value ? t.text.previewLoading : "" : t.text.previewUnavailable : t.text.previewChooseOutlet;
|
|
222
|
+
});
|
|
223
|
+
async function f() {
|
|
224
|
+
var p, C;
|
|
225
|
+
U.value = !1;
|
|
226
|
+
try {
|
|
227
|
+
const i = t.host;
|
|
228
|
+
let E = [];
|
|
229
|
+
if (i != null && i.loadApplyTargets ? E = await i.loadApplyTargets(i.businessId) : i != null && i.restaurantId && (E = [{ scope: { businessId: i.businessId, restaurantId: i.restaurantId }, name: i.restaurantName ?? i.restaurantId, products: t.products }]), T) return;
|
|
230
|
+
g.value = E.filter((o) => (!(i != null && i.restaurantId) || o.scope.restaurantId === i.restaurantId) && o.scope.restaurantId && o.scope.businessId === (i == null ? void 0 : i.businessId) && !o.unavailableReason), I.value = ((p = g.value.find((o) => o.scope.restaurantId === (i == null ? void 0 : i.restaurantId))) == null ? void 0 : p.scope.restaurantId) ?? ((C = g.value[0]) == null ? void 0 : C.scope.restaurantId) ?? "";
|
|
231
|
+
} catch {
|
|
232
|
+
T || (U.value = !0);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
be(f), G(I, () => {
|
|
236
|
+
l.value = [], A.value = /* @__PURE__ */ new Set();
|
|
237
|
+
});
|
|
238
|
+
function M(p) {
|
|
239
|
+
D.value.some((C) => C.value === p) && (l.value = [...l.value, { productId: p, quantity: 1 }]);
|
|
240
|
+
}
|
|
241
|
+
function V(p, C) {
|
|
242
|
+
const i = Number(C.target.value), E = l.value.find((o) => o.productId === p);
|
|
243
|
+
E && (E.quantity = Number.isInteger(i) && i >= 1 && i <= 99 ? i : 1), C.target.value = String((E == null ? void 0 : E.quantity) ?? 1);
|
|
244
|
+
}
|
|
245
|
+
function H(p, C) {
|
|
246
|
+
if (!p || !["historical", "weight_only", "no_data", "unknown"].includes(p.source) || !Array.isArray(p.products)) throw new Error("Invalid preview products");
|
|
247
|
+
const i = p.products.map((E) => E.productId);
|
|
248
|
+
if (i.some((E) => !C.has(E)) || new Set(i).size !== i.length) throw new Error("Invalid preview products");
|
|
249
|
+
}
|
|
250
|
+
async function Y() {
|
|
251
|
+
clearTimeout(j);
|
|
252
|
+
const p = ++_;
|
|
253
|
+
a.value = !1, S.value = !1;
|
|
254
|
+
const C = t.host, i = J.value, E = `${C == null ? void 0 : C.businessId}:${i == null ? void 0 : i.scope.restaurantId}:${k.value}`;
|
|
255
|
+
if (E !== N && (P.value = null), N = E, !(C != null && C.loadPreview) || !(i != null && i.scope.restaurantId) || k.value === "cart" && !l.value.length) {
|
|
256
|
+
P.value = null;
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const o = { businessId: C.businessId, restaurantId: i.scope.restaurantId }, R = k.value, K = R === "cart" ? l.value.map((q) => ({ ...q })) : [], Q = new Set(i.products.map((q) => q.productId)), re = We(t.savedItems, t.draftItems).filter((q) => Q.has(q.productId)), W = C.loadPreview;
|
|
260
|
+
S.value = !0;
|
|
261
|
+
try {
|
|
262
|
+
const q = await C.api.get(o);
|
|
263
|
+
if (p !== _) return;
|
|
264
|
+
if (he(q) !== he(o)) throw new Error("Preview scope mismatch");
|
|
265
|
+
const le = (b) => ({ ...o, recommendationType: R, cart: K.map((ee) => ({ ...ee })), items: b.filter((ee) => Q.has(ee.productId)).map((ee) => ({ ...ee })), limit: 5 }), d = C.restaurantId || q.inherited === !0 ? re : [], m = [{ ...le(q.items), mode: "current" }, { ...le(Be(q.items, d)), mode: "preview" }], n = await Promise.all(m.map((b) => W(b)));
|
|
266
|
+
if (p !== _) return;
|
|
267
|
+
n.forEach((b) => H(b, Q)), P.value = { saved: { ...n[0], weightsEnabled: m[0].items.some((b) => b.adjustWeight), products: de(n[0].products) }, draft: { ...n[1], weightsEnabled: m[1].items.some((b) => b.adjustWeight), products: de(n[1].products) } };
|
|
268
|
+
} catch {
|
|
269
|
+
p === _ && (P.value = null, a.value = !0);
|
|
270
|
+
} finally {
|
|
271
|
+
p === _ && (S.value = !1);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return G(() => {
|
|
275
|
+
var p;
|
|
276
|
+
return [J.value, k.value, l.value, t.savedItems, (p = t.host) == null ? void 0 : p.loadPreview];
|
|
277
|
+
}, Y, { deep: !0 }), G(() => t.draftItems, () => {
|
|
278
|
+
var p;
|
|
279
|
+
_++, a.value = !1, S.value = !!((p = t.host) != null && p.loadPreview), clearTimeout(j), j = setTimeout(Y, 250);
|
|
280
|
+
}, { deep: !0 }), (p, C) => {
|
|
281
|
+
var i, E;
|
|
282
|
+
return ((i = e.touchpoints) == null ? void 0 : i.length) !== 0 ? (v(), w("section", {
|
|
283
|
+
key: 0,
|
|
284
|
+
class: "upsell-preview",
|
|
285
|
+
"aria-label": e.text.preview
|
|
286
|
+
}, [
|
|
287
|
+
h("header", De, [
|
|
288
|
+
h("h2", Ve, y(e.text.preview), 1),
|
|
289
|
+
(E = e.host) != null && E.restaurantId ? L("", !0) : (v(), ae(u(s), {
|
|
290
|
+
key: 0,
|
|
291
|
+
modelValue: I.value,
|
|
292
|
+
"onUpdate:modelValue": C[0] || (C[0] = (o) => I.value = o),
|
|
293
|
+
label: e.text.previewOutlet,
|
|
294
|
+
items: O.value
|
|
295
|
+
}, null, 8, ["modelValue", "label", "items"])),
|
|
296
|
+
h("div", {
|
|
297
|
+
class: "upsell-preview-tabs",
|
|
298
|
+
role: "group",
|
|
299
|
+
"aria-label": e.text.preview
|
|
300
|
+
}, [
|
|
301
|
+
(v(!0), w(se, null, ne(X.value, (o) => (v(), w("button", {
|
|
302
|
+
key: o.value,
|
|
303
|
+
type: "button",
|
|
304
|
+
"aria-pressed": k.value === o.value,
|
|
305
|
+
onClick: (R) => k.value = o.value
|
|
306
|
+
}, y(o.label), 9, qe))), 128))
|
|
307
|
+
], 8, He)
|
|
308
|
+
]),
|
|
309
|
+
k.value === "cart" ? (v(), w("div", ze, [
|
|
310
|
+
te(u(s), {
|
|
311
|
+
"model-value": "",
|
|
312
|
+
label: e.text.previewOrder,
|
|
313
|
+
items: D.value,
|
|
314
|
+
"onUpdate:modelValue": M
|
|
315
|
+
}, null, 8, ["label", "items"]),
|
|
316
|
+
h("ul", Je, [
|
|
317
|
+
(v(!0), w(se, null, ne(l.value, (o) => {
|
|
318
|
+
var R, K, Q, re;
|
|
319
|
+
return v(), w("li", {
|
|
320
|
+
key: o.productId,
|
|
321
|
+
"data-cart-product": o.productId
|
|
322
|
+
}, [
|
|
323
|
+
h("span", null, y((R = F.value.find((W) => W.productId === o.productId)) == null ? void 0 : R.name), 1),
|
|
324
|
+
h("label", Ye, [
|
|
325
|
+
h("span", Ke, y(e.text.previewQuantity) + ": " + y((K = F.value.find((W) => W.productId === o.productId)) == null ? void 0 : K.name), 1),
|
|
326
|
+
C[2] || (C[2] = h("span", { "aria-hidden": "true" }, "×", -1)),
|
|
327
|
+
h("input", {
|
|
328
|
+
type: "number",
|
|
329
|
+
min: "1",
|
|
330
|
+
max: "99",
|
|
331
|
+
value: o.quantity,
|
|
332
|
+
onChange: (W) => V(o.productId, W)
|
|
333
|
+
}, null, 40, Ge)
|
|
334
|
+
]),
|
|
335
|
+
h("button", {
|
|
336
|
+
type: "button",
|
|
337
|
+
class: "upsell-preview-remove",
|
|
338
|
+
"aria-label": `${e.text.previewRemove} ${(Q = F.value.find((W) => W.productId === o.productId)) == null ? void 0 : Q.name}`,
|
|
339
|
+
title: `${e.text.previewRemove} ${(re = F.value.find((W) => W.productId === o.productId)) == null ? void 0 : re.name}`,
|
|
340
|
+
onClick: (W) => l.value = l.value.filter((q) => q.productId !== o.productId)
|
|
341
|
+
}, [...C[3] || (C[3] = [
|
|
342
|
+
h("svg", {
|
|
343
|
+
width: "16",
|
|
344
|
+
height: "16",
|
|
345
|
+
viewBox: "0 0 24 24",
|
|
346
|
+
fill: "none",
|
|
347
|
+
"aria-hidden": "true"
|
|
348
|
+
}, [
|
|
349
|
+
h("path", {
|
|
350
|
+
d: "m6 6 12 12M18 6 6 18",
|
|
351
|
+
stroke: "currentColor",
|
|
352
|
+
"stroke-width": "1.8",
|
|
353
|
+
"stroke-linecap": "round"
|
|
354
|
+
})
|
|
355
|
+
], -1)
|
|
356
|
+
])], 8, Qe)
|
|
357
|
+
], 8, Xe);
|
|
358
|
+
}), 128))
|
|
359
|
+
]),
|
|
360
|
+
h("p", Ze, y(e.text.previewCartQuantities), 1)
|
|
361
|
+
])) : L("", !0),
|
|
362
|
+
S.value && P.value ? (v(), w("p", et, y(e.text.previewLoading), 1)) : L("", !0),
|
|
363
|
+
h("div", {
|
|
364
|
+
class: "upsell-preview-panels",
|
|
365
|
+
"aria-busy": S.value
|
|
366
|
+
}, [
|
|
367
|
+
(v(!0), w(se, null, ne(z.value, (o) => (v(), w("article", {
|
|
368
|
+
key: o.id,
|
|
369
|
+
"data-preview": o.id,
|
|
370
|
+
class: "upsell-preview-panel"
|
|
371
|
+
}, [
|
|
372
|
+
h("div", rt, [
|
|
373
|
+
h("h3", lt, y(o.title), 1)
|
|
374
|
+
]),
|
|
375
|
+
h("div", st, [
|
|
376
|
+
o.source && o.source !== "unknown" ? (v(), w("div", nt, [
|
|
377
|
+
h("span", {
|
|
378
|
+
"data-active": o.weightsEnabled
|
|
379
|
+
}, y(o.weightsEnabled ? e.text.previewWeightsOn : e.text.previewWeightsOff), 9, ot),
|
|
380
|
+
h("span", {
|
|
381
|
+
"data-active": o.source === "historical"
|
|
382
|
+
}, y(o.source === "historical" ? e.text.previewRelevanceOn : e.text.previewRelevanceOff), 9, ut)
|
|
383
|
+
])) : L("", !0),
|
|
384
|
+
x.value ? (v(), w("p", {
|
|
385
|
+
key: 1,
|
|
386
|
+
class: ke(["upsell-preview-none", { "upsell-error": a.value || U.value }]),
|
|
387
|
+
role: a.value || U.value ? "alert" : "status"
|
|
388
|
+
}, y(x.value), 11, it)) : P.value && !o.products.length ? (v(), w("p", dt, y(o.source === "no_data" ? e.text.previewNoData : e.text.previewEmpty), 1)) : (v(), ae($e, {
|
|
389
|
+
key: 3,
|
|
390
|
+
tag: "ul",
|
|
391
|
+
name: "upsell-suggestion",
|
|
392
|
+
"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}`
|
|
393
|
+
}, {
|
|
394
|
+
default: Ie(() => [
|
|
395
|
+
(v(!0), w(se, null, ne(o.products, (R) => (v(), w("li", {
|
|
396
|
+
key: R.productId,
|
|
397
|
+
"data-preview-product": R.productId
|
|
398
|
+
}, [
|
|
399
|
+
R.imageUrl && !A.value.has(R.productId) ? (v(), w("img", {
|
|
400
|
+
key: 0,
|
|
401
|
+
src: R.imageUrl,
|
|
402
|
+
alt: "",
|
|
403
|
+
loading: "lazy",
|
|
404
|
+
onError: (K) => A.value.add(R.productId)
|
|
405
|
+
}, null, 40, pt)) : (v(), w("span", vt, y(e.text.missingPhoto), 1)),
|
|
406
|
+
h("div", null, [
|
|
407
|
+
h("h4", null, y(R.name), 1),
|
|
408
|
+
R.priceLabel ? (v(), w("p", mt, y(R.priceLabel), 1)) : L("", !0)
|
|
409
|
+
])
|
|
410
|
+
], 8, ct))), 128))
|
|
411
|
+
]),
|
|
412
|
+
_: 2
|
|
413
|
+
}, 1032, ["aria-label"]))
|
|
414
|
+
])
|
|
415
|
+
], 8, at))), 128))
|
|
416
|
+
], 8, tt),
|
|
417
|
+
a.value || U.value ? (v(), ae(u(r), {
|
|
418
|
+
key: 2,
|
|
419
|
+
label: e.text.retry,
|
|
420
|
+
variant: "secondary",
|
|
421
|
+
onClick: C[1] || (C[1] = (o) => U.value ? f() : Y())
|
|
422
|
+
}, null, 8, ["label"])) : L("", !0)
|
|
423
|
+
], 8, Fe)) : L("", !0);
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
}), ht = ["aria-label", "aria-busy"], wt = { class: "upsell-header" }, yt = {
|
|
427
|
+
key: 0,
|
|
428
|
+
class: "upsell-eyebrow"
|
|
429
|
+
}, ft = {
|
|
430
|
+
key: 1,
|
|
431
|
+
class: "upsell-eyebrow"
|
|
432
|
+
}, bt = { class: "upsell-actions" }, It = { class: "upsell-note" }, kt = {
|
|
433
|
+
key: 0,
|
|
434
|
+
class: "upsell-scope"
|
|
435
|
+
}, Ct = { class: "upsell-description" }, Tt = {
|
|
436
|
+
key: 0,
|
|
437
|
+
class: "upsell-error",
|
|
438
|
+
role: "alert"
|
|
439
|
+
}, xt = {
|
|
440
|
+
key: 1,
|
|
441
|
+
class: "upsell-description"
|
|
442
|
+
}, Et = {
|
|
443
|
+
class: "upsell-feedback",
|
|
444
|
+
"aria-live": "polite"
|
|
445
|
+
}, Pt = {
|
|
446
|
+
key: 0,
|
|
447
|
+
role: "alert",
|
|
448
|
+
class: "upsell-error"
|
|
449
|
+
}, St = {
|
|
450
|
+
key: 1,
|
|
451
|
+
class: "upsell-success"
|
|
452
|
+
}, Ot = { key: 2 }, Ut = {
|
|
453
|
+
key: 2,
|
|
454
|
+
class: "upsell-empty"
|
|
455
|
+
}, At = {
|
|
456
|
+
key: 3,
|
|
457
|
+
class: "upsell-empty",
|
|
458
|
+
role: "status"
|
|
459
|
+
}, $t = {
|
|
460
|
+
key: 4,
|
|
461
|
+
class: "upsell-empty"
|
|
462
|
+
}, Mt = {
|
|
463
|
+
key: 5,
|
|
464
|
+
class: "upsell-editor"
|
|
465
|
+
}, Rt = { class: "upsell-editor-products" }, Nt = { class: "upsell-toolbar" }, Lt = { class: "upsell-search" }, _t = {
|
|
466
|
+
key: 0,
|
|
467
|
+
class: "upsell-empty"
|
|
468
|
+
}, jt = {
|
|
469
|
+
key: 1,
|
|
470
|
+
class: "upsell-empty"
|
|
471
|
+
}, Wt = {
|
|
472
|
+
key: 2,
|
|
473
|
+
class: "upsell-products"
|
|
474
|
+
}, Bt = ["data-product-id"], Ft = { class: "upsell-product" }, Dt = ["src", "onError"], Vt = {
|
|
475
|
+
key: 1,
|
|
476
|
+
class: "upsell-photo upsell-no-photo"
|
|
477
|
+
}, Ht = { key: 0 }, qt = { key: 1 }, zt = {
|
|
478
|
+
key: 2,
|
|
479
|
+
class: "upsell-unavailable"
|
|
480
|
+
}, Jt = { class: "upsell-switch" }, Xt = { class: "upsell-sr-only" }, Yt = { class: "upsell-weight-heading" }, Kt = { key: 0 }, Gt = ["aria-label"], Qt = ["value", "aria-label", "aria-valuetext", "disabled", "data-boosted", "onInput", "onPointermove", "onPointerup", "onPointercancel", "onLostpointercapture"], Zt = /* @__PURE__ */ ce({
|
|
481
|
+
__name: "UpsellingSettings",
|
|
482
|
+
props: {
|
|
483
|
+
loadPreview: { type: Function },
|
|
484
|
+
loadApplyTargets: { type: Function },
|
|
485
|
+
restaurantName: {},
|
|
486
|
+
messages: {},
|
|
487
|
+
previewTouchpoints: {},
|
|
488
|
+
api: {},
|
|
489
|
+
loadProducts: { type: Function },
|
|
490
|
+
businessId: {},
|
|
491
|
+
restaurantId: {}
|
|
492
|
+
},
|
|
493
|
+
emits: ["dirty-change", "busy-change", "saved"],
|
|
494
|
+
setup(e, { expose: t, emit: s }) {
|
|
495
|
+
const { FmButton: r, FmSwitch: g, FmTextField: I, FmSelect: k } = Ce, l = e, S = s, a = B(() => ({ ...Le, ...l.messages })), U = $(""), A = $(/* @__PURE__ */ new Set()), P = $(l.restaurantId ?? ""), _ = $([]), N = $(!1), T = $(!1);
|
|
496
|
+
let j = 0;
|
|
497
|
+
G(() => [l.businessId, l.restaurantId], () => {
|
|
498
|
+
P.value = l.restaurantId ?? "";
|
|
499
|
+
}, { flush: "sync" });
|
|
500
|
+
async function J() {
|
|
501
|
+
var d;
|
|
502
|
+
const m = ++j;
|
|
503
|
+
_.value = [], T.value = !1, N.value = !!l.loadApplyTargets;
|
|
504
|
+
try {
|
|
505
|
+
const n = await ((d = l.loadApplyTargets) == null ? void 0 : d.call(l, l.businessId)) ?? [];
|
|
506
|
+
m === j && (_.value = n.filter((b) => b.scope.businessId === l.businessId));
|
|
507
|
+
} catch {
|
|
508
|
+
m === j && (T.value = !0);
|
|
509
|
+
} finally {
|
|
510
|
+
m === j && (N.value = !1);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
G(() => [l.businessId, l.loadApplyTargets], J, { immediate: !0 });
|
|
514
|
+
const F = B(() => [
|
|
515
|
+
{ value: "", label: a.value.businessDefault },
|
|
516
|
+
..._.value.filter((d) => d.scope.restaurantId && !d.unavailableReason).map((d) => ({ value: d.scope.restaurantId, label: d.name }))
|
|
517
|
+
]), D = fe({
|
|
518
|
+
get businessId() {
|
|
519
|
+
return l.businessId;
|
|
520
|
+
},
|
|
521
|
+
get restaurantId() {
|
|
522
|
+
return P.value || void 0;
|
|
523
|
+
},
|
|
524
|
+
get restaurantName() {
|
|
525
|
+
var d;
|
|
526
|
+
return ((d = _.value.find((m) => m.scope.restaurantId === P.value)) == null ? void 0 : d.name) ?? l.restaurantName;
|
|
527
|
+
},
|
|
528
|
+
get api() {
|
|
529
|
+
return l.api;
|
|
530
|
+
},
|
|
531
|
+
get loadProducts() {
|
|
532
|
+
return l.loadProducts;
|
|
533
|
+
},
|
|
534
|
+
get loadApplyTargets() {
|
|
535
|
+
return l.loadApplyTargets;
|
|
536
|
+
},
|
|
537
|
+
get loadPreview() {
|
|
538
|
+
return l.loadPreview;
|
|
539
|
+
}
|
|
540
|
+
}), O = _e(D), { hasUnsaved: X } = O, { itemMap: z, loading: x, saving: f, loaded: M, error: V, dirty: H, saved: Y, inherited: p } = O, C = B(() => {
|
|
541
|
+
const d = U.value.trim().toLocaleLowerCase();
|
|
542
|
+
return O.rows.value.filter((m) => !m.unavailable).filter((m) => `${m.name} ${m.category ?? ""} ${m.productId}`.toLocaleLowerCase().includes(d));
|
|
543
|
+
});
|
|
544
|
+
function i(d) {
|
|
545
|
+
var m;
|
|
546
|
+
return ((m = z.value.get(d)) == null ? void 0 : m.weight) ?? 0.5;
|
|
547
|
+
}
|
|
548
|
+
function E(d) {
|
|
549
|
+
var m;
|
|
550
|
+
return ((m = z.value.get(d)) == null ? void 0 : m.adjustWeight) ?? !1;
|
|
551
|
+
}
|
|
552
|
+
function o(d) {
|
|
553
|
+
return E(d) ? i(d) === 0 ? a.value.excluded : i(d) < 0.4 ? a.value.weak : i(d) < 0.6 ? a.value.normal : i(d) < 0.8 ? a.value.strong : a.value.strongest : a.value.automatic;
|
|
554
|
+
}
|
|
555
|
+
function R(d, m) {
|
|
556
|
+
const n = Number(m.target.value);
|
|
557
|
+
O.change(d, { weight: n / 100 });
|
|
558
|
+
}
|
|
559
|
+
const K = /* @__PURE__ */ new WeakMap();
|
|
560
|
+
function Q(d) {
|
|
561
|
+
const m = d.currentTarget;
|
|
562
|
+
m.disabled || d.button !== 0 || (d.preventDefault(), m.focus({ preventScroll: !0 }), K.set(m, { pointerId: d.pointerId, x: d.clientX, value: Number(m.value), width: m.clientWidth || 1 }), m.setPointerCapture(d.pointerId), m.dataset.dragging = "true");
|
|
563
|
+
}
|
|
564
|
+
function re(d, m) {
|
|
565
|
+
const n = m.currentTarget, b = K.get(n);
|
|
566
|
+
if (!b || b.pointerId !== m.pointerId) return;
|
|
567
|
+
const ee = m.clientX - b.x, me = b.value + ee / b.width * 100, ge = Math.max(0, Math.min(100, me)), Se = Math.round(ge);
|
|
568
|
+
O.change(d, { weight: Se / 100 });
|
|
569
|
+
const ie = (me - ge) / 100 * b.width;
|
|
570
|
+
ie !== 0 && n.style.setProperty("--upsell-origin", ie > 0 ? "left center" : "right center"), n.style.setProperty("--upsell-stretch", `${1 + 10 * Math.tanh(Math.abs(ie) / 90) / b.width}`);
|
|
571
|
+
}
|
|
572
|
+
function W(d, m) {
|
|
573
|
+
var n;
|
|
574
|
+
const b = m.currentTarget;
|
|
575
|
+
((n = K.get(b)) == null ? void 0 : n.pointerId) === m.pointerId && (K.delete(b), delete b.dataset.dragging, m.type === "pointerup" && O.change(d, { weight: Math.round(i(d) * 20) / 20 }), b.style.removeProperty("--upsell-stretch"), b.hasPointerCapture(m.pointerId) && b.releasePointerCapture(m.pointerId));
|
|
576
|
+
}
|
|
577
|
+
async function q() {
|
|
578
|
+
const d = await O.save();
|
|
579
|
+
d && S("saved", d);
|
|
580
|
+
}
|
|
581
|
+
function le(d) {
|
|
582
|
+
(X.value || f.value) && (d.preventDefault(), d.returnValue = "");
|
|
583
|
+
}
|
|
584
|
+
return G(X, (d) => S("dirty-change", d), { immediate: !0 }), G(() => f.value, (d) => S("busy-change", d), { immediate: !0 }), G(() => [l.businessId, P.value], () => {
|
|
585
|
+
U.value = "", A.value = /* @__PURE__ */ new Set();
|
|
586
|
+
}), be(() => window.addEventListener("beforeunload", le)), ue(() => {
|
|
587
|
+
j++;
|
|
588
|
+
}), ue(() => window.removeEventListener("beforeunload", le)), t({ dirty: X, saving: f, discard: O.discard }), (d, m) => (v(), w("section", {
|
|
589
|
+
class: "fm-upselling",
|
|
590
|
+
"aria-label": a.value.title,
|
|
591
|
+
"aria-busy": u(x) || u(f)
|
|
592
|
+
}, [
|
|
593
|
+
h("header", wt, [
|
|
594
|
+
h("div", null, [
|
|
595
|
+
!e.loadApplyTargets && e.restaurantName ? (v(), w("p", yt, y(e.restaurantName), 1)) : L("", !0),
|
|
596
|
+
e.loadApplyTargets ? L("", !0) : (v(), w("p", ft, y(e.restaurantId ? a.value.restaurantOverride : a.value.businessDefault), 1)),
|
|
597
|
+
h("h1", null, y(a.value.title), 1)
|
|
598
|
+
]),
|
|
599
|
+
h("div", bt, [
|
|
600
|
+
P.value && e.api.reset ? (v(), ae(u(r), {
|
|
601
|
+
key: 0,
|
|
602
|
+
variant: "secondary",
|
|
603
|
+
label: a.value.reset,
|
|
604
|
+
disabled: u(f) || !u(M) || u(p) && !u(H),
|
|
605
|
+
onClick: u(O).reset
|
|
606
|
+
}, null, 8, ["label", "disabled", "onClick"])) : L("", !0),
|
|
607
|
+
te(u(r), {
|
|
608
|
+
variant: "secondary",
|
|
609
|
+
label: a.value.discard,
|
|
610
|
+
disabled: !u(H) || u(f) || !u(M),
|
|
611
|
+
onClick: u(O).discard
|
|
612
|
+
}, null, 8, ["label", "disabled", "onClick"]),
|
|
613
|
+
te(u(r), {
|
|
614
|
+
label: u(f) ? a.value.saving : e.loadApplyTargets ? a.value.apply : a.value.save,
|
|
615
|
+
loading: u(f),
|
|
616
|
+
disabled: !u(H) || u(f) || N.value || T.value || !u(M),
|
|
617
|
+
onClick: q
|
|
618
|
+
}, null, 8, ["label", "loading", "disabled"])
|
|
619
|
+
])
|
|
620
|
+
]),
|
|
621
|
+
h("p", It, y(a.value.hint), 1),
|
|
622
|
+
e.loadApplyTargets ? (v(), w("div", kt, [
|
|
623
|
+
te(u(k), {
|
|
624
|
+
modelValue: P.value,
|
|
625
|
+
"onUpdate:modelValue": m[0] || (m[0] = (n) => P.value = n),
|
|
626
|
+
label: a.value.editingScope,
|
|
627
|
+
items: F.value,
|
|
628
|
+
disabled: u(f) || N.value || T.value
|
|
629
|
+
}, null, 8, ["modelValue", "label", "items", "disabled"]),
|
|
630
|
+
h("p", Ct, y(P.value ? a.value.editingOutletHint : a.value.editingBusinessHint), 1),
|
|
631
|
+
T.value ? (v(), w("p", Tt, y(a.value.loadError), 1)) : L("", !0),
|
|
632
|
+
T.value ? (v(), ae(u(r), {
|
|
633
|
+
key: 1,
|
|
634
|
+
variant: "secondary",
|
|
635
|
+
label: a.value.retry,
|
|
636
|
+
onClick: J
|
|
637
|
+
}, null, 8, ["label"])) : L("", !0)
|
|
638
|
+
])) : L("", !0),
|
|
639
|
+
P.value && u(p) ? (v(), w("p", xt, y(a.value.inherited), 1)) : L("", !0),
|
|
640
|
+
h("div", Et, [
|
|
641
|
+
u(V) ? (v(), w("p", Pt, y(u(V) === "load" ? a.value.loadError : a.value.saveError), 1)) : u(Y) ? (v(), w("p", St, y(a.value.saved), 1)) : u(H) ? (v(), w("p", Ot, y(a.value.dirty), 1)) : L("", !0)
|
|
642
|
+
]),
|
|
643
|
+
e.businessId ? u(x) ? (v(), w("p", At, y(a.value.loading), 1)) : u(V) === "load" ? (v(), w("div", $t, [
|
|
644
|
+
te(u(r), {
|
|
645
|
+
variant: "secondary",
|
|
646
|
+
label: a.value.retry,
|
|
647
|
+
onClick: u(O).load
|
|
648
|
+
}, null, 8, ["label", "onClick"])
|
|
649
|
+
])) : u(M) ? (v(), w("div", Mt, [
|
|
650
|
+
h("div", Rt, [
|
|
651
|
+
h("div", Nt, [
|
|
652
|
+
h("h2", null, [
|
|
653
|
+
Oe(y(a.value.products) + " ", 1),
|
|
654
|
+
h("span", null, y(u(O).rows.value.filter((n) => !n.unavailable).length), 1)
|
|
655
|
+
]),
|
|
656
|
+
h("div", Lt, [
|
|
657
|
+
te(u(I), {
|
|
658
|
+
modelValue: U.value,
|
|
659
|
+
"onUpdate:modelValue": m[1] || (m[1] = (n) => U.value = n),
|
|
660
|
+
label: a.value.search,
|
|
661
|
+
placeholder: a.value.search
|
|
662
|
+
}, null, 8, ["modelValue", "label", "placeholder"])
|
|
663
|
+
])
|
|
664
|
+
]),
|
|
665
|
+
u(O).rows.value.some((n) => !n.unavailable) ? C.value.length ? (v(), w("ul", Wt, [
|
|
666
|
+
(v(!0), w(se, null, ne(C.value, (n) => (v(), w("li", {
|
|
667
|
+
key: n.productId,
|
|
668
|
+
class: "upsell-row",
|
|
669
|
+
"data-product-id": n.productId
|
|
670
|
+
}, [
|
|
671
|
+
h("div", Ft, [
|
|
672
|
+
n.imageUrl && !A.value.has(n.productId) ? (v(), w("img", {
|
|
673
|
+
key: 0,
|
|
674
|
+
src: n.imageUrl,
|
|
675
|
+
alt: "",
|
|
676
|
+
class: "upsell-photo",
|
|
677
|
+
loading: "lazy",
|
|
678
|
+
onError: (b) => A.value.add(n.productId)
|
|
679
|
+
}, null, 40, Dt)) : (v(), w("span", Vt, y(a.value.missingPhoto), 1)),
|
|
680
|
+
h("div", null, [
|
|
681
|
+
h("h3", null, y(n.unavailable ? a.value.unavailable : n.name), 1),
|
|
682
|
+
n.unavailable ? (v(), w("p", Ht, y(n.productId), 1)) : (v(), w("p", qt, y([n.category, n.priceLabel].filter(Boolean).join(" · ")), 1)),
|
|
683
|
+
n.unavailable ? (v(), w("p", zt, y(a.value.unavailableHint), 1)) : L("", !0)
|
|
684
|
+
])
|
|
685
|
+
]),
|
|
686
|
+
h("div", Jt, [
|
|
687
|
+
te(u(g), {
|
|
688
|
+
"model-value": E(n.productId),
|
|
689
|
+
disabled: u(f),
|
|
690
|
+
"onUpdate:modelValue": (b) => u(O).change(n.productId, { adjustWeight: b })
|
|
691
|
+
}, {
|
|
692
|
+
label: Ie(() => [
|
|
693
|
+
h("span", Xt, y(a.value.adjust) + ": " + y(n.name), 1)
|
|
694
|
+
]),
|
|
695
|
+
_: 2
|
|
696
|
+
}, 1032, ["model-value", "disabled", "onUpdate:modelValue"])
|
|
697
|
+
]),
|
|
698
|
+
h("div", {
|
|
699
|
+
class: ke(["upsell-weight", { "upsell-weight-auto": !E(n.productId) }])
|
|
700
|
+
}, [
|
|
701
|
+
h("div", Yt, [
|
|
702
|
+
E(n.productId) ? (v(), w("span", Kt, y(o(n.productId)), 1)) : L("", !0),
|
|
703
|
+
h("output", {
|
|
704
|
+
"aria-label": `${a.value.weight}: ${n.name}`
|
|
705
|
+
}, y(E(n.productId) ? `${Math.round(i(n.productId) * 100)}%` : a.value.automatic), 9, Gt)
|
|
706
|
+
]),
|
|
707
|
+
h("input", {
|
|
708
|
+
type: "range",
|
|
709
|
+
min: "0",
|
|
710
|
+
max: "100",
|
|
711
|
+
step: "1",
|
|
712
|
+
value: Math.round(i(n.productId) * 100),
|
|
713
|
+
"aria-label": `${a.value.weight}: ${n.name}`,
|
|
714
|
+
"aria-valuetext": `${Math.round(i(n.productId) * 100)}% — ${o(n.productId)}`,
|
|
715
|
+
disabled: !E(n.productId) || u(f),
|
|
716
|
+
"data-boosted": E(n.productId) && i(n.productId) >= 0.8,
|
|
717
|
+
style: Ue({ "--upsell-fill": `${E(n.productId) ? i(n.productId) * 100 : 0}%` }),
|
|
718
|
+
onInput: (b) => R(n.productId, b),
|
|
719
|
+
onPointerdown: Q,
|
|
720
|
+
onPointermove: (b) => re(n.productId, b),
|
|
721
|
+
onPointerup: (b) => W(n.productId, b),
|
|
722
|
+
onPointercancel: (b) => W(n.productId, b),
|
|
723
|
+
onLostpointercapture: (b) => W(n.productId, b)
|
|
724
|
+
}, null, 44, Qt)
|
|
725
|
+
], 2)
|
|
726
|
+
], 8, Bt))), 128))
|
|
727
|
+
])) : (v(), w("p", jt, y(a.value.noMatches), 1)) : (v(), w("p", _t, y(a.value.empty), 1))
|
|
728
|
+
]),
|
|
729
|
+
(v(), ae(gt, {
|
|
730
|
+
host: D,
|
|
731
|
+
key: JSON.stringify([e.businessId, P.value]),
|
|
732
|
+
products: u(O).rows.value.filter((n) => !n.unavailable),
|
|
733
|
+
"saved-items": u(O).baseline.value,
|
|
734
|
+
"draft-items": u(O).items.value,
|
|
735
|
+
text: a.value,
|
|
736
|
+
touchpoints: e.previewTouchpoints
|
|
737
|
+
}, null, 8, ["host", "products", "saved-items", "draft-items", "text", "touchpoints"]))
|
|
738
|
+
])) : L("", !0) : (v(), w("p", Ut, y(a.value.chooseRestaurant), 1))
|
|
739
|
+
], 8, ht));
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
function ea(e) {
|
|
743
|
+
const t = new URL(e.baseUrl);
|
|
744
|
+
if (t.protocol !== "https:" && !(t.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(t.hostname)))
|
|
745
|
+
throw new Error("Use HTTPS for report-service, or HTTP on localhost.");
|
|
746
|
+
if (t.username || t.password || t.search || t.hash)
|
|
747
|
+
throw new Error("Report-service URL must not contain credentials, query parameters or a fragment.");
|
|
748
|
+
async function s(r, g, I = g === void 0 ? "GET" : "PUT") {
|
|
749
|
+
const k = await e.getToken();
|
|
750
|
+
if (!k) throw new Error("Sign in to Portal to load upselling settings.");
|
|
751
|
+
const l = await fetch(`${t.href.replace(/\/$/, "")}${r}`, {
|
|
752
|
+
method: I,
|
|
753
|
+
headers: { Authorization: `Bearer ${k}`, ...g === void 0 ? {} : { "Content-Type": "application/json" } },
|
|
754
|
+
body: g === void 0 ? void 0 : JSON.stringify(g),
|
|
755
|
+
cache: "no-store",
|
|
756
|
+
redirect: "error"
|
|
757
|
+
});
|
|
758
|
+
if (!l.ok) throw new Error(`Unable to ${g === void 0 ? "load" : "save"} upselling settings (${l.status}).`);
|
|
759
|
+
return { data: await l.json() };
|
|
760
|
+
}
|
|
761
|
+
return ta({ get: (r) => s(r), put: (r, g) => s(r, g), delete: (r) => s(r, void 0, "DELETE") });
|
|
762
|
+
}
|
|
763
|
+
function ta(e) {
|
|
764
|
+
const t = ({ businessId: s, restaurantId: r }) => `/${encodeURIComponent(s)}${r ? `/${encodeURIComponent(r)}` : ""}/upsell-settings`;
|
|
765
|
+
return {
|
|
766
|
+
async get(s) {
|
|
767
|
+
return (await e.get(t(s))).data;
|
|
768
|
+
},
|
|
769
|
+
async save(s, r) {
|
|
770
|
+
const g = { items: r.map(({ productId: I, adjustWeight: k, weight: l }) => ({ productId: I, adjustWeight: k, weight: l })) };
|
|
771
|
+
return (await e.put(t(s), g)).data;
|
|
772
|
+
},
|
|
773
|
+
...e.delete ? { async reset(s) {
|
|
774
|
+
if (!s.restaurantId) throw new Error("Only restaurant overrides can be reset");
|
|
775
|
+
return (await e.delete(t(s))).data;
|
|
776
|
+
} } : {}
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
function aa(e) {
|
|
780
|
+
const t = new URL(e), s = ["localhost", "127.0.0.1", "[::1]"].includes(t.hostname);
|
|
781
|
+
if (t.protocol !== "https:" && !(t.protocol === "http:" && s))
|
|
782
|
+
throw new Error("Use HTTPS for recommendations, or HTTP on localhost.");
|
|
783
|
+
if (t.username || t.password || t.search || t.hash)
|
|
784
|
+
throw new Error("Recommendation URL must not contain credentials, query parameters or a fragment.");
|
|
785
|
+
return t.href.replace(/\/$/, "");
|
|
786
|
+
}
|
|
787
|
+
function ra(e, t) {
|
|
788
|
+
if (!e || typeof e != "object") return !1;
|
|
789
|
+
const s = e;
|
|
790
|
+
if (s.restaurant_id !== t.restaurantId || t.mode === "current" && !["restaurant", "business", "none"].includes(s.source ?? "")) return !1;
|
|
791
|
+
const r = s.product_id, g = s.score;
|
|
792
|
+
return Array.isArray(r) && Array.isArray(g) && r.length === g.length && r.every((I) => typeof I == "string" && I.length > 0) && g.every((I) => typeof I == "number" && Number.isFinite(I)) && new Set(r).size === r.length;
|
|
793
|
+
}
|
|
794
|
+
function la(e) {
|
|
795
|
+
const t = aa(e.baseUrl);
|
|
796
|
+
return async (s) => {
|
|
797
|
+
const r = await e.getToken();
|
|
798
|
+
if (!r) throw new Error("Authentication required for preview");
|
|
799
|
+
const g = e.fetch ?? fetch, I = s.mode ?? "preview", k = await g(`${t}/recommendation/${encodeURIComponent(s.businessId)}/${I}`, {
|
|
800
|
+
method: "POST",
|
|
801
|
+
cache: "no-store",
|
|
802
|
+
redirect: "error",
|
|
803
|
+
signal: AbortSignal.timeout(15e3),
|
|
804
|
+
headers: { "Content-Type": "application/json", Authorization: `Bearer ${r}` },
|
|
805
|
+
body: JSON.stringify({
|
|
806
|
+
restaurant_id: s.restaurantId,
|
|
807
|
+
type: s.recommendationType === "cart" ? "cart" : "whats_hot",
|
|
808
|
+
...s.recommendationType === "cart" ? { cart_item: [...new Set(s.cart.map((a) => a.productId))] } : {},
|
|
809
|
+
...I === "preview" ? { items: s.items.map(({ productId: a, adjustWeight: U, weight: A }) => ({ productId: a, adjustWeight: U, weight: A })) } : {}
|
|
810
|
+
})
|
|
811
|
+
});
|
|
812
|
+
if (!k.ok) throw new Error(`Recommendation preview failed (${k.status})`);
|
|
813
|
+
const l = await k.json();
|
|
814
|
+
if (!ra(l, s)) throw new Error("Preview response is not supported");
|
|
815
|
+
const S = new Map((await e.loadProducts({ businessId: s.businessId, restaurantId: s.restaurantId })).map((a) => [a.productId, a]));
|
|
816
|
+
return { products: de(l.product_id.flatMap((a) => S.has(a) ? [S.get(a)] : []), s.limit), source: "unknown" };
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
const we = c.object({
|
|
820
|
+
catalog: c.array(
|
|
821
|
+
c.object({
|
|
822
|
+
_id: c.string(),
|
|
823
|
+
override: c.object({
|
|
824
|
+
items: c.record(
|
|
825
|
+
c.array(
|
|
826
|
+
c.object({
|
|
827
|
+
combinationKey: c.string().nullish(),
|
|
828
|
+
orderFrom: c.string().nullish(),
|
|
829
|
+
category: c.string().nullish()
|
|
830
|
+
})
|
|
831
|
+
)
|
|
832
|
+
).optional()
|
|
833
|
+
}).passthrough()
|
|
834
|
+
})
|
|
835
|
+
).default([]),
|
|
836
|
+
category: c.array(c.object({ _id: c.string(), name: c.string() })),
|
|
837
|
+
item: c.array(
|
|
838
|
+
c.object({
|
|
839
|
+
_id: c.string().min(1),
|
|
840
|
+
name: c.string(),
|
|
841
|
+
orderFrom: c.string().nullish(),
|
|
842
|
+
unit: c.string().nullish(),
|
|
843
|
+
perXUnit: c.coerce.number().nullish(),
|
|
844
|
+
isOutOfStocked: c.boolean().optional(),
|
|
845
|
+
thumbnail: c.string().nullish(),
|
|
846
|
+
category: c.string().nullish(),
|
|
847
|
+
price: c.object({
|
|
848
|
+
currency: c.string(),
|
|
849
|
+
amount: c.number(),
|
|
850
|
+
precision: c.number()
|
|
851
|
+
}).nullish()
|
|
852
|
+
})
|
|
853
|
+
)
|
|
854
|
+
}), xe = c.object({
|
|
855
|
+
_id: c.string().min(1),
|
|
856
|
+
menuMode: c.enum(["businessLevel", "restaurantLevel"]).optional(),
|
|
857
|
+
modules: we.nullish(),
|
|
858
|
+
restaurants: c.array(
|
|
859
|
+
c.object({
|
|
860
|
+
restaurantId: c.string(),
|
|
861
|
+
modules: we.nullish()
|
|
862
|
+
})
|
|
863
|
+
).nullish()
|
|
864
|
+
});
|
|
865
|
+
function ve() {
|
|
866
|
+
const e = pe();
|
|
867
|
+
if (e.namespace.value !== "dev" || e.currentCountry.value !== "MY")
|
|
868
|
+
throw new Error("Upselling is available in MY dev only.");
|
|
869
|
+
}
|
|
870
|
+
function sa() {
|
|
871
|
+
return ea({
|
|
872
|
+
baseUrl: "https://query-engine.feedmeapidev.com",
|
|
873
|
+
getToken: () => (ve(), Te.getIdToken() ?? "")
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
function na(e) {
|
|
877
|
+
const t = new URL(e), s = t.protocol === "http:" && ["127.0.0.1", "localhost"].includes(t.hostname), r = t.origin === "https://public-query-engine.feedmeapidev.com";
|
|
878
|
+
if (!s && !r || t.username || t.password || t.search || t.hash || t.pathname !== "/")
|
|
879
|
+
throw new Error(
|
|
880
|
+
"Use a local or MY dev recommendation backend for preview."
|
|
881
|
+
);
|
|
882
|
+
return la({
|
|
883
|
+
baseUrl: t.origin,
|
|
884
|
+
getToken: () => (ve(), Te.getIdToken() ?? ""),
|
|
885
|
+
loadProducts: Ee
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
function ye(e, t) {
|
|
889
|
+
var I, k;
|
|
890
|
+
const s = xe.parse(e), r = s.restaurants || s.menuMode === "restaurantLevel" ? (k = (I = s.restaurants) == null ? void 0 : I.find((l) => l.restaurantId === t)) == null ? void 0 : k.modules : s.modules;
|
|
891
|
+
if (!r) return [];
|
|
892
|
+
const g = new Map(
|
|
893
|
+
r.category.map((l) => [l._id, l.name])
|
|
894
|
+
);
|
|
895
|
+
return r.item.map((l) => ({
|
|
896
|
+
productId: l._id,
|
|
897
|
+
name: l.name,
|
|
898
|
+
...l.unit != null ? { unit: l.unit } : {},
|
|
899
|
+
...l.perXUnit != null ? { perXUnit: l.perXUnit } : {},
|
|
900
|
+
...l.isOutOfStocked != null ? { isOutOfStocked: l.isOutOfStocked } : {},
|
|
901
|
+
imageUrl: l.thumbnail ?? void 0,
|
|
902
|
+
category: g.get(l.category ?? ""),
|
|
903
|
+
priceLabel: l.price ? Ne(l.price) : void 0
|
|
904
|
+
}));
|
|
905
|
+
}
|
|
906
|
+
const Ee = async ({
|
|
907
|
+
businessId: e,
|
|
908
|
+
restaurantId: t
|
|
909
|
+
}) => {
|
|
910
|
+
const r = (await Pe(e)).find((g) => g.scope.restaurantId === t);
|
|
911
|
+
if (!r)
|
|
912
|
+
throw new Error("This outlet is not available in the current business.");
|
|
913
|
+
if (r.unavailableReason) throw new Error(r.unavailableReason);
|
|
914
|
+
return r.products;
|
|
915
|
+
}, oa = c.array(
|
|
916
|
+
c.object({
|
|
917
|
+
_id: c.string(),
|
|
918
|
+
businessId: c.string(),
|
|
919
|
+
profile: c.object({ name: c.string().optional() }).passthrough().optional(),
|
|
920
|
+
catalogId: c.string().nullish(),
|
|
921
|
+
additionalCatalogs: c.array(c.string()).nullish(),
|
|
922
|
+
takeaway: c.object({ catalogId: c.string().nullish() }).passthrough().nullish(),
|
|
923
|
+
pickup: c.object({ catalogId: c.string().nullish() }).passthrough().nullish()
|
|
924
|
+
}).passthrough()
|
|
925
|
+
), Pe = async (e) => {
|
|
926
|
+
var S, a, U, A, P, _, N;
|
|
927
|
+
ve();
|
|
928
|
+
const t = pe(), s = oa.parse(t.restaurants.value).filter((T) => T.businessId === e), r = c.object({ menuVersion: c.enum(["v3", "v4"]).nullish() }).parse(t.currentBusiness.value).menuVersion, g = await Re(
|
|
929
|
+
`menu-v4/businesses/${encodeURIComponent(
|
|
930
|
+
e
|
|
931
|
+
)}/menu-v4/effective-menu?modules=item,category,catalog`
|
|
932
|
+
).get(""), I = xe.parse(g.data), k = I.menuMode === "restaurantLevel", l = [
|
|
933
|
+
{
|
|
934
|
+
name: "Business default",
|
|
935
|
+
scope: { businessId: e },
|
|
936
|
+
products: k ? [] : ye(g.data),
|
|
937
|
+
...k ? {
|
|
938
|
+
unavailableReason: "This business uses separate outlet menus. Apply to selected outlets instead; product IDs cannot be combined into one shared catalog."
|
|
939
|
+
} : {}
|
|
940
|
+
}
|
|
941
|
+
];
|
|
942
|
+
for (const T of s) {
|
|
943
|
+
const j = k ? (a = (S = I.restaurants) == null ? void 0 : S.find((D) => D.restaurantId === T._id)) == null ? void 0 : a.modules : I.modules, J = /* @__PURE__ */ new Set();
|
|
944
|
+
let F;
|
|
945
|
+
if (!j) F = "No menu is available for this outlet.";
|
|
946
|
+
else if (r !== "v3" && r !== "v4")
|
|
947
|
+
F = "Menu version could not be verified. Nothing will be applied.";
|
|
948
|
+
else {
|
|
949
|
+
const D = [
|
|
950
|
+
T.catalogId ?? null,
|
|
951
|
+
...T.additionalCatalogs ?? [],
|
|
952
|
+
(U = T.takeaway) == null ? void 0 : U.catalogId,
|
|
953
|
+
(A = T.pickup) == null ? void 0 : A.catalogId
|
|
954
|
+
].filter((O) => O !== void 0);
|
|
955
|
+
for (const O of D) {
|
|
956
|
+
const X = O ? j.catalog.find((z) => z._id === O) : void 0;
|
|
957
|
+
if (O && !X) {
|
|
958
|
+
F = "An assigned catalog is unavailable. Reload this outlet’s menu before applying.";
|
|
959
|
+
break;
|
|
960
|
+
}
|
|
961
|
+
for (const z of j.item) {
|
|
962
|
+
const x = (_ = (P = X == null ? void 0 : X.override.items) == null ? void 0 : P[z._id]) == null ? void 0 : _.find(
|
|
963
|
+
(M) => !M.combinationKey
|
|
964
|
+
);
|
|
965
|
+
((x == null ? void 0 : x.orderFrom) ?? z.orderFrom) !== "NONE" && (r === "v4" || (x == null ? void 0 : x.category) !== "") && J.add(z._id);
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
l.push({
|
|
970
|
+
name: ((N = T.profile) == null ? void 0 : N.name) ?? T._id,
|
|
971
|
+
scope: { businessId: e, restaurantId: T._id },
|
|
972
|
+
products: ye(g.data, T._id).filter(
|
|
973
|
+
(D) => J.has(D.productId)
|
|
974
|
+
),
|
|
975
|
+
unavailableReason: F
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
return l;
|
|
979
|
+
};
|
|
980
|
+
var ua = { mode: "development", appMode: "mf" };
|
|
981
|
+
const ha = /* @__PURE__ */ ce({
|
|
982
|
+
__name: "Upselling",
|
|
983
|
+
setup(e) {
|
|
984
|
+
const t = pe(), s = sa(), r = na(
|
|
985
|
+
"https://public-query-engine.feedmeapidev.com"
|
|
986
|
+
), g = $(!1), I = $(!1), k = B(
|
|
987
|
+
() => ua.mode === "development" && t.namespace.value === "dev" && t.currentCountry.value === "MY"
|
|
988
|
+
), l = B(
|
|
989
|
+
() => {
|
|
990
|
+
var S;
|
|
991
|
+
return `${t.namespace.value}:${t.currentCountry.value}:${(S = t.sessionUser.value) == null ? void 0 : S.id}`;
|
|
992
|
+
}
|
|
993
|
+
);
|
|
994
|
+
return Me(
|
|
995
|
+
() => !I.value && (!g.value || window.confirm("Discard unsaved changes?"))
|
|
996
|
+
), (S, a) => {
|
|
997
|
+
var U;
|
|
998
|
+
return k.value ? (v(), ae(u(Zt), {
|
|
999
|
+
key: l.value,
|
|
1000
|
+
"business-id": ((U = u(t).currentBusiness.value) == null ? void 0 : U._id) ?? "",
|
|
1001
|
+
api: u(s),
|
|
1002
|
+
"load-products": u(Ee),
|
|
1003
|
+
"load-apply-targets": u(Pe),
|
|
1004
|
+
"load-preview": u(r),
|
|
1005
|
+
onDirtyChange: a[0] || (a[0] = (A) => g.value = A),
|
|
1006
|
+
onBusyChange: a[1] || (a[1] = (A) => I.value = A)
|
|
1007
|
+
}, null, 8, ["business-id", "api", "load-products", "load-apply-targets", "load-preview"])) : L("", !0);
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
});
|
|
1011
|
+
export {
|
|
1012
|
+
ha as default
|
|
1013
|
+
};
|