@feedmepos/mf-connect 0.1.91-prod → 0.1.92-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 (96) hide show
  1. package/dist/{Analytic-NC-USqGi.js → Analytic-CpBxKgs9.js} +11 -11
  2. package/dist/{App-7D_MZN0d.js → App-B7AQKHNG.js} +7 -7
  3. package/dist/{Bin-60inU7_9.js → Bin-fMP89RQu.js} +8 -8
  4. package/dist/{Broadcast-BFMikTv0.js → Broadcast-CzakSN6g.js} +8 -8
  5. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-DrHHwGED.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-mpvpNP4k.js} +7 -7
  6. package/dist/{Card-vafU4dyU.js → Card-CBl-FP75.js} +19 -19
  7. package/dist/{Collections-BNSNZg7H.js → Collections-CSE9blWI.js} +8 -8
  8. package/dist/{Credit-Cy6YPGph.js → Credit-Ys2hpuhy.js} +8 -8
  9. package/dist/{EditCampaignSheet.vue_vue_type_script_setup_true_lang-7IXALR4_.js → EditCampaignSheet.vue_vue_type_script_setup_true_lang-8xKxU19h.js} +33 -33
  10. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-7Tanljx6.js → EffectSheet.vue_vue_type_style_index_0_lang-CCmIV0PO.js} +6 -6
  11. package/dist/{Experience-BVneXtjz.js → Experience-ldXxT64B.js} +8 -8
  12. package/dist/{FileSaver.min-DRZVt2c-.js → FileSaver.min-ChbDZYru.js} +1 -1
  13. package/dist/{Game-leXiqv6v.js → Game-CzNAKcbn.js} +9 -9
  14. package/dist/{ImageInput.vue_vue_type_script_setup_true_lang-bvPXAI2I.js → ImageInput.vue_vue_type_script_setup_true_lang-BWSlxKAt.js} +1 -1
  15. package/dist/{Index-BU3ubcCK.js → Index-BTg5_VLv.js} +10 -10
  16. package/dist/{LottieAnimation.vue_vue_type_script_setup_true_lang-DmnST0XL.js → LottieAnimation.vue_vue_type_script_setup_true_lang-CEX4A8Vu.js} +1 -1
  17. package/dist/{MainLayout-DfMxhjyZ.js → MainLayout-DTnxYJL-.js} +1 -1
  18. package/dist/{Marketing-DVZfv6KL.js → Marketing-CaFEmsay.js} +6 -6
  19. package/dist/{Member-C1UGjz3K.js → Member-BFfuRNc3.js} +12 -12
  20. package/dist/{MemberList-B51qk9PN.js → MemberList-BIOv6v6t.js} +27 -27
  21. package/dist/{MemberTransactions-XeeZVSj7.js → MemberTransactions-BeFVDHAh.js} +1 -1
  22. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-BZFh4LbN.js → MessageInput.vue_vue_type_script_setup_true_lang-BtiTqHlT.js} +9 -9
  23. package/dist/{Mission-_2ubnxed.js → Mission-D7-WUd8e.js} +9 -9
  24. package/dist/{Overview-Wtw2Gxca.js → Overview-wPnRJWSF.js} +19 -19
  25. package/dist/{Point-BWNPBISs.js → Point-B6K7s305.js} +8 -8
  26. package/dist/{Promotion-Cq1rta1U.js → Promotion-V9HF_-4a.js} +9 -9
  27. package/dist/{Queue-BislCglv.js → Queue-GxWELL-8.js} +15 -15
  28. package/dist/{Record-DllYWBQs.js → Record-D6xoFcc_.js} +9 -9
  29. package/dist/{Reward-DNnMSiIt.js → Reward-ChrJx3TQ.js} +16 -16
  30. package/dist/{RewardGroup.vue_vue_type_script_setup_true_lang-CYgKBX4A.js → RewardGroup.vue_vue_type_script_setup_true_lang-BzxTwBV9.js} +12 -12
  31. package/dist/{RuleGroup.vue_vue_type_script_setup_true_lang-CBLDHomx.js → RuleGroup.vue_vue_type_script_setup_true_lang-aDa4GkmZ.js} +15 -15
  32. package/dist/Segment-rI73g2Pf.js +1016 -0
  33. package/dist/{SelectItems.vue_vue_type_script_setup_true_lang-DaF39TyG.js → SelectItems.vue_vue_type_script_setup_true_lang-DqhqodSA.js} +2 -2
  34. package/dist/{SendCollectionSheet.vue_vue_type_script_setup_true_lang-vxFwpQoN.js → SendCollectionSheet.vue_vue_type_script_setup_true_lang-DmG2wWp8.js} +13 -13
  35. package/dist/{SendVoucherSheet.vue_vue_type_script_setup_true_lang-BBddcORt.js → SendVoucherSheet.vue_vue_type_script_setup_true_lang-nqcXkNuh.js} +4 -4
  36. package/dist/{Setting-Gt-j2X-h.js → Setting-BTBy21Dh.js} +14 -14
  37. package/dist/{SettingAdvertisements-CETtBWdy.js → SettingAdvertisements-DpQSHRt5.js} +29 -29
  38. package/dist/{Store-DxBaC_7y.js → Store-CDeDk5j3.js} +22 -22
  39. package/dist/{StoreRewards-CbmzaAnf.js → StoreRewards-B_sIvED1.js} +15 -15
  40. package/dist/{StoreTransactions.vue_vue_type_script_setup_true_lang-CB6y-TEk.js → StoreTransactions.vue_vue_type_script_setup_true_lang-C_jYgOxV.js} +21 -21
  41. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-Ckdg2H3D.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-CZgImaiL.js} +2 -2
  42. package/dist/{Tier-BRBr_4Vs.js → Tier-BqPORpVi.js} +22 -22
  43. package/dist/{Title-N1Aoum66.js → Title-DZFyfOvY.js} +21 -21
  44. package/dist/{Transaction-DzrBiUhw.js → Transaction-BicSfNsV.js} +2 -2
  45. package/dist/{UserRuleGroup.vue_vue_type_script_setup_true_lang-xtnyUh_C.js → UserRuleGroup.vue_vue_type_script_setup_true_lang-Bj7F_2lN.js} +6 -6
  46. package/dist/{Voucher-95IbNNON.js → Voucher-D5xZbzfU.js} +12 -12
  47. package/dist/{VoucherEditor.vue_vue_type_script_setup_true_lang-BOf9umaT.js → VoucherEditor.vue_vue_type_script_setup_true_lang-DQlzbuAg.js} +12 -12
  48. package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-vCA6xspO.js → ZodTextField.vue_vue_type_script_setup_true_lang-DAsm-iDs.js} +2 -2
  49. package/dist/{app-CSXjCxhe.js → app-D427_gmU.js} +193 -43
  50. package/dist/app.js +1 -1
  51. package/dist/{business-B1gGiOi3.js → business-DVT9-z7e.js} +1 -1
  52. package/dist/{campaign-CJ-3fIa_.js → campaign-BxeCSYow.js} +8 -8
  53. package/dist/{campaign-CTPJV80W.js → campaign-Cd2S6J2Z.js} +1 -1
  54. package/dist/{campaign.enum-C6mTkAc0.js → campaign.enum-BWx2XJCj.js} +1 -1
  55. package/dist/{campaign.fn-Dnq8oOA7.js → campaign.fn-C6_ucHrl.js} +93 -93
  56. package/dist/{collectible.enum-Bm9ym61N.js → collectible.enum-CMr5OBDH.js} +1 -1
  57. package/dist/{collection.fn-eGKUovTx.js → collection.fn-QKLnoDfT.js} +2 -2
  58. package/dist/{dto-BmlZ970m.js → dto-DGMbacfr.js} +4 -4
  59. package/dist/{effect-Fi165HuU.js → effect-BGkSRKmY.js} +1 -1
  60. package/dist/{email-addresses-CkqIxXsD.js → email-addresses-BAv5RfxW.js} +2 -2
  61. package/dist/{export-BINxBZ3o.js → export-1X3xd2lm.js} +3 -3
  62. package/dist/{helper-BJpoVem-.js → helper-CjJd9YN0.js} +1 -1
  63. package/dist/{index-ShgzGUii.js → index-8FtsTHd_.js} +3 -3
  64. package/dist/{index-CfEzixyr.js → index-BtOj2rTq.js} +1 -1
  65. package/dist/{index-CMnMUrQv.js → index-C-5iRXaD.js} +1 -1
  66. package/dist/{index-agtRTQ1_.js → index-CI3LvsAN.js} +334 -333
  67. package/dist/{index-D_D_KuCj.js → index-CTTeS30R.js} +1 -1
  68. package/dist/{index-Cg170bHf.js → index-CeC11VY5.js} +5 -7
  69. package/dist/{index-C-7bzCQ9.js → index-CqoU5D_S.js} +1341 -1147
  70. package/dist/{index-elY0gYnL.js → index-DVEBKqPp.js} +1 -1
  71. package/dist/{index-Ceebw9zT.js → index-DkEmFIqa.js} +1 -1
  72. package/dist/{index-msYk4Nww.js → index-DxbpoYQX.js} +1 -1
  73. package/dist/{index-BBTSDrdg.js → index-ueyNfpGe.js} +3 -3
  74. package/dist/{index-D2lJ7rbj.js → index-yF2I6Xtv.js} +6 -6
  75. package/dist/{index-BazRPGxz.js → index-yOug8IQK.js} +1 -1
  76. package/dist/{index.esm2017-CFwZeNKo.js → index.esm2017-DBFENth9.js} +1 -1
  77. package/dist/{loading-CWsuOmex.js → loading-X5Dle07s.js} +1 -1
  78. package/dist/{lodash-Cm9Z1YF2.js → lodash-CJtUEnSL.js} +1 -1
  79. package/dist/{membership-DMInG-QR.js → membership-CKuQtReq.js} +38 -18
  80. package/dist/{money-COObXSez.js → money-C99PNkQ0.js} +1 -1
  81. package/dist/{number-ZsyBuNFr.js → number-C42NY90L.js} +1 -1
  82. package/dist/{objectid-Tx-E_slw.js → objectid-B5SRENL3.js} +9 -9
  83. package/dist/{plugins-CvqTFq6l.js → plugins-0yAaVVcL.js} +3 -3
  84. package/dist/{reward-BDSUzN0_.js → reward-eIVX1EnX.js} +1 -1
  85. package/dist/{rule-BzWFD4lu.js → rule-BsTx8uRy.js} +3 -3
  86. package/dist/{rule-builder-y5PUkSk9.js → rule-builder-DxJBecU0.js} +1 -1
  87. package/dist/{template-CO3A7_3t.js → template-vPfeVxs-.js} +7 -7
  88. package/dist/{timezone-ClbAM0Sw.js → timezone-CzWr1nhO.js} +2 -2
  89. package/dist/{trigger-DGoPndhx.js → trigger-BSEdMaKu.js} +12 -12
  90. package/dist/{usePagination-COHUplyH.js → usePagination-BnISBBlq.js} +1 -1
  91. package/dist/{user-CnDTKRSl.js → user-CUOEkvb1.js} +1 -1
  92. package/dist/{vue-i18n-X1TYXdQD.js → vue-i18n-CdwtjeYd.js} +287 -287
  93. package/dist/{xlsx-W_9bPRI8.js → xlsx-DOd1PS56.js} +166 -166
  94. package/dist/{zod-D9xVg76J.js → zod-_h5DNk2u.js} +1 -1
  95. package/package.json +1 -1
  96. package/dist/Segment-BawFn2kF.js +0 -882
