@feedmepos/mf-connect 0.1.119-prod → 0.1.121-dev

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