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;YACT,CAAC;YACD,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;YACvB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACvB,CAAC;IACH,CAAC;IAEO,2CAAkB,GAA1B,UAA2B,KAAQ,EAAE,KAAa;QAChD,IAAI,MAAW,CAAC;QAChB,IAAI,CAAC;YACH,MAAM,GAAS,IAAK,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACpD,CAAE;QAAA,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACb,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC5B,MAAM,CAAC;QACT,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;IAES,kCAAS,GAAnB;QACE,IAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACrC,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YAClB,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACjC,WAAW,CAAC,QAAQ,EAAE,CAAC;QACzB,CAAC;QAAC,IAAI,CAAC,CAAC;YACN,WAAW,CAAC,KAAK,CAAC,IAAI,uBAAU,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IACH,qBAAC;AAAD,CAAC,AAtED,CAAmC,uBAAU,GAsE5C","sourcesContent":["import { Observable } from '../Observable';\nimport { Operator } from '../Operator';\nimport { Subscriber } from '../Subscriber';\nimport { EmptyError } from '../util/EmptyError';\nimport { OperatorFunction, MonoTypeOperatorFunction } from '../interfaces';\n\n/* tslint:disable:max-line-length */\nexport function last<T, S extends T>(predicate: (value: T, index: number, source: Observable<T>) => value is S): OperatorFunction<T, S>;\nexport function last<T, S extends T, R>(predicate: (value: T | S, index: number, source: Observable<T>) => value is S,\n resultSelector: (value: S, index: number) => R, defaultValue?: R): OperatorFunction<T, R>;\nexport function last<T, S extends T>(predicate: (value: T, index: number, source: Observable<T>) => value is S,\n resultSelector: void,\n defaultValue?: S): OperatorFunction<T, S>;\nexport function last<T>(predicate?: (value: T, index: number, source: Observable<T>) => boolean): MonoTypeOperatorFunction<T>;\nexport function last<T, R>(predicate: (value: T, index: number, source: Observable<T>) => boolean,\n resultSelector?: (value: T, index: number) => R,\n defaultValue?: R): OperatorFunction<T, R>;\nexport function last<T>(predicate: (value: T, index: number, source: Observable<T>) => boolean,\n resultSelector: void,\n defaultValue?: T): MonoTypeOperatorFunction<T>;\n/* tslint:enable:max-line-length */\n\n/**\n * Returns an Observable that emits only the last item emitted by the source Observable.\n * It optionally takes a predicate function as a parameter, in which case, rather than emitting\n * the last item from the source Observable, the resulting Observable will emit the last item\n * from the source Observable that satisfies the predicate.\n *\n * <img src=\"./img/last.png\" width=\"100%\">\n *\n * @throws {EmptyError} Delivers an EmptyError to the Observer's `error`\n * callback if the Observable completes before any `next` notification was sent.\n * @param {function} predicate - The condition any source emitted item has to satisfy.\n * @return {Observable} An Observable that emits only the last item satisfying the given condition\n * from the source, or an NoSuchElementException if no such items are emitted.\n * @throws - Throws if no items that match the predicate are emitted by the source Observable.\n * @method last\n * @owner Observable\n */\nexport function last<T, R>(predicate?: (value: T, index: number, source: Observable<T>) => boolean,\n resultSelector?: ((value: T, index: number) => R) | void,\n defaultValue?: R): OperatorFunction<T, T | R> {\n return (source: Observable<T>) => source.lift(new LastOperator(predicate, resultSelector, defaultValue, source));\n}\n\nclass LastOperator<T, R> implements Operator<T, R> {\n constructor(private predicate?: (value: T, index: number, source: Observable<T>) => boolean,\n private resultSelector?: ((value: T, index: number) => R) | void,\n private defaultValue?: any,\n private source?: Observable<T>) {\n }\n\n call(observer: Subscriber<R>, source: any): any {\n return source.subscribe(new LastSubscriber(observer, this.predicate, this.resultSelector, this.defaultValue, this.source));\n }\n}\n\n/**\n * We need this JSDoc comment for affecting ESDoc.\n * @ignore\n * @extends {Ignored}\n */\nclass LastSubscriber<T, R> extends Subscriber<T> {\n private lastValue: T | R;\n private hasValue: boolean = false;\n private index: number = 0;\n\n constructor(destination: Subscriber<R>,\n private predicate?: (value: T, index: number, source: Observable<T>) => boolean,\n private resultSelector?: ((value: T, index: number) => R) | void,\n private defaultValue?: any,\n private source?: Observable<T>) {\n super(destination);\n if (typeof defaultValue !== 'undefined') {\n this.lastValue = defaultValue;\n this.hasValue = true;\n }\n }\n\n protected _next(value: T): void {\n const index = this.index++;\n if (this.predicate) {\n this._tryPredicate(value, index);\n } else {\n if (this.resultSelector) {\n this._tryResultSelector(value, index);\n return;\n }\n this.lastValue = value;\n this.hasValue = true;\n }\n }\n\n private _tryPredicate(value: T, index: number) {\n let result: any;\n try {\n result = this.predicate(value, index, this.source);\n } catch (err) {\n this.destination.error(err);\n return;\n }\n if (result) {\n if (this.resultSelector) {\n this._tryResultSelector(value, index);\n return;\n }\n this.lastValue = value;\n this.hasValue = true;\n }\n }\n\n private _tryResultSelector(value: T, index: number) {\n let result: any;\n try {\n result = (<any>this).resultSelector(value, index);\n } catch (err) {\n this.destination.error(err);\n return;\n }\n this.lastValue = result;\n this.hasValue = true;\n }\n\n protected _complete(): void {\n const destination = this.destination;\n if (this.hasValue) {\n destination.next(this.lastValue);\n destination.complete();\n } else {\n destination.error(new EmptyError);\n }\n }\n}\n"]}