@feedmepos/mf-connect 0.0.6 → 0.0.8

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 (72) hide show
  1. package/dist/{Analytic-BJYHu6np.js → Analytic-BxRuK2P2.js} +8 -8
  2. package/dist/{Broadcast-B8FNr597.js → Broadcast-BqGojAWW.js} +8 -8
  3. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-BlZ4cdrl.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-B-VzcVMS.js} +8 -8
  4. package/dist/{Card-DLHnQyMF.js → Card-Dlj5jQp4.js} +54 -54
  5. package/dist/{Collections-d7N7aO1G.js → Collections-DvdDRozp.js} +180 -185
  6. package/dist/{Credit-DWbl28df.js → Credit-BeHm7_2S.js} +8 -8
  7. package/dist/{EditCampaignSheet.vue_vue_type_script_setup_true_lang-DBRqd0z4.js → EditCampaignSheet.vue_vue_type_script_setup_true_lang-BsbgHsah.js} +170 -160
  8. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-DTxJHWjb.js → EffectSheet.vue_vue_type_style_index_0_lang-hwXvdiut.js} +2999 -2978
  9. package/dist/{Experience-Bzt7yrvt.js → Experience-CtDY9u4Y.js} +8 -8
  10. package/dist/{Game-IRXuMUL3.js → Game-DjaYuqcb.js} +8 -8
  11. package/dist/{ImageInput.vue_vue_type_script_setup_true_lang-C8d0t8nQ.js → ImageInput.vue_vue_type_script_setup_true_lang-Bq5-Gl9N.js} +1 -1
  12. package/dist/{MainLayout-DDh1WuO8.js → MainLayout-B-iAZM2k.js} +1 -1
  13. package/dist/{Marketing-C2kkxDFL.js → Marketing-BJJltAh-.js} +6 -6
  14. package/dist/Member-eJ9Pdi5w.js +91 -0
  15. package/dist/MemberList-CrhMqUfJ.js +1664 -0
  16. package/dist/{MemberTransactions-DNIJDHOQ.js → MemberTransactions-DRET8mSQ.js} +4 -4
  17. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-DYWmeADi.js → MessageInput.vue_vue_type_script_setup_true_lang-D-ttMwn2.js} +2 -2
  18. package/dist/{Point-Bgp7ogL-.js → Point-DPTOgJbC.js} +8 -8
  19. package/dist/{Promotion-Dk6STeBk.js → Promotion-wzkRuNqO.js} +9 -9
  20. package/dist/{RuleGroup.vue_vue_type_script_setup_true_lang-BXzBoSgP.js → RuleGroup.vue_vue_type_script_setup_true_lang-Z06eB5i5.js} +12 -12
  21. package/dist/{Segment-BEQJcNkY.js → Segment-DnsPrP7Q.js} +10 -10
  22. package/dist/{Setting-CZi479L2.js → Setting-CXuZu0-m.js} +9 -9
  23. package/dist/Store-4Um9keEp.js +1424 -0
  24. package/dist/StoreRewards-B-UFeyQM.js +434 -0
  25. package/dist/{StoreTransactions.vue_vue_type_script_setup_true_lang-Bdo4vZkG.js → StoreTransactions.vue_vue_type_script_setup_true_lang-BAyotuXd.js} +5 -5
  26. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-DQQ-EPvQ.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-I_XFpctY.js} +1 -1
  27. package/dist/Tier-C6KVsxGO.js +818 -0
  28. package/dist/{Title-Dc3COZA9.js → Title-DuN1ahIM.js} +236 -236
  29. package/dist/{Transaction-BCa3ObND.js → Transaction-DdfX7Xfe.js} +1 -1
  30. package/dist/Voucher-DarXrxZr.js +454 -0
  31. package/dist/{app-DldkpdyI.js → app-CxBTTB31.js} +2372 -2357
  32. package/dist/app.js +1 -1
  33. package/dist/{campaign-COrVPhtR.js → campaign-B0aXkadj.js} +7 -7
  34. package/dist/dto-BtdVC-Ab.js +1093 -0
  35. package/dist/{effect-B4_HDofh.js → effect-BUN6rkQM.js} +1 -1
  36. package/dist/{helper-CwQEM81T.js → helper-Cpq3x8K5.js} +1 -1
  37. package/dist/{index-DujHgfez.js → index-0GYrZr4L.js} +138 -132
  38. package/dist/{index-Cd-A6imB.js → index-8clzk3uX.js} +1 -1
  39. package/dist/{index-ClQze5GX.js → index-BTntbYTS.js} +1 -1
  40. package/dist/{index-D8ae8TSh.js → index-BvnZdJBY.js} +2 -2
  41. package/dist/{index-D3Oa_lL4.js → index-C6NgUSl2.js} +1 -1
  42. package/dist/{index-CDXgQC_P.js → index-CK9yJMj7.js} +34 -34
  43. package/dist/{index-DApTNNm8.js → index-D2Juhkdw.js} +2 -2
  44. package/dist/{index-DCIJl8iK.js → index-DDSLx7vu.js} +2 -2
  45. package/dist/{index-BGEOMkg0.js → index-Dg-PMgXV.js} +1 -1
  46. package/dist/index-DysVCkrx.js +1735 -0
  47. package/dist/libs/packages/core/src/campaign/campaign.enum.d.ts +6 -0
  48. package/dist/libs/packages/core/src/campaign/campaign.fn.d.ts +2 -0
  49. package/dist/libs/packages/core/src/template/templates.d.ts +7 -0
  50. package/dist/{loading-CEcLG67g.js → loading-Cxp7sI5p.js} +2 -2
  51. package/dist/{lodash-CQck_rTn.js → lodash-DsT1nK-T.js} +1 -1
  52. package/dist/{membership-Bat0mrVs.js → membership-DtD45RXh.js} +4 -4
  53. package/dist/{money-JE8h3c0z.js → money-CFI1TMCS.js} +1 -1
  54. package/dist/{number-D5WgTK0X.js → number-BBtf4fYz.js} +1 -1
  55. package/dist/packages/connect/src/api/index.d.ts +3 -0
  56. package/dist/packages/connect/src/api/settings/index.d.ts +1 -1
  57. package/dist/packages/connect/src/main.d.ts +1 -1
  58. package/dist/{plugins-B53iVLET.js → plugins-B_d-WFtN.js} +4 -4
  59. package/dist/{rule-lH1B2od5.js → rule-CB9Qlcx1.js} +2 -2
  60. package/dist/{rule-builder-D6chADAd.js → rule-builder-BIKcA4Bg.js} +1 -1
  61. package/dist/{template-D4IPNePW.js → template-qlb46PGl.js} +5 -5
  62. package/dist/{usePagination-MD91K8Ao.js → usePagination-CX66ab1Y.js} +1 -1
  63. package/dist/{xlsx-zo_mxA6a.js → xlsx-DMaFso0k.js} +1 -1
  64. package/package.json +2 -2
  65. package/dist/Member-CNfC-lCV.js +0 -90
  66. package/dist/MemberList-B_lQ2EIK.js +0 -1663
  67. package/dist/Store-BeH0Gm7T.js +0 -1423
  68. package/dist/StoreRewards-BgYxgC_0.js +0 -433
  69. package/dist/Tier-DS1BnVuA.js +0 -818
  70. package/dist/Voucher-BG51P9yR.js +0 -448
  71. package/dist/dto-lHIRZTaN.js +0 -353
  72. package/dist/index-BDLy_dUj.js +0 -1742
