Socket
Socket
Sign inDemoInstall

rx

Package Overview
Dependencies
Maintainers
2
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rx - npm Package Compare versions

Comparing version 2.1.1 to 2.1.2

2

package.json

@@ -5,3 +5,3 @@ {

"description": "Library for composing asynchronous and event-based operations in JavaScript",
"version": "2.1.1",
"version": "2.1.2",
"homepage": "http://rx.codeplex.com",

@@ -8,0 +8,0 @@ "author": {

@@ -1,2 +0,2 @@

(function(t,e){function n(){}function r(t){return t}function i(){return(new Date).getTime()}function o(t,e){return t===e}function s(t,e){return t-e}function u(t){return""+t}function c(t){throw t}function a(){if(this.isDisposed)throw Error(E)}function h(t,e){return 1===t.length&&Array.isArray(t[e])?t[e]:x.call(t)}function l(t,e){for(var n=Array(t),r=0;t>r;r++)n[r]=e();return n}function f(t,e){this.scheduler=t,this.disposable=e,this.isDisposed=!1}function p(t,e,n,r,i){this.scheduler=t,this.state=e,this.action=n,this.dueTime=r,this.comparer=i||s,this.disposable=new I}function d(t,n){return new Ce(function(r){var i=new I,o=new P;return o.setDisposable(i),i.setDisposable(t.subscribe(r.onNext.bind(r),function(t){var i,s;try{s=n(t)}catch(u){return r.onError(u),e}i=new I,o.setDisposable(i),i.setDisposable(s.subscribe(r))},r.onCompleted.bind(r))),o})}function b(t,n){var r=this;return new Ce(function(i){var o=0,s=t.length;return r.subscribe(function(r){if(s>o){var u,c=t[o++];try{u=n(r,c)}catch(a){return i.onError(a),e}i.onNext(u)}else i.onCompleted()},i.onError.bind(i),i.onCompleted.bind(i))})}function v(t){return this.select(t).mergeObservable()}var m="object"==typeof exports&&exports&&("object"==typeof global&&global&&global==global.global&&(t=global),exports),y={Internals:{}},w="Sequence contains no elements.",g="Argument out of range",E="Object has been disposed",x=Array.prototype.slice;({}).hasOwnProperty;var C=this.inherits=y.Internals.inherits=function(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n},D=y.Internals.addProperties=function(t){for(var e=x.call(arguments,1),n=0,r=e.length;r>n;n++){var i=e[n];for(var o in i)t[o]=i[o]}},A=y.Internals.addRef=function(t,e){return new Ce(function(n){return new O(e.getDisposable(),t.subscribe(n))})};Function.prototype.bind||(Function.prototype.bind=function(t){var e=this,n=x.call(arguments,1),r=function(){function i(){}if(this instanceof r){i.prototype=e.prototype;var o=new i,s=e.apply(o,n.concat(x.call(arguments)));return Object(s)===s?s:o}return e.apply(t,n.concat(x.call(arguments)))};return r});var S=Object("a"),_="a"!=S[0]||!(0 in S);Array.prototype.every||(Array.prototype.every=function(t){var e=Object(this),n=_&&"[object String]"=={}.toString.call(this)?this.split(""):e,r=n.length>>>0,i=arguments[1];if("[object Function]"!={}.toString.call(t))throw new TypeError(t+" is not a function");for(var o=0;r>o;o++)if(o in n&&!t.call(i,n[o],o,e))return!1;return!0}),Array.prototype.map||(Array.prototype.map=function(t){var e=Object(this),n=_&&"[object String]"=={}.toString.call(this)?this.split(""):e,r=n.length>>>0,i=Array(r),o=arguments[1];if("[object Function]"!={}.toString.call(t))throw new TypeError(t+" is not a function");for(var s=0;r>s;s++)s in n&&(i[s]=t.call(o,n[s],s,e));return i}),Array.prototype.filter||(Array.prototype.filter=function(t){for(var e,n=[],r=Object(this),i=0,o=r.length>>>0;o>i;i++)e=r[i],i in r&&t.call(arguments[1],e,i,r)&&n.push(e);return n}),Array.isArray||(Array.isArray=function(t){return"[object Array]"==Object.prototype.toString.call(t)}),Array.prototype.indexOf||(Array.prototype.indexOf=function(t){var e=Object(this),n=e.length>>>0;if(0===n)return-1;var r=0;if(arguments.length>1&&(r=Number(arguments[1]),r!=r?r=0:0!=r&&1/0!=r&&r!=-1/0&&(r=(r>0||-1)*Math.floor(Math.abs(r)))),r>=n)return-1;for(var i=r>=0?r:Math.max(n-Math.abs(r),0);n>i;i++)if(i in e&&e[i]===t)return i;return-1});var N=function(t,e){this.id=t,this.value=e};N.prototype.compareTo=function(t){var e=this.value.compareTo(t.value);return 0===e&&(e=this.id-t.id),e};var W=function(t){this.items=Array(t),this.length=0},R=W.prototype;R.isHigherPriority=function(t,e){return 0>this.items[t].compareTo(this.items[e])},R.percolate=function(t){if(!(t>=this.length||0>t)){var e=t-1>>1;if(!(0>e||e===t)&&this.isHigherPriority(t,e)){var n=this.items[t];this.items[t]=this.items[e],this.items[e]=n,this.percolate(e)}}},R.heapify=function(t){if(t===e&&(t=0),!(t>=this.length||0>t)){var n=2*t+1,r=2*t+2,i=t;if(this.length>n&&this.isHigherPriority(n,i)&&(i=n),this.length>r&&this.isHigherPriority(r,i)&&(i=r),i!==t){var o=this.items[t];this.items[t]=this.items[i],this.items[i]=o,this.heapify(i)}}},R.peek=function(){return this.items[0].value},R.removeAt=function(t){this.items[t]=this.items[--this.length],delete this.items[this.length],this.heapify()},R.dequeue=function(){var t=this.peek();return this.removeAt(0),t},R.enqueue=function(t){var e=this.length++;this.items[e]=new N(W.count++,t),this.percolate(e)},R.remove=function(t){for(var e=0;this.length>e;e++)if(this.items[e].value===t)return this.removeAt(e),!0;return!1},W.count=0;var O=y.CompositeDisposable=function(){this.disposables=h(arguments,0),this.isDisposed=!1,this.length=this.disposables.length},k=O.prototype;k.add=function(t){this.isDisposed?t.dispose():(this.disposables.push(t),this.length++)},k.remove=function(t){var e=!1;if(!this.isDisposed){var n=this.disposables.indexOf(t);-1!==n&&(e=!0,this.disposables.splice(n,1),this.length--,t.dispose())}return e},k.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var t=this.disposables.slice(0);this.disposables=[],this.length=0;for(var e=0,n=t.length;n>e;e++)t[e].dispose()}},k.clear=function(){var t=this.disposables.slice(0);this.disposables=[],this.length=0;for(var e=0,n=t.length;n>e;e++)t[e].dispose()},k.contains=function(t){return-1!==this.disposables.indexOf(t)},k.toArray=function(){return this.disposables.slice(0)};var q=y.Disposable=function(t){this.isDisposed=!1,this.action=t};q.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var T=q.create=function(t){return new q(t)},j=q.empty={dispose:n},I=y.SingleAssignmentDisposable=function(){this.isDisposed=!1,this.current=null},M=I.prototype;M.disposable=function(t){return t?this.setDisposable(t):this.getDisposable()},M.getDisposable=function(){return this.current},M.setDisposable=function(t){if(this.current)throw Error("Disposable has already been assigned");var e=this.isDisposed;e||(this.current=t),e&&t&&t.dispose()},M.dispose=function(){var t;this.isDisposed||(this.isDisposed=!0,t=this.current,this.current=null),t&&t.dispose()};var P=y.SerialDisposable=function(){this.isDisposed=!1,this.current=null};P.prototype.getDisposable=function(){return this.current},P.prototype.setDisposable=function(t){var e,n=this.isDisposed;n||(e=this.current,this.current=t),e&&e.dispose(),n&&t&&t.dispose()},P.prototype.disposable=function(t){return t?(this.setDisposable(t),e):this.getDisposable()},P.prototype.dispose=function(){var t;this.isDisposed||(this.isDisposed=!0,t=this.current,this.current=null),t&&t.dispose()};var L=y.RefCountDisposable=function(){function t(t){this.disposable=t,this.disposable.count++,this.isInnerDisposed=!1}function e(t){this.underlyingDisposable=t,this.isDisposed=!1,this.isPrimaryDisposed=!1,this.count=0}return t.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()))},e.prototype.dispose=function(){this.isDisposed||this.isPrimaryDisposed||(this.isPrimaryDisposed=!0,0===this.count&&(this.isDisposed=!0,this.underlyingDisposable.dispose()))},e.prototype.getDisposable=function(){return this.isDisposed?j:new t(this)},e}();f.prototype.dispose=function(){var t=this;this.scheduler.schedule(function(){t.isDisposed||(t.isDisposed=!0,t.disposable.dispose())})},p.prototype.invoke=function(){this.disposable.disposable(this.invokeCore())},p.prototype.compareTo=function(t){return this.comparer(this.dueTime,t.dueTime)},p.prototype.isCancelled=function(){return this.disposable.isDisposed},p.prototype.invokeCore=function(){return this.action(this.scheduler,this.state)};var V=y.Scheduler=function(){function e(t,e,n,r){this.now=t,this._schedule=e,this._scheduleRelative=n,this._scheduleAbsolute=r}function n(t,e){var n=e.first,r=e.second,i=new O,o=function(e){r(e,function(e){var n=!1,r=!1,s=t.scheduleWithState(e,function(t,e){return n?i.remove(s):r=!0,o(e),j});r||(i.add(s),n=!0)})};return o(n),i}function r(t,e,n){var r=e.first,i=e.second,o=new O,s=function(e){i(e,function(e,r){var i=!1,u=!1,c=t[n].call(t,e,r,function(t,e){return i?o.remove(c):u=!0,s(e),j});u||(o.add(c),i=!0)})};return s(r),o}function o(t,e){return e(),j}var s=e.prototype;return s.catchException=function(t){return new G(this,t)},s.schedulePeriodic=function(t,e){return this.schedulePeriodicWithState(null,t,function(){e()})},s.schedulePeriodicWithState=function(e,n,r){var i=e,o=t.setInterval(function(){i=r(i)},n);return T(function(){t.clearInterval(o)})},s.schedule=function(t){return this._schedule(t,o)},s.scheduleWithState=function(t,e){return this._schedule(t,e)},s.scheduleWithRelative=function(t,e){return this._scheduleRelative(e,t,o)},s.scheduleWithRelativeAndState=function(t,e,n){return this._scheduleRelative(t,e,n)},s.scheduleWithAbsolute=function(t,e){return this._scheduleAbsolute(e,t,o)},s.scheduleWithAbsoluteAndState=function(t,e,n){return this._scheduleAbsolute(t,e,n)},s.scheduleRecursive=function(t){return this.scheduleRecursiveWithState(t,function(t,e){t(function(){e(t)})})},s.scheduleRecursiveWithState=function(t,e){return this.scheduleWithState({first:t,second:e},function(t,e){return n(t,e)})},s.scheduleRecursiveWithRelative=function(t,e){return this.scheduleRecursiveWithRelativeAndState(e,t,function(t,e){t(function(n){e(t,n)})})},s.scheduleRecursiveWithRelativeAndState=function(t,e,n){return this._scheduleRelative({first:t,second:n},e,function(t,e){return r(t,e,"scheduleWithRelativeAndState")})},s.scheduleRecursiveWithAbsolute=function(t,e){return this.scheduleRecursiveWithAbsoluteAndState(e,t,function(t,e){t(function(n){e(t,n)})})},s.scheduleRecursiveWithAbsoluteAndState=function(t,e,n){return this._scheduleAbsolute({first:t,second:n},e,function(t,e){return r(t,e,"scheduleWithAbsoluteAndState")})},e.now=i,e.normalize=function(t){return 0>t&&(t=0),t},e}(),z="Scheduler is not allowed to block the thread",F=V.immediate=function(){function t(t,e){return e(this,t)}function e(t,e,n){if(e>0)throw Error(z);return n(this,t)}function n(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new V(i,t,e,n)}(),B=V.currentThread=function(){function t(){o=new W(4)}function e(t,e){return this.scheduleWithRelativeAndState(t,0,e)}function n(e,n,r){var i,s=this.now()+V.normalize(n),u=new p(this,e,r,s);if(o)o.enqueue(u);else{i=new t;try{o.enqueue(u),i.run()}catch(c){throw c}finally{i.dispose()}}return u.disposable}function r(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}var o;t.prototype.dispose=function(){o=null},t.prototype.run=function(){for(var t;o.length>0;)if(t=o.dequeue(),!t.isCancelled()){for(;t.dueTime-V.now()>0;);t.isCancelled()||t.invoke()}};var s=new V(i,e,n,r);return s.scheduleRequired=function(){return null===o},s.ensureTrampoline=function(t){return null===o?this.schedule(t):t()},s}(),H=function(){function t(t,e){e(0,this._period);try{this._state=this._action(this._state)}catch(n){throw this._cancel.dispose(),n}}function e(t,e,n,r){this._scheduler=t,this._state=e,this._period=n,this._action=r}return e.prototype.start=function(){var e=new I;return this._cancel=e,e.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,t.bind(this))),e},e}();y.VirtualTimeScheduler=function(t){function n(){return this.toDateTimeOffset(this.clock)}function r(t,e){return this.scheduleAbsoluteWithState(t,this.clock,e)}function i(t,e,n){return this.scheduleRelativeWithState(t,this.toRelative(e),n)}function o(t,e,n){return this.scheduleRelativeWithState(t,this.toRelative(e-this.now()),n)}function s(t,e){return e(),j}function u(e,s){this.clock=e,this.comparer=s,this.isEnabled=!1,this.queue=new W(1024),t.call(this,n,r,i,o)}C(u,t);var c=u.prototype;return c.schedulePeriodicWithState=function(t,e,n){var r=new H(this,t,e,n);return r.start()},c.scheduleRelativeWithState=function(t,e,n){var r=this.add(this.clock,e);return this.scheduleAbsoluteWithState(t,r,n)},c.scheduleRelative=function(t,e){return this.scheduleRelativeWithState(e,t,s)},c.start=function(){var t;if(!this.isEnabled){this.isEnabled=!0;do t=this.getNext(),null!==t?(this.comparer(t.dueTime,this.clock)>0&&(this.clock=t.dueTime),t.invoke()):this.isEnabled=!1;while(this.isEnabled)}},c.stop=function(){this.isEnabled=!1},c.advanceTo=function(t){var e,n=this.comparer(this.clock,t);if(this.comparer(this.clock,t)>0)throw Error(g);if(0!==n&&!this.isEnabled){this.isEnabled=!0;do e=this.getNext(),null!==e&&0>=this.comparer(e.dueTime,t)?(this.comparer(e.dueTime,this.clock)>0&&(this.clock=e.dueTime),e.invoke()):this.isEnabled=!1;while(this.isEnabled);this.clock=t}},c.advanceBy=function(t){var n=this.add(this.clock,t),r=this.comparer(this.clock,n);if(r>0)throw Error(g);return 0!==r?this.advanceTo(n):e},c.sleep=function(t){var e=this.add(this.clock,t);if(this.comparer(this.clock,e)>=0)throw Error(g);this.clock=e},c.getNext=function(){for(var t;this.queue.length>0;){if(t=this.queue.peek(),!t.isCancelled())return t;this.queue.dequeue()}return null},c.scheduleAbsolute=function(t,e){return this.scheduleAbsoluteWithState(e,t,s)},c.scheduleAbsoluteWithState=function(t,e,n){var r=this,i=function(t,e){return r.queue.remove(o),n(t,e)},o=new p(r,t,i,e,r.comparer);return r.queue.enqueue(o),o.disposable},u}(V),y.HistoricalScheduler=function(t){function e(e,n){var r=null==e?0:e,i=n||s;t.call(this,r,i)}C(e,t);var n=e.prototype;return n.add=function(t,e){return t+e},n.toDateTimeOffset=function(t){return new Date(t).getTime()},n.toRelative=function(t){return t},e}(y.VirtualTimeScheduler);var U=V.timeout=function(){function r(){if(!t.postMessage||t.importScripts)return!1;var e=!1,n=t.onmessage;return t.onmessage=function(){e=!0},t.postMessage("","*"),t.onmessage=n,e}function o(t){if("string"==typeof t.data&&t.data.substring(0,l.length)===l){var e=t.data.substring(l.length),n=f[e];n(),delete f[e]}}function s(t,e){var n=this,r=new I,i=a(function(){r.isDisposed||r.setDisposable(e(n,t))});return new O(r,T(function(){h(i)}))}function u(e,n,r){var i=this,o=V.normalize(n);if(0===o)return i.scheduleWithState(e,r);var s=new I,u=t.setTimeout(function(){s.isDisposed||s.setDisposable(r(i,e))},o);return new O(s,T(function(){t.clearTimeout(u)}))}function c(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}var a,h=n;if(t.process!==e&&"[object process]"==typeof t.process)a=t.process.nextTick;else if("function"==typeof t.setImmediate)a=t.setImmediate,h=t.clearImmediate;else if(r()){var l="ms.rx.schedule"+Math.random(),f={},p=0;t.addEventListener?t.addEventListener("message",o,!1):t.attachEvent("onmessage",o,!1),a=function(e){var n=p++;f[n]=e,t.postMessage(l+n,"*")}}else if(t.MessageChannel)a=function(e){var n=new t.MessageChannel;n.port1.onmessage=function(){e()},n.port2.postMessage()};else if("document"in t&&"onreadystatechange"in t.document.createElement("script")){var d=t.document.createElement("script");d.onreadystatechange=function(){action(),d.onreadystatechange=null,d.parentNode.removeChild(d),d=null},t.document.documentElement.appendChild(d)}else a=function(e){return t.setTimeout(e,0)},h=t.clearTimeout;return new V(i,s,u,c)}(),G=function(t){function e(){return this._scheduler.now()}function n(t,e){return this._scheduler.scheduleWithState(t,this._wrap(e))}function r(t,e,n){return this._scheduler.scheduleWithRelativeAndState(t,e,this._wrap(n))}function i(t,e,n){return this._scheduler.scheduleWithAbsoluteAndState(t,e,this._wrap(n))}function o(o,s){this._scheduler=o,this._handler=s,this._recursiveOriginal=null,this._recursiveWrapper=null,t.call(this,e,n,r,i)}return C(o,t),o.prototype._clone=function(t){return new o(t,this._handler)},o.prototype._wrap=function(t){var e=this;return function(n,r){try{return t(e._getRecursiveWrapper(n),r)}catch(i){if(!e._handler(i))throw i;return j}}},o.prototype._getRecursiveWrapper=function(t){if(!this._recursiveOriginal!==t){this._recursiveOriginal=t;var e=this._clone(t);e._recursiveOriginal=t,e._recursiveWrapper=e,this._recursiveWrapper=e}return this._recursiveWrapper},o.prototype.schedulePeriodicWithState=function(t,e,n){var r=this,i=!1,o=new I;return o.setDisposable(this._scheduler.schedulePeriodicWithState(t,e,function(t){if(i)return null;try{return n(t)}catch(e){if(i=!0,!r._handler(e))throw e;return o.dispose(),null}})),o},o}(V),J=y.Notification=function(){function t(t,e){this.hasValue=null==e?!1:e,this.kind=t}var e=t.prototype;return e.accept=function(t,e,n){return 1===arguments.length&&"object"==typeof t?this._acceptObservable(t):this._accept(t,e,n)},e.toObservable=function(t){var e=this;return t=t||F,new Ce(function(n){return t.schedule(function(){e._acceptObservable(n),"N"===e.kind&&n.onCompleted()})})},e.equals=function(t){var e=null==t?"":""+t;return""+this===e},t}(),K=J.createOnNext=function(){function t(t){return t(this.value)}function e(t){return t.onNext(this.value)}function n(){return"OnNext("+this.value+")"}return function(r){var i=new J("N",!0);return i.value=r,i._accept=t.bind(i),i._acceptObservable=e.bind(i),i.toString=n.bind(i),i}}(),Q=J.createOnError=function(){function t(t,e){return e(this.exception)}function e(t){return t.onError(this.exception)}function n(){return"OnError("+this.exception+")"}return function(r){var i=new J("E");return i.exception=r,i._accept=t.bind(i),i._acceptObservable=e.bind(i),i.toString=n.bind(i),i}}(),X=J.createOnCompleted=function(){function t(t,e,n){return n()}function e(t){return t.onCompleted()}function n(){return"OnCompleted()"}return function(){var r=new J("C");return r._accept=t.bind(r),r._acceptObservable=e.bind(r),r.toString=n.bind(r),r}}(),Y=y.Internals.Enumerator=function(t,e,n){this.moveNext=t,this.getCurrent=e,this.dispose=n},Z=Y.create=function(t,e,r){var i=!1;return r||(r=n),new Y(function(){if(i)return!1;var e=t();return e||(i=!0,r()),e},function(){return e()},function(){i||(r(),i=!0)})},$=y.Internals.Enumerable=function(){function t(t){this.getEnumerator=t}return t.prototype.concat=function(){var t=this;return new Ce(function(n){var r=t.getEnumerator(),i=!1,o=new P,s=F.scheduleRecursive(function(t){var s,u,c=!1;if(!i){try{c=r.moveNext(),c?s=r.getCurrent():r.dispose()}catch(a){u=a,r.dispose()}if(u)return n.onError(u),e;if(!c)return n.onCompleted(),e;var h=new I;o.setDisposable(h),h.setDisposable(s.subscribe(n.onNext.bind(n),n.onError.bind(n),function(){t()}))}});return new O(o,s,T(function(){i=!0,r.dispose()}))})},t.prototype.catchException=function(){var t=this;return new Ce(function(n){var r,i=t.getEnumerator(),o=!1,s=new P,u=F.scheduleRecursive(function(t){var u,c,a;if(a=!1,!o){try{a=i.moveNext(),a&&(u=i.getCurrent())}catch(h){c=h}if(c)return n.onError(c),e;if(!a)return r?n.onError(r):n.onCompleted(),e;var l=new I;s.setDisposable(l),l.setDisposable(u.subscribe(n.onNext.bind(n),function(e){r=e,t()},n.onCompleted.bind(n)))}});return new O(s,u,T(function(){o=!0}))})},t}(),te=$.repeat=function(t,n){return n===e&&(n=-1),new $(function(){var e,r=n;return Z(function(){return 0===r?!1:(r>0&&r--,e=t,!0)},function(){return e})})},ee=$.forEach=function(t,e){return e||(e=r),new $(function(){var n,r=-1;return Z(function(){return++r<t.length?(n=e(t[r],r),!0):!1},function(){return n})})},ne=y.Observer=function(){};ne.prototype.toNotifier=function(){var t=this;return function(e){return e.accept(t)}},ne.prototype.asObserver=function(){return new se(this.onNext.bind(this),this.onError.bind(this),this.onCompleted.bind(this))},ne.prototype.checked=function(){return new ue(this)};var re=ne.create=function(t,e,r){return t||(t=n),e||(e=c),r||(r=n),new se(t,e,r)};ne.fromNotifier=function(t){return new se(function(e){return t(K(e))},function(e){return t(Q(e))},function(){return t(X())})};var ie,oe=y.Internals.AbstractObserver=function(t){function e(){this.isStopped=!1,t.call(this)}return C(e,t),e.prototype.onNext=function(t){this.isStopped||this.next(t)},e.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.error(t))},e.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.completed())},e.prototype.dispose=function(){this.isStopped=!0},e.prototype.fail=function(){return this.isStopped?!1:(this.isStopped=!0,this.error(!0),!0)},e}(ne),se=y.AnonymousObserver=function(t){function e(e,n,r){t.call(this),this._onNext=e,this._onError=n,this._onCompleted=r}return C(e,t),e.prototype.next=function(t){this._onNext(t)},e.prototype.error=function(t){this._onError(t)},e.prototype.completed=function(){this._onCompleted()},e}(oe),ue=function(t){function e(e){t.call(this),this._observer=e,this._state=0}C(e,t);var n=e.prototype;return n.onNext=function(t){this.checkAccess();try{this._observer.onNext(t)}catch(e){throw e}finally{this._state=0}},n.onError=function(t){this.checkAccess();try{this._observer.onError(t)}catch(e){throw e}finally{this._state=2}},n.onCompleted=function(){this.checkAccess();try{this._observer.onCompleted()}catch(t){throw t}finally{this._state=2}},n.checkAccess=function(){if(1===this._state)throw Error("Re-entrancy detected");if(2===this._state)throw Error("Observer completed");0===this._state&&(this._state=1)},e}(ne),ce=y.Internals.ScheduledObserver=function(t){function n(e,n){t.call(this),this.scheduler=e,this.observer=n,this.isAcquired=!1,this.hasFaulted=!1,this.queue=[],this.disposable=new P}return C(n,t),n.prototype.next=function(t){var e=this;this.queue.push(function(){e.observer.onNext(t)})},n.prototype.error=function(t){var e=this;this.queue.push(function(){e.observer.onError(t)})},n.prototype.completed=function(){var t=this;this.queue.push(function(){t.observer.onCompleted()})},n.prototype.ensureActive=function(){var t=!1,n=this;!this.hasFaulted&&this.queue.length>0&&(t=!this.isAcquired,this.isAcquired=!0),t&&this.disposable.setDisposable(this.scheduler.scheduleRecursive(function(t){var r;if(!(n.queue.length>0))return n.isAcquired=!1,e;r=n.queue.shift();try{r()}catch(i){throw n.queue=[],n.hasFaulted=!0,i}t()}))},n.prototype.dispose=function(){t.prototype.dispose.call(this),this.disposable.dispose()},n}(oe),ae=function(t){function e(){t.apply(this,arguments)}return C(e,t),e.prototype.next=function(e){t.prototype.next.call(this,e),this.ensureActive()},e.prototype.error=function(e){t.prototype.error.call(this,e),this.ensureActive()},e.prototype.completed=function(){t.prototype.completed.call(this),this.ensureActive()},e}(ce),he=y.Observable=function(){function t(t){this._subscribe=t}return ie=t.prototype,ie.finalValue=function(){var t=this;return new Ce(function(e){var n,r=!1;return t.subscribe(function(t){r=!0,n=t},e.onError.bind(e),function(){r?(e.onNext(n),e.onCompleted()):e.onError(Error(w))})})},ie.subscribe=ie.forEach=function(t,e,n){var r;return r="object"==typeof t?t:re(t,e,n),this._subscribe(r)},ie.toArray=function(){function t(t,e){var n=t.slice(0);return n.push(e),n}return this.scan([],t).startWith([]).finalValue()},t}();he.start=function(t,e){return le(t,e)()};var le=he.toAsync=function(t,n,r){return n||(n=U),function(){var i=x.call(arguments,0),o=new Ne;return n.schedule(function(){var n;try{n=t.apply(r,i)}catch(s){return o.onError(s),e}o.onNext(n),o.onCompleted()}),o.asObservable()}};ie.observeOn=function(t){var e=this;return new Ce(function(n){return e.subscribe(new ae(t,n))})},ie.subscribeOn=function(t){var e=this;return new Ce(function(n){var r=new I,i=new P;return i.setDisposable(r),r.setDisposable(t.schedule(function(){i.setDisposable(new f(t,e.subscribe(n)))})),i})},he.create=function(t){return new Ce(function(e){return T(t(e))})},he.createWithDisposable=function(t){return new Ce(t)};var fe=he.defer=function(t){return new Ce(function(e){var n;try{n=t()}catch(r){return me(r).subscribe(e)}return n.subscribe(e)})},pe=he.empty=function(t){return t||(t=F),new Ce(function(e){return t.schedule(function(){e.onCompleted()})})},de=he.fromArray=function(t,e){return e||(e=B),new Ce(function(n){var r=0;return e.scheduleRecursive(function(e){t.length>r?(n.onNext(t[r++]),e()):n.onCompleted()})})};he.generate=function(t,n,r,i,o){return o||(o=B),new Ce(function(s){var u=!0,c=t;return o.scheduleRecursive(function(t){var o,a;try{u?u=!1:c=r(c),o=n(c),o&&(a=i(c))}catch(h){return s.onError(h),e}o?(s.onNext(a),t()):s.onCompleted()})})};var be=he.never=function(){return new Ce(function(){return j})};he.range=function(t,e,n){return n||(n=B),new Ce(function(r){return n.scheduleRecursiveWithState(0,function(n,i){e>n?(r.onNext(t+n),i(n+1)):r.onCompleted()})})},he.repeat=function(t,n,r){return r||(r=B),n==e&&(n=-1),ve(t,r).repeat(n)};var ve=he.returnValue=function(t,e){return e||(e=F),new Ce(function(n){return e.schedule(function(){n.onNext(t),n.onCompleted()})})},me=he.throwException=function(t,e){return e||(e=F),new Ce(function(n){return e.schedule(function(){n.onError(t)})})};he.using=function(t,e){return new Ce(function(n){var r,i,o=j;try{r=t(),r&&(o=r),i=e(r)}catch(s){return new O(me(s).subscribe(n),o)}return new O(i.subscribe(n),o)})},ie.amb=function(t){var e=this;return new Ce(function(n){function r(){o||(o=s,a.dispose())}function i(){o||(o=u,c.dispose())}var o,s="L",u="R",c=new I,a=new I;return c.setDisposable(e.subscribe(function(t){r(),o===s&&n.onNext(t)},function(t){r(),o===s&&n.onError(t)},function(){r(),o===s&&n.onCompleted()})),a.setDisposable(t.subscribe(function(t){i(),o===u&&n.onNext(t)},function(t){i(),o===u&&n.onError(t)},function(){i(),o===u&&n.onCompleted()})),new O(c,a)})},he.amb=function(){function t(t,e){return t.amb(e)}for(var e=be(),n=h(arguments,0),r=0,i=n.length;i>r;r++)e=t(e,n[r]);return e},ie.catchException=function(t){return"function"==typeof t?d(this,t):ye([this,t])};var ye=he.catchException=function(){var t=h(arguments,0);return ee(t).catchException()};ie.combineLatest=function(){var t=x.call(arguments);return Array.isArray(t[0])?t[0].unshift(this):t.unshift(this),we.apply(this,t)};var we=he.combineLatest=function(){var t=x.call(arguments),n=t.pop();return Array.isArray(t[0])&&(t=t[0]),new Ce(function(r){function i(t){var i;if(c[t]=!0,a||(a=c.every(function(t){return t}))){try{i=n.apply(null,f)}catch(o){return r.onError(o),e}r.onNext(i)}else h.filter(function(e,n){return n!==t}).every(function(t){return t})&&r.onCompleted()}function o(t){h[t]=!0,h.every(function(t){return t})&&r.onCompleted()}for(var s=function(){return!1},u=t.length,c=l(u,s),a=!1,h=l(u,s),f=Array(u),p=Array(u),d=0;u>d;d++)(function(e){p[e]=new I,p[e].setDisposable(t[e].subscribe(function(t){f[e]=t,i(e)},r.onError.bind(r),function(){o(e)}))})(d);return new O(p)})};ie.concat=function(){var t=x.call(arguments,0);return t.unshift(this),ge.apply(this,t)};var ge=he.concat=function(){var t=h(arguments,0);return ee(t).concat()};ie.concatObservable=ie.concatAll=function(){return this.merge(1)},ie.merge=function(t){if("number"!=typeof t)return Ee(this,t);var e=this;return new Ce(function(n){var r=0,i=new O,o=!1,s=[],u=function(t){var e=new I;i.add(e),e.setDisposable(t.subscribe(n.onNext.bind(n),n.onError.bind(n),function(){var t;i.remove(e),s.length>0?(t=s.shift(),u(t)):(r--,o&&0===r&&n.onCompleted())}))};return i.add(e.subscribe(function(e){t>r?(r++,u(e)):s.push(e)},n.onError.bind(n),function(){o=!0,0===r&&n.onCompleted()})),i})};var Ee=he.merge=function(){var t,e;return arguments[0]?arguments[0].now?(t=arguments[0],e=x.call(arguments,1)):(t=F,e=x.call(arguments,0)):(t=F,e=x.call(arguments,1)),Array.isArray(e[0])&&(e=e[0]),de(e,t).mergeObservable()};ie.mergeObservable=ie.mergeAll=function(){var t=this;return new Ce(function(e){var n=new O,r=!1,i=new I;return n.add(i),i.setDisposable(t.subscribe(function(t){var i=new I;n.add(i),i.setDisposable(t.subscribe(function(t){e.onNext(t)},e.onError.bind(e),function(){n.remove(i),r&&1===n.length&&e.onCompleted()}))},e.onError.bind(e),function(){r=!0,1===n.length&&e.onCompleted()})),n})},ie.onErrorResumeNext=function(t){if(!t)throw Error("Second observable is required");return xe([this,t])};var xe=he.onErrorResumeNext=function(){var t=h(arguments,0);return new Ce(function(e){var n=0,r=new P,i=F.scheduleRecursive(function(i){var o,s;t.length>n?(o=t[n++],s=new I,r.setDisposable(s),s.setDisposable(o.subscribe(e.onNext.bind(e),function(){i()},function(){i()}))):e.onCompleted()});return new O(r,i)})};ie.skipUntil=function(t){var e=this;return new Ce(function(n){var r=!1,i=new O(e.subscribe(function(t){r&&n.onNext(t)},n.onError.bind(n),function(){r&&n.onCompleted()})),o=new I;return i.add(o),o.setDisposable(t.subscribe(function(){r=!0,o.dispose()},n.onError.bind(n),function(){o.dispose()})),i})},ie.switchLatest=function(){var t=this;return new Ce(function(e){var n=!1,r=new P,i=!1,o=0,s=t.subscribe(function(t){var s=new I,u=++o;n=!0,r.setDisposable(s),s.setDisposable(t.subscribe(function(t){o===u&&e.onNext(t)},function(t){o===u&&e.onError(t)},function(){o===u&&(n=!1,i&&e.onCompleted())}))},e.onError.bind(e),function(){i=!0,n||e.onCompleted()});return new O(s,r)})},ie.takeUntil=function(t){var e=this;return new Ce(function(r){return new O(e.subscribe(r),t.subscribe(r.onCompleted.bind(r),r.onError.bind(r),n))})},ie.zip=function(){if(Array.isArray(arguments[0]))return b.apply(this,arguments);var t=this,n=x.call(arguments),r=n.pop();return n.unshift(t),new Ce(function(i){function o(t){c[t]=!0,c.every(function(t){return t})&&i.onCompleted()}for(var s=n.length,u=l(s,function(){return[]}),c=l(s,function(){return!1}),a=function(n){var o,s;if(u.every(function(t){return t.length>0})){try{s=u.map(function(t){return t.shift()}),o=r.apply(t,s)}catch(a){return i.onError(a),e}i.onNext(o)}else c.filter(function(t,e){return e!==n}).every(function(t){return t})&&i.onCompleted()},h=Array(s),f=0;s>f;f++)(function(t){h[t]=new I,h[t].setDisposable(n[t].subscribe(function(e){u[t].push(e),a(t)},i.onError.bind(i),function(){o(t)}))})(f);return new O(h)})},he.zip=function(t,e){var n=t[0],r=t.slice(1);return r.push(e),n.zip.apply(n,r)},ie.asObservable=function(){var t=this;return new Ce(function(e){return t.subscribe(e)})},ie.bufferWithCount=function(t,n){return n===e&&(n=t),this.windowWithCount(t,n).selectMany(function(t){return t.toArray()}).where(function(t){return t.length>0})},ie.dematerialize=function(){var t=this;return new Ce(function(e){return t.subscribe(function(t){return t.accept(e)},e.onError.bind(e),e.onCompleted.bind(e))})},ie.distinctUntilChanged=function(t,n){var i=this;return t||(t=r),n||(n=o),new Ce(function(r){var o,s=!1;return i.subscribe(function(i){var u,c=!1;try{u=t(i)}catch(a){return r.onError(a),e}if(s)try{c=n(o,u)}catch(a){return r.onError(a),e}s&&c||(s=!0,o=u,r.onNext(i))},r.onError.bind(r),r.onCompleted.bind(r))})},ie.doAction=function(t,e,n){var r,i=this;return"function"==typeof t?r=t:(r=t.onNext.bind(t),e=t.onError.bind(t),n=t.onCompleted.bind(t)),new Ce(function(t){return i.subscribe(function(e){try{r(e)}catch(n){t.onError(n)}t.onNext(e)},function(n){if(e){try{e(n)}catch(r){t.onError(r)}t.onError(n)}else t.onError(n)},function(){if(n){try{n()}catch(e){t.onError(e)}t.onCompleted()}else t.onCompleted()})})},ie.finallyAction=function(t){var e=this;return new Ce(function(n){var r=e.subscribe(n);return T(function(){try{r.dispose()}catch(e){throw e}finally{t()}})})},ie.ignoreElements=function(){var t=this;return new Ce(function(e){return t.subscribe(n,e.onError.bind(e),e.onCompleted.bind(e))})},ie.materialize=function(){var t=this;return new Ce(function(e){return t.subscribe(function(t){e.onNext(K(t))},function(t){e.onNext(Q(t)),e.onCompleted()},function(){e.onNext(X()),e.onCompleted()})})},ie.repeat=function(t){return te(this,t).concat()},ie.retry=function(t){return te(this,t).catchException()},ie.scan=function(){var t,e,n=!1;2===arguments.length?(t=arguments[0],e=arguments[1],n=!0):e=arguments[0];var r=this;return fe(function(){var i,o=!1;return r.select(function(r){return o?i=e(i,r):(i=n?e(t,r):r,o=!0),i})})},ie.skipLast=function(t){var e=this;return new Ce(function(n){var r=[];return e.subscribe(function(e){r.push(e),r.length>t&&n.onNext(r.shift())},n.onError.bind(n),n.onCompleted.bind(n))
})},ie.startWith=function(){var t,n,r=0;return arguments.length>0&&null!=arguments[0]&&arguments[0].now!==e?(n=arguments[0],r=1):n=F,t=x.call(arguments,r),ee([de(t,n),this]).concat()},ie.takeLast=function(t,e){return this.takeLastBuffer(t).selectMany(function(t){return de(t,e)})},ie.takeLastBuffer=function(t){var e=this;return new Ce(function(n){var r=[];return e.subscribe(function(e){r.push(e),r.length>t&&r.shift()},n.onError.bind(n),function(){n.onNext(r),n.onCompleted()})})},ie.windowWithCount=function(t,e){var n=this;if(0>=t)throw Error(g);if(null==e&&(e=t),0>=e)throw Error(g);return new Ce(function(r){var i=new I,o=new L(i),s=0,u=[],c=function(){var t=new _e;u.push(t),r.onNext(A(t,o))};return c(),i.setDisposable(n.subscribe(function(n){for(var r,i=0,o=u.length;o>i;i++)u[i].onNext(n);var a=s-t+1;a>=0&&0===a%e&&(r=u.shift(),r.onCompleted()),s++,0===s%e&&c()},function(t){for(;u.length>0;)u.shift().onError(t);r.onError(t)},function(){for(;u.length>0;)u.shift().onCompleted();r.onCompleted()})),o})},ie.defaultIfEmpty=function(t){var n=this;return t===e&&(t=null),new Ce(function(e){var r=!1;return n.subscribe(function(t){r=!0,e.onNext(t)},e.onError.bind(e),function(){r||e.onNext(t),e.onCompleted()})})},ie.distinct=function(t,n){var i=this;return t||(t=r),n||(n=u),new Ce(function(r){var o={};return i.subscribe(function(i){var s,u,c,a=!1;try{s=t(i),u=n(s)}catch(h){return r.onError(h),e}for(c in o)if(u===c){a=!0;break}a||(o[u]=null,r.onNext(i))},r.onError.bind(r),r.onCompleted.bind(r))})},ie.groupBy=function(t,e,n){return this.groupByUntil(t,e,function(){return be()},n)},ie.groupByUntil=function(t,i,o,s){var c=this;return i||(i=r),s||(s=u),new Ce(function(r){var u={},a=new O,h=new L(a);return a.add(c.subscribe(function(c){var l,f,p,d,b,v,m,y,w,g,E;try{m=t(c),y=s(m)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}b=!1;try{g=u[y],g||(g=new _e,u[y]=g,b=!0)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}if(b){v=new Ae(m,g,h),f=new Ae(m,g);try{l=o(f)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}r.onNext(v),w=new I,a.add(w),d=function(){y in u&&(delete u[y],g.onCompleted()),a.remove(w)},w.setDisposable(l.take(1).subscribe(n,function(t){for(E in u)u[E].onError(t);r.onError(t)},function(){d()}))}try{p=i(c)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}g.onNext(p)},function(t){for(var e in u)u[e].onError(t);r.onError(t)},function(){for(var t in u)u[t].onCompleted();r.onCompleted()})),h})},ie.select=function(t,n){var r=this;return new Ce(function(i){var o=0;return r.subscribe(function(s){var u;try{u=t.call(n,s,o++,r)}catch(c){return i.onError(c),e}i.onNext(u)},i.onError.bind(i),i.onCompleted.bind(i))})},ie.map=ie.select,ie.selectMany=ie.flatMap=function(t,e){return e?this.selectMany(function(n){return t(n).select(function(t){return e(n,t)})}):"function"==typeof t?v.call(this,t):v.call(this,function(){return t})},ie.skip=function(t){if(0>t)throw Error(g);var e=this;return new Ce(function(n){var r=t;return e.subscribe(function(t){0>=r?n.onNext(t):r--},n.onError.bind(n),n.onCompleted.bind(n))})},ie.skipWhile=function(t){var n=this;return new Ce(function(r){var i=0,o=!1;return n.subscribe(function(n){if(!o)try{o=!t(n,i++)}catch(s){return r.onError(s),e}o&&r.onNext(n)},r.onError.bind(r),r.onCompleted.bind(r))})},ie.take=function(t,e){if(0>t)throw Error(g);if(0===t)return pe(e);var n=this;return new Ce(function(e){var r=t;return n.subscribe(function(t){r>0&&(r--,e.onNext(t),0===r&&e.onCompleted())},e.onError.bind(e),e.onCompleted.bind(e))})},ie.takeWhile=function(t){var n=this;return new Ce(function(r){var i=0,o=!0;return n.subscribe(function(n){if(o){try{o=t(n,i++)}catch(s){return r.onError(s),e}o?r.onNext(n):r.onCompleted()}},r.onError.bind(r),r.onCompleted.bind(r))})},ie.where=function(t,n){var r=this;return new Ce(function(i){var o=0;return r.subscribe(function(s){var u;try{u=t.call(n,s,o++,r)}catch(c){return i.onError(c),e}u&&i.onNext(s)},i.onError.bind(i),i.onCompleted.bind(i))})},ie.filter=ie.where;var Ce=y.Internals.AnonymousObservable=function(t){function e(e){function n(t){var n=new De(t);if(B.scheduleRequired())B.schedule(function(){try{n.disposable(e(n))}catch(t){if(!n.fail(t))throw t}});else try{n.disposable(e(n))}catch(r){if(!n.fail(r))throw r}return n}t.call(this,n)}return C(e,t),e}(he),De=function(t){function e(e){t.call(this),this.observer=e,this.m=new I}C(e,t);var n=e.prototype;return n.next=function(t){var e=!1;try{this.observer.onNext(t),e=!0}catch(n){throw n}finally{e||this.dispose()}},n.error=function(t){try{this.observer.onError(t)}catch(e){throw e}finally{this.dispose()}},n.completed=function(){try{this.observer.onCompleted()}catch(t){throw t}finally{this.dispose()}},n.disposable=function(t){return this.m.disposable(t)},n.dispose=function(){t.prototype.dispose.call(this),this.m.dispose()},e}(oe),Ae=function(t){function e(t){return this.underlyingObservable.subscribe(t)}function n(n,r,i){t.call(this,e),this.key=n,this.underlyingObservable=i?new Ce(function(t){return new O(i.getDisposable(),r.subscribe(t))}):r}return C(n,t),n}(he),Se=function(t,e){this.subject=t,this.observer=e};Se.prototype.dispose=function(){if(!this.subject.isDisposed&&null!==this.observer){var t=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(t,1),this.observer=null}};var _e=y.Subject=function(t){function e(t){return a.call(this),this.isStopped?this.exception?(t.onError(this.exception),j):(t.onCompleted(),j):(this.observers.push(t),new Se(this,t))}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.observers=[]}return C(n,t),D(n.prototype,ne,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(a.call(this),!this.isStopped){var t=this.observers.slice(0);this.isStopped=!0;for(var e=0,n=t.length;n>e;e++)t[e].onCompleted();this.observers=[]}},onError:function(t){if(a.call(this),!this.isStopped){var e=this.observers.slice(0);this.isStopped=!0,this.exception=t;for(var n=0,r=e.length;r>n;n++)e[n].onError(t);this.observers=[]}},onNext:function(t){if(a.call(this),!this.isStopped)for(var e=this.observers.slice(0),n=0,r=e.length;r>n;n++)e[n].onNext(t)},dispose:function(){this.isDisposed=!0,this.observers=null}}),n.create=function(t,e){return new We(t,e)},n}(he),Ne=y.AsyncSubject=function(t){function e(t){if(a.call(this),!this.isStopped)return this.observers.push(t),new Se(this,t);var e=this.exception,n=this.hasValue,r=this.value;return e?t.onError(e):n?(t.onNext(r),t.onCompleted()):t.onCompleted(),j}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.value=null,this.hasValue=!1,this.observers=[],this.exception=null}return C(n,t),D(n.prototype,ne,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){var t,e,n;if(a.call(this),!this.isStopped){var r=this.observers.slice(0);this.isStopped=!0;var i=this.value,o=this.hasValue;if(o)for(e=0,n=r.length;n>e;e++)t=r[e],t.onNext(i),t.onCompleted();else for(e=0,n=r.length;n>e;e++)r[e].onCompleted();this.observers=[]}},onError:function(t){if(a.call(this),!this.isStopped){var e=this.observers.slice(0);this.isStopped=!0,this.exception=t;for(var n=0,r=e.length;r>n;n++)e[n].onError(t);this.observers=[]}},onNext:function(t){a.call(this),this.isStopped||(this.value=t,this.hasValue=!0)},dispose:function(){this.isDisposed=!0,this.observers=null,this.exception=null,this.value=null}}),n}(he),We=function(t){function e(t){return this.observable.subscribe(t)}function n(n,r){t.call(this,e),this.observer=n,this.observable=r}return C(n,t),D(n.prototype,ne,{onCompleted:function(){this.observer.onCompleted()},onError:function(t){this.observer.onError(t)},onNext:function(t){this.observer.onNext(t)}}),n}(he);return"function"==typeof define&&"object"==typeof define.amd&&define.amd?(t.Rx=y,define(function(){return y})):(m?"object"==typeof module&&module&&module.exports==m?module.exports=y:m=y:t.Rx=y,e)})(this);
(function(t,e){function n(){}function r(t){return t}function i(){return(new Date).getTime()}function o(t,e){return t===e}function s(t,e){return t-e}function u(t){return""+t}function c(t){throw t}function a(){if(this.isDisposed)throw Error(E)}function h(t,e){return 1===t.length&&Array.isArray(t[e])?t[e]:x.call(t)}function l(t,e){for(var n=Array(t),r=0;t>r;r++)n[r]=e();return n}function f(t,e){this.scheduler=t,this.disposable=e,this.isDisposed=!1}function p(t,e,n,r,i){this.scheduler=t,this.state=e,this.action=n,this.dueTime=r,this.comparer=i||s,this.disposable=new I}function d(t,n){return new Ae(function(r){var i=new I,o=new P;return o.setDisposable(i),i.setDisposable(t.subscribe(r.onNext.bind(r),function(t){var i,s;try{s=n(t)}catch(u){return r.onError(u),e}i=new I,o.setDisposable(i),i.setDisposable(s.subscribe(r))},r.onCompleted.bind(r))),o})}function b(t,n){var r=this;return new Ae(function(i){var o=0,s=t.length;return r.subscribe(function(r){if(s>o){var u,c=t[o++];try{u=n(r,c)}catch(a){return i.onError(a),e}i.onNext(u)}else i.onCompleted()},i.onError.bind(i),i.onCompleted.bind(i))})}function v(t){return this.select(t).mergeObservable()}var m="object"==typeof exports&&exports&&("object"==typeof global&&global&&global==global.global&&(t=global),exports),y={Internals:{}},w="Sequence contains no elements.",g="Argument out of range",E="Object has been disposed",x=Array.prototype.slice;({}).hasOwnProperty;var C=this.inherits=y.Internals.inherits=function(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n},D=y.Internals.addProperties=function(t){for(var e=x.call(arguments,1),n=0,r=e.length;r>n;n++){var i=e[n];for(var o in i)t[o]=i[o]}},A=y.Internals.addRef=function(t,e){return new Ae(function(n){return new R(e.getDisposable(),t.subscribe(n))})};Function.prototype.bind||(Function.prototype.bind=function(t){var e=this,n=x.call(arguments,1),r=function(){function i(){}if(this instanceof r){i.prototype=e.prototype;var o=new i,s=e.apply(o,n.concat(x.call(arguments)));return Object(s)===s?s:o}return e.apply(t,n.concat(x.call(arguments)))};return r});var S=Object("a"),_="a"!=S[0]||!(0 in S);Array.prototype.every||(Array.prototype.every=function(t){var e=Object(this),n=_&&"[object String]"=={}.toString.call(this)?this.split(""):e,r=n.length>>>0,i=arguments[1];if("[object Function]"!={}.toString.call(t))throw new TypeError(t+" is not a function");for(var o=0;r>o;o++)if(o in n&&!t.call(i,n[o],o,e))return!1;return!0}),Array.prototype.map||(Array.prototype.map=function(t){var e=Object(this),n=_&&"[object String]"=={}.toString.call(this)?this.split(""):e,r=n.length>>>0,i=Array(r),o=arguments[1];if("[object Function]"!={}.toString.call(t))throw new TypeError(t+" is not a function");for(var s=0;r>s;s++)s in n&&(i[s]=t.call(o,n[s],s,e));return i}),Array.prototype.filter||(Array.prototype.filter=function(t){for(var e,n=[],r=Object(this),i=0,o=r.length>>>0;o>i;i++)e=r[i],i in r&&t.call(arguments[1],e,i,r)&&n.push(e);return n}),Array.isArray||(Array.isArray=function(t){return"[object Array]"==Object.prototype.toString.call(t)}),Array.prototype.indexOf||(Array.prototype.indexOf=function(t){var e=Object(this),n=e.length>>>0;if(0===n)return-1;var r=0;if(arguments.length>1&&(r=Number(arguments[1]),r!=r?r=0:0!=r&&1/0!=r&&r!=-1/0&&(r=(r>0||-1)*Math.floor(Math.abs(r)))),r>=n)return-1;for(var i=r>=0?r:Math.max(n-Math.abs(r),0);n>i;i++)if(i in e&&e[i]===t)return i;return-1});var N=function(t,e){this.id=t,this.value=e};N.prototype.compareTo=function(t){var e=this.value.compareTo(t.value);return 0===e&&(e=this.id-t.id),e};var W=function(t){this.items=Array(t),this.length=0},O=W.prototype;O.isHigherPriority=function(t,e){return 0>this.items[t].compareTo(this.items[e])},O.percolate=function(t){if(!(t>=this.length||0>t)){var e=t-1>>1;if(!(0>e||e===t)&&this.isHigherPriority(t,e)){var n=this.items[t];this.items[t]=this.items[e],this.items[e]=n,this.percolate(e)}}},O.heapify=function(t){if(t===e&&(t=0),!(t>=this.length||0>t)){var n=2*t+1,r=2*t+2,i=t;if(this.length>n&&this.isHigherPriority(n,i)&&(i=n),this.length>r&&this.isHigherPriority(r,i)&&(i=r),i!==t){var o=this.items[t];this.items[t]=this.items[i],this.items[i]=o,this.heapify(i)}}},O.peek=function(){return this.items[0].value},O.removeAt=function(t){this.items[t]=this.items[--this.length],delete this.items[this.length],this.heapify()},O.dequeue=function(){var t=this.peek();return this.removeAt(0),t},O.enqueue=function(t){var e=this.length++;this.items[e]=new N(W.count++,t),this.percolate(e)},O.remove=function(t){for(var e=0;this.length>e;e++)if(this.items[e].value===t)return this.removeAt(e),!0;return!1},W.count=0;var R=y.CompositeDisposable=function(){this.disposables=h(arguments,0),this.isDisposed=!1,this.length=this.disposables.length},k=R.prototype;k.add=function(t){this.isDisposed?t.dispose():(this.disposables.push(t),this.length++)},k.remove=function(t){var e=!1;if(!this.isDisposed){var n=this.disposables.indexOf(t);-1!==n&&(e=!0,this.disposables.splice(n,1),this.length--,t.dispose())}return e},k.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var t=this.disposables.slice(0);this.disposables=[],this.length=0;for(var e=0,n=t.length;n>e;e++)t[e].dispose()}},k.clear=function(){var t=this.disposables.slice(0);this.disposables=[],this.length=0;for(var e=0,n=t.length;n>e;e++)t[e].dispose()},k.contains=function(t){return-1!==this.disposables.indexOf(t)},k.toArray=function(){return this.disposables.slice(0)};var q=y.Disposable=function(t){this.isDisposed=!1,this.action=t};q.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var T=q.create=function(t){return new q(t)},j=q.empty={dispose:n},I=y.SingleAssignmentDisposable=function(){this.isDisposed=!1,this.current=null},M=I.prototype;M.disposable=function(t){return t?this.setDisposable(t):this.getDisposable()},M.getDisposable=function(){return this.current},M.setDisposable=function(t){if(this.current)throw Error("Disposable has already been assigned");var e=this.isDisposed;e||(this.current=t),e&&t&&t.dispose()},M.dispose=function(){var t;this.isDisposed||(this.isDisposed=!0,t=this.current,this.current=null),t&&t.dispose()};var P=y.SerialDisposable=function(){this.isDisposed=!1,this.current=null};P.prototype.getDisposable=function(){return this.current},P.prototype.setDisposable=function(t){var e,n=this.isDisposed;n||(e=this.current,this.current=t),e&&e.dispose(),n&&t&&t.dispose()},P.prototype.disposable=function(t){return t?(this.setDisposable(t),e):this.getDisposable()},P.prototype.dispose=function(){var t;this.isDisposed||(this.isDisposed=!0,t=this.current,this.current=null),t&&t.dispose()};var L=y.RefCountDisposable=function(){function t(t){this.disposable=t,this.disposable.count++,this.isInnerDisposed=!1}function e(t){this.underlyingDisposable=t,this.isDisposed=!1,this.isPrimaryDisposed=!1,this.count=0}return t.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()))},e.prototype.dispose=function(){this.isDisposed||this.isPrimaryDisposed||(this.isPrimaryDisposed=!0,0===this.count&&(this.isDisposed=!0,this.underlyingDisposable.dispose()))},e.prototype.getDisposable=function(){return this.isDisposed?j:new t(this)},e}();f.prototype.dispose=function(){var t=this;this.scheduler.schedule(function(){t.isDisposed||(t.isDisposed=!0,t.disposable.dispose())})},p.prototype.invoke=function(){this.disposable.disposable(this.invokeCore())},p.prototype.compareTo=function(t){return this.comparer(this.dueTime,t.dueTime)},p.prototype.isCancelled=function(){return this.disposable.isDisposed},p.prototype.invokeCore=function(){return this.action(this.scheduler,this.state)};var V=y.Scheduler=function(){function e(t,e,n,r){this.now=t,this._schedule=e,this._scheduleRelative=n,this._scheduleAbsolute=r}function n(t,e){var n=e.first,r=e.second,i=new R,o=function(e){r(e,function(e){var n=!1,r=!1,s=t.scheduleWithState(e,function(t,e){return n?i.remove(s):r=!0,o(e),j});r||(i.add(s),n=!0)})};return o(n),i}function r(t,e,n){var r=e.first,i=e.second,o=new R,s=function(e){i(e,function(e,r){var i=!1,u=!1,c=t[n].call(t,e,r,function(t,e){return i?o.remove(c):u=!0,s(e),j});u||(o.add(c),i=!0)})};return s(r),o}function o(t,e){return e(),j}var s=e.prototype;return s.catchException=function(t){return new K(this,t)},s.schedulePeriodic=function(t,e){return this.schedulePeriodicWithState(null,t,function(){e()})},s.schedulePeriodicWithState=function(e,n,r){var i=e,o=t.setInterval(function(){i=r(i)},n);return T(function(){t.clearInterval(o)})},s.schedule=function(t){return this._schedule(t,o)},s.scheduleWithState=function(t,e){return this._schedule(t,e)},s.scheduleWithRelative=function(t,e){return this._scheduleRelative(e,t,o)},s.scheduleWithRelativeAndState=function(t,e,n){return this._scheduleRelative(t,e,n)},s.scheduleWithAbsolute=function(t,e){return this._scheduleAbsolute(e,t,o)},s.scheduleWithAbsoluteAndState=function(t,e,n){return this._scheduleAbsolute(t,e,n)},s.scheduleRecursive=function(t){return this.scheduleRecursiveWithState(t,function(t,e){t(function(){e(t)})})},s.scheduleRecursiveWithState=function(t,e){return this.scheduleWithState({first:t,second:e},function(t,e){return n(t,e)})},s.scheduleRecursiveWithRelative=function(t,e){return this.scheduleRecursiveWithRelativeAndState(e,t,function(t,e){t(function(n){e(t,n)})})},s.scheduleRecursiveWithRelativeAndState=function(t,e,n){return this._scheduleRelative({first:t,second:n},e,function(t,e){return r(t,e,"scheduleWithRelativeAndState")})},s.scheduleRecursiveWithAbsolute=function(t,e){return this.scheduleRecursiveWithAbsoluteAndState(e,t,function(t,e){t(function(n){e(t,n)})})},s.scheduleRecursiveWithAbsoluteAndState=function(t,e,n){return this._scheduleAbsolute({first:t,second:n},e,function(t,e){return r(t,e,"scheduleWithAbsoluteAndState")})},e.now=i,e.normalize=function(t){return 0>t&&(t=0),t},e}(),z="Scheduler is not allowed to block the thread",F=V.immediate=function(){function t(t,e){return e(this,t)}function e(t,e,n){if(e>0)throw Error(z);return n(this,t)}function n(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new V(i,t,e,n)}(),B=V.currentThread=function(){function t(){o=new W(4)}function e(t,e){return this.scheduleWithRelativeAndState(t,0,e)}function n(e,n,r){var i,s=this.now()+V.normalize(n),u=new p(this,e,r,s);if(o)o.enqueue(u);else{i=new t;try{o.enqueue(u),i.run()}catch(c){throw c}finally{i.dispose()}}return u.disposable}function r(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}var o;t.prototype.dispose=function(){o=null},t.prototype.run=function(){for(var t;o.length>0;)if(t=o.dequeue(),!t.isCancelled()){for(;t.dueTime-V.now()>0;);t.isCancelled()||t.invoke()}};var s=new V(i,e,n,r);return s.scheduleRequired=function(){return null===o},s.ensureTrampoline=function(t){return null===o?this.schedule(t):t()},s}(),H=function(){function t(t,e){e(0,this._period);try{this._state=this._action(this._state)}catch(n){throw this._cancel.dispose(),n}}function e(t,e,n,r){this._scheduler=t,this._state=e,this._period=n,this._action=r}return e.prototype.start=function(){var e=new I;return this._cancel=e,e.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,t.bind(this))),e},e}();y.VirtualTimeScheduler=function(t){function n(){return this.toDateTimeOffset(this.clock)}function r(t,e){return this.scheduleAbsoluteWithState(t,this.clock,e)}function i(t,e,n){return this.scheduleRelativeWithState(t,this.toRelative(e),n)}function o(t,e,n){return this.scheduleRelativeWithState(t,this.toRelative(e-this.now()),n)}function s(t,e){return e(),j}function u(e,s){this.clock=e,this.comparer=s,this.isEnabled=!1,this.queue=new W(1024),t.call(this,n,r,i,o)}C(u,t);var c=u.prototype;return c.schedulePeriodicWithState=function(t,e,n){var r=new H(this,t,e,n);return r.start()},c.scheduleRelativeWithState=function(t,e,n){var r=this.add(this.clock,e);return this.scheduleAbsoluteWithState(t,r,n)},c.scheduleRelative=function(t,e){return this.scheduleRelativeWithState(e,t,s)},c.start=function(){var t;if(!this.isEnabled){this.isEnabled=!0;do t=this.getNext(),null!==t?(this.comparer(t.dueTime,this.clock)>0&&(this.clock=t.dueTime),t.invoke()):this.isEnabled=!1;while(this.isEnabled)}},c.stop=function(){this.isEnabled=!1},c.advanceTo=function(t){var e,n=this.comparer(this.clock,t);if(this.comparer(this.clock,t)>0)throw Error(g);if(0!==n&&!this.isEnabled){this.isEnabled=!0;do e=this.getNext(),null!==e&&0>=this.comparer(e.dueTime,t)?(this.comparer(e.dueTime,this.clock)>0&&(this.clock=e.dueTime),e.invoke()):this.isEnabled=!1;while(this.isEnabled);this.clock=t}},c.advanceBy=function(t){var n=this.add(this.clock,t),r=this.comparer(this.clock,n);if(r>0)throw Error(g);return 0!==r?this.advanceTo(n):e},c.sleep=function(t){var e=this.add(this.clock,t);if(this.comparer(this.clock,e)>=0)throw Error(g);this.clock=e},c.getNext=function(){for(var t;this.queue.length>0;){if(t=this.queue.peek(),!t.isCancelled())return t;this.queue.dequeue()}return null},c.scheduleAbsolute=function(t,e){return this.scheduleAbsoluteWithState(e,t,s)},c.scheduleAbsoluteWithState=function(t,e,n){var r=this,i=function(t,e){return r.queue.remove(o),n(t,e)},o=new p(r,t,i,e,r.comparer);return r.queue.enqueue(o),o.disposable},u}(V),y.HistoricalScheduler=function(t){function e(e,n){var r=null==e?0:e,i=n||s;t.call(this,r,i)}C(e,t);var n=e.prototype;return n.add=function(t,e){return t+e},n.toDateTimeOffset=function(t){return new Date(t).getTime()},n.toRelative=function(t){return t},e}(y.VirtualTimeScheduler);var U,G=n;(function(){function n(){if(!t.postMessage||t.importScripts)return!1;var e=!1,n=t.onmessage;return t.onmessage=function(){e=!0},t.postMessage("","*"),t.onmessage=n,e}function r(t){if("string"==typeof t.data&&t.data.substring(0,i.length)===i){var e=t.data.substring(i.length),n=o[e];n(),delete o[e]}}if(t.process!==e&&"[object process]"===Object.prototype.toString.call(t.process))U=t.process.nextTick;else if("function"==typeof t.setImmediate)U=t.setImmediate,G=t.clearImmediate;else if(n()){var i="ms.rx.schedule"+Math.random(),o={},s=0;t.addEventListener?t.addEventListener("message",r,!1):t.attachEvent("onmessage",r,!1),U=function(e){var n=s++;o[n]=e,t.postMessage(i+n,"*")}}else if(t.MessageChannel){var u=new t.MessageChannel,c={},a=0;u.port1.onmessage=function(t){var e=t.data,n=c[e];n(),delete c[e]},U=function(t){var e=a++;c[e]=t,u.port2.postMessage(e)}}else"document"in t&&"onreadystatechange"in t.document.createElement("script")?U=function(e){var n=t.document.createElement("script");n.onreadystatechange=function(){e(),n.onreadystatechange=null,n.parentNode.removeChild(n),n=null},t.document.documentElement.appendChild(n)}:(U=function(e){return t.setTimeout(e,0)},G=t.clearTimeout)})();var J=V.timeout=function(){function e(t,e){var n=this,r=new I,i=U(function(){r.isDisposed||r.setDisposable(e(n,t))});return new R(r,T(function(){G(i)}))}function n(e,n,r){var i=this,o=V.normalize(n);if(0===o)return i.scheduleWithState(e,r);var s=new I,u=t.setTimeout(function(){s.isDisposed||s.setDisposable(r(i,e))},o);return new R(s,T(function(){t.clearTimeout(u)}))}function r(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new V(i,e,n,r)}(),K=function(t){function e(){return this._scheduler.now()}function n(t,e){return this._scheduler.scheduleWithState(t,this._wrap(e))}function r(t,e,n){return this._scheduler.scheduleWithRelativeAndState(t,e,this._wrap(n))}function i(t,e,n){return this._scheduler.scheduleWithAbsoluteAndState(t,e,this._wrap(n))}function o(o,s){this._scheduler=o,this._handler=s,this._recursiveOriginal=null,this._recursiveWrapper=null,t.call(this,e,n,r,i)}return C(o,t),o.prototype._clone=function(t){return new o(t,this._handler)},o.prototype._wrap=function(t){var e=this;return function(n,r){try{return t(e._getRecursiveWrapper(n),r)}catch(i){if(!e._handler(i))throw i;return j}}},o.prototype._getRecursiveWrapper=function(t){if(!this._recursiveOriginal!==t){this._recursiveOriginal=t;var e=this._clone(t);e._recursiveOriginal=t,e._recursiveWrapper=e,this._recursiveWrapper=e}return this._recursiveWrapper},o.prototype.schedulePeriodicWithState=function(t,e,n){var r=this,i=!1,o=new I;return o.setDisposable(this._scheduler.schedulePeriodicWithState(t,e,function(t){if(i)return null;try{return n(t)}catch(e){if(i=!0,!r._handler(e))throw e;return o.dispose(),null}})),o},o}(V),Q=y.Notification=function(){function t(t,e){this.hasValue=null==e?!1:e,this.kind=t}var e=t.prototype;return e.accept=function(t,e,n){return 1===arguments.length&&"object"==typeof t?this._acceptObservable(t):this._accept(t,e,n)},e.toObservable=function(t){var e=this;return t=t||F,new Ae(function(n){return t.schedule(function(){e._acceptObservable(n),"N"===e.kind&&n.onCompleted()})})},e.equals=function(t){var e=null==t?"":""+t;return""+this===e},t}(),X=Q.createOnNext=function(){function t(t){return t(this.value)}function e(t){return t.onNext(this.value)}function n(){return"OnNext("+this.value+")"}return function(r){var i=new Q("N",!0);return i.value=r,i._accept=t.bind(i),i._acceptObservable=e.bind(i),i.toString=n.bind(i),i}}(),Y=Q.createOnError=function(){function t(t,e){return e(this.exception)}function e(t){return t.onError(this.exception)}function n(){return"OnError("+this.exception+")"}return function(r){var i=new Q("E");return i.exception=r,i._accept=t.bind(i),i._acceptObservable=e.bind(i),i.toString=n.bind(i),i}}(),Z=Q.createOnCompleted=function(){function t(t,e,n){return n()}function e(t){return t.onCompleted()}function n(){return"OnCompleted()"}return function(){var r=new Q("C");return r._accept=t.bind(r),r._acceptObservable=e.bind(r),r.toString=n.bind(r),r}}(),$=y.Internals.Enumerator=function(t,e,n){this.moveNext=t,this.getCurrent=e,this.dispose=n},te=$.create=function(t,e,r){var i=!1;return r||(r=n),new $(function(){if(i)return!1;var e=t();return e||(i=!0,r()),e},function(){return e()},function(){i||(r(),i=!0)})},ee=y.Internals.Enumerable=function(){function t(t){this.getEnumerator=t}return t.prototype.concat=function(){var t=this;return new Ae(function(n){var r=t.getEnumerator(),i=!1,o=new P,s=F.scheduleRecursive(function(t){var s,u,c=!1;if(!i){try{c=r.moveNext(),c?s=r.getCurrent():r.dispose()}catch(a){u=a,r.dispose()}if(u)return n.onError(u),e;if(!c)return n.onCompleted(),e;var h=new I;o.setDisposable(h),h.setDisposable(s.subscribe(n.onNext.bind(n),n.onError.bind(n),function(){t()}))}});return new R(o,s,T(function(){i=!0,r.dispose()}))})},t.prototype.catchException=function(){var t=this;return new Ae(function(n){var r,i=t.getEnumerator(),o=!1,s=new P,u=F.scheduleRecursive(function(t){var u,c,a;if(a=!1,!o){try{a=i.moveNext(),a&&(u=i.getCurrent())}catch(h){c=h}if(c)return n.onError(c),e;if(!a)return r?n.onError(r):n.onCompleted(),e;var l=new I;s.setDisposable(l),l.setDisposable(u.subscribe(n.onNext.bind(n),function(e){r=e,t()},n.onCompleted.bind(n)))}});return new R(s,u,T(function(){o=!0}))})},t}(),ne=ee.repeat=function(t,n){return n===e&&(n=-1),new ee(function(){var e,r=n;return te(function(){return 0===r?!1:(r>0&&r--,e=t,!0)},function(){return e})})},re=ee.forEach=function(t,e){return e||(e=r),new ee(function(){var n,r=-1;return te(function(){return++r<t.length?(n=e(t[r],r),!0):!1},function(){return n})})},ie=y.Observer=function(){};ie.prototype.toNotifier=function(){var t=this;return function(e){return e.accept(t)}},ie.prototype.asObserver=function(){return new ce(this.onNext.bind(this),this.onError.bind(this),this.onCompleted.bind(this))},ie.prototype.checked=function(){return new ae(this)};var oe=ie.create=function(t,e,r){return t||(t=n),e||(e=c),r||(r=n),new ce(t,e,r)};ie.fromNotifier=function(t){return new ce(function(e){return t(X(e))},function(e){return t(Y(e))},function(){return t(Z())})};var se,ue=y.Internals.AbstractObserver=function(t){function e(){this.isStopped=!1,t.call(this)}return C(e,t),e.prototype.onNext=function(t){this.isStopped||this.next(t)},e.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.error(t))},e.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.completed())},e.prototype.dispose=function(){this.isStopped=!0},e.prototype.fail=function(){return this.isStopped?!1:(this.isStopped=!0,this.error(!0),!0)},e}(ie),ce=y.AnonymousObserver=function(t){function e(e,n,r){t.call(this),this._onNext=e,this._onError=n,this._onCompleted=r}return C(e,t),e.prototype.next=function(t){this._onNext(t)},e.prototype.error=function(t){this._onError(t)},e.prototype.completed=function(){this._onCompleted()},e}(ue),ae=function(t){function e(e){t.call(this),this._observer=e,this._state=0}C(e,t);var n=e.prototype;return n.onNext=function(t){this.checkAccess();try{this._observer.onNext(t)}catch(e){throw e}finally{this._state=0}},n.onError=function(t){this.checkAccess();try{this._observer.onError(t)}catch(e){throw e}finally{this._state=2}},n.onCompleted=function(){this.checkAccess();try{this._observer.onCompleted()}catch(t){throw t}finally{this._state=2}},n.checkAccess=function(){if(1===this._state)throw Error("Re-entrancy detected");if(2===this._state)throw Error("Observer completed");0===this._state&&(this._state=1)},e}(ie),he=y.Internals.ScheduledObserver=function(t){function n(e,n){t.call(this),this.scheduler=e,this.observer=n,this.isAcquired=!1,this.hasFaulted=!1,this.queue=[],this.disposable=new P}return C(n,t),n.prototype.next=function(t){var e=this;this.queue.push(function(){e.observer.onNext(t)})},n.prototype.error=function(t){var e=this;this.queue.push(function(){e.observer.onError(t)})},n.prototype.completed=function(){var t=this;this.queue.push(function(){t.observer.onCompleted()})},n.prototype.ensureActive=function(){var t=!1,n=this;!this.hasFaulted&&this.queue.length>0&&(t=!this.isAcquired,this.isAcquired=!0),t&&this.disposable.setDisposable(this.scheduler.scheduleRecursive(function(t){var r;if(!(n.queue.length>0))return n.isAcquired=!1,e;r=n.queue.shift();try{r()}catch(i){throw n.queue=[],n.hasFaulted=!0,i}t()}))},n.prototype.dispose=function(){t.prototype.dispose.call(this),this.disposable.dispose()},n}(ue),le=function(t){function e(){t.apply(this,arguments)}return C(e,t),e.prototype.next=function(e){t.prototype.next.call(this,e),this.ensureActive()},e.prototype.error=function(e){t.prototype.error.call(this,e),this.ensureActive()},e.prototype.completed=function(){t.prototype.completed.call(this),this.ensureActive()},e}(he),fe=y.Observable=function(){function t(t){this._subscribe=t}return se=t.prototype,se.finalValue=function(){var t=this;return new Ae(function(e){var n,r=!1;return t.subscribe(function(t){r=!0,n=t},e.onError.bind(e),function(){r?(e.onNext(n),e.onCompleted()):e.onError(Error(w))})})},se.subscribe=se.forEach=function(t,e,n){var r;return r="object"==typeof t?t:oe(t,e,n),this._subscribe(r)},se.toArray=function(){function t(t,e){var n=t.slice(0);return n.push(e),n}return this.scan([],t).startWith([]).finalValue()},t}();fe.start=function(t,e){return pe(t,e)()};var pe=fe.toAsync=function(t,n,r){return n||(n=J),function(){var i=x.call(arguments,0),o=new Oe;return n.schedule(function(){var n;try{n=t.apply(r,i)}catch(s){return o.onError(s),e}o.onNext(n),o.onCompleted()}),o.asObservable()}};se.observeOn=function(t){var e=this;return new Ae(function(n){return e.subscribe(new le(t,n))})},se.subscribeOn=function(t){var e=this;return new Ae(function(n){var r=new I,i=new P;return i.setDisposable(r),r.setDisposable(t.schedule(function(){i.setDisposable(new f(t,e.subscribe(n)))})),i})},fe.create=function(t){return new Ae(function(e){return T(t(e))})},fe.createWithDisposable=function(t){return new Ae(t)};var de=fe.defer=function(t){return new Ae(function(e){var n;try{n=t()}catch(r){return we(r).subscribe(e)}return n.subscribe(e)})},be=fe.empty=function(t){return t||(t=F),new Ae(function(e){return t.schedule(function(){e.onCompleted()})})},ve=fe.fromArray=function(t,e){return e||(e=B),new Ae(function(n){var r=0;return e.scheduleRecursive(function(e){t.length>r?(n.onNext(t[r++]),e()):n.onCompleted()})})};fe.generate=function(t,n,r,i,o){return o||(o=B),new Ae(function(s){var u=!0,c=t;return o.scheduleRecursive(function(t){var o,a;try{u?u=!1:c=r(c),o=n(c),o&&(a=i(c))}catch(h){return s.onError(h),e}o?(s.onNext(a),t()):s.onCompleted()})})};var me=fe.never=function(){return new Ae(function(){return j})};fe.range=function(t,e,n){return n||(n=B),new Ae(function(r){return n.scheduleRecursiveWithState(0,function(n,i){e>n?(r.onNext(t+n),i(n+1)):r.onCompleted()})})},fe.repeat=function(t,n,r){return r||(r=B),n==e&&(n=-1),ye(t,r).repeat(n)};var ye=fe.returnValue=function(t,e){return e||(e=F),new Ae(function(n){return e.schedule(function(){n.onNext(t),n.onCompleted()})})},we=fe.throwException=function(t,e){return e||(e=F),new Ae(function(n){return e.schedule(function(){n.onError(t)})})};fe.using=function(t,e){return new Ae(function(n){var r,i,o=j;try{r=t(),r&&(o=r),i=e(r)}catch(s){return new R(we(s).subscribe(n),o)}return new R(i.subscribe(n),o)})},se.amb=function(t){var e=this;return new Ae(function(n){function r(){o||(o=s,a.dispose())}function i(){o||(o=u,c.dispose())}var o,s="L",u="R",c=new I,a=new I;return c.setDisposable(e.subscribe(function(t){r(),o===s&&n.onNext(t)},function(t){r(),o===s&&n.onError(t)},function(){r(),o===s&&n.onCompleted()})),a.setDisposable(t.subscribe(function(t){i(),o===u&&n.onNext(t)},function(t){i(),o===u&&n.onError(t)},function(){i(),o===u&&n.onCompleted()})),new R(c,a)})},fe.amb=function(){function t(t,e){return t.amb(e)}for(var e=me(),n=h(arguments,0),r=0,i=n.length;i>r;r++)e=t(e,n[r]);return e},se.catchException=function(t){return"function"==typeof t?d(this,t):ge([this,t])};var ge=fe.catchException=function(){var t=h(arguments,0);return re(t).catchException()};se.combineLatest=function(){var t=x.call(arguments);return Array.isArray(t[0])?t[0].unshift(this):t.unshift(this),Ee.apply(this,t)};var Ee=fe.combineLatest=function(){var t=x.call(arguments),n=t.pop();return Array.isArray(t[0])&&(t=t[0]),new Ae(function(r){function i(t){var i;if(c[t]=!0,a||(a=c.every(function(t){return t}))){try{i=n.apply(null,f)}catch(o){return r.onError(o),e}r.onNext(i)}else h.filter(function(e,n){return n!==t}).every(function(t){return t})&&r.onCompleted()}function o(t){h[t]=!0,h.every(function(t){return t})&&r.onCompleted()}for(var s=function(){return!1},u=t.length,c=l(u,s),a=!1,h=l(u,s),f=Array(u),p=Array(u),d=0;u>d;d++)(function(e){p[e]=new I,p[e].setDisposable(t[e].subscribe(function(t){f[e]=t,i(e)},r.onError.bind(r),function(){o(e)}))})(d);return new R(p)})};se.concat=function(){var t=x.call(arguments,0);return t.unshift(this),xe.apply(this,t)};var xe=fe.concat=function(){var t=h(arguments,0);return re(t).concat()};se.concatObservable=se.concatAll=function(){return this.merge(1)},se.merge=function(t){if("number"!=typeof t)return Ce(this,t);var e=this;return new Ae(function(n){var r=0,i=new R,o=!1,s=[],u=function(t){var e=new I;i.add(e),e.setDisposable(t.subscribe(n.onNext.bind(n),n.onError.bind(n),function(){var t;i.remove(e),s.length>0?(t=s.shift(),u(t)):(r--,o&&0===r&&n.onCompleted())}))};return i.add(e.subscribe(function(e){t>r?(r++,u(e)):s.push(e)},n.onError.bind(n),function(){o=!0,0===r&&n.onCompleted()})),i})};var Ce=fe.merge=function(){var t,e;return arguments[0]?arguments[0].now?(t=arguments[0],e=x.call(arguments,1)):(t=F,e=x.call(arguments,0)):(t=F,e=x.call(arguments,1)),Array.isArray(e[0])&&(e=e[0]),ve(e,t).mergeObservable()};se.mergeObservable=se.mergeAll=function(){var t=this;return new Ae(function(e){var n=new R,r=!1,i=new I;return n.add(i),i.setDisposable(t.subscribe(function(t){var i=new I;n.add(i),i.setDisposable(t.subscribe(function(t){e.onNext(t)},e.onError.bind(e),function(){n.remove(i),r&&1===n.length&&e.onCompleted()}))},e.onError.bind(e),function(){r=!0,1===n.length&&e.onCompleted()})),n})},se.onErrorResumeNext=function(t){if(!t)throw Error("Second observable is required");return De([this,t])};var De=fe.onErrorResumeNext=function(){var t=h(arguments,0);return new Ae(function(e){var n=0,r=new P,i=F.scheduleRecursive(function(i){var o,s;t.length>n?(o=t[n++],s=new I,r.setDisposable(s),s.setDisposable(o.subscribe(e.onNext.bind(e),function(){i()},function(){i()}))):e.onCompleted()});return new R(r,i)})};se.skipUntil=function(t){var e=this;return new Ae(function(n){var r=!1,i=new R(e.subscribe(function(t){r&&n.onNext(t)},n.onError.bind(n),function(){r&&n.onCompleted()})),o=new I;return i.add(o),o.setDisposable(t.subscribe(function(){r=!0,o.dispose()},n.onError.bind(n),function(){o.dispose()})),i})},se.switchLatest=function(){var t=this;return new Ae(function(e){var n=!1,r=new P,i=!1,o=0,s=t.subscribe(function(t){var s=new I,u=++o;n=!0,r.setDisposable(s),s.setDisposable(t.subscribe(function(t){o===u&&e.onNext(t)},function(t){o===u&&e.onError(t)},function(){o===u&&(n=!1,i&&e.onCompleted())}))},e.onError.bind(e),function(){i=!0,n||e.onCompleted()});return new R(s,r)})},se.takeUntil=function(t){var e=this;return new Ae(function(r){return new R(e.subscribe(r),t.subscribe(r.onCompleted.bind(r),r.onError.bind(r),n))})},se.zip=function(){if(Array.isArray(arguments[0]))return b.apply(this,arguments);var t=this,n=x.call(arguments),r=n.pop();return n.unshift(t),new Ae(function(i){function o(t){c[t]=!0,c.every(function(t){return t})&&i.onCompleted()}for(var s=n.length,u=l(s,function(){return[]}),c=l(s,function(){return!1}),a=function(n){var o,s;if(u.every(function(t){return t.length>0})){try{s=u.map(function(t){return t.shift()}),o=r.apply(t,s)}catch(a){return i.onError(a),e}i.onNext(o)}else c.filter(function(t,e){return e!==n}).every(function(t){return t})&&i.onCompleted()},h=Array(s),f=0;s>f;f++)(function(t){h[t]=new I,h[t].setDisposable(n[t].subscribe(function(e){u[t].push(e),a(t)},i.onError.bind(i),function(){o(t)}))})(f);return new R(h)})},fe.zip=function(t,e){var n=t[0],r=t.slice(1);return r.push(e),n.zip.apply(n,r)},se.asObservable=function(){var t=this;return new Ae(function(e){return t.subscribe(e)})},se.bufferWithCount=function(t,n){return n===e&&(n=t),this.windowWithCount(t,n).selectMany(function(t){return t.toArray()}).where(function(t){return t.length>0})},se.dematerialize=function(){var t=this;return new Ae(function(e){return t.subscribe(function(t){return t.accept(e)},e.onError.bind(e),e.onCompleted.bind(e))})},se.distinctUntilChanged=function(t,n){var i=this;return t||(t=r),n||(n=o),new Ae(function(r){var o,s=!1;return i.subscribe(function(i){var u,c=!1;try{u=t(i)}catch(a){return r.onError(a),e}if(s)try{c=n(o,u)}catch(a){return r.onError(a),e}s&&c||(s=!0,o=u,r.onNext(i))},r.onError.bind(r),r.onCompleted.bind(r))})},se.doAction=function(t,e,n){var r,i=this;return"function"==typeof t?r=t:(r=t.onNext.bind(t),e=t.onError.bind(t),n=t.onCompleted.bind(t)),new Ae(function(t){return i.subscribe(function(e){try{r(e)}catch(n){t.onError(n)}t.onNext(e)},function(n){if(e){try{e(n)}catch(r){t.onError(r)}t.onError(n)}else t.onError(n)},function(){if(n){try{n()}catch(e){t.onError(e)}t.onCompleted()}else t.onCompleted()})})},se.finallyAction=function(t){var e=this;return new Ae(function(n){var r=e.subscribe(n);return T(function(){try{r.dispose()}catch(e){throw e}finally{t()}})})},se.ignoreElements=function(){var t=this;return new Ae(function(e){return t.subscribe(n,e.onError.bind(e),e.onCompleted.bind(e))})},se.materialize=function(){var t=this;return new Ae(function(e){return t.subscribe(function(t){e.onNext(X(t))},function(t){e.onNext(Y(t)),e.onCompleted()},function(){e.onNext(Z()),e.onCompleted()})})},se.repeat=function(t){return ne(this,t).concat()},se.retry=function(t){return ne(this,t).catchException()},se.scan=function(){var t,e,n=!1;2===arguments.length?(t=arguments[0],e=arguments[1],n=!0):e=arguments[0];var r=this;return de(function(){var i,o=!1;return r.select(function(r){return o?i=e(i,r):(i=n?e(t,r):r,o=!0),i})})},se.skipLast=function(t){var e=this;return new Ae(function(n){var r=[];
return e.subscribe(function(e){r.push(e),r.length>t&&n.onNext(r.shift())},n.onError.bind(n),n.onCompleted.bind(n))})},se.startWith=function(){var t,n,r=0;return arguments.length>0&&null!=arguments[0]&&arguments[0].now!==e?(n=arguments[0],r=1):n=F,t=x.call(arguments,r),re([ve(t,n),this]).concat()},se.takeLast=function(t,e){return this.takeLastBuffer(t).selectMany(function(t){return ve(t,e)})},se.takeLastBuffer=function(t){var e=this;return new Ae(function(n){var r=[];return e.subscribe(function(e){r.push(e),r.length>t&&r.shift()},n.onError.bind(n),function(){n.onNext(r),n.onCompleted()})})},se.windowWithCount=function(t,e){var n=this;if(0>=t)throw Error(g);if(null==e&&(e=t),0>=e)throw Error(g);return new Ae(function(r){var i=new I,o=new L(i),s=0,u=[],c=function(){var t=new We;u.push(t),r.onNext(A(t,o))};return c(),i.setDisposable(n.subscribe(function(n){for(var r,i=0,o=u.length;o>i;i++)u[i].onNext(n);var a=s-t+1;a>=0&&0===a%e&&(r=u.shift(),r.onCompleted()),s++,0===s%e&&c()},function(t){for(;u.length>0;)u.shift().onError(t);r.onError(t)},function(){for(;u.length>0;)u.shift().onCompleted();r.onCompleted()})),o})},se.defaultIfEmpty=function(t){var n=this;return t===e&&(t=null),new Ae(function(e){var r=!1;return n.subscribe(function(t){r=!0,e.onNext(t)},e.onError.bind(e),function(){r||e.onNext(t),e.onCompleted()})})},se.distinct=function(t,n){var i=this;return t||(t=r),n||(n=u),new Ae(function(r){var o={};return i.subscribe(function(i){var s,u,c,a=!1;try{s=t(i),u=n(s)}catch(h){return r.onError(h),e}for(c in o)if(u===c){a=!0;break}a||(o[u]=null,r.onNext(i))},r.onError.bind(r),r.onCompleted.bind(r))})},se.groupBy=function(t,e,n){return this.groupByUntil(t,e,function(){return me()},n)},se.groupByUntil=function(t,i,o,s){var c=this;return i||(i=r),s||(s=u),new Ae(function(r){var u={},a=new R,h=new L(a);return a.add(c.subscribe(function(c){var l,f,p,d,b,v,m,y,w,g,E;try{m=t(c),y=s(m)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}b=!1;try{g=u[y],g||(g=new We,u[y]=g,b=!0)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}if(b){v=new _e(m,g,h),f=new _e(m,g);try{l=o(f)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}r.onNext(v),w=new I,a.add(w),d=function(){y in u&&(delete u[y],g.onCompleted()),a.remove(w)},w.setDisposable(l.take(1).subscribe(n,function(t){for(E in u)u[E].onError(t);r.onError(t)},function(){d()}))}try{p=i(c)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}g.onNext(p)},function(t){for(var e in u)u[e].onError(t);r.onError(t)},function(){for(var t in u)u[t].onCompleted();r.onCompleted()})),h})},se.select=function(t,n){var r=this;return new Ae(function(i){var o=0;return r.subscribe(function(s){var u;try{u=t.call(n,s,o++,r)}catch(c){return i.onError(c),e}i.onNext(u)},i.onError.bind(i),i.onCompleted.bind(i))})},se.map=se.select,se.selectMany=se.flatMap=function(t,e){return e?this.selectMany(function(n){return t(n).select(function(t){return e(n,t)})}):"function"==typeof t?v.call(this,t):v.call(this,function(){return t})},se.skip=function(t){if(0>t)throw Error(g);var e=this;return new Ae(function(n){var r=t;return e.subscribe(function(t){0>=r?n.onNext(t):r--},n.onError.bind(n),n.onCompleted.bind(n))})},se.skipWhile=function(t){var n=this;return new Ae(function(r){var i=0,o=!1;return n.subscribe(function(n){if(!o)try{o=!t(n,i++)}catch(s){return r.onError(s),e}o&&r.onNext(n)},r.onError.bind(r),r.onCompleted.bind(r))})},se.take=function(t,e){if(0>t)throw Error(g);if(0===t)return be(e);var n=this;return new Ae(function(e){var r=t;return n.subscribe(function(t){r>0&&(r--,e.onNext(t),0===r&&e.onCompleted())},e.onError.bind(e),e.onCompleted.bind(e))})},se.takeWhile=function(t){var n=this;return new Ae(function(r){var i=0,o=!0;return n.subscribe(function(n){if(o){try{o=t(n,i++)}catch(s){return r.onError(s),e}o?r.onNext(n):r.onCompleted()}},r.onError.bind(r),r.onCompleted.bind(r))})},se.where=function(t,n){var r=this;return new Ae(function(i){var o=0;return r.subscribe(function(s){var u;try{u=t.call(n,s,o++,r)}catch(c){return i.onError(c),e}u&&i.onNext(s)},i.onError.bind(i),i.onCompleted.bind(i))})},se.filter=se.where;var Ae=y.Internals.AnonymousObservable=function(t){function e(e){function n(t){var n=new Se(t);if(B.scheduleRequired())B.schedule(function(){try{n.disposable(e(n))}catch(t){if(!n.fail(t))throw t}});else try{n.disposable(e(n))}catch(r){if(!n.fail(r))throw r}return n}t.call(this,n)}return C(e,t),e}(fe),Se=function(t){function e(e){t.call(this),this.observer=e,this.m=new I}C(e,t);var n=e.prototype;return n.next=function(t){var e=!1;try{this.observer.onNext(t),e=!0}catch(n){throw n}finally{e||this.dispose()}},n.error=function(t){try{this.observer.onError(t)}catch(e){throw e}finally{this.dispose()}},n.completed=function(){try{this.observer.onCompleted()}catch(t){throw t}finally{this.dispose()}},n.disposable=function(t){return this.m.disposable(t)},n.dispose=function(){t.prototype.dispose.call(this),this.m.dispose()},e}(ue),_e=function(t){function e(t){return this.underlyingObservable.subscribe(t)}function n(n,r,i){t.call(this,e),this.key=n,this.underlyingObservable=i?new Ae(function(t){return new R(i.getDisposable(),r.subscribe(t))}):r}return C(n,t),n}(fe),Ne=function(t,e){this.subject=t,this.observer=e};Ne.prototype.dispose=function(){if(!this.subject.isDisposed&&null!==this.observer){var t=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(t,1),this.observer=null}};var We=y.Subject=function(t){function e(t){return a.call(this),this.isStopped?this.exception?(t.onError(this.exception),j):(t.onCompleted(),j):(this.observers.push(t),new Ne(this,t))}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.observers=[]}return C(n,t),D(n.prototype,ie,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(a.call(this),!this.isStopped){var t=this.observers.slice(0);this.isStopped=!0;for(var e=0,n=t.length;n>e;e++)t[e].onCompleted();this.observers=[]}},onError:function(t){if(a.call(this),!this.isStopped){var e=this.observers.slice(0);this.isStopped=!0,this.exception=t;for(var n=0,r=e.length;r>n;n++)e[n].onError(t);this.observers=[]}},onNext:function(t){if(a.call(this),!this.isStopped)for(var e=this.observers.slice(0),n=0,r=e.length;r>n;n++)e[n].onNext(t)},dispose:function(){this.isDisposed=!0,this.observers=null}}),n.create=function(t,e){return new Re(t,e)},n}(fe),Oe=y.AsyncSubject=function(t){function e(t){if(a.call(this),!this.isStopped)return this.observers.push(t),new Ne(this,t);var e=this.exception,n=this.hasValue,r=this.value;return e?t.onError(e):n?(t.onNext(r),t.onCompleted()):t.onCompleted(),j}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.value=null,this.hasValue=!1,this.observers=[],this.exception=null}return C(n,t),D(n.prototype,ie,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){var t,e,n;if(a.call(this),!this.isStopped){var r=this.observers.slice(0);this.isStopped=!0;var i=this.value,o=this.hasValue;if(o)for(e=0,n=r.length;n>e;e++)t=r[e],t.onNext(i),t.onCompleted();else for(e=0,n=r.length;n>e;e++)r[e].onCompleted();this.observers=[]}},onError:function(t){if(a.call(this),!this.isStopped){var e=this.observers.slice(0);this.isStopped=!0,this.exception=t;for(var n=0,r=e.length;r>n;n++)e[n].onError(t);this.observers=[]}},onNext:function(t){a.call(this),this.isStopped||(this.value=t,this.hasValue=!0)},dispose:function(){this.isDisposed=!0,this.observers=null,this.exception=null,this.value=null}}),n}(fe),Re=function(t){function e(t){return this.observable.subscribe(t)}function n(n,r){t.call(this,e),this.observer=n,this.observable=r}return C(n,t),D(n.prototype,ie,{onCompleted:function(){this.observer.onCompleted()},onError:function(t){this.observer.onError(t)},onNext:function(t){this.observer.onNext(t)}}),n}(fe);return"function"==typeof define&&"object"==typeof define.amd&&define.amd?(t.Rx=y,define(function(){return y})):(m?"object"==typeof module&&module&&module.exports==m?module.exports=y:m=y:t.Rx=y,e)})(this);

