@infrab4a/connect-angular 3.7.3 → 3.7.4-beta.0

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 (61) hide show
  1. package/angular-connect.module.d.ts +19 -19
  2. package/angular-elastic-search.module.d.ts +9 -9
  3. package/angular-firebase-auth.module.d.ts +10 -10
  4. package/angular-firestore.module.d.ts +15 -15
  5. package/angular-hasura-graphql.module.d.ts +16 -16
  6. package/bundles/infrab4a-connect-angular.umd.js +1950 -1954
  7. package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
  8. package/consts/backend-url.const.d.ts +1 -1
  9. package/consts/default-shop.const.d.ts +1 -1
  10. package/consts/es-config.const.d.ts +1 -1
  11. package/consts/hasura-options.const.d.ts +1 -1
  12. package/consts/index.d.ts +4 -4
  13. package/esm2015/angular-connect.module.js +52 -52
  14. package/esm2015/angular-elastic-search.module.js +38 -38
  15. package/esm2015/angular-firebase-auth.module.js +113 -113
  16. package/esm2015/angular-firestore.module.js +394 -394
  17. package/esm2015/angular-hasura-graphql.module.js +156 -156
  18. package/esm2015/consts/backend-url.const.js +1 -1
  19. package/esm2015/consts/default-shop.const.js +2 -2
  20. package/esm2015/consts/es-config.const.js +2 -2
  21. package/esm2015/consts/hasura-options.const.js +2 -2
  22. package/esm2015/consts/index.js +5 -5
  23. package/esm2015/index.js +6 -6
  24. package/esm2015/infrab4a-connect-angular.js +4 -4
  25. package/esm2015/services/auth.service.js +42 -42
  26. package/esm2015/services/cart.service.js +148 -148
  27. package/esm2015/services/checkout-subscription.service.js +51 -51
  28. package/esm2015/services/checkout.service.js +75 -75
  29. package/esm2015/services/coupon.service.js +247 -251
  30. package/esm2015/services/errors/group-invalid-coupon.error.js +8 -8
  31. package/esm2015/services/errors/index.js +3 -3
  32. package/esm2015/services/errors/invalid-coupon.error.js +8 -8
  33. package/esm2015/services/home-shop.service.js +116 -116
  34. package/esm2015/services/index.js +9 -9
  35. package/esm2015/services/order.service.js +32 -32
  36. package/esm2015/services/shipping.service.js +98 -98
  37. package/esm2015/services/types/index.js +3 -3
  38. package/esm2015/services/types/required-checkout-data.type.js +2 -2
  39. package/esm2015/services/types/required-checkout-subscription-data.type.js +2 -2
  40. package/esm2015/services/types/shipping-methods.type.js +2 -2
  41. package/fesm2015/infrab4a-connect-angular.js +1448 -1452
  42. package/fesm2015/infrab4a-connect-angular.js.map +1 -1
  43. package/index.d.ts +5 -5
  44. package/infrab4a-connect-angular.d.ts +5 -5
  45. package/package.json +1 -1
  46. package/services/auth.service.d.ts +19 -19
  47. package/services/cart.service.d.ts +35 -35
  48. package/services/checkout-subscription.service.d.ts +18 -18
  49. package/services/checkout.service.d.ts +23 -23
  50. package/services/coupon.service.d.ts +25 -26
  51. package/services/errors/group-invalid-coupon.error.d.ts +6 -6
  52. package/services/errors/index.d.ts +2 -2
  53. package/services/errors/invalid-coupon.error.d.ts +5 -5
  54. package/services/home-shop.service.d.ts +25 -25
  55. package/services/index.d.ts +8 -8
  56. package/services/order.service.d.ts +13 -13
  57. package/services/shipping.service.d.ts +19 -19
  58. package/services/types/index.d.ts +2 -2
  59. package/services/types/required-checkout-data.type.d.ts +2 -2
  60. package/services/types/required-checkout-subscription-data.type.d.ts +2 -2
  61. package/services/types/shipping-methods.type.d.ts +12 -12
@@ -14,40 +14,40 @@ import { AngularFirestore } from '@angular/fire/firestore';
14
14
  import * as i1$3 from '@angular/common/http';
15
15
  import { FIREBASE_OPTIONS, FIREBASE_APP_NAME, AngularFireModule } from '@angular/fire';
16
16
 
