@infrab4a/connect-angular 0.9.1 → 0.9.2

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 (39) hide show
  1. package/bundles/infrab4a-connect-angular.umd.js +1044 -1035
  2. package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
  3. package/esm2015/infrab4a-connect-angular.js +4 -4
  4. package/esm2015/lib/angular-connect.module.js +30 -30
  5. package/esm2015/lib/angular-firebase-auth.module.js +71 -71
  6. package/esm2015/lib/angular-firestore.module.js +323 -323
  7. package/esm2015/lib/consts/default-shop.const.js +2 -2
  8. package/esm2015/lib/consts/index.js +2 -2
  9. package/esm2015/lib/index.js +5 -5
  10. package/esm2015/lib/services/auth.service.js +42 -33
  11. package/esm2015/lib/services/cart.service.js +153 -153
  12. package/esm2015/lib/services/checkout-subscription.service.js +37 -37
  13. package/esm2015/lib/services/checkout.service.js +57 -57
  14. package/esm2015/lib/services/index.js +6 -6
  15. package/esm2015/lib/services/order.service.js +32 -32
  16. package/esm2015/lib/services/types/index.js +3 -3
  17. package/esm2015/lib/services/types/required-checkout-data.type.js +2 -2
  18. package/esm2015/lib/services/types/required-checkout-subscription-data.type.js +2 -2
  19. package/esm2015/public-api.js +2 -2
  20. package/fesm2015/infrab4a-connect-angular.js +676 -667
  21. package/fesm2015/infrab4a-connect-angular.js.map +1 -1
  22. package/infrab4a-connect-angular.d.ts +5 -5
  23. package/lib/angular-connect.module.d.ts +12 -12
  24. package/lib/angular-firebase-auth.module.d.ts +10 -10
  25. package/lib/angular-firestore.module.d.ts +10 -10
  26. package/lib/consts/default-shop.const.d.ts +1 -1
  27. package/lib/consts/index.d.ts +1 -1
  28. package/lib/index.d.ts +4 -4
  29. package/lib/services/auth.service.d.ts +19 -16
  30. package/lib/services/cart.service.d.ts +35 -35
  31. package/lib/services/checkout-subscription.service.d.ts +13 -13
  32. package/lib/services/checkout.service.d.ts +18 -18
  33. package/lib/services/index.d.ts +5 -5
  34. package/lib/services/order.service.d.ts +13 -13
  35. package/lib/services/types/index.d.ts +2 -2
  36. package/lib/services/types/required-checkout-data.type.d.ts +2 -2
  37. package/lib/services/types/required-checkout-subscription-data.type.d.ts +2 -2
  38. package/package.json +1 -1
  39. package/public-api.d.ts +1 -1
@@ -30,1059 +30,1068 @@
30
30
  var cookie__default = /*#__PURE__*/_interopDefaultLegacy(cookie);
31
31
  var i1__namespace$2 = /*#__PURE__*/_interopNamespace(i1$2);
32
32
 
33
- var AuthService = /** @class */ (function () {
34
- function AuthService(angularFireAuth, userRepository) {
35
- this.angularFireAuth = angularFireAuth;
36
- this.userRepository = userRepository;
37
- }
38
- AuthService.prototype.getAuthstate = function () {
39
- var _this = this;
40
- return this.angularFireAuth.authState.pipe(operators.mergeMap(function () { return _this.getUser(); }));
41
- };
42
- AuthService.prototype.getUser = function () {
43
- var _this = this;
44
- return this.getFireUser().pipe(operators.map(function (user) { return user.uid || rxjs.throwError(function () { return new Error('Usuário não logado'); }); }), operators.mergeMap(function (id) { return _this.userRepository.get({ id: id }); }));
45
- };
46
- AuthService.prototype.getTokenId = function () {
47
- return this.angularFireAuth.idToken;
48
- };
49
- AuthService.prototype.getFireUser = function () {
50
- return this.angularFireAuth.user;
51
- };
52
- return AuthService;
53
- }());
54
- 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 });
55
- AuthService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AuthService });
56
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AuthService, decorators: [{
57
- type: i0.Injectable
58
- }], ctorParameters: function () {
59
- return [{ type: i1__namespace.AngularFireAuth }, { type: undefined, decorators: [{
60
- type: i0.Inject,
61
- args: ['UserRepository']
62
- }] }];
33
+ /*! *****************************************************************************
34
+ Copyright (c) Microsoft Corporation.
35
+
36
+ Permission to use, copy, modify, and/or distribute this software for any
37
+ purpose with or without fee is hereby granted.
38
+
39
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
40
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
41
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
42
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
43
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
44
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
45
+ PERFORMANCE OF THIS SOFTWARE.
46
+ ***************************************************************************** */
47
+ /* global Reflect, Promise */
48
+ var extendStatics = function (d, b) {
49
+ extendStatics = Object.setPrototypeOf ||
50
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
51
+ function (d, b) { for (var p in b)
52
+ if (Object.prototype.hasOwnProperty.call(b, p))
53
+ d[p] = b[p]; };
54
+ return extendStatics(d, b);
55
+ };
56
+ function __extends(d, b) {
57
+ if (typeof b !== "function" && b !== null)
58
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
59
+ extendStatics(d, b);
60
+ function __() { this.constructor = d; }
61
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
62
+ }
63
+ var __assign = function () {
64
+ __assign = Object.assign || function __assign(t) {
65
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
66
+ s = arguments[i];
67
+ for (var p in s)
68
+ if (Object.prototype.hasOwnProperty.call(s, p))
69
+ t[p] = s[p];
70
+ }
71
+ return t;
72
+ };
73
+ return __assign.apply(this, arguments);
74
+ };
75
+ function __rest(s, e) {
76
+ var t = {};
77
+ for (var p in s)
78
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
79
+ t[p] = s[p];
80
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
81
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
82
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
83
+ t[p[i]] = s[p[i]];
84
+ }
85
+ return t;
86
+ }
87
+ function __decorate(decorators, target, key, desc) {
88
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
89
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
90
+ r = Reflect.decorate(decorators, target, key, desc);
91
+ else
92
+ for (var i = decorators.length - 1; i >= 0; i--)
93
+ if (d = decorators[i])
94
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
95
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
96
+ }
97
+ function __param(paramIndex, decorator) {
98
+ return function (target, key) { decorator(target, key, paramIndex); };
99
+ }
100
+ function __metadata(metadataKey, metadataValue) {
101
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
102
+ return Reflect.metadata(metadataKey, metadataValue);
103
+ }
104
+ function __awaiter(thisArg, _arguments, P, generator) {
105
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
106
+ return new (P || (P = Promise))(function (resolve, reject) {
107
+ function fulfilled(value) { try {
108
+ step(generator.next(value));
109
+ }
110
+ catch (e) {
111
+ reject(e);
112
+ } }
113
+ function rejected(value) { try {
114
+ step(generator["throw"](value));
115
+ }
116
+ catch (e) {
117
+ reject(e);
118
+ } }
119
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
120
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
121
+ });
122
+ }
123
+ function __generator(thisArg, body) {
124
+ var _ = { label: 0, sent: function () { if (t[0] & 1)
125
+ throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
126
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
127
+ function verb(n) { return function (v) { return step([n, v]); }; }
128
+ function step(op) {
129
+ if (f)
130
+ throw new TypeError("Generator is already executing.");
131
+ while (_)
132
+ try {
133
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
134
+ return t;
135
+ if (y = 0, t)
136
+ op = [op[0] & 2, t.value];
137
+ switch (op[0]) {
138
+ case 0:
139
+ case 1:
140
+ t = op;
141
+ break;
142
+ case 4:
143
+ _.label++;
144
+ return { value: op[1], done: false };
145
+ case 5:
146
+ _.label++;
147
+ y = op[1];
148
+ op = [0];
149
+ continue;
150
+ case 7:
151
+ op = _.ops.pop();
152
+ _.trys.pop();
153
+ continue;
154
+ default:
155
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
156
+ _ = 0;
157
+ continue;
158
+ }
159
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
160
+ _.label = op[1];
161
+ break;
162
+ }
163
+ if (op[0] === 6 && _.label < t[1]) {
164
+ _.label = t[1];
165
+ t = op;
166
+ break;
167
+ }
168
+ if (t && _.label < t[2]) {
169
+ _.label = t[2];
170
+ _.ops.push(op);
171
+ break;
172
+ }
173
+ if (t[2])
174
+ _.ops.pop();
175
+ _.trys.pop();
176
+ continue;
177
+ }
178
+ op = body.call(thisArg, _);
179
+ }
180
+ catch (e) {
181
+ op = [6, e];
182
+ y = 0;
183
+ }
184
+ finally {
185
+ f = t = 0;
186
+ }
187
+ if (op[0] & 5)
188
+ throw op[1];
189
+ return { value: op[0] ? op[1] : void 0, done: true };
190
+ }
191
+ }
192
+ var __createBinding = Object.create ? (function (o, m, k, k2) {
193
+ if (k2 === undefined)
194
+ k2 = k;
195
+ Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
196
+ }) : (function (o, m, k, k2) {
197
+ if (k2 === undefined)
198
+ k2 = k;
199
+ o[k2] = m[k];
200
+ });
201
+ function __exportStar(m, o) {
202
+ for (var p in m)
203
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
204
+ __createBinding(o, m, p);
205
+ }
206
+ function __values(o) {
207
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
208
+ if (m)
209
+ return m.call(o);
210
+ if (o && typeof o.length === "number")
211
+ return {
212
+ next: function () {
213
+ if (o && i >= o.length)
214
+ o = void 0;
215
+ return { value: o && o[i++], done: !o };
216
+ }
217
+ };
218
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
219
+ }
220
+ function __read(o, n) {
221
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
222
+ if (!m)
223
+ return o;
224
+ var i = m.call(o), r, ar = [], e;
225
+ try {
226
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
227
+ ar.push(r.value);
228
+ }
229
+ catch (error) {
230
+ e = { error: error };
231
+ }
232
+ finally {
233
+ try {
234
+ if (r && !r.done && (m = i["return"]))
235
+ m.call(i);
236
+ }
237
+ finally {
238
+ if (e)
239
+ throw e.error;
240
+ }
241
+ }
242
+ return ar;
243
+ }
244
+ /** @deprecated */
245
+ function __spread() {
246
+ for (var ar = [], i = 0; i < arguments.length; i++)
247
+ ar = ar.concat(__read(arguments[i]));
248
+ return ar;
249
+ }
250
+ /** @deprecated */
251
+ function __spreadArrays() {
252
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++)
253
+ s += arguments[i].length;
254
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
255
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
256
+ r[k] = a[j];
257
+ return r;
258
+ }
259
+ function __spreadArray(to, from, pack) {
260
+ if (pack || arguments.length === 2)
261
+ for (var i = 0, l = from.length, ar; i < l; i++) {
262
+ if (ar || !(i in from)) {
263
+ if (!ar)
264
+ ar = Array.prototype.slice.call(from, 0, i);
265
+ ar[i] = from[i];
266
+ }
267
+ }
268
+ return to.concat(ar || Array.prototype.slice.call(from));
269
+ }
270
+ function __await(v) {
271
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
272
+ }
273
+ function __asyncGenerator(thisArg, _arguments, generator) {
274
+ if (!Symbol.asyncIterator)
275
+ throw new TypeError("Symbol.asyncIterator is not defined.");
276
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
277
+ return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
278
+ function verb(n) { if (g[n])
279
+ i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
280
+ function resume(n, v) { try {
281
+ step(g[n](v));
282
+ }
283
+ catch (e) {
284
+ settle(q[0][3], e);
285
+ } }
286
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
287
+ function fulfill(value) { resume("next", value); }
288
+ function reject(value) { resume("throw", value); }
289
+ function settle(f, v) { if (f(v), q.shift(), q.length)
290
+ resume(q[0][0], q[0][1]); }
291
+ }
292
+ function __asyncDelegator(o) {
293
+ var i, p;
294
+ return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
295
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
296
+ }
297
+ function __asyncValues(o) {
298
+ if (!Symbol.asyncIterator)
299
+ throw new TypeError("Symbol.asyncIterator is not defined.");
300
+ var m = o[Symbol.asyncIterator], i;
301
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
302
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
303
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
304
+ }
305
+ function __makeTemplateObject(cooked, raw) {
306
+ if (Object.defineProperty) {
307
+ Object.defineProperty(cooked, "raw", { value: raw });
308
+ }
309
+ else {
310
+ cooked.raw = raw;
311
+ }
312
+ return cooked;
313
+ }
314
+ ;
315
+ var __setModuleDefault = Object.create ? (function (o, v) {
316
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
317
+ }) : function (o, v) {
318
+ o["default"] = v;
319
+ };
320
+ function __importStar(mod) {
321
+ if (mod && mod.__esModule)
322
+ return mod;
323
+ var result = {};
324
+ if (mod != null)
325
+ for (var k in mod)
326
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
327
+ __createBinding(result, mod, k);
328
+ __setModuleDefault(result, mod);
329
+ return result;
330
+ }
331
+ function __importDefault(mod) {
332
+ return (mod && mod.__esModule) ? mod : { default: mod };
333
+ }
334
+ function __classPrivateFieldGet(receiver, state, kind, f) {
335
+ if (kind === "a" && !f)
336
+ throw new TypeError("Private accessor was defined without a getter");
337
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
338
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
339
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
340
+ }
341
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
342
+ if (kind === "m")
343
+ throw new TypeError("Private method is not writable");
344
+ if (kind === "a" && !f)
345
+ throw new TypeError("Private accessor was defined without a setter");
346
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
347
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
348
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
349
+ }
350
+
351
+ var AuthService = /** @class */ (function () {
352
+ function AuthService(angularFireAuth, userRepository) {
353
+ this.angularFireAuth = angularFireAuth;
354
+ this.userRepository = userRepository;
355
+ }
356
+ AuthService.prototype.getAuthstate = function () {
357
+ var observables = [
358
+ this.angularFireAuth.authState.pipe(operators.catchError(function () { return rxjs.of(null); })),
359
+ this.getUser().pipe(operators.catchError(function () { return rxjs.of(null); })),
360
+ ];
361
+ return rxjs.combineLatest(observables).pipe(operators.map(function (_a) {
362
+ var _b = __read(_a, 2), fireUser = _b[0], user = _b[1];
363
+ return {
364
+ user: user,
365
+ isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
366
+ };
367
+ }));
368
+ };
369
+ AuthService.prototype.getUser = function () {
370
+ var _this = this;
371
+ return this.getFireUser().pipe(operators.map(function (user) { return user === null || user === void 0 ? void 0 : user.uid; }), operators.mergeMap(function (id) { return (id ? _this.userRepository.get({ id: id }) : rxjs.of(null)); }));
372
+ };
373
+ AuthService.prototype.getTokenId = function () {
374
+ return this.angularFireAuth.idToken;
375
+ };
376
+ AuthService.prototype.getFireUser = function () {
377
+ return this.angularFireAuth.user.pipe(operators.catchError(function () { return rxjs.of(null); }));
378
+ };
379
+ return AuthService;
380
+ }());
381
+ AuthService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AuthService, deps: [{ token: i1__namespace.AngularFireAuth }, { token: 'UserRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
382
+ AuthService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AuthService });
383
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AuthService, decorators: [{
384
+ type: i0.Injectable
385
+ }], ctorParameters: function () {
386
+ return [{ type: i1__namespace.AngularFireAuth }, { type: undefined, decorators: [{
387
+ type: i0.Inject,
388
+ args: ['UserRepository']
389
+ }] }];
63
390
  } });
