@infrab4a/connect-angular 0.7.0 → 0.7.3

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 (35) hide show
  1. package/bundles/infrab4a-connect-angular.umd.js +980 -973
  2. package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
  3. package/esm2015/infrab4a-connect-angular.js +4 -4
  4. package/esm2015/lib/angular-connect.module.js +30 -30
  5. package/esm2015/lib/angular-firebase-auth.module.js +71 -71
  6. package/esm2015/lib/angular-firestore.module.js +309 -309
  7. package/esm2015/lib/consts/default-shop.const.js +2 -2
  8. package/esm2015/lib/consts/index.js +2 -2
  9. package/esm2015/lib/index.js +5 -5
  10. package/esm2015/lib/services/auth.service.js +33 -27
  11. package/esm2015/lib/services/cart.service.js +153 -153
  12. package/esm2015/lib/services/checkout.service.js +57 -57
  13. package/esm2015/lib/services/index.js +5 -5
  14. package/esm2015/lib/services/order.service.js +32 -32
  15. package/esm2015/lib/services/types/index.js +2 -2
  16. package/esm2015/lib/services/types/required-checkout-data.type.js +2 -2
  17. package/esm2015/public-api.js +2 -2
  18. package/fesm2015/infrab4a-connect-angular.js +624 -618
  19. package/fesm2015/infrab4a-connect-angular.js.map +1 -1
  20. package/infrab4a-connect-angular.d.ts +5 -5
  21. package/lib/angular-connect.module.d.ts +12 -12
  22. package/lib/angular-firebase-auth.module.d.ts +10 -10
  23. package/lib/angular-firestore.module.d.ts +10 -10
  24. package/lib/consts/default-shop.const.d.ts +1 -1
  25. package/lib/consts/index.d.ts +1 -1
  26. package/lib/index.d.ts +4 -4
  27. package/lib/services/auth.service.d.ts +16 -13
  28. package/lib/services/cart.service.d.ts +35 -35
  29. package/lib/services/checkout.service.d.ts +18 -18
  30. package/lib/services/index.d.ts +4 -4
  31. package/lib/services/order.service.d.ts +13 -13
  32. package/lib/services/types/index.d.ts +1 -1
  33. package/lib/services/types/required-checkout-data.type.d.ts +2 -2
  34. package/package.json +1 -1
  35. package/public-api.d.ts +1 -1
@@ -2,8 +2,8 @@ import * as i0 from '@angular/core';
2
2
  import { Injectable, Inject, NgModule } from '@angular/core';
3
3
  import * as i1 from '@angular/fire/auth';
4
4
  import { AngularFireAuth } from '@angular/fire/auth';
5
- import { from, throwError, of, Subject, iif } from 'rxjs';
6
- import { map, mergeMap, concatMap, tap, catchError } from 'rxjs/operators';
5
+ import { throwError, from, of, Subject, iif } from 'rxjs';
6
+ import { mergeMap, map, concatMap, tap, catchError } from 'rxjs/operators';
7
7
  import * as i1$1 from '@infrab4a/connect';
8
8
  import { isNil, NotFoundError, Checkout, pick, LineItem, CouponTypes, FinancialCoupon, CouponSubtypes, Order, Authentication, AuthenticationFirebaseAuthService, SignOut, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, ProductVariantFirestoreRepository } from '@infrab4a/connect';
9
9
  import { __awaiter } from 'tslib';
@@ -12,638 +12,644 @@ import * as i1$2 from '@angular/fire/firestore';
12
12
  import { AngularFirestore } from '@angular/fire/firestore';
13
13
  import { FIREBASE_OPTIONS, FIREBASE_APP_NAME, AngularFireModule } from '@angular/fire';
14
14
 
15
- class AuthService {
16
- constructor(angularFireAuth, userRepository) {
17
- this.angularFireAuth = angularFireAuth;
18
- this.userRepository = userRepository;
19
- }
20
- getUser() {
21
- return from(this.getTokenId()).pipe(map((id) => id || throwError(() => new Error('Usuário não logado'))), mergeMap((id) => this.userRepository.get({ id })));
22
- }
23
- getTokenId() {
24
- return this.angularFireAuth.idToken;
25
- }
26
- }
27
- AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AuthService, deps: [{ token: i1.AngularFireAuth }, { token: 'UserRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
28
- AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AuthService });
29
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AuthService, decorators: [{
30
- type: Injectable
31
- }], ctorParameters: function () { return [{ type: i1.AngularFireAuth }, { type: undefined, decorators: [{
32
- type: Inject,
33
- args: ['UserRepository']
15
+ class AuthService {
16
+ constructor(angularFireAuth, userRepository) {
17
+ this.angularFireAuth = angularFireAuth;
18
+ this.userRepository = userRepository;
19
+ }
20
+ getAuthstate() {
21
+ return this.angularFireAuth.authState.pipe(mergeMap(() => this.getUser()));
22
+ }
23
+ getUser() {
24
+ return this.getFireUser().pipe(map((user) => user.uid || throwError(() => new Error('Usuário não logado'))), mergeMap((id) => this.userRepository.get({ id })));
25
+ }
26
+ getTokenId() {
27
+ return this.angularFireAuth.idToken;
28
+ }
29
+ getFireUser() {
30
+ return this.angularFireAuth.user;
31
+ }
32
+ }
33
+ 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 });
34
+ AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService });
35
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService, decorators: [{
36
+ type: Injectable
37
+ }], ctorParameters: function () { return [{ type: i1.AngularFireAuth }, { type: undefined, decorators: [{
38
+ type: Inject,
39
+ args: ['UserRepository']
34
40
  }] }]; } });
35
41
 
36
42
  const DEFAULT_SHOP = 'DEFAULT_SHOP';
37
43
 