17
- class AuthService {
18
- constructor(angularFireAuth, userRepository) {
19
- this.angularFireAuth = angularFireAuth;
20
- this.userRepository = userRepository;
21
- }
22
- getAuthstate() {
23
- const observables = [
24
- this.angularFireAuth.authState.pipe(catchError(() => of(null))),
25
- this.getUser().pipe(catchError(() => of(null))),
26
- ];
27
- return combineLatest(observables).pipe(map(([fireUser, user]) => {
28
- return {
29
- user,
30
- isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
31
- };
32
- }));
33
- }
34
- getUser() {
35
- return this.getFireUser().pipe(map((user) => user === null || user === void 0 ? void 0 : user.uid), mergeMap((id) => (id ? this.userRepository.get({ id }) : of(null))));
36
- }
37
- getTokenId() {
38
- return this.angularFireAuth.idToken;
39
- }
40
- getFireUser() {
41
- return this.angularFireAuth.user.pipe(catchError(() => of(null)));
42
- }
43
- }
44
- AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService, deps: [{ token: i1.AngularFireAuth }, { token: 'UserRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
45
- AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService });
46
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService, decorators: [{
47
- type: Injectable
48
- }], ctorParameters: function () { return [{ type: i1.AngularFireAuth }, { type: undefined, decorators: [{
49
- type: Inject,
50
- args: ['UserRepository']
17
+ class AuthService {
18
+ constructor(angularFireAuth, userRepository) {
19
+ this.angularFireAuth = angularFireAuth;
20
+ this.userRepository = userRepository;
21
+ }
22
+ getAuthstate() {
23
+ const observables = [
24
+ this.angularFireAuth.authState.pipe(catchError(() => of(null))),
25
+ this.getUser().pipe(catchError(() => of(null))),
26
+ ];
27
+ return combineLatest(observables).pipe(map(([fireUser, user]) => {
28
+ return {
29
+ user,
30
+ isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
31
+ };
32
+ }));
33
+ }
34
+ getUser() {
35
+ return this.getFireUser().pipe(map((user) => user === null || user === void 0 ? void 0 : user.uid), mergeMap((id) => (id ? this.userRepository.get({ id }) : of(null))));
36
+ }
37
+ getTokenId() {
38
+ return this.angularFireAuth.idToken;
39
+ }
40
+ getFireUser() {
41
+ return this.angularFireAuth.user.pipe(catchError(() => of(null)));
42
+ }
43
+ }
44
+ AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService, deps: [{ token: i1.AngularFireAuth }, { token: 'UserRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
45
+ AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService });
46
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService, decorators: [{
47
+ type: Injectable
48
+ }], ctorParameters: function () { return [{ type: i1.AngularFireAuth }, { type: undefined, decorators: [{
49
+ type: Inject,
50
+ args: ['UserRepository']
51
51
  }] }]; } });
52
52
 
53
53
  const BACKEND_URL = 'BACKEND_URL';
@@ -58,1452 +58,1448 @@ const ES_CONFIG = 'ES_CONFIG';
58
58
 
59
59
  const HASURA_OPTIONS = 'HASURA_OPTIONS';
60
60
 
61
- class InvalidCouponError extends CustomError {
62
- constructor(message) {
63
- super(message);
64
- this.message = message;
65
- }
61
+ class InvalidCouponError extends CustomError {
62
+ constructor(message) {
63
+ super(message);
64
+ this.message = message;
65
+ }
66
66
  }
67
67
 
68
- class GroupInvalidCouponError extends CustomError {
69
- constructor(errors) {
70
- super('Many coupon errors throw');
71
- this.errors = errors;
72
- }
68
+ class GroupInvalidCouponError extends CustomError {
69
+ constructor(errors) {
70
+ super('Many coupon errors throw');
71
+ this.errors = errors;
72
+ }
73
73
  }
74
74
 
75
- class CouponService {
76
- constructor(couponRepository, defaultShop, orderRepository, subscriptionRepository, categoryRepository) {
77
- this.couponRepository = couponRepository;
78
- this.defaultShop = defaultShop;
79
- this.orderRepository = orderRepository;
80
- this.subscriptionRepository = subscriptionRepository;
81
- this.categoryRepository = categoryRepository;
82
- this.emailIsFromCollaborator = (userEmail) => !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g));
83
- this.separateValidCoupons = (coupons, userEmail) => coupons
84
- .map((coupon) => {
85
- try {
86
- if (!(coupon instanceof Coupon))
87
- throw new InvalidCouponError('Cupom inválido.');
88
- if (this.isValidCoupon(coupon, userEmail))
89
- return coupon;
90
- }
91
- catch (error) {
92
- return error;
93
- }
94
- })
95
- .reduce((current, coupon) => (Object.assign(Object.assign({}, current), (coupon instanceof Coupon
96
- ? { valids: [...current.valids, coupon] }
97
- : { invalids: [...current.invalids, coupon] }))), {
98
- valids: [],
99
- invalids: [],
100
- });
101
- }
102
- checkCoupon(nickname, userEmail, checkoutType, plan, checkout, isSubscription) {
103
- return from(this.couponRepository.find({
104
- filters: {
105
- nickname: { operator: Where.EQUALS, value: nickname },
106
- active: { operator: Where.EQUALS, value: true },
107
- },
108
- })).pipe(concatMap((coupons) => this.checkCouponRules(coupons, checkoutType, plan, checkout, isSubscription)), concatMap((coupon) => this.checkCouponUseAndLimit(coupon, userEmail, checkout)), map((coupon) => this.isValidCoupon(coupon, userEmail)), map((coupon) => coupon));
109
- }
110
- checkCouponRules(coupons, checkoutType, plan, checkout, isSubscription) {
111
- // Caso não ache nenhum cupom, retorna erro
112
- if (coupons.count < 1) {
113
- return throwError('Cupom inválido.');
114
- }
115
- // Get Primeiro Cupom (o find do repository retorna um array)
116
- const coupon = coupons.data.shift();
117
- // Verifica se o cupom é aplicavel na loja
118
- const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.defaultShop;
119
- // Cupon não aplicavel a loja retorna erro
120
- if (!isInShop)
121
- return throwError('Cupom inválido para loja.');
122
- // Verifica se o coupon é aplicado no checkout que está sendo realizado
123
- const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
124
- // Cupon não aplicavel ao checkout retorna erro
125
- if (!isCheckoutType)
126
- return throwError('Cupom inválido. Erro de checkout.');
127
- // Verifica se o cupom é ou pode ser aplicado para subscription
128
- if (checkoutType === CheckoutTypes.ALL || checkoutType === CheckoutTypes.SUBSCRIPTION) {
129
- // Se o cupom tiver um plano associado, verifica se é o mesmo plano do checkout da assinatura
130
- if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
131
- return throwError('Cupom inválido para sua assinatura.');
132
- }
133
- if (isSubscription)
134
- return of(coupon);
135
- // Verifica se possui o valor minimo de compra para utilização do cupom
136
- const hasMinSubTotal = this.hasMinSubTotal(coupon, checkout);
137
- // Se não tem valor mínimo atingido, retorna erro
138
- if (!hasMinSubTotal)
139
- return throwError('Valor mínimo não atingido');
140
- return of(coupon);
141
- }
142
- isValidCoupon(coupon, userEmail) {
143
- // Verifica a data de inicio de validade do cupom
144
- if ((coupon === null || coupon === void 0 ? void 0 : coupon.beginAt) > new Date())
145
- throw new InvalidCouponError('Cupom ainda não liberado.');
146
- // Verifica a data de validade do cupom
147
- if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) < new Date())
148
- throw new InvalidCouponError('Cupom expirado.');
149
- return coupon;
150
- }
151
- checkCouponUseAndLimit(coupon, userEmail, checkout) {
152
- return __awaiter(this, void 0, void 0, function* () {
153
- const orders = yield this.orderRepository.find({
154
- filters: {
155
- coupon: { id: coupon.id },
156
- payment: { status: 'paid' },
157
- },
158
- });
159
- // orders que usuario ja fez com o cupom
160
- const ordersUserCoupon = orders.data.filter((o) => o.user.email == userEmail);
161
- // Verifica o limite de uso de cupom por usuario
162
- if (coupon.useLimitPerUser && ordersUserCoupon.length)
163
- throw new InvalidCouponError('Limite de uso por usuário atingido.');
164
- // Verifica o limite de uso geral por usuario
165
- if (coupon.useLimit && orders.data.length >= coupon.useLimit)
166
- throw new InvalidCouponError('Limite de uso atingido.');
167
- const validUser = this.userValidationAndSubscriptionStatus(coupon, checkout.user);
168
- if (!validUser)
169
- throw new InvalidCouponError('Usuário não elegível.');
170
- const hasProductCategories = yield this.hasProductCategories(coupon, checkout);
171
- if (!hasProductCategories)
172
- throw 'Seu carrinho não possui produtos elegíveis para desconto.';
173
- return coupon;
174
- });
175
- }
176
- calcDiscountSubscription(coupon, checkout) {
177
- //
178
- let discount = 0;
179
- if (coupon.type === CouponTypes.ABSOLUTE)
180
- discount = coupon.discount;
181
- else if (coupon.type === CouponTypes.PERCENTAGE)
182
- discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount / 100);
183
- return of(discount);
184
- }
185
- calcDiscountShopping(coupon, checkout) {
186
- return __awaiter(this, void 0, void 0, function* () {
187
- let discount = 0;
188
- switch (coupon.type) {
189
- case CouponTypes.ABSOLUTE: {
190
- discount = coupon.discount;
191
- break;
192
- }
193
- case CouponTypes.PERCENTAGE: {
194
- discount = yield this.calcShoppingPercentageDiscount(coupon, checkout);
195
- break;
196
- }
197
- }
198
- return discount;
199
- });
200
- }
201
- calcShoppingPercentageDiscount(coupon, checkout) {
202
- var _a;
203
- return __awaiter(this, void 0, void 0, function* () {
204
- let discount = 0;
205
- const shop = checkout.shop;
206
- let lineItensDiscount = [];
207
- const couponCategories = yield this.getCouponCategoriesId(coupon);
208
- if (coupon.productsCategories && coupon.productsCategories.length) {
209
- lineItensDiscount = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
210
- var _a;
211
- if ((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length) {
212
- return i.categories.some((c) => couponCategories.some((cat) => cat.id == c || cat.firestoreId == c));
213
- }
214
- return true;
215
- });
216
- }
217
- else {
218
- lineItensDiscount = checkout.lineItems;
219
- }
220
- const subTotal = lineItensDiscount.reduce((acc, curr) => {
221
- var _a, _b, _c;
222
- return ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber) && ((_b = curr.price[shop]) === null || _b === void 0 ? void 0 : _b.subscriberPrice)
223
- ? acc + ((_c = curr.price[shop]) === null || _c === void 0 ? void 0 : _c.subscriberPrice) * curr.quantity
224
- : acc + curr.pricePaid * curr.quantity;
225
- }, 0) || 0;
226
- discount = subTotal * (coupon.discount / 100);
227
- return discount;
228
- });
229
- }
230
- hasMinSubTotal(coupon, checkout) {
231
- var _a;
232
- if (!coupon.minSubTotalValue)
233
- return true;
234
- const shop = checkout.shop;
235
- let subTotal = ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.reduce((acc, curr) => {
236
- var _a, _b, _c;
237
- return ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber) && ((_b = curr.price[shop]) === null || _b === void 0 ? void 0 : _b.subscriberPrice)
238
- ? acc + ((_c = curr.price[shop]) === null || _c === void 0 ? void 0 : _c.subscriberPrice) * curr.quantity
239
- : acc + curr.pricePaid * curr.quantity;
240
- }, 0)) || 0;
241
- if (coupon.minSubTotalValue <= subTotal)
242
- return true;
243
- return false;
244
- }
245
- hasProductCategories(coupon, checkout) {
246
- var _a;
247
- return __awaiter(this, void 0, void 0, function* () {
248
- if (!coupon.productsCategories || !coupon.productsCategories.length) {
249
- return true;
250
- }
251
- const couponCategories = yield this.getCouponCategoriesId(coupon);
252
- const hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
253
- var _a;
254
- if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length))
255
- return true;
256
- return i.categories.some((c) => couponCategories.some((cat) => cat.id == c || cat.firestoreId == c));
257
- });
258
- return hasCategories.length ? true : false;
259
- });
260
- }
261
- userValidationAndSubscriptionStatus(coupon, user) {
262
- if (coupon.exclusivityType === Exclusivities.ALL_USERS)
263
- return true;
264
- // Verifica se o email do usuário é coorporativo
265
- if (!this.emailIsFromCollaborator(user.email) && coupon.exclusivityType === Exclusivities.COLLABORATORS)
266
- throw new InvalidCouponError('Você não é colaborador.');
267
- // Verifica se o email do usuário é associado ao cupom de uso por usuario
268
- if (coupon.exclusivityType === Exclusivities.SPECIFIC_USER && coupon.userExclusiveEmail !== user.email)
269
- throw new InvalidCouponError('Cupom não é válido para este usuário.');
270
- switch (coupon.exclusivityType) {
271
- case Exclusivities.ACTIVE_SUBSCRIBER:
272
- return user.isSubscriber ? true : false;
273
- case Exclusivities.INACTIVE_SUBSCRIBER:
274
- return user.isSubscriber ? false : true;
275
- case Exclusivities.NON_SUBSCRIBER:
276
- return user.isSubscriber ? false : true;
277
- }
278
- return true;
279
- }
280
- getCouponCategoriesId(coupon) {
281
- return __awaiter(this, void 0, void 0, function* () {
282
- let couponCategories = [];
283
- for (let index = 0; index < coupon.productsCategories.length; index++) {
284
- let c = yield this.categoryRepository.get({
285
- id: coupon.productsCategories[index],
286
- });
287
- couponCategories.push({ id: c.id, firestoreId: c.firestoreId });
288
- }
289
- return couponCategories;
290
- });
291
- }
292
- }
293
- CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'SubscriptionRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
294
- CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, providedIn: 'root' });
295
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, decorators: [{
296
- type: Injectable,
297
- args: [{
298
- providedIn: 'root',
299
- }]
300
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
301
- type: Inject,
302
- args: ['CouponRepository']
303
- }] }, { type: i1$1.Shops, decorators: [{
304
- type: Inject,
305
- args: [DEFAULT_SHOP]
306
- }] }, { type: undefined, decorators: [{
307
- type: Inject,
308
- args: ['OrderRepository']
309
- }] }, { type: undefined, decorators: [{
310
- type: Inject,
311
- args: ['SubscriptionRepository']
312
- }] }, { type: undefined, decorators: [{
313
- type: Inject,
314
- args: ['CategoryRepository']
75
+ class CouponService {
76
+ constructor(couponRepository, defaultShop, orderRepository, categoryRepository) {
77
+ this.couponRepository = couponRepository;
78
+ this.defaultShop = defaultShop;
79
+ this.orderRepository = orderRepository;
80
+ this.categoryRepository = categoryRepository;
81
+ this.emailIsFromCollaborator = (userEmail) => !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g));
82
+ this.separateValidCoupons = (coupons, userEmail) => coupons
83
+ .map((coupon) => {
84
+ try {
85
+ if (!(coupon instanceof Coupon))
86
+ throw new InvalidCouponError('Cupom inválido.');
87
+ if (this.isValidCoupon(coupon, userEmail))
88
+ return coupon;
89
+ }
90
+ catch (error) {
91
+ return error;
92
+ }
93
+ })
94
+ .reduce((current, coupon) => (Object.assign(Object.assign({}, current), (coupon instanceof Coupon
95
+ ? { valids: [...current.valids, coupon] }
96
+ : { invalids: [...current.invalids, coupon] }))), {
97
+ valids: [],
98
+ invalids: [],
99
+ });
100
+ }
101
+ checkCoupon(nickname, userEmail, checkoutType, plan, checkout, isSubscription) {
102
+ return from(this.couponRepository.find({
103
+ filters: {
104
+ nickname: { operator: Where.EQUALS, value: nickname },
105
+ active: { operator: Where.EQUALS, value: true },
106
+ },
107
+ })).pipe(concatMap((coupons) => this.checkCouponRules(coupons, checkoutType, plan, checkout, isSubscription)), concatMap((coupon) => this.checkCouponUseAndLimit(coupon, userEmail, checkout)), map((coupon) => this.isValidCoupon(coupon, userEmail)), map((coupon) => coupon));
108
+ }
109
+ checkCouponRules(coupons, checkoutType, plan, checkout, isSubscription) {
110
+ // Caso não ache nenhum cupom, retorna erro
111
+ if (coupons.count < 1) {
112
+ return throwError('Cupom inválido.');
113
+ }
114
+ // Get Primeiro Cupom (o find do repository retorna um array)
115
+ const coupon = coupons.data.shift();
116
+ // Verifica se o cupom é aplicavel na loja
117
+ const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.defaultShop;
118
+ // Cupon não aplicavel a loja retorna erro
119
+ if (!isInShop)
120
+ return throwError('Cupom inválido para loja.');
121
+ // Verifica se o coupon é aplicado no checkout que está sendo realizado
122
+ const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
123
+ // Cupon não aplicavel ao checkout retorna erro
124
+ if (!isCheckoutType)
125
+ return throwError('Cupom inválido. Erro de checkout.');
126
+ // Verifica se o cupom é ou pode ser aplicado para subscription
127
+ if (checkoutType === CheckoutTypes.ALL || checkoutType === CheckoutTypes.SUBSCRIPTION) {
128
+ // Se o cupom tiver um plano associado, verifica se é o mesmo plano do checkout da assinatura
129
+ if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
130
+ return throwError('Cupom inválido para sua assinatura.');
131
+ }
132
+ if (isSubscription)
133
+ return of(coupon);
134
+ // Verifica se possui o valor minimo de compra para utilização do cupom
135
+ const hasMinSubTotal = this.hasMinSubTotal(coupon, checkout);
136
+ // Se não tem valor mínimo atingido, retorna erro
137
+ if (!hasMinSubTotal)
138
+ return throwError(`Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido`);
139
+ return of(coupon);
140
+ }
141
+ isValidCoupon(coupon, userEmail) {
142
+ // Verifica a data de inicio de validade do cupom
143
+ if ((coupon === null || coupon === void 0 ? void 0 : coupon.beginAt) > new Date())
144
+ throw new InvalidCouponError('Cupom ainda não liberado.');
145
+ // Verifica a data de validade do cupom
146
+ if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) < new Date())
147
+ throw new InvalidCouponError('Cupom expirado.');
148
+ return coupon;
149
+ }
150
+ checkCouponUseAndLimit(coupon, userEmail, checkout) {
151
+ return __awaiter(this, void 0, void 0, function* () {
152
+ const orders = yield this.orderRepository.find({
153
+ filters: {
154
+ coupon: { id: coupon.id },
155
+ payment: { status: 'paid' },
156
+ },
157
+ });
158
+ // orders que usuario ja fez com o cupom
159
+ const ordersUserCoupon = orders.data.filter((o) => o.user.email == userEmail);
160
+ // Verifica o limite de uso de cupom por usuario
161
+ if (coupon.useLimitPerUser && ordersUserCoupon.length)
162
+ throw new InvalidCouponError('Limite de uso por usuário atingido.');
163
+ // Verifica o limite de uso geral por usuario
164
+ if (coupon.useLimit && orders.data.length >= coupon.useLimit)
165
+ throw new InvalidCouponError('Limite de uso atingido.');
166
+ const validUser = this.userValidationAndSubscriptionStatus(coupon, checkout.user);
167
+ if (!validUser)
168
+ throw new InvalidCouponError('Usuário não elegível.');
169
+ const hasProductCategories = yield this.hasProductCategories(coupon, checkout);
170
+ if (!hasProductCategories)
171
+ throw 'Seu carrinho não possui produtos elegíveis para desconto.';
172
+ return coupon;
173
+ });
174
+ }
175
+ calcDiscountSubscription(coupon, checkout) {
176
+ //
177
+ let discount = 0;
178
+ if (coupon.type === CouponTypes.ABSOLUTE)
179
+ discount = coupon.discount;
180
+ else if (coupon.type === CouponTypes.PERCENTAGE)
181
+ discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount / 100);
182
+ return of(discount);
183
+ }
184
+ calcDiscountShopping(coupon, checkout) {
185
+ return __awaiter(this, void 0, void 0, function* () {
186
+ let discount = 0;
187
+ switch (coupon.type) {
188
+ case CouponTypes.ABSOLUTE: {
189
+ discount = coupon.discount;
190
+ break;
191
+ }
192
+ case CouponTypes.PERCENTAGE: {
193
+ discount = yield this.calcShoppingPercentageDiscount(coupon, checkout);
194
+ break;
195
+ }
196
+ }
197
+ return discount;
198
+ });
199
+ }
200
+ calcShoppingPercentageDiscount(coupon, checkout) {
201
+ var _a;
202
+ return __awaiter(this, void 0, void 0, function* () {
203
+ let discount = 0;
204
+ const shop = checkout.shop;
205
+ let lineItensDiscount = [];
206
+ const couponCategories = yield this.getCouponCategoriesId(coupon);
207
+ if (coupon.productsCategories && coupon.productsCategories.length) {
208
+ lineItensDiscount = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
209
+ var _a;
210
+ if ((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length) {
211
+ return i.categories.some((c) => couponCategories.some((cat) => cat.id == c || cat.firestoreId == c));
212
+ }
213
+ return true;
214
+ });
215
+ }
216
+ else {
217
+ lineItensDiscount = checkout.lineItems;
218
+ }
219
+ const subTotal = lineItensDiscount.reduce((acc, curr) => {
220
+ var _a, _b, _c;
221
+ return ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber) && ((_b = curr.price[shop]) === null || _b === void 0 ? void 0 : _b.subscriberPrice)
222
+ ? acc + ((_c = curr.price[shop]) === null || _c === void 0 ? void 0 : _c.subscriberPrice) * curr.quantity
223
+ : acc + curr.pricePaid * curr.quantity;
224
+ }, 0) || 0;
225
+ discount = subTotal * (coupon.discount / 100);
226
+ return discount;
227
+ });
228
+ }
229
+ hasMinSubTotal(coupon, checkout) {
230
+ var _a;
231
+ if (!coupon.minSubTotalValue)
232
+ return true;
233
+ const shop = checkout.shop;
234
+ let subTotal = ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.reduce((acc, curr) => {
235
+ var _a, _b, _c;
236
+ return ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber) && ((_b = curr.price[shop]) === null || _b === void 0 ? void 0 : _b.subscriberPrice)
237
+ ? acc + ((_c = curr.price[shop]) === null || _c === void 0 ? void 0 : _c.subscriberPrice) * curr.quantity
238
+ : acc + curr.pricePaid * curr.quantity;
239
+ }, 0)) || 0;
240
+ if (coupon.minSubTotalValue <= subTotal)
241
+ return true;
242
+ return false;
243
+ }
244
+ hasProductCategories(coupon, checkout) {
245
+ var _a;
246
+ return __awaiter(this, void 0, void 0, function* () {
247
+ if (!coupon.productsCategories || !coupon.productsCategories.length) {
248
+ return true;
249
+ }
250
+ const couponCategories = yield this.getCouponCategoriesId(coupon);
251
+ const hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
252
+ var _a;
253
+ if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length))
254
+ return true;
255
+ return i.categories.some((c) => couponCategories.some((cat) => cat.id == c || cat.firestoreId == c));
256
+ });
257
+ return hasCategories.length ? true : false;
258
+ });
259
+ }
260
+ userValidationAndSubscriptionStatus(coupon, user) {
261
+ if (coupon.exclusivityType === Exclusivities.ALL_USERS)
262
+ return true;
263
+ // Verifica se o email do usuário é coorporativo
264
+ if (!this.emailIsFromCollaborator(user.email) && coupon.exclusivityType === Exclusivities.COLLABORATORS)
265
+ throw new InvalidCouponError('Você não é colaborador.');
266
+ // Verifica se o email do usuário é associado ao cupom de uso por usuario
267
+ if (coupon.exclusivityType === Exclusivities.SPECIFIC_USER && coupon.userExclusiveEmail !== user.email)
268
+ throw new InvalidCouponError('Cupom não é válido para este usuário.');
269
+ switch (coupon.exclusivityType) {
270
+ case Exclusivities.ACTIVE_SUBSCRIBER:
271
+ return user.isSubscriber ? true : false;
272
+ case Exclusivities.INACTIVE_SUBSCRIBER:
273
+ return user.isSubscriber ? false : true;
274
+ case Exclusivities.NON_SUBSCRIBER:
275
+ return user.isSubscriber ? false : true;
276
+ }
277
+ return true;
278
+ }
279
+ getCouponCategoriesId(coupon) {
280
+ return __awaiter(this, void 0, void 0, function* () {
281
+ let couponCategories = [];
282
+ for (let index = 0; index < coupon.productsCategories.length; index++) {
283
+ let c = yield this.categoryRepository.get({
284
+ id: coupon.productsCategories[index],
285
+ });
286
+ couponCategories.push({ id: c.id, firestoreId: c.firestoreId });
287
+ }
288
+ return couponCategories;
289
+ });
290
+ }
291
+ }
292
+ CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
293
+ CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, providedIn: 'root' });
294
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, decorators: [{
295
+ type: Injectable,
296
+ args: [{
297
+ providedIn: 'root',
298
+ }]
299
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
300
+ type: Inject,
301
+ args: ['CouponRepository']
302
+ }] }, { type: i1$1.Shops, decorators: [{
303
+ type: Inject,
304
+ args: [DEFAULT_SHOP]
305
+ }] }, { type: undefined, decorators: [{
306
+ type: Inject,
307
+ args: ['OrderRepository']
308
+ }] }, { type: undefined, decorators: [{
309
+ type: Inject,
310
+ args: ['CategoryRepository']
315
311
  }] }]; } });
