{"ast":null,"code":"import { Observable } from './Observable';\nimport { Subscriber } from './Subscriber';\nimport { Subscription } from './Subscription';\nimport { ObjectUnsubscribedError } from './util/ObjectUnsubscribedError';\nimport { SubjectSubscription } from './SubjectSubscription';\nimport { rxSubscriber as rxSubscriberSymbol } from '../internal/symbol/rxSubscriber';\nexport class SubjectSubscriber extends Subscriber {\n  constructor(destination) {\n    super(destination);\n    this.destination = destination;\n  }\n\n}\nexport let Subject = /*#__PURE__*/(() => {\n  class Subject extends Observable {\n    constructor() {\n      super();\n      this.observers = [];\n      this.closed = false;\n      this.isStopped = false;\n      this.hasError = false;\n      this.thrownError = null;\n    }\n\n    [rxSubscriberSymbol]() {\n      return new SubjectSubscriber(this);\n    }\n\n    lift(operator) {\n      const subject = new AnonymousSubject(this, this);\n      subject.operator = operator;\n      return subject;\n    }\n\n    next(value) {\n      if (this.closed) {\n        throw new ObjectUnsubscribedError();\n      }\n\n      if (!this.isStopped) {\n        const {\n          observers\n        } = this;\n        const len = observers.length;\n        const copy = observers.slice();\n\n        for (let i = 0; i < len; i++) {\n          copy[i].next(value);\n        }\n      }\n    }\n\n    error(err) {\n      if (this.closed) {\n        throw new ObjectUnsubscribedError();\n      }\n\n      this.hasError = true;\n      this.thrownError = err;\n      this.isStopped = true;\n      const {\n        observers\n      } = this;\n      const len = observers.length;\n      const copy = observers.slice();\n\n      for (let i = 0; i < len; i++) {\n        copy[i].error(err);\n      }\n\n      this.observers.length = 0;\n    }\n\n    complete() {\n      if (this.closed) {\n        throw new ObjectUnsubscribedError();\n      }\n\n      this.isStopped = true;\n      const {\n        observers\n      } = this;\n      const len = observers.length;\n      const copy = observers.slice();\n\n      for (let i = 0; i < len; i++) {\n        copy[i].complete();\n      }\n\n      this.observers.length = 0;\n    }\n\n    unsubscribe() {\n      this.isStopped = true;\n      this.closed = true;\n      this.observers = null;\n    }\n\n    _trySubscribe(subscriber) {\n      if (this.closed) {\n        throw new ObjectUnsubscribedError();\n      } else {\n        return super._trySubscribe(subscriber);\n      }\n    }\n\n    _subscribe(subscriber) {\n      if (this.closed) {\n        throw new ObjectUnsubscribedError();\n      } else if (this.hasError) {\n        subscriber.error(this.thrownError);\n        return Subscription.EMPTY;\n      } else if (this.isStopped) {\n        subscriber.complete();\n        return Subscription.EMPTY;\n      } else {\n        this.observers.push(subscriber);\n        return new SubjectSubscription(this, subscriber);\n      }\n    }\n\n    asObservable() {\n      const observable = new Observable();\n      observable.source = this;\n      return observable;\n    }\n\n  }\n\n  Subject.create = (destination, source) => {\n    return new AnonymousSubject(destination, source);\n  };\n\n  return Subject;\n})();\nexport class AnonymousSubject extends Subject {\n  constructor(destination, source) {\n    super();\n    this.destination = destination;\n    this.source = source;\n  }\n\n  next(value) {\n    const {\n      destination\n    } = this;\n\n    if (destination && destination.next) {\n      destination.next(value);\n    }\n  }\n\n  error(err) {\n    const {\n      destination\n    } = this;\n\n    if (destination && destination.error) {\n      this.destination.error(err);\n    }\n  }\n\n  complete() {\n    const {\n      destination\n    } = this;\n\n    if (destination && destination.complete) {\n      this.destination.complete();\n    }\n  }\n\n  _subscribe(subscriber) {\n    const {\n      source\n    } = this;\n\n    if (source) {\n      return this.source.subscribe(subscriber);\n    } else {\n      return Subscription.EMPTY;\n    }\n  }\n\n} //# sourceMappingURL=Subject.js.map","map":null,"metadata":{},"sourceType":"module"}