64
391
 
65
392
  var DEFAULT_SHOP = 'DEFAULT_SHOP';
66
393
 
67
- /*! *****************************************************************************
68
- Copyright (c) Microsoft Corporation.
69
-
70
- Permission to use, copy, modify, and/or distribute this software for any
71
- purpose with or without fee is hereby granted.
72
-
73
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
74
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
75
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
76
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
77
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
78
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
79
- PERFORMANCE OF THIS SOFTWARE.
80
- ***************************************************************************** */
81
- /* global Reflect, Promise */
82
- var extendStatics = function (d, b) {
83
- extendStatics = Object.setPrototypeOf ||
84
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
85
- function (d, b) { for (var p in b)
86
- if (Object.prototype.hasOwnProperty.call(b, p))
87
- d[p] = b[p]; };
88
- return extendStatics(d, b);
89
- };
90
- function __extends(d, b) {
91
- if (typeof b !== "function" && b !== null)
92
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
93
- extendStatics(d, b);
94
- function __() { this.constructor = d; }
95
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
96
- }
97
- var __assign = function () {
98
- __assign = Object.assign || function __assign(t) {
99
- for (var s, i = 1, n = arguments.length; i < n; i++) {
100
- s = arguments[i];
101
- for (var p in s)
102
- if (Object.prototype.hasOwnProperty.call(s, p))
103
- t[p] = s[p];
104
- }
105
- return t;
106
- };
107
- return __assign.apply(this, arguments);
108
- };
109
- function __rest(s, e) {
110
- var t = {};
111
- for (var p in s)
112
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
113
- t[p] = s[p];
114
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
115
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
116
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
117
- t[p[i]] = s[p[i]];
118
- }
119
- return t;
120
- }
121
- function __decorate(decorators, target, key, desc) {
122
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
123
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
124
- r = Reflect.decorate(decorators, target, key, desc);
125
- else
126
- for (var i = decorators.length - 1; i >= 0; i--)
127
- if (d = decorators[i])
128
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
129
- return c > 3 && r && Object.defineProperty(target, key, r), r;
130
- }
131
- function __param(paramIndex, decorator) {
132
- return function (target, key) { decorator(target, key, paramIndex); };
133
- }
134
- function __metadata(metadataKey, metadataValue) {
135
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
136
- return Reflect.metadata(metadataKey, metadataValue);
137
- }
138
- function __awaiter(thisArg, _arguments, P, generator) {
139
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
140
- return new (P || (P = Promise))(function (resolve, reject) {
141
- function fulfilled(value) { try {
142
- step(generator.next(value));
143
- }
144
- catch (e) {
145
- reject(e);
146
- } }
147
- function rejected(value) { try {
148
- step(generator["throw"](value));
149
- }
150
- catch (e) {
151
- reject(e);
152
- } }
153
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
154
- step((generator = generator.apply(thisArg, _arguments || [])).next());
155
- });
156
- }
157
- function __generator(thisArg, body) {
158
- var _ = { label: 0, sent: function () { if (t[0] & 1)
159
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
160
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
161
- function verb(n) { return function (v) { return step([n, v]); }; }
162
- function step(op) {
163
- if (f)
164
- throw new TypeError("Generator is already executing.");
165
- while (_)
166
- try {
167
- 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)
168
- return t;
169
- if (y = 0, t)
170
- op = [op[0] & 2, t.value];
171
- switch (op[0]) {
172
- case 0:
173
- case 1:
174
- t = op;
175
- break;
176
- case 4:
177
- _.label++;
178
- return { value: op[1], done: false };
179
- case 5:
180
- _.label++;
181
- y = op[1];
182
- op = [0];
183
- continue;
184
- case 7:
185
- op = _.ops.pop();
186
- _.trys.pop();
187
- continue;
188
- default:
189
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
190
- _ = 0;
191
- continue;
192
- }
193
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
194
- _.label = op[1];
195
- break;
196
- }
197
- if (op[0] === 6 && _.label < t[1]) {
198
- _.label = t[1];
199
- t = op;
200
- break;
201
- }
202
- if (t && _.label < t[2]) {
203
- _.label = t[2];
204
- _.ops.push(op);
205
- break;
206
- }
207
- if (t[2])
208
- _.ops.pop();
209
- _.trys.pop();
210
- continue;
211
- }
212
- op = body.call(thisArg, _);
213
- }
214
- catch (e) {
215
- op = [6, e];
216
- y = 0;
217
- }
218
- finally {
219
- f = t = 0;
220
- }
221
- if (op[0] & 5)
222
- throw op[1];
223
- return { value: op[0] ? op[1] : void 0, done: true };
224
- }
225
- }
226
- var __createBinding = Object.create ? (function (o, m, k, k2) {
227
- if (k2 === undefined)
228
- k2 = k;
229
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
230
- }) : (function (o, m, k, k2) {
231
- if (k2 === undefined)
232
- k2 = k;
233
- o[k2] = m[k];
234
- });
235
- function __exportStar(m, o) {
236
- for (var p in m)
237
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
238
- __createBinding(o, m, p);
239
- }
240
- function __values(o) {
241
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
242
- if (m)
243
- return m.call(o);
244
- if (o && typeof o.length === "number")
245
- return {
246
- next: function () {
247
- if (o && i >= o.length)
248
- o = void 0;
249
- return { value: o && o[i++], done: !o };
250
- }
251
- };
252
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
253
- }
254
- function __read(o, n) {
255
- var m = typeof Symbol === "function" && o[Symbol.iterator];
256
- if (!m)
257
- return o;
258
- var i = m.call(o), r, ar = [], e;
259
- try {
260
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
261
- ar.push(r.value);
262
- }
263
- catch (error) {
264
- e = { error: error };
265
- }
266
- finally {
267
- try {
268
- if (r && !r.done && (m = i["return"]))
269
- m.call(i);
270
- }
271
- finally {
272
- if (e)
273
- throw e.error;
274
- }
275
- }
276
- return ar;
277
- }
278
- /** @deprecated */
279
- function __spread() {
280
- for (var ar = [], i = 0; i < arguments.length; i++)
281
- ar = ar.concat(__read(arguments[i]));
282
- return ar;
283
- }
284
- /** @deprecated */
285
- function __spreadArrays() {
286
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
287
- s += arguments[i].length;
288
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
289
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
290
- r[k] = a[j];
291
- return r;
292
- }
293
- function __spreadArray(to, from, pack) {
294
- if (pack || arguments.length === 2)
295
- for (var i = 0, l = from.length, ar; i < l; i++) {
296
- if (ar || !(i in from)) {
297
- if (!ar)
298
- ar = Array.prototype.slice.call(from, 0, i);
299
- ar[i] = from[i];
300
- }
301
- }
302
- return to.concat(ar || Array.prototype.slice.call(from));
303
- }
304
- function __await(v) {
305
- return this instanceof __await ? (this.v = v, this) : new __await(v);
306
- }
307
- function __asyncGenerator(thisArg, _arguments, generator) {
308
- if (!Symbol.asyncIterator)
309
- throw new TypeError("Symbol.asyncIterator is not defined.");
310
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
311
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
312
- function verb(n) { if (g[n])
313
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
314
- function resume(n, v) { try {
315
- step(g[n](v));
316
- }
317
- catch (e) {
318
- settle(q[0][3], e);
319
- } }
320
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
321
- function fulfill(value) { resume("next", value); }
322
- function reject(value) { resume("throw", value); }
323
- function settle(f, v) { if (f(v), q.shift(), q.length)
324
- resume(q[0][0], q[0][1]); }
325
- }
326
- function __asyncDelegator(o) {
327
- var i, p;
328
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
329
- 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; }
330
- }
331
- function __asyncValues(o) {
332
- if (!Symbol.asyncIterator)
333
- throw new TypeError("Symbol.asyncIterator is not defined.");
334
- var m = o[Symbol.asyncIterator], i;
335
- 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);
336
- 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); }); }; }
337
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
338
- }
339
- function __makeTemplateObject(cooked, raw) {
340
- if (Object.defineProperty) {
341
- Object.defineProperty(cooked, "raw", { value: raw });
342
- }
343
- else {
344
- cooked.raw = raw;
345
- }
346
- return cooked;
347
- }
348
- ;
349
- var __setModuleDefault = Object.create ? (function (o, v) {
350
- Object.defineProperty(o, "default", { enumerable: true, value: v });
351
- }) : function (o, v) {
352
- o["default"] = v;
353
- };
354
- function __importStar(mod) {
355
- if (mod && mod.__esModule)
356
- return mod;
357
- var result = {};
358
- if (mod != null)
359
- for (var k in mod)
360
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
361
- __createBinding(result, mod, k);
362
- __setModuleDefault(result, mod);
363
- return result;
364
- }
365
- function __importDefault(mod) {
366
- return (mod && mod.__esModule) ? mod : { default: mod };
367
- }
368
- function __classPrivateFieldGet(receiver, state, kind, f) {
369
- if (kind === "a" && !f)
370
- throw new TypeError("Private accessor was defined without a getter");
371
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
372
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
373
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
374
- }
375
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
376
- if (kind === "m")
377
- throw new TypeError("Private method is not writable");
378
- if (kind === "a" && !f)
379
- throw new TypeError("Private accessor was defined without a setter");
380
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
381
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
382
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
383
- }
384
-
385
- var CheckoutService = /** @class */ (function () {
386
- function CheckoutService(checkoutRepository, userRepository, defaultShop) {
387
- this.checkoutRepository = checkoutRepository;
388
- this.userRepository = userRepository;
389
- this.defaultShop = defaultShop;
390
- }
391
- CheckoutService.prototype.getCheckout = function (checkoutData) {
392
- var checkoutId = cookie__default["default"].get('checkoutId');
393
- if (!i1$1.isNil(checkoutId))
394
- return rxjs.from(this.checkoutRepository.get({ id: checkoutId }));
395
- return rxjs.from(this.createCheckout(checkoutData));
396
- };
397
- CheckoutService.prototype.getUserByCheckout = function (checkoutId) {
398
- var _this = this;
399
- 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 i1$1.NotFoundError('User is not found'); }); }));
400
- };
401
- CheckoutService.prototype.updateCheckoutLineItems = function (checkout) {
402
- return rxjs.from(this.checkoutRepository.update(i1$1.Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
403
- };
404
- CheckoutService.prototype.updateCheckoutUser = function (checkout) {
405
- return rxjs.from(this.checkoutRepository.update(i1$1.Checkout.toInstance({ id: checkout.id, user: checkout.user })));
406
- };
407
- CheckoutService.prototype.clearCheckoutFromSession = function () {
408
- cookie__default["default"].remove('checkoutId');
409
- return rxjs.of();
410
- };
411
- CheckoutService.prototype.createCheckout = function (checkoutData) {
412
- return __awaiter(this, void 0, void 0, function () {
413
- var checkout;
414
- return __generator(this, function (_b) {
415
- switch (_b.label) {
416
- case 0: return [4 /*yield*/, this.checkoutRepository.create(Object.assign(Object.assign({ createdAt: new Date() }, i1$1.Checkout.toInstance(i1$1.pick(checkoutData, ['user', 'shop'])).toPlain()), { shop: (checkoutData === null || checkoutData === void 0 ? void 0 : checkoutData.shop) || this.defaultShop }))];
417
- case 1:
418
- checkout = _b.sent();
419
- cookie__default["default"].set('checkoutId', checkout.id);
420
- return [2 /*return*/, checkout];
421
- }
422
- });
423
- });
424
- };
425
- return CheckoutService;
426
- }());
427
- CheckoutService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService, deps: [{ token: 'CheckoutRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
428
- CheckoutService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService });
429
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService, decorators: [{
430
- type: i0.Injectable
431
- }], ctorParameters: function () {
432
- return [{ type: undefined, decorators: [{
433
- type: i0.Inject,
434
- args: ['CheckoutRepository']
435
- }] }, { type: undefined, decorators: [{
436
- type: i0.Inject,
437
- args: ['UserRepository']
438
- }] }, { type: i1__namespace$1.Shops, decorators: [{
439
- type: i0.Inject,
440
- args: [DEFAULT_SHOP]
441
- }] }];
394
+ var CheckoutService = /** @class */ (function () {
395
+ function CheckoutService(checkoutRepository, userRepository, defaultShop) {
396
+ this.checkoutRepository = checkoutRepository;
397
+ this.userRepository = userRepository;
398
+ this.defaultShop = defaultShop;
399
+ }
400
+ CheckoutService.prototype.getCheckout = function (checkoutData) {
401
+ var checkoutId = cookie__default["default"].get('checkoutId');
402
+ if (!i1$1.isNil(checkoutId))
403
+ return rxjs.from(this.checkoutRepository.get({ id: checkoutId }));
404
+ return rxjs.from(this.createCheckout(checkoutData));
405
+ };
406
+ CheckoutService.prototype.getUserByCheckout = function (checkoutId) {
407
+ var _this = this;
408
+ 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 i1$1.NotFoundError('User is not found'); }); }));
409
+ };
410
+ CheckoutService.prototype.updateCheckoutLineItems = function (checkout) {
411
+ return rxjs.from(this.checkoutRepository.update(i1$1.Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
412
+ };
413
+ CheckoutService.prototype.updateCheckoutUser = function (checkout) {
414
+ return rxjs.from(this.checkoutRepository.update(i1$1.Checkout.toInstance({ id: checkout.id, user: checkout.user })));
415
+ };
416
+ CheckoutService.prototype.clearCheckoutFromSession = function () {
417
+ cookie__default["default"].remove('checkoutId');
418
+ return rxjs.of();
419
+ };
420
+ CheckoutService.prototype.createCheckout = function (checkoutData) {
421
+ return __awaiter(this, void 0, void 0, function () {
422
+ var checkout;
423
+ return __generator(this, function (_b) {
424
+ switch (_b.label) {
425
+ case 0: return [4 /*yield*/, this.checkoutRepository.create(Object.assign(Object.assign({ createdAt: new Date() }, i1$1.Checkout.toInstance(i1$1.pick(checkoutData, ['user', 'shop'])).toPlain()), { shop: (checkoutData === null || checkoutData === void 0 ? void 0 : checkoutData.shop) || this.defaultShop }))];
426
+ case 1:
427
+ checkout = _b.sent();
428
+ cookie__default["default"].set('checkoutId', checkout.id);
429
+ return [2 /*return*/, checkout];
430
+ }
431
+ });
432
+ });
433
+ };
434
+ return CheckoutService;
435
+ }());
436
+ CheckoutService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService, deps: [{ token: 'CheckoutRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
437
+ CheckoutService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService });
438
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService, decorators: [{
439
+ type: i0.Injectable
440
+ }], ctorParameters: function () {
441
+ return [{ type: undefined, decorators: [{
442
+ type: i0.Inject,
443
+ args: ['CheckoutRepository']
444
+ }] }, { type: undefined, decorators: [{
445
+ type: i0.Inject,
446
+ args: ['UserRepository']
447
+ }] }, { type: i1__namespace$1.Shops, decorators: [{
448
+ type: i0.Inject,
449
+ args: [DEFAULT_SHOP]
450
+ }] }];
442
451
  } });
443
452
 
444
- var CartService = /** @class */ (function () {
445
- function CartService(authService, checkoutService, defaultShop) {
446
- var _this = this;
447
- this.authService = authService;
448
- this.checkoutService = checkoutService;
449
- this.defaultShop = defaultShop;
450
- this.cartSubject = new rxjs.Subject();
451
- this.updateLineItemInCart = function (lineItem, quantity, checkout) { return (i1$1.isNil(checkout) ? _this.checkoutService.getCheckout() : rxjs.of(checkout)).pipe(operators.concatMap(function (checkoutLoaded) {
452
- var _a;
453
- var items = [];
454
- var index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map(function (checkoutItem) { return checkoutItem.sku; }).indexOf(lineItem.sku);
455
- if (index > -1) {
456
- checkoutLoaded.lineItems[index].quantity += quantity;
457
- checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
458
- }
459
- else
460
- checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
461
- return _this.checkoutService
462
- .updateCheckoutLineItems(checkoutLoaded)
463
- .pipe(operators.map(function (updatedCheckout) { return _this.generateCartObject(updatedCheckout.lineItems); }));
464
- })); };
465
- this.generateCartObject = function (items) {
466
- var cart = {};
467
- items === null || items === void 0 ? void 0 : items.forEach(function (item) {
468
- var _a;
469
- return (cart[item.sku] = i1$1.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) })));
470
- });
471
- return cart;
472
- };
473
- this.buildLineItem = function (_f) {
474
- var checkout = _f.checkout, item = _f.item, quantity = _f.quantity;
475
- var _a, _b, _c, _d, _e;
476
- 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;
477
- if (_this.checkMaxStock(item, quantity || 0))
478
- throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
479
- var image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
480
- 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;
481
- var isGift = item.isGift || null;
482
- var pricePaid = _this.getProductPrice({
483
- product: item,
484
- shop: checkout.shop || _this.defaultShop,
485
- isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
486
- });
487
- return i1$1.LineItem.toInstance({
488
- id: id,
489
- name: name,
490
- brand: brand,
491
- slug: slug,
492
- sku: sku,
493
- stock: stock,
494
- price: price,
495
- image: image,
496
- weight: weight,
497
- quantity: (item.quantity || 0) + (quantity || 0),
498
- pricePaid: pricePaid,
499
- categories: categories,
500
- isGift: isGift,
501
- });
502
- };
503
- this.getProductPrice = function (_f) {
504
- var product = _f.product, shop = _f.shop, isSubscriber = _f.isSubscriber;
505
- var info = product.getInfoByShop(shop);
506
- if (product.isGift)
507
- return 0;
508
- return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
509
- };
510
- this.checkMaxStock = function (item, quantity) {
511
- var _a;
512
- var maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
513
- var currentItemAmount = item.quantity || 0;
514
- return currentItemAmount + quantity > maxStock;
515
- };
516
- }
517
- CartService.prototype.addItem = function (item, quantity) {
518
- var _this = this;
519
- if (quantity === void 0) { quantity = 1; }
520
- 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) {
521
- var checkout = _f.checkout, lineItem = _f.lineItem;
522
- return _this.updateLineItemInCart(lineItem, quantity || 1, checkout);
523
- }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
524
- };
525
- CartService.prototype.decreaseItem = function (item) {
526
- var _this = this;
527
- return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
528
- var _a;
529
- var checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find(function (lineItem) { return lineItem.sku === item.sku; });
530
- if (!i1$1.isNil(checkoutItem))
531
- checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
532
- return checkout;
533
- }), 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); }));
534
- };
535
- CartService.prototype.getCart = function (checkout) {
536
- var _this = this;
537
- this.buildCartFromCheckout(checkout).subscribe(function (cart) { return _this.cartSubject.next(cart); });
538
- return this.cartSubject;
539
- };
540
- CartService.prototype.getDiscount = function (coupon) {
541
- switch (coupon.type) {
542
- case i1$1.CouponTypes.FINANCIAL:
543
- return this.getFinancialDiscount(coupon);
544
- case i1$1.CouponTypes.PRODUCT:
545
- return function (subTotalPrice) { return subTotalPrice; };
546
- case i1$1.CouponTypes.GIFTCARD:
547
- return this.getFinancialDiscount(coupon);
548
- case i1$1.CouponTypes.VOUCHER:
549
- return function (subTotalPrice) { return subTotalPrice; };
550
- }
551
- };
552
- CartService.prototype.getVariantPriceDiscount = function (item, shop) {
553
- 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); }));
554
- };
555
- CartService.prototype.removeItem = function (item) {
556
- var _this = this;
557
- return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
558
- var index = checkout.lineItems.findIndex(function (lineItem) { return lineItem.sku === item.sku; });
559
- if (index >= 0)
560
- checkout.lineItems.splice(index, 1);
561
- return checkout;
562
- }), 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); }));
563
- };
564
- CartService.prototype.updateUserCart = function (user) {
565
- var _this = this;
566
- return this.checkoutService.getCheckout().pipe(operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutUser(i1$1.Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user: user }))); }), operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutLineItems(i1$1.Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: checkout.lineItems.map(function (item) { return _this.buildLineItem({ checkout: checkout, item: item }); }) }))); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
567
- };
568
- CartService.prototype.clearCart = function () {
569
- var _this = this;
570
- return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
571
- _this.checkoutService.clearCheckoutFromSession();
572
- return checkout;
573
- }), operators.concatMap(function (oldCheckout) { return _this.buildCartFromCheckout(oldCheckout); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
574
- };
575
- CartService.prototype.buildCartFromCheckout = function (checkoutData) {
576
- var _this = this;
577
- return this.checkoutService.getCheckout(checkoutData).pipe(operators.map(function (checkout) { return checkout.lineItems; }), operators.concatMap(function (lineItems) { return rxjs.of(_this.generateCartObject(lineItems)); }));
578
- };
579
- CartService.prototype.getFinancialDiscount = function (coupon) {
580
- return function (subTotalPrice) {
581
- if (i1$1.FinancialCoupon.isFinancialCoupon(coupon))
582
- switch (coupon.subtype) {
583
- case i1$1.CouponSubtypes.ABSOLUTE:
584
- return subTotalPrice - coupon.discount * 100;
585
- case i1$1.CouponSubtypes.PERCENTAGE:
586
- return subTotalPrice * (1 - coupon.discount / 100);
587
- }
588
- };
589
- };
590
- return CartService;
591
- }());
592
- 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 });
593
- CartService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService });
594
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService, decorators: [{
595
- type: i0.Injectable
596
- }], ctorParameters: function () {
597
- return [{ type: AuthService }, { type: CheckoutService }, { type: i1__namespace$1.Shops, decorators: [{
598
- type: i0.Inject,
599
- args: [DEFAULT_SHOP]
600
- }] }];
453
+ var CartService = /** @class */ (function () {
454
+ function CartService(authService, checkoutService, defaultShop) {
455
+ var _this = this;
456
+ this.authService = authService;
457
+ this.checkoutService = checkoutService;
458
+ this.defaultShop = defaultShop;
459
+ this.cartSubject = new rxjs.Subject();
460
+ this.updateLineItemInCart = function (lineItem, quantity, checkout) { return (i1$1.isNil(checkout) ? _this.checkoutService.getCheckout() : rxjs.of(checkout)).pipe(operators.concatMap(function (checkoutLoaded) {
461
+ var _a;
462
+ var items = [];
463
+ var index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map(function (checkoutItem) { return checkoutItem.sku; }).indexOf(lineItem.sku);
464
+ if (index > -1) {
465
+ checkoutLoaded.lineItems[index].quantity += quantity;
466
+ checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
467
+ }
468
+ else
469
+ checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
470
+ return _this.checkoutService
471
+ .updateCheckoutLineItems(checkoutLoaded)
472
+ .pipe(operators.map(function (updatedCheckout) { return _this.generateCartObject(updatedCheckout.lineItems); }));
473
+ })); };
474
+ this.generateCartObject = function (items) {
475
+ var cart = {};
476
+ items === null || items === void 0 ? void 0 : items.forEach(function (item) {
477
+ var _a;
478
+ return (cart[item.sku] = i1$1.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) })));
479
+ });
480
+ return cart;
481
+ };
482
+ this.buildLineItem = function (_f) {
483
+ var checkout = _f.checkout, item = _f.item, quantity = _f.quantity;
484
+ var _a, _b, _c, _d, _e;
485
+ 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;
486
+ if (_this.checkMaxStock(item, quantity || 0))
487
+ throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
488
+ var image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
489
+ 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;
490
+ var isGift = item.isGift || null;
491
+ var pricePaid = _this.getProductPrice({
492
+ product: item,
493
+ shop: checkout.shop || _this.defaultShop,
494
+ isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
495
+ });
496
+ return i1$1.LineItem.toInstance({
497
+ id: id,
498
+ name: name,
499
+ brand: brand,
500
+ slug: slug,
501
+ sku: sku,
502
+ stock: stock,
503
+ price: price,
504
+ image: image,
505
+ weight: weight,
506
+ quantity: (item.quantity || 0) + (quantity || 0),
507
+ pricePaid: pricePaid,
508
+ categories: categories,
509
+ isGift: isGift,
510
+ });
511
+ };
512
+ this.getProductPrice = function (_f) {
513
+ var product = _f.product, shop = _f.shop, isSubscriber = _f.isSubscriber;
514
+ var info = product.getInfoByShop(shop);
515
+ if (product.isGift)
516
+ return 0;
517
+ return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
518
+ };
519
+ this.checkMaxStock = function (item, quantity) {
520
+ var _a;
521
+ var maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
522
+ var currentItemAmount = item.quantity || 0;
523
+ return currentItemAmount + quantity > maxStock;
524
+ };
525
+ }
526
+ CartService.prototype.addItem = function (item, quantity) {
527
+ var _this = this;
528
+ if (quantity === void 0) { quantity = 1; }
529
+ 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) {
530
+ var checkout = _f.checkout, lineItem = _f.lineItem;
531
+ return _this.updateLineItemInCart(lineItem, quantity || 1, checkout);
532
+ }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
533
+ };
534
+ CartService.prototype.decreaseItem = function (item) {
535
+ var _this = this;
536
+ return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
537
+ var _a;
538
+ var checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find(function (lineItem) { return lineItem.sku === item.sku; });
539
+ if (!i1$1.isNil(checkoutItem))
540
+ checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
541
+ return checkout;
542
+ }), 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); }));
543
+ };
544
+ CartService.prototype.getCart = function (checkout) {
545
+ var _this = this;
546
+ this.buildCartFromCheckout(checkout).subscribe(function (cart) { return _this.cartSubject.next(cart); });
547
+ return this.cartSubject;
548
+ };
549
+ CartService.prototype.getDiscount = function (coupon) {
550
+ switch (coupon.type) {
551
+ case i1$1.CouponTypes.FINANCIAL:
552
+ return this.getFinancialDiscount(coupon);
553
+ case i1$1.CouponTypes.PRODUCT:
554
+ return function (subTotalPrice) { return subTotalPrice; };
555
+ case i1$1.CouponTypes.GIFTCARD:
556
+ return this.getFinancialDiscount(coupon);
557
+ case i1$1.CouponTypes.VOUCHER:
558
+ return function (subTotalPrice) { return subTotalPrice; };
559
+ }
560
+ };
561
+ CartService.prototype.getVariantPriceDiscount = function (item, shop) {
562
+ 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); }));
563
+ };
564
+ CartService.prototype.removeItem = function (item) {
565
+ var _this = this;
566
+ return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
567
+ var index = checkout.lineItems.findIndex(function (lineItem) { return lineItem.sku === item.sku; });
568
+ if (index >= 0)
569
+ checkout.lineItems.splice(index, 1);
570
+ return checkout;
571
+ }), 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); }));
572
+ };
573
+ CartService.prototype.updateUserCart = function (user) {
574
+ var _this = this;
575
+ return this.checkoutService.getCheckout().pipe(operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutUser(i1$1.Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user: user }))); }), operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutLineItems(i1$1.Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: checkout.lineItems.map(function (item) { return _this.buildLineItem({ checkout: checkout, item: item }); }) }))); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
576
+ };
577
+ CartService.prototype.clearCart = function () {
578
+ var _this = this;
579
+ return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
580
+ _this.checkoutService.clearCheckoutFromSession();
581
+ return checkout;
582
+ }), operators.concatMap(function (oldCheckout) { return _this.buildCartFromCheckout(oldCheckout); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
583
+ };
584
+ CartService.prototype.buildCartFromCheckout = function (checkoutData) {
585
+ var _this = this;
586
+ return this.checkoutService.getCheckout(checkoutData).pipe(operators.map(function (checkout) { return checkout.lineItems; }), operators.concatMap(function (lineItems) { return rxjs.of(_this.generateCartObject(lineItems)); }));
587
+ };
588
+ CartService.prototype.getFinancialDiscount = function (coupon) {
589
+ return function (subTotalPrice) {
590
+ if (i1$1.FinancialCoupon.isFinancialCoupon(coupon))
591
+ switch (coupon.subtype) {
592
+ case i1$1.CouponSubtypes.ABSOLUTE:
593
+ return subTotalPrice - coupon.discount * 100;
594
+ case i1$1.CouponSubtypes.PERCENTAGE:
595
+ return subTotalPrice * (1 - coupon.discount / 100);
596
+ }
597
+ };
598
+ };
599
+ return CartService;
600
+ }());
601
+ 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 });
602
+ CartService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService });
603
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService, decorators: [{
604
+ type: i0.Injectable
605
+ }], ctorParameters: function () {
606
+ return [{ type: AuthService }, { type: CheckoutService }, { type: i1__namespace$1.Shops, decorators: [{
607
+ type: i0.Inject,
608
+ args: [DEFAULT_SHOP]
609
+ }] }];
601
610
  } });
602
611
 
603
- var CheckoutSubscriptionService = /** @class */ (function () {
604
- function CheckoutSubscriptionService(checkoutSubscriptionRepository) {
605
- this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
606
- }
607
- CheckoutSubscriptionService.prototype.getCheckoutSubscription = function (checkoutData) {
608
- var checkoutId = cookie__default["default"].get('checkoutSubscriptionId');
609
- if (!i1$1.isNil(checkoutId))
610
- return rxjs.from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
611
- return rxjs.from(this.createCheckoutSubscription(checkoutData));
612
- };
613
- CheckoutSubscriptionService.prototype.createCheckoutSubscription = function (checkoutData) {
614
- return __awaiter(this, void 0, void 0, function () {
615
- var checkout;
616
- return __generator(this, function (_a) {
617
- switch (_a.label) {
618
- case 0: return [4 /*yield*/, this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, i1$1.CheckoutSubscription.toInstance(i1$1.pick(checkoutData, ['user', 'shop'])).toPlain()))];
619
- case 1:
620
- checkout = _a.sent();
621
- cookie__default["default"].set('checkoutSubscriptionId', checkout.id);
622
- return [2 /*return*/, checkout];
623
- }
624
- });
625
- });
626
- };
627
- CheckoutSubscriptionService.prototype.clearCheckoutSubscriptionFromSession = function () {
628
- cookie__default["default"].remove('checkoutSubscriptionId');
629
- return rxjs.of();
630
- };
631
- return CheckoutSubscriptionService;
632
- }());
633
- 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 });
634
- CheckoutSubscriptionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService });
635
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService, decorators: [{
636
- type: i0.Injectable
637
- }], ctorParameters: function () {
638
- return [{ type: undefined, decorators: [{
639
- type: i0.Inject,
640
- args: ['CheckoutSubscriptionRepository']
641
- }] }];
612
+ var CheckoutSubscriptionService = /** @class */ (function () {
613
+ function CheckoutSubscriptionService(checkoutSubscriptionRepository) {
614
+ this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
615
+ }
616
+ CheckoutSubscriptionService.prototype.getCheckoutSubscription = function (checkoutData) {
617
+ var checkoutId = cookie__default["default"].get('checkoutSubscriptionId');
618
+ if (!i1$1.isNil(checkoutId))
619
+ return rxjs.from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
620
+ return rxjs.from(this.createCheckoutSubscription(checkoutData));
621
+ };
622
+ CheckoutSubscriptionService.prototype.createCheckoutSubscription = function (checkoutData) {
623
+ return __awaiter(this, void 0, void 0, function () {
624
+ var checkout;
625
+ return __generator(this, function (_a) {
626
+ switch (_a.label) {
627
+ case 0: return [4 /*yield*/, this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, i1$1.CheckoutSubscription.toInstance(i1$1.pick(checkoutData, ['user', 'shop'])).toPlain()))];
628
+ case 1:
629
+ checkout = _a.sent();
630
+ cookie__default["default"].set('checkoutSubscriptionId', checkout.id);
631
+ return [2 /*return*/, checkout];
632
+ }
633
+ });
634
+ });
635
+ };
636
+ CheckoutSubscriptionService.prototype.clearCheckoutSubscriptionFromSession = function () {
637
+ cookie__default["default"].remove('checkoutSubscriptionId');
638
+ return rxjs.of();
639
+ };
640
+ return CheckoutSubscriptionService;
641
+ }());
642
+ 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 });
643
+ CheckoutSubscriptionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService });
644
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService, decorators: [{
645
+ type: i0.Injectable
646
+ }], ctorParameters: function () {
647
+ return [{ type: undefined, decorators: [{
648
+ type: i0.Inject,
649
+ args: ['CheckoutSubscriptionRepository']
650
+ }] }];
642
651
  } });
643
652
 
644
- var OrderService = /** @class */ (function () {
645
- function OrderService(angularFirestore, orderRepository) {
646
- this.angularFirestore = angularFirestore;
647
- this.orderRepository = orderRepository;
648
- this.orderSubject = new rxjs.Subject();
649
- }
650
- OrderService.prototype.getOrder = function (id) {
651
- var _this = this;
652
- this.angularFirestore
653
- .doc(this.orderRepository.collectionName + "/" + id)
654
- .valueChanges()
655
- .pipe(operators.map(function (doc) { return i1$1.Order.toInstance(doc); }))
656
- .subscribe(function (doc) { return _this.orderSubject.next(doc); });
657
- return this.orderSubject;
658
- };
659
- return OrderService;
660
- }());
661
- OrderService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService, deps: [{ token: i1__namespace$2.AngularFirestore }, { token: 'OrderRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
662
- OrderService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService });
663
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService, decorators: [{
664
- type: i0.Injectable
665
- }], ctorParameters: function () {
666
- return [{ type: i1__namespace$2.AngularFirestore }, { type: i1__namespace$1.OrderFirestoreRepository, decorators: [{
667
- type: i0.Inject,
668
- args: ['OrderRepository']
669
- }] }];
653
+ var OrderService = /** @class */ (function () {
654
+ function OrderService(angularFirestore, orderRepository) {
655
+ this.angularFirestore = angularFirestore;
656
+ this.orderRepository = orderRepository;
657
+ this.orderSubject = new rxjs.Subject();
658
+ }
659
+ OrderService.prototype.getOrder = function (id) {
660
+ var _this = this;
661
+ this.angularFirestore
662
+ .doc(this.orderRepository.collectionName + "/" + id)
663
+ .valueChanges()
664
+ .pipe(operators.map(function (doc) { return i1$1.Order.toInstance(doc); }))
665
+ .subscribe(function (doc) { return _this.orderSubject.next(doc); });
666
+ return this.orderSubject;
667
+ };
668
+ return OrderService;
669
+ }());
670
+ OrderService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService, deps: [{ token: i1__namespace$2.AngularFirestore }, { token: 'OrderRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
671
+ OrderService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService });
672
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService, decorators: [{
673
+ type: i0.Injectable
674
+ }], ctorParameters: function () {
675
+ return [{ type: i1__namespace$2.AngularFirestore }, { type: i1__namespace$1.OrderFirestoreRepository, decorators: [{
676
+ type: i0.Inject,
677
+ args: ['OrderRepository']
678
+ }] }];
670
679
  } });
671
680
 
