@feedmepos/mf-connect 0.1.38-beta.72 → 0.1.38-beta.73

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 (133) hide show
  1. package/dist/Analytic-gGjm5ome.js +761 -0
  2. package/dist/App-BDz9mw-6.js +4638 -0
  3. package/dist/AuditLogs-4x90ZjjY.js +1991 -0
  4. package/dist/Bin-Bby2f42O.js +166 -0
  5. package/dist/Broadcast-eYN2AqFC.js +267 -0
  6. package/dist/CampaignTypeDialog.vue_vue_type_script_setup_true_lang-B-fO9-Hb.js +121 -0
  7. package/dist/Card-Cz-pLt7X.js +909 -0
  8. package/dist/ChipMenu.vue_vue_type_script_setup_true_lang-BPpZZNkr.js +97 -0
  9. package/dist/Collections-CgfXuVA1.js +540 -0
  10. package/dist/Credit-Lc6B2oQ9.js +261 -0
  11. package/dist/CustomSelect.vue_vue_type_script_setup_true_lang-Du7fRSZC.js +128 -0
  12. package/dist/DateRangeChip.vue_vue_type_script_setup_true_lang-eIoPtgO5.js +58 -0
  13. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-Bm7XTR7o.js +3167 -0
  14. package/dist/EffectSheet.vue_vue_type_style_index_0_lang-Cp5nSLEX.js +351 -0
  15. package/dist/Experience-Ca94IJBt.js +260 -0
  16. package/dist/FileSaver.min-BThLVsSf.js +74 -0
  17. package/dist/FilterChip.vue_vue_type_script_setup_true_lang-DaU-9GzO.js +129 -0
  18. package/dist/Game-BYLYDTU9.js +331 -0
  19. package/dist/GenerateMaterial-CUoG6uyI.js +589 -0
  20. package/dist/Grab-DZ_LkTly.js +301 -0
  21. package/dist/ImageInput.vue_vue_type_script_setup_true_lang-CI4kP9ul.js +145 -0
  22. package/dist/Index-BZ2r8x0t.js +259 -0
  23. package/dist/JsonViewer-v8_C7l5N.js +87 -0
  24. package/dist/LottieAnimation.vue_vue_type_script_setup_true_lang-BLKlXW1b.js +18737 -0
  25. package/dist/MainLayout-BfGSSVMW.js +41 -0
  26. package/dist/Marketing-DYg0J1xG.js +145 -0
  27. package/dist/MarketingMaterialEdit-B--Kck7j.js +746 -0
  28. package/dist/Member-By5QEJxn.js +280 -0
  29. package/dist/MemberList-D49bMmGJ.js +1600 -0
  30. package/dist/MemberOverview-wL_ailso.js +58 -0
  31. package/dist/MemberTransactions-Cz9XENK1.js +45 -0
  32. package/dist/MessageInput.vue_vue_type_script_setup_true_lang-IlFjM-Y5.js +60798 -0
  33. package/dist/Mission-Cvl-V7c8.js +335 -0
  34. package/dist/Overview-lu82lUJp.js +1078 -0
  35. package/dist/Point-C65YFhOB.js +263 -0
  36. package/dist/Promotion-DQCrKO6a.js +397 -0
  37. package/dist/Queue-DR5lfSMi.js +259 -0
  38. package/dist/Record-BCt42_VZ.js +341 -0
  39. package/dist/Reward-7aOnjmMm.js +442 -0
  40. package/dist/RewardGroup.vue_vue_type_script_setup_true_lang-BPgjr91S.js +149 -0
  41. package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-Bp5jnlFr.js +1912 -0
  42. package/dist/Segment-DiYwfb8M.js +881 -0
  43. package/dist/SelectItems.vue_vue_type_script_setup_true_lang-ydM5ypC0.js +181 -0
  44. package/dist/SendCollectionSheet.vue_vue_type_script_setup_true_lang-BRs7pw0l.js +188 -0
  45. package/dist/SendVoucherSheet.vue_vue_type_script_setup_true_lang-DU8AAPFD.js +147 -0
  46. package/dist/Setting-k6xShcs8.js +1999 -0
  47. package/dist/SettingAdvertisements-DQa_jXYM.js +263 -0
  48. package/dist/Store-B6lYBpsm.js +1995 -0
  49. package/dist/StoreRewards-Cqd399q8.js +534 -0
  50. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-Wv_SHwmo.js +1128 -0
  51. package/dist/TargetLocationInput.vue_vue_type_script_setup_true_lang-Bi1o4YAz.js +7005 -0
  52. package/dist/Tier-CXXImaDx.js +969 -0
  53. package/dist/Title-CTxNCmBW.js +567 -0
  54. package/dist/Transaction-DonaHVzF.js +39 -0
  55. package/dist/UserRuleGroup.vue_vue_type_script_setup_true_lang-DbRVYccO.js +130 -0
  56. package/dist/Voucher-Bso_Mjlg.js +422 -0
  57. package/dist/VoucherEditor.vue_vue_type_script_setup_true_lang-DNvmaJk9.js +421 -0
  58. package/dist/ZodTextField.vue_vue_type_script_setup_true_lang-KHZ3-THo.js +56 -0
  59. package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
  60. package/dist/app-DKrmktFJ.js +59071 -0
  61. package/dist/app-wDQR6dpb.js +39 -0
  62. package/dist/app.js +7 -0
  63. package/dist/business-Dd73TVX5.js +82 -0
  64. package/dist/campaign-BUQHH4KL.js +100 -0
  65. package/dist/campaign-CpzFl8Vr.js +4 -0
  66. package/dist/campaign-DkJOyF24.js +253 -0
  67. package/dist/campaign.enum-C8vJuDAq.js +26 -0
  68. package/dist/campaign.fn-DJSpfhZH.js +776 -0
  69. package/dist/collectible.enum-D3W0TwoJ.js +19 -0
  70. package/dist/collection.fn-YzgpOmG0.js +26 -0
  71. package/dist/dto-sceHHLGr.js +222 -0
  72. package/dist/duplicateCampaign-CDulKxgJ.js +51 -0
  73. package/dist/effect-BSgfR9iB.js +89 -0
  74. package/dist/email-addresses-D_fyxOof.js +705 -0
  75. package/dist/export-OxiqL1B7.js +96 -0
  76. package/dist/feedme.ico +0 -0
  77. package/dist/helper-CzurWUe4.js +86 -0
  78. package/dist/index-BF0hGAkO.js +32 -0
  79. package/dist/index-BGMhsZnB.js +124 -0
  80. package/dist/index-B_QGGlMD.js +54 -0
  81. package/dist/index-BbTHqh58.js +31 -0
  82. package/dist/index-BqQas5Sx.js +2428 -0
  83. package/dist/index-BtMmY44D.js +36 -0
  84. package/dist/index-CAUVTn1I.js +67 -0
  85. package/dist/index-Cg-sBBf_.js +3419 -0
  86. package/dist/index-CuvNtC_M.js +61 -0
  87. package/dist/index-Cyt6eKEF.js +8912 -0
  88. package/dist/index-Dw3ew6qN.js +85 -0
  89. package/dist/index-IBvUTxqC.js +30289 -0
  90. package/dist/index-pkwrUX33.js +28897 -0
  91. package/dist/index-tYmg4eyJ.js +3 -0
  92. package/dist/index-vh86FiIQ.js +10 -0
  93. package/dist/index.esm2017-5xGykkgL.js +3069 -0
  94. package/dist/loading-CvHPT80F.js +215 -0
  95. package/dist/lodash-Q-_FPkpI.js +3678 -0
  96. package/dist/membership-CU-wFWan.js +235 -0
  97. package/dist/moment-D7p2TMB-.js +2583 -0
  98. package/dist/money-CzlfhEoe.js +15 -0
  99. package/dist/number-Bee2M41N.js +12 -0
  100. package/dist/object-qECH92oz.js +26 -0
  101. package/dist/objectId-dwaoBfJX.js +7 -0
  102. package/dist/objectid-DRJQv7AY.js +145 -0
  103. package/dist/plugins-CAdlnev8.js +1817 -0
  104. package/dist/remy-D_Deb3ue.js +13 -0
  105. package/dist/reward-BhlYd0FB.js +36 -0
  106. package/dist/rule-Ccvu41A_.js +1969 -0
  107. package/dist/rule-builder-B968rIyS.js +102 -0
  108. package/dist/style.css +13 -0
  109. package/dist/template-OZfyPJVE.js +188 -0
  110. package/dist/tier-BJDhpH6X.js +4 -0
  111. package/dist/tiers/tier=1.png +0 -0
  112. package/dist/tiers/tier=2.png +0 -0
  113. package/dist/tiers/tier=3.png +0 -0
  114. package/dist/tiers/tier=4.png +0 -0
  115. package/dist/timezone-CopuRbDK.js +1154 -0
  116. package/dist/titles/type=diamond.png +0 -0
  117. package/dist/titles/type=drinks.png +0 -0
  118. package/dist/titles/type=food.png +0 -0
  119. package/dist/titles/type=heart.png +0 -0
  120. package/dist/titles/type=medal.png +0 -0
  121. package/dist/titles/type=spend.png +0 -0
  122. package/dist/titles/type=thank-you.png +0 -0
  123. package/dist/titles/type=thumbs-up.png +0 -0
  124. package/dist/titles/type=years.png +0 -0
  125. package/dist/trigger-BtQI81FL.js +213 -0
  126. package/dist/tslib.es6-BCqqvLQ_.js +44 -0
  127. package/dist/type_drinks-D6jnpvwV.js +4 -0
  128. package/dist/usePagination-Ciom38dd.js +266 -0
  129. package/dist/user-BOW0ixDK.js +55 -0
  130. package/dist/vue-i18n-jTYKTJq1.js +2365 -0
  131. package/dist/xlsx-YD3LYwip.js +15491 -0
  132. package/dist/zod-B_G9o5PC.js +91 -0
  133. package/package.json +1 -1
