box-chrome-sdk
Version:
A Chrome App SDK for the Box V2 API
1 lines • 26 kB
JavaScript
(function(t){function e(){if(this.isDisposed)throw Error(A)}function n(t){var e=typeof t;return t&&("function"==e||"object"==e)||!1}function i(t){var e=[];if(!n(t))return e;G.nonEnumArgs&&t.length&&u(t)&&(t=U.call(t));var i=G.enumPrototypes&&"function"==typeof t,r=G.enumErrorProps&&(t===H||t instanceof Error);for(var s in t)i&&"prototype"==s||r&&("message"==s||"name"==s)||e.push(s);if(G.nonEnumShadows&&t!==L){var o=t.constructor,c=-1,h=K.length;if(t===(o&&o.prototype))var a=t===stringProto?M:t===H?N:F.call(t),l=Q[a];for(;h>++c;)s=K[c],l&&l[s]||!z.call(t,s)||e.push(s)}return e}function r(t,e,n){for(var i=-1,r=n(t),s=r.length;s>++i;){var o=r[i];if(e(t[o],o,t)===!1)break}return t}function s(t,e){return r(t,e,i)}function o(t){return"function"!=typeof t.toString&&"string"==typeof(t+"")}function u(t){return t&&"object"==typeof t?F.call(t)==C:!1}function c(t){return"function"==typeof t||!1}function h(e,n,i,r){if(e===n)return 0!==e||1/e==1/n;var a=typeof e,l=typeof n;if(e===e&&(null==e||null==n||"function"!=a&&"object"!=a&&"function"!=l&&"object"!=l))return!1;var p=F.call(e),f=F.call(n);if(p==C&&(p=T),f==C&&(f=T),p!=f)return!1;switch(p){case W:case P:return+e==+n;case k:return e!=+e?n!=+n:0==e?1/e==1/n:e==+n;case I:case M:return e==n+""}var d=p==j;if(!d){if(p!=T||!G.nodeClass&&(o(e)||o(n)))return!1;var v=!G.argsObject&&u(e)?Object:e.constructor,b=!G.argsObject&&u(n)?Object:n.constructor;if(!(v==b||z.call(e,"constructor")&&z.call(n,"constructor")||c(v)&&v instanceof v&&c(b)&&b instanceof b||!("constructor"in e&&"constructor"in n)))return!1}i||(i=[]),r||(r=[]);for(var y=i.length;y--;)if(i[y]==e)return r[y]==n;var m=0;if(result=!0,i.push(e),r.push(n),d){if(y=e.length,m=n.length,result=m==y)for(;m--;){var g=n[m];if(!(result=h(e[m],g,i,r)))break}}else s(n,function(n,s,o){return z.call(o,s)?(m++,result=z.call(e,s)&&h(e[s],n,i,r)):t}),result&&s(e,function(e,n,i){return z.call(i,n)?result=--m>-1:t});return i.pop(),r.pop(),result}function a(t,e){return 1===t.length&&Array.isArray(t[e])?t[e]:U.call(t)}function l(t,e){this.scheduler=t,this.disposable=e,this.isDisposed=!1}var p={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},f=p[typeof window]&&window||this,d=p[typeof exports]&&exports&&!exports.nodeType&&exports,v=p[typeof module]&&module&&!module.nodeType&&module,b=v&&v.exports===d&&d,y=p[typeof global]&&global;!y||y.global!==y&&y.window!==y||(f=y);var m={internals:{},config:{Promise:f.Promise},helpers:{}},g=m.helpers.noop=function(){},w=m.helpers.identity=function(t){return t},_=(m.helpers.pluck=function(t){return function(e){return e[t]}},m.helpers.just=function(t){return function(){return t}},m.helpers.defaultNow=Date.now),S=(m.helpers.defaultComparer=function(t,e){return J(t,e)},m.helpers.defaultSubComparer=function(t,e){return t>e?1:e>t?-1:0}),D=(m.helpers.defaultKeySerializer=function(t){return""+t},m.helpers.defaultError=function(t){throw t}),x=m.helpers.isPromise=function(t){return!!t&&"function"==typeof t.then&&t.then!==m.Observable.prototype.then};m.helpers.asArray=function(){return Array.prototype.slice.call(arguments)},m.helpers.not=function(t){return!t};var A="Object has been disposed",E="object"==typeof Symbol&&Symbol.iterator||"_es6shim_iterator_";f.Set&&"function"==typeof(new f.Set)["@@iterator"]&&(E="@@iterator");var O,R={done:!0,value:t},C="[object Arguments]",j="[object Array]",W="[object Boolean]",P="[object Date]",N="[object Error]",q="[object Function]",k="[object Number]",T="[object Object]",I="[object RegExp]",M="[object String]",F=Object.prototype.toString,z=Object.prototype.hasOwnProperty,V=F.call(arguments)==C,H=Error.prototype,L=Object.prototype,$=L.propertyIsEnumerable;try{O=!(F.call(document)==T&&!({toString:0}+""))}catch(B){O=!0}var K=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Q={};Q[j]=Q[P]=Q[k]={constructor:!0,toLocaleString:!0,toString:!0,valueOf:!0},Q[W]=Q[M]={constructor:!0,toString:!0,valueOf:!0},Q[N]=Q[q]=Q[I]={constructor:!0,toString:!0},Q[T]={constructor:!0};var G={};(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);G.enumErrorProps=$.call(H,"message")||$.call(H,"name"),G.enumPrototypes=$.call(t,"prototype"),G.nonEnumArgs=0!=n,G.nonEnumShadows=!/valueOf/.test(e)})(1),V||(u=function(t){return t&&"object"==typeof t?z.call(t,"callee"):!1}),c(/x/)&&(c=function(t){return"function"==typeof t&&F.call(t)==q});var J=m.internals.isEqual=function(t,e){return h(t,e,[],[])},U=Array.prototype.slice;({}).hasOwnProperty;var X=this.inherits=m.internals.inherits=function(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n},Y=m.internals.addProperties=function(t){for(var e=U.call(arguments,1),n=0,i=e.length;i>n;n++){var r=e[n];for(var s in r)t[s]=r[s]}};m.internals.addRef=function(t,e){return new Ne(function(n){return new ne(e.getDisposable(),t.subscribe(n))})};var Z=function(t,e){this.id=t,this.value=e};Z.prototype.compareTo=function(t){var e=this.value.compareTo(t.value);return 0===e&&(e=this.id-t.id),e};var te=m.internals.PriorityQueue=function(t){this.items=Array(t),this.length=0},ee=te.prototype;ee.isHigherPriority=function(t,e){return 0>this.items[t].compareTo(this.items[e])},ee.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)}}},ee.heapify=function(e){if(e===t&&(e=0),!(e>=this.length||0>e)){var n=2*e+1,i=2*e+2,r=e;if(this.length>n&&this.isHigherPriority(n,r)&&(r=n),this.length>i&&this.isHigherPriority(i,r)&&(r=i),r!==e){var s=this.items[e];this.items[e]=this.items[r],this.items[r]=s,this.heapify(r)}}},ee.peek=function(){return this.items[0].value},ee.removeAt=function(t){this.items[t]=this.items[--this.length],delete this.items[this.length],this.heapify()},ee.dequeue=function(){var t=this.peek();return this.removeAt(0),t},ee.enqueue=function(t){var e=this.length++;this.items[e]=new Z(te.count++,t),this.percolate(e)},ee.remove=function(t){for(var e=0;this.length>e;e++)if(this.items[e].value===t)return this.removeAt(e),!0;return!1},te.count=0;var ne=m.CompositeDisposable=function(){this.disposables=a(arguments,0),this.isDisposed=!1,this.length=this.disposables.length},ie=ne.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 re=m.Disposable=function(t){this.isDisposed=!1,this.action=t||g};re.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var se=re.create=function(t){return new re(t)},oe=re.empty={dispose:g},ue=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}(),ce=m.SingleAssignmentDisposable=function(t){function e(){t.call(this,!0)}return X(e,t),e}(ue),he=m.SerialDisposable=function(t){function e(){t.call(this,!1)}return X(e,t),e}(ue);m.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?oe:new t(this)},e}(),l.prototype.dispose=function(){var t=this;this.scheduler.schedule(function(){t.isDisposed||(t.isDisposed=!0,t.disposable.dispose())})};var ae=m.internals.ScheduledItem=function(t,e,n,i,r){this.scheduler=t,this.state=e,this.action=n,this.dueTime=i,this.comparer=r||S,this.disposable=new ce};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 le=m.Scheduler=function(){function t(t,e,n,i){this.now=t,this._schedule=e,this._scheduleRelative=n,this._scheduleAbsolute=i}function e(t,e){var n=e.first,i=e.second,r=new ne,s=function(e){i(e,function(e){var n=!1,i=!1,o=t.scheduleWithState(e,function(t,e){return n?r.remove(o):i=!0,s(e),oe});i||(r.add(o),n=!0)})};return s(n),r}function n(t,e,n){var i=e.first,r=e.second,s=new ne,o=function(e){r(e,function(e,i){var r=!1,u=!1,c=t[n].call(t,e,i,function(t,e){return r?s.remove(c):u=!0,o(e),oe});u||(s.add(c),r=!0)})};return o(i),s}function i(t,e){return e(),oe}var r=t.prototype;return r.catchException=r["catch"]=function(t){return new ye(this,t)},r.schedulePeriodic=function(t,e){return this.schedulePeriodicWithState(null,t,function(){e()})},r.schedulePeriodicWithState=function(t,e,n){var i=t,r=setInterval(function(){i=n(i)},e);return se(function(){clearInterval(r)})},r.schedule=function(t){return this._schedule(t,i)},r.scheduleWithState=function(t,e){return this._schedule(t,e)},r.scheduleWithRelative=function(t,e){return this._scheduleRelative(e,t,i)},r.scheduleWithRelativeAndState=function(t,e,n){return this._scheduleRelative(t,e,n)},r.scheduleWithAbsolute=function(t,e){return this._scheduleAbsolute(e,t,i)},r.scheduleWithAbsoluteAndState=function(t,e,n){return this._scheduleAbsolute(t,e,n)},r.scheduleRecursive=function(t){return this.scheduleRecursiveWithState(t,function(t,e){t(function(){e(t)})})},r.scheduleRecursiveWithState=function(t,n){return this.scheduleWithState({first:t,second:n},function(t,n){return e(t,n)})},r.scheduleRecursiveWithRelative=function(t,e){return this.scheduleRecursiveWithRelativeAndState(e,t,function(t,e){t(function(n){e(t,n)})})},r.scheduleRecursiveWithRelativeAndState=function(t,e,i){return this._scheduleRelative({first:t,second:i},e,function(t,e){return n(t,e,"scheduleWithRelativeAndState")})},r.scheduleRecursiveWithAbsolute=function(t,e){return this.scheduleRecursiveWithAbsoluteAndState(e,t,function(t,e){t(function(n){e(t,n)})})},r.scheduleRecursiveWithAbsoluteAndState=function(t,e,i){return this._scheduleAbsolute({first:t,second:i},e,function(t,e){return n(t,e,"scheduleWithAbsoluteAndState")})},t.now=_,t.normalize=function(t){return 0>t&&(t=0),t},t}(),pe=le.normalize;m.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,i){this._scheduler=t,this._state=e,this._period=n,this._action=i}return e.prototype.start=function(){var e=new ce;return this._cancel=e,e.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,t.bind(this))),e},e}();var fe,de=le.immediate=function(){function t(t,e){return e(this,t)}function e(t,e,n){for(var i=pe(i);i-this.now()>0;);return n(this,t)}function n(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new le(_,t,e,n)}(),ve=le.currentThread=function(){function t(t){for(var e;t.length>0;)if(e=t.dequeue(),!e.isCancelled()){for(;e.dueTime-le.now()>0;);e.isCancelled()||e.invoke()}}function e(t,e){return this.scheduleWithRelativeAndState(t,0,e)}function n(e,n,i){var s=this.now()+le.normalize(n),o=new ae(this,e,i,s);if(r)r.enqueue(o);else{r=new te(4),r.enqueue(o);try{t(r)}catch(u){throw u}finally{r=null}}return o.disposable}function i(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}var r,s=new le(_,e,n,i);return s.scheduleRequired=function(){return null===r},s.ensureTrampoline=function(t){return null===r?this.schedule(t):t()},s}(),be=g;(function(){function t(){if(!f.postMessage||f.importScripts)return!1;var t=!1,e=f.onmessage;return f.onmessage=function(){t=!0},f.postMessage("","*"),f.onmessage=e,t}function e(t){if("string"==typeof t.data&&t.data.substring(0,s.length)===s){var e=t.data.substring(s.length),n=o[e];n(),delete o[e]}}var n=RegExp("^"+(F+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),i="function"==typeof(i=y&&b&&y.setImmediate)&&!n.test(i)&&i,r="function"==typeof(r=y&&b&&y.clearImmediate)&&!n.test(r)&&r;if("undefined"!=typeof process&&"[object process]"==={}.toString.call(process))fe=process.nextTick;else if("function"==typeof i)fe=i,be=r;else if(t()){var s="ms.rx.schedule"+Math.random(),o={},u=0;f.addEventListener?f.addEventListener("message",e,!1):f.attachEvent("onmessage",e,!1),fe=function(t){var e=u++;o[e]=t,f.postMessage(s+e,"*")}}else if(f.MessageChannel){var c=new f.MessageChannel,h={},a=0;c.port1.onmessage=function(t){var e=t.data,n=h[e];n(),delete h[e]},fe=function(t){var e=a++;h[e]=t,c.port2.postMessage(e)}}else"document"in f&&"onreadystatechange"in f.document.createElement("script")?fe=function(t){var e=f.document.createElement("script");e.onreadystatechange=function(){t(),e.onreadystatechange=null,e.parentNode.removeChild(e),e=null},f.document.documentElement.appendChild(e)}:(fe=function(t){return setTimeout(t,0)},be=clearTimeout)})(),le.timeout=function(){function t(t,e){var n=this,i=new ce,r=fe(function(){i.isDisposed||i.setDisposable(e(n,t))});return new ne(i,se(function(){be(r)}))}function e(t,e,n){var i=this,r=le.normalize(e);if(0===r)return i.scheduleWithState(t,n);var s=new ce,o=setTimeout(function(){s.isDisposed||s.setDisposable(n(i,t))},r);return new ne(s,se(function(){clearTimeout(o)}))}function n(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new le(_,t,e,n)}();var ye=function(t){function e(){return this._scheduler.now()}function n(t,e){return this._scheduler.scheduleWithState(t,this._wrap(e))}function i(t,e,n){return this._scheduler.scheduleWithRelativeAndState(t,e,this._wrap(n))}function r(t,e,n){return this._scheduler.scheduleWithAbsoluteAndState(t,e,this._wrap(n))}function s(s,o){this._scheduler=s,this._handler=o,this._recursiveOriginal=null,this._recursiveWrapper=null,t.call(this,e,n,i,r)}return X(s,t),s.prototype._clone=function(t){return new s(t,this._handler)},s.prototype._wrap=function(t){var e=this;return function(n,i){try{return t(e._getRecursiveWrapper(n),i)}catch(r){if(!e._handler(r))throw r;return oe}}},s.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},s.prototype.schedulePeriodicWithState=function(t,e,n){var i=this,r=!1,s=new ce;return s.setDisposable(this._scheduler.schedulePeriodicWithState(t,e,function(t){if(r)return null;try{return n(t)}catch(e){if(r=!0,!i._handler(e))throw e;return s.dispose(),null}})),s},s}(le),me=m.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 Ne(function(n){return t.schedule(function(){e._acceptObservable(n),"N"===e.kind&&n.onCompleted()})})},t}(),ge=me.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(i){var r=new me("N",!0);return r.value=i,r._accept=t,r._acceptObservable=e,r.toString=n,r}}(),we=me.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(i){var r=new me("E");return r.exception=i,r._accept=t,r._acceptObservable=e,r.toString=n,r}}(),_e=me.createOnCompleted=function(){function t(t,e,n){return n()}function e(t){return t.onCompleted()}function n(){return"OnCompleted()"}return function(){var i=new me("C");return i._accept=t,i._acceptObservable=e,i.toString=n,i}}(),Se=m.internals.Enumerator=function(t){this._next=t};Se.prototype.next=function(){return this._next()},Se.prototype[E]=function(){return this};var De=m.internals.Enumerable=function(t){this._iterator=t};De.prototype[E]=function(){return this._iterator()},De.prototype.concat=function(){var e=this;return new Ne(function(n){var i;try{i=e[E]()}catch(r){return n.onError(),t}var s,o=new he,u=de.scheduleRecursive(function(e){var r;if(!s){try{r=i.next()}catch(u){return n.onError(u),t}if(r.done)return n.onCompleted(),t;var c=r.value;x(c)&&(c=observableFromPromise(c));var h=new ce;o.setDisposable(h),h.setDisposable(c.subscribe(n.onNext.bind(n),n.onError.bind(n),function(){e()}))}});return new ne(o,u,se(function(){s=!0}))})},De.prototype.catchException=function(){var e=this;return new Ne(function(n){var i;try{i=e[E]()}catch(r){return n.onError(),t}var s,o,u=new he,c=de.scheduleRecursive(function(e){if(!s){var r;try{r=i.next()}catch(c){return n.onError(c),t}if(r.done)return o?n.onError(o):n.onCompleted(),t;var h=r.value;x(h)&&(h=observableFromPromise(h));var a=new ce;u.setDisposable(a),a.setDisposable(h.subscribe(n.onNext.bind(n),function(t){o=t,e()},n.onCompleted.bind(n)))}});return new ne(u,c,se(function(){s=!0}))})},De.repeat=function(t,e){return null==e&&(e=-1),new De(function(){var n=e;return new Se(function(){return 0===n?R:(n>0&&n--,{done:!1,value:t})})})},De.forEach=function(t,e,n){return e||(e=w),new De(function(){var i=-1;return new Se(function(){return++i<t.length?{done:!1,value:e.call(n,t[i],i,t)}:R})})};var xe=m.Observer=function(){};xe.prototype.toNotifier=function(){var t=this;return function(e){return e.accept(t)}},xe.prototype.asObserver=function(){return new Re(this.onNext.bind(this),this.onError.bind(this),this.onCompleted.bind(this))},xe.prototype.checked=function(){return new Ce(this)};var Ae=xe.create=function(t,e,n){return t||(t=g),e||(e=D),n||(n=g),new Re(t,e,n)};xe.fromNotifier=function(t){return new Re(function(e){return t(ge(e))},function(e){return t(we(e))},function(){return t(_e())})},xe.notifyOn=function(t){return new We(t,this)};var Ee,Oe=m.internals.AbstractObserver=function(t){function e(){this.isStopped=!1,t.call(this)}return X(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}(xe),Re=m.AnonymousObserver=function(t){function e(e,n,i){t.call(this),this._onNext=e,this._onError=n,this._onCompleted=i}return X(e,t),e.prototype.next=function(t){this._onNext(t)},e.prototype.error=function(t){this._onError(t)},e.prototype.completed=function(){this._onCompleted()},e}(Oe),Ce=function(t){function e(e){t.call(this),this._observer=e,this._state=0}X(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}(xe),je=m.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 X(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 i;if(!(n.queue.length>0))return n.isAcquired=!1,t;i=n.queue.shift();try{i()}catch(r){throw n.queue=[],n.hasFaulted=!0,r}e()}))},n.prototype.dispose=function(){e.prototype.dispose.call(this),this.disposable.dispose()},n}(Oe),We=function(t){function e(){t.apply(this,arguments)}return X(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}(je),Pe=m.Observable=function(){function t(t){this._subscribe=t}return Ee=t.prototype,Ee.subscribe=Ee.forEach=function(t,e,n){var i="object"==typeof t?t:Ae(t,e,n);return this._subscribe(i)},t}(),Ne=m.AnonymousObservable=function(e){function n(e){return e===t?e=oe:"function"==typeof e&&(e=se(e)),e}function i(r){function s(t){var e=new qe(t);if(ve.scheduleRequired())ve.schedule(function(){try{e.setDisposable(n(r(e)))}catch(t){if(!e.fail(t))throw t}});else try{e.setDisposable(n(r(e)))}catch(i){if(!e.fail(i))throw i}return e}return this instanceof i?(e.call(this,s),t):new i(r)}return X(i,e),i}(Pe),qe=function(t){function e(e){t.call(this),this.observer=e,this.m=new ce}X(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}(Oe);(function(t){function e(t){return this.underlyingObservable.subscribe(t)}function n(n,i,r){t.call(this,e),this.key=n,this.underlyingObservable=r?new Ne(function(t){return new ne(r.getDisposable(),i.subscribe(t))}):i}return X(n,t),n})(Pe);var ke=function(t,e){this.subject=t,this.observer=e};ke.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}},m.Subject=function(t){function n(t){return e.call(this),this.isStopped?this.exception?(t.onError(this.exception),oe):(t.onCompleted(),oe):(this.observers.push(t),new ke(this,t))}function i(){t.call(this,n),this.isDisposed=!1,this.isStopped=!1,this.observers=[]}return X(i,t),Y(i.prototype,xe,{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,i=t.length;i>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 i=0,r=n.length;r>i;i++)n[i].onError(t);this.observers=[]}},onNext:function(t){if(e.call(this),!this.isStopped)for(var n=this.observers.slice(0),i=0,r=n.length;r>i;i++)n[i].onNext(t)},dispose:function(){this.isDisposed=!0,this.observers=null}}),i.create=function(t,e){return new Te(t,e)},i}(Pe),m.AsyncSubject=function(t){function n(t){if(e.call(this),!this.isStopped)return this.observers.push(t),new ke(this,t);var n=this.exception,i=this.hasValue,r=this.value;return n?t.onError(n):i?(t.onNext(r),t.onCompleted()):t.onCompleted(),oe}function i(){t.call(this,n),this.isDisposed=!1,this.isStopped=!1,this.value=null,this.hasValue=!1,this.observers=[],this.exception=null}return X(i,t),Y(i.prototype,xe,{hasObservers:function(){return e.call(this),this.observers.length>0},onCompleted:function(){var t,n,i;if(e.call(this),!this.isStopped){this.isStopped=!0;var r=this.observers.slice(0),s=this.value,o=this.hasValue;if(o)for(n=0,i=r.length;i>n;n++)t=r[n],t.onNext(s),t.onCompleted();else for(n=0,i=r.length;i>n;n++)r[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 i=0,r=n.length;r>i;i++)n[i].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}}),i}(Pe);var Te=function(t){function e(t){return this.observable.subscribe(t)}function n(n,i){t.call(this,e),this.observer=n,this.observable=i}return X(n,t),Y(n.prototype,xe,{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?(f.Rx=m,define(function(){return m})):d&&v?b?(v.exports=m).Rx=m:d.Rx=m:f.Rx=m}).call(this);