@feedmepos/mf-connect 0.1.38-beta.3 → 0.1.38-beta.31

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 (110) hide show
  1. package/dist/{Analytic-DlzNe_iy.js → Analytic-C_nMR1Be.js} +15 -15
  2. package/dist/{App-S5t6byxx.js → App-s6O0r91S.js} +624 -618
  3. package/dist/{AuditLogs-FO7SmMm2.js → AuditLogs-BcVkpvGw.js} +14 -14
  4. package/dist/{Bin-D--pK-f4.js → Bin-C5g9jHoQ.js} +9 -9
  5. package/dist/Broadcast-JPTVWDJC.js +233 -0
  6. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-C6MYdWnX.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-CloO2B7A.js} +6 -6
  7. package/dist/{Card-DHL6WnwR.js → Card-Dgj6yukn.js} +143 -137
  8. package/dist/{Collections-DnonNjPT.js → Collections-D-aFYRCq.js} +82 -76
  9. package/dist/Credit-BZcRB9Wj.js +228 -0
  10. package/dist/{DateRangeChip.vue_vue_type_script_setup_true_lang-BUzUIIUW.js → DateRangeChip.vue_vue_type_script_setup_true_lang-eIoPtgO5.js} +1 -1
  11. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-DnPPICf0.js +3117 -0
  12. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-C4zzEOCb.js → EffectSheet.vue_vue_type_style_index_0_lang-DbSiVLaJ.js} +100 -99
  13. package/dist/Experience-DHQPxVv3.js +229 -0
  14. package/dist/FilterChip.vue_vue_type_script_setup_true_lang-DaU-9GzO.js +129 -0
  15. package/dist/{Game-Bkl0JnBq.js → Game-C1XnMgil.js} +103 -97
  16. package/dist/Grab-BbHccgZO.js +301 -0
  17. package/dist/{ImageInput.vue_vue_type_script_setup_true_lang-rWUkV9gn.js → ImageInput.vue_vue_type_script_setup_true_lang-D1KQpDGg.js} +8 -8
  18. package/dist/{Index-BXTpF6kN.js → Index-DYZsN2H3.js} +54 -54
  19. package/dist/{Marketing-kk88gqDC.js → Marketing-DnsPHYpt.js} +7112 -5424
  20. package/dist/{Member-Cq-orpRf.js → Member-rkdV1fVo.js} +10 -10
  21. package/dist/{MemberList-B0K6Djc0.js → MemberList-QaB13bxO.js} +33 -33
  22. package/dist/{MemberTransactions-BCrJz8M9.js → MemberTransactions-Dw5qHQVW.js} +1 -1
  23. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-BcGhTM5H.js → MessageInput.vue_vue_type_script_setup_true_lang-DGyv0LMu.js} +5789 -5515
  24. package/dist/{Mission-BF1Z-Veq.js → Mission-B7rAzf6O.js} +112 -106
  25. package/dist/{Overview-CLSBBnZz.js → Overview-Cg4Szz05.js} +21 -21
  26. package/dist/Point-DuKS8-0D.js +232 -0
  27. package/dist/{Promotion-CGwxt3l3.js → Promotion-CFtLq-LB.js} +11 -11
  28. package/dist/{Queue-Dihw6DCV.js → Queue-BZONVNCP.js} +13 -13
  29. package/dist/{Record-ChSb722p.js → Record-jNEahJNC.js} +10 -10
  30. package/dist/{Reward-8oKlHA-x.js → Reward-VS6C6NQO.js} +15 -15
  31. package/dist/{RewardGroup.vue_vue_type_script_setup_true_lang-D--YGFcF.js → RewardGroup.vue_vue_type_script_setup_true_lang-D4KMGgkv.js} +11 -11
  32. package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-Cb-WJA0i.js +1763 -0
  33. package/dist/{Segment-BbYgbJ7w.js → Segment-DK5tqeOF.js} +274 -274
  34. package/dist/{SelectItems.vue_vue_type_script_setup_true_lang-Dy_G8md1.js → SelectItems.vue_vue_type_script_setup_true_lang-AYAwO37B.js} +14 -14
  35. package/dist/{SendCollectionSheet.vue_vue_type_script_setup_true_lang-BFhY3cve.js → SendCollectionSheet.vue_vue_type_script_setup_true_lang-K8js6fbo.js} +11 -11
  36. package/dist/{SendVoucherSheet.vue_vue_type_script_setup_true_lang-WEiXy4o1.js → SendVoucherSheet.vue_vue_type_script_setup_true_lang-lcPHPa4K.js} +3 -3
  37. package/dist/{Setting-B75a5DWV.js → Setting-BtiUlWRc.js} +459 -444
  38. package/dist/{Store-Cb8Et93b.js → Store-DqFW5hr_.js} +472 -465
  39. package/dist/{StoreRewards-DEI9VJHO.js → StoreRewards-g-3WtxwG.js} +15 -15
  40. package/dist/{StoreTransactions.vue_vue_type_script_setup_true_lang-BGBl4Zla.js → StoreTransactions.vue_vue_type_script_setup_true_lang-DNT4PWgl.js} +208 -222
  41. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-92NnMkro.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-CXYnNSta.js} +1 -1
  42. package/dist/{Tier-BB4AyAZV.js → Tier-SHij9zKX.js} +230 -227
  43. package/dist/{Title-Cla1U1ye.js → Title-_2JVV1rW.js} +142 -139
  44. package/dist/{Transaction-fHFbemk-.js → Transaction-BHLb6hZN.js} +2 -2
  45. package/dist/{UserRuleGroup.vue_vue_type_script_setup_true_lang-yS5qh7za.js → UserRuleGroup.vue_vue_type_script_setup_true_lang-DolBmHzN.js} +6 -6
  46. package/dist/{Voucher-CraCvVuq.js → Voucher-CJk8ZuCA.js} +14 -14
  47. package/dist/{VoucherEditor.vue_vue_type_script_setup_true_lang-DqKT6Fep.js → VoucherEditor.vue_vue_type_script_setup_true_lang-BviU3rz6.js} +86 -86
  48. package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-B14K5zel.js → ZodTextField.vue_vue_type_script_setup_true_lang-R4Xcn7gl.js} +1 -1
  49. package/dist/app-BpcIC6Ud.js +57962 -0
  50. package/dist/{app-B8hYhD6p.js → app-D9ygZVP0.js} +678 -597
  51. package/dist/app.js +1 -1
  52. package/dist/{business-CwtLYoAT.js → business-CzJxdKc-.js} +11 -8
  53. package/dist/{campaign-BwM5SLyy.js → campaign-RKjwSpJk.js} +29 -16
  54. package/dist/{campaign-Bea47E3G.js → campaign-s_7F9I6R.js} +29 -25
  55. package/dist/{campaign.enum-v4z9v1aa.js → campaign.enum-BlGYJ6p4.js} +3 -2
  56. package/dist/{campaign.fn-CV5s8XUt.js → campaign.fn-aH0pz1jU.js} +95 -95
  57. package/dist/{collectible.enum-BGt9xa0D.js → collectible.enum-DYV8J5Mg.js} +1 -1
  58. package/dist/{collection.fn-DFzVxsA9.js → collection.fn-lLG_rLyd.js} +2 -2
  59. package/dist/dto-Cx-z2h2_.js +222 -0
  60. package/dist/{effect-DQtWLIrF.js → effect-DV2GiHqM.js} +1 -1
  61. package/dist/{email-addresses-I8wDL9bh.js → email-addresses-DTfbKDsC.js} +1 -1
  62. package/dist/{export-BauRZnqp.js → export-hHjutAC3.js} +4 -4
  63. package/dist/{helper-B2Q1CLCG.js → helper-oy_DH4P5.js} +1 -1
  64. package/dist/{index-CCJqmSob.js → index-8t9y1bUZ.js} +1 -1
  65. package/dist/{index-B20y17xe.js → index-B1C5UjP5.js} +3 -3
  66. package/dist/{index-DQpw4Va-.js → index-B79nkieV.js} +1452 -1452
  67. package/dist/{index-DGuR3NRj.js → index-BA6oC2L9.js} +3 -3
  68. package/dist/{index-BdizAaMz.js → index-Ba05Naif.js} +16 -16
  69. package/dist/{index-B1Bdn9rV.js → index-BoRTW-dI.js} +196 -16
  70. package/dist/{index-CgYAHnlX.js → index-CUGS4y58.js} +861 -714
  71. package/dist/{index-IXY9hkrD.js → index-CV_3mltA.js} +1 -1
  72. package/dist/{index-DtfWwcp4.js → index-ClgsfK3Y.js} +1 -1
  73. package/dist/{index-dK8fMQ5h.js → index-CtxtD8HE.js} +1 -1
  74. package/dist/{index-aguYFa7D.js → index-CycW9ri6.js} +6347 -6305
  75. package/dist/{index-s1IB44jY.js → index-D8JDdV2w.js} +1 -1
  76. package/dist/{index-Bv3aqvRF.js → index-DJlZYwDo.js} +11 -4
  77. package/dist/{index-yOFbPJEE.js → index-sSxaqeIi.js} +1 -1
  78. package/dist/{index.esm2017-VwpfHNpU.js → index.esm2017-B3-oEraK.js} +34 -34
  79. package/dist/{loading-BFKvxqlx.js → loading-D98ofaCB.js} +1 -1
  80. package/dist/{membership-Cgzqg1Vw.js → membership-CwbI7ZrE.js} +3 -3
  81. package/dist/{moment-BWErdI6_.js → moment-D7p2TMB-.js} +6 -1
  82. package/dist/{money-DIh7Uegf.js → money-D5cHxcPB.js} +1 -1
  83. package/dist/{number-onslf0BL.js → number-CPEEKMZZ.js} +1 -1
  84. package/dist/objectid-Be_atBnH.js +145 -0
  85. package/dist/{plugins-hfoXoiK2.js → plugins-B55BRo5q.js} +2 -2
  86. package/dist/{reward-CYC7hCgM.js → reward-xrTcTYjt.js} +1 -1
  87. package/dist/rule-builder-NTDBB2kj.js +93 -0
  88. package/dist/{rule-C_M3oFLI.js → rule-w89XmfIg.js} +4 -4
  89. package/dist/style.css +1 -1
  90. package/dist/{template-C6URy7QF.js → template-Bt_auQZW.js} +5 -5
  91. package/dist/timezone-BcBn2Kb_.js +1151 -0
  92. package/dist/{trigger-CZAiHFT5.js → trigger-D_6mNiva.js} +4 -4
  93. package/dist/usePagination-Ds-cuHop.js +223 -0
  94. package/dist/{user-uo2wREaB.js → user-B6YOJ_7r.js} +1 -1
  95. package/dist/{vue-i18n-Ba5EWUgR.js → vue-i18n-QvFKKqSt.js} +418 -418
  96. package/dist/{xlsx-CIJPKm4G.js → xlsx-Dr9Ctrs4.js} +1 -1
  97. package/package.json +6 -5
  98. package/dist/Broadcast-BYL3w06w.js +0 -227
  99. package/dist/Credit-BMeykOe-.js +0 -222
  100. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-D6Ps8njr.js +0 -2185
  101. package/dist/Experience-Lu8sCso6.js +0 -223
  102. package/dist/FilterChip.vue_vue_type_script_setup_true_lang-d8rh38tD.js +0 -114
  103. package/dist/Point-BZ2Bgfw8.js +0 -226
  104. package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-GSqXPvRs.js +0 -1728
  105. package/dist/app-BVCw28s0.js +0 -33357
  106. package/dist/dto-BgJqr4qT.js +0 -214
  107. package/dist/objectid-vtlpVGBH.js +0 -145
  108. package/dist/remy-vue-client-Cpppk9h-.js +0 -1693
  109. package/dist/rule-builder-BOG14MYK.js +0 -89
  110. package/dist/usePagination-BeF5K3M7.js +0 -223
