@infrab4a/connect-angular 4.3.6-beta.4 → 4.3.6

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 (100) hide show
  1. package/angular-connect.module.d.ts +24 -24
  2. package/angular-elastic-search.module.d.ts +9 -9
  3. package/angular-firebase-auth.module.d.ts +11 -11
  4. package/angular-firestore.module.d.ts +18 -18
  5. package/angular-hasura-graphql.module.d.ts +16 -16
  6. package/consts/backend-url.const.d.ts +1 -1
  7. package/consts/category-structure.d.ts +1 -1
  8. package/consts/default-shop.const.d.ts +1 -1
  9. package/consts/es-config.const.d.ts +1 -1
  10. package/consts/firebase-const.d.ts +3 -3
  11. package/consts/hasura-options.const.d.ts +1 -1
  12. package/consts/index.d.ts +6 -6
  13. package/consts/storage-base-url.const.d.ts +1 -1
  14. package/esm2020/angular-connect.module.mjs +113 -113
  15. package/esm2020/angular-elastic-search.module.mjs +34 -34
  16. package/esm2020/angular-firebase-auth.module.mjs +115 -115
  17. package/esm2020/angular-firestore.module.mjs +502 -502
  18. package/esm2020/angular-hasura-graphql.module.mjs +265 -265
  19. package/esm2020/consts/backend-url.const.mjs +1 -1
  20. package/esm2020/consts/category-structure.mjs +2 -2
  21. package/esm2020/consts/default-shop.const.mjs +2 -2
  22. package/esm2020/consts/es-config.const.mjs +2 -2
  23. package/esm2020/consts/firebase-const.mjs +4 -4
  24. package/esm2020/consts/hasura-options.const.mjs +2 -2
  25. package/esm2020/consts/index.mjs +7 -7
  26. package/esm2020/consts/storage-base-url.const.mjs +2 -2
  27. package/esm2020/helpers/index.mjs +2 -2
  28. package/esm2020/helpers/mobile-operation-system-checker.helper.mjs +7 -7
  29. package/esm2020/index.mjs +6 -6
  30. package/esm2020/infrab4a-connect-angular.mjs +4 -4
  31. package/esm2020/services/auth.service.mjs +37 -37
  32. package/esm2020/services/cart.service.mjs +281 -282
  33. package/esm2020/services/catalog/adapters/category-structure.adapter.mjs +2 -2
  34. package/esm2020/services/catalog/adapters/index.mjs +4 -4
  35. package/esm2020/services/catalog/adapters/new-category-structure.adapter.mjs +41 -41
  36. package/esm2020/services/catalog/adapters/old-category-structure.adapter.mjs +23 -23
  37. package/esm2020/services/catalog/catalog.service.mjs +185 -185
  38. package/esm2020/services/catalog/category.service.mjs +51 -51
  39. package/esm2020/services/catalog/enums/index.mjs +2 -2
  40. package/esm2020/services/catalog/enums/product-sorts.enum.mjs +11 -11
  41. package/esm2020/services/catalog/index.mjs +8 -8
  42. package/esm2020/services/catalog/models/category-with-tree.model.mjs +10 -10
  43. package/esm2020/services/catalog/models/index.mjs +2 -2
  44. package/esm2020/services/catalog/types/index.mjs +2 -2
  45. package/esm2020/services/catalog/types/product-sort.type.mjs +2 -2
  46. package/esm2020/services/catalog/wishlist.service.mjs +115 -115
  47. package/esm2020/services/checkout-subscription.service.mjs +53 -53
  48. package/esm2020/services/checkout.service.mjs +71 -71
  49. package/esm2020/services/coupon.service.mjs +235 -235
  50. package/esm2020/services/helpers/index.mjs +2 -2
  51. package/esm2020/services/helpers/util.helper.mjs +18 -18
  52. package/esm2020/services/home-shop.service.mjs +125 -125
  53. package/esm2020/services/index.mjs +11 -11
  54. package/esm2020/services/order.service.mjs +30 -30
  55. package/esm2020/services/shipping.service.mjs +96 -96
  56. package/esm2020/services/types/index.mjs +3 -3
  57. package/esm2020/services/types/required-checkout-data.type.mjs +2 -2
  58. package/esm2020/services/types/required-checkout-subscription-data.type.mjs +2 -2
  59. package/esm2020/services/types/shipping-methods.type.mjs +2 -2
  60. package/esm2020/types/firebase-app-config.type.mjs +2 -2
  61. package/esm2020/types/index.mjs +2 -2
  62. package/fesm2015/infrab4a-connect-angular.mjs +2309 -2310
  63. package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
  64. package/fesm2020/infrab4a-connect-angular.mjs +2241 -2242
  65. package/fesm2020/infrab4a-connect-angular.mjs.map +1 -1
  66. package/helpers/index.d.ts +1 -1
  67. package/helpers/mobile-operation-system-checker.helper.d.ts +3 -3
  68. package/index.d.ts +5 -5
  69. package/package.json +1 -1
  70. package/services/auth.service.d.ts +18 -18
  71. package/services/cart.service.d.ts +42 -42
  72. package/services/catalog/adapters/category-structure.adapter.d.ts +4 -4
  73. package/services/catalog/adapters/index.d.ts +3 -3
  74. package/services/catalog/adapters/new-category-structure.adapter.d.ts +12 -12
  75. package/services/catalog/adapters/old-category-structure.adapter.d.ts +10 -10
  76. package/services/catalog/catalog.service.d.ts +86 -86
  77. package/services/catalog/category.service.d.ts +20 -20
  78. package/services/catalog/enums/index.d.ts +1 -1
  79. package/services/catalog/enums/product-sorts.enum.d.ts +9 -9
  80. package/services/catalog/index.d.ts +7 -7
  81. package/services/catalog/models/category-with-tree.model.d.ts +4 -4
  82. package/services/catalog/models/index.d.ts +1 -1
  83. package/services/catalog/types/index.d.ts +1 -1
  84. package/services/catalog/types/product-sort.type.d.ts +2 -2
  85. package/services/catalog/wishlist.service.d.ts +38 -38
  86. package/services/checkout-subscription.service.d.ts +18 -18
  87. package/services/checkout.service.d.ts +23 -23
  88. package/services/coupon.service.d.ts +29 -29
  89. package/services/helpers/index.d.ts +1 -1
  90. package/services/helpers/util.helper.d.ts +3 -3
  91. package/services/home-shop.service.d.ts +26 -26
  92. package/services/index.d.ts +10 -10
  93. package/services/order.service.d.ts +13 -13
  94. package/services/shipping.service.d.ts +19 -19
  95. package/services/types/index.d.ts +2 -2
  96. package/services/types/required-checkout-data.type.d.ts +2 -2
  97. package/services/types/required-checkout-subscription-data.type.d.ts +2 -2
  98. package/services/types/shipping-methods.type.d.ts +12 -12
  99. package/types/firebase-app-config.type.d.ts +1 -1
  100. package/types/index.d.ts +1 -1
@@ -20,34 +20,34 @@ import * as i1$3 from '@angular/common/http';
20
20
 
21
21
  const ES_CONFIG = 'ES_CONFIG';
22
22
 
23
- class AngularElasticSeachModule {
24
- static initializeApp(options) {
25
- return {
26
- ngModule: AngularElasticSeachModule,
27
- providers: [{ provide: ES_CONFIG, useValue: options }],
28
- };
29
- }
30
- }
31
- AngularElasticSeachModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
32
- AngularElasticSeachModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule });
33
- AngularElasticSeachModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, providers: [
34
- {
35
- provide: ProductsIndex,
36
- useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
37
- deps: [ES_CONFIG],
38
- },
39
- ] });
40
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, decorators: [{
41
- type: NgModule,
42
- args: [{
43
- providers: [
44
- {
45
- provide: ProductsIndex,
46
- useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
47
- deps: [ES_CONFIG],
48
- },
49
- ],
50
- }]
23
+ class AngularElasticSeachModule {
24
+ static initializeApp(options) {
25
+ return {
26
+ ngModule: AngularElasticSeachModule,
27
+ providers: [{ provide: ES_CONFIG, useValue: options }],
28
+ };
29
+ }
30
+ }
31
+ AngularElasticSeachModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
32
+ AngularElasticSeachModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule });
33
+ AngularElasticSeachModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, providers: [
34
+ {
35
+ provide: ProductsIndex,
36
+ useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
37
+ deps: [ES_CONFIG],
38
+ },
39
+ ] });
40
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, decorators: [{
41
+ type: NgModule,
42
+ args: [{
43
+ providers: [
44
+ {
45
+ provide: ProductsIndex,
46
+ useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
47
+ deps: [ES_CONFIG],
48
+ },
49
+ ],
50
+ }]
51
51
  }] });
52
52
 
53
53
  const BACKEND_URL = 'BACKEND_URL';
@@ -56,2336 +56,2335 @@ const CATEGORY_STRUCTURE = 'CATEGORY_STRUCTURE';
56
56
 
57
57
  const DEFAULT_SHOP = 'DEFAULT_SHOP';
58
58
 
59
- const FIREBASE_APP_NAME = new InjectionToken('firebaseAppName');
59
+ const FIREBASE_APP_NAME = new InjectionToken('firebaseAppName');
60
60
  const FIREBASE_OPTIONS = new InjectionToken('firebaseOptions');
61
61
 
62
62
  const HASURA_OPTIONS = 'HASURA_OPTIONS';
63
63
 
64
- class AngularFirebaseAuthModule {
65
- static initializeApp(options, nameOrConfig) {
66
- return {
67
- ngModule: AngularFirebaseAuthModule,
68
- providers: [
69
- { provide: FIREBASE_OPTIONS, useValue: options },
70
- { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
71
- ],
72
- };
73
- }
74
- }
75
- AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
76
- AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, imports: [i1.AuthModule] });
77
- AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
78
- {
79
- provide: 'Authentication',
80
- useFactory: (authenticationService, userRepository) => {
81
- return new Authentication(authenticationService, userRepository);
82
- },
83
- deps: ['AuthenticationService', 'UserRepository'],
84
- },
85
- {
86
- provide: 'AuthenticationService',
87
- useFactory: (angularFireAuth) => {
88
- return new AuthenticationFirebaseAuthService(angularFireAuth);
89
- },
90
- deps: [Auth],
91
- },
92
- {
93
- provide: 'Register',
94
- useFactory: (registerService, userRepository) => {
95
- return new Register(registerService, userRepository);
96
- },
97
- deps: ['RegisterService', 'UserRepository'],
98
- },
99
- {
100
- provide: 'RegisterService',
101
- useFactory: (angularFireAuth) => {
102
- return new RegisterFirebaseAuthService(angularFireAuth);
103
- },
104
- deps: [Auth],
105
- },
106
- {
107
- provide: 'SignOut',
108
- useFactory: (authenticationService) => {
109
- return new SignOut(authenticationService);
110
- },
111
- deps: ['AuthenticationService'],
112
- },
113
- {
114
- provide: 'RecoveryPassword',
115
- useFactory: (authenticationService) => {
116
- return new RecoveryPassword(authenticationService);
117
- },
118
- deps: ['AuthenticationService'],
119
- },
120
- ], imports: [provideAuth((injector) => getAuth(injector.get(FirebaseApp)))] });
121
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
122
- type: NgModule,
123
- args: [{
124
- imports: [provideAuth((injector) => getAuth(injector.get(FirebaseApp)))],
125
- providers: [
126
- {
127
- provide: 'Authentication',
128
- useFactory: (authenticationService, userRepository) => {
129
- return new Authentication(authenticationService, userRepository);
130
- },
131
- deps: ['AuthenticationService', 'UserRepository'],
132
- },
133
- {
134
- provide: 'AuthenticationService',
135
- useFactory: (angularFireAuth) => {
136
- return new AuthenticationFirebaseAuthService(angularFireAuth);
137
- },
138
- deps: [Auth],
139
- },
140
- {
141
- provide: 'Register',
142
- useFactory: (registerService, userRepository) => {
143
- return new Register(registerService, userRepository);
144
- },
145
- deps: ['RegisterService', 'UserRepository'],
146
- },
147
- {
148
- provide: 'RegisterService',
149
- useFactory: (angularFireAuth) => {
150
- return new RegisterFirebaseAuthService(angularFireAuth);
151
- },
152
- deps: [Auth],
153
- },
154
- {
155
- provide: 'SignOut',
156
- useFactory: (authenticationService) => {
157
- return new SignOut(authenticationService);
158
- },
159
- deps: ['AuthenticationService'],
160
- },
161
- {
162
- provide: 'RecoveryPassword',
163
- useFactory: (authenticationService) => {
164
- return new RecoveryPassword(authenticationService);
165
- },
166
- deps: ['AuthenticationService'],
167
- },
168
- ],
169
- }]
64
+ class AngularFirebaseAuthModule {
65
+ static initializeApp(options, nameOrConfig) {
66
+ return {
67
+ ngModule: AngularFirebaseAuthModule,
68
+ providers: [
69
+ { provide: FIREBASE_OPTIONS, useValue: options },
70
+ { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
71
+ ],
72
+ };
73
+ }
74
+ }
75
+ AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
76
+ AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, imports: [i1.AuthModule] });
77
+ AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
78
+ {
79
+ provide: 'Authentication',
80
+ useFactory: (authenticationService, userRepository) => {
81
+ return new Authentication(authenticationService, userRepository);
82
+ },
83
+ deps: ['AuthenticationService', 'UserRepository'],
84
+ },
85
+ {
86
+ provide: 'AuthenticationService',
87
+ useFactory: (angularFireAuth) => {
88
+ return new AuthenticationFirebaseAuthService(angularFireAuth);
89
+ },
90
+ deps: [Auth],
91
+ },
92
+ {
93
+ provide: 'Register',
94
+ useFactory: (registerService, userRepository) => {
95
+ return new Register(registerService, userRepository);
96
+ },
97
+ deps: ['RegisterService', 'UserRepository'],
98
+ },
99
+ {
100
+ provide: 'RegisterService',
101
+ useFactory: (angularFireAuth) => {
102
+ return new RegisterFirebaseAuthService(angularFireAuth);
103
+ },
104
+ deps: [Auth],
105
+ },
106
+ {
107
+ provide: 'SignOut',
108
+ useFactory: (authenticationService) => {
109
+ return new SignOut(authenticationService);
110
+ },
111
+ deps: ['AuthenticationService'],
112
+ },
113
+ {
114
+ provide: 'RecoveryPassword',
115
+ useFactory: (authenticationService) => {
116
+ return new RecoveryPassword(authenticationService);
117
+ },
118
+ deps: ['AuthenticationService'],
119
+ },
120
+ ], imports: [provideAuth((injector) => getAuth(injector.get(FirebaseApp)))] });
121
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
122
+ type: NgModule,
123
+ args: [{
124
+ imports: [provideAuth((injector) => getAuth(injector.get(FirebaseApp)))],
125
+ providers: [
126
+ {
127
+ provide: 'Authentication',
128
+ useFactory: (authenticationService, userRepository) => {
129
+ return new Authentication(authenticationService, userRepository);
130
+ },
131
+ deps: ['AuthenticationService', 'UserRepository'],
132
+ },
133
+ {
134
+ provide: 'AuthenticationService',
135
+ useFactory: (angularFireAuth) => {
136
+ return new AuthenticationFirebaseAuthService(angularFireAuth);
137
+ },
138
+ deps: [Auth],
139
+ },
140
+ {
141
+ provide: 'Register',
142
+ useFactory: (registerService, userRepository) => {
143
+ return new Register(registerService, userRepository);
144
+ },
145
+ deps: ['RegisterService', 'UserRepository'],
146
+ },
147
+ {
148
+ provide: 'RegisterService',
149
+ useFactory: (angularFireAuth) => {
150
+ return new RegisterFirebaseAuthService(angularFireAuth);
151
+ },
152
+ deps: [Auth],
153
+ },
154
+ {
155
+ provide: 'SignOut',
156
+ useFactory: (authenticationService) => {
157
+ return new SignOut(authenticationService);
158
+ },
159
+ deps: ['AuthenticationService'],
160
+ },
161
+ {
162
+ provide: 'RecoveryPassword',
163
+ useFactory: (authenticationService) => {
164
+ return new RecoveryPassword(authenticationService);
165
+ },
166
+ deps: ['AuthenticationService'],
167
+ },
168
+ ],
169
+ }]
170
170
  }] });
171
171
 
172
172
  const STORAGE_BASE_URL = 'STORAGE_BASE_URL';
173
173
 