316
312
 
317
- class CheckoutService {
318
- constructor(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
319
- this.couponService = couponService;
320
- this.checkoutRepository = checkoutRepository;
321
- this.orderRepository = orderRepository;
322
- this.userRepository = userRepository;
323
- this.defaultShop = defaultShop;
324
- }
325
- getCheckout(checkoutData) {
326
- const checkoutId = cookie.get('checkoutId');
327
- if (!isNil(checkoutId))
328
- return from(this.checkoutRepository.get({ id: checkoutId }));
329
- return from(this.createCheckout(checkoutData));
330
- }
331
- getUserByCheckout(checkoutId) {
332
- return from(this.checkoutRepository.get({ id: checkoutId })).pipe(concatMap((checkout) => { var _a; return ((_a = checkout === null || checkout === void 0 ? void 0 : checkout.user) === null || _a === void 0 ? void 0 : _a.id) ? of(checkout.user) : from(this.userRepository.get({ id: checkout.user.id })); }), concatMap((user) => of(user) || throwError(() => new NotFoundError('User is not found'))));
333
- }
334
- updateCheckoutLineItems(checkout) {
335
- return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
336
- }
337
- updateCheckoutUser(checkout) {
338
- return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
339
- }
340
- clearCheckoutFromSession() {
341
- cookie.remove('checkoutId');
342
- return of();
343
- }
344
- calcDiscount(coupon) {
345
- return this.getCheckout().pipe(concatMap((checkout) => __awaiter(this, void 0, void 0, function* () { return yield this.couponService.calcDiscountShopping(coupon, checkout); })));
346
- }
347
- checkCoupon(nickname, checkoutType) {
348
- return this.getCheckout().pipe(concatMap((checkout) => {
349
- var _a;
350
- return this.couponService
351
- .checkCoupon(nickname, (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email, CheckoutTypes.ECOMMERCE, checkout.user.subscriptionPlan, checkout, false)
352
- .pipe();
353
- }));
354
- }
355
- createCheckout(checkoutData) {
356
- return __awaiter(this, void 0, void 0, function* () {
357
- const checkout = yield this.checkoutRepository.create(Object.assign(Object.assign({ createdAt: new Date() }, Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()), { shop: (checkoutData === null || checkoutData === void 0 ? void 0 : checkoutData.shop) || this.defaultShop }));
358
- cookie.set('checkoutId', checkout.id);
359
- return checkout;
360
- });
361
- }
362
- }
363
- CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'OrderRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
364
- CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService });
365
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService, decorators: [{
366
- type: Injectable
367
- }], ctorParameters: function () { return [{ type: CouponService }, { type: undefined, decorators: [{
368
- type: Inject,
369
- args: ['CheckoutRepository']
370
- }] }, { type: undefined, decorators: [{
371
- type: Inject,
372
- args: ['OrderRepository']
373
- }] }, { type: undefined, decorators: [{
374
- type: Inject,
375
- args: ['UserRepository']
376
- }] }, { type: i1$1.Shops, decorators: [{
377
- type: Inject,
378
- args: [DEFAULT_SHOP]
313
+ class CheckoutService {
314
+ constructor(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
315
+ this.couponService = couponService;
316
+ this.checkoutRepository = checkoutRepository;
317
+ this.orderRepository = orderRepository;
318
+ this.userRepository = userRepository;
319
+ this.defaultShop = defaultShop;
320
+ }
321
+ getCheckout(checkoutData) {
322
+ const checkoutId = cookie.get('checkoutId');
323
+ if (!isNil(checkoutId))
324
+ return from(this.checkoutRepository.get({ id: checkoutId }));
325
+ return from(this.createCheckout(checkoutData));
326
+ }
327
+ getUserByCheckout(checkoutId) {
328
+ return from(this.checkoutRepository.get({ id: checkoutId })).pipe(concatMap((checkout) => { var _a; return ((_a = checkout === null || checkout === void 0 ? void 0 : checkout.user) === null || _a === void 0 ? void 0 : _a.id) ? of(checkout.user) : from(this.userRepository.get({ id: checkout.user.id })); }), concatMap((user) => of(user) || throwError(() => new NotFoundError('User is not found'))));
329
+ }
330
+ updateCheckoutLineItems(checkout) {
331
+ return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
332
+ }
333
+ updateCheckoutUser(checkout) {
334
+ return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
335
+ }
336
+ clearCheckoutFromSession() {
337
+ cookie.remove('checkoutId');
338
+ return of();
339
+ }
340
+ calcDiscount(coupon) {
341
+ return this.getCheckout().pipe(concatMap((checkout) => __awaiter(this, void 0, void 0, function* () { return yield this.couponService.calcDiscountShopping(coupon, checkout); })));
342
+ }
343
+ checkCoupon(nickname, checkoutType) {
344
+ return this.getCheckout().pipe(concatMap((checkout) => {
345
+ var _a;
346
+ return this.couponService
347
+ .checkCoupon(nickname, (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email, CheckoutTypes.ECOMMERCE, checkout.user.subscriptionPlan, checkout, false)
348
+ .pipe();
349
+ }));
350
+ }
351
+ createCheckout(checkoutData) {
352
+ return __awaiter(this, void 0, void 0, function* () {
353
+ const checkout = yield this.checkoutRepository.create(Object.assign(Object.assign({ createdAt: new Date() }, Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()), { shop: (checkoutData === null || checkoutData === void 0 ? void 0 : checkoutData.shop) || this.defaultShop }));
354
+ cookie.set('checkoutId', checkout.id);
355
+ return checkout;
356
+ });
357
+ }
358
+ }
359
+ CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'OrderRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
360
+ CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService });
361
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService, decorators: [{
362
+ type: Injectable
363
+ }], ctorParameters: function () { return [{ type: CouponService }, { type: undefined, decorators: [{
364
+ type: Inject,
365
+ args: ['CheckoutRepository']
366
+ }] }, { type: undefined, decorators: [{
367
+ type: Inject,
368
+ args: ['OrderRepository']
369
+ }] }, { type: undefined, decorators: [{
370
+ type: Inject,
371
+ args: ['UserRepository']
372
+ }] }, { type: i1$1.Shops, decorators: [{
373
+ type: Inject,
374
+ args: [DEFAULT_SHOP]
379
375
  }] }]; } });
380
376
 
381
- class CartService {
382
- constructor(authService, checkoutService, defaultShop, productRepository) {
383
- this.authService = authService;
384
- this.checkoutService = checkoutService;
385
- this.defaultShop = defaultShop;
386
- this.productRepository = productRepository;
387
- this.cartSubject = new Subject();
388
- this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
389
- var _a;
390
- const items = [];
391
- const index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map((checkoutItem) => checkoutItem.sku).indexOf(lineItem.sku);
392
- if (index > -1) {
393
- checkoutLoaded.lineItems[index].quantity += quantity;
394
- checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
395
- }
396
- else
397
- checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
398
- return this.checkoutService
399
- .updateCheckoutLineItems(checkoutLoaded)
400
- .pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
401
- }));
402
- this.generateCartObject = (items) => {
403
- const cart = {};
404
- items === null || items === void 0 ? void 0 : items.forEach((item) => {
405
- var _a;
406
- return (cart[item.sku] = LineItem.toInstance(Object.assign(Object.assign({}, (cart[item.sku] || item)), { quantity: (((_a = cart[item.sku]) === null || _a === void 0 ? void 0 : _a.quantity) || 0) + (item.quantity ? item.quantity : 1) })));
407
- });
408
- return cart;
409
- };
410
- this.buildLineItem = ({ checkout, item, quantity, }) => __awaiter(this, void 0, void 0, function* () {
411
- var _a, _b, _c, _d, _e, _f, _g;
412
- const product = yield this.productRepository.get({ id: item.id });
413
- item.quantity = (item === null || item === void 0 ? void 0 : item.quantity) || ((_b = (_a = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.sku === item.sku)) === null || _b === void 0 ? void 0 : _b.quantity) || 0;
414
- if (this.checkMaxStock(item, quantity || 0))
415
- throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
416
- const image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
417
- const { id, name, EAN, brand, slug, stock, price, weight, categories, sku, type } = item;
418
- const isGift = item.isGift || null;
419
- const pricePaid = this.getProductPrice({
420
- product: item,
421
- shop: checkout.shop || this.defaultShop,
422
- isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
423
- });
424
- return {
425
- checkout,
426
- lineItem: LineItem.toInstance({
427
- id,
428
- name: name !== null && name !== void 0 ? name : product.name,
429
- EAN: EAN !== null && EAN !== void 0 ? EAN : product.EAN,
430
- brand: product.brand,
431
- slug: slug !== null && slug !== void 0 ? slug : product.slug,
432
- sku: sku !== null && sku !== void 0 ? sku : product.sku,
433
- stock,
434
- price,
435
- image,
436
- weight: weight !== null && weight !== void 0 ? weight : product.weight,
437
- quantity: (item.quantity || 0) + (quantity || 0),
438
- pricePaid,
439
- categories: (_f = product.categories) !== null && _f !== void 0 ? _f : [],
440
- isGift: isGift !== null && isGift !== void 0 ? isGift : null,
441
- costPrice: (_g = product.costPrice) !== null && _g !== void 0 ? _g : 0,
442
- type,
443
- }),
444
- };
445
- });
446
- this.getProductPrice = ({ product, isSubscriber, }) => {
447
- const info = product.price;
448
- if (product.isGift)
449
- return 0;
450
- return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
451
- };
452
- this.checkMaxStock = (item, quantity) => {
453
- var _a;
454
- const maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
455
- const currentItemAmount = item.quantity || 0;
456
- return currentItemAmount + quantity > maxStock;
457
- };
458
- }
459
- addItem(item, quantity = 1) {
460
- return from(this.checkoutService.getCheckout()).pipe(concatMap((checkout) => __awaiter(this, void 0, void 0, function* () { return yield this.buildLineItem({ checkout, item, quantity: quantity || 1 }); })), mergeMap(({ checkout, lineItem }) => this.updateLineItemInCart(lineItem, quantity || 1, checkout)), tap((cart) => this.cartSubject.next(cart)));
461
- }
462
- decreaseItem(item) {
463
- return this.checkoutService.getCheckout().pipe(map((checkout) => {
464
- var _a;
465
- const checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.sku === item.sku);
466
- if (!isNil(checkoutItem))
467
- checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
468
- return checkout;
469
- }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
470
- }
471
- getCart(checkout) {
472
- this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
473
- return this.cartSubject;
474
- }
475
- /**
476
- * @deprecated The method should not be used
477
- */
478
- getVariantPriceDiscount(item) {
479
- return this.authService.getUser().pipe(concatMap((user) => iif(() => user.isSubscriber && !!item.price.subscriberPrice, of(item.price.subscriberPrice), of(item.price.price))), catchError(() => of(item.price.price)));
480
- }
481
- removeItem(item) {
482
- return this.checkoutService.getCheckout().pipe(map((checkout) => {
483
- const index = checkout.lineItems.findIndex((lineItem) => lineItem.sku === item.sku);
484
- if (index >= 0)
485
- checkout.lineItems.splice(index, 1);
486
- return checkout;
487
- }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
488
- }
489
- updateUserCart(user) {
490
- return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user })))), concatMap((checkout) => __awaiter(this, void 0, void 0, function* () {
491
- var _a, _b;
492
- return this.checkoutService.updateCheckoutLineItems(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.length) ? yield Promise.all((_b = checkout.lineItems) === null || _b === void 0 ? void 0 : _b.map((item) => __awaiter(this, void 0, void 0, function* () { return (yield this.buildLineItem({ checkout, item })).lineItem; }))) : [] }))).toPromise();
493
- })), map(checkout => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
494
- }
495
- clearCart() {
496
- return this.checkoutService.getCheckout().pipe(map((checkout) => {
497
- this.checkoutService.clearCheckoutFromSession();
498
- return checkout;
499
- }), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
500
- }
501
- buildCartFromCheckout(checkoutData) {
502
- return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
503
- }
504
- }
505
- CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
506
- CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService });
507
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, decorators: [{
508
- type: Injectable
509
- }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i1$1.Shops, decorators: [{
510
- type: Inject,
511
- args: [DEFAULT_SHOP]
512
- }] }, { type: undefined, decorators: [{
513
- type: Inject,
514
- args: ['ProductRepository']
377
+ class CartService {
378
+ constructor(authService, checkoutService, defaultShop, productRepository) {
379
+ this.authService = authService;
380
+ this.checkoutService = checkoutService;
381
+ this.defaultShop = defaultShop;
382
+ this.productRepository = productRepository;
383
+ this.cartSubject = new Subject();
384
+ this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
385
+ var _a;
386
+ const items = [];
387
+ const index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map((checkoutItem) => checkoutItem.sku).indexOf(lineItem.sku);
388
+ if (index > -1) {
389
+ checkoutLoaded.lineItems[index].quantity += quantity;
390
+ checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
391
+ }
392
+ else
393
+ checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
394
+ return this.checkoutService
395
+ .updateCheckoutLineItems(checkoutLoaded)
396
+ .pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
397
+ }));
398
+ this.generateCartObject = (items) => {
399
+ const cart = {};
400
+ items === null || items === void 0 ? void 0 : items.forEach((item) => {
401
+ var _a;
402
+ return (cart[item.sku] = LineItem.toInstance(Object.assign(Object.assign({}, (cart[item.sku] || item)), { quantity: (((_a = cart[item.sku]) === null || _a === void 0 ? void 0 : _a.quantity) || 0) + (item.quantity ? item.quantity : 1) })));
403
+ });
404
+ return cart;
405
+ };
406
+ this.buildLineItem = ({ checkout, item, quantity, }) => __awaiter(this, void 0, void 0, function* () {
407
+ var _a, _b, _c, _d, _e, _f, _g;
408
+ const product = yield this.productRepository.get({ id: item.id });
409
+ item.quantity = (item === null || item === void 0 ? void 0 : item.quantity) || ((_b = (_a = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.sku === item.sku)) === null || _b === void 0 ? void 0 : _b.quantity) || 0;
410
+ if (this.checkMaxStock(item, quantity || 0))
411
+ throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
412
+ const image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
413
+ const { id, name, EAN, brand, slug, stock, price, weight, categories, sku, type } = item;
414
+ const isGift = item.isGift || null;
415
+ const pricePaid = this.getProductPrice({
416
+ product: item,
417
+ shop: checkout.shop || this.defaultShop,
418
+ isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
419
+ });
420
+ return {
421
+ checkout,
422
+ lineItem: LineItem.toInstance({
423
+ id,
424
+ name: name !== null && name !== void 0 ? name : product.name,
425
+ EAN: EAN !== null && EAN !== void 0 ? EAN : product.EAN,
426
+ brand: product.brand,
427
+ slug: slug !== null && slug !== void 0 ? slug : product.slug,
428
+ sku: sku !== null && sku !== void 0 ? sku : product.sku,
429
+ stock,
430
+ price,
431
+ image,
432
+ weight: weight !== null && weight !== void 0 ? weight : product.weight,
433
+ quantity: (item.quantity || 0) + (quantity || 0),
434
+ pricePaid,
435
+ categories: (_f = product.categories) !== null && _f !== void 0 ? _f : [],
436
+ isGift: isGift !== null && isGift !== void 0 ? isGift : null,
437
+ costPrice: (_g = product.costPrice) !== null && _g !== void 0 ? _g : 0,
438
+ type,
439
+ }),
440
+ };
441
+ });
442
+ this.getProductPrice = ({ product, isSubscriber, }) => {
443
+ const info = product.price;
444
+ if (product.isGift)
445
+ return 0;
446
+ return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
447
+ };
448
+ this.checkMaxStock = (item, quantity) => {
449
+ var _a;
450
+ const maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
451
+ const currentItemAmount = item.quantity || 0;
452
+ return currentItemAmount + quantity > maxStock;
453
+ };
454
+ }
455
+ addItem(item, quantity = 1) {
456
+ return from(this.checkoutService.getCheckout()).pipe(concatMap((checkout) => __awaiter(this, void 0, void 0, function* () { return yield this.buildLineItem({ checkout, item, quantity: quantity || 1 }); })), mergeMap(({ checkout, lineItem }) => this.updateLineItemInCart(lineItem, quantity || 1, checkout)), tap((cart) => this.cartSubject.next(cart)));
457
+ }
458
+ decreaseItem(item) {
459
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
460
+ var _a;
461
+ const checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.sku === item.sku);
462
+ if (!isNil(checkoutItem))
463
+ checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
464
+ return checkout;
465
+ }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
466
+ }
467
+ getCart(checkout) {
468
+ this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
469
+ return this.cartSubject;
470
+ }
471
+ /**
472
+ * @deprecated The method should not be used
473
+ */
474
+ getVariantPriceDiscount(item) {
475
+ return this.authService.getUser().pipe(concatMap((user) => iif(() => user.isSubscriber && !!item.price.subscriberPrice, of(item.price.subscriberPrice), of(item.price.price))), catchError(() => of(item.price.price)));
476
+ }
477
+ removeItem(item) {
478
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
479
+ const index = checkout.lineItems.findIndex((lineItem) => lineItem.sku === item.sku);
480
+ if (index >= 0)
481
+ checkout.lineItems.splice(index, 1);
482
+ return checkout;
483
+ }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
484
+ }
485
+ updateUserCart(user) {
486
+ return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user })))), concatMap((checkout) => __awaiter(this, void 0, void 0, function* () {
487
+ var _a, _b;
488
+ return this.checkoutService.updateCheckoutLineItems(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.length) ? yield Promise.all((_b = checkout.lineItems) === null || _b === void 0 ? void 0 : _b.map((item) => __awaiter(this, void 0, void 0, function* () { return (yield this.buildLineItem({ checkout, item })).lineItem; }))) : [] }))).toPromise();
489
+ })), map(checkout => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
490
+ }
491
+ clearCart() {
492
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
493
+ this.checkoutService.clearCheckoutFromSession();
494
+ return checkout;
495
+ }), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
496
+ }
497
+ buildCartFromCheckout(checkoutData) {
498
+ return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
499
+ }
500
+ }
501
+ CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
502
+ CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService });
503
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, decorators: [{
504
+ type: Injectable
505
+ }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i1$1.Shops, decorators: [{
506
+ type: Inject,
507
+ args: [DEFAULT_SHOP]
508
+ }] }, { type: undefined, decorators: [{
509
+ type: Inject,
510
+ args: ['ProductRepository']
515
511
  }] }]; } });
