extended-angular-firestore
Version:
Lightweight extension of Angular Firestore. Provides a more intuitive API. Create, Update, Insert-or-Update (Upsert), Check for Existence, Download Once, Download and Listen for Changes.
1 lines • 441 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("rxjs/Observable"),require("rxjs/add/observable/of"),require("rxjs/observable/from"),require("rxjs/add/operator/map"),require("rxjs/operator/observeOn"),require("rxjs/add/operator/share"),require("rxjs/add/operator/filter"),require("rxjs/add/operator/scan")):"function"==typeof define&&define.amd?define(["exports","@angular/core","rxjs/Observable","rxjs/add/observable/of","rxjs/observable/from","rxjs/add/operator/map","rxjs/operator/observeOn","rxjs/add/operator/share","rxjs/add/operator/filter","rxjs/add/operator/scan"],e):e(t["extended-angular-firestore"]={},t.ng.core,t.Rx,t.Rx.Observable,t.Rx.Observable,t.Rx.Observable.prototype,t.Rx.Observable.prototype)}(this,function(exports,core,Observable,of,from,map,observeOn){"use strict";var commonjsGlobal="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(t,e){return t(e={exports:{}},e.exports),e.exports}var promise$2=createCommonjsModule(function(t){!function(e){var r=setTimeout;function n(){}function o(t){if(!(this instanceof o))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=undefined,this._deferreds=[],c(t,this)}function i(t,e){for(;3===t._state;)t=t._value;0!==t._state?(t._handled=!0,o._immediateFn(function(){var r=1===t._state?e.onFulfilled:e.onRejected;if(null!==r){var n;try{n=r(t._value)}catch(o){return void a(e.promise,o)}s(e.promise,n)}else(1===t._state?s:a)(e.promise,t._value)})):t._deferreds.push(e)}function s(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var r=e.then;if(e instanceof o)return t._state=3,t._value=e,void u(t);if("function"==typeof r)return void c((n=r,i=e,function(){n.apply(i,arguments)}),t)}t._state=1,t._value=e,u(t)}catch(s){a(t,s)}var n,i}function a(t,e){t._state=2,t._value=e,u(t)}function u(t){2===t._state&&0===t._deferreds.length&&o._immediateFn(function(){t._handled||o._unhandledRejectionFn(t._value)});for(var e=0,r=t._deferreds.length;e<r;e++)i(t,t._deferreds[e]);t._deferreds=null}function c(t,e){var r=!1;try{t(function(t){r||(r=!0,s(e,t))},function(t){r||(r=!0,a(e,t))})}catch(n){if(r)return;r=!0,a(e,n)}}o.prototype["catch"]=function(t){return this.then(null,t)},o.prototype.then=function(t,e){var r=new this.constructor(n);return i(this,new function(t,e,r){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=r}(t,e,r)),r},o.all=function(t){return new o(function(e,r){if(!t||"undefined"==typeof t.length)throw new TypeError("Promise.all accepts an array");var n=Array.prototype.slice.call(t);if(0===n.length)return e([]);var o=n.length;function i(t,s){try{if(s&&("object"==typeof s||"function"==typeof s)){var a=s.then;if("function"==typeof a)return void a.call(s,function(e){i(t,e)},r)}n[t]=s,0==--o&&e(n)}catch(u){r(u)}}for(var s=0;s<n.length;s++)i(s,n[s])})},o.resolve=function(t){return t&&"object"==typeof t&&t.constructor===o?t:new o(function(e){e(t)})},o.reject=function(t){return new o(function(e,r){r(t)})},o.race=function(t){return new o(function(e,r){for(var n=0,o=t.length;n<o;n++)t[n].then(e,r)})},o._immediateFn="function"==typeof setImmediate&&function(t){setImmediate(t)}||function(t){r(t,0)},o._unhandledRejectionFn=function(t){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)},o._setImmediateFn=function(t){o._immediateFn=t},o._setUnhandledRejectionFn=function(t){o._unhandledRejectionFn=t},t.exports?t.exports=o:e.Promise||(e.Promise=o)}(commonjsGlobal)}),__global=function(){if(void 0!==commonjsGlobal)return commonjsGlobal;if("undefined"!=typeof window)return window;if("undefined"!=typeof self)return self;throw new Error("unable to locate global object")}();function deepCopy(t){return deepExtend(undefined,t)}function deepExtend(t,e){if(!(e instanceof Object))return e;switch(e.constructor){case Date:return new Date(e.getTime());case Object:t===undefined&&(t={});break;case Array:t=[];break;default:return e}for(var r in e)e.hasOwnProperty(r)&&(t[r]=deepExtend(t[r],e[r]));return t}function patchProperty(t,e,r){t[e]=r}"undefined"==typeof Promise&&(__global.Promise=Promise=promise$2),Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(t){if(null==this)throw new TypeError('"this" is null or not defined');var e=Object(this),r=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var n=arguments[1],o=0;o<r;){var i=e[o];if(t.call(n,i,o,e))return i;o++}return undefined}}),Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(t){if(null==this)throw new TypeError('"this" is null or not defined');var e=Object(this),r=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var n=arguments[1],o=0;o<r;){var i=e[o];if(t.call(n,i,o,e))return o;o++}return-1}});var ERROR_NAME="FirebaseError",captureStackTrace=Error.captureStackTrace,FirebaseError=function(){return function(t,e){if(this.code=t,this.message=e,captureStackTrace)captureStackTrace(this,ErrorFactory.prototype.create);else{var r=Error.apply(this,arguments);this.name=ERROR_NAME,Object.defineProperty(this,"stack",{get:function(){return r.stack}})}}}();FirebaseError.prototype=Object.create(Error.prototype),FirebaseError.prototype.constructor=FirebaseError,FirebaseError.prototype.name=ERROR_NAME;var ErrorFactory=function(){function t(t,e,r){this.service=t,this.serviceName=e,this.errors=r,this.pattern=/\{\$([^}]+)}/g}return t.prototype.create=function(t,e){e===undefined&&(e={});var r,n=this.errors[t],o=this.service+"/"+t;r=n===undefined?"Error":n.replace(this.pattern,function(t,r){var n=e[r];return n!==undefined?n.toString():"<"+r+"?>"}),r=this.serviceName+": "+r+" ("+o+").";var i=new FirebaseError(o,r);for(var s in e)e.hasOwnProperty(s)&&"_"!==s.slice(-1)&&(i[s]=e[s]);return i},t}(),Hash=function(){return function(){this.blockSize=-1}}(),__extends=this&&this.__extends||(Ng=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},function(t,e){function r(){this.constructor=t}Ng(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),Ng,Sha1=function(t){function e(){var e=t.call(this)||this;e.chain_=[],e.buf_=[],e.W_=[],e.pad_=[],e.inbuf_=0,e.total_=0,e.blockSize=64,e.pad_[0]=128;for(var r=1;r<e.blockSize;++r)e.pad_[r]=0;return e.reset(),e}return __extends(e,t),e.prototype.reset=function(){this.chain_[0]=1732584193,this.chain_[1]=4023233417,this.chain_[2]=2562383102,this.chain_[3]=271733878,this.chain_[4]=3285377520,this.inbuf_=0,this.total_=0},e.prototype.compress_=function(t,e){e||(e=0);var r=this.W_;if("string"==typeof t)for(var n=0;n<16;n++)r[n]=t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|t.charCodeAt(e+3),e+=4;else for(n=0;n<16;n++)r[n]=t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3],e+=4;for(n=16;n<80;n++){var o=r[n-3]^r[n-8]^r[n-14]^r[n-16];r[n]=4294967295&(o<<1|o>>>31)}var i,s,a=this.chain_[0],u=this.chain_[1],c=this.chain_[2],h=this.chain_[3],l=this.chain_[4];for(n=0;n<80;n++){n<40?n<20?(i=h^u&(c^h),s=1518500249):(i=u^c^h,s=1859775393):n<60?(i=u&c|h&(u|c),s=2400959708):(i=u^c^h,s=3395469782);o=(a<<5|a>>>27)+i+l+s+r[n]&4294967295;l=h,h=c,c=4294967295&(u<<30|u>>>2),u=a,a=o}this.chain_[0]=this.chain_[0]+a&4294967295,this.chain_[1]=this.chain_[1]+u&4294967295,this.chain_[2]=this.chain_[2]+c&4294967295,this.chain_[3]=this.chain_[3]+h&4294967295,this.chain_[4]=this.chain_[4]+l&4294967295},e.prototype.update=function(t,e){if(null!=t){e===undefined&&(e=t.length);for(var r=e-this.blockSize,n=0,o=this.buf_,i=this.inbuf_;n<e;){if(0==i)for(;n<=r;)this.compress_(t,n),n+=this.blockSize;if("string"==typeof t){for(;n<e;)if(o[i]=t.charCodeAt(n),++n,++i==this.blockSize){this.compress_(o),i=0;break}}else for(;n<e;)if(o[i]=t[n],++n,++i==this.blockSize){this.compress_(o),i=0;break}}this.inbuf_=i,this.total_+=e}},e.prototype.digest=function(){var t=[],e=8*this.total_;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(var r=this.blockSize-1;r>=56;r--)this.buf_[r]=255&e,e/=256;this.compress_(this.buf_);var n=0;for(r=0;r<5;r++)for(var o=24;o>=0;o-=8)t[n]=this.chain_[r]>>o&255,++n;return t},e}(Hash);function createSubscribe(t,e){var r=new ObserverProxy(t,e);return r.subscribe.bind(r)}var ObserverProxy=function(){function t(t,e){var r=this;this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=e,this.task.then(function(){t(r)})["catch"](function(t){r.error(t)})}return t.prototype.next=function(t){this.forEachObserver(function(e){e.next(t)})},t.prototype.error=function(t){this.forEachObserver(function(e){e.error(t)}),this.close(t)},t.prototype.complete=function(){this.forEachObserver(function(t){t.complete()}),this.close()},t.prototype.subscribe=function(t,e,r){var n,o=this;if(t===undefined&&e===undefined&&r===undefined)throw new Error("Missing Observer.");(n=implementsAnyMethods(t,["next","error","complete"])?t:{next:t,error:e,complete:r}).next===undefined&&(n.next=noop),n.error===undefined&&(n.error=noop),n.complete===undefined&&(n.complete=noop);var i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(function(){try{o.finalError?n.error(o.finalError):n.complete()}catch(t){}}),this.observers.push(n),i},t.prototype.unsubscribeOne=function(t){this.observers!==undefined&&this.observers[t]!==undefined&&(delete this.observers[t],this.observerCount-=1,0===this.observerCount&&this.onNoObservers!==undefined&&this.onNoObservers(this))},t.prototype.forEachObserver=function(t){if(!this.finalized)for(var e=0;e<this.observers.length;e++)this.sendOne(e,t)},t.prototype.sendOne=function(t,e){var r=this;this.task.then(function(){if(r.observers!==undefined&&r.observers[t]!==undefined)try{e(r.observers[t])}catch(n){"undefined"!=typeof console&&console.error&&console.error(n)}})},t.prototype.close=function(t){var e=this;this.finalized||(this.finalized=!0,t!==undefined&&(this.finalError=t),this.task.then(function(){e.observers=undefined,e.onNoObservers=undefined}))},t}();function implementsAnyMethods(t,e){if("object"!=typeof t||null===t)return!1;for(var r=0,n=e;r<n.length;r++){var o=n[r];if(o in t&&"function"==typeof t[o])return!0}return!1}function noop(){}var contains=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},DEFAULT_ENTRY_NAME="[DEFAULT]",tokenListeners=[],FirebaseAppImpl=function(){function t(t,e,r){this.firebase_=r,this.isDeleted_=!1,this.services_={},this.name_=e,this.options_=deepCopy(t),this.INTERNAL={getUid:function(){return null},getToken:function(){return Promise.resolve(null)},addAuthTokenListener:function(t){tokenListeners.push(t),setTimeout(function(){return t(null)},0)},removeAuthTokenListener:function(t){tokenListeners=tokenListeners.filter(function(e){return e!==t})}}}return Object.defineProperty(t.prototype,"name",{get:function(){return this.checkDestroyed_(),this.name_},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"options",{get:function(){return this.checkDestroyed_(),this.options_},enumerable:!0,configurable:!0}),t.prototype["delete"]=function(){var t=this;return new Promise(function(e){t.checkDestroyed_(),e()}).then(function(){t.firebase_.INTERNAL.removeApp(t.name_);var e=[];return Object.keys(t.services_).forEach(function(r){Object.keys(t.services_[r]).forEach(function(n){e.push(t.services_[r][n])})}),Promise.all(e.map(function(t){return t.INTERNAL["delete"]()}))}).then(function(){t.isDeleted_=!0,t.services_={}})},t.prototype._getService=function(t,e){if(void 0===e&&(e=DEFAULT_ENTRY_NAME),this.checkDestroyed_(),this.services_[t]||(this.services_[t]={}),!this.services_[t][e]){var r=e!==DEFAULT_ENTRY_NAME?e:undefined,n=this.firebase_.INTERNAL.factories[t](this,this.extendApp.bind(this),r);this.services_[t][e]=n}return this.services_[t][e]},t.prototype.extendApp=function(t){var e=this;deepExtend(this,t),t.INTERNAL&&t.INTERNAL.addAuthTokenListener&&(tokenListeners.forEach(function(t){e.INTERNAL.addAuthTokenListener(t)}),tokenListeners=[])},t.prototype.checkDestroyed_=function(){this.isDeleted_&&error("app-deleted",{name:this.name_})},t}();function createFirebaseNamespace(){var t={},e={},r={},n={__esModule:!0,initializeApp:function(e,r){r===undefined?r=DEFAULT_ENTRY_NAME:"string"==typeof r&&""!==r||error("bad-app-name",{name:r+""});contains(t,r)&&error("duplicate-app",{name:r});var o=new FirebaseAppImpl(e,r,n);return t[r]=o,s(o,"create"),o},app:o,apps:null,Promise:Promise,SDK_VERSION:"4.9.0",INTERNAL:{registerService:function(t,s,a,u,c){e[t]&&error("duplicate-service",{name:t});e[t]=s,u&&(r[t]=u,i().forEach(function(t){u("create",t)}));var h=function(e){return void 0===e&&(e=o()),"function"!=typeof e[t]&&error("invalid-app-argument",{name:t}),e[t]()};a!==undefined&&deepExtend(h,a);return n[t]=h,FirebaseAppImpl.prototype[t]=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return this._getService.bind(this,t).apply(this,c?e:[])},h},createFirebaseNamespace:createFirebaseNamespace,extendNamespace:function(t){deepExtend(n,t)},createSubscribe:createSubscribe,ErrorFactory:ErrorFactory,removeApp:function(e){s(t[e],"delete"),delete t[e]},factories:e,useAsService:a,Promise:Promise,deepExtend:deepExtend}};function o(e){return contains(t,e=e||DEFAULT_ENTRY_NAME)||error("no-app",{name:e}),t[e]}function i(){return Object.keys(t).map(function(e){return t[e]})}function s(t,n){Object.keys(e).forEach(function(e){var o=a(t,e);null!==o&&r[o]&&r[o](n,t)})}function a(t,e){if("serverAuth"===e)return null;var r=e;t.options;return r}return patchProperty(n,"default",n),Object.defineProperty(n,"apps",{get:i}),patchProperty(o,"App",FirebaseAppImpl),n}function error(t,e){throw appErrors.create(t,e)}FirebaseAppImpl.prototype.name&&FirebaseAppImpl.prototype.options||FirebaseAppImpl.prototype["delete"]||console.log("dc");var errors={"no-app":"No Firebase App '{$name}' has been created - call Firebase App.initializeApp()","bad-app-name":"Illegal App name: '{$name}","duplicate-app":"Firebase App named '{$name}' already exists","app-deleted":"Firebase App named '{$name}' already deleted","duplicate-service":"Firebase service named '{$name}' already registered","sa-not-supported":"Initializing the Firebase SDK with a service account is only allowed in a Node.js environment. On client devices, you should instead initialize the SDK with an api key and auth domain","invalid-app-argument":"firebase.{$name}() takes either no argument or a Firebase App instance."},appErrors=new ErrorFactory("app","Firebase",errors),firebase=createFirebaseNamespace(),esm=Object.freeze({firebase:firebase,"default":firebase}),require$$1=esm&&firebase||esm,app=require$$1["default"],FirebaseAppConfigToken=new core.InjectionToken("FirebaseAppConfigToken"),FirebaseApp=function(){return function(){}}();function _firebaseAppFactory(t,e){try{return e?undefined(t,e):undefined(t)}catch(r){return"app/duplicate-app"===r.code?undefined(r.name):undefined(null)}}var __window="undefined"!=typeof window&&window,__self="undefined"!=typeof self&&"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&self,__global$1=void 0!==commonjsGlobal&&commonjsGlobal,_root=__window||__global$1||__self,root_1=_root;!function(){if(!_root)throw new Error("RxJS could not find any global context (window, self, global)")}();var root={root:root_1},isArray_1=Array.isArray||function(t){return t&&"number"==typeof t.length},isArray={isArray:isArray_1};function isObject(t){return null!=t&&"object"==typeof t}var isObject_2=isObject,isObject_1={isObject:isObject_2};function isFunction(t){return"function"==typeof t}var isFunction_2=isFunction,isFunction_1={isFunction:isFunction_2},errorObject_1={e:{}},errorObject={errorObject:errorObject_1},tryCatchTarget;function tryCatcher(){try{return tryCatchTarget.apply(this,arguments)}catch(t){return errorObject.errorObject.e=t,errorObject.errorObject}}function tryCatch(t){return tryCatchTarget=t,tryCatcher}var tryCatch_2=tryCatch,tryCatch_1={tryCatch:tryCatch_2},__extends$4=commonjsGlobal&&commonjsGlobal.__extends||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);function n(){this.constructor=t}t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},UnsubscriptionError=function(t){function e(e){t.call(this),this.errors=e;var r=Error.call(this,e?e.length+" errors occurred during unsubscription:\n "+e.map(function(t,e){return e+1+") "+t.toString()}).join("\n "):"");this.name=r.name="UnsubscriptionError",this.stack=r.stack,this.message=r.message}return __extends$4(e,t),e}(Error),UnsubscriptionError_2=UnsubscriptionError,UnsubscriptionError_1={UnsubscriptionError:UnsubscriptionError_2},Subscription=function(){function t(t){this.closed=!1,this._parent=null,this._parents=null,this._subscriptions=null,t&&(this._unsubscribe=t)}var e;return t.prototype.unsubscribe=function(){var t,e=!1;if(!this.closed){var r=this._parent,n=this._parents,o=this._unsubscribe,i=this._subscriptions;this.closed=!0,this._parent=null,this._parents=null,this._subscriptions=null;for(var s=-1,a=n?n.length:0;r;)r.remove(this),r=++s<a&&n[s]||null;if(isFunction_1.isFunction(o))tryCatch_1.tryCatch(o).call(this)===errorObject.errorObject&&(e=!0,t=t||(errorObject.errorObject.e instanceof UnsubscriptionError_1.UnsubscriptionError?flattenUnsubscriptionErrors(errorObject.errorObject.e.errors):[errorObject.errorObject.e]));if(isArray.isArray(i))for(s=-1,a=i.length;++s<a;){var u=i[s];if(isObject_1.isObject(u))if(tryCatch_1.tryCatch(u.unsubscribe).call(u)===errorObject.errorObject){e=!0,t=t||[];var c=errorObject.errorObject.e;c instanceof UnsubscriptionError_1.UnsubscriptionError?t=t.concat(flattenUnsubscriptionErrors(c.errors)):t.push(c)}}if(e)throw new UnsubscriptionError_1.UnsubscriptionError(t)}},t.prototype.add=function(e){if(!e||e===t.EMPTY)return t.EMPTY;if(e===this)return this;var r=e;switch(typeof e){case"function":r=new t(e);case"object":if(r.closed||"function"!=typeof r.unsubscribe)return r;if(this.closed)return r.unsubscribe(),r;if("function"!=typeof r._addParent){var n=r;(r=new t)._subscriptions=[n]}break;default:throw new Error("unrecognized teardown "+e+" added to Subscription.")}return(this._subscriptions||(this._subscriptions=[])).push(r),r._addParent(this),r},t.prototype.remove=function(t){var e=this._subscriptions;if(e){var r=e.indexOf(t);-1!==r&&e.splice(r,1)}},t.prototype._addParent=function(t){var e=this._parent,r=this._parents;e&&e!==t?r?-1===r.indexOf(t)&&r.push(t):this._parents=[t]:this._parent=t},t.EMPTY=((e=new t).closed=!0,e),t}(),Subscription_2=Subscription;function flattenUnsubscriptionErrors(t){return t.reduce(function(t,e){return t.concat(e instanceof UnsubscriptionError_1.UnsubscriptionError?e.errors:e)},[])}var Subscription_1={Subscription:Subscription_2},__extends$3=commonjsGlobal&&commonjsGlobal.__extends||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);function n(){this.constructor=t}t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},Action=function(t){function e(e,r){t.call(this)}return __extends$3(e,t),e.prototype.schedule=function(t,e){return void 0===e&&(e=0),this},e}(Subscription_1.Subscription),Action_2=Action,Action_1={Action:Action_2},__extends$2=commonjsGlobal&&commonjsGlobal.__extends||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);function n(){this.constructor=t}t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},AsyncAction=function(t){function e(e,r){t.call(this,e,r),this.scheduler=e,this.work=r,this.pending=!1}return __extends$2(e,t),e.prototype.schedule=function(t,e){if(void 0===e&&(e=0),this.closed)return this;this.state=t,this.pending=!0;var r=this.id,n=this.scheduler;return null!=r&&(this.id=this.recycleAsyncId(n,r,e)),this.delay=e,this.id=this.id||this.requestAsyncId(n,this.id,e),this},e.prototype.requestAsyncId=function(t,e,r){return void 0===r&&(r=0),root.root.setInterval(t.flush.bind(t,this),r)},e.prototype.recycleAsyncId=function(t,e,r){return void 0===r&&(r=0),null!==r&&this.delay===r&&!1===this.pending?e:root.root.clearInterval(e)&&undefined||undefined},e.prototype.execute=function(t,e){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(t,e);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,e){var r=!1,n=undefined;try{this.work(t)}catch(o){r=!0,n=!!o&&o||new Error(o)}if(r)return this.unsubscribe(),n},e.prototype._unsubscribe=function(){var t=this.id,e=this.scheduler,r=e.actions,n=r.indexOf(this);this.work=null,this.state=null,this.pending=!1,this.scheduler=null,-1!==n&&r.splice(n,1),null!=t&&(this.id=this.recycleAsyncId(e,t,null)),this.delay=null},e}(Action_1.Action),AsyncAction_2=AsyncAction,AsyncAction_1={AsyncAction:AsyncAction_2},__extends$1=commonjsGlobal&&commonjsGlobal.__extends||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);function n(){this.constructor=t}t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},QueueAction=function(t){function e(e,r){t.call(this,e,r),this.scheduler=e,this.work=r}return __extends$1(e,t),e.prototype.schedule=function(e,r){return void 0===r&&(r=0),r>0?t.prototype.schedule.call(this,e,r):(this.delay=r,this.state=e,this.scheduler.flush(this),this)},e.prototype.execute=function(e,r){return r>0||this.closed?t.prototype.execute.call(this,e,r):this._execute(e,r)},e.prototype.requestAsyncId=function(e,r,n){return void 0===n&&(n=0),null!==n&&n>0||null===n&&this.delay>0?t.prototype.requestAsyncId.call(this,e,r,n):e.flush(this)},e}(AsyncAction_1.AsyncAction),QueueAction_2=QueueAction,QueueAction_1={QueueAction:QueueAction_2},Scheduler=function(){function t(e,r){void 0===r&&(r=t.now),this.SchedulerAction=e,this.now=r}return t.prototype.schedule=function(t,e,r){return void 0===e&&(e=0),new this.SchedulerAction(this,t).schedule(r,e)},t.now=Date.now?Date.now:function(){return+new Date},t}(),Scheduler_2=Scheduler,Scheduler_1={Scheduler:Scheduler_2},__extends$6=commonjsGlobal&&commonjsGlobal.__extends||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);function n(){this.constructor=t}t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},AsyncScheduler=function(t){function e(){t.apply(this,arguments),this.actions=[],this.active=!1,this.scheduled=undefined}return __extends$6(e,t),e.prototype.flush=function(t){var e=this.actions;if(this.active)e.push(t);else{var r;this.active=!0;do{if(r=t.execute(t.state,t.delay))break}while(t=e.shift());if(this.active=!1,r){for(;t=e.shift();)t.unsubscribe();throw r}}},e}(Scheduler_1.Scheduler),AsyncScheduler_2=AsyncScheduler,AsyncScheduler_1={AsyncScheduler:AsyncScheduler_2},__extends$5=commonjsGlobal&&commonjsGlobal.__extends||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);function n(){this.constructor=t}t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},QueueScheduler=function(t){function e(){t.apply(this,arguments)}return __extends$5(e,t),e}(AsyncScheduler_1.AsyncScheduler),QueueScheduler_2=QueueScheduler,QueueScheduler_1={QueueScheduler:QueueScheduler_2},queue_1=new QueueScheduler_1.QueueScheduler(QueueAction_1.QueueAction),queue={queue:queue_1},FirebaseAppName=new core.InjectionToken("FirebaseAppName"),FirebaseAppProvider={provide:FirebaseApp,useFactory:_firebaseAppFactory,deps:[FirebaseAppConfigToken,FirebaseAppName]},AngularFireModule=function(){function t(){}return t.initializeApp=function(e,r){return{ngModule:t,providers:[{provide:FirebaseAppConfigToken,useValue:e},{provide:FirebaseAppName,useValue:r}]}},t.decorators=[{type:core.NgModule,args:[{providers:[FirebaseAppProvider]}]}],t.ctorParameters=function(){return[]},t}(),ZoneScheduler=function(){function t(t){this.zone=t}return t.prototype.schedule=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this.zone.run(function(){return queue_1.schedule.apply(queue_1,t)})},t}(),empty={closed:!0,next:function(t){},error:function(t){throw t},complete:function(){}},Observer={empty:empty},rxSubscriber=createCommonjsModule(function(t,e){var r=root.root.Symbol;e.rxSubscriber="function"==typeof r&&"function"==typeof r["for"]?r["for"]("rxSubscriber"):"@@rxSubscriber",e.$$rxSubscriber=e.rxSubscriber}),rxSubscriber_1=rxSubscriber.rxSubscriber,rxSubscriber_2=rxSubscriber.$$rxSubscriber,__extends$9=commonjsGlobal&&commonjsGlobal.__extends||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);function n(){this.constructor=t}t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},Subscriber=function(t){function e(r,n,o){switch(t.call(this),this.syncErrorValue=null,this.syncErrorThrown=!1,this.syncErrorThrowable=!1,this.isStopped=!1,arguments.length){case 0:this.destination=Observer.empty;break;case 1:if(!r){this.destination=Observer.empty;break}if("object"==typeof r){r instanceof e?(this.syncErrorThrowable=r.syncErrorThrowable,this.destination=r,this.destination.add(this)):(this.syncErrorThrowable=!0,this.destination=new SafeSubscriber(this,r));break}default:this.syncErrorThrowable=!0,this.destination=new SafeSubscriber(this,r,n,o)}}return __extends$9(e,t),e.prototype[rxSubscriber.rxSubscriber]=function(){return this},e.create=function(t,r,n){var o=new e(t,r,n);return o.syncErrorThrowable=!1,o},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this))},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){this.destination.error(t),this.unsubscribe()},e.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},e.prototype._unsubscribeAndRecycle=function(){var t=this._parent,e=this._parents;return this._parent=null,this._parents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parent=t,this._parents=e,this},e}(Subscription_1.Subscription),Subscriber_2=Subscriber,SafeSubscriber=function(t){function e(e,r,n,o){var i;t.call(this),this._parentSubscriber=e;var s=this;isFunction_1.isFunction(r)?i=r:r&&(i=r.next,n=r.error,o=r.complete,r!==Observer.empty&&(s=Object.create(r),isFunction_1.isFunction(s.unsubscribe)&&this.add(s.unsubscribe.bind(s)),s.unsubscribe=this.unsubscribe.bind(this))),this._context=s,this._next=i,this._error=n,this._complete=o}return __extends$9(e,t),e.prototype.next=function(t){if(!this.isStopped&&this._next){var e=this._parentSubscriber;e.syncErrorThrowable?this.__tryOrSetError(e,this._next,t)&&this.unsubscribe():this.__tryOrUnsub(this._next,t)}},e.prototype.error=function(t){if(!this.isStopped){var e=this._parentSubscriber;if(this._error)e.syncErrorThrowable?(this.__tryOrSetError(e,this._error,t),this.unsubscribe()):(this.__tryOrUnsub(this._error,t),this.unsubscribe());else{if(!e.syncErrorThrowable)throw this.unsubscribe(),t;e.syncErrorValue=t,e.syncErrorThrown=!0,this.unsubscribe()}}},e.prototype.complete=function(){var t=this;if(!this.isStopped){var e=this._parentSubscriber;if(this._complete){var r=function(){return t._complete.call(t._context)};e.syncErrorThrowable?(this.__tryOrSetError(e,r),this.unsubscribe()):(this.__tryOrUnsub(r),this.unsubscribe())}else this.unsubscribe()}},e.prototype.__tryOrUnsub=function(t,e){try{t.call(this._context,e)}catch(r){throw this.unsubscribe(),r}},e.prototype.__tryOrSetError=function(t,e,r){try{e.call(this._context,r)}catch(n){return t.syncErrorValue=n,t.syncErrorThrown=!0,!0}return!1},e.prototype._unsubscribe=function(){var t=this._parentSubscriber;this._context=null,this._parentSubscriber=null,t.unsubscribe()},e}(Subscriber),Subscriber_1={Subscriber:Subscriber_2},__extends$8=commonjsGlobal&&commonjsGlobal.__extends||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);function n(){this.constructor=t}t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},OuterSubscriber=function(t){function e(){t.apply(this,arguments)}return __extends$8(e,t),e.prototype.notifyNext=function(t,e,r,n,o){this.destination.next(e)},e.prototype.notifyError=function(t,e){this.destination.error(t)},e.prototype.notifyComplete=function(t){this.destination.complete()},e}(Subscriber_1.Subscriber),OuterSubscriber_2=OuterSubscriber,OuterSubscriber_1={OuterSubscriber:OuterSubscriber_2},isArrayLike_1=function(t){return t&&"number"==typeof t.length},isArrayLike={isArrayLike:isArrayLike_1};function isPromise(t){return t&&"function"!=typeof t.subscribe&&"function"==typeof t.then}var isPromise_2=isPromise,isPromise_1={isPromise:isPromise_2};function toSubscriber(t,e,r){if(t){if(t instanceof Subscriber_1.Subscriber)return t;if(t[rxSubscriber.rxSubscriber])return t[rxSubscriber.rxSubscriber]()}return t||e||r?new Subscriber_1.Subscriber(t,e,r):new Subscriber_1.Subscriber(Observer.empty)}var toSubscriber_2=toSubscriber,toSubscriber_1={toSubscriber:toSubscriber_2},observable=createCommonjsModule(function(t,e){function r(t){var e,r=t.Symbol;return"function"==typeof r?r.observable?e=r.observable:(e=r("observable"),r.observable=e):e="@@observable",e}e.getSymbolObservable=r,e.observable=r(root.root),e.$$observable=e.observable}),observable_1=observable.getSymbolObservable,observable_2=observable.observable,observable_3=observable.$$observable;function noop$1(){}var noop_2=noop$1,noop_1={noop:noop_2};function pipe(){for(var t=[],e=0;e<arguments.length;e++)t[e-0]=arguments[e];return pipeFromArray(t)}var pipe_2=pipe;function pipeFromArray(t){return t?1===t.length?t[0]:function(e){return t.reduce(function(t,e){return e(t)},e)}:noop_1.noop}var pipeFromArray_1=pipeFromArray,pipe_1={pipe:pipe_2,pipeFromArray:pipeFromArray_1},Observable$2=function(){function t(t){this._isScalar=!1,t&&(this._subscribe=t)}return t.prototype.lift=function(e){var r=new t;return r.source=this,r.operator=e,r},t.prototype.subscribe=function(t,e,r){var n=this.operator,o=toSubscriber_1.toSubscriber(t,e,r);if(n?n.call(o,this.source):o.add(this.source||!o.syncErrorThrowable?this._subscribe(o):this._trySubscribe(o)),o.syncErrorThrowable&&(o.syncErrorThrowable=!1,o.syncErrorThrown))throw o.syncErrorValue;return o},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.syncErrorThrown=!0,t.syncErrorValue=e,t.error(e)}},t.prototype.forEach=function(t,e){var r=this;if(e||(root.root.Rx&&root.root.Rx.config&&root.root.Rx.config.Promise?e=root.root.Rx.config.Promise:root.root.Promise&&(e=root.root.Promise)),!e)throw new Error("no Promise impl found");return new e(function(e,n){var o;o=r.subscribe(function(e){if(o)try{t(e)}catch(r){n(r),o.unsubscribe()}else t(e)},n,e)})},t.prototype._subscribe=function(t){return this.source.subscribe(t)},t.prototype[observable.observable]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e-0]=arguments[e];return 0===t.length?this:pipe_1.pipeFromArray(t)(this)},t.prototype.toPromise=function(t){var e=this;if(t||(root.root.Rx&&root.root.Rx.config&&root.root.Rx.config.Promise?t=root.root.Rx.config.Promise:root.root.Promise&&(t=root.root.Promise)),!t)throw new Error("no Promise impl found");return new t(function(t,r){var n;e.subscribe(function(t){return n=t},function(t){return r(t)},function(){return t(n)})})},t.create=function(e){return new t(e)},t}(),Observable_2=Observable$2,Observable_1={Observable:Observable_2},iterator=createCommonjsModule(function(t,e){function r(t){var e=t.Symbol;if("function"==typeof e)return e.iterator||(e.iterator=e("iterator polyfill")),e.iterator;var r=t.Set;if(r&&"function"==typeof(new r)["@@iterator"])return"@@iterator";var n=t.Map;if(n)for(var o=Object.getOwnPropertyNames(n.prototype),i=0;i<o.length;++i){var s=o[i];if("entries"!==s&&"size"!==s&&n.prototype[s]===n.prototype.entries)return s}return"@@iterator"}e.symbolIteratorPonyfill=r,e.iterator=r(root.root),e.$$iterator=e.iterator}),iterator_1=iterator.symbolIteratorPonyfill,iterator_2=iterator.iterator,iterator_3=iterator.$$iterator,__extends$10=commonjsGlobal&&commonjsGlobal.__extends||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);function n(){this.constructor=t}t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},InnerSubscriber=function(t){function e(e,r,n){t.call(this),this.parent=e,this.outerValue=r,this.outerIndex=n,this.index=0}return __extends$10(e,t),e.prototype._next=function(t){this.parent.notifyNext(this.outerValue,t,this.outerIndex,this.index++,this)},e.prototype._error=function(t){this.parent.notifyError(t,this),this.unsubscribe()},e.prototype._complete=function(){this.parent.notifyComplete(this),this.unsubscribe()},e}(Subscriber_1.Subscriber),InnerSubscriber_2=InnerSubscriber,InnerSubscriber_1={InnerSubscriber:InnerSubscriber_2};function subscribeToResult(t,e,r,n){var o=new InnerSubscriber_1.InnerSubscriber(t,r,n);if(o.closed)return null;if(e instanceof Observable_1.Observable)return e._isScalar?(o.next(e.value),o.complete(),null):(o.syncErrorThrowable=!0,e.subscribe(o));if(isArrayLike.isArrayLike(e)){for(var i=0,s=e.length;i<s&&!o.closed;i++)o.next(e[i]);o.closed||o.complete()}else{if(isPromise_1.isPromise(e))return e.then(function(t){o.closed||(o.next(t),o.complete())},function(t){return o.error(t)}).then(null,function(t){root.root.setTimeout(function(){throw t})}),o;if(e&&"function"==typeof e[iterator.iterator])for(var a=e[iterator.iterator]();;){var u=a.next();if(u.done){o.complete();break}if(o.next(u.value),o.closed)break}else if(e&&"function"==typeof e[observable.observable]){var c=e[observable.observable]();if("function"==typeof c.subscribe)return c.subscribe(new InnerSubscriber_1.InnerSubscriber(t,r,n));o.error(new TypeError("Provided object does not correctly implement Symbol.observable"))}else{var h="You provided "+(isObject_1.isObject(e)?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.";o.error(new TypeError(h))}}return null}var subscribeToResult_2=subscribeToResult,subscribeToResult_1={subscribeToResult:subscribeToResult_2},__extends$7=commonjsGlobal&&commonjsGlobal.__extends||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);function n(){this.constructor=t}t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},AuditSubscriber=function(t){function e(e,r){t.call(this,e),this.durationSelector=r,this.hasValue=!1}return __extends$7(e,t),e.prototype._next=function(t){if(this.value=t,this.hasValue=!0,!this.throttled){var e=tryCatch_1.tryCatch(this.durationSelector)(t);if(e===errorObject.errorObject)this.destination.error(errorObject.errorObject.e);else{var r=subscribeToResult_1.subscribeToResult(this,e);r.closed?this.clearThrottle():this.add(this.throttled=r)}}},e.prototype.clearThrottle=function(){var t=this.value,e=this.hasValue,r=this.throttled;r&&(this.remove(r),this.throttled=null,r.unsubscribe()),e&&(this.value=null,this.hasValue=!1,this.destination.next(t))},e.prototype.notifyNext=function(t,e,r,n){this.clearThrottle()},e.prototype.notifyComplete=function(){this.clearThrottle()},e}(OuterSubscriber_1.OuterSubscriber),async_1=new AsyncScheduler_1.AsyncScheduler(AsyncAction_1.AsyncAction),async$1={async:async_1};function isNumeric(t){return!isArray.isArray(t)&&t-parseFloat(t)+1>=0}var isNumeric_2=isNumeric,isNumeric_1={isNumeric:isNumeric_2};function isScheduler(t){return t&&"function"==typeof t.schedule}var isScheduler_2=isScheduler,isScheduler_1={isScheduler:isScheduler_2};function isDate(t){return t instanceof Date&&!isNaN(+t)}var isDate_2=isDate,isDate_1={isDate:isDate_2},__extends$11=commonjsGlobal&&commonjsGlobal.__extends||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);function n(){this.constructor=t}t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},TimerObservable=function(t){function e(e,r,n){void 0===e&&(e=0),t.call(this),this.period=-1,this.dueTime=0,isNumeric_1.isNumeric(r)?this.period=Number(r)<1?1:Number(r):isScheduler_1.isScheduler(r)&&(n=r),isScheduler_1.isScheduler(n)||(n=async$1.async),this.scheduler=n,this.dueTime=isDate_1.isDate(e)?+e-this.scheduler.now():e}return __extends$11(e,t),e.create=function(t,r,n){return void 0===t&&(t=0),new e(t,r,n)},e.dispatch=function(t){var e=t.index,r=t.period,n=t.subscriber;if(n.next(e),!n.closed){if(-1===r)return n.complete();t.index=e+1,this.schedule(t,r)}},e.prototype._subscribe=function(t){var r=this.period,n=this.dueTime;return this.scheduler.schedule(e.dispatch,n,{index:0,period:r,subscriber:t})},e}(Observable_1.Observable),__extends$12=commonjsGlobal&&commonjsGlobal.__extends||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);function n(){this.constructor=t}t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},BufferSubscriber=function(t){function e(e,r){t.call(this,e),this.buffer=[],this.add(subscribeToResult_1.subscribeToResult(this,r))}return __extends$12(e,t),e.prototype._next=function(t){this.buffer.push(t)},e.prototype.notifyNext=function(t,e,r,n,o){var i=this.buffer;this.buffer=[],this.destination.next(i)},e}(OuterSubscriber_1.OuterSubscriber),__extends$13=commonjsGlobal&&commonjsGlobal.__extends||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);function n(){this.constructor=t}t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},BufferCountSubscriber=function(t){function e(e,r){t.call(this,e),this.bufferSize=r,this.buffer=[]}return __extends$13(e,t),e.prototype._next=function(t){var e=this.buffer;e.push(t),e.length==this.bufferSize&&(this.destination.next(e),this.buffer=[])},e.prototype._complete=function(){var e=this.buffer;e.length>0&&this.destination.next(e),t.prototype._complete.call(this)},e}(Subscriber_1.Subscriber),BufferSkipCountSubscriber=function(t){function e(e,r,n){t.call(this,e),this.bufferSize=r,this.startBufferEvery=n,this.buffers=[],this.count=0}return __extends$13(e,t),e.prototype._next=function(t){var e=this.bufferSize,r=this.startBufferEvery,n=this.buffers,o=this.count;this.count++,o%r==0&&n.push([]);for(var i=n.length;i--;){var s=n[i];s.push(t),s.length===e&&(n.splice(i,1),this.destination.next(s))}},e.prototype._complete=function(){for(var e=this.buffers,r=this.destination;e.length>0;){var n=e.shift();n.length>0&&r.next(n)}t.prototype._complete.call(this)},e}(Subscriber_1.Subscriber),__extends$14=commonjsGlobal&&commonjsGlobal.__extends||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);function n(){this.constructor=t}t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},Context=function(){return function(){this.buffer=[]}}(),BufferTimeSubscriber=function(t){function e(e,r,n,o,i){t.call(this,e),this.bufferTimeSpan=r,this.bufferCreationInterval=n,this.maxBufferSize=o,this.scheduler=i,this.contexts=[];var s=this.openContext();if(this.timespanOnly=null==n||n<0,this.timespanOnly){var a={subscriber:this,context:s,bufferTimeSpan:r};this.add(s.closeAction=i.schedule(dispatchBufferTimeSpanOnly,r,a))}else{var u={subscriber:this,context:s},c={bufferTimeSpan:r,bufferCreationInterval:n,subscriber:this,scheduler:i};this.add(s.closeAction=i.schedule(dispatchBufferClose,r,u)),this.add(i.schedule(dispatchBufferCreation,n,c))}}return __extends$14(e,t),e.prototype._next=function(t){for(var e,r=this.contexts,n=r.length,o=0;o<n;o++){var i=r[o],s=i.buffer;s.push(t),s.length==this.maxBufferSize&&(e=i)}e&&this.onBufferFull(e)},e.prototype._error=function(e){this.contexts.length=0,t.prototype._error.call(this,e)},e.prototype._complete=function(){for(var e=this.contexts,r=this.destination;e.length>0;){var n=e.shift();r.next(n.buffer)}t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){this.contexts=null},e.prototype.onBufferFull=function(t){this.closeContext(t);var e=t.closeAction;if(e.unsubscribe(),this.remove(e),!this.closed&&this.timespanOnly){t=this.openContext();var r=this.bufferTimeSpan,n={subscriber:this,context:t,bufferTimeSpan:r};this.add(t.closeAction=this.scheduler.schedule(dispatchBufferTimeSpanOnly,r,n))}},e.prototype.openContext=function(){var t=new Context;return this.contexts.push(t),t},e.prototype.closeContext=function(t){this.destination.next(t.buffer);var e=this.contexts;(e?e.indexOf(t):-1)>=0&&e.splice(e.indexOf(t),1)},e}(Subscriber_1.Subscriber);function dispatchBufferTimeSpanOnly(t){var e=t.subscriber,r=t.context;r&&e.closeContext(r),e.closed||(t.context=e.openContext(),t.context.closeAction=this.schedule(t,t.bufferTimeSpan))}function dispatchBufferCreation(t){var e=t.bufferCreationInterval,r=t.bufferTimeSpan,n=t.subscriber,o=t.scheduler,i=n.openContext();n.closed||(n.add(i.closeAction=o.schedule(dispatchBufferClose,r,{subscriber:n,context:i})),this.schedule(t,e))}function dispatchBufferClose(t){var e=t.subscriber,r=t.context;e.closeContext(r)}var __extends$15=commonjsGlobal&&commonjsGlobal.__extends||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);function n(){this.constructor=t}t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},BufferToggleSubscriber=function(t){function e(e,r,n){t.call(this,e),this.openings=r,this.closingSelector=n,this.contexts=[],this.add(subscribeToResult_1.subscribeToResult(this,r))}return __extends$15(e,t),e.prototype._next=function(t){for(var e=this.contexts,r=e.length,n=0;n<r;n++)e[n].buffer.push(t)},e.prototype._error=function(e){for(var r=this.contexts;r.length>0;){var n=r.shift();n.subscription.unsubscribe(),n.buffer=null,n.subscription=null}this.contexts=null,t.prototype._error.call(this,e)},e.prototype._complete=function(){for(var e=this.contexts;e.length>0;){var r=e.shift();this.destination.next(r.buffer),r.subscription.unsubscribe(),r.buffer=null,r.subscription=null}this.contexts=null,t.prototype._complete.call(this)},e.prototype.notifyNext=function(t,e,r,n,o){t?this.closeBuffer(t):this.openBuffer(e)},e.prototype.notifyComplete=function(t){this.closeBuffer(t.context)},e.prototype.openBuffer=function(t){try{var e=this.closingSelector.call(this,t);e&&this.trySubscribe(e)}catch(r){this._error(r)}},e.prototype.closeBuffer=function(t){var e=this.contexts;if(e&&t){var r=t.buffer,n=t.subscription;this.destination.next(r),e.splice(e.indexOf(t),1),this.remove(n),n.unsubscribe()}},e.prototype.trySubscribe=function(t){var e=this.contexts,r=new Subscription_1.Subscription,n={buffer:[],subscription:r};e.push(n);var o=subscribeToResult_1.subscribeToResult(this,t,n);!o||o.closed?this.closeBuffer(n):(o.context=n,this.add(o),r.add(o))},e}(OuterSubscriber_1.OuterSubscriber),__extends$16=commonjsGlobal&&commonjsGlobal.__extends||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);function n(){this.constructor=t}t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},BufferWhenSubscriber=function(t){function e(e,r){t.call(this,e),this.closingSelector=r,this.subscribing=!1,this.openBuffer()}return __extends$16(e,t),e.prototype._next=function(t){this.buffer.push(t)},e.prototype._complete=function(){var e=this.buffer;e&&this.destination.next(e),t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){this.buffer=null,this.subscribing=!1},e.prototype.notifyNext=function(t,e,r,n,o){this.openBuffer()},e.prototype.notifyComplete=function(){this.subscribing?this.complete():this.openBuffer()},e.prototype.openBuffer=function(){var t=this.closingSubscription;t&&(this.remove(t),t.unsubscribe());var e=this.buffer;this.buffer&&this.destination.next(e),this.buffer=[];var r=tryCatch_1.tryCatch(this.closingSelector)();r===errorObject.errorObject?this.error(errorObject.errorObject.e):(t=new Subscription_1.Subscription,this.closingSubscription=t,this.add(t),this.subscribing=!0,t.add(subscribeToResult_1.subscribeToResult(this,r)),this.subscribing=!1)},e}(OuterSubscriber_1.OuterSubscriber),__extends$17=commonjsGlobal&&commonjsGlobal.__extends||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);function n(){this.constructor=t}t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},CatchSubscriber=function(t){function e(e,r,n){t.call(this,e),this.selector=r,this.caught=n}return __extends$17(e,t),e.prototype.error=function(e){if(!this.isStopped){var r=void 0;try{r=this.selector(e,this.caught)}catch(n){return void t.prototype.error.call(this,n)}this._unsubscribeAndRecycle(),this.add(subscribeToResult_1.subscribeToResult(this,r))}},e}(OuterSubscriber_1.OuterSubscriber),__extends$20=commonjsGlobal&&commonjsGlobal.__extends||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);function n(){this.constructor=t}t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},ScalarObservable=function(t){function e(e,r){t.call(this),this.value=e,this.scheduler=r,this._isScalar=!0,r&&(this._isScalar=!1)}return __extends$20(e,t),e.create=function(t,r){return new e(t,r)},e.dispatch=function(t){var e=t.done,r=t.value,n=t.subscriber;e?n.complete():(n.next(r),n.closed||(t.done=!0,this.schedule(t)))},e.prototype._subscribe=function(t){var r=this.value,n=this.scheduler;if(n)return n.schedule(e.dispatch,0,{done:!1,value:r,subscriber:t});t.next(r),t.closed||t.complete()},e}(Observable_1.Observable),ScalarObservable_2=ScalarObservable,ScalarObservable_1={ScalarObservable:ScalarObservable_2},__extends$21=commonjsGlobal&&commonjsGlobal.__extends||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);function n(){this.constructor=t}t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},EmptyObservable=function(t){function e(e){t.call(this),this.scheduler=e}return __extends$21(e,t),e.create=function(t){return new e(t)},e.dispatch=function(t){t.subscriber.complete()},e.prototype._subscribe=function(t){var r=this.scheduler;if(r)return r.schedule(e.dispatch,0,{subscriber:t});t.complete()},e}(Observable_1.Observable),EmptyObservable_2=EmptyObservable,EmptyObservable_1={EmptyObservable:EmptyObservable_2},__extends$19=commonjsGlobal&&commonjsGlobal.__extends||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);function n(){this.constructor=t}t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},ArrayObservable=function(t){function e(e,r){t.call(this),this.array=e,this.scheduler=r,r||1!==e.length||(this._isScalar=!0,this.value=e[0])}return __extends$19(e,t),e.create=function(t,r){return new e(t,r)},e.of=function(){for(var t=[],r=0;r<arguments.length;r++)t[r-0]=arguments[r];var n=t[t.length-1];isScheduler_1.isScheduler(n)?t.pop():n=null;var o=t.length;return o>1?new e(t,n):1===o?new ScalarObservable_1.ScalarObservable(t[0],n):new EmptyObservable_1.EmptyObservable(n)},e.dispatch=function(t){var e=t.array,r=t.index,n=t.count,o=t.subscriber;r>=n?o.complete():(o.next(e[r]),o.closed||(t.index=r+1,this.schedule(t)))},e.prototype._subscribe=function(t){var r=this.array,n=r.length,o=this.scheduler;if(o)return o.schedule(e.dispatch,0,{array:r,index:0,count:n,subscriber:t});for(var i=0;i<n&&!t.closed;i++)t.next(r[i]);t.complete()},e}(Observable_1.Observable),ArrayObservable_2=ArrayObservable,ArrayObservable_1={ArrayObservable:ArrayObservable_2},__extends$18=commonjsGlobal&&commonjsGlobal.__extends||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);function n(){this.constructor=t}t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},none={},CombineLatestSubscriber=function(t){function e(e,r){t.call(this,e),this.project=r,this.active=0,this.values=[],this.observables=[]}return __extends$18(e,t),e.prototype._next=function(t){this.values.push(none),this.observables.push(t)},e.prototype._complete=function(){var t=this.observables,e=t.length;if(0===e)this.destination.complete();else{this.active=e,this.toRespond=e;for(var r=0;r<e;r++){var n=t[r];this.add(subscribeToResult_1.subscribeToResult(this,n,n,r))}}},e.prototype.notifyComplete=function(t){0==(this.active-=1)&&this.destination.complete()},e.prototype.notifyNext=function(t,e,r,n,o){var i=this.values,s=i[r],a=this.toRespond?s===none?--this.toRespond:this.toRespond:0;i[r]=e,0===a&&(this.project?this._tryProject(i):this.destination.next(i.slice()))},e.prototype._tryProject=function(t){var e;try{e=this.project.apply(this,t)}catch(r){return void this.destination.error(r)}this.destination.next(e)},e}(OuterSubscriber_1.OuterSubscriber),__extends$23=commonjsGlobal&&commonjsGlobal.__extends||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);function n(){this.constructor=t}t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},PromiseObservable=function(t){function e(e,r){t.call(this),this.promise=e,this.scheduler=r}return __extends$23(e,t),e.create=function(t,r){return new e(t,r)},e.prototype._subscribe=function(t){var e=this,r=this.promise,n=this.scheduler;if(null==n)this._isScalar?t.closed||(t.next(this.value),t.complete()):r.then(function(r){e.value=r,e._isScalar=!0,t.closed||(t.next(r),t.complete())},function(e){t.closed||t.error(e)}).then(null,function(t){root.root.setTimeout(function(){throw t})});else if(this._isScalar){if(!t.closed)return n.schedule(dispatchNext,0,{value:this.value,subscriber:t})}else r.then(function(r){e.value=r,e._isScalar=!0,t.closed||t.add(n.schedule(dispatchNext,0,{value:r,subscriber:t}))},function(e){t.closed||t.add(n.schedule(dispatchError,0,{err:e,subscriber:t}))}).then(null,function(t){root.root.setTimeout(function(){throw t})})},e}(Observable_1.Observable),PromiseObservable_2=PromiseObservable;function dispatchNext(t){var e=t.value,r=t.subscriber;r.closed||(r.next(e),r.complete())}function dispatchError(t){var e=t.err,r=t.subscriber;r.closed||r.error(e)}var PromiseObservable_1={PromiseObservable:PromiseObservable_2}