@infrab4a/connect-angular 0.14.2-beta.12 → 0.14.2-beta.3

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 (51) hide show
  1. package/angular-connect.module.d.ts +15 -15
  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/bundles/infrab4a-connect-angular.umd.js +1397 -1418
  6. package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
  7. package/consts/default-shop.const.d.ts +1 -1
  8. package/consts/es-config.const.d.ts +1 -1
  9. package/consts/index.d.ts +2 -2
  10. package/esm2015/angular-connect.module.js +47 -47
  11. package/esm2015/angular-elastic-search.module.js +38 -38
  12. package/esm2015/angular-firebase-auth.module.js +113 -113
  13. package/esm2015/angular-firestore.module.js +340 -340
  14. package/esm2015/consts/default-shop.const.js +2 -2
  15. package/esm2015/consts/es-config.const.js +2 -2
  16. package/esm2015/consts/index.js +3 -3
  17. package/esm2015/index.js +5 -5
  18. package/esm2015/infrab4a-connect-angular.js +4 -4
  19. package/esm2015/services/auth.service.js +42 -42
  20. package/esm2015/services/cart.service.js +150 -167
  21. package/esm2015/services/checkout-subscription.service.js +44 -68
  22. package/esm2015/services/checkout.service.js +68 -79
  23. package/esm2015/services/coupon.service.js +98 -70
  24. package/esm2015/services/errors/group-invalid-coupon.error.js +7 -7
  25. package/esm2015/services/errors/index.js +3 -3
  26. package/esm2015/services/errors/invalid-coupon.error.js +7 -7
  27. package/esm2015/services/home-shop.service.js +108 -108
  28. package/esm2015/services/index.js +8 -8
  29. package/esm2015/services/order.service.js +32 -32
  30. package/esm2015/services/types/index.js +3 -3
  31. package/esm2015/services/types/required-checkout-data.type.js +2 -2
  32. package/esm2015/services/types/required-checkout-subscription-data.type.js +2 -2
  33. package/fesm2015/infrab4a-connect-angular.js +988 -1011
  34. package/fesm2015/infrab4a-connect-angular.js.map +1 -1
  35. package/index.d.ts +4 -4
  36. package/infrab4a-connect-angular.d.ts +5 -5
  37. package/package.json +2 -2
  38. package/services/auth.service.d.ts +19 -19
  39. package/services/cart.service.d.ts +35 -41
  40. package/services/checkout-subscription.service.d.ts +16 -18
  41. package/services/checkout.service.d.ts +23 -22
  42. package/services/coupon.service.d.ts +17 -14
  43. package/services/errors/group-invalid-coupon.error.d.ts +5 -5
  44. package/services/errors/index.d.ts +2 -2
  45. package/services/errors/invalid-coupon.error.d.ts +4 -4
  46. package/services/home-shop.service.d.ts +24 -24
  47. package/services/index.d.ts +7 -7
  48. package/services/order.service.d.ts +13 -13
  49. package/services/types/index.d.ts +2 -2
  50. package/services/types/required-checkout-data.type.d.ts +2 -2
  51. package/services/types/required-checkout-subscription-data.type.d.ts +2 -2
@@ -30,1456 +30,1435 @@
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';
393
393
 
394
394
  var ES_CONFIG = 'ES_CONFIG';
395
395
 
396
- var InvalidCouponError = /** @class */ (function (_super) {
397
- __extends(InvalidCouponError, _super);
398
- function InvalidCouponError(message) {
399
- var _this = _super.call(this, message) || this;
400
- _this.message = message;
401
- return _this;
402
- }
403
- return InvalidCouponError;
396
+ var InvalidCouponError = /** @class */ (function (_super) {
397
+ __extends(InvalidCouponError, _super);
398
+ function InvalidCouponError(message) {
399
+ var _this = _super.call(this, message) || this;
400
+ _this.message = message;
401
+ return _this;
402
+ }
403
+ return InvalidCouponError;
404
404
  }(Error));
405
405
 
406
- var GroupInvalidCouponError = /** @class */ (function (_super) {
407
- __extends(GroupInvalidCouponError, _super);
408
- function GroupInvalidCouponError(errors) {
409
- var _this = _super.call(this, 'Many coupon errors throw') || this;
410
- _this.errors = errors;
411
- return _this;
412
- }
413
- return GroupInvalidCouponError;
406
+ var GroupInvalidCouponError = /** @class */ (function (_super) {
407
+ __extends(GroupInvalidCouponError, _super);
408
+ function GroupInvalidCouponError(errors) {
409
+ var _this = _super.call(this, 'Many coupon errors throw') || this;
410
+ _this.errors = errors;
411
+ return _this;
412
+ }
413
+ return GroupInvalidCouponError;
414
414
  }(Error));
415
415
 
416
- var CouponService = /** @class */ (function () {
417
- function CouponService(couponRepository, defaultShop) {
418
- var _this = this;
419
- this.couponRepository = couponRepository;
420
- this.defaultShop = defaultShop;
421
- this.emailIsFromCollaborator = function (userEmail) { return !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g)); };
422
- this.separateValidCoupons = function (coupons, userEmail) { return coupons
423
- .map(function (coupon) {
424
- try {
425
- if (!i2.FinancialCoupon.isFinancialCoupon(coupon))
426
- throw new InvalidCouponError('Coupon is not valid');
427
- if (_this.isValidCoupon(coupon, userEmail))
428
- return coupon;
429
- }
430
- catch (error) {
431
- return error;
432
- }
433
- })
434
- .reduce(function (current, coupon) { return (Object.assign(Object.assign({}, current), (i2.FinancialCoupon.isFinancialCoupon(coupon)
435
- ? { valids: __spreadArray(__spreadArray([], __read(current.valids)), [coupon]) }
436
- : { invalids: __spreadArray(__spreadArray([], __read(current.invalids)), [coupon]) }))); }, {
437
- valids: [],
438
- invalids: [],
439
- }); };
440
- }
441
- CouponService.prototype.checkCoupon = function (nickname, userEmail, checkoutType) {
442
- var _this = this;
443
- return rxjs.from(this.couponRepository.find([
444
- {
445
- nickname: { operator: i2.Where.EQUALS, value: nickname },
446
- shopAvailability: { operator: i2.Where.EQUALS, value: this.defaultShop },
447
- checkoutType: { operator: i2.Where.EQUALS, value: checkoutType },
448
- },
449
- ])).pipe(operators.concatMap(function (coupons) { return coupons.count < 1 ? rxjs.throwError(function () { return new i2.NotFoundError('Coupon not found'); }) : rxjs.of(coupons.data); }), operators.map(function (coupons) { return _this.separateValidCoupons(coupons, userEmail); }), operators.map(function (_a) {
450
- var valids = _a.valids, invalids = _a.invalids;
451
- if (!valids.length)
452
- throw new GroupInvalidCouponError(invalids);
453
- return valids;
454
- }));
455
- };
456
- CouponService.prototype.isValidCoupon = function (coupon, userEmail) {
457
- if (!this.emailIsFromCollaborator(userEmail) && coupon.exclusivityType === i2.Exclusivities.COLLABORATORS)
458
- throw new InvalidCouponError('User is not a collaborator');
459
- if (coupon.exclusivityType === i2.Exclusivities.SPECIFIC_USER && coupon.recipient !== userEmail)
460
- throw new InvalidCouponError('Coupon is not valid for user');
461
- if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) < new Date())
462
- throw new InvalidCouponError('Coupon is expired');
463
- return true;
464
- };
465
- return CouponService;
466
- }());
467
- CouponService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
468
- CouponService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CouponService, providedIn: 'root' });
469
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CouponService, decorators: [{
470
- type: i0.Injectable,
471
- args: [{
472
- providedIn: 'root',
473
- }]
474
- }], ctorParameters: function () {
475
- return [{ type: undefined, decorators: [{
476
- type: i0.Inject,
477
- args: ['CouponRepository']
478
- }] }, { type: i2__namespace.Shops, decorators: [{
479
- type: i0.Inject,
480
- args: [DEFAULT_SHOP]
481
- }] }];
416
+ var CouponService = /** @class */ (function () {
417
+ function CouponService(couponRepository, defaultShop, orderRepository) {
418
+ var _this = this;
419
+ this.couponRepository = couponRepository;
420
+ this.defaultShop = defaultShop;
421
+ this.orderRepository = orderRepository;
422
+ this.emailIsFromCollaborator = function (userEmail) { return !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g)); };
423
+ this.separateValidCoupons = function (coupons, userEmail) { return coupons
424
+ .map(function (coupon) {
425
+ try {
426
+ if (!(coupon instanceof i2.Coupon))
427
+ throw new InvalidCouponError('Coupon is not valid');
428
+ if (_this.isValidCoupon(coupon, userEmail))
429
+ return coupon;
430
+ }
431
+ catch (error) {
432
+ return error;
433
+ }
434
+ })
435
+ .reduce(function (current, coupon) { return (Object.assign(Object.assign({}, current), (coupon instanceof i2.Coupon
436
+ ? { valids: __spreadArray(__spreadArray([], __read(current.valids)), [coupon]) }
437
+ : { invalids: __spreadArray(__spreadArray([], __read(current.invalids)), [coupon]) }))); }, {
438
+ valids: [],
439
+ invalids: [],
440
+ }); };
441
+ }
442
+ CouponService.prototype.checkCoupon = function (nickname, userEmail, checkoutType, plan) {
443
+ var _this = this;
444
+ return rxjs.from(this.couponRepository.find([
445
+ {
446
+ nickname: { operator: i2.Where.EQUALS, value: nickname },
447
+ // shopAvailability: { operator: Where.EQUALS, value: this.defaultShop },
448
+ // checkoutType: { operator: Where.EQUALS, value: checkoutType },
449
+ },
450
+ ])).pipe(operators.concatMap(function (coupons) { return _this.checkCouponRules(coupons, checkoutType); }), operators.concatMap(function (coupons) { return _this.checkCouponUseLimit(coupons, userEmail); }), operators.map(function (coupon) { return _this.isValidCoupon(coupon, userEmail); }));
451
+ };
452
+ CouponService.prototype.isValidCoupon = function (coupon, userEmail) {
453
+ if (!this.emailIsFromCollaborator(userEmail) && coupon.exclusivityType === i2.Exclusivities.COLLABORATORS)
454
+ throw new InvalidCouponError('User is not a collaborator');
455
+ if (coupon.exclusivityType === i2.Exclusivities.SPECIFIC_USER && coupon.recipient !== userEmail)
456
+ throw new InvalidCouponError('Coupon is not valid for user');
457
+ if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) < new Date())
458
+ throw new InvalidCouponError('Coupon is expired');
459
+ return coupon;
460
+ };
461
+ CouponService.prototype.checkCouponRules = function (coupons, checkoutType, plan) {
462
+ var _this = this;
463
+ // coupons.count < 1 ? return throwError(() => new NotFoundError('Coupon not found')) : return of(coupons.data);
464
+ if (coupons.count < 1)
465
+ return rxjs.throwError(function () { return new i2.NotFoundError('Coupon not found'); });
466
+ var isInShop = coupons.data.find(function (c) { return c.shopAvailability == i2.Shops.ALL || c.shopAvailability == _this.defaultShop; });
467
+ if (!isInShop)
468
+ return rxjs.throwError(function () { return new i2.NotFoundError('Coupon not found'); });
469
+ var isCheckoutType = coupons.data.find(function (c) { return c.checkoutType == i2.CheckoutTypes.ALL || c.checkoutType == checkoutType; });
470
+ if (!isCheckoutType)
471
+ return rxjs.throwError(function () { return new i2.NotFoundError('Coupon not found'); });
472
+ if (checkoutType === i2.CheckoutTypes.ALL || checkoutType === i2.CheckoutTypes.SUBSCRIPTION) {
473
+ //regra
474
+ }
475
+ return coupons.data;
476
+ };
477
+ CouponService.prototype.checkCouponUseLimit = function (coupons, userEmail) {
478
+ return __awaiter(this, void 0, void 0, function () {
479
+ var coupon, orders, ordersUserCoupon;
480
+ return __generator(this, function (_a) {
481
+ switch (_a.label) {
482
+ case 0:
483
+ coupon = coupons.shift();
484
+ return [4 /*yield*/, this.orderRepository.find([{ coupon: { id: coupon.id } }])];
485
+ case 1:
486
+ orders = _a.sent();
487
+ ordersUserCoupon = orders.data.filter(function (o) { return o.user.email == userEmail; });
488
+ if (orders.data.length >= (coupon.useLimit || Infinity))
489
+ return [2 /*return*/, rxjs.throwError(function () { return new Error('Coupon já usou tudo'); })];
490
+ if (ordersUserCoupon.length >= coupon.useLimitPerUser)
491
+ return [2 /*return*/, rxjs.throwError(function () { return new Error('Usuário Coupon já usou tudo'); })];
492
+ return [2 /*return*/, coupon];
493
+ }
494
+ });
495
+ });
496
+ };
497
+ return CouponService;
498
+ }());
499
+ 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' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
500
+ CouponService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CouponService, providedIn: 'root' });
501
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CouponService, decorators: [{
502
+ type: i0.Injectable,
503
+ args: [{
504
+ providedIn: 'root',
505
+ }]
506
+ }], ctorParameters: function () {
507
+ return [{ type: undefined, decorators: [{
508
+ type: i0.Inject,
509
+ args: ['CouponRepository']
510
+ }] }, { type: i2__namespace.Shops, decorators: [{
511
+ type: i0.Inject,
512
+ args: [DEFAULT_SHOP]
513
+ }] }, { type: undefined, decorators: [{
514
+ type: i0.Inject,
515
+ args: ['OrderRepository']
516
+ }] }];
482
517
  } });