174
- class MobileOperationSystemCheckerHelper {
175
- static isAppleDevice() {
176
- var _a, _b;
177
- return (['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator === null || navigator === void 0 ? void 0 : navigator.platform) ||
178
- (((_b = (_a = navigator === null || navigator === void 0 ? void 0 : navigator.userAgent) === null || _a === void 0 ? void 0 : _a.includes) === null || _b === void 0 ? void 0 : _b.call(_a, 'Mac')) && 'ontouchend' in (document || {})));
179
- }
174
+ class MobileOperationSystemCheckerHelper {
175
+ static isAppleDevice() {
176
+ var _a, _b;
177
+ return (['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator === null || navigator === void 0 ? void 0 : navigator.platform) ||
178
+ (((_b = (_a = navigator === null || navigator === void 0 ? void 0 : navigator.userAgent) === null || _a === void 0 ? void 0 : _a.includes) === null || _b === void 0 ? void 0 : _b.call(_a, 'Mac')) && 'ontouchend' in (document || {})));
179
+ }
180
180
  }
181
181
 
182
- class AngularFirestoreModule {
183
- static initializeApp(options, nameOrConfig) {
184
- return {
185
- ngModule: AngularFirestoreModule,
186
- providers: [
187
- { provide: FIREBASE_OPTIONS, useValue: options.firebase },
188
- { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
189
- { provide: ES_CONFIG, useValue: options.elasticSearch },
190
- ],
191
- };
192
- }
193
- }
194
- AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
195
- AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, imports: [AngularElasticSeachModule, i1$1.FirestoreModule, i2.StorageModule] });
196
- AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, providers: [
197
- {
198
- provide: 'FirestoreOptions',
199
- useFactory: (firestore, platformId) => ({
200
- firestore,
201
- interceptors: {
202
- request: (request) => {
203
- if (isPlatformBrowser(platformId))
204
- return request;
205
- const interval = setInterval(() => { }, 100);
206
- request.interval = interval;
207
- return request;
208
- },
209
- response: (response, request) => {
210
- if (isPlatformBrowser(platformId))
211
- return response;
212
- clearInterval(request.interval);
213
- return response;
214
- },
215
- },
216
- }),
217
- deps: [Firestore, PLATFORM_ID],
218
- },
219
- {
220
- provide: 'BeautyProfileRepository',
221
- useFactory: (config, userRepository) => {
222
- return new UserBeautyProfileFirestoreRepository(config, userRepository);
223
- },
224
- deps: ['FirestoreOptions', 'UserRepository'],
225
- },
226
- {
227
- provide: 'Buy2WinRepository',
228
- useFactory: (options) => {
229
- return new Buy2WinFirestoreRepository(options);
230
- },
231
- deps: ['FirestoreOptions'],
232
- },
233
- {
234
- provide: CategoryFirestoreRepository,
235
- useFactory: (options) => {
236
- return new CategoryFirestoreRepository(options);
237
- },
238
- deps: ['FirestoreOptions'],
239
- },
240
- {
241
- provide: 'CheckoutRepository',
242
- useFactory: (options) => {
243
- return new CheckoutFirestoreRepository(options);
244
- },
245
- deps: ['FirestoreOptions'],
246
- },
247
- {
248
- provide: 'CheckoutSubscriptionRepository',
249
- useFactory: (options) => {
250
- return new CheckoutSubscriptionFirestoreRepository(options);
251
- },
252
- deps: ['FirestoreOptions'],
253
- },
254
- {
255
- provide: 'CouponRepository',
256
- useFactory: (options) => {
257
- return new CouponFirestoreRepository(options);
258
- },
259
- deps: ['FirestoreOptions'],
260
- },
261
- {
262
- provide: 'CampaignHashtagRepository',
263
- useFactory: (options) => {
264
- return new CampaignHashtagFirestoreRepository(options);
265
- },
266
- deps: ['FirestoreOptions'],
267
- },
268
- {
269
- provide: 'CampaignDashboardRepository',
270
- useFactory: (options) => {
271
- return new CampaignDashboardFirestoreRepository(options);
272
- },
273
- deps: ['FirestoreOptions'],
274
- },
275
- {
276
- provide: 'EditionRepository',
277
- useFactory: (options, subscriptionRepository) => {
278
- return new SubscriptionEditionFirestoreRepository(options, subscriptionRepository);
279
- },
280
- deps: ['FirestoreOptions', 'SubscriptionRepository'],
281
- },
282
- {
283
- provide: 'HomeRepository',
284
- useFactory: (options) => {
285
- return new HomeFirestoreRepository(options);
286
- },
287
- deps: ['FirestoreOptions'],
288
- },
289
- {
290
- provide: 'LeadRepository',
291
- useFactory: (options) => {
292
- return new LeadFirestoreRepository(options);
293
- },
294
- deps: ['FirestoreOptions'],
295
- },
296
- {
297
- provide: 'LegacyOrderRepository',
298
- useFactory: (options) => {
299
- return new LegacyOrderFirestoreRepository(options);
300
- },
301
- deps: ['FirestoreOptions'],
302
- },
303
- {
304
- provide: 'ShopMenuRepository',
305
- useFactory: (options) => {
306
- return new ShopMenuFirestoreRepository(options);
307
- },
308
- deps: ['FirestoreOptions'],
309
- },
310
- {
311
- provide: 'OrderRepository',
312
- useFactory: (options) => {
313
- return new OrderFirestoreRepository(options);
314
- },
315
- deps: ['FirestoreOptions'],
316
- },
317
- {
318
- provide: 'PaymentRepository',
319
- useFactory: (options) => {
320
- return new PaymentFirestoreRepository(options);
321
- },
322
- deps: ['FirestoreOptions'],
323
- },
324
- {
325
- provide: ProductFirestoreRepository,
326
- useFactory: (options) => {
327
- return new ProductFirestoreRepository(options);
328
- },
329
- deps: ['FirestoreOptions'],
330
- },
331
- {
332
- provide: 'ShopSettingsRepository',
333
- useFactory: (options) => {
334
- return new ShopSettingsFirestoreRepository(options);
335
- },
336
- deps: ['FirestoreOptions'],
337
- },
338
- {
339
- provide: 'SubscriptionPaymentRepository',
340
- useFactory: (options, subscriptionRepository) => {
341
- return new SubscriptionPaymentFirestoreRepository(options, subscriptionRepository);
342
- },
343
- deps: ['FirestoreOptions', 'SubscriptionRepository'],
344
- },
345
- {
346
- provide: 'SubscriptionPlanRepository',
347
- useFactory: (options) => {
348
- return new SubscriptionPlanFirestoreRepository(options);
349
- },
350
- deps: ['FirestoreOptions'],
351
- },
352
- {
353
- provide: 'SubscriptionProductRepository',
354
- useFactory: (options) => {
355
- return new SubscriptionProductFirestoreRepository(options);
356
- },
357
- deps: ['FirestoreOptions'],
358
- },
359
- {
360
- provide: 'SubscriptionRepository',
361
- useFactory: (options) => {
362
- return new SubscriptionFirestoreRepository(options);
363
- },
364
- deps: ['FirestoreOptions'],
365
- },
366
- {
367
- provide: 'UserRepository',
368
- useFactory: (options) => {
369
- return new UserFirestoreRepository(options);
370
- },
371
- deps: ['FirestoreOptions'],
372
- },
373
- {
374
- provide: 'UserAddressRepository',
375
- useFactory: (options, userRepository) => {
376
- return new UserAddressFirestoreRepository(options, userRepository);
377
- },
378
- deps: ['FirestoreOptions', 'UserRepository'],
379
- },
380
- {
381
- provide: 'UserPaymentMethodRepository',
382
- useFactory: (options, userRepository) => {
383
- return new UserPaymentMethodFirestoreRepository(options, userRepository);
384
- },
385
- deps: ['FirestoreOptions', 'UserRepository'],
386
- },
387
- {
388
- provide: 'SubscriptionMaterializationRepository',
389
- useFactory: (options) => {
390
- return new SubscriptionMaterializationFirestoreRepository(options);
391
- },
392
- deps: ['FirestoreOptions'],
393
- },
394
- {
395
- provide: 'SubscriptionSummaryRepository',
396
- useFactory: (options) => {
397
- return new SubscriptionSummaryFirestoreRepository(options);
398
- },
399
- deps: ['FirestoreOptions'],
400
- },
401
- {
402
- provide: ProductVariantFirestoreRepository,
403
- useFactory: (options, productRepository) => {
404
- return new ProductVariantFirestoreRepository(options, productRepository);
405
- },
406
- deps: ['FirestoreOptions', ProductFirestoreRepository],
407
- },
408
- {
409
- provide: 'FileUploaderService',
410
- useFactory: (storage, baseUrl) => {
411
- return new FirebaseFileUploaderService(storage, baseUrl);
412
- },
413
- deps: [Storage, STORAGE_BASE_URL],
414
- },
415
- ], imports: [AngularElasticSeachModule,
416
- provideFirestore((injector) => {
417
- const platformId = injector.get(PLATFORM_ID);
418
- if (isPlatformServer(platformId))
419
- return getFirestore(injector.get(FirebaseApp));
420
- if (!MobileOperationSystemCheckerHelper.isAppleDevice())
421
- return getFirestore(injector.get(FirebaseApp));
422
- const firestore = initializeFirestore(injector.get(FirebaseApp), {
423
- experimentalForceLongPolling: true,
424
- localCache: memoryLocalCache(),
425
- });
426
- return firestore;
427
- }),
428
- provideStorage(() => getStorage())] });
429
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, decorators: [{
430
- type: NgModule,
431
- args: [{
432
- imports: [
433
- AngularElasticSeachModule,
434
- provideFirestore((injector) => {
435
- const platformId = injector.get(PLATFORM_ID);
436
- if (isPlatformServer(platformId))
437
- return getFirestore(injector.get(FirebaseApp));
438
- if (!MobileOperationSystemCheckerHelper.isAppleDevice())
439
- return getFirestore(injector.get(FirebaseApp));
440
- const firestore = initializeFirestore(injector.get(FirebaseApp), {
441
- experimentalForceLongPolling: true,
442
- localCache: memoryLocalCache(),
443
- });
444
- return firestore;
445
- }),
446
- provideStorage(() => getStorage()),
447
- ],
448
- providers: [
449
- {
450
- provide: 'FirestoreOptions',
451
- useFactory: (firestore, platformId) => ({
452
- firestore,
453
- interceptors: {
454
- request: (request) => {
455
- if (isPlatformBrowser(platformId))
456
- return request;
457
- const interval = setInterval(() => { }, 100);
458
- request.interval = interval;
459
- return request;
460
- },
461
- response: (response, request) => {
462
- if (isPlatformBrowser(platformId))
463
- return response;
464
- clearInterval(request.interval);
465
- return response;
466
- },
467
- },
468
- }),
469
- deps: [Firestore, PLATFORM_ID],
470
- },
471
- {
472
- provide: 'BeautyProfileRepository',
473
- useFactory: (config, userRepository) => {
474
- return new UserBeautyProfileFirestoreRepository(config, userRepository);
475
- },
476
- deps: ['FirestoreOptions', 'UserRepository'],
477
- },
478
- {
479
- provide: 'Buy2WinRepository',
480
- useFactory: (options) => {
481
- return new Buy2WinFirestoreRepository(options);
482
- },
483
- deps: ['FirestoreOptions'],
484
- },
485
- {
486
- provide: CategoryFirestoreRepository,
487
- useFactory: (options) => {
488
- return new CategoryFirestoreRepository(options);
489
- },
490
- deps: ['FirestoreOptions'],
491
- },
492
- {
493
- provide: 'CheckoutRepository',
494
- useFactory: (options) => {
495
- return new CheckoutFirestoreRepository(options);
496
- },
497
- deps: ['FirestoreOptions'],
498
- },
499
- {
500
- provide: 'CheckoutSubscriptionRepository',
501
- useFactory: (options) => {
502
- return new CheckoutSubscriptionFirestoreRepository(options);
503
- },
504
- deps: ['FirestoreOptions'],
505
- },
506
- {
507
- provide: 'CouponRepository',
508
- useFactory: (options) => {
509
- return new CouponFirestoreRepository(options);
510
- },
511
- deps: ['FirestoreOptions'],
512
- },
513
- {
514
- provide: 'CampaignHashtagRepository',
515
- useFactory: (options) => {
516
- return new CampaignHashtagFirestoreRepository(options);
517
- },
518
- deps: ['FirestoreOptions'],
519
- },
520
- {
521
- provide: 'CampaignDashboardRepository',
522
- useFactory: (options) => {
523
- return new CampaignDashboardFirestoreRepository(options);
524
- },
525
- deps: ['FirestoreOptions'],
526
- },
527
- {
528
- provide: 'EditionRepository',
529
- useFactory: (options, subscriptionRepository) => {
530
- return new SubscriptionEditionFirestoreRepository(options, subscriptionRepository);
531
- },
532
- deps: ['FirestoreOptions', 'SubscriptionRepository'],
533
- },
534
- {
535
- provide: 'HomeRepository',
536
- useFactory: (options) => {
537
- return new HomeFirestoreRepository(options);
538
- },
539
- deps: ['FirestoreOptions'],
540
- },
541
- {
542
- provide: 'LeadRepository',
543
- useFactory: (options) => {
544
- return new LeadFirestoreRepository(options);
545
- },
546
- deps: ['FirestoreOptions'],
547
- },
548
- {
549
- provide: 'LegacyOrderRepository',
550
- useFactory: (options) => {
551
- return new LegacyOrderFirestoreRepository(options);
552
- },
553
- deps: ['FirestoreOptions'],
554
- },
555
- {
556
- provide: 'ShopMenuRepository',
557
- useFactory: (options) => {
558
- return new ShopMenuFirestoreRepository(options);
559
- },
560
- deps: ['FirestoreOptions'],
561
- },
562
- {
563
- provide: 'OrderRepository',
564
- useFactory: (options) => {
565
- return new OrderFirestoreRepository(options);
566
- },
567
- deps: ['FirestoreOptions'],
568
- },
569
- {
570
- provide: 'PaymentRepository',
571
- useFactory: (options) => {
572
- return new PaymentFirestoreRepository(options);
573
- },
574
- deps: ['FirestoreOptions'],
575
- },
576
- {
577
- provide: ProductFirestoreRepository,
578
- useFactory: (options) => {
579
- return new ProductFirestoreRepository(options);
580
- },
581
- deps: ['FirestoreOptions'],
582
- },
583
- {
584
- provide: 'ShopSettingsRepository',
585
- useFactory: (options) => {
586
- return new ShopSettingsFirestoreRepository(options);
587
- },
588
- deps: ['FirestoreOptions'],
589
- },
590
- {
591
- provide: 'SubscriptionPaymentRepository',
592
- useFactory: (options, subscriptionRepository) => {
593
- return new SubscriptionPaymentFirestoreRepository(options, subscriptionRepository);
594
- },
595
- deps: ['FirestoreOptions', 'SubscriptionRepository'],
596
- },
597
- {
598
- provide: 'SubscriptionPlanRepository',
599
- useFactory: (options) => {
600
- return new SubscriptionPlanFirestoreRepository(options);
601
- },
602
- deps: ['FirestoreOptions'],
603
- },
604
- {
605
- provide: 'SubscriptionProductRepository',
606
- useFactory: (options) => {
607
- return new SubscriptionProductFirestoreRepository(options);
608
- },
609
- deps: ['FirestoreOptions'],
610
- },
611
- {
612
- provide: 'SubscriptionRepository',
613
- useFactory: (options) => {
614
- return new SubscriptionFirestoreRepository(options);
615
- },
616
- deps: ['FirestoreOptions'],
617
- },
618
- {
619
- provide: 'UserRepository',
620
- useFactory: (options) => {
621
- return new UserFirestoreRepository(options);
622
- },
623
- deps: ['FirestoreOptions'],
624
- },
625
- {
626
- provide: 'UserAddressRepository',
627
- useFactory: (options, userRepository) => {
628
- return new UserAddressFirestoreRepository(options, userRepository);
629
- },
630
- deps: ['FirestoreOptions', 'UserRepository'],
631
- },
632
- {
633
- provide: 'UserPaymentMethodRepository',
634
- useFactory: (options, userRepository) => {
635
- return new UserPaymentMethodFirestoreRepository(options, userRepository);
636
- },
637
- deps: ['FirestoreOptions', 'UserRepository'],
638
- },
639
- {
640
- provide: 'SubscriptionMaterializationRepository',
641
- useFactory: (options) => {
642
- return new SubscriptionMaterializationFirestoreRepository(options);
643
- },
644
- deps: ['FirestoreOptions'],
645
- },
646
- {
647
- provide: 'SubscriptionSummaryRepository',
648
- useFactory: (options) => {
649
- return new SubscriptionSummaryFirestoreRepository(options);
650
- },
651
- deps: ['FirestoreOptions'],
652
- },
653
- {
654
- provide: ProductVariantFirestoreRepository,
655
- useFactory: (options, productRepository) => {
656
- return new ProductVariantFirestoreRepository(options, productRepository);
657
- },
658
- deps: ['FirestoreOptions', ProductFirestoreRepository],
659
- },
660
- {
661
- provide: 'FileUploaderService',
662
- useFactory: (storage, baseUrl) => {
663
- return new FirebaseFileUploaderService(storage, baseUrl);
664
- },
665
- deps: [Storage, STORAGE_BASE_URL],
666
- },
667
- ],
668
- }]
182
+ class AngularFirestoreModule {
183
+ static initializeApp(options, nameOrConfig) {
184
+ return {
185
+ ngModule: AngularFirestoreModule,
186
+ providers: [
187
+ { provide: FIREBASE_OPTIONS, useValue: options.firebase },
188
+ { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
189
+ { provide: ES_CONFIG, useValue: options.elasticSearch },
190
+ ],
191
+ };
192
+ }
193
+ }
194
+ AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
195
+ AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, imports: [AngularElasticSeachModule, i1$1.FirestoreModule, i2.StorageModule] });
196
+ AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, providers: [
197
+ {
198
+ provide: 'FirestoreOptions',
199
+ useFactory: (firestore, platformId) => ({
200
+ firestore,
201
+ interceptors: {
202
+ request: (request) => {
203
+ if (isPlatformBrowser(platformId))
204
+ return request;
205
+ const interval = setInterval(() => { }, 100);
206
+ request.interval = interval;
207
+ return request;
208
+ },
209
+ response: (response, request) => {
210
+ if (isPlatformBrowser(platformId))
211
+ return response;
212
+ clearInterval(request.interval);
213
+ return response;
214
+ },
215
+ },
216
+ }),
217
+ deps: [Firestore, PLATFORM_ID],
218
+ },
219
+ {
220
+ provide: 'BeautyProfileRepository',
221
+ useFactory: (config, userRepository) => {
222
+ return new UserBeautyProfileFirestoreRepository(config, userRepository);
223
+ },
224
+ deps: ['FirestoreOptions', 'UserRepository'],
225
+ },
226
+ {
227
+ provide: 'Buy2WinRepository',
228
+ useFactory: (options) => {
229
+ return new Buy2WinFirestoreRepository(options);
230
+ },
231
+ deps: ['FirestoreOptions'],
232
+ },
233
+ {
234
+ provide: CategoryFirestoreRepository,
235
+ useFactory: (options) => {
236
+ return new CategoryFirestoreRepository(options);
237
+ },
238
+ deps: ['FirestoreOptions'],
239
+ },
240
+ {
241
+ provide: 'CheckoutRepository',
242
+ useFactory: (options) => {
243
+ return new CheckoutFirestoreRepository(options);
244
+ },
245
+ deps: ['FirestoreOptions'],
246
+ },
247
+ {
248
+ provide: 'CheckoutSubscriptionRepository',
249
+ useFactory: (options) => {
250
+ return new CheckoutSubscriptionFirestoreRepository(options);
251
+ },
252
+ deps: ['FirestoreOptions'],
253
+ },
254
+ {
255
+ provide: 'CouponRepository',
256
+ useFactory: (options) => {
257
+ return new CouponFirestoreRepository(options);
258
+ },
259
+ deps: ['FirestoreOptions'],
260
+ },
261
+ {
262
+ provide: 'CampaignHashtagRepository',
263
+ useFactory: (options) => {
264
+ return new CampaignHashtagFirestoreRepository(options);
265
+ },
266
+ deps: ['FirestoreOptions'],
267
+ },
268
+ {
269
+ provide: 'CampaignDashboardRepository',
270
+ useFactory: (options) => {
271
+ return new CampaignDashboardFirestoreRepository(options);
272
+ },
273
+ deps: ['FirestoreOptions'],
274
+ },
275
+ {
276
+ provide: 'EditionRepository',
277
+ useFactory: (options, subscriptionRepository) => {
278
+ return new SubscriptionEditionFirestoreRepository(options, subscriptionRepository);
279
+ },
280
+ deps: ['FirestoreOptions', 'SubscriptionRepository'],
281
+ },
282
+ {
283
+ provide: 'HomeRepository',
284
+ useFactory: (options) => {
285
+ return new HomeFirestoreRepository(options);
286
+ },
287
+ deps: ['FirestoreOptions'],
288
+ },
289
+ {
290
+ provide: 'LeadRepository',
291
+ useFactory: (options) => {
292
+ return new LeadFirestoreRepository(options);
293
+ },
294
+ deps: ['FirestoreOptions'],
295
+ },
296
+ {
297
+ provide: 'LegacyOrderRepository',
298
+ useFactory: (options) => {
299
+ return new LegacyOrderFirestoreRepository(options);
300
+ },
301
+ deps: ['FirestoreOptions'],
302
+ },
303
+ {
304
+ provide: 'ShopMenuRepository',
305
+ useFactory: (options) => {
306
+ return new ShopMenuFirestoreRepository(options);
307
+ },
308
+ deps: ['FirestoreOptions'],
309
+ },
310
+ {
311
+ provide: 'OrderRepository',
312
+ useFactory: (options) => {
313
+ return new OrderFirestoreRepository(options);
314
+ },
315
+ deps: ['FirestoreOptions'],
316
+ },
317
+ {
318
+ provide: 'PaymentRepository',
319
+ useFactory: (options) => {
320
+ return new PaymentFirestoreRepository(options);
321
+ },
322
+ deps: ['FirestoreOptions'],
323
+ },
324
+ {
325
+ provide: ProductFirestoreRepository,
326
+ useFactory: (options) => {
327
+ return new ProductFirestoreRepository(options);
328
+ },
329
+ deps: ['FirestoreOptions'],
330
+ },
331
+ {
332
+ provide: 'ShopSettingsRepository',
333
+ useFactory: (options) => {
334
+ return new ShopSettingsFirestoreRepository(options);
335
+ },
336
+ deps: ['FirestoreOptions'],
337
+ },
338
+ {
339
+ provide: 'SubscriptionPaymentRepository',
340
+ useFactory: (options, subscriptionRepository) => {
341
+ return new SubscriptionPaymentFirestoreRepository(options, subscriptionRepository);
342
+ },
343
+ deps: ['FirestoreOptions', 'SubscriptionRepository'],
344
+ },
345
+ {
346
+ provide: 'SubscriptionPlanRepository',
347
+ useFactory: (options) => {
348
+ return new SubscriptionPlanFirestoreRepository(options);
349
+ },
350
+ deps: ['FirestoreOptions'],
351
+ },
352
+ {
353
+ provide: 'SubscriptionProductRepository',
354
+ useFactory: (options) => {
355
+ return new SubscriptionProductFirestoreRepository(options);
356
+ },
357
+ deps: ['FirestoreOptions'],
358
+ },
359
+ {
360
+ provide: 'SubscriptionRepository',
361
+ useFactory: (options) => {
362
+ return new SubscriptionFirestoreRepository(options);
363
+ },
364
+ deps: ['FirestoreOptions'],
365
+ },
366
+ {
367
+ provide: 'UserRepository',
368
+ useFactory: (options) => {
369
+ return new UserFirestoreRepository(options);
370
+ },
371
+ deps: ['FirestoreOptions'],
372
+ },
373
+ {
374
+ provide: 'UserAddressRepository',
375
+ useFactory: (options, userRepository) => {
376
+ return new UserAddressFirestoreRepository(options, userRepository);
377
+ },
378
+ deps: ['FirestoreOptions', 'UserRepository'],
379
+ },
380
+ {
381
+ provide: 'UserPaymentMethodRepository',
382
+ useFactory: (options, userRepository) => {
383
+ return new UserPaymentMethodFirestoreRepository(options, userRepository);
384
+ },
385
+ deps: ['FirestoreOptions', 'UserRepository'],
386
+ },
387
+ {
388
+ provide: 'SubscriptionMaterializationRepository',
389
+ useFactory: (options) => {
390
+ return new SubscriptionMaterializationFirestoreRepository(options);
391
+ },
392
+ deps: ['FirestoreOptions'],
393
+ },
394
+ {
395
+ provide: 'SubscriptionSummaryRepository',
396
+ useFactory: (options) => {
397
+ return new SubscriptionSummaryFirestoreRepository(options);
398
+ },
399
+ deps: ['FirestoreOptions'],
400
+ },
401
+ {
402
+ provide: ProductVariantFirestoreRepository,
403
+ useFactory: (options, productRepository) => {
404
+ return new ProductVariantFirestoreRepository(options, productRepository);
405
+ },
406
+ deps: ['FirestoreOptions', ProductFirestoreRepository],
407
+ },
408
+ {
409
+ provide: 'FileUploaderService',
410
+ useFactory: (storage, baseUrl) => {
411
+ return new FirebaseFileUploaderService(storage, baseUrl);
412
+ },
413
+ deps: [Storage, STORAGE_BASE_URL],
414
+ },
415
+ ], imports: [AngularElasticSeachModule,
416
+ provideFirestore((injector) => {
417
+ const platformId = injector.get(PLATFORM_ID);
418
+ if (isPlatformServer(platformId))
419
+ return getFirestore(injector.get(FirebaseApp));
420
+ if (!MobileOperationSystemCheckerHelper.isAppleDevice())
421
+ return getFirestore(injector.get(FirebaseApp));
422
+ const firestore = initializeFirestore(injector.get(FirebaseApp), {
423
+ experimentalForceLongPolling: true,
424
+ localCache: memoryLocalCache(),
425
+ });
426
+ return firestore;
427
+ }),
428
+ provideStorage(() => getStorage())] });
429
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, decorators: [{
430
+ type: NgModule,
431
+ args: [{
432
+ imports: [
433
+ AngularElasticSeachModule,
434
+ provideFirestore((injector) => {
435
+ const platformId = injector.get(PLATFORM_ID);
436
+ if (isPlatformServer(platformId))
437
+ return getFirestore(injector.get(FirebaseApp));
438
+ if (!MobileOperationSystemCheckerHelper.isAppleDevice())
439
+ return getFirestore(injector.get(FirebaseApp));
440
+ const firestore = initializeFirestore(injector.get(FirebaseApp), {
441
+ experimentalForceLongPolling: true,
442
+ localCache: memoryLocalCache(),
443
+ });
444
+ return firestore;
445
+ }),
446
+ provideStorage(() => getStorage()),
447
+ ],
448
+ providers: [
449
+ {
450
+ provide: 'FirestoreOptions',
451
+ useFactory: (firestore, platformId) => ({
452
+ firestore,
453
+ interceptors: {
454
+ request: (request) => {
455
+ if (isPlatformBrowser(platformId))
456
+ return request;
457
+ const interval = setInterval(() => { }, 100);
458
+ request.interval = interval;
459
+ return request;
460
+ },
461
+ response: (response, request) => {
462
+ if (isPlatformBrowser(platformId))
463
+ return response;
464
+ clearInterval(request.interval);
465
+ return response;
466
+ },
467
+ },
468
+ }),
469
+ deps: [Firestore, PLATFORM_ID],
470
+ },
471
+ {
472
+ provide: 'BeautyProfileRepository',
473
+ useFactory: (config, userRepository) => {
474
+ return new UserBeautyProfileFirestoreRepository(config, userRepository);
475
+ },
476
+ deps: ['FirestoreOptions', 'UserRepository'],
477
+ },
478
+ {
479
+ provide: 'Buy2WinRepository',
480
+ useFactory: (options) => {
481
+ return new Buy2WinFirestoreRepository(options);
482
+ },
483
+ deps: ['FirestoreOptions'],
484
+ },
485
+ {
486
+ provide: CategoryFirestoreRepository,
487
+ useFactory: (options) => {
488
+ return new CategoryFirestoreRepository(options);
489
+ },
490
+ deps: ['FirestoreOptions'],
491
+ },
492
+ {
493
+ provide: 'CheckoutRepository',
494
+ useFactory: (options) => {
495
+ return new CheckoutFirestoreRepository(options);
496
+ },
497
+ deps: ['FirestoreOptions'],
498
+ },
499
+ {
500
+ provide: 'CheckoutSubscriptionRepository',
501
+ useFactory: (options) => {
502
+ return new CheckoutSubscriptionFirestoreRepository(options);
503
+ },
504
+ deps: ['FirestoreOptions'],
505
+ },
506
+ {
507
+ provide: 'CouponRepository',
508
+ useFactory: (options) => {
509
+ return new CouponFirestoreRepository(options);
510
+ },
511
+ deps: ['FirestoreOptions'],
512
+ },
513
+ {
514
+ provide: 'CampaignHashtagRepository',
515
+ useFactory: (options) => {
516
+ return new CampaignHashtagFirestoreRepository(options);
517
+ },
518
+ deps: ['FirestoreOptions'],
519
+ },
520
+ {
521
+ provide: 'CampaignDashboardRepository',
522
+ useFactory: (options) => {
523
+ return new CampaignDashboardFirestoreRepository(options);
524
+ },
525
+ deps: ['FirestoreOptions'],
526
+ },
527
+ {
528
+ provide: 'EditionRepository',
529
+ useFactory: (options, subscriptionRepository) => {
530
+ return new SubscriptionEditionFirestoreRepository(options, subscriptionRepository);
531
+ },
532
+ deps: ['FirestoreOptions', 'SubscriptionRepository'],
533
+ },
534
+ {
535
+ provide: 'HomeRepository',
536
+ useFactory: (options) => {
537
+ return new HomeFirestoreRepository(options);
538
+ },
539
+ deps: ['FirestoreOptions'],
540
+ },
541
+ {
542
+ provide: 'LeadRepository',
543
+ useFactory: (options) => {
544
+ return new LeadFirestoreRepository(options);
545
+ },
546
+ deps: ['FirestoreOptions'],
547
+ },
548
+ {
549
+ provide: 'LegacyOrderRepository',
550
+ useFactory: (options) => {
551
+ return new LegacyOrderFirestoreRepository(options);
552
+ },
553
+ deps: ['FirestoreOptions'],
554
+ },
555
+ {
556
+ provide: 'ShopMenuRepository',
557
+ useFactory: (options) => {
558
+ return new ShopMenuFirestoreRepository(options);
559
+ },
560
+ deps: ['FirestoreOptions'],
561
+ },
562
+ {
563
+ provide: 'OrderRepository',
564
+ useFactory: (options) => {
565
+ return new OrderFirestoreRepository(options);
566
+ },
567
+ deps: ['FirestoreOptions'],
568
+ },
569
+ {
570
+ provide: 'PaymentRepository',
571
+ useFactory: (options) => {
572
+ return new PaymentFirestoreRepository(options);
573
+ },
574
+ deps: ['FirestoreOptions'],
575
+ },
576
+ {
577
+ provide: ProductFirestoreRepository,
578
+ useFactory: (options) => {
579
+ return new ProductFirestoreRepository(options);
580
+ },
581
+ deps: ['FirestoreOptions'],
582
+ },
583
+ {
584
+ provide: 'ShopSettingsRepository',
585
+ useFactory: (options) => {
586
+ return new ShopSettingsFirestoreRepository(options);
587
+ },
588
+ deps: ['FirestoreOptions'],
589
+ },
590
+ {
591
+ provide: 'SubscriptionPaymentRepository',
592
+ useFactory: (options, subscriptionRepository) => {
593
+ return new SubscriptionPaymentFirestoreRepository(options, subscriptionRepository);
594
+ },
595
+ deps: ['FirestoreOptions', 'SubscriptionRepository'],
596
+ },
597
+ {
598
+ provide: 'SubscriptionPlanRepository',
599
+ useFactory: (options) => {
600
+ return new SubscriptionPlanFirestoreRepository(options);
601
+ },
602
+ deps: ['FirestoreOptions'],
603
+ },
604
+ {
605
+ provide: 'SubscriptionProductRepository',
606
+ useFactory: (options) => {
607
+ return new SubscriptionProductFirestoreRepository(options);
608
+ },
609
+ deps: ['FirestoreOptions'],
610
+ },
611
+ {
612
+ provide: 'SubscriptionRepository',
613
+ useFactory: (options) => {
614
+ return new SubscriptionFirestoreRepository(options);
615
+ },
616
+ deps: ['FirestoreOptions'],
617
+ },
618
+ {
619
+ provide: 'UserRepository',
620
+ useFactory: (options) => {
621
+ return new UserFirestoreRepository(options);
622
+ },
623
+ deps: ['FirestoreOptions'],
624
+ },
625
+ {
626
+ provide: 'UserAddressRepository',
627
+ useFactory: (options, userRepository) => {
628
+ return new UserAddressFirestoreRepository(options, userRepository);
629
+ },
630
+ deps: ['FirestoreOptions', 'UserRepository'],
631
+ },
632
+ {
633
+ provide: 'UserPaymentMethodRepository',
634
+ useFactory: (options, userRepository) => {
635
+ return new UserPaymentMethodFirestoreRepository(options, userRepository);
636
+ },
637
+ deps: ['FirestoreOptions', 'UserRepository'],
638
+ },
639
+ {
640
+ provide: 'SubscriptionMaterializationRepository',
641
+ useFactory: (options) => {
642
+ return new SubscriptionMaterializationFirestoreRepository(options);
643
+ },
644
+ deps: ['FirestoreOptions'],
645
+ },
646
+ {
647
+ provide: 'SubscriptionSummaryRepository',
648
+ useFactory: (options) => {
649
+ return new SubscriptionSummaryFirestoreRepository(options);
650
+ },
651
+ deps: ['FirestoreOptions'],
652
+ },
653
+ {
654
+ provide: ProductVariantFirestoreRepository,
655
+ useFactory: (options, productRepository) => {
656
+ return new ProductVariantFirestoreRepository(options, productRepository);
657
+ },
658
+ deps: ['FirestoreOptions', ProductFirestoreRepository],
659
+ },
660
+ {
661
+ provide: 'FileUploaderService',
662
+ useFactory: (storage, baseUrl) => {
663
+ return new FirebaseFileUploaderService(storage, baseUrl);
664
+ },
665
+ deps: [Storage, STORAGE_BASE_URL],
666
+ },
667
+ ],
668
+ }]
669
669
  }] });
