Repository navigation
Expand file tree
/
Copy pathrx.lite.min.js
More file actions
2 lines (2 loc) · 50.6 KB
/
Copy pathrx.lite.min.js
File metadata and controls
2 lines (2 loc) · 50.6 KB
1
2
(function(t){function e(){if(this.isDisposed)throw Error(T)}function n(t){var e=typeof t;return t&&("function"==e||"object"==e)||!1}function r(t){var e=[];if(!n(t))return e;oe.nonEnumArgs&&t.length&&u(t)&&(t=ue.call(t));var r=oe.enumPrototypes&&"function"==typeof t,i=oe.enumErrorProps&&(t===Y||t instanceof Error);for(var o in t)r&&"prototype"==o||i&&("message"==o||"name"==o)||e.push(o);if(oe.nonEnumShadows&&t!==te){var s=t.constructor,c=-1,a=re.length;if(t===(s&&s.prototype))var h=t===stringProto?K:t===Y?U:Z.call(t),l=ie[h];for(;a>++c;)o=re[c],l&&l[o]||!X.call(t,o)||e.push(o)}return e}function i(t,e,n){for(var r=-1,i=n(t),o=i.length;o>++r;){var s=i[r];if(e(t[s],s,t)===!1)break}return t}function o(t,e){return i(t,e,r)}function s(t){return"function"!=typeof t.toString&&"string"==typeof(t+"")}function u(t){return t&&"object"==typeof t?Z.call(t)==M:!1}function c(t){return"function"==typeof t}function a(e,n,r,i){if(e===n)return 0!==e||1/e==1/n;var h=typeof e,l=typeof n;if(e===e&&(null==e||null==n||"function"!=h&&"object"!=h&&"function"!=l&&"object"!=l))return!1;var f=Z.call(e),p=Z.call(n);if(f==M&&(f=$),p==M&&(p=$),f!=p)return!1;switch(f){case B:case F:return+e==+n;case H:return e!=+e?n!=+n:0==e?1/e==1/n:e==+n;case J:case K:return e==n+""}var d=f==I;if(!d){if(f!=$||!oe.nodeClass&&(s(e)||s(n)))return!1;var b=!oe.argsObject&&u(e)?Object:e.constructor,v=!oe.argsObject&&u(n)?Object:n.constructor;if(!(b==v||X.call(e,"constructor")&&X.call(n,"constructor")||c(b)&&b instanceof b&&c(v)&&v instanceof v||!("constructor"in e&&"constructor"in n)))return!1}r||(r=[]),i||(i=[]);for(var m=r.length;m--;)if(r[m]==e)return i[m]==n;var y=0;if(result=!0,r.push(e),i.push(n),d){if(m=e.length,y=n.length,result=y==m)for(;y--;){var w=n[y];if(!(result=a(e[y],w,r,i)))break}}else o(n,function(n,o,s){return X.call(s,o)?(y++,result=X.call(e,o)&&a(e[o],n,r,i)):t}),result&&o(e,function(e,n,r){return X.call(r,n)?result=--y>-1:t});return r.pop(),i.pop(),result}function h(t,e){return 1===t.length&&Array.isArray(t[e])?t[e]:ue.call(t)}function l(t,e){for(var n=Array(t),r=0;t>r;r++)n[r]=e();return n}function f(e,n){return new fn(function(r){var i=new we,o=new ge;return o.setDisposable(i),i.setDisposable(e.subscribe(r.onNext.bind(r),function(e){var i,s;try{s=n(e)}catch(u){return r.onError(u),t}q(s)&&(s=rn(s)),i=new we,o.setDisposable(i),i.setDisposable(s.subscribe(r))},r.onCompleted.bind(r))),o})}function p(e,n){var r=this;return new fn(function(i){var o=0,s=e.length;return r.subscribe(function(r){if(s>o){var u,c=e[o++];try{u=n(r,c)}catch(a){return i.onError(a),t}i.onNext(u)}else i.onCompleted()},i.onError.bind(i),i.onCompleted.bind(i))})}function d(t){return this.select(function(e,n){var r=t(e,n);return q(r)?rn(r):r}).mergeObservable()}function b(t,e,n){if(t.addListener)return t.addListener(e,n),ve(function(){t.removeListener(e,n)});if(t.addEventListener)return t.addEventListener(e,n,!1),ve(function(){t.removeEventListener(e,n,!1)});throw Error("No listener found")}function v(t,e,n){var r=new pe;if("function"==typeof t.item&&"number"==typeof t.length)for(var i=0,o=t.length;o>i;i++)r.add(v(t.item(i),e,n));else t&&r.add(b(t,e,n));return r}function m(t,e){var n=Ce(t);return new fn(function(t){return e.scheduleWithRelative(n,function(){t.onNext(0),t.onCompleted()})})}function y(t,e,n){return t===e?new fn(function(t){return n.schedulePeriodicWithState(0,e,function(e){return t.onNext(e),e+1})}):Ue(function(){return observableTimerDateAndPeriod(n.now()+t,e,n)})}function w(t,e){return new fn(function(n){function r(){s&&(s=!1,n.onNext(o)),i&&n.onCompleted()}var i,o,s;return new pe(t.subscribe(function(t){s=!0,o=t},n.onError.bind(n),function(){i=!0}),e.subscribe(r,n.onError.bind(n),r))})}function g(e,n,r){return new fn(function(i){function o(e,n){h[n]=e;var o;if(u[n]=!0,c||(c=u.every(_))){try{o=r.apply(null,h)}catch(s){return i.onError(s),t}i.onNext(o)}else a&&i.onCompleted()}var s=2,u=[!1,!1],c=!1,a=!1,h=Array(s);return new pe(e.subscribe(function(t){o(t,0)},i.onError.bind(i),function(){a=!0,i.onCompleted()}),n.subscribe(function(t){o(t,1)},i.onError.bind(i)))})}var E={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},x=E[typeof window]&&window||this,C=E[typeof exports]&&exports&&!exports.nodeType&&exports,D=E[typeof module]&&module&&!module.nodeType&&module,N=D&&D.exports===C&&C,S=E[typeof global]&&global;!S||S.global!==S&&S.window!==S||(x=S);var A={internals:{},config:{Promise:x.Promise},helpers:{}},O=A.helpers.noop=function(){},_=A.helpers.identity=function(t){return t},R=A.helpers.defaultNow=Date.now,j=A.helpers.defaultComparer=function(t,e){return se(t,e)},k=A.helpers.defaultSubComparer=function(t,e){return t>e?1:e>t?-1:0},W=(A.helpers.defaultKeySerializer=function(t){return""+t},A.helpers.defaultError=function(t){throw t}),q=A.helpers.isPromise=function(t){return!!t&&"function"==typeof t.then&&t.then!==A.Observable.prototype.then};A.helpers.asArray=function(){return Array.prototype.slice.call(arguments)},A.helpers.not=function(t){return!t};var P="Argument out of range",T="Object has been disposed",L="object"==typeof Symbol&&Symbol.iterator||"_es6shim_iterator_";x.Set&&"function"==typeof(new x.Set)["@@iterator"]&&(L="@@iterator");var V,z={done:!0,value:t},M="[object Arguments]",I="[object Array]",B="[object Boolean]",F="[object Date]",U="[object Error]",Q="[object Function]",H="[object Number]",$="[object Object]",J="[object RegExp]",K="[object String]",Z=Object.prototype.toString,X=Object.prototype.hasOwnProperty,G=Z.call(arguments)==M,Y=Error.prototype,te=Object.prototype,ee=te.propertyIsEnumerable;try{V=!(Z.call(document)==$&&!({toString:0}+""))}catch(ne){V=!0}var re=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],ie={};ie[I]=ie[F]=ie[H]={constructor:!0,toLocaleString:!0,toString:!0,valueOf:!0},ie[B]=ie[K]={constructor:!0,toString:!0,valueOf:!0},ie[U]=ie[Q]=ie[J]={constructor:!0,toString:!0},ie[$]={constructor:!0};var oe={};(function(){var t=function(){this.x=1},e=[];t.prototype={valueOf:1,y:1};for(var n in new t)e.push(n);for(n in arguments);oe.enumErrorProps=ee.call(Y,"message")||ee.call(Y,"name"),oe.enumPrototypes=ee.call(t,"prototype"),oe.nonEnumArgs=0!=n,oe.nonEnumShadows=!/valueOf/.test(e)})(1),G||(u=function(t){return t&&"object"==typeof t?X.call(t,"callee"):!1}),c(/x/)&&(c=function(t){return"function"==typeof t&&Z.call(t)==Q});var se=A.internals.isEqual=function(t,e){return a(t,e,[],[])},ue=Array.prototype.slice;({}).hasOwnProperty;var ce=this.inherits=A.internals.inherits=function(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n},ae=A.internals.addProperties=function(t){for(var e=ue.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.internals.addRef=function(t,e){return new fn(function(n){return new pe(e.getDisposable(),t.subscribe(n))})};var he=function(t,e){this.id=t,this.value=e};he.prototype.compareTo=function(t){var e=this.value.compareTo(t.value);return 0===e&&(e=this.id-t.id),e};var le=A.internals.PriorityQueue=function(t){this.items=Array(t),this.length=0},fe=le.prototype;fe.isHigherPriority=function(t,e){return 0>this.items[t].compareTo(this.items[e])},fe.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)}}},fe.heapify=function(e){if(e===t&&(e=0),!(e>=this.length||0>e)){var n=2*e+1,r=2*e+2,i=e;if(this.length>n&&this.isHigherPriority(n,i)&&(i=n),this.length>r&&this.isHigherPriority(r,i)&&(i=r),i!==e){var o=this.items[e];this.items[e]=this.items[i],this.items[i]=o,this.heapify(i)}}},fe.peek=function(){return this.items[0].value},fe.removeAt=function(t){this.items[t]=this.items[--this.length],delete this.items[this.length],this.heapify()},fe.dequeue=function(){var t=this.peek();return this.removeAt(0),t},fe.enqueue=function(t){var e=this.length++;this.items[e]=new he(le.count++,t),this.percolate(e)},fe.remove=function(t){for(var e=0;this.length>e;e++)if(this.items[e].value===t)return this.removeAt(e),!0;return!1},le.count=0;var pe=A.CompositeDisposable=function(){this.disposables=h(arguments,0),this.isDisposed=!1,this.length=this.disposables.length},de=pe.prototype;de.add=function(t){this.isDisposed?t.dispose():(this.disposables.push(t),this.length++)},de.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},de.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()}},de.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()},de.contains=function(t){return-1!==this.disposables.indexOf(t)},de.toArray=function(){return this.disposables.slice(0)};var be=A.Disposable=function(t){this.isDisposed=!1,this.action=t||O};be.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var ve=be.create=function(t){return new be(t)},me=be.empty={dispose:O},ye=function(){function t(t){this.isSingle=t,this.isDisposed=!1,this.current=null}var e=t.prototype;return e.getDisposable=function(){return this.current},e.setDisposable=function(t){if(this.current&&this.isSingle)throw Error("Disposable has already been assigned");var e,n=this.isDisposed;n||(e=this.current,this.current=t),e&&e.dispose(),n&&t&&t.dispose()},e.dispose=function(){var t;this.isDisposed||(this.isDisposed=!0,t=this.current,this.current=null),t&&t.dispose()},t}(),we=A.SingleAssignmentDisposable=function(t){function e(){t.call(this,!0)}return ce(e,t),e}(ye),ge=A.SerialDisposable=function(t){function e(){t.call(this,!1)}return ce(e,t),e}(ye);A.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?me:new t(this)},e}();var Ee=A.internals.ScheduledItem=function(t,e,n,r,i){this.scheduler=t,this.state=e,this.action=n,this.dueTime=r,this.comparer=i||k,this.disposable=new we};Ee.prototype.invoke=function(){this.disposable.setDisposable(this.invokeCore())},Ee.prototype.compareTo=function(t){return this.comparer(this.dueTime,t.dueTime)},Ee.prototype.isCancelled=function(){return this.disposable.isDisposed},Ee.prototype.invokeCore=function(){return this.action(this.scheduler,this.state)};var xe=A.Scheduler=function(){function t(t,e,n,r){this.now=t,this._schedule=e,this._scheduleRelative=n,this._scheduleAbsolute=r}function e(t,e){var n=e.first,r=e.second,i=new pe,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),me});r||(i.add(s),n=!0)})};return o(n),i}function n(t,e,n){var r=e.first,i=e.second,o=new pe,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),me});u||(o.add(c),i=!0)})};return s(r),o}function r(t,e){return e(),me}var i=t.prototype;return i.schedulePeriodic=function(t,e){return this.schedulePeriodicWithState(null,t,function(){e()})},i.schedulePeriodicWithState=function(t,e,n){var r=t,i=setInterval(function(){r=n(r)},e);return ve(function(){clearInterval(i)})},i.schedule=function(t){return this._schedule(t,r)},i.scheduleWithState=function(t,e){return this._schedule(t,e)},i.scheduleWithRelative=function(t,e){return this._scheduleRelative(e,t,r)},i.scheduleWithRelativeAndState=function(t,e,n){return this._scheduleRelative(t,e,n)},i.scheduleWithAbsolute=function(t,e){return this._scheduleAbsolute(e,t,r)},i.scheduleWithAbsoluteAndState=function(t,e,n){return this._scheduleAbsolute(t,e,n)},i.scheduleRecursive=function(t){return this.scheduleRecursiveWithState(t,function(t,e){t(function(){e(t)})})},i.scheduleRecursiveWithState=function(t,n){return this.scheduleWithState({first:t,second:n},function(t,n){return e(t,n)})},i.scheduleRecursiveWithRelative=function(t,e){return this.scheduleRecursiveWithRelativeAndState(e,t,function(t,e){t(function(n){e(t,n)})})},i.scheduleRecursiveWithRelativeAndState=function(t,e,r){return this._scheduleRelative({first:t,second:r},e,function(t,e){return n(t,e,"scheduleWithRelativeAndState")})},i.scheduleRecursiveWithAbsolute=function(t,e){return this.scheduleRecursiveWithAbsoluteAndState(e,t,function(t,e){t(function(n){e(t,n)})})},i.scheduleRecursiveWithAbsoluteAndState=function(t,e,r){return this._scheduleAbsolute({first:t,second:r},e,function(t,e){return n(t,e,"scheduleWithAbsoluteAndState")})},t.now=R,t.normalize=function(t){return 0>t&&(t=0),t},t}(),Ce=xe.normalize,De=xe.immediate=function(){function t(t,e){return e(this,t)}function e(t,e,n){for(var r=Ce(r);r-this.now()>0;);return n(this,t)}function n(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new xe(R,t,e,n)}(),Ne=xe.currentThread=function(){function t(t){for(var e;t.length>0;)if(e=t.dequeue(),!e.isCancelled()){for(;e.dueTime-xe.now()>0;);e.isCancelled()||e.invoke()}}function e(t,e){return this.scheduleWithRelativeAndState(t,0,e)}function n(e,n,r){var o=this.now()+xe.normalize(n),s=new Ee(this,e,r,o);if(i)i.enqueue(s);else{i=new le(4),i.enqueue(s);try{t(i)}catch(u){throw u}finally{i=null}}return s.disposable}function r(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n
C98B
)}var i,o=new xe(R,e,n,r);return o.scheduleRequired=function(){return null===i},o.ensureTrampoline=function(t){return null===i?this.schedule(t):t()},o}();A.internals.SchedulePeriodicRecursive=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 we;return this._cancel=e,e.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,t.bind(this))),e},e}();var Se,Ae=O;(function(){function t(){if(!x.postMessage||x.importScripts)return!1;var t=!1,e=x.onmessage;return x. e(t){if("string"==typeof t.data&&t.data.substring(0,o.length)===o){var e=t.data.substring(o.length),n=s[e];n(),delete s[e]}}var n=RegExp("^"+(Z+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),r="function"==typeof(r=S&&N&&S.setImmediate)&&!n.test(r)&&r,i="function"==typeof(i=S&&N&&S.clearImmediate)&&!n.test(i)&&i;if("undefined"!=typeof process&&"[object process]"==={}.toString.call(process))Se=process.nextTick;else if("function"==typeof r)Se=r,Ae=i;else if(t()){var o="ms.rx.schedule"+Math.random(),s={},u=0;x.addEventListener?x.addEventListener("message",e,!1):x.attachEvent("onmessage",e,!1),Se=function(t){var e=u++;s[e]=t,x.postMessage(o+e,"*")}}else if(x.MessageChannel){var c=new x.MessageChannel,a={},h=0;c.port1. e=t.data,n=a[e];n(),delete a[e]},Se=function(t){var e=h++;a[e]=t,c.port2.postMessage(e)}}else"document"in x&&"onreadystatechange"in x.document.createElement("script")?Se=function(t){var e=x.document.createElement("script");e. setTimeout(t,0)},Ae=clearTimeout)})();var Oe=xe.timeout=function(){function t(t,e){var n=this,r=new we,i=Se(function(){r.isDisposed||r.setDisposable(e(n,t))});return new pe(r,ve(function(){Ae(i)}))}function e(t,e,n){var r=this,i=xe.normalize(e);if(0===i)return r.scheduleWithState(t,n);var o=new we,s=setTimeout(function(){o.isDisposed||o.setDisposable(n(r,t))},i);return new pe(o,ve(function(){clearTimeout(s)}))}function n(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new xe(R,t,e,n)}(),_e=A.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=De),new fn(function(n){return t.schedule(function(){e._acceptObservable(n),"N"===e.kind&&n.onCompleted()})})},t}(),Re=_e.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 _e("N",!0);return i.value=r,i._accept=t,i._acceptObservable=e,i.toString=n,i}}(),je=_e.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 _e("E");return i.exception=r,i._accept=t,i._acceptObservable=e,i.toString=n,i}}(),ke=_e.createOnCompleted=function(){function t(t,e,n){return n()}function e(t){return t.onCompleted()}function n(){return"OnCompleted()"}return function(){var r=new _e("C");return r._accept=t,r._acceptObservable=e,r.toString=n,r}}(),We=A.internals.Enumerator=function(t){this._next=t};We.prototype.next=function(){return this._next()},We.prototype[L]=function(){return this};var qe=A.internals.Enumerable=function(t){this._iterator=t};qe.prototype[L]=function(){return this._iterator()},qe.prototype.concat=function(){var e=this;return new fn(function(n){var r;try{r=e[L]()}catch(i){return n.onError(),t}var o,s=new ge,u=De.scheduleRecursive(function(e){var i;if(!o){try{i=r.next()}catch(u){return n.onError(u),t}if(i.done)return n.onCompleted(),t;var c=i.value;q(c)&&(c=rn(c));var a=new we;s.setDisposable(a),a.setDisposable(c.subscribe(n.onNext.bind(n),n.onError.bind(n),function(){e()}))}});return new pe(s,u,ve(function(){o=!0}))})},qe.prototype.catchException=function(){var e=this;return new fn(function(n){var r;try{r=e[L]()}catch(i){return n.onError(),t}var o,s,u=new ge,c=De.scheduleRecursive(function(e){if(!o){var i;try{i=r.next()}catch(c){return n.onError(c),t}if(i.done)return s?n.onError(s):n.onCompleted(),t;var a=i.value;q(a)&&(a=rn(a));var h=new we;u.setDisposable(h),h.setDisposable(a.subscribe(n.onNext.bind(n),function(t){s=t,e()},n.onCompleted.bind(n)))}});return new pe(u,c,ve(function(){o=!0}))})};var Pe=qe.repeat=function(t,e){return null==e&&(e=-1),new qe(function(){var n=e;return new We(function(){return 0===n?z:(n>0&&n--,{done:!1,value:t})})})},Te=qe.forEach=function(t,e,n){return e||(e=_),new qe(function(){var r=-1;return new We(function(){return++r<t.length?{done:!1,value:e.call(n,t[r],r,t)}:z})})},Le=A.Observer=function(){};Le.prototype.toNotifier=function(){var t=this;return function(e){return e.accept(t)}},Le.prototype.asObserver=function(){return new Ie(this.onNext.bind(this),this.onError.bind(this),this.onCompleted.bind(this))};var Ve=Le.create=function(t,e,n){return t||(t=O),e||(e=W),n||(n=O),new Ie(t,e,n)};Le.fromNotifier=function(t){return new Ie(function(e){return t(Re(e))},function(e){return t(je(e))},function(){return t(ke())})};var ze,Me=A.internals.AbstractObserver=function(t){function e(){this.isStopped=!1,t.call(this)}return ce(e,t),e.prototype. this.isStopped?!1:(this.isStopped=!0,this.error(t),!0)},e}(Le),Ie=A.AnonymousObserver=function(t){function e(e,n,r){t.call(this),this._onNext=e,this._onError=n,this._onCompleted=r}return ce(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}(Me),Be=A.Observable=function(){function t(t){this._subscribe=t}return ze=t.prototype,ze.subscribe=ze.forEach=function(t,e,n){var r="object"==typeof t?t:Ve(t,e,n);return this._subscribe(r)},t}(),Fe=A.internals.ScheduledObserver=function(e){function n(t,n){e.call(this),this.scheduler=t,this.observer=n,this.isAcquired=!1,this.hasFaulted=!1,this.queue=[],this.disposable=new ge}return ce(n,e),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 e=!1,n=this;!this.hasFaulted&&this.queue.length>0&&(e=!this.isAcquired,this.isAcquired=!0),e&&this.disposable.setDisposable(this.scheduler.scheduleRecursive(function(e){var r;if(!(n.queue.length>0))return n.isAcquired=!1,t;r=n.queue.shift();try{r()}catch(i){throw n.queue=[],n.hasFaulted=!0,i}e()}))},n.prototype.dispose=function(){e.prototype.dispose.call(this),this.disposable.dispose()},n}(Me);ze.toArray=function(){var t=this;return new fn(function(e){var n=[];return t.subscribe(n.push.bind(n),e.onError.bind(e),function(){e.onNext(n),e.onCompleted()})})},Be.create=Be.createWithDisposable=function(t){return new fn(t)};var Ue=Be.defer=function(t){return new fn(function(e){var n;try{n=t()}catch(r){return Ke(r).subscribe(e)}return q(n)&&(n=rn(n)),n.subscribe(e)})},Qe=Be.empty=function(t){return t||(t=De),new fn(function(e){return t.schedule(function(){e.onCompleted()})})},He=Be.fromArray=function(t,e){return e||(e=Ne),new fn(function(n){var r=0;return e.scheduleRecursive(function(e){t.length>r?(n.onNext(t[r++]),e()):n.onCompleted()})})};Be.fromIterable=function(e,n){return n||(n=Ne),new fn(function(r){var i;try{i=e[L]()}catch(o){return r.onError(o),t}return n.scheduleRecursive(function(e){var n;try{n=i.next()}catch(o){return r.onError(o),t}n.done?r.onCompleted():(r.onNext(n.value),e())})})},Be.generate=function(e,n,r,i,o){return o||(o=Ne),new fn(function(s){var u=!0,c=e;return o.scheduleRecursive(function(e){var o,a;try{u?u=!1:c=r(c),o=n(c),o&&(a=i(c))}catch(h){return s.onError(h),t}o?(s.onNext(a),e()):s.onCompleted()})})};var $e=Be.never=function(){return new fn(function(){return me})};Be.range=function(t,e,n){return n||(n=Ne),new fn(function(r){return n.scheduleRecursiveWithState(0,function(n,i){e>n?(r.onNext(t+n),i(n+1)):r.onCompleted()})})},Be.repeat=function(t,e,n){return n||(n=Ne),null==e&&(e=-1),Je(t,n).repeat(e)};var Je=Be["return"]=Be.returnValue=function(t,e){return e||(e=De),new fn(function(n){return e.schedule(function(){n.onNext(t),n.onCompleted()})})},Ke=Be["throw"]=Be.throwException=function(t,e){return e||(e=De),new fn(function(n){return e.schedule(function(){n.onError(t)})})};ze["catch"]=ze.catchException=function(t){return"function"==typeof t?f(this,t):Ze([this,t])};var Ze=Be.catchException=Be["catch"]=function(){var t=h(arguments,0);return Te(t).catchException()};ze.combineLatest=function(){var t=ue.call(arguments);return Array.isArray(t[0])?t[0].unshift(this):t.unshift(this),Xe.apply(this,t)};var Xe=Be.combineLatest=function(){var e=ue.call(arguments),n=e.pop();return Array.isArray(e[0])&&(e=e[0]),new fn(function(r){function i(e){var i;if(c[e]=!0,a||(a=c.every(_))){try{i=n.apply(null,f)}catch(o){return r.onError(o),t}r.onNext(i)}else h.filter(function(t,n){return n!==e}).every(_)&&r.onCompleted()}function o(t){h[t]=!0,h.every(_)&&r.onCompleted()}for(var s=function(){return!1},u=e.length,c=l(u,s),a=!1,h=l(u,s),f=Array(u),p=Array(u),d=0;u>d;d++)(function(t){var n=e[t],s=new we;q(n)&&(n=rn(n)),s.setDisposable(n.subscribe(function(e){f[t]=e,i(t)},r.onError.bind(r),function(){o(t)})),p[t]=s})(d);return new pe(p)})};ze.concat=function(){var t=ue.call(arguments,0);return t.unshift(this),Ge.apply(this,t)};var Ge=Be.concat=function(){var t=h(arguments,0);return Te(t).concat()};ze.concatObservable=ze.concatAll=function(){return this.merge(1)},ze.merge=function(t){if("number"!=typeof t)return Ye(this,t);var e=this;return new fn(function(n){var r=0,i=new pe,o=!1,s=[],u=function(t){var e=new we;i.add(e),q(t)&&(t=rn(t)),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 Ye=Be.merge=function(){var t,e;return arguments[0]?arguments[0].now?(t=arguments[0],e=ue.call(arguments,1)):(t=De,e=ue.call(arguments,0)):(t=De,e=ue.call(arguments,1)),Array.isArray(e[0])&&(e=e[0]),He(e,t).mergeObservable()};ze.mergeObservable=ze.mergeAll=function(){var t=this;return new fn(function(e){var n=new pe,r=!1,i=new we;return n.add(i),i.setDisposable(t.subscribe(function(t){var i=new we;n.add(i),q(t)&&(t=rn(t)),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})},ze.skipUntil=function(t){var e=this;return new fn(function(n){var r=!1,i=new pe(e.subscribe(function(t){r&&n.onNext(t)},n.onError.bind(n),function(){r&&n.onCompleted()}));q(t)&&(t=rn(t));var o=new we;return i.add(o),o.setDisposable(t.subscribe(function(){r=!0,o.dispose()},n.onError.bind(n),function(){o.dispose()})),i})},ze["switch"]=ze.switchLatest=function(){var t=this;return new fn(function(e){var n=!1,r=new ge,i=!1,o=0,s=t.subscribe(function(t){var s=new we,u=++o;n=!0,r.setDisposable(s),q(t)&&(t=rn(t)),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 pe(s,r)})},ze.takeUntil=function(t){var e=this;return new fn(function(n){return q(t)&&(t=rn(t)),new pe(e.subscribe(n),t.subscribe(n.onCompleted.bind(n),n.onError.bind(n),O))})},ze.zip=function(){if(Array.isArray(arguments[0]))return p.apply(this,arguments);var e=this,n=ue.call(arguments),r=n.pop();return n.unshift(e),new fn(function(i){function o(n){var o,s;if(c.every(function(t){return t.length>0})){try{s=c.map(function(t){return t.shift()}),o=r.apply(e,s)}catch(u){return i.onError(u),t}i.onNext(o)}else a.filter(function(t,e){return e!==n}).every(_)&&i.onCompleted()}function s(t){a[t]=!0,a.every(function(t){return t})&&i.onCompleted()}for(var u=n.length,c=l(u,function(){return[]}),a=l(u,function(){return!1}),h=Array(u),f=0;u>f;f++)(function(t){var e=n[t],r=new we;q(e)&&(e=rn(e)),r.setDisposable(e.subscribe(function(e){c[t].push(e),o(t)},i.onError.bind(i),function(){s(t)})),h[t]=r})(f);return new pe(h)})},Be.zip=function(){var t=ue.call(arguments,0),e=t.shift();return e.zip.apply(e,t)},Be.zipArray=function(){var e=h(arguments,0);return new fn(function(n){function r(e){if(s.every(function(t){return t.length>0})){var r=s.map(function(t){return t.shift()});n.onNext(r)}else if(u.filter(function(t,n){return n!==e}).every(_))return n.onCompleted(),t}function i(e){return u[e]=!0,u.every(_)?(n.onCompleted(),t):t}for(var o=e.length,s=l(o,function(){return[]}),u=l(o,function(){return!1}),c=Array(o),a=0;o>a;a++)(function(t){c[t]=new we,c[t].setDisposable(e[t].subscribe(function(e){s[t].push(e),r(t)},n.onError.bind(n),function(){i(t)}))})(a);var h=new pe(c);return h.add(ve(function(){for(var t=0,e=s.length;e>t;t++)s[t]=[]})),h})},ze.asObservable=function(){var t=this;return new fn(function(e){return t.subscribe(e)})},ze.dematerialize=function(){var t=this;return new fn(function(e){return t.subscribe(function(t){return t.accept(e)},e.onError.bind(e),e.onCompleted.bind(e))})},ze.distinctUntilChanged=function(e,n){var r=this;return e||(e=_),n||(n=j),new fn(function(i){var o,s=!1;return r.subscribe(function(r){var u,c=!1;try{u=e(r)}catch(a){return i.onError(a),t}if(s)try{c=n(o,u)}catch(a){return i.onError(a),t}s&&c||(s=!0,o=u,i.onNext(r))},i.onError.bind(i),i.onCompleted.bind(i))})},ze["do"]=ze.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 fn(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()})})},ze["finally"]=ze.finallyAction=function(t){var e=this;return new fn(function(n){var r;try{r=e.subscribe(n)}catch(i){throw t(),i}return ve(function(){try{r.dispose()}catch(e){throw e}finally{t()}})})},ze.ignoreElements=function(){var t=this;return new fn(function(e){return t.subscribe(O,e.onError.bind(e),e.onCompleted.bind(e))})},ze.materialize=function(){var t=this;return new fn(function(e){return t.subscribe(function(t){e.onNext(Re(t))},function(t){e.onNext(je(t)),e.onCompleted()},function(){e.onNext(ke()),e.onCompleted()})})},ze.repeat=function(t){return Pe(this,t).concat()},ze.retry=function(t){return Pe(this,t).catchException()},ze.scan=function(){var e,n,r=!1,i=this;return 2===arguments.length?(r=!0,e=arguments[0],n=arguments[1]):n=arguments[0],new fn(function(o){var s,u,c;return i.subscribe(function(i){try{c||(c=!0),s?u=n(u,i):(u=r?n(e,i):i,s=!0)}catch(a){return o.onError(a),t}o.onNext(u)},o.onError.bind(o),function(){!c&&r&&o.onNext(e),o.onCompleted()})})},ze.skipLast=function(t){var e=this;return new fn(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))})},ze.startWith=function(){var t,e,n=0;return arguments.length&&"now"in Object(arguments[0])?(e=arguments[0],n=1):e=De,t=ue.call(arguments,n),Te([He(t,e),this]).concat()},ze.takeLast=function(t,e){return this.takeLastBuffer(t).selectMany(function(t){return He(t,e)})},ze.takeLastBuffer=function(t){var e=this;return new fn(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()})})},ze.select=ze.map=function(e,n){var r=this;return new fn(function(i){var o=0;return r.subscribe(function(s){var u;try{u=e.call(n,s,o++,r)}catch(c){return i.onError(c),t}i.onNext(u)},i.onError.bind(i),i.onCompleted.bind(i))})},ze.pluck=function(t){return this.select(function(e){return e[t]})},ze.selectMany=ze.flatMap=function(t,e){return e?this.selectMany(function(n,r){var i=t(n,r),o=q(i)?rn(i):i;return o.select(function(t){return e(n,t,r)})}):"function"==typeof t?d.call(this,t):d.call(this,function(){return t})},ze.selectSwitch=ze.flatMapLatest=function(t,e){return this.select(t,e).switchLatest()},ze.skip=function(t){if(0>t)throw Error(P);var e=this;return new fn(function(n){var r=t;return e.subscribe(function(t){0>=r?n.onNext(t):r--},n.onError.bind(n),n.onCompleted.bind(n))})},ze.skipWhile=function(e,n){var r=this;return new fn(function(i){var o=0,s=!1;return r.subscribe(function(u){if(!s)try{s=!e.call(n,u,o++,r)}catch(c){return i.onError(c),t}s&&i.onNext(u)},i.onError.bind(i),i.onCompleted.bind(i))})},ze.take=function(t,e){if(0>t)throw Error(P);if(0===t)return Qe(e);var n=this;return new fn(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))})},ze.takeWhile=function(e,n){var r=this;return new fn(function(i){var o=0,s=!0;return r.subscribe(function(u){if(s){try{s=e.call(n,u,o++,r)}catch(c){return i.onError(c),t}s?i.onNext(u):i.onCompleted()}},i.onError.bind(i),i.onCompleted.bind(i))})},ze.where=ze.filter=function(e,n){var r=this;return new fn(function(i){var o=0;return r.subscribe(function(s){var u;try{u=e.call(n,s,o++,r)
}catch(c){return i.onError(c),t}u&&i.onNext(s)},i.onError.bind(i),i.onCompleted.bind(i))})},Be.fromCallback=function(e,n,r,i){return n||(n=De),function(){var o=ue.call(arguments,0);return new fn(function(s){return n.schedule(function(){function n(e){var n=e;if(i)try{n=i(arguments)}catch(r){return s.onError(r),t}else 1===n.length&&(n=n[0]);s.onNext(n),s.onCompleted()}o.push(n),e.apply(r,o)})})}},Be.fromNodeCallback=function(e,n,r,i){return n||(n=De),function(){var o=ue.call(arguments,0);return new fn(function(s){return n.schedule(function(){function n(e){if(e)return s.onError(e),t;var n=ue.call(arguments,1);if(i)try{n=i(n)}catch(r){return s.onError(r),t}else 1===n.length&&(n=n[0]);s.onNext(n),s.onCompleted()}o.push(n),e.apply(r,o)})})}};var tn=x.angular&&angular.element?angular.element:x.jQuery?x.jQuery:x.Zepto?x.Zepto:null,en=!!x.Ember&&"function"==typeof x.Ember.addListener;Be.fromEvent=function(e,n,r){if(en)return nn(function(){Ember.addListener(e,n)},function(){Ember.removeListener(e,n)},r);if(tn){var i=tn(e);return nn(function(t){i.on(n,t)},function(t){i.off(n,t)},r)}return new fn(function(i){return v(e,n,function(e){var n=e;if(r)try{n=r(arguments)}catch(o){return i.onError(o),t}i.onNext(n)})}).publish().refCount()};var nn=Be.fromEventPattern=function(e,n,r){return new fn(function(i){function o(e){var n=e;if(r)try{n=r(arguments)}catch(o){return i.onError(o),t}i.onNext(n)}var s=e(o);return ve(function(){n&&n(o,s)})}).publish().refCount()},rn=Be.fromPromise=function(t){return new fn(function(e){return t.then(function(t){e.onNext(t),e.onCompleted()},function(t){e.onError(t)}),function(){t&&t.abort&&t.abort()}})};ze.toPromise=function(t){if(t||(t=A.config.Promise),!t)throw Error("Promise type not provided nor in Rx.config.Promise");var e=this;return new t(function(t,n){var r,i=!1;e.subscribe(function(t){r=t,i=!0},function(t){n(t)},function(){i&&t(r)})})},Be.startAsync=function(t){var e;try{e=t()}catch(n){return Ke(n)}return rn(e)},ze.multicast=function(t,e){var n=this;return"function"==typeof t?new fn(function(r){var i=n.multicast(t());return new pe(e(i).subscribe(r),i.connect())}):new on(n,t)},ze.publish=function(t){return t?this.multicast(function(){return new bn},t):this.multicast(new bn)},ze.share=function(){return this.publish(null).refCount()},ze.publishLast=function(t){return t?this.multicast(function(){return new vn},t):this.multicast(new vn)},ze.publishValue=function(t,e){return 2===arguments.length?this.multicast(function(){return new yn(e)},t):this.multicast(new yn(t))},ze.shareValue=function(t){return this.publishValue(t).refCount()},ze.replay=function(t,e,n,r){return t?this.multicast(function(){return new wn(e,n,r)},t):this.multicast(new wn(e,n,r))},ze.shareReplay=function(t,e,n){return this.replay(null,t,e,n).refCount()};var on=A.ConnectableObservable=function(t){function e(e,n){function r(t){return i.subject.subscribe(t)}var i={subject:n,source:e.asObservable(),hasSubscription:!1,subscription:null};this.connect=function(){return i.hasSubscription||(i.hasSubscription=!0,i.subscription=new pe(i.source.subscribe(i.subject),ve(function(){i.hasSubscription=!1}))),i.subscription},t.call(this,r)}return ce(e,t),e.prototype.connect=function(){return this.connect()},e.prototype.refCount=function(){var t=null,e=0,n=this;return new fn(function(r){var i,o;return e++,i=1===e,o=n.subscribe(r),i&&(t=n.connect()),ve(function(){o.dispose(),e--,0===e&&t.dispose()})})},e}(Be),sn=Be.interval=function(t,e){return e||(e=Oe),y(t,t,e)},un=Be.timer=function(e,n,r){var i;return r||(r=Oe),"number"==typeof n?i=n:"object"==typeof n&&"now"in n&&(r=n),i===t?m(e,r):y(e,i,r)};ze.delay=function(t,e){e||(e=Oe);var n=this;return new fn(function(r){var i,o=!1,s=new ge,u=null,c=[],a=!1;return i=n.materialize().timestamp(e).subscribe(function(n){var i,h;"E"===n.value.kind?(c=[],c.push(n),u=n.value.exception,h=!a):(c.push({value:n.value,timestamp:n.timestamp+t}),h=!o,o=!0),h&&(null!==u?r.onError(u):(i=new we,s.setDisposable(i),i.setDisposable(e.scheduleRecursiveWithRelative(t,function(t){var n,i,s,h;if(null===u){a=!0;do s=null,c.length>0&&0>=c[0].timestamp-e.now()&&(s=c.shift().value),null!==s&&s.accept(r);while(null!==s);h=!1,i=0,c.length>0?(h=!0,i=Math.max(0,c[0].timestamp-e.now())):o=!1,n=u,a=!1,null!==n?r.onError(n):h&&t(i)}}))))}),new pe(i,s)})},ze.throttle=function(t,e){return e||(e=Oe),this.throttleWithSelector(function(){return un(t,e)})},ze.timeInterval=function(t){var e=this;return t||(t=Oe),Ue(function(){var n=t.now();return e.select(function(e){var r=t.now(),i=r-n;return n=r,{value:e,interval:i}})})},ze.timestamp=function(t){return t||(t=Oe),this.select(function(e){return{value:e,timestamp:t.now()}})},ze.sample=function(t,e){return e||(e=Oe),"number"==typeof t?w(this,sn(t,e)):w(this,t)},ze.timeout=function(t,e,n){e||(e=Ke(Error("Timeout"))),n||(n=Oe);var r=this,i=t instanceof Date?"scheduleWithAbsolute":"scheduleWithRelative";return new fn(function(o){var s=0,u=new we,c=new ge,a=!1,h=new ge;c.setDisposable(u);var l=function(){var r=s;h.setDisposable(n[i](t,function(){s===r&&(q(e)&&(e=rn(e)),c.setDisposable(e.subscribe(o)))}))};return l(),u.setDisposable(r.subscribe(function(t){a||(s++,o.onNext(t),l())},function(t){a||(s++,o.onError(t))},function(){a||(s++,o.onCompleted())})),new pe(c,h)})},Be.generateWithRelativeTime=function(e,n,r,i,o,s){return s||(s=Oe),new fn(function(u){var c,a,h=!0,l=!1,f=e;return s.scheduleRecursiveWithRelative(0,function(e){l&&u.onNext(c);try{h?h=!1:f=r(f),l=n(f),l&&(c=i(f),a=o(f))}catch(s){return u.onError(s),t}l?e(a):u.onCompleted()})})},ze.delaySubscription=function(t,e){return e||(e=Oe),this.delayWithSelector(un(t,e),function(){return Qe()})},ze.delayWithSelector=function(e,n){var r,i,o=this;return"function"==typeof e?i=e:(r=e,i=n),new fn(function(e){var n=new pe,s=!1,u=function(){s&&0===n.length&&e.onCompleted()},c=new ge,a=function(){c.setDisposable(o.subscribe(function(r){var o;try{o=i(r)}catch(s){return e.onError(s),t}var c=new we;n.add(c),c.setDisposable(o.subscribe(function(){e.onNext(r),n.remove(c),u()},e.onError.bind(e),function(){e.onNext(r),n.remove(c),u()}))},e.onError.bind(e),function(){s=!0,c.dispose(),u()}))};return r?c.setDisposable(r.subscribe(function(){a()},e.onError.bind(e),function(){a()})):a(),new pe(c,n)})},ze.timeoutWithSelector=function(e,n,r){if(1===arguments.length){n=e;var e=$e()}r||(r=Ke(Error("Timeout")));var i=this;return new fn(function(o){var s=new ge,u=new ge,c=new we;s.setDisposable(c);var a=0,h=!1,l=function(t){var e=a,n=function(){return a===e},i=new we;u.setDisposable(i),i.setDisposable(t.subscribe(function(){n()&&s.setDisposable(r.subscribe(o)),i.dispose()},function(t){n()&&o.onError(t)},function(){n()&&s.setDisposable(r.subscribe(o))}))};l(e);var f=function(){var t=!h;return t&&a++,t};return c.setDisposable(i.subscribe(function(e){if(f()){o.onNext(e);var r;try{r=n(e)}catch(i){return o.onError(i),t}l(r)}},function(t){f()&&o.onError(t)},function(){f()&&o.onCompleted()})),new pe(s,u)})},ze.throttleWithSelector=function(e){var n=this;return new fn(function(r){var i,o=!1,s=new ge,u=0,c=n.subscribe(function(n){var c;try{c=e(n)}catch(a){return r.onError(a),t}o=!0,i=n,u++;var h=u,l=new we;s.setDisposable(l),l.setDisposable(c.subscribe(function(){o&&u===h&&r.onNext(i),o=!1,l.dispose()},r.onError.bind(r),function(){o&&u===h&&r.onNext(i),o=!1,l.dispose()}))},function(t){s.dispose(),r.onError(t),o=!1,u++},function(){s.dispose(),o&&r.onNext(i),r.onCompleted(),o=!1,u++});return new pe(c,s)})},ze.skipLastWithTime=function(t,e){e||(e=Oe);var n=this;return new fn(function(r){var i=[];return n.subscribe(function(n){var o=e.now();for(i.push({interval:o,value:n});i.length>0&&o-i[0].interval>=t;)r.onNext(i.shift().value)},r.onError.bind(r),function(){for(var n=e.now();i.length>0&&n-i[0].interval>=t;)r.onNext(i.shift().value);r.onCompleted()})})},ze.takeLastWithTime=function(t,e,n){return this.takeLastBufferWithTime(t,e).selectMany(function(t){return He(t,n)})},ze.takeLastBufferWithTime=function(t,e){var n=this;return e||(e=Oe),new fn(function(r){var i=[];return n.subscribe(function(n){var r=e.now();for(i.push({interval:r,value:n});i.length>0&&r-i[0].interval>=t;)i.shift()},r.onError.bind(r),function(){for(var n=e.now(),o=[];i.length>0;){var s=i.shift();t>=n-s.interval&&o.push(s.value)}r.onNext(o),r.onCompleted()})})},ze.takeWithTime=function(t,e){var n=this;return e||(e=Oe),new fn(function(r){var i=e.scheduleWithRelative(t,function(){r.onCompleted()});return new pe(i,n.subscribe(r))})},ze.skipWithTime=function(t,e){var n=this;return e||(e=Oe),new fn(function(r){var i=!1,o=e.scheduleWithRelative(t,function(){i=!0}),s=n.subscribe(function(t){i&&r.onNext(t)},r.onError.bind(r),r.onCompleted.bind(r));return new pe(o,s)})},ze.skipUntilWithTime=function(t,e){e||(e=Oe);var n=this,r=t instanceof Date?"scheduleWithAbsolute":"scheduleWithRelative";return new fn(function(i){var o=!1;return new pe(e[r](t,function(){o=!0}),n.subscribe(function(t){o&&i.onNext(t)},i.onError.bind(i),i.onCompleted.bind(i)))})},ze.takeUntilWithTime=function(t,e){e||(e=Oe);var n=this,r=t instanceof Date?"scheduleWithAbsolute":"scheduleWithRelative";return new fn(function(i){return new pe(e[r](t,function(){i.onCompleted()}),n.subscribe(i))})};var cn=function(t){function e(t){var e=this.source.publish(),n=e.subscribe(t),r=me,i=this.subject.distinctUntilChanged().subscribe(function(t){t?r=e.connect():(r.dispose(),r=me)});return new pe(n,r,i)}function n(n,r){this.source=n,this.subject=r||new bn,this.isPaused=!0,t.call(this,e)}return ce(n,t),n.prototype.pause=function(){this.isPaused!==!0&&(this.isPaused=!0,this.subject.onNext(!1))},n.prototype.resume=function(){this.isPaused!==!1&&(this.isPaused=!1,this.subject.onNext(!0))},n}(Be);ze.pausable=function(t){return new cn(this,t)};var an=function(t){function e(t){var e=[],n=!0,r=g(this.source,this.subject.distinctUntilChanged(),function(t,e){return{data:t,shouldFire:e}}).subscribe(function(r){if(r.shouldFire&&n&&t.onNext(r.data),r.shouldFire&&!n){for(;e.length>0;)t.onNext(e.shift());n=!0}else r.shouldFire||n?!r.shouldFire&&n&&(n=!1):e.push(r.data)},function(n){for(;e.length>0;)t.onNext(e.shift());t.onError(n)},function(){for(;e.length>0;)t.onNext(e.shift());t.onCompleted()});return this.subject.onNext(!1),r}function n(n,r){this.source=n,this.subject=r||new bn,this.isPaused=!0,t.call(this,e)}return ce(n,t),n.prototype.pause=function(){this.isPaused!==!0&&(this.isPaused=!0,this.subject.onNext(!1))},n.prototype.resume=function(){this.isPaused!==!1&&(this.isPaused=!1,this.subject.onNext(!0))},n}(Be);ze.pausableBuffered=function(t){return new an(this,t)},ze.controlled=function(t){return null==t&&(t=!0),new hn(this,t)};var hn=function(t){function e(t){return this.source.subscribe(t)}function n(n,r){t.call(this,e),this.subject=new ln(r),this.source=n.multicast(this.subject).refCount()}return ce(n,t),n.prototype.request=function(t){return null==t&&(t=-1),this.subject.request(t)},n}(Be),ln=A.ControlledSubject=function(t){function n(t){return this.subject.subscribe(t)}function r(e){null==e&&(e=!0),t.call(this,n),this.subject=new bn,this.enableQueue=e,this.queue=e?[]:null,this.requestedCount=0,this.requestedDisposable=me,this.error=null,this.hasFailed=!1,this.hasCompleted=!1,this.controlledDisposable=me}return ce(r,t),ae(r.prototype,Le,{onCompleted:function(){e.call(this),this.hasCompleted=!0,this.enableQueue&&0!==this.queue.length||this.subject.onCompleted()},onError:function(t){e.call(this),this.hasFailed=!0,this.error=t,this.enableQueue&&0!==this.queue.length||this.subject.onError(t)},onNext:function(t){e.call(this);var n=!1;0===this.requestedCount?this.enableQueue&&this.queue.push(t):(-1!==this.requestedCount&&0===this.requestedCount--&&this.disposeCurrentRequest(),n=!0),n&&this.subject.onNext(t)},_processRequest:function(t){if(this.enableQueue){for(;this.queue.length>=t&&t>0;)this.subject.onNext(this.queue.shift()),t--;return 0!==this.queue.length?{numberOfItems:t,returnValue:!0}:{numberOfItems:t,returnValue:!1}}return this.hasFailed?(this.subject.onError(this.error),this.controlledDisposable.dispose(),this.controlledDisposable=me):this.hasCompleted&&(this.subject.onCompleted(),this.controlledDisposable.dispose(),this.controlledDisposable=me),{numberOfItems:t,returnValue:!1}},request:function(t){e.call(this),this.disposeCurrentRequest();var n=this,r=this._processRequest(t);return t=r.numberOfItems,r.returnValue?me:(this.requestedCount=t,this.requestedDisposable=ve(function(){n.requestedCount=0}),this.requestedDisposable)},disposeCurrentRequest:function(){this.requestedDisposable.dispose(),this.requestedDisposable=me},dispose:function(){this.isDisposed=!0,this.error=null,this.subject.dispose(),this.requestedDisposable.dispose()}}),r}(Be);ze.pairwise=function(){var t=this;return new fn(function(e){var n,r=!1;return t.subscribe(function(t){r?e.onNext([n,t]):r=!0,n=t},e.onError.bind(e),e.onCompleted.bind(e))})},ze.partition=function(t,e){var n=this.publish().refCount();return[n.filter(t,e),n.filter(function(n,r,i){return!t.call(e,n,r,i)})]};var fn=A.AnonymousObservable=function(e){function n(e){return e===t?e=me:"function"==typeof e&&(e=ve(e)),e}function r(i){function o(t){var e=new pn(t);if(Ne.scheduleRequired())Ne.schedule(function(){try{e.setDisposable(n(i(e)))}catch(t){if(!e.fail(t))throw t}});else try{e.setDisposable(n(i(e)))}catch(r){if(!e.fail(r))throw r}return e}return this instanceof r?(e.call(this,o),t):new r(i)}return ce(r,e),r}(Be),pn=function(t){function e(e){t.call(this),this.observer=e,this.m=new we}ce(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.setDisposable=function(t){this.m.setDisposable(t)},n.getDisposable=function(){return this.m.getDisposable()},n.disposable=function(t){return arguments.length?this.getDisposable():setDisposable(t)},n.dispose=function(){t.prototype.dispose.call(this),this.m.dispose()},e}(Me),dn=function(t,e){this.subject=t,this.observer=e};dn.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 bn=A.Subject=function(t){function n(t){return e.call(this),this.isStopped?this.exception?(t.onError(this.exception),me):(t.onCompleted(),me):(this.observers.push(t),new dn(this,t))}function r(){t.call(this,n),this.isDisposed=!1,this.isStopped=!1,this.observers=[]}return ce(r,t),ae(r.prototype,Le,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(e.call(this),!this.isStopped){var t=this.observers.slice(0);this.isStopped=!0;for(var n=0,r=t.length;r>n;n++)t[n].onCompleted();this.observers=[]}},onError:function(t){if(e.call(this),!this.isStopped){var n=this.observers.slice(0);this.isStopped=!0,this.exception=t;for(var r=0,i=n.length;i>r;r++)n[r].onError(t);this.observers=[]}},onNext:function(t){if(e.call(this),!this.isStopped)for(var n=this.observers.slice(0),r=0,i=n.length;i>r;r++)n[r].onNext(t)},dispose:function(){this.isDisposed=!0,this.observers=null}}),r.create=function(t,e){return new mn(t,e)},r}(Be),vn=A.AsyncSubject=function(t){function n(t){if(e.call(this),!this.isStopped)return this.observers.push(t),new dn(this,t);var n=this.exception,r=this.hasValue,i=this.value;return n?t.onError(n):r?(t.onNext(i),t.onCompleted()):t.onCompleted(),me}function r(){t.call(this,n),this.isDisposed=!1,this.isStopped=!1,this.value=null,this.hasValue=!1,this.observers=[],this.exception=null}return ce(r,t),ae(r.prototype,Le,{hasObservers:function(){return e.call(this),this.observers.length>0},onCompleted:function(){var t,n,r;if(e.call(this),!this.isStopped){this.isStopped=!0;var i=this.observers.slice(0),o=this.value,s=this.hasValue;if(s)for(n=0,r=i.length;r>n;n++)t=i[n],t.onNext(o),t.onCompleted();else for(n=0,r=i.length;r>n;n++)i[n].onCompleted();this.observers=[]}},onError:function(t){if(e.call(this),!this.isStopped){var n=this.observers.slice(0);this.isStopped=!0,this.exception=t;for(var r=0,i=n.length;i>r;r++)n[r].onError(t);this.observers=[]}},onNext:function(t){e.call(this),this.isStopped||(this.value=t,this.hasValue=!0)},dispose:function(){this.isDisposed=!0,this.observers=null,this.exception=null,this.value=null}}),r}(Be),mn=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 ce(n,t),ae(n.prototype,Le,{onCompleted:function(){this.observer.onCompleted()},onError:function(t){this.observer.onError(t)},onNext:function(t){this.observer.onNext(t)}}),n}(Be),yn=A.BehaviorSubject=function(t){function n(t){if(e.call(this),!this.isStopped)return this.observers.push(t),t.onNext(this.value),new dn(this,t);var n=this.exception;return n?t.onError(n):t.onCompleted(),me}function r(e){t.call(this,n),this.value=e,this.observers=[],this.isDisposed=!1,this.isStopped=!1,this.exception=null}return ce(r,t),ae(r.prototype,Le,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(e.call(this),!this.isStopped){var t=this.observers.slice(0);this.isStopped=!0;for(var n=0,r=t.length;r>n;n++)t[n].onCompleted();this.observers=[]}},onError:function(t){if(e.call(this),!this.isStopped){var n=this.observers.slice(0);this.isStopped=!0,this.exception=t;for(var r=0,i=n.length;i>r;r++)n[r].onError(t);this.observers=[]}},onNext:function(t){if(e.call(this),!this.isStopped){this.value=t;for(var n=this.observers.slice(0),r=0,i=n.length;i>r;r++)n[r].onNext(t)}},dispose:function(){this.isDisposed=!0,this.observers=null,this.value=null,this.exception=null}}),r}(Be),wn=A.ReplaySubject=function(t){function n(t,e){this.subject=t,this.observer=e}function r(t){var r=new Fe(this.scheduler,t),i=new n(this,r);e.call(this),this._trim(this.scheduler.now()),this.observers.push(r);for(var o=this.q.length,s=0,u=this.q.length;u>s;s++)r.onNext(this.q[s].value);return this.hasError?(o++,r.onError(this.error)):this.isStopped&&(o++,r.onCompleted()),r.ensureActive(o),i}function i(e,n,i){this.bufferSize=null==e?Number.MAX_VALUE:e,this.windowSize=null==n?Number.MAX_VALUE:n,this.scheduler=i||Ne,this.q=[],this.observers=[],this.isStopped=!1,this.isDisposed=!1,this.hasError=!1,this.error=null,t.call(this,r)}return n.prototype.dispose=function(){if(this.observer.dispose(),!this.subject.isDisposed){var t=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(t,1)}},ce(i,t),ae(i.prototype,Le,{hasObservers:function(){return this.observers.length>0},_trim:function(t){for(;this.q.length>this.bufferSize;)this.q.shift();for(;this.q.length>0&&t-this.q[0].interval>this.windowSize;)this.q.shift()},onNext:function(t){var n;if(e.call(this),!this.isStopped){var r=this.scheduler.now();this.q.push({interval:r,value:t}),this._trim(r);for(var i=this.observers.slice(0),o=0,s=i.length;s>o;o++)n=i[o],n.onNext(t),n.ensureActive()}},onError:function(t){var n;if(e.call(this),!this.isStopped){this.isStopped=!0,this.error=t,this.hasError=!0;var r=this.scheduler.now();this._trim(r);for(var i=this.observers.slice(0),o=0,s=i.length;s>o;o++)n=i[o],n.onError(t),n.ensureActive();this.observers=[]}},onCompleted:function(){var t;if(e.call(this),!this.isStopped){this.isStopped=!0;var n=this.scheduler.now();this._trim(n);for(var r=this.observers.slice(0),i=0,o=r.length;o>i;i++)t=r[i],t.onCompleted(),t.ensureActive();this.observers=[]}},dispose:function(){this.isDisposed=!0,this.observers=null}}),i}(Be);"function"==typeof define&&"object"==typeof define.amd&&define.amd?(x.Rx=A,define(function(){return A})):C&&D?N?(D.exports=A).Rx=A:C.Rx=A:x.Rx=A}).call(this);