@@ -1,2 +0,2 @@

(function(t,e){function n(){}function r(t){return t}function i(){return(new Date).getTime()}function o(t,e){return t===e}function s(t,e){return t-e}function u(t){return""+t}function c(t){throw t}function a(){if(this.isDisposed)throw Error(E)}function h(t,e){return 1===t.length&&Array.isArray(t[e])?t[e]:x.call(t)}function l(t,e){for(var n=Array(t),r=0;t>r;r++)n[r]=e();return n}function f(t,e){this.scheduler=t,this.disposable=e,this.isDisposed=!1}function p(t,e,n,r,i){this.scheduler=t,this.state=e,this.action=n,this.dueTime=r,this.comparer=i||s,this.disposable=new T}function d(t,n){return new Ee(function(r){var i=new T,o=new I;return o.setDisposable(i),i.setDisposable(t.subscribe(r.onNext.bind(r),function(t){var i,s;try{s=n(t)}catch(u){return r.onError(u),e}i=new T,o.setDisposable(i),i.setDisposable(s.subscribe(r))},r.onCompleted.bind(r))),o})}function b(t,n){var r=this;return new Ee(function(i){var o=0,s=t.length;return r.subscribe(function(r){if(s>o){var u,c=t[o++];try{u=n(r,c)}catch(a){return i.onError(a),e}i.onNext(u)}else i.onCompleted()},i.onError.bind(i),i.onCompleted.bind(i))})}function v(t){return this.select(t).mergeObservable()}var m="object"==typeof exports&&exports&&("object"==typeof global&&global&&global==global.global&&(t=global),exports),y={Internals:{}},w="Sequence contains no elements.",g="Argument out of range",E="Object has been disposed",x=Array.prototype.slice;({}).hasOwnProperty;var C=this.inherits=y.Internals.inherits=function(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n},D=y.Internals.addProperties=function(t){for(var e=x.call(arguments,1),n=0,r=e.length;r>n;n++){var i=e[n];for(var o in i)t[o]=i[o]}},A=y.Internals.addRef=function(t,e){return new Ee(function(n){return new W(e.getDisposable(),t.subscribe(n))})},S=function(t,e){this.id=t,this.value=e};S.prototype.compareTo=function(t){var e=this.value.compareTo(t.value);return 0===e&&(e=this.id-t.id),e};var _=function(t){this.items=Array(t),this.length=0},N=_.prototype;N.isHigherPriority=function(t,e){return 0>this.items[t].compareTo(this.items[e])},N.percolate=function(t){if(!(t>=this.length||0>t)){var e=t-1>>1;if(!(0>e||e===t)&&this.isHigherPriority(t,e)){var n=this.items[t];this.items[t]=this.items[e],this.items[e]=n,this.percolate(e)}}},N.heapify=function(t){if(t===e&&(t=0),!(t>=this.length||0>t)){var n=2*t+1,r=2*t+2,i=t;if(this.length>n&&this.isHigherPriority(n,i)&&(i=n),this.length>r&&this.isHigherPriority(r,i)&&(i=r),i!==t){var o=this.items[t];this.items[t]=this.items[i],this.items[i]=o,this.heapify(i)}}},N.peek=function(){return this.items[0].value},N.removeAt=function(t){this.items[t]=this.items[--this.length],delete this.items[this.length],this.heapify()},N.dequeue=function(){var t=this.peek();return this.removeAt(0),t},N.enqueue=function(t){var e=this.length++;this.items[e]=new S(_.count++,t),this.percolate(e)},N.remove=function(t){for(var e=0;this.length>e;e++)if(this.items[e].value===t)return this.removeAt(e),!0;return!1},_.count=0;var W=y.CompositeDisposable=function(){this.disposables=h(arguments,0),this.isDisposed=!1,this.length=this.disposables.length},R=W.prototype;R.add=function(t){this.isDisposed?t.dispose():(this.disposables.push(t),this.length++)},R.remove=function(t){var e=!1;if(!this.isDisposed){var n=this.disposables.indexOf(t);-1!==n&&(e=!0,this.disposables.splice(n,1),this.length--,t.dispose())}return e},R.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var t=this.disposables.slice(0);this.disposables=[],this.length=0;for(var e=0,n=t.length;n>e;e++)t[e].dispose()}},R.clear=function(){var t=this.disposables.slice(0);this.disposables=[],this.length=0;for(var e=0,n=t.length;n>e;e++)t[e].dispose()},R.contains=function(t){return-1!==this.disposables.indexOf(t)},R.toArray=function(){return this.disposables.slice(0)};var O=y.Disposable=function(t){this.isDisposed=!1,this.action=t};O.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var k=O.create=function(t){return new O(t)},q=O.empty={dispose:n},T=y.SingleAssignmentDisposable=function(){this.isDisposed=!1,this.current=null},j=T.prototype;j.disposable=function(t){return t?this.setDisposable(t):this.getDisposable()},j.getDisposable=function(){return this.current},j.setDisposable=function(t){if(this.current)throw Error("Disposable has already been assigned");var e=this.isDisposed;e||(this.current=t),e&&t&&t.dispose()},j.dispose=function(){var t;this.isDisposed||(this.isDisposed=!0,t=this.current,this.current=null),t&&t.dispose()};var I=y.SerialDisposable=function(){this.isDisposed=!1,this.current=null};I.prototype.getDisposable=function(){return this.current},I.prototype.setDisposable=function(t){var e,n=this.isDisposed;n||(e=this.current,this.current=t),e&&e.dispose(),n&&t&&t.dispose()},I.prototype.disposable=function(t){return t?(this.setDisposable(t),e):this.getDisposable()},I.prototype.dispose=function(){var t;this.isDisposed||(this.isDisposed=!0,t=this.current,this.current=null),t&&t.dispose()};var P=y.RefCountDisposable=function(){function t(t){this.disposable=t,this.disposable.count++,this.isInnerDisposed=!1}function e(t){this.underlyingDisposable=t,this.isDisposed=!1,this.isPrimaryDisposed=!1,this.count=0}return t.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()))},e.prototype.dispose=function(){this.isDisposed||this.isPrimaryDisposed||(this.isPrimaryDisposed=!0,0===this.count&&(this.isDisposed=!0,this.underlyingDisposable.dispose()))},e.prototype.getDisposable=function(){return this.isDisposed?q:new t(this)},e}();f.prototype.dispose=function(){var t=this;this.scheduler.schedule(function(){t.isDisposed||(t.isDisposed=!0,t.disposable.dispose())})},p.prototype.invoke=function(){this.disposable.disposable(this.invokeCore())},p.prototype.compareTo=function(t){return this.comparer(this.dueTime,t.dueTime)},p.prototype.isCancelled=function(){return this.disposable.isDisposed},p.prototype.invokeCore=function(){return this.action(this.scheduler,this.state)};var M=y.Scheduler=function(){function e(t,e,n,r){this.now=t,this._schedule=e,this._scheduleRelative=n,this._scheduleAbsolute=r}function n(t,e){var n=e.first,r=e.second,i=new W,o=function(e){r(e,function(e){var n=!1,r=!1,s=t.scheduleWithState(e,function(t,e){return n?i.remove(s):r=!0,o(e),q});r||(i.add(s),n=!0)})};return o(n),i}function r(t,e,n){var r=e.first,i=e.second,o=new W,s=function(e){i(e,function(e,r){var i=!1,u=!1,c=t[n].call(t,e,r,function(t,e){return i?o.remove(c):u=!0,s(e),q});u||(o.add(c),i=!0)})};return s(r),o}function o(t,e){return e(),q}var s=e.prototype;return s.catchException=function(t){return new H(this,t)},s.schedulePeriodic=function(t,e){return this.schedulePeriodicWithState(null,t,function(){e()})},s.schedulePeriodicWithState=function(e,n,r){var i=e,o=t.setInterval(function(){i=r(i)},n);return k(function(){t.clearInterval(o)})},s.schedule=function(t){return this._schedule(t,o)},s.scheduleWithState=function(t,e){return this._schedule(t,e)},s.scheduleWithRelative=function(t,e){return this._scheduleRelative(e,t,o)},s.scheduleWithRelativeAndState=function(t,e,n){return this._scheduleRelative(t,e,n)},s.scheduleWithAbsolute=function(t,e){return this._scheduleAbsolute(e,t,o)},s.scheduleWithAbsoluteAndState=function(t,e,n){return this._scheduleAbsolute(t,e,n)},s.scheduleRecursive=function(t){return this.scheduleRecursiveWithState(t,function(t,e){t(function(){e(t)})})},s.scheduleRecursiveWithState=function(t,e){return this.scheduleWithState({first:t,second:e},function(t,e){return n(t,e)})},s.scheduleRecursiveWithRelative=function(t,e){return this.scheduleRecursiveWithRelativeAndState(e,t,function(t,e){t(function(n){e(t,n)})})},s.scheduleRecursiveWithRelativeAndState=function(t,e,n){return this._scheduleRelative({first:t,second:n},e,function(t,e){return r(t,e,"scheduleWithRelativeAndState")})},s.scheduleRecursiveWithAbsolute=function(t,e){return this.scheduleRecursiveWithAbsoluteAndState(e,t,function(t,e){t(function(n){e(t,n)})})},s.scheduleRecursiveWithAbsoluteAndState=function(t,e,n){return this._scheduleAbsolute({first:t,second:n},e,function(t,e){return r(t,e,"scheduleWithAbsoluteAndState")})},e.now=i,e.normalize=function(t){return 0>t&&(t=0),t},e}(),L="Scheduler is not allowed to block the thread",V=M.immediate=function(){function t(t,e){return e(this,t)}function e(t,e,n){if(e>0)throw Error(L);return n(this,t)}function n(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new M(i,t,e,n)}(),z=M.currentThread=function(){function t(){o=new _(4)}function e(t,e){return this.scheduleWithRelativeAndState(t,0,e)}function n(e,n,r){var i,s=this.now()+M.normalize(n),u=new p(this,e,r,s);if(o)o.enqueue(u);else{i=new t;try{o.enqueue(u),i.run()}catch(c){throw c}finally{i.dispose()}}return u.disposable}function r(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}var o;t.prototype.dispose=function(){o=null},t.prototype.run=function(){for(var t;o.length>0;)if(t=o.dequeue(),!t.isCancelled()){for(;t.dueTime-M.now()>0;);t.isCancelled()||t.invoke()}};var s=new M(i,e,n,r);return s.scheduleRequired=function(){return null===o},s.ensureTrampoline=function(t){return null===o?this.schedule(t):t()},s}(),B=function(){function t(t,e){e(0,this._period);try{this._state=this._action(this._state)}catch(n){throw this._cancel.dispose(),n}}function e(t,e,n,r){this._scheduler=t,this._state=e,this._period=n,this._action=r}return e.prototype.start=function(){var e=new T;return this._cancel=e,e.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,t.bind(this))),e},e}();y.VirtualTimeScheduler=function(t){function n(){return this.toDateTimeOffset(this.clock)}function r(t,e){return this.scheduleAbsoluteWithState(t,this.clock,e)}function i(t,e,n){return this.scheduleRelativeWithState(t,this.toRelative(e),n)}function o(t,e,n){return this.scheduleRelativeWithState(t,this.toRelative(e-this.now()),n)}function s(t,e){return e(),q}function u(e,s){this.clock=e,this.comparer=s,this.isEnabled=!1,this.queue=new _(1024),t.call(this,n,r,i,o)}C(u,t);var c=u.prototype;return c.schedulePeriodicWithState=function(t,e,n){var r=new B(this,t,e,n);return r.start()},c.scheduleRelativeWithState=function(t,e,n){var r=this.add(this.clock,e);return this.scheduleAbsoluteWithState(t,r,n)},c.scheduleRelative=function(t,e){return this.scheduleRelativeWithState(e,t,s)},c.start=function(){var t;if(!this.isEnabled){this.isEnabled=!0;do t=this.getNext(),null!==t?(this.comparer(t.dueTime,this.clock)>0&&(this.clock=t.dueTime),t.invoke()):this.isEnabled=!1;while(this.isEnabled)}},c.stop=function(){this.isEnabled=!1},c.advanceTo=function(t){var e,n=this.comparer(this.clock,t);if(this.comparer(this.clock,t)>0)throw Error(g);if(0!==n&&!this.isEnabled){this.isEnabled=!0;do e=this.getNext(),null!==e&&0>=this.comparer(e.dueTime,t)?(this.comparer(e.dueTime,this.clock)>0&&(this.clock=e.dueTime),e.invoke()):this.isEnabled=!1;while(this.isEnabled);this.clock=t}},c.advanceBy=function(t){var n=this.add(this.clock,t),r=this.comparer(this.clock,n);if(r>0)throw Error(g);return 0!==r?this.advanceTo(n):e},c.sleep=function(t){var e=this.add(this.clock,t);if(this.comparer(this.clock,e)>=0)throw Error(g);this.clock=e},c.getNext=function(){for(var t;this.queue.length>0;){if(t=this.queue.peek(),!t.isCancelled())return t;this.queue.dequeue()}return null},c.scheduleAbsolute=function(t,e){return this.scheduleAbsoluteWithState(e,t,s)},c.scheduleAbsoluteWithState=function(t,e,n){var r=this,i=function(t,e){return r.queue.remove(o),n(t,e)},o=new p(r,t,i,e,r.comparer);return r.queue.enqueue(o),o.disposable},u}(M),y.HistoricalScheduler=function(t){function e(e,n){var r=null==e?0:e,i=n||s;t.call(this,r,i)}C(e,t);var n=e.prototype;return n.add=function(t,e){return t+e},n.toDateTimeOffset=function(t){return new Date(t).getTime()},n.toRelative=function(t){return t},e}(y.VirtualTimeScheduler);var F=M.timeout=function(){function r(){if(!t.postMessage||t.importScripts)return!1;var e=!1,n=t.onmessage;return t.onmessage=function(){e=!0},t.postMessage("","*"),t.onmessage=n,e}function o(t){if("string"==typeof t.data&&t.data.substring(0,l.length)===l){var e=t.data.substring(l.length),n=f[e];n(),delete f[e]}}function s(t,e){var n=this,r=new T,i=a(function(){r.isDisposed||r.setDisposable(e(n,t))});return new W(r,k(function(){h(i)}))}function u(e,n,r){var i=this,o=M.normalize(n);if(0===o)return i.scheduleWithState(e,r);var s=new T,u=t.setTimeout(function(){s.isDisposed||s.setDisposable(r(i,e))},o);return new W(s,k(function(){t.clearTimeout(u)}))}function c(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}var a,h=n;if(t.process!==e&&"[object process]"==typeof t.process)a=t.process.nextTick;else if("function"==typeof t.setImmediate)a=t.setImmediate,h=t.clearImmediate;else if(r()){var l="ms.rx.schedule"+Math.random(),f={},p=0;t.addEventListener?t.addEventListener("message",o,!1):t.attachEvent("onmessage",o,!1),a=function(e){var n=p++;f[n]=e,t.postMessage(l+n,"*")}}else if(t.MessageChannel)a=function(e){var n=new t.MessageChannel;n.port1.onmessage=function(){e()},n.port2.postMessage()};else if("document"in t&&"onreadystatechange"in t.document.createElement("script")){var d=t.document.createElement("script");d.onreadystatechange=function(){action(),d.onreadystatechange=null,d.parentNode.removeChild(d),d=null},t.document.documentElement.appendChild(d)}else a=function(e){return t.setTimeout(e,0)},h=t.clearTimeout;return new M(i,s,u,c)}(),H=function(t){function e(){return this._scheduler.now()}function n(t,e){return this._scheduler.scheduleWithState(t,this._wrap(e))}function r(t,e,n){return this._scheduler.scheduleWithRelativeAndState(t,e,this._wrap(n))}function i(t,e,n){return this._scheduler.scheduleWithAbsoluteAndState(t,e,this._wrap(n))}function o(o,s){this._scheduler=o,this._handler=s,this._recursiveOriginal=null,this._recursiveWrapper=null,t.call(this,e,n,r,i)}return C(o,t),o.prototype._clone=function(t){return new o(t,this._handler)},o.prototype._wrap=function(t){var e=this;return function(n,r){try{return t(e._getRecursiveWrapper(n),r)}catch(i){if(!e._handler(i))throw i;return q}}},o.prototype._getRecursiveWrapper=function(t){if(!this._recursiveOriginal!==t){this._recursiveOriginal=t;var e=this._clone(t);e._recursiveOriginal=t,e._recursiveWrapper=e,this._recursiveWrapper=e}return this._recursiveWrapper},o.prototype.schedulePeriodicWithState=function(t,e,n){var r=this,i=!1,o=new T;return o.setDisposable(this._scheduler.schedulePeriodicWithState(t,e,function(t){if(i)return null;try{return n(t)}catch(e){if(i=!0,!r._handler(e))throw e;return o.dispose(),null}})),o},o}(M),U=y.Notification=function(){function t(t,e){this.hasValue=null==e?!1:e,this.kind=t}var e=t.prototype;return e.accept=function(t,e,n){return 1===arguments.length&&"object"==typeof t?this._acceptObservable(t):this._accept(t,e,n)},e.toObservable=function(t){var e=this;return t=t||V,new Ee(function(n){return t.schedule(function(){e._acceptObservable(n),"N"===e.kind&&n.onCompleted()})})},e.equals=function(t){var e=null==t?"":""+t;return""+this===e},t}(),G=U.createOnNext=function(){function t(t){return t(this.value)}function e(t){return t.onNext(this.value)}function n(){return"OnNext("+this.value+")"}return function(r){var i=new U("N",!0);return i.value=r,i._accept=t.bind(i),i._acceptObservable=e.bind(i),i.toString=n.bind(i),i}}(),J=U.createOnError=function(){function t(t,e){return e(this.exception)}function e(t){return t.onError(this.exception)}function n(){return"OnError("+this.exception+")"}return function(r){var i=new U("E");return i.exception=r,i._accept=t.bind(i),i._acceptObservable=e.bind(i),i.toString=n.bind(i),i}}(),K=U.createOnCompleted=function(){function t(t,e,n){return n()}function e(t){return t.onCompleted()}function n(){return"OnCompleted()"}return function(){var r=new U("C");return r._accept=t.bind(r),r._acceptObservable=e.bind(r),r.toString=n.bind(r),r}}(),Q=y.Internals.Enumerator=function(t,e,n){this.moveNext=t,this.getCurrent=e,this.dispose=n},X=Q.create=function(t,e,r){var i=!1;return r||(r=n),new Q(function(){if(i)return!1;var e=t();return e||(i=!0,r()),e},function(){return e()},function(){i||(r(),i=!0)})},Y=y.Internals.Enumerable=function(){function t(t){this.getEnumerator=t}return t.prototype.concat=function(){var t=this;return new Ee(function(n){var r=t.getEnumerator(),i=!1,o=new I,s=V.scheduleRecursive(function(t){var s,u,c=!1;if(!i){try{c=r.moveNext(),c?s=r.getCurrent():r.dispose()}catch(a){u=a,r.dispose()}if(u)return n.onError(u),e;if(!c)return n.onCompleted(),e;var h=new T;o.setDisposable(h),h.setDisposable(s.subscribe(n.onNext.bind(n),n.onError.bind(n),function(){t()}))}});return new W(o,s,k(function(){i=!0,r.dispose()}))})},t.prototype.catchException=function(){var t=this;return new Ee(function(n){var r,i=t.getEnumerator(),o=!1,s=new I,u=V.scheduleRecursive(function(t){var u,c,a;if(a=!1,!o){try{a=i.moveNext(),a&&(u=i.getCurrent())}catch(h){c=h}if(c)return n.onError(c),e;if(!a)return r?n.onError(r):n.onCompleted(),e;var l=new T;s.setDisposable(l),l.setDisposable(u.subscribe(n.onNext.bind(n),function(e){r=e,t()},n.onCompleted.bind(n)))}});return new W(s,u,k(function(){o=!0}))})},t}(),Z=Y.repeat=function(t,n){return n===e&&(n=-1),new Y(function(){var e,r=n;return X(function(){return 0===r?!1:(r>0&&r--,e=t,!0)},function(){return e})})},$=Y.forEach=function(t,e){return e||(e=r),new Y(function(){var n,r=-1;return X(function(){return++r<t.length?(n=e(t[r],r),!0):!1},function(){return n})})},te=y.Observer=function(){};te.prototype.toNotifier=function(){var t=this;return function(e){return e.accept(t)}},te.prototype.asObserver=function(){return new ie(this.onNext.bind(this),this.onError.bind(this),this.onCompleted.bind(this))},te.prototype.checked=function(){return new oe(this)};var ee=te.create=function(t,e,r){return t||(t=n),e||(e=c),r||(r=n),new ie(t,e,r)};te.fromNotifier=function(t){return new ie(function(e){return t(G(e))},function(e){return t(J(e))},function(){return t(K())})};var ne,re=y.Internals.AbstractObserver=function(t){function e(){this.isStopped=!1,t.call(this)}return C(e,t),e.prototype.onNext=function(t){this.isStopped||this.next(t)},e.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.error(t))},e.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.completed())},e.prototype.dispose=function(){this.isStopped=!0},e.prototype.fail=function(){return this.isStopped?!1:(this.isStopped=!0,this.error(!0),!0)},e}(te),ie=y.AnonymousObserver=function(t){function e(e,n,r){t.call(this),this._onNext=e,this._onError=n,this._onCompleted=r}return C(e,t),e.prototype.next=function(t){this._onNext(t)},e.prototype.error=function(t){this._onError(t)},e.prototype.completed=function(){this._onCompleted()},e}(re),oe=function(t){function e(e){t.call(this),this._observer=e,this._state=0}C(e,t);var n=e.prototype;return n.onNext=function(t){this.checkAccess();try{this._observer.onNext(t)}catch(e){throw e}finally{this._state=0}},n.onError=function(t){this.checkAccess();try{this._observer.onError(t)}catch(e){throw e}finally{this._state=2}},n.onCompleted=function(){this.checkAccess();try{this._observer.onCompleted()}catch(t){throw t}finally{this._state=2}},n.checkAccess=function(){if(1===this._state)throw Error("Re-entrancy detected");if(2===this._state)throw Error("Observer completed");0===this._state&&(this._state=1)},e}(te),se=y.Internals.ScheduledObserver=function(t){function n(e,n){t.call(this),this.scheduler=e,this.observer=n,this.isAcquired=!1,this.hasFaulted=!1,this.queue=[],this.disposable=new I}return C(n,t),n.prototype.next=function(t){var e=this;this.queue.push(function(){e.observer.onNext(t)})},n.prototype.error=function(t){var e=this;this.queue.push(function(){e.observer.onError(t)})},n.prototype.completed=function(){var t=this;this.queue.push(function(){t.observer.onCompleted()})},n.prototype.ensureActive=function(){var t=!1,n=this;!this.hasFaulted&&this.queue.length>0&&(t=!this.isAcquired,this.isAcquired=!0),t&&this.disposable.setDisposable(this.scheduler.scheduleRecursive(function(t){var r;if(!(n.queue.length>0))return n.isAcquired=!1,e;r=n.queue.shift();try{r()}catch(i){throw n.queue=[],n.hasFaulted=!0,i}t()}))},n.prototype.dispose=function(){t.prototype.dispose.call(this),this.disposable.dispose()},n}(re),ue=function(t){function e(){t.apply(this,arguments)}return C(e,t),e.prototype.next=function(e){t.prototype.next.call(this,e),this.ensureActive()},e.prototype.error=function(e){t.prototype.error.call(this,e),this.ensureActive()},e.prototype.completed=function(){t.prototype.completed.call(this),this.ensureActive()},e}(se),ce=y.Observable=function(){function t(t){this._subscribe=t}return ne=t.prototype,ne.finalValue=function(){var t=this;return new Ee(function(e){var n,r=!1;return t.subscribe(function(t){r=!0,n=t},e.onError.bind(e),function(){r?(e.onNext(n),e.onCompleted()):e.onError(Error(w))})})},ne.subscribe=ne.forEach=function(t,e,n){var r;return r="object"==typeof t?t:ee(t,e,n),this._subscribe(r)},ne.toArray=function(){function t(t,e){var n=t.slice(0);return n.push(e),n}return this.scan([],t).startWith([]).finalValue()},t}();ce.start=function(t,e){return ae(t,e)()};var ae=ce.toAsync=function(t,n,r){return n||(n=F),function(){var i=x.call(arguments,0),o=new Se;return n.schedule(function(){var n;try{n=t.apply(r,i)}catch(s){return o.onError(s),e}o.onNext(n),o.onCompleted()}),o.asObservable()}};ne.observeOn=function(t){var e=this;return new Ee(function(n){return e.subscribe(new ue(t,n))})},ne.subscribeOn=function(t){var e=this;return new Ee(function(n){var r=new T,i=new I;return i.setDisposable(r),r.setDisposable(t.schedule(function(){i.setDisposable(new f(t,e.subscribe(n)))})),i})},ce.create=function(t){return new Ee(function(e){return k(t(e))})},ce.createWithDisposable=function(t){return new Ee(t)};var he=ce.defer=function(t){return new Ee(function(e){var n;try{n=t()}catch(r){return be(r).subscribe(e)}return n.subscribe(e)})},le=ce.empty=function(t){return t||(t=V),new Ee(function(e){return t.schedule(function(){e.onCompleted()})})},fe=ce.fromArray=function(t,e){return e||(e=z),new Ee(function(n){var r=0;return e.scheduleRecursive(function(e){t.length>r?(n.onNext(t[r++]),e()):n.onCompleted()})})};ce.generate=function(t,n,r,i,o){return o||(o=z),new Ee(function(s){var u=!0,c=t;return o.scheduleRecursive(function(t){var o,a;try{u?u=!1:c=r(c),o=n(c),o&&(a=i(c))}catch(h){return s.onError(h),e}o?(s.onNext(a),t()):s.onCompleted()})})};var pe=ce.never=function(){return new Ee(function(){return q})};ce.range=function(t,e,n){return n||(n=z),new Ee(function(r){return n.scheduleRecursiveWithState(0,function(n,i){e>n?(r.onNext(t+n),i(n+1)):r.onCompleted()})})},ce.repeat=function(t,n,r){return r||(r=z),n==e&&(n=-1),de(t,r).repeat(n)};var de=ce.returnValue=function(t,e){return e||(e=V),new Ee(function(n){return e.schedule(function(){n.onNext(t),n.onCompleted()})})},be=ce.throwException=function(t,e){return e||(e=V),new Ee(function(n){return e.schedule(function(){n.onError(t)})})};ce.using=function(t,e){return new Ee(function(n){var r,i,o=q;try{r=t(),r&&(o=r),i=e(r)}catch(s){return new W(be(s).subscribe(n),o)}return new W(i.subscribe(n),o)})},ne.amb=function(t){var e=this;return new Ee(function(n){function r(){o||(o=s,a.dispose())}function i(){o||(o=u,c.dispose())}var o,s="L",u="R",c=new T,a=new T;return c.setDisposable(e.subscribe(function(t){r(),o===s&&n.onNext(t)},function(t){r(),o===s&&n.onError(t)},function(){r(),o===s&&n.onCompleted()})),a.setDisposable(t.subscribe(function(t){i(),o===u&&n.onNext(t)},function(t){i(),o===u&&n.onError(t)},function(){i(),o===u&&n.onCompleted()})),new W(c,a)})},ce.amb=function(){function t(t,e){return t.amb(e)}for(var e=pe(),n=h(arguments,0),r=0,i=n.length;i>r;r++)e=t(e,n[r]);return e},ne.catchException=function(t){return"function"==typeof t?d(this,t):ve([this,t])};var ve=ce.catchException=function(){var t=h(arguments,0);return $(t).catchException()};ne.combineLatest=function(){var t=x.call(arguments);return Array.isArray(t[0])?t[0].unshift(this):t.unshift(this),me.apply(this,t)};var me=ce.combineLatest=function(){var t=x.call(arguments),n=t.pop();return Array.isArray(t[0])&&(t=t[0]),new Ee(function(r){function i(t){var i;if(c[t]=!0,a||(a=c.every(function(t){return t}))){try{i=n.apply(null,f)}catch(o){return r.onError(o),e}r.onNext(i)}else h.filter(function(e,n){return n!==t}).every(function(t){return t})&&r.onCompleted()}function o(t){h[t]=!0,h.every(function(t){return t})&&r.onCompleted()}for(var s=function(){return!1},u=t.length,c=l(u,s),a=!1,h=l(u,s),f=Array(u),p=Array(u),d=0;u>d;d++)(function(e){p[e]=new T,p[e].setDisposable(t[e].subscribe(function(t){f[e]=t,i(e)},r.onError.bind(r),function(){o(e)}))})(d);return new W(p)})};ne.concat=function(){var t=x.call(arguments,0);return t.unshift(this),ye.apply(this,t)};var ye=ce.concat=function(){var t=h(arguments,0);return $(t).concat()};ne.concatObservable=ne.concatAll=function(){return this.merge(1)},ne.merge=function(t){if("number"!=typeof t)return we(this,t);var e=this;return new Ee(function(n){var r=0,i=new W,o=!1,s=[],u=function(t){var e=new T;i.add(e),e.setDisposable(t.subscribe(n.onNext.bind(n),n.onError.bind(n),function(){var t;i.remove(e),s.length>0?(t=s.shift(),u(t)):(r--,o&&0===r&&n.onCompleted())}))};return i.add(e.subscribe(function(e){t>r?(r++,u(e)):s.push(e)},n.onError.bind(n),function(){o=!0,0===r&&n.onCompleted()})),i})};var we=ce.merge=function(){var t,e;return arguments[0]?arguments[0].now?(t=arguments[0],e=x.call(arguments,1)):(t=V,e=x.call(arguments,0)):(t=V,e=x.call(arguments,1)),Array.isArray(e[0])&&(e=e[0]),fe(e,t).mergeObservable()};ne.mergeObservable=ne.mergeAll=function(){var t=this;return new Ee(function(e){var n=new W,r=!1,i=new T;return n.add(i),i.setDisposable(t.subscribe(function(t){var i=new T;n.add(i),i.setDisposable(t.subscribe(function(t){e.onNext(t)},e.onError.bind(e),function(){n.remove(i),r&&1===n.length&&e.onCompleted()}))},e.onError.bind(e),function(){r=!0,1===n.length&&e.onCompleted()})),n})},ne.onErrorResumeNext=function(t){if(!t)throw Error("Second observable is required");return ge([this,t])};var ge=ce.onErrorResumeNext=function(){var t=h(arguments,0);return new Ee(function(e){var n=0,r=new I,i=V.scheduleRecursive(function(i){var o,s;t.length>n?(o=t[n++],s=new T,r.setDisposable(s),s.setDisposable(o.subscribe(e.onNext.bind(e),function(){i()},function(){i()}))):e.onCompleted()});return new W(r,i)})};ne.skipUntil=function(t){var e=this;return new Ee(function(n){var r=!1,i=new W(e.subscribe(function(t){r&&n.onNext(t)},n.onError.bind(n),function(){r&&n.onCompleted()})),o=new T;return i.add(o),o.setDisposable(t.subscribe(function(){r=!0,o.dispose()},n.onError.bind(n),function(){o.dispose()})),i})},ne.switchLatest=function(){var t=this;return new Ee(function(e){var n=!1,r=new I,i=!1,o=0,s=t.subscribe(function(t){var s=new T,u=++o;n=!0,r.setDisposable(s),s.setDisposable(t.subscribe(function(t){o===u&&e.onNext(t)},function(t){o===u&&e.onError(t)},function(){o===u&&(n=!1,i&&e.onCompleted())}))},e.onError.bind(e),function(){i=!0,n||e.onCompleted()});return new W(s,r)})},ne.takeUntil=function(t){var e=this;return new Ee(function(r){return new W(e.subscribe(r),t.subscribe(r.onCompleted.bind(r),r.onError.bind(r),n))})},ne.zip=function(){if(Array.isArray(arguments[0]))return b.apply(this,arguments);var t=this,n=x.call(arguments),r=n.pop();return n.unshift(t),new Ee(function(i){function o(t){c[t]=!0,c.every(function(t){return t})&&i.onCompleted()}for(var s=n.length,u=l(s,function(){return[]}),c=l(s,function(){return!1}),a=function(n){var o,s;if(u.every(function(t){return t.length>0})){try{s=u.map(function(t){return t.shift()}),o=r.apply(t,s)}catch(a){return i.onError(a),e}i.onNext(o)}else c.filter(function(t,e){return e!==n}).every(function(t){return t})&&i.onCompleted()},h=Array(s),f=0;s>f;f++)(function(t){h[t]=new T,h[t].setDisposable(n[t].subscribe(function(e){u[t].push(e),a(t)},i.onError.bind(i),function(){o(t)}))})(f);return new W(h)})},ce.zip=function(t,e){var n=t[0],r=t.slice(1);return r.push(e),n.zip.apply(n,r)},ne.asObservable=function(){var t=this;return new Ee(function(e){return t.subscribe(e)})},ne.bufferWithCount=function(t,n){return n===e&&(n=t),this.windowWithCount(t,n).selectMany(function(t){return t.toArray()}).where(function(t){return t.length>0})},ne.dematerialize=function(){var t=this;return new Ee(function(e){return t.subscribe(function(t){return t.accept(e)},e.onError.bind(e),e.onCompleted.bind(e))})},ne.distinctUntilChanged=function(t,n){var i=this;return t||(t=r),n||(n=o),new Ee(function(r){var o,s=!1;return i.subscribe(function(i){var u,c=!1;try{u=t(i)}catch(a){return r.onError(a),e}if(s)try{c=n(o,u)}catch(a){return r.onError(a),e}s&&c||(s=!0,o=u,r.onNext(i))},r.onError.bind(r),r.onCompleted.bind(r))})},ne.doAction=function(t,e,n){var r,i=this;return"function"==typeof t?r=t:(r=t.onNext.bind(t),e=t.onError.bind(t),n=t.onCompleted.bind(t)),new Ee(function(t){return i.subscribe(function(e){try{r(e)}catch(n){t.onError(n)}t.onNext(e)},function(n){if(e){try{e(n)}catch(r){t.onError(r)}t.onError(n)}else t.onError(n)},function(){if(n){try{n()}catch(e){t.onError(e)}t.onCompleted()}else t.onCompleted()})})},ne.finallyAction=function(t){var e=this;return new Ee(function(n){var r=e.subscribe(n);return k(function(){try{r.dispose()}catch(e){throw e}finally{t()}})})},ne.ignoreElements=function(){var t=this;return new Ee(function(e){return t.subscribe(n,e.onError.bind(e),e.onCompleted.bind(e))})},ne.materialize=function(){var t=this;return new Ee(function(e){return t.subscribe(function(t){e.onNext(G(t))},function(t){e.onNext(J(t)),e.onCompleted()},function(){e.onNext(K()),e.onCompleted()})})},ne.repeat=function(t){return Z(this,t).concat()},ne.retry=function(t){return Z(this,t).catchException()},ne.scan=function(){var t,e,n=!1;2===arguments.length?(t=arguments[0],e=arguments[1],n=!0):e=arguments[0];var r=this;return he(function(){var i,o=!1;return r.select(function(r){return o?i=e(i,r):(i=n?e(t,r):r,o=!0),i})})},ne.skipLast=function(t){var e=this;return new Ee(function(n){var r=[];return e.subscribe(function(e){r.push(e),r.length>t&&n.onNext(r.shift())},n.onError.bind(n),n.onCompleted.bind(n))})},ne.startWith=function(){var t,n,r=0;return arguments.length>0&&null!=arguments[0]&&arguments[0].now!==e?(n=arguments[0],r=1):n=V,t=x.call(arguments,r),$([fe(t,n),this]).concat()},ne.takeLast=function(t,e){return this.takeLastBuffer(t).selectMany(function(t){return fe(t,e)})},ne.takeLastBuffer=function(t){var e=this;return new Ee(function(n){var r=[];return e.subscribe(function(e){r.push(e),r.length>t&&r.shift()},n.onError.bind(n),function(){n.onNext(r),n.onCompleted()})})},ne.windowWithCount=function(t,e){var n=this;if(0>=t)throw Error(g);if(null==e&&(e=t),0>=e)throw Error(g);return new Ee(function(r){var i=new T,o=new P(i),s=0,u=[],c=function(){var t=new Ae;u.push(t),r.onNext(A(t,o))};return c(),i.setDisposable(n.subscribe(function(n){for(var r,i=0,o=u.length;o>i;i++)u[i].onNext(n);var a=s-t+1;a>=0&&0===a%e&&(r=u.shift(),r.onCompleted()),s++,0===s%e&&c()},function(t){for(;u.length>0;)u.shift().onError(t);r.onError(t)},function(){for(;u.length>0;)u.shift().onCompleted();r.onCompleted()})),o})},ne.defaultIfEmpty=function(t){var n=this;return t===e&&(t=null),new Ee(function(e){var r=!1;return n.subscribe(function(t){r=!0,e.onNext(t)},e.onError.bind(e),function(){r||e.onNext(t),e.onCompleted()})})},ne.distinct=function(t,n){var i=this;return t||(t=r),n||(n=u),new Ee(function(r){var o={};return i.subscribe(function(i){var s,u,c,a=!1;try{s=t(i),u=n(s)}catch(h){return r.onError(h),e}for(c in o)if(u===c){a=!0;break}a||(o[u]=null,r.onNext(i))},r.onError.bind(r),r.onCompleted.bind(r))})},ne.groupBy=function(t,e,n){return this.groupByUntil(t,e,function(){return pe()},n)},ne.groupByUntil=function(t,i,o,s){var c=this;return i||(i=r),s||(s=u),new Ee(function(r){var u={},a=new W,h=new P(a);
return a.add(c.subscribe(function(c){var l,f,p,d,b,v,m,y,w,g,E;try{m=t(c),y=s(m)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}b=!1;try{g=u[y],g||(g=new Ae,u[y]=g,b=!0)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}if(b){v=new Ce(m,g,h),f=new Ce(m,g);try{l=o(f)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}r.onNext(v),w=new T,a.add(w),d=function(){y in u&&(delete u[y],g.onCompleted()),a.remove(w)},w.setDisposable(l.take(1).subscribe(n,function(t){for(E in u)u[E].onError(t);r.onError(t)},function(){d()}))}try{p=i(c)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}g.onNext(p)},function(t){for(var e in u)u[e].onError(t);r.onError(t)},function(){for(var t in u)u[t].onCompleted();r.onCompleted()})),h})},ne.select=function(t,n){var r=this;return new Ee(function(i){var o=0;return r.subscribe(function(s){var u;try{u=t.call(n,s,o++,r)}catch(c){return i.onError(c),e}i.onNext(u)},i.onError.bind(i),i.onCompleted.bind(i))})},ne.map=ne.select,ne.selectMany=ne.flatMap=function(t,e){return e?this.selectMany(function(n){return t(n).select(function(t){return e(n,t)})}):"function"==typeof t?v.call(this,t):v.call(this,function(){return t})},ne.skip=function(t){if(0>t)throw Error(g);var e=this;return new Ee(function(n){var r=t;return e.subscribe(function(t){0>=r?n.onNext(t):r--},n.onError.bind(n),n.onCompleted.bind(n))})},ne.skipWhile=function(t){var n=this;return new Ee(function(r){var i=0,o=!1;return n.subscribe(function(n){if(!o)try{o=!t(n,i++)}catch(s){return r.onError(s),e}o&&r.onNext(n)},r.onError.bind(r),r.onCompleted.bind(r))})},ne.take=function(t,e){if(0>t)throw Error(g);if(0===t)return le(e);var n=this;return new Ee(function(e){var r=t;return n.subscribe(function(t){r>0&&(r--,e.onNext(t),0===r&&e.onCompleted())},e.onError.bind(e),e.onCompleted.bind(e))})},ne.takeWhile=function(t){var n=this;return new Ee(function(r){var i=0,o=!0;return n.subscribe(function(n){if(o){try{o=t(n,i++)}catch(s){return r.onError(s),e}o?r.onNext(n):r.onCompleted()}},r.onError.bind(r),r.onCompleted.bind(r))})},ne.where=function(t,n){var r=this;return new Ee(function(i){var o=0;return r.subscribe(function(s){var u;try{u=t.call(n,s,o++,r)}catch(c){return i.onError(c),e}u&&i.onNext(s)},i.onError.bind(i),i.onCompleted.bind(i))})},ne.filter=ne.where;var Ee=y.Internals.AnonymousObservable=function(t){function e(e){function n(t){var n=new xe(t);if(z.scheduleRequired())z.schedule(function(){try{n.disposable(e(n))}catch(t){if(!n.fail(t))throw t}});else try{n.disposable(e(n))}catch(r){if(!n.fail(r))throw r}return n}t.call(this,n)}return C(e,t),e}(ce),xe=function(t){function e(e){t.call(this),this.observer=e,this.m=new T}C(e,t);var n=e.prototype;return n.next=function(t){var e=!1;try{this.observer.onNext(t),e=!0}catch(n){throw n}finally{e||this.dispose()}},n.error=function(t){try{this.observer.onError(t)}catch(e){throw e}finally{this.dispose()}},n.completed=function(){try{this.observer.onCompleted()}catch(t){throw t}finally{this.dispose()}},n.disposable=function(t){return this.m.disposable(t)},n.dispose=function(){t.prototype.dispose.call(this),this.m.dispose()},e}(re),Ce=function(t){function e(t){return this.underlyingObservable.subscribe(t)}function n(n,r,i){t.call(this,e),this.key=n,this.underlyingObservable=i?new Ee(function(t){return new W(i.getDisposable(),r.subscribe(t))}):r}return C(n,t),n}(ce),De=function(t,e){this.subject=t,this.observer=e};De.prototype.dispose=function(){if(!this.subject.isDisposed&&null!==this.observer){var t=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(t,1),this.observer=null}};var Ae=y.Subject=function(t){function e(t){return a.call(this),this.isStopped?this.exception?(t.onError(this.exception),q):(t.onCompleted(),q):(this.observers.push(t),new De(this,t))}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.observers=[]}return C(n,t),D(n.prototype,te,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(a.call(this),!this.isStopped){var t=this.observers.slice(0);this.isStopped=!0;for(var e=0,n=t.length;n>e;e++)t[e].onCompleted();this.observers=[]}},onError:function(t){if(a.call(this),!this.isStopped){var e=this.observers.slice(0);this.isStopped=!0,this.exception=t;for(var n=0,r=e.length;r>n;n++)e[n].onError(t);this.observers=[]}},onNext:function(t){if(a.call(this),!this.isStopped)for(var e=this.observers.slice(0),n=0,r=e.length;r>n;n++)e[n].onNext(t)},dispose:function(){this.isDisposed=!0,this.observers=null}}),n.create=function(t,e){return new _e(t,e)},n}(ce),Se=y.AsyncSubject=function(t){function e(t){if(a.call(this),!this.isStopped)return this.observers.push(t),new De(this,t);var e=this.exception,n=this.hasValue,r=this.value;return e?t.onError(e):n?(t.onNext(r),t.onCompleted()):t.onCompleted(),q}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.value=null,this.hasValue=!1,this.observers=[],this.exception=null}return C(n,t),D(n.prototype,te,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){var t,e,n;if(a.call(this),!this.isStopped){var r=this.observers.slice(0);this.isStopped=!0;var i=this.value,o=this.hasValue;if(o)for(e=0,n=r.length;n>e;e++)t=r[e],t.onNext(i),t.onCompleted();else for(e=0,n=r.length;n>e;e++)r[e].onCompleted();this.observers=[]}},onError:function(t){if(a.call(this),!this.isStopped){var e=this.observers.slice(0);this.isStopped=!0,this.exception=t;for(var n=0,r=e.length;r>n;n++)e[n].onError(t);this.observers=[]}},onNext:function(t){a.call(this),this.isStopped||(this.value=t,this.hasValue=!0)},dispose:function(){this.isDisposed=!0,this.observers=null,this.exception=null,this.value=null}}),n}(ce),_e=function(t){function e(t){return this.observable.subscribe(t)}function n(n,r){t.call(this,e),this.observer=n,this.observable=r}return C(n,t),D(n.prototype,te,{onCompleted:function(){this.observer.onCompleted()},onError:function(t){this.observer.onError(t)},onNext:function(t){this.observer.onNext(t)}}),n}(ce);return"function"==typeof define&&"object"==typeof define.amd&&define.amd?(t.Rx=y,define(function(){return y})):(m?"object"==typeof module&&module&&module.exports==m?module.exports=y:m=y:t.Rx=y,e)})(this);
(function(t,e){function n(){}function r(t){return t}function i(){return(new Date).getTime()}function o(t,e){return t===e}function s(t,e){return t-e}function u(t){return""+t}function c(t){throw t}function a(){if(this.isDisposed)throw Error(E)}function h(t,e){return 1===t.length&&Array.isArray(t[e])?t[e]:x.call(t)}function l(t,e){for(var n=Array(t),r=0;t>r;r++)n[r]=e();return n}function f(t,e){this.scheduler=t,this.disposable=e,this.isDisposed=!1}function p(t,e,n,r,i){this.scheduler=t,this.state=e,this.action=n,this.dueTime=r,this.comparer=i||s,this.disposable=new T}function d(t,n){return new Ce(function(r){var i=new T,o=new I;return o.setDisposable(i),i.setDisposable(t.subscribe(r.onNext.bind(r),function(t){var i,s;try{s=n(t)}catch(u){return r.onError(u),e}i=new T,o.setDisposable(i),i.setDisposable(s.subscribe(r))},r.onCompleted.bind(r))),o})}function b(t,n){var r=this;return new Ce(function(i){var o=0,s=t.length;return r.subscribe(function(r){if(s>o){var u,c=t[o++];try{u=n(r,c)}catch(a){return i.onError(a),e}i.onNext(u)}else i.onCompleted()},i.onError.bind(i),i.onCompleted.bind(i))})}function v(t){return this.select(t).mergeObservable()}var m="object"==typeof exports&&exports&&("object"==typeof global&&global&&global==global.global&&(t=global),exports),y={Internals:{}},w="Sequence contains no elements.",g="Argument out of range",E="Object has been disposed",x=Array.prototype.slice;({}).hasOwnProperty;var C=this.inherits=y.Internals.inherits=function(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n},D=y.Internals.addProperties=function(t){for(var e=x.call(arguments,1),n=0,r=e.length;r>n;n++){var i=e[n];for(var o in i)t[o]=i[o]}},A=y.Internals.addRef=function(t,e){return new Ce(function(n){return new W(e.getDisposable(),t.subscribe(n))})},S=function(t,e){this.id=t,this.value=e};S.prototype.compareTo=function(t){var e=this.value.compareTo(t.value);return 0===e&&(e=this.id-t.id),e};var _=function(t){this.items=Array(t),this.length=0},N=_.prototype;N.isHigherPriority=function(t,e){return 0>this.items[t].compareTo(this.items[e])},N.percolate=function(t){if(!(t>=this.length||0>t)){var e=t-1>>1;if(!(0>e||e===t)&&this.isHigherPriority(t,e)){var n=this.items[t];this.items[t]=this.items[e],this.items[e]=n,this.percolate(e)}}},N.heapify=function(t){if(t===e&&(t=0),!(t>=this.length||0>t)){var n=2*t+1,r=2*t+2,i=t;if(this.length>n&&this.isHigherPriority(n,i)&&(i=n),this.length>r&&this.isHigherPriority(r,i)&&(i=r),i!==t){var o=this.items[t];this.items[t]=this.items[i],this.items[i]=o,this.heapify(i)}}},N.peek=function(){return this.items[0].value},N.removeAt=function(t){this.items[t]=this.items[--this.length],delete this.items[this.length],this.heapify()},N.dequeue=function(){var t=this.peek();return this.removeAt(0),t},N.enqueue=function(t){var e=this.length++;this.items[e]=new S(_.count++,t),this.percolate(e)},N.remove=function(t){for(var e=0;this.length>e;e++)if(this.items[e].value===t)return this.removeAt(e),!0;return!1},_.count=0;var W=y.CompositeDisposable=function(){this.disposables=h(arguments,0),this.isDisposed=!1,this.length=this.disposables.length},R=W.prototype;R.add=function(t){this.isDisposed?t.dispose():(this.disposables.push(t),this.length++)},R.remove=function(t){var e=!1;if(!this.isDisposed){var n=this.disposables.indexOf(t);-1!==n&&(e=!0,this.disposables.splice(n,1),this.length--,t.dispose())}return e},R.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var t=this.disposables.slice(0);this.disposables=[],this.length=0;for(var e=0,n=t.length;n>e;e++)t[e].dispose()}},R.clear=function(){var t=this.disposables.slice(0);this.disposables=[],this.length=0;for(var e=0,n=t.length;n>e;e++)t[e].dispose()},R.contains=function(t){return-1!==this.disposables.indexOf(t)},R.toArray=function(){return this.disposables.slice(0)};var O=y.Disposable=function(t){this.isDisposed=!1,this.action=t};O.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var k=O.create=function(t){return new O(t)},q=O.empty={dispose:n},T=y.SingleAssignmentDisposable=function(){this.isDisposed=!1,this.current=null},j=T.prototype;j.disposable=function(t){return t?this.setDisposable(t):this.getDisposable()},j.getDisposable=function(){return this.current},j.setDisposable=function(t){if(this.current)throw Error("Disposable has already been assigned");var e=this.isDisposed;e||(this.current=t),e&&t&&t.dispose()},j.dispose=function(){var t;this.isDisposed||(this.isDisposed=!0,t=this.current,this.current=null),t&&t.dispose()};var I=y.SerialDisposable=function(){this.isDisposed=!1,this.current=null};I.prototype.getDisposable=function(){return this.current},I.prototype.setDisposable=function(t){var e,n=this.isDisposed;n||(e=this.current,this.current=t),e&&e.dispose(),n&&t&&t.dispose()},I.prototype.disposable=function(t){return t?(this.setDisposable(t),e):this.getDisposable()},I.prototype.dispose=function(){var t;this.isDisposed||(this.isDisposed=!0,t=this.current,this.current=null),t&&t.dispose()};var P=y.RefCountDisposable=function(){function t(t){this.disposable=t,this.disposable.count++,this.isInnerDisposed=!1}function e(t){this.underlyingDisposable=t,this.isDisposed=!1,this.isPrimaryDisposed=!1,this.count=0}return t.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()))},e.prototype.dispose=function(){this.isDisposed||this.isPrimaryDisposed||(this.isPrimaryDisposed=!0,0===this.count&&(this.isDisposed=!0,this.underlyingDisposable.dispose()))},e.prototype.getDisposable=function(){return this.isDisposed?q:new t(this)},e}();f.prototype.dispose=function(){var t=this;this.scheduler.schedule(function(){t.isDisposed||(t.isDisposed=!0,t.disposable.dispose())})},p.prototype.invoke=function(){this.disposable.disposable(this.invokeCore())},p.prototype.compareTo=function(t){return this.comparer(this.dueTime,t.dueTime)},p.prototype.isCancelled=function(){return this.disposable.isDisposed},p.prototype.invokeCore=function(){return this.action(this.scheduler,this.state)};var M=y.Scheduler=function(){function e(t,e,n,r){this.now=t,this._schedule=e,this._scheduleRelative=n,this._scheduleAbsolute=r}function n(t,e){var n=e.first,r=e.second,i=new W,o=function(e){r(e,function(e){var n=!1,r=!1,s=t.scheduleWithState(e,function(t,e){return n?i.remove(s):r=!0,o(e),q});r||(i.add(s),n=!0)})};return o(n),i}function r(t,e,n){var r=e.first,i=e.second,o=new W,s=function(e){i(e,function(e,r){var i=!1,u=!1,c=t[n].call(t,e,r,function(t,e){return i?o.remove(c):u=!0,s(e),q});u||(o.add(c),i=!0)})};return s(r),o}function o(t,e){return e(),q}var s=e.prototype;return s.catchException=function(t){return new G(this,t)},s.schedulePeriodic=function(t,e){return this.schedulePeriodicWithState(null,t,function(){e()})},s.schedulePeriodicWithState=function(e,n,r){var i=e,o=t.setInterval(function(){i=r(i)},n);return k(function(){t.clearInterval(o)})},s.schedule=function(t){return this._schedule(t,o)},s.scheduleWithState=function(t,e){return this._schedule(t,e)},s.scheduleWithRelative=function(t,e){return this._scheduleRelative(e,t,o)},s.scheduleWithRelativeAndState=function(t,e,n){return this._scheduleRelative(t,e,n)},s.scheduleWithAbsolute=function(t,e){return this._scheduleAbsolute(e,t,o)},s.scheduleWithAbsoluteAndState=function(t,e,n){return this._scheduleAbsolute(t,e,n)},s.scheduleRecursive=function(t){return this.scheduleRecursiveWithState(t,function(t,e){t(function(){e(t)})})},s.scheduleRecursiveWithState=function(t,e){return this.scheduleWithState({first:t,second:e},function(t,e){return n(t,e)})},s.scheduleRecursiveWithRelative=function(t,e){return this.scheduleRecursiveWithRelativeAndState(e,t,function(t,e){t(function(n){e(t,n)})})},s.scheduleRecursiveWithRelativeAndState=function(t,e,n){return this._scheduleRelative({first:t,second:n},e,function(t,e){return r(t,e,"scheduleWithRelativeAndState")})},s.scheduleRecursiveWithAbsolute=function(t,e){return this.scheduleRecursiveWithAbsoluteAndState(e,t,function(t,e){t(function(n){e(t,n)})})},s.scheduleRecursiveWithAbsoluteAndState=function(t,e,n){return this._scheduleAbsolute({first:t,second:n},e,function(t,e){return r(t,e,"scheduleWithAbsoluteAndState")})},e.now=i,e.normalize=function(t){return 0>t&&(t=0),t},e}(),L="Scheduler is not allowed to block the thread",V=M.immediate=function(){function t(t,e){return e(this,t)}function e(t,e,n){if(e>0)throw Error(L);return n(this,t)}function n(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new M(i,t,e,n)}(),z=M.currentThread=function(){function t(){o=new _(4)}function e(t,e){return this.scheduleWithRelativeAndState(t,0,e)}function n(e,n,r){var i,s=this.now()+M.normalize(n),u=new p(this,e,r,s);if(o)o.enqueue(u);else{i=new t;try{o.enqueue(u),i.run()}catch(c){throw c}finally{i.dispose()}}return u.disposable}function r(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}var o;t.prototype.dispose=function(){o=null},t.prototype.run=function(){for(var t;o.length>0;)if(t=o.dequeue(),!t.isCancelled()){for(;t.dueTime-M.now()>0;);t.isCancelled()||t.invoke()}};var s=new M(i,e,n,r);return s.scheduleRequired=function(){return null===o},s.ensureTrampoline=function(t){return null===o?this.schedule(t):t()},s}(),B=function(){function t(t,e){e(0,this._period);try{this._state=this._action(this._state)}catch(n){throw this._cancel.dispose(),n}}function e(t,e,n,r){this._scheduler=t,this._state=e,this._period=n,this._action=r}return e.prototype.start=function(){var e=new T;return this._cancel=e,e.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,t.bind(this))),e},e}();y.VirtualTimeScheduler=function(t){function n(){return this.toDateTimeOffset(this.clock)}function r(t,e){return this.scheduleAbsoluteWithState(t,this.clock,e)}function i(t,e,n){return this.scheduleRelativeWithState(t,this.toRelative(e),n)}function o(t,e,n){return this.scheduleRelativeWithState(t,this.toRelative(e-this.now()),n)}function s(t,e){return e(),q}function u(e,s){this.clock=e,this.comparer=s,this.isEnabled=!1,this.queue=new _(1024),t.call(this,n,r,i,o)}C(u,t);var c=u.prototype;return c.schedulePeriodicWithState=function(t,e,n){var r=new B(this,t,e,n);return r.start()},c.scheduleRelativeWithState=function(t,e,n){var r=this.add(this.clock,e);return this.scheduleAbsoluteWithState(t,r,n)},c.scheduleRelative=function(t,e){return this.scheduleRelativeWithState(e,t,s)},c.start=function(){var t;if(!this.isEnabled){this.isEnabled=!0;do t=this.getNext(),null!==t?(this.comparer(t.dueTime,this.clock)>0&&(this.clock=t.dueTime),t.invoke()):this.isEnabled=!1;while(this.isEnabled)}},c.stop=function(){this.isEnabled=!1},c.advanceTo=function(t){var e,n=this.comparer(this.clock,t);if(this.comparer(this.clock,t)>0)throw Error(g);if(0!==n&&!this.isEnabled){this.isEnabled=!0;do e=this.getNext(),null!==e&&0>=this.comparer(e.dueTime,t)?(this.comparer(e.dueTime,this.clock)>0&&(this.clock=e.dueTime),e.invoke()):this.isEnabled=!1;while(this.isEnabled);this.clock=t}},c.advanceBy=function(t){var n=this.add(this.clock,t),r=this.comparer(this.clock,n);if(r>0)throw Error(g);return 0!==r?this.advanceTo(n):e},c.sleep=function(t){var e=this.add(this.clock,t);if(this.comparer(this.clock,e)>=0)throw Error(g);this.clock=e},c.getNext=function(){for(var t;this.queue.length>0;){if(t=this.queue.peek(),!t.isCancelled())return t;this.queue.dequeue()}return null},c.scheduleAbsolute=function(t,e){return this.scheduleAbsoluteWithState(e,t,s)},c.scheduleAbsoluteWithState=function(t,e,n){var r=this,i=function(t,e){return r.queue.remove(o),n(t,e)},o=new p(r,t,i,e,r.comparer);return r.queue.enqueue(o),o.disposable},u}(M),y.HistoricalScheduler=function(t){function e(e,n){var r=null==e?0:e,i=n||s;t.call(this,r,i)}C(e,t);var n=e.prototype;return n.add=function(t,e){return t+e},n.toDateTimeOffset=function(t){return new Date(t).getTime()},n.toRelative=function(t){return t},e}(y.VirtualTimeScheduler);var F,H=n;(function(){function n(){if(!t.postMessage||t.importScripts)return!1;var e=!1,n=t.onmessage;return t.onmessage=function(){e=!0},t.postMessage("","*"),t.onmessage=n,e}function r(t){if("string"==typeof t.data&&t.data.substring(0,i.length)===i){var e=t.data.substring(i.length),n=o[e];n(),delete o[e]}}if(t.process!==e&&"[object process]"===Object.prototype.toString.call(t.process))F=t.process.nextTick;else if("function"==typeof t.setImmediate)F=t.setImmediate,H=t.clearImmediate;else if(n()){var i="ms.rx.schedule"+Math.random(),o={},s=0;t.addEventListener?t.addEventListener("message",r,!1):t.attachEvent("onmessage",r,!1),F=function(e){var n=s++;o[n]=e,t.postMessage(i+n,"*")}}else if(t.MessageChannel){var u=new t.MessageChannel,c={},a=0;u.port1.onmessage=function(t){var e=t.data,n=c[e];n(),delete c[e]},F=function(t){var e=a++;c[e]=t,u.port2.postMessage(e)}}else"document"in t&&"onreadystatechange"in t.document.createElement("script")?F=function(e){var n=t.document.createElement("script");n.onreadystatechange=function(){e(),n.onreadystatechange=null,n.parentNode.removeChild(n),n=null},t.document.documentElement.appendChild(n)}:(F=function(e){return t.setTimeout(e,0)},H=t.clearTimeout)})();var U=M.timeout=function(){function e(t,e){var n=this,r=new T,i=F(function(){r.isDisposed||r.setDisposable(e(n,t))});return new W(r,k(function(){H(i)}))}function n(e,n,r){var i=this,o=M.normalize(n);if(0===o)return i.scheduleWithState(e,r);var s=new T,u=t.setTimeout(function(){s.isDisposed||s.setDisposable(r(i,e))},o);return new W(s,k(function(){t.clearTimeout(u)}))}function r(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new M(i,e,n,r)}(),G=function(t){function e(){return this._scheduler.now()}function n(t,e){return this._scheduler.scheduleWithState(t,this._wrap(e))}function r(t,e,n){return this._scheduler.scheduleWithRelativeAndState(t,e,this._wrap(n))}function i(t,e,n){return this._scheduler.scheduleWithAbsoluteAndState(t,e,this._wrap(n))}function o(o,s){this._scheduler=o,this._handler=s,this._recursiveOriginal=null,this._recursiveWrapper=null,t.call(this,e,n,r,i)}return C(o,t),o.prototype._clone=function(t){return new o(t,this._handler)},o.prototype._wrap=function(t){var e=this;return function(n,r){try{return t(e._getRecursiveWrapper(n),r)}catch(i){if(!e._handler(i))throw i;return q}}},o.prototype._getRecursiveWrapper=function(t){if(!this._recursiveOriginal!==t){this._recursiveOriginal=t;var e=this._clone(t);e._recursiveOriginal=t,e._recursiveWrapper=e,this._recursiveWrapper=e}return this._recursiveWrapper},o.prototype.schedulePeriodicWithState=function(t,e,n){var r=this,i=!1,o=new T;return o.setDisposable(this._scheduler.schedulePeriodicWithState(t,e,function(t){if(i)return null;try{return n(t)}catch(e){if(i=!0,!r._handler(e))throw e;return o.dispose(),null}})),o},o}(M),J=y.Notification=function(){function t(t,e){this.hasValue=null==e?!1:e,this.kind=t}var e=t.prototype;return e.accept=function(t,e,n){return 1===arguments.length&&"object"==typeof t?this._acceptObservable(t):this._accept(t,e,n)},e.toObservable=function(t){var e=this;return t=t||V,new Ce(function(n){return t.schedule(function(){e._acceptObservable(n),"N"===e.kind&&n.onCompleted()})})},e.equals=function(t){var e=null==t?"":""+t;return""+this===e},t}(),K=J.createOnNext=function(){function t(t){return t(this.value)}function e(t){return t.onNext(this.value)}function n(){return"OnNext("+this.value+")"}return function(r){var i=new J("N",!0);return i.value=r,i._accept=t.bind(i),i._acceptObservable=e.bind(i),i.toString=n.bind(i),i}}(),Q=J.createOnError=function(){function t(t,e){return e(this.exception)}function e(t){return t.onError(this.exception)}function n(){return"OnError("+this.exception+")"}return function(r){var i=new J("E");return i.exception=r,i._accept=t.bind(i),i._acceptObservable=e.bind(i),i.toString=n.bind(i),i}}(),X=J.createOnCompleted=function(){function t(t,e,n){return n()}function e(t){return t.onCompleted()}function n(){return"OnCompleted()"}return function(){var r=new J("C");return r._accept=t.bind(r),r._acceptObservable=e.bind(r),r.toString=n.bind(r),r}}(),Y=y.Internals.Enumerator=function(t,e,n){this.moveNext=t,this.getCurrent=e,this.dispose=n},Z=Y.create=function(t,e,r){var i=!1;return r||(r=n),new Y(function(){if(i)return!1;var e=t();return e||(i=!0,r()),e},function(){return e()},function(){i||(r(),i=!0)})},$=y.Internals.Enumerable=function(){function t(t){this.getEnumerator=t}return t.prototype.concat=function(){var t=this;return new Ce(function(n){var r=t.getEnumerator(),i=!1,o=new I,s=V.scheduleRecursive(function(t){var s,u,c=!1;if(!i){try{c=r.moveNext(),c?s=r.getCurrent():r.dispose()}catch(a){u=a,r.dispose()}if(u)return n.onError(u),e;if(!c)return n.onCompleted(),e;var h=new T;o.setDisposable(h),h.setDisposable(s.subscribe(n.onNext.bind(n),n.onError.bind(n),function(){t()}))}});return new W(o,s,k(function(){i=!0,r.dispose()}))})},t.prototype.catchException=function(){var t=this;return new Ce(function(n){var r,i=t.getEnumerator(),o=!1,s=new I,u=V.scheduleRecursive(function(t){var u,c,a;if(a=!1,!o){try{a=i.moveNext(),a&&(u=i.getCurrent())}catch(h){c=h}if(c)return n.onError(c),e;if(!a)return r?n.onError(r):n.onCompleted(),e;var l=new T;s.setDisposable(l),l.setDisposable(u.subscribe(n.onNext.bind(n),function(e){r=e,t()},n.onCompleted.bind(n)))}});return new W(s,u,k(function(){o=!0}))})},t}(),te=$.repeat=function(t,n){return n===e&&(n=-1),new $(function(){var e,r=n;return Z(function(){return 0===r?!1:(r>0&&r--,e=t,!0)},function(){return e})})},ee=$.forEach=function(t,e){return e||(e=r),new $(function(){var n,r=-1;return Z(function(){return++r<t.length?(n=e(t[r],r),!0):!1},function(){return n})})},ne=y.Observer=function(){};ne.prototype.toNotifier=function(){var t=this;return function(e){return e.accept(t)}},ne.prototype.asObserver=function(){return new se(this.onNext.bind(this),this.onError.bind(this),this.onCompleted.bind(this))},ne.prototype.checked=function(){return new ue(this)};var re=ne.create=function(t,e,r){return t||(t=n),e||(e=c),r||(r=n),new se(t,e,r)};ne.fromNotifier=function(t){return new se(function(e){return t(K(e))},function(e){return t(Q(e))},function(){return t(X())})};var ie,oe=y.Internals.AbstractObserver=function(t){function e(){this.isStopped=!1,t.call(this)}return C(e,t),e.prototype.onNext=function(t){this.isStopped||this.next(t)},e.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.error(t))},e.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.completed())},e.prototype.dispose=function(){this.isStopped=!0},e.prototype.fail=function(){return this.isStopped?!1:(this.isStopped=!0,this.error(!0),!0)},e}(ne),se=y.AnonymousObserver=function(t){function e(e,n,r){t.call(this),this._onNext=e,this._onError=n,this._onCompleted=r}return C(e,t),e.prototype.next=function(t){this._onNext(t)},e.prototype.error=function(t){this._onError(t)},e.prototype.completed=function(){this._onCompleted()},e}(oe),ue=function(t){function e(e){t.call(this),this._observer=e,this._state=0}C(e,t);var n=e.prototype;return n.onNext=function(t){this.checkAccess();try{this._observer.onNext(t)}catch(e){throw e}finally{this._state=0}},n.onError=function(t){this.checkAccess();try{this._observer.onError(t)}catch(e){throw e}finally{this._state=2}},n.onCompleted=function(){this.checkAccess();try{this._observer.onCompleted()}catch(t){throw t}finally{this._state=2}},n.checkAccess=function(){if(1===this._state)throw Error("Re-entrancy detected");if(2===this._state)throw Error("Observer completed");0===this._state&&(this._state=1)},e}(ne),ce=y.Internals.ScheduledObserver=function(t){function n(e,n){t.call(this),this.scheduler=e,this.observer=n,this.isAcquired=!1,this.hasFaulted=!1,this.queue=[],this.disposable=new I}return C(n,t),n.prototype.next=function(t){var e=this;this.queue.push(function(){e.observer.onNext(t)})},n.prototype.error=function(t){var e=this;this.queue.push(function(){e.observer.onError(t)})},n.prototype.completed=function(){var t=this;this.queue.push(function(){t.observer.onCompleted()})},n.prototype.ensureActive=function(){var t=!1,n=this;!this.hasFaulted&&this.queue.length>0&&(t=!this.isAcquired,this.isAcquired=!0),t&&this.disposable.setDisposable(this.scheduler.scheduleRecursive(function(t){var r;if(!(n.queue.length>0))return n.isAcquired=!1,e;r=n.queue.shift();try{r()}catch(i){throw n.queue=[],n.hasFaulted=!0,i}t()}))},n.prototype.dispose=function(){t.prototype.dispose.call(this),this.disposable.dispose()},n}(oe),ae=function(t){function e(){t.apply(this,arguments)}return C(e,t),e.prototype.next=function(e){t.prototype.next.call(this,e),this.ensureActive()},e.prototype.error=function(e){t.prototype.error.call(this,e),this.ensureActive()},e.prototype.completed=function(){t.prototype.completed.call(this),this.ensureActive()},e}(ce),he=y.Observable=function(){function t(t){this._subscribe=t}return ie=t.prototype,ie.finalValue=function(){var t=this;return new Ce(function(e){var n,r=!1;return t.subscribe(function(t){r=!0,n=t},e.onError.bind(e),function(){r?(e.onNext(n),e.onCompleted()):e.onError(Error(w))})})},ie.subscribe=ie.forEach=function(t,e,n){var r;return r="object"==typeof t?t:re(t,e,n),this._subscribe(r)},ie.toArray=function(){function t(t,e){var n=t.slice(0);return n.push(e),n}return this.scan([],t).startWith([]).finalValue()},t}();he.start=function(t,e){return le(t,e)()};var le=he.toAsync=function(t,n,r){return n||(n=U),function(){var i=x.call(arguments,0),o=new Ne;return n.schedule(function(){var n;try{n=t.apply(r,i)}catch(s){return o.onError(s),e}o.onNext(n),o.onCompleted()}),o.asObservable()}};ie.observeOn=function(t){var e=this;return new Ce(function(n){return e.subscribe(new ae(t,n))})},ie.subscribeOn=function(t){var e=this;return new Ce(function(n){var r=new T,i=new I;return i.setDisposable(r),r.setDisposable(t.schedule(function(){i.setDisposable(new f(t,e.subscribe(n)))})),i})},he.create=function(t){return new Ce(function(e){return k(t(e))})},he.createWithDisposable=function(t){return new Ce(t)};var fe=he.defer=function(t){return new Ce(function(e){var n;try{n=t()}catch(r){return me(r).subscribe(e)}return n.subscribe(e)})},pe=he.empty=function(t){return t||(t=V),new Ce(function(e){return t.schedule(function(){e.onCompleted()})})},de=he.fromArray=function(t,e){return e||(e=z),new Ce(function(n){var r=0;return e.scheduleRecursive(function(e){t.length>r?(n.onNext(t[r++]),e()):n.onCompleted()})})};he.generate=function(t,n,r,i,o){return o||(o=z),new Ce(function(s){var u=!0,c=t;return o.scheduleRecursive(function(t){var o,a;try{u?u=!1:c=r(c),o=n(c),o&&(a=i(c))}catch(h){return s.onError(h),e}o?(s.onNext(a),t()):s.onCompleted()})})};var be=he.never=function(){return new Ce(function(){return q})};he.range=function(t,e,n){return n||(n=z),new Ce(function(r){return n.scheduleRecursiveWithState(0,function(n,i){e>n?(r.onNext(t+n),i(n+1)):r.onCompleted()})})},he.repeat=function(t,n,r){return r||(r=z),n==e&&(n=-1),ve(t,r).repeat(n)};var ve=he.returnValue=function(t,e){return e||(e=V),new Ce(function(n){return e.schedule(function(){n.onNext(t),n.onCompleted()})})},me=he.throwException=function(t,e){return e||(e=V),new Ce(function(n){return e.schedule(function(){n.onError(t)})})};he.using=function(t,e){return new Ce(function(n){var r,i,o=q;try{r=t(),r&&(o=r),i=e(r)}catch(s){return new W(me(s).subscribe(n),o)}return new W(i.subscribe(n),o)})},ie.amb=function(t){var e=this;return new Ce(function(n){function r(){o||(o=s,a.dispose())}function i(){o||(o=u,c.dispose())}var o,s="L",u="R",c=new T,a=new T;return c.setDisposable(e.subscribe(function(t){r(),o===s&&n.onNext(t)},function(t){r(),o===s&&n.onError(t)},function(){r(),o===s&&n.onCompleted()})),a.setDisposable(t.subscribe(function(t){i(),o===u&&n.onNext(t)},function(t){i(),o===u&&n.onError(t)},function(){i(),o===u&&n.onCompleted()})),new W(c,a)})},he.amb=function(){function t(t,e){return t.amb(e)}for(var e=be(),n=h(arguments,0),r=0,i=n.length;i>r;r++)e=t(e,n[r]);return e},ie.catchException=function(t){return"function"==typeof t?d(this,t):ye([this,t])};var ye=he.catchException=function(){var t=h(arguments,0);return ee(t).catchException()};ie.combineLatest=function(){var t=x.call(arguments);return Array.isArray(t[0])?t[0].unshift(this):t.unshift(this),we.apply(this,t)};var we=he.combineLatest=function(){var t=x.call(arguments),n=t.pop();return Array.isArray(t[0])&&(t=t[0]),new Ce(function(r){function i(t){var i;if(c[t]=!0,a||(a=c.every(function(t){return t}))){try{i=n.apply(null,f)}catch(o){return r.onError(o),e}r.onNext(i)}else h.filter(function(e,n){return n!==t}).every(function(t){return t})&&r.onCompleted()}function o(t){h[t]=!0,h.every(function(t){return t})&&r.onCompleted()}for(var s=function(){return!1},u=t.length,c=l(u,s),a=!1,h=l(u,s),f=Array(u),p=Array(u),d=0;u>d;d++)(function(e){p[e]=new T,p[e].setDisposable(t[e].subscribe(function(t){f[e]=t,i(e)},r.onError.bind(r),function(){o(e)}))})(d);return new W(p)})};ie.concat=function(){var t=x.call(arguments,0);return t.unshift(this),ge.apply(this,t)};var ge=he.concat=function(){var t=h(arguments,0);return ee(t).concat()};ie.concatObservable=ie.concatAll=function(){return this.merge(1)},ie.merge=function(t){if("number"!=typeof t)return Ee(this,t);var e=this;return new Ce(function(n){var r=0,i=new W,o=!1,s=[],u=function(t){var e=new T;i.add(e),e.setDisposable(t.subscribe(n.onNext.bind(n),n.onError.bind(n),function(){var t;i.remove(e),s.length>0?(t=s.shift(),u(t)):(r--,o&&0===r&&n.onCompleted())}))};return i.add(e.subscribe(function(e){t>r?(r++,u(e)):s.push(e)},n.onError.bind(n),function(){o=!0,0===r&&n.onCompleted()})),i})};var Ee=he.merge=function(){var t,e;return arguments[0]?arguments[0].now?(t=arguments[0],e=x.call(arguments,1)):(t=V,e=x.call(arguments,0)):(t=V,e=x.call(arguments,1)),Array.isArray(e[0])&&(e=e[0]),de(e,t).mergeObservable()};ie.mergeObservable=ie.mergeAll=function(){var t=this;return new Ce(function(e){var n=new W,r=!1,i=new T;return n.add(i),i.setDisposable(t.subscribe(function(t){var i=new T;n.add(i),i.setDisposable(t.subscribe(function(t){e.onNext(t)},e.onError.bind(e),function(){n.remove(i),r&&1===n.length&&e.onCompleted()}))},e.onError.bind(e),function(){r=!0,1===n.length&&e.onCompleted()})),n})},ie.onErrorResumeNext=function(t){if(!t)throw Error("Second observable is required");return xe([this,t])};var xe=he.onErrorResumeNext=function(){var t=h(arguments,0);return new Ce(function(e){var n=0,r=new I,i=V.scheduleRecursive(function(i){var o,s;t.length>n?(o=t[n++],s=new T,r.setDisposable(s),s.setDisposable(o.subscribe(e.onNext.bind(e),function(){i()},function(){i()}))):e.onCompleted()});return new W(r,i)})};ie.skipUntil=function(t){var e=this;return new Ce(function(n){var r=!1,i=new W(e.subscribe(function(t){r&&n.onNext(t)},n.onError.bind(n),function(){r&&n.onCompleted()})),o=new T;return i.add(o),o.setDisposable(t.subscribe(function(){r=!0,o.dispose()},n.onError.bind(n),function(){o.dispose()})),i})},ie.switchLatest=function(){var t=this;return new Ce(function(e){var n=!1,r=new I,i=!1,o=0,s=t.subscribe(function(t){var s=new T,u=++o;n=!0,r.setDisposable(s),s.setDisposable(t.subscribe(function(t){o===u&&e.onNext(t)},function(t){o===u&&e.onError(t)},function(){o===u&&(n=!1,i&&e.onCompleted())}))},e.onError.bind(e),function(){i=!0,n||e.onCompleted()});return new W(s,r)})},ie.takeUntil=function(t){var e=this;return new Ce(function(r){return new W(e.subscribe(r),t.subscribe(r.onCompleted.bind(r),r.onError.bind(r),n))})},ie.zip=function(){if(Array.isArray(arguments[0]))return b.apply(this,arguments);var t=this,n=x.call(arguments),r=n.pop();return n.unshift(t),new Ce(function(i){function o(t){c[t]=!0,c.every(function(t){return t})&&i.onCompleted()}for(var s=n.length,u=l(s,function(){return[]}),c=l(s,function(){return!1}),a=function(n){var o,s;if(u.every(function(t){return t.length>0})){try{s=u.map(function(t){return t.shift()}),o=r.apply(t,s)}catch(a){return i.onError(a),e}i.onNext(o)}else c.filter(function(t,e){return e!==n}).every(function(t){return t})&&i.onCompleted()},h=Array(s),f=0;s>f;f++)(function(t){h[t]=new T,h[t].setDisposable(n[t].subscribe(function(e){u[t].push(e),a(t)},i.onError.bind(i),function(){o(t)}))})(f);return new W(h)})},he.zip=function(t,e){var n=t[0],r=t.slice(1);return r.push(e),n.zip.apply(n,r)},ie.asObservable=function(){var t=this;return new Ce(function(e){return t.subscribe(e)})},ie.bufferWithCount=function(t,n){return n===e&&(n=t),this.windowWithCount(t,n).selectMany(function(t){return t.toArray()}).where(function(t){return t.length>0})},ie.dematerialize=function(){var t=this;return new Ce(function(e){return t.subscribe(function(t){return t.accept(e)},e.onError.bind(e),e.onCompleted.bind(e))})},ie.distinctUntilChanged=function(t,n){var i=this;return t||(t=r),n||(n=o),new Ce(function(r){var o,s=!1;return i.subscribe(function(i){var u,c=!1;try{u=t(i)}catch(a){return r.onError(a),e}if(s)try{c=n(o,u)}catch(a){return r.onError(a),e}s&&c||(s=!0,o=u,r.onNext(i))},r.onError.bind(r),r.onCompleted.bind(r))})},ie.doAction=function(t,e,n){var r,i=this;return"function"==typeof t?r=t:(r=t.onNext.bind(t),e=t.onError.bind(t),n=t.onCompleted.bind(t)),new Ce(function(t){return i.subscribe(function(e){try{r(e)}catch(n){t.onError(n)}t.onNext(e)},function(n){if(e){try{e(n)}catch(r){t.onError(r)}t.onError(n)}else t.onError(n)},function(){if(n){try{n()}catch(e){t.onError(e)}t.onCompleted()}else t.onCompleted()})})},ie.finallyAction=function(t){var e=this;return new Ce(function(n){var r=e.subscribe(n);return k(function(){try{r.dispose()}catch(e){throw e}finally{t()}})})},ie.ignoreElements=function(){var t=this;return new Ce(function(e){return t.subscribe(n,e.onError.bind(e),e.onCompleted.bind(e))})},ie.materialize=function(){var t=this;return new Ce(function(e){return t.subscribe(function(t){e.onNext(K(t))},function(t){e.onNext(Q(t)),e.onCompleted()},function(){e.onNext(X()),e.onCompleted()})})},ie.repeat=function(t){return te(this,t).concat()},ie.retry=function(t){return te(this,t).catchException()},ie.scan=function(){var t,e,n=!1;2===arguments.length?(t=arguments[0],e=arguments[1],n=!0):e=arguments[0];var r=this;return fe(function(){var i,o=!1;return r.select(function(r){return o?i=e(i,r):(i=n?e(t,r):r,o=!0),i})})},ie.skipLast=function(t){var e=this;return new Ce(function(n){var r=[];return e.subscribe(function(e){r.push(e),r.length>t&&n.onNext(r.shift())},n.onError.bind(n),n.onCompleted.bind(n))})},ie.startWith=function(){var t,n,r=0;return arguments.length>0&&null!=arguments[0]&&arguments[0].now!==e?(n=arguments[0],r=1):n=V,t=x.call(arguments,r),ee([de(t,n),this]).concat()},ie.takeLast=function(t,e){return this.takeLastBuffer(t).selectMany(function(t){return de(t,e)})},ie.takeLastBuffer=function(t){var e=this;return new Ce(function(n){var r=[];return e.subscribe(function(e){r.push(e),r.length>t&&r.shift()},n.onError.bind(n),function(){n.onNext(r),n.onCompleted()})})},ie.windowWithCount=function(t,e){var n=this;if(0>=t)throw Error(g);if(null==e&&(e=t),0>=e)throw Error(g);return new Ce(function(r){var i=new T,o=new P(i),s=0,u=[],c=function(){var t=new _e;u.push(t),r.onNext(A(t,o))};return c(),i.setDisposable(n.subscribe(function(n){for(var r,i=0,o=u.length;o>i;i++)u[i].onNext(n);var a=s-t+1;a>=0&&0===a%e&&(r=u.shift(),r.onCompleted()),s++,0===s%e&&c()},function(t){for(;u.length>0;)u.shift().onError(t);r.onError(t)},function(){for(;u.length>0;)u.shift().onCompleted();r.onCompleted()})),o})},ie.defaultIfEmpty=function(t){var n=this;return t===e&&(t=null),new Ce(function(e){var r=!1;return n.subscribe(function(t){r=!0,e.onNext(t)},e.onError.bind(e),function(){r||e.onNext(t),e.onCompleted()})})},ie.distinct=function(t,n){var i=this;return t||(t=r),n||(n=u),new Ce(function(r){var o={};return i.subscribe(function(i){var s,u,c,a=!1;try{s=t(i),u=n(s)}catch(h){return r.onError(h),e}for(c in o)if(u===c){a=!0;break}a||(o[u]=null,r.onNext(i))},r.onError.bind(r),r.onCompleted.bind(r))})},ie.groupBy=function(t,e,n){return this.groupByUntil(t,e,function(){return be()
},n)},ie.groupByUntil=function(t,i,o,s){var c=this;return i||(i=r),s||(s=u),new Ce(function(r){var u={},a=new W,h=new P(a);return a.add(c.subscribe(function(c){var l,f,p,d,b,v,m,y,w,g,E;try{m=t(c),y=s(m)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}b=!1;try{g=u[y],g||(g=new _e,u[y]=g,b=!0)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}if(b){v=new Ae(m,g,h),f=new Ae(m,g);try{l=o(f)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}r.onNext(v),w=new T,a.add(w),d=function(){y in u&&(delete u[y],g.onCompleted()),a.remove(w)},w.setDisposable(l.take(1).subscribe(n,function(t){for(E in u)u[E].onError(t);r.onError(t)},function(){d()}))}try{p=i(c)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}g.onNext(p)},function(t){for(var e in u)u[e].onError(t);r.onError(t)},function(){for(var t in u)u[t].onCompleted();r.onCompleted()})),h})},ie.select=function(t,n){var r=this;return new Ce(function(i){var o=0;return r.subscribe(function(s){var u;try{u=t.call(n,s,o++,r)}catch(c){return i.onError(c),e}i.onNext(u)},i.onError.bind(i),i.onCompleted.bind(i))})},ie.map=ie.select,ie.selectMany=ie.flatMap=function(t,e){return e?this.selectMany(function(n){return t(n).select(function(t){return e(n,t)})}):"function"==typeof t?v.call(this,t):v.call(this,function(){return t})},ie.skip=function(t){if(0>t)throw Error(g);var e=this;return new Ce(function(n){var r=t;return e.subscribe(function(t){0>=r?n.onNext(t):r--},n.onError.bind(n),n.onCompleted.bind(n))})},ie.skipWhile=function(t){var n=this;return new Ce(function(r){var i=0,o=!1;return n.subscribe(function(n){if(!o)try{o=!t(n,i++)}catch(s){return r.onError(s),e}o&&r.onNext(n)},r.onError.bind(r),r.onCompleted.bind(r))})},ie.take=function(t,e){if(0>t)throw Error(g);if(0===t)return pe(e);var n=this;return new Ce(function(e){var r=t;return n.subscribe(function(t){r>0&&(r--,e.onNext(t),0===r&&e.onCompleted())},e.onError.bind(e),e.onCompleted.bind(e))})},ie.takeWhile=function(t){var n=this;return new Ce(function(r){var i=0,o=!0;return n.subscribe(function(n){if(o){try{o=t(n,i++)}catch(s){return r.onError(s),e}o?r.onNext(n):r.onCompleted()}},r.onError.bind(r),r.onCompleted.bind(r))})},ie.where=function(t,n){var r=this;return new Ce(function(i){var o=0;return r.subscribe(function(s){var u;try{u=t.call(n,s,o++,r)}catch(c){return i.onError(c),e}u&&i.onNext(s)},i.onError.bind(i),i.onCompleted.bind(i))})},ie.filter=ie.where;var Ce=y.Internals.AnonymousObservable=function(t){function e(e){function n(t){var n=new De(t);if(z.scheduleRequired())z.schedule(function(){try{n.disposable(e(n))}catch(t){if(!n.fail(t))throw t}});else try{n.disposable(e(n))}catch(r){if(!n.fail(r))throw r}return n}t.call(this,n)}return C(e,t),e}(he),De=function(t){function e(e){t.call(this),this.observer=e,this.m=new T}C(e,t);var n=e.prototype;return n.next=function(t){var e=!1;try{this.observer.onNext(t),e=!0}catch(n){throw n}finally{e||this.dispose()}},n.error=function(t){try{this.observer.onError(t)}catch(e){throw e}finally{this.dispose()}},n.completed=function(){try{this.observer.onCompleted()}catch(t){throw t}finally{this.dispose()}},n.disposable=function(t){return this.m.disposable(t)},n.dispose=function(){t.prototype.dispose.call(this),this.m.dispose()},e}(oe),Ae=function(t){function e(t){return this.underlyingObservable.subscribe(t)}function n(n,r,i){t.call(this,e),this.key=n,this.underlyingObservable=i?new Ce(function(t){return new W(i.getDisposable(),r.subscribe(t))}):r}return C(n,t),n}(he),Se=function(t,e){this.subject=t,this.observer=e};Se.prototype.dispose=function(){if(!this.subject.isDisposed&&null!==this.observer){var t=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(t,1),this.observer=null}};var _e=y.Subject=function(t){function e(t){return a.call(this),this.isStopped?this.exception?(t.onError(this.exception),q):(t.onCompleted(),q):(this.observers.push(t),new Se(this,t))}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.observers=[]}return C(n,t),D(n.prototype,ne,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(a.call(this),!this.isStopped){var t=this.observers.slice(0);this.isStopped=!0;for(var e=0,n=t.length;n>e;e++)t[e].onCompleted();this.observers=[]}},onError:function(t){if(a.call(this),!this.isStopped){var e=this.observers.slice(0);this.isStopped=!0,this.exception=t;for(var n=0,r=e.length;r>n;n++)e[n].onError(t);this.observers=[]}},onNext:function(t){if(a.call(this),!this.isStopped)for(var e=this.observers.slice(0),n=0,r=e.length;r>n;n++)e[n].onNext(t)},dispose:function(){this.isDisposed=!0,this.observers=null}}),n.create=function(t,e){return new We(t,e)},n}(he),Ne=y.AsyncSubject=function(t){function e(t){if(a.call(this),!this.isStopped)return this.observers.push(t),new Se(this,t);var e=this.exception,n=this.hasValue,r=this.value;return e?t.onError(e):n?(t.onNext(r),t.onCompleted()):t.onCompleted(),q}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.value=null,this.hasValue=!1,this.observers=[],this.exception=null}return C(n,t),D(n.prototype,ne,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){var t,e,n;if(a.call(this),!this.isStopped){var r=this.observers.slice(0);this.isStopped=!0;var i=this.value,o=this.hasValue;if(o)for(e=0,n=r.length;n>e;e++)t=r[e],t.onNext(i),t.onCompleted();else for(e=0,n=r.length;n>e;e++)r[e].onCompleted();this.observers=[]}},onError:function(t){if(a.call(this),!this.isStopped){var e=this.observers.slice(0);this.isStopped=!0,this.exception=t;for(var n=0,r=e.length;r>n;n++)e[n].onError(t);this.observers=[]}},onNext:function(t){a.call(this),this.isStopped||(this.value=t,this.hasValue=!0)},dispose:function(){this.isDisposed=!0,this.observers=null,this.exception=null,this.value=null}}),n}(he),We=function(t){function e(t){return this.observable.subscribe(t)}function n(n,r){t.call(this,e),this.observer=n,this.observable=r}return C(n,t),D(n.prototype,ne,{onCompleted:function(){this.observer.onCompleted()},onError:function(t){this.observer.onError(t)},onNext:function(t){this.observer.onNext(t)}}),n}(he);return"function"==typeof define&&"object"==typeof define.amd&&define.amd?(t.Rx=y,define(function(){return y})):(m?"object"==typeof module&&module&&module.exports==m?module.exports=y:m=y:t.Rx=y,e)})(this);

