@feedmepos/mf-connect 0.1.98-beta.8 → 0.1.98-beta.80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/dist/{App-DsB2o1oB.js → App-DievprEi.js} +853 -683
  2. package/dist/{AuditLogs-BcfgiYnJ.js → AuditLogs-DrdqOhZL.js} +16 -13
  3. package/dist/{Bin-DMr7K8Kj.js → Bin-Ci2k3z77.js} +8 -8
  4. package/dist/Broadcast-CpDMAG1o.js +306 -0
  5. package/dist/CampaignAnalytic-uRyGaLaN.js +1830 -0
  6. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-CwGoEBsW.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-DtGe2Og1.js} +8 -5
  7. package/dist/Card-tb98Kyr-.js +1086 -0
  8. package/dist/{Collections-B0uGC2FE.js → Collections-P1S5WjnJ.js} +14 -13
  9. package/dist/Credit-DwK7JYf-.js +286 -0
  10. package/dist/DateRangeChip.vue_vue_type_script_setup_true_lang-Cyk0iIsd.js +53 -0
  11. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-8r29jKh9.js +4432 -0
  12. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-DJLxGk7W.js → EffectSheet.vue_vue_type_style_index_0_lang-BML_-v8I.js} +36 -36
  13. package/dist/Experience-BejtRlOj.js +288 -0
  14. package/dist/{FileSaver.min-BlA0oZEC.js → FileSaver.min-C-hmBaHm.js} +1 -1
  15. package/dist/FilterChip.vue_vue_type_script_setup_true_lang-3bH-tZAm.js +138 -0
  16. package/dist/Game-n8qL896g.js +356 -0
  17. package/dist/GiftCardSetup-Bgsfcu7N.js +736 -0
  18. package/dist/GoalPickerPanel.vue_vue_type_script_setup_true_lang-CzL68PPP.js +424 -0
  19. package/dist/Goals-BB8LJlq3.js +247 -0
  20. package/dist/{Grab-DmmwrGzk.js → Grab-COq3Ujst.js} +33 -32
  21. package/dist/{ImageInput.vue_vue_type_script_setup_true_lang-DNtLW0yQ.js → ImageInput.vue_vue_type_script_setup_true_lang-BmLclEyi.js} +1 -1
  22. package/dist/{Index-m7l4insz.js → Index-BdkIinaE.js} +10 -10
  23. package/dist/{LocationPicker.vue_vue_type_script_setup_true_lang-B9sJ-M20.js → LocationPicker.vue_vue_type_script_setup_true_lang-DsWv3DVb.js} +1 -1
  24. package/dist/{LottieAnimation.vue_vue_type_script_setup_true_lang-Dsg2sWjF.js → LottieAnimation.vue_vue_type_script_setup_true_lang-DvOzGF8c.js} +1 -1
  25. package/dist/LoyaltyDashboard-D4Jtpw0n.js +2911 -0
  26. package/dist/MainLayout-Ca-Xm3eZ.js +143 -0
  27. package/dist/{Marketing-C9pSIdBU.js → Marketing-Cpe4s7NZ.js} +7 -6
  28. package/dist/{MarketingMaterialEdit-BEF2T9LR.js → MarketingMaterialEdit-nTeS9VVx.js} +15 -14
  29. package/dist/Member-DgGZ4Cdg.js +654 -0
  30. package/dist/MemberDetailSheet.vue_vue_type_script_setup_true_lang-_O3B-FIA.js +1281 -0
  31. package/dist/MemberImportHistory-rdlbDVWU.js +187 -0
  32. package/dist/MemberList-BC4aRJTt.js +334 -0
  33. package/dist/{MemberTransactions-CAut1TQb.js → MemberTransactions-BFfdTttp.js} +1 -1
  34. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-1AuHixPC.js → MessageInput.vue_vue_type_script_setup_true_lang-DXajAQy9.js} +5928 -5644
  35. package/dist/MetricInfoTooltip.vue_vue_type_script_setup_true_lang-8xVDzdO3.js +40 -0
  36. package/dist/Mission-BWCNKTjU.js +363 -0
  37. package/dist/Overview--Q7vzhNK.js +1316 -0
  38. package/dist/{Overview-DOJj4XvO.js → Overview-i02Wnyjn.js} +23 -20
  39. package/dist/Point-CiWxqny5.js +297 -0
  40. package/dist/Promotion-B0G9qfBm.js +426 -0
  41. package/dist/{Queue-55G2gtP5.js → Queue-YfwgYmzH.js} +16 -13
  42. package/dist/{Record-DNPI02c6.js → Record-CCuwrPKW.js} +9 -9
  43. package/dist/Review-ymsfdh7Q.js +45 -0
  44. package/dist/ReviewFacebookCallback-DyDExWvP.js +238 -0
  45. package/dist/ReviewGoogleCallback-DNyg3n2S.js +213 -0
  46. package/dist/{Reward-CnP8R2pS.js → Reward-BKIb0ezH.js} +28 -28
  47. package/dist/{RewardGroup.vue_vue_type_script_setup_true_lang-BN71h9IK.js → RewardGroup.vue_vue_type_script_setup_true_lang-DPaaNgpr.js} +26 -23
  48. package/dist/{RuleGroup.vue_vue_type_script_setup_true_lang-CtB9Ls5-.js → RuleGroup.vue_vue_type_script_setup_true_lang-BLFLybFn.js} +198 -186
  49. package/dist/{Segment-CxiQnnyj.js → Segment-D5_pp7fh.js} +278 -276
  50. package/dist/{SendCollectionSheet.vue_vue_type_script_setup_true_lang-B1vj5f7T.js → SendCollectionSheet.vue_vue_type_script_setup_true_lang-BLLjIA-D.js} +45 -42
  51. package/dist/{SendVoucherSheet.vue_vue_type_script_setup_true_lang-cWx0G3nM.js → SendVoucherSheet.vue_vue_type_script_setup_true_lang-BRIcZwnU.js} +4 -4
  52. package/dist/Setting-CD78gIMU.js +574 -0
  53. package/dist/{SettingAdvertisements-Vt7w1WN3.js → SettingAdvertisements-C2AIT4s4.js} +12 -12
  54. package/dist/Settings-DI_tryQV.js +230 -0
  55. package/dist/Store-BV2JTRNZ.js +2615 -0
  56. package/dist/{StoreRewards-DILeipMG.js → StoreRewards-Bk55YXyO.js} +15 -15
  57. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-BZZ1fqwg.js +1331 -0
  58. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-C7lVeybl.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-BrEzWVrH.js} +2 -2
  59. package/dist/{Tier-BAZ1xuKL.js → Tier-CO2K30Ew.js} +2576 -757
  60. package/dist/{Title-CcNAt47f.js → Title-qProQh3T.js} +41 -37
  61. package/dist/Transaction-qL5L-fE_.js +45 -0
  62. package/dist/{UserRuleGroup.vue_vue_type_script_setup_true_lang-hUjQVZ_U.js → UserRuleGroup.vue_vue_type_script_setup_true_lang-Co1BPScS.js} +26 -26
  63. package/dist/Voucher-VFD1LY9Y.js +837 -0
  64. package/dist/{VoucherEditor.vue_vue_type_script_setup_true_lang-CTQDxc5l.js → VoucherEditor.vue_vue_type_script_setup_true_lang-9QyTl7iq.js} +118 -124
  65. package/dist/WhatsappAccount-CxSGqm7H.js +325 -0
  66. package/dist/WhatsappAccountStatusLabel.vue_vue_type_script_setup_true_lang-D8L6izf0.js +96 -0
  67. package/dist/WhatsappBot-C4Oz7Xwv.js +441 -0
  68. package/dist/WhatsappBotSettings-CKqaWzwE.js +136 -0
  69. package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-DuRKA4cj.js → ZodTextField.vue_vue_type_script_setup_true_lang-Bcsi94dw.js} +2 -2
  70. package/dist/{app-Z-UKRG5V.js → app-BEYzXWZO.js} +50954 -42517
  71. package/dist/app.js +1 -1
  72. package/dist/base.export-S_82Elmg.js +75 -0
  73. package/dist/browser-BSAOEeIM.js +1478 -0
  74. package/dist/{business-C7EF6cKC.js → business-DH7djUl8.js} +5 -5
  75. package/dist/campaign-DlHDgoFX.js +100 -0
  76. package/dist/campaign-k_WHxsOR.js +400 -0
  77. package/dist/{campaign.enum-BNN2gLFY.js → campaign.enum-Dx-Zo68Q.js} +1 -1
  78. package/dist/{campaign.fn-Bd34dVnx.js → campaign.fn-B-4JRzft.js} +67 -67
  79. package/dist/{collectible.enum-DO9HdJGH.js → collectible.enum-Liy2wH3s.js} +1 -1
  80. package/dist/collection.fn-zQwWDzZT.js +26 -0
  81. package/dist/currency-CQVHXBFe.js +7 -0
  82. package/dist/{duplicateCampaign-2ODeDw3a.js → duplicateCampaign-YTXMbJTj.js} +11 -11
  83. package/dist/{effect-BcB8IlTI.js → effect-CQkVLHWi.js} +1 -1
  84. package/dist/{email-addresses-BcTeU4Sh.js → email-addresses-BIoVbPGC.js} +209 -201
  85. package/dist/google-C3S8u0mT.js +4 -0
  86. package/dist/{helper-BSgrCJRv.js → helper-BCkTvF4m.js} +1 -1
  87. package/dist/{index-CoHWpylO.js → index-B-bQnb0_.js} +2115 -2557
  88. package/dist/index-BAJOC43K.js +14550 -0
  89. package/dist/{index-HXiYGO4_.js → index-BFIHEBnX.js} +6343 -7693
  90. package/dist/{index-VlFWaBrg.js → index-BJIQe3QJ.js} +1 -1
  91. package/dist/{index-BpI-BI4H.js → index-BJkRTH5T.js} +4 -4
  92. package/dist/index-BOJogkKQ.js +172 -0
  93. package/dist/{index-BoYEqLif.js → index-BRPajAkE.js} +1517 -263
  94. package/dist/{index-CsoBDon4.js → index-BTkxgos0.js} +1590 -1523
  95. package/dist/index-BUP4aHq8.js +32438 -0
  96. package/dist/index-BYvnqARr.js +902 -0
  97. package/dist/{index-hlyg-wxV.js → index-Bonq819P.js} +1 -1
  98. package/dist/{index-CIBPhxlC.js → index-C6mOI2Pp.js} +105 -123
  99. package/dist/{index-Bf6jNZit.js → index-CDIe15AY.js} +24 -9
  100. package/dist/index-CTrcdIkt.js +137 -0
  101. package/dist/index-C_H8jFYf.js +2743 -0
  102. package/dist/index-CpnchVe1.js +74 -0
  103. package/dist/index-D5AR7A5e.js +151 -0
  104. package/dist/index-D7-Q86HI.js +54 -0
  105. package/dist/index-DdOj8Hew.js +53 -0
  106. package/dist/{index-iMPtFp54.js → index-Dvqguh2B.js} +10 -9
  107. package/dist/{index-Bm0QPucw.js → index-hAKRfE-4.js} +14 -14
  108. package/dist/index-o2Ga_qaX.js +39 -0
  109. package/dist/{index.esm2017-CM7OnEyP.js → index.esm2017-D0fhMMPG.js} +128 -128
  110. package/dist/{loading-CSXr0Yqz.js → loading-C686AMVG.js} +1 -1
  111. package/dist/{lodash-Bh7XKI-R.js → lodash-CANlWUWW.js} +1 -1
  112. package/dist/member-import-UzJ6ByIS.js +188 -0
  113. package/dist/membership-DCVzFaFy.js +274 -0
  114. package/dist/{money-BZIST_m9.js → money-DuazwoX7.js} +1 -1
  115. package/dist/{number-DXLR2w95.js → number-B2HFiV0g.js} +1 -1
  116. package/dist/objectid-Bq-oVMdP.js +145 -0
  117. package/dist/onboarding-BxvNxz-9.js +131 -0
  118. package/dist/onboardingSetup-CcvKmyx8.js +17 -0
  119. package/dist/{plugins-4FlbwoES.js → plugins-C39O5j42.js} +13 -12
  120. package/dist/remy-Qz_pNsUS.js +13 -0
  121. package/dist/{reward-DUbl79bZ.js → reward-HYt-2nxt.js} +1 -1
  122. package/dist/{rule-BQUoZ4l_.js → rule-3xNIYM7z.js} +337 -275
  123. package/dist/style.css +1 -1
  124. package/dist/{template-BoiSG7G7.js → template-D37Z_b0m.js} +6 -6
  125. package/dist/timezone-JwnQgpaU.js +20 -0
  126. package/dist/transaction.fn-C5vswLI_.js +71 -0
  127. package/dist/{trigger-D5g5m6tT.js → trigger-Bc6s2cvq.js} +17 -17
  128. package/dist/useMarketingMaterialActions-DMGyAXcy.js +96 -0
  129. package/dist/{usePagination-DHePBBoR.js → usePagination-DLOOwiiY.js} +1 -1
  130. package/dist/{user-C_ToSo-g.js → user-CTIGugVF.js} +1 -1
  131. package/dist/{vue-i18n-BcYh6_51.js → vue-i18n-Dpic36zz.js} +287 -287
  132. package/dist/{xlsx-h4G1C-xj.js → xlsx-CT9_1SFr.js} +786 -786
  133. package/dist/{zod-CgigfJar.js → zod-CGVrMcDl.js} +1 -1
  134. package/package.json +10 -6
  135. package/dist/Broadcast-C9akM-TB.js +0 -266
  136. package/dist/Card-DRkIYs0M.js +0 -910
  137. package/dist/Credit-V5YA_hGx.js +0 -260
  138. package/dist/DateRangeChip.vue_vue_type_script_setup_true_lang-eIoPtgO5.js +0 -58
  139. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-CYQMXARx.js +0 -3377
  140. package/dist/Experience-WTWy5yY6.js +0 -259
  141. package/dist/FilterChip.vue_vue_type_script_setup_true_lang-DaU-9GzO.js +0 -129
  142. package/dist/Game-BwOfTCW5.js +0 -330
  143. package/dist/LoyaltyDashboard-CJdhYiea.js +0 -1082
  144. package/dist/MainLayout-Du5kZOtA.js +0 -41
  145. package/dist/Member-DUV_vbPI.js +0 -280
  146. package/dist/MemberList-Ye4nOk-i.js +0 -1601
  147. package/dist/Mission-BBmCGpt8.js +0 -334
  148. package/dist/Point-Bzg6hi6o.js +0 -262
  149. package/dist/Promotion-BMXIp_ef.js +0 -397
  150. package/dist/Review-CYNPPxYU.js +0 -1141
  151. package/dist/ReviewFacebookCallback-0SUkKAaC.js +0 -243
  152. package/dist/ReviewGoogleCallback-BZEzx68n.js +0 -208
  153. package/dist/SelectItems.vue_vue_type_script_setup_true_lang-C4vohf6c.js +0 -181
  154. package/dist/Setting-jHAjccod.js +0 -2047
  155. package/dist/Store-Cu-hKmVa.js +0 -1996
  156. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-CGz6CTWA.js +0 -1130
  157. package/dist/Transaction-D7DO3dKQ.js +0 -39
  158. package/dist/Voucher-Cq-n1CaC.js +0 -421
  159. package/dist/campaign--MjoY1Mn.js +0 -219
  160. package/dist/campaign-DHBuP4UA.js +0 -277
  161. package/dist/export-CjB7qxZ9.js +0 -97
  162. package/dist/index-BIAjmMga.js +0 -85
  163. package/dist/index-Bv4MBLQ5.js +0 -52
  164. package/dist/index-hbyCVNa7.js +0 -30289
  165. package/dist/membership-CfredTm3.js +0 -255
  166. package/dist/objectid-Dg4ZodlT.js +0 -145
  167. package/dist/useMarketingMaterialActions-B-Jlw2Z9.js +0 -107
@@ -0,0 +1,4432 @@
1
+ import { defineComponent, ref, watch, resolveComponent, openBlock, createElementBlock, createElementVNode, createVNode, unref, createCommentVNode, computed, onMounted, toDisplayString, createBlock, withCtx, Fragment, renderList, withModifiers, isRef, createTextVNode, normalizeClass, watchEffect, resolveDynamicComponent, toRefs, normalizeStyle, onBeforeUnmount, createSlots } from "vue";
2
+ import { _ } from "./lodash-CANlWUWW.js";
3
+ import { h as axios, c as core, S as SvcConfig } from "./index-BUP4aHq8.js";
4
+ import { z, S as S6, f as Zh } from "./app-BEYzXWZO.js";
5
+ import { Z as ZodHelper } from "./zod-CGVrMcDl.js";
6
+ import { z as z$1 } from "./index-C_H8jFYf.js";
7
+ import { e as FdoGroup, F as F_RUNNABLE_CAMPAIGN_TYPE, f as FdtoRunnableCampaign, g as FdoCreditLoyaltyReward, h as FdtoRandomReward, i as F_MISSION_TYPE, j as FdoThresholdCreditReward, k as FdtoThresholdReward, l as FdoMission } from "./index-BYvnqARr.js";
8
+ import { F as FdoObjectId } from "./index-BFIHEBnX.js";
9
+ import { F as FdtoCollectibleConfig } from "./index-BTkxgos0.js";
10
+ import { a as isRuleGroup, R as RuleBuilder, s as stripRruleDtstartExceptSchedule, i as isRuleEntry, T as TEMPLATES } from "./index-BRPajAkE.js";
11
+ import { A as APP_INBOX_BODY_LIMIT, g as FdoBroadcastUrl, h as F_PUSH_DESTINATION, t as toDelivery, i as toLegacyMessage } from "./index-BAJOC43K.js";
12
+ import { e as CHANNEL_DISPLAY_ORDER, i as isPaidChannel, f as isChannelComplete, h as setMode, j as addChannel, k as hasDraft, l as setPrimaryChannel, r as removeChannel, m as moveChannel, n as setChannelContent, o as getCampaignSummaryObject, p as normaliseBroadcastDelivery } from "./campaign-k_WHxsOR.js";
13
+ import { u as useMembershipStore } from "./membership-DCVzFaFy.js";
14
+ import { u as useBusinessStore } from "./business-DH7djUl8.js";
15
+ import { J as JsonViewer } from "./JsonViewer-v8_C7l5N.js";
16
+ import { h as hooks } from "./moment-D7p2TMB-.js";
17
+ import { f as featureVersionMapping } from "./campaign.enum-Dx-Zo68Q.js";
18
+ import { _ as _sfc_main$C } from "./ImageInput.vue_vue_type_script_setup_true_lang-BmLclEyi.js";
19
+ import { _ as _sfc_main$A, a as _sfc_main$D, b as _sfc_main$F } from "./EffectSheet.vue_vue_type_style_index_0_lang-BML_-v8I.js";
20
+ import { _ as _sfc_main$E } from "./TargetLocationInput.vue_vue_type_script_setup_true_lang-BrEzWVrH.js";
21
+ import { p as prompt, f as firebaseStorage } from "./plugins-C39O5j42.js";
22
+ import { _ as _export_sfc } from "./_plugin-vue_export-helper-CHgC5LLL.js";
23
+ import { _ as _sfc_main$G } from "./UserRuleGroup.vue_vue_type_script_setup_true_lang-Co1BPScS.js";
24
+ import { a as _sfc_main$u, _ as _sfc_main$y } from "./RuleGroup.vue_vue_type_script_setup_true_lang-BLFLybFn.js";
25
+ import { u as useI18n } from "./vue-i18n-Dpic36zz.js";
26
+ import { T as TypeToTriggerOptions, _ as _sfc_main$H, b as _sfc_main$I } from "./trigger-Bc6s2cvq.js";
27
+ import { D as DEFAULT_MESSAGE_VARIABLES, a as _sfc_main$v, g as getSmsMessageMetrics, _ as _sfc_main$w, b as _sfc_main$x } from "./MessageInput.vue_vue_type_script_setup_true_lang-DXajAQy9.js";
28
+ import { useDialog } from "@feedmepos/ui-library";
29
+ import { useCoreStore } from "@feedmepos/mf-common";
30
+ import { c as campaignApi } from "./index-D5AR7A5e.js";
31
+ import { m as membershipApi } from "./index-CDIe15AY.js";
32
+ import { m as moment } from "./index-C6mOI2Pp.js";
33
+ import { c as calculateNextScheduleAt, R as RRule, S as SummarizeRrule, g as getRruleAnchorDate } from "./rule-3xNIYM7z.js";
34
+ import { C as CountryTimezone } from "./timezone-JwnQgpaU.js";
35
+ import { _ as _sfc_main$z, a as _sfc_main$B } from "./VoucherEditor.vue_vue_type_script_setup_true_lang-9QyTl7iq.js";
36
+ import "./index-B-bQnb0_.js";
37
+ import "./index-Dvqguh2B.js";
38
+ import "./index-o2Ga_qaX.js";
39
+ import "./index-BOJogkKQ.js";
40
+ import { a as F_GAME_TYPE } from "./collectible.enum-Liy2wH3s.js";
41
+ import { u as useLoading } from "./loading-C686AMVG.js";
42
+ import { i as initCollectibleConfig } from "./helper-BCkTvF4m.js";
43
+ import { C as CollectionUtils } from "./collection.fn-zQwWDzZT.js";
44
+ import { s as sentenceCase$1 } from "./index-CuvNtC_M.js";
45
+ import { u as useCampaignStore } from "./campaign-DlHDgoFX.js";
46
+ import { a as cleanPF } from "./object-BYyQ0PZp.js";
47
+ const publicClient = axios.create({ withCredentials: !1, timeout: 5e3 });
48
+ async function getNativeApp(e) {
49
+ z.string().length(24).parse(e);
50
+ const o = await publicClient.get(
51
+ `https://api.feedmedev.vip/metadata/${encodeURIComponent(e)}/native-app`
52
+ );
53
+ return z.object({
54
+ businessId: z.literal(e),
55
+ native: z.boolean(),
56
+ platforms: z.array(z.string())
57
+ }).parse(o.data).native;
58
+ }
59
+ function campaignRefinement(e, r) {
60
+ var i, u;
61
+ if (console.log(e, r), !e) return;
62
+ const o = e.campaign;
63
+ if (!o) return;
64
+ const m = o.event.rule;
65
+ if (!m || !isRuleGroup(m)) {
66
+ r.addIssue({
67
+ code: "custom",
68
+ path: ["campaign", "event", "rule"],
69
+ params: {
70
+ i18n: "connectZodCustom:campaign.rule_required",
71
+ type: o.event.type
72
+ }
73
+ });
74
+ return;
75
+ }
76
+ switch (o.type) {
77
+ case "MISSION": {
78
+ o.earningOption.amount > o.mission.end && r.addIssue({
79
+ code: "custom",
80
+ path: ["campaign", "earningOption"],
81
+ params: {
82
+ i18n: "connectZodCustom:campaign.earning_amount_exceed",
83
+ max: o.mission.end
84
+ }
85
+ });
86
+ break;
87
+ }
88
+ case "CREDIT": {
89
+ const l = (i = o.config) == null ? void 0 : i.validityOption;
90
+ (!l || ["validForDay", "validBefore"].every((a) => l[a] == null)) && r.addIssue({
91
+ code: "custom",
92
+ path: ["campaign", "config", "validityOption"],
93
+ params: {
94
+ i18n: "connectZodCustom:campaign.credit_validity_required"
95
+ }
96
+ });
97
+ }
98
+ }
99
+ switch (o.event.type) {
100
+ case "BILL_COMPLETED":
101
+ o.type === "MISSION" && o.rewards.length && (o.rewards.forEach((l, n) => {
102
+ (l.threshold < 0 || l.threshold > o.mission.end) && r.addIssue({
103
+ code: "custom",
104
+ path: ["campaign", "rewards", n, "threshold"],
105
+ params: {
106
+ i18n: "connectZodCustom:campaign.reward_threshold_range"
107
+ }
108
+ });
109
+ }), (u = o.config) != null && u.validityOption.followFirstReceive || r.addIssue({
110
+ code: "custom",
111
+ path: ["campaign", "config", "validityOption"],
112
+ params: {
113
+ i18n: "connectZodCustom:campaign.mission_first_receive"
114
+ }
115
+ }));
116
+ break;
117
+ case "SCHEDULE": {
118
+ if (!m.rules.g_schedule) {
119
+ r.addIssue({
120
+ code: "custom",
121
+ path: ["campaign", "event", "rule"],
122
+ params: {
123
+ i18n: "connectZodCustom:campaign.schedule_period_required"
124
+ },
125
+ fatal: !0
126
+ });
127
+ return;
128
+ }
129
+ const l = RuleBuilder.getRules(
130
+ m.rules.g_schedule
131
+ ), n = [
132
+ {
133
+ property: "trigger.date",
134
+ operator: ["_isOnDate", "_rrule"]
135
+ },
136
+ {
137
+ property: "trigger.time",
138
+ operator: ["_isOnTime"]
139
+ }
140
+ ];
141
+ n.length == l.length && n.every((s) => l.some((y) => {
142
+ const f = RuleBuilder.simplify(y);
143
+ return f.property === s.property && s.operator.includes(f.operator);
144
+ })) || r.addIssue({
145
+ code: "custom",
146
+ path: ["campaign", "event", "rule"],
147
+ params: {
148
+ i18n: "connectZodCustom:campaign.active_period_invalid"
149
+ }
150
+ });
151
+ break;
152
+ }
153
+ default: {
154
+ "earningOption" in o && o.earningOption.type != "FIXED" && r.addIssue({
155
+ code: "custom",
156
+ path: ["campaign", "earningOption"],
157
+ params: {
158
+ i18n: "connectZodCustom:campaign.fixed_earning_required"
159
+ }
160
+ });
161
+ break;
162
+ }
163
+ }
164
+ }
165
+ function campaignTransform(e) {
166
+ var o;
167
+ if (e.campaign.type === "VOUCHER" && "configs" in e) {
168
+ const m = e.configs;
169
+ m.extras.targetLocation = e.campaign.targetLocation;
170
+ const i = Math.max(
171
+ e.campaign.earningOption.amount,
172
+ m.options.maxUse ?? 1
173
+ );
174
+ e.campaign.earningOption.amount = i, m.options.maxUse = i, e.campaign.earningOption = {
175
+ type: "FIXED",
176
+ amount: 1
177
+ };
178
+ }
179
+ if (e.campaign.type == "MISSION" && "configs" in e) {
180
+ const m = e.configs;
181
+ m.options.validityOption = (o = e.campaign.config) == null ? void 0 : o.validityOption;
182
+ }
183
+ const r = e.campaign.event;
184
+ return r.type != "BILL_COMPLETED" && r.rule && isRuleGroup(r.rule) && (r.rule = RuleBuilder.removeEntry(r.rule, "g_bill"), e.campaign.event = r), r.rule && isRuleGroup(r.rule) && (r.rule = stripRruleDtstartExceptSchedule(r.rule), e.campaign.event = r), e;
185
+ }
186
+ function GenerateCampaignReq(e) {
187
+ const r = FdtoRunnableCampaign.optionsMap.get(e).extend({
188
+ _id: FdoObjectId.optional(),
189
+ collectible: z$1.string().nullish()
190
+ });
191
+ switch (e) {
192
+ case "VOUCHER":
193
+ return z$1.object({
194
+ campaign: r,
195
+ templateId: FdoObjectId,
196
+ configs: FdtoCollectibleConfig,
197
+ updateCollections: z$1.boolean().optional(),
198
+ code: z$1.string().optional()
199
+ });
200
+ case "PROMOTION":
201
+ return z$1.object({
202
+ campaign: r,
203
+ templateId: FdoObjectId
204
+ });
205
+ case "POINT":
206
+ return z$1.object({
207
+ campaign: r,
208
+ templateId: FdoObjectId
209
+ });
210
+ case "CREDIT":
211
+ return z$1.object({
212
+ campaign: r,
213
+ templateId: FdoObjectId
214
+ });
215
+ case "BROADCAST":
216
+ return z$1.object({
217
+ campaign: r.refine((o) => !!o.delivery || !!o.message, {
218
+ path: ["delivery"],
219
+ message: "A broadcast requires a message or delivery configuration."
220
+ }),
221
+ templateId: FdoObjectId
222
+ });
223
+ case "COIN":
224
+ return z$1.object({
225
+ campaign: r,
226
+ templateId: FdoObjectId
227
+ });
228
+ case "REWARD_POOL":
229
+ return z$1.object({
230
+ campaign: r,
231
+ templateId: FdoObjectId,
232
+ updateCollections: z$1.boolean().optional()
233
+ });
234
+ case "GAME":
235
+ return z$1.object({
236
+ campaign: r,
237
+ configs: FdtoCollectibleConfig,
238
+ templateId: FdoObjectId,
239
+ updateCollections: z$1.boolean().optional()
240
+ });
241
+ case "MISSION":
242
+ return z$1.object({
243
+ campaign: r,
244
+ configs: FdtoCollectibleConfig,
245
+ templateId: FdoObjectId,
246
+ updateCollections: z$1.boolean().optional()
247
+ });
248
+ case "GRAB":
249
+ return z$1.object({
250
+ campaign: r,
251
+ templateId: FdoObjectId
252
+ });
253
+ default:
254
+ throw new Error("Not implemented");
255
+ }
256
+ }
257
+ FdoGroup.extend({
258
+ _id: FdoObjectId.optional(),
259
+ name: z$1.string().min(1).max(300),
260
+ business: FdoObjectId.optional(),
261
+ campaigns: z$1.array(FdoObjectId).optional()
262
+ });
263
+ const CampaignDtos = {
264
+ [F_RUNNABLE_CAMPAIGN_TYPE.enum.VOUCHER]: GenerateCampaignReq("VOUCHER"),
265
+ [F_RUNNABLE_CAMPAIGN_TYPE.enum.PROMOTION]: GenerateCampaignReq("PROMOTION"),
266
+ [F_RUNNABLE_CAMPAIGN_TYPE.enum.POINT]: GenerateCampaignReq("POINT"),
267
+ [F_RUNNABLE_CAMPAIGN_TYPE.enum.CREDIT]: GenerateCampaignReq("CREDIT"),
268
+ [F_RUNNABLE_CAMPAIGN_TYPE.enum.BROADCAST]: GenerateCampaignReq("BROADCAST"),
269
+ [F_RUNNABLE_CAMPAIGN_TYPE.enum.COIN]: GenerateCampaignReq("COIN"),
270
+ [F_RUNNABLE_CAMPAIGN_TYPE.enum.REWARD_POOL]: GenerateCampaignReq("REWARD_POOL"),
271
+ [F_RUNNABLE_CAMPAIGN_TYPE.enum.GAME]: GenerateCampaignReq("GAME"),
272
+ [F_RUNNABLE_CAMPAIGN_TYPE.enum.MISSION]: GenerateCampaignReq("MISSION"),
273
+ [F_RUNNABLE_CAMPAIGN_TYPE.enum.GRAB]: GenerateCampaignReq("GRAB")
274
+ };
275
+ function summarizeGrabDiscount(e) {
276
+ if (!e)
277
+ return null;
278
+ const r = core.Config.getCountry().currency.symbol;
279
+ function o(l) {
280
+ switch (l.scope.type) {
281
+ case "order":
282
+ return "Bill discount";
283
+ case "items":
284
+ return l.type.startsWith("bundle") ? m(l.type) : "Item discount";
285
+ case "categories":
286
+ return "Category discount";
287
+ default:
288
+ return "Discount";
289
+ }
290
+ }
291
+ function m(l) {
292
+ switch (l) {
293
+ case "bundleSameFixPrice":
294
+ return "Bundle (same item) - Fixed price";
295
+ case "bundleDiffFixPrice":
296
+ return "Bundle (different items) - Fixed price";
297
+ case "bundleSameNet":
298
+ return "Bundle (same item) - Amount off";
299
+ case "bundleDiffNet":
300
+ return "Bundle (different items) - Amount off";
301
+ case "bundleSamePercentage":
302
+ return "Bundle (same item) - Percentage off";
303
+ case "bundleDiffPercentage":
304
+ return "Bundle (different items) - Percentage off";
305
+ default:
306
+ return "Bundle discount";
307
+ }
308
+ }
309
+ function i(l) {
310
+ switch (l.type) {
311
+ case "percentage":
312
+ case "bundleSamePercentage":
313
+ case "bundleDiffPercentage":
314
+ return `${l.value}% discount`;
315
+ case "net":
316
+ case "bundleSameNet":
317
+ case "bundleDiffNet":
318
+ return `${r}${l.value} discount`;
319
+ case "bundleSameFixPrice":
320
+ case "bundleDiffFixPrice":
321
+ return `${r}${l.value} fixed price`;
322
+ case "delivery":
323
+ return "Delivery fee discount";
324
+ case "freeItem":
325
+ return "Free item";
326
+ default:
327
+ return `${r}${l.value} discount`;
328
+ }
329
+ }
330
+ function u(l) {
331
+ return l.cap && l.cap > 0 ? `capped at ${r}${l.cap}` : null;
332
+ }
333
+ return {
334
+ type: o(e),
335
+ adjustment: i(e),
336
+ cap: u(e)
337
+ };
338
+ }
339
+ const _hoisted_1$r = {
340
+ key: 0,
341
+ class: "bg-fm-color-neutral-gray-50 border border-fm-color-neutral-gray-200 rounded-8 p-16 space-y-16"
342
+ }, _hoisted_2$n = { class: "flex items-center justify-between" }, _hoisted_3$k = { class: "flex items-center gap-8" }, _hoisted_4$j = { class: "bg-white border border-fm-color-neutral-gray-200 rounded-8 p-16" }, _hoisted_5$g = { class: "flex justify-end gap-8 pt-8 border-t border-fm-color-neutral-gray-200" }, _sfc_main$t = /* @__PURE__ */ defineComponent({
343
+ __name: "GrabItemSelectionInline",
344
+ props: {
345
+ visible: { type: Boolean },
346
+ initialValue: {},
347
+ filterItems: { type: Function }
348
+ },
349
+ emits: ["confirm", "cancel"],
350
+ setup(e, { emit: r }) {
351
+ const o = e, m = r, i = ref();
352
+ watch(
353
+ () => o.visible,
354
+ (a) => {
355
+ var s, y;
356
+ !a && i.value && ((y = (s = i.value).setSelectedItems) == null || y.call(s, o.initialValue || []));
357
+ }
358
+ );
359
+ function u() {
360
+ var a;
361
+ (a = i.value) == null || a.onConfirm();
362
+ }
363
+ function l() {
364
+ m("cancel");
365
+ }
366
+ function n(a) {
367
+ m("confirm", a);
368
+ }
369
+ return (a, s) => {
370
+ const y = resolveComponent("FmIcon"), f = resolveComponent("FmButton");
371
+ return e.visible ? (openBlock(), createElementBlock("div", _hoisted_1$r, [
372
+ createElementVNode("div", _hoisted_2$n, [
373
+ createElementVNode("div", _hoisted_3$k, [
374
+ createVNode(y, {
375
+ name: "restaurant",
376
+ size: "md"
377
+ }),
378
+ s[0] || (s[0] = createElementVNode("h3", { class: "fm-typo-en-body-lg-600" }, "Select Items", -1))
379
+ ]),
380
+ createVNode(f, {
381
+ icon: "close",
382
+ variant: "tertiary",
383
+ onClick: l
384
+ })
385
+ ]),
386
+ s[1] || (s[1] = createElementVNode("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Choose which items this discount applies to. For bundle discounts, select multiple items that can be bundled together. ", -1)),
387
+ createElementVNode("div", _hoisted_4$j, [
388
+ createVNode(unref(S6), {
389
+ ref_key: "selectItemRef",
390
+ ref: i,
391
+ "initial-value": e.initialValue,
392
+ "filter-items": e.filterItems,
393
+ "on-complete": n,
394
+ "max-height": 300
395
+ }, null, 8, ["initial-value", "filter-items"])
396
+ ]),
397
+ createElementVNode("div", _hoisted_5$g, [
398
+ createVNode(f, {
399
+ variant: "secondary",
400
+ label: "Cancel",
401
+ onClick: l
402
+ }),
403
+ createVNode(f, {
404
+ variant: "primary",
405
+ label: "Confirm Selection",
406
+ onClick: u
407
+ })
408
+ ])
409
+ ])) : createCommentVNode("", !0);
410
+ };
411
+ }
412
+ }), _hoisted_1$q = {
413
+ key: 0,
414
+ class: "bg-fm-color-neutral-gray-50 border border-fm-color-neutral-gray-200 rounded-8 p-16 space-y-16"
415
+ }, _hoisted_2$m = { class: "flex items-center justify-between" }, _hoisted_3$j = { class: "flex items-center gap-8" }, _hoisted_4$i = { class: "flex gap-16 items-center flex-wrap" }, _hoisted_5$f = { class: "flex gap-8 items-center" }, _hoisted_6$b = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, _hoisted_7$a = { class: "bg-white border border-fm-color-neutral-gray-200 rounded-8 max-h-[300px] overflow-y-auto" }, _hoisted_8$9 = { class: "flex items-center gap-12" }, _hoisted_9$9 = { class: "fm-typo-en-body-md-600" }, _hoisted_10$8 = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, _hoisted_11$6 = {
416
+ key: 1,
417
+ class: "p-24 text-center"
418
+ }, _hoisted_12$5 = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _hoisted_13$5 = { class: "flex justify-end gap-8 pt-8 border-t border-fm-color-neutral-gray-200" }, _sfc_main$s = /* @__PURE__ */ defineComponent({
419
+ __name: "GrabCategorySelectionInline",
420
+ props: {
421
+ visible: { type: Boolean },
422
+ initialValue: {}
423
+ },
424
+ emits: ["confirm", "cancel"],
425
+ setup(e, { emit: r }) {
426
+ const o = e, m = r, i = Zh(), u = ref({}), l = ref(""), n = computed(() => {
427
+ const d = i.menu.value;
428
+ return d ? d.modules.category.map((p) => ({
429
+ id: p._id,
430
+ name: p.name
431
+ })) : [];
432
+ }), a = computed(() => {
433
+ if (!l.value) return n.value;
434
+ const d = l.value.toLowerCase();
435
+ return n.value.filter(
436
+ (p) => p.name.toLowerCase().includes(d)
437
+ );
438
+ }), s = computed(() => Object.values(u.value).filter(Boolean).length);
439
+ function y() {
440
+ u.value = n.value.reduce(
441
+ (d, p) => (d[p.id] = o.initialValue.includes(p.id), d),
442
+ {}
443
+ );
444
+ }
445
+ watch([() => o.visible, () => o.initialValue], () => {
446
+ o.visible && y();
447
+ }), onMounted(async () => {
448
+ await i.store.getMenu(), y();
449
+ });
450
+ function f(d) {
451
+ u.value[d] = !u.value[d];
452
+ }
453
+ function c() {
454
+ const d = s.value === a.value.length;
455
+ a.value.forEach((p) => {
456
+ u.value[p.id] = !d;
457
+ });
458
+ }
459
+ function k() {
460
+ Object.keys(u.value).forEach((d) => {
461
+ u.value[d] = !1;
462
+ });
463
+ }
464
+ function V() {
465
+ const d = Object.entries(u.value).filter(([, p]) => p).map(([p]) => p);
466
+ m("confirm", d);
467
+ }
468
+ function g() {
469
+ m("cancel");
470
+ }
471
+ const v = computed(() => a.value.length > 0 && a.value.every(
472
+ (d) => u.value[d.id]
473
+ ));
474
+ return (d, p) => {
475
+ const C = resolveComponent("FmIcon"), x = resolveComponent("FmButton"), N = resolveComponent("FmTextField"), w = resolveComponent("FmCheckbox"), $ = resolveComponent("FmListItem"), T = resolveComponent("FmList");
476
+ return e.visible ? (openBlock(), createElementBlock("div", _hoisted_1$q, [
477
+ createElementVNode("div", _hoisted_2$m, [
478
+ createElementVNode("div", _hoisted_3$j, [
479
+ createVNode(C, {
480
+ name: "category",
481
+ size: "md"
482
+ }),
483
+ p[2] || (p[2] = createElementVNode("h3", { class: "fm-typo-en-body-lg-600" }, "Select Categories", -1))
484
+ ]),
485
+ createVNode(x, {
486
+ icon: "close",
487
+ variant: "tertiary",
488
+ onClick: g
489
+ })
490
+ ]),
491
+ p[3] || (p[3] = createElementVNode("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Choose which categories this discount applies to. The discount will be available for all items within the selected categories. ", -1)),
492
+ createElementVNode("div", _hoisted_4$i, [
493
+ createElementVNode("div", _hoisted_5$f, [
494
+ createVNode(x, {
495
+ icon: "select_all",
496
+ variant: "tertiary",
497
+ size: "small",
498
+ label: `${v.value ? "Deselect" : "Select"} All`,
499
+ onClick: c
500
+ }, null, 8, ["label"]),
501
+ createVNode(x, {
502
+ icon: "sync",
503
+ variant: "tertiary",
504
+ size: "small",
505
+ label: "Clear",
506
+ onClick: k
507
+ }),
508
+ createElementVNode("span", _hoisted_6$b, toDisplayString(s.value) + " selected ", 1)
509
+ ]),
510
+ createVNode(N, {
511
+ modelValue: l.value,
512
+ "onUpdate:modelValue": p[0] || (p[0] = (R) => l.value = R),
513
+ placeholder: "Search categories",
514
+ "leading-icon": { name: "search", color: "" },
515
+ class: "flex-1 min-w-[200px]"
516
+ }, null, 8, ["modelValue"])
517
+ ]),
518
+ createElementVNode("div", _hoisted_7$a, [
519
+ a.value.length > 0 ? (openBlock(), createBlock(T, { key: 0 }, {
520
+ default: withCtx(() => [
521
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(a.value, (R) => (openBlock(), createBlock($, {
522
+ key: R.id,
523
+ clickable: !0,
524
+ onClick: (A) => f(R.id)
525
+ }, {
526
+ leading: withCtx(() => [
527
+ createVNode(w, {
528
+ "model-value": u.value[R.id] || !1,
529
+ value: R.id,
530
+ "onUpdate:modelValue": (A) => f(R.id),
531
+ onClick: p[1] || (p[1] = withModifiers(() => {
532
+ }, ["stop"]))
533
+ }, null, 8, ["model-value", "value", "onUpdate:modelValue"])
534
+ ]),
535
+ default: withCtx(() => [
536
+ createElementVNode("div", _hoisted_8$9, [
537
+ createVNode(C, {
538
+ name: "category",
539
+ size: "sm",
540
+ class: "text-fm-color-typo-secondary"
541
+ }),
542
+ createElementVNode("div", null, [
543
+ createElementVNode("div", _hoisted_9$9, toDisplayString(R.name), 1),
544
+ createElementVNode("div", _hoisted_10$8, " ID: " + toDisplayString(R.id), 1)
545
+ ])
546
+ ])
547
+ ]),
548
+ _: 2
549
+ }, 1032, ["onClick"]))), 128))
550
+ ]),
551
+ _: 1
552
+ })) : (openBlock(), createElementBlock("div", _hoisted_11$6, [
553
+ createElementVNode("div", _hoisted_12$5, toDisplayString(l.value ? "No categories found matching your search." : "No categories available."), 1)
554
+ ]))
555
+ ]),
556
+ createElementVNode("div", _hoisted_13$5, [
557
+ createVNode(x, {
558
+ variant: "secondary",
559
+ label: "Cancel",
560
+ onClick: g
561
+ }),
562
+ createVNode(x, {
563
+ variant: "primary",
564
+ label: `Confirm Selection (${s.value})`,
565
+ disabled: s.value === 0,
566
+ onClick: V
567
+ }, null, 8, ["label", "disabled"])
568
+ ])
569
+ ])) : createCommentVNode("", !0);
570
+ };
571
+ }
572
+ }), _hoisted_1$p = { class: "space-y-8" }, _hoisted_2$l = {
573
+ key: 1,
574
+ class: "border-1 rounded-md flex gap-16 items-center justify-between px-16 py-12"
575
+ }, _hoisted_3$i = { class: "fm-typo-en-body-lg-400" }, _hoisted_4$h = { class: "text-fm-color-typo-secondary" }, _hoisted_5$e = { key: 0 }, _hoisted_6$a = { class: "space-y-24" }, _hoisted_7$9 = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary mt-4" }, _hoisted_8$8 = { key: 0 }, _hoisted_9$8 = { class: "fm-typo-en-body-md-600 mb-8 block" }, _hoisted_10$7 = { key: 1 }, _hoisted_11$5 = { key: 2 }, _hoisted_12$4 = { key: 0 }, _hoisted_13$4 = { class: "space-y-8" }, _hoisted_14$4 = { class: "flex items-center justify-between p-12 border border-fm-color-neutral-gray-200 fm-corner-radius-md" }, _hoisted_15$3 = { class: "flex items-center gap-8" }, _hoisted_16$2 = { class: "fm-typo-en-body-md-400" }, _hoisted_17$2 = { key: 3 }, _hoisted_18$2 = { key: 0 }, _hoisted_19$2 = { class: "space-y-8" }, _hoisted_20$2 = { class: "flex items-center justify-between p-12 border border-fm-color-neutral-gray-200 fm-corner-radius-md" }, _hoisted_21$1 = { class: "flex items-center gap-8" }, _hoisted_22$1 = { class: "fm-typo-en-body-md-400" }, _hoisted_23$1 = {
576
+ key: 0,
577
+ class: "mt-16 p-12 bg-fm-color-feedback-error-light rounded-8 border border-fm-color-feedback-error-main"
578
+ }, _hoisted_24$1 = { class: "flex items-center gap-8 mb-8 text-fm-color-system-error-300" }, _hoisted_25$1 = { class: "space-y-4" }, _hoisted_26$1 = { class: "flex gap-16" }, _sfc_main$r = /* @__PURE__ */ defineComponent({
579
+ __name: "GrabEffectSheet",
580
+ props: {
581
+ modelValue: { type: Object }
582
+ },
583
+ emits: ["update:model-value"],
584
+ setup(e, { emit: r }) {
585
+ const o = e, m = r, i = Zh(), u = ref(!1), l = ref(!1), n = ref(!1), a = ref({
586
+ type: "net",
587
+ value: 0,
588
+ scope: {
589
+ type: "order"
590
+ }
591
+ });
592
+ watch(
593
+ () => o.modelValue,
594
+ (b) => {
595
+ b && (a.value = { ...b });
596
+ },
597
+ { immediate: !0 }
598
+ ), onMounted(async () => {
599
+ await i.store.getMenu();
600
+ });
601
+ const s = computed(() => {
602
+ var b;
603
+ return !(!a.value.type || !((b = a.value.scope) != null && b.type) || c(a.value.type) && (!a.value.value || a.value.value <= 0) || (a.value.scope.type === "items" || a.value.scope.type === "category") && (!a.value.scope.objectIDs || a.value.scope.objectIDs.length === 0));
604
+ });
605
+ async function y(b) {
606
+ b.stopPropagation(), await prompt.remove("Are you sure you want to remove this discount?") && m("update:model-value", null);
607
+ }
608
+ function f() {
609
+ var b;
610
+ return C(((b = a.value.scope) == null ? void 0 : b.type) || "order");
611
+ }
612
+ function c(b) {
613
+ return b && !["freeItem", "delivery"].includes(b);
614
+ }
615
+ function k(b) {
616
+ return b && ["percentage", "bundleSamePercentage", "bundleDiffPercentage"].includes(
617
+ b
618
+ );
619
+ }
620
+ function V(b) {
621
+ return b != null && b.includes("Percentage") ? "Discount percentage" : b != null && b.includes("FixPrice") ? "Bundle fixed price" : b === "percentage" ? "Discount percentage" : "Discount amount";
622
+ }
623
+ function g(b) {
624
+ return b != null && b.includes("Percentage") || b === "percentage" ? "10" : "5.00";
625
+ }
626
+ function v(b) {
627
+ return b != null && b.includes("Percentage") || b === "percentage" ? "%" : "$";
628
+ }
629
+ function d(b, E) {
630
+ a.value = {
631
+ ...a.value,
632
+ [b]: E
633
+ };
634
+ }
635
+ function p(b, E) {
636
+ var U;
637
+ const F = {
638
+ ...a.value.scope,
639
+ [b]: E
640
+ };
641
+ if (a.value = {
642
+ ...a.value,
643
+ scope: F
644
+ }, b === "type") {
645
+ const O = C(E);
646
+ O.some(
647
+ (H) => H.value === a.value.type
648
+ ) || (a.value = {
649
+ ...a.value,
650
+ type: ((U = O[0]) == null ? void 0 : U.value) || "net",
651
+ // Reset value and cap when changing to incompatible type
652
+ value: 0,
653
+ cap: void 0
654
+ });
655
+ }
656
+ }
657
+ function C(b) {
658
+ switch (b) {
659
+ case "order":
660
+ return [
661
+ { label: "Amount off", value: "net" },
662
+ { label: "Percentage off", value: "percentage" },
663
+ { label: "Delivery fee off", value: "delivery" }
664
+ ];
665
+ case "category":
666
+ return [
667
+ { label: "Amount off", value: "net" },
668
+ { label: "Percentage off", value: "percentage" }
669
+ ];
670
+ case "items":
671
+ return [
672
+ { label: "Amount off", value: "net" },
673
+ { label: "Percentage off", value: "percentage" },
674
+ { label: "Free item", value: "freeItem" },
675
+ {
676
+ label: "Bundle (same item) - Fixed price",
677
+ value: "bundleSameFixPrice"
678
+ },
679
+ { label: "Bundle (same item) - Amount off", value: "bundleSameNet" },
680
+ {
681
+ label: "Bundle (same item) - Percentage off",
682
+ value: "bundleSamePercentage"
683
+ },
684
+ {
685
+ label: "Bundle (different items) - Fixed price",
686
+ value: "bundleDiffFixPrice"
687
+ },
688
+ {
689
+ label: "Bundle (different items) - Amount off",
690
+ value: "bundleDiffNet"
691
+ },
692
+ {
693
+ label: "Bundle (different items) - Percentage off",
694
+ value: "bundleDiffPercentage"
695
+ }
696
+ ];
697
+ default:
698
+ return [
699
+ { label: "Amount off", value: "net" },
700
+ { label: "Percentage off", value: "percentage" }
701
+ ];
702
+ }
703
+ }
704
+ function x(b) {
705
+ switch (b) {
706
+ case "order":
707
+ return "Applies to entire order. Available: Amount off, Percentage off, Delivery fee discount.";
708
+ case "category":
709
+ return "Applies to specific item categories. Available: Amount off, Percentage off, Free item.";
710
+ case "items":
711
+ return "Applies to specific items. Available: Basic discounts, Bundle offers (same/different items).";
712
+ default:
713
+ return "Select how you want to apply the discount.";
714
+ }
715
+ }
716
+ function N() {
717
+ var b;
718
+ return ((b = a.value.scope) == null ? void 0 : b.type) === "items";
719
+ }
720
+ function w() {
721
+ var b;
722
+ return ((b = a.value.scope) == null ? void 0 : b.type) === "category";
723
+ }
724
+ function $() {
725
+ var F;
726
+ const b = (F = a.value.scope) == null ? void 0 : F.objectIDs;
727
+ if (!b || b.length === 0)
728
+ return "No items selected";
729
+ const E = i.menu.value;
730
+ return E && b.length <= 3 ? b.map((O) => {
731
+ const P = E.modules.item.find((H) => H._id === O);
732
+ return P ? (P.name2 || P.name).trim() : `Item ${O}`;
733
+ }).join(", ") : b.length === 1 ? "1 item selected" : `${b.length} items selected`;
734
+ }
735
+ function T() {
736
+ var F;
737
+ const b = (F = a.value.scope) == null ? void 0 : F.objectIDs;
738
+ if (!b || b.length === 0)
739
+ return "No categories selected";
740
+ const E = i.menu.value;
741
+ return E && b.length <= 3 ? b.map((O) => {
742
+ const P = E.modules.category.find((H) => H._id === O);
743
+ return P ? P.name : `Category ${O}`;
744
+ }).join(", ") : b.length === 1 ? "1 category selected" : `${b.length} categories selected`;
745
+ }
746
+ function R() {
747
+ l.value = !0;
748
+ }
749
+ function A() {
750
+ n.value = !0;
751
+ }
752
+ function M(b) {
753
+ p("objectIDs", b), l.value = !1;
754
+ }
755
+ function I(b) {
756
+ p("objectIDs", b), n.value = !1;
757
+ }
758
+ function X() {
759
+ l.value = !1;
760
+ }
761
+ function K() {
762
+ n.value = !1;
763
+ }
764
+ const Z = computed(() => {
765
+ var E, F, U;
766
+ const b = [];
767
+ return a.value.type || b.push("Discount type is required"), (E = a.value.scope) != null && E.type || b.push("Scope type is required"), c(a.value.type) && (!a.value.value || a.value.value <= 0) && b.push("Discount amount must be greater than 0"), ((F = a.value.scope) == null ? void 0 : F.type) === "items" && (!a.value.scope.objectIDs || a.value.scope.objectIDs.length === 0) && b.push("Please select at least one item"), ((U = a.value.scope) == null ? void 0 : U.type) === "category" && (!a.value.scope.objectIDs || a.value.scope.objectIDs.length === 0) && b.push("Please select at least one category"), b;
768
+ });
769
+ function W() {
770
+ m("update:model-value", a.value), u.value = !1;
771
+ }
772
+ const Y = [
773
+ { label: "Bill discount", value: "order" },
774
+ { label: "Item discount", value: "items" },
775
+ { label: "Category discount", value: "category" }
776
+ ];
777
+ return (b, E) => {
778
+ const F = resolveComponent("FmButton"), U = resolveComponent("FmSelect"), O = resolveComponent("FmStepperField"), P = resolveComponent("FmIcon"), H = resolveComponent("FmSideSheet");
779
+ return openBlock(), createBlock(H, {
780
+ "max-width": 550,
781
+ header: "Apply discount",
782
+ modelValue: unref(u),
783
+ "onUpdate:modelValue": [
784
+ E[5] || (E[5] = (L) => isRef(u) ? u.value = L : null),
785
+ E[6] || (E[6] = (L) => u.value = L)
786
+ ]
787
+ }, {
788
+ "side-sheet-button": withCtx(() => {
789
+ var L, j, G, h;
790
+ return [
791
+ createElementVNode("div", _hoisted_1$p, [
792
+ E[7] || (E[7] = createElementVNode("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Configure the Grab campaign discount you want to offer your customers. ", -1)),
793
+ e.modelValue ? (openBlock(), createElementBlock("div", _hoisted_2$l, [
794
+ createElementVNode("div", _hoisted_3$i, [
795
+ createElementVNode("div", null, toDisplayString((L = unref(summarizeGrabDiscount)(e.modelValue)) == null ? void 0 : L.type), 1),
796
+ createElementVNode("div", _hoisted_4$h, [
797
+ createTextVNode(toDisplayString((j = unref(summarizeGrabDiscount)(e.modelValue)) == null ? void 0 : j.adjustment) + " ", 1),
798
+ (G = unref(summarizeGrabDiscount)(e.modelValue)) != null && G.cap ? (openBlock(), createElementBlock("span", _hoisted_5$e, toDisplayString((h = unref(summarizeGrabDiscount)(e.modelValue)) == null ? void 0 : h.cap), 1)) : createCommentVNode("", !0)
799
+ ])
800
+ ]),
801
+ createVNode(F, {
802
+ icon: "delete",
803
+ "icon-color": "neutral-gray-400",
804
+ variant: "tertiary",
805
+ onClick: y
806
+ })
807
+ ])) : (openBlock(), createBlock(F, {
808
+ key: 0,
809
+ label: "Apply Grab discount",
810
+ icon: "add",
811
+ "icon-color": "primary",
812
+ variant: "secondary",
813
+ class: "border-fm-color-primary text-fm-color-primary"
814
+ }))
815
+ ])
816
+ ];
817
+ }),
818
+ "side-sheet-footer": withCtx(() => [
819
+ createElementVNode("div", _hoisted_26$1, [
820
+ createVNode(F, {
821
+ variant: "secondary",
822
+ label: "Cancel",
823
+ class: "flex-1",
824
+ onClick: E[4] || (E[4] = (L) => u.value = !1)
825
+ }),
826
+ createVNode(F, {
827
+ variant: "primary",
828
+ label: unref(s) ? "Confirm" : "Complete Required Fields",
829
+ class: "flex-1",
830
+ disabled: !unref(s),
831
+ onClick: W
832
+ }, null, 8, ["label", "disabled"])
833
+ ])
834
+ ]),
835
+ default: withCtx(() => {
836
+ var L, j, G, h;
837
+ return [
838
+ createElementVNode("div", _hoisted_6$a, [
839
+ createElementVNode("div", null, [
840
+ E[8] || (E[8] = createElementVNode("label", { class: "fm-typo-en-body-md-600 mb-8 block" }, "Campaign type", -1)),
841
+ createVNode(U, {
842
+ "model-value": ((L = unref(a).scope) == null ? void 0 : L.type) || "order",
843
+ "onUpdate:modelValue": E[0] || (E[0] = (B) => p("type", B)),
844
+ placeholder: "Select campaign type",
845
+ items: Y
846
+ }, null, 8, ["model-value"]),
847
+ createElementVNode("div", _hoisted_7$9, toDisplayString(x((j = unref(a).scope) == null ? void 0 : j.type)), 1)
848
+ ]),
849
+ createElementVNode("div", null, [
850
+ E[9] || (E[9] = createElementVNode("label", { class: "fm-typo-en-body-md-600 mb-8 block" }, "Discount type", -1)),
851
+ createVNode(U, {
852
+ "model-value": unref(a).type,
853
+ "onUpdate:modelValue": E[1] || (E[1] = (B) => d("type", B)),
854
+ placeholder: "Select discount type",
855
+ items: f()
856
+ }, null, 8, ["model-value", "items"])
857
+ ]),
858
+ c(unref(a).type) ? (openBlock(), createElementBlock("div", _hoisted_8$8, [
859
+ createElementVNode("label", _hoisted_9$8, toDisplayString(V(unref(a).type)), 1),
860
+ createVNode(O, {
861
+ modelValue: unref(a).value,
862
+ "onUpdate:modelValue": E[2] || (E[2] = (B) => unref(a).value = B),
863
+ placeholder: g(unref(a).type),
864
+ suffix: v(unref(a).type),
865
+ type: "number"
866
+ }, null, 8, ["modelValue", "placeholder", "suffix"])
867
+ ])) : createCommentVNode("", !0),
868
+ k(unref(a).type) ? (openBlock(), createElementBlock("div", _hoisted_10$7, [
869
+ E[10] || (E[10] = createElementVNode("label", { class: "fm-typo-en-body-md-600 mb-8 block" }, "Discount cap (optional)", -1)),
870
+ createVNode(O, {
871
+ modelValue: unref(a).cap,
872
+ "onUpdate:modelValue": E[3] || (E[3] = (B) => unref(a).cap = B),
873
+ placeholder: "Maximum discount amount",
874
+ type: "number"
875
+ }, null, 8, ["modelValue"])
876
+ ])) : createCommentVNode("", !0),
877
+ N() ? (openBlock(), createElementBlock("div", _hoisted_11$5, [
878
+ unref(l) ? createCommentVNode("", !0) : (openBlock(), createElementBlock("div", _hoisted_12$4, [
879
+ E[12] || (E[12] = createElementVNode("label", { class: "fm-typo-en-body-md-600 mb-8 block" }, "Select Items", -1)),
880
+ createElementVNode("div", _hoisted_13$4, [
881
+ createElementVNode("div", _hoisted_14$4, [
882
+ createElementVNode("div", _hoisted_15$3, [
883
+ createVNode(P, {
884
+ name: "restaurant",
885
+ size: "md"
886
+ }),
887
+ createElementVNode("span", _hoisted_16$2, toDisplayString($()), 1)
888
+ ]),
889
+ createVNode(F, {
890
+ variant: "secondary",
891
+ label: "Select Items",
892
+ icon: "chevron_right",
893
+ onClick: R
894
+ })
895
+ ]),
896
+ E[11] || (E[11] = createElementVNode("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Choose which items this discount applies to. Bundle discounts require multiple items. ", -1))
897
+ ])
898
+ ])),
899
+ createVNode(_sfc_main$t, {
900
+ visible: unref(l),
901
+ "initial-value": ((G = unref(a).scope) == null ? void 0 : G.objectIDs) || [],
902
+ onConfirm: M,
903
+ onCancel: X
904
+ }, null, 8, ["visible", "initial-value"])
905
+ ])) : createCommentVNode("", !0),
906
+ w() ? (openBlock(), createElementBlock("div", _hoisted_17$2, [
907
+ unref(n) ? createCommentVNode("", !0) : (openBlock(), createElementBlock("div", _hoisted_18$2, [
908
+ E[14] || (E[14] = createElementVNode("label", { class: "fm-typo-en-body-md-600 mb-8 block" }, "Select Categories", -1)),
909
+ createElementVNode("div", _hoisted_19$2, [
910
+ createElementVNode("div", _hoisted_20$2, [
911
+ createElementVNode("div", _hoisted_21$1, [
912
+ createVNode(P, {
913
+ name: "category",
914
+ size: "md"
915
+ }),
916
+ createElementVNode("span", _hoisted_22$1, toDisplayString(T()), 1)
917
+ ]),
918
+ createVNode(F, {
919
+ variant: "secondary",
920
+ label: "Select Categories",
921
+ icon: "chevron_right",
922
+ onClick: A
923
+ })
924
+ ]),
925
+ E[13] || (E[13] = createElementVNode("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Choose which categories this discount applies to. ", -1))
926
+ ])
927
+ ])),
928
+ createVNode(_sfc_main$s, {
929
+ visible: unref(n),
930
+ "initial-value": ((h = unref(a).scope) == null ? void 0 : h.objectIDs) || [],
931
+ onConfirm: I,
932
+ onCancel: K
933
+ }, null, 8, ["visible", "initial-value"])
934
+ ])) : createCommentVNode("", !0)
935
+ ]),
936
+ unref(Z).length > 0 ? (openBlock(), createElementBlock("div", _hoisted_23$1, [
937
+ createElementVNode("div", _hoisted_24$1, [
938
+ createVNode(P, { name: "warning" }),
939
+ E[15] || (E[15] = createElementVNode("span", { class: "fm-typo-en-body-sm-600" }, "Please fix the following issues:", -1))
940
+ ]),
941
+ createElementVNode("ul", _hoisted_25$1, [
942
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(Z), (B) => (openBlock(), createElementBlock("li", {
943
+ key: B,
944
+ class: "fm-typo-en-body-sm-400 text-fm-color-feedback-error-main flex items-start gap-8"
945
+ }, [
946
+ E[16] || (E[16] = createElementVNode("span", { class: "w-4 h-4 bg-fm-color-feedback-error-main rounded-full mt-6 flex-shrink-0" }, null, -1)),
947
+ createTextVNode(" " + toDisplayString(B), 1)
948
+ ]))), 128))
949
+ ])
950
+ ])) : createCommentVNode("", !0)
951
+ ];
952
+ }),
953
+ _: 1
954
+ }, 8, ["modelValue"]);
955
+ };
956
+ }
957
+ }), GrabEffectSheet = /* @__PURE__ */ _export_sfc(_sfc_main$r, [["__scopeId", "data-v-cf604dd7"]]), _hoisted_1$o = { class: "space-y-24" }, _sfc_main$q = /* @__PURE__ */ defineComponent({
958
+ __name: "TimeRuleGroup",
959
+ props: {
960
+ modelValue: {
961
+ type: Object,
962
+ default: () => {
963
+ }
964
+ }
965
+ },
966
+ emits: ["update:model-value"],
967
+ setup(e, { emit: r }) {
968
+ const { t: o } = useI18n(), m = e, i = r, u = ref(
969
+ !m.modelValue || !m.modelValue.rules.g_time ? "all_time" : RuleBuilder.getRules(m.modelValue.rules.g_time).length > 0 ? "custom" : "all_time"
970
+ );
971
+ watch(u, async (n, a) => {
972
+ var s;
973
+ if (a == "custom" && n == "all_time" && RuleBuilder.getRules((s = m.modelValue) == null ? void 0 : s.rules.g_time).length > 0) {
974
+ const y = await prompt.confirm(
975
+ o("connect.template.rule.time.confirm_remove"),
976
+ o("connect.common.confirm"),
977
+ o("connect.common.confirm"),
978
+ o("connect.common.cancel")
979
+ );
980
+ y && i(
981
+ "update:model-value",
982
+ RuleBuilder.setRuleToGroup(
983
+ m.modelValue ?? RuleBuilder.scaffoldGroup(),
984
+ RuleBuilder.scaffoldGroup("g_time")
985
+ )
986
+ ), u.value = y ? n : a;
987
+ }
988
+ });
989
+ async function l(n) {
990
+ var a;
991
+ if (n == "custom" && RuleBuilder.getRules((a = m.modelValue) == null ? void 0 : a.rules.g_time).length > 0) {
992
+ if (!await prompt.confirm(
993
+ o("connect.template.rule.time.confirm_remove"),
994
+ o("connect.common.confirm"),
995
+ o("connect.common.confirm"),
996
+ o("connect.common.cancel")
997
+ )) {
998
+ u.value = "all_time";
999
+ return;
1000
+ }
1001
+ i(
1002
+ "update:model-value",
1003
+ RuleBuilder.setRuleToGroup(
1004
+ m.modelValue ?? RuleBuilder.scaffoldGroup(),
1005
+ RuleBuilder.scaffoldGroup("g_time")
1006
+ )
1007
+ );
1008
+ }
1009
+ }
1010
+ return (n, a) => {
1011
+ var f;
1012
+ const s = resolveComponent("FmRadio"), y = resolveComponent("FmRadioGroup");
1013
+ return openBlock(), createElementBlock("div", _hoisted_1$o, [
1014
+ createVNode(y, {
1015
+ modelValue: unref(u),
1016
+ "onUpdate:modelValue": [
1017
+ a[0] || (a[0] = (c) => isRef(u) ? u.value = c : null),
1018
+ a[1] || (a[1] = (c) => l(c))
1019
+ ]
1020
+ }, {
1021
+ default: withCtx(() => [
1022
+ createVNode(s, {
1023
+ label: unref(o)("connect.template.rule.time.all_time"),
1024
+ value: "all_time"
1025
+ }, null, 8, ["label"]),
1026
+ createVNode(s, {
1027
+ label: unref(o)("connect.template.rule.time.custom"),
1028
+ value: "custom"
1029
+ }, null, 8, ["label"])
1030
+ ]),
1031
+ _: 1
1032
+ }, 8, ["modelValue"]),
1033
+ unref(u) == "custom" ? (openBlock(), createBlock(_sfc_main$u, {
1034
+ key: 0,
1035
+ class: "!mt-[0px]",
1036
+ "include-only": "trigger",
1037
+ "trigger-type": "SCHEDULE",
1038
+ "model-value": ((f = e.modelValue) == null ? void 0 : f.rules.g_time) ?? unref(RuleBuilder).scaffoldGroup("g_time"),
1039
+ "onUpdate:modelValue": a[2] || (a[2] = (c) => i(
1040
+ "update:model-value",
1041
+ unref(RuleBuilder).setRuleToGroup(
1042
+ e.modelValue ?? unref(RuleBuilder).scaffoldGroup(),
1043
+ c,
1044
+ "&&"
1045
+ )
1046
+ ))
1047
+ }, null, 8, ["model-value"])) : createCommentVNode("", !0)
1048
+ ]);
1049
+ };
1050
+ }
1051
+ }), _sfc_main$p = /* @__PURE__ */ defineComponent({
1052
+ __name: "BirthdayInput",
1053
+ props: {
1054
+ modelValue: {
1055
+ type: Object
1056
+ }
1057
+ },
1058
+ emits: ["update:model-value"],
1059
+ setup(e, { emit: r }) {
1060
+ const { t: o } = useI18n(), m = e, i = r, u = computed(() => {
1061
+ const { property: l, operator: n, equator: a } = RuleBuilder.simplify(
1062
+ m.modelValue ?? RuleBuilder.constructEntry("user.birthday", "_isDay", {
1063
+ op: "before",
1064
+ x: 1
1065
+ })
1066
+ );
1067
+ return {
1068
+ property: l,
1069
+ operator: n,
1070
+ equator: a
1071
+ };
1072
+ });
1073
+ return (l, n) => {
1074
+ const a = resolveComponent("FmRadio"), s = resolveComponent("FmStepperField");
1075
+ return openBlock(), createElementBlock("div", null, [
1076
+ createVNode(a, {
1077
+ label: unref(o)("connect.template.rule.birthday.on_birthday"),
1078
+ value: "_isRange-day",
1079
+ "model-value": `${unref(u).operator}-${unref(u).equator.unit}`,
1080
+ "onUpdate:modelValue": n[0] || (n[0] = () => {
1081
+ i(
1082
+ "update:model-value",
1083
+ unref(RuleBuilder).constructEntry("user.birthday", "_isRange", {
1084
+ op: "this",
1085
+ unit: "day",
1086
+ ignoreYear: !0
1087
+ })
1088
+ );
1089
+ })
1090
+ }, null, 8, ["label", "model-value"]),
1091
+ createVNode(a, {
1092
+ label: unref(o)("connect.template.rule.birthday.days_before"),
1093
+ value: "_isDay",
1094
+ "model-value": unref(u).operator,
1095
+ "onUpdate:modelValue": n[1] || (n[1] = () => {
1096
+ i(
1097
+ "update:model-value",
1098
+ unref(RuleBuilder).constructEntry("user.birthday", "_isDay", {
1099
+ op: "after",
1100
+ x: 1,
1101
+ ignoreYear: !0
1102
+ })
1103
+ );
1104
+ })
1105
+ }, null, 8, ["label", "model-value"]),
1106
+ unref(u).operator == "_isDay" ? (openBlock(), createBlock(s, {
1107
+ key: 0,
1108
+ label: unref(o)("connect.template.rule.birthday.days_before_label"),
1109
+ "show-steppers": !1,
1110
+ "model-value": unref(u).equator.x,
1111
+ "onUpdate:modelValue": n[2] || (n[2] = (y) => i(
1112
+ "update:model-value",
1113
+ unref(RuleBuilder).constructEntry("user.birthday", "_isDay", {
1114
+ op: "after",
1115
+ x: y,
1116
+ ignoreYear: !0
1117
+ })
1118
+ ))
1119
+ }, null, 8, ["label", "model-value"])) : createCommentVNode("", !0),
1120
+ createVNode(a, {
1121
+ label: unref(o)("connect.template.rule.birthday.in_birthday_week"),
1122
+ value: "_isRange-week",
1123
+ "model-value": `${unref(u).operator}-${unref(u).equator.unit}`,
1124
+ "onUpdate:modelValue": n[3] || (n[3] = () => {
1125
+ i(
1126
+ "update:model-value",
1127
+ unref(RuleBuilder).constructEntry("user.birthday", "_isRange", {
1128
+ op: "this",
1129
+ unit: "week",
1130
+ ignoreYear: !0
1131
+ })
1132
+ );
1133
+ })
1134
+ }, null, 8, ["label", "model-value"]),
1135
+ createVNode(a, {
1136
+ label: unref(o)("connect.template.rule.birthday.in_birthday_month"),
1137
+ value: "_isRange-month",
1138
+ "model-value": `${unref(u).operator}-${unref(u).equator.unit}`,
1139
+ "onUpdate:modelValue": n[4] || (n[4] = () => {
1140
+ i(
1141
+ "update:model-value",
1142
+ unref(RuleBuilder).constructEntry("user.birthday", "_isRange", {
1143
+ op: "this",
1144
+ unit: "month",
1145
+ ignoreYear: !0
1146
+ })
1147
+ );
1148
+ })
1149
+ }, null, 8, ["label", "model-value"])
1150
+ ]);
1151
+ };
1152
+ }
1153
+ }), _hoisted_1$n = { class: "space-y-16" }, _hoisted_2$k = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$h = { class: "grid grid-cols-3 gap-16" }, _hoisted_4$g = { class: "fm-typo-en-title-sm-800" }, _hoisted_5$d = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$o = /* @__PURE__ */ defineComponent({
1154
+ __name: "CampaignTriggerInput",
1155
+ props: {
1156
+ campaignType: {
1157
+ type: String,
1158
+ required: !0
1159
+ },
1160
+ modelValue: {
1161
+ type: String
1162
+ },
1163
+ disabled: {
1164
+ type: Boolean,
1165
+ default: !1
1166
+ }
1167
+ },
1168
+ emits: ["update:model-value"],
1169
+ setup(e, { emit: r }) {
1170
+ const { t: o } = useI18n(), m = e, i = r, u = computed(() => m.disabled ? TypeToTriggerOptions[m.campaignType].filter(
1171
+ (l) => l.value == m.modelValue
1172
+ ) : TypeToTriggerOptions[m.campaignType]);
1173
+ return (l, n) => {
1174
+ const a = resolveComponent("FmCard");
1175
+ return openBlock(), createElementBlock("div", _hoisted_1$n, [
1176
+ createElementVNode("div", _hoisted_2$k, toDisplayString(unref(o)("connect.campaign.trigger.description")), 1),
1177
+ createElementVNode("div", _hoisted_3$h, [
1178
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(u), (s) => (openBlock(), createBlock(a, {
1179
+ variant: "outlined",
1180
+ disabled: m.disabled,
1181
+ class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
1182
+ "col-span-3": unref(u).length == 1,
1183
+ "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": e.modelValue == s.value,
1184
+ "hover:bg-fm-color-opacity-sm": e.modelValue != s.value
1185
+ }]),
1186
+ onClick: () => {
1187
+ m.modelValue != s.value && !m.disabled && i("update:model-value", s.value);
1188
+ },
1189
+ key: s.name
1190
+ }, {
1191
+ default: withCtx(() => [
1192
+ createElementVNode("div", _hoisted_4$g, toDisplayString(s.name), 1),
1193
+ createElementVNode("div", _hoisted_5$d, toDisplayString(s.description), 1)
1194
+ ]),
1195
+ _: 2
1196
+ }, 1032, ["disabled", "class", "onClick"]))), 128))
1197
+ ])
1198
+ ]);
1199
+ };
1200
+ }
1201
+ }), _sfc_main$n = /* @__PURE__ */ defineComponent({
1202
+ __name: "DateInput",
1203
+ props: {
1204
+ label: {
1205
+ type: String,
1206
+ required: !1
1207
+ },
1208
+ modelValue: {
1209
+ type: Object,
1210
+ required: !1
1211
+ }
1212
+ },
1213
+ emits: ["update:model-value"],
1214
+ setup(e, { emit: r }) {
1215
+ const o = r;
1216
+ return (m, i) => {
1217
+ const u = resolveComponent("FmButton"), l = resolveComponent("FmField"), n = resolveComponent("FmDatePicker");
1218
+ return openBlock(), createBlock(n, {
1219
+ label: e.label,
1220
+ "model-value": e.modelValue || "",
1221
+ "onUpdate:modelValue": i[1] || (i[1] = (a) => o("update:model-value", a))
1222
+ }, {
1223
+ "trigger-button": withCtx(({ opened: a }) => [
1224
+ createVNode(l, {
1225
+ class: "flex items-center",
1226
+ "prepend-icon": "calendar_month",
1227
+ "icon-outlined": !a
1228
+ }, {
1229
+ append: withCtx(() => [
1230
+ e.modelValue ? (openBlock(), createBlock(u, {
1231
+ key: 0,
1232
+ variant: "tertiary",
1233
+ icon: "clear",
1234
+ onClick: i[0] || (i[0] = (s) => (s.stopPropagation(), o("update:model-value", null)))
1235
+ })) : createCommentVNode("", !0)
1236
+ ]),
1237
+ default: withCtx(() => [
1238
+ createElementVNode("div", {
1239
+ class: normalizeClass(["fm-typo-en-body-lg-400", { "text-fm-color-typo-secondary": !e.modelValue }])
1240
+ }, toDisplayString(e.modelValue ? unref(hooks)(e.modelValue).format("DD MMM YYYY") : "DD MM YYYY"), 3)
1241
+ ]),
1242
+ _: 1
1243
+ }, 8, ["icon-outlined"])
1244
+ ]),
1245
+ _: 1
1246
+ }, 8, ["label", "model-value"]);
1247
+ };
1248
+ }
1249
+ }), _hoisted_1$m = { class: "flex items-center gap-8 w-full xs:flex-col" }, _hoisted_2$j = { class: "flex-1 xs:w-full" }, _hoisted_3$g = { class: "mt-5 xs:hidden" }, _hoisted_4$f = { class: "flex-1 xs:w-full" }, _sfc_main$m = /* @__PURE__ */ defineComponent({
1250
+ __name: "DateRangeInput",
1251
+ props: {
1252
+ modelValue: {
1253
+ type: Object,
1254
+ required: !1
1255
+ }
1256
+ },
1257
+ emits: ["update:model-value"],
1258
+ setup(e, { emit: r }) {
1259
+ const { t: o } = useI18n(), m = r;
1260
+ return (i, u) => {
1261
+ var l, n;
1262
+ return openBlock(), createElementBlock("div", _hoisted_1$m, [
1263
+ createElementVNode("div", _hoisted_2$j, [
1264
+ createVNode(_sfc_main$n, {
1265
+ "model-value": ((l = e.modelValue) == null ? void 0 : l.startDate) ?? null,
1266
+ label: unref(o)("connect.common.startDate"),
1267
+ "onUpdate:modelValue": u[0] || (u[0] = (a) => {
1268
+ var s;
1269
+ return m("update:model-value", {
1270
+ startDate: a,
1271
+ endDate: ((s = e.modelValue) == null ? void 0 : s.endDate) ?? null
1272
+ });
1273
+ })
1274
+ }, null, 8, ["model-value", "label"])
1275
+ ]),
1276
+ createElementVNode("div", _hoisted_3$g, toDisplayString(unref(o)("connect.common.to")), 1),
1277
+ createElementVNode("div", _hoisted_4$f, [
1278
+ createVNode(_sfc_main$n, {
1279
+ "model-value": ((n = e.modelValue) == null ? void 0 : n.endDate) ?? null,
1280
+ label: unref(o)("connect.common.endDate"),
1281
+ "onUpdate:modelValue": u[1] || (u[1] = (a) => {
1282
+ var s;
1283
+ return m("update:model-value", {
1284
+ startDate: ((s = e.modelValue) == null ? void 0 : s.startDate) ?? null,
1285
+ endDate: a
1286
+ });
1287
+ })
1288
+ }, null, 8, ["model-value", "label"])
1289
+ ])
1290
+ ]);
1291
+ };
1292
+ }
1293
+ }), _hoisted_1$l = { class: "flex flex-col gap-16" }, _hoisted_2$i = { class: "mb-[6px] flex items-baseline justify-between" }, _hoisted_3$f = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, _hoisted_4$e = { class: "mb-[6px] flex items-baseline justify-between" }, _hoisted_5$c = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, _hoisted_6$9 = { class: "flex items-center justify-between gap-8" }, _hoisted_7$8 = { class: "fm-typo-en-body-lg-400" }, _hoisted_8$7 = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _hoisted_9$7 = { class: "flex flex-col gap-8" }, _hoisted_10$6 = { class: "flex items-baseline justify-between" }, _hoisted_11$4 = { class: "fm-typo-en-body-lg-400" }, _hoisted_12$3 = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, _hoisted_13$3 = { class: "min-w-[160px] flex-1" }, _hoisted_14$3 = { class: "min-w-[180px] flex-1" }, TITLE_LIMIT$1 = 40, PREVIEW_LIMIT = 120, MAX_BUTTONS = 2, TITLE_WARN_AT$1 = 34, PREVIEW_WARN_AT = 110, _sfc_main$l = /* @__PURE__ */ defineComponent({
1294
+ __name: "AppInboxInput",
1295
+ props: {
1296
+ modelValue: {
1297
+ type: Object,
1298
+ required: !0
1299
+ },
1300
+ variables: {
1301
+ type: Array,
1302
+ default: () => [...DEFAULT_MESSAGE_VARIABLES]
1303
+ },
1304
+ /** False until the form is submitted; broadcasts validate on submit. */
1305
+ showValidation: {
1306
+ type: Boolean,
1307
+ default: !0
1308
+ }
1309
+ },
1310
+ emits: ["update:model-value"],
1311
+ setup(e, { emit: r }) {
1312
+ const { t: o } = useI18n(), m = e, i = r;
1313
+ function u(k) {
1314
+ i("update:model-value", { ...m.modelValue, ...k });
1315
+ }
1316
+ function l(k, V) {
1317
+ return k >= V ? "text-fm-color-system-warning-400" : "text-fm-color-typo-secondary";
1318
+ }
1319
+ const n = computed(() => m.modelValue.buttons ?? []), a = computed(() => {
1320
+ var k;
1321
+ return ((k = m.modelValue.content) == null ? void 0 : k.length) ?? 0;
1322
+ });
1323
+ function s(k, V) {
1324
+ u({
1325
+ buttons: n.value.map(
1326
+ (g, v) => v === k ? { ...g, ...V } : g
1327
+ )
1328
+ });
1329
+ }
1330
+ function y() {
1331
+ n.value.length >= MAX_BUTTONS || u({ buttons: [...n.value, { label: "", url: "" }] });
1332
+ }
1333
+ function f(k) {
1334
+ var g;
1335
+ if (!m.showValidation) return { label: void 0, url: void 0 };
1336
+ const V = (g = k.url) == null ? void 0 : g.trim();
1337
+ return {
1338
+ label: k.label.trim() ? void 0 : o("connect.campaign.appInbox.buttonLabelRequired"),
1339
+ url: V ? FdoBroadcastUrl.safeParse(V).success ? void 0 : o("connect.campaign.push.linkUrlInvalid") : o("connect.campaign.appInbox.buttonUrlRequired")
1340
+ };
1341
+ }
1342
+ function c(k) {
1343
+ u({ buttons: n.value.filter((V, g) => g !== k) });
1344
+ }
1345
+ return (k, V) => {
1346
+ const g = resolveComponent("FmTextField"), v = resolveComponent("FmButton");
1347
+ return openBlock(), createElementBlock("div", _hoisted_1$l, [
1348
+ createElementVNode("div", null, [
1349
+ createElementVNode("div", _hoisted_2$i, [
1350
+ createElementVNode("span", _hoisted_3$f, toDisplayString(unref(o)("connect.campaign.appInbox.title")), 1),
1351
+ createElementVNode("span", {
1352
+ class: normalizeClass(["fm-typo-en-body-sm-400", l(e.modelValue.title.length, TITLE_WARN_AT$1)])
1353
+ }, toDisplayString(e.modelValue.title.length) + " / " + toDisplayString(TITLE_LIMIT$1), 3)
1354
+ ]),
1355
+ createVNode(g, {
1356
+ "model-value": e.modelValue.title,
1357
+ "max-length": TITLE_LIMIT$1,
1358
+ placeholder: unref(o)("connect.campaign.appInbox.titlePlaceholder"),
1359
+ "onUpdate:modelValue": V[0] || (V[0] = (d) => u({ title: d }))
1360
+ }, null, 8, ["model-value", "placeholder"])
1361
+ ]),
1362
+ createElementVNode("div", null, [
1363
+ createElementVNode("div", _hoisted_4$e, [
1364
+ createElementVNode("span", _hoisted_5$c, toDisplayString(unref(o)("connect.campaign.appInbox.previewText")), 1),
1365
+ createElementVNode("span", {
1366
+ class: normalizeClass(["fm-typo-en-body-sm-400", l(e.modelValue.previewText.length, PREVIEW_WARN_AT)])
1367
+ }, toDisplayString(e.modelValue.previewText.length) + " / " + toDisplayString(PREVIEW_LIMIT), 3)
1368
+ ]),
1369
+ createVNode(g, {
1370
+ "model-value": e.modelValue.previewText,
1371
+ "max-length": PREVIEW_LIMIT,
1372
+ placeholder: unref(o)("connect.campaign.appInbox.previewTextPlaceholder"),
1373
+ "onUpdate:modelValue": V[1] || (V[1] = (d) => u({ previewText: d }))
1374
+ }, null, 8, ["model-value", "placeholder"])
1375
+ ]),
1376
+ createElementVNode("div", _hoisted_6$9, [
1377
+ createElementVNode("div", null, [
1378
+ createElementVNode("div", _hoisted_7$8, toDisplayString(unref(o)("connect.campaign.appInbox.bodyMessage")), 1),
1379
+ createElementVNode("div", _hoisted_8$7, toDisplayString(unref(o)("connect.campaign.appInbox.bodyMessageDescription")), 1),
1380
+ createElementVNode("div", {
1381
+ class: normalizeClass([
1382
+ "mt-[2px] fm-typo-en-body-sm-400",
1383
+ unref(a) > unref(APP_INBOX_BODY_LIMIT) ? "text-fm-color-system-error-400" : "text-fm-color-typo-secondary"
1384
+ ])
1385
+ }, toDisplayString(unref(a)) + " / " + toDisplayString(unref(APP_INBOX_BODY_LIMIT)), 3)
1386
+ ]),
1387
+ createVNode(_sfc_main$v, {
1388
+ html: e.modelValue.content,
1389
+ variables: e.variables,
1390
+ "media-limit": 1,
1391
+ "button-label": unref(o)("connect.campaign.appInbox.editBodyMessage"),
1392
+ "onUpdate:html": V[2] || (V[2] = (d) => u({ content: d.html }))
1393
+ }, null, 8, ["html", "variables", "button-label"])
1394
+ ]),
1395
+ createElementVNode("div", _hoisted_9$7, [
1396
+ createElementVNode("div", _hoisted_10$6, [
1397
+ createElementVNode("span", _hoisted_11$4, toDisplayString(unref(o)("connect.campaign.appInbox.buttons")), 1),
1398
+ createElementVNode("span", _hoisted_12$3, toDisplayString(unref(n).length) + " / " + toDisplayString(MAX_BUTTONS), 1)
1399
+ ]),
1400
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(n), (d, p) => (openBlock(), createElementBlock("div", {
1401
+ key: p,
1402
+ class: "flex flex-wrap items-start gap-8"
1403
+ }, [
1404
+ createElementVNode("div", _hoisted_13$3, [
1405
+ createVNode(g, {
1406
+ "model-value": d.label,
1407
+ "max-length": 20,
1408
+ placeholder: unref(o)("connect.campaign.appInbox.buttonLabel"),
1409
+ "helper-state": f(d).label ? "error" : "none",
1410
+ "helper-text": f(d).label,
1411
+ "onUpdate:modelValue": (C) => s(p, { label: C })
1412
+ }, null, 8, ["model-value", "placeholder", "helper-state", "helper-text", "onUpdate:modelValue"])
1413
+ ]),
1414
+ createElementVNode("div", _hoisted_14$3, [
1415
+ createVNode(g, {
1416
+ "model-value": d.url ?? "",
1417
+ inputmode: "url",
1418
+ placeholder: unref(o)("connect.campaign.push.linkUrlPlaceholder"),
1419
+ "helper-state": f(d).url ? "error" : "none",
1420
+ "helper-text": f(d).url,
1421
+ "onUpdate:modelValue": (C) => s(p, { url: C.trim() })
1422
+ }, null, 8, ["model-value", "placeholder", "helper-state", "helper-text", "onUpdate:modelValue"])
1423
+ ]),
1424
+ createVNode(v, {
1425
+ icon: "delete",
1426
+ "icon-color": "neutral-gray-400",
1427
+ variant: "tertiary",
1428
+ onClick: (C) => c(p)
1429
+ }, null, 8, ["onClick"])
1430
+ ]))), 128)),
1431
+ unref(n).length < MAX_BUTTONS ? (openBlock(), createBlock(v, {
1432
+ key: 0,
1433
+ variant: "tertiary",
1434
+ icon: "add",
1435
+ label: unref(o)("connect.campaign.appInbox.addButton"),
1436
+ onClick: y
1437
+ }, null, 8, ["label"])) : createCommentVNode("", !0)
1438
+ ])
1439
+ ]);
1440
+ };
1441
+ }
1442
+ }), _hoisted_1$k = { class: "flex flex-col gap-16" }, _hoisted_2$h = { class: "mb-[6px] flex items-baseline justify-between" }, _hoisted_3$e = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, _hoisted_4$d = { class: "mb-[6px] flex items-baseline justify-between" }, _hoisted_5$b = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, _hoisted_6$8 = { class: "mb-[6px] fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, _hoisted_7$7 = {
1443
+ key: 0,
1444
+ class: "mt-4 fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1445
+ }, _hoisted_8$6 = {
1446
+ key: 1,
1447
+ class: "mt-12"
1448
+ }, _hoisted_9$6 = { class: "mb-[6px] fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, TITLE_LIMIT = 40, BODY_LIMIT = 120, TITLE_WARN_AT = 34, BODY_WARN_AT = 110, _sfc_main$k = /* @__PURE__ */ defineComponent({
1449
+ __name: "PushInput",
1450
+ props: {
1451
+ modelValue: {
1452
+ type: Object,
1453
+ required: !0
1454
+ },
1455
+ /** False until the form is submitted; broadcasts validate on submit. */
1456
+ showValidation: {
1457
+ type: Boolean,
1458
+ default: !0
1459
+ }
1460
+ },
1461
+ emits: ["update:model-value"],
1462
+ setup(e, { emit: r }) {
1463
+ const { t: o } = useI18n(), m = e, i = r, u = F_PUSH_DESTINATION.options, l = computed(() => m.modelValue.destination === "EXTERNAL"), n = computed(() => {
1464
+ var c;
1465
+ if (!m.showValidation || !l.value) return;
1466
+ const f = (c = m.modelValue.url) == null ? void 0 : c.trim();
1467
+ return f ? FdoBroadcastUrl.safeParse(f).success ? void 0 : o("connect.campaign.push.linkUrlInvalid") : o("connect.campaign.push.linkUrlRequired");
1468
+ });
1469
+ function a(f) {
1470
+ i("update:model-value", { ...m.modelValue, ...f });
1471
+ }
1472
+ function s(f) {
1473
+ a(f === "EXTERNAL" ? { destination: f } : { destination: f, url: null });
1474
+ }
1475
+ function y(f, c) {
1476
+ return f >= c ? "text-fm-color-system-warning-400" : "text-fm-color-typo-secondary";
1477
+ }
1478
+ return (f, c) => {
1479
+ const k = resolveComponent("FmTextField"), V = resolveComponent("FmTextarea"), g = resolveComponent("FmSelect");
1480
+ return openBlock(), createElementBlock("div", _hoisted_1$k, [
1481
+ createElementVNode("div", null, [
1482
+ createElementVNode("div", _hoisted_2$h, [
1483
+ createElementVNode("span", _hoisted_3$e, toDisplayString(unref(o)("connect.campaign.push.title")), 1),
1484
+ createElementVNode("span", {
1485
+ class: normalizeClass(["fm-typo-en-body-sm-400", y(e.modelValue.title.length, TITLE_WARN_AT)])
1486
+ }, toDisplayString(e.modelValue.title.length) + " / " + toDisplayString(TITLE_LIMIT), 3)
1487
+ ]),
1488
+ createVNode(k, {
1489
+ "model-value": e.modelValue.title,
1490
+ "max-length": TITLE_LIMIT,
1491
+ placeholder: unref(o)("connect.campaign.push.titlePlaceholder"),
1492
+ "onUpdate:modelValue": c[0] || (c[0] = (v) => a({ title: v }))
1493
+ }, null, 8, ["model-value", "placeholder"])
1494
+ ]),
1495
+ createElementVNode("div", null, [
1496
+ createElementVNode("div", _hoisted_4$d, [
1497
+ createElementVNode("span", _hoisted_5$b, toDisplayString(unref(o)("connect.campaign.push.body")), 1),
1498
+ createElementVNode("span", {
1499
+ class: normalizeClass(["fm-typo-en-body-sm-400", y(e.modelValue.body.length, BODY_WARN_AT)])
1500
+ }, toDisplayString(e.modelValue.body.length) + " / " + toDisplayString(BODY_LIMIT), 3)
1501
+ ]),
1502
+ createVNode(V, {
1503
+ "model-value": e.modelValue.body,
1504
+ "max-length": BODY_LIMIT,
1505
+ placeholder: unref(o)("connect.campaign.push.bodyPlaceholder"),
1506
+ "onUpdate:modelValue": c[1] || (c[1] = (v) => a({ body: v }))
1507
+ }, null, 8, ["model-value", "placeholder"])
1508
+ ]),
1509
+ createElementVNode("div", null, [
1510
+ createElementVNode("div", _hoisted_6$8, toDisplayString(unref(o)("connect.campaign.push.link")), 1),
1511
+ createVNode(g, {
1512
+ "model-value": e.modelValue.destination ?? "NONE",
1513
+ items: unref(u).map((v) => ({
1514
+ label: unref(o)(`connect.campaign.appInbox.destination.${v}`),
1515
+ value: v
1516
+ })),
1517
+ "onUpdate:modelValue": c[2] || (c[2] = (v) => s(v))
1518
+ }, null, 8, ["model-value", "items"]),
1519
+ unref(l) ? createCommentVNode("", !0) : (openBlock(), createElementBlock("div", _hoisted_7$7, toDisplayString(unref(o)("connect.campaign.push.linkHelper")), 1)),
1520
+ unref(l) ? (openBlock(), createElementBlock("div", _hoisted_8$6, [
1521
+ createElementVNode("div", _hoisted_9$6, toDisplayString(unref(o)("connect.campaign.push.linkUrl")), 1),
1522
+ createVNode(k, {
1523
+ "model-value": e.modelValue.url ?? "",
1524
+ inputmode: "url",
1525
+ placeholder: unref(o)("connect.campaign.push.linkUrlPlaceholder"),
1526
+ "helper-state": unref(n) ? "error" : "none",
1527
+ "helper-text": unref(n),
1528
+ "onUpdate:modelValue": c[3] || (c[3] = (v) => a({ url: v.trim() || null }))
1529
+ }, null, 8, ["model-value", "placeholder", "helper-state", "helper-text"])
1530
+ ])) : createCommentVNode("", !0)
1531
+ ])
1532
+ ]);
1533
+ };
1534
+ }
1535
+ }), _hoisted_1$j = { class: "flex items-stretch overflow-x-auto pb-4" }, _hoisted_2$g = {
1536
+ key: 0,
1537
+ class: "flex flex-none items-center px-8 fm-typo-en-body-lg-600 text-fm-color-neutral-gray-300",
1538
+ "aria-hidden": "true"
1539
+ }, _hoisted_3$d = ["aria-current", "onClick"], _hoisted_4$c = { class: "flex items-center gap-[6px]" }, _hoisted_5$a = ["title"], _hoisted_6$7 = { class: "mt-[3px] block text-[11px] leading-[1.3] text-fm-color-typo-secondary" }, _sfc_main$j = /* @__PURE__ */ defineComponent({
1540
+ __name: "ChannelContentTabs",
1541
+ props: {
1542
+ tabs: {},
1543
+ modelValue: {}
1544
+ },
1545
+ emits: ["update:model-value"],
1546
+ setup(e) {
1547
+ const { t: r } = useI18n();
1548
+ return (o, m) => (openBlock(), createElementBlock("div", _hoisted_1$j, [
1549
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(e.tabs, (i) => (openBlock(), createElementBlock("div", {
1550
+ key: i.key,
1551
+ class: "flex flex-none items-center"
1552
+ }, [
1553
+ i.connector ? (openBlock(), createElementBlock("span", _hoisted_2$g, toDisplayString(i.connector), 1)) : createCommentVNode("", !0),
1554
+ createElementVNode("button", {
1555
+ type: "button",
1556
+ class: normalizeClass([
1557
+ "min-w-[132px] flex-none rounded-[10px] border px-[14px] py-[10px] text-left transition-colors",
1558
+ e.modelValue === i.key ? "border-fm-color-primary bg-fm-color-system-warning-100" : "border-fm-color-neutral-gray-100 bg-fm-color-neutral-white hover:border-fm-color-neutral-gray-200"
1559
+ ]),
1560
+ "aria-current": e.modelValue === i.key ? "true" : void 0,
1561
+ onClick: (u) => o.$emit("update:model-value", i.key)
1562
+ }, [
1563
+ createElementVNode("span", _hoisted_4$c, [
1564
+ i.step ? (openBlock(), createElementBlock("span", {
1565
+ key: 0,
1566
+ class: normalizeClass([
1567
+ "flex h-[18px] w-[18px] flex-none items-center justify-center rounded-full text-[10.5px] font-semibold leading-[18px]",
1568
+ e.modelValue === i.key ? "bg-fm-color-primary text-fm-color-typo-white" : "bg-fm-color-neutral-gray-100 text-fm-color-typo-secondary"
1569
+ ])
1570
+ }, toDisplayString(i.step), 3)) : createCommentVNode("", !0),
1571
+ createElementVNode("span", {
1572
+ class: normalizeClass([
1573
+ "truncate text-[12.5px] font-semibold leading-[1.3]",
1574
+ e.modelValue === i.key ? "text-fm-color-primary" : "text-fm-color-typo-primary"
1575
+ ])
1576
+ }, toDisplayString(i.label), 3),
1577
+ i.complete ? createCommentVNode("", !0) : (openBlock(), createElementBlock("span", {
1578
+ key: 1,
1579
+ class: "h-[7px] w-[7px] flex-none rounded-full bg-fm-color-system-error-400",
1580
+ title: unref(r)("connect.campaign.broadcast.messageMissing")
1581
+ }, null, 8, _hoisted_5$a))
1582
+ ]),
1583
+ createElementVNode("span", _hoisted_6$7, toDisplayString(i.sub), 1)
1584
+ ], 10, _hoisted_3$d)
1585
+ ]))), 128))
1586
+ ]));
1587
+ }
1588
+ }), _hoisted_1$i = {
1589
+ key: 0,
1590
+ class: "flex w-[264px] shrink-0 flex-col gap-8"
1591
+ }, _hoisted_2$f = { class: "fm-typo-en-body-md-600" }, _hoisted_3$c = { class: "flex justify-center py-8" }, _hoisted_4$b = {
1592
+ key: 0,
1593
+ class: "px-12 pb-16 pt-16"
1594
+ }, _hoisted_5$9 = { class: "mb-12 text-center text-[11px] text-[rgba(255,255,255,0.6)]" }, _hoisted_6$6 = { class: "rounded-[14px] border border-[rgba(255,255,255,0.12)] bg-[rgba(255,255,255,0.14)] p-12 backdrop-blur" }, _hoisted_7$6 = { class: "fm-typo-en-body-md-600 text-fm-color-typo-white line-clamp-2" }, _hoisted_8$5 = { class: "mt-[2px] fm-typo-en-body-sm-400 text-[rgba(255,255,255,0.72)] line-clamp-3" }, _hoisted_9$5 = {
1595
+ key: 1,
1596
+ class: "px-12 pb-16"
1597
+ }, _hoisted_10$5 = { class: "fm-typo-en-body-md-600 mb-8" }, _hoisted_11$3 = { class: "rounded-[12px] border border-fm-color-neutral-gray-100 p-12" }, _hoisted_12$2 = { class: "fm-typo-en-body-md-600 line-clamp-2" }, _hoisted_13$2 = { class: "mt-[2px] fm-typo-en-body-sm-400 text-fm-color-typo-secondary line-clamp-3" }, _hoisted_14$2 = ["src"], _hoisted_15$2 = ["srcdoc", "title"], _hoisted_16$1 = {
1598
+ key: 2,
1599
+ class: "mt-12 flex flex-col gap-[6px]"
1600
+ }, _hoisted_17$1 = {
1601
+ key: 2,
1602
+ class: "px-12 pb-16"
1603
+ }, _hoisted_18$1 = { class: "fm-typo-en-body-md-600 mb-8" }, _hoisted_19$1 = { class: "whitespace-pre-wrap break-words rounded-[12px] bg-fm-color-neutral-gray-100 p-12 fm-typo-en-body-sm-400" }, _hoisted_20$1 = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, _sfc_main$i = /* @__PURE__ */ defineComponent({
1604
+ __name: "ChannelPreview",
1605
+ props: {
1606
+ target: {},
1607
+ content: {},
1608
+ senderPrefix: {}
1609
+ },
1610
+ setup(e) {
1611
+ const { t: r } = useI18n(), o = e, m = computed(
1612
+ () => o.target === "PUSH" ? o.content : void 0
1613
+ ), i = computed(
1614
+ () => o.target === "APP_INBOX" ? o.content : void 0
1615
+ ), u = computed(
1616
+ () => o.target === "SMS" || o.target === "WHATSAPP" ? o.content : void 0
1617
+ ), l = computed(() => {
1618
+ var f, c;
1619
+ const y = (c = (f = u.value) == null ? void 0 : f.content) == null ? void 0 : c.trim();
1620
+ return y ? o.senderPrefix ? `${o.senderPrefix}${y}` : y : r("connect.campaign.broadcast.preview.emptyText");
1621
+ }), n = computed(() => {
1622
+ var f;
1623
+ const y = ((f = i.value) == null ? void 0 : f.content) ?? "";
1624
+ return y.trim() ? `<!doctype html><meta charset="utf-8"><base target="_blank"><style>
1625
+ html,body{margin:0;font:400 12px/1.5 Inter,system-ui,sans-serif;color:#1C1C1E;word-break:break-word}
1626
+ img{max-width:100%;height:auto}
1627
+ </style>${y}` : "";
1628
+ }), a = computed(() => {
1629
+ const y = /* @__PURE__ */ new Date(), f = y.toLocaleDateString(void 0, {
1630
+ weekday: "short",
1631
+ day: "2-digit",
1632
+ month: "short"
1633
+ }), c = y.toLocaleTimeString(void 0, {
1634
+ hour: "2-digit",
1635
+ minute: "2-digit"
1636
+ });
1637
+ return `${f} · ${c}`;
1638
+ }), s = computed(() => o.target === "PUSH" ? r("connect.campaign.broadcast.preview.note.push") : o.target === "APP_INBOX" ? r("connect.campaign.broadcast.preview.note.inbox") : r("connect.campaign.broadcast.preview.note.text"));
1639
+ return (y, f) => {
1640
+ var c, k, V, g, v, d, p, C, x, N, w;
1641
+ return e.target !== "EMAIL" ? (openBlock(), createElementBlock("div", _hoisted_1$i, [
1642
+ createElementVNode("div", _hoisted_2$f, toDisplayString(unref(r)("connect.campaign.broadcast.preview.title")), 1),
1643
+ createElementVNode("div", {
1644
+ class: normalizeClass([
1645
+ "overflow-hidden rounded-[22px] border border-fm-color-neutral-gray-100",
1646
+ e.target === "PUSH" ? "bg-fm-color-neutral-black" : "bg-fm-color-neutral-white"
1647
+ ])
1648
+ }, [
1649
+ createElementVNode("div", _hoisted_3$c, [
1650
+ createElementVNode("div", {
1651
+ class: normalizeClass([
1652
+ "h-4 w-40 rounded-full",
1653
+ e.target === "PUSH" ? "bg-fm-color-neutral-gray-400" : "bg-fm-color-neutral-gray-100"
1654
+ ])
1655
+ }, null, 2)
1656
+ ]),
1657
+ e.target === "PUSH" ? (openBlock(), createElementBlock("div", _hoisted_4$b, [
1658
+ createElementVNode("div", _hoisted_5$9, toDisplayString(unref(a)), 1),
1659
+ createElementVNode("div", _hoisted_6$6, [
1660
+ createElementVNode("div", _hoisted_7$6, toDisplayString(((k = (c = unref(m)) == null ? void 0 : c.title) == null ? void 0 : k.trim()) || unref(r)("connect.campaign.broadcast.preview.emptyTitle")), 1),
1661
+ createElementVNode("div", _hoisted_8$5, toDisplayString(((g = (V = unref(m)) == null ? void 0 : V.body) == null ? void 0 : g.trim()) || unref(r)("connect.campaign.broadcast.preview.emptyBody")), 1)
1662
+ ])
1663
+ ])) : e.target === "APP_INBOX" ? (openBlock(), createElementBlock("div", _hoisted_9$5, [
1664
+ createElementVNode("div", _hoisted_10$5, toDisplayString(unref(r)("connect.campaign.broadcast.preview.inboxHeading")), 1),
1665
+ createElementVNode("div", _hoisted_11$3, [
1666
+ createElementVNode("div", _hoisted_12$2, toDisplayString(((d = (v = unref(i)) == null ? void 0 : v.title) == null ? void 0 : d.trim()) || unref(r)("connect.campaign.broadcast.preview.emptyTitle")), 1),
1667
+ createElementVNode("div", _hoisted_13$2, toDisplayString(((C = (p = unref(i)) == null ? void 0 : p.previewText) == null ? void 0 : C.trim()) || unref(r)("connect.campaign.broadcast.preview.emptyBody")), 1),
1668
+ (x = unref(i)) != null && x.imageUrl ? (openBlock(), createElementBlock("img", {
1669
+ key: 0,
1670
+ src: unref(i).imageUrl,
1671
+ alt: "",
1672
+ class: "mt-8 w-full rounded-[8px]"
1673
+ }, null, 8, _hoisted_14$2)) : createCommentVNode("", !0),
1674
+ unref(n) ? (openBlock(), createElementBlock("iframe", {
1675
+ key: 1,
1676
+ srcdoc: unref(n),
1677
+ sandbox: "",
1678
+ referrerpolicy: "no-referrer",
1679
+ class: "mt-8 h-[120px] w-full border-0",
1680
+ title: unref(r)("connect.campaign.broadcast.preview.bodyFrameTitle")
1681
+ }, null, 8, _hoisted_15$2)) : createCommentVNode("", !0),
1682
+ (w = (N = unref(i)) == null ? void 0 : N.buttons) != null && w.length ? (openBlock(), createElementBlock("div", _hoisted_16$1, [
1683
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(i).buttons, ($, T) => (openBlock(), createElementBlock("div", {
1684
+ key: T,
1685
+ class: "rounded-[8px] bg-fm-color-primary px-12 py-8 text-center fm-typo-en-body-sm-400 text-fm-color-typo-white"
1686
+ }, toDisplayString($.label || unref(r)("connect.campaign.appInbox.buttonLabel")), 1))), 128))
1687
+ ])) : createCommentVNode("", !0)
1688
+ ])
1689
+ ])) : (openBlock(), createElementBlock("div", _hoisted_17$1, [
1690
+ createElementVNode("div", _hoisted_18$1, toDisplayString(unref(r)(`connect.campaign.broadcast.channel.${e.target}`)), 1),
1691
+ createElementVNode("div", _hoisted_19$1, toDisplayString(unref(l)), 1)
1692
+ ]))
1693
+ ], 2),
1694
+ createElementVNode("div", _hoisted_20$1, toDisplayString(unref(s)), 1)
1695
+ ])) : createCommentVNode("", !0);
1696
+ };
1697
+ }
1698
+ }), _hoisted_1$h = { class: "flex flex-col gap-12 pt-8" }, _hoisted_2$e = { class: "flex flex-wrap items-baseline justify-between gap-16" }, _hoisted_3$b = { class: "fm-typo-en-body-lg-600" }, _hoisted_4$a = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, _hoisted_5$8 = { class: "h-24 w-24 flex-none rounded-full bg-fm-color-neutral-gray-100 text-center fm-typo-en-body-sm-400 leading-[24px]" }, _hoisted_6$5 = { class: "min-w-0 flex-1" }, _hoisted_7$5 = { class: "flex flex-wrap items-center gap-[10px]" }, _hoisted_8$4 = { class: "fm-typo-en-body-md-600" }, _hoisted_9$4 = {
1699
+ key: 0,
1700
+ class: "inline-flex items-center gap-[5px] fm-typo-en-body-sm-400 text-fm-color-system-error-400"
1701
+ }, _hoisted_10$4 = { class: "ml-auto flex flex-none items-center gap-[2px] border-l border-fm-color-neutral-gray-100 pl-4" }, _hoisted_11$2 = ["title"], _hoisted_12$1 = ["title"], _hoisted_13$1 = ["title"], _hoisted_14$1 = {
1702
+ type: "button",
1703
+ class: "w-full rounded-[8px] border-2 border-dashed border-fm-color-neutral-gray-200 p-[20px] fm-typo-en-body-lg-600 text-fm-color-typo-secondary transition-colors hover:border-fm-color-primary hover:text-fm-color-primary"
1704
+ }, _hoisted_15$1 = {
1705
+ key: 1,
1706
+ class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1707
+ }, _sfc_main$h = /* @__PURE__ */ defineComponent({
1708
+ __name: "FallbackChannelList",
1709
+ props: {
1710
+ rows: {},
1711
+ addable: {}
1712
+ },
1713
+ emits: ["move", "remove", "add"],
1714
+ setup(e) {
1715
+ const { t: r } = useI18n(), o = e, m = computed(() => o.addable.length > 0);
1716
+ return (i, u) => {
1717
+ const l = resolveComponent("FmButton"), n = resolveComponent("FmMenuItem"), a = resolveComponent("FmMenu");
1718
+ return openBlock(), createElementBlock("div", _hoisted_1$h, [
1719
+ createElementVNode("div", _hoisted_2$e, [
1720
+ createElementVNode("span", _hoisted_3$b, toDisplayString(unref(r)("connect.campaign.broadcast.fallbackChannels")), 1),
1721
+ createElementVNode("span", _hoisted_4$a, toDisplayString(unref(r)("connect.campaign.broadcast.fallbackChannelsHint")), 1)
1722
+ ]),
1723
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(e.rows, (s, y) => (openBlock(), createElementBlock("div", {
1724
+ key: s.channel,
1725
+ class: "flex flex-wrap items-center gap-12 rounded-[8px] border border-fm-color-neutral-gray-100 px-16 py-[14px]"
1726
+ }, [
1727
+ createElementVNode("span", _hoisted_5$8, toDisplayString(s.position), 1),
1728
+ createElementVNode("span", _hoisted_6$5, [
1729
+ createElementVNode("span", _hoisted_7$5, [
1730
+ createElementVNode("span", _hoisted_8$4, toDisplayString(s.label), 1),
1731
+ s.complete ? createCommentVNode("", !0) : (openBlock(), createElementBlock("span", _hoisted_9$4, [
1732
+ u[0] || (u[0] = createElementVNode("span", { class: "h-[6px] w-[6px] rounded-full bg-fm-color-system-error-400" }, null, -1)),
1733
+ createTextVNode(" " + toDisplayString(unref(r)("connect.campaign.broadcast.messageMissing")), 1)
1734
+ ]))
1735
+ ])
1736
+ ]),
1737
+ createElementVNode("span", _hoisted_10$4, [
1738
+ createElementVNode("span", {
1739
+ title: unref(r)("connect.campaign.broadcast.moveUp"),
1740
+ class: "flex"
1741
+ }, [
1742
+ createVNode(l, {
1743
+ icon: "arrow_upward",
1744
+ "icon-color": "neutral-gray-400",
1745
+ variant: "tertiary",
1746
+ disabled: y === 0,
1747
+ onClick: (f) => i.$emit("move", s.channel, -1)
1748
+ }, null, 8, ["disabled", "onClick"])
1749
+ ], 8, _hoisted_11$2),
1750
+ createElementVNode("span", {
1751
+ title: unref(r)("connect.campaign.broadcast.moveDown"),
1752
+ class: "flex"
1753
+ }, [
1754
+ createVNode(l, {
1755
+ icon: "arrow_downward",
1756
+ "icon-color": "neutral-gray-400",
1757
+ variant: "tertiary",
1758
+ disabled: y === e.rows.length - 1,
1759
+ onClick: (f) => i.$emit("move", s.channel, 1)
1760
+ }, null, 8, ["disabled", "onClick"])
1761
+ ], 8, _hoisted_12$1),
1762
+ createElementVNode("span", {
1763
+ title: unref(r)("connect.campaign.broadcast.removeChannel"),
1764
+ class: "flex"
1765
+ }, [
1766
+ createVNode(l, {
1767
+ icon: "delete",
1768
+ "icon-color": "neutral-gray-400",
1769
+ variant: "tertiary",
1770
+ onClick: (f) => i.$emit("remove", s.channel)
1771
+ }, null, 8, ["onClick"])
1772
+ ], 8, _hoisted_13$1)
1773
+ ])
1774
+ ]))), 128)),
1775
+ unref(m) ? (openBlock(), createBlock(a, {
1776
+ key: 0,
1777
+ placement: "bottom-start"
1778
+ }, {
1779
+ "menu-button": withCtx(() => [
1780
+ createElementVNode("button", _hoisted_14$1, " + " + toDisplayString(unref(r)("connect.campaign.broadcast.addFallbackChannel")), 1)
1781
+ ]),
1782
+ default: withCtx(() => [
1783
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(e.addable, (s) => (openBlock(), createBlock(n, {
1784
+ key: s.channel,
1785
+ label: s.label,
1786
+ onClick: (y) => i.$emit("add", s.channel)
1787
+ }, null, 8, ["label", "onClick"]))), 128))
1788
+ ]),
1789
+ _: 1
1790
+ })) : (openBlock(), createElementBlock("div", _hoisted_15$1, toDisplayString(unref(r)("connect.campaign.broadcast.allChannelsAdded")), 1))
1791
+ ]);
1792
+ };
1793
+ }
1794
+ });
1795
+ var define_appEndpoint_default = { authUrl: "https://portal-v2-dev.feedmeapi.com/", slackWebhookUrl: "https://hooks.slack.com/services/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", appUrl: "feedmedev.vip", crmUrl: "crm.feedmedev.cc", paymentPortalUrl: "https://portal.feedmedev.cc/payment/payout-account", licensePortalUrl: "https://license.feedmedev.cc/", marketingV1Portal: "https://marketing-v1.feedmedev.cc", voucherAppUrl: "https://voucher.feedmedev.cc/" };
1796
+ const _hoisted_1$g = { class: "flex flex-col gap-[28px]" }, _hoisted_2$d = { class: "flex flex-col gap-[14px]" }, _hoisted_3$a = { class: "fm-typo-en-body-lg-600" }, _hoisted_4$9 = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _hoisted_5$7 = { class: "grid gap-12 md:grid-cols-2 lg:grid-cols-2" }, _hoisted_6$4 = { class: "flex items-start justify-between gap-12" }, _hoisted_7$4 = { class: "fm-typo-en-title-sm-800" }, _hoisted_8$3 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_9$3 = {
1797
+ key: 0,
1798
+ class: "flex items-start gap-8 fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1799
+ }, _hoisted_10$3 = { class: "flex flex-col gap-12" }, _hoisted_11$1 = { class: "fm-typo-en-body-lg-600" }, _hoisted_12 = { class: "grid items-stretch gap-12 sm:grid-cols-2 md:grid-cols-4 lg:grid-cols-4" }, _hoisted_13 = { class: "flex items-start justify-between gap-12" }, _hoisted_14 = {
1800
+ key: 1,
1801
+ class: "h-[8px] w-[8px] rounded-full bg-fm-color-neutral-white"
1802
+ }, _hoisted_15 = {
1803
+ key: 0,
1804
+ class: "mt-[3px] fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1805
+ }, _hoisted_16 = {
1806
+ key: 1,
1807
+ class: "mt-[6px] inline-flex rounded-[6px] bg-fm-color-system-warning-100 px-8 py-[3px] fm-typo-en-body-sm-400 text-fm-color-system-warning-400"
1808
+ }, _hoisted_17 = {
1809
+ key: 2,
1810
+ class: "mt-[6px] inline-flex rounded-[6px] bg-fm-color-neutral-gray-100 px-8 py-[3px] fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1811
+ }, _hoisted_18 = {
1812
+ key: 0,
1813
+ class: "fm-typo-en-body-sm-400 text-fm-color-system-warning-400"
1814
+ }, _hoisted_19 = {
1815
+ key: 1,
1816
+ class: "fm-typo-en-body-sm-400 text-fm-color-system-error-400"
1817
+ }, _hoisted_20 = { class: "flex flex-col gap-[14px]" }, _hoisted_21 = { class: "fm-typo-en-body-lg-600" }, _hoisted_22 = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _hoisted_23 = {
1818
+ key: 1,
1819
+ class: "rounded-[8px] border border-dashed border-fm-color-neutral-gray-200 p-24 text-center fm-typo-en-body-md-400 text-fm-color-typo-secondary"
1820
+ }, _hoisted_24 = {
1821
+ key: 3,
1822
+ class: "flex flex-wrap items-start gap-24"
1823
+ }, _hoisted_25 = { class: "min-w-0 flex-1 basis-[340px]" }, _hoisted_26 = {
1824
+ key: 1,
1825
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
1826
+ }, _sfc_main$g = /* @__PURE__ */ defineComponent({
1827
+ __name: "BroadcastDeliveryInput",
1828
+ props: {
1829
+ pushAvailability: {
1830
+ type: String,
1831
+ default: "checking"
1832
+ },
1833
+ /** Either the new delivery shape or a legacy single-channel message. */
1834
+ modelValue: {
1835
+ type: Object,
1836
+ default: void 0
1837
+ },
1838
+ triggerType: {
1839
+ type: String,
1840
+ default: () => "SCHEDULE"
1841
+ },
1842
+ variables: {
1843
+ type: Object,
1844
+ default: () => [...DEFAULT_MESSAGE_VARIABLES]
1845
+ },
1846
+ helperText: { type: String },
1847
+ /**
1848
+ * False until the merchant tries to proceed. Broadcasts validate on submit,
1849
+ * so incomplete-channel markers stay hidden while the form is being filled.
1850
+ */
1851
+ showValidation: { type: Boolean, default: !0 },
1852
+ helperState: { type: String },
1853
+ placeholder: { type: String }
1854
+ },
1855
+ emits: ["retry-push", "update:model-value"],
1856
+ setup(e, { emit: r }) {
1857
+ const { t: o } = useI18n(), m = useDialog(), i = computed(
1858
+ () => o(
1859
+ "connect.campaign.broadcast.pushAvailability." + (a.pushAvailability === "checking" ? "checking" : a.pushAvailability === "non-native" ? "requiresNativeApp" : "unavailable")
1860
+ )
1861
+ );
1862
+ function u() {
1863
+ m.open({
1864
+ title: o("connect.campaign.broadcast.pushAvailability.contactSales"),
1865
+ message: o("connect.campaign.broadcast.pushAvailability.dialogMessage"),
1866
+ primaryActions: {
1867
+ text: o("connect.campaign.broadcast.pushAvailability.close"),
1868
+ close: !0
1869
+ }
1870
+ });
1871
+ }
1872
+ const l = useCoreStore(), n = useMembershipStore(), a = e, s = r, y = ref(!1), f = ref("SMS"), c = computed(() => {
1873
+ const h = a.modelValue;
1874
+ return h && "channels" in h ? h : toDelivery({ message: h });
1875
+ });
1876
+ function k(h) {
1877
+ s("update:model-value", h);
1878
+ }
1879
+ function V(h) {
1880
+ return o(`connect.campaign.broadcast.channel.${h}`);
1881
+ }
1882
+ const g = {
1883
+ SMS: "chat",
1884
+ WHATSAPP: "chat",
1885
+ EMAIL: "mail",
1886
+ APP_INBOX: "inbox",
1887
+ PUSH: "notifications"
1888
+ };
1889
+ function v(h) {
1890
+ return g[h];
1891
+ }
1892
+ const d = computed(() => c.value.mode === "fallback"), p = computed(
1893
+ () => a.variables.filter(
1894
+ (h) => a.triggerType == "SCHEDULE" ? !h.startsWith("transaction.") : !0
1895
+ )
1896
+ );
1897
+ function C(h) {
1898
+ return h === "PUSH" ? a.pushAvailability === "native" : h === "WHATSAPP" ? y.value : !0;
1899
+ }
1900
+ const x = ["fallback", "all"];
1901
+ function N(h) {
1902
+ h !== c.value.mode && k(setMode(c.value, h));
1903
+ }
1904
+ const w = ref(null);
1905
+ function $(h) {
1906
+ var D;
1907
+ const B = (D = w.value) == null ? void 0 : D[h];
1908
+ return B ? new Intl.NumberFormat(void 0, {
1909
+ style: "currency",
1910
+ currency: B.currency,
1911
+ minimumFractionDigits: B.precision,
1912
+ maximumFractionDigits: B.precision
1913
+ }).format(B.amount / 10 ** B.precision) : null;
1914
+ }
1915
+ const T = computed(
1916
+ () => CHANNEL_DISPLAY_ORDER.map((h) => {
1917
+ const B = c.value.channels.includes(h), D = $(h);
1918
+ return {
1919
+ channel: h,
1920
+ label: V(h),
1921
+ selected: B,
1922
+ available: C(h),
1923
+ rateNote: isPaidChannel(h) ? D ? o("connect.campaign.broadcast.perMessage", { price: D }) : null : o("connect.campaign.broadcast.freeChannel"),
1924
+ // In fallback mode the grid is a radio for the primary channel, so only
1925
+ // the primary reads as checked; a fallback is tagged instead.
1926
+ checked: d.value ? c.value.channels[0] === h : B,
1927
+ usedAsFallback: d.value && c.value.channels.indexOf(h) > 0
1928
+ };
1929
+ })
1930
+ );
1931
+ async function R(h) {
1932
+ if (C(h)) {
1933
+ if (d.value) {
1934
+ await A(h);
1935
+ return;
1936
+ }
1937
+ if (c.value.channels.includes(h)) {
1938
+ await M(h);
1939
+ return;
1940
+ }
1941
+ k(addChannel(c.value, h, p.value));
1942
+ }
1943
+ }
1944
+ async function A(h) {
1945
+ if (!C(h)) return;
1946
+ const B = c.value.channels[0];
1947
+ B !== h && (B && hasDraft(c.value, B) && !await prompt.remove(
1948
+ o("connect.campaign.broadcast.replaceChannelConfirm", {
1949
+ channel: V(B),
1950
+ next: V(h)
1951
+ })
1952
+ ) || C(h) && (k(setPrimaryChannel(c.value, h, p.value)), f.value = h));
1953
+ }
1954
+ async function M(h) {
1955
+ if (hasDraft(c.value, h) && !await prompt.remove(
1956
+ o("connect.campaign.broadcast.removeChannelConfirm", {
1957
+ channel: V(h)
1958
+ })
1959
+ ))
1960
+ return;
1961
+ const B = removeChannel(c.value, h);
1962
+ k(B), f.value === h && (f.value = B.channels[0] ?? "SMS");
1963
+ }
1964
+ function I(h, B) {
1965
+ k(moveChannel(c.value, h, B));
1966
+ }
1967
+ function X(h) {
1968
+ C(h) && k(addChannel(c.value, h, p.value));
1969
+ }
1970
+ const K = computed(
1971
+ () => c.value.channels.slice(1).map((h, B) => ({
1972
+ channel: h,
1973
+ label: V(h),
1974
+ position: B + 2,
1975
+ complete: !a.showValidation || isChannelComplete(c.value, h)
1976
+ }))
1977
+ ), Z = computed(
1978
+ () => CHANNEL_DISPLAY_ORDER.filter(
1979
+ (h) => !c.value.channels.includes(h) && C(h)
1980
+ ).map((h) => ({
1981
+ channel: h,
1982
+ label: V(h)
1983
+ }))
1984
+ ), W = computed(
1985
+ () => c.value.channels.map((h, B) => ({
1986
+ key: h,
1987
+ label: V(h),
1988
+ sub: d.value ? o(B === 0 ? "connect.campaign.broadcast.tab.firstAttempt" : "connect.campaign.broadcast.tab.ifNotReached") : o("connect.campaign.broadcast.tab.sendsToEligible"),
1989
+ complete: !a.showValidation || isChannelComplete(c.value, h),
1990
+ step: d.value ? B + 1 : void 0,
1991
+ connector: B === 0 ? void 0 : d.value ? "→" : "+"
1992
+ }))
1993
+ );
1994
+ watchEffect(() => {
1995
+ const h = W.value.map((B) => B.key);
1996
+ h.length && !h.includes(f.value) && (f.value = h[0]);
1997
+ });
1998
+ const Y = computed(() => f.value), b = computed(() => {
1999
+ const h = Y.value;
2000
+ if (!(h === "APP_INBOX" || h === "PUSH"))
2001
+ return c.value.content[h];
2002
+ }), E = computed(
2003
+ () => c.value.content.APP_INBOX
2004
+ ), F = computed(
2005
+ () => c.value.content.PUSH
2006
+ );
2007
+ function U(h) {
2008
+ k(setChannelContent(c.value, "APP_INBOX", h));
2009
+ }
2010
+ function O(h) {
2011
+ C("PUSH") && k(setChannelContent(c.value, "PUSH", h));
2012
+ }
2013
+ function P(h, B) {
2014
+ h === "APP_INBOX" || h === "PUSH" || k(setChannelContent(c.value, h, { ...B, channel: h }));
2015
+ }
2016
+ const H = computed(
2017
+ () => c.value.channels.filter(isPaidChannel)
2018
+ ), L = computed(() => {
2019
+ var B, D, q;
2020
+ const h = ((B = n.membership) == null ? void 0 : B.brand) || ((q = (D = l.currentBusiness) == null ? void 0 : D.value) == null ? void 0 : q.name) || "";
2021
+ return getSmsMessageMetrics({ brandName: h, content: "" }).prefix;
2022
+ }), j = `${define_appEndpoint_default.licensePortalUrl}settings?businessId=${SvcConfig.businessId}`;
2023
+ async function G() {
2024
+ try {
2025
+ const h = await membershipApi.getWhatsappNumbers();
2026
+ y.value = h.some(
2027
+ (B) => {
2028
+ var D;
2029
+ return (D = B == null ? void 0 : B.default) == null ? void 0 : D.includes("Marketing");
2030
+ }
2031
+ );
2032
+ } catch (h) {
2033
+ console.error("Failed to fetch WhatsApp numbers:", h);
2034
+ }
2035
+ }
2036
+ return onMounted(async () => {
2037
+ const h = c.value.channels[0];
2038
+ h && (f.value = h), campaignApi.readBroadcastCreditSummary().then((B) => w.value = B.prices).catch(() => w.value = null), await G();
2039
+ }), (h, B) => {
2040
+ const D = resolveComponent("FmIcon"), q = resolveComponent("FmCard"), J = resolveComponent("FmButton");
2041
+ return openBlock(), createElementBlock("div", _hoisted_1$g, [
2042
+ createElementVNode("div", _hoisted_2$d, [
2043
+ createElementVNode("div", null, [
2044
+ createElementVNode("div", _hoisted_3$a, toDisplayString(unref(o)("connect.campaign.broadcast.delivery")), 1),
2045
+ createElementVNode("div", _hoisted_4$9, toDisplayString(unref(o)("connect.campaign.broadcast.deliveryDescription")), 1)
2046
+ ]),
2047
+ createElementVNode("div", _hoisted_5$7, [
2048
+ (openBlock(), createElementBlock(Fragment, null, renderList(x, (S) => createVNode(q, {
2049
+ key: S,
2050
+ variant: "outlined",
2051
+ class: normalizeClass(["h-full cursor-pointer select-none p-16 space-y-8", {
2052
+ "border-fm-color-primary bg-fm-color-system-warning-100": unref(c).mode === S,
2053
+ "hover:bg-fm-color-opacity-sm": unref(c).mode !== S
2054
+ }]),
2055
+ onClick: (Q) => N(S)
2056
+ }, {
2057
+ default: withCtx(() => [
2058
+ createElementVNode("div", _hoisted_6$4, [
2059
+ createElementVNode("div", _hoisted_7$4, toDisplayString(unref(o)(`connect.campaign.broadcast.mode.${S}.label`)), 1),
2060
+ unref(c).mode === S ? (openBlock(), createBlock(D, {
2061
+ key: 0,
2062
+ name: "check_circle",
2063
+ size: "md",
2064
+ class: "shrink-0 text-fm-color-primary"
2065
+ })) : createCommentVNode("", !0)
2066
+ ]),
2067
+ createElementVNode("div", _hoisted_8$3, toDisplayString(unref(o)(`connect.campaign.broadcast.mode.${S}.description`)), 1)
2068
+ ]),
2069
+ _: 2
2070
+ }, 1032, ["class", "onClick"])), 64))
2071
+ ]),
2072
+ unref(c).channels.length < 2 ? (openBlock(), createElementBlock("div", _hoisted_9$3, [
2073
+ createVNode(D, {
2074
+ name: "info",
2075
+ size: "sm",
2076
+ class: "mt-[2px]"
2077
+ }),
2078
+ createElementVNode("span", null, toDisplayString(unref(o)("connect.campaign.broadcast.singleChannelNote")), 1)
2079
+ ])) : createCommentVNode("", !0)
2080
+ ]),
2081
+ createElementVNode("div", _hoisted_10$3, [
2082
+ createElementVNode("div", _hoisted_11$1, toDisplayString(unref(d) ? unref(o)("connect.campaign.broadcast.primaryChannel") : unref(o)("connect.campaign.broadcast.channels")), 1),
2083
+ createElementVNode("div", _hoisted_12, [
2084
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(T), (S) => (openBlock(), createBlock(q, {
2085
+ key: S.channel,
2086
+ variant: "outlined",
2087
+ class: normalizeClass(["flex h-full flex-col gap-12 p-16", [
2088
+ S.checked ? "!border-fm-color-primary bg-fm-color-system-warning-100" : "",
2089
+ S.available ? "cursor-pointer" : "cursor-not-allowed bg-fm-color-neutral-gray-100"
2090
+ ]]),
2091
+ "aria-disabled": S.channel === "PUSH" ? void 0 : !S.available,
2092
+ onClick: (Q) => R(S.channel)
2093
+ }, {
2094
+ default: withCtx(() => [
2095
+ createElementVNode("div", _hoisted_13, [
2096
+ createElementVNode("span", {
2097
+ class: normalizeClass([
2098
+ "flex h-[34px] w-[34px] flex-none items-center justify-center rounded-[8px]",
2099
+ S.available ? "bg-fm-color-primary-oats text-fm-color-primary" : "bg-fm-color-neutral-gray-200 text-fm-color-neutral-gray-400"
2100
+ ])
2101
+ }, [
2102
+ createVNode(D, {
2103
+ name: v(S.channel),
2104
+ size: "md"
2105
+ }, null, 8, ["name"])
2106
+ ], 2),
2107
+ S.available ? (openBlock(), createElementBlock("span", {
2108
+ key: 0,
2109
+ class: normalizeClass(["flex h-[22px] w-[22px] flex-none items-center justify-center border-2 transition-colors", [
2110
+ unref(d) ? "rounded-full" : "rounded-[4px]",
2111
+ S.checked ? "border-fm-color-primary bg-fm-color-primary text-fm-color-typo-white" : "border-fm-color-neutral-gray-300 bg-fm-color-neutral-white"
2112
+ ]])
2113
+ }, [
2114
+ S.checked && !unref(d) ? (openBlock(), createBlock(D, {
2115
+ key: 0,
2116
+ name: "check",
2117
+ size: "sm"
2118
+ })) : S.checked ? (openBlock(), createElementBlock("span", _hoisted_14)) : createCommentVNode("", !0)
2119
+ ], 2)) : createCommentVNode("", !0)
2120
+ ]),
2121
+ createElementVNode("div", null, [
2122
+ createElementVNode("div", {
2123
+ class: normalizeClass(["fm-typo-en-body-md-600", S.available ? "" : "text-fm-color-typo-disabled"])
2124
+ }, toDisplayString(S.label), 3),
2125
+ S.available && S.rateNote ? (openBlock(), createElementBlock("div", _hoisted_15, toDisplayString(S.rateNote), 1)) : createCommentVNode("", !0),
2126
+ S.available ? S.usedAsFallback ? (openBlock(), createElementBlock("div", _hoisted_17, toDisplayString(unref(o)("connect.campaign.broadcast.usedAsFallback")), 1)) : createCommentVNode("", !0) : (openBlock(), createElementBlock("div", _hoisted_16, toDisplayString(S.channel === "PUSH" ? unref(i) : unref(o)("connect.campaign.broadcast.notSetUp")), 1))
2127
+ ]),
2128
+ S.channel === "WHATSAPP" && !S.available ? (openBlock(), createElementBlock("a", {
2129
+ key: 0,
2130
+ href: j,
2131
+ target: "_blank",
2132
+ class: "mt-auto fm-typo-en-body-sm-400 text-fm-color-secondary-blueberry underline",
2133
+ onClick: B[0] || (B[0] = withModifiers(() => {
2134
+ }, ["stop"]))
2135
+ }, toDisplayString(unref(o)("connect.campaign.messageInput.manageWhatsappChannel")), 1)) : createCommentVNode("", !0),
2136
+ S.channel === "PUSH" && !S.available ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
2137
+ e.pushAvailability === "non-native" ? (openBlock(), createBlock(J, {
2138
+ key: 0,
2139
+ label: unref(o)("connect.campaign.broadcast.pushAvailability.contactSales"),
2140
+ onClick: withModifiers(u, ["stop"])
2141
+ }, null, 8, ["label"])) : createCommentVNode("", !0),
2142
+ e.pushAvailability === "failed" ? (openBlock(), createBlock(J, {
2143
+ key: 1,
2144
+ label: unref(o)("connect.campaign.broadcast.pushAvailability.retry"),
2145
+ onClick: B[1] || (B[1] = withModifiers((Q) => s("retry-push"), ["stop"]))
2146
+ }, null, 8, ["label"])) : createCommentVNode("", !0),
2147
+ S.selected ? (openBlock(), createBlock(J, {
2148
+ key: 2,
2149
+ label: unref(o)("connect.campaign.broadcast.pushAvailability.removePush"),
2150
+ onClick: B[2] || (B[2] = withModifiers((Q) => M("PUSH"), ["stop"]))
2151
+ }, null, 8, ["label"])) : createCommentVNode("", !0)
2152
+ ], 64)) : createCommentVNode("", !0)
2153
+ ]),
2154
+ _: 2
2155
+ }, 1032, ["class", "aria-disabled", "onClick"]))), 128))
2156
+ ]),
2157
+ unref(c).channels.includes("PUSH") && !C("PUSH") ? (openBlock(), createElementBlock("div", _hoisted_18, toDisplayString(unref(o)("connect.campaign.broadcast.pushAvailability.removeBeforeSave")), 1)) : createCommentVNode("", !0),
2158
+ e.showValidation && !unref(c).channels.length ? (openBlock(), createElementBlock("div", _hoisted_19, toDisplayString(unref(o)("connect.campaign.broadcast.selectChannelRequired")), 1)) : createCommentVNode("", !0),
2159
+ unref(d) && unref(c).channels.length ? (openBlock(), createBlock(_sfc_main$h, {
2160
+ key: 2,
2161
+ rows: unref(K),
2162
+ addable: unref(Z),
2163
+ onMove: I,
2164
+ onRemove: M,
2165
+ onAdd: X
2166
+ }, null, 8, ["rows", "addable"])) : createCommentVNode("", !0)
2167
+ ]),
2168
+ createElementVNode("div", _hoisted_20, [
2169
+ createElementVNode("div", null, [
2170
+ createElementVNode("div", _hoisted_21, toDisplayString(unref(o)("connect.campaign.broadcast.content")), 1),
2171
+ createElementVNode("div", _hoisted_22, toDisplayString(unref(o)("connect.campaign.broadcast.contentDescription")), 1)
2172
+ ]),
2173
+ unref(H).length ? (openBlock(), createBlock(_sfc_main$w, {
2174
+ key: 0,
2175
+ channels: unref(H)
2176
+ }, null, 8, ["channels"])) : createCommentVNode("", !0),
2177
+ unref(c).channels.length ? createCommentVNode("", !0) : (openBlock(), createElementBlock("div", _hoisted_23, toDisplayString(unref(o)("connect.campaign.broadcast.noChannelContent")), 1)),
2178
+ unref(c).channels.length ? (openBlock(), createBlock(_sfc_main$j, {
2179
+ key: 2,
2180
+ modelValue: unref(f),
2181
+ "onUpdate:modelValue": B[3] || (B[3] = (S) => isRef(f) ? f.value = S : null),
2182
+ tabs: unref(W)
2183
+ }, null, 8, ["modelValue", "tabs"])) : createCommentVNode("", !0),
2184
+ unref(c).channels.includes(unref(f)) ? (openBlock(), createElementBlock("div", _hoisted_24, [
2185
+ createElementVNode("div", _hoisted_25, [
2186
+ unref(f) === "PUSH" && unref(F) && C("PUSH") ? (openBlock(), createBlock(_sfc_main$k, {
2187
+ key: 0,
2188
+ "model-value": unref(F),
2189
+ "show-validation": e.showValidation,
2190
+ "onUpdate:modelValue": O
2191
+ }, null, 8, ["model-value", "show-validation"])) : unref(f) === "PUSH" ? (openBlock(), createElementBlock("div", _hoisted_26, toDisplayString(unref(i)), 1)) : unref(f) === "APP_INBOX" && unref(E) ? (openBlock(), createBlock(_sfc_main$l, {
2192
+ key: 2,
2193
+ "model-value": unref(E),
2194
+ variables: unref(p),
2195
+ "show-validation": e.showValidation,
2196
+ "onUpdate:modelValue": U
2197
+ }, null, 8, ["model-value", "variables", "show-validation"])) : unref(f) !== "APP_INBOX" ? (openBlock(), createBlock(_sfc_main$x, {
2198
+ key: unref(f),
2199
+ "model-value": unref(b),
2200
+ "allow-email": !1,
2201
+ "allow-whatsapp": !1,
2202
+ "hide-credit-card": !0,
2203
+ "trigger-type": e.triggerType,
2204
+ variables: unref(p),
2205
+ placeholder: e.placeholder,
2206
+ "onUpdate:modelValue": B[4] || (B[4] = (S) => P(unref(Y), S))
2207
+ }, null, 8, ["model-value", "trigger-type", "variables", "placeholder"])) : createCommentVNode("", !0)
2208
+ ]),
2209
+ createVNode(_sfc_main$i, {
2210
+ target: unref(f),
2211
+ content: unref(c).content[unref(Y)],
2212
+ "sender-prefix": unref(L)
2213
+ }, null, 8, ["target", "content", "sender-prefix"])
2214
+ ])) : createCommentVNode("", !0)
2215
+ ])
2216
+ ]);
2217
+ };
2218
+ }
2219
+ }), _hoisted_1$f = { class: "space-y-8" }, _hoisted_2$c = { class: "grid grid-cols-2 gap-16" }, _hoisted_3$9 = {
2220
+ key: 0,
2221
+ class: "space-y-4"
2222
+ }, _hoisted_4$8 = { class: "fm-typo-en-body-lg-400 class flex items-center justify-between" }, _hoisted_5$6 = { class: "text-ellipsis line-clamp-1" }, _sfc_main$f = /* @__PURE__ */ defineComponent({
2223
+ __name: "ScheduleRuleInput",
2224
+ props: {
2225
+ modelValue: {
2226
+ type: Object,
2227
+ required: !0
2228
+ },
2229
+ startDate: {
2230
+ type: String
2231
+ },
2232
+ endDate: {
2233
+ type: String
2234
+ }
2235
+ },
2236
+ emits: ["update:model-value"],
2237
+ setup(e, { emit: r }) {
2238
+ const { t: o } = useI18n(), m = e, i = r, u = useCoreStore(), l = computed(
2239
+ () => CountryTimezone[u.currentCountry.value || "MY"]
2240
+ );
2241
+ function n() {
2242
+ const d = RuleBuilder.getRules(m.modelValue);
2243
+ return d.length == 0 ? "fixed" : d.some(
2244
+ (p) => isRuleEntry(p) && RuleBuilder.simplify(p).operator == "_rrule"
2245
+ ) ? "repeating" : "fixed";
2246
+ }
2247
+ const a = ref(n()), s = ref(!1), y = ref(!1), f = computed(() => [
2248
+ { label: o("connect.template.rule.schedule.fixed"), value: "fixed" },
2249
+ { label: o("connect.template.rule.schedule.repeating"), value: "repeating" }
2250
+ ]), c = computed(() => {
2251
+ const d = RuleBuilder.getRules(m.modelValue), p = d.find(
2252
+ (x) => isRuleEntry(x) && RuleBuilder.simplify(x).property == "trigger.date"
2253
+ ), C = d.find(
2254
+ (x) => isRuleEntry(x) && RuleBuilder.simplify(x).property == "trigger.time"
2255
+ );
2256
+ return {
2257
+ date: p ? RuleBuilder.simplify(p).equator : null,
2258
+ time: C ? RuleBuilder.simplify(C).equator : null
2259
+ };
2260
+ }), k = computed(
2261
+ () => calculateNextScheduleAt(
2262
+ m.modelValue,
2263
+ /* @__PURE__ */ new Date(),
2264
+ m.startDate ? new Date(m.startDate) : /* @__PURE__ */ new Date(),
2265
+ m.endDate ? new Date(m.endDate) : void 0
2266
+ )
2267
+ );
2268
+ function V(d, p) {
2269
+ i(
2270
+ "update:model-value",
2271
+ RuleBuilder.setRuleToGroup(RuleBuilder.scaffoldGroup("g_schedule"), [
2272
+ RuleBuilder.constructEntry("trigger.date", "_rrule", d),
2273
+ RuleBuilder.constructEntry("trigger.time", "_isOnTime", p ?? "00:00")
2274
+ ])
2275
+ );
2276
+ }
2277
+ watch(
2278
+ () => m.startDate,
2279
+ (d, p) => {
2280
+ if (!d || d === p || a.value !== "repeating" || !c.value.date) return;
2281
+ const C = RRule.fromString(c.value.date), x = new RRule({
2282
+ ...C.origOptions,
2283
+ dtstart: new Date(d)
2284
+ }).toString();
2285
+ x !== c.value.date && (V(x, c.value.time), y.value = !0);
2286
+ }
2287
+ );
2288
+ function g(d) {
2289
+ const p = d.value, C = getRruleAnchorDate({
2290
+ startDate: m.startDate ? new Date(m.startDate) : void 0
2291
+ }), x = p == "fixed" ? [
2292
+ RuleBuilder.constructEntry(
2293
+ "trigger.date",
2294
+ "_isOnDate",
2295
+ (/* @__PURE__ */ new Date()).toISOString()
2296
+ ),
2297
+ RuleBuilder.constructEntry("trigger.time", "_isOnTime", "00:00")
2298
+ ] : [
2299
+ RuleBuilder.constructEntry(
2300
+ "trigger.date",
2301
+ "_rrule",
2302
+ new RRule({
2303
+ dtstart: C,
2304
+ freq: RRule.DAILY,
2305
+ interval: 1,
2306
+ byhour: 0,
2307
+ byminute: 0,
2308
+ bysecond: 0,
2309
+ wkst: RRule.SU
2310
+ }).toString()
2311
+ ),
2312
+ RuleBuilder.constructEntry("trigger.time", "_isOnTime", "00:00")
2313
+ ];
2314
+ i(
2315
+ "update:model-value",
2316
+ RuleBuilder.setRuleToGroup(
2317
+ RuleBuilder.scaffoldGroup("g_schedule"),
2318
+ x
2319
+ )
2320
+ ), a.value = p, y.value = !1;
2321
+ }
2322
+ function v(d) {
2323
+ a.value == "fixed" ? i(
2324
+ "update:model-value",
2325
+ RuleBuilder.setRuleToGroup(RuleBuilder.scaffoldGroup("g_schedule"), [
2326
+ RuleBuilder.constructEntry(
2327
+ "trigger.date",
2328
+ "_isOnDate",
2329
+ d.date
2330
+ ),
2331
+ RuleBuilder.constructEntry(
2332
+ "trigger.time",
2333
+ "_isOnTime",
2334
+ d.time
2335
+ )
2336
+ ])
2337
+ ) : V(d.date, d.time), y.value = !1;
2338
+ }
2339
+ return (d, p) => {
2340
+ const C = resolveComponent("FmButtonGroup"), x = resolveComponent("FmTimePicker"), N = resolveComponent("FmIcon"), w = resolveComponent("FmTooltip"), $ = resolveComponent("FmField"), T = resolveComponent("FmCard"), R = resolveComponent("FmPopover"), A = resolveComponent("FmDatePicker"), M = resolveComponent("FmHelperText");
2341
+ return openBlock(), createElementBlock(Fragment, null, [
2342
+ createVNode(C, {
2343
+ items: unref(f),
2344
+ "model-value": unref(f).find((I) => I.value === unref(a)) ?? null,
2345
+ "onUpdate:modelValue": g,
2346
+ class: "mb-8"
2347
+ }, null, 8, ["items", "model-value"]),
2348
+ createElementVNode("div", _hoisted_1$f, [
2349
+ createElementVNode("div", _hoisted_2$c, [
2350
+ createVNode(x, {
2351
+ label: unref(o)("connect.template.rule.schedule.notify_time"),
2352
+ "model-value": unref(c).time,
2353
+ "onUpdate:modelValue": p[0] || (p[0] = (I) => v({ date: unref(c).date, time: I })),
2354
+ "helper-text": unref(c).time ? void 0 : unref(o)("connect.template.rule.schedule.time_required"),
2355
+ "helper-state": unref(c).time ? void 0 : "error"
2356
+ }, null, 8, ["label", "model-value", "helper-text", "helper-state"]),
2357
+ unref(a) == "repeating" ? (openBlock(), createElementBlock("div", _hoisted_3$9, [
2358
+ createElementVNode("div", _hoisted_4$8, [
2359
+ createElementVNode("div", null, toDisplayString(unref(o)("connect.template.rule.schedule.notify_date")), 1),
2360
+ unref(c).date ? (openBlock(), createBlock(w, {
2361
+ key: 0,
2362
+ "z-index": 9999,
2363
+ content: unref(SummarizeRrule)(unref(RRule).fromString(unref(c).date).options)
2364
+ }, {
2365
+ default: withCtx(() => [
2366
+ createVNode(N, {
2367
+ name: "info",
2368
+ size: "sm",
2369
+ outline: !0
2370
+ })
2371
+ ]),
2372
+ _: 1
2373
+ }, 8, ["content"])) : createCommentVNode("", !0)
2374
+ ]),
2375
+ createVNode(R, {
2376
+ "show-popover": unref(s),
2377
+ onPopoverChanged: p[3] || (p[3] = (I) => s.value = I)
2378
+ }, {
2379
+ "popover-button": withCtx(() => [
2380
+ createVNode($, {
2381
+ class: "cursor-pointer",
2382
+ "helper-text": unref(c).date ? void 0 : unref(o)("connect.template.rule.schedule.date_required"),
2383
+ "helper-state": unref(c).date ? void 0 : "error"
2384
+ }, {
2385
+ default: withCtx(() => [
2386
+ createElementVNode("div", _hoisted_5$6, toDisplayString(unref(c).date ? unref(SummarizeRrule)(unref(RRule).fromString(unref(c).date).options) : unref(o)("connect.template.rule.schedule.set_repeating_date")), 1)
2387
+ ]),
2388
+ _: 1
2389
+ }, 8, ["helper-text", "helper-state"])
2390
+ ]),
2391
+ default: withCtx(() => [
2392
+ createVNode(T, { class: "elevated p-8 w-[450px]" }, {
2393
+ default: withCtx(() => [
2394
+ createVNode(_sfc_main$y, {
2395
+ "apply-button": !0,
2396
+ "model-value": unref(c).date || "",
2397
+ "start-date": e.startDate ? new Date(e.startDate) : /* @__PURE__ */ new Date(),
2398
+ onCancel: p[1] || (p[1] = (I) => s.value = !1),
2399
+ "onUpdate:modelValue": p[2] || (p[2] = (I) => (v({ date: I, time: unref(c).time }), s.value = !1))
2400
+ }, null, 8, ["model-value", "start-date"])
2401
+ ]),
2402
+ _: 1
2403
+ })
2404
+ ]),
2405
+ _: 1
2406
+ }, 8, ["show-popover"])
2407
+ ])) : (openBlock(), createBlock(A, {
2408
+ key: 1,
2409
+ label: unref(o)("connect.template.rule.schedule.notify_date"),
2410
+ "model-value": unref(c).date || "",
2411
+ "onUpdate:modelValue": p[4] || (p[4] = (I) => v({ date: I, time: unref(c).time })),
2412
+ "helper-text": unref(c).date ? void 0 : unref(o)("connect.template.rule.schedule.date_required"),
2413
+ "helper-state": unref(c).date ? void 0 : "error"
2414
+ }, null, 8, ["label", "model-value", "helper-text", "helper-state"]))
2415
+ ]),
2416
+ unref(c).date && unref(c).time && unref(k) ? (openBlock(), createBlock(M, {
2417
+ key: 0,
2418
+ text: `${unref(moment)(unref(k)).isAfter(unref(moment)()) ? unref(o)("connect.template.rule.schedule.next_notification") : unref(o)("connect.template.rule.schedule.last_trigger_on")} ${unref(moment)(unref(k)).format("dddd, DD MMM YYYY")} at
2419
+ ${unref(moment)(unref(k)).format("hh:mmA")}(UTC${unref(moment).tz(unref(l)).format("Z")}) (${unref(moment)(unref(k)).fromNow()})`
2420
+ }, null, 8, ["text"])) : createCommentVNode("", !0),
2421
+ unref(y) ? (openBlock(), createBlock(M, {
2422
+ key: 1,
2423
+ text: "Repeating schedule was updated to stay anchored to the campaign start date.",
2424
+ state: "warning"
2425
+ })) : createCommentVNode("", !0)
2426
+ ])
2427
+ ], 64);
2428
+ };
2429
+ }
2430
+ }), _hoisted_1$e = { class: "space-y-16" }, _hoisted_2$b = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$8 = { class: "grid grid-cols-2 gap-16" }, _hoisted_4$7 = { class: "fm-typo-en-title-sm-800" }, _hoisted_5$5 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$e = /* @__PURE__ */ defineComponent({
2431
+ __name: "GameTypeInput",
2432
+ props: {
2433
+ modelValue: {
2434
+ type: String
2435
+ }
2436
+ },
2437
+ emits: ["update:model-value"],
2438
+ setup(e, { emit: r }) {
2439
+ const { t: o } = useI18n(), m = e, i = r, u = computed(
2440
+ () => [
2441
+ {
2442
+ label: o("connect.campaign.gameType.option.FORTUNE_WHEEL.label"),
2443
+ description: o("connect.campaign.gameType.option.FORTUNE_WHEEL.description"),
2444
+ value: F_GAME_TYPE.enum.FORTUNE_WHEEL,
2445
+ hidden: !1
2446
+ },
2447
+ {
2448
+ label: o("connect.campaign.gameType.option.ROCK_PAPER_SCISSORS.label"),
2449
+ description: o("connect.campaign.gameType.option.ROCK_PAPER_SCISSORS.description"),
2450
+ value: F_GAME_TYPE.enum.ROCK_PAPER_SCISSORS,
2451
+ hidden: !0
2452
+ }
2453
+ ].filter((l) => !l.hidden)
2454
+ );
2455
+ return (l, n) => {
2456
+ const a = resolveComponent("FmCard");
2457
+ return openBlock(), createElementBlock("div", _hoisted_1$e, [
2458
+ createElementVNode("div", _hoisted_2$b, toDisplayString(unref(o)("connect.template.select_game")), 1),
2459
+ createElementVNode("div", _hoisted_3$8, [
2460
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(u), (s) => (openBlock(), createBlock(a, {
2461
+ variant: "outlined",
2462
+ class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
2463
+ "col-span-2": unref(u).length == 1,
2464
+ "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": e.modelValue == s.value,
2465
+ "hover:bg-fm-color-opacity-sm": e.modelValue != s.value
2466
+ }]),
2467
+ onClick: () => {
2468
+ m.modelValue != s.value && i("update:model-value", s.value);
2469
+ },
2470
+ key: s.value
2471
+ }, {
2472
+ default: withCtx(() => [
2473
+ createElementVNode("div", _hoisted_4$7, toDisplayString(s.label), 1),
2474
+ createElementVNode("div", _hoisted_5$5, toDisplayString(s.description), 1)
2475
+ ]),
2476
+ _: 2
2477
+ }, 1032, ["class", "onClick"]))), 128))
2478
+ ])
2479
+ ]);
2480
+ };
2481
+ }
2482
+ }), _hoisted_1$d = {
2483
+ key: 0,
2484
+ class: "flex flex-col gap-y-24"
2485
+ }, _hoisted_2$a = { class: "flex gap-8 items-center justify-start" }, _sfc_main$d = /* @__PURE__ */ defineComponent({
2486
+ __name: "EditRewardPoolSheet",
2487
+ emits: ["update:model-value"],
2488
+ setup(e, { expose: r, emit: o }) {
2489
+ const m = useMembershipStore(), { minor: i } = useLoading, u = ref(!1), l = ref(), n = ref(), a = ref(0), s = computed(() => {
2490
+ var g;
2491
+ return ((g = m.loyaltyRewards.items.find(
2492
+ (v) => {
2493
+ var d;
2494
+ return v.value === ((d = l.value) == null ? void 0 : d.collectible);
2495
+ }
2496
+ )) == null ? void 0 : g.raw.type) === "CREDIT" ? FdoCreditLoyaltyReward : FdtoRandomReward;
2497
+ }), y = computed(() => {
2498
+ const V = s.value.safeParse(l.value);
2499
+ return V.success ? [] : V.error.errors;
2500
+ });
2501
+ function f(V, g, v) {
2502
+ V && (l.value = g, a.value = v), u.value = V;
2503
+ }
2504
+ const c = o;
2505
+ async function k() {
2506
+ const V = s.value.safeParse(l.value);
2507
+ V.success && (await i(
2508
+ async () => {
2509
+ V.data.type === "VOUCHER" && n.value && (V.data.collectibleConfig.image = await firebaseStorage.update(
2510
+ V.data.collectibleConfig.image || firebaseStorage.collectibleImagePath(void 0, n.value),
2511
+ n.value
2512
+ ));
2513
+ },
2514
+ {
2515
+ message: "Uploading reward image",
2516
+ successMessage: "Reward image updated"
2517
+ }
2518
+ ), c("update:model-value", V.data, a.value));
2519
+ }
2520
+ return r({
2521
+ showSheet: f
2522
+ }), (V, g) => {
2523
+ const v = resolveComponent("FmSelect"), d = resolveComponent("FmStepperField"), p = resolveComponent("FmButton"), C = resolveComponent("FmSideSheet");
2524
+ return openBlock(), createBlock(C, {
2525
+ "max-width": 560,
2526
+ modelValue: unref(u),
2527
+ "onUpdate:modelValue": [
2528
+ g[9] || (g[9] = (x) => isRef(u) ? u.value = x : null),
2529
+ g[10] || (g[10] = (x) => u.value = x)
2530
+ ],
2531
+ header: "Edit reward",
2532
+ "dismiss-away": ""
2533
+ }, {
2534
+ "side-sheet-footer": withCtx(() => [
2535
+ createElementVNode("div", _hoisted_2$a, [
2536
+ createVNode(p, {
2537
+ variant: "primary",
2538
+ type: "button",
2539
+ disabled: unref(y).length > 0,
2540
+ label: "Confirm",
2541
+ onClick: g[7] || (g[7] = (x) => k())
2542
+ }, null, 8, ["disabled"]),
2543
+ createVNode(p, {
2544
+ variant: "secondary",
2545
+ type: "button",
2546
+ label: "Cancel",
2547
+ onClick: g[8] || (g[8] = (x) => u.value = !1)
2548
+ })
2549
+ ])
2550
+ ]),
2551
+ default: withCtx(() => {
2552
+ var x, N, w;
2553
+ return [
2554
+ unref(l) ? (openBlock(), createElementBlock("div", _hoisted_1$d, [
2555
+ createVNode(v, {
2556
+ label: "Reward Type",
2557
+ items: [
2558
+ { label: "No Reward", value: "NO_REWARD" },
2559
+ { label: "Voucher", value: "VOUCHER" },
2560
+ { label: "Loyalty", value: "LOYALTY" }
2561
+ ],
2562
+ "model-value": unref(l).type,
2563
+ "onUpdate:modelValue": g[0] || (g[0] = ($) => {
2564
+ $ == "NO_REWARD" ? l.value = {
2565
+ type: "NO_REWARD",
2566
+ collectible: null,
2567
+ weight: 1
2568
+ } : $ === "VOUCHER" ? l.value = {
2569
+ collectible: null,
2570
+ type: "VOUCHER",
2571
+ collectibleConfig: unref(initCollectibleConfig)("VOUCHER", {
2572
+ business: unref(useCoreStore)().currentBusiness.value._id
2573
+ }),
2574
+ earningOption: {
2575
+ amount: 1,
2576
+ type: "FIXED"
2577
+ },
2578
+ validityOption: {
2579
+ validForDay: 7
2580
+ },
2581
+ weight: 1
2582
+ } : l.value = {
2583
+ collectible: unref(m).loyaltyRewards.raw[0]._id,
2584
+ type: "LOYALTY",
2585
+ earningOption: {
2586
+ amount: 1,
2587
+ type: "FIXED"
2588
+ },
2589
+ validityOption: {
2590
+ validForDay: 7
2591
+ },
2592
+ weight: 1
2593
+ };
2594
+ })
2595
+ }, null, 8, ["model-value"]),
2596
+ unref(l).type == "LOYALTY" ? (openBlock(), createBlock(v, {
2597
+ key: 0,
2598
+ label: "Loyalty type",
2599
+ rules: [unref(ZodHelper).ruleAtPath(unref(s), "collectible", [unref(l).type])],
2600
+ items: unref(m).loyaltyRewards.items,
2601
+ "model-value": unref(l).collectible,
2602
+ "onUpdate:modelValue": g[1] || (g[1] = ($) => unref(l).collectible = $)
2603
+ }, null, 8, ["rules", "items", "model-value"])) : createCommentVNode("", !0),
2604
+ createVNode(d, {
2605
+ label: "Weight",
2606
+ rules: [unref(ZodHelper).ruleAtPath(unref(s), "weight", [unref(l).type])],
2607
+ "model-value": unref(l).weight,
2608
+ "onUpdate:modelValue": g[2] || (g[2] = ($) => l.value = {
2609
+ ...unref(l),
2610
+ weight: $
2611
+ })
2612
+ }, null, 8, ["rules", "model-value"]),
2613
+ unref(l).type === "LOYALTY" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
2614
+ ((x = unref(m).loyaltyRewards.items.find(
2615
+ ($) => {
2616
+ var T;
2617
+ return $.value === ((T = unref(l)) == null ? void 0 : T.collectible);
2618
+ }
2619
+ )) == null ? void 0 : x.raw.type) !== "TITLE" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
2620
+ g[11] || (g[11] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Earning option", -1)),
2621
+ createVNode(_sfc_main$z, {
2622
+ class: "mt-[-8px]",
2623
+ rules: [
2624
+ unref(ZodHelper).ruleAtPath(unref(s), "earningOption", [unref(l).type])
2625
+ ],
2626
+ "helper-state": unref(ZodHelper).helperState(unref(y), "earningOption"),
2627
+ "error-text": unref(ZodHelper).helperText(unref(y), "earningOption"),
2628
+ "fixed-type": !0,
2629
+ "model-value": unref(l).earningOption,
2630
+ "onUpdate:modelValue": g[3] || (g[3] = ($) => l.value = {
2631
+ ...unref(l),
2632
+ earningOption: $
2633
+ })
2634
+ }, null, 8, ["rules", "helper-state", "error-text", "model-value"])
2635
+ ], 64)) : createCommentVNode("", !0),
2636
+ g[12] || (g[12] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Validity option", -1)),
2637
+ createVNode(_sfc_main$A, {
2638
+ type: unref(l).type === "LOYALTY" ? "custom" : "range",
2639
+ "for-credit": unref(l).type === "LOYALTY" && ((N = unref(m).loyaltyRewards.items.find(
2640
+ ($) => {
2641
+ var T;
2642
+ return $.value === ((T = unref(l)) == null ? void 0 : T.collectible);
2643
+ }
2644
+ )) == null ? void 0 : N.raw.type) === "CREDIT",
2645
+ class: "!gap-24",
2646
+ rules: [unref(ZodHelper).ruleAtPath(unref(s), "validityOption", [unref(l).type])],
2647
+ "model-value": unref(l).validityOption,
2648
+ "onUpdate:modelValue": g[4] || (g[4] = ($) => l.value = {
2649
+ ...unref(l),
2650
+ validityOption: $
2651
+ })
2652
+ }, null, 8, ["type", "for-credit", "rules", "model-value"])
2653
+ ], 64)) : createCommentVNode("", !0),
2654
+ unref(l).type === "VOUCHER" ? (openBlock(), createBlock(_sfc_main$B, {
2655
+ key: 2,
2656
+ "reward-image": unref(n),
2657
+ "model-value": ((w = unref(l)) == null ? void 0 : w.collectibleConfig) ?? void 0,
2658
+ "onUpdate:modelValue": g[5] || (g[5] = ($) => l.value = {
2659
+ ...unref(l),
2660
+ collectibleConfig: $
2661
+ }),
2662
+ "onUpdate:rewardImage": g[6] || (g[6] = ($) => n.value = $)
2663
+ }, null, 8, ["reward-image", "model-value"])) : createCommentVNode("", !0),
2664
+ createVNode(JsonViewer, { json: unref(y) }, null, 8, ["json"])
2665
+ ])) : createCommentVNode("", !0)
2666
+ ];
2667
+ }),
2668
+ _: 1
2669
+ }, 8, ["modelValue"]);
2670
+ };
2671
+ }
2672
+ });
2673
+ function isNullOrEmpty(e) {
2674
+ return e == null || e === "";
2675
+ }
2676
+ const _hoisted_1$c = { class: "space-y-16" }, _hoisted_2$9 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$7 = { class: "fm-typo-en-body-lg-400" }, _hoisted_4$6 = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _sfc_main$c = /* @__PURE__ */ defineComponent({
2677
+ __name: "RewardPoolInput",
2678
+ props: {
2679
+ modelValue: {
2680
+ type: Array,
2681
+ default: () => [
2682
+ {
2683
+ collectible: null,
2684
+ type: "NO_REWARD",
2685
+ weight: 1
2686
+ }
2687
+ ]
2688
+ }
2689
+ },
2690
+ emits: ["update:model-value"],
2691
+ setup(e, { emit: r }) {
2692
+ const o = e, m = r, i = useMembershipStore(), { t: u } = useI18n(), l = z.array(z.lazy(() => FdtoRandomReward)).min(1, "Requires at least 1 reward"), n = computed(() => o.modelValue ?? []), a = computed(() => {
2693
+ const g = l.safeParse(n.value);
2694
+ return g.success ? [] : g.error.errors;
2695
+ }), s = ref();
2696
+ function y(g, v) {
2697
+ var p;
2698
+ const d = [...n.value];
2699
+ d[v] = g, (p = s.value) == null || p.showSheet(!1), m("update:model-value", d);
2700
+ }
2701
+ function f(g) {
2702
+ const v = g.type == "VOUCHER" ? g.collectibleConfig : i.collectibles.find(
2703
+ (C) => C._id.toString() == g.collectible
2704
+ ), d = CollectionUtils.formattedType((v == null ? void 0 : v.name) || ""), p = g.weight;
2705
+ return {
2706
+ label: isNullOrEmpty(d) ? "NO REWARD" : d,
2707
+ sublabel: `${p} (${(p / n.value.reduce((C, x) => C + x.weight, 0) * 100).toFixed(2)}%)`
2708
+ };
2709
+ }
2710
+ function c(g) {
2711
+ var d;
2712
+ const v = [...n.value];
2713
+ (d = s.value) == null || d.showSheet(!0, v[g], g);
2714
+ }
2715
+ function k(g) {
2716
+ const v = [...n.value];
2717
+ v.splice(g, 1), m("update:model-value", v);
2718
+ }
2719
+ function V() {
2720
+ var g;
2721
+ (g = s.value) == null || g.showSheet(
2722
+ !0,
2723
+ {
2724
+ type: "NO_REWARD",
2725
+ collectible: null,
2726
+ weight: 1
2727
+ },
2728
+ n.value.length
2729
+ );
2730
+ }
2731
+ return (g, v) => {
2732
+ const d = resolveComponent("FmButton"), p = resolveComponent("FmCard"), C = resolveComponent("FmHelperText");
2733
+ return openBlock(), createElementBlock("div", _hoisted_1$c, [
2734
+ createElementVNode("div", _hoisted_2$9, toDisplayString(unref(u)("connect.template.configure_reward_type")), 1),
2735
+ createVNode(d, {
2736
+ label: unref(u)("connect.campaign.rewardPool.addReward"),
2737
+ onClick: v[0] || (v[0] = (x) => V()),
2738
+ variant: "plain",
2739
+ icon: "add"
2740
+ }, null, 8, ["label"]),
2741
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(n), (x, N) => (openBlock(), createBlock(p, {
2742
+ key: N,
2743
+ class: "px-16 py-12 flex items-center justify-between cursor-pointer",
2744
+ variant: "outlined",
2745
+ onClick: (w) => c(N)
2746
+ }, {
2747
+ default: withCtx(() => {
2748
+ var w;
2749
+ return [
2750
+ createElementVNode("div", null, [
2751
+ createElementVNode("div", _hoisted_3$7, toDisplayString(x.type == "LOYALTY" ? (w = x == null ? void 0 : x.earningOption) == null ? void 0 : w.amount : "") + " " + toDisplayString(f(x).label), 1),
2752
+ createElementVNode("div", _hoisted_4$6, toDisplayString(f(x).sublabel), 1)
2753
+ ]),
2754
+ createVNode(d, {
2755
+ icon: "delete",
2756
+ variant: "tertiary",
2757
+ onClick: ($) => ($.stopPropagation(), k(N))
2758
+ }, null, 8, ["onClick"])
2759
+ ];
2760
+ }),
2761
+ _: 2
2762
+ }, 1032, ["onClick"]))), 128)),
2763
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(a).filter((x) => x.path.join(".") == ""), (x) => (openBlock(), createBlock(C, {
2764
+ key: x.message,
2765
+ text: x.message,
2766
+ state: "error"
2767
+ }, null, 8, ["text"]))), 128)),
2768
+ createVNode(_sfc_main$d, {
2769
+ ref_key: "sheetRef",
2770
+ ref: s,
2771
+ "onUpdate:modelValue": y
2772
+ }, null, 512)
2773
+ ]);
2774
+ };
2775
+ }
2776
+ }), _hoisted_1$b = { class: "space-y-16" }, _hoisted_2$8 = {
2777
+ key: 0,
2778
+ class: "grid grid-cols-2 gap-16"
2779
+ }, _hoisted_3$6 = { class: "fm-typo-en-title-sm-800" }, _hoisted_4$5 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$b = /* @__PURE__ */ defineComponent({
2780
+ __name: "PromotionGameTypeInput",
2781
+ props: {
2782
+ modelValue: {
2783
+ type: Object
2784
+ }
2785
+ },
2786
+ emits: ["update:model-value"],
2787
+ setup(e, { emit: r }) {
2788
+ const { t: o } = useI18n(), m = e, i = r, u = computed(() => [
2789
+ {
2790
+ label: o("connect.template.promotion_game.rock_paper_scissors.label"),
2791
+ description: o("connect.template.promotion_game.rock_paper_scissors.description"),
2792
+ value: F_GAME_TYPE.enum.ROCK_PAPER_SCISSORS
2793
+ }
2794
+ ]);
2795
+ return (l, n) => {
2796
+ var f, c, k;
2797
+ const a = resolveComponent("FmSwitch"), s = resolveComponent("FmCard"), y = resolveComponent("FmHelperText");
2798
+ return openBlock(), createElementBlock("div", _hoisted_1$b, [
2799
+ createVNode(a, {
2800
+ label: unref(o)("connect.template.promotion_game.enable"),
2801
+ "model-value": !!((f = e.modelValue) != null && f.gameType),
2802
+ "onUpdate:modelValue": n[0] || (n[0] = (V) => V ? i("update:model-value", { gameType: "ROCK_PAPER_SCISSORS" }) : i("update:model-value", null))
2803
+ }, null, 8, ["label", "model-value"]),
2804
+ ((c = e.modelValue) == null ? void 0 : c.gameType) == "ROCK_PAPER_SCISSORS" ? (openBlock(), createElementBlock("div", _hoisted_2$8, [
2805
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(u), (V) => {
2806
+ var g, v;
2807
+ return openBlock(), createBlock(s, {
2808
+ variant: "outlined",
2809
+ class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
2810
+ "col-span-2": unref(u).length == 1,
2811
+ "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": ((g = e.modelValue) == null ? void 0 : g.gameType) == V.value,
2812
+ "hover:bg-fm-color-opacity-sm": ((v = e.modelValue) == null ? void 0 : v.gameType) != V.value
2813
+ }]),
2814
+ onClick: () => {
2815
+ var d;
2816
+ ((d = m.modelValue) == null ? void 0 : d.gameType) != V.value && i("update:model-value", { gameType: V.value });
2817
+ },
2818
+ key: V.value
2819
+ }, {
2820
+ default: withCtx(() => [
2821
+ createElementVNode("div", _hoisted_3$6, toDisplayString(V.label), 1),
2822
+ createElementVNode("div", _hoisted_4$5, toDisplayString(V.description), 1)
2823
+ ]),
2824
+ _: 2
2825
+ }, 1032, ["class", "onClick"]);
2826
+ }), 128))
2827
+ ])) : createCommentVNode("", !0),
2828
+ ((k = e.modelValue) == null ? void 0 : k.gameType) == "ROCK_PAPER_SCISSORS" ? (openBlock(), createBlock(y, {
2829
+ key: 1,
2830
+ text: unref(o)("connect.template.promotion_game.rock_paper_scissors.warning"),
2831
+ state: "warning"
2832
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
2833
+ ]);
2834
+ };
2835
+ }
2836
+ }), _hoisted_1$a = { class: "space-y-8" }, _hoisted_2$7 = { class: "grid gap-16 grid-cols-2" }, _hoisted_3$5 = { class: "space-y-6" }, _hoisted_4$4 = { class: "space-y-8" }, _hoisted_5$4 = { class: "fm-typo-en-body-lg-600" }, _hoisted_6$3 = { class: "flex items-center space-x-3" }, _hoisted_7$3 = {
2837
+ key: 0,
2838
+ class: "ml-6 space-y-2"
2839
+ }, _sfc_main$a = /* @__PURE__ */ defineComponent({
2840
+ __name: "GrabConditionsInput",
2841
+ props: {
2842
+ modelValue: {
2843
+ type: Object
2844
+ },
2845
+ schema: {
2846
+ type: Object,
2847
+ default: () => z.any()
2848
+ }
2849
+ },
2850
+ emits: ["update:model-value"],
2851
+ setup(e, { emit: r }) {
2852
+ const { t: o } = useI18n(), m = e, i = r, u = ref(m.modelValue ?? {}), l = ref(
2853
+ (() => {
2854
+ const f = {};
2855
+ return u.value.workingHour && Object.keys(u.value.workingHour).forEach((c) => {
2856
+ const k = u.value.workingHour[c];
2857
+ k && "periods" in k && Array.isArray(k.periods) ? f[c] = k.periods : Array.isArray(k) && (f[c] = k);
2858
+ }), f;
2859
+ })()
2860
+ ), n = [
2861
+ { key: "mon", label: "Monday" },
2862
+ { key: "tue", label: "Tuesday" },
2863
+ { key: "wed", label: "Wednesday" },
2864
+ { key: "thu", label: "Thursday" },
2865
+ { key: "fri", label: "Friday" },
2866
+ { key: "sat", label: "Saturday" },
2867
+ { key: "sun", label: "Sunday" }
2868
+ ], a = (f) => {
2869
+ l.value[f] || (l.value[f] = []), l.value[f].push({
2870
+ startTime: "00:00",
2871
+ endTime: "23:59"
2872
+ }), y();
2873
+ }, s = (f, c) => {
2874
+ l.value[f] && l.value[f].length > c && (l.value[f].splice(c, 1), l.value[f].length === 0 && delete l.value[f], y());
2875
+ }, y = () => {
2876
+ const f = Object.keys(l.value).reduce(
2877
+ (c, k) => (l.value[k] && l.value[k].length > 0 && (c[k] = {
2878
+ periods: l.value[k]
2879
+ }), c),
2880
+ {}
2881
+ );
2882
+ u.value.workingHour = Object.keys(f).length > 0 ? f : void 0;
2883
+ };
2884
+ return watch(u, () => i("update:model-value", u.value), { deep: !0 }), watch(l, y, { deep: !0 }), (f, c) => {
2885
+ const k = resolveComponent("FmSelect"), V = resolveComponent("FmStepperField"), g = resolveComponent("FmCheckbox"), v = resolveComponent("FmTimePicker"), d = resolveComponent("FmButton");
2886
+ return openBlock(), createElementBlock("div", _hoisted_1$a, [
2887
+ createElementVNode("div", _hoisted_2$7, [
2888
+ createVNode(k, {
2889
+ label: unref(o)("connect.template.eaterType"),
2890
+ modelValue: unref(u).eaterType,
2891
+ "onUpdate:modelValue": c[0] || (c[0] = (p) => unref(u).eaterType = p),
2892
+ items: [
2893
+ { label: unref(o)("connect.template.allEaters"), value: "all" },
2894
+ { label: unref(o)("connect.template.newEatersOnly"), value: "new" },
2895
+ {
2896
+ label: unref(o)("connect.template.existingEatersOnly"),
2897
+ value: "existing"
2898
+ }
2899
+ ],
2900
+ rules: [unref(ZodHelper).ruleAtPath(e.schema, "eaterType")]
2901
+ }, null, 8, ["label", "modelValue", "items", "rules"]),
2902
+ createVNode(V, {
2903
+ modelValue: unref(u).minBasketAmount,
2904
+ "onUpdate:modelValue": c[1] || (c[1] = (p) => unref(u).minBasketAmount = p),
2905
+ "show-steppers": !1,
2906
+ rules: [unref(ZodHelper).ruleAtPath(e.schema, "minBasketAmount")]
2907
+ }, {
2908
+ label: withCtx(() => [
2909
+ (openBlock(), createBlock(resolveDynamicComponent(
2910
+ unref(ZodHelper).toInputLabel(
2911
+ unref(ZodHelper).typeAtPath(e.schema, "minBasketAmount"),
2912
+ unref(o)("connect.template.minBasketAmount")
2913
+ )
2914
+ )))
2915
+ ]),
2916
+ _: 1
2917
+ }, 8, ["modelValue", "rules"]),
2918
+ createVNode(V, {
2919
+ modelValue: unref(u).bundleQuantity,
2920
+ "onUpdate:modelValue": c[2] || (c[2] = (p) => unref(u).bundleQuantity = p),
2921
+ "show-steppers": !1,
2922
+ rules: [unref(ZodHelper).ruleAtPath(e.schema, "bundleQuantity")]
2923
+ }, {
2924
+ label: withCtx(() => [
2925
+ (openBlock(), createBlock(resolveDynamicComponent(
2926
+ unref(ZodHelper).toInputLabel(
2927
+ unref(ZodHelper).typeAtPath(e.schema, "bundleQuantity"),
2928
+ unref(o)("connect.template.bundleQuantity")
2929
+ )
2930
+ )))
2931
+ ]),
2932
+ _: 1
2933
+ }, 8, ["modelValue", "rules"])
2934
+ ]),
2935
+ createElementVNode("div", _hoisted_3$5, [
2936
+ createElementVNode("div", _hoisted_4$4, [
2937
+ createElementVNode("div", _hoisted_5$4, toDisplayString(unref(o)("connect.template.operationHours")), 1),
2938
+ (openBlock(), createElementBlock(Fragment, null, renderList(n, (p) => createElementVNode("div", {
2939
+ key: p.key,
2940
+ class: "space-y-2"
2941
+ }, [
2942
+ createElementVNode("div", _hoisted_6$3, [
2943
+ createVNode(g, {
2944
+ label: p.label,
2945
+ "model-value": !!(unref(l)[p.key] && unref(l)[p.key].length > 0),
2946
+ "onUpdate:modelValue": (C) => {
2947
+ C ? a(p.key) : (unref(l)[p.key] = [], delete unref(l)[p.key], y());
2948
+ }
2949
+ }, null, 8, ["label", "model-value", "onUpdate:modelValue"])
2950
+ ]),
2951
+ unref(l)[p.key] && unref(l)[p.key].length > 0 ? (openBlock(), createElementBlock("div", _hoisted_7$3, [
2952
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(l)[p.key] || [], (C, x) => (openBlock(), createElementBlock("div", {
2953
+ key: x,
2954
+ class: "flex items-center space-x-2 w-100"
2955
+ }, [
2956
+ createVNode(v, {
2957
+ "model-value": C.startTime || "",
2958
+ "onUpdate:modelValue": (N) => {
2959
+ unref(l)[p.key] && unref(l)[p.key][x] && (unref(l)[p.key][x].startTime = N || "", y());
2960
+ }
2961
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
2962
+ c[3] || (c[3] = createElementVNode("span", null, "to", -1)),
2963
+ createVNode(v, {
2964
+ "model-value": C.endTime || "",
2965
+ "onUpdate:modelValue": (N) => {
2966
+ unref(l)[p.key] && unref(l)[p.key][x] && (unref(l)[p.key][x].endTime = N || "", y());
2967
+ }
2968
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
2969
+ createVNode(d, {
2970
+ variant: "tertiary",
2971
+ size: "sm",
2972
+ onClick: (N) => s(p.key, x),
2973
+ icon: "close"
2974
+ }, null, 8, ["onClick"]),
2975
+ x === 0 ? (openBlock(), createBlock(d, {
2976
+ key: 0,
2977
+ onClick: (N) => a(p.key),
2978
+ icon: "add",
2979
+ variant: "plain"
2980
+ }, null, 8, ["onClick"])) : createCommentVNode("", !0)
2981
+ ]))), 128))
2982
+ ])) : createCommentVNode("", !0)
2983
+ ])), 64))
2984
+ ])
2985
+ ])
2986
+ ]);
2987
+ };
2988
+ }
2989
+ }), GrabConditionsInput = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-7f17ebe8"]]), _hoisted_1$9 = { class: "space-y-8" }, _hoisted_2$6 = { class: "grid gap-16 grid-cols-2" }, _sfc_main$9 = /* @__PURE__ */ defineComponent({
2990
+ __name: "GrabQuotaInput",
2991
+ props: {
2992
+ modelValue: {
2993
+ type: Object
2994
+ },
2995
+ schema: {
2996
+ type: Object,
2997
+ default: () => z.any()
2998
+ }
2999
+ },
3000
+ emits: ["update:model-value"],
3001
+ setup(e, { emit: r }) {
3002
+ const { t: o } = useI18n(), m = e, i = r, u = ref(m.modelValue ?? {});
3003
+ return watch(u, () => i("update:model-value", u.value)), (l, n) => {
3004
+ const a = resolveComponent("FmStepperField");
3005
+ return openBlock(), createElementBlock("div", _hoisted_1$9, [
3006
+ createElementVNode("div", _hoisted_2$6, [
3007
+ createVNode(a, {
3008
+ modelValue: unref(u).totalCount,
3009
+ "onUpdate:modelValue": n[0] || (n[0] = (s) => unref(u).totalCount = s),
3010
+ "show-steppers": !1,
3011
+ rules: [unref(ZodHelper).ruleAtPath(e.schema, "totalCount")]
3012
+ }, {
3013
+ label: withCtx(() => [
3014
+ (openBlock(), createBlock(resolveDynamicComponent(
3015
+ unref(ZodHelper).toInputLabel(
3016
+ unref(ZodHelper).typeAtPath(e.schema, "totalCount"),
3017
+ unref(o)("connect.template.totalCount")
3018
+ )
3019
+ )))
3020
+ ]),
3021
+ _: 1
3022
+ }, 8, ["modelValue", "rules"]),
3023
+ createVNode(a, {
3024
+ modelValue: unref(u).totalCountPerUser,
3025
+ "onUpdate:modelValue": n[1] || (n[1] = (s) => unref(u).totalCountPerUser = s),
3026
+ "show-steppers": !1,
3027
+ rules: [unref(ZodHelper).ruleAtPath(e.schema, "totalCountPerUser")]
3028
+ }, {
3029
+ label: withCtx(() => [
3030
+ (openBlock(), createBlock(resolveDynamicComponent(
3031
+ unref(ZodHelper).toInputLabel(
3032
+ unref(ZodHelper).typeAtPath(e.schema, "totalCountPerUser"),
3033
+ unref(o)("connect.template.totalCountPerUser")
3034
+ )
3035
+ )))
3036
+ ]),
3037
+ _: 1
3038
+ }, 8, ["modelValue", "rules"])
3039
+ ])
3040
+ ]);
3041
+ };
3042
+ }
3043
+ }), _hoisted_1$8 = { class: "space-y-16" }, _hoisted_2$5 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$4 = { class: "grid grid-cols-2 gap-16" }, _hoisted_4$3 = { class: "fm-typo-en-title-sm-800" }, _hoisted_5$3 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$8 = /* @__PURE__ */ defineComponent({
3044
+ __name: "MissionTypeInput",
3045
+ props: {
3046
+ modelValue: {
3047
+ type: String
3048
+ }
3049
+ },
3050
+ emits: ["update:model-value"],
3051
+ setup(e, { emit: r }) {
3052
+ const { t: o } = useI18n(), m = e, i = r, u = computed(() => [
3053
+ {
3054
+ label: o("connect.campaign.mission.typeOption.STAMP.label"),
3055
+ description: o("connect.campaign.mission.typeOption.STAMP.description"),
3056
+ value: F_MISSION_TYPE.enum.STAMP
3057
+ },
3058
+ {
3059
+ label: o("connect.campaign.mission.typeOption.PROGRESSIVE.label"),
3060
+ description: o("connect.campaign.mission.typeOption.PROGRESSIVE.description"),
3061
+ value: F_MISSION_TYPE.enum.PROGRESSIVE
3062
+ }
3063
+ ]);
3064
+ return (l, n) => {
3065
+ const a = resolveComponent("FmCard");
3066
+ return openBlock(), createElementBlock("div", _hoisted_1$8, [
3067
+ createElementVNode("div", _hoisted_2$5, toDisplayString(unref(o)("connect.template.select_game")), 1),
3068
+ createElementVNode("div", _hoisted_3$4, [
3069
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(u), (s) => (openBlock(), createBlock(a, {
3070
+ variant: "outlined",
3071
+ class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
3072
+ "col-span-2": unref(u).length == 1,
3073
+ "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": e.modelValue == s.value,
3074
+ "hover:bg-fm-color-opacity-sm": e.modelValue != s.value
3075
+ }]),
3076
+ onClick: () => {
3077
+ m.modelValue != s.value && i("update:model-value", s.value);
3078
+ },
3079
+ key: s.value
3080
+ }, {
3081
+ default: withCtx(() => [
3082
+ createElementVNode("div", _hoisted_4$3, toDisplayString(s.label), 1),
3083
+ createElementVNode("div", _hoisted_5$3, toDisplayString(s.description), 1)
3084
+ ]),
3085
+ _: 2
3086
+ }, 1032, ["class", "onClick"]))), 128))
3087
+ ])
3088
+ ]);
3089
+ };
3090
+ }
3091
+ }), _hoisted_1$7 = { class: "space-y-16" }, _sfc_main$7 = /* @__PURE__ */ defineComponent({
3092
+ __name: "MissionEndInput",
3093
+ props: {
3094
+ modelValue: {
3095
+ type: [String, Number]
3096
+ },
3097
+ helperText: {
3098
+ type: String
3099
+ },
3100
+ helperState: {
3101
+ type: String
3102
+ }
3103
+ },
3104
+ emits: ["update:model-value"],
3105
+ setup(e, { emit: r }) {
3106
+ const o = r;
3107
+ return (m, i) => {
3108
+ const u = resolveComponent("FmStepperField");
3109
+ return openBlock(), createElementBlock("div", _hoisted_1$7, [
3110
+ i[1] || (i[1] = createElementVNode("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Input the total number of stamps needed to complete the mission ", -1)),
3111
+ createVNode(u, {
3112
+ label: "Maximum to collect",
3113
+ "model-value": e.modelValue || null,
3114
+ "onUpdate:modelValue": i[0] || (i[0] = (l) => o("update:model-value", l)),
3115
+ "helper-text": e.helperText || "Set the threshold required for reward eligibility",
3116
+ "helper-state": e.helperState || "none"
3117
+ }, null, 8, ["model-value", "helper-text", "helper-state"])
3118
+ ]);
3119
+ };
3120
+ }
3121
+ }), _hoisted_1$6 = { class: "flex gap-8 items-center justify-start" }, _sfc_main$6 = /* @__PURE__ */ defineComponent({
3122
+ __name: "EditMissionPoolSheet",
3123
+ props: {
3124
+ maxThreshold: {
3125
+ type: Number,
3126
+ required: !0
3127
+ }
3128
+ },
3129
+ emits: ["update:model-value"],
3130
+ setup(e, { expose: r, emit: o }) {
3131
+ const m = e, i = useMembershipStore(), { minor: u } = useLoading, l = ref(!1), n = ref(), a = ref(), s = ref(0), y = computed(() => {
3132
+ var d;
3133
+ return ((d = i.loyaltyRewards.items.find(
3134
+ (p) => {
3135
+ var C;
3136
+ return p.value === ((C = n.value) == null ? void 0 : C.collectible);
3137
+ }
3138
+ )) == null ? void 0 : d.raw.type) === "CREDIT" ? FdoThresholdCreditReward : FdtoThresholdReward;
3139
+ }), f = computed(() => {
3140
+ const v = y.value.safeParse(n.value);
3141
+ return v.success ? [] : v.error.errors;
3142
+ });
3143
+ function c(v, d, p) {
3144
+ v && (n.value = d, s.value = p), l.value = v;
3145
+ }
3146
+ const k = o;
3147
+ async function V() {
3148
+ const v = y.value.safeParse(n.value);
3149
+ v.success && (await u(
3150
+ async () => {
3151
+ v.data.type === "VOUCHER" && a.value && (v.data.collectibleConfig.image = await firebaseStorage.update(
3152
+ v.data.collectibleConfig.image || firebaseStorage.collectibleImagePath(void 0, a.value),
3153
+ a.value
3154
+ ));
3155
+ },
3156
+ {
3157
+ message: "Uploading reward image",
3158
+ successMessage: "Reward image updated"
3159
+ }
3160
+ ), k("update:model-value", v.data, s.value));
3161
+ }
3162
+ const g = ref();
3163
+ return r({
3164
+ showSheet: c
3165
+ }), (v, d) => {
3166
+ const p = resolveComponent("FmStepperField"), C = resolveComponent("FmSelect"), x = resolveComponent("FmForm"), N = resolveComponent("FmButton"), w = resolveComponent("FmSideSheet");
3167
+ return openBlock(), createBlock(w, {
3168
+ "max-width": 560,
3169
+ modelValue: unref(l),
3170
+ "onUpdate:modelValue": [
3171
+ d[10] || (d[10] = ($) => isRef(l) ? l.value = $ : null),
3172
+ d[11] || (d[11] = ($) => l.value = $)
3173
+ ],
3174
+ header: "Edit reward",
3175
+ "dismiss-away": ""
3176
+ }, {
3177
+ "side-sheet-footer": withCtx(() => [
3178
+ createElementVNode("div", _hoisted_1$6, [
3179
+ createVNode(N, {
3180
+ variant: "primary",
3181
+ type: "button",
3182
+ label: "Confirm",
3183
+ disabled: unref(f).length > 0,
3184
+ onClick: d[8] || (d[8] = async () => {
3185
+ var $;
3186
+ return ($ = unref(g)) == null ? void 0 : $.validateInputs();
3187
+ })
3188
+ }, null, 8, ["disabled"]),
3189
+ createVNode(N, {
3190
+ variant: "secondary",
3191
+ type: "button",
3192
+ label: "Cancel",
3193
+ onClick: d[9] || (d[9] = ($) => l.value = !1)
3194
+ })
3195
+ ])
3196
+ ]),
3197
+ default: withCtx(() => [
3198
+ createVNode(JsonViewer, { json: unref(n) }, null, 8, ["json"]),
3199
+ unref(n) ? (openBlock(), createBlock(x, {
3200
+ key: 0,
3201
+ class: "flex flex-col gap-y-24",
3202
+ ref_key: "formRef",
3203
+ ref: g,
3204
+ onValidationSuccess: d[7] || (d[7] = ($) => V())
3205
+ }, {
3206
+ default: withCtx(() => {
3207
+ var $, T;
3208
+ return [
3209
+ unref(n).type ? (openBlock(), createBlock(p, {
3210
+ key: 0,
3211
+ label: "Threshold",
3212
+ rules: [
3213
+ unref(ZodHelper).toRule(
3214
+ unref(z).number().min(1).max(
3215
+ m.maxThreshold,
3216
+ `Number cannot be more than ${m.maxThreshold}`
3217
+ )
3218
+ )
3219
+ ],
3220
+ "model-value": unref(n).threshold,
3221
+ "onUpdate:modelValue": d[0] || (d[0] = (R) => n.value = {
3222
+ ...unref(n),
3223
+ threshold: R
3224
+ })
3225
+ }, null, 8, ["rules", "model-value"])) : createCommentVNode("", !0),
3226
+ createVNode(C, {
3227
+ label: "Reward Type",
3228
+ items: [
3229
+ { label: "Voucher", value: "VOUCHER" },
3230
+ { label: "Loyalty", value: "LOYALTY" }
3231
+ ],
3232
+ "model-value": unref(n).type,
3233
+ "onUpdate:modelValue": d[1] || (d[1] = (R) => {
3234
+ var A, M;
3235
+ R === "VOUCHER" ? n.value = {
3236
+ collectible: null,
3237
+ type: "VOUCHER",
3238
+ collectibleConfig: unref(initCollectibleConfig)("VOUCHER", {
3239
+ business: unref(useCoreStore)().currentBusiness.value._id
3240
+ }),
3241
+ earningOption: {
3242
+ amount: 1,
3243
+ type: "FIXED"
3244
+ },
3245
+ validityOption: {
3246
+ validForDay: 7
3247
+ },
3248
+ threshold: (A = unref(n)) == null ? void 0 : A.threshold
3249
+ } : n.value = {
3250
+ collectible: unref(i).loyaltyRewards.raw[0]._id,
3251
+ type: "LOYALTY",
3252
+ earningOption: {
3253
+ amount: 1,
3254
+ type: "FIXED"
3255
+ },
3256
+ validityOption: {
3257
+ validForDay: 7
3258
+ },
3259
+ threshold: (M = unref(n)) == null ? void 0 : M.threshold
3260
+ };
3261
+ })
3262
+ }, null, 8, ["model-value"]),
3263
+ unref(n).type == "LOYALTY" ? (openBlock(), createBlock(C, {
3264
+ key: 1,
3265
+ label: "Loyalty type",
3266
+ rules: [unref(ZodHelper).ruleAtPath(unref(y), "collectible", [unref(n).type])],
3267
+ items: unref(i).loyaltyRewards.items,
3268
+ "model-value": unref(n).collectible,
3269
+ "onUpdate:modelValue": d[2] || (d[2] = (R) => unref(n).collectible = R)
3270
+ }, null, 8, ["rules", "items", "model-value"])) : createCommentVNode("", !0),
3271
+ unref(n).type === "LOYALTY" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
3272
+ d[12] || (d[12] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Earning option", -1)),
3273
+ createVNode(_sfc_main$z, {
3274
+ class: "mt-[-8px]",
3275
+ rules: [unref(ZodHelper).ruleAtPath(unref(y), "earningOption", [unref(n).type])],
3276
+ "helper-state": unref(ZodHelper).helperState(unref(f), "earningOption"),
3277
+ "error-text": unref(ZodHelper).helperText(unref(f), "earningOption"),
3278
+ "fixed-type": !0,
3279
+ "model-value": unref(n).earningOption,
3280
+ "onUpdate:modelValue": d[3] || (d[3] = (R) => n.value = {
3281
+ ...unref(n),
3282
+ earningOption: R
3283
+ })
3284
+ }, null, 8, ["rules", "helper-state", "error-text", "model-value"]),
3285
+ createVNode(_sfc_main$A, {
3286
+ class: "!gap-24",
3287
+ type: unref(n).type === "LOYALTY" ? "custom" : "range",
3288
+ "for-credit": unref(n).type === "LOYALTY" && (($ = unref(i).loyaltyRewards.items.find(
3289
+ (R) => {
3290
+ var A;
3291
+ return R.value === ((A = unref(n)) == null ? void 0 : A.collectible);
3292
+ }
3293
+ )) == null ? void 0 : $.raw.type) === "CREDIT",
3294
+ rules: [unref(ZodHelper).ruleAtPath(unref(y), "validityOption", [unref(n).type])],
3295
+ "model-value": unref(n).validityOption,
3296
+ "onUpdate:modelValue": d[4] || (d[4] = (R) => n.value = {
3297
+ ...unref(n),
3298
+ validityOption: R
3299
+ })
3300
+ }, null, 8, ["type", "for-credit", "rules", "model-value"])
3301
+ ], 64)) : createCommentVNode("", !0),
3302
+ unref(n).type === "VOUCHER" ? (openBlock(), createBlock(_sfc_main$B, {
3303
+ key: 3,
3304
+ "reward-image": unref(a),
3305
+ "model-value": ((T = unref(n)) == null ? void 0 : T.collectibleConfig) ?? void 0,
3306
+ "onUpdate:modelValue": d[5] || (d[5] = (R) => n.value = {
3307
+ ...unref(n),
3308
+ collectibleConfig: R
3309
+ }),
3310
+ "onUpdate:rewardImage": d[6] || (d[6] = (R) => a.value = R)
3311
+ }, null, 8, ["reward-image", "model-value"])) : createCommentVNode("", !0),
3312
+ createVNode(JsonViewer, { json: unref(f) }, null, 8, ["json"])
3313
+ ];
3314
+ }),
3315
+ _: 1
3316
+ }, 512)) : createCommentVNode("", !0)
3317
+ ]),
3318
+ _: 1
3319
+ }, 8, ["modelValue"]);
3320
+ };
3321
+ }
3322
+ }), _hoisted_1$5 = {
3323
+ key: 0,
3324
+ class: "grid grid-cols-5 text-center gap-8 justify-between items-center w-full"
3325
+ }, _hoisted_2$4 = { class: "flex flex-col gap-0 items-center justify-center" }, _sfc_main$5 = /* @__PURE__ */ defineComponent({
3326
+ __name: "MissionProgress",
3327
+ props: {
3328
+ type: {
3329
+ type: String,
3330
+ required: !0
3331
+ },
3332
+ maxRange: {
3333
+ type: Number,
3334
+ required: !0
3335
+ },
3336
+ currentRange: {
3337
+ type: Number,
3338
+ default: 0
3339
+ },
3340
+ markers: {
3341
+ type: Array,
3342
+ default: () => []
3343
+ }
3344
+ },
3345
+ setup(e) {
3346
+ const r = e, { maxRange: o, currentRange: m, markers: i } = toRefs(r), u = computed(
3347
+ () => Math.min(m.value / o.value * 100, 100)
3348
+ ), l = (n) => n / o.value * 100;
3349
+ return (n, a) => {
3350
+ const s = resolveComponent("FmIcon");
3351
+ return e.type === "STAMP" ? (openBlock(), createElementBlock("div", _hoisted_1$5, [
3352
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(Math.min(unref(o), 40), (y) => (openBlock(), createBlock(s, {
3353
+ class: normalizeClass(
3354
+ unref(m) >= y ? "text-fm-color-primary" : "text-fm-color-neutral-gray-200"
3355
+ ),
3356
+ outline: unref(m) < y,
3357
+ key: y,
3358
+ name: unref(i).some((f) => f === y) ? "featured_seasonal_and_gifts" : "check_circle"
3359
+ }, null, 8, ["class", "outline", "name"]))), 128))
3360
+ ])) : (openBlock(), createElementBlock("div", {
3361
+ key: 1,
3362
+ class: normalizeClass(["relative w-full h-4 rounded-lg", "bg-fm-color-system-warning-100"])
3363
+ }, [
3364
+ createElementVNode("div", {
3365
+ class: normalizeClass(["bg-fm-color-primary", "absolute top-0 left-0 h-full rounded-lg"]),
3366
+ style: normalizeStyle({ width: unref(u) + "%" })
3367
+ }, null, 4),
3368
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(i), (y, f) => (openBlock(), createElementBlock("div", {
3369
+ key: f,
3370
+ class: "absolute -top-1.5 flex flex-col items-center -translate-x-1/2",
3371
+ style: normalizeStyle({ left: l(y) + "%" })
3372
+ }, [
3373
+ createElementVNode("div", _hoisted_2$4, [
3374
+ createElementVNode("div", {
3375
+ class: normalizeClass(["h-16 w-[2px]", "bg-fm-color-system-warning-300"])
3376
+ }),
3377
+ a[0] || (a[0] = createElementVNode("div", null, "🎁", -1))
3378
+ ])
3379
+ ], 4))), 128))
3380
+ ]));
3381
+ };
3382
+ }
3383
+ }), isObject = (e) => e !== null && typeof e == "object";
3384
+ function changeKeysFactory(e) {
3385
+ return function r(o, m = 1, i) {
3386
+ if (m === 0 || !isObject(o))
3387
+ return o;
3388
+ if (Array.isArray(o))
3389
+ return o.map((l) => r(l, m - 1, i));
3390
+ const u = Object.create(Object.getPrototypeOf(o));
3391
+ return Object.keys(o).forEach((l) => {
3392
+ const n = o[l], a = e(l, i), s = r(n, m - 1, i);
3393
+ u[a] = s;
3394
+ }), u;
3395
+ };
3396
+ }
3397
+ const sentenceCase = changeKeysFactory(sentenceCase$1), _hoisted_1$4 = { class: "space-y-16" }, _hoisted_2$3 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$3 = { class: "fm-typo-en-body-lg-400" }, _hoisted_4$2 = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _hoisted_5$2 = { class: "fm-typo-en-title-sm-800" }, _hoisted_6$2 = { class: "flex items-center gap-4" }, _hoisted_7$2 = { class: "fm-typo-en-body-lg-600" }, _hoisted_8$2 = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, _hoisted_9$2 = { class: "flex items-center gap-16" }, _hoisted_10$2 = { key: 0 }, _sfc_main$4 = /* @__PURE__ */ defineComponent({
3398
+ __name: "MissionPoolInput",
3399
+ props: {
3400
+ modelValue: {
3401
+ type: Array,
3402
+ default: () => []
3403
+ },
3404
+ mission: {
3405
+ type: Object,
3406
+ required: !0
3407
+ }
3408
+ },
3409
+ emits: ["update:model-value"],
3410
+ setup(e, { emit: r }) {
3411
+ const { t: o } = useI18n(), m = e, i = r, u = useMembershipStore(), l = z.array(z.lazy(() => FdtoThresholdReward)).min(1, "Requires at least 1 reward"), n = computed(
3412
+ () => m.modelValue.sort((v, d) => v.threshold - d.threshold) ?? []
3413
+ ), a = computed(() => {
3414
+ const v = l.safeParse(n.value);
3415
+ return v.success ? [] : v.error.errors;
3416
+ }), s = ref();
3417
+ function y(v, d) {
3418
+ var C;
3419
+ const p = [...n.value];
3420
+ p[d] = v, (C = s.value) == null || C.showSheet(!1), i("update:model-value", p);
3421
+ }
3422
+ function f(v) {
3423
+ const d = v.type == "VOUCHER" ? v.collectibleConfig : u.collectibles.find(
3424
+ (x) => x._id.toString() == v.collectible
3425
+ ), p = CollectionUtils.formattedType((d == null ? void 0 : d.name) || ""), C = v.earningOption.type == "FIXED" ? o("connect.template.mission_pool.reward_sublabel_fixed", {
3426
+ threshold: v.threshold,
3427
+ amount: v.earningOption.amount
3428
+ }) : o("connect.template.mission_pool.reward_sublabel_per_spend", {
3429
+ threshold: v.threshold,
3430
+ amount: v.earningOption.amount,
3431
+ every: v.earningOption.every
3432
+ });
3433
+ return {
3434
+ label: isNullOrEmpty(p) ? o("connect.template.mission_pool.no_reward") : p,
3435
+ sublabel: C
3436
+ };
3437
+ }
3438
+ function c(v) {
3439
+ var p;
3440
+ const d = [...n.value];
3441
+ (p = s.value) == null || p.showSheet(!0, d[v], v);
3442
+ }
3443
+ function k(v) {
3444
+ const d = [...n.value];
3445
+ d.splice(v, 1), i("update:model-value", d);
3446
+ }
3447
+ function V() {
3448
+ var v;
3449
+ (v = s.value) == null || v.showSheet(
3450
+ !0,
3451
+ {
3452
+ type: "LOYALTY",
3453
+ collectible: u.loyaltyRewards.items[0].value,
3454
+ threshold: null,
3455
+ validityOption: {
3456
+ validForDay: 7
3457
+ },
3458
+ earningOption: {
3459
+ type: "FIXED",
3460
+ amount: 1
3461
+ }
3462
+ },
3463
+ n.value.length
3464
+ );
3465
+ }
3466
+ function g(v) {
3467
+ var d, p;
3468
+ return v.type == "VOUCHER" ? (d = v.collectibleConfig) == null ? void 0 : d.name : sentenceCase(
3469
+ ((p = u.loyaltyRewards.items.find(
3470
+ (C) => C.value == v.collectible
3471
+ )) == null ? void 0 : p.label) || ""
3472
+ );
3473
+ }
3474
+ return (v, d) => {
3475
+ const p = resolveComponent("FmButton"), C = resolveComponent("FmCard"), x = resolveComponent("FmHelperText");
3476
+ return openBlock(), createElementBlock("div", _hoisted_1$4, [
3477
+ createElementVNode("div", _hoisted_2$3, toDisplayString(unref(o)("connect.template.configure_reward_customer")), 1),
3478
+ createVNode(p, {
3479
+ label: unref(o)("connect.template.mission_pool.add_reward"),
3480
+ onClick: d[0] || (d[0] = (N) => V()),
3481
+ variant: "plain",
3482
+ icon: "add"
3483
+ }, null, 8, ["label"]),
3484
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(n), (N, w) => (openBlock(), createBlock(C, {
3485
+ key: w,
3486
+ class: "px-16 py-12 flex items-center justify-between cursor-pointer",
3487
+ variant: "outlined",
3488
+ onClick: ($) => c(w)
3489
+ }, {
3490
+ default: withCtx(() => [
3491
+ createElementVNode("div", null, [
3492
+ createElementVNode("div", _hoisted_3$3, toDisplayString(f(N).label), 1),
3493
+ createElementVNode("div", _hoisted_4$2, toDisplayString(f(N).sublabel), 1)
3494
+ ]),
3495
+ createVNode(p, {
3496
+ icon: "delete",
3497
+ variant: "tertiary",
3498
+ onClick: ($) => ($.stopPropagation(), k(w))
3499
+ }, null, 8, ["onClick"])
3500
+ ]),
3501
+ _: 2
3502
+ }, 1032, ["onClick"]))), 128)),
3503
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(a).filter((N) => N.path.join(".") == ""), (N) => (openBlock(), createBlock(x, {
3504
+ key: N.message,
3505
+ text: N.message,
3506
+ state: "error"
3507
+ }, null, 8, ["text"]))), 128)),
3508
+ createElementVNode("div", _hoisted_5$2, toDisplayString(unref(o)("connect.template.mission_pool.preview")), 1),
3509
+ (openBlock(), createBlock(C, {
3510
+ key: 0,
3511
+ variant: "outlined",
3512
+ class: "p-24 space-y-16 w-fit"
3513
+ }, {
3514
+ default: withCtx(() => {
3515
+ var N, w;
3516
+ return [
3517
+ createElementVNode("div", _hoisted_6$2, [
3518
+ createElementVNode("div", null, [
3519
+ createElementVNode("div", _hoisted_7$2, toDisplayString(unref(o)("connect.template.mission_pool.collect_stamps", { end: e.mission.end })) + " " + toDisplayString(((N = e.modelValue[e.modelValue.length - 1]) == null ? void 0 : N.earningOption.amount) > 1 ? (w = e.modelValue[e.modelValue.length - 1]) == null ? void 0 : w.earningOption.amount : "") + " " + toDisplayString(e.modelValue[e.modelValue.length - 1] ? g(e.modelValue[e.modelValue.length - 1]) : ""), 1),
3520
+ createElementVNode("div", _hoisted_8$2, toDisplayString(unref(o)("connect.template.mission_pool.earn_stamp")), 1)
3521
+ ])
3522
+ ]),
3523
+ createElementVNode("div", _hoisted_9$2, [
3524
+ createVNode(_sfc_main$5, {
3525
+ type: e.mission.type,
3526
+ "max-range": e.mission.end,
3527
+ currentRange: e.mission.end / 4,
3528
+ markers: e.modelValue.map(($) => $.threshold)
3529
+ }, null, 8, ["type", "max-range", "currentRange", "markers"]),
3530
+ e.mission.type == "PROGRESSIVE" ? (openBlock(), createElementBlock("div", _hoisted_10$2, " 0/" + toDisplayString(e.mission.end.toLocaleString()), 1)) : createCommentVNode("", !0)
3531
+ ])
3532
+ ];
3533
+ }),
3534
+ _: 1
3535
+ })),
3536
+ createVNode(_sfc_main$6, {
3537
+ ref_key: "sheetRef",
3538
+ ref: s,
3539
+ "onUpdate:modelValue": y,
3540
+ "max-threshold": e.mission.end
3541
+ }, null, 8, ["max-threshold"])
3542
+ ]);
3543
+ };
3544
+ }
3545
+ }), _hoisted_1$3 = { class: "space-y-16" }, _hoisted_2$2 = { class: "space-y-8" }, _hoisted_3$2 = { class: "fm-typo-en-title-sm-800" }, _hoisted_4$1 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_5$1 = { class: "grid grid-cols-2 gap-16" }, _hoisted_6$1 = { class: "fm-typo-en-title-sm-800" }, _hoisted_7$1 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_8$1 = { class: "space-y-8" }, _hoisted_9$1 = { class: "fm-typo-en-title-sm-800" }, _hoisted_10$1 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$3 = /* @__PURE__ */ defineComponent({
3546
+ __name: "MissionInput",
3547
+ props: {
3548
+ modelValue: Object
3549
+ },
3550
+ emits: ["update:model-value"],
3551
+ setup(e, { emit: r }) {
3552
+ const { t: o } = useI18n(), m = e, i = computed(() => {
3553
+ const n = FdoMission.safeParse(m.modelValue);
3554
+ return n.success ? [] : n.error.errors;
3555
+ }), u = computed(() => [
3556
+ {
3557
+ label: o("connect.campaign.mission.typeOption.STAMP.label"),
3558
+ description: o("connect.campaign.mission.typeOption.STAMP.description"),
3559
+ value: F_MISSION_TYPE.enum.STAMP
3560
+ },
3561
+ {
3562
+ label: o("connect.campaign.mission.typeOption.PROGRESSIVE.label"),
3563
+ description: o("connect.campaign.mission.typeOption.PROGRESSIVE.description"),
3564
+ value: F_MISSION_TYPE.enum.PROGRESSIVE
3565
+ }
3566
+ ]), l = r;
3567
+ return (n, a) => {
3568
+ var f;
3569
+ const s = resolveComponent("FmCard"), y = resolveComponent("FmStepperField");
3570
+ return openBlock(), createElementBlock("div", _hoisted_1$3, [
3571
+ createElementVNode("div", _hoisted_2$2, [
3572
+ createElementVNode("div", _hoisted_3$2, toDisplayString(unref(o)("connect.campaign.mission.missionType")), 1),
3573
+ createElementVNode("div", _hoisted_4$1, toDisplayString(unref(o)("connect.template.select_game")), 1),
3574
+ createElementVNode("div", _hoisted_5$1, [
3575
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(u), (c) => {
3576
+ var k, V;
3577
+ return openBlock(), createBlock(s, {
3578
+ variant: "outlined",
3579
+ class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
3580
+ "col-span-2": unref(u).length == 1,
3581
+ "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": ((k = e.modelValue) == null ? void 0 : k.type) == c.value,
3582
+ "hover:bg-fm-color-opacity-sm": ((V = e.modelValue) == null ? void 0 : V.type) != c.value
3583
+ }]),
3584
+ onClick: () => {
3585
+ var g, v;
3586
+ ((g = e.modelValue) == null ? void 0 : g.type) != c.value && l("update:model-value", {
3587
+ ...e.modelValue,
3588
+ type: c.value,
3589
+ end: ((v = e.modelValue) == null ? void 0 : v.end) || 1
3590
+ });
3591
+ },
3592
+ key: c.value
3593
+ }, {
3594
+ default: withCtx(() => [
3595
+ createElementVNode("div", _hoisted_6$1, toDisplayString(c.label), 1),
3596
+ createElementVNode("div", _hoisted_7$1, toDisplayString(c.description), 1)
3597
+ ]),
3598
+ _: 2
3599
+ }, 1032, ["class", "onClick"]);
3600
+ }), 128))
3601
+ ])
3602
+ ]),
3603
+ createElementVNode("div", _hoisted_8$1, [
3604
+ createElementVNode("div", _hoisted_9$1, toDisplayString(unref(o)("connect.campaign.mission.collectionsRequired")), 1),
3605
+ createElementVNode("div", _hoisted_10$1, toDisplayString(unref(o)("connect.campaign.mission.collectionsRequiredDescription")), 1),
3606
+ createVNode(y, {
3607
+ label: unref(o)("connect.campaign.mission.maximumToCollect"),
3608
+ "model-value": ((f = e.modelValue) == null ? void 0 : f.end) || null,
3609
+ "onUpdate:modelValue": a[0] || (a[0] = (c) => {
3610
+ var k;
3611
+ return l("update:model-value", {
3612
+ ...e.modelValue,
3613
+ type: ((k = e.modelValue) == null ? void 0 : k.type) || "STAMP",
3614
+ end: c
3615
+ });
3616
+ }),
3617
+ "helper-text": unref(ZodHelper).helperText(unref(i), "end") || unref(o)("connect.campaign.mission.thresholdHelperText"),
3618
+ "helper-state": unref(ZodHelper).helperState(unref(i), "end") || "none"
3619
+ }, null, 8, ["label", "model-value", "helper-text", "helper-state"])
3620
+ ])
3621
+ ]);
3622
+ };
3623
+ }
3624
+ });
3625
+ function useLocaleText() {
3626
+ const { locale: e, t: r } = useI18n();
3627
+ function o(m, i) {
3628
+ return m ? m[e.value] ?? m["en-US"] ?? r(i) : r(i);
3629
+ }
3630
+ return { getLocaleText: o };
3631
+ }
3632
+ const _hoisted_1$2 = { key: 29 }, _sfc_main$2 = /* @__PURE__ */ defineComponent({
3633
+ __name: "TemplateInput",
3634
+ props: {
3635
+ pushAvailability: {
3636
+ type: String,
3637
+ default: "checking"
3638
+ },
3639
+ field: { type: Object, required: !0 },
3640
+ modelValue: {
3641
+ type: Object
3642
+ },
3643
+ schema: {
3644
+ type: Object
3645
+ },
3646
+ extras: {
3647
+ type: Object
3648
+ },
3649
+ helperText: {
3650
+ type: String
3651
+ },
3652
+ disabled: {
3653
+ type: Boolean,
3654
+ default: !1
3655
+ },
3656
+ campaignType: {
3657
+ type: String,
3658
+ default: void 0
3659
+ },
3660
+ /** False until the form has been submitted, for fields that validate late. */
3661
+ showValidation: {
3662
+ type: Boolean,
3663
+ default: !0
3664
+ }
3665
+ },
3666
+ emits: ["retry-push", "update:model-value", "update:file"],
3667
+ setup(e, { emit: r }) {
3668
+ const { t: o } = useI18n(), { getLocaleText: m } = useLocaleText(), i = e, u = r;
3669
+ function l(y) {
3670
+ switch (i.field.type) {
3671
+ case "timeframe":
3672
+ const f = y.startDate ? hooks(y.startDate).startOf("day").toISOString() : void 0, c = y.endDate ? hooks(y.endDate).endOf("day").toISOString() : void 0;
3673
+ u("update:model-value", {
3674
+ type: "timeframe",
3675
+ property: "__now",
3676
+ start: f,
3677
+ end: c
3678
+ });
3679
+ break;
3680
+ case "image": {
3681
+ u(
3682
+ "update:file",
3683
+ y,
3684
+ n.value || firebaseStorage.collectibleImagePath(void 0, y)
3685
+ );
3686
+ break;
3687
+ }
3688
+ default:
3689
+ u("update:model-value", y);
3690
+ break;
3691
+ }
3692
+ }
3693
+ const n = computed(() => {
3694
+ switch (i.field.type) {
3695
+ case "timeframe": {
3696
+ const y = i.modelValue;
3697
+ return {
3698
+ startDate: y != null && y.start ? hooks(y == null ? void 0 : y.start).format("YYYY-MM-DD") : null,
3699
+ endDate: y != null && y.end ? hooks(y == null ? void 0 : y.end).format("YYYY-MM-DD") : null
3700
+ };
3701
+ }
3702
+ default:
3703
+ return i.modelValue;
3704
+ }
3705
+ });
3706
+ function a() {
3707
+ if (!s.value.schema) return [];
3708
+ const y = s.value.schema.safeParse(i.modelValue);
3709
+ return y.success ? [] : y.error.errors;
3710
+ }
3711
+ const s = computed(() => ({
3712
+ schema: i.schema,
3713
+ unwrapped: i.schema ? ZodHelper.unwrap(i.schema) : void 0,
3714
+ rules: i.schema ? [ZodHelper.ruleAtPath(i.schema, "")] : void 0,
3715
+ labelMark: i.schema && ZodHelper.isRequired(i.schema) == !1 ? "optional" : void 0,
3716
+ zodLabel: i.schema ? ZodHelper.toInputLabel(
3717
+ i.schema,
3718
+ m(i.field.label_locale, i.field.label ?? "")
3719
+ ) : void 0
3720
+ }));
3721
+ return (y, f) => {
3722
+ var d, p, C, x, N;
3723
+ const c = resolveComponent("FmTextField"), k = resolveComponent("FmStepperField"), V = resolveComponent("FmTextarea"), g = resolveComponent("FmHelperText"), v = resolveComponent("FmSwitch");
3724
+ return e.field.type === "text" ? (openBlock(), createBlock(c, {
3725
+ key: 0,
3726
+ label: unref(m)(e.field.label_locale, e.field.label ?? ""),
3727
+ "label-mark": unref(s).labelMark,
3728
+ rules: unref(s).rules,
3729
+ "model-value": unref(n),
3730
+ "onUpdate:modelValue": l,
3731
+ "helper-state": e.helperText ? "error" : void 0,
3732
+ "helper-text": e.helperText
3733
+ }, null, 8, ["label", "label-mark", "rules", "model-value", "helper-state", "helper-text"])) : e.field.type === "number" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
3734
+ createVNode(JsonViewer, {
3735
+ json: { schema: unref(s).unwrapped, props: i }
3736
+ }, null, 8, ["json"]),
3737
+ createVNode(k, {
3738
+ label: unref(m)(e.field.label_locale, e.field.label ?? ""),
3739
+ "label-mark": e.field.isRuleChildren ? void 0 : unref(s).labelMark,
3740
+ "model-value": unref(n),
3741
+ rules: e.field.isRuleChildren ? [] : unref(s).rules,
3742
+ "onUpdate:modelValue": l,
3743
+ "helper-state": e.field.isRuleChildren && e.helperText ? "error" : void 0,
3744
+ "helper-text": e.field.isRuleChildren ? e.helperText : void 0
3745
+ }, null, 8, ["label", "label-mark", "model-value", "rules", "helper-state", "helper-text"])
3746
+ ], 64)) : e.field.type === "textarea" ? (openBlock(), createBlock(V, {
3747
+ key: 2,
3748
+ label: unref(m)(e.field.label_locale, e.field.label ?? ""),
3749
+ "label-mark": unref(s).labelMark,
3750
+ rules: unref(s).rules,
3751
+ "model-value": unref(n),
3752
+ "onUpdate:modelValue": l,
3753
+ "show-word-count": "",
3754
+ "max-length": (N = (x = (C = (p = (d = unref(s)) == null ? void 0 : d.unwrapped) == null ? void 0 : p._def) == null ? void 0 : C.checks) == null ? void 0 : x.find((w) => w.kind == "max")) == null ? void 0 : N.value
3755
+ }, null, 8, ["label", "label-mark", "rules", "model-value", "max-length"])) : e.field.type === "trigger" ? (openBlock(), createBlock(_sfc_main$o, {
3756
+ key: 3,
3757
+ "campaign-type": e.extras,
3758
+ "model-value": unref(n),
3759
+ disabled: e.disabled,
3760
+ "onUpdate:modelValue": l
3761
+ }, null, 8, ["campaign-type", "model-value", "disabled"])) : e.field.type === "timeframe" ? (openBlock(), createElementBlock(Fragment, { key: 4 }, [
3762
+ createVNode(_sfc_main$m, {
3763
+ "model-value": unref(n),
3764
+ "onUpdate:modelValue": l
3765
+ }, null, 8, ["model-value"]),
3766
+ createVNode(g, {
3767
+ class: "!mt-[8px]",
3768
+ text: unref(ZodHelper).helperText(a(), ""),
3769
+ state: unref(ZodHelper).helperState(a(), "")
3770
+ }, null, 8, ["text", "state"])
3771
+ ], 64)) : e.field.type === "image" ? (openBlock(), createBlock(_sfc_main$C, {
3772
+ key: 5,
3773
+ thumbnail: unref(n),
3774
+ "aspect-ratio": "16 / 9",
3775
+ class: "w-1/2 xs:w-2/3",
3776
+ "onUpdate:file": l
3777
+ }, {
3778
+ label: withCtx(() => [
3779
+ (openBlock(), createBlock(resolveDynamicComponent(unref(s).zodLabel)))
3780
+ ]),
3781
+ _: 1
3782
+ }, 8, ["thumbnail"])) : e.field.type === "switch" ? (openBlock(), createBlock(v, {
3783
+ key: 6,
3784
+ label: unref(m)(e.field.label_locale, e.field.label ?? ""),
3785
+ "label-placement": "right",
3786
+ sublabel: e.field.property == "campaign.notify" ? "Notify customer when customer receives the reward" : void 0,
3787
+ "label-mark": unref(s).labelMark,
3788
+ rules: unref(s).rules,
3789
+ "model-value": unref(n),
3790
+ "onUpdate:modelValue": l
3791
+ }, null, 8, ["label", "sublabel", "label-mark", "rules", "model-value"])) : e.field.type === "collectible_options" ? (openBlock(), createBlock(_sfc_main$D, {
3792
+ key: 7,
3793
+ "model-value": unref(n),
3794
+ "onUpdate:modelValue": l,
3795
+ "no-campaign": !1,
3796
+ schema: unref(s).schema,
3797
+ "is-mission": e.extras === "MISSION"
3798
+ }, null, 8, ["model-value", "schema", "is-mission"])) : e.field.type === "grab_conditions" ? (openBlock(), createBlock(GrabConditionsInput, {
3799
+ key: 8,
3800
+ "model-value": unref(n),
3801
+ "onUpdate:modelValue": l,
3802
+ schema: unref(s).schema
3803
+ }, null, 8, ["model-value", "schema"])) : e.field.type === "grab_quota" ? (openBlock(), createBlock(_sfc_main$9, {
3804
+ key: 9,
3805
+ "model-value": unref(n),
3806
+ "onUpdate:modelValue": l,
3807
+ schema: unref(s).schema
3808
+ }, null, 8, ["model-value", "schema"])) : e.field.type === "target_location" ? (openBlock(), createBlock(_sfc_main$E, {
3809
+ key: 10,
3810
+ "model-value": unref(n),
3811
+ "onUpdate:modelValue": l
3812
+ }, null, 8, ["model-value"])) : e.field.type == "effect" ? (openBlock(), createElementBlock(Fragment, { key: 11 }, [
3813
+ createVNode(_sfc_main$F, {
3814
+ "model-value": unref(n),
3815
+ "onUpdate:modelValue": l,
3816
+ "can-set-auto-apply": e.field.property == "campaign.effect"
3817
+ }, null, 8, ["model-value", "can-set-auto-apply"]),
3818
+ unref(n) ? createCommentVNode("", !0) : (openBlock(), createBlock(g, {
3819
+ key: 0,
3820
+ class: "!mt-[8px]",
3821
+ text: unref(o)("connect.campaign.common.effect_required"),
3822
+ state: "error"
3823
+ }, null, 8, ["text"]))
3824
+ ], 64)) : e.field.type == "grab_effect" ? (openBlock(), createElementBlock(Fragment, { key: 12 }, [
3825
+ createVNode(GrabEffectSheet, {
3826
+ "model-value": unref(n),
3827
+ "onUpdate:modelValue": l
3828
+ }, null, 8, ["model-value"]),
3829
+ unref(n) ? createCommentVNode("", !0) : (openBlock(), createBlock(g, {
3830
+ key: 0,
3831
+ class: "!mt-[8px]",
3832
+ text: unref(o)("connect.campaign.common.effect_required"),
3833
+ state: "error"
3834
+ }, null, 8, ["text"]))
3835
+ ], 64)) : e.field.type === "message" ? (openBlock(), createElementBlock(Fragment, { key: 13 }, [
3836
+ e.field.property === "campaign.message" ? (openBlock(), createBlock(_sfc_main$g, {
3837
+ key: 0,
3838
+ "push-availability": e.pushAvailability,
3839
+ onRetryPush: f[0] || (f[0] = (w) => u("retry-push")),
3840
+ "show-validation": e.showValidation,
3841
+ "model-value": unref(n),
3842
+ "onUpdate:modelValue": l,
3843
+ "helper-text": unref(ZodHelper).helperText(a(), ""),
3844
+ "trigger-type": e.field.extras,
3845
+ "helper-state": unref(ZodHelper).helperState(a(), "")
3846
+ }, null, 8, ["push-availability", "show-validation", "model-value", "helper-text", "trigger-type", "helper-state"])) : (openBlock(), createBlock(_sfc_main$x, {
3847
+ key: 1,
3848
+ "allow-email": !0,
3849
+ "allow-whatsapp": !0,
3850
+ "model-value": unref(n),
3851
+ "onUpdate:modelValue": l,
3852
+ "helper-text": unref(ZodHelper).helperText(a(), ""),
3853
+ "trigger-type": e.field.extras,
3854
+ "helper-state": unref(ZodHelper).helperState(a(), "")
3855
+ }, null, 8, ["model-value", "helper-text", "trigger-type", "helper-state"]))
3856
+ ], 64)) : e.field.type === "earning_option" ? (openBlock(), createBlock(_sfc_main$z, {
3857
+ key: 14,
3858
+ "model-value": unref(n),
3859
+ "onUpdate:modelValue": l,
3860
+ extras: e.extras,
3861
+ "error-text": e.helperText
3862
+ }, null, 8, ["model-value", "extras", "error-text"])) : e.field.type === "validity_option" ? (openBlock(), createBlock(_sfc_main$A, {
3863
+ key: 15,
3864
+ type: "custom",
3865
+ "model-value": unref(n),
3866
+ "onUpdate:modelValue": l,
3867
+ "helper-text": e.helperText || unref(ZodHelper).helperText(a(), ""),
3868
+ "for-credit": i.campaignType === "CREDIT"
3869
+ }, null, 8, ["model-value", "helper-text", "for-credit"])) : e.field.type === "game_type" ? (openBlock(), createBlock(_sfc_main$e, {
3870
+ key: 16,
3871
+ "model-value": unref(n),
3872
+ "onUpdate:modelValue": l
3873
+ }, null, 8, ["model-value"])) : e.field.type === "reward_pool" ? (openBlock(), createBlock(_sfc_main$c, {
3874
+ key: 17,
3875
+ "model-value": unref(n),
3876
+ "onUpdate:modelValue": l
3877
+ }, null, 8, ["model-value"])) : e.field.type === "mission" ? (openBlock(), createBlock(_sfc_main$3, {
3878
+ key: 18,
3879
+ "model-value": unref(n),
3880
+ "onUpdate:modelValue": l
3881
+ }, null, 8, ["model-value"])) : e.field.type === "mission_type" ? (openBlock(), createBlock(_sfc_main$8, {
3882
+ key: 19,
3883
+ "model-value": unref(n),
3884
+ "onUpdate:modelValue": l
3885
+ }, null, 8, ["model-value"])) : e.field.type === "mission_end" ? (openBlock(), createBlock(_sfc_main$7, {
3886
+ key: 20,
3887
+ "model-value": unref(n),
3888
+ "onUpdate:modelValue": l,
3889
+ "helper-text": unref(ZodHelper).helperText(a(), ""),
3890
+ "helper-state": unref(ZodHelper).helperState(a(), "")
3891
+ }, null, 8, ["model-value", "helper-text", "helper-state"])) : e.field.type === "mission_pool" ? (openBlock(), createBlock(_sfc_main$4, {
3892
+ key: 21,
3893
+ "model-value": unref(n),
3894
+ "onUpdate:modelValue": l,
3895
+ mission: e.extras.mission
3896
+ }, null, 8, ["model-value", "mission"])) : e.field.type === "rule_schedule" ? (openBlock(), createElementBlock(Fragment, { key: 22 }, [
3897
+ createVNode(_sfc_main$f, {
3898
+ "model-value": unref(n),
3899
+ "onUpdate:modelValue": l,
3900
+ "start-date": e.extras.start,
3901
+ "end-date": e.extras.end
3902
+ }, null, 8, ["model-value", "start-date", "end-date"]),
3903
+ e.helperText ? (openBlock(), createBlock(g, {
3904
+ key: 0,
3905
+ class: "!mt-[8px]",
3906
+ text: e.helperText,
3907
+ state: "error"
3908
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
3909
+ ], 64)) : e.field.type === "rule_user" ? (openBlock(), createElementBlock(Fragment, { key: 23 }, [
3910
+ createVNode(_sfc_main$G, {
3911
+ "model-value": unref(n),
3912
+ "onUpdate:modelValue": l
3913
+ }, null, 8, ["model-value"]),
3914
+ e.helperText ? (openBlock(), createBlock(g, {
3915
+ key: 0,
3916
+ class: "!mt-[8px]",
3917
+ text: e.helperText,
3918
+ state: "error"
3919
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
3920
+ ], 64)) : e.field.type === "rule_time" ? (openBlock(), createElementBlock(Fragment, { key: 24 }, [
3921
+ e.extras == "PROMOTION" && unref(RuleBuilder).getRules(unref(n).rules.g_time).length > 0 ? (openBlock(), createBlock(g, {
3922
+ key: 0,
3923
+ state: "warning",
3924
+ text: `Time based rule only work for POS >= v${unref(featureVersionMapping).TIME_BASED_PROMOTION}`
3925
+ }, null, 8, ["text"])) : createCommentVNode("", !0),
3926
+ createVNode(_sfc_main$q, {
3927
+ "model-value": unref(n),
3928
+ "onUpdate:modelValue": l
3929
+ }, null, 8, ["model-value"]),
3930
+ e.helperText ? (openBlock(), createBlock(g, {
3931
+ key: 1,
3932
+ class: "!mt-[8px]",
3933
+ text: e.helperText,
3934
+ state: "error"
3935
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
3936
+ ], 64)) : e.field.type === "rule_bill" ? (openBlock(), createElementBlock(Fragment, { key: 25 }, [
3937
+ createVNode(_sfc_main$H, {
3938
+ "model-value": unref(n),
3939
+ "onUpdate:modelValue": l
3940
+ }, null, 8, ["model-value"]),
3941
+ e.helperText ? (openBlock(), createBlock(g, {
3942
+ key: 0,
3943
+ class: "!mt-[8px]",
3944
+ text: e.helperText,
3945
+ state: "error"
3946
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
3947
+ ], 64)) : e.field.type === "rule_feedback" ? (openBlock(), createElementBlock(Fragment, { key: 26 }, [
3948
+ createVNode(_sfc_main$I, {
3949
+ "model-value": unref(n),
3950
+ "onUpdate:modelValue": l
3951
+ }, null, 8, ["model-value"]),
3952
+ e.helperText ? (openBlock(), createBlock(g, {
3953
+ key: 0,
3954
+ class: "!mt-[8px]",
3955
+ text: e.helperText,
3956
+ state: "error"
3957
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
3958
+ ], 64)) : e.field.type === "rule_birthday" ? (openBlock(), createElementBlock(Fragment, { key: 27 }, [
3959
+ createVNode(_sfc_main$p, {
3960
+ "model-value": unref(n),
3961
+ "onUpdate:modelValue": l
3962
+ }, null, 8, ["model-value"]),
3963
+ e.helperText ? (openBlock(), createBlock(g, {
3964
+ key: 0,
3965
+ class: "!mt-[8px]",
3966
+ text: e.helperText,
3967
+ state: "error"
3968
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
3969
+ ], 64)) : e.field.type === "promotion_game_type" ? (openBlock(), createElementBlock(Fragment, { key: 28 }, [
3970
+ createVNode(_sfc_main$b, {
3971
+ "model-value": unref(n),
3972
+ "onUpdate:modelValue": l
3973
+ }, null, 8, ["model-value"]),
3974
+ e.helperText ? (openBlock(), createBlock(g, {
3975
+ key: 0,
3976
+ class: "!mt-[8px]",
3977
+ text: e.helperText,
3978
+ state: "error"
3979
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
3980
+ ], 64)) : (openBlock(), createElementBlock("pre", _hoisted_1$2, toDisplayString(i.field), 1));
3981
+ };
3982
+ }
3983
+ }), _hoisted_1$1 = { class: "fm-typo-en-body-lg-600" }, _hoisted_2$1 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$1 = { class: "fm-typo-en-body-lg-600" }, _sfc_main$1 = /* @__PURE__ */ defineComponent({
3984
+ __name: "CampaignSummary",
3985
+ props: {
3986
+ data: {
3987
+ type: Object,
3988
+ required: !0
3989
+ }
3990
+ },
3991
+ setup(e) {
3992
+ const { t: r, te: o } = useI18n();
3993
+ function m(i) {
3994
+ return o(i) || o(i, "en-US");
3995
+ }
3996
+ return (i, u) => {
3997
+ const l = resolveComponent("FmCard");
3998
+ return openBlock(), createBlock(l, {
3999
+ variant: "outlined",
4000
+ class: "p-16 space-y-8"
4001
+ }, {
4002
+ default: withCtx(() => [
4003
+ createElementVNode("div", _hoisted_1$1, toDisplayString(unref(r)("connect.campaign.common.summary")), 1),
4004
+ u[0] || (u[0] = createElementVNode("div", { class: "h-[1px] bg-fm-color-neutral-gray-100 w-full" }, null, -1)),
4005
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(getCampaignSummaryObject)(e.data), (n, a) => (openBlock(), createElementBlock("div", {
4006
+ class: "space-y-4",
4007
+ key: a
4008
+ }, [
4009
+ n ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
4010
+ createElementVNode("div", _hoisted_2$1, toDisplayString(unref(r)(`${a}`)), 1),
4011
+ createElementVNode("div", _hoisted_3$1, toDisplayString(m(`${n}`) ? unref(r)(`${n}`) : n), 1)
4012
+ ], 64)) : createCommentVNode("", !0)
4013
+ ]))), 128))
4014
+ ]),
4015
+ _: 1
4016
+ });
4017
+ };
4018
+ }
4019
+ }), _hoisted_1 = { class: "xs:hidden px-24 pb-[14px] pt-[22px] flex items-center justify-between w-full border-b" }, _hoisted_2 = { class: "flex items-center gap-8" }, _hoisted_3 = {
4020
+ key: 0,
4021
+ class: "max-w-6xl mx-auto"
4022
+ }, _hoisted_4 = { class: "hidden xs:!flex gap-8 items-center w-full px-16 py-8 border-b border-fm-color-neutral-gray-100" }, _hoisted_5 = { class: "grid grid-cols-3 gap-40" }, _hoisted_6 = { class: "col-span-2 space-y-40 xs:col-span-3 xs:px-16 xs:pt-16" }, _hoisted_7 = { class: "fm-typo-en-title-sm-800 !mb-[-8px]" }, _hoisted_8 = { class: "w-full flex items-center justify-end gap-8 pb-24" }, _hoisted_9 = { class: "max-w-6xl mx-auto rounded-md p-4 w-full" }, _hoisted_10 = { class: "animate-pulse flex space-x-4 pt-16" }, _hoisted_11 = { class: "grid grid-cols-3 w-full gap-40" }, _sfc_main = /* @__PURE__ */ defineComponent({
4023
+ __name: "EditCampaignSheet",
4024
+ emits: ["submit:model-value"],
4025
+ setup(__props, { expose: __expose, emit: __emit }) {
4026
+ const Dialog = useDialog(), sheetVisible = ref(!1), { t } = useI18n(), { getLocaleText } = useLocaleText(), currentStep = ref(1), data = ref(), schema = ref(z.any()), template = ref(
4027
+ TEMPLATES.VOUCHER
4028
+ ), { minor } = useLoading, isLoading = ref(!1), sheetTitle = ref("Create Campaign"), campaignType = ref("VOUCHER"), pushAvailability = ref("checking");
4029
+ let availabilityRequest = 0;
4030
+ async function checkPushAvailability() {
4031
+ const e = ++availabilityRequest, r = SvcConfig.getBusinessId();
4032
+ pushAvailability.value = "checking";
4033
+ try {
4034
+ if (!r) throw new Error("Business ID is unavailable");
4035
+ const m = await getNativeApp(r);
4036
+ o() && (pushAvailability.value = m ? "native" : "non-native");
4037
+ } catch {
4038
+ o() && (pushAvailability.value = "failed");
4039
+ }
4040
+ function o() {
4041
+ return e === availabilityRequest && sheetVisible.value && campaignType.value === "BROADCAST" && SvcConfig.getBusinessId() === r;
4042
+ }
4043
+ }
4044
+ watch(
4045
+ sheetVisible,
4046
+ (e) => {
4047
+ e || ++availabilityRequest;
4048
+ },
4049
+ { flush: "sync" }
4050
+ ), onBeforeUnmount(() => {
4051
+ ++availabilityRequest;
4052
+ });
4053
+ const pushBlocked = computed(
4054
+ () => {
4055
+ var e;
4056
+ return campaignType.value === "BROADCAST" && toDelivery(((e = data.value) == null ? void 0 : e.campaign) ?? {}).channels.includes("PUSH") && pushAvailability.value !== "native";
4057
+ }
4058
+ );
4059
+ async function showSheet(visible, type, campaign, selectedTemplate) {
4060
+ var e, r, o;
4061
+ if (sheetVisible.value = visible, campaignType.value = type, ++availabilityRequest, visible && type === "BROADCAST" && checkPushAvailability(), visible == !0) {
4062
+ try {
4063
+ isLoading.value = visible, await useMembershipStore().readRewards(), await useBusinessStore().readLocations(), await useMembershipStore().readSegments(), await useMembershipStore().readMembership();
4064
+ } catch {
4065
+ } finally {
4066
+ await new Promise((m) => setTimeout(m, 120)), isLoading.value = !1;
4067
+ }
4068
+ console.log(
4069
+ TEMPLATES[type],
4070
+ "base template"
4071
+ ), template.value = selectedTemplate ?? TEMPLATES[type], schema.value = CampaignDtos[type], type === "VOUCHER" && (await useCampaignStore().read(), schema.value = schema.value.superRefine((m, i) => {
4072
+ var u;
4073
+ if (m.campaign.type === "VOUCHER" && m.campaign.code) {
4074
+ const l = (u = m.campaign._id) == null ? void 0 : u.toString();
4075
+ useCampaignStore().campaigns.voucher.some(
4076
+ (n) => n.code === m.campaign.code && n._id.toString() !== l
4077
+ ) && i.addIssue({
4078
+ code: "custom",
4079
+ message: "Code already exists, please use another code",
4080
+ path: ["campaign", "code"]
4081
+ });
4082
+ }
4083
+ })), data.value = campaign != null ? { ...campaign, templateId: (e = campaign.template) == null ? void 0 : e._id } : _.cloneDeep({
4084
+ ...(r = template.value) == null ? void 0 : r.defaultValue
4085
+ }), "configs" in data.value && typeof data.value.configs == "string" && (data.value.configs = eval(data.value.configs)), data.value = cleanPF(data.value), type === "BROADCAST" && normaliseBroadcastDelivery(data.value.campaign), data.value.templateId = SvcConfig.getBusinessId(), data.value.campaign.business = SvcConfig.getBusinessId(), data.value.campaign.templateId = SvcConfig.getBusinessId(), "configs" in data.value && (data.value.configs.business = SvcConfig.getBusinessId()), currentStep.value = 1, submitAttempted.value = !1, sheetTitle.value = (o = campaign == null ? void 0 : campaign.campaign) != null && o._id ? t("connect.campaign.common.edit_campaign_title", {
4086
+ typeName: t(`connect.campaign.common.typeName.${type}`)
4087
+ }) : t("connect.campaign.common.create_campaign_title", {
4088
+ typeName: t(`connect.campaign.common.typeName.${type}`)
4089
+ });
4090
+ }
4091
+ }
4092
+ async function hideSheet() {
4093
+ Dialog.open({
4094
+ title: t("connect.campaign.common.unsaved_changes"),
4095
+ message: t("connect.campaign.common.unsaved_changes"),
4096
+ primaryActions: {
4097
+ text: t("connect.campaign.common.unsaved_changes_confirm"),
4098
+ close: !0
4099
+ },
4100
+ secondaryActions: {
4101
+ text: t("connect.campaign.common.unsaved_changes_cancel"),
4102
+ close: !1
4103
+ }
4104
+ }).onPrimary(() => {
4105
+ sheetVisible.value = !1;
4106
+ }).onSecondary(() => {
4107
+ Dialog.close();
4108
+ });
4109
+ }
4110
+ const emits = __emit, errors = computed(() => {
4111
+ const e = schema.value.superRefine(campaignRefinement).safeParse(data.value), r = e.success ? [] : [...e.error.errors];
4112
+ return pushBlocked.value && r.push({
4113
+ code: "custom",
4114
+ path: ["campaign", "delivery", "channels"],
4115
+ message: t(
4116
+ "connect.campaign.broadcast.pushAvailability.removeBeforeSave"
4117
+ )
4118
+ }), r;
4119
+ });
4120
+ function stepErrors(e = currentStep.value - 1) {
4121
+ const r = template.value.steps[e].groups.flatMap(
4122
+ (o) => o.fields.map((m) => schemaPathForField(m.property))
4123
+ );
4124
+ return errors.value.filter(
4125
+ (o) => r.some((m) => o.path.join(".").includes(m))
4126
+ );
4127
+ }
4128
+ const validateOnSubmit = computed(() => campaignType.value === "BROADCAST"), submitAttempted = ref(!1), showValidation = computed(
4129
+ () => !validateOnSubmit.value || submitAttempted.value
4130
+ ), visibleErrors = computed(
4131
+ () => showValidation.value ? errors.value : []
4132
+ );
4133
+ function hasVisibleStepErrors(e) {
4134
+ return showValidation.value && stepErrors(e).length > 0;
4135
+ }
4136
+ function isNextDisabled() {
4137
+ return validateOnSubmit.value ? !1 : currentStep.value - 1 < template.value.steps.length - 1 ? stepErrors().length > 0 : errors.value.length > 0;
4138
+ }
4139
+ function onNext() {
4140
+ if (stepErrors().length > 0) {
4141
+ submitAttempted.value = !0;
4142
+ return;
4143
+ }
4144
+ submitAttempted.value = !1, currentStep.value++;
4145
+ }
4146
+ __expose({ showSheet });
4147
+ function showSummaryDialog() {
4148
+ Dialog.open({
4149
+ title: "",
4150
+ dialogComponent: _sfc_main$1,
4151
+ dialogComponentProps: {
4152
+ data: data.value
4153
+ }
4154
+ });
4155
+ }
4156
+ const broadcastDelivery = computed(
4157
+ () => {
4158
+ var e;
4159
+ return (e = data.value) != null && e.campaign ? toDelivery(data.value.campaign) : void 0;
4160
+ }
4161
+ );
4162
+ function valueForField(e) {
4163
+ return e === "campaign.message" ? broadcastDelivery.value : _.get(data.value, e);
4164
+ }
4165
+ function schemaPathForField(e) {
4166
+ return e === "campaign.message" ? "campaign.delivery" : e;
4167
+ }
4168
+ function onUpdateProperty(e, r) {
4169
+ var o, m, i, u, l, n, a, s;
4170
+ if (e === "campaign.message" && r && "channels" in r) {
4171
+ _.set(data.value, "campaign.delivery", r);
4172
+ const y = toLegacyMessage(r);
4173
+ y ? _.set(data.value, "campaign.message", y) : delete data.value.campaign.message;
4174
+ return;
4175
+ }
4176
+ if (_.set(data.value, e, r), e == "campaign.event.type") {
4177
+ const f = ((u = (i = (m = (o = template.value) == null ? void 0 : o.defaultValue) == null ? void 0 : m.campaign) == null ? void 0 : i.event) == null ? void 0 : u.rule) ? _.cloneDeep({
4178
+ ...(s = (a = (n = (l = template.value) == null ? void 0 : l.defaultValue) == null ? void 0 : n.campaign) == null ? void 0 : a.event) == null ? void 0 : s.rule
4179
+ }) : RuleBuilder.setRuleToGroup(RuleBuilder.scaffoldGroup(), [
4180
+ RuleBuilder.scaffoldGroup("g_schedule"),
4181
+ RuleBuilder.scaffoldGroup("g_time"),
4182
+ RuleBuilder.scaffoldGroup("g_user"),
4183
+ RuleBuilder.scaffoldGroup("g_bill")
4184
+ ]), c = RuleBuilder.setRuleToGroup(
4185
+ RuleBuilder.scaffoldGroup("g_schedule"),
4186
+ [
4187
+ RuleBuilder.constructEntry(
4188
+ "trigger.date",
4189
+ "_rrule",
4190
+ "RRULE:FREQ=DAILY;INTERVAL=1;BYHOUR=0;BYMINUTE=0;BYSECOND=0;WKST=SU"
4191
+ ),
4192
+ RuleBuilder.constructEntry("trigger.time", "_isOnTime", "00:00")
4193
+ ],
4194
+ "&&"
4195
+ );
4196
+ if (r != "SCHEDULE") {
4197
+ _.set(data.value, "campaign.event.rule", f);
4198
+ return;
4199
+ }
4200
+ _.set(
4201
+ data.value,
4202
+ "campaign.event.rule",
4203
+ RuleBuilder.setRuleToGroup(f, c)
4204
+ );
4205
+ }
4206
+ e == "campaign.notify" && r == !1 && _.set(data.value, "campaign.notifyMessage", void 0);
4207
+ }
4208
+ async function onUpdateFile(e, r) {
4209
+ return e ? await minor(async () => firebaseStorage.update(r, e), {
4210
+ message: `${e ? "Uploading" : "Removing"} file`,
4211
+ successMessage: `File ${e ? "uploaded" : "removed"} successfully`
4212
+ }) : "";
4213
+ }
4214
+ function isDisable(e) {
4215
+ var r, o;
4216
+ switch (e == null ? void 0 : e.property) {
4217
+ case "campaign.event.type":
4218
+ return ((o = (r = data.value) == null ? void 0 : r.campaign) == null ? void 0 : o._id) || !1;
4219
+ default:
4220
+ return !1;
4221
+ }
4222
+ }
4223
+ async function onSubmit() {
4224
+ if (submitAttempted.value = !0, pushBlocked.value) return;
4225
+ const e = schema.value.superRefine(campaignRefinement).transform(campaignTransform).safeParse(data.value);
4226
+ if (!e.success)
4227
+ return;
4228
+ const r = await emits(
4229
+ "submit:model-value",
4230
+ cleanPF(JSON.parse(JSON.stringify(e.data)))
4231
+ );
4232
+ (r || r === void 0) && (sheetVisible.value = !1);
4233
+ }
4234
+ return (e, r) => {
4235
+ const o = resolveComponent("FmButton"), m = resolveComponent("FmStep"), i = resolveComponent("FmStepper"), u = resolveComponent("FmCard"), l = resolveComponent("FmTopSheet");
4236
+ return openBlock(), createBlock(l, {
4237
+ "fullscreen-size": "lg",
4238
+ modelValue: unref(sheetVisible),
4239
+ "onUpdate:modelValue": [
4240
+ r[7] || (r[7] = (n) => isRef(sheetVisible) ? sheetVisible.value = n : null),
4241
+ r[8] || (r[8] = (n) => sheetVisible.value = n)
4242
+ ]
4243
+ }, createSlots({
4244
+ "top-sheet-header": withCtx(() => [
4245
+ createElementVNode("div", _hoisted_1, [
4246
+ createElementVNode("div", null, toDisplayString(unref(sheetTitle)), 1),
4247
+ createElementVNode("div", _hoisted_2, [
4248
+ createVNode(o, {
4249
+ onClick: r[0] || (r[0] = (n) => hideSheet()),
4250
+ label: unref(t)("connect.campaign.common.cancel"),
4251
+ variant: "tertiary"
4252
+ }, null, 8, ["label"]),
4253
+ createVNode(o, {
4254
+ onClick: onSubmit,
4255
+ label: unref(t)("connect.campaign.common.save"),
4256
+ disabled: !unref(validateOnSubmit) && unref(errors).length > 0
4257
+ }, null, 8, ["label", "disabled"])
4258
+ ])
4259
+ ])
4260
+ ]),
4261
+ _: 2
4262
+ }, [
4263
+ unref(isLoading) ? {
4264
+ name: "default",
4265
+ fn: withCtx(() => [
4266
+ createElementVNode("div", _hoisted_9, [
4267
+ createElementVNode("div", _hoisted_10, [
4268
+ createElementVNode("div", _hoisted_11, [
4269
+ r[9] || (r[9] = createElementVNode("div", { class: "col-span-2 space-y-80 xs:col-span-3 xs:px-16 xs:pt-16" }, [
4270
+ createElementVNode("div", { class: "flex-1 space-y-6 py-1" }, [
4271
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100 rounded" }),
4272
+ createElementVNode("div", { class: "h-[80px] bg-fm-color-neutral-gray-100 rounded" }),
4273
+ createElementVNode("div", { class: "space-y-3" }, [
4274
+ createElementVNode("div", { class: "grid grid-cols-2 gap-4" }, [
4275
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" }),
4276
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
4277
+ ]),
4278
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
4279
+ ]),
4280
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100 rounded" }),
4281
+ createElementVNode("div", { class: "h-[80px] bg-fm-color-neutral-gray-100 rounded" }),
4282
+ createElementVNode("div", { class: "space-y-3" }, [
4283
+ createElementVNode("div", { class: "grid grid-cols-2 gap-4" }, [
4284
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" }),
4285
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
4286
+ ]),
4287
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
4288
+ ])
4289
+ ])
4290
+ ], -1)),
4291
+ createVNode(u, { class: "h-[150px] bg-fm-color-neutral-gray-100" })
4292
+ ])
4293
+ ])
4294
+ ])
4295
+ ]),
4296
+ key: "1"
4297
+ } : {
4298
+ name: "default",
4299
+ fn: withCtx(() => [
4300
+ unref(data) ? (openBlock(), createElementBlock("div", _hoisted_3, [
4301
+ createVNode(i, {
4302
+ modelValue: unref(currentStep),
4303
+ "onUpdate:modelValue": r[1] || (r[1] = (n) => isRef(currentStep) ? currentStep.value = n : null),
4304
+ orientation: "horizontal",
4305
+ class: "xs:hidden mx-[-24px] mt-16 mb-24 flex-1"
4306
+ }, {
4307
+ default: withCtx(() => [
4308
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(template).steps, (n, a) => (openBlock(), createBlock(m, {
4309
+ key: n.name,
4310
+ title: unref(getLocaleText)(n.name_locale, n.name),
4311
+ value: a + 1,
4312
+ error: () => hasVisibleStepErrors(a),
4313
+ complete: () => a + 1 <= unref(currentStep)
4314
+ }, null, 8, ["title", "value", "error", "complete"]))), 128))
4315
+ ]),
4316
+ _: 1
4317
+ }, 8, ["modelValue"]),
4318
+ createElementVNode("div", _hoisted_4, [
4319
+ createVNode(o, {
4320
+ icon: "close",
4321
+ variant: "tertiary",
4322
+ onClick: r[2] || (r[2] = (n) => sheetVisible.value = !1)
4323
+ }),
4324
+ createVNode(i, {
4325
+ modelValue: unref(currentStep),
4326
+ "onUpdate:modelValue": r[3] || (r[3] = (n) => isRef(currentStep) ? currentStep.value = n : null),
4327
+ orientation: "horizontal",
4328
+ class: "flex-1"
4329
+ }, {
4330
+ default: withCtx(() => [
4331
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(template).steps, (n, a) => (openBlock(), createBlock(m, {
4332
+ key: n.name,
4333
+ title: unref(sheetTitle),
4334
+ description: unref(getLocaleText)(n.name_locale, n.name),
4335
+ value: a + 1,
4336
+ error: () => hasVisibleStepErrors(a),
4337
+ complete: () => a + 1 <= unref(currentStep) && stepErrors(unref(currentStep) - 1).length == 0
4338
+ }, null, 8, ["title", "description", "value", "error", "complete"]))), 128))
4339
+ ]),
4340
+ _: 1
4341
+ }, 8, ["modelValue"]),
4342
+ createVNode(o, {
4343
+ icon: "info",
4344
+ variant: "tertiary",
4345
+ onClick: r[4] || (r[4] = () => showSummaryDialog())
4346
+ })
4347
+ ]),
4348
+ createElementVNode("div", _hoisted_5, [
4349
+ createElementVNode("div", _hoisted_6, [
4350
+ createVNode(JsonViewer, {
4351
+ json: {
4352
+ data: unref(data),
4353
+ errors: unref(errors).map(
4354
+ (n) => `${n.path.join(".")} - ${n.message}`
4355
+ ),
4356
+ stepErrors: stepErrors().map(
4357
+ (n) => `${n.path.join(".")} - ${n.message}`
4358
+ ),
4359
+ schema: unref(schema)
4360
+ }
4361
+ }, null, 8, ["json"]),
4362
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(template).steps[unref(currentStep) - 1].groups.filter(
4363
+ (n) => n.fields.length && (!n.condition || (Array.isArray(n.condition) ? n.condition.every((a) => unref(_).get(unref(data), a.property) == a.value == (a.not != !0)) : unref(_).get(unref(data), n.condition.property) == n.condition.value == (n.condition.not != !0)))
4364
+ ), (n, a) => (openBlock(), createElementBlock("div", {
4365
+ key: a,
4366
+ class: "space-y-24"
4367
+ }, [
4368
+ createElementVNode("div", _hoisted_7, toDisplayString(unref(getLocaleText)(n.name_locale, n.name ?? "")), 1),
4369
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(n.fields, (s, y) => (openBlock(), createElementBlock("div", { key: y }, [
4370
+ (openBlock(), createBlock(_sfc_main$2, {
4371
+ key: y,
4372
+ field: s,
4373
+ modelValue: valueForField(s.property),
4374
+ disabled: isDisable(s),
4375
+ "campaign-type": unref(campaignType),
4376
+ "show-validation": unref(showValidation),
4377
+ "push-availability": unref(pushAvailability),
4378
+ onRetryPush: checkPushAvailability,
4379
+ "onUpdate:modelValue": (f) => onUpdateProperty(s.property, f),
4380
+ "onUpdate:file": async (f, c) => {
4381
+ const k = await onUpdateFile(f, c);
4382
+ onUpdateProperty(s.property, k || "");
4383
+ },
4384
+ schema: unref(ZodHelper).typeAtPath(
4385
+ unref(schema),
4386
+ schemaPathForField(s.property),
4387
+ unref(data).campaign.type != "MISSION" ? [unref(data).campaign.type] : ["STAMP", "MISSION"]
4388
+ ),
4389
+ "helper-state": unref(ZodHelper).helperState(
4390
+ unref(visibleErrors),
4391
+ schemaPathForField(s.property)
4392
+ ),
4393
+ "helper-text": unref(ZodHelper).helperText(
4394
+ unref(visibleErrors),
4395
+ schemaPathForField(s.property)
4396
+ ),
4397
+ extras: s.extras != null ? s.extras == "" ? unref(data) : unref(_).get(unref(data), s.extras) : void 0
4398
+ }, null, 8, ["field", "modelValue", "disabled", "campaign-type", "show-validation", "push-availability", "onUpdate:modelValue", "onUpdate:file", "schema", "helper-state", "helper-text", "extras"]))
4399
+ ]))), 128))
4400
+ ]))), 128)),
4401
+ createElementVNode("div", _hoisted_8, [
4402
+ createVNode(o, {
4403
+ label: unref(t)("connect.common.back"),
4404
+ variant: "tertiary",
4405
+ disabled: unref(currentStep) == 1,
4406
+ onClick: r[5] || (r[5] = (n) => currentStep.value--)
4407
+ }, null, 8, ["label", "disabled"]),
4408
+ createVNode(o, {
4409
+ disabled: isNextDisabled(),
4410
+ label: unref(currentStep) - 1 < unref(template).steps.length - 1 ? unref(t)("connect.common.next") : unref(t)("connect.common.submit"),
4411
+ onClick: r[6] || (r[6] = (n) => unref(currentStep) - 1 < unref(template).steps.length - 1 ? onNext() : onSubmit())
4412
+ }, null, 8, ["disabled", "label"])
4413
+ ])
4414
+ ]),
4415
+ createVNode(_sfc_main$1, {
4416
+ data: unref(data),
4417
+ class: "xs:hidden"
4418
+ }, null, 8, ["data"])
4419
+ ])
4420
+ ])) : createCommentVNode("", !0)
4421
+ ]),
4422
+ key: "0"
4423
+ }
4424
+ ]), 1032, ["modelValue"]);
4425
+ };
4426
+ }
4427
+ });
4428
+ export {
4429
+ _sfc_main as _,
4430
+ summarizeGrabDiscount as s,
4431
+ useLocaleText as u
4432
+ };