670
670
 
671
- class AngularHasuraGraphQLModule {
672
- static initializeApp(options) {
673
- return {
674
- ngModule: AngularHasuraGraphQLModule,
675
- providers: [{ provide: HASURA_OPTIONS, useValue: options }],
676
- };
677
- }
678
- }
679
- AngularHasuraGraphQLModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
680
- AngularHasuraGraphQLModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule });
681
- AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, providers: [
682
- {
683
- provide: 'HasuraConfig',
684
- useFactory: (options, platformId) => ({
685
- endpoint: options.endpoint,
686
- authOptions: options.credentials,
687
- interceptors: {
688
- request: (request) => {
689
- if (isPlatformBrowser(platformId))
690
- return request;
691
- const interval = setInterval(() => { }, 100);
692
- request.interval = interval;
693
- return request;
694
- },
695
- response: (response, request) => {
696
- if (isPlatformBrowser(platformId))
697
- return response;
698
- clearInterval(request.interval);
699
- return response;
700
- },
701
- },
702
- }),
703
- deps: [HASURA_OPTIONS, PLATFORM_ID],
704
- },
705
- {
706
- provide: 'CategoryRepository',
707
- useExisting: CategoryHasuraGraphQLRepository,
708
- },
709
- {
710
- provide: CategoryHasuraGraphQLRepository,
711
- useFactory: (options, productRepository, categoryFilterRepository) => {
712
- return new CategoryHasuraGraphQLRepository(options, productRepository, categoryFilterRepository);
713
- },
714
- deps: ['HasuraConfig', ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
715
- },
716
- {
717
- provide: 'ProductRepository',
718
- useExisting: ProductHasuraGraphQLRepository,
719
- },
720
- {
721
- provide: ProductHasuraGraphQLRepository,
722
- useFactory: (hasuraConfig) => {
723
- return new ProductHasuraGraphQLRepository(hasuraConfig);
724
- },
725
- deps: ['HasuraConfig'],
726
- },
727
- {
728
- provide: 'ProductReviewsRepository',
729
- useExisting: ProductReviewsHasuraGraphQLRepository,
730
- },
731
- {
732
- provide: ProductReviewsHasuraGraphQLRepository,
733
- useFactory: (hasuraConfig) => {
734
- return new ProductReviewsHasuraGraphQLRepository(hasuraConfig);
735
- },
736
- deps: ['HasuraConfig'],
737
- },
738
- {
739
- provide: 'VariantRepository',
740
- useExisting: VariantHasuraGraphQLRepository,
741
- },
742
- {
743
- provide: VariantHasuraGraphQLRepository,
744
- useFactory: (hasuraConfig) => {
745
- return new VariantHasuraGraphQLRepository(hasuraConfig);
746
- },
747
- deps: ['HasuraConfig'],
748
- },
749
- {
750
- provide: 'CategoryFilterRepository',
751
- useExisting: CategoryFilterHasuraGraphQLRepository,
752
- },
753
- {
754
- provide: CategoryFilterHasuraGraphQLRepository,
755
- useFactory: (options) => {
756
- return new CategoryFilterHasuraGraphQLRepository(options);
757
- },
758
- deps: ['HasuraConfig'],
759
- },
760
- {
761
- provide: 'FilterOptionRepository',
762
- useExisting: FilterOptionHasuraGraphQLRepository,
763
- },
764
- {
765
- provide: FilterOptionHasuraGraphQLRepository,
766
- useFactory: (options) => {
767
- return new FilterOptionHasuraGraphQLRepository(options);
768
- },
769
- deps: ['HasuraConfig'],
770
- },
771
- {
772
- provide: 'FilterRepository',
773
- useExisting: FilterHasuraGraphQLRepository,
774
- },
775
- {
776
- provide: FilterHasuraGraphQLRepository,
777
- useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
778
- return new FilterHasuraGraphQLRepository(options, filterOptionRepository, categoryFilterRepository);
779
- },
780
- deps: ['HasuraConfig', FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
781
- },
782
- {
783
- provide: CategoryCollectionChildrenHasuraGraphQLRepository,
784
- useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options),
785
- deps: ['HasuraConfig'],
786
- },
787
- {
788
- provide: 'CategoryCollectionChildrenRepository',
789
- useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
790
- },
791
- {
792
- provide: WishlistHasuraGraphQLRepository,
793
- useFactory: (options, categoryFilterRepository) => {
794
- return new WishlistHasuraGraphQLRepository(options, categoryFilterRepository);
795
- },
796
- deps: ['HasuraConfig', CategoryFilterHasuraGraphQLRepository],
797
- },
798
- {
799
- provide: 'WishlistRepository',
800
- useExisting: WishlistHasuraGraphQLRepository,
801
- },
802
- ] });
803
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
804
- type: NgModule,
805
- args: [{
806
- providers: [
807
- {
808
- provide: 'HasuraConfig',
809
- useFactory: (options, platformId) => ({
810
- endpoint: options.endpoint,
811
- authOptions: options.credentials,
812
- interceptors: {
813
- request: (request) => {
814
- if (isPlatformBrowser(platformId))
815
- return request;
816
- const interval = setInterval(() => { }, 100);
817
- request.interval = interval;
818
- return request;
819
- },
820
- response: (response, request) => {
821
- if (isPlatformBrowser(platformId))
822
- return response;
823
- clearInterval(request.interval);
824
- return response;
825
- },
826
- },
827
- }),
828
- deps: [HASURA_OPTIONS, PLATFORM_ID],
829
- },
830
- {
831
- provide: 'CategoryRepository',
832
- useExisting: CategoryHasuraGraphQLRepository,
833
- },
834
- {
835
- provide: CategoryHasuraGraphQLRepository,
836
- useFactory: (options, productRepository, categoryFilterRepository) => {
837
- return new CategoryHasuraGraphQLRepository(options, productRepository, categoryFilterRepository);
838
- },
839
- deps: ['HasuraConfig', ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
840
- },
841
- {
842
- provide: 'ProductRepository',
843
- useExisting: ProductHasuraGraphQLRepository,
844
- },
845
- {
846
- provide: ProductHasuraGraphQLRepository,
847
- useFactory: (hasuraConfig) => {
848
- return new ProductHasuraGraphQLRepository(hasuraConfig);
849
- },
850
- deps: ['HasuraConfig'],
851
- },
852
- {
853
- provide: 'ProductReviewsRepository',
854
- useExisting: ProductReviewsHasuraGraphQLRepository,
855
- },
856
- {
857
- provide: ProductReviewsHasuraGraphQLRepository,
858
- useFactory: (hasuraConfig) => {
859
- return new ProductReviewsHasuraGraphQLRepository(hasuraConfig);
860
- },
861
- deps: ['HasuraConfig'],
862
- },
863
- {
864
- provide: 'VariantRepository',
865
- useExisting: VariantHasuraGraphQLRepository,
866
- },
867
- {
868
- provide: VariantHasuraGraphQLRepository,
869
- useFactory: (hasuraConfig) => {
870
- return new VariantHasuraGraphQLRepository(hasuraConfig);
871
- },
872
- deps: ['HasuraConfig'],
873
- },
874
- {
875
- provide: 'CategoryFilterRepository',
876
- useExisting: CategoryFilterHasuraGraphQLRepository,
877
- },
878
- {
879
- provide: CategoryFilterHasuraGraphQLRepository,
880
- useFactory: (options) => {
881
- return new CategoryFilterHasuraGraphQLRepository(options);
882
- },
883
- deps: ['HasuraConfig'],
884
- },
885
- {
886
- provide: 'FilterOptionRepository',
887
- useExisting: FilterOptionHasuraGraphQLRepository,
888
- },
889
- {
890
- provide: FilterOptionHasuraGraphQLRepository,
891
- useFactory: (options) => {
892
- return new FilterOptionHasuraGraphQLRepository(options);
893
- },
894
- deps: ['HasuraConfig'],
895
- },
896
- {
897
- provide: 'FilterRepository',
898
- useExisting: FilterHasuraGraphQLRepository,
899
- },
900
- {
901
- provide: FilterHasuraGraphQLRepository,
902
- useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
903
- return new FilterHasuraGraphQLRepository(options, filterOptionRepository, categoryFilterRepository);
904
- },
905
- deps: ['HasuraConfig', FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
906
- },
907
- {
908
- provide: CategoryCollectionChildrenHasuraGraphQLRepository,
909
- useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options),
910
- deps: ['HasuraConfig'],
911
- },
912
- {
913
- provide: 'CategoryCollectionChildrenRepository',
914
- useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
915
- },
916
- {
917
- provide: WishlistHasuraGraphQLRepository,
918
- useFactory: (options, categoryFilterRepository) => {
919
- return new WishlistHasuraGraphQLRepository(options, categoryFilterRepository);
920
- },
921
- deps: ['HasuraConfig', CategoryFilterHasuraGraphQLRepository],
922
- },
923
- {
924
- provide: 'WishlistRepository',
925
- useExisting: WishlistHasuraGraphQLRepository,
926
- },
927
- ],
928
- }]
671
+ class AngularHasuraGraphQLModule {
672
+ static initializeApp(options) {
673
+ return {
674
+ ngModule: AngularHasuraGraphQLModule,
675
+ providers: [{ provide: HASURA_OPTIONS, useValue: options }],
676
+ };
677
+ }
678
+ }
679
+ AngularHasuraGraphQLModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
680
+ AngularHasuraGraphQLModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule });
681
+ AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, providers: [
682
+ {
683
+ provide: 'HasuraConfig',
684
+ useFactory: (options, platformId) => ({
685
+ endpoint: options.endpoint,
686
+ authOptions: options.credentials,
687
+ interceptors: {
688
+ request: (request) => {
689
+ if (isPlatformBrowser(platformId))
690
+ return request;
691
+ const interval = setInterval(() => { }, 100);
692
+ request.interval = interval;
693
+ return request;
694
+ },
695
+ response: (response, request) => {
696
+ if (isPlatformBrowser(platformId))
697
+ return response;
698
+ clearInterval(request.interval);
699
+ return response;
700
+ },
701
+ },
702
+ }),
703
+ deps: [HASURA_OPTIONS, PLATFORM_ID],
704
+ },
705
+ {
706
+ provide: 'CategoryRepository',
707
+ useExisting: CategoryHasuraGraphQLRepository,
708
+ },
709
+ {
710
+ provide: CategoryHasuraGraphQLRepository,
711
+ useFactory: (options, productRepository, categoryFilterRepository) => {
712
+ return new CategoryHasuraGraphQLRepository(options, productRepository, categoryFilterRepository);
713
+ },
714
+ deps: ['HasuraConfig', ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
715
+ },
716
+ {
717
+ provide: 'ProductRepository',
718
+ useExisting: ProductHasuraGraphQLRepository,
719
+ },
720
+ {
721
+ provide: ProductHasuraGraphQLRepository,
722
+ useFactory: (hasuraConfig) => {
723
+ return new ProductHasuraGraphQLRepository(hasuraConfig);
724
+ },
725
+ deps: ['HasuraConfig'],
726
+ },
727
+ {
728
+ provide: 'ProductReviewsRepository',
729
+ useExisting: ProductReviewsHasuraGraphQLRepository,
730
+ },
731
+ {
732
+ provide: ProductReviewsHasuraGraphQLRepository,
733
+ useFactory: (hasuraConfig) => {
734
+ return new ProductReviewsHasuraGraphQLRepository(hasuraConfig);
735
+ },
736
+ deps: ['HasuraConfig'],
737
+ },
738
+ {
739
+ provide: 'VariantRepository',
740
+ useExisting: VariantHasuraGraphQLRepository,
741
+ },
742
+ {
743
+ provide: VariantHasuraGraphQLRepository,
744
+ useFactory: (hasuraConfig) => {
745
+ return new VariantHasuraGraphQLRepository(hasuraConfig);
746
+ },
747
+ deps: ['HasuraConfig'],
748
+ },
749
+ {
750
+ provide: 'CategoryFilterRepository',
751
+ useExisting: CategoryFilterHasuraGraphQLRepository,
752
+ },
753
+ {
754
+ provide: CategoryFilterHasuraGraphQLRepository,
755
+ useFactory: (options) => {
756
+ return new CategoryFilterHasuraGraphQLRepository(options);
757
+ },
758
+ deps: ['HasuraConfig'],
759
+ },
760
+ {
761
+ provide: 'FilterOptionRepository',
762
+ useExisting: FilterOptionHasuraGraphQLRepository,
763
+ },
764
+ {
765
+ provide: FilterOptionHasuraGraphQLRepository,
766
+ useFactory: (options) => {
767
+ return new FilterOptionHasuraGraphQLRepository(options);
768
+ },
769
+ deps: ['HasuraConfig'],
770
+ },
771
+ {
772
+ provide: 'FilterRepository',
773
+ useExisting: FilterHasuraGraphQLRepository,
774
+ },
775
+ {
776
+ provide: FilterHasuraGraphQLRepository,
777
+ useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
778
+ return new FilterHasuraGraphQLRepository(options, filterOptionRepository, categoryFilterRepository);
779
+ },
780
+ deps: ['HasuraConfig', FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
781
+ },
782
+ {
783
+ provide: CategoryCollectionChildrenHasuraGraphQLRepository,
784
+ useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options),
785
+ deps: ['HasuraConfig'],
786
+ },
787
+ {
788
+ provide: 'CategoryCollectionChildrenRepository',
789
+ useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
790
+ },
791
+ {
792
+ provide: WishlistHasuraGraphQLRepository,
793
+ useFactory: (options, categoryFilterRepository) => {
794
+ return new WishlistHasuraGraphQLRepository(options, categoryFilterRepository);
795
+ },
796
+ deps: ['HasuraConfig', CategoryFilterHasuraGraphQLRepository],
797
+ },
798
+ {
799
+ provide: 'WishlistRepository',
800
+ useExisting: WishlistHasuraGraphQLRepository,
801
+ },
802
+ ] });
803
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
804
+ type: NgModule,
805
+ args: [{
806
+ providers: [
807
+ {
808
+ provide: 'HasuraConfig',
809
+ useFactory: (options, platformId) => ({
810
+ endpoint: options.endpoint,
811
+ authOptions: options.credentials,
812
+ interceptors: {
813
+ request: (request) => {
814
+ if (isPlatformBrowser(platformId))
815
+ return request;
816
+ const interval = setInterval(() => { }, 100);
817
+ request.interval = interval;
818
+ return request;
819
+ },
820
+ response: (response, request) => {
821
+ if (isPlatformBrowser(platformId))
822
+ return response;
823
+ clearInterval(request.interval);
824
+ return response;
825
+ },
826
+ },
827
+ }),
828
+ deps: [HASURA_OPTIONS, PLATFORM_ID],
829
+ },
830
+ {
831
+ provide: 'CategoryRepository',
832
+ useExisting: CategoryHasuraGraphQLRepository,
833
+ },
834
+ {
835
+ provide: CategoryHasuraGraphQLRepository,
836
+ useFactory: (options, productRepository, categoryFilterRepository) => {
837
+ return new CategoryHasuraGraphQLRepository(options, productRepository, categoryFilterRepository);
838
+ },
839
+ deps: ['HasuraConfig', ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
840
+ },
841
+ {
842
+ provide: 'ProductRepository',
843
+ useExisting: ProductHasuraGraphQLRepository,
844
+ },
845
+ {
846
+ provide: ProductHasuraGraphQLRepository,
847
+ useFactory: (hasuraConfig) => {
848
+ return new ProductHasuraGraphQLRepository(hasuraConfig);
849
+ },
850
+ deps: ['HasuraConfig'],
851
+ },
852
+ {
853
+ provide: 'ProductReviewsRepository',
854
+ useExisting: ProductReviewsHasuraGraphQLRepository,
855
+ },
856
+ {
857
+ provide: ProductReviewsHasuraGraphQLRepository,
858
+ useFactory: (hasuraConfig) => {
859
+ return new ProductReviewsHasuraGraphQLRepository(hasuraConfig);
860
+ },
861
+ deps: ['HasuraConfig'],
862
+ },
863
+ {
864
+ provide: 'VariantRepository',
865
+ useExisting: VariantHasuraGraphQLRepository,
866
+ },
867
+ {
868
+ provide: VariantHasuraGraphQLRepository,
869
+ useFactory: (hasuraConfig) => {
870
+ return new VariantHasuraGraphQLRepository(hasuraConfig);
871
+ },
872
+ deps: ['HasuraConfig'],
873
+ },
874
+ {
875
+ provide: 'CategoryFilterRepository',
876
+ useExisting: CategoryFilterHasuraGraphQLRepository,
877
+ },
878
+ {
879
+ provide: CategoryFilterHasuraGraphQLRepository,
880
+ useFactory: (options) => {
881
+ return new CategoryFilterHasuraGraphQLRepository(options);
882
+ },
883
+ deps: ['HasuraConfig'],
884
+ },
885
+ {
886
+ provide: 'FilterOptionRepository',
887
+ useExisting: FilterOptionHasuraGraphQLRepository,
888
+ },
889
+ {
890
+ provide: FilterOptionHasuraGraphQLRepository,
891
+ useFactory: (options) => {
892
+ return new FilterOptionHasuraGraphQLRepository(options);
893
+ },
894
+ deps: ['HasuraConfig'],
895
+ },
896
+ {
897
+ provide: 'FilterRepository',
898
+ useExisting: FilterHasuraGraphQLRepository,
899
+ },
900
+ {
901
+ provide: FilterHasuraGraphQLRepository,
902
+ useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
903
+ return new FilterHasuraGraphQLRepository(options, filterOptionRepository, categoryFilterRepository);
904
+ },
905
+ deps: ['HasuraConfig', FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
906
+ },
907
+ {
908
+ provide: CategoryCollectionChildrenHasuraGraphQLRepository,
909
+ useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options),
910
+ deps: ['HasuraConfig'],
911
+ },
912
+ {
913
+ provide: 'CategoryCollectionChildrenRepository',
914
+ useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
915
+ },
916
+ {
917
+ provide: WishlistHasuraGraphQLRepository,
918
+ useFactory: (options, categoryFilterRepository) => {
919
+ return new WishlistHasuraGraphQLRepository(options, categoryFilterRepository);
920
+ },
921
+ deps: ['HasuraConfig', CategoryFilterHasuraGraphQLRepository],
922
+ },
923
+ {
924
+ provide: 'WishlistRepository',
925
+ useExisting: WishlistHasuraGraphQLRepository,
926
+ },
927
+ ],
928
+ }]
929
929
  }] });
930
930
 
931
- class AuthService {
932
- constructor(angularFireAuth, userRepository) {
933
- this.angularFireAuth = angularFireAuth;
934
- this.userRepository = userRepository;
935
- }
936
- getAuthstate() {
937
- const observables = [this.getFireUser(), this.getUser()];
938
- return combineLatest(observables).pipe(map(([fireUser, user]) => ({
939
- user,
940
- isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
941
- })));
942
- }
943
- getUser() {
944
- return this.getFireUser().pipe(map((user) => user === null || user === void 0 ? void 0 : user.uid), mergeMap((id) => (id ? from(this.userRepository.get({ id })).pipe(catchError(() => of(null))) : of(null))));
945
- }
946
- getTokenId() {
947
- return from(getIdToken(this.angularFireAuth.currentUser));
948
- }
949
- getFireUser() {
950
- return authState(this.angularFireAuth).pipe(catchError(() => of(null)));
951
- }
952
- }
953
- AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService, deps: [{ token: i1.Auth }, { token: 'UserRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
954
- AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService });
955
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService, decorators: [{
956
- type: Injectable
957
- }], ctorParameters: function () {
958
- return [{ type: i1.Auth }, { type: undefined, decorators: [{
959
- type: Inject,
960
- args: ['UserRepository']
961
- }] }];
931
+ class AuthService {
932
+ constructor(angularFireAuth, userRepository) {
933
+ this.angularFireAuth = angularFireAuth;
934
+ this.userRepository = userRepository;
935
+ }
936
+ getAuthstate() {
937
+ const observables = [this.getFireUser(), this.getUser()];
938
+ return combineLatest(observables).pipe(map(([fireUser, user]) => ({
939
+ user,
940
+ isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
941
+ })));
942
+ }
943
+ getUser() {
944
+ return this.getFireUser().pipe(map((user) => user === null || user === void 0 ? void 0 : user.uid), mergeMap((id) => (id ? from(this.userRepository.get({ id })).pipe(catchError(() => of(null))) : of(null))));
945
+ }
946
+ getTokenId() {
947
+ return from(getIdToken(this.angularFireAuth.currentUser));
948
+ }
949
+ getFireUser() {
950
+ return authState(this.angularFireAuth).pipe(catchError(() => of(null)));
951
+ }
952
+ }
953
+ AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService, deps: [{ token: i1.Auth }, { token: 'UserRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
954
+ AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService });
955
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService, decorators: [{
956
+ type: Injectable
957
+ }], ctorParameters: function () {
958
+ return [{ type: i1.Auth }, { type: undefined, decorators: [{
959
+ type: Inject,
960
+ args: ['UserRepository']
961
+ }] }];
962
962
  } });
963
963
 
964
- class CouponService {
965
- constructor(couponRepository, defaultShop, orderRepository, categoryRepository) {
966
- this.couponRepository = couponRepository;
967
- this.defaultShop = defaultShop;
968
- this.orderRepository = orderRepository;
969
- this.categoryRepository = categoryRepository;
970
- this.emailIsFromCollaborator = (userEmail) => !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g));
971
- }
972
- checkCoupon(nickname, checkoutType, checkout, plan) {
973
- return from(this.couponRepository
974
- .find({
975
- filters: {
976
- nickname: { operator: Where.EQUALS, value: nickname },
977
- active: { operator: Where.EQUALS, value: true },
978
- },
979
- })
980
- .then((result) => result.data[0])).pipe(concatMap((coupon) => this.couponValidation(coupon, checkoutType)), concatMap((couponValid) => this.couponRulesValidation(couponValid, checkoutType, checkout, plan)), map((couponValidated) => couponValidated));
981
- }
982
- couponValidation(coupon, checkoutType) {
983
- return __awaiter(this, void 0, void 0, function* () {
984
- if (!coupon)
985
- throw 'Cupom inválido.';
986
- if ((coupon === null || coupon === void 0 ? void 0 : coupon.beginAt) && (coupon === null || coupon === void 0 ? void 0 : coupon.beginAt.getTime()) > new Date().getTime())
987
- throw 'Cupom inválido.';
988
- if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) && (coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn.getTime()) < new Date().getTime())
989
- throw 'Cupom expirado.';
990
- const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.defaultShop;
991
- if (!isInShop)
992
- throw 'Cupom inválido para loja.';
993
- const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
994
- if (!isCheckoutType)
995
- throw 'Cupom inválido. Erro de checkout.';
996
- return coupon;
997
- });
998
- }
999
- couponRulesValidation(coupon, checkoutType, checkout, plan) {
1000
- return __awaiter(this, void 0, void 0, function* () {
1001
- if (checkoutType == CheckoutTypes.SUBSCRIPTION) {
1002
- if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
1003
- throw 'Cupom inválido para sua assinatura.';
1004
- return coupon;
1005
- }
1006
- const validUser = this.coupomUserValidation(coupon, checkout === null || checkout === void 0 ? void 0 : checkout.user);
1007
- if (!validUser)
1008
- throw 'Usuário não elegível.';
1009
- const couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
1010
- if (couponUseLimits.firstOrder) {
1011
- const ordersUser = yield this.getOrdersFromUser(checkout.user.email.toLocaleLowerCase());
1012
- if (couponUseLimits.firstOrder && ordersUser.length >= 1)
1013
- throw 'Limite de uso atingido';
1014
- }
1015
- if (!couponUseLimits.unlimited || couponUseLimits.limitedPerUser) {
1016
- const orders = yield this.getOrdersWithCoupon(coupon);
1017
- if (!couponUseLimits.unlimited && couponUseLimits.total && orders.length >= couponUseLimits.total)
1018
- throw 'Limite de uso atingido.';
1019
- if (couponUseLimits.limitedPerUser) {
1020
- const ordersWithUser = this.countOrdersWithUser(orders, checkout.user.email);
1021
- if (ordersWithUser > 0)
1022
- throw 'Limite de uso por usuário atingido.';
1023
- }
1024
- }
1025
- const hasProductCategories = yield this.hasProductCategories(coupon, checkout);
1026
- if (!hasProductCategories)
1027
- throw 'Seu carrinho não possui produtos elegíveis para desconto.';
1028
- const hasMinSubTotal = yield this.hasMinSubTotal(coupon, checkout);
1029
- if (!hasMinSubTotal)
1030
- throw `Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido`;
1031
- return coupon;
1032
- });
1033
- }
1034
- calcDiscountSubscription(coupon, checkout) {
1035
- let discount = 0;
1036
- if (coupon.discount.subscription.type == CouponTypes.ABSOLUTE)
1037
- discount = coupon.discount.subscription.value;
1038
- else
1039
- discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount.subscription.value / 100);
1040
- return of(discount);
1041
- }
1042
- calcDiscountShopping(coupon, checkout) {
1043
- return __awaiter(this, void 0, void 0, function* () {
1044
- let discount = 0;
1045
- if (checkout.user.isSubscriber && coupon.discount.subscriber.value) {
1046
- discount = yield this.calcDiscountByType(coupon.discount.subscriber.type, coupon.discount.subscriber.value, coupon.productsCategories, checkout);
1047
- }
1048
- else {
1049
- discount = yield this.calcDiscountByType(coupon.discount.non_subscriber.type, coupon.discount.non_subscriber.value, coupon.productsCategories, checkout);
1050
- }
1051
- return discount;
1052
- });
1053
- }
1054
- calcDiscountByType(type, value, categories, checkout) {
1055
- return __awaiter(this, void 0, void 0, function* () {
1056
- let discount = 0;
1057
- let lineItensDiscount = yield this.getLineItensEligebleForDiscount(categories, checkout);
1058
- const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
1059
- if (type == CouponTypes.ABSOLUTE) {
1060
- discount = value > subTotal ? subTotal : value;
1061
- }
1062
- else {
1063
- discount = subTotal * (value / 100);
1064
- }
1065
- return discount;
1066
- });
1067
- }
1068
- hasMinSubTotal(coupon, checkout) {
1069
- return __awaiter(this, void 0, void 0, function* () {
1070
- if (!coupon.minSubTotalValue)
1071
- return true;
1072
- let lineItensDiscount = yield this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
1073
- const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
1074
- if (coupon.minSubTotalValue <= subTotal)
1075
- return true;
1076
- return false;
1077
- });
1078
- }
1079
- hasProductCategories(coupon, checkout) {
1080
- var _a;
1081
- return __awaiter(this, void 0, void 0, function* () {
1082
- if (!coupon.productsCategories || !coupon.productsCategories.length) {
1083
- return true;
1084
- }
1085
- const couponCategories = yield this.getCouponCategoriesId(coupon.productsCategories);
1086
- const hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
1087
- var _a;
1088
- if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length))
1089
- return true;
1090
- return i.categories.some((c) => couponCategories.some((cat) => cat == c));
1091
- });
1092
- return hasCategories.length ? true : false;
1093
- });
1094
- }
1095
- coupomUserValidation(coupon, user) {
1096
- if (!user || coupon.exclusivityType.includes(Exclusivities.ALL_USERS))
1097
- return true;
1098
- let userTypes = [];
1099
- if (coupon.exclusivityType.includes(Exclusivities.COLLABORATORS) &&
1100
- this.emailIsFromCollaborator(user.email.toLocaleLowerCase()))
1101
- userTypes.push(Exclusivities.COLLABORATORS);
1102
- if (coupon.exclusivityType.includes(Exclusivities.SPECIFIC_USER) &&
1103
- coupon.userExclusiveEmail.includes(user.email.toLocaleLowerCase()))
1104
- userTypes.push(Exclusivities.SPECIFIC_USER);
1105
- if (coupon.exclusivityType.includes(Exclusivities.ACTIVE_SUBSCRIBER) &&
1106
- user.isSubscriber &&
1107
- user.subscriptionPlan != '')
1108
- userTypes.push(Exclusivities.ACTIVE_SUBSCRIBER);
1109
- if (user.isSubscriber &&
1110
- user.subscriptionPlan == '' &&
1111
- coupon.exclusivityType.includes(Exclusivities.INACTIVE_SUBSCRIBER))
1112
- userTypes.push(Exclusivities.INACTIVE_SUBSCRIBER);
1113
- if (coupon.exclusivityType.includes(Exclusivities.NON_SUBSCRIBER) && !user.isSubscriber)
1114
- userTypes.push(Exclusivities.NON_SUBSCRIBER);
1115
- return coupon.exclusivityType.some((r) => userTypes.includes(r));
1116
- }
1117
- getCouponCategoriesId(productsCategories) {
1118
- return __awaiter(this, void 0, void 0, function* () {
1119
- const couponCategories = [];
1120
- for (let index = 0; index < productsCategories.length; index++) {
1121
- const category = yield this.categoryRepository.get({
1122
- id: productsCategories[index],
1123
- });
1124
- if (category) {
1125
- const children = yield this.categoryRepository.getChildren(parseInt(productsCategories[index]));
1126
- couponCategories.push(category.id, ...children.map((c) => c.id.toString()));
1127
- }
1128
- }
1129
- return [...new Set(couponCategories)];
1130
- });
1131
- }
1132
- getLineItensEligebleForDiscount(productsCategories, checkout) {
1133
- var _a;
1134
- return __awaiter(this, void 0, void 0, function* () {
1135
- let lineItensDiscount = [];
1136
- const couponCategories = yield this.getCouponCategoriesId(productsCategories);
1137
- if (productsCategories && productsCategories.length) {
1138
- lineItensDiscount = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
1139
- var _a;
1140
- if ((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length) {
1141
- return i.categories.some((c) => couponCategories.some((cat) => cat == c));
1142
- }
1143
- return true;
1144
- });
1145
- }
1146
- else {
1147
- lineItensDiscount = checkout.lineItems;
1148
- }
1149
- return lineItensDiscount;
1150
- });
1151
- }
1152
- calcCheckoutSubtotal(lineItens, user, shop) {
1153
- return ((lineItens === null || lineItens === void 0 ? void 0 : lineItens.reduce((acc, curr) => {
1154
- var _a;
1155
- return (user === null || user === void 0 ? void 0 : user.isSubscriber) && curr.price.subscriberPrice
1156
- ? acc + ((_a = curr.price) === null || _a === void 0 ? void 0 : _a.subscriberPrice) * curr.quantity
1157
- : acc + curr.pricePaid * curr.quantity;
1158
- }, 0)) || 0);
1159
- }
1160
- getOrdersWithCoupon(coupon) {
1161
- return __awaiter(this, void 0, void 0, function* () {
1162
- return yield this.orderRepository
1163
- .find({
1164
- filters: {
1165
- coupon: { id: coupon.id },
1166
- payment: { status: 'paid' },
1167
- },
1168
- })
1169
- .then((result) => result.data);
1170
- });
1171
- }
1172
- getOrdersFromUser(email) {
1173
- return __awaiter(this, void 0, void 0, function* () {
1174
- return yield this.orderRepository
1175
- .find({
1176
- filters: {
1177
- user: { email: { operator: Where.EQUALS, value: email } },
1178
- payment: { status: 'paid' },
1179
- },
1180
- })
1181
- .then((result) => result.data);
1182
- });
1183
- }
1184
- countOrdersWithUser(orders, email) {
1185
- return orders.filter((o) => o.user.email == email).length;
1186
- }
1187
- getCouponUseLimits(coupon, checkoutType, user) {
1188
- let couponUseLimits;
1189
- if (checkoutType == CheckoutTypes.ECOMMERCE || checkoutType == CheckoutTypes.ALL) {
1190
- couponUseLimits = user && user.isSubscriber ? coupon.useLimits.subscriber : coupon.useLimits.non_subscriber;
1191
- }
1192
- else {
1193
- couponUseLimits = coupon.useLimits.subscription;
1194
- }
1195
- return couponUseLimits;
1196
- }
1197
- }
1198
- CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1199
- CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, providedIn: 'root' });
1200
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, decorators: [{
1201
- type: Injectable,
1202
- args: [{
1203
- providedIn: 'root',
1204
- }]
1205
- }], ctorParameters: function () {
1206
- return [{ type: undefined, decorators: [{
1207
- type: Inject,
1208
- args: ['CouponRepository']
1209
- }] }, { type: i1$2.Shops, decorators: [{
1210
- type: Inject,
1211
- args: [DEFAULT_SHOP]
1212
- }] }, { type: undefined, decorators: [{
1213
- type: Inject,
1214
- args: ['OrderRepository']
1215
- }] }, { type: undefined, decorators: [{
1216
- type: Inject,
1217
- args: ['CategoryRepository']
1218
- }] }];
964
+ class CouponService {
965
+ constructor(couponRepository, defaultShop, orderRepository, categoryRepository) {
966
+ this.couponRepository = couponRepository;
967
+ this.defaultShop = defaultShop;
968
+ this.orderRepository = orderRepository;
969
+ this.categoryRepository = categoryRepository;
970
+ this.emailIsFromCollaborator = (userEmail) => !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g));
971
+ }
972
+ checkCoupon(nickname, checkoutType, checkout, plan) {
973
+ return from(this.couponRepository
974
+ .find({
975
+ filters: {
976
+ nickname: { operator: Where.EQUALS, value: nickname },
977
+ active: { operator: Where.EQUALS, value: true },
978
+ },
979
+ })
980
+ .then((result) => result.data[0])).pipe(concatMap((coupon) => this.couponValidation(coupon, checkoutType)), concatMap((couponValid) => this.couponRulesValidation(couponValid, checkoutType, checkout, plan)), map((couponValidated) => couponValidated));
981
+ }
982
+ couponValidation(coupon, checkoutType) {
983
+ return __awaiter(this, void 0, void 0, function* () {
984
+ if (!coupon)
985
+ throw 'Cupom inválido.';
986
+ if ((coupon === null || coupon === void 0 ? void 0 : coupon.beginAt) && (coupon === null || coupon === void 0 ? void 0 : coupon.beginAt.getTime()) > new Date().getTime())
987
+ throw 'Cupom inválido.';
988
+ if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) && (coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn.getTime()) < new Date().getTime())
989
+ throw 'Cupom expirado.';
990
+ const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.defaultShop;
991
+ if (!isInShop)
992
+ throw 'Cupom inválido para loja.';
993
+ const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
994
+ if (!isCheckoutType)
995
+ throw 'Cupom inválido. Erro de checkout.';
996
+ return coupon;
997
+ });
998
+ }
999
+ couponRulesValidation(coupon, checkoutType, checkout, plan) {
1000
+ return __awaiter(this, void 0, void 0, function* () {
1001
+ if (checkoutType == CheckoutTypes.SUBSCRIPTION) {
1002
+ if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
1003
+ throw 'Cupom inválido para sua assinatura.';
1004
+ return coupon;
1005
+ }
1006
+ const validUser = this.coupomUserValidation(coupon, checkout === null || checkout === void 0 ? void 0 : checkout.user);
1007
+ if (!validUser)
1008
+ throw 'Usuário não elegível.';
1009
+ const couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
1010
+ if (couponUseLimits.firstOrder) {
1011
+ const ordersUser = yield this.getOrdersFromUser(checkout.user.email.toLocaleLowerCase());
1012
+ if (couponUseLimits.firstOrder && ordersUser.length >= 1)
1013
+ throw 'Limite de uso atingido';
1014
+ }
1015
+ if (!couponUseLimits.unlimited || couponUseLimits.limitedPerUser) {
1016
+ const orders = yield this.getOrdersWithCoupon(coupon);
1017
+ if (!couponUseLimits.unlimited && couponUseLimits.total && orders.length >= couponUseLimits.total)
1018
+ throw 'Limite de uso atingido.';
1019
+ if (couponUseLimits.limitedPerUser) {
1020
+ const ordersWithUser = this.countOrdersWithUser(orders, checkout.user.email);
1021
+ if (ordersWithUser > 0)
1022
+ throw 'Limite de uso por usuário atingido.';
1023
+ }
1024
+ }
1025
+ const hasProductCategories = yield this.hasProductCategories(coupon, checkout);
1026
+ if (!hasProductCategories)
1027
+ throw 'Seu carrinho não possui produtos elegíveis para desconto.';
1028
+ const hasMinSubTotal = yield this.hasMinSubTotal(coupon, checkout);
1029
+ if (!hasMinSubTotal)
1030
+ throw `Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido`;
1031
+ return coupon;
1032
+ });
1033
+ }
1034
+ calcDiscountSubscription(coupon, checkout) {
1035
+ let discount = 0;
1036
+ if (coupon.discount.subscription.type == CouponTypes.ABSOLUTE)
1037
+ discount = coupon.discount.subscription.value;
1038
+ else
1039
+ discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount.subscription.value / 100);
1040
+ return of(discount);
1041
+ }
1042
+ calcDiscountShopping(coupon, checkout) {
1043
+ return __awaiter(this, void 0, void 0, function* () {
1044
+ let discount = 0;
1045
+ if (checkout.user.isSubscriber && coupon.discount.subscriber.value) {
1046
+ discount = yield this.calcDiscountByType(coupon.discount.subscriber.type, coupon.discount.subscriber.value, coupon.productsCategories, checkout);
1047
+ }
1048
+ else {
1049
+ discount = yield this.calcDiscountByType(coupon.discount.non_subscriber.type, coupon.discount.non_subscriber.value, coupon.productsCategories, checkout);
1050
+ }
1051
+ return discount;
1052
+ });
1053
+ }
1054
+ calcDiscountByType(type, value, categories, checkout) {
1055
+ return __awaiter(this, void 0, void 0, function* () {
1056
+ let discount = 0;
1057
+ let lineItensDiscount = yield this.getLineItensEligebleForDiscount(categories, checkout);
1058
+ const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
1059
+ if (type == CouponTypes.ABSOLUTE) {
1060
+ discount = value > subTotal ? subTotal : value;
1061
+ }
1062
+ else {
1063
+ discount = subTotal * (value / 100);
1064
+ }
1065
+ return discount;
1066
+ });
1067
+ }
1068
+ hasMinSubTotal(coupon, checkout) {
1069
+ return __awaiter(this, void 0, void 0, function* () {
1070
+ if (!coupon.minSubTotalValue)
1071
+ return true;
1072
+ let lineItensDiscount = yield this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
1073
+ const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
1074
+ if (coupon.minSubTotalValue <= subTotal)
1075
+ return true;
1076
+ return false;
1077
+ });
1078
+ }
1079
+ hasProductCategories(coupon, checkout) {
1080
+ var _a;
1081
+ return __awaiter(this, void 0, void 0, function* () {
1082
+ if (!coupon.productsCategories || !coupon.productsCategories.length) {
1083
+ return true;
1084
+ }
1085
+ const couponCategories = yield this.getCouponCategoriesId(coupon.productsCategories);
1086
+ const hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
1087
+ var _a;
1088
+ if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length))
1089
+ return true;
1090
+ return i.categories.some((c) => couponCategories.some((cat) => cat == c));
1091
+ });
1092
+ return hasCategories.length ? true : false;
1093
+ });
1094
+ }
1095
+ coupomUserValidation(coupon, user) {
1096
+ if (!user || coupon.exclusivityType.includes(Exclusivities.ALL_USERS))
1097
+ return true;
1098
+ let userTypes = [];
1099
+ if (coupon.exclusivityType.includes(Exclusivities.COLLABORATORS) &&
1100
+ this.emailIsFromCollaborator(user.email.toLocaleLowerCase()))
1101
+ userTypes.push(Exclusivities.COLLABORATORS);
1102
+ if (coupon.exclusivityType.includes(Exclusivities.SPECIFIC_USER) &&
1103
+ coupon.userExclusiveEmail.includes(user.email.toLocaleLowerCase()))
1104
+ userTypes.push(Exclusivities.SPECIFIC_USER);
1105
+ if (coupon.exclusivityType.includes(Exclusivities.ACTIVE_SUBSCRIBER) &&
1106
+ user.isSubscriber &&
1107
+ user.subscriptionPlan != '')
1108
+ userTypes.push(Exclusivities.ACTIVE_SUBSCRIBER);
1109
+ if (user.isSubscriber &&
1110
+ user.subscriptionPlan == '' &&
1111
+ coupon.exclusivityType.includes(Exclusivities.INACTIVE_SUBSCRIBER))
1112
+ userTypes.push(Exclusivities.INACTIVE_SUBSCRIBER);
1113
+ if (coupon.exclusivityType.includes(Exclusivities.NON_SUBSCRIBER) && !user.isSubscriber)
1114
+ userTypes.push(Exclusivities.NON_SUBSCRIBER);
1115
+ return coupon.exclusivityType.some((r) => userTypes.includes(r));
1116
+ }
1117
+ getCouponCategoriesId(productsCategories) {
1118
+ return __awaiter(this, void 0, void 0, function* () {
1119
+ const couponCategories = [];
1120
+ for (let index = 0; index < productsCategories.length; index++) {
1121
+ const category = yield this.categoryRepository.get({
1122
+ id: productsCategories[index],
1123
+ });
1124
+ if (category) {
1125
+ const children = yield this.categoryRepository.getChildren(parseInt(productsCategories[index]));
1126
+ couponCategories.push(category.id, ...children.map((c) => c.id.toString()));
1127
+ }
1128
+ }
1129
+ return [...new Set(couponCategories)];
1130
+ });
1131
+ }
1132
+ getLineItensEligebleForDiscount(productsCategories, checkout) {
1133
+ var _a;
1134
+ return __awaiter(this, void 0, void 0, function* () {
1135
+ let lineItensDiscount = [];
1136
+ const couponCategories = yield this.getCouponCategoriesId(productsCategories);
1137
+ if (productsCategories && productsCategories.length) {
1138
+ lineItensDiscount = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
1139
+ var _a;
1140
+ if ((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length) {
1141
+ return i.categories.some((c) => couponCategories.some((cat) => cat == c));
1142
+ }
1143
+ return true;
1144
+ });
1145
+ }
1146
+ else {
1147
+ lineItensDiscount = checkout.lineItems;
1148
+ }
1149
+ return lineItensDiscount;
1150
+ });
1151
+ }
1152
+ calcCheckoutSubtotal(lineItens, user, shop) {
1153
+ return ((lineItens === null || lineItens === void 0 ? void 0 : lineItens.reduce((acc, curr) => {
1154
+ var _a;
1155
+ return (user === null || user === void 0 ? void 0 : user.isSubscriber) && curr.price.subscriberPrice
1156
+ ? acc + ((_a = curr.price) === null || _a === void 0 ? void 0 : _a.subscriberPrice) * curr.quantity
1157
+ : acc + curr.pricePaid * curr.quantity;
1158
+ }, 0)) || 0);
1159
+ }
1160
+ getOrdersWithCoupon(coupon) {
1161
+ return __awaiter(this, void 0, void 0, function* () {
1162
+ return yield this.orderRepository
1163
+ .find({
1164
+ filters: {
1165
+ coupon: { id: coupon.id },
1166
+ payment: { status: 'paid' },
1167
+ },
1168
+ })
1169
+ .then((result) => result.data);
1170
+ });
1171
+ }
1172
+ getOrdersFromUser(email) {
1173
+ return __awaiter(this, void 0, void 0, function* () {
1174
+ return yield this.orderRepository
1175
+ .find({
1176
+ filters: {
1177
+ user: { email: { operator: Where.EQUALS, value: email } },
1178
+ payment: { status: 'paid' },
1179
+ },
1180
+ })
1181
+ .then((result) => result.data);
1182
+ });
1183
+ }
1184
+ countOrdersWithUser(orders, email) {
1185
+ return orders.filter((o) => o.user.email == email).length;
1186
+ }
1187
+ getCouponUseLimits(coupon, checkoutType, user) {
1188
+ let couponUseLimits;
1189
+ if (checkoutType == CheckoutTypes.ECOMMERCE || checkoutType == CheckoutTypes.ALL) {
1190
+ couponUseLimits = user && user.isSubscriber ? coupon.useLimits.subscriber : coupon.useLimits.non_subscriber;
1191
+ }
1192
+ else {
1193
+ couponUseLimits = coupon.useLimits.subscription;
1194
+ }
1195
+ return couponUseLimits;
1196
+ }
1197
+ }
1198
+ CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1199
+ CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, providedIn: 'root' });
1200
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, decorators: [{
1201
+ type: Injectable,
1202
+ args: [{
1203
+ providedIn: 'root',
1204
+ }]
1205
+ }], ctorParameters: function () {
1206
+ return [{ type: undefined, decorators: [{
1207
+ type: Inject,
1208
+ args: ['CouponRepository']
1209
+ }] }, { type: i1$2.Shops, decorators: [{
1210
+ type: Inject,
1211
+ args: [DEFAULT_SHOP]
1212
+ }] }, { type: undefined, decorators: [{
1213
+ type: Inject,
1214
+ args: ['OrderRepository']
1215
+ }] }, { type: undefined, decorators: [{
1216
+ type: Inject,
1217
+ args: ['CategoryRepository']
1218
+ }] }];
1219
1219
  } });
1220
1220
 
1221
- class CheckoutService {
1222
- constructor(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
1223
- this.couponService = couponService;
1224
- this.checkoutRepository = checkoutRepository;
1225
- this.orderRepository = orderRepository;
1226
- this.userRepository = userRepository;
1227
- this.defaultShop = defaultShop;
1228
- }
1229
- getCheckout(checkoutData) {
1230
- const checkoutId = cookie.get('checkoutId');
1231
- if (!isNil(checkoutId))
1232
- return from(this.checkoutRepository.get({ id: checkoutId }));
1233
- return from(this.createCheckout(checkoutData));
1234
- }
1235
- getUserByCheckout(checkoutId) {
1236
- 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'))));
1237
- }
1238
- updateCheckoutLineItems(checkout) {
1239
- return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
1240
- }
1241
- updateCheckoutUser(checkout) {
1242
- return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
1243
- }
1244
- clearCheckoutFromSession() {
1245
- cookie.remove('checkoutId');
1246
- return of();
1247
- }
1248
- calcDiscount(coupon) {
1249
- return this.getCheckout().pipe(concatMap((checkout) => __awaiter(this, void 0, void 0, function* () { return yield this.couponService.calcDiscountShopping(coupon, checkout); })));
1250
- }
1251
- checkCoupon(nickname, checkoutType) {
1252
- return this.getCheckout().pipe(concatMap((checkout) => this.couponService.checkCoupon(nickname, CheckoutTypes.ECOMMERCE, checkout, null).pipe()));
1253
- }
1254
- createCheckout(checkoutData) {
1255
- return __awaiter(this, void 0, void 0, function* () {
1256
- 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 }));
1257
- cookie.set('checkoutId', checkout.id);
1258
- return checkout;
1259
- });
1260
- }
1261
- }
1262
- CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'OrderRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
1263
- CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService });
1264
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, decorators: [{
1265
- type: Injectable
1266
- }], ctorParameters: function () {
1267
- return [{ type: CouponService }, { type: undefined, decorators: [{
1268
- type: Inject,
1269
- args: ['CheckoutRepository']
1270
- }] }, { type: undefined, decorators: [{
1271
- type: Inject,
1272
- args: ['OrderRepository']
1273
- }] }, { type: undefined, decorators: [{
1274
- type: Inject,
1275
- args: ['UserRepository']
1276
- }] }, { type: i1$2.Shops, decorators: [{
1277
- type: Inject,
1278
- args: [DEFAULT_SHOP]
1279
- }] }];
1221
+ class CheckoutService {
1222
+ constructor(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
1223
+ this.couponService = couponService;
1224
+ this.checkoutRepository = checkoutRepository;
1225
+ this.orderRepository = orderRepository;
1226
+ this.userRepository = userRepository;
1227
+ this.defaultShop = defaultShop;
1228
+ }
1229
+ getCheckout(checkoutData) {
1230
+ const checkoutId = cookie.get('checkoutId');
1231
+ if (!isNil(checkoutId))
1232
+ return from(this.checkoutRepository.get({ id: checkoutId }));
1233
+ return from(this.createCheckout(checkoutData));
1234
+ }
1235
+ getUserByCheckout(checkoutId) {
1236
+ 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'))));
1237
+ }
1238
+ updateCheckoutLineItems(checkout) {
1239
+ return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
1240
+ }
1241
+ updateCheckoutUser(checkout) {
1242
+ return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
1243
+ }
1244
+ clearCheckoutFromSession() {
1245
+ cookie.remove('checkoutId');
1246
+ return of();
1247
+ }
1248
+ calcDiscount(coupon) {
1249
+ return this.getCheckout().pipe(concatMap((checkout) => __awaiter(this, void 0, void 0, function* () { return yield this.couponService.calcDiscountShopping(coupon, checkout); })));
1250
+ }
1251
+ checkCoupon(nickname, checkoutType) {
1252
+ return this.getCheckout().pipe(concatMap((checkout) => this.couponService.checkCoupon(nickname, CheckoutTypes.ECOMMERCE, checkout, null).pipe()));
1253
+ }
1254
+ createCheckout(checkoutData) {
1255
+ return __awaiter(this, void 0, void 0, function* () {
1256
+ 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 }));
1257
+ cookie.set('checkoutId', checkout.id);
1258
+ return checkout;
1259
+ });
1260
+ }
1261
+ }
1262
+ CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'OrderRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
1263
+ CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService });
1264
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, decorators: [{
1265
+ type: Injectable
1266
+ }], ctorParameters: function () {
1267
+ return [{ type: CouponService }, { type: undefined, decorators: [{
1268
+ type: Inject,
1269
+ args: ['CheckoutRepository']
1270
+ }] }, { type: undefined, decorators: [{
1271
+ type: Inject,
1272
+ args: ['OrderRepository']
1273
+ }] }, { type: undefined, decorators: [{
1274
+ type: Inject,
1275
+ args: ['UserRepository']
1276
+ }] }, { type: i1$2.Shops, decorators: [{
1277
+ type: Inject,
1278
+ args: [DEFAULT_SHOP]
1279
+ }] }];
1280
1280
  } });