@@ -0,0 +1,1600 @@
1
+ import { defineComponent as be, computed as H, ref as G, resolveComponent as V, openBlock as u, createElementBlock as A, Fragment as q, createElementVNode as n, unref as t, createBlock as U, createCommentVNode as le, createVNode as _, renderList as ie, withCtx as xe, createTextVNode as Me, toDisplayString as $, withDirectives as Re, vShow as Le, watch as ze, onBeforeMount as at, h as K, onMounted as je, isRef as rt, normalizeClass as st } from "vue";
2
+ import { h as C } from "./moment-D7p2TMB-.js";
3
+ import { useDialog as Ve, components as ve } from "@feedmepos/ui-library";
4
+ import { e as it, M as lt } from "./email-addresses-D_fyxOof.js";
5
+ import { w as ct } from "./xlsx-YD3LYwip.js";
6
+ import "./index-tYmg4eyJ.js";
7
+ import "./index-IBvUTxqC.js";
8
+ import { u as Ie, C as Be, s as dt } from "./membership-CU-wFWan.js";
9
+ import { c as mt } from "./index-pkwrUX33.js";
10
+ import { _ as Ye } from "./lodash-Q-_FPkpI.js";
11
+ import { D as ut } from "./type_drinks-D6jnpvwV.js";
12
+ import { d as pt, e as ft, f as bt, g as yt, h as gt } from "./index-Cg-sBBf_.js";
13
+ import { p as Pe, c as Oe, b as Ue } from "./plugins-CAdlnev8.js";
14
+ import { m as Te, u as qe } from "./loading-CvHPT80F.js";
15
+ import { C as Ee } from "./collection.fn-YzgpOmG0.js";
16
+ import { u as Ke } from "./business-Dd73TVX5.js";
17
+ import { defineStore as vt } from "pinia";
18
+ import { f as ee } from "./number-Bee2M41N.js";
19
+ import "./index-BqQas5Sx.js";
20
+ import "./index-Cyt6eKEF.js";
21
+ import "./index-B_QGGlMD.js";
22
+ import { s as xt } from "./index-CuvNtC_M.js";
23
+ import { u as Ge, _ as He } from "./usePagination-Ciom38dd.js";
24
+ import { B as ht, e as _t } from "./export-OxiqL1B7.js";
25
+ import { o as he } from "./objectId-dwaoBfJX.js";
26
+ import { F as Ae } from "./collectible.enum-D3W0TwoJ.js";
27
+ import { a as St, c as Ct } from "./campaign-DkJOyF24.js";
28
+ import { useRouter as We } from "vue-router";
29
+ import { m as fe } from "./index-Dw3ew6qN.js";
30
+ import { t as wt } from "./index-CAUVTn1I.js";
31
+ import { R as Je } from "./app-DKrmktFJ.js";
32
+ import { t as Ft } from "./money-CzlfhEoe.js";
33
+ import { g as Mt, a as Tt, b as kt } from "./user-BOW0ixDK.js";
34
+ const At = { class: "flex flex-col" }, Et = { key: 1 }, Vt = { class: "flex flex-nowrap gap-4 items-center my-[-4px]" }, It = { class: "flex flex-nowrap gap-8 items-center pt-24 w-full" }, $t = /* @__PURE__ */ be({
35
+ __name: "MemberStatsDialog",
36
+ props: {
37
+ member: {
38
+ type: Object,
39
+ required: !0
40
+ },
41
+ onSubmit: {
42
+ type: Function,
43
+ required: !0
44
+ }
45
+ },
46
+ setup(y) {
47
+ var ce, ae, W, re;
48
+ const k = Ve(), p = Ie(), x = y, s = H(
49
+ () => {
50
+ var f;
51
+ return (((f = x.member.collection) == null ? void 0 : f.TITLE) ?? []).reduce(
52
+ (c, M) => {
53
+ var S, T, O, E, R;
54
+ const r = p.sortedTitles.find(
55
+ (te) => te._id.toString() === M.collectible
56
+ );
57
+ if (!r) return c;
58
+ const i = [...M.expiryBalance ?? []].sort(
59
+ (te, z) => C(te.expiredAt).isAfter(C(z.expiredAt)) ? -1 : 1
60
+ );
61
+ return (S = i[0]) != null && S.expiredAt && C((T = i[0]) == null ? void 0 : T.expiredAt).isBefore(C()) || c.push({
62
+ _id: r._id,
63
+ name: r.name,
64
+ expiredAt: (O = i[0]) != null && O.expiredAt ? C((E = i[0]) == null ? void 0 : E.expiredAt).toISOString() : "",
65
+ expiresIn: C((R = i[0]) == null ? void 0 : R.expiredAt).diff(C(), "days")
66
+ }), c;
67
+ },
68
+ []
69
+ );
70
+ }
71
+ ), o = G({
72
+ cardNo: x.member.cardNo,
73
+ experience: ((ae = (ce = x.member.collection) == null ? void 0 : ce.POINT) == null ? void 0 : ae[0].balance) ?? 0,
74
+ tier: ((re = (W = x.member.collection) == null ? void 0 : W.TIER) == null ? void 0 : re[0].balance) ?? -1,
75
+ titles: s.value.map((f) => ({ expiredAt: f.expiresIn, id: f._id })) ?? void 0
76
+ }), g = H(
77
+ () => (p.sortedTitles ?? []).map((f) => ({
78
+ label: f.name,
79
+ value: f._id.toString(),
80
+ sublabel: s.value.some((c) => c._id === f._id) ? "Owned" : void 0
81
+ }))
82
+ ), d = H(() => (p.sortedTiers ?? []).map((f, c) => ({
83
+ label: f.name,
84
+ sublabel: `${f.option.from} - ${f.option.to}`,
85
+ from: f.option.from,
86
+ to: f.option.to,
87
+ value: c + 1
88
+ })));
89
+ function w() {
90
+ var M, r;
91
+ const f = ((M = d.value[(o.value.tier ?? 1) - 1]) == null ? void 0 : M.from) ?? 0, c = (r = d.value[(o.value.tier ?? 1) - 1]) == null ? void 0 : r.to;
92
+ o.value.experience = Math.min(
93
+ c ?? f,
94
+ Math.max(f, o.value.experience ?? 0)
95
+ );
96
+ }
97
+ const m = H(() => {
98
+ var M, r, i, S, T, O;
99
+ const f = ((r = (M = x.member.collection) == null ? void 0 : M.TIER) == null ? void 0 : r[0].balance) ?? -1, c = ((S = (i = x.member.collection) == null ? void 0 : i.POINT) == null ? void 0 : S[0].balance) ?? 0;
100
+ if (f != o.value.tier) return !0;
101
+ if (o.value.experience && o.value.experience != c) {
102
+ const E = ((T = d.value[f - 1]) == null ? void 0 : T.from) ?? 0, R = ((O = d.value[f - 1]) == null ? void 0 : O.to) ?? 0;
103
+ if (o.value.experience < E || R && o.value.experience > R)
104
+ return !0;
105
+ }
106
+ return !1;
107
+ });
108
+ function v(f) {
109
+ var c;
110
+ return (c = s.value.find((M) => M._id === f)) == null ? void 0 : c.expiresIn;
111
+ }
112
+ const I = H(() => {
113
+ const f = pt.safeParse(o.value);
114
+ return f.success ? void 0 : f.error.errors;
115
+ });
116
+ function N(f) {
117
+ var c, M;
118
+ return (M = (c = I.value) == null ? void 0 : c.find((r) => r.path.join(".") === f)) == null ? void 0 : M.message;
119
+ }
120
+ function L(f) {
121
+ var c;
122
+ return (c = I.value) == null ? void 0 : c.filter((M) => M.path.join(".").startsWith(f)).map((M) => M.message);
123
+ }
124
+ async function P() {
125
+ await x.onSubmit(o.value), k.close();
126
+ }
127
+ return (f, c) => {
128
+ var te, z;
129
+ const M = V("FmSelect"), r = V("FmStepperField"), i = V("FmTextField"), S = V("FmField"), T = V("FmFormGroup"), O = V("FmButton"), E = V("FmHelperText"), R = V("FmSpacer");
130
+ return u(), A(q, null, [
131
+ n("div", At, [
132
+ c[6] || (c[6] = n("div", { class: "fm-typo-en-title-sm-800 mb-8" }, "Member tiering", -1)),
133
+ t(d).length ? (u(), U(M, {
134
+ key: 0,
135
+ modelValue: t(o).tier,
136
+ "onUpdate:modelValue": [
137
+ c[0] || (c[0] = (F) => t(o).tier = F),
138
+ w
139
+ ],
140
+ label: "Member Tier",
141
+ items: t(d),
142
+ "helper-text": N("tier"),
143
+ "helper-state": N("tier") ? "error" : void 0
144
+ }, null, 8, ["modelValue", "items", "helper-text", "helper-state"])) : le("", !0),
145
+ _(r, {
146
+ "model-value": t(o).experience ?? 0,
147
+ "onUpdate:modelValue": c[1] || (c[1] = (F) => t(o).experience = F),
148
+ label: "Member Experience",
149
+ "max-fraction-digits": 0,
150
+ "helper-text": N("experience"),
151
+ "helper-state": N("experience") ? "error" : void 0
152
+ }, null, 8, ["model-value", "helper-text", "helper-state"]),
153
+ c[7] || (c[7] = n("div", { class: "fm-typo-en-title-sm-800 mt-16 mb-8" }, "Member Card", -1)),
154
+ _(i, {
155
+ modelValue: t(o).cardNo,
156
+ "onUpdate:modelValue": c[2] || (c[2] = (F) => t(o).cardNo = F),
157
+ label: "Card number",
158
+ "helper-text": N("cardNo"),
159
+ "helper-state": N("cardNo") ? "error" : void 0
160
+ }, null, 8, ["modelValue", "helper-text", "helper-state"]),
161
+ c[8] || (c[8] = n("div", { class: "fm-typo-en-title-sm-800 mt-16 mb-8" }, "Titles", -1)),
162
+ (te = t(o).titles) != null && te.length ? (u(), A("div", Et, [...c[5] || (c[5] = [
163
+ n("div", { class: "flex flex-nowrap gap-4 items-center" }, [
164
+ n("div", { class: "flex-1" }, "Title"),
165
+ n("div", { class: "flex-1" }, "Expires in days"),
166
+ n("div", { class: "w-24 h-1" })
167
+ ], -1)
168
+ ])])) : le("", !0),
169
+ (u(!0), A(q, null, ie(t(o).titles ?? [], (F, J) => (u(), A("div", { key: J }, [
170
+ n("div", Vt, [
171
+ t(s).some((a) => a._id === F.id) ? (u(), U(T, {
172
+ key: 1,
173
+ "model-value": "",
174
+ class: "flex-1"
175
+ }, {
176
+ default: xe(() => [
177
+ _(S, {
178
+ disabled: !0,
179
+ class: "text-fm-color-typo-secondary"
180
+ }, {
181
+ default: xe(() => {
182
+ var a;
183
+ return [
184
+ Me($((a = t(g).find((e) => e.value === F.id)) == null ? void 0 : a.label), 1)
185
+ ];
186
+ }),
187
+ _: 2
188
+ }, 1024)
189
+ ]),
190
+ _: 2
191
+ }, 1024)) : (u(), U(M, {
192
+ key: 0,
193
+ modelValue: F.id,
194
+ "onUpdate:modelValue": [(a) => F.id = a, (a) => F.expiredAt = v(a) ?? 1],
195
+ class: "flex-1",
196
+ items: t(g).filter(
197
+ (a) => {
198
+ var e;
199
+ return !((e = t(o).titles) != null && e.map((b) => b.id).includes(a.value)) || F.id === a.value;
200
+ }
201
+ )
202
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "items"])),
203
+ _(r, {
204
+ modelValue: F.expiredAt,
205
+ "onUpdate:modelValue": (a) => F.expiredAt = a,
206
+ class: "flex-1",
207
+ label: "",
208
+ "max-fraction-digits": 0,
209
+ min: 0,
210
+ max: 9999,
211
+ step: 1
212
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
213
+ _(O, {
214
+ class: "w-24 h-24",
215
+ icon: "close",
216
+ variant: "tertiary",
217
+ onClick: (a) => {
218
+ var e;
219
+ return (e = t(o).titles) == null ? void 0 : e.splice(J, 1);
220
+ }
221
+ }, null, 8, ["onClick"])
222
+ ]),
223
+ (u(!0), A(q, null, ie(L(`titles.${J}`), (a, e) => (u(), U(E, {
224
+ key: e,
225
+ class: "items-center",
226
+ state: "error",
227
+ text: a.toString()
228
+ }, null, 8, ["text"]))), 128))
229
+ ]))), 128)),
230
+ t(g).length && (((z = t(o).titles) == null ? void 0 : z.length) ?? 0) < t(g).length ? (u(), U(O, {
231
+ key: 2,
232
+ icon: "add",
233
+ label: "Give title",
234
+ variant: "plain",
235
+ onClick: c[3] || (c[3] = (F) => {
236
+ var J;
237
+ return t(o).titles = [
238
+ ...t(o).titles ?? [],
239
+ {
240
+ id: ((J = t(g).find(
241
+ (a) => {
242
+ var e;
243
+ return !((e = t(o).titles) != null && e.map((b) => b.id).includes(a.value));
244
+ }
245
+ )) == null ? void 0 : J.value) || t(g)[0].value,
246
+ expiredAt: 0
247
+ }
248
+ ];
249
+ })
250
+ })) : le("", !0)
251
+ ]),
252
+ n("div", It, [
253
+ Re(_(E, {
254
+ state: "warning",
255
+ text: "Updating member will cause tier to change"
256
+ }, null, 512), [
257
+ [Le, t(m)]
258
+ ]),
259
+ _(R),
260
+ _(O, {
261
+ variant: "secondary",
262
+ label: "Cancel",
263
+ size: "md",
264
+ onClick: c[4] || (c[4] = (F) => t(k).close())
265
+ }),
266
+ _(O, {
267
+ disabled: !!t(I),
268
+ variant: "primary",
269
+ label: "Submit",
270
+ size: "md",
271
+ onClick: P
272
+ }, null, 8, ["disabled"])
273
+ ])
274
+ ], 64);
275
+ };
276
+ }
277
+ }), Dt = { class: "fm-typo-en-title-sm-800" }, Nt = { class: "space-y-16" }, Bt = { class: "flex flex-nowrap gap-8 items-center justify-end pt-24 w-full" }, Yt = /* @__PURE__ */ be({
278
+ __name: "CreditCoinDialog",
279
+ props: {
280
+ type: { type: String, required: !0 },
281
+ action: { type: String, required: !0 },
282
+ onSubmit: {
283
+ type: Function,
284
+ required: !0
285
+ }
286
+ },
287
+ setup(y) {
288
+ const k = Ve(), p = y, x = G({
289
+ amount: 1,
290
+ day: 1,
291
+ remark: void 0
292
+ }), s = G(!0), o = H(() => Ee.formattedType(p.type.toUpperCase()));
293
+ function g(m) {
294
+ s.value = m, !m && p.type === "coin" && (x.value.day = void 0);
295
+ }
296
+ async function d() {
297
+ if (p.action === "send") {
298
+ const m = x.value.day ? `, expire in ${x.value.day} days` : "";
299
+ Pe.confirm(
300
+ `Are you sure to send ${x.value.amount} ${o.value.toLowerCase()}${m}? This action cannot be reversed.`
301
+ ).then(async (v) => {
302
+ v && await p.onSubmit(x.value);
303
+ });
304
+ } else
305
+ Pe.confirm(
306
+ `Are you sure to deduct ${x.value.amount} ${o.value.toLowerCase()}? This action cannot be reversed.`
307
+ ).then(async (m) => {
308
+ m && await p.onSubmit(x.value);
309
+ });
310
+ }
311
+ const w = H(() => {
312
+ const v = (p.action === "send" ? p.type === "coin" ? ft : bt : p.type === "coin" ? yt : gt).safeParse(x.value);
313
+ return v.success == !1 ? v.error.flatten().fieldErrors : void 0;
314
+ });
315
+ return (m, v) => {
316
+ const I = V("FmStepperField"), N = V("FmSwitch"), L = V("FmTextarea"), P = V("FmButton"), ce = V("FmCard");
317
+ return u(), U(ce, { class: "flex flex-col gap-16 p-16" }, {
318
+ default: xe(() => {
319
+ var ae, W, re, f, c, M;
320
+ return [
321
+ n("div", Dt, $(p.action == "send" ? "Send" : "Deduct") + " " + $(t(Be)[p.type.toUpperCase()].name), 1),
322
+ Me(" " + $(t(w)) + " ", 1),
323
+ n("div", Nt, [
324
+ _(I, {
325
+ modelValue: t(x).amount,
326
+ "onUpdate:modelValue": v[0] || (v[0] = (r) => t(x).amount = r),
327
+ label: `${t(Be)[p.type.toUpperCase()].name} amount`,
328
+ "is-currency": !0,
329
+ "max-fraction-digits": 2,
330
+ "helper-state": (ae = t(w)) != null && ae.amount ? "error" : void 0,
331
+ "helper-text": (re = (W = t(w)) == null ? void 0 : W.amount) == null ? void 0 : re[0]
332
+ }, null, 8, ["modelValue", "label", "helper-state", "helper-text"]),
333
+ y.action === "send" && p.type === "coin" ? (u(), U(N, {
334
+ key: 0,
335
+ "model-value": t(s),
336
+ label: `${t(o)} expires`,
337
+ "label-placement": "right",
338
+ "onUpdate:modelValue": v[1] || (v[1] = (r) => g(r))
339
+ }, null, 8, ["model-value", "label"])) : le("", !0),
340
+ y.action === "send" && t(s) ? (u(), U(I, {
341
+ key: 1,
342
+ modelValue: t(x).day,
343
+ "onUpdate:modelValue": v[2] || (v[2] = (r) => t(x).day = r),
344
+ label: `${t(o)} expires in`,
345
+ "max-fraction-digits": 0,
346
+ "append-text": "day(s)",
347
+ max: 9999,
348
+ min: 0,
349
+ "helper-state": (f = t(w)) != null && f.day ? "error" : void 0,
350
+ "helper-text": (M = (c = t(w)) == null ? void 0 : c.day) == null ? void 0 : M[0]
351
+ }, null, 8, ["modelValue", "label", "helper-state", "helper-text"])) : le("", !0),
352
+ _(L, {
353
+ modelValue: t(x).remark,
354
+ "onUpdate:modelValue": v[3] || (v[3] = (r) => t(x).remark = r),
355
+ label: "Remark"
356
+ }, null, 8, ["modelValue"])
357
+ ]),
358
+ n("div", Bt, [
359
+ _(P, {
360
+ variant: "secondary",
361
+ label: "Cancel",
362
+ size: "md",
363
+ onClick: v[4] || (v[4] = (r) => t(k).close())
364
+ }),
365
+ _(P, {
366
+ disabled: !!t(w),
367
+ variant: "primary",
368
+ label: "Submit",
369
+ size: "md",
370
+ onClick: v[5] || (v[5] = async () => d())
371
+ }, null, 8, ["disabled"])
372
+ ])
373
+ ];
374
+ }),
375
+ _: 1
376
+ });
377
+ };
378
+ }
379
+ }), Xe = vt("segment", () => {
380
+ const y = G([]);
381
+ async function k() {
382
+ const p = await dt.readAll({
383
+ limit: 1e3,
384
+ skip: 0,
385
+ sortBy: "_id",
386
+ descending: !0
387
+ });
388
+ y.value = p.resources;
389
+ }
390
+ return {
391
+ segments: y,
392
+ read: k
393
+ };
394
+ });
395
+ class Pt extends ht {
396
+ }
397
+ const Ot = { class: "border border-fm-color-neutral-gray-100 rounded-lg p-16" }, Ut = { class: "hidden xs:!flex items-center justify-end" }, Rt = { class: "flex items-center justify-between mb-4" }, Lt = { class: "flex items-center justify-between gap-x-8" }, zt = { class: "fm-typo-en-body-lg-600" }, jt = { class: "px-4 py-0.5 rounded-md bg-fm-color-neutral-gray-100 fm-typo-en-body-md-600" }, qt = { class: "xs:hidden flex justify-between gap-x-4" }, ke = /* @__PURE__ */ be({
398
+ __name: "MemberCollectionTable",
399
+ props: {
400
+ member: {
401
+ type: Object,
402
+ required: !0
403
+ },
404
+ title: {
405
+ type: String,
406
+ default: ""
407
+ },
408
+ columns: {
409
+ type: Array,
410
+ default: [],
411
+ required: !0
412
+ },
413
+ filters: {
414
+ type: Object,
415
+ default: {}
416
+ },
417
+ withExport: {
418
+ type: Boolean,
419
+ default: !1
420
+ },
421
+ transformExportRecord: {
422
+ type: Function
423
+ }
424
+ },
425
+ setup(y) {
426
+ const k = y, p = G({
427
+ search: ""
428
+ }), x = G(!1), { tableMeta: s, rowData: o, onSort: g, debouncedFetchData: d, onSearch: w } = Ge(async (v) => {
429
+ const I = {
430
+ ...p.value,
431
+ ...k.filters
432
+ };
433
+ return await Te.readCollectionsByMemberId(
434
+ k.member._id.toString(),
435
+ v,
436
+ I
437
+ );
438
+ });
439
+ ze(
440
+ p,
441
+ () => {
442
+ d();
443
+ },
444
+ { deep: !0 }
445
+ );
446
+ async function m() {
447
+ try {
448
+ x.value = !0;
449
+ const v = {
450
+ ...p.value,
451
+ ...k.filters
452
+ };
453
+ await _t({
454
+ exporter: new Pt(),
455
+ readFunction: (I) => Te.readCollectionsByMemberId(
456
+ k.member._id.toString(),
457
+ I,
458
+ v
459
+ ),
460
+ transformRecord: k.transformExportRecord,
461
+ filename: `${k.member._id.toString()}-${k.title.replace(" ", "-").toLowerCase()}`
462
+ });
463
+ } catch (v) {
464
+ console.error(v);
465
+ } finally {
466
+ x.value = !1;
467
+ }
468
+ }
469
+ return at(async () => {
470
+ await d();
471
+ }), (v, I) => {
472
+ const N = V("FmSearch"), L = V("FmButton");
473
+ return u(), A("div", Ot, [
474
+ n("div", Ut, [
475
+ _(N, {
476
+ class: "hidden xs:!flex",
477
+ modelValue: t(p).search,
478
+ "onUpdate:modelValue": [
479
+ I[0] || (I[0] = (P) => t(p).search = P),
480
+ t(w)
481
+ ],
482
+ placeholder: "Search",
483
+ collapsible: ""
484
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
485
+ y.withExport ? (u(), U(L, {
486
+ key: 0,
487
+ icon: "ios_share",
488
+ variant: "tertiary",
489
+ onClick: m
490
+ })) : le("", !0)
491
+ ]),
492
+ n("div", Rt, [
493
+ n("div", Lt, [
494
+ n("div", zt, $(k.title), 1),
495
+ n("div", jt, $(t(s).totalRows), 1)
496
+ ]),
497
+ n("div", qt, [
498
+ _(N, {
499
+ modelValue: t(p).search,
500
+ "onUpdate:modelValue": [
501
+ I[1] || (I[1] = (P) => t(p).search = P),
502
+ t(w)
503
+ ],
504
+ placeholder: "Search"
505
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
506
+ y.withExport ? (u(), U(L, {
507
+ key: 0,
508
+ icon: "ios_share",
509
+ variant: "tertiary",
510
+ onClick: m
511
+ })) : le("", !0)
512
+ ])
513
+ ]),
514
+ _(He, {
515
+ loading: t(s).isLoading,
516
+ "row-data": t(o),
517
+ "row-count": t(s).totalRows,
518
+ "column-defs": y.columns,
519
+ "page-count": t(s).pageCount,
520
+ "page-index": t(s).pageIndex,
521
+ "page-size": t(s).pageSize,
522
+ "shrink-at": !1,
523
+ onSortChange: t(g),
524
+ onPageChange: I[2] || (I[2] = (P) => t(d)({
525
+ pageSize: P.pageSize,
526
+ pageIndex: P.pageIndex
527
+ }))
528
+ }, null, 8, ["loading", "row-data", "row-count", "column-defs", "page-count", "page-index", "page-size", "onSortChange"])
529
+ ]);
530
+ };
531
+ }
532
+ }), Kt = /* @__PURE__ */ be({
533
+ __name: "MemberVouchers",
534
+ props: {
535
+ member: {
536
+ type: Object,
537
+ required: !0
538
+ }
539
+ },
540
+ setup(y) {
541
+ const k = y, p = [
542
+ {
543
+ header: "Voucher title",
544
+ meta: {
545
+ maxWidth: "300px"
546
+ },
547
+ cell(o) {
548
+ var g;
549
+ return K(
550
+ "div",
551
+ { class: "text-ellipsis truncate" },
552
+ ((g = o.row.original.pf_collectible) == null ? void 0 : g.name) || "-"
553
+ );
554
+ },
555
+ enableSorting: !1
556
+ },
557
+ {
558
+ header: "Claimed at",
559
+ accessorKey: "_id",
560
+ accessorFn: (o) => C(he(o._id.toString())).format("D MMM YYYY"),
561
+ enableSorting: !1
562
+ },
563
+ {
564
+ header: "Expired at",
565
+ cell(o) {
566
+ var d, w, m, v;
567
+ const g = (w = (d = o.row.original.expiryBalance) == null ? void 0 : d[0]) != null && w.expiredAt ? C((v = (m = o.row.original.expiryBalance) == null ? void 0 : m[0]) == null ? void 0 : v.expiredAt).format(
568
+ "D MMM YYYY"
569
+ ) : "-";
570
+ return K("div", {}, g);
571
+ },
572
+ enableSorting: !0
573
+ },
574
+ {
575
+ header: "Transfer open",
576
+ accessorFn: (o) => {
577
+ var g, d, w;
578
+ return xt((w = (d = (g = o.pf_collectible) == null ? void 0 : g.options) == null ? void 0 : d.enableTransfer) == null ? void 0 : w.toString());
579
+ },
580
+ enableSorting: !1
581
+ }
582
+ ], x = (o) => ({
583
+ type: Ae.enum.VOUCHER,
584
+ isActive: o
585
+ }), s = (o) => {
586
+ var g, d, w, m, v, I, N;
587
+ return {
588
+ CollectionID: o._id,
589
+ Title: (g = o.pf_collectible) == null ? void 0 : g.name,
590
+ ClaimedAt: C(he(o._id.toString())).format(
591
+ "D MMM YYYY, hh:mmA"
592
+ ),
593
+ ExpiredAt: (w = (d = o.expiryBalance) == null ? void 0 : d[0]) != null && w.expiredAt ? C((v = (m = o.expiryBalance) == null ? void 0 : m[0]) == null ? void 0 : v.expiredAt).format("D MMM YYYY") : "",
594
+ TransferOpen: ((N = (I = o.pf_collectible) == null ? void 0 : I.options) == null ? void 0 : N.enableTransfer) || !1
595
+ };
596
+ };
597
+ return (o, g) => (u(), A(q, null, [
598
+ g[0] || (g[0] = n("div", { class: "fm-typo-en-title-sm-600 mb-16" }, "Voucher Collections", -1)),
599
+ _(ke, {
600
+ member: k.member,
601
+ columns: p,
602
+ title: "Active voucher",
603
+ filters: x(!0),
604
+ withExport: !0,
605
+ transformExportRecord: s
606
+ }, null, 8, ["member", "filters"]),
607
+ _(ke, {
608
+ member: k.member,
609
+ columns: p,
610
+ title: "Past voucher",
611
+ filters: x(!1),
612
+ withExport: !0,
613
+ transformExportRecord: s
614
+ }, null, 8, ["member", "filters"])
615
+ ], 64));
616
+ }
617
+ }), Gt = /* @__PURE__ */ be({
618
+ __name: "MemberMissions",
619
+ props: {
620
+ member: {
621
+ type: Object,
622
+ required: !0
623
+ }
624
+ },
625
+ setup(y) {
626
+ const k = y, p = [
627
+ {
628
+ header: "Mission title",
629
+ meta: {
630
+ maxWidth: "300px"
631
+ },
632
+ cell(s) {
633
+ var o;
634
+ return K(
635
+ "div",
636
+ { class: "text-ellipsis truncate" },
637
+ ((o = s.row.original.pf_campaign) == null ? void 0 : o.name) || "Deleted Campaign"
638
+ );
639
+ },
640
+ enableSorting: !1
641
+ },
642
+ {
643
+ header: "Type",
644
+ accessorFn: (s) => {
645
+ var o, g, d;
646
+ return Oe.title(((d = (g = (o = s == null ? void 0 : s.pf_collectible) == null ? void 0 : o.extras) == null ? void 0 : g.mission) == null ? void 0 : d.type) || "-");
647
+ },
648
+ enableSorting: !1
649
+ },
650
+ {
651
+ header: "Status",
652
+ cell(s) {
653
+ var o;
654
+ if (s.row.original.pf_campaign) {
655
+ const g = {
656
+ active: "text-fm-color-typo-warning bg-fm-color-system-warning-100",
657
+ upcoming: "text-fm-color-typo-info bg-fm-color-system-info-100",
658
+ completed: "text-fm-color-typo-success bg-fm-color-system-success-100",
659
+ expired: "text-fm-color-typo-error bg-fm-color-system-error-100"
660
+ }, d = St(
661
+ s.row.original.pf_campaign
662
+ ), m = s.row.original.balance === s.row.original.pf_collectible.extras.mission.end && d === "active" ? "completed" : (o = s.row.original) != null && o.deactivatedAt ? "expired" : d;
663
+ return K(ve.FmChip, {
664
+ class: g[m],
665
+ label: Oe.title(m),
666
+ compact: !0
667
+ });
668
+ }
669
+ return K(ve.FmChip, {
670
+ class: "",
671
+ label: "-",
672
+ compact: !0
673
+ });
674
+ },
675
+ enableSorting: !1
676
+ },
677
+ {
678
+ header: "Summary",
679
+ accessorFn: (s) => s != null && s.pf_campaign ? Ct(s.pf_campaign) : "Deleted Campaign",
680
+ enableSorting: !1
681
+ },
682
+ {
683
+ header: "Current Step",
684
+ accessorKey: "balance",
685
+ enableSorting: !1
686
+ },
687
+ {
688
+ header: "Total Step",
689
+ accessorFn: (s) => {
690
+ var o, g, d;
691
+ return ((d = (g = (o = s == null ? void 0 : s.pf_collectible) == null ? void 0 : o.extras) == null ? void 0 : g.mission) == null ? void 0 : d.end) ?? 0;
692
+ },
693
+ enableSorting: !1
694
+ }
695
+ ], x = {
696
+ type: Ae.enum.STAMP
697
+ };
698
+ return (s, o) => (u(), A(q, null, [
699
+ o[0] || (o[0] = n("div", { class: "fm-typo-en-title-sm-600 mb-16" }, "Mission", -1)),
700
+ _(ke, {
701
+ member: k.member,
702
+ columns: p,
703
+ title: "Mission",
704
+ filters: x
705
+ }, null, 8, ["member"])
706
+ ], 64));
707
+ }
708
+ }), Ht = /* @__PURE__ */ be({
709
+ __name: "MemberGames",
710
+ props: {
711
+ member: {
712
+ type: Object,
713
+ required: !0
714
+ }
715
+ },
716
+ setup(y) {
717
+ const k = y, p = [
718
+ {
719
+ header: "Game title",
720
+ meta: {
721
+ maxWidth: "300px"
722
+ },
723
+ cell(s) {
724
+ var o;
725
+ return K(
726
+ "div",
727
+ { class: "text-ellipsis truncate" },
728
+ ((o = s.row.original.pf_campaign) == null ? void 0 : o.name) || "-"
729
+ );
730
+ },
731
+ enableSorting: !1
732
+ },
733
+ {
734
+ header: "Claimed at",
735
+ accessorKey: "_id",
736
+ accessorFn: (s) => C(he(s._id.toString())).format("D MMM YYYY"),
737
+ enableSorting: !1
738
+ },
739
+ {
740
+ header: "Expired at",
741
+ cell(s) {
742
+ var g, d, w, m;
743
+ const o = (d = (g = s.row.original.expiryBalance) == null ? void 0 : g[0]) != null && d.expiredAt ? C((m = (w = s.row.original.expiryBalance) == null ? void 0 : w[0]) == null ? void 0 : m.expiredAt).format(
744
+ "D MMM YYYY"
745
+ ) : "-";
746
+ return K("div", {}, o);
747
+ },
748
+ enableSorting: !1
749
+ },
750
+ {
751
+ header: "Token received",
752
+ accessorKey: "balance",
753
+ enableSorting: !1
754
+ }
755
+ ], x = (s) => ({
756
+ type: Ae.enum.GAME,
757
+ isActive: s
758
+ });
759
+ return (s, o) => (u(), A(q, null, [
760
+ o[0] || (o[0] = n("div", { class: "fm-typo-en-title-sm-600 mb-16" }, "Game program", -1)),
761
+ _(ke, {
762
+ member: k.member,
763
+ columns: p,
764
+ title: "Active game token",
765
+ filters: x(!0)
766
+ }, null, 8, ["member", "filters"])
767
+ ], 64));
768
+ }
769
+ }), Wt = { class: "flex flex-col flex-nowrap gap-y-24 max-h-full" }, Jt = { class: "grid md:grid-cols-2 lg:grid-cols-2 gap-x-36 gap-y-24" }, Xt = { class: "space-y-16" }, Qt = { class: "flex gap-16 items-center" }, Zt = { class: "flex-auto" }, eo = { class: "fm-typo-en-body-md-600" }, to = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, oo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, no = { class: "fm-typo-en-body-md-800" }, ao = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ro = { class: "fm-typo-en-body-md-800" }, so = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, io = { class: "fm-typo-en-body-md-600" }, lo = { class: "gap-16 grid grid-cols-1" }, co = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, mo = { class: "fm-typo-en-body-md-600" }, uo = { class: "p-16 grid md:grid-cols-3 lg:grid-cols-3 border-2 border-fm-color-neutral-gray-100 rounded-lg gap-16 divide-y md:divide-y-0 lg:divide-y-0 md:divide-x lg:divide-x divide-fm-color-neutral-gray-100" }, po = { class: "flex justify-between mb-16" }, fo = { class: "fm-typo-en-title-sm-600" }, bo = ["onClick"], yo = { class: "flex flex-col gap-y-16" }, go = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, vo = { class: "fm-typo-en-body-md-600" }, xo = { class: "space-y-8" }, ho = {
770
+ key: 0,
771
+ class: "space-x-8"
772
+ }, _o = {
773
+ key: 1,
774
+ class: "text-fm-color-typo-secondary"
775
+ }, So = { class: "space-y-8" }, Co = ["src"], wo = { class: "fm-typo-en-body-md-600" }, Fo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Mo = {
776
+ key: 1,
777
+ class: "text-fm-color-typo-secondary"
778
+ }, To = {
779
+ key: 1,
780
+ class: "space-y-24"
781
+ }, ko = { class: "space-y-8" }, Ao = { class: "fm-typo-en-title-md-800" }, Eo = { class: "space-y-4" }, Vo = { class: "fm-typo-en-body-md-600" }, Io = { class: "flex gap-24 items-center xs:flex-col xs:items-start" }, $o = { class: "space-y-8" }, Do = { class: "fm-typo-en-title-md-800" }, No = { class: "space-y-4" }, Bo = { class: "fm-typo-en-body-md-600" }, Yo = { class: "flex gap-24 items-center xs:flex-col xs:items-start" }, Po = /* @__PURE__ */ be({
782
+ __name: "MemberDetailSheet",
783
+ props: {
784
+ member: {
785
+ type: Object,
786
+ required: !0
787
+ }
788
+ },
789
+ emits: ["update:member"],
790
+ setup(y, { expose: k, emit: p }) {
791
+ const x = We(), s = Ke(), o = Ie(), g = Xe(), d = Ve(), { minor: w } = qe, m = y, v = p, I = H(() => s.locations.map((a) => ({
792
+ label: a.name,
793
+ value: a._id
794
+ }))), N = H(() => (m.member.segment || []).map((a) => {
795
+ var e;
796
+ return ((e = g.segments.find((b) => b._id === a)) == null ? void 0 : e.name) || "";
797
+ }).filter(Boolean)), L = [
798
+ {
799
+ label: "Loyalty",
800
+ stats: [
801
+ {
802
+ label: "Experiences",
803
+ getter: (a) => {
804
+ var e, b, D;
805
+ return ee(((D = (b = (e = a.collection) == null ? void 0 : e.POINT) == null ? void 0 : b[0]) == null ? void 0 : D.balance) ?? 0, 2);
806
+ }
807
+ },
808
+ {
809
+ label: "Credits",
810
+ getter: (a) => {
811
+ var e, b, D;
812
+ return ee(((D = (b = (e = a.collection) == null ? void 0 : e.CREDIT) == null ? void 0 : b[0]) == null ? void 0 : D.balance) ?? 0, 2);
813
+ }
814
+ }
815
+ ]
816
+ },
817
+ {
818
+ label: "Voucher",
819
+ stats: [
820
+ {
821
+ label: "Active vouchers",
822
+ getter: () => ee(S.value.active, 0)
823
+ },
824
+ {
825
+ label: "Past vouchers",
826
+ getter: () => ee(S.value.past, 0)
827
+ }
828
+ ]
829
+ },
830
+ {
831
+ label: "Mission",
832
+ stats: [
833
+ {
834
+ label: "Stamp missions",
835
+ getter: () => ee(i.value.stamp, 0)
836
+ },
837
+ {
838
+ label: "Progress missions",
839
+ getter: () => ee(i.value.progressive, 0)
840
+ }
841
+ ]
842
+ },
843
+ {
844
+ label: "Game",
845
+ stats: [
846
+ {
847
+ label: "Tokens",
848
+ getter: (a) => {
849
+ var e, b;
850
+ return ee(
851
+ ((b = (e = a.collection) == null ? void 0 : e.GAME) == null ? void 0 : b.reduce(
852
+ (D, B) => D + B.balance,
853
+ 0
854
+ )) || 0,
855
+ 0
856
+ );
857
+ }
858
+ }
859
+ ]
860
+ },
861
+ {
862
+ label: "Store bundle",
863
+ stats: [
864
+ {
865
+ label: "Bundle purchased",
866
+ getter: () => ee(O.value, 0)
867
+ }
868
+ ]
869
+ }
870
+ ], ce = (() => {
871
+ const e = [];
872
+ for (let b = 0; b < L.length; b += 3)
873
+ e.push(L.slice(b, b + 3));
874
+ return e;
875
+ })();
876
+ async function ae(a, e) {
877
+ switch (a.stopPropagation(), e) {
878
+ case "Store bundle":
879
+ await x.push({
880
+ name: Je["$connect-LOYALTY_MEMBER_TRANSACTIONS"],
881
+ params: { id: m.member._id.toString() },
882
+ query: { tab: "store" }
883
+ });
884
+ break;
885
+ default:
886
+ F.value = z.find((b) => b.label === e) || z[0];
887
+ break;
888
+ }
889
+ }
890
+ async function W(a, e) {
891
+ d.open({
892
+ title: "",
893
+ dialogComponent: Yt,
894
+ dialogComponentProps: {
895
+ type: a,
896
+ action: e,
897
+ onSubmit: async (b) => {
898
+ await w(
899
+ async () => {
900
+ const D = {
901
+ "credit-send": fe.sendCredit,
902
+ "credit-deduct": fe.deductCredit,
903
+ "coin-send": fe.sendCoin,
904
+ "coin-deduct": fe.deductCoin
905
+ }, B = `${a}-${e}`, X = D[B];
906
+ X && await X(m.member._id, b), v("update:member"), d.close();
907
+ },
908
+ {
909
+ message: `Adjusting ${Ee.formattedType(
910
+ a.toUpperCase()
911
+ ).toLowerCase()}`,
912
+ successMessage: `${b.amount} ${Ee.formattedType(
913
+ a.toUpperCase()
914
+ ).toLowerCase()} ${e} ${e == "send" ? "to" : "from"} ${m.member.phoneNumber}`
915
+ }
916
+ );
917
+ }
918
+ }
919
+ });
920
+ }
921
+ async function re() {
922
+ d.open({
923
+ title: "Update member statistics",
924
+ contentComponent: $t,
925
+ contentComponentProps: {
926
+ member: m.member,
927
+ onSubmit: async (a) => {
928
+ await w(
929
+ async () => {
930
+ await fe.updateMember(m.member._id, a), v("update:member"), d.close();
931
+ },
932
+ {
933
+ message: "Updating member stats",
934
+ successMessage: `Updated member ${m.member.phoneNumber} stats successfully`
935
+ }
936
+ );
937
+ }
938
+ }
939
+ });
940
+ }
941
+ const f = [
942
+ {
943
+ label: "Mobile No.",
944
+ key: "phoneNumber"
945
+ },
946
+ {
947
+ label: "Tier",
948
+ getter: (a) => {
949
+ var se, de, ye, h, Y;
950
+ const e = (((de = Ye.first((se = m.member.collection) == null ? void 0 : se.TIER)) == null ? void 0 : de.balance) || 0) - 1, b = M.value.name, D = ((h = (ye = a.collection) == null ? void 0 : ye.POINT) == null ? void 0 : h[0].balance) ?? 0, B = o.sortedTiers[e + 1], X = ((Y = B == null ? void 0 : B.option) == null ? void 0 : Y.from) ?? 1 / 0;
951
+ return `${b} (${D}/${X})`;
952
+ }
953
+ },
954
+ {
955
+ label: "Email",
956
+ key: "email"
957
+ },
958
+ {
959
+ label: "Birthday",
960
+ getter: (a) => a.birthday ? C(a.birthday).format("D MMM YYYY") : "-"
961
+ }
962
+ ], c = [
963
+ {
964
+ label: "Customer since",
965
+ getter: (a) => C(he(a._id.toString())).format("D MMM YYYY")
966
+ },
967
+ {
968
+ label: "Joined at location",
969
+ getter: (a) => {
970
+ var e;
971
+ return a != null && a.location && ((e = I.value.find((b) => b.value == a.location)) == null ? void 0 : e.label) || "-";
972
+ }
973
+ },
974
+ {
975
+ label: "Total visit(s)",
976
+ getter: (a) => Ue.singularOrPlural(a.stats.visitCount, "bill")
977
+ },
978
+ {
979
+ label: "Last visit",
980
+ getter: (a) => C(a.stats.lastVisit).fromNow()
981
+ },
982
+ {
983
+ label: "Frequency",
984
+ getter: (a) => `Every ${Ue.singularOrPlural(
985
+ Number(Math.ceil(a.stats.avgVisitFrequency).toFixed(0)),
986
+ "day"
987
+ )}`
988
+ },
989
+ {
990
+ label: "Average spend",
991
+ getter: (a) => mt.Dinero.fromNumber({ number: Number(a.stats.avgBillSize || 0) }).toFormat(
992
+ !0
993
+ )
994
+ }
995
+ // {
996
+ // label: 'Feedback',
997
+ // key: 'feedbackCount',
998
+ // },
999
+ // {
1000
+ // label: 'Tier Earned this season',
1001
+ // key: 'lastSeasonTierEarned',
1002
+ // },
1003
+ // {
1004
+ // label: 'Point Earned this season',
1005
+ // key: 'lastSeasonPointEarned',
1006
+ // },
1007
+ ], M = H(() => {
1008
+ var b, D;
1009
+ const a = (((D = Ye.first((b = m.member.collection) == null ? void 0 : b.TIER)) == null ? void 0 : D.balance) || 0) - 1, e = o.sortedTiers[a];
1010
+ return { name: (e == null ? void 0 : e.name) || "-", tier: a, config: e };
1011
+ }), r = H(() => {
1012
+ var a;
1013
+ return (((a = m.member.collection) == null ? void 0 : a.TITLE) || []).map((e) => {
1014
+ var D, B, X;
1015
+ const b = (D = o.sortedTitles) == null ? void 0 : D.find(
1016
+ (se) => se._id == e.collectible
1017
+ );
1018
+ return {
1019
+ name: b == null ? void 0 : b.name,
1020
+ expiredAt: (X = (B = e.expiryBalance) == null ? void 0 : B.at(-1)) == null ? void 0 : X.expiredAt,
1021
+ collectible: b
1022
+ };
1023
+ }).filter(
1024
+ (e) => e.expiredAt ? C(e.expiredAt).isAfter(C()) : !0
1025
+ );
1026
+ }), i = G({ stamp: 0, progressive: 0 }), S = G({ active: 0, past: 0 }), T = G([]), O = H(
1027
+ () => T.value.reduce((a, e) => a + e.count, 0)
1028
+ ), E = G(!0);
1029
+ function R() {
1030
+ E.value = !0, F.value = z[0];
1031
+ }
1032
+ function te() {
1033
+ E.value = !1;
1034
+ }
1035
+ const z = [
1036
+ {
1037
+ label: "Overview",
1038
+ value: "overview"
1039
+ },
1040
+ {
1041
+ label: "Loyalty",
1042
+ value: "loyalty"
1043
+ },
1044
+ {
1045
+ label: "Voucher",
1046
+ value: "voucher"
1047
+ },
1048
+ {
1049
+ label: "Mission",
1050
+ value: "mission"
1051
+ },
1052
+ {
1053
+ label: "Game",
1054
+ value: "game"
1055
+ }
1056
+ ], F = G(z[0]), J = async () => {
1057
+ S.value = await Te.readCollectionCountByMemberId(
1058
+ m.member._id.toString(),
1059
+ Ae.enum.VOUCHER
1060
+ ), T.value = await wt.readPurchaseCountByMember(
1061
+ m.member._id.toString()
1062
+ ), i.value = await Te.readMissionCountByMemberId(
1063
+ m.member._id.toString()
1064
+ );
1065
+ };
1066
+ return je(async () => {
1067
+ await o.readMembership(), await J(), s.locations.length || await s.readLocations();
1068
+ }), ze(E, async () => {
1069
+ await J();
1070
+ }), k({
1071
+ showSheet: R,
1072
+ hideSheet: te
1073
+ }), (a, e) => {
1074
+ const b = V("FmTabs"), D = V("FmAvatar"), B = V("FmButton"), X = V("FmIcon"), se = V("FmChip"), de = V("FmCard"), ye = V("FmSideSheet");
1075
+ return u(), U(ye, {
1076
+ modelValue: t(E),
1077
+ "onUpdate:modelValue": e[5] || (e[5] = (h) => rt(E) ? E.value = h : null),
1078
+ header: "Member Detail",
1079
+ "dismiss-away": "",
1080
+ "close-button": !0,
1081
+ "max-width": 1100
1082
+ }, {
1083
+ "side-sheet-footer": xe(() => [...e[19] || (e[19] = [])]),
1084
+ default: xe(() => [
1085
+ n("div", Wt, [
1086
+ n("div", null, [
1087
+ _(b, {
1088
+ "model-value": t(F).value,
1089
+ items: z,
1090
+ class: "overflow-x-auto",
1091
+ "onUpdate:modelValue": e[0] || (e[0] = (h) => F.value = z.find((Y) => Y.value === h))
1092
+ }, null, 8, ["model-value"])
1093
+ ]),
1094
+ t(F).value == "overview" ? (u(), A(q, { key: 0 }, [
1095
+ n("div", Jt, [
1096
+ n("div", null, [
1097
+ e[9] || (e[9] = n("div", { class: "fm-typo-en-title-sm-800 mb-16" }, "Profile Information", -1)),
1098
+ n("div", Xt, [
1099
+ n("div", Qt, [
1100
+ _(D, {
1101
+ name: y.member.photoUrl ? void 0 : y.member.name,
1102
+ src: y.member.photoUrl || void 0
1103
+ }, null, 8, ["name", "src"]),
1104
+ n("div", Zt, [
1105
+ e[8] || (e[8] = n("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Member Name ", -1)),
1106
+ n("div", eo, $(y.member.name), 1),
1107
+ n("div", to, $(y.member._id), 1),
1108
+ n("div", oo, [
1109
+ e[6] || (e[6] = Me(" Member Card: ", -1)),
1110
+ n("span", no, $(y.member.cardNo ? y.member.cardNo : "-"), 1)
1111
+ ]),
1112
+ n("div", ao, [
1113
+ e[7] || (e[7] = Me(" Referral Code: ", -1)),
1114
+ n("span", ro, $(y.member.referralCode ? y.member.referralCode : "-"), 1)
1115
+ ])
1116
+ ]),
1117
+ _(B, {
1118
+ variant: "tertiary",
1119
+ icon: "settings",
1120
+ onClick: re
1121
+ })
1122
+ ]),
1123
+ (u(), A(q, null, ie(f, (h, Y) => n("div", { key: Y }, [
1124
+ n("div", so, $(h.label), 1),
1125
+ n("div", io, $(h.key ? y.member[h.key] : h.getter(y.member)), 1)
1126
+ ])), 64))
1127
+ ])
1128
+ ]),
1129
+ n("div", null, [
1130
+ e[10] || (e[10] = n("div", { class: "fm-typo-en-title-sm-800 mb-16" }, "Activities", -1)),
1131
+ n("div", lo, [
1132
+ (u(), A(q, null, ie(c, (h) => n("div", {
1133
+ key: h.key
1134
+ }, [
1135
+ n("div", co, $(h.label), 1),
1136
+ n("div", mo, $(h.key ? m.member.stats[h.key] || "-" : h.getter(y.member)), 1)
1137
+ ])), 64))
1138
+ ])
1139
+ ])
1140
+ ]),
1141
+ e[13] || (e[13] = n("div", { class: "border-fm-color-neutral-gray-100 rounded-sm border-t" }, null, -1)),
1142
+ (u(!0), A(q, null, ie(t(ce), (h) => (u(), A("div", uo, [
1143
+ (u(!0), A(q, null, ie(h, (Y, oe) => (u(), A("div", { key: oe }, [
1144
+ n("div", {
1145
+ class: st(oe !== 0 ? "pt-12 md:pt-0 lg:pt-0 md:pl-12 lg:pl-12" : "")
1146
+ }, [
1147
+ n("div", po, [
1148
+ n("div", fo, $(Y.label), 1),
1149
+ n("button", {
1150
+ onClick: (j) => ae(j, Y.label)
1151
+ }, [
1152
+ _(X, {
1153
+ name: "chevron_right",
1154
+ outline: "",
1155
+ size: "md"
1156
+ })
1157
+ ], 8, bo)
1158
+ ]),
1159
+ n("div", yo, [
1160
+ (u(!0), A(q, null, ie(Y.stats, (j) => (u(), A("div", {
1161
+ key: j.key
1162
+ }, [
1163
+ n("div", go, $(j.label), 1),
1164
+ n("div", vo, $(j.getter(y.member)), 1)
1165
+ ]))), 128))
1166
+ ])
1167
+ ], 2)
1168
+ ]))), 128))
1169
+ ]))), 256)),
1170
+ n("div", xo, [
1171
+ e[11] || (e[11] = n("div", { class: "fm-typo-en-title-sm-800" }, "Segments", -1)),
1172
+ t(N).length ? (u(), A("div", ho, [
1173
+ (u(!0), A(q, null, ie(t(N), (h) => (u(), U(se, {
1174
+ label: h.toString()
1175
+ }, null, 8, ["label"]))), 256))
1176
+ ])) : (u(), A("div", _o, "No titles"))
1177
+ ]),
1178
+ e[14] || (e[14] = n("div", { class: "border-fm-color-neutral-gray-100 rounded-sm border-t" }, null, -1)),
1179
+ n("div", So, [
1180
+ e[12] || (e[12] = n("div", { class: "fm-typo-en-title-sm-800" }, "Title badge", -1)),
1181
+ t(r).length ? (u(!0), A(q, { key: 0 }, ie(t(r).filter((h) => h.collectible), (h) => (u(), A("div", {
1182
+ class: "flex items-center gap-x-8 h-48",
1183
+ key: h.name
1184
+ }, [
1185
+ n("img", {
1186
+ src: h.collectible.image || t(ut),
1187
+ class: "aspect-square h-full object-contain"
1188
+ }, null, 8, Co),
1189
+ n("div", null, [
1190
+ n("div", wo, $(h.name), 1),
1191
+ n("div", Fo, " Expired on " + $(t(C)(h.expiredAt).format("MMM D, Y")), 1)
1192
+ ])
1193
+ ]))), 128)) : (u(), A("div", Mo, "No titles"))
1194
+ ])
1195
+ ], 64)) : t(F).value == "loyalty" ? (u(), A("div", To, [
1196
+ _(de, {
1197
+ class: "p-16 space-y-24",
1198
+ variant: "outlined"
1199
+ }, {
1200
+ default: xe(() => {
1201
+ var h, Y, oe, j, me, ue, pe;
1202
+ return [
1203
+ n("div", ko, [
1204
+ e[15] || (e[15] = n("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Credit ", -1)),
1205
+ n("div", Ao, $(((oe = (Y = (h = y.member.collection) == null ? void 0 : h.CREDIT) == null ? void 0 : Y[0]) == null ? void 0 : oe.balance) ?? 0), 1)
1206
+ ]),
1207
+ n("div", Eo, [
1208
+ e[16] || (e[16] = n("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Credit(s) to be expired in 30 days ", -1)),
1209
+ n("div", Vo, $(((pe = (ue = (me = (j = y.member.collection) == null ? void 0 : j.CREDIT) == null ? void 0 : me[0]) == null ? void 0 : ue.expiryBalance) == null ? void 0 : pe.reduce(
1210
+ (Q, Z) => Z.expiredAt && t(C)(Z.expiredAt).isAfter(t(C)()) && t(C)(Z.expiredAt).isBefore(t(C)().add(30, "days")) ? Q + Z.amount : Q,
1211
+ 0
1212
+ )) ?? 0), 1)
1213
+ ]),
1214
+ n("div", Io, [
1215
+ _(B, {
1216
+ label: "Add credit",
1217
+ icon: "add",
1218
+ variant: "plain",
1219
+ onClick: e[1] || (e[1] = (Q) => W("credit", "send"))
1220
+ }),
1221
+ _(B, {
1222
+ label: "Deduct credit",
1223
+ icon: "remove",
1224
+ variant: "plain",
1225
+ onClick: e[2] || (e[2] = (Q) => W("credit", "deduct"))
1226
+ })
1227
+ ])
1228
+ ];
1229
+ }),
1230
+ _: 1
1231
+ }),
1232
+ _(de, {
1233
+ class: "p-16 space-y-24",
1234
+ variant: "outlined"
1235
+ }, {
1236
+ default: xe(() => {
1237
+ var h, Y, oe, j, me, ue, pe;
1238
+ return [
1239
+ n("div", $o, [
1240
+ e[17] || (e[17] = n("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Point ", -1)),
1241
+ n("div", Do, $(((oe = (Y = (h = y.member.collection) == null ? void 0 : h.COIN) == null ? void 0 : Y[0]) == null ? void 0 : oe.balance) ?? 0), 1)
1242
+ ]),
1243
+ n("div", No, [
1244
+ e[18] || (e[18] = n("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Point(s) to be expired in 30 days ", -1)),
1245
+ n("div", Bo, $(((pe = (ue = (me = (j = y.member.collection) == null ? void 0 : j.COIN) == null ? void 0 : me[0]) == null ? void 0 : ue.expiryBalance) == null ? void 0 : pe.reduce(
1246
+ (Q, Z) => Z.expiredAt && t(C)(Z.expiredAt).isAfter(t(C)()) && t(C)(Z.expiredAt).isBefore(t(C)().add(30, "days")) ? Q + Z.amount : Q,
1247
+ 0
1248
+ )) ?? 0), 1)
1249
+ ]),
1250
+ n("div", Yo, [
1251
+ _(B, {
1252
+ label: "Add point",
1253
+ icon: "add",
1254
+ variant: "plain",
1255
+ onClick: e[3] || (e[3] = (Q) => W("coin", "send"))
1256
+ }),
1257
+ _(B, {
1258
+ label: "Deduct point",
1259
+ icon: "remove",
1260
+ variant: "plain",
1261
+ onClick: e[4] || (e[4] = (Q) => W("coin", "deduct"))
1262
+ })
1263
+ ])
1264
+ ];
1265
+ }),
1266
+ _: 1
1267
+ })
1268
+ ])) : t(F).value == "voucher" ? (u(), U(Kt, {
1269
+ key: 2,
1270
+ member: m.member
1271
+ }, null, 8, ["member"])) : t(F).value == "mission" ? (u(), U(Gt, {
1272
+ key: 3,
1273
+ member: m.member
1274
+ }, null, 8, ["member"])) : t(F).value == "game" ? (u(), U(Ht, {
1275
+ key: 4,
1276
+ member: m.member
1277
+ }, null, 8, ["member"])) : le("", !0)
1278
+ ])
1279
+ ]),
1280
+ _: 1
1281
+ }, 8, ["modelValue"]);
1282
+ };
1283
+ }
1284
+ }), Oo = { class: "flex items-center justify-end" }, hn = /* @__PURE__ */ be({
1285
+ __name: "MemberList",
1286
+ setup(y) {
1287
+ const k = Xe(), p = Ie(), x = Ke(), { minor: s } = qe, o = We(), g = [
1288
+ {
1289
+ header: "Name",
1290
+ enableSorting: !0,
1291
+ accessorKey: "name",
1292
+ cell(r) {
1293
+ return Mt(r.row.original);
1294
+ }
1295
+ },
1296
+ {
1297
+ header: "Phone",
1298
+ enableSorting: !0,
1299
+ accessorKey: "phoneNumber"
1300
+ },
1301
+ {
1302
+ accessorFn: (r) => C(he(r._id.toString())).format("D MMM YYYY"),
1303
+ header: "Customer Since",
1304
+ accessorKey: "_id",
1305
+ id: "_id"
1306
+ },
1307
+ {
1308
+ accessorKey: "collection_TIER_0_balance",
1309
+ header: "Tier",
1310
+ enableSorting: !0,
1311
+ cell(r) {
1312
+ return Tt(
1313
+ r.row.original,
1314
+ p.sortedTiers
1315
+ );
1316
+ }
1317
+ },
1318
+ {
1319
+ header: "Title",
1320
+ enableSorting: !1,
1321
+ cell(r) {
1322
+ return kt(
1323
+ r.row.original,
1324
+ p.sortedTitles
1325
+ );
1326
+ }
1327
+ },
1328
+ {
1329
+ accessorKey: "collection_CREDIT_0_balance",
1330
+ accessorFn: (r) => {
1331
+ var i, S, T;
1332
+ return ee(((T = (S = (i = r.collection) == null ? void 0 : i.CREDIT) == null ? void 0 : S[0]) == null ? void 0 : T.balance) ?? 0, 2);
1333
+ },
1334
+ header: "Credit(s)",
1335
+ enableSorting: !0
1336
+ },
1337
+ {
1338
+ accessorKey: "collection_POINT_0_balance",
1339
+ accessorFn: (r) => {
1340
+ var i, S, T;
1341
+ return ee(((T = (S = (i = r.collection) == null ? void 0 : i.POINT) == null ? void 0 : S[0]) == null ? void 0 : T.balance) ?? 0, 2);
1342
+ },
1343
+ header: "Experience(s)",
1344
+ enableSorting: !0
1345
+ },
1346
+ {
1347
+ accessorKey: "collection_COIN_0_balance",
1348
+ accessorFn: (r) => {
1349
+ var i, S, T;
1350
+ return ee(((T = (S = (i = r.collection) == null ? void 0 : i.COIN) == null ? void 0 : S[0]) == null ? void 0 : T.balance) ?? 0, 2);
1351
+ },
1352
+ header: "Point(s)",
1353
+ enableSorting: !0
1354
+ },
1355
+ {
1356
+ accessorFn: (r) => {
1357
+ var i;
1358
+ return ((i = r.stats) == null ? void 0 : i.visitCount) ?? 0;
1359
+ },
1360
+ header: "Total visit",
1361
+ accessorKey: "stats.visitCount",
1362
+ id: "stats.visitCount"
1363
+ },
1364
+ {
1365
+ accessorFn: (r) => {
1366
+ var i;
1367
+ return (i = r.stats) == null ? void 0 : i.lastVisit;
1368
+ },
1369
+ sortingFn: (r, i) => {
1370
+ var S, T;
1371
+ return new Date((S = r.original.stats) == null ? void 0 : S.lastVisit).getTime() - new Date((T = i.original.stats) == null ? void 0 : T.lastVisit).getTime();
1372
+ },
1373
+ id: "stats.lastVisit",
1374
+ header: "Last visit",
1375
+ cell(r) {
1376
+ var i, S;
1377
+ return K("div", { class: "flex items-center justify-end gap-4" }, [
1378
+ K(
1379
+ "span",
1380
+ (i = r.row.original.stats) != null && i.lastVisit ? C((S = r.row.original.stats) == null ? void 0 : S.lastVisit).fromNow() : "NA"
1381
+ ),
1382
+ K(
1383
+ ve.FmTooltip,
1384
+ {
1385
+ content: C(r.row.original.stats.lastVisit).format(
1386
+ "D MMM YYYY - hh:mmA"
1387
+ )
1388
+ },
1389
+ [K(ve.FmIcon, { name: "info", outline: !0, size: "sm" })]
1390
+ )
1391
+ ]);
1392
+ }
1393
+ },
1394
+ {
1395
+ id: "actions",
1396
+ cell(r) {
1397
+ return K(
1398
+ ve.FmMenu,
1399
+ {
1400
+ placement: "bottom-end",
1401
+ onClick: (i) => {
1402
+ i.stopPropagation();
1403
+ }
1404
+ },
1405
+ {
1406
+ "menu-button": () => K(ve.FmButton, { icon: "more_vert", variant: "tertiary" }),
1407
+ default: () => [
1408
+ K(ve.FmMenuItem, {
1409
+ label: "Transaction details",
1410
+ onClick: async (i) => {
1411
+ i.stopPropagation(), await re(r.row.original._id);
1412
+ }
1413
+ })
1414
+ ]
1415
+ }
1416
+ );
1417
+ }
1418
+ }
1419
+ ], { tableMeta: d, rowData: w, onSort: m, debouncedFetchData: v, onSearch: I } = Ge(fe.read), N = G(), L = G(!1), P = G(), ce = H(() => x.locations.map((r) => ({
1420
+ label: r.name,
1421
+ value: r._id
1422
+ })));
1423
+ async function ae() {
1424
+ P.value = await fe.readById(
1425
+ P.value._id.toString()
1426
+ ), L.value = !0;
1427
+ }
1428
+ async function W() {
1429
+ await v(), L.value = !1;
1430
+ }
1431
+ async function re(r) {
1432
+ await o.push({
1433
+ name: Je["$connect-LOYALTY_MEMBER_TRANSACTIONS"],
1434
+ params: { id: r }
1435
+ });
1436
+ }
1437
+ const f = {
1438
+ sortBy: "_id",
1439
+ descending: !1,
1440
+ rowsPerPage: 1e3
1441
+ };
1442
+ function c(r) {
1443
+ const i = C(r);
1444
+ return i.isValid() ? i.format("DD/MM/YYYY") : "";
1445
+ }
1446
+ async function M() {
1447
+ const r = new lt(), i = f.rowsPerPage;
1448
+ await s(
1449
+ async () => {
1450
+ var O, E, R, te, z, F, J, a, e, b, D, B, X, se, de, ye, h, Y, oe, j, me, ue, pe, Q, Z;
1451
+ let S, T = !0;
1452
+ for (; T; ) {
1453
+ const we = await fe.readCursor({
1454
+ limit: i,
1455
+ sortBy: f.sortBy,
1456
+ descending: f.descending,
1457
+ ...S ? { cursor: S } : {}
1458
+ });
1459
+ if (!we.resources.length)
1460
+ break;
1461
+ for (const l of we.resources) {
1462
+ const Qe = (O = it.parseOneAddress(
1463
+ l == null ? void 0 : l.email
1464
+ )) != null && O.domain.includes("feedmepos.com") ? void 0 : l.email, Ze = (R = ((E = l == null ? void 0 : l.collection) == null ? void 0 : E.TITLE) || []) == null ? void 0 : R.reduce(
1465
+ (ne, ge) => {
1466
+ var Se, Ce;
1467
+ const _e = (Ce = (Se = p.sortedTitles) == null ? void 0 : Se.find(
1468
+ (Fe) => Fe._id === ge.collectible
1469
+ )) == null ? void 0 : Ce.name;
1470
+ return !_e || ge.balance <= 0 || ne.push(_e), ne;
1471
+ },
1472
+ []
1473
+ ), et = (p.sortedTitles || []).reduce(
1474
+ (ne, ge) => {
1475
+ var Se, Ce, Fe, Ne;
1476
+ const _e = (Ne = (Fe = (Ce = (((Se = l == null ? void 0 : l.collection) == null ? void 0 : Se.TITLE) || []).find(
1477
+ (nt) => nt.collectible === ge._id
1478
+ )) == null ? void 0 : Ce.expiryBalance) == null ? void 0 : Fe[0]) == null ? void 0 : Ne.expiredAt;
1479
+ return ne[ge.name] = _e ? C(_e).format("DD/MM/YYYY") : "", ne;
1480
+ },
1481
+ {}
1482
+ ), tt = ((F = (z = (te = l.collection) == null ? void 0 : te.CREDIT) == null ? void 0 : z.at(0)) == null ? void 0 : F.balance) || 0, $e = ((b = (e = (a = (J = l.collection) == null ? void 0 : J.CREDIT) == null ? void 0 : a.at(0)) == null ? void 0 : e.expiryBalance) == null ? void 0 : b.reduce(
1483
+ (ne, ge) => ne + ge.amount,
1484
+ 0
1485
+ )) || 0, De = ee(tt, 2), ot = {
1486
+ ID: l._id.toString(),
1487
+ Name: ((D = l.name) == null ? void 0 : D.trim()) || "",
1488
+ Phone: ((B = l == null ? void 0 : l.phoneNumber) == null ? void 0 : B.trim()) || "",
1489
+ Email: Qe || "",
1490
+ Gender: l.gender || "",
1491
+ CardNo: l.cardNo || "",
1492
+ Birthday: l != null && l.birthday ? c(l == null ? void 0 : l.birthday) : "",
1493
+ Credit: (Number(De) - Number($e)).toFixed(2),
1494
+ FreeCredit: Number($e.toFixed(2)),
1495
+ TotalCredit: Number(De),
1496
+ Exp: l != null && l.collection ? ((de = (se = (X = l.collection) == null ? void 0 : X.POINT) == null ? void 0 : se.at(0)) == null ? void 0 : de.balance) ?? 0 : 0,
1497
+ Point: l != null && l.collection ? ((Y = (h = (ye = l.collection) == null ? void 0 : ye.COIN) == null ? void 0 : h.at(0)) == null ? void 0 : Y.balance) ?? 0 : 0,
1498
+ Tier: l != null && l.collection ? ((me = (j = (oe = l.collection) == null ? void 0 : oe.TIER) == null ? void 0 : j.at(0)) == null ? void 0 : me.balance) ?? 0 : 0,
1499
+ Titles: Ze.join(","),
1500
+ ...et,
1501
+ TotalTransaction: l.stats.visitCount,
1502
+ AvgSpent: Ft(Number(l.stats.avgBillSize || 0)).toFormat(
1503
+ !1
1504
+ ),
1505
+ TotalSpent: l.stats.avgBillSize * l.stats.visitCount,
1506
+ LastVisit: c(l.stats.lastVisit),
1507
+ Feedback: ((ue = l.stats) == null ? void 0 : ue.feedbackCount) || 0,
1508
+ LastSeasonTierEarned: ((pe = l.stats) == null ? void 0 : pe.lastSeasonTierEarned) || 0,
1509
+ LastSeasonPointEarned: ((Q = l.stats) == null ? void 0 : Q.lastSeasonPointEarned) || 0,
1510
+ JoinedAt: c(l.joinAt || he(l._id)),
1511
+ JoinedAtLocation: l.location && ((Z = ce.value.find((ne) => ne.value == l.location)) == null ? void 0 : Z.label) || "-",
1512
+ VisitFrequency: `${Number(
1513
+ Math.ceil(l.stats.avgVisitFrequency).toFixed(0)
1514
+ )}`
1515
+ };
1516
+ r.addRecord(ot);
1517
+ }
1518
+ S = we.meta.nextCursor ?? void 0, T = we.meta.hasNext && !!S;
1519
+ }
1520
+ await ct(
1521
+ r.buildExcel(),
1522
+ `members-${(/* @__PURE__ */ new Date()).toISOString()}.xlsx`,
1523
+ {
1524
+ bookType: "xlsx",
1525
+ bookSST: !1,
1526
+ type: "array"
1527
+ }
1528
+ );
1529
+ },
1530
+ {
1531
+ message: "Exporting member...",
1532
+ successMessage: "Member exported successfully"
1533
+ }
1534
+ );
1535
+ }
1536
+ return je(async () => {
1537
+ await p.readMembership(), await x.readLocations(), await k.read(), await x.readLocations(), await v();
1538
+ }), (r, i) => {
1539
+ const S = V("FmSearch"), T = V("FmButton"), O = V("FmSnackbar");
1540
+ return u(), A("div", null, [
1541
+ n("div", Oo, [
1542
+ _(S, {
1543
+ class: "mt-4",
1544
+ modelValue: t(d).searchValue,
1545
+ "onUpdate:modelValue": [
1546
+ i[0] || (i[0] = (E) => t(d).searchValue = E),
1547
+ t(I)
1548
+ ],
1549
+ placeholder: "Search",
1550
+ collapsible: ""
1551
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
1552
+ _(T, {
1553
+ icon: "ios_share",
1554
+ variant: "tertiary",
1555
+ onClick: M
1556
+ })
1557
+ ]),
1558
+ Re(_(O, {
1559
+ "z-index": 0,
1560
+ class: "!max-w-full my-16",
1561
+ title: "Info",
1562
+ description: "Current list is not up to date, please refresh table for latest data.",
1563
+ variant: "info",
1564
+ dismissable: "",
1565
+ onOnDismiss: i[1] || (i[1] = (E) => L.value = !1),
1566
+ action: "Refresh",
1567
+ onOnAction: W
1568
+ }, null, 512), [
1569
+ [Le, t(L)]
1570
+ ]),
1571
+ _(He, {
1572
+ loading: t(d).isLoading,
1573
+ "row-data": t(w),
1574
+ "row-count": t(d).totalRows,
1575
+ "column-defs": g,
1576
+ "shrink-at": !1,
1577
+ "page-count": t(d).pageCount,
1578
+ "page-index": t(d).pageIndex,
1579
+ "page-size": t(d).pageSize,
1580
+ onSortChange: t(m),
1581
+ onPageChange: i[2] || (i[2] = (E) => t(v)({ pageSize: E.pageSize, pageIndex: E.pageIndex })),
1582
+ onRowClick: i[3] || (i[3] = (E) => {
1583
+ var R;
1584
+ P.value = E.original, (R = t(N)) == null || R.showSheet();
1585
+ })
1586
+ }, null, 8, ["loading", "row-data", "row-count", "page-count", "page-index", "page-size", "onSortChange"]),
1587
+ t(P) ? (u(), U(Po, {
1588
+ key: 0,
1589
+ ref_key: "sheetRef",
1590
+ ref: N,
1591
+ member: t(P),
1592
+ "onUpdate:member": ae
1593
+ }, null, 8, ["member"])) : le("", !0)
1594
+ ]);
1595
+ };
1596
+ }
1597
+ });
1598
+ export {
1599
+ hn as default
1600
+ };