@@ -0,0 +1,1016 @@
1
+ import { defineComponent as le, ref as W, resolveComponent as x, openBlock as r, createElementBlock as k, createElementVNode as s, createVNode as d, unref as e, createCommentVNode as K, withCtx as $, Fragment as Z, renderList as me, createBlock as V, toDisplayString as D, normalizeClass as ce, computed as O, onMounted as we, isRef as Te, createSlots as Ee, h as B, onBeforeMount as De } from "vue";
2
+ import { _ as $e } from "./campaign-CpzFl8Vr.js";
3
+ import { n as Ae, p as Pe } from "./plugins-0yAaVVcL.js";
4
+ import { u as Re } from "./loading-X5Dle07s.js";
5
+ import { FmButtonVariant as re, useSnackbar as Ne, components as ae } from "@feedmepos/ui-library";
6
+ import { u as Fe, _ as Ce } from "./usePagination-BnISBBlq.js";
7
+ import { u as pe } from "./vue-i18n-CdwtjeYd.js";
8
+ import { i as Be, j as U, D as Ue, k as Ve, c as ye } from "./index-CqoU5D_S.js";
9
+ import "./index-CeC11VY5.js";
10
+ import { F as ge, z as Le } from "./index-8FtsTHd_.js";
11
+ import "./index-yF2I6Xtv.js";
12
+ import "./index-BtOj2rTq.js";
13
+ import "./index-ueyNfpGe.js";
14
+ import { u as de, w as ke } from "./xlsx-DOd1PS56.js";
15
+ import { e as Ye, M as ze } from "./email-addresses-BAv5RfxW.js";
16
+ import { Z as Oe } from "./zod-_h5DNk2u.js";
17
+ import { u as je } from "./app-wDQR6dpb.js";
18
+ import { R as ve } from "./rule-builder-DxJBecU0.js";
19
+ import { _ as qe } from "./ZodTextField.vue_vue_type_script_setup_true_lang-DAsm-iDs.js";
20
+ import { _ as Ge } from "./RuleGroup.vue_vue_type_script_setup_true_lang-aDa4GkmZ.js";
21
+ import { u as He, v as Ke, w as Je } from "./index.esm2017-DBFENth9.js";
22
+ import { F as Qe } from "./FileSaver.min-ChbDZYru.js";
23
+ import { h as se } from "./moment-D7p2TMB-.js";
24
+ import { s as z, u as We } from "./membership-CKuQtReq.js";
25
+ import { o as Ze } from "./objectId-dwaoBfJX.js";
26
+ import { J as Xe } from "./JsonViewer-v8_C7l5N.js";
27
+ import { u as Ie } from "./business-DVT9-z7e.js";
28
+ import { f as et } from "./number-C42NY90L.js";
29
+ import { t as tt } from "./money-C99PNkQ0.js";
30
+ import "./index-yOug8IQK.js";
31
+ import { useRouter as ot } from "vue-router";
32
+ import { m as _e } from "./index-DkEmFIqa.js";
33
+ import { R as Se } from "./app-D427_gmU.js";
34
+ const nt = Be.extend({
35
+ _id: ge.optional(),
36
+ business: ge.optional(),
37
+ file: Le.any().nullish()
38
+ });
39
+ var at = { firebase: { apiKey: "AIzaSyA_isPR1-9bX7UmRiJIhsIRNNwdn6DdmW4", authDomain: "feedme-253402.firebaseapp.com", databaseURL: "https://feedme-253402.firebaseio.com", projectId: "feedme-253402", storageBucket: "image.feedme.cc", messagingSenderId: "128512026847", appId: "1:128512026847:web:7c5c8ab7e8b90502dc616a", measurementId: "G-LTKS7N2HQS" }, assetBucketUrl: "static.feedme.cc", importFilesBucketUrl: "feedme-253402.appspot.com", clientId: "d5f8840d63dbb758b6c4ee2a5e8b013d15dd25e242c457481326062b83962476" };
40
+ const st = { class: "flex flex-col space-y-16" }, lt = {
41
+ key: 0,
42
+ class: /* @__PURE__ */ ce([
43
+ "p-16 pl-24 space-x-8",
44
+ "bg-fm-color-primary-oats rounded-lg",
45
+ "flex items-center",
46
+ "justify-between"
47
+ ])
48
+ }, it = { class: "flex justify-end" }, ct = {
49
+ key: 1,
50
+ class: /* @__PURE__ */ ce([
51
+ "flex items-center",
52
+ "border border-fm-color-neutral-gray-300",
53
+ "p-16 space-x-16 rounded-md"
54
+ ])
55
+ }, rt = { class: "fm-typo-en-body-lg-400 flex-1 truncate" }, dt = /* @__PURE__ */ le({
56
+ __name: "ImportSegment",
57
+ props: {
58
+ importFile: {}
59
+ },
60
+ emits: ["update:file"],
61
+ setup(t, { emit: f }) {
62
+ const c = t, M = f, { t: b } = pe(), _ = W(null), u = W(null), T = ["Id"], E = [
63
+ {
64
+ label: "CSV",
65
+ icon: "csv",
66
+ value: "csv"
67
+ },
68
+ {
69
+ label: "Excel",
70
+ icon: "description",
71
+ value: "xlsx"
72
+ }
73
+ ];
74
+ async function a() {
75
+ if (c.importFile)
76
+ try {
77
+ const y = He(void 0, at.importFilesBucketUrl), p = Ke(y, c.importFile), g = await Je(p);
78
+ window.open(g, "_blank");
79
+ } catch (y) {
80
+ console.log(y), Ae.error("Failed to download uploaded file");
81
+ }
82
+ }
83
+ async function m(y) {
84
+ switch (y) {
85
+ case "csv":
86
+ const p = new Blob([T.join(",")], {
87
+ type: "text/csv;charset=utf-8;"
88
+ });
89
+ Qe.saveAs(p, "ImportSegmentTemplate.csv");
90
+ break;
91
+ case "xlsx":
92
+ const g = de.aoa_to_sheet([T]), S = de.book_new();
93
+ de.book_append_sheet(S, g, "Sheet1"), ke(S, "ImportSegmentTemplate.xlsx");
94
+ break;
95
+ }
96
+ }
97
+ function i(y) {
98
+ _.value = y, M("update:file", _.value);
99
+ }
100
+ function A(y) {
101
+ var g, S;
102
+ const p = ((S = (g = y.target) == null ? void 0 : g.files) == null ? void 0 : S[0]) ?? null;
103
+ i(p);
104
+ }
105
+ return (y, p) => {
106
+ const g = x("FmButton"), S = x("FmMenuItem"), j = x("FmMenu"), q = x("FmDropField");
107
+ return r(), k("div", st, [
108
+ p[2] || (p[2] = s("div", { class: "fm-typo-en-title-sm-800" }, "Upload File", -1)),
109
+ t.importFile ? (r(), k("div", lt, [
110
+ d(g, {
111
+ label: e(b)("View uploaded file"),
112
+ variant: e(re).Plain,
113
+ icon: "file_present",
114
+ onClick: a
115
+ }, null, 8, ["label", "variant"])
116
+ ])) : K("", !0),
117
+ s("div", null, [
118
+ s("div", it, [
119
+ d(j, { class: "" }, {
120
+ "menu-button": $(() => [
121
+ d(g, {
122
+ variant: "tertiary",
123
+ icon: "download",
124
+ label: "Download Template"
125
+ })
126
+ ]),
127
+ default: $(() => [
128
+ (r(), k(Z, null, me(E, (I) => d(S, {
129
+ key: I.value,
130
+ icon: I.icon,
131
+ label: I.label,
132
+ onClick: (G) => m(I.value),
133
+ selectable: ""
134
+ }, null, 8, ["icon", "label", "onClick"])), 64))
135
+ ]),
136
+ _: 1
137
+ })
138
+ ]),
139
+ _.value ? (r(), k("div", ct, [
140
+ d(g, {
141
+ variant: e(re).Tertiary,
142
+ "prepend-icon": "attach_file"
143
+ }, null, 8, ["variant"]),
144
+ s("p", rt, D(_.value.name), 1),
145
+ s("label", {
146
+ ref_key: "fileLabelRef",
147
+ ref: u,
148
+ htmlFor: "file"
149
+ }, [
150
+ d(g, {
151
+ variant: e(re).Plain,
152
+ label: e(b)("Replace File"),
153
+ onClick: p[1] || (p[1] = () => {
154
+ var I;
155
+ return (I = u.value) == null ? void 0 : I.click();
156
+ })
157
+ }, null, 8, ["variant", "label"]),
158
+ s("input", {
159
+ id: "file",
160
+ accept: ".csv",
161
+ class: "hidden",
162
+ type: "file",
163
+ multiple: "",
164
+ onChange: A
165
+ }, null, 32)
166
+ ], 512)
167
+ ])) : (r(), V(q, {
168
+ key: 0,
169
+ onFileUpload: p[0] || (p[0] = (I) => i(I)),
170
+ accept: ".csv, .xlsx",
171
+ "max-file-size": 2e7
172
+ }))
173
+ ])
174
+ ]);
175
+ };
176
+ }
177
+ }), ut = { class: "space-y-16 pr-12" }, mt = { class: "fm-typo-en-title-md-800" }, pt = { class: "flex space-x-8" }, ft = { class: "fm-typo-en-title-md-800 text-fm-color-primary" }, yt = { class: "text-fm-color-typo-secondary" }, xe = /* @__PURE__ */ le({
178
+ __name: "ReviewSegment",
179
+ props: {
180
+ title: {},
181
+ segment: {}
182
+ },
183
+ setup(t) {
184
+ const f = t, c = O(
185
+ () => f.segment.memberCount ?? f.segment.members.length
186
+ ), M = O(
187
+ () => f.segment.lastUpdated ? se(f.segment.lastUpdated).format("DD MMM YYYY") : "Not refreshed yet"
188
+ ), b = [
189
+ {
190
+ header: "Name",
191
+ accessorFn: (i) => i.name
192
+ },
193
+ {
194
+ header: "Id",
195
+ accessorFn: (i) => i._id
196
+ },
197
+ {
198
+ header: "Customer Since",
199
+ accessorFn: (i) => se(Ze(i._id.toString())).format("DD MMM YYYY")
200
+ },
201
+ {
202
+ header: "Phone",
203
+ accessorFn: (i) => i.phoneNumber
204
+ },
205
+ {
206
+ header: "Birthday",
207
+ accessorFn: (i) => se(i.birthday).format("DD MMM YYYY")
208
+ },
209
+ {
210
+ header: "Last Visit",
211
+ accessorFn: (i) => se(i.stats.lastVisit).format("DD MMM YYYY")
212
+ }
213
+ ];
214
+ async function _(i) {
215
+ return f.segment._id ? (console.log(i), await z.paginateSegmentUsers(
216
+ f.segment._id,
217
+ i
218
+ )) : {
219
+ resources: [],
220
+ meta: {
221
+ totalResources: 0,
222
+ totalPages: 0,
223
+ skip: i.skip,
224
+ limit: i.limit,
225
+ sortBy: i.sortBy
226
+ }
227
+ };
228
+ }
229
+ const { tableMeta: u, rowData: T, onSort: E, debouncedFetchData: a, onSearch: m } = Fe(_);
230
+ return we(async () => {
231
+ await a();
232
+ }), (i, A) => (r(), k("div", ut, [
233
+ s("div", mt, D(f.title), 1),
234
+ s("div", pt, [
235
+ s("div", ft, D(e(c)), 1),
236
+ s("div", yt, [
237
+ A[1] || (A[1] = s("div", null, "contacts in your segment", -1)),
238
+ s("div", null, "as of " + D(e(M)), 1)
239
+ ])
240
+ ]),
241
+ d(Ce, {
242
+ loading: e(u).isLoading,
243
+ "row-data": e(T),
244
+ "row-count": e(u).totalRows,
245
+ "column-defs": b,
246
+ "page-size": e(u).pageSize,
247
+ "page-count": e(u).pageCount,
248
+ "page-index": e(u).pageIndex,
249
+ onSortChange: e(E),
250
+ onPageChange: A[0] || (A[0] = (y) => e(a)({ pageSize: y.pageSize, pageIndex: y.pageIndex }))
251
+ }, null, 8, ["loading", "row-data", "row-count", "page-size", "page-count", "page-index", "onSortChange"])
252
+ ]));
253
+ }
254
+ }), gt = { class: "space-y-24" }, vt = { class: "grid grid-cols-2 gap-16" }, _t = { class: "fm-typo-en-title-sm-800" }, St = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, xt = /* @__PURE__ */ le({
255
+ __name: "SegmentTypeOption",
256
+ props: {
257
+ modelValue: {},
258
+ errorText: {}
259
+ },
260
+ emits: ["update:model-value"],
261
+ setup(t, { emit: f }) {
262
+ const c = t, M = f, b = [
263
+ {
264
+ label: "Dynamic",
265
+ sublabel: "Segment statistics are based on rules configured and will be recalculated automatically when rule changes.",
266
+ value: U.enum.DYNAMIC
267
+ },
268
+ {
269
+ label: "Static",
270
+ sublabel: "Segment statistics are based on imported data and will not be recalculated.",
271
+ value: U.enum.STATIC
272
+ }
273
+ ];
274
+ function _(u) {
275
+ u !== c.modelValue && M("update:model-value", u);
276
+ }
277
+ return (u, T) => {
278
+ const E = x("FmCard"), a = x("FmHelperText");
279
+ return r(), k("div", gt, [
280
+ s("div", vt, [
281
+ (r(), k(Z, null, me(b, (m) => d(E, {
282
+ variant: "outlined",
283
+ class: ce(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-2", {
284
+ "col-span-2": b.length == 1,
285
+ "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": t.modelValue === m.value,
286
+ "hover:bg-fm-color-opacity-sm": t.modelValue !== m.value
287
+ }]),
288
+ onClick: (i) => _(m.value),
289
+ key: m.value
290
+ }, {
291
+ default: $(() => [
292
+ s("div", _t, D(m.label), 1),
293
+ s("div", St, D(m.sublabel), 1)
294
+ ]),
295
+ _: 2
296
+ }, 1032, ["class", "onClick"])), 64))
297
+ ]),
298
+ t.errorText ? (r(), V(a, {
299
+ key: 0,
300
+ class: "!mt-4",
301
+ text: t.errorText,
302
+ state: "error"
303
+ }, null, 8, ["text"])) : K("", !0)
304
+ ]);
305
+ };
306
+ }
307
+ }), ht = { class: "flex items-center gap-x-8" }, bt = {
308
+ key: 0,
309
+ class: "space-y-16 pr-12"
310
+ }, wt = {
311
+ key: 0,
312
+ class: "flex flex-col gap-12"
313
+ }, Ft = { class: "flex flex-wrap items-center gap-8" }, Ct = { class: "fm-typo-en-title-sm-800" }, kt = { class: "flex flex-col gap-4" }, It = { class: "fm-typo-en-body-md-600 text-fm-color-typo-primary" }, Mt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Tt = {
314
+ key: 2,
315
+ class: "flex flex-col space-y-16"
316
+ }, Et = {
317
+ key: 3,
318
+ class: "flex flex-col space-y-16"
319
+ }, Dt = {
320
+ key: 4,
321
+ class: "flex flex-col space-y-16"
322
+ }, $t = {
323
+ key: 5,
324
+ class: "flex flex-col space-y-16"
325
+ }, At = { class: "flex items-center gap-8" }, Pt = /* @__PURE__ */ le({
326
+ __name: "SegmentSheet",
327
+ emits: ["update:model-value"],
328
+ setup(t, { expose: f, emit: c }) {
329
+ const M = je(), { t: b } = pe(), _ = W(!1), u = W(!1), T = {
330
+ name: "",
331
+ isActive: !0,
332
+ type: U.enum.DYNAMIC,
333
+ rule: ve.scaffoldGroup(),
334
+ members: []
335
+ }, E = nt, a = W(T), m = O(() => !!a.value.defaultKey), i = O(
336
+ () => a.value.defaultKey ? `connect.loyalty.segment.default_segments.${a.value.defaultKey.toLowerCase()}` : void 0
337
+ ), A = O(
338
+ () => i.value ? b(`${i.value}.name`) : a.value.name
339
+ ), y = O(() => {
340
+ const v = a.value.defaultKey;
341
+ return v ? b(Ue[v]) : a.value.description ?? "";
342
+ }), p = O(() => {
343
+ const v = E.safeParse(a.value);
344
+ return v.success ? [] : v.error.errors;
345
+ });
346
+ function g(v) {
347
+ _.value = !0, u.value = !1, v ? a.value = {
348
+ ...v,
349
+ isActive: v.isActive !== !1,
350
+ type: v.type ?? (v.importFile ? U.enum.STATIC : U.enum.DYNAMIC)
351
+ } : a.value = { ...T };
352
+ }
353
+ function S() {
354
+ _.value = !1;
355
+ }
356
+ async function j() {
357
+ E.safeParse(a.value).success && (u.value = !0);
358
+ }
359
+ function q(v) {
360
+ v === U.enum.STATIC ? S() : u.value = !1;
361
+ }
362
+ async function I() {
363
+ a.value.type === U.enum.STATIC ? (a.value.rule = ve.scaffoldGroup(), a.value.isActive = !0) : a.value.file = void 0, J("update:model-value", a.value);
364
+ }
365
+ async function G(v) {
366
+ a.value.type = v;
367
+ }
368
+ we(async () => {
369
+ });
370
+ const J = c;
371
+ return f({
372
+ showSheet: g,
373
+ hideSheet: S
374
+ }), (v, l) => {
375
+ const P = x("FmButton"), X = x("FmChip"), ee = x("FmCard"), te = x("FmSwitch"), o = x("FmSideSheet");
376
+ return r(), V(o, {
377
+ modelValue: e(_),
378
+ "onUpdate:modelValue": l[9] || (l[9] = (n) => Te(_) ? _.value = n : null),
379
+ header: e(m) ? e(b)("connect.loyalty.segment.default_segments.default_segment") : e(a)._id ? "Edit segment" : "Add segment",
380
+ "dismiss-away": "",
381
+ "close-button": !0,
382
+ "max-width": 1100
383
+ }, Ee({
384
+ "side-sheet-footer": $(() => [
385
+ s("div", At, [
386
+ e(m) ? (r(), V(P, {
387
+ key: 0,
388
+ label: e(b)("connect.loyalty.segment.default_segments.close"),
389
+ onClick: l[6] || (l[6] = (n) => S()),
390
+ variant: "tertiary"
391
+ }, null, 8, ["label"])) : e(u) || e(a).type === e(U).enum.STATIC ? (r(), k(Z, { key: 1 }, [
392
+ d(P, {
393
+ label: "Save Segment",
394
+ onClick: I,
395
+ loading: e(M).isLoading,
396
+ disabled: e(p).length > 0 || e(M).isLoading
397
+ }, null, 8, ["loading", "disabled"]),
398
+ d(P, {
399
+ label: "Cancel",
400
+ onClick: l[7] || (l[7] = (n) => q(e(a).type)),
401
+ variant: "tertiary"
402
+ })
403
+ ], 64)) : (r(), k(Z, { key: 2 }, [
404
+ d(P, {
405
+ label: "Review Segment",
406
+ disabled: e(p).length > 0 || e(M).isLoading,
407
+ onClick: j
408
+ }, null, 8, ["disabled"]),
409
+ d(P, {
410
+ label: "Cancel",
411
+ onClick: l[8] || (l[8] = (n) => S()),
412
+ variant: "tertiary"
413
+ })
414
+ ], 64))
415
+ ])
416
+ ]),
417
+ default: $(() => {
418
+ var n, F;
419
+ return [
420
+ d(Xe, { json: e(a) }, null, 8, ["json"]),
421
+ e(u) ? (r(), V(xe, {
422
+ key: 1,
423
+ title: e(a).name,
424
+ segment: e(a)
425
+ }, null, 8, ["title", "segment"])) : (r(), k("div", bt, [
426
+ e(m) ? (r(), k("div", wt, [
427
+ s("div", Ft, [
428
+ s("div", Ct, D(e(A)), 1),
429
+ d(X, {
430
+ label: e(b)("connect.loyalty.segment.default_segments.system"),
431
+ compact: "",
432
+ class: "text-fm-color-typo-info bg-fm-color-system-info-100"
433
+ }, null, 8, ["label"])
434
+ ]),
435
+ d(ee, {
436
+ variant: "outlined",
437
+ class: "p-16"
438
+ }, {
439
+ default: $(() => [
440
+ s("div", kt, [
441
+ s("div", It, D(e(b)("connect.loyalty.segment.default_segments.description")), 1),
442
+ s("div", Mt, D(e(y)), 1)
443
+ ])
444
+ ]),
445
+ _: 1
446
+ })
447
+ ])) : (r(), V(qe, {
448
+ key: 1,
449
+ modelValue: e(a).name,
450
+ "onUpdate:modelValue": l[1] || (l[1] = (w) => e(a).name = w),
451
+ label: "Segment title",
452
+ schema: e(Oe).typeAtPath(e(E), "name")
453
+ }, null, 8, ["modelValue", "schema"])),
454
+ e(m) ? K("", !0) : (r(), k("div", Tt, [
455
+ l[11] || (l[11] = s("div", { class: "fm-typo-en-title-sm-800" }, "Segment Type", -1)),
456
+ d(xt, {
457
+ "model-value": e(a).type,
458
+ "onUpdate:modelValue": l[2] || (l[2] = (w) => {
459
+ G(w);
460
+ })
461
+ }, null, 8, ["model-value"])
462
+ ])),
463
+ e(a).type === e(U).enum.DYNAMIC && !e(m) ? (r(), k("div", Et, [
464
+ l[12] || (l[12] = s("div", { class: "fm-typo-en-title-sm-800" }, "Segment Filter", -1)),
465
+ d(Ge, {
466
+ "trigger-type": "MEMBERSHIP_JOINED",
467
+ includeOnly: "user",
468
+ "model-value": (n = e(a)) == null ? void 0 : n.rule,
469
+ "onUpdate:modelValue": l[3] || (l[3] = (w) => {
470
+ e(a).rule = w;
471
+ })
472
+ }, null, 8, ["model-value"])
473
+ ])) : e(m) ? K("", !0) : (r(), k("div", Dt, [
474
+ d(dt, {
475
+ importFile: e(a).importFile,
476
+ "onUpdate:file": l[4] || (l[4] = (w) => {
477
+ e(a).file = w;
478
+ })
479
+ }, null, 8, ["importFile"])
480
+ ])),
481
+ e(a).type === e(U).enum.DYNAMIC && !e(m) ? (r(), k("div", $t, [
482
+ l[13] || (l[13] = s("div", { class: "fm-typo-en-title-sm-800" }, "Segment Status", -1)),
483
+ d(te, {
484
+ "model-value": e(a).isActive ?? !0,
485
+ "onUpdate:modelValue": l[5] || (l[5] = (w) => e(a).isActive = w),
486
+ label: "Active",
487
+ sublabel: "When enabled, this will recalculate the segment statistics daily.",
488
+ "label-placement": "right"
489
+ }, null, 8, ["model-value"])
490
+ ])) : K("", !0),
491
+ e(m) ? (r(), V(xe, {
492
+ key: (F = e(a)._id) == null ? void 0 : F.toString(),
493
+ title: e(b)("connect.loyalty.segment.default_segments.members"),
494
+ segment: e(a)
495
+ }, null, 8, ["title", "segment"])) : K("", !0)
496
+ ]))
497
+ ];
498
+ }),
499
+ _: 2
500
+ }, [
501
+ e(u) && !e(m) ? {
502
+ name: "side-sheet-header",
503
+ fn: $(() => [
504
+ s("div", ht, [
505
+ d(P, {
506
+ icon: "arrow_back",
507
+ variant: "tertiary",
508
+ onClick: l[0] || (l[0] = (n) => u.value = !1)
509
+ }),
510
+ l[10] || (l[10] = s("div", null, "Review segment", -1))
511
+ ])
512
+ ]),
513
+ key: "0"
514
+ } : void 0
515
+ ]), 1032, ["modelValue", "header"]);
516
+ };
517
+ }
518
+ }), he = We(), Rt = Ie();
519
+ function ue(t) {
520
+ const f = se(t);
521
+ return f.isValid() ? f.format("DD/MM/YYYY") : "";
522
+ }
523
+ const Nt = {
524
+ mapMemberExportRow: (t) => {
525
+ var a, m, i, A, y, p, g, S, j, q, I, G, J, v, l, P, X, ee, te, o, n, F, w, R, H, L, oe, ne;
526
+ const f = O(() => Rt.locations.map((C) => ({
527
+ label: C.name,
528
+ value: C._id
529
+ }))), c = (a = Ye.parseOneAddress(
530
+ t == null ? void 0 : t.email
531
+ )) != null && a.domain.includes("feedmepos.com") ? void 0 : t.email, M = (i = ((m = t == null ? void 0 : t.collection) == null ? void 0 : m.TITLE) || []) == null ? void 0 : i.reduce(
532
+ (C, N) => {
533
+ var h, Y;
534
+ const Q = (Y = (h = he.sortedTitles) == null ? void 0 : h.find(
535
+ (ie) => ie._id === N.collectible
536
+ )) == null ? void 0 : Y.name;
537
+ return !Q || N.balance <= 0 || C.push(Q), C;
538
+ },
539
+ []
540
+ ), b = (he.sortedTitles || []).reduce(
541
+ (C, N) => {
542
+ var h, Y, ie, fe;
543
+ const Q = (fe = (ie = (Y = (((h = t == null ? void 0 : t.collection) == null ? void 0 : h.TITLE) || []).find(
544
+ (Me) => Me.collectible === N._id
545
+ )) == null ? void 0 : Y.expiryBalance) == null ? void 0 : ie[0]) == null ? void 0 : fe.expiredAt;
546
+ return C[N.name] = Q ? se(Q).format("DD/MM/YYYY") : "", C;
547
+ },
548
+ {}
549
+ ), _ = ((p = (y = (A = t.collection) == null ? void 0 : A.CREDIT) == null ? void 0 : y.at(0)) == null ? void 0 : p.balance) || 0, u = ((q = (j = (S = (g = t.collection) == null ? void 0 : g.CREDIT) == null ? void 0 : S.at(0)) == null ? void 0 : j.expiryBalance) == null ? void 0 : q.reduce(
550
+ (C, N) => C + N.amount,
551
+ 0
552
+ )) || 0, T = et(_, 2);
553
+ return {
554
+ ID: t._id.toString(),
555
+ Name: ((I = t.name) == null ? void 0 : I.trim()) || "",
556
+ Phone: ((G = t == null ? void 0 : t.phoneNumber) == null ? void 0 : G.trim()) || "",
557
+ Email: c || "",
558
+ Gender: t.gender || "",
559
+ CardNo: t.cardNo || "",
560
+ Birthday: t != null && t.birthday ? ue(t == null ? void 0 : t.birthday) : "",
561
+ Credit: parseFloat((Number(T) - Number(u)).toFixed(2)),
562
+ FreeCredit: Number(u.toFixed(2)),
563
+ TotalCredit: Number(T),
564
+ Exp: t != null && t.collection ? ((l = (v = (J = t.collection) == null ? void 0 : J.POINT) == null ? void 0 : v.at(0)) == null ? void 0 : l.balance) ?? 0 : 0,
565
+ Point: t != null && t.collection ? ((ee = (X = (P = t.collection) == null ? void 0 : P.COIN) == null ? void 0 : X.at(0)) == null ? void 0 : ee.balance) ?? 0 : 0,
566
+ Level: t != null && t.collection ? ((n = (o = (te = t.collection) == null ? void 0 : te.TIER) == null ? void 0 : o.at(0)) == null ? void 0 : n.balance) ?? 0 : 0,
567
+ Tier: t != null && t.collection ? ((R = (w = (F = t.collection) == null ? void 0 : F.TIER) == null ? void 0 : w.at(0)) == null ? void 0 : R.balance) ?? 0 : 0,
568
+ Titles: M.join(","),
569
+ ...b,
570
+ TotalTransaction: t.stats.visitCount,
571
+ AvgSpent: tt(Number(t.stats.avgBillSize || 0)).toFormat(
572
+ !1
573
+ ),
574
+ TotalSpent: t.stats.avgBillSize * t.stats.visitCount,
575
+ LastVisit: ue(t.stats.lastVisit),
576
+ Feedback: ((H = t.stats) == null ? void 0 : H.feedbackCount) || 0,
577
+ LastSeasonTierEarned: ((L = t.stats) == null ? void 0 : L.lastSeasonTierEarned) || 0,
578
+ LastSeasonPointEarned: ((oe = t.stats) == null ? void 0 : oe.lastSeasonPointEarned) || 0,
579
+ JoinedAt: ue(t.joinAt || void 0),
580
+ JoinedAtLocation: t.location && ((ne = f.value.find((C) => C.value == t.location)) == null ? void 0 : ne.label) || "-",
581
+ VisitFrequency: `${Number(
582
+ Math.ceil(t.stats.avgVisitFrequency).toFixed(0)
583
+ )}`
584
+ };
585
+ }
586
+ }, Bt = { class: "flex items-center" }, Ut = { class: "fm-typo-en-title-md-600 fm-step-title line-clamp-2 mr-8" }, Vt = { class: "px-24 flex flex-col gap-y-16" }, Lt = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, Yt = { class: "flex flex-wrap items-center gap-8" }, zt = { class: "fm-typo-en-body-md-600" }, Ot = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, jt = { class: "flex flex-col gap-16 text-center" }, qt = { class: "fm-typo-en-title-sm-800" }, Gt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, be = "text-fm-color-typo-info bg-fm-color-system-info-100", Io = /* @__PURE__ */ le({
587
+ __name: "Segment",
588
+ setup(t) {
589
+ const { minor: f } = Re, { t: c } = pe(), M = Ie(), { mapMemberExportRow: b } = Nt, _ = Ne(), u = ot(), T = W(0);
590
+ function E(o) {
591
+ return !!o.defaultKey;
592
+ }
593
+ function a(o) {
594
+ return o ? `connect.loyalty.segment.default_segments.${o.toLowerCase()}` : void 0;
595
+ }
596
+ function m(o) {
597
+ const n = a(o.defaultKey);
598
+ return n ? c(`${n}.name`) : o.name;
599
+ }
600
+ function i(o) {
601
+ return T.value <= 0 ? "0.00" : ((o ?? 0) * 100 / T.value).toFixed(2);
602
+ }
603
+ const A = [
604
+ {
605
+ header: c("connect.loyalty.segment.table.name"),
606
+ accessorFn: (o) => o.name,
607
+ cell(o) {
608
+ return B("div", { class: "flex flex-wrap items-center gap-8" }, [
609
+ B("span", m(o.row.original)),
610
+ ...E(o.row.original) ? [
611
+ B(ae.FmChip, {
612
+ class: be,
613
+ label: c("connect.loyalty.segment.default_segments.system"),
614
+ compact: !0
615
+ })
616
+ ] : []
617
+ ]);
618
+ }
619
+ },
620
+ {
621
+ header: c("connect.loyalty.segment.table.status"),
622
+ enableSorting: !1,
623
+ cell(o) {
624
+ const n = o.row.original.isActive === !1 ? "Inactive" : "Active";
625
+ return B(ae.FmChip, {
626
+ class: o.row.original.isActive === !1 ? "text-fm-color-typo-error bg-fm-color-system-error-100" : "text-fm-color-typo-success bg-fm-color-system-success-100",
627
+ label: n,
628
+ compact: !0
629
+ });
630
+ }
631
+ },
632
+ {
633
+ header: c("connect.loyalty.segment.table.total_customers"),
634
+ accessorFn: (o) => o.memberCount ?? 0
635
+ },
636
+ {
637
+ header: c("connect.loyalty.segment.table.customer_percentage"),
638
+ accessorFn: (o) => i(o.memberCount)
639
+ },
640
+ {
641
+ header: c("connect.loyalty.segment.table.actions"),
642
+ meta: {
643
+ maxWidth: "100px"
644
+ },
645
+ cell(o) {
646
+ return B("div", { class: "flex items-center justify-end" }, [
647
+ B(
648
+ ae.FmMenu,
649
+ {
650
+ placement: "bottom-end",
651
+ onClick: (n) => {
652
+ n.stopPropagation();
653
+ }
654
+ },
655
+ {
656
+ "menu-button": () => B(ae.FmButton, {
657
+ icon: "more_vert",
658
+ iconColor: "neutral-gray-400",
659
+ variant: "tertiary"
660
+ }),
661
+ default: () => [
662
+ B(
663
+ ae.FmMenuItem,
664
+ {
665
+ onClick: async (n) => {
666
+ n.stopPropagation(), J(o.row.original);
667
+ }
668
+ },
669
+ {
670
+ label: B(
671
+ "div",
672
+ {
673
+ class: "fm-typo-en-body-md-400"
674
+ },
675
+ "Export"
676
+ )
677
+ }
678
+ ),
679
+ ...E(o.row.original) ? [] : [
680
+ B(
681
+ ae.FmMenuItem,
682
+ {
683
+ onClick: async (n) => {
684
+ n.stopPropagation(), G(o.row.original);
685
+ }
686
+ },
687
+ {
688
+ label: B(
689
+ "div",
690
+ {
691
+ class: "text-fm-color-typo-error fm-typo-en-body-md-400"
692
+ },
693
+ "Remove"
694
+ )
695
+ }
696
+ )
697
+ ]
698
+ ]
699
+ }
700
+ )
701
+ ]);
702
+ }
703
+ }
704
+ ], y = W(null), { tableMeta: p, rowData: g, debouncedFetchData: S } = Fe(
705
+ z.readAll
706
+ ), j = O(() => g.value.length === 0 ? !1 : Ve.some(
707
+ (o) => !g.value.some((n) => n.defaultKey === o)
708
+ ));
709
+ async function q() {
710
+ var o;
711
+ try {
712
+ await z.refreshSegments(), _.open({ type: "info", title: "Segment refresh queued" });
713
+ } catch (n) {
714
+ if (((n == null ? void 0 : n.status) ?? ((o = n == null ? void 0 : n.response) == null ? void 0 : o.status)) === 409) {
715
+ _.open({
716
+ type: "info",
717
+ title: "Segment refresh already in progress"
718
+ });
719
+ return;
720
+ }
721
+ _.open({
722
+ type: "error",
723
+ title: (n == null ? void 0 : n.message) ?? "Failed to queue segment refresh"
724
+ });
725
+ }
726
+ }
727
+ async function I() {
728
+ await f(
729
+ async () => {
730
+ await z.startDefaultSegments(), await S({ pageSize: 10, pageIndex: 0 });
731
+ },
732
+ {
733
+ message: c(
734
+ "connect.loyalty.segment.default_segments.get_started.loading"
735
+ ),
736
+ successMessage: c(
737
+ "connect.loyalty.segment.default_segments.get_started.success"
738
+ )
739
+ }
740
+ );
741
+ }
742
+ async function G(o) {
743
+ await Pe.remove(`Are you sure you want to remove ${o.name}?`) && await f(
744
+ async () => {
745
+ await z.delete(o._id), await S({ pageSize: 10, pageIndex: 0 });
746
+ },
747
+ {
748
+ message: `Removing ${o.name}`,
749
+ successMessage: `Removed ${o.name} successfully`
750
+ }
751
+ );
752
+ }
753
+ async function J(o) {
754
+ const n = {
755
+ sortBy: "_id",
756
+ descending: !1,
757
+ rowsPerPage: 1e3,
758
+ page: 1,
759
+ rowsNumber: 0
760
+ }, F = new ze(), w = m(o), R = (await _e.read({
761
+ limit: 1,
762
+ skip: 0,
763
+ sortBy: n.sortBy,
764
+ descending: n.descending
765
+ })).meta.totalResources ?? 0, H = n.rowsPerPage;
766
+ await f(
767
+ async () => {
768
+ for (let L = 0; L < R; L += H) {
769
+ const oe = {
770
+ ...n,
771
+ limit: H,
772
+ skip: n.page - 1,
773
+ sortBy: n.sortBy,
774
+ descending: n.descending
775
+ }, ne = await z.paginateSegmentUsers(
776
+ o._id,
777
+ oe
778
+ );
779
+ for (const C of ne.resources) {
780
+ const N = b(C);
781
+ F.addRecord(N);
782
+ }
783
+ n.page++;
784
+ }
785
+ await ke(
786
+ F.buildExcel(),
787
+ `[${w}]-members-${(/* @__PURE__ */ new Date()).toISOString()}.xlsx`,
788
+ {
789
+ bookType: "xlsx",
790
+ bookSST: !1,
791
+ type: "array"
792
+ }
793
+ ), n.page = 1;
794
+ },
795
+ {
796
+ message: "Exporting member...",
797
+ successMessage: "Member exported successfully"
798
+ }
799
+ );
800
+ }
801
+ async function v(o) {
802
+ await f(
803
+ async () => {
804
+ var n;
805
+ if (o.type === U.enum.STATIC) {
806
+ const F = new FormData();
807
+ if (F.append("file", o.file), o._id) {
808
+ const { members: w, _id: R, file: H, ...L } = o;
809
+ F.append("segment", JSON.stringify(L)), await z.updateStatic(o._id, F);
810
+ } else {
811
+ const { file: w, ...R } = o;
812
+ F.append("segment", JSON.stringify(R)), await z.createStatic(F);
813
+ }
814
+ o.file && _.open({
815
+ type: "info",
816
+ title: "Import begins soon. Check Queue for updates.",
817
+ action: "View",
818
+ onAction: async () => {
819
+ await u.push({
820
+ name: Se["$connect-QUEUE"],
821
+ query: { type: [ye.enum.SEGMENTATION_IMPORTED] }
822
+ });
823
+ }
824
+ });
825
+ } else if (o._id) {
826
+ const { members: F, _id: w, ...R } = o;
827
+ await z.update(o._id, R);
828
+ } else
829
+ await z.create(o);
830
+ await S({ pageSize: 10, pageIndex: 0 }), (n = y.value) == null || n.hideSheet();
831
+ },
832
+ {
833
+ message: "Saving segment",
834
+ successMessage: "Segment saved"
835
+ }
836
+ );
837
+ }
838
+ function l(o) {
839
+ var n;
840
+ (n = y.value) == null || n.showSheet(o);
841
+ }
842
+ const P = {
843
+ label: c("connect.navigation.queue"),
844
+ value: "queue",
845
+ isPrimary: !1,
846
+ prependIcon: "work_history"
847
+ }, X = {
848
+ label: c("connect.loyalty.segment.default_segments.get_started.action"),
849
+ value: "start-default-segments",
850
+ isPrimary: !1,
851
+ prependIcon: "auto_awesome"
852
+ }, ee = O(() => {
853
+ if (!M.isPremium)
854
+ return [];
855
+ const o = [P];
856
+ return j.value && o.push(X), o.push(
857
+ {
858
+ label: c("connect.loyalty.segment.actions.refresh"),
859
+ value: "refresh",
860
+ prependIcon: "refresh"
861
+ },
862
+ {
863
+ label: c("connect.loyalty.segment.actions.add"),
864
+ value: "add",
865
+ isPrimary: !0,
866
+ prependIcon: "add"
867
+ }
868
+ ), o;
869
+ });
870
+ function te(o) {
871
+ switch (o) {
872
+ case "add":
873
+ l();
874
+ break;
875
+ case "refresh":
876
+ q();
877
+ break;
878
+ case "queue":
879
+ u.push({
880
+ name: Se["$connect-QUEUE"],
881
+ query: { type: [ye.enum.SEGMENTATION_IMPORTED] }
882
+ });
883
+ break;
884
+ case "start-default-segments":
885
+ I();
886
+ break;
887
+ }
888
+ }
889
+ return De(async () => {
890
+ const { meta: o } = await _e.read({
891
+ limit: 1,
892
+ skip: 0,
893
+ sortBy: "_id",
894
+ search: void 0,
895
+ descending: !1
896
+ });
897
+ T.value = o.totalResources ?? 0, await S({ pageSize: 10, pageIndex: 0 }), await M.readPremium(), await M.readLocations();
898
+ }), (o, n) => {
899
+ const F = x("FmPill"), w = x("FmPageHead"), R = x("FmChip"), H = x("FmIcon"), L = x("FmMenuItem"), oe = x("FmMenu"), ne = x("FmListItem"), C = x("FmList"), N = x("FmButton"), Q = x("FmCard");
900
+ return r(), k(Z, null, [
901
+ d(w, {
902
+ title: "Segments",
903
+ actions: e(ee),
904
+ "onClick:action": n[0] || (n[0] = (h) => te(h))
905
+ }, {
906
+ title: $(() => [
907
+ s("div", Bt, [
908
+ s("span", Ut, D(e(c)("connect.loyalty.segment.title")), 1),
909
+ d(F, { variant: "premium" })
910
+ ])
911
+ ]),
912
+ _: 1
913
+ }, 8, ["actions"]),
914
+ s("div", Vt, [
915
+ e(g).length > 0 || e(p).searchValue || e(p).isLoading ? (r(), k(Z, { key: 0 }, [
916
+ d(Ce, {
917
+ loading: e(p).isLoading,
918
+ "row-data": e(g),
919
+ "row-count": e(p).totalRows,
920
+ "column-defs": A,
921
+ "shrink-at": !1,
922
+ "page-count": e(p).pageCount,
923
+ "page-index": e(p).pageIndex,
924
+ "page-size": e(p).pageSize,
925
+ onRowClick: n[1] || (n[1] = (h) => {
926
+ l(h.original);
927
+ }),
928
+ onPageChange: e(S)
929
+ }, null, 8, ["loading", "row-data", "row-count", "page-count", "page-index", "page-size", "onPageChange"]),
930
+ d(C, { class: "w-full hidden xs:!block" }, {
931
+ default: $(() => [
932
+ (r(!0), k(Z, null, me(e(g), (h) => (r(), V(ne, {
933
+ key: h._id.toString(),
934
+ tag: "label",
935
+ onClick: (Y) => l(h)
936
+ }, {
937
+ default: $(() => [
938
+ s("div", null, [
939
+ s("div", Lt, D((h.memberCount ?? 0).toLocaleString()) + " total customers ", 1),
940
+ s("div", Yt, [
941
+ s("span", zt, D(m(h)), 1),
942
+ E(h) ? (r(), V(R, {
943
+ key: 0,
944
+ class: ce(be),
945
+ label: e(c)("connect.loyalty.segment.default_segments.system"),
946
+ compact: ""
947
+ }, null, 8, ["label"])) : K("", !0)
948
+ ]),
949
+ s("div", Ot, D(i(h.memberCount)) + "% of customers ", 1)
950
+ ])
951
+ ]),
952
+ append: $(() => [
953
+ d(oe, { "stop-click-propagation": !0 }, {
954
+ "menu-button": $(() => [
955
+ d(H, { name: "more_vert" })
956
+ ]),
957
+ default: $(() => [
958
+ d(L, {
959
+ class: "fm-typo-en-body-md-400",
960
+ label: "Export",
961
+ "onUpdate:modelValue": (Y) => Y && J(h)
962
+ }, null, 8, ["onUpdate:modelValue"]),
963
+ E(h) ? K("", !0) : (r(), V(L, {
964
+ key: 0,
965
+ class: "text-fm-color-typo-error fm-typo-en-body-md-400",
966
+ label: "Remove",
967
+ "onUpdate:modelValue": (Y) => Y && G(h)
968
+ }, null, 8, ["onUpdate:modelValue"]))
969
+ ]),
970
+ _: 2
971
+ }, 1024)
972
+ ]),
973
+ _: 2
974
+ }, 1032, ["onClick"]))), 128))
975
+ ]),
976
+ _: 1
977
+ })
978
+ ], 64)) : (r(), V(Q, {
979
+ key: 1,
980
+ variant: "outlined",
981
+ class: "w-full flex flex-col items-center justify-center gap-y-24 p-24"
982
+ }, {
983
+ default: $(() => [
984
+ n[3] || (n[3] = s("img", {
985
+ src: $e,
986
+ class: "aspect-square w-[150px]"
987
+ }, null, -1)),
988
+ s("div", jt, [
989
+ s("div", qt, D(e(c)("connect.loyalty.segment.default_segments.get_started.title")), 1),
990
+ s("div", Gt, D(e(c)(
991
+ "connect.loyalty.segment.default_segments.get_started.description"
992
+ )), 1)
993
+ ]),
994
+ d(N, {
995
+ variant: "primary",
996
+ label: e(c)("connect.loyalty.segment.default_segments.get_started.action"),
997
+ disabled: !e(M).isPremium,
998
+ icon: "auto_awesome",
999
+ onClick: n[2] || (n[2] = (h) => I())
1000
+ }, null, 8, ["label", "disabled"])
1001
+ ]),
1002
+ _: 1
1003
+ })),
1004
+ d(Pt, {
1005
+ ref_key: "sheetRef",
1006
+ ref: y,
1007
+ "onUpdate:modelValue": v
1008
+ }, null, 512)
1009
+ ])
1010
+ ], 64);
1011
+ };
1012
+ }
1013
+ });
1014
+ export {
1015
+ Io as default
1016
+ };