672
- var AngularFirebaseAuthModule = /** @class */ (function () {
673
- function AngularFirebaseAuthModule() {
674
- }
675
- AngularFirebaseAuthModule.initializeApp = function (options, nameOrConfig) {
676
- return {
677
- ngModule: AngularFirebaseAuthModule,
678
- providers: [
679
- { provide: fire.FIREBASE_OPTIONS, useValue: options },
680
- { provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
681
- ],
682
- };
683
- };
684
- return AngularFirebaseAuthModule;
685
- }());
686
- AngularFirebaseAuthModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
687
- AngularFirebaseAuthModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, imports: [fire.AngularFireModule] });
688
- AngularFirebaseAuthModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, providers: [
689
- {
690
- provide: 'Authentication',
691
- useFactory: function (authenticationService, userRepository) {
692
- return new i1$1.Authentication(authenticationService, userRepository);
693
- },
694
- deps: ['AuthenticationService', 'UserRepository'],
695
- },
696
- {
697
- provide: 'AuthenticationService',
698
- useFactory: function (angularFireAuth) {
699
- return new i1$1.AuthenticationFirebaseAuthService(angularFireAuth);
700
- },
701
- deps: [i1.AngularFireAuth],
702
- },
703
- {
704
- provide: 'SignOut',
705
- useFactory: function (authenticationService) {
706
- return new i1$1.SignOut(authenticationService);
707
- },
708
- deps: ['AuthenticationService'],
709
- },
710
- ], imports: [[fire.AngularFireModule]] });
711
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, decorators: [{
712
- type: i0.NgModule,
713
- args: [{
714
- imports: [fire.AngularFireModule],
715
- providers: [
716
- {
717
- provide: 'Authentication',
718
- useFactory: function (authenticationService, userRepository) {
719
- return new i1$1.Authentication(authenticationService, userRepository);
720
- },
721
- deps: ['AuthenticationService', 'UserRepository'],
722
- },
723
- {
724
- provide: 'AuthenticationService',
725
- useFactory: function (angularFireAuth) {
726
- return new i1$1.AuthenticationFirebaseAuthService(angularFireAuth);
727
- },
728
- deps: [i1.AngularFireAuth],
729
- },
730
- {
731
- provide: 'SignOut',
732
- useFactory: function (authenticationService) {
733
- return new i1$1.SignOut(authenticationService);
734
- },
735
- deps: ['AuthenticationService'],
736
- },
737
- ],
738
- }]
681
+ var AngularFirebaseAuthModule = /** @class */ (function () {
682
+ function AngularFirebaseAuthModule() {
683
+ }
684
+ AngularFirebaseAuthModule.initializeApp = function (options, nameOrConfig) {
685
+ return {
686
+ ngModule: AngularFirebaseAuthModule,
687
+ providers: [
688
+ { provide: fire.FIREBASE_OPTIONS, useValue: options },
689
+ { provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
690
+ ],
691
+ };
692
+ };
693
+ return AngularFirebaseAuthModule;
694
+ }());
695
+ AngularFirebaseAuthModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
696
+ AngularFirebaseAuthModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, imports: [fire.AngularFireModule] });
697
+ AngularFirebaseAuthModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, providers: [
698
+ {
699
+ provide: 'Authentication',
700
+ useFactory: function (authenticationService, userRepository) {
701
+ return new i1$1.Authentication(authenticationService, userRepository);
702
+ },
703
+ deps: ['AuthenticationService', 'UserRepository'],
704
+ },
705
+ {
706
+ provide: 'AuthenticationService',
707
+ useFactory: function (angularFireAuth) {
708
+ return new i1$1.AuthenticationFirebaseAuthService(angularFireAuth);
709
+ },
710
+ deps: [i1.AngularFireAuth],
711
+ },
712
+ {
713
+ provide: 'SignOut',
714
+ useFactory: function (authenticationService) {
715
+ return new i1$1.SignOut(authenticationService);
716
+ },
717
+ deps: ['AuthenticationService'],
718
+ },
719
+ ], imports: [[fire.AngularFireModule]] });
720
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, decorators: [{
721
+ type: i0.NgModule,
722
+ args: [{
723
+ imports: [fire.AngularFireModule],
724
+ providers: [
725
+ {
726
+ provide: 'Authentication',
727
+ useFactory: function (authenticationService, userRepository) {
728
+ return new i1$1.Authentication(authenticationService, userRepository);
729
+ },
730
+ deps: ['AuthenticationService', 'UserRepository'],
731
+ },
732
+ {
733
+ provide: 'AuthenticationService',
734
+ useFactory: function (angularFireAuth) {
735
+ return new i1$1.AuthenticationFirebaseAuthService(angularFireAuth);
736
+ },
737
+ deps: [i1.AngularFireAuth],
738
+ },
739
+ {
740
+ provide: 'SignOut',
741
+ useFactory: function (authenticationService) {
742
+ return new i1$1.SignOut(authenticationService);
743
+ },
744
+ deps: ['AuthenticationService'],
745
+ },
746
+ ],
747
+ }]
739
748
  }] });
740
749
 
741
- var AngularFirestoreModule = /** @class */ (function () {
742
- function AngularFirestoreModule() {
743
- }
744
- AngularFirestoreModule.initializeApp = function (options, nameOrConfig) {
745
- return {
746
- ngModule: AngularFirestoreModule,
747
- providers: [
748
- { provide: fire.FIREBASE_OPTIONS, useValue: options },
749
- { provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
750
- ],
751
- };
752
- };
753
- return AngularFirestoreModule;
754
- }());
755
- AngularFirestoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
756
- AngularFirestoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, imports: [fire.AngularFireModule] });
757
- AngularFirestoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, providers: [
758
- {
759
- provide: 'BeautyProfileRepository',
760
- useFactory: function (firestore, userRepository) {
761
- return new i1$1.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
762
- },
763
- deps: [i1$2.AngularFirestore, 'UserRepository'],
764
- },
765
- {
766
- provide: 'Buy2WinRepository',
767
- useFactory: function (firestore) {
768
- return new i1$1.Buy2WinFirestoreRepository(firestore.firestore);
769
- },
770
- deps: [i1$2.AngularFirestore],
771
- },
772
- {
773
- provide: 'CategoryRepository',
774
- useFactory: function (firestore) {
775
- return new i1$1.CategoryFirestoreRepository(firestore.firestore);
776
- },
777
- deps: [i1$2.AngularFirestore],
778
- },
779
- {
780
- provide: 'CheckoutRepository',
781
- useFactory: function (firestore) {
782
- return new i1$1.CheckoutFirestoreRepository(firestore.firestore);
783
- },
784
- deps: [i1$2.AngularFirestore],
785
- },
786
- {
787
- provide: 'CheckoutSubscriptionRepository',
788
- useFactory: function (firestore) {
789
- return new i1$1.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
790
- },
791
- deps: [i1$2.AngularFirestore],
792
- },
793
- {
794
- provide: 'CouponRepository',
795
- useFactory: function (firestore) {
796
- return new i1$1.CouponFirestoreRepository(firestore.firestore);
797
- },
798
- deps: [i1$2.AngularFirestore],
799
- },
800
- {
801
- provide: 'EditionRepository',
802
- useFactory: function (firestore, subscriptionRepository) {
803
- return new i1$1.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
804
- },
805
- deps: [i1$2.AngularFirestore, 'SubscriptionRepository'],
806
- },
807
- {
808
- provide: 'HomeRepository',
809
- useFactory: function (firestore) {
810
- return new i1$1.HomeFirestoreRepository(firestore.firestore);
811
- },
812
- deps: [i1$2.AngularFirestore],
813
- },
814
- {
815
- provide: 'LeadRepository',
816
- useFactory: function (firestore) {
817
- return new i1$1.LeadFirestoreRepository(firestore.firestore);
818
- },
819
- deps: [i1$2.AngularFirestore],
820
- },
821
- {
822
- provide: 'LegacyOrderRepository',
823
- useFactory: function (firestore) {
824
- return new i1$1.LegacyOrderFirestoreRepository(firestore.firestore);
825
- },
826
- deps: [i1$2.AngularFirestore],
827
- },
828
- {
829
- provide: 'ShopMenuRepository',
830
- useFactory: function (firestore) {
831
- return new i1$1.ShopMenuFirestoreRepository(firestore.firestore);
832
- },
833
- deps: [i1$2.AngularFirestore],
834
- },
835
- {
836
- provide: 'OrderRepository',
837
- useFactory: function (firestore) {
838
- return new i1$1.OrderFirestoreRepository(firestore.firestore);
839
- },
840
- deps: [i1$2.AngularFirestore],
841
- },
842
- {
843
- provide: 'PaymentRepository',
844
- useFactory: function (firestore) {
845
- return new i1$1.PaymentFirestoreRepository(firestore.firestore);
846
- },
847
- deps: [i1$2.AngularFirestore],
848
- },
849
- {
850
- provide: 'ProductRepository',
851
- useFactory: function (firestore) {
852
- return new i1$1.ProductFirestoreRepository(firestore.firestore);
853
- },
854
- deps: [i1$2.AngularFirestore],
855
- },
856
- {
857
- provide: 'SubscriptionPaymentRepository',
858
- useFactory: function (firestore, subscriptionRepository) {
859
- return new i1$1.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
860
- },
861
- deps: [i1$2.AngularFirestore, 'SubscriptionRepository'],
862
- },
863
- {
864
- provide: 'SubscriptionPlanRepository',
865
- useFactory: function (firestore) {
866
- return new i1$1.SubscriptionPlanFirestoreRepository(firestore.firestore);
867
- },
868
- deps: [i1$2.AngularFirestore],
869
- },
870
- {
871
- provide: 'SubscriptionRepository',
872
- useFactory: function (firestore) {
873
- return new i1$1.SubscriptionFirestoreRepository(firestore.firestore);
874
- },
875
- deps: [i1$2.AngularFirestore],
876
- },
877
- {
878
- provide: 'UserRepository',
879
- useFactory: function (firestore) {
880
- return new i1$1.UserFirestoreRepository(firestore.firestore);
881
- },
882
- deps: [i1$2.AngularFirestore],
883
- },
884
- {
885
- provide: 'UserAddressRepository',
886
- useFactory: function (firestore, userRepository) {
887
- return new i1$1.UserAddressFirestoreRepository(firestore.firestore, userRepository);
888
- },
889
- deps: [i1$2.AngularFirestore, 'UserRepository'],
890
- },
891
- {
892
- provide: 'UserPaymentMethodRepository',
893
- useFactory: function (firestore, userRepository) {
894
- return new i1$1.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
895
- },
896
- deps: [i1$2.AngularFirestore, 'UserRepository'],
897
- },
898
- {
899
- provide: 'VariantRepository',
900
- useFactory: function (firestore, productRepository) {
901
- return new i1$1.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
902
- },
903
- deps: [i1$2.AngularFirestore, 'ProductRepository'],
904
- },
905
- ], imports: [[fire.AngularFireModule]] });
906
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, decorators: [{
907
- type: i0.NgModule,
908
- args: [{
909
- imports: [fire.AngularFireModule],
910
- providers: [
911
- {
912
- provide: 'BeautyProfileRepository',
913
- useFactory: function (firestore, userRepository) {
914
- return new i1$1.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
915
- },
916
- deps: [i1$2.AngularFirestore, 'UserRepository'],
917
- },
918
- {
919
- provide: 'Buy2WinRepository',
920
- useFactory: function (firestore) {
921
- return new i1$1.Buy2WinFirestoreRepository(firestore.firestore);
922
- },
923
- deps: [i1$2.AngularFirestore],
924
- },
925
- {
926
- provide: 'CategoryRepository',
927
- useFactory: function (firestore) {
928
- return new i1$1.CategoryFirestoreRepository(firestore.firestore);
929
- },
930
- deps: [i1$2.AngularFirestore],
931
- },
932
- {
933
- provide: 'CheckoutRepository',
934
- useFactory: function (firestore) {
935
- return new i1$1.CheckoutFirestoreRepository(firestore.firestore);
936
- },
937
- deps: [i1$2.AngularFirestore],
938
- },
939
- {
940
- provide: 'CheckoutSubscriptionRepository',
941
- useFactory: function (firestore) {
942
- return new i1$1.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
943
- },
944
- deps: [i1$2.AngularFirestore],
945
- },
946
- {
947
- provide: 'CouponRepository',
948
- useFactory: function (firestore) {
949
- return new i1$1.CouponFirestoreRepository(firestore.firestore);
950
- },
951
- deps: [i1$2.AngularFirestore],
952
- },
953
- {
954
- provide: 'EditionRepository',
955
- useFactory: function (firestore, subscriptionRepository) {
956
- return new i1$1.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
957
- },
958
- deps: [i1$2.AngularFirestore, 'SubscriptionRepository'],
959
- },
960
- {
961
- provide: 'HomeRepository',
962
- useFactory: function (firestore) {
963
- return new i1$1.HomeFirestoreRepository(firestore.firestore);
964
- },
965
- deps: [i1$2.AngularFirestore],
966
- },
967
- {
968
- provide: 'LeadRepository',
969
- useFactory: function (firestore) {
970
- return new i1$1.LeadFirestoreRepository(firestore.firestore);
971
- },
972
- deps: [i1$2.AngularFirestore],
973
- },
974
- {
975
- provide: 'LegacyOrderRepository',
976
- useFactory: function (firestore) {
977
- return new i1$1.LegacyOrderFirestoreRepository(firestore.firestore);
978
- },
979
- deps: [i1$2.AngularFirestore],
980
- },
981
- {
982
- provide: 'ShopMenuRepository',
983
- useFactory: function (firestore) {
984
- return new i1$1.ShopMenuFirestoreRepository(firestore.firestore);
985
- },
986
- deps: [i1$2.AngularFirestore],
987
- },
988
- {
989
- provide: 'OrderRepository',
990
- useFactory: function (firestore) {
991
- return new i1$1.OrderFirestoreRepository(firestore.firestore);
992
- },
993
- deps: [i1$2.AngularFirestore],
994
- },
995
- {
996
- provide: 'PaymentRepository',
997
- useFactory: function (firestore) {
998
- return new i1$1.PaymentFirestoreRepository(firestore.firestore);
999
- },
1000
- deps: [i1$2.AngularFirestore],
1001
- },
1002
- {
1003
- provide: 'ProductRepository',
1004
- useFactory: function (firestore) {
1005
- return new i1$1.ProductFirestoreRepository(firestore.firestore);
1006
- },
1007
- deps: [i1$2.AngularFirestore],
1008
- },
1009
- {
1010
- provide: 'SubscriptionPaymentRepository',
1011
- useFactory: function (firestore, subscriptionRepository) {
1012
- return new i1$1.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1013
- },
1014
- deps: [i1$2.AngularFirestore, 'SubscriptionRepository'],
1015
- },
1016
- {
1017
- provide: 'SubscriptionPlanRepository',
1018
- useFactory: function (firestore) {
1019
- return new i1$1.SubscriptionPlanFirestoreRepository(firestore.firestore);
1020
- },
1021
- deps: [i1$2.AngularFirestore],
1022
- },
1023
- {
1024
- provide: 'SubscriptionRepository',
1025
- useFactory: function (firestore) {
1026
- return new i1$1.SubscriptionFirestoreRepository(firestore.firestore);
1027
- },
1028
- deps: [i1$2.AngularFirestore],
1029
- },
1030
- {
1031
- provide: 'UserRepository',
1032
- useFactory: function (firestore) {
1033
- return new i1$1.UserFirestoreRepository(firestore.firestore);
1034
- },
1035
- deps: [i1$2.AngularFirestore],
1036
- },
1037
- {
1038
- provide: 'UserAddressRepository',
1039
- useFactory: function (firestore, userRepository) {
1040
- return new i1$1.UserAddressFirestoreRepository(firestore.firestore, userRepository);
1041
- },
1042
- deps: [i1$2.AngularFirestore, 'UserRepository'],
1043
- },
1044
- {
1045
- provide: 'UserPaymentMethodRepository',
1046
- useFactory: function (firestore, userRepository) {
1047
- return new i1$1.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1048
- },
1049
- deps: [i1$2.AngularFirestore, 'UserRepository'],
1050
- },
1051
- {
1052
- provide: 'VariantRepository',
1053
- useFactory: function (firestore, productRepository) {
1054
- return new i1$1.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1055
- },
1056
- deps: [i1$2.AngularFirestore, 'ProductRepository'],
1057
- },
1058
- ],
1059
- }]
750
+ var AngularFirestoreModule = /** @class */ (function () {
751
+ function AngularFirestoreModule() {
752
+ }
753
+ AngularFirestoreModule.initializeApp = function (options, nameOrConfig) {
754
+ return {
755
+ ngModule: AngularFirestoreModule,
756
+ providers: [
757
+ { provide: fire.FIREBASE_OPTIONS, useValue: options },
758
+ { provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
759
+ ],
760
+ };
761
+ };
762
+ return AngularFirestoreModule;
763
+ }());
764
+ AngularFirestoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
765
+ AngularFirestoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, imports: [fire.AngularFireModule] });
766
+ AngularFirestoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, providers: [
767
+ {
768
+ provide: 'BeautyProfileRepository',
769
+ useFactory: function (firestore, userRepository) {
770
+ return new i1$1.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
771
+ },
772
+ deps: [i1$2.AngularFirestore, 'UserRepository'],
773
+ },
774
+ {
775
+ provide: 'Buy2WinRepository',
776
+ useFactory: function (firestore) {
777
+ return new i1$1.Buy2WinFirestoreRepository(firestore.firestore);
778
+ },
779
+ deps: [i1$2.AngularFirestore],
780
+ },
781
+ {
782
+ provide: 'CategoryRepository',
783
+ useFactory: function (firestore) {
784
+ return new i1$1.CategoryFirestoreRepository(firestore.firestore);
785
+ },
786
+ deps: [i1$2.AngularFirestore],
787
+ },
788
+ {
789
+ provide: 'CheckoutRepository',
790
+ useFactory: function (firestore) {
791
+ return new i1$1.CheckoutFirestoreRepository(firestore.firestore);
792
+ },
793
+ deps: [i1$2.AngularFirestore],
794
+ },
795
+ {
796
+ provide: 'CheckoutSubscriptionRepository',
797
+ useFactory: function (firestore) {
798
+ return new i1$1.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
799
+ },
800
+ deps: [i1$2.AngularFirestore],
801
+ },
802
+ {
803
+ provide: 'CouponRepository',
804
+ useFactory: function (firestore) {
805
+ return new i1$1.CouponFirestoreRepository(firestore.firestore);
806
+ },
807
+ deps: [i1$2.AngularFirestore],
808
+ },
809
+ {
810
+ provide: 'EditionRepository',
811
+ useFactory: function (firestore, subscriptionRepository) {
812
+ return new i1$1.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
813
+ },
814
+ deps: [i1$2.AngularFirestore, 'SubscriptionRepository'],
815
+ },
816
+ {
817
+ provide: 'HomeRepository',
818
+ useFactory: function (firestore) {
819
+ return new i1$1.HomeFirestoreRepository(firestore.firestore);
820
+ },
821
+ deps: [i1$2.AngularFirestore],
822
+ },
823
+ {
824
+ provide: 'LeadRepository',
825
+ useFactory: function (firestore) {
826
+ return new i1$1.LeadFirestoreRepository(firestore.firestore);
827
+ },
828
+ deps: [i1$2.AngularFirestore],
829
+ },
830
+ {
831
+ provide: 'LegacyOrderRepository',
832
+ useFactory: function (firestore) {
833
+ return new i1$1.LegacyOrderFirestoreRepository(firestore.firestore);
834
+ },
835
+ deps: [i1$2.AngularFirestore],
836
+ },
837
+ {
838
+ provide: 'ShopMenuRepository',
839
+ useFactory: function (firestore) {
840
+ return new i1$1.ShopMenuFirestoreRepository(firestore.firestore);
841
+ },
842
+ deps: [i1$2.AngularFirestore],
843
+ },
844
+ {
845
+ provide: 'OrderRepository',
846
+ useFactory: function (firestore) {
847
+ return new i1$1.OrderFirestoreRepository(firestore.firestore);
848
+ },
849
+ deps: [i1$2.AngularFirestore],
850
+ },
851
+ {
852
+ provide: 'PaymentRepository',
853
+ useFactory: function (firestore) {
854
+ return new i1$1.PaymentFirestoreRepository(firestore.firestore);
855
+ },
856
+ deps: [i1$2.AngularFirestore],
857
+ },
858
+ {
859
+ provide: 'ProductRepository',
860
+ useFactory: function (firestore) {
861
+ return new i1$1.ProductFirestoreRepository(firestore.firestore);
862
+ },
863
+ deps: [i1$2.AngularFirestore],
864
+ },
865
+ {
866
+ provide: 'SubscriptionPaymentRepository',
867
+ useFactory: function (firestore, subscriptionRepository) {
868
+ return new i1$1.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
869
+ },
870
+ deps: [i1$2.AngularFirestore, 'SubscriptionRepository'],
871
+ },
872
+ {
873
+ provide: 'SubscriptionPlanRepository',
874
+ useFactory: function (firestore) {
875
+ return new i1$1.SubscriptionPlanFirestoreRepository(firestore.firestore);
876
+ },
877
+ deps: [i1$2.AngularFirestore],
878
+ },
879
+ {
880
+ provide: 'SubscriptionRepository',
881
+ useFactory: function (firestore) {
882
+ return new i1$1.SubscriptionFirestoreRepository(firestore.firestore);
883
+ },
884
+ deps: [i1$2.AngularFirestore],
885
+ },
886
+ {
887
+ provide: 'UserRepository',
888
+ useFactory: function (firestore) {
889
+ return new i1$1.UserFirestoreRepository(firestore.firestore);
890
+ },
891
+ deps: [i1$2.AngularFirestore],
892
+ },
893
+ {
894
+ provide: 'UserAddressRepository',
895
+ useFactory: function (firestore, userRepository) {
896
+ return new i1$1.UserAddressFirestoreRepository(firestore.firestore, userRepository);
897
+ },
898
+ deps: [i1$2.AngularFirestore, 'UserRepository'],
899
+ },
900
+ {
901
+ provide: 'UserPaymentMethodRepository',
902
+ useFactory: function (firestore, userRepository) {
903
+ return new i1$1.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
904
+ },
905
+ deps: [i1$2.AngularFirestore, 'UserRepository'],
906
+ },
907
+ {
908
+ provide: 'VariantRepository',
909
+ useFactory: function (firestore, productRepository) {
910
+ return new i1$1.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
911
+ },
912
+ deps: [i1$2.AngularFirestore, 'ProductRepository'],
913
+ },
914
+ ], imports: [[fire.AngularFireModule]] });
915
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, decorators: [{
916
+ type: i0.NgModule,
917
+ args: [{
918
+ imports: [fire.AngularFireModule],
919
+ providers: [
920
+ {
921
+ provide: 'BeautyProfileRepository',
922
+ useFactory: function (firestore, userRepository) {
923
+ return new i1$1.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
924
+ },
925
+ deps: [i1$2.AngularFirestore, 'UserRepository'],
926
+ },
927
+ {
928
+ provide: 'Buy2WinRepository',
929
+ useFactory: function (firestore) {
930
+ return new i1$1.Buy2WinFirestoreRepository(firestore.firestore);
931
+ },
932
+ deps: [i1$2.AngularFirestore],
933
+ },
934
+ {
935
+ provide: 'CategoryRepository',
936
+ useFactory: function (firestore) {
937
+ return new i1$1.CategoryFirestoreRepository(firestore.firestore);
938
+ },
939
+ deps: [i1$2.AngularFirestore],
940
+ },
941
+ {
942
+ provide: 'CheckoutRepository',
943
+ useFactory: function (firestore) {
944
+ return new i1$1.CheckoutFirestoreRepository(firestore.firestore);
945
+ },
946
+ deps: [i1$2.AngularFirestore],
947
+ },
948
+ {
949
+ provide: 'CheckoutSubscriptionRepository',
950
+ useFactory: function (firestore) {
951
+ return new i1$1.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
952
+ },
953
+ deps: [i1$2.AngularFirestore],
954
+ },
955
+ {
956
+ provide: 'CouponRepository',
957
+ useFactory: function (firestore) {
958
+ return new i1$1.CouponFirestoreRepository(firestore.firestore);
959
+ },
960
+ deps: [i1$2.AngularFirestore],
961
+ },
962
+ {
963
+ provide: 'EditionRepository',
964
+ useFactory: function (firestore, subscriptionRepository) {
965
+ return new i1$1.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
966
+ },
967
+ deps: [i1$2.AngularFirestore, 'SubscriptionRepository'],
968
+ },
969
+ {
970
+ provide: 'HomeRepository',
971
+ useFactory: function (firestore) {
972
+ return new i1$1.HomeFirestoreRepository(firestore.firestore);
973
+ },
974
+ deps: [i1$2.AngularFirestore],
975
+ },
976
+ {
977
+ provide: 'LeadRepository',
978
+ useFactory: function (firestore) {
979
+ return new i1$1.LeadFirestoreRepository(firestore.firestore);
980
+ },
981
+ deps: [i1$2.AngularFirestore],
982
+ },
983
+ {
984
+ provide: 'LegacyOrderRepository',
985
+ useFactory: function (firestore) {
986
+ return new i1$1.LegacyOrderFirestoreRepository(firestore.firestore);
987
+ },
988
+ deps: [i1$2.AngularFirestore],
989
+ },
990
+ {
991
+ provide: 'ShopMenuRepository',
992
+ useFactory: function (firestore) {
993
+ return new i1$1.ShopMenuFirestoreRepository(firestore.firestore);
994
+ },
995
+ deps: [i1$2.AngularFirestore],
996
+ },
997
+ {
998
+ provide: 'OrderRepository',
999
+ useFactory: function (firestore) {
1000
+ return new i1$1.OrderFirestoreRepository(firestore.firestore);
1001
+ },
1002
+ deps: [i1$2.AngularFirestore],
1003
+ },
1004
+ {
1005
+ provide: 'PaymentRepository',
1006
+ useFactory: function (firestore) {
1007
+ return new i1$1.PaymentFirestoreRepository(firestore.firestore);
1008
+ },
1009
+ deps: [i1$2.AngularFirestore],
1010
+ },
1011
+ {
1012
+ provide: 'ProductRepository',
1013
+ useFactory: function (firestore) {
1014
+ return new i1$1.ProductFirestoreRepository(firestore.firestore);
1015
+ },
1016
+ deps: [i1$2.AngularFirestore],
1017
+ },
1018
+ {
1019
+ provide: 'SubscriptionPaymentRepository',
1020
+ useFactory: function (firestore, subscriptionRepository) {
1021
+ return new i1$1.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1022
+ },
1023
+ deps: [i1$2.AngularFirestore, 'SubscriptionRepository'],
1024
+ },
1025
+ {
1026
+ provide: 'SubscriptionPlanRepository',
1027
+ useFactory: function (firestore) {
1028
+ return new i1$1.SubscriptionPlanFirestoreRepository(firestore.firestore);
1029
+ },
1030
+ deps: [i1$2.AngularFirestore],
1031
+ },
1032
+ {
1033
+ provide: 'SubscriptionRepository',
1034
+ useFactory: function (firestore) {
1035
+ return new i1$1.SubscriptionFirestoreRepository(firestore.firestore);
1036
+ },
1037
+ deps: [i1$2.AngularFirestore],
1038
+ },
1039
+ {
1040
+ provide: 'UserRepository',
1041
+ useFactory: function (firestore) {
1042
+ return new i1$1.UserFirestoreRepository(firestore.firestore);
1043
+ },
1044
+ deps: [i1$2.AngularFirestore],
1045
+ },
1046
+ {
1047
+ provide: 'UserAddressRepository',
1048
+ useFactory: function (firestore, userRepository) {
1049
+ return new i1$1.UserAddressFirestoreRepository(firestore.firestore, userRepository);
1050
+ },
1051
+ deps: [i1$2.AngularFirestore, 'UserRepository'],
1052
+ },
1053
+ {
1054
+ provide: 'UserPaymentMethodRepository',
1055
+ useFactory: function (firestore, userRepository) {
1056
+ return new i1$1.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1057
+ },
1058
+ deps: [i1$2.AngularFirestore, 'UserRepository'],
1059
+ },
1060
+ {
1061
+ provide: 'VariantRepository',
1062
+ useFactory: function (firestore, productRepository) {
1063
+ return new i1$1.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1064
+ },
1065
+ deps: [i1$2.AngularFirestore, 'ProductRepository'],
1066
+ },
1067
+ ],
1068
+ }]
1060
1069
  }] });
1061
1070
 
1062
- var AngularConnectModule = /** @class */ (function () {
1063
- function AngularConnectModule() {
1064
- }
1065
- AngularConnectModule.initializeApp = function (defaultShop, options, nameOrConfig) {
1066
- return {
1067
- ngModule: AngularConnectModule,
1068
- providers: __spreadArray(__spreadArray(__spreadArray([], __read((i1$1.isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]))), __read((i1$1.isNil(options) ? [] : [{ provide: fire.FIREBASE_OPTIONS, useValue: options }]))), __read((i1$1.isNil(options) ? [] : [{ provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig }]))),
1069
- };
1070
- };
1071
- return AngularConnectModule;
1072
- }());
1073
- AngularConnectModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1074
- AngularConnectModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, imports: [fire.AngularFireModule, AngularFirestoreModule] });
1075
- AngularConnectModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, providers: [AuthService, CartService, CheckoutService, CheckoutSubscriptionService, OrderService], imports: [[fire.AngularFireModule, AngularFirestoreModule]] });
1076
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, decorators: [{
1077
- type: i0.NgModule,
1078
- args: [{
1079
- imports: [fire.AngularFireModule, AngularFirestoreModule],
1080
- providers: [AuthService, CartService, CheckoutService, CheckoutSubscriptionService, OrderService],
1081
- }]
1071
+ var AngularConnectModule = /** @class */ (function () {
1072
+ function AngularConnectModule() {
1073
+ }
1074
+ AngularConnectModule.initializeApp = function (defaultShop, options, nameOrConfig) {
1075
+ return {
1076
+ ngModule: AngularConnectModule,
1077
+ providers: __spreadArray(__spreadArray(__spreadArray([], __read((i1$1.isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]))), __read((i1$1.isNil(options) ? [] : [{ provide: fire.FIREBASE_OPTIONS, useValue: options }]))), __read((i1$1.isNil(options) ? [] : [{ provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig }]))),
1078
+ };
1079
+ };
1080
+ return AngularConnectModule;
1081
+ }());
1082
+ AngularConnectModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1083
+ AngularConnectModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, imports: [fire.AngularFireModule, AngularFirestoreModule] });
1084
+ AngularConnectModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, providers: [AuthService, CartService, CheckoutService, CheckoutSubscriptionService, OrderService], imports: [[fire.AngularFireModule, AngularFirestoreModule]] });
1085
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, decorators: [{
1086
+ type: i0.NgModule,
1087
+ args: [{
1088
+ imports: [fire.AngularFireModule, AngularFirestoreModule],
1089
+ providers: [AuthService, CartService, CheckoutService, CheckoutSubscriptionService, OrderService],
1090
+ }]
1082
1091
  }] });
1083
1092
 
1084
- /**
1085
- * Generated bundle index. Do not edit.
1093
+ /**
1094
+ * Generated bundle index. Do not edit.
1086
1095
  */
1087
1096
 
1088
1097
  exports.AngularConnectModule = AngularConnectModule;