@feedmepos/mf-connect 0.1.121-dev → 0.1.121-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.
- package/dist/{App-DwtaLO6F.js → App-C4T5UWGw.js} +493 -502
- package/dist/{Bin-BBaVggZI.js → Bin-ude598pY.js} +8 -8
- package/dist/{Broadcast-CqAQ3EmE.js → Broadcast-BtJbmDzX.js} +21 -22
- package/dist/{CampaignAnalytic-34bfP8iY.js → CampaignAnalytic-DxC_sgPy.js} +7 -7
- package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-BvAAxE3a.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-CBy6cXYx.js} +9 -8
- package/dist/{Card-8hlnKnhk.js → Card-B6Qt_KqI.js} +22 -22
- package/dist/{Collections-BJ0-UjKf.js → Collections-BCsbhQJM.js} +185 -197
- package/dist/{Credit-DJNc__yp.js → Credit-CCl-UjVj.js} +20 -21
- package/dist/{DateRangeChip.vue_vue_type_script_setup_true_lang-BvilcyyB.js → DateRangeChip.vue_vue_type_script_setup_true_lang-DE_JYKS8.js} +1 -1
- package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-CReXb9gY.js +3493 -0
- package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-DFzVuuEy.js → EffectSheet.vue_vue_type_style_index_0_lang-D_wHxBmj.js} +16 -16
- package/dist/{Experience-D-cUhjWc.js → Experience-BZfx679t.js} +31 -32
- package/dist/{FileSaver.min-DKYYse6A.js → FileSaver.min-aAU7_riE.js} +1 -1
- package/dist/{Game-DdFV90Kp.js → Game-L-RmEmNY.js} +18 -19
- package/dist/{GiftCardSetup-Dz0AN159.js → GiftCardSetup-BA_I83wm.js} +31 -31
- package/dist/{GoalPickerPanel.vue_vue_type_script_setup_true_lang-GCp3IFaC.js → GoalPickerPanel.vue_vue_type_script_setup_true_lang-CtiPxBgn.js} +7 -7
- package/dist/{Goals-Dg_kAezl.js → Goals-Dur5LKYk.js} +4 -4
- package/dist/{ImageInput.vue_vue_type_script_setup_true_lang-B_H1Bgy1.js → ImageInput.vue_vue_type_script_setup_true_lang-ALdW6e1t.js} +1 -1
- package/dist/{Index-ZSup3I7J.js → Index-_sUu1gDp.js} +10 -10
- package/dist/{LocationPicker.vue_vue_type_script_setup_true_lang-DisF-jcd.js → LocationPicker.vue_vue_type_script_setup_true_lang-BgweoLh2.js} +1 -1
- package/dist/{LottieAnimation.vue_vue_type_script_setup_true_lang-BHhjZOYi.js → LottieAnimation.vue_vue_type_script_setup_true_lang-BjvB1fab.js} +1 -1
- package/dist/{LoyaltyDashboard-D8BhHsaw.js → LoyaltyDashboard-DgLAdZiP.js} +15 -15
- package/dist/{MainLayout-BBnhRxyR.js → MainLayout-DOXx217V.js} +1 -1
- package/dist/{MainLayout.vue_vue_type_script_setup_true_lang-DFrPlj5u.js → MainLayout.vue_vue_type_script_setup_true_lang-BwT0vGID.js} +3 -3
- package/dist/{Marketing-5F9LLn91.js → Marketing-CoBYtHdr.js} +4 -4
- package/dist/{MarketingMaterialEdit-C7dD4Bzw.js → MarketingMaterialEdit-R2jgDJKr.js} +211 -214
- package/dist/{Member-Dk4JeGru.js → Member-CQicHGEK.js} +7 -7
- package/dist/{MemberDetailSheet.vue_vue_type_script_setup_true_lang-ISolD_Qg.js → MemberDetailSheet.vue_vue_type_script_setup_true_lang-BY57N2OM.js} +47 -39
- package/dist/{MemberImportHistory-C0Ep8L2q.js → MemberImportHistory-C_xDFYQh.js} +7 -7
- package/dist/{MemberList-BsuPfBgk.js → MemberList-DaOsohKg.js} +105 -103
- package/dist/{MemberTransactions-mZ3fHw5O.js → MemberTransactions-DOCrHQ2s.js} +1 -1
- package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-1weyRM8c.js → MessageInput.vue_vue_type_script_setup_true_lang-ep7Yqi5n.js} +12 -12
- package/dist/{MetricInfoTooltip.vue_vue_type_script_setup_true_lang-caED3JRW.js → MetricInfoTooltip.vue_vue_type_script_setup_true_lang-CTorzIeM.js} +1 -1
- package/dist/{Mission-C7DqUOJz.js → Mission-BeNYiQ9K.js} +21 -22
- package/dist/{Overview-U201nBVO.js → Overview-8QoQ_gHU.js} +20 -20
- package/dist/{Overview-VABLg36G.js → Overview-BMXpAv-n.js} +144 -145
- package/dist/{Point-DU6Ndv35.js → Point-Dyq5SXT2.js} +21 -22
- package/dist/{Promotion-9UhZXNPb.js → Promotion-BLAsz0mu.js} +131 -137
- package/dist/{Queue-CUxMedbd.js → Queue-qmf3ymVp.js} +45 -45
- package/dist/{Record-BIftCQzV.js → Record-DMqhKlIc.js} +9 -9
- package/dist/{Review-lyVgTfsP.js → Review-DDGtAXxX.js} +2 -2
- package/dist/ReviewFacebookCallback-jCP7vNJ3.js +238 -0
- package/dist/{ReviewGoogleCallback-B41PXfsj.js → ReviewGoogleCallback-kIu4wO-x.js} +5 -5
- package/dist/{Reward-BMun_Rs4.js → Reward-B9eyzyk7.js} +16 -16
- package/dist/{RewardGroup.vue_vue_type_script_setup_true_lang-3TONrUQu.js → RewardGroup.vue_vue_type_script_setup_true_lang-B5oNDez7.js} +13 -13
- package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-Cyo98lN8.js +1884 -0
- package/dist/{Segment-1VS7ycXi.js → Segment-CSenE8-8.js} +306 -303
- package/dist/{SendCollectionSheet.vue_vue_type_script_setup_true_lang-C5iJSlxi.js → SendCollectionSheet.vue_vue_type_script_setup_true_lang-gUmEIxLj.js} +14 -14
- package/dist/{SendVoucherSheet.vue_vue_type_script_setup_true_lang-CXY9Wyk9.js → SendVoucherSheet.vue_vue_type_script_setup_true_lang-5m7qY393.js} +4 -4
- package/dist/{Setting-BdtzvKjt.js → Setting-CshEhFJ0.js} +148 -159
- package/dist/{SettingAdvertisements-BO2l3HBT.js → SettingAdvertisements-B7NU1mTE.js} +12 -12
- package/dist/Settings-CSeRLtGl.js +179 -0
- package/dist/{Store-DWQz-MgY.js → Store-BouP_m9K.js} +28 -28
- package/dist/{StoreRewards-Bfwuqxf-.js → StoreRewards-NX24LqS_.js} +15 -15
- package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-B2zDGFAw.js +1265 -0
- package/dist/TargetLocationInput.vue_vue_type_script_setup_true_lang-IGh7Kiot.js +142 -0
- package/dist/{Tier-CKn-l-wY.js → Tier-Cg5KAErk.js} +687 -2575
- package/dist/{Title-BXDk69uL.js → Title-BcziCAh4.js} +94 -95
- package/dist/{Transaction-D4HQO4i9.js → Transaction-DK0Splad.js} +2 -2
- package/dist/Upselling-1RSD_l_k.js +200 -0
- package/dist/{UserRuleGroup.vue_vue_type_script_setup_true_lang-um124o4t.js → UserRuleGroup.vue_vue_type_script_setup_true_lang-C-mg8LqR.js} +26 -26
- package/dist/{Voucher-BGIyw4jq.js → Voucher-DX6-GX17.js} +19 -19
- package/dist/{VoucherEditor.vue_vue_type_script_setup_true_lang-BKyZj5SP.js → VoucherEditor.vue_vue_type_script_setup_true_lang-7KZNW6gS.js} +12 -12
- package/dist/{WhatsappAccount-Cd82g_xj.js → WhatsappAccount-qbnBp7mv.js} +6 -6
- package/dist/{WhatsappAccountStatusLabel.vue_vue_type_script_setup_true_lang-DWy8kS66.js → WhatsappAccountStatusLabel.vue_vue_type_script_setup_true_lang-BAw8wUAu.js} +1 -1
- package/dist/{WhatsappBot-auQhO8zk.js → WhatsappBot-Dkx24HI7.js} +6 -6
- package/dist/{WhatsappBotLogs-CWuJzK9W.js → WhatsappBotLogs-CR9RPc-1.js} +6 -6
- package/dist/{WhatsappBotSettings-B8KXMpIF.js → WhatsappBotSettings-DF97RSSV.js} +4 -4
- package/dist/{WhatsappLayout-DxooAkkL.js → WhatsappLayout-JAye9JZI.js} +3 -3
- package/dist/{WhatsappNotificationGroupDialog.vue_vue_type_script_setup_true_lang-CYHmgQ2v.js → WhatsappNotificationGroupDialog.vue_vue_type_script_setup_true_lang-toCNd_Ip.js} +3 -3
- package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-DilxQM_z.js → ZodTextField.vue_vue_type_script_setup_true_lang-DvMdQKET.js} +2 -2
- package/dist/{app-BG-zK89d.js → app-O2-Xtjxu.js} +15017 -14861
- package/dist/app.js +3 -4
- package/dist/{base.export-BcMuREGH.js → base.export-0NAAWE2x.js} +2 -2
- package/dist/{business-9_NOI2V9.js → business-DO-6gAei.js} +1 -1
- package/dist/{campaign-DjBTRZyA.js → campaign-CKpTYx8r.js} +94 -121
- package/dist/{campaign-8y_9SvKP.js → campaign-CjtbytTA.js} +28 -34
- package/dist/{campaign.enum-Dx-Zo68Q.js → campaign.enum-BqekIiiN.js} +1 -2
- package/dist/campaign.fn-DNva0Lzi.js +776 -0
- package/dist/{collection.fn-yXurU9iv.js → collection.fn-DgVYvv2u.js} +2 -2
- package/dist/{currency-YzyBFtDU.js → currency-RCSoljIc.js} +1 -1
- package/dist/{effect-bMGarJZ6.js → effect-Cic-yJ5a.js} +1 -1
- package/dist/{email-addresses-Ciu83j_3.js → email-addresses-Cz7nxyM7.js} +25 -25
- package/dist/{feature-flag-H5D1Cob5.js → feature-flag-BHFUKA3S.js} +70 -70
- package/dist/google-C3S8u0mT.js +4 -0
- package/dist/{helper-BH9HMikb.js → helper-H_gC1vRi.js} +1 -1
- package/dist/{index-CH-KHkm5.js → index-B-RKMcrS.js} +1 -1
- package/dist/{index-DkMy7WpU.js → index-BEFoWcsk.js} +2 -2
- package/dist/{index-DbxiG50D.js → index-BFxCHHSQ.js} +2 -2
- package/dist/{index-Cyf05z_2.js → index-BU-CbflW.js} +2 -2
- package/dist/{index-CIOidYvo.js → index-C-vDa3pL.js} +1 -1
- package/dist/{index-MWNnMT2T.js → index-CSNMZuv4.js} +4 -4
- package/dist/{index-RvJ5cq__.js → index-CTDzF7d_.js} +3 -3
- package/dist/{index-BaTnDV-T.js → index-D5_gAcWw.js} +2613 -2699
- package/dist/{index-BHO82_Ix.js → index-DRuHmNoi.js} +1 -1
- package/dist/{index-DYu7ZdQt.js → index-DVIKJ8Fi.js} +1 -1
- package/dist/{index-_giqGuYM.js → index-DVt628Qh.js} +1 -1
- package/dist/{index-pnM5q4c_.js → index-DZBbFrO4.js} +232 -389
- package/dist/{index-BxwJfT08.js → index-DlRDCDW-.js} +197 -197
- package/dist/{index-BvKJM3M2.js → index-Dw5ikwFR.js} +15 -29
- package/dist/{index-CooParq-.js → index-G8S_j3nj.js} +581 -682
- package/dist/{index-taPHgOqE.js → index-GJRqAxuJ.js} +251 -608
- package/dist/{index-Ye3qFt34.js → index-bMAgU-Xo.js} +10 -10
- package/dist/{index-DpkoCl4z.js → index-ka7lQ9t1.js} +10 -10
- package/dist/{index-B7-Uvnfn.js → index-rQ30JRKa.js} +6 -19
- package/dist/{index-CJAFz9Nn.js → index-zsTY_sDR.js} +1 -1
- package/dist/{index.esm2017-CLxZor1Y.js → index.esm2017-Cf5e9e4I.js} +104 -104
- package/dist/{loading-CsOSUWBd.js → loading-Q15eugE9.js} +1 -1
- package/dist/{lodash-CshibTzh.js → lodash-B9y2Z6FT.js} +1 -1
- package/dist/{member-import-BdaGAjjt.js → member-import-B7-pNlAu.js} +1 -1
- package/dist/{membership-C5JWO1FM.js → membership-FjTQN8-W.js} +2 -2
- package/dist/{money-Blt5EM43.js → money-DpnjYb20.js} +1 -1
- package/dist/{number-COm3MiH8.js → number-DQpgkGJp.js} +1 -1
- package/dist/objectid-DDT17fUp.js +145 -0
- package/dist/{onboarding-BbQDJOOS.js → onboarding-j-EtZDu5.js} +36 -36
- package/dist/{onboardingSetup-BLISY52M.js → onboardingSetup-B4yc4Acp.js} +2 -2
- package/dist/{plugins-De_chCYU.js → plugins-TZdigPwR.js} +3 -3
- package/dist/{reward-Dl8Zoxe_.js → reward-BpRIHbOy.js} +1 -1
- package/dist/{rule-D6_iss3O.js → rule-PjQfvtJP.js} +492 -572
- package/dist/rule-builder-Vloq9R4R.js +102 -0
- package/dist/style.css +1 -1
- package/dist/template-CeZkljlm.js +275 -0
- package/dist/{timezone-CA5FwOyy.js → timezone-BmgCN50d.js} +1 -1
- package/dist/{transaction.fn-DI_NeGQb.js → transaction.fn-C9wUfIRo.js} +2 -2
- package/dist/{trigger-CuymoMM-.js → trigger-D9XVMrkP.js} +9 -9
- package/dist/{useMarketingMaterialActions-Bz0Kgvgd.js → useMarketingMaterialActions-2_HeLxeK.js} +4 -4
- package/dist/{usePagination-yb1rupwa.js → usePagination-Do3Rw4mx.js} +1 -1
- package/dist/{user-QSKyFaMI.js → user-CJpvF5mn.js} +1 -1
- package/dist/vue-i18n-CJsKXxJX.js +2365 -0
- package/dist/{xlsx--RjkGa9A.js → xlsx-CaTmMdcM.js} +440 -440
- package/dist/{zod-CmPMd-h0.js → zod-BcPs1As4.js} +1 -1
- package/package.json +3 -7
- package/dist/AuditLogs-s572aHLw.js +0 -2016
- package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-CSjOHBhA.js +0 -4439
- package/dist/Grab-BSQt4deB.js +0 -301
- package/dist/ReviewFacebookCallback-Da5G19bE.js +0 -225
- package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-DHzFgr4h.js +0 -1923
- package/dist/Settings-CvYawDU5.js +0 -286
- package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-CBwmDKAw.js +0 -1319
- package/dist/TargetLocationInput.vue_vue_type_script_setup_true_lang-CHzFjo24.js +0 -7007
- package/dist/Upselling-CikWzKq7.js +0 -1032
- package/dist/campaign.fn-COkPH1QE.js +0 -776
- package/dist/duplicateCampaign-dRWioann.js +0 -51
- package/dist/google-BQK68wbe.js +0 -5
- package/dist/objectid-DQTx3-ee.js +0 -145
- package/dist/template-Cw6j1cLX.js +0 -224
- package/dist/vue-i18n-B_qtODCw.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-BG-zK89d.js";
|
|
6
|
-
import { S as Ue, a as _e } from "./index-Ye3qFt34.js";
|
|
7
|
-
import { f as Ne } from "./currency-YzyBFtDU.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
|
-
};
|