forked from Reactive-Extensions/RxJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrx.lite.compat.min.js
2 lines (2 loc) · 45.7 KB
/
rx.lite.compat.min.js
1
2
(function(t){function e(){}function n(t){return t}function r(t,e){return Q(t,e)}function i(t,e){return t-e}function o(t){throw t}function s(){if(this.isDisposed)throw Error(T)}function u(t){return"function"!=typeof t.toString&&"string"==typeof(t+"")}function c(t){return t&&"object"==typeof t?H.call(t)==q:!1}function a(t){return"function"==typeof t}function h(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&&C[o]||e&&C[s]))return!1;if(null==t||null==e)return t===e;var l=H.call(t),f=H.call(e);if(l==q&&(l=z),f==q&&(f=z),l!=f)return!1;switch(l){case P:case L:return+t==+e;case V:return t!=+t?e!=+e:0==t?1/t==1/e:t==+e;case B:case U:return t==e+""}var p=l==I;if(!p){if(l!=z||!R&&(u(t)||u(e)))return!1;var d=!$&&c(t)?Object:t.constructor,b=!$&&c(e)?Object:e.constructor;if(d!=b&&!(a(d)&&d instanceof d&&a(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=h(t[m],y,n,r)))break}return i}for(var w in e)if(F.call(e,w))return m++,i=F.call(t,w)&&h(t[w],e[w],n,r);if(i)for(var w in t)if(F.call(t,w))return i=--m>-1;return n.pop(),r.pop(),i}function l(t,e){return 1===t.length&&Array.isArray(t[e])?t[e]:K.call(t)}function f(t,e){for(var n=Array(t),r=0;t>r;r++)n[r]=e();return n}function p(e,n){return new Ge(function(r){var i=new ae,o=new he;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 ae,o.setDisposable(i),i.setDisposable(s.subscribe(r))},r.onCompleted.bind(r))),o})}function d(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 b(t){return this.select(t).mergeObservable()}function m(t){var e=function(){this.cancelBubble=!0},n=function(){if(this.bubbledKeyCode=this.keyCode,this.ctrlKey)try{this.keyCode=0}catch(t){}this.defaultPrevented=!0,this.returnValue=!1,this.modified=!0};if(t||(t=window.event),!t.target)switch(t.target=t.target||t.srcElement,"mouseover"==t.type&&(t.relatedTarget=t.fromElement),"mouseout"==t.type&&(t.relatedTarget=t.toElement),t.stopPropagation||(t.stopPropagation=e,t.preventDefault=n),t.type){case"keypress":var r="charCode"in t?t.charCode:t.keyCode;10==r?(r=0,t.keyCode=13):13==r||27==r?r=0:3==r&&(r=99),t.charCode=r,t.keyChar=t.charCode?String.fromCharCode(t.charCode):""}return t}function y(t,e,n){if(t.addListener)return t.addListener(e,n),se(function(){t.removeListener(e,n)});if(t.addEventListener)return t.addEventListener(e,n,!1),se(function(){t.removeEventListener(e,n,!1)});if(t.attachEvent){var r=function(t){n(m(t))};return t.attachEvent("on"+e,r),se(function(){t.detachEvent("on"+e,r)})}return t["on"+e]=n,se(function(){t["on"+e]=null})}function w(t,e,n){var r=new re;if(t&&t.length)for(var i=0,o=t.length;o>i;i++)r.add(w(t[i],e,n));else t&&r.add(y(t,e,n));return r}function g(t,e){var n=pe(t);return new Ge(function(t){return e.scheduleWithRelative(n,function(){t.onNext(0),t.onCompleted()})})}function x(t,e,n){return t===e?new Ge(function(t){return n.schedulePeriodicWithState(0,e,function(e){return t.onNext(e),e+1})}):Le(function(){return observableTimerDateAndPeriod(n.now()+t,e,n)})}function E(t,e){return new Ge(function(n){function r(){s&&(s=!1,n.onNext(o)),i&&n.onCompleted()}var i,o,s;return new re(t.subscribe(function(t){s=!0,o=t},n.onError.bind(n),function(){i=!0}),e.subscribe(r,n.onError.bind(n),r))})}var C={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},D=C[typeof window]&&window||this,S=C[typeof exports]&&exports&&!exports.nodeType&&exports,N=C[typeof module]&&module&&!module.nodeType&&module,A=N&&N.exports===S&&S,O=C[typeof global]&&global;!O||O.global!==O&&O.window!==O||(D=O);var R,_={Internals:{}},W=function(){return Date.now?Date.now:function(){return+new Date}}(),k="Sequence contains no elements.",j="Argument out of range",T="Object has been disposed",q="[object Arguments]",I="[object Array]",P="[object Boolean]",L="[object Date]",M="[object Function]",V="[object Number]",z="[object Object]",B="[object RegExp]",U="[object String]",H=Object.prototype.toString,F=Object.prototype.hasOwnProperty,$=H.call(arguments)==q;try{R=!(H.call(document)==z&&!({toString:0}+""))}catch(X){R=!0}$||(c=function(t){return t&&"object"==typeof t?F.call(t,"callee"):!1}),a(/x/)&&(a=function(t){return"function"==typeof t&&H.call(t)==M});var Q=_.Internals.isEqual=function(t,e){return h(t,e,[],[])},K=Array.prototype.slice;({}).hasOwnProperty;var J=this.inherits=_.Internals.inherits=function(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n},G=_.Internals.addProperties=function(t){for(var e=K.call(arguments,1),n=0,r=e.length;r>n;n++){var i=e[n];for(var o in i)t[o]=i[o]}};_.Internals.addRef=function(t,e){return new Ge(function(n){return new re(e.getDisposable(),t.subscribe(n))})},Function.prototype.bind||(Function.prototype.bind=function(t){var e=this,n=K.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(K.call(arguments)));return Object(s)===s?s:o}return e.apply(t,n.concat(K.call(arguments)))};return r});var Y=Object("a"),Z="a"!=Y[0]||!(0 in Y);Array.prototype.every||(Array.prototype.every=function(t){var e=Object(this),n=Z&&{}.toString.call(this)==U?this.split(""):e,r=n.length>>>0,i=arguments[1];if({}.toString.call(t)!=M)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=Z&&{}.toString.call(this)==U?this.split(""):e,r=n.length>>>0,i=Array(r),o=arguments[1];if({}.toString.call(t)!=M)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)==I}),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 te=function(t,e){this.id=t,this.value=e};te.prototype.compareTo=function(t){var e=this.value.compareTo(t.value);return 0===e&&(e=this.id-t.id),e};var ee=_.Internals.PriorityQueue=function(t){this.items=Array(t),this.length=0},ne=ee.prototype;ne.isHigherPriority=function(t,e){return 0>this.items[t].compareTo(this.items[e])},ne.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)}}},ne.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)}}},ne.peek=function(){return this.items[0].value},ne.removeAt=function(t){this.items[t]=this.items[--this.length],delete this.items[this.length],this.heapify()},ne.dequeue=function(){var t=this.peek();return this.removeAt(0),t},ne.enqueue=function(t){var e=this.length++;this.items[e]=new te(ee.count++,t),this.percolate(e)},ne.remove=function(t){for(var e=0;this.length>e;e++)if(this.items[e].value===t)return this.removeAt(e),!0;return!1},ee.count=0;var re=_.CompositeDisposable=function(){this.disposables=l(arguments,0),this.isDisposed=!1,this.length=this.disposables.length},ie=re.prototype;ie.add=function(t){this.isDisposed?t.dispose():(this.disposables.push(t),this.length++)},ie.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},ie.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()}},ie.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()},ie.contains=function(t){return-1!==this.disposables.indexOf(t)},ie.toArray=function(){return this.disposables.slice(0)};var oe=_.Disposable=function(t){this.isDisposed=!1,this.action=t||e};oe.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var se=oe.create=function(t){return new oe(t)},ue=oe.empty={dispose:e},ce=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}(),ae=_.SingleAssignmentDisposable=function(t){function e(){t.call(this,!0)}return J(e,t),e}(ce),he=_.SerialDisposable=function(t){function e(){t.call(this,!1)}return J(e,t),e}(ce);_.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?ue:new t(this)},e}();var le=_.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 ae};le.prototype.invoke=function(){this.disposable.setDisposable(this.invokeCore())},le.prototype.compareTo=function(t){return this.comparer(this.dueTime,t.dueTime)},le.prototype.isCancelled=function(){return this.disposable.isDisposed},le.prototype.invokeCore=function(){return this.action(this.scheduler,this.state)};var fe=_.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 re,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),ue});r||(i.add(s),n=!0)})};return o(n),i}function n(t,e,n){var r=e.first,i=e.second,o=new re,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),ue});u||(o.add(c),i=!0)})};return s(r),o}function r(t,e){return e(),ue}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 se(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=W,t.normalize=function(t){return 0>t&&(t=0),t},t}(),pe=fe.normalize,de=fe.immediate=function(){function t(t,e){return e(this,t)}function e(t,e,n){for(var r=pe(r);r-this.now()>0;);return n(this,t)}function n(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new fe(W,t,e,n)}(),be=fe.currentThread=function(){function t(){i=new ee(4)}function e(t,e){return this.scheduleWithRelativeAndState(t,0,e)}function n(e,n,r){var o,s=this.now()+pe(n),u=new le(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-fe.now()>0;);t.isCancelled()||t.invoke()}};var o=new fe(W,e,n,r);return o.scheduleRequired=function(){return null===i},o.ensureTrampoline=function(t){return null===i?this.schedule(t):t()},o}();_.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 ae;return this._cancel=e,e.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,t.bind(this))),e},e}();var ve,me=RegExp("^"+(H+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),ye="function"==typeof(ye=O&&A&&O.setImmediate)&&!me.test(ye)&&ye,we="function"==typeof(we=O&&A&&O.clearImmediate)&&!me.test(we)&&we,ge=e;(function(){function t(){if(!D.postMessage||D.importScripts)return!1;var t=!1,e=D.onmessage;return D.onmessage=function(){t=!0},D.postMessage("","*"),D.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 ye)ve=ye,ge=we;else if("undefined"!=typeof process&&"[object process]"==={}.toString.call(process))ve=process.nextTick;else if(t()){var n="ms.rx.schedule"+Math.random(),r={},i=0;D.addEventListener?D.addEventListener("message",e,!1):D.attachEvent("onmessage",e,!1),ve=function(t){var e=i++;r[e]=t,D.postMessage(n+e,"*")}}else if(D.MessageChannel){var o=new D.MessageChannel,s={},u=0;o.port1.onmessage=function(t){var e=t.data,n=s[e];n(),delete s[e]},ve=function(t){var e=u++;s[e]=t,o.port2.postMessage(e)}}else"document"in D&&"onreadystatechange"in D.document.createElement("script")?ve=function(t){var e=D.document.createElement("script");e.onreadystatechange=function(){t(),e.onreadystatechange=null,e.parentNode.removeChild(e),e=null},D.document.documentElement.appendChild(e)}:(ve=function(t){return setTimeout(t,0)},ge=clearTimeout)})();var xe=fe.timeout=function(){function t(t,e){var n=this,r=new ae,i=ve(function(){r.isDisposed||r.setDisposable(e(n,t))});return new re(r,se(function(){ge(i)}))}function e(t,e,n){var r=this,i=fe.normalize(e);if(0===i)return r.scheduleWithState(t,n);var o=new ae,s=setTimeout(function(){o.isDisposed||o.setDisposable(n(r,t))},i);return new re(o,se(function(){clearTimeout(s)}))}function n(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new fe(W,t,e,n)}(),Ee=_.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 Ge(function(n){return t.schedule(function(){e._acceptObservable(n),"N"===e.kind&&n.onCompleted()})})},t}(),Ce=Ee.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 Ee("N",!0);return i.value=r,i._accept=t,i._acceptObservable=e,i.toString=n,i}}(),De=Ee.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 Ee("E");return i.exception=r,i._accept=t,i._acceptObservable=e,i.toString=n,i}}(),Se=Ee.createOnCompleted=function(){function t(t,e,n){return n()}function e(t){return t.onCompleted()}function n(){return"OnCompleted()"}return function(){var r=new Ee("C");return r._accept=t,r._acceptObservable=e,r.toString=n,r}}(),Ne=_.Internals.Enumerator=function(t,e){this.moveNext=t,this.getCurrent=e},Ae=Ne.create=function(t,e){var n=!1;return new Ne(function(){if(n)return!1;var e=t();return e||(n=!0),e},function(){return e()})},Oe=_.Internals.Enumerable=function(t){this.getEnumerator=t};Oe.prototype.concat=function(){var e=this;return new Ge(function(n){var r,i=e.getEnumerator(),o=new he,s=de.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 ae;o.setDisposable(a),a.setDisposable(s.subscribe(n.onNext.bind(n),n.onError.bind(n),function(){e()}))}});return new re(o,s,se(function(){r=!0}))})},Oe.prototype.catchException=function(){var e=this;return new Ge(function(n){var r,i,o=e.getEnumerator(),s=new he,u=de.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 ae;s.setDisposable(h),h.setDisposable(u.subscribe(n.onNext.bind(n),function(t){i=t,e()},n.onCompleted.bind(n)))}});return new re(s,u,se(function(){r=!0}))})};var Re=Oe.repeat=function(t,e){return 1===arguments.length&&(e=-1),new Oe(function(){var n,r=e;return Ae(function(){return 0===r?!1:(r>0&&r--,n=t,!0)},function(){return n})})},_e=Oe.forEach=function(t,e,r){return e||(e=n),new Oe(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})})},We=_.Observer=function(){};We.prototype.toNotifier=function(){var t=this;return function(e){return e.accept(t)}},We.prototype.asObserver=function(){return new qe(this.onNext.bind(this),this.onError.bind(this),this.onCompleted.bind(this))};var ke=We.create=function(t,n,r){return t||(t=e),n||(n=o),r||(r=e),new qe(t,n,r)};We.fromNotifier=function(t){return new qe(function(e){return t(Ce(e))},function(e){return t(De(e))},function(){return t(Se())})};var je,Te=_.Internals.AbstractObserver=function(t){function e(){this.isStopped=!1,t.call(this)}return J(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}(We),qe=_.AnonymousObserver=function(t){function e(e,n,r){t.call(this),this._onNext=e,this._onError=n,this._onCompleted=r}return J(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}(Te),Ie=_.Observable=function(){function t(t){this._subscribe=t}return je=t.prototype,je.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(k))})})},je.subscribe=je.forEach=function(t,e,n){var r;return r="object"==typeof t?t:ke(t,e,n),this._subscribe(r)},je.toArray=function(){function t(t,e){var n=t.slice(0);return n.push(e),n}return this.scan([],t).startWith([]).finalValue()},t}(),Pe=_.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 he}return J(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}(Te);Ie.create=Ie.createWithDisposable=function(t){return new Ge(t)};var Le=Ie.defer=function(t){return new Ge(function(e){var n;try{n=t()}catch(r){return Ue(r).subscribe(e)}return n.subscribe(e)})},Me=Ie.empty=function(t){return t||(t=de),new Ge(function(e){return t.schedule(function(){e.onCompleted()})})},Ve=Ie.fromArray=function(t,e){return e||(e=be),new Ge(function(n){var r=0;return e.scheduleRecursive(function(e){t.length>r?(n.onNext(t[r++]),e()):n.onCompleted()})})};Ie.generate=function(e,n,r,i,o){return o||(o=be),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=Ie.never=function(){return new Ge(function(){return ue})};Ie.range=function(t,e,n){return n||(n=be),new Ge(function(r){return n.scheduleRecursiveWithState(0,function(n,i){e>n?(r.onNext(t+n),i(n+1)):r.onCompleted()})})},Ie.repeat=function(t,e,n){return n||(n=be),null==e&&(e=-1),Be(t,n).repeat(e)};var Be=Ie["return"]=Ie.returnValue=function(t,e){return e||(e=de),new Ge(function(n){return e.schedule(function(){n.onNext(t),n.onCompleted()})})},Ue=Ie["throw"]=Ie.throwException=function(t,e){return e||(e=de),new Ge(function(n){return e.schedule(function(){n.onError(t)})})};je["catch"]=je.catchException=function(t){return"function"==typeof t?p(this,t):He([this,t])};var He=Ie.catchException=Ie["catch"]=function(){var t=l(arguments,0);return _e(t).catchException()};je.combineLatest=function(){var t=K.call(arguments);return Array.isArray(t[0])?t[0].unshift(this):t.unshift(this),Fe.apply(this,t)};var Fe=Ie.combineLatest=function(){var e=K.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,p)}catch(s){return i.onError(s),t}i.onNext(o)}else l.filter(function(t,n){return n!==e}).every(n)&&i.onCompleted()}function s(t){l[t]=!0,l.every(n)&&i.onCompleted()}for(var u=function(){return!1},c=e.length,a=f(c,u),h=!1,l=f(c,u),p=Array(c),d=Array(c),b=0;c>b;b++)(function(t){d[t]=new ae,d[t].setDisposable(e[t].subscribe(function(e){p[t]=e,o(t)},i.onError.bind(i),function(){s(t)}))})(b);return new re(d)})};je.concat=function(){var t=K.call(arguments,0);return t.unshift(this),$e.apply(this,t)};var $e=Ie.concat=function(){var t=l(arguments,0);return _e(t).concat()};je.concatObservable=je.concatAll=function(){return this.merge(1)},je.merge=function(t){if("number"!=typeof t)return Xe(this,t);var e=this;return new Ge(function(n){var r=0,i=new re,o=!1,s=[],u=function(t){var e=new ae;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 Xe=Ie.merge=function(){var t,e;return arguments[0]?arguments[0].now?(t=arguments[0],e=K.call(arguments,1)):(t=de,e=K.call(arguments,0)):(t=de,e=K.call(arguments,1)),Array.isArray(e[0])&&(e=e[0]),Ve(e,t).mergeObservable()};je.mergeObservable=je.mergeAll=function(){var t=this;return new Ge(function(e){var n=new re,r=!1,i=new ae;return n.add(i),i.setDisposable(t.subscribe(function(t){var i=new ae;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})},je.skipUntil=function(t){var e=this;return new Ge(function(n){var r=!1,i=new re(e.subscribe(function(t){r&&n.onNext(t)},n.onError.bind(n),function(){r&&n.onCompleted()})),o=new ae;return i.add(o),o.setDisposable(t.subscribe(function(){r=!0,o.dispose()},n.onError.bind(n),function(){o.dispose()})),i})},je["switch"]=je.switchLatest=function(){var t=this;return new Ge(function(e){var n=!1,r=new he,i=!1,o=0,s=t.subscribe(function(t){var s=new ae,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 re(s,r)})},je.takeUntil=function(t){var n=this;return new Ge(function(r){return new re(n.subscribe(r),t.subscribe(r.onCompleted.bind(r),r.onError.bind(r),e))})},je.zip=function(){if(Array.isArray(arguments[0]))return d.apply(this,arguments);var e=this,r=K.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=f(u,function(){return[]}),a=f(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()},l=Array(u),p=0;u>p;p++)(function(t){l[t]=new ae,l[t].setDisposable(r[t].subscribe(function(e){c[t].push(e),h(t)},o.onError.bind(o),function(){s(t)}))})(p);return new re(l)})},Ie.zip=function(){var t=K.call(arguments,0),e=t.shift();return e.zip.apply(e,t)},Ie.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=f(s,function(){return[]}),c=f(s,function(){return!1}),a=Array(s),h=0;s>h;h++)(function(t){a[t]=new ae,a[t].setDisposable(e[t].subscribe(function(e){u[t].push(e),i(t)},r.onError.bind(r),function(){o(t)}))})(h);var l=new re(a);return l.add(se(function(){for(var t=0,e=u.length;e>t;t++)u[t]=[]})),l})},je.asObservable=function(){var t=this;return new Ge(function(e){return t.subscribe(e)})},je.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))})},je.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))})},je["do"]=je.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()})})},je["finally"]=je.finallyAction=function(t){var e=this;return new Ge(function(n){var r=e.subscribe(n);return se(function(){try{r.dispose()}catch(e){throw e}finally{t()}})})},je.ignoreElements=function(){var t=this;return new Ge(function(n){return t.subscribe(e,n.onError.bind(n),n.onCompleted.bind(n))})},je.materialize=function(){var t=this;return new Ge(function(e){return t.subscribe(function(t){e.onNext(Ce(t))},function(t){e.onNext(De(t)),e.onCompleted()},function(){e.onNext(Se()),e.onCompleted()})})},je.repeat=function(t){return Re(this,t).concat()},je.retry=function(t){return Re(this,t).catchException()},je.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()})})},je.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))})},je.startWith=function(){var t,e,n=0;return arguments.length&&"now"in Object(arguments[0])?(e=arguments[0],n=1):e=de,t=K.call(arguments,n),_e([Ve(t,e),this]).concat()},je.takeLast=function(t,e){return this.takeLastBuffer(t).selectMany(function(t){return Ve(t,e)})},je.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()})})},je.select=je.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))})},je.selectMany=je.flatMap=function(t,e){return e?this.selectMany(function(n){return t(n).select(function(t){return e(n,t)})}):"function"==typeof t?b.call(this,t):b.call(this,function(){return t})},je.selectSwitch=je.flatMapLatest=function(t,e){return this.select(t,e).switchLatest()},je.skip=function(t){if(0>t)throw Error(j);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))})},je.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))})},je.take=function(t,e){if(0>t)throw Error(j);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))})},je.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))})},je.where=je.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))})},Ie.fromCallback=function(e,n,r,i){return n||(n=de),function(){var o=K.call(arguments,0);return new Ge(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)})})}},Ie.fromNodeCallback=function(e,n,r,i){return n||(n=de),function(){var o=K.call(arguments,0);return new Ge(function(s){return n.schedule(function(){function n(e){if(e)return s.onError(e),t;
var n=K.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)})})}},Ie.fromEvent=function(e,n,r){return new Ge(function(i){return w(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()},Ie.fromEventPattern=function(e,n,r){return new Ge(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 se(function(){n&&n(o,s)})}).publish().refCount()},Ie.fromPromise=function(t){return new Ge(function(e){t.then(function(t){e.onNext(t),e.onCompleted()},function(t){e.onError(t)})})},je.toPromise=function(t){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)})})},je.multicast=function(t,e){var n=this;return"function"==typeof t?new Ge(function(r){var i=n.multicast(t());return new re(e(i).subscribe(r),i.connect())}):new Qe(n,t)},je.publish=function(t){return t?this.multicast(function(){return new tn},t):this.multicast(new tn)},je.share=function(){return this.publish(null).refCount()},je.publishLast=function(t){return t?this.multicast(function(){return new en},t):this.multicast(new en)},je.publishValue=function(t,e){return 2===arguments.length?this.multicast(function(){return new rn(e)},t):this.multicast(new rn(t))},je.shareValue=function(t){return this.publishValue(t).refCount()},je.replay=function(t,e,n,r){return t?this.multicast(function(){return new on(e,n,r)},t):this.multicast(new on(e,n,r))},je.shareReplay=function(t,e,n){return this.replay(null,t,e,n).refCount()};var Qe=_.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 re(i.source.subscribe(i.subject),se(function(){i.hasSubscription=!1}))),i.subscription},t.call(this,r)}return J(e,t),e.prototype.connect=function(){return this.connect()},e.prototype.refCount=function(){var t=null,e=0,n=this;return new Ge(function(r){var i,o;return e++,i=1===e,o=n.subscribe(r),i&&(t=n.connect()),se(function(){o.dispose(),e--,0===e&&t.dispose()})})},e}(Ie),Ke=Ie.interval=function(t,e){return e||(e=xe),x(t,t,e)},Je=Ie.timer=function(e,n,r){var i;return r||(r=xe),"number"==typeof n?i=n:"object"==typeof n&&"now"in n&&(r=n),i===t?g(e,r):x(e,i,r)};je.delay=function(t,e){e||(e=xe);var n=this;return new Ge(function(r){var i,o=!1,s=new he,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 ae,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 re(i,s)})},je.throttle=function(t,e){return e||(e=xe),this.throttleWithSelector(function(){return Je(t,e)})},je.timeInterval=function(t){var e=this;return t||(t=xe),Le(function(){var n=t.now();return e.select(function(e){var r=t.now(),i=r-n;return n=r,{value:e,interval:i}})})},je.timestamp=function(t){return t||(t=xe),this.select(function(e){return{value:e,timestamp:t.now()}})},je.sample=function(t,e){return e||(e=xe),"number"==typeof t?E(this,Ke(t,e)):E(this,t)},je.timeout=function(t,e,n){var r,i=this;return e||(e=Ue(Error("Timeout"))),n||(n=xe),r=t instanceof Date?function(t,e){n.scheduleWithAbsolute(t,e)}:function(t,e){n.scheduleWithRelative(t,e)},new Ge(function(n){var o,s=0,u=new ae,c=new he,a=!1,h=new he;return c.setDisposable(u),o=function(){var i=s;h.setDisposable(r(t,function(){a=s===i;var t=a;t&&c.setDisposable(e.subscribe(n))}))},o(),u.setDisposable(i.subscribe(function(t){var e=!a;e&&(s++,n.onNext(t),o())},function(t){var e=!a;e&&(s++,n.onError(t))},function(){var t=!a;t&&(s++,n.onCompleted())})),new re(c,h)})},Ie.generateWithTime=function(e,n,r,i,o,s){return s||(s=xe),new Ge(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()})})},je.delaySubscription=function(t,e){return e||(e=xe),this.delayWithSelector(Je(t,e),function(){return Me()})},je.delayWithSelector=function(e,n){var r,i,o=this;return"function"==typeof e?i=e:(r=e,i=n),new Ge(function(e){var n=new re,s=!1,u=function(){s&&0===n.length&&e.onCompleted()},c=new he,a=function(){c.setDisposable(o.subscribe(function(r){var o;try{o=i(r)}catch(s){return e.onError(s),t}var c=new ae;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 re(c,n)})},je.timeoutWithSelector=function(e,n,r){if(1===arguments.length){n=e;var e=ze()}r||(r=Ue(Error("Timeout")));var i=this;return new Ge(function(o){var s=new he,u=new he,c=new ae;s.setDisposable(c);var a=0,h=!1,l=function(t){var e=a,n=function(){return a===e},i=new ae;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 re(s,u)})},je.throttleWithSelector=function(e){var n=this;return new Ge(function(r){var i,o=!1,s=new he,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 ae;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 re(c,s)})},je.skipLastWithTime=function(t,e){e||(e=xe);var n=this;return new Ge(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()})})},je.takeLastWithTime=function(t,e,n){return this.takeLastBufferWithTime(t,e).selectMany(function(t){return Ve(t,n)})},je.takeLastBufferWithTime=function(t,e){var n=this;return e||(e=xe),new Ge(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()})})},je.takeWithTime=function(t,e){var n=this;return e||(e=xe),new Ge(function(r){var i=e.scheduleWithRelative(t,function(){r.onCompleted()});return new re(i,n.subscribe(r))})},je.skipWithTime=function(t,e){var n=this;return e||(e=xe),new Ge(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 re(o,s)})},je.skipUntilWithTime=function(t,e){e||(e=xe);var n=this;return new Ge(function(r){var i=!1,o=e.scheduleWithAbsolute(t,function(){i=!0}),s=n.subscribe(function(t){i&&r.onNext(t)},r.onError.bind(r),r.onCompleted.bind(r));return new re(o,s)})},je.takeUntilWithTime=function(t,e){e||(e=xe);var n=this;return new Ge(function(r){return new re(e.scheduleWithAbsolute(t,function(){r.onCompleted()}),n.subscribe(r))})};var Ge=_.Internals.AnonymousObservable=function(e){function n(e){return e===t?e=ue:"function"==typeof e&&(e=se(e)),e}function r(i){function o(t){var e=new Ye(t);if(be.scheduleRequired())be.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 J(r,e),r}(Ie),Ye=function(t){function e(e){t.call(this),this.observer=e,this.m=new ae}J(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}(Te),Ze=function(t,e){this.subject=t,this.observer=e};Ze.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 tn=_.Subject=function(t){function e(t){return s.call(this),this.isStopped?this.exception?(t.onError(this.exception),ue):(t.onCompleted(),ue):(this.observers.push(t),new Ze(this,t))}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.observers=[]}return J(n,t),G(n.prototype,We,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(s.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(s.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(s.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 nn(t,e)},n}(Ie),en=_.AsyncSubject=function(t){function e(t){if(s.call(this),!this.isStopped)return this.observers.push(t),new Ze(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(),ue}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.value=null,this.hasValue=!1,this.observers=[],this.exception=null}return J(n,t),G(n.prototype,We,{hasObservers:function(){return s.call(this),this.observers.length>0},onCompleted:function(){var t,e,n;if(s.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(s.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){s.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}(Ie),nn=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 J(n,t),G(n.prototype,We,{onCompleted:function(){this.observer.onCompleted()},onError:function(t){this.observer.onError(t)},onNext:function(t){this.observer.onNext(t)}}),n}(Ie),rn=_.BehaviorSubject=function(t){function e(t){if(s.call(this),!this.isStopped)return this.observers.push(t),t.onNext(this.value),new Ze(this,t);var e=this.exception;return e?t.onError(e):t.onCompleted(),ue}function n(n){t.call(this,e),this.value=n,this.observers=[],this.isDisposed=!1,this.isStopped=!1,this.exception=null}return J(n,t),G(n.prototype,We,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(s.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(s.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(s.call(this),!this.isStopped){this.value=t;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,this.value=null,this.exception=null}}),n}(Ie),on=_.ReplaySubject=function(t){function e(t,e){this.subject=t,this.observer=e}function n(t){var n=new Pe(this.scheduler,t),r=new e(this,n);s.call(this),this._trim(this.scheduler.now()),this.observers.push(n);for(var i=this.q.length,o=0,u=this.q.length;u>o;o++)n.onNext(this.q[o].value);return this.hasError?(i++,n.onError(this.error)):this.isStopped&&(i++,n.onCompleted()),n.ensureActive(i),r}function r(e,r,i){this.bufferSize=null==e?Number.MAX_VALUE:e,this.windowSize=null==r?Number.MAX_VALUE:r,this.scheduler=i||be,this.q=[],this.observers=[],this.isStopped=!1,this.isDisposed=!1,this.hasError=!1,this.error=null,t.call(this,n)}return e.prototype.dispose=function(){if(this.observer.dispose(),!this.subject.isDisposed){var t=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(t,1)}},J(r,t),G(r.prototype,We,{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 e;if(s.call(this),!this.isStopped){var n=this.scheduler.now();this.q.push({interval:n,value:t}),this._trim(n);for(var r=this.observers.slice(0),i=0,o=r.length;o>i;i++)e=r[i],e.onNext(t),e.ensureActive()}},onError:function(t){var e;if(s.call(this),!this.isStopped){this.isStopped=!0,this.error=t,this.hasError=!0;var n=this.scheduler.now();this._trim(n);for(var r=this.observers.slice(0),i=0,o=r.length;o>i;i++)e=r[i],e.onError(t),e.ensureActive();this.observers=[]}},onCompleted:function(){var t;if(s.call(this),!this.isStopped){this.isStopped=!0;var e=this.scheduler.now();this._trim(e);for(var n=this.observers.slice(0),r=0,i=n.length;i>r;r++)t=n[r],t.onCompleted(),t.ensureActive();this.observers=[]}},dispose:function(){this.isDisposed=!0,this.observers=null}}),r}(Ie);"function"==typeof define&&"object"==typeof define.amd&&define.amd?(D.Rx=_,define(function(){return _})):S&&N?A?(N.exports=_).Rx=_:S.Rx=_:D.Rx=_}).call(this);