@@ -0,0 +1,1424 @@
1
+ import { defineComponent as G, computed as R, resolveComponent as V, openBlock as h, createBlock as E, withCtx as T, createElementVNode as v, createVNode as r, createElementBlock as P, toDisplayString as de, unref as e, Fragment as J, renderList as te, ref as A, isRef as ue, createCommentVNode as W, reactive as Ie, onMounted as me, watch as ve, toRaw as Re, createTextVNode as oe, h as De } from "vue";
2
+ import { _ as Be } from "./tier-BJDhpH6X.js";
3
+ import { useDialog as Pe, useDialogChild as Ne, components as Ae } from "@feedmepos/ui-library";
4
+ import { u as Ee } from "./loading-Cxp7sI5p.js";
5
+ import { u as Ue, C as le } from "./membership-DtD45RXh.js";
6
+ import { a as Me, c as $e } from "./object-qECH92oz.js";
7
+ import { a as Q, c as Oe, p as ce, n as je, f as pe } from "./plugins-B_d-WFtN.js";
8
+ import { d as D, z as L, i as fe, S as Le, u as be, J as he, R as He } from "./app-CxBTTB31.js";
9
+ import { F as qe, a as Ke, b as We, c as Te } from "./index-BvnZdJBY.js";
10
+ import { _ as Y, Z as H, g as q, a as K } from "./ZodTextField.vue_vue_type_script_setup_true_lang-3LlSDiq0.js";
11
+ import { _ as ie } from "./lodash-DsT1nK-T.js";
12
+ import { _ as Je } from "./index-D2Juhkdw.js";
13
+ import { _ as Ye } from "./ImageInput.vue_vue_type_script_setup_true_lang-Bq5-Gl9N.js";
14
+ import { _ as ze } from "./ChipMenu.vue_vue_type_script_setup_true_lang-BPpZZNkr.js";
15
+ import { z as Ge, a as Ze } from "./money-CFI1TMCS.js";
16
+ import { F as Qe } from "./number-BBtf4fYz.js";
17
+ import { t as Xe } from "./helper-Cpq3x8K5.js";
18
+ import { useRouter as et } from "vue-router";
19
+ import { m as ye } from "./index-C6NgUSl2.js";
20
+ function tt(f) {
21
+ return Q.DineroFactory(f).toUnit();
22
+ }
23
+ function ot(f, b, u, F, _ = [], t = []) {
24
+ const p = Je.compact(
25
+ b.map((d) => f.find((i) => i.systemCode === d.systemCode && i.taxCode === d.taxCode)).filter((d) => !!d && t.includes(d.systemCode))
26
+ ), m = p.reduce(
27
+ (d, i) => {
28
+ var n;
29
+ return Object.assign(d, {
30
+ [i.taxCode]: {
31
+ inclusive: ((n = _.find((y) => y.systemCode === i.systemCode)) == null ? void 0 : n.inclusive) || !1,
32
+ adjustment: {
33
+ level: 1,
34
+ type: {
35
+ type: "BY_MULTIPLIER",
36
+ amount: {
37
+ amount: i.rate.amount,
38
+ precision: i.rate.precision,
39
+ currency: "MYR"
40
+ }
41
+ }
42
+ }
43
+ }
44
+ });
45
+ },
46
+ {}
47
+ ), a = Q.Calculator.calculate({
48
+ items: {
49
+ 0: {
50
+ quantity: 1,
51
+ adjustments: {
52
+ price: {
53
+ level: 0,
54
+ type: {
55
+ type: "BY_AMOUNT",
56
+ amount: Q.DineroFactory(u).subtract(Q.Dinero.fromNumber({ number: F }).toObject()).toObject()
57
+ }
58
+ }
59
+ },
60
+ taxes: m
61
+ }
62
+ },
63
+ adjustments: {},
64
+ roundToNearest: 0
65
+ });
66
+ return p.map((d) => ({
67
+ setting: d,
68
+ systemCode: d.systemCode,
69
+ name: d.name,
70
+ taxCode: d.taxCode,
71
+ rate: d.rate,
72
+ total: Q.DineroFactory({
73
+ ...a.items[0].taxes[d.taxCode]
74
+ }).convertPrecision(2).toObject()
75
+ }));
76
+ }
77
+ function at(f, b, u) {
78
+ return f ? f.reduce((F, _) => {
79
+ var t;
80
+ return (t = u.find((p) => p.systemCode === _.systemCode)) != null && t.inclusive || (F = Q.DineroFactory(F.toObject()).add(_.total)), F;
81
+ }, Q.DineroFactory(b)).toObject() : Q.DineroFactory(b).toObject();
82
+ }
83
+ const nt = { class: "absolute top-0 right-0" }, lt = { class: "relative h-[120px] aspect-video flex items-center justify-center border rounded-md border-fm-color-neutral-gray-300" }, st = ["src"], rt = { class: "fm-typo-en-body-lg-600" }, it = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, dt = { class: "flex gap-8 items-center flex-wrap" }, ut = /* @__PURE__ */ G({
84
+ __name: "StoreBundleCard",
85
+ props: {
86
+ bundle: { type: Object, required: !0 }
87
+ },
88
+ emits: ["edit", "delete"],
89
+ setup(f, { emit: b }) {
90
+ const u = f, F = b, _ = R(() => {
91
+ const p = [];
92
+ return u.bundle.price.amount > 0 && p.push(
93
+ `${D.Config.getCountry().currency.symbol}${tt(u.bundle.price)}`
94
+ ), u.bundle.coinPrice && p.push(`${u.bundle.coinPrice} point(s)`), p.join(" or ");
95
+ }), t = R(() => {
96
+ var m, a;
97
+ const p = [];
98
+ if (u.bundle.titles.length > 0 && p.push(`${u.bundle.titles.length} title(s)`), u.bundle.vouchers.length > 0 && p.push(`${u.bundle.vouchers.length} voucher(s)`), u.bundle.credit.normal || (m = u.bundle.credit.free) != null && m.amount) {
99
+ const d = u.bundle.credit.normal + (((a = u.bundle.credit.free) == null ? void 0 : a.amount) ?? 0);
100
+ p.push(`${d} credit(s)`);
101
+ }
102
+ return p;
103
+ });
104
+ return (p, m) => {
105
+ const a = V("FmButton"), d = V("FmMenuItem"), i = V("FmMenu"), n = V("FmIcon"), y = V("FmChip"), l = V("FmCard");
106
+ return h(), E(l, {
107
+ variant: "outlined",
108
+ class: "flex flex-col gap-y-8 p-16 min-h-[240px] h-full text-center items-center relative"
109
+ }, {
110
+ default: T(() => [
111
+ v("div", nt, [
112
+ r(i, { placement: "bottom-end" }, {
113
+ "menu-button": T(() => [
114
+ r(a, {
115
+ icon: "more_vert",
116
+ variant: "tertiary"
117
+ })
118
+ ]),
119
+ default: T(() => [
120
+ r(d, {
121
+ onClick: m[0] || (m[0] = (g) => F("edit", f.bundle)),
122
+ label: "Edit"
123
+ }),
124
+ r(d, {
125
+ onClick: m[1] || (m[1] = (g) => F("delete", f.bundle)),
126
+ label: "Delete"
127
+ })
128
+ ]),
129
+ _: 1
130
+ })
131
+ ]),
132
+ v("div", lt, [
133
+ f.bundle.image ? (h(), P("img", {
134
+ key: 1,
135
+ src: f.bundle.image,
136
+ class: "w-full h-full object-contain aspect-video"
137
+ }, null, 8, st)) : (h(), E(n, {
138
+ key: 0,
139
+ name: "image",
140
+ outline: !0,
141
+ size: "lg",
142
+ class: "text-fm-color-neutral-gray-200"
143
+ }))
144
+ ]),
145
+ v("div", rt, de(f.bundle.name), 1),
146
+ v("div", it, de(e(_) || "Free"), 1),
147
+ v("div", dt, [
148
+ (h(!0), P(J, null, te(e(t), (g, k) => (h(), E(y, {
149
+ key: k,
150
+ label: g
151
+ }, null, 8, ["label"]))), 128))
152
+ ])
153
+ ]),
154
+ _: 1
155
+ });
156
+ };
157
+ }
158
+ }), mt = /* @__PURE__ */ G({
159
+ __name: "AddBundleCard",
160
+ emits: ["create"],
161
+ setup(f, { emit: b }) {
162
+ const u = b;
163
+ return (F, _) => {
164
+ const t = V("FmButton"), p = V("FmCard");
165
+ return h(), E(p, {
166
+ variant: "outlined",
167
+ class: "flex flex-col gap-y-8 p-16 h-full min-h-[240px] items-center justify-center"
168
+ }, {
169
+ default: T(() => [
170
+ r(t, {
171
+ onClick: _[0] || (_[0] = (m) => u("create")),
172
+ label: "Add bundle",
173
+ icon: "add",
174
+ variant: "secondary"
175
+ })
176
+ ]),
177
+ _: 1
178
+ });
179
+ };
180
+ }
181
+ }), ct = { class: "flex w-full justify-between mt-32" }, pt = { class: "flex items-center gap-8" }, ft = /* @__PURE__ */ G({
182
+ __name: "CategoryDialog",
183
+ props: {
184
+ action: {
185
+ type: String,
186
+ default: () => "add"
187
+ },
188
+ initialValue: {
189
+ type: String,
190
+ default: () => ""
191
+ }
192
+ },
193
+ setup(f) {
194
+ const b = f, u = Pe(), { emitData: F, emitAction: _ } = Ne(), t = A(b.initialValue), p = L.string().min(1), m = R(() => {
195
+ const i = p.safeParse(t.value);
196
+ return i.success ? "" : i.error.flatten().formErrors.join(`
197
+ `);
198
+ });
199
+ function a() {
200
+ F(t.value), _("primary"), u.close();
201
+ }
202
+ function d() {
203
+ F(null), _("primary"), u.close();
204
+ }
205
+ return (i, n) => {
206
+ const y = V("FmTextField"), l = V("FmButton");
207
+ return h(), P("div", null, [
208
+ r(y, {
209
+ modelValue: e(t),
210
+ "onUpdate:modelValue": n[0] || (n[0] = (g) => ue(t) ? t.value = g : null),
211
+ label: "Category name",
212
+ "helper-text": e(m),
213
+ "helper-state": e(m) ? "error" : "none"
214
+ }, null, 8, ["modelValue", "helper-text", "helper-state"]),
215
+ v("div", ct, [
216
+ v("div", null, [
217
+ f.action == "edit" ? (h(), E(l, {
218
+ key: 0,
219
+ onClick: d,
220
+ label: "Delete",
221
+ variant: "destructive"
222
+ })) : W("", !0)
223
+ ]),
224
+ v("div", pt, [
225
+ r(l, {
226
+ label: "Cancel",
227
+ variant: "tertiary",
228
+ onClick: n[1] || (n[1] = (g) => e(u).close())
229
+ }),
230
+ r(l, {
231
+ label: f.action == "edit" ? "Edit" : "Add",
232
+ disabled: !!e(m),
233
+ onClick: a
234
+ }, null, 8, ["label", "disabled"])
235
+ ])
236
+ ])
237
+ ]);
238
+ };
239
+ }
240
+ });
241
+ function ge(f) {
242
+ return f.states.map((b) => ({ label: b, value: b }));
243
+ }
244
+ const yt = {
245
+ [fe.F_COUNTRY.enum.MY]: {
246
+ states: [
247
+ "Johor",
248
+ "Kedah",
249
+ "Kelantan",
250
+ "Kuala Lumpur",
251
+ "Labuan",
252
+ "Melaka",
253
+ "Negeri Sembilan",
254
+ "Pahang",
255
+ "Perak",
256
+ "Perlis",
257
+ "Pulau Pinang",
258
+ "Putrajaya",
259
+ "Sabah",
260
+ "Sarawak",
261
+ "Selangor",
262
+ "Terengganu"
263
+ ],
264
+ get stateItems() {
265
+ return ge(this);
266
+ }
267
+ },
268
+ [fe.F_COUNTRY.enum.SG]: {
269
+ states: [],
270
+ get stateItems() {
271
+ return ge(this);
272
+ }
273
+ },
274
+ [fe.F_COUNTRY.enum.ID]: {
275
+ states: [
276
+ "Aceh",
277
+ "Bali",
278
+ "Bangka-Belitung",
279
+ "Banten",
280
+ "Bengkulu",
281
+ "Central Java",
282
+ "Central Sulawesi",
283
+ "Daerah Istimewa Yogyakarta",
284
+ "East Java",
285
+ "East Kalimantan",
286
+ "East Nusa Tenggara",
287
+ "Gorontalo",
288
+ "Jakarta Raya",
289
+ "Jambi",
290
+ "Kalimantan Tengah",
291
+ "Lampung",
292
+ "Maluku",
293
+ "Maluku Utara",
294
+ "North Sulawesi",
295
+ "North Sumatra",
296
+ "Nusa Tenggara Barat",
297
+ "Papua",
298
+ "Riau",
299
+ "Riau Islands",
300
+ "South Kalimantan",
301
+ "South Sulawesi",
302
+ "South Sumatra",
303
+ "Sulawesi Barat",
304
+ "Sulawesi Tenggara",
305
+ "West Java",
306
+ "West Kalimantan",
307
+ "West Papua",
308
+ "West Sumatra"
309
+ ],
310
+ get stateItems() {
311
+ return ge(this);
312
+ }
313
+ }
314
+ }, se = () => D.Config.getCountry(), re = {
315
+ get fullCurrency() {
316
+ return se().currency;
317
+ },
318
+ get currency() {
319
+ return se().currency.code;
320
+ },
321
+ get fullTax() {
322
+ return D.Country.getCountryFlattenTaxes(se().code);
323
+ },
324
+ get taxSystem() {
325
+ return se().taxSystems;
326
+ },
327
+ taxInclusion(f) {
328
+ return re.taxSystem.map((b) => ({
329
+ systemCode: b.code,
330
+ inclusive: f !== void 0 ? f : !1
331
+ }));
332
+ },
333
+ groupedTaxOptions() {
334
+ const f = D.Country.getCountryFlattenTaxes(se().code);
335
+ return re.taxSystem.map((b) => ({
336
+ code: b.code,
337
+ options: f.map((u) => ({ ...u, feedmeTaxCode: re.generateCode(u) })).filter((u) => u.systemCode === b.code)
338
+ }));
339
+ },
340
+ systemDefaultCode(f) {
341
+ const b = re.groupedTaxOptions().find((u) => u.code === f);
342
+ return b == null ? void 0 : b.options.find((u) => u.default);
343
+ },
344
+ generateCode(f) {
345
+ return `${f.systemCode}/${f.taxCode}`;
346
+ }
347
+ }, z = re, gt = /* @__PURE__ */ G({
348
+ __name: "TaxInclusiveSetting",
349
+ props: {
350
+ modelValue: {
351
+ type: Array,
352
+ required: !0,
353
+ default: () => []
354
+ }
355
+ },
356
+ emits: ["update:model-value"],
357
+ setup(f, { emit: b }) {
358
+ const u = f, F = z.taxSystem, _ = b, t = A(u.modelValue);
359
+ function p(i, n) {
360
+ const y = ie.clone(u.modelValue), l = y.findIndex((g) => g.systemCode === i);
361
+ l >= 0 ? y[l].inclusive = n : y.push({
362
+ systemCode: i,
363
+ inclusive: n
364
+ }), t.value = y, _("update:model-value", y);
365
+ }
366
+ function m() {
367
+ return F.map((i) => {
368
+ const n = u.modelValue ? u.modelValue.find((y) => y.systemCode === i.code) : !1;
369
+ return {
370
+ label: i.name,
371
+ config: {
372
+ value: n ? n.inclusive : !1
373
+ },
374
+ input: (y) => {
375
+ p(i.code, y);
376
+ }
377
+ };
378
+ });
379
+ }
380
+ const a = Ie(m());
381
+ function d(i, n) {
382
+ return `${i} ${n ? "Inclusive" : "Exclusive"}`;
383
+ }
384
+ return me(() => {
385
+ u.modelValue.length || p(F[0].code, !1);
386
+ }), ve(
387
+ () => u.modelValue,
388
+ (i, n) => {
389
+ i != n && !i.length && p(F[0].code, !1);
390
+ }
391
+ ), (i, n) => {
392
+ const y = V("FmSwitch");
393
+ return h(!0), P(J, null, te(e(a), (l, g) => {
394
+ var k;
395
+ return h(), P("div", { key: g }, [
396
+ r(y, {
397
+ "model-value": ((k = e(t)[g]) == null ? void 0 : k.inclusive) || !1,
398
+ "label-placement": "left",
399
+ "onUpdate:modelValue": (B) => l.input(B)
400
+ }, {
401
+ label: T(() => {
402
+ var B;
403
+ return [
404
+ v("div", null, de(d(l.label, ((B = e(t)[g]) == null ? void 0 : B.inclusive) || !1)), 1)
405
+ ];
406
+ }),
407
+ _: 2
408
+ }, 1032, ["model-value", "onUpdate:modelValue"])
409
+ ]);
410
+ }), 128);
411
+ };
412
+ }
413
+ });
414
+ var bt = { mode: "production" };
415
+ const vt = { class: "space-y-8" }, ht = {
416
+ key: 0,
417
+ class: "space-y-16"
418
+ }, xt = /* @__PURE__ */ G({
419
+ __name: "StripeSetting",
420
+ props: {
421
+ modelValue: {}
422
+ },
423
+ emits: ["update:modelValue"],
424
+ setup(f, { emit: b }) {
425
+ const u = f, F = b, _ = A(!1);
426
+ ve(_, (p, m) => {
427
+ m != p && (!u.modelValue && p ? F("update:modelValue", {
428
+ apiKey: "",
429
+ webhookSecret: ""
430
+ }) : p || F("update:modelValue", void 0));
431
+ });
432
+ const t = R(() => {
433
+ const p = bt.mode === "development", m = D.Config.getCountry().code.toLowerCase(), a = m != "my" ? `.${m}` : "";
434
+ return `https://marketing${p ? "-dev" : ""}${a}.feedmeapi.com/stripe/${Le.getBusinessId()}/webhook`;
435
+ });
436
+ return me(() => {
437
+ _.value = !!u.modelValue;
438
+ }), (p, m) => {
439
+ const a = V("FmSwitch"), d = V("FmTextField"), i = V("FmButton");
440
+ return h(), P("div", vt, [
441
+ r(a, {
442
+ modelValue: e(_),
443
+ "onUpdate:modelValue": m[0] || (m[0] = (n) => ue(_) ? _.value = n : null),
444
+ value: "true",
445
+ label: "Enable Stripe"
446
+ }, null, 8, ["modelValue"]),
447
+ u.modelValue ? (h(), P("div", ht, [
448
+ r(d, {
449
+ label: "API Key",
450
+ modelValue: u.modelValue.apiKey,
451
+ "onUpdate:modelValue": m[1] || (m[1] = (n) => u.modelValue.apiKey = n),
452
+ "helper-text": "Go to Stripe Dashboard get your API Key and paste here."
453
+ }, null, 8, ["modelValue"]),
454
+ r(d, {
455
+ label: "Webhook URL",
456
+ "model-value": e(t),
457
+ readonly: "",
458
+ "helper-text": "Copy this URL to your Stripe dashboard"
459
+ }, {
460
+ append: T(() => [
461
+ r(i, {
462
+ icon: "content_copy",
463
+ variant: "tertiary",
464
+ onClick: m[2] || (m[2] = (n) => e(Oe)(e(t)))
465
+ })
466
+ ]),
467
+ _: 1
468
+ }, 8, ["model-value"]),
469
+ r(d, {
470
+ modelValue: u.modelValue.webhookSecret,
471
+ "onUpdate:modelValue": m[3] || (m[3] = (n) => u.modelValue.webhookSecret = n),
472
+ label: "Webhook Secret",
473
+ "helper-text": `Copy the webhook signing secret from your Stripe account and paste
474
+ here.`
475
+ }, null, 8, ["modelValue"])
476
+ ])) : W("", !0)
477
+ ]);
478
+ };
479
+ }
480
+ }), _t = {
481
+ key: 0,
482
+ class: "space-y-16 pr-12"
483
+ }, Ct = /* @__PURE__ */ v("div", { class: "fm-typo-en-title-sm-800 !mb-[-12px]" }, " Company legal information ", -1), Vt = {
484
+ key: 0,
485
+ class: "space-y-16"
486
+ }, St = /* @__PURE__ */ v("div", { class: "fm-typo-en-title-sm-800 !mb-[-12px]" }, "Tax", -1), Ft = /* @__PURE__ */ v("div", { class: "fm-typo-en-title-sm-800 !mb-[-12px]" }, "Address", -1), wt = { class: "grid grid-cols-2 gap-x-16 gap-y-16" }, $t = { class: "space-y-4" }, Tt = /* @__PURE__ */ v("div", { class: "fm-typo-en-body-lg-400" }, "State", -1), Pt = { class: "space-y-16" }, Ut = /* @__PURE__ */ v("div", { class: "fm-typo-en-title-sm-800 !mb-[-12px]" }, " Stripe Integration ", -1), kt = { class: "flex items-center gap-8" }, It = /* @__PURE__ */ G({
487
+ __name: "StoreSettingSheet",
488
+ emits: ["update"],
489
+ setup(f, { expose: b, emit: u }) {
490
+ const F = u, _ = A(!1), t = A(), p = A(!1), m = qe.extend({
491
+ company: Ke.extend({
492
+ name: L.string().min(1, "Company name is required"),
493
+ regNo: L.string().min(1, "Registration number is required"),
494
+ address: We.extend({
495
+ line1: L.string().min(1, "Line 1 is required"),
496
+ line2: L.string().optional(),
497
+ state: L.string().min(1, "State is required"),
498
+ city: L.string().min(1, "City is required"),
499
+ postcode: L.string().min(1, "Postcode is required"),
500
+ country: L.string().min(1, "Country is required")
501
+ }),
502
+ phoneNo: L.string().min(1, "Phone number is required"),
503
+ sstRegNo: L.string().optional()
504
+ })
505
+ }), a = R(() => m.safeParse(t.value).success);
506
+ function d() {
507
+ const y = m.safeParse(t.value);
508
+ y.success && F("update", y.data);
509
+ }
510
+ function i() {
511
+ return {
512
+ company: {
513
+ name: "",
514
+ address: {
515
+ line1: "",
516
+ line2: "",
517
+ city: "",
518
+ postcode: "",
519
+ state: "",
520
+ country: D.Config.getCountry().name
521
+ },
522
+ phoneNo: "",
523
+ regNo: "",
524
+ sstRegNo: ""
525
+ },
526
+ inclusiveTaxes: []
527
+ };
528
+ }
529
+ function n(y, l) {
530
+ _.value = y, y && (t.value = l != null && l.company ? l : i());
531
+ }
532
+ return b({
533
+ showSheet: n,
534
+ data: t
535
+ }), (y, l) => {
536
+ const g = V("FmIcon"), k = V("FmMenuItem"), B = V("FmMenu"), C = V("FmSelect"), $ = V("FmButton"), U = V("FmSideSheet");
537
+ return h(), E(U, {
538
+ "max-width": 560,
539
+ modelValue: e(_),
540
+ "onUpdate:modelValue": l[15] || (l[15] = (I) => ue(_) ? _.value = I : null),
541
+ header: "Store setting"
542
+ }, {
543
+ "side-sheet-footer": T(() => [
544
+ v("div", kt, [
545
+ r($, {
546
+ label: "Submit",
547
+ onClick: d,
548
+ disabled: !e(a) || e(be)().isLoading,
549
+ loading: e(be)().isLoading
550
+ }, null, 8, ["disabled", "loading"]),
551
+ r($, {
552
+ label: "Cancel",
553
+ onClick: l[14] || (l[14] = (I) => n(!1)),
554
+ variant: "tertiary"
555
+ })
556
+ ])
557
+ ]),
558
+ default: T(() => {
559
+ var I, M;
560
+ return [
561
+ r(he, { json: e(t) }, null, 8, ["json"]),
562
+ e(t) && e(t).company ? (h(), P("div", _t, [
563
+ Ct,
564
+ r(Y, {
565
+ modelValue: e(t).company.name,
566
+ "onUpdate:modelValue": l[0] || (l[0] = (c) => e(t).company.name = c),
567
+ label: "Company name",
568
+ schema: e(H).typeAtPath(e(m), "company.name")
569
+ }, null, 8, ["modelValue", "schema"]),
570
+ r(Y, {
571
+ modelValue: e(t).company.regNo,
572
+ "onUpdate:modelValue": l[1] || (l[1] = (c) => e(t).company.regNo = c),
573
+ label: "Registration number",
574
+ schema: e(H).typeAtPath(e(m), "company.regNo")
575
+ }, null, 8, ["modelValue", "schema"]),
576
+ r(Y, {
577
+ modelValue: e(t).company.sstRegNo,
578
+ "onUpdate:modelValue": [
579
+ l[2] || (l[2] = (c) => e(t).company.sstRegNo = c),
580
+ l[3] || (l[3] = (c) => c ? null : e(t).inclusiveTaxes = [])
581
+ ],
582
+ label: "Tax Registration number",
583
+ schema: e(H).typeAtPath(e(m), "company.sstRegNo")
584
+ }, null, 8, ["modelValue", "schema"]),
585
+ (I = e(t).company) != null && I.sstRegNo && e(t).inclusiveTaxes ? (h(), P("div", Vt, [
586
+ St,
587
+ r(gt, {
588
+ modelValue: e(t).inclusiveTaxes,
589
+ "onUpdate:modelValue": l[4] || (l[4] = (c) => e(t).inclusiveTaxes = c)
590
+ }, null, 8, ["modelValue"])
591
+ ])) : W("", !0),
592
+ r(Y, {
593
+ modelValue: e(t).company.phoneNo,
594
+ "onUpdate:modelValue": l[5] || (l[5] = (c) => e(t).company.phoneNo = c),
595
+ label: "Phone number",
596
+ schema: e(H).typeAtPath(e(m), "company.phoneNo")
597
+ }, null, 8, ["modelValue", "schema"]),
598
+ Ft,
599
+ r(Y, {
600
+ modelValue: e(t).company.address.line1,
601
+ "onUpdate:modelValue": l[6] || (l[6] = (c) => e(t).company.address.line1 = c),
602
+ label: "Line 1",
603
+ schema: e(H).typeAtPath(e(m), "company.address.line1")
604
+ }, null, 8, ["modelValue", "schema"]),
605
+ r(Y, {
606
+ modelValue: e(t).company.address.line2,
607
+ "onUpdate:modelValue": l[7] || (l[7] = (c) => e(t).company.address.line2 = c),
608
+ label: "Line 2",
609
+ schema: e(H).typeAtPath(e(m), "company.address.line2")
610
+ }, null, 8, ["modelValue", "schema"]),
611
+ v("div", wt, [
612
+ r(Y, {
613
+ modelValue: e(t).company.address.city,
614
+ "onUpdate:modelValue": l[8] || (l[8] = (c) => e(t).company.address.city = c),
615
+ label: "City",
616
+ schema: e(H).typeAtPath(e(m), "company.address.city")
617
+ }, null, 8, ["modelValue", "schema"]),
618
+ r(Y, {
619
+ modelValue: e(t).company.address.postcode,
620
+ "onUpdate:modelValue": l[9] || (l[9] = (c) => e(t).company.address.postcode = c),
621
+ label: "Postcode",
622
+ schema: e(H).typeAtPath(e(m), "company.address.postcode")
623
+ }, null, 8, ["modelValue", "schema"]),
624
+ v("div", $t, [
625
+ Tt,
626
+ r(B, {
627
+ placement: "top-end",
628
+ "model-value": e(p)
629
+ }, {
630
+ "menu-button": T(() => [
631
+ r(Y, {
632
+ modelValue: e(t).company.address.state,
633
+ "onUpdate:modelValue": l[10] || (l[10] = (c) => e(t).company.address.state = c),
634
+ schema: e(H).typeAtPath(e(m), "company.address.state"),
635
+ onFocusChanged: l[11] || (l[11] = (c) => p.value = c)
636
+ }, {
637
+ append: T(() => [
638
+ r(g, {
639
+ name: e(p) ? "keyboard_arrow_up" : "keyboard_arrow_down"
640
+ }, null, 8, ["name"])
641
+ ]),
642
+ _: 1
643
+ }, 8, ["modelValue", "schema"])
644
+ ]),
645
+ default: T(() => [
646
+ (h(!0), P(J, null, te(e(yt)[e(D.Config).getCountry().code].stateItems.filter(
647
+ (c) => {
648
+ var N, O;
649
+ return c.label.toLowerCase().includes(((O = (N = e(t)) == null ? void 0 : N.company) == null ? void 0 : O.address.state.toLowerCase()) ?? "");
650
+ }
651
+ ) || [], (c) => (h(), E(k, {
652
+ key: c.value,
653
+ "model-value": e(t).company.address.state === c.value,
654
+ label: c.label,
655
+ onClick: () => {
656
+ e(t).company.address.state = c.value, p.value = !1;
657
+ }
658
+ }, null, 8, ["model-value", "label", "onClick"]))), 128))
659
+ ]),
660
+ _: 1
661
+ }, 8, ["model-value"])
662
+ ]),
663
+ r(C, {
664
+ label: "Country",
665
+ modelValue: e(t).company.address.country,
666
+ "onUpdate:modelValue": l[12] || (l[12] = (c) => e(t).company.address.country = c),
667
+ items: [
668
+ {
669
+ label: e(D.Config).getCountry().name,
670
+ value: e(D.Config).getCountry().name
671
+ }
672
+ ],
673
+ rules: [e(H).ruleAtPath(e(m), "company.address.country")]
674
+ }, null, 8, ["modelValue", "items", "rules"])
675
+ ]),
676
+ v("div", Pt, [
677
+ Ut,
678
+ r(xt, {
679
+ "model-value": (M = e(t)) == null ? void 0 : M.stripe,
680
+ "onUpdate:modelValue": l[13] || (l[13] = (c) => e(t).stripe = c)
681
+ }, null, 8, ["model-value"])
682
+ ])
683
+ ])) : W("", !0)
684
+ ];
685
+ }),
686
+ _: 1
687
+ }, 8, ["modelValue"]);
688
+ };
689
+ }
690
+ });
691
+ function Rt(f, b = !0) {
692
+ return D.DineroFactory(f).toFormat(b);
693
+ }
694
+ const Dt = /* @__PURE__ */ G({
695
+ __name: "TaxVariantSetting",
696
+ props: {
697
+ modelValue: {
698
+ type: Array,
699
+ required: !0,
700
+ default: () => []
701
+ }
702
+ },
703
+ emits: ["update:modelValue"],
704
+ setup(f, { emit: b }) {
705
+ const u = f, F = b;
706
+ me(() => {
707
+ if (p.value.length !== t.value.length) {
708
+ const d = t.value.reduce((i, n) => {
709
+ const y = z.systemDefaultCode(n.name);
710
+ if (!y) return i;
711
+ const { systemCode: l, taxCode: g } = y;
712
+ return n.value || i.push({ systemCode: l, taxCode: g }), i;
713
+ }, []);
714
+ a(d);
715
+ }
716
+ });
717
+ function _() {
718
+ return z.groupedTaxOptions();
719
+ }
720
+ const t = R(() => _().map((d) => ({
721
+ name: d.code,
722
+ value: (p.value || []).find(
723
+ (i) => d.options.some((n) => n.feedmeTaxCode === i)
724
+ ),
725
+ options: d.options.map((i) => ({
726
+ label: `${i.name} (${Qe(i.rate)}%)`,
727
+ value: i.feedmeTaxCode
728
+ }))
729
+ }))), p = R(() => u.modelValue.map((d) => z.generateCode(d)));
730
+ function m(d) {
731
+ const i = _().find(
732
+ (g) => g.options.some((k) => k.feedmeTaxCode === d)
733
+ ), n = i == null ? void 0 : i.options.find((g) => g.feedmeTaxCode === d);
734
+ if (!n) return;
735
+ const { systemCode: y, taxCode: l } = n;
736
+ a([{ systemCode: y, taxCode: l }]);
737
+ }
738
+ function a(d) {
739
+ const i = ie.clone(u.modelValue);
740
+ d.forEach((n) => {
741
+ const y = _().find(
742
+ (k) => k.options.some((B) => B.feedmeTaxCode === z.generateCode(n))
743
+ ), l = (y == null ? void 0 : y.options) || [], g = i.findIndex(
744
+ (k) => l.some((B) => z.generateCode(B) === z.generateCode(k))
745
+ );
746
+ g >= 0 ? i.splice(g, 1, n) : i.push(n);
747
+ }), F("update:modelValue", i);
748
+ }
749
+ return (d, i) => {
750
+ const n = V("FmRadio"), y = V("FmRadioGroup");
751
+ return h(!0), P(J, null, te(e(t), (l) => (h(), P("div", {
752
+ key: l.name,
753
+ class: "flex items-start"
754
+ }, [
755
+ r(y, {
756
+ modelValue: l.value,
757
+ "onUpdate:modelValue": [
758
+ (g) => l.value = g,
759
+ i[0] || (i[0] = (g) => {
760
+ m(g);
761
+ })
762
+ ]
763
+ }, {
764
+ default: T(() => [
765
+ (h(!0), P(J, null, te(l.options, (g, k) => (h(), E(n, {
766
+ key: k,
767
+ value: g.value,
768
+ label: g.label
769
+ }, null, 8, ["value", "label"]))), 128))
770
+ ]),
771
+ _: 2
772
+ }, 1032, ["modelValue", "onUpdate:modelValue"])
773
+ ]))), 128);
774
+ };
775
+ }
776
+ }), Bt = {
777
+ key: 0,
778
+ class: "space-y-24 pr-12"
779
+ }, Nt = /* @__PURE__ */ v("div", { class: "fm-typo-en-title-sm-800 !mb-[-16px]" }, "Basic information", -1), At = {
780
+ key: 0,
781
+ class: "fm-typo-en-title-sm-800 !mb-[-16px]"
782
+ }, Et = /* @__PURE__ */ v("div", { class: "fm-typo-en-title-sm-800 !mb-[-16px]" }, "Credit", -1), Mt = /* @__PURE__ */ v("div", { class: "fm-typo-en-title-sm-800 !mb-[-16px]" }, "Taxes", -1), Ot = /* @__PURE__ */ v("div", { class: "fm-typo-en-title-sm-800 !mb-[-20px]" }, "Bundle reward", -1), jt = /* @__PURE__ */ v("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary !mb-[-16px]" }, " Let your member know what they can expect from this bundle ", -1), Lt = { class: "space-y-8" }, Ht = { class: "flex items-center justify-between" }, qt = /* @__PURE__ */ v("div", { class: "fm-typo-en-title-sm-800 !mb-[-20px]" }, "Advanced Setting", -1), Kt = { class: "space-y-8" }, Wt = { class: "flex items-center gap-8" }, Jt = /* @__PURE__ */ G({
783
+ __name: "EditBundleSheet",
784
+ emits: ["update"],
785
+ setup(f, { expose: b, emit: u }) {
786
+ const F = {
787
+ get _id() {
788
+ return (/* @__PURE__ */ new Date()).toISOString();
789
+ },
790
+ name: "",
791
+ price: D.Dinero.zero().toObject(),
792
+ vouchers: [],
793
+ credit: {
794
+ normal: 0,
795
+ free: {
796
+ amount: 0,
797
+ day: 0
798
+ }
799
+ },
800
+ config: {
801
+ options: {}
802
+ },
803
+ titles: [],
804
+ taxes: [],
805
+ taxTotals: [],
806
+ internal: !1,
807
+ priceWithTaxes: Ge()
808
+ }, _ = u, t = Ue(), p = A(!1), m = A({
809
+ category: 0,
810
+ index: -1
811
+ }), a = A(ie.cloneDeep(F)), d = A(), i = Te.superRefine((s, o) => {
812
+ var x, w;
813
+ s.price.amount < 0 && o.addIssue({
814
+ code: "custom",
815
+ path: ["price"],
816
+ message: "Price cannot be less than 0"
817
+ }), s.coinPrice && s.coinPrice < 0 && o.addIssue({
818
+ code: "custom",
819
+ path: ["coinPrice"],
820
+ message: "Point price cannot be less than 0"
821
+ }), s.credit.normal < 0 && o.addIssue({
822
+ code: "custom",
823
+ path: ["credit", "normal"],
824
+ message: "Normal credit cannot be less than 0"
825
+ }), s.credit.free && (s.credit.free.amount < 0 && o.addIssue({
826
+ code: "custom",
827
+ path: ["credit", "free", "amount"],
828
+ message: "Free credit cannot be less than 0"
829
+ }), s.credit.free.amount && s.credit.free.day < 0 && o.addIssue({
830
+ code: "custom",
831
+ path: ["credit", "free", "day"],
832
+ message: "Expiry must be at least 0 (expire same day)"
833
+ })), s.credit.normal && s.coinPrice && o.addIssue({
834
+ code: "custom",
835
+ message: "Bundle redeem with point cannot set normal credit.",
836
+ path: ["credit", "normal"]
837
+ }), s.credit.normal > D.Dinero.fromFdoDinero(s.price).toUnit() && o.addIssue({
838
+ code: "custom",
839
+ message: `Normal credit cannot be more than price. Max: ${D.Dinero.fromFdoDinero(s.price).toUnit()}`,
840
+ path: ["credit", "normal"]
841
+ }), s.titles.length > 0 && s.titles.some((j) => j.dayToExpire < 0) && o.addIssue({
842
+ code: "custom",
843
+ path: ["titles"],
844
+ message: "Title expiry must be at least 0 day (expire same day)"
845
+ }), (((w = (x = s.config) == null ? void 0 : x.options) == null ? void 0 : w.maxPerUser) || 0) < 0 && o.addIssue({
846
+ code: "custom",
847
+ path: ["config.options.maxPerUser"],
848
+ message: "Max purchase per user cannot be negative"
849
+ });
850
+ }), n = R(() => {
851
+ const s = i.safeParse(a.value);
852
+ return s.success ? [] : s.error.errors;
853
+ }), y = [
854
+ {
855
+ header: "Reward title",
856
+ accessorFn: (s) => s.collectible.name,
857
+ enableSorting: !0
858
+ },
859
+ {
860
+ id: "type",
861
+ header: "Reward type",
862
+ accessorFn: (s) => s.collectible.type,
863
+ cell(s) {
864
+ return le[s.row.original.collectible.type].chip();
865
+ }
866
+ },
867
+ {
868
+ header: "Description",
869
+ accessorFn: (s) => s.description,
870
+ cell(s) {
871
+ var x;
872
+ const o = s.row.original;
873
+ return o.collectible.type == "VOUCHER" || o.selectedReward == null ? o.description : De(Ae.FmStepperField, {
874
+ "onUpdate:modelValue": (w) => {
875
+ a.value.titles = a.value.titles.map(
876
+ (j) => j.id == o.collectible._id ? { ...j, dayToExpire: w } : j
877
+ );
878
+ },
879
+ modelValue: ((x = o.selectedReward) == null ? void 0 : x.extra) ?? 0,
880
+ appendText: "day(s)",
881
+ showSteppers: !1,
882
+ disabled: !!a.value.stripePriceId
883
+ });
884
+ }
885
+ }
886
+ ], l = A([]), g = R(() => t.bundleRewards.map((s) => {
887
+ const o = k.value.find((w) => w.id == s._id), x = s.type === "VOUCHER" ? `${s.options.maxUse} use(s), ${Xe(s.options.validityOption || {})}` : "No expiry";
888
+ return {
889
+ collectible: s,
890
+ description: x,
891
+ selectedReward: o
892
+ };
893
+ })), k = R(() => {
894
+ var s, o;
895
+ return [
896
+ ...((s = a.value) == null ? void 0 : s.titles.map((x) => ({
897
+ id: x.id,
898
+ extra: x.dayToExpire
899
+ }))) ?? [],
900
+ ...((o = a.value) == null ? void 0 : o.vouchers.map((x) => ({
901
+ id: x,
902
+ extra: void 0
903
+ }))) ?? []
904
+ ];
905
+ }), B = R(
906
+ () => a.value.stripePriceId && a.value.subscriptionValidity ? a.value.subscriptionValidity : 0
907
+ );
908
+ function C(s) {
909
+ a.value.subscriptionValidity = s;
910
+ for (const o of a.value.titles)
911
+ o.dayToExpire = s;
912
+ a.value.credit.free && (a.value.credit.free.day = s);
913
+ }
914
+ function $() {
915
+ const s = g.value, o = a.value;
916
+ if (!(!o || !s))
917
+ for (let x = 0; x < s.length; x++) {
918
+ const w = s[x];
919
+ U.value[x] ? w.collectible.type == "TITLE" ? o.titles.findIndex(
920
+ (ae) => ae.id == w.collectible._id
921
+ ) < 0 && o.titles.push({
922
+ id: w.collectible._id,
923
+ dayToExpire: B.value
924
+ }) : o.vouchers.findIndex(
925
+ (ae) => ae == w.collectible._id
926
+ ) < 0 && o.vouchers.push(w.collectible._id) : (o.titles = o.titles.filter((ee) => ee.id != w.collectible._id), o.vouchers = o.vouchers.filter(
927
+ (ee) => ee != w.collectible._id
928
+ ));
929
+ }
930
+ }
931
+ const U = A({});
932
+ ve(U, $, { deep: !0 });
933
+ const I = R(() => {
934
+ var s;
935
+ return (s = t.storeOption.company) == null ? void 0 : s.sstRegNo;
936
+ }), M = R(() => {
937
+ var s, o, x;
938
+ return (x = (o = (s = t.storeOption) == null ? void 0 : s.inclusiveTaxes) == null ? void 0 : o[0]) != null && x.inclusive ? "Inclusive" : "Exclusive";
939
+ }), c = R(() => {
940
+ var s, o;
941
+ return ot(
942
+ z.fullTax,
943
+ Re(a.value.taxes),
944
+ a.value.price,
945
+ Number(a.value.credit.normal),
946
+ ((s = t.storeOption) == null ? void 0 : s.inclusiveTaxes) ?? [],
947
+ (o = t.storeOption.company) != null && o.sstRegNo ? z.taxSystem.map((x) => x.code) : []
948
+ );
949
+ }), N = R(() => c.value.reduce(
950
+ (o, x) => o.add(x.total),
951
+ Ze()
952
+ ).toFormat()), O = R(() => {
953
+ var w;
954
+ const s = at(
955
+ c.value,
956
+ a.value.price,
957
+ ((w = t.storeOption) == null ? void 0 : w.inclusiveTaxes) ?? []
958
+ );
959
+ a.value.priceWithTaxes = s;
960
+ const o = Rt(s, !1), x = Number(o.replace(/[^\d.-]/g, ""));
961
+ return Number.isNaN(x) ? 0 : x;
962
+ });
963
+ function X() {
964
+ a.value.taxTotals = c.value, _("update", Te.parse(Me(a.value)));
965
+ }
966
+ function Z() {
967
+ return ie.cloneDeep(F);
968
+ }
969
+ function xe(s, o) {
970
+ p.value = s, s && o && (console.log(o.bundle, "set.bundle"), d.value = void 0, a.value = o.bundle || Z(), m.value.category = o.category, m.value.index = o.index, U.value = g.value.reduce((x, w, j) => (x[j] = !!w.selectedReward, x), {}));
971
+ }
972
+ return b({
973
+ showSheet: xe,
974
+ bundleImage: d,
975
+ target: m,
976
+ data: a
977
+ }), (s, o) => {
978
+ const x = V("FmTextField"), w = V("FmStepperField"), j = V("FmMenuItem"), ee = V("FmTable"), ae = V("FmHelperText"), _e = V("FmSwitch"), Ce = V("FmButton"), ke = V("FmSideSheet");
979
+ return h(), E(ke, {
980
+ "max-width": 560,
981
+ modelValue: e(p),
982
+ "onUpdate:modelValue": o[17] || (o[17] = (ne) => ue(p) ? p.value = ne : null),
983
+ header: e(m).index != -1 ? "Edit bundle" : "Create bundle"
984
+ }, {
985
+ "side-sheet-footer": T(() => [
986
+ v("div", Wt, [
987
+ r(Ce, {
988
+ label: e(m).index != -1 ? "Save" : "Add",
989
+ onClick: X,
990
+ disabled: e(n).length > 0,
991
+ loading: e(be)().isLoading
992
+ }, null, 8, ["label", "disabled", "loading"]),
993
+ r(Ce, {
994
+ label: "Cancel",
995
+ onClick: o[16] || (o[16] = (ne) => xe(!1)),
996
+ variant: "tertiary"
997
+ })
998
+ ])
999
+ ]),
1000
+ default: T(() => {
1001
+ var ne, Ve, Se, Fe, we;
1002
+ return [
1003
+ r(he, { json: e(a) }, null, 8, ["json"]),
1004
+ e(a) ? (h(), P("div", Bt, [
1005
+ Nt,
1006
+ r(x, {
1007
+ label: "Bundle name",
1008
+ modelValue: e(a).name,
1009
+ "onUpdate:modelValue": o[0] || (o[0] = (S) => e(a).name = S),
1010
+ "helper-state": e(q)(e(n), "name"),
1011
+ "helper-text": e(K)(e(n), "name")
1012
+ }, null, 8, ["modelValue", "helper-state", "helper-text"]),
1013
+ r(Ye, {
1014
+ label: "Bundle image",
1015
+ class: "w-1/2 xs:w-2/3",
1016
+ "aspect-ratio": "16/9",
1017
+ thumbnail: e(a).image ?? void 0,
1018
+ file: e(d) ?? void 0,
1019
+ "onUpdate:file": o[1] || (o[1] = (S) => {
1020
+ d.value = S;
1021
+ }),
1022
+ "helper-state": e(q)(e(n), "image"),
1023
+ "helper-text": e(K)(e(n), "image")
1024
+ }, null, 8, ["thumbnail", "file", "helper-state", "helper-text"]),
1025
+ r(w, {
1026
+ "model-value": e(D.Dinero).fromFdoDinero(e(a).price).toUnit(),
1027
+ label: "Price",
1028
+ min: 0,
1029
+ "max-fraction-digits": 2,
1030
+ "onUpdate:modelValue": o[2] || (o[2] = (S) => {
1031
+ e(a).price.amount = S * 10 ** e(a).price.precision;
1032
+ }),
1033
+ "is-currency": !0,
1034
+ "show-steppers": !1,
1035
+ "helper-text": e(K)(e(n), "price") || `${e(D.Dinero).fromNumber({ number: 1 }).toFormat(!0)} = ${e(D.Dinero).fromNumber({ number: 1 }).toUnit()} credit`,
1036
+ "helper-state": e(q)(e(n), "price")
1037
+ }, {
1038
+ prepend: T(() => [
1039
+ oe(de(e(D.Dinero).defaultCurrency()), 1)
1040
+ ]),
1041
+ _: 1
1042
+ }, 8, ["model-value", "helper-text", "helper-state"]),
1043
+ r(w, {
1044
+ "model-value": e(a).coinPrice ?? null,
1045
+ label: "Point Needed",
1046
+ min: 0,
1047
+ "onUpdate:modelValue": o[3] || (o[3] = (S) => {
1048
+ S > 0 && e(a).credit.normal > 0 && (e(a).credit.normal = 0), e(a).coinPrice = S;
1049
+ }),
1050
+ "show-steppers": !1,
1051
+ "helper-state": e(q)(e(n), "coinPrice"),
1052
+ "helper-text": e(K)(e(n), "coinPrice")
1053
+ }, {
1054
+ append: T(() => [
1055
+ oe(" point(s) ")
1056
+ ]),
1057
+ _: 1
1058
+ }, 8, ["model-value", "helper-state", "helper-text"]),
1059
+ e(t).storeOption.stripe ? (h(), P("div", At, " Subscription Settings ")) : W("", !0),
1060
+ e(t).storeOption.stripe ? (h(), E(x, {
1061
+ key: 1,
1062
+ label: "Stripe Price ID",
1063
+ modelValue: e(a).stripePriceId,
1064
+ "onUpdate:modelValue": o[4] || (o[4] = (S) => e(a).stripePriceId = S),
1065
+ "helper-state": e(q)(e(n), "stripePriceId"),
1066
+ "helper-text": e(K)(e(n), "stripePriceId")
1067
+ }, null, 8, ["modelValue", "helper-state", "helper-text"])) : W("", !0),
1068
+ e(a).stripePriceId ? (h(), E(w, {
1069
+ key: 2,
1070
+ "model-value": e(a).subscriptionValidity ?? null,
1071
+ min: 1,
1072
+ "onUpdate:modelValue": C,
1073
+ label: "Subscription validity (days)",
1074
+ "show-steppers": !1,
1075
+ "helper-state": e(q)(e(n), "subscriptionValidity"),
1076
+ "helper-text": e(K)(e(n), "subscriptionValidity")
1077
+ }, {
1078
+ append: T(() => [
1079
+ oe(" day(s) ")
1080
+ ]),
1081
+ _: 1
1082
+ }, 8, ["model-value", "helper-state", "helper-text"])) : W("", !0),
1083
+ Et,
1084
+ r(w, {
1085
+ modelValue: e(a).credit.normal,
1086
+ "onUpdate:modelValue": o[5] || (o[5] = (S) => e(a).credit.normal = S),
1087
+ label: "Normal credit",
1088
+ "show-steppers": !1,
1089
+ "helper-state": e(q)(e(n), "credit.normal"),
1090
+ "helper-text": e(K)(e(n), "credit.normal")
1091
+ }, {
1092
+ append: T(() => [
1093
+ oe(" credit ")
1094
+ ]),
1095
+ _: 1
1096
+ }, 8, ["modelValue", "helper-state", "helper-text"]),
1097
+ r(w, {
1098
+ "model-value": ((ne = e(a).credit.free) == null ? void 0 : ne.amount) ?? null,
1099
+ min: 0,
1100
+ "onUpdate:modelValue": o[6] || (o[6] = (S) => {
1101
+ e(a).credit.free || (e(a).credit.free = {
1102
+ amount: 0,
1103
+ day: 1
1104
+ }), e(a).credit.free.amount = S;
1105
+ }),
1106
+ label: "Free credit",
1107
+ "show-steppers": !1,
1108
+ "helper-state": e(q)(e(n), "credit.free.amount"),
1109
+ "helper-text": e(K)(e(n), "credit.free.amount")
1110
+ }, {
1111
+ append: T(() => [
1112
+ oe(" credit ")
1113
+ ]),
1114
+ _: 1
1115
+ }, 8, ["model-value", "helper-state", "helper-text"]),
1116
+ (Ve = e(a).credit.free) != null && Ve.amount ? (h(), E(w, {
1117
+ key: 3,
1118
+ disabled: !!e(a).stripePriceId,
1119
+ "model-value": ((Se = e(a).credit.free) == null ? void 0 : Se.day) ?? null,
1120
+ min: 0,
1121
+ "onUpdate:modelValue": o[7] || (o[7] = (S) => {
1122
+ e(a).credit.free || (e(a).credit.free = {
1123
+ amount: 0,
1124
+ day: 1
1125
+ }), e(a).credit.free.day = e(B) || S;
1126
+ }),
1127
+ label: "Free credit valid for",
1128
+ "show-steppers": !1,
1129
+ "helper-state": e(q)(e(n), "credit.free.day"),
1130
+ "helper-text": e(K)(e(n), "credit.free.day")
1131
+ }, {
1132
+ append: T(() => [
1133
+ oe(" day(s) ")
1134
+ ]),
1135
+ _: 1
1136
+ }, 8, ["disabled", "model-value", "helper-state", "helper-text"])) : W("", !0),
1137
+ e(I) ? (h(), P(J, { key: 4 }, [
1138
+ Mt,
1139
+ r(Dt, {
1140
+ modelValue: e(a).taxes,
1141
+ "onUpdate:modelValue": o[8] || (o[8] = (S) => e(a).taxes = S)
1142
+ }, null, 8, ["modelValue"]),
1143
+ r(x, {
1144
+ label: `Tax Charged (${e(M)})`,
1145
+ "model-value": e(N),
1146
+ disabled: ""
1147
+ }, null, 8, ["label", "model-value"])
1148
+ ], 64)) : W("", !0),
1149
+ r(w, {
1150
+ label: "Total Price",
1151
+ "model-value": e(O),
1152
+ disabled: !0
1153
+ }, null, 8, ["model-value"]),
1154
+ Ot,
1155
+ jt,
1156
+ v("div", Lt, [
1157
+ v("div", Ht, [
1158
+ r(ze, {
1159
+ label: `Reward type: ${e(l).length == 0 ? "All" : e(l)[0].name}`
1160
+ }, {
1161
+ default: T(() => [
1162
+ r(j, {
1163
+ onClick: o[9] || (o[9] = (S) => l.value = []),
1164
+ label: "All"
1165
+ }),
1166
+ r(j, {
1167
+ onClick: o[10] || (o[10] = (S) => l.value = [
1168
+ {
1169
+ id: "type",
1170
+ value: "VOUCHER",
1171
+ name: e(le).VOUCHER.name
1172
+ }
1173
+ ]),
1174
+ label: e(le).VOUCHER.name
1175
+ }, null, 8, ["label"]),
1176
+ r(j, {
1177
+ onClick: o[11] || (o[11] = (S) => l.value = [
1178
+ {
1179
+ id: "type",
1180
+ value: "TITLE",
1181
+ name: e(le).TITLE.name
1182
+ }
1183
+ ]),
1184
+ label: e(le).TITLE.name
1185
+ }, null, 8, ["label"])
1186
+ ]),
1187
+ _: 1
1188
+ }, 8, ["label"])
1189
+ ]),
1190
+ r(ee, {
1191
+ modelValue: e(U),
1192
+ "onUpdate:modelValue": o[12] || (o[12] = (S) => ue(U) ? U.value = S : null),
1193
+ selection: "multiple",
1194
+ "column-filter": e(l),
1195
+ "column-defs": y,
1196
+ "row-data": e(g),
1197
+ "hide-footer": e(g).length <= 10
1198
+ }, null, 8, ["modelValue", "column-filter", "row-data", "hide-footer"]),
1199
+ r(ae, {
1200
+ text: e(K)(e(n), "titles"),
1201
+ state: e(q)(e(n), "titles")
1202
+ }, null, 8, ["text", "state"])
1203
+ ]),
1204
+ qt,
1205
+ v("div", Kt, [
1206
+ r(_e, {
1207
+ "model-value": e(a).internal ?? !1,
1208
+ "onUpdate:modelValue": o[13] || (o[13] = (S) => e(a).internal = S),
1209
+ "label-placement": "right",
1210
+ label: "Internal Bundle",
1211
+ sublabel: "Internal bundle will be hidden in FeedMe member app"
1212
+ }, null, 8, ["model-value"]),
1213
+ r(_e, {
1214
+ "model-value": e(a).hideInPos ?? !1,
1215
+ "onUpdate:modelValue": o[14] || (o[14] = (S) => e(a).hideInPos = S),
1216
+ "label-placement": "right",
1217
+ label: "Hide In POS",
1218
+ sublabel: "Bundle will be hidden in FeedMe POS"
1219
+ }, null, 8, ["model-value"]),
1220
+ r(w, {
1221
+ "model-value": ((we = (Fe = e(a).config) == null ? void 0 : Fe.options) == null ? void 0 : we.maxPerUser) || null,
1222
+ "onUpdate:modelValue": o[15] || (o[15] = (S) => e(ie).set(e(a), "config.options.maxPerUser", S)),
1223
+ label: "Max purchase per user",
1224
+ "show-steppers": !1,
1225
+ placeholder: "Unlimited"
1226
+ }, null, 8, ["model-value"])
1227
+ ])
1228
+ ])) : W("", !0)
1229
+ ];
1230
+ }),
1231
+ _: 1
1232
+ }, 8, ["modelValue", "header"]);
1233
+ };
1234
+ }
1235
+ }), Yt = { class: "px-24 flex flex-col gap-y-16" }, zt = { class: "flex gap-8 items-center" }, Gt = { class: "fm-typo-en-body-lg-600" }, Zt = { class: "grid sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-24" }, Qt = /* @__PURE__ */ v("img", {
1236
+ src: Be,
1237
+ class: "aspect-square w-[150px]"
1238
+ }, null, -1), Xt = /* @__PURE__ */ v("div", { class: "flex flex-col gap-16 text-center" }, [
1239
+ /* @__PURE__ */ v("div", { class: "fm-typo-en-title-sm-800" }, "Store bundle"),
1240
+ /* @__PURE__ */ v("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Add item that you want to let your user spend and get here. It can be bunch of vouchers, benefits, experience and more! ")
1241
+ ], -1), xo = /* @__PURE__ */ G({
1242
+ __name: "Store",
1243
+ setup(f) {
1244
+ const b = {
1245
+ label: "Store setting",
1246
+ value: "setting",
1247
+ isPrimary: !1
1248
+ }, u = {
1249
+ label: "Manage reward",
1250
+ value: "create_reward"
1251
+ }, F = {
1252
+ label: "Add category",
1253
+ value: "create_category",
1254
+ isPrimary: !0,
1255
+ prependIcon: "add"
1256
+ }, _ = et(), t = Ue(), { global: p, minor: m } = Ee, a = Pe(), d = R(() => t.sortedStoreCategories), i = A(), n = A();
1257
+ async function y(C) {
1258
+ var $;
1259
+ C === "setting" ? ($ = i.value) == null || $.showSheet(!0, t.storeOption) : C === "create_category" ? g(-1) : C === "create_reward" && await _.push({ name: He["$connect-STORE_REWARDS"] });
1260
+ }
1261
+ async function l(C) {
1262
+ await m(
1263
+ async () => {
1264
+ var $;
1265
+ await ye.updateStore(C), await t.readMemberStore(), ($ = i.value) == null || $.showSheet(!1);
1266
+ },
1267
+ {
1268
+ message: "Updating store setting",
1269
+ successMessage: "Store setting updated successfully"
1270
+ }
1271
+ );
1272
+ }
1273
+ async function g(C = -1) {
1274
+ var $, U;
1275
+ if ((!t.storeOption || !t.storeOption.company) && await ce.confirm(
1276
+ "Please set up your store setting first before adding category.",
1277
+ "Update store setting",
1278
+ "Update now"
1279
+ ))
1280
+ return ($ = i.value) == null ? void 0 : $.showSheet(!0);
1281
+ a.open({
1282
+ title: C == -1 ? "Add category" : "Edit category",
1283
+ contentComponent: ft,
1284
+ contentComponentProps: {
1285
+ initialValue: ((U = d.value[C]) == null ? void 0 : U.name) ?? "",
1286
+ action: C == -1 ? "add" : "edit"
1287
+ }
1288
+ }).onPrimary(async (I) => {
1289
+ I === null && !await ce.remove(
1290
+ "Are you sure you want to remove category?",
1291
+ "Remove category"
1292
+ ) || await m(
1293
+ async () => {
1294
+ const M = C == -1 ? [...d.value, { name: I, bundles: [] }] : [...d.value].map((c, N) => N == C ? { ...c, name: I } : c).filter((c) => c.name !== null);
1295
+ await ye.updateStoreBundle({
1296
+ categories: M
1297
+ }), await t.readMemberStore();
1298
+ },
1299
+ {
1300
+ message: I === null ? "Deleting category" : C == -1 ? "Creating category" : "Updating categories",
1301
+ successMessage: `Category ${I === null ? "deleted" : C == -1 ? "created" : "updated"} successfully`
1302
+ }
1303
+ );
1304
+ });
1305
+ }
1306
+ async function k(C, $, U) {
1307
+ var c, N;
1308
+ $ ?? ($ = (c = n.value) == null ? void 0 : c.target.category), U ?? (U = (N = n.value) == null ? void 0 : N.target.index);
1309
+ const I = $e(d.value), M = I[$];
1310
+ if (!M) {
1311
+ je.error("Unexpected error", 2e3);
1312
+ return;
1313
+ }
1314
+ if (C == null) {
1315
+ if (await ce.remove(
1316
+ "Are you sure you want to delete this bundle?",
1317
+ "Delete bundle"
1318
+ ) == !1)
1319
+ return;
1320
+ M.bundles.splice(U, 1);
1321
+ } else
1322
+ U == -1 ? M.bundles.push(C) : M.bundles[U] = C;
1323
+ await m(
1324
+ async () => {
1325
+ var O, X;
1326
+ if (C != null) {
1327
+ const Z = (O = n.value) == null ? void 0 : O.bundleImage;
1328
+ Z === null && C.image ? (await pe.delete(C.image), C.image = null) : Z && (C.image = await pe.update(
1329
+ pe.bundleImagePath(void 0, Z),
1330
+ Z
1331
+ ));
1332
+ }
1333
+ await ye.updateStoreBundle({
1334
+ categories: I
1335
+ }), await t.readMemberStore(), await t.readMembership(), await t.readRewards(), (X = n.value) == null || X.showSheet(!1);
1336
+ },
1337
+ {
1338
+ message: `${C == null ? "Deleting" : U == -1 ? "Creating" : "Updating"} bundle`,
1339
+ successMessage: `Bundle ${C == null ? "deleted" : U == -1 ? "created" : "updated"} successfully`
1340
+ }
1341
+ );
1342
+ }
1343
+ function B(C) {
1344
+ var $;
1345
+ ($ = n.value) == null || $.showSheet(!0, {
1346
+ ...C,
1347
+ bundle: C.bundle ? $e(C.bundle) : void 0
1348
+ });
1349
+ }
1350
+ return me(async () => {
1351
+ await p(async () => {
1352
+ await t.readMemberStore(), await t.readMembership(), await t.readRewards();
1353
+ });
1354
+ }), (C, $) => {
1355
+ const U = V("FmPageHead"), I = V("FmButton"), M = V("FmCard");
1356
+ return h(), P(J, null, [
1357
+ r(U, {
1358
+ title: "Store",
1359
+ actions: [b, u, F],
1360
+ "onClick:action": y
1361
+ }, null, 8, ["actions"]),
1362
+ v("div", Yt, [
1363
+ e(d) && e(d).length > 0 ? (h(), P(J, { key: 0 }, [
1364
+ (h(!0), P(J, null, te(e(d), (c, N) => (h(), P("div", {
1365
+ key: c.name,
1366
+ class: "space-y-8 py-12"
1367
+ }, [
1368
+ v("div", zt, [
1369
+ v("div", Gt, de(c.name), 1),
1370
+ r(he, { json: c }, null, 8, ["json"]),
1371
+ r(I, {
1372
+ icon: "edit",
1373
+ size: "md",
1374
+ variant: "tertiary",
1375
+ onClick: (O) => g(N)
1376
+ }, null, 8, ["onClick"])
1377
+ ]),
1378
+ v("div", Zt, [
1379
+ (h(!0), P(J, null, te(c.bundles, (O, X) => (h(), E(ut, {
1380
+ bundle: O,
1381
+ key: O._id,
1382
+ onEdit: (Z) => B({ bundle: O, category: N, index: X }),
1383
+ onDelete: (Z) => k(null, N, X)
1384
+ }, null, 8, ["bundle", "onEdit", "onDelete"]))), 128)),
1385
+ r(mt, {
1386
+ onCreate: (O) => B({ category: N, index: -1 })
1387
+ }, null, 8, ["onCreate"])
1388
+ ])
1389
+ ]))), 128)),
1390
+ r(Jt, {
1391
+ ref_key: "bundleSheetRef",
1392
+ ref: n,
1393
+ onUpdate: k
1394
+ }, null, 512)
1395
+ ], 64)) : (h(), E(M, {
1396
+ key: 1,
1397
+ variant: "outlined",
1398
+ class: "w-full flex flex-col items-center justify-center gap-y-24 p-24"
1399
+ }, {
1400
+ default: T(() => [
1401
+ Qt,
1402
+ Xt,
1403
+ r(I, {
1404
+ variant: "primary",
1405
+ label: "Add category",
1406
+ icon: "add",
1407
+ onClick: $[0] || ($[0] = (c) => g(-1))
1408
+ })
1409
+ ]),
1410
+ _: 1
1411
+ })),
1412
+ r(It, {
1413
+ ref_key: "settingSheetRef",
1414
+ ref: i,
1415
+ onUpdate: l
1416
+ }, null, 512)
1417
+ ])
1418
+ ], 64);
1419
+ };
1420
+ }
1421
+ });
1422
+ export {
1423
+ xo as default
1424
+ };