1281
1281
 
1282
- class CartService {
1283
- constructor(authService, checkoutService, defaultShop, productRepository, categoryRepository, variantRepository, buy2WinRepository) {
1284
- this.authService = authService;
1285
- this.checkoutService = checkoutService;
1286
- this.defaultShop = defaultShop;
1287
- this.productRepository = productRepository;
1288
- this.categoryRepository = categoryRepository;
1289
- this.variantRepository = variantRepository;
1290
- this.buy2WinRepository = buy2WinRepository;
1291
- this.cartSubject = new Subject();
1292
- this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
1293
- var _a;
1294
- const items = [];
1295
- const index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map((checkoutItem) => checkoutItem.id).indexOf(lineItem.id);
1296
- if (index > -1) {
1297
- checkoutLoaded.lineItems[index].quantity += quantity;
1298
- checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
1299
- }
1300
- else
1301
- checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
1302
- return this.checkoutService
1303
- .updateCheckoutLineItems(checkoutLoaded)
1304
- .pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
1305
- }));
1306
- this.generateCartObject = (items) => (items === null || items === void 0 ? void 0 : items.reduce((cart, item) => {
1307
- var _a;
1308
- return (Object.assign(Object.assign({}, cart), { [item.id]: LineItem.toInstance(Object.assign(Object.assign({}, (cart[item.id] || item)), { quantity: (((_a = cart[item.id]) === null || _a === void 0 ? void 0 : _a.quantity) || 0) + (item.quantity ? item.quantity : 1) })) }));
1309
- }, {})) || {};
1310
- this.buildLineItem = ({ checkout, item, quantity, }) => __awaiter(this, void 0, void 0, function* () {
1311
- var _a, _b, _c, _d, _e, _f, _g;
1312
- const product = yield this.getProductData(item.id);
1313
- 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.id === item.id)) === null || _b === void 0 ? void 0 : _b.quantity) || 0;
1314
- if (this.checkMaxStock(item, quantity || 0))
1315
- throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
1316
- const image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
1317
- const { id, name, EAN, slug, stock, price, weight, sku, type } = item;
1318
- const isGift = item.isGift || null;
1319
- const pricePaid = this.getProductPrice({
1320
- product: item,
1321
- shop: checkout.shop || this.defaultShop,
1322
- isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
1323
- });
1324
- RoundProductPricesHelper.roundProductPrices(item);
1325
- console.log('buildLineItem', product.name, pricePaid);
1326
- return {
1327
- checkout,
1328
- lineItem: LineItem.toInstance({
1329
- id,
1330
- name: name !== null && name !== void 0 ? name : product.name,
1331
- EAN: EAN !== null && EAN !== void 0 ? EAN : product.EAN,
1332
- brand: product.brand,
1333
- slug: slug !== null && slug !== void 0 ? slug : product.slug,
1334
- sku: sku !== null && sku !== void 0 ? sku : product.sku,
1335
- stock,
1336
- price: this.roundPrice(price),
1337
- image,
1338
- weight: weight !== null && weight !== void 0 ? weight : product.weight,
1339
- quantity: (item.quantity || 0) + (quantity || 0),
1340
- pricePaid,
1341
- categories: (_f = product.categories) !== null && _f !== void 0 ? _f : [],
1342
- isGift: isGift !== null && isGift !== void 0 ? isGift : null,
1343
- costPrice: (_g = product.costPrice) !== null && _g !== void 0 ? _g : 0,
1344
- type,
1345
- }),
1346
- };
1347
- });
1348
- this.getProductPrice = ({ product, isSubscriber, }) => {
1349
- const info = product.price;
1350
- if (product.isGift)
1351
- return 0;
1352
- return isSubscriber && info.subscriberPrice > 0
1353
- ? Number(info.subscriberPrice.toFixed(2))
1354
- : Number(info.price.toFixed(2));
1355
- };
1356
- this.checkMaxStock = (item, quantity) => {
1357
- var _a;
1358
- const maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
1359
- const currentItemAmount = item.quantity || 0;
1360
- return currentItemAmount + quantity > maxStock;
1361
- };
1362
- }
1363
- addItem(item, quantity = 1) {
1364
- 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)));
1365
- }
1366
- decreaseItem(item) {
1367
- return this.checkoutService.getCheckout().pipe(map((checkout) => {
1368
- var _a;
1369
- const checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.id === item.id);
1370
- if (!isNil(checkoutItem))
1371
- checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
1372
- return checkout;
1373
- }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1374
- }
1375
- getCart(checkout) {
1376
- this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
1377
- return this.cartSubject;
1378
- }
1379
- /**
1380
- * @deprecated The method should not be used
1381
- */
1382
- getVariantPriceDiscount(item) {
1383
- 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)));
1384
- }
1385
- removeItem(item) {
1386
- return this.checkoutService.getCheckout().pipe(map((checkout) => {
1387
- const index = checkout.lineItems.findIndex((lineItem) => lineItem.id === item.id);
1388
- if (index >= 0)
1389
- checkout.lineItems.splice(index, 1);
1390
- return checkout;
1391
- }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1392
- }
1393
- updateUserCart(user) {
1394
- 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* () {
1395
- var _a, _b;
1396
- return yield this.checkoutService
1397
- .updateCheckoutLineItems(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.length)
1398
- ? 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; })))
1399
- : [] })))
1400
- .toPromise();
1401
- })), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1402
- }
1403
- clearCart() {
1404
- return this.checkoutService.getCheckout().pipe(map((checkout) => {
1405
- this.checkoutService.clearCheckoutFromSession();
1406
- return checkout;
1407
- }), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
1408
- }
1409
- buildCartFromCheckout(checkoutData) {
1410
- return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
1411
- }
1412
- roundPrice(productPrice) {
1413
- const { price, fullPrice, subscriberPrice } = productPrice;
1414
- return Object.assign(Object.assign(Object.assign({}, productPrice), { price: Number(price.toFixed(2)), fullPrice: Number(fullPrice.toFixed(2)) }), (subscriberPrice && { subscriberPrice: Number(subscriberPrice.toFixed(2)) }));
1415
- }
1416
- getProductData(productId) {
1417
- return __awaiter(this, void 0, void 0, function* () {
1418
- let product;
1419
- let variant;
1420
- try {
1421
- product = yield this.productRepository.get({ id: productId });
1422
- }
1423
- catch (error) {
1424
- if (!(error instanceof NotFoundError))
1425
- throw error;
1426
- const { data: variants } = yield this.variantRepository.find({ filters: { id: productId } });
1427
- variant = variants.shift();
1428
- if (!variant)
1429
- throw error;
1430
- product = yield this.productRepository.get({ id: variant.productId });
1431
- }
1432
- return Object.assign(Object.assign({}, product.toPlain()), (variant && Object.assign({}, variant.toPlain())));
1433
- });
1434
- }
1435
- getGifts() {
1436
- return this.checkoutService.getCheckout().pipe(mergeMap((checkout) => __awaiter(this, void 0, void 0, function* () {
1437
- const notGiftItems = checkout.lineItems ? checkout.lineItems.filter((item) => !item.isGift) : [];
1438
- if (!notGiftItems.length)
1439
- return Object.assign(Object.assign({}, checkout), { lineItems: [] });
1440
- const cartTotal = notGiftItems.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
1441
- const campaigns = yield this.buy2WinRepository
1442
- .find({
1443
- filters: {
1444
- active: { operator: Where.EQUALS, value: true },
1445
- shop: { operator: Where.EQUALS, value: this.defaultShop },
1446
- },
1447
- })
1448
- .then((data) => data.data);
1449
- if (!campaigns.length)
1450
- return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
1451
- const elegibleCampaigns = [];
1452
- for (const campaign of campaigns) {
1453
- const today = new Date().getTime();
1454
- if (!(campaign.startDate.getTime() <= today) && !(campaign.endDate.getTime() >= today))
1455
- continue;
1456
- if (campaign.activeCategory) {
1457
- const categoriesCampaing = campaign.categories.map((c) => c.id.toString());
1458
- const categoriesCampaingFullTree = [];
1459
- for (const id of categoriesCampaing) {
1460
- const children = yield this.categoryRepository.getChildren(parseInt(id));
1461
- categoriesCampaingFullTree.push(id, ...children.map((c) => c.id.toString()));
1462
- }
1463
- const categoriesCampaingTree = [...new Set(categoriesCampaingFullTree)];
1464
- const filterProductsCategories = checkout.lineItems.filter((l) => {
1465
- var _a;
1466
- if (!l.categories || !((_a = l.categories) === null || _a === void 0 ? void 0 : _a.length))
1467
- return true;
1468
- return l.categories.some((c) => categoriesCampaingTree.some((cat) => cat == c));
1469
- });
1470
- if (filterProductsCategories.length) {
1471
- const cartTotalCategories = filterProductsCategories.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
1472
- if (cartTotalCategories >= campaign.cartValueMin)
1473
- elegibleCampaigns.push(campaign);
1474
- }
1475
- }
1476
- else {
1477
- if (campaign.cartValue && campaign.cartValue > 0) {
1478
- if (campaign.cartValue <= cartTotal)
1479
- elegibleCampaigns.push(campaign);
1480
- }
1481
- }
1482
- }
1483
- if (!elegibleCampaigns.length)
1484
- return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
1485
- const campaingnProducts = [];
1486
- for (const campaign of elegibleCampaigns) {
1487
- let elegibleProducts = [];
1488
- for (const product of campaign.products) {
1489
- const { data: productData } = yield this.productRepository.find({ filters: { sku: product } });
1490
- if (!productData.length)
1491
- continue;
1492
- const gift = productData.shift();
1493
- if (gift.stock.quantity < 1)
1494
- continue;
1495
- elegibleProducts.push(gift);
1496
- }
1497
- campaingnProducts.push(elegibleProducts);
1498
- }
1499
- if (!campaingnProducts.length)
1500
- return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
1501
- const gifts = this.giftToLineItems([].concat(...campaingnProducts));
1502
- return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems.concat(gifts) });
1503
- })), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1504
- }
1505
- giftToLineItems(items) {
1506
- return items.map((item) => {
1507
- var _a;
1508
- const { brand, categories, id, name, price, sku, slug, stock, weight, EAN } = item;
1509
- const image = ((_a = item === null || item === void 0 ? void 0 : item.miniatures) === null || _a === void 0 ? void 0 : _a.length) ? item.miniatures[0] : item.images[0];
1510
- return LineItem.toInstance({
1511
- brand,
1512
- categories,
1513
- id: id.toString(),
1514
- name,
1515
- price,
1516
- sku,
1517
- slug,
1518
- stock,
1519
- weight,
1520
- EAN,
1521
- image,
1522
- pricePaid: 0,
1523
- quantity: 1,
1524
- isGift: true,
1525
- });
1526
- });
1527
- }
1528
- }
1529
- CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'VariantRepository' }, { token: 'Buy2WinRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1530
- CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService });
1531
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, decorators: [{
1532
- type: Injectable
1533
- }], ctorParameters: function () {
1534
- return [{ type: AuthService }, { type: CheckoutService }, { type: i1$2.Shops, decorators: [{
1535
- type: Inject,
1536
- args: [DEFAULT_SHOP]
1537
- }] }, { type: undefined, decorators: [{
1538
- type: Inject,
1539
- args: ['ProductRepository']
1540
- }] }, { type: undefined, decorators: [{
1541
- type: Inject,
1542
- args: ['CategoryRepository']
1543
- }] }, { type: undefined, decorators: [{
1544
- type: Inject,
1545
- args: ['VariantRepository']
1546
- }] }, { type: i1$2.Buy2WinFirestoreRepository, decorators: [{
1547
- type: Inject,
1548
- args: ['Buy2WinRepository']
1549
- }] }];
1282
+ class CartService {
1283
+ constructor(authService, checkoutService, defaultShop, productRepository, categoryRepository, variantRepository, buy2WinRepository) {
1284
+ this.authService = authService;
1285
+ this.checkoutService = checkoutService;
1286
+ this.defaultShop = defaultShop;
1287
+ this.productRepository = productRepository;
1288
+ this.categoryRepository = categoryRepository;
1289
+ this.variantRepository = variantRepository;
1290
+ this.buy2WinRepository = buy2WinRepository;
1291
+ this.cartSubject = new Subject();
1292
+ this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
1293
+ var _a;
1294
+ const items = [];
1295
+ const index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map((checkoutItem) => checkoutItem.id).indexOf(lineItem.id);
1296
+ if (index > -1) {
1297
+ checkoutLoaded.lineItems[index].quantity += quantity;
1298
+ checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
1299
+ }
1300
+ else
1301
+ checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
1302
+ return this.checkoutService
1303
+ .updateCheckoutLineItems(checkoutLoaded)
1304
+ .pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
1305
+ }));
1306
+ this.generateCartObject = (items) => (items === null || items === void 0 ? void 0 : items.reduce((cart, item) => {
1307
+ var _a;
1308
+ return (Object.assign(Object.assign({}, cart), { [item.id]: LineItem.toInstance(Object.assign(Object.assign({}, (cart[item.id] || item)), { quantity: (((_a = cart[item.id]) === null || _a === void 0 ? void 0 : _a.quantity) || 0) + (item.quantity ? item.quantity : 1) })) }));
1309
+ }, {})) || {};
1310
+ this.buildLineItem = ({ checkout, item, quantity, }) => __awaiter(this, void 0, void 0, function* () {
1311
+ var _a, _b, _c, _d, _e, _f, _g;
1312
+ const product = yield this.getProductData(item.id);
1313
+ 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.id === item.id)) === null || _b === void 0 ? void 0 : _b.quantity) || 0;
1314
+ if (this.checkMaxStock(item, quantity || 0))
1315
+ throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
1316
+ const image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
1317
+ const { id, name, EAN, slug, stock, price, weight, sku, type } = item;
1318
+ const isGift = item.isGift || null;
1319
+ const pricePaid = this.getProductPrice({
1320
+ product: item,
1321
+ shop: checkout.shop || this.defaultShop,
1322
+ isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
1323
+ });
1324
+ RoundProductPricesHelper.roundProductPrices(item);
1325
+ return {
1326
+ checkout,
1327
+ lineItem: LineItem.toInstance({
1328
+ id,
1329
+ name: name !== null && name !== void 0 ? name : product.name,
1330
+ EAN: EAN !== null && EAN !== void 0 ? EAN : product.EAN,
1331
+ brand: product.brand,
1332
+ slug: slug !== null && slug !== void 0 ? slug : product.slug,
1333
+ sku: sku !== null && sku !== void 0 ? sku : product.sku,
1334
+ stock,
1335
+ price: this.roundPrice(price),
1336
+ image,
1337
+ weight: weight !== null && weight !== void 0 ? weight : product.weight,
1338
+ quantity: (item.quantity || 0) + (quantity || 0),
1339
+ pricePaid,
1340
+ categories: (_f = product.categories) !== null && _f !== void 0 ? _f : [],
1341
+ isGift: isGift !== null && isGift !== void 0 ? isGift : null,
1342
+ costPrice: (_g = product.costPrice) !== null && _g !== void 0 ? _g : 0,
1343
+ type,
1344
+ }),
1345
+ };
1346
+ });
1347
+ this.getProductPrice = ({ product, isSubscriber, }) => {
1348
+ const info = product.price;
1349
+ if (product.isGift)
1350
+ return 0;
1351
+ return isSubscriber && info.subscriberPrice > 0
1352
+ ? Number(info.subscriberPrice.toFixed(2))
1353
+ : Number(info.price.toFixed(2));
1354
+ };
1355
+ this.checkMaxStock = (item, quantity) => {
1356
+ var _a;
1357
+ const maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
1358
+ const currentItemAmount = item.quantity || 0;
1359
+ return currentItemAmount + quantity > maxStock;
1360
+ };
1361
+ }
1362
+ addItem(item, quantity = 1) {
1363
+ 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)));
1364
+ }
1365
+ decreaseItem(item) {
1366
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
1367
+ var _a;
1368
+ const checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.id === item.id);
1369
+ if (!isNil(checkoutItem))
1370
+ checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
1371
+ return checkout;
1372
+ }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1373
+ }
1374
+ getCart(checkout) {
1375
+ this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
1376
+ return this.cartSubject;
1377
+ }
1378
+ /**
1379
+ * @deprecated The method should not be used
1380
+ */
1381
+ getVariantPriceDiscount(item) {
1382
+ 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)));
1383
+ }
1384
+ removeItem(item) {
1385
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
1386
+ const index = checkout.lineItems.findIndex((lineItem) => lineItem.id === item.id);
1387
+ if (index >= 0)
1388
+ checkout.lineItems.splice(index, 1);
1389
+ return checkout;
1390
+ }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1391
+ }
1392
+ updateUserCart(user) {
1393
+ 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* () {
1394
+ var _a, _b;
1395
+ return yield this.checkoutService
1396
+ .updateCheckoutLineItems(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.length)
1397
+ ? 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; })))
1398
+ : [] })))
1399
+ .toPromise();
1400
+ })), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1401
+ }
1402
+ clearCart() {
1403
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
1404
+ this.checkoutService.clearCheckoutFromSession();
1405
+ return checkout;
1406
+ }), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
1407
+ }
1408
+ buildCartFromCheckout(checkoutData) {
1409
+ return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
1410
+ }
1411
+ roundPrice(productPrice) {
1412
+ const { price, fullPrice, subscriberPrice } = productPrice;
1413
+ return Object.assign(Object.assign(Object.assign({}, productPrice), { price: Number(price.toFixed(2)), fullPrice: Number(fullPrice.toFixed(2)) }), (subscriberPrice && { subscriberPrice: Number(subscriberPrice.toFixed(2)) }));
1414
+ }
1415
+ getProductData(productId) {
1416
+ return __awaiter(this, void 0, void 0, function* () {
1417
+ let product;
1418
+ let variant;
1419
+ try {
1420
+ product = yield this.productRepository.get({ id: productId });
1421
+ }
1422
+ catch (error) {
1423
+ if (!(error instanceof NotFoundError))
1424
+ throw error;
1425
+ const { data: variants } = yield this.variantRepository.find({ filters: { id: productId } });
1426
+ variant = variants.shift();
1427
+ if (!variant)
1428
+ throw error;
1429
+ product = yield this.productRepository.get({ id: variant.productId });
1430
+ }
1431
+ return Object.assign(Object.assign({}, product.toPlain()), (variant && Object.assign({}, variant.toPlain())));
1432
+ });
1433
+ }
1434
+ getGifts() {
1435
+ return this.checkoutService.getCheckout().pipe(mergeMap((checkout) => __awaiter(this, void 0, void 0, function* () {
1436
+ const notGiftItems = checkout.lineItems ? checkout.lineItems.filter((item) => !item.isGift) : [];
1437
+ if (!notGiftItems.length)
1438
+ return Object.assign(Object.assign({}, checkout), { lineItems: [] });
1439
+ const cartTotal = notGiftItems.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
1440
+ const campaigns = yield this.buy2WinRepository
1441
+ .find({
1442
+ filters: {
1443
+ active: { operator: Where.EQUALS, value: true },
1444
+ shop: { operator: Where.EQUALS, value: this.defaultShop },
1445
+ },
1446
+ })
1447
+ .then((data) => data.data);
1448
+ if (!campaigns.length)
1449
+ return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
1450
+ const elegibleCampaigns = [];
1451
+ for (const campaign of campaigns) {
1452
+ const today = new Date().getTime();
1453
+ if (!(campaign.startDate.getTime() <= today) && !(campaign.endDate.getTime() >= today))
1454
+ continue;
1455
+ if (campaign.activeCategory) {
1456
+ const categoriesCampaing = campaign.categories.map((c) => c.id.toString());
1457
+ const categoriesCampaingFullTree = [];
1458
+ for (const id of categoriesCampaing) {
1459
+ const children = yield this.categoryRepository.getChildren(parseInt(id));
1460
+ categoriesCampaingFullTree.push(id, ...children.map((c) => c.id.toString()));
1461
+ }
1462
+ const categoriesCampaingTree = [...new Set(categoriesCampaingFullTree)];
1463
+ const filterProductsCategories = checkout.lineItems.filter((l) => {
1464
+ var _a;
1465
+ if (!l.categories || !((_a = l.categories) === null || _a === void 0 ? void 0 : _a.length))
1466
+ return true;
1467
+ return l.categories.some((c) => categoriesCampaingTree.some((cat) => cat == c));
1468
+ });
1469
+ if (filterProductsCategories.length) {
1470
+ const cartTotalCategories = filterProductsCategories.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
1471
+ if (cartTotalCategories >= campaign.cartValueMin)
1472
+ elegibleCampaigns.push(campaign);
1473
+ }
1474
+ }
1475
+ else {
1476
+ if (campaign.cartValue && campaign.cartValue > 0) {
1477
+ if (campaign.cartValue <= cartTotal)
1478
+ elegibleCampaigns.push(campaign);
1479
+ }
1480
+ }
1481
+ }
1482
+ if (!elegibleCampaigns.length)
1483
+ return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
1484
+ const campaingnProducts = [];
1485
+ for (const campaign of elegibleCampaigns) {
1486
+ let elegibleProducts = [];
1487
+ for (const product of campaign.products) {
1488
+ const { data: productData } = yield this.productRepository.find({ filters: { sku: product } });
1489
+ if (!productData.length)
1490
+ continue;
1491
+ const gift = productData.shift();
1492
+ if (gift.stock.quantity < 1)
1493
+ continue;
1494
+ elegibleProducts.push(gift);
1495
+ }
1496
+ campaingnProducts.push(elegibleProducts);
1497
+ }
1498
+ if (!campaingnProducts.length)
1499
+ return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
1500
+ const gifts = this.giftToLineItems([].concat(...campaingnProducts));
1501
+ return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems.concat(gifts) });
1502
+ })), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1503
+ }
1504
+ giftToLineItems(items) {
1505
+ return items.map((item) => {
1506
+ var _a;
1507
+ const { brand, categories, id, name, price, sku, slug, stock, weight, EAN } = item;
1508
+ const image = ((_a = item === null || item === void 0 ? void 0 : item.miniatures) === null || _a === void 0 ? void 0 : _a.length) ? item.miniatures[0] : item.images[0];
1509
+ return LineItem.toInstance({
1510
+ brand,
1511
+ categories,
1512
+ id: id.toString(),
1513
+ name,
1514
+ price,
1515
+ sku,
1516
+ slug,
1517
+ stock,
1518
+ weight,
1519
+ EAN,
1520
+ image,
1521
+ pricePaid: 0,
1522
+ quantity: 1,
1523
+ isGift: true,
1524
+ });
1525
+ });
1526
+ }
1527
+ }
1528
+ CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'VariantRepository' }, { token: 'Buy2WinRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1529
+ CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService });
1530
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, decorators: [{
1531
+ type: Injectable
1532
+ }], ctorParameters: function () {
1533
+ return [{ type: AuthService }, { type: CheckoutService }, { type: i1$2.Shops, decorators: [{
1534
+ type: Inject,
1535
+ args: [DEFAULT_SHOP]
1536
+ }] }, { type: undefined, decorators: [{
1537
+ type: Inject,
1538
+ args: ['ProductRepository']
1539
+ }] }, { type: undefined, decorators: [{
1540
+ type: Inject,
1541
+ args: ['CategoryRepository']
1542
+ }] }, { type: undefined, decorators: [{
1543
+ type: Inject,
1544
+ args: ['VariantRepository']
1545
+ }] }, { type: i1$2.Buy2WinFirestoreRepository, decorators: [{
1546
+ type: Inject,
1547
+ args: ['Buy2WinRepository']
1548
+ }] }];
1550
1549
  } });
