@feedmepos/mf-connect 0.1.126-prod → 0.1.127-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 (155) hide show
  1. package/dist/{App-DRHHPaMz.js → App-CLrxVFgX.js} +224 -216
  2. package/dist/AuditLogs-DYlfToAk.js +2016 -0
  3. package/dist/{Bin-FkcYLSTm.js → Bin-C0CugBW4.js} +8 -8
  4. package/dist/{Broadcast-Cgqp_BMa.js → Broadcast-DhVQa_WW.js} +22 -21
  5. package/dist/{CampaignAnalytic-kKZ_BwW0.js → CampaignAnalytic-6jeG5U90.js} +97 -97
  6. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-CX0mWLjO.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-Cxydrkof.js} +9 -10
  7. package/dist/{Card-Bu1y37hV.js → Card-cpLj34Oy.js} +23 -23
  8. package/dist/{Collections-B3mJkBCT.js → Collections-CdRpJuHO.js} +197 -185
  9. package/dist/{Credit-Bn-2EcVy.js → Credit-E_N_yfnJ.js} +21 -20
  10. package/dist/{DateRangeChip.vue_vue_type_script_setup_true_lang-Cz7pZ7LD.js → DateRangeChip.vue_vue_type_script_setup_true_lang-Dq-2vUqT.js} +1 -1
  11. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-CSXO2bYC.js +4584 -0
  12. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-B7XBiv4l.js → EffectSheet.vue_vue_type_style_index_0_lang-BeQZjLIw.js} +33 -33
  13. package/dist/{Experience-CunbmoAu.js → Experience-D9i0ax4C.js} +32 -31
  14. package/dist/{FileSaver.min-ChFSxYyS.js → FileSaver.min-BOE2RBne.js} +1 -1
  15. package/dist/{Game-dFDwx_UJ.js → Game-CirwX_l1.js} +19 -18
  16. package/dist/{GiftCardSetup-DYpEqqX0.js → GiftCardSetup-DpJb_azW.js} +31 -31
  17. package/dist/{GoalPickerPanel.vue_vue_type_script_setup_true_lang-DxJdI6gc.js → GoalPickerPanel.vue_vue_type_script_setup_true_lang-ff6Nfvxe.js} +140 -128
  18. package/dist/{Goals-DuZzgM_K.js → Goals-TejbPs-I.js} +4 -4
  19. package/dist/Grab-CeUX-LlF.js +301 -0
  20. package/dist/{ImageInput.vue_vue_type_script_setup_true_lang-lDulspkF.js → ImageInput.vue_vue_type_script_setup_true_lang-CnZzRDGS.js} +1 -1
  21. package/dist/{Index-BxB2ohT0.js → Index-gqWBDZBN.js} +10 -10
  22. package/dist/{LocationPicker.vue_vue_type_script_setup_true_lang-9sKJE1A5.js → LocationPicker.vue_vue_type_script_setup_true_lang-CzobgD7L.js} +1 -1
  23. package/dist/{LottieAnimation.vue_vue_type_script_setup_true_lang-CxBNYzcz.js → LottieAnimation.vue_vue_type_script_setup_true_lang-DgeD1RQq.js} +1 -1
  24. package/dist/{LoyaltyDashboard-DQzGvQ7j.js → LoyaltyDashboard-R22oQHTd.js} +82 -82
  25. package/dist/{MainLayout-MAZ1S06H.js → MainLayout-pJBEBaM-.js} +1 -1
  26. package/dist/{MainLayout.vue_vue_type_script_setup_true_lang-CeF3LU-N.js → MainLayout.vue_vue_type_script_setup_true_lang-IX_utv2Z.js} +3 -3
  27. package/dist/{Marketing-ACF6F7be.js → Marketing-5gMwO1jV.js} +4 -4
  28. package/dist/{MarketingMaterialEdit-B8NfkoHg.js → MarketingMaterialEdit-BaHNX_qE.js} +214 -211
  29. package/dist/{Member-rLxDUOr8.js → Member-Cd0oraEq.js} +7 -7
  30. package/dist/MemberDetailSheet.vue_vue_type_script_setup_true_lang-DzyM1fW_.js +1322 -0
  31. package/dist/{MemberImportHistory-BuG6DmdV.js → MemberImportHistory-C_RkY3fg.js} +7 -7
  32. package/dist/{MemberList-CC6zm_I6.js → MemberList-CJK1akUC.js} +103 -105
  33. package/dist/{MemberTransactions-Bw2xu6jZ.js → MemberTransactions-DP6schuy.js} +1 -1
  34. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-Cav8gQUK.js → MessageInput.vue_vue_type_script_setup_true_lang-BaivunRx.js} +12 -12
  35. package/dist/{MetricInfoTooltip.vue_vue_type_script_setup_true_lang-8wdY4FnI.js → MetricInfoTooltip.vue_vue_type_script_setup_true_lang-DOdYyPp2.js} +1 -1
  36. package/dist/{Mission-DnEcbALs.js → Mission-DJ40IcG9.js} +22 -21
  37. package/dist/{Overview-DShFohlk.js → Overview-CaQlLSBg.js} +145 -144
  38. package/dist/{Overview-COytI5xN.js → Overview-DXHjNmIO.js} +21 -21
  39. package/dist/{Point-CWYwlx0i.js → Point-D0Qqmgai.js} +22 -21
  40. package/dist/{Promotion-LBrQYtad.js → Promotion-CQU2-tpG.js} +137 -131
  41. package/dist/{Queue-DKg5EvDM.js → Queue-B-Uki3qh.js} +46 -46
  42. package/dist/{Record--lYpawLN.js → Record-BvQ0nVja.js} +9 -9
  43. package/dist/{Review-C4pNmJ7n.js → Review-DMfBPU_D.js} +2 -2
  44. package/dist/ReviewFacebookCallback-Bq6JQ7LR.js +225 -0
  45. package/dist/{ReviewGoogleCallback-ge8fL_A-.js → ReviewGoogleCallback-Bg9PFxog.js} +5 -5
  46. package/dist/{Reward-B67r1Bpz.js → Reward-CNC0z98e.js} +16 -16
  47. package/dist/{RewardGroup.vue_vue_type_script_setup_true_lang-Bt0Kx2--.js → RewardGroup.vue_vue_type_script_setup_true_lang-DXr-5wJE.js} +14 -14
  48. package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-OznhirAU.js +1923 -0
  49. package/dist/{Segment-DeSC3z5G.js → Segment-V0ZQJkN-.js} +304 -307
  50. package/dist/{SendCollectionSheet.vue_vue_type_script_setup_true_lang-DdjC7X1V.js → SendCollectionSheet.vue_vue_type_script_setup_true_lang-BmFp2pst.js} +15 -15
  51. package/dist/{SendVoucherSheet.vue_vue_type_script_setup_true_lang-Crys59UO.js → SendVoucherSheet.vue_vue_type_script_setup_true_lang-C0IbEZMG.js} +4 -4
  52. package/dist/{Setting-DiDcMU5E.js → Setting-DCb6IIrk.js} +17 -17
  53. package/dist/{SettingAdvertisements-3wMI9egH.js → SettingAdvertisements-Dc9XfzVl.js} +12 -12
  54. package/dist/Settings-BIjIfmFI.js +286 -0
  55. package/dist/{Store-DgefqByH.js → Store-DkoB_5IF.js} +29 -29
  56. package/dist/{StoreRewards-CS2h5RVB.js → StoreRewards-a4ujLMfY.js} +15 -15
  57. package/dist/{StoreTransactions.vue_vue_type_script_setup_true_lang-gPR8sn4k.js → StoreTransactions.vue_vue_type_script_setup_true_lang-UbMY0RzG.js} +25 -25
  58. package/dist/TargetLocationInput.vue_vue_type_script_setup_true_lang-BWjb1wHV.js +7007 -0
  59. package/dist/{Tier-Cye6888q.js → Tier-1WKuUirS.js} +2583 -688
  60. package/dist/{Title-B1eJh5oy.js → Title-CznZg4jL.js} +96 -95
  61. package/dist/{Transaction-ouzdsBUx.js → Transaction-DBRQDmA3.js} +2 -2
  62. package/dist/{Upselling-CdQd2Fuk.js → Upselling-CjZvUUqn.js} +3 -3
  63. package/dist/{UserRuleGroup.vue_vue_type_script_setup_true_lang-BSlxe1Hf.js → UserRuleGroup.vue_vue_type_script_setup_true_lang-DS4hdSE9.js} +26 -26
  64. package/dist/{Voucher-CJJt8VlJ.js → Voucher-Di6VhoSM.js} +19 -19
  65. package/dist/{VoucherEditor.vue_vue_type_script_setup_true_lang-BzbNaK6H.js → VoucherEditor.vue_vue_type_script_setup_true_lang-BjSzCnBw.js} +12 -12
  66. package/dist/{WhatsappAccount-DIxSP6Tp.js → WhatsappAccount-DdXadlHI.js} +6 -6
  67. package/dist/{WhatsappAccountStatusLabel.vue_vue_type_script_setup_true_lang-L9Y5lAft.js → WhatsappAccountStatusLabel.vue_vue_type_script_setup_true_lang-Cnlvi-GG.js} +1 -1
  68. package/dist/WhatsappBot-DwhQmZLJ.js +882 -0
  69. package/dist/{WhatsappBotLogs-D8IfLHk3.js → WhatsappBotLogs-BAglKUAZ.js} +66 -66
  70. package/dist/WhatsappBotSettings-DslJTj2X.js +945 -0
  71. package/dist/{WhatsappLayout-3rWwmGRd.js → WhatsappLayout-14847AOz.js} +3 -3
  72. package/dist/{WhatsappNotificationGroupDialog.vue_vue_type_script_setup_true_lang-C3N-loYJ.js → WhatsappNotificationGroupDialog.vue_vue_type_script_setup_true_lang-otzgv6Jh.js} +3 -3
  73. package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-D1dORvMi.js → ZodTextField.vue_vue_type_script_setup_true_lang-BEY-LOVu.js} +2 -2
  74. package/dist/{app-BXqas0p1.js → app-KbxCI4gY.js} +4204 -3400
  75. package/dist/app.js +4 -3
  76. package/dist/{base.export-DQCZiS2E.js → base.export-DH8OxNrx.js} +2 -2
  77. package/dist/business-DuKNr9P7.js +83 -0
  78. package/dist/{campaign-C2X6aa7B.js → campaign-DR5xHhgA.js} +31 -25
  79. package/dist/{campaign-DASPASQ0.js → campaign-Ddv-RZgo.js} +121 -94
  80. package/dist/{campaign.enum-BqekIiiN.js → campaign.enum-DsaSpHDQ.js} +3 -2
  81. package/dist/campaign.fn-CJlEovlZ.js +776 -0
  82. package/dist/{collectible.enum-Liy2wH3s.js → collectible.enum-CDHT9uk3.js} +1 -1
  83. package/dist/{collection.fn-C7jNdh0A.js → collection.fn-DTZs-hUX.js} +2 -2
  84. package/dist/{currency-BvBM_Io9.js → currency-1-Yhpyv5.js} +1 -1
  85. package/dist/duplicateCampaign-BncSxYSg.js +51 -0
  86. package/dist/{effect-BA1yh6Mj.js → effect-TTD5--LN.js} +1 -1
  87. package/dist/{email-addresses-haS5P7hq.js → email-addresses-pxXp67Al.js} +2 -2
  88. package/dist/{feature-flag-B4bJnuei.js → feature-flag-CFVZl4ed.js} +84 -84
  89. package/dist/google-BQK68wbe.js +5 -0
  90. package/dist/{helper-BtTBvFuA.js → helper-BC_Cl5VR.js} +1 -1
  91. package/dist/{index-ChGZ_S3V.js → index-42Wl_5UE.js} +1 -1
  92. package/dist/{index-Dm2Dvxph.js → index-BRl7Besd.js} +23 -23
  93. package/dist/{index-DAtVp1NI.js → index-BxUMqeaY.js} +2700 -2614
  94. package/dist/{index-Dg972Dfv.js → index-ByFFDLTo.js} +1 -1
  95. package/dist/{index-DtbR7I4C.js → index-CBKbnJRo.js} +9 -9
  96. package/dist/index-CGtlXLTG.js +10767 -0
  97. package/dist/{index-CH-uRaZH.js → index-CRKdLbXL.js} +71 -52
  98. package/dist/{index-B1dAoOWi.js → index-CaHkqz0W.js} +19 -6
  99. package/dist/{index-DeomfIu9.js → index-CcXMYJxc.js} +609 -252
  100. package/dist/{index-B6A6sHpy.js → index-CkiP4iG6.js} +1 -1
  101. package/dist/{index-g_SHjVWE.js → index-D1iOPNg3.js} +1 -1
  102. package/dist/{index-D-D0s8PB.js → index-D2Nq0UoL.js} +381 -235
  103. package/dist/index-D4nA0Z7e.js +19528 -0
  104. package/dist/{index-BV-YiCDM.js → index-DHw8wo7T.js} +2 -2
  105. package/dist/{index-C2rjmdar.js → index-DKOoRHPf.js} +4 -4
  106. package/dist/{index-Q-iHraJ3.js → index-DcbPYZkw.js} +26 -19
  107. package/dist/{index-C7UBk5gq.js → index-DjwrfZk3.js} +35 -17
  108. package/dist/{index-BvFq5REc.js → index-EuZfRdBT.js} +10 -10
  109. package/dist/{index-CJ-BZCvB.js → index-H4XJDOoT.js} +1315 -1243
  110. package/dist/{index-CXznvd79.js → index-ImU7YXN7.js} +4 -4
  111. package/dist/{index-BRTy6G9c.js → index-N4EzkcEu.js} +2 -2
  112. package/dist/{index-CBfVFFME.js → index-j7eLKJK3.js} +198 -198
  113. package/dist/{index.esm2017-B7iE1Ggr.js → index.esm2017-CBo4j3U1.js} +93 -93
  114. package/dist/{loading-BvlSfSVK.js → loading-COAu2l7W.js} +1 -1
  115. package/dist/{lodash-Daey2k0N.js → lodash-Bu1ipIkR.js} +1 -1
  116. package/dist/{member-import-CF9aym_y.js → member-import-CkiTJIqy.js} +2 -2
  117. package/dist/{membership-DfG-fl80.js → membership-BSEeYyiz.js} +3 -3
  118. package/dist/{money-SBIQhxqf.js → money-BOaGQSGa.js} +1 -1
  119. package/dist/{number-Cp1bFK9U.js → number-B2AC2EMT.js} +1 -1
  120. package/dist/objectid-BKw48v5L.js +145 -0
  121. package/dist/{onboarding-bjc7C8O-.js → onboarding-ClA8xAnH.js} +25 -25
  122. package/dist/{onboardingSetup-BAu9TDI6.js → onboardingSetup-DHjnq0H1.js} +2 -2
  123. package/dist/{plugins-Def73Eyk.js → plugins-DewN43sP.js} +3 -3
  124. package/dist/{reward-KecVeztH.js → reward-deDdPQiR.js} +1 -1
  125. package/dist/{rule-kMIC0vOi.js → rule-B8ifutnO.js} +572 -492
  126. package/dist/style.css +1 -1
  127. package/dist/template-z3VMmWei.js +227 -0
  128. package/dist/timezone-BxJDy-bY.js +19 -0
  129. package/dist/{transaction.fn-Bjy5utxD.js → transaction.fn-CBBhq01K.js} +2 -2
  130. package/dist/{trigger-DnnOJVUi.js → trigger-B_quLwWr.js} +9 -9
  131. package/dist/{useMarketingMaterialActions-DMrNOpok.js → useMarketingMaterialActions-DqoRLx1M.js} +4 -4
  132. package/dist/{usePagination-BCY4a-dh.js → usePagination-Q1fPttcp.js} +1 -1
  133. package/dist/{user-BTc0S1Vx.js → user-Bw6h9xn-.js} +1 -1
  134. package/dist/vue-i18n-DpCS1FnK.js +2365 -0
  135. package/dist/{xlsx-DR5oLrEs.js → xlsx--toeD6hC.js} +1 -1
  136. package/dist/{zod-CMq39HWn.js → zod-BkNAcpay.js} +1 -1
  137. package/package.json +6 -2
  138. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-DIUEjCFW.js +0 -3638
  139. package/dist/MemberDetailSheet.vue_vue_type_script_setup_true_lang-Bq3UKX7v.js +0 -1308
  140. package/dist/ReviewFacebookCallback-BYXwKQNG.js +0 -238
  141. package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-fLtn32Rw.js +0 -1884
  142. package/dist/Settings-BR6Y1DBZ.js +0 -179
  143. package/dist/TargetLocationInput.vue_vue_type_script_setup_true_lang-Cjnkpd1j.js +0 -142
  144. package/dist/WhatsappBot-BXxoaz7-.js +0 -878
  145. package/dist/WhatsappBotSettings-Bq9C7pNZ.js +0 -704
  146. package/dist/business-RsRhXSh8.js +0 -82
  147. package/dist/campaign.fn-BEX99lsa.js +0 -776
  148. package/dist/google-C3S8u0mT.js +0 -4
  149. package/dist/index-C_H8jFYf.js +0 -2743
  150. package/dist/index-D9zjHXFU.js +0 -27551
  151. package/dist/objectid-BMRA1fIL.js +0 -145
  152. package/dist/rule-builder-DgU6P24U.js +0 -102
  153. package/dist/template-BH9vS8A9.js +0 -275
  154. package/dist/timezone-CMX1sJ0a.js +0 -20
  155. package/dist/vue-i18n-7BKLPLxj.js +0 -2365