38
- class CheckoutService {
39
- constructor(checkoutRepository, userRepository, defaultShop) {
40
- this.checkoutRepository = checkoutRepository;
41
- this.userRepository = userRepository;
42
- this.defaultShop = defaultShop;
43
- }
44
- getCheckout(checkoutData) {
45
- const checkoutId = cookie.get('checkoutId');
46
- if (!isNil(checkoutId))
47
- return from(this.checkoutRepository.get({ id: checkoutId }));
48
- return from(this.createCheckout(checkoutData));
49
- }
50
- getUserByCheckout(checkoutId) {
51
- 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'))));
52
- }
53
- updateCheckoutLineItems(checkout) {
54
- return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
55
- }
56
- updateCheckoutUser(checkout) {
57
- return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
58
- }
59
- clearCheckoutFromSession() {
60
- cookie.remove('checkoutId');
61
- return of();
62
- }
63
- createCheckout(checkoutData) {
64
- return __awaiter(this, void 0, void 0, function* () {
65
- 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 }));
66
- cookie.set('checkoutId', checkout.id);
67
- return checkout;
68
- });
69
- }
70
- }
71
- CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: CheckoutService, deps: [{ token: 'CheckoutRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
72
- CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: CheckoutService });
73
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: CheckoutService, decorators: [{
74
- type: Injectable
75
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
76
- type: Inject,
77
- args: ['CheckoutRepository']
78
- }] }, { type: undefined, decorators: [{
79
- type: Inject,
80
- args: ['UserRepository']
81
- }] }, { type: i1$1.Shops, decorators: [{
82
- type: Inject,
83
- args: [DEFAULT_SHOP]
44
+ class CheckoutService {
45
+ constructor(checkoutRepository, userRepository, defaultShop) {
46
+ this.checkoutRepository = checkoutRepository;
47
+ this.userRepository = userRepository;
48
+ this.defaultShop = defaultShop;
49
+ }
50
+ getCheckout(checkoutData) {
51
+ const checkoutId = cookie.get('checkoutId');
52
+ if (!isNil(checkoutId))
53
+ return from(this.checkoutRepository.get({ id: checkoutId }));
54
+ return from(this.createCheckout(checkoutData));
55
+ }
56
+ getUserByCheckout(checkoutId) {
57
+ 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'))));
58
+ }
59
+ updateCheckoutLineItems(checkout) {
60
+ return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
61
+ }
62
+ updateCheckoutUser(checkout) {
63
+ return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
64
+ }
65
+ clearCheckoutFromSession() {
66
+ cookie.remove('checkoutId');
67
+ return of();
68
+ }
69
+ createCheckout(checkoutData) {
70
+ return __awaiter(this, void 0, void 0, function* () {
71
+ 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 }));
72
+ cookie.set('checkoutId', checkout.id);
73
+ return checkout;
74
+ });
75
+ }
76
+ }
77
+ CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService, deps: [{ token: 'CheckoutRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
78
+ CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService });
79
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService, decorators: [{
80
+ type: Injectable
81
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
82
+ type: Inject,
83
+ args: ['CheckoutRepository']
84
+ }] }, { type: undefined, decorators: [{
85
+ type: Inject,
86
+ args: ['UserRepository']
87
+ }] }, { type: i1$1.Shops, decorators: [{
88
+ type: Inject,
89
+ args: [DEFAULT_SHOP]
84
90
  }] }]; } });
85
91
 
