From c16e58b8b5a5caee59babeb4ee4447105cc23dfb Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Mon, 17 Mar 2014 23:28:23 -0400 Subject: [PATCH] Fixing backpressure and adding controlled --- Gruntfile.js | 18 +- bower.json | 2 +- .../RxJS-BackPressure.nuspec | 2 +- package.json | 2 +- rx.backpressure.js | 265 +++++++++++++++++- rx.backpressure.min.js | 2 +- rx.lite.compat.js | 253 +++++++++++++++++ rx.lite.compat.min.js | 4 +- rx.lite.js | 253 +++++++++++++++++ rx.lite.min.js | 4 +- src/core/backpressure/controlledsubject.js | 8 +- ...auseblebuffered.js => pausablebuffered.js} | 47 +++- src/core/backpressureheader.js | 12 +- tests/observable/controlled.js | 97 +++++++ tests/observable/pausable.js | 146 ++++++++++ tests/observable/pausablebuffered.js | 149 ++++++++++ tests/rx.backpressure.html | 24 ++ tests/rx.lite.compat.html | 4 + tests/rx.lite.html | 4 + 19 files changed, 1262 insertions(+), 34 deletions(-) rename src/core/backpressure/{pauseblebuffered.js => pausablebuffered.js} (57%) create mode 100644 tests/observable/controlled.js create mode 100644 tests/observable/pausable.js create mode 100644 tests/observable/pausablebuffered.js create mode 100644 tests/rx.backpressure.html diff --git a/Gruntfile.js b/Gruntfile.js index 9697c4575..048718fc3 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -423,11 +423,11 @@ var browsers = [{ // Backpressure operators 'src/core/backpressure/pausable.js', 'src/core/backpressure/pausablebuffered.js', -/* 'src/core/backpressure/controlled.js', + 'src/core/backpressure/controlled.js', 'src/core/backpressure/controlledobservable.js', 'src/core/backpressure/controlledsubject.js', - 'src/core/backpressure/windowed.js', - 'src/core/backpressure/windowedobservable.js',*/ + //'src/core/backpressure/windowed.js', + //'src/core/backpressure/windowedobservable.js', 'src/core/anonymousobservable.js', 'src/core/autodetachobserver.js', @@ -581,11 +581,11 @@ var browsers = [{ // Backpressure operators 'src/core/backpressure/pausable.js', 'src/core/backpressure/pausablebuffered.js', -/* 'src/core/backpressure/controlled.js', + 'src/core/backpressure/controlled.js', 'src/core/backpressure/controlledobservable.js', 'src/core/backpressure/controlledsubject.js', - 'src/core/backpressure/windowed.js', - 'src/core/backpressure/windowedobservable.js',*/ + //'src/core/backpressure/windowed.js', + //'src/core/backpressure/windowedobservable.js', 'src/core/anonymousobservable.js', 'src/core/autodetachobserver.js', @@ -610,11 +610,11 @@ var browsers = [{ // Backpressure operators 'src/core/backpressure/pausable.js', 'src/core/backpressure/pausablebuffered.js', -/* 'src/core/backpressure/controlled.js', + 'src/core/backpressure/controlled.js', 'src/core/backpressure/controlledobservable.js', 'src/core/backpressure/controlledsubject.js', - 'src/core/backpressure/windowed.js', - 'src/core/backpressure/windowedobservable.js',*/ + //'src/core/backpressure/windowed.js', + //'src/core/backpressure/windowedobservable.js', 'src/core/suboutro.js' ], diff --git a/bower.json b/bower.json index a89e71c2b..17782af7f 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "rxjs", - "version": "2.2.14", + "version": "2.2.15", "main": [ "rx.js", "rx.compat.js", diff --git a/nuget/RxJS-BackPressure/RxJS-BackPressure.nuspec b/nuget/RxJS-BackPressure/RxJS-BackPressure.nuspec index 1c07bb766..6f3cdec52 100644 --- a/nuget/RxJS-BackPressure/RxJS-BackPressure.nuspec +++ b/nuget/RxJS-BackPressure/RxJS-BackPressure.nuspec @@ -1,7 +1,7 @@ - RxJS-Async + RxJS-BackPressure Reactive Extensions for JavaScript - BackPressure-Based Operations 2.2.7 diff --git a/package.json b/package.json index 1c667ad69..0c60f419c 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "rx", "title": "Reactive Extensions for JavaScript (RxJS)", "description": "Library for composing asynchronous and event-based operations in JavaScript", - "version": "2.2.14", + "version": "2.2.15", "homepage": "https://github.com/Reactive-Extensions/RxJS", "author": { "name": "Cloud Programmability Team", diff --git a/rx.backpressure.js b/rx.backpressure.js index 42c1505af..1ef15f21d 100644 --- a/rx.backpressure.js +++ b/rx.backpressure.js @@ -36,19 +36,19 @@ // References var Observable = Rx.Observable, observableProto = Observable.prototype, - AnonymousObservable = Rx.Internals.AnonymousObservable, + AnonymousObservable = Rx.AnonymousObservable, + CompositeDisposable = Rx.CompositeDisposable, Subject = Rx.Subject, Observer = Rx.Observer, disposableEmpty = Rx.Disposable.empty, disposableCreate = Rx.Disposable.create, - inherits = Rx.Internals.inherits, - addProperties = Rx.Internals.addProperties, + inherits = Rx.internals.inherits, + addProperties = Rx.internals.addProperties, timeoutScheduler = Rx.Scheduler.timeout; var objectDisposed = 'Object has been disposed'; - function checkDisposed() { - if (this.isDisposed) { throw new Error(objectDisposed); } - } + function checkDisposed() { if (this.isDisposed) { throw new Error(objectDisposed); } } + function identity (x) { return x; } /** * Pauses the underlying observable sequence based upon the observable sequence which yields true/false. @@ -77,5 +77,258 @@ return new CompositeDisposable(subscription, connection, pausable); }); }; + function combineLatestSource(source, subject, resultSelector) { + return new AnonymousObservable(function (observer) { + var n = 2, + hasValue = [false, false], + hasValueAll = false, + isDone = false, + values = new Array(n); + + function next(x, i) { + values[i] = x + var res; + hasValue[i] = true; + if (hasValueAll || (hasValueAll = hasValue.every(identity))) { + try { + res = resultSelector.apply(null, values); + } catch (ex) { + observer.onError(ex); + return; + } + observer.onNext(res); + } else if (isDone) { + observer.onCompleted(); + } + } + + return new CompositeDisposable( + source.subscribe( + function (x) { + next(x, 0); + }, + observer.onError.bind(observer), + function () { + isDone = true; + observer.onCompleted(); + }), + subject.subscribe( + function (x) { + next(x, 1); + }, + observer.onError.bind(observer)) + ); + }); + } + + /** + * Pauses the underlying observable sequence based upon the observable sequence which yields true/false, + * and yields the values that were buffered while paused. + * @example + * var pauser = new Rx.Subject(); + * var source = Rx.Observable.interval(100).pausableBuffered(pauser); + * @param {Observable} pauser The observable sequence used to pause the underlying sequence. + * @returns {Observable} The observable sequence which is paused based upon the pauser. + */ + observableProto.pausableBuffered = function (subject) { + var source = this; + return new AnonymousObservable(function (observer) { + var q = [], previous = true; + + var subscription = + combineLatestSource( + source, + subject.distinctUntilChanged(), + function (data, shouldFire) { + return { data: data, shouldFire: shouldFire }; + }) + .subscribe( + function (results) { + if (results.shouldFire && previous) { + observer.onNext(results.data); + } + if (results.shouldFire && !previous) { + while (q.length > 0) { + observer.onNext(q.shift()); + } + previous = true; + } else if (!results.shouldFire && !previous) { + q.push(results.data); + } else if (!results.shouldFire && previous) { + previous = false; + } + + }, + observer.onError.bind(observer), + observer.onCompleted.bind(observer) + ); + + subject.onNext(false); + + return subscription; + }); + }; + + /** + * Attaches a controller to the observable sequence with the ability to queue. + * @example + * var source = Rx.Observable.interval(100).controlled(); + * source.request(3); // Reads 3 values + * @param {Observable} pauser The observable sequence used to pause the underlying sequence. + * @returns {Observable} The observable sequence which is paused based upon the pauser. + */ + observableProto.controlled = function (enableQueue) { + if (enableQueue == null) { enableQueue = true; } + return new ControlledObservable(this, enableQueue); + }; + var ControlledObservable = (function (_super) { + + inherits(ControlledObservable, _super); + + function subscribe (observer) { + return this.source.subscribe(observer); + } + + function ControlledObservable (source, enableQueue) { + _super.call(this, subscribe); + this.subject = new ControlledSubject(enableQueue); + this.source = source.multicast(this.subject).refCount(); + } + + ControlledObservable.prototype.request = function (numberOfItems) { + if (numberOfItems == null) { numberOfItems = -1; } + return this.subject.request(numberOfItems); + }; + + return ControlledObservable; + + }(Observable)); + + var ControlledSubject = Rx.ControlledSubject = (function (_super) { + + function subscribe (observer) { + return this.subject.subscribe(observer); + } + + inherits(ControlledSubject, _super); + + function ControlledSubject(enableQueue) { + if (enableQueue == null) { + enableQueue = true; + } + + _super.call(this, subscribe); + this.subject = new Subject(); + this.enableQueue = enableQueue; + this.queue = enableQueue ? [] : null; + this.requestedCount = 0; + this.requestedDisposable = disposableEmpty; + this.error = null; + this.hasFailed = false; + this.hasCompleted = false; + this.controlledDisposable = disposableEmpty; + } + + addProperties(ControlledSubject.prototype, Observer, { + onCompleted: function () { + checkDisposed.call(this); + this.hasCompleted = true; + + if (!this.enableQueue || this.queue.length === 0) { + this.subject.onCompleted(); + } + }, + onError: function (error) { + checkDisposed.call(this); + this.hasFailed = true; + this.error = error; + + if (!this.enableQueue || this.queue.length === 0) { + this.subject.onError(error); + } + }, + onNext: function (value) { + checkDisposed.call(this); + var hasRequested = false; + + if (this.requestedCount === 0) { + if (this.enableQueue) { + this.queue.push(value); + } + } else { + if (this.requestedCount !== -1) { + if (this.requestedCount-- === 0) { + this.disposeCurrentRequest(); + } + } + hasRequested = true; + } + + if (hasRequested) { + this.subject.onNext(value); + } + }, + _processRequest: function (numberOfItems) { + if (this.enableQueue) { + //console.log('queue length', this.queue.length); + + while (this.queue.length >= numberOfItems && numberOfItems > 0) { + //console.log('number of items', numberOfItems); + this.subject.onNext(this.queue.shift()); + numberOfItems--; + } + + if (this.queue.length !== 0) { + return { numberOfItems: numberOfItems, returnValue: true }; + } else { + return { numberOfItems: numberOfItems, returnValue: false }; + } + } + + if (this.hasFailed) { + this.subject.onError(this.error); + this.controlledDisposable.dispose(); + this.controlledDisposable = disposableEmpty; + } else if (this.hasCompleted) { + this.subject.onCompleted(); + this.controlledDisposable.dispose(); + this.controlledDisposable = disposableEmpty; + } + + return { numberOfItems: numberOfItems, returnValue: false }; + }, + request: function (number) { + checkDisposed.call(this); + this.disposeCurrentRequest(); + var self = this, + r = this._processRequest(number); + + number = r.numberOfItems; + if (!r.returnValue) { + this.requestedCount = number; + this.requestedDisposable = disposableCreate(function () { + self.requestedCount = 0; + }); + + return this.requestedDisposable + } else { + return disposableEmpty; + } + }, + disposeCurrentRequest: function () { + this.requestedDisposable.dispose(); + this.requestedDisposable = disposableEmpty; + }, + + dispose: function () { + this.isDisposed = true; + this.error = null; + this.subject.dispose(); + this.requestedDisposable.dispose(); + } + }); + + return ControlledSubject; + }(Observable)); return Rx; })); \ No newline at end of file diff --git a/rx.backpressure.min.js b/rx.backpressure.min.js index e0d5e1a0c..8c0657b33 100644 --- a/rx.backpressure.min.js +++ b/rx.backpressure.min.js @@ -1 +1 @@ -(function(a){var b={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},c=b[typeof window]&&window||this,d=b[typeof exports]&&exports&&!exports.nodeType&&exports,e=b[typeof module]&&module&&!module.nodeType&&module,f=(e&&e.exports===d&&d,b[typeof global]&&global);!f||f.global!==f&&f.window!==f||(c=f),"function"==typeof define&&define.amd?define(["rx","exports"],function(b,d){return c.Rx=a(c,d,b),c.Rx}):"object"==typeof module&&module&&module.exports===d?module.exports=a(c,module.exports,require("./rx")):c.Rx=a(c,{},c.Rx)}).call(this,function(a,b,c){{var d=c.Observable,e=d.prototype,f=c.Internals.AnonymousObservable,g=(c.Subject,c.Observer,c.Disposable.empty);c.Disposable.create,c.Internals.inherits,c.Internals.addProperties,c.Scheduler.timeout}return e.pausable=function(a){var b=this;return new f(function(c){var d=b.publish(),e=d.subscribe(c),f=g,h=a.distinctUntilChanged().subscribe(function(a){a?f=d.connect():(f.dispose(),f=g)});return new CompositeDisposable(e,f,h)})},c}); \ No newline at end of file +(function(a){var b={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},c=b[typeof window]&&window||this,d=b[typeof exports]&&exports&&!exports.nodeType&&exports,e=b[typeof module]&&module&&!module.nodeType&&module,f=(e&&e.exports===d&&d,b[typeof global]&&global);!f||f.global!==f&&f.window!==f||(c=f),"function"==typeof define&&define.amd?define(["rx","exports"],function(b,d){return c.Rx=a(c,d,b),c.Rx}):"object"==typeof module&&module&&module.exports===d?module.exports=a(c,module.exports,require("./rx")):c.Rx=a(c,{},c.Rx)}).call(this,function(a,b,c){function d(){if(this.isDisposed)throw new Error(q)}function e(a){return a}function f(a,b,c){return new i(function(d){function f(a,b){l[b]=a;var f;if(h[b]=!0,i||(i=h.every(e))){try{f=c.apply(null,l)}catch(g){return d.onError(g),void 0}d.onNext(f)}else k&&d.onCompleted()}var g=2,h=[!1,!1],i=!1,k=!1,l=new Array(g);return new j(a.subscribe(function(a){f(a,0)},d.onError.bind(d),function(){k=!0,d.onCompleted()}),b.subscribe(function(a){f(a,1)},d.onError.bind(d)))})}var g=c.Observable,h=g.prototype,i=c.AnonymousObservable,j=c.CompositeDisposable,k=c.Subject,l=c.Observer,m=c.Disposable.empty,n=c.Disposable.create,o=c.internals.inherits,p=c.internals.addProperties,q=(c.Scheduler.timeout,"Object has been disposed");h.pausable=function(a){var b=this;return new i(function(c){var d=b.publish(),e=d.subscribe(c),f=m,g=a.distinctUntilChanged().subscribe(function(a){a?f=d.connect():(f.dispose(),f=m)});return new j(e,f,g)})},h.pausableBuffered=function(a){var b=this;return new i(function(c){var d=[],e=!0,g=f(b,a.distinctUntilChanged(),function(a,b){return{data:a,shouldFire:b}}).subscribe(function(a){if(a.shouldFire&&e&&c.onNext(a.data),a.shouldFire&&!e){for(;d.length>0;)c.onNext(d.shift());e=!0}else a.shouldFire||e?!a.shouldFire&&e&&(e=!1):d.push(a.data)},c.onError.bind(c),c.onCompleted.bind(c));return a.onNext(!1),g})},h.controlled=function(a){return null==a&&(a=!0),new r(this,a)};var r=function(a){function b(a){return this.source.subscribe(a)}function c(c,d){a.call(this,b),this.subject=new s(d),this.source=c.multicast(this.subject).refCount()}return o(c,a),c.prototype.request=function(a){return null==a&&(a=-1),this.subject.request(a)},c}(g),s=c.ControlledSubject=function(a){function b(a){return this.subject.subscribe(a)}function c(c){null==c&&(c=!0),a.call(this,b),this.subject=new k,this.enableQueue=c,this.queue=c?[]:null,this.requestedCount=0,this.requestedDisposable=m,this.error=null,this.hasFailed=!1,this.hasCompleted=!1,this.controlledDisposable=m}return o(c,a),p(c.prototype,l,{onCompleted:function(){d.call(this),this.hasCompleted=!0,this.enableQueue&&0!==this.queue.length||this.subject.onCompleted()},onError:function(a){d.call(this),this.hasFailed=!0,this.error=a,this.enableQueue&&0!==this.queue.length||this.subject.onError(a)},onNext:function(a){d.call(this);var b=!1;0===this.requestedCount?this.enableQueue&&this.queue.push(a):(-1!==this.requestedCount&&0===this.requestedCount--&&this.disposeCurrentRequest(),b=!0),b&&this.subject.onNext(a)},_processRequest:function(a){if(this.enableQueue){for(;this.queue.length>=a&&a>0;)this.subject.onNext(this.queue.shift()),a--;return 0!==this.queue.length?{numberOfItems:a,returnValue:!0}:{numberOfItems:a,returnValue:!1}}return this.hasFailed?(this.subject.onError(this.error),this.controlledDisposable.dispose(),this.controlledDisposable=m):this.hasCompleted&&(this.subject.onCompleted(),this.controlledDisposable.dispose(),this.controlledDisposable=m),{numberOfItems:a,returnValue:!1}},request:function(a){d.call(this),this.disposeCurrentRequest();var b=this,c=this._processRequest(a);return a=c.numberOfItems,c.returnValue?m:(this.requestedCount=a,this.requestedDisposable=n(function(){b.requestedCount=0}),this.requestedDisposable)},disposeCurrentRequest:function(){this.requestedDisposable.dispose(),this.requestedDisposable=m},dispose:function(){this.isDisposed=!0,this.error=null,this.subject.dispose(),this.requestedDisposable.dispose()}}),c}(g);return c}); \ No newline at end of file diff --git a/rx.lite.compat.js b/rx.lite.compat.js index 18d3c6dc1..3280865da 100644 --- a/rx.lite.compat.js +++ b/rx.lite.compat.js @@ -4694,6 +4694,259 @@ return new CompositeDisposable(subscription, connection, pausable); }); }; + function combineLatestSource(source, subject, resultSelector) { + return new AnonymousObservable(function (observer) { + var n = 2, + hasValue = [false, false], + hasValueAll = false, + isDone = false, + values = new Array(n); + + function next(x, i) { + values[i] = x + var res; + hasValue[i] = true; + if (hasValueAll || (hasValueAll = hasValue.every(identity))) { + try { + res = resultSelector.apply(null, values); + } catch (ex) { + observer.onError(ex); + return; + } + observer.onNext(res); + } else if (isDone) { + observer.onCompleted(); + } + } + + return new CompositeDisposable( + source.subscribe( + function (x) { + next(x, 0); + }, + observer.onError.bind(observer), + function () { + isDone = true; + observer.onCompleted(); + }), + subject.subscribe( + function (x) { + next(x, 1); + }, + observer.onError.bind(observer)) + ); + }); + } + + /** + * Pauses the underlying observable sequence based upon the observable sequence which yields true/false, + * and yields the values that were buffered while paused. + * @example + * var pauser = new Rx.Subject(); + * var source = Rx.Observable.interval(100).pausableBuffered(pauser); + * @param {Observable} pauser The observable sequence used to pause the underlying sequence. + * @returns {Observable} The observable sequence which is paused based upon the pauser. + */ + observableProto.pausableBuffered = function (subject) { + var source = this; + return new AnonymousObservable(function (observer) { + var q = [], previous = true; + + var subscription = + combineLatestSource( + source, + subject.distinctUntilChanged(), + function (data, shouldFire) { + return { data: data, shouldFire: shouldFire }; + }) + .subscribe( + function (results) { + if (results.shouldFire && previous) { + observer.onNext(results.data); + } + if (results.shouldFire && !previous) { + while (q.length > 0) { + observer.onNext(q.shift()); + } + previous = true; + } else if (!results.shouldFire && !previous) { + q.push(results.data); + } else if (!results.shouldFire && previous) { + previous = false; + } + + }, + observer.onError.bind(observer), + observer.onCompleted.bind(observer) + ); + + subject.onNext(false); + + return subscription; + }); + }; + + /** + * Attaches a controller to the observable sequence with the ability to queue. + * @example + * var source = Rx.Observable.interval(100).controlled(); + * source.request(3); // Reads 3 values + * @param {Observable} pauser The observable sequence used to pause the underlying sequence. + * @returns {Observable} The observable sequence which is paused based upon the pauser. + */ + observableProto.controlled = function (enableQueue) { + if (enableQueue == null) { enableQueue = true; } + return new ControlledObservable(this, enableQueue); + }; + var ControlledObservable = (function (_super) { + + inherits(ControlledObservable, _super); + + function subscribe (observer) { + return this.source.subscribe(observer); + } + + function ControlledObservable (source, enableQueue) { + _super.call(this, subscribe); + this.subject = new ControlledSubject(enableQueue); + this.source = source.multicast(this.subject).refCount(); + } + + ControlledObservable.prototype.request = function (numberOfItems) { + if (numberOfItems == null) { numberOfItems = -1; } + return this.subject.request(numberOfItems); + }; + + return ControlledObservable; + + }(Observable)); + + var ControlledSubject = Rx.ControlledSubject = (function (_super) { + + function subscribe (observer) { + return this.subject.subscribe(observer); + } + + inherits(ControlledSubject, _super); + + function ControlledSubject(enableQueue) { + if (enableQueue == null) { + enableQueue = true; + } + + _super.call(this, subscribe); + this.subject = new Subject(); + this.enableQueue = enableQueue; + this.queue = enableQueue ? [] : null; + this.requestedCount = 0; + this.requestedDisposable = disposableEmpty; + this.error = null; + this.hasFailed = false; + this.hasCompleted = false; + this.controlledDisposable = disposableEmpty; + } + + addProperties(ControlledSubject.prototype, Observer, { + onCompleted: function () { + checkDisposed.call(this); + this.hasCompleted = true; + + if (!this.enableQueue || this.queue.length === 0) { + this.subject.onCompleted(); + } + }, + onError: function (error) { + checkDisposed.call(this); + this.hasFailed = true; + this.error = error; + + if (!this.enableQueue || this.queue.length === 0) { + this.subject.onError(error); + } + }, + onNext: function (value) { + checkDisposed.call(this); + var hasRequested = false; + + if (this.requestedCount === 0) { + if (this.enableQueue) { + this.queue.push(value); + } + } else { + if (this.requestedCount !== -1) { + if (this.requestedCount-- === 0) { + this.disposeCurrentRequest(); + } + } + hasRequested = true; + } + + if (hasRequested) { + this.subject.onNext(value); + } + }, + _processRequest: function (numberOfItems) { + if (this.enableQueue) { + //console.log('queue length', this.queue.length); + + while (this.queue.length >= numberOfItems && numberOfItems > 0) { + //console.log('number of items', numberOfItems); + this.subject.onNext(this.queue.shift()); + numberOfItems--; + } + + if (this.queue.length !== 0) { + return { numberOfItems: numberOfItems, returnValue: true }; + } else { + return { numberOfItems: numberOfItems, returnValue: false }; + } + } + + if (this.hasFailed) { + this.subject.onError(this.error); + this.controlledDisposable.dispose(); + this.controlledDisposable = disposableEmpty; + } else if (this.hasCompleted) { + this.subject.onCompleted(); + this.controlledDisposable.dispose(); + this.controlledDisposable = disposableEmpty; + } + + return { numberOfItems: numberOfItems, returnValue: false }; + }, + request: function (number) { + checkDisposed.call(this); + this.disposeCurrentRequest(); + var self = this, + r = this._processRequest(number); + + number = r.numberOfItems; + if (!r.returnValue) { + this.requestedCount = number; + this.requestedDisposable = disposableCreate(function () { + self.requestedCount = 0; + }); + + return this.requestedDisposable + } else { + return disposableEmpty; + } + }, + disposeCurrentRequest: function () { + this.requestedDisposable.dispose(); + this.requestedDisposable = disposableEmpty; + }, + + dispose: function () { + this.isDisposed = true; + this.error = null; + this.subject.dispose(); + this.requestedDisposable.dispose(); + } + }); + + return ControlledSubject; + }(Observable)); var AnonymousObservable = Rx.AnonymousObservable = (function (_super) { inherits(AnonymousObservable, _super); diff --git a/rx.lite.compat.min.js b/rx.lite.compat.min.js index cd0773cf2..c7281c1ed 100644 --- a/rx.lite.compat.min.js +++ b/rx.lite.compat.min.js @@ -1,2 +1,2 @@ -(function(a){function b(){}function c(a){return a}function d(a,b){return fb(a,b)}function e(a,b){return a-b}function f(a){throw a}function g(a){return"function"==typeof a.then}function h(){if(this.isDisposed)throw new Error(M)}function i(a){var b=typeof a;return a&&("function"==b||"object"==b)||!1}function j(a){var b=[];if(!i(a))return b;eb.nonEnumArgs&&a.length&&n(a)&&(a=gb.call(a));var c=eb.enumPrototypes&&"function"==typeof a,d=eb.enumErrorProps&&(a===$||a instanceof Error);for(var e in a)c&&"prototype"==e||d&&("message"==e||"name"==e)||b.push(e);if(eb.nonEnumShadows&&a!==_){var f=a.constructor,g=-1,h=cb.length;if(a===(f&&f.prototype))var j=a===stringProto?W:a===$?R:X.call(a),k=db[j];for(;++g-1:void 0});return c.pop(),d.pop(),result}function q(a,b){return 1===a.length&&Array.isArray(a[b])?a[b]:gb.call(a)}function r(a,b){for(var c=new Array(a),d=0;a>d;d++)c[d]=b();return c}function s(a,b){return new gc(function(c){var d=new ub,e=new vb;return e.setDisposable(d),d.setDisposable(a.subscribe(c.onNext.bind(c),function(a){var d,f;try{f=b(a)}catch(g){return c.onError(g),void 0}d=new ub,e.setDisposable(d),d.setDisposable(f.subscribe(c))},c.onCompleted.bind(c))),e})}function t(a,b){var c=this;return new gc(function(d){var e=0,f=a.length;return c.subscribe(function(c){if(f>e){var g,h=a[e++];try{g=b(c,h)}catch(i){return d.onError(i),void 0}d.onNext(g)}else d.onCompleted()},d.onError.bind(d),d.onCompleted.bind(d))})}function u(a){return this.select(function(b,c){var d=a(b,c);return g(d)?cc(d):d}).mergeObservable()}function v(a){var b=function(){this.cancelBubble=!0},c=function(){if(this.bubbledKeyCode=this.keyCode,this.ctrlKey)try{this.keyCode=0}catch(a){}this.defaultPrevented=!0,this.returnValue=!1,this.modified=!0};if(a||(a=window.event),!a.target)switch(a.target=a.target||a.srcElement,"mouseover"==a.type&&(a.relatedTarget=a.fromElement),"mouseout"==a.type&&(a.relatedTarget=a.toElement),a.stopPropagation||(a.stopPropagation=b,a.preventDefault=c),a.type){case"keypress":var d="charCode"in a?a.charCode:a.keyCode;10==d?(d=0,a.keyCode=13):13==d||27==d?d=0:3==d&&(d=99),a.charCode=d,a.keyChar=a.charCode?String.fromCharCode(a.charCode):""}return a}function w(a,b,c){if(a.addListener)return a.addListener(b,c),rb(function(){a.removeListener(b,c)});if(a.addEventListener)return a.addEventListener(b,c,!1),rb(function(){a.removeEventListener(b,c,!1)});if(a.attachEvent){var d=function(a){c(v(a))};return a.attachEvent("on"+b,d),rb(function(){a.detachEvent("on"+b,d)})}return a["on"+b]=c,rb(function(){a["on"+b]=null})}function x(a,b,c){var d=new ob;if(a&&a.length)for(var e=0,f=a.length;f>e;e++)d.add(x(a[e],b,c));else a&&d.add(w(a,b,c));return d}function y(a,b){var c=zb(a);return new gc(function(a){return b.scheduleWithRelative(c,function(){a.onNext(0),a.onCompleted()})})}function z(a,b,c){return a===b?new gc(function(a){return c.schedulePeriodicWithState(0,b,function(b){return a.onNext(b),b+1})}):Ub(function(){return observableTimerDateAndPeriod(c.now()+a,b,c)})}function A(a,b){return new gc(function(c){function d(){g&&(g=!1,c.onNext(f)),e&&c.onCompleted()}var e,f,g;return new ob(a.subscribe(function(a){g=!0,f=a},c.onError.bind(c),function(){e=!0}),b.subscribe(d,c.onError.bind(c),d))})}var B={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},C=B[typeof window]&&window||this,D=B[typeof exports]&&exports&&!exports.nodeType&&exports,E=B[typeof module]&&module&&!module.nodeType&&module,F=E&&E.exports===D&&D,G=B[typeof global]&&global;!G||G.global!==G&&G.window!==G||(C=G);var H,I={internals:{},config:{}},J=function(){return Date.now?Date.now:function(){return+new Date}}(),K="Sequence contains no elements.",L="Argument out of range",M="Object has been disposed",N="[object Arguments]",O="[object Array]",P="[object Boolean]",Q="[object Date]",R="[object Error]",S="[object Function]",T="[object Number]",U="[object Object]",V="[object RegExp]",W="[object String]",X=Object.prototype.toString,Y=Object.prototype.hasOwnProperty,Z=X.call(arguments)==N,$=Error.prototype,_=Object.prototype,ab=_.propertyIsEnumerable;try{H=!(X.call(document)==U&&!({toString:0}+""))}catch(bb){H=!0}var cb=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],db={};db[O]=db[Q]=db[T]={constructor:!0,toLocaleString:!0,toString:!0,valueOf:!0},db[P]=db[W]={constructor:!0,toString:!0,valueOf:!0},db[R]=db[S]=db[V]={constructor:!0,toString:!0},db[U]={constructor:!0};var eb={};!function(){var a=function(){this.x=1},b=[];a.prototype={valueOf:1,y:1};for(var c in new a)b.push(c);for(c in arguments);eb.enumErrorProps=ab.call($,"message")||ab.call($,"name"),eb.enumPrototypes=ab.call(a,"prototype"),eb.nonEnumArgs=0!=c,eb.nonEnumShadows=!/valueOf/.test(b)}(1),Z||(n=function(a){return a&&"object"==typeof a?Y.call(a,"callee"):!1}),o(/x/)&&(o=function(a){return"function"==typeof a&&X.call(a)==S});{var fb=I.internals.isEqual=function(a,b){return p(a,b,[],[])},gb=Array.prototype.slice,hb=({}.hasOwnProperty,this.inherits=I.internals.inherits=function(a,b){function c(){this.constructor=a}c.prototype=b.prototype,a.prototype=new c}),ib=I.internals.addProperties=function(a){for(var b=gb.call(arguments,1),c=0,d=b.length;d>c;c++){var e=b[c];for(var f in e)a[f]=e[f]}};I.internals.addRef=function(a,b){return new gc(function(c){return new ob(b.getDisposable(),a.subscribe(c))})}}Function.prototype.bind||(Function.prototype.bind=function(a){var b=this,c=gb.call(arguments,1),d=function(){function e(){}if(this instanceof d){e.prototype=b.prototype;var f=new e,g=b.apply(f,c.concat(gb.call(arguments)));return Object(g)===g?g:f}return b.apply(a,c.concat(gb.call(arguments)))};return d});var jb=Object("a"),kb="a"!=jb[0]||!(0 in jb);Array.prototype.every||(Array.prototype.every=function(a){var b=Object(this),c=kb&&{}.toString.call(this)==W?this.split(""):b,d=c.length>>>0,e=arguments[1];if({}.toString.call(a)!=S)throw new TypeError(a+" is not a function");for(var f=0;d>f;f++)if(f in c&&!a.call(e,c[f],f,b))return!1;return!0}),Array.prototype.map||(Array.prototype.map=function(a){var b=Object(this),c=kb&&{}.toString.call(this)==W?this.split(""):b,d=c.length>>>0,e=Array(d),f=arguments[1];if({}.toString.call(a)!=S)throw new TypeError(a+" is not a function");for(var g=0;d>g;g++)g in c&&(e[g]=a.call(f,c[g],g,b));return e}),Array.prototype.filter||(Array.prototype.filter=function(a){for(var b,c=[],d=new Object(this),e=0,f=d.length>>>0;f>e;e++)b=d[e],e in d&&a.call(arguments[1],b,e,d)&&c.push(b);return c}),Array.isArray||(Array.isArray=function(a){return Object.prototype.toString.call(a)==O}),Array.prototype.indexOf||(Array.prototype.indexOf=function(a){var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=0;if(arguments.length>1&&(d=Number(arguments[1]),d!==d?d=0:0!==d&&1/0!=d&&d!==-1/0&&(d=(d>0||-1)*Math.floor(Math.abs(d)))),d>=c)return-1;for(var e=d>=0?d:Math.max(c-Math.abs(d),0);c>e;e++)if(e in b&&b[e]===a)return e;return-1});var lb=function(a,b){this.id=a,this.value=b};lb.prototype.compareTo=function(a){var b=this.value.compareTo(a.value);return 0===b&&(b=this.id-a.id),b};var mb=I.internals.PriorityQueue=function(a){this.items=new Array(a),this.length=0},nb=mb.prototype;nb.isHigherPriority=function(a,b){return this.items[a].compareTo(this.items[b])<0},nb.percolate=function(a){if(!(a>=this.length||0>a)){var b=a-1>>1;if(!(0>b||b===a)&&this.isHigherPriority(a,b)){var c=this.items[a];this.items[a]=this.items[b],this.items[b]=c,this.percolate(b)}}},nb.heapify=function(b){if(b===a&&(b=0),!(b>=this.length||0>b)){var c=2*b+1,d=2*b+2,e=b;if(cb;b++)a[b].dispose()}},pb.clear=function(){var a=this.disposables.slice(0);this.disposables=[],this.length=0;for(var b=0,c=a.length;c>b;b++)a[b].dispose()},pb.contains=function(a){return-1!==this.disposables.indexOf(a)},pb.toArray=function(){return this.disposables.slice(0)};var qb=I.Disposable=function(a){this.isDisposed=!1,this.action=a||b};qb.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var rb=qb.create=function(a){return new qb(a)},sb=qb.empty={dispose:b},tb=function(){function a(a){this.isSingle=a,this.isDisposed=!1,this.current=null}var b=a.prototype;return b.getDisposable=function(){return this.current},b.setDisposable=function(a){if(this.current&&this.isSingle)throw new Error("Disposable has already been assigned");var b,c=this.isDisposed;c||(b=this.current,this.current=a),b&&b.dispose(),c&&a&&a.dispose()},b.dispose=function(){var a;this.isDisposed||(this.isDisposed=!0,a=this.current,this.current=null),a&&a.dispose()},a}(),ub=I.SingleAssignmentDisposable=function(a){function b(){a.call(this,!0)}return hb(b,a),b}(tb),vb=I.SerialDisposable=function(a){function b(){a.call(this,!1)}return hb(b,a),b}(tb),wb=(I.RefCountDisposable=function(){function a(a){this.disposable=a,this.disposable.count++,this.isInnerDisposed=!1}function b(a){this.underlyingDisposable=a,this.isDisposed=!1,this.isPrimaryDisposed=!1,this.count=0}return a.prototype.dispose=function(){this.disposable.isDisposed||this.isInnerDisposed||(this.isInnerDisposed=!0,this.disposable.count--,0===this.disposable.count&&this.disposable.isPrimaryDisposed&&(this.disposable.isDisposed=!0,this.disposable.underlyingDisposable.dispose()))},b.prototype.dispose=function(){this.isDisposed||this.isPrimaryDisposed||(this.isPrimaryDisposed=!0,0===this.count&&(this.isDisposed=!0,this.underlyingDisposable.dispose()))},b.prototype.getDisposable=function(){return this.isDisposed?sb:new a(this)},b}(),I.internals.ScheduledItem=function(a,b,c,d,f){this.scheduler=a,this.state=b,this.action=c,this.dueTime=d,this.comparer=f||e,this.disposable=new ub});wb.prototype.invoke=function(){this.disposable.setDisposable(this.invokeCore())},wb.prototype.compareTo=function(a){return this.comparer(this.dueTime,a.dueTime)},wb.prototype.isCancelled=function(){return this.disposable.isDisposed},wb.prototype.invokeCore=function(){return this.action(this.scheduler,this.state)};var xb,yb=I.Scheduler=function(){function a(a,b,c,d){this.now=a,this._schedule=b,this._scheduleRelative=c,this._scheduleAbsolute=d}function b(a,b){var c=b.first,d=b.second,e=new ob,f=function(b){d(b,function(b){var c=!1,d=!1,g=a.scheduleWithState(b,function(a,b){return c?e.remove(g):d=!0,f(b),sb});d||(e.add(g),c=!0)})};return f(c),e}function c(a,b,c){var d=b.first,e=b.second,f=new ob,g=function(b){e(b,function(b,d){var e=!1,h=!1,i=a[c].call(a,b,d,function(a,b){return e?f.remove(i):h=!0,g(b),sb});h||(f.add(i),e=!0)})};return g(d),f}function d(a,b){return b(),sb}var e=a.prototype;return e.schedulePeriodic=function(a,b){return this.schedulePeriodicWithState(null,a,function(){b()})},e.schedulePeriodicWithState=function(a,b,c){var d=a,e=setInterval(function(){d=c(d)},b);return rb(function(){clearInterval(e)})},e.schedule=function(a){return this._schedule(a,d)},e.scheduleWithState=function(a,b){return this._schedule(a,b)},e.scheduleWithRelative=function(a,b){return this._scheduleRelative(b,a,d)},e.scheduleWithRelativeAndState=function(a,b,c){return this._scheduleRelative(a,b,c)},e.scheduleWithAbsolute=function(a,b){return this._scheduleAbsolute(b,a,d)},e.scheduleWithAbsoluteAndState=function(a,b,c){return this._scheduleAbsolute(a,b,c)},e.scheduleRecursive=function(a){return this.scheduleRecursiveWithState(a,function(a,b){a(function(){b(a)})})},e.scheduleRecursiveWithState=function(a,c){return this.scheduleWithState({first:a,second:c},function(a,c){return b(a,c)})},e.scheduleRecursiveWithRelative=function(a,b){return this.scheduleRecursiveWithRelativeAndState(b,a,function(a,b){a(function(c){b(a,c)})})},e.scheduleRecursiveWithRelativeAndState=function(a,b,d){return this._scheduleRelative({first:a,second:d},b,function(a,b){return c(a,b,"scheduleWithRelativeAndState")})},e.scheduleRecursiveWithAbsolute=function(a,b){return this.scheduleRecursiveWithAbsoluteAndState(b,a,function(a,b){a(function(c){b(a,c)})})},e.scheduleRecursiveWithAbsoluteAndState=function(a,b,d){return this._scheduleAbsolute({first:a,second:d},b,function(a,b){return c(a,b,"scheduleWithAbsoluteAndState")})},a.now=J,a.normalize=function(a){return 0>a&&(a=0),a},a}(),zb=yb.normalize,Ab=yb.immediate=function(){function a(a,b){return b(this,a)}function b(a,b,c){for(var d=zb(d);d-this.now()>0;);return c(this,a)}function c(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}return new yb(J,a,b,c)}(),Bb=yb.currentThread=function(){function a(a){for(var b;a.length>0;)if(b=a.dequeue(),!b.isCancelled()){for(;b.dueTime-yb.now()>0;);b.isCancelled()||b.invoke()}}function b(a,b){return this.scheduleWithRelativeAndState(a,0,b)}function c(b,c,d){var f=this.now()+yb.normalize(c),g=new wb(this,b,d,f);if(e)e.enqueue(g);else{e=new mb(4),e.enqueue(g);try{a(e)}catch(h){throw h}finally{e=null}}return g.disposable}function d(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}var e,f=new yb(J,b,c,d);return f.scheduleRequired=function(){return null===e},f.ensureTrampoline=function(a){return null===e?this.schedule(a):a()},f}(),Cb=(I.internals.SchedulePeriodicRecursive=function(){function a(a,b){b(0,this._period);try{this._state=this._action(this._state)}catch(c){throw this._cancel.dispose(),c}}function b(a,b,c,d){this._scheduler=a,this._state=b,this._period=c,this._action=d}return b.prototype.start=function(){var b=new ub;return this._cancel=b,b.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,a.bind(this))),b},b}(),b);!function(){function a(){if(!C.postMessage||C.importScripts)return!1;var a=!1,b=C.onmessage;return C.onmessage=function(){a=!0},C.postMessage("","*"),C.onmessage=b,a}function b(a){if("string"==typeof a.data&&a.data.substring(0,f.length)===f){var b=a.data.substring(f.length),c=g[b];c(),delete g[b]}}var c=RegExp("^"+String(X).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),d="function"==typeof(d=G&&F&&G.setImmediate)&&!c.test(d)&&d,e="function"==typeof(e=G&&F&&G.clearImmediate)&&!c.test(e)&&e;if("undefined"!=typeof process&&"[object process]"==={}.toString.call(process))xb=process.nextTick;else if("function"==typeof d)xb=d,Cb=e;else if(a()){var f="ms.rx.schedule"+Math.random(),g={},h=0;C.addEventListener?C.addEventListener("message",b,!1):C.attachEvent("onmessage",b,!1),xb=function(a){var b=h++;g[b]=a,C.postMessage(f+b,"*")}}else if(C.MessageChannel){var i=new C.MessageChannel,j={},k=0;i.port1.onmessage=function(a){var b=a.data,c=j[b];c(),delete j[b]},xb=function(a){var b=k++;j[b]=a,i.port2.postMessage(b)}}else"document"in C&&"onreadystatechange"in C.document.createElement("script")?xb=function(a){var b=C.document.createElement("script");b.onreadystatechange=function(){a(),b.onreadystatechange=null,b.parentNode.removeChild(b),b=null},C.document.documentElement.appendChild(b)}:(xb=function(a){return setTimeout(a,0)},Cb=clearTimeout)}();var Db=yb.timeout=function(){function a(a,b){var c=this,d=new ub,e=xb(function(){d.isDisposed||d.setDisposable(b(c,a))});return new ob(d,rb(function(){Cb(e)}))}function b(a,b,c){var d=this,e=yb.normalize(b);if(0===e)return d.scheduleWithState(a,c);var f=new ub,g=setTimeout(function(){f.isDisposed||f.setDisposable(c(d,a))},e);return new ob(f,rb(function(){clearTimeout(g)}))}function c(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}return new yb(J,a,b,c)}(),Eb=I.Notification=function(){function a(a,b){this.hasValue=null==b?!1:b,this.kind=a}var b=a.prototype;return b.accept=function(a,b,c){return 1===arguments.length&&"object"==typeof a?this._acceptObservable(a):this._accept(a,b,c)},b.toObservable=function(a){var b=this;return a||(a=Ab),new gc(function(c){return a.schedule(function(){b._acceptObservable(c),"N"===b.kind&&c.onCompleted()})})},a}(),Fb=Eb.createOnNext=function(){function a(a){return a(this.value)}function b(a){return a.onNext(this.value)}function c(){return"OnNext("+this.value+")"}return function(d){var e=new Eb("N",!0);return e.value=d,e._accept=a,e._acceptObservable=b,e.toString=c,e}}(),Gb=Eb.createOnError=function(){function a(a,b){return b(this.exception)}function b(a){return a.onError(this.exception)}function c(){return"OnError("+this.exception+")"}return function(d){var e=new Eb("E");return e.exception=d,e._accept=a,e._acceptObservable=b,e.toString=c,e}}(),Hb=Eb.createOnCompleted=function(){function a(a,b,c){return c()}function b(a){return a.onCompleted()}function c(){return"OnCompleted()"}return function(){var d=new Eb("C");return d._accept=a,d._acceptObservable=b,d.toString=c,d}}(),Ib=I.internals.Enumerator=function(a,b){this.moveNext=a,this.getCurrent=b},Jb=Ib.create=function(a,b){var c=!1;return new Ib(function(){if(c)return!1;var b=a();return b||(c=!0),b},function(){return b()})},Kb=I.internals.Enumerable=function(a){this.getEnumerator=a};Kb.prototype.concat=function(){var a=this;return new gc(function(b){var c,d=a.getEnumerator(),e=new vb,f=Ab.scheduleRecursive(function(a){var f,g;if(!c){try{g=d.moveNext(),g&&(f=d.getCurrent())}catch(h){return b.onError(h),void 0}if(!g)return b.onCompleted(),void 0;var i=new ub;e.setDisposable(i),i.setDisposable(f.subscribe(b.onNext.bind(b),b.onError.bind(b),function(){a()}))}});return new ob(e,f,rb(function(){c=!0}))})},Kb.prototype.catchException=function(){var a=this;return new gc(function(b){var c,d,e=a.getEnumerator(),f=new vb,g=Ab.scheduleRecursive(function(a){var g,h;if(!c){try{h=e.moveNext(),h&&(g=e.getCurrent())}catch(i){return b.onError(i),void 0}if(!h)return d?b.onError(d):b.onCompleted(),void 0;var j=new ub;f.setDisposable(j),j.setDisposable(g.subscribe(b.onNext.bind(b),function(b){d=b,a()},b.onCompleted.bind(b)))}});return new ob(f,g,rb(function(){c=!0}))})};var Lb=Kb.repeat=function(a,b){return 1===arguments.length&&(b=-1),new Kb(function(){var c,d=b;return Jb(function(){return 0===d?!1:(d>0&&d--,c=a,!0)},function(){return c})})},Mb=Kb.forEach=function(a,b,d){return b||(b=c),new Kb(function(){var c,e=-1;return Jb(function(){return++e0&&(a=!this.isAcquired,this.isAcquired=!0),a&&this.disposable.setDisposable(this.scheduler.scheduleRecursive(function(a){var c;if(!(b.queue.length>0))return b.isAcquired=!1,void 0;c=b.queue.shift();try{c()}catch(d){throw b.queue=[],b.hasFaulted=!0,d}a()}))},b.prototype.dispose=function(){a.prototype.dispose.call(this),this.disposable.dispose()},b}(Qb);Sb.create=Sb.createWithDisposable=function(a){return new gc(a)};var Ub=Sb.defer=function(a){return new gc(function(b){var c;try{c=a()}catch(d){return Zb(d).subscribe(b)}return c.subscribe(b)})},Vb=Sb.empty=function(a){return a||(a=Ab),new gc(function(b){return a.schedule(function(){b.onCompleted()})})},Wb=Sb.fromArray=function(a,b){return b||(b=Bb),new gc(function(c){var d=0;return b.scheduleRecursive(function(b){dc?(d.onNext(a+c),e(c+1)):d.onCompleted()})})},Sb.repeat=function(a,b,c){return c||(c=Bb),null==b&&(b=-1),Yb(a,c).repeat(b)};var Yb=Sb["return"]=Sb.returnValue=function(a,b){return b||(b=Ab),new gc(function(c){return b.schedule(function(){c.onNext(a),c.onCompleted()})})},Zb=Sb["throw"]=Sb.throwException=function(a,b){return b||(b=Ab),new gc(function(c){return b.schedule(function(){c.onError(a)})})};Pb["catch"]=Pb.catchException=function(a){return"function"==typeof a?s(this,a):$b([this,a])};var $b=Sb.catchException=Sb["catch"]=function(){var a=q(arguments,0);return Mb(a).catchException()};Pb.combineLatest=function(){var a=gb.call(arguments);return Array.isArray(a[0])?a[0].unshift(this):a.unshift(this),_b.apply(this,a)};var _b=Sb.combineLatest=function(){var a=gb.call(arguments),b=a.pop();return Array.isArray(a[0])&&(a=a[0]),new gc(function(d){function e(a){var e;if(i[a]=!0,j||(j=i.every(c))){try{e=b.apply(null,l)}catch(f){return d.onError(f),void 0}d.onNext(e)}else k.filter(function(b,c){return c!==a}).every(c)&&d.onCompleted()}function f(a){k[a]=!0,k.every(c)&&d.onCompleted()}for(var g=function(){return!1},h=a.length,i=r(h,g),j=!1,k=r(h,g),l=new Array(h),m=new Array(h),n=0;h>n;n++)!function(b){m[b]=new ub,m[b].setDisposable(a[b].subscribe(function(a){l[b]=a,e(b)},d.onError.bind(d),function(){f(b)}))}(n);return new ob(m)})};Pb.concat=function(){var a=gb.call(arguments,0);return a.unshift(this),ac.apply(this,a)};var ac=Sb.concat=function(){var a=q(arguments,0);return Mb(a).concat()};Pb.concatObservable=Pb.concatAll=function(){return this.merge(1)},Pb.merge=function(a){if("number"!=typeof a)return bc(this,a);var b=this;return new gc(function(c){var d=0,e=new ob,f=!1,h=[],i=function(a){var b=new ub;e.add(b),g(a)&&(a=cc(a)),b.setDisposable(a.subscribe(c.onNext.bind(c),c.onError.bind(c),function(){var a;e.remove(b),h.length>0?(a=h.shift(),i(a)):(d--,f&&0===d&&c.onCompleted())}))};return e.add(b.subscribe(function(b){a>d?(d++,i(b)):h.push(b)},c.onError.bind(c),function(){f=!0,0===d&&c.onCompleted()})),e})};var bc=Sb.merge=function(){var a,b;return arguments[0]?arguments[0].now?(a=arguments[0],b=gb.call(arguments,1)):(a=Ab,b=gb.call(arguments,0)):(a=Ab,b=gb.call(arguments,1)),Array.isArray(b[0])&&(b=b[0]),Wb(b,a).mergeObservable()};Pb.mergeObservable=Pb.mergeAll=function(){var a=this;return new gc(function(b){var c=new ob,d=!1,e=new ub;return c.add(e),e.setDisposable(a.subscribe(function(a){var e=new ub;c.add(e),g(a)&&(a=cc(a)),e.setDisposable(a.subscribe(function(a){b.onNext(a)},b.onError.bind(b),function(){c.remove(e),d&&1===c.length&&b.onCompleted()}))},b.onError.bind(b),function(){d=!0,1===c.length&&b.onCompleted()})),c})},Pb.skipUntil=function(a){var b=this;return new gc(function(c){var d=!1,e=new ob(b.subscribe(function(a){d&&c.onNext(a)},c.onError.bind(c),function(){d&&c.onCompleted()})),f=new ub;return e.add(f),f.setDisposable(a.subscribe(function(){d=!0,f.dispose()},c.onError.bind(c),function(){f.dispose()})),e})},Pb["switch"]=Pb.switchLatest=function(){var a=this;return new gc(function(b){var c=!1,d=new vb,e=!1,f=0,h=a.subscribe(function(a){var h=new ub,i=++f;c=!0,d.setDisposable(h),g(a)&&(a=cc(a)),h.setDisposable(a.subscribe(function(a){f===i&&b.onNext(a)},function(a){f===i&&b.onError(a)},function(){f===i&&(c=!1,e&&b.onCompleted())}))},b.onError.bind(b),function(){e=!0,c||b.onCompleted()});return new ob(h,d)})},Pb.takeUntil=function(a){var c=this;return new gc(function(d){return new ob(c.subscribe(d),a.subscribe(d.onCompleted.bind(d),d.onError.bind(d),b))})},Pb.zip=function(){if(Array.isArray(arguments[0]))return t.apply(this,arguments);var a=this,b=gb.call(arguments),d=b.pop();return b.unshift(a),new gc(function(e){function f(a){i[a]=!0,i.every(function(a){return a})&&e.onCompleted()}for(var g=b.length,h=r(g,function(){return[]}),i=r(g,function(){return!1}),j=function(b){var f,g;if(h.every(function(a){return a.length>0})){try{g=h.map(function(a){return a.shift()}),f=d.apply(a,g)}catch(j){return e.onError(j),void 0}e.onNext(f)}else i.filter(function(a,c){return c!==b}).every(c)&&e.onCompleted()},k=new Array(g),l=0;g>l;l++)!function(a){k[a]=new ub,k[a].setDisposable(b[a].subscribe(function(b){h[a].push(b),j(a)},e.onError.bind(e),function(){f(a)}))}(l);return new ob(k)})},Sb.zip=function(){var a=gb.call(arguments,0),b=a.shift();return b.zip.apply(b,a)},Sb.zipArray=function(){var a=q(arguments,0);return new gc(function(b){function d(a){if(g.every(function(a){return a.length>0})){var d=g.map(function(a){return a.shift()});b.onNext(d)}else if(h.filter(function(b,c){return c!==a}).every(c))return b.onCompleted(),void 0}function e(a){return h[a]=!0,h.every(c)?(b.onCompleted(),void 0):void 0}for(var f=a.length,g=r(f,function(){return[]}),h=r(f,function(){return!1}),i=new Array(f),j=0;f>j;j++)!function(c){i[c]=new ub,i[c].setDisposable(a[c].subscribe(function(a){g[c].push(a),d(c)},b.onError.bind(b),function(){e(c)}))}(j);var k=new ob(i);return k.add(rb(function(){for(var a=0,b=g.length;b>a;a++)g[a]=[]})),k})},Pb.asObservable=function(){var a=this;return new gc(function(b){return a.subscribe(b)})},Pb.dematerialize=function(){var a=this;return new gc(function(b){return a.subscribe(function(a){return a.accept(b)},b.onError.bind(b),b.onCompleted.bind(b))})},Pb.distinctUntilChanged=function(a,b){var e=this;return a||(a=c),b||(b=d),new gc(function(c){var d,f=!1;return e.subscribe(function(e){var g,h=!1;try{g=a(e)}catch(i){return c.onError(i),void 0}if(f)try{h=b(d,g)}catch(i){return c.onError(i),void 0}f&&h||(f=!0,d=g,c.onNext(e))},c.onError.bind(c),c.onCompleted.bind(c))})},Pb["do"]=Pb.doAction=function(a,b,c){var d,e=this;return"function"==typeof a?d=a:(d=a.onNext.bind(a),b=a.onError.bind(a),c=a.onCompleted.bind(a)),new gc(function(a){return e.subscribe(function(b){try{d(b)}catch(c){a.onError(c)}a.onNext(b)},function(c){if(b){try{b(c)}catch(d){a.onError(d)}a.onError(c)}else a.onError(c)},function(){if(c){try{c()}catch(b){a.onError(b)}a.onCompleted()}else a.onCompleted()})})},Pb["finally"]=Pb.finallyAction=function(a){var b=this;return new gc(function(c){var d=b.subscribe(c);return rb(function(){try{d.dispose()}catch(b){throw b}finally{a()}})})},Pb.ignoreElements=function(){var a=this;return new gc(function(c){return a.subscribe(b,c.onError.bind(c),c.onCompleted.bind(c))})},Pb.materialize=function(){var a=this;return new gc(function(b){return a.subscribe(function(a){b.onNext(Fb(a))},function(a){b.onNext(Gb(a)),b.onCompleted()},function(){b.onNext(Hb()),b.onCompleted()})})},Pb.repeat=function(a){return Lb(this,a).concat()},Pb.retry=function(a){return Lb(this,a).catchException()},Pb.scan=function(){var a,b,c=!1,d=this;return 2===arguments.length?(c=!0,a=arguments[0],b=arguments[1]):b=arguments[0],new gc(function(e){var f,g,h;return d.subscribe(function(d){try{h||(h=!0),f?g=b(g,d):(g=c?b(a,d):d,f=!0)}catch(i){return e.onError(i),void 0}e.onNext(g)},e.onError.bind(e),function(){!h&&c&&e.onNext(a),e.onCompleted()})})},Pb.skipLast=function(a){var b=this;return new gc(function(c){var d=[];return b.subscribe(function(b){d.push(b),d.length>a&&c.onNext(d.shift())},c.onError.bind(c),c.onCompleted.bind(c))})},Pb.startWith=function(){var a,b,c=0;return arguments.length&&"now"in Object(arguments[0])?(b=arguments[0],c=1):b=Ab,a=gb.call(arguments,c),Mb([Wb(a,b),this]).concat()},Pb.takeLast=function(a,b){return this.takeLastBuffer(a).selectMany(function(a){return Wb(a,b)})},Pb.takeLastBuffer=function(a){var b=this;return new gc(function(c){var d=[];return b.subscribe(function(b){d.push(b),d.length>a&&d.shift()},c.onError.bind(c),function(){c.onNext(d),c.onCompleted()})})},Pb.select=Pb.map=function(a,b){var c=this;return new gc(function(d){var e=0;return c.subscribe(function(f){var g;try{g=a.call(b,f,e++,c) -}catch(h){return d.onError(h),void 0}d.onNext(g)},d.onError.bind(d),d.onCompleted.bind(d))})},Pb.selectMany=Pb.flatMap=function(a,b){return b?this.selectMany(function(c,d){var e=a(c,d),f=g(e)?cc(e):e;return f.select(function(a){return b(c,a,d)})}):"function"==typeof a?u.call(this,a):u.call(this,function(){return a})},Pb.selectSwitch=Pb.flatMapLatest=function(a,b){return this.select(a,b).switchLatest()},Pb.skip=function(a){if(0>a)throw new Error(L);var b=this;return new gc(function(c){var d=a;return b.subscribe(function(a){0>=d?c.onNext(a):d--},c.onError.bind(c),c.onCompleted.bind(c))})},Pb.skipWhile=function(a,b){var c=this;return new gc(function(d){var e=0,f=!1;return c.subscribe(function(g){if(!f)try{f=!a.call(b,g,e++,c)}catch(h){return d.onError(h),void 0}f&&d.onNext(g)},d.onError.bind(d),d.onCompleted.bind(d))})},Pb.take=function(a,b){if(0>a)throw new Error(L);if(0===a)return Vb(b);var c=this;return new gc(function(b){var d=a;return c.subscribe(function(a){d>0&&(d--,b.onNext(a),0===d&&b.onCompleted())},b.onError.bind(b),b.onCompleted.bind(b))})},Pb.takeWhile=function(a,b){var c=this;return new gc(function(d){var e=0,f=!0;return c.subscribe(function(g){if(f){try{f=a.call(b,g,e++,c)}catch(h){return d.onError(h),void 0}f?d.onNext(g):d.onCompleted()}},d.onError.bind(d),d.onCompleted.bind(d))})},Pb.where=Pb.filter=function(a,b){var c=this;return new gc(function(d){var e=0;return c.subscribe(function(f){var g;try{g=a.call(b,f,e++,c)}catch(h){return d.onError(h),void 0}g&&d.onNext(f)},d.onError.bind(d),d.onCompleted.bind(d))})},Sb.fromCallback=function(a,b,c,d){return b||(b=Ab),function(){var e=gb.call(arguments,0);return new gc(function(f){return b.schedule(function(){function b(a){var b=a;if(d)try{b=d(arguments)}catch(c){return f.onError(c),void 0}else 1===b.length&&(b=b[0]);f.onNext(b),f.onCompleted()}e.push(b),a.apply(c,e)})})}},Sb.fromNodeCallback=function(a,b,c,d){return b||(b=Ab),function(){var e=gb.call(arguments,0);return new gc(function(f){return b.schedule(function(){function b(a){if(a)return f.onError(a),void 0;var b=gb.call(arguments,1);if(d)try{b=d(b)}catch(c){return f.onError(c),void 0}else 1===b.length&&(b=b[0]);f.onNext(b),f.onCompleted()}e.push(b),a.apply(c,e)})})}},Sb.fromEvent=function(a,b,c){return new gc(function(d){return x(a,b,function(a){var b=a;if(c)try{b=c(arguments)}catch(e){return d.onError(e),void 0}d.onNext(b)})}).publish().refCount()},Sb.fromEventPattern=function(a,b,c){return new gc(function(d){function e(a){var b=a;if(c)try{b=c(arguments)}catch(e){return d.onError(e),void 0}d.onNext(b)}var f=a(e);return rb(function(){b&&b(e,f)})}).publish().refCount()};var cc=Sb.fromPromise=function(a){return new gc(function(b){a.then(function(a){b.onNext(a),b.onCompleted()},function(a){b.onError(a)})})};Pb.toPromise=function(a){if(a||(a=I.config.Promise),!a)throw new Error("Promise type not provided nor in Rx.config.Promise");var b=this;return new a(function(a,c){var d,e=!1;b.subscribe(function(a){d=a,e=!0},function(a){c(a)},function(){e&&a(d)})})},Sb.startAsync=function(a){var b;try{b=a()}catch(c){return Zb(c)}return cc(b)},Pb.multicast=function(a,b){var c=this;return"function"==typeof a?new gc(function(d){var e=c.multicast(a());return new ob(b(e).subscribe(d),e.connect())}):new dc(c,a)},Pb.publish=function(a){return a?this.multicast(function(){return new jc},a):this.multicast(new jc)},Pb.share=function(){return this.publish(null).refCount()},Pb.publishLast=function(a){return a?this.multicast(function(){return new kc},a):this.multicast(new kc)},Pb.publishValue=function(a,b){return 2===arguments.length?this.multicast(function(){return new mc(b)},a):this.multicast(new mc(a))},Pb.shareValue=function(a){return this.publishValue(a).refCount()},Pb.replay=function(a,b,c,d){return a?this.multicast(function(){return new nc(b,c,d)},a):this.multicast(new nc(b,c,d))},Pb.shareReplay=function(a,b,c){return this.replay(null,a,b,c).refCount()};var dc=I.ConnectableObservable=function(a){function b(b,c){function d(a){return e.subject.subscribe(a)}var e={subject:c,source:b.asObservable(),hasSubscription:!1,subscription:null};this.connect=function(){return e.hasSubscription||(e.hasSubscription=!0,e.subscription=new ob(e.source.subscribe(e.subject),rb(function(){e.hasSubscription=!1}))),e.subscription},a.call(this,d)}return hb(b,a),b.prototype.connect=function(){return this.connect()},b.prototype.refCount=function(){var a=null,b=0,c=this;return new gc(function(d){var e,f;return b++,e=1===b,f=c.subscribe(d),e&&(a=c.connect()),rb(function(){f.dispose(),b--,0===b&&a.dispose()})})},b}(Sb),ec=Sb.interval=function(a,b){return b||(b=Db),z(a,a,b)},fc=Sb.timer=function(b,c,d){var e;return d||(d=Db),"number"==typeof c?e=c:"object"==typeof c&&"now"in c&&(d=c),e===a?y(b,d):z(b,e,d)};Pb.delay=function(a,b){b||(b=Db);var c=this;return new gc(function(d){var e,f=!1,g=new vb,h=null,i=[],j=!1;return e=c.materialize().timestamp(b).subscribe(function(c){var e,k;"E"===c.value.kind?(i=[],i.push(c),h=c.value.exception,k=!j):(i.push({value:c.value,timestamp:c.timestamp+a}),k=!f,f=!0),k&&(null!==h?d.onError(h):(e=new ub,g.setDisposable(e),e.setDisposable(b.scheduleRecursiveWithRelative(a,function(a){var c,e,g,k;if(null===h){j=!0;do g=null,i.length>0&&i[0].timestamp-b.now()<=0&&(g=i.shift().value),null!==g&&g.accept(d);while(null!==g);k=!1,e=0,i.length>0?(k=!0,e=Math.max(0,i[0].timestamp-b.now())):f=!1,c=h,j=!1,null!==c?d.onError(c):k&&a(e)}}))))}),new ob(e,g)})},Pb.throttle=function(a,b){b||(b=Db);return this.throttleWithSelector(function(){return fc(a,b)})},Pb.timeInterval=function(a){var b=this;return a||(a=Db),Ub(function(){var c=a.now();return b.select(function(b){var d=a.now(),e=d-c;return c=d,{value:b,interval:e}})})},Pb.timestamp=function(a){return a||(a=Db),this.select(function(b){return{value:b,timestamp:a.now()}})},Pb.sample=function(a,b){return b||(b=Db),"number"==typeof a?A(this,ec(a,b)):A(this,a)},Pb.timeout=function(a,b,c){var d,e=this;return b||(b=Zb(new Error("Timeout"))),c||(c=Db),d=a instanceof Date?function(a,b){c.scheduleWithAbsolute(a,b)}:function(a,b){c.scheduleWithRelative(a,b)},new gc(function(c){var f,g=0,h=new ub,i=new vb,j=!1,k=new vb;return i.setDisposable(h),f=function(){var e=g;k.setDisposable(d(a,function(){j=g===e;var a=j;a&&i.setDisposable(b.subscribe(c))}))},f(),h.setDisposable(e.subscribe(function(a){var b=!j;b&&(g++,c.onNext(a),f())},function(a){var b=!j;b&&(g++,c.onError(a))},function(){var a=!j;a&&(g++,c.onCompleted())})),new ob(i,k)})},Sb.generateWithTime=function(a,b,c,d,e,f){return f||(f=Db),new gc(function(g){var h,i,j=!0,k=!1,l=a;return f.scheduleRecursiveWithRelative(0,function(a){k&&g.onNext(h);try{j?j=!1:l=c(l),k=b(l),k&&(h=d(l),i=e(l))}catch(f){return g.onError(f),void 0}k?a(i):g.onCompleted()})})},Pb.delaySubscription=function(a,b){return b||(b=Db),this.delayWithSelector(fc(a,b),function(){return Vb()})},Pb.delayWithSelector=function(a,b){var c,d,e=this;return"function"==typeof a?d=a:(c=a,d=b),new gc(function(a){var b=new ob,f=!1,g=function(){f&&0===b.length&&a.onCompleted()},h=new vb,i=function(){h.setDisposable(e.subscribe(function(c){var e;try{e=d(c)}catch(f){return a.onError(f),void 0}var h=new ub;b.add(h),h.setDisposable(e.subscribe(function(){a.onNext(c),b.remove(h),g()},a.onError.bind(a),function(){a.onNext(c),b.remove(h),g()}))},a.onError.bind(a),function(){f=!0,h.dispose(),g()}))};return c?h.setDisposable(c.subscribe(function(){i()},a.onError.bind(a),function(){i()})):i(),new ob(h,b)})},Pb.timeoutWithSelector=function(a,b,c){if(1===arguments.length){b=a;var a=Xb()}c||(c=Zb(new Error("Timeout")));var d=this;return new gc(function(e){var f=new vb,g=new vb,h=new ub;f.setDisposable(h);var i=0,j=!1,k=function(a){var b=i,d=function(){return i===b},h=new ub;g.setDisposable(h),h.setDisposable(a.subscribe(function(){d()&&f.setDisposable(c.subscribe(e)),h.dispose()},function(a){d()&&e.onError(a)},function(){d()&&f.setDisposable(c.subscribe(e))}))};k(a);var l=function(){var a=!j;return a&&i++,a};return h.setDisposable(d.subscribe(function(a){if(l()){e.onNext(a);var c;try{c=b(a)}catch(d){return e.onError(d),void 0}k(c)}},function(a){l()&&e.onError(a)},function(){l()&&e.onCompleted()})),new ob(f,g)})},Pb.throttleWithSelector=function(a){var b=this;return new gc(function(c){var d,e=!1,f=new vb,g=0,h=b.subscribe(function(b){var h;try{h=a(b)}catch(i){return c.onError(i),void 0}e=!0,d=b,g++;var j=g,k=new ub;f.setDisposable(k),k.setDisposable(h.subscribe(function(){e&&g===j&&c.onNext(d),e=!1,k.dispose()},c.onError.bind(c),function(){e&&g===j&&c.onNext(d),e=!1,k.dispose()}))},function(a){f.dispose(),c.onError(a),e=!1,g++},function(){f.dispose(),e&&c.onNext(d),c.onCompleted(),e=!1,g++});return new ob(h,f)})},Pb.skipLastWithTime=function(a,b){b||(b=Db);var c=this;return new gc(function(d){var e=[];return c.subscribe(function(c){var f=b.now();for(e.push({interval:f,value:c});e.length>0&&f-e[0].interval>=a;)d.onNext(e.shift().value)},d.onError.bind(d),function(){for(var c=b.now();e.length>0&&c-e[0].interval>=a;)d.onNext(e.shift().value);d.onCompleted()})})},Pb.takeLastWithTime=function(a,b,c){return this.takeLastBufferWithTime(a,b).selectMany(function(a){return Wb(a,c)})},Pb.takeLastBufferWithTime=function(a,b){var c=this;return b||(b=Db),new gc(function(d){var e=[];return c.subscribe(function(c){var d=b.now();for(e.push({interval:d,value:c});e.length>0&&d-e[0].interval>=a;)e.shift()},d.onError.bind(d),function(){for(var c=b.now(),f=[];e.length>0;){var g=e.shift();c-g.interval<=a&&f.push(g.value)}d.onNext(f),d.onCompleted()})})},Pb.takeWithTime=function(a,b){var c=this;return b||(b=Db),new gc(function(d){var e=b.scheduleWithRelative(a,function(){d.onCompleted()});return new ob(e,c.subscribe(d))})},Pb.skipWithTime=function(a,b){var c=this;return b||(b=Db),new gc(function(d){var e=!1,f=b.scheduleWithRelative(a,function(){e=!0}),g=c.subscribe(function(a){e&&d.onNext(a)},d.onError.bind(d),d.onCompleted.bind(d));return new ob(f,g)})},Pb.skipUntilWithTime=function(a,b){b||(b=Db);var c=this;return new gc(function(d){var e=!1,f=b.scheduleWithAbsolute(a,function(){e=!0}),g=c.subscribe(function(a){e&&d.onNext(a)},d.onError.bind(d),d.onCompleted.bind(d));return new ob(f,g)})},Pb.takeUntilWithTime=function(a,b){b||(b=Db);var c=this;return new gc(function(d){return new ob(b.scheduleWithAbsolute(a,function(){d.onCompleted()}),c.subscribe(d))})},Pb.pausable=function(a){var b=this;return new gc(function(c){var d=b.publish(),e=d.subscribe(c),f=sb,g=a.distinctUntilChanged().subscribe(function(a){a?f=d.connect():(f.dispose(),f=sb)});return new ob(e,f,g)})};var gc=I.AnonymousObservable=function(a){function b(a){return"undefined"==typeof a?a=sb:"function"==typeof a&&(a=rb(a)),a}function c(d){function e(a){var c=new hc(a);if(Bb.scheduleRequired())Bb.schedule(function(){try{c.setDisposable(b(d(c)))}catch(a){if(!c.fail(a))throw a}});else try{c.setDisposable(b(d(c)))}catch(e){if(!c.fail(e))throw e}return c}return this instanceof c?(a.call(this,e),void 0):new c(d)}return hb(c,a),c}(Sb),hc=function(a){function b(b){a.call(this),this.observer=b,this.m=new ub}hb(b,a);var c=b.prototype;return c.next=function(a){var b=!1;try{this.observer.onNext(a),b=!0}catch(c){throw c}finally{b||this.dispose()}},c.error=function(a){try{this.observer.onError(a)}catch(b){throw b}finally{this.dispose()}},c.completed=function(){try{this.observer.onCompleted()}catch(a){throw a}finally{this.dispose()}},c.setDisposable=function(a){this.m.setDisposable(a)},c.getDisposable=function(){return this.m.getDisposable()},c.disposable=function(a){return arguments.length?this.getDisposable():setDisposable(a)},c.dispose=function(){a.prototype.dispose.call(this),this.m.dispose()},b}(Qb),ic=function(a,b){this.subject=a,this.observer=b};ic.prototype.dispose=function(){if(!this.subject.isDisposed&&null!==this.observer){var a=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(a,1),this.observer=null}};var jc=I.Subject=function(a){function b(a){return h.call(this),this.isStopped?this.exception?(a.onError(this.exception),sb):(a.onCompleted(),sb):(this.observers.push(a),new ic(this,a))}function c(){a.call(this,b),this.isDisposed=!1,this.isStopped=!1,this.observers=[]}return hb(c,a),ib(c.prototype,Nb,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(h.call(this),!this.isStopped){var a=this.observers.slice(0);this.isStopped=!0;for(var b=0,c=a.length;c>b;b++)a[b].onCompleted();this.observers=[]}},onError:function(a){if(h.call(this),!this.isStopped){var b=this.observers.slice(0);this.isStopped=!0,this.exception=a;for(var c=0,d=b.length;d>c;c++)b[c].onError(a);this.observers=[]}},onNext:function(a){if(h.call(this),!this.isStopped)for(var b=this.observers.slice(0),c=0,d=b.length;d>c;c++)b[c].onNext(a)},dispose:function(){this.isDisposed=!0,this.observers=null}}),c.create=function(a,b){return new lc(a,b)},c}(Sb),kc=I.AsyncSubject=function(a){function b(a){if(h.call(this),!this.isStopped)return this.observers.push(a),new ic(this,a);var b=this.exception,c=this.hasValue,d=this.value;return b?a.onError(b):c?(a.onNext(d),a.onCompleted()):a.onCompleted(),sb}function c(){a.call(this,b),this.isDisposed=!1,this.isStopped=!1,this.value=null,this.hasValue=!1,this.observers=[],this.exception=null}return hb(c,a),ib(c.prototype,Nb,{hasObservers:function(){return h.call(this),this.observers.length>0},onCompleted:function(){var a,b,c;if(h.call(this),!this.isStopped){this.isStopped=!0;var d=this.observers.slice(0),e=this.value,f=this.hasValue;if(f)for(b=0,c=d.length;c>b;b++)a=d[b],a.onNext(e),a.onCompleted();else for(b=0,c=d.length;c>b;b++)d[b].onCompleted();this.observers=[]}},onError:function(a){if(h.call(this),!this.isStopped){var b=this.observers.slice(0);this.isStopped=!0,this.exception=a;for(var c=0,d=b.length;d>c;c++)b[c].onError(a);this.observers=[]}},onNext:function(a){h.call(this),this.isStopped||(this.value=a,this.hasValue=!0)},dispose:function(){this.isDisposed=!0,this.observers=null,this.exception=null,this.value=null}}),c}(Sb),lc=function(a){function b(a){return this.observable.subscribe(a)}function c(c,d){a.call(this,b),this.observer=c,this.observable=d}return hb(c,a),ib(c.prototype,Nb,{onCompleted:function(){this.observer.onCompleted()},onError:function(a){this.observer.onError(a)},onNext:function(a){this.observer.onNext(a)}}),c}(Sb),mc=I.BehaviorSubject=function(a){function b(a){if(h.call(this),!this.isStopped)return this.observers.push(a),a.onNext(this.value),new ic(this,a);var b=this.exception;return b?a.onError(b):a.onCompleted(),sb}function c(c){a.call(this,b),this.value=c,this.observers=[],this.isDisposed=!1,this.isStopped=!1,this.exception=null}return hb(c,a),ib(c.prototype,Nb,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(h.call(this),!this.isStopped){var a=this.observers.slice(0);this.isStopped=!0;for(var b=0,c=a.length;c>b;b++)a[b].onCompleted();this.observers=[]}},onError:function(a){if(h.call(this),!this.isStopped){var b=this.observers.slice(0);this.isStopped=!0,this.exception=a;for(var c=0,d=b.length;d>c;c++)b[c].onError(a);this.observers=[]}},onNext:function(a){if(h.call(this),!this.isStopped){this.value=a;for(var b=this.observers.slice(0),c=0,d=b.length;d>c;c++)b[c].onNext(a)}},dispose:function(){this.isDisposed=!0,this.observers=null,this.value=null,this.exception=null}}),c}(Sb),nc=I.ReplaySubject=function(a){function b(a,b){this.subject=a,this.observer=b}function c(a){var c=new Tb(this.scheduler,a),d=new b(this,c);h.call(this),this._trim(this.scheduler.now()),this.observers.push(c);for(var e=this.q.length,f=0,g=this.q.length;g>f;f++)c.onNext(this.q[f].value);return this.hasError?(e++,c.onError(this.error)):this.isStopped&&(e++,c.onCompleted()),c.ensureActive(e),d}function d(b,d,e){this.bufferSize=null==b?Number.MAX_VALUE:b,this.windowSize=null==d?Number.MAX_VALUE:d,this.scheduler=e||Bb,this.q=[],this.observers=[],this.isStopped=!1,this.isDisposed=!1,this.hasError=!1,this.error=null,a.call(this,c)}return b.prototype.dispose=function(){if(this.observer.dispose(),!this.subject.isDisposed){var a=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(a,1)}},hb(d,a),ib(d.prototype,Nb,{hasObservers:function(){return this.observers.length>0},_trim:function(a){for(;this.q.length>this.bufferSize;)this.q.shift();for(;this.q.length>0&&a-this.q[0].interval>this.windowSize;)this.q.shift()},onNext:function(a){var b;if(h.call(this),!this.isStopped){var c=this.scheduler.now();this.q.push({interval:c,value:a}),this._trim(c);for(var d=this.observers.slice(0),e=0,f=d.length;f>e;e++)b=d[e],b.onNext(a),b.ensureActive()}},onError:function(a){var b;if(h.call(this),!this.isStopped){this.isStopped=!0,this.error=a,this.hasError=!0;var c=this.scheduler.now();this._trim(c);for(var d=this.observers.slice(0),e=0,f=d.length;f>e;e++)b=d[e],b.onError(a),b.ensureActive();this.observers=[]}},onCompleted:function(){var a;if(h.call(this),!this.isStopped){this.isStopped=!0;var b=this.scheduler.now();this._trim(b);for(var c=this.observers.slice(0),d=0,e=c.length;e>d;d++)a=c[d],a.onCompleted(),a.ensureActive();this.observers=[]}},dispose:function(){this.isDisposed=!0,this.observers=null}}),d}(Sb);"function"==typeof define&&"object"==typeof define.amd&&define.amd?(C.Rx=I,define(function(){return I})):D&&E?F?(E.exports=I).Rx=I:D.Rx=I:C.Rx=I}).call(this); \ No newline at end of file +(function(a){function b(){}function c(a){return a}function d(a,b){return gb(a,b)}function e(a,b){return a-b}function f(a){throw a}function g(a){return"function"==typeof a.then}function h(){if(this.isDisposed)throw new Error(N)}function i(a){var b=typeof a;return a&&("function"==b||"object"==b)||!1}function j(a){var b=[];if(!i(a))return b;fb.nonEnumArgs&&a.length&&n(a)&&(a=hb.call(a));var c=fb.enumPrototypes&&"function"==typeof a,d=fb.enumErrorProps&&(a===_||a instanceof Error);for(var e in a)c&&"prototype"==e||d&&("message"==e||"name"==e)||b.push(e);if(fb.nonEnumShadows&&a!==ab){var f=a.constructor,g=-1,h=db.length;if(a===(f&&f.prototype))var j=a===stringProto?X:a===_?S:Y.call(a),k=eb[j];for(;++g-1:void 0});return c.pop(),d.pop(),result}function q(a,b){return 1===a.length&&Array.isArray(a[b])?a[b]:hb.call(a)}function r(a,b){for(var c=new Array(a),d=0;a>d;d++)c[d]=b();return c}function s(a,b){return new jc(function(c){var d=new vb,e=new wb;return e.setDisposable(d),d.setDisposable(a.subscribe(c.onNext.bind(c),function(a){var d,f;try{f=b(a)}catch(g){return c.onError(g),void 0}d=new vb,e.setDisposable(d),d.setDisposable(f.subscribe(c))},c.onCompleted.bind(c))),e})}function t(a,b){var c=this;return new jc(function(d){var e=0,f=a.length;return c.subscribe(function(c){if(f>e){var g,h=a[e++];try{g=b(c,h)}catch(i){return d.onError(i),void 0}d.onNext(g)}else d.onCompleted()},d.onError.bind(d),d.onCompleted.bind(d))})}function u(a){return this.select(function(b,c){var d=a(b,c);return g(d)?dc(d):d}).mergeObservable()}function v(a){var b=function(){this.cancelBubble=!0},c=function(){if(this.bubbledKeyCode=this.keyCode,this.ctrlKey)try{this.keyCode=0}catch(a){}this.defaultPrevented=!0,this.returnValue=!1,this.modified=!0};if(a||(a=window.event),!a.target)switch(a.target=a.target||a.srcElement,"mouseover"==a.type&&(a.relatedTarget=a.fromElement),"mouseout"==a.type&&(a.relatedTarget=a.toElement),a.stopPropagation||(a.stopPropagation=b,a.preventDefault=c),a.type){case"keypress":var d="charCode"in a?a.charCode:a.keyCode;10==d?(d=0,a.keyCode=13):13==d||27==d?d=0:3==d&&(d=99),a.charCode=d,a.keyChar=a.charCode?String.fromCharCode(a.charCode):""}return a}function w(a,b,c){if(a.addListener)return a.addListener(b,c),sb(function(){a.removeListener(b,c)});if(a.addEventListener)return a.addEventListener(b,c,!1),sb(function(){a.removeEventListener(b,c,!1)});if(a.attachEvent){var d=function(a){c(v(a))};return a.attachEvent("on"+b,d),sb(function(){a.detachEvent("on"+b,d)})}return a["on"+b]=c,sb(function(){a["on"+b]=null})}function x(a,b,c){var d=new pb;if(a&&a.length)for(var e=0,f=a.length;f>e;e++)d.add(x(a[e],b,c));else a&&d.add(w(a,b,c));return d}function y(a,b){var c=Ab(a);return new jc(function(a){return b.scheduleWithRelative(c,function(){a.onNext(0),a.onCompleted()})})}function z(a,b,c){return a===b?new jc(function(a){return c.schedulePeriodicWithState(0,b,function(b){return a.onNext(b),b+1})}):Vb(function(){return observableTimerDateAndPeriod(c.now()+a,b,c)})}function A(a,b){return new jc(function(c){function d(){g&&(g=!1,c.onNext(f)),e&&c.onCompleted()}var e,f,g;return new pb(a.subscribe(function(a){g=!0,f=a},c.onError.bind(c),function(){e=!0}),b.subscribe(d,c.onError.bind(c),d))})}function B(a,b,d){return new jc(function(e){function f(a,b){k[b]=a;var f;if(h[b]=!0,i||(i=h.every(c))){try{f=d.apply(null,k)}catch(g){return e.onError(g),void 0}e.onNext(f)}else j&&e.onCompleted()}var g=2,h=[!1,!1],i=!1,j=!1,k=new Array(g);return new pb(a.subscribe(function(a){f(a,0)},e.onError.bind(e),function(){j=!0,e.onCompleted()}),b.subscribe(function(a){f(a,1)},e.onError.bind(e)))})}var C={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},D=C[typeof window]&&window||this,E=C[typeof exports]&&exports&&!exports.nodeType&&exports,F=C[typeof module]&&module&&!module.nodeType&&module,G=F&&F.exports===E&&E,H=C[typeof global]&&global;!H||H.global!==H&&H.window!==H||(D=H);var I,J={internals:{},config:{}},K=function(){return Date.now?Date.now:function(){return+new Date}}(),L="Sequence contains no elements.",M="Argument out of range",N="Object has been disposed",O="[object Arguments]",P="[object Array]",Q="[object Boolean]",R="[object Date]",S="[object Error]",T="[object Function]",U="[object Number]",V="[object Object]",W="[object RegExp]",X="[object String]",Y=Object.prototype.toString,Z=Object.prototype.hasOwnProperty,$=Y.call(arguments)==O,_=Error.prototype,ab=Object.prototype,bb=ab.propertyIsEnumerable;try{I=!(Y.call(document)==V&&!({toString:0}+""))}catch(cb){I=!0}var db=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],eb={};eb[P]=eb[R]=eb[U]={constructor:!0,toLocaleString:!0,toString:!0,valueOf:!0},eb[Q]=eb[X]={constructor:!0,toString:!0,valueOf:!0},eb[S]=eb[T]=eb[W]={constructor:!0,toString:!0},eb[V]={constructor:!0};var fb={};!function(){var a=function(){this.x=1},b=[];a.prototype={valueOf:1,y:1};for(var c in new a)b.push(c);for(c in arguments);fb.enumErrorProps=bb.call(_,"message")||bb.call(_,"name"),fb.enumPrototypes=bb.call(a,"prototype"),fb.nonEnumArgs=0!=c,fb.nonEnumShadows=!/valueOf/.test(b)}(1),$||(n=function(a){return a&&"object"==typeof a?Z.call(a,"callee"):!1}),o(/x/)&&(o=function(a){return"function"==typeof a&&Y.call(a)==T});{var gb=J.internals.isEqual=function(a,b){return p(a,b,[],[])},hb=Array.prototype.slice,ib=({}.hasOwnProperty,this.inherits=J.internals.inherits=function(a,b){function c(){this.constructor=a}c.prototype=b.prototype,a.prototype=new c}),jb=J.internals.addProperties=function(a){for(var b=hb.call(arguments,1),c=0,d=b.length;d>c;c++){var e=b[c];for(var f in e)a[f]=e[f]}};J.internals.addRef=function(a,b){return new jc(function(c){return new pb(b.getDisposable(),a.subscribe(c))})}}Function.prototype.bind||(Function.prototype.bind=function(a){var b=this,c=hb.call(arguments,1),d=function(){function e(){}if(this instanceof d){e.prototype=b.prototype;var f=new e,g=b.apply(f,c.concat(hb.call(arguments)));return Object(g)===g?g:f}return b.apply(a,c.concat(hb.call(arguments)))};return d});var kb=Object("a"),lb="a"!=kb[0]||!(0 in kb);Array.prototype.every||(Array.prototype.every=function(a){var b=Object(this),c=lb&&{}.toString.call(this)==X?this.split(""):b,d=c.length>>>0,e=arguments[1];if({}.toString.call(a)!=T)throw new TypeError(a+" is not a function");for(var f=0;d>f;f++)if(f in c&&!a.call(e,c[f],f,b))return!1;return!0}),Array.prototype.map||(Array.prototype.map=function(a){var b=Object(this),c=lb&&{}.toString.call(this)==X?this.split(""):b,d=c.length>>>0,e=Array(d),f=arguments[1];if({}.toString.call(a)!=T)throw new TypeError(a+" is not a function");for(var g=0;d>g;g++)g in c&&(e[g]=a.call(f,c[g],g,b));return e}),Array.prototype.filter||(Array.prototype.filter=function(a){for(var b,c=[],d=new Object(this),e=0,f=d.length>>>0;f>e;e++)b=d[e],e in d&&a.call(arguments[1],b,e,d)&&c.push(b);return c}),Array.isArray||(Array.isArray=function(a){return Object.prototype.toString.call(a)==P}),Array.prototype.indexOf||(Array.prototype.indexOf=function(a){var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=0;if(arguments.length>1&&(d=Number(arguments[1]),d!==d?d=0:0!==d&&1/0!=d&&d!==-1/0&&(d=(d>0||-1)*Math.floor(Math.abs(d)))),d>=c)return-1;for(var e=d>=0?d:Math.max(c-Math.abs(d),0);c>e;e++)if(e in b&&b[e]===a)return e;return-1});var mb=function(a,b){this.id=a,this.value=b};mb.prototype.compareTo=function(a){var b=this.value.compareTo(a.value);return 0===b&&(b=this.id-a.id),b};var nb=J.internals.PriorityQueue=function(a){this.items=new Array(a),this.length=0},ob=nb.prototype;ob.isHigherPriority=function(a,b){return this.items[a].compareTo(this.items[b])<0},ob.percolate=function(a){if(!(a>=this.length||0>a)){var b=a-1>>1;if(!(0>b||b===a)&&this.isHigherPriority(a,b)){var c=this.items[a];this.items[a]=this.items[b],this.items[b]=c,this.percolate(b)}}},ob.heapify=function(b){if(b===a&&(b=0),!(b>=this.length||0>b)){var c=2*b+1,d=2*b+2,e=b;if(cb;b++)a[b].dispose()}},qb.clear=function(){var a=this.disposables.slice(0);this.disposables=[],this.length=0;for(var b=0,c=a.length;c>b;b++)a[b].dispose()},qb.contains=function(a){return-1!==this.disposables.indexOf(a)},qb.toArray=function(){return this.disposables.slice(0)};var rb=J.Disposable=function(a){this.isDisposed=!1,this.action=a||b};rb.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var sb=rb.create=function(a){return new rb(a)},tb=rb.empty={dispose:b},ub=function(){function a(a){this.isSingle=a,this.isDisposed=!1,this.current=null}var b=a.prototype;return b.getDisposable=function(){return this.current},b.setDisposable=function(a){if(this.current&&this.isSingle)throw new Error("Disposable has already been assigned");var b,c=this.isDisposed;c||(b=this.current,this.current=a),b&&b.dispose(),c&&a&&a.dispose()},b.dispose=function(){var a;this.isDisposed||(this.isDisposed=!0,a=this.current,this.current=null),a&&a.dispose()},a}(),vb=J.SingleAssignmentDisposable=function(a){function b(){a.call(this,!0)}return ib(b,a),b}(ub),wb=J.SerialDisposable=function(a){function b(){a.call(this,!1)}return ib(b,a),b}(ub),xb=(J.RefCountDisposable=function(){function a(a){this.disposable=a,this.disposable.count++,this.isInnerDisposed=!1}function b(a){this.underlyingDisposable=a,this.isDisposed=!1,this.isPrimaryDisposed=!1,this.count=0}return a.prototype.dispose=function(){this.disposable.isDisposed||this.isInnerDisposed||(this.isInnerDisposed=!0,this.disposable.count--,0===this.disposable.count&&this.disposable.isPrimaryDisposed&&(this.disposable.isDisposed=!0,this.disposable.underlyingDisposable.dispose()))},b.prototype.dispose=function(){this.isDisposed||this.isPrimaryDisposed||(this.isPrimaryDisposed=!0,0===this.count&&(this.isDisposed=!0,this.underlyingDisposable.dispose()))},b.prototype.getDisposable=function(){return this.isDisposed?tb:new a(this)},b}(),J.internals.ScheduledItem=function(a,b,c,d,f){this.scheduler=a,this.state=b,this.action=c,this.dueTime=d,this.comparer=f||e,this.disposable=new vb});xb.prototype.invoke=function(){this.disposable.setDisposable(this.invokeCore())},xb.prototype.compareTo=function(a){return this.comparer(this.dueTime,a.dueTime)},xb.prototype.isCancelled=function(){return this.disposable.isDisposed},xb.prototype.invokeCore=function(){return this.action(this.scheduler,this.state)};var yb,zb=J.Scheduler=function(){function a(a,b,c,d){this.now=a,this._schedule=b,this._scheduleRelative=c,this._scheduleAbsolute=d}function b(a,b){var c=b.first,d=b.second,e=new pb,f=function(b){d(b,function(b){var c=!1,d=!1,g=a.scheduleWithState(b,function(a,b){return c?e.remove(g):d=!0,f(b),tb});d||(e.add(g),c=!0)})};return f(c),e}function c(a,b,c){var d=b.first,e=b.second,f=new pb,g=function(b){e(b,function(b,d){var e=!1,h=!1,i=a[c].call(a,b,d,function(a,b){return e?f.remove(i):h=!0,g(b),tb});h||(f.add(i),e=!0)})};return g(d),f}function d(a,b){return b(),tb}var e=a.prototype;return e.schedulePeriodic=function(a,b){return this.schedulePeriodicWithState(null,a,function(){b()})},e.schedulePeriodicWithState=function(a,b,c){var d=a,e=setInterval(function(){d=c(d)},b);return sb(function(){clearInterval(e)})},e.schedule=function(a){return this._schedule(a,d)},e.scheduleWithState=function(a,b){return this._schedule(a,b)},e.scheduleWithRelative=function(a,b){return this._scheduleRelative(b,a,d)},e.scheduleWithRelativeAndState=function(a,b,c){return this._scheduleRelative(a,b,c)},e.scheduleWithAbsolute=function(a,b){return this._scheduleAbsolute(b,a,d)},e.scheduleWithAbsoluteAndState=function(a,b,c){return this._scheduleAbsolute(a,b,c)},e.scheduleRecursive=function(a){return this.scheduleRecursiveWithState(a,function(a,b){a(function(){b(a)})})},e.scheduleRecursiveWithState=function(a,c){return this.scheduleWithState({first:a,second:c},function(a,c){return b(a,c)})},e.scheduleRecursiveWithRelative=function(a,b){return this.scheduleRecursiveWithRelativeAndState(b,a,function(a,b){a(function(c){b(a,c)})})},e.scheduleRecursiveWithRelativeAndState=function(a,b,d){return this._scheduleRelative({first:a,second:d},b,function(a,b){return c(a,b,"scheduleWithRelativeAndState")})},e.scheduleRecursiveWithAbsolute=function(a,b){return this.scheduleRecursiveWithAbsoluteAndState(b,a,function(a,b){a(function(c){b(a,c)})})},e.scheduleRecursiveWithAbsoluteAndState=function(a,b,d){return this._scheduleAbsolute({first:a,second:d},b,function(a,b){return c(a,b,"scheduleWithAbsoluteAndState")})},a.now=K,a.normalize=function(a){return 0>a&&(a=0),a},a}(),Ab=zb.normalize,Bb=zb.immediate=function(){function a(a,b){return b(this,a)}function b(a,b,c){for(var d=Ab(d);d-this.now()>0;);return c(this,a)}function c(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}return new zb(K,a,b,c)}(),Cb=zb.currentThread=function(){function a(a){for(var b;a.length>0;)if(b=a.dequeue(),!b.isCancelled()){for(;b.dueTime-zb.now()>0;);b.isCancelled()||b.invoke()}}function b(a,b){return this.scheduleWithRelativeAndState(a,0,b)}function c(b,c,d){var f=this.now()+zb.normalize(c),g=new xb(this,b,d,f);if(e)e.enqueue(g);else{e=new nb(4),e.enqueue(g);try{a(e)}catch(h){throw h}finally{e=null}}return g.disposable}function d(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}var e,f=new zb(K,b,c,d);return f.scheduleRequired=function(){return null===e},f.ensureTrampoline=function(a){return null===e?this.schedule(a):a()},f}(),Db=(J.internals.SchedulePeriodicRecursive=function(){function a(a,b){b(0,this._period);try{this._state=this._action(this._state)}catch(c){throw this._cancel.dispose(),c}}function b(a,b,c,d){this._scheduler=a,this._state=b,this._period=c,this._action=d}return b.prototype.start=function(){var b=new vb;return this._cancel=b,b.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,a.bind(this))),b},b}(),b);!function(){function a(){if(!D.postMessage||D.importScripts)return!1;var a=!1,b=D.onmessage;return D.onmessage=function(){a=!0},D.postMessage("","*"),D.onmessage=b,a}function b(a){if("string"==typeof a.data&&a.data.substring(0,f.length)===f){var b=a.data.substring(f.length),c=g[b];c(),delete g[b]}}var c=RegExp("^"+String(Y).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),d="function"==typeof(d=H&&G&&H.setImmediate)&&!c.test(d)&&d,e="function"==typeof(e=H&&G&&H.clearImmediate)&&!c.test(e)&&e;if("undefined"!=typeof process&&"[object process]"==={}.toString.call(process))yb=process.nextTick;else if("function"==typeof d)yb=d,Db=e;else if(a()){var f="ms.rx.schedule"+Math.random(),g={},h=0;D.addEventListener?D.addEventListener("message",b,!1):D.attachEvent("onmessage",b,!1),yb=function(a){var b=h++;g[b]=a,D.postMessage(f+b,"*")}}else if(D.MessageChannel){var i=new D.MessageChannel,j={},k=0;i.port1.onmessage=function(a){var b=a.data,c=j[b];c(),delete j[b]},yb=function(a){var b=k++;j[b]=a,i.port2.postMessage(b)}}else"document"in D&&"onreadystatechange"in D.document.createElement("script")?yb=function(a){var b=D.document.createElement("script");b.onreadystatechange=function(){a(),b.onreadystatechange=null,b.parentNode.removeChild(b),b=null},D.document.documentElement.appendChild(b)}:(yb=function(a){return setTimeout(a,0)},Db=clearTimeout)}();var Eb=zb.timeout=function(){function a(a,b){var c=this,d=new vb,e=yb(function(){d.isDisposed||d.setDisposable(b(c,a))});return new pb(d,sb(function(){Db(e)}))}function b(a,b,c){var d=this,e=zb.normalize(b);if(0===e)return d.scheduleWithState(a,c);var f=new vb,g=setTimeout(function(){f.isDisposed||f.setDisposable(c(d,a))},e);return new pb(f,sb(function(){clearTimeout(g)}))}function c(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}return new zb(K,a,b,c)}(),Fb=J.Notification=function(){function a(a,b){this.hasValue=null==b?!1:b,this.kind=a}var b=a.prototype;return b.accept=function(a,b,c){return 1===arguments.length&&"object"==typeof a?this._acceptObservable(a):this._accept(a,b,c)},b.toObservable=function(a){var b=this;return a||(a=Bb),new jc(function(c){return a.schedule(function(){b._acceptObservable(c),"N"===b.kind&&c.onCompleted()})})},a}(),Gb=Fb.createOnNext=function(){function a(a){return a(this.value)}function b(a){return a.onNext(this.value)}function c(){return"OnNext("+this.value+")"}return function(d){var e=new Fb("N",!0);return e.value=d,e._accept=a,e._acceptObservable=b,e.toString=c,e}}(),Hb=Fb.createOnError=function(){function a(a,b){return b(this.exception)}function b(a){return a.onError(this.exception)}function c(){return"OnError("+this.exception+")"}return function(d){var e=new Fb("E");return e.exception=d,e._accept=a,e._acceptObservable=b,e.toString=c,e}}(),Ib=Fb.createOnCompleted=function(){function a(a,b,c){return c()}function b(a){return a.onCompleted()}function c(){return"OnCompleted()"}return function(){var d=new Fb("C");return d._accept=a,d._acceptObservable=b,d.toString=c,d}}(),Jb=J.internals.Enumerator=function(a,b){this.moveNext=a,this.getCurrent=b},Kb=Jb.create=function(a,b){var c=!1;return new Jb(function(){if(c)return!1;var b=a();return b||(c=!0),b},function(){return b()})},Lb=J.internals.Enumerable=function(a){this.getEnumerator=a};Lb.prototype.concat=function(){var a=this;return new jc(function(b){var c,d=a.getEnumerator(),e=new wb,f=Bb.scheduleRecursive(function(a){var f,g;if(!c){try{g=d.moveNext(),g&&(f=d.getCurrent())}catch(h){return b.onError(h),void 0}if(!g)return b.onCompleted(),void 0;var i=new vb;e.setDisposable(i),i.setDisposable(f.subscribe(b.onNext.bind(b),b.onError.bind(b),function(){a()}))}});return new pb(e,f,sb(function(){c=!0}))})},Lb.prototype.catchException=function(){var a=this;return new jc(function(b){var c,d,e=a.getEnumerator(),f=new wb,g=Bb.scheduleRecursive(function(a){var g,h;if(!c){try{h=e.moveNext(),h&&(g=e.getCurrent())}catch(i){return b.onError(i),void 0}if(!h)return d?b.onError(d):b.onCompleted(),void 0;var j=new vb;f.setDisposable(j),j.setDisposable(g.subscribe(b.onNext.bind(b),function(b){d=b,a()},b.onCompleted.bind(b)))}});return new pb(f,g,sb(function(){c=!0}))})};var Mb=Lb.repeat=function(a,b){return 1===arguments.length&&(b=-1),new Lb(function(){var c,d=b;return Kb(function(){return 0===d?!1:(d>0&&d--,c=a,!0)},function(){return c})})},Nb=Lb.forEach=function(a,b,d){return b||(b=c),new Lb(function(){var c,e=-1;return Kb(function(){return++e0&&(a=!this.isAcquired,this.isAcquired=!0),a&&this.disposable.setDisposable(this.scheduler.scheduleRecursive(function(a){var c;if(!(b.queue.length>0))return b.isAcquired=!1,void 0;c=b.queue.shift();try{c()}catch(d){throw b.queue=[],b.hasFaulted=!0,d}a()}))},b.prototype.dispose=function(){a.prototype.dispose.call(this),this.disposable.dispose()},b}(Rb);Tb.create=Tb.createWithDisposable=function(a){return new jc(a)};var Vb=Tb.defer=function(a){return new jc(function(b){var c;try{c=a()}catch(d){return $b(d).subscribe(b)}return c.subscribe(b)})},Wb=Tb.empty=function(a){return a||(a=Bb),new jc(function(b){return a.schedule(function(){b.onCompleted()})})},Xb=Tb.fromArray=function(a,b){return b||(b=Cb),new jc(function(c){var d=0;return b.scheduleRecursive(function(b){dc?(d.onNext(a+c),e(c+1)):d.onCompleted()})})},Tb.repeat=function(a,b,c){return c||(c=Cb),null==b&&(b=-1),Zb(a,c).repeat(b)};var Zb=Tb["return"]=Tb.returnValue=function(a,b){return b||(b=Bb),new jc(function(c){return b.schedule(function(){c.onNext(a),c.onCompleted()})})},$b=Tb["throw"]=Tb.throwException=function(a,b){return b||(b=Bb),new jc(function(c){return b.schedule(function(){c.onError(a)})})};Qb["catch"]=Qb.catchException=function(a){return"function"==typeof a?s(this,a):_b([this,a])};var _b=Tb.catchException=Tb["catch"]=function(){var a=q(arguments,0);return Nb(a).catchException()};Qb.combineLatest=function(){var a=hb.call(arguments);return Array.isArray(a[0])?a[0].unshift(this):a.unshift(this),ac.apply(this,a)};var ac=Tb.combineLatest=function(){var a=hb.call(arguments),b=a.pop();return Array.isArray(a[0])&&(a=a[0]),new jc(function(d){function e(a){var e;if(i[a]=!0,j||(j=i.every(c))){try{e=b.apply(null,l)}catch(f){return d.onError(f),void 0}d.onNext(e)}else k.filter(function(b,c){return c!==a}).every(c)&&d.onCompleted()}function f(a){k[a]=!0,k.every(c)&&d.onCompleted()}for(var g=function(){return!1},h=a.length,i=r(h,g),j=!1,k=r(h,g),l=new Array(h),m=new Array(h),n=0;h>n;n++)!function(b){m[b]=new vb,m[b].setDisposable(a[b].subscribe(function(a){l[b]=a,e(b)},d.onError.bind(d),function(){f(b)}))}(n);return new pb(m)})};Qb.concat=function(){var a=hb.call(arguments,0);return a.unshift(this),bc.apply(this,a)};var bc=Tb.concat=function(){var a=q(arguments,0);return Nb(a).concat()};Qb.concatObservable=Qb.concatAll=function(){return this.merge(1)},Qb.merge=function(a){if("number"!=typeof a)return cc(this,a);var b=this;return new jc(function(c){var d=0,e=new pb,f=!1,h=[],i=function(a){var b=new vb;e.add(b),g(a)&&(a=dc(a)),b.setDisposable(a.subscribe(c.onNext.bind(c),c.onError.bind(c),function(){var a;e.remove(b),h.length>0?(a=h.shift(),i(a)):(d--,f&&0===d&&c.onCompleted())}))};return e.add(b.subscribe(function(b){a>d?(d++,i(b)):h.push(b)},c.onError.bind(c),function(){f=!0,0===d&&c.onCompleted()})),e})};var cc=Tb.merge=function(){var a,b;return arguments[0]?arguments[0].now?(a=arguments[0],b=hb.call(arguments,1)):(a=Bb,b=hb.call(arguments,0)):(a=Bb,b=hb.call(arguments,1)),Array.isArray(b[0])&&(b=b[0]),Xb(b,a).mergeObservable()};Qb.mergeObservable=Qb.mergeAll=function(){var a=this;return new jc(function(b){var c=new pb,d=!1,e=new vb;return c.add(e),e.setDisposable(a.subscribe(function(a){var e=new vb;c.add(e),g(a)&&(a=dc(a)),e.setDisposable(a.subscribe(function(a){b.onNext(a)},b.onError.bind(b),function(){c.remove(e),d&&1===c.length&&b.onCompleted()}))},b.onError.bind(b),function(){d=!0,1===c.length&&b.onCompleted()})),c})},Qb.skipUntil=function(a){var b=this;return new jc(function(c){var d=!1,e=new pb(b.subscribe(function(a){d&&c.onNext(a)},c.onError.bind(c),function(){d&&c.onCompleted()})),f=new vb;return e.add(f),f.setDisposable(a.subscribe(function(){d=!0,f.dispose()},c.onError.bind(c),function(){f.dispose()})),e})},Qb["switch"]=Qb.switchLatest=function(){var a=this;return new jc(function(b){var c=!1,d=new wb,e=!1,f=0,h=a.subscribe(function(a){var h=new vb,i=++f;c=!0,d.setDisposable(h),g(a)&&(a=dc(a)),h.setDisposable(a.subscribe(function(a){f===i&&b.onNext(a)},function(a){f===i&&b.onError(a)},function(){f===i&&(c=!1,e&&b.onCompleted())}))},b.onError.bind(b),function(){e=!0,c||b.onCompleted()});return new pb(h,d)})},Qb.takeUntil=function(a){var c=this;return new jc(function(d){return new pb(c.subscribe(d),a.subscribe(d.onCompleted.bind(d),d.onError.bind(d),b))})},Qb.zip=function(){if(Array.isArray(arguments[0]))return t.apply(this,arguments);var a=this,b=hb.call(arguments),d=b.pop();return b.unshift(a),new jc(function(e){function f(a){i[a]=!0,i.every(function(a){return a})&&e.onCompleted()}for(var g=b.length,h=r(g,function(){return[]}),i=r(g,function(){return!1}),j=function(b){var f,g;if(h.every(function(a){return a.length>0})){try{g=h.map(function(a){return a.shift()}),f=d.apply(a,g)}catch(j){return e.onError(j),void 0}e.onNext(f)}else i.filter(function(a,c){return c!==b}).every(c)&&e.onCompleted()},k=new Array(g),l=0;g>l;l++)!function(a){k[a]=new vb,k[a].setDisposable(b[a].subscribe(function(b){h[a].push(b),j(a)},e.onError.bind(e),function(){f(a)}))}(l);return new pb(k)})},Tb.zip=function(){var a=hb.call(arguments,0),b=a.shift();return b.zip.apply(b,a)},Tb.zipArray=function(){var a=q(arguments,0);return new jc(function(b){function d(a){if(g.every(function(a){return a.length>0})){var d=g.map(function(a){return a.shift()});b.onNext(d)}else if(h.filter(function(b,c){return c!==a}).every(c))return b.onCompleted(),void 0}function e(a){return h[a]=!0,h.every(c)?(b.onCompleted(),void 0):void 0}for(var f=a.length,g=r(f,function(){return[]}),h=r(f,function(){return!1}),i=new Array(f),j=0;f>j;j++)!function(c){i[c]=new vb,i[c].setDisposable(a[c].subscribe(function(a){g[c].push(a),d(c)},b.onError.bind(b),function(){e(c)}))}(j);var k=new pb(i);return k.add(sb(function(){for(var a=0,b=g.length;b>a;a++)g[a]=[]})),k})},Qb.asObservable=function(){var a=this;return new jc(function(b){return a.subscribe(b)})},Qb.dematerialize=function(){var a=this;return new jc(function(b){return a.subscribe(function(a){return a.accept(b)},b.onError.bind(b),b.onCompleted.bind(b))})},Qb.distinctUntilChanged=function(a,b){var e=this;return a||(a=c),b||(b=d),new jc(function(c){var d,f=!1;return e.subscribe(function(e){var g,h=!1;try{g=a(e)}catch(i){return c.onError(i),void 0}if(f)try{h=b(d,g)}catch(i){return c.onError(i),void 0}f&&h||(f=!0,d=g,c.onNext(e))},c.onError.bind(c),c.onCompleted.bind(c))})},Qb["do"]=Qb.doAction=function(a,b,c){var d,e=this;return"function"==typeof a?d=a:(d=a.onNext.bind(a),b=a.onError.bind(a),c=a.onCompleted.bind(a)),new jc(function(a){return e.subscribe(function(b){try{d(b)}catch(c){a.onError(c)}a.onNext(b)},function(c){if(b){try{b(c)}catch(d){a.onError(d)}a.onError(c)}else a.onError(c)},function(){if(c){try{c()}catch(b){a.onError(b)}a.onCompleted()}else a.onCompleted()})})},Qb["finally"]=Qb.finallyAction=function(a){var b=this;return new jc(function(c){var d=b.subscribe(c);return sb(function(){try{d.dispose()}catch(b){throw b}finally{a()}})})},Qb.ignoreElements=function(){var a=this;return new jc(function(c){return a.subscribe(b,c.onError.bind(c),c.onCompleted.bind(c))})},Qb.materialize=function(){var a=this;return new jc(function(b){return a.subscribe(function(a){b.onNext(Gb(a))},function(a){b.onNext(Hb(a)),b.onCompleted()},function(){b.onNext(Ib()),b.onCompleted()})})},Qb.repeat=function(a){return Mb(this,a).concat()},Qb.retry=function(a){return Mb(this,a).catchException()},Qb.scan=function(){var a,b,c=!1,d=this;return 2===arguments.length?(c=!0,a=arguments[0],b=arguments[1]):b=arguments[0],new jc(function(e){var f,g,h;return d.subscribe(function(d){try{h||(h=!0),f?g=b(g,d):(g=c?b(a,d):d,f=!0)}catch(i){return e.onError(i),void 0}e.onNext(g)},e.onError.bind(e),function(){!h&&c&&e.onNext(a),e.onCompleted()})})},Qb.skipLast=function(a){var b=this;return new jc(function(c){var d=[];return b.subscribe(function(b){d.push(b),d.length>a&&c.onNext(d.shift())},c.onError.bind(c),c.onCompleted.bind(c))})},Qb.startWith=function(){var a,b,c=0;return arguments.length&&"now"in Object(arguments[0])?(b=arguments[0],c=1):b=Bb,a=hb.call(arguments,c),Nb([Xb(a,b),this]).concat()},Qb.takeLast=function(a,b){return this.takeLastBuffer(a).selectMany(function(a){return Xb(a,b) +})},Qb.takeLastBuffer=function(a){var b=this;return new jc(function(c){var d=[];return b.subscribe(function(b){d.push(b),d.length>a&&d.shift()},c.onError.bind(c),function(){c.onNext(d),c.onCompleted()})})},Qb.select=Qb.map=function(a,b){var c=this;return new jc(function(d){var e=0;return c.subscribe(function(f){var g;try{g=a.call(b,f,e++,c)}catch(h){return d.onError(h),void 0}d.onNext(g)},d.onError.bind(d),d.onCompleted.bind(d))})},Qb.selectMany=Qb.flatMap=function(a,b){return b?this.selectMany(function(c,d){var e=a(c,d),f=g(e)?dc(e):e;return f.select(function(a){return b(c,a,d)})}):"function"==typeof a?u.call(this,a):u.call(this,function(){return a})},Qb.selectSwitch=Qb.flatMapLatest=function(a,b){return this.select(a,b).switchLatest()},Qb.skip=function(a){if(0>a)throw new Error(M);var b=this;return new jc(function(c){var d=a;return b.subscribe(function(a){0>=d?c.onNext(a):d--},c.onError.bind(c),c.onCompleted.bind(c))})},Qb.skipWhile=function(a,b){var c=this;return new jc(function(d){var e=0,f=!1;return c.subscribe(function(g){if(!f)try{f=!a.call(b,g,e++,c)}catch(h){return d.onError(h),void 0}f&&d.onNext(g)},d.onError.bind(d),d.onCompleted.bind(d))})},Qb.take=function(a,b){if(0>a)throw new Error(M);if(0===a)return Wb(b);var c=this;return new jc(function(b){var d=a;return c.subscribe(function(a){d>0&&(d--,b.onNext(a),0===d&&b.onCompleted())},b.onError.bind(b),b.onCompleted.bind(b))})},Qb.takeWhile=function(a,b){var c=this;return new jc(function(d){var e=0,f=!0;return c.subscribe(function(g){if(f){try{f=a.call(b,g,e++,c)}catch(h){return d.onError(h),void 0}f?d.onNext(g):d.onCompleted()}},d.onError.bind(d),d.onCompleted.bind(d))})},Qb.where=Qb.filter=function(a,b){var c=this;return new jc(function(d){var e=0;return c.subscribe(function(f){var g;try{g=a.call(b,f,e++,c)}catch(h){return d.onError(h),void 0}g&&d.onNext(f)},d.onError.bind(d),d.onCompleted.bind(d))})},Tb.fromCallback=function(a,b,c,d){return b||(b=Bb),function(){var e=hb.call(arguments,0);return new jc(function(f){return b.schedule(function(){function b(a){var b=a;if(d)try{b=d(arguments)}catch(c){return f.onError(c),void 0}else 1===b.length&&(b=b[0]);f.onNext(b),f.onCompleted()}e.push(b),a.apply(c,e)})})}},Tb.fromNodeCallback=function(a,b,c,d){return b||(b=Bb),function(){var e=hb.call(arguments,0);return new jc(function(f){return b.schedule(function(){function b(a){if(a)return f.onError(a),void 0;var b=hb.call(arguments,1);if(d)try{b=d(b)}catch(c){return f.onError(c),void 0}else 1===b.length&&(b=b[0]);f.onNext(b),f.onCompleted()}e.push(b),a.apply(c,e)})})}},Tb.fromEvent=function(a,b,c){return new jc(function(d){return x(a,b,function(a){var b=a;if(c)try{b=c(arguments)}catch(e){return d.onError(e),void 0}d.onNext(b)})}).publish().refCount()},Tb.fromEventPattern=function(a,b,c){return new jc(function(d){function e(a){var b=a;if(c)try{b=c(arguments)}catch(e){return d.onError(e),void 0}d.onNext(b)}var f=a(e);return sb(function(){b&&b(e,f)})}).publish().refCount()};var dc=Tb.fromPromise=function(a){return new jc(function(b){a.then(function(a){b.onNext(a),b.onCompleted()},function(a){b.onError(a)})})};Qb.toPromise=function(a){if(a||(a=J.config.Promise),!a)throw new Error("Promise type not provided nor in Rx.config.Promise");var b=this;return new a(function(a,c){var d,e=!1;b.subscribe(function(a){d=a,e=!0},function(a){c(a)},function(){e&&a(d)})})},Tb.startAsync=function(a){var b;try{b=a()}catch(c){return $b(c)}return dc(b)},Qb.multicast=function(a,b){var c=this;return"function"==typeof a?new jc(function(d){var e=c.multicast(a());return new pb(b(e).subscribe(d),e.connect())}):new ec(c,a)},Qb.publish=function(a){return a?this.multicast(function(){return new mc},a):this.multicast(new mc)},Qb.share=function(){return this.publish(null).refCount()},Qb.publishLast=function(a){return a?this.multicast(function(){return new nc},a):this.multicast(new nc)},Qb.publishValue=function(a,b){return 2===arguments.length?this.multicast(function(){return new pc(b)},a):this.multicast(new pc(a))},Qb.shareValue=function(a){return this.publishValue(a).refCount()},Qb.replay=function(a,b,c,d){return a?this.multicast(function(){return new qc(b,c,d)},a):this.multicast(new qc(b,c,d))},Qb.shareReplay=function(a,b,c){return this.replay(null,a,b,c).refCount()};var ec=J.ConnectableObservable=function(a){function b(b,c){function d(a){return e.subject.subscribe(a)}var e={subject:c,source:b.asObservable(),hasSubscription:!1,subscription:null};this.connect=function(){return e.hasSubscription||(e.hasSubscription=!0,e.subscription=new pb(e.source.subscribe(e.subject),sb(function(){e.hasSubscription=!1}))),e.subscription},a.call(this,d)}return ib(b,a),b.prototype.connect=function(){return this.connect()},b.prototype.refCount=function(){var a=null,b=0,c=this;return new jc(function(d){var e,f;return b++,e=1===b,f=c.subscribe(d),e&&(a=c.connect()),sb(function(){f.dispose(),b--,0===b&&a.dispose()})})},b}(Tb),fc=Tb.interval=function(a,b){return b||(b=Eb),z(a,a,b)},gc=Tb.timer=function(b,c,d){var e;return d||(d=Eb),"number"==typeof c?e=c:"object"==typeof c&&"now"in c&&(d=c),e===a?y(b,d):z(b,e,d)};Qb.delay=function(a,b){b||(b=Eb);var c=this;return new jc(function(d){var e,f=!1,g=new wb,h=null,i=[],j=!1;return e=c.materialize().timestamp(b).subscribe(function(c){var e,k;"E"===c.value.kind?(i=[],i.push(c),h=c.value.exception,k=!j):(i.push({value:c.value,timestamp:c.timestamp+a}),k=!f,f=!0),k&&(null!==h?d.onError(h):(e=new vb,g.setDisposable(e),e.setDisposable(b.scheduleRecursiveWithRelative(a,function(a){var c,e,g,k;if(null===h){j=!0;do g=null,i.length>0&&i[0].timestamp-b.now()<=0&&(g=i.shift().value),null!==g&&g.accept(d);while(null!==g);k=!1,e=0,i.length>0?(k=!0,e=Math.max(0,i[0].timestamp-b.now())):f=!1,c=h,j=!1,null!==c?d.onError(c):k&&a(e)}}))))}),new pb(e,g)})},Qb.throttle=function(a,b){b||(b=Eb);return this.throttleWithSelector(function(){return gc(a,b)})},Qb.timeInterval=function(a){var b=this;return a||(a=Eb),Vb(function(){var c=a.now();return b.select(function(b){var d=a.now(),e=d-c;return c=d,{value:b,interval:e}})})},Qb.timestamp=function(a){return a||(a=Eb),this.select(function(b){return{value:b,timestamp:a.now()}})},Qb.sample=function(a,b){return b||(b=Eb),"number"==typeof a?A(this,fc(a,b)):A(this,a)},Qb.timeout=function(a,b,c){var d,e=this;return b||(b=$b(new Error("Timeout"))),c||(c=Eb),d=a instanceof Date?function(a,b){c.scheduleWithAbsolute(a,b)}:function(a,b){c.scheduleWithRelative(a,b)},new jc(function(c){var f,g=0,h=new vb,i=new wb,j=!1,k=new wb;return i.setDisposable(h),f=function(){var e=g;k.setDisposable(d(a,function(){j=g===e;var a=j;a&&i.setDisposable(b.subscribe(c))}))},f(),h.setDisposable(e.subscribe(function(a){var b=!j;b&&(g++,c.onNext(a),f())},function(a){var b=!j;b&&(g++,c.onError(a))},function(){var a=!j;a&&(g++,c.onCompleted())})),new pb(i,k)})},Tb.generateWithTime=function(a,b,c,d,e,f){return f||(f=Eb),new jc(function(g){var h,i,j=!0,k=!1,l=a;return f.scheduleRecursiveWithRelative(0,function(a){k&&g.onNext(h);try{j?j=!1:l=c(l),k=b(l),k&&(h=d(l),i=e(l))}catch(f){return g.onError(f),void 0}k?a(i):g.onCompleted()})})},Qb.delaySubscription=function(a,b){return b||(b=Eb),this.delayWithSelector(gc(a,b),function(){return Wb()})},Qb.delayWithSelector=function(a,b){var c,d,e=this;return"function"==typeof a?d=a:(c=a,d=b),new jc(function(a){var b=new pb,f=!1,g=function(){f&&0===b.length&&a.onCompleted()},h=new wb,i=function(){h.setDisposable(e.subscribe(function(c){var e;try{e=d(c)}catch(f){return a.onError(f),void 0}var h=new vb;b.add(h),h.setDisposable(e.subscribe(function(){a.onNext(c),b.remove(h),g()},a.onError.bind(a),function(){a.onNext(c),b.remove(h),g()}))},a.onError.bind(a),function(){f=!0,h.dispose(),g()}))};return c?h.setDisposable(c.subscribe(function(){i()},a.onError.bind(a),function(){i()})):i(),new pb(h,b)})},Qb.timeoutWithSelector=function(a,b,c){if(1===arguments.length){b=a;var a=Yb()}c||(c=$b(new Error("Timeout")));var d=this;return new jc(function(e){var f=new wb,g=new wb,h=new vb;f.setDisposable(h);var i=0,j=!1,k=function(a){var b=i,d=function(){return i===b},h=new vb;g.setDisposable(h),h.setDisposable(a.subscribe(function(){d()&&f.setDisposable(c.subscribe(e)),h.dispose()},function(a){d()&&e.onError(a)},function(){d()&&f.setDisposable(c.subscribe(e))}))};k(a);var l=function(){var a=!j;return a&&i++,a};return h.setDisposable(d.subscribe(function(a){if(l()){e.onNext(a);var c;try{c=b(a)}catch(d){return e.onError(d),void 0}k(c)}},function(a){l()&&e.onError(a)},function(){l()&&e.onCompleted()})),new pb(f,g)})},Qb.throttleWithSelector=function(a){var b=this;return new jc(function(c){var d,e=!1,f=new wb,g=0,h=b.subscribe(function(b){var h;try{h=a(b)}catch(i){return c.onError(i),void 0}e=!0,d=b,g++;var j=g,k=new vb;f.setDisposable(k),k.setDisposable(h.subscribe(function(){e&&g===j&&c.onNext(d),e=!1,k.dispose()},c.onError.bind(c),function(){e&&g===j&&c.onNext(d),e=!1,k.dispose()}))},function(a){f.dispose(),c.onError(a),e=!1,g++},function(){f.dispose(),e&&c.onNext(d),c.onCompleted(),e=!1,g++});return new pb(h,f)})},Qb.skipLastWithTime=function(a,b){b||(b=Eb);var c=this;return new jc(function(d){var e=[];return c.subscribe(function(c){var f=b.now();for(e.push({interval:f,value:c});e.length>0&&f-e[0].interval>=a;)d.onNext(e.shift().value)},d.onError.bind(d),function(){for(var c=b.now();e.length>0&&c-e[0].interval>=a;)d.onNext(e.shift().value);d.onCompleted()})})},Qb.takeLastWithTime=function(a,b,c){return this.takeLastBufferWithTime(a,b).selectMany(function(a){return Xb(a,c)})},Qb.takeLastBufferWithTime=function(a,b){var c=this;return b||(b=Eb),new jc(function(d){var e=[];return c.subscribe(function(c){var d=b.now();for(e.push({interval:d,value:c});e.length>0&&d-e[0].interval>=a;)e.shift()},d.onError.bind(d),function(){for(var c=b.now(),f=[];e.length>0;){var g=e.shift();c-g.interval<=a&&f.push(g.value)}d.onNext(f),d.onCompleted()})})},Qb.takeWithTime=function(a,b){var c=this;return b||(b=Eb),new jc(function(d){var e=b.scheduleWithRelative(a,function(){d.onCompleted()});return new pb(e,c.subscribe(d))})},Qb.skipWithTime=function(a,b){var c=this;return b||(b=Eb),new jc(function(d){var e=!1,f=b.scheduleWithRelative(a,function(){e=!0}),g=c.subscribe(function(a){e&&d.onNext(a)},d.onError.bind(d),d.onCompleted.bind(d));return new pb(f,g)})},Qb.skipUntilWithTime=function(a,b){b||(b=Eb);var c=this;return new jc(function(d){var e=!1,f=b.scheduleWithAbsolute(a,function(){e=!0}),g=c.subscribe(function(a){e&&d.onNext(a)},d.onError.bind(d),d.onCompleted.bind(d));return new pb(f,g)})},Qb.takeUntilWithTime=function(a,b){b||(b=Eb);var c=this;return new jc(function(d){return new pb(b.scheduleWithAbsolute(a,function(){d.onCompleted()}),c.subscribe(d))})},Qb.pausable=function(a){var b=this;return new jc(function(c){var d=b.publish(),e=d.subscribe(c),f=tb,g=a.distinctUntilChanged().subscribe(function(a){a?f=d.connect():(f.dispose(),f=tb)});return new pb(e,f,g)})},Qb.pausableBuffered=function(a){var b=this;return new jc(function(c){var d=[],e=!0,f=B(b,a.distinctUntilChanged(),function(a,b){return{data:a,shouldFire:b}}).subscribe(function(a){if(a.shouldFire&&e&&c.onNext(a.data),a.shouldFire&&!e){for(;d.length>0;)c.onNext(d.shift());e=!0}else a.shouldFire||e?!a.shouldFire&&e&&(e=!1):d.push(a.data)},c.onError.bind(c),c.onCompleted.bind(c));return a.onNext(!1),f})},Qb.controlled=function(a){return null==a&&(a=!0),new hc(this,a)};var hc=function(a){function b(a){return this.source.subscribe(a)}function c(c,d){a.call(this,b),this.subject=new ic(d),this.source=c.multicast(this.subject).refCount()}return ib(c,a),c.prototype.request=function(a){return null==a&&(a=-1),this.subject.request(a)},c}(Tb),ic=J.ControlledSubject=function(a){function b(a){return this.subject.subscribe(a)}function c(c){null==c&&(c=!0),a.call(this,b),this.subject=new mc,this.enableQueue=c,this.queue=c?[]:null,this.requestedCount=0,this.requestedDisposable=tb,this.error=null,this.hasFailed=!1,this.hasCompleted=!1,this.controlledDisposable=tb}return ib(c,a),jb(c.prototype,Ob,{onCompleted:function(){h.call(this),this.hasCompleted=!0,this.enableQueue&&0!==this.queue.length||this.subject.onCompleted()},onError:function(a){h.call(this),this.hasFailed=!0,this.error=a,this.enableQueue&&0!==this.queue.length||this.subject.onError(a)},onNext:function(a){h.call(this);var b=!1;0===this.requestedCount?this.enableQueue&&this.queue.push(a):(-1!==this.requestedCount&&0===this.requestedCount--&&this.disposeCurrentRequest(),b=!0),b&&this.subject.onNext(a)},_processRequest:function(a){if(this.enableQueue){for(;this.queue.length>=a&&a>0;)this.subject.onNext(this.queue.shift()),a--;return 0!==this.queue.length?{numberOfItems:a,returnValue:!0}:{numberOfItems:a,returnValue:!1}}return this.hasFailed?(this.subject.onError(this.error),this.controlledDisposable.dispose(),this.controlledDisposable=tb):this.hasCompleted&&(this.subject.onCompleted(),this.controlledDisposable.dispose(),this.controlledDisposable=tb),{numberOfItems:a,returnValue:!1}},request:function(a){h.call(this),this.disposeCurrentRequest();var b=this,c=this._processRequest(a);return a=c.numberOfItems,c.returnValue?tb:(this.requestedCount=a,this.requestedDisposable=sb(function(){b.requestedCount=0}),this.requestedDisposable)},disposeCurrentRequest:function(){this.requestedDisposable.dispose(),this.requestedDisposable=tb},dispose:function(){this.isDisposed=!0,this.error=null,this.subject.dispose(),this.requestedDisposable.dispose()}}),c}(Tb),jc=J.AnonymousObservable=function(a){function b(a){return"undefined"==typeof a?a=tb:"function"==typeof a&&(a=sb(a)),a}function c(d){function e(a){var c=new kc(a);if(Cb.scheduleRequired())Cb.schedule(function(){try{c.setDisposable(b(d(c)))}catch(a){if(!c.fail(a))throw a}});else try{c.setDisposable(b(d(c)))}catch(e){if(!c.fail(e))throw e}return c}return this instanceof c?(a.call(this,e),void 0):new c(d)}return ib(c,a),c}(Tb),kc=function(a){function b(b){a.call(this),this.observer=b,this.m=new vb}ib(b,a);var c=b.prototype;return c.next=function(a){var b=!1;try{this.observer.onNext(a),b=!0}catch(c){throw c}finally{b||this.dispose()}},c.error=function(a){try{this.observer.onError(a)}catch(b){throw b}finally{this.dispose()}},c.completed=function(){try{this.observer.onCompleted()}catch(a){throw a}finally{this.dispose()}},c.setDisposable=function(a){this.m.setDisposable(a)},c.getDisposable=function(){return this.m.getDisposable()},c.disposable=function(a){return arguments.length?this.getDisposable():setDisposable(a)},c.dispose=function(){a.prototype.dispose.call(this),this.m.dispose()},b}(Rb),lc=function(a,b){this.subject=a,this.observer=b};lc.prototype.dispose=function(){if(!this.subject.isDisposed&&null!==this.observer){var a=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(a,1),this.observer=null}};var mc=J.Subject=function(a){function b(a){return h.call(this),this.isStopped?this.exception?(a.onError(this.exception),tb):(a.onCompleted(),tb):(this.observers.push(a),new lc(this,a))}function c(){a.call(this,b),this.isDisposed=!1,this.isStopped=!1,this.observers=[]}return ib(c,a),jb(c.prototype,Ob,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(h.call(this),!this.isStopped){var a=this.observers.slice(0);this.isStopped=!0;for(var b=0,c=a.length;c>b;b++)a[b].onCompleted();this.observers=[]}},onError:function(a){if(h.call(this),!this.isStopped){var b=this.observers.slice(0);this.isStopped=!0,this.exception=a;for(var c=0,d=b.length;d>c;c++)b[c].onError(a);this.observers=[]}},onNext:function(a){if(h.call(this),!this.isStopped)for(var b=this.observers.slice(0),c=0,d=b.length;d>c;c++)b[c].onNext(a)},dispose:function(){this.isDisposed=!0,this.observers=null}}),c.create=function(a,b){return new oc(a,b)},c}(Tb),nc=J.AsyncSubject=function(a){function b(a){if(h.call(this),!this.isStopped)return this.observers.push(a),new lc(this,a);var b=this.exception,c=this.hasValue,d=this.value;return b?a.onError(b):c?(a.onNext(d),a.onCompleted()):a.onCompleted(),tb}function c(){a.call(this,b),this.isDisposed=!1,this.isStopped=!1,this.value=null,this.hasValue=!1,this.observers=[],this.exception=null}return ib(c,a),jb(c.prototype,Ob,{hasObservers:function(){return h.call(this),this.observers.length>0},onCompleted:function(){var a,b,c;if(h.call(this),!this.isStopped){this.isStopped=!0;var d=this.observers.slice(0),e=this.value,f=this.hasValue;if(f)for(b=0,c=d.length;c>b;b++)a=d[b],a.onNext(e),a.onCompleted();else for(b=0,c=d.length;c>b;b++)d[b].onCompleted();this.observers=[]}},onError:function(a){if(h.call(this),!this.isStopped){var b=this.observers.slice(0);this.isStopped=!0,this.exception=a;for(var c=0,d=b.length;d>c;c++)b[c].onError(a);this.observers=[]}},onNext:function(a){h.call(this),this.isStopped||(this.value=a,this.hasValue=!0)},dispose:function(){this.isDisposed=!0,this.observers=null,this.exception=null,this.value=null}}),c}(Tb),oc=function(a){function b(a){return this.observable.subscribe(a)}function c(c,d){a.call(this,b),this.observer=c,this.observable=d}return ib(c,a),jb(c.prototype,Ob,{onCompleted:function(){this.observer.onCompleted()},onError:function(a){this.observer.onError(a)},onNext:function(a){this.observer.onNext(a)}}),c}(Tb),pc=J.BehaviorSubject=function(a){function b(a){if(h.call(this),!this.isStopped)return this.observers.push(a),a.onNext(this.value),new lc(this,a);var b=this.exception;return b?a.onError(b):a.onCompleted(),tb}function c(c){a.call(this,b),this.value=c,this.observers=[],this.isDisposed=!1,this.isStopped=!1,this.exception=null}return ib(c,a),jb(c.prototype,Ob,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(h.call(this),!this.isStopped){var a=this.observers.slice(0);this.isStopped=!0;for(var b=0,c=a.length;c>b;b++)a[b].onCompleted();this.observers=[]}},onError:function(a){if(h.call(this),!this.isStopped){var b=this.observers.slice(0);this.isStopped=!0,this.exception=a;for(var c=0,d=b.length;d>c;c++)b[c].onError(a);this.observers=[]}},onNext:function(a){if(h.call(this),!this.isStopped){this.value=a;for(var b=this.observers.slice(0),c=0,d=b.length;d>c;c++)b[c].onNext(a)}},dispose:function(){this.isDisposed=!0,this.observers=null,this.value=null,this.exception=null}}),c}(Tb),qc=J.ReplaySubject=function(a){function b(a,b){this.subject=a,this.observer=b}function c(a){var c=new Ub(this.scheduler,a),d=new b(this,c);h.call(this),this._trim(this.scheduler.now()),this.observers.push(c);for(var e=this.q.length,f=0,g=this.q.length;g>f;f++)c.onNext(this.q[f].value);return this.hasError?(e++,c.onError(this.error)):this.isStopped&&(e++,c.onCompleted()),c.ensureActive(e),d}function d(b,d,e){this.bufferSize=null==b?Number.MAX_VALUE:b,this.windowSize=null==d?Number.MAX_VALUE:d,this.scheduler=e||Cb,this.q=[],this.observers=[],this.isStopped=!1,this.isDisposed=!1,this.hasError=!1,this.error=null,a.call(this,c)}return b.prototype.dispose=function(){if(this.observer.dispose(),!this.subject.isDisposed){var a=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(a,1)}},ib(d,a),jb(d.prototype,Ob,{hasObservers:function(){return this.observers.length>0},_trim:function(a){for(;this.q.length>this.bufferSize;)this.q.shift();for(;this.q.length>0&&a-this.q[0].interval>this.windowSize;)this.q.shift()},onNext:function(a){var b;if(h.call(this),!this.isStopped){var c=this.scheduler.now();this.q.push({interval:c,value:a}),this._trim(c);for(var d=this.observers.slice(0),e=0,f=d.length;f>e;e++)b=d[e],b.onNext(a),b.ensureActive()}},onError:function(a){var b;if(h.call(this),!this.isStopped){this.isStopped=!0,this.error=a,this.hasError=!0;var c=this.scheduler.now();this._trim(c);for(var d=this.observers.slice(0),e=0,f=d.length;f>e;e++)b=d[e],b.onError(a),b.ensureActive();this.observers=[]}},onCompleted:function(){var a;if(h.call(this),!this.isStopped){this.isStopped=!0;var b=this.scheduler.now();this._trim(b);for(var c=this.observers.slice(0),d=0,e=c.length;e>d;d++)a=c[d],a.onCompleted(),a.ensureActive();this.observers=[]}},dispose:function(){this.isDisposed=!0,this.observers=null}}),d}(Tb);"function"==typeof define&&"object"==typeof define.amd&&define.amd?(D.Rx=J,define(function(){return J})):E&&F?G?(F.exports=J).Rx=J:E.Rx=J:D.Rx=J}).call(this); \ No newline at end of file diff --git a/rx.lite.js b/rx.lite.js index 74c3ee7d2..33419a391 100644 --- a/rx.lite.js +++ b/rx.lite.js @@ -4506,6 +4506,259 @@ return new CompositeDisposable(subscription, connection, pausable); }); }; + function combineLatestSource(source, subject, resultSelector) { + return new AnonymousObservable(function (observer) { + var n = 2, + hasValue = [false, false], + hasValueAll = false, + isDone = false, + values = new Array(n); + + function next(x, i) { + values[i] = x + var res; + hasValue[i] = true; + if (hasValueAll || (hasValueAll = hasValue.every(identity))) { + try { + res = resultSelector.apply(null, values); + } catch (ex) { + observer.onError(ex); + return; + } + observer.onNext(res); + } else if (isDone) { + observer.onCompleted(); + } + } + + return new CompositeDisposable( + source.subscribe( + function (x) { + next(x, 0); + }, + observer.onError.bind(observer), + function () { + isDone = true; + observer.onCompleted(); + }), + subject.subscribe( + function (x) { + next(x, 1); + }, + observer.onError.bind(observer)) + ); + }); + } + + /** + * Pauses the underlying observable sequence based upon the observable sequence which yields true/false, + * and yields the values that were buffered while paused. + * @example + * var pauser = new Rx.Subject(); + * var source = Rx.Observable.interval(100).pausableBuffered(pauser); + * @param {Observable} pauser The observable sequence used to pause the underlying sequence. + * @returns {Observable} The observable sequence which is paused based upon the pauser. + */ + observableProto.pausableBuffered = function (subject) { + var source = this; + return new AnonymousObservable(function (observer) { + var q = [], previous = true; + + var subscription = + combineLatestSource( + source, + subject.distinctUntilChanged(), + function (data, shouldFire) { + return { data: data, shouldFire: shouldFire }; + }) + .subscribe( + function (results) { + if (results.shouldFire && previous) { + observer.onNext(results.data); + } + if (results.shouldFire && !previous) { + while (q.length > 0) { + observer.onNext(q.shift()); + } + previous = true; + } else if (!results.shouldFire && !previous) { + q.push(results.data); + } else if (!results.shouldFire && previous) { + previous = false; + } + + }, + observer.onError.bind(observer), + observer.onCompleted.bind(observer) + ); + + subject.onNext(false); + + return subscription; + }); + }; + + /** + * Attaches a controller to the observable sequence with the ability to queue. + * @example + * var source = Rx.Observable.interval(100).controlled(); + * source.request(3); // Reads 3 values + * @param {Observable} pauser The observable sequence used to pause the underlying sequence. + * @returns {Observable} The observable sequence which is paused based upon the pauser. + */ + observableProto.controlled = function (enableQueue) { + if (enableQueue == null) { enableQueue = true; } + return new ControlledObservable(this, enableQueue); + }; + var ControlledObservable = (function (_super) { + + inherits(ControlledObservable, _super); + + function subscribe (observer) { + return this.source.subscribe(observer); + } + + function ControlledObservable (source, enableQueue) { + _super.call(this, subscribe); + this.subject = new ControlledSubject(enableQueue); + this.source = source.multicast(this.subject).refCount(); + } + + ControlledObservable.prototype.request = function (numberOfItems) { + if (numberOfItems == null) { numberOfItems = -1; } + return this.subject.request(numberOfItems); + }; + + return ControlledObservable; + + }(Observable)); + + var ControlledSubject = Rx.ControlledSubject = (function (_super) { + + function subscribe (observer) { + return this.subject.subscribe(observer); + } + + inherits(ControlledSubject, _super); + + function ControlledSubject(enableQueue) { + if (enableQueue == null) { + enableQueue = true; + } + + _super.call(this, subscribe); + this.subject = new Subject(); + this.enableQueue = enableQueue; + this.queue = enableQueue ? [] : null; + this.requestedCount = 0; + this.requestedDisposable = disposableEmpty; + this.error = null; + this.hasFailed = false; + this.hasCompleted = false; + this.controlledDisposable = disposableEmpty; + } + + addProperties(ControlledSubject.prototype, Observer, { + onCompleted: function () { + checkDisposed.call(this); + this.hasCompleted = true; + + if (!this.enableQueue || this.queue.length === 0) { + this.subject.onCompleted(); + } + }, + onError: function (error) { + checkDisposed.call(this); + this.hasFailed = true; + this.error = error; + + if (!this.enableQueue || this.queue.length === 0) { + this.subject.onError(error); + } + }, + onNext: function (value) { + checkDisposed.call(this); + var hasRequested = false; + + if (this.requestedCount === 0) { + if (this.enableQueue) { + this.queue.push(value); + } + } else { + if (this.requestedCount !== -1) { + if (this.requestedCount-- === 0) { + this.disposeCurrentRequest(); + } + } + hasRequested = true; + } + + if (hasRequested) { + this.subject.onNext(value); + } + }, + _processRequest: function (numberOfItems) { + if (this.enableQueue) { + //console.log('queue length', this.queue.length); + + while (this.queue.length >= numberOfItems && numberOfItems > 0) { + //console.log('number of items', numberOfItems); + this.subject.onNext(this.queue.shift()); + numberOfItems--; + } + + if (this.queue.length !== 0) { + return { numberOfItems: numberOfItems, returnValue: true }; + } else { + return { numberOfItems: numberOfItems, returnValue: false }; + } + } + + if (this.hasFailed) { + this.subject.onError(this.error); + this.controlledDisposable.dispose(); + this.controlledDisposable = disposableEmpty; + } else if (this.hasCompleted) { + this.subject.onCompleted(); + this.controlledDisposable.dispose(); + this.controlledDisposable = disposableEmpty; + } + + return { numberOfItems: numberOfItems, returnValue: false }; + }, + request: function (number) { + checkDisposed.call(this); + this.disposeCurrentRequest(); + var self = this, + r = this._processRequest(number); + + number = r.numberOfItems; + if (!r.returnValue) { + this.requestedCount = number; + this.requestedDisposable = disposableCreate(function () { + self.requestedCount = 0; + }); + + return this.requestedDisposable + } else { + return disposableEmpty; + } + }, + disposeCurrentRequest: function () { + this.requestedDisposable.dispose(); + this.requestedDisposable = disposableEmpty; + }, + + dispose: function () { + this.isDisposed = true; + this.error = null; + this.subject.dispose(); + this.requestedDisposable.dispose(); + } + }); + + return ControlledSubject; + }(Observable)); var AnonymousObservable = Rx.AnonymousObservable = (function (_super) { inherits(AnonymousObservable, _super); diff --git a/rx.lite.min.js b/rx.lite.min.js index 6eb7c0d23..6831693b0 100644 --- a/rx.lite.min.js +++ b/rx.lite.min.js @@ -1,2 +1,2 @@ -(function(a){function b(){}function c(a){return a}function d(a,b){return eb(a,b)}function e(a,b){return a-b}function f(a){throw a}function g(a){return"function"==typeof a.then}function h(){if(this.isDisposed)throw new Error(L)}function i(a){var b=typeof a;return a&&("function"==b||"object"==b)||!1}function j(a){var b=[];if(!i(a))return b;db.nonEnumArgs&&a.length&&n(a)&&(a=fb.call(a));var c=db.enumPrototypes&&"function"==typeof a,d=db.enumErrorProps&&(a===Z||a instanceof Error);for(var e in a)c&&"prototype"==e||d&&("message"==e||"name"==e)||b.push(e);if(db.nonEnumShadows&&a!==$){var f=a.constructor,g=-1,h=bb.length;if(a===(f&&f.prototype))var j=a===stringProto?V:a===Z?Q:W.call(a),k=cb[j];for(;++g-1:void 0});return c.pop(),d.pop(),result}function q(a,b){return 1===a.length&&Array.isArray(a[b])?a[b]:fb.call(a)}function r(a,b){for(var c=new Array(a),d=0;a>d;d++)c[d]=b();return c}function s(a,b){return new dc(function(c){var d=new rb,e=new sb;return e.setDisposable(d),d.setDisposable(a.subscribe(c.onNext.bind(c),function(a){var d,f;try{f=b(a)}catch(g){return c.onError(g),void 0}d=new rb,e.setDisposable(d),d.setDisposable(f.subscribe(c))},c.onCompleted.bind(c))),e})}function t(a,b){var c=this;return new dc(function(d){var e=0,f=a.length;return c.subscribe(function(c){if(f>e){var g,h=a[e++];try{g=b(c,h)}catch(i){return d.onError(i),void 0}d.onNext(g)}else d.onCompleted()},d.onError.bind(d),d.onCompleted.bind(d))})}function u(a){return this.select(function(b,c){var d=a(b,c);return g(d)?_b(d):d}).mergeObservable()}function v(a,b,c){return a.addListener?(a.addListener(b,c),ob(function(){a.removeListener(b,c)})):a.addEventListener?(a.addEventListener(b,c,!1),ob(function(){a.removeEventListener(b,c,!1)})):void 0}function w(a,b,c){var d=new lb;if(a&&a.length)for(var e=0,f=a.length;f>e;e++)d.add(w(a[e],b,c));else a&&d.add(v(a,b,c));return d}function x(a,b){var c=wb(a);return new dc(function(a){return b.scheduleWithRelative(c,function(){a.onNext(0),a.onCompleted()})})}function y(a,b,c){return a===b?new dc(function(a){return c.schedulePeriodicWithState(0,b,function(b){return a.onNext(b),b+1})}):Rb(function(){return observableTimerDateAndPeriod(c.now()+a,b,c)})}function z(a,b){return new dc(function(c){function d(){g&&(g=!1,c.onNext(f)),e&&c.onCompleted()}var e,f,g;return new lb(a.subscribe(function(a){g=!0,f=a},c.onError.bind(c),function(){e=!0}),b.subscribe(d,c.onError.bind(c),d))})}var A={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},B=A[typeof window]&&window||this,C=A[typeof exports]&&exports&&!exports.nodeType&&exports,D=A[typeof module]&&module&&!module.nodeType&&module,E=D&&D.exports===C&&C,F=A[typeof global]&&global;!F||F.global!==F&&F.window!==F||(B=F);var G,H={internals:{},config:{}},I=Date.now,J="Sequence contains no elements.",K="Argument out of range",L="Object has been disposed",M="[object Arguments]",N="[object Array]",O="[object Boolean]",P="[object Date]",Q="[object Error]",R="[object Function]",S="[object Number]",T="[object Object]",U="[object RegExp]",V="[object String]",W=Object.prototype.toString,X=Object.prototype.hasOwnProperty,Y=W.call(arguments)==M,Z=Error.prototype,$=Object.prototype,_=$.propertyIsEnumerable;try{G=!(W.call(document)==T&&!({toString:0}+""))}catch(ab){G=!0}var bb=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],cb={};cb[N]=cb[P]=cb[S]={constructor:!0,toLocaleString:!0,toString:!0,valueOf:!0},cb[O]=cb[V]={constructor:!0,toString:!0,valueOf:!0},cb[Q]=cb[R]=cb[U]={constructor:!0,toString:!0},cb[T]={constructor:!0};var db={};!function(){var a=function(){this.x=1},b=[];a.prototype={valueOf:1,y:1};for(var c in new a)b.push(c);for(c in arguments);db.enumErrorProps=_.call(Z,"message")||_.call(Z,"name"),db.enumPrototypes=_.call(a,"prototype"),db.nonEnumArgs=0!=c,db.nonEnumShadows=!/valueOf/.test(b)}(1),Y||(n=function(a){return a&&"object"==typeof a?X.call(a,"callee"):!1}),o(/x/)&&(o=function(a){return"function"==typeof a&&W.call(a)==R});var eb=H.internals.isEqual=function(a,b){return p(a,b,[],[])},fb=Array.prototype.slice,gb=({}.hasOwnProperty,this.inherits=H.internals.inherits=function(a,b){function c(){this.constructor=a}c.prototype=b.prototype,a.prototype=new c}),hb=H.internals.addProperties=function(a){for(var b=fb.call(arguments,1),c=0,d=b.length;d>c;c++){var e=b[c];for(var f in e)a[f]=e[f]}},ib=(H.internals.addRef=function(a,b){return new dc(function(c){return new lb(b.getDisposable(),a.subscribe(c))})},function(a,b){this.id=a,this.value=b});ib.prototype.compareTo=function(a){var b=this.value.compareTo(a.value);return 0===b&&(b=this.id-a.id),b};var jb=H.internals.PriorityQueue=function(a){this.items=new Array(a),this.length=0},kb=jb.prototype;kb.isHigherPriority=function(a,b){return this.items[a].compareTo(this.items[b])<0},kb.percolate=function(a){if(!(a>=this.length||0>a)){var b=a-1>>1;if(!(0>b||b===a)&&this.isHigherPriority(a,b)){var c=this.items[a];this.items[a]=this.items[b],this.items[b]=c,this.percolate(b)}}},kb.heapify=function(b){if(b===a&&(b=0),!(b>=this.length||0>b)){var c=2*b+1,d=2*b+2,e=b;if(cb;b++)a[b].dispose()}},mb.clear=function(){var a=this.disposables.slice(0);this.disposables=[],this.length=0;for(var b=0,c=a.length;c>b;b++)a[b].dispose()},mb.contains=function(a){return-1!==this.disposables.indexOf(a)},mb.toArray=function(){return this.disposables.slice(0)};var nb=H.Disposable=function(a){this.isDisposed=!1,this.action=a||b};nb.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var ob=nb.create=function(a){return new nb(a)},pb=nb.empty={dispose:b},qb=function(){function a(a){this.isSingle=a,this.isDisposed=!1,this.current=null}var b=a.prototype;return b.getDisposable=function(){return this.current},b.setDisposable=function(a){if(this.current&&this.isSingle)throw new Error("Disposable has already been assigned");var b,c=this.isDisposed;c||(b=this.current,this.current=a),b&&b.dispose(),c&&a&&a.dispose()},b.dispose=function(){var a;this.isDisposed||(this.isDisposed=!0,a=this.current,this.current=null),a&&a.dispose()},a}(),rb=H.SingleAssignmentDisposable=function(a){function b(){a.call(this,!0)}return gb(b,a),b}(qb),sb=H.SerialDisposable=function(a){function b(){a.call(this,!1)}return gb(b,a),b}(qb),tb=(H.RefCountDisposable=function(){function a(a){this.disposable=a,this.disposable.count++,this.isInnerDisposed=!1}function b(a){this.underlyingDisposable=a,this.isDisposed=!1,this.isPrimaryDisposed=!1,this.count=0}return a.prototype.dispose=function(){this.disposable.isDisposed||this.isInnerDisposed||(this.isInnerDisposed=!0,this.disposable.count--,0===this.disposable.count&&this.disposable.isPrimaryDisposed&&(this.disposable.isDisposed=!0,this.disposable.underlyingDisposable.dispose()))},b.prototype.dispose=function(){this.isDisposed||this.isPrimaryDisposed||(this.isPrimaryDisposed=!0,0===this.count&&(this.isDisposed=!0,this.underlyingDisposable.dispose()))},b.prototype.getDisposable=function(){return this.isDisposed?pb:new a(this)},b}(),H.internals.ScheduledItem=function(a,b,c,d,f){this.scheduler=a,this.state=b,this.action=c,this.dueTime=d,this.comparer=f||e,this.disposable=new rb});tb.prototype.invoke=function(){this.disposable.setDisposable(this.invokeCore())},tb.prototype.compareTo=function(a){return this.comparer(this.dueTime,a.dueTime)},tb.prototype.isCancelled=function(){return this.disposable.isDisposed},tb.prototype.invokeCore=function(){return this.action(this.scheduler,this.state)};var ub,vb=H.Scheduler=function(){function a(a,b,c,d){this.now=a,this._schedule=b,this._scheduleRelative=c,this._scheduleAbsolute=d}function b(a,b){var c=b.first,d=b.second,e=new lb,f=function(b){d(b,function(b){var c=!1,d=!1,g=a.scheduleWithState(b,function(a,b){return c?e.remove(g):d=!0,f(b),pb});d||(e.add(g),c=!0)})};return f(c),e}function c(a,b,c){var d=b.first,e=b.second,f=new lb,g=function(b){e(b,function(b,d){var e=!1,h=!1,i=a[c].call(a,b,d,function(a,b){return e?f.remove(i):h=!0,g(b),pb});h||(f.add(i),e=!0)})};return g(d),f}function d(a,b){return b(),pb}var e=a.prototype;return e.schedulePeriodic=function(a,b){return this.schedulePeriodicWithState(null,a,function(){b()})},e.schedulePeriodicWithState=function(a,b,c){var d=a,e=setInterval(function(){d=c(d)},b);return ob(function(){clearInterval(e)})},e.schedule=function(a){return this._schedule(a,d)},e.scheduleWithState=function(a,b){return this._schedule(a,b)},e.scheduleWithRelative=function(a,b){return this._scheduleRelative(b,a,d)},e.scheduleWithRelativeAndState=function(a,b,c){return this._scheduleRelative(a,b,c)},e.scheduleWithAbsolute=function(a,b){return this._scheduleAbsolute(b,a,d)},e.scheduleWithAbsoluteAndState=function(a,b,c){return this._scheduleAbsolute(a,b,c)},e.scheduleRecursive=function(a){return this.scheduleRecursiveWithState(a,function(a,b){a(function(){b(a)})})},e.scheduleRecursiveWithState=function(a,c){return this.scheduleWithState({first:a,second:c},function(a,c){return b(a,c)})},e.scheduleRecursiveWithRelative=function(a,b){return this.scheduleRecursiveWithRelativeAndState(b,a,function(a,b){a(function(c){b(a,c)})})},e.scheduleRecursiveWithRelativeAndState=function(a,b,d){return this._scheduleRelative({first:a,second:d},b,function(a,b){return c(a,b,"scheduleWithRelativeAndState")})},e.scheduleRecursiveWithAbsolute=function(a,b){return this.scheduleRecursiveWithAbsoluteAndState(b,a,function(a,b){a(function(c){b(a,c)})})},e.scheduleRecursiveWithAbsoluteAndState=function(a,b,d){return this._scheduleAbsolute({first:a,second:d},b,function(a,b){return c(a,b,"scheduleWithAbsoluteAndState")})},a.now=I,a.normalize=function(a){return 0>a&&(a=0),a},a}(),wb=vb.normalize,xb=vb.immediate=function(){function a(a,b){return b(this,a)}function b(a,b,c){for(var d=wb(d);d-this.now()>0;);return c(this,a)}function c(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}return new vb(I,a,b,c)}(),yb=vb.currentThread=function(){function a(a){for(var b;a.length>0;)if(b=a.dequeue(),!b.isCancelled()){for(;b.dueTime-vb.now()>0;);b.isCancelled()||b.invoke()}}function b(a,b){return this.scheduleWithRelativeAndState(a,0,b)}function c(b,c,d){var f=this.now()+vb.normalize(c),g=new tb(this,b,d,f);if(e)e.enqueue(g);else{e=new jb(4),e.enqueue(g);try{a(e)}catch(h){throw h}finally{e=null}}return g.disposable}function d(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}var e,f=new vb(I,b,c,d);return f.scheduleRequired=function(){return null===e},f.ensureTrampoline=function(a){return null===e?this.schedule(a):a()},f}(),zb=(H.internals.SchedulePeriodicRecursive=function(){function a(a,b){b(0,this._period);try{this._state=this._action(this._state)}catch(c){throw this._cancel.dispose(),c}}function b(a,b,c,d){this._scheduler=a,this._state=b,this._period=c,this._action=d}return b.prototype.start=function(){var b=new rb;return this._cancel=b,b.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,a.bind(this))),b},b}(),b);!function(){function a(){if(!B.postMessage||B.importScripts)return!1;var a=!1,b=B.onmessage;return B.onmessage=function(){a=!0},B.postMessage("","*"),B.onmessage=b,a}function b(a){if("string"==typeof a.data&&a.data.substring(0,f.length)===f){var b=a.data.substring(f.length),c=g[b];c(),delete g[b]}}var c=RegExp("^"+String(W).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),d="function"==typeof(d=F&&E&&F.setImmediate)&&!c.test(d)&&d,e="function"==typeof(e=F&&E&&F.clearImmediate)&&!c.test(e)&&e;if("undefined"!=typeof process&&"[object process]"==={}.toString.call(process))ub=process.nextTick;else if("function"==typeof d)ub=d,zb=e;else if(a()){var f="ms.rx.schedule"+Math.random(),g={},h=0;B.addEventListener?B.addEventListener("message",b,!1):B.attachEvent("onmessage",b,!1),ub=function(a){var b=h++;g[b]=a,B.postMessage(f+b,"*")}}else if(B.MessageChannel){var i=new B.MessageChannel,j={},k=0;i.port1.onmessage=function(a){var b=a.data,c=j[b];c(),delete j[b]},ub=function(a){var b=k++;j[b]=a,i.port2.postMessage(b)}}else"document"in B&&"onreadystatechange"in B.document.createElement("script")?ub=function(a){var b=B.document.createElement("script");b.onreadystatechange=function(){a(),b.onreadystatechange=null,b.parentNode.removeChild(b),b=null},B.document.documentElement.appendChild(b)}:(ub=function(a){return setTimeout(a,0)},zb=clearTimeout)}();var Ab=vb.timeout=function(){function a(a,b){var c=this,d=new rb,e=ub(function(){d.isDisposed||d.setDisposable(b(c,a))});return new lb(d,ob(function(){zb(e)}))}function b(a,b,c){var d=this,e=vb.normalize(b);if(0===e)return d.scheduleWithState(a,c);var f=new rb,g=setTimeout(function(){f.isDisposed||f.setDisposable(c(d,a))},e);return new lb(f,ob(function(){clearTimeout(g)}))}function c(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}return new vb(I,a,b,c)}(),Bb=H.Notification=function(){function a(a,b){this.hasValue=null==b?!1:b,this.kind=a}var b=a.prototype;return b.accept=function(a,b,c){return 1===arguments.length&&"object"==typeof a?this._acceptObservable(a):this._accept(a,b,c)},b.toObservable=function(a){var b=this;return a||(a=xb),new dc(function(c){return a.schedule(function(){b._acceptObservable(c),"N"===b.kind&&c.onCompleted()})})},a}(),Cb=Bb.createOnNext=function(){function a(a){return a(this.value)}function b(a){return a.onNext(this.value)}function c(){return"OnNext("+this.value+")"}return function(d){var e=new Bb("N",!0);return e.value=d,e._accept=a,e._acceptObservable=b,e.toString=c,e}}(),Db=Bb.createOnError=function(){function a(a,b){return b(this.exception)}function b(a){return a.onError(this.exception)}function c(){return"OnError("+this.exception+")"}return function(d){var e=new Bb("E");return e.exception=d,e._accept=a,e._acceptObservable=b,e.toString=c,e}}(),Eb=Bb.createOnCompleted=function(){function a(a,b,c){return c()}function b(a){return a.onCompleted()}function c(){return"OnCompleted()"}return function(){var d=new Bb("C");return d._accept=a,d._acceptObservable=b,d.toString=c,d}}(),Fb=H.internals.Enumerator=function(a,b){this.moveNext=a,this.getCurrent=b},Gb=Fb.create=function(a,b){var c=!1;return new Fb(function(){if(c)return!1;var b=a();return b||(c=!0),b},function(){return b()})},Hb=H.internals.Enumerable=function(a){this.getEnumerator=a};Hb.prototype.concat=function(){var a=this;return new dc(function(b){var c,d=a.getEnumerator(),e=new sb,f=xb.scheduleRecursive(function(a){var f,g;if(!c){try{g=d.moveNext(),g&&(f=d.getCurrent())}catch(h){return b.onError(h),void 0}if(!g)return b.onCompleted(),void 0;var i=new rb;e.setDisposable(i),i.setDisposable(f.subscribe(b.onNext.bind(b),b.onError.bind(b),function(){a()}))}});return new lb(e,f,ob(function(){c=!0}))})},Hb.prototype.catchException=function(){var a=this;return new dc(function(b){var c,d,e=a.getEnumerator(),f=new sb,g=xb.scheduleRecursive(function(a){var g,h;if(!c){try{h=e.moveNext(),h&&(g=e.getCurrent())}catch(i){return b.onError(i),void 0}if(!h)return d?b.onError(d):b.onCompleted(),void 0;var j=new rb;f.setDisposable(j),j.setDisposable(g.subscribe(b.onNext.bind(b),function(b){d=b,a()},b.onCompleted.bind(b)))}});return new lb(f,g,ob(function(){c=!0}))})};var Ib=Hb.repeat=function(a,b){return 1===arguments.length&&(b=-1),new Hb(function(){var c,d=b;return Gb(function(){return 0===d?!1:(d>0&&d--,c=a,!0)},function(){return c})})},Jb=Hb.forEach=function(a,b,d){return b||(b=c),new Hb(function(){var c,e=-1;return Gb(function(){return++e0&&(a=!this.isAcquired,this.isAcquired=!0),a&&this.disposable.setDisposable(this.scheduler.scheduleRecursive(function(a){var c;if(!(b.queue.length>0))return b.isAcquired=!1,void 0;c=b.queue.shift();try{c()}catch(d){throw b.queue=[],b.hasFaulted=!0,d}a()}))},b.prototype.dispose=function(){a.prototype.dispose.call(this),this.disposable.dispose()},b}(Nb);Pb.create=Pb.createWithDisposable=function(a){return new dc(a)};var Rb=Pb.defer=function(a){return new dc(function(b){var c;try{c=a()}catch(d){return Wb(d).subscribe(b)}return c.subscribe(b)})},Sb=Pb.empty=function(a){return a||(a=xb),new dc(function(b){return a.schedule(function(){b.onCompleted()})})},Tb=Pb.fromArray=function(a,b){return b||(b=yb),new dc(function(c){var d=0;return b.scheduleRecursive(function(b){dc?(d.onNext(a+c),e(c+1)):d.onCompleted()})})},Pb.repeat=function(a,b,c){return c||(c=yb),null==b&&(b=-1),Vb(a,c).repeat(b)};var Vb=Pb["return"]=Pb.returnValue=function(a,b){return b||(b=xb),new dc(function(c){return b.schedule(function(){c.onNext(a),c.onCompleted()})})},Wb=Pb["throw"]=Pb.throwException=function(a,b){return b||(b=xb),new dc(function(c){return b.schedule(function(){c.onError(a)})})};Mb["catch"]=Mb.catchException=function(a){return"function"==typeof a?s(this,a):Xb([this,a])};var Xb=Pb.catchException=Pb["catch"]=function(){var a=q(arguments,0);return Jb(a).catchException()};Mb.combineLatest=function(){var a=fb.call(arguments);return Array.isArray(a[0])?a[0].unshift(this):a.unshift(this),Yb.apply(this,a)};var Yb=Pb.combineLatest=function(){var a=fb.call(arguments),b=a.pop();return Array.isArray(a[0])&&(a=a[0]),new dc(function(d){function e(a){var e;if(i[a]=!0,j||(j=i.every(c))){try{e=b.apply(null,l)}catch(f){return d.onError(f),void 0}d.onNext(e)}else k.filter(function(b,c){return c!==a}).every(c)&&d.onCompleted()}function f(a){k[a]=!0,k.every(c)&&d.onCompleted()}for(var g=function(){return!1},h=a.length,i=r(h,g),j=!1,k=r(h,g),l=new Array(h),m=new Array(h),n=0;h>n;n++)!function(b){m[b]=new rb,m[b].setDisposable(a[b].subscribe(function(a){l[b]=a,e(b)},d.onError.bind(d),function(){f(b)}))}(n);return new lb(m)})};Mb.concat=function(){var a=fb.call(arguments,0);return a.unshift(this),Zb.apply(this,a)};var Zb=Pb.concat=function(){var a=q(arguments,0);return Jb(a).concat()};Mb.concatObservable=Mb.concatAll=function(){return this.merge(1)},Mb.merge=function(a){if("number"!=typeof a)return $b(this,a);var b=this;return new dc(function(c){var d=0,e=new lb,f=!1,h=[],i=function(a){var b=new rb;e.add(b),g(a)&&(a=_b(a)),b.setDisposable(a.subscribe(c.onNext.bind(c),c.onError.bind(c),function(){var a;e.remove(b),h.length>0?(a=h.shift(),i(a)):(d--,f&&0===d&&c.onCompleted())}))};return e.add(b.subscribe(function(b){a>d?(d++,i(b)):h.push(b)},c.onError.bind(c),function(){f=!0,0===d&&c.onCompleted()})),e})};var $b=Pb.merge=function(){var a,b;return arguments[0]?arguments[0].now?(a=arguments[0],b=fb.call(arguments,1)):(a=xb,b=fb.call(arguments,0)):(a=xb,b=fb.call(arguments,1)),Array.isArray(b[0])&&(b=b[0]),Tb(b,a).mergeObservable()};Mb.mergeObservable=Mb.mergeAll=function(){var a=this;return new dc(function(b){var c=new lb,d=!1,e=new rb;return c.add(e),e.setDisposable(a.subscribe(function(a){var e=new rb;c.add(e),g(a)&&(a=_b(a)),e.setDisposable(a.subscribe(function(a){b.onNext(a)},b.onError.bind(b),function(){c.remove(e),d&&1===c.length&&b.onCompleted()}))},b.onError.bind(b),function(){d=!0,1===c.length&&b.onCompleted()})),c})},Mb.skipUntil=function(a){var b=this;return new dc(function(c){var d=!1,e=new lb(b.subscribe(function(a){d&&c.onNext(a)},c.onError.bind(c),function(){d&&c.onCompleted()})),f=new rb;return e.add(f),f.setDisposable(a.subscribe(function(){d=!0,f.dispose()},c.onError.bind(c),function(){f.dispose()})),e})},Mb["switch"]=Mb.switchLatest=function(){var a=this;return new dc(function(b){var c=!1,d=new sb,e=!1,f=0,h=a.subscribe(function(a){var h=new rb,i=++f;c=!0,d.setDisposable(h),g(a)&&(a=_b(a)),h.setDisposable(a.subscribe(function(a){f===i&&b.onNext(a)},function(a){f===i&&b.onError(a)},function(){f===i&&(c=!1,e&&b.onCompleted())}))},b.onError.bind(b),function(){e=!0,c||b.onCompleted()});return new lb(h,d)})},Mb.takeUntil=function(a){var c=this;return new dc(function(d){return new lb(c.subscribe(d),a.subscribe(d.onCompleted.bind(d),d.onError.bind(d),b))})},Mb.zip=function(){if(Array.isArray(arguments[0]))return t.apply(this,arguments);var a=this,b=fb.call(arguments),d=b.pop();return b.unshift(a),new dc(function(e){function f(a){i[a]=!0,i.every(function(a){return a})&&e.onCompleted()}for(var g=b.length,h=r(g,function(){return[]}),i=r(g,function(){return!1}),j=function(b){var f,g;if(h.every(function(a){return a.length>0})){try{g=h.map(function(a){return a.shift()}),f=d.apply(a,g)}catch(j){return e.onError(j),void 0}e.onNext(f)}else i.filter(function(a,c){return c!==b}).every(c)&&e.onCompleted()},k=new Array(g),l=0;g>l;l++)!function(a){k[a]=new rb,k[a].setDisposable(b[a].subscribe(function(b){h[a].push(b),j(a)},e.onError.bind(e),function(){f(a)}))}(l);return new lb(k)})},Pb.zip=function(){var a=fb.call(arguments,0),b=a.shift();return b.zip.apply(b,a)},Pb.zipArray=function(){var a=q(arguments,0);return new dc(function(b){function d(a){if(g.every(function(a){return a.length>0})){var d=g.map(function(a){return a.shift()});b.onNext(d)}else if(h.filter(function(b,c){return c!==a}).every(c))return b.onCompleted(),void 0}function e(a){return h[a]=!0,h.every(c)?(b.onCompleted(),void 0):void 0}for(var f=a.length,g=r(f,function(){return[]}),h=r(f,function(){return!1}),i=new Array(f),j=0;f>j;j++)!function(c){i[c]=new rb,i[c].setDisposable(a[c].subscribe(function(a){g[c].push(a),d(c)},b.onError.bind(b),function(){e(c)}))}(j);var k=new lb(i);return k.add(ob(function(){for(var a=0,b=g.length;b>a;a++)g[a]=[]})),k})},Mb.asObservable=function(){var a=this;return new dc(function(b){return a.subscribe(b)})},Mb.dematerialize=function(){var a=this;return new dc(function(b){return a.subscribe(function(a){return a.accept(b)},b.onError.bind(b),b.onCompleted.bind(b))})},Mb.distinctUntilChanged=function(a,b){var e=this;return a||(a=c),b||(b=d),new dc(function(c){var d,f=!1;return e.subscribe(function(e){var g,h=!1;try{g=a(e)}catch(i){return c.onError(i),void 0}if(f)try{h=b(d,g)}catch(i){return c.onError(i),void 0}f&&h||(f=!0,d=g,c.onNext(e))},c.onError.bind(c),c.onCompleted.bind(c))})},Mb["do"]=Mb.doAction=function(a,b,c){var d,e=this;return"function"==typeof a?d=a:(d=a.onNext.bind(a),b=a.onError.bind(a),c=a.onCompleted.bind(a)),new dc(function(a){return e.subscribe(function(b){try{d(b)}catch(c){a.onError(c)}a.onNext(b)},function(c){if(b){try{b(c)}catch(d){a.onError(d)}a.onError(c)}else a.onError(c)},function(){if(c){try{c()}catch(b){a.onError(b)}a.onCompleted()}else a.onCompleted()})})},Mb["finally"]=Mb.finallyAction=function(a){var b=this;return new dc(function(c){var d=b.subscribe(c);return ob(function(){try{d.dispose()}catch(b){throw b}finally{a()}})})},Mb.ignoreElements=function(){var a=this;return new dc(function(c){return a.subscribe(b,c.onError.bind(c),c.onCompleted.bind(c))})},Mb.materialize=function(){var a=this;return new dc(function(b){return a.subscribe(function(a){b.onNext(Cb(a))},function(a){b.onNext(Db(a)),b.onCompleted()},function(){b.onNext(Eb()),b.onCompleted()})})},Mb.repeat=function(a){return Ib(this,a).concat()},Mb.retry=function(a){return Ib(this,a).catchException()},Mb.scan=function(){var a,b,c=!1,d=this;return 2===arguments.length?(c=!0,a=arguments[0],b=arguments[1]):b=arguments[0],new dc(function(e){var f,g,h;return d.subscribe(function(d){try{h||(h=!0),f?g=b(g,d):(g=c?b(a,d):d,f=!0)}catch(i){return e.onError(i),void 0}e.onNext(g)},e.onError.bind(e),function(){!h&&c&&e.onNext(a),e.onCompleted()})})},Mb.skipLast=function(a){var b=this;return new dc(function(c){var d=[];return b.subscribe(function(b){d.push(b),d.length>a&&c.onNext(d.shift())},c.onError.bind(c),c.onCompleted.bind(c))})},Mb.startWith=function(){var a,b,c=0;return arguments.length&&"now"in Object(arguments[0])?(b=arguments[0],c=1):b=xb,a=fb.call(arguments,c),Jb([Tb(a,b),this]).concat()},Mb.takeLast=function(a,b){return this.takeLastBuffer(a).selectMany(function(a){return Tb(a,b)})},Mb.takeLastBuffer=function(a){var b=this;return new dc(function(c){var d=[];return b.subscribe(function(b){d.push(b),d.length>a&&d.shift()},c.onError.bind(c),function(){c.onNext(d),c.onCompleted()})})},Mb.select=Mb.map=function(a,b){var c=this;return new dc(function(d){var e=0;return c.subscribe(function(f){var g;try{g=a.call(b,f,e++,c)}catch(h){return d.onError(h),void 0}d.onNext(g)},d.onError.bind(d),d.onCompleted.bind(d))})},Mb.selectMany=Mb.flatMap=function(a,b){return b?this.selectMany(function(c,d){var e=a(c,d),f=g(e)?_b(e):e;return f.select(function(a){return b(c,a,d)})}):"function"==typeof a?u.call(this,a):u.call(this,function(){return a})},Mb.selectSwitch=Mb.flatMapLatest=function(a,b){return this.select(a,b).switchLatest()},Mb.skip=function(a){if(0>a)throw new Error(K);var b=this;return new dc(function(c){var d=a;return b.subscribe(function(a){0>=d?c.onNext(a):d--},c.onError.bind(c),c.onCompleted.bind(c))})},Mb.skipWhile=function(a,b){var c=this;return new dc(function(d){var e=0,f=!1;return c.subscribe(function(g){if(!f)try{f=!a.call(b,g,e++,c)}catch(h){return d.onError(h),void 0}f&&d.onNext(g)},d.onError.bind(d),d.onCompleted.bind(d))})},Mb.take=function(a,b){if(0>a)throw new Error(K);if(0===a)return Sb(b);var c=this;return new dc(function(b){var d=a;return c.subscribe(function(a){d>0&&(d--,b.onNext(a),0===d&&b.onCompleted())},b.onError.bind(b),b.onCompleted.bind(b))})},Mb.takeWhile=function(a,b){var c=this;return new dc(function(d){var e=0,f=!0;return c.subscribe(function(g){if(f){try{f=a.call(b,g,e++,c)}catch(h){return d.onError(h),void 0}f?d.onNext(g):d.onCompleted()}},d.onError.bind(d),d.onCompleted.bind(d))})},Mb.where=Mb.filter=function(a,b){var c=this;return new dc(function(d){var e=0;return c.subscribe(function(f){var g;try{g=a.call(b,f,e++,c)}catch(h){return d.onError(h),void 0}g&&d.onNext(f)},d.onError.bind(d),d.onCompleted.bind(d))})},Pb.fromCallback=function(a,b,c,d){return b||(b=xb),function(){var e=fb.call(arguments,0);return new dc(function(f){return b.schedule(function(){function b(a){var b=a;if(d)try{b=d(arguments)}catch(c){return f.onError(c),void 0}else 1===b.length&&(b=b[0]);f.onNext(b),f.onCompleted()}e.push(b),a.apply(c,e)})})}},Pb.fromNodeCallback=function(a,b,c,d){return b||(b=xb),function(){var e=fb.call(arguments,0);return new dc(function(f){return b.schedule(function(){function b(a){if(a)return f.onError(a),void 0;var b=fb.call(arguments,1);if(d)try{b=d(b)}catch(c){return f.onError(c),void 0}else 1===b.length&&(b=b[0]);f.onNext(b),f.onCompleted()}e.push(b),a.apply(c,e)})})}},Pb.fromEvent=function(a,b,c){return new dc(function(d){return w(a,b,function(a){var b=a;if(c)try{b=c(arguments)}catch(e){return d.onError(e),void 0}d.onNext(b)})}).publish().refCount()},Pb.fromEventPattern=function(a,b,c){return new dc(function(d){function e(a){var b=a; -if(c)try{b=c(arguments)}catch(e){return d.onError(e),void 0}d.onNext(b)}var f=a(e);return ob(function(){b&&b(e,f)})}).publish().refCount()};var _b=Pb.fromPromise=function(a){return new dc(function(b){a.then(function(a){b.onNext(a),b.onCompleted()},function(a){b.onError(a)})})};Mb.toPromise=function(a){if(a||(a=H.config.Promise),!a)throw new Error("Promise type not provided nor in Rx.config.Promise");var b=this;return new a(function(a,c){var d,e=!1;b.subscribe(function(a){d=a,e=!0},function(a){c(a)},function(){e&&a(d)})})},Pb.startAsync=function(a){var b;try{b=a()}catch(c){return Wb(c)}return _b(b)},Mb.multicast=function(a,b){var c=this;return"function"==typeof a?new dc(function(d){var e=c.multicast(a());return new lb(b(e).subscribe(d),e.connect())}):new ac(c,a)},Mb.publish=function(a){return a?this.multicast(function(){return new gc},a):this.multicast(new gc)},Mb.share=function(){return this.publish(null).refCount()},Mb.publishLast=function(a){return a?this.multicast(function(){return new hc},a):this.multicast(new hc)},Mb.publishValue=function(a,b){return 2===arguments.length?this.multicast(function(){return new jc(b)},a):this.multicast(new jc(a))},Mb.shareValue=function(a){return this.publishValue(a).refCount()},Mb.replay=function(a,b,c,d){return a?this.multicast(function(){return new kc(b,c,d)},a):this.multicast(new kc(b,c,d))},Mb.shareReplay=function(a,b,c){return this.replay(null,a,b,c).refCount()};var ac=H.ConnectableObservable=function(a){function b(b,c){function d(a){return e.subject.subscribe(a)}var e={subject:c,source:b.asObservable(),hasSubscription:!1,subscription:null};this.connect=function(){return e.hasSubscription||(e.hasSubscription=!0,e.subscription=new lb(e.source.subscribe(e.subject),ob(function(){e.hasSubscription=!1}))),e.subscription},a.call(this,d)}return gb(b,a),b.prototype.connect=function(){return this.connect()},b.prototype.refCount=function(){var a=null,b=0,c=this;return new dc(function(d){var e,f;return b++,e=1===b,f=c.subscribe(d),e&&(a=c.connect()),ob(function(){f.dispose(),b--,0===b&&a.dispose()})})},b}(Pb),bc=Pb.interval=function(a,b){return b||(b=Ab),y(a,a,b)},cc=Pb.timer=function(b,c,d){var e;return d||(d=Ab),"number"==typeof c?e=c:"object"==typeof c&&"now"in c&&(d=c),e===a?x(b,d):y(b,e,d)};Mb.delay=function(a,b){b||(b=Ab);var c=this;return new dc(function(d){var e,f=!1,g=new sb,h=null,i=[],j=!1;return e=c.materialize().timestamp(b).subscribe(function(c){var e,k;"E"===c.value.kind?(i=[],i.push(c),h=c.value.exception,k=!j):(i.push({value:c.value,timestamp:c.timestamp+a}),k=!f,f=!0),k&&(null!==h?d.onError(h):(e=new rb,g.setDisposable(e),e.setDisposable(b.scheduleRecursiveWithRelative(a,function(a){var c,e,g,k;if(null===h){j=!0;do g=null,i.length>0&&i[0].timestamp-b.now()<=0&&(g=i.shift().value),null!==g&&g.accept(d);while(null!==g);k=!1,e=0,i.length>0?(k=!0,e=Math.max(0,i[0].timestamp-b.now())):f=!1,c=h,j=!1,null!==c?d.onError(c):k&&a(e)}}))))}),new lb(e,g)})},Mb.throttle=function(a,b){b||(b=Ab);return this.throttleWithSelector(function(){return cc(a,b)})},Mb.timeInterval=function(a){var b=this;return a||(a=Ab),Rb(function(){var c=a.now();return b.select(function(b){var d=a.now(),e=d-c;return c=d,{value:b,interval:e}})})},Mb.timestamp=function(a){return a||(a=Ab),this.select(function(b){return{value:b,timestamp:a.now()}})},Mb.sample=function(a,b){return b||(b=Ab),"number"==typeof a?z(this,bc(a,b)):z(this,a)},Mb.timeout=function(a,b,c){var d,e=this;return b||(b=Wb(new Error("Timeout"))),c||(c=Ab),d=a instanceof Date?function(a,b){c.scheduleWithAbsolute(a,b)}:function(a,b){c.scheduleWithRelative(a,b)},new dc(function(c){var f,g=0,h=new rb,i=new sb,j=!1,k=new sb;return i.setDisposable(h),f=function(){var e=g;k.setDisposable(d(a,function(){j=g===e;var a=j;a&&i.setDisposable(b.subscribe(c))}))},f(),h.setDisposable(e.subscribe(function(a){var b=!j;b&&(g++,c.onNext(a),f())},function(a){var b=!j;b&&(g++,c.onError(a))},function(){var a=!j;a&&(g++,c.onCompleted())})),new lb(i,k)})},Pb.generateWithTime=function(a,b,c,d,e,f){return f||(f=Ab),new dc(function(g){var h,i,j=!0,k=!1,l=a;return f.scheduleRecursiveWithRelative(0,function(a){k&&g.onNext(h);try{j?j=!1:l=c(l),k=b(l),k&&(h=d(l),i=e(l))}catch(f){return g.onError(f),void 0}k?a(i):g.onCompleted()})})},Mb.delaySubscription=function(a,b){return b||(b=Ab),this.delayWithSelector(cc(a,b),function(){return Sb()})},Mb.delayWithSelector=function(a,b){var c,d,e=this;return"function"==typeof a?d=a:(c=a,d=b),new dc(function(a){var b=new lb,f=!1,g=function(){f&&0===b.length&&a.onCompleted()},h=new sb,i=function(){h.setDisposable(e.subscribe(function(c){var e;try{e=d(c)}catch(f){return a.onError(f),void 0}var h=new rb;b.add(h),h.setDisposable(e.subscribe(function(){a.onNext(c),b.remove(h),g()},a.onError.bind(a),function(){a.onNext(c),b.remove(h),g()}))},a.onError.bind(a),function(){f=!0,h.dispose(),g()}))};return c?h.setDisposable(c.subscribe(function(){i()},a.onError.bind(a),function(){i()})):i(),new lb(h,b)})},Mb.timeoutWithSelector=function(a,b,c){if(1===arguments.length){b=a;var a=Ub()}c||(c=Wb(new Error("Timeout")));var d=this;return new dc(function(e){var f=new sb,g=new sb,h=new rb;f.setDisposable(h);var i=0,j=!1,k=function(a){var b=i,d=function(){return i===b},h=new rb;g.setDisposable(h),h.setDisposable(a.subscribe(function(){d()&&f.setDisposable(c.subscribe(e)),h.dispose()},function(a){d()&&e.onError(a)},function(){d()&&f.setDisposable(c.subscribe(e))}))};k(a);var l=function(){var a=!j;return a&&i++,a};return h.setDisposable(d.subscribe(function(a){if(l()){e.onNext(a);var c;try{c=b(a)}catch(d){return e.onError(d),void 0}k(c)}},function(a){l()&&e.onError(a)},function(){l()&&e.onCompleted()})),new lb(f,g)})},Mb.throttleWithSelector=function(a){var b=this;return new dc(function(c){var d,e=!1,f=new sb,g=0,h=b.subscribe(function(b){var h;try{h=a(b)}catch(i){return c.onError(i),void 0}e=!0,d=b,g++;var j=g,k=new rb;f.setDisposable(k),k.setDisposable(h.subscribe(function(){e&&g===j&&c.onNext(d),e=!1,k.dispose()},c.onError.bind(c),function(){e&&g===j&&c.onNext(d),e=!1,k.dispose()}))},function(a){f.dispose(),c.onError(a),e=!1,g++},function(){f.dispose(),e&&c.onNext(d),c.onCompleted(),e=!1,g++});return new lb(h,f)})},Mb.skipLastWithTime=function(a,b){b||(b=Ab);var c=this;return new dc(function(d){var e=[];return c.subscribe(function(c){var f=b.now();for(e.push({interval:f,value:c});e.length>0&&f-e[0].interval>=a;)d.onNext(e.shift().value)},d.onError.bind(d),function(){for(var c=b.now();e.length>0&&c-e[0].interval>=a;)d.onNext(e.shift().value);d.onCompleted()})})},Mb.takeLastWithTime=function(a,b,c){return this.takeLastBufferWithTime(a,b).selectMany(function(a){return Tb(a,c)})},Mb.takeLastBufferWithTime=function(a,b){var c=this;return b||(b=Ab),new dc(function(d){var e=[];return c.subscribe(function(c){var d=b.now();for(e.push({interval:d,value:c});e.length>0&&d-e[0].interval>=a;)e.shift()},d.onError.bind(d),function(){for(var c=b.now(),f=[];e.length>0;){var g=e.shift();c-g.interval<=a&&f.push(g.value)}d.onNext(f),d.onCompleted()})})},Mb.takeWithTime=function(a,b){var c=this;return b||(b=Ab),new dc(function(d){var e=b.scheduleWithRelative(a,function(){d.onCompleted()});return new lb(e,c.subscribe(d))})},Mb.skipWithTime=function(a,b){var c=this;return b||(b=Ab),new dc(function(d){var e=!1,f=b.scheduleWithRelative(a,function(){e=!0}),g=c.subscribe(function(a){e&&d.onNext(a)},d.onError.bind(d),d.onCompleted.bind(d));return new lb(f,g)})},Mb.skipUntilWithTime=function(a,b){b||(b=Ab);var c=this;return new dc(function(d){var e=!1,f=b.scheduleWithAbsolute(a,function(){e=!0}),g=c.subscribe(function(a){e&&d.onNext(a)},d.onError.bind(d),d.onCompleted.bind(d));return new lb(f,g)})},Mb.takeUntilWithTime=function(a,b){b||(b=Ab);var c=this;return new dc(function(d){return new lb(b.scheduleWithAbsolute(a,function(){d.onCompleted()}),c.subscribe(d))})},Mb.pausable=function(a){var b=this;return new dc(function(c){var d=b.publish(),e=d.subscribe(c),f=pb,g=a.distinctUntilChanged().subscribe(function(a){a?f=d.connect():(f.dispose(),f=pb)});return new lb(e,f,g)})};var dc=H.AnonymousObservable=function(a){function b(a){return"undefined"==typeof a?a=pb:"function"==typeof a&&(a=ob(a)),a}function c(d){function e(a){var c=new ec(a);if(yb.scheduleRequired())yb.schedule(function(){try{c.setDisposable(b(d(c)))}catch(a){if(!c.fail(a))throw a}});else try{c.setDisposable(b(d(c)))}catch(e){if(!c.fail(e))throw e}return c}return this instanceof c?(a.call(this,e),void 0):new c(d)}return gb(c,a),c}(Pb),ec=function(a){function b(b){a.call(this),this.observer=b,this.m=new rb}gb(b,a);var c=b.prototype;return c.next=function(a){var b=!1;try{this.observer.onNext(a),b=!0}catch(c){throw c}finally{b||this.dispose()}},c.error=function(a){try{this.observer.onError(a)}catch(b){throw b}finally{this.dispose()}},c.completed=function(){try{this.observer.onCompleted()}catch(a){throw a}finally{this.dispose()}},c.setDisposable=function(a){this.m.setDisposable(a)},c.getDisposable=function(){return this.m.getDisposable()},c.disposable=function(a){return arguments.length?this.getDisposable():setDisposable(a)},c.dispose=function(){a.prototype.dispose.call(this),this.m.dispose()},b}(Nb),fc=function(a,b){this.subject=a,this.observer=b};fc.prototype.dispose=function(){if(!this.subject.isDisposed&&null!==this.observer){var a=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(a,1),this.observer=null}};var gc=H.Subject=function(a){function b(a){return h.call(this),this.isStopped?this.exception?(a.onError(this.exception),pb):(a.onCompleted(),pb):(this.observers.push(a),new fc(this,a))}function c(){a.call(this,b),this.isDisposed=!1,this.isStopped=!1,this.observers=[]}return gb(c,a),hb(c.prototype,Kb,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(h.call(this),!this.isStopped){var a=this.observers.slice(0);this.isStopped=!0;for(var b=0,c=a.length;c>b;b++)a[b].onCompleted();this.observers=[]}},onError:function(a){if(h.call(this),!this.isStopped){var b=this.observers.slice(0);this.isStopped=!0,this.exception=a;for(var c=0,d=b.length;d>c;c++)b[c].onError(a);this.observers=[]}},onNext:function(a){if(h.call(this),!this.isStopped)for(var b=this.observers.slice(0),c=0,d=b.length;d>c;c++)b[c].onNext(a)},dispose:function(){this.isDisposed=!0,this.observers=null}}),c.create=function(a,b){return new ic(a,b)},c}(Pb),hc=H.AsyncSubject=function(a){function b(a){if(h.call(this),!this.isStopped)return this.observers.push(a),new fc(this,a);var b=this.exception,c=this.hasValue,d=this.value;return b?a.onError(b):c?(a.onNext(d),a.onCompleted()):a.onCompleted(),pb}function c(){a.call(this,b),this.isDisposed=!1,this.isStopped=!1,this.value=null,this.hasValue=!1,this.observers=[],this.exception=null}return gb(c,a),hb(c.prototype,Kb,{hasObservers:function(){return h.call(this),this.observers.length>0},onCompleted:function(){var a,b,c;if(h.call(this),!this.isStopped){this.isStopped=!0;var d=this.observers.slice(0),e=this.value,f=this.hasValue;if(f)for(b=0,c=d.length;c>b;b++)a=d[b],a.onNext(e),a.onCompleted();else for(b=0,c=d.length;c>b;b++)d[b].onCompleted();this.observers=[]}},onError:function(a){if(h.call(this),!this.isStopped){var b=this.observers.slice(0);this.isStopped=!0,this.exception=a;for(var c=0,d=b.length;d>c;c++)b[c].onError(a);this.observers=[]}},onNext:function(a){h.call(this),this.isStopped||(this.value=a,this.hasValue=!0)},dispose:function(){this.isDisposed=!0,this.observers=null,this.exception=null,this.value=null}}),c}(Pb),ic=function(a){function b(a){return this.observable.subscribe(a)}function c(c,d){a.call(this,b),this.observer=c,this.observable=d}return gb(c,a),hb(c.prototype,Kb,{onCompleted:function(){this.observer.onCompleted()},onError:function(a){this.observer.onError(a)},onNext:function(a){this.observer.onNext(a)}}),c}(Pb),jc=H.BehaviorSubject=function(a){function b(a){if(h.call(this),!this.isStopped)return this.observers.push(a),a.onNext(this.value),new fc(this,a);var b=this.exception;return b?a.onError(b):a.onCompleted(),pb}function c(c){a.call(this,b),this.value=c,this.observers=[],this.isDisposed=!1,this.isStopped=!1,this.exception=null}return gb(c,a),hb(c.prototype,Kb,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(h.call(this),!this.isStopped){var a=this.observers.slice(0);this.isStopped=!0;for(var b=0,c=a.length;c>b;b++)a[b].onCompleted();this.observers=[]}},onError:function(a){if(h.call(this),!this.isStopped){var b=this.observers.slice(0);this.isStopped=!0,this.exception=a;for(var c=0,d=b.length;d>c;c++)b[c].onError(a);this.observers=[]}},onNext:function(a){if(h.call(this),!this.isStopped){this.value=a;for(var b=this.observers.slice(0),c=0,d=b.length;d>c;c++)b[c].onNext(a)}},dispose:function(){this.isDisposed=!0,this.observers=null,this.value=null,this.exception=null}}),c}(Pb),kc=H.ReplaySubject=function(a){function b(a,b){this.subject=a,this.observer=b}function c(a){var c=new Qb(this.scheduler,a),d=new b(this,c);h.call(this),this._trim(this.scheduler.now()),this.observers.push(c);for(var e=this.q.length,f=0,g=this.q.length;g>f;f++)c.onNext(this.q[f].value);return this.hasError?(e++,c.onError(this.error)):this.isStopped&&(e++,c.onCompleted()),c.ensureActive(e),d}function d(b,d,e){this.bufferSize=null==b?Number.MAX_VALUE:b,this.windowSize=null==d?Number.MAX_VALUE:d,this.scheduler=e||yb,this.q=[],this.observers=[],this.isStopped=!1,this.isDisposed=!1,this.hasError=!1,this.error=null,a.call(this,c)}return b.prototype.dispose=function(){if(this.observer.dispose(),!this.subject.isDisposed){var a=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(a,1)}},gb(d,a),hb(d.prototype,Kb,{hasObservers:function(){return this.observers.length>0},_trim:function(a){for(;this.q.length>this.bufferSize;)this.q.shift();for(;this.q.length>0&&a-this.q[0].interval>this.windowSize;)this.q.shift()},onNext:function(a){var b;if(h.call(this),!this.isStopped){var c=this.scheduler.now();this.q.push({interval:c,value:a}),this._trim(c);for(var d=this.observers.slice(0),e=0,f=d.length;f>e;e++)b=d[e],b.onNext(a),b.ensureActive()}},onError:function(a){var b;if(h.call(this),!this.isStopped){this.isStopped=!0,this.error=a,this.hasError=!0;var c=this.scheduler.now();this._trim(c);for(var d=this.observers.slice(0),e=0,f=d.length;f>e;e++)b=d[e],b.onError(a),b.ensureActive();this.observers=[]}},onCompleted:function(){var a;if(h.call(this),!this.isStopped){this.isStopped=!0;var b=this.scheduler.now();this._trim(b);for(var c=this.observers.slice(0),d=0,e=c.length;e>d;d++)a=c[d],a.onCompleted(),a.ensureActive();this.observers=[]}},dispose:function(){this.isDisposed=!0,this.observers=null}}),d}(Pb);"function"==typeof define&&"object"==typeof define.amd&&define.amd?(B.Rx=H,define(function(){return H})):C&&D?E?(D.exports=H).Rx=H:C.Rx=H:B.Rx=H}).call(this); \ No newline at end of file +(function(a){function b(){}function c(a){return a}function d(a,b){return fb(a,b)}function e(a,b){return a-b}function f(a){throw a}function g(a){return"function"==typeof a.then}function h(){if(this.isDisposed)throw new Error(M)}function i(a){var b=typeof a;return a&&("function"==b||"object"==b)||!1}function j(a){var b=[];if(!i(a))return b;eb.nonEnumArgs&&a.length&&n(a)&&(a=gb.call(a));var c=eb.enumPrototypes&&"function"==typeof a,d=eb.enumErrorProps&&(a===$||a instanceof Error);for(var e in a)c&&"prototype"==e||d&&("message"==e||"name"==e)||b.push(e);if(eb.nonEnumShadows&&a!==_){var f=a.constructor,g=-1,h=cb.length;if(a===(f&&f.prototype))var j=a===stringProto?W:a===$?R:X.call(a),k=db[j];for(;++g-1:void 0});return c.pop(),d.pop(),result}function q(a,b){return 1===a.length&&Array.isArray(a[b])?a[b]:gb.call(a)}function r(a,b){for(var c=new Array(a),d=0;a>d;d++)c[d]=b();return c}function s(a,b){return new gc(function(c){var d=new sb,e=new tb;return e.setDisposable(d),d.setDisposable(a.subscribe(c.onNext.bind(c),function(a){var d,f;try{f=b(a)}catch(g){return c.onError(g),void 0}d=new sb,e.setDisposable(d),d.setDisposable(f.subscribe(c))},c.onCompleted.bind(c))),e})}function t(a,b){var c=this;return new gc(function(d){var e=0,f=a.length;return c.subscribe(function(c){if(f>e){var g,h=a[e++];try{g=b(c,h)}catch(i){return d.onError(i),void 0}d.onNext(g)}else d.onCompleted()},d.onError.bind(d),d.onCompleted.bind(d))})}function u(a){return this.select(function(b,c){var d=a(b,c);return g(d)?ac(d):d}).mergeObservable()}function v(a,b,c){return a.addListener?(a.addListener(b,c),pb(function(){a.removeListener(b,c)})):a.addEventListener?(a.addEventListener(b,c,!1),pb(function(){a.removeEventListener(b,c,!1)})):void 0}function w(a,b,c){var d=new mb;if(a&&a.length)for(var e=0,f=a.length;f>e;e++)d.add(w(a[e],b,c));else a&&d.add(v(a,b,c));return d}function x(a,b){var c=xb(a);return new gc(function(a){return b.scheduleWithRelative(c,function(){a.onNext(0),a.onCompleted()})})}function y(a,b,c){return a===b?new gc(function(a){return c.schedulePeriodicWithState(0,b,function(b){return a.onNext(b),b+1})}):Sb(function(){return observableTimerDateAndPeriod(c.now()+a,b,c)})}function z(a,b){return new gc(function(c){function d(){g&&(g=!1,c.onNext(f)),e&&c.onCompleted()}var e,f,g;return new mb(a.subscribe(function(a){g=!0,f=a},c.onError.bind(c),function(){e=!0}),b.subscribe(d,c.onError.bind(c),d))})}function A(a,b,d){return new gc(function(e){function f(a,b){k[b]=a;var f;if(h[b]=!0,i||(i=h.every(c))){try{f=d.apply(null,k)}catch(g){return e.onError(g),void 0}e.onNext(f)}else j&&e.onCompleted()}var g=2,h=[!1,!1],i=!1,j=!1,k=new Array(g);return new mb(a.subscribe(function(a){f(a,0)},e.onError.bind(e),function(){j=!0,e.onCompleted()}),b.subscribe(function(a){f(a,1)},e.onError.bind(e)))})}var B={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},C=B[typeof window]&&window||this,D=B[typeof exports]&&exports&&!exports.nodeType&&exports,E=B[typeof module]&&module&&!module.nodeType&&module,F=E&&E.exports===D&&D,G=B[typeof global]&&global;!G||G.global!==G&&G.window!==G||(C=G);var H,I={internals:{},config:{}},J=Date.now,K="Sequence contains no elements.",L="Argument out of range",M="Object has been disposed",N="[object Arguments]",O="[object Array]",P="[object Boolean]",Q="[object Date]",R="[object Error]",S="[object Function]",T="[object Number]",U="[object Object]",V="[object RegExp]",W="[object String]",X=Object.prototype.toString,Y=Object.prototype.hasOwnProperty,Z=X.call(arguments)==N,$=Error.prototype,_=Object.prototype,ab=_.propertyIsEnumerable;try{H=!(X.call(document)==U&&!({toString:0}+""))}catch(bb){H=!0}var cb=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],db={};db[O]=db[Q]=db[T]={constructor:!0,toLocaleString:!0,toString:!0,valueOf:!0},db[P]=db[W]={constructor:!0,toString:!0,valueOf:!0},db[R]=db[S]=db[V]={constructor:!0,toString:!0},db[U]={constructor:!0};var eb={};!function(){var a=function(){this.x=1},b=[];a.prototype={valueOf:1,y:1};for(var c in new a)b.push(c);for(c in arguments);eb.enumErrorProps=ab.call($,"message")||ab.call($,"name"),eb.enumPrototypes=ab.call(a,"prototype"),eb.nonEnumArgs=0!=c,eb.nonEnumShadows=!/valueOf/.test(b)}(1),Z||(n=function(a){return a&&"object"==typeof a?Y.call(a,"callee"):!1}),o(/x/)&&(o=function(a){return"function"==typeof a&&X.call(a)==S});var fb=I.internals.isEqual=function(a,b){return p(a,b,[],[])},gb=Array.prototype.slice,hb=({}.hasOwnProperty,this.inherits=I.internals.inherits=function(a,b){function c(){this.constructor=a}c.prototype=b.prototype,a.prototype=new c}),ib=I.internals.addProperties=function(a){for(var b=gb.call(arguments,1),c=0,d=b.length;d>c;c++){var e=b[c];for(var f in e)a[f]=e[f]}},jb=(I.internals.addRef=function(a,b){return new gc(function(c){return new mb(b.getDisposable(),a.subscribe(c))})},function(a,b){this.id=a,this.value=b});jb.prototype.compareTo=function(a){var b=this.value.compareTo(a.value);return 0===b&&(b=this.id-a.id),b};var kb=I.internals.PriorityQueue=function(a){this.items=new Array(a),this.length=0},lb=kb.prototype;lb.isHigherPriority=function(a,b){return this.items[a].compareTo(this.items[b])<0},lb.percolate=function(a){if(!(a>=this.length||0>a)){var b=a-1>>1;if(!(0>b||b===a)&&this.isHigherPriority(a,b)){var c=this.items[a];this.items[a]=this.items[b],this.items[b]=c,this.percolate(b)}}},lb.heapify=function(b){if(b===a&&(b=0),!(b>=this.length||0>b)){var c=2*b+1,d=2*b+2,e=b;if(cb;b++)a[b].dispose()}},nb.clear=function(){var a=this.disposables.slice(0);this.disposables=[],this.length=0;for(var b=0,c=a.length;c>b;b++)a[b].dispose()},nb.contains=function(a){return-1!==this.disposables.indexOf(a)},nb.toArray=function(){return this.disposables.slice(0)};var ob=I.Disposable=function(a){this.isDisposed=!1,this.action=a||b};ob.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var pb=ob.create=function(a){return new ob(a)},qb=ob.empty={dispose:b},rb=function(){function a(a){this.isSingle=a,this.isDisposed=!1,this.current=null}var b=a.prototype;return b.getDisposable=function(){return this.current},b.setDisposable=function(a){if(this.current&&this.isSingle)throw new Error("Disposable has already been assigned");var b,c=this.isDisposed;c||(b=this.current,this.current=a),b&&b.dispose(),c&&a&&a.dispose()},b.dispose=function(){var a;this.isDisposed||(this.isDisposed=!0,a=this.current,this.current=null),a&&a.dispose()},a}(),sb=I.SingleAssignmentDisposable=function(a){function b(){a.call(this,!0)}return hb(b,a),b}(rb),tb=I.SerialDisposable=function(a){function b(){a.call(this,!1)}return hb(b,a),b}(rb),ub=(I.RefCountDisposable=function(){function a(a){this.disposable=a,this.disposable.count++,this.isInnerDisposed=!1}function b(a){this.underlyingDisposable=a,this.isDisposed=!1,this.isPrimaryDisposed=!1,this.count=0}return a.prototype.dispose=function(){this.disposable.isDisposed||this.isInnerDisposed||(this.isInnerDisposed=!0,this.disposable.count--,0===this.disposable.count&&this.disposable.isPrimaryDisposed&&(this.disposable.isDisposed=!0,this.disposable.underlyingDisposable.dispose()))},b.prototype.dispose=function(){this.isDisposed||this.isPrimaryDisposed||(this.isPrimaryDisposed=!0,0===this.count&&(this.isDisposed=!0,this.underlyingDisposable.dispose()))},b.prototype.getDisposable=function(){return this.isDisposed?qb:new a(this)},b}(),I.internals.ScheduledItem=function(a,b,c,d,f){this.scheduler=a,this.state=b,this.action=c,this.dueTime=d,this.comparer=f||e,this.disposable=new sb});ub.prototype.invoke=function(){this.disposable.setDisposable(this.invokeCore())},ub.prototype.compareTo=function(a){return this.comparer(this.dueTime,a.dueTime)},ub.prototype.isCancelled=function(){return this.disposable.isDisposed},ub.prototype.invokeCore=function(){return this.action(this.scheduler,this.state)};var vb,wb=I.Scheduler=function(){function a(a,b,c,d){this.now=a,this._schedule=b,this._scheduleRelative=c,this._scheduleAbsolute=d}function b(a,b){var c=b.first,d=b.second,e=new mb,f=function(b){d(b,function(b){var c=!1,d=!1,g=a.scheduleWithState(b,function(a,b){return c?e.remove(g):d=!0,f(b),qb});d||(e.add(g),c=!0)})};return f(c),e}function c(a,b,c){var d=b.first,e=b.second,f=new mb,g=function(b){e(b,function(b,d){var e=!1,h=!1,i=a[c].call(a,b,d,function(a,b){return e?f.remove(i):h=!0,g(b),qb});h||(f.add(i),e=!0)})};return g(d),f}function d(a,b){return b(),qb}var e=a.prototype;return e.schedulePeriodic=function(a,b){return this.schedulePeriodicWithState(null,a,function(){b()})},e.schedulePeriodicWithState=function(a,b,c){var d=a,e=setInterval(function(){d=c(d)},b);return pb(function(){clearInterval(e)})},e.schedule=function(a){return this._schedule(a,d)},e.scheduleWithState=function(a,b){return this._schedule(a,b)},e.scheduleWithRelative=function(a,b){return this._scheduleRelative(b,a,d)},e.scheduleWithRelativeAndState=function(a,b,c){return this._scheduleRelative(a,b,c)},e.scheduleWithAbsolute=function(a,b){return this._scheduleAbsolute(b,a,d)},e.scheduleWithAbsoluteAndState=function(a,b,c){return this._scheduleAbsolute(a,b,c)},e.scheduleRecursive=function(a){return this.scheduleRecursiveWithState(a,function(a,b){a(function(){b(a)})})},e.scheduleRecursiveWithState=function(a,c){return this.scheduleWithState({first:a,second:c},function(a,c){return b(a,c)})},e.scheduleRecursiveWithRelative=function(a,b){return this.scheduleRecursiveWithRelativeAndState(b,a,function(a,b){a(function(c){b(a,c)})})},e.scheduleRecursiveWithRelativeAndState=function(a,b,d){return this._scheduleRelative({first:a,second:d},b,function(a,b){return c(a,b,"scheduleWithRelativeAndState")})},e.scheduleRecursiveWithAbsolute=function(a,b){return this.scheduleRecursiveWithAbsoluteAndState(b,a,function(a,b){a(function(c){b(a,c)})})},e.scheduleRecursiveWithAbsoluteAndState=function(a,b,d){return this._scheduleAbsolute({first:a,second:d},b,function(a,b){return c(a,b,"scheduleWithAbsoluteAndState")})},a.now=J,a.normalize=function(a){return 0>a&&(a=0),a},a}(),xb=wb.normalize,yb=wb.immediate=function(){function a(a,b){return b(this,a)}function b(a,b,c){for(var d=xb(d);d-this.now()>0;);return c(this,a)}function c(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}return new wb(J,a,b,c)}(),zb=wb.currentThread=function(){function a(a){for(var b;a.length>0;)if(b=a.dequeue(),!b.isCancelled()){for(;b.dueTime-wb.now()>0;);b.isCancelled()||b.invoke()}}function b(a,b){return this.scheduleWithRelativeAndState(a,0,b)}function c(b,c,d){var f=this.now()+wb.normalize(c),g=new ub(this,b,d,f);if(e)e.enqueue(g);else{e=new kb(4),e.enqueue(g);try{a(e)}catch(h){throw h}finally{e=null}}return g.disposable}function d(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}var e,f=new wb(J,b,c,d);return f.scheduleRequired=function(){return null===e},f.ensureTrampoline=function(a){return null===e?this.schedule(a):a()},f}(),Ab=(I.internals.SchedulePeriodicRecursive=function(){function a(a,b){b(0,this._period);try{this._state=this._action(this._state)}catch(c){throw this._cancel.dispose(),c}}function b(a,b,c,d){this._scheduler=a,this._state=b,this._period=c,this._action=d}return b.prototype.start=function(){var b=new sb;return this._cancel=b,b.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,a.bind(this))),b},b}(),b);!function(){function a(){if(!C.postMessage||C.importScripts)return!1;var a=!1,b=C.onmessage;return C.onmessage=function(){a=!0},C.postMessage("","*"),C.onmessage=b,a}function b(a){if("string"==typeof a.data&&a.data.substring(0,f.length)===f){var b=a.data.substring(f.length),c=g[b];c(),delete g[b]}}var c=RegExp("^"+String(X).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),d="function"==typeof(d=G&&F&&G.setImmediate)&&!c.test(d)&&d,e="function"==typeof(e=G&&F&&G.clearImmediate)&&!c.test(e)&&e;if("undefined"!=typeof process&&"[object process]"==={}.toString.call(process))vb=process.nextTick;else if("function"==typeof d)vb=d,Ab=e;else if(a()){var f="ms.rx.schedule"+Math.random(),g={},h=0;C.addEventListener?C.addEventListener("message",b,!1):C.attachEvent("onmessage",b,!1),vb=function(a){var b=h++;g[b]=a,C.postMessage(f+b,"*")}}else if(C.MessageChannel){var i=new C.MessageChannel,j={},k=0;i.port1.onmessage=function(a){var b=a.data,c=j[b];c(),delete j[b]},vb=function(a){var b=k++;j[b]=a,i.port2.postMessage(b)}}else"document"in C&&"onreadystatechange"in C.document.createElement("script")?vb=function(a){var b=C.document.createElement("script");b.onreadystatechange=function(){a(),b.onreadystatechange=null,b.parentNode.removeChild(b),b=null},C.document.documentElement.appendChild(b)}:(vb=function(a){return setTimeout(a,0)},Ab=clearTimeout)}();var Bb=wb.timeout=function(){function a(a,b){var c=this,d=new sb,e=vb(function(){d.isDisposed||d.setDisposable(b(c,a))});return new mb(d,pb(function(){Ab(e)}))}function b(a,b,c){var d=this,e=wb.normalize(b);if(0===e)return d.scheduleWithState(a,c);var f=new sb,g=setTimeout(function(){f.isDisposed||f.setDisposable(c(d,a))},e);return new mb(f,pb(function(){clearTimeout(g)}))}function c(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}return new wb(J,a,b,c)}(),Cb=I.Notification=function(){function a(a,b){this.hasValue=null==b?!1:b,this.kind=a}var b=a.prototype;return b.accept=function(a,b,c){return 1===arguments.length&&"object"==typeof a?this._acceptObservable(a):this._accept(a,b,c)},b.toObservable=function(a){var b=this;return a||(a=yb),new gc(function(c){return a.schedule(function(){b._acceptObservable(c),"N"===b.kind&&c.onCompleted()})})},a}(),Db=Cb.createOnNext=function(){function a(a){return a(this.value)}function b(a){return a.onNext(this.value)}function c(){return"OnNext("+this.value+")"}return function(d){var e=new Cb("N",!0);return e.value=d,e._accept=a,e._acceptObservable=b,e.toString=c,e}}(),Eb=Cb.createOnError=function(){function a(a,b){return b(this.exception)}function b(a){return a.onError(this.exception)}function c(){return"OnError("+this.exception+")"}return function(d){var e=new Cb("E");return e.exception=d,e._accept=a,e._acceptObservable=b,e.toString=c,e}}(),Fb=Cb.createOnCompleted=function(){function a(a,b,c){return c()}function b(a){return a.onCompleted()}function c(){return"OnCompleted()"}return function(){var d=new Cb("C");return d._accept=a,d._acceptObservable=b,d.toString=c,d}}(),Gb=I.internals.Enumerator=function(a,b){this.moveNext=a,this.getCurrent=b},Hb=Gb.create=function(a,b){var c=!1;return new Gb(function(){if(c)return!1;var b=a();return b||(c=!0),b},function(){return b()})},Ib=I.internals.Enumerable=function(a){this.getEnumerator=a};Ib.prototype.concat=function(){var a=this;return new gc(function(b){var c,d=a.getEnumerator(),e=new tb,f=yb.scheduleRecursive(function(a){var f,g;if(!c){try{g=d.moveNext(),g&&(f=d.getCurrent())}catch(h){return b.onError(h),void 0}if(!g)return b.onCompleted(),void 0;var i=new sb;e.setDisposable(i),i.setDisposable(f.subscribe(b.onNext.bind(b),b.onError.bind(b),function(){a()}))}});return new mb(e,f,pb(function(){c=!0}))})},Ib.prototype.catchException=function(){var a=this;return new gc(function(b){var c,d,e=a.getEnumerator(),f=new tb,g=yb.scheduleRecursive(function(a){var g,h;if(!c){try{h=e.moveNext(),h&&(g=e.getCurrent())}catch(i){return b.onError(i),void 0}if(!h)return d?b.onError(d):b.onCompleted(),void 0;var j=new sb;f.setDisposable(j),j.setDisposable(g.subscribe(b.onNext.bind(b),function(b){d=b,a()},b.onCompleted.bind(b)))}});return new mb(f,g,pb(function(){c=!0}))})};var Jb=Ib.repeat=function(a,b){return 1===arguments.length&&(b=-1),new Ib(function(){var c,d=b;return Hb(function(){return 0===d?!1:(d>0&&d--,c=a,!0)},function(){return c})})},Kb=Ib.forEach=function(a,b,d){return b||(b=c),new Ib(function(){var c,e=-1;return Hb(function(){return++e0&&(a=!this.isAcquired,this.isAcquired=!0),a&&this.disposable.setDisposable(this.scheduler.scheduleRecursive(function(a){var c;if(!(b.queue.length>0))return b.isAcquired=!1,void 0;c=b.queue.shift();try{c()}catch(d){throw b.queue=[],b.hasFaulted=!0,d}a()}))},b.prototype.dispose=function(){a.prototype.dispose.call(this),this.disposable.dispose()},b}(Ob);Qb.create=Qb.createWithDisposable=function(a){return new gc(a)};var Sb=Qb.defer=function(a){return new gc(function(b){var c;try{c=a()}catch(d){return Xb(d).subscribe(b)}return c.subscribe(b)})},Tb=Qb.empty=function(a){return a||(a=yb),new gc(function(b){return a.schedule(function(){b.onCompleted()})})},Ub=Qb.fromArray=function(a,b){return b||(b=zb),new gc(function(c){var d=0;return b.scheduleRecursive(function(b){dc?(d.onNext(a+c),e(c+1)):d.onCompleted()})})},Qb.repeat=function(a,b,c){return c||(c=zb),null==b&&(b=-1),Wb(a,c).repeat(b)};var Wb=Qb["return"]=Qb.returnValue=function(a,b){return b||(b=yb),new gc(function(c){return b.schedule(function(){c.onNext(a),c.onCompleted()})})},Xb=Qb["throw"]=Qb.throwException=function(a,b){return b||(b=yb),new gc(function(c){return b.schedule(function(){c.onError(a)})})};Nb["catch"]=Nb.catchException=function(a){return"function"==typeof a?s(this,a):Yb([this,a])};var Yb=Qb.catchException=Qb["catch"]=function(){var a=q(arguments,0);return Kb(a).catchException()};Nb.combineLatest=function(){var a=gb.call(arguments);return Array.isArray(a[0])?a[0].unshift(this):a.unshift(this),Zb.apply(this,a)};var Zb=Qb.combineLatest=function(){var a=gb.call(arguments),b=a.pop();return Array.isArray(a[0])&&(a=a[0]),new gc(function(d){function e(a){var e;if(i[a]=!0,j||(j=i.every(c))){try{e=b.apply(null,l)}catch(f){return d.onError(f),void 0}d.onNext(e)}else k.filter(function(b,c){return c!==a}).every(c)&&d.onCompleted()}function f(a){k[a]=!0,k.every(c)&&d.onCompleted()}for(var g=function(){return!1},h=a.length,i=r(h,g),j=!1,k=r(h,g),l=new Array(h),m=new Array(h),n=0;h>n;n++)!function(b){m[b]=new sb,m[b].setDisposable(a[b].subscribe(function(a){l[b]=a,e(b)},d.onError.bind(d),function(){f(b)}))}(n);return new mb(m)})};Nb.concat=function(){var a=gb.call(arguments,0);return a.unshift(this),$b.apply(this,a)};var $b=Qb.concat=function(){var a=q(arguments,0);return Kb(a).concat()};Nb.concatObservable=Nb.concatAll=function(){return this.merge(1)},Nb.merge=function(a){if("number"!=typeof a)return _b(this,a);var b=this;return new gc(function(c){var d=0,e=new mb,f=!1,h=[],i=function(a){var b=new sb;e.add(b),g(a)&&(a=ac(a)),b.setDisposable(a.subscribe(c.onNext.bind(c),c.onError.bind(c),function(){var a;e.remove(b),h.length>0?(a=h.shift(),i(a)):(d--,f&&0===d&&c.onCompleted())}))};return e.add(b.subscribe(function(b){a>d?(d++,i(b)):h.push(b)},c.onError.bind(c),function(){f=!0,0===d&&c.onCompleted()})),e})};var _b=Qb.merge=function(){var a,b;return arguments[0]?arguments[0].now?(a=arguments[0],b=gb.call(arguments,1)):(a=yb,b=gb.call(arguments,0)):(a=yb,b=gb.call(arguments,1)),Array.isArray(b[0])&&(b=b[0]),Ub(b,a).mergeObservable()};Nb.mergeObservable=Nb.mergeAll=function(){var a=this;return new gc(function(b){var c=new mb,d=!1,e=new sb;return c.add(e),e.setDisposable(a.subscribe(function(a){var e=new sb;c.add(e),g(a)&&(a=ac(a)),e.setDisposable(a.subscribe(function(a){b.onNext(a)},b.onError.bind(b),function(){c.remove(e),d&&1===c.length&&b.onCompleted()}))},b.onError.bind(b),function(){d=!0,1===c.length&&b.onCompleted()})),c})},Nb.skipUntil=function(a){var b=this;return new gc(function(c){var d=!1,e=new mb(b.subscribe(function(a){d&&c.onNext(a)},c.onError.bind(c),function(){d&&c.onCompleted()})),f=new sb;return e.add(f),f.setDisposable(a.subscribe(function(){d=!0,f.dispose()},c.onError.bind(c),function(){f.dispose()})),e})},Nb["switch"]=Nb.switchLatest=function(){var a=this;return new gc(function(b){var c=!1,d=new tb,e=!1,f=0,h=a.subscribe(function(a){var h=new sb,i=++f;c=!0,d.setDisposable(h),g(a)&&(a=ac(a)),h.setDisposable(a.subscribe(function(a){f===i&&b.onNext(a)},function(a){f===i&&b.onError(a)},function(){f===i&&(c=!1,e&&b.onCompleted())}))},b.onError.bind(b),function(){e=!0,c||b.onCompleted()});return new mb(h,d)})},Nb.takeUntil=function(a){var c=this;return new gc(function(d){return new mb(c.subscribe(d),a.subscribe(d.onCompleted.bind(d),d.onError.bind(d),b))})},Nb.zip=function(){if(Array.isArray(arguments[0]))return t.apply(this,arguments);var a=this,b=gb.call(arguments),d=b.pop();return b.unshift(a),new gc(function(e){function f(a){i[a]=!0,i.every(function(a){return a})&&e.onCompleted()}for(var g=b.length,h=r(g,function(){return[]}),i=r(g,function(){return!1}),j=function(b){var f,g;if(h.every(function(a){return a.length>0})){try{g=h.map(function(a){return a.shift()}),f=d.apply(a,g)}catch(j){return e.onError(j),void 0}e.onNext(f)}else i.filter(function(a,c){return c!==b}).every(c)&&e.onCompleted()},k=new Array(g),l=0;g>l;l++)!function(a){k[a]=new sb,k[a].setDisposable(b[a].subscribe(function(b){h[a].push(b),j(a)},e.onError.bind(e),function(){f(a)}))}(l);return new mb(k)})},Qb.zip=function(){var a=gb.call(arguments,0),b=a.shift();return b.zip.apply(b,a)},Qb.zipArray=function(){var a=q(arguments,0);return new gc(function(b){function d(a){if(g.every(function(a){return a.length>0})){var d=g.map(function(a){return a.shift()});b.onNext(d)}else if(h.filter(function(b,c){return c!==a}).every(c))return b.onCompleted(),void 0}function e(a){return h[a]=!0,h.every(c)?(b.onCompleted(),void 0):void 0}for(var f=a.length,g=r(f,function(){return[]}),h=r(f,function(){return!1}),i=new Array(f),j=0;f>j;j++)!function(c){i[c]=new sb,i[c].setDisposable(a[c].subscribe(function(a){g[c].push(a),d(c)},b.onError.bind(b),function(){e(c)}))}(j);var k=new mb(i);return k.add(pb(function(){for(var a=0,b=g.length;b>a;a++)g[a]=[]})),k})},Nb.asObservable=function(){var a=this;return new gc(function(b){return a.subscribe(b)})},Nb.dematerialize=function(){var a=this;return new gc(function(b){return a.subscribe(function(a){return a.accept(b)},b.onError.bind(b),b.onCompleted.bind(b))})},Nb.distinctUntilChanged=function(a,b){var e=this;return a||(a=c),b||(b=d),new gc(function(c){var d,f=!1;return e.subscribe(function(e){var g,h=!1;try{g=a(e)}catch(i){return c.onError(i),void 0}if(f)try{h=b(d,g)}catch(i){return c.onError(i),void 0}f&&h||(f=!0,d=g,c.onNext(e))},c.onError.bind(c),c.onCompleted.bind(c))})},Nb["do"]=Nb.doAction=function(a,b,c){var d,e=this;return"function"==typeof a?d=a:(d=a.onNext.bind(a),b=a.onError.bind(a),c=a.onCompleted.bind(a)),new gc(function(a){return e.subscribe(function(b){try{d(b)}catch(c){a.onError(c)}a.onNext(b)},function(c){if(b){try{b(c)}catch(d){a.onError(d)}a.onError(c)}else a.onError(c)},function(){if(c){try{c()}catch(b){a.onError(b)}a.onCompleted()}else a.onCompleted()})})},Nb["finally"]=Nb.finallyAction=function(a){var b=this;return new gc(function(c){var d=b.subscribe(c);return pb(function(){try{d.dispose()}catch(b){throw b}finally{a()}})})},Nb.ignoreElements=function(){var a=this;return new gc(function(c){return a.subscribe(b,c.onError.bind(c),c.onCompleted.bind(c))})},Nb.materialize=function(){var a=this;return new gc(function(b){return a.subscribe(function(a){b.onNext(Db(a))},function(a){b.onNext(Eb(a)),b.onCompleted()},function(){b.onNext(Fb()),b.onCompleted()})})},Nb.repeat=function(a){return Jb(this,a).concat()},Nb.retry=function(a){return Jb(this,a).catchException()},Nb.scan=function(){var a,b,c=!1,d=this;return 2===arguments.length?(c=!0,a=arguments[0],b=arguments[1]):b=arguments[0],new gc(function(e){var f,g,h;return d.subscribe(function(d){try{h||(h=!0),f?g=b(g,d):(g=c?b(a,d):d,f=!0)}catch(i){return e.onError(i),void 0}e.onNext(g)},e.onError.bind(e),function(){!h&&c&&e.onNext(a),e.onCompleted()})})},Nb.skipLast=function(a){var b=this;return new gc(function(c){var d=[];return b.subscribe(function(b){d.push(b),d.length>a&&c.onNext(d.shift())},c.onError.bind(c),c.onCompleted.bind(c))})},Nb.startWith=function(){var a,b,c=0;return arguments.length&&"now"in Object(arguments[0])?(b=arguments[0],c=1):b=yb,a=gb.call(arguments,c),Kb([Ub(a,b),this]).concat()},Nb.takeLast=function(a,b){return this.takeLastBuffer(a).selectMany(function(a){return Ub(a,b)})},Nb.takeLastBuffer=function(a){var b=this;return new gc(function(c){var d=[];return b.subscribe(function(b){d.push(b),d.length>a&&d.shift()},c.onError.bind(c),function(){c.onNext(d),c.onCompleted()})})},Nb.select=Nb.map=function(a,b){var c=this;return new gc(function(d){var e=0;return c.subscribe(function(f){var g;try{g=a.call(b,f,e++,c)}catch(h){return d.onError(h),void 0}d.onNext(g)},d.onError.bind(d),d.onCompleted.bind(d))})},Nb.selectMany=Nb.flatMap=function(a,b){return b?this.selectMany(function(c,d){var e=a(c,d),f=g(e)?ac(e):e;return f.select(function(a){return b(c,a,d)})}):"function"==typeof a?u.call(this,a):u.call(this,function(){return a})},Nb.selectSwitch=Nb.flatMapLatest=function(a,b){return this.select(a,b).switchLatest()},Nb.skip=function(a){if(0>a)throw new Error(L);var b=this;return new gc(function(c){var d=a;return b.subscribe(function(a){0>=d?c.onNext(a):d--},c.onError.bind(c),c.onCompleted.bind(c))})},Nb.skipWhile=function(a,b){var c=this;return new gc(function(d){var e=0,f=!1;return c.subscribe(function(g){if(!f)try{f=!a.call(b,g,e++,c)}catch(h){return d.onError(h),void 0}f&&d.onNext(g)},d.onError.bind(d),d.onCompleted.bind(d))})},Nb.take=function(a,b){if(0>a)throw new Error(L);if(0===a)return Tb(b);var c=this;return new gc(function(b){var d=a;return c.subscribe(function(a){d>0&&(d--,b.onNext(a),0===d&&b.onCompleted())},b.onError.bind(b),b.onCompleted.bind(b))})},Nb.takeWhile=function(a,b){var c=this;return new gc(function(d){var e=0,f=!0;return c.subscribe(function(g){if(f){try{f=a.call(b,g,e++,c)}catch(h){return d.onError(h),void 0}f?d.onNext(g):d.onCompleted()}},d.onError.bind(d),d.onCompleted.bind(d))})},Nb.where=Nb.filter=function(a,b){var c=this;return new gc(function(d){var e=0;return c.subscribe(function(f){var g;try{g=a.call(b,f,e++,c)}catch(h){return d.onError(h),void 0}g&&d.onNext(f)},d.onError.bind(d),d.onCompleted.bind(d))})},Qb.fromCallback=function(a,b,c,d){return b||(b=yb),function(){var e=gb.call(arguments,0);return new gc(function(f){return b.schedule(function(){function b(a){var b=a;if(d)try{b=d(arguments)}catch(c){return f.onError(c),void 0}else 1===b.length&&(b=b[0]);f.onNext(b),f.onCompleted()}e.push(b),a.apply(c,e)})})}},Qb.fromNodeCallback=function(a,b,c,d){return b||(b=yb),function(){var e=gb.call(arguments,0);return new gc(function(f){return b.schedule(function(){function b(a){if(a)return f.onError(a),void 0; +var b=gb.call(arguments,1);if(d)try{b=d(b)}catch(c){return f.onError(c),void 0}else 1===b.length&&(b=b[0]);f.onNext(b),f.onCompleted()}e.push(b),a.apply(c,e)})})}},Qb.fromEvent=function(a,b,c){return new gc(function(d){return w(a,b,function(a){var b=a;if(c)try{b=c(arguments)}catch(e){return d.onError(e),void 0}d.onNext(b)})}).publish().refCount()},Qb.fromEventPattern=function(a,b,c){return new gc(function(d){function e(a){var b=a;if(c)try{b=c(arguments)}catch(e){return d.onError(e),void 0}d.onNext(b)}var f=a(e);return pb(function(){b&&b(e,f)})}).publish().refCount()};var ac=Qb.fromPromise=function(a){return new gc(function(b){a.then(function(a){b.onNext(a),b.onCompleted()},function(a){b.onError(a)})})};Nb.toPromise=function(a){if(a||(a=I.config.Promise),!a)throw new Error("Promise type not provided nor in Rx.config.Promise");var b=this;return new a(function(a,c){var d,e=!1;b.subscribe(function(a){d=a,e=!0},function(a){c(a)},function(){e&&a(d)})})},Qb.startAsync=function(a){var b;try{b=a()}catch(c){return Xb(c)}return ac(b)},Nb.multicast=function(a,b){var c=this;return"function"==typeof a?new gc(function(d){var e=c.multicast(a());return new mb(b(e).subscribe(d),e.connect())}):new bc(c,a)},Nb.publish=function(a){return a?this.multicast(function(){return new jc},a):this.multicast(new jc)},Nb.share=function(){return this.publish(null).refCount()},Nb.publishLast=function(a){return a?this.multicast(function(){return new kc},a):this.multicast(new kc)},Nb.publishValue=function(a,b){return 2===arguments.length?this.multicast(function(){return new mc(b)},a):this.multicast(new mc(a))},Nb.shareValue=function(a){return this.publishValue(a).refCount()},Nb.replay=function(a,b,c,d){return a?this.multicast(function(){return new nc(b,c,d)},a):this.multicast(new nc(b,c,d))},Nb.shareReplay=function(a,b,c){return this.replay(null,a,b,c).refCount()};var bc=I.ConnectableObservable=function(a){function b(b,c){function d(a){return e.subject.subscribe(a)}var e={subject:c,source:b.asObservable(),hasSubscription:!1,subscription:null};this.connect=function(){return e.hasSubscription||(e.hasSubscription=!0,e.subscription=new mb(e.source.subscribe(e.subject),pb(function(){e.hasSubscription=!1}))),e.subscription},a.call(this,d)}return hb(b,a),b.prototype.connect=function(){return this.connect()},b.prototype.refCount=function(){var a=null,b=0,c=this;return new gc(function(d){var e,f;return b++,e=1===b,f=c.subscribe(d),e&&(a=c.connect()),pb(function(){f.dispose(),b--,0===b&&a.dispose()})})},b}(Qb),cc=Qb.interval=function(a,b){return b||(b=Bb),y(a,a,b)},dc=Qb.timer=function(b,c,d){var e;return d||(d=Bb),"number"==typeof c?e=c:"object"==typeof c&&"now"in c&&(d=c),e===a?x(b,d):y(b,e,d)};Nb.delay=function(a,b){b||(b=Bb);var c=this;return new gc(function(d){var e,f=!1,g=new tb,h=null,i=[],j=!1;return e=c.materialize().timestamp(b).subscribe(function(c){var e,k;"E"===c.value.kind?(i=[],i.push(c),h=c.value.exception,k=!j):(i.push({value:c.value,timestamp:c.timestamp+a}),k=!f,f=!0),k&&(null!==h?d.onError(h):(e=new sb,g.setDisposable(e),e.setDisposable(b.scheduleRecursiveWithRelative(a,function(a){var c,e,g,k;if(null===h){j=!0;do g=null,i.length>0&&i[0].timestamp-b.now()<=0&&(g=i.shift().value),null!==g&&g.accept(d);while(null!==g);k=!1,e=0,i.length>0?(k=!0,e=Math.max(0,i[0].timestamp-b.now())):f=!1,c=h,j=!1,null!==c?d.onError(c):k&&a(e)}}))))}),new mb(e,g)})},Nb.throttle=function(a,b){b||(b=Bb);return this.throttleWithSelector(function(){return dc(a,b)})},Nb.timeInterval=function(a){var b=this;return a||(a=Bb),Sb(function(){var c=a.now();return b.select(function(b){var d=a.now(),e=d-c;return c=d,{value:b,interval:e}})})},Nb.timestamp=function(a){return a||(a=Bb),this.select(function(b){return{value:b,timestamp:a.now()}})},Nb.sample=function(a,b){return b||(b=Bb),"number"==typeof a?z(this,cc(a,b)):z(this,a)},Nb.timeout=function(a,b,c){var d,e=this;return b||(b=Xb(new Error("Timeout"))),c||(c=Bb),d=a instanceof Date?function(a,b){c.scheduleWithAbsolute(a,b)}:function(a,b){c.scheduleWithRelative(a,b)},new gc(function(c){var f,g=0,h=new sb,i=new tb,j=!1,k=new tb;return i.setDisposable(h),f=function(){var e=g;k.setDisposable(d(a,function(){j=g===e;var a=j;a&&i.setDisposable(b.subscribe(c))}))},f(),h.setDisposable(e.subscribe(function(a){var b=!j;b&&(g++,c.onNext(a),f())},function(a){var b=!j;b&&(g++,c.onError(a))},function(){var a=!j;a&&(g++,c.onCompleted())})),new mb(i,k)})},Qb.generateWithTime=function(a,b,c,d,e,f){return f||(f=Bb),new gc(function(g){var h,i,j=!0,k=!1,l=a;return f.scheduleRecursiveWithRelative(0,function(a){k&&g.onNext(h);try{j?j=!1:l=c(l),k=b(l),k&&(h=d(l),i=e(l))}catch(f){return g.onError(f),void 0}k?a(i):g.onCompleted()})})},Nb.delaySubscription=function(a,b){return b||(b=Bb),this.delayWithSelector(dc(a,b),function(){return Tb()})},Nb.delayWithSelector=function(a,b){var c,d,e=this;return"function"==typeof a?d=a:(c=a,d=b),new gc(function(a){var b=new mb,f=!1,g=function(){f&&0===b.length&&a.onCompleted()},h=new tb,i=function(){h.setDisposable(e.subscribe(function(c){var e;try{e=d(c)}catch(f){return a.onError(f),void 0}var h=new sb;b.add(h),h.setDisposable(e.subscribe(function(){a.onNext(c),b.remove(h),g()},a.onError.bind(a),function(){a.onNext(c),b.remove(h),g()}))},a.onError.bind(a),function(){f=!0,h.dispose(),g()}))};return c?h.setDisposable(c.subscribe(function(){i()},a.onError.bind(a),function(){i()})):i(),new mb(h,b)})},Nb.timeoutWithSelector=function(a,b,c){if(1===arguments.length){b=a;var a=Vb()}c||(c=Xb(new Error("Timeout")));var d=this;return new gc(function(e){var f=new tb,g=new tb,h=new sb;f.setDisposable(h);var i=0,j=!1,k=function(a){var b=i,d=function(){return i===b},h=new sb;g.setDisposable(h),h.setDisposable(a.subscribe(function(){d()&&f.setDisposable(c.subscribe(e)),h.dispose()},function(a){d()&&e.onError(a)},function(){d()&&f.setDisposable(c.subscribe(e))}))};k(a);var l=function(){var a=!j;return a&&i++,a};return h.setDisposable(d.subscribe(function(a){if(l()){e.onNext(a);var c;try{c=b(a)}catch(d){return e.onError(d),void 0}k(c)}},function(a){l()&&e.onError(a)},function(){l()&&e.onCompleted()})),new mb(f,g)})},Nb.throttleWithSelector=function(a){var b=this;return new gc(function(c){var d,e=!1,f=new tb,g=0,h=b.subscribe(function(b){var h;try{h=a(b)}catch(i){return c.onError(i),void 0}e=!0,d=b,g++;var j=g,k=new sb;f.setDisposable(k),k.setDisposable(h.subscribe(function(){e&&g===j&&c.onNext(d),e=!1,k.dispose()},c.onError.bind(c),function(){e&&g===j&&c.onNext(d),e=!1,k.dispose()}))},function(a){f.dispose(),c.onError(a),e=!1,g++},function(){f.dispose(),e&&c.onNext(d),c.onCompleted(),e=!1,g++});return new mb(h,f)})},Nb.skipLastWithTime=function(a,b){b||(b=Bb);var c=this;return new gc(function(d){var e=[];return c.subscribe(function(c){var f=b.now();for(e.push({interval:f,value:c});e.length>0&&f-e[0].interval>=a;)d.onNext(e.shift().value)},d.onError.bind(d),function(){for(var c=b.now();e.length>0&&c-e[0].interval>=a;)d.onNext(e.shift().value);d.onCompleted()})})},Nb.takeLastWithTime=function(a,b,c){return this.takeLastBufferWithTime(a,b).selectMany(function(a){return Ub(a,c)})},Nb.takeLastBufferWithTime=function(a,b){var c=this;return b||(b=Bb),new gc(function(d){var e=[];return c.subscribe(function(c){var d=b.now();for(e.push({interval:d,value:c});e.length>0&&d-e[0].interval>=a;)e.shift()},d.onError.bind(d),function(){for(var c=b.now(),f=[];e.length>0;){var g=e.shift();c-g.interval<=a&&f.push(g.value)}d.onNext(f),d.onCompleted()})})},Nb.takeWithTime=function(a,b){var c=this;return b||(b=Bb),new gc(function(d){var e=b.scheduleWithRelative(a,function(){d.onCompleted()});return new mb(e,c.subscribe(d))})},Nb.skipWithTime=function(a,b){var c=this;return b||(b=Bb),new gc(function(d){var e=!1,f=b.scheduleWithRelative(a,function(){e=!0}),g=c.subscribe(function(a){e&&d.onNext(a)},d.onError.bind(d),d.onCompleted.bind(d));return new mb(f,g)})},Nb.skipUntilWithTime=function(a,b){b||(b=Bb);var c=this;return new gc(function(d){var e=!1,f=b.scheduleWithAbsolute(a,function(){e=!0}),g=c.subscribe(function(a){e&&d.onNext(a)},d.onError.bind(d),d.onCompleted.bind(d));return new mb(f,g)})},Nb.takeUntilWithTime=function(a,b){b||(b=Bb);var c=this;return new gc(function(d){return new mb(b.scheduleWithAbsolute(a,function(){d.onCompleted()}),c.subscribe(d))})},Nb.pausable=function(a){var b=this;return new gc(function(c){var d=b.publish(),e=d.subscribe(c),f=qb,g=a.distinctUntilChanged().subscribe(function(a){a?f=d.connect():(f.dispose(),f=qb)});return new mb(e,f,g)})},Nb.pausableBuffered=function(a){var b=this;return new gc(function(c){var d=[],e=!0,f=A(b,a.distinctUntilChanged(),function(a,b){return{data:a,shouldFire:b}}).subscribe(function(a){if(a.shouldFire&&e&&c.onNext(a.data),a.shouldFire&&!e){for(;d.length>0;)c.onNext(d.shift());e=!0}else a.shouldFire||e?!a.shouldFire&&e&&(e=!1):d.push(a.data)},c.onError.bind(c),c.onCompleted.bind(c));return a.onNext(!1),f})},Nb.controlled=function(a){return null==a&&(a=!0),new ec(this,a)};var ec=function(a){function b(a){return this.source.subscribe(a)}function c(c,d){a.call(this,b),this.subject=new fc(d),this.source=c.multicast(this.subject).refCount()}return hb(c,a),c.prototype.request=function(a){return null==a&&(a=-1),this.subject.request(a)},c}(Qb),fc=I.ControlledSubject=function(a){function b(a){return this.subject.subscribe(a)}function c(c){null==c&&(c=!0),a.call(this,b),this.subject=new jc,this.enableQueue=c,this.queue=c?[]:null,this.requestedCount=0,this.requestedDisposable=qb,this.error=null,this.hasFailed=!1,this.hasCompleted=!1,this.controlledDisposable=qb}return hb(c,a),ib(c.prototype,Lb,{onCompleted:function(){h.call(this),this.hasCompleted=!0,this.enableQueue&&0!==this.queue.length||this.subject.onCompleted()},onError:function(a){h.call(this),this.hasFailed=!0,this.error=a,this.enableQueue&&0!==this.queue.length||this.subject.onError(a)},onNext:function(a){h.call(this);var b=!1;0===this.requestedCount?this.enableQueue&&this.queue.push(a):(-1!==this.requestedCount&&0===this.requestedCount--&&this.disposeCurrentRequest(),b=!0),b&&this.subject.onNext(a)},_processRequest:function(a){if(this.enableQueue){for(;this.queue.length>=a&&a>0;)this.subject.onNext(this.queue.shift()),a--;return 0!==this.queue.length?{numberOfItems:a,returnValue:!0}:{numberOfItems:a,returnValue:!1}}return this.hasFailed?(this.subject.onError(this.error),this.controlledDisposable.dispose(),this.controlledDisposable=qb):this.hasCompleted&&(this.subject.onCompleted(),this.controlledDisposable.dispose(),this.controlledDisposable=qb),{numberOfItems:a,returnValue:!1}},request:function(a){h.call(this),this.disposeCurrentRequest();var b=this,c=this._processRequest(a);return a=c.numberOfItems,c.returnValue?qb:(this.requestedCount=a,this.requestedDisposable=pb(function(){b.requestedCount=0}),this.requestedDisposable)},disposeCurrentRequest:function(){this.requestedDisposable.dispose(),this.requestedDisposable=qb},dispose:function(){this.isDisposed=!0,this.error=null,this.subject.dispose(),this.requestedDisposable.dispose()}}),c}(Qb),gc=I.AnonymousObservable=function(a){function b(a){return"undefined"==typeof a?a=qb:"function"==typeof a&&(a=pb(a)),a}function c(d){function e(a){var c=new hc(a);if(zb.scheduleRequired())zb.schedule(function(){try{c.setDisposable(b(d(c)))}catch(a){if(!c.fail(a))throw a}});else try{c.setDisposable(b(d(c)))}catch(e){if(!c.fail(e))throw e}return c}return this instanceof c?(a.call(this,e),void 0):new c(d)}return hb(c,a),c}(Qb),hc=function(a){function b(b){a.call(this),this.observer=b,this.m=new sb}hb(b,a);var c=b.prototype;return c.next=function(a){var b=!1;try{this.observer.onNext(a),b=!0}catch(c){throw c}finally{b||this.dispose()}},c.error=function(a){try{this.observer.onError(a)}catch(b){throw b}finally{this.dispose()}},c.completed=function(){try{this.observer.onCompleted()}catch(a){throw a}finally{this.dispose()}},c.setDisposable=function(a){this.m.setDisposable(a)},c.getDisposable=function(){return this.m.getDisposable()},c.disposable=function(a){return arguments.length?this.getDisposable():setDisposable(a)},c.dispose=function(){a.prototype.dispose.call(this),this.m.dispose()},b}(Ob),ic=function(a,b){this.subject=a,this.observer=b};ic.prototype.dispose=function(){if(!this.subject.isDisposed&&null!==this.observer){var a=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(a,1),this.observer=null}};var jc=I.Subject=function(a){function b(a){return h.call(this),this.isStopped?this.exception?(a.onError(this.exception),qb):(a.onCompleted(),qb):(this.observers.push(a),new ic(this,a))}function c(){a.call(this,b),this.isDisposed=!1,this.isStopped=!1,this.observers=[]}return hb(c,a),ib(c.prototype,Lb,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(h.call(this),!this.isStopped){var a=this.observers.slice(0);this.isStopped=!0;for(var b=0,c=a.length;c>b;b++)a[b].onCompleted();this.observers=[]}},onError:function(a){if(h.call(this),!this.isStopped){var b=this.observers.slice(0);this.isStopped=!0,this.exception=a;for(var c=0,d=b.length;d>c;c++)b[c].onError(a);this.observers=[]}},onNext:function(a){if(h.call(this),!this.isStopped)for(var b=this.observers.slice(0),c=0,d=b.length;d>c;c++)b[c].onNext(a)},dispose:function(){this.isDisposed=!0,this.observers=null}}),c.create=function(a,b){return new lc(a,b)},c}(Qb),kc=I.AsyncSubject=function(a){function b(a){if(h.call(this),!this.isStopped)return this.observers.push(a),new ic(this,a);var b=this.exception,c=this.hasValue,d=this.value;return b?a.onError(b):c?(a.onNext(d),a.onCompleted()):a.onCompleted(),qb}function c(){a.call(this,b),this.isDisposed=!1,this.isStopped=!1,this.value=null,this.hasValue=!1,this.observers=[],this.exception=null}return hb(c,a),ib(c.prototype,Lb,{hasObservers:function(){return h.call(this),this.observers.length>0},onCompleted:function(){var a,b,c;if(h.call(this),!this.isStopped){this.isStopped=!0;var d=this.observers.slice(0),e=this.value,f=this.hasValue;if(f)for(b=0,c=d.length;c>b;b++)a=d[b],a.onNext(e),a.onCompleted();else for(b=0,c=d.length;c>b;b++)d[b].onCompleted();this.observers=[]}},onError:function(a){if(h.call(this),!this.isStopped){var b=this.observers.slice(0);this.isStopped=!0,this.exception=a;for(var c=0,d=b.length;d>c;c++)b[c].onError(a);this.observers=[]}},onNext:function(a){h.call(this),this.isStopped||(this.value=a,this.hasValue=!0)},dispose:function(){this.isDisposed=!0,this.observers=null,this.exception=null,this.value=null}}),c}(Qb),lc=function(a){function b(a){return this.observable.subscribe(a)}function c(c,d){a.call(this,b),this.observer=c,this.observable=d}return hb(c,a),ib(c.prototype,Lb,{onCompleted:function(){this.observer.onCompleted()},onError:function(a){this.observer.onError(a)},onNext:function(a){this.observer.onNext(a)}}),c}(Qb),mc=I.BehaviorSubject=function(a){function b(a){if(h.call(this),!this.isStopped)return this.observers.push(a),a.onNext(this.value),new ic(this,a);var b=this.exception;return b?a.onError(b):a.onCompleted(),qb}function c(c){a.call(this,b),this.value=c,this.observers=[],this.isDisposed=!1,this.isStopped=!1,this.exception=null}return hb(c,a),ib(c.prototype,Lb,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(h.call(this),!this.isStopped){var a=this.observers.slice(0);this.isStopped=!0;for(var b=0,c=a.length;c>b;b++)a[b].onCompleted();this.observers=[]}},onError:function(a){if(h.call(this),!this.isStopped){var b=this.observers.slice(0);this.isStopped=!0,this.exception=a;for(var c=0,d=b.length;d>c;c++)b[c].onError(a);this.observers=[]}},onNext:function(a){if(h.call(this),!this.isStopped){this.value=a;for(var b=this.observers.slice(0),c=0,d=b.length;d>c;c++)b[c].onNext(a)}},dispose:function(){this.isDisposed=!0,this.observers=null,this.value=null,this.exception=null}}),c}(Qb),nc=I.ReplaySubject=function(a){function b(a,b){this.subject=a,this.observer=b}function c(a){var c=new Rb(this.scheduler,a),d=new b(this,c);h.call(this),this._trim(this.scheduler.now()),this.observers.push(c);for(var e=this.q.length,f=0,g=this.q.length;g>f;f++)c.onNext(this.q[f].value);return this.hasError?(e++,c.onError(this.error)):this.isStopped&&(e++,c.onCompleted()),c.ensureActive(e),d}function d(b,d,e){this.bufferSize=null==b?Number.MAX_VALUE:b,this.windowSize=null==d?Number.MAX_VALUE:d,this.scheduler=e||zb,this.q=[],this.observers=[],this.isStopped=!1,this.isDisposed=!1,this.hasError=!1,this.error=null,a.call(this,c)}return b.prototype.dispose=function(){if(this.observer.dispose(),!this.subject.isDisposed){var a=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(a,1)}},hb(d,a),ib(d.prototype,Lb,{hasObservers:function(){return this.observers.length>0},_trim:function(a){for(;this.q.length>this.bufferSize;)this.q.shift();for(;this.q.length>0&&a-this.q[0].interval>this.windowSize;)this.q.shift()},onNext:function(a){var b;if(h.call(this),!this.isStopped){var c=this.scheduler.now();this.q.push({interval:c,value:a}),this._trim(c);for(var d=this.observers.slice(0),e=0,f=d.length;f>e;e++)b=d[e],b.onNext(a),b.ensureActive()}},onError:function(a){var b;if(h.call(this),!this.isStopped){this.isStopped=!0,this.error=a,this.hasError=!0;var c=this.scheduler.now();this._trim(c);for(var d=this.observers.slice(0),e=0,f=d.length;f>e;e++)b=d[e],b.onError(a),b.ensureActive();this.observers=[]}},onCompleted:function(){var a;if(h.call(this),!this.isStopped){this.isStopped=!0;var b=this.scheduler.now();this._trim(b);for(var c=this.observers.slice(0),d=0,e=c.length;e>d;d++)a=c[d],a.onCompleted(),a.ensureActive();this.observers=[]}},dispose:function(){this.isDisposed=!0,this.observers=null}}),d}(Qb);"function"==typeof define&&"object"==typeof define.amd&&define.amd?(C.Rx=I,define(function(){return I})):D&&E?F?(E.exports=I).Rx=I:D.Rx=I:C.Rx=I}).call(this); \ No newline at end of file diff --git a/src/core/backpressure/controlledsubject.js b/src/core/backpressure/controlledsubject.js index 16ded55ff..8e60b1880 100644 --- a/src/core/backpressure/controlledsubject.js +++ b/src/core/backpressure/controlledsubject.js @@ -29,7 +29,7 @@ this.hasCompleted = true; if (!this.enableQueue || this.queue.length === 0) { - this.onCompleted(); + this.subject.onCompleted(); } }, onError: function (error) { @@ -38,7 +38,7 @@ this.error = error; if (!this.enableQueue || this.queue.length === 0) { - this.onError(error); + this.subject.onError(error); } }, onNext: function (value) { @@ -64,10 +64,10 @@ }, _processRequest: function (numberOfItems) { if (this.enableQueue) { - console.log('queue length', this.queue.length); + //console.log('queue length', this.queue.length); while (this.queue.length >= numberOfItems && numberOfItems > 0) { - console.log('number of items', numberOfItems); + //console.log('number of items', numberOfItems); this.subject.onNext(this.queue.shift()); numberOfItems--; } diff --git a/src/core/backpressure/pauseblebuffered.js b/src/core/backpressure/pausablebuffered.js similarity index 57% rename from src/core/backpressure/pauseblebuffered.js rename to src/core/backpressure/pausablebuffered.js index bae86e3a7..0a9e7a34f 100644 --- a/src/core/backpressure/pauseblebuffered.js +++ b/src/core/backpressure/pausablebuffered.js @@ -1,3 +1,47 @@ + function combineLatestSource(source, subject, resultSelector) { + return new AnonymousObservable(function (observer) { + var n = 2, + hasValue = [false, false], + hasValueAll = false, + isDone = false, + values = new Array(n); + + function next(x, i) { + values[i] = x + var res; + hasValue[i] = true; + if (hasValueAll || (hasValueAll = hasValue.every(identity))) { + try { + res = resultSelector.apply(null, values); + } catch (ex) { + observer.onError(ex); + return; + } + observer.onNext(res); + } else if (isDone) { + observer.onCompleted(); + } + } + + return new CompositeDisposable( + source.subscribe( + function (x) { + next(x, 0); + }, + observer.onError.bind(observer), + function () { + isDone = true; + observer.onCompleted(); + }), + subject.subscribe( + function (x) { + next(x, 1); + }, + observer.onError.bind(observer)) + ); + }); + } + /** * Pauses the underlying observable sequence based upon the observable sequence which yields true/false, * and yields the values that were buffered while paused. @@ -13,7 +57,8 @@ var q = [], previous = true; var subscription = - source.combineLatest( + combineLatestSource( + source, subject.distinctUntilChanged(), function (data, shouldFire) { return { data: data, shouldFire: shouldFire }; diff --git a/src/core/backpressureheader.js b/src/core/backpressureheader.js index cb247ee13..8ee5147fc 100644 --- a/src/core/backpressureheader.js +++ b/src/core/backpressureheader.js @@ -1,16 +1,16 @@ // References var Observable = Rx.Observable, observableProto = Observable.prototype, - AnonymousObservable = Rx.Internals.AnonymousObservable, + AnonymousObservable = Rx.AnonymousObservable, + CompositeDisposable = Rx.CompositeDisposable, Subject = Rx.Subject, Observer = Rx.Observer, disposableEmpty = Rx.Disposable.empty, disposableCreate = Rx.Disposable.create, - inherits = Rx.Internals.inherits, - addProperties = Rx.Internals.addProperties, + inherits = Rx.internals.inherits, + addProperties = Rx.internals.addProperties, timeoutScheduler = Rx.Scheduler.timeout; var objectDisposed = 'Object has been disposed'; - function checkDisposed() { - if (this.isDisposed) { throw new Error(objectDisposed); } - } + function checkDisposed() { if (this.isDisposed) { throw new Error(objectDisposed); } } + function identity (x) { return x; } diff --git a/tests/observable/controlled.js b/tests/observable/controlled.js new file mode 100644 index 000000000..f3428ec37 --- /dev/null +++ b/tests/observable/controlled.js @@ -0,0 +1,97 @@ +QUnit.module('Controlled'); + +var TestScheduler = Rx.TestScheduler, + onNext = Rx.ReactiveTest.onNext, + onError = Rx.ReactiveTest.onError, + onCompleted = Rx.ReactiveTest.onCompleted, + subscribe = Rx.ReactiveTest.subscribe; + +test('controlled gets some values', function () { + var subscription; + + var scheduler = new TestScheduler(); + + var results = scheduler.createObserver(); + + var xs = scheduler.createHotObservable( + onNext(150, 1), + onNext(210, 2), + onNext(230, 3), + onNext(301, 4), + onNext(350, 5), + onNext(399, 6), + onCompleted(500) + ); + + var controlled = xs.controlled(); + + scheduler.scheduleAbsolute(200, function () { + subscription = controlled.subscribe(results); + }); + + scheduler.scheduleAbsolute(400, function () { + controlled.request(5); + }); + + scheduler.scheduleAbsolute(1000, function () { + subscription.dispose(); + }); + + scheduler.start(); + + results.messages.assertEqual( + onNext(400, 2), + onNext(400, 3), + onNext(400, 4), + onNext(400, 5), + onNext(400, 6), + onCompleted(500) + ); +}); + +test('controlled gets two sets of values', function () { + var subscription; + + var scheduler = new TestScheduler(); + + var results = scheduler.createObserver(); + + var xs = scheduler.createHotObservable( + onNext(150, 1), + onNext(210, 2), + onNext(230, 3), + onNext(301, 4), + onNext(350, 5), + onNext(399, 6), + onCompleted(500) + ); + + var controlled = xs.controlled(); + + scheduler.scheduleAbsolute(200, function () { + subscription = controlled.subscribe(results); + }); + + scheduler.scheduleAbsolute(400, function () { + controlled.request(3); + }); + + scheduler.scheduleAbsolute(450, function () { + controlled.request(2); + }); + + scheduler.scheduleAbsolute(1000, function () { + subscription.dispose(); + }); + + scheduler.start(); + + results.messages.assertEqual( + onNext(400, 2), + onNext(400, 3), + onNext(400, 4), + onNext(450, 5), + onNext(450, 6), + onCompleted(500) + ); +}); \ No newline at end of file diff --git a/tests/observable/pausable.js b/tests/observable/pausable.js new file mode 100644 index 000000000..4d8c23fbb --- /dev/null +++ b/tests/observable/pausable.js @@ -0,0 +1,146 @@ +QUnit.module('Pausable'); + +var TestScheduler = Rx.TestScheduler, + Subject = Rx.Subject, + onNext = Rx.ReactiveTest.onNext, + onError = Rx.ReactiveTest.onError, + onCompleted = Rx.ReactiveTest.onCompleted, + subscribe = Rx.ReactiveTest.subscribe; + +test('paused_no_skip', function () { + var subscription; + + var scheduler = new TestScheduler(); + + var controller = new Subject(); + + var results = scheduler.createObserver(); + + var xs = scheduler.createHotObservable( + onNext(150, 1), + onNext(210, 2), + onNext(230, 3), + onNext(301, 4), + onNext(350, 5), + onNext(399, 6), + onCompleted(500) + ); + + scheduler.scheduleAbsolute(200, function () { + subscription = xs.pausable(controller).subscribe(results); + controller.onNext(true); + }); + + scheduler.scheduleAbsolute(205, function () { + controller.onNext(false); + }); + + scheduler.scheduleAbsolute(209, function () { + controller.onNext(true); + }); + + scheduler.scheduleAbsolute(1000, function () { + subscription.dispose(); + }); + + scheduler.start(); + + results.messages.assertEqual( + onNext(210, 2), + onNext(230, 3), + onNext(301, 4), + onNext(350, 5), + onNext(399, 6), + onCompleted(500) + ); +}); + +test('paused_skips', function () { + var subscription; + + var scheduler = new TestScheduler(); + + var controller = new Subject(); + + var results = scheduler.createObserver(); + + var xs = scheduler.createHotObservable( + onNext(150, 1), + onNext(210, 2), + onNext(230, 3), + onNext(301, 4), + onNext(350, 5), + onNext(399, 6), + onCompleted(500) + ); + + scheduler.scheduleAbsolute(200, function () { + subscription = xs.pausable(controller).subscribe(results); + controller.onNext(true); + }); + + scheduler.scheduleAbsolute(300, function () { + controller.onNext(false); + }); + + scheduler.scheduleAbsolute(400, function () { + controller.onNext(true); + }); + + scheduler.scheduleAbsolute(1000, function () { + subscription.dispose(); + }); + + scheduler.start(); + + results.messages.assertEqual( + onNext(210, 2), + onNext(230, 3), + onCompleted(500) + ); +}); + +test('paused_error', function () { + var subscription; + + var err = new Error(); + var scheduler = new TestScheduler(); + + var controller = new Subject(); + + var results = scheduler.createObserver(); + + var xs = scheduler.createHotObservable( + onNext(150, 1), + onNext(210, 2), + onError(230, err), + onNext(301, 4), + onNext(350, 5), + onNext(399, 6), + onCompleted(500) + ); + + scheduler.scheduleAbsolute(200, function () { + subscription = xs.pausable(controller).subscribe(results); + controller.onNext(true); + }); + + scheduler.scheduleAbsolute(300, function () { + controller.onNext(false); + }); + + scheduler.scheduleAbsolute(400, function () { + controller.onNext(true); + }); + + scheduler.scheduleAbsolute(1000, function () { + subscription.dispose(); + }); + + scheduler.start(); + + results.messages.assertEqual( + onNext(210, 2), + onError(230, err) + ); +}); \ No newline at end of file diff --git a/tests/observable/pausablebuffered.js b/tests/observable/pausablebuffered.js new file mode 100644 index 000000000..79883b6bd --- /dev/null +++ b/tests/observable/pausablebuffered.js @@ -0,0 +1,149 @@ +QUnit.module('PausableBuffered'); + +var TestScheduler = Rx.TestScheduler, + Subject = Rx.Subject, + onNext = Rx.ReactiveTest.onNext, + onError = Rx.ReactiveTest.onError, + onCompleted = Rx.ReactiveTest.onCompleted, + subscribe = Rx.ReactiveTest.subscribe; + +test('paused_no_skip', function () { + var subscription; + + var scheduler = new TestScheduler(); + + var controller = new Subject(); + + var results = scheduler.createObserver(); + + var xs = scheduler.createHotObservable( + onNext(150, 1), + onNext(210, 2), + onNext(230, 3), + onNext(301, 4), + onNext(350, 5), + onNext(399, 6), + onCompleted(500) + ); + + scheduler.scheduleAbsolute(200, function () { + subscription = xs.pausableBuffered(controller).subscribe(results); + controller.onNext(true); + }); + + scheduler.scheduleAbsolute(205, function () { + controller.onNext(false); + }); + + scheduler.scheduleAbsolute(209, function () { + controller.onNext(true); + }); + + scheduler.scheduleAbsolute(1000, function () { + subscription.dispose(); + }); + + scheduler.start(); + + results.messages.assertEqual( + onNext(210, 2), + onNext(230, 3), + onNext(301, 4), + onNext(350, 5), + onNext(399, 6), + onCompleted(500) + ); +}); + +test('paused_skips', function () { + var subscription; + + var scheduler = new TestScheduler(); + + var controller = new Subject(); + + var results = scheduler.createObserver(); + + var xs = scheduler.createHotObservable( + onNext(150, 1), + onNext(210, 2), + onNext(230, 3), + onNext(301, 4), + onNext(350, 5), + onNext(399, 6), + onCompleted(500) + ); + + scheduler.scheduleAbsolute(200, function () { + subscription = xs.pausableBuffered(controller).subscribe(results); + controller.onNext(true); + }); + + scheduler.scheduleAbsolute(300, function () { + controller.onNext(false); + }); + + scheduler.scheduleAbsolute(400, function () { + controller.onNext(true); + }); + + scheduler.scheduleAbsolute(1000, function () { + subscription.dispose(); + }); + + scheduler.start(); + + results.messages.assertEqual( + onNext(210, 2), + onNext(230, 3), + onNext(400, 4), + onNext(400, 5), + onNext(400, 6), + onCompleted(500) + ); +}); + +test('paused_error', function () { + var subscription; + + var err = new Error(); + var scheduler = new TestScheduler(); + + var controller = new Subject(); + + var results = scheduler.createObserver(); + + var xs = scheduler.createHotObservable( + onNext(150, 1), + onNext(210, 2), + onError(230, err), + onNext(301, 4), + onNext(350, 5), + onNext(399, 6), + onCompleted(500) + ); + + scheduler.scheduleAbsolute(200, function () { + subscription = xs.pausableBuffered(controller).subscribe(results); + controller.onNext(true); + }); + + scheduler.scheduleAbsolute(300, function () { + controller.onNext(false); + }); + + scheduler.scheduleAbsolute(400, function () { + controller.onNext(true); + }); + + scheduler.scheduleAbsolute(1000, function () { + subscription.dispose(); + }); + + scheduler.start(); + + results.messages.assertEqual( + onNext(210, 2), + onError(230, err) + ); +}); \ No newline at end of file diff --git a/tests/rx.backpressure.html b/tests/rx.backpressure.html new file mode 100644 index 000000000..0c9c075f1 --- /dev/null +++ b/tests/rx.backpressure.html @@ -0,0 +1,24 @@ + + + + + Reactive Extensions for JavaScript Tests + + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/rx.lite.compat.html b/tests/rx.lite.compat.html index dce663ee7..07cd2fa69 100644 --- a/tests/rx.lite.compat.html +++ b/tests/rx.lite.compat.html @@ -20,6 +20,10 @@ + + + + diff --git a/tests/rx.lite.html b/tests/rx.lite.html index 60e0adc31..0fe7e6db7 100644 --- a/tests/rx.lite.html +++ b/tests/rx.lite.html @@ -32,6 +32,10 @@ + + + +