{"ast":null,"code":"import _get from \"C:/Users/kgamal/Downloads/HijriGregorianDatepicker-master/HijriGregorianDatepicker-master/node_modules/@babel/runtime/helpers/esm/get\";\nimport _getPrototypeOf from \"C:/Users/kgamal/Downloads/HijriGregorianDatepicker-master/HijriGregorianDatepicker-master/node_modules/@babel/runtime/helpers/esm/getPrototypeOf\";\nimport _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 { Subscription } from '../Subscription';\nimport { SimpleOuterSubscriber, innerSubscribe, SimpleInnerSubscriber } from '../innerSubscribe';\nexport function bufferWhen(closingSelector) {\n  return function (source) {\n    return source.lift(new BufferWhenOperator(closingSelector));\n  };\n}\n\nvar BufferWhenOperator = /*#__PURE__*/function () {\n  function BufferWhenOperator(closingSelector) {\n    _classCallCheck(this, BufferWhenOperator);\n\n    this.closingSelector = closingSelector;\n  }\n\n  _createClass(BufferWhenOperator, [{\n    key: \"call\",\n    value: function call(subscriber, source) {\n      return source.subscribe(new BufferWhenSubscriber(subscriber, this.closingSelector));\n    }\n  }]);\n\n  return BufferWhenOperator;\n}();\n\nvar BufferWhenSubscriber = /*#__PURE__*/function (_SimpleOuterSubscribe) {\n  _inherits(BufferWhenSubscriber, _SimpleOuterSubscribe);\n\n  var _super = _createSuper(BufferWhenSubscriber);\n\n  function BufferWhenSubscriber(destination, closingSelector) {\n    var _this;\n\n    _classCallCheck(this, BufferWhenSubscriber);\n\n    _this = _super.call(this, destination);\n    _this.closingSelector = closingSelector;\n    _this.subscribing = false;\n\n    _this.openBuffer();\n\n    return _this;\n  }\n\n  _createClass(BufferWhenSubscriber, [{\n    key: \"_next\",\n    value: function _next(value) {\n      this.buffer.push(value);\n    }\n  }, {\n    key: \"_complete\",\n    value: function _complete() {\n      var buffer = this.buffer;\n\n      if (buffer) {\n        this.destination.next(buffer);\n      }\n\n      _get(_getPrototypeOf(BufferWhenSubscriber.prototype), \"_complete\", this).call(this);\n    }\n  }, {\n    key: \"_unsubscribe\",\n    value: function _unsubscribe() {\n      this.buffer = undefined;\n      this.subscribing = false;\n    }\n  }, {\n    key: \"notifyNext\",\n    value: function notifyNext() {\n      this.openBuffer();\n    }\n  }, {\n    key: \"notifyComplete\",\n    value: function notifyComplete() {\n      if (this.subscribing) {\n        this.complete();\n      } else {\n        this.openBuffer();\n      }\n    }\n  }, {\n    key: \"openBuffer\",\n    value: function openBuffer() {\n      var closingSubscription = this.closingSubscription;\n\n      if (closingSubscription) {\n        this.remove(closingSubscription);\n        closingSubscription.unsubscribe();\n      }\n\n      var buffer = this.buffer;\n\n      if (this.buffer) {\n        this.destination.next(buffer);\n      }\n\n      this.buffer = [];\n      var closingNotifier;\n\n      try {\n        var closingSelector = this.closingSelector;\n        closingNotifier = closingSelector();\n      } catch (err) {\n        return this.error(err);\n      }\n\n      closingSubscription = new Subscription();\n      this.closingSubscription = closingSubscription;\n      this.add(closingSubscription);\n      this.subscribing = true;\n      closingSubscription.add(innerSubscribe(closingNotifier, new SimpleInnerSubscriber(this)));\n      this.subscribing = false;\n    }\n  }]);\n\n  return BufferWhenSubscriber;\n}(SimpleOuterSubscriber); //# sourceMappingURL=bufferWhen.js.map","map":null,"metadata":{},"sourceType":"module"}