86
- class CartService {
87
- constructor(authService, checkoutService, defaultShop) {
88
- this.authService = authService;
89
- this.checkoutService = checkoutService;
90
- this.defaultShop = defaultShop;
91
- this.cartSubject = new Subject();
92
- this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
93
- var _a;
94
- const items = [];
95
- const index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map((checkoutItem) => checkoutItem.sku).indexOf(lineItem.sku);
96
- if (index > -1) {
97
- checkoutLoaded.lineItems[index].quantity += quantity;
98
- checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
99
- }
100
- else
101
- checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
102
- return this.checkoutService
103
- .updateCheckoutLineItems(checkoutLoaded)
104
- .pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
105
- }));
106
- this.generateCartObject = (items) => {
107
- const cart = {};
108
- items === null || items === void 0 ? void 0 : items.forEach((item) => {
109
- var _a;
110
- 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) })));
111
- });
112
- return cart;
113
- };
114
- this.buildLineItem = ({ checkout, item, quantity, }) => {
115
- var _a, _b, _c, _d, _e;
116
- 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;
117
- if (this.checkMaxStock(item, quantity || 0))
118
- throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
119
- const image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
120
- const { id, name, brand, slug, stock, price, weight, categories, sku } = item;
121
- const isGift = item.isGift || null;
122
- const pricePaid = this.getProductPrice({
123
- product: item,
124
- shop: checkout.shop || this.defaultShop,
125
- isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
126
- });
127
- return LineItem.toInstance({
128
- id,
129
- name,
130
- brand,
131
- slug,
132
- sku,
133
- stock,
134
- price,
135
- image,
136
- weight,
137
- quantity: (item.quantity || 0) + (quantity || 0),
138
- pricePaid,
139
- categories,
140
- isGift,
141
- });
142
- };
143
- this.getProductPrice = ({ product, shop, isSubscriber, }) => {
144
- const info = product.getInfoByShop(shop);
145
- if (product.isGift)
146
- return 0;
147
- return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
148
- };
149
- this.checkMaxStock = (item, quantity) => {
150
- var _a;
151
- const maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
152
- const currentItemAmount = item.quantity || 0;
153
- return currentItemAmount + quantity > maxStock;
154
- };
155
- }
156
- addItem(item, quantity = 1) {
157
- return this.checkoutService.getCheckout().pipe(map((checkout) => ({ checkout, lineItem: this.buildLineItem({ checkout, item, quantity: quantity || 1 }) })), concatMap(({ checkout, lineItem }) => this.updateLineItemInCart(lineItem, quantity || 1, checkout)), tap((cart) => this.cartSubject.next(cart)));
158
- }
159
- decreaseItem(item) {
160
- return this.checkoutService.getCheckout().pipe(map((checkout) => {
161
- var _a;
162
- const checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.sku === item.sku);
163
- if (!isNil(checkoutItem))
164
- checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
165
- return checkout;
166
- }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
167
- }
168
- getCart(checkout) {
169
- this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
170
- return this.cartSubject;
171
- }
172
- getDiscount(coupon) {
173
- switch (coupon.type) {
174
- case CouponTypes.FINANCIAL:
175
- return this.getFinancialDiscount(coupon);
176
- case CouponTypes.PRODUCT:
177
- return (subTotalPrice) => subTotalPrice;
178
- case CouponTypes.GIFTCARD:
179
- return this.getFinancialDiscount(coupon);
180
- case CouponTypes.VOUCHER:
181
- return (subTotalPrice) => subTotalPrice;
182
- }
183
- }
184
- getVariantPriceDiscount(item, shop) {
185
- return this.authService.getUser().pipe(concatMap((user) => iif(() => user.isSubscriber && !!item.getInfoByShop(shop).subscriberPrice, of(item.getInfoByShop(shop).subscriberPrice), of(item.getInfoByShop(shop).price))), catchError(() => of(item.getInfoByShop(shop).price)));
186
- }
187
- removeItem(item) {
188
- return this.checkoutService.getCheckout().pipe(map((checkout) => {
189
- const index = checkout.lineItems.findIndex((lineItem) => lineItem.sku === item.sku);
190
- if (index >= 0)
191
- checkout.lineItems.splice(index, 1);
192
- return checkout;
193
- }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
194
- }
195
- updateUserCart(user) {
196
- return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user })))), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: checkout.lineItems.map((item) => this.buildLineItem({ checkout, item })) })))), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
197
- }
198
- clearCart() {
199
- return this.checkoutService.getCheckout().pipe(map((checkout) => {
200
- this.checkoutService.clearCheckoutFromSession();
201
- return checkout;
202
- }), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
203
- }
204
- buildCartFromCheckout(checkoutData) {
205
- return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
206
- }
207
- getFinancialDiscount(coupon) {
208
- return (subTotalPrice) => {
209
- if (FinancialCoupon.isFinancialCoupon(coupon))
210
- switch (coupon.subtype) {
211
- case CouponSubtypes.ABSOLUTE:
212
- return subTotalPrice - coupon.discount * 100;
213
- case CouponSubtypes.PERCENTAGE:
214
- return subTotalPrice * (1 - coupon.discount / 100);
215
- }
216
- };
217
- }
218
- }
219
- CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
220
- CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: CartService });
221
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: CartService, decorators: [{
222
- type: Injectable
223
- }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i1$1.Shops, decorators: [{
224
- type: Inject,
225
- args: [DEFAULT_SHOP]
92
+ class CartService {
93
+ constructor(authService, checkoutService, defaultShop) {
94
+ this.authService = authService;
95
+ this.checkoutService = checkoutService;
96
+ this.defaultShop = defaultShop;
97
+ this.cartSubject = new Subject();
98
+ this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
99
+ var _a;
100
+ const items = [];
101
+ const index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map((checkoutItem) => checkoutItem.sku).indexOf(lineItem.sku);
102
+ if (index > -1) {
103
+ checkoutLoaded.lineItems[index].quantity += quantity;
104
+ checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
105
+ }
106
+ else
107
+ checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
108
+ return this.checkoutService
109
+ .updateCheckoutLineItems(checkoutLoaded)
110
+ .pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
111
+ }));
112
+ this.generateCartObject = (items) => {
113
+ const cart = {};
114
+ items === null || items === void 0 ? void 0 : items.forEach((item) => {
115
+ var _a;
116
+ 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) })));
117
+ });
118
+ return cart;
119
+ };
120
+ this.buildLineItem = ({ checkout, item, quantity, }) => {
121
+ var _a, _b, _c, _d, _e;
122
+ 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;
123
+ if (this.checkMaxStock(item, quantity || 0))
124
+ throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
125
+ const image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
126
+ const { id, name, brand, slug, stock, price, weight, categories, sku } = item;
127
+ const isGift = item.isGift || null;
128
+ const pricePaid = this.getProductPrice({
129
+ product: item,
130
+ shop: checkout.shop || this.defaultShop,
131
+ isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
132
+ });
133
+ return LineItem.toInstance({
134
+ id,
135
+ name,
136
+ brand,
137
+ slug,
138
+ sku,
139
+ stock,
140
+ price,
141
+ image,
142
+ weight,
143
+ quantity: (item.quantity || 0) + (quantity || 0),
144
+ pricePaid,
145
+ categories,
146
+ isGift,
147
+ });
148
+ };
149
+ this.getProductPrice = ({ product, shop, isSubscriber, }) => {
150
+ const info = product.getInfoByShop(shop);
151
+ if (product.isGift)
152
+ return 0;
153
+ return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
154
+ };
155
+ this.checkMaxStock = (item, quantity) => {
156
+ var _a;
157
+ const maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
158
+ const currentItemAmount = item.quantity || 0;
159
+ return currentItemAmount + quantity > maxStock;
160
+ };
161
+ }
162
+ addItem(item, quantity = 1) {
163
+ return this.checkoutService.getCheckout().pipe(map((checkout) => ({ checkout, lineItem: this.buildLineItem({ checkout, item, quantity: quantity || 1 }) })), concatMap(({ checkout, lineItem }) => this.updateLineItemInCart(lineItem, quantity || 1, checkout)), tap((cart) => this.cartSubject.next(cart)));
164
+ }
165
+ decreaseItem(item) {
166
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
167
+ var _a;
168
+ const checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.sku === item.sku);
169
+ if (!isNil(checkoutItem))
170
+ checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
171
+ return checkout;
172
+ }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
173
+ }
174
+ getCart(checkout) {
175
+ this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
176
+ return this.cartSubject;
177
+ }
178
+ getDiscount(coupon) {
179
+ switch (coupon.type) {
180
+ case CouponTypes.FINANCIAL:
181
+ return this.getFinancialDiscount(coupon);
182
+ case CouponTypes.PRODUCT:
183
+ return (subTotalPrice) => subTotalPrice;
184
+ case CouponTypes.GIFTCARD:
185
+ return this.getFinancialDiscount(coupon);
186
+ case CouponTypes.VOUCHER:
187
+ return (subTotalPrice) => subTotalPrice;
188
+ }
189
+ }
190
+ getVariantPriceDiscount(item, shop) {
191
+ return this.authService.getUser().pipe(concatMap((user) => iif(() => user.isSubscriber && !!item.getInfoByShop(shop).subscriberPrice, of(item.getInfoByShop(shop).subscriberPrice), of(item.getInfoByShop(shop).price))), catchError(() => of(item.getInfoByShop(shop).price)));
192
+ }
193
+ removeItem(item) {
194
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
195
+ const index = checkout.lineItems.findIndex((lineItem) => lineItem.sku === item.sku);
196
+ if (index >= 0)
197
+ checkout.lineItems.splice(index, 1);
198
+ return checkout;
199
+ }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
200
+ }
201
+ updateUserCart(user) {
202
+ return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user })))), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: checkout.lineItems.map((item) => this.buildLineItem({ checkout, item })) })))), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
203
+ }
204
+ clearCart() {
205
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
206
+ this.checkoutService.clearCheckoutFromSession();
207
+ return checkout;
208
+ }), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
209
+ }
210
+ buildCartFromCheckout(checkoutData) {
211
+ return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
212
+ }
213
+ getFinancialDiscount(coupon) {
214
+ return (subTotalPrice) => {
215
+ if (FinancialCoupon.isFinancialCoupon(coupon))
216
+ switch (coupon.subtype) {
217
+ case CouponSubtypes.ABSOLUTE:
218
+ return subTotalPrice - coupon.discount * 100;
219
+ case CouponSubtypes.PERCENTAGE:
220
+ return subTotalPrice * (1 - coupon.discount / 100);
221
+ }
222
+ };
223
+ }
224
+ }
225
+ CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
226
+ CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService });
227
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, decorators: [{
228
+ type: Injectable
229
+ }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i1$1.Shops, decorators: [{
230
+ type: Inject,
231
+ args: [DEFAULT_SHOP]
226
232
  }] }]; } });