1551
1550
 
1552
- class NewCategoryStructureAdapter {
1553
- constructor(categoryRepository) {
1554
- this.categoryRepository = categoryRepository;
1555
- }
1556
- buildProductFilterByCategory(category) {
1557
- return __awaiter(this, void 0, void 0, function* () {
1558
- const loadedCategory = yield this.getCategory(category);
1559
- if (loadedCategory.isCollection)
1560
- return { id: { operator: Where.IN, value: loadedCategory.products } };
1561
- const categoryIds = [...(yield this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
1562
- return {
1563
- category: {
1564
- id: {
1565
- operator: Where.IN,
1566
- value: categoryIds,
1567
- },
1568
- },
1569
- };
1570
- });
1571
- }
1572
- getAllCategoriesIdFromCategory(category) {
1573
- return __awaiter(this, void 0, void 0, function* () {
1574
- return this.categoryRepository
1575
- .getChildren(+category.id)
1576
- .then((categories) => categories.map((category) => category.id.toString()));
1577
- });
1578
- }
1579
- getCategory(category) {
1580
- var _a;
1581
- return __awaiter(this, void 0, void 0, function* () {
1582
- return isNil(category.isCollection) || (category.isCollection && !((_a = category.products) === null || _a === void 0 ? void 0 : _a.length))
1583
- ? this.categoryRepository.get({ id: category.id })
1584
- : category;
1585
- });
1586
- }
1587
- }
1588
- NewCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1589
- NewCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter });
1590
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, decorators: [{
1591
- type: Injectable
1592
- }], ctorParameters: function () {
1593
- return [{ type: undefined, decorators: [{
1594
- type: Inject,
1595
- args: ['CategoryRepository']
1596
- }] }];
1551
+ class NewCategoryStructureAdapter {
1552
+ constructor(categoryRepository) {
1553
+ this.categoryRepository = categoryRepository;
1554
+ }
1555
+ buildProductFilterByCategory(category) {
1556
+ return __awaiter(this, void 0, void 0, function* () {
1557
+ const loadedCategory = yield this.getCategory(category);
1558
+ if (loadedCategory.isCollection)
1559
+ return { id: { operator: Where.IN, value: loadedCategory.products } };
1560
+ const categoryIds = [...(yield this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
1561
+ return {
1562
+ category: {
1563
+ id: {
1564
+ operator: Where.IN,
1565
+ value: categoryIds,
1566
+ },
1567
+ },
1568
+ };
1569
+ });
1570
+ }
1571
+ getAllCategoriesIdFromCategory(category) {
1572
+ return __awaiter(this, void 0, void 0, function* () {
1573
+ return this.categoryRepository
1574
+ .getChildren(+category.id)
1575
+ .then((categories) => categories.map((category) => category.id.toString()));
1576
+ });
1577
+ }
1578
+ getCategory(category) {
1579
+ var _a;
1580
+ return __awaiter(this, void 0, void 0, function* () {
1581
+ return isNil(category.isCollection) || (category.isCollection && !((_a = category.products) === null || _a === void 0 ? void 0 : _a.length))
1582
+ ? this.categoryRepository.get({ id: category.id })
1583
+ : category;
1584
+ });
1585
+ }
1586
+ }
1587
+ NewCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1588
+ NewCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter });
1589
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, decorators: [{
1590
+ type: Injectable
1591
+ }], ctorParameters: function () {
1592
+ return [{ type: undefined, decorators: [{
1593
+ type: Inject,
1594
+ args: ['CategoryRepository']
1595
+ }] }];
1597
1596
  } });
1598
1597
 
1599
- class OldCategoryStructureAdapter {
1600
- constructor(categoryRepository) {
1601
- this.categoryRepository = categoryRepository;
1602
- }
1603
- buildProductFilterByCategory(category) {
1604
- var _a;
1605
- return __awaiter(this, void 0, void 0, function* () {
1606
- const productsIds = ((_a = category.products) === null || _a === void 0 ? void 0 : _a.length)
1607
- ? category.products
1608
- : yield this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
1609
- return { id: { operator: Where.IN, value: productsIds } };
1610
- });
1611
- }
1612
- }
1613
- OldCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1614
- OldCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter });
1615
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, decorators: [{
1616
- type: Injectable
1617
- }], ctorParameters: function () {
1618
- return [{ type: undefined, decorators: [{
1619
- type: Inject,
1620
- args: ['CategoryRepository']
1621
- }] }];
1598
+ class OldCategoryStructureAdapter {
1599
+ constructor(categoryRepository) {
1600
+ this.categoryRepository = categoryRepository;
1601
+ }
1602
+ buildProductFilterByCategory(category) {
1603
+ var _a;
1604
+ return __awaiter(this, void 0, void 0, function* () {
1605
+ const productsIds = ((_a = category.products) === null || _a === void 0 ? void 0 : _a.length)
1606
+ ? category.products
1607
+ : yield this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
1608
+ return { id: { operator: Where.IN, value: productsIds } };
1609
+ });
1610
+ }
1611
+ }
1612
+ OldCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1613
+ OldCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter });
1614
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, decorators: [{
1615
+ type: Injectable
1616
+ }], ctorParameters: function () {
1617
+ return [{ type: undefined, decorators: [{
1618
+ type: Inject,
1619
+ args: ['CategoryRepository']
1620
+ }] }];
1622
1621
  } });
1623
1622
 
1624
- class CatalogService {
1625
- constructor(productRepository, categoryRepository, categoryStructureAdapter, shop, productIndex) {
1626
- this.productRepository = productRepository;
1627
- this.categoryRepository = categoryRepository;
1628
- this.categoryStructureAdapter = categoryStructureAdapter;
1629
- this.shop = shop;
1630
- this.productIndex = productIndex;
1631
- this.productsByTerm = {};
1632
- this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, tags, rate, customOptions, }) => {
1633
- const filters = {};
1634
- if (clubDiscount === null || clubDiscount === void 0 ? void 0 : clubDiscount.length)
1635
- set(filters, 'price.subscriberDiscountPercentage', { operator: Where.IN, value: clubDiscount });
1636
- if (brands === null || brands === void 0 ? void 0 : brands.length)
1637
- filters.brand = { operator: Where.IN, value: brands };
1638
- if (gender === null || gender === void 0 ? void 0 : gender.length)
1639
- filters.gender = { operator: Where.IN, value: gender };
1640
- if ((prices === null || prices === void 0 ? void 0 : prices.min) || (prices === null || prices === void 0 ? void 0 : prices.max))
1641
- set(filters, prices.subscriberPrice ? 'price.subscriberPrice' : 'price.price', [
1642
- ...(prices.min ? [{ operator: Where.GTE, value: Math.round(prices.min) }] : []),
1643
- ...(prices.max ? [{ operator: Where.LTE, value: Math.ceil(prices.max) }] : []),
1644
- ]);
1645
- if (rate)
1646
- filters.rate = { operator: Where.GTE, value: rate };
1647
- if (tags === null || tags === void 0 ? void 0 : tags.length)
1648
- filters.tags = { operator: Where.LIKE, value: tags };
1649
- if (customOptions === null || customOptions === void 0 ? void 0 : customOptions.length)
1650
- filters.filters = { operator: Where.LIKE, value: customOptions };
1651
- return filters;
1652
- };
1653
- this.buildSortQuery = (sort) => {
1654
- if (!sort || sort === 'most-relevant')
1655
- return {};
1656
- if (sort === 'best-sellers')
1657
- return { shoppingCount: 'desc' };
1658
- if (sort === 'biggest-price')
1659
- return { subscriberPrice: 'desc' };
1660
- if (sort === 'lowest-price')
1661
- return { subscriberPrice: 'asc' };
1662
- if (sort === 'best-rating')
1663
- return { rate: 'desc' };
1664
- if (sort === 'news')
1665
- return { createdAt: 'desc' };
1666
- if (sort === 'biggest-discount')
1667
- return { subscriberDiscountPercentage: 'desc' };
1668
- };
1669
- this.buildLimitQuery = (options) => {
1670
- const limit = (options === null || options === void 0 ? void 0 : options.perPage) || 20;
1671
- return {
1672
- limit,
1673
- offset: (((options === null || options === void 0 ? void 0 : options.page) || 1) - 1) * limit,
1674
- };
1675
- };
1676
- this.hasProfile = (options) => 'profile' in options;
1677
- this.hasTerm = (options) => 'term' in options;
1678
- this.hasCategory = (options) => 'category' in options;
1679
- }
1680
- fetchProducts(options) {
1681
- var _a, _b, _c;
1682
- return __awaiter(this, void 0, void 0, function* () {
1683
- const limits = this.buildLimitQuery(options);
1684
- if (this.hasProfile(options) && ((_a = options.filters) === null || _a === void 0 ? void 0 : _a.customOptions))
1685
- throw new InvalidArgumentError(`It couldn't filled customOptions when profile is given`);
1686
- if (this.hasProfile(options) && ((_b = options.filters) === null || _b === void 0 ? void 0 : _b.tags))
1687
- throw new InvalidArgumentError(`It couldn't filled tags when profile is given`);
1688
- if (this.hasTerm(options) && ((_c = options.filters) === null || _c === void 0 ? void 0 : _c.customOptions))
1689
- throw new InvalidArgumentError(`It couldn't filled customOptions when term is given`);
1690
- return yield this.findCatalog(options, limits).then(({ data, count: total, maximum, minimal, distinct }) => {
1691
- var _a, _b, _c, _d, _e, _f, _g, _h;
1692
- return ({
1693
- products: { data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)), total },
1694
- pages: Math.ceil(total / limits.limit),
1695
- prices: {
1696
- price: { min: +((_b = (_a = minimal === null || minimal === void 0 ? void 0 : minimal.price) === null || _a === void 0 ? void 0 : _a.price) === null || _b === void 0 ? void 0 : _b.toFixed(2)), max: +((_d = (_c = maximum === null || maximum === void 0 ? void 0 : maximum.price) === null || _c === void 0 ? void 0 : _c.price) === null || _d === void 0 ? void 0 : _d.toFixed(2)) },
1697
- subscriberPrice: {
1698
- min: +((_f = (_e = minimal === null || minimal === void 0 ? void 0 : minimal.price) === null || _e === void 0 ? void 0 : _e.subscriberPrice) === null || _f === void 0 ? void 0 : _f.toFixed(2)),
1699
- max: +((_h = (_g = maximum === null || maximum === void 0 ? void 0 : maximum.price) === null || _g === void 0 ? void 0 : _g.subscriberPrice) === null || _h === void 0 ? void 0 : _h.toFixed(2)),
1700
- },
1701
- },
1702
- brands: distinct === null || distinct === void 0 ? void 0 : distinct.brand,
1703
- });
1704
- });
1705
- });
1706
- }
1707
- findCatalog(options, limits) {
1708
- var _a;
1709
- return __awaiter(this, void 0, void 0, function* () {
1710
- if (this.hasTerm(options) && options.sort === 'most-relevant') {
1711
- const productsIds = yield this.findCatalogIdsByElasticSearch(options.term);
1712
- return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
1713
- }
1714
- if (this.hasCategory(options) && options.sort === 'most-relevant') {
1715
- const productsIds = ((_a = options.category.products) === null || _a === void 0 ? void 0 : _a.length)
1716
- ? options.category.products
1717
- : yield this.categoryRepository.get({ id: options.category.id }).then((categoryFound) => categoryFound.products);
1718
- return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
1719
- }
1720
- const repoParams = Object.assign(Object.assign({ filters: Object.assign(Object.assign({}, (yield this.buildMainFilter(options))), this.buildFilterQuery((options === null || options === void 0 ? void 0 : options.filters) || {})) }, ((options === null || options === void 0 ? void 0 : options.sort) ? { orderBy: this.buildSortQuery(options === null || options === void 0 ? void 0 : options.sort) } : {})), { limits, options: Object.assign({ minimal: ['price'], maximum: ['price'] }, (!this.hasCategory(options) ? { distinct: ['brand'] } : {})) });
1721
- if (['biggest-price', 'lowest-price', 'biggest-discount', 'best-rating'].includes(options.sort))
1722
- return this.productRepository.findCatalog(repoParams);
1723
- return this.productRepository.findCatalog(repoParams, (options === null || options === void 0 ? void 0 : options.mainGender) || this.shop === Shops.MENSMARKET ? 'male' : 'female');
1724
- });
1725
- }
1726
- buildMainFilter({ category, profile, term, }) {
1727
- return __awaiter(this, void 0, void 0, function* () {
1728
- if (category)
1729
- return this.categoryStructureAdapter.buildProductFilterByCategory(category);
1730
- if (profile)
1731
- return { tags: { operator: Where.LIKE, value: profile } };
1732
- if (term)
1733
- return this.productIndex
1734
- .search(term, 999, this.shop)
1735
- .then((data) => ({ id: { operator: Where.IN, value: data.hits.map(({ _source }) => _source.id) } }));
1736
- });
1737
- }
1738
- findCatalogAndSortByMostRevelant(productIds, options, limits) {
1739
- return __awaiter(this, void 0, void 0, function* () {
1740
- const totalResult = yield this.productRepository.findCatalog({
1741
- fields: ['id', 'stock'],
1742
- filters: Object.assign({ id: { operator: Where.IN, value: productIds } }, this.buildFilterQuery((options === null || options === void 0 ? void 0 : options.filters) || {})),
1743
- options: {
1744
- minimal: ['price'],
1745
- maximum: ['price'],
1746
- distinct: ['brand'],
1747
- },
1748
- }, (options === null || options === void 0 ? void 0 : options.mainGender) || this.shop === Shops.MENSMARKET ? 'male' : 'female');
1749
- const stockData = totalResult.data.filter((product) => product.stock.quantity > 0);
1750
- const stockOut = totalResult.data.filter((product) => product.stock.quantity <= 0);
1751
- const productIdsStock = productIds.filter((product) => stockData.some((result) => result.id == product));
1752
- const productIdsStockOut = productIds.filter((product) => stockOut.some((result) => result.id == product));
1753
- const limitedProductId = productIdsStock
1754
- .concat(productIdsStockOut)
1755
- .slice(limits.offset, limits.offset + limits.limit);
1756
- const orderedId = productIds.filter((product) => limitedProductId.includes(product));
1757
- const productResult = yield this.productRepository.findCatalog({
1758
- filters: {
1759
- id: { operator: Where.IN, value: orderedId },
1760
- },
1761
- });
1762
- return {
1763
- data: limitedProductId.map((id) => productResult.data.find((product) => product.id === id)).filter(Boolean),
1764
- count: totalResult.count,
1765
- maximum: totalResult.maximum,
1766
- minimal: totalResult.minimal,
1767
- distinct: totalResult.distinct,
1768
- };
1769
- });
1770
- }
1771
- findCatalogIdsByElasticSearch(term) {
1772
- return __awaiter(this, void 0, void 0, function* () {
1773
- if (this.productsByTerm[term])
1774
- return this.productsByTerm[term];
1775
- return (this.productsByTerm[term] = yield this.productIndex
1776
- .search(term, 999, this.shop)
1777
- .then(({ hits: products }) => {
1778
- const withStock = products.filter(({ _source }) => _source.stock.quantity > 0);
1779
- const withOutStock = products.filter(({ _source }) => _source.stock.quantity <= 0);
1780
- const sorted = [...withStock, ...withOutStock];
1781
- return [...new Set(sorted.map(({ _source }) => _source.id))];
1782
- }));
1783
- });
1784
- }
1785
- }
1786
- CatalogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable });
1787
- CatalogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService });
1788
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, decorators: [{
1789
- type: Injectable
1790
- }], ctorParameters: function () {
1791
- return [{ type: undefined, decorators: [{
1792
- type: Inject,
1793
- args: ['ProductRepository']
1794
- }] }, { type: undefined, decorators: [{
1795
- type: Inject,
1796
- args: ['CategoryRepository']
1797
- }] }, { type: undefined, decorators: [{
1798
- type: Inject,
1799
- args: [CATEGORY_STRUCTURE]
1800
- }] }, { type: i1$2.Shops, decorators: [{
1801
- type: Inject,
1802
- args: [DEFAULT_SHOP]
1803
- }] }, { type: i1$2.ProductsIndex }];
1623
+ class CatalogService {
1624
+ constructor(productRepository, categoryRepository, categoryStructureAdapter, shop, productIndex) {
1625
+ this.productRepository = productRepository;
1626
+ this.categoryRepository = categoryRepository;
1627
+ this.categoryStructureAdapter = categoryStructureAdapter;
1628
+ this.shop = shop;
1629
+ this.productIndex = productIndex;
1630
+ this.productsByTerm = {};
1631
+ this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, tags, rate, customOptions, }) => {
1632
+ const filters = {};
1633
+ if (clubDiscount === null || clubDiscount === void 0 ? void 0 : clubDiscount.length)
1634
+ set(filters, 'price.subscriberDiscountPercentage', { operator: Where.IN, value: clubDiscount });
1635
+ if (brands === null || brands === void 0 ? void 0 : brands.length)
1636
+ filters.brand = { operator: Where.IN, value: brands };
1637
+ if (gender === null || gender === void 0 ? void 0 : gender.length)
1638
+ filters.gender = { operator: Where.IN, value: gender };
1639
+ if ((prices === null || prices === void 0 ? void 0 : prices.min) || (prices === null || prices === void 0 ? void 0 : prices.max))
1640
+ set(filters, prices.subscriberPrice ? 'price.subscriberPrice' : 'price.price', [
1641
+ ...(prices.min ? [{ operator: Where.GTE, value: Math.round(prices.min) }] : []),
1642
+ ...(prices.max ? [{ operator: Where.LTE, value: Math.ceil(prices.max) }] : []),
1643
+ ]);
1644
+ if (rate)
1645
+ filters.rate = { operator: Where.GTE, value: rate };
1646
+ if (tags === null || tags === void 0 ? void 0 : tags.length)
1647
+ filters.tags = { operator: Where.LIKE, value: tags };
1648
+ if (customOptions === null || customOptions === void 0 ? void 0 : customOptions.length)
1649
+ filters.filters = { operator: Where.LIKE, value: customOptions };
1650
+ return filters;
1651
+ };
1652
+ this.buildSortQuery = (sort) => {
1653
+ if (!sort || sort === 'most-relevant')
1654
+ return {};
1655
+ if (sort === 'best-sellers')
1656
+ return { shoppingCount: 'desc' };
1657
+ if (sort === 'biggest-price')
1658
+ return { subscriberPrice: 'desc' };
1659
+ if (sort === 'lowest-price')
1660
+ return { subscriberPrice: 'asc' };
1661
+ if (sort === 'best-rating')
1662
+ return { rate: 'desc' };
1663
+ if (sort === 'news')
1664
+ return { createdAt: 'desc' };
1665
+ if (sort === 'biggest-discount')
1666
+ return { subscriberDiscountPercentage: 'desc' };
1667
+ };
1668
+ this.buildLimitQuery = (options) => {
1669
+ const limit = (options === null || options === void 0 ? void 0 : options.perPage) || 20;
1670
+ return {
1671
+ limit,
1672
+ offset: (((options === null || options === void 0 ? void 0 : options.page) || 1) - 1) * limit,
1673
+ };
1674
+ };
1675
+ this.hasProfile = (options) => 'profile' in options;
1676
+ this.hasTerm = (options) => 'term' in options;
1677
+ this.hasCategory = (options) => 'category' in options;
1678
+ }
1679
+ fetchProducts(options) {
1680
+ var _a, _b, _c;
1681
+ return __awaiter(this, void 0, void 0, function* () {
1682
+ const limits = this.buildLimitQuery(options);
1683
+ if (this.hasProfile(options) && ((_a = options.filters) === null || _a === void 0 ? void 0 : _a.customOptions))
1684
+ throw new InvalidArgumentError(`It couldn't filled customOptions when profile is given`);
1685
+ if (this.hasProfile(options) && ((_b = options.filters) === null || _b === void 0 ? void 0 : _b.tags))
1686
+ throw new InvalidArgumentError(`It couldn't filled tags when profile is given`);
1687
+ if (this.hasTerm(options) && ((_c = options.filters) === null || _c === void 0 ? void 0 : _c.customOptions))
1688
+ throw new InvalidArgumentError(`It couldn't filled customOptions when term is given`);
1689
+ return yield this.findCatalog(options, limits).then(({ data, count: total, maximum, minimal, distinct }) => {
1690
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1691
+ return ({
1692
+ products: { data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)), total },
1693
+ pages: Math.ceil(total / limits.limit),
1694
+ prices: {
1695
+ price: { min: +((_b = (_a = minimal === null || minimal === void 0 ? void 0 : minimal.price) === null || _a === void 0 ? void 0 : _a.price) === null || _b === void 0 ? void 0 : _b.toFixed(2)), max: +((_d = (_c = maximum === null || maximum === void 0 ? void 0 : maximum.price) === null || _c === void 0 ? void 0 : _c.price) === null || _d === void 0 ? void 0 : _d.toFixed(2)) },
1696
+ subscriberPrice: {
1697
+ min: +((_f = (_e = minimal === null || minimal === void 0 ? void 0 : minimal.price) === null || _e === void 0 ? void 0 : _e.subscriberPrice) === null || _f === void 0 ? void 0 : _f.toFixed(2)),
1698
+ max: +((_h = (_g = maximum === null || maximum === void 0 ? void 0 : maximum.price) === null || _g === void 0 ? void 0 : _g.subscriberPrice) === null || _h === void 0 ? void 0 : _h.toFixed(2)),
1699
+ },
1700
+ },
1701
+ brands: distinct === null || distinct === void 0 ? void 0 : distinct.brand,
1702
+ });
1703
+ });
1704
+ });
1705
+ }
1706
+ findCatalog(options, limits) {
1707
+ var _a;
1708
+ return __awaiter(this, void 0, void 0, function* () {
1709
+ if (this.hasTerm(options) && options.sort === 'most-relevant') {
1710
+ const productsIds = yield this.findCatalogIdsByElasticSearch(options.term);
1711
+ return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
1712
+ }
1713
+ if (this.hasCategory(options) && options.sort === 'most-relevant') {
1714
+ const productsIds = ((_a = options.category.products) === null || _a === void 0 ? void 0 : _a.length)
1715
+ ? options.category.products
1716
+ : yield this.categoryRepository.get({ id: options.category.id }).then((categoryFound) => categoryFound.products);
1717
+ return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
1718
+ }
1719
+ const repoParams = Object.assign(Object.assign({ filters: Object.assign(Object.assign({}, (yield this.buildMainFilter(options))), this.buildFilterQuery((options === null || options === void 0 ? void 0 : options.filters) || {})) }, ((options === null || options === void 0 ? void 0 : options.sort) ? { orderBy: this.buildSortQuery(options === null || options === void 0 ? void 0 : options.sort) } : {})), { limits, options: Object.assign({ minimal: ['price'], maximum: ['price'] }, (!this.hasCategory(options) ? { distinct: ['brand'] } : {})) });
1720
+ if (['biggest-price', 'lowest-price', 'biggest-discount', 'best-rating'].includes(options.sort))
1721
+ return this.productRepository.findCatalog(repoParams);
1722
+ return this.productRepository.findCatalog(repoParams, (options === null || options === void 0 ? void 0 : options.mainGender) || this.shop === Shops.MENSMARKET ? 'male' : 'female');
1723
+ });
1724
+ }
1725
+ buildMainFilter({ category, profile, term, }) {
1726
+ return __awaiter(this, void 0, void 0, function* () {
1727
+ if (category)
1728
+ return this.categoryStructureAdapter.buildProductFilterByCategory(category);
1729
+ if (profile)
1730
+ return { tags: { operator: Where.LIKE, value: profile } };
1731
+ if (term)
1732
+ return this.productIndex
1733
+ .search(term, 999, this.shop)
1734
+ .then((data) => ({ id: { operator: Where.IN, value: data.hits.map(({ _source }) => _source.id) } }));
1735
+ });
1736
+ }
1737
+ findCatalogAndSortByMostRevelant(productIds, options, limits) {
1738
+ return __awaiter(this, void 0, void 0, function* () {
1739
+ const totalResult = yield this.productRepository.findCatalog({
1740
+ fields: ['id', 'stock'],
1741
+ filters: Object.assign({ id: { operator: Where.IN, value: productIds } }, this.buildFilterQuery((options === null || options === void 0 ? void 0 : options.filters) || {})),
1742
+ options: {
1743
+ minimal: ['price'],
1744
+ maximum: ['price'],
1745
+ distinct: ['brand'],
1746
+ },
1747
+ }, (options === null || options === void 0 ? void 0 : options.mainGender) || this.shop === Shops.MENSMARKET ? 'male' : 'female');
1748
+ const stockData = totalResult.data.filter((product) => product.stock.quantity > 0);
1749
+ const stockOut = totalResult.data.filter((product) => product.stock.quantity <= 0);
1750
+ const productIdsStock = productIds.filter((product) => stockData.some((result) => result.id == product));
1751
+ const productIdsStockOut = productIds.filter((product) => stockOut.some((result) => result.id == product));
1752
+ const limitedProductId = productIdsStock
1753
+ .concat(productIdsStockOut)
1754
+ .slice(limits.offset, limits.offset + limits.limit);
1755
+ const orderedId = productIds.filter((product) => limitedProductId.includes(product));
1756
+ const productResult = yield this.productRepository.findCatalog({
1757
+ filters: {
1758
+ id: { operator: Where.IN, value: orderedId },
1759
+ },
1760
+ });
1761
+ return {
1762
+ data: limitedProductId.map((id) => productResult.data.find((product) => product.id === id)).filter(Boolean),
1763
+ count: totalResult.count,
1764
+ maximum: totalResult.maximum,
1765
+ minimal: totalResult.minimal,
1766
+ distinct: totalResult.distinct,
1767
+ };
1768
+ });
1769
+ }
1770
+ findCatalogIdsByElasticSearch(term) {
1771
+ return __awaiter(this, void 0, void 0, function* () {
1772
+ if (this.productsByTerm[term])
1773
+ return this.productsByTerm[term];
1774
+ return (this.productsByTerm[term] = yield this.productIndex
1775
+ .search(term, 999, this.shop)
1776
+ .then(({ hits: products }) => {
1777
+ const withStock = products.filter(({ _source }) => _source.stock.quantity > 0);
1778
+ const withOutStock = products.filter(({ _source }) => _source.stock.quantity <= 0);
1779
+ const sorted = [...withStock, ...withOutStock];
1780
+ return [...new Set(sorted.map(({ _source }) => _source.id))];
1781
+ }));
1782
+ });
1783
+ }
1784
+ }
1785
+ CatalogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable });
1786
+ CatalogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService });
1787
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, decorators: [{
1788
+ type: Injectable
1789
+ }], ctorParameters: function () {
1790
+ return [{ type: undefined, decorators: [{
1791
+ type: Inject,
1792
+ args: ['ProductRepository']
1793
+ }] }, { type: undefined, decorators: [{
1794
+ type: Inject,
1795
+ args: ['CategoryRepository']
1796
+ }] }, { type: undefined, decorators: [{
1797
+ type: Inject,
1798
+ args: [CATEGORY_STRUCTURE]
1799
+ }] }, { type: i1$2.Shops, decorators: [{
1800
+ type: Inject,
1801
+ args: [DEFAULT_SHOP]
1802
+ }] }, { type: i1$2.ProductsIndex }];
1804
1803
  } });
