forked from Reactive-Extensions/RxJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrx.compat.min.js
2 lines (2 loc) · 39.2 KB
/
rx.compat.min.js
1
2
(function(t){function e(){}function n(t){return t}function r(t,e){return U(t,e)}function i(t,e){return t-e}function o(t){return""+t}function s(t){throw t}function u(){if(this.isDisposed)throw Error(R)}function c(t){return"function"!=typeof t.toString&&"string"==typeof(t+"")}function a(t){return t&&"object"==typeof t?z.call(t)==W:!1}function h(t){return"function"==typeof t}function f(t,e,n,r){var i;if(t===e)return 0!==t||1/t==1/e;var o=typeof t,s=typeof e;if(!(t!==t||t&&w[o]||e&&w[s]))return!1;if(null==t||null==e)return t===e;var u=z.call(t),l=z.call(e);if(u==W&&(u=P),l==W&&(l=P),u!=l)return!1;switch(u){case k:case q:return+t==+e;case T:return t!=+t?e!=+e:0==t?1/t==1/e:t==+e;case M:case L:return t==e+""}var p=u==j;if(!p){if(u!=P||!A&&(c(t)||c(e)))return!1;var d=!B&&a(t)?Object:t.constructor,b=!B&&a(e)?Object:e.constructor;if(d!=b&&!(h(d)&&d instanceof d&&h(b)&&b instanceof b))return!1}for(var v=n.length;v--;)if(n[v]==t)return r[v]==e;var m=0;if(i=!0,n.push(t),r.push(e),p){for(v=t.length,m=e.length,i=m==t.length;m--;){var y=e[m];if(!(i=f(t[m],y,n,r)))break}return i}for(var g in e)if(V.call(e,g))return m++,i=V.call(t,g)&&f(t[g],e[g],n,r);if(i)for(var g in t)if(V.call(t,g))return i=--m>-1;return n.pop(),r.pop(),i}function l(t,e){return 1===t.length&&Array.isArray(t[e])?t[e]:H.call(t)}function p(t,e){for(var n=Array(t),r=0;t>r;r++)n[r]=e();return n}function d(t,e){this.scheduler=t,this.disposable=e,this.isDisposed=!1}function b(e,n){return new Ge(function(r){var i=new se,o=new ue;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}i=new se,o.setDisposable(i),i.setDisposable(s.subscribe(r))},r.onCompleted.bind(r))),o})}function m(e,n){var r=this;return new Ge(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 y(t){return this.select(t).mergeObservable()}var w={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},g=w[typeof window]&&window||this,E=w[typeof exports]&&exports&&!exports.nodeType&&exports,x=w[typeof module]&&module&&!module.nodeType&&module,C=x&&x.exports===E&&E,D=w[typeof global]&&global;!D||D.global!==D&&D.window!==D||(g=D);var A,S={Internals:{}},_=function(){return Date.now?Date.now:function(){return+new Date}}(),N="Sequence contains no elements.",O="Argument out of range",R="Object has been disposed",W="[object Arguments]",j="[object Array]",k="[object Boolean]",q="[object Date]",I="[object Function]",T="[object Number]",P="[object Object]",M="[object RegExp]",L="[object String]",z=Object.prototype.toString,V=Object.prototype.hasOwnProperty,B=z.call(arguments)==W;try{A=!(z.call(document)==P&&!({toString:0}+""))}catch(F){A=!0}B||(a=function(t){return t&&"object"==typeof t?V.call(t,"callee"):!1}),h(/x/)&&(h=function(t){return"function"==typeof t&&z.call(t)==I});var U=S.Internals.isEqual=function(t,e){return f(t,e,[],[])},H=Array.prototype.slice;({}).hasOwnProperty;var $=this.inherits=S.Internals.inherits=function(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n},Q=S.Internals.addProperties=function(t){for(var e=H.call(arguments,1),n=0,r=e.length;r>n;n++){var i=e[n];for(var o in i)t[o]=i[o]}},G=S.Internals.addRef=function(t,e){return new Ge(function(n){return new te(e.getDisposable(),t.subscribe(n))})};Function.prototype.bind||(Function.prototype.bind=function(t){var e=this,n=H.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(H.call(arguments)));return Object(s)===s?s:o}return e.apply(t,n.concat(H.call(arguments)))};return r});var J=Object("a"),K="a"!=J[0]||!(0 in J);Array.prototype.every||(Array.prototype.every=function(t){var e=Object(this),n=K&&{}.toString.call(this)==L?this.split(""):e,r=n.length>>>0,i=arguments[1];if({}.toString.call(t)!=I)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=K&&{}.toString.call(this)==L?this.split(""):e,r=n.length>>>0,i=Array(r),o=arguments[1];if({}.toString.call(t)!=I)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.prototype.toString.call(t)==j}),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 X=function(t,e){this.id=t,this.value=e};X.prototype.compareTo=function(t){var e=this.value.compareTo(t.value);return 0===e&&(e=this.id-t.id),e};var Y=S.Internals.PriorityQueue=function(t){this.items=Array(t),this.length=0},Z=Y.prototype;Z.isHigherPriority=function(t,e){return 0>this.items[t].compareTo(this.items[e])},Z.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)}}},Z.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)}}},Z.peek=function(){return this.items[0].value},Z.removeAt=function(t){this.items[t]=this.items[--this.length],delete this.items[this.length],this.heapify()},Z.dequeue=function(){var t=this.peek();return this.removeAt(0),t},Z.enqueue=function(t){var e=this.length++;this.items[e]=new X(Y.count++,t),this.percolate(e)},Z.remove=function(t){for(var e=0;this.length>e;e++)if(this.items[e].value===t)return this.removeAt(e),!0;return!1},Y.count=0;var te=S.CompositeDisposable=function(){this.disposables=l(arguments,0),this.isDisposed=!1,this.length=this.disposables.length},ee=te.prototype;ee.add=function(t){this.isDisposed?t.dispose():(this.disposables.push(t),this.length++)},ee.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},ee.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()}},ee.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()},ee.contains=function(t){return-1!==this.disposables.indexOf(t)},ee.toArray=function(){return this.disposables.slice(0)};var ne=S.Disposable=function(t){this.isDisposed=!1,this.action=t||e};ne.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var re=ne.create=function(t){return new ne(t)},ie=ne.empty={dispose:e},oe=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}(),se=S.SingleAssignmentDisposable=function(t){function e(){t.call(this,!0)}return $(e,t),e}(oe),ue=S.SerialDisposable=function(t){function e(){t.call(this,!1)}return $(e,t),e}(oe),ce=S.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?ie:new t(this)},e}();d.prototype.dispose=function(){var t=this;this.scheduler.schedule(function(){t.isDisposed||(t.isDisposed=!0,t.disposable.dispose())})};var ae=S.Internals.ScheduledItem=function(t,e,n,r,o){this.scheduler=t,this.state=e,this.action=n,this.dueTime=r,this.comparer=o||i,this.disposable=new se};ae.prototype.invoke=function(){this.disposable.setDisposable(this.invokeCore())},ae.prototype.compareTo=function(t){return this.comparer(this.dueTime,t.dueTime)},ae.prototype.isCancelled=function(){return this.disposable.isDisposed},ae.prototype.invokeCore=function(){return this.action(this.scheduler,this.state)};var he=S.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 te,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),ie});r||(i.add(s),n=!0)})};return o(n),i}function n(t,e,n){var r=e.first,i=e.second,o=new te,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),ie});u||(o.add(c),i=!0)})};return s(r),o}function r(t,e){return e(),ie}var i=t.prototype;return i.catchException=i["catch"]=function(t){return new we(this,t)},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 re(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=_,t.normalize=function(t){return 0>t&&(t=0),t},t}(),fe=he.normalize;S.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 se;return this._cancel=e,e.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,t.bind(this))),e},e}();var le,pe=he.immediate=function(){function t(t,e){return e(this,t)}function e(t,e,n){for(var r=fe(r);r-this.now()>0;);return n(this,t)}function n(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new he(_,t,e,n)}(),de=he.currentThread=function(){function t(){i=new Y(4)}function e(t,e){return this.scheduleWithRelativeAndState(t,0,e)}function n(e,n,r){var o,s=this.now()+fe(n),u=new ae(this,e,r,s);if(i)i.enqueue(u);else{o=new t;try{i.enqueue(u),o.run()}catch(c){throw c}finally{o.dispose()}}return u.disposable}function r(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}var i;t.prototype.dispose=function(){i=null},t.prototype.run=function(){for(var t;i.length>0;)if(t=i.dequeue(),!t.isCancelled()){for(;t.dueTime-he.now()>0;);t.isCancelled()||t.invoke()}};var o=new he(_,e,n,r);return o.scheduleRequired=function(){return null===i},o.ensureTrampoline=function(t){return null===i?this.schedule(t):t()},o}(),be=RegExp("^"+(z+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),ve="function"==typeof(ve=D&&C&&D.setImmediate)&&!be.test(ve)&&ve,me="function"==typeof(me=D&&C&&D.clearImmediate)&&!be.test(me)&&me,ye=e;(function(){function t(){if(!g.postMessage||g.importScripts)return!1;var t=!1,e=g.onmessage;return g.onmessage=function(){t=!0},g.postMessage("","*"),g.onmessage=e,t}function e(t){if("string"==typeof t.data&&t.data.substring(0,n.length)===n){var e=t.data.substring(n.length),i=r[e];i(),delete r[e]}}if("function"==typeof ve)le=ve,ye=me;else if("undefined"!=typeof process&&"[object process]"==={}.toString.call(process))le=process.nextTick;else if(t()){var n="ms.rx.schedule"+Math.random(),r={},i=0;g.addEventListener?g.addEventListener("message",e,!1):g.attachEvent("onmessage",e,!1),le=function(t){var e=i++;r[e]=t,g.postMessage(n+e,"*")}}else if(g.MessageChannel){var o=new g.MessageChannel,s={},u=0;o.port1.onmessage=function(t){var e=t.data,n=s[e];n(),delete s[e]},le=function(t){var e=u++;s[e]=t,o.port2.postMessage(e)}}else"document"in g&&"onreadystatechange"in g.document.createElement("script")?le=function(t){var e=g.document.createElement("script");e.onreadystatechange=function(){t(),e.onreadystatechange=null,e.parentNode.removeChild(e),e=null},g.document.documentElement.appendChild(e)}:(le=function(t){return setTimeout(t,0)},ye=clearTimeout)})(),he.timeout=function(){function t(t,e){var n=this,r=new se,i=le(function(){r.isDisposed||r.setDisposable(e(n,t))});return new te(r,re(function(){ye(i)}))}function e(t,e,n){var r=this,i=he.normalize(e);if(0===i)return r.scheduleWithState(t,n);var o=new se,s=setTimeout(function(){o.isDisposed||o.setDisposable(n(r,t))},i);return new te(o,re(function(){clearTimeout(s)}))}function n(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new he(_,t,e,n)}();var we=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 $(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 ie}}},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 se;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}(he),ge=S.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=pe),new Ge(function(n){return t.schedule(function(){e._acceptObservable(n),"N"===e.kind&&n.onCompleted()})})},t}(),Ee=ge.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 ge("N",!0);return i.value=r,i._accept=t,i._acceptObservable=e,i.toString=n,i}}(),xe=ge.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 ge("E");return i.exception=r,i._accept=t,i._acceptObservable=e,i.toString=n,i}}(),Ce=ge.createOnCompleted=function(){function t(t,e,n){return n()}function e(t){return t.onCompleted()}function n(){return"OnCompleted()"}return function(){var r=new ge("C");return r._accept=t,r._acceptObservable=e,r.toString=n,r}}(),De=S.Internals.Enumerator=function(t,e){this.moveNext=t,this.getCurrent=e},Ae=De.create=function(t,e){var n=!1;return new De(function(){if(n)return!1;var e=t();return e||(n=!0),e},function(){return e()})},Se=S.Internals.Enumerable=function(t){this.getEnumerator=t};Se.prototype.concat=function(){var e=this;return new Ge(function(n){var r,i=e.getEnumerator(),o=new ue,s=pe.scheduleRecursive(function(e){var s,u;if(!r){try{u=i.moveNext(),u&&(s=i.getCurrent())}catch(c){return n.onError(c),t}if(!u)return n.onCompleted(),t;var a=new se;o.setDisposable(a),a.setDisposable(s.subscribe(n.onNext.bind(n),n.onError.bind(n),function(){e()}))}});return new te(o,s,re(function(){r=!0}))})},Se.prototype.catchException=function(){var e=this;return new Ge(function(n){var r,i,o=e.getEnumerator(),s=new ue,u=pe.scheduleRecursive(function(e){var u,c;if(!r){try{c=o.moveNext(),c&&(u=o.getCurrent())}catch(a){return n.onError(a),t}if(!c)return i?n.onError(i):n.onCompleted(),t;var h=new se;s.setDisposable(h),h.setDisposable(u.subscribe(n.onNext.bind(n),function(t){i=t,e()},n.onCompleted.bind(n)))}});return new te(s,u,re(function(){r=!0}))})};var _e=Se.repeat=function(t,e){return 1===arguments.length&&(e=-1),new Se(function(){var n,r=e;return Ae(function(){return 0===r?!1:(r>0&&r--,n=t,!0)},function(){return n})})},Ne=Se.forEach=function(t,e,r){return e||(e=n),new Se(function(){var n,i=-1;return Ae(function(){return++i<t.length?(n=e.call(r,t[i],i,t),!0):!1},function(){return n})})},Oe=S.Observer=function(){};Oe.prototype.toNotifier=function(){var t=this;return function(e){return e.accept(t)}},Oe.prototype.asObserver=function(){return new ke(this.onNext.bind(this),this.onError.bind(this),this.onCompleted.bind(this))},Oe.prototype.checked=function(){return new qe(this)};var Re=Oe.create=function(t,n,r){return t||(t=e),n||(n=s),r||(r=e),new ke(t,n,r)};Oe.fromNotifier=function(t){return new ke(function(e){return t(Ee(e))},function(e){return t(xe(e))},function(){return t(Ce())})},Oe.notifyOn=function(t){return new Te(t,this)};var We,je=S.Internals.AbstractObserver=function(t){function e(){this.isStopped=!1,t.call(this)}return $(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(t){return this.isStopped?!1:(this.isStopped=!0,this.error(t),!0)},e}(Oe),ke=S.AnonymousObserver=function(t){function e(e,n,r){t.call(this),this._onNext=e,this._onError=n,this._onCompleted=r}return $(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}(je),qe=function(t){function e(e){t.call(this),this._observer=e,this._state=0}$(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}(Oe),Ie=S.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 ue}return $(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}(je),Te=function(t){function e(){t.apply(this,arguments)}return $(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}(Ie),Pe=S.Observable=function(){function t(t){this._subscribe=t}return We=t.prototype,We.finalValue=function(){var t=this;return new Ge(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(N))})})},We.subscribe=We.forEach=function(t,e,n){var r;return r="object"==typeof t?t:Re(t,e,n),this._subscribe(r)},We.toArray=function(){function t(t,e){var n=t.slice(0);return n.push(e),n}return this.scan([],t).startWith([]).finalValue()},t}();We.observeOn=function(t){var e=this;return new Ge(function(n){return e.subscribe(new Te(t,n))})},We.subscribeOn=function(t){var e=this;return new Ge(function(n){var r=new se,i=new ue;return i.setDisposable(r),r.setDisposable(t.schedule(function(){i.setDisposable(new d(t,e.subscribe(n)))})),i})},Pe.create=Pe.createWithDisposable=function(t){return new Ge(t)},Pe.defer=function(t){return new Ge(function(e){var n;try{n=t()}catch(r){return Be(r).subscribe(e)}return n.subscribe(e)})};var Me=Pe.empty=function(t){return t||(t=pe),new Ge(function(e){return t.schedule(function(){e.onCompleted()})})},Le=Pe.fromArray=function(t,e){return e||(e=de),new Ge(function(n){var r=0;return e.scheduleRecursive(function(e){t.length>r?(n.onNext(t[r++]),e()):n.onCompleted()})})};Pe.generate=function(e,n,r,i,o){return o||(o=de),new Ge(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 ze=Pe.never=function(){return new Ge(function(){return ie})};Pe.range=function(t,e,n){return n||(n=de),new Ge(function(r){return n.scheduleRecursiveWithState(0,function(n,i){e>n?(r.onNext(t+n),i(n+1)):r.onCompleted()})})},Pe.repeat=function(t,e,n){return n||(n=de),null==e&&(e=-1),Ve(t,n).repeat(e)};var Ve=Pe["return"]=Pe.returnValue=function(t,e){return e||(e=pe),new Ge(function(n){return e.schedule(function(){n.onNext(t),n.onCompleted()})})},Be=Pe["throw"]=Pe.throwException=function(t,e){return e||(e=pe),new Ge(function(n){return e.schedule(function(){n.onError(t)})})};Pe.using=function(t,e){return new Ge(function(n){var r,i,o=ie;try{r=t(),r&&(o=r),i=e(r)}catch(s){return new te(Be(s).subscribe(n),o)}return new te(i.subscribe(n),o)})},We.amb=function(t){var e=this;return new Ge(function(n){function r(){o||(o=s,a.dispose())}function i(){o||(o=u,c.dispose())}var o,s="L",u="R",c=new se,a=new se;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 te(c,a)})},Pe.amb=function(){function t(t,e){return t.amb(e)}for(var e=ze(),n=l(arguments,0),r=0,i=n.length;i>r;r++)e=t(e,n[r]);return e},We["catch"]=We.catchException=function(t){return"function"==typeof t?b(this,t):Fe([this,t])};var Fe=Pe.catchException=Pe["catch"]=function(){var t=l(arguments,0);return Ne(t).catchException()};We.combineLatest=function(){var t=H.call(arguments);return Array.isArray(t[0])?t[0].unshift(this):t.unshift(this),Ue.apply(this,t)};var Ue=Pe.combineLatest=function(){var e=H.call(arguments),r=e.pop();return Array.isArray(e[0])&&(e=e[0]),new Ge(function(i){function o(e){var o;if(a[e]=!0,h||(h=a.every(n))){try{o=r.apply(null,l)}catch(s){return i.onError(s),t}i.onNext(o)}else f.filter(function(t,n){return n!==e}).every(n)&&i.onCompleted()}function s(t){f[t]=!0,f.every(n)&&i.onCompleted()}for(var u=function(){return!1},c=e.length,a=p(c,u),h=!1,f=p(c,u),l=Array(c),d=Array(c),b=0;c>b;b++)(function(t){d[t]=new se,d[t].setDisposable(e[t].subscribe(function(e){l[t]=e,o(t)},i.onError.bind(i),function(){s(t)}))})(b);return new te(d)})};We.concat=function(){var t=H.call(arguments,0);return t.unshift(this),He.apply(this,t)};var He=Pe.concat=function(){var t=l(arguments,0);return Ne(t).concat()};We.concatObservable=We.concatAll=function(){return this.merge(1)},We.merge=function(t){if("number"!=typeof t)return $e(this,t);var e=this;return new Ge(function(n){var r=0,i=new te,o=!1,s=[],u=function(t){var e=new se;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 $e=Pe.merge=function(){var t,e;return arguments[0]?arguments[0].now?(t=arguments[0],e=H.call(arguments,1)):(t=pe,e=H.call(arguments,0)):(t=pe,e=H.call(arguments,1)),Array.isArray(e[0])&&(e=e[0]),Le(e,t).mergeObservable()};We.mergeObservable=We.mergeAll=function(){var t=this;return new Ge(function(e){var n=new te,r=!1,i=new se;return n.add(i),i.setDisposable(t.subscribe(function(t){var i=new se;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})},We.onErrorResumeNext=function(t){if(!t)throw Error("Second observable is required");return Qe([this,t])};var Qe=Pe.onErrorResumeNext=function(){var t=l(arguments,0);return new Ge(function(e){var n=0,r=new ue,i=pe.scheduleRecursive(function(i){var o,s;t.length>n?(o=t[n++],s=new se,r.setDisposable(s),s.setDisposable(o.subscribe(e.onNext.bind(e),function(){i()},function(){i()}))):e.onCompleted()});return new te(r,i)})};We.skipUntil=function(t){var e=this;return new Ge(function(n){var r=!1,i=new te(e.subscribe(function(t){r&&n.onNext(t)},n.onError.bind(n),function(){r&&n.onCompleted()})),o=new se;return i.add(o),o.setDisposable(t.subscribe(function(){r=!0,o.dispose()},n.onError.bind(n),function(){o.dispose()})),i})},We["switch"]=We.switchLatest=function(){var t=this;return new Ge(function(e){var n=!1,r=new ue,i=!1,o=0,s=t.subscribe(function(t){var s=new se,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 te(s,r)})},We.takeUntil=function(t){var n=this;return new Ge(function(r){return new te(n.subscribe(r),t.subscribe(r.onCompleted.bind(r),r.onError.bind(r),e))})},We.zip=function(){if(Array.isArray(arguments[0]))return m.apply(this,arguments);var e=this,r=H.call(arguments),i=r.pop();return r.unshift(e),new Ge(function(o){function s(t){a[t]=!0,a.every(function(t){return t})&&o.onCompleted()}for(var u=r.length,c=p(u,function(){return[]}),a=p(u,function(){return!1}),h=function(r){var s,u;if(c.every(function(t){return t.length>0})){try{u=c.map(function(t){return t.shift()}),s=i.apply(e,u)}catch(h){return o.onError(h),t}o.onNext(s)}else a.filter(function(t,e){return e!==r}).every(n)&&o.onCompleted()},f=Array(u),l=0;u>l;l++)(function(t){f[t]=new se,f[t].setDisposable(r[t].subscribe(function(e){c[t].push(e),h(t)},o.onError.bind(o),function(){s(t)}))})(l);return new te(f)})},Pe.zip=function(){var t=H.call(arguments,0),e=t.shift();return e.zip.apply(e,t)},Pe.zipArray=function(){var e=l(arguments,0);return new Ge(function(r){function i(e){if(u.every(function(t){return t.length>0})){var i=u.map(function(t){return t.shift()});r.onNext(i)}else if(c.filter(function(t,n){return n!==e}).every(n))return r.onCompleted(),t}function o(e){return c[e]=!0,c.every(n)?(r.onCompleted(),t):t}for(var s=e.length,u=p(s,function(){return[]}),c=p(s,function(){return!1}),a=Array(s),h=0;s>h;h++)(function(t){a[t]=new se,a[t].setDisposable(e[t].subscribe(function(e){u[t].push(e),i(t)},r.onError.bind(r),function(){o(t)}))})(h);var f=new te(a);return f.add(re(function(){for(var t=0,e=u.length;e>t;t++)u[t]=[]})),f})},We.asObservable=function(){var t=this;return new Ge(function(e){return t.subscribe(e)})},We.bufferWithCount=function(t,e){return 1===arguments.length&&(e=t),this.windowWithCount(t,e).selectMany(function(t){return t.toArray()}).where(function(t){return t.length>0})},We.dematerialize=function(){var t=this;return new Ge(function(e){return t.subscribe(function(t){return t.accept(e)},e.onError.bind(e),e.onCompleted.bind(e))})},We.distinctUntilChanged=function(e,i){var o=this;return e||(e=n),i||(i=r),new Ge(function(n){var r,s=!1;return o.subscribe(function(o){var u,c=!1;try{u=e(o)}catch(a){return n.onError(a),t}if(s)try{c=i(r,u)}catch(a){return n.onError(a),t}s&&c||(s=!0,r=u,n.onNext(o))},n.onError.bind(n),n.onCompleted.bind(n))})},We["do"]=We.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 Ge(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()})})},We["finally"]=We.finallyAction=function(t){var e=this;return new Ge(function(n){var r=e.subscribe(n);return re(function(){try{r.dispose()}catch(e){throw e}finally{t()}})})},We.ignoreElements=function(){var t=this;return new Ge(function(n){return t.subscribe(e,n.onError.bind(n),n.onCompleted.bind(n))})},We.materialize=function(){var t=this;return new Ge(function(e){return t.subscribe(function(t){e.onNext(Ee(t))},function(t){e.onNext(xe(t)),e.onCompleted()},function(){e.onNext(Ce()),e.onCompleted()})})},We.repeat=function(t){return _e(this,t).concat()},We.retry=function(t){return _e(this,t).catchException()},We.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 Ge(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()})})},We.skipLast=function(t){var e=this;return new Ge(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))})},We.startWith=function(){var t,e,n=0;return arguments.length&&"now"in Object(arguments[0])?(e=arguments[0],n=1):e=pe,t=H.call(arguments,n),Ne([Le(t,e),this]).concat()
},We.takeLast=function(t,e){return this.takeLastBuffer(t).selectMany(function(t){return Le(t,e)})},We.takeLastBuffer=function(t){var e=this;return new Ge(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()})})},We.windowWithCount=function(t,e){var n=this;if(0>=t)throw Error(O);if(1===arguments.length&&(e=t),0>=e)throw Error(O);return new Ge(function(r){var i=new se,o=new ce(i),s=0,u=[],c=function(){var t=new Ye;u.push(t),r.onNext(G(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})},We.defaultIfEmpty=function(e){var n=this;return e===t&&(e=null),new Ge(function(t){var r=!1;return n.subscribe(function(e){r=!0,t.onNext(e)},t.onError.bind(t),function(){r||t.onNext(e),t.onCompleted()})})},We.distinct=function(e,r){var i=this;return e||(e=n),r||(r=o),new Ge(function(n){var o={};return i.subscribe(function(i){var s,u,c,a=!1;try{s=e(i),u=r(s)}catch(h){return n.onError(h),t}for(c in o)if(u===c){a=!0;break}a||(o[u]=null,n.onNext(i))},n.onError.bind(n),n.onCompleted.bind(n))})},We.groupBy=function(t,e,n){return this.groupByUntil(t,e,function(){return ze()},n)},We.groupByUntil=function(r,i,s,u){var c=this;return i||(i=n),u||(u=o),new Ge(function(n){var o={},a=new te,h=new ce(a);return a.add(c.subscribe(function(c){var f,l,p,d,b,v,m,y,w,g;try{v=r(c),m=u(v)}catch(E){for(g in o)o[g].onError(E);return n.onError(E),t}d=!1;try{w=o[m],w||(w=new Ye,o[m]=w,d=!0)}catch(E){for(g in o)o[g].onError(E);return n.onError(E),t}if(d){b=new Ke(v,w,h),l=new Ke(v,w);try{f=s(l)}catch(E){for(g in o)o[g].onError(E);return n.onError(E),t}n.onNext(b),y=new se,a.add(y);var x=function(){m in o&&(delete o[m],w.onCompleted()),a.remove(y)};y.setDisposable(f.take(1).subscribe(e,function(t){for(g in o)o[g].onError(t);n.onError(t)},function(){x()}))}try{p=i(c)}catch(E){for(g in o)o[g].onError(E);return n.onError(E),t}w.onNext(p)},function(t){for(var e in o)o[e].onError(t);n.onError(t)},function(){for(var t in o)o[t].onCompleted();n.onCompleted()})),h})},We.select=We.map=function(e,n){var r=this;return new Ge(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))})},We.pluck=function(t){return this.select(function(e){return e[t]})},We.selectMany=We.flatMap=function(t,e){return e?this.selectMany(function(n){return t(n).select(function(t){return e(n,t)})}):"function"==typeof t?y.call(this,t):y.call(this,function(){return t})},We.selectSwitch=We.flatMapLatest=function(t,e){return this.select(t,e).switchLatest()},We.skip=function(t){if(0>t)throw Error(O);var e=this;return new Ge(function(n){var r=t;return e.subscribe(function(t){0>=r?n.onNext(t):r--},n.onError.bind(n),n.onCompleted.bind(n))})},We.skipWhile=function(e,n){var r=this;return new Ge(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))})},We.take=function(t,e){if(0>t)throw Error(O);if(0===t)return Me(e);var n=this;return new Ge(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))})},We.takeWhile=function(e,n){var r=this;return new Ge(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))})},We.where=We.filter=function(e,n){var r=this;return new Ge(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))})};var Ge=S.Internals.AnonymousObservable=function(e){function n(e){return e===t?e=ie:"function"==typeof e&&(e=re(e)),e}function r(i){function o(t){var e=new Je(t);if(de.scheduleRequired())de.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 $(r,e),r}(Pe),Je=function(t){function e(e){t.call(this),this.observer=e,this.m=new se}$(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}(je),Ke=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 Ge(function(t){return new te(i.getDisposable(),r.subscribe(t))}):r}return $(n,t),n}(Pe),Xe=function(t,e){this.subject=t,this.observer=e};Xe.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 Ye=S.Subject=function(t){function e(t){return u.call(this),this.isStopped?this.exception?(t.onError(this.exception),ie):(t.onCompleted(),ie):(this.observers.push(t),new Xe(this,t))}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.observers=[]}return $(n,t),Q(n.prototype,Oe,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(u.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(u.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(u.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 Ze(t,e)},n}(Pe);S.AsyncSubject=function(t){function e(t){if(u.call(this),!this.isStopped)return this.observers.push(t),new Xe(this,t);var e=this.exception;return hv=this.hasValue,v=this.value,e?t.onError(e):hv?(t.onNext(v),t.onCompleted()):t.onCompleted(),ie}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.value=null,this.hasValue=!1,this.observers=[],this.exception=null}return $(n,t),Q(n.prototype,Oe,{hasObservers:function(){return u.call(this),this.observers.length>0},onCompleted:function(){var t,e,n;if(u.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(u.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){u.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}(Pe);var Ze=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 $(n,t),Q(n.prototype,Oe,{onCompleted:function(){this.observer.onCompleted()},onError:function(t){this.observer.onError(t)},onNext:function(t){this.observer.onNext(t)}}),n}(Pe);"function"==typeof define&&"object"==typeof define.amd&&define.amd?(g.Rx=S,define(function(){return S})):E&&x?C?(x.exports=S).Rx=S:E.Rx=S:g.Rx=S}).call(this);