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AU,CAAC,CAAC;QAC7D,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QAC5C,MAAM,CAAC,YAAY,CAAC;IACtB,CAAC;IACH,wBAAC;AAAD,CAAC,AAXD,IAWC;AAXY,yBAAiB,oBAW7B,CAAA","sourcesContent":["import { Subject } from '../Subject';\nimport { Operator } from '../Operator';\nimport { Subscriber } from '../Subscriber';\nimport { Observable } from '../Observable';\nimport { ConnectableObservable, connectableObservableDescriptor } from '../observable/ConnectableObservable';\nimport { FactoryOrValue, MonoTypeOperatorFunction, OperatorFunction, UnaryFunction } from '../interfaces';\n\n/* tslint:disable:max-line-length */\nexport function multicast<T>(subjectOrSubjectFactory: FactoryOrValue<Subject<T>>): UnaryFunction<Observable<T>, ConnectableObservable<T>>;\nexport function multicast<T>(SubjectFactory: (this: Observable<T>) => Subject<T>, selector?: MonoTypeOperatorFunction<T>): MonoTypeOperatorFunction<T>;\nexport function multicast<T, R>(SubjectFactory: (this: Observable<T>) => Subject<T>, selector?: OperatorFunction<T, R>): OperatorFunction<T, R>;\n/* tslint:enable:max-line-length */\n\n/**\n * Returns an Observable that emits the results of invoking a specified selector on items\n * emitted by a ConnectableObservable that shares a single subscription to the underlying stream.\n *\n * <img src=\"./img/multicast.png\" width=\"100%\">\n *\n * @param {Function|Subject} subjectOrSubjectFactory - Factory function to create an intermediate subject through\n * which the source sequence's elements will be multicast to the selector function\n * or Subject to push source elements into.\n * @param {Function} [selector] - Optional selector function that can use the multicasted source stream\n * as many times as needed, without causing multiple subscriptions to the source stream.\n * Subscribers to the given source will receive all notifications of the source from the\n * time of the subscription forward.\n * @return {Observable} An Observable that emits the results of invoking the selector\n * on the items emitted by a `ConnectableObservable` that shares a single subscription to\n * the underlying stream.\n * @method multicast\n * @owner Observable\n */\nexport function multicast<T, R>(subjectOrSubjectFactory: Subject<T> | (() => Subject<T>),\n selector?: (source: Observable<T>) => Observable<R>): OperatorFunction<T, R> {\n return function multicastOperatorFunction(source: Observable<T>): Observable<R> {\n let subjectFactory: () => Subject<T>;\n if (typeof subjectOrSubjectFactory === 'function') {\n subjectFactory = <() => Subject<T>>subjectOrSubjectFactory;\n } else {\n subjectFactory = function subjectFactory() {\n return <Subject<T>>subjectOrSubjectFactory;\n };\n }\n\n if (typeof selector === 'function') {\n return source.lift(new MulticastOperator(subjectFactory, selector));\n }\n\n const connectable: any = Object.create(source, connectableObservableDescriptor);\n connectable.source = source;\n connectable.subjectFactory = subjectFactory;\n\n return <ConnectableObservable<R>> connectable;\n };\n}\n\nexport class MulticastOperator<T, R> implements Operator<T, R> {\n constructor(private subjectFactory: () => Subject<T>,\n private selector: (source: Observable<T>) => Observable<R>) {\n }\n call(subscriber: Subscriber<R>, source: any): any {\n const { selector } = this;\n const subject = this.subjectFactory();\n const subscription = selector(subject).subscribe(subscriber);\n subscription.add(source.subscribe(subject));\n return subscription;\n }\n}\n"]}