@infrab4a/connect-angular 3.9.5 → 3.10.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/angular-connect.module.d.ts +19 -19
  2. package/angular-elastic-search.module.d.ts +9 -9
  3. package/angular-firebase-auth.module.d.ts +10 -10
  4. package/angular-firestore.module.d.ts +15 -15
  5. package/angular-hasura-graphql.module.d.ts +16 -16
  6. package/bundles/infrab4a-connect-angular.umd.js +2123 -2160
  7. package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
  8. package/consts/backend-url.const.d.ts +1 -1
  9. package/consts/default-shop.const.d.ts +1 -1
  10. package/consts/es-config.const.d.ts +1 -1
  11. package/consts/hasura-options.const.d.ts +1 -1
  12. package/consts/index.d.ts +4 -4
  13. package/esm2015/angular-connect.module.js +52 -52
  14. package/esm2015/angular-elastic-search.module.js +34 -34
  15. package/esm2015/angular-firebase-auth.module.js +113 -113
  16. package/esm2015/angular-firestore.module.js +394 -394
  17. package/esm2015/angular-hasura-graphql.module.js +156 -156
  18. package/esm2015/consts/backend-url.const.js +1 -1
  19. package/esm2015/consts/default-shop.const.js +2 -2
  20. package/esm2015/consts/es-config.const.js +2 -2
  21. package/esm2015/consts/hasura-options.const.js +2 -2
  22. package/esm2015/consts/index.js +5 -5
  23. package/esm2015/index.js +6 -6
  24. package/esm2015/infrab4a-connect-angular.js +4 -4
  25. package/esm2015/services/auth.service.js +42 -42
  26. package/esm2015/services/cart.service.js +261 -271
  27. package/esm2015/services/checkout-subscription.service.js +53 -53
  28. package/esm2015/services/checkout.service.js +70 -75
  29. package/esm2015/services/coupon.service.js +222 -249
  30. package/esm2015/services/home-shop.service.js +116 -116
  31. package/esm2015/services/index.js +9 -9
  32. package/esm2015/services/order.service.js +32 -32
  33. package/esm2015/services/shipping.service.js +98 -98
  34. package/esm2015/services/types/index.js +3 -3
  35. package/esm2015/services/types/required-checkout-data.type.js +2 -2
  36. package/esm2015/services/types/required-checkout-subscription-data.type.js +2 -2
  37. package/esm2015/services/types/shipping-methods.type.js +2 -2
  38. package/fesm2015/infrab4a-connect-angular.js +1521 -1577
  39. package/fesm2015/infrab4a-connect-angular.js.map +1 -1
  40. package/index.d.ts +5 -5
  41. package/infrab4a-connect-angular.d.ts +5 -5
  42. package/package.json +2 -2
  43. package/services/auth.service.d.ts +19 -19
  44. package/services/cart.service.d.ts +40 -41
  45. package/services/checkout-subscription.service.d.ts +18 -18
  46. package/services/checkout.service.d.ts +23 -23
  47. package/services/coupon.service.d.ts +27 -25
  48. package/services/home-shop.service.d.ts +25 -25
  49. package/services/index.d.ts +8 -8
  50. package/services/order.service.d.ts +13 -13
  51. package/services/shipping.service.d.ts +19 -19
  52. package/services/types/index.d.ts +2 -2
  53. package/services/types/required-checkout-data.type.d.ts +2 -2
  54. package/services/types/required-checkout-subscription-data.type.d.ts +2 -2
  55. package/services/types/shipping-methods.type.d.ts +12 -12
  56. package/esm2015/services/errors/group-invalid-coupon.error.js +0 -8
  57. package/esm2015/services/errors/index.js +0 -3
  58. package/esm2015/services/errors/invalid-coupon.error.js +0 -8
  59. package/services/errors/group-invalid-coupon.error.d.ts +0 -6
  60. package/services/errors/index.d.ts +0 -2
  61. package/services/errors/invalid-coupon.error.d.ts +0 -5
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('@angular/fire/auth'), require('@infrab4a/connect'), require('js-cookie'), require('ts-custom-error'), require('@angular/fire/firestore'), require('@angular/common/http'), require('@angular/fire')) :
3
- typeof define === 'function' && define.amd ? define('@infrab4a/connect-angular', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', '@angular/fire/auth', '@infrab4a/connect', 'js-cookie', 'ts-custom-error', '@angular/fire/firestore', '@angular/common/http', '@angular/fire'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a["connect-angular"] = {}), global.ng.core, global.rxjs, global.rxjs.operators, global.ng.fire.auth, global["@infrab4a/connect"], global["js-cookie"], global["ts-custom-error"], global.ng.fire.firestore, global.ng.common.http, global.ng.fire));
5
- })(this, (function (exports, i0, rxjs, operators, i1, i3, cookie, tsCustomError, i1$1, i1$2, fire) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('@angular/fire/auth'), require('@infrab4a/connect'), require('js-cookie'), require('@angular/fire/firestore'), require('@angular/common/http'), require('@angular/fire')) :
3
+ typeof define === 'function' && define.amd ? define('@infrab4a/connect-angular', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', '@angular/fire/auth', '@infrab4a/connect', 'js-cookie', '@angular/fire/firestore', '@angular/common/http', '@angular/fire'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a["connect-angular"] = {}), global.ng.core, global.rxjs, global.rxjs.operators, global.ng.fire.auth, global["@infrab4a/connect"], global["js-cookie"], global.ng.fire.firestore, global.ng.common.http, global.ng.fire));
5
+ })(this, (function (exports, i0, rxjs, operators, i1, i3, cookie, i1$1, i1$2, fire) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -31,363 +31,363 @@
31
31
  var i1__namespace$1 = /*#__PURE__*/_interopNamespace(i1$1);
32
32
  var i1__namespace$2 = /*#__PURE__*/_interopNamespace(i1$2);
33
33
 
34
- /*! *****************************************************************************
35
- Copyright (c) Microsoft Corporation.
36
-
37
- Permission to use, copy, modify, and/or distribute this software for any
38
- purpose with or without fee is hereby granted.
39
-
40
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
41
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
42
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
43
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
44
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
45
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
46
- PERFORMANCE OF THIS SOFTWARE.
47
- ***************************************************************************** */
48
- /* global Reflect, Promise */
49
- var extendStatics = function (d, b) {
50
- extendStatics = Object.setPrototypeOf ||
51
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
52
- function (d, b) { for (var p in b)
53
- if (Object.prototype.hasOwnProperty.call(b, p))
54
- d[p] = b[p]; };
55
- return extendStatics(d, b);
56
- };
57
- function __extends(d, b) {
58
- if (typeof b !== "function" && b !== null)
59
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
60
- extendStatics(d, b);
61
- function __() { this.constructor = d; }
62
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
63
- }
64
- var __assign = function () {
65
- __assign = Object.assign || function __assign(t) {
66
- for (var s, i = 1, n = arguments.length; i < n; i++) {
67
- s = arguments[i];
68
- for (var p in s)
69
- if (Object.prototype.hasOwnProperty.call(s, p))
70
- t[p] = s[p];
71
- }
72
- return t;
73
- };
74
- return __assign.apply(this, arguments);
75
- };
76
- function __rest(s, e) {
77
- var t = {};
78
- for (var p in s)
79
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
80
- t[p] = s[p];
81
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
82
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
83
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
84
- t[p[i]] = s[p[i]];
85
- }
86
- return t;
87
- }
88
- function __decorate(decorators, target, key, desc) {
89
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
90
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
91
- r = Reflect.decorate(decorators, target, key, desc);
92
- else
93
- for (var i = decorators.length - 1; i >= 0; i--)
94
- if (d = decorators[i])
95
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
96
- return c > 3 && r && Object.defineProperty(target, key, r), r;
97
- }
98
- function __param(paramIndex, decorator) {
99
- return function (target, key) { decorator(target, key, paramIndex); };
100
- }
101
- function __metadata(metadataKey, metadataValue) {
102
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
103
- return Reflect.metadata(metadataKey, metadataValue);
104
- }
105
- function __awaiter(thisArg, _arguments, P, generator) {
106
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
107
- return new (P || (P = Promise))(function (resolve, reject) {
108
- function fulfilled(value) { try {
109
- step(generator.next(value));
110
- }
111
- catch (e) {
112
- reject(e);
113
- } }
114
- function rejected(value) { try {
115
- step(generator["throw"](value));
116
- }
117
- catch (e) {
118
- reject(e);
119
- } }
120
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
121
- step((generator = generator.apply(thisArg, _arguments || [])).next());
122
- });
123
- }
124
- function __generator(thisArg, body) {
125
- var _ = { label: 0, sent: function () { if (t[0] & 1)
126
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
127
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
128
- function verb(n) { return function (v) { return step([n, v]); }; }
129
- function step(op) {
130
- if (f)
131
- throw new TypeError("Generator is already executing.");
132
- while (_)
133
- try {
134
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
135
- return t;
136
- if (y = 0, t)
137
- op = [op[0] & 2, t.value];
138
- switch (op[0]) {
139
- case 0:
140
- case 1:
141
- t = op;
142
- break;
143
- case 4:
144
- _.label++;
145
- return { value: op[1], done: false };
146
- case 5:
147
- _.label++;
148
- y = op[1];
149
- op = [0];
150
- continue;
151
- case 7:
152
- op = _.ops.pop();
153
- _.trys.pop();
154
- continue;
155
- default:
156
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
157
- _ = 0;
158
- continue;
159
- }
160
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
161
- _.label = op[1];
162
- break;
163
- }
164
- if (op[0] === 6 && _.label < t[1]) {
165
- _.label = t[1];
166
- t = op;
167
- break;
168
- }
169
- if (t && _.label < t[2]) {
170
- _.label = t[2];
171
- _.ops.push(op);
172
- break;
173
- }
174
- if (t[2])
175
- _.ops.pop();
176
- _.trys.pop();
177
- continue;
178
- }
179
- op = body.call(thisArg, _);
180
- }
181
- catch (e) {
182
- op = [6, e];
183
- y = 0;
184
- }
185
- finally {
186
- f = t = 0;
187
- }
188
- if (op[0] & 5)
189
- throw op[1];
190
- return { value: op[0] ? op[1] : void 0, done: true };
191
- }
192
- }
193
- var __createBinding = Object.create ? (function (o, m, k, k2) {
194
- if (k2 === undefined)
195
- k2 = k;
196
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
197
- }) : (function (o, m, k, k2) {
198
- if (k2 === undefined)
199
- k2 = k;
200
- o[k2] = m[k];
201
- });
202
- function __exportStar(m, o) {
203
- for (var p in m)
204
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
205
- __createBinding(o, m, p);
206
- }
207
- function __values(o) {
208
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
209
- if (m)
210
- return m.call(o);
211
- if (o && typeof o.length === "number")
212
- return {
213
- next: function () {
214
- if (o && i >= o.length)
215
- o = void 0;
216
- return { value: o && o[i++], done: !o };
217
- }
218
- };
219
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
220
- }
221
- function __read(o, n) {
222
- var m = typeof Symbol === "function" && o[Symbol.iterator];
223
- if (!m)
224
- return o;
225
- var i = m.call(o), r, ar = [], e;
226
- try {
227
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
228
- ar.push(r.value);
229
- }
230
- catch (error) {
231
- e = { error: error };
232
- }
233
- finally {
234
- try {
235
- if (r && !r.done && (m = i["return"]))
236
- m.call(i);
237
- }
238
- finally {
239
- if (e)
240
- throw e.error;
241
- }
242
- }
243
- return ar;
244
- }
245
- /** @deprecated */
246
- function __spread() {
247
- for (var ar = [], i = 0; i < arguments.length; i++)
248
- ar = ar.concat(__read(arguments[i]));
249
- return ar;
250
- }
251
- /** @deprecated */
252
- function __spreadArrays() {
253
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
254
- s += arguments[i].length;
255
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
256
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
257
- r[k] = a[j];
258
- return r;
259
- }
260
- function __spreadArray(to, from, pack) {
261
- if (pack || arguments.length === 2)
262
- for (var i = 0, l = from.length, ar; i < l; i++) {
263
- if (ar || !(i in from)) {
264
- if (!ar)
265
- ar = Array.prototype.slice.call(from, 0, i);
266
- ar[i] = from[i];
267
- }
268
- }
269
- return to.concat(ar || Array.prototype.slice.call(from));
270
- }
271
- function __await(v) {
272
- return this instanceof __await ? (this.v = v, this) : new __await(v);
273
- }
274
- function __asyncGenerator(thisArg, _arguments, generator) {
275
- if (!Symbol.asyncIterator)
276
- throw new TypeError("Symbol.asyncIterator is not defined.");
277
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
278
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
279
- function verb(n) { if (g[n])
280
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
281
- function resume(n, v) { try {
282
- step(g[n](v));
283
- }
284
- catch (e) {
285
- settle(q[0][3], e);
286
- } }
287
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
288
- function fulfill(value) { resume("next", value); }
289
- function reject(value) { resume("throw", value); }
290
- function settle(f, v) { if (f(v), q.shift(), q.length)
291
- resume(q[0][0], q[0][1]); }
292
- }
293
- function __asyncDelegator(o) {
294
- var i, p;
295
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
296
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
297
- }
298
- function __asyncValues(o) {
299
- if (!Symbol.asyncIterator)
300
- throw new TypeError("Symbol.asyncIterator is not defined.");
301
- var m = o[Symbol.asyncIterator], i;
302
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
303
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
304
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
305
- }
306
- function __makeTemplateObject(cooked, raw) {
307
- if (Object.defineProperty) {
308
- Object.defineProperty(cooked, "raw", { value: raw });
309
- }
310
- else {
311
- cooked.raw = raw;
312
- }
313
- return cooked;
314
- }
315
- ;
316
- var __setModuleDefault = Object.create ? (function (o, v) {
317
- Object.defineProperty(o, "default", { enumerable: true, value: v });
318
- }) : function (o, v) {
319
- o["default"] = v;
320
- };
321
- function __importStar(mod) {
322
- if (mod && mod.__esModule)
323
- return mod;
324
- var result = {};
325
- if (mod != null)
326
- for (var k in mod)
327
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
328
- __createBinding(result, mod, k);
329
- __setModuleDefault(result, mod);
330
- return result;
331
- }
332
- function __importDefault(mod) {
333
- return (mod && mod.__esModule) ? mod : { default: mod };
334
- }
335
- function __classPrivateFieldGet(receiver, state, kind, f) {
336
- if (kind === "a" && !f)
337
- throw new TypeError("Private accessor was defined without a getter");
338
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
339
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
340
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
341
- }
342
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
343
- if (kind === "m")
344
- throw new TypeError("Private method is not writable");
345
- if (kind === "a" && !f)
346
- throw new TypeError("Private accessor was defined without a setter");
347
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
348
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
349
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
34
+ /*! *****************************************************************************
35
+ Copyright (c) Microsoft Corporation.
36
+
37
+ Permission to use, copy, modify, and/or distribute this software for any
38
+ purpose with or without fee is hereby granted.
39
+
40
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
41
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
42
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
43
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
44
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
45
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
46
+ PERFORMANCE OF THIS SOFTWARE.
47
+ ***************************************************************************** */
48
+ /* global Reflect, Promise */
49
+ var extendStatics = function (d, b) {
50
+ extendStatics = Object.setPrototypeOf ||
51
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
52
+ function (d, b) { for (var p in b)
53
+ if (Object.prototype.hasOwnProperty.call(b, p))
54
+ d[p] = b[p]; };
55
+ return extendStatics(d, b);
56
+ };
57
+ function __extends(d, b) {
58
+ if (typeof b !== "function" && b !== null)
59
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
60
+ extendStatics(d, b);
61
+ function __() { this.constructor = d; }
62
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
63
+ }
64
+ var __assign = function () {
65
+ __assign = Object.assign || function __assign(t) {
66
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
67
+ s = arguments[i];
68
+ for (var p in s)
69
+ if (Object.prototype.hasOwnProperty.call(s, p))
70
+ t[p] = s[p];
71
+ }
72
+ return t;
73
+ };
74
+ return __assign.apply(this, arguments);
75
+ };
76
+ function __rest(s, e) {
77
+ var t = {};
78
+ for (var p in s)
79
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
80
+ t[p] = s[p];
81
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
82
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
83
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
84
+ t[p[i]] = s[p[i]];
85
+ }
86
+ return t;
87
+ }
88
+ function __decorate(decorators, target, key, desc) {
89
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
90
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
91
+ r = Reflect.decorate(decorators, target, key, desc);
92
+ else
93
+ for (var i = decorators.length - 1; i >= 0; i--)
94
+ if (d = decorators[i])
95
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
96
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
97
+ }
98
+ function __param(paramIndex, decorator) {
99
+ return function (target, key) { decorator(target, key, paramIndex); };
100
+ }
101
+ function __metadata(metadataKey, metadataValue) {
102
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
103
+ return Reflect.metadata(metadataKey, metadataValue);
104
+ }
105
+ function __awaiter(thisArg, _arguments, P, generator) {
106
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
107
+ return new (P || (P = Promise))(function (resolve, reject) {
108
+ function fulfilled(value) { try {
109
+ step(generator.next(value));
110
+ }
111
+ catch (e) {
112
+ reject(e);
113
+ } }
114
+ function rejected(value) { try {
115
+ step(generator["throw"](value));
116
+ }
117
+ catch (e) {
118
+ reject(e);
119
+ } }
120
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
121
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
122
+ });
123
+ }
124
+ function __generator(thisArg, body) {
125
+ var _ = { label: 0, sent: function () { if (t[0] & 1)
126
+ throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
127
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
128
+ function verb(n) { return function (v) { return step([n, v]); }; }
129
+ function step(op) {
130
+ if (f)
131
+ throw new TypeError("Generator is already executing.");
132
+ while (_)
133
+ try {
134
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
135
+ return t;
136
+ if (y = 0, t)
137
+ op = [op[0] & 2, t.value];
138
+ switch (op[0]) {
139
+ case 0:
140
+ case 1:
141
+ t = op;
142
+ break;
143
+ case 4:
144
+ _.label++;
145
+ return { value: op[1], done: false };
146
+ case 5:
147
+ _.label++;
148
+ y = op[1];
149
+ op = [0];
150
+ continue;
151
+ case 7:
152
+ op = _.ops.pop();
153
+ _.trys.pop();
154
+ continue;
155
+ default:
156
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
157
+ _ = 0;
158
+ continue;
159
+ }
160
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
161
+ _.label = op[1];
162
+ break;
163
+ }
164
+ if (op[0] === 6 && _.label < t[1]) {
165
+ _.label = t[1];
166
+ t = op;
167
+ break;
168
+ }
169
+ if (t && _.label < t[2]) {
170
+ _.label = t[2];
171
+ _.ops.push(op);
172
+ break;
173
+ }
174
+ if (t[2])
175
+ _.ops.pop();
176
+ _.trys.pop();
177
+ continue;
178
+ }
179
+ op = body.call(thisArg, _);
180
+ }
181
+ catch (e) {
182
+ op = [6, e];
183
+ y = 0;
184
+ }
185
+ finally {
186
+ f = t = 0;
187
+ }
188
+ if (op[0] & 5)
189
+ throw op[1];
190
+ return { value: op[0] ? op[1] : void 0, done: true };
191
+ }
192
+ }
193
+ var __createBinding = Object.create ? (function (o, m, k, k2) {
194
+ if (k2 === undefined)
195
+ k2 = k;
196
+ Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
197
+ }) : (function (o, m, k, k2) {
198
+ if (k2 === undefined)
199
+ k2 = k;
200
+ o[k2] = m[k];
201
+ });
202
+ function __exportStar(m, o) {
203
+ for (var p in m)
204
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
205
+ __createBinding(o, m, p);
206
+ }
207
+ function __values(o) {
208
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
209
+ if (m)
210
+ return m.call(o);
211
+ if (o && typeof o.length === "number")
212
+ return {
213
+ next: function () {
214
+ if (o && i >= o.length)
215
+ o = void 0;
216
+ return { value: o && o[i++], done: !o };
217
+ }
218
+ };
219
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
220
+ }
221
+ function __read(o, n) {
222
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
223
+ if (!m)
224
+ return o;
225
+ var i = m.call(o), r, ar = [], e;
226
+ try {
227
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
228
+ ar.push(r.value);
229
+ }
230
+ catch (error) {
231
+ e = { error: error };
232
+ }
233
+ finally {
234
+ try {
235
+ if (r && !r.done && (m = i["return"]))
236
+ m.call(i);
237
+ }
238
+ finally {
239
+ if (e)
240
+ throw e.error;
241
+ }
242
+ }
243
+ return ar;
244
+ }
245
+ /** @deprecated */
246
+ function __spread() {
247
+ for (var ar = [], i = 0; i < arguments.length; i++)
248
+ ar = ar.concat(__read(arguments[i]));
249
+ return ar;
250
+ }
251
+ /** @deprecated */
252
+ function __spreadArrays() {
253
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++)
254
+ s += arguments[i].length;
255
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
256
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
257
+ r[k] = a[j];
258
+ return r;
259
+ }
260
+ function __spreadArray(to, from, pack) {
261
+ if (pack || arguments.length === 2)
262
+ for (var i = 0, l = from.length, ar; i < l; i++) {
263
+ if (ar || !(i in from)) {
264
+ if (!ar)
265
+ ar = Array.prototype.slice.call(from, 0, i);
266
+ ar[i] = from[i];
267
+ }
268
+ }
269
+ return to.concat(ar || Array.prototype.slice.call(from));
270
+ }
271
+ function __await(v) {
272
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
273
+ }
274
+ function __asyncGenerator(thisArg, _arguments, generator) {
275
+ if (!Symbol.asyncIterator)
276
+ throw new TypeError("Symbol.asyncIterator is not defined.");
277
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
278
+ return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
279
+ function verb(n) { if (g[n])
280
+ i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
281
+ function resume(n, v) { try {
282
+ step(g[n](v));
283
+ }
284
+ catch (e) {
285
+ settle(q[0][3], e);
286
+ } }
287
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
288
+ function fulfill(value) { resume("next", value); }
289
+ function reject(value) { resume("throw", value); }
290
+ function settle(f, v) { if (f(v), q.shift(), q.length)
291
+ resume(q[0][0], q[0][1]); }
292
+ }
293
+ function __asyncDelegator(o) {
294
+ var i, p;
295
+ return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
296
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
297
+ }
298
+ function __asyncValues(o) {
299
+ if (!Symbol.asyncIterator)
300
+ throw new TypeError("Symbol.asyncIterator is not defined.");
301
+ var m = o[Symbol.asyncIterator], i;
302
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
303
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
304
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
305
+ }
306
+ function __makeTemplateObject(cooked, raw) {
307
+ if (Object.defineProperty) {
308
+ Object.defineProperty(cooked, "raw", { value: raw });
309
+ }
310
+ else {
311
+ cooked.raw = raw;
312
+ }
313
+ return cooked;
314
+ }
315
+ ;
316
+ var __setModuleDefault = Object.create ? (function (o, v) {
317
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
318
+ }) : function (o, v) {
319
+ o["default"] = v;
320
+ };
321
+ function __importStar(mod) {
322
+ if (mod && mod.__esModule)
323
+ return mod;
324
+ var result = {};
325
+ if (mod != null)
326
+ for (var k in mod)
327
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
328
+ __createBinding(result, mod, k);
329
+ __setModuleDefault(result, mod);
330
+ return result;
331
+ }
332
+ function __importDefault(mod) {
333
+ return (mod && mod.__esModule) ? mod : { default: mod };
334
+ }
335
+ function __classPrivateFieldGet(receiver, state, kind, f) {
336
+ if (kind === "a" && !f)
337
+ throw new TypeError("Private accessor was defined without a getter");
338
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
339
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
340
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
341
+ }
342
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
343
+ if (kind === "m")
344
+ throw new TypeError("Private method is not writable");
345
+ if (kind === "a" && !f)
346
+ throw new TypeError("Private accessor was defined without a setter");
347
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
348
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
349
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
350
350
  }
351
351
 
352
- var AuthService = /** @class */ (function () {
353
- function AuthService(angularFireAuth, userRepository) {
354
- this.angularFireAuth = angularFireAuth;
355
- this.userRepository = userRepository;
356
- }
357
- AuthService.prototype.getAuthstate = function () {
358
- var observables = [
359
- this.angularFireAuth.authState.pipe(operators.catchError(function () { return rxjs.of(null); })),
360
- this.getUser().pipe(operators.catchError(function () { return rxjs.of(null); })),
361
- ];
362
- return rxjs.combineLatest(observables).pipe(operators.map(function (_a) {
363
- var _b = __read(_a, 2), fireUser = _b[0], user = _b[1];
364
- return {
365
- user: user,
366
- isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
367
- };
368
- }));
369
- };
370
- AuthService.prototype.getUser = function () {
371
- var _this = this;
372
- return this.getFireUser().pipe(operators.map(function (user) { return user === null || user === void 0 ? void 0 : user.uid; }), operators.mergeMap(function (id) { return (id ? rxjs.from(_this.userRepository.get({ id: id })).pipe(operators.catchError(function () { return rxjs.of(null); })) : rxjs.of(null)); }));
373
- };
374
- AuthService.prototype.getTokenId = function () {
375
- return this.angularFireAuth.idToken;
376
- };
377
- AuthService.prototype.getFireUser = function () {
378
- return this.angularFireAuth.user.pipe(operators.catchError(function () { return rxjs.of(null); }));
379
- };
380
- return AuthService;
381
- }());
382
- AuthService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AuthService, deps: [{ token: i1__namespace.AngularFireAuth }, { token: 'UserRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
383
- AuthService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AuthService });
384
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AuthService, decorators: [{
385
- type: i0.Injectable
386
- }], ctorParameters: function () {
387
- return [{ type: i1__namespace.AngularFireAuth }, { type: undefined, decorators: [{
388
- type: i0.Inject,
389
- args: ['UserRepository']
390
- }] }];
352
+ var AuthService = /** @class */ (function () {
353
+ function AuthService(angularFireAuth, userRepository) {
354
+ this.angularFireAuth = angularFireAuth;
355
+ this.userRepository = userRepository;
356
+ }
357
+ AuthService.prototype.getAuthstate = function () {
358
+ var observables = [
359
+ this.angularFireAuth.authState.pipe(operators.catchError(function () { return rxjs.of(null); })),
360
+ this.getUser().pipe(operators.catchError(function () { return rxjs.of(null); })),
361
+ ];
362
+ return rxjs.combineLatest(observables).pipe(operators.map(function (_a) {
363
+ var _b = __read(_a, 2), fireUser = _b[0], user = _b[1];
364
+ return {
365
+ user: user,
366
+ isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
367
+ };
368
+ }));
369
+ };
370
+ AuthService.prototype.getUser = function () {
371
+ var _this = this;
372
+ return this.getFireUser().pipe(operators.map(function (user) { return user === null || user === void 0 ? void 0 : user.uid; }), operators.mergeMap(function (id) { return (id ? rxjs.from(_this.userRepository.get({ id: id })).pipe(operators.catchError(function () { return rxjs.of(null); })) : rxjs.of(null)); }));
373
+ };
374
+ AuthService.prototype.getTokenId = function () {
375
+ return this.angularFireAuth.idToken;
376
+ };
377
+ AuthService.prototype.getFireUser = function () {
378
+ return this.angularFireAuth.user.pipe(operators.catchError(function () { return rxjs.of(null); }));
379
+ };
380
+ return AuthService;
381
+ }());
382
+ AuthService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AuthService, deps: [{ token: i1__namespace.AngularFireAuth }, { token: 'UserRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
383
+ AuthService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AuthService });
384
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AuthService, decorators: [{
385
+ type: i0.Injectable
386
+ }], ctorParameters: function () {
387
+ return [{ type: i1__namespace.AngularFireAuth }, { type: undefined, decorators: [{
388
+ type: i0.Inject,
389
+ args: ['UserRepository']
390
+ }] }];
391
391
  } });
392
392
 
393
393
  var BACKEND_URL = 'BACKEND_URL';
@@ -398,1831 +398,1794 @@
398
398
 
399
399
  var HASURA_OPTIONS = 'HASURA_OPTIONS';
400
400
 
401
- var InvalidCouponError = /** @class */ (function (_super) {
402
- __extends(InvalidCouponError, _super);
403
- function InvalidCouponError(message) {
404
- var _this = _super.call(this, message) || this;
405
- _this.message = message;
406
- return _this;
407
- }
408
- return InvalidCouponError;
409
- }(tsCustomError.CustomError));
410
-
411
- var GroupInvalidCouponError = /** @class */ (function (_super) {
412
- __extends(GroupInvalidCouponError, _super);
413
- function GroupInvalidCouponError(errors) {
414
- var _this = _super.call(this, 'Many coupon errors throw') || this;
415
- _this.errors = errors;
416
- return _this;
417
- }
418
- return GroupInvalidCouponError;
419
- }(tsCustomError.CustomError));
420
-
421
- var CouponService = /** @class */ (function () {
422
- function CouponService(couponRepository, defaultShop, orderRepository, categoryRepository) {
423
- var _this = this;
424
- this.couponRepository = couponRepository;
425
- this.defaultShop = defaultShop;
426
- this.orderRepository = orderRepository;
427
- this.categoryRepository = categoryRepository;
428
- this.emailIsFromCollaborator = function (userEmail) { return !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g)); };
429
- this.separateValidCoupons = function (coupons, userEmail) { return coupons
430
- .map(function (coupon) {
431
- try {
432
- if (!(coupon instanceof i3.Coupon))
433
- throw new InvalidCouponError('Cupom inválido.');
434
- if (_this.isValidCoupon(coupon, userEmail))
435
- return coupon;
436
- }
437
- catch (error) {
438
- return error;
439
- }
440
- })
441
- .reduce(function (current, coupon) { return (Object.assign(Object.assign({}, current), (coupon instanceof i3.Coupon
442
- ? { valids: __spreadArray(__spreadArray([], __read(current.valids)), [coupon]) }
443
- : { invalids: __spreadArray(__spreadArray([], __read(current.invalids)), [coupon]) }))); }, {
444
- valids: [],
445
- invalids: [],
446
- }); };
447
- }
448
- CouponService.prototype.checkCoupon = function (nickname, userEmail, checkoutType, plan, checkout, isSubscription) {
449
- var _this = this;
450
- return rxjs.from(this.couponRepository.find({
451
- filters: {
452
- nickname: { operator: i3.Where.EQUALS, value: nickname },
453
- active: { operator: i3.Where.EQUALS, value: true },
454
- },
455
- })).pipe(operators.concatMap(function (coupons) { return _this.checkCouponRules(coupons, checkoutType, plan, checkout, isSubscription); }), operators.concatMap(function (coupon) { return _this.checkCouponUseAndLimit(coupon, userEmail, checkout); }), operators.map(function (coupon) { return _this.isValidCoupon(coupon, userEmail); }), operators.map(function (coupon) { return coupon; }));
456
- };
457
- CouponService.prototype.checkCouponRules = function (coupons, checkoutType, plan, checkout, isSubscription) {
458
- // Caso não ache nenhum cupom, retorna erro
459
- if (coupons.count < 1) {
460
- return rxjs.throwError('Cupom inválido.');
461
- }
462
- // Get Primeiro Cupom (o find do repository retorna um array)
463
- var coupon = coupons.data.shift();
464
- // Verifica se o cupom é aplicavel na loja
465
- var isInShop = coupon.shopAvailability === i3.Shops.ALL || coupon.shopAvailability === this.defaultShop;
466
- // Cupon não aplicavel a loja retorna erro
467
- if (!isInShop)
468
- return rxjs.throwError('Cupom inválido para loja.');
469
- // Verifica se o coupon é aplicado no checkout que está sendo realizado
470
- var isCheckoutType = coupon.checkoutType === i3.CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
471
- // Cupon não aplicavel ao checkout retorna erro
472
- if (!isCheckoutType)
473
- return rxjs.throwError('Cupom inválido. Erro de checkout.');
474
- // Verifica se o cupom é ou pode ser aplicado para subscription
475
- if (checkoutType === i3.CheckoutTypes.ALL || checkoutType === i3.CheckoutTypes.SUBSCRIPTION) {
476
- // Se o cupom tiver um plano associado, verifica se é o mesmo plano do checkout da assinatura
477
- if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
478
- return rxjs.throwError('Cupom inválido para sua assinatura.');
479
- }
480
- if (isSubscription)
481
- return rxjs.of(coupon);
482
- // Verifica se possui o valor minimo de compra para utilização do cupom
483
- var hasMinSubTotal = this.hasMinSubTotal(coupon, checkout);
484
- // Se não tem valor mínimo atingido, retorna erro
485
- if (!hasMinSubTotal)
486
- return rxjs.throwError("Valor m\u00EDnimo de " + Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue) + " n\u00E3o atingido");
487
- return rxjs.of(coupon);
488
- };
489
- CouponService.prototype.isValidCoupon = function (coupon, userEmail) {
490
- // Verifica a data de inicio de validade do cupom
491
- if ((coupon === null || coupon === void 0 ? void 0 : coupon.beginAt) > new Date())
492
- throw new InvalidCouponError('Cupom ainda não liberado.');
493
- // Verifica a data de validade do cupom
494
- if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) < new Date())
495
- throw new InvalidCouponError('Cupom expirado.');
496
- return coupon;
497
- };
498
- CouponService.prototype.checkCouponUseAndLimit = function (coupon, userEmail, checkout) {
499
- return __awaiter(this, void 0, void 0, function () {
500
- var orders, ordersUserCoupon, validUser, hasProductCategories;
501
- return __generator(this, function (_d) {
502
- switch (_d.label) {
503
- case 0: return [4 /*yield*/, this.orderRepository.find({
504
- filters: {
505
- coupon: { id: coupon.id },
506
- payment: { status: 'paid' },
507
- },
508
- })];
509
- case 1:
510
- orders = _d.sent();
511
- ordersUserCoupon = orders.data.filter(function (o) { return o.user.email == userEmail; });
512
- // Verifica o limite de uso de cupom por usuario
513
- if (coupon.useLimitPerUser && ordersUserCoupon.length)
514
- throw new InvalidCouponError('Limite de uso por usuário atingido.');
515
- // Verifica o limite de uso geral por usuario
516
- if (coupon.useLimit && orders.data.length >= coupon.useLimit)
517
- throw new InvalidCouponError('Limite de uso atingido.');
518
- validUser = this.userValidationAndSubscriptionStatus(coupon, checkout === null || checkout === void 0 ? void 0 : checkout.user);
519
- if (!validUser)
520
- throw new InvalidCouponError('Usuário não elegível.');
521
- return [4 /*yield*/, this.hasProductCategories(coupon, checkout)];
522
- case 2:
523
- hasProductCategories = _d.sent();
524
- if (!hasProductCategories)
525
- throw 'Seu carrinho não possui produtos elegíveis para desconto.';
526
- return [2 /*return*/, coupon];
527
- }
528
- });
529
- });
530
- };
531
- CouponService.prototype.calcDiscountSubscription = function (coupon, checkout) {
532
- //
533
- var discount = 0;
534
- if (coupon.type === i3.CouponTypes.ABSOLUTE)
535
- discount = coupon.discount;
536
- else if (coupon.type === i3.CouponTypes.PERCENTAGE)
537
- discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount / 100);
538
- return rxjs.of(discount);
539
- };
540
- CouponService.prototype.calcDiscountShopping = function (coupon, checkout) {
541
- return __awaiter(this, void 0, void 0, function () {
542
- var discount, _d;
543
- return __generator(this, function (_e) {
544
- switch (_e.label) {
545
- case 0:
546
- discount = 0;
547
- _d = coupon.type;
548
- switch (_d) {
549
- case i3.CouponTypes.ABSOLUTE: return [3 /*break*/, 1];
550
- case i3.CouponTypes.PERCENTAGE: return [3 /*break*/, 2];
551
- }
552
- return [3 /*break*/, 4];
553
- case 1:
554
- {
555
- discount = coupon.discount;
556
- return [3 /*break*/, 4];
557
- }
558
- _e.label = 2;
559
- case 2: return [4 /*yield*/, this.calcShoppingPercentageDiscount(coupon, checkout)];
560
- case 3:
561
- discount = _e.sent();
562
- return [3 /*break*/, 4];
563
- case 4: return [2 /*return*/, discount];
564
- }
565
- });
566
- });
567
- };
568
- CouponService.prototype.calcShoppingPercentageDiscount = function (coupon, checkout) {
569
- var _a;
570
- return __awaiter(this, void 0, void 0, function () {
571
- var discount, shop, lineItensDiscount, couponCategories, subTotal;
572
- return __generator(this, function (_d) {
573
- switch (_d.label) {
574
- case 0:
575
- discount = 0;
576
- shop = checkout.shop;
577
- lineItensDiscount = [];
578
- return [4 /*yield*/, this.getCouponCategoriesId(coupon)];
579
- case 1:
580
- couponCategories = _d.sent();
581
- if (coupon.productsCategories && coupon.productsCategories.length) {
582
- lineItensDiscount = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter(function (i) {
583
- var _a;
584
- if ((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length) {
585
- return i.categories.some(function (c) { return couponCategories.some(function (cat) { return cat.id == c || cat.firestoreId == c; }); });
586
- }
587
- return true;
588
- });
589
- }
590
- else {
591
- lineItensDiscount = checkout.lineItems;
592
- }
593
- subTotal = lineItensDiscount.reduce(function (acc, curr) {
594
- var _a, _b, _c;
595
- return ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber) && ((_b = curr.price[shop]) === null || _b === void 0 ? void 0 : _b.subscriberPrice)
596
- ? acc + ((_c = curr.price[shop]) === null || _c === void 0 ? void 0 : _c.subscriberPrice) * curr.quantity
597
- : acc + curr.pricePaid * curr.quantity;
598
- }, 0) || 0;
599
- discount = subTotal * (coupon.discount / 100);
600
- return [2 /*return*/, discount];
601
- }
602
- });
603
- });
604
- };
605
- CouponService.prototype.hasMinSubTotal = function (coupon, checkout) {
606
- var _a;
607
- if (!coupon.minSubTotalValue)
608
- return true;
609
- var shop = checkout.shop;
610
- var subTotal = ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.reduce(function (acc, curr) {
611
- var _a, _b, _c;
612
- return ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber) && ((_b = curr.price[shop]) === null || _b === void 0 ? void 0 : _b.subscriberPrice)
613
- ? acc + ((_c = curr.price[shop]) === null || _c === void 0 ? void 0 : _c.subscriberPrice) * curr.quantity
614
- : acc + curr.pricePaid * curr.quantity;
615
- }, 0)) || 0;
616
- if (coupon.minSubTotalValue <= subTotal)
617
- return true;
618
- return false;
619
- };
620
- CouponService.prototype.hasProductCategories = function (coupon, checkout) {
621
- var _a;
622
- return __awaiter(this, void 0, void 0, function () {
623
- var couponCategories, hasCategories;
624
- return __generator(this, function (_d) {
625
- switch (_d.label) {
626
- case 0:
627
- if (!coupon.productsCategories || !coupon.productsCategories.length) {
628
- return [2 /*return*/, true];
629
- }
630
- return [4 /*yield*/, this.getCouponCategoriesId(coupon)];
631
- case 1:
632
- couponCategories = _d.sent();
633
- hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter(function (i) {
634
- var _a;
635
- if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length))
636
- return true;
637
- return i.categories.some(function (c) { return couponCategories.some(function (cat) { return cat.id == c || cat.firestoreId == c; }); });
638
- });
639
- return [2 /*return*/, hasCategories.length ? true : false];
640
- }
641
- });
642
- });
643
- };
644
- CouponService.prototype.userValidationAndSubscriptionStatus = function (coupon, user) {
645
- if (coupon.exclusivityType === i3.Exclusivities.ALL_USERS)
646
- return true;
647
- if (!user)
648
- return true;
649
- // Verifica se o email do usuário é coorporativo
650
- if (!this.emailIsFromCollaborator(user.email) && coupon.exclusivityType === i3.Exclusivities.COLLABORATORS)
651
- throw new InvalidCouponError('Você não é colaborador.');
652
- // Verifica se o email do usuário é associado ao cupom de uso por usuario
653
- if (coupon.exclusivityType === i3.Exclusivities.SPECIFIC_USER && coupon.userExclusiveEmail !== user.email)
654
- throw new InvalidCouponError('Cupom não é válido para este usuário.');
655
- switch (coupon.exclusivityType) {
656
- case i3.Exclusivities.ACTIVE_SUBSCRIBER:
657
- return user.isSubscriber ? true : false;
658
- case i3.Exclusivities.INACTIVE_SUBSCRIBER:
659
- return user.isSubscriber ? false : true;
660
- case i3.Exclusivities.NON_SUBSCRIBER:
661
- return user.isSubscriber ? false : true;
662
- }
663
- return true;
664
- };
665
- CouponService.prototype.getCouponCategoriesId = function (coupon) {
666
- return __awaiter(this, void 0, void 0, function () {
667
- var couponCategories, index, c;
668
- return __generator(this, function (_d) {
669
- switch (_d.label) {
670
- case 0:
671
- couponCategories = [];
672
- index = 0;
673
- _d.label = 1;
674
- case 1:
675
- if (!(index < coupon.productsCategories.length)) return [3 /*break*/, 4];
676
- return [4 /*yield*/, this.categoryRepository.get({
677
- id: coupon.productsCategories[index],
678
- })];
679
- case 2:
680
- c = _d.sent();
681
- couponCategories.push({ id: c.id, firestoreId: c.firestoreId });
682
- _d.label = 3;
683
- case 3:
684
- index++;
685
- return [3 /*break*/, 1];
686
- case 4: return [2 /*return*/, couponCategories];
687
- }
688
- });
689
- });
690
- };
691
- return CouponService;
692
- }());
693
- CouponService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
694
- CouponService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CouponService, providedIn: 'root' });
695
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CouponService, decorators: [{
696
- type: i0.Injectable,
697
- args: [{
698
- providedIn: 'root',
699
- }]
700
- }], ctorParameters: function () {
701
- return [{ type: undefined, decorators: [{
702
- type: i0.Inject,
703
- args: ['CouponRepository']
704
- }] }, { type: i3__namespace.Shops, decorators: [{
705
- type: i0.Inject,
706
- args: [DEFAULT_SHOP]
707
- }] }, { type: undefined, decorators: [{
708
- type: i0.Inject,
709
- args: ['OrderRepository']
710
- }] }, { type: undefined, decorators: [{
711
- type: i0.Inject,
712
- args: ['CategoryRepository']
713
- }] }];
401
+ var CouponService = /** @class */ (function () {
402
+ function CouponService(couponRepository, defaultShop, orderRepository, categoryRepository) {
403
+ this.couponRepository = couponRepository;
404
+ this.defaultShop = defaultShop;
405
+ this.orderRepository = orderRepository;
406
+ this.categoryRepository = categoryRepository;
407
+ this.emailIsFromCollaborator = function (userEmail) { return !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g)); };
408
+ }
409
+ CouponService.prototype.checkCoupon = function (nickname, checkoutType, checkout, plan) {
410
+ var _this = this;
411
+ return rxjs.from(this.couponRepository
412
+ .find({
413
+ filters: {
414
+ nickname: { operator: i3.Where.EQUALS, value: nickname },
415
+ active: { operator: i3.Where.EQUALS, value: true },
416
+ },
417
+ })
418
+ .then(function (result) { return result.data[0]; })).pipe(operators.concatMap(function (coupon) { return _this.couponValidation(coupon, checkoutType); }), operators.concatMap(function (couponValid) { return _this.couponRulesValidation(couponValid, checkoutType, checkout, plan); }), operators.map(function (couponValidated) { return couponValidated; }));
419
+ };
420
+ CouponService.prototype.couponValidation = function (coupon, checkoutType) {
421
+ return __awaiter(this, void 0, void 0, function () {
422
+ var isInShop, isCheckoutType;
423
+ return __generator(this, function (_c) {
424
+ if (!coupon)
425
+ throw 'Cupom inválido.';
426
+ if ((coupon === null || coupon === void 0 ? void 0 : coupon.beginAt) && (coupon === null || coupon === void 0 ? void 0 : coupon.beginAt) > new Date())
427
+ throw 'Cupom inválido.';
428
+ if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) && (coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) < new Date())
429
+ throw 'Cupom expirado.';
430
+ isInShop = coupon.shopAvailability === i3.Shops.ALL || coupon.shopAvailability === this.defaultShop;
431
+ if (!isInShop)
432
+ throw 'Cupom inválido para loja.';
433
+ isCheckoutType = coupon.checkoutType === i3.CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
434
+ if (!isCheckoutType)
435
+ throw 'Cupom inválido. Erro de checkout.';
436
+ return [2 /*return*/, coupon];
437
+ });
438
+ });
439
+ };
440
+ CouponService.prototype.couponRulesValidation = function (coupon, checkoutType, checkout, plan) {
441
+ return __awaiter(this, void 0, void 0, function () {
442
+ var orders, ordersWithUser, validUser, hasProductCategories, hasMinSubTotal;
443
+ return __generator(this, function (_c) {
444
+ switch (_c.label) {
445
+ case 0:
446
+ if (checkoutType == i3.CheckoutTypes.SUBSCRIPTION) {
447
+ if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
448
+ throw 'Cupom inválido para sua assinatura.';
449
+ return [2 /*return*/, coupon];
450
+ }
451
+ return [4 /*yield*/, this.getOrdersWithCoupon(coupon)];
452
+ case 1:
453
+ orders = _c.sent();
454
+ ordersWithUser = this.countOrdersWithUser(orders, checkout.user.email);
455
+ if (coupon.useLimitPerUser && ordersWithUser > 0)
456
+ throw 'Limite de uso por usuário atingido.';
457
+ if (!coupon.unlimited && coupon.useLimit && orders.length >= coupon.useLimit)
458
+ throw 'Limite de uso atingido.';
459
+ validUser = this.coupomUserValidation(coupon, checkout === null || checkout === void 0 ? void 0 : checkout.user);
460
+ if (!validUser)
461
+ throw 'Usuário não elegível.';
462
+ return [4 /*yield*/, this.hasProductCategories(coupon, checkout)];
463
+ case 2:
464
+ hasProductCategories = _c.sent();
465
+ if (!hasProductCategories)
466
+ throw 'Seu carrinho não possui produtos elegíveis para desconto.';
467
+ return [4 /*yield*/, this.hasMinSubTotal(coupon, checkout)];
468
+ case 3:
469
+ hasMinSubTotal = _c.sent();
470
+ if (!hasMinSubTotal)
471
+ throw "Valor m\u00EDnimo de " + Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue) + " n\u00E3o atingido";
472
+ return [2 /*return*/, coupon];
473
+ }
474
+ });
475
+ });
476
+ };
477
+ CouponService.prototype.calcDiscountSubscription = function (coupon, checkout) {
478
+ var discount = 0;
479
+ if (coupon.discount.subscription.type == i3.CouponTypes.ABSOLUTE)
480
+ discount = coupon.discount.subscription.value;
481
+ else
482
+ discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount.subscription.value / 100);
483
+ return rxjs.of(discount);
484
+ };
485
+ CouponService.prototype.calcDiscountShopping = function (coupon, checkout) {
486
+ return __awaiter(this, void 0, void 0, function () {
487
+ var discount;
488
+ return __generator(this, function (_c) {
489
+ switch (_c.label) {
490
+ case 0:
491
+ discount = 0;
492
+ if (!(checkout.user.isSubscriber && coupon.discount.subscriber.value)) return [3 /*break*/, 2];
493
+ return [4 /*yield*/, this.calcDiscountByType(coupon.discount.subscriber.type, coupon.discount.subscriber.value, coupon.productsCategories, checkout)];
494
+ case 1:
495
+ discount = _c.sent();
496
+ return [3 /*break*/, 4];
497
+ case 2: return [4 /*yield*/, this.calcDiscountByType(coupon.discount.non_subscriber.type, coupon.discount.non_subscriber.value, coupon.productsCategories, checkout)];
498
+ case 3:
499
+ discount = _c.sent();
500
+ _c.label = 4;
501
+ case 4: return [2 /*return*/, discount];
502
+ }
503
+ });
504
+ });
505
+ };
506
+ CouponService.prototype.calcDiscountByType = function (type, value, categories, checkout) {
507
+ return __awaiter(this, void 0, void 0, function () {
508
+ var discount, lineItensDiscount, subTotal;
509
+ return __generator(this, function (_c) {
510
+ switch (_c.label) {
511
+ case 0:
512
+ discount = 0;
513
+ return [4 /*yield*/, this.getLineItensEligebleForDiscount(categories, checkout)];
514
+ case 1:
515
+ lineItensDiscount = _c.sent();
516
+ subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
517
+ if (type == i3.CouponTypes.ABSOLUTE) {
518
+ discount = value > subTotal ? subTotal : value;
519
+ }
520
+ else {
521
+ discount = subTotal * (value / 100);
522
+ }
523
+ return [2 /*return*/, discount];
524
+ }
525
+ });
526
+ });
527
+ };
528
+ CouponService.prototype.hasMinSubTotal = function (coupon, checkout) {
529
+ return __awaiter(this, void 0, void 0, function () {
530
+ var lineItensDiscount, subTotal;
531
+ return __generator(this, function (_c) {
532
+ switch (_c.label) {
533
+ case 0:
534
+ if (!coupon.minSubTotalValue)
535
+ return [2 /*return*/, true];
536
+ return [4 /*yield*/, this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout)];
537
+ case 1:
538
+ lineItensDiscount = _c.sent();
539
+ subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
540
+ if (coupon.minSubTotalValue <= subTotal)
541
+ return [2 /*return*/, true];
542
+ return [2 /*return*/, false];
543
+ }
544
+ });
545
+ });
546
+ };
547
+ CouponService.prototype.hasProductCategories = function (coupon, checkout) {
548
+ var _a;
549
+ return __awaiter(this, void 0, void 0, function () {
550
+ var couponCategories, hasCategories;
551
+ return __generator(this, function (_c) {
552
+ switch (_c.label) {
553
+ case 0:
554
+ if (!coupon.productsCategories || !coupon.productsCategories.length) {
555
+ return [2 /*return*/, true];
556
+ }
557
+ return [4 /*yield*/, this.getCouponCategoriesId(coupon.productsCategories)];
558
+ case 1:
559
+ couponCategories = _c.sent();
560
+ hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter(function (i) {
561
+ var _a;
562
+ if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length))
563
+ return true;
564
+ return i.categories.some(function (c) { return couponCategories.some(function (cat) { return cat.id == c || cat.firestoreId == c; }); });
565
+ });
566
+ return [2 /*return*/, hasCategories.length ? true : false];
567
+ }
568
+ });
569
+ });
570
+ };
571
+ CouponService.prototype.coupomUserValidation = function (coupon, user) {
572
+ if (!user || coupon.exclusivityType.includes(i3.Exclusivities.ALL_USERS))
573
+ return true;
574
+ var userTypes = [];
575
+ if (coupon.exclusivityType.includes(i3.Exclusivities.COLLABORATORS) && this.emailIsFromCollaborator(user.email))
576
+ userTypes.push(i3.Exclusivities.COLLABORATORS);
577
+ if (coupon.exclusivityType.includes(i3.Exclusivities.SPECIFIC_USER) && coupon.userExclusiveEmail.includes(user.email))
578
+ userTypes.push(i3.Exclusivities.SPECIFIC_USER);
579
+ if (coupon.exclusivityType.includes(i3.Exclusivities.ACTIVE_SUBSCRIBER) && user.isSubscriber)
580
+ userTypes.push(i3.Exclusivities.ACTIVE_SUBSCRIBER);
581
+ if ((coupon.exclusivityType.includes(i3.Exclusivities.NON_SUBSCRIBER) ||
582
+ coupon.exclusivityType.includes(i3.Exclusivities.INACTIVE_SUBSCRIBER)) &&
583
+ !user.isSubscriber)
584
+ userTypes.push(i3.Exclusivities.ACTIVE_SUBSCRIBER);
585
+ return coupon.exclusivityType.some(function (r) { return userTypes.includes(r); });
586
+ };
587
+ CouponService.prototype.getCouponCategoriesId = function (productsCategories) {
588
+ return __awaiter(this, void 0, void 0, function () {
589
+ var couponCategories, index, c;
590
+ return __generator(this, function (_c) {
591
+ switch (_c.label) {
592
+ case 0:
593
+ couponCategories = [];
594
+ index = 0;
595
+ _c.label = 1;
596
+ case 1:
597
+ if (!(index < productsCategories.length)) return [3 /*break*/, 4];
598
+ return [4 /*yield*/, this.categoryRepository.get({
599
+ id: productsCategories[index],
600
+ })];
601
+ case 2:
602
+ c = _c.sent();
603
+ couponCategories.push({ id: c.id, firestoreId: c.firestoreId });
604
+ _c.label = 3;
605
+ case 3:
606
+ index++;
607
+ return [3 /*break*/, 1];
608
+ case 4: return [2 /*return*/, couponCategories];
609
+ }
610
+ });
611
+ });
612
+ };
613
+ CouponService.prototype.getLineItensEligebleForDiscount = function (productsCategories, checkout) {
614
+ var _a;
615
+ return __awaiter(this, void 0, void 0, function () {
616
+ var lineItensDiscount, couponCategories;
617
+ return __generator(this, function (_c) {
618
+ switch (_c.label) {
619
+ case 0:
620
+ lineItensDiscount = [];
621
+ return [4 /*yield*/, this.getCouponCategoriesId(productsCategories)];
622
+ case 1:
623
+ couponCategories = _c.sent();
624
+ if (productsCategories && productsCategories.length) {
625
+ lineItensDiscount = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter(function (i) {
626
+ var _a;
627
+ if ((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length) {
628
+ return i.categories.some(function (c) { return couponCategories.some(function (cat) { return cat.id == c || cat.firestoreId == c; }); });
629
+ }
630
+ return true;
631
+ });
632
+ }
633
+ else {
634
+ lineItensDiscount = checkout.lineItems;
635
+ }
636
+ return [2 /*return*/, lineItensDiscount];
637
+ }
638
+ });
639
+ });
640
+ };
641
+ CouponService.prototype.calcCheckoutSubtotal = function (lineItens, user, shop) {
642
+ return ((lineItens === null || lineItens === void 0 ? void 0 : lineItens.reduce(function (acc, curr) {
643
+ var _a, _b;
644
+ return (user === null || user === void 0 ? void 0 : user.isSubscriber) && ((_a = curr.price[shop]) === null || _a === void 0 ? void 0 : _a.subscriberPrice)
645
+ ? acc + ((_b = curr.price[shop]) === null || _b === void 0 ? void 0 : _b.subscriberPrice) * curr.quantity
646
+ : acc + curr.pricePaid * curr.quantity;
647
+ }, 0)) || 0);
648
+ };
649
+ CouponService.prototype.getOrdersWithCoupon = function (coupon) {
650
+ return __awaiter(this, void 0, void 0, function () {
651
+ return __generator(this, function (_c) {
652
+ switch (_c.label) {
653
+ case 0: return [4 /*yield*/, this.orderRepository
654
+ .find({
655
+ filters: {
656
+ coupon: { id: coupon.id },
657
+ payment: { status: 'paid' },
658
+ },
659
+ })
660
+ .then(function (result) { return result.data; })];
661
+ case 1: return [2 /*return*/, _c.sent()];
662
+ }
663
+ });
664
+ });
665
+ };
666
+ CouponService.prototype.countOrdersWithUser = function (orders, email) {
667
+ return orders.filter(function (o) { return o.user.email == email; }).length;
668
+ };
669
+ return CouponService;
670
+ }());
671
+ CouponService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
672
+ CouponService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CouponService, providedIn: 'root' });
673
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CouponService, decorators: [{
674
+ type: i0.Injectable,
675
+ args: [{
676
+ providedIn: 'root',
677
+ }]
678
+ }], ctorParameters: function () {
679
+ return [{ type: undefined, decorators: [{
680
+ type: i0.Inject,
681
+ args: ['CouponRepository']
682
+ }] }, { type: i3__namespace.Shops, decorators: [{
683
+ type: i0.Inject,
684
+ args: [DEFAULT_SHOP]
685
+ }] }, { type: undefined, decorators: [{
686
+ type: i0.Inject,
687
+ args: ['OrderRepository']
688
+ }] }, { type: undefined, decorators: [{
689
+ type: i0.Inject,
690
+ args: ['CategoryRepository']
691
+ }] }];
714
692
  } });
715
693
 
716
- var CheckoutService = /** @class */ (function () {
717
- function CheckoutService(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
718
- this.couponService = couponService;
719
- this.checkoutRepository = checkoutRepository;
720
- this.orderRepository = orderRepository;
721
- this.userRepository = userRepository;
722
- this.defaultShop = defaultShop;
723
- }
724
- CheckoutService.prototype.getCheckout = function (checkoutData) {
725
- var checkoutId = cookie__default["default"].get('checkoutId');
726
- if (!i3.isNil(checkoutId))
727
- return rxjs.from(this.checkoutRepository.get({ id: checkoutId }));
728
- return rxjs.from(this.createCheckout(checkoutData));
729
- };
730
- CheckoutService.prototype.getUserByCheckout = function (checkoutId) {
731
- var _this = this;
732
- return rxjs.from(this.checkoutRepository.get({ id: checkoutId })).pipe(operators.concatMap(function (checkout) { var _a; return ((_a = checkout === null || checkout === void 0 ? void 0 : checkout.user) === null || _a === void 0 ? void 0 : _a.id) ? rxjs.of(checkout.user) : rxjs.from(_this.userRepository.get({ id: checkout.user.id })); }), operators.concatMap(function (user) { return rxjs.of(user) || rxjs.throwError(function () { return new i3.NotFoundError('User is not found'); }); }));
733
- };
734
- CheckoutService.prototype.updateCheckoutLineItems = function (checkout) {
735
- return rxjs.from(this.checkoutRepository.update(i3.Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
736
- };
737
- CheckoutService.prototype.updateCheckoutUser = function (checkout) {
738
- return rxjs.from(this.checkoutRepository.update(i3.Checkout.toInstance({ id: checkout.id, user: checkout.user })));
739
- };
740
- CheckoutService.prototype.clearCheckoutFromSession = function () {
741
- cookie__default["default"].remove('checkoutId');
742
- return rxjs.of();
743
- };
744
- CheckoutService.prototype.calcDiscount = function (coupon) {
745
- var _this = this;
746
- return this.getCheckout().pipe(operators.concatMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_b) {
747
- switch (_b.label) {
748
- case 0: return [4 /*yield*/, this.couponService.calcDiscountShopping(coupon, checkout)];
749
- case 1: return [2 /*return*/, _b.sent()];
750
- }
751
- }); }); }));
752
- };
753
- CheckoutService.prototype.checkCoupon = function (nickname, checkoutType) {
754
- var _this = this;
755
- return this.getCheckout().pipe(operators.concatMap(function (checkout) {
756
- var _a;
757
- return _this.couponService
758
- .checkCoupon(nickname, (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email, i3.CheckoutTypes.ECOMMERCE, checkout.user.subscriptionPlan, checkout, false)
759
- .pipe();
760
- }));
761
- };
762
- CheckoutService.prototype.createCheckout = function (checkoutData) {
763
- return __awaiter(this, void 0, void 0, function () {
764
- var checkout;
765
- return __generator(this, function (_b) {
766
- switch (_b.label) {
767
- case 0: return [4 /*yield*/, this.checkoutRepository.create(Object.assign(Object.assign({ createdAt: new Date() }, i3.Checkout.toInstance(i3.pick(checkoutData, ['user', 'shop'])).toPlain()), { shop: (checkoutData === null || checkoutData === void 0 ? void 0 : checkoutData.shop) || this.defaultShop }))];
768
- case 1:
769
- checkout = _b.sent();
770
- cookie__default["default"].set('checkoutId', checkout.id);
771
- return [2 /*return*/, checkout];
772
- }
773
- });
774
- });
775
- };
776
- return CheckoutService;
777
- }());
778
- CheckoutService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'OrderRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
779
- CheckoutService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService });
780
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService, decorators: [{
781
- type: i0.Injectable
782
- }], ctorParameters: function () {
783
- return [{ type: CouponService }, { type: undefined, decorators: [{
784
- type: i0.Inject,
785
- args: ['CheckoutRepository']
786
- }] }, { type: undefined, decorators: [{
787
- type: i0.Inject,
788
- args: ['OrderRepository']
789
- }] }, { type: undefined, decorators: [{
790
- type: i0.Inject,
791
- args: ['UserRepository']
792
- }] }, { type: i3__namespace.Shops, decorators: [{
793
- type: i0.Inject,
794
- args: [DEFAULT_SHOP]
795
- }] }];
694
+ var CheckoutService = /** @class */ (function () {
695
+ function CheckoutService(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
696
+ this.couponService = couponService;
697
+ this.checkoutRepository = checkoutRepository;
698
+ this.orderRepository = orderRepository;
699
+ this.userRepository = userRepository;
700
+ this.defaultShop = defaultShop;
701
+ }
702
+ CheckoutService.prototype.getCheckout = function (checkoutData) {
703
+ var checkoutId = cookie__default["default"].get('checkoutId');
704
+ if (!i3.isNil(checkoutId))
705
+ return rxjs.from(this.checkoutRepository.get({ id: checkoutId }));
706
+ return rxjs.from(this.createCheckout(checkoutData));
707
+ };
708
+ CheckoutService.prototype.getUserByCheckout = function (checkoutId) {
709
+ var _this = this;
710
+ return rxjs.from(this.checkoutRepository.get({ id: checkoutId })).pipe(operators.concatMap(function (checkout) { var _a; return ((_a = checkout === null || checkout === void 0 ? void 0 : checkout.user) === null || _a === void 0 ? void 0 : _a.id) ? rxjs.of(checkout.user) : rxjs.from(_this.userRepository.get({ id: checkout.user.id })); }), operators.concatMap(function (user) { return rxjs.of(user) || rxjs.throwError(function () { return new i3.NotFoundError('User is not found'); }); }));
711
+ };
712
+ CheckoutService.prototype.updateCheckoutLineItems = function (checkout) {
713
+ return rxjs.from(this.checkoutRepository.update(i3.Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
714
+ };
715
+ CheckoutService.prototype.updateCheckoutUser = function (checkout) {
716
+ return rxjs.from(this.checkoutRepository.update(i3.Checkout.toInstance({ id: checkout.id, user: checkout.user })));
717
+ };
718
+ CheckoutService.prototype.clearCheckoutFromSession = function () {
719
+ cookie__default["default"].remove('checkoutId');
720
+ return rxjs.of();
721
+ };
722
+ CheckoutService.prototype.calcDiscount = function (coupon) {
723
+ var _this = this;
724
+ return this.getCheckout().pipe(operators.concatMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_b) {
725
+ switch (_b.label) {
726
+ case 0: return [4 /*yield*/, this.couponService.calcDiscountShopping(coupon, checkout)];
727
+ case 1: return [2 /*return*/, _b.sent()];
728
+ }
729
+ }); }); }));
730
+ };
731
+ CheckoutService.prototype.checkCoupon = function (nickname, checkoutType) {
732
+ var _this = this;
733
+ return this.getCheckout().pipe(operators.concatMap(function (checkout) { return _this.couponService.checkCoupon(nickname, i3.CheckoutTypes.ECOMMERCE, checkout, null).pipe(); }));
734
+ };
735
+ CheckoutService.prototype.createCheckout = function (checkoutData) {
736
+ return __awaiter(this, void 0, void 0, function () {
737
+ var checkout;
738
+ return __generator(this, function (_b) {
739
+ switch (_b.label) {
740
+ case 0: return [4 /*yield*/, this.checkoutRepository.create(Object.assign(Object.assign({ createdAt: new Date() }, i3.Checkout.toInstance(i3.pick(checkoutData, ['user', 'shop'])).toPlain()), { shop: (checkoutData === null || checkoutData === void 0 ? void 0 : checkoutData.shop) || this.defaultShop }))];
741
+ case 1:
742
+ checkout = _b.sent();
743
+ cookie__default["default"].set('checkoutId', checkout.id);
744
+ return [2 /*return*/, checkout];
745
+ }
746
+ });
747
+ });
748
+ };
749
+ return CheckoutService;
750
+ }());
751
+ CheckoutService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'OrderRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
752
+ CheckoutService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService });
753
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService, decorators: [{
754
+ type: i0.Injectable
755
+ }], ctorParameters: function () {
756
+ return [{ type: CouponService }, { type: undefined, decorators: [{
757
+ type: i0.Inject,
758
+ args: ['CheckoutRepository']
759
+ }] }, { type: undefined, decorators: [{
760
+ type: i0.Inject,
761
+ args: ['OrderRepository']
762
+ }] }, { type: undefined, decorators: [{
763
+ type: i0.Inject,
764
+ args: ['UserRepository']
765
+ }] }, { type: i3__namespace.Shops, decorators: [{
766
+ type: i0.Inject,
767
+ args: [DEFAULT_SHOP]
768
+ }] }];
796
769
  } });
797
770
 
798
- var CartService = /** @class */ (function () {
799
- function CartService(authService, checkoutService, defaultShop, productRepository, variantRepository, buy2WinRepository) {
800
- var _this = this;
801
- this.authService = authService;
802
- this.checkoutService = checkoutService;
803
- this.defaultShop = defaultShop;
804
- this.productRepository = productRepository;
805
- this.variantRepository = variantRepository;
806
- this.buy2WinRepository = buy2WinRepository;
807
- this.cartSubject = new rxjs.Subject();
808
- this.updateLineItemInCart = function (lineItem, quantity, checkout) { return (i3.isNil(checkout) ? _this.checkoutService.getCheckout() : rxjs.of(checkout)).pipe(operators.concatMap(function (checkoutLoaded) {
809
- var _a;
810
- var items = [];
811
- var index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map(function (checkoutItem) { return checkoutItem.id; }).indexOf(lineItem.id);
812
- if (index > -1) {
813
- checkoutLoaded.lineItems[index].quantity += quantity;
814
- checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
815
- }
816
- else
817
- checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
818
- return _this.checkoutService
819
- .updateCheckoutLineItems(checkoutLoaded)
820
- .pipe(operators.map(function (updatedCheckout) { return _this.generateCartObject(updatedCheckout.lineItems); }));
821
- })); };
822
- this.generateCartObject = function (items) { return items
823
- ? items.reduce(function (cart, item) {
824
- var _h;
825
- var _a;
826
- return (Object.assign(Object.assign({}, cart), (_h = {}, _h[item.id] = i3.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) })), _h)));
827
- }, {})
828
- : []; };
829
- this.buildLineItem = function (_h) {
830
- var checkout = _h.checkout, item = _h.item, quantity = _h.quantity;
831
- return __awaiter(_this, void 0, void 0, function () {
832
- var _a, _b, _c, _d, _e, _f, _g, product, image, id, name, EAN, slug, stock, price, weight, sku, type, isGift, pricePaid;
833
- return __generator(this, function (_h) {
834
- switch (_h.label) {
835
- case 0: return [4 /*yield*/, this.getProductData(item.id)];
836
- case 1:
837
- product = _h.sent();
838
- item.quantity = (item === null || item === void 0 ? void 0 : item.quantity) || ((_b = (_a = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find(function (lineItem) { return lineItem.id === item.id; })) === null || _b === void 0 ? void 0 : _b.quantity) || 0;
839
- if (this.checkMaxStock(item, quantity || 0))
840
- throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
841
- image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
842
- id = item.id, name = item.name, EAN = item.EAN, slug = item.slug, stock = item.stock, price = item.price, weight = item.weight, sku = item.sku, type = item.type;
843
- isGift = item.isGift || null;
844
- pricePaid = this.getProductPrice({
845
- product: item,
846
- shop: checkout.shop || this.defaultShop,
847
- isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
848
- });
849
- i3.RoundProductPricesHelper.roundProductPrices(item);
850
- return [2 /*return*/, {
851
- checkout: checkout,
852
- lineItem: i3.LineItem.toInstance({
853
- id: id,
854
- name: name !== null && name !== void 0 ? name : product.name,
855
- EAN: EAN !== null && EAN !== void 0 ? EAN : product.EAN,
856
- brand: product.brand,
857
- slug: slug !== null && slug !== void 0 ? slug : product.slug,
858
- sku: sku !== null && sku !== void 0 ? sku : product.sku,
859
- stock: stock,
860
- price: this.roundPrice(price),
861
- image: image,
862
- weight: weight !== null && weight !== void 0 ? weight : product.weight,
863
- quantity: (item.quantity || 0) + (quantity || 0),
864
- pricePaid: pricePaid,
865
- categories: (_f = product.categories) !== null && _f !== void 0 ? _f : [],
866
- isGift: isGift !== null && isGift !== void 0 ? isGift : null,
867
- costPrice: (_g = product.costPrice) !== null && _g !== void 0 ? _g : 0,
868
- type: type,
869
- }),
870
- }];
871
- }
872
- });
873
- });
874
- };
875
- this.getProductPrice = function (_h) {
876
- var product = _h.product, isSubscriber = _h.isSubscriber;
877
- var info = product.price;
878
- if (product.isGift)
879
- return 0;
880
- return isSubscriber && info.subscriberPrice > 0
881
- ? Number(info.subscriberPrice.toFixed(2))
882
- : Number(info.price.toFixed(2));
883
- };
884
- this.checkMaxStock = function (item, quantity) {
885
- var _a;
886
- var maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
887
- var currentItemAmount = item.quantity || 0;
888
- return currentItemAmount + quantity > maxStock;
889
- };
890
- }
891
- CartService.prototype.addItem = function (item, quantity) {
892
- var _this = this;
893
- if (quantity === void 0) { quantity = 1; }
894
- return rxjs.from(this.checkoutService.getCheckout()).pipe(operators.concatMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_h) {
895
- switch (_h.label) {
896
- case 0: return [4 /*yield*/, this.buildLineItem({ checkout: checkout, item: item, quantity: quantity || 1 })];
897
- case 1: return [2 /*return*/, _h.sent()];
898
- }
899
- }); }); }), operators.mergeMap(function (_h) {
900
- var checkout = _h.checkout, lineItem = _h.lineItem;
901
- return _this.updateLineItemInCart(lineItem, quantity || 1, checkout);
902
- }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
903
- };
904
- CartService.prototype.decreaseItem = function (item) {
905
- var _this = this;
906
- return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
907
- var _a;
908
- var checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find(function (lineItem) { return lineItem.id === item.id; });
909
- if (!i3.isNil(checkoutItem))
910
- checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
911
- return checkout;
912
- }), operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutLineItems(checkout); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
913
- };
914
- CartService.prototype.getCart = function (checkout) {
915
- var _this = this;
916
- this.buildCartFromCheckout(checkout).subscribe(function (cart) { return _this.cartSubject.next(cart); });
917
- return this.cartSubject;
918
- };
919
- /**
920
- * @deprecated The method should not be used
921
- */
922
- CartService.prototype.getVariantPriceDiscount = function (item) {
923
- return this.authService.getUser().pipe(operators.concatMap(function (user) { return rxjs.iif(function () { return user.isSubscriber && !!item.price.subscriberPrice; }, rxjs.of(item.price.subscriberPrice), rxjs.of(item.price.price)); }), operators.catchError(function () { return rxjs.of(item.price.price); }));
924
- };
925
- CartService.prototype.removeItem = function (item) {
926
- var _this = this;
927
- return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
928
- var index = checkout.lineItems.findIndex(function (lineItem) { return lineItem.id === item.id; });
929
- if (index >= 0)
930
- checkout.lineItems.splice(index, 1);
931
- return checkout;
932
- }), operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutLineItems(checkout); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
933
- };
934
- CartService.prototype.updateUserCart = function (user) {
935
- var _this = this;
936
- return this.checkoutService.getCheckout().pipe(operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutUser(i3.Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user: user }))); }), operators.concatMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () {
937
- var _a, _b, _h, _j, _k, _l, _m, _o, _p, _q, _r;
938
- var _this = this;
939
- return __generator(this, function (_s) {
940
- switch (_s.label) {
941
- case 0:
942
- _j = (_h = this.checkoutService)
943
- .updateCheckoutLineItems;
944
- _l = (_k = i3.Checkout).toInstance;
945
- _o = (_m = Object).assign;
946
- _p = [Object.assign({}, checkout.toPlain())];
947
- _q = {};
948
- if (!((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.length)) return [3 /*break*/, 2];
949
- return [4 /*yield*/, Promise.all((_b = checkout.lineItems) === null || _b === void 0 ? void 0 : _b.map(function (item) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_h) {
950
- switch (_h.label) {
951
- case 0: return [4 /*yield*/, this.buildLineItem({ checkout: checkout, item: item })];
952
- case 1: return [2 /*return*/, (_h.sent()).lineItem];
953
- }
954
- }); }); }))];
955
- case 1:
956
- _r = _s.sent();
957
- return [3 /*break*/, 3];
958
- case 2:
959
- _r = [];
960
- _s.label = 3;
961
- case 3: return [2 /*return*/, _j.apply(_h, [_l.apply(_k, [_o.apply(_m, _p.concat([(_q.lineItems = _r, _q)]))])])
962
- .toPromise()];
963
- }
964
- });
965
- }); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
966
- };
967
- CartService.prototype.clearCart = function () {
968
- var _this = this;
969
- return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
970
- _this.checkoutService.clearCheckoutFromSession();
971
- return checkout;
972
- }), operators.concatMap(function (oldCheckout) { return _this.buildCartFromCheckout(oldCheckout); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
973
- };
974
- CartService.prototype.buildCartFromCheckout = function (checkoutData) {
975
- var _this = this;
976
- return this.checkoutService.getCheckout(checkoutData).pipe(operators.map(function (checkout) { return checkout.lineItems; }), operators.concatMap(function (lineItems) { return rxjs.of(_this.generateCartObject(lineItems)); }));
977
- };
978
- CartService.prototype.roundPrice = function (productPrice) {
979
- var price = productPrice.price, fullPrice = productPrice.fullPrice, subscriberPrice = productPrice.subscriberPrice;
980
- return Object.assign(Object.assign(Object.assign({}, productPrice), { price: Number(price.toFixed(2)), fullPrice: Number(fullPrice.toFixed(2)) }), (subscriberPrice && { subscriberPrice: Number(subscriberPrice.toFixed(2)) }));
981
- };
982
- CartService.prototype.getProductData = function (productId) {
983
- return __awaiter(this, void 0, void 0, function () {
984
- var product, variant, error_1, variants;
985
- return __generator(this, function (_h) {
986
- switch (_h.label) {
987
- case 0:
988
- _h.trys.push([0, 2, , 5]);
989
- return [4 /*yield*/, this.productRepository.get({ id: productId })];
990
- case 1:
991
- product = _h.sent();
992
- return [3 /*break*/, 5];
993
- case 2:
994
- error_1 = _h.sent();
995
- if (!(error_1 instanceof i3.NotFoundError))
996
- throw error_1;
997
- return [4 /*yield*/, this.variantRepository.find({ filters: { id: productId } })];
998
- case 3:
999
- variants = (_h.sent()).data;
1000
- variant = variants.shift();
1001
- if (!variant)
1002
- throw error_1;
1003
- return [4 /*yield*/, this.productRepository.get({ id: variant.productId })];
1004
- case 4:
1005
- product = _h.sent();
1006
- return [3 /*break*/, 5];
1007
- case 5: return [2 /*return*/, Object.assign(Object.assign({}, product.toPlain()), (variant && Object.assign({}, variant.toPlain())))];
1008
- }
1009
- });
1010
- });
1011
- };
1012
- CartService.prototype.getGifts = function () {
1013
- var _this = this;
1014
- return this.checkoutService.getCheckout().pipe(operators.mergeMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () {
1015
- var notGiftItems, cartTotal, campaigns, elegibleCampaigns, _loop_1, campaigns_1, campaigns_1_1, campaign, campaingnProducts, elegibleCampaigns_1, elegibleCampaigns_1_1, campaign, elegibleProducts, _h, _j, product, productData, gift, e_1_1, e_2_1, gifts;
1016
- var e_3, _k, e_2, _l, e_1, _m;
1017
- return __generator(this, function (_o) {
1018
- switch (_o.label) {
1019
- case 0:
1020
- notGiftItems = checkout.lineItems ? checkout.lineItems.filter(function (item) { return !item.isGift; }) : [];
1021
- if (!notGiftItems.length)
1022
- return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: [] })];
1023
- cartTotal = notGiftItems.reduce(function (a, b) { return a + b.pricePaid * b.quantity; }, 0);
1024
- return [4 /*yield*/, this.buy2WinRepository
1025
- .find({
1026
- filters: {
1027
- active: { operator: i3.Where.EQUALS, value: true },
1028
- shop: { operator: i3.Where.EQUALS, value: this.defaultShop },
1029
- },
1030
- })
1031
- .then(function (data) { return data.data; })];
1032
- case 1:
1033
- campaigns = _o.sent();
1034
- if (!campaigns.length)
1035
- return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems })];
1036
- elegibleCampaigns = [];
1037
- _loop_1 = function (campaign) {
1038
- var today = new Date();
1039
- if (!(campaign.startDate <= today) && !(campaign.endDate >= today))
1040
- return "continue";
1041
- if (campaign.activeCategory) {
1042
- var categoriesCampaing_1 = campaign.categories.map(function (c) { return c.id; });
1043
- var filterProductsCategories = checkout.lineItems.filter(function (l) {
1044
- var _a;
1045
- if (!l.categories || !((_a = l.categories) === null || _a === void 0 ? void 0 : _a.length))
1046
- return true;
1047
- return l.categories.some(function (c) { return categoriesCampaing_1.some(function (cat) { return cat == c; }); });
1048
- });
1049
- if (filterProductsCategories.length) {
1050
- var cartTotalCategories = filterProductsCategories.reduce(function (a, b) { return a + b.pricePaid * b.quantity; }, 0);
1051
- if (cartTotalCategories >= campaign.cartValueMin)
1052
- elegibleCampaigns.push(campaign);
1053
- }
1054
- }
1055
- else {
1056
- if (campaign.cartValue && campaign.cartValue > 0) {
1057
- if (campaign.cartValue <= cartTotal)
1058
- elegibleCampaigns.push(campaign);
1059
- }
1060
- }
1061
- };
1062
- try {
1063
- for (campaigns_1 = __values(campaigns), campaigns_1_1 = campaigns_1.next(); !campaigns_1_1.done; campaigns_1_1 = campaigns_1.next()) {
1064
- campaign = campaigns_1_1.value;
1065
- _loop_1(campaign);
1066
- }
1067
- }
1068
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1069
- finally {
1070
- try {
1071
- if (campaigns_1_1 && !campaigns_1_1.done && (_k = campaigns_1.return)) _k.call(campaigns_1);
1072
- }
1073
- finally { if (e_3) throw e_3.error; }
1074
- }
1075
- if (!elegibleCampaigns.length)
1076
- return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems })];
1077
- campaingnProducts = [];
1078
- _o.label = 2;
1079
- case 2:
1080
- _o.trys.push([2, 14, 15, 16]);
1081
- elegibleCampaigns_1 = __values(elegibleCampaigns), elegibleCampaigns_1_1 = elegibleCampaigns_1.next();
1082
- _o.label = 3;
1083
- case 3:
1084
- if (!!elegibleCampaigns_1_1.done) return [3 /*break*/, 13];
1085
- campaign = elegibleCampaigns_1_1.value;
1086
- elegibleProducts = [];
1087
- _o.label = 4;
1088
- case 4:
1089
- _o.trys.push([4, 9, 10, 11]);
1090
- _h = (e_1 = void 0, __values(campaign.products)), _j = _h.next();
1091
- _o.label = 5;
1092
- case 5:
1093
- if (!!_j.done) return [3 /*break*/, 8];
1094
- product = _j.value;
1095
- return [4 /*yield*/, this.productRepository.find({ filters: { sku: product } })];
1096
- case 6:
1097
- productData = (_o.sent()).data;
1098
- if (!productData.length)
1099
- return [3 /*break*/, 7];
1100
- gift = productData.shift();
1101
- if (gift.stock.quantity < 1)
1102
- return [3 /*break*/, 7];
1103
- elegibleProducts.push(gift);
1104
- _o.label = 7;
1105
- case 7:
1106
- _j = _h.next();
1107
- return [3 /*break*/, 5];
1108
- case 8: return [3 /*break*/, 11];
1109
- case 9:
1110
- e_1_1 = _o.sent();
1111
- e_1 = { error: e_1_1 };
1112
- return [3 /*break*/, 11];
1113
- case 10:
1114
- try {
1115
- if (_j && !_j.done && (_m = _h.return)) _m.call(_h);
1116
- }
1117
- finally { if (e_1) throw e_1.error; }
1118
- return [7 /*endfinally*/];
1119
- case 11:
1120
- campaingnProducts.push(elegibleProducts);
1121
- _o.label = 12;
1122
- case 12:
1123
- elegibleCampaigns_1_1 = elegibleCampaigns_1.next();
1124
- return [3 /*break*/, 3];
1125
- case 13: return [3 /*break*/, 16];
1126
- case 14:
1127
- e_2_1 = _o.sent();
1128
- e_2 = { error: e_2_1 };
1129
- return [3 /*break*/, 16];
1130
- case 15:
1131
- try {
1132
- if (elegibleCampaigns_1_1 && !elegibleCampaigns_1_1.done && (_l = elegibleCampaigns_1.return)) _l.call(elegibleCampaigns_1);
1133
- }
1134
- finally { if (e_2) throw e_2.error; }
1135
- return [7 /*endfinally*/];
1136
- case 16:
1137
- if (!campaingnProducts.length)
1138
- return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems })];
1139
- gifts = this.giftToLineItems([].concat.apply([], __spreadArray([], __read(campaingnProducts))));
1140
- return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems.concat(gifts) })];
1141
- }
1142
- });
1143
- }); }), operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutLineItems(checkout); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
1144
- };
1145
- CartService.prototype.giftToLineItems = function (items) {
1146
- return items.map(function (item) {
1147
- var _a;
1148
- var brand = item.brand, categories = item.categories, id = item.id, name = item.name, price = item.price, sku = item.sku, slug = item.slug, stock = item.stock, weight = item.weight, EAN = item.EAN;
1149
- var image = ((_a = item === null || item === void 0 ? void 0 : item.miniatures) === null || _a === void 0 ? void 0 : _a.length) ? item.miniatures[0] : item.images[0];
1150
- return i3.LineItem.toInstance({
1151
- brand: brand,
1152
- categories: categories,
1153
- id: id.toString(),
1154
- name: name,
1155
- price: price,
1156
- sku: sku,
1157
- slug: slug,
1158
- stock: stock,
1159
- weight: weight,
1160
- EAN: EAN,
1161
- image: image,
1162
- pricePaid: 0,
1163
- quantity: 1,
1164
- isGift: true,
1165
- });
1166
- });
1167
- };
1168
- return CartService;
1169
- }());
1170
- CartService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'VariantRepository' }, { token: 'Buy2WinRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1171
- CartService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService });
1172
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService, decorators: [{
1173
- type: i0.Injectable
1174
- }], ctorParameters: function () {
1175
- return [{ type: AuthService }, { type: CheckoutService }, { type: i3__namespace.Shops, decorators: [{
1176
- type: i0.Inject,
1177
- args: [DEFAULT_SHOP]
1178
- }] }, { type: undefined, decorators: [{
1179
- type: i0.Inject,
1180
- args: ['ProductRepository']
1181
- }] }, { type: undefined, decorators: [{
1182
- type: i0.Inject,
1183
- args: ['VariantRepository']
1184
- }] }, { type: i3__namespace.Buy2WinFirestoreRepository, decorators: [{
1185
- type: i0.Inject,
1186
- args: ['Buy2WinRepository']
1187
- }] }];
771
+ var CartService = /** @class */ (function () {
772
+ function CartService(authService, checkoutService, defaultShop, productRepository, variantRepository, buy2WinRepository) {
773
+ var _this = this;
774
+ this.authService = authService;
775
+ this.checkoutService = checkoutService;
776
+ this.defaultShop = defaultShop;
777
+ this.productRepository = productRepository;
778
+ this.variantRepository = variantRepository;
779
+ this.buy2WinRepository = buy2WinRepository;
780
+ this.cartSubject = new rxjs.Subject();
781
+ this.updateLineItemInCart = function (lineItem, quantity, checkout) { return (i3.isNil(checkout) ? _this.checkoutService.getCheckout() : rxjs.of(checkout)).pipe(operators.concatMap(function (checkoutLoaded) {
782
+ var _a;
783
+ var items = [];
784
+ var index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map(function (checkoutItem) { return checkoutItem.id; }).indexOf(lineItem.id);
785
+ if (index > -1) {
786
+ checkoutLoaded.lineItems[index].quantity += quantity;
787
+ checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
788
+ }
789
+ else
790
+ checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
791
+ return _this.checkoutService
792
+ .updateCheckoutLineItems(checkoutLoaded)
793
+ .pipe(operators.map(function (updatedCheckout) { return _this.generateCartObject(updatedCheckout.lineItems); }));
794
+ })); };
795
+ this.generateCartObject = function (items) { return items
796
+ ? items.reduce(function (cart, item) {
797
+ var _h;
798
+ var _a;
799
+ return (Object.assign(Object.assign({}, cart), (_h = {}, _h[item.id] = i3.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) })), _h)));
800
+ }, {})
801
+ : []; };
802
+ this.buildLineItem = function (_h) {
803
+ var checkout = _h.checkout, item = _h.item, quantity = _h.quantity;
804
+ return __awaiter(_this, void 0, void 0, function () {
805
+ var _a, _b, _c, _d, _e, _f, _g, product, image, id, name, EAN, slug, stock, price, weight, sku, type, isGift, pricePaid;
806
+ return __generator(this, function (_h) {
807
+ switch (_h.label) {
808
+ case 0: return [4 /*yield*/, this.getProductData(item.id)];
809
+ case 1:
810
+ product = _h.sent();
811
+ item.quantity = (item === null || item === void 0 ? void 0 : item.quantity) || ((_b = (_a = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find(function (lineItem) { return lineItem.id === item.id; })) === null || _b === void 0 ? void 0 : _b.quantity) || 0;
812
+ if (this.checkMaxStock(item, quantity || 0))
813
+ throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
814
+ image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
815
+ id = item.id, name = item.name, EAN = item.EAN, slug = item.slug, stock = item.stock, price = item.price, weight = item.weight, sku = item.sku, type = item.type;
816
+ isGift = item.isGift || null;
817
+ pricePaid = this.getProductPrice({
818
+ product: item,
819
+ shop: checkout.shop || this.defaultShop,
820
+ isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
821
+ });
822
+ return [2 /*return*/, {
823
+ checkout: checkout,
824
+ lineItem: i3.LineItem.toInstance({
825
+ id: id,
826
+ name: name !== null && name !== void 0 ? name : product.name,
827
+ EAN: EAN !== null && EAN !== void 0 ? EAN : product.EAN,
828
+ brand: product.brand,
829
+ slug: slug !== null && slug !== void 0 ? slug : product.slug,
830
+ sku: sku !== null && sku !== void 0 ? sku : product.sku,
831
+ stock: stock,
832
+ price: price,
833
+ image: image,
834
+ weight: weight !== null && weight !== void 0 ? weight : product.weight,
835
+ quantity: (item.quantity || 0) + (quantity || 0),
836
+ pricePaid: pricePaid,
837
+ categories: (_f = product.categories) !== null && _f !== void 0 ? _f : [],
838
+ isGift: isGift !== null && isGift !== void 0 ? isGift : null,
839
+ costPrice: (_g = product.costPrice) !== null && _g !== void 0 ? _g : 0,
840
+ type: type,
841
+ }),
842
+ }];
843
+ }
844
+ });
845
+ });
846
+ };
847
+ this.getProductPrice = function (_h) {
848
+ var product = _h.product, isSubscriber = _h.isSubscriber;
849
+ var info = product.price;
850
+ if (product.isGift)
851
+ return 0;
852
+ return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
853
+ };
854
+ this.checkMaxStock = function (item, quantity) {
855
+ var _a;
856
+ var maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
857
+ var currentItemAmount = item.quantity || 0;
858
+ return currentItemAmount + quantity > maxStock;
859
+ };
860
+ }
861
+ CartService.prototype.addItem = function (item, quantity) {
862
+ var _this = this;
863
+ if (quantity === void 0) { quantity = 1; }
864
+ return rxjs.from(this.checkoutService.getCheckout()).pipe(operators.concatMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_h) {
865
+ switch (_h.label) {
866
+ case 0: return [4 /*yield*/, this.buildLineItem({ checkout: checkout, item: item, quantity: quantity || 1 })];
867
+ case 1: return [2 /*return*/, _h.sent()];
868
+ }
869
+ }); }); }), operators.mergeMap(function (_h) {
870
+ var checkout = _h.checkout, lineItem = _h.lineItem;
871
+ return _this.updateLineItemInCart(lineItem, quantity || 1, checkout);
872
+ }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
873
+ };
874
+ CartService.prototype.decreaseItem = function (item) {
875
+ var _this = this;
876
+ return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
877
+ var _a;
878
+ var checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find(function (lineItem) { return lineItem.id === item.id; });
879
+ if (!i3.isNil(checkoutItem))
880
+ checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
881
+ return checkout;
882
+ }), operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutLineItems(checkout); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
883
+ };
884
+ CartService.prototype.getCart = function (checkout) {
885
+ var _this = this;
886
+ this.buildCartFromCheckout(checkout).subscribe(function (cart) { return _this.cartSubject.next(cart); });
887
+ return this.cartSubject;
888
+ };
889
+ /**
890
+ * @deprecated The method should not be used
891
+ */
892
+ CartService.prototype.getVariantPriceDiscount = function (item) {
893
+ return this.authService.getUser().pipe(operators.concatMap(function (user) { return rxjs.iif(function () { return user.isSubscriber && !!item.price.subscriberPrice; }, rxjs.of(item.price.subscriberPrice), rxjs.of(item.price.price)); }), operators.catchError(function () { return rxjs.of(item.price.price); }));
894
+ };
895
+ CartService.prototype.removeItem = function (item) {
896
+ var _this = this;
897
+ return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
898
+ var index = checkout.lineItems.findIndex(function (lineItem) { return lineItem.id === item.id; });
899
+ if (index >= 0)
900
+ checkout.lineItems.splice(index, 1);
901
+ return checkout;
902
+ }), operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutLineItems(checkout); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
903
+ };
904
+ CartService.prototype.updateUserCart = function (user) {
905
+ var _this = this;
906
+ return this.checkoutService.getCheckout().pipe(operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutUser(i3.Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user: user }))); }), operators.concatMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () {
907
+ var _a, _b, _h, _j, _k, _l, _m, _o, _p, _q, _r;
908
+ var _this = this;
909
+ return __generator(this, function (_s) {
910
+ switch (_s.label) {
911
+ case 0:
912
+ _j = (_h = this.checkoutService)
913
+ .updateCheckoutLineItems;
914
+ _l = (_k = i3.Checkout).toInstance;
915
+ _o = (_m = Object).assign;
916
+ _p = [Object.assign({}, checkout.toPlain())];
917
+ _q = {};
918
+ if (!((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.length)) return [3 /*break*/, 2];
919
+ return [4 /*yield*/, Promise.all((_b = checkout.lineItems) === null || _b === void 0 ? void 0 : _b.map(function (item) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_h) {
920
+ switch (_h.label) {
921
+ case 0: return [4 /*yield*/, this.buildLineItem({ checkout: checkout, item: item })];
922
+ case 1: return [2 /*return*/, (_h.sent()).lineItem];
923
+ }
924
+ }); }); }))];
925
+ case 1:
926
+ _r = _s.sent();
927
+ return [3 /*break*/, 3];
928
+ case 2:
929
+ _r = [];
930
+ _s.label = 3;
931
+ case 3: return [2 /*return*/, _j.apply(_h, [_l.apply(_k, [_o.apply(_m, _p.concat([(_q.lineItems = _r, _q)]))])])
932
+ .toPromise()];
933
+ }
934
+ });
935
+ }); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
936
+ };
937
+ CartService.prototype.clearCart = function () {
938
+ var _this = this;
939
+ return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
940
+ _this.checkoutService.clearCheckoutFromSession();
941
+ return checkout;
942
+ }), operators.concatMap(function (oldCheckout) { return _this.buildCartFromCheckout(oldCheckout); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
943
+ };
944
+ CartService.prototype.buildCartFromCheckout = function (checkoutData) {
945
+ var _this = this;
946
+ return this.checkoutService.getCheckout(checkoutData).pipe(operators.map(function (checkout) { return checkout.lineItems; }), operators.concatMap(function (lineItems) { return rxjs.of(_this.generateCartObject(lineItems)); }));
947
+ };
948
+ CartService.prototype.getProductData = function (productId) {
949
+ return __awaiter(this, void 0, void 0, function () {
950
+ var product, variant, error_1;
951
+ return __generator(this, function (_h) {
952
+ switch (_h.label) {
953
+ case 0:
954
+ _h.trys.push([0, 2, , 5]);
955
+ return [4 /*yield*/, this.productRepository.get({ id: productId })];
956
+ case 1:
957
+ product = _h.sent();
958
+ return [3 /*break*/, 5];
959
+ case 2:
960
+ error_1 = _h.sent();
961
+ if (!(error_1 instanceof i3.NotFoundError))
962
+ throw error_1;
963
+ return [4 /*yield*/, this.variantRepository.get({ id: productId })];
964
+ case 3:
965
+ variant = _h.sent();
966
+ return [4 /*yield*/, this.productRepository.get({ id: variant.productId })];
967
+ case 4:
968
+ product = _h.sent();
969
+ return [3 /*break*/, 5];
970
+ case 5: return [2 /*return*/, Object.assign(Object.assign({}, product.toPlain()), (variant && Object.assign({}, variant.toPlain())))];
971
+ }
972
+ });
973
+ });
974
+ };
975
+ CartService.prototype.getGifts = function () {
976
+ var _this = this;
977
+ return this.checkoutService.getCheckout().pipe(operators.mergeMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () {
978
+ var notGiftItems, cartTotal, campaigns, elegibleCampaigns, _loop_1, campaigns_1, campaigns_1_1, campaign, campaingnProducts, elegibleCampaigns_1, elegibleCampaigns_1_1, campaign, elegibleProducts, _h, _j, product, productData, gift, e_1_1, e_2_1, gifts;
979
+ var e_3, _k, e_2, _l, e_1, _m;
980
+ return __generator(this, function (_o) {
981
+ switch (_o.label) {
982
+ case 0:
983
+ notGiftItems = checkout.lineItems ? checkout.lineItems.filter(function (item) { return !item.isGift; }) : [];
984
+ if (!notGiftItems.length)
985
+ return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: [] })];
986
+ cartTotal = notGiftItems.reduce(function (a, b) { return a + b.pricePaid * b.quantity; }, 0);
987
+ return [4 /*yield*/, this.buy2WinRepository
988
+ .find({
989
+ filters: {
990
+ active: { operator: i3.Where.EQUALS, value: true },
991
+ shop: { operator: i3.Where.EQUALS, value: this.defaultShop },
992
+ },
993
+ })
994
+ .then(function (data) { return data.data; })];
995
+ case 1:
996
+ campaigns = _o.sent();
997
+ if (!campaigns.length)
998
+ return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems })];
999
+ elegibleCampaigns = [];
1000
+ _loop_1 = function (campaign) {
1001
+ var today = new Date();
1002
+ if (!(campaign.startDate <= today) && !(campaign.endDate >= today))
1003
+ return "continue";
1004
+ if (campaign.activeCategory) {
1005
+ var categoriesCampaing_1 = campaign.categories.map(function (c) { return c.id; });
1006
+ var filterProductsCategories = checkout.lineItems.filter(function (l) {
1007
+ var _a;
1008
+ if (!l.categories || !((_a = l.categories) === null || _a === void 0 ? void 0 : _a.length))
1009
+ return true;
1010
+ return l.categories.some(function (c) { return categoriesCampaing_1.some(function (cat) { return cat == c; }); });
1011
+ });
1012
+ if (filterProductsCategories.length) {
1013
+ var cartTotalCategories = filterProductsCategories.reduce(function (a, b) { return a + b.pricePaid * b.quantity; }, 0);
1014
+ if (cartTotalCategories >= campaign.cartValueMin)
1015
+ elegibleCampaigns.push(campaign);
1016
+ }
1017
+ }
1018
+ else {
1019
+ if (campaign.cartValue && campaign.cartValue > 0) {
1020
+ if (campaign.cartValue <= cartTotal)
1021
+ elegibleCampaigns.push(campaign);
1022
+ }
1023
+ }
1024
+ };
1025
+ try {
1026
+ for (campaigns_1 = __values(campaigns), campaigns_1_1 = campaigns_1.next(); !campaigns_1_1.done; campaigns_1_1 = campaigns_1.next()) {
1027
+ campaign = campaigns_1_1.value;
1028
+ _loop_1(campaign);
1029
+ }
1030
+ }
1031
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
1032
+ finally {
1033
+ try {
1034
+ if (campaigns_1_1 && !campaigns_1_1.done && (_k = campaigns_1.return)) _k.call(campaigns_1);
1035
+ }
1036
+ finally { if (e_3) throw e_3.error; }
1037
+ }
1038
+ if (!elegibleCampaigns.length)
1039
+ return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems })];
1040
+ campaingnProducts = [];
1041
+ _o.label = 2;
1042
+ case 2:
1043
+ _o.trys.push([2, 14, 15, 16]);
1044
+ elegibleCampaigns_1 = __values(elegibleCampaigns), elegibleCampaigns_1_1 = elegibleCampaigns_1.next();
1045
+ _o.label = 3;
1046
+ case 3:
1047
+ if (!!elegibleCampaigns_1_1.done) return [3 /*break*/, 13];
1048
+ campaign = elegibleCampaigns_1_1.value;
1049
+ elegibleProducts = [];
1050
+ _o.label = 4;
1051
+ case 4:
1052
+ _o.trys.push([4, 9, 10, 11]);
1053
+ _h = (e_1 = void 0, __values(campaign.products)), _j = _h.next();
1054
+ _o.label = 5;
1055
+ case 5:
1056
+ if (!!_j.done) return [3 /*break*/, 8];
1057
+ product = _j.value;
1058
+ return [4 /*yield*/, this.productRepository.find({ filters: { sku: product } })];
1059
+ case 6:
1060
+ productData = (_o.sent()).data;
1061
+ if (!productData.length)
1062
+ return [3 /*break*/, 7];
1063
+ gift = productData.shift();
1064
+ if (gift.stock.quantity < 1)
1065
+ return [3 /*break*/, 7];
1066
+ elegibleProducts.push(gift);
1067
+ _o.label = 7;
1068
+ case 7:
1069
+ _j = _h.next();
1070
+ return [3 /*break*/, 5];
1071
+ case 8: return [3 /*break*/, 11];
1072
+ case 9:
1073
+ e_1_1 = _o.sent();
1074
+ e_1 = { error: e_1_1 };
1075
+ return [3 /*break*/, 11];
1076
+ case 10:
1077
+ try {
1078
+ if (_j && !_j.done && (_m = _h.return)) _m.call(_h);
1079
+ }
1080
+ finally { if (e_1) throw e_1.error; }
1081
+ return [7 /*endfinally*/];
1082
+ case 11:
1083
+ campaingnProducts.push(elegibleProducts);
1084
+ _o.label = 12;
1085
+ case 12:
1086
+ elegibleCampaigns_1_1 = elegibleCampaigns_1.next();
1087
+ return [3 /*break*/, 3];
1088
+ case 13: return [3 /*break*/, 16];
1089
+ case 14:
1090
+ e_2_1 = _o.sent();
1091
+ e_2 = { error: e_2_1 };
1092
+ return [3 /*break*/, 16];
1093
+ case 15:
1094
+ try {
1095
+ if (elegibleCampaigns_1_1 && !elegibleCampaigns_1_1.done && (_l = elegibleCampaigns_1.return)) _l.call(elegibleCampaigns_1);
1096
+ }
1097
+ finally { if (e_2) throw e_2.error; }
1098
+ return [7 /*endfinally*/];
1099
+ case 16:
1100
+ if (!campaingnProducts.length)
1101
+ return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems })];
1102
+ gifts = this.giftToLineItems([].concat.apply([], __spreadArray([], __read(campaingnProducts))));
1103
+ return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems.concat(gifts) })];
1104
+ }
1105
+ });
1106
+ }); }), operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutLineItems(checkout); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
1107
+ };
1108
+ CartService.prototype.giftToLineItems = function (items) {
1109
+ return items.map(function (item) {
1110
+ var _a;
1111
+ var brand = item.brand, categories = item.categories, id = item.id, name = item.name, price = item.price, sku = item.sku, slug = item.slug, stock = item.stock, weight = item.weight, EAN = item.EAN;
1112
+ var image = ((_a = item === null || item === void 0 ? void 0 : item.miniatures) === null || _a === void 0 ? void 0 : _a.length) ? item.miniatures[0] : item.images[0];
1113
+ return i3.LineItem.toInstance({
1114
+ brand: brand,
1115
+ categories: categories,
1116
+ id: id.toString(),
1117
+ name: name,
1118
+ price: price,
1119
+ sku: sku,
1120
+ slug: slug,
1121
+ stock: stock,
1122
+ weight: weight,
1123
+ EAN: EAN,
1124
+ image: image,
1125
+ pricePaid: 0,
1126
+ quantity: 1,
1127
+ isGift: true,
1128
+ });
1129
+ });
1130
+ };
1131
+ return CartService;
1132
+ }());
1133
+ CartService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'VariantRepository' }, { token: 'Buy2WinRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1134
+ CartService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService });
1135
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService, decorators: [{
1136
+ type: i0.Injectable
1137
+ }], ctorParameters: function () {
1138
+ return [{ type: AuthService }, { type: CheckoutService }, { type: i3__namespace.Shops, decorators: [{
1139
+ type: i0.Inject,
1140
+ args: [DEFAULT_SHOP]
1141
+ }] }, { type: undefined, decorators: [{
1142
+ type: i0.Inject,
1143
+ args: ['ProductRepository']
1144
+ }] }, { type: undefined, decorators: [{
1145
+ type: i0.Inject,
1146
+ args: ['VariantRepository']
1147
+ }] }, { type: i3__namespace.Buy2WinFirestoreRepository, decorators: [{
1148
+ type: i0.Inject,
1149
+ args: ['Buy2WinRepository']
1150
+ }] }];
1188
1151
  } });
1189
1152
 
1190
- var CheckoutSubscriptionService = /** @class */ (function () {
1191
- function CheckoutSubscriptionService(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
1192
- this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
1193
- this.subscriptionRepository = subscriptionRepository;
1194
- this.couponService = couponService;
1195
- }
1196
- CheckoutSubscriptionService.prototype.getCheckoutSubscription = function (checkoutData) {
1197
- var checkoutId = cookie__default["default"].get('checkoutSubscriptionId');
1198
- if (!i3.isNil(checkoutId))
1199
- return rxjs.from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
1200
- return rxjs.from(this.createCheckoutSubscription(checkoutData));
1201
- };
1202
- CheckoutSubscriptionService.prototype.createCheckoutSubscription = function (checkoutData) {
1203
- return __awaiter(this, void 0, void 0, function () {
1204
- var checkout;
1205
- return __generator(this, function (_a) {
1206
- switch (_a.label) {
1207
- case 0: return [4 /*yield*/, this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, i3.CheckoutSubscription.toInstance(i3.pick(checkoutData, ['user', 'shop'])).toPlain()))];
1208
- case 1:
1209
- checkout = _a.sent();
1210
- cookie__default["default"].set('checkoutSubscriptionId', checkout.id);
1211
- return [2 /*return*/, checkout];
1212
- }
1213
- });
1214
- });
1215
- };
1216
- CheckoutSubscriptionService.prototype.clearCheckoutSubscriptionFromSession = function () {
1217
- cookie__default["default"].remove('checkoutSubscriptionId');
1218
- return rxjs.of();
1219
- };
1220
- CheckoutSubscriptionService.prototype.checkCoupon = function (nickname, userEmail) {
1221
- var _this = this;
1222
- return this.getCheckoutSubscription().pipe(operators.concatMap(function (checkout) { return _this.couponService
1223
- .checkCoupon(nickname, userEmail, i3.CheckoutTypes.SUBSCRIPTION, checkout.subscriptionPlan.name, checkout, true)
1224
- .pipe(); }));
1225
- };
1226
- CheckoutSubscriptionService.prototype.calcDiscountSubscription = function (coupon) {
1227
- var _this = this;
1228
- return this.getCheckoutSubscription().pipe(operators.concatMap(function (checkout) { return _this.couponService.calcDiscountSubscription(coupon, checkout).pipe(); }));
1229
- };
1230
- return CheckoutSubscriptionService;
1231
- }());
1232
- CheckoutSubscriptionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: 'SubscriptionRepository' }, { token: CouponService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1233
- CheckoutSubscriptionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService });
1234
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService, decorators: [{
1235
- type: i0.Injectable
1236
- }], ctorParameters: function () {
1237
- return [{ type: undefined, decorators: [{
1238
- type: i0.Inject,
1239
- args: ['CheckoutSubscriptionRepository']
1240
- }] }, { type: undefined, decorators: [{
1241
- type: i0.Inject,
1242
- args: ['SubscriptionRepository']
1243
- }] }, { type: CouponService }];
1153
+ var CheckoutSubscriptionService = /** @class */ (function () {
1154
+ function CheckoutSubscriptionService(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
1155
+ this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
1156
+ this.subscriptionRepository = subscriptionRepository;
1157
+ this.couponService = couponService;
1158
+ }
1159
+ CheckoutSubscriptionService.prototype.getCheckoutSubscription = function (checkoutData) {
1160
+ var checkoutId = cookie__default["default"].get('checkoutSubscriptionId');
1161
+ if (!i3.isNil(checkoutId))
1162
+ return rxjs.from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
1163
+ return rxjs.from(this.createCheckoutSubscription(checkoutData));
1164
+ };
1165
+ CheckoutSubscriptionService.prototype.createCheckoutSubscription = function (checkoutData) {
1166
+ return __awaiter(this, void 0, void 0, function () {
1167
+ var checkout;
1168
+ return __generator(this, function (_a) {
1169
+ switch (_a.label) {
1170
+ case 0: return [4 /*yield*/, this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, i3.CheckoutSubscription.toInstance(i3.pick(checkoutData, ['user', 'shop'])).toPlain()))];
1171
+ case 1:
1172
+ checkout = _a.sent();
1173
+ cookie__default["default"].set('checkoutSubscriptionId', checkout.id);
1174
+ return [2 /*return*/, checkout];
1175
+ }
1176
+ });
1177
+ });
1178
+ };
1179
+ CheckoutSubscriptionService.prototype.clearCheckoutSubscriptionFromSession = function () {
1180
+ cookie__default["default"].remove('checkoutSubscriptionId');
1181
+ return rxjs.of();
1182
+ };
1183
+ CheckoutSubscriptionService.prototype.checkCoupon = function (nickname, userEmail) {
1184
+ var _this = this;
1185
+ return this.getCheckoutSubscription().pipe(operators.concatMap(function (checkout) { return _this.couponService
1186
+ .checkCoupon(nickname, i3.CheckoutTypes.SUBSCRIPTION, checkout, checkout.subscriptionPlan.name)
1187
+ .pipe(); }));
1188
+ };
1189
+ CheckoutSubscriptionService.prototype.calcDiscountSubscription = function (coupon) {
1190
+ var _this = this;
1191
+ return this.getCheckoutSubscription().pipe(operators.concatMap(function (checkout) { return _this.couponService.calcDiscountSubscription(coupon, checkout).pipe(); }));
1192
+ };
1193
+ return CheckoutSubscriptionService;
1194
+ }());
1195
+ CheckoutSubscriptionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: 'SubscriptionRepository' }, { token: CouponService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1196
+ CheckoutSubscriptionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService });
1197
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService, decorators: [{
1198
+ type: i0.Injectable
1199
+ }], ctorParameters: function () {
1200
+ return [{ type: undefined, decorators: [{
1201
+ type: i0.Inject,
1202
+ args: ['CheckoutSubscriptionRepository']
1203
+ }] }, { type: undefined, decorators: [{
1204
+ type: i0.Inject,
1205
+ args: ['SubscriptionRepository']
1206
+ }] }, { type: CouponService }];
1244
1207
  } });
1245
1208
 
1246
- var HomeShopService = /** @class */ (function () {
1247
- function HomeShopService(categoryRepository, homeRepository, productRepository, defaultShop) {
1248
- this.categoryRepository = categoryRepository;
1249
- this.homeRepository = homeRepository;
1250
- this.productRepository = productRepository;
1251
- this.defaultShop = defaultShop;
1252
- this.buildCategoryGroupWithRequiredData = function (group) {
1253
- var _a, _b;
1254
- return ({
1255
- category: i3.Category.toInstance(i3.pick(((_a = group === null || group === void 0 ? void 0 : group.category) === null || _a === void 0 ? void 0 : _a.toPlain()) || {}, ['id', 'name', 'slug', 'conditions'])),
1256
- products: ((_b = group === null || group === void 0 ? void 0 : group.products) === null || _b === void 0 ? void 0 : _b.map(function (product) { return i3.Product.toInstance(i3.pick((product === null || product === void 0 ? void 0 : product.toPlain()) || {}, [
1257
- 'id',
1258
- 'price',
1259
- 'reviews',
1260
- 'hasVariants',
1261
- 'slug',
1262
- 'sku',
1263
- 'stock',
1264
- 'costPrice',
1265
- 'images',
1266
- 'miniatures',
1267
- 'name',
1268
- 'weight',
1269
- 'rate',
1270
- 'type',
1271
- ])); })) || [],
1272
- });
1273
- };
1274
- }
1275
- Object.defineProperty(HomeShopService.prototype, "homeId", {
1276
- get: function () {
1277
- if (this.defaultShop === i3.Shops.GLAMSHOP)
1278
- return 'glamshop';
1279
- if (this.defaultShop === i3.Shops.MENSMARKET)
1280
- return 'mens_market';
1281
- return null;
1282
- },
1283
- enumerable: false,
1284
- configurable: true
1285
- });
1286
- HomeShopService.prototype.getHomeData = function () {
1287
- var _this = this;
1288
- return this.getHomeConfiguration().pipe(operators.map(function (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); }), operators.concatMap(function (home) { return home
1289
- ? rxjs.of(home)
1290
- : rxjs.forkJoin([_this.getDiscoverProducts(), _this.getFeaturedProducts(), _this.getVerticalProducts()]).pipe(operators.map(function (_c) {
1291
- var _d = __read(_c, 3), discoverProducts = _d[0], featuredProducts = _d[1], verticalProducts = _d[2];
1292
- return ({
1293
- discoverProducts: discoverProducts,
1294
- featuredProducts: featuredProducts,
1295
- verticalProducts: verticalProducts,
1296
- });
1297
- }), operators.concatMap(function (data) { return _this.saveHomeData(data); })); }));
1298
- };
1299
- HomeShopService.prototype.getBanners = function (type) {
1300
- return this.getHomeConfiguration().pipe(operators.map(function (home) {
1301
- if (type === 'brand')
1302
- return home.brandsCarousel;
1303
- if (type === 'buyToWin')
1304
- return [home.buyToWinBanner];
1305
- if (type === 'block')
1306
- return home.blockBanners;
1307
- if (type === 'blog')
1308
- return [home.blogBanner];
1309
- }));
1310
- };
1311
- HomeShopService.prototype.getMinValueForFreeShipping = function () {
1312
- return this.getHomeConfiguration().pipe(operators.map(function (home) { return home.minValueForFreeShipping; }));
1313
- };
1314
- HomeShopService.prototype.getDiscoverProducts = function () {
1315
- var _this = this;
1316
- return this.getHomeConfiguration().pipe(operators.concatMap(function (home) { return rxjs.from(_this.categoryRepository.getCategoriesForHome(home.discoverCategories)).pipe(operators.map(function (groups) { return groups.map(_this.buildCategoryGroupWithRequiredData); })); }));
1317
- };
1318
- HomeShopService.prototype.getFeaturedProducts = function () {
1319
- var _this = this;
1320
- return this.getHomeConfiguration().pipe(operators.concatMap(function (home) { return rxjs.from(_this.categoryRepository.getCategoriesForHome(home.featuredCategories)).pipe(operators.map(function (groups) { return groups.map(_this.buildCategoryGroupWithRequiredData); })); }));
1321
- };
1322
- HomeShopService.prototype.getVerticalProducts = function () {
1323
- var _this = this;
1324
- return this.getHomeConfiguration().pipe(operators.concatMap(function (home) { return rxjs.forkJoin(home.verticalCarousels.filter(Boolean).map(function (id) { return rxjs.from(_this.categoryRepository.get({ id: id })).pipe(operators.concatMap(function (category) { return rxjs.from(_this.productRepository.find({
1325
- filters: { categories: { operator: i3.Where.IN, value: [category.id] } },
1326
- limits: { limit: 12 },
1327
- })).pipe(operators.map(function (products) { return ({ category: category, products: products }); })); }), operators.map(function (_c) {
1328
- var category = _c.category, products = _c.products;
1329
- return ({ category: category, products: products.data });
1330
- }), operators.map(_this.buildCategoryGroupWithRequiredData)); })); }));
1331
- };
1332
- HomeShopService.prototype.getHomeConfiguration = function () {
1333
- var _this = this;
1334
- return rxjs.of(this.homeConfiguration).pipe(operators.concatMap(function (home) { return home
1335
- ? rxjs.of(home)
1336
- : !_this.homeId
1337
- ? rxjs.throwError(new i3.RequiredArgumentError(['homeId']))
1338
- : rxjs.from(_this.homeRepository.get({ id: _this.homeId })).pipe(operators.tap(function (homeLoaded) { return (_this.homeConfiguration = homeLoaded); })); }));
1339
- };
1340
- HomeShopService.prototype.saveHomeData = function (homeData) {
1341
- var _this = this;
1342
- var data = {
1343
- createdAt: new Date(),
1344
- expiresAt: i3.add(new Date(), { hours: 1 }),
1345
- data: homeData,
1346
- };
1347
- return rxjs.from(this.homeRepository.update({
1348
- id: this.homeId,
1349
- data: data,
1350
- })).pipe(operators.tap(function () { return (_this.homeConfiguration.data = data); }), operators.map(function () { return _this.homeConfiguration; }));
1351
- };
1352
- return HomeShopService;
1353
- }());
1354
- HomeShopService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService, deps: [{ token: 'CategoryRepository' }, { token: 'HomeRepository' }, { token: 'ProductRepository' }, { token: DEFAULT_SHOP }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1355
- HomeShopService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService });
1356
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService, decorators: [{
1357
- type: i0.Injectable
1358
- }], ctorParameters: function () {
1359
- return [{ type: undefined, decorators: [{
1360
- type: i0.Inject,
1361
- args: ['CategoryRepository']
1362
- }] }, { type: undefined, decorators: [{
1363
- type: i0.Inject,
1364
- args: ['HomeRepository']
1365
- }] }, { type: undefined, decorators: [{
1366
- type: i0.Inject,
1367
- args: ['ProductRepository']
1368
- }] }, { type: i3__namespace.Shops, decorators: [{
1369
- type: i0.Inject,
1370
- args: [DEFAULT_SHOP]
1371
- }] }];
1209
+ var HomeShopService = /** @class */ (function () {
1210
+ function HomeShopService(categoryRepository, homeRepository, productRepository, defaultShop) {
1211
+ this.categoryRepository = categoryRepository;
1212
+ this.homeRepository = homeRepository;
1213
+ this.productRepository = productRepository;
1214
+ this.defaultShop = defaultShop;
1215
+ this.buildCategoryGroupWithRequiredData = function (group) {
1216
+ var _a, _b;
1217
+ return ({
1218
+ category: i3.Category.toInstance(i3.pick(((_a = group === null || group === void 0 ? void 0 : group.category) === null || _a === void 0 ? void 0 : _a.toPlain()) || {}, ['id', 'name', 'slug', 'conditions'])),
1219
+ products: ((_b = group === null || group === void 0 ? void 0 : group.products) === null || _b === void 0 ? void 0 : _b.map(function (product) { return i3.Product.toInstance(i3.pick((product === null || product === void 0 ? void 0 : product.toPlain()) || {}, [
1220
+ 'id',
1221
+ 'price',
1222
+ 'reviews',
1223
+ 'hasVariants',
1224
+ 'slug',
1225
+ 'sku',
1226
+ 'stock',
1227
+ 'costPrice',
1228
+ 'images',
1229
+ 'miniatures',
1230
+ 'name',
1231
+ 'weight',
1232
+ 'rate',
1233
+ 'type',
1234
+ ])); })) || [],
1235
+ });
1236
+ };
1237
+ }
1238
+ Object.defineProperty(HomeShopService.prototype, "homeId", {
1239
+ get: function () {
1240
+ if (this.defaultShop === i3.Shops.GLAMSHOP)
1241
+ return 'glamshop';
1242
+ if (this.defaultShop === i3.Shops.MENSMARKET)
1243
+ return 'mens_market';
1244
+ return null;
1245
+ },
1246
+ enumerable: false,
1247
+ configurable: true
1248
+ });
1249
+ HomeShopService.prototype.getHomeData = function () {
1250
+ var _this = this;
1251
+ return this.getHomeConfiguration().pipe(operators.map(function (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); }), operators.concatMap(function (home) { return home
1252
+ ? rxjs.of(home)
1253
+ : rxjs.forkJoin([_this.getDiscoverProducts(), _this.getFeaturedProducts(), _this.getVerticalProducts()]).pipe(operators.map(function (_c) {
1254
+ var _d = __read(_c, 3), discoverProducts = _d[0], featuredProducts = _d[1], verticalProducts = _d[2];
1255
+ return ({
1256
+ discoverProducts: discoverProducts,
1257
+ featuredProducts: featuredProducts,
1258
+ verticalProducts: verticalProducts,
1259
+ });
1260
+ }), operators.concatMap(function (data) { return _this.saveHomeData(data); })); }));
1261
+ };
1262
+ HomeShopService.prototype.getBanners = function (type) {
1263
+ return this.getHomeConfiguration().pipe(operators.map(function (home) {
1264
+ if (type === 'brand')
1265
+ return home.brandsCarousel;
1266
+ if (type === 'buyToWin')
1267
+ return [home.buyToWinBanner];
1268
+ if (type === 'block')
1269
+ return home.blockBanners;
1270
+ if (type === 'blog')
1271
+ return [home.blogBanner];
1272
+ }));
1273
+ };
1274
+ HomeShopService.prototype.getMinValueForFreeShipping = function () {
1275
+ return this.getHomeConfiguration().pipe(operators.map(function (home) { return home.minValueForFreeShipping; }));
1276
+ };
1277
+ HomeShopService.prototype.getDiscoverProducts = function () {
1278
+ var _this = this;
1279
+ return this.getHomeConfiguration().pipe(operators.concatMap(function (home) { return rxjs.from(_this.categoryRepository.getCategoriesForHome(home.discoverCategories)).pipe(operators.map(function (groups) { return groups.map(_this.buildCategoryGroupWithRequiredData); })); }));
1280
+ };
1281
+ HomeShopService.prototype.getFeaturedProducts = function () {
1282
+ var _this = this;
1283
+ return this.getHomeConfiguration().pipe(operators.concatMap(function (home) { return rxjs.from(_this.categoryRepository.getCategoriesForHome(home.featuredCategories)).pipe(operators.map(function (groups) { return groups.map(_this.buildCategoryGroupWithRequiredData); })); }));
1284
+ };
1285
+ HomeShopService.prototype.getVerticalProducts = function () {
1286
+ var _this = this;
1287
+ return this.getHomeConfiguration().pipe(operators.concatMap(function (home) { return rxjs.forkJoin(home.verticalCarousels.filter(Boolean).map(function (id) { return rxjs.from(_this.categoryRepository.get({ id: id })).pipe(operators.concatMap(function (category) { return rxjs.from(_this.productRepository.find({
1288
+ filters: { categories: { operator: i3.Where.IN, value: [category.id] } },
1289
+ limits: { limit: 12 },
1290
+ })).pipe(operators.map(function (products) { return ({ category: category, products: products }); })); }), operators.map(function (_c) {
1291
+ var category = _c.category, products = _c.products;
1292
+ return ({ category: category, products: products.data });
1293
+ }), operators.map(_this.buildCategoryGroupWithRequiredData)); })); }));
1294
+ };
1295
+ HomeShopService.prototype.getHomeConfiguration = function () {
1296
+ var _this = this;
1297
+ return rxjs.of(this.homeConfiguration).pipe(operators.concatMap(function (home) { return home
1298
+ ? rxjs.of(home)
1299
+ : !_this.homeId
1300
+ ? rxjs.throwError(new i3.RequiredArgumentError(['homeId']))
1301
+ : rxjs.from(_this.homeRepository.get({ id: _this.homeId })).pipe(operators.tap(function (homeLoaded) { return (_this.homeConfiguration = homeLoaded); })); }));
1302
+ };
1303
+ HomeShopService.prototype.saveHomeData = function (homeData) {
1304
+ var _this = this;
1305
+ var data = {
1306
+ createdAt: new Date(),
1307
+ expiresAt: i3.add(new Date(), { hours: 1 }),
1308
+ data: homeData,
1309
+ };
1310
+ return rxjs.from(this.homeRepository.update({
1311
+ id: this.homeId,
1312
+ data: data,
1313
+ })).pipe(operators.tap(function () { return (_this.homeConfiguration.data = data); }), operators.map(function () { return _this.homeConfiguration; }));
1314
+ };
1315
+ return HomeShopService;
1316
+ }());
1317
+ HomeShopService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService, deps: [{ token: 'CategoryRepository' }, { token: 'HomeRepository' }, { token: 'ProductRepository' }, { token: DEFAULT_SHOP }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1318
+ HomeShopService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService });
1319
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService, decorators: [{
1320
+ type: i0.Injectable
1321
+ }], ctorParameters: function () {
1322
+ return [{ type: undefined, decorators: [{
1323
+ type: i0.Inject,
1324
+ args: ['CategoryRepository']
1325
+ }] }, { type: undefined, decorators: [{
1326
+ type: i0.Inject,
1327
+ args: ['HomeRepository']
1328
+ }] }, { type: undefined, decorators: [{
1329
+ type: i0.Inject,
1330
+ args: ['ProductRepository']
1331
+ }] }, { type: i3__namespace.Shops, decorators: [{
1332
+ type: i0.Inject,
1333
+ args: [DEFAULT_SHOP]
1334
+ }] }];
1372
1335
  } });
1373
1336
 
1374
- var OrderService = /** @class */ (function () {
1375
- function OrderService(angularFirestore, orderRepository) {
1376
- this.angularFirestore = angularFirestore;
1377
- this.orderRepository = orderRepository;
1378
- this.orderSubject = new rxjs.Subject();
1379
- }
1380
- OrderService.prototype.getOrder = function (id) {
1381
- var _this = this;
1382
- this.angularFirestore
1383
- .doc(this.orderRepository.collectionName + "/" + id)
1384
- .valueChanges()
1385
- .pipe(operators.map(function (doc) { return i3.Order.toInstance(doc); }))
1386
- .subscribe(function (doc) { return _this.orderSubject.next(doc); });
1387
- return this.orderSubject;
1388
- };
1389
- return OrderService;
1390
- }());
1391
- OrderService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService, deps: [{ token: i1__namespace$1.AngularFirestore }, { token: 'OrderRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1392
- OrderService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService });
1393
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService, decorators: [{
1394
- type: i0.Injectable
1395
- }], ctorParameters: function () {
1396
- return [{ type: i1__namespace$1.AngularFirestore }, { type: i3__namespace.OrderFirestoreRepository, decorators: [{
1397
- type: i0.Inject,
1398
- args: ['OrderRepository']
1399
- }] }];
1337
+ var OrderService = /** @class */ (function () {
1338
+ function OrderService(angularFirestore, orderRepository) {
1339
+ this.angularFirestore = angularFirestore;
1340
+ this.orderRepository = orderRepository;
1341
+ this.orderSubject = new rxjs.Subject();
1342
+ }
1343
+ OrderService.prototype.getOrder = function (id) {
1344
+ var _this = this;
1345
+ this.angularFirestore
1346
+ .doc(this.orderRepository.collectionName + "/" + id)
1347
+ .valueChanges()
1348
+ .pipe(operators.map(function (doc) { return i3.Order.toInstance(doc); }))
1349
+ .subscribe(function (doc) { return _this.orderSubject.next(doc); });
1350
+ return this.orderSubject;
1351
+ };
1352
+ return OrderService;
1353
+ }());
1354
+ OrderService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService, deps: [{ token: i1__namespace$1.AngularFirestore }, { token: 'OrderRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1355
+ OrderService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService });
1356
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService, decorators: [{
1357
+ type: i0.Injectable
1358
+ }], ctorParameters: function () {
1359
+ return [{ type: i1__namespace$1.AngularFirestore }, { type: i3__namespace.OrderFirestoreRepository, decorators: [{
1360
+ type: i0.Inject,
1361
+ args: ['OrderRepository']
1362
+ }] }];
1400
1363
  } });
1401
1364
 
1402
- var ShippingService = /** @class */ (function () {
1403
- function ShippingService(http, apiUrl, homeService) {
1404
- this.http = http;
1405
- this.apiUrl = apiUrl;
1406
- this.homeService = homeService;
1407
- }
1408
- ShippingService.prototype.getShippingMethods = function (shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
1409
- var _this = this;
1410
- return rxjs.combineLatest([
1411
- this.homeService.getHomeData(),
1412
- this.http.get(this.apiUrl + "open/checkshippingcompany?personId=" + personId + "&postalCode=" + zip + "&weightGrams=" + weightGrams),
1413
- ]).pipe(operators.map(function (_a) {
1414
- var _b = __read(_a, 2), datas = _b[0], shippingMethodsResponse = _b[1];
1415
- var shippingMethods = shippingMethodsResponse.result;
1416
- if (!shippingMethods.length)
1417
- return [];
1418
- shippingMethods = shippingMethods.map(function (s) {
1419
- if (s.ShippingCompanyName == 'Same Day EG')
1420
- s.ShippingCompanyName = 'Same Day';
1421
- else
1422
- return s;
1423
- });
1424
- var datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
1425
- if (_this.isHolidays(datasSameDayNotAvaliable)) {
1426
- shippingMethods = shippingMethods.filter(function (method) { return method.serviceName !== 'Same Day'; });
1427
- }
1428
- if (totalPrice >= 200) {
1429
- shippingMethods = shippingMethods.map(function (s) {
1430
- if (s.serviceName !== 'Same Day')
1431
- return Object.assign(Object.assign({}, s), { totalPrice: 0 });
1432
- else
1433
- return s;
1434
- });
1435
- }
1436
- if (shop == i3.Shops.GLAMSHOP)
1437
- return shippingMethods;
1438
- if (_this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
1439
- shippingMethods = shippingMethods.map(function (s) {
1440
- if (s.serviceName == 'Same Day')
1441
- return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
1442
- else
1443
- return Object.assign(Object.assign({}, s), { totalPrice: 0 });
1444
- });
1445
- }
1446
- if (_this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
1447
- shippingMethods = shippingMethods.map(function (s) {
1448
- return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
1449
- });
1450
- }
1451
- return shippingMethods;
1452
- }));
1453
- };
1454
- ShippingService.prototype.isFreeShippingBySubscription = function (shop, subscriptionPlan) {
1455
- if (!subscriptionPlan)
1456
- return false;
1457
- if (shop == i3.Shops.MENSMARKET && subscriptionPlan == 'SELECT') {
1458
- return true;
1459
- }
1460
- return false;
1461
- };
1462
- ShippingService.prototype.isHalfShippingBySubscription = function (shop, subscriptionPlan) {
1463
- if (!subscriptionPlan)
1464
- return false;
1465
- if (shop == i3.Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
1466
- return true;
1467
- }
1468
- return false;
1469
- };
1470
- ShippingService.prototype.isHolidays = function (datas) {
1471
- var today = new Date();
1472
- for (var key in datas) {
1473
- var start = new Date(today.getFullYear() + "-" + datas[key].beginDate);
1474
- var end = new Date(today.getFullYear() + "-" + datas[key].endDate);
1475
- if (start > end)
1476
- end = new Date(today.getFullYear() + 1 + "-" + datas[key].endDate);
1477
- if (today >= start && today <= end)
1478
- return true;
1479
- }
1480
- return false;
1481
- };
1482
- return ShippingService;
1483
- }());
1484
- ShippingService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService, deps: [{ token: i1__namespace$2.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1485
- ShippingService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService });
1486
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService, decorators: [{
1487
- type: i0.Injectable
1488
- }], ctorParameters: function () {
1489
- return [{ type: i1__namespace$2.HttpClient }, { type: undefined, decorators: [{
1490
- type: i0.Inject,
1491
- args: [BACKEND_URL]
1492
- }] }, { type: HomeShopService }];
1365
+ var ShippingService = /** @class */ (function () {
1366
+ function ShippingService(http, apiUrl, homeService) {
1367
+ this.http = http;
1368
+ this.apiUrl = apiUrl;
1369
+ this.homeService = homeService;
1370
+ }
1371
+ ShippingService.prototype.getShippingMethods = function (shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
1372
+ var _this = this;
1373
+ return rxjs.combineLatest([
1374
+ this.homeService.getHomeData(),
1375
+ this.http.get(this.apiUrl + "open/checkshippingcompany?personId=" + personId + "&postalCode=" + zip + "&weightGrams=" + weightGrams),
1376
+ ]).pipe(operators.map(function (_a) {
1377
+ var _b = __read(_a, 2), datas = _b[0], shippingMethodsResponse = _b[1];
1378
+ var shippingMethods = shippingMethodsResponse.result;
1379
+ if (!shippingMethods.length)
1380
+ return [];
1381
+ shippingMethods = shippingMethods.map(function (s) {
1382
+ if (s.ShippingCompanyName == 'Same Day EG')
1383
+ s.ShippingCompanyName = 'Same Day';
1384
+ else
1385
+ return s;
1386
+ });
1387
+ var datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
1388
+ if (_this.isHolidays(datasSameDayNotAvaliable)) {
1389
+ shippingMethods = shippingMethods.filter(function (method) { return method.serviceName !== 'Same Day'; });
1390
+ }
1391
+ if (totalPrice >= 200) {
1392
+ shippingMethods = shippingMethods.map(function (s) {
1393
+ if (s.serviceName !== 'Same Day')
1394
+ return Object.assign(Object.assign({}, s), { totalPrice: 0 });
1395
+ else
1396
+ return s;
1397
+ });
1398
+ }
1399
+ if (shop == i3.Shops.GLAMSHOP)
1400
+ return shippingMethods;
1401
+ if (_this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
1402
+ shippingMethods = shippingMethods.map(function (s) {
1403
+ if (s.serviceName == 'Same Day')
1404
+ return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
1405
+ else
1406
+ return Object.assign(Object.assign({}, s), { totalPrice: 0 });
1407
+ });
1408
+ }
1409
+ if (_this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
1410
+ shippingMethods = shippingMethods.map(function (s) {
1411
+ return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
1412
+ });
1413
+ }
1414
+ return shippingMethods;
1415
+ }));
1416
+ };
1417
+ ShippingService.prototype.isFreeShippingBySubscription = function (shop, subscriptionPlan) {
1418
+ if (!subscriptionPlan)
1419
+ return false;
1420
+ if (shop == i3.Shops.MENSMARKET && subscriptionPlan == 'SELECT') {
1421
+ return true;
1422
+ }
1423
+ return false;
1424
+ };
1425
+ ShippingService.prototype.isHalfShippingBySubscription = function (shop, subscriptionPlan) {
1426
+ if (!subscriptionPlan)
1427
+ return false;
1428
+ if (shop == i3.Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
1429
+ return true;
1430
+ }
1431
+ return false;
1432
+ };
1433
+ ShippingService.prototype.isHolidays = function (datas) {
1434
+ var today = new Date();
1435
+ for (var key in datas) {
1436
+ var start = new Date(today.getFullYear() + "-" + datas[key].beginDate);
1437
+ var end = new Date(today.getFullYear() + "-" + datas[key].endDate);
1438
+ if (start > end)
1439
+ end = new Date(today.getFullYear() + 1 + "-" + datas[key].endDate);
1440
+ if (today >= start && today <= end)
1441
+ return true;
1442
+ }
1443
+ return false;
1444
+ };
1445
+ return ShippingService;
1446
+ }());
1447
+ ShippingService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService, deps: [{ token: i1__namespace$2.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1448
+ ShippingService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService });
1449
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService, decorators: [{
1450
+ type: i0.Injectable
1451
+ }], ctorParameters: function () {
1452
+ return [{ type: i1__namespace$2.HttpClient }, { type: undefined, decorators: [{
1453
+ type: i0.Inject,
1454
+ args: [BACKEND_URL]
1455
+ }] }, { type: HomeShopService }];
1493
1456
  } });
1494
1457
 
1495
- var AngularFirebaseAuthModule = /** @class */ (function () {
1496
- function AngularFirebaseAuthModule() {
1497
- }
1498
- AngularFirebaseAuthModule.initializeApp = function (options, nameOrConfig) {
1499
- return {
1500
- ngModule: AngularFirebaseAuthModule,
1501
- providers: [
1502
- { provide: fire.FIREBASE_OPTIONS, useValue: options },
1503
- { provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
1504
- ],
1505
- };
1506
- };
1507
- return AngularFirebaseAuthModule;
1508
- }());
1509
- AngularFirebaseAuthModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1510
- AngularFirebaseAuthModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, imports: [fire.AngularFireModule] });
1511
- AngularFirebaseAuthModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, providers: [
1512
- {
1513
- provide: 'Authentication',
1514
- useFactory: function (authenticationService, userRepository) {
1515
- return new i3.Authentication(authenticationService, userRepository);
1516
- },
1517
- deps: ['AuthenticationService', 'UserRepository'],
1518
- },
1519
- {
1520
- provide: 'AuthenticationService',
1521
- useFactory: function (angularFireAuth) {
1522
- return new i3.AuthenticationFirebaseAuthService(angularFireAuth);
1523
- },
1524
- deps: [i1.AngularFireAuth],
1525
- },
1526
- {
1527
- provide: 'Register',
1528
- useFactory: function (registerService, userRepository) {
1529
- return new i3.Register(registerService, userRepository);
1530
- },
1531
- deps: ['RegisterService', 'UserRepository'],
1532
- },
1533
- {
1534
- provide: 'RegisterService',
1535
- useFactory: function (angularFireAuth) {
1536
- return new i3.RegisterFirebaseAuthService(angularFireAuth);
1537
- },
1538
- deps: [i1.AngularFireAuth],
1539
- },
1540
- {
1541
- provide: 'SignOut',
1542
- useFactory: function (authenticationService) {
1543
- return new i3.SignOut(authenticationService);
1544
- },
1545
- deps: ['AuthenticationService'],
1546
- },
1547
- {
1548
- provide: 'RecoveryPassword',
1549
- useFactory: function (authenticationService) {
1550
- return new i3.RecoveryPassword(authenticationService);
1551
- },
1552
- deps: ['AuthenticationService'],
1553
- },
1554
- ], imports: [[fire.AngularFireModule]] });
1555
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, decorators: [{
1556
- type: i0.NgModule,
1557
- args: [{
1558
- imports: [fire.AngularFireModule],
1559
- providers: [
1560
- {
1561
- provide: 'Authentication',
1562
- useFactory: function (authenticationService, userRepository) {
1563
- return new i3.Authentication(authenticationService, userRepository);
1564
- },
1565
- deps: ['AuthenticationService', 'UserRepository'],
1566
- },
1567
- {
1568
- provide: 'AuthenticationService',
1569
- useFactory: function (angularFireAuth) {
1570
- return new i3.AuthenticationFirebaseAuthService(angularFireAuth);
1571
- },
1572
- deps: [i1.AngularFireAuth],
1573
- },
1574
- {
1575
- provide: 'Register',
1576
- useFactory: function (registerService, userRepository) {
1577
- return new i3.Register(registerService, userRepository);
1578
- },
1579
- deps: ['RegisterService', 'UserRepository'],
1580
- },
1581
- {
1582
- provide: 'RegisterService',
1583
- useFactory: function (angularFireAuth) {
1584
- return new i3.RegisterFirebaseAuthService(angularFireAuth);
1585
- },
1586
- deps: [i1.AngularFireAuth],
1587
- },
1588
- {
1589
- provide: 'SignOut',
1590
- useFactory: function (authenticationService) {
1591
- return new i3.SignOut(authenticationService);
1592
- },
1593
- deps: ['AuthenticationService'],
1594
- },
1595
- {
1596
- provide: 'RecoveryPassword',
1597
- useFactory: function (authenticationService) {
1598
- return new i3.RecoveryPassword(authenticationService);
1599
- },
1600
- deps: ['AuthenticationService'],
1601
- },
1602
- ],
1603
- }]
1458
+ var AngularFirebaseAuthModule = /** @class */ (function () {
1459
+ function AngularFirebaseAuthModule() {
1460
+ }
1461
+ AngularFirebaseAuthModule.initializeApp = function (options, nameOrConfig) {
1462
+ return {
1463
+ ngModule: AngularFirebaseAuthModule,
1464
+ providers: [
1465
+ { provide: fire.FIREBASE_OPTIONS, useValue: options },
1466
+ { provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
1467
+ ],
1468
+ };
1469
+ };
1470
+ return AngularFirebaseAuthModule;
1471
+ }());
1472
+ AngularFirebaseAuthModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1473
+ AngularFirebaseAuthModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, imports: [fire.AngularFireModule] });
1474
+ AngularFirebaseAuthModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, providers: [
1475
+ {
1476
+ provide: 'Authentication',
1477
+ useFactory: function (authenticationService, userRepository) {
1478
+ return new i3.Authentication(authenticationService, userRepository);
1479
+ },
1480
+ deps: ['AuthenticationService', 'UserRepository'],
1481
+ },
1482
+ {
1483
+ provide: 'AuthenticationService',
1484
+ useFactory: function (angularFireAuth) {
1485
+ return new i3.AuthenticationFirebaseAuthService(angularFireAuth);
1486
+ },
1487
+ deps: [i1.AngularFireAuth],
1488
+ },
1489
+ {
1490
+ provide: 'Register',
1491
+ useFactory: function (registerService, userRepository) {
1492
+ return new i3.Register(registerService, userRepository);
1493
+ },
1494
+ deps: ['RegisterService', 'UserRepository'],
1495
+ },
1496
+ {
1497
+ provide: 'RegisterService',
1498
+ useFactory: function (angularFireAuth) {
1499
+ return new i3.RegisterFirebaseAuthService(angularFireAuth);
1500
+ },
1501
+ deps: [i1.AngularFireAuth],
1502
+ },
1503
+ {
1504
+ provide: 'SignOut',
1505
+ useFactory: function (authenticationService) {
1506
+ return new i3.SignOut(authenticationService);
1507
+ },
1508
+ deps: ['AuthenticationService'],
1509
+ },
1510
+ {
1511
+ provide: 'RecoveryPassword',
1512
+ useFactory: function (authenticationService) {
1513
+ return new i3.RecoveryPassword(authenticationService);
1514
+ },
1515
+ deps: ['AuthenticationService'],
1516
+ },
1517
+ ], imports: [[fire.AngularFireModule]] });
1518
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, decorators: [{
1519
+ type: i0.NgModule,
1520
+ args: [{
1521
+ imports: [fire.AngularFireModule],
1522
+ providers: [
1523
+ {
1524
+ provide: 'Authentication',
1525
+ useFactory: function (authenticationService, userRepository) {
1526
+ return new i3.Authentication(authenticationService, userRepository);
1527
+ },
1528
+ deps: ['AuthenticationService', 'UserRepository'],
1529
+ },
1530
+ {
1531
+ provide: 'AuthenticationService',
1532
+ useFactory: function (angularFireAuth) {
1533
+ return new i3.AuthenticationFirebaseAuthService(angularFireAuth);
1534
+ },
1535
+ deps: [i1.AngularFireAuth],
1536
+ },
1537
+ {
1538
+ provide: 'Register',
1539
+ useFactory: function (registerService, userRepository) {
1540
+ return new i3.Register(registerService, userRepository);
1541
+ },
1542
+ deps: ['RegisterService', 'UserRepository'],
1543
+ },
1544
+ {
1545
+ provide: 'RegisterService',
1546
+ useFactory: function (angularFireAuth) {
1547
+ return new i3.RegisterFirebaseAuthService(angularFireAuth);
1548
+ },
1549
+ deps: [i1.AngularFireAuth],
1550
+ },
1551
+ {
1552
+ provide: 'SignOut',
1553
+ useFactory: function (authenticationService) {
1554
+ return new i3.SignOut(authenticationService);
1555
+ },
1556
+ deps: ['AuthenticationService'],
1557
+ },
1558
+ {
1559
+ provide: 'RecoveryPassword',
1560
+ useFactory: function (authenticationService) {
1561
+ return new i3.RecoveryPassword(authenticationService);
1562
+ },
1563
+ deps: ['AuthenticationService'],
1564
+ },
1565
+ ],
1566
+ }]
1604
1567
  }] });
1605
1568
 
1606
- var AngularElasticSeachModule = /** @class */ (function () {
1607
- function AngularElasticSeachModule() {
1608
- }
1609
- AngularElasticSeachModule.initializeApp = function (options) {
1610
- return {
1611
- ngModule: AngularElasticSeachModule,
1612
- providers: [{ provide: ES_CONFIG, useValue: options }],
1613
- };
1614
- };
1615
- return AngularElasticSeachModule;
1616
- }());
1617
- AngularElasticSeachModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1618
- AngularElasticSeachModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule });
1619
- AngularElasticSeachModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, providers: [
1620
- {
1621
- provide: i3.ProductsIndex,
1622
- useFactory: function (configuration) { return new i3.ProductsIndex(new i3.AxiosAdapter(configuration)); },
1623
- deps: [ES_CONFIG],
1624
- },
1625
- ] });
1626
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, decorators: [{
1627
- type: i0.NgModule,
1628
- args: [{
1629
- providers: [
1630
- {
1631
- provide: i3.ProductsIndex,
1632
- useFactory: function (configuration) { return new i3.ProductsIndex(new i3.AxiosAdapter(configuration)); },
1633
- deps: [ES_CONFIG],
1634
- },
1635
- ],
1636
- }]
1569
+ var AngularElasticSeachModule = /** @class */ (function () {
1570
+ function AngularElasticSeachModule() {
1571
+ }
1572
+ AngularElasticSeachModule.initializeApp = function (options) {
1573
+ return {
1574
+ ngModule: AngularElasticSeachModule,
1575
+ providers: [{ provide: ES_CONFIG, useValue: options }],
1576
+ };
1577
+ };
1578
+ return AngularElasticSeachModule;
1579
+ }());
1580
+ AngularElasticSeachModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1581
+ AngularElasticSeachModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule });
1582
+ AngularElasticSeachModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, providers: [
1583
+ {
1584
+ provide: i3.ProductsIndex,
1585
+ useFactory: function (configuration) { return new i3.ProductsIndex(new i3.AxiosAdapter(configuration)); },
1586
+ deps: [ES_CONFIG],
1587
+ },
1588
+ ] });
1589
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, decorators: [{
1590
+ type: i0.NgModule,
1591
+ args: [{
1592
+ providers: [
1593
+ {
1594
+ provide: i3.ProductsIndex,
1595
+ useFactory: function (configuration) { return new i3.ProductsIndex(new i3.AxiosAdapter(configuration)); },
1596
+ deps: [ES_CONFIG],
1597
+ },
1598
+ ],
1599
+ }]
1637
1600
  }] });
1638
1601
 
1639
- var AngularFirestoreModule = /** @class */ (function () {
1640
- function AngularFirestoreModule() {
1641
- }
1642
- AngularFirestoreModule.initializeApp = function (options, nameOrConfig) {
1643
- return {
1644
- ngModule: AngularFirestoreModule,
1645
- providers: [
1646
- { provide: fire.FIREBASE_OPTIONS, useValue: options.firebase },
1647
- { provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
1648
- { provide: ES_CONFIG, useValue: options.elasticSearch },
1649
- ],
1650
- };
1651
- };
1652
- return AngularFirestoreModule;
1653
- }());
1654
- AngularFirestoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1655
- AngularFirestoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, imports: [fire.AngularFireModule, AngularElasticSeachModule] });
1656
- AngularFirestoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, providers: [
1657
- {
1658
- provide: 'BeautyProfileRepository',
1659
- useFactory: function (firestore, userRepository) {
1660
- return new i3.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
1661
- },
1662
- deps: [i1$1.AngularFirestore, 'UserRepository'],
1663
- },
1664
- {
1665
- provide: 'Buy2WinRepository',
1666
- useFactory: function (firestore) {
1667
- return new i3.Buy2WinFirestoreRepository(firestore.firestore);
1668
- },
1669
- deps: [i1$1.AngularFirestore],
1670
- },
1671
- {
1672
- provide: i3.CategoryFirestoreRepository,
1673
- useFactory: function (firestore) {
1674
- return new i3.CategoryFirestoreRepository(firestore.firestore);
1675
- },
1676
- deps: [i1$1.AngularFirestore],
1677
- },
1678
- {
1679
- provide: 'CheckoutRepository',
1680
- useFactory: function (firestore) {
1681
- return new i3.CheckoutFirestoreRepository(firestore.firestore);
1682
- },
1683
- deps: [i1$1.AngularFirestore],
1684
- },
1685
- {
1686
- provide: 'CheckoutSubscriptionRepository',
1687
- useFactory: function (firestore) {
1688
- return new i3.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
1689
- },
1690
- deps: [i1$1.AngularFirestore],
1691
- },
1692
- {
1693
- provide: 'CouponRepository',
1694
- useFactory: function (firestore) {
1695
- return new i3.CouponFirestoreRepository(firestore.firestore);
1696
- },
1697
- deps: [i1$1.AngularFirestore],
1698
- },
1699
- {
1700
- provide: 'CampaignHashtagRepository',
1701
- useFactory: function (firestore) {
1702
- return new i3.CampaignHashtagFirestoreRepository(firestore.firestore);
1703
- },
1704
- deps: [i1$1.AngularFirestore],
1705
- },
1706
- {
1707
- provide: 'CampaignDashboardRepository',
1708
- useFactory: function (firestore) {
1709
- return new i3.CampaignDashboardFirestoreRepository(firestore.firestore);
1710
- },
1711
- deps: [i1$1.AngularFirestore],
1712
- },
1713
- {
1714
- provide: 'EditionRepository',
1715
- useFactory: function (firestore, subscriptionRepository) {
1716
- return new i3.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
1717
- },
1718
- deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1719
- },
1720
- {
1721
- provide: 'HomeRepository',
1722
- useFactory: function (firestore) {
1723
- return new i3.HomeFirestoreRepository(firestore.firestore);
1724
- },
1725
- deps: [i1$1.AngularFirestore],
1726
- },
1727
- {
1728
- provide: 'LeadRepository',
1729
- useFactory: function (firestore) {
1730
- return new i3.LeadFirestoreRepository(firestore.firestore);
1731
- },
1732
- deps: [i1$1.AngularFirestore],
1733
- },
1734
- {
1735
- provide: 'LegacyOrderRepository',
1736
- useFactory: function (firestore) {
1737
- return new i3.LegacyOrderFirestoreRepository(firestore.firestore);
1738
- },
1739
- deps: [i1$1.AngularFirestore],
1740
- },
1741
- {
1742
- provide: 'ShopMenuRepository',
1743
- useFactory: function (firestore) {
1744
- return new i3.ShopMenuFirestoreRepository(firestore.firestore);
1745
- },
1746
- deps: [i1$1.AngularFirestore],
1747
- },
1748
- {
1749
- provide: 'OrderRepository',
1750
- useFactory: function (firestore) {
1751
- return new i3.OrderFirestoreRepository(firestore.firestore);
1752
- },
1753
- deps: [i1$1.AngularFirestore],
1754
- },
1755
- {
1756
- provide: 'PaymentRepository',
1757
- useFactory: function (firestore) {
1758
- return new i3.PaymentFirestoreRepository(firestore.firestore);
1759
- },
1760
- deps: [i1$1.AngularFirestore],
1761
- },
1762
- {
1763
- provide: i3.ProductFirestoreRepository,
1764
- useFactory: function (firestore) {
1765
- return new i3.ProductFirestoreRepository(firestore.firestore);
1766
- },
1767
- deps: [i1$1.AngularFirestore],
1768
- },
1769
- {
1770
- provide: 'ShopSettingsRepository',
1771
- useFactory: function (firestore) {
1772
- return new i3.ShopSettingsFirestoreRepository(firestore.firestore);
1773
- },
1774
- deps: [i1$1.AngularFirestore],
1775
- },
1776
- {
1777
- provide: 'SubscriptionPaymentRepository',
1778
- useFactory: function (firestore, subscriptionRepository) {
1779
- return new i3.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1780
- },
1781
- deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1782
- },
1783
- {
1784
- provide: 'SubscriptionPlanRepository',
1785
- useFactory: function (firestore) {
1786
- return new i3.SubscriptionPlanFirestoreRepository(firestore.firestore);
1787
- },
1788
- deps: [i1$1.AngularFirestore],
1789
- },
1790
- {
1791
- provide: 'SubscriptionProductRepository',
1792
- useFactory: function (firestore) {
1793
- return new i3.SubscriptionProductFirestoreRepository(firestore.firestore);
1794
- },
1795
- deps: [i1$1.AngularFirestore],
1796
- },
1797
- {
1798
- provide: 'SubscriptionRepository',
1799
- useFactory: function (firestore) {
1800
- return new i3.SubscriptionFirestoreRepository(firestore.firestore);
1801
- },
1802
- deps: [i1$1.AngularFirestore],
1803
- },
1804
- {
1805
- provide: 'UserRepository',
1806
- useFactory: function (firestore) {
1807
- return new i3.UserFirestoreRepository(firestore.firestore);
1808
- },
1809
- deps: [i1$1.AngularFirestore],
1810
- },
1811
- {
1812
- provide: 'UserAddressRepository',
1813
- useFactory: function (firestore, userRepository) {
1814
- return new i3.UserAddressFirestoreRepository(firestore.firestore, userRepository);
1815
- },
1816
- deps: [i1$1.AngularFirestore, 'UserRepository'],
1817
- },
1818
- {
1819
- provide: 'UserPaymentMethodRepository',
1820
- useFactory: function (firestore, userRepository) {
1821
- return new i3.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1822
- },
1823
- deps: [i1$1.AngularFirestore, 'UserRepository'],
1824
- },
1825
- {
1826
- provide: i3.ProductVariantFirestoreRepository,
1827
- useFactory: function (firestore, productRepository) {
1828
- return new i3.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1829
- },
1830
- deps: [i1$1.AngularFirestore, i3.ProductFirestoreRepository],
1831
- },
1832
- {
1833
- provide: i0.APP_INITIALIZER,
1834
- useFactory: function (firestore) { return function () { return firestore.firestore.settings({ ignoreUndefinedProperties: true }); }; },
1835
- deps: [i1$1.AngularFirestore],
1836
- multi: true,
1837
- },
1838
- ], imports: [[fire.AngularFireModule, AngularElasticSeachModule]] });
1839
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, decorators: [{
1840
- type: i0.NgModule,
1841
- args: [{
1842
- imports: [fire.AngularFireModule, AngularElasticSeachModule],
1843
- providers: [
1844
- {
1845
- provide: 'BeautyProfileRepository',
1846
- useFactory: function (firestore, userRepository) {
1847
- return new i3.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
1848
- },
1849
- deps: [i1$1.AngularFirestore, 'UserRepository'],
1850
- },
1851
- {
1852
- provide: 'Buy2WinRepository',
1853
- useFactory: function (firestore) {
1854
- return new i3.Buy2WinFirestoreRepository(firestore.firestore);
1855
- },
1856
- deps: [i1$1.AngularFirestore],
1857
- },
1858
- {
1859
- provide: i3.CategoryFirestoreRepository,
1860
- useFactory: function (firestore) {
1861
- return new i3.CategoryFirestoreRepository(firestore.firestore);
1862
- },
1863
- deps: [i1$1.AngularFirestore],
1864
- },
1865
- {
1866
- provide: 'CheckoutRepository',
1867
- useFactory: function (firestore) {
1868
- return new i3.CheckoutFirestoreRepository(firestore.firestore);
1869
- },
1870
- deps: [i1$1.AngularFirestore],
1871
- },
1872
- {
1873
- provide: 'CheckoutSubscriptionRepository',
1874
- useFactory: function (firestore) {
1875
- return new i3.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
1876
- },
1877
- deps: [i1$1.AngularFirestore],
1878
- },
1879
- {
1880
- provide: 'CouponRepository',
1881
- useFactory: function (firestore) {
1882
- return new i3.CouponFirestoreRepository(firestore.firestore);
1883
- },
1884
- deps: [i1$1.AngularFirestore],
1885
- },
1886
- {
1887
- provide: 'CampaignHashtagRepository',
1888
- useFactory: function (firestore) {
1889
- return new i3.CampaignHashtagFirestoreRepository(firestore.firestore);
1890
- },
1891
- deps: [i1$1.AngularFirestore],
1892
- },
1893
- {
1894
- provide: 'CampaignDashboardRepository',
1895
- useFactory: function (firestore) {
1896
- return new i3.CampaignDashboardFirestoreRepository(firestore.firestore);
1897
- },
1898
- deps: [i1$1.AngularFirestore],
1899
- },
1900
- {
1901
- provide: 'EditionRepository',
1902
- useFactory: function (firestore, subscriptionRepository) {
1903
- return new i3.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
1904
- },
1905
- deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1906
- },
1907
- {
1908
- provide: 'HomeRepository',
1909
- useFactory: function (firestore) {
1910
- return new i3.HomeFirestoreRepository(firestore.firestore);
1911
- },
1912
- deps: [i1$1.AngularFirestore],
1913
- },
1914
- {
1915
- provide: 'LeadRepository',
1916
- useFactory: function (firestore) {
1917
- return new i3.LeadFirestoreRepository(firestore.firestore);
1918
- },
1919
- deps: [i1$1.AngularFirestore],
1920
- },
1921
- {
1922
- provide: 'LegacyOrderRepository',
1923
- useFactory: function (firestore) {
1924
- return new i3.LegacyOrderFirestoreRepository(firestore.firestore);
1925
- },
1926
- deps: [i1$1.AngularFirestore],
1927
- },
1928
- {
1929
- provide: 'ShopMenuRepository',
1930
- useFactory: function (firestore) {
1931
- return new i3.ShopMenuFirestoreRepository(firestore.firestore);
1932
- },
1933
- deps: [i1$1.AngularFirestore],
1934
- },
1935
- {
1936
- provide: 'OrderRepository',
1937
- useFactory: function (firestore) {
1938
- return new i3.OrderFirestoreRepository(firestore.firestore);
1939
- },
1940
- deps: [i1$1.AngularFirestore],
1941
- },
1942
- {
1943
- provide: 'PaymentRepository',
1944
- useFactory: function (firestore) {
1945
- return new i3.PaymentFirestoreRepository(firestore.firestore);
1946
- },
1947
- deps: [i1$1.AngularFirestore],
1948
- },
1949
- {
1950
- provide: i3.ProductFirestoreRepository,
1951
- useFactory: function (firestore) {
1952
- return new i3.ProductFirestoreRepository(firestore.firestore);
1953
- },
1954
- deps: [i1$1.AngularFirestore],
1955
- },
1956
- {
1957
- provide: 'ShopSettingsRepository',
1958
- useFactory: function (firestore) {
1959
- return new i3.ShopSettingsFirestoreRepository(firestore.firestore);
1960
- },
1961
- deps: [i1$1.AngularFirestore],
1962
- },
1963
- {
1964
- provide: 'SubscriptionPaymentRepository',
1965
- useFactory: function (firestore, subscriptionRepository) {
1966
- return new i3.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1967
- },
1968
- deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1969
- },
1970
- {
1971
- provide: 'SubscriptionPlanRepository',
1972
- useFactory: function (firestore) {
1973
- return new i3.SubscriptionPlanFirestoreRepository(firestore.firestore);
1974
- },
1975
- deps: [i1$1.AngularFirestore],
1976
- },
1977
- {
1978
- provide: 'SubscriptionProductRepository',
1979
- useFactory: function (firestore) {
1980
- return new i3.SubscriptionProductFirestoreRepository(firestore.firestore);
1981
- },
1982
- deps: [i1$1.AngularFirestore],
1983
- },
1984
- {
1985
- provide: 'SubscriptionRepository',
1986
- useFactory: function (firestore) {
1987
- return new i3.SubscriptionFirestoreRepository(firestore.firestore);
1988
- },
1989
- deps: [i1$1.AngularFirestore],
1990
- },
1991
- {
1992
- provide: 'UserRepository',
1993
- useFactory: function (firestore) {
1994
- return new i3.UserFirestoreRepository(firestore.firestore);
1995
- },
1996
- deps: [i1$1.AngularFirestore],
1997
- },
1998
- {
1999
- provide: 'UserAddressRepository',
2000
- useFactory: function (firestore, userRepository) {
2001
- return new i3.UserAddressFirestoreRepository(firestore.firestore, userRepository);
2002
- },
2003
- deps: [i1$1.AngularFirestore, 'UserRepository'],
2004
- },
2005
- {
2006
- provide: 'UserPaymentMethodRepository',
2007
- useFactory: function (firestore, userRepository) {
2008
- return new i3.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
2009
- },
2010
- deps: [i1$1.AngularFirestore, 'UserRepository'],
2011
- },
2012
- {
2013
- provide: i3.ProductVariantFirestoreRepository,
2014
- useFactory: function (firestore, productRepository) {
2015
- return new i3.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
2016
- },
2017
- deps: [i1$1.AngularFirestore, i3.ProductFirestoreRepository],
2018
- },
2019
- {
2020
- provide: i0.APP_INITIALIZER,
2021
- useFactory: function (firestore) { return function () { return firestore.firestore.settings({ ignoreUndefinedProperties: true }); }; },
2022
- deps: [i1$1.AngularFirestore],
2023
- multi: true,
2024
- },
2025
- ],
2026
- }]
1602
+ var AngularFirestoreModule = /** @class */ (function () {
1603
+ function AngularFirestoreModule() {
1604
+ }
1605
+ AngularFirestoreModule.initializeApp = function (options, nameOrConfig) {
1606
+ return {
1607
+ ngModule: AngularFirestoreModule,
1608
+ providers: [
1609
+ { provide: fire.FIREBASE_OPTIONS, useValue: options.firebase },
1610
+ { provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
1611
+ { provide: ES_CONFIG, useValue: options.elasticSearch },
1612
+ ],
1613
+ };
1614
+ };
1615
+ return AngularFirestoreModule;
1616
+ }());
1617
+ AngularFirestoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1618
+ AngularFirestoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, imports: [fire.AngularFireModule, AngularElasticSeachModule] });
1619
+ AngularFirestoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, providers: [
1620
+ {
1621
+ provide: 'BeautyProfileRepository',
1622
+ useFactory: function (firestore, userRepository) {
1623
+ return new i3.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
1624
+ },
1625
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
1626
+ },
1627
+ {
1628
+ provide: 'Buy2WinRepository',
1629
+ useFactory: function (firestore) {
1630
+ return new i3.Buy2WinFirestoreRepository(firestore.firestore);
1631
+ },
1632
+ deps: [i1$1.AngularFirestore],
1633
+ },
1634
+ {
1635
+ provide: i3.CategoryFirestoreRepository,
1636
+ useFactory: function (firestore) {
1637
+ return new i3.CategoryFirestoreRepository(firestore.firestore);
1638
+ },
1639
+ deps: [i1$1.AngularFirestore],
1640
+ },
1641
+ {
1642
+ provide: 'CheckoutRepository',
1643
+ useFactory: function (firestore) {
1644
+ return new i3.CheckoutFirestoreRepository(firestore.firestore);
1645
+ },
1646
+ deps: [i1$1.AngularFirestore],
1647
+ },
1648
+ {
1649
+ provide: 'CheckoutSubscriptionRepository',
1650
+ useFactory: function (firestore) {
1651
+ return new i3.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
1652
+ },
1653
+ deps: [i1$1.AngularFirestore],
1654
+ },
1655
+ {
1656
+ provide: 'CouponRepository',
1657
+ useFactory: function (firestore) {
1658
+ return new i3.CouponFirestoreRepository(firestore.firestore);
1659
+ },
1660
+ deps: [i1$1.AngularFirestore],
1661
+ },
1662
+ {
1663
+ provide: 'CampaignHashtagRepository',
1664
+ useFactory: function (firestore) {
1665
+ return new i3.CampaignHashtagFirestoreRepository(firestore.firestore);
1666
+ },
1667
+ deps: [i1$1.AngularFirestore],
1668
+ },
1669
+ {
1670
+ provide: 'CampaignDashboardRepository',
1671
+ useFactory: function (firestore) {
1672
+ return new i3.CampaignDashboardFirestoreRepository(firestore.firestore);
1673
+ },
1674
+ deps: [i1$1.AngularFirestore],
1675
+ },
1676
+ {
1677
+ provide: 'EditionRepository',
1678
+ useFactory: function (firestore, subscriptionRepository) {
1679
+ return new i3.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
1680
+ },
1681
+ deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1682
+ },
1683
+ {
1684
+ provide: 'HomeRepository',
1685
+ useFactory: function (firestore) {
1686
+ return new i3.HomeFirestoreRepository(firestore.firestore);
1687
+ },
1688
+ deps: [i1$1.AngularFirestore],
1689
+ },
1690
+ {
1691
+ provide: 'LeadRepository',
1692
+ useFactory: function (firestore) {
1693
+ return new i3.LeadFirestoreRepository(firestore.firestore);
1694
+ },
1695
+ deps: [i1$1.AngularFirestore],
1696
+ },
1697
+ {
1698
+ provide: 'LegacyOrderRepository',
1699
+ useFactory: function (firestore) {
1700
+ return new i3.LegacyOrderFirestoreRepository(firestore.firestore);
1701
+ },
1702
+ deps: [i1$1.AngularFirestore],
1703
+ },
1704
+ {
1705
+ provide: 'ShopMenuRepository',
1706
+ useFactory: function (firestore) {
1707
+ return new i3.ShopMenuFirestoreRepository(firestore.firestore);
1708
+ },
1709
+ deps: [i1$1.AngularFirestore],
1710
+ },
1711
+ {
1712
+ provide: 'OrderRepository',
1713
+ useFactory: function (firestore) {
1714
+ return new i3.OrderFirestoreRepository(firestore.firestore);
1715
+ },
1716
+ deps: [i1$1.AngularFirestore],
1717
+ },
1718
+ {
1719
+ provide: 'PaymentRepository',
1720
+ useFactory: function (firestore) {
1721
+ return new i3.PaymentFirestoreRepository(firestore.firestore);
1722
+ },
1723
+ deps: [i1$1.AngularFirestore],
1724
+ },
1725
+ {
1726
+ provide: i3.ProductFirestoreRepository,
1727
+ useFactory: function (firestore) {
1728
+ return new i3.ProductFirestoreRepository(firestore.firestore);
1729
+ },
1730
+ deps: [i1$1.AngularFirestore],
1731
+ },
1732
+ {
1733
+ provide: 'ShopSettingsRepository',
1734
+ useFactory: function (firestore) {
1735
+ return new i3.ShopSettingsFirestoreRepository(firestore.firestore);
1736
+ },
1737
+ deps: [i1$1.AngularFirestore],
1738
+ },
1739
+ {
1740
+ provide: 'SubscriptionPaymentRepository',
1741
+ useFactory: function (firestore, subscriptionRepository) {
1742
+ return new i3.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1743
+ },
1744
+ deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1745
+ },
1746
+ {
1747
+ provide: 'SubscriptionPlanRepository',
1748
+ useFactory: function (firestore) {
1749
+ return new i3.SubscriptionPlanFirestoreRepository(firestore.firestore);
1750
+ },
1751
+ deps: [i1$1.AngularFirestore],
1752
+ },
1753
+ {
1754
+ provide: 'SubscriptionProductRepository',
1755
+ useFactory: function (firestore) {
1756
+ return new i3.SubscriptionProductFirestoreRepository(firestore.firestore);
1757
+ },
1758
+ deps: [i1$1.AngularFirestore],
1759
+ },
1760
+ {
1761
+ provide: 'SubscriptionRepository',
1762
+ useFactory: function (firestore) {
1763
+ return new i3.SubscriptionFirestoreRepository(firestore.firestore);
1764
+ },
1765
+ deps: [i1$1.AngularFirestore],
1766
+ },
1767
+ {
1768
+ provide: 'UserRepository',
1769
+ useFactory: function (firestore) {
1770
+ return new i3.UserFirestoreRepository(firestore.firestore);
1771
+ },
1772
+ deps: [i1$1.AngularFirestore],
1773
+ },
1774
+ {
1775
+ provide: 'UserAddressRepository',
1776
+ useFactory: function (firestore, userRepository) {
1777
+ return new i3.UserAddressFirestoreRepository(firestore.firestore, userRepository);
1778
+ },
1779
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
1780
+ },
1781
+ {
1782
+ provide: 'UserPaymentMethodRepository',
1783
+ useFactory: function (firestore, userRepository) {
1784
+ return new i3.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1785
+ },
1786
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
1787
+ },
1788
+ {
1789
+ provide: i3.ProductVariantFirestoreRepository,
1790
+ useFactory: function (firestore, productRepository) {
1791
+ return new i3.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1792
+ },
1793
+ deps: [i1$1.AngularFirestore, i3.ProductFirestoreRepository],
1794
+ },
1795
+ {
1796
+ provide: i0.APP_INITIALIZER,
1797
+ useFactory: function (firestore) { return function () { return firestore.firestore.settings({ ignoreUndefinedProperties: true }); }; },
1798
+ deps: [i1$1.AngularFirestore],
1799
+ multi: true,
1800
+ },
1801
+ ], imports: [[fire.AngularFireModule, AngularElasticSeachModule]] });
1802
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, decorators: [{
1803
+ type: i0.NgModule,
1804
+ args: [{
1805
+ imports: [fire.AngularFireModule, AngularElasticSeachModule],
1806
+ providers: [
1807
+ {
1808
+ provide: 'BeautyProfileRepository',
1809
+ useFactory: function (firestore, userRepository) {
1810
+ return new i3.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
1811
+ },
1812
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
1813
+ },
1814
+ {
1815
+ provide: 'Buy2WinRepository',
1816
+ useFactory: function (firestore) {
1817
+ return new i3.Buy2WinFirestoreRepository(firestore.firestore);
1818
+ },
1819
+ deps: [i1$1.AngularFirestore],
1820
+ },
1821
+ {
1822
+ provide: i3.CategoryFirestoreRepository,
1823
+ useFactory: function (firestore) {
1824
+ return new i3.CategoryFirestoreRepository(firestore.firestore);
1825
+ },
1826
+ deps: [i1$1.AngularFirestore],
1827
+ },
1828
+ {
1829
+ provide: 'CheckoutRepository',
1830
+ useFactory: function (firestore) {
1831
+ return new i3.CheckoutFirestoreRepository(firestore.firestore);
1832
+ },
1833
+ deps: [i1$1.AngularFirestore],
1834
+ },
1835
+ {
1836
+ provide: 'CheckoutSubscriptionRepository',
1837
+ useFactory: function (firestore) {
1838
+ return new i3.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
1839
+ },
1840
+ deps: [i1$1.AngularFirestore],
1841
+ },
1842
+ {
1843
+ provide: 'CouponRepository',
1844
+ useFactory: function (firestore) {
1845
+ return new i3.CouponFirestoreRepository(firestore.firestore);
1846
+ },
1847
+ deps: [i1$1.AngularFirestore],
1848
+ },
1849
+ {
1850
+ provide: 'CampaignHashtagRepository',
1851
+ useFactory: function (firestore) {
1852
+ return new i3.CampaignHashtagFirestoreRepository(firestore.firestore);
1853
+ },
1854
+ deps: [i1$1.AngularFirestore],
1855
+ },
1856
+ {
1857
+ provide: 'CampaignDashboardRepository',
1858
+ useFactory: function (firestore) {
1859
+ return new i3.CampaignDashboardFirestoreRepository(firestore.firestore);
1860
+ },
1861
+ deps: [i1$1.AngularFirestore],
1862
+ },
1863
+ {
1864
+ provide: 'EditionRepository',
1865
+ useFactory: function (firestore, subscriptionRepository) {
1866
+ return new i3.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
1867
+ },
1868
+ deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1869
+ },
1870
+ {
1871
+ provide: 'HomeRepository',
1872
+ useFactory: function (firestore) {
1873
+ return new i3.HomeFirestoreRepository(firestore.firestore);
1874
+ },
1875
+ deps: [i1$1.AngularFirestore],
1876
+ },
1877
+ {
1878
+ provide: 'LeadRepository',
1879
+ useFactory: function (firestore) {
1880
+ return new i3.LeadFirestoreRepository(firestore.firestore);
1881
+ },
1882
+ deps: [i1$1.AngularFirestore],
1883
+ },
1884
+ {
1885
+ provide: 'LegacyOrderRepository',
1886
+ useFactory: function (firestore) {
1887
+ return new i3.LegacyOrderFirestoreRepository(firestore.firestore);
1888
+ },
1889
+ deps: [i1$1.AngularFirestore],
1890
+ },
1891
+ {
1892
+ provide: 'ShopMenuRepository',
1893
+ useFactory: function (firestore) {
1894
+ return new i3.ShopMenuFirestoreRepository(firestore.firestore);
1895
+ },
1896
+ deps: [i1$1.AngularFirestore],
1897
+ },
1898
+ {
1899
+ provide: 'OrderRepository',
1900
+ useFactory: function (firestore) {
1901
+ return new i3.OrderFirestoreRepository(firestore.firestore);
1902
+ },
1903
+ deps: [i1$1.AngularFirestore],
1904
+ },
1905
+ {
1906
+ provide: 'PaymentRepository',
1907
+ useFactory: function (firestore) {
1908
+ return new i3.PaymentFirestoreRepository(firestore.firestore);
1909
+ },
1910
+ deps: [i1$1.AngularFirestore],
1911
+ },
1912
+ {
1913
+ provide: i3.ProductFirestoreRepository,
1914
+ useFactory: function (firestore) {
1915
+ return new i3.ProductFirestoreRepository(firestore.firestore);
1916
+ },
1917
+ deps: [i1$1.AngularFirestore],
1918
+ },
1919
+ {
1920
+ provide: 'ShopSettingsRepository',
1921
+ useFactory: function (firestore) {
1922
+ return new i3.ShopSettingsFirestoreRepository(firestore.firestore);
1923
+ },
1924
+ deps: [i1$1.AngularFirestore],
1925
+ },
1926
+ {
1927
+ provide: 'SubscriptionPaymentRepository',
1928
+ useFactory: function (firestore, subscriptionRepository) {
1929
+ return new i3.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1930
+ },
1931
+ deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1932
+ },
1933
+ {
1934
+ provide: 'SubscriptionPlanRepository',
1935
+ useFactory: function (firestore) {
1936
+ return new i3.SubscriptionPlanFirestoreRepository(firestore.firestore);
1937
+ },
1938
+ deps: [i1$1.AngularFirestore],
1939
+ },
1940
+ {
1941
+ provide: 'SubscriptionProductRepository',
1942
+ useFactory: function (firestore) {
1943
+ return new i3.SubscriptionProductFirestoreRepository(firestore.firestore);
1944
+ },
1945
+ deps: [i1$1.AngularFirestore],
1946
+ },
1947
+ {
1948
+ provide: 'SubscriptionRepository',
1949
+ useFactory: function (firestore) {
1950
+ return new i3.SubscriptionFirestoreRepository(firestore.firestore);
1951
+ },
1952
+ deps: [i1$1.AngularFirestore],
1953
+ },
1954
+ {
1955
+ provide: 'UserRepository',
1956
+ useFactory: function (firestore) {
1957
+ return new i3.UserFirestoreRepository(firestore.firestore);
1958
+ },
1959
+ deps: [i1$1.AngularFirestore],
1960
+ },
1961
+ {
1962
+ provide: 'UserAddressRepository',
1963
+ useFactory: function (firestore, userRepository) {
1964
+ return new i3.UserAddressFirestoreRepository(firestore.firestore, userRepository);
1965
+ },
1966
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
1967
+ },
1968
+ {
1969
+ provide: 'UserPaymentMethodRepository',
1970
+ useFactory: function (firestore, userRepository) {
1971
+ return new i3.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1972
+ },
1973
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
1974
+ },
1975
+ {
1976
+ provide: i3.ProductVariantFirestoreRepository,
1977
+ useFactory: function (firestore, productRepository) {
1978
+ return new i3.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1979
+ },
1980
+ deps: [i1$1.AngularFirestore, i3.ProductFirestoreRepository],
1981
+ },
1982
+ {
1983
+ provide: i0.APP_INITIALIZER,
1984
+ useFactory: function (firestore) { return function () { return firestore.firestore.settings({ ignoreUndefinedProperties: true }); }; },
1985
+ deps: [i1$1.AngularFirestore],
1986
+ multi: true,
1987
+ },
1988
+ ],
1989
+ }]
2027
1990
  }] });
