@infrab4a/connect-angular 4.18.0 → 4.18.1

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