227
233
 
228
- class OrderService {
229
- constructor(angularFirestore, orderRepository) {
230
- this.angularFirestore = angularFirestore;
231
- this.orderRepository = orderRepository;
232
- this.orderSubject = new Subject();
233
- }
234
- getOrder(id) {
235
- this.angularFirestore
236
- .doc(`${this.orderRepository.collectionName}/${id}`)
237
- .valueChanges()
238
- .pipe(map((doc) => Order.toInstance(doc)))
239
- .subscribe((doc) => this.orderSubject.next(doc));
240
- return this.orderSubject;
241
- }
242
- }
243
- OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: OrderService, deps: [{ token: i1$2.AngularFirestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
244
- OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: OrderService });
245
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: OrderService, decorators: [{
246
- type: Injectable
247
- }], ctorParameters: function () { return [{ type: i1$2.AngularFirestore }, { type: i1$1.OrderFirestoreRepository, decorators: [{
248
- type: Inject,
249
- args: ['OrderRepository']
234
+ class OrderService {
235
+ constructor(angularFirestore, orderRepository) {
236
+ this.angularFirestore = angularFirestore;
237
+ this.orderRepository = orderRepository;
238
+ this.orderSubject = new Subject();
239
+ }
240
+ getOrder(id) {
241
+ this.angularFirestore
242
+ .doc(`${this.orderRepository.collectionName}/${id}`)
243
+ .valueChanges()
244
+ .pipe(map((doc) => Order.toInstance(doc)))
245
+ .subscribe((doc) => this.orderSubject.next(doc));
246
+ return this.orderSubject;
247
+ }
248
+ }
249
+ 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 });
250
+ OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService });
251
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, decorators: [{
252
+ type: Injectable
253
+ }], ctorParameters: function () { return [{ type: i1$2.AngularFirestore }, { type: i1$1.OrderFirestoreRepository, decorators: [{
254
+ type: Inject,
255
+ args: ['OrderRepository']
250
256
  }] }]; } });
251
257
 
252
- class AngularFirebaseAuthModule {
253
- static initializeApp(options, nameOrConfig) {
254
- return {
255
- ngModule: AngularFirebaseAuthModule,
256
- providers: [
257
- { provide: FIREBASE_OPTIONS, useValue: options },
258
- { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
259
- ],
260
- };
261
- }
262
- }
263
- AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
264
- AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularFirebaseAuthModule, imports: [AngularFireModule] });
265
- AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
266
- {
267
- provide: 'Authentication',
268
- useFactory: (authenticationService, userRepository) => {
269
- return new Authentication(authenticationService, userRepository);
270
- },
271
- deps: ['AuthenticationService', 'UserRepository'],
272
- },
273
- {
274
- provide: 'AuthenticationService',
275
- useFactory: (angularFireAuth) => {
276
- return new AuthenticationFirebaseAuthService(angularFireAuth);
277
- },
278
- deps: [AngularFireAuth],
279
- },
280
- {
281
- provide: 'SignOut',
282
- useFactory: (authenticationService) => {
283
- return new SignOut(authenticationService);
284
- },
285
- deps: ['AuthenticationService'],
286
- },
287
- ], imports: [[AngularFireModule]] });
288
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
289
- type: NgModule,
290
- args: [{
291
- imports: [AngularFireModule],
292
- providers: [
293
- {
294
- provide: 'Authentication',
295
- useFactory: (authenticationService, userRepository) => {
296
- return new Authentication(authenticationService, userRepository);
297
- },
298
- deps: ['AuthenticationService', 'UserRepository'],
299
- },
300
- {
301
- provide: 'AuthenticationService',
302
- useFactory: (angularFireAuth) => {
303
- return new AuthenticationFirebaseAuthService(angularFireAuth);
304
- },
305
- deps: [AngularFireAuth],
306
- },
307
- {
308
- provide: 'SignOut',
309
- useFactory: (authenticationService) => {
310
- return new SignOut(authenticationService);
311
- },
312
- deps: ['AuthenticationService'],
313
- },
314
- ],
315
- }]
258
+ class AngularFirebaseAuthModule {
259
+ static initializeApp(options, nameOrConfig) {
260
+ return {
261
+ ngModule: AngularFirebaseAuthModule,
262
+ providers: [
263
+ { provide: FIREBASE_OPTIONS, useValue: options },
264
+ { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
265
+ ],
266
+ };
267
+ }
268
+ }
269
+ AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
270
+ AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, imports: [AngularFireModule] });
271
+ AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
272
+ {
273
+ provide: 'Authentication',
274
+ useFactory: (authenticationService, userRepository) => {
275
+ return new Authentication(authenticationService, userRepository);
276
+ },
277
+ deps: ['AuthenticationService', 'UserRepository'],
278
+ },
279
+ {
280
+ provide: 'AuthenticationService',
281
+ useFactory: (angularFireAuth) => {
282
+ return new AuthenticationFirebaseAuthService(angularFireAuth);
283
+ },
284
+ deps: [AngularFireAuth],
285
+ },
286
+ {
287
+ provide: 'SignOut',
288
+ useFactory: (authenticationService) => {
289
+ return new SignOut(authenticationService);
290
+ },
291
+ deps: ['AuthenticationService'],
292
+ },
293
+ ], imports: [[AngularFireModule]] });
294
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
295
+ type: NgModule,
296
+ args: [{
297
+ imports: [AngularFireModule],
298
+ providers: [
299
+ {
300
+ provide: 'Authentication',
301
+ useFactory: (authenticationService, userRepository) => {
302
+ return new Authentication(authenticationService, userRepository);
303
+ },
304
+ deps: ['AuthenticationService', 'UserRepository'],
305
+ },
306
+ {
307
+ provide: 'AuthenticationService',
308
+ useFactory: (angularFireAuth) => {
309
+ return new AuthenticationFirebaseAuthService(angularFireAuth);
310
+ },
311
+ deps: [AngularFireAuth],
312
+ },
313
+ {
314
+ provide: 'SignOut',
315
+ useFactory: (authenticationService) => {
316
+ return new SignOut(authenticationService);
317
+ },
318
+ deps: ['AuthenticationService'],
319
+ },
320
+ ],
321
+ }]
316
322
  }] });