516
512
 
517
- class CheckoutSubscriptionService {
518
- constructor(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
519
- this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
520
- this.subscriptionRepository = subscriptionRepository;
521
- this.couponService = couponService;
522
- }
523
- getCheckoutSubscription(checkoutData) {
524
- const checkoutId = cookie.get('checkoutSubscriptionId');
525
- if (!isNil(checkoutId))
526
- return from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
527
- return from(this.createCheckoutSubscription(checkoutData));
528
- }
529
- createCheckoutSubscription(checkoutData) {
530
- return __awaiter(this, void 0, void 0, function* () {
531
- const checkout = yield this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()));
532
- cookie.set('checkoutSubscriptionId', checkout.id);
533
- return checkout;
534
- });
535
- }
536
- clearCheckoutSubscriptionFromSession() {
537
- cookie.remove('checkoutSubscriptionId');
538
- return of();
539
- }
540
- checkCoupon(nickname, userEmail) {
541
- return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.checkCoupon(nickname, userEmail, CheckoutTypes.SUBSCRIPTION, checkout.subscriptionPlan.name, null, true).pipe()));
542
- }
543
- calcDiscountSubscription(coupon) {
544
- return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
545
- }
546
- }
547
- CheckoutSubscriptionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: 'SubscriptionRepository' }, { token: CouponService }], target: i0.ɵɵFactoryTarget.Injectable });
548
- CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService });
549
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
550
- type: Injectable
551
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
552
- type: Inject,
553
- args: ['CheckoutSubscriptionRepository']
554
- }] }, { type: undefined, decorators: [{
555
- type: Inject,
556
- args: ['SubscriptionRepository']
513
+ class CheckoutSubscriptionService {
514
+ constructor(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
515
+ this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
516
+ this.subscriptionRepository = subscriptionRepository;
517
+ this.couponService = couponService;
518
+ }
519
+ getCheckoutSubscription(checkoutData) {
520
+ const checkoutId = cookie.get('checkoutSubscriptionId');
521
+ if (!isNil(checkoutId))
522
+ return from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
523
+ return from(this.createCheckoutSubscription(checkoutData));
524
+ }
525
+ createCheckoutSubscription(checkoutData) {
526
+ return __awaiter(this, void 0, void 0, function* () {
527
+ const checkout = yield this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()));
528
+ cookie.set('checkoutSubscriptionId', checkout.id);
529
+ return checkout;
530
+ });
531
+ }
532
+ clearCheckoutSubscriptionFromSession() {
533
+ cookie.remove('checkoutSubscriptionId');
534
+ return of();
535
+ }
536
+ checkCoupon(nickname, userEmail) {
537
+ return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.checkCoupon(nickname, userEmail, CheckoutTypes.SUBSCRIPTION, checkout.subscriptionPlan.name, null, true).pipe()));
538
+ }
539
+ calcDiscountSubscription(coupon) {
540
+ return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
541
+ }
542
+ }
543
+ CheckoutSubscriptionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: 'SubscriptionRepository' }, { token: CouponService }], target: i0.ɵɵFactoryTarget.Injectable });
544
+ CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService });
545
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
546
+ type: Injectable
547
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
548
+ type: Inject,
549
+ args: ['CheckoutSubscriptionRepository']
550
+ }] }, { type: undefined, decorators: [{
551
+ type: Inject,
552
+ args: ['SubscriptionRepository']
557
553
  }] }, { type: CouponService }]; } });
558
554
 