@@ -1,3638 +0,0 @@
1
- import { defineComponent, ref, watch, resolveComponent, openBlock, createElementBlock, createVNode, unref, isRef, withCtx, createBlock, createCommentVNode, computed, createElementVNode, toDisplayString, Fragment, renderList, normalizeClass, createTextVNode, watchEffect, onMounted, withModifiers, toRefs, normalizeStyle, resolveDynamicComponent, nextTick, onBeforeUnmount, createSlots } from "vue";
2
- import { _ } from "./lodash-Daey2k0N.js";
3
- import { h as axios, S as SvcConfig } from "./index-BvFq5REc.js";
4
- import { z } from "./app-BXqas0p1.js";
5
- import { Z as ZodHelper } from "./zod-CMq39HWn.js";
6
- import { z as z$1 } from "./index-C_H8jFYf.js";
7
- import { e as FdoGroup, F as F_RUNNABLE_CAMPAIGN_TYPE, f as FdtoRunnableCampaign, g as FdoCreditLoyaltyReward, h as FdtoRandomReward, i as F_MISSION_TYPE, j as FdoThresholdCreditReward, k as FdtoThresholdReward, l as FdoMission } from "./index-D-D0s8PB.js";
8
- import { F as FdoObjectId } from "./index-D9zjHXFU.js";
9
- import { F as FdtoCollectibleConfig } from "./index-DAtVp1NI.js";
10
- import { i as isRuleGroup, R as RuleBuilder, a as isRuleEntry } from "./rule-builder-DgU6P24U.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-CBfVFFME.js";
12
- import { d as CHANNEL_DISPLAY_ORDER, i as isPaidChannel, e as isChannelComplete, f as setMode, h as addChannel, j as hasDraft, k as setPrimaryChannel, r as removeChannel, m as moveChannel, l as setChannelContent, n as getCampaignSummaryObject, o as normaliseBroadcastDelivery } from "./campaign-DASPASQ0.js";
13
- import { u as useMembershipStore } from "./membership-DfG-fl80.js";
14
- import { u as useBusinessStore } from "./business-RsRhXSh8.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-BqekIiiN.js";
18
- import { _ as _sfc_main$y } from "./ImageInput.vue_vue_type_script_setup_true_lang-lDulspkF.js";
19
- import { _ as _sfc_main$w, a as _sfc_main$z, b as _sfc_main$B } from "./EffectSheet.vue_vue_type_style_index_0_lang-B7XBiv4l.js";
20
- import { _ as _sfc_main$A } from "./TargetLocationInput.vue_vue_type_script_setup_true_lang-Cjnkpd1j.js";
21
- import { _ as _sfc_main$C } from "./UserRuleGroup.vue_vue_type_script_setup_true_lang-BSlxe1Hf.js";
22
- import { _ as _sfc_main$q, a as _sfc_main$u } from "./RuleGroup.vue_vue_type_script_setup_true_lang-fLtn32Rw.js";
23
- import { p as prompt, f as firebaseStorage } from "./plugins-Def73Eyk.js";
24
- import { u as useI18n } from "./vue-i18n-7BKLPLxj.js";
25
- import { T as TypeToTriggerOptions, _ as _sfc_main$D, b as _sfc_main$E } from "./trigger-DnnOJVUi.js";
26
- import { D as DEFAULT_MESSAGE_VARIABLES, a as _sfc_main$r, g as getSmsMessageMetrics, _ as _sfc_main$s, b as _sfc_main$t } from "./MessageInput.vue_vue_type_script_setup_true_lang-Cav8gQUK.js";
27
- import { useDialog } from "@feedmepos/ui-library";
28
- import { useCoreStore } from "@feedmepos/mf-common";
29
- import { c as campaignApi } from "./index-BV-YiCDM.js";
30
- import { m as membershipApi } from "./index-B1dAoOWi.js";
31
- import { a as useChannelFlag } from "./feature-flag-B4bJnuei.js";
32
- import { m as moment } from "./index-B6A6sHpy.js";
33
- import { c as calculateNextScheduleAt, S as SummarizeRrule, R as RRule } from "./rule-kMIC0vOi.js";
34
- import { C as CountryTimezone } from "./timezone-CMX1sJ0a.js";
35
- import { _ as _sfc_main$v, a as _sfc_main$x } from "./VoucherEditor.vue_vue_type_script_setup_true_lang-BzbNaK6H.js";
36
- import "./index-CJ-BZCvB.js";
37
- import { T as TEMPLATES } from "./index-DeomfIu9.js";
38
- import "./index-C2rjmdar.js";
39
- import "./index-CH-uRaZH.js";
40
- import "./index-Q-iHraJ3.js";
41
- import { a as F_GAME_TYPE } from "./collectible.enum-Liy2wH3s.js";
42
- import { u as useLoading } from "./loading-BvlSfSVK.js";
43
- import { i as initCollectibleConfig } from "./helper-BtTBvFuA.js";
44
- import { C as CollectionUtils } from "./collection.fn-C7jNdh0A.js";
45
- import { s as sentenceCase$1 } from "./index-CuvNtC_M.js";
46
- import { u as useCampaignStore } from "./campaign-C2X6aa7B.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.feedme.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, l) {
61
- var r, y;
62
- if (!e) return;
63
- const o = e.campaign;
64
- if (!o) return;
65
- const s = o.event.rule;
66
- if (!s || !isRuleGroup(s)) {
67
- l.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 && l.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 a = (r = o.config) == null ? void 0 : r.validityOption;
91
- (!a || ["validForDay", "validBefore"].every((m) => a[m] == null)) && l.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((a, n) => {
103
- (a.threshold < 0 || a.threshold > o.mission.end) && l.addIssue({
104
- code: "custom",
105
- path: ["campaign", "rewards", n, "threshold"],
106
- params: {
107
- i18n: "connectZodCustom:campaign.reward_threshold_range"
108
- }
109
- });
110
- }), (y = o.config) != null && y.validityOption.followFirstReceive || l.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 (!s.rules.g_schedule) {
120
- l.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 a = RuleBuilder.getRules(
131
- s.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 == a.length && n.every((i) => a.some((f) => {
143
- const c = RuleBuilder.simplify(f);
144
- return c.property === i.property && i.operator.includes(c.operator);
145
- })) || l.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" && l.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 s = e.configs;
170
- s.extras.targetLocation = e.campaign.targetLocation;
171
- const r = Math.max(
172
- e.campaign.earningOption.amount,
173
- s.options.maxUse ?? 1
174
- );
175
- e.campaign.earningOption.amount = r, s.options.maxUse = r, e.campaign.earningOption = {
176
- type: "FIXED",
177
- amount: 1
178
- };
179
- }
180
- if (e.campaign.type == "MISSION" && "configs" in e) {
181
- const s = e.configs;
182
- s.options.validityOption = (o = e.campaign.config) == null ? void 0 : o.validityOption;
183
- }
184
- const l = e.campaign.event;
185
- return l.type != "BILL_COMPLETED" && l.rule && isRuleGroup(l.rule) && (l.rule = RuleBuilder.removeEntry(l.rule, "g_bill"), e.campaign.event = l), e;
186
- }
187
- function GenerateCampaignReq(e) {
188
- const l = 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: l,
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: l,
204
- templateId: FdoObjectId
205
- });
206
- case "POINT":
207
- return z$1.object({
208
- campaign: l,
209
- templateId: FdoObjectId
210
- });
211
- case "CREDIT":
212
- return z$1.object({
213
- campaign: l,
214
- templateId: FdoObjectId
215
- });
216
- case "BROADCAST":
217
- return z$1.object({
218
- campaign: l.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: l,
227
- templateId: FdoObjectId
228
- });
229
- case "REWARD_POOL":
230
- return z$1.object({
231
- campaign: l,
232
- templateId: FdoObjectId,
233
- updateCollections: z$1.boolean().optional()
234
- });
235
- case "GAME":
236
- return z$1.object({
237
- campaign: l,
238
- configs: FdtoCollectibleConfig,
239
- templateId: FdoObjectId,
240
- updateCollections: z$1.boolean().optional()
241
- });
242
- case "MISSION":
243
- return z$1.object({
244
- campaign: l,
245
- configs: FdtoCollectibleConfig,
246
- templateId: FdoObjectId,
247
- updateCollections: z$1.boolean().optional()
248
- });
249
- default:
250
- throw new Error("Not implemented");
251
- }
252
- }
253
- FdoGroup.extend({
254
- _id: FdoObjectId.optional(),
255
- name: z$1.string().min(1).max(300),
256
- business: FdoObjectId.optional(),
257
- campaigns: z$1.array(FdoObjectId).optional()
258
- });
259
- const CampaignDtos = {
260
- [F_RUNNABLE_CAMPAIGN_TYPE.enum.VOUCHER]: GenerateCampaignReq("VOUCHER"),
261
- [F_RUNNABLE_CAMPAIGN_TYPE.enum.PROMOTION]: GenerateCampaignReq("PROMOTION"),
262
- [F_RUNNABLE_CAMPAIGN_TYPE.enum.POINT]: GenerateCampaignReq("POINT"),
263
- [F_RUNNABLE_CAMPAIGN_TYPE.enum.CREDIT]: GenerateCampaignReq("CREDIT"),
264
- [F_RUNNABLE_CAMPAIGN_TYPE.enum.BROADCAST]: GenerateCampaignReq("BROADCAST"),
265
- [F_RUNNABLE_CAMPAIGN_TYPE.enum.COIN]: GenerateCampaignReq("COIN"),
266
- [F_RUNNABLE_CAMPAIGN_TYPE.enum.REWARD_POOL]: GenerateCampaignReq("REWARD_POOL"),
267
- [F_RUNNABLE_CAMPAIGN_TYPE.enum.GAME]: GenerateCampaignReq("GAME"),
268
- [F_RUNNABLE_CAMPAIGN_TYPE.enum.MISSION]: GenerateCampaignReq("MISSION")
269
- }, _hoisted_1$n = { class: "space-y-24" }, _sfc_main$p = /* @__PURE__ */ defineComponent({
270
- __name: "TimeRuleGroup",
271
- props: {
272
- modelValue: {
273
- type: Object,
274
- default: () => {
275
- }
276
- }
277
- },
278
- emits: ["update:model-value"],
279
- setup(e, { emit: l }) {
280
- const { t: o } = useI18n(), s = e, r = l, y = ref(
281
- !s.modelValue || !s.modelValue.rules.g_time ? "all_time" : RuleBuilder.getRules(s.modelValue.rules.g_time).length > 0 ? "custom" : "all_time"
282
- );
283
- watch(y, async (n, m) => {
284
- var i;
285
- if (m == "custom" && n == "all_time" && RuleBuilder.getRules((i = s.modelValue) == null ? void 0 : i.rules.g_time).length > 0) {
286
- const f = await prompt.confirm(
287
- o("connect.template.rule.time.confirm_remove"),
288
- o("connect.common.confirm"),
289
- o("connect.common.confirm"),
290
- o("connect.common.cancel")
291
- );
292
- f && r(
293
- "update:model-value",
294
- RuleBuilder.setRuleToGroup(
295
- s.modelValue ?? RuleBuilder.scaffoldGroup(),
296
- RuleBuilder.scaffoldGroup("g_time")
297
- )
298
- ), y.value = f ? n : m;
299
- }
300
- });
301
- async function a(n) {
302
- var m;
303
- if (n == "custom" && RuleBuilder.getRules((m = s.modelValue) == null ? void 0 : m.rules.g_time).length > 0) {
304
- if (!await prompt.confirm(
305
- o("connect.template.rule.time.confirm_remove"),
306
- o("connect.common.confirm"),
307
- o("connect.common.confirm"),
308
- o("connect.common.cancel")
309
- )) {
310
- y.value = "all_time";
311
- return;
312
- }
313
- r(
314
- "update:model-value",
315
- RuleBuilder.setRuleToGroup(
316
- s.modelValue ?? RuleBuilder.scaffoldGroup(),
317
- RuleBuilder.scaffoldGroup("g_time")
318
- )
319
- );
320
- }
321
- }
322
- return (n, m) => {
323
- var c;
324
- const i = resolveComponent("FmRadio"), f = resolveComponent("FmRadioGroup");
325
- return openBlock(), createElementBlock("div", _hoisted_1$n, [
326
- createVNode(f, {
327
- modelValue: unref(y),
328
- "onUpdate:modelValue": [
329
- m[0] || (m[0] = (u) => isRef(y) ? y.value = u : null),
330
- m[1] || (m[1] = (u) => a(u))
331
- ]
332
- }, {
333
- default: withCtx(() => [
334
- createVNode(i, {
335
- label: unref(o)("connect.template.rule.time.all_time"),
336
- value: "all_time"
337
- }, null, 8, ["label"]),
338
- createVNode(i, {
339
- label: unref(o)("connect.template.rule.time.custom"),
340
- value: "custom"
341
- }, null, 8, ["label"])
342
- ]),
343
- _: 1
344
- }, 8, ["modelValue"]),
345
- unref(y) == "custom" ? (openBlock(), createBlock(_sfc_main$q, {
346
- key: 0,
347
- class: "!mt-[0px]",
348
- "include-only": "trigger",
349
- "trigger-type": "SCHEDULE",
350
- "model-value": ((c = e.modelValue) == null ? void 0 : c.rules.g_time) ?? unref(RuleBuilder).scaffoldGroup("g_time"),
351
- "onUpdate:modelValue": m[2] || (m[2] = (u) => r(
352
- "update:model-value",
353
- unref(RuleBuilder).setRuleToGroup(
354
- e.modelValue ?? unref(RuleBuilder).scaffoldGroup(),
355
- u,
356
- "&&"
357
- )
358
- ))
359
- }, null, 8, ["model-value"])) : createCommentVNode("", !0)
360
- ]);
361
- };
362
- }
363
- }), _sfc_main$o = /* @__PURE__ */ defineComponent({
364
- __name: "BirthdayInput",
365
- props: {
366
- modelValue: {
367
- type: Object
368
- }
369
- },
370
- emits: ["update:model-value"],
371
- setup(e, { emit: l }) {
372
- const { t: o } = useI18n(), s = e, r = l, y = computed(() => {
373
- const { property: a, operator: n, equator: m } = RuleBuilder.simplify(
374
- s.modelValue ?? RuleBuilder.constructEntry("user.birthday", "_isDay", {
375
- op: "before",
376
- x: 1
377
- })
378
- );
379
- return {
380
- property: a,
381
- operator: n,
382
- equator: m
383
- };
384
- });
385
- return (a, n) => {
386
- const m = resolveComponent("FmRadio"), i = resolveComponent("FmStepperField");
387
- return openBlock(), createElementBlock("div", null, [
388
- createVNode(m, {
389
- label: unref(o)("connect.template.rule.birthday.on_birthday"),
390
- value: "_isRange-day",
391
- "model-value": `${unref(y).operator}-${unref(y).equator.unit}`,
392
- "onUpdate:modelValue": n[0] || (n[0] = () => {
393
- r(
394
- "update:model-value",
395
- unref(RuleBuilder).constructEntry("user.birthday", "_isRange", {
396
- op: "this",
397
- unit: "day",
398
- ignoreYear: !0
399
- })
400
- );
401
- })
402
- }, null, 8, ["label", "model-value"]),
403
- createVNode(m, {
404
- label: unref(o)("connect.template.rule.birthday.days_before"),
405
- value: "_isDay",
406
- "model-value": unref(y).operator,
407
- "onUpdate:modelValue": n[1] || (n[1] = () => {
408
- r(
409
- "update:model-value",
410
- unref(RuleBuilder).constructEntry("user.birthday", "_isDay", {
411
- op: "after",
412
- x: 1,
413
- ignoreYear: !0
414
- })
415
- );
416
- })
417
- }, null, 8, ["label", "model-value"]),
418
- unref(y).operator == "_isDay" ? (openBlock(), createBlock(i, {
419
- key: 0,
420
- label: unref(o)("connect.template.rule.birthday.days_before_label"),
421
- "show-steppers": !1,
422
- "model-value": unref(y).equator.x,
423
- "onUpdate:modelValue": n[2] || (n[2] = (f) => r(
424
- "update:model-value",
425
- unref(RuleBuilder).constructEntry("user.birthday", "_isDay", {
426
- op: "after",
427
- x: f,
428
- ignoreYear: !0
429
- })
430
- ))
431
- }, null, 8, ["label", "model-value"])) : createCommentVNode("", !0),
432
- createVNode(m, {
433
- label: unref(o)("connect.template.rule.birthday.in_birthday_week"),
434
- value: "_isRange-week",
435
- "model-value": `${unref(y).operator}-${unref(y).equator.unit}`,
436
- "onUpdate:modelValue": n[3] || (n[3] = () => {
437
- r(
438
- "update:model-value",
439
- unref(RuleBuilder).constructEntry("user.birthday", "_isRange", {
440
- op: "this",
441
- unit: "week",
442
- ignoreYear: !0
443
- })
444
- );
445
- })
446
- }, null, 8, ["label", "model-value"]),
447
- createVNode(m, {
448
- label: unref(o)("connect.template.rule.birthday.in_birthday_month"),
449
- value: "_isRange-month",
450
- "model-value": `${unref(y).operator}-${unref(y).equator.unit}`,
451
- "onUpdate:modelValue": n[4] || (n[4] = () => {
452
- r(
453
- "update:model-value",
454
- unref(RuleBuilder).constructEntry("user.birthday", "_isRange", {
455
- op: "this",
456
- unit: "month",
457
- ignoreYear: !0
458
- })
459
- );
460
- })
461
- }, null, 8, ["label", "model-value"])
462
- ]);
463
- };
464
- }
465
- }), _hoisted_1$m = { class: "space-y-16" }, _hoisted_2$j = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$h = { class: "grid grid-cols-3 gap-16" }, _hoisted_4$h = { class: "fm-typo-en-title-sm-800" }, _hoisted_5$e = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$n = /* @__PURE__ */ defineComponent({
466
- __name: "CampaignTriggerInput",
467
- props: {
468
- campaignType: {
469
- type: String,
470
- required: !0
471
- },
472
- modelValue: {
473
- type: String
474
- },
475
- disabled: {
476
- type: Boolean,
477
- default: !1
478
- }
479
- },
480
- emits: ["update:model-value"],
481
- setup(e, { emit: l }) {
482
- const { t: o } = useI18n(), s = e, r = l, y = computed(() => s.disabled ? TypeToTriggerOptions[s.campaignType].filter(
483
- (a) => a.value == s.modelValue
484
- ) : TypeToTriggerOptions[s.campaignType]);
485
- return (a, n) => {
486
- const m = resolveComponent("FmCard");
487
- return openBlock(), createElementBlock("div", _hoisted_1$m, [
488
- createElementVNode("div", _hoisted_2$j, toDisplayString(unref(o)("connect.campaign.trigger.description")), 1),
489
- createElementVNode("div", _hoisted_3$h, [
490
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(y), (i) => (openBlock(), createBlock(m, {
491
- variant: "outlined",
492
- disabled: s.disabled,
493
- class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
494
- "col-span-3": unref(y).length == 1,
495
- "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": e.modelValue == i.value,
496
- "hover:bg-fm-color-opacity-sm": e.modelValue != i.value
497
- }]),
498
- onClick: () => {
499
- s.modelValue != i.value && !s.disabled && r("update:model-value", i.value);
500
- },
501
- key: i.name
502
- }, {
503
- default: withCtx(() => [
504
- createElementVNode("div", _hoisted_4$h, toDisplayString(i.name), 1),
505
- createElementVNode("div", _hoisted_5$e, toDisplayString(i.description), 1)
506
- ]),
507
- _: 2
508
- }, 1032, ["disabled", "class", "onClick"]))), 128))
509
- ])
510
- ]);
511
- };
512
- }
513
- }), _sfc_main$m = /* @__PURE__ */ defineComponent({
514
- __name: "DateInput",
515
- props: {
516
- label: {
517
- type: String,
518
- required: !1
519
- },
520
- modelValue: {
521
- type: Object,
522
- required: !1
523
- }
524
- },
525
- emits: ["update:model-value"],
526
- setup(e, { emit: l }) {
527
- const o = l;
528
- return (s, r) => {
529
- const y = resolveComponent("FmButton"), a = resolveComponent("FmField"), n = resolveComponent("FmDatePicker");
530
- return openBlock(), createBlock(n, {
531
- label: e.label,
532
- "model-value": e.modelValue || "",
533
- "onUpdate:modelValue": r[1] || (r[1] = (m) => o("update:model-value", m))
534
- }, {
535
- "trigger-button": withCtx(({ opened: m }) => [
536
- createVNode(a, {
537
- class: "flex items-center",
538
- "prepend-icon": "calendar_month",
539
- "icon-outlined": !m
540
- }, {
541
- append: withCtx(() => [
542
- e.modelValue ? (openBlock(), createBlock(y, {
543
- key: 0,
544
- variant: "tertiary",
545
- icon: "clear",
546
- onClick: r[0] || (r[0] = (i) => (i.stopPropagation(), o("update:model-value", null)))
547
- })) : createCommentVNode("", !0)
548
- ]),
549
- default: withCtx(() => [
550
- createElementVNode("div", {
551
- class: normalizeClass(["fm-typo-en-body-lg-400", { "text-fm-color-typo-secondary": !e.modelValue }])
552
- }, toDisplayString(e.modelValue ? unref(hooks)(e.modelValue).format("DD MMM YYYY") : "DD MM YYYY"), 3)
553
- ]),
554
- _: 1
555
- }, 8, ["icon-outlined"])
556
- ]),
557
- _: 1
558
- }, 8, ["label", "model-value"]);
559
- };
560
- }
561
- }), _hoisted_1$l = { class: "flex items-center gap-8 w-full xs:flex-col" }, _hoisted_2$i = { class: "flex-1 xs:w-full" }, _hoisted_3$g = { class: "mt-5 xs:hidden" }, _hoisted_4$g = { class: "flex-1 xs:w-full" }, _sfc_main$l = /* @__PURE__ */ defineComponent({
562
- __name: "DateRangeInput",
563
- props: {
564
- modelValue: {
565
- type: Object,
566
- required: !1
567
- }
568
- },
569
- emits: ["update:model-value"],
570
- setup(e, { emit: l }) {
571
- const { t: o } = useI18n(), s = l;
572
- return (r, y) => {
573
- var a, n;
574
- return openBlock(), createElementBlock("div", _hoisted_1$l, [
575
- createElementVNode("div", _hoisted_2$i, [
576
- createVNode(_sfc_main$m, {
577
- "model-value": ((a = e.modelValue) == null ? void 0 : a.startDate) ?? null,
578
- label: unref(o)("connect.common.startDate"),
579
- "onUpdate:modelValue": y[0] || (y[0] = (m) => {
580
- var i;
581
- return s("update:model-value", {
582
- startDate: m,
583
- endDate: ((i = e.modelValue) == null ? void 0 : i.endDate) ?? null
584
- });
585
- })
586
- }, null, 8, ["model-value", "label"])
587
- ]),
588
- createElementVNode("div", _hoisted_3$g, toDisplayString(unref(o)("connect.common.to")), 1),
589
- createElementVNode("div", _hoisted_4$g, [
590
- createVNode(_sfc_main$m, {
591
- "model-value": ((n = e.modelValue) == null ? void 0 : n.endDate) ?? null,
592
- label: unref(o)("connect.common.endDate"),
593
- "onUpdate:modelValue": y[1] || (y[1] = (m) => {
594
- var i;
595
- return s("update:model-value", {
596
- startDate: ((i = e.modelValue) == null ? void 0 : i.startDate) ?? null,
597
- endDate: m
598
- });
599
- })
600
- }, null, 8, ["model-value", "label"])
601
- ])
602
- ]);
603
- };
604
- }
605
- }), _hoisted_1$k = { class: "flex flex-col gap-16" }, _hoisted_2$h = { 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$f = { class: "mb-[6px] flex items-baseline justify-between" }, _hoisted_5$d = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, _hoisted_6$a = { class: "flex items-center justify-between gap-8" }, _hoisted_7$8 = { class: "fm-typo-en-body-lg-400" }, _hoisted_8$8 = { 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$k = /* @__PURE__ */ defineComponent({
606
- __name: "AppInboxInput",
607
- props: {
608
- modelValue: {
609
- type: Object,
610
- required: !0
611
- },
612
- variables: {
613
- type: Array,
614
- default: () => [...DEFAULT_MESSAGE_VARIABLES]
615
- },
616
- /** False until the form is submitted; broadcasts validate on submit. */
617
- showValidation: {
618
- type: Boolean,
619
- default: !0
620
- }
621
- },
622
- emits: ["update:model-value"],
623
- setup(e, { emit: l }) {
624
- const { t: o } = useI18n(), s = e, r = l;
625
- function y(k) {
626
- r("update:model-value", { ...s.modelValue, ...k });
627
- }
628
- function a(k, b) {
629
- return k >= b ? "text-fm-color-system-warning-400" : "text-fm-color-typo-secondary";
630
- }
631
- const n = computed(() => s.modelValue.buttons ?? []), m = computed(() => {
632
- var k;
633
- return ((k = s.modelValue.content) == null ? void 0 : k.length) ?? 0;
634
- });
635
- function i(k, b) {
636
- y({
637
- buttons: n.value.map(
638
- (h, d) => d === k ? { ...h, ...b } : h
639
- )
640
- });
641
- }
642
- function f() {
643
- n.value.length >= MAX_BUTTONS || y({ buttons: [...n.value, { label: "", url: "" }] });
644
- }
645
- function c(k) {
646
- var d;
647
- if (!s.showValidation) return { label: void 0, url: void 0 };
648
- const b = (d = k.url) == null ? void 0 : d.trim();
649
- let h;
650
- return b ? FdoBroadcastUrl.safeParse(b).success || (h = o("connect.campaign.push.linkUrlInvalid")) : h = o("connect.campaign.appInbox.buttonUrlRequired"), {
651
- label: k.label.trim() ? void 0 : o("connect.campaign.appInbox.buttonLabelRequired"),
652
- url: h
653
- };
654
- }
655
- function u(k) {
656
- y({ buttons: n.value.filter((b, h) => h !== k) });
657
- }
658
- return (k, b) => {
659
- const h = resolveComponent("FmTextField"), d = resolveComponent("FmButton");
660
- return openBlock(), createElementBlock("div", _hoisted_1$k, [
661
- createElementVNode("div", null, [
662
- createElementVNode("div", _hoisted_2$h, [
663
- createElementVNode("span", _hoisted_3$f, toDisplayString(unref(o)("connect.campaign.appInbox.title")), 1),
664
- createElementVNode("span", {
665
- class: normalizeClass(["fm-typo-en-body-sm-400", a(e.modelValue.title.length, TITLE_WARN_AT$1)])
666
- }, toDisplayString(e.modelValue.title.length) + " / " + toDisplayString(TITLE_LIMIT$1), 3)
667
- ]),
668
- createVNode(h, {
669
- "model-value": e.modelValue.title,
670
- "max-length": TITLE_LIMIT$1,
671
- placeholder: unref(o)("connect.campaign.appInbox.titlePlaceholder"),
672
- "onUpdate:modelValue": b[0] || (b[0] = (p) => y({ title: p }))
673
- }, null, 8, ["model-value", "placeholder"])
674
- ]),
675
- createElementVNode("div", null, [
676
- createElementVNode("div", _hoisted_4$f, [
677
- createElementVNode("span", _hoisted_5$d, toDisplayString(unref(o)("connect.campaign.appInbox.previewText")), 1),
678
- createElementVNode("span", {
679
- class: normalizeClass(["fm-typo-en-body-sm-400", a(e.modelValue.previewText.length, PREVIEW_WARN_AT)])
680
- }, toDisplayString(e.modelValue.previewText.length) + " / " + toDisplayString(PREVIEW_LIMIT), 3)
681
- ]),
682
- createVNode(h, {
683
- "model-value": e.modelValue.previewText,
684
- "max-length": PREVIEW_LIMIT,
685
- placeholder: unref(o)("connect.campaign.appInbox.previewTextPlaceholder"),
686
- "onUpdate:modelValue": b[1] || (b[1] = (p) => y({ previewText: p }))
687
- }, null, 8, ["model-value", "placeholder"])
688
- ]),
689
- createElementVNode("div", _hoisted_6$a, [
690
- createElementVNode("div", null, [
691
- createElementVNode("div", _hoisted_7$8, toDisplayString(unref(o)("connect.campaign.appInbox.bodyMessage")), 1),
692
- createElementVNode("div", _hoisted_8$8, toDisplayString(unref(o)("connect.campaign.appInbox.bodyMessageDescription")), 1),
693
- createElementVNode("div", {
694
- class: normalizeClass([
695
- "mt-[2px] fm-typo-en-body-sm-400",
696
- unref(m) > unref(APP_INBOX_BODY_LIMIT) ? "text-fm-color-system-error-400" : "text-fm-color-typo-secondary"
697
- ])
698
- }, toDisplayString(unref(m)) + " / " + toDisplayString(unref(APP_INBOX_BODY_LIMIT)), 3)
699
- ]),
700
- createVNode(_sfc_main$r, {
701
- html: e.modelValue.content,
702
- variables: e.variables,
703
- "media-limit": 1,
704
- "button-label": unref(o)("connect.campaign.appInbox.editBodyMessage"),
705
- "onUpdate:html": b[2] || (b[2] = (p) => y({ content: p.html }))
706
- }, null, 8, ["html", "variables", "button-label"])
707
- ]),
708
- createElementVNode("div", _hoisted_9$7, [
709
- createElementVNode("div", _hoisted_10$6, [
710
- createElementVNode("span", _hoisted_11$4, toDisplayString(unref(o)("connect.campaign.appInbox.buttons")), 1),
711
- createElementVNode("span", _hoisted_12$3, toDisplayString(unref(n).length) + " / " + toDisplayString(MAX_BUTTONS), 1)
712
- ]),
713
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(n), (p, v) => (openBlock(), createElementBlock("div", {
714
- key: v,
715
- class: "flex flex-wrap items-start gap-8"
716
- }, [
717
- createElementVNode("div", _hoisted_13$3, [
718
- createVNode(h, {
719
- "model-value": p.label,
720
- "max-length": 20,
721
- placeholder: unref(o)("connect.campaign.appInbox.buttonLabel"),
722
- "helper-state": c(p).label ? "error" : "none",
723
- "helper-text": c(p).label,
724
- "onUpdate:modelValue": (C) => i(v, { label: C })
725
- }, null, 8, ["model-value", "placeholder", "helper-state", "helper-text", "onUpdate:modelValue"])
726
- ]),
727
- createElementVNode("div", _hoisted_14$3, [
728
- createVNode(h, {
729
- "model-value": p.url ?? "",
730
- inputmode: "url",
731
- placeholder: unref(o)("connect.campaign.push.linkUrlPlaceholder"),
732
- "helper-state": c(p).url ? "error" : "none",
733
- "helper-text": c(p).url,
734
- "onUpdate:modelValue": (C) => i(v, { url: C.trim() })
735
- }, null, 8, ["model-value", "placeholder", "helper-state", "helper-text", "onUpdate:modelValue"])
736
- ]),
737
- createVNode(d, {
738
- icon: "delete",
739
- "icon-color": "neutral-gray-400",
740
- variant: "tertiary",
741
- onClick: (C) => u(v)
742
- }, null, 8, ["onClick"])
743
- ]))), 128)),
744
- unref(n).length < MAX_BUTTONS ? (openBlock(), createBlock(d, {
745
- key: 0,
746
- variant: "tertiary",
747
- icon: "add",
748
- label: unref(o)("connect.campaign.appInbox.addButton"),
749
- onClick: f
750
- }, null, 8, ["label"])) : createCommentVNode("", !0)
751
- ])
752
- ]);
753
- };
754
- }
755
- }), _hoisted_1$j = { class: "flex flex-col gap-16" }, _hoisted_2$g = { 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$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: "mb-[6px] fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, _hoisted_7$7 = {
756
- key: 0,
757
- class: "mt-4 fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
758
- }, _hoisted_8$7 = {
759
- key: 1,
760
- class: "mt-12"
761
- }, _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$j = /* @__PURE__ */ defineComponent({
762
- __name: "PushInput",
763
- props: {
764
- modelValue: {
765
- type: Object,
766
- required: !0
767
- },
768
- /** False until the form is submitted; broadcasts validate on submit. */
769
- showValidation: {
770
- type: Boolean,
771
- default: !0
772
- }
773
- },
774
- emits: ["update:model-value"],
775
- setup(e, { emit: l }) {
776
- const { t: o } = useI18n(), s = e, r = l, y = F_PUSH_DESTINATION.options, a = computed(() => s.modelValue.destination === "EXTERNAL"), n = computed(() => {
777
- var u;
778
- if (!s.showValidation || !a.value) return;
779
- const c = (u = s.modelValue.url) == null ? void 0 : u.trim();
780
- return c ? FdoBroadcastUrl.safeParse(c).success ? void 0 : o("connect.campaign.push.linkUrlInvalid") : o("connect.campaign.push.linkUrlRequired");
781
- });
782
- function m(c) {
783
- r("update:model-value", { ...s.modelValue, ...c });
784
- }
785
- function i(c) {
786
- m(c === "EXTERNAL" ? { destination: c } : { destination: c, url: null });
787
- }
788
- function f(c, u) {
789
- return c >= u ? "text-fm-color-system-warning-400" : "text-fm-color-typo-secondary";
790
- }
791
- return (c, u) => {
792
- const k = resolveComponent("FmTextField"), b = resolveComponent("FmTextarea"), h = resolveComponent("FmSelect");
793
- return openBlock(), createElementBlock("div", _hoisted_1$j, [
794
- createElementVNode("div", null, [
795
- createElementVNode("div", _hoisted_2$g, [
796
- createElementVNode("span", _hoisted_3$e, toDisplayString(unref(o)("connect.campaign.push.title")), 1),
797
- createElementVNode("span", {
798
- class: normalizeClass(["fm-typo-en-body-sm-400", f(e.modelValue.title.length, TITLE_WARN_AT)])
799
- }, toDisplayString(e.modelValue.title.length) + " / " + toDisplayString(TITLE_LIMIT), 3)
800
- ]),
801
- createVNode(k, {
802
- "model-value": e.modelValue.title,
803
- "max-length": TITLE_LIMIT,
804
- placeholder: unref(o)("connect.campaign.push.titlePlaceholder"),
805
- "onUpdate:modelValue": u[0] || (u[0] = (d) => m({ title: d }))
806
- }, null, 8, ["model-value", "placeholder"])
807
- ]),
808
- createElementVNode("div", null, [
809
- createElementVNode("div", _hoisted_4$e, [
810
- createElementVNode("span", _hoisted_5$c, toDisplayString(unref(o)("connect.campaign.push.body")), 1),
811
- createElementVNode("span", {
812
- class: normalizeClass(["fm-typo-en-body-sm-400", f(e.modelValue.body.length, BODY_WARN_AT)])
813
- }, toDisplayString(e.modelValue.body.length) + " / " + toDisplayString(BODY_LIMIT), 3)
814
- ]),
815
- createVNode(b, {
816
- "model-value": e.modelValue.body,
817
- "max-length": BODY_LIMIT,
818
- placeholder: unref(o)("connect.campaign.push.bodyPlaceholder"),
819
- "onUpdate:modelValue": u[1] || (u[1] = (d) => m({ body: d }))
820
- }, null, 8, ["model-value", "placeholder"])
821
- ]),
822
- createElementVNode("div", null, [
823
- createElementVNode("div", _hoisted_6$9, toDisplayString(unref(o)("connect.campaign.push.link")), 1),
824
- createVNode(h, {
825
- "model-value": e.modelValue.destination ?? "NONE",
826
- items: unref(y).map((d) => ({
827
- label: unref(o)(`connect.campaign.appInbox.destination.${d}`),
828
- value: d
829
- })),
830
- "onUpdate:modelValue": u[2] || (u[2] = (d) => i(d))
831
- }, null, 8, ["model-value", "items"]),
832
- unref(a) ? createCommentVNode("", !0) : (openBlock(), createElementBlock("div", _hoisted_7$7, toDisplayString(unref(o)("connect.campaign.push.linkHelper")), 1)),
833
- unref(a) ? (openBlock(), createElementBlock("div", _hoisted_8$7, [
834
- createElementVNode("div", _hoisted_9$6, toDisplayString(unref(o)("connect.campaign.push.linkUrl")), 1),
835
- createVNode(k, {
836
- "model-value": e.modelValue.url ?? "",
837
- inputmode: "url",
838
- placeholder: unref(o)("connect.campaign.push.linkUrlPlaceholder"),
839
- "helper-state": unref(n) ? "error" : "none",
840
- "helper-text": unref(n),
841
- "onUpdate:modelValue": u[3] || (u[3] = (d) => m({ url: d.trim() || null }))
842
- }, null, 8, ["model-value", "placeholder", "helper-state", "helper-text"])
843
- ])) : createCommentVNode("", !0)
844
- ])
845
- ]);
846
- };
847
- }
848
- }), _hoisted_1$i = { class: "flex items-stretch overflow-x-auto pb-4" }, _hoisted_2$f = {
849
- key: 0,
850
- class: "flex flex-none items-center px-8 fm-typo-en-body-lg-600 text-fm-color-neutral-gray-300",
851
- "aria-hidden": "true"
852
- }, _hoisted_3$d = ["aria-current", "onClick"], _hoisted_4$d = { class: "flex items-center gap-[6px]" }, _hoisted_5$b = ["title"], _hoisted_6$8 = { class: "mt-[3px] block text-[11px] leading-[1.3] text-fm-color-typo-secondary" }, _sfc_main$i = /* @__PURE__ */ defineComponent({
853
- __name: "ChannelContentTabs",
854
- props: {
855
- tabs: {},
856
- modelValue: {}
857
- },
858
- emits: ["update:model-value"],
859
- setup(e) {
860
- const { t: l } = useI18n();
861
- return (o, s) => (openBlock(), createElementBlock("div", _hoisted_1$i, [
862
- (openBlock(!0), createElementBlock(Fragment, null, renderList(e.tabs, (r) => (openBlock(), createElementBlock("div", {
863
- key: r.key,
864
- class: "flex flex-none items-center"
865
- }, [
866
- r.connector ? (openBlock(), createElementBlock("span", _hoisted_2$f, toDisplayString(r.connector), 1)) : createCommentVNode("", !0),
867
- createElementVNode("button", {
868
- type: "button",
869
- class: normalizeClass([
870
- "min-w-[132px] flex-none rounded-[10px] border px-[14px] py-[10px] text-left transition-colors",
871
- e.modelValue === r.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"
872
- ]),
873
- "aria-current": e.modelValue === r.key ? "true" : void 0,
874
- onClick: (y) => o.$emit("update:model-value", r.key)
875
- }, [
876
- createElementVNode("span", _hoisted_4$d, [
877
- r.step ? (openBlock(), createElementBlock("span", {
878
- key: 0,
879
- class: normalizeClass([
880
- "flex h-[18px] w-[18px] flex-none items-center justify-center rounded-full text-[10.5px] font-semibold leading-[18px]",
881
- e.modelValue === r.key ? "bg-fm-color-primary text-fm-color-typo-white" : "bg-fm-color-neutral-gray-100 text-fm-color-typo-secondary"
882
- ])
883
- }, toDisplayString(r.step), 3)) : createCommentVNode("", !0),
884
- createElementVNode("span", {
885
- class: normalizeClass([
886
- "truncate text-[12.5px] font-semibold leading-[1.3]",
887
- e.modelValue === r.key ? "text-fm-color-primary" : "text-fm-color-typo-primary"
888
- ])
889
- }, toDisplayString(r.label), 3),
890
- r.complete ? createCommentVNode("", !0) : (openBlock(), createElementBlock("span", {
891
- key: 1,
892
- class: "h-[7px] w-[7px] flex-none rounded-full bg-fm-color-system-error-400",
893
- title: unref(l)("connect.campaign.broadcast.messageMissing")
894
- }, null, 8, _hoisted_5$b))
895
- ]),
896
- createElementVNode("span", _hoisted_6$8, toDisplayString(r.sub), 1)
897
- ], 10, _hoisted_3$d)
898
- ]))), 128))
899
- ]));
900
- }
901
- }), _hoisted_1$h = {
902
- key: 0,
903
- class: "flex w-[264px] shrink-0 flex-col gap-8"
904
- }, _hoisted_2$e = { class: "fm-typo-en-body-md-600" }, _hoisted_3$c = { class: "flex justify-center py-8" }, _hoisted_4$c = {
905
- key: 0,
906
- class: "px-12 pb-16 pt-16"
907
- }, _hoisted_5$a = { class: "mb-12 text-center text-[11px] text-[rgba(255,255,255,0.6)]" }, _hoisted_6$7 = { 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$6 = { class: "mt-[2px] fm-typo-en-body-sm-400 text-[rgba(255,255,255,0.72)] line-clamp-3" }, _hoisted_9$5 = {
908
- key: 1,
909
- class: "px-12 pb-16"
910
- }, _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 = {
911
- key: 2,
912
- class: "mt-12 flex flex-col gap-[6px]"
913
- }, _hoisted_17$1 = {
914
- key: 2,
915
- class: "px-12 pb-16"
916
- }, _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$h = /* @__PURE__ */ defineComponent({
917
- __name: "ChannelPreview",
918
- props: {
919
- target: {},
920
- content: {},
921
- senderPrefix: {}
922
- },
923
- setup(e) {
924
- const { t: l } = useI18n(), o = e, s = computed(
925
- () => o.target === "PUSH" ? o.content : void 0
926
- ), r = computed(
927
- () => o.target === "APP_INBOX" ? o.content : void 0
928
- ), y = computed(
929
- () => o.target === "SMS" || o.target === "WHATSAPP" ? o.content : void 0
930
- ), a = computed(() => {
931
- var c, u;
932
- const f = (u = (c = y.value) == null ? void 0 : c.content) == null ? void 0 : u.trim();
933
- return f ? o.senderPrefix ? `${o.senderPrefix}${f}` : f : l("connect.campaign.broadcast.preview.emptyText");
934
- }), n = computed(() => {
935
- var c;
936
- const f = ((c = r.value) == null ? void 0 : c.content) ?? "";
937
- return f.trim() ? `<!doctype html><meta charset="utf-8"><base target="_blank"><style>
938
- html,body{margin:0;font:400 12px/1.5 Inter,system-ui,sans-serif;color:#1C1C1E;word-break:break-word}
939
- img{max-width:100%;height:auto}
940
- </style>${f}` : "";
941
- }), m = computed(() => {
942
- const f = /* @__PURE__ */ new Date(), c = f.toLocaleDateString(void 0, {
943
- weekday: "short",
944
- day: "2-digit",
945
- month: "short"
946
- }), u = f.toLocaleTimeString(void 0, {
947
- hour: "2-digit",
948
- minute: "2-digit"
949
- });
950
- return `${c} · ${u}`;
951
- }), i = computed(() => o.target === "PUSH" ? l("connect.campaign.broadcast.preview.note.push") : o.target === "APP_INBOX" ? l("connect.campaign.broadcast.preview.note.inbox") : l("connect.campaign.broadcast.preview.note.text"));
952
- return (f, c) => {
953
- var u, k, b, h, d, p, v, C, V, B, S;
954
- return e.target !== "EMAIL" ? (openBlock(), createElementBlock("div", _hoisted_1$h, [
955
- createElementVNode("div", _hoisted_2$e, toDisplayString(unref(l)("connect.campaign.broadcast.preview.title")), 1),
956
- createElementVNode("div", {
957
- class: normalizeClass([
958
- "overflow-hidden rounded-[22px] border border-fm-color-neutral-gray-100",
959
- e.target === "PUSH" ? "bg-fm-color-neutral-black" : "bg-fm-color-neutral-white"
960
- ])
961
- }, [
962
- createElementVNode("div", _hoisted_3$c, [
963
- createElementVNode("div", {
964
- class: normalizeClass([
965
- "h-4 w-40 rounded-full",
966
- e.target === "PUSH" ? "bg-fm-color-neutral-gray-400" : "bg-fm-color-neutral-gray-100"
967
- ])
968
- }, null, 2)
969
- ]),
970
- e.target === "PUSH" ? (openBlock(), createElementBlock("div", _hoisted_4$c, [
971
- createElementVNode("div", _hoisted_5$a, toDisplayString(unref(m)), 1),
972
- createElementVNode("div", _hoisted_6$7, [
973
- createElementVNode("div", _hoisted_7$6, toDisplayString(((k = (u = unref(s)) == null ? void 0 : u.title) == null ? void 0 : k.trim()) || unref(l)("connect.campaign.broadcast.preview.emptyTitle")), 1),
974
- createElementVNode("div", _hoisted_8$6, toDisplayString(((h = (b = unref(s)) == null ? void 0 : b.body) == null ? void 0 : h.trim()) || unref(l)("connect.campaign.broadcast.preview.emptyBody")), 1)
975
- ])
976
- ])) : e.target === "APP_INBOX" ? (openBlock(), createElementBlock("div", _hoisted_9$5, [
977
- createElementVNode("div", _hoisted_10$5, toDisplayString(unref(l)("connect.campaign.broadcast.preview.inboxHeading")), 1),
978
- createElementVNode("div", _hoisted_11$3, [
979
- createElementVNode("div", _hoisted_12$2, toDisplayString(((p = (d = unref(r)) == null ? void 0 : d.title) == null ? void 0 : p.trim()) || unref(l)("connect.campaign.broadcast.preview.emptyTitle")), 1),
980
- createElementVNode("div", _hoisted_13$2, toDisplayString(((C = (v = unref(r)) == null ? void 0 : v.previewText) == null ? void 0 : C.trim()) || unref(l)("connect.campaign.broadcast.preview.emptyBody")), 1),
981
- (V = unref(r)) != null && V.imageUrl ? (openBlock(), createElementBlock("img", {
982
- key: 0,
983
- src: unref(r).imageUrl,
984
- alt: "",
985
- class: "mt-8 w-full rounded-[8px]"
986
- }, null, 8, _hoisted_14$2)) : createCommentVNode("", !0),
987
- unref(n) ? (openBlock(), createElementBlock("iframe", {
988
- key: 1,
989
- srcdoc: unref(n),
990
- sandbox: "",
991
- referrerpolicy: "no-referrer",
992
- class: "mt-8 h-[120px] w-full border-0",
993
- title: unref(l)("connect.campaign.broadcast.preview.bodyFrameTitle")
994
- }, null, 8, _hoisted_15$2)) : createCommentVNode("", !0),
995
- (S = (B = unref(r)) == null ? void 0 : B.buttons) != null && S.length ? (openBlock(), createElementBlock("div", _hoisted_16$1, [
996
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(r).buttons, ($, w) => (openBlock(), createElementBlock("div", {
997
- key: w,
998
- class: "rounded-[8px] bg-fm-color-primary px-12 py-8 text-center fm-typo-en-body-sm-400 text-fm-color-typo-white"
999
- }, toDisplayString($.label || unref(l)("connect.campaign.appInbox.buttonLabel")), 1))), 128))
1000
- ])) : createCommentVNode("", !0)
1001
- ])
1002
- ])) : (openBlock(), createElementBlock("div", _hoisted_17$1, [
1003
- createElementVNode("div", _hoisted_18$1, toDisplayString(unref(l)(`connect.campaign.broadcast.channel.${e.target}`)), 1),
1004
- createElementVNode("div", _hoisted_19$1, toDisplayString(unref(a)), 1)
1005
- ]))
1006
- ], 2),
1007
- createElementVNode("div", _hoisted_20$1, toDisplayString(unref(i)), 1)
1008
- ])) : createCommentVNode("", !0);
1009
- };
1010
- }
1011
- }), _hoisted_1$g = { class: "flex flex-col gap-12 pt-8" }, _hoisted_2$d = { class: "flex flex-wrap items-baseline justify-between gap-16" }, _hoisted_3$b = { class: "fm-typo-en-body-lg-600" }, _hoisted_4$b = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, _hoisted_5$9 = { 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$6 = { class: "min-w-0 flex-1" }, _hoisted_7$5 = { class: "flex flex-wrap items-center gap-[10px]" }, _hoisted_8$5 = { class: "fm-typo-en-body-md-600" }, _hoisted_9$4 = {
1012
- key: 0,
1013
- class: "inline-flex items-center gap-[5px] fm-typo-en-body-sm-400 text-fm-color-system-error-400"
1014
- }, _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 = {
1015
- type: "button",
1016
- 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"
1017
- }, _hoisted_15$1 = {
1018
- key: 1,
1019
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1020
- }, _sfc_main$g = /* @__PURE__ */ defineComponent({
1021
- __name: "FallbackChannelList",
1022
- props: {
1023
- rows: {},
1024
- addable: {}
1025
- },
1026
- emits: ["move", "remove", "add"],
1027
- setup(e) {
1028
- const { t: l } = useI18n(), o = e, s = computed(() => o.addable.length > 0);
1029
- return (r, y) => {
1030
- const a = resolveComponent("FmButton"), n = resolveComponent("FmMenuItem"), m = resolveComponent("FmMenu");
1031
- return openBlock(), createElementBlock("div", _hoisted_1$g, [
1032
- createElementVNode("div", _hoisted_2$d, [
1033
- createElementVNode("span", _hoisted_3$b, toDisplayString(unref(l)("connect.campaign.broadcast.fallbackChannels")), 1),
1034
- createElementVNode("span", _hoisted_4$b, toDisplayString(unref(l)("connect.campaign.broadcast.fallbackChannelsHint")), 1)
1035
- ]),
1036
- (openBlock(!0), createElementBlock(Fragment, null, renderList(e.rows, (i, f) => (openBlock(), createElementBlock("div", {
1037
- key: i.channel,
1038
- class: "flex flex-wrap items-center gap-12 rounded-[8px] border border-fm-color-neutral-gray-100 px-16 py-[14px]"
1039
- }, [
1040
- createElementVNode("span", _hoisted_5$9, toDisplayString(i.position), 1),
1041
- createElementVNode("span", _hoisted_6$6, [
1042
- createElementVNode("span", _hoisted_7$5, [
1043
- createElementVNode("span", _hoisted_8$5, toDisplayString(i.label), 1),
1044
- i.complete ? createCommentVNode("", !0) : (openBlock(), createElementBlock("span", _hoisted_9$4, [
1045
- y[0] || (y[0] = createElementVNode("span", { class: "h-[6px] w-[6px] rounded-full bg-fm-color-system-error-400" }, null, -1)),
1046
- createTextVNode(" " + toDisplayString(unref(l)("connect.campaign.broadcast.messageMissing")), 1)
1047
- ]))
1048
- ])
1049
- ]),
1050
- createElementVNode("span", _hoisted_10$4, [
1051
- createElementVNode("span", {
1052
- title: unref(l)("connect.campaign.broadcast.moveUp"),
1053
- class: "flex"
1054
- }, [
1055
- createVNode(a, {
1056
- icon: "arrow_upward",
1057
- "icon-color": "neutral-gray-400",
1058
- variant: "tertiary",
1059
- disabled: f === 0,
1060
- onClick: (c) => r.$emit("move", i.channel, -1)
1061
- }, null, 8, ["disabled", "onClick"])
1062
- ], 8, _hoisted_11$2),
1063
- createElementVNode("span", {
1064
- title: unref(l)("connect.campaign.broadcast.moveDown"),
1065
- class: "flex"
1066
- }, [
1067
- createVNode(a, {
1068
- icon: "arrow_downward",
1069
- "icon-color": "neutral-gray-400",
1070
- variant: "tertiary",
1071
- disabled: f === e.rows.length - 1,
1072
- onClick: (c) => r.$emit("move", i.channel, 1)
1073
- }, null, 8, ["disabled", "onClick"])
1074
- ], 8, _hoisted_12$1),
1075
- createElementVNode("span", {
1076
- title: unref(l)("connect.campaign.broadcast.removeChannel"),
1077
- class: "flex"
1078
- }, [
1079
- createVNode(a, {
1080
- icon: "delete",
1081
- "icon-color": "neutral-gray-400",
1082
- variant: "tertiary",
1083
- onClick: (c) => r.$emit("remove", i.channel)
1084
- }, null, 8, ["onClick"])
1085
- ], 8, _hoisted_13$1)
1086
- ])
1087
- ]))), 128)),
1088
- unref(s) ? (openBlock(), createBlock(m, {
1089
- key: 0,
1090
- placement: "bottom-start"
1091
- }, {
1092
- "menu-button": withCtx(() => [
1093
- createElementVNode("button", _hoisted_14$1, " + " + toDisplayString(unref(l)("connect.campaign.broadcast.addFallbackChannel")), 1)
1094
- ]),
1095
- default: withCtx(() => [
1096
- (openBlock(!0), createElementBlock(Fragment, null, renderList(e.addable, (i) => (openBlock(), createBlock(n, {
1097
- key: i.channel,
1098
- label: i.label,
1099
- onClick: (f) => r.$emit("add", i.channel)
1100
- }, null, 8, ["label", "onClick"]))), 128))
1101
- ]),
1102
- _: 1
1103
- })) : (openBlock(), createElementBlock("div", _hoisted_15$1, toDisplayString(unref(l)("connect.campaign.broadcast.allChannelsAdded")), 1))
1104
- ]);
1105
- };
1106
- }
1107
- });
1108
- var define_appEndpoint_default = { authUrl: "https://portal-v2.feedmeapi.com/", slackWebhookUrl: "https://hooks.slack.com/services/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", appUrl: "member.feedme.cc", crmUrl: "crm.feedme.cc", paymentPortalUrl: "https://portal.feedme.cc/payment/payout-account", licensePortalUrl: "https://license.feedme.cc/", marketingV1Portal: "https://marketing-v1.feedme.cc", voucherAppUrl: "https://voucher.feedme.cc/" };
1109
- const _hoisted_1$f = { class: "flex flex-col gap-[28px]" }, _hoisted_2$c = { class: "flex flex-col gap-[14px]" }, _hoisted_3$a = { class: "fm-typo-en-body-lg-600" }, _hoisted_4$a = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _hoisted_5$8 = { class: "grid gap-12 md:grid-cols-2 lg:grid-cols-2" }, _hoisted_6$5 = { class: "flex items-start justify-between gap-12" }, _hoisted_7$4 = { class: "fm-typo-en-title-sm-800" }, _hoisted_8$4 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_9$3 = {
1110
- key: 0,
1111
- class: "flex items-start gap-8 fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1112
- }, _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 = {
1113
- key: 1,
1114
- class: "h-[8px] w-[8px] rounded-full bg-fm-color-neutral-white"
1115
- }, _hoisted_15 = {
1116
- key: 0,
1117
- class: "mt-[3px] fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1118
- }, _hoisted_16 = {
1119
- key: 1,
1120
- 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"
1121
- }, _hoisted_17 = {
1122
- key: 2,
1123
- 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"
1124
- }, _hoisted_18 = {
1125
- key: 0,
1126
- class: "fm-typo-en-body-sm-400 text-fm-color-system-warning-400"
1127
- }, _hoisted_19 = {
1128
- key: 1,
1129
- class: "fm-typo-en-body-sm-400 text-fm-color-system-error-400"
1130
- }, _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 = {
1131
- key: 1,
1132
- 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"
1133
- }, _hoisted_24 = {
1134
- key: 3,
1135
- class: "flex flex-wrap items-start gap-24"
1136
- }, _hoisted_25 = { class: "min-w-0 flex-1 basis-[340px]" }, _hoisted_26 = {
1137
- key: 1,
1138
- class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
1139
- }, _sfc_main$f = /* @__PURE__ */ defineComponent({
1140
- __name: "BroadcastDeliveryInput",
1141
- props: {
1142
- pushAvailability: {
1143
- type: String,
1144
- default: "checking"
1145
- },
1146
- /** Either the new delivery shape or a legacy single-channel message. */
1147
- modelValue: {
1148
- type: Object,
1149
- default: void 0
1150
- },
1151
- triggerType: {
1152
- type: String,
1153
- default: () => "SCHEDULE"
1154
- },
1155
- variables: {
1156
- type: Object,
1157
- default: () => [...DEFAULT_MESSAGE_VARIABLES]
1158
- },
1159
- helperText: { type: String },
1160
- /**
1161
- * False until the merchant tries to proceed. Broadcasts validate on submit,
1162
- * so incomplete-channel markers stay hidden while the form is being filled.
1163
- */
1164
- showValidation: { type: Boolean, default: !0 },
1165
- helperState: { type: String },
1166
- placeholder: { type: String }
1167
- },
1168
- emits: ["retry-push", "update:model-value"],
1169
- setup(e, { emit: l }) {
1170
- const { t: o } = useI18n(), s = useDialog(), r = computed(() => {
1171
- let g = "unavailable";
1172
- return m.pushAvailability === "checking" ? g = "checking" : m.pushAvailability === "non-native" && (g = "requiresNativeApp"), o("connect.campaign.broadcast.pushAvailability." + g);
1173
- });
1174
- function y() {
1175
- s.open({
1176
- title: o("connect.campaign.broadcast.pushAvailability.contactSales"),
1177
- message: o("connect.campaign.broadcast.pushAvailability.dialogMessage"),
1178
- primaryActions: {
1179
- text: o("connect.campaign.broadcast.pushAvailability.close"),
1180
- close: !0
1181
- }
1182
- });
1183
- }
1184
- const a = useCoreStore(), n = useMembershipStore(), m = e, i = l, f = ref(!1), c = ref("SMS"), u = computed(() => {
1185
- const g = m.modelValue;
1186
- return g && "channels" in g ? g : toDelivery({ message: g });
1187
- });
1188
- function k(g) {
1189
- i("update:model-value", g);
1190
- }
1191
- function b(g) {
1192
- return o(`connect.campaign.broadcast.channel.${g}`);
1193
- }
1194
- const h = {
1195
- SMS: "chat",
1196
- WHATSAPP: "chat",
1197
- EMAIL: "mail",
1198
- APP_INBOX: "inbox",
1199
- PUSH: "notifications"
1200
- };
1201
- function d(g) {
1202
- return h[g];
1203
- }
1204
- const p = computed(() => u.value.mode === "fallback"), v = computed(
1205
- () => m.variables.filter(
1206
- (g) => m.triggerType == "SCHEDULE" ? !g.startsWith("transaction.") : !0
1207
- )
1208
- ), C = useChannelFlag();
1209
- function V(g) {
1210
- return C(g) === "off" ? !1 : g === "PUSH" ? m.pushAvailability === "native" : g === "WHATSAPP" ? f.value : !0;
1211
- }
1212
- const B = ["fallback", "all"];
1213
- function S(g) {
1214
- g !== u.value.mode && k(setMode(u.value, g));
1215
- }
1216
- const $ = ref(null);
1217
- function w(g) {
1218
- var N;
1219
- const x = (N = $.value) == null ? void 0 : N[g];
1220
- return x ? new Intl.NumberFormat(void 0, {
1221
- style: "currency",
1222
- currency: x.currency,
1223
- minimumFractionDigits: x.precision,
1224
- maximumFractionDigits: x.precision
1225
- }).format(x.amount / 10 ** x.precision) : null;
1226
- }
1227
- const R = computed(
1228
- () => (
1229
- // A flagged-off channel stays visible while selected, so it can be removed.
1230
- CHANNEL_DISPLAY_ORDER.filter(
1231
- (g) => C(g) === "on" || u.value.channels.includes(g)
1232
- ).map((g) => {
1233
- const x = u.value.channels.includes(g), N = w(g);
1234
- let F = o("connect.campaign.broadcast.freeChannel");
1235
- return isPaidChannel(g) && (F = N ? o("connect.campaign.broadcast.perMessage", { price: N }) : null), {
1236
- channel: g,
1237
- label: b(g),
1238
- selected: x,
1239
- available: V(g),
1240
- rateNote: F,
1241
- // In fallback mode the grid is a radio for the primary channel, so only
1242
- // the primary reads as checked; a fallback is tagged instead.
1243
- checked: p.value ? u.value.channels[0] === g : x,
1244
- usedAsFallback: p.value && u.value.channels.indexOf(g) > 0
1245
- };
1246
- })
1247
- )
1248
- );
1249
- async function T(g) {
1250
- if (p.value) {
1251
- await O(g);
1252
- return;
1253
- }
1254
- if (u.value.channels.includes(g)) {
1255
- await I(g);
1256
- return;
1257
- }
1258
- V(g) && k(addChannel(u.value, g, v.value));
1259
- }
1260
- async function O(g) {
1261
- if (!V(g)) return;
1262
- const x = u.value.channels[0];
1263
- x !== g && (x && hasDraft(u.value, x) && !await prompt.remove(
1264
- o("connect.campaign.broadcast.replaceChannelConfirm", {
1265
- channel: b(x),
1266
- next: b(g)
1267
- })
1268
- ) || V(g) && (k(setPrimaryChannel(u.value, g, v.value)), c.value = g));
1269
- }
1270
- async function I(g) {
1271
- if (hasDraft(u.value, g) && !await prompt.remove(
1272
- o("connect.campaign.broadcast.removeChannelConfirm", {
1273
- channel: b(g)
1274
- })
1275
- ))
1276
- return;
1277
- const x = removeChannel(u.value, g);
1278
- k(x), c.value === g && (c.value = x.channels[0] ?? "SMS");
1279
- }
1280
- function Y(g, x) {
1281
- k(moveChannel(u.value, g, x));
1282
- }
1283
- function j(g) {
1284
- V(g) && k(addChannel(u.value, g, v.value));
1285
- }
1286
- const G = computed(
1287
- () => u.value.channels.slice(1).map((g, x) => ({
1288
- channel: g,
1289
- label: b(g),
1290
- position: x + 2,
1291
- complete: !m.showValidation || isChannelComplete(u.value, g)
1292
- }))
1293
- ), q = computed(
1294
- () => CHANNEL_DISPLAY_ORDER.filter(
1295
- (g) => !u.value.channels.includes(g) && V(g)
1296
- ).map((g) => ({
1297
- channel: g,
1298
- label: b(g)
1299
- }))
1300
- ), U = computed(
1301
- () => u.value.channels.map((g, x) => {
1302
- let N = o("connect.campaign.broadcast.tab.sendsToEligible");
1303
- p.value && (N = o(
1304
- x === 0 ? "connect.campaign.broadcast.tab.firstAttempt" : "connect.campaign.broadcast.tab.ifNotReached"
1305
- ));
1306
- let F;
1307
- return x > 0 && (F = p.value ? "→" : "+"), {
1308
- key: g,
1309
- label: b(g),
1310
- sub: N,
1311
- complete: !m.showValidation || isChannelComplete(u.value, g),
1312
- step: p.value ? x + 1 : void 0,
1313
- connector: F
1314
- };
1315
- })
1316
- );
1317
- watchEffect(() => {
1318
- const g = U.value.map((x) => x.key);
1319
- g.length && !g.includes(c.value) && (c.value = g[0]);
1320
- });
1321
- const D = computed(() => c.value), W = computed(() => {
1322
- const g = D.value;
1323
- if (!(g === "APP_INBOX" || g === "PUSH"))
1324
- return u.value.content[g];
1325
- }), L = computed(
1326
- () => u.value.content.APP_INBOX
1327
- ), M = computed(
1328
- () => u.value.content.PUSH
1329
- );
1330
- function Z(g) {
1331
- k(setChannelContent(u.value, "APP_INBOX", g));
1332
- }
1333
- function X(g) {
1334
- V("PUSH") && k(setChannelContent(u.value, "PUSH", g));
1335
- }
1336
- function K(g, x) {
1337
- g === "APP_INBOX" || g === "PUSH" || k(setChannelContent(u.value, g, { ...x, channel: g }));
1338
- }
1339
- const H = computed(
1340
- () => u.value.channels.filter(isPaidChannel)
1341
- ), J = computed(() => {
1342
- var x, N, F;
1343
- const g = ((x = n.membership) == null ? void 0 : x.brand) || ((F = (N = a.currentBusiness) == null ? void 0 : N.value) == null ? void 0 : F.name) || "";
1344
- return getSmsMessageMetrics({ brandName: g, content: "" }).prefix;
1345
- }), Q = `${define_appEndpoint_default.licensePortalUrl}settings?businessId=${SvcConfig.businessId}`;
1346
- async function ee() {
1347
- try {
1348
- const g = await membershipApi.getWhatsappNumbers();
1349
- f.value = g.some(
1350
- (x) => {
1351
- var N;
1352
- return (N = x == null ? void 0 : x.default) == null ? void 0 : N.includes("Marketing");
1353
- }
1354
- );
1355
- } catch (g) {
1356
- console.error("Failed to fetch WhatsApp numbers:", g);
1357
- }
1358
- }
1359
- return onMounted(async () => {
1360
- const g = u.value.channels[0];
1361
- g && (c.value = g), campaignApi.readBroadcastCreditSummary().then((x) => $.value = x.prices).catch(() => $.value = null), await ee();
1362
- }), (g, x) => {
1363
- const N = resolveComponent("FmIcon"), F = resolveComponent("FmCard"), A = resolveComponent("FmButton");
1364
- return openBlock(), createElementBlock("div", _hoisted_1$f, [
1365
- createElementVNode("div", _hoisted_2$c, [
1366
- createElementVNode("div", null, [
1367
- createElementVNode("div", _hoisted_3$a, toDisplayString(unref(o)("connect.campaign.broadcast.delivery")), 1),
1368
- createElementVNode("div", _hoisted_4$a, toDisplayString(unref(o)("connect.campaign.broadcast.deliveryDescription")), 1)
1369
- ]),
1370
- createElementVNode("div", _hoisted_5$8, [
1371
- (openBlock(), createElementBlock(Fragment, null, renderList(B, (E) => createVNode(F, {
1372
- key: E,
1373
- variant: "outlined",
1374
- class: normalizeClass(["h-full cursor-pointer select-none p-16 space-y-8", {
1375
- "border-fm-color-primary bg-fm-color-system-warning-100": unref(u).mode === E,
1376
- "hover:bg-fm-color-opacity-sm": unref(u).mode !== E
1377
- }]),
1378
- onClick: (P) => S(E)
1379
- }, {
1380
- default: withCtx(() => [
1381
- createElementVNode("div", _hoisted_6$5, [
1382
- createElementVNode("div", _hoisted_7$4, toDisplayString(unref(o)(`connect.campaign.broadcast.mode.${E}.label`)), 1),
1383
- unref(u).mode === E ? (openBlock(), createBlock(N, {
1384
- key: 0,
1385
- name: "check_circle",
1386
- size: "md",
1387
- class: "shrink-0 text-fm-color-primary"
1388
- })) : createCommentVNode("", !0)
1389
- ]),
1390
- createElementVNode("div", _hoisted_8$4, toDisplayString(unref(o)(`connect.campaign.broadcast.mode.${E}.description`)), 1)
1391
- ]),
1392
- _: 2
1393
- }, 1032, ["class", "onClick"])), 64))
1394
- ]),
1395
- unref(u).channels.length < 2 ? (openBlock(), createElementBlock("div", _hoisted_9$3, [
1396
- createVNode(N, {
1397
- name: "info",
1398
- size: "sm",
1399
- class: "mt-[2px]"
1400
- }),
1401
- createElementVNode("span", null, toDisplayString(unref(o)("connect.campaign.broadcast.singleChannelNote")), 1)
1402
- ])) : createCommentVNode("", !0)
1403
- ]),
1404
- createElementVNode("div", _hoisted_10$3, [
1405
- createElementVNode("div", _hoisted_11$1, toDisplayString(unref(p) ? unref(o)("connect.campaign.broadcast.primaryChannel") : unref(o)("connect.campaign.broadcast.channels")), 1),
1406
- createElementVNode("div", _hoisted_12, [
1407
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(R), (E) => (openBlock(), createBlock(F, {
1408
- key: E.channel,
1409
- variant: "outlined",
1410
- class: normalizeClass(["flex h-full flex-col gap-12 p-16", [
1411
- E.checked ? "!border-fm-color-primary bg-fm-color-system-warning-100" : "",
1412
- E.available ? "cursor-pointer" : "cursor-not-allowed bg-fm-color-neutral-gray-100"
1413
- ]]),
1414
- "aria-disabled": E.channel === "PUSH" ? void 0 : !E.available,
1415
- onClick: (P) => T(E.channel)
1416
- }, {
1417
- default: withCtx(() => [
1418
- createElementVNode("div", _hoisted_13, [
1419
- createElementVNode("span", {
1420
- class: normalizeClass([
1421
- "flex h-[34px] w-[34px] flex-none items-center justify-center rounded-[8px]",
1422
- E.available ? "bg-fm-color-primary-oats text-fm-color-primary" : "bg-fm-color-neutral-gray-200 text-fm-color-neutral-gray-400"
1423
- ])
1424
- }, [
1425
- createVNode(N, {
1426
- name: d(E.channel),
1427
- size: "md"
1428
- }, null, 8, ["name"])
1429
- ], 2),
1430
- E.available ? (openBlock(), createElementBlock("span", {
1431
- key: 0,
1432
- class: normalizeClass(["flex h-[22px] w-[22px] flex-none items-center justify-center border-2 transition-colors", [
1433
- unref(p) ? "rounded-full" : "rounded-[4px]",
1434
- E.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"
1435
- ]])
1436
- }, [
1437
- E.checked && !unref(p) ? (openBlock(), createBlock(N, {
1438
- key: 0,
1439
- name: "check",
1440
- size: "sm"
1441
- })) : E.checked ? (openBlock(), createElementBlock("span", _hoisted_14)) : createCommentVNode("", !0)
1442
- ], 2)) : createCommentVNode("", !0)
1443
- ]),
1444
- createElementVNode("div", null, [
1445
- createElementVNode("div", {
1446
- class: normalizeClass(["fm-typo-en-body-md-600", E.available ? "" : "text-fm-color-typo-disabled"])
1447
- }, toDisplayString(E.label), 3),
1448
- E.available && E.rateNote ? (openBlock(), createElementBlock("div", _hoisted_15, toDisplayString(E.rateNote), 1)) : createCommentVNode("", !0),
1449
- E.available ? E.usedAsFallback ? (openBlock(), createElementBlock("div", _hoisted_17, toDisplayString(unref(o)("connect.campaign.broadcast.usedAsFallback")), 1)) : createCommentVNode("", !0) : (openBlock(), createElementBlock("div", _hoisted_16, toDisplayString(E.channel === "PUSH" ? unref(r) : unref(o)("connect.campaign.broadcast.notSetUp")), 1))
1450
- ]),
1451
- E.channel === "WHATSAPP" && !E.available ? (openBlock(), createElementBlock("a", {
1452
- key: 0,
1453
- href: Q,
1454
- target: "_blank",
1455
- class: "mt-auto fm-typo-en-body-sm-400 text-fm-color-secondary-blueberry underline",
1456
- onClick: x[0] || (x[0] = withModifiers(() => {
1457
- }, ["stop"]))
1458
- }, toDisplayString(unref(o)("connect.campaign.messageInput.manageWhatsappChannel")), 1)) : createCommentVNode("", !0),
1459
- E.channel === "PUSH" && !E.available ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
1460
- e.pushAvailability === "non-native" ? (openBlock(), createBlock(A, {
1461
- key: 0,
1462
- label: unref(o)("connect.campaign.broadcast.pushAvailability.contactSales"),
1463
- onClick: withModifiers(y, ["stop"])
1464
- }, null, 8, ["label"])) : createCommentVNode("", !0),
1465
- e.pushAvailability === "failed" ? (openBlock(), createBlock(A, {
1466
- key: 1,
1467
- label: unref(o)("connect.campaign.broadcast.pushAvailability.retry"),
1468
- onClick: x[1] || (x[1] = withModifiers((P) => i("retry-push"), ["stop"]))
1469
- }, null, 8, ["label"])) : createCommentVNode("", !0),
1470
- E.selected ? (openBlock(), createBlock(A, {
1471
- key: 2,
1472
- label: unref(o)("connect.campaign.broadcast.pushAvailability.removePush"),
1473
- onClick: x[2] || (x[2] = withModifiers((P) => I("PUSH"), ["stop"]))
1474
- }, null, 8, ["label"])) : createCommentVNode("", !0)
1475
- ], 64)) : createCommentVNode("", !0)
1476
- ]),
1477
- _: 2
1478
- }, 1032, ["class", "aria-disabled", "onClick"]))), 128))
1479
- ]),
1480
- unref(u).channels.includes("PUSH") && !V("PUSH") ? (openBlock(), createElementBlock("div", _hoisted_18, toDisplayString(unref(o)("connect.campaign.broadcast.pushAvailability.removeBeforeSave")), 1)) : createCommentVNode("", !0),
1481
- e.showValidation && !unref(u).channels.length ? (openBlock(), createElementBlock("div", _hoisted_19, toDisplayString(unref(o)("connect.campaign.broadcast.selectChannelRequired")), 1)) : createCommentVNode("", !0),
1482
- unref(p) && unref(u).channels.length ? (openBlock(), createBlock(_sfc_main$g, {
1483
- key: 2,
1484
- rows: unref(G),
1485
- addable: unref(q),
1486
- onMove: Y,
1487
- onRemove: I,
1488
- onAdd: j
1489
- }, null, 8, ["rows", "addable"])) : createCommentVNode("", !0)
1490
- ]),
1491
- createElementVNode("div", _hoisted_20, [
1492
- createElementVNode("div", null, [
1493
- createElementVNode("div", _hoisted_21, toDisplayString(unref(o)("connect.campaign.broadcast.content")), 1),
1494
- createElementVNode("div", _hoisted_22, toDisplayString(unref(o)("connect.campaign.broadcast.contentDescription")), 1)
1495
- ]),
1496
- unref(H).length ? (openBlock(), createBlock(_sfc_main$s, {
1497
- key: 0,
1498
- channels: unref(H)
1499
- }, null, 8, ["channels"])) : createCommentVNode("", !0),
1500
- unref(u).channels.length ? createCommentVNode("", !0) : (openBlock(), createElementBlock("div", _hoisted_23, toDisplayString(unref(o)("connect.campaign.broadcast.noChannelContent")), 1)),
1501
- unref(u).channels.length ? (openBlock(), createBlock(_sfc_main$i, {
1502
- key: 2,
1503
- modelValue: unref(c),
1504
- "onUpdate:modelValue": x[3] || (x[3] = (E) => isRef(c) ? c.value = E : null),
1505
- tabs: unref(U)
1506
- }, null, 8, ["modelValue", "tabs"])) : createCommentVNode("", !0),
1507
- unref(u).channels.includes(unref(c)) ? (openBlock(), createElementBlock("div", _hoisted_24, [
1508
- createElementVNode("div", _hoisted_25, [
1509
- unref(c) === "PUSH" && unref(M) && V("PUSH") ? (openBlock(), createBlock(_sfc_main$j, {
1510
- key: 0,
1511
- "model-value": unref(M),
1512
- "show-validation": e.showValidation,
1513
- "onUpdate:modelValue": X
1514
- }, null, 8, ["model-value", "show-validation"])) : unref(c) === "PUSH" ? (openBlock(), createElementBlock("div", _hoisted_26, toDisplayString(unref(r)), 1)) : unref(c) === "APP_INBOX" && unref(L) ? (openBlock(), createBlock(_sfc_main$k, {
1515
- key: 2,
1516
- "model-value": unref(L),
1517
- variables: unref(v),
1518
- "show-validation": e.showValidation,
1519
- "onUpdate:modelValue": Z
1520
- }, null, 8, ["model-value", "variables", "show-validation"])) : unref(c) !== "APP_INBOX" ? (openBlock(), createBlock(_sfc_main$t, {
1521
- key: unref(c),
1522
- "model-value": unref(W),
1523
- "allow-email": !1,
1524
- "allow-whatsapp": !1,
1525
- "hide-credit-card": !0,
1526
- "trigger-type": e.triggerType,
1527
- variables: unref(v),
1528
- placeholder: e.placeholder,
1529
- "onUpdate:modelValue": x[4] || (x[4] = (E) => K(unref(D), E))
1530
- }, null, 8, ["model-value", "trigger-type", "variables", "placeholder"])) : createCommentVNode("", !0)
1531
- ]),
1532
- createVNode(_sfc_main$h, {
1533
- target: unref(c),
1534
- content: unref(u).content[unref(D)],
1535
- "sender-prefix": unref(J)
1536
- }, null, 8, ["target", "content", "sender-prefix"])
1537
- ])) : createCommentVNode("", !0)
1538
- ])
1539
- ]);
1540
- };
1541
- }
1542
- }), _hoisted_1$e = { class: "space-y-8" }, _hoisted_2$b = { class: "grid grid-cols-2 gap-16" }, _hoisted_3$9 = {
1543
- key: 0,
1544
- class: "space-y-4"
1545
- }, _hoisted_4$9 = { class: "fm-typo-en-body-lg-400 class flex items-center justify-between" }, _hoisted_5$7 = { class: "text-ellipsis line-clamp-1" }, _sfc_main$e = /* @__PURE__ */ defineComponent({
1546
- __name: "ScheduleRuleInput",
1547
- props: {
1548
- modelValue: {
1549
- type: Object,
1550
- required: !0
1551
- },
1552
- startDate: {
1553
- type: String
1554
- },
1555
- endDate: {
1556
- type: String
1557
- }
1558
- },
1559
- emits: ["update:model-value"],
1560
- setup(e, { emit: l }) {
1561
- const { t: o } = useI18n(), s = e, r = l, y = useCoreStore(), a = computed(
1562
- () => CountryTimezone[y.currentCountry.value || "MY"]
1563
- );
1564
- function n() {
1565
- const h = RuleBuilder.getRules(s.modelValue);
1566
- return h.length == 0 ? "fixed" : h.some(
1567
- (d) => isRuleEntry(d) && RuleBuilder.simplify(d).operator == "_rrule"
1568
- ) ? "repeating" : "fixed";
1569
- }
1570
- const m = ref(n()), i = ref(!1), f = computed(() => [
1571
- { label: o("connect.template.rule.schedule.fixed"), value: "fixed" },
1572
- { label: o("connect.template.rule.schedule.repeating"), value: "repeating" }
1573
- ]), c = computed(() => {
1574
- const h = RuleBuilder.getRules(s.modelValue), d = h.find(
1575
- (v) => isRuleEntry(v) && RuleBuilder.simplify(v).property == "trigger.date"
1576
- ), p = h.find(
1577
- (v) => isRuleEntry(v) && RuleBuilder.simplify(v).property == "trigger.time"
1578
- );
1579
- return {
1580
- date: d ? RuleBuilder.simplify(d).equator : null,
1581
- time: p ? RuleBuilder.simplify(p).equator : null
1582
- };
1583
- }), u = computed(
1584
- () => calculateNextScheduleAt(
1585
- s.modelValue,
1586
- /* @__PURE__ */ new Date(),
1587
- s.startDate ? new Date(s.startDate) : void 0,
1588
- s.endDate ? new Date(s.endDate) : void 0
1589
- )
1590
- );
1591
- function k(h) {
1592
- const d = h.value, p = d == "fixed" ? [
1593
- RuleBuilder.constructEntry(
1594
- "trigger.date",
1595
- "_isOnDate",
1596
- (/* @__PURE__ */ new Date()).toISOString()
1597
- ),
1598
- RuleBuilder.constructEntry("trigger.time", "_isOnTime", "00:00")
1599
- ] : [
1600
- RuleBuilder.constructEntry(
1601
- "trigger.date",
1602
- "_rrule",
1603
- "RRULE:FREQ=DAILY;INTERVAL=1;BYHOUR=0;BYMINUTE=0;BYSECOND=0;WKST=SU"
1604
- ),
1605
- RuleBuilder.constructEntry("trigger.time", "_isOnTime", "00:00")
1606
- ];
1607
- r(
1608
- "update:model-value",
1609
- RuleBuilder.setRuleToGroup(
1610
- RuleBuilder.scaffoldGroup("g_schedule"),
1611
- p
1612
- )
1613
- ), m.value = d;
1614
- }
1615
- function b(h) {
1616
- m.value == "fixed" ? r(
1617
- "update:model-value",
1618
- RuleBuilder.setRuleToGroup(RuleBuilder.scaffoldGroup("g_schedule"), [
1619
- RuleBuilder.constructEntry(
1620
- "trigger.date",
1621
- "_isOnDate",
1622
- h.date
1623
- ),
1624
- RuleBuilder.constructEntry(
1625
- "trigger.time",
1626
- "_isOnTime",
1627
- h.time
1628
- )
1629
- ])
1630
- ) : r(
1631
- "update:model-value",
1632
- RuleBuilder.setRuleToGroup(RuleBuilder.scaffoldGroup("g_schedule"), [
1633
- RuleBuilder.constructEntry(
1634
- "trigger.date",
1635
- "_rrule",
1636
- h.date
1637
- ),
1638
- RuleBuilder.constructEntry(
1639
- "trigger.time",
1640
- "_isOnTime",
1641
- h.time
1642
- )
1643
- ])
1644
- );
1645
- }
1646
- return (h, d) => {
1647
- const p = resolveComponent("FmButtonGroup"), v = resolveComponent("FmTimePicker"), C = resolveComponent("FmIcon"), V = resolveComponent("FmTooltip"), B = resolveComponent("FmField"), S = resolveComponent("FmCard"), $ = resolveComponent("FmPopover"), w = resolveComponent("FmDatePicker"), R = resolveComponent("FmHelperText");
1648
- return openBlock(), createElementBlock(Fragment, null, [
1649
- createVNode(p, {
1650
- items: unref(f),
1651
- "model-value": unref(f).find((T) => T.value === unref(m)) ?? null,
1652
- "onUpdate:modelValue": k,
1653
- class: "mb-8"
1654
- }, null, 8, ["items", "model-value"]),
1655
- createElementVNode("div", _hoisted_1$e, [
1656
- createElementVNode("div", _hoisted_2$b, [
1657
- createVNode(v, {
1658
- label: unref(o)("connect.template.rule.schedule.notify_time"),
1659
- "model-value": unref(c).time,
1660
- "onUpdate:modelValue": d[0] || (d[0] = (T) => b({ date: unref(c).date, time: T })),
1661
- "helper-text": unref(c).time ? void 0 : unref(o)("connect.template.rule.schedule.time_required"),
1662
- "helper-state": unref(c).time ? void 0 : "error"
1663
- }, null, 8, ["label", "model-value", "helper-text", "helper-state"]),
1664
- unref(m) == "repeating" ? (openBlock(), createElementBlock("div", _hoisted_3$9, [
1665
- createElementVNode("div", _hoisted_4$9, [
1666
- createElementVNode("div", null, toDisplayString(unref(o)("connect.template.rule.schedule.notify_date")), 1),
1667
- unref(c).date ? (openBlock(), createBlock(V, {
1668
- key: 0,
1669
- "z-index": 9999,
1670
- content: unref(SummarizeRrule)(unref(RRule).fromString(unref(c).date).options)
1671
- }, {
1672
- default: withCtx(() => [
1673
- createVNode(C, {
1674
- name: "info",
1675
- size: "sm",
1676
- outline: !0
1677
- })
1678
- ]),
1679
- _: 1
1680
- }, 8, ["content"])) : createCommentVNode("", !0)
1681
- ]),
1682
- createVNode($, {
1683
- "show-popover": unref(i),
1684
- onPopoverChanged: d[3] || (d[3] = (T) => i.value = T)
1685
- }, {
1686
- "popover-button": withCtx(() => [
1687
- createVNode(B, {
1688
- class: "cursor-pointer",
1689
- "helper-text": unref(c).date ? void 0 : unref(o)("connect.template.rule.schedule.date_required"),
1690
- "helper-state": unref(c).date ? void 0 : "error"
1691
- }, {
1692
- default: withCtx(() => [
1693
- createElementVNode("div", _hoisted_5$7, toDisplayString(unref(c).date ? unref(SummarizeRrule)(unref(RRule).fromString(unref(c).date).options) : unref(o)("connect.template.rule.schedule.set_repeating_date")), 1)
1694
- ]),
1695
- _: 1
1696
- }, 8, ["helper-text", "helper-state"])
1697
- ]),
1698
- default: withCtx(() => [
1699
- createVNode(S, { class: "elevated p-8 w-[450px]" }, {
1700
- default: withCtx(() => [
1701
- createVNode(_sfc_main$u, {
1702
- "apply-button": !0,
1703
- "model-value": unref(c).date || "",
1704
- onCancel: d[1] || (d[1] = (T) => i.value = !1),
1705
- "onUpdate:modelValue": d[2] || (d[2] = (T) => (b({ date: T, time: unref(c).time }), i.value = !1))
1706
- }, null, 8, ["model-value"])
1707
- ]),
1708
- _: 1
1709
- })
1710
- ]),
1711
- _: 1
1712
- }, 8, ["show-popover"])
1713
- ])) : (openBlock(), createBlock(w, {
1714
- key: 1,
1715
- label: unref(o)("connect.template.rule.schedule.notify_date"),
1716
- "model-value": unref(c).date || "",
1717
- "onUpdate:modelValue": d[4] || (d[4] = (T) => b({ date: T, time: unref(c).time })),
1718
- "helper-text": unref(c).date ? void 0 : unref(o)("connect.template.rule.schedule.date_required"),
1719
- "helper-state": unref(c).date ? void 0 : "error"
1720
- }, null, 8, ["label", "model-value", "helper-text", "helper-state"]))
1721
- ]),
1722
- unref(c).date && unref(c).time && unref(u) ? (openBlock(), createBlock(R, {
1723
- key: 0,
1724
- text: `${unref(moment)(unref(u)).isAfter(unref(moment)()) ? unref(o)("connect.template.rule.schedule.next_notification") : unref(o)("connect.template.rule.schedule.last_trigger_on")} ${unref(moment)(unref(u)).format("dddd, DD MMM YYYY")} at
1725
- ${unref(moment)(unref(u)).format("hh:mmA")}(UTC${unref(moment).tz(unref(a)).format("Z")}) (${unref(moment)(unref(u)).fromNow()})`
1726
- }, null, 8, ["text"])) : createCommentVNode("", !0)
1727
- ])
1728
- ], 64);
1729
- };
1730
- }
1731
- }), _hoisted_1$d = { class: "space-y-16" }, _hoisted_2$a = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$8 = { class: "grid grid-cols-2 gap-16" }, _hoisted_4$8 = { class: "fm-typo-en-title-sm-800" }, _hoisted_5$6 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$d = /* @__PURE__ */ defineComponent({
1732
- __name: "GameTypeInput",
1733
- props: {
1734
- modelValue: {
1735
- type: String
1736
- }
1737
- },
1738
- emits: ["update:model-value"],
1739
- setup(e, { emit: l }) {
1740
- const { t: o } = useI18n(), s = e, r = l, y = computed(
1741
- () => [
1742
- {
1743
- label: o("connect.campaign.gameType.option.FORTUNE_WHEEL.label"),
1744
- description: o("connect.campaign.gameType.option.FORTUNE_WHEEL.description"),
1745
- value: F_GAME_TYPE.enum.FORTUNE_WHEEL,
1746
- hidden: !1
1747
- },
1748
- {
1749
- label: o("connect.campaign.gameType.option.ROCK_PAPER_SCISSORS.label"),
1750
- description: o("connect.campaign.gameType.option.ROCK_PAPER_SCISSORS.description"),
1751
- value: F_GAME_TYPE.enum.ROCK_PAPER_SCISSORS,
1752
- hidden: !0
1753
- }
1754
- ].filter((a) => !a.hidden)
1755
- );
1756
- return (a, n) => {
1757
- const m = resolveComponent("FmCard");
1758
- return openBlock(), createElementBlock("div", _hoisted_1$d, [
1759
- createElementVNode("div", _hoisted_2$a, toDisplayString(unref(o)("connect.template.select_game")), 1),
1760
- createElementVNode("div", _hoisted_3$8, [
1761
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(y), (i) => (openBlock(), createBlock(m, {
1762
- variant: "outlined",
1763
- class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
1764
- "col-span-2": unref(y).length == 1,
1765
- "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": e.modelValue == i.value,
1766
- "hover:bg-fm-color-opacity-sm": e.modelValue != i.value
1767
- }]),
1768
- onClick: () => {
1769
- s.modelValue != i.value && r("update:model-value", i.value);
1770
- },
1771
- key: i.value
1772
- }, {
1773
- default: withCtx(() => [
1774
- createElementVNode("div", _hoisted_4$8, toDisplayString(i.label), 1),
1775
- createElementVNode("div", _hoisted_5$6, toDisplayString(i.description), 1)
1776
- ]),
1777
- _: 2
1778
- }, 1032, ["class", "onClick"]))), 128))
1779
- ])
1780
- ]);
1781
- };
1782
- }
1783
- }), _hoisted_1$c = {
1784
- key: 0,
1785
- class: "flex flex-col gap-y-24"
1786
- }, _hoisted_2$9 = { class: "flex gap-8 items-center justify-start" }, _sfc_main$c = /* @__PURE__ */ defineComponent({
1787
- __name: "EditRewardPoolSheet",
1788
- emits: ["update:model-value"],
1789
- setup(e, { expose: l, emit: o }) {
1790
- const s = useMembershipStore(), { minor: r } = useLoading, y = ref(!1), a = ref(), n = ref(), m = ref(0), i = computed(
1791
- () => {
1792
- var d;
1793
- return (d = s.loyaltyRewards.items.find(
1794
- (p) => {
1795
- var v;
1796
- return p.value === ((v = a.value) == null ? void 0 : v.collectible);
1797
- }
1798
- )) == null ? void 0 : d.raw.type;
1799
- }
1800
- ), f = computed(
1801
- () => {
1802
- var d;
1803
- return ((d = a.value) == null ? void 0 : d.type) === "LOYALTY" && (i.value === "CREDIT" || i.value === "TITLE");
1804
- }
1805
- ), c = computed(
1806
- () => f.value ? FdoCreditLoyaltyReward : FdtoRandomReward
1807
- ), u = computed(() => {
1808
- const d = c.value.safeParse(a.value);
1809
- return d.success ? [] : d.error.errors;
1810
- });
1811
- function k(d, p, v) {
1812
- d && (a.value = p, m.value = v), y.value = d;
1813
- }
1814
- const b = o;
1815
- async function h() {
1816
- const d = c.value.safeParse(a.value);
1817
- d.success && (await r(
1818
- async () => {
1819
- d.data.type === "VOUCHER" && n.value && (d.data.collectibleConfig.image = await firebaseStorage.update(
1820
- d.data.collectibleConfig.image || firebaseStorage.collectibleImagePath(void 0, n.value),
1821
- n.value
1822
- ));
1823
- },
1824
- {
1825
- message: "Uploading reward image",
1826
- successMessage: "Reward image updated"
1827
- }
1828
- ), b("update:model-value", d.data, m.value));
1829
- }
1830
- return l({
1831
- showSheet: k
1832
- }), (d, p) => {
1833
- const v = resolveComponent("FmSelect"), C = resolveComponent("FmStepperField"), V = resolveComponent("FmButton"), B = resolveComponent("FmSideSheet");
1834
- return openBlock(), createBlock(B, {
1835
- "max-width": 560,
1836
- modelValue: unref(y),
1837
- "onUpdate:modelValue": [
1838
- p[9] || (p[9] = (S) => isRef(y) ? y.value = S : null),
1839
- p[10] || (p[10] = (S) => y.value = S)
1840
- ],
1841
- header: "Edit reward",
1842
- "dismiss-away": ""
1843
- }, {
1844
- "side-sheet-footer": withCtx(() => [
1845
- createElementVNode("div", _hoisted_2$9, [
1846
- createVNode(V, {
1847
- variant: "primary",
1848
- type: "button",
1849
- disabled: unref(u).length > 0,
1850
- label: "Confirm",
1851
- onClick: p[7] || (p[7] = (S) => h())
1852
- }, null, 8, ["disabled"]),
1853
- createVNode(V, {
1854
- variant: "secondary",
1855
- type: "button",
1856
- label: "Cancel",
1857
- onClick: p[8] || (p[8] = (S) => y.value = !1)
1858
- })
1859
- ])
1860
- ]),
1861
- default: withCtx(() => {
1862
- var S;
1863
- return [
1864
- unref(a) ? (openBlock(), createElementBlock("div", _hoisted_1$c, [
1865
- createVNode(v, {
1866
- label: "Reward Type",
1867
- items: [
1868
- { label: "No Reward", value: "NO_REWARD" },
1869
- { label: "Voucher", value: "VOUCHER" },
1870
- { label: "Loyalty", value: "LOYALTY" }
1871
- ],
1872
- "model-value": unref(a).type,
1873
- "onUpdate:modelValue": p[0] || (p[0] = ($) => {
1874
- $ == "NO_REWARD" ? a.value = {
1875
- type: "NO_REWARD",
1876
- collectible: null,
1877
- weight: 1
1878
- } : $ === "VOUCHER" ? a.value = {
1879
- collectible: null,
1880
- type: "VOUCHER",
1881
- collectibleConfig: unref(initCollectibleConfig)("VOUCHER", {
1882
- business: unref(useCoreStore)().currentBusiness.value._id
1883
- }),
1884
- earningOption: {
1885
- amount: 1,
1886
- type: "FIXED"
1887
- },
1888
- validityOption: {
1889
- validForDay: 7
1890
- },
1891
- weight: 1
1892
- } : a.value = {
1893
- collectible: unref(s).loyaltyRewards.raw[0]._id,
1894
- type: "LOYALTY",
1895
- earningOption: {
1896
- amount: 1,
1897
- type: "FIXED"
1898
- },
1899
- validityOption: {
1900
- validForDay: 7
1901
- },
1902
- weight: 1
1903
- };
1904
- })
1905
- }, null, 8, ["model-value"]),
1906
- unref(a).type == "LOYALTY" ? (openBlock(), createBlock(v, {
1907
- key: 0,
1908
- label: "Loyalty type",
1909
- rules: [unref(ZodHelper).ruleAtPath(unref(c), "collectible", [unref(a).type])],
1910
- items: unref(s).loyaltyRewards.items,
1911
- "model-value": unref(a).collectible,
1912
- "onUpdate:modelValue": p[1] || (p[1] = ($) => unref(a).collectible = $)
1913
- }, null, 8, ["rules", "items", "model-value"])) : createCommentVNode("", !0),
1914
- createVNode(C, {
1915
- label: "Weight",
1916
- rules: [unref(ZodHelper).ruleAtPath(unref(c), "weight", [unref(a).type])],
1917
- "model-value": unref(a).weight,
1918
- "onUpdate:modelValue": p[2] || (p[2] = ($) => a.value = {
1919
- ...unref(a),
1920
- weight: $
1921
- })
1922
- }, null, 8, ["rules", "model-value"]),
1923
- unref(a).type === "LOYALTY" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
1924
- unref(i) !== "TITLE" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
1925
- p[11] || (p[11] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Earning option", -1)),
1926
- createVNode(_sfc_main$v, {
1927
- class: "mt-[-8px]",
1928
- rules: [
1929
- unref(ZodHelper).ruleAtPath(unref(c), "earningOption", [unref(a).type])
1930
- ],
1931
- "helper-state": unref(ZodHelper).helperState(unref(u), "earningOption"),
1932
- "error-text": unref(ZodHelper).helperText(unref(u), "earningOption"),
1933
- "fixed-type": !0,
1934
- "model-value": unref(a).earningOption,
1935
- "onUpdate:modelValue": p[3] || (p[3] = ($) => a.value = {
1936
- ...unref(a),
1937
- earningOption: $
1938
- })
1939
- }, null, 8, ["rules", "helper-state", "error-text", "model-value"])
1940
- ], 64)) : createCommentVNode("", !0),
1941
- p[12] || (p[12] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Validity option", -1)),
1942
- createVNode(_sfc_main$w, {
1943
- type: unref(a).type === "LOYALTY" ? "custom" : "range",
1944
- "for-credit": unref(f),
1945
- class: "!gap-24",
1946
- rules: [unref(ZodHelper).ruleAtPath(unref(c), "validityOption", [unref(a).type])],
1947
- "model-value": unref(a).validityOption,
1948
- "onUpdate:modelValue": p[4] || (p[4] = ($) => a.value = {
1949
- ...unref(a),
1950
- validityOption: $
1951
- })
1952
- }, null, 8, ["type", "for-credit", "rules", "model-value"])
1953
- ], 64)) : createCommentVNode("", !0),
1954
- unref(a).type === "VOUCHER" ? (openBlock(), createBlock(_sfc_main$x, {
1955
- key: 2,
1956
- "reward-image": unref(n),
1957
- "model-value": ((S = unref(a)) == null ? void 0 : S.collectibleConfig) ?? void 0,
1958
- "onUpdate:modelValue": p[5] || (p[5] = ($) => a.value = {
1959
- ...unref(a),
1960
- collectibleConfig: $
1961
- }),
1962
- "onUpdate:rewardImage": p[6] || (p[6] = ($) => n.value = $)
1963
- }, null, 8, ["reward-image", "model-value"])) : createCommentVNode("", !0),
1964
- createVNode(JsonViewer, { json: unref(u) }, null, 8, ["json"])
1965
- ])) : createCommentVNode("", !0)
1966
- ];
1967
- }),
1968
- _: 1
1969
- }, 8, ["modelValue"]);
1970
- };
1971
- }
1972
- });
1973
- function isNullOrEmpty(e) {
1974
- return e == null || e === "";
1975
- }
1976
- const _hoisted_1$b = { class: "space-y-16" }, _hoisted_2$8 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$7 = { class: "fm-typo-en-body-lg-400" }, _hoisted_4$7 = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _sfc_main$b = /* @__PURE__ */ defineComponent({
1977
- __name: "RewardPoolInput",
1978
- props: {
1979
- modelValue: {
1980
- type: Array,
1981
- default: () => [
1982
- {
1983
- collectible: null,
1984
- type: "NO_REWARD",
1985
- weight: 1
1986
- }
1987
- ]
1988
- }
1989
- },
1990
- emits: ["update:model-value"],
1991
- setup(e, { emit: l }) {
1992
- const o = e, s = l, r = useMembershipStore(), { t: y } = useI18n(), a = z.array(z.lazy(() => FdtoRandomReward)).min(1, "Requires at least 1 reward"), n = computed(() => o.modelValue ?? []), m = computed(() => {
1993
- const h = a.safeParse(n.value);
1994
- return h.success ? [] : h.error.errors;
1995
- }), i = ref();
1996
- function f(h, d) {
1997
- var v;
1998
- const p = [...n.value];
1999
- p[d] = h, (v = i.value) == null || v.showSheet(!1), s("update:model-value", p);
2000
- }
2001
- function c(h) {
2002
- const d = h.type == "VOUCHER" ? h.collectibleConfig : r.collectibles.find(
2003
- (C) => C._id.toString() == h.collectible
2004
- ), p = CollectionUtils.formattedType((d == null ? void 0 : d.name) || ""), v = h.weight;
2005
- return {
2006
- label: isNullOrEmpty(p) ? "NO REWARD" : p,
2007
- sublabel: `${v} (${(v / n.value.reduce((C, V) => C + V.weight, 0) * 100).toFixed(2)}%)`
2008
- };
2009
- }
2010
- function u(h) {
2011
- var p;
2012
- const d = [...n.value];
2013
- (p = i.value) == null || p.showSheet(!0, d[h], h);
2014
- }
2015
- function k(h) {
2016
- const d = [...n.value];
2017
- d.splice(h, 1), s("update:model-value", d);
2018
- }
2019
- function b() {
2020
- var h;
2021
- (h = i.value) == null || h.showSheet(
2022
- !0,
2023
- {
2024
- type: "NO_REWARD",
2025
- collectible: null,
2026
- weight: 1
2027
- },
2028
- n.value.length
2029
- );
2030
- }
2031
- return (h, d) => {
2032
- const p = resolveComponent("FmButton"), v = resolveComponent("FmCard"), C = resolveComponent("FmHelperText");
2033
- return openBlock(), createElementBlock("div", _hoisted_1$b, [
2034
- createElementVNode("div", _hoisted_2$8, toDisplayString(unref(y)("connect.template.configure_reward_type")), 1),
2035
- createVNode(p, {
2036
- label: unref(y)("connect.campaign.rewardPool.addReward"),
2037
- onClick: d[0] || (d[0] = (V) => b()),
2038
- variant: "plain",
2039
- icon: "add"
2040
- }, null, 8, ["label"]),
2041
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(n), (V, B) => (openBlock(), createBlock(v, {
2042
- key: B,
2043
- class: "px-16 py-12 flex items-center justify-between cursor-pointer",
2044
- variant: "outlined",
2045
- onClick: (S) => u(B)
2046
- }, {
2047
- default: withCtx(() => {
2048
- var S;
2049
- return [
2050
- createElementVNode("div", null, [
2051
- createElementVNode("div", _hoisted_3$7, toDisplayString(V.type == "LOYALTY" ? (S = V == null ? void 0 : V.earningOption) == null ? void 0 : S.amount : "") + " " + toDisplayString(c(V).label), 1),
2052
- createElementVNode("div", _hoisted_4$7, toDisplayString(c(V).sublabel), 1)
2053
- ]),
2054
- createVNode(p, {
2055
- icon: "delete",
2056
- variant: "tertiary",
2057
- onClick: ($) => ($.stopPropagation(), k(B))
2058
- }, null, 8, ["onClick"])
2059
- ];
2060
- }),
2061
- _: 2
2062
- }, 1032, ["onClick"]))), 128)),
2063
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(m).filter((V) => V.path.join(".") == ""), (V) => (openBlock(), createBlock(C, {
2064
- key: V.message,
2065
- text: V.message,
2066
- state: "error"
2067
- }, null, 8, ["text"]))), 128)),
2068
- createVNode(_sfc_main$c, {
2069
- ref_key: "sheetRef",
2070
- ref: i,
2071
- "onUpdate:modelValue": f
2072
- }, null, 512)
2073
- ]);
2074
- };
2075
- }
2076
- }), _hoisted_1$a = { class: "space-y-16" }, _hoisted_2$7 = {
2077
- key: 0,
2078
- class: "grid grid-cols-2 gap-16"
2079
- }, _hoisted_3$6 = { class: "fm-typo-en-title-sm-800" }, _hoisted_4$6 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$a = /* @__PURE__ */ defineComponent({
2080
- __name: "PromotionGameTypeInput",
2081
- props: {
2082
- modelValue: {
2083
- type: Object
2084
- }
2085
- },
2086
- emits: ["update:model-value"],
2087
- setup(e, { emit: l }) {
2088
- const { t: o } = useI18n(), s = e, r = l, y = computed(() => [
2089
- {
2090
- label: o("connect.template.promotion_game.rock_paper_scissors.label"),
2091
- description: o("connect.template.promotion_game.rock_paper_scissors.description"),
2092
- value: F_GAME_TYPE.enum.ROCK_PAPER_SCISSORS
2093
- }
2094
- ]);
2095
- return (a, n) => {
2096
- var c, u, k;
2097
- const m = resolveComponent("FmSwitch"), i = resolveComponent("FmCard"), f = resolveComponent("FmHelperText");
2098
- return openBlock(), createElementBlock("div", _hoisted_1$a, [
2099
- createVNode(m, {
2100
- label: unref(o)("connect.template.promotion_game.enable"),
2101
- "model-value": !!((c = e.modelValue) != null && c.gameType),
2102
- "onUpdate:modelValue": n[0] || (n[0] = (b) => b ? r("update:model-value", { gameType: "ROCK_PAPER_SCISSORS" }) : r("update:model-value", null))
2103
- }, null, 8, ["label", "model-value"]),
2104
- ((u = e.modelValue) == null ? void 0 : u.gameType) == "ROCK_PAPER_SCISSORS" ? (openBlock(), createElementBlock("div", _hoisted_2$7, [
2105
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(y), (b) => {
2106
- var h, d;
2107
- return openBlock(), createBlock(i, {
2108
- variant: "outlined",
2109
- class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
2110
- "col-span-2": unref(y).length == 1,
2111
- "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": ((h = e.modelValue) == null ? void 0 : h.gameType) == b.value,
2112
- "hover:bg-fm-color-opacity-sm": ((d = e.modelValue) == null ? void 0 : d.gameType) != b.value
2113
- }]),
2114
- onClick: () => {
2115
- var p;
2116
- ((p = s.modelValue) == null ? void 0 : p.gameType) != b.value && r("update:model-value", { gameType: b.value });
2117
- },
2118
- key: b.value
2119
- }, {
2120
- default: withCtx(() => [
2121
- createElementVNode("div", _hoisted_3$6, toDisplayString(b.label), 1),
2122
- createElementVNode("div", _hoisted_4$6, toDisplayString(b.description), 1)
2123
- ]),
2124
- _: 2
2125
- }, 1032, ["class", "onClick"]);
2126
- }), 128))
2127
- ])) : createCommentVNode("", !0),
2128
- ((k = e.modelValue) == null ? void 0 : k.gameType) == "ROCK_PAPER_SCISSORS" ? (openBlock(), createBlock(f, {
2129
- key: 1,
2130
- text: unref(o)("connect.template.promotion_game.rock_paper_scissors.warning"),
2131
- state: "warning"
2132
- }, null, 8, ["text"])) : createCommentVNode("", !0)
2133
- ]);
2134
- };
2135
- }
2136
- }), _hoisted_1$9 = { class: "space-y-16" }, _hoisted_2$6 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$5 = { class: "grid grid-cols-2 gap-16" }, _hoisted_4$5 = { class: "fm-typo-en-title-sm-800" }, _hoisted_5$5 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$9 = /* @__PURE__ */ defineComponent({
2137
- __name: "MissionTypeInput",
2138
- props: {
2139
- modelValue: {
2140
- type: String
2141
- }
2142
- },
2143
- emits: ["update:model-value"],
2144
- setup(e, { emit: l }) {
2145
- const { t: o } = useI18n(), s = e, r = l, y = computed(() => [
2146
- {
2147
- label: o("connect.campaign.mission.typeOption.STAMP.label"),
2148
- description: o("connect.campaign.mission.typeOption.STAMP.description"),
2149
- value: F_MISSION_TYPE.enum.STAMP
2150
- },
2151
- {
2152
- label: o("connect.campaign.mission.typeOption.PROGRESSIVE.label"),
2153
- description: o("connect.campaign.mission.typeOption.PROGRESSIVE.description"),
2154
- value: F_MISSION_TYPE.enum.PROGRESSIVE
2155
- }
2156
- ]);
2157
- return (a, n) => {
2158
- const m = resolveComponent("FmCard");
2159
- return openBlock(), createElementBlock("div", _hoisted_1$9, [
2160
- createElementVNode("div", _hoisted_2$6, toDisplayString(unref(o)("connect.template.select_game")), 1),
2161
- createElementVNode("div", _hoisted_3$5, [
2162
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(y), (i) => (openBlock(), createBlock(m, {
2163
- variant: "outlined",
2164
- class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
2165
- "col-span-2": unref(y).length == 1,
2166
- "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": e.modelValue == i.value,
2167
- "hover:bg-fm-color-opacity-sm": e.modelValue != i.value
2168
- }]),
2169
- onClick: () => {
2170
- s.modelValue != i.value && r("update:model-value", i.value);
2171
- },
2172
- key: i.value
2173
- }, {
2174
- default: withCtx(() => [
2175
- createElementVNode("div", _hoisted_4$5, toDisplayString(i.label), 1),
2176
- createElementVNode("div", _hoisted_5$5, toDisplayString(i.description), 1)
2177
- ]),
2178
- _: 2
2179
- }, 1032, ["class", "onClick"]))), 128))
2180
- ])
2181
- ]);
2182
- };
2183
- }
2184
- }), _hoisted_1$8 = { class: "space-y-16" }, _sfc_main$8 = /* @__PURE__ */ defineComponent({
2185
- __name: "MissionEndInput",
2186
- props: {
2187
- modelValue: {
2188
- type: [String, Number]
2189
- },
2190
- helperText: {
2191
- type: String
2192
- },
2193
- helperState: {
2194
- type: String
2195
- }
2196
- },
2197
- emits: ["update:model-value"],
2198
- setup(e, { emit: l }) {
2199
- const o = l;
2200
- return (s, r) => {
2201
- const y = resolveComponent("FmStepperField");
2202
- return openBlock(), createElementBlock("div", _hoisted_1$8, [
2203
- r[1] || (r[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)),
2204
- createVNode(y, {
2205
- label: "Maximum to collect",
2206
- "model-value": e.modelValue || null,
2207
- "onUpdate:modelValue": r[0] || (r[0] = (a) => o("update:model-value", a)),
2208
- "helper-text": e.helperText || "Set the threshold required for reward eligibility",
2209
- "helper-state": e.helperState || "none"
2210
- }, null, 8, ["model-value", "helper-text", "helper-state"])
2211
- ]);
2212
- };
2213
- }
2214
- }), _hoisted_1$7 = { class: "flex gap-8 items-center justify-start" }, _sfc_main$7 = /* @__PURE__ */ defineComponent({
2215
- __name: "EditMissionPoolSheet",
2216
- props: {
2217
- maxThreshold: {
2218
- type: Number,
2219
- required: !0
2220
- }
2221
- },
2222
- emits: ["update:model-value"],
2223
- setup(e, { expose: l, emit: o }) {
2224
- const s = e, r = useMembershipStore(), { minor: y } = useLoading, a = ref(!1), n = ref(), m = ref(), i = ref(0), f = computed(() => {
2225
- var v, C;
2226
- const p = (v = r.loyaltyRewards.items.find(
2227
- (V) => {
2228
- var B;
2229
- return V.value === ((B = n.value) == null ? void 0 : B.collectible);
2230
- }
2231
- )) == null ? void 0 : v.raw.type;
2232
- return ((C = n.value) == null ? void 0 : C.type) === "LOYALTY" && (p === "CREDIT" || p === "TITLE");
2233
- }), c = computed(
2234
- () => f.value ? FdoThresholdCreditReward : FdtoThresholdReward
2235
- ), u = computed(() => {
2236
- const p = c.value.safeParse(n.value);
2237
- return p.success ? [] : p.error.errors;
2238
- });
2239
- function k(p, v, C) {
2240
- p && (n.value = v, i.value = C), a.value = p;
2241
- }
2242
- const b = o;
2243
- async function h() {
2244
- const p = c.value.safeParse(n.value);
2245
- p.success && (await y(
2246
- async () => {
2247
- p.data.type === "VOUCHER" && m.value && (p.data.collectibleConfig.image = await firebaseStorage.update(
2248
- p.data.collectibleConfig.image || firebaseStorage.collectibleImagePath(void 0, m.value),
2249
- m.value
2250
- ));
2251
- },
2252
- {
2253
- message: "Uploading reward image",
2254
- successMessage: "Reward image updated"
2255
- }
2256
- ), b("update:model-value", p.data, i.value));
2257
- }
2258
- const d = ref();
2259
- return l({
2260
- showSheet: k
2261
- }), (p, v) => {
2262
- const C = resolveComponent("FmStepperField"), V = resolveComponent("FmSelect"), B = resolveComponent("FmForm"), S = resolveComponent("FmButton"), $ = resolveComponent("FmSideSheet");
2263
- return openBlock(), createBlock($, {
2264
- "max-width": 560,
2265
- modelValue: unref(a),
2266
- "onUpdate:modelValue": [
2267
- v[10] || (v[10] = (w) => isRef(a) ? a.value = w : null),
2268
- v[11] || (v[11] = (w) => a.value = w)
2269
- ],
2270
- header: "Edit reward",
2271
- "dismiss-away": ""
2272
- }, {
2273
- "side-sheet-footer": withCtx(() => [
2274
- createElementVNode("div", _hoisted_1$7, [
2275
- createVNode(S, {
2276
- variant: "primary",
2277
- type: "button",
2278
- label: "Confirm",
2279
- disabled: unref(u).length > 0,
2280
- onClick: v[8] || (v[8] = async () => {
2281
- var w;
2282
- return (w = unref(d)) == null ? void 0 : w.validateInputs();
2283
- })
2284
- }, null, 8, ["disabled"]),
2285
- createVNode(S, {
2286
- variant: "secondary",
2287
- type: "button",
2288
- label: "Cancel",
2289
- onClick: v[9] || (v[9] = (w) => a.value = !1)
2290
- })
2291
- ])
2292
- ]),
2293
- default: withCtx(() => [
2294
- createVNode(JsonViewer, { json: unref(n) }, null, 8, ["json"]),
2295
- unref(n) ? (openBlock(), createBlock(B, {
2296
- key: 0,
2297
- class: "flex flex-col gap-y-24",
2298
- ref_key: "formRef",
2299
- ref: d,
2300
- onValidationSuccess: v[7] || (v[7] = (w) => h())
2301
- }, {
2302
- default: withCtx(() => {
2303
- var w;
2304
- return [
2305
- unref(n).type ? (openBlock(), createBlock(C, {
2306
- key: 0,
2307
- label: "Threshold",
2308
- rules: [
2309
- unref(ZodHelper).toRule(
2310
- unref(z).number().min(1).max(
2311
- s.maxThreshold,
2312
- `Number cannot be more than ${s.maxThreshold}`
2313
- )
2314
- )
2315
- ],
2316
- "model-value": unref(n).threshold,
2317
- "onUpdate:modelValue": v[0] || (v[0] = (R) => n.value = {
2318
- ...unref(n),
2319
- threshold: R
2320
- })
2321
- }, null, 8, ["rules", "model-value"])) : createCommentVNode("", !0),
2322
- createVNode(V, {
2323
- label: "Reward Type",
2324
- items: [
2325
- { label: "Voucher", value: "VOUCHER" },
2326
- { label: "Loyalty", value: "LOYALTY" }
2327
- ],
2328
- "model-value": unref(n).type,
2329
- "onUpdate:modelValue": v[1] || (v[1] = (R) => {
2330
- var T, O;
2331
- R === "VOUCHER" ? n.value = {
2332
- collectible: null,
2333
- type: "VOUCHER",
2334
- collectibleConfig: unref(initCollectibleConfig)("VOUCHER", {
2335
- business: unref(useCoreStore)().currentBusiness.value._id
2336
- }),
2337
- earningOption: {
2338
- amount: 1,
2339
- type: "FIXED"
2340
- },
2341
- validityOption: {
2342
- validForDay: 7
2343
- },
2344
- threshold: (T = unref(n)) == null ? void 0 : T.threshold
2345
- } : n.value = {
2346
- collectible: unref(r).loyaltyRewards.raw[0]._id,
2347
- type: "LOYALTY",
2348
- earningOption: {
2349
- amount: 1,
2350
- type: "FIXED"
2351
- },
2352
- validityOption: {
2353
- validForDay: 7
2354
- },
2355
- threshold: (O = unref(n)) == null ? void 0 : O.threshold
2356
- };
2357
- })
2358
- }, null, 8, ["model-value"]),
2359
- unref(n).type == "LOYALTY" ? (openBlock(), createBlock(V, {
2360
- key: 1,
2361
- label: "Loyalty type",
2362
- rules: [unref(ZodHelper).ruleAtPath(unref(c), "collectible", [unref(n).type])],
2363
- items: unref(r).loyaltyRewards.items,
2364
- "model-value": unref(n).collectible,
2365
- "onUpdate:modelValue": v[2] || (v[2] = (R) => unref(n).collectible = R)
2366
- }, null, 8, ["rules", "items", "model-value"])) : createCommentVNode("", !0),
2367
- unref(n).type === "LOYALTY" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
2368
- v[12] || (v[12] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Earning option", -1)),
2369
- createVNode(_sfc_main$v, {
2370
- class: "mt-[-8px]",
2371
- rules: [unref(ZodHelper).ruleAtPath(unref(c), "earningOption", [unref(n).type])],
2372
- "helper-state": unref(ZodHelper).helperState(unref(u), "earningOption"),
2373
- "error-text": unref(ZodHelper).helperText(unref(u), "earningOption"),
2374
- "fixed-type": !0,
2375
- "model-value": unref(n).earningOption,
2376
- "onUpdate:modelValue": v[3] || (v[3] = (R) => n.value = {
2377
- ...unref(n),
2378
- earningOption: R
2379
- })
2380
- }, null, 8, ["rules", "helper-state", "error-text", "model-value"]),
2381
- createVNode(_sfc_main$w, {
2382
- class: "!gap-24",
2383
- type: unref(n).type === "LOYALTY" ? "custom" : "range",
2384
- "for-credit": unref(f),
2385
- rules: [unref(ZodHelper).ruleAtPath(unref(c), "validityOption", [unref(n).type])],
2386
- "model-value": unref(n).validityOption,
2387
- "onUpdate:modelValue": v[4] || (v[4] = (R) => n.value = {
2388
- ...unref(n),
2389
- validityOption: R
2390
- })
2391
- }, null, 8, ["type", "for-credit", "rules", "model-value"])
2392
- ], 64)) : createCommentVNode("", !0),
2393
- unref(n).type === "VOUCHER" ? (openBlock(), createBlock(_sfc_main$x, {
2394
- key: 3,
2395
- "reward-image": unref(m),
2396
- "model-value": ((w = unref(n)) == null ? void 0 : w.collectibleConfig) ?? void 0,
2397
- "onUpdate:modelValue": v[5] || (v[5] = (R) => n.value = {
2398
- ...unref(n),
2399
- collectibleConfig: R
2400
- }),
2401
- "onUpdate:rewardImage": v[6] || (v[6] = (R) => m.value = R)
2402
- }, null, 8, ["reward-image", "model-value"])) : createCommentVNode("", !0),
2403
- createVNode(JsonViewer, { json: unref(u) }, null, 8, ["json"])
2404
- ];
2405
- }),
2406
- _: 1
2407
- }, 512)) : createCommentVNode("", !0)
2408
- ]),
2409
- _: 1
2410
- }, 8, ["modelValue"]);
2411
- };
2412
- }
2413
- }), _hoisted_1$6 = {
2414
- key: 0,
2415
- class: "grid grid-cols-5 text-center gap-8 justify-between items-center w-full"
2416
- }, _hoisted_2$5 = { class: "flex flex-col gap-0 items-center justify-center" }, _sfc_main$6 = /* @__PURE__ */ defineComponent({
2417
- __name: "MissionProgress",
2418
- props: {
2419
- type: {
2420
- type: String,
2421
- required: !0
2422
- },
2423
- maxRange: {
2424
- type: Number,
2425
- required: !0
2426
- },
2427
- currentRange: {
2428
- type: Number,
2429
- default: 0
2430
- },
2431
- markers: {
2432
- type: Array,
2433
- default: () => []
2434
- }
2435
- },
2436
- setup(e) {
2437
- const l = e, { maxRange: o, currentRange: s, markers: r } = toRefs(l), y = computed(
2438
- () => Math.min(s.value / o.value * 100, 100)
2439
- ), a = (n) => n / o.value * 100;
2440
- return (n, m) => {
2441
- const i = resolveComponent("FmIcon");
2442
- return e.type === "STAMP" ? (openBlock(), createElementBlock("div", _hoisted_1$6, [
2443
- (openBlock(!0), createElementBlock(Fragment, null, renderList(Math.min(unref(o), 40), (f) => (openBlock(), createBlock(i, {
2444
- class: normalizeClass(
2445
- unref(s) >= f ? "text-fm-color-primary" : "text-fm-color-neutral-gray-200"
2446
- ),
2447
- outline: unref(s) < f,
2448
- key: f,
2449
- name: unref(r).some((c) => c === f) ? "featured_seasonal_and_gifts" : "check_circle"
2450
- }, null, 8, ["class", "outline", "name"]))), 128))
2451
- ])) : (openBlock(), createElementBlock("div", {
2452
- key: 1,
2453
- class: normalizeClass(["relative w-full h-4 rounded-lg", "bg-fm-color-system-warning-100"])
2454
- }, [
2455
- createElementVNode("div", {
2456
- class: normalizeClass(["bg-fm-color-primary", "absolute top-0 left-0 h-full rounded-lg"]),
2457
- style: normalizeStyle({ width: unref(y) + "%" })
2458
- }, null, 4),
2459
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(r), (f, c) => (openBlock(), createElementBlock("div", {
2460
- key: c,
2461
- class: "absolute -top-1.5 flex flex-col items-center -translate-x-1/2",
2462
- style: normalizeStyle({ left: a(f) + "%" })
2463
- }, [
2464
- createElementVNode("div", _hoisted_2$5, [
2465
- createElementVNode("div", {
2466
- class: normalizeClass(["h-16 w-[2px]", "bg-fm-color-system-warning-300"])
2467
- }),
2468
- m[0] || (m[0] = createElementVNode("div", null, "🎁", -1))
2469
- ])
2470
- ], 4))), 128))
2471
- ]));
2472
- };
2473
- }
2474
- }), isObject = (e) => e !== null && typeof e == "object";
2475
- function changeKeysFactory(e) {
2476
- return function l(o, s = 1, r) {
2477
- if (s === 0 || !isObject(o))
2478
- return o;
2479
- if (Array.isArray(o))
2480
- return o.map((a) => l(a, s - 1, r));
2481
- const y = Object.create(Object.getPrototypeOf(o));
2482
- return Object.keys(o).forEach((a) => {
2483
- const n = o[a], m = e(a, r), i = l(n, s - 1, r);
2484
- y[m] = i;
2485
- }), y;
2486
- };
2487
- }
2488
- const sentenceCase = changeKeysFactory(sentenceCase$1), _hoisted_1$5 = { class: "space-y-16" }, _hoisted_2$4 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$4 = { class: "fm-typo-en-body-lg-400" }, _hoisted_4$4 = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _hoisted_5$4 = { class: "fm-typo-en-title-sm-800" }, _hoisted_6$4 = { class: "flex items-center gap-4" }, _hoisted_7$3 = { class: "fm-typo-en-body-lg-600" }, _hoisted_8$3 = { 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$5 = /* @__PURE__ */ defineComponent({
2489
- __name: "MissionPoolInput",
2490
- props: {
2491
- modelValue: {
2492
- type: Array,
2493
- default: () => []
2494
- },
2495
- mission: {
2496
- type: Object,
2497
- required: !0
2498
- }
2499
- },
2500
- emits: ["update:model-value"],
2501
- setup(e, { emit: l }) {
2502
- const { t: o } = useI18n(), s = e, r = l, y = useMembershipStore(), a = z.array(z.lazy(() => FdtoThresholdReward)).min(1, "Requires at least 1 reward"), n = computed(
2503
- () => s.modelValue.sort((d, p) => d.threshold - p.threshold) ?? []
2504
- ), m = computed(() => {
2505
- const d = a.safeParse(n.value);
2506
- return d.success ? [] : d.error.errors;
2507
- }), i = ref();
2508
- function f(d, p) {
2509
- var C;
2510
- const v = [...n.value];
2511
- v[p] = d, (C = i.value) == null || C.showSheet(!1), r("update:model-value", v);
2512
- }
2513
- function c(d) {
2514
- const p = d.type == "VOUCHER" ? d.collectibleConfig : y.collectibles.find(
2515
- (V) => V._id.toString() == d.collectible
2516
- ), v = CollectionUtils.formattedType((p == null ? void 0 : p.name) || ""), C = d.earningOption.type == "FIXED" ? o("connect.template.mission_pool.reward_sublabel_fixed", {
2517
- threshold: d.threshold,
2518
- amount: d.earningOption.amount
2519
- }) : o("connect.template.mission_pool.reward_sublabel_per_spend", {
2520
- threshold: d.threshold,
2521
- amount: d.earningOption.amount,
2522
- every: d.earningOption.every
2523
- });
2524
- return {
2525
- label: isNullOrEmpty(v) ? o("connect.template.mission_pool.no_reward") : v,
2526
- sublabel: C
2527
- };
2528
- }
2529
- function u(d) {
2530
- var v;
2531
- const p = [...n.value];
2532
- (v = i.value) == null || v.showSheet(!0, p[d], d);
2533
- }
2534
- function k(d) {
2535
- const p = [...n.value];
2536
- p.splice(d, 1), r("update:model-value", p);
2537
- }
2538
- function b() {
2539
- var d;
2540
- (d = i.value) == null || d.showSheet(
2541
- !0,
2542
- {
2543
- type: "LOYALTY",
2544
- collectible: y.loyaltyRewards.items[0].value,
2545
- threshold: null,
2546
- validityOption: {
2547
- validForDay: 7
2548
- },
2549
- earningOption: {
2550
- type: "FIXED",
2551
- amount: 1
2552
- }
2553
- },
2554
- n.value.length
2555
- );
2556
- }
2557
- function h(d) {
2558
- var p, v;
2559
- return d.type == "VOUCHER" ? (p = d.collectibleConfig) == null ? void 0 : p.name : sentenceCase(
2560
- ((v = y.loyaltyRewards.items.find(
2561
- (C) => C.value == d.collectible
2562
- )) == null ? void 0 : v.label) || ""
2563
- );
2564
- }
2565
- return (d, p) => {
2566
- const v = resolveComponent("FmButton"), C = resolveComponent("FmCard"), V = resolveComponent("FmHelperText");
2567
- return openBlock(), createElementBlock("div", _hoisted_1$5, [
2568
- createElementVNode("div", _hoisted_2$4, toDisplayString(unref(o)("connect.template.configure_reward_customer")), 1),
2569
- createVNode(v, {
2570
- label: unref(o)("connect.template.mission_pool.add_reward"),
2571
- onClick: p[0] || (p[0] = (B) => b()),
2572
- variant: "plain",
2573
- icon: "add"
2574
- }, null, 8, ["label"]),
2575
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(n), (B, S) => (openBlock(), createBlock(C, {
2576
- key: S,
2577
- class: "px-16 py-12 flex items-center justify-between cursor-pointer",
2578
- variant: "outlined",
2579
- onClick: ($) => u(S)
2580
- }, {
2581
- default: withCtx(() => [
2582
- createElementVNode("div", null, [
2583
- createElementVNode("div", _hoisted_3$4, toDisplayString(c(B).label), 1),
2584
- createElementVNode("div", _hoisted_4$4, toDisplayString(c(B).sublabel), 1)
2585
- ]),
2586
- createVNode(v, {
2587
- icon: "delete",
2588
- variant: "tertiary",
2589
- onClick: ($) => ($.stopPropagation(), k(S))
2590
- }, null, 8, ["onClick"])
2591
- ]),
2592
- _: 2
2593
- }, 1032, ["onClick"]))), 128)),
2594
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(m).filter((B) => B.path.join(".") == ""), (B) => (openBlock(), createBlock(V, {
2595
- key: B.message,
2596
- text: B.message,
2597
- state: "error"
2598
- }, null, 8, ["text"]))), 128)),
2599
- createElementVNode("div", _hoisted_5$4, toDisplayString(unref(o)("connect.template.mission_pool.preview")), 1),
2600
- (openBlock(), createBlock(C, {
2601
- key: 0,
2602
- variant: "outlined",
2603
- class: "p-24 space-y-16 w-fit"
2604
- }, {
2605
- default: withCtx(() => {
2606
- var B, S;
2607
- return [
2608
- createElementVNode("div", _hoisted_6$4, [
2609
- createElementVNode("div", null, [
2610
- createElementVNode("div", _hoisted_7$3, toDisplayString(unref(o)("connect.template.mission_pool.collect_stamps", { end: e.mission.end })) + " " + toDisplayString(((B = e.modelValue[e.modelValue.length - 1]) == null ? void 0 : B.earningOption.amount) > 1 ? (S = e.modelValue[e.modelValue.length - 1]) == null ? void 0 : S.earningOption.amount : "") + " " + toDisplayString(e.modelValue[e.modelValue.length - 1] ? h(e.modelValue[e.modelValue.length - 1]) : ""), 1),
2611
- createElementVNode("div", _hoisted_8$3, toDisplayString(unref(o)("connect.template.mission_pool.earn_stamp")), 1)
2612
- ])
2613
- ]),
2614
- createElementVNode("div", _hoisted_9$2, [
2615
- createVNode(_sfc_main$6, {
2616
- type: e.mission.type,
2617
- "max-range": e.mission.end,
2618
- currentRange: e.mission.end / 4,
2619
- markers: e.modelValue.map(($) => $.threshold)
2620
- }, null, 8, ["type", "max-range", "currentRange", "markers"]),
2621
- e.mission.type == "PROGRESSIVE" ? (openBlock(), createElementBlock("div", _hoisted_10$2, " 0/" + toDisplayString(e.mission.end.toLocaleString()), 1)) : createCommentVNode("", !0)
2622
- ])
2623
- ];
2624
- }),
2625
- _: 1
2626
- })),
2627
- createVNode(_sfc_main$7, {
2628
- ref_key: "sheetRef",
2629
- ref: i,
2630
- "onUpdate:modelValue": f,
2631
- "max-threshold": e.mission.end
2632
- }, null, 8, ["max-threshold"])
2633
- ]);
2634
- };
2635
- }
2636
- }), _hoisted_1$4 = { class: "space-y-16" }, _hoisted_2$3 = { class: "space-y-8" }, _hoisted_3$3 = { class: "fm-typo-en-title-sm-800" }, _hoisted_4$3 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_5$3 = { class: "grid grid-cols-2 gap-16" }, _hoisted_6$3 = { class: "fm-typo-en-title-sm-800" }, _hoisted_7$2 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_8$2 = { 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$4 = /* @__PURE__ */ defineComponent({
2637
- __name: "MissionInput",
2638
- props: {
2639
- modelValue: Object
2640
- },
2641
- emits: ["update:model-value"],
2642
- setup(e, { emit: l }) {
2643
- const { t: o } = useI18n(), s = e, r = computed(() => {
2644
- const n = FdoMission.safeParse(s.modelValue);
2645
- return n.success ? [] : n.error.errors;
2646
- }), y = computed(() => [
2647
- {
2648
- label: o("connect.campaign.mission.typeOption.STAMP.label"),
2649
- description: o("connect.campaign.mission.typeOption.STAMP.description"),
2650
- value: F_MISSION_TYPE.enum.STAMP
2651
- },
2652
- {
2653
- label: o("connect.campaign.mission.typeOption.PROGRESSIVE.label"),
2654
- description: o("connect.campaign.mission.typeOption.PROGRESSIVE.description"),
2655
- value: F_MISSION_TYPE.enum.PROGRESSIVE
2656
- }
2657
- ]), a = l;
2658
- return (n, m) => {
2659
- var c;
2660
- const i = resolveComponent("FmCard"), f = resolveComponent("FmStepperField");
2661
- return openBlock(), createElementBlock("div", _hoisted_1$4, [
2662
- createElementVNode("div", _hoisted_2$3, [
2663
- createElementVNode("div", _hoisted_3$3, toDisplayString(unref(o)("connect.campaign.mission.missionType")), 1),
2664
- createElementVNode("div", _hoisted_4$3, toDisplayString(unref(o)("connect.template.select_game")), 1),
2665
- createElementVNode("div", _hoisted_5$3, [
2666
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(y), (u) => {
2667
- var k, b;
2668
- return openBlock(), createBlock(i, {
2669
- variant: "outlined",
2670
- class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
2671
- "col-span-2": unref(y).length == 1,
2672
- "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": ((k = e.modelValue) == null ? void 0 : k.type) == u.value,
2673
- "hover:bg-fm-color-opacity-sm": ((b = e.modelValue) == null ? void 0 : b.type) != u.value
2674
- }]),
2675
- onClick: () => {
2676
- var h, d;
2677
- ((h = e.modelValue) == null ? void 0 : h.type) != u.value && a("update:model-value", {
2678
- ...e.modelValue,
2679
- type: u.value,
2680
- end: ((d = e.modelValue) == null ? void 0 : d.end) || 1
2681
- });
2682
- },
2683
- key: u.value
2684
- }, {
2685
- default: withCtx(() => [
2686
- createElementVNode("div", _hoisted_6$3, toDisplayString(u.label), 1),
2687
- createElementVNode("div", _hoisted_7$2, toDisplayString(u.description), 1)
2688
- ]),
2689
- _: 2
2690
- }, 1032, ["class", "onClick"]);
2691
- }), 128))
2692
- ])
2693
- ]),
2694
- createElementVNode("div", _hoisted_8$2, [
2695
- createElementVNode("div", _hoisted_9$1, toDisplayString(unref(o)("connect.campaign.mission.collectionsRequired")), 1),
2696
- createElementVNode("div", _hoisted_10$1, toDisplayString(unref(o)("connect.campaign.mission.collectionsRequiredDescription")), 1),
2697
- createVNode(f, {
2698
- label: unref(o)("connect.campaign.mission.maximumToCollect"),
2699
- "model-value": ((c = e.modelValue) == null ? void 0 : c.end) || null,
2700
- "onUpdate:modelValue": m[0] || (m[0] = (u) => {
2701
- var k;
2702
- return a("update:model-value", {
2703
- ...e.modelValue,
2704
- type: ((k = e.modelValue) == null ? void 0 : k.type) || "STAMP",
2705
- end: u
2706
- });
2707
- }),
2708
- "helper-text": unref(ZodHelper).helperText(unref(r), "end") || unref(o)("connect.campaign.mission.thresholdHelperText"),
2709
- "helper-state": unref(ZodHelper).helperState(unref(r), "end") || "none"
2710
- }, null, 8, ["label", "model-value", "helper-text", "helper-state"])
2711
- ])
2712
- ]);
2713
- };
2714
- }
2715
- });
2716
- function useLocaleText() {
2717
- const { locale: e, t: l } = useI18n();
2718
- function o(s, r) {
2719
- return s ? s[e.value] ?? s["en-US"] ?? l(r) : l(r);
2720
- }
2721
- return { getLocaleText: o };
2722
- }
2723
- const _hoisted_1$3 = { key: 26 }, _sfc_main$3 = /* @__PURE__ */ defineComponent({
2724
- __name: "TemplateInput",
2725
- props: {
2726
- pushAvailability: {
2727
- type: String,
2728
- default: "checking"
2729
- },
2730
- field: { type: Object, required: !0 },
2731
- modelValue: {
2732
- type: Object
2733
- },
2734
- schema: {
2735
- type: Object
2736
- },
2737
- extras: {
2738
- type: Object
2739
- },
2740
- helperText: {
2741
- type: String
2742
- },
2743
- disabled: {
2744
- type: Boolean,
2745
- default: !1
2746
- },
2747
- campaignType: {
2748
- type: String,
2749
- default: void 0
2750
- },
2751
- /** False until the form has been submitted, for fields that validate late. */
2752
- showValidation: {
2753
- type: Boolean,
2754
- default: !0
2755
- }
2756
- },
2757
- emits: ["retry-push", "update:model-value", "update:file"],
2758
- setup(e, { emit: l }) {
2759
- const { t: o } = useI18n(), { getLocaleText: s } = useLocaleText(), r = e, y = l;
2760
- function a(f) {
2761
- switch (r.field.type) {
2762
- case "timeframe":
2763
- const c = f.startDate ? hooks(f.startDate).startOf("day").toISOString() : void 0, u = f.endDate ? hooks(f.endDate).endOf("day").toISOString() : void 0;
2764
- y("update:model-value", {
2765
- type: "timeframe",
2766
- property: "__now",
2767
- start: c,
2768
- end: u
2769
- });
2770
- break;
2771
- case "image": {
2772
- y(
2773
- "update:file",
2774
- f,
2775
- n.value || firebaseStorage.collectibleImagePath(void 0, f)
2776
- );
2777
- break;
2778
- }
2779
- default:
2780
- y("update:model-value", f);
2781
- break;
2782
- }
2783
- }
2784
- const n = computed(() => {
2785
- switch (r.field.type) {
2786
- case "timeframe": {
2787
- const f = r.modelValue;
2788
- return {
2789
- startDate: f != null && f.start ? hooks(f == null ? void 0 : f.start).format("YYYY-MM-DD") : null,
2790
- endDate: f != null && f.end ? hooks(f == null ? void 0 : f.end).format("YYYY-MM-DD") : null
2791
- };
2792
- }
2793
- default:
2794
- return r.modelValue;
2795
- }
2796
- });
2797
- function m() {
2798
- if (!i.value.schema) return [];
2799
- const f = i.value.schema.safeParse(r.modelValue);
2800
- return f.success ? [] : f.error.errors;
2801
- }
2802
- const i = computed(() => ({
2803
- schema: r.schema,
2804
- unwrapped: r.schema ? ZodHelper.unwrap(r.schema) : void 0,
2805
- rules: r.schema ? [ZodHelper.ruleAtPath(r.schema, "")] : void 0,
2806
- labelMark: r.schema && ZodHelper.isRequired(r.schema) == !1 ? "optional" : void 0,
2807
- zodLabel: r.schema ? ZodHelper.toInputLabel(
2808
- r.schema,
2809
- s(r.field.label_locale, r.field.label ?? "")
2810
- ) : void 0
2811
- }));
2812
- return (f, c) => {
2813
- var p, v, C, V, B;
2814
- const u = resolveComponent("FmTextField"), k = resolveComponent("FmStepperField"), b = resolveComponent("FmTextarea"), h = resolveComponent("FmHelperText"), d = resolveComponent("FmSwitch");
2815
- return e.field.type === "text" ? (openBlock(), createBlock(u, {
2816
- key: 0,
2817
- label: unref(s)(e.field.label_locale, e.field.label ?? ""),
2818
- "label-mark": unref(i).labelMark,
2819
- rules: unref(i).rules,
2820
- "model-value": unref(n),
2821
- "onUpdate:modelValue": a,
2822
- "helper-state": e.helperText ? "error" : void 0,
2823
- "helper-text": e.helperText
2824
- }, null, 8, ["label", "label-mark", "rules", "model-value", "helper-state", "helper-text"])) : e.field.type === "number" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
2825
- createVNode(JsonViewer, {
2826
- json: { schema: unref(i).unwrapped, props: r }
2827
- }, null, 8, ["json"]),
2828
- createVNode(k, {
2829
- label: unref(s)(e.field.label_locale, e.field.label ?? ""),
2830
- "label-mark": e.field.isRuleChildren ? void 0 : unref(i).labelMark,
2831
- "model-value": unref(n),
2832
- rules: e.field.isRuleChildren ? [] : unref(i).rules,
2833
- "onUpdate:modelValue": a,
2834
- "helper-state": e.field.isRuleChildren && e.helperText ? "error" : void 0,
2835
- "helper-text": e.field.isRuleChildren ? e.helperText : void 0
2836
- }, null, 8, ["label", "label-mark", "model-value", "rules", "helper-state", "helper-text"])
2837
- ], 64)) : e.field.type === "textarea" ? (openBlock(), createBlock(b, {
2838
- key: 2,
2839
- label: unref(s)(e.field.label_locale, e.field.label ?? ""),
2840
- "label-mark": unref(i).labelMark,
2841
- rules: unref(i).rules,
2842
- "model-value": unref(n),
2843
- "onUpdate:modelValue": a,
2844
- "show-word-count": "",
2845
- "max-length": (B = (V = (C = (v = (p = unref(i)) == null ? void 0 : p.unwrapped) == null ? void 0 : v._def) == null ? void 0 : C.checks) == null ? void 0 : V.find((S) => S.kind == "max")) == null ? void 0 : B.value
2846
- }, null, 8, ["label", "label-mark", "rules", "model-value", "max-length"])) : e.field.type === "trigger" ? (openBlock(), createBlock(_sfc_main$n, {
2847
- key: 3,
2848
- "campaign-type": e.extras,
2849
- "model-value": unref(n),
2850
- disabled: e.disabled,
2851
- "onUpdate:modelValue": a
2852
- }, null, 8, ["campaign-type", "model-value", "disabled"])) : e.field.type === "timeframe" ? (openBlock(), createElementBlock(Fragment, { key: 4 }, [
2853
- createVNode(_sfc_main$l, {
2854
- "model-value": unref(n),
2855
- "onUpdate:modelValue": a
2856
- }, null, 8, ["model-value"]),
2857
- createVNode(h, {
2858
- class: "!mt-[8px]",
2859
- text: unref(ZodHelper).helperText(m(), ""),
2860
- state: unref(ZodHelper).helperState(m(), "")
2861
- }, null, 8, ["text", "state"])
2862
- ], 64)) : e.field.type === "image" ? (openBlock(), createBlock(_sfc_main$y, {
2863
- key: 5,
2864
- thumbnail: unref(n),
2865
- "aspect-ratio": "16 / 9",
2866
- class: "w-1/2 xs:w-2/3",
2867
- "onUpdate:file": a
2868
- }, {
2869
- label: withCtx(() => [
2870
- (openBlock(), createBlock(resolveDynamicComponent(unref(i).zodLabel)))
2871
- ]),
2872
- _: 1
2873
- }, 8, ["thumbnail"])) : e.field.type === "switch" ? (openBlock(), createBlock(d, {
2874
- key: 6,
2875
- label: unref(s)(e.field.label_locale, e.field.label ?? ""),
2876
- "label-placement": "right",
2877
- sublabel: e.field.property == "campaign.notify" ? "Notify customer when customer receives the reward" : void 0,
2878
- "label-mark": unref(i).labelMark,
2879
- rules: unref(i).rules,
2880
- "model-value": unref(n),
2881
- "onUpdate:modelValue": a
2882
- }, null, 8, ["label", "sublabel", "label-mark", "rules", "model-value"])) : e.field.type === "collectible_options" ? (openBlock(), createBlock(_sfc_main$z, {
2883
- key: 7,
2884
- "model-value": unref(n),
2885
- "onUpdate:modelValue": a,
2886
- "no-campaign": !1,
2887
- schema: unref(i).schema,
2888
- "is-mission": e.extras === "MISSION"
2889
- }, null, 8, ["model-value", "schema", "is-mission"])) : e.field.type === "target_location" ? (openBlock(), createBlock(_sfc_main$A, {
2890
- key: 8,
2891
- "model-value": unref(n),
2892
- "onUpdate:modelValue": a
2893
- }, null, 8, ["model-value"])) : e.field.type == "effect" ? (openBlock(), createElementBlock(Fragment, { key: 9 }, [
2894
- createVNode(_sfc_main$B, {
2895
- "model-value": unref(n),
2896
- "onUpdate:modelValue": a,
2897
- "can-set-auto-apply": e.field.property == "campaign.effect"
2898
- }, null, 8, ["model-value", "can-set-auto-apply"]),
2899
- unref(n) ? createCommentVNode("", !0) : (openBlock(), createBlock(h, {
2900
- key: 0,
2901
- class: "!mt-[8px]",
2902
- text: unref(o)("connect.campaign.common.effect_required"),
2903
- state: "error"
2904
- }, null, 8, ["text"]))
2905
- ], 64)) : e.field.type === "message" ? (openBlock(), createElementBlock(Fragment, { key: 10 }, [
2906
- e.field.property === "campaign.message" ? (openBlock(), createBlock(_sfc_main$f, {
2907
- key: 0,
2908
- "push-availability": e.pushAvailability,
2909
- onRetryPush: c[0] || (c[0] = (S) => y("retry-push")),
2910
- "show-validation": e.showValidation,
2911
- "model-value": unref(n),
2912
- "onUpdate:modelValue": a,
2913
- "helper-text": unref(ZodHelper).helperText(m(), ""),
2914
- "trigger-type": e.field.extras,
2915
- "helper-state": unref(ZodHelper).helperState(m(), "")
2916
- }, null, 8, ["push-availability", "show-validation", "model-value", "helper-text", "trigger-type", "helper-state"])) : (openBlock(), createBlock(_sfc_main$t, {
2917
- key: 1,
2918
- "allow-email": !0,
2919
- "allow-whatsapp": !0,
2920
- "model-value": unref(n),
2921
- "onUpdate:modelValue": a,
2922
- "helper-text": unref(ZodHelper).helperText(m(), ""),
2923
- "trigger-type": e.field.extras,
2924
- "helper-state": unref(ZodHelper).helperState(m(), "")
2925
- }, null, 8, ["model-value", "helper-text", "trigger-type", "helper-state"]))
2926
- ], 64)) : e.field.type === "earning_option" ? (openBlock(), createBlock(_sfc_main$v, {
2927
- key: 11,
2928
- "model-value": unref(n),
2929
- "onUpdate:modelValue": a,
2930
- extras: e.extras,
2931
- "error-text": e.helperText
2932
- }, null, 8, ["model-value", "extras", "error-text"])) : e.field.type === "validity_option" ? (openBlock(), createBlock(_sfc_main$w, {
2933
- key: 12,
2934
- type: "custom",
2935
- "model-value": unref(n),
2936
- "onUpdate:modelValue": a,
2937
- "helper-text": e.helperText || unref(ZodHelper).helperText(m(), ""),
2938
- "for-credit": r.campaignType === "CREDIT"
2939
- }, null, 8, ["model-value", "helper-text", "for-credit"])) : e.field.type === "game_type" ? (openBlock(), createBlock(_sfc_main$d, {
2940
- key: 13,
2941
- "model-value": unref(n),
2942
- "onUpdate:modelValue": a
2943
- }, null, 8, ["model-value"])) : e.field.type === "reward_pool" ? (openBlock(), createBlock(_sfc_main$b, {
2944
- key: 14,
2945
- "model-value": unref(n),
2946
- "onUpdate:modelValue": a
2947
- }, null, 8, ["model-value"])) : e.field.type === "mission" ? (openBlock(), createBlock(_sfc_main$4, {
2948
- key: 15,
2949
- "model-value": unref(n),
2950
- "onUpdate:modelValue": a
2951
- }, null, 8, ["model-value"])) : e.field.type === "mission_type" ? (openBlock(), createBlock(_sfc_main$9, {
2952
- key: 16,
2953
- "model-value": unref(n),
2954
- "onUpdate:modelValue": a
2955
- }, null, 8, ["model-value"])) : e.field.type === "mission_end" ? (openBlock(), createBlock(_sfc_main$8, {
2956
- key: 17,
2957
- "model-value": unref(n),
2958
- "onUpdate:modelValue": a,
2959
- "helper-text": unref(ZodHelper).helperText(m(), ""),
2960
- "helper-state": unref(ZodHelper).helperState(m(), "")
2961
- }, null, 8, ["model-value", "helper-text", "helper-state"])) : e.field.type === "mission_pool" ? (openBlock(), createBlock(_sfc_main$5, {
2962
- key: 18,
2963
- "model-value": unref(n),
2964
- "onUpdate:modelValue": a,
2965
- mission: e.extras.mission
2966
- }, null, 8, ["model-value", "mission"])) : e.field.type === "rule_schedule" ? (openBlock(), createElementBlock(Fragment, { key: 19 }, [
2967
- createVNode(_sfc_main$e, {
2968
- "model-value": unref(n),
2969
- "onUpdate:modelValue": a,
2970
- "start-date": e.extras.start,
2971
- "end-date": e.extras.end
2972
- }, null, 8, ["model-value", "start-date", "end-date"]),
2973
- e.helperText ? (openBlock(), createBlock(h, {
2974
- key: 0,
2975
- class: "!mt-[8px]",
2976
- text: e.helperText,
2977
- state: "error"
2978
- }, null, 8, ["text"])) : createCommentVNode("", !0)
2979
- ], 64)) : e.field.type === "rule_user" ? (openBlock(), createElementBlock(Fragment, { key: 20 }, [
2980
- createVNode(_sfc_main$C, {
2981
- "model-value": unref(n),
2982
- "onUpdate:modelValue": a
2983
- }, null, 8, ["model-value"]),
2984
- e.helperText ? (openBlock(), createBlock(h, {
2985
- key: 0,
2986
- class: "!mt-[8px]",
2987
- text: e.helperText,
2988
- state: "error"
2989
- }, null, 8, ["text"])) : createCommentVNode("", !0)
2990
- ], 64)) : e.field.type === "rule_time" ? (openBlock(), createElementBlock(Fragment, { key: 21 }, [
2991
- e.extras == "PROMOTION" && unref(RuleBuilder).getRules(unref(n).rules.g_time).length > 0 ? (openBlock(), createBlock(h, {
2992
- key: 0,
2993
- state: "warning",
2994
- text: `Time based rule only work for POS >= v${unref(featureVersionMapping).TIME_BASED_PROMOTION}`
2995
- }, null, 8, ["text"])) : createCommentVNode("", !0),
2996
- createVNode(_sfc_main$p, {
2997
- "model-value": unref(n),
2998
- "onUpdate:modelValue": a
2999
- }, null, 8, ["model-value"]),
3000
- e.helperText ? (openBlock(), createBlock(h, {
3001
- key: 1,
3002
- class: "!mt-[8px]",
3003
- text: e.helperText,
3004
- state: "error"
3005
- }, null, 8, ["text"])) : createCommentVNode("", !0)
3006
- ], 64)) : e.field.type === "rule_bill" ? (openBlock(), createElementBlock(Fragment, { key: 22 }, [
3007
- createVNode(_sfc_main$D, {
3008
- "model-value": unref(n),
3009
- "onUpdate:modelValue": a
3010
- }, null, 8, ["model-value"]),
3011
- e.helperText ? (openBlock(), createBlock(h, {
3012
- key: 0,
3013
- class: "!mt-[8px]",
3014
- text: e.helperText,
3015
- state: "error"
3016
- }, null, 8, ["text"])) : createCommentVNode("", !0)
3017
- ], 64)) : e.field.type === "rule_feedback" ? (openBlock(), createElementBlock(Fragment, { key: 23 }, [
3018
- createVNode(_sfc_main$E, {
3019
- "model-value": unref(n),
3020
- "onUpdate:modelValue": a
3021
- }, null, 8, ["model-value"]),
3022
- e.helperText ? (openBlock(), createBlock(h, {
3023
- key: 0,
3024
- class: "!mt-[8px]",
3025
- text: e.helperText,
3026
- state: "error"
3027
- }, null, 8, ["text"])) : createCommentVNode("", !0)
3028
- ], 64)) : e.field.type === "rule_birthday" ? (openBlock(), createElementBlock(Fragment, { key: 24 }, [
3029
- createVNode(_sfc_main$o, {
3030
- "model-value": unref(n),
3031
- "onUpdate:modelValue": a
3032
- }, null, 8, ["model-value"]),
3033
- e.helperText ? (openBlock(), createBlock(h, {
3034
- key: 0,
3035
- class: "!mt-[8px]",
3036
- text: e.helperText,
3037
- state: "error"
3038
- }, null, 8, ["text"])) : createCommentVNode("", !0)
3039
- ], 64)) : e.field.type === "promotion_game_type" ? (openBlock(), createElementBlock(Fragment, { key: 25 }, [
3040
- createVNode(_sfc_main$a, {
3041
- "model-value": unref(n),
3042
- "onUpdate:modelValue": a
3043
- }, null, 8, ["model-value"]),
3044
- e.helperText ? (openBlock(), createBlock(h, {
3045
- key: 0,
3046
- class: "!mt-[8px]",
3047
- text: e.helperText,
3048
- state: "error"
3049
- }, null, 8, ["text"])) : createCommentVNode("", !0)
3050
- ], 64)) : (openBlock(), createElementBlock("pre", _hoisted_1$3, toDisplayString(r.field), 1));
3051
- };
3052
- }
3053
- }), _hoisted_1$2 = { class: "space-y-4" }, _hoisted_2$2 = {
3054
- id: "location-list-title",
3055
- class: "fm-typo-en-title-sm-800"
3056
- }, _hoisted_3$2 = { class: "block fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _hoisted_4$2 = ["aria-label"], _hoisted_5$2 = ["title"], _hoisted_6$2 = ["title"], _hoisted_7$1 = {
3057
- key: 1,
3058
- class: "p-16 fm-typo-en-body-md-400 text-fm-color-typo-secondary"
3059
- }, _hoisted_8$1 = { class: "flex justify-end" }, ROW_HEIGHT = 44, VIEWPORT_HEIGHT = 352, OVERSCAN = 6, _sfc_main$2 = /* @__PURE__ */ defineComponent({
3060
- __name: "LocationListDialog",
3061
- props: {
3062
- rows: {},
3063
- total: {},
3064
- unavailable: {}
3065
- },
3066
- setup(e) {
3067
- const l = e, o = useDialog(), { t: s } = useI18n(), r = ref(""), y = ref(0), a = ref(), n = computed(() => {
3068
- const f = r.value.trim().toLowerCase();
3069
- return f ? l.rows.filter(
3070
- (c) => {
3071
- var u;
3072
- return c.name.toLowerCase().includes(f) || ((u = c.code) == null ? void 0 : u.toLowerCase().includes(f));
3073
- }
3074
- ) : l.rows;
3075
- }), m = computed(
3076
- () => Math.max(0, Math.floor(y.value / ROW_HEIGHT) - OVERSCAN)
3077
- ), i = computed(() => {
3078
- const f = Math.ceil((y.value + VIEWPORT_HEIGHT) / ROW_HEIGHT);
3079
- return n.value.slice(m.value, f + OVERSCAN);
3080
- });
3081
- return watch(r, () => {
3082
- y.value = 0, a.value && (a.value.scrollTop = 0);
3083
- }), (f, c) => {
3084
- const u = resolveComponent("FmTextField"), k = resolveComponent("FmButton"), b = resolveComponent("FmCard");
3085
- return openBlock(), createBlock(b, {
3086
- class: "flex flex-col gap-12 p-24 xs:p-16 w-[640px] max-w-[calc(100vw-32px)] min-w-0",
3087
- role: "dialog",
3088
- "aria-labelledby": "location-list-title"
3089
- }, {
3090
- default: withCtx(() => [
3091
- createElementVNode("div", _hoisted_1$2, [
3092
- createElementVNode("h2", _hoisted_2$2, toDisplayString(unref(s)("connect.campaign.common.available_at")), 1),
3093
- createElementVNode("output", _hoisted_3$2, [
3094
- createTextVNode(toDisplayString(unref(r).trim() ? unref(s)("connect.campaign.common.locations_match", {
3095
- count: unref(n).length.toLocaleString(),
3096
- total: e.total.toLocaleString()
3097
- }) : unref(s)("connect.campaign.common.locations_count", {
3098
- count: e.rows.length.toLocaleString(),
3099
- total: e.total.toLocaleString()
3100
- })) + " ", 1),
3101
- e.unavailable ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
3102
- createTextVNode(" , " + toDisplayString(unref(s)("connect.campaign.common.locations_unavailable", {
3103
- count: e.unavailable.toLocaleString()
3104
- })), 1)
3105
- ], 64)) : createCommentVNode("", !0)
3106
- ])
3107
- ]),
3108
- createVNode(u, {
3109
- modelValue: unref(r),
3110
- "onUpdate:modelValue": c[0] || (c[0] = (h) => isRef(r) ? r.value = h : null),
3111
- label: unref(s)("connect.setting.location.searchLocations"),
3112
- placeholder: unref(s)("connect.setting.location.searchLocations")
3113
- }, null, 8, ["modelValue", "label", "placeholder"]),
3114
- createElementVNode("div", {
3115
- ref_key: "listEl",
3116
- ref: a,
3117
- class: "overflow-y-auto border-y border-fm-color-neutral-gray-100",
3118
- style: normalizeStyle({ height: `min(${VIEWPORT_HEIGHT}px, 50vh)` }),
3119
- onScrollPassive: c[1] || (c[1] = (h) => y.value = h.target.scrollTop)
3120
- }, [
3121
- unref(n).length ? (openBlock(), createElementBlock("ul", {
3122
- key: 0,
3123
- class: "relative m-0 p-0 list-none",
3124
- "aria-label": unref(s)("connect.campaign.common.available_at"),
3125
- style: normalizeStyle({ height: `${unref(n).length * ROW_HEIGHT}px` })
3126
- }, [
3127
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(i), (h, d) => (openBlock(), createElementBlock("li", {
3128
- key: h.id,
3129
- class: "absolute left-0 right-0 flex items-center gap-12 px-8 border-b border-fm-color-neutral-gray-100 fm-typo-en-body-md-400",
3130
- style: normalizeStyle({
3131
- height: `${ROW_HEIGHT}px`,
3132
- top: `${(unref(m) + d) * ROW_HEIGHT}px`
3133
- })
3134
- }, [
3135
- h.code ? (openBlock(), createElementBlock("span", {
3136
- key: 0,
3137
- title: h.code,
3138
- class: "w-[72px] shrink-0 truncate text-fm-color-typo-secondary"
3139
- }, toDisplayString(h.code), 9, _hoisted_5$2)) : createCommentVNode("", !0),
3140
- createElementVNode("span", {
3141
- class: "min-w-0 truncate fm-typo-en-body-md-600",
3142
- title: h.name
3143
- }, toDisplayString(h.name), 9, _hoisted_6$2)
3144
- ], 4))), 128))
3145
- ], 12, _hoisted_4$2)) : (openBlock(), createElementBlock("div", _hoisted_7$1, toDisplayString(e.rows.length ? unref(s)("connect.campaign.common.locations_no_match") : unref(s)("connect.campaign.common.no_location")), 1))
3146
- ], 36),
3147
- createElementVNode("div", _hoisted_8$1, [
3148
- createVNode(k, {
3149
- label: unref(s)("connect.campaign.common.locations_close"),
3150
- onClick: c[2] || (c[2] = (h) => unref(o).close())
3151
- }, null, 8, ["label"])
3152
- ])
3153
- ]),
3154
- _: 1
3155
- });
3156
- };
3157
- }
3158
- }), _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 = {
3159
- key: 0,
3160
- class: "flex flex-wrap items-baseline gap-12"
3161
- }, _hoisted_4$1 = { class: "fm-typo-en-body-lg-600" }, _hoisted_5$1 = ["onClick"], _hoisted_6$1 = {
3162
- key: 1,
3163
- class: "fm-typo-en-body-lg-600"
3164
- }, _sfc_main$1 = /* @__PURE__ */ defineComponent({
3165
- __name: "CampaignSummary",
3166
- props: {
3167
- inDialog: {
3168
- type: Boolean,
3169
- default: !1
3170
- },
3171
- data: {
3172
- type: Object,
3173
- required: !0
3174
- }
3175
- },
3176
- setup(e) {
3177
- const { t: l, te: o } = useI18n(), s = useDialog();
3178
- async function r(n) {
3179
- a.inDialog && (s.close(), await nextTick()), s.open({
3180
- title: "",
3181
- dialogComponent: _sfc_main$2,
3182
- dialogComponentProps: {
3183
- rows: n.rows,
3184
- total: n.total,
3185
- unavailable: n.unavailable
3186
- }
3187
- });
3188
- }
3189
- function y(n) {
3190
- return o(n) || o(n, "en-US");
3191
- }
3192
- const a = e;
3193
- return (n, m) => {
3194
- const i = resolveComponent("FmCard");
3195
- return openBlock(), createBlock(i, {
3196
- variant: "outlined",
3197
- class: "p-16 space-y-8"
3198
- }, {
3199
- default: withCtx(() => [
3200
- createElementVNode("div", _hoisted_1$1, toDisplayString(unref(l)("connect.campaign.common.summary")), 1),
3201
- m[0] || (m[0] = createElementVNode("div", { class: "h-[1px] bg-fm-color-neutral-gray-100 w-full" }, null, -1)),
3202
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(getCampaignSummaryObject)(e.data), (f, c) => (openBlock(), createElementBlock("div", {
3203
- class: "space-y-4",
3204
- key: c
3205
- }, [
3206
- f ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
3207
- createElementVNode("div", _hoisted_2$1, toDisplayString(unref(l)(`${c}`)), 1),
3208
- typeof f == "object" ? (openBlock(), createElementBlock("div", _hoisted_3$1, [
3209
- createElementVNode("span", _hoisted_4$1, [
3210
- createTextVNode(toDisplayString(unref(l)("connect.campaign.common.locations_count", {
3211
- count: f.rows.length.toLocaleString(),
3212
- total: f.total.toLocaleString()
3213
- })) + " ", 1),
3214
- f.unavailable ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
3215
- createTextVNode(" , " + toDisplayString(unref(l)("connect.campaign.common.locations_unavailable", {
3216
- count: f.unavailable.toLocaleString()
3217
- })), 1)
3218
- ], 64)) : createCommentVNode("", !0)
3219
- ]),
3220
- createElementVNode("button", {
3221
- type: "button",
3222
- class: "fm-typo-en-body-lg-600 text-fm-color-primary py-12 -my-12 px-8 -mx-8 underline underline-offset-2 hover:opacity-80 focus-visible:outline focus-visible:outline-2 focus-visible:outline-fm-color-primary rounded-sm",
3223
- onClick: (u) => r(f)
3224
- }, toDisplayString(unref(l)("connect.campaign.common.locations_view")), 9, _hoisted_5$1)
3225
- ])) : (openBlock(), createElementBlock("div", _hoisted_6$1, toDisplayString(y(`${f}`) ? unref(l)(`${f}`) : f), 1))
3226
- ], 64)) : createCommentVNode("", !0)
3227
- ]))), 128))
3228
- ]),
3229
- _: 1
3230
- });
3231
- };
3232
- }
3233
- }), _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 = {
3234
- key: 0,
3235
- class: "max-w-6xl mx-auto"
3236
- }, _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({
3237
- __name: "EditCampaignSheet",
3238
- emits: ["submit:model-value"],
3239
- setup(__props, { expose: __expose, emit: __emit }) {
3240
- const Dialog = useDialog(), sheetVisible = ref(!1), { t } = useI18n(), { getLocaleText } = useLocaleText(), currentStep = ref(1), data = ref(), schema = ref(z.any()), template = ref(
3241
- TEMPLATES.VOUCHER
3242
- ), { minor } = useLoading, isLoading = ref(!1), sheetTitle = ref("Create Campaign"), campaignType = ref("VOUCHER"), pushAvailability = ref("checking");
3243
- let availabilityRequest = 0;
3244
- async function checkPushAvailability() {
3245
- const e = ++availabilityRequest, l = SvcConfig.getBusinessId();
3246
- pushAvailability.value = "checking";
3247
- try {
3248
- if (!l) throw new Error("Business ID is unavailable");
3249
- const s = await getNativeApp(l);
3250
- o() && (pushAvailability.value = s ? "native" : "non-native");
3251
- } catch {
3252
- o() && (pushAvailability.value = "failed");
3253
- }
3254
- function o() {
3255
- return e === availabilityRequest && sheetVisible.value && campaignType.value === "BROADCAST" && SvcConfig.getBusinessId() === l;
3256
- }
3257
- }
3258
- watch(
3259
- sheetVisible,
3260
- (e) => {
3261
- e || ++availabilityRequest;
3262
- },
3263
- { flush: "sync" }
3264
- ), onBeforeUnmount(() => {
3265
- ++availabilityRequest;
3266
- });
3267
- const pushBlocked = computed(
3268
- () => {
3269
- var e;
3270
- return campaignType.value === "BROADCAST" && toDelivery(((e = data.value) == null ? void 0 : e.campaign) ?? {}).channels.includes("PUSH") && pushAvailability.value !== "native";
3271
- }
3272
- );
3273
- async function showSheet(visible, type, campaign, selectedTemplate) {
3274
- var e, l, o;
3275
- if (sheetVisible.value = visible, campaignType.value = type, ++availabilityRequest, !!visible) {
3276
- type === "BROADCAST" && checkPushAvailability();
3277
- try {
3278
- isLoading.value = visible, await useMembershipStore().readRewards(), await useBusinessStore().readLocations(), await useMembershipStore().readSegments(), await useMembershipStore().readMembership();
3279
- } catch {
3280
- } finally {
3281
- await new Promise((s) => setTimeout(s, 120)), isLoading.value = !1;
3282
- }
3283
- template.value = selectedTemplate ?? TEMPLATES[type], schema.value = CampaignDtos[type], type === "VOUCHER" && (await useCampaignStore().read(), schema.value = schema.value.superRefine((s, r) => {
3284
- var y;
3285
- if (s.campaign.type === "VOUCHER" && s.campaign.code) {
3286
- const a = (y = s.campaign._id) == null ? void 0 : y.toString();
3287
- useCampaignStore().campaigns.voucher.some(
3288
- (n) => n.code === s.campaign.code && n._id.toString() !== a
3289
- ) && r.addIssue({
3290
- code: "custom",
3291
- message: "Code already exists, please use another code",
3292
- path: ["campaign", "code"]
3293
- });
3294
- }
3295
- })), data.value = campaign != null ? { ...campaign, templateId: (e = campaign.template) == null ? void 0 : e._id } : _.cloneDeep({
3296
- ...(l = template.value) == null ? void 0 : l.defaultValue
3297
- }), "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", {
3298
- typeName: t(`connect.campaign.common.typeName.${type}`)
3299
- }) : t("connect.campaign.common.create_campaign_title", {
3300
- typeName: t(`connect.campaign.common.typeName.${type}`)
3301
- });
3302
- }
3303
- }
3304
- async function hideSheet() {
3305
- Dialog.open({
3306
- title: t("connect.campaign.common.unsaved_changes"),
3307
- message: t("connect.campaign.common.unsaved_changes"),
3308
- primaryActions: {
3309
- text: t("connect.campaign.common.unsaved_changes_confirm"),
3310
- close: !0
3311
- },
3312
- secondaryActions: {
3313
- text: t("connect.campaign.common.unsaved_changes_cancel"),
3314
- close: !1
3315
- }
3316
- }).onPrimary(() => {
3317
- sheetVisible.value = !1;
3318
- }).onSecondary(() => {
3319
- Dialog.close();
3320
- });
3321
- }
3322
- const emits = __emit, errors = computed(() => {
3323
- const e = schema.value.superRefine(campaignRefinement).safeParse(data.value), l = e.success ? [] : [...e.error.errors];
3324
- return pushBlocked.value && l.push({
3325
- code: "custom",
3326
- path: ["campaign", "delivery", "channels"],
3327
- message: t(
3328
- "connect.campaign.broadcast.pushAvailability.removeBeforeSave"
3329
- )
3330
- }), l;
3331
- });
3332
- function stepErrors(e = currentStep.value - 1) {
3333
- const l = template.value.steps[e].groups.flatMap(
3334
- (o) => o.fields.map((s) => schemaPathForField(s.property))
3335
- );
3336
- return errors.value.filter(
3337
- (o) => l.some((s) => o.path.join(".").includes(s))
3338
- );
3339
- }
3340
- const validateOnSubmit = computed(() => campaignType.value === "BROADCAST"), submitAttempted = ref(!1), showValidation = computed(
3341
- () => !validateOnSubmit.value || submitAttempted.value
3342
- ), visibleErrors = computed(
3343
- () => showValidation.value ? errors.value : []
3344
- );
3345
- function hasVisibleStepErrors(e) {
3346
- return showValidation.value && stepErrors(e).length > 0;
3347
- }
3348
- function isNextDisabled() {
3349
- return validateOnSubmit.value ? !1 : currentStep.value - 1 < template.value.steps.length - 1 ? stepErrors().length > 0 : errors.value.length > 0;
3350
- }
3351
- function onNext() {
3352
- if (stepErrors().length > 0) {
3353
- submitAttempted.value = !0;
3354
- return;
3355
- }
3356
- submitAttempted.value = !1, currentStep.value++;
3357
- }
3358
- __expose({ showSheet });
3359
- function showSummaryDialog() {
3360
- Dialog.open({
3361
- title: "",
3362
- dialogComponent: _sfc_main$1,
3363
- dialogComponentProps: {
3364
- data: data.value,
3365
- inDialog: !0
3366
- }
3367
- });
3368
- }
3369
- const broadcastDelivery = computed(
3370
- () => {
3371
- var e;
3372
- return (e = data.value) != null && e.campaign ? toDelivery(data.value.campaign) : void 0;
3373
- }
3374
- );
3375
- function valueForField(e) {
3376
- return e === "campaign.message" ? broadcastDelivery.value : _.get(data.value, e);
3377
- }
3378
- function schemaPathForField(e) {
3379
- return e === "campaign.message" ? "campaign.delivery" : e;
3380
- }
3381
- function onUpdateProperty(e, l) {
3382
- var o, s, r, y, a, n, m, i;
3383
- if (e === "campaign.message" && l && "channels" in l) {
3384
- _.set(data.value, "campaign.delivery", l);
3385
- const f = toLegacyMessage(l);
3386
- f ? _.set(data.value, "campaign.message", f) : delete data.value.campaign.message;
3387
- return;
3388
- }
3389
- if (_.set(data.value, e, l), e == "campaign.event.type") {
3390
- const c = ((y = (r = (s = (o = template.value) == null ? void 0 : o.defaultValue) == null ? void 0 : s.campaign) == null ? void 0 : r.event) == null ? void 0 : y.rule) ? _.cloneDeep({
3391
- ...(i = (m = (n = (a = template.value) == null ? void 0 : a.defaultValue) == null ? void 0 : n.campaign) == null ? void 0 : m.event) == null ? void 0 : i.rule
3392
- }) : RuleBuilder.setRuleToGroup(RuleBuilder.scaffoldGroup(), [
3393
- RuleBuilder.scaffoldGroup("g_schedule"),
3394
- RuleBuilder.scaffoldGroup("g_time"),
3395
- RuleBuilder.scaffoldGroup("g_user"),
3396
- RuleBuilder.scaffoldGroup("g_bill")
3397
- ]), u = RuleBuilder.setRuleToGroup(
3398
- RuleBuilder.scaffoldGroup("g_schedule"),
3399
- [
3400
- RuleBuilder.constructEntry(
3401
- "trigger.date",
3402
- "_rrule",
3403
- "RRULE:FREQ=DAILY;INTERVAL=1;BYHOUR=0;BYMINUTE=0;BYSECOND=0;WKST=SU"
3404
- ),
3405
- RuleBuilder.constructEntry("trigger.time", "_isOnTime", "00:00")
3406
- ],
3407
- "&&"
3408
- );
3409
- if (l != "SCHEDULE") {
3410
- _.set(data.value, "campaign.event.rule", c);
3411
- return;
3412
- }
3413
- _.set(
3414
- data.value,
3415
- "campaign.event.rule",
3416
- RuleBuilder.setRuleToGroup(c, u)
3417
- );
3418
- }
3419
- e == "campaign.notify" && l == !1 && _.set(data.value, "campaign.notifyMessage", void 0);
3420
- }
3421
- async function onUpdateFile(e, l) {
3422
- return e ? await minor(async () => firebaseStorage.update(l, e), {
3423
- message: `${e ? "Uploading" : "Removing"} file`,
3424
- successMessage: `File ${e ? "uploaded" : "removed"} successfully`
3425
- }) : "";
3426
- }
3427
- function isDisable(e) {
3428
- var l, o;
3429
- switch (e == null ? void 0 : e.property) {
3430
- case "campaign.event.type":
3431
- return ((o = (l = data.value) == null ? void 0 : l.campaign) == null ? void 0 : o._id) || !1;
3432
- default:
3433
- return !1;
3434
- }
3435
- }
3436
- function onSubmit() {
3437
- if (submitAttempted.value = !0, pushBlocked.value) return;
3438
- const e = schema.value.superRefine(campaignRefinement).transform(campaignTransform).safeParse(data.value);
3439
- e.success && (emits("submit:model-value", cleanPF(JSON.parse(JSON.stringify(e.data)))), sheetVisible.value = !1);
3440
- }
3441
- return (e, l) => {
3442
- const o = resolveComponent("FmButton"), s = resolveComponent("FmStep"), r = resolveComponent("FmStepper"), y = resolveComponent("FmCard"), a = resolveComponent("FmTopSheet");
3443
- return openBlock(), createBlock(a, {
3444
- "fullscreen-size": "lg",
3445
- modelValue: unref(sheetVisible),
3446
- "onUpdate:modelValue": [
3447
- l[7] || (l[7] = (n) => isRef(sheetVisible) ? sheetVisible.value = n : null),
3448
- l[8] || (l[8] = (n) => sheetVisible.value = n)
3449
- ]
3450
- }, createSlots({
3451
- "top-sheet-header": withCtx(() => [
3452
- createElementVNode("div", _hoisted_1, [
3453
- createElementVNode("div", null, toDisplayString(unref(sheetTitle)), 1),
3454
- createElementVNode("div", _hoisted_2, [
3455
- createVNode(o, {
3456
- onClick: l[0] || (l[0] = (n) => hideSheet()),
3457
- label: unref(t)("connect.campaign.common.cancel"),
3458
- variant: "tertiary"
3459
- }, null, 8, ["label"]),
3460
- createVNode(o, {
3461
- onClick: onSubmit,
3462
- label: unref(t)("connect.campaign.common.save"),
3463
- disabled: !unref(validateOnSubmit) && unref(errors).length > 0
3464
- }, null, 8, ["label", "disabled"])
3465
- ])
3466
- ])
3467
- ]),
3468
- _: 2
3469
- }, [
3470
- unref(isLoading) ? {
3471
- name: "default",
3472
- fn: withCtx(() => [
3473
- createElementVNode("div", _hoisted_9, [
3474
- createElementVNode("div", _hoisted_10, [
3475
- createElementVNode("div", _hoisted_11, [
3476
- l[9] || (l[9] = createElementVNode("div", { class: "col-span-2 space-y-80 xs:col-span-3 xs:px-16 xs:pt-16" }, [
3477
- createElementVNode("div", { class: "flex-1 space-y-6 py-1" }, [
3478
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100 rounded" }),
3479
- createElementVNode("div", { class: "h-[80px] bg-fm-color-neutral-gray-100 rounded" }),
3480
- createElementVNode("div", { class: "space-y-3" }, [
3481
- createElementVNode("div", { class: "grid grid-cols-2 gap-4" }, [
3482
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" }),
3483
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
3484
- ]),
3485
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
3486
- ]),
3487
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100 rounded" }),
3488
- createElementVNode("div", { class: "h-[80px] bg-fm-color-neutral-gray-100 rounded" }),
3489
- createElementVNode("div", { class: "space-y-3" }, [
3490
- createElementVNode("div", { class: "grid grid-cols-2 gap-4" }, [
3491
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" }),
3492
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
3493
- ]),
3494
- createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
3495
- ])
3496
- ])
3497
- ], -1)),
3498
- createVNode(y, { class: "h-[150px] bg-fm-color-neutral-gray-100" })
3499
- ])
3500
- ])
3501
- ])
3502
- ]),
3503
- key: "1"
3504
- } : {
3505
- name: "default",
3506
- fn: withCtx(() => [
3507
- unref(data) ? (openBlock(), createElementBlock("div", _hoisted_3, [
3508
- createVNode(r, {
3509
- modelValue: unref(currentStep),
3510
- "onUpdate:modelValue": l[1] || (l[1] = (n) => isRef(currentStep) ? currentStep.value = n : null),
3511
- orientation: "horizontal",
3512
- class: "xs:hidden mx-[-24px] mt-16 mb-24 flex-1"
3513
- }, {
3514
- default: withCtx(() => [
3515
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(template).steps, (n, m) => (openBlock(), createBlock(s, {
3516
- key: n.name,
3517
- title: unref(getLocaleText)(n.name_locale, n.name),
3518
- value: m + 1,
3519
- error: () => hasVisibleStepErrors(m),
3520
- complete: () => m + 1 <= unref(currentStep)
3521
- }, null, 8, ["title", "value", "error", "complete"]))), 128))
3522
- ]),
3523
- _: 1
3524
- }, 8, ["modelValue"]),
3525
- createElementVNode("div", _hoisted_4, [
3526
- createVNode(o, {
3527
- icon: "close",
3528
- variant: "tertiary",
3529
- onClick: l[2] || (l[2] = (n) => sheetVisible.value = !1)
3530
- }),
3531
- createVNode(r, {
3532
- modelValue: unref(currentStep),
3533
- "onUpdate:modelValue": l[3] || (l[3] = (n) => isRef(currentStep) ? currentStep.value = n : null),
3534
- orientation: "horizontal",
3535
- class: "flex-1"
3536
- }, {
3537
- default: withCtx(() => [
3538
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(template).steps, (n, m) => (openBlock(), createBlock(s, {
3539
- key: n.name,
3540
- title: unref(sheetTitle),
3541
- description: unref(getLocaleText)(n.name_locale, n.name),
3542
- value: m + 1,
3543
- error: () => hasVisibleStepErrors(m),
3544
- complete: () => m + 1 <= unref(currentStep) && stepErrors(unref(currentStep) - 1).length == 0
3545
- }, null, 8, ["title", "description", "value", "error", "complete"]))), 128))
3546
- ]),
3547
- _: 1
3548
- }, 8, ["modelValue"]),
3549
- createVNode(o, {
3550
- icon: "info",
3551
- variant: "tertiary",
3552
- onClick: l[4] || (l[4] = () => showSummaryDialog())
3553
- })
3554
- ]),
3555
- createElementVNode("div", _hoisted_5, [
3556
- createElementVNode("div", _hoisted_6, [
3557
- createVNode(JsonViewer, {
3558
- json: {
3559
- data: unref(data),
3560
- errors: unref(errors).map(
3561
- (n) => `${n.path.join(".")} - ${n.message}`
3562
- ),
3563
- stepErrors: stepErrors().map(
3564
- (n) => `${n.path.join(".")} - ${n.message}`
3565
- ),
3566
- schema: unref(schema)
3567
- }
3568
- }, null, 8, ["json"]),
3569
- (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(template).steps[unref(currentStep) - 1].groups.filter(
3570
- (n) => n.fields.length && (!n.condition || (Array.isArray(n.condition) ? n.condition.every((m) => unref(_).get(unref(data), m.property) == m.value == (m.not != !0)) : unref(_).get(unref(data), n.condition.property) == n.condition.value == (n.condition.not != !0)))
3571
- ), (n, m) => (openBlock(), createElementBlock("div", {
3572
- key: m,
3573
- class: "space-y-24"
3574
- }, [
3575
- createElementVNode("div", _hoisted_7, toDisplayString(unref(getLocaleText)(n.name_locale, n.name ?? "")), 1),
3576
- (openBlock(!0), createElementBlock(Fragment, null, renderList(n.fields, (i, f) => (openBlock(), createElementBlock("div", { key: f }, [
3577
- (openBlock(), createBlock(_sfc_main$3, {
3578
- key: f,
3579
- field: i,
3580
- modelValue: valueForField(i.property),
3581
- disabled: isDisable(i),
3582
- "campaign-type": unref(campaignType),
3583
- "show-validation": unref(showValidation),
3584
- "push-availability": unref(pushAvailability),
3585
- onRetryPush: checkPushAvailability,
3586
- "onUpdate:modelValue": (c) => onUpdateProperty(i.property, c),
3587
- "onUpdate:file": async (c, u) => {
3588
- const k = await onUpdateFile(c, u);
3589
- onUpdateProperty(i.property, k || "");
3590
- },
3591
- schema: unref(ZodHelper).typeAtPath(
3592
- unref(schema),
3593
- schemaPathForField(i.property),
3594
- unref(data).campaign.type != "MISSION" ? [unref(data).campaign.type] : ["STAMP", "MISSION"]
3595
- ),
3596
- "helper-state": unref(ZodHelper).helperState(
3597
- unref(visibleErrors),
3598
- schemaPathForField(i.property)
3599
- ),
3600
- "helper-text": unref(ZodHelper).helperText(
3601
- unref(visibleErrors),
3602
- schemaPathForField(i.property)
3603
- ),
3604
- extras: i.extras != null ? i.extras == "" ? unref(data) : unref(_).get(unref(data), i.extras) : void 0
3605
- }, null, 8, ["field", "modelValue", "disabled", "campaign-type", "show-validation", "push-availability", "onUpdate:modelValue", "onUpdate:file", "schema", "helper-state", "helper-text", "extras"]))
3606
- ]))), 128))
3607
- ]))), 128)),
3608
- createElementVNode("div", _hoisted_8, [
3609
- createVNode(o, {
3610
- label: unref(t)("connect.common.back"),
3611
- variant: "tertiary",
3612
- disabled: unref(currentStep) == 1,
3613
- onClick: l[5] || (l[5] = (n) => currentStep.value--)
3614
- }, null, 8, ["label", "disabled"]),
3615
- createVNode(o, {
3616
- disabled: isNextDisabled(),
3617
- label: unref(currentStep) - 1 < unref(template).steps.length - 1 ? unref(t)("connect.common.next") : unref(t)("connect.common.submit"),
3618
- onClick: l[6] || (l[6] = (n) => unref(currentStep) - 1 < unref(template).steps.length - 1 ? onNext() : onSubmit())
3619
- }, null, 8, ["disabled", "label"])
3620
- ])
3621
- ]),
3622
- createVNode(_sfc_main$1, {
3623
- data: unref(data),
3624
- class: "xs:hidden"
3625
- }, null, 8, ["data"])
3626
- ])
3627
- ])) : createCommentVNode("", !0)
3628
- ]),
3629
- key: "0"
3630
- }
3631
- ]), 1032, ["modelValue"]);
3632
- };
3633
- }
3634
- });
3635
- export {
3636
- _sfc_main as _,
3637
- useLocaleText as u
3638
- };