@infrab4a/connect 4.2.2 → 4.2.3-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.cjs.js +629 -769
  2. package/index.esm.js +465 -587
  3. package/package.json +1 -1
package/index.cjs.js CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  require('reflect-metadata');
6
6
  var classTransformer = require('class-transformer');
7
- var tslib_1 = require('tslib');
7
+ var tslib = require('tslib');
8
8
  var dateFns = require('date-fns');
9
9
  var lodash = require('lodash');
10
10
  var debug = require('debug');
@@ -16,25 +16,6 @@ var gqlQueryBuilder = require('gql-query-builder');
16
16
 
17
17
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
18
18
 
19
- function _interopNamespace(e) {
20
- if (e && e.__esModule) return e;
21
- var n = Object.create(null);
22
- if (e) {
23
- Object.keys(e).forEach(function (k) {
24
- if (k !== 'default') {
25
- var d = Object.getOwnPropertyDescriptor(e, k);
26
- Object.defineProperty(n, k, d.get ? d : {
27
- enumerable: true,
28
- get: function () { return e[k]; }
29
- });
30
- }
31
- });
32
- }
33
- n["default"] = e;
34
- return Object.freeze(n);
35
- }
36
-
37
- var tslib_1__namespace = /*#__PURE__*/_interopNamespace(tslib_1);
38
19
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
39
20
 
40
21
  class BaseModel {
@@ -316,165 +297,165 @@ class Payment extends BaseModel {
316
297
  return ['id'];
317
298
  }
318
299
  }