2028
1991
 
2029
- var AngularHasuraGraphQLModule = /** @class */ (function () {
2030
- function AngularHasuraGraphQLModule() {
2031
- }
2032
- AngularHasuraGraphQLModule.initializeApp = function (options) {
2033
- return {
2034
- ngModule: AngularHasuraGraphQLModule,
2035
- providers: [{ provide: HASURA_OPTIONS, useValue: options }],
2036
- };
2037
- };
2038
- return AngularHasuraGraphQLModule;
2039
- }());
2040
- AngularHasuraGraphQLModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
2041
- AngularHasuraGraphQLModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule });
2042
- AngularHasuraGraphQLModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule, providers: [
2043
- {
2044
- provide: 'CategoryRepository',
2045
- useExisting: i3.CategoryHasuraGraphQLRepository,
2046
- },
2047
- {
2048
- provide: i3.CategoryHasuraGraphQLRepository,
2049
- useFactory: function (options, productRepository, categoryFilterRepository) {
2050
- return new i3.CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
2051
- },
2052
- deps: [HASURA_OPTIONS, i3.ProductHasuraGraphQLRepository, i3.CategoryFilterHasuraGraphQLRepository],
2053
- },
2054
- {
2055
- provide: 'ProductRepository',
2056
- useExisting: i3.ProductHasuraGraphQLRepository,
2057
- },
2058
- {
2059
- provide: i3.ProductHasuraGraphQLRepository,
2060
- useFactory: function (options) {
2061
- return new i3.ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
2062
- },
2063
- deps: [HASURA_OPTIONS],
2064
- },
2065
- {
2066
- provide: 'VariantRepository',
2067
- useExisting: i3.VariantHasuraGraphQLRepository,
2068
- },
2069
- {
2070
- provide: i3.VariantHasuraGraphQLRepository,
2071
- useFactory: function (options) {
2072
- return new i3.VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
2073
- },
2074
- deps: [HASURA_OPTIONS],
2075
- },
2076
- {
2077
- provide: 'CategoryFilterRepository',
2078
- useExisting: i3.CategoryFilterHasuraGraphQLRepository,
2079
- },
2080
- {
2081
- provide: i3.CategoryFilterHasuraGraphQLRepository,
2082
- useFactory: function (options) {
2083
- return new i3.CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
2084
- },
2085
- deps: [HASURA_OPTIONS],
2086
- },
2087
- {
2088
- provide: 'FilterOptionRepository',
2089
- useExisting: i3.FilterOptionHasuraGraphQLRepository,
2090
- },
2091
- {
2092
- provide: i3.FilterOptionHasuraGraphQLRepository,
2093
- useFactory: function (options) {
2094
- return new i3.FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
2095
- },
2096
- deps: [HASURA_OPTIONS],
2097
- },
2098
- {
2099
- provide: 'FilterRepository',
2100
- useExisting: i3.FilterHasuraGraphQLRepository,
2101
- },
2102
- {
2103
- provide: i3.FilterHasuraGraphQLRepository,
2104
- useFactory: function (options, filterOptionRepository, categoryFilterRepository) {
2105
- return new i3.FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
2106
- },
2107
- deps: [HASURA_OPTIONS, i3.FilterOptionHasuraGraphQLRepository, i3.CategoryFilterHasuraGraphQLRepository],
2108
- },
2109
- ] });
2110
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule, decorators: [{
2111
- type: i0.NgModule,
2112
- args: [{
2113
- providers: [
2114
- {
2115
- provide: 'CategoryRepository',
2116
- useExisting: i3.CategoryHasuraGraphQLRepository,
2117
- },
2118
- {
2119
- provide: i3.CategoryHasuraGraphQLRepository,
2120
- useFactory: function (options, productRepository, categoryFilterRepository) {
2121
- return new i3.CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
2122
- },
2123
- deps: [HASURA_OPTIONS, i3.ProductHasuraGraphQLRepository, i3.CategoryFilterHasuraGraphQLRepository],
2124
- },
2125
- {
2126
- provide: 'ProductRepository',
2127
- useExisting: i3.ProductHasuraGraphQLRepository,
2128
- },
2129
- {
2130
- provide: i3.ProductHasuraGraphQLRepository,
2131
- useFactory: function (options) {
2132
- return new i3.ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
2133
- },
2134
- deps: [HASURA_OPTIONS],
2135
- },
2136
- {
2137
- provide: 'VariantRepository',
2138
- useExisting: i3.VariantHasuraGraphQLRepository,
2139
- },
2140
- {
2141
- provide: i3.VariantHasuraGraphQLRepository,
2142
- useFactory: function (options) {
2143
- return new i3.VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
2144
- },
2145
- deps: [HASURA_OPTIONS],
2146
- },
2147
- {
2148
- provide: 'CategoryFilterRepository',
2149
- useExisting: i3.CategoryFilterHasuraGraphQLRepository,
2150
- },
2151
- {
2152
- provide: i3.CategoryFilterHasuraGraphQLRepository,
2153
- useFactory: function (options) {
2154
- return new i3.CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
2155
- },
2156
- deps: [HASURA_OPTIONS],
2157
- },
2158
- {
2159
- provide: 'FilterOptionRepository',
2160
- useExisting: i3.FilterOptionHasuraGraphQLRepository,
2161
- },
2162
- {
2163
- provide: i3.FilterOptionHasuraGraphQLRepository,
2164
- useFactory: function (options) {
2165
- return new i3.FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
2166
- },
2167
- deps: [HASURA_OPTIONS],
2168
- },
2169
- {
2170
- provide: 'FilterRepository',
2171
- useExisting: i3.FilterHasuraGraphQLRepository,
2172
- },
2173
- {
2174
- provide: i3.FilterHasuraGraphQLRepository,
2175
- useFactory: function (options, filterOptionRepository, categoryFilterRepository) {
2176
- return new i3.FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
2177
- },
2178
- deps: [HASURA_OPTIONS, i3.FilterOptionHasuraGraphQLRepository, i3.CategoryFilterHasuraGraphQLRepository],
2179
- },
2180
- ],
2181
- }]
1992
+ var AngularHasuraGraphQLModule = /** @class */ (function () {
1993
+ function AngularHasuraGraphQLModule() {
1994
+ }
1995
+ AngularHasuraGraphQLModule.initializeApp = function (options) {
1996
+ return {
1997
+ ngModule: AngularHasuraGraphQLModule,
1998
+ providers: [{ provide: HASURA_OPTIONS, useValue: options }],
1999
+ };
2000
+ };
2001
+ return AngularHasuraGraphQLModule;
2002
+ }());
2003
+ AngularHasuraGraphQLModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
2004
+ AngularHasuraGraphQLModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule });
2005
+ AngularHasuraGraphQLModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule, providers: [
2006
+ {
2007
+ provide: 'CategoryRepository',
2008
+ useExisting: i3.CategoryHasuraGraphQLRepository,
2009
+ },
2010
+ {
2011
+ provide: i3.CategoryHasuraGraphQLRepository,
2012
+ useFactory: function (options, productRepository, categoryFilterRepository) {
2013
+ return new i3.CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
2014
+ },
2015
+ deps: [HASURA_OPTIONS, i3.ProductHasuraGraphQLRepository, i3.CategoryFilterHasuraGraphQLRepository],
2016
+ },
2017
+ {
2018
+ provide: 'ProductRepository',
2019
+ useExisting: i3.ProductHasuraGraphQLRepository,
2020
+ },
2021
+ {
2022
+ provide: i3.ProductHasuraGraphQLRepository,
2023
+ useFactory: function (options) {
2024
+ return new i3.ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
2025
+ },
2026
+ deps: [HASURA_OPTIONS],
2027
+ },
2028
+ {
2029
+ provide: 'VariantRepository',
2030
+ useExisting: i3.VariantHasuraGraphQLRepository,
2031
+ },
2032
+ {
2033
+ provide: i3.VariantHasuraGraphQLRepository,
2034
+ useFactory: function (options) {
2035
+ return new i3.VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
2036
+ },
2037
+ deps: [HASURA_OPTIONS],
2038
+ },
2039
+ {
2040
+ provide: 'CategoryFilterRepository',
2041
+ useExisting: i3.CategoryFilterHasuraGraphQLRepository,
2042
+ },
2043
+ {
2044
+ provide: i3.CategoryFilterHasuraGraphQLRepository,
2045
+ useFactory: function (options) {
2046
+ return new i3.CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
2047
+ },
2048
+ deps: [HASURA_OPTIONS],
2049
+ },
2050
+ {
2051
+ provide: 'FilterOptionRepository',
2052
+ useExisting: i3.FilterOptionHasuraGraphQLRepository,
2053
+ },
2054
+ {
2055
+ provide: i3.FilterOptionHasuraGraphQLRepository,
2056
+ useFactory: function (options) {
2057
+ return new i3.FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
2058
+ },
2059
+ deps: [HASURA_OPTIONS],
2060
+ },
2061
+ {
2062
+ provide: 'FilterRepository',
2063
+ useExisting: i3.FilterHasuraGraphQLRepository,
2064
+ },
2065
+ {
2066
+ provide: i3.FilterHasuraGraphQLRepository,
2067
+ useFactory: function (options, filterOptionRepository, categoryFilterRepository) {
2068
+ return new i3.FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
2069
+ },
2070
+ deps: [HASURA_OPTIONS, i3.FilterOptionHasuraGraphQLRepository, i3.CategoryFilterHasuraGraphQLRepository],
2071
+ },
2072
+ ] });
2073
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule, decorators: [{
2074
+ type: i0.NgModule,
2075
+ args: [{
2076
+ providers: [
2077
+ {
2078
+ provide: 'CategoryRepository',
2079
+ useExisting: i3.CategoryHasuraGraphQLRepository,
2080
+ },
2081
+ {
2082
+ provide: i3.CategoryHasuraGraphQLRepository,
2083
+ useFactory: function (options, productRepository, categoryFilterRepository) {
2084
+ return new i3.CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
2085
+ },
2086
+ deps: [HASURA_OPTIONS, i3.ProductHasuraGraphQLRepository, i3.CategoryFilterHasuraGraphQLRepository],
2087
+ },
2088
+ {
2089
+ provide: 'ProductRepository',
2090
+ useExisting: i3.ProductHasuraGraphQLRepository,
2091
+ },
2092
+ {
2093
+ provide: i3.ProductHasuraGraphQLRepository,
2094
+ useFactory: function (options) {
2095
+ return new i3.ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
2096
+ },
2097
+ deps: [HASURA_OPTIONS],
2098
+ },
2099
+ {
2100
+ provide: 'VariantRepository',
2101
+ useExisting: i3.VariantHasuraGraphQLRepository,
2102
+ },
2103
+ {
2104
+ provide: i3.VariantHasuraGraphQLRepository,
2105
+ useFactory: function (options) {
2106
+ return new i3.VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
2107
+ },
2108
+ deps: [HASURA_OPTIONS],
2109
+ },
2110
+ {
2111
+ provide: 'CategoryFilterRepository',
2112
+ useExisting: i3.CategoryFilterHasuraGraphQLRepository,
2113
+ },
2114
+ {
2115
+ provide: i3.CategoryFilterHasuraGraphQLRepository,
2116
+ useFactory: function (options) {
2117
+ return new i3.CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
2118
+ },
2119
+ deps: [HASURA_OPTIONS],
2120
+ },
2121
+ {
2122
+ provide: 'FilterOptionRepository',
2123
+ useExisting: i3.FilterOptionHasuraGraphQLRepository,
2124
+ },
2125
+ {
2126
+ provide: i3.FilterOptionHasuraGraphQLRepository,
2127
+ useFactory: function (options) {
2128
+ return new i3.FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
2129
+ },
2130
+ deps: [HASURA_OPTIONS],
2131
+ },
2132
+ {
2133
+ provide: 'FilterRepository',
2134
+ useExisting: i3.FilterHasuraGraphQLRepository,
2135
+ },
2136
+ {
2137
+ provide: i3.FilterHasuraGraphQLRepository,
2138
+ useFactory: function (options, filterOptionRepository, categoryFilterRepository) {
2139
+ return new i3.FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
2140
+ },
2141
+ deps: [HASURA_OPTIONS, i3.FilterOptionHasuraGraphQLRepository, i3.CategoryFilterHasuraGraphQLRepository],
2142
+ },
2143
+ ],
2144
+ }]
2182
2145
  }] });
2183
2146
 
2184
- var AngularConnectModule = /** @class */ (function () {
2185
- function AngularConnectModule() {
2186
- }
2187
- AngularConnectModule.initializeApp = function (defaultShop, options, nameOrConfig) {
2188
- return {
2189
- ngModule: AngularConnectModule,
2190
- providers: __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((i3.isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]))), __read((i3.isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: fire.FIREBASE_OPTIONS, useValue: options === null || options === void 0 ? void 0 : options.firebase }]))), __read((i3.isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig }]))), __read((i3.isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]))), __read((i3.isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]))), __read((i3.isNil(options === null || options === void 0 ? void 0 : options.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]))),
2191
- };
2192
- };
2193
- return AngularConnectModule;
2194
- }());
2195
- AngularConnectModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
2196
- AngularConnectModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, imports: [fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
2197
- AngularConnectModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, providers: [
2198
- AuthService,
2199
- CartService,
2200
- CheckoutService,
2201
- CheckoutSubscriptionService,
2202
- CouponService,
2203
- HomeShopService,
2204
- OrderService,
2205
- ShippingService,
2206
- ], imports: [[fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
2207
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, decorators: [{
2208
- type: i0.NgModule,
2209
- args: [{
2210
- imports: [fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule],
2211
- providers: [
2212
- AuthService,
2213
- CartService,
2214
- CheckoutService,
2215
- CheckoutSubscriptionService,
2216
- CouponService,
2217
- HomeShopService,
2218
- OrderService,
2219
- ShippingService,
2220
- ],
2221
- }]
2147
+ var AngularConnectModule = /** @class */ (function () {
2148
+ function AngularConnectModule() {
2149
+ }
2150
+ AngularConnectModule.initializeApp = function (defaultShop, options, nameOrConfig) {
2151
+ return {
2152
+ ngModule: AngularConnectModule,
2153
+ providers: __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((i3.isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]))), __read((i3.isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: fire.FIREBASE_OPTIONS, useValue: options === null || options === void 0 ? void 0 : options.firebase }]))), __read((i3.isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig }]))), __read((i3.isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]))), __read((i3.isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]))), __read((i3.isNil(options === null || options === void 0 ? void 0 : options.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]))),
2154
+ };
2155
+ };
2156
+ return AngularConnectModule;
2157
+ }());
2158
+ AngularConnectModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
2159
+ AngularConnectModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, imports: [fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
2160
+ AngularConnectModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, providers: [
2161
+ AuthService,
2162
+ CartService,
2163
+ CheckoutService,
2164
+ CheckoutSubscriptionService,
2165
+ CouponService,
2166
+ HomeShopService,
2167
+ OrderService,
2168
+ ShippingService,
2169
+ ], imports: [[fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
2170
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, decorators: [{
2171
+ type: i0.NgModule,
2172
+ args: [{
2173
+ imports: [fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule],
2174
+ providers: [
2175
+ AuthService,
2176
+ CartService,
2177
+ CheckoutService,
2178
+ CheckoutSubscriptionService,
2179
+ CouponService,
2180
+ HomeShopService,
2181
+ OrderService,
2182
+ ShippingService,
2183
+ ],
2184
+ }]
2222
2185
  }] });
2223
2186
 
2224
- /**
2225
- * Generated bundle index. Do not edit.
2187
+ /**
2188
+ * Generated bundle index. Do not edit.
2226
2189
  */
2227
2190
 
2228
2191
  exports.AngularConnectModule = AngularConnectModule;