forked from Reactive-Extensions/RxJS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrx.min.js
More file actions
2 lines (2 loc) · 37.9 KB
/
Copy pathrx.min.js
File metadata and controls
2 lines (2 loc) · 37.9 KB
1
2
!function(a,b){function c(){}function d(a){return a}function e(a,b){return P(a,b)}function f(a,b){return a-b}function g(a){return a.toString()}function h(a){throw a}function i(){if(this.isDisposed)throw new Error(A)}function j(a){return"function"!=typeof a.toString&&"string"==typeof(a+"")}function k(a){return a&&"object"==typeof a?L.call(a)==C:!1}function l(a){return"function"==typeof a}function m(a,b,c,d){var e;if(a===b)return 0!==a||1/a==1/b;var f=typeof a,g=typeof b;if(!(a!==a||a&&B[f]||b&&B[g]))return!1;if(null==a||null==b)return a===b;var h=L.call(a),i=L.call(b);if(h==C&&(h=I),i==C&&(i=I),h!=i)return!1;switch(h){case E:case F:return+a==+b;case H:return a!=+a?b!=+b:0==a?1/a==1/b:a==+b;case J:case K:return a==String(b)}var n=h==D;if(!n){if(h!=I||!v&&(j(a)||j(b)))return!1;var o=!N&&k(a)?Object:a.constructor,p=!N&&k(b)?Object:b.constructor;if(o!=p&&!(l(o)&&o instanceof o&&l(p)&&p instanceof p))return!1}for(var q=c.length;q--;)if(c[q]==a)return d[q]==b;var r=0;if(e=!0,c.push(a),d.push(b),n){for(q=a.length,r=b.length,e=r==a.length;r--;){var s=b[r];if(!(e=m(a[r],s,c,d)))break}return e}for(var t in b)if(M.call(b,t))return r++,e=M.call(a,t)&&m(a[t],b[t],c,d);if(e)for(var t in a)if(M.call(a,t))return e=--r>-1;return c.pop(),d.pop(),e}function n(a,b){return 1===a.length&&Array.isArray(a[b])?a[b]:Q.call(a)}function o(a,b){for(var c=new Array(a),d=0;a>d;d++)c[d]=b();return c}function p(a,b){this.scheduler=a,this.disposable=b,this.isDisposed=!1}function q(a,b){return new Qb(function(c){var d=new ab,e=new cb;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 ab,e.setDisposable(d),d.setDisposable(f.subscribe(c))},c.onCompleted.bind(c))),e})}function r(a,b){var c=this;return new Qb(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 s(a){return this.select(a).mergeObservable()}var t="object"==typeof exports&&exports,u=("object"==typeof module&&module&&module.exports==t&&module,"object"==typeof global&&global);u.global===u&&(a=u);var v,w={Internals:{}},x=Date.now,y="Sequence contains no elements.",z="Argument out of range",A="Object has been disposed",B={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},C="[object Arguments]",D="[object Array]",E="[object Boolean]",F="[object Date]",G="[object Function]",H="[object Number]",I="[object Object]",J="[object RegExp]",K="[object String]",L=Object.prototype.toString,M=Object.prototype.hasOwnProperty,N=L.call(arguments)==C;try{v=!(L.call(document)==I&&!({toString:0}+""))}catch(O){v=!0}N||(k=function(a){return a&&"object"==typeof a?M.call(a,"callee"):!1}),l(/x/)&&(l=function(a){return"function"==typeof a&&L.call(a)==G});var P=w.Internals.isEqual=function(a,b){return m(a,b,[],[])},Q=Array.prototype.slice;({}).hasOwnProperty;var R=this.inherits=w.Internals.inherits=function(a,b){function c(){this.constructor=a}c.prototype=b.prototype,a.prototype=new c},S=w.Internals.addProperties=function(a){for(var b=Q.call(arguments,1),c=0,d=b.length;d>c;c++){var e=b[c];for(var f in e)a[f]=e[f]}},T=w.Internals.addRef=function(a,b){return new Qb(function(c){return new X(b.getDisposable(),a.subscribe(c))})},U=function(a,b){this.id=a,this.value=b};U.prototype.compareTo=function(a){var b=this.value.compareTo(a.value);return 0===b&&(b=this.id-a.id),b};var V=w.Internals.PriorityQueue=function(a){this.items=new Array(a),this.length=0},W=V.prototype;W.isHigherPriority=function(a,b){return this.items[a].compareTo(this.items[b])<0},W.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)}}},W.heapify=function(a){if(a===b&&(a=0),!(a>=this.length||0>a)){var c=2*a+1,d=2*a+2,e=a;if(c<this.length&&this.isHigherPriority(c,e)&&(e=c),d<this.length&&this.isHigherPriority(d,e)&&(e=d),e!==a){var f=this.items[a];this.items[a]=this.items[e],this.items[e]=f,this.heapify(e)}}},W.peek=function(){return this.items[0].value},W.removeAt=function(a){this.items[a]=this.items[--this.length],delete this.items[this.length],this.heapify()},W.dequeue=function(){var a=this.peek();return this.removeAt(0),a},W.enqueue=function(a){var b=this.length++;this.items[b]=new U(V.count++,a),this.percolate(b)},W.remove=function(a){for(var b=0;b<this.length;b++)if(this.items[b].value===a)return this.removeAt(b),!0;return!1},V.count=0;var X=w.CompositeDisposable=function(){this.disposables=n(arguments,0),this.isDisposed=!1,this.length=this.disposables.length},Y=X.prototype;Y.add=function(a){this.isDisposed?a.dispose():(this.disposables.push(a),this.length++)},Y.remove=function(a){var b=!1;if(!this.isDisposed){var c=this.disposables.indexOf(a);-1!==c&&(b=!0,this.disposables.splice(c,1),this.length--,a.dispose())}return b},Y.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var a=this.disposables.slice(0);this.disposables=[],this.length=0;for(var b=0,c=a.length;c>b;b++)a[b].dispose()}},Y.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()},Y.contains=function(a){return-1!==this.disposables.indexOf(a)},Y.toArray=function(){return this.disposables.slice(0)};var Z=w.Disposable=function(a){this.isDisposed=!1,this.action=a||c};Z.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var $=Z.create=function(a){return new Z(a)},_=Z.empty={dispose:c},ab=w.SingleAssignmentDisposable=function(){this.isDisposed=!1,this.current=null},bb=ab.prototype;bb.getDisposable=function(){return this.current},ab.disposable=function(a){return arguments.length?this.getDisposable():this.setDisposable(a)},bb.setDisposable=function(a){if(this.current)throw new Error("Disposable has already been assigned");var b=this.isDisposed;b||(this.current=a),b&&a&&a.dispose()},bb.dispose=function(){var a;this.isDisposed||(this.isDisposed=!0,a=this.current,this.current=null),a&&a.dispose()};var cb=w.SerialDisposable=function(){this.isDisposed=!1,this.current=null},db=cb.prototype;db.getDisposable=function(){return this.current},db.setDisposable=function(a){var b,c=this.isDisposed;c||(b=this.current,this.current=a),b&&b.dispose(),c&&a&&a.dispose()},db.disposable=function(a){return a?(this.setDisposable(a),void 0):this.getDisposable()},db.dispose=function(){var a;this.isDisposed||(this.isDisposed=!0,a=this.current,this.current=null),a&&a.dispose()};var eb=w.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?_:new a(this)},b}();p.prototype.dispose=function(){var a=this;this.scheduler.schedule(function(){a.isDisposed||(a.isDisposed=!0,a.disposable.dispose())})};var fb=w.Internals.ScheduledItem=function(a,b,c,d,e){this.scheduler=a,this.state=b,this.action=c,this.dueTime=d,this.comparer=e||f,this.disposable=new ab};fb.prototype.invoke=function(){this.disposable.setDisposable(this.invokeCore())},fb.prototype.compareTo=function(a){return this.comparer(this.dueTime,a.dueTime)},fb.prototype.isCancelled=function(){return this.disposable.isDisposed},fb.prototype.invokeCore=function(){return this.action(this.scheduler,this.state)};var gb=w.Scheduler=function(){function b(a,b,c,d){this.now=a,this._schedule=b,this._scheduleRelative=c,this._scheduleAbsolute=d}function c(a,b){var c=b.first,d=b.second,e=new X,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),_});d||(e.add(g),c=!0)})};return f(c),e}function d(a,b,c){var d=b.first,e=b.second,f=new X,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),_});h||(f.add(i),e=!0)})};return g(d),f}function e(a,b){return b(),_}var f=b.prototype;return f.catchException=f["catch"]=function(a){return new mb(this,a)},f.schedulePeriodic=function(a,b){return this.schedulePeriodicWithState(null,a,function(){b()})},f.schedulePeriodicWithState=function(b,c,d){var e=b,f=a.setInterval(function(){e=d(e)},c);return $(function(){a.clearInterval(f)})},f.schedule=function(a){return this._schedule(a,e)},f.scheduleWithState=function(a,b){return this._schedule(a,b)},f.scheduleWithRelative=function(a,b){return this._scheduleRelative(b,a,e)},f.scheduleWithRelativeAndState=function(a,b,c){return this._scheduleRelative(a,b,c)},f.scheduleWithAbsolute=function(a,b){return this._scheduleAbsolute(b,a,e)},f.scheduleWithAbsoluteAndState=function(a,b,c){return this._scheduleAbsolute(a,b,c)},f.scheduleRecursive=function(a){return this.scheduleRecursiveWithState(a,function(a,b){a(function(){b(a)})})},f.scheduleRecursiveWithState=function(a,b){return this.scheduleWithState({first:a,second:b},function(a,b){return c(a,b)})},f.scheduleRecursiveWithRelative=function(a,b){return this.scheduleRecursiveWithRelativeAndState(b,a,function(a,b){a(function(c){b(a,c)})})},f.scheduleRecursiveWithRelativeAndState=function(a,b,c){return this._scheduleRelative({first:a,second:c},b,function(a,b){return d(a,b,"scheduleWithRelativeAndState")})},f.scheduleRecursiveWithAbsolute=function(a,b){return this.scheduleRecursiveWithAbsoluteAndState(b,a,function(a,b){a(function(c){b(a,c)})})},f.scheduleRecursiveWithAbsoluteAndState=function(a,b,c){return this._scheduleAbsolute({first:a,second:c},b,function(a,b){return d(a,b,"scheduleWithAbsoluteAndState")})},b.now=x,b.normalize=function(a){return 0>a&&(a=0),a},b}();w.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 ab;return this._cancel=b,b.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,a.bind(this))),b},b}();var hb,ib="Scheduler is not allowed to block the thread",jb=gb.immediate=function(){function a(a,b){return b(this,a)}function b(a,b,c){if(b>0)throw new Error(ib);return c(this,a)}function c(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}return new gb(x,a,b,c)}(),kb=gb.currentThread=function(){function a(){e=new V(4)}function b(a,b){return this.scheduleWithRelativeAndState(a,0,b)}function c(b,c,d){var f,g=this.now()+gb.normalize(c),h=new fb(this,b,d,g);if(e)e.enqueue(h);else{f=new a;try{e.enqueue(h),f.run()}catch(i){throw i}finally{f.dispose()}}return h.disposable}function d(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}var e;a.prototype.dispose=function(){e=null},a.prototype.run=function(){for(var a;e.length>0;)if(a=e.dequeue(),!a.isCancelled()){for(;a.dueTime-gb.now()>0;);a.isCancelled()||a.invoke()}};var f=new gb(x,b,c,d);return f.scheduleRequired=function(){return null===e},f.ensureTrampoline=function(a){return null===e?this.schedule(a):a()},f}(),lb=c;!function(){function b(){if(!a.postMessage||a.importScripts)return!1;var b=!1,c=a.onmessage;return a.onmessage=function(){b=!0},a.postMessage("","*"),a.onmessage=c,b}function c(a){if("string"==typeof a.data&&a.data.substring(0,d.length)===d){var b=a.data.substring(d.length),c=e[b];c(),delete e[b]}}if("function"==typeof a.setImmediate)hb=a.setImmediate,lb=clearImmediate;else if("undefined"!=typeof process&&"[object process]"==={}.toString.call(process))hb=process.nextTick;else if(b()){var d="ms.rx.schedule"+Math.random(),e={},f=0;a.addEventListener?a.addEventListener("message",c,!1):a.attachEvent("onmessage",c,!1),hb=function(b){var c=f++;e[c]=b,a.postMessage(d+c,"*")}}else if(a.MessageChannel){var g=new a.MessageChannel,h={},i=0;g.port1.onmessage=function(a){var b=a.data,c=h[b];c(),delete h[b]},hb=function(a){var b=i++;h[b]=a,g.port2.postMessage(b)}}else"document"in a&&"onreadystatechange"in a.document.createElement("script")?hb=function(b){var c=a.document.createElement("script");c.onreadystatechange=function(){b(),c.onreadystatechange=null,c.parentNode.removeChild(c),c=null},a.document.documentElement.appendChild(c)}:(hb=function(b){return a.setTimeout(b,0)},lb=a.clearTimeout)}(),gb.timeout=function(){function b(a,b){var c=this,d=new ab,e=hb(function(){d.isDisposed||d.setDisposable(b(c,a))});return new X(d,$(function(){lb(e)}))}function c(b,c,d){var e=this,f=gb.normalize(c);if(0===f)return e.scheduleWithState(b,d);var g=new ab,h=a.setTimeout(function(){g.isDisposed||g.setDisposable(d(e,b))},f);return new X(g,$(function(){a.clearTimeout(h)}))}function d(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}return new gb(x,b,c,d)}();var mb=function(a){function b(){return this._scheduler.now()}function c(a,b){return this._scheduler.scheduleWithState(a,this._wrap(b))}function d(a,b,c){return this._scheduler.scheduleWithRelativeAndState(a,b,this._wrap(c))}function e(a,b,c){return this._scheduler.scheduleWithAbsoluteAndState(a,b,this._wrap(c))}function f(f,g){this._scheduler=f,this._handler=g,this._recursiveOriginal=null,this._recursiveWrapper=null,a.call(this,b,c,d,e)}return R(f,a),f.prototype._clone=function(a){return new f(a,this._handler)},f.prototype._wrap=function(a){var b=this;return function(c,d){try{return a(b._getRecursiveWrapper(c),d)}catch(e){if(!b._handler(e))throw e;return _}}},f.prototype._getRecursiveWrapper=function(a){if(this._recursiveOriginal!==a){this._recursiveOriginal=a;var b=this._clone(a);b._recursiveOriginal=a,b._recursiveWrapper=b,this._recursiveWrapper=b}return this._recursiveWrapper},f.prototype.schedulePeriodicWithState=function(a,b,c){var d=this,e=!1,f=new ab;return f.setDisposable(this._scheduler.schedulePeriodicWithState(a,b,function(a){if(e)return null;try{return c(a)}catch(b){if(e=!0,!d._handler(b))throw b;return f.dispose(),null}})),f},f}(gb),nb=w.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=jb),new Qb(function(c){return a.schedule(function(){b._acceptObservable(c),"N"===b.kind&&c.onCompleted()})})},a}(),ob=nb.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 nb("N",!0);return e.value=d,e._accept=a,e._acceptObservable=b,e.toString=c,e}}(),pb=nb.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 nb("E");return e.exception=d,e._accept=a,e._acceptObservable=b,e.toString=c,e}}(),qb=nb.createOnCompleted=function(){function a(a,b,c){return c()}function b(a){return a.onCompleted()}function c(){return"OnCompleted()"}return function(){var d=new nb("C");return d._accept=a,d._acceptObservable=b,d.toString=c,d}}(),rb=w.Internals.Enumerator=function(a,b,c){this.moveNext=a,this.getCurrent=b,this.dispose=c},sb=rb.create=function(a,b,d){var e=!1;return d||(d=c),new rb(function(){if(e)return!1;var b=a();return b||(e=!0,d()),b},function(){return b()},function(){e||(d(),e=!0)})},tb=w.Internals.Enumerable=function(){function a(a){this.getEnumerator=a}return a.prototype.concat=function(){var a=this;return new Qb(function(b){var c=a.getEnumerator(),d=!1,e=new cb,f=jb.scheduleRecursive(function(a){var f,g,h=!1;if(!d){try{h=c.moveNext(),h?f=c.getCurrent():c.dispose()}catch(i){g=i,c.dispose()}if(g)return b.onError(g),void 0;if(!h)return b.onCompleted(),void 0;var j=new ab;e.setDisposable(j),j.setDisposable(f.subscribe(b.onNext.bind(b),b.onError.bind(b),function(){a()}))}});return new X(e,f,$(function(){d=!0,c.dispose()}))})},a.prototype.catchException=function(){var a=this;return new Qb(function(b){var c,d=a.getEnumerator(),e=!1,f=new cb,g=jb.scheduleRecursive(function(a){var g,h,i;if(i=!1,!e){try{i=d.moveNext(),i&&(g=d.getCurrent())}catch(j){h=j}if(h)return b.onError(h),void 0;if(!i)return c?b.onError(c):b.onCompleted(),void 0;var k=new ab;f.setDisposable(k),k.setDisposable(g.subscribe(b.onNext.bind(b),function(b){c=b,a()},b.onCompleted.bind(b)))}});return new X(f,g,$(function(){e=!0}))})},a}(),ub=tb.repeat=function(a,c){return c===b&&(c=-1),new tb(function(){var b,d=c;return sb(function(){return 0===d?!1:(d>0&&d--,b=a,!0)},function(){return b})})},vb=tb.forEach=function(a,b){return b||(b=d),new tb(function(){var c,d=-1;return sb(function(){return++d<a.length?(c=b(a[d],d),!0):!1},function(){return c})})},wb=w.Observer=function(){};wb.prototype.toNotifier=function(){var a=this;return function(b){return b.accept(a)}},wb.prototype.asObserver=function(){return new Ab(this.onNext.bind(this),this.onError.bind(this),this.onCompleted.bind(this))},wb.prototype.checked=function(){return new Bb(this)};var xb=wb.create=function(a,b,d){return a||(a=c),b||(b=h),d||(d=c),new Ab(a,b,d)};wb.fromNotifier=function(a){return new Ab(function(b){return a(ob(b))},function(b){return a(pb(b))},function(){return a(qb())})},wb.notifyOn=function(a){return new Db(a,this)};var yb,zb=w.Internals.AbstractObserver=function(a){function b(){this.isStopped=!1,a.call(this)}return R(b,a),b.prototype.onNext=function(a){this.isStopped||this.next(a)},b.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.error(a))},b.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.completed())},b.prototype.dispose=function(){this.isStopped=!0},b.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.error(a),!0)},b}(wb),Ab=w.AnonymousObserver=function(a){function b(b,c,d){a.call(this),this._onNext=b,this._onError=c,this._onCompleted=d}return R(b,a),b.prototype.next=function(a){this._onNext(a)},b.prototype.error=function(a){this._onError(a)},b.prototype.completed=function(){this._onCompleted()},b}(zb),Bb=function(a){function b(b){a.call(this),this._observer=b,this._state=0}R(b,a);var c=b.prototype;return c.onNext=function(a){this.checkAccess();try{this._observer.onNext(a)}catch(b){throw b}finally{this._state=0}},c.onError=function(a){this.checkAccess();try{this._observer.onError(a)}catch(b){throw b}finally{this._state=2}},c.onCompleted=function(){this.checkAccess();try{this._observer.onCompleted()}catch(a){throw a}finally{this._state=2}},c.checkAccess=function(){if(1===this._state)throw new Error("Re-entrancy detected");if(2===this._state)throw new Error("Observer completed");0===this._state&&(this._state=1)},b}(wb),Cb=w.Internals.ScheduledObserver=function(a){function b(b,c){a.call(this),this.scheduler=b,this.observer=c,this.isAcquired=!1,this.hasFaulted=!1,this.queue=[],this.disposable=new cb}return R(b,a),b.prototype.next=function(a){var b=this;this.queue.push(function(){b.observer.onNext(a)})},b.prototype.error=function(a){var b=this;this.queue.push(function(){b.observer.onError(a)})},b.prototype.completed=function(){var a=this;this.queue.push(function(){a.observer.onCompleted()})},b.prototype.ensureActive=function(){var a=!1,b=this;!this.hasFaulted&&this.queue.length>0&&(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}(zb),Db=function(a){function b(){a.apply(this,arguments)}return R(b,a),b.prototype.next=function(b){a.prototype.next.call(this,b),this.ensureActive()},b.prototype.error=function(b){a.prototype.error.call(this,b),this.ensureActive()},b.prototype.completed=function(){a.prototype.completed.call(this),this.ensureActive()},b}(Cb),Eb=w.Observable=function(){function a(a){this._subscribe=a}return yb=a.prototype,yb.finalValue=function(){var a=this;return new Qb(function(b){var c,d=!1;return a.subscribe(function(a){d=!0,c=a},b.onError.bind(b),function(){d?(b.onNext(c),b.onCompleted()):b.onError(new Error(y))})})},yb.subscribe=yb.forEach=function(a,b,c){var d;return d="object"==typeof a?a:xb(a,b,c),this._subscribe(d)},yb.toArray=function(){function a(a,b){var c=a.slice(0);return c.push(b),c}return this.scan([],a).startWith([]).finalValue()},a}();yb.observeOn=function(a){var b=this;return new Qb(function(c){return b.subscribe(new Db(a,c))})},yb.subscribeOn=function(a){var b=this;return new Qb(function(c){var d=new ab,e=new cb;return e.setDisposable(d),d.setDisposable(a.schedule(function(){e.setDisposable(new p(a,b.subscribe(c)))})),e})},Eb.create=function(a){return new Qb(function(b){return $(a(b))})},Eb.createWithDisposable=function(a){return new Qb(a)};var Fb=Eb.defer=function(a){return new Qb(function(b){var c;try{c=a()}catch(d){return Kb(d).subscribe(b)}return c.subscribe(b)})},Gb=Eb.empty=function(a){return a||(a=jb),new Qb(function(b){return a.schedule(function(){b.onCompleted()})})},Hb=Eb.fromArray=function(a,b){return b||(b=kb),new Qb(function(c){var d=0;return b.scheduleRecursive(function(b){d<a.length?(c.onNext(a[d++]),b()):c.onCompleted()})})};Eb.generate=function(a,b,c,d,e){return e||(e=kb),new Qb(function(f){var g=!0,h=a;return e.scheduleRecursive(function(a){var e,i;try{g?g=!1:h=c(h),e=b(h),e&&(i=d(h))}catch(j){return f.onError(j),void 0}e?(f.onNext(i),a()):f.onCompleted()})})};var Ib=Eb.never=function(){return new Qb(function(){return _})};Eb.range=function(a,b,c){return c||(c=kb),new Qb(function(d){return c.scheduleRecursiveWithState(0,function(c,e){b>c?(d.onNext(a+c),e(c+1)):d.onCompleted()})})},Eb.repeat=function(a,b,c){return c||(c=kb),null==b&&(b=-1),Jb(a,c).repeat(b)};var Jb=Eb["return"]=Eb.returnValue=function(a,b){return b||(b=jb),new Qb(function(c){return b.schedule(function(){c.onNext(a),c.onCompleted()})})},Kb=Eb["throw"]=Eb.throwException=function(a,b){return b||(b=jb),new Qb(function(c){return b.schedule(function(){c.onError(a)})})};Eb.using=function(a,b){return new Qb(function(c){var d,e,f=_;try{d=a(),d&&(f=d),e=b(d)}catch(g){return new X(Kb(g).subscribe(c),f)}return new X(e.subscribe(c),f)})},yb.amb=function(a){var b=this;return new Qb(function(c){function d(){f||(f=g,j.dispose())}function e(){f||(f=h,i.dispose())}var f,g="L",h="R",i=new ab,j=new ab;return i.setDisposable(b.subscribe(function(a){d(),f===g&&c.onNext(a)},function(a){d(),f===g&&c.onError(a)},function(){d(),f===g&&c.onCompleted()})),j.setDisposable(a.subscribe(function(a){e(),f===h&&c.onNext(a)},function(a){e(),f===h&&c.onError(a)},function(){e(),f===h&&c.onCompleted()})),new X(i,j)})},Eb.amb=function(){function a(a,b){return a.amb(b)}for(var b=Ib(),c=n(arguments,0),d=0,e=c.length;e>d;d++)b=a(b,c[d]);return b},yb["catch"]=yb.catchException=function(a){return"function"==typeof a?q(this,a):Lb([this,a])};var Lb=Eb.catchException=Eb["catch"]=function(){var a=n(arguments,0);return vb(a).catchException()};yb.combineLatest=function(){var a=Q.call(arguments);return Array.isArray(a[0])?a[0].unshift(this):a.unshift(this),Mb.apply(this,a)};var Mb=Eb.combineLatest=function(){var a=Q.call(arguments),b=a.pop();return Array.isArray(a[0])&&(a=a[0]),new Qb(function(c){function e(a){var e;if(i[a]=!0,j||(j=i.every(d))){try{e=b.apply(null,l)}catch(f){return c.onError(f),void 0}c.onNext(e)}else k.filter(function(b,c){return c!==a}).every(d)&&c.onCompleted()}function f(a){k[a]=!0,k.every(d)&&c.onCompleted()}for(var g=function(){return!1},h=a.length,i=o(h,g),j=!1,k=o(h,g),l=new Array(h),m=new Array(h),n=0;h>n;n++)!function(b){m[b]=new ab,m[b].setDisposable(a[b].subscribe(function(a){l[b]=a,e(b)},c.onError.bind(c),function(){f(b)}))}(n);return new X(m)})};yb.concat=function(){var a=Q.call(arguments,0);return a.unshift(this),Nb.apply(this,a)};var Nb=Eb.concat=function(){var a=n(arguments,0);return vb(a).concat()};yb.concatObservable=yb.concatAll=function(){return this.merge(1)},yb.merge=function(a){if("number"!=typeof a)return Ob(this,a);var b=this;return new Qb(function(c){var d=0,e=new X,f=!1,g=[],h=function(a){var b=new ab;e.add(b),b.setDisposable(a.subscribe(c.onNext.bind(c),c.onError.bind(c),function(){var a;e.remove(b),g.length>0?(a=g.shift(),h(a)):(d--,f&&0===d&&c.onCompleted())}))};return e.add(b.subscribe(function(b){a>d?(d++,h(b)):g.push(b)},c.onError.bind(c),function(){f=!0,0===d&&c.onCompleted()})),e})};var Ob=Eb.merge=function(){var a,b;return arguments[0]?arguments[0].now?(a=arguments[0],b=Q.call(arguments,1)):(a=jb,b=Q.call(arguments,0)):(a=jb,b=Q.call(arguments,1)),Array.isArray(b[0])&&(b=b[0]),Hb(b,a).mergeObservable()};yb.mergeObservable=yb.mergeAll=function(){var a=this;return new Qb(function(b){var c=new X,d=!1,e=new ab;return c.add(e),e.setDisposable(a.subscribe(function(a){var e=new ab;c.add(e),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})},yb.onErrorResumeNext=function(a){if(!a)throw new Error("Second observable is required");return Pb([this,a])};var Pb=Eb.onErrorResumeNext=function(){var a=n(arguments,0);return new Qb(function(b){var c=0,d=new cb,e=jb.scheduleRecursive(function(e){var f,g;c<a.length?(f=a[c++],g=new ab,d.setDisposable(g),g.setDisposable(f.subscribe(b.onNext.bind(b),function(){e()},function(){e()}))):b.onCompleted()});return new X(d,e)})};yb.skipUntil=function(a){var b=this;return new Qb(function(c){var d=!1,e=new X(b.subscribe(function(a){d&&c.onNext(a)},c.onError.bind(c),function(){d&&c.onCompleted()})),f=new ab;return e.add(f),f.setDisposable(a.subscribe(function(){d=!0,f.dispose()},c.onError.bind(c),function(){f.dispose()})),e})},yb["switch"]=yb.switchLatest=function(){var a=this;return new Qb(function(b){var c=!1,d=new cb,e=!1,f=0,g=a.subscribe(function(a){var g=new ab,h=++f;c=!0,d.setDisposable(g),g.setDisposable(a.subscribe(function(a){f===h&&b.onNext(a)},function(a){f===h&&b.onError(a)},function(){f===h&&(c=!1,e&&b.onCompleted())}))},b.onError.bind(b),function(){e=!0,c||b.onCompleted()});return new X(g,d)})},yb.takeUntil=function(a){var b=this;return new Qb(function(d){return new X(b.subscribe(d),a.subscribe(d.onCompleted.bind(d),d.onError.bind(d),c))})},yb.zip=function(){if(Array.isArray(arguments[0]))return r.apply(this,arguments);var a=this,b=Q.call(arguments),c=b.pop();return b.unshift(a),new Qb(function(e){function f(a){i[a]=!0,i.every(function(a){return a})&&e.onCompleted()}for(var g=b.length,h=o(g,function(){return[]}),i=o(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=c.apply(a,g)}catch(j){return e.onError(j),void 0}e.onNext(f)}else i.filter(function(a,c){return c!==b}).every(d)&&e.onCompleted()},k=new Array(g),l=0;g>l;l++)!function(a){k[a]=new ab,k[a].setDisposable(b[a].subscribe(function(b){h[a].push(b),j(a)},e.onError.bind(e),function(){f(a)}))}(l);return new X(k)})},Eb.zip=function(){var a=Q.call(arguments,0),b=a.shift();return b.zip.apply(b,a)},Eb.zipArray=function(){var a=Q.call(arguments);return new Qb(function(b){function c(a){if(g.every(function(a){return a.length>0})){var c=g.map(function(a){return a.shift()});b.onNext(c)}else if(h.filter(function(b,c){return c!==a}).every(d))return b.onCompleted(),void 0}function e(a){return h[a]=!0,h.every(d)?(b.onCompleted(),void 0):void 0}for(var f=a.length,g=o(f,function(){return[]}),h=o(f,function(){return!1}),i=new Array(f),j=0;f>j;j++)!function(d){i[d]=new ab,i[d].setDisposable(a[d].subscribe(function(a){g[d].push(a),c(d)},b.onError.bind(b),function(){e(d)}))}(j);var k=new X(i);return k.add($(function(){for(var a=0,b=g.length;b>a;a++)g[a]=[]})),k})},yb.asObservable=function(){var a=this;return new Qb(function(b){return a.subscribe(b)})},yb.bufferWithCount=function(a,c){return c===b&&(c=a),this.windowWithCount(a,c).selectMany(function(a){return a.toArray()}).where(function(a){return a.length>0})},yb.dematerialize=function(){var a=this;return new Qb(function(b){return a.subscribe(function(a){return a.accept(b)},b.onError.bind(b),b.onCompleted.bind(b))})},yb.distinctUntilChanged=function(a,b){var c=this;return a||(a=d),b||(b=e),new Qb(function(d){var e,f=!1;return c.subscribe(function(c){var g,h=!1;try{g=a(c)}catch(i){return d.onError(i),void 0}if(f)try{h=b(e,g)}catch(i){return d.onError(i),void 0}f&&h||(f=!0,e=g,d.onNext(c))},d.onError.bind(d),d.onCompleted.bind(d))})},yb["do"]=yb.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 Qb(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()})})},yb["finally"]=yb.finallyAction=function(a){var b=this;return new Qb(function(c){var d=b.subscribe(c);return $(function(){try{d.dispose()}catch(b){throw b}finally{a()}})})},yb.ignoreElements=function(){var a=this;return new Qb(function(b){return a.subscribe(c,b.onError.bind(b),b.onCompleted.bind(b))})},yb.materialize=function(){var a=this;return new Qb(function(b){return a.subscribe(function(a){b.onNext(ob(a))},function(a){b.onNext(pb(a)),b.onCompleted()},function(){b.onNext(qb()),b.onCompleted()})})},yb.repeat=function(a){return ub(this,a).concat()},yb.retry=function(a){return ub(this,a).catchException()},yb.scan=function(){var a,b,c=!1;2===arguments.length?(a=arguments[0],b=arguments[1],c=!0):b=arguments[0];var d=this;return Fb(function(){var e,f=!1;return d.select(function(d){return f?e=b(e,d):(e=c?b(a,d):d,f=!0),e})})},yb.skipLast=function(a){var b=this;return new Qb(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))})},yb.startWith=function(){var a,b,c=0;return arguments.length&&"now"in Object(arguments[0])?(b=arguments[0],c=1):b=jb,a=Q.call(arguments,c),vb([Hb(a,b),this]).concat()},yb.takeLast=function(a,b){return this.takeLastBuffer(a).selectMany(function(a){return Hb(a,b)})},yb.takeLastBuffer=function(a){var b=this;return new Qb(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()})})},yb.windowWithCount=function(a,b){var c=this;if(0>=a)throw new Error(z);if(null==b&&(b=a),0>=b)throw new Error(z);return new Qb(function(d){var e=new ab,f=new eb(e),g=0,h=[],i=function(){var a=new Ub;h.push(a),d.onNext(T(a,f))};return i(),e.setDisposable(c.subscribe(function(c){for(var d,e=0,f=h.length;f>e;e++)h[e].onNext(c);var j=g-a+1;j>=0&&0===j%b&&(d=h.shift(),d.onCompleted()),g++,0===g%b&&i()},function(a){for(;h.length>0;)h.shift().onError(a);d.onError(a)},function(){for(;h.length>0;)h.shift().onCompleted();d.onCompleted()})),f})},yb.defaultIfEmpty=function(a){var c=this;return a===b&&(a=null),new Qb(function(b){var d=!1;return c.subscribe(function(a){d=!0,b.onNext(a)},b.onError.bind(b),function(){d||b.onNext(a),b.onCompleted()})})},yb.distinct=function(a,b){var c=this;return a||(a=d),b||(b=g),new Qb(function(d){var e={};return c.subscribe(function(c){var f,g,h,i=!1;try{f=a(c),g=b(f)}catch(j){return d.onError(j),void 0}for(h in e)if(g===h){i=!0;break}i||(e[g]=null,d.onNext(c))},d.onError.bind(d),d.onCompleted.bind(d))})},yb.groupBy=function(a,b,c){return this.groupByUntil(a,b,function(){return Ib()
},c)},yb.groupByUntil=function(a,b,e,f){var h=this;return b||(b=d),f||(f=g),new Qb(function(d){var g={},i=new X,j=new eb(i);return i.add(h.subscribe(function(h){var k,l,m,n,o,p,q,r,s,t;try{p=a(h),q=f(p)}catch(u){for(t in g)g[t].onError(u);return d.onError(u),void 0}n=!1;try{s=g[q],s||(s=new Ub,g[q]=s,n=!0)}catch(u){for(t in g)g[t].onError(u);return d.onError(u),void 0}if(n){o=new Sb(p,s,j),l=new Sb(p,s);try{k=e(l)}catch(u){for(t in g)g[t].onError(u);return d.onError(u),void 0}d.onNext(o),r=new ab,i.add(r);var v=function(){q in g&&(delete g[q],s.onCompleted()),i.remove(r)};r.setDisposable(k.take(1).subscribe(c,function(a){for(t in g)g[t].onError(a);d.onError(a)},function(){v()}))}try{m=b(h)}catch(u){for(t in g)g[t].onError(u);return d.onError(u),void 0}s.onNext(m)},function(a){for(var b in g)g[b].onError(a);d.onError(a)},function(){for(var a in g)g[a].onCompleted();d.onCompleted()})),j})},yb.select=yb.map=function(a,b){var c=this;return new Qb(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))})},yb.pluck=function(a){return this.select(function(b){return b[a]})},yb.selectMany=yb.flatMap=function(a,b){return b?this.selectMany(function(c){return a(c).select(function(a){return b(c,a)})}):"function"==typeof a?s.call(this,a):s.call(this,function(){return a})},yb.selectSwitch=yb.flatMapLatest=function(a,b){return this.select(a,b).switchLatest()},yb.skip=function(a){if(0>a)throw new Error(z);var b=this;return new Qb(function(c){var d=a;return b.subscribe(function(a){0>=d?c.onNext(a):d--},c.onError.bind(c),c.onCompleted.bind(c))})},yb.skipWhile=function(a,b){var c=this;return new Qb(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))})},yb.take=function(a,b){if(0>a)throw new Error(z);if(0===a)return Gb(b);var c=this;return new Qb(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))})},yb.takeWhile=function(a,b){var c=this;return new Qb(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))})},yb.where=yb.filter=function(a,b){var c=this;return new Qb(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))})};var Qb=w.Internals.AnonymousObservable=function(a){function b(c){function d(a){var b=new Rb(a);if(kb.scheduleRequired())kb.schedule(function(){try{b.setDisposable(c(b))}catch(a){if(!b.fail(a))throw a}});else try{b.setDisposable(c(b))}catch(d){if(!b.fail(d))throw d}return b}return this instanceof b?(a.call(this,d),void 0):new b(c)}return R(b,a),b}(Eb),Rb=function(a){function b(b){a.call(this),this.observer=b,this.m=new ab}R(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}(zb),Sb=function(a){function b(a){return this.underlyingObservable.subscribe(a)}function c(c,d,e){a.call(this,b),this.key=c,this.underlyingObservable=e?new Qb(function(a){return new X(e.getDisposable(),d.subscribe(a))}):d}return R(c,a),c}(Eb),Tb=function(a,b){this.subject=a,this.observer=b};Tb.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 Ub=w.Subject=function(a){function b(a){return i.call(this),this.isStopped?this.exception?(a.onError(this.exception),_):(a.onCompleted(),_):(this.observers.push(a),new Tb(this,a))}function c(){a.call(this,b),this.isDisposed=!1,this.isStopped=!1,this.observers=[]}return R(c,a),S(c.prototype,wb,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(i.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(i.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(i.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 Vb(a,b)},c}(Eb);w.AsyncSubject=function(a){function b(a){if(i.call(this),!this.isStopped)return this.observers.push(a),new Tb(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(),_}function c(){a.call(this,b),this.isDisposed=!1,this.isStopped=!1,this.value=null,this.hasValue=!1,this.observers=[],this.exception=null}return R(c,a),S(c.prototype,wb,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){var a,b,c;if(i.call(this),!this.isStopped){var d=this.observers.slice(0);this.isStopped=!0;var 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(i.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){i.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}(Eb);var Vb=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 R(c,a),S(c.prototype,wb,{onCompleted:function(){this.observer.onCompleted()},onError:function(a){this.observer.onError(a)},onNext:function(a){this.observer.onNext(a)}}),c}(Eb);return"function"==typeof define&&"object"==typeof define.amd&&define.amd?(a.Rx=w,define(function(){return w})):(t?"object"==typeof module&&module&&module.exports==t?module.exports=w:t=w:a.Rx=w,void 0)}(this);