319
- tslib_1.__decorate([
300
+ tslib.__decorate([
320
301
  classTransformer.Expose({ name: 'refuse_reason' }),
321
- tslib_1.__metadata("design:type", String)
302
+ tslib.__metadata("design:type", String)
322
303
  ], Payment.prototype, "refuseReason", void 0);
323
- tslib_1.__decorate([
304
+ tslib.__decorate([
324
305
  classTransformer.Expose({ name: 'status_reason' }),
325
- tslib_1.__metadata("design:type", String)
306
+ tslib.__metadata("design:type", String)
326
307
  ], Payment.prototype, "statusReason", void 0);
327
- tslib_1.__decorate([
308
+ tslib.__decorate([
328
309
  classTransformer.Expose({ name: 'acquirer_response_code' }),
329
- tslib_1.__metadata("design:type", String)
310
+ tslib.__metadata("design:type", String)
330
311
  ], Payment.prototype, "acquirerResponseCode", void 0);
331
- tslib_1.__decorate([
312
+ tslib.__decorate([
332
313
  classTransformer.Expose({ name: 'acquirer_name' }),
333
- tslib_1.__metadata("design:type", String)
314
+ tslib.__metadata("design:type", String)
334
315
  ], Payment.prototype, "acquirerName", void 0);
335
- tslib_1.__decorate([
316
+ tslib.__decorate([
336
317
  classTransformer.Expose({ name: 'acquirer_id' }),
337
- tslib_1.__metadata("design:type", String)
318
+ tslib.__metadata("design:type", String)
338
319
  ], Payment.prototype, "acquirerId", void 0);
339
- tslib_1.__decorate([
320
+ tslib.__decorate([
340
321
  classTransformer.Expose({ name: 'authorization_code' }),
341
- tslib_1.__metadata("design:type", String)
322
+ tslib.__metadata("design:type", String)
342
323
  ], Payment.prototype, "authorizationCode", void 0);
343
- tslib_1.__decorate([
324
+ tslib.__decorate([
344
325
  classTransformer.Expose({ name: 'soft_descriptor' }),
345
- tslib_1.__metadata("design:type", String)
326
+ tslib.__metadata("design:type", String)
346
327
  ], Payment.prototype, "softDescriptor", void 0);
347
- tslib_1.__decorate([
328
+ tslib.__decorate([
348
329
  classTransformer.Expose({ name: 'date_created' }),
349
- tslib_1.__metadata("design:type", String)
330
+ tslib.__metadata("design:type", String)
350
331
  ], Payment.prototype, "dateCreated", void 0);
351
- tslib_1.__decorate([
332
+ tslib.__decorate([
352
333
  classTransformer.Expose({ name: 'date_updated' }),
353
- tslib_1.__metadata("design:type", String)
334
+ tslib.__metadata("design:type", String)
354
335
  ], Payment.prototype, "dateUpdated", void 0);
355
- tslib_1.__decorate([
336
+ tslib.__decorate([
356
337
  classTransformer.Expose({ name: 'authorized_amount' }),
357
- tslib_1.__metadata("design:type", Number)
338
+ tslib.__metadata("design:type", Number)
358
339
  ], Payment.prototype, "authorizedAmount", void 0);
359
- tslib_1.__decorate([
340
+ tslib.__decorate([
360
341
  classTransformer.Expose({ name: 'paid_amount' }),
361
- tslib_1.__metadata("design:type", Number)
342
+ tslib.__metadata("design:type", Number)
362
343
  ], Payment.prototype, "paidAmount", void 0);
363
- tslib_1.__decorate([
344
+ tslib.__decorate([
364
345
  classTransformer.Expose({ name: 'refunded_amount' }),
365
- tslib_1.__metadata("design:type", Number)
346
+ tslib.__metadata("design:type", Number)
366
347
  ], Payment.prototype, "refundedAmount", void 0);
367
- tslib_1.__decorate([
348
+ tslib.__decorate([
368
349
  classTransformer.Expose({ name: 'card_holder_name' }),
369
- tslib_1.__metadata("design:type", String)
350
+ tslib.__metadata("design:type", String)
370
351
  ], Payment.prototype, "cardHolderName", void 0);
371
- tslib_1.__decorate([
352
+ tslib.__decorate([
372
353
  classTransformer.Expose({ name: 'card_last_digits' }),
373
- tslib_1.__metadata("design:type", String)
354
+ tslib.__metadata("design:type", String)
374
355
  ], Payment.prototype, "cardLastDigits", void 0);
375
- tslib_1.__decorate([
356
+ tslib.__decorate([
376
357
  classTransformer.Expose({ name: 'card_first_digits' }),
377
- tslib_1.__metadata("design:type", String)
358
+ tslib.__metadata("design:type", String)
378
359
  ], Payment.prototype, "cardFirstDigits", void 0);
379
- tslib_1.__decorate([
360
+ tslib.__decorate([
380
361
  classTransformer.Expose({ name: 'card_brand' }),
381
- tslib_1.__metadata("design:type", String)
362
+ tslib.__metadata("design:type", String)
382
363
  ], Payment.prototype, "cardBrand", void 0);
383
- tslib_1.__decorate([
364
+ tslib.__decorate([
384
365
  classTransformer.Expose({ name: 'card_pin_mode' }),
385
- tslib_1.__metadata("design:type", String)
366
+ tslib.__metadata("design:type", String)
386
367
  ], Payment.prototype, "cardPinMode", void 0);
387
- tslib_1.__decorate([
368
+ tslib.__decorate([
388
369
  classTransformer.Expose({ name: 'card_magstripe_fallback' }),
389
- tslib_1.__metadata("design:type", Boolean)
370
+ tslib.__metadata("design:type", Boolean)
390
371
  ], Payment.prototype, "cardMagstripeFallback", void 0);
391
- tslib_1.__decorate([
372
+ tslib.__decorate([
392
373
  classTransformer.Expose({ name: 'cvm_pin' }),
393
- tslib_1.__metadata("design:type", Boolean)
374
+ tslib.__metadata("design:type", Boolean)
394
375
  ], Payment.prototype, "cvmPin", void 0);
395
- tslib_1.__decorate([
376
+ tslib.__decorate([
396
377
  classTransformer.Expose({ name: 'postback_url' }),
397
- tslib_1.__metadata("design:type", String)
378
+ tslib.__metadata("design:type", String)
398
379
  ], Payment.prototype, "postbackUrl", void 0);
399
- tslib_1.__decorate([
380
+ tslib.__decorate([
400
381
  classTransformer.Expose({ name: 'payment_method' }),
401
- tslib_1.__metadata("design:type", String)
382
+ tslib.__metadata("design:type", String)
402
383
  ], Payment.prototype, "paymentMethod", void 0);
403
- tslib_1.__decorate([
384
+ tslib.__decorate([
404
385
  classTransformer.Expose({ name: 'capture_method' }),
405
- tslib_1.__metadata("design:type", String)
386
+ tslib.__metadata("design:type", String)
406
387
  ], Payment.prototype, "captureMethod", void 0);
407
- tslib_1.__decorate([
388
+ tslib.__decorate([
408
389
  classTransformer.Expose({ name: 'antifraud_score' }),
409
- tslib_1.__metadata("design:type", String)
390
+ tslib.__metadata("design:type", String)
410
391
  ], Payment.prototype, "antifraudScore", void 0);
411
- tslib_1.__decorate([
392
+ tslib.__decorate([
412
393
  classTransformer.Expose({ name: 'boleto_url' }),
413
- tslib_1.__metadata("design:type", String)
394
+ tslib.__metadata("design:type", String)
414
395
  ], Payment.prototype, "boletoUrl", void 0);
415
- tslib_1.__decorate([
396
+ tslib.__decorate([
416
397
  classTransformer.Expose({ name: 'boleto_barcode' }),
417
- tslib_1.__metadata("design:type", String)
398
+ tslib.__metadata("design:type", String)
418
399
  ], Payment.prototype, "boletoBarcode", void 0);
419
- tslib_1.__decorate([
400
+ tslib.__decorate([
420
401
  classTransformer.Expose({ name: 'boleto_expiration_date' }),
421
- tslib_1.__metadata("design:type", String)
402
+ tslib.__metadata("design:type", String)
422
403
  ], Payment.prototype, "boletoExpirationDate", void 0);
423
- tslib_1.__decorate([
404
+ tslib.__decorate([
424
405
  classTransformer.Expose({ name: 'subscription_id' }),
425
- tslib_1.__metadata("design:type", String)
406
+ tslib.__metadata("design:type", String)
426
407
  ], Payment.prototype, "subscriptionId", void 0);
427
- tslib_1.__decorate([
408
+ tslib.__decorate([
428
409
  classTransformer.Expose({ name: 'split_rules' }),
429
- tslib_1.__metadata("design:type", String)
410
+ tslib.__metadata("design:type", String)
430
411
  ], Payment.prototype, "splitRules", void 0);
431
- tslib_1.__decorate([
412
+ tslib.__decorate([
432
413
  classTransformer.Expose({ name: 'antifraud_metadata' }),
433
- tslib_1.__metadata("design:type", Object)
414
+ tslib.__metadata("design:type", Object)
434
415
  ], Payment.prototype, "antifraudMetadata", void 0);
435
- tslib_1.__decorate([
416
+ tslib.__decorate([
436
417
  classTransformer.Expose({ name: 'reference_key' }),
437
- tslib_1.__metadata("design:type", String)
418
+ tslib.__metadata("design:type", String)
438
419
  ], Payment.prototype, "referenceKey", void 0);
439
- tslib_1.__decorate([
420
+ tslib.__decorate([
440
421
  classTransformer.Expose({ name: 'local_transaction_id' }),
441
- tslib_1.__metadata("design:type", String)
422
+ tslib.__metadata("design:type", String)
442
423
  ], Payment.prototype, "localTransactionId", void 0);
443
- tslib_1.__decorate([
424
+ tslib.__decorate([
444
425
  classTransformer.Expose({ name: 'local_time' }),
445
- tslib_1.__metadata("design:type", String)
426
+ tslib.__metadata("design:type", String)
446
427
  ], Payment.prototype, "localTime", void 0);
447
- tslib_1.__decorate([
428
+ tslib.__decorate([
448
429
  classTransformer.Expose({ name: 'fraud_covered' }),
449
- tslib_1.__metadata("design:type", Boolean)
430
+ tslib.__metadata("design:type", Boolean)
450
431
  ], Payment.prototype, "fraudCovered", void 0);
451
- tslib_1.__decorate([
432
+ tslib.__decorate([
452
433
  classTransformer.Expose({ name: 'fraud_reimbursed' }),
453
- tslib_1.__metadata("design:type", String)
434
+ tslib.__metadata("design:type", String)
454
435
  ], Payment.prototype, "fraudReimbursed", void 0);
455
- tslib_1.__decorate([
436
+ tslib.__decorate([
456
437
  classTransformer.Expose({ name: 'order_id' }),
457
- tslib_1.__metadata("design:type", String)
438
+ tslib.__metadata("design:type", String)
458
439
  ], Payment.prototype, "orderId", void 0);
459
- tslib_1.__decorate([
440
+ tslib.__decorate([
460
441
  classTransformer.Expose({ name: 'risk_level' }),
461
- tslib_1.__metadata("design:type", String)
442
+ tslib.__metadata("design:type", String)
462
443
  ], Payment.prototype, "riskLevel", void 0);
463
- tslib_1.__decorate([
444
+ tslib.__decorate([
464
445
  classTransformer.Expose({ name: 'receipt_url' }),
465
- tslib_1.__metadata("design:type", String)
446
+ tslib.__metadata("design:type", String)
466
447
  ], Payment.prototype, "receiptUrl", void 0);
467
- tslib_1.__decorate([
448
+ tslib.__decorate([
468
449
  classTransformer.Expose({ name: 'private_label' }),
469
- tslib_1.__metadata("design:type", String)
450
+ tslib.__metadata("design:type", String)
470
451
  ], Payment.prototype, "privateLabel", void 0);
471
- tslib_1.__decorate([
452
+ tslib.__decorate([
472
453
  classTransformer.Expose({ name: 'pix_qr_code' }),
473
- tslib_1.__metadata("design:type", String)
454
+ tslib.__metadata("design:type", String)
474
455
  ], Payment.prototype, "pixQrCode", void 0);
475
- tslib_1.__decorate([
456
+ tslib.__decorate([
476
457
  classTransformer.Expose({ name: 'pix_expiration_date' }),
477
- tslib_1.__metadata("design:type", String)
458
+ tslib.__metadata("design:type", String)
478
459
  ], Payment.prototype, "pixExpirationDate", void 0);
479
460
 
480
461
  class SubscriptionPayment extends BaseModel {
@@ -482,483 +463,406 @@ class SubscriptionPayment extends BaseModel {
482
463
  return ['id', 'subscriptionId'];
483
464
  }
484
465
  }
485
- tslib_1.__decorate([
466
+ tslib.__decorate([
486
467
  classTransformer.Type(() => Payment),
487
- tslib_1.__metadata("design:type", Payment)
468
+ tslib.__metadata("design:type", Payment)
488
469
  ], SubscriptionPayment.prototype, "payment", void 0);
489
470
 
490
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
491
- function isFunction(x) {
492
- return typeof x === 'function';
471
+ function isFunction(value) {
472
+ return typeof value === 'function';
493
473
  }
494
474
 
495
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
496
- var _enable_super_gross_mode_that_will_cause_bad_things = false;
497
- var config = {
498
- Promise: undefined,
499
- set useDeprecatedSynchronousErrorHandling(value) {
500
- if (value) {
501
- var error = /*@__PURE__*/ new Error();
502
- /*@__PURE__*/ console.warn('DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n' + error.stack);
503
- }
504
- _enable_super_gross_mode_that_will_cause_bad_things = value;
505
- },
506
- get useDeprecatedSynchronousErrorHandling() {
507
- return _enable_super_gross_mode_that_will_cause_bad_things;
508
- },
509
- };
510
-
511
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
512
- function hostReportError(err) {
513
- setTimeout(function () { throw err; }, 0);
514
- }
515
-
516
- /** PURE_IMPORTS_START _config,_util_hostReportError PURE_IMPORTS_END */
517
- var empty = {
518
- closed: true,
519
- next: function (value) { },
520
- error: function (err) {
521
- if (config.useDeprecatedSynchronousErrorHandling) {
522
- throw err;
523
- }
524
- else {
525
- hostReportError(err);
526
- }
527
- },
528
- complete: function () { }
529
- };
530
-
531
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
532
- var isArray = /*@__PURE__*/ (function () { return Array.isArray || (function (x) { return x && typeof x.length === 'number'; }); })();
533
-
534
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
535
- function isObject(x) {
536
- return x !== null && typeof x === 'object';
475
+ function createErrorClass(createImpl) {
476
+ var _super = function (instance) {
477
+ Error.call(instance);
478
+ instance.stack = new Error().stack;
479
+ };
480
+ var ctorFunc = createImpl(_super);
481
+ ctorFunc.prototype = Object.create(Error.prototype);
482
+ ctorFunc.prototype.constructor = ctorFunc;
483
+ return ctorFunc;
537
484
  }
538
485
 
539
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
540
- var UnsubscriptionErrorImpl = /*@__PURE__*/ (function () {
541
- function UnsubscriptionErrorImpl(errors) {
542
- Error.call(this);
543
- this.message = errors ?
544
- errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ') : '';
486
+ var UnsubscriptionError = createErrorClass(function (_super) {
487
+ return function UnsubscriptionErrorImpl(errors) {
488
+ _super(this);
489
+ this.message = errors
490
+ ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ')
491
+ : '';
545
492
  this.name = 'UnsubscriptionError';
546
493
  this.errors = errors;
547
- return this;
494
+ };
495
+ });
496
+
497
+ function arrRemove(arr, item) {
498
+ if (arr) {
499
+ var index = arr.indexOf(item);
500
+ 0 <= index && arr.splice(index, 1);
548
501
  }
549
- UnsubscriptionErrorImpl.prototype = /*@__PURE__*/ Object.create(Error.prototype);
550
- return UnsubscriptionErrorImpl;
551
- })();
552
- var UnsubscriptionError = UnsubscriptionErrorImpl;
553
-
554
- /** PURE_IMPORTS_START _util_isArray,_util_isObject,_util_isFunction,_util_UnsubscriptionError PURE_IMPORTS_END */
555
- var Subscription$1 = /*@__PURE__*/ (function () {
556
- function Subscription(unsubscribe) {
502
+ }
503
+
504
+ var Subscription$1 = (function () {
505
+ function Subscription(initialTeardown) {
506
+ this.initialTeardown = initialTeardown;
557
507
  this.closed = false;
558
- this._parentOrParents = null;
559
- this._subscriptions = null;
560
- if (unsubscribe) {
561
- this._ctorUnsubscribe = true;
562
- this._unsubscribe = unsubscribe;
563
- }
508
+ this._parentage = null;
509
+ this._finalizers = null;
564
510
  }
565
511
  Subscription.prototype.unsubscribe = function () {
512
+ var e_1, _a, e_2, _b;
566
513
  var errors;
567
- if (this.closed) {
568
- return;
569
- }
570
- var _a = this, _parentOrParents = _a._parentOrParents, _ctorUnsubscribe = _a._ctorUnsubscribe, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
571
- this.closed = true;
572
- this._parentOrParents = null;
573
- this._subscriptions = null;
574
- if (_parentOrParents instanceof Subscription) {
575
- _parentOrParents.remove(this);
576
- }
577
- else if (_parentOrParents !== null) {
578
- for (var index = 0; index < _parentOrParents.length; ++index) {
579
- var parent_1 = _parentOrParents[index];
580
- parent_1.remove(this);
581
- }
582
- }
583
- if (isFunction(_unsubscribe)) {
584
- if (_ctorUnsubscribe) {
585
- this._unsubscribe = undefined;
586
- }
587
- try {
588
- _unsubscribe.call(this);
589
- }
590
- catch (e) {
591
- errors = e instanceof UnsubscriptionError ? flattenUnsubscriptionErrors(e.errors) : [e];
592
- }
593
- }
594
- if (isArray(_subscriptions)) {
595
- var index = -1;
596
- var len = _subscriptions.length;
597
- while (++index < len) {
598
- var sub = _subscriptions[index];
599
- if (isObject(sub)) {
514
+ if (!this.closed) {
515
+ this.closed = true;
516
+ var _parentage = this._parentage;
517
+ if (_parentage) {
518
+ this._parentage = null;
519
+ if (Array.isArray(_parentage)) {
600
520
  try {
601
- sub.unsubscribe();
602
- }
603
- catch (e) {
604
- errors = errors || [];
605
- if (e instanceof UnsubscriptionError) {
606
- errors = errors.concat(flattenUnsubscriptionErrors(e.errors));
521
+ for (var _parentage_1 = tslib.__values(_parentage), _parentage_1_1 = _parentage_1.next(); !_parentage_1_1.done; _parentage_1_1 = _parentage_1.next()) {
522
+ var parent_1 = _parentage_1_1.value;
523
+ parent_1.remove(this);
607
524
  }
608
- else {
609
- errors.push(e);
525
+ }
526
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
527
+ finally {
528
+ try {
529
+ if (_parentage_1_1 && !_parentage_1_1.done && (_a = _parentage_1.return)) _a.call(_parentage_1);
610
530
  }
531
+ finally { if (e_1) throw e_1.error; }
611
532
  }
612
533
  }
534
+ else {
535
+ _parentage.remove(this);
536
+ }
613
537
  }
614
- }
615
- if (errors) {
616
- throw new UnsubscriptionError(errors);
617
- }
618
- };
619
- Subscription.prototype.add = function (teardown) {
620
- var subscription = teardown;
621
- if (!teardown) {
622
- return Subscription.EMPTY;
623
- }
624
- switch (typeof teardown) {
625
- case 'function':
626
- subscription = new Subscription(teardown);
627
- case 'object':
628
- if (subscription === this || subscription.closed || typeof subscription.unsubscribe !== 'function') {
629
- return subscription;
538
+ var initialFinalizer = this.initialTeardown;
539
+ if (isFunction(initialFinalizer)) {
540
+ try {
541
+ initialFinalizer();
542
+ }
543
+ catch (e) {
544
+ errors = e instanceof UnsubscriptionError ? e.errors : [e];
630
545
  }
631
- else if (this.closed) {
632
- subscription.unsubscribe();
633
- return subscription;
546
+ }
547
+ var _finalizers = this._finalizers;
548
+ if (_finalizers) {
549
+ this._finalizers = null;
550
+ try {
551
+ for (var _finalizers_1 = tslib.__values(_finalizers), _finalizers_1_1 = _finalizers_1.next(); !_finalizers_1_1.done; _finalizers_1_1 = _finalizers_1.next()) {
552
+ var finalizer = _finalizers_1_1.value;
553
+ try {
554
+ execFinalizer(finalizer);
555
+ }
556
+ catch (err) {
557
+ errors = errors !== null && errors !== void 0 ? errors : [];
558
+ if (err instanceof UnsubscriptionError) {
559
+ errors = tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(errors)), tslib.__read(err.errors));
560
+ }
561
+ else {
562
+ errors.push(err);
563
+ }
564
+ }
565
+ }
634
566
  }
635
- else if (!(subscription instanceof Subscription)) {
636
- var tmp = subscription;
637
- subscription = new Subscription();
638
- subscription._subscriptions = [tmp];
567
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
568
+ finally {
569
+ try {
570
+ if (_finalizers_1_1 && !_finalizers_1_1.done && (_b = _finalizers_1.return)) _b.call(_finalizers_1);
571
+ }
572
+ finally { if (e_2) throw e_2.error; }
639
573
  }
640
- break;
641
- default: {
642
- throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
643
574
  }
644
- }
645
- var _parentOrParents = subscription._parentOrParents;
646
- if (_parentOrParents === null) {
647
- subscription._parentOrParents = this;
648
- }
649
- else if (_parentOrParents instanceof Subscription) {
650
- if (_parentOrParents === this) {
651
- return subscription;
575
+ if (errors) {
576
+ throw new UnsubscriptionError(errors);
652
577
  }
653
- subscription._parentOrParents = [_parentOrParents, this];
654
578
  }
655
- else if (_parentOrParents.indexOf(this) === -1) {
656
- _parentOrParents.push(this);
657
- }
658
- else {
659
- return subscription;
579
+ };
580
+ Subscription.prototype.add = function (teardown) {
581
+ var _a;
582
+ if (teardown && teardown !== this) {
583
+ if (this.closed) {
584
+ execFinalizer(teardown);
585
+ }
586
+ else {
587
+ if (teardown instanceof Subscription) {
588
+ if (teardown.closed || teardown._hasParent(this)) {
589
+ return;
590
+ }
591
+ teardown._addParent(this);
592
+ }
593
+ (this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown);
594
+ }
660
595
  }
661
- var subscriptions = this._subscriptions;
662
- if (subscriptions === null) {
663
- this._subscriptions = [subscription];
596
+ };
597
+ Subscription.prototype._hasParent = function (parent) {
598
+ var _parentage = this._parentage;
599
+ return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent));
600
+ };
601
+ Subscription.prototype._addParent = function (parent) {
602
+ var _parentage = this._parentage;
603
+ this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
604
+ };
605
+ Subscription.prototype._removeParent = function (parent) {
606
+ var _parentage = this._parentage;
607
+ if (_parentage === parent) {
608
+ this._parentage = null;
664
609
  }
665
- else {
666
- subscriptions.push(subscription);
610
+ else if (Array.isArray(_parentage)) {
611
+ arrRemove(_parentage, parent);
667
612
  }
668
- return subscription;
669
613
  };
670
- Subscription.prototype.remove = function (subscription) {
671
- var subscriptions = this._subscriptions;
672
- if (subscriptions) {
673
- var subscriptionIndex = subscriptions.indexOf(subscription);
674
- if (subscriptionIndex !== -1) {
675
- subscriptions.splice(subscriptionIndex, 1);
676
- }
614
+ Subscription.prototype.remove = function (teardown) {
615
+ var _finalizers = this._finalizers;
616
+ _finalizers && arrRemove(_finalizers, teardown);
617
+ if (teardown instanceof Subscription) {
618
+ teardown._removeParent(this);
677
619
  }
678
620
  };
679
- Subscription.EMPTY = (function (empty) {
621
+ Subscription.EMPTY = (function () {
622
+ var empty = new Subscription();
680
623
  empty.closed = true;
681
624
  return empty;
682
- }(new Subscription()));
625
+ })();
683
626
  return Subscription;
684
627
  }());
685
- function flattenUnsubscriptionErrors(errors) {
686
- return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError) ? err.errors : err); }, []);
628
+ var EMPTY_SUBSCRIPTION = Subscription$1.EMPTY;
629
+ function isSubscription(value) {
630
+ return (value instanceof Subscription$1 ||
631
+ (value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe)));
632
+ }
633
+ function execFinalizer(finalizer) {
634
+ if (isFunction(finalizer)) {
635
+ finalizer();
636
+ }
637
+ else {
638
+ finalizer.unsubscribe();
639
+ }
640
+ }
641
+
642
+ var config = {
643
+ onUnhandledError: null,
644
+ onStoppedNotification: null,
645
+ Promise: undefined,
646
+ useDeprecatedSynchronousErrorHandling: false,
647
+ useDeprecatedNextContext: false,
648
+ };
649
+
650
+ var timeoutProvider = {
651
+ setTimeout: function (handler, timeout) {
652
+ var args = [];
653
+ for (var _i = 2; _i < arguments.length; _i++) {
654
+ args[_i - 2] = arguments[_i];
655
+ }
656
+ var delegate = timeoutProvider.delegate;
657
+ if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) {
658
+ return delegate.setTimeout.apply(delegate, tslib.__spreadArray([handler, timeout], tslib.__read(args)));
659
+ }
660
+ return setTimeout.apply(void 0, tslib.__spreadArray([handler, timeout], tslib.__read(args)));
661
+ },
662
+ clearTimeout: function (handle) {
663
+ var delegate = timeoutProvider.delegate;
664
+ return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearTimeout) || clearTimeout)(handle);
665
+ },
666
+ delegate: undefined,
667
+ };
668
+
669
+ function reportUnhandledError(err) {
670
+ timeoutProvider.setTimeout(function () {
671
+ {
672
+ throw err;
673
+ }
674
+ });
675
+ }
676
+
677
+ function noop() { }
678
+
679
+ var context = null;
680
+ function errorContext(cb) {
681
+ if (config.useDeprecatedSynchronousErrorHandling) {
682
+ var isRoot = !context;
683
+ if (isRoot) {
684
+ context = { errorThrown: false, error: null };
685
+ }
686
+ cb();
687
+ if (isRoot) {
688
+ var _a = context, errorThrown = _a.errorThrown, error = _a.error;
689
+ context = null;
690
+ if (errorThrown) {
691
+ throw error;
692
+ }
693
+ }
694
+ }
695
+ else {
696
+ cb();
697
+ }
687
698
  }
688
699
 
689
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
690
- var rxSubscriber = /*@__PURE__*/ (function () {
691
- return typeof Symbol === 'function'
692
- ? /*@__PURE__*/ Symbol('rxSubscriber')
693
- : '@@rxSubscriber_' + /*@__PURE__*/ Math.random();
694
- })();
695
-
696
- /** PURE_IMPORTS_START tslib,_util_isFunction,_Observer,_Subscription,_internal_symbol_rxSubscriber,_config,_util_hostReportError PURE_IMPORTS_END */
697
- var Subscriber = /*@__PURE__*/ (function (_super) {
698
- tslib_1__namespace.__extends(Subscriber, _super);
699
- function Subscriber(destinationOrNext, error, complete) {
700
+ var Subscriber = (function (_super) {
701
+ tslib.__extends(Subscriber, _super);
702
+ function Subscriber(destination) {
700
703
  var _this = _super.call(this) || this;
701
- _this.syncErrorValue = null;
702
- _this.syncErrorThrown = false;
703
- _this.syncErrorThrowable = false;
704
704
  _this.isStopped = false;
705
- switch (arguments.length) {
706
- case 0:
707
- _this.destination = empty;
708
- break;
709
- case 1:
710
- if (!destinationOrNext) {
711
- _this.destination = empty;
712
- break;
713
- }
714
- if (typeof destinationOrNext === 'object') {
715
- if (destinationOrNext instanceof Subscriber) {
716
- _this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;
717
- _this.destination = destinationOrNext;
718
- destinationOrNext.add(_this);
719
- }
720
- else {
721
- _this.syncErrorThrowable = true;
722
- _this.destination = new SafeSubscriber(_this, destinationOrNext);
723
- }
724
- break;
725
- }
726
- default:
727
- _this.syncErrorThrowable = true;
728
- _this.destination = new SafeSubscriber(_this, destinationOrNext, error, complete);
729
- break;
705
+ if (destination) {
706
+ _this.destination = destination;
707
+ if (isSubscription(destination)) {
708
+ destination.add(_this);
709
+ }
710
+ }
711
+ else {
712
+ _this.destination = EMPTY_OBSERVER;
730
713
  }
731
714
  return _this;
732
715
  }
733
- Subscriber.prototype[rxSubscriber] = function () { return this; };
734
716
  Subscriber.create = function (next, error, complete) {
735
- var subscriber = new Subscriber(next, error, complete);
736
- subscriber.syncErrorThrowable = false;
737
- return subscriber;
717
+ return new SafeSubscriber(next, error, complete);
738
718
  };
739
719
  Subscriber.prototype.next = function (value) {
740
- if (!this.isStopped) {
720
+ if (this.isStopped) ;
721
+ else {
741
722
  this._next(value);
742
723
  }
743
724
  };
744
725
  Subscriber.prototype.error = function (err) {
745
- if (!this.isStopped) {
726
+ if (this.isStopped) ;
727
+ else {
746
728
  this.isStopped = true;
747
729
  this._error(err);
748
730
  }
749
731
  };
750
732
  Subscriber.prototype.complete = function () {
751
- if (!this.isStopped) {
733
+ if (this.isStopped) ;
734
+ else {
752
735
  this.isStopped = true;
753
736
  this._complete();
754
737
  }
755
738
  };
756
739
  Subscriber.prototype.unsubscribe = function () {
757
- if (this.closed) {
758
- return;
740
+ if (!this.closed) {
741
+ this.isStopped = true;
742
+ _super.prototype.unsubscribe.call(this);
743
+ this.destination = null;
759
744
  }
760
- this.isStopped = true;
761
- _super.prototype.unsubscribe.call(this);
762
745
  };
763
746
  Subscriber.prototype._next = function (value) {
764
747
  this.destination.next(value);
765
748
  };
766
749
  Subscriber.prototype._error = function (err) {
767
- this.destination.error(err);
768
- this.unsubscribe();
750
+ try {
751
+ this.destination.error(err);
752
+ }
753
+ finally {
754
+ this.unsubscribe();
755
+ }
769
756
  };
770
757
  Subscriber.prototype._complete = function () {
771
- this.destination.complete();
772
- this.unsubscribe();
773
- };
774
- Subscriber.prototype._unsubscribeAndRecycle = function () {
775
- var _parentOrParents = this._parentOrParents;
776
- this._parentOrParents = null;
777
- this.unsubscribe();
778
- this.closed = false;
779
- this.isStopped = false;
780
- this._parentOrParents = _parentOrParents;
781
- return this;
758
+ try {
759
+ this.destination.complete();
760
+ }
761
+ finally {
762
+ this.unsubscribe();
763
+ }
782
764
  };
783
765
  return Subscriber;
784
766
  }(Subscription$1));
785
- var SafeSubscriber = /*@__PURE__*/ (function (_super) {
786
- tslib_1__namespace.__extends(SafeSubscriber, _super);
787
- function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) {
788
- var _this = _super.call(this) || this;
789
- _this._parentSubscriber = _parentSubscriber;
790
- var next;
791
- var context = _this;
792
- if (isFunction(observerOrNext)) {
793
- next = observerOrNext;
794
- }
795
- else if (observerOrNext) {
796
- next = observerOrNext.next;
797
- error = observerOrNext.error;
798
- complete = observerOrNext.complete;
799
- if (observerOrNext !== empty) {
800
- context = Object.create(observerOrNext);
801
- if (isFunction(context.unsubscribe)) {
802
- _this.add(context.unsubscribe.bind(context));
803
- }
804
- context.unsubscribe = _this.unsubscribe.bind(_this);
805
- }
806
- }
807
- _this._context = context;
808
- _this._next = next;
809
- _this._error = error;
810
- _this._complete = complete;
811
- return _this;
767
+ var _bind = Function.prototype.bind;
768
+ function bind(fn, thisArg) {
769
+ return _bind.call(fn, thisArg);
770
+ }
771
+ var ConsumerObserver = (function () {
772
+ function ConsumerObserver(partialObserver) {
773
+ this.partialObserver = partialObserver;
812
774
  }
813
- SafeSubscriber.prototype.next = function (value) {
814
- if (!this.isStopped && this._next) {
815
- var _parentSubscriber = this._parentSubscriber;
816
- if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
817
- this.__tryOrUnsub(this._next, value);
775
+ ConsumerObserver.prototype.next = function (value) {
776
+ var partialObserver = this.partialObserver;
777
+ if (partialObserver.next) {
778
+ try {
779
+ partialObserver.next(value);
818
780
  }
819
- else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
820
- this.unsubscribe();
781
+ catch (error) {
782
+ handleUnhandledError(error);
821
783
  }
822
784
  }
823
785
  };
824
- SafeSubscriber.prototype.error = function (err) {
825
- if (!this.isStopped) {
826
- var _parentSubscriber = this._parentSubscriber;
827
- var useDeprecatedSynchronousErrorHandling = config.useDeprecatedSynchronousErrorHandling;
828
- if (this._error) {
829
- if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
830
- this.__tryOrUnsub(this._error, err);
831
- this.unsubscribe();
832
- }
833
- else {
834
- this.__tryOrSetError(_parentSubscriber, this._error, err);
835
- this.unsubscribe();
836
- }
786
+ ConsumerObserver.prototype.error = function (err) {
787
+ var partialObserver = this.partialObserver;
788
+ if (partialObserver.error) {
789
+ try {
790
+ partialObserver.error(err);
837
791
  }
838
- else if (!_parentSubscriber.syncErrorThrowable) {
839
- this.unsubscribe();
840
- if (useDeprecatedSynchronousErrorHandling) {
841
- throw err;
842
- }
843
- hostReportError(err);
844
- }
845
- else {
846
- if (useDeprecatedSynchronousErrorHandling) {
847
- _parentSubscriber.syncErrorValue = err;
848
- _parentSubscriber.syncErrorThrown = true;
849
- }
850
- else {
851
- hostReportError(err);
852
- }
853
- this.unsubscribe();
792
+ catch (error) {
793
+ handleUnhandledError(error);
854
794
  }
855
795
  }
856
- };
857
- SafeSubscriber.prototype.complete = function () {
858
- var _this = this;
859
- if (!this.isStopped) {
860
- var _parentSubscriber = this._parentSubscriber;
861
- if (this._complete) {
862
- var wrappedComplete = function () { return _this._complete.call(_this._context); };
863
- if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
864
- this.__tryOrUnsub(wrappedComplete);
865
- this.unsubscribe();
866
- }
867
- else {
868
- this.__tryOrSetError(_parentSubscriber, wrappedComplete);
869
- this.unsubscribe();
870
- }
871
- }
872
- else {
873
- this.unsubscribe();
874
- }
796
+ else {
797
+ handleUnhandledError(err);
875
798
  }
876
799
  };
877
- SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
878
- try {
879
- fn.call(this._context, value);
880
- }
881
- catch (err) {
882
- this.unsubscribe();
883
- if (config.useDeprecatedSynchronousErrorHandling) {
884
- throw err;
800
+ ConsumerObserver.prototype.complete = function () {
801
+ var partialObserver = this.partialObserver;
802
+ if (partialObserver.complete) {
803
+ try {
804
+ partialObserver.complete();
885
805
  }
886
- else {
887
- hostReportError(err);
806
+ catch (error) {
807
+ handleUnhandledError(error);
888
808
  }
889
809
  }
890
810
  };
891
- SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {
892
- if (!config.useDeprecatedSynchronousErrorHandling) {
893
- throw new Error('bad call');
894
- }
895
- try {
896
- fn.call(this._context, value);
811
+ return ConsumerObserver;
812
+ }());
813
+ var SafeSubscriber = (function (_super) {
814
+ tslib.__extends(SafeSubscriber, _super);
815
+ function SafeSubscriber(observerOrNext, error, complete) {
816
+ var _this = _super.call(this) || this;
817
+ var partialObserver;
818
+ if (isFunction(observerOrNext) || !observerOrNext) {
819
+ partialObserver = {
820
+ next: (observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined),
821
+ error: error !== null && error !== void 0 ? error : undefined,
822
+ complete: complete !== null && complete !== void 0 ? complete : undefined,
823
+ };
897
824
  }
898
- catch (err) {
899
- if (config.useDeprecatedSynchronousErrorHandling) {
900
- parent.syncErrorValue = err;
901
- parent.syncErrorThrown = true;
902
- return true;
825
+ else {
826
+ var context_1;
827
+ if (_this && config.useDeprecatedNextContext) {
828
+ context_1 = Object.create(observerOrNext);
829
+ context_1.unsubscribe = function () { return _this.unsubscribe(); };
830
+ partialObserver = {
831
+ next: observerOrNext.next && bind(observerOrNext.next, context_1),
832
+ error: observerOrNext.error && bind(observerOrNext.error, context_1),
833
+ complete: observerOrNext.complete && bind(observerOrNext.complete, context_1),
834
+ };
903
835
  }
904
836
  else {
905
- hostReportError(err);
906
- return true;
837
+ partialObserver = observerOrNext;
907
838
  }
908
839
  }
909
- return false;
910
- };
911
- SafeSubscriber.prototype._unsubscribe = function () {
912
- var _parentSubscriber = this._parentSubscriber;
913
- this._context = null;
914
- this._parentSubscriber = null;
915
- _parentSubscriber.unsubscribe();
916
- };
840
+ _this.destination = new ConsumerObserver(partialObserver);
841
+ return _this;
842
+ }
917
843
  return SafeSubscriber;
918
844
  }(Subscriber));
919
-
920
- /** PURE_IMPORTS_START _Subscriber PURE_IMPORTS_END */
921
- function canReportError(observer) {
922
- while (observer) {
923
- var _a = observer, closed_1 = _a.closed, destination = _a.destination, isStopped = _a.isStopped;
924
- if (closed_1 || isStopped) {
925
- return false;
926
- }
927
- else if (destination && destination instanceof Subscriber) {
928
- observer = destination;
929
- }
930
- else {
931
- observer = null;
932
- }
845
+ function handleUnhandledError(error) {
846
+ {
847
+ reportUnhandledError(error);
933
848
  }
934
- return true;
935
849
  }
936
-
937
- /** PURE_IMPORTS_START _Subscriber,_symbol_rxSubscriber,_Observer PURE_IMPORTS_END */
938
- function toSubscriber(nextOrObserver, error, complete) {
939
- if (nextOrObserver) {
940
- if (nextOrObserver instanceof Subscriber) {
941
- return nextOrObserver;
942
- }
943
- if (nextOrObserver[rxSubscriber]) {
944
- return nextOrObserver[rxSubscriber]();
945
- }
946
- }
947
- if (!nextOrObserver && !error && !complete) {
948
- return new Subscriber(empty);
949
- }
950
- return new Subscriber(nextOrObserver, error, complete);
850
+ function defaultErrorHandler(err) {
851
+ throw err;
951
852
  }
853
+ var EMPTY_OBSERVER = {
854
+ closed: true,
855
+ next: noop,
856
+ error: defaultErrorHandler,
857
+ complete: noop,
858
+ };
952
859
 
953
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
954
- var observable = /*@__PURE__*/ (function () { return typeof Symbol === 'function' && Symbol.observable || '@@observable'; })();
860
+ var observable = (function () { return (typeof Symbol === 'function' && Symbol.observable) || '@@observable'; })();
955
861
 
956
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
957
862
  function identity(x) {
958
863
  return x;
959
864
  }
960
865
 
961
- /** PURE_IMPORTS_START _identity PURE_IMPORTS_END */
962
866
  function pipeFromArray(fns) {
963
867
  if (fns.length === 0) {
964
868
  return identity;
@@ -971,10 +875,8 @@ function pipeFromArray(fns) {
971
875
  };
972
876
  }
973
877
 
974
- /** PURE_IMPORTS_START _util_canReportError,_util_toSubscriber,_symbol_observable,_util_pipe,_config PURE_IMPORTS_END */
975
- var Observable = /*@__PURE__*/ (function () {
878
+ var Observable = (function () {
976
879
  function Observable(subscribe) {
977
- this._isScalar = false;
978
880
  if (subscribe) {
979
881
  this._subscribe = subscribe;
980
882
  }
@@ -986,64 +888,52 @@ var Observable = /*@__PURE__*/ (function () {
986
888
  return observable;
987
889
  };
988
890
  Observable.prototype.subscribe = function (observerOrNext, error, complete) {
989
- var operator = this.operator;
990
- var sink = toSubscriber(observerOrNext, error, complete);
991
- if (operator) {
992
- sink.add(operator.call(sink, this.source));
993
- }
994
- else {
995
- sink.add(this.source || (config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable) ?
996
- this._subscribe(sink) :
997
- this._trySubscribe(sink));
998
- }
999
- if (config.useDeprecatedSynchronousErrorHandling) {
1000
- if (sink.syncErrorThrowable) {
1001
- sink.syncErrorThrowable = false;
1002
- if (sink.syncErrorThrown) {
1003
- throw sink.syncErrorValue;
1004
- }
1005
- }
1006
- }
1007
- return sink;
891
+ var _this = this;
892
+ var subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);
893
+ errorContext(function () {
894
+ var _a = _this, operator = _a.operator, source = _a.source;
895
+ subscriber.add(operator
896
+ ?
897
+ operator.call(subscriber, source)
898
+ : source
899
+ ?
900
+ _this._subscribe(subscriber)
901
+ :
902
+ _this._trySubscribe(subscriber));
903
+ });
904
+ return subscriber;
1008
905
  };
1009
906
  Observable.prototype._trySubscribe = function (sink) {
1010
907
  try {
1011
908
  return this._subscribe(sink);
1012
909
  }
1013
910
  catch (err) {
1014
- if (config.useDeprecatedSynchronousErrorHandling) {
1015
- sink.syncErrorThrown = true;
1016
- sink.syncErrorValue = err;
1017
- }
1018
- if (canReportError(sink)) {
1019
- sink.error(err);
1020
- }
1021
- else {
1022
- console.warn(err);
1023
- }
911
+ sink.error(err);
1024
912
  }
1025
913
  };
1026
914
  Observable.prototype.forEach = function (next, promiseCtor) {
1027
915
  var _this = this;
1028
916
  promiseCtor = getPromiseCtor(promiseCtor);
1029
917
  return new promiseCtor(function (resolve, reject) {
1030
- var subscription;
1031
- subscription = _this.subscribe(function (value) {
1032
- try {
1033
- next(value);
1034
- }
1035
- catch (err) {
1036
- reject(err);
1037
- if (subscription) {
1038
- subscription.unsubscribe();
918
+ var subscriber = new SafeSubscriber({
919
+ next: function (value) {
920
+ try {
921
+ next(value);
1039
922
  }
1040
- }
1041
- }, reject, resolve);
923
+ catch (err) {
924
+ reject(err);
925
+ subscriber.unsubscribe();
926
+ }
927
+ },
928
+ error: reject,
929
+ complete: resolve,
930
+ });
931
+ _this.subscribe(subscriber);
1042
932
  });
1043
933
  };
1044
934
  Observable.prototype._subscribe = function (subscriber) {
1045
- var source = this.source;
1046
- return source && source.subscribe(subscriber);
935
+ var _a;
936
+ return (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber);
1047
937
  };
1048
938
  Observable.prototype[observable] = function () {
1049
939
  return this;
@@ -1053,9 +943,6 @@ var Observable = /*@__PURE__*/ (function () {
1053
943
  for (var _i = 0; _i < arguments.length; _i++) {
1054
944
  operations[_i] = arguments[_i];
1055
945
  }
1056
- if (operations.length === 0) {
1057
- return this;
1058
- }
1059
946
  return pipeFromArray(operations)(this);
1060
947
  };
1061
948
  Observable.prototype.toPromise = function (promiseCtor) {
@@ -1063,7 +950,7 @@ var Observable = /*@__PURE__*/ (function () {
1063
950
  promiseCtor = getPromiseCtor(promiseCtor);
1064
951
  return new promiseCtor(function (resolve, reject) {
1065
952
  var value;
1066
- _this.subscribe(function (x) { return value = x; }, function (err) { return reject(err); }, function () { return resolve(value); });
953
+ _this.subscribe(function (x) { return (value = x); }, function (err) { return reject(err); }, function () { return resolve(value); });
1067
954
  });
1068
955
  };
1069
956
  Observable.create = function (subscribe) {
@@ -1072,155 +959,139 @@ var Observable = /*@__PURE__*/ (function () {
1072
959
  return Observable;
1073
960
  }());
1074
961
  function getPromiseCtor(promiseCtor) {
1075
- if (!promiseCtor) {
1076
- promiseCtor = config.Promise || Promise;
1077
- }
1078
- if (!promiseCtor) {
1079
- throw new Error('no Promise impl found');
1080
- }
1081
- return promiseCtor;
962
+ var _a;
963
+ return (_a = promiseCtor !== null && promiseCtor !== void 0 ? promiseCtor : config.Promise) !== null && _a !== void 0 ? _a : Promise;
964
+ }
965
+ function isObserver(value) {
966
+ return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);
967
+ }
968
+ function isSubscriber(value) {
969
+ return (value && value instanceof Subscriber) || (isObserver(value) && isSubscription(value));
1082
970
  }
1083
971
 
1084
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
1085
- var ObjectUnsubscribedErrorImpl = /*@__PURE__*/ (function () {
1086
- function ObjectUnsubscribedErrorImpl() {
1087
- Error.call(this);
1088
- this.message = 'object unsubscribed';
972
+ var ObjectUnsubscribedError = createErrorClass(function (_super) {
973
+ return function ObjectUnsubscribedErrorImpl() {
974
+ _super(this);
1089
975
  this.name = 'ObjectUnsubscribedError';
1090
- return this;
1091
- }
1092
- ObjectUnsubscribedErrorImpl.prototype = /*@__PURE__*/ Object.create(Error.prototype);
1093
- return ObjectUnsubscribedErrorImpl;
1094
- })();
1095
- var ObjectUnsubscribedError = ObjectUnsubscribedErrorImpl;
1096
-
1097
- /** PURE_IMPORTS_START tslib,_Subscription PURE_IMPORTS_END */
1098
- var SubjectSubscription = /*@__PURE__*/ (function (_super) {
1099
- tslib_1__namespace.__extends(SubjectSubscription, _super);
1100
- function SubjectSubscription(subject, subscriber) {
1101
- var _this = _super.call(this) || this;
1102
- _this.subject = subject;
1103
- _this.subscriber = subscriber;
1104
- _this.closed = false;
1105
- return _this;
1106
- }
1107
- SubjectSubscription.prototype.unsubscribe = function () {
1108
- if (this.closed) {
1109
- return;
1110
- }
1111
- this.closed = true;
1112
- var subject = this.subject;
1113
- var observers = subject.observers;
1114
- this.subject = null;
1115
- if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
1116
- return;
1117
- }
1118
- var subscriberIndex = observers.indexOf(this.subscriber);
1119
- if (subscriberIndex !== -1) {
1120
- observers.splice(subscriberIndex, 1);
1121
- }
976
+ this.message = 'object unsubscribed';
1122
977
  };
1123
- return SubjectSubscription;
1124
- }(Subscription$1));
978
+ });
1125
979
 
1126
- /** PURE_IMPORTS_START tslib,_Observable,_Subscriber,_Subscription,_util_ObjectUnsubscribedError,_SubjectSubscription,_internal_symbol_rxSubscriber PURE_IMPORTS_END */
1127
- var SubjectSubscriber = /*@__PURE__*/ (function (_super) {
1128
- tslib_1__namespace.__extends(SubjectSubscriber, _super);
1129
- function SubjectSubscriber(destination) {
1130
- var _this = _super.call(this, destination) || this;
1131
- _this.destination = destination;
1132
- return _this;
1133
- }
1134
- return SubjectSubscriber;
1135
- }(Subscriber));
1136
- var Subject = /*@__PURE__*/ (function (_super) {
1137
- tslib_1__namespace.__extends(Subject, _super);
980
+ var Subject = (function (_super) {
981
+ tslib.__extends(Subject, _super);
1138
982
  function Subject() {
1139
983
  var _this = _super.call(this) || this;
1140
- _this.observers = [];
1141
984
  _this.closed = false;
985
+ _this.currentObservers = null;
986
+ _this.observers = [];
1142
987
  _this.isStopped = false;
1143
988
  _this.hasError = false;
1144
989
  _this.thrownError = null;
1145
990
  return _this;
1146
991
  }
1147
- Subject.prototype[rxSubscriber] = function () {
1148
- return new SubjectSubscriber(this);
1149
- };
1150
992
  Subject.prototype.lift = function (operator) {
1151
993
  var subject = new AnonymousSubject(this, this);
1152
994
  subject.operator = operator;
1153
995
  return subject;
1154
996
  };
1155
- Subject.prototype.next = function (value) {
997
+ Subject.prototype._throwIfClosed = function () {
1156
998
  if (this.closed) {
1157
999
  throw new ObjectUnsubscribedError();
1158
1000
  }
1159
- if (!this.isStopped) {
1160
- var observers = this.observers;
1161
- var len = observers.length;
1162
- var copy = observers.slice();
1163
- for (var i = 0; i < len; i++) {
1164
- copy[i].next(value);
1001
+ };
1002
+ Subject.prototype.next = function (value) {
1003
+ var _this = this;
1004
+ errorContext(function () {
1005
+ var e_1, _a;
1006
+ _this._throwIfClosed();
1007
+ if (!_this.isStopped) {
1008
+ if (!_this.currentObservers) {
1009
+ _this.currentObservers = Array.from(_this.observers);
1010
+ }
1011
+ try {
1012
+ for (var _b = tslib.__values(_this.currentObservers), _c = _b.next(); !_c.done; _c = _b.next()) {
1013
+ var observer = _c.value;
1014
+ observer.next(value);
1015
+ }
1016
+ }
1017
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1018
+ finally {
1019
+ try {
1020
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1021
+ }
1022
+ finally { if (e_1) throw e_1.error; }
1023
+ }
1165
1024
  }
1166
- }
1025
+ });
1167
1026
  };
1168
1027
  Subject.prototype.error = function (err) {
1169
- if (this.closed) {
1170
- throw new ObjectUnsubscribedError();
1171
- }
1172
- this.hasError = true;
1173
- this.thrownError = err;
1174
- this.isStopped = true;
1175
- var observers = this.observers;
1176
- var len = observers.length;
1177
- var copy = observers.slice();
1178
- for (var i = 0; i < len; i++) {
1179
- copy[i].error(err);
1180
- }
1181
- this.observers.length = 0;
1028
+ var _this = this;
1029
+ errorContext(function () {
1030
+ _this._throwIfClosed();
1031
+ if (!_this.isStopped) {
1032
+ _this.hasError = _this.isStopped = true;
1033
+ _this.thrownError = err;
1034
+ var observers = _this.observers;
1035
+ while (observers.length) {
1036
+ observers.shift().error(err);
1037
+ }
1038
+ }
1039
+ });
1182
1040
  };
1183
1041
  Subject.prototype.complete = function () {
1184
- if (this.closed) {
1185
- throw new ObjectUnsubscribedError();
1186
- }
1187
- this.isStopped = true;
1188
- var observers = this.observers;
1189
- var len = observers.length;
1190
- var copy = observers.slice();
1191
- for (var i = 0; i < len; i++) {
1192
- copy[i].complete();
1193
- }
1194
- this.observers.length = 0;
1042
+ var _this = this;
1043
+ errorContext(function () {
1044
+ _this._throwIfClosed();
1045
+ if (!_this.isStopped) {
1046
+ _this.isStopped = true;
1047
+ var observers = _this.observers;
1048
+ while (observers.length) {
1049
+ observers.shift().complete();
1050
+ }
1051
+ }
1052
+ });
1195
1053
  };
1196
1054
  Subject.prototype.unsubscribe = function () {
1197
- this.isStopped = true;
1198
- this.closed = true;
1199
- this.observers = null;
1055
+ this.isStopped = this.closed = true;
1056
+ this.observers = this.currentObservers = null;
1200
1057
  };
1058
+ Object.defineProperty(Subject.prototype, "observed", {
1059
+ get: function () {
1060
+ var _a;
1061
+ return ((_a = this.observers) === null || _a === void 0 ? void 0 : _a.length) > 0;
1062
+ },
1063
+ enumerable: false,
1064
+ configurable: true
1065
+ });
1201
1066
  Subject.prototype._trySubscribe = function (subscriber) {
1202
- if (this.closed) {
1203
- throw new ObjectUnsubscribedError();
1204
- }
1205
- else {
1206
- return _super.prototype._trySubscribe.call(this, subscriber);
1207
- }
1067
+ this._throwIfClosed();
1068
+ return _super.prototype._trySubscribe.call(this, subscriber);
1208
1069
  };
1209
1070
  Subject.prototype._subscribe = function (subscriber) {
1210
- if (this.closed) {
1211
- throw new ObjectUnsubscribedError();
1071
+ this._throwIfClosed();
1072
+ this._checkFinalizedStatuses(subscriber);
1073
+ return this._innerSubscribe(subscriber);
1074
+ };
1075
+ Subject.prototype._innerSubscribe = function (subscriber) {
1076
+ var _this = this;
1077
+ var _a = this, hasError = _a.hasError, isStopped = _a.isStopped, observers = _a.observers;
1078
+ if (hasError || isStopped) {
1079
+ return EMPTY_SUBSCRIPTION;
1212
1080
  }
1213
- else if (this.hasError) {
1214
- subscriber.error(this.thrownError);
1215
- return Subscription$1.EMPTY;
1081
+ this.currentObservers = null;
1082
+ observers.push(subscriber);
1083
+ return new Subscription$1(function () {
1084
+ _this.currentObservers = null;
1085
+ arrRemove(observers, subscriber);
1086
+ });
1087
+ };
1088
+ Subject.prototype._checkFinalizedStatuses = function (subscriber) {
1089
+ var _a = this, hasError = _a.hasError, thrownError = _a.thrownError, isStopped = _a.isStopped;
1090
+ if (hasError) {
1091
+ subscriber.error(thrownError);
1216
1092
  }
1217
- else if (this.isStopped) {
1093
+ else if (isStopped) {
1218
1094
  subscriber.complete();
1219
- return Subscription$1.EMPTY;
1220
- }
1221
- else {
1222
- this.observers.push(subscriber);
1223
- return new SubjectSubscription(this, subscriber);
1224
1095
  }
1225
1096
  };
1226
1097
  Subject.prototype.asObservable = function () {
@@ -1233,8 +1104,8 @@ var Subject = /*@__PURE__*/ (function (_super) {
1233
1104
  };
1234
1105
  return Subject;
1235
1106
  }(Observable));
1236
- var AnonymousSubject = /*@__PURE__*/ (function (_super) {
1237
- tslib_1__namespace.__extends(AnonymousSubject, _super);
1107
+ var AnonymousSubject = (function (_super) {
1108
+ tslib.__extends(AnonymousSubject, _super);
1238
1109
  function AnonymousSubject(destination, source) {
1239
1110
  var _this = _super.call(this) || this;
1240
1111
  _this.destination = destination;
@@ -1242,31 +1113,20 @@ var AnonymousSubject = /*@__PURE__*/ (function (_super) {
1242
1113
  return _this;
1243
1114
  }
1244
1115
  AnonymousSubject.prototype.next = function (value) {
1245
- var destination = this.destination;
1246
- if (destination && destination.next) {
1247
- destination.next(value);
1248
- }
1116
+ var _a, _b;
1117
+ (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.next) === null || _b === void 0 ? void 0 : _b.call(_a, value);
1249
1118
  };
1250
1119
  AnonymousSubject.prototype.error = function (err) {
1251
- var destination = this.destination;
1252
- if (destination && destination.error) {
1253
- this.destination.error(err);
1254
- }
1120
+ var _a, _b;
1121
+ (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.call(_a, err);
1255
1122
  };
1256
1123
  AnonymousSubject.prototype.complete = function () {
1257
- var destination = this.destination;
1258
- if (destination && destination.complete) {
1259
- this.destination.complete();
1260
- }
1124
+ var _a, _b;
1125
+ (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.complete) === null || _b === void 0 ? void 0 : _b.call(_a);
1261
1126
  };
1262
1127
  AnonymousSubject.prototype._subscribe = function (subscriber) {
1263
- var source = this.source;
1264
- if (source) {
1265
- return this.source.subscribe(subscriber);
1266
- }
1267
- else {
1268
- return Subscription$1.EMPTY;
1269
- }
1128
+ var _a, _b;
1129
+ return (_b = (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber)) !== null && _b !== void 0 ? _b : EMPTY_SUBSCRIPTION;
1270
1130
  };
1271
1131
  return AnonymousSubject;
1272
1132
  }(Subject));
@@ -1827,9 +1687,9 @@ class User extends BaseModel {
1827
1687
  return ['id'];
1828
1688
  }
1829
1689
  }
1830
- tslib_1.__decorate([
1690
+ tslib.__decorate([
1831
1691
  classTransformer.Type(() => BeautyProfile),
1832
- tslib_1.__metadata("design:type", BeautyProfile)
1692
+ tslib.__metadata("design:type", BeautyProfile)
1833
1693
  ], User.prototype, "beautyProfile", void 0);
1834
1694
 
1835
1695
  class Address extends BaseModel {
@@ -1849,33 +1709,33 @@ class Subscription extends BaseModel {
1849
1709
  return ['id'];
1850
1710
  }
1851
1711
  }
1852
- tslib_1.__decorate([
1712
+ tslib.__decorate([
1853
1713
  classTransformer.Type(() => User),
1854
- tslib_1.__metadata("design:type", User)
1714
+ tslib.__metadata("design:type", User)
1855
1715
  ], Subscription.prototype, "user", void 0);
1856
- tslib_1.__decorate([
1716
+ tslib.__decorate([
1857
1717
  classTransformer.Type(() => SubscriptionPlan),
1858
- tslib_1.__metadata("design:type", SubscriptionPlan)
1718
+ tslib.__metadata("design:type", SubscriptionPlan)
1859
1719
  ], Subscription.prototype, "subscriptionPlan", void 0);
1860
- tslib_1.__decorate([
1720
+ tslib.__decorate([
1861
1721
  classTransformer.Type(() => UserAddress),
1862
- tslib_1.__metadata("design:type", UserAddress)
1722
+ tslib.__metadata("design:type", UserAddress)
1863
1723
  ], Subscription.prototype, "shippingAddress", void 0);
1864
- tslib_1.__decorate([
1724
+ tslib.__decorate([
1865
1725
  classTransformer.Type(() => UserAddress),
1866
- tslib_1.__metadata("design:type", UserAddress)
1726
+ tslib.__metadata("design:type", UserAddress)
1867
1727
  ], Subscription.prototype, "billingAddress", void 0);
1868
- tslib_1.__decorate([
1728
+ tslib.__decorate([
1869
1729
  classTransformer.Type(() => Coupon),
1870
- tslib_1.__metadata("design:type", Coupon)
1730
+ tslib.__metadata("design:type", Coupon)
1871
1731
  ], Subscription.prototype, "coupon", void 0);
1872
- tslib_1.__decorate([
1732
+ tslib.__decorate([
1873
1733
  classTransformer.Type(() => Edition),
1874
- tslib_1.__metadata("design:type", Array)
1734
+ tslib.__metadata("design:type", Array)
1875
1735
  ], Subscription.prototype, "editions", void 0);
1876
- tslib_1.__decorate([
1736
+ tslib.__decorate([
1877
1737
  classTransformer.Type(() => SubscriptionPayment),
1878
- tslib_1.__metadata("design:type", Array)
1738
+ tslib.__metadata("design:type", Array)
1879
1739
  ], Subscription.prototype, "payment", void 0);
1880
1740
 
1881
1741
  class Filter extends BaseModel {
@@ -1889,13 +1749,13 @@ class CategoryBase extends BaseModel {
1889
1749
  return ['id'];
1890
1750
  }
1891
1751
  }
1892
- tslib_1.__decorate([
1752
+ tslib.__decorate([
1893
1753
  classTransformer.Type(() => CategoryBase),
1894
- tslib_1.__metadata("design:type", CategoryBase)
1754
+ tslib.__metadata("design:type", CategoryBase)
1895
1755
  ], CategoryBase.prototype, "parent", void 0);
1896
- tslib_1.__decorate([
1756
+ tslib.__decorate([
1897
1757
  classTransformer.Type(() => Filter),
1898
- tslib_1.__metadata("design:type", Array)
1758
+ tslib.__metadata("design:type", Array)
1899
1759
  ], CategoryBase.prototype, "filters", void 0);
1900
1760
 
1901
1761
  class CategoryForProduct extends CategoryBase {
@@ -1933,9 +1793,9 @@ class ProductForKit extends ProductBase {
1933
1793
  return ['id'];
1934
1794
  }
1935
1795
  }
1936
- tslib_1.__decorate([
1796
+ tslib.__decorate([
1937
1797
  classTransformer.Type(() => CategoryForProduct),
1938
- tslib_1.__metadata("design:type", CategoryForProduct)
1798
+ tslib.__metadata("design:type", CategoryForProduct)
1939
1799
  ], ProductForKit.prototype, "category", void 0);
1940
1800
 
1941
1801
  class KitProduct extends BaseModel {
@@ -1943,13 +1803,13 @@ class KitProduct extends BaseModel {
1943
1803
  return ['productId', 'kitProductId'];
1944
1804
  }
1945
1805
  }
1946
- tslib_1.__decorate([
1806
+ tslib.__decorate([
1947
1807
  classTransformer.Type(() => ProductForKit),
1948
- tslib_1.__metadata("design:type", ProductForKit)
1808
+ tslib.__metadata("design:type", ProductForKit)
1949
1809
  ], KitProduct.prototype, "kit", void 0);
1950
- tslib_1.__decorate([
1810
+ tslib.__decorate([
1951
1811
  classTransformer.Type(() => ProductForKit),
1952
- tslib_1.__metadata("design:type", ProductForKit)
1812
+ tslib.__metadata("design:type", ProductForKit)
1953
1813
  ], KitProduct.prototype, "product", void 0);
1954
1814
 
1955
1815
  class ProductForCategory extends ProductBase {
@@ -1957,9 +1817,9 @@ class ProductForCategory extends ProductBase {
1957
1817
  return ['id'];
1958
1818
  }
1959
1819
  }
1960
- tslib_1.__decorate([
1820
+ tslib.__decorate([
1961
1821
  classTransformer.Type(() => KitProduct),
1962
- tslib_1.__metadata("design:type", Array)
1822
+ tslib.__metadata("design:type", Array)
1963
1823
  ], ProductForCategory.prototype, "kitProducts", void 0);
1964
1824
 
1965
1825
  class Category extends CategoryBase {
@@ -1967,9 +1827,9 @@ class Category extends CategoryBase {
1967
1827
  return ['id'];
1968
1828
  }
1969
1829
  }
1970
- tslib_1.__decorate([
1830
+ tslib.__decorate([
1971
1831
  classTransformer.Type(() => ProductForCategory),
1972
- tslib_1.__metadata("design:type", Array)
1832
+ tslib.__metadata("design:type", Array)
1973
1833
  ], Category.prototype, "childrenProducts", void 0);
1974
1834
 
1975
1835
  class CategoryCollectionChildren extends BaseModel {
@@ -1977,9 +1837,9 @@ class CategoryCollectionChildren extends BaseModel {
1977
1837
  return ['collectionId', 'categoryId'];
1978
1838
  }
1979
1839
  }
1980
- tslib_1.__decorate([
1840
+ tslib.__decorate([
1981
1841
  classTransformer.Type(() => CategoryCollectionChildren),
1982
- tslib_1.__metadata("design:type", CategoryCollectionChildren)
1842
+ tslib.__metadata("design:type", CategoryCollectionChildren)
1983
1843
  ], CategoryCollectionChildren.prototype, "parent", void 0);
1984
1844
 
1985
1845
  class CategoryFilter extends BaseModel {
@@ -1987,13 +1847,13 @@ class CategoryFilter extends BaseModel {
1987
1847
  return ['id'];
1988
1848
  }
1989
1849
  }
1990
- tslib_1.__decorate([
1850
+ tslib.__decorate([
1991
1851
  classTransformer.Type(() => Filter),
1992
- tslib_1.__metadata("design:type", Filter)
1852
+ tslib.__metadata("design:type", Filter)
1993
1853
  ], CategoryFilter.prototype, "filter", void 0);
1994
- tslib_1.__decorate([
1854
+ tslib.__decorate([
1995
1855
  classTransformer.Type(() => Category),
1996
- tslib_1.__metadata("design:type", Category)
1856
+ tslib.__metadata("design:type", Category)
1997
1857
  ], CategoryFilter.prototype, "category", void 0);
1998
1858
 
1999
1859
  exports.GenderDestination = void 0;
@@ -2022,13 +1882,13 @@ class Product extends ProductBase {
2022
1882
  return ['id'];
2023
1883
  }
2024
1884
  }
2025
- tslib_1.__decorate([
1885
+ tslib.__decorate([
2026
1886
  classTransformer.Type(() => CategoryForProduct),
2027
- tslib_1.__metadata("design:type", CategoryForProduct)
1887
+ tslib.__metadata("design:type", CategoryForProduct)
2028
1888
  ], Product.prototype, "category", void 0);
2029
- tslib_1.__decorate([
1889
+ tslib.__decorate([
2030
1890
  classTransformer.Type(() => KitProduct),
2031
- tslib_1.__metadata("design:type", Array)
1891
+ tslib.__metadata("design:type", Array)
2032
1892
  ], Product.prototype, "kitProducts", void 0);
2033
1893
 
2034
1894
  class ProductReviews extends BaseModel {
@@ -2054,9 +1914,9 @@ class Buy2Win extends BaseModel {
2054
1914
  return ['id'];
2055
1915
  }
2056
1916
  }
2057
- tslib_1.__decorate([
1917
+ tslib.__decorate([
2058
1918
  classTransformer.Type(() => Category),
2059
- tslib_1.__metadata("design:type", Array)
1919
+ tslib.__metadata("design:type", Array)
2060
1920
  ], Buy2Win.prototype, "categories", void 0);
2061
1921
 
2062
1922
  class CampaignDashboard extends BaseModel {
@@ -2085,29 +1945,29 @@ class Checkout extends BaseModel {
2085
1945
  return ['id'];
2086
1946
  }
2087
1947
  }
2088
- tslib_1.__decorate([
1948
+ tslib.__decorate([
2089
1949
  classTransformer.Type(() => LineItem),
2090
- tslib_1.__metadata("design:type", Array)
1950
+ tslib.__metadata("design:type", Array)
2091
1951
  ], Checkout.prototype, "lineItems", void 0);
2092
- tslib_1.__decorate([
1952
+ tslib.__decorate([
2093
1953
  classTransformer.Type(() => User),
2094
- tslib_1.__metadata("design:type", User)
1954
+ tslib.__metadata("design:type", User)
2095
1955
  ], Checkout.prototype, "user", void 0);
2096
- tslib_1.__decorate([
1956
+ tslib.__decorate([
2097
1957
  classTransformer.Type(() => UserAddress),
2098
- tslib_1.__metadata("design:type", UserAddress)
1958
+ tslib.__metadata("design:type", UserAddress)
2099
1959
  ], Checkout.prototype, "shippingAddress", void 0);
2100
- tslib_1.__decorate([
1960
+ tslib.__decorate([
2101
1961
  classTransformer.Type(() => UserAddress),
2102
- tslib_1.__metadata("design:type", UserAddress)
1962
+ tslib.__metadata("design:type", UserAddress)
2103
1963
  ], Checkout.prototype, "billingAddress", void 0);
2104
- tslib_1.__decorate([
1964
+ tslib.__decorate([
2105
1965
  classTransformer.Type(() => ShippingMethod),
2106
- tslib_1.__metadata("design:type", ShippingMethod)
1966
+ tslib.__metadata("design:type", ShippingMethod)
2107
1967
  ], Checkout.prototype, "shipping", void 0);
2108
- tslib_1.__decorate([
1968
+ tslib.__decorate([
2109
1969
  classTransformer.Type(() => Coupon),
2110
- tslib_1.__metadata("design:type", Coupon)
1970
+ tslib.__metadata("design:type", Coupon)
2111
1971
  ], Checkout.prototype, "coupon", void 0);
2112
1972
 
2113
1973
  exports.OrderStatus = void 0;
@@ -2124,9 +1984,9 @@ exports.OrderStatus = void 0;
2124
1984
 
2125
1985
  class Order extends Checkout {
2126
1986
  }
2127
- tslib_1.__decorate([
1987
+ tslib.__decorate([
2128
1988
  classTransformer.Type(() => Payment),
2129
- tslib_1.__metadata("design:type", Payment)
1989
+ tslib.__metadata("design:type", Payment)
2130
1990
  ], Order.prototype, "payment", void 0);
2131
1991
 
2132
1992
  class CheckoutSubscription extends BaseModel {
@@ -2134,21 +1994,21 @@ class CheckoutSubscription extends BaseModel {
2134
1994
  return ['id'];
2135
1995
  }
2136
1996
  }
2137
- tslib_1.__decorate([
1997
+ tslib.__decorate([
2138
1998
  classTransformer.Type(() => UserAddress),
2139
- tslib_1.__metadata("design:type", UserAddress)
1999
+ tslib.__metadata("design:type", UserAddress)
2140
2000
  ], CheckoutSubscription.prototype, "shippingAddress", void 0);
2141
- tslib_1.__decorate([
2001
+ tslib.__decorate([
2142
2002
  classTransformer.Type(() => UserAddress),
2143
- tslib_1.__metadata("design:type", UserAddress)
2003
+ tslib.__metadata("design:type", UserAddress)
2144
2004
  ], CheckoutSubscription.prototype, "billingAddress", void 0);
2145
- tslib_1.__decorate([
2005
+ tslib.__decorate([
2146
2006
  classTransformer.Type(() => SubscriptionPlan),
2147
- tslib_1.__metadata("design:type", SubscriptionPlan)
2007
+ tslib.__metadata("design:type", SubscriptionPlan)
2148
2008
  ], CheckoutSubscription.prototype, "subscriptionPlan", void 0);
2149
- tslib_1.__decorate([
2009
+ tslib.__decorate([
2150
2010
  classTransformer.Type(() => Coupon),
2151
- tslib_1.__metadata("design:type", Coupon)
2011
+ tslib.__metadata("design:type", Coupon)
2152
2012
  ], CheckoutSubscription.prototype, "coupon", void 0);
2153
2013
 
2154
2014
  class SubscriptionMaterialization extends BaseModel {
@@ -2156,33 +2016,33 @@ class SubscriptionMaterialization extends BaseModel {
2156
2016
  return ['id'];
2157
2017
  }
2158
2018
  }
2159
- tslib_1.__decorate([
2019
+ tslib.__decorate([
2160
2020
  classTransformer.Type(() => User),
2161
- tslib_1.__metadata("design:type", User)
2021
+ tslib.__metadata("design:type", User)
2162
2022
  ], SubscriptionMaterialization.prototype, "user", void 0);
2163
- tslib_1.__decorate([
2023
+ tslib.__decorate([
2164
2024
  classTransformer.Type(() => SubscriptionPlan),
2165
- tslib_1.__metadata("design:type", SubscriptionPlan)
2025
+ tslib.__metadata("design:type", SubscriptionPlan)
2166
2026
  ], SubscriptionMaterialization.prototype, "subscriptionPlan", void 0);
2167
- tslib_1.__decorate([
2027
+ tslib.__decorate([
2168
2028
  classTransformer.Type(() => UserAddress),
2169
- tslib_1.__metadata("design:type", UserAddress)
2029
+ tslib.__metadata("design:type", UserAddress)
2170
2030
  ], SubscriptionMaterialization.prototype, "shippingAddress", void 0);
2171
- tslib_1.__decorate([
2031
+ tslib.__decorate([
2172
2032
  classTransformer.Type(() => UserAddress),
2173
- tslib_1.__metadata("design:type", UserAddress)
2033
+ tslib.__metadata("design:type", UserAddress)
2174
2034
  ], SubscriptionMaterialization.prototype, "billingAddress", void 0);
2175
- tslib_1.__decorate([
2035
+ tslib.__decorate([
2176
2036
  classTransformer.Type(() => Coupon),
2177
- tslib_1.__metadata("design:type", Coupon)
2037
+ tslib.__metadata("design:type", Coupon)
2178
2038
  ], SubscriptionMaterialization.prototype, "coupon", void 0);
2179
- tslib_1.__decorate([
2039
+ tslib.__decorate([
2180
2040
  classTransformer.Type(() => Edition),
2181
- tslib_1.__metadata("design:type", Array)
2041
+ tslib.__metadata("design:type", Array)
2182
2042
  ], SubscriptionMaterialization.prototype, "editions", void 0);
2183
- tslib_1.__decorate([
2043
+ tslib.__decorate([
2184
2044
  classTransformer.Type(() => SubscriptionPayment),
2185
- tslib_1.__metadata("design:type", SubscriptionPayment)
2045
+ tslib.__metadata("design:type", SubscriptionPayment)
2186
2046
  ], SubscriptionMaterialization.prototype, "payment", void 0);
2187
2047
 
2188
2048
  class SubscriptionSummary extends BaseModel {
@@ -2608,7 +2468,7 @@ class ProductsIndex {
2608
2468
  }
2609
2469
  async save(product) {
2610
2470
  try {
2611
- const { createdAt, updatedAt, kitProducts } = product, data = tslib_1.__rest(product, ["createdAt", "updatedAt", "kitProducts"]);
2471
+ const { createdAt, updatedAt, kitProducts } = product, data = tslib.__rest(product, ["createdAt", "updatedAt", "kitProducts"]);
2612
2472
  this.adapter.save(this.index, data);
2613
2473
  }
2614
2474
  catch (error) {
@@ -4207,20 +4067,20 @@ class CategoryHasuraGraphQL extends Category {
4207
4067
 
4208
4068
  class ProductHasuraGraphQL extends Product {
4209
4069
  }
4210
- tslib_1.__decorate([
4070
+ tslib.__decorate([
4211
4071
  classTransformer.Type(() => KitProductHasuraGraphQL),
4212
- tslib_1.__metadata("design:type", Array)
4072
+ tslib.__metadata("design:type", Array)
4213
4073
  ], ProductHasuraGraphQL.prototype, "kitProducts", void 0);
4214
4074
 
4215
4075
  class KitProductHasuraGraphQL extends KitProduct {
4216
4076
  }
4217
- tslib_1.__decorate([
4077
+ tslib.__decorate([
4218
4078
  classTransformer.Type(() => ProductHasuraGraphQL),
4219
- tslib_1.__metadata("design:type", ProductHasuraGraphQL)
4079
+ tslib.__metadata("design:type", ProductHasuraGraphQL)
4220
4080
  ], KitProductHasuraGraphQL.prototype, "kit", void 0);
4221
- tslib_1.__decorate([
4081
+ tslib.__decorate([
4222
4082
  classTransformer.Type(() => ProductHasuraGraphQL),
4223
- tslib_1.__metadata("design:type", ProductHasuraGraphQL)
4083
+ tslib.__metadata("design:type", ProductHasuraGraphQL)
4224
4084
  ], KitProductHasuraGraphQL.prototype, "product", void 0);
4225
4085
 
4226
4086
  class VariantHasuraGraphQL extends Variant {
@@ -4462,7 +4322,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4462
4322
  this.categoryFilterRepository = categoryFilterRepository;
4463
4323
  }
4464
4324
  async create(params) {
4465
- const { metadata } = params, data = tslib_1.__rest(params, ["metadata"]);
4325
+ const { metadata } = params, data = tslib.__rest(params, ["metadata"]);
4466
4326
  return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || { description: null, title: null } }));
4467
4327
  }
4468
4328
  async get(identifiers) {
@@ -4472,7 +4332,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4472
4332
  : super.get(identifiers);
4473
4333
  }
4474
4334
  async update(params) {
4475
- const { products, id: checkId, metadata, filters } = params, data = tslib_1.__rest(params, ["products", "id", "metadata", "filters"]);
4335
+ const { products, id: checkId, metadata, filters } = params, data = tslib.__rest(params, ["products", "id", "metadata", "filters"]);
4476
4336
  const plainData = this.paramsToPlain({ id: checkId });
4477
4337
  const id = await this.getId(plainData.id);
4478
4338
  const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: false }));
@@ -4595,18 +4455,14 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4595
4455
  const plainData = this.paramsToPlain({ products });
4596
4456
  if (!plainData.products || plainData.products.length <= 0)
4597
4457
  return [];
4598
- await this.mutation('delete_category_product', ['affected_rows'], {
4599
- where: {
4600
- type: 'category_product_bool_exp',
4601
- required: true,
4602
- value: { category_id: { _eq: categoryId } },
4603
- },
4604
- });
4458
+ const category = await this.get({ id: categoryId.toString() });
4605
4459
  await this.mutation('insert_category_product', ['affected_rows'], {
4606
4460
  objects: {
4607
4461
  type: '[category_product_insert_input!]',
4608
4462
  required: true,
4609
- value: plainData.products.map((productId) => ({ category_id: categoryId, product_id: productId })),
4463
+ value: plainData.products
4464
+ .filter((productId) => !category.products.includes(productId))
4465
+ .map((productId) => ({ category_id: categoryId, product_id: productId })),
4610
4466
  },
4611
4467
  });
4612
4468
  return plainData.products;
@@ -4644,15 +4500,14 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4644
4500
  },
4645
4501
  })
4646
4502
  .then((res) => res.data);
4647
- const currentFiltersId = currentFilters.map((f) => f.id);
4503
+ const currentFiltersId = currentFilters.map((f) => f.filterId);
4648
4504
  const filtersUpdatedId = filters.value.map((f) => f.id);
4649
4505
  const filterToBeDeleted = currentFiltersId.filter((c) => !filtersUpdatedId.includes(c));
4650
4506
  const filterToBeInserted = filtersUpdatedId.filter((c) => !currentFiltersId.includes(c));
4651
4507
  for (const filter of filterToBeDeleted) {
4652
4508
  const index = currentFilters.findIndex((f) => f.id == filter);
4653
- if (index != -1) {
4509
+ if (index != -1)
4654
4510
  currentFilters.splice(index, 1);
4655
- }
4656
4511
  await this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filter);
4657
4512
  }
4658
4513
  for (const filter of filterToBeInserted) {
@@ -4724,7 +4579,7 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
4724
4579
  this.categoryFilterRepository = categoryFilterRepository;
4725
4580
  }
4726
4581
  async update(params) {
4727
- const { options } = params, data = tslib_1.__rest(params, ["options"]);
4582
+ const { options } = params, data = tslib.__rest(params, ["options"]);
4728
4583
  const filter = await super.update(data);
4729
4584
  filter.options = await this.updateOptions(+data.id, { options });
4730
4585
  return filter;
@@ -5001,7 +4856,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5001
4856
  ];
5002
4857
  }
5003
4858
  async create(params) {
5004
- const { metadata } = params, data = tslib_1.__rest(params, ["metadata"]);
4859
+ const { metadata } = params, data = tslib.__rest(params, ["metadata"]);
5005
4860
  const product = await super.create(lodash.omit(Object.assign(Object.assign({}, data), { metadata: metadata || { description: null, title: null } }), ['reviews']));
5006
4861
  try {
5007
4862
  product.reviews = data.reviews && (await this.updateReviews(+product.id, data));
@@ -5024,7 +4879,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5024
4879
  }
5025
4880
  async find(params) {
5026
4881
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
5027
- const _o = params || {}, { filters, fields } = _o, options = tslib_1.__rest(_o, ["filters", "fields"]);
4882
+ const _o = params || {}, { filters, fields } = _o, options = tslib.__rest(_o, ["filters", "fields"]);
5028
4883
  const bindFields = fields ||
5029
4884
  this.fields
5030
4885
  .map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
@@ -5062,7 +4917,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5062
4917
  return product;
5063
4918
  }
5064
4919
  async update(params) {
5065
- const { categories, kitProducts, reviews, id: checkId, rate, metadata } = params, data = tslib_1.__rest(params, ["categories", "kitProducts", "reviews", "id", "rate", "metadata"]);
4920
+ const { categories, kitProducts, reviews, id: checkId, rate, metadata } = params, data = tslib.__rest(params, ["categories", "kitProducts", "reviews", "id", "rate", "metadata"]);
5066
4921
  const plainData = this.paramsToPlain({ id: checkId });
5067
4922
  const id = await this.getId(plainData.id);
5068
4923
  const product = await super.update(Object.assign({ id }, data));
@@ -5382,11 +5237,11 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5382
5237
  return variant;
5383
5238
  }
5384
5239
  async find(params) {
5385
- const _a = params || {}, { filters } = _a, options = tslib_1.__rest(_a, ["filters"]);
5240
+ const _a = params || {}, { filters } = _a, options = tslib.__rest(_a, ["filters"]);
5386
5241
  return super.find(Object.assign(Object.assign({}, options), { filters: Object.assign({ productId: { operator: exports.Where.ISNOTNULL } }, filters) }));
5387
5242
  }
5388
5243
  async update(params) {
5389
- const { productId, id: checkId } = params, data = tslib_1.__rest(params, ["productId", "id"]);
5244
+ const { productId, id: checkId } = params, data = tslib.__rest(params, ["productId", "id"]);
5390
5245
  const dataWithProductId = this.paramsToPlain({ id: checkId, productId });
5391
5246
  const id = await this.getId(dataWithProductId.id);
5392
5247
  const product = await super.update(Object.assign({ id }, data));
@@ -5494,7 +5349,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5494
5349
  this.categoryFilterRepository = categoryFilterRepository;
5495
5350
  }
5496
5351
  async create(params) {
5497
- const { metadata } = params, data = tslib_1.__rest(params, ["metadata"]);
5352
+ const { metadata } = params, data = tslib.__rest(params, ["metadata"]);
5498
5353
  return super.create(Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadata: metadata || { description: data.description, title: data.name } }));
5499
5354
  }
5500
5355
  async get(identifiers) {
@@ -5504,7 +5359,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5504
5359
  return data;
5505
5360
  }
5506
5361
  async update(params) {
5507
- const { products, id: checkId, metadata, filters } = params, data = tslib_1.__rest(params, ["products", "id", "metadata", "filters"]);
5362
+ const { products, id: checkId, metadata, filters } = params, data = tslib.__rest(params, ["products", "id", "metadata", "filters"]);
5508
5363
  const plainData = this.paramsToPlain({ id: checkId });
5509
5364
  const id = plainData.id;
5510
5365
  const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: true, isCollection: true, brandCategory: false }));
@@ -5561,19 +5416,24 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5561
5416
  const plainData = this.paramsToPlain({ products });
5562
5417
  if (!plainData.products || plainData.products.length <= 0)
5563
5418
  return [];
5419
+ const category = await this.get({ id: categoryId.toString() });
5420
+ await this.categoryFilterRepository.deleteByCategory(categoryId);
5564
5421
  await this.mutation('delete_category_product', ['affected_rows'], {
5565
5422
  where: {
5566
5423
  type: 'category_product_bool_exp',
5567
5424
  required: true,
5568
- value: { category_id: { _eq: categoryId } },
5425
+ value: {
5426
+ category_id: { _in: category.products.filter((productId) => !plainData.products.includes(productId)) },
5427
+ },
5569
5428
  },
5570
5429
  });
5571
- await this.categoryFilterRepository.deleteByCategory(categoryId);
5572
5430
  await this.mutation('insert_category_product', ['affected_rows'], {
5573
5431
  objects: {
5574
5432
  type: '[category_product_insert_input!]',
5575
5433
  required: true,
5576
- value: plainData.products.map((productId) => ({ category_id: categoryId, product_id: productId })),
5434
+ value: plainData.products
5435
+ .filter((productId) => !category.products.includes(productId))
5436
+ .map((productId) => ({ category_id: categoryId, product_id: productId })),
5577
5437
  },
5578
5438
  });
5579
5439
  return plainData.products;