1805
1804
 
1806
- class CategoryService {
1807
- constructor(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop) {
1808
- this.productRepository = productRepository;
1809
- this.categoryRepository = categoryRepository;
1810
- this.categoryFilterRepository = categoryFilterRepository;
1811
- this.categoryStructureAdapter = categoryStructureAdapter;
1812
- this.shop = shop;
1813
- }
1814
- fetchBrands(category, options) {
1815
- return __awaiter(this, void 0, void 0, function* () {
1816
- const brands = yield this.productRepository
1817
- .findCatalog({
1818
- filters: yield this.categoryStructureAdapter.buildProductFilterByCategory(category),
1819
- fields: ['brand'],
1820
- }, (options === null || options === void 0 ? void 0 : options.mainGender) || this.shop === Shops.MENSMARKET ? 'male' : 'female')
1821
- .then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => (Object.assign(Object.assign({}, brands), { [brand]: true })), {})));
1822
- return this.categoryRepository
1823
- .find({ filters: { brandCategory: true, shop: (options === null || options === void 0 ? void 0 : options.shop) || this.shop }, orderBy: { name: 'asc' } })
1824
- .then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
1825
- });
1826
- }
1827
- fetchFilterOptions(category) {
1828
- return __awaiter(this, void 0, void 0, function* () {
1829
- return yield this.categoryFilterRepository
1830
- .find({ filters: { categoryId: +category.id } })
1831
- .then(({ data }) => data.map((categoryFilter) => categoryFilter.filter));
1832
- });
1833
- }
1834
- }
1835
- CategoryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService, deps: [{ token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'CategoryFilterRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
1836
- CategoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService });
1837
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService, decorators: [{
1838
- type: Injectable
1839
- }], ctorParameters: function () {
1840
- return [{ type: undefined, decorators: [{
1841
- type: Inject,
1842
- args: ['ProductRepository']
1843
- }] }, { type: undefined, decorators: [{
1844
- type: Inject,
1845
- args: ['CategoryRepository']
1846
- }] }, { type: undefined, decorators: [{
1847
- type: Inject,
1848
- args: ['CategoryFilterRepository']
1849
- }] }, { type: undefined, decorators: [{
1850
- type: Inject,
1851
- args: [CATEGORY_STRUCTURE]
1852
- }] }, { type: i1$2.Shops, decorators: [{
1853
- type: Inject,
1854
- args: [DEFAULT_SHOP]
1855
- }] }];
1805
+ class CategoryService {
1806
+ constructor(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop) {
1807
+ this.productRepository = productRepository;
1808
+ this.categoryRepository = categoryRepository;
1809
+ this.categoryFilterRepository = categoryFilterRepository;
1810
+ this.categoryStructureAdapter = categoryStructureAdapter;
1811
+ this.shop = shop;
1812
+ }
1813
+ fetchBrands(category, options) {
1814
+ return __awaiter(this, void 0, void 0, function* () {
1815
+ const brands = yield this.productRepository
1816
+ .findCatalog({
1817
+ filters: yield this.categoryStructureAdapter.buildProductFilterByCategory(category),
1818
+ fields: ['brand'],
1819
+ }, (options === null || options === void 0 ? void 0 : options.mainGender) ? options === null || options === void 0 ? void 0 : options.mainGender : this.shop === Shops.MENSMARKET ? 'male' : 'female')
1820
+ .then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => (Object.assign(Object.assign({}, brands), { [brand]: true })), {})));
1821
+ return this.categoryRepository
1822
+ .find({ filters: { brandCategory: true, shop: (options === null || options === void 0 ? void 0 : options.shop) || this.shop }, orderBy: { name: 'asc' } })
1823
+ .then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
1824
+ });
1825
+ }
1826
+ fetchFilterOptions(category) {
1827
+ return __awaiter(this, void 0, void 0, function* () {
1828
+ return yield this.categoryFilterRepository
1829
+ .find({ filters: { categoryId: +category.id } })
1830
+ .then(({ data }) => data.map((categoryFilter) => categoryFilter.filter));
1831
+ });
1832
+ }
1833
+ }
1834
+ CategoryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService, deps: [{ token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'CategoryFilterRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
1835
+ CategoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService });
1836
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService, decorators: [{
1837
+ type: Injectable
1838
+ }], ctorParameters: function () {
1839
+ return [{ type: undefined, decorators: [{
1840
+ type: Inject,
1841
+ args: ['ProductRepository']
1842
+ }] }, { type: undefined, decorators: [{
1843
+ type: Inject,
1844
+ args: ['CategoryRepository']
1845
+ }] }, { type: undefined, decorators: [{
1846
+ type: Inject,
1847
+ args: ['CategoryFilterRepository']
1848
+ }] }, { type: undefined, decorators: [{
1849
+ type: Inject,
1850
+ args: [CATEGORY_STRUCTURE]
1851
+ }] }, { type: i1$2.Shops, decorators: [{
1852
+ type: Inject,
1853
+ args: [DEFAULT_SHOP]
1854
+ }] }];
1856
1855
  } });
1857
1856
 
1858
- var ProductSorts;
1859
- (function (ProductSorts) {
1860
- ProductSorts["MOST_RELEVANT"] = "most-relevant";
1861
- ProductSorts["BEST_SELLER"] = "best-sellers";
1862
- ProductSorts["BIGGEST_PRICE"] = "biggest-price";
1863
- ProductSorts["LOWEST_PRICE"] = "lowest-price";
1864
- ProductSorts["BIGGEST_DISCOUNT"] = "biggest-discount";
1865
- ProductSorts["BEST_RATING"] = "best-rating";
1866
- ProductSorts["NEWS"] = "news";
1857
+ var ProductSorts;
1858
+ (function (ProductSorts) {
1859
+ ProductSorts["MOST_RELEVANT"] = "most-relevant";
1860
+ ProductSorts["BEST_SELLER"] = "best-sellers";
1861
+ ProductSorts["BIGGEST_PRICE"] = "biggest-price";
1862
+ ProductSorts["LOWEST_PRICE"] = "lowest-price";
1863
+ ProductSorts["BIGGEST_DISCOUNT"] = "biggest-discount";
1864
+ ProductSorts["BEST_RATING"] = "best-rating";
1865
+ ProductSorts["NEWS"] = "news";
1867
1866
  })(ProductSorts || (ProductSorts = {}));
1868
1867
 
1869
- class CategoryWithTree extends Category {
1870
- }
1871
- __decorate([
1872
- Type(() => CategoryWithTree),
1873
- __metadata("design:type", Array)
1868
+ class CategoryWithTree extends Category {
1869
+ }
1870
+ __decorate([
1871
+ Type(() => CategoryWithTree),
1872
+ __metadata("design:type", Array)
1874
1873
  ], CategoryWithTree.prototype, "children", void 0);
1875
1874
 
1876
- class WishlistService {
1877
- constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository, productIndex) {
1878
- this.wishlistRepository = wishlistRepository;
1879
- this.shop = shop;
1880
- const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository);
1881
- this.catalogService = new CatalogService(productRepository, categoryRepository, categoryStructureAdapter, shop, productIndex);
1882
- this.categoryService = new CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop);
1883
- }
1884
- getCatalogService() {
1885
- return this.catalogService;
1886
- }
1887
- getCategoryService() {
1888
- return this.categoryService;
1889
- }
1890
- create({ personId, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
1891
- return __awaiter(this, void 0, void 0, function* () {
1892
- const data = {
1893
- slug: '',
1894
- name: title,
1895
- description,
1896
- metadata: {
1897
- title: `${userFullName} - ${title}`,
1898
- description: `${userFullName} - ${description}`,
1899
- },
1900
- shop: this.shop,
1901
- shops: [this.shop],
1902
- personId,
1903
- personName: userFullName,
1904
- personPhoto: userPhoto,
1905
- brandCategory: false,
1906
- published: true,
1907
- theme,
1908
- bannerUrl,
1909
- };
1910
- const newWishlist = yield this.wishlistRepository.create(data);
1911
- yield this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id });
1912
- return Wishlist.toInstance(Object.assign(Object.assign({}, newWishlist.toPlain()), { slug: newWishlist.id }));
1913
- });
1914
- }
1915
- update({ id, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
1916
- const data = {
1917
- id,
1918
- name: title,
1919
- description,
1920
- metadata: {
1921
- title: `${userFullName} - ${title}`,
1922
- description: `${userFullName} - ${description}`,
1923
- },
1924
- personName: userFullName,
1925
- personPhoto: userPhoto,
1926
- theme,
1927
- bannerUrl,
1928
- };
1929
- return this.wishlistRepository.update(data);
1930
- }
1931
- delete(wishlistId) {
1932
- return this.wishlistRepository.delete({ id: wishlistId });
1933
- }
1934
- getWishlistBySlug(slug) {
1935
- const [id] = slug.split('-');
1936
- if (+id)
1937
- return this.wishlistRepository.get({ id });
1938
- return this.wishlistRepository.getWishlistBySlug(slug);
1939
- }
1940
- getWishlistsByPerson(personId) {
1941
- return this.wishlistRepository.getWishlistByPerson(personId);
1942
- }
1943
- addProduct(wishlistId, productId) {
1944
- return __awaiter(this, void 0, void 0, function* () {
1945
- const wishlist = yield this.wishlistRepository.get({ id: wishlistId });
1946
- const hasProduct = wishlist.products.some((p) => p == productId);
1947
- if (!hasProduct) {
1948
- wishlist.products = [...wishlist.products, productId];
1949
- return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
1950
- }
1951
- return wishlist;
1952
- });
1953
- }
1954
- removeProduct(wishlistId, productId) {
1955
- return __awaiter(this, void 0, void 0, function* () {
1956
- const wishlist = yield this.wishlistRepository.get({ id: wishlistId });
1957
- const productIndex = wishlist.products.findIndex((p) => p == productId);
1958
- if (productIndex != -1) {
1959
- wishlist.products.splice(productIndex, 1);
1960
- if (!wishlist.products.length)
1961
- return this.wishlistRepository.update({ id: wishlistId, products: { action: 'remove' } });
1962
- return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
1963
- }
1964
- return wishlist;
1965
- });
1966
- }
1967
- }
1968
- WishlistService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryFilterRepository' }, { token: 'CategoryRepository' }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable });
1969
- WishlistService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService });
1970
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, decorators: [{
1971
- type: Injectable
1972
- }], ctorParameters: function () {
1973
- return [{ type: undefined, decorators: [{
1974
- type: Inject,
1975
- args: ['WishlistRepository']
1976
- }] }, { type: i1$2.Shops, decorators: [{
1977
- type: Inject,
1978
- args: [DEFAULT_SHOP]
1979
- }] }, { type: undefined, decorators: [{
1980
- type: Inject,
1981
- args: ['ProductRepository']
1982
- }] }, { type: undefined, decorators: [{
1983
- type: Inject,
1984
- args: ['CategoryFilterRepository']
1985
- }] }, { type: undefined, decorators: [{
1986
- type: Inject,
1987
- args: ['CategoryRepository']
1988
- }] }, { type: i1$2.ProductsIndex }];
1875
+ class WishlistService {
1876
+ constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository, productIndex) {
1877
+ this.wishlistRepository = wishlistRepository;
1878
+ this.shop = shop;
1879
+ const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository);
1880
+ this.catalogService = new CatalogService(productRepository, categoryRepository, categoryStructureAdapter, shop, productIndex);
1881
+ this.categoryService = new CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop);
1882
+ }
1883
+ getCatalogService() {
1884
+ return this.catalogService;
1885
+ }
1886
+ getCategoryService() {
1887
+ return this.categoryService;
1888
+ }
1889
+ create({ personId, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
1890
+ return __awaiter(this, void 0, void 0, function* () {
1891
+ const data = {
1892
+ slug: '',
1893
+ name: title,
1894
+ description,
1895
+ metadata: {
1896
+ title: `${userFullName} - ${title}`,
1897
+ description: `${userFullName} - ${description}`,
1898
+ },
1899
+ shop: this.shop,
1900
+ shops: [this.shop],
1901
+ personId,
1902
+ personName: userFullName,
1903
+ personPhoto: userPhoto,
1904
+ brandCategory: false,
1905
+ published: true,
1906
+ theme,
1907
+ bannerUrl,
1908
+ };
1909
+ const newWishlist = yield this.wishlistRepository.create(data);
1910
+ yield this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id });
1911
+ return Wishlist.toInstance(Object.assign(Object.assign({}, newWishlist.toPlain()), { slug: newWishlist.id }));
1912
+ });
1913
+ }
1914
+ update({ id, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
1915
+ const data = {
1916
+ id,
1917
+ name: title,
1918
+ description,
1919
+ metadata: {
1920
+ title: `${userFullName} - ${title}`,
1921
+ description: `${userFullName} - ${description}`,
1922
+ },
1923
+ personName: userFullName,
1924
+ personPhoto: userPhoto,
1925
+ theme,
1926
+ bannerUrl,
1927
+ };
1928
+ return this.wishlistRepository.update(data);
1929
+ }
1930
+ delete(wishlistId) {
1931
+ return this.wishlistRepository.delete({ id: wishlistId });
1932
+ }
1933
+ getWishlistBySlug(slug) {
1934
+ const [id] = slug.split('-');
1935
+ if (+id)
1936
+ return this.wishlistRepository.get({ id });
1937
+ return this.wishlistRepository.getWishlistBySlug(slug);
1938
+ }
1939
+ getWishlistsByPerson(personId) {
1940
+ return this.wishlistRepository.getWishlistByPerson(personId);
1941
+ }
1942
+ addProduct(wishlistId, productId) {
1943
+ return __awaiter(this, void 0, void 0, function* () {
1944
+ const wishlist = yield this.wishlistRepository.get({ id: wishlistId });
1945
+ const hasProduct = wishlist.products.some((p) => p == productId);
1946
+ if (!hasProduct) {
1947
+ wishlist.products = [...wishlist.products, productId];
1948
+ return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
1949
+ }
1950
+ return wishlist;
1951
+ });
1952
+ }
1953
+ removeProduct(wishlistId, productId) {
1954
+ return __awaiter(this, void 0, void 0, function* () {
1955
+ const wishlist = yield this.wishlistRepository.get({ id: wishlistId });
1956
+ const productIndex = wishlist.products.findIndex((p) => p == productId);
1957
+ if (productIndex != -1) {
1958
+ wishlist.products.splice(productIndex, 1);
1959
+ if (!wishlist.products.length)
1960
+ return this.wishlistRepository.update({ id: wishlistId, products: { action: 'remove' } });
1961
+ return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
1962
+ }
1963
+ return wishlist;
1964
+ });
1965
+ }
1966
+ }
1967
+ WishlistService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryFilterRepository' }, { token: 'CategoryRepository' }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable });
1968
+ WishlistService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService });
1969
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, decorators: [{
1970
+ type: Injectable
1971
+ }], ctorParameters: function () {
1972
+ return [{ type: undefined, decorators: [{
1973
+ type: Inject,
1974
+ args: ['WishlistRepository']
1975
+ }] }, { type: i1$2.Shops, decorators: [{
1976
+ type: Inject,
1977
+ args: [DEFAULT_SHOP]
1978
+ }] }, { type: undefined, decorators: [{
1979
+ type: Inject,
1980
+ args: ['ProductRepository']
1981
+ }] }, { type: undefined, decorators: [{
1982
+ type: Inject,
1983
+ args: ['CategoryFilterRepository']
1984
+ }] }, { type: undefined, decorators: [{
1985
+ type: Inject,
1986
+ args: ['CategoryRepository']
1987
+ }] }, { type: i1$2.ProductsIndex }];
1989
1988
  } });
1990
1989
 
1991
- class CheckoutSubscriptionService {
1992
- constructor(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
1993
- this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
1994
- this.subscriptionRepository = subscriptionRepository;
1995
- this.couponService = couponService;
1996
- }
1997
- getCheckoutSubscription(checkoutData) {
1998
- const checkoutId = cookie.get('checkoutSubscriptionId');
1999
- if (!isNil(checkoutId))
2000
- return from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
2001
- return from(this.createCheckoutSubscription(checkoutData));
2002
- }
2003
- createCheckoutSubscription(checkoutData) {
2004
- return __awaiter(this, void 0, void 0, function* () {
2005
- const checkout = yield this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()));
2006
- cookie.set('checkoutSubscriptionId', checkout.id);
2007
- return checkout;
2008
- });
2009
- }
2010
- clearCheckoutSubscriptionFromSession() {
2011
- cookie.remove('checkoutSubscriptionId');
2012
- return of();
2013
- }
2014
- checkCoupon(nickname, userEmail) {
2015
- return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
2016
- .checkCoupon(nickname, CheckoutTypes.SUBSCRIPTION, checkout, checkout.subscriptionPlan.name)
2017
- .pipe()));
2018
- }
2019
- calcDiscountSubscription(coupon) {
2020
- return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
2021
- }
2022
- }
2023
- CheckoutSubscriptionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: 'SubscriptionRepository' }, { token: CouponService }], target: i0.ɵɵFactoryTarget.Injectable });
2024
- CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService });
2025
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
2026
- type: Injectable
2027
- }], ctorParameters: function () {
2028
- return [{ type: undefined, decorators: [{
2029
- type: Inject,
2030
- args: ['CheckoutSubscriptionRepository']
2031
- }] }, { type: undefined, decorators: [{
2032
- type: Inject,
2033
- args: ['SubscriptionRepository']
2034
- }] }, { type: CouponService }];
1990
+ class CheckoutSubscriptionService {
1991
+ constructor(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
1992
+ this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
1993
+ this.subscriptionRepository = subscriptionRepository;
1994
+ this.couponService = couponService;
1995
+ }
1996
+ getCheckoutSubscription(checkoutData) {
1997
+ const checkoutId = cookie.get('checkoutSubscriptionId');
1998
+ if (!isNil(checkoutId))
1999
+ return from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
2000
+ return from(this.createCheckoutSubscription(checkoutData));
2001
+ }
2002
+ createCheckoutSubscription(checkoutData) {
2003
+ return __awaiter(this, void 0, void 0, function* () {
2004
+ const checkout = yield this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()));
2005
+ cookie.set('checkoutSubscriptionId', checkout.id);
2006
+ return checkout;
2007
+ });
2008
+ }
2009
+ clearCheckoutSubscriptionFromSession() {
2010
+ cookie.remove('checkoutSubscriptionId');
2011
+ return of();
2012
+ }
2013
+ checkCoupon(nickname, userEmail) {
2014
+ return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
2015
+ .checkCoupon(nickname, CheckoutTypes.SUBSCRIPTION, checkout, checkout.subscriptionPlan.name)
2016
+ .pipe()));
2017
+ }
2018
+ calcDiscountSubscription(coupon) {
2019
+ return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
2020
+ }
2021
+ }
2022
+ CheckoutSubscriptionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: 'SubscriptionRepository' }, { token: CouponService }], target: i0.ɵɵFactoryTarget.Injectable });
2023
+ CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService });
2024
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
2025
+ type: Injectable
2026
+ }], ctorParameters: function () {
2027
+ return [{ type: undefined, decorators: [{
2028
+ type: Inject,
2029
+ args: ['CheckoutSubscriptionRepository']
2030
+ }] }, { type: undefined, decorators: [{
2031
+ type: Inject,
2032
+ args: ['SubscriptionRepository']
2033
+ }] }, { type: CouponService }];
2035
2034
  } });
2036
2035
 
2037
- class UtilHelper {
2038
- static createSlug(name) {
2039
- return name
2040
- .toLowerCase()
2041
- .replace(/\s+/g, '-') // Replace spaces with -
2042
- .replace(/[ãàáäâ]/g, 'a') // Replace spaces with -
2043
- .replace(/[ẽèéëê]/g, 'e') // Replace spaces with -
2044
- .replace(/[ìíïî]/g, 'i') // Replace spaces with -
2045
- .replace(/[õòóöô]/g, 'o') // Replace spaces with -
2046
- .replace(/[ùúüû]/g, 'u') // Replace spaces with -
2047
- .replace(/[ñ]/g, 'n') // Replace spaces with -
2048
- .replace(/[ç]/g, 'c') // Replace spaces with -
2049
- .replace(/[&]/g, 'and') // Replace spaces with -
2050
- .replace(/[^\w\-]+/g, '') // Remove all non-word chars
2051
- .replace(/\-\-+/g, '-'); // Replace multiple - with single -
2052
- }
2036
+ class UtilHelper {
2037
+ static createSlug(name) {
2038
+ return name
2039
+ .toLowerCase()
2040
+ .replace(/\s+/g, '-') // Replace spaces with -
2041
+ .replace(/[ãàáäâ]/g, 'a') // Replace spaces with -
2042
+ .replace(/[ẽèéëê]/g, 'e') // Replace spaces with -
2043
+ .replace(/[ìíïî]/g, 'i') // Replace spaces with -
2044
+ .replace(/[õòóöô]/g, 'o') // Replace spaces with -
2045
+ .replace(/[ùúüû]/g, 'u') // Replace spaces with -
2046
+ .replace(/[ñ]/g, 'n') // Replace spaces with -
2047
+ .replace(/[ç]/g, 'c') // Replace spaces with -
2048
+ .replace(/[&]/g, 'and') // Replace spaces with -
2049
+ .replace(/[^\w\-]+/g, '') // Remove all non-word chars
2050
+ .replace(/\-\-+/g, '-'); // Replace multiple - with single -
2051
+ }
2053
2052
  }
2054
2053
 
2055
- class HomeShopService {
2056
- get homeId() {
2057
- if (this.defaultShop === Shops.GLAMSHOP)
2058
- return 'glamshop';
2059
- if (this.defaultShop === Shops.MENSMARKET)
2060
- return 'mens_market';
2061
- return null;
2062
- }
2063
- constructor(categoryRepository, homeRepository, productRepository, defaultShop) {
2064
- this.categoryRepository = categoryRepository;
2065
- this.homeRepository = homeRepository;
2066
- this.productRepository = productRepository;
2067
- this.defaultShop = defaultShop;
2068
- this.buildCategoryGroupWithRequiredData = (group) => {
2069
- var _a, _b;
2070
- return ({
2071
- 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'])),
2072
- 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()) || {}, [
2073
- 'id',
2074
- 'price',
2075
- 'reviews',
2076
- 'hasVariants',
2077
- 'slug',
2078
- 'sku',
2079
- 'stock',
2080
- 'costPrice',
2081
- 'images',
2082
- 'miniatures',
2083
- 'name',
2084
- 'weight',
2085
- 'rate',
2086
- 'type',
2087
- 'brand',
2088
- ])))) || [],
2089
- });
2090
- };
2091
- }
2092
- getHomeData() {
2093
- 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
2094
- ? of(home)
2095
- : forkJoin([
2096
- this.getDiscoverProducts(this.gender),
2097
- this.getFeaturedProducts(this.gender),
2098
- this.getVerticalProducts(this.gender),
2099
- ]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
2100
- discoverProducts,
2101
- featuredProducts,
2102
- verticalProducts,
2103
- })), concatMap((data) => this.saveHomeData(data)))));
2104
- }
2105
- getBanners(type) {
2106
- return this.getHomeConfiguration().pipe(map((home) => {
2107
- if (type === 'brand')
2108
- return home.brandsCarousel;
2109
- if (type === 'buyToWin')
2110
- return [home.buyToWinBanner];
2111
- if (type === 'block')
2112
- return home.blockBanners;
2113
- if (type === 'blog')
2114
- return [home.blogBanner];
2115
- return [];
2116
- }));
2117
- }
2118
- getMinValueForFreeShipping() {
2119
- return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
2120
- }
2121
- getDiscoverProducts(gender) {
2122
- return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories, undefined, gender)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
2123
- }
2124
- getFeaturedProducts(gender) {
2125
- return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories, undefined, gender)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
2126
- }
2127
- getVerticalProducts(gender) {
2128
- 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({
2129
- filters: Object.assign({ categories: { operator: Where.IN, value: [category.id] } }, (gender ? { tags: { operator: Where.IN, value: [gender] } } : {})),
2130
- limits: { limit: 12 },
2131
- })).pipe(map((products) => ({ category, products })))), map(({ category, products }) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
2132
- }
2133
- getHomeConfiguration() {
2134
- return of(this.homeConfiguration).pipe(concatMap((home) => home
2135
- ? of(home)
2136
- : !this.homeId
2137
- ? throwError(new RequiredArgumentError(['homeId']))
2138
- : from(this.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
2139
- }
2140
- saveHomeData(homeData) {
2141
- const data = {
2142
- createdAt: new Date(),
2143
- expiresAt: add(new Date(), { hours: 1 }),
2144
- data: homeData,
2145
- };
2146
- return from(this.homeRepository.update({
2147
- id: this.homeId,
2148
- data,
2149
- })).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
2150
- }
2151
- get gender() {
2152
- return this.homeId === 'mens_market' ? 'masculino' : undefined;
2153
- }
2154
- }
2155
- HomeShopService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService, deps: [{ token: 'CategoryRepository' }, { token: 'HomeRepository' }, { token: 'ProductRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
2156
- HomeShopService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService });
2157
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService, decorators: [{
2158
- type: Injectable
2159
- }], ctorParameters: function () {
2160
- return [{ type: undefined, decorators: [{
2161
- type: Inject,
2162
- args: ['CategoryRepository']
2163
- }] }, { type: undefined, decorators: [{
2164
- type: Inject,
2165
- args: ['HomeRepository']
2166
- }] }, { type: undefined, decorators: [{
2167
- type: Inject,
2168
- args: ['ProductRepository']
2169
- }] }, { type: i1$2.Shops, decorators: [{
2170
- type: Inject,
2171
- args: [DEFAULT_SHOP]
2172
- }] }];
2054
+ class HomeShopService {
2055
+ get homeId() {
2056
+ if (this.defaultShop === Shops.GLAMSHOP)
2057
+ return 'glamshop';
2058
+ if (this.defaultShop === Shops.MENSMARKET)
2059
+ return 'mens_market';
2060
+ return null;
2061
+ }
2062
+ constructor(categoryRepository, homeRepository, productRepository, defaultShop) {
2063
+ this.categoryRepository = categoryRepository;
2064
+ this.homeRepository = homeRepository;
2065
+ this.productRepository = productRepository;
2066
+ this.defaultShop = defaultShop;
2067
+ this.buildCategoryGroupWithRequiredData = (group) => {
2068
+ var _a, _b;
2069
+ return ({
2070
+ 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'])),
2071
+ 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()) || {}, [
2072
+ 'id',
2073
+ 'price',
2074
+ 'reviews',
2075
+ 'hasVariants',
2076
+ 'slug',
2077
+ 'sku',
2078
+ 'stock',
2079
+ 'costPrice',
2080
+ 'images',
2081
+ 'miniatures',
2082
+ 'name',
2083
+ 'weight',
2084
+ 'rate',
2085
+ 'type',
2086
+ 'brand',
2087
+ ])))) || [],
2088
+ });
2089
+ };
2090
+ }
2091
+ getHomeData() {
2092
+ 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
2093
+ ? of(home)
2094
+ : forkJoin([
2095
+ this.getDiscoverProducts(this.gender),
2096
+ this.getFeaturedProducts(this.gender),
2097
+ this.getVerticalProducts(this.gender),
2098
+ ]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
2099
+ discoverProducts,
2100
+ featuredProducts,
2101
+ verticalProducts,
2102
+ })), concatMap((data) => this.saveHomeData(data)))));
2103
+ }
2104
+ getBanners(type) {
2105
+ return this.getHomeConfiguration().pipe(map((home) => {
2106
+ if (type === 'brand')
2107
+ return home.brandsCarousel;
2108
+ if (type === 'buyToWin')
2109
+ return [home.buyToWinBanner];
2110
+ if (type === 'block')
2111
+ return home.blockBanners;
2112
+ if (type === 'blog')
2113
+ return [home.blogBanner];
2114
+ return [];
2115
+ }));
2116
+ }
2117
+ getMinValueForFreeShipping() {
2118
+ return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
2119
+ }
2120
+ getDiscoverProducts(gender) {
2121
+ return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories, undefined, gender)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
2122
+ }
2123
+ getFeaturedProducts(gender) {
2124
+ return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories, undefined, gender)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
2125
+ }
2126
+ getVerticalProducts(gender) {
2127
+ 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({
2128
+ filters: Object.assign({ categories: { operator: Where.IN, value: [category.id] } }, (gender ? { tags: { operator: Where.IN, value: [gender] } } : {})),
2129
+ limits: { limit: 12 },
2130
+ })).pipe(map((products) => ({ category, products })))), map(({ category, products }) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
2131
+ }
2132
+ getHomeConfiguration() {
2133
+ return of(this.homeConfiguration).pipe(concatMap((home) => home
2134
+ ? of(home)
2135
+ : !this.homeId
2136
+ ? throwError(new RequiredArgumentError(['homeId']))
2137
+ : from(this.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
2138
+ }
2139
+ saveHomeData(homeData) {
2140
+ const data = {
2141
+ createdAt: new Date(),
2142
+ expiresAt: add(new Date(), { hours: 1 }),
2143
+ data: homeData,
2144
+ };
2145
+ return from(this.homeRepository.update({
2146
+ id: this.homeId,
2147
+ data,
2148
+ })).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
2149
+ }
2150
+ get gender() {
2151
+ return this.homeId === 'mens_market' ? 'masculino' : undefined;
2152
+ }
2153
+ }
2154
+ HomeShopService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService, deps: [{ token: 'CategoryRepository' }, { token: 'HomeRepository' }, { token: 'ProductRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
2155
+ HomeShopService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService });
2156
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService, decorators: [{
2157
+ type: Injectable
2158
+ }], ctorParameters: function () {
2159
+ return [{ type: undefined, decorators: [{
2160
+ type: Inject,
2161
+ args: ['CategoryRepository']
2162
+ }] }, { type: undefined, decorators: [{
2163
+ type: Inject,
2164
+ args: ['HomeRepository']
2165
+ }] }, { type: undefined, decorators: [{
2166
+ type: Inject,
2167
+ args: ['ProductRepository']
2168
+ }] }, { type: i1$2.Shops, decorators: [{
2169
+ type: Inject,
2170
+ args: [DEFAULT_SHOP]
2171
+ }] }];
2173
2172
  } });
2174
2173
 
2175
- class OrderService {
2176
- constructor(angularFirestore, orderRepository) {
2177
- this.angularFirestore = angularFirestore;
2178
- this.orderRepository = orderRepository;
2179
- this.orderSubject = new Subject();
2180
- }
2181
- getOrder(id) {
2182
- docSnapshots(doc(this.angularFirestore, `${this.orderRepository.collectionName}/${id}`))
2183
- .pipe(map((doc) => Order.toInstance(doc.data())))
2184
- .subscribe((doc) => this.orderSubject.next(doc));
2185
- return this.orderSubject;
2186
- }
2187
- }
2188
- OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, deps: [{ token: i1$1.Firestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
2189
- OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService });
2190
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, decorators: [{
2191
- type: Injectable
2192
- }], ctorParameters: function () {
2193
- return [{ type: i1$1.Firestore }, { type: i1$2.OrderFirestoreRepository, decorators: [{
2194
- type: Inject,
2195
- args: ['OrderRepository']
2196
- }] }];
2174
+ class OrderService {
2175
+ constructor(angularFirestore, orderRepository) {
2176
+ this.angularFirestore = angularFirestore;
2177
+ this.orderRepository = orderRepository;
2178
+ this.orderSubject = new Subject();
2179
+ }
2180
+ getOrder(id) {
2181
+ docSnapshots(doc(this.angularFirestore, `${this.orderRepository.collectionName}/${id}`))
2182
+ .pipe(map((doc) => Order.toInstance(doc.data())))
2183
+ .subscribe((doc) => this.orderSubject.next(doc));
2184
+ return this.orderSubject;
2185
+ }
2186
+ }
2187
+ OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, deps: [{ token: i1$1.Firestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
2188
+ OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService });
2189
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, decorators: [{
2190
+ type: Injectable
2191
+ }], ctorParameters: function () {
2192
+ return [{ type: i1$1.Firestore }, { type: i1$2.OrderFirestoreRepository, decorators: [{
2193
+ type: Inject,
2194
+ args: ['OrderRepository']
2195
+ }] }];
2197
2196
  } });
2198
2197
 
2199
- class ShippingService {
2200
- constructor(http, apiUrl, homeService) {
2201
- this.http = http;
2202
- this.apiUrl = apiUrl;
2203
- this.homeService = homeService;
2204
- }
2205
- getShippingMethods(shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
2206
- return combineLatest([
2207
- this.homeService.getHomeData(),
2208
- this.http.get(`${this.apiUrl}open/checkshippingcompany?personId=${personId}&postalCode=${zip}&weightGrams=${weightGrams}`),
2209
- ]).pipe(map(([datas, shippingMethodsResponse]) => {
2210
- let shippingMethods = shippingMethodsResponse.result;
2211
- if (!shippingMethods.length)
2212
- return [];
2213
- shippingMethods = shippingMethods.map((shippingMethod) => {
2214
- if (shippingMethod.ShippingCompanyName == 'Same Day EG')
2215
- shippingMethod.ShippingCompanyName = 'Same Day';
2216
- return shippingMethod;
2217
- });
2218
- const datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
2219
- if (this.isHolidays(datasSameDayNotAvaliable)) {
2220
- shippingMethods = shippingMethods.filter((method) => method.serviceName !== 'Same Day');
2221
- }
2222
- if (totalPrice >= 200) {
2223
- shippingMethods = shippingMethods.map((s) => {
2224
- if (s.serviceName !== 'Same Day')
2225
- return Object.assign(Object.assign({}, s), { totalPrice: 0 });
2226
- else
2227
- return s;
2228
- });
2229
- }
2230
- if (shop == Shops.GLAMSHOP)
2231
- return shippingMethods;
2232
- if (this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
2233
- shippingMethods = shippingMethods.map((s) => {
2234
- if (s.serviceName == 'Same Day')
2235
- return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
2236
- else
2237
- return Object.assign(Object.assign({}, s), { totalPrice: 0 });
2238
- });
2239
- }
2240
- if (this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
2241
- shippingMethods = shippingMethods.map((s) => {
2242
- return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
2243
- });
2244
- }
2245
- return shippingMethods;
2246
- }));
2247
- }
2248
- isFreeShippingBySubscription(shop, subscriptionPlan) {
2249
- if (!subscriptionPlan)
2250
- return false;
2251
- if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT')
2252
- return true;
2253
- return false;
2254
- }
2255
- isHalfShippingBySubscription(shop, subscriptionPlan) {
2256
- if (!subscriptionPlan)
2257
- return false;
2258
- if (shop == Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
2259
- return true;
2260
- }
2261
- return false;
2262
- }
2263
- isHolidays(datas) {
2264
- const today = new Date();
2265
- for (const key in datas) {
2266
- let start = new Date(`${today.getFullYear()}-${datas[key].beginDate}`);
2267
- let end = new Date(`${today.getFullYear()}-${datas[key].endDate}`);
2268
- if (start > end)
2269
- end = new Date(`${today.getFullYear() + 1}-${datas[key].endDate}`);
2270
- if (today >= start && today <= end)
2271
- return true;
2272
- }
2273
- return false;
2274
- }
2275
- }
2276
- ShippingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, deps: [{ token: i1$3.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0.ɵɵFactoryTarget.Injectable });
2277
- ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService });
2278
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, decorators: [{
2279
- type: Injectable
2280
- }], ctorParameters: function () {
2281
- return [{ type: i1$3.HttpClient }, { type: undefined, decorators: [{
2282
- type: Inject,
2283
- args: [BACKEND_URL]
2284
- }] }, { type: HomeShopService }];
2198
+ class ShippingService {
2199
+ constructor(http, apiUrl, homeService) {
2200
+ this.http = http;
2201
+ this.apiUrl = apiUrl;
2202
+ this.homeService = homeService;
2203
+ }
2204
+ getShippingMethods(shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
2205
+ return combineLatest([
2206
+ this.homeService.getHomeData(),
2207
+ this.http.get(`${this.apiUrl}open/checkshippingcompany?personId=${personId}&postalCode=${zip}&weightGrams=${weightGrams}`),
2208
+ ]).pipe(map(([datas, shippingMethodsResponse]) => {
2209
+ let shippingMethods = shippingMethodsResponse.result;
2210
+ if (!shippingMethods.length)
2211
+ return [];
2212
+ shippingMethods = shippingMethods.map((shippingMethod) => {
2213
+ if (shippingMethod.ShippingCompanyName == 'Same Day EG')
2214
+ shippingMethod.ShippingCompanyName = 'Same Day';
2215
+ return shippingMethod;
2216
+ });
2217
+ const datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
2218
+ if (this.isHolidays(datasSameDayNotAvaliable)) {
2219
+ shippingMethods = shippingMethods.filter((method) => method.serviceName !== 'Same Day');
2220
+ }
2221
+ if (totalPrice >= 200) {
2222
+ shippingMethods = shippingMethods.map((s) => {
2223
+ if (s.serviceName !== 'Same Day')
2224
+ return Object.assign(Object.assign({}, s), { totalPrice: 0 });
2225
+ else
2226
+ return s;
2227
+ });
2228
+ }
2229
+ if (shop == Shops.GLAMSHOP)
2230
+ return shippingMethods;
2231
+ if (this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
2232
+ shippingMethods = shippingMethods.map((s) => {
2233
+ if (s.serviceName == 'Same Day')
2234
+ return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
2235
+ else
2236
+ return Object.assign(Object.assign({}, s), { totalPrice: 0 });
2237
+ });
2238
+ }
2239
+ if (this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
2240
+ shippingMethods = shippingMethods.map((s) => {
2241
+ return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
2242
+ });
2243
+ }
2244
+ return shippingMethods;
2245
+ }));
2246
+ }
2247
+ isFreeShippingBySubscription(shop, subscriptionPlan) {
2248
+ if (!subscriptionPlan)
2249
+ return false;
2250
+ if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT')
2251
+ return true;
2252
+ return false;
2253
+ }
2254
+ isHalfShippingBySubscription(shop, subscriptionPlan) {
2255
+ if (!subscriptionPlan)
2256
+ return false;
2257
+ if (shop == Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
2258
+ return true;
2259
+ }
2260
+ return false;
2261
+ }
2262
+ isHolidays(datas) {
2263
+ const today = new Date();
2264
+ for (const key in datas) {
2265
+ let start = new Date(`${today.getFullYear()}-${datas[key].beginDate}`);
2266
+ let end = new Date(`${today.getFullYear()}-${datas[key].endDate}`);
2267
+ if (start > end)
2268
+ end = new Date(`${today.getFullYear() + 1}-${datas[key].endDate}`);
2269
+ if (today >= start && today <= end)
2270
+ return true;
2271
+ }
2272
+ return false;
2273
+ }
2274
+ }
2275
+ ShippingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, deps: [{ token: i1$3.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0.ɵɵFactoryTarget.Injectable });
2276
+ ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService });
2277
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, decorators: [{
2278
+ type: Injectable
2279
+ }], ctorParameters: function () {
2280
+ return [{ type: i1$3.HttpClient }, { type: undefined, decorators: [{
2281
+ type: Inject,
2282
+ args: [BACKEND_URL]
2283
+ }] }, { type: HomeShopService }];
2285
2284
  } });
2286
2285
 
2287
- class AngularConnectModule {
2288
- static initializeApp(defaultShop, options, nameOrConfig) {
2289
- return {
2290
- ngModule: AngularConnectModule,
2291
- providers: [
2292
- {
2293
- provide: CATEGORY_STRUCTURE,
2294
- useClass: isNil(options === null || options === void 0 ? void 0 : options.oldCategoryStructure) || (options === null || options === void 0 ? void 0 : options.oldCategoryStructure)
2295
- ? OldCategoryStructureAdapter
2296
- : NewCategoryStructureAdapter,
2297
- },
2298
- ...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
2299
- ...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options === null || options === void 0 ? void 0 : options.firebase }]),
2300
- ...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
2301
- ...(isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
2302
- ...(isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
2303
- ...(isNil(options === null || options === void 0 ? void 0 : options.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]),
2304
- ...(isNil(options === null || options === void 0 ? void 0 : options.storageBaseUrl) ? [] : [{ provide: STORAGE_BASE_URL, useValue: options.storageBaseUrl }]),
2305
- ],
2306
- };
2307
- }
2308
- }
2309
- AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2310
- AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, imports: [i1$4.FirebaseAppModule, AngularElasticSeachModule,
2311
- AngularFirebaseAuthModule,
2312
- AngularFirestoreModule,
2313
- AngularHasuraGraphQLModule] });
2314
- AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, providers: [
2315
- AuthService,
2316
- CartService,
2317
- CatalogService,
2318
- CategoryService,
2319
- CheckoutService,
2320
- CheckoutSubscriptionService,
2321
- CouponService,
2322
- HomeShopService,
2323
- OrderService,
2324
- ShippingService,
2325
- WishlistService,
2326
- {
2327
- provide: UpdateUserImage,
2328
- useFactory: (userRepository, fileUploader) => {
2329
- return new UpdateUserImage(userRepository, fileUploader);
2330
- },
2331
- deps: ['UserRepository', 'FileUploaderService'],
2332
- },
2333
- ], imports: [provideFirebaseApp((injector) => {
2334
- const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
2335
- try {
2336
- return getApp(appName);
2337
- }
2338
- catch (error) {
2339
- return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
2340
- }
2341
- }),
2342
- AngularElasticSeachModule,
2343
- AngularFirebaseAuthModule,
2344
- AngularFirestoreModule,
2345
- AngularHasuraGraphQLModule] });
2346
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, decorators: [{
2347
- type: NgModule,
2348
- args: [{
2349
- imports: [
2350
- provideFirebaseApp((injector) => {
2351
- const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
2352
- try {
2353
- return getApp(appName);
2354
- }
2355
- catch (error) {
2356
- return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
2357
- }
2358
- }),
2359
- AngularElasticSeachModule,
2360
- AngularFirebaseAuthModule,
2361
- AngularFirestoreModule,
2362
- AngularHasuraGraphQLModule,
2363
- ],
2364
- providers: [
2365
- AuthService,
2366
- CartService,
2367
- CatalogService,
2368
- CategoryService,
2369
- CheckoutService,
2370
- CheckoutSubscriptionService,
2371
- CouponService,
2372
- HomeShopService,
2373
- OrderService,
2374
- ShippingService,
2375
- WishlistService,
2376
- {
2377
- provide: UpdateUserImage,
2378
- useFactory: (userRepository, fileUploader) => {
2379
- return new UpdateUserImage(userRepository, fileUploader);
2380
- },
2381
- deps: ['UserRepository', 'FileUploaderService'],
2382
- },
2383
- ],
2384
- }]
2286
+ class AngularConnectModule {
2287
+ static initializeApp(defaultShop, options, nameOrConfig) {
2288
+ return {
2289
+ ngModule: AngularConnectModule,
2290
+ providers: [
2291
+ {
2292
+ provide: CATEGORY_STRUCTURE,
2293
+ useClass: isNil(options === null || options === void 0 ? void 0 : options.oldCategoryStructure) || (options === null || options === void 0 ? void 0 : options.oldCategoryStructure)
2294
+ ? OldCategoryStructureAdapter
2295
+ : NewCategoryStructureAdapter,
2296
+ },
2297
+ ...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
2298
+ ...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options === null || options === void 0 ? void 0 : options.firebase }]),
2299
+ ...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
2300
+ ...(isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
2301
+ ...(isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
2302
+ ...(isNil(options === null || options === void 0 ? void 0 : options.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]),
2303
+ ...(isNil(options === null || options === void 0 ? void 0 : options.storageBaseUrl) ? [] : [{ provide: STORAGE_BASE_URL, useValue: options.storageBaseUrl }]),
2304
+ ],
2305
+ };
2306
+ }
2307
+ }
2308
+ AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2309
+ AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, imports: [i1$4.FirebaseAppModule, AngularElasticSeachModule,
2310
+ AngularFirebaseAuthModule,
2311
+ AngularFirestoreModule,
2312
+ AngularHasuraGraphQLModule] });
2313
+ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, providers: [
2314
+ AuthService,
2315
+ CartService,
2316
+ CatalogService,
2317
+ CategoryService,
2318
+ CheckoutService,
2319
+ CheckoutSubscriptionService,
2320
+ CouponService,
2321
+ HomeShopService,
2322
+ OrderService,
2323
+ ShippingService,
2324
+ WishlistService,
2325
+ {
2326
+ provide: UpdateUserImage,
2327
+ useFactory: (userRepository, fileUploader) => {
2328
+ return new UpdateUserImage(userRepository, fileUploader);
2329
+ },
2330
+ deps: ['UserRepository', 'FileUploaderService'],
2331
+ },
2332
+ ], imports: [provideFirebaseApp((injector) => {
2333
+ const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
2334
+ try {
2335
+ return getApp(appName);
2336
+ }
2337
+ catch (error) {
2338
+ return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
2339
+ }
2340
+ }),
2341
+ AngularElasticSeachModule,
2342
+ AngularFirebaseAuthModule,
2343
+ AngularFirestoreModule,
2344
+ AngularHasuraGraphQLModule] });
2345
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, decorators: [{
2346
+ type: NgModule,
2347
+ args: [{
2348
+ imports: [
2349
+ provideFirebaseApp((injector) => {
2350
+ const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
2351
+ try {
2352
+ return getApp(appName);
2353
+ }
2354
+ catch (error) {
2355
+ return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
2356
+ }
2357
+ }),
2358
+ AngularElasticSeachModule,
2359
+ AngularFirebaseAuthModule,
2360
+ AngularFirestoreModule,
2361
+ AngularHasuraGraphQLModule,
2362
+ ],
2363
+ providers: [
2364
+ AuthService,
2365
+ CartService,
2366
+ CatalogService,
2367
+ CategoryService,
2368
+ CheckoutService,
2369
+ CheckoutSubscriptionService,
2370
+ CouponService,
2371
+ HomeShopService,
2372
+ OrderService,
2373
+ ShippingService,
2374
+ WishlistService,
2375
+ {
2376
+ provide: UpdateUserImage,
2377
+ useFactory: (userRepository, fileUploader) => {
2378
+ return new UpdateUserImage(userRepository, fileUploader);
2379
+ },
2380
+ deps: ['UserRepository', 'FileUploaderService'],
2381
+ },
2382
+ ],
2383
+ }]
2385
2384
  }] });
2386
2385
 
2387
- /**
2388
- * Generated bundle index. Do not edit.
2386
+ /**
2387
+ * Generated bundle index. Do not edit.
2389
2388
  */
2390
2389
 
2391
2390
  export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderService, ProductSorts, ShippingService, UtilHelper, WishlistService };