@infrab4a/connect-angular 2.0.5-beta.1 → 2.0.6-beta.1

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