317
323
 
318
- class AngularFirestoreModule {
319
- static initializeApp(options, nameOrConfig) {
320
- return {
321
- ngModule: AngularFirestoreModule,
322
- providers: [
323
- { provide: FIREBASE_OPTIONS, useValue: options },
324
- { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
325
- ],
326
- };
327
- }
328
- }
329
- AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
330
- AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularFirestoreModule, imports: [AngularFireModule] });
331
- AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularFirestoreModule, providers: [
332
- {
333
- provide: 'BeautyProfileRepository',
334
- useFactory: (firestore, userRepository) => {
335
- return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
336
- },
337
- deps: [AngularFirestore, 'UserRepository'],
338
- },
339
- {
340
- provide: 'Buy2WinRepository',
341
- useFactory: (firestore) => {
342
- return new Buy2WinFirestoreRepository(firestore.firestore);
343
- },
344
- deps: [AngularFirestore],
345
- },
346
- {
347
- provide: 'CategoryRepository',
348
- useFactory: (firestore) => {
349
- return new CategoryFirestoreRepository(firestore.firestore);
350
- },
351
- deps: [AngularFirestore],
352
- },
353
- {
354
- provide: 'CheckoutRepository',
355
- useFactory: (firestore) => {
356
- return new CheckoutFirestoreRepository(firestore.firestore);
357
- },
358
- deps: [AngularFirestore],
359
- },
360
- {
361
- provide: 'CheckoutSubscriptionRepository',
362
- useFactory: (firestore) => {
363
- return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
364
- },
365
- deps: [AngularFirestore],
366
- },
367
- {
368
- provide: 'CouponRepository',
369
- useFactory: (firestore) => {
370
- return new CouponFirestoreRepository(firestore.firestore);
371
- },
372
- deps: [AngularFirestore],
373
- },
374
- {
375
- provide: 'EditionRepository',
376
- useFactory: (firestore, subscriptionRepository) => {
377
- return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
378
- },
379
- deps: [AngularFirestore, 'SubscriptionRepository'],
380
- },
381
- {
382
- provide: 'HomeRepository',
383
- useFactory: (firestore) => {
384
- return new HomeFirestoreRepository(firestore.firestore);
385
- },
386
- deps: [AngularFirestore],
387
- },
388
- {
389
- provide: 'LeadRepository',
390
- useFactory: (firestore) => {
391
- return new LeadFirestoreRepository(firestore.firestore);
392
- },
393
- deps: [AngularFirestore],
394
- },
395
- {
396
- provide: 'LegacyOrderRepository',
397
- useFactory: (firestore) => {
398
- return new LegacyOrderFirestoreRepository(firestore.firestore);
399
- },
400
- deps: [AngularFirestore],
401
- },
402
- {
403
- provide: 'ShopMenuRepository',
404
- useFactory: (firestore) => {
405
- return new ShopMenuFirestoreRepository(firestore.firestore);
406
- },
407
- deps: [AngularFirestore],
408
- },
409
- {
410
- provide: 'OrderRepository',
411
- useFactory: (firestore) => {
412
- return new OrderFirestoreRepository(firestore.firestore);
413
- },
414
- deps: [AngularFirestore],
415
- },
416
- {
417
- provide: 'PaymentRepository',
418
- useFactory: (firestore) => {
419
- return new PaymentFirestoreRepository(firestore.firestore);
420
- },
421
- deps: [AngularFirestore],
422
- },
423
- {
424
- provide: 'ProductRepository',
425
- useFactory: (firestore) => {
426
- return new ProductFirestoreRepository(firestore.firestore);
427
- },
428
- deps: [AngularFirestore],
429
- },
430
- {
431
- provide: 'SubscriptionPaymentRepository',
432
- useFactory: (firestore, subscriptionRepository) => {
433
- return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
434
- },
435
- deps: [AngularFirestore, 'SubscriptionRepository'],
436
- },
437
- {
438
- provide: 'SubscriptionPlanRepository',
439
- useFactory: (firestore) => {
440
- return new SubscriptionPlanFirestoreRepository(firestore.firestore);
441
- },
442
- deps: [AngularFirestore],
443
- },
444
- {
445
- provide: 'SubscriptionRepository',
446
- useFactory: (firestore) => {
447
- return new SubscriptionFirestoreRepository(firestore.firestore);
448
- },
449
- deps: [AngularFirestore],
450
- },
451
- {
452
- provide: 'UserRepository',
453
- useFactory: (firestore) => {
454
- return new UserFirestoreRepository(firestore.firestore);
455
- },
456
- deps: [AngularFirestore],
457
- },
458
- {
459
- provide: 'UserAddressRepository',
460
- useFactory: (firestore, userRepository) => {
461
- return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
462
- },
463
- deps: [AngularFirestore, 'UserRepository'],
464
- },
465
- {
466
- provide: 'VariantRepository',
467
- useFactory: (firestore, productRepository) => {
468
- return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
469
- },
470
- deps: [AngularFirestore, 'ProductRepository'],
471
- },
472
- ], imports: [[AngularFireModule]] });
473
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularFirestoreModule, decorators: [{
474
- type: NgModule,
475
- args: [{
476
- imports: [AngularFireModule],
477
- providers: [
478
- {
479
- provide: 'BeautyProfileRepository',
480
- useFactory: (firestore, userRepository) => {
481
- return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
482
- },
483
- deps: [AngularFirestore, 'UserRepository'],
484
- },
485
- {
486
- provide: 'Buy2WinRepository',
487
- useFactory: (firestore) => {
488
- return new Buy2WinFirestoreRepository(firestore.firestore);
489
- },
490
- deps: [AngularFirestore],
491
- },
492
- {
493
- provide: 'CategoryRepository',
494
- useFactory: (firestore) => {
495
- return new CategoryFirestoreRepository(firestore.firestore);
496
- },
497
- deps: [AngularFirestore],
498
- },
499
- {
500
- provide: 'CheckoutRepository',
501
- useFactory: (firestore) => {
502
- return new CheckoutFirestoreRepository(firestore.firestore);
503
- },
504
- deps: [AngularFirestore],
505
- },
506
- {
507
- provide: 'CheckoutSubscriptionRepository',
508
- useFactory: (firestore) => {
509
- return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
510
- },
511
- deps: [AngularFirestore],
512
- },
513
- {
514
- provide: 'CouponRepository',
515
- useFactory: (firestore) => {
516
- return new CouponFirestoreRepository(firestore.firestore);
517
- },
518
- deps: [AngularFirestore],
519
- },
520
- {
521
- provide: 'EditionRepository',
522
- useFactory: (firestore, subscriptionRepository) => {
523
- return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
524
- },
525
- deps: [AngularFirestore, 'SubscriptionRepository'],
526
- },
527
- {
528
- provide: 'HomeRepository',
529
- useFactory: (firestore) => {
530
- return new HomeFirestoreRepository(firestore.firestore);
531
- },
532
- deps: [AngularFirestore],
533
- },
534
- {
535
- provide: 'LeadRepository',
536
- useFactory: (firestore) => {
537
- return new LeadFirestoreRepository(firestore.firestore);
538
- },
539
- deps: [AngularFirestore],
540
- },
541
- {
542
- provide: 'LegacyOrderRepository',
543
- useFactory: (firestore) => {
544
- return new LegacyOrderFirestoreRepository(firestore.firestore);
545
- },
546
- deps: [AngularFirestore],
547
- },
548
- {
549
- provide: 'ShopMenuRepository',
550
- useFactory: (firestore) => {
551
- return new ShopMenuFirestoreRepository(firestore.firestore);
552
- },
553
- deps: [AngularFirestore],
554
- },
555
- {
556
- provide: 'OrderRepository',
557
- useFactory: (firestore) => {
558
- return new OrderFirestoreRepository(firestore.firestore);
559
- },
560
- deps: [AngularFirestore],
561
- },
562
- {
563
- provide: 'PaymentRepository',
564
- useFactory: (firestore) => {
565
- return new PaymentFirestoreRepository(firestore.firestore);
566
- },
567
- deps: [AngularFirestore],
568
- },
569
- {
570
- provide: 'ProductRepository',
571
- useFactory: (firestore) => {
572
- return new ProductFirestoreRepository(firestore.firestore);
573
- },
574
- deps: [AngularFirestore],
575
- },
576
- {
577
- provide: 'SubscriptionPaymentRepository',
578
- useFactory: (firestore, subscriptionRepository) => {
579
- return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
580
- },
581
- deps: [AngularFirestore, 'SubscriptionRepository'],
582
- },
583
- {
584
- provide: 'SubscriptionPlanRepository',
585
- useFactory: (firestore) => {
586
- return new SubscriptionPlanFirestoreRepository(firestore.firestore);
587
- },
588
- deps: [AngularFirestore],
589
- },
590
- {
591
- provide: 'SubscriptionRepository',
592
- useFactory: (firestore) => {
593
- return new SubscriptionFirestoreRepository(firestore.firestore);
594
- },
595
- deps: [AngularFirestore],
596
- },
597
- {
598
- provide: 'UserRepository',
599
- useFactory: (firestore) => {
600
- return new UserFirestoreRepository(firestore.firestore);
601
- },
602
- deps: [AngularFirestore],
603
- },
604
- {
605
- provide: 'UserAddressRepository',
606
- useFactory: (firestore, userRepository) => {
607
- return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
608
- },
609
- deps: [AngularFirestore, 'UserRepository'],
610
- },
611
- {
612
- provide: 'VariantRepository',
613
- useFactory: (firestore, productRepository) => {
614
- return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
615
- },
616
- deps: [AngularFirestore, 'ProductRepository'],
617
- },
618
- ],
619
- }]
324
+ class AngularFirestoreModule {
325
+ static initializeApp(options, nameOrConfig) {
326
+ return {
327
+ ngModule: AngularFirestoreModule,
328
+ providers: [
329
+ { provide: FIREBASE_OPTIONS, useValue: options },
330
+ { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
331
+ ],
332
+ };
333
+ }
334
+ }
335
+ AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
336
+ AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, imports: [AngularFireModule] });
337
+ AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, providers: [
338
+ {
339
+ provide: 'BeautyProfileRepository',
340
+ useFactory: (firestore, userRepository) => {
341
+ return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
342
+ },
343
+ deps: [AngularFirestore, 'UserRepository'],
344
+ },
345
+ {
346
+ provide: 'Buy2WinRepository',
347
+ useFactory: (firestore) => {
348
+ return new Buy2WinFirestoreRepository(firestore.firestore);
349
+ },
350
+ deps: [AngularFirestore],
351
+ },
352
+ {
353
+ provide: 'CategoryRepository',
354
+ useFactory: (firestore) => {
355
+ return new CategoryFirestoreRepository(firestore.firestore);
356
+ },
357
+ deps: [AngularFirestore],
358
+ },
359
+ {
360
+ provide: 'CheckoutRepository',
361
+ useFactory: (firestore) => {
362
+ return new CheckoutFirestoreRepository(firestore.firestore);
363
+ },
364
+ deps: [AngularFirestore],
365
+ },
366
+ {
367
+ provide: 'CheckoutSubscriptionRepository',
368
+ useFactory: (firestore) => {
369
+ return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
370
+ },
371
+ deps: [AngularFirestore],
372
+ },
373
+ {
374
+ provide: 'CouponRepository',
375
+ useFactory: (firestore) => {
376
+ return new CouponFirestoreRepository(firestore.firestore);
377
+ },
378
+ deps: [AngularFirestore],
379
+ },
380
+ {
381
+ provide: 'EditionRepository',
382
+ useFactory: (firestore, subscriptionRepository) => {
383
+ return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
384
+ },
385
+ deps: [AngularFirestore, 'SubscriptionRepository'],
386
+ },
387
+ {
388
+ provide: 'HomeRepository',
389
+ useFactory: (firestore) => {
390
+ return new HomeFirestoreRepository(firestore.firestore);
391
+ },
392
+ deps: [AngularFirestore],
393
+ },
394
+ {
395
+ provide: 'LeadRepository',
396
+ useFactory: (firestore) => {
397
+ return new LeadFirestoreRepository(firestore.firestore);
398
+ },
399
+ deps: [AngularFirestore],
400
+ },
401
+ {
402
+ provide: 'LegacyOrderRepository',
403
+ useFactory: (firestore) => {
404
+ return new LegacyOrderFirestoreRepository(firestore.firestore);
405
+ },
406
+ deps: [AngularFirestore],
407
+ },
408
+ {
409
+ provide: 'ShopMenuRepository',
410
+ useFactory: (firestore) => {
411
+ return new ShopMenuFirestoreRepository(firestore.firestore);
412
+ },
413
+ deps: [AngularFirestore],
414
+ },
415
+ {
416
+ provide: 'OrderRepository',
417
+ useFactory: (firestore) => {
418
+ return new OrderFirestoreRepository(firestore.firestore);
419
+ },
420
+ deps: [AngularFirestore],
421
+ },
422
+ {
423
+ provide: 'PaymentRepository',
424
+ useFactory: (firestore) => {
425
+ return new PaymentFirestoreRepository(firestore.firestore);
426
+ },
427
+ deps: [AngularFirestore],
428
+ },
429
+ {
430
+ provide: 'ProductRepository',
431
+ useFactory: (firestore) => {
432
+ return new ProductFirestoreRepository(firestore.firestore);
433
+ },
434
+ deps: [AngularFirestore],
435
+ },
436
+ {
437
+ provide: 'SubscriptionPaymentRepository',
438
+ useFactory: (firestore, subscriptionRepository) => {
439
+ return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
440
+ },
441
+ deps: [AngularFirestore, 'SubscriptionRepository'],
442
+ },
443
+ {
444
+ provide: 'SubscriptionPlanRepository',
445
+ useFactory: (firestore) => {
446
+ return new SubscriptionPlanFirestoreRepository(firestore.firestore);
447
+ },
448
+ deps: [AngularFirestore],
449
+ },
450
+ {
451
+ provide: 'SubscriptionRepository',
452
+ useFactory: (firestore) => {
453
+ return new SubscriptionFirestoreRepository(firestore.firestore);
454
+ },
455
+ deps: [AngularFirestore],
456
+ },
457
+ {
458
+ provide: 'UserRepository',
459
+ useFactory: (firestore) => {
460
+ return new UserFirestoreRepository(firestore.firestore);
461
+ },
462
+ deps: [AngularFirestore],
463
+ },
464
+ {
465
+ provide: 'UserAddressRepository',
466
+ useFactory: (firestore, userRepository) => {
467
+ return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
468
+ },
469
+ deps: [AngularFirestore, 'UserRepository'],
470
+ },
471
+ {
472
+ provide: 'VariantRepository',
473
+ useFactory: (firestore, productRepository) => {
474
+ return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
475
+ },
476
+ deps: [AngularFirestore, 'ProductRepository'],
477
+ },
478
+ ], imports: [[AngularFireModule]] });
479
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, decorators: [{
480
+ type: NgModule,
481
+ args: [{
482
+ imports: [AngularFireModule],
483
+ providers: [
484
+ {
485
+ provide: 'BeautyProfileRepository',
486
+ useFactory: (firestore, userRepository) => {
487
+ return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
488
+ },
489
+ deps: [AngularFirestore, 'UserRepository'],
490
+ },
491
+ {
492
+ provide: 'Buy2WinRepository',
493
+ useFactory: (firestore) => {
494
+ return new Buy2WinFirestoreRepository(firestore.firestore);
495
+ },
496
+ deps: [AngularFirestore],
497
+ },
498
+ {
499
+ provide: 'CategoryRepository',
500
+ useFactory: (firestore) => {
501
+ return new CategoryFirestoreRepository(firestore.firestore);
502
+ },
503
+ deps: [AngularFirestore],
504
+ },
505
+ {
506
+ provide: 'CheckoutRepository',
507
+ useFactory: (firestore) => {
508
+ return new CheckoutFirestoreRepository(firestore.firestore);
509
+ },
510
+ deps: [AngularFirestore],
511
+ },
512
+ {
513
+ provide: 'CheckoutSubscriptionRepository',
514
+ useFactory: (firestore) => {
515
+ return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
516
+ },
517
+ deps: [AngularFirestore],
518
+ },
519
+ {
520
+ provide: 'CouponRepository',
521
+ useFactory: (firestore) => {
522
+ return new CouponFirestoreRepository(firestore.firestore);
523
+ },
524
+ deps: [AngularFirestore],
525
+ },
526
+ {
527
+ provide: 'EditionRepository',
528
+ useFactory: (firestore, subscriptionRepository) => {
529
+ return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
530
+ },
531
+ deps: [AngularFirestore, 'SubscriptionRepository'],
532
+ },
533
+ {
534
+ provide: 'HomeRepository',
535
+ useFactory: (firestore) => {
536
+ return new HomeFirestoreRepository(firestore.firestore);
537
+ },
538
+ deps: [AngularFirestore],
539
+ },
540
+ {
541
+ provide: 'LeadRepository',
542
+ useFactory: (firestore) => {
543
+ return new LeadFirestoreRepository(firestore.firestore);
544
+ },
545
+ deps: [AngularFirestore],
546
+ },
547
+ {
548
+ provide: 'LegacyOrderRepository',
549
+ useFactory: (firestore) => {
550
+ return new LegacyOrderFirestoreRepository(firestore.firestore);
551
+ },
552
+ deps: [AngularFirestore],
553
+ },
554
+ {
555
+ provide: 'ShopMenuRepository',
556
+ useFactory: (firestore) => {
557
+ return new ShopMenuFirestoreRepository(firestore.firestore);
558
+ },
559
+ deps: [AngularFirestore],
560
+ },
561
+ {
562
+ provide: 'OrderRepository',
563
+ useFactory: (firestore) => {
564
+ return new OrderFirestoreRepository(firestore.firestore);
565
+ },
566
+ deps: [AngularFirestore],
567
+ },
568
+ {
569
+ provide: 'PaymentRepository',
570
+ useFactory: (firestore) => {
571
+ return new PaymentFirestoreRepository(firestore.firestore);
572
+ },
573
+ deps: [AngularFirestore],
574
+ },
575
+ {
576
+ provide: 'ProductRepository',
577
+ useFactory: (firestore) => {
578
+ return new ProductFirestoreRepository(firestore.firestore);
579
+ },
580
+ deps: [AngularFirestore],
581
+ },
582
+ {
583
+ provide: 'SubscriptionPaymentRepository',
584
+ useFactory: (firestore, subscriptionRepository) => {
585
+ return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
586
+ },
587
+ deps: [AngularFirestore, 'SubscriptionRepository'],
588
+ },
589
+ {
590
+ provide: 'SubscriptionPlanRepository',
591
+ useFactory: (firestore) => {
592
+ return new SubscriptionPlanFirestoreRepository(firestore.firestore);
593
+ },
594
+ deps: [AngularFirestore],
595
+ },
596
+ {
597
+ provide: 'SubscriptionRepository',
598
+ useFactory: (firestore) => {
599
+ return new SubscriptionFirestoreRepository(firestore.firestore);
600
+ },
601
+ deps: [AngularFirestore],
602
+ },
603
+ {
604
+ provide: 'UserRepository',
605
+ useFactory: (firestore) => {
606
+ return new UserFirestoreRepository(firestore.firestore);
607
+ },
608
+ deps: [AngularFirestore],
609
+ },
610
+ {
611
+ provide: 'UserAddressRepository',
612
+ useFactory: (firestore, userRepository) => {
613
+ return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
614
+ },
615
+ deps: [AngularFirestore, 'UserRepository'],
616
+ },
617
+ {
618
+ provide: 'VariantRepository',
619
+ useFactory: (firestore, productRepository) => {
620
+ return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
621
+ },
622
+ deps: [AngularFirestore, 'ProductRepository'],
623
+ },
624
+ ],
625
+ }]
620
626
  }] });