@@ -0,0 +1,3117 @@
1
+ import { defineComponent, ref, watch, resolveComponent, openBlock, createElementBlock, createElementVNode, createVNode, createCommentVNode, computed, onMounted, toDisplayString, createBlock, withCtx, Fragment, renderList, withModifiers, unref, isRef, createTextVNode, normalizeClass, resolveDynamicComponent, toRefs, normalizeStyle, createSlots } from "vue";
2
+ import { _ } from "./lodash-B5I3zXaY.js";
3
+ import { z } from "./app-D9ygZVP0.js";
4
+ import { Z as ZodHelper } from "./zod-Bg2FbC-D.js";
5
+ import { c as getCampaignSummaryObject, C as CampaignOptions } from "./campaign-RKjwSpJk.js";
6
+ import { c as campaignRefinement, C as CampaignDtos, a as campaignTransform } from "./dto-Cx-z2h2_.js";
7
+ import { u as useMembershipStore } from "./membership-CwbI7ZrE.js";
8
+ import { u as useBusinessStore } from "./business-CzJxdKc-.js";
9
+ import "./index-Ba05Naif.js";
10
+ import { R as RuleBuilder, a as isRuleEntry } from "./rule-builder-NTDBB2kj.js";
11
+ import { J as JsonViewer } from "./JsonViewer-v8_C7l5N.js";
12
+ import { h as hooks } from "./moment-D7p2TMB-.js";
13
+ import { f as featureVersionMapping } from "./campaign.enum-BlGYJ6p4.js";
14
+ import { _ as _sfc_main$u } from "./ImageInput.vue_vue_type_script_setup_true_lang-D1KQpDGg.js";
15
+ import { b as _sfc_main$s, a as _sfc_main$v, _ as _sfc_main$x } from "./EffectSheet.vue_vue_type_style_index_0_lang-DbSiVLaJ.js";
16
+ import { _ as _sfc_main$w } from "./TargetLocationInput.vue_vue_type_script_setup_true_lang-CXYnNSta.js";
17
+ import { c as core, S as SvcConfig } from "./index-CycW9ri6.js";
18
+ import { p as prompt, c as cases, f as firebaseStorage } from "./plugins-B55BRo5q.js";
19
+ import { C as Cb } from "./app-BpcIC6Ud.js";
20
+ import { _ as _sfc_main$o } from "./SelectItems.vue_vue_type_script_setup_true_lang-AYAwO37B.js";
21
+ import { _ as _export_sfc } from "./_plugin-vue_export-helper-CHgC5LLL.js";
22
+ import { _ as _sfc_main$z } from "./UserRuleGroup.vue_vue_type_script_setup_true_lang-DolBmHzN.js";
23
+ import { _ as _sfc_main$p, a as _sfc_main$q } from "./RuleGroup.vue_vue_type_script_setup_true_lang-Cb-WJA0i.js";
24
+ import { u as useI18n } from "./vue-i18n-QvFKKqSt.js";
25
+ import { T as TypeToTriggerOptions, _ as _sfc_main$A, b as _sfc_main$B } from "./trigger-D_6mNiva.js";
26
+ import { _ as _sfc_main$y } from "./MessageInput.vue_vue_type_script_setup_true_lang-DGyv0LMu.js";
27
+ import { C as CountryTimezone, m as moment } from "./timezone-BcBn2Kb_.js";
28
+ import { c as calculateNextScheduleAt, S as SummarizeRrule, R as RRule } from "./rule-w89XmfIg.js";
29
+ import { useCoreStore } from "@feedmepos/mf-common";
30
+ import { _ as _sfc_main$r, a as _sfc_main$t } from "./VoucherEditor.vue_vue_type_script_setup_true_lang-BviU3rz6.js";
31
+ import { T as TEMPLATES } from "./index-BoRTW-dI.js";
32
+ import { v as FdoCreditLoyaltyReward, w as FdtoRandomReward, x as F_MISSION_TYPE, y as FdoThresholdCreditReward, z as FdtoThresholdReward, A as FdoMission } from "./index-CUGS4y58.js";
33
+ import "./index-CV_3mltA.js";
34
+ import "./index-BA6oC2L9.js";
35
+ import { a as F_GAME_TYPE } from "./collectible.enum-DYV8J5Mg.js";
36
+ import { u as useLoading } from "./loading-D98ofaCB.js";
37
+ import { i as initCollectibleConfig } from "./helper-oy_DH4P5.js";
38
+ import { C as CollectionUtils } from "./collection.fn-lLG_rLyd.js";
39
+ import { s as sentenceCase$1 } from "./index-CsaQJMAR.js";
40
+ import "./index-B79nkieV.js";
41
+ import { useDialog } from "@feedmepos/ui-library";
42
+ import { u as useCampaignStore } from "./campaign-s_7F9I6R.js";
43
+ import { a as cleanPF } from "./object-qECH92oz.js";
44
+ function summarizeGrabDiscount(e) {
45
+ if (!e)
46
+ return null;
47
+ const d = core.Config.getCountry().currency.symbol;
48
+ function r(o) {
49
+ switch (o.scope.type) {
50
+ case "order":
51
+ return "Bill discount";
52
+ case "items":
53
+ return o.type.startsWith("bundle") ? i(o.type) : "Item discount";
54
+ case "categories":
55
+ return "Category discount";
56
+ default:
57
+ return "Discount";
58
+ }
59
+ }
60
+ function i(o) {
61
+ switch (o) {
62
+ case "bundleSameFixPrice":
63
+ return "Bundle (same item) - Fixed price";
64
+ case "bundleDiffFixPrice":
65
+ return "Bundle (different items) - Fixed price";
66
+ case "bundleSameNet":
67
+ return "Bundle (same item) - Amount off";
68
+ case "bundleDiffNet":
69
+ return "Bundle (different items) - Amount off";
70
+ case "bundleSamePercentage":
71
+ return "Bundle (same item) - Percentage off";
72
+ case "bundleDiffPercentage":
73
+ return "Bundle (different items) - Percentage off";
74
+ default:
75
+ return "Bundle discount";
76
+ }
77
+ }
78
+ function u(o) {
79
+ switch (o.type) {
80
+ case "percentage":
81
+ case "bundleSamePercentage":
82
+ case "bundleDiffPercentage":
83
+ return `${o.value}% discount`;
84
+ case "net":
85
+ case "bundleSameNet":
86
+ case "bundleDiffNet":
87
+ return `${d}${o.value} discount`;
88
+ case "bundleSameFixPrice":
89
+ case "bundleDiffFixPrice":
90
+ return `${d}${o.value} fixed price`;
91
+ case "delivery":
92
+ return "Delivery fee discount";
93
+ case "freeItem":
94
+ return "Free item";
95
+ default:
96
+ return `${d}${o.value} discount`;
97
+ }
98
+ }
99
+ function a(o) {
100
+ return o.cap && o.cap > 0 ? `capped at ${d}${o.cap}` : null;
101
+ }
102
+ return {
103
+ type: r(e),
104
+ adjustment: u(e),
105
+ cap: a(e)
106
+ };
107
+ }
108
+ const _hoisted_1$l = {
109
+ key: 0,
110
+ class: "bg-fm-color-neutral-gray-50 border border-fm-color-neutral-gray-200 rounded-8 p-16 space-y-16"
111
+ }, _hoisted_2$h = { class: "flex items-center justify-between" }, _hoisted_3$e = { class: "flex items-center gap-8" }, _hoisted_4$b = { class: "bg-white border border-fm-color-neutral-gray-200 rounded-8 p-16" }, _hoisted_5$7 = { class: "flex justify-end gap-8 pt-8 border-t border-fm-color-neutral-gray-200" }, _sfc_main$n = /* @__PURE__ */ defineComponent({
112
+ __name: "GrabItemSelectionInline",
113
+ props: {
114
+ visible: { type: Boolean },
115
+ initialValue: {},
116
+ filterItems: { type: Function }
117
+ },
118
+ emits: ["confirm", "cancel"],
119
+ setup(e, { emit: d }) {
120
+ const r = e, i = d, u = ref();
121
+ watch(
122
+ () => r.visible,
123
+ (l) => {
124
+ var s, h;
125
+ !l && u.value && ((h = (s = u.value).setSelectedItems) == null || h.call(s, r.initialValue || []));
126
+ }
127
+ );
128
+ function a() {
129
+ var l;
130
+ (l = u.value) == null || l.onConfirm();
131
+ }
132
+ function o() {
133
+ i("cancel");
134
+ }
135
+ function n(l) {
136
+ i("confirm", l);
137
+ }
138
+ return (l, s) => {
139
+ const h = resolveComponent("FmIcon"), g = resolveComponent("FmButton");
140
+ return e.visible ? (openBlock(), createElementBlock("div", _hoisted_1$l, [
141
+ createElementVNode("div", _hoisted_2$h, [
142
+ createElementVNode("div", _hoisted_3$e, [
143
+ createVNode(h, {
144
+ name: "restaurant",
145
+ size: "md"
146
+ }),
147
+ s[0] || (s[0] = createElementVNode("h3", { class: "fm-typo-en-body-lg-600" }, "Select Items", -1))
148
+ ]),
149
+ createVNode(g, {
150
+ icon: "close",
151
+ variant: "tertiary",
152
+ onClick: o
153
+ })
154
+ ]),
155
+ s[1] || (s[1] = createElementVNode("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Choose which items this discount applies to. For bundle discounts, select multiple items that can be bundled together. ", -1)),
156
+ createElementVNode("div", _hoisted_4$b, [
157
+ createVNode(_sfc_main$o, {
158
+ ref_key: "selectItemRef",
159
+ ref: u,
160
+ "initial-value": e.initialValue,
161
+ "filter-items": e.filterItems,
162
+ "on-complete": n,
163
+ "max-height": 300
164
+ }, null, 8, ["initial-value", "filter-items"])
165
+ ]),
166
+ createElementVNode("div", _hoisted_5$7, [
167
+ createVNode(g, {
168
+ variant: "secondary",
169
+ label: "Cancel",
170
+ onClick: o
171
+ }),
172
+ createVNode(g, {
173
+ variant: "primary",
174
+ label: "Confirm Selection",
175
+ onClick: a
176
+ })
177
+ ])
178
+ ])) : createCommentVNode("", !0);
179
+ };
180
+ }
181
+ }), _hoisted_1$k = {
182
+ key: 0,
183
+ class: "bg-fm-color-neutral-gray-50 border border-fm-color-neutral-gray-200 rounded-8 p-16 space-y-16"
184
+ }, _hoisted_2$g = { class: "flex items-center justify-between" }, _hoisted_3$d = { class: "flex items-center gap-8" }, _hoisted_4$a = { class: "flex gap-16 items-center flex-wrap" }, _hoisted_5$6 = { class: "flex gap-8 items-center" }, _hoisted_6$5 = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, _hoisted_7$4 = { class: "bg-white border border-fm-color-neutral-gray-200 rounded-8 max-h-[300px] overflow-y-auto" }, _hoisted_8$2 = { class: "flex items-center gap-12" }, _hoisted_9$2 = { class: "fm-typo-en-body-md-600" }, _hoisted_10$2 = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, _hoisted_11$2 = {
185
+ key: 1,
186
+ class: "p-24 text-center"
187
+ }, _hoisted_12$1 = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _hoisted_13$1 = { class: "flex justify-end gap-8 pt-8 border-t border-fm-color-neutral-gray-200" }, _sfc_main$m = /* @__PURE__ */ defineComponent({
188
+ __name: "GrabCategorySelectionInline",
189
+ props: {
190
+ visible: { type: Boolean },
191
+ initialValue: {}
192
+ },
193
+ emits: ["confirm", "cancel"],
194
+ setup(e, { emit: d }) {
195
+ const r = e, i = d, u = Cb(), a = ref({}), o = ref(""), n = computed(() => {
196
+ const m = u.menu.value;
197
+ return m ? m.modules.category.map((f) => ({
198
+ id: f._id,
199
+ name: f.name
200
+ })) : [];
201
+ }), l = computed(() => {
202
+ if (!o.value) return n.value;
203
+ const m = o.value.toLowerCase();
204
+ return n.value.filter(
205
+ (f) => f.name.toLowerCase().includes(m)
206
+ );
207
+ }), s = computed(() => Object.values(a.value).filter(Boolean).length);
208
+ function h() {
209
+ a.value = n.value.reduce(
210
+ (m, f) => (m[f.id] = r.initialValue.includes(f.id), m),
211
+ {}
212
+ );
213
+ }
214
+ watch([() => r.visible, () => r.initialValue], () => {
215
+ r.visible && h();
216
+ }), onMounted(async () => {
217
+ await u.store.getMenu(), h();
218
+ });
219
+ function g(m) {
220
+ a.value[m] = !a.value[m];
221
+ }
222
+ function b() {
223
+ const m = s.value === l.value.length;
224
+ l.value.forEach((f) => {
225
+ a.value[f.id] = !m;
226
+ });
227
+ }
228
+ function V() {
229
+ Object.keys(a.value).forEach((m) => {
230
+ a.value[m] = !1;
231
+ });
232
+ }
233
+ function p() {
234
+ const m = Object.entries(a.value).filter(([, f]) => f).map(([f]) => f);
235
+ i("confirm", m);
236
+ }
237
+ function c() {
238
+ i("cancel");
239
+ }
240
+ const y = computed(() => l.value.length > 0 && l.value.every(
241
+ (m) => a.value[m.id]
242
+ ));
243
+ return (m, f) => {
244
+ const B = resolveComponent("FmIcon"), C = resolveComponent("FmButton"), E = resolveComponent("FmTextField"), $ = resolveComponent("FmCheckbox"), x = resolveComponent("FmListItem"), S = resolveComponent("FmList");
245
+ return e.visible ? (openBlock(), createElementBlock("div", _hoisted_1$k, [
246
+ createElementVNode("div", _hoisted_2$g, [
247
+ createElementVNode("div", _hoisted_3$d, [
248
+ createVNode(B, {
249
+ name: "category",
250
+ size: "md"
251
+ }),
252
+ f[2] || (f[2] = createElementVNode("h3", { class: "fm-typo-en-body-lg-600" }, "Select Categories", -1))
253
+ ]),
254
+ createVNode(C, {
255
+ icon: "close",
256
+ variant: "tertiary",
257
+ onClick: c
258
+ })
259
+ ]),
260
+ f[3] || (f[3] = createElementVNode("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Choose which categories this discount applies to. The discount will be available for all items within the selected categories. ", -1)),
261
+ createElementVNode("div", _hoisted_4$a, [
262
+ createElementVNode("div", _hoisted_5$6, [
263
+ createVNode(C, {
264
+ icon: "select_all",
265
+ variant: "tertiary",
266
+ size: "small",
267
+ label: `${y.value ? "Deselect" : "Select"} All`,
268
+ onClick: b
269
+ }, null, 8, ["label"]),
270
+ createVNode(C, {
271
+ icon: "sync",
272
+ variant: "tertiary",
273
+ size: "small",
274
+ label: "Clear",
275
+ onClick: V
276
+ }),
277
+ createElementVNode("span", _hoisted_6$5, toDisplayString(s.value) + " selected ", 1)
278
+ ]),
279
+ createVNode(E, {
280
+ modelValue: o.value,
281
+ "onUpdate:modelValue": f[0] || (f[0] = (N) => o.value = N),
282
+ placeholder: "Search categories",
283
+ "leading-icon": { name: "search", color: "" },
284
+ class: "flex-1 min-w-[200px]"
285
+ }, null, 8, ["modelValue"])
286
+ ]),
287
+ createElementVNode("div", _hoisted_7$4, [
288
+ l.value.length > 0 ? (openBlock(), createBlock(S, { key: 0 }, {
289
+ default: withCtx(() => [
290
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(l.value, (N) => (openBlock(), createBlock(x, {
291
+ key: N.id,
292
+ clickable: !0,
293
+ onClick: (I) => g(N.id)
294
+ }, {
295
+ leading: withCtx(() => [
296
+ createVNode($, {
297
+ "model-value": a.value[N.id] || !1,
298
+ value: N.id,
299
+ "onUpdate:modelValue": (I) => g(N.id),
300
+ onClick: f[1] || (f[1] = withModifiers(() => {
301
+ }, ["stop"]))
302
+ }, null, 8, ["model-value", "value", "onUpdate:modelValue"])
303
+ ]),
304
+ default: withCtx(() => [
305
+ createElementVNode("div", _hoisted_8$2, [
306
+ createVNode(B, {
307
+ name: "category",
308
+ size: "sm",
309
+ class: "text-fm-color-typo-secondary"
310
+ }),
311
+ createElementVNode("div", null, [
312
+ createElementVNode("div", _hoisted_9$2, toDisplayString(N.name), 1),
313
+ createElementVNode("div", _hoisted_10$2, " ID: " + toDisplayString(N.id), 1)
314
+ ])
315
+ ])
316
+ ]),
317
+ _: 2
318
+ }, 1032, ["onClick"]))), 128))
319
+ ]),
320
+ _: 1
321
+ })) : (openBlock(), createElementBlock("div", _hoisted_11$2, [
322
+ createElementVNode("div", _hoisted_12$1, toDisplayString(o.value ? "No categories found matching your search." : "No categories available."), 1)
323
+ ]))
324
+ ]),
325
+ createElementVNode("div", _hoisted_13$1, [
326
+ createVNode(C, {
327
+ variant: "secondary",
328
+ label: "Cancel",
329
+ onClick: c
330
+ }),
331
+ createVNode(C, {
332
+ variant: "primary",
333
+ label: `Confirm Selection (${s.value})`,
334
+ disabled: s.value === 0,
335
+ onClick: p
336
+ }, null, 8, ["label", "disabled"])
337
+ ])
338
+ ])) : createCommentVNode("", !0);
339
+ };
340
+ }
341
+ }), _hoisted_1$j = { class: "space-y-8" }, _hoisted_2$f = {
342
+ key: 1,
343
+ class: "border-1 rounded-md flex gap-16 items-center justify-between px-16 py-12"
344
+ }, _hoisted_3$c = { class: "fm-typo-en-body-lg-400" }, _hoisted_4$9 = { class: "text-fm-color-typo-secondary" }, _hoisted_5$5 = { key: 0 }, _hoisted_6$4 = { class: "space-y-24" }, _hoisted_7$3 = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary mt-4" }, _hoisted_8$1 = { key: 0 }, _hoisted_9$1 = { class: "fm-typo-en-body-md-600 mb-8 block" }, _hoisted_10$1 = { key: 1 }, _hoisted_11$1 = { key: 2 }, _hoisted_12 = { key: 0 }, _hoisted_13 = { class: "space-y-8" }, _hoisted_14 = { class: "flex items-center justify-between p-12 border border-fm-color-neutral-gray-200 fm-corner-radius-md" }, _hoisted_15 = { class: "flex items-center gap-8" }, _hoisted_16 = { class: "fm-typo-en-body-md-400" }, _hoisted_17 = { key: 3 }, _hoisted_18 = { key: 0 }, _hoisted_19 = { class: "space-y-8" }, _hoisted_20 = { class: "flex items-center justify-between p-12 border border-fm-color-neutral-gray-200 fm-corner-radius-md" }, _hoisted_21 = { class: "flex items-center gap-8" }, _hoisted_22 = { class: "fm-typo-en-body-md-400" }, _hoisted_23 = {
345
+ key: 0,
346
+ class: "mt-16 p-12 bg-fm-color-feedback-error-light rounded-8 border border-fm-color-feedback-error-main"
347
+ }, _hoisted_24 = { class: "flex items-center gap-8 mb-8 text-fm-color-system-error-300" }, _hoisted_25 = { class: "space-y-4" }, _hoisted_26 = { class: "flex gap-16" }, _sfc_main$l = /* @__PURE__ */ defineComponent({
348
+ __name: "GrabEffectSheet",
349
+ props: {
350
+ modelValue: { type: Object }
351
+ },
352
+ emits: ["update:model-value"],
353
+ setup(e, { emit: d }) {
354
+ const r = e, i = d, u = Cb(), a = ref(!1), o = ref(!1), n = ref(!1), l = ref({
355
+ type: "net",
356
+ value: 0,
357
+ scope: {
358
+ type: "order"
359
+ }
360
+ });
361
+ watch(
362
+ () => r.modelValue,
363
+ (v) => {
364
+ v && (l.value = { ...v });
365
+ },
366
+ { immediate: !0 }
367
+ ), onMounted(async () => {
368
+ await u.store.getMenu();
369
+ });
370
+ const s = computed(() => {
371
+ var v;
372
+ return !(!l.value.type || !((v = l.value.scope) != null && v.type) || b(l.value.type) && (!l.value.value || l.value.value <= 0) || (l.value.scope.type === "items" || l.value.scope.type === "category") && (!l.value.scope.objectIDs || l.value.scope.objectIDs.length === 0));
373
+ });
374
+ async function h(v) {
375
+ v.stopPropagation(), await prompt.remove("Are you sure you want to remove this discount?") && i("update:model-value", null);
376
+ }
377
+ function g() {
378
+ var v;
379
+ return B(((v = l.value.scope) == null ? void 0 : v.type) || "order");
380
+ }
381
+ function b(v) {
382
+ return v && !["freeItem", "delivery"].includes(v);
383
+ }
384
+ function V(v) {
385
+ return v && ["percentage", "bundleSamePercentage", "bundleDiffPercentage"].includes(
386
+ v
387
+ );
388
+ }
389
+ function p(v) {
390
+ return v != null && v.includes("Percentage") ? "Discount percentage" : v != null && v.includes("FixPrice") ? "Bundle fixed price" : v === "percentage" ? "Discount percentage" : "Discount amount";
391
+ }
392
+ function c(v) {
393
+ return v != null && v.includes("Percentage") || v === "percentage" ? "10" : "5.00";
394
+ }
395
+ function y(v) {
396
+ return v != null && v.includes("Percentage") || v === "percentage" ? "%" : "$";
397
+ }
398
+ function m(v, k) {
399
+ l.value = {
400
+ ...l.value,
401
+ [v]: k
402
+ };
403
+ }
404
+ function f(v, k) {
405
+ var T;
406
+ const w = {
407
+ ...l.value.scope,
408
+ [v]: k
409
+ };
410
+ if (l.value = {
411
+ ...l.value,
412
+ scope: w
413
+ }, v === "type") {
414
+ const F = B(k);
415
+ F.some(
416
+ (U) => U.value === l.value.type
417
+ ) || (l.value = {
418
+ ...l.value,
419
+ type: ((T = F[0]) == null ? void 0 : T.value) || "net",
420
+ // Reset value and cap when changing to incompatible type
421
+ value: 0,
422
+ cap: void 0
423
+ });
424
+ }
425
+ }
426
+ function B(v) {
427
+ switch (v) {
428
+ case "order":
429
+ return [
430
+ { label: "Amount off", value: "net" },
431
+ { label: "Percentage off", value: "percentage" },
432
+ { label: "Delivery fee off", value: "delivery" }
433
+ ];
434
+ case "category":
435
+ return [
436
+ { label: "Amount off", value: "net" },
437
+ { label: "Percentage off", value: "percentage" }
438
+ ];
439
+ case "items":
440
+ return [
441
+ { label: "Amount off", value: "net" },
442
+ { label: "Percentage off", value: "percentage" },
443
+ { label: "Free item", value: "freeItem" },
444
+ {
445
+ label: "Bundle (same item) - Fixed price",
446
+ value: "bundleSameFixPrice"
447
+ },
448
+ { label: "Bundle (same item) - Amount off", value: "bundleSameNet" },
449
+ {
450
+ label: "Bundle (same item) - Percentage off",
451
+ value: "bundleSamePercentage"
452
+ },
453
+ {
454
+ label: "Bundle (different items) - Fixed price",
455
+ value: "bundleDiffFixPrice"
456
+ },
457
+ {
458
+ label: "Bundle (different items) - Amount off",
459
+ value: "bundleDiffNet"
460
+ },
461
+ {
462
+ label: "Bundle (different items) - Percentage off",
463
+ value: "bundleDiffPercentage"
464
+ }
465
+ ];
466
+ default:
467
+ return [
468
+ { label: "Amount off", value: "net" },
469
+ { label: "Percentage off", value: "percentage" }
470
+ ];
471
+ }
472
+ }
473
+ function C(v) {
474
+ switch (v) {
475
+ case "order":
476
+ return "Applies to entire order. Available: Amount off, Percentage off, Delivery fee discount.";
477
+ case "category":
478
+ return "Applies to specific item categories. Available: Amount off, Percentage off, Free item.";
479
+ case "items":
480
+ return "Applies to specific items. Available: Basic discounts, Bundle offers (same/different items).";
481
+ default:
482
+ return "Select how you want to apply the discount.";
483
+ }
484
+ }
485
+ function E() {
486
+ var v;
487
+ return ((v = l.value.scope) == null ? void 0 : v.type) === "items";
488
+ }
489
+ function $() {
490
+ var v;
491
+ return ((v = l.value.scope) == null ? void 0 : v.type) === "category";
492
+ }
493
+ function x() {
494
+ var w;
495
+ const v = (w = l.value.scope) == null ? void 0 : w.objectIDs;
496
+ if (!v || v.length === 0)
497
+ return "No items selected";
498
+ const k = u.menu.value;
499
+ return k && v.length <= 3 ? v.map((F) => {
500
+ const R = k.modules.item.find((U) => U._id === F);
501
+ return R ? (R.name2 || R.name).trim() : `Item ${F}`;
502
+ }).join(", ") : v.length === 1 ? "1 item selected" : `${v.length} items selected`;
503
+ }
504
+ function S() {
505
+ var w;
506
+ const v = (w = l.value.scope) == null ? void 0 : w.objectIDs;
507
+ if (!v || v.length === 0)
508
+ return "No categories selected";
509
+ const k = u.menu.value;
510
+ return k && v.length <= 3 ? v.map((F) => {
511
+ const R = k.modules.category.find((U) => U._id === F);
512
+ return R ? R.name : `Category ${F}`;
513
+ }).join(", ") : v.length === 1 ? "1 category selected" : `${v.length} categories selected`;
514
+ }
515
+ function N() {
516
+ o.value = !0;
517
+ }
518
+ function I() {
519
+ n.value = !0;
520
+ }
521
+ function M(v) {
522
+ f("objectIDs", v), o.value = !1;
523
+ }
524
+ function j(v) {
525
+ f("objectIDs", v), n.value = !1;
526
+ }
527
+ function Y() {
528
+ o.value = !1;
529
+ }
530
+ function G() {
531
+ n.value = !1;
532
+ }
533
+ const H = computed(() => {
534
+ var k, w, T;
535
+ const v = [];
536
+ return l.value.type || v.push("Discount type is required"), (k = l.value.scope) != null && k.type || v.push("Scope type is required"), b(l.value.type) && (!l.value.value || l.value.value <= 0) && v.push("Discount amount must be greater than 0"), ((w = l.value.scope) == null ? void 0 : w.type) === "items" && (!l.value.scope.objectIDs || l.value.scope.objectIDs.length === 0) && v.push("Please select at least one item"), ((T = l.value.scope) == null ? void 0 : T.type) === "category" && (!l.value.scope.objectIDs || l.value.scope.objectIDs.length === 0) && v.push("Please select at least one category"), v;
537
+ });
538
+ function Z() {
539
+ i("update:model-value", l.value), a.value = !1;
540
+ }
541
+ const q = [
542
+ { label: "Bill discount", value: "order" },
543
+ { label: "Item discount", value: "items" },
544
+ { label: "Category discount", value: "category" }
545
+ ];
546
+ return (v, k) => {
547
+ const w = resolveComponent("FmButton"), T = resolveComponent("FmSelect"), F = resolveComponent("FmStepperField"), R = resolveComponent("FmIcon"), U = resolveComponent("FmSideSheet");
548
+ return openBlock(), createBlock(U, {
549
+ "max-width": 550,
550
+ header: "Apply discount",
551
+ modelValue: unref(a),
552
+ "onUpdate:modelValue": [
553
+ k[5] || (k[5] = (D) => isRef(a) ? a.value = D : null),
554
+ k[6] || (k[6] = (D) => a.value = D)
555
+ ]
556
+ }, {
557
+ "side-sheet-button": withCtx(() => {
558
+ var D, P, A, L;
559
+ return [
560
+ createElementVNode("div", _hoisted_1$j, [
561
+ k[7] || (k[7] = createElementVNode("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Configure the Grab campaign discount you want to offer your customers. ", -1)),
562
+ e.modelValue ? (openBlock(), createElementBlock("div", _hoisted_2$f, [
563
+ createElementVNode("div", _hoisted_3$c, [
564
+ createElementVNode("div", null, toDisplayString((D = unref(summarizeGrabDiscount)(e.modelValue)) == null ? void 0 : D.type), 1),
565
+ createElementVNode("div", _hoisted_4$9, [
566
+ createTextVNode(toDisplayString((P = unref(summarizeGrabDiscount)(e.modelValue)) == null ? void 0 : P.adjustment) + " ", 1),
567
+ (A = unref(summarizeGrabDiscount)(e.modelValue)) != null && A.cap ? (openBlock(), createElementBlock("span", _hoisted_5$5, toDisplayString((L = unref(summarizeGrabDiscount)(e.modelValue)) == null ? void 0 : L.cap), 1)) : createCommentVNode("", !0)
568
+ ])
569
+ ]),
570
+ createVNode(w, {
571
+ icon: "delete",
572
+ "icon-color": "neutral-gray-400",
573
+ variant: "tertiary",
574
+ onClick: h
575
+ })
576
+ ])) : (openBlock(), createBlock(w, {
577
+ key: 0,
578
+ label: "Apply Grab discount",
579
+ icon: "add",
580
+ "icon-color": "primary",
581
+ variant: "secondary",
582
+ class: "border-fm-color-primary text-fm-color-primary"
583
+ }))
584
+ ])
585
+ ];
586
+ }),
587
+ "side-sheet-footer": withCtx(() => [
588
+ createElementVNode("div", _hoisted_26, [
589
+ createVNode(w, {
590
+ variant: "secondary",
591
+ label: "Cancel",
592
+ class: "flex-1",
593
+ onClick: k[4] || (k[4] = (D) => a.value = !1)
594
+ }),
595
+ createVNode(w, {
596
+ variant: "primary",
597
+ label: unref(s) ? "Confirm" : "Complete Required Fields",
598
+ class: "flex-1",
599
+ disabled: !unref(s),
600
+ onClick: Z
601
+ }, null, 8, ["label", "disabled"])
602
+ ])
603
+ ]),
604
+ default: withCtx(() => {
605
+ var D, P, A, L;
606
+ return [
607
+ createElementVNode("div", _hoisted_6$4, [
608
+ createElementVNode("div", null, [
609
+ k[8] || (k[8] = createElementVNode("label", { class: "fm-typo-en-body-md-600 mb-8 block" }, "Campaign type", -1)),
610
+ createVNode(T, {
611
+ "model-value": ((D = unref(l).scope) == null ? void 0 : D.type) || "order",
612
+ "onUpdate:modelValue": k[0] || (k[0] = (O) => f("type", O)),
613
+ placeholder: "Select campaign type",
614
+ items: q
615
+ }, null, 8, ["model-value"]),
616
+ createElementVNode("div", _hoisted_7$3, toDisplayString(C((P = unref(l).scope) == null ? void 0 : P.type)), 1)
617
+ ]),
618
+ createElementVNode("div", null, [
619
+ k[9] || (k[9] = createElementVNode("label", { class: "fm-typo-en-body-md-600 mb-8 block" }, "Discount type", -1)),
620
+ createVNode(T, {
621
+ "model-value": unref(l).type,
622
+ "onUpdate:modelValue": k[1] || (k[1] = (O) => m("type", O)),
623
+ placeholder: "Select discount type",
624
+ items: g()
625
+ }, null, 8, ["model-value", "items"])
626
+ ]),
627
+ b(unref(l).type) ? (openBlock(), createElementBlock("div", _hoisted_8$1, [
628
+ createElementVNode("label", _hoisted_9$1, toDisplayString(p(unref(l).type)), 1),
629
+ createVNode(F, {
630
+ modelValue: unref(l).value,
631
+ "onUpdate:modelValue": k[2] || (k[2] = (O) => unref(l).value = O),
632
+ placeholder: c(unref(l).type),
633
+ suffix: y(unref(l).type),
634
+ type: "number"
635
+ }, null, 8, ["modelValue", "placeholder", "suffix"])
636
+ ])) : createCommentVNode("", !0),
637
+ V(unref(l).type) ? (openBlock(), createElementBlock("div", _hoisted_10$1, [
638
+ k[10] || (k[10] = createElementVNode("label", { class: "fm-typo-en-body-md-600 mb-8 block" }, "Discount cap (optional)", -1)),
639
+ createVNode(F, {
640
+ modelValue: unref(l).cap,
641
+ "onUpdate:modelValue": k[3] || (k[3] = (O) => unref(l).cap = O),
642
+ placeholder: "Maximum discount amount",
643
+ type: "number"
644
+ }, null, 8, ["modelValue"])
645
+ ])) : createCommentVNode("", !0),
646
+ E() ? (openBlock(), createElementBlock("div", _hoisted_11$1, [
647
+ unref(o) ? createCommentVNode("", !0) : (openBlock(), createElementBlock("div", _hoisted_12, [
648
+ k[12] || (k[12] = createElementVNode("label", { class: "fm-typo-en-body-md-600 mb-8 block" }, "Select Items", -1)),
649
+ createElementVNode("div", _hoisted_13, [
650
+ createElementVNode("div", _hoisted_14, [
651
+ createElementVNode("div", _hoisted_15, [
652
+ createVNode(R, {
653
+ name: "restaurant",
654
+ size: "md"
655
+ }),
656
+ createElementVNode("span", _hoisted_16, toDisplayString(x()), 1)
657
+ ]),
658
+ createVNode(w, {
659
+ variant: "secondary",
660
+ label: "Select Items",
661
+ icon: "chevron_right",
662
+ onClick: N
663
+ })
664
+ ]),
665
+ k[11] || (k[11] = createElementVNode("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Choose which items this discount applies to. Bundle discounts require multiple items. ", -1))
666
+ ])
667
+ ])),
668
+ createVNode(_sfc_main$n, {
669
+ visible: unref(o),
670
+ "initial-value": ((A = unref(l).scope) == null ? void 0 : A.objectIDs) || [],
671
+ onConfirm: M,
672
+ onCancel: Y
673
+ }, null, 8, ["visible", "initial-value"])
674
+ ])) : createCommentVNode("", !0),
675
+ $() ? (openBlock(), createElementBlock("div", _hoisted_17, [
676
+ unref(n) ? createCommentVNode("", !0) : (openBlock(), createElementBlock("div", _hoisted_18, [
677
+ k[14] || (k[14] = createElementVNode("label", { class: "fm-typo-en-body-md-600 mb-8 block" }, "Select Categories", -1)),
678
+ createElementVNode("div", _hoisted_19, [
679
+ createElementVNode("div", _hoisted_20, [
680
+ createElementVNode("div", _hoisted_21, [
681
+ createVNode(R, {
682
+ name: "category",
683
+ size: "md"
684
+ }),
685
+ createElementVNode("span", _hoisted_22, toDisplayString(S()), 1)
686
+ ]),
687
+ createVNode(w, {
688
+ variant: "secondary",
689
+ label: "Select Categories",
690
+ icon: "chevron_right",
691
+ onClick: I
692
+ })
693
+ ]),
694
+ k[13] || (k[13] = createElementVNode("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Choose which categories this discount applies to. ", -1))
695
+ ])
696
+ ])),
697
+ createVNode(_sfc_main$m, {
698
+ visible: unref(n),
699
+ "initial-value": ((L = unref(l).scope) == null ? void 0 : L.objectIDs) || [],
700
+ onConfirm: j,
701
+ onCancel: G
702
+ }, null, 8, ["visible", "initial-value"])
703
+ ])) : createCommentVNode("", !0)
704
+ ]),
705
+ unref(H).length > 0 ? (openBlock(), createElementBlock("div", _hoisted_23, [
706
+ createElementVNode("div", _hoisted_24, [
707
+ createVNode(R, { name: "warning" }),
708
+ k[15] || (k[15] = createElementVNode("span", { class: "fm-typo-en-body-sm-600" }, "Please fix the following issues:", -1))
709
+ ]),
710
+ createElementVNode("ul", _hoisted_25, [
711
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(H), (O) => (openBlock(), createElementBlock("li", {
712
+ key: O,
713
+ class: "fm-typo-en-body-sm-400 text-fm-color-feedback-error-main flex items-start gap-8"
714
+ }, [
715
+ k[16] || (k[16] = createElementVNode("span", { class: "w-4 h-4 bg-fm-color-feedback-error-main rounded-full mt-6 flex-shrink-0" }, null, -1)),
716
+ createTextVNode(" " + toDisplayString(O), 1)
717
+ ]))), 128))
718
+ ])
719
+ ])) : createCommentVNode("", !0)
720
+ ];
721
+ }),
722
+ _: 1
723
+ }, 8, ["modelValue"]);
724
+ };
725
+ }
726
+ }), GrabEffectSheet = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["__scopeId", "data-v-cf604dd7"]]), _hoisted_1$i = { class: "space-y-24" }, _sfc_main$k = /* @__PURE__ */ defineComponent({
727
+ __name: "TimeRuleGroup",
728
+ props: {
729
+ modelValue: {
730
+ type: Object,
731
+ default: () => {
732
+ }
733
+ }
734
+ },
735
+ emits: ["update:model-value"],
736
+ setup(e, { emit: d }) {
737
+ const { t: r } = useI18n(), i = e, u = d, a = ref(
738
+ !i.modelValue || !i.modelValue.rules.g_time ? "all_time" : RuleBuilder.getRules(i.modelValue.rules.g_time).length > 0 ? "custom" : "all_time"
739
+ );
740
+ watch(a, async (n, l) => {
741
+ var s;
742
+ if (l == "custom" && n == "all_time" && RuleBuilder.getRules((s = i.modelValue) == null ? void 0 : s.rules.g_time).length > 0) {
743
+ const h = await prompt.confirm(
744
+ r("connect.template.rule.time.confirm_remove"),
745
+ r("connect.common.confirm"),
746
+ r("connect.common.confirm"),
747
+ r("connect.common.cancel")
748
+ );
749
+ h && u(
750
+ "update:model-value",
751
+ RuleBuilder.setRuleToGroup(
752
+ i.modelValue ?? RuleBuilder.scaffoldGroup(),
753
+ RuleBuilder.scaffoldGroup("g_time")
754
+ )
755
+ ), a.value = h ? n : l;
756
+ }
757
+ });
758
+ async function o(n) {
759
+ var l;
760
+ if (n == "custom" && RuleBuilder.getRules((l = i.modelValue) == null ? void 0 : l.rules.g_time).length > 0) {
761
+ if (!await prompt.confirm(
762
+ r("connect.template.rule.time.confirm_remove"),
763
+ r("connect.common.confirm"),
764
+ r("connect.common.confirm"),
765
+ r("connect.common.cancel")
766
+ )) {
767
+ a.value = "all_time";
768
+ return;
769
+ }
770
+ u(
771
+ "update:model-value",
772
+ RuleBuilder.setRuleToGroup(
773
+ i.modelValue ?? RuleBuilder.scaffoldGroup(),
774
+ RuleBuilder.scaffoldGroup("g_time")
775
+ )
776
+ );
777
+ }
778
+ }
779
+ return (n, l) => {
780
+ var g;
781
+ const s = resolveComponent("FmRadio"), h = resolveComponent("FmRadioGroup");
782
+ return openBlock(), createElementBlock("div", _hoisted_1$i, [
783
+ createVNode(h, {
784
+ modelValue: unref(a),
785
+ "onUpdate:modelValue": [
786
+ l[0] || (l[0] = (b) => isRef(a) ? a.value = b : null),
787
+ l[1] || (l[1] = (b) => o(b))
788
+ ]
789
+ }, {
790
+ default: withCtx(() => [
791
+ createVNode(s, {
792
+ label: unref(r)("connect.template.rule.time.all_time"),
793
+ value: "all_time"
794
+ }, null, 8, ["label"]),
795
+ createVNode(s, {
796
+ label: unref(r)("connect.template.rule.time.custom"),
797
+ value: "custom"
798
+ }, null, 8, ["label"])
799
+ ]),
800
+ _: 1
801
+ }, 8, ["modelValue"]),
802
+ unref(a) == "custom" ? (openBlock(), createBlock(_sfc_main$p, {
803
+ key: 0,
804
+ class: "!mt-[0px]",
805
+ "include-only": "trigger",
806
+ "trigger-type": "SCHEDULE",
807
+ "model-value": ((g = e.modelValue) == null ? void 0 : g.rules.g_time) ?? unref(RuleBuilder).scaffoldGroup("g_time"),
808
+ "onUpdate:modelValue": l[2] || (l[2] = (b) => u(
809
+ "update:model-value",
810
+ unref(RuleBuilder).setRuleToGroup(
811
+ e.modelValue ?? unref(RuleBuilder).scaffoldGroup(),
812
+ b,
813
+ "&&"
814
+ )
815
+ ))
816
+ }, null, 8, ["model-value"])) : createCommentVNode("", !0)
817
+ ]);
818
+ };
819
+ }
820
+ }), _sfc_main$j = /* @__PURE__ */ defineComponent({
821
+ __name: "BirthdayInput",
822
+ props: {
823
+ modelValue: {
824
+ type: Object
825
+ }
826
+ },
827
+ emits: ["update:model-value"],
828
+ setup(e, { emit: d }) {
829
+ const r = e, i = d, u = computed(() => {
830
+ const { property: a, operator: o, equator: n } = RuleBuilder.simplify(
831
+ r.modelValue ?? RuleBuilder.constructEntry("user.birthday", "_isDay", {
832
+ op: "before",
833
+ x: 1
834
+ })
835
+ );
836
+ return {
837
+ property: a,
838
+ operator: o,
839
+ equator: n
840
+ };
841
+ });
842
+ return (a, o) => {
843
+ const n = resolveComponent("FmRadio"), l = resolveComponent("FmStepperField");
844
+ return openBlock(), createElementBlock("div", null, [
845
+ createVNode(n, {
846
+ label: "On birthday",
847
+ value: "_isRange-day",
848
+ "model-value": `${unref(u).operator}-${unref(u).equator.unit}`,
849
+ "onUpdate:modelValue": o[0] || (o[0] = () => {
850
+ i(
851
+ "update:model-value",
852
+ unref(RuleBuilder).constructEntry("user.birthday", "_isRange", {
853
+ op: "this",
854
+ unit: "day",
855
+ ignoreYear: !0
856
+ })
857
+ );
858
+ })
859
+ }, null, 8, ["model-value"]),
860
+ createVNode(n, {
861
+ label: "N days before birthday",
862
+ value: "_isDay",
863
+ "model-value": unref(u).operator,
864
+ "onUpdate:modelValue": o[1] || (o[1] = () => {
865
+ i(
866
+ "update:model-value",
867
+ unref(RuleBuilder).constructEntry("user.birthday", "_isDay", {
868
+ op: "after",
869
+ x: 1,
870
+ ignoreYear: !0
871
+ })
872
+ );
873
+ })
874
+ }, null, 8, ["model-value"]),
875
+ unref(u).operator == "_isDay" ? (openBlock(), createBlock(l, {
876
+ key: 0,
877
+ label: "Days before birthday",
878
+ "show-steppers": !1,
879
+ "model-value": unref(u).equator.x,
880
+ "onUpdate:modelValue": o[2] || (o[2] = (s) => i(
881
+ "update:model-value",
882
+ unref(RuleBuilder).constructEntry("user.birthday", "_isDay", {
883
+ op: "after",
884
+ x: s,
885
+ ignoreYear: !0
886
+ })
887
+ ))
888
+ }, null, 8, ["model-value"])) : createCommentVNode("", !0),
889
+ createVNode(n, {
890
+ label: "In birthday week",
891
+ value: "_isRange-week",
892
+ "model-value": `${unref(u).operator}-${unref(u).equator.unit}`,
893
+ "onUpdate:modelValue": o[3] || (o[3] = () => {
894
+ i(
895
+ "update:model-value",
896
+ unref(RuleBuilder).constructEntry("user.birthday", "_isRange", {
897
+ op: "this",
898
+ unit: "week",
899
+ ignoreYear: !0
900
+ })
901
+ );
902
+ })
903
+ }, null, 8, ["model-value"]),
904
+ createVNode(n, {
905
+ label: "In birthday month",
906
+ value: "_isRange-month",
907
+ "model-value": `${unref(u).operator}-${unref(u).equator.unit}`,
908
+ "onUpdate:modelValue": o[4] || (o[4] = () => {
909
+ i(
910
+ "update:model-value",
911
+ unref(RuleBuilder).constructEntry("user.birthday", "_isRange", {
912
+ op: "this",
913
+ unit: "month",
914
+ ignoreYear: !0
915
+ })
916
+ );
917
+ })
918
+ }, null, 8, ["model-value"])
919
+ ]);
920
+ };
921
+ }
922
+ }), _hoisted_1$h = { class: "space-y-16" }, _hoisted_2$e = { class: "grid grid-cols-3 gap-16" }, _hoisted_3$b = { class: "fm-typo-en-title-sm-800" }, _hoisted_4$8 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$i = /* @__PURE__ */ defineComponent({
923
+ __name: "CampaignTriggerInput",
924
+ props: {
925
+ campaignType: {
926
+ type: String,
927
+ required: !0
928
+ },
929
+ modelValue: {
930
+ type: String
931
+ },
932
+ disabled: {
933
+ type: Boolean,
934
+ default: !1
935
+ }
936
+ },
937
+ emits: ["update:model-value"],
938
+ setup(e, { emit: d }) {
939
+ const r = e, i = d, u = computed(() => r.disabled ? TypeToTriggerOptions[r.campaignType].filter(
940
+ (a) => a.value == r.modelValue
941
+ ) : TypeToTriggerOptions[r.campaignType]);
942
+ return (a, o) => {
943
+ const n = resolveComponent("FmCard");
944
+ return openBlock(), createElementBlock("div", _hoisted_1$h, [
945
+ o[0] || (o[0] = createElementVNode("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Define the conditions that must be met to activate a reward. ", -1)),
946
+ createElementVNode("div", _hoisted_2$e, [
947
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(u), (l) => (openBlock(), createBlock(n, {
948
+ variant: "outlined",
949
+ disabled: r.disabled,
950
+ class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
951
+ "col-span-3": unref(u).length == 1,
952
+ "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": e.modelValue == l.value,
953
+ "hover:bg-fm-color-opacity-sm": e.modelValue != l.value
954
+ }]),
955
+ onClick: () => {
956
+ r.modelValue != l.value && !r.disabled && i("update:model-value", l.value);
957
+ },
958
+ key: l.name
959
+ }, {
960
+ default: withCtx(() => [
961
+ createElementVNode("div", _hoisted_3$b, toDisplayString(l.name), 1),
962
+ createElementVNode("div", _hoisted_4$8, toDisplayString(l.description), 1)
963
+ ]),
964
+ _: 2
965
+ }, 1032, ["disabled", "class", "onClick"]))), 128))
966
+ ])
967
+ ]);
968
+ };
969
+ }
970
+ }), _sfc_main$h = /* @__PURE__ */ defineComponent({
971
+ __name: "DateInput",
972
+ props: {
973
+ label: {
974
+ type: String,
975
+ required: !1
976
+ },
977
+ modelValue: {
978
+ type: Object,
979
+ required: !1
980
+ }
981
+ },
982
+ emits: ["update:model-value"],
983
+ setup(e, { emit: d }) {
984
+ const r = d;
985
+ return (i, u) => {
986
+ const a = resolveComponent("FmButton"), o = resolveComponent("FmField"), n = resolveComponent("FmDatePicker");
987
+ return openBlock(), createBlock(n, {
988
+ label: e.label,
989
+ "model-value": e.modelValue || "",
990
+ "onUpdate:modelValue": u[1] || (u[1] = (l) => r("update:model-value", l))
991
+ }, {
992
+ "trigger-button": withCtx(({ opened: l }) => [
993
+ createVNode(o, {
994
+ class: "flex items-center",
995
+ "prepend-icon": "calendar_month",
996
+ "icon-outlined": !l
997
+ }, {
998
+ append: withCtx(() => [
999
+ e.modelValue ? (openBlock(), createBlock(a, {
1000
+ key: 0,
1001
+ variant: "tertiary",
1002
+ icon: "clear",
1003
+ onClick: u[0] || (u[0] = (s) => (s.stopPropagation(), r("update:model-value", null)))
1004
+ })) : createCommentVNode("", !0)
1005
+ ]),
1006
+ default: withCtx(() => [
1007
+ createElementVNode("div", {
1008
+ class: normalizeClass(["fm-typo-en-body-lg-400", { "text-fm-color-typo-secondary": !e.modelValue }])
1009
+ }, toDisplayString(e.modelValue ? unref(hooks)(e.modelValue).format("DD MMM YYYY") : "DD MM YYYY"), 3)
1010
+ ]),
1011
+ _: 1
1012
+ }, 8, ["icon-outlined"])
1013
+ ]),
1014
+ _: 1
1015
+ }, 8, ["label", "model-value"]);
1016
+ };
1017
+ }
1018
+ }), _hoisted_1$g = { class: "flex items-center gap-8 w-full xs:flex-col" }, _hoisted_2$d = { class: "flex-1 xs:w-full" }, _hoisted_3$a = { class: "flex-1 xs:w-full" }, _sfc_main$g = /* @__PURE__ */ defineComponent({
1019
+ __name: "DateRangeInput",
1020
+ props: {
1021
+ modelValue: {
1022
+ type: Object,
1023
+ required: !1
1024
+ }
1025
+ },
1026
+ emits: ["update:model-value"],
1027
+ setup(e, { emit: d }) {
1028
+ const r = d;
1029
+ return (i, u) => {
1030
+ var a, o;
1031
+ return openBlock(), createElementBlock("div", _hoisted_1$g, [
1032
+ createElementVNode("div", _hoisted_2$d, [
1033
+ createVNode(_sfc_main$h, {
1034
+ "model-value": ((a = e.modelValue) == null ? void 0 : a.startDate) ?? null,
1035
+ label: "Start date",
1036
+ "onUpdate:modelValue": u[0] || (u[0] = (n) => {
1037
+ var l;
1038
+ return r("update:model-value", {
1039
+ startDate: n,
1040
+ endDate: ((l = e.modelValue) == null ? void 0 : l.endDate) ?? null
1041
+ });
1042
+ })
1043
+ }, null, 8, ["model-value"])
1044
+ ]),
1045
+ u[2] || (u[2] = createElementVNode("div", { class: "mt-5 xs:hidden" }, "to", -1)),
1046
+ createElementVNode("div", _hoisted_3$a, [
1047
+ createVNode(_sfc_main$h, {
1048
+ "model-value": ((o = e.modelValue) == null ? void 0 : o.endDate) ?? null,
1049
+ label: "End date",
1050
+ "onUpdate:modelValue": u[1] || (u[1] = (n) => {
1051
+ var l;
1052
+ return r("update:model-value", {
1053
+ startDate: ((l = e.modelValue) == null ? void 0 : l.startDate) ?? null,
1054
+ endDate: n
1055
+ });
1056
+ })
1057
+ }, null, 8, ["model-value"])
1058
+ ])
1059
+ ]);
1060
+ };
1061
+ }
1062
+ }), _hoisted_1$f = { class: "space-y-8" }, _hoisted_2$c = { class: "grid grid-cols-2 gap-16" }, _hoisted_3$9 = {
1063
+ key: 0,
1064
+ class: "space-y-4"
1065
+ }, _hoisted_4$7 = { class: "fm-typo-en-body-lg-400 class flex items-center justify-between" }, _hoisted_5$4 = { class: "text-ellipsis line-clamp-1" }, _sfc_main$f = /* @__PURE__ */ defineComponent({
1066
+ __name: "ScheduleRuleInput",
1067
+ props: {
1068
+ modelValue: {
1069
+ type: Object,
1070
+ required: !0
1071
+ },
1072
+ startDate: {
1073
+ type: String
1074
+ },
1075
+ endDate: {
1076
+ type: String
1077
+ }
1078
+ },
1079
+ emits: ["update:model-value"],
1080
+ setup(e, { emit: d }) {
1081
+ const r = e, i = d, u = useCoreStore(), a = computed(
1082
+ () => CountryTimezone[u.currentCountry.value || "MY"]
1083
+ );
1084
+ function o() {
1085
+ const V = RuleBuilder.getRules(r.modelValue);
1086
+ return V.length == 0 ? "fixed" : V.some(
1087
+ (p) => isRuleEntry(p) && RuleBuilder.simplify(p).operator == "_rrule"
1088
+ ) ? "repeating" : "fixed";
1089
+ }
1090
+ const n = ref(o()), l = ref(!1), s = computed(() => {
1091
+ const V = RuleBuilder.getRules(r.modelValue), p = V.find(
1092
+ (y) => isRuleEntry(y) && RuleBuilder.simplify(y).property == "trigger.date"
1093
+ ), c = V.find(
1094
+ (y) => isRuleEntry(y) && RuleBuilder.simplify(y).property == "trigger.time"
1095
+ );
1096
+ return {
1097
+ date: p ? RuleBuilder.simplify(p).equator : null,
1098
+ time: c ? RuleBuilder.simplify(c).equator : null
1099
+ };
1100
+ }), h = computed(
1101
+ () => calculateNextScheduleAt(
1102
+ r.modelValue,
1103
+ /* @__PURE__ */ new Date(),
1104
+ r.startDate ? new Date(r.startDate) : void 0,
1105
+ r.endDate ? new Date(r.endDate) : void 0
1106
+ )
1107
+ );
1108
+ function g(V) {
1109
+ const p = V.label.toLowerCase(), c = p == "fixed" ? [
1110
+ RuleBuilder.constructEntry(
1111
+ "trigger.date",
1112
+ "_isOnDate",
1113
+ (/* @__PURE__ */ new Date()).toISOString()
1114
+ ),
1115
+ RuleBuilder.constructEntry("trigger.time", "_isOnTime", "00:00")
1116
+ ] : [
1117
+ RuleBuilder.constructEntry(
1118
+ "trigger.date",
1119
+ "_rrule",
1120
+ "RRULE:FREQ=DAILY;INTERVAL=1;BYHOUR=0;BYMINUTE=0;BYSECOND=0;WKST=SU"
1121
+ ),
1122
+ RuleBuilder.constructEntry("trigger.time", "_isOnTime", "00:00")
1123
+ ];
1124
+ i(
1125
+ "update:model-value",
1126
+ RuleBuilder.setRuleToGroup(
1127
+ RuleBuilder.scaffoldGroup("g_schedule"),
1128
+ c
1129
+ )
1130
+ ), n.value = p;
1131
+ }
1132
+ function b(V) {
1133
+ n.value == "fixed" ? i(
1134
+ "update:model-value",
1135
+ RuleBuilder.setRuleToGroup(RuleBuilder.scaffoldGroup("g_schedule"), [
1136
+ RuleBuilder.constructEntry(
1137
+ "trigger.date",
1138
+ "_isOnDate",
1139
+ V.date
1140
+ ),
1141
+ RuleBuilder.constructEntry(
1142
+ "trigger.time",
1143
+ "_isOnTime",
1144
+ V.time
1145
+ )
1146
+ ])
1147
+ ) : i(
1148
+ "update:model-value",
1149
+ RuleBuilder.setRuleToGroup(RuleBuilder.scaffoldGroup("g_schedule"), [
1150
+ RuleBuilder.constructEntry(
1151
+ "trigger.date",
1152
+ "_rrule",
1153
+ V.date
1154
+ ),
1155
+ RuleBuilder.constructEntry(
1156
+ "trigger.time",
1157
+ "_isOnTime",
1158
+ V.time
1159
+ )
1160
+ ])
1161
+ );
1162
+ }
1163
+ return (V, p) => {
1164
+ const c = resolveComponent("FmButtonGroup"), y = resolveComponent("FmTimePicker"), m = resolveComponent("FmIcon"), f = resolveComponent("FmTooltip"), B = resolveComponent("FmField"), C = resolveComponent("FmCard"), E = resolveComponent("FmPopover"), $ = resolveComponent("FmDatePicker"), x = resolveComponent("FmHelperText");
1165
+ return openBlock(), createElementBlock(Fragment, null, [
1166
+ createVNode(c, {
1167
+ items: [{ label: "Fixed" }, { label: "Repeating" }],
1168
+ "model-value": { label: unref(cases).title(unref(n)) },
1169
+ "onUpdate:modelValue": g,
1170
+ class: "mb-8"
1171
+ }, null, 8, ["model-value"]),
1172
+ createElementVNode("div", _hoisted_1$f, [
1173
+ createElementVNode("div", _hoisted_2$c, [
1174
+ createVNode(y, {
1175
+ label: "Notify time",
1176
+ "model-value": unref(s).time,
1177
+ "onUpdate:modelValue": p[0] || (p[0] = (S) => b({ date: unref(s).date, time: S })),
1178
+ "helper-text": unref(s).time ? void 0 : "Time is required",
1179
+ "helper-state": unref(s).time ? void 0 : "error"
1180
+ }, null, 8, ["model-value", "helper-text", "helper-state"]),
1181
+ unref(n) == "repeating" ? (openBlock(), createElementBlock("div", _hoisted_3$9, [
1182
+ createElementVNode("div", _hoisted_4$7, [
1183
+ p[5] || (p[5] = createElementVNode("div", null, "Notify date", -1)),
1184
+ unref(s).date ? (openBlock(), createBlock(f, {
1185
+ key: 0,
1186
+ "z-index": 9999,
1187
+ content: unref(SummarizeRrule)(unref(RRule).fromString(unref(s).date).options)
1188
+ }, {
1189
+ default: withCtx(() => [
1190
+ createVNode(m, {
1191
+ name: "info",
1192
+ size: "sm",
1193
+ outline: !0
1194
+ })
1195
+ ]),
1196
+ _: 1
1197
+ }, 8, ["content"])) : createCommentVNode("", !0)
1198
+ ]),
1199
+ createVNode(E, {
1200
+ "show-popover": unref(l),
1201
+ onPopoverChanged: p[3] || (p[3] = (S) => l.value = S)
1202
+ }, {
1203
+ "popover-button": withCtx(() => [
1204
+ createVNode(B, {
1205
+ class: "cursor-pointer",
1206
+ "helper-text": unref(s).date ? void 0 : "Date is required",
1207
+ "helper-state": unref(s).date ? void 0 : "error"
1208
+ }, {
1209
+ default: withCtx(() => [
1210
+ createElementVNode("div", _hoisted_5$4, toDisplayString(unref(s).date ? unref(SummarizeRrule)(unref(RRule).fromString(unref(s).date).options) : "Set a repeating date"), 1)
1211
+ ]),
1212
+ _: 1
1213
+ }, 8, ["helper-text", "helper-state"])
1214
+ ]),
1215
+ default: withCtx(() => [
1216
+ createVNode(C, { class: "elevated p-8 w-[450px]" }, {
1217
+ default: withCtx(() => [
1218
+ createVNode(_sfc_main$q, {
1219
+ "apply-button": !0,
1220
+ "model-value": unref(s).date || "",
1221
+ onCancel: p[1] || (p[1] = (S) => l.value = !1),
1222
+ "onUpdate:modelValue": p[2] || (p[2] = (S) => (b({ date: S, time: unref(s).time }), l.value = !1))
1223
+ }, null, 8, ["model-value"])
1224
+ ]),
1225
+ _: 1
1226
+ })
1227
+ ]),
1228
+ _: 1
1229
+ }, 8, ["show-popover"])
1230
+ ])) : (openBlock(), createBlock($, {
1231
+ key: 1,
1232
+ label: "Notify date",
1233
+ "model-value": unref(s).date || "",
1234
+ "onUpdate:modelValue": p[4] || (p[4] = (S) => b({ date: S, time: unref(s).time })),
1235
+ "helper-text": unref(s).date ? void 0 : "Date is required",
1236
+ "helper-state": unref(s).date ? void 0 : "error"
1237
+ }, null, 8, ["model-value", "helper-text", "helper-state"]))
1238
+ ]),
1239
+ unref(s).date && unref(s).time && unref(h) ? (openBlock(), createBlock(x, {
1240
+ key: 0,
1241
+ text: `${unref(moment)(unref(h)).isAfter(unref(moment)()) ? "The next notification will be sent on " : "Last trigger is on "} ${unref(moment)(unref(h)).format("dddd, DD MMM YYYY")} at
1242
+ ${unref(moment)(unref(h)).format("hh:mmA")}(UTC${unref(moment).tz(unref(a)).format("Z")}) (${unref(moment)(unref(h)).fromNow()})`
1243
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
1244
+ ])
1245
+ ], 64);
1246
+ };
1247
+ }
1248
+ }), _hoisted_1$e = { class: "space-y-16" }, _hoisted_2$b = { class: "grid grid-cols-2 gap-16" }, _hoisted_3$8 = { class: "fm-typo-en-title-sm-800" }, _hoisted_4$6 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$e = /* @__PURE__ */ defineComponent({
1249
+ __name: "GameTypeInput",
1250
+ props: {
1251
+ modelValue: {
1252
+ type: String
1253
+ }
1254
+ },
1255
+ emits: ["update:model-value"],
1256
+ setup(e, { emit: d }) {
1257
+ const r = e, i = d, u = computed(
1258
+ () => [
1259
+ {
1260
+ label: "Fortune Wheel",
1261
+ description: "Allow customers to spin the Fortune Wheel to win various rewards.",
1262
+ value: F_GAME_TYPE.enum.FORTUNE_WHEEL,
1263
+ hidden: !1
1264
+ },
1265
+ {
1266
+ label: "Rock paper scissor",
1267
+ description: "Customers play a game of Rock Paper Scissors against the cashier.",
1268
+ value: F_GAME_TYPE.enum.ROCK_PAPER_SCISSORS,
1269
+ hidden: !0
1270
+ }
1271
+ ].filter((a) => !a.hidden)
1272
+ );
1273
+ return (a, o) => {
1274
+ const n = resolveComponent("FmCard");
1275
+ return openBlock(), createElementBlock("div", _hoisted_1$e, [
1276
+ o[0] || (o[0] = createElementVNode("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Select a game where you want your customer to play. ", -1)),
1277
+ createElementVNode("div", _hoisted_2$b, [
1278
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(u), (l) => (openBlock(), createBlock(n, {
1279
+ variant: "outlined",
1280
+ class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
1281
+ "col-span-2": unref(u).length == 1,
1282
+ "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": e.modelValue == l.value,
1283
+ "hover:bg-fm-color-opacity-sm": e.modelValue != l.value
1284
+ }]),
1285
+ onClick: () => {
1286
+ r.modelValue != l.value && i("update:model-value", l.value);
1287
+ },
1288
+ key: l.value
1289
+ }, {
1290
+ default: withCtx(() => [
1291
+ createElementVNode("div", _hoisted_3$8, toDisplayString(l.label), 1),
1292
+ createElementVNode("div", _hoisted_4$6, toDisplayString(l.description), 1)
1293
+ ]),
1294
+ _: 2
1295
+ }, 1032, ["class", "onClick"]))), 128))
1296
+ ])
1297
+ ]);
1298
+ };
1299
+ }
1300
+ }), _hoisted_1$d = {
1301
+ key: 0,
1302
+ class: "flex flex-col gap-y-24"
1303
+ }, _hoisted_2$a = { class: "flex gap-8 items-center justify-start" }, _sfc_main$d = /* @__PURE__ */ defineComponent({
1304
+ __name: "EditRewardPoolSheet",
1305
+ emits: ["update:model-value"],
1306
+ setup(e, { expose: d, emit: r }) {
1307
+ const i = useMembershipStore(), { minor: u } = useLoading, a = ref(!1), o = ref(), n = ref(), l = ref(0), s = computed(() => {
1308
+ var c;
1309
+ return ((c = i.loyaltyRewards.items.find(
1310
+ (y) => {
1311
+ var m;
1312
+ return y.value === ((m = o.value) == null ? void 0 : m.collectible);
1313
+ }
1314
+ )) == null ? void 0 : c.raw.type) === "CREDIT" ? FdoCreditLoyaltyReward : FdtoRandomReward;
1315
+ }), h = computed(() => {
1316
+ const p = s.value.safeParse(o.value);
1317
+ return p.success ? [] : p.error.errors;
1318
+ });
1319
+ function g(p, c, y) {
1320
+ p && (o.value = c, l.value = y), a.value = p;
1321
+ }
1322
+ const b = r;
1323
+ async function V() {
1324
+ const p = s.value.safeParse(o.value);
1325
+ p.success && (await u(
1326
+ async () => {
1327
+ p.data.type === "VOUCHER" && n.value && (p.data.collectibleConfig.image = await firebaseStorage.update(
1328
+ p.data.collectibleConfig.image || firebaseStorage.collectibleImagePath(void 0, n.value),
1329
+ n.value
1330
+ ));
1331
+ },
1332
+ {
1333
+ message: "Uploading reward image",
1334
+ successMessage: "Reward image updated"
1335
+ }
1336
+ ), b("update:model-value", p.data, l.value));
1337
+ }
1338
+ return d({
1339
+ showSheet: g
1340
+ }), (p, c) => {
1341
+ const y = resolveComponent("FmSelect"), m = resolveComponent("FmStepperField"), f = resolveComponent("FmButton"), B = resolveComponent("FmSideSheet");
1342
+ return openBlock(), createBlock(B, {
1343
+ "max-width": 560,
1344
+ modelValue: unref(a),
1345
+ "onUpdate:modelValue": [
1346
+ c[9] || (c[9] = (C) => isRef(a) ? a.value = C : null),
1347
+ c[10] || (c[10] = (C) => a.value = C)
1348
+ ],
1349
+ header: "Edit reward",
1350
+ "dismiss-away": ""
1351
+ }, {
1352
+ "side-sheet-footer": withCtx(() => [
1353
+ createElementVNode("div", _hoisted_2$a, [
1354
+ createVNode(f, {
1355
+ variant: "primary",
1356
+ type: "button",
1357
+ disabled: unref(h).length > 0,
1358
+ label: "Confirm",
1359
+ onClick: c[7] || (c[7] = (C) => V())
1360
+ }, null, 8, ["disabled"]),
1361
+ createVNode(f, {
1362
+ variant: "secondary",
1363
+ type: "button",
1364
+ label: "Cancel",
1365
+ onClick: c[8] || (c[8] = (C) => a.value = !1)
1366
+ })
1367
+ ])
1368
+ ]),
1369
+ default: withCtx(() => {
1370
+ var C, E, $;
1371
+ return [
1372
+ unref(o) ? (openBlock(), createElementBlock("div", _hoisted_1$d, [
1373
+ createVNode(y, {
1374
+ label: "Reward Type",
1375
+ items: [
1376
+ { label: "No Reward", value: "NO_REWARD" },
1377
+ { label: "Voucher", value: "VOUCHER" },
1378
+ { label: "Loyalty", value: "LOYALTY" }
1379
+ ],
1380
+ "model-value": unref(o).type,
1381
+ "onUpdate:modelValue": c[0] || (c[0] = (x) => {
1382
+ x == "NO_REWARD" ? o.value = {
1383
+ type: "NO_REWARD",
1384
+ collectible: null,
1385
+ weight: 1
1386
+ } : x === "VOUCHER" ? o.value = {
1387
+ collectible: null,
1388
+ type: "VOUCHER",
1389
+ collectibleConfig: unref(initCollectibleConfig)("VOUCHER", {
1390
+ business: unref(useCoreStore)().currentBusiness.value._id
1391
+ }),
1392
+ earningOption: {
1393
+ amount: 1,
1394
+ type: "FIXED"
1395
+ },
1396
+ validityOption: {
1397
+ validForDay: 7
1398
+ },
1399
+ weight: 1
1400
+ } : o.value = {
1401
+ collectible: unref(i).loyaltyRewards.raw[0]._id,
1402
+ type: "LOYALTY",
1403
+ earningOption: {
1404
+ amount: 1,
1405
+ type: "FIXED"
1406
+ },
1407
+ validityOption: {
1408
+ validForDay: 7
1409
+ },
1410
+ weight: 1
1411
+ };
1412
+ })
1413
+ }, null, 8, ["model-value"]),
1414
+ unref(o).type == "LOYALTY" ? (openBlock(), createBlock(y, {
1415
+ key: 0,
1416
+ label: "Loyalty type",
1417
+ rules: [unref(ZodHelper).ruleAtPath(unref(s), "collectible", [unref(o).type])],
1418
+ items: unref(i).loyaltyRewards.items,
1419
+ "model-value": unref(o).collectible,
1420
+ "onUpdate:modelValue": c[1] || (c[1] = (x) => unref(o).collectible = x)
1421
+ }, null, 8, ["rules", "items", "model-value"])) : createCommentVNode("", !0),
1422
+ createVNode(m, {
1423
+ label: "Weight",
1424
+ rules: [unref(ZodHelper).ruleAtPath(unref(s), "weight", [unref(o).type])],
1425
+ "model-value": unref(o).weight,
1426
+ "onUpdate:modelValue": c[2] || (c[2] = (x) => o.value = {
1427
+ ...unref(o),
1428
+ weight: x
1429
+ })
1430
+ }, null, 8, ["rules", "model-value"]),
1431
+ unref(o).type === "LOYALTY" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
1432
+ ((C = unref(i).loyaltyRewards.items.find(
1433
+ (x) => {
1434
+ var S;
1435
+ return x.value === ((S = unref(o)) == null ? void 0 : S.collectible);
1436
+ }
1437
+ )) == null ? void 0 : C.raw.type) !== "TITLE" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
1438
+ c[11] || (c[11] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Earning option", -1)),
1439
+ createVNode(_sfc_main$r, {
1440
+ class: "mt-[-8px]",
1441
+ rules: [
1442
+ unref(ZodHelper).ruleAtPath(unref(s), "earningOption", [unref(o).type])
1443
+ ],
1444
+ "helper-state": unref(ZodHelper).helperState(unref(h), "earningOption"),
1445
+ "error-text": unref(ZodHelper).helperText(unref(h), "earningOption"),
1446
+ "fixed-type": !0,
1447
+ "model-value": unref(o).earningOption,
1448
+ "onUpdate:modelValue": c[3] || (c[3] = (x) => o.value = {
1449
+ ...unref(o),
1450
+ earningOption: x
1451
+ })
1452
+ }, null, 8, ["rules", "helper-state", "error-text", "model-value"])
1453
+ ], 64)) : createCommentVNode("", !0),
1454
+ c[12] || (c[12] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Validity option", -1)),
1455
+ createVNode(_sfc_main$s, {
1456
+ type: unref(o).type === "LOYALTY" ? "custom" : "range",
1457
+ "for-credit": unref(o).type === "LOYALTY" && ((E = unref(i).loyaltyRewards.items.find(
1458
+ (x) => {
1459
+ var S;
1460
+ return x.value === ((S = unref(o)) == null ? void 0 : S.collectible);
1461
+ }
1462
+ )) == null ? void 0 : E.raw.type) === "CREDIT",
1463
+ class: "!gap-24",
1464
+ rules: [unref(ZodHelper).ruleAtPath(unref(s), "validityOption", [unref(o).type])],
1465
+ "model-value": unref(o).validityOption,
1466
+ "onUpdate:modelValue": c[4] || (c[4] = (x) => o.value = {
1467
+ ...unref(o),
1468
+ validityOption: x
1469
+ })
1470
+ }, null, 8, ["type", "for-credit", "rules", "model-value"])
1471
+ ], 64)) : createCommentVNode("", !0),
1472
+ unref(o).type === "VOUCHER" ? (openBlock(), createBlock(_sfc_main$t, {
1473
+ key: 2,
1474
+ "reward-image": unref(n),
1475
+ "model-value": (($ = unref(o)) == null ? void 0 : $.collectibleConfig) ?? void 0,
1476
+ "onUpdate:modelValue": c[5] || (c[5] = (x) => o.value = {
1477
+ ...unref(o),
1478
+ collectibleConfig: x
1479
+ }),
1480
+ "onUpdate:rewardImage": c[6] || (c[6] = (x) => n.value = x)
1481
+ }, null, 8, ["reward-image", "model-value"])) : createCommentVNode("", !0),
1482
+ createVNode(JsonViewer, { json: unref(h) }, null, 8, ["json"])
1483
+ ])) : createCommentVNode("", !0)
1484
+ ];
1485
+ }),
1486
+ _: 1
1487
+ }, 8, ["modelValue"]);
1488
+ };
1489
+ }
1490
+ });
1491
+ function isNullOrEmpty(e) {
1492
+ return e == null || e === "";
1493
+ }
1494
+ const _hoisted_1$c = { class: "space-y-16" }, _hoisted_2$9 = { class: "fm-typo-en-body-lg-400" }, _hoisted_3$7 = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _sfc_main$c = /* @__PURE__ */ defineComponent({
1495
+ __name: "RewardPoolInput",
1496
+ props: {
1497
+ modelValue: {
1498
+ type: Array,
1499
+ default: () => [
1500
+ {
1501
+ collectible: null,
1502
+ type: "NO_REWARD",
1503
+ weight: 1
1504
+ }
1505
+ ]
1506
+ }
1507
+ },
1508
+ emits: ["update:model-value"],
1509
+ setup(e, { emit: d }) {
1510
+ const r = e, i = d, u = useMembershipStore(), a = z.array(z.lazy(() => FdtoRandomReward)).min(1, "Requires at least 1 reward"), o = computed(() => r.modelValue ?? []), n = computed(() => {
1511
+ const p = a.safeParse(o.value);
1512
+ return p.success ? [] : p.error.errors;
1513
+ }), l = ref();
1514
+ function s(p, c) {
1515
+ var m;
1516
+ const y = [...o.value];
1517
+ y[c] = p, (m = l.value) == null || m.showSheet(!1), i("update:model-value", y);
1518
+ }
1519
+ function h(p) {
1520
+ const c = p.type == "VOUCHER" ? p.collectibleConfig : u.collectibles.find(
1521
+ (f) => f._id.toString() == p.collectible
1522
+ ), y = CollectionUtils.formattedType((c == null ? void 0 : c.name) || ""), m = p.weight;
1523
+ return {
1524
+ label: isNullOrEmpty(y) ? "NO REWARD" : y,
1525
+ sublabel: `${m} (${(m / o.value.reduce((f, B) => f + B.weight, 0) * 100).toFixed(2)}%)`
1526
+ };
1527
+ }
1528
+ function g(p) {
1529
+ var y;
1530
+ const c = [...o.value];
1531
+ (y = l.value) == null || y.showSheet(!0, c[p], p);
1532
+ }
1533
+ function b(p) {
1534
+ const c = [...o.value];
1535
+ c.splice(p, 1), i("update:model-value", c);
1536
+ }
1537
+ function V() {
1538
+ var p;
1539
+ (p = l.value) == null || p.showSheet(
1540
+ !0,
1541
+ {
1542
+ type: "NO_REWARD",
1543
+ collectible: null,
1544
+ weight: 1
1545
+ },
1546
+ o.value.length
1547
+ );
1548
+ }
1549
+ return (p, c) => {
1550
+ const y = resolveComponent("FmButton"), m = resolveComponent("FmCard"), f = resolveComponent("FmHelperText");
1551
+ return openBlock(), createElementBlock("div", _hoisted_1$c, [
1552
+ c[1] || (c[1] = createElementVNode("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Configure the reward type and weightage given to your customer. ", -1)),
1553
+ createVNode(y, {
1554
+ label: "Add Reward",
1555
+ onClick: c[0] || (c[0] = (B) => V()),
1556
+ variant: "plain",
1557
+ icon: "add"
1558
+ }),
1559
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(o), (B, C) => (openBlock(), createBlock(m, {
1560
+ key: C,
1561
+ class: "px-16 py-12 flex items-center justify-between cursor-pointer",
1562
+ variant: "outlined",
1563
+ onClick: (E) => g(C)
1564
+ }, {
1565
+ default: withCtx(() => {
1566
+ var E;
1567
+ return [
1568
+ createElementVNode("div", null, [
1569
+ createElementVNode("div", _hoisted_2$9, toDisplayString(B.type == "LOYALTY" ? (E = B == null ? void 0 : B.earningOption) == null ? void 0 : E.amount : "") + " " + toDisplayString(h(B).label), 1),
1570
+ createElementVNode("div", _hoisted_3$7, toDisplayString(h(B).sublabel), 1)
1571
+ ]),
1572
+ createVNode(y, {
1573
+ icon: "delete",
1574
+ variant: "tertiary",
1575
+ onClick: ($) => ($.stopPropagation(), b(C))
1576
+ }, null, 8, ["onClick"])
1577
+ ];
1578
+ }),
1579
+ _: 2
1580
+ }, 1032, ["onClick"]))), 128)),
1581
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(n).filter((B) => B.path.join(".") == ""), (B) => (openBlock(), createBlock(f, {
1582
+ key: B.message,
1583
+ text: B.message,
1584
+ state: "error"
1585
+ }, null, 8, ["text"]))), 128)),
1586
+ createVNode(_sfc_main$d, {
1587
+ ref_key: "sheetRef",
1588
+ ref: l,
1589
+ "onUpdate:modelValue": s
1590
+ }, null, 512)
1591
+ ]);
1592
+ };
1593
+ }
1594
+ }), _hoisted_1$b = { class: "space-y-16" }, _hoisted_2$8 = {
1595
+ key: 0,
1596
+ class: "grid grid-cols-2 gap-16"
1597
+ }, _hoisted_3$6 = { class: "fm-typo-en-title-sm-800" }, _hoisted_4$5 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$b = /* @__PURE__ */ defineComponent({
1598
+ __name: "PromotionGameTypeInput",
1599
+ props: {
1600
+ modelValue: {
1601
+ type: Object
1602
+ }
1603
+ },
1604
+ emits: ["update:model-value"],
1605
+ setup(e, { emit: d }) {
1606
+ const r = e, i = d, u = computed(() => [
1607
+ {
1608
+ label: "Rock paper scissor",
1609
+ description: "Customers play 3 rounds of Rock Paper Scissors against the cashier. If customer won 2 rounds, they will get a discount.",
1610
+ value: F_GAME_TYPE.enum.ROCK_PAPER_SCISSORS
1611
+ }
1612
+ ]);
1613
+ return (a, o) => {
1614
+ var h, g, b;
1615
+ const n = resolveComponent("FmSwitch"), l = resolveComponent("FmCard"), s = resolveComponent("FmHelperText");
1616
+ return openBlock(), createElementBlock("div", _hoisted_1$b, [
1617
+ createVNode(n, {
1618
+ label: "Enable game",
1619
+ "model-value": !!((h = e.modelValue) != null && h.gameType),
1620
+ "onUpdate:modelValue": o[0] || (o[0] = (V) => V ? i("update:model-value", { gameType: "ROCK_PAPER_SCISSORS" }) : i("update:model-value", null))
1621
+ }, null, 8, ["model-value"]),
1622
+ ((g = e.modelValue) == null ? void 0 : g.gameType) == "ROCK_PAPER_SCISSORS" ? (openBlock(), createElementBlock("div", _hoisted_2$8, [
1623
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(u), (V) => {
1624
+ var p, c;
1625
+ return openBlock(), createBlock(l, {
1626
+ variant: "outlined",
1627
+ class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
1628
+ "col-span-2": unref(u).length == 1,
1629
+ "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": ((p = e.modelValue) == null ? void 0 : p.gameType) == V.value,
1630
+ "hover:bg-fm-color-opacity-sm": ((c = e.modelValue) == null ? void 0 : c.gameType) != V.value
1631
+ }]),
1632
+ onClick: () => {
1633
+ var y;
1634
+ ((y = r.modelValue) == null ? void 0 : y.gameType) != V.value && i("update:model-value", { gameType: V.value });
1635
+ },
1636
+ key: V.value
1637
+ }, {
1638
+ default: withCtx(() => [
1639
+ createElementVNode("div", _hoisted_3$6, toDisplayString(V.label), 1),
1640
+ createElementVNode("div", _hoisted_4$5, toDisplayString(V.description), 1)
1641
+ ]),
1642
+ _: 2
1643
+ }, 1032, ["class", "onClick"]);
1644
+ }), 128))
1645
+ ])) : createCommentVNode("", !0),
1646
+ ((b = e.modelValue) == null ? void 0 : b.gameType) == "ROCK_PAPER_SCISSORS" ? (openBlock(), createBlock(s, {
1647
+ key: 1,
1648
+ text: "Rock paper scissors is only available for POS >= 7.7.4 with dual screen on android devices (Sunmi D3 Pro and Sunmi T3 Pro)",
1649
+ state: "warning"
1650
+ })) : createCommentVNode("", !0)
1651
+ ]);
1652
+ };
1653
+ }
1654
+ }), _hoisted_1$a = { class: "space-y-8" }, _hoisted_2$7 = { class: "grid gap-16 grid-cols-2" }, _hoisted_3$5 = { class: "space-y-6" }, _hoisted_4$4 = { class: "space-y-8" }, _hoisted_5$3 = { class: "fm-typo-en-body-lg-600" }, _hoisted_6$3 = { class: "flex items-center space-x-3" }, _hoisted_7$2 = {
1655
+ key: 0,
1656
+ class: "ml-6 space-y-2"
1657
+ }, _sfc_main$a = /* @__PURE__ */ defineComponent({
1658
+ __name: "GrabConditionsInput",
1659
+ props: {
1660
+ modelValue: {
1661
+ type: Object
1662
+ },
1663
+ schema: {
1664
+ type: Object,
1665
+ default: () => z.any()
1666
+ }
1667
+ },
1668
+ emits: ["update:model-value"],
1669
+ setup(e, { emit: d }) {
1670
+ const { t: r } = useI18n(), i = e, u = d, a = ref(i.modelValue ?? {}), o = ref(
1671
+ (() => {
1672
+ const g = {};
1673
+ return a.value.workingHour && Object.keys(a.value.workingHour).forEach((b) => {
1674
+ const V = a.value.workingHour[b];
1675
+ V && "periods" in V && Array.isArray(V.periods) ? g[b] = V.periods : Array.isArray(V) && (g[b] = V);
1676
+ }), g;
1677
+ })()
1678
+ ), n = [
1679
+ { key: "mon", label: "Monday" },
1680
+ { key: "tue", label: "Tuesday" },
1681
+ { key: "wed", label: "Wednesday" },
1682
+ { key: "thu", label: "Thursday" },
1683
+ { key: "fri", label: "Friday" },
1684
+ { key: "sat", label: "Saturday" },
1685
+ { key: "sun", label: "Sunday" }
1686
+ ], l = (g) => {
1687
+ o.value[g] || (o.value[g] = []), o.value[g].push({
1688
+ startTime: "00:00",
1689
+ endTime: "23:59"
1690
+ }), h();
1691
+ }, s = (g, b) => {
1692
+ o.value[g] && o.value[g].length > b && (o.value[g].splice(b, 1), o.value[g].length === 0 && delete o.value[g], h());
1693
+ }, h = () => {
1694
+ const g = Object.keys(o.value).reduce(
1695
+ (b, V) => (o.value[V] && o.value[V].length > 0 && (b[V] = {
1696
+ periods: o.value[V]
1697
+ }), b),
1698
+ {}
1699
+ );
1700
+ a.value.workingHour = Object.keys(g).length > 0 ? g : void 0;
1701
+ };
1702
+ return watch(a, () => u("update:model-value", a.value), { deep: !0 }), watch(o, h, { deep: !0 }), (g, b) => {
1703
+ const V = resolveComponent("FmSelect"), p = resolveComponent("FmStepperField"), c = resolveComponent("FmCheckbox"), y = resolveComponent("FmTimePicker"), m = resolveComponent("FmButton");
1704
+ return openBlock(), createElementBlock("div", _hoisted_1$a, [
1705
+ createElementVNode("div", _hoisted_2$7, [
1706
+ createVNode(V, {
1707
+ label: unref(r)("connect.template.eaterType"),
1708
+ modelValue: unref(a).eaterType,
1709
+ "onUpdate:modelValue": b[0] || (b[0] = (f) => unref(a).eaterType = f),
1710
+ items: [
1711
+ { label: unref(r)("connect.template.allEaters"), value: "all" },
1712
+ { label: unref(r)("connect.template.newEatersOnly"), value: "new" },
1713
+ {
1714
+ label: unref(r)("connect.template.existingEatersOnly"),
1715
+ value: "existing"
1716
+ }
1717
+ ],
1718
+ rules: [unref(ZodHelper).ruleAtPath(e.schema, "eaterType")]
1719
+ }, null, 8, ["label", "modelValue", "items", "rules"]),
1720
+ createVNode(p, {
1721
+ modelValue: unref(a).minBasketAmount,
1722
+ "onUpdate:modelValue": b[1] || (b[1] = (f) => unref(a).minBasketAmount = f),
1723
+ "show-steppers": !1,
1724
+ rules: [unref(ZodHelper).ruleAtPath(e.schema, "minBasketAmount")]
1725
+ }, {
1726
+ label: withCtx(() => [
1727
+ (openBlock(), createBlock(resolveDynamicComponent(
1728
+ unref(ZodHelper).toInputLabel(
1729
+ unref(ZodHelper).typeAtPath(e.schema, "minBasketAmount"),
1730
+ unref(r)("connect.template.minBasketAmount")
1731
+ )
1732
+ )))
1733
+ ]),
1734
+ _: 1
1735
+ }, 8, ["modelValue", "rules"]),
1736
+ createVNode(p, {
1737
+ modelValue: unref(a).bundleQuantity,
1738
+ "onUpdate:modelValue": b[2] || (b[2] = (f) => unref(a).bundleQuantity = f),
1739
+ "show-steppers": !1,
1740
+ rules: [unref(ZodHelper).ruleAtPath(e.schema, "bundleQuantity")]
1741
+ }, {
1742
+ label: withCtx(() => [
1743
+ (openBlock(), createBlock(resolveDynamicComponent(
1744
+ unref(ZodHelper).toInputLabel(
1745
+ unref(ZodHelper).typeAtPath(e.schema, "bundleQuantity"),
1746
+ unref(r)("connect.template.bundleQuantity")
1747
+ )
1748
+ )))
1749
+ ]),
1750
+ _: 1
1751
+ }, 8, ["modelValue", "rules"])
1752
+ ]),
1753
+ createElementVNode("div", _hoisted_3$5, [
1754
+ createElementVNode("div", _hoisted_4$4, [
1755
+ createElementVNode("div", _hoisted_5$3, toDisplayString(unref(r)("connect.template.operationHours")), 1),
1756
+ (openBlock(), createElementBlock(Fragment, null, renderList(n, (f) => createElementVNode("div", {
1757
+ key: f.key,
1758
+ class: "space-y-2"
1759
+ }, [
1760
+ createElementVNode("div", _hoisted_6$3, [
1761
+ createVNode(c, {
1762
+ label: f.label,
1763
+ "model-value": !!(unref(o)[f.key] && unref(o)[f.key].length > 0),
1764
+ "onUpdate:modelValue": (B) => {
1765
+ B ? l(f.key) : (unref(o)[f.key] = [], delete unref(o)[f.key], h());
1766
+ }
1767
+ }, null, 8, ["label", "model-value", "onUpdate:modelValue"])
1768
+ ]),
1769
+ unref(o)[f.key] && unref(o)[f.key].length > 0 ? (openBlock(), createElementBlock("div", _hoisted_7$2, [
1770
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(o)[f.key] || [], (B, C) => (openBlock(), createElementBlock("div", {
1771
+ key: C,
1772
+ class: "flex items-center space-x-2 w-100"
1773
+ }, [
1774
+ createVNode(y, {
1775
+ "model-value": B.startTime || "",
1776
+ "onUpdate:modelValue": (E) => {
1777
+ unref(o)[f.key] && unref(o)[f.key][C] && (unref(o)[f.key][C].startTime = E || "", h());
1778
+ }
1779
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
1780
+ b[3] || (b[3] = createElementVNode("span", null, "to", -1)),
1781
+ createVNode(y, {
1782
+ "model-value": B.endTime || "",
1783
+ "onUpdate:modelValue": (E) => {
1784
+ unref(o)[f.key] && unref(o)[f.key][C] && (unref(o)[f.key][C].endTime = E || "", h());
1785
+ }
1786
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
1787
+ createVNode(m, {
1788
+ variant: "tertiary",
1789
+ size: "sm",
1790
+ onClick: (E) => s(f.key, C),
1791
+ icon: "close"
1792
+ }, null, 8, ["onClick"]),
1793
+ C === 0 ? (openBlock(), createBlock(m, {
1794
+ key: 0,
1795
+ onClick: (E) => l(f.key),
1796
+ icon: "add",
1797
+ variant: "plain"
1798
+ }, null, 8, ["onClick"])) : createCommentVNode("", !0)
1799
+ ]))), 128))
1800
+ ])) : createCommentVNode("", !0)
1801
+ ])), 64))
1802
+ ])
1803
+ ])
1804
+ ]);
1805
+ };
1806
+ }
1807
+ }), GrabConditionsInput = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-7f17ebe8"]]), _hoisted_1$9 = { class: "space-y-8" }, _hoisted_2$6 = { class: "grid gap-16 grid-cols-2" }, _sfc_main$9 = /* @__PURE__ */ defineComponent({
1808
+ __name: "GrabQuotaInput",
1809
+ props: {
1810
+ modelValue: {
1811
+ type: Object
1812
+ },
1813
+ schema: {
1814
+ type: Object,
1815
+ default: () => z.any()
1816
+ }
1817
+ },
1818
+ emits: ["update:model-value"],
1819
+ setup(e, { emit: d }) {
1820
+ const { t: r } = useI18n(), i = e, u = d, a = ref(i.modelValue ?? {});
1821
+ return watch(a, () => u("update:model-value", a.value)), (o, n) => {
1822
+ const l = resolveComponent("FmStepperField");
1823
+ return openBlock(), createElementBlock("div", _hoisted_1$9, [
1824
+ createElementVNode("div", _hoisted_2$6, [
1825
+ createVNode(l, {
1826
+ modelValue: unref(a).totalCount,
1827
+ "onUpdate:modelValue": n[0] || (n[0] = (s) => unref(a).totalCount = s),
1828
+ "show-steppers": !1,
1829
+ rules: [unref(ZodHelper).ruleAtPath(e.schema, "totalCount")]
1830
+ }, {
1831
+ label: withCtx(() => [
1832
+ (openBlock(), createBlock(resolveDynamicComponent(
1833
+ unref(ZodHelper).toInputLabel(
1834
+ unref(ZodHelper).typeAtPath(e.schema, "totalCount"),
1835
+ unref(r)("connect.template.totalCount")
1836
+ )
1837
+ )))
1838
+ ]),
1839
+ _: 1
1840
+ }, 8, ["modelValue", "rules"]),
1841
+ createVNode(l, {
1842
+ modelValue: unref(a).totalCountPerUser,
1843
+ "onUpdate:modelValue": n[1] || (n[1] = (s) => unref(a).totalCountPerUser = s),
1844
+ "show-steppers": !1,
1845
+ rules: [unref(ZodHelper).ruleAtPath(e.schema, "totalCountPerUser")]
1846
+ }, {
1847
+ label: withCtx(() => [
1848
+ (openBlock(), createBlock(resolveDynamicComponent(
1849
+ unref(ZodHelper).toInputLabel(
1850
+ unref(ZodHelper).typeAtPath(e.schema, "totalCountPerUser"),
1851
+ unref(r)("connect.template.totalCountPerUser")
1852
+ )
1853
+ )))
1854
+ ]),
1855
+ _: 1
1856
+ }, 8, ["modelValue", "rules"])
1857
+ ])
1858
+ ]);
1859
+ };
1860
+ }
1861
+ }), _hoisted_1$8 = { class: "space-y-16" }, _hoisted_2$5 = { class: "grid grid-cols-2 gap-16" }, _hoisted_3$4 = { class: "fm-typo-en-title-sm-800" }, _hoisted_4$3 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$8 = /* @__PURE__ */ defineComponent({
1862
+ __name: "MissionTypeInput",
1863
+ props: {
1864
+ modelValue: {
1865
+ type: String
1866
+ }
1867
+ },
1868
+ emits: ["update:model-value"],
1869
+ setup(e, { emit: d }) {
1870
+ const r = e, i = d, u = computed(() => [
1871
+ {
1872
+ label: "Stamp",
1873
+ description: "Award stamps for purchases, redeemable after reaching set milestones.",
1874
+ value: F_MISSION_TYPE.enum.STAMP
1875
+ },
1876
+ {
1877
+ label: "Progress",
1878
+ description: "Reward customers when they reach a cumulative spending goal.",
1879
+ value: F_MISSION_TYPE.enum.PROGRESSIVE
1880
+ }
1881
+ ]);
1882
+ return (a, o) => {
1883
+ const n = resolveComponent("FmCard");
1884
+ return openBlock(), createElementBlock("div", _hoisted_1$8, [
1885
+ o[0] || (o[0] = createElementVNode("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Select a game where you want your customer to play. ", -1)),
1886
+ createElementVNode("div", _hoisted_2$5, [
1887
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(u), (l) => (openBlock(), createBlock(n, {
1888
+ variant: "outlined",
1889
+ class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
1890
+ "col-span-2": unref(u).length == 1,
1891
+ "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": e.modelValue == l.value,
1892
+ "hover:bg-fm-color-opacity-sm": e.modelValue != l.value
1893
+ }]),
1894
+ onClick: () => {
1895
+ r.modelValue != l.value && i("update:model-value", l.value);
1896
+ },
1897
+ key: l.value
1898
+ }, {
1899
+ default: withCtx(() => [
1900
+ createElementVNode("div", _hoisted_3$4, toDisplayString(l.label), 1),
1901
+ createElementVNode("div", _hoisted_4$3, toDisplayString(l.description), 1)
1902
+ ]),
1903
+ _: 2
1904
+ }, 1032, ["class", "onClick"]))), 128))
1905
+ ])
1906
+ ]);
1907
+ };
1908
+ }
1909
+ }), _hoisted_1$7 = { class: "space-y-16" }, _sfc_main$7 = /* @__PURE__ */ defineComponent({
1910
+ __name: "MissionEndInput",
1911
+ props: {
1912
+ modelValue: {
1913
+ type: [String, Number]
1914
+ },
1915
+ helperText: {
1916
+ type: String
1917
+ },
1918
+ helperState: {
1919
+ type: String
1920
+ }
1921
+ },
1922
+ emits: ["update:model-value"],
1923
+ setup(e, { emit: d }) {
1924
+ const r = d;
1925
+ return (i, u) => {
1926
+ const a = resolveComponent("FmStepperField");
1927
+ return openBlock(), createElementBlock("div", _hoisted_1$7, [
1928
+ u[1] || (u[1] = createElementVNode("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Input the total number of stamps needed to complete the mission ", -1)),
1929
+ createVNode(a, {
1930
+ label: "Maximum to collect",
1931
+ "model-value": e.modelValue || null,
1932
+ "onUpdate:modelValue": u[0] || (u[0] = (o) => r("update:model-value", o)),
1933
+ "helper-text": e.helperText || "Set the threshold required for reward eligibility",
1934
+ "helper-state": e.helperState || "none"
1935
+ }, null, 8, ["model-value", "helper-text", "helper-state"])
1936
+ ]);
1937
+ };
1938
+ }
1939
+ }), _hoisted_1$6 = { class: "flex gap-8 items-center justify-start" }, _sfc_main$6 = /* @__PURE__ */ defineComponent({
1940
+ __name: "EditMissionPoolSheet",
1941
+ props: {
1942
+ maxThreshold: {
1943
+ type: Number,
1944
+ required: !0
1945
+ }
1946
+ },
1947
+ emits: ["update:model-value"],
1948
+ setup(e, { expose: d, emit: r }) {
1949
+ const i = e, u = useMembershipStore(), { minor: a } = useLoading, o = ref(!1), n = ref(), l = ref(), s = ref(0), h = computed(() => {
1950
+ var m;
1951
+ return ((m = u.loyaltyRewards.items.find(
1952
+ (f) => {
1953
+ var B;
1954
+ return f.value === ((B = n.value) == null ? void 0 : B.collectible);
1955
+ }
1956
+ )) == null ? void 0 : m.raw.type) === "CREDIT" ? FdoThresholdCreditReward : FdtoThresholdReward;
1957
+ }), g = computed(() => {
1958
+ const y = h.value.safeParse(n.value);
1959
+ return y.success ? [] : y.error.errors;
1960
+ });
1961
+ function b(y, m, f) {
1962
+ y && (n.value = m, s.value = f), o.value = y;
1963
+ }
1964
+ const V = r;
1965
+ async function p() {
1966
+ const y = h.value.safeParse(n.value);
1967
+ y.success && (await a(
1968
+ async () => {
1969
+ y.data.type === "VOUCHER" && l.value && (y.data.collectibleConfig.image = await firebaseStorage.update(
1970
+ y.data.collectibleConfig.image || firebaseStorage.collectibleImagePath(void 0, l.value),
1971
+ l.value
1972
+ ));
1973
+ },
1974
+ {
1975
+ message: "Uploading reward image",
1976
+ successMessage: "Reward image updated"
1977
+ }
1978
+ ), V("update:model-value", y.data, s.value));
1979
+ }
1980
+ const c = ref();
1981
+ return d({
1982
+ showSheet: b
1983
+ }), (y, m) => {
1984
+ const f = resolveComponent("FmStepperField"), B = resolveComponent("FmSelect"), C = resolveComponent("FmForm"), E = resolveComponent("FmButton"), $ = resolveComponent("FmSideSheet");
1985
+ return openBlock(), createBlock($, {
1986
+ "max-width": 560,
1987
+ modelValue: unref(o),
1988
+ "onUpdate:modelValue": [
1989
+ m[10] || (m[10] = (x) => isRef(o) ? o.value = x : null),
1990
+ m[11] || (m[11] = (x) => o.value = x)
1991
+ ],
1992
+ header: "Edit reward",
1993
+ "dismiss-away": ""
1994
+ }, {
1995
+ "side-sheet-footer": withCtx(() => [
1996
+ createElementVNode("div", _hoisted_1$6, [
1997
+ createVNode(E, {
1998
+ variant: "primary",
1999
+ type: "button",
2000
+ label: "Confirm",
2001
+ disabled: unref(g).length > 0,
2002
+ onClick: m[8] || (m[8] = async () => {
2003
+ var x;
2004
+ return (x = unref(c)) == null ? void 0 : x.validateInputs();
2005
+ })
2006
+ }, null, 8, ["disabled"]),
2007
+ createVNode(E, {
2008
+ variant: "secondary",
2009
+ type: "button",
2010
+ label: "Cancel",
2011
+ onClick: m[9] || (m[9] = (x) => o.value = !1)
2012
+ })
2013
+ ])
2014
+ ]),
2015
+ default: withCtx(() => [
2016
+ createVNode(JsonViewer, { json: unref(n) }, null, 8, ["json"]),
2017
+ unref(n) ? (openBlock(), createBlock(C, {
2018
+ key: 0,
2019
+ class: "flex flex-col gap-y-24",
2020
+ ref_key: "formRef",
2021
+ ref: c,
2022
+ onValidationSuccess: m[7] || (m[7] = (x) => p())
2023
+ }, {
2024
+ default: withCtx(() => {
2025
+ var x, S;
2026
+ return [
2027
+ unref(n).type ? (openBlock(), createBlock(f, {
2028
+ key: 0,
2029
+ label: "Threshold",
2030
+ rules: [
2031
+ unref(ZodHelper).toRule(
2032
+ unref(z).number().min(1).max(
2033
+ i.maxThreshold,
2034
+ `Number cannot be more than ${i.maxThreshold}`
2035
+ )
2036
+ )
2037
+ ],
2038
+ "model-value": unref(n).threshold,
2039
+ "onUpdate:modelValue": m[0] || (m[0] = (N) => n.value = {
2040
+ ...unref(n),
2041
+ threshold: N
2042
+ })
2043
+ }, null, 8, ["rules", "model-value"])) : createCommentVNode("", !0),
2044
+ createVNode(B, {
2045
+ label: "Reward Type",
2046
+ items: [
2047
+ { label: "Voucher", value: "VOUCHER" },
2048
+ { label: "Loyalty", value: "LOYALTY" }
2049
+ ],
2050
+ "model-value": unref(n).type,
2051
+ "onUpdate:modelValue": m[1] || (m[1] = (N) => {
2052
+ var I, M;
2053
+ N === "VOUCHER" ? n.value = {
2054
+ collectible: null,
2055
+ type: "VOUCHER",
2056
+ collectibleConfig: unref(initCollectibleConfig)("VOUCHER", {
2057
+ business: unref(useCoreStore)().currentBusiness.value._id
2058
+ }),
2059
+ earningOption: {
2060
+ amount: 1,
2061
+ type: "FIXED"
2062
+ },
2063
+ validityOption: {
2064
+ validForDay: 7
2065
+ },
2066
+ threshold: (I = unref(n)) == null ? void 0 : I.threshold
2067
+ } : n.value = {
2068
+ collectible: unref(u).loyaltyRewards.raw[0]._id,
2069
+ type: "LOYALTY",
2070
+ earningOption: {
2071
+ amount: 1,
2072
+ type: "FIXED"
2073
+ },
2074
+ validityOption: {
2075
+ validForDay: 7
2076
+ },
2077
+ threshold: (M = unref(n)) == null ? void 0 : M.threshold
2078
+ };
2079
+ })
2080
+ }, null, 8, ["model-value"]),
2081
+ unref(n).type == "LOYALTY" ? (openBlock(), createBlock(B, {
2082
+ key: 1,
2083
+ label: "Loyalty type",
2084
+ rules: [unref(ZodHelper).ruleAtPath(unref(h), "collectible", [unref(n).type])],
2085
+ items: unref(u).loyaltyRewards.items,
2086
+ "model-value": unref(n).collectible,
2087
+ "onUpdate:modelValue": m[2] || (m[2] = (N) => unref(n).collectible = N)
2088
+ }, null, 8, ["rules", "items", "model-value"])) : createCommentVNode("", !0),
2089
+ unref(n).type === "LOYALTY" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
2090
+ m[12] || (m[12] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Earning option", -1)),
2091
+ createVNode(_sfc_main$r, {
2092
+ class: "mt-[-8px]",
2093
+ rules: [unref(ZodHelper).ruleAtPath(unref(h), "earningOption", [unref(n).type])],
2094
+ "helper-state": unref(ZodHelper).helperState(unref(g), "earningOption"),
2095
+ "error-text": unref(ZodHelper).helperText(unref(g), "earningOption"),
2096
+ "fixed-type": !0,
2097
+ "model-value": unref(n).earningOption,
2098
+ "onUpdate:modelValue": m[3] || (m[3] = (N) => n.value = {
2099
+ ...unref(n),
2100
+ earningOption: N
2101
+ })
2102
+ }, null, 8, ["rules", "helper-state", "error-text", "model-value"]),
2103
+ createVNode(_sfc_main$s, {
2104
+ class: "!gap-24",
2105
+ type: unref(n).type === "LOYALTY" ? "custom" : "range",
2106
+ "for-credit": unref(n).type === "LOYALTY" && ((x = unref(u).loyaltyRewards.items.find(
2107
+ (N) => {
2108
+ var I;
2109
+ return N.value === ((I = unref(n)) == null ? void 0 : I.collectible);
2110
+ }
2111
+ )) == null ? void 0 : x.raw.type) === "CREDIT",
2112
+ rules: [unref(ZodHelper).ruleAtPath(unref(h), "validityOption", [unref(n).type])],
2113
+ "model-value": unref(n).validityOption,
2114
+ "onUpdate:modelValue": m[4] || (m[4] = (N) => n.value = {
2115
+ ...unref(n),
2116
+ validityOption: N
2117
+ })
2118
+ }, null, 8, ["type", "for-credit", "rules", "model-value"])
2119
+ ], 64)) : createCommentVNode("", !0),
2120
+ unref(n).type === "VOUCHER" ? (openBlock(), createBlock(_sfc_main$t, {
2121
+ key: 3,
2122
+ "reward-image": unref(l),
2123
+ "model-value": ((S = unref(n)) == null ? void 0 : S.collectibleConfig) ?? void 0,
2124
+ "onUpdate:modelValue": m[5] || (m[5] = (N) => n.value = {
2125
+ ...unref(n),
2126
+ collectibleConfig: N
2127
+ }),
2128
+ "onUpdate:rewardImage": m[6] || (m[6] = (N) => l.value = N)
2129
+ }, null, 8, ["reward-image", "model-value"])) : createCommentVNode("", !0),
2130
+ createVNode(JsonViewer, { json: unref(g) }, null, 8, ["json"])
2131
+ ];
2132
+ }),
2133
+ _: 1
2134
+ }, 512)) : createCommentVNode("", !0)
2135
+ ]),
2136
+ _: 1
2137
+ }, 8, ["modelValue"]);
2138
+ };
2139
+ }
2140
+ }), _hoisted_1$5 = {
2141
+ key: 0,
2142
+ class: "grid grid-cols-5 text-center gap-8 justify-between items-center w-full"
2143
+ }, _hoisted_2$4 = { class: "flex flex-col gap-0 items-center justify-center" }, _sfc_main$5 = /* @__PURE__ */ defineComponent({
2144
+ __name: "MissionProgress",
2145
+ props: {
2146
+ type: {
2147
+ type: String,
2148
+ required: !0
2149
+ },
2150
+ maxRange: {
2151
+ type: Number,
2152
+ required: !0
2153
+ },
2154
+ currentRange: {
2155
+ type: Number,
2156
+ default: 0
2157
+ },
2158
+ markers: {
2159
+ type: Array,
2160
+ default: () => []
2161
+ }
2162
+ },
2163
+ setup(e) {
2164
+ const d = e, { maxRange: r, currentRange: i, markers: u } = toRefs(d), a = computed(
2165
+ () => Math.min(i.value / r.value * 100, 100)
2166
+ ), o = (n) => n / r.value * 100;
2167
+ return (n, l) => {
2168
+ const s = resolveComponent("FmIcon");
2169
+ return e.type === "STAMP" ? (openBlock(), createElementBlock("div", _hoisted_1$5, [
2170
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(Math.min(unref(r), 40), (h) => (openBlock(), createBlock(s, {
2171
+ class: normalizeClass(
2172
+ unref(i) >= h ? "text-fm-color-primary" : "text-fm-color-neutral-gray-200"
2173
+ ),
2174
+ outline: unref(i) < h,
2175
+ key: h,
2176
+ name: unref(u).some((g) => g === h) ? "featured_seasonal_and_gifts" : "check_circle"
2177
+ }, null, 8, ["class", "outline", "name"]))), 128))
2178
+ ])) : (openBlock(), createElementBlock("div", {
2179
+ key: 1,
2180
+ class: normalizeClass(["relative w-full h-4 rounded-lg", "bg-fm-color-system-warning-100"])
2181
+ }, [
2182
+ createElementVNode("div", {
2183
+ class: normalizeClass(["bg-fm-color-primary", "absolute top-0 left-0 h-full rounded-lg"]),
2184
+ style: normalizeStyle({ width: unref(a) + "%" })
2185
+ }, null, 4),
2186
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(u), (h, g) => (openBlock(), createElementBlock("div", {
2187
+ key: g,
2188
+ class: "absolute -top-1.5 flex flex-col items-center -translate-x-1/2",
2189
+ style: normalizeStyle({ left: o(h) + "%" })
2190
+ }, [
2191
+ createElementVNode("div", _hoisted_2$4, [
2192
+ createElementVNode("div", {
2193
+ class: normalizeClass(["h-16 w-[2px]", "bg-fm-color-system-warning-300"])
2194
+ }),
2195
+ l[0] || (l[0] = createElementVNode("div", null, "🎁", -1))
2196
+ ])
2197
+ ], 4))), 128))
2198
+ ]));
2199
+ };
2200
+ }
2201
+ }), isObject = (e) => e !== null && typeof e == "object";
2202
+ function changeKeysFactory(e) {
2203
+ return function d(r, i = 1, u) {
2204
+ if (i === 0 || !isObject(r))
2205
+ return r;
2206
+ if (Array.isArray(r))
2207
+ return r.map((o) => d(o, i - 1, u));
2208
+ const a = Object.create(Object.getPrototypeOf(r));
2209
+ return Object.keys(r).forEach((o) => {
2210
+ const n = r[o], l = e(o, u), s = d(n, i - 1, u);
2211
+ a[l] = s;
2212
+ }), a;
2213
+ };
2214
+ }
2215
+ const sentenceCase = changeKeysFactory(sentenceCase$1), _hoisted_1$4 = { class: "space-y-16" }, _hoisted_2$3 = { class: "fm-typo-en-body-lg-400" }, _hoisted_3$3 = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _hoisted_4$2 = { class: "flex items-center gap-4" }, _hoisted_5$2 = { class: "fm-typo-en-body-lg-600" }, _hoisted_6$2 = { class: "flex items-center gap-16" }, _hoisted_7$1 = { key: 0 }, _sfc_main$4 = /* @__PURE__ */ defineComponent({
2216
+ __name: "MissionPoolInput",
2217
+ props: {
2218
+ modelValue: {
2219
+ type: Array,
2220
+ default: () => []
2221
+ },
2222
+ mission: {
2223
+ type: Object,
2224
+ required: !0
2225
+ }
2226
+ },
2227
+ emits: ["update:model-value"],
2228
+ setup(e, { emit: d }) {
2229
+ const r = e, i = d, u = useMembershipStore(), a = z.array(z.lazy(() => FdtoThresholdReward)).min(1, "Requires at least 1 reward"), o = computed(
2230
+ () => r.modelValue.sort((c, y) => c.threshold - y.threshold) ?? []
2231
+ ), n = computed(() => {
2232
+ const c = a.safeParse(o.value);
2233
+ return c.success ? [] : c.error.errors;
2234
+ }), l = ref();
2235
+ function s(c, y) {
2236
+ var f;
2237
+ const m = [...o.value];
2238
+ m[y] = c, (f = l.value) == null || f.showSheet(!1), i("update:model-value", m);
2239
+ }
2240
+ function h(c) {
2241
+ const y = c.type == "VOUCHER" ? c.collectibleConfig : u.collectibles.find(
2242
+ (f) => f._id.toString() == c.collectible
2243
+ ), m = CollectionUtils.formattedType((y == null ? void 0 : y.name) || "");
2244
+ return {
2245
+ label: isNullOrEmpty(m) ? "NO REWARD" : m,
2246
+ sublabel: `Reward at ${c.threshold} | Amount: ${c.earningOption.type == "FIXED" ? c.earningOption.amount : `${c.earningOption.amount} for every RM${c.earningOption.every} spent`} `
2247
+ };
2248
+ }
2249
+ function g(c) {
2250
+ var m;
2251
+ const y = [...o.value];
2252
+ (m = l.value) == null || m.showSheet(!0, y[c], c);
2253
+ }
2254
+ function b(c) {
2255
+ const y = [...o.value];
2256
+ y.splice(c, 1), i("update:model-value", y);
2257
+ }
2258
+ function V() {
2259
+ var c;
2260
+ (c = l.value) == null || c.showSheet(
2261
+ !0,
2262
+ {
2263
+ type: "LOYALTY",
2264
+ collectible: u.loyaltyRewards.items[0].value,
2265
+ threshold: null,
2266
+ validityOption: {
2267
+ validForDay: 7
2268
+ },
2269
+ earningOption: {
2270
+ type: "FIXED",
2271
+ amount: 1
2272
+ }
2273
+ },
2274
+ o.value.length
2275
+ );
2276
+ }
2277
+ function p(c) {
2278
+ var y, m;
2279
+ return c.type == "VOUCHER" ? (y = c.collectibleConfig) == null ? void 0 : y.name : sentenceCase(
2280
+ ((m = u.loyaltyRewards.items.find(
2281
+ (f) => f.value == c.collectible
2282
+ )) == null ? void 0 : m.label) || ""
2283
+ );
2284
+ }
2285
+ return (c, y) => {
2286
+ const m = resolveComponent("FmButton"), f = resolveComponent("FmCard"), B = resolveComponent("FmHelperText");
2287
+ return openBlock(), createElementBlock("div", _hoisted_1$4, [
2288
+ y[2] || (y[2] = createElementVNode("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Configure the reward type given to your customer. ", -1)),
2289
+ createVNode(m, {
2290
+ label: "Add Reward",
2291
+ onClick: y[0] || (y[0] = (C) => V()),
2292
+ variant: "plain",
2293
+ icon: "add"
2294
+ }),
2295
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(o), (C, E) => (openBlock(), createBlock(f, {
2296
+ key: E,
2297
+ class: "px-16 py-12 flex items-center justify-between cursor-pointer",
2298
+ variant: "outlined",
2299
+ onClick: ($) => g(E)
2300
+ }, {
2301
+ default: withCtx(() => [
2302
+ createElementVNode("div", null, [
2303
+ createElementVNode("div", _hoisted_2$3, toDisplayString(h(C).label), 1),
2304
+ createElementVNode("div", _hoisted_3$3, toDisplayString(h(C).sublabel), 1)
2305
+ ]),
2306
+ createVNode(m, {
2307
+ icon: "delete",
2308
+ variant: "tertiary",
2309
+ onClick: ($) => ($.stopPropagation(), b(E))
2310
+ }, null, 8, ["onClick"])
2311
+ ]),
2312
+ _: 2
2313
+ }, 1032, ["onClick"]))), 128)),
2314
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(n).filter((C) => C.path.join(".") == ""), (C) => (openBlock(), createBlock(B, {
2315
+ key: C.message,
2316
+ text: C.message,
2317
+ state: "error"
2318
+ }, null, 8, ["text"]))), 128)),
2319
+ y[3] || (y[3] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Mission Preview", -1)),
2320
+ (openBlock(), createBlock(f, {
2321
+ key: 0,
2322
+ variant: "outlined",
2323
+ class: "p-24 space-y-16 w-fit"
2324
+ }, {
2325
+ default: withCtx(() => {
2326
+ var C, E;
2327
+ return [
2328
+ createElementVNode("div", _hoisted_4$2, [
2329
+ createElementVNode("div", null, [
2330
+ createElementVNode("div", _hoisted_5$2, " Collect " + toDisplayString(e.mission.end) + " stamps to get " + toDisplayString(((C = e.modelValue[e.modelValue.length - 1]) == null ? void 0 : C.earningOption.amount) > 1 ? (E = e.modelValue[e.modelValue.length - 1]) == null ? void 0 : E.earningOption.amount : "") + " " + toDisplayString(e.modelValue[e.modelValue.length - 1] ? p(e.modelValue[e.modelValue.length - 1]) : ""), 1),
2331
+ y[1] || (y[1] = createElementVNode("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Earn a stamp! ", -1))
2332
+ ])
2333
+ ]),
2334
+ createElementVNode("div", _hoisted_6$2, [
2335
+ createVNode(_sfc_main$5, {
2336
+ type: e.mission.type,
2337
+ "max-range": e.mission.end,
2338
+ currentRange: e.mission.end / 4,
2339
+ markers: e.modelValue.map(($) => $.threshold)
2340
+ }, null, 8, ["type", "max-range", "currentRange", "markers"]),
2341
+ e.mission.type == "PROGRESSIVE" ? (openBlock(), createElementBlock("div", _hoisted_7$1, " 0/" + toDisplayString(e.mission.end.toLocaleString()), 1)) : createCommentVNode("", !0)
2342
+ ])
2343
+ ];
2344
+ }),
2345
+ _: 1
2346
+ })),
2347
+ createVNode(_sfc_main$6, {
2348
+ ref_key: "sheetRef",
2349
+ ref: l,
2350
+ "onUpdate:modelValue": s,
2351
+ "max-threshold": e.mission.end
2352
+ }, null, 8, ["max-threshold"])
2353
+ ]);
2354
+ };
2355
+ }
2356
+ }), _hoisted_1$3 = { class: "space-y-16" }, _hoisted_2$2 = { class: "space-y-8" }, _hoisted_3$2 = { class: "grid grid-cols-2 gap-16" }, _hoisted_4$1 = { class: "fm-typo-en-title-sm-800" }, _hoisted_5$1 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_6$1 = { class: "space-y-8" }, _sfc_main$3 = /* @__PURE__ */ defineComponent({
2357
+ __name: "MissionInput",
2358
+ props: {
2359
+ modelValue: Object
2360
+ },
2361
+ emits: ["update:model-value"],
2362
+ setup(e, { emit: d }) {
2363
+ const r = e, i = computed(() => {
2364
+ const o = FdoMission.safeParse(r.modelValue);
2365
+ return o.success ? [] : o.error.errors;
2366
+ }), u = computed(() => [
2367
+ {
2368
+ label: "Stamp",
2369
+ description: "Award stamps for purchases, redeemable after reaching set milestones.",
2370
+ value: F_MISSION_TYPE.enum.STAMP
2371
+ },
2372
+ {
2373
+ label: "Progress",
2374
+ description: "Reward customers when they reach a cumulative spending goal.",
2375
+ value: F_MISSION_TYPE.enum.PROGRESSIVE
2376
+ }
2377
+ ]), a = d;
2378
+ return (o, n) => {
2379
+ var h;
2380
+ const l = resolveComponent("FmCard"), s = resolveComponent("FmStepperField");
2381
+ return openBlock(), createElementBlock("div", _hoisted_1$3, [
2382
+ createElementVNode("div", _hoisted_2$2, [
2383
+ n[1] || (n[1] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Mission Type", -1)),
2384
+ n[2] || (n[2] = createElementVNode("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Select a game where you want your customer to play. ", -1)),
2385
+ createElementVNode("div", _hoisted_3$2, [
2386
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(u), (g) => {
2387
+ var b, V;
2388
+ return openBlock(), createBlock(l, {
2389
+ variant: "outlined",
2390
+ class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
2391
+ "col-span-2": unref(u).length == 1,
2392
+ "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": ((b = e.modelValue) == null ? void 0 : b.type) == g.value,
2393
+ "hover:bg-fm-color-opacity-sm": ((V = e.modelValue) == null ? void 0 : V.type) != g.value
2394
+ }]),
2395
+ onClick: () => {
2396
+ var p, c;
2397
+ ((p = e.modelValue) == null ? void 0 : p.type) != g.value && a("update:model-value", {
2398
+ ...e.modelValue,
2399
+ type: g.value,
2400
+ end: ((c = e.modelValue) == null ? void 0 : c.end) || 1
2401
+ });
2402
+ },
2403
+ key: g.value
2404
+ }, {
2405
+ default: withCtx(() => [
2406
+ createElementVNode("div", _hoisted_4$1, toDisplayString(g.label), 1),
2407
+ createElementVNode("div", _hoisted_5$1, toDisplayString(g.description), 1)
2408
+ ]),
2409
+ _: 2
2410
+ }, 1032, ["class", "onClick"]);
2411
+ }), 128))
2412
+ ])
2413
+ ]),
2414
+ createElementVNode("div", _hoisted_6$1, [
2415
+ n[3] || (n[3] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Collections required", -1)),
2416
+ n[4] || (n[4] = 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)),
2417
+ createVNode(s, {
2418
+ label: "Maximum to collect",
2419
+ "model-value": ((h = e.modelValue) == null ? void 0 : h.end) || null,
2420
+ "onUpdate:modelValue": n[0] || (n[0] = (g) => {
2421
+ var b;
2422
+ return a("update:model-value", {
2423
+ ...e.modelValue,
2424
+ type: ((b = e.modelValue) == null ? void 0 : b.type) || "STAMP",
2425
+ end: g
2426
+ });
2427
+ }),
2428
+ "helper-text": unref(ZodHelper).helperText(unref(i), "end") || "Set the threshold required for reward eligibility",
2429
+ "helper-state": unref(ZodHelper).helperState(unref(i), "end") || "none"
2430
+ }, null, 8, ["model-value", "helper-text", "helper-state"])
2431
+ ])
2432
+ ]);
2433
+ };
2434
+ }
2435
+ }), _hoisted_1$2 = { key: 29 }, _sfc_main$2 = /* @__PURE__ */ defineComponent({
2436
+ __name: "TemplateInput",
2437
+ props: {
2438
+ field: { type: Object, required: !0 },
2439
+ modelValue: {
2440
+ type: Object
2441
+ },
2442
+ schema: {
2443
+ type: Object
2444
+ },
2445
+ extras: {
2446
+ type: Object
2447
+ },
2448
+ helperText: {
2449
+ type: String
2450
+ },
2451
+ disabled: {
2452
+ type: Boolean,
2453
+ default: !1
2454
+ },
2455
+ campaignType: {
2456
+ type: String,
2457
+ default: void 0
2458
+ }
2459
+ },
2460
+ emits: ["update:model-value", "update:file"],
2461
+ setup(e, { emit: d }) {
2462
+ const { t: r } = useI18n(), i = e, u = d;
2463
+ function a(s) {
2464
+ switch (i.field.type) {
2465
+ case "timeframe":
2466
+ const h = s.startDate ? hooks(s.startDate).startOf("day").toISOString() : void 0, g = s.endDate ? hooks(s.endDate).endOf("day").toISOString() : void 0;
2467
+ u("update:model-value", {
2468
+ type: "timeframe",
2469
+ property: "__now",
2470
+ start: h,
2471
+ end: g
2472
+ });
2473
+ break;
2474
+ case "image": {
2475
+ u(
2476
+ "update:file",
2477
+ s,
2478
+ o.value || firebaseStorage.collectibleImagePath(void 0, s)
2479
+ );
2480
+ break;
2481
+ }
2482
+ default:
2483
+ u("update:model-value", s);
2484
+ break;
2485
+ }
2486
+ }
2487
+ const o = computed(() => {
2488
+ switch (i.field.type) {
2489
+ case "timeframe": {
2490
+ const s = i.modelValue;
2491
+ return {
2492
+ startDate: s != null && s.start ? hooks(s == null ? void 0 : s.start).format("YYYY-MM-DD") : null,
2493
+ endDate: s != null && s.end ? hooks(s == null ? void 0 : s.end).format("YYYY-MM-DD") : null
2494
+ };
2495
+ }
2496
+ default:
2497
+ return i.modelValue;
2498
+ }
2499
+ });
2500
+ function n() {
2501
+ if (!l.value.schema) return [];
2502
+ const s = l.value.schema.safeParse(i.modelValue);
2503
+ return s.success ? [] : s.error.errors;
2504
+ }
2505
+ const l = computed(() => ({
2506
+ schema: i.schema,
2507
+ unwrapped: i.schema ? ZodHelper.unwrap(i.schema) : void 0,
2508
+ rules: i.schema ? [ZodHelper.ruleAtPath(i.schema, "")] : void 0,
2509
+ labelMark: i.schema && ZodHelper.isRequired(i.schema) == !1 ? "optional" : void 0,
2510
+ zodLabel: i.schema ? ZodHelper.toInputLabel(i.schema, i.field.label) : void 0
2511
+ }));
2512
+ return (s, h) => {
2513
+ var y, m, f, B, C;
2514
+ const g = resolveComponent("FmTextField"), b = resolveComponent("FmStepperField"), V = resolveComponent("FmTextarea"), p = resolveComponent("FmHelperText"), c = resolveComponent("FmSwitch");
2515
+ return e.field.type === "text" ? (openBlock(), createBlock(g, {
2516
+ key: 0,
2517
+ label: unref(r)(e.field.label),
2518
+ "label-mark": unref(l).labelMark,
2519
+ rules: unref(l).rules,
2520
+ "model-value": unref(o),
2521
+ "onUpdate:modelValue": a,
2522
+ "helper-state": e.helperText ? "error" : void 0,
2523
+ "helper-text": e.helperText
2524
+ }, null, 8, ["label", "label-mark", "rules", "model-value", "helper-state", "helper-text"])) : e.field.type === "number" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
2525
+ createVNode(JsonViewer, {
2526
+ json: { schema: unref(l).unwrapped, props: i }
2527
+ }, null, 8, ["json"]),
2528
+ createVNode(b, {
2529
+ label: unref(r)(e.field.label),
2530
+ "label-mark": e.field.isRuleChildren ? void 0 : unref(l).labelMark,
2531
+ "model-value": unref(o),
2532
+ rules: e.field.isRuleChildren ? [] : unref(l).rules,
2533
+ "onUpdate:modelValue": a,
2534
+ "helper-state": e.field.isRuleChildren && e.helperText ? "error" : void 0,
2535
+ "helper-text": e.field.isRuleChildren ? e.helperText : void 0
2536
+ }, null, 8, ["label", "label-mark", "model-value", "rules", "helper-state", "helper-text"])
2537
+ ], 64)) : e.field.type === "textarea" ? (openBlock(), createBlock(V, {
2538
+ key: 2,
2539
+ label: unref(r)(e.field.label),
2540
+ "label-mark": unref(l).labelMark,
2541
+ rules: unref(l).rules,
2542
+ "model-value": unref(o),
2543
+ "onUpdate:modelValue": a,
2544
+ "show-word-count": "",
2545
+ "max-length": (C = (B = (f = (m = (y = unref(l)) == null ? void 0 : y.unwrapped) == null ? void 0 : m._def) == null ? void 0 : f.checks) == null ? void 0 : B.find((E) => E.kind == "max")) == null ? void 0 : C.value
2546
+ }, null, 8, ["label", "label-mark", "rules", "model-value", "max-length"])) : e.field.type === "trigger" ? (openBlock(), createBlock(_sfc_main$i, {
2547
+ key: 3,
2548
+ "campaign-type": e.extras,
2549
+ "model-value": unref(o),
2550
+ disabled: e.disabled,
2551
+ "onUpdate:modelValue": a
2552
+ }, null, 8, ["campaign-type", "model-value", "disabled"])) : e.field.type === "timeframe" ? (openBlock(), createElementBlock(Fragment, { key: 4 }, [
2553
+ createVNode(_sfc_main$g, {
2554
+ "model-value": unref(o),
2555
+ "onUpdate:modelValue": a
2556
+ }, null, 8, ["model-value"]),
2557
+ createVNode(p, {
2558
+ class: "!mt-[8px]",
2559
+ text: unref(ZodHelper).helperText(n(), ""),
2560
+ state: unref(ZodHelper).helperState(n(), "")
2561
+ }, null, 8, ["text", "state"])
2562
+ ], 64)) : e.field.type === "image" ? (openBlock(), createBlock(_sfc_main$u, {
2563
+ key: 5,
2564
+ thumbnail: unref(o),
2565
+ "aspect-ratio": "16 / 9",
2566
+ class: "w-1/2 xs:w-2/3",
2567
+ "onUpdate:file": a
2568
+ }, {
2569
+ label: withCtx(() => [
2570
+ (openBlock(), createBlock(resolveDynamicComponent(unref(l).zodLabel)))
2571
+ ]),
2572
+ _: 1
2573
+ }, 8, ["thumbnail"])) : e.field.type === "switch" ? (openBlock(), createBlock(c, {
2574
+ key: 6,
2575
+ label: unref(r)(e.field.label),
2576
+ "label-placement": "right",
2577
+ sublabel: e.field.property == "campaign.notify" ? "Notify customer when customer receives the reward" : void 0,
2578
+ "label-mark": unref(l).labelMark,
2579
+ rules: unref(l).rules,
2580
+ "model-value": unref(o),
2581
+ "onUpdate:modelValue": a
2582
+ }, null, 8, ["label", "sublabel", "label-mark", "rules", "model-value"])) : e.field.type === "collectible_options" ? (openBlock(), createBlock(_sfc_main$v, {
2583
+ key: 7,
2584
+ "model-value": unref(o),
2585
+ "onUpdate:modelValue": a,
2586
+ "no-campaign": !1,
2587
+ schema: unref(l).schema,
2588
+ "is-mission": e.extras === "MISSION"
2589
+ }, null, 8, ["model-value", "schema", "is-mission"])) : e.field.type === "grab_conditions" ? (openBlock(), createBlock(GrabConditionsInput, {
2590
+ key: 8,
2591
+ "model-value": unref(o),
2592
+ "onUpdate:modelValue": a,
2593
+ schema: unref(l).schema
2594
+ }, null, 8, ["model-value", "schema"])) : e.field.type === "grab_quota" ? (openBlock(), createBlock(_sfc_main$9, {
2595
+ key: 9,
2596
+ "model-value": unref(o),
2597
+ "onUpdate:modelValue": a,
2598
+ schema: unref(l).schema
2599
+ }, null, 8, ["model-value", "schema"])) : e.field.type === "target_location" ? (openBlock(), createBlock(_sfc_main$w, {
2600
+ key: 10,
2601
+ "model-value": unref(o),
2602
+ "onUpdate:modelValue": a
2603
+ }, null, 8, ["model-value"])) : e.field.type == "effect" ? (openBlock(), createElementBlock(Fragment, { key: 11 }, [
2604
+ createVNode(_sfc_main$x, {
2605
+ "model-value": unref(o),
2606
+ "onUpdate:modelValue": a,
2607
+ "can-set-auto-apply": e.field.property == "campaign.effect"
2608
+ }, null, 8, ["model-value", "can-set-auto-apply"]),
2609
+ unref(o) ? createCommentVNode("", !0) : (openBlock(), createBlock(p, {
2610
+ key: 0,
2611
+ class: "!mt-[8px]",
2612
+ text: unref(r)("connect.campaign.common.effect_required"),
2613
+ state: "error"
2614
+ }, null, 8, ["text"]))
2615
+ ], 64)) : e.field.type == "grab_effect" ? (openBlock(), createElementBlock(Fragment, { key: 12 }, [
2616
+ createVNode(GrabEffectSheet, {
2617
+ "model-value": unref(o),
2618
+ "onUpdate:modelValue": a
2619
+ }, null, 8, ["model-value"]),
2620
+ unref(o) ? createCommentVNode("", !0) : (openBlock(), createBlock(p, {
2621
+ key: 0,
2622
+ class: "!mt-[8px]",
2623
+ text: unref(r)("connect.campaign.common.effect_required"),
2624
+ state: "error"
2625
+ }, null, 8, ["text"]))
2626
+ ], 64)) : e.field.type === "message" ? (openBlock(), createBlock(_sfc_main$y, {
2627
+ key: 13,
2628
+ "allow-email": !0,
2629
+ "allow-whatsapp": !0,
2630
+ "model-value": unref(o),
2631
+ "onUpdate:modelValue": a,
2632
+ "helper-text": unref(ZodHelper).helperText(n(), ""),
2633
+ "trigger-type": e.field.extras,
2634
+ "helper-state": unref(ZodHelper).helperState(n(), "")
2635
+ }, null, 8, ["model-value", "helper-text", "trigger-type", "helper-state"])) : e.field.type === "earning_option" ? (openBlock(), createBlock(_sfc_main$r, {
2636
+ key: 14,
2637
+ "model-value": unref(o),
2638
+ "onUpdate:modelValue": a,
2639
+ extras: e.extras,
2640
+ "error-text": e.helperText
2641
+ }, null, 8, ["model-value", "extras", "error-text"])) : e.field.type === "validity_option" ? (openBlock(), createBlock(_sfc_main$s, {
2642
+ key: 15,
2643
+ type: "custom",
2644
+ "model-value": unref(o),
2645
+ "onUpdate:modelValue": a,
2646
+ "helper-text": e.helperText || unref(ZodHelper).helperText(n(), ""),
2647
+ "for-credit": i.campaignType === "CREDIT"
2648
+ }, null, 8, ["model-value", "helper-text", "for-credit"])) : e.field.type === "game_type" ? (openBlock(), createBlock(_sfc_main$e, {
2649
+ key: 16,
2650
+ "model-value": unref(o),
2651
+ "onUpdate:modelValue": a
2652
+ }, null, 8, ["model-value"])) : e.field.type === "reward_pool" ? (openBlock(), createBlock(_sfc_main$c, {
2653
+ key: 17,
2654
+ "model-value": unref(o),
2655
+ "onUpdate:modelValue": a
2656
+ }, null, 8, ["model-value"])) : e.field.type === "mission" ? (openBlock(), createBlock(_sfc_main$3, {
2657
+ key: 18,
2658
+ "model-value": unref(o),
2659
+ "onUpdate:modelValue": a
2660
+ }, null, 8, ["model-value"])) : e.field.type === "mission_type" ? (openBlock(), createBlock(_sfc_main$8, {
2661
+ key: 19,
2662
+ "model-value": unref(o),
2663
+ "onUpdate:modelValue": a
2664
+ }, null, 8, ["model-value"])) : e.field.type === "mission_end" ? (openBlock(), createBlock(_sfc_main$7, {
2665
+ key: 20,
2666
+ "model-value": unref(o),
2667
+ "onUpdate:modelValue": a,
2668
+ "helper-text": unref(ZodHelper).helperText(n(), ""),
2669
+ "helper-state": unref(ZodHelper).helperState(n(), "")
2670
+ }, null, 8, ["model-value", "helper-text", "helper-state"])) : e.field.type === "mission_pool" ? (openBlock(), createBlock(_sfc_main$4, {
2671
+ key: 21,
2672
+ "model-value": unref(o),
2673
+ "onUpdate:modelValue": a,
2674
+ mission: e.extras.mission
2675
+ }, null, 8, ["model-value", "mission"])) : e.field.type === "rule_schedule" ? (openBlock(), createElementBlock(Fragment, { key: 22 }, [
2676
+ createVNode(_sfc_main$f, {
2677
+ "model-value": unref(o),
2678
+ "onUpdate:modelValue": a,
2679
+ "start-date": e.extras.start,
2680
+ "end-date": e.extras.end
2681
+ }, null, 8, ["model-value", "start-date", "end-date"]),
2682
+ e.helperText ? (openBlock(), createBlock(p, {
2683
+ key: 0,
2684
+ class: "!mt-[8px]",
2685
+ text: e.helperText,
2686
+ state: "error"
2687
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
2688
+ ], 64)) : e.field.type === "rule_user" ? (openBlock(), createElementBlock(Fragment, { key: 23 }, [
2689
+ createVNode(_sfc_main$z, {
2690
+ "model-value": unref(o),
2691
+ "onUpdate:modelValue": a
2692
+ }, null, 8, ["model-value"]),
2693
+ e.helperText ? (openBlock(), createBlock(p, {
2694
+ key: 0,
2695
+ class: "!mt-[8px]",
2696
+ text: e.helperText,
2697
+ state: "error"
2698
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
2699
+ ], 64)) : e.field.type === "rule_time" ? (openBlock(), createElementBlock(Fragment, { key: 24 }, [
2700
+ e.extras == "PROMOTION" && unref(RuleBuilder).getRules(unref(o).rules.g_time).length > 0 ? (openBlock(), createBlock(p, {
2701
+ key: 0,
2702
+ state: "warning",
2703
+ text: `Time based rule only work for POS >= v${unref(featureVersionMapping).TIME_BASED_PROMOTION}`
2704
+ }, null, 8, ["text"])) : createCommentVNode("", !0),
2705
+ createVNode(_sfc_main$k, {
2706
+ "model-value": unref(o),
2707
+ "onUpdate:modelValue": a
2708
+ }, null, 8, ["model-value"]),
2709
+ e.helperText ? (openBlock(), createBlock(p, {
2710
+ key: 1,
2711
+ class: "!mt-[8px]",
2712
+ text: e.helperText,
2713
+ state: "error"
2714
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
2715
+ ], 64)) : e.field.type === "rule_bill" ? (openBlock(), createElementBlock(Fragment, { key: 25 }, [
2716
+ createVNode(_sfc_main$A, {
2717
+ "model-value": unref(o),
2718
+ "onUpdate:modelValue": a
2719
+ }, null, 8, ["model-value"]),
2720
+ e.helperText ? (openBlock(), createBlock(p, {
2721
+ key: 0,
2722
+ class: "!mt-[8px]",
2723
+ text: e.helperText,
2724
+ state: "error"
2725
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
2726
+ ], 64)) : e.field.type === "rule_feedback" ? (openBlock(), createElementBlock(Fragment, { key: 26 }, [
2727
+ createVNode(_sfc_main$B, {
2728
+ "model-value": unref(o),
2729
+ "onUpdate:modelValue": a
2730
+ }, null, 8, ["model-value"]),
2731
+ e.helperText ? (openBlock(), createBlock(p, {
2732
+ key: 0,
2733
+ class: "!mt-[8px]",
2734
+ text: e.helperText,
2735
+ state: "error"
2736
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
2737
+ ], 64)) : e.field.type === "rule_birthday" ? (openBlock(), createElementBlock(Fragment, { key: 27 }, [
2738
+ createVNode(_sfc_main$j, {
2739
+ "model-value": unref(o),
2740
+ "onUpdate:modelValue": a
2741
+ }, null, 8, ["model-value"]),
2742
+ e.helperText ? (openBlock(), createBlock(p, {
2743
+ key: 0,
2744
+ class: "!mt-[8px]",
2745
+ text: e.helperText,
2746
+ state: "error"
2747
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
2748
+ ], 64)) : e.field.type === "promotion_game_type" ? (openBlock(), createElementBlock(Fragment, { key: 28 }, [
2749
+ createVNode(_sfc_main$b, {
2750
+ "model-value": unref(o),
2751
+ "onUpdate:modelValue": a
2752
+ }, null, 8, ["model-value"]),
2753
+ e.helperText ? (openBlock(), createBlock(p, {
2754
+ key: 0,
2755
+ class: "!mt-[8px]",
2756
+ text: e.helperText,
2757
+ state: "error"
2758
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
2759
+ ], 64)) : (openBlock(), createElementBlock("pre", _hoisted_1$2, toDisplayString(i.field), 1));
2760
+ };
2761
+ }
2762
+ }), _hoisted_1$1 = { class: "fm-typo-en-body-lg-600" }, _hoisted_2$1 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$1 = { class: "fm-typo-en-body-lg-600" }, _sfc_main$1 = /* @__PURE__ */ defineComponent({
2763
+ __name: "CampaignSummary",
2764
+ props: {
2765
+ data: {
2766
+ type: Object,
2767
+ required: !0
2768
+ }
2769
+ },
2770
+ setup(e) {
2771
+ const { t: d, te: r } = useI18n();
2772
+ return (i, u) => {
2773
+ const a = resolveComponent("FmCard");
2774
+ return openBlock(), createBlock(a, {
2775
+ variant: "outlined",
2776
+ class: "p-16 space-y-8"
2777
+ }, {
2778
+ default: withCtx(() => [
2779
+ createElementVNode("div", _hoisted_1$1, toDisplayString(unref(d)("connect.campaign.common.summary")), 1),
2780
+ u[0] || (u[0] = createElementVNode("div", { class: "h-[1px] bg-fm-color-neutral-gray-100 w-full" }, null, -1)),
2781
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(getCampaignSummaryObject)(e.data), (o, n) => (openBlock(), createElementBlock("div", {
2782
+ class: "space-y-4",
2783
+ key: n
2784
+ }, [
2785
+ o ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
2786
+ createElementVNode("div", _hoisted_2$1, toDisplayString(unref(d)(`${n}`)), 1),
2787
+ createElementVNode("div", _hoisted_3$1, toDisplayString(unref(r)(`${o}`) ? unref(d)(`${o}`) : o), 1)
2788
+ ], 64)) : createCommentVNode("", !0)
2789
+ ]))), 128))
2790
+ ]),
2791
+ _: 1
2792
+ });
2793
+ };
2794
+ }
2795
+ }), _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 = {
2796
+ key: 0,
2797
+ class: "max-w-6xl mx-auto"
2798
+ }, _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({
2799
+ __name: "EditCampaignSheet",
2800
+ emits: ["submit:model-value"],
2801
+ setup(__props, { expose: __expose, emit: __emit }) {
2802
+ const Dialog = useDialog(), sheetVisible = ref(!1), { t } = useI18n(), currentStep = ref(1), data = ref(), schema = ref(z.any()), template = ref(
2803
+ TEMPLATES.VOUCHER
2804
+ ), { minor } = useLoading, isLoading = ref(!1), sheetTitle = ref("Create Campaign"), campaignType = ref("VOUCHER");
2805
+ async function showSheet(visible, type, campaign, selectedTemplate) {
2806
+ var e, d;
2807
+ if (sheetVisible.value = visible, campaignType.value = type, visible == !0) {
2808
+ try {
2809
+ isLoading.value = visible, await useMembershipStore().readRewards(), await useBusinessStore().readLocations(), await useMembershipStore().readSegments(), await useMembershipStore().readMembership();
2810
+ } catch {
2811
+ } finally {
2812
+ await new Promise((r) => setTimeout(r, 120)), isLoading.value = !1;
2813
+ }
2814
+ console.log(
2815
+ TEMPLATES[type],
2816
+ "base template"
2817
+ ), template.value = selectedTemplate ?? TEMPLATES[type], schema.value = CampaignDtos[type], type === "VOUCHER" && (await useCampaignStore().read(), schema.value = schema.value.superRefine((r, i) => {
2818
+ r.campaign.type === "VOUCHER" && r.campaign.code && useCampaignStore().campaigns.voucher.some(
2819
+ (u) => u.code === r.campaign.code && u._id.toString() !== r.campaign._id.toString()
2820
+ ) && i.addIssue({
2821
+ code: "custom",
2822
+ message: "Code already exists, please use another code",
2823
+ path: ["campaign", "code"]
2824
+ });
2825
+ })), data.value = campaign != null ? { ...campaign, templateId: (e = campaign.template) == null ? void 0 : e._id } : _.cloneDeep({
2826
+ ...(d = template.value) == null ? void 0 : d.defaultValue
2827
+ }), "configs" in data.value && typeof data.value.configs == "string" && (data.value.configs = eval(data.value.configs)), data.value = cleanPF(data.value), 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, sheetTitle.value = campaign ? `Edit ${CampaignOptions[type].name} Campaign` : `Create ${CampaignOptions[type].name} Campaign`;
2828
+ }
2829
+ }
2830
+ async function hideSheet() {
2831
+ Dialog.open({
2832
+ title: t("connect.campaign.common.unsaved_changes"),
2833
+ message: t("connect.campaign.common.unsaved_changes"),
2834
+ primaryActions: {
2835
+ text: t("connect.campaign.common.unsaved_changes_confirm"),
2836
+ close: !0
2837
+ },
2838
+ secondaryActions: {
2839
+ text: t("connect.campaign.common.unsaved_changes_cancel"),
2840
+ close: !1
2841
+ }
2842
+ }).onPrimary(() => {
2843
+ sheetVisible.value = !1;
2844
+ }).onSecondary(() => {
2845
+ Dialog.close();
2846
+ });
2847
+ }
2848
+ const emits = __emit, errors = computed(() => {
2849
+ const e = schema.value.superRefine(campaignRefinement).safeParse(data.value);
2850
+ return e.success ? [] : e.error.errors;
2851
+ });
2852
+ function stepErrors(e = currentStep.value - 1) {
2853
+ const d = template.value.steps[e].groups.flatMap(
2854
+ (r) => r.fields.map((i) => i.property)
2855
+ );
2856
+ return errors.value.filter(
2857
+ (r) => d.some((i) => r.path.join(".").includes(i))
2858
+ );
2859
+ }
2860
+ __expose({ showSheet });
2861
+ function showSummaryDialog() {
2862
+ Dialog.open({
2863
+ title: "",
2864
+ dialogComponent: _sfc_main$1,
2865
+ dialogComponentProps: {
2866
+ data: data.value
2867
+ }
2868
+ });
2869
+ }
2870
+ function onUpdateProperty(e, d) {
2871
+ var r, i, u, a, o, n, l, s;
2872
+ if (_.set(data.value, e, d), e == "campaign.event.type") {
2873
+ const g = ((a = (u = (i = (r = template.value) == null ? void 0 : r.defaultValue) == null ? void 0 : i.campaign) == null ? void 0 : u.event) == null ? void 0 : a.rule) ? _.cloneDeep({
2874
+ ...(s = (l = (n = (o = template.value) == null ? void 0 : o.defaultValue) == null ? void 0 : n.campaign) == null ? void 0 : l.event) == null ? void 0 : s.rule
2875
+ }) : RuleBuilder.setRuleToGroup(RuleBuilder.scaffoldGroup(), [
2876
+ RuleBuilder.scaffoldGroup("g_schedule"),
2877
+ RuleBuilder.scaffoldGroup("g_time"),
2878
+ RuleBuilder.scaffoldGroup("g_user"),
2879
+ RuleBuilder.scaffoldGroup("g_bill")
2880
+ ]), b = RuleBuilder.setRuleToGroup(
2881
+ RuleBuilder.scaffoldGroup("g_schedule"),
2882
+ [
2883
+ RuleBuilder.constructEntry(
2884
+ "trigger.date",
2885
+ "_rrule",
2886
+ "RRULE:FREQ=DAILY;INTERVAL=1;BYHOUR=0;BYMINUTE=0;BYSECOND=0;WKST=SU"
2887
+ ),
2888
+ RuleBuilder.constructEntry("trigger.time", "_isOnTime", "00:00")
2889
+ ],
2890
+ "&&"
2891
+ );
2892
+ if (d != "SCHEDULE") {
2893
+ _.set(data.value, "campaign.event.rule", g);
2894
+ return;
2895
+ }
2896
+ _.set(
2897
+ data.value,
2898
+ "campaign.event.rule",
2899
+ RuleBuilder.setRuleToGroup(g, b)
2900
+ );
2901
+ }
2902
+ e == "campaign.notify" && d == !1 && _.set(data.value, "campaign.notifyMessage", void 0);
2903
+ }
2904
+ async function onUpdateFile(e, d) {
2905
+ return e ? await minor(async () => firebaseStorage.update(d, e), {
2906
+ message: `${e ? "Uploading" : "Removing"} file`,
2907
+ successMessage: `File ${e ? "uploaded" : "removed"} successfully`
2908
+ }) : "";
2909
+ }
2910
+ function isDisable(e) {
2911
+ var d, r;
2912
+ switch (e == null ? void 0 : e.property) {
2913
+ case "campaign.event.type":
2914
+ return ((r = (d = data.value) == null ? void 0 : d.campaign) == null ? void 0 : r._id) || !1;
2915
+ default:
2916
+ return !1;
2917
+ }
2918
+ }
2919
+ async function onSubmit() {
2920
+ const e = schema.value.superRefine(campaignRefinement).transform(campaignTransform).safeParse(data.value);
2921
+ if (!e.success)
2922
+ return;
2923
+ const d = await emits(
2924
+ "submit:model-value",
2925
+ cleanPF(JSON.parse(JSON.stringify(e.data)))
2926
+ );
2927
+ (d || d === void 0) && (sheetVisible.value = !1);
2928
+ }
2929
+ return (e, d) => {
2930
+ const r = resolveComponent("FmButton"), i = resolveComponent("FmStep"), u = resolveComponent("FmStepper"), a = resolveComponent("FmCard"), o = resolveComponent("FmTopSheet");
2931
+ return openBlock(), createBlock(o, {
2932
+ "fullscreen-size": "lg",
2933
+ modelValue: unref(sheetVisible),
2934
+ "onUpdate:modelValue": [
2935
+ d[7] || (d[7] = (n) => isRef(sheetVisible) ? sheetVisible.value = n : null),
2936
+ d[8] || (d[8] = (n) => sheetVisible.value = n)
2937
+ ]
2938
+ }, createSlots({
2939
+ "top-sheet-header": withCtx(() => [
2940
+ createElementVNode("div", _hoisted_1, [
2941
+ createElementVNode("div", null, toDisplayString(unref(sheetTitle)), 1),
2942
+ createElementVNode("div", _hoisted_2, [
2943
+ createVNode(r, {
2944
+ onClick: d[0] || (d[0] = (n) => hideSheet()),
2945
+ label: unref(t)("connect.campaign.common.cancel"),
2946
+ variant: "tertiary"
2947
+ }, null, 8, ["label"]),
2948
+ createVNode(r, {
2949
+ onClick: onSubmit,
2950
+ label: unref(t)("connect.campaign.common.save"),
2951
+ disabled: unref(errors).length > 0
2952
+ }, null, 8, ["label", "disabled"])
2953
+ ])
2954
+ ])
2955
+ ]),
2956
+ _: 2
2957
+ }, [
2958
+ unref(isLoading) ? {
2959
+ name: "default",
2960
+ fn: withCtx(() => [
2961
+ createElementVNode("div", _hoisted_9, [
2962
+ createElementVNode("div", _hoisted_10, [
2963
+ createElementVNode("div", _hoisted_11, [
2964
+ d[9] || (d[9] = createElementVNode("div", { class: "col-span-2 space-y-80 xs:col-span-3 xs:px-16 xs:pt-16" }, [
2965
+ createElementVNode("div", { class: "flex-1 space-y-6 py-1" }, [
2966
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100 rounded" }),
2967
+ createElementVNode("div", { class: "h-[80px] bg-fm-color-neutral-gray-100 rounded" }),
2968
+ createElementVNode("div", { class: "space-y-3" }, [
2969
+ createElementVNode("div", { class: "grid grid-cols-2 gap-4" }, [
2970
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" }),
2971
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
2972
+ ]),
2973
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
2974
+ ]),
2975
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100 rounded" }),
2976
+ createElementVNode("div", { class: "h-[80px] bg-fm-color-neutral-gray-100 rounded" }),
2977
+ createElementVNode("div", { class: "space-y-3" }, [
2978
+ createElementVNode("div", { class: "grid grid-cols-2 gap-4" }, [
2979
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" }),
2980
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
2981
+ ]),
2982
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
2983
+ ])
2984
+ ])
2985
+ ], -1)),
2986
+ createVNode(a, { class: "h-[150px] bg-fm-color-neutral-gray-100" })
2987
+ ])
2988
+ ])
2989
+ ])
2990
+ ]),
2991
+ key: "1"
2992
+ } : {
2993
+ name: "default",
2994
+ fn: withCtx(() => [
2995
+ unref(data) ? (openBlock(), createElementBlock("div", _hoisted_3, [
2996
+ createVNode(u, {
2997
+ modelValue: unref(currentStep),
2998
+ "onUpdate:modelValue": d[1] || (d[1] = (n) => isRef(currentStep) ? currentStep.value = n : null),
2999
+ orientation: "horizontal",
3000
+ class: "xs:hidden mx-[-24px] mt-16 mb-24 flex-1"
3001
+ }, {
3002
+ default: withCtx(() => [
3003
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(template).steps, (n, l) => (openBlock(), createBlock(i, {
3004
+ key: n.name,
3005
+ title: unref(t)(n.name),
3006
+ value: l + 1,
3007
+ error: () => stepErrors(l).length > 0,
3008
+ complete: () => l + 1 <= unref(currentStep)
3009
+ }, null, 8, ["title", "value", "error", "complete"]))), 128))
3010
+ ]),
3011
+ _: 1
3012
+ }, 8, ["modelValue"]),
3013
+ createElementVNode("div", _hoisted_4, [
3014
+ createVNode(r, {
3015
+ icon: "close",
3016
+ variant: "tertiary",
3017
+ onClick: d[2] || (d[2] = (n) => sheetVisible.value = !1)
3018
+ }),
3019
+ createVNode(u, {
3020
+ modelValue: unref(currentStep),
3021
+ "onUpdate:modelValue": d[3] || (d[3] = (n) => isRef(currentStep) ? currentStep.value = n : null),
3022
+ orientation: "horizontal",
3023
+ class: "flex-1"
3024
+ }, {
3025
+ default: withCtx(() => [
3026
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(template).steps, (n, l) => (openBlock(), createBlock(i, {
3027
+ key: n.name,
3028
+ title: unref(sheetTitle),
3029
+ description: unref(t)(n.name),
3030
+ value: l + 1,
3031
+ error: () => stepErrors(l).length > 0,
3032
+ complete: () => l + 1 <= unref(currentStep) && stepErrors(unref(currentStep) - 1).length == 0
3033
+ }, null, 8, ["title", "description", "value", "error", "complete"]))), 128))
3034
+ ]),
3035
+ _: 1
3036
+ }, 8, ["modelValue"]),
3037
+ createVNode(r, {
3038
+ icon: "info",
3039
+ variant: "tertiary",
3040
+ onClick: d[4] || (d[4] = () => showSummaryDialog())
3041
+ })
3042
+ ]),
3043
+ createElementVNode("div", _hoisted_5, [
3044
+ createElementVNode("div", _hoisted_6, [
3045
+ createVNode(JsonViewer, {
3046
+ json: {
3047
+ data: unref(data),
3048
+ errors: unref(errors).map(
3049
+ (n) => `${n.path.join(".")} - ${n.message}`
3050
+ ),
3051
+ stepErrors: stepErrors().map(
3052
+ (n) => `${n.path.join(".")} - ${n.message}`
3053
+ ),
3054
+ schema: unref(schema)
3055
+ }
3056
+ }, null, 8, ["json"]),
3057
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(template).steps[unref(currentStep) - 1].groups.filter(
3058
+ (n) => n.fields.length && (!n.condition || unref(_).get(unref(data), n.condition.property) == n.condition.value == (n.condition.not != !0))
3059
+ ), (n, l) => (openBlock(), createElementBlock("div", {
3060
+ key: l,
3061
+ class: "space-y-24"
3062
+ }, [
3063
+ createElementVNode("div", _hoisted_7, toDisplayString(n.name ? unref(t)(n.name) : ""), 1),
3064
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(n.fields, (s, h) => (openBlock(), createElementBlock("div", { key: h }, [
3065
+ (openBlock(), createBlock(_sfc_main$2, {
3066
+ key: h,
3067
+ field: s,
3068
+ modelValue: unref(_).get(unref(data), s.property),
3069
+ disabled: isDisable(s),
3070
+ "campaign-type": unref(campaignType),
3071
+ "onUpdate:modelValue": (g) => onUpdateProperty(s.property, g),
3072
+ "onUpdate:file": async (g, b) => {
3073
+ const V = await onUpdateFile(g, b);
3074
+ onUpdateProperty(s.property, V || "");
3075
+ },
3076
+ schema: unref(ZodHelper).typeAtPath(
3077
+ unref(schema),
3078
+ s.property,
3079
+ unref(data).campaign.type != "MISSION" ? [unref(data).campaign.type] : ["STAMP", "MISSION"]
3080
+ ),
3081
+ "helper-state": unref(ZodHelper).helperState(unref(errors), s.property),
3082
+ "helper-text": unref(ZodHelper).helperText(unref(errors), s.property),
3083
+ extras: s.extras != null ? s.extras == "" ? unref(data) : unref(_).get(unref(data), s.extras) : void 0
3084
+ }, null, 8, ["field", "modelValue", "disabled", "campaign-type", "onUpdate:modelValue", "onUpdate:file", "schema", "helper-state", "helper-text", "extras"]))
3085
+ ]))), 128))
3086
+ ]))), 128)),
3087
+ createElementVNode("div", _hoisted_8, [
3088
+ createVNode(r, {
3089
+ label: "Back",
3090
+ variant: "tertiary",
3091
+ disabled: unref(currentStep) == 1,
3092
+ onClick: d[5] || (d[5] = (n) => currentStep.value--)
3093
+ }, null, 8, ["disabled"]),
3094
+ createVNode(r, {
3095
+ disabled: unref(currentStep) - 1 < unref(template).steps.length - 1 ? stepErrors().length > 0 : unref(errors).length > 0,
3096
+ label: unref(currentStep) - 1 < unref(template).steps.length - 1 ? "Next" : "Submit",
3097
+ onClick: d[6] || (d[6] = (n) => unref(currentStep) - 1 < unref(template).steps.length - 1 ? currentStep.value++ : onSubmit())
3098
+ }, null, 8, ["disabled", "label"])
3099
+ ])
3100
+ ]),
3101
+ createVNode(_sfc_main$1, {
3102
+ data: unref(data),
3103
+ class: "xs:hidden"
3104
+ }, null, 8, ["data"])
3105
+ ])
3106
+ ])) : createCommentVNode("", !0)
3107
+ ]),
3108
+ key: "0"
3109
+ }
3110
+ ]), 1032, ["modelValue"]);
3111
+ };
3112
+ }
3113
+ });
3114
+ export {
3115
+ _sfc_main as _,
3116
+ summarizeGrabDiscount as s
3117
+ };