483
518
 
484
- var CheckoutService = /** @class */ (function () {
485
- function CheckoutService(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
486
- this.couponService = couponService;
487
- this.checkoutRepository = checkoutRepository;
488
- this.orderRepository = orderRepository;
489
- this.userRepository = userRepository;
490
- this.defaultShop = defaultShop;
491
- }
492
- CheckoutService.prototype.getCheckout = function (checkoutData) {
493
- var checkoutId = cookie__default["default"].get('checkoutId');
494
- if (!i2.isNil(checkoutId))
495
- return rxjs.from(this.checkoutRepository.get({ id: checkoutId }));
496
- return rxjs.from(this.createCheckout(checkoutData));
497
- };
498
- CheckoutService.prototype.getUserByCheckout = function (checkoutId) {
499
- var _this = this;
500
- 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'); }); }));
501
- };
502
- CheckoutService.prototype.updateCheckoutLineItems = function (checkout) {
503
- return rxjs.from(this.checkoutRepository.update(i2.Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
504
- };
505
- CheckoutService.prototype.updateCheckoutUser = function (checkout) {
506
- return rxjs.from(this.checkoutRepository.update(i2.Checkout.toInstance({ id: checkout.id, user: checkout.user })));
507
- };
508
- CheckoutService.prototype.clearCheckoutFromSession = function () {
509
- cookie__default["default"].remove('checkoutId');
510
- return rxjs.of();
511
- };
512
- CheckoutService.prototype.checkCoupon = function (nickname) {
513
- var _this = this;
514
- return this.getCheckout().pipe(operators.concatMap(function (checkout) {
515
- var _a;
516
- return _this.couponService.checkCoupon(nickname, (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email, i2.CheckoutTypes.ECOMMERCE).pipe(operators.concatMap(function (coupons) { return rxjs.of(coupons.shift()); }), operators.concatMap(function (coupon) {
517
- var _a, _b;
518
- return !!((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email)
519
- ? rxjs.from(_this.orderRepository.find([{ user: { email: (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email }, coupon: { id: coupon.id } }])).pipe(operators.concatMap(function (orders) {
520
- if (orders.data.length >= (coupon.useLimit || Infinity))
521
- return rxjs.throwError(function () { return new Error('Coupon is already applied'); });
522
- return rxjs.of(coupon);
523
- }))
524
- : rxjs.of(coupon);
525
- }));
526
- }));
527
- };
528
- CheckoutService.prototype.createCheckout = function (checkoutData) {
529
- return __awaiter(this, void 0, void 0, function () {
530
- var checkout;
531
- return __generator(this, function (_c) {
532
- switch (_c.label) {
533
- 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 }))];
534
- case 1:
535
- checkout = _c.sent();
536
- cookie__default["default"].set('checkoutId', checkout.id);
537
- return [2 /*return*/, checkout];
538
- }
539
- });
540
- });
541
- };
542
- return CheckoutService;
543
- }());
544
- 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 });
545
- CheckoutService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService });
546
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService, decorators: [{
547
- type: i0.Injectable
548
- }], ctorParameters: function () {
549
- return [{ type: CouponService }, { type: undefined, decorators: [{
550
- type: i0.Inject,
551
- args: ['CheckoutRepository']
552
- }] }, { type: undefined, decorators: [{
553
- type: i0.Inject,
554
- args: ['OrderRepository']
555
- }] }, { type: undefined, decorators: [{
556
- type: i0.Inject,
557
- args: ['UserRepository']
558
- }] }, { type: i2__namespace.Shops, decorators: [{
559
- type: i0.Inject,
560
- args: [DEFAULT_SHOP]
561
- }] }];
519
+ var CheckoutService = /** @class */ (function () {
520
+ function CheckoutService(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
521
+ this.couponService = couponService;
522
+ this.checkoutRepository = checkoutRepository;
523
+ this.orderRepository = orderRepository;
524
+ this.userRepository = userRepository;
525
+ this.defaultShop = defaultShop;
526
+ }
527
+ CheckoutService.prototype.getCheckout = function (checkoutData) {
528
+ var checkoutId = cookie__default["default"].get('checkoutId');
529
+ if (!i2.isNil(checkoutId))
530
+ return rxjs.from(this.checkoutRepository.get({ id: checkoutId }));
531
+ return rxjs.from(this.createCheckout(checkoutData));
532
+ };
533
+ CheckoutService.prototype.getUserByCheckout = function (checkoutId) {
534
+ var _this = this;
535
+ 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'); }); }));
536
+ };
537
+ CheckoutService.prototype.updateCheckoutLineItems = function (checkout) {
538
+ return rxjs.from(this.checkoutRepository.update(i2.Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
539
+ };
540
+ CheckoutService.prototype.updateCheckoutUser = function (checkout) {
541
+ return rxjs.from(this.checkoutRepository.update(i2.Checkout.toInstance({ id: checkout.id, user: checkout.user })));
542
+ };
543
+ CheckoutService.prototype.clearCheckoutFromSession = function () {
544
+ cookie__default["default"].remove('checkoutId');
545
+ return rxjs.of();
546
+ };
547
+ CheckoutService.prototype.applyCupon = function (coupon) { };
548
+ CheckoutService.prototype.checkCoupon = function (nickname) {
549
+ var _this = this;
550
+ return this.getCheckout().pipe(operators.concatMap(function (checkout) { var _a; return _this.couponService.checkCoupon(nickname, (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email, i2.CheckoutTypes.ECOMMERCE).pipe(); }));
551
+ };
552
+ CheckoutService.prototype.createCheckout = function (checkoutData) {
553
+ return __awaiter(this, void 0, void 0, function () {
554
+ var checkout;
555
+ return __generator(this, function (_b) {
556
+ switch (_b.label) {
557
+ 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 }))];
558
+ case 1:
559
+ checkout = _b.sent();
560
+ cookie__default["default"].set('checkoutId', checkout.id);
561
+ return [2 /*return*/, checkout];
562
+ }
563
+ });
564
+ });
565
+ };
566
+ return CheckoutService;
567
+ }());
568
+ 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 });
569
+ CheckoutService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService });
570
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService, decorators: [{
571
+ type: i0.Injectable
572
+ }], ctorParameters: function () {
573
+ return [{ type: CouponService }, { type: undefined, decorators: [{
574
+ type: i0.Inject,
575
+ args: ['CheckoutRepository']
576
+ }] }, { type: undefined, decorators: [{
577
+ type: i0.Inject,
578
+ args: ['OrderRepository']
579
+ }] }, { type: undefined, decorators: [{
580
+ type: i0.Inject,
581
+ args: ['UserRepository']
582
+ }] }, { type: i2__namespace.Shops, decorators: [{
583
+ type: i0.Inject,
584
+ args: [DEFAULT_SHOP]
585
+ }] }];
562
586
  } });
563
587
 
564
- var CartService = /** @class */ (function () {
565
- function CartService(authService, checkoutService, defaultShop) {
566
- var _this = this;
567
- this.authService = authService;
568
- this.checkoutService = checkoutService;
569
- this.defaultShop = defaultShop;
570
- this.cartSubject = new rxjs.Subject();
571
- this.updateLineItemInCart = function (lineItem, quantity, checkout) { return (i2.isNil(checkout) ? _this.checkoutService.getCheckout() : rxjs.of(checkout)).pipe(operators.concatMap(function (checkoutLoaded) {
572
- var _a;
573
- var items = [];
574
- var index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map(function (checkoutItem) { return checkoutItem.sku; }).indexOf(lineItem.sku);
575
- if (index > -1) {
576
- checkoutLoaded.lineItems[index].quantity += quantity;
577
- checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
578
- }
579
- else
580
- checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
581
- return _this.checkoutService
582
- .updateCheckoutLineItems(checkoutLoaded)
583
- .pipe(operators.map(function (updatedCheckout) { return _this.generateCartObject(updatedCheckout.lineItems); }));
584
- })); };
585
- this.generateCartObject = function (items) {
586
- var cart = {};
587
- items === null || items === void 0 ? void 0 : items.forEach(function (item) {
588
- var _a;
589
- 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) })));
590
- });
591
- return cart;
592
- };
593
- this.buildLineItem = function (_f) {
594
- var checkout = _f.checkout, item = _f.item, quantity = _f.quantity;
595
- var _a, _b, _c, _d, _e;
596
- 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;
597
- if (_this.checkMaxStock(item, quantity || 0))
598
- throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
599
- var image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
600
- var 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;
601
- var isGift = item.isGift || null;
602
- var pricePaid = _this.getProductPrice({
603
- product: item,
604
- shop: checkout.shop || _this.defaultShop,
605
- isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
606
- });
607
- return i2.LineItem.toInstance({
608
- id: id,
609
- name: name,
610
- EAN: EAN,
611
- brand: brand,
612
- slug: slug,
613
- sku: sku,
614
- stock: stock,
615
- price: price,
616
- image: image,
617
- weight: weight,
618
- quantity: (item.quantity || 0) + (quantity || 0),
619
- pricePaid: pricePaid,
620
- categories: categories,
621
- isGift: isGift,
622
- costPrice: item === null || item === void 0 ? void 0 : item.costPrice,
623
- });
624
- };
625
- this.getProductPrice = function (_f) {
626
- var product = _f.product, shop = _f.shop, isSubscriber = _f.isSubscriber;
627
- var info = product.getInfoByShop(shop);
628
- if (product.isGift)
629
- return 0;
630
- return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
631
- };
632
- this.checkMaxStock = function (item, quantity) {
633
- var _a;
634
- var maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
635
- var currentItemAmount = item.quantity || 0;
636
- return currentItemAmount + quantity > maxStock;
637
- };
638
- }
639
- CartService.prototype.addItem = function (item, quantity) {
640
- var _this = this;
641
- if (quantity === void 0) { quantity = 1; }
642
- return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) { return ({
643
- checkout: checkout,
644
- lineItem: _this.buildLineItem({ checkout: checkout, item: item, quantity: quantity || 1 }),
645
- }); }), operators.concatMap(function (_f) {
646
- var checkout = _f.checkout, lineItem = _f.lineItem;
647
- return _this.updateLineItemInCart(lineItem, quantity || 1, checkout);
648
- }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
649
- };
650
- CartService.prototype.decreaseItem = function (item) {
651
- var _this = this;
652
- return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
653
- var _a;
654
- var checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find(function (lineItem) { return lineItem.sku === item.sku; });
655
- if (!i2.isNil(checkoutItem))
656
- checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
657
- return checkout;
658
- }), 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); }));
659
- };
660
- CartService.prototype.getCart = function (checkout) {
661
- var _this = this;
662
- this.buildCartFromCheckout(checkout).subscribe(function (cart) { return _this.cartSubject.next(cart); });
663
- return this.cartSubject;
664
- };
665
- /**
666
- * @deprecated The method should not be used
667
- */
668
- CartService.prototype.getDiscount = function (coupon) {
669
- switch (coupon.type) {
670
- case i2.CouponTypes.FINANCIAL:
671
- return this.getFinancialDiscount(coupon);
672
- case i2.CouponTypes.PRODUCT:
673
- return function (subTotalPrice) { return subTotalPrice; };
674
- case i2.CouponTypes.GIFTCARD:
675
- return this.getFinancialDiscount(coupon);
676
- case i2.CouponTypes.VOUCHER:
677
- return function (subTotalPrice) { return subTotalPrice; };
678
- }
679
- };
680
- /**
681
- * @deprecated The method should not be used
682
- */
683
- CartService.prototype.getVariantPriceDiscount = function (item, shop) {
684
- 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); }));
685
- };
686
- CartService.prototype.removeItem = function (item) {
687
- var _this = this;
688
- return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
689
- var index = checkout.lineItems.findIndex(function (lineItem) { return lineItem.sku === item.sku; });
690
- if (index >= 0)
691
- checkout.lineItems.splice(index, 1);
692
- return checkout;
693
- }), 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); }));
694
- };
695
- CartService.prototype.updateUserCart = function (user) {
696
- var _this = this;
697
- 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) {
698
- var _a;
699
- 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 _this.buildLineItem({ checkout: checkout, item: item }); })) || [] })));
700
- }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
701
- };
702
- CartService.prototype.clearCart = function () {
703
- var _this = this;
704
- return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
705
- _this.checkoutService.clearCheckoutFromSession();
706
- return checkout;
707
- }), operators.concatMap(function (oldCheckout) { return _this.buildCartFromCheckout(oldCheckout); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
708
- };
709
- CartService.prototype.buildCartFromCheckout = function (checkoutData) {
710
- var _this = this;
711
- return this.checkoutService.getCheckout(checkoutData).pipe(operators.map(function (checkout) { return checkout.lineItems; }), operators.concatMap(function (lineItems) { return rxjs.of(_this.generateCartObject(lineItems)); }));
712
- };
713
- CartService.prototype.getFinancialDiscount = function (coupon) {
714
- return function (subTotalPrice) {
715
- if (i2.FinancialCoupon.isFinancialCoupon(coupon))
716
- switch (coupon.subtype) {
717
- case i2.CouponSubtypes.ABSOLUTE:
718
- return subTotalPrice - coupon.discount * 100;
719
- case i2.CouponSubtypes.PERCENTAGE:
720
- return subTotalPrice * (1 - coupon.discount / 100);
721
- }
722
- };
723
- };
724
- return CartService;
725
- }());
726
- 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 }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
727
- CartService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService });
728
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService, decorators: [{
729
- type: i0.Injectable
730
- }], ctorParameters: function () {
731
- return [{ type: AuthService }, { type: CheckoutService }, { type: i2__namespace.Shops, decorators: [{
732
- type: i0.Inject,
733
- args: [DEFAULT_SHOP]
734
- }] }];
588
+ var CartService = /** @class */ (function () {
589
+ function CartService(authService, checkoutService, defaultShop) {
590
+ var _this = this;
591
+ this.authService = authService;
592
+ this.checkoutService = checkoutService;
593
+ this.defaultShop = defaultShop;
594
+ this.cartSubject = new rxjs.Subject();
595
+ this.updateLineItemInCart = function (lineItem, quantity, checkout) { return (i2.isNil(checkout) ? _this.checkoutService.getCheckout() : rxjs.of(checkout)).pipe(operators.concatMap(function (checkoutLoaded) {
596
+ var _a;
597
+ var items = [];
598
+ var index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map(function (checkoutItem) { return checkoutItem.sku; }).indexOf(lineItem.sku);
599
+ if (index > -1) {
600
+ checkoutLoaded.lineItems[index].quantity += quantity;
601
+ checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
602
+ }
603
+ else
604
+ checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
605
+ return _this.checkoutService
606
+ .updateCheckoutLineItems(checkoutLoaded)
607
+ .pipe(operators.map(function (updatedCheckout) { return _this.generateCartObject(updatedCheckout.lineItems); }));
608
+ })); };
609
+ this.generateCartObject = function (items) {
610
+ var cart = {};
611
+ items === null || items === void 0 ? void 0 : items.forEach(function (item) {
612
+ var _a;
613
+ 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) })));
614
+ });
615
+ return cart;
616
+ };
617
+ this.buildLineItem = function (_f) {
618
+ var checkout = _f.checkout, item = _f.item, quantity = _f.quantity;
619
+ var _a, _b, _c, _d, _e;
620
+ 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;
621
+ if (_this.checkMaxStock(item, quantity || 0))
622
+ throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
623
+ var image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
624
+ var id = item.id, name = item.name, brand = item.brand, slug = item.slug, stock = item.stock, price = item.price, weight = item.weight, categories = item.categories, sku = item.sku;
625
+ var isGift = item.isGift || null;
626
+ var pricePaid = _this.getProductPrice({
627
+ product: item,
628
+ shop: checkout.shop || _this.defaultShop,
629
+ isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
630
+ });
631
+ return i2.LineItem.toInstance({
632
+ id: id,
633
+ name: name,
634
+ brand: brand,
635
+ slug: slug,
636
+ sku: sku,
637
+ stock: stock,
638
+ price: price,
639
+ image: image,
640
+ weight: weight,
641
+ quantity: (item.quantity || 0) + (quantity || 0),
642
+ pricePaid: pricePaid,
643
+ categories: categories,
644
+ isGift: isGift,
645
+ costPrice: item === null || item === void 0 ? void 0 : item.costPrice,
646
+ });
647
+ };
648
+ this.getProductPrice = function (_f) {
649
+ var product = _f.product, shop = _f.shop, isSubscriber = _f.isSubscriber;
650
+ var info = product.getInfoByShop(shop);
651
+ if (product.isGift)
652
+ return 0;
653
+ return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
654
+ };
655
+ this.checkMaxStock = function (item, quantity) {
656
+ var _a;
657
+ var maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
658
+ var currentItemAmount = item.quantity || 0;
659
+ return currentItemAmount + quantity > maxStock;
660
+ };
661
+ }
662
+ CartService.prototype.addItem = function (item, quantity) {
663
+ var _this = this;
664
+ if (quantity === void 0) { quantity = 1; }
665
+ return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) { return ({
666
+ checkout: checkout,
667
+ lineItem: _this.buildLineItem({ checkout: checkout, item: item, quantity: quantity || 1 }),
668
+ }); }), operators.concatMap(function (_f) {
669
+ var checkout = _f.checkout, lineItem = _f.lineItem;
670
+ return _this.updateLineItemInCart(lineItem, quantity || 1, checkout);
671
+ }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
672
+ };
673
+ CartService.prototype.decreaseItem = function (item) {
674
+ var _this = this;
675
+ return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
676
+ var _a;
677
+ var checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find(function (lineItem) { return lineItem.sku === item.sku; });
678
+ if (!i2.isNil(checkoutItem))
679
+ checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
680
+ return checkout;
681
+ }), 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); }));
682
+ };
683
+ CartService.prototype.getCart = function (checkout) {
684
+ var _this = this;
685
+ this.buildCartFromCheckout(checkout).subscribe(function (cart) { return _this.cartSubject.next(cart); });
686
+ return this.cartSubject;
687
+ };
688
+ /**
689
+ * @deprecated The method should not be used
690
+ */
691
+ CartService.prototype.getVariantPriceDiscount = function (item, shop) {
692
+ 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); }));
693
+ };
694
+ CartService.prototype.removeItem = function (item) {
695
+ var _this = this;
696
+ return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
697
+ var index = checkout.lineItems.findIndex(function (lineItem) { return lineItem.sku === item.sku; });
698
+ if (index >= 0)
699
+ checkout.lineItems.splice(index, 1);
700
+ return checkout;
701
+ }), 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); }));
702
+ };
703
+ CartService.prototype.updateUserCart = function (user) {
704
+ var _this = this;
705
+ 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) {
706
+ var _a;
707
+ 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 _this.buildLineItem({ checkout: checkout, item: item }); })) || [] })));
708
+ }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
709
+ };
710
+ CartService.prototype.clearCart = function () {
711
+ var _this = this;
712
+ return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
713
+ _this.checkoutService.clearCheckoutFromSession();
714
+ return checkout;
715
+ }), operators.concatMap(function (oldCheckout) { return _this.buildCartFromCheckout(oldCheckout); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
716
+ };
717
+ CartService.prototype.buildCartFromCheckout = function (checkoutData) {
718
+ var _this = this;
719
+ return this.checkoutService.getCheckout(checkoutData).pipe(operators.map(function (checkout) { return checkout.lineItems; }), operators.concatMap(function (lineItems) { return rxjs.of(_this.generateCartObject(lineItems)); }));
720
+ };
721
+ CartService.prototype.getSubTotalDiscount = function (coupon) {
722
+ return function (subTotalPrice) {
723
+ switch (coupon.type) {
724
+ case i2.CouponTypes.ABSOLUTE:
725
+ return subTotalPrice - coupon.discount;
726
+ case i2.CouponTypes.PERCENTAGE:
727
+ return subTotalPrice * (1 - coupon.discount / 100);
728
+ }
729
+ };
730
+ };
731
+ return CartService;
732
+ }());
733
+ 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 }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
734
+ CartService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService });
735
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService, decorators: [{
736
+ type: i0.Injectable
737
+ }], ctorParameters: function () {
738
+ return [{ type: AuthService }, { type: CheckoutService }, { type: i2__namespace.Shops, decorators: [{
739
+ type: i0.Inject,
740
+ args: [DEFAULT_SHOP]
741
+ }] }];
735
742
  } });
736
743
 
737
- var CheckoutSubscriptionService = /** @class */ (function () {
738
- function CheckoutSubscriptionService(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
739
- var _this = this;
740
- this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
741
- this.subscriptionRepository = subscriptionRepository;
742
- this.couponService = couponService;
743
- this.checkCouponsWithCheckout = function (coupons, checkout) { return rxjs.forkJoin(coupons.map(function (coupon) {
744
- var _a;
745
- return rxjs.from(_this.subscriptionRepository.find([{ user: { email: (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email }, coupon: { id: coupon.id } }])).pipe(operators.map(function (subscriptions) { return ({ coupon: coupon, subscriptions: subscriptions }); }));
746
- })).pipe(operators.map(function (results) { return results.map(function (_b) {
747
- var coupon = _b.coupon, subscriptions = _b.subscriptions;
748
- if (subscriptions.data.length >= (coupon.useLimit || Infinity))
749
- return new InvalidCouponError('Coupon is already applied');
750
- return coupon;
751
- }); }), operators.map(function (validatedCoupons) { return ({
752
- valids: validatedCoupons.filter(function (coupon) { return i2.FinancialCoupon.isFinancialCoupon(coupon); }),
753
- invalids: validatedCoupons.filter(function (coupon) { return coupon instanceof InvalidCouponError; }),
754
- }); }), operators.concatMap(function (_b) {
755
- var valids = _b.valids, invalids = _b.invalids;
756
- return valids.length ? rxjs.of(valids) : rxjs.throwError(new GroupInvalidCouponError(invalids));
757
- })); };
758
- }
759
- CheckoutSubscriptionService.prototype.getCheckoutSubscription = function (checkoutData) {
760
- var checkoutId = cookie__default["default"].get('checkoutSubscriptionId');
761
- if (!i2.isNil(checkoutId))
762
- return rxjs.from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
763
- return rxjs.from(this.createCheckoutSubscription(checkoutData));
764
- };
765
- CheckoutSubscriptionService.prototype.createCheckoutSubscription = function (checkoutData) {
766
- return __awaiter(this, void 0, void 0, function () {
767
- var checkout;
768
- return __generator(this, function (_b) {
769
- switch (_b.label) {
770
- case 0: return [4 /*yield*/, this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, i2.CheckoutSubscription.toInstance(i2.pick(checkoutData, ['user', 'shop'])).toPlain()))];
771
- case 1:
772
- checkout = _b.sent();
773
- cookie__default["default"].set('checkoutSubscriptionId', checkout.id);
774
- return [2 /*return*/, checkout];
775
- }
776
- });
777
- });
778
- };
779
- CheckoutSubscriptionService.prototype.clearCheckoutSubscriptionFromSession = function () {
780
- cookie__default["default"].remove('checkoutSubscriptionId');
781
- return rxjs.of();
782
- };
783
- CheckoutSubscriptionService.prototype.checkCoupon = function (nickname, userEmail) {
784
- var _this = this;
785
- return this.getCheckoutSubscription().pipe(operators.concatMap(function (checkout) { return _this.couponService.checkCoupon(nickname, userEmail, i2.CheckoutTypes.SUBSCRIPTION).pipe(operators.concatMap(function (coupons) {
786
- var couponsWithSamePlan = coupons.filter(function (coupon) { return checkout.subscriptionPlan.name === coupon.plan; });
787
- var couponsWithNoPlan = coupons.filter(function (coupon) { return !coupon.plan; });
788
- if (couponsWithSamePlan.length > 0)
789
- return rxjs.of(couponsWithSamePlan);
790
- if (couponsWithNoPlan.length > 0)
791
- return rxjs.of(couponsWithNoPlan);
792
- throw new Error("Coupon subscription plan is invalid.");
793
- }), operators.concatMap(function (coupons) { var _a; return !!((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email) ? _this.checkCouponsWithCheckout(coupons, checkout) : rxjs.of(coupons); }), operators.map(function (validatedCoupons) { return validatedCoupons.shift(); })); }));
794
- };
795
- return CheckoutSubscriptionService;
796
- }());
797
- 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 });
798
- CheckoutSubscriptionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService });
799
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService, decorators: [{
800
- type: i0.Injectable
801
- }], ctorParameters: function () {
802
- return [{ type: undefined, decorators: [{
803
- type: i0.Inject,
804
- args: ['CheckoutSubscriptionRepository']
805
- }] }, { type: undefined, decorators: [{
806
- type: i0.Inject,
807
- args: ['SubscriptionRepository']
808
- }] }, { type: CouponService }];
744
+ var CheckoutSubscriptionService = /** @class */ (function () {
745
+ function CheckoutSubscriptionService(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
746
+ this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
747
+ this.subscriptionRepository = subscriptionRepository;
748
+ this.couponService = couponService;
749
+ }
750
+ CheckoutSubscriptionService.prototype.getCheckoutSubscription = function (checkoutData) {
751
+ var checkoutId = cookie__default["default"].get('checkoutSubscriptionId');
752
+ if (!i2.isNil(checkoutId))
753
+ return rxjs.from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
754
+ return rxjs.from(this.createCheckoutSubscription(checkoutData));
755
+ };
756
+ CheckoutSubscriptionService.prototype.createCheckoutSubscription = function (checkoutData) {
757
+ return __awaiter(this, void 0, void 0, function () {
758
+ var checkout;
759
+ return __generator(this, function (_a) {
760
+ switch (_a.label) {
761
+ case 0: return [4 /*yield*/, this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, i2.CheckoutSubscription.toInstance(i2.pick(checkoutData, ['user', 'shop'])).toPlain()))];
762
+ case 1:
763
+ checkout = _a.sent();
764
+ cookie__default["default"].set('checkoutSubscriptionId', checkout.id);
765
+ return [2 /*return*/, checkout];
766
+ }
767
+ });
768
+ });
769
+ };
770
+ CheckoutSubscriptionService.prototype.clearCheckoutSubscriptionFromSession = function () {
771
+ cookie__default["default"].remove('checkoutSubscriptionId');
772
+ return rxjs.of();
773
+ };
774
+ return CheckoutSubscriptionService;
775
+ }());
776
+ 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 });
777
+ CheckoutSubscriptionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService });
778
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService, decorators: [{
779
+ type: i0.Injectable
780
+ }], ctorParameters: function () {
781
+ return [{ type: undefined, decorators: [{
782
+ type: i0.Inject,
783
+ args: ['CheckoutSubscriptionRepository']
784
+ }] }, { type: undefined, decorators: [{
785
+ type: i0.Inject,
786
+ args: ['SubscriptionRepository']
787
+ }] }, { type: CouponService }];
809
788
  } });
810
789
 
811
- var OrderService = /** @class */ (function () {
812
- function OrderService(angularFirestore, orderRepository) {
813
- this.angularFirestore = angularFirestore;
814
- this.orderRepository = orderRepository;
815
- this.orderSubject = new rxjs.Subject();
816
- }
817
- OrderService.prototype.getOrder = function (id) {
818
- var _this = this;
819
- this.angularFirestore
820
- .doc(this.orderRepository.collectionName + "/" + id)
821
- .valueChanges()
822
- .pipe(operators.map(function (doc) { return i2.Order.toInstance(doc); }))
823
- .subscribe(function (doc) { return _this.orderSubject.next(doc); });
824
- return this.orderSubject;
825
- };
826
- return OrderService;
827
- }());
828
- 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 });
829
- OrderService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService });
830
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService, decorators: [{
831
- type: i0.Injectable
832
- }], ctorParameters: function () {
833
- return [{ type: i1__namespace$1.AngularFirestore }, { type: i2__namespace.OrderFirestoreRepository, decorators: [{
834
- type: i0.Inject,
835
- args: ['OrderRepository']
836
- }] }];
790
+ var OrderService = /** @class */ (function () {
791
+ function OrderService(angularFirestore, orderRepository) {
792
+ this.angularFirestore = angularFirestore;
793
+ this.orderRepository = orderRepository;
794
+ this.orderSubject = new rxjs.Subject();
795
+ }
796
+ OrderService.prototype.getOrder = function (id) {
797
+ var _this = this;
798
+ this.angularFirestore
799
+ .doc(this.orderRepository.collectionName + "/" + id)
800
+ .valueChanges()
801
+ .pipe(operators.map(function (doc) { return i2.Order.toInstance(doc); }))
802
+ .subscribe(function (doc) { return _this.orderSubject.next(doc); });
803
+ return this.orderSubject;
804
+ };
805
+ return OrderService;
806
+ }());
807
+ 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 });
808
+ OrderService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService });
809
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService, decorators: [{
810
+ type: i0.Injectable
811
+ }], ctorParameters: function () {
812
+ return [{ type: i1__namespace$1.AngularFirestore }, { type: i2__namespace.OrderFirestoreRepository, decorators: [{
813
+ type: i0.Inject,
814
+ args: ['OrderRepository']
815
+ }] }];
837
816
  } });
838
817
 
839
- var HomeShopService = /** @class */ (function () {
840
- function HomeShopService(categoryRepository, homeRepository, productRepository, defaultShop) {
841
- this.categoryRepository = categoryRepository;
842
- this.homeRepository = homeRepository;
843
- this.productRepository = productRepository;
844
- this.defaultShop = defaultShop;
845
- this.buildCategoryGroupWithRequiredData = function (group) { return ({
846
- category: i2.Category.toInstance(i2.pick(group.category.toPlain(), ['id', 'name', 'slug', 'conditions'])),
847
- products: group.products.map(function (product) { return i2.Product.toInstance(i2.pick(product.toPlain(), [
848
- 'id',
849
- 'price',
850
- 'reviews',
851
- 'hasVariants',
852
- 'slug',
853
- 'sku',
854
- 'stock',
855
- 'costPrice',
856
- 'images',
857
- 'miniatures',
858
- 'name',
859
- 'weight',
860
- ])); }),
861
- }); };
862
- }
863
- Object.defineProperty(HomeShopService.prototype, "homeId", {
864
- get: function () {
865
- if (this.defaultShop === i2.Shops.GLAMSHOP)
866
- return 'glamshop';
867
- if (this.defaultShop === i2.Shops.MENSMARKET)
868
- return 'mens_market';
869
- return null;
870
- },
871
- enumerable: false,
872
- configurable: true
873
- });
874
- HomeShopService.prototype.getHomeData = function () {
875
- var _this = this;
876
- return this.getHomeConfiguration().pipe(operators.tap(function (home) { var _a; return console.log((_a = home === null || home === void 0 ? void 0 : home.data) === null || _a === void 0 ? void 0 : _a.expiresAt); }), 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
877
- ? rxjs.of(home)
878
- : rxjs.forkJoin([_this.getDiscoverProducts(), _this.getFeaturedProducts(), _this.getVerticalProducts()]).pipe(operators.map(function (_b) {
879
- var _c = __read(_b, 3), discoverProducts = _c[0], featuredProducts = _c[1], verticalProducts = _c[2];
880
- return ({
881
- discoverProducts: discoverProducts,
882
- featuredProducts: featuredProducts,
883
- verticalProducts: verticalProducts,
884
- });
885
- }), operators.concatMap(function (data) { return _this.saveHomeData(data); })); }));
886
- };
887
- HomeShopService.prototype.getBanners = function (type) {
888
- return this.getHomeConfiguration().pipe(operators.map(function (home) {
889
- if (type === 'brand')
890
- return home.brandsCarousel;
891
- if (type === 'buyToWin')
892
- return [home.buyToWinBanner];
893
- if (type === 'block')
894
- return home.blockBanners;
895
- if (type === 'blog')
896
- return [home.blogBanner];
897
- }));
898
- };
899
- HomeShopService.prototype.getDiscoverProducts = function () {
900
- var _this = this;
901
- 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); })); }));
902
- };
903
- HomeShopService.prototype.getFeaturedProducts = function () {
904
- var _this = this;
905
- 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); })); }));
906
- };
907
- HomeShopService.prototype.getVerticalProducts = function () {
908
- var _this = this;
909
- return this.getHomeConfiguration().pipe(operators.concatMap(function (home) { return rxjs.forkJoin(home.verticalCarousels.filter(Boolean).map(function (id) { return rxjs.forkJoin([
910
- _this.categoryRepository.get({ id: id }),
911
- _this.productRepository.find([{ categories: { operator: i2.Where.LIKE, value: [id] } }], { limit: 12 }),
912
- ]).pipe(operators.map(function (_b) {
913
- var _c = __read(_b, 2), category = _c[0], products = _c[1];
914
- return ({ category: category, products: products.data });
915
- }), operators.map(_this.buildCategoryGroupWithRequiredData)); })); }));
916
- };
917
- HomeShopService.prototype.getHomeConfiguration = function () {
918
- var _this = this;
919
- return rxjs.of(this.homeConfiguration).pipe(operators.concatMap(function (home) { return home
920
- ? rxjs.of(home)
921
- : !_this.homeId
922
- ? rxjs.throwError(new i2.RequiredArgumentError(['homeId']))
923
- : rxjs.from(_this.homeRepository.get({ id: _this.homeId })).pipe(operators.tap(function (homeLoaded) { return (_this.homeConfiguration = homeLoaded); })); }));
924
- };
925
- HomeShopService.prototype.saveHomeData = function (homeData) {
926
- var _this = this;
927
- var data = {
928
- createdAt: new Date(),
929
- expiresAt: i2.add(new Date(), { hours: 1 }),
930
- data: homeData,
931
- };
932
- return rxjs.from(this.homeRepository.update({
933
- id: this.homeId,
934
- data: data,
935
- })).pipe(operators.tap(function () { return (_this.homeConfiguration.data = data); }), operators.map(function () { return _this.homeConfiguration; }));
936
- };
937
- return HomeShopService;
938
- }());
939
- 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 });
940
- HomeShopService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService });
941
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService, decorators: [{
942
- type: i0.Injectable
943
- }], ctorParameters: function () {
944
- return [{ type: undefined, decorators: [{
945
- type: i0.Inject,
946
- args: ['CategoryRepository']
947
- }] }, { type: undefined, decorators: [{
948
- type: i0.Inject,
949
- args: ['HomeRepository']
950
- }] }, { type: undefined, decorators: [{
951
- type: i0.Inject,
952
- args: ['ProductRepository']
953
- }] }, { type: i2__namespace.Shops, decorators: [{
954
- type: i0.Inject,
955
- args: [DEFAULT_SHOP]
956
- }] }];
818
+ var HomeShopService = /** @class */ (function () {
819
+ function HomeShopService(categoryRepository, homeRepository, productRepository, defaultShop) {
820
+ this.categoryRepository = categoryRepository;
821
+ this.homeRepository = homeRepository;
822
+ this.productRepository = productRepository;
823
+ this.defaultShop = defaultShop;
824
+ this.buildCategoryGroupWithRequiredData = function (group) { return ({
825
+ category: i2.Category.toInstance(i2.pick(group.category.toPlain(), ['id', 'name', 'slug', 'conditions'])),
826
+ products: group.products.map(function (product) { return i2.Product.toInstance(i2.pick(product.toPlain(), [
827
+ 'id',
828
+ 'price',
829
+ 'reviews',
830
+ 'hasVariants',
831
+ 'slug',
832
+ 'sku',
833
+ 'stock',
834
+ 'costPrice',
835
+ 'images',
836
+ 'miniatures',
837
+ 'name',
838
+ 'weight',
839
+ ])); }),
840
+ }); };
841
+ }
842
+ Object.defineProperty(HomeShopService.prototype, "homeId", {
843
+ get: function () {
844
+ if (this.defaultShop === i2.Shops.GLAMSHOP)
845
+ return 'glamshop';
846
+ if (this.defaultShop === i2.Shops.MENSMARKET)
847
+ return 'mens_market';
848
+ return null;
849
+ },
850
+ enumerable: false,
851
+ configurable: true
852
+ });
853
+ HomeShopService.prototype.getHomeData = function () {
854
+ var _this = this;
855
+ return this.getHomeConfiguration().pipe(operators.tap(function (home) { var _a; return console.log((_a = home === null || home === void 0 ? void 0 : home.data) === null || _a === void 0 ? void 0 : _a.expiresAt); }), 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
856
+ ? rxjs.of(home)
857
+ : rxjs.forkJoin([_this.getDiscoverProducts(), _this.getFeaturedProducts(), _this.getVerticalProducts()]).pipe(operators.map(function (_b) {
858
+ var _c = __read(_b, 3), discoverProducts = _c[0], featuredProducts = _c[1], verticalProducts = _c[2];
859
+ return ({
860
+ discoverProducts: discoverProducts,
861
+ featuredProducts: featuredProducts,
862
+ verticalProducts: verticalProducts,
863
+ });
864
+ }), operators.concatMap(function (data) { return _this.saveHomeData(data); })); }));
865
+ };
866
+ HomeShopService.prototype.getBanners = function (type) {
867
+ return this.getHomeConfiguration().pipe(operators.map(function (home) {
868
+ if (type === 'brand')
869
+ return home.brandsCarousel;
870
+ if (type === 'buyToWin')
871
+ return [home.buyToWinBanner];
872
+ if (type === 'block')
873
+ return home.blockBanners;
874
+ if (type === 'blog')
875
+ return [home.blogBanner];
876
+ }));
877
+ };
878
+ HomeShopService.prototype.getDiscoverProducts = function () {
879
+ var _this = this;
880
+ 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); })); }));
881
+ };
882
+ HomeShopService.prototype.getFeaturedProducts = function () {
883
+ var _this = this;
884
+ 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); })); }));
885
+ };
886
+ HomeShopService.prototype.getVerticalProducts = function () {
887
+ var _this = this;
888
+ return this.getHomeConfiguration().pipe(operators.concatMap(function (home) { return rxjs.forkJoin(home.verticalCarousels.filter(Boolean).map(function (id) { return rxjs.forkJoin([
889
+ _this.categoryRepository.get({ id: id }),
890
+ _this.productRepository.find([{ categories: { operator: i2.Where.LIKE, value: [id] } }], { limit: 12 }),
891
+ ]).pipe(operators.map(function (_b) {
892
+ var _c = __read(_b, 2), category = _c[0], products = _c[1];
893
+ return ({ category: category, products: products.data });
894
+ }), operators.map(_this.buildCategoryGroupWithRequiredData)); })); }));
895
+ };
896
+ HomeShopService.prototype.getHomeConfiguration = function () {
897
+ var _this = this;
898
+ return rxjs.of(this.homeConfiguration).pipe(operators.concatMap(function (home) { return home
899
+ ? rxjs.of(home)
900
+ : !_this.homeId
901
+ ? rxjs.throwError(new i2.RequiredArgumentError(['homeId']))
902
+ : rxjs.from(_this.homeRepository.get({ id: _this.homeId })).pipe(operators.tap(function (homeLoaded) { return (_this.homeConfiguration = homeLoaded); })); }));
903
+ };
904
+ HomeShopService.prototype.saveHomeData = function (homeData) {
905
+ var _this = this;
906
+ var data = {
907
+ createdAt: new Date(),
908
+ expiresAt: i2.add(new Date(), { hours: 1 }),
909
+ data: homeData,
910
+ };
911
+ return rxjs.from(this.homeRepository.update({
912
+ id: this.homeId,
913
+ data: data,
914
+ })).pipe(operators.tap(function () { return (_this.homeConfiguration.data = data); }), operators.map(function () { return _this.homeConfiguration; }));
915
+ };
916
+ return HomeShopService;
917
+ }());
918
+ 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 });
919
+ HomeShopService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService });
920
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService, decorators: [{
921
+ type: i0.Injectable
922
+ }], ctorParameters: function () {
923
+ return [{ type: undefined, decorators: [{
924
+ type: i0.Inject,
925
+ args: ['CategoryRepository']
926
+ }] }, { type: undefined, decorators: [{
927
+ type: i0.Inject,
928
+ args: ['HomeRepository']
929
+ }] }, { type: undefined, decorators: [{
930
+ type: i0.Inject,
931
+ args: ['ProductRepository']
932
+ }] }, { type: i2__namespace.Shops, decorators: [{
933
+ type: i0.Inject,
934
+ args: [DEFAULT_SHOP]
935
+ }] }];
957
936
  } });
958
937
 
959
- var AngularFirebaseAuthModule = /** @class */ (function () {
960
- function AngularFirebaseAuthModule() {
961
- }
962
- AngularFirebaseAuthModule.initializeApp = function (options, nameOrConfig) {
963
- return {
964
- ngModule: AngularFirebaseAuthModule,
965
- providers: [
966
- { provide: fire.FIREBASE_OPTIONS, useValue: options },
967
- { provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
968
- ],
969
- };
970
- };
971
- return AngularFirebaseAuthModule;
972
- }());
973
- AngularFirebaseAuthModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
974
- AngularFirebaseAuthModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, imports: [fire.AngularFireModule] });
975
- AngularFirebaseAuthModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, providers: [
976
- {
977
- provide: 'Authentication',
978
- useFactory: function (authenticationService, userRepository) {
979
- return new i2.Authentication(authenticationService, userRepository);
980
- },
981
- deps: ['AuthenticationService', 'UserRepository'],
982
- },
983
- {
984
- provide: 'AuthenticationService',
985
- useFactory: function (angularFireAuth) {
986
- return new i2.AuthenticationFirebaseAuthService(angularFireAuth);
987
- },
988
- deps: [i1.AngularFireAuth],
989
- },
990
- {
991
- provide: 'Register',
992
- useFactory: function (registerService, userRepository) {
993
- return new i2.Register(registerService, userRepository);
994
- },
995
- deps: ['RegisterService', 'UserRepository'],
996
- },
997
- {
998
- provide: 'RegisterService',
999
- useFactory: function (angularFireAuth) {
1000
- return new i2.RegisterFirebaseAuthService(angularFireAuth);
1001
- },
1002
- deps: [i1.AngularFireAuth],
1003
- },
1004
- {
1005
- provide: 'SignOut',
1006
- useFactory: function (authenticationService) {
1007
- return new i2.SignOut(authenticationService);
1008
- },
1009
- deps: ['AuthenticationService'],
1010
- },
1011
- {
1012
- provide: 'RecoveryPassword',
1013
- useFactory: function (authenticationService) {
1014
- return new i2.RecoveryPassword(authenticationService);
1015
- },
1016
- deps: ['AuthenticationService'],
1017
- },
1018
- ], imports: [[fire.AngularFireModule]] });
1019
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, decorators: [{
1020
- type: i0.NgModule,
1021
- args: [{
1022
- imports: [fire.AngularFireModule],
1023
- providers: [
1024
- {
1025
- provide: 'Authentication',
1026
- useFactory: function (authenticationService, userRepository) {
1027
- return new i2.Authentication(authenticationService, userRepository);
1028
- },
1029
- deps: ['AuthenticationService', 'UserRepository'],
1030
- },
1031
- {
1032
- provide: 'AuthenticationService',
1033
- useFactory: function (angularFireAuth) {
1034
- return new i2.AuthenticationFirebaseAuthService(angularFireAuth);
1035
- },
1036
- deps: [i1.AngularFireAuth],
1037
- },
1038
- {
1039
- provide: 'Register',
1040
- useFactory: function (registerService, userRepository) {
1041
- return new i2.Register(registerService, userRepository);
1042
- },
1043
- deps: ['RegisterService', 'UserRepository'],
1044
- },
1045
- {
1046
- provide: 'RegisterService',
1047
- useFactory: function (angularFireAuth) {
1048
- return new i2.RegisterFirebaseAuthService(angularFireAuth);
1049
- },
1050
- deps: [i1.AngularFireAuth],
1051
- },
1052
- {
1053
- provide: 'SignOut',
1054
- useFactory: function (authenticationService) {
1055
- return new i2.SignOut(authenticationService);
1056
- },
1057
- deps: ['AuthenticationService'],
1058
- },
1059
- {
1060
- provide: 'RecoveryPassword',
1061
- useFactory: function (authenticationService) {
1062
- return new i2.RecoveryPassword(authenticationService);
1063
- },
1064
- deps: ['AuthenticationService'],
1065
- },
1066
- ],
1067
- }]
938
+ var AngularFirebaseAuthModule = /** @class */ (function () {
939
+ function AngularFirebaseAuthModule() {
940
+ }
941
+ AngularFirebaseAuthModule.initializeApp = function (options, nameOrConfig) {
942
+ return {
943
+ ngModule: AngularFirebaseAuthModule,
944
+ providers: [
945
+ { provide: fire.FIREBASE_OPTIONS, useValue: options },
946
+ { provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
947
+ ],
948
+ };
949
+ };
950
+ return AngularFirebaseAuthModule;
951
+ }());
952
+ AngularFirebaseAuthModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
953
+ AngularFirebaseAuthModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, imports: [fire.AngularFireModule] });
954
+ AngularFirebaseAuthModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, providers: [
955
+ {
956
+ provide: 'Authentication',
957
+ useFactory: function (authenticationService, userRepository) {
958
+ return new i2.Authentication(authenticationService, userRepository);
959
+ },
960
+ deps: ['AuthenticationService', 'UserRepository'],
961
+ },
962
+ {
963
+ provide: 'AuthenticationService',
964
+ useFactory: function (angularFireAuth) {
965
+ return new i2.AuthenticationFirebaseAuthService(angularFireAuth);
966
+ },
967
+ deps: [i1.AngularFireAuth],
968
+ },
969
+ {
970
+ provide: 'Register',
971
+ useFactory: function (registerService, userRepository) {
972
+ return new i2.Register(registerService, userRepository);
973
+ },
974
+ deps: ['RegisterService', 'UserRepository'],
975
+ },
976
+ {
977
+ provide: 'RegisterService',
978
+ useFactory: function (angularFireAuth) {
979
+ return new i2.RegisterFirebaseAuthService(angularFireAuth);
980
+ },
981
+ deps: [i1.AngularFireAuth],
982
+ },
983
+ {
984
+ provide: 'SignOut',
985
+ useFactory: function (authenticationService) {
986
+ return new i2.SignOut(authenticationService);
987
+ },
988
+ deps: ['AuthenticationService'],
989
+ },
990
+ {
991
+ provide: 'RecoveryPassword',
992
+ useFactory: function (authenticationService) {
993
+ return new i2.RecoveryPassword(authenticationService);
994
+ },
995
+ deps: ['AuthenticationService'],
996
+ },
997
+ ], imports: [[fire.AngularFireModule]] });
998
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, decorators: [{
999
+ type: i0.NgModule,
1000
+ args: [{
1001
+ imports: [fire.AngularFireModule],
1002
+ providers: [
1003
+ {
1004
+ provide: 'Authentication',
1005
+ useFactory: function (authenticationService, userRepository) {
1006
+ return new i2.Authentication(authenticationService, userRepository);
1007
+ },
1008
+ deps: ['AuthenticationService', 'UserRepository'],
1009
+ },
1010
+ {
1011
+ provide: 'AuthenticationService',
1012
+ useFactory: function (angularFireAuth) {
1013
+ return new i2.AuthenticationFirebaseAuthService(angularFireAuth);
1014
+ },
1015
+ deps: [i1.AngularFireAuth],
1016
+ },
1017
+ {
1018
+ provide: 'Register',
1019
+ useFactory: function (registerService, userRepository) {
1020
+ return new i2.Register(registerService, userRepository);
1021
+ },
1022
+ deps: ['RegisterService', 'UserRepository'],
1023
+ },
1024
+ {
1025
+ provide: 'RegisterService',
1026
+ useFactory: function (angularFireAuth) {
1027
+ return new i2.RegisterFirebaseAuthService(angularFireAuth);
1028
+ },
1029
+ deps: [i1.AngularFireAuth],
1030
+ },
1031
+ {
1032
+ provide: 'SignOut',
1033
+ useFactory: function (authenticationService) {
1034
+ return new i2.SignOut(authenticationService);
1035
+ },
1036
+ deps: ['AuthenticationService'],
1037
+ },
1038
+ {
1039
+ provide: 'RecoveryPassword',
1040
+ useFactory: function (authenticationService) {
1041
+ return new i2.RecoveryPassword(authenticationService);
1042
+ },
1043
+ deps: ['AuthenticationService'],
1044
+ },
1045
+ ],
1046
+ }]
1068
1047
  }] });
1069
1048
 
1070
- var AngularElasticSeachModule = /** @class */ (function () {
1071
- function AngularElasticSeachModule() {
1072
- }
1073
- AngularElasticSeachModule.initializeApp = function (options) {
1074
- return {
1075
- ngModule: AngularElasticSeachModule,
1076
- providers: [{ provide: ES_CONFIG, useValue: options }],
1077
- };
1078
- };
1079
- return AngularElasticSeachModule;
1080
- }());
1081
- AngularElasticSeachModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1082
- AngularElasticSeachModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule });
1083
- AngularElasticSeachModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, providers: [
1084
- {
1085
- provide: i2.ProductsIndex,
1086
- useFactory: function (configuration) {
1087
- return new i2.ProductsIndex(new i2.AxiosAdapter(configuration));
1088
- },
1089
- deps: [ES_CONFIG],
1090
- },
1091
- ] });
1092
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, decorators: [{
1093
- type: i0.NgModule,
1094
- args: [{
1095
- providers: [
1096
- {
1097
- provide: i2.ProductsIndex,
1098
- useFactory: function (configuration) {
1099
- return new i2.ProductsIndex(new i2.AxiosAdapter(configuration));
1100
- },
1101
- deps: [ES_CONFIG],
1102
- },
1103
- ],
1104
- }]
1049
+ var AngularElasticSeachModule = /** @class */ (function () {
1050
+ function AngularElasticSeachModule() {
1051
+ }
1052
+ AngularElasticSeachModule.initializeApp = function (options) {
1053
+ return {
1054
+ ngModule: AngularElasticSeachModule,
1055
+ providers: [{ provide: ES_CONFIG, useValue: options }],
1056
+ };
1057
+ };
1058
+ return AngularElasticSeachModule;
1059
+ }());
1060
+ AngularElasticSeachModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1061
+ AngularElasticSeachModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule });
1062
+ AngularElasticSeachModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, providers: [
1063
+ {
1064
+ provide: i2.ProductsIndex,
1065
+ useFactory: function (configuration) {
1066
+ return new i2.ProductsIndex(new i2.AxiosAdapter(configuration));
1067
+ },
1068
+ deps: [ES_CONFIG],
1069
+ },
1070
+ ] });
1071
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, decorators: [{
1072
+ type: i0.NgModule,
1073
+ args: [{
1074
+ providers: [
1075
+ {
1076
+ provide: i2.ProductsIndex,
1077
+ useFactory: function (configuration) {
1078
+ return new i2.ProductsIndex(new i2.AxiosAdapter(configuration));
1079
+ },
1080
+ deps: [ES_CONFIG],
1081
+ },
1082
+ ],
1083
+ }]
1105
1084
  }] });
1106
1085
 
