@infrab4a/connect-angular 4.3.12 → 4.3.14

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