{"ast":null,"code":"import _inherits from \"C:/Users/kgamal/Downloads/HijriGregorianDatepicker-master/HijriGregorianDatepicker-master/node_modules/@babel/runtime/helpers/esm/inherits\";\nimport _createSuper from \"C:/Users/kgamal/Downloads/HijriGregorianDatepicker-master/HijriGregorianDatepicker-master/node_modules/@babel/runtime/helpers/esm/createSuper\";\nimport _classCallCheck from \"C:/Users/kgamal/Downloads/HijriGregorianDatepicker-master/HijriGregorianDatepicker-master/node_modules/@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"C:/Users/kgamal/Downloads/HijriGregorianDatepicker-master/HijriGregorianDatepicker-master/node_modules/@babel/runtime/helpers/esm/createClass\";\nimport { Subscriber } from '../Subscriber';\nimport { Observable } from '../Observable';\nimport { OuterSubscriber } from '../OuterSubscriber';\nimport { subscribeToResult } from '../util/subscribeToResult';\nexport function delayWhen(delayDurationSelector, subscriptionDelay) {\n  if (subscriptionDelay) {\n    return function (source) {\n      return new SubscriptionDelayObservable(source, subscriptionDelay).lift(new DelayWhenOperator(delayDurationSelector));\n    };\n  }\n\n  return function (source) {\n    return source.lift(new DelayWhenOperator(delayDurationSelector));\n  };\n}\n\nvar DelayWhenOperator = /*#__PURE__*/function () {\n  function DelayWhenOperator(delayDurationSelector) {\n    _classCallCheck(this, DelayWhenOperator);\n\n    this.delayDurationSelector = delayDurationSelector;\n  }\n\n  _createClass(DelayWhenOperator, [{\n    key: \"call\",\n    value: function call(subscriber, source) {\n      return source.subscribe(new DelayWhenSubscriber(subscriber, this.delayDurationSelector));\n    }\n  }]);\n\n  return DelayWhenOperator;\n}();\n\nvar DelayWhenSubscriber = /*#__PURE__*/function (_OuterSubscriber) {\n  _inherits(DelayWhenSubscriber, _OuterSubscriber);\n\n  var _super = _createSuper(DelayWhenSubscriber);\n\n  function DelayWhenSubscriber(destination, delayDurationSelector) {\n    var _this;\n\n    _classCallCheck(this, DelayWhenSubscriber);\n\n    _this = _super.call(this, destination);\n    _this.delayDurationSelector = delayDurationSelector;\n    _this.completed = false;\n    _this.delayNotifierSubscriptions = [];\n    _this.index = 0;\n    return _this;\n  }\n\n  _createClass(DelayWhenSubscriber, [{\n    key: \"notifyNext\",\n    value: function notifyNext(outerValue, _innerValue, _outerIndex, _innerIndex, innerSub) {\n      this.destination.next(outerValue);\n      this.removeSubscription(innerSub);\n      this.tryComplete();\n    }\n  }, {\n    key: \"notifyError\",\n    value: function notifyError(error, innerSub) {\n      this._error(error);\n    }\n  }, {\n    key: \"notifyComplete\",\n    value: function notifyComplete(innerSub) {\n      var value = this.removeSubscription(innerSub);\n\n      if (value) {\n        this.destination.next(value);\n      }\n\n      this.tryComplete();\n    }\n  }, {\n    key: \"_next\",\n    value: function _next(value) {\n      var index = this.index++;\n\n      try {\n        var delayNotifier = this.delayDurationSelector(value, index);\n\n        if (delayNotifier) {\n          this.tryDelay(delayNotifier, value);\n        }\n      } catch (err) {\n        this.destination.error(err);\n      }\n    }\n  }, {\n    key: \"_complete\",\n    value: function _complete() {\n      this.completed = true;\n      this.tryComplete();\n      this.unsubscribe();\n    }\n  }, {\n    key: \"removeSubscription\",\n    value: function removeSubscription(subscription) {\n      subscription.unsubscribe();\n      var subscriptionIdx = this.delayNotifierSubscriptions.indexOf(subscription);\n\n      if (subscriptionIdx !== -1) {\n        this.delayNotifierSubscriptions.splice(subscriptionIdx, 1);\n      }\n\n      return subscription.outerValue;\n    }\n  }, {\n    key: \"tryDelay\",\n    value: function tryDelay(delayNotifier, value) {\n      var notifierSubscription = subscribeToResult(this, delayNotifier, value);\n\n      if (notifierSubscription && !notifierSubscription.closed) {\n        var destination = this.destination;\n        destination.add(notifierSubscription);\n        this.delayNotifierSubscriptions.push(notifierSubscription);\n      }\n    }\n  }, {\n    key: \"tryComplete\",\n    value: function tryComplete() {\n      if (this.completed && this.delayNotifierSubscriptions.length === 0) {\n        this.destination.complete();\n      }\n    }\n  }]);\n\n  return DelayWhenSubscriber;\n}(OuterSubscriber);\n\nvar SubscriptionDelayObservable = /*#__PURE__*/function (_Observable) {\n  _inherits(SubscriptionDelayObservable, _Observable);\n\n  var _super2 = _createSuper(SubscriptionDelayObservable);\n\n  function SubscriptionDelayObservable(source, subscriptionDelay) {\n    var _this2;\n\n    _classCallCheck(this, SubscriptionDelayObservable);\n\n    _this2 = _super2.call(this);\n    _this2.source = source;\n    _this2.subscriptionDelay = subscriptionDelay;\n    return _this2;\n  }\n\n  _createClass(SubscriptionDelayObservable, [{\n    key: \"_subscribe\",\n    value: function _subscribe(subscriber) {\n      this.subscriptionDelay.subscribe(new SubscriptionDelaySubscriber(subscriber, this.source));\n    }\n  }]);\n\n  return SubscriptionDelayObservable;\n}(Observable);\n\nvar SubscriptionDelaySubscriber = /*#__PURE__*/function (_Subscriber) {\n  _inherits(SubscriptionDelaySubscriber, _Subscriber);\n\n  var _super3 = _createSuper(SubscriptionDelaySubscriber);\n\n  function SubscriptionDelaySubscriber(parent, source) {\n    var _this3;\n\n    _classCallCheck(this, SubscriptionDelaySubscriber);\n\n    _this3 = _super3.call(this);\n    _this3.parent = parent;\n    _this3.source = source;\n    _this3.sourceSubscribed = false;\n    return _this3;\n  }\n\n  _createClass(SubscriptionDelaySubscriber, [{\n    key: \"_next\",\n    value: function _next(unused) {\n      this.subscribeToSource();\n    }\n  }, {\n    key: \"_error\",\n    value: function _error(err) {\n      this.unsubscribe();\n      this.parent.error(err);\n    }\n  }, {\n    key: \"_complete\",\n    value: function _complete() {\n      this.unsubscribe();\n      this.subscribeToSource();\n    }\n  }, {\n    key: \"subscribeToSource\",\n    value: function subscribeToSource() {\n      if (!this.sourceSubscribed) {\n        this.sourceSubscribed = true;\n        this.unsubscribe();\n        this.source.subscribe(this.parent);\n      }\n    }\n  }]);\n\n  return SubscriptionDelaySubscriber;\n}(Subscriber); //# sourceMappingURL=delayWhen.js.map","map":null,"metadata":{},"sourceType":"module"}