559
- class HomeShopService {
560
- constructor(categoryRepository, homeRepository, productRepository, defaultShop) {
561
- this.categoryRepository = categoryRepository;
562
- this.homeRepository = homeRepository;
563
- this.productRepository = productRepository;
564
- this.defaultShop = defaultShop;
565
- this.buildCategoryGroupWithRequiredData = (group) => {
566
- var _a, _b;
567
- return ({
568
- category: Category.toInstance(pick(((_a = group === null || group === void 0 ? void 0 : group.category) === null || _a === void 0 ? void 0 : _a.toPlain()) || {}, ['id', 'name', 'slug', 'conditions'])),
569
- products: ((_b = group === null || group === void 0 ? void 0 : group.products) === null || _b === void 0 ? void 0 : _b.map((product) => Product.toInstance(pick((product === null || product === void 0 ? void 0 : product.toPlain()) || {}, [
570
- 'id',
571
- 'price',
572
- 'reviews',
573
- 'hasVariants',
574
- 'slug',
575
- 'sku',
576
- 'stock',
577
- 'costPrice',
578
- 'images',
579
- 'miniatures',
580
- 'name',
581
- 'weight',
582
- 'rate',
583
- 'type',
584
- ])))) || [],
585
- });
586
- };
587
- }
588
- get homeId() {
589
- if (this.defaultShop === Shops.GLAMSHOP)
590
- return 'glamshop';
591
- if (this.defaultShop === Shops.MENSMARKET)
592
- return 'mens_market';
593
- return null;
594
- }
595
- getHomeData() {
596
- return this.getHomeConfiguration().pipe(map((home) => { var _a; return (((_a = home === null || home === void 0 ? void 0 : home.data) === null || _a === void 0 ? void 0 : _a.expiresAt) > new Date() ? home : null); }), concatMap((home) => home
597
- ? of(home)
598
- : forkJoin([this.getDiscoverProducts(), this.getFeaturedProducts(), this.getVerticalProducts()]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
599
- discoverProducts,
600
- featuredProducts,
601
- verticalProducts,
602
- })), concatMap((data) => this.saveHomeData(data)))));
603
- }
604
- getBanners(type) {
605
- return this.getHomeConfiguration().pipe(map((home) => {
606
- if (type === 'brand')
607
- return home.brandsCarousel;
608
- if (type === 'buyToWin')
609
- return [home.buyToWinBanner];
610
- if (type === 'block')
611
- return home.blockBanners;
612
- if (type === 'blog')
613
- return [home.blogBanner];
614
- }));
615
- }
616
- getMinValueForFreeShipping() {
617
- return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
618
- }
619
- getDiscoverProducts() {
620
- return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
621
- }
622
- getFeaturedProducts() {
623
- return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
624
- }
625
- getVerticalProducts() {
626
- return this.getHomeConfiguration().pipe(concatMap((home) => forkJoin(home.verticalCarousels.filter(Boolean).map((id) => from(this.categoryRepository.get({ id })).pipe(concatMap((category) => from(this.productRepository.find({
627
- filters: { categories: { operator: Where.IN, value: [category.id] } },
628
- limits: { limit: 12 },
629
- })).pipe(map((products) => ({ category, products })))), map(({ category, products }) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
630
- }
631
- getHomeConfiguration() {
632
- return of(this.homeConfiguration).pipe(concatMap((home) => home
633
- ? of(home)
634
- : !this.homeId
635
- ? throwError(new RequiredArgumentError(['homeId']))
636
- : from(this.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
637
- }
638
- saveHomeData(homeData) {
639
- const data = {
640
- createdAt: new Date(),
641
- expiresAt: add(new Date(), { hours: 1 }),
642
- data: homeData,
643
- };
644
- return from(this.homeRepository.update({
645
- id: this.homeId,
646
- data,
647
- })).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
648
- }
649
- }
650
- HomeShopService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService, deps: [{ token: 'CategoryRepository' }, { token: 'HomeRepository' }, { token: 'ProductRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
651
- HomeShopService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService });
652
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService, decorators: [{
653
- type: Injectable
654
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
655
- type: Inject,
656
- args: ['CategoryRepository']
657
- }] }, { type: undefined, decorators: [{
658
- type: Inject,
659
- args: ['HomeRepository']
660
- }] }, { type: undefined, decorators: [{
661
- type: Inject,
662
- args: ['ProductRepository']
663
- }] }, { type: i1$1.Shops, decorators: [{
664
- type: Inject,
665
- args: [DEFAULT_SHOP]
555
+ class HomeShopService {
556
+ constructor(categoryRepository, homeRepository, productRepository, defaultShop) {
557
+ this.categoryRepository = categoryRepository;
558
+ this.homeRepository = homeRepository;
559
+ this.productRepository = productRepository;
560
+ this.defaultShop = defaultShop;
561
+ this.buildCategoryGroupWithRequiredData = (group) => {
562
+ var _a, _b;
563
+ return ({
564
+ category: Category.toInstance(pick(((_a = group === null || group === void 0 ? void 0 : group.category) === null || _a === void 0 ? void 0 : _a.toPlain()) || {}, ['id', 'name', 'slug', 'conditions'])),
565
+ products: ((_b = group === null || group === void 0 ? void 0 : group.products) === null || _b === void 0 ? void 0 : _b.map((product) => Product.toInstance(pick((product === null || product === void 0 ? void 0 : product.toPlain()) || {}, [
566
+ 'id',
567
+ 'price',
568
+ 'reviews',
569
+ 'hasVariants',
570
+ 'slug',
571
+ 'sku',
572
+ 'stock',
573
+ 'costPrice',
574
+ 'images',
575
+ 'miniatures',
576
+ 'name',
577
+ 'weight',
578
+ 'rate',
579
+ 'type',
580
+ ])))) || [],
581
+ });
582
+ };
583
+ }
584
+ get homeId() {
585
+ if (this.defaultShop === Shops.GLAMSHOP)
586
+ return 'glamshop';
587
+ if (this.defaultShop === Shops.MENSMARKET)
588
+ return 'mens_market';
589
+ return null;
590
+ }
591
+ getHomeData() {
592
+ return this.getHomeConfiguration().pipe(map((home) => { var _a; return (((_a = home === null || home === void 0 ? void 0 : home.data) === null || _a === void 0 ? void 0 : _a.expiresAt) > new Date() ? home : null); }), concatMap((home) => home
593
+ ? of(home)
594
+ : forkJoin([this.getDiscoverProducts(), this.getFeaturedProducts(), this.getVerticalProducts()]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
595
+ discoverProducts,
596
+ featuredProducts,
597
+ verticalProducts,
598
+ })), concatMap((data) => this.saveHomeData(data)))));
599
+ }
600
+ getBanners(type) {
601
+ return this.getHomeConfiguration().pipe(map((home) => {
602
+ if (type === 'brand')
603
+ return home.brandsCarousel;
604
+ if (type === 'buyToWin')
605
+ return [home.buyToWinBanner];
606
+ if (type === 'block')
607
+ return home.blockBanners;
608
+ if (type === 'blog')
609
+ return [home.blogBanner];
610
+ }));
611
+ }
612
+ getMinValueForFreeShipping() {
613
+ return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
614
+ }
615
+ getDiscoverProducts() {
616
+ return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
617
+ }
618
+ getFeaturedProducts() {
619
+ return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
620
+ }
621
+ getVerticalProducts() {
622
+ return this.getHomeConfiguration().pipe(concatMap((home) => forkJoin(home.verticalCarousels.filter(Boolean).map((id) => from(this.categoryRepository.get({ id })).pipe(concatMap((category) => from(this.productRepository.find({
623
+ filters: { categories: { operator: Where.IN, value: [category.id] } },
624
+ limits: { limit: 12 },
625
+ })).pipe(map((products) => ({ category, products })))), map(({ category, products }) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
626
+ }
627
+ getHomeConfiguration() {
628
+ return of(this.homeConfiguration).pipe(concatMap((home) => home
629
+ ? of(home)
630
+ : !this.homeId
631
+ ? throwError(new RequiredArgumentError(['homeId']))
632
+ : from(this.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
633
+ }
634
+ saveHomeData(homeData) {
635
+ const data = {
636
+ createdAt: new Date(),
637
+ expiresAt: add(new Date(), { hours: 1 }),
638
+ data: homeData,
639
+ };
640
+ return from(this.homeRepository.update({
641
+ id: this.homeId,
642
+ data,
643
+ })).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
644
+ }
645
+ }
646
+ HomeShopService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService, deps: [{ token: 'CategoryRepository' }, { token: 'HomeRepository' }, { token: 'ProductRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
647
+ HomeShopService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService });
648
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService, decorators: [{
649
+ type: Injectable
650
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
651
+ type: Inject,
652
+ args: ['CategoryRepository']
653
+ }] }, { type: undefined, decorators: [{
654
+ type: Inject,
655
+ args: ['HomeRepository']
656
+ }] }, { type: undefined, decorators: [{
657
+ type: Inject,
658
+ args: ['ProductRepository']
659
+ }] }, { type: i1$1.Shops, decorators: [{
660
+ type: Inject,
661
+ args: [DEFAULT_SHOP]
666
662
  }] }]; } });
667
663
 
668
- class OrderService {
669
- constructor(angularFirestore, orderRepository) {
670
- this.angularFirestore = angularFirestore;
671
- this.orderRepository = orderRepository;
672
- this.orderSubject = new Subject();
673
- }
674
- getOrder(id) {
675
- this.angularFirestore
676
- .doc(`${this.orderRepository.collectionName}/${id}`)
677
- .valueChanges()
678
- .pipe(map((doc) => Order.toInstance(doc)))
679
- .subscribe((doc) => this.orderSubject.next(doc));
680
- return this.orderSubject;
681
- }
682
- }
683
- OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, deps: [{ token: i1$2.AngularFirestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
684
- OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService });
685
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, decorators: [{
686
- type: Injectable
687
- }], ctorParameters: function () { return [{ type: i1$2.AngularFirestore }, { type: i1$1.OrderFirestoreRepository, decorators: [{
688
- type: Inject,
689
- args: ['OrderRepository']
664
+ class OrderService {
665
+ constructor(angularFirestore, orderRepository) {
666
+ this.angularFirestore = angularFirestore;
667
+ this.orderRepository = orderRepository;
668
+ this.orderSubject = new Subject();
669
+ }
670
+ getOrder(id) {
671
+ this.angularFirestore
672
+ .doc(`${this.orderRepository.collectionName}/${id}`)
673
+ .valueChanges()
674
+ .pipe(map((doc) => Order.toInstance(doc)))
675
+ .subscribe((doc) => this.orderSubject.next(doc));
676
+ return this.orderSubject;
677
+ }
678
+ }
679
+ OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, deps: [{ token: i1$2.AngularFirestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
680
+ OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService });
681
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, decorators: [{
682
+ type: Injectable
683
+ }], ctorParameters: function () { return [{ type: i1$2.AngularFirestore }, { type: i1$1.OrderFirestoreRepository, decorators: [{
684
+ type: Inject,
685
+ args: ['OrderRepository']
690
686
  }] }]; } });
691
687
 
692
- class ShippingService {
693
- constructor(http, apiUrl, homeService) {
694
- this.http = http;
695
- this.apiUrl = apiUrl;
696
- this.homeService = homeService;
697
- }
698
- getShippingMethods(shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
699
- return combineLatest([
700
- this.homeService.getHomeData(),
701
- this.http.get(`${this.apiUrl}open/checkshippingcompany?personId=${personId}&postalCode=${zip}&weightGrams=${weightGrams}`),
702
- ]).pipe(map(([datas, shippingMethodsResponse]) => {
703
- let shippingMethods = shippingMethodsResponse.result;
704
- if (!shippingMethods.length)
705
- return [];
706
- shippingMethods = shippingMethods.map((s) => {
707
- if (s.ShippingCompanyName == 'Same Day EG')
708
- s.ShippingCompanyName = 'Same Day';
709
- else
710
- return s;
711
- });
712
- const datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
713
- if (this.isHolidays(datasSameDayNotAvaliable)) {
714
- shippingMethods = shippingMethods.filter((method) => method.serviceName !== 'Same Day');
715
- }
716
- if (totalPrice >= 200) {
717
- shippingMethods = shippingMethods.map((s) => {
718
- if (s.serviceName !== 'Same Day')
719
- return Object.assign(Object.assign({}, s), { totalPrice: 0 });
720
- else
721
- return s;
722
- });
723
- }
724
- if (shop == Shops.GLAMSHOP)
725
- return shippingMethods;
726
- if (this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
727
- shippingMethods = shippingMethods.map((s) => {
728
- if (s.serviceName == 'Same Day')
729
- return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
730
- else
731
- return Object.assign(Object.assign({}, s), { totalPrice: 0 });
732
- });
733
- }
734
- if (this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
735
- shippingMethods = shippingMethods.map((s) => {
736
- return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
737
- });
738
- }
739
- return shippingMethods;
740
- }));
741
- }
742
- isFreeShippingBySubscription(shop, subscriptionPlan) {
743
- if (!subscriptionPlan)
744
- return false;
745
- if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT') {
746
- return true;
747
- }
748
- return false;
749
- }
750
- isHalfShippingBySubscription(shop, subscriptionPlan) {
751
- if (!subscriptionPlan)
752
- return false;
753
- if (shop == Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
754
- return true;
755
- }
756
- return false;
757
- }
758
- isHolidays(datas) {
759
- const today = new Date();
760
- for (const key in datas) {
761
- let start = new Date(`${today.getFullYear()}-${datas[key].beginDate}`);
762
- let end = new Date(`${today.getFullYear()}-${datas[key].endDate}`);
763
- if (start > end)
764
- end = new Date(`${today.getFullYear() + 1}-${datas[key].endDate}`);
765
- if (today >= start && today <= end)
766
- return true;
767
- }
768
- return false;
769
- }
770
- }
771
- ShippingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService, deps: [{ token: i1$3.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0.ɵɵFactoryTarget.Injectable });
772
- ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService });
773
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService, decorators: [{
774
- type: Injectable
775
- }], ctorParameters: function () { return [{ type: i1$3.HttpClient }, { type: undefined, decorators: [{
776
- type: Inject,
777
- args: [BACKEND_URL]
688
+ class ShippingService {
689
+ constructor(http, apiUrl, homeService) {
690
+ this.http = http;
691
+ this.apiUrl = apiUrl;
692
+ this.homeService = homeService;
693
+ }
694
+ getShippingMethods(shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
695
+ return combineLatest([
696
+ this.homeService.getHomeData(),
697
+ this.http.get(`${this.apiUrl}open/checkshippingcompany?personId=${personId}&postalCode=${zip}&weightGrams=${weightGrams}`),
698
+ ]).pipe(map(([datas, shippingMethodsResponse]) => {
699
+ let shippingMethods = shippingMethodsResponse.result;
700
+ if (!shippingMethods.length)
701
+ return [];
702
+ shippingMethods = shippingMethods.map((s) => {
703
+ if (s.ShippingCompanyName == 'Same Day EG')
704
+ s.ShippingCompanyName = 'Same Day';
705
+ else
706
+ return s;
707
+ });
708
+ const datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
709
+ if (this.isHolidays(datasSameDayNotAvaliable)) {
710
+ shippingMethods = shippingMethods.filter((method) => method.serviceName !== 'Same Day');
711
+ }
712
+ if (totalPrice >= 200) {
713
+ shippingMethods = shippingMethods.map((s) => {
714
+ if (s.serviceName !== 'Same Day')
715
+ return Object.assign(Object.assign({}, s), { totalPrice: 0 });
716
+ else
717
+ return s;
718
+ });
719
+ }
720
+ if (shop == Shops.GLAMSHOP)
721
+ return shippingMethods;
722
+ if (this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
723
+ shippingMethods = shippingMethods.map((s) => {
724
+ if (s.serviceName == 'Same Day')
725
+ return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
726
+ else
727
+ return Object.assign(Object.assign({}, s), { totalPrice: 0 });
728
+ });
729
+ }
730
+ if (this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
731
+ shippingMethods = shippingMethods.map((s) => {
732
+ return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
733
+ });
734
+ }
735
+ return shippingMethods;
736
+ }));
737
+ }
738
+ isFreeShippingBySubscription(shop, subscriptionPlan) {
739
+ if (!subscriptionPlan)
740
+ return false;
741
+ if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT') {
742
+ return true;
743
+ }
744
+ return false;
745
+ }
746
+ isHalfShippingBySubscription(shop, subscriptionPlan) {
747
+ if (!subscriptionPlan)
748
+ return false;
749
+ if (shop == Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
750
+ return true;
751
+ }
752
+ return false;
753
+ }
754
+ isHolidays(datas) {
755
+ const today = new Date();
756
+ for (const key in datas) {
757
+ let start = new Date(`${today.getFullYear()}-${datas[key].beginDate}`);
758
+ let end = new Date(`${today.getFullYear()}-${datas[key].endDate}`);
759
+ if (start > end)
760
+ end = new Date(`${today.getFullYear() + 1}-${datas[key].endDate}`);
761
+ if (today >= start && today <= end)
762
+ return true;
763
+ }
764
+ return false;
765
+ }
766
+ }
767
+ ShippingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService, deps: [{ token: i1$3.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0.ɵɵFactoryTarget.Injectable });
768
+ ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService });
769
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService, decorators: [{
770
+ type: Injectable
771
+ }], ctorParameters: function () { return [{ type: i1$3.HttpClient }, { type: undefined, decorators: [{
772
+ type: Inject,
773
+ args: [BACKEND_URL]
778
774
  }] }, { type: HomeShopService }]; } });
779
775
 
780
- class AngularFirebaseAuthModule {
781
- static initializeApp(options, nameOrConfig) {
782
- return {
783
- ngModule: AngularFirebaseAuthModule,
784
- providers: [
785
- { provide: FIREBASE_OPTIONS, useValue: options },
786
- { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
787
- ],
788
- };
789
- }
790
- }
791
- AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
792
- AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, imports: [AngularFireModule] });
793
- AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
794
- {
795
- provide: 'Authentication',
796
- useFactory: (authenticationService, userRepository) => {
797
- return new Authentication(authenticationService, userRepository);
798
- },
799
- deps: ['AuthenticationService', 'UserRepository'],
800
- },
801
- {
802
- provide: 'AuthenticationService',
803
- useFactory: (angularFireAuth) => {
804
- return new AuthenticationFirebaseAuthService(angularFireAuth);
805
- },
806
- deps: [AngularFireAuth],
807
- },
808
- {
809
- provide: 'Register',
810
- useFactory: (registerService, userRepository) => {
811
- return new Register(registerService, userRepository);
812
- },
813
- deps: ['RegisterService', 'UserRepository'],
814
- },
815
- {
816
- provide: 'RegisterService',
817
- useFactory: (angularFireAuth) => {
818
- return new RegisterFirebaseAuthService(angularFireAuth);
819
- },
820
- deps: [AngularFireAuth],
821
- },
822
- {
823
- provide: 'SignOut',
824
- useFactory: (authenticationService) => {
825
- return new SignOut(authenticationService);
826
- },
827
- deps: ['AuthenticationService'],
828
- },
829
- {
830
- provide: 'RecoveryPassword',
831
- useFactory: (authenticationService) => {
832
- return new RecoveryPassword(authenticationService);
833
- },
834
- deps: ['AuthenticationService'],
835
- },
836
- ], imports: [[AngularFireModule]] });
837
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
838
- type: NgModule,
839
- args: [{
840
- imports: [AngularFireModule],
841
- providers: [
842
- {
843
- provide: 'Authentication',
844
- useFactory: (authenticationService, userRepository) => {
845
- return new Authentication(authenticationService, userRepository);
846
- },
847
- deps: ['AuthenticationService', 'UserRepository'],
848
- },
849
- {
850
- provide: 'AuthenticationService',
851
- useFactory: (angularFireAuth) => {
852
- return new AuthenticationFirebaseAuthService(angularFireAuth);
853
- },
854
- deps: [AngularFireAuth],
855
- },
856
- {
857
- provide: 'Register',
858
- useFactory: (registerService, userRepository) => {
859
- return new Register(registerService, userRepository);
860
- },
861
- deps: ['RegisterService', 'UserRepository'],
862
- },
863
- {
864
- provide: 'RegisterService',
865
- useFactory: (angularFireAuth) => {
866
- return new RegisterFirebaseAuthService(angularFireAuth);
867
- },
868
- deps: [AngularFireAuth],
869
- },
870
- {
871
- provide: 'SignOut',
872
- useFactory: (authenticationService) => {
873
- return new SignOut(authenticationService);
874
- },
875
- deps: ['AuthenticationService'],
876
- },
877
- {
878
- provide: 'RecoveryPassword',
879
- useFactory: (authenticationService) => {
880
- return new RecoveryPassword(authenticationService);
881
- },
882
- deps: ['AuthenticationService'],
883
- },
884
- ],
885
- }]
776
+ class AngularFirebaseAuthModule {
777
+ static initializeApp(options, nameOrConfig) {
778
+ return {
779
+ ngModule: AngularFirebaseAuthModule,
780
+ providers: [
781
+ { provide: FIREBASE_OPTIONS, useValue: options },
782
+ { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
783
+ ],
784
+ };
785
+ }
786
+ }
787
+ AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
788
+ AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, imports: [AngularFireModule] });
789
+ AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
790
+ {
791
+ provide: 'Authentication',
792
+ useFactory: (authenticationService, userRepository) => {
793
+ return new Authentication(authenticationService, userRepository);
794
+ },
795
+ deps: ['AuthenticationService', 'UserRepository'],
796
+ },
797
+ {
798
+ provide: 'AuthenticationService',
799
+ useFactory: (angularFireAuth) => {
800
+ return new AuthenticationFirebaseAuthService(angularFireAuth);
801
+ },
802
+ deps: [AngularFireAuth],
803
+ },
804
+ {
805
+ provide: 'Register',
806
+ useFactory: (registerService, userRepository) => {
807
+ return new Register(registerService, userRepository);
808
+ },
809
+ deps: ['RegisterService', 'UserRepository'],
810
+ },
811
+ {
812
+ provide: 'RegisterService',
813
+ useFactory: (angularFireAuth) => {
814
+ return new RegisterFirebaseAuthService(angularFireAuth);
815
+ },
816
+ deps: [AngularFireAuth],
817
+ },
818
+ {
819
+ provide: 'SignOut',
820
+ useFactory: (authenticationService) => {
821
+ return new SignOut(authenticationService);
822
+ },
823
+ deps: ['AuthenticationService'],
824
+ },
825
+ {
826
+ provide: 'RecoveryPassword',
827
+ useFactory: (authenticationService) => {
828
+ return new RecoveryPassword(authenticationService);
829
+ },
830
+ deps: ['AuthenticationService'],
831
+ },
832
+ ], imports: [[AngularFireModule]] });
833
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
834
+ type: NgModule,
835
+ args: [{
836
+ imports: [AngularFireModule],
837
+ providers: [
838
+ {
839
+ provide: 'Authentication',
840
+ useFactory: (authenticationService, userRepository) => {
841
+ return new Authentication(authenticationService, userRepository);
842
+ },
843
+ deps: ['AuthenticationService', 'UserRepository'],
844
+ },
845
+ {
846
+ provide: 'AuthenticationService',
847
+ useFactory: (angularFireAuth) => {
848
+ return new AuthenticationFirebaseAuthService(angularFireAuth);
849
+ },
850
+ deps: [AngularFireAuth],
851
+ },
852
+ {
853
+ provide: 'Register',
854
+ useFactory: (registerService, userRepository) => {
855
+ return new Register(registerService, userRepository);
856
+ },
857
+ deps: ['RegisterService', 'UserRepository'],
858
+ },
859
+ {
860
+ provide: 'RegisterService',
861
+ useFactory: (angularFireAuth) => {
862
+ return new RegisterFirebaseAuthService(angularFireAuth);
863
+ },
864
+ deps: [AngularFireAuth],
865
+ },
866
+ {
867
+ provide: 'SignOut',
868
+ useFactory: (authenticationService) => {
869
+ return new SignOut(authenticationService);
870
+ },
871
+ deps: ['AuthenticationService'],
872
+ },
873
+ {
874
+ provide: 'RecoveryPassword',
875
+ useFactory: (authenticationService) => {
876
+ return new RecoveryPassword(authenticationService);
877
+ },
878
+ deps: ['AuthenticationService'],
879
+ },
880
+ ],
881
+ }]
886
882
  }] });