621
627
 
622
- class AngularConnectModule {
623
- static initializeApp(defaultShop, options, nameOrConfig) {
624
- return {
625
- ngModule: AngularConnectModule,
626
- providers: [
627
- ...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
628
- ...(isNil(options) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options }]),
629
- ...(isNil(options) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
630
- ],
631
- };
632
- }
633
- }
634
- AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
635
- AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularConnectModule, imports: [AngularFireModule, AngularFirestoreModule] });
636
- AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularConnectModule, providers: [AuthService, CartService, CheckoutService, OrderService], imports: [[AngularFireModule, AngularFirestoreModule]] });
637
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularConnectModule, decorators: [{
638
- type: NgModule,
639
- args: [{
640
- imports: [AngularFireModule, AngularFirestoreModule],
641
- providers: [AuthService, CartService, CheckoutService, OrderService],
642
- }]
628
+ class AngularConnectModule {
629
+ static initializeApp(defaultShop, options, nameOrConfig) {
630
+ return {
631
+ ngModule: AngularConnectModule,
632
+ providers: [
633
+ ...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
634
+ ...(isNil(options) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options }]),
635
+ ...(isNil(options) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
636
+ ],
637
+ };
638
+ }
639
+ }
640
+ AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
641
+ AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, imports: [AngularFireModule, AngularFirestoreModule] });
642
+ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, providers: [AuthService, CartService, CheckoutService, OrderService], imports: [[AngularFireModule, AngularFirestoreModule]] });
643
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, decorators: [{
644
+ type: NgModule,
645
+ args: [{
646
+ imports: [AngularFireModule, AngularFirestoreModule],
647
+ providers: [AuthService, CartService, CheckoutService, OrderService],
648
+ }]
643
649
  }] });
644
650
 
645
- /**
646
- * Generated bundle index. Do not edit.
651
+ /**
652
+ * Generated bundle index. Do not edit.
647
653
  */
648
654
 
649
655
  export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AuthService, CartService, CheckoutService, OrderService };