@infrab4a/connect-angular 0.17.0-beta.8 → 1.0.0-beta.1

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