1107
- var AngularFirestoreModule = /** @class */ (function () {
1108
- function AngularFirestoreModule() {
1109
- }
1110
- AngularFirestoreModule.initializeApp = function (options, nameOrConfig) {
1111
- return {
1112
- ngModule: AngularFirestoreModule,
1113
- providers: [
1114
- { provide: fire.FIREBASE_OPTIONS, useValue: options.firebase },
1115
- { provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
1116
- { provide: ES_CONFIG, useValue: options.elasticSearch },
1117
- ],
1118
- };
1119
- };
1120
- return AngularFirestoreModule;
1121
- }());
1122
- AngularFirestoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1123
- AngularFirestoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, imports: [fire.AngularFireModule, AngularElasticSeachModule] });
1124
- AngularFirestoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, providers: [
1125
- {
1126
- provide: 'BeautyProfileRepository',
1127
- useFactory: function (firestore, userRepository) {
1128
- return new i2.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
1129
- },
1130
- deps: [i1$1.AngularFirestore, 'UserRepository'],
1131
- },
1132
- {
1133
- provide: 'Buy2WinRepository',
1134
- useFactory: function (firestore) {
1135
- return new i2.Buy2WinFirestoreRepository(firestore.firestore);
1136
- },
1137
- deps: [i1$1.AngularFirestore],
1138
- },
1139
- {
1140
- provide: 'CategoryRepository',
1141
- useFactory: function (firestore, productsIndex) {
1142
- return new i2.CategoryFirestoreRepository(firestore.firestore, productsIndex);
1143
- },
1144
- deps: [i1$1.AngularFirestore, i2.ProductsIndex],
1145
- },
1146
- {
1147
- provide: 'CheckoutRepository',
1148
- useFactory: function (firestore) {
1149
- return new i2.CheckoutFirestoreRepository(firestore.firestore);
1150
- },
1151
- deps: [i1$1.AngularFirestore],
1152
- },
1153
- {
1154
- provide: 'CheckoutSubscriptionRepository',
1155
- useFactory: function (firestore) {
1156
- return new i2.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
1157
- },
1158
- deps: [i1$1.AngularFirestore],
1159
- },
1160
- {
1161
- provide: 'CouponRepository',
1162
- useFactory: function (firestore) {
1163
- return new i2.CouponFirestoreRepository(firestore.firestore);
1164
- },
1165
- deps: [i1$1.AngularFirestore],
1166
- },
1167
- {
1168
- provide: 'EditionRepository',
1169
- useFactory: function (firestore, subscriptionRepository) {
1170
- return new i2.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
1171
- },
1172
- deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1173
- },
1174
- {
1175
- provide: 'HomeRepository',
1176
- useFactory: function (firestore) {
1177
- return new i2.HomeFirestoreRepository(firestore.firestore);
1178
- },
1179
- deps: [i1$1.AngularFirestore],
1180
- },
1181
- {
1182
- provide: 'LeadRepository',
1183
- useFactory: function (firestore) {
1184
- return new i2.LeadFirestoreRepository(firestore.firestore);
1185
- },
1186
- deps: [i1$1.AngularFirestore],
1187
- },
1188
- {
1189
- provide: 'LegacyOrderRepository',
1190
- useFactory: function (firestore) {
1191
- return new i2.LegacyOrderFirestoreRepository(firestore.firestore);
1192
- },
1193
- deps: [i1$1.AngularFirestore],
1194
- },
1195
- {
1196
- provide: 'ShopMenuRepository',
1197
- useFactory: function (firestore) {
1198
- return new i2.ShopMenuFirestoreRepository(firestore.firestore);
1199
- },
1200
- deps: [i1$1.AngularFirestore],
1201
- },
1202
- {
1203
- provide: 'OrderRepository',
1204
- useFactory: function (firestore) {
1205
- return new i2.OrderFirestoreRepository(firestore.firestore);
1206
- },
1207
- deps: [i1$1.AngularFirestore],
1208
- },
1209
- {
1210
- provide: 'PaymentRepository',
1211
- useFactory: function (firestore) {
1212
- return new i2.PaymentFirestoreRepository(firestore.firestore);
1213
- },
1214
- deps: [i1$1.AngularFirestore],
1215
- },
1216
- {
1217
- provide: 'ProductRepository',
1218
- useFactory: function (firestore) {
1219
- return new i2.ProductFirestoreRepository(firestore.firestore);
1220
- },
1221
- deps: [i1$1.AngularFirestore],
1222
- },
1223
- {
1224
- provide: 'SubscriptionPaymentRepository',
1225
- useFactory: function (firestore, subscriptionRepository) {
1226
- return new i2.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1227
- },
1228
- deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1229
- },
1230
- {
1231
- provide: 'SubscriptionPlanRepository',
1232
- useFactory: function (firestore) {
1233
- return new i2.SubscriptionPlanFirestoreRepository(firestore.firestore);
1234
- },
1235
- deps: [i1$1.AngularFirestore],
1236
- },
1237
- {
1238
- provide: 'SubscriptionProductRepository',
1239
- useFactory: function (firestore) {
1240
- return new i2.SubscriptionProductFirestoreRepository(firestore.firestore);
1241
- },
1242
- deps: [i1$1.AngularFirestore],
1243
- },
1244
- {
1245
- provide: 'SubscriptionRepository',
1246
- useFactory: function (firestore) {
1247
- return new i2.SubscriptionFirestoreRepository(firestore.firestore);
1248
- },
1249
- deps: [i1$1.AngularFirestore],
1250
- },
1251
- {
1252
- provide: 'UserRepository',
1253
- useFactory: function (firestore) {
1254
- return new i2.UserFirestoreRepository(firestore.firestore);
1255
- },
1256
- deps: [i1$1.AngularFirestore],
1257
- },
1258
- {
1259
- provide: 'UserAddressRepository',
1260
- useFactory: function (firestore, userRepository) {
1261
- return new i2.UserAddressFirestoreRepository(firestore.firestore, userRepository);
1262
- },
1263
- deps: [i1$1.AngularFirestore, 'UserRepository'],
1264
- },
1265
- {
1266
- provide: 'UserPaymentMethodRepository',
1267
- useFactory: function (firestore, userRepository) {
1268
- return new i2.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1269
- },
1270
- deps: [i1$1.AngularFirestore, 'UserRepository'],
1271
- },
1272
- {
1273
- provide: 'VariantRepository',
1274
- useFactory: function (firestore, productRepository) {
1275
- return new i2.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1276
- },
1277
- deps: [i1$1.AngularFirestore, 'ProductRepository'],
1278
- },
1279
- ], imports: [[fire.AngularFireModule, AngularElasticSeachModule]] });
1280
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, decorators: [{
1281
- type: i0.NgModule,
1282
- args: [{
1283
- imports: [fire.AngularFireModule, AngularElasticSeachModule],
1284
- providers: [
1285
- {
1286
- provide: 'BeautyProfileRepository',
1287
- useFactory: function (firestore, userRepository) {
1288
- return new i2.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
1289
- },
1290
- deps: [i1$1.AngularFirestore, 'UserRepository'],
1291
- },
1292
- {
1293
- provide: 'Buy2WinRepository',
1294
- useFactory: function (firestore) {
1295
- return new i2.Buy2WinFirestoreRepository(firestore.firestore);
1296
- },
1297
- deps: [i1$1.AngularFirestore],
1298
- },
1299
- {
1300
- provide: 'CategoryRepository',
1301
- useFactory: function (firestore, productsIndex) {
1302
- return new i2.CategoryFirestoreRepository(firestore.firestore, productsIndex);
1303
- },
1304
- deps: [i1$1.AngularFirestore, i2.ProductsIndex],
1305
- },
1306
- {
1307
- provide: 'CheckoutRepository',
1308
- useFactory: function (firestore) {
1309
- return new i2.CheckoutFirestoreRepository(firestore.firestore);
1310
- },
1311
- deps: [i1$1.AngularFirestore],
1312
- },
1313
- {
1314
- provide: 'CheckoutSubscriptionRepository',
1315
- useFactory: function (firestore) {
1316
- return new i2.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
1317
- },
1318
- deps: [i1$1.AngularFirestore],
1319
- },
1320
- {
1321
- provide: 'CouponRepository',
1322
- useFactory: function (firestore) {
1323
- return new i2.CouponFirestoreRepository(firestore.firestore);
1324
- },
1325
- deps: [i1$1.AngularFirestore],
1326
- },
1327
- {
1328
- provide: 'EditionRepository',
1329
- useFactory: function (firestore, subscriptionRepository) {
1330
- return new i2.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
1331
- },
1332
- deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1333
- },
1334
- {
1335
- provide: 'HomeRepository',
1336
- useFactory: function (firestore) {
1337
- return new i2.HomeFirestoreRepository(firestore.firestore);
1338
- },
1339
- deps: [i1$1.AngularFirestore],
1340
- },
1341
- {
1342
- provide: 'LeadRepository',
1343
- useFactory: function (firestore) {
1344
- return new i2.LeadFirestoreRepository(firestore.firestore);
1345
- },
1346
- deps: [i1$1.AngularFirestore],
1347
- },
1348
- {
1349
- provide: 'LegacyOrderRepository',
1350
- useFactory: function (firestore) {
1351
- return new i2.LegacyOrderFirestoreRepository(firestore.firestore);
1352
- },
1353
- deps: [i1$1.AngularFirestore],
1354
- },
1355
- {
1356
- provide: 'ShopMenuRepository',
1357
- useFactory: function (firestore) {
1358
- return new i2.ShopMenuFirestoreRepository(firestore.firestore);
1359
- },
1360
- deps: [i1$1.AngularFirestore],
1361
- },
1362
- {
1363
- provide: 'OrderRepository',
1364
- useFactory: function (firestore) {
1365
- return new i2.OrderFirestoreRepository(firestore.firestore);
1366
- },
1367
- deps: [i1$1.AngularFirestore],
1368
- },
1369
- {
1370
- provide: 'PaymentRepository',
1371
- useFactory: function (firestore) {
1372
- return new i2.PaymentFirestoreRepository(firestore.firestore);
1373
- },
1374
- deps: [i1$1.AngularFirestore],
1375
- },
1376
- {
1377
- provide: 'ProductRepository',
1378
- useFactory: function (firestore) {
1379
- return new i2.ProductFirestoreRepository(firestore.firestore);
1380
- },
1381
- deps: [i1$1.AngularFirestore],
1382
- },
1383
- {
1384
- provide: 'SubscriptionPaymentRepository',
1385
- useFactory: function (firestore, subscriptionRepository) {
1386
- return new i2.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1387
- },
1388
- deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1389
- },
1390
- {
1391
- provide: 'SubscriptionPlanRepository',
1392
- useFactory: function (firestore) {
1393
- return new i2.SubscriptionPlanFirestoreRepository(firestore.firestore);
1394
- },
1395
- deps: [i1$1.AngularFirestore],
1396
- },
1397
- {
1398
- provide: 'SubscriptionProductRepository',
1399
- useFactory: function (firestore) {
1400
- return new i2.SubscriptionProductFirestoreRepository(firestore.firestore);
1401
- },
1402
- deps: [i1$1.AngularFirestore],
1403
- },
1404
- {
1405
- provide: 'SubscriptionRepository',
1406
- useFactory: function (firestore) {
1407
- return new i2.SubscriptionFirestoreRepository(firestore.firestore);
1408
- },
1409
- deps: [i1$1.AngularFirestore],
1410
- },
1411
- {
1412
- provide: 'UserRepository',
1413
- useFactory: function (firestore) {
1414
- return new i2.UserFirestoreRepository(firestore.firestore);
1415
- },
1416
- deps: [i1$1.AngularFirestore],
1417
- },
1418
- {
1419
- provide: 'UserAddressRepository',
1420
- useFactory: function (firestore, userRepository) {
1421
- return new i2.UserAddressFirestoreRepository(firestore.firestore, userRepository);
1422
- },
1423
- deps: [i1$1.AngularFirestore, 'UserRepository'],
1424
- },
1425
- {
1426
- provide: 'UserPaymentMethodRepository',
1427
- useFactory: function (firestore, userRepository) {
1428
- return new i2.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1429
- },
1430
- deps: [i1$1.AngularFirestore, 'UserRepository'],
1431
- },
1432
- {
1433
- provide: 'VariantRepository',
1434
- useFactory: function (firestore, productRepository) {
1435
- return new i2.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1436
- },
1437
- deps: [i1$1.AngularFirestore, 'ProductRepository'],
1438
- },
1439
- ],
1440
- }]
1086
+ var AngularFirestoreModule = /** @class */ (function () {
1087
+ function AngularFirestoreModule() {
1088
+ }
1089
+ AngularFirestoreModule.initializeApp = function (options, nameOrConfig) {
1090
+ return {
1091
+ ngModule: AngularFirestoreModule,
1092
+ providers: [
1093
+ { provide: fire.FIREBASE_OPTIONS, useValue: options.firebase },
1094
+ { provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
1095
+ { provide: ES_CONFIG, useValue: options.elasticSearch },
1096
+ ],
1097
+ };
1098
+ };
1099
+ return AngularFirestoreModule;
1100
+ }());
1101
+ AngularFirestoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1102
+ AngularFirestoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, imports: [fire.AngularFireModule, AngularElasticSeachModule] });
1103
+ AngularFirestoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, providers: [
1104
+ {
1105
+ provide: 'BeautyProfileRepository',
1106
+ useFactory: function (firestore, userRepository) {
1107
+ return new i2.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
1108
+ },
1109
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
1110
+ },
1111
+ {
1112
+ provide: 'Buy2WinRepository',
1113
+ useFactory: function (firestore) {
1114
+ return new i2.Buy2WinFirestoreRepository(firestore.firestore);
1115
+ },
1116
+ deps: [i1$1.AngularFirestore],
1117
+ },
1118
+ {
1119
+ provide: 'CategoryRepository',
1120
+ useFactory: function (firestore, productsIndex) {
1121
+ return new i2.CategoryFirestoreRepository(firestore.firestore);
1122
+ },
1123
+ deps: [i1$1.AngularFirestore, i2.ProductsIndex],
1124
+ },
1125
+ {
1126
+ provide: 'CheckoutRepository',
1127
+ useFactory: function (firestore) {
1128
+ return new i2.CheckoutFirestoreRepository(firestore.firestore);
1129
+ },
1130
+ deps: [i1$1.AngularFirestore],
1131
+ },
1132
+ {
1133
+ provide: 'CheckoutSubscriptionRepository',
1134
+ useFactory: function (firestore) {
1135
+ return new i2.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
1136
+ },
1137
+ deps: [i1$1.AngularFirestore],
1138
+ },
1139
+ {
1140
+ provide: 'CouponRepository',
1141
+ useFactory: function (firestore) {
1142
+ return new i2.CouponFirestoreRepository(firestore.firestore);
1143
+ },
1144
+ deps: [i1$1.AngularFirestore],
1145
+ },
1146
+ {
1147
+ provide: 'EditionRepository',
1148
+ useFactory: function (firestore, subscriptionRepository) {
1149
+ return new i2.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
1150
+ },
1151
+ deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1152
+ },
1153
+ {
1154
+ provide: 'HomeRepository',
1155
+ useFactory: function (firestore) {
1156
+ return new i2.HomeFirestoreRepository(firestore.firestore);
1157
+ },
1158
+ deps: [i1$1.AngularFirestore],
1159
+ },
1160
+ {
1161
+ provide: 'LeadRepository',
1162
+ useFactory: function (firestore) {
1163
+ return new i2.LeadFirestoreRepository(firestore.firestore);
1164
+ },
1165
+ deps: [i1$1.AngularFirestore],
1166
+ },
1167
+ {
1168
+ provide: 'LegacyOrderRepository',
1169
+ useFactory: function (firestore) {
1170
+ return new i2.LegacyOrderFirestoreRepository(firestore.firestore);
1171
+ },
1172
+ deps: [i1$1.AngularFirestore],
1173
+ },
1174
+ {
1175
+ provide: 'ShopMenuRepository',
1176
+ useFactory: function (firestore) {
1177
+ return new i2.ShopMenuFirestoreRepository(firestore.firestore);
1178
+ },
1179
+ deps: [i1$1.AngularFirestore],
1180
+ },
1181
+ {
1182
+ provide: 'OrderRepository',
1183
+ useFactory: function (firestore) {
1184
+ return new i2.OrderFirestoreRepository(firestore.firestore);
1185
+ },
1186
+ deps: [i1$1.AngularFirestore],
1187
+ },
1188
+ {
1189
+ provide: 'PaymentRepository',
1190
+ useFactory: function (firestore) {
1191
+ return new i2.PaymentFirestoreRepository(firestore.firestore);
1192
+ },
1193
+ deps: [i1$1.AngularFirestore],
1194
+ },
1195
+ {
1196
+ provide: 'ProductRepository',
1197
+ useFactory: function (firestore) {
1198
+ return new i2.ProductFirestoreRepository(firestore.firestore);
1199
+ },
1200
+ deps: [i1$1.AngularFirestore],
1201
+ },
1202
+ {
1203
+ provide: 'SubscriptionPaymentRepository',
1204
+ useFactory: function (firestore, subscriptionRepository) {
1205
+ return new i2.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1206
+ },
1207
+ deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1208
+ },
1209
+ {
1210
+ provide: 'SubscriptionPlanRepository',
1211
+ useFactory: function (firestore) {
1212
+ return new i2.SubscriptionPlanFirestoreRepository(firestore.firestore);
1213
+ },
1214
+ deps: [i1$1.AngularFirestore],
1215
+ },
1216
+ {
1217
+ provide: 'SubscriptionProductRepository',
1218
+ useFactory: function (firestore) {
1219
+ return new i2.SubscriptionProductFirestoreRepository(firestore.firestore);
1220
+ },
1221
+ deps: [i1$1.AngularFirestore],
1222
+ },
1223
+ {
1224
+ provide: 'SubscriptionRepository',
1225
+ useFactory: function (firestore) {
1226
+ return new i2.SubscriptionFirestoreRepository(firestore.firestore);
1227
+ },
1228
+ deps: [i1$1.AngularFirestore],
1229
+ },
1230
+ {
1231
+ provide: 'UserRepository',
1232
+ useFactory: function (firestore) {
1233
+ return new i2.UserFirestoreRepository(firestore.firestore);
1234
+ },
1235
+ deps: [i1$1.AngularFirestore],
1236
+ },
1237
+ {
1238
+ provide: 'UserAddressRepository',
1239
+ useFactory: function (firestore, userRepository) {
1240
+ return new i2.UserAddressFirestoreRepository(firestore.firestore, userRepository);
1241
+ },
1242
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
1243
+ },
1244
+ {
1245
+ provide: 'UserPaymentMethodRepository',
1246
+ useFactory: function (firestore, userRepository) {
1247
+ return new i2.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1248
+ },
1249
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
1250
+ },
1251
+ {
1252
+ provide: 'VariantRepository',
1253
+ useFactory: function (firestore, productRepository) {
1254
+ return new i2.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1255
+ },
1256
+ deps: [i1$1.AngularFirestore, 'ProductRepository'],
1257
+ },
1258
+ ], imports: [[fire.AngularFireModule, AngularElasticSeachModule]] });
1259
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, decorators: [{
1260
+ type: i0.NgModule,
1261
+ args: [{
1262
+ imports: [fire.AngularFireModule, AngularElasticSeachModule],
1263
+ providers: [
1264
+ {
1265
+ provide: 'BeautyProfileRepository',
1266
+ useFactory: function (firestore, userRepository) {
1267
+ return new i2.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
1268
+ },
1269
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
1270
+ },
1271
+ {
1272
+ provide: 'Buy2WinRepository',
1273
+ useFactory: function (firestore) {
1274
+ return new i2.Buy2WinFirestoreRepository(firestore.firestore);
1275
+ },
1276
+ deps: [i1$1.AngularFirestore],
1277
+ },
1278
+ {
1279
+ provide: 'CategoryRepository',
1280
+ useFactory: function (firestore, productsIndex) {
1281
+ return new i2.CategoryFirestoreRepository(firestore.firestore);
1282
+ },
1283
+ deps: [i1$1.AngularFirestore, i2.ProductsIndex],
1284
+ },
1285
+ {
1286
+ provide: 'CheckoutRepository',
1287
+ useFactory: function (firestore) {
1288
+ return new i2.CheckoutFirestoreRepository(firestore.firestore);
1289
+ },
1290
+ deps: [i1$1.AngularFirestore],
1291
+ },
1292
+ {
1293
+ provide: 'CheckoutSubscriptionRepository',
1294
+ useFactory: function (firestore) {
1295
+ return new i2.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
1296
+ },
1297
+ deps: [i1$1.AngularFirestore],
1298
+ },
1299
+ {
1300
+ provide: 'CouponRepository',
1301
+ useFactory: function (firestore) {
1302
+ return new i2.CouponFirestoreRepository(firestore.firestore);
1303
+ },
1304
+ deps: [i1$1.AngularFirestore],
1305
+ },
1306
+ {
1307
+ provide: 'EditionRepository',
1308
+ useFactory: function (firestore, subscriptionRepository) {
1309
+ return new i2.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
1310
+ },
1311
+ deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1312
+ },
1313
+ {
1314
+ provide: 'HomeRepository',
1315
+ useFactory: function (firestore) {
1316
+ return new i2.HomeFirestoreRepository(firestore.firestore);
1317
+ },
1318
+ deps: [i1$1.AngularFirestore],
1319
+ },
1320
+ {
1321
+ provide: 'LeadRepository',
1322
+ useFactory: function (firestore) {
1323
+ return new i2.LeadFirestoreRepository(firestore.firestore);
1324
+ },
1325
+ deps: [i1$1.AngularFirestore],
1326
+ },
1327
+ {
1328
+ provide: 'LegacyOrderRepository',
1329
+ useFactory: function (firestore) {
1330
+ return new i2.LegacyOrderFirestoreRepository(firestore.firestore);
1331
+ },
1332
+ deps: [i1$1.AngularFirestore],
1333
+ },
1334
+ {
1335
+ provide: 'ShopMenuRepository',
1336
+ useFactory: function (firestore) {
1337
+ return new i2.ShopMenuFirestoreRepository(firestore.firestore);
1338
+ },
1339
+ deps: [i1$1.AngularFirestore],
1340
+ },
1341
+ {
1342
+ provide: 'OrderRepository',
1343
+ useFactory: function (firestore) {
1344
+ return new i2.OrderFirestoreRepository(firestore.firestore);
1345
+ },
1346
+ deps: [i1$1.AngularFirestore],
1347
+ },
1348
+ {
1349
+ provide: 'PaymentRepository',
1350
+ useFactory: function (firestore) {
1351
+ return new i2.PaymentFirestoreRepository(firestore.firestore);
1352
+ },
1353
+ deps: [i1$1.AngularFirestore],
1354
+ },
1355
+ {
1356
+ provide: 'ProductRepository',
1357
+ useFactory: function (firestore) {
1358
+ return new i2.ProductFirestoreRepository(firestore.firestore);
1359
+ },
1360
+ deps: [i1$1.AngularFirestore],
1361
+ },
1362
+ {
1363
+ provide: 'SubscriptionPaymentRepository',
1364
+ useFactory: function (firestore, subscriptionRepository) {
1365
+ return new i2.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1366
+ },
1367
+ deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1368
+ },
1369
+ {
1370
+ provide: 'SubscriptionPlanRepository',
1371
+ useFactory: function (firestore) {
1372
+ return new i2.SubscriptionPlanFirestoreRepository(firestore.firestore);
1373
+ },
1374
+ deps: [i1$1.AngularFirestore],
1375
+ },
1376
+ {
1377
+ provide: 'SubscriptionProductRepository',
1378
+ useFactory: function (firestore) {
1379
+ return new i2.SubscriptionProductFirestoreRepository(firestore.firestore);
1380
+ },
1381
+ deps: [i1$1.AngularFirestore],
1382
+ },
1383
+ {
1384
+ provide: 'SubscriptionRepository',
1385
+ useFactory: function (firestore) {
1386
+ return new i2.SubscriptionFirestoreRepository(firestore.firestore);
1387
+ },
1388
+ deps: [i1$1.AngularFirestore],
1389
+ },
1390
+ {
1391
+ provide: 'UserRepository',
1392
+ useFactory: function (firestore) {
1393
+ return new i2.UserFirestoreRepository(firestore.firestore);
1394
+ },
1395
+ deps: [i1$1.AngularFirestore],
1396
+ },
1397
+ {
1398
+ provide: 'UserAddressRepository',
1399
+ useFactory: function (firestore, userRepository) {
1400
+ return new i2.UserAddressFirestoreRepository(firestore.firestore, userRepository);
1401
+ },
1402
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
1403
+ },
1404
+ {
1405
+ provide: 'UserPaymentMethodRepository',
1406
+ useFactory: function (firestore, userRepository) {
1407
+ return new i2.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1408
+ },
1409
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
1410
+ },
1411
+ {
1412
+ provide: 'VariantRepository',
1413
+ useFactory: function (firestore, productRepository) {
1414
+ return new i2.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1415
+ },
1416
+ deps: [i1$1.AngularFirestore, 'ProductRepository'],
1417
+ },
1418
+ ],
1419
+ }]
1441
1420
  }] });
1442
1421
 
1443
- var AngularConnectModule = /** @class */ (function () {
1444
- function AngularConnectModule() {
1445
- }
1446
- AngularConnectModule.initializeApp = function (defaultShop, options, nameOrConfig) {
1447
- return {
1448
- ngModule: AngularConnectModule,
1449
- providers: __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 }]))),
1450
- };
1451
- };
1452
- return AngularConnectModule;
1453
- }());
1454
- AngularConnectModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1455
- AngularConnectModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, imports: [fire.AngularFireModule, AngularFirestoreModule] });
1456
- AngularConnectModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, providers: [
1457
- AuthService,
1458
- CartService,
1459
- CheckoutService,
1460
- CheckoutSubscriptionService,
1461
- CouponService,
1462
- HomeShopService,
1463
- OrderService,
1464
- ], imports: [[fire.AngularFireModule, AngularFirestoreModule]] });
1465
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, decorators: [{
1466
- type: i0.NgModule,
1467
- args: [{
1468
- imports: [fire.AngularFireModule, AngularFirestoreModule],
1469
- providers: [
1470
- AuthService,
1471
- CartService,
1472
- CheckoutService,
1473
- CheckoutSubscriptionService,
1474
- CouponService,
1475
- HomeShopService,
1476
- OrderService,
1477
- ],
1478
- }]
1422
+ var AngularConnectModule = /** @class */ (function () {
1423
+ function AngularConnectModule() {
1424
+ }
1425
+ AngularConnectModule.initializeApp = function (defaultShop, options, nameOrConfig) {
1426
+ return {
1427
+ ngModule: AngularConnectModule,
1428
+ providers: __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 }]))),
1429
+ };
1430
+ };
1431
+ return AngularConnectModule;
1432
+ }());
1433
+ AngularConnectModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1434
+ AngularConnectModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, imports: [fire.AngularFireModule, AngularFirestoreModule] });
1435
+ AngularConnectModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, providers: [
1436
+ AuthService,
1437
+ CartService,
1438
+ CheckoutService,
1439
+ CheckoutSubscriptionService,
1440
+ CouponService,
1441
+ HomeShopService,
1442
+ OrderService,
1443
+ ], imports: [[fire.AngularFireModule, AngularFirestoreModule]] });
1444
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, decorators: [{
1445
+ type: i0.NgModule,
1446
+ args: [{
1447
+ imports: [fire.AngularFireModule, AngularFirestoreModule],
1448
+ providers: [
1449
+ AuthService,
1450
+ CartService,
1451
+ CheckoutService,
1452
+ CheckoutSubscriptionService,
1453
+ CouponService,
1454
+ HomeShopService,
1455
+ OrderService,
1456
+ ],
1457
+ }]
1479
1458
  }] });
1480
1459
 
1481
- /**
1482
- * Generated bundle index. Do not edit.
1460
+ /**
1461
+ * Generated bundle index. Do not edit.
1483
1462
  */
1484
1463
 
1485
1464
  exports.AngularConnectModule = AngularConnectModule;