@feedmepos/mf-connect 0.1.0-beta.9 → 0.1.1-prod

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 (102) hide show
  1. package/dist/Analytic-C2etD-eu.js +620 -0
  2. package/dist/{App-DQUbRsdA.js → App-DlRvkDpN.js} +58 -59
  3. package/dist/Broadcast-DpCGUS6r.js +216 -0
  4. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-D-BFllvG.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-Cj4IcH5D.js} +20 -20
  5. package/dist/Card-DjGC6jmq.js +823 -0
  6. package/dist/Collections-Q2pYWnJF.js +440 -0
  7. package/dist/Credit-DOIq2VYW.js +214 -0
  8. package/dist/{EditCampaignSheet.vue_vue_type_script_setup_true_lang-C_ZKNWzb.js → EditCampaignSheet.vue_vue_type_script_setup_true_lang-D7ML8ePp.js} +1010 -1026
  9. package/dist/EffectSheet.vue_vue_type_style_index_0_lang-CyxWG5I7.js +344 -0
  10. package/dist/Experience-DUst4I0H.js +211 -0
  11. package/dist/Game-CXnQR-wV.js +250 -0
  12. package/dist/ImageInput.vue_vue_type_script_setup_true_lang-ByhTB9Ie.js +144 -0
  13. package/dist/{LottieAnimation.vue_vue_type_script_setup_true_lang-CyGJxUol.js → MainLayout-DpZC6o3R.js} +53 -19
  14. package/dist/Marketing-CZfHsMFC.js +309 -0
  15. package/dist/Member-CX5Ohgeg.js +92 -0
  16. package/dist/MemberList-D8I3SaAs.js +1040 -0
  17. package/dist/MemberOverview-C2n9oJZh.js +58 -0
  18. package/dist/{MemberTransactions-zSxSnUkK.js → MemberTransactions-DfZNbCHD.js} +1 -1
  19. package/dist/MessageInput.vue_vue_type_script_setup_true_lang-BxFVEoBX.js +203 -0
  20. package/dist/Mission-S1pwDbqp.js +248 -0
  21. package/dist/Point-BdLUcGZy.js +220 -0
  22. package/dist/Promotion-DWAeQGkU.js +244 -0
  23. package/dist/{RuleGroup.vue_vue_type_script_setup_true_lang-CTKKhH-r.js → RuleGroup.vue_vue_type_script_setup_true_lang-Dux_NMO5.js} +577 -568
  24. package/dist/Segment-CXSE8Bzf.js +560 -0
  25. package/dist/Setting-CLuXuEId.js +1870 -0
  26. package/dist/Store-Be3cui0S.js +1533 -0
  27. package/dist/StoreRewards-zFy_w8p4.js +429 -0
  28. package/dist/{StoreTransactions.vue_vue_type_script_setup_true_lang-2Jqj_rKv.js → StoreTransactions.vue_vue_type_script_setup_true_lang-DxGJKgbc.js} +10 -10
  29. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-BkdSj0cX.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-Dreo45H1.js} +1 -1
  30. package/dist/{Tier-Cpl0FV8L.js → Tier-ChzcISYF.js} +453 -481
  31. package/dist/{Title-CbMDd1Et.js → Title-DQSjhBkT.js} +295 -314
  32. package/dist/Transaction-CeWmWpN_.js +36 -0
  33. package/dist/Voucher-BkLIxiZN.js +485 -0
  34. package/dist/ZodTextField.vue_vue_type_script_setup_true_lang-3LlSDiq0.js +140 -0
  35. package/dist/app-CLNirPsB.js +2974 -0
  36. package/dist/{app-VxaUCtgl.js → app-DuNsy0aC.js} +1 -1
  37. package/dist/app.js +3 -5
  38. package/dist/{business-DR7jpnLz.js → business-COGiTmLD.js} +1 -1
  39. package/dist/{campaign-MqcTb329.js → campaign-BHZMjQi5.js} +3 -5
  40. package/dist/{collection.fn-CvEoe61K.js → collection.fn-sAxtYO_r.js} +2 -2
  41. package/dist/dto-ndeeV_nc.js +1145 -0
  42. package/dist/{effect-BjjQeiQg.js → effect-BQt0rkdT.js} +9 -9
  43. package/dist/email-addresses-B3PazwKs.js +705 -0
  44. package/dist/{export-B8cvWh5n.js → export-D6r-xNji.js} +3 -3
  45. package/dist/{helper-DfgVNY7B.js → helper-CrjQw_Et.js} +1 -1
  46. package/dist/{index-CWR3qYjb.js → index-Btlj28Vg.js} +1 -1
  47. package/dist/{index-C7zMfUgy.js → index-Buy-yvAZ.js} +319 -304
  48. package/dist/{index-0UYoh1-7.js → index-C3AAy__p.js} +1 -1
  49. package/dist/index-CHAaFSD2.js +11 -0
  50. package/dist/{index-Dap5R3vr.js → index-Cg3RFxc9.js} +91 -102
  51. package/dist/{index-2P9w5u3m.js → index-CqpEhMr6.js} +4 -4
  52. package/dist/{index-BsfWRB8R.js → index-CvHj-wYi.js} +1 -1
  53. package/dist/index-DGLmbBnE.js +28997 -0
  54. package/dist/{index-CJ8Uh2Ja.js → index-DXpd07G3.js} +3 -3
  55. package/dist/{index-B5NufbUt.js → index-Daax_BQa.js} +1 -1
  56. package/dist/{index-C2JNcGc-.js → index-DrLEuIe1.js} +281 -299
  57. package/dist/{index-DBy30v8N.js → index-tSEYvA-2.js} +3 -3
  58. package/dist/{index.esm2017-D1X3PgpO.js → index.esm2017-a5BlZ76G.js} +55 -55
  59. package/dist/{loading-CJ3nOovJ.js → loading-B3XGyQ8W.js} +460 -469
  60. package/dist/{membership-B1cmSRyk.js → membership-GIOJ1ptN.js} +3 -3
  61. package/dist/money-z7VwzhZP.js +15 -0
  62. package/dist/number-DHYb2ua_.js +12 -0
  63. package/dist/{rule-builder-CSmOONdb.js → rule-builder-CcsWd5r9.js} +1 -1
  64. package/dist/{rule-ChWyR-0j.js → rule-iIEblTE4.js} +179 -177
  65. package/dist/style.css +1 -1
  66. package/dist/{template-Cug7aRK0.js → template-DMRMDZOW.js} +63 -63
  67. package/dist/{xlsx-CfgPFFvp.js → usePagination-CNFe0T2B.js} +3176 -2955
  68. package/package.json +5 -8
  69. package/dist/Analytic-CMXUjK_F.js +0 -622
  70. package/dist/Broadcast-DowFtHv6.js +0 -223
  71. package/dist/Card-C7rhL0pV.js +0 -825
  72. package/dist/Collections-B-1wlk3r.js +0 -453
  73. package/dist/Credit-DDjozmoF.js +0 -220
  74. package/dist/EffectSheet.vue_vue_type_style_index_0_lang-pwMuIgs5.js +0 -345
  75. package/dist/Experience-BbE-c1Op.js +0 -221
  76. package/dist/Game-DQdRpaN-.js +0 -255
  77. package/dist/ImageInput.vue_vue_type_script_setup_true_lang-rWUkV9gn.js +0 -144
  78. package/dist/MainLayout-B1aJoR95.js +0 -41
  79. package/dist/Marketing-Dgmxzg4h.js +0 -316
  80. package/dist/Member-w23oRVwN.js +0 -69
  81. package/dist/MemberList-BLIdjznQ.js +0 -1735
  82. package/dist/MemberOverview-wL_ailso.js +0 -58
  83. package/dist/MessageInput.vue_vue_type_script_setup_true_lang-Dy_lMdZA.js +0 -432
  84. package/dist/Mission-Cjt0E083.js +0 -261
  85. package/dist/Point-CQJL3Ewu.js +0 -222
  86. package/dist/Promotion-BYViH3bu.js +0 -247
  87. package/dist/Segment-B9Jj1ak0.js +0 -437
  88. package/dist/Setting-DXWbgRxs.js +0 -1901
  89. package/dist/Store-Dswk2e_z.js +0 -1511
  90. package/dist/StoreRewards-CNUhG_Ue.js +0 -401
  91. package/dist/Transaction-BB-kk-84.js +0 -39
  92. package/dist/Voucher-b1_Jlm6X.js +0 -490
  93. package/dist/ZodTextField.vue_vue_type_script_setup_true_lang-pG-SrXp9.js +0 -56
  94. package/dist/app-DCHKJoql.js +0 -5639
  95. package/dist/dto-jcK3TGB7.js +0 -2770
  96. package/dist/index-Cv7pLAYq.js +0 -3
  97. package/dist/index-LrSSauN2.js +0 -29193
  98. package/dist/money-BEATdGS6.js +0 -15
  99. package/dist/number-CeAYAKCp.js +0 -12
  100. package/dist/usePagination-BeF5K3M7.js +0 -223
  101. package/dist/vue-i18n-BRhKDHdF.js +0 -2365
  102. package/dist/zod-Bg2FbC-D.js +0 -90
@@ -0,0 +1,560 @@
1
+ import { defineComponent as K, onMounted as re, openBlock as h, createElementBlock as E, createElementVNode as s, toDisplayString as L, unref as o, createVNode as c, ref as j, computed as ce, resolveComponent as v, createBlock as Z, isRef as me, createSlots as ge, withCtx as S, Fragment as H, onBeforeMount as fe, renderList as ye, h as P } from "vue";
2
+ import { _ as _e } from "./campaign-CpzFl8Vr.js";
3
+ import { F as se, p as ve, u as he } from "./loading-B3XGyQ8W.js";
4
+ import { components as J } from "@feedmepos/ui-library";
5
+ import { a as de, _ as ue, w as Se } from "./usePagination-CNFe0T2B.js";
6
+ import { e as xe, M as we } from "./email-addresses-B3PazwKs.js";
7
+ import { _ as Fe, Z as Ce } from "./ZodTextField.vue_vue_type_script_setup_true_lang-3LlSDiq0.js";
8
+ import { a as Me } from "./index-tSEYvA-2.js";
9
+ import { u as ke } from "./app-wDQR6dpb.js";
10
+ import { R as Ie } from "./rule-builder-CcsWd5r9.js";
11
+ import { _ as Pe } from "./RuleGroup.vue_vue_type_script_setup_true_lang-Dux_NMO5.js";
12
+ import { h as V } from "./moment-BWErdI6_.js";
13
+ import { s as R, u as Re } from "./membership-GIOJ1ptN.js";
14
+ import { o as Ee } from "./objectId-dwaoBfJX.js";
15
+ import { u as $e } from "./business-COGiTmLD.js";
16
+ import { f as Be } from "./number-DHYb2ua_.js";
17
+ import { t as De } from "./money-z7VwzhZP.js";
18
+ import { m as ie } from "./index-C3AAy__p.js";
19
+ const Ye = Me.extend({
20
+ _id: se.optional(),
21
+ business: se.optional()
22
+ }), be = { class: "space-y-16 pr-12" }, Te = { class: "fm-typo-en-title-md-800" }, Ne = { class: "flex space-x-8" }, Ve = { class: "fm-typo-en-title-md-800 text-fm-color-primary" }, Le = { class: "text-fm-color-typo-secondary" }, ze = /* @__PURE__ */ s("div", null, "contacts in your segment", -1), Ae = /* @__PURE__ */ K({
23
+ __name: "ReviewSegment",
24
+ props: {
25
+ title: {},
26
+ segment: {}
27
+ },
28
+ setup(e) {
29
+ const d = e, x = [
30
+ {
31
+ header: "Name",
32
+ accessorFn: (n) => n.name
33
+ },
34
+ {
35
+ header: "Id",
36
+ accessorFn: (n) => n._id
37
+ },
38
+ {
39
+ header: "Customer Since",
40
+ accessorFn: (n) => V(Ee(n._id.toString())).format("DD MMM YYYY")
41
+ },
42
+ {
43
+ header: "Phone",
44
+ accessorFn: (n) => n.phoneNumber
45
+ },
46
+ {
47
+ header: "Birthday",
48
+ accessorFn: (n) => V(n.birthday).format("DD MMM YYYY")
49
+ },
50
+ {
51
+ header: "Last Visit",
52
+ accessorFn: (n) => V(n.stats.lastVisit).format("DD MMM YYYY")
53
+ }
54
+ ], w = async (n) => d.segment._id ? await R.paginateSegmentUsers(d.segment._id, {
55
+ limit: l.value.pageSize,
56
+ skip: n.pageIndex ?? 0,
57
+ sortBy: "_id",
58
+ search: n.searchValue,
59
+ descending: !0
60
+ }) : { resources: [], meta: { totalResources: 0, totalPages: 0 } }, { tableMeta: l, rowData: p, onSort: f, debouncedFetchData: u, onSearch: i } = de(w);
61
+ return re(async () => {
62
+ await u();
63
+ }), (n, F) => (h(), E("div", be, [
64
+ s("div", Te, L(d.title), 1),
65
+ s("div", Ne, [
66
+ s("div", Ve, L(n.segment.members.length), 1),
67
+ s("div", Le, [
68
+ ze,
69
+ s("div", null, "as of " + L(o(V)(n.segment.lastUpdated).format("DD MMM YYYY")), 1)
70
+ ])
71
+ ]),
72
+ c(ue, {
73
+ loading: o(l).isLoading,
74
+ "row-data": o(p),
75
+ "row-count": o(l).totalRows,
76
+ "column-defs": x,
77
+ "page-size": o(l).pageSize,
78
+ "page-count": o(l).pageCount,
79
+ "page-index": o(l).pageIndex,
80
+ onSortChange: o(f),
81
+ onPageChange: F[0] || (F[0] = (y) => o(u)({ pageSize: y.pageSize, pageIndex: y.pageIndex }))
82
+ }, null, 8, ["loading", "row-data", "row-count", "page-size", "page-count", "page-index", "onSortChange"])
83
+ ]));
84
+ }
85
+ }), Ue = { class: "flex items-center gap-x-8" }, Oe = /* @__PURE__ */ s("div", null, "Review segment", -1), je = {
86
+ key: 0,
87
+ class: "space-y-16 pr-12"
88
+ }, He = /* @__PURE__ */ s("div", { class: "fm-typo-en-title-sm-800" }, "Segment Filter", -1), qe = { class: "flex items-center gap-8" }, Ge = /* @__PURE__ */ K({
89
+ __name: "SegmentSheet",
90
+ emits: ["update:model-value"],
91
+ setup(e, { expose: d, emit: x }) {
92
+ const w = ke(), l = j(!1), p = j(!1), f = {
93
+ name: "",
94
+ rule: Ie.scaffoldGroup(),
95
+ members: []
96
+ }, u = Ye, i = j(f), n = ce(() => {
97
+ const a = u.safeParse(i.value);
98
+ return a.success ? [] : a.error.errors;
99
+ });
100
+ function F(a) {
101
+ l.value = !0, p.value = !1, a ? i.value = { ...a } : i.value = { ...f };
102
+ }
103
+ function y() {
104
+ l.value = !1;
105
+ }
106
+ async function $() {
107
+ u.safeParse(i.value).success && (p.value = !0);
108
+ }
109
+ function B() {
110
+ p.value = !1;
111
+ }
112
+ async function C() {
113
+ D("update:model-value", i.value);
114
+ }
115
+ re(async () => {
116
+ });
117
+ const D = x;
118
+ return d({
119
+ showSheet: F,
120
+ hideSheet: y
121
+ }), (a, t) => {
122
+ const m = v("FmButton"), M = v("FmSideSheet");
123
+ return h(), Z(M, {
124
+ modelValue: o(l),
125
+ "onUpdate:modelValue": t[5] || (t[5] = (r) => me(l) ? l.value = r : null),
126
+ header: "Add segment",
127
+ "dismiss-away": "",
128
+ "close-button": !0,
129
+ "max-width": 1100
130
+ }, ge({
131
+ "side-sheet-footer": S(() => [
132
+ s("div", qe, [
133
+ o(p) ? (h(), E(H, { key: 0 }, [
134
+ c(m, {
135
+ label: "Save Segment",
136
+ onClick: C,
137
+ loading: o(w).isLoading,
138
+ disabled: o(n).length > 0 || o(w).isLoading
139
+ }, null, 8, ["loading", "disabled"]),
140
+ c(m, {
141
+ label: "Cancel",
142
+ onClick: t[3] || (t[3] = (r) => B()),
143
+ variant: "tertiary"
144
+ })
145
+ ], 64)) : (h(), E(H, { key: 1 }, [
146
+ c(m, {
147
+ label: "Review Segment",
148
+ disabled: o(n).length > 0 || o(w).isLoading,
149
+ onClick: $
150
+ }, null, 8, ["disabled"]),
151
+ c(m, {
152
+ label: "Cancel",
153
+ onClick: t[4] || (t[4] = (r) => y()),
154
+ variant: "tertiary"
155
+ })
156
+ ], 64))
157
+ ])
158
+ ]),
159
+ default: S(() => {
160
+ var r;
161
+ return [
162
+ o(p) ? (h(), Z(Ae, {
163
+ key: 1,
164
+ title: o(i).name,
165
+ segment: o(i)
166
+ }, null, 8, ["title", "segment"])) : (h(), E("div", je, [
167
+ c(Fe, {
168
+ modelValue: o(i).name,
169
+ "onUpdate:modelValue": t[1] || (t[1] = (_) => o(i).name = _),
170
+ label: "Segment title",
171
+ schema: o(Ce).typeAtPath(o(u), "name")
172
+ }, null, 8, ["modelValue", "schema"]),
173
+ He,
174
+ c(Pe, {
175
+ "trigger-type": "MEMBERSHIP_JOINED",
176
+ includeOnly: "user",
177
+ "model-value": (r = o(i)) == null ? void 0 : r.rule,
178
+ "onUpdate:modelValue": t[2] || (t[2] = (_) => {
179
+ o(i).rule = _;
180
+ })
181
+ }, null, 8, ["model-value"])
182
+ ]))
183
+ ];
184
+ }),
185
+ _: 2
186
+ }, [
187
+ o(p) ? {
188
+ name: "side-sheet-header",
189
+ fn: S(() => [
190
+ s("div", Ue, [
191
+ c(m, {
192
+ icon: "arrow_back",
193
+ variant: "tertiary",
194
+ onClick: t[0] || (t[0] = (r) => p.value = !1)
195
+ }),
196
+ Oe
197
+ ])
198
+ ]),
199
+ key: "0"
200
+ } : void 0
201
+ ]), 1032, ["modelValue"]);
202
+ };
203
+ }
204
+ }), le = Re();
205
+ function W(e) {
206
+ const d = V(e);
207
+ return d.isValid() ? d.format("DD/MM/YYYY") : "";
208
+ }
209
+ const Je = {
210
+ mapMemberExportRow: (e) => {
211
+ var i, n, F, y, $, B, C, D, a, t, m, M, r, _, Y, b, T, N, q, g, z, Q, X, ee, te, oe, ae;
212
+ const d = (i = xe.parseOneAddress(
213
+ e == null ? void 0 : e.email
214
+ )) != null && i.domain.includes("feedmepos.com") ? void 0 : e.email, x = (F = ((n = e == null ? void 0 : e.collection) == null ? void 0 : n.TITLE) || []) == null ? void 0 : F.reduce(
215
+ (k, I) => {
216
+ var U, O;
217
+ const A = (O = (U = le.sortedTitles) == null ? void 0 : U.find(
218
+ (G) => G._id === I.collectible
219
+ )) == null ? void 0 : O.name;
220
+ return !A || I.balance <= 0 || k.push(A), k;
221
+ },
222
+ []
223
+ ), w = (le.sortedTitles || []).reduce(
224
+ (k, I) => {
225
+ var U, O, G, ne;
226
+ const A = (ne = (G = (O = (((U = e == null ? void 0 : e.collection) == null ? void 0 : U.TITLE) || []).find(
227
+ (pe) => pe.collectible === I._id
228
+ )) == null ? void 0 : O.expiryBalance) == null ? void 0 : G[0]) == null ? void 0 : ne.expiredAt;
229
+ return k[I.name] = A ? V(A).format("DD/MM/YYYY") : "", k;
230
+ },
231
+ {}
232
+ ), l = ((B = ($ = (y = e.collection) == null ? void 0 : y.CREDIT) == null ? void 0 : $.at(0)) == null ? void 0 : B.balance) || 0, p = ((t = (a = (D = (C = e.collection) == null ? void 0 : C.CREDIT) == null ? void 0 : D.at(0)) == null ? void 0 : a.expiryBalance) == null ? void 0 : t.reduce(
233
+ (k, I) => k + I.amount,
234
+ 0
235
+ )) || 0, f = Be(l, 2);
236
+ return {
237
+ ID: e._id.toString(),
238
+ Name: ((m = e.name) == null ? void 0 : m.trim()) || "",
239
+ Phone: ((M = e == null ? void 0 : e.phoneNumber) == null ? void 0 : M.trim()) || "",
240
+ Email: d || "",
241
+ Gender: e.gender || "",
242
+ CardNo: e.cardNo || "",
243
+ Birthday: W((e == null ? void 0 : e.birthday) || void 0),
244
+ Credit: parseFloat((Number(f) - Number(p)).toFixed(2)),
245
+ FreeCredit: Number(p.toFixed(2)),
246
+ TotalCredit: Number(f),
247
+ Exp: e != null && e.collection ? ((Y = (_ = (r = e.collection) == null ? void 0 : r.POINT) == null ? void 0 : _.at(0)) == null ? void 0 : Y.balance) ?? 0 : 0,
248
+ Point: e != null && e.collection ? ((N = (T = (b = e.collection) == null ? void 0 : b.COIN) == null ? void 0 : T.at(0)) == null ? void 0 : N.balance) ?? 0 : 0,
249
+ Level: e != null && e.collection ? ((z = (g = (q = e.collection) == null ? void 0 : q.TIER) == null ? void 0 : g.at(0)) == null ? void 0 : z.balance) ?? 0 : 0,
250
+ Tier: e != null && e.collection ? ((ee = (X = (Q = e.collection) == null ? void 0 : Q.TIER) == null ? void 0 : X.at(0)) == null ? void 0 : ee.balance) ?? 0 : 0,
251
+ Titles: x.join(","),
252
+ ...w,
253
+ TotalTransaction: e.stats.visitCount,
254
+ AvgSpent: De(Number(e.stats.avgBillSize || 0)).toFormat(
255
+ !1
256
+ ),
257
+ TotalSpent: e.stats.avgBillSize * e.stats.visitCount,
258
+ LastVisit: W(e.stats.lastVisit),
259
+ Feedback: ((te = e.stats) == null ? void 0 : te.feedbackCount) || 0,
260
+ LastSeasonTierEarned: ((oe = e.stats) == null ? void 0 : oe.lastSeasonTierEarned) || 0,
261
+ LastSeasonPointEarned: ((ae = e.stats) == null ? void 0 : ae.lastSeasonPointEarned) || 0,
262
+ JoinedAt: W(e.joinAt || void 0),
263
+ VisitFrequency: `${Number(
264
+ Math.ceil(e.stats.avgVisitFrequency).toFixed(0)
265
+ )}`
266
+ };
267
+ }
268
+ }, Ze = { class: "flex items-center" }, We = /* @__PURE__ */ s("span", { class: "fm-typo-en-title-md-600 fm-step-title line-clamp-2 mr-8" }, " Segments ", -1), Ke = { class: "px-24 flex flex-col gap-y-16" }, Qe = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, Xe = { class: "fm-typo-en-body-md-600" }, et = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, tt = /* @__PURE__ */ s("img", {
269
+ src: _e,
270
+ class: "aspect-square w-[150px]"
271
+ }, null, -1), ot = /* @__PURE__ */ s("div", { class: "flex flex-col gap-16 text-center" }, [
272
+ /* @__PURE__ */ s("div", { class: "fm-typo-en-title-sm-800" }, "Create customer segments"),
273
+ /* @__PURE__ */ s("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Segments allow you to categorize your customers based on various criteria, enabling targeted marketing and personalized experiences. ")
274
+ ], -1), xt = /* @__PURE__ */ K({
275
+ __name: "Segment",
276
+ setup(e) {
277
+ const { minor: d } = he, x = $e(), { mapMemberExportRow: w } = Je, l = j(0), p = [
278
+ {
279
+ header: "Name",
280
+ accessorFn: (a) => a.name
281
+ },
282
+ {
283
+ header: "Total Customers in this Segment",
284
+ accessorFn: (a) => a.memberCount ?? 0
285
+ },
286
+ {
287
+ header: "% of customers",
288
+ accessorFn: (a) => ((a.memberCount ?? 0) * 100 / l.value).toFixed(2)
289
+ },
290
+ {
291
+ header: "Actions",
292
+ meta: {
293
+ maxWidth: "100px"
294
+ },
295
+ cell(a) {
296
+ return P("div", { class: "flex items-center justify-end" }, [
297
+ P(
298
+ J.FmMenu,
299
+ {
300
+ placement: "bottom-end",
301
+ onClick: (t) => {
302
+ t.stopPropagation();
303
+ }
304
+ },
305
+ {
306
+ "menu-button": () => P(J.FmButton, {
307
+ icon: "more_vert",
308
+ iconColor: "neutral-gray-400",
309
+ variant: "tertiary"
310
+ }),
311
+ default: () => [
312
+ P(
313
+ J.FmMenuItem,
314
+ {
315
+ onClick: async (t) => {
316
+ t.stopPropagation(), $(a.row.original);
317
+ }
318
+ },
319
+ {
320
+ label: P(
321
+ "div",
322
+ {
323
+ class: "fm-typo-en-body-md-400"
324
+ },
325
+ "Export"
326
+ )
327
+ }
328
+ ),
329
+ P(
330
+ J.FmMenuItem,
331
+ {
332
+ onClick: async (t) => {
333
+ t.stopPropagation(), y(a.row.original);
334
+ }
335
+ },
336
+ {
337
+ label: P(
338
+ "div",
339
+ {
340
+ class: "text-fm-color-typo-error fm-typo-en-body-md-400"
341
+ },
342
+ "Remove"
343
+ )
344
+ }
345
+ )
346
+ ]
347
+ }
348
+ )
349
+ ]);
350
+ }
351
+ }
352
+ ], f = j(null), { tableMeta: u, rowData: i, debouncedFetchData: n } = de(
353
+ R.readAll
354
+ );
355
+ async function F() {
356
+ await d(
357
+ async () => {
358
+ await R.refreshSegments(), await n({ pageSize: 10, pageIndex: 0 });
359
+ },
360
+ { message: "Refreshing segmentations" }
361
+ );
362
+ }
363
+ async function y(a) {
364
+ await ve.remove(`Are you sure you want to remove ${a.name}?`) && await d(
365
+ async () => {
366
+ await R.delete(a._id), await n({ pageSize: 10, pageIndex: 0 });
367
+ },
368
+ {
369
+ message: `Removing ${a.name}`,
370
+ successMessage: `Removed ${a.name} successfully`
371
+ }
372
+ );
373
+ }
374
+ async function $(a) {
375
+ const t = {
376
+ sortBy: "_id",
377
+ descending: !1,
378
+ rowsPerPage: 1e3,
379
+ page: 1,
380
+ rowsNumber: 0
381
+ }, m = new we(), M = (await ie.read({
382
+ limit: 1,
383
+ skip: 0,
384
+ sortBy: t.sortBy,
385
+ descending: t.descending
386
+ })).meta.totalResources ?? 0, r = t.rowsPerPage;
387
+ await d(
388
+ async () => {
389
+ for (let _ = 0; _ < M; _ += r) {
390
+ const Y = {
391
+ ...t,
392
+ limit: r,
393
+ skip: t.page - 1,
394
+ sortBy: t.sortBy,
395
+ descending: t.descending
396
+ }, b = await R.paginateSegmentUsers(
397
+ a._id,
398
+ Y
399
+ );
400
+ for (const T of b.resources) {
401
+ const N = w(T);
402
+ m.addRecord(N);
403
+ }
404
+ t.page++;
405
+ }
406
+ await Se(
407
+ m.buildExcel(),
408
+ `[${a.name}]-members-${(/* @__PURE__ */ new Date()).toISOString()}.xlsx`,
409
+ {
410
+ bookType: "xlsx",
411
+ bookSST: !1,
412
+ type: "array"
413
+ }
414
+ ), t.page = 1;
415
+ },
416
+ {
417
+ message: "Exporting member...",
418
+ successMessage: "Member exported successfully"
419
+ }
420
+ );
421
+ }
422
+ async function B(a) {
423
+ await d(
424
+ async () => {
425
+ var t;
426
+ if (a._id) {
427
+ const { members: m, _id: M, ...r } = a;
428
+ await R.update(a._id, r);
429
+ } else
430
+ await R.create(a);
431
+ await n({ pageSize: 10, pageIndex: 0 }), (t = f.value) == null || t.hideSheet();
432
+ },
433
+ {
434
+ message: "Saving segment",
435
+ successMessage: "Segment saved"
436
+ }
437
+ );
438
+ }
439
+ function C(a) {
440
+ var t;
441
+ (t = f.value) == null || t.showSheet(a);
442
+ }
443
+ const D = ce(() => x.isPremium ? [
444
+ {
445
+ label: "Refresh segments",
446
+ value: "refresh"
447
+ },
448
+ {
449
+ label: "Add segment",
450
+ value: "add",
451
+ isPrimary: !0,
452
+ prependIcon: "add"
453
+ }
454
+ ] : []);
455
+ return fe(async () => {
456
+ const { meta: a } = await ie.read({
457
+ limit: 1,
458
+ skip: 0,
459
+ sortBy: "_id",
460
+ search: void 0,
461
+ descending: !1
462
+ });
463
+ l.value = a.totalResources ?? 0, await n({ pageSize: 10, pageIndex: 0 }), await x.readPremium();
464
+ }), (a, t) => {
465
+ const m = v("FmPill"), M = v("FmPageHead"), r = v("FmIcon"), _ = v("FmMenuItem"), Y = v("FmMenu"), b = v("FmListItem"), T = v("FmList"), N = v("FmButton"), q = v("FmCard");
466
+ return h(), E(H, null, [
467
+ c(M, {
468
+ title: "Segments",
469
+ actions: o(D),
470
+ "onClick:action": t[0] || (t[0] = (g) => g === "add" ? C() : F())
471
+ }, {
472
+ title: S(() => [
473
+ s("div", Ze, [
474
+ We,
475
+ c(m, { variant: "premium" })
476
+ ])
477
+ ]),
478
+ _: 1
479
+ }, 8, ["actions"]),
480
+ s("div", Ke, [
481
+ o(i).length > 0 || o(u).searchValue || o(u).isLoading ? (h(), E(H, { key: 0 }, [
482
+ c(ue, {
483
+ loading: o(u).isLoading,
484
+ "row-data": o(i),
485
+ "row-count": o(u).totalRows,
486
+ "column-defs": p,
487
+ "shrink-at": !1,
488
+ "page-count": o(u).pageCount,
489
+ "page-index": o(u).pageIndex,
490
+ "page-size": o(u).pageSize,
491
+ onRowClick: t[1] || (t[1] = (g) => {
492
+ C(g.original);
493
+ }),
494
+ onPageChange: o(n)
495
+ }, null, 8, ["loading", "row-data", "row-count", "page-count", "page-index", "page-size", "onPageChange"]),
496
+ c(T, { class: "w-full hidden xs:block" }, {
497
+ default: S(() => [
498
+ (h(!0), E(H, null, ye(o(i), (g) => (h(), Z(b, {
499
+ key: g._id.toString(),
500
+ tag: "label",
501
+ onClick: (z) => C(g)
502
+ }, {
503
+ default: S(() => [
504
+ s("div", null, [
505
+ s("div", Qe, L((g.memberCount ?? 0).toLocaleString()) + " total customers ", 1),
506
+ s("div", Xe, L(g.name), 1),
507
+ s("div", et, L(((g.memberCount ?? 0) * 100 / o(l)).toFixed(2)) + "% of customers ", 1)
508
+ ])
509
+ ]),
510
+ append: S(() => [
511
+ c(Y, { "stop-click-propagation": !0 }, {
512
+ "menu-button": S(() => [
513
+ c(r, { name: "more_vert" })
514
+ ]),
515
+ default: S(() => [
516
+ c(_, {
517
+ class: "text-fm-color-typo-error fm-typo-en-body-md-400",
518
+ label: "Remove",
519
+ "onUpdate:modelValue": (z) => z && y(g)
520
+ }, null, 8, ["onUpdate:modelValue"])
521
+ ]),
522
+ _: 2
523
+ }, 1024)
524
+ ]),
525
+ _: 2
526
+ }, 1032, ["onClick"]))), 128))
527
+ ]),
528
+ _: 1
529
+ })
530
+ ], 64)) : (h(), Z(q, {
531
+ key: 1,
532
+ variant: "outlined",
533
+ class: "w-full flex flex-col items-center justify-center gap-y-24 p-24"
534
+ }, {
535
+ default: S(() => [
536
+ tt,
537
+ ot,
538
+ c(N, {
539
+ variant: "primary",
540
+ label: "Create segment",
541
+ disabled: !o(x).isPremium,
542
+ icon: "add",
543
+ onClick: t[2] || (t[2] = (g) => C())
544
+ }, null, 8, ["disabled"])
545
+ ]),
546
+ _: 1
547
+ })),
548
+ c(Ge, {
549
+ ref_key: "sheetRef",
550
+ ref: f,
551
+ "onUpdate:modelValue": B
552
+ }, null, 512)
553
+ ])
554
+ ], 64);
555
+ };
556
+ }
557
+ });
558
+ export {
559
+ xt as default
560
+ };