887
883
 
888
- class AngularElasticSeachModule {
889
- static initializeApp(options) {
890
- return {
891
- ngModule: AngularElasticSeachModule,
892
- providers: [{ provide: ES_CONFIG, useValue: options }],
893
- };
894
- }
895
- }
896
- AngularElasticSeachModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
897
- AngularElasticSeachModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule });
898
- AngularElasticSeachModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, providers: [
899
- {
900
- provide: ProductsIndex,
901
- useFactory: (configuration) => {
902
- return new ProductsIndex(new AxiosAdapter(configuration));
903
- },
904
- deps: [ES_CONFIG],
905
- },
906
- ] });
907
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, decorators: [{
908
- type: NgModule,
909
- args: [{
910
- providers: [
911
- {
912
- provide: ProductsIndex,
913
- useFactory: (configuration) => {
914
- return new ProductsIndex(new AxiosAdapter(configuration));
915
- },
916
- deps: [ES_CONFIG],
917
- },
918
- ],
919
- }]
884
+ class AngularElasticSeachModule {
885
+ static initializeApp(options) {
886
+ return {
887
+ ngModule: AngularElasticSeachModule,
888
+ providers: [{ provide: ES_CONFIG, useValue: options }],
889
+ };
890
+ }
891
+ }
892
+ AngularElasticSeachModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
893
+ AngularElasticSeachModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule });
894
+ AngularElasticSeachModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, providers: [
895
+ {
896
+ provide: ProductsIndex,
897
+ useFactory: (configuration) => {
898
+ return new ProductsIndex(new AxiosAdapter(configuration));
899
+ },
900
+ deps: [ES_CONFIG],
901
+ },
902
+ ] });
903
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, decorators: [{
904
+ type: NgModule,
905
+ args: [{
906
+ providers: [
907
+ {
908
+ provide: ProductsIndex,
909
+ useFactory: (configuration) => {
910
+ return new ProductsIndex(new AxiosAdapter(configuration));
911
+ },
912
+ deps: [ES_CONFIG],
913
+ },
914
+ ],
915
+ }]
920
916
  }] });
921
917
 
922
- class AngularFirestoreModule {
923
- static initializeApp(options, nameOrConfig) {
924
- return {
925
- ngModule: AngularFirestoreModule,
926
- providers: [
927
- { provide: FIREBASE_OPTIONS, useValue: options.firebase },
928
- { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
929
- { provide: ES_CONFIG, useValue: options.elasticSearch },
930
- ],
931
- };
932
- }
933
- }
934
- AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
935
- AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, imports: [AngularFireModule, AngularElasticSeachModule] });
936
- AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, providers: [
937
- {
938
- provide: 'BeautyProfileRepository',
939
- useFactory: (firestore, userRepository) => {
940
- return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
941
- },
942
- deps: [AngularFirestore, 'UserRepository'],
943
- },
944
- {
945
- provide: 'Buy2WinRepository',
946
- useFactory: (firestore) => {
947
- return new Buy2WinFirestoreRepository(firestore.firestore);
948
- },
949
- deps: [AngularFirestore],
950
- },
951
- {
952
- provide: CategoryFirestoreRepository,
953
- useFactory: (firestore) => {
954
- return new CategoryFirestoreRepository(firestore.firestore);
955
- },
956
- deps: [AngularFirestore],
957
- },
958
- {
959
- provide: 'CheckoutRepository',
960
- useFactory: (firestore) => {
961
- return new CheckoutFirestoreRepository(firestore.firestore);
962
- },
963
- deps: [AngularFirestore],
964
- },
965
- {
966
- provide: 'CheckoutSubscriptionRepository',
967
- useFactory: (firestore) => {
968
- return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
969
- },
970
- deps: [AngularFirestore],
971
- },
972
- {
973
- provide: 'CouponRepository',
974
- useFactory: (firestore) => {
975
- return new CouponFirestoreRepository(firestore.firestore);
976
- },
977
- deps: [AngularFirestore],
978
- },
979
- {
980
- provide: 'CampaignHashtagRepository',
981
- useFactory: (firestore) => {
982
- return new CampaignHashtagFirestoreRepository(firestore.firestore);
983
- },
984
- deps: [AngularFirestore],
985
- },
986
- {
987
- provide: 'CampaignDashboardRepository',
988
- useFactory: (firestore) => {
989
- return new CampaignDashboardFirestoreRepository(firestore.firestore);
990
- },
991
- deps: [AngularFirestore],
992
- },
993
- {
994
- provide: 'EditionRepository',
995
- useFactory: (firestore, subscriptionRepository) => {
996
- return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
997
- },
998
- deps: [AngularFirestore, 'SubscriptionRepository'],
999
- },
1000
- {
1001
- provide: 'HomeRepository',
1002
- useFactory: (firestore) => {
1003
- return new HomeFirestoreRepository(firestore.firestore);
1004
- },
1005
- deps: [AngularFirestore],
1006
- },
1007
- {
1008
- provide: 'LeadRepository',
1009
- useFactory: (firestore) => {
1010
- return new LeadFirestoreRepository(firestore.firestore);
1011
- },
1012
- deps: [AngularFirestore],
1013
- },
1014
- {
1015
- provide: 'LegacyOrderRepository',
1016
- useFactory: (firestore) => {
1017
- return new LegacyOrderFirestoreRepository(firestore.firestore);
1018
- },
1019
- deps: [AngularFirestore],
1020
- },
1021
- {
1022
- provide: 'ShopMenuRepository',
1023
- useFactory: (firestore) => {
1024
- return new ShopMenuFirestoreRepository(firestore.firestore);
1025
- },
1026
- deps: [AngularFirestore],
1027
- },
1028
- {
1029
- provide: 'OrderRepository',
1030
- useFactory: (firestore) => {
1031
- return new OrderFirestoreRepository(firestore.firestore);
1032
- },
1033
- deps: [AngularFirestore],
1034
- },
1035
- {
1036
- provide: 'PaymentRepository',
1037
- useFactory: (firestore) => {
1038
- return new PaymentFirestoreRepository(firestore.firestore);
1039
- },
1040
- deps: [AngularFirestore],
1041
- },
1042
- {
1043
- provide: ProductFirestoreRepository,
1044
- useFactory: (firestore) => {
1045
- return new ProductFirestoreRepository(firestore.firestore);
1046
- },
1047
- deps: [AngularFirestore],
1048
- },
1049
- {
1050
- provide: 'ShopSettingsRepository',
1051
- useFactory: (firestore) => {
1052
- return new ShopSettingsFirestoreRepository(firestore.firestore);
1053
- },
1054
- deps: [AngularFirestore],
1055
- },
1056
- {
1057
- provide: 'SubscriptionPaymentRepository',
1058
- useFactory: (firestore, subscriptionRepository) => {
1059
- return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1060
- },
1061
- deps: [AngularFirestore, 'SubscriptionRepository'],
1062
- },
1063
- {
1064
- provide: 'SubscriptionPlanRepository',
1065
- useFactory: (firestore) => {
1066
- return new SubscriptionPlanFirestoreRepository(firestore.firestore);
1067
- },
1068
- deps: [AngularFirestore],
1069
- },
1070
- {
1071
- provide: 'SubscriptionProductRepository',
1072
- useFactory: (firestore) => {
1073
- return new SubscriptionProductFirestoreRepository(firestore.firestore);
1074
- },
1075
- deps: [AngularFirestore],
1076
- },
1077
- {
1078
- provide: 'SubscriptionRepository',
1079
- useFactory: (firestore) => {
1080
- return new SubscriptionFirestoreRepository(firestore.firestore);
1081
- },
1082
- deps: [AngularFirestore],
1083
- },
1084
- {
1085
- provide: 'UserRepository',
1086
- useFactory: (firestore) => {
1087
- return new UserFirestoreRepository(firestore.firestore);
1088
- },
1089
- deps: [AngularFirestore],
1090
- },
1091
- {
1092
- provide: 'UserAddressRepository',
1093
- useFactory: (firestore, userRepository) => {
1094
- return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
1095
- },
1096
- deps: [AngularFirestore, 'UserRepository'],
1097
- },
1098
- {
1099
- provide: 'UserPaymentMethodRepository',
1100
- useFactory: (firestore, userRepository) => {
1101
- return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1102
- },
1103
- deps: [AngularFirestore, 'UserRepository'],
1104
- },
1105
- {
1106
- provide: ProductVariantFirestoreRepository,
1107
- useFactory: (firestore, productRepository) => {
1108
- return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1109
- },
1110
- deps: [AngularFirestore, ProductFirestoreRepository],
1111
- },
1112
- {
1113
- provide: APP_INITIALIZER,
1114
- useFactory: (firestore) => () => firestore.firestore.settings({ ignoreUndefinedProperties: true }),
1115
- deps: [AngularFirestore],
1116
- multi: true,
1117
- },
1118
- ], imports: [[AngularFireModule, AngularElasticSeachModule]] });
1119
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, decorators: [{
1120
- type: NgModule,
1121
- args: [{
1122
- imports: [AngularFireModule, AngularElasticSeachModule],
1123
- providers: [
1124
- {
1125
- provide: 'BeautyProfileRepository',
1126
- useFactory: (firestore, userRepository) => {
1127
- return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
1128
- },
1129
- deps: [AngularFirestore, 'UserRepository'],
1130
- },
1131
- {
1132
- provide: 'Buy2WinRepository',
1133
- useFactory: (firestore) => {
1134
- return new Buy2WinFirestoreRepository(firestore.firestore);
1135
- },
1136
- deps: [AngularFirestore],
1137
- },
1138
- {
1139
- provide: CategoryFirestoreRepository,
1140
- useFactory: (firestore) => {
1141
- return new CategoryFirestoreRepository(firestore.firestore);
1142
- },
1143
- deps: [AngularFirestore],
1144
- },
1145
- {
1146
- provide: 'CheckoutRepository',
1147
- useFactory: (firestore) => {
1148
- return new CheckoutFirestoreRepository(firestore.firestore);
1149
- },
1150
- deps: [AngularFirestore],
1151
- },
1152
- {
1153
- provide: 'CheckoutSubscriptionRepository',
1154
- useFactory: (firestore) => {
1155
- return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
1156
- },
1157
- deps: [AngularFirestore],
1158
- },
1159
- {
1160
- provide: 'CouponRepository',
1161
- useFactory: (firestore) => {
1162
- return new CouponFirestoreRepository(firestore.firestore);
1163
- },
1164
- deps: [AngularFirestore],
1165
- },
1166
- {
1167
- provide: 'CampaignHashtagRepository',
1168
- useFactory: (firestore) => {
1169
- return new CampaignHashtagFirestoreRepository(firestore.firestore);
1170
- },
1171
- deps: [AngularFirestore],
1172
- },
1173
- {
1174
- provide: 'CampaignDashboardRepository',
1175
- useFactory: (firestore) => {
1176
- return new CampaignDashboardFirestoreRepository(firestore.firestore);
1177
- },
1178
- deps: [AngularFirestore],
1179
- },
1180
- {
1181
- provide: 'EditionRepository',
1182
- useFactory: (firestore, subscriptionRepository) => {
1183
- return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
1184
- },
1185
- deps: [AngularFirestore, 'SubscriptionRepository'],
1186
- },
1187
- {
1188
- provide: 'HomeRepository',
1189
- useFactory: (firestore) => {
1190
- return new HomeFirestoreRepository(firestore.firestore);
1191
- },
1192
- deps: [AngularFirestore],
1193
- },
1194
- {
1195
- provide: 'LeadRepository',
1196
- useFactory: (firestore) => {
1197
- return new LeadFirestoreRepository(firestore.firestore);
1198
- },
1199
- deps: [AngularFirestore],
1200
- },
1201
- {
1202
- provide: 'LegacyOrderRepository',
1203
- useFactory: (firestore) => {
1204
- return new LegacyOrderFirestoreRepository(firestore.firestore);
1205
- },
1206
- deps: [AngularFirestore],
1207
- },
1208
- {
1209
- provide: 'ShopMenuRepository',
1210
- useFactory: (firestore) => {
1211
- return new ShopMenuFirestoreRepository(firestore.firestore);
1212
- },
1213
- deps: [AngularFirestore],
1214
- },
1215
- {
1216
- provide: 'OrderRepository',
1217
- useFactory: (firestore) => {
1218
- return new OrderFirestoreRepository(firestore.firestore);
1219
- },
1220
- deps: [AngularFirestore],
1221
- },
1222
- {
1223
- provide: 'PaymentRepository',
1224
- useFactory: (firestore) => {
1225
- return new PaymentFirestoreRepository(firestore.firestore);
1226
- },
1227
- deps: [AngularFirestore],
1228
- },
1229
- {
1230
- provide: ProductFirestoreRepository,
1231
- useFactory: (firestore) => {
1232
- return new ProductFirestoreRepository(firestore.firestore);
1233
- },
1234
- deps: [AngularFirestore],
1235
- },
1236
- {
1237
- provide: 'ShopSettingsRepository',
1238
- useFactory: (firestore) => {
1239
- return new ShopSettingsFirestoreRepository(firestore.firestore);
1240
- },
1241
- deps: [AngularFirestore],
1242
- },
1243
- {
1244
- provide: 'SubscriptionPaymentRepository',
1245
- useFactory: (firestore, subscriptionRepository) => {
1246
- return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1247
- },
1248
- deps: [AngularFirestore, 'SubscriptionRepository'],
1249
- },
1250
- {
1251
- provide: 'SubscriptionPlanRepository',
1252
- useFactory: (firestore) => {
1253
- return new SubscriptionPlanFirestoreRepository(firestore.firestore);
1254
- },
1255
- deps: [AngularFirestore],
1256
- },
1257
- {
1258
- provide: 'SubscriptionProductRepository',
1259
- useFactory: (firestore) => {
1260
- return new SubscriptionProductFirestoreRepository(firestore.firestore);
1261
- },
1262
- deps: [AngularFirestore],
1263
- },
1264
- {
1265
- provide: 'SubscriptionRepository',
1266
- useFactory: (firestore) => {
1267
- return new SubscriptionFirestoreRepository(firestore.firestore);
1268
- },
1269
- deps: [AngularFirestore],
1270
- },
1271
- {
1272
- provide: 'UserRepository',
1273
- useFactory: (firestore) => {
1274
- return new UserFirestoreRepository(firestore.firestore);
1275
- },
1276
- deps: [AngularFirestore],
1277
- },
1278
- {
1279
- provide: 'UserAddressRepository',
1280
- useFactory: (firestore, userRepository) => {
1281
- return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
1282
- },
1283
- deps: [AngularFirestore, 'UserRepository'],
1284
- },
1285
- {
1286
- provide: 'UserPaymentMethodRepository',
1287
- useFactory: (firestore, userRepository) => {
1288
- return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1289
- },
1290
- deps: [AngularFirestore, 'UserRepository'],
1291
- },
1292
- {
1293
- provide: ProductVariantFirestoreRepository,
1294
- useFactory: (firestore, productRepository) => {
1295
- return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1296
- },
1297
- deps: [AngularFirestore, ProductFirestoreRepository],
1298
- },
1299
- {
1300
- provide: APP_INITIALIZER,
1301
- useFactory: (firestore) => () => firestore.firestore.settings({ ignoreUndefinedProperties: true }),
1302
- deps: [AngularFirestore],
1303
- multi: true,
1304
- },
1305
- ],
1306
- }]
918
+ class AngularFirestoreModule {
919
+ static initializeApp(options, nameOrConfig) {
920
+ return {
921
+ ngModule: AngularFirestoreModule,
922
+ providers: [
923
+ { provide: FIREBASE_OPTIONS, useValue: options.firebase },
924
+ { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
925
+ { provide: ES_CONFIG, useValue: options.elasticSearch },
926
+ ],
927
+ };
928
+ }
929
+ }
930
+ AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
931
+ AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, imports: [AngularFireModule, AngularElasticSeachModule] });
932
+ AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, providers: [
933
+ {
934
+ provide: 'BeautyProfileRepository',
935
+ useFactory: (firestore, userRepository) => {
936
+ return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
937
+ },
938
+ deps: [AngularFirestore, 'UserRepository'],
939
+ },
940
+ {
941
+ provide: 'Buy2WinRepository',
942
+ useFactory: (firestore) => {
943
+ return new Buy2WinFirestoreRepository(firestore.firestore);
944
+ },
945
+ deps: [AngularFirestore],
946
+ },
947
+ {
948
+ provide: CategoryFirestoreRepository,
949
+ useFactory: (firestore) => {
950
+ return new CategoryFirestoreRepository(firestore.firestore);
951
+ },
952
+ deps: [AngularFirestore],
953
+ },
954
+ {
955
+ provide: 'CheckoutRepository',
956
+ useFactory: (firestore) => {
957
+ return new CheckoutFirestoreRepository(firestore.firestore);
958
+ },
959
+ deps: [AngularFirestore],
960
+ },
961
+ {
962
+ provide: 'CheckoutSubscriptionRepository',
963
+ useFactory: (firestore) => {
964
+ return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
965
+ },
966
+ deps: [AngularFirestore],
967
+ },
968
+ {
969
+ provide: 'CouponRepository',
970
+ useFactory: (firestore) => {
971
+ return new CouponFirestoreRepository(firestore.firestore);
972
+ },
973
+ deps: [AngularFirestore],
974
+ },
975
+ {
976
+ provide: 'CampaignHashtagRepository',
977
+ useFactory: (firestore) => {
978
+ return new CampaignHashtagFirestoreRepository(firestore.firestore);
979
+ },
980
+ deps: [AngularFirestore],
981
+ },
982
+ {
983
+ provide: 'CampaignDashboardRepository',
984
+ useFactory: (firestore) => {
985
+ return new CampaignDashboardFirestoreRepository(firestore.firestore);
986
+ },
987
+ deps: [AngularFirestore],
988
+ },
989
+ {
990
+ provide: 'EditionRepository',
991
+ useFactory: (firestore, subscriptionRepository) => {
992
+ return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
993
+ },
994
+ deps: [AngularFirestore, 'SubscriptionRepository'],
995
+ },
996
+ {
997
+ provide: 'HomeRepository',
998
+ useFactory: (firestore) => {
999
+ return new HomeFirestoreRepository(firestore.firestore);
1000
+ },
1001
+ deps: [AngularFirestore],
1002
+ },
1003
+ {
1004
+ provide: 'LeadRepository',
1005
+ useFactory: (firestore) => {
1006
+ return new LeadFirestoreRepository(firestore.firestore);
1007
+ },
1008
+ deps: [AngularFirestore],
1009
+ },
1010
+ {
1011
+ provide: 'LegacyOrderRepository',
1012
+ useFactory: (firestore) => {
1013
+ return new LegacyOrderFirestoreRepository(firestore.firestore);
1014
+ },
1015
+ deps: [AngularFirestore],
1016
+ },
1017
+ {
1018
+ provide: 'ShopMenuRepository',
1019
+ useFactory: (firestore) => {
1020
+ return new ShopMenuFirestoreRepository(firestore.firestore);
1021
+ },
1022
+ deps: [AngularFirestore],
1023
+ },
1024
+ {
1025
+ provide: 'OrderRepository',
1026
+ useFactory: (firestore) => {
1027
+ return new OrderFirestoreRepository(firestore.firestore);
1028
+ },
1029
+ deps: [AngularFirestore],
1030
+ },
1031
+ {
1032
+ provide: 'PaymentRepository',
1033
+ useFactory: (firestore) => {
1034
+ return new PaymentFirestoreRepository(firestore.firestore);
1035
+ },
1036
+ deps: [AngularFirestore],
1037
+ },
1038
+ {
1039
+ provide: ProductFirestoreRepository,
1040
+ useFactory: (firestore) => {
1041
+ return new ProductFirestoreRepository(firestore.firestore);
1042
+ },
1043
+ deps: [AngularFirestore],
1044
+ },
1045
+ {
1046
+ provide: 'ShopSettingsRepository',
1047
+ useFactory: (firestore) => {
1048
+ return new ShopSettingsFirestoreRepository(firestore.firestore);
1049
+ },
1050
+ deps: [AngularFirestore],
1051
+ },
1052
+ {
1053
+ provide: 'SubscriptionPaymentRepository',
1054
+ useFactory: (firestore, subscriptionRepository) => {
1055
+ return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1056
+ },
1057
+ deps: [AngularFirestore, 'SubscriptionRepository'],
1058
+ },
1059
+ {
1060
+ provide: 'SubscriptionPlanRepository',
1061
+ useFactory: (firestore) => {
1062
+ return new SubscriptionPlanFirestoreRepository(firestore.firestore);
1063
+ },
1064
+ deps: [AngularFirestore],
1065
+ },
1066
+ {
1067
+ provide: 'SubscriptionProductRepository',
1068
+ useFactory: (firestore) => {
1069
+ return new SubscriptionProductFirestoreRepository(firestore.firestore);
1070
+ },
1071
+ deps: [AngularFirestore],
1072
+ },
1073
+ {
1074
+ provide: 'SubscriptionRepository',
1075
+ useFactory: (firestore) => {
1076
+ return new SubscriptionFirestoreRepository(firestore.firestore);
1077
+ },
1078
+ deps: [AngularFirestore],
1079
+ },
1080
+ {
1081
+ provide: 'UserRepository',
1082
+ useFactory: (firestore) => {
1083
+ return new UserFirestoreRepository(firestore.firestore);
1084
+ },
1085
+ deps: [AngularFirestore],
1086
+ },
1087
+ {
1088
+ provide: 'UserAddressRepository',
1089
+ useFactory: (firestore, userRepository) => {
1090
+ return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
1091
+ },
1092
+ deps: [AngularFirestore, 'UserRepository'],
1093
+ },
1094
+ {
1095
+ provide: 'UserPaymentMethodRepository',
1096
+ useFactory: (firestore, userRepository) => {
1097
+ return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1098
+ },
1099
+ deps: [AngularFirestore, 'UserRepository'],
1100
+ },
1101
+ {
1102
+ provide: ProductVariantFirestoreRepository,
1103
+ useFactory: (firestore, productRepository) => {
1104
+ return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1105
+ },
1106
+ deps: [AngularFirestore, ProductFirestoreRepository],
1107
+ },
1108
+ {
1109
+ provide: APP_INITIALIZER,
1110
+ useFactory: (firestore) => () => firestore.firestore.settings({ ignoreUndefinedProperties: true }),
1111
+ deps: [AngularFirestore],
1112
+ multi: true,
1113
+ },
1114
+ ], imports: [[AngularFireModule, AngularElasticSeachModule]] });
1115
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, decorators: [{
1116
+ type: NgModule,
1117
+ args: [{
1118
+ imports: [AngularFireModule, AngularElasticSeachModule],
1119
+ providers: [
1120
+ {
1121
+ provide: 'BeautyProfileRepository',
1122
+ useFactory: (firestore, userRepository) => {
1123
+ return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
1124
+ },
1125
+ deps: [AngularFirestore, 'UserRepository'],
1126
+ },
1127
+ {
1128
+ provide: 'Buy2WinRepository',
1129
+ useFactory: (firestore) => {
1130
+ return new Buy2WinFirestoreRepository(firestore.firestore);
1131
+ },
1132
+ deps: [AngularFirestore],
1133
+ },
1134
+ {
1135
+ provide: CategoryFirestoreRepository,
1136
+ useFactory: (firestore) => {
1137
+ return new CategoryFirestoreRepository(firestore.firestore);
1138
+ },
1139
+ deps: [AngularFirestore],
1140
+ },
1141
+ {
1142
+ provide: 'CheckoutRepository',
1143
+ useFactory: (firestore) => {
1144
+ return new CheckoutFirestoreRepository(firestore.firestore);
1145
+ },
1146
+ deps: [AngularFirestore],
1147
+ },
1148
+ {
1149
+ provide: 'CheckoutSubscriptionRepository',
1150
+ useFactory: (firestore) => {
1151
+ return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
1152
+ },
1153
+ deps: [AngularFirestore],
1154
+ },
1155
+ {
1156
+ provide: 'CouponRepository',
1157
+ useFactory: (firestore) => {
1158
+ return new CouponFirestoreRepository(firestore.firestore);
1159
+ },
1160
+ deps: [AngularFirestore],
1161
+ },
1162
+ {
1163
+ provide: 'CampaignHashtagRepository',
1164
+ useFactory: (firestore) => {
1165
+ return new CampaignHashtagFirestoreRepository(firestore.firestore);
1166
+ },
1167
+ deps: [AngularFirestore],
1168
+ },
1169
+ {
1170
+ provide: 'CampaignDashboardRepository',
1171
+ useFactory: (firestore) => {
1172
+ return new CampaignDashboardFirestoreRepository(firestore.firestore);
1173
+ },
1174
+ deps: [AngularFirestore],
1175
+ },
1176
+ {
1177
+ provide: 'EditionRepository',
1178
+ useFactory: (firestore, subscriptionRepository) => {
1179
+ return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
1180
+ },
1181
+ deps: [AngularFirestore, 'SubscriptionRepository'],
1182
+ },
1183
+ {
1184
+ provide: 'HomeRepository',
1185
+ useFactory: (firestore) => {
1186
+ return new HomeFirestoreRepository(firestore.firestore);
1187
+ },
1188
+ deps: [AngularFirestore],
1189
+ },
1190
+ {
1191
+ provide: 'LeadRepository',
1192
+ useFactory: (firestore) => {
1193
+ return new LeadFirestoreRepository(firestore.firestore);
1194
+ },
1195
+ deps: [AngularFirestore],
1196
+ },
1197
+ {
1198
+ provide: 'LegacyOrderRepository',
1199
+ useFactory: (firestore) => {
1200
+ return new LegacyOrderFirestoreRepository(firestore.firestore);
1201
+ },
1202
+ deps: [AngularFirestore],
1203
+ },
1204
+ {
1205
+ provide: 'ShopMenuRepository',
1206
+ useFactory: (firestore) => {
1207
+ return new ShopMenuFirestoreRepository(firestore.firestore);
1208
+ },
1209
+ deps: [AngularFirestore],
1210
+ },
1211
+ {
1212
+ provide: 'OrderRepository',
1213
+ useFactory: (firestore) => {
1214
+ return new OrderFirestoreRepository(firestore.firestore);
1215
+ },
1216
+ deps: [AngularFirestore],
1217
+ },
1218
+ {
1219
+ provide: 'PaymentRepository',
1220
+ useFactory: (firestore) => {
1221
+ return new PaymentFirestoreRepository(firestore.firestore);
1222
+ },
1223
+ deps: [AngularFirestore],
1224
+ },
1225
+ {
1226
+ provide: ProductFirestoreRepository,
1227
+ useFactory: (firestore) => {
1228
+ return new ProductFirestoreRepository(firestore.firestore);
1229
+ },
1230
+ deps: [AngularFirestore],
1231
+ },
1232
+ {
1233
+ provide: 'ShopSettingsRepository',
1234
+ useFactory: (firestore) => {
1235
+ return new ShopSettingsFirestoreRepository(firestore.firestore);
1236
+ },
1237
+ deps: [AngularFirestore],
1238
+ },
1239
+ {
1240
+ provide: 'SubscriptionPaymentRepository',
1241
+ useFactory: (firestore, subscriptionRepository) => {
1242
+ return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1243
+ },
1244
+ deps: [AngularFirestore, 'SubscriptionRepository'],
1245
+ },
1246
+ {
1247
+ provide: 'SubscriptionPlanRepository',
1248
+ useFactory: (firestore) => {
1249
+ return new SubscriptionPlanFirestoreRepository(firestore.firestore);
1250
+ },
1251
+ deps: [AngularFirestore],
1252
+ },
1253
+ {
1254
+ provide: 'SubscriptionProductRepository',
1255
+ useFactory: (firestore) => {
1256
+ return new SubscriptionProductFirestoreRepository(firestore.firestore);
1257
+ },
1258
+ deps: [AngularFirestore],
1259
+ },
1260
+ {
1261
+ provide: 'SubscriptionRepository',
1262
+ useFactory: (firestore) => {
1263
+ return new SubscriptionFirestoreRepository(firestore.firestore);
1264
+ },
1265
+ deps: [AngularFirestore],
1266
+ },
1267
+ {
1268
+ provide: 'UserRepository',
1269
+ useFactory: (firestore) => {
1270
+ return new UserFirestoreRepository(firestore.firestore);
1271
+ },
1272
+ deps: [AngularFirestore],
1273
+ },
1274
+ {
1275
+ provide: 'UserAddressRepository',
1276
+ useFactory: (firestore, userRepository) => {
1277
+ return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
1278
+ },
1279
+ deps: [AngularFirestore, 'UserRepository'],
1280
+ },
1281
+ {
1282
+ provide: 'UserPaymentMethodRepository',
1283
+ useFactory: (firestore, userRepository) => {
1284
+ return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1285
+ },
1286
+ deps: [AngularFirestore, 'UserRepository'],
1287
+ },
1288
+ {
1289
+ provide: ProductVariantFirestoreRepository,
1290
+ useFactory: (firestore, productRepository) => {
1291
+ return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1292
+ },
1293
+ deps: [AngularFirestore, ProductFirestoreRepository],
1294
+ },
1295
+ {
1296
+ provide: APP_INITIALIZER,
1297
+ useFactory: (firestore) => () => firestore.firestore.settings({ ignoreUndefinedProperties: true }),
1298
+ deps: [AngularFirestore],
1299
+ multi: true,
1300
+ },
1301
+ ],
1302
+ }]
1307
1303
  }] });
1308
1304
 
1309
- class AngularHasuraGraphQLModule {
1310
- static initializeApp(options) {
1311
- return {
1312
- ngModule: AngularHasuraGraphQLModule,
1313
- providers: [{ provide: HASURA_OPTIONS, useValue: options }],
1314
- };
1315
- }
1316
- }
1317
- AngularHasuraGraphQLModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1318
- AngularHasuraGraphQLModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule });
1319
- AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, providers: [
1320
- {
1321
- provide: 'CategoryRepository',
1322
- useExisting: CategoryHasuraGraphQLRepository,
1323
- },
1324
- {
1325
- provide: CategoryHasuraGraphQLRepository,
1326
- useFactory: (options, productRepository, categoryFilterRepository) => {
1327
- return new CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
1328
- },
1329
- deps: [HASURA_OPTIONS, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1330
- },
1331
- {
1332
- provide: 'ProductRepository',
1333
- useExisting: ProductHasuraGraphQLRepository,
1334
- },
1335
- {
1336
- provide: ProductHasuraGraphQLRepository,
1337
- useFactory: (options) => {
1338
- return new ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
1339
- },
1340
- deps: [HASURA_OPTIONS],
1341
- },
1342
- {
1343
- provide: 'VariantRepository',
1344
- useExisting: VariantHasuraGraphQLRepository,
1345
- },
1346
- {
1347
- provide: VariantHasuraGraphQLRepository,
1348
- useFactory: (options) => {
1349
- return new VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
1350
- },
1351
- deps: [HASURA_OPTIONS],
1352
- },
1353
- {
1354
- provide: 'CategoryFilterRepository',
1355
- useExisting: CategoryFilterHasuraGraphQLRepository,
1356
- },
1357
- {
1358
- provide: CategoryFilterHasuraGraphQLRepository,
1359
- useFactory: (options) => {
1360
- return new CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
1361
- },
1362
- deps: [HASURA_OPTIONS],
1363
- },
1364
- {
1365
- provide: 'FilterOptionRepository',
1366
- useExisting: FilterOptionHasuraGraphQLRepository,
1367
- },
1368
- {
1369
- provide: FilterOptionHasuraGraphQLRepository,
1370
- useFactory: (options) => {
1371
- return new FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
1372
- },
1373
- deps: [HASURA_OPTIONS],
1374
- },
1375
- {
1376
- provide: 'FilterRepository',
1377
- useExisting: FilterHasuraGraphQLRepository,
1378
- },
1379
- {
1380
- provide: FilterHasuraGraphQLRepository,
1381
- useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
1382
- return new FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
1383
- },
1384
- deps: [HASURA_OPTIONS, FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1385
- },
1386
- ] });
1387
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
1388
- type: NgModule,
1389
- args: [{
1390
- providers: [
1391
- {
1392
- provide: 'CategoryRepository',
1393
- useExisting: CategoryHasuraGraphQLRepository,
1394
- },
1395
- {
1396
- provide: CategoryHasuraGraphQLRepository,
1397
- useFactory: (options, productRepository, categoryFilterRepository) => {
1398
- return new CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
1399
- },
1400
- deps: [HASURA_OPTIONS, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1401
- },
1402
- {
1403
- provide: 'ProductRepository',
1404
- useExisting: ProductHasuraGraphQLRepository,
1405
- },
1406
- {
1407
- provide: ProductHasuraGraphQLRepository,
1408
- useFactory: (options) => {
1409
- return new ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
1410
- },
1411
- deps: [HASURA_OPTIONS],
1412
- },
1413
- {
1414
- provide: 'VariantRepository',
1415
- useExisting: VariantHasuraGraphQLRepository,
1416
- },
1417
- {
1418
- provide: VariantHasuraGraphQLRepository,
1419
- useFactory: (options) => {
1420
- return new VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
1421
- },
1422
- deps: [HASURA_OPTIONS],
1423
- },
1424
- {
1425
- provide: 'CategoryFilterRepository',
1426
- useExisting: CategoryFilterHasuraGraphQLRepository,
1427
- },
1428
- {
1429
- provide: CategoryFilterHasuraGraphQLRepository,
1430
- useFactory: (options) => {
1431
- return new CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
1432
- },
1433
- deps: [HASURA_OPTIONS],
1434
- },
1435
- {
1436
- provide: 'FilterOptionRepository',
1437
- useExisting: FilterOptionHasuraGraphQLRepository,
1438
- },
1439
- {
1440
- provide: FilterOptionHasuraGraphQLRepository,
1441
- useFactory: (options) => {
1442
- return new FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
1443
- },
1444
- deps: [HASURA_OPTIONS],
1445
- },
1446
- {
1447
- provide: 'FilterRepository',
1448
- useExisting: FilterHasuraGraphQLRepository,
1449
- },
1450
- {
1451
- provide: FilterHasuraGraphQLRepository,
1452
- useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
1453
- return new FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
1454
- },
1455
- deps: [HASURA_OPTIONS, FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1456
- },
1457
- ],
1458
- }]
1305
+ class AngularHasuraGraphQLModule {
1306
+ static initializeApp(options) {
1307
+ return {
1308
+ ngModule: AngularHasuraGraphQLModule,
1309
+ providers: [{ provide: HASURA_OPTIONS, useValue: options }],
1310
+ };
1311
+ }
1312
+ }
1313
+ AngularHasuraGraphQLModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1314
+ AngularHasuraGraphQLModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule });
1315
+ AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, providers: [
1316
+ {
1317
+ provide: 'CategoryRepository',
1318
+ useExisting: CategoryHasuraGraphQLRepository,
1319
+ },
1320
+ {
1321
+ provide: CategoryHasuraGraphQLRepository,
1322
+ useFactory: (options, productRepository, categoryFilterRepository) => {
1323
+ return new CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
1324
+ },
1325
+ deps: [HASURA_OPTIONS, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1326
+ },
1327
+ {
1328
+ provide: 'ProductRepository',
1329
+ useExisting: ProductHasuraGraphQLRepository,
1330
+ },
1331
+ {
1332
+ provide: ProductHasuraGraphQLRepository,
1333
+ useFactory: (options) => {
1334
+ return new ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
1335
+ },
1336
+ deps: [HASURA_OPTIONS],
1337
+ },
1338
+ {
1339
+ provide: 'VariantRepository',
1340
+ useExisting: VariantHasuraGraphQLRepository,
1341
+ },
1342
+ {
1343
+ provide: VariantHasuraGraphQLRepository,
1344
+ useFactory: (options) => {
1345
+ return new VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
1346
+ },
1347
+ deps: [HASURA_OPTIONS],
1348
+ },
1349
+ {
1350
+ provide: 'CategoryFilterRepository',
1351
+ useExisting: CategoryFilterHasuraGraphQLRepository,
1352
+ },
1353
+ {
1354
+ provide: CategoryFilterHasuraGraphQLRepository,
1355
+ useFactory: (options) => {
1356
+ return new CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
1357
+ },
1358
+ deps: [HASURA_OPTIONS],
1359
+ },
1360
+ {
1361
+ provide: 'FilterOptionRepository',
1362
+ useExisting: FilterOptionHasuraGraphQLRepository,
1363
+ },
1364
+ {
1365
+ provide: FilterOptionHasuraGraphQLRepository,
1366
+ useFactory: (options) => {
1367
+ return new FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
1368
+ },
1369
+ deps: [HASURA_OPTIONS],
1370
+ },
1371
+ {
1372
+ provide: 'FilterRepository',
1373
+ useExisting: FilterHasuraGraphQLRepository,
1374
+ },
1375
+ {
1376
+ provide: FilterHasuraGraphQLRepository,
1377
+ useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
1378
+ return new FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
1379
+ },
1380
+ deps: [HASURA_OPTIONS, FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1381
+ },
1382
+ ] });
1383
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
1384
+ type: NgModule,
1385
+ args: [{
1386
+ providers: [
1387
+ {
1388
+ provide: 'CategoryRepository',
1389
+ useExisting: CategoryHasuraGraphQLRepository,
1390
+ },
1391
+ {
1392
+ provide: CategoryHasuraGraphQLRepository,
1393
+ useFactory: (options, productRepository, categoryFilterRepository) => {
1394
+ return new CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
1395
+ },
1396
+ deps: [HASURA_OPTIONS, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1397
+ },
1398
+ {
1399
+ provide: 'ProductRepository',
1400
+ useExisting: ProductHasuraGraphQLRepository,
1401
+ },
1402
+ {
1403
+ provide: ProductHasuraGraphQLRepository,
1404
+ useFactory: (options) => {
1405
+ return new ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
1406
+ },
1407
+ deps: [HASURA_OPTIONS],
1408
+ },
1409
+ {
1410
+ provide: 'VariantRepository',
1411
+ useExisting: VariantHasuraGraphQLRepository,
1412
+ },
1413
+ {
1414
+ provide: VariantHasuraGraphQLRepository,
1415
+ useFactory: (options) => {
1416
+ return new VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
1417
+ },
1418
+ deps: [HASURA_OPTIONS],
1419
+ },
1420
+ {
1421
+ provide: 'CategoryFilterRepository',
1422
+ useExisting: CategoryFilterHasuraGraphQLRepository,
1423
+ },
1424
+ {
1425
+ provide: CategoryFilterHasuraGraphQLRepository,
1426
+ useFactory: (options) => {
1427
+ return new CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
1428
+ },
1429
+ deps: [HASURA_OPTIONS],
1430
+ },
1431
+ {
1432
+ provide: 'FilterOptionRepository',
1433
+ useExisting: FilterOptionHasuraGraphQLRepository,
1434
+ },
1435
+ {
1436
+ provide: FilterOptionHasuraGraphQLRepository,
1437
+ useFactory: (options) => {
1438
+ return new FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
1439
+ },
1440
+ deps: [HASURA_OPTIONS],
1441
+ },
1442
+ {
1443
+ provide: 'FilterRepository',
1444
+ useExisting: FilterHasuraGraphQLRepository,
1445
+ },
1446
+ {
1447
+ provide: FilterHasuraGraphQLRepository,
1448
+ useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
1449
+ return new FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
1450
+ },
1451
+ deps: [HASURA_OPTIONS, FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1452
+ },
1453
+ ],
1454
+ }]
1459
1455
  }] });
1460
1456
 
1461
- class AngularConnectModule {
1462
- static initializeApp(defaultShop, options, nameOrConfig) {
1463
- return {
1464
- ngModule: AngularConnectModule,
1465
- providers: [
1466
- ...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
1467
- ...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options === null || options === void 0 ? void 0 : options.firebase }]),
1468
- ...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
1469
- ...(isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
1470
- ...(isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
1471
- ...(isNil(options === null || options === void 0 ? void 0 : options.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]),
1472
- ],
1473
- };
1474
- }
1475
- }
1476
- AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1477
- AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, imports: [AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
1478
- AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, providers: [
1479
- AuthService,
1480
- CartService,
1481
- CheckoutService,
1482
- CheckoutSubscriptionService,
1483
- CouponService,
1484
- HomeShopService,
1485
- OrderService,
1486
- ShippingService,
1487
- ], imports: [[AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
1488
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, decorators: [{
1489
- type: NgModule,
1490
- args: [{
1491
- imports: [AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule],
1492
- providers: [
1493
- AuthService,
1494
- CartService,
1495
- CheckoutService,
1496
- CheckoutSubscriptionService,
1497
- CouponService,
1498
- HomeShopService,
1499
- OrderService,
1500
- ShippingService,
1501
- ],
1502
- }]
1457
+ class AngularConnectModule {
1458
+ static initializeApp(defaultShop, options, nameOrConfig) {
1459
+ return {
1460
+ ngModule: AngularConnectModule,
1461
+ providers: [
1462
+ ...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
1463
+ ...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options === null || options === void 0 ? void 0 : options.firebase }]),
1464
+ ...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
1465
+ ...(isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
1466
+ ...(isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
1467
+ ...(isNil(options === null || options === void 0 ? void 0 : options.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]),
1468
+ ],
1469
+ };
1470
+ }
1471
+ }
1472
+ AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1473
+ AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, imports: [AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
1474
+ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, providers: [
1475
+ AuthService,
1476
+ CartService,
1477
+ CheckoutService,
1478
+ CheckoutSubscriptionService,
1479
+ CouponService,
1480
+ HomeShopService,
1481
+ OrderService,
1482
+ ShippingService,
1483
+ ], imports: [[AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
1484
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, decorators: [{
1485
+ type: NgModule,
1486
+ args: [{
1487
+ imports: [AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule],
1488
+ providers: [
1489
+ AuthService,
1490
+ CartService,
1491
+ CheckoutService,
1492
+ CheckoutSubscriptionService,
1493
+ CouponService,
1494
+ HomeShopService,
1495
+ OrderService,
1496
+ ShippingService,
1497
+ ],
1498
+ }]
1503
1499
  }] });
1504
1500
 
1505
- /**
1506
- * Generated bundle index. Do not edit.
1501
+ /**
1502
+ * Generated bundle index. Do not edit.
1507
1503
  */
1508
1504
 
1509
1505
  export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, OrderService, ShippingService };