@@ -1,8 +0,4 @@

/**
* Gets a scheduler that schedules work via a timed callback based upon platform.
*
* @memberOf Scheduler
*/
var timeoutScheduler = Scheduler.timeout = (function () {
var scheduleMethod, clearMethod = noop;
(function () {
function postMessageSupported () {

@@ -21,4 +17,3 @@ // Ensure not in a worker

var scheduleMethod, clearMethod = noop;
if (typeof window.process !== 'undefined' && typeof window.process === '[object process]') {
if (typeof window.process !== 'undefined' && Object.prototype.toString.call(window.process) === '[object process]') {
scheduleMethod = window.process.nextTick;

@@ -55,18 +50,31 @@ } else if (typeof window.setImmediate === 'function') {

} else if (!!window.MessageChannel) {
var channel = new window.MessageChannel(),
channelTasks = {},
channelTaskId = 0;
channel.port1.onmessage = function (event) {
var id = event.data,
action = channelTasks[id];
action();
delete channelTasks[id];
};
scheduleMethod = function (action) {
var channel = new window.MessageChannel();
channel.port1.onmessage = function (event) {
var id = channelTaskId++;
channelTasks[id] = action;
channel.port2.postMessage(id);
};
} else if ('document' in window && 'onreadystatechange' in window.document.createElement('script')) {
scheduleMethod = function (action) {
var scriptElement = window.document.createElement('script');
scriptElement.onreadystatechange = function () {
action();
scriptElement.onreadystatechange = null;
scriptElement.parentNode.removeChild(scriptElement);
scriptElement = null;
};
channel.port2.postMessage();
window.document.documentElement.appendChild(scriptElement);
};
} else if ('document' in window && 'onreadystatechange' in window.document.createElement('script')) {
var scriptElement = window.document.createElement('script');
scriptElement.onreadystatechange = function () {
action();
scriptElement.onreadystatechange = null;
scriptElement.parentNode.removeChild(scriptElement);
scriptElement = null;
};
window.document.documentElement.appendChild(scriptElement);
} else {

@@ -76,3 +84,11 @@ scheduleMethod = function (action) { return window.setTimeout(action, 0); };

}
}());
/**
* Gets a scheduler that schedules work via a timed callback based upon platform.
*
* @memberOf Scheduler
*/
var timeoutScheduler = Scheduler.timeout = (function () {
function scheduleNow(state, action) {

@@ -79,0 +95,0 @@ var scheduler = this,

@@ -